-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
executable file
·1 lines (1 loc) · 5.3 KB
/
index.js
1
(function(){"use strict";const M="";function r(n,e,t,u,a,o,p,A){var i=typeof n=="function"?n.options:n;e&&(i.render=e,i.staticRenderFns=t,i._compiled=!0),u&&(i.functional=!0),o&&(i._scopeId="data-v-"+o);var s;if(p?(s=function(l){l=l||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!l&&typeof __VUE_SSR_CONTEXT__<"u"&&(l=__VUE_SSR_CONTEXT__),a&&a.call(this,l),l&&l._registeredComponents&&l._registeredComponents.add(p)},i._ssrRegister=s):a&&(s=A?function(){a.call(this,(i.functional?this.parent:this).$root.$options.shadowRoot)}:a),s)if(i.functional){i._injectStyles=s;var x=i.render;i.render=function(F,d){return s.call(d),x(F,d)}}else{var c=i.beforeCreate;i.beforeCreate=c?[].concat(c,s):[s]}return{exports:n,options:i}}const f={props:{value:Object,endpoints:Object,width:String,linkTypes:Array,pages:Object,files:Object},computed:{linkType(){return this.value.type},linkValue(){return this.value.value},showSelect(){return this.linkTypeOptions.length>1},widthPercent(){let n=this.width.split("/"),e=n[0]||1,t=n[1]||1;return e/t*100},uiWidth(){let n=this.widthPercent>=50;return{select:n?"1/4":"1/1",field:this.showSelect?n?"3/4":"1/1":null}},linkTypeOptions(){return this.linkTypes.map(n=>({value:n,text:this.$t(n)}))}},methods:{handleTypeSelect(n){this.$emit("input",{type:n,value:void 0})},handleValueInput(n){this.$emit("input",{value:n})}}};var _=function(){var e=this,t=e._self._c;return t("k-grid",[e.showSelect?t("k-column",{attrs:{width:e.uiWidth.select}},[t("k-select-field",{attrs:{type:"select",value:e.linkType,options:e.linkTypeOptions,empty:!1},on:{input:e.handleTypeSelect}})],1):e._e(),t("k-column",{attrs:{width:e.uiWidth.field}},[e.linkType==="url"?t("k-url-field",{attrs:{value:e.linkValue,placeholder:"https://example.com/"},on:{input:e.handleValueInput}}):e.linkType==="page"?t("k-pages-field",e._b({attrs:{value:e.linkValue,endpoints:{field:this.endpoints.field+"/link-pages"}},on:{input:e.handleValueInput}},"k-pages-field",e.pages,!1)):e.linkType==="file"?t("k-files-field",e._b({attrs:{value:e.linkValue,endpoints:{field:this.endpoints.field+"/link-files"}},on:{input:e.handleValueInput}},"k-files-field",e.files,!1)):e.linkType==="email"?t("k-email-field",{attrs:{value:e.linkValue},on:{input:e.handleValueInput}}):e.linkType==="tel"?t("k-tel-field",{attrs:{value:e.linkValue},on:{input:e.handleValueInput}}):t("k-box",{attrs:{theme:"negative",text:e.$t("error.type",{type:e.linkType})}})],1)],1)},k=[],h=r(f,_,k,!1,null,"1c410ce7",null,null);const v=h.exports,m={props:{value:Object,settings:Object},created(){for(let n in this.settings)for(let e in this.settings[n]){let t=this.settings[n][e];typeof t!="string"||t[0]!=="$"||(this.settings[n][e]=this.$t(t.substr(1)))}},methods:{handleInput(n){this.$emit("input",n)}}};var g=function(){var e=this,t=e._self._c;return t("div",{staticClass:"k-structure-form"},[t("section",[t("k-form",{staticClass:"k-structure-form-fields",attrs:{fields:e.settings},on:{input:e.handleInput},model:{value:e.value,callback:function(u){e.value=u},expression:"value"}})],1)])},y=[],$=r(m,g,y,!1,null,null,null,null);const b=$.exports,T={components:{LinkSelect:v,LinkSettings:b},props:{value:[Object,String],endpoints:Object,width:String,label:String,help:String,disabled:Boolean,required:Boolean,linkTypes:Array,settings:Object,pages:Object,files:Object},data(){return{screen:"link"}},computed:{validValue(){return!this.value||!this.linkTypes.includes(this.value.type)?{type:this.linkTypes[0]}:{...this.value}},isMainScreen(){return this.screen==="link"}},methods:{handleInput(n){this.$emit("input",{...this.validValue,...n})}}};var V=function(){var e=this,t=e._self._c;return t("k-field",e._b({staticClass:"k-link-field"},"k-field",e.$props,!1),[e.settings?t("k-button",{attrs:{slot:"options",icon:e.isMainScreen?"cog":"cancel"},on:{click:function(u){e.screen=e.isMainScreen?"options":"link"}},slot:"options"},[e._v(" "+e._s(e.isMainScreen?e.$t("label.settings"):e.$t("label.close"))+" ")]):e._e(),e.isMainScreen?t("LinkSelect",{attrs:{value:e.validValue,width:e.width,required:e.required,endpoints:e.endpoints,linkTypes:e.linkTypes,pages:e.pages,files:e.files},on:{input:e.handleInput}}):t("LinkSettings",{attrs:{value:e.validValue,settings:e.settings},on:{input:e.handleInput}})],1)},S=[],w=r(T,V,S,!1,null,null,null,null);const O=w.exports,C={props:{value:Object,field:Object},computed:{linkType(){return this.value.type},linkValue(){return this.value.value}},methods:{isArray:Array.isArray,handleLinkClick(n){n.stopImmediatePropagation()}}};var I=function(){var e=this,t=e._self._c;return e.linkValue?t("div",[e.isArray(e.linkValue)?[e.linkType==="page"?t("k-pages-field-preview",e._b({attrs:{value:e.linkValue}},"k-pages-field-preview",e.$props,!1)):e.linkType==="file"?t("k-files-field-preview",e._b({attrs:{value:e.linkValue}},"k-files-field-preview",e.$props,!1)):e._e()]:t("p",{staticClass:"k-structure-table-text k-url-field-preview"},[e.linkType==="url"?t("a",{staticClass:"k-link",attrs:{href:e.linkValue,target:"_blank"},on:{click:e.handleLinkClick}},[e._v(" "+e._s(e.value.text||e.linkValue)+" ")]):[e.value.text?[t("strong",[e._v(e._s(e.value.text))]),e._v(" "+e._s(e.linkValue)+" ")]:[e._v(" "+e._s(e.linkValue)+" ")]]],2)],2):e._e()},j=[],L=r(C,I,j,!1,null,null,null,null);const R=L.exports;panel.plugin("oblik/link-field",{fields:{legacyLink:O},components:{"k-legacyLink-field-preview":R}})})();