UNPKG

yuang-framework-ui-pc

Version:

yuang-framework-ui-pc Library

89 lines (88 loc) 2.69 kB
import { defineComponent, ref, computed, onDeactivated, resolveComponent, openBlock, createBlock, Teleport, createVNode, Transition, withCtx, createElementBlock, normalizeClass, normalizeStyle, mergeProps, renderSlot, createCommentVNode } from "vue"; import { ElImageViewer } from "element-plus"; import { omit } from "../utils/core"; import { imageViewerProps, imageViewerEmits } from "./props"; const _sfc_main = defineComponent({ name: "EleImageViewer", components: { ElImageViewer }, props: imageViewerProps, emits: imageViewerEmits, setup(props, { emit }) { const imageViewerRef = ref(null); const viewerProps = computed(() => { const options = omit(props, [ "modelValue", "customClass", "customStyle", "transitionName", "keepAlive" ]); options.teleported = false; return options; }); const handleClose = () => { emit("update:modelValue", false); emit("close"); }; const handleSwitch = (index2) => { emit("switch", index2); }; const handleRotate = (deg) => { emit("rotate", deg); }; onDeactivated(() => { handleClose(); }); return { imageViewerRef, viewerProps, handleClose, handleSwitch, handleRotate }; } }); const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_ElImageViewer = resolveComponent("ElImageViewer"); return openBlock(), createBlock(Teleport, { to: "body", disabled: !_ctx.teleported }, [ createVNode(Transition, { name: _ctx.transitionName, appear: true }, { default: withCtx(() => [ _ctx.modelValue ? (openBlock(), createElementBlock("div", { key: 0, class: normalizeClass(["ele-image-viewer", _ctx.customClass]), style: normalizeStyle(_ctx.customStyle) }, [ createVNode(_component_ElImageViewer, mergeProps(_ctx.viewerProps, { ref: "imageViewerRef", onClose: _ctx.handleClose, onSwitch: _ctx.handleSwitch, onRotate: _ctx.handleRotate }), { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 16, ["onClose", "onSwitch", "onRotate"]) ], 6)) : createCommentVNode("", true) ]), _: 3 }, 8, ["name"]) ], 8, ["disabled"]); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index as default };