@syncfusion/ej2-vue-base
Version:
A common package of Essential JS 2 base Vue libraries, methods and class definitions
12 lines (11 loc) • 16.2 kB
JavaScript
/*!
* filename: ej2-vue-base.umd.min.js
* version : 31.1.17
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue"),require("@syncfusion/ej2-base")):"function"==typeof define&&define.amd?define(["exports","vue","@syncfusion/ej2-base"],t):t((e=e||self).ej={},e.Vue,e.ej2Base)}(this,function(e,t,M){"use strict";function n(e){return k?N.extend(e):N.defineComponent(e)}var t=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[""+n]=e[""+n]);return t.default=e,t}(t),k=!(2<parseInt(t.version,10)),N=k?t.default.default||t.default:t,t=t.h,s=n({name:"ComponentBase",data:function(){return{tagMapper:{},tagNameMapper:{},hasInjectedModules:!1,hasChildDirective:!1,childDirObjects:"",propKeys:{},isDecorator:!1}},created:function(){var n=this;if(this.ej2Instance&&(this.ej2Instances=this.isVue3?N.toRaw(this.ej2Instance):this.ej2Instance),this.propKeys){for(var e=this,t=0,s=this.propKeys;t<s.length;t++)!function(t){e.ej2Instances.addEventListener(t,function(e){n.$emit(t,e)})}(s[t]);var r=M.getValue("$root.$options.provide",this),i=M.getValue("$parent.$options.provide",this),i=M.isNullOrUndefined(i)?M.getValue("$.parent.provides",this):i;if(this.hasInjectedModules&&!k){var a=[];r&&r.managed?(this.isDecorator=!0,a=this.getInjectedServices()||[]):r?a=r[this.ej2Instances.getModuleName()]||[]:i&&(a=this.getInjectedServices()||[]);for(var o=0,p=this.ej2Instances.getInjectedModules()||[];o<p.length;o++){var l=p[o];-1===a.indexOf(l)&&a.push(l)}this.ej2Instances.injectedModules=a}}},mounted:function(){var e=this.$el?this.$el.querySelectorAll("div.e-directive"):null;if(!k&&e)for(var t=0;t<e.length;t++){var n=e[parseInt(t.toString(),10)];n.parentElement&&n.parentElement.removeChild(n)}this.ej2Instances.isVue=!0,this.ej2Instances.isVue3=this.isVue3,(this.ej2Instances.vueInstance=this).isVue3&&(this.ej2Instances.ej2Instances=this.ej2Instances,this.ej2Instances.referModels=this.models,this.setModelValue()),this.ej2Instances.appendTo(this.$el)},updated:function(){this.updated()},beforeDestroy:function(){this.destroyComponent()},beforeUnmount:function(){this.destroyComponent()},methods:{setModelValue:function(){var e;M.isNullOrUndefined(this.modelValue)&&M.isNullOrUndefined(this.$attrs.modelValue)||(e=(this.models.toString().match(/checked|value/)||[])[0],M.isNullOrUndefined(e))||(this.ej2Instances[""+e]=(M.isNullOrUndefined(this.modelValue)?this.$attrs:this).modelValue)},updated:function(){var e,t;this.isVue3&&this.setModelValue(),this.hasChildDirective&&(this.fetchChildPropValues(e={}),t=JSON.stringify(e),this.childDirObjects!==t)&&(this.childDirObjects=t,this.assignValueToWrapper(e,!1))},getInjectedServices:function(){var e,t=[];if(this.$root&&this.isDecorator?e=M.getValue("$root.$options.provide",this):this.$vnode?e=M.getValue("$vnode.context.$options.provide",this):this.$parent&&(e=M.getValue("$parent.$options.provide",this)),e=M.isNullOrUndefined(e)&&!M.isNullOrUndefined(this.$)?M.getValue("$.parent.provides",this):e){var n=e;if("function"==typeof e)if(e.managed){var s=e.managed,r=Object.keys(s),i=void 0;this.$root&&this.isDecorator?i=Object.keys(this.$root):this.$vnode?i=Object.keys(this.$vnode.context):this.$parent&&(i=Object.keys(this.$parent));for(var a=0;a<r.length;a++)for(var o=0;o<i.length;o++)-1!==i[parseInt(o.toString(),10)].indexOf(r[parseInt(a.toString(),10)])&&(this.$root&&this.isDecorator?s[r[parseInt(o.toString(),10)]]=this.$root[i[parseInt(a.toString(),10)]]:this.$vnode?s[r[parseInt(a.toString(),10)]]=this.$vnode.context[i[parseInt(o.toString(),10)]]:this.$parent&&(s[r[parseInt(a.toString(),10)]]=this.$parent[i[parseInt(o.toString(),10)]]),n=s)}else this.$vnode?n=this.$vnode.context.$options.provide():this.$parent&&(n=this.$parent.$options.provide());t=n[this.ej2Instances.getModuleName()]||[]}return this.isDecorator=!1,t},destroyComponent:function(){this.ej2Instances.destroy(),this.$el.style.visibility="hidden",this.clearTemplate()},destroyPortals:function(e){if(e){if(M.getValue("__vue__.$destroy",e))e.__vue__.$destroy();else if(!k&&e._vnode)try{N.render(null,e)}catch(e){}e.innerHTML&&(e.innerHTML="")}},bindProperties:function(){for(var e={},t=0,n=this.propKeys;t<n.length;t++){var s=n[t];M.isNullOrUndefined(this[""+s])?!this[0]||M.isNullOrUndefined(this[0][0])||M.isNullOrUndefined(this[0][0][""+s])||(e[""+s]=this[0][0][""+s]):e[""+s]=this[""+s]}if(this.hasChildDirective&&this.fetchChildPropValues(e),this.hasInjectedModules){for(var r=this.getInjectedServices()||[],i=0,a=this.ej2Instances.getInjectedModules()||[];i<a.length;i++){var o=a[i];-1===r.indexOf(o)&&r.push(o)}this.ej2Instances.injectedModules=r}this.assignValueToWrapper(e)},assignValueToWrapper:function(e,t){this.ej2Instances.setProperties(M.extend({},{},e,!0),!!M.isNullOrUndefined(t)||t)},fetchChildPropValues:function(e){var t={};if(this.isVue3){var n=void 0;if(this[0]&&this[0][1].slots.default?n=this[0][1].slots.default():this&&this.$&&this.$.slots&&this.$.slots.default&&(n=this.$.slots.default()),!n)return;for(var s,r,i,a,o=0;o<n.length;o++)!n[parseInt(o.toString(),10)].type.methods&&"e-seriescollection"!==n[parseInt(o.toString(),10)].type||(s="e-seriescollection"===n[parseInt(o.toString(),10)].type?"series-collection":n[parseInt(o.toString(),10)].type.methods.getTag().replace("e-",""),r=this.resolveArrayDirectives(n[parseInt(o.toString(),10)].children,s),a=s.split("-"),i=this.ej2Instances.getModuleName().toLowerCase(),a=(a=1<a.length&&-1<i.indexOf(a[0])?a[1]:a[0]).replace(i,""),a=this.tagNameMapper["e-"+s]?this.tagNameMapper["e-"+s].replace("e-",""):a,"splitter"===i&&"panes"===a?a="paneSettings":"bulletchart"===i&&"range"===a?a="ranges":"schedule"===i&&"header"===a&&(a="headerRows"),t[""+a]=r[""+s])}else t=this.getDirectiveValues(this.$slots.default,this.tagMapper||{},this.tagNameMapper||{});this.childDirObjects||(this.childDirObjects=JSON.stringify(t));for(var p=0,l=Object.keys(t);p<l.length;p++){var c=l[p];e[""+c]=t[""+c]}},resolveArrayDirectives:function(e,i){var a,t=[];t=(t=e.default?e.default():e).flatMap(function(e){return Array.isArray(e.children)?e.children:e});for(var o={},p=(o[""+i]=[],this),n=0,s=t;n<s.length;n++)!function(n){var s={},e=n.type.methods?n.type.methods.getTag():i;if(n.children){var t;if((a=p.resolveComplexDirs(n.children,p.tagMapper["e-"+i],e)).length)s=a;else for(var r=0;r<Object.keys(a).length;r++)t=Object.keys(a)[parseInt(r.toString(),10)],s[""+t]=a[""+t]}n.props&&Object.keys(n.props).forEach(function(e){var t=e.replace(/-[a-z]/g,function(e){return e[1].toUpperCase()});t&&(s[""+t]=n.props[""+e])}),/[s]\b/.test(e)&&a&&(!/[s]\b/.test(i)||a.length)?Array.isArray(s)?s.forEach(function(e){o[""+i].push(e)}):o[""+i].push(s):s&&0!==Object.keys(s).length&&o[""+i].push(s)}(s[n]);return o},resolveComplexDirs:function(e,n,s){for(var r,i=[],i=e.default?e.default():e,a={},o=this,t=0,p=i;t<p.length;t++)!function(t){var e=void 0;n[""+s]&&(e=(e=Object.keys(n[""+s]).find(function(e){return n[""+s][""+e]===t.type.methods.getTag().replace(/[s]\b/,"")}))||t.type.methods.getTag(),e=(o.tagNameMapper[""+e]||e).replace("e-",""),"diagram"===o.ej2Instances.getModuleName().toLowerCase())&&-1!==e.indexOf("annotations")&&(e="annotations"),t.children&&(r=o.resolveComplexInnerDirs(t.children,n[""+s],t.type.methods.getTag()),a[""+e]||(a[""+e]=[]),1<r.length?a[""+e]=r:a[""+e].push(r)),t.props&&(t.props=o.getCamelCaseProps(t.props)),1<i.length?(a=0!==Object.keys(a).length||a.length?a:[],t.props&&a.push(t.props)):a=t.props?Object.assign(a,t.props):a}(p[t]);return a},resolveComplexInnerDirs:function(e,t,n){for(var s,r=1<(s=e.default?e.default():e).length?[]:{},i=0,a=s;i<a.length;i++){var o=a[i],p=null,l=o.type.methods.getTag(),l=(this.tagNameMapper[""+l]||l).replace("e-","");o.children&&(p=this.resolveMultilevelComplexInnerDirs(o.children,t[""+n],o.type.methods.getTag()),/[s]\b/.test(l)||1<s.length?/[s]\b/.test(l)?(r[""+l]=r[""+l]||[],p.length?r[""+l]=p:r[""+l].push(p)):p&&!o.props&&r.push(p):r=p||r),o.props&&(o.props=this.getCamelCaseProps(o.props)),1<s.length&&o.props?p?(p=o.props?Object.assign(p,o.props):p,r.push(p)):0<=r.length?r.push(o.props):r=o.props?Object.assign(r,o.props):r:r=o.props?Object.assign(r,o.props):r}return r},resolveMultilevelComplexInnerDirs:function(e,t,n){for(var s=1<(e=e.default?e.default():e).length?[]:{},r=0,i=e;r<i.length;r++){var a=i[r],o=null,p=a.type.methods.getTag(),p=(this.tagNameMapper[""+p]||p).replace("e-","");a.children&&(o=this.resolveComplexInnerDirs(a.children,t[""+n],a.type.methods.getTag())),a.props&&(a.props=this.getCamelCaseProps(a.props)),/[s]\b/.test(p)?(s[""+p]=s[""+p]||[],o.length?s[""+p]=o:s[""+p].push(o),a.props&&s[""+p].push(a.props)):(s=o,s=a.props?Object.assign(s,a.props):s)}return s},getDirectiveValues:function(e,t,n){var s=Object.keys(t),r={};if(e)for(var i=0,a=e;i<a.length;i++){var o=a[i],p=o.componentOptions;if(p&&p.children&&this.getTagName(p)||"e-seriescollection"===o.tag&&o.children){var l=p?this.getTagName(p):o.tag;if(-1!==s.indexOf(l="e-seriescollection"===l?"e-seriesCollection":l)){var c=n[""+l]||l;r[c.replace("e-","")]=[];for(var d=0,h=(p||o).children;d<h.length;d++){var u=h[d],u=this.getVNodeValue(u,t[""+l],n);0!==Object.keys(u).length&&r[c.replace("e-","")].push(u)}}}}return r},getMultiLevelDirValue:function(e,t,n){for(var s={},r=0,i=e;r<i.length;r++){var a=i[r],o=void 0,p=void 0;if(a.componentOptions?(o=this.getTagName(a.componentOptions),a.componentOptions.children&&(p=a.componentOptions.children)):"e-markersettings"!==a.tag&&"e-markersetting"!==a.tag||!a.children||(o="e-markersettings"===a.tag?"e-markerSettings":"e-markerSetting",p=a.children),o){var l=n[""+o]||o;if(s[l.replace("e-","")]=[],p)for(var c=0,d=p;c<d.length;c++){var h=d[c],h=this.getVNodeValue(h,t[""+o],n);0!==Object.keys(h).length&&s[l.replace("e-","")].push(h)}}}return s},getVNodeValue:function(e,t,n){var s,r,i={};return(e.componentOptions||("e-markersettings"===e.tag||"e-markersetting"===e.tag)&&e.context)&&(s=void 0,s=e.componentOptions?this.getTagName(e.componentOptions):"e-markersettings"===e.tag?"e-markerSettings":"e-markerSetting",r=e.data,"string"==typeof t&&s===t&&r?i=r.attrs?this.getCamelCaseProps(r.attrs):this.getCamelCaseProps(r):"object"==typeof t&&(e.componentOptions.children&&-1!==Object.keys(t).indexOf(s)?i=this.getMultiLevelDirValue(e.componentOptions.children,t[""+s],n):!e.children||-1===Object.keys(t).indexOf(s)||"e-markersettings"!==s&&"e-markersetting"!==s||(i=this.getMultiLevelDirValue(e.children,t[""+s],n)),r)&&r.attrs&&(i=M.extend(i,this.getCamelCaseProps(r.attrs)))),i},getCamelCaseProps:function(e){for(var t={},n=0,s=Object.keys(e);n<s.length;n++){var r=s[n];t[r.replace(/-[a-z]/g,function(e){return e[1].toUpperCase()})]=e[""+r]}return t},dataBind:function(){this.ej2Instances.dataBind()},setProperties:function(e,t){return this.ej2Instances.setProperties(e,t)},getTagName:function(e){var t=e.tag,n=e.Ctor;return t=!t&&n&&n.extendOptions&&n.extendOptions.methods&&n.extendOptions.methods.getTag?e.Ctor.extendOptions.methods.getTag():t}}});k||M.setProxyToRaw(N.toRaw);var S=function(){return(S=Object.assign||function(e){for(var t,n=1,s=arguments.length;n<s;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},T=M.getTemplateEngine();function r(x,V){var D=this;return function(e,t,n,s,r){var i;if(t){var a=t.vueInstance&&t.vueInstance.plugins?{plugins:t.vueInstance.plugins}:{},o=t.vueInstance||(r&&r.vueInstance?r.vueInstance:null),p=M.getUniqueID("templateParentDiv"),l=M.getUniqueID("templateDiv"),p=M.createElement("div",{id:p,innerHTML:'<div id="'+l+'"></div>'});if(document.body.appendChild(p),!k&&("string"==typeof x||x.prototype&&x.prototype.CSPTemplate&&"function"==typeof x)){var c=function(e,t,n){if(e||n&&n.vueInstance)return function e(t,n){{if(t&&t[""+n])return t;if(t&&t.default){var s=t.default();s=s.flatMap(function(e){return Array.isArray(e.children)?e.children:e});for(var r=0;r<s.length;r++){var i=e(s[parseInt(r.toString(),10)].children,n);if(i)return i}}}return}((n&&n.vueInstance?n.vueInstance:e).$slots,t)}(t.vueInstance,x,r);if(!c)return M.detach(p),T(x,V)(e);var d=N.createVNode({render:function(){return c[""+x]({data:e})}},a);p.innerHTML="",_(d,t.vueInstance,r),N.render(d,p),i=p.childNodes,o&&(($=o.templateCollection)||(o.templateCollection={},$=o.templateCollection),n)&&($[""+n]||($[""+n]=[]),$[""+n].push(p))}else if(k)if("string"==typeof x||x.prototype&&x.prototype.CSPTemplate&&"function"==typeof x){var h=function(e,t,n){if(e||n&&n.vueInstance)return function e(t,n){if(!t)return;var s=t.$slots;var r=t.$scopedSlots;var i=t.scopedSlots;var a=t.children;{if(r&&r[""+n])return r;if(s&&s.default){for(var o=s.default,p=0;p<o.length;p++)if(l=e(P(o[parseInt(p.toString(),10)]),n))return l}else{if(i&&i[""+n])return i;if(a)for(var l,p=0;p<a.length;p++)if(l=e(P(a[parseInt(p.toString(),10)]),n))return l}}return}(n&&n.vueInstance?n.vueInstance:e,t)}(t.vueInstance,x,r);if(!h)return M.detach(p),T(x,V)(e);var u={},f=function(e){e.$parent&&f(e.$parent),e._provided&&0<Object.keys(e._provided).length&&(u=S({},u,e._provided))},g=t.vueInstance||(r&&r.vueInstance?r.vueInstance:null);g&&f(g),new N({provide:S({},u),render:function(){return h[""+x]({data:e})}}).$mount("#"+l),i=p.childNodes,g&&(($=g.templateCollection)||(g.templateCollection={},$=g.templateCollection),n)&&($[""+n]||($[""+n]=[]),$[""+n].push(i[0]))}else{var g=(j=x.call(D,{})).template,v=M.getValue("template.propsData",j),m={data:{data:M.extend(j.data||{},e)},parent:t.vueInstance};v&&(g=j.template.extends,m.propsData=v),(g="function"!=typeof g?N.extend(g):g).options.setup&&(m.propsData=Object.assign(m.propsData||{},e)),new g(m).$mount("#"+l),i=p.childNodes,m.parent=null,o&&(($=o.templateCollection)||(o.templateCollection={},$=o.templateCollection),n)&&($[""+n]||($[""+n]=[]),$[""+n].push(i[0]))}else{var j,I,g=j=x.call(D,{}),v=M.getValue("template.propsData",j),y={data:{data:M.extend(j.data||{},e)},parent:t.vueInstance},O=(g.template||(g.template=g[Object.keys(g)[0]]),void 0);if(g.template.extends?O=g.template.extends._context.components.template:(O=g.template._context.components[x.name])||(l=Object.keys(g.template._context.components)[0],O=g.template._context.components[""+l]),v)I=O.setup?Object.assign({},v):Object.assign(O.data(),v);else if(I=O.setup?Object.assign({},y.data):Object.assign(O.data(),y.data),O.components)for(var C=0,b=Object.keys(O.components)||[];C<b.length;C++)!function(e){var t=O.components[""+e];t&&t.data&&(t.__data||(t.__data=t.data),t.data=function(e){return Object.assign(t.__data.call(e),y.data)})}(b[C]);O.setup&&(a=Object.assign(a,e)),O.data=function(){return I};var $,d=N.createVNode(O,a);p.innerHTML="",_(d,t.vueInstance,r),N.render(d,p),i=p.childNodes,y.parent=null,o&&(($=o.templateCollection)||(o.templateCollection={},$=o.templateCollection),n)&&($[""+n]||($[""+n]=[]),$[""+n].push(p))}M.detach(p)}return i||[]}}function _(e,t,n){var s,r,t=t||(n&&n.vueInstance?n.vueInstance:null);t&&(e.appContext=t.$.appContext,s={},(r=function(e){e.$&&e.$.parent&&r(e.$.parent),e.provides&&0<Object.keys(e.provides).length&&(s=S({},s,e.provides))})(t),e.appContext.provides)&&(e.appContext.provides=S({},e.appContext.provides,s))}function P(e){var t=e.componentOptions&&e.componentOptions.children?e.componentOptions:e.data||"e-markersettings"!==e.tag&&"e-markersetting"!==e.tag?e.data:e;return e.componentInstance||t}M.setTemplateEngine({compile:r}),e.ComponentBase=s,e.aVue=N,e.compile=r,e.getProps=function(n){if((n=void 0===n?{}:n).props)for(var e=0,t=n.props;e<t.length;e++)!function(t){(n.newprops||(n.newprops={}))[""+t]={},(n.watch||(n.watch={}))[""+t]=function(e){this.ej2Instances[""+t]=e,this.dataBind&&"DateRangePickerComponent"!==n.name&&this.dataBind()}}(t[e]);return[n.newprops,n.watch]},e.gh=t,e.isExecute=k,e.vueDefineComponent=n,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ej2-vue-base.umd.min.js.map