UNPKG

@syncfusion/ej2-vue-popups

Version:

A package of Essential JS 2 popup components such as Dialog and Tooltip that is used to display information or messages in separate pop-ups. for Vue

346 lines (341 loc) 13.8 kB
import { Dialog, Tooltip } from '@syncfusion/ej2-popups'; export * from '@syncfusion/ej2-popups'; import { vueDefineComponent, isExecute, gh, getProps, ComponentBase } from '@syncfusion/ej2-vue-base'; import { isNullOrUndefined, isUndefined } from '@syncfusion/ej2-base'; let ButtonsDirective = 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-buttons'; } } }); const ButtonsPlugin = { name: 'e-buttons', install(Vue) { Vue.component(ButtonsPlugin.name, ButtonsDirective); } }; /** * 'e-button' directive represent a button of Vue Dialog * It must be contained in a Dialog component(`ejs-dialog`). * ```html * <ejs-Dialog id='dialog' :showCloseIcon=true> * <e-buttons> * <e-dialogbutton :buttonModal='okButton'></e-dialogbutton> * <e-dialogbutton :buttonModal='cancelButton'></e-dialogbutton> * </e-buttons> * </ejs-Dialog> * ``` */ let DialogButtonDirective = vueDefineComponent({ render() { return; }, methods: { getTag() { return 'e-dialogbutton'; } } }); const DialogButtonPlugin = { name: 'e-dialogbutton', install(Vue) { Vue.component(DialogButtonPlugin.name, DialogButtonDirective); } }; const properties = ['isLazyUpdate', 'plugins', 'allowDragging', 'animationSettings', 'buttons', 'closeOnEscape', 'content', 'cssClass', 'enableHtmlSanitizer', 'enablePersistence', 'enableResize', 'enableRtl', 'footerTemplate', 'header', 'height', 'isModal', 'locale', 'minHeight', 'position', 'resizeHandles', 'showCloseIcon', 'target', 'visible', 'width', 'zIndex', 'beforeClose', 'beforeOpen', 'beforeSanitizeHtml', 'close', 'created', 'destroyed', 'drag', 'dragStart', 'dragStop', 'open', 'overlayClick', 'resizeStart', 'resizeStop', 'resizing']; const modelProps = ['visible']; 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 VueJS Dialog component * ```html * <ejs-dialog></ejs-dialog> * ``` */ let DialogComponent = vueDefineComponent({ name: 'DialogComponent', mixins: [ComponentBase], props: props, watch: watch, emits: emitProbs, model: { event: 'modelchanged' }, provide() { return { custom: this.custom }; }, data() { return { ej2Instances: new Dialog({}), propKeys: properties, models: modelProps, hasChildDirective: true, hasInjectedModules: false, tagMapper: { "e-buttons": "e-dialogbutton" }, tagNameMapper: {}, isVue3: !isExecute, templateCollection: {}, }; }, created() { this.ej2Instances._trigger = this.ej2Instances.trigger; this.ej2Instances.trigger = this.trigger; 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]); } } }); }); } }, trigger(eventName, eventProp, successHandler) { if (!isExecute) { this.models = !this.models ? this.ej2Instances.referModels : this.models; } if ((eventName === 'change' || eventName === 'input') && this.models && (this.models.length !== 0)) { let key = this.models.toString().match(/checked|value/) || []; let propKey = key[0]; if (eventProp && key && !isUndefined(eventProp[propKey])) { if (!isExecute) { this.ej2Instances.vueInstance.$emit('update:' + propKey, eventProp[propKey]); this.ej2Instances.vueInstance.$emit('modelchanged', eventProp[propKey]); this.ej2Instances.vueInstance.$emit('update:modelValue', eventProp[propKey]); } else { if (eventName === 'change' || (this.$props && !this.$props.isLazyUpdate)) { this.$emit('update:' + propKey, eventProp[propKey]); this.$emit('modelchanged', eventProp[propKey]); } } } } else if ((eventName === 'actionBegin' && eventProp.requestType === 'dateNavigate') && this.models && (this.models.length !== 0)) { let key = this.models.toString().match(/currentView|selectedDate/) || []; let propKey = key[0]; if (eventProp && key && !isUndefined(eventProp[propKey])) { if (!isExecute) { this.ej2Instances.vueInstance.$emit('update:' + propKey, eventProp[propKey]); this.ej2Instances.vueInstance.$emit('modelchanged', eventProp[propKey]); } else { this.$emit('update:' + propKey, eventProp[propKey]); this.$emit('modelchanged', eventProp[propKey]); } } } if ((this.ej2Instances && this.ej2Instances._trigger)) { this.ej2Instances._trigger(eventName, eventProp, successHandler); } }, custom() { this.updated(); }, destroy() { return this.ej2Instances.destroy(); }, getButtons(index) { return this.ej2Instances.getButtons(index); }, getDimension() { return this.ej2Instances.getDimension(); }, hide(event) { return this.ej2Instances.hide(event); }, refreshPosition() { return this.ej2Instances.refreshPosition(); }, sanitizeHelper(value) { return this.ej2Instances.sanitizeHelper(value); }, show(isFullScreen) { return this.ej2Instances.show(isFullScreen); }, } }); const DialogPlugin = { name: 'ejs-dialog', install(Vue) { Vue.component(DialogPlugin.name, DialogComponent); Vue.component(DialogButtonPlugin.name, DialogButtonDirective); Vue.component(ButtonsPlugin.name, ButtonsDirective); } }; const properties$1 = ['isLazyUpdate', 'plugins', 'animation', 'closeDelay', 'container', 'content', 'cssClass', 'enableHtmlParse', 'enableHtmlSanitizer', 'enablePersistence', 'enableRtl', 'height', 'htmlAttributes', 'isSticky', 'locale', 'mouseTrail', 'offsetX', 'offsetY', 'openDelay', 'opensOn', 'position', 'showTipPointer', 'target', 'tipPointerPosition', 'width', 'windowCollision', 'afterClose', 'afterOpen', 'beforeClose', 'beforeCollision', 'beforeOpen', 'beforeRender', '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); } /** * Represents the VueJS Tooltip component that displays a piece of information about the target element on mouse hover. * ```html * <ejs-tooltip content='Tooltip content'>Show Tooltip</ejs-tooltip> * ``` */ let TooltipComponent = vueDefineComponent({ name: 'TooltipComponent', mixins: [ComponentBase], props: props$1, watch: watch$1, emits: emitProbs$1, provide() { return { custom: this.custom }; }, data() { return { ej2Instances: new Tooltip({}), 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(); }, close(animation) { return this.ej2Instances.close(animation); }, destroy() { return this.ej2Instances.destroy(); }, open(element, animation) { return this.ej2Instances.open(element, animation); }, refresh(target) { return this.ej2Instances.refresh(target); }, } }); const TooltipPlugin = { name: 'ejs-tooltip', install(Vue) { Vue.component(TooltipPlugin.name, TooltipComponent); } }; export { ButtonsDirective, ButtonsPlugin, DialogButtonDirective, DialogButtonPlugin, DialogComponent, DialogPlugin, TooltipComponent, TooltipPlugin }; //# sourceMappingURL=ej2-vue-popups.es2015.js.map