forked from Daandelange/kirby3-TranslatedLayout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 18.6 KB
/
index.js
1
(function(){"use strict";const it="";function l(s,t,n,e,i,o,c,nt){var a=typeof s=="function"?s.options:s;t&&(a.render=t,a.staticRenderFns=n,a._compiled=!0),e&&(a.functional=!0),o&&(a._scopeId="data-v-"+o);var u;if(c?(u=function(r){r=r||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!r&&typeof __VUE_SSR_CONTEXT__<"u"&&(r=__VUE_SSR_CONTEXT__),i&&i.call(this,r),r&&r._registeredComponents&&r._registeredComponents.add(c)},a._ssrRegister=u):i&&(u=nt?function(){i.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:i),u)if(a.functional){a._injectStyles=u;var st=a.render;a.render=function(ot,m){return u.call(m),st(ot,m)}}else{var k=a.beforeCreate;a.beforeCreate=k?[].concat(k,u):[u]}return{exports:s,options:a}}const v={props:{blocks:Array,endpoints:Object,fieldsetGroups:Object,fieldsets:Object,id:String,isSelected:Boolean,width:String}};var y=function(){var t=this,n=t._self._c;return n("div",{staticClass:"k-column k-layout-column",attrs:{id:t.id,"data-width":t.width,tabindex:"0"},on:{dblclick:function(e){return t.$refs.blocks.choose(t.blocks.length)}}},[n("k-blocks",{ref:"blocks",attrs:{endpoints:t.endpoints,"fieldset-groups":t.fieldsetGroups,fieldsets:t.fieldsets,value:t.blocks,group:"layout"},on:{input:function(e){return t.$emit("input",e)}},nativeOn:{dblclick:function(e){e.stopPropagation()}}})],1)},b=[],h=l(v,y,b,!1,null,null,null,null);const p=h.exports,at="",g={components:{"k-layout-column":p},props:{attrs:[Array,Object],columns:Array,disabled:Boolean,endpoints:Object,fieldsetGroups:Object,fieldsets:Object,id:String,isSelected:Boolean,settings:Object},computed:{tabs(){let s=this.settings.tabs;return Object.entries(s).forEach(([t,n])=>{Object.entries(n.fields).forEach(([e])=>{s[t].fields[e].endpoints={field:this.endpoints.field+"/fields/"+e,section:this.endpoints.section,model:this.endpoints.model}})}),s}}};var $=function(){var t=this,n=t._self._c;return n("section",{staticClass:"k-layout",attrs:{"data-selected":t.isSelected,tabindex:"0"},on:{click:function(e){return t.$emit("select")}}},[n("k-grid",{staticClass:"k-layout-columns"},t._l(t.columns,function(e,i){return n("k-layout-column",t._b({key:e.id,attrs:{endpoints:t.endpoints,"fieldset-groups":t.fieldsetGroups,fieldsets:t.fieldsets},on:{input:function(o){return t.$emit("updateColumn",{column:e,columnIndex:i,blocks:o})}}},"k-layout-column",e,!1))}),1),t.disabled?t._e():n("nav",{staticClass:"k-layout-toolbar"},[t.settings?n("k-button",{staticClass:"k-layout-toolbar-button",attrs:{tooltip:t.$t("settings"),icon:"settings"},on:{click:function(e){return t.$refs.drawer.open()}}}):t._e(),n("k-dropdown",[n("k-button",{staticClass:"k-layout-toolbar-button",attrs:{icon:"angle-down"},on:{click:function(e){return t.$refs.options.toggle()}}}),n("k-dropdown-content",{ref:"options",attrs:{align:"right"}},[n("k-dropdown-item",{attrs:{icon:"angle-up"},on:{click:function(e){return t.$emit("prepend")}}},[t._v(" "+t._s(t.$t("insert.before"))+" ")]),n("k-dropdown-item",{attrs:{icon:"angle-down"},on:{click:function(e){return t.$emit("append")}}},[t._v(" "+t._s(t.$t("insert.after"))+" ")]),n("hr"),t.settings?n("k-dropdown-item",{attrs:{icon:"settings"},on:{click:function(e){return t.$refs.drawer.open()}}},[t._v(" "+t._s(t.$t("settings"))+" ")]):t._e(),n("k-dropdown-item",{attrs:{icon:"copy"},on:{click:function(e){return t.$emit("duplicate")}}},[t._v(" "+t._s(t.$t("duplicate"))+" ")]),n("hr"),n("k-dropdown-item",{attrs:{icon:"trash"},on:{click:function(e){return t.$refs.confirmRemoveDialog.open()}}},[t._v(" "+t._s(t.$t("field.layout.delete"))+" ")])],1)],1),n("k-sort-handle")],1),t.settings?n("k-form-drawer",{ref:"drawer",staticClass:"k-layout-drawer",attrs:{tabs:t.tabs,title:t.$t("settings"),value:t.attrs,icon:"settings"},on:{input:function(e){return t.$emit("updateAttrs",e)}}}):t._e(),n("k-remove-dialog",{ref:"confirmRemoveDialog",attrs:{text:t.$t("field.layout.delete.confirm")},on:{submit:function(e){return t.$emit("remove")}}})],1)},C=[],w=l(g,$,C,!1,null,null,null,null);const _=w.exports,d={computed:{layoutEditingIsDisabled(){return this.$root.$language?!this.$root.$language.default&&this.isWithinTranslatedComponent:!1},isWithinTranslatedComponent(){let s=this;const t=["translatedblocks","translatedlayout"];for(;s!=this.$root&&s!=null;){if(s.type&&t.includes(s.type))return!0;s=s.$parent}return!1}}},lt="",L={extends:_,components:{"k-layout-column":p},mixins:[d]};var D=function(){var t=this,n=t._self._c;return n("section",{staticClass:"k-layout",attrs:{"data-selected":t.isSelected,tabindex:"0"},on:{click:function(e){return t.$emit("select")}}},[n("k-grid",{staticClass:"k-layout-columns"},t._l(t.columns,function(e,i){return n("k-layout-column",t._b({key:e.id,attrs:{endpoints:t.endpoints,"fieldset-groups":t.fieldsetGroups,fieldsets:t.fieldsets},on:{input:function(o){return t.$emit("updateColumn",{column:e,columnIndex:i,blocks:o})}}},"k-layout-column",e,!1))}),1),t.disabled?t._e():n("nav",{staticClass:"k-layout-toolbar"},[t.settings?n("k-button",{staticClass:"k-layout-toolbar-button",attrs:{tooltip:t.$t("settings"),icon:"settings"},on:{click:function(e){return t.$refs.drawer.open()}}}):t._e(),t.layoutEditingIsDisabled?t._e():n("k-dropdown",[n("k-button",{staticClass:"k-layout-toolbar-button",attrs:{icon:"angle-down"},on:{click:function(e){return t.$refs.options.toggle()}}}),n("k-dropdown-content",{ref:"options",attrs:{align:"right"}},[n("k-dropdown-item",{attrs:{icon:"angle-up"},on:{click:function(e){return t.$emit("prepend")}}},[t._v(" "+t._s(t.$t("insert.before"))+" ")]),n("k-dropdown-item",{attrs:{icon:"angle-down"},on:{click:function(e){return t.$emit("append")}}},[t._v(" "+t._s(t.$t("insert.after"))+" ")]),n("hr"),t.settings?n("k-dropdown-item",{attrs:{icon:"settings"},on:{click:function(e){return t.$refs.drawer.open()}}},[t._v(" "+t._s(t.$t("settings"))+" ")]):t._e(),n("k-dropdown-item",{attrs:{icon:"copy"},on:{click:function(e){return t.$emit("duplicate")}}},[t._v(" "+t._s(t.$t("duplicate"))+" ")]),n("hr"),n("k-dropdown-item",{attrs:{icon:"trash"},on:{click:function(e){return t.$refs.confirmRemoveDialog.open()}}},[t._v(" "+t._s(t.$t("field.layout.delete"))+" ")])],1)],1),t.layoutEditingIsDisabled?t._e():n("k-sort-handle")],1),t.settings?n("k-form-drawer",{ref:"drawer",staticClass:"k-layout-drawer",attrs:{tabs:t.tabs,title:t.$t("settings"),value:t.attrs,icon:"settings"},on:{input:function(e){return t.$emit("updateAttrs",e)}}}):t._e(),n("k-remove-dialog",{ref:"confirmRemoveDialog",attrs:{text:t.$t("field.layout.delete.confirm")},on:{submit:function(e){return t.$emit("remove")}}})],1)},x=[],E=l(L,D,x,!1,null,null,null,null);const I=E.exports,rt="",N={components:{"k-layout":_},props:{disabled:Boolean,empty:String,endpoints:Object,fieldsetGroups:Object,fieldsets:Object,layouts:Array,max:Number,settings:Object,value:Array},data(){return{currentLayout:null,nextIndex:null,rows:this.value,selected:null}},computed:{draggableOptions(){return{id:this._uid,handle:!0,list:this.rows}}},watch:{value(){this.rows=this.value}},methods:{async addLayout(s){let t=await this.$api.post(this.endpoints.field+"/layout",{columns:s});this.rows.splice(this.nextIndex,0,t),this.layouts.length>1&&this.$refs.selector.close(),this.save()},duplicateLayout(s,t){let n={...this.$helper.clone(t),id:this.$helper.uuid()};n.columns=n.columns.map(e=>(e.id=this.$helper.uuid(),e.blocks=e.blocks.map(i=>(i.id=this.$helper.uuid(),i)),e)),this.rows.splice(s+1,0,n),this.save()},removeLayout(s){const t=this.rows.findIndex(n=>n.id===s.id);t!==-1&&this.$delete(this.rows,t),this.save()},save(){this.$emit("input",this.rows)},selectLayout(s){if(this.nextIndex=s,this.layouts.length===1){this.addLayout(this.layouts[0]);return}this.$refs.selector.open()},updateColumn(s){this.rows[s.layoutIndex].columns[s.columnIndex].blocks=s.blocks,this.save()},updateAttrs(s,t){this.rows[s].attrs=t,this.save()}}};var T=function(){var t=this,n=t._self._c;return n("div",[t.rows.length?[n("k-draggable",t._b({staticClass:"k-layouts",on:{sort:t.save}},"k-draggable",t.draggableOptions,!1),t._l(t.rows,function(e,i){return n("k-layout",t._b({key:e.id,attrs:{disabled:t.disabled,endpoints:t.endpoints,"fieldset-groups":t.fieldsetGroups,fieldsets:t.fieldsets,"is-selected":t.selected===e.id,settings:t.settings},on:{append:function(o){return t.selectLayout(i+1)},duplicate:function(o){return t.duplicateLayout(i,e)},prepend:function(o){return t.selectLayout(i)},remove:function(o){return t.removeLayout(e)},select:function(o){t.selected=e.id},updateAttrs:function(o){return t.updateAttrs(i,o)},updateColumn:function(o){return t.updateColumn({layout:e,layoutIndex:i,...o})}}},"k-layout",e,!1))}),1),t.disabled?t._e():n("k-button",{staticClass:"k-field-add-item-button",attrs:{icon:"add",tooltip:t.$t("add")},on:{click:function(e){return t.selectLayout(t.rows.length)}}})]:[n("k-empty",{staticClass:"k-layout-empty",attrs:{icon:"dashboard"},on:{click:function(e){return t.selectLayout(0)}}},[t._v(" "+t._s(t.empty||t.$t("field.layout.empty"))+" ")])],n("k-dialog",{ref:"selector",staticClass:"k-layout-selector",attrs:{"cancel-button":!1,"submit-button":!1,size:"medium"}},[n("k-headline",[t._v(t._s(t.$t("field.layout.select")))]),n("ul",t._l(t.layouts,function(e,i){return n("li",{key:i,staticClass:"k-layout-selector-option"},[n("k-grid",{nativeOn:{click:function(o){return t.addLayout(e)}}},t._l(e,function(o,c){return n("k-column",{key:c,attrs:{width:o}})}),1)],1)}),0)],1)],2)},A=[],F=l(N,T,A,!1,null,null,null,null);const f=F.exports,ut="",O={extends:f,components:{"k-translated-layout":I},mixins:[d],mounted:function(){this.addLayoutNative=f.methods.addLayout,this.removeLayoutNative=f.methods.removeLayout,this.duplicateLayoutNative=f.methods.duplicateLayout,this.selectLayoutNative=f.methods.selectLayout},methods:{async addLayout(s){return this.layoutEditingIsDisabled?null:this.addLayoutNative(s)},duplicateLayout(s,t){return this.layoutEditingIsDisabled?null:this.duplicateLayoutNative(s,t)},removeLayout(s){return this.layoutEditingIsDisabled?null:this.removeLayoutNative(s)},selectLayout(s){return this.layoutEditingIsDisabled?null:this.selectLayoutNative(s)}}};var R=function(){var t=this,n=t._self._c;return n("div",[t.rows.length?[n("k-draggable",t._b({staticClass:"k-layouts",on:{sort:t.save}},"k-draggable",t.draggableOptions,!1),t._l(t.rows,function(e,i){return n("k-translated-layout",t._b({key:e.id,attrs:{disabled:t.disabled,endpoints:t.endpoints,"fieldset-groups":t.fieldsetGroups,fieldsets:t.fieldsets,"is-selected":t.selected===e.id,settings:t.settings},on:{append:function(o){return t.selectLayout(i+1)},duplicate:function(o){return t.duplicateLayout(i,e)},prepend:function(o){return t.selectLayout(i)},remove:function(o){return t.removeLayout(e)},select:function(o){t.selected=e.id},updateAttrs:function(o){return t.updateAttrs(i,o)},updateColumn:function(o){return t.updateColumn({layout:e,layoutIndex:i,...o})}}},"k-translated-layout",e,!1))}),1),t.layoutEditingIsDisabled?t._e():n("k-button",{staticClass:"k-layout-add-button",attrs:{icon:"add"},on:{click:function(e){return t.selectLayout(t.rows.length)}}})]:[n("k-empty",{staticClass:"k-layout-empty",attrs:{icon:"dashboard"},on:{click:function(e){return t.selectLayout(0)}}},[t._v(" "+t._s(t.empty||t.$t("field.layout.empty"))+" ")])],n("k-dialog",{ref:"selector",staticClass:"k-layout-selector",attrs:{"cancel-button":!1,"submit-button":!1,size:"medium"}},[n("k-headline",[t._v(t._s(t.$t("field.layout.select")))]),n("ul",t._l(t.layouts,function(e,i){return n("li",{key:i,staticClass:"k-layout-selector-option"},[n("k-grid",{nativeOn:{click:function(o){return t.addLayout(e)}}},t._l(e,function(o,c){return n("k-column",{key:c,attrs:{width:o}})}),1)],1)}),0)],1)],2)},B=[],S=l(O,R,B,!1,null,null,null,null);const j=S.exports,dt="",G={extends:"k-layout-field",components:{"k-translated-block-layouts":j},mixins:[d]};var K=function(){var t=this,n=t._self._c;return n("k-field",t._b({class:{"k-translated-layout-field":!0,"k-layout-field":!0,"layouts-disabled":t.layoutEditingIsDisabled}},"k-field",t.$props,!1),[n("k-translated-block-layouts",t._b({on:{input:function(e){return t.$emit("input",e)}}},"k-translated-block-layouts",t.$props,!1))],1)},P=[],U=l(G,K,P,!1,null,null,null,null);const W=U.exports,ct="",z={extends:"k-blocks-field",components:{},mixins:[d]};var H=function(){var t=this,n=t._self._c;return n("k-field",t._b({class:{"k-blocks-field":!0,"k-translated-blocks-field":!0,"blocks-disabled":t.layoutEditingIsDisabled},scopedSlots:t._u([{key:"options",fn:function(){return[t.hasFieldsets&&!t.layoutEditingIsDisabled?n("k-dropdown",[n("k-button",{attrs:{icon:"dots"},on:{click:function(e){return t.$refs.options.toggle()}}}),n("k-dropdown-content",{ref:"options",attrs:{align:"right"}},[n("k-dropdown-item",{attrs:{disabled:t.isFull,icon:"add"},on:{click:function(e){return t.$refs.blocks.choose(t.value.length)}}},[t._v(" "+t._s(t.$t("add"))+" ")]),n("hr"),n("k-dropdown-item",{attrs:{disabled:t.isEmpty,icon:"template"},on:{click:function(e){return t.$refs.blocks.copyAll()}}},[t._v(" "+t._s(t.$t("copy.all"))+" ")]),n("k-dropdown-item",{attrs:{disabled:t.isFull,icon:"download"},on:{click:function(e){return t.$refs.blocks.pasteboard()}}},[t._v(" "+t._s(t.$t("paste"))+" ")]),n("hr"),n("k-dropdown-item",{attrs:{disabled:t.isEmpty,icon:"trash"},on:{click:function(e){return t.$refs.blocks.confirmToRemoveAll()}}},[t._v(" "+t._s(t.$t("delete.all"))+" ")])],1)],1):t._e()]},proxy:!0}])},"k-field",t.$props,!1),[t.layoutEditingIsDisabled&&t.isEmpty?n("k-empty",{staticClass:"k-blocks-empty",attrs:{icon:"box"}},[t._v(" "+t._s(t.empty||t.$t("field.blocks.empty"))+" ")]):n("k-blocks",t._g({ref:"blocks",attrs:{autofocus:t.autofocus,compact:!1,empty:t.empty,endpoints:t.endpoints,fieldsets:t.fieldsets,"fieldset-groups":t.fieldsetGroups,group:t.group,max:t.max,value:t.value},on:{close:function(e){t.opened=e},open:function(e){t.opened=e}}},t.$listeners)),!t.isEmpty&&!t.isFull&&!t.layoutEditingIsDisabled?n("k-button",{staticClass:"k-field-add-item-button",attrs:{icon:"add",tooltip:t.$t("add")},on:{click:function(e){return t.$refs.blocks.choose(t.value.length)}}}):t._e()],1)},M=[],V=l(z,H,M,!1,null,null,null,null);const X=V.exports,ft="";var q=l({extends:"k-blocks",name:"k-blocks",mixins:[d],props:{_devInfo:{type:String,default:"Warning: I'm not the default k-blocks. I have been replaced by a k-translated-blocks !"}},mounted(){this.invertCustomAndNativeFunctions(["choose","addToBatch","onKey","onPaste","paste","pasteboard","append","remove","removeAll","convert","move","copyAll","duplicate","chooseToConvert","add","removeAll","removeSelected"])},methods:{invertCustomAndNativeFunctions(s){for(const t of s)this[t+"Native"]||(this[t+"Native"]=this[t],this[t]=this[t+"Custom"])},chooseCustom(s){return this.layoutEditingIsDisabled?null:this.chooseNative(s)},addToBatchCustom(s){return this.layoutEditingIsDisabled?null:this.addToBatchNative(s)},onKeyCustom(s,t=null){if(this.layoutEditingIsDisabled){this.isMultiSelectKey=!1;return}this.onKeyNative(s,t)},onPasteCustom(s){return this.layoutEditingIsDisabled?(s.preventDefault(),s.stopImmediatePropagation(),!1):this.pasteNative(s)},async pasteCustom(s){return this.layoutEditingIsDisabled?(s.preventDefault(),s.stopImmediatePropagation(),!1):this.pasteNative(s)},pasteboardCustom(){return this.layoutEditingIsDisabled?!1:this.pasteboardNative()},appendCustom(s,t){return this.layoutEditingIsDisabled?null:this.appendNative(s,t)},removeCustom(s){return this.layoutEditingIsDisabled?null:this.removeNative(s)},async convertCustom(s,t){return this.layoutEditingIsDisabled?null:this.convertNative(s,t)},chooseToConvert(s){return this.layoutEditingIsDisabled?null:this.chooseToConvert(s)},moveCustom(s){return this.layoutEditingIsDisabled?null:this.moveNative(s)},copyAllCustom(){return this.layoutEditingIsDisabled?null:this.copyAllNative()},async duplicateCustom(s,t){return this.layoutEditingIsDisabled?null:this.duplicateNative(s,t)},async addCustom(s="text",t){return this.layoutEditingIsDisabled?null:this.addNative(s,t)},removeAllCustom(){return this.layoutEditingIsDisabled?null:this.removeAllNative()},removeSelectedCustom(){return this.layoutEditingIsDisabled?null:this.removeSelectedNative()}}},null,null,!1,null,null,null,null);const J=q.exports,mt="",Q={extends:"k-block",mixins:[d],props:{_devInfo:{type:String,default:"Warning: I'm not the default k-block. I have been replaced by a k-translated-block !"}}};var Y=function(){var t=this,n=t._self._c;return n("div",{ref:"container",staticClass:"k-block-container",class:"k-block-container-type-"+t.type,attrs:{"data-batched":t.isBatched,"data-disabled":t.fieldset.disabled,"data-hidden":t.isHidden,"data-id":t.id,"data-last-in-batch":t.isLastInBatch,"data-selected":t.isSelected,"data-translate":t.fieldset.translate,tabindex:"0"},on:{keydown:[function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"down",40,e.key,["Down","ArrowDown"])||!e.ctrlKey||!e.shiftKey?null:(e.preventDefault(),t.$emit("sortDown"))},function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"up",38,e.key,["Up","ArrowUp"])||!e.ctrlKey||!e.shiftKey?null:(e.preventDefault(),t.$emit("sortUp"))}],focus:function(e){return t.$emit("focus")},focusin:t.onFocusIn}},[n("div",{staticClass:"k-block",class:t.className},[n(t.customComponent,t._g(t._b({ref:"editor",tag:"component"},"component",t.$props,!1),t.listeners))],1),t.layoutEditingIsDisabled&&t.isEditable?n("k-dropdown",{staticClass:"k-block-options"},[t.isEditable?n("k-button",{staticClass:"k-block-options-button",attrs:{tooltip:t.$t("edit"),icon:"edit"},on:{click:t.open}}):t._e()],1):n("k-block-options",t._g({ref:"options",attrs:{"is-batched":t.isBatched,"is-editable":t.isEditable,"is-full":t.isFull,"is-hidden":t.isHidden}},t.listeners)),t.isEditable&&!t.isBatched?n("k-form-drawer",{ref:"drawer",staticClass:"k-block-drawer",attrs:{id:t.id,icon:t.fieldset.icon||"box",tabs:t.tabs,title:t.fieldset.name,value:t.content},on:{close:function(e){return t.focus()},input:function(e){return t.$emit("update",e)}},scopedSlots:t._u([{key:"options",fn:function(){return[t.isHidden?n("k-button",{staticClass:"k-drawer-option",attrs:{icon:"hidden"},on:{click:function(e){return t.$emit("show")}}}):t._e(),n("k-button",{staticClass:"k-drawer-option",attrs:{disabled:!t.prev,icon:"angle-left"},on:{click:function(e){return e.preventDefault(),e.stopPropagation(),t.goTo(t.prev)}}}),n("k-button",{staticClass:"k-drawer-option",attrs:{disabled:!t.next,icon:"angle-right"},on:{click:function(e){return e.preventDefault(),e.stopPropagation(),t.goTo(t.next)}}}),n("k-button",{staticClass:"k-drawer-option",attrs:{icon:"trash"},on:{click:function(e){return e.preventDefault(),e.stopPropagation(),t.confirmToRemove.apply(null,arguments)}}})]},proxy:!0}],null,!1,2211169536)}):t._e(),n("k-remove-dialog",{ref:"removeDialog",attrs:{text:t.$t("field.blocks.delete.confirm")},on:{submit:t.remove}})],1)},Z=[],tt=l(Q,Y,Z,!1,null,null,null,null);const et=tt.exports;panel.plugin("daandelange/translatedlayout",{components:{"k-block":et,"k-blocks":J},fields:{translatedlayout:W,translatedblocks:X}})})();