UNPKG

vue-files-preview-inno

Version:

A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.

72 lines (71 loc) 2.17 kB
import { defineComponent as g, ref as F, shallowRef as N, watch as f, openBlock as a, createElementBlock as c, normalizeStyle as P, createElementVNode as B, createCommentVNode as T, createBlock as k, resolveDynamicComponent as E } from "vue"; import { PreviewRules as u, getPreviewTypeByFileType as s } from "../../preview.const.mjs"; import { PreviewType as R } from "../../preview.interface.mjs"; import { getFileType as x, getFileName as C, getFileTypeFromUrl as U, getFileNameFromUrl as V } from "../../utils/utils.mjs"; const z = { key: 0, class: "vfp-loading" }, j = /* @__PURE__ */ g({ __name: "index", props: { file: { default: () => null }, url: { default: () => null }, name: {}, width: { default: () => "100%" }, height: { default: () => "100%" }, overflow: { default: () => "auto" } }, emits: ["rendered", "error"], setup(n, { emit: d }) { const t = n, m = d, r = F(!0), i = N(u[R.NONE]); function v(e) { const l = u[s(x(e, t.name))]; l && (r.value = !0, i.value = { ...l, name: C(e, t.name) }); } function y(e, l) { const o = u[s(e)]; o && (r.value = !0, i.value = { ...o, name: l }); } async function p(e) { const l = U(e, t.name), o = V(e, t.name); y(l, o); } function w() { r.value = !1, m("rendered"); } function h(e) { r.value = !1, m("error", e); } return f( () => t.file, (e) => { e && v(e); }, { immediate: !0 } ), f( () => t.url, (e) => { e && !t.file && p(e); }, { immediate: !0 } ), (e, l) => (a(), c("div", { class: "vue-files-preview", style: P({ width: n.width, height: n.height, overflow: n.overflow }) }, [ r.value ? (a(), c("div", z, [...l[0] || (l[0] = [ B("div", { class: "vfp-spinner" }, null, -1) ])])) : T("", !0), (a(), k(E(i.value.component), { name: i.value.name, file: n.file, url: n.url, onRendered: w, onError: h }, null, 40, ["name", "file", "url"])) ], 4)); } }); export { j as default }; //# sourceMappingURL=index.vue2.mjs.map