UNPKG

ivue-material-plus

Version:

A high quality UI components Library with Vue.js

81 lines (79 loc) 2.04 kB
import { createApp, getCurrentInstance, h } from 'vue'; import ImagePreview from './image-preview.mjs'; export { default } from './image-preview.mjs'; import { isClient } from '../../utils/helpers.mjs'; ImagePreview.newInstance = (properties) => { if (!isClient) { return; } const _props = properties || {}; let _instance = null; const Instance = createApp({ data() { return Object.assign({}, _props, { visible: false, previewList: [], initialIndex: 0, toolbar: [ "zoomIn", "zoomOut", "original", "rotateLeft", "rotateRight", "download" ], infinite: true, maskClosable: true, transfer: true }); }, created() { _instance = getCurrentInstance(); }, methods: { handleClose() { this.visible = false; setTimeout(() => { this.destroy(); this.removeInstance(); }, 300); }, destroy() { Instance.unmount(); document.body.removeChild(container); }, removeInstance() { } }, render() { return h( ImagePreview, Object.assign({}, _props, { ref: "imagePreview", modelValue: this.visible, previewList: this.previewList, initialIndex: this.initialIndex, toolbar: this.toolbar, infinite: this.infinite, maskClosable: this.maskClosable, transfer: this.transfer, "onOn-close": this.handleClose }) ); } }); const container = document.createElement("div"); document.body.appendChild(container); Instance.mount(container); const imagePreview = _instance.refs.imagePreview; return { show(options) { Object.keys(options).forEach((key) => { imagePreview.$parent[key] = options[key]; }); imagePreview.$parent.visible = true; }, component: imagePreview }; }; //# sourceMappingURL=image-preview-global.mjs.map