UNPKG

@appscode/ui-builder

Version:
1 lines 7.88 kB
import{e,m as t,n as a}from"./wrapper-5d451278.js";import"vue";import"./es.array.concat-bc6da240.js";import"./index-ba66ec6f.js";import"./web.dom-collections.iterator-98113e95.js";import"./set-to-string-tag-edc1b53a.js";import"./object-set-prototype-of-866dfe15.js";import{_ as o,r as n}from"./stickyContent-c27d9838.js";import"./index-f7c726f7.js";import"./es.function.name-b20a5f0c.js";import"./SingleStepForm-e4a2064c.js";import{v as i}from"./FormElement-3679b8af.js";import{f as r}from"./function-call-mixins-9e1aa828.js";var s={setTheme:function(e,t){e.defineTheme(t,this[t]),e.setTheme(t)},acLightTheme:{base:"vs",inherit:!0,rules:[{foreground:"406040",token:"comment"},{foreground:"c03030",token:"string"},{foreground:"0080a0",token:"constant.numeric"},{fontStyle:"underline",token:"source.ocaml constant.numeric.floating-point"},{foreground:"800000",token:"constant.character"},{foreground:"2060a0",token:"keyword"},{foreground:"2060a0",token:"keyword.operator"},{fontStyle:"underline",token:"source.ocaml keyword.operator.symbol.prefix.floating-point"},{fontStyle:"underline",token:"source.ocaml keyword.operator.symbol.infix.floating-point"},{foreground:"0080ff",token:"entity.name.module"},{foreground:"0080ff",token:"support.other.module"},{foreground:"a08000",token:"storage.type"},{foreground:"008080",token:"storage"},{foreground:"c08060",token:"entity.name.class.variant"},{fontStyle:"bold",token:"keyword.other.directive"},{foreground:"800000",token:"entity.name.function"},{foreground:"800080",token:"storage.type.user-defined"},{foreground:"8000c0",token:"entity.name.type.class.type"},{token:"",background:"F1F1F1"}],colors:{"editor.foreground":"#000000","editor.background":"#F1F1F1","editor.selectionBackground":"#B0B0FF","editor.lineHighlightBackground":"#00000026","editorCursor.foreground":"#000000","editorWhitespace.foreground":"#BFBFBF"}}},l={name:"ub-key-value-modal",props:{label:{type:Object,default:function(){return{}}},title:{type:String,default:""},content:{type:String,default:""},required:{type:Boolean,default:!1},ui:{type:Object,default:function(){return{}}},disabled:{type:Boolean,default:!1},disabledValidation:{type:Boolean,default:!1},buttonText:{type:String,default:"buttons.view_more"},newItemValidator:{type:String,default:""}},mixins:[i,r],components:{"monaco-editor":function(){return import("./vue-monaco.es-220f6092.js")},UbLabelElement:function(){return import("./LabelElement-d1b528f2.js").then((function(e){return e.default}))}},data:function(){return{showModal:!1,key:"",oldKey:"",value:"",oldValue:"",itemValidationError:""}},computed:e(e({},t({editorTheme:"editorTheme"})),{},{editorOptionsFile:function(){var e={minimap:{enabled:!1},wordWrap:!0};return!0===this.disabled&&(e.readOnly=!0),e},labelText:function(){return this.label.text||"label"},keysLabel:function(){var e;return(null===(e=this.ui.keys)||void 0===e?void 0:e.label)||{}},valuesLabel:function(){var e;return(null===(e=this.ui.values)||void 0===e?void 0:e.label)||{}},keysLabelText:function(){return this.keysLabel.text||"label"},valuesLabelText:function(){return this.valuesLabel.text||"label"}}),watch:{title:{immediate:!0,handler:function(e){this.key=e,this.oldKey=e}},content:{immediate:!0,handler:function(e){this.value=e,this.oldValue=e}},showModal:{immediate:!0,handler:function(e){e||(this.itemValidationError="")}}},methods:{saveKeyValue:function(){var e=this;return o(n.mark((function t(){var a,o;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a="".concat(e.$ubt(e.labelText).replace(/ /g,"-")),t.next=3,e.$refs[a].validate();case 3:if(!t.sent){t.next=15;break}if(!e.newItemValidator){t.next=12;break}return t.next=8,e.performFuncCall(e.newItemValidator,{key:e.key,value:e.value});case 8:if(!(o=t.sent)||!o.isInvalid){t.next=12;break}return e.itemValidationError=o.message,t.abrupt("return");case 12:e.itemValidationError="",e.$emit("save",{oldKey:e.oldKey,oldValue:e.oldValue,newKey:e.key,newValue:e.value,isUpdate:!0}),e.showModal=!1;case 15:case"end":return t.stop()}}),t)})))()},onEditorMount:function(){s.setTheme(this.$refs.keyValueModalEditor.monaco.editor,this.editorTheme)}}},d=a({render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("span",[a("button",{staticClass:"button ac-button is-text is-small p-0 height-16 pl-10",on:{click:function(t){t.preventDefault(),e.showModal=!0}}},[e._v("\n "+e._s(e.$ubt(e.buttonText))+"\n ")]),e._v(" "),e.showModal?a("div",{staticClass:"ac-modal is-action is-medium pt-100"},[a("validation-observer",{ref:""+e.$ubt(e.labelText).replace(/ /g,"-"),staticClass:"key-value-modal",attrs:{disabled:e.disabledValidation,slim:""}},[a("div",{staticClass:"ac-modal-inner"},[a("div",{staticClass:"ac-modal-header"},[a("ub-label-element",{attrs:{label:e.label,errors:e.itemValidationError?[e.itemValidationError]:[]}}),e._v(" "),a("div",{staticClass:"ms-close-button is-pulled-right"},[a("div",{staticClass:"buttons"},[a("button",{staticClass:"is-transparent",on:{click:function(t){t.preventDefault(),e.showModal=!1}}},[a("img",{attrs:{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEgMUwxNS4yMjIyIDE1LjIyMjJNMTUuMjIyMiAxTDEgMTUuMjIyMiIgc3Ryb2tlPSIjNTQ2NTdFIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+Cjwvc3ZnPg==",alt:"close-icon"}})])])])],1),e._v(" "),a("div",{staticClass:"ac-modal-body"},[a("div",{staticClass:"ac-modal-content"},[a("div",{staticClass:"ac-code-preview-wrapper is-border-none"},[a("div",{staticClass:"ac-code-body"},[a("div",{staticClass:"ac-code-inner"},[a("ub-label-element",{attrs:{label:e.keysLabel}}),e._v(" "),a("validation-provider",{attrs:{rules:e.required?"required":"",name:e.$ubt(e.keysLabelText),slim:""},scopedSlots:e._u([{key:"default",fn:function(t){var o=t.errors;return[a("div",{staticClass:"ac-single-input is-small"},[a("input",{directives:[{name:"model",rawName:"v-model",value:e.key,expression:"key"}],staticClass:"ac-input",domProps:{value:e.key},on:{input:function(t){t.target.composing||(e.key=t.target.value)}}}),e._v(" "),a("p",{directives:[{name:"show",rawName:"v-show",value:o.length,expression:"errors.length"}],staticClass:"is-error"},[a("i",{staticClass:"fa fa-exclamation-triangle",attrs:{"aria-hidden":"true"}}),e._v("\n "+e._s(o[0])+"\n ")])])]}}],null,!1,480904758)}),e._v(" "),a("ub-label-element",{attrs:{label:e.valuesLabel}}),e._v(" "),a("validation-provider",{attrs:{rules:e.required?"required":"",name:e.$ubt(e.valuesLabelText),slim:""},scopedSlots:e._u([{key:"default",fn:function(t){var o=t.errors;return[a("monaco-editor",{ref:"keyValueModalEditor",staticClass:"editor-writable vh-50 is-clipped",attrs:{options:e.editorOptionsFile,language:"json",theme:e.editorTheme},on:{editorDidMount:e.onEditorMount},model:{value:e.value,callback:function(t){e.value=t},expression:"value"}}),e._v(" "),a("p",{directives:[{name:"show",rawName:"v-show",value:o.length,expression:"errors.length"}],staticClass:"is-error"},[a("i",{staticClass:"fa fa-exclamation-triangle",attrs:{"aria-hidden":"true"}}),e._v("\n "+e._s(o[0])+"\n ")])]}}],null,!1,1887324534)})],1)])])])]),e._v(" "),a("div",{staticClass:"ac-modal-footer action-footer"},[a("div",{staticClass:"buttons has-text-right is-block"},[a("button",{staticClass:"button ac-button",on:{click:function(t){t.preventDefault(),e.showModal=!1}}},[e._v("\n Cancel\n ")]),e._v(" "),a("button",{staticClass:"button ac-button is-primary",class:{"is-disabled":e.disabled},attrs:{disabled:e.disabled},on:{click:function(t){return t.preventDefault(),e.saveKeyValue(t)}}},[e._v("\n Save\n ")])])])])])],1):e._e()])},staticRenderFns:[]},void 0,l,void 0,!1,void 0,!1,void 0,void 0,void 0);export default d;