UNPKG

@syncfusion/ej2-vue-notifications

Version:

A package of Essential JS 2 notification components such as Toast and Badge which used to notify important information to end-users. for Vue

387 lines (381 loc) 14.3 kB
import { Toast, Message, Skeleton } from '@syncfusion/ej2-notifications'; export * from '@syncfusion/ej2-notifications'; import { vueDefineComponent, isExecute, gh, getProps, ComponentBase } from '@syncfusion/ej2-vue-base'; import { isNullOrUndefined } from '@syncfusion/ej2-base'; let ButtonModelPropsDirective = vueDefineComponent({ inject: { custom: { default: null } }, render(createElement) { if (!isExecute) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', { class: 'e-directive' }, slots); } return; }, updated() { if (!isExecute && this.custom) { this.custom(); } }, methods: { getTag() { return 'e-buttonmodelprops'; } } }); const ButtonModelPropsPlugin = { name: 'e-buttonmodelprops', install(Vue) { Vue.component(ButtonModelPropsPlugin.name, ButtonModelPropsDirective); } }; /** * 'e-button' directive represent a button of Vue toast * It must be contained in a Toast component(`ejs-toast`). * ```html * <ejs-toast id='toast' :showCloseIcon=true> * <e-buttons> * <e-button :content='Ok' :isPrimary=true></e-button> * <e-button :content='Cancel'></e-button> * </e-buttons> * </ejs-toast> * ``` */ let ButtonModelPropDirective = vueDefineComponent({ render() { return; }, methods: { getTag() { return 'e-buttonmodelprop'; } } }); const ButtonModelPropPlugin = { name: 'e-buttonmodelprop', install(Vue) { Vue.component(ButtonModelPropPlugin.name, ButtonModelPropDirective); } }; const properties = ['isLazyUpdate', 'plugins', 'animation', 'buttons', 'content', 'cssClass', 'enableHtmlSanitizer', 'enablePersistence', 'enableRtl', 'extendedTimeout', 'height', 'icon', 'locale', 'newestOnTop', 'position', 'progressDirection', 'showCloseButton', 'showProgressBar', 'target', 'template', 'timeOut', 'title', 'width', 'beforeClose', 'beforeOpen', 'beforeSanitizeHtml', 'click', 'close', 'created', 'destroyed', 'open']; const modelProps = []; const testProp = getProps({ props: properties }); const props = testProp[0], watch = testProp[1], emitProbs = Object.keys(watch); emitProbs.push('modelchanged', 'update:modelValue'); for (let props of modelProps) { emitProbs.push('update:' + props); } /** * Represents the Vue Toast Component * ```html * <ejs-toast></ejs-toast> * ``` */ let ToastComponent = vueDefineComponent({ name: 'ToastComponent', mixins: [ComponentBase], props: props, watch: watch, emits: emitProbs, provide() { return { custom: this.custom }; }, data() { return { ej2Instances: new Toast({}), propKeys: properties, models: modelProps, hasChildDirective: true, hasInjectedModules: false, tagMapper: { "e-buttonmodelprops": "e-buttonmodelprop" }, tagNameMapper: { "e-buttonmodelprops": "e-buttons" }, isVue3: !isExecute, templateCollection: {}, }; }, created() { this.bindProperties(); this.ej2Instances._setProperties = this.ej2Instances.setProperties; this.ej2Instances.setProperties = this.setProperties; this.ej2Instances.clearTemplate = this.clearTemplate; this.updated = this.updated; }, render(createElement) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', slots); }, methods: { clearTemplate(templateNames) { if (!templateNames) { templateNames = Object.keys(this.templateCollection || {}); } if (templateNames.length && this.templateCollection) { for (let tempName of templateNames) { let elementCollection = this.templateCollection[tempName]; if (elementCollection && elementCollection.length) { for (let ele of elementCollection) { this.destroyPortals(ele); } delete this.templateCollection[tempName]; } } } }, setProperties(prop, muteOnChange) { if (this.isVue3) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if (this.ej2Instances && this.ej2Instances._setProperties) { this.ej2Instances._setProperties(prop, muteOnChange); } if (prop && this.models && this.models.length) { Object.keys(prop).map((key) => { this.models.map((model) => { if ((key === model) && !(/datasource/i.test(key))) { if (this.isVue3) { this.ej2Instances.vueInstance.$emit('update:' + key, prop[key]); } else { this.$emit('update:' + key, prop[key]); this.$emit('modelchanged', prop[key]); } } }); }); } }, custom() { this.updated(); }, destroy() { return this.ej2Instances.destroy(); }, hide(element) { return this.ej2Instances.hide(element); }, show(toastObj) { return this.ej2Instances.show(toastObj); }, } }); const ToastPlugin = { name: 'ejs-toast', install(Vue) { Vue.component(ToastPlugin.name, ToastComponent); Vue.component(ButtonModelPropPlugin.name, ButtonModelPropDirective); Vue.component(ButtonModelPropsPlugin.name, ButtonModelPropsDirective); } }; const properties$1 = ['isLazyUpdate', 'plugins', 'content', 'cssClass', 'enablePersistence', 'enableRtl', 'locale', 'severity', 'showCloseIcon', 'showIcon', 'variant', 'visible', 'closed', 'created', 'destroyed']; const modelProps$1 = []; const testProp$1 = getProps({ props: properties$1 }); const props$1 = testProp$1[0], watch$1 = testProp$1[1], emitProbs$1 = Object.keys(watch$1); emitProbs$1.push('modelchanged', 'update:modelValue'); for (let props of modelProps$1) { emitProbs$1.push('update:' + props); } /** * The Vue Message component displays messages with severity by differentiating icons and colors to denote the importance and context of the message to the end user. * ```html * <ejs-message id='msg'>Editing is restricted</ejs-message> * ``` */ let MessageComponent = vueDefineComponent({ name: 'MessageComponent', mixins: [ComponentBase], props: props$1, watch: watch$1, emits: emitProbs$1, provide() { return { custom: this.custom }; }, data() { return { ej2Instances: new Message({}), propKeys: properties$1, models: modelProps$1, hasChildDirective: false, hasInjectedModules: false, tagMapper: {}, tagNameMapper: {}, isVue3: !isExecute, templateCollection: {}, }; }, created() { this.bindProperties(); this.ej2Instances._setProperties = this.ej2Instances.setProperties; this.ej2Instances.setProperties = this.setProperties; this.ej2Instances.clearTemplate = this.clearTemplate; this.updated = this.updated; }, render(createElement) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', slots); }, methods: { clearTemplate(templateNames) { if (!templateNames) { templateNames = Object.keys(this.templateCollection || {}); } if (templateNames.length && this.templateCollection) { for (let tempName of templateNames) { let elementCollection = this.templateCollection[tempName]; if (elementCollection && elementCollection.length) { for (let ele of elementCollection) { this.destroyPortals(ele); } delete this.templateCollection[tempName]; } } } }, setProperties(prop, muteOnChange) { if (this.isVue3) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if (this.ej2Instances && this.ej2Instances._setProperties) { this.ej2Instances._setProperties(prop, muteOnChange); } if (prop && this.models && this.models.length) { Object.keys(prop).map((key) => { this.models.map((model) => { if ((key === model) && !(/datasource/i.test(key))) { if (this.isVue3) { this.ej2Instances.vueInstance.$emit('update:' + key, prop[key]); } else { this.$emit('update:' + key, prop[key]); this.$emit('modelchanged', prop[key]); } } }); }); } }, custom() { this.updated(); }, destroy() { return this.ej2Instances.destroy(); }, } }); const MessagePlugin = { name: 'ejs-message', install(Vue) { Vue.component(MessagePlugin.name, MessageComponent); } }; const properties$2 = ['isLazyUpdate', 'plugins', 'cssClass', 'enablePersistence', 'enableRtl', 'height', 'label', 'locale', 'shape', 'shimmerEffect', 'visible', 'width']; const modelProps$2 = []; const testProp$2 = getProps({ props: properties$2 }); const props$2 = testProp$2[0], watch$2 = testProp$2[1], emitProbs$2 = Object.keys(watch$2); emitProbs$2.push('modelchanged', 'update:modelValue'); for (let props of modelProps$2) { emitProbs$2.push('update:' + props); } /** * Represents the Vue Skeleton component * ```html * <ejs-skeleton></ejs-skeleton> * ``` */ let SkeletonComponent = vueDefineComponent({ name: 'SkeletonComponent', mixins: [ComponentBase], props: props$2, watch: watch$2, emits: emitProbs$2, provide() { return { custom: this.custom }; }, data() { return { ej2Instances: new Skeleton({}), propKeys: properties$2, models: modelProps$2, hasChildDirective: false, hasInjectedModules: false, tagMapper: {}, tagNameMapper: {}, isVue3: !isExecute, templateCollection: {}, }; }, created() { this.bindProperties(); this.ej2Instances._setProperties = this.ej2Instances.setProperties; this.ej2Instances.setProperties = this.setProperties; this.ej2Instances.clearTemplate = this.clearTemplate; this.updated = this.updated; }, render(createElement) { let h = !isExecute ? gh : createElement; let slots = null; if (!isNullOrUndefined(this.$slots.default)) { slots = !isExecute ? this.$slots.default() : this.$slots.default; } return h('div', slots); }, methods: { clearTemplate(templateNames) { if (!templateNames) { templateNames = Object.keys(this.templateCollection || {}); } if (templateNames.length && this.templateCollection) { for (let tempName of templateNames) { let elementCollection = this.templateCollection[tempName]; if (elementCollection && elementCollection.length) { for (let ele of elementCollection) { this.destroyPortals(ele); } delete this.templateCollection[tempName]; } } } }, setProperties(prop, muteOnChange) { if (this.isVue3) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if (this.ej2Instances && this.ej2Instances._setProperties) { this.ej2Instances._setProperties(prop, muteOnChange); } if (prop && this.models && this.models.length) { Object.keys(prop).map((key) => { this.models.map((model) => { if ((key === model) && !(/datasource/i.test(key))) { if (this.isVue3) { this.ej2Instances.vueInstance.$emit('update:' + key, prop[key]); } else { this.$emit('update:' + key, prop[key]); this.$emit('modelchanged', prop[key]); } } }); }); } }, custom() { this.updated(); }, destroy() { return this.ej2Instances.destroy(); }, } }); const SkeletonPlugin = { name: 'ejs-skeleton', install(Vue) { Vue.component(SkeletonPlugin.name, SkeletonComponent); } }; export { ButtonModelPropDirective, ButtonModelPropPlugin, ButtonModelPropsDirective, ButtonModelPropsPlugin, MessageComponent, MessagePlugin, SkeletonComponent, SkeletonPlugin, ToastComponent, ToastPlugin }; //# sourceMappingURL=ej2-vue-notifications.es2015.js.map