UNPKG

comic-plus

Version:

<p align="center"> <img width="200px" src="./logo.png"/> </p>

150 lines (149 loc) 5.76 kB
import { defineComponent, openBlock, createBlock, TransitionGroup, withCtx, createElementBlock, Fragment, renderList, createElementVNode, resolveDynamicComponent, normalizeClass, unref, toDisplayString, createVNode, createCommentVNode, Transition, renderSlot } from "vue"; import { CuProgress } from "../../progress/index.mjs"; import { preview } from "../../preview-image/index.mjs"; import "../../../icons/index.mjs"; import { CheckOne, Delete, ZoomIn, Save, Upload, CloseOne } from "../../../icons/components/components.mjs"; const _hoisted_1 = { class: "progress" }; const _hoisted_2 = { key: 1, class: "cu-upload__pictures" }; const _hoisted_3 = { key: 0, class: "progress" }; const _hoisted_4 = { key: 1, class: "mask" }; const _hoisted_5 = ["src"]; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "CuUploadList" }, __name: "upload-list", props: { type: { type: String, required: true }, previewList: Array, uploadFileEnum: { type: Object, required: true }, disabled: Boolean }, emits: ["remove", "choose"], setup(__props, { emit: __emit }) { const icons = { ready: Save, uploading: Upload, success: CheckOne, fail: CloseOne }; const props = __props; const emit = __emit; function previewImg(index) { var _a; if (props.disabled) return; preview( (_a = props.previewList) == null ? void 0 : _a.map((v) => v.url), index ); } function remove(uid, index) { if (props.disabled) return; emit("remove", uid, index); } return (_ctx, _cache) => { return __props.type === "list" ? (openBlock(), createBlock(TransitionGroup, { key: 0, name: "list", class: "cu-upload__list", tag: "ul" }, { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.previewList, (file, index) => { var _a, _b; return openBlock(), createElementBlock("li", { key: file.uid || file.name }, [ createElementVNode("span", null, [ file.uid && __props.uploadFileEnum[file.uid] ? (openBlock(), createBlock(resolveDynamicComponent(icons[__props.uploadFileEnum[file.uid].status]), { key: 0, class: normalizeClass(__props.uploadFileEnum[file.uid].status) }, null, 8, ["class"])) : (openBlock(), createBlock(unref(CheckOne), { key: 1, class: "success" })) ]), createElementVNode("span", { class: normalizeClass(["filename", (_a = __props.uploadFileEnum[file.uid]) == null ? void 0 : _a.status]) }, toDisplayString(file.name), 3), createVNode(unref(Delete), { class: "delete", onClick: ($event) => remove(file.uid, index) }, null, 8, ["onClick"]), createElementVNode("span", _hoisted_1, [ ((_b = __props.uploadFileEnum[file.uid]) == null ? void 0 : _b.status) === "uploading" ? (openBlock(), createBlock(unref(CuProgress), { key: 0, progress: __props.uploadFileEnum[file.uid].progress, style: { "margin-top": "4px" } }, null, 8, ["progress"])) : createCommentVNode("", true) ]) ]); }), 128)) ]), _: 1 })) : __props.type === "picture" ? (openBlock(), createElementBlock("ul", _hoisted_2, [ createVNode(TransitionGroup, { name: "list" }, { default: withCtx(() => [ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.previewList, (file, index) => { var _a; return openBlock(), createElementBlock("li", { key: file.uid || file.name, class: normalizeClass((_a = __props.uploadFileEnum[file.uid]) == null ? void 0 : _a.status) }, [ createVNode(Transition, { name: "cu-fade" }, { default: withCtx(() => { var _a2; return [ ((_a2 = __props.uploadFileEnum[file.uid]) == null ? void 0 : _a2.status) === "uploading" ? (openBlock(), createElementBlock("span", _hoisted_3, [ createVNode(unref(CuProgress), { size: "100", type: "success", "bar-type": "circle", progress: __props.uploadFileEnum[file.uid].progress || 0 }, null, 8, ["progress"]) ])) : (openBlock(), createElementBlock("span", _hoisted_4, [ createVNode(unref(ZoomIn), { onClick: ($event) => previewImg(index) }, null, 8, ["onClick"]), createVNode(unref(Delete), { onClick: ($event) => remove(file.uid, index) }, null, 8, ["onClick"]) ])) ]; }), _: 2 }, 1024), createElementVNode("img", { src: file.url, alt: "" }, null, 8, _hoisted_5) ], 2); }), 128)) ]), _: 1 }), renderSlot(_ctx.$slots, "default", {}, () => [ _cache[0] || (_cache[0] = createElementVNode("li", { class: "choose-slot" }, null, -1)) ]) ])) : createCommentVNode("", true); }; } }); export { _sfc_main as default };