vue-files-preview
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
43 lines (42 loc) • 1.32 kB
JavaScript
import { defineComponent as m, shallowRef as u, watch as p, openBlock as t, createElementBlock as s, normalizeStyle as c, createBlock as w, resolveDynamicComponent as v, unref as o } from "vue";
import { PreviewRules as i, getPreviewTypeByFileType as d } from "../../preview.const.mjs";
import { PreviewType as h } from "../../preview.interface.mjs";
import { getFileType as y, getFileName as g } from "../../utils/utils.mjs";
const F = /* @__PURE__ */ m({
__name: "index",
props: {
file: { default: () => null },
url: { default: () => null },
name: {},
width: { default: () => "100%" },
height: { default: () => "100%" },
overflow: { default: () => "auto" }
},
setup(n) {
const a = n, r = u(i[h.NONE]);
function f(e) {
const l = i[d(y(e))];
l && (l.name = g(e), r.value = l);
}
return p(
() => a.file,
(e) => {
e && f(e);
},
{ immediate: !0 }
), (e, l) => (t(), s("div", {
class: "vue-files-preview",
style: c({ width: e.width, height: e.height, overflow: e.overflow })
}, [
(t(), w(v(o(r).component), {
name: o(r).name,
file: e.file,
url: e.url
}, null, 8, ["name", "file", "url"]))
], 4));
}
});
export {
F as default
};
//# sourceMappingURL=index.vue.mjs.map