UNPKG

yanzhen-design-vue

Version:

72 lines (71 loc) 3.18 kB
import { defineComponent, useAttrs, openBlock, createElementBlock, Fragment, createBlock, Teleport, createElementVNode, normalizeClass, unref, createVNode, withCtx, renderList, normalizeStyle, renderSlot, normalizeProps, guardReactiveProps, h, createTextVNode, toDisplayString } from "vue"; import { ImagePreviewGroup, Image, Button } from "ant-design-vue"; import { FileImageOutlined } from "@ant-design/icons-vue"; import { uploadImagePreviewName, uploadImagePreviewProps, uploadImagePreviewEmits, uploadImagePreviewOptions } from "./upload-image-preview.mjs"; import { useUploadImagePreview } from "./use-upload-image-preview.mjs"; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: uploadImagePreviewName }, __name: "upload-image-preview", props: uploadImagePreviewProps, emits: uploadImagePreviewEmits, setup(__props, { expose: __expose, emit: __emit }) { const ns = uploadImagePreviewOptions.ns; const props = __props; const emit = __emit; const attrs = useAttrs(); const { preview, imageListRef, exposeCtx, handleOpenPreviewImage } = useUploadImagePreview( props, emit ); __expose(exposeCtx); return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [ (openBlock(), createBlock(Teleport, { to: "body" }, [ createElementVNode("div", { class: normalizeClass(unref(ns).b()), style: { "display": "none" } }, [ createVNode(unref(ImagePreviewGroup), { preview: unref(preview), list: unref(imageListRef) }, { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(imageListRef), (item) => { return openBlock(), createBlock(unref(Image), { key: (item == null ? void 0 : item.src) ?? item.uid, style: normalizeStyle([{ "display": "none" }, [item.style]]), class: normalizeClass([item.class]), width: item.width, src: item.src, preview: { visible: item.visible, onVisibleChange: item.onVisibleChange } }, null, 8, ["style", "class", "width", "src", "preview"]); }), 128)) ]), _: 1 }, 8, ["preview", "list"]) ], 2) ])), renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(unref(exposeCtx))), () => [ createVNode(unref(Button), { class: normalizeClass(unref(attrs).class), style: normalizeStyle(unref(attrs).style), icon: h(unref(FileImageOutlined)), type: "link", onClick: _cache[0] || (_cache[0] = ($event) => unref(handleOpenPreviewImage)()) }, { default: withCtx(() => [ createTextVNode(toDisplayString(unref(imageListRef).length), 1) ]), _: 1 }, 8, ["class", "style", "icon"]) ]) ], 64); }; } }); export { _sfc_main as default };