@appscode/ui-builder
Version:
## Motivation
1 lines • 7.98 kB
JavaScript
"use strict";var e=require("./wrapper-944ca3a6.js");require("vue"),require("./es.array.concat-5462e385.js"),require("./index-cc93bc29.js"),require("./web.dom-collections.iterator-4a73d869.js"),require("./set-to-string-tag-4a66b282.js"),require("./object-set-prototype-of-f804d831.js");var t=require("./stickyContent-fa0d230c.js");require("./index-80081729.js"),require("./es.function.name-3ad8052c.js"),require("./SingleStepForm-3a723b1b.js");var a=require("./FormElement-d08d9261.js"),r=require("./function-call-mixins-447c7f1f.js"),n={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"}}},o={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:[a.v,r.f],components:{"monaco-editor":function(){return Promise.resolve().then((function(){return require("./vue-monaco.es-5cd68854.js")}))},UbLabelElement:function(){return Promise.resolve().then((function(){return require("./LabelElement-87e1ef84.js")})).then((function(e){return e.default}))}},data:function(){return{showModal:!1,key:"",oldKey:"",value:"",oldValue:"",itemValidationError:""}},computed:e.e(e.e({},e.m({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 t._(t.r.mark((function a(){var r,n;return t.r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="".concat(e.$ubt(e.labelText).replace(/ /g,"-")),t.next=3,e.$refs[r].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(!(n=t.sent)||!n.isInvalid){t.next=12;break}return e.itemValidationError=n.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()}}),a)})))()},onEditorMount:function(){n.setTheme(this.$refs.keyValueModalEditor.monaco.editor,this.editorTheme)}}},i=o,s=e.n({render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("span",[e._ssrNode('<button class="button ac-button is-text is-small p-0 height-16 pl-10">'+e._ssrEscape("\n "+e._s(e.$ubt(e.buttonText))+"\n ")+"</button> "),e.showModal?e._ssrNode('<div class="ac-modal is-action is-medium pt-100">',"</div>",[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 r=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:r.length,expression:"errors.length"}],staticClass:"is-error"},[a("i",{staticClass:"fa fa-exclamation-triangle",attrs:{"aria-hidden":"true"}}),e._v("\n "+e._s(r[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 r=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:r.length,expression:"errors.length"}],staticClass:"is-error"},[a("i",{staticClass:"fa fa-exclamation-triangle",attrs:{"aria-hidden":"true"}}),e._v("\n "+e._s(r[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()],2)},staticRenderFns:[]},void 0,i,void 0,!1,"data-v-229bcc83",!1,void 0,void 0,void 0);exports.default=s;