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.

60 lines (59 loc) 1.75 kB
import { isClient as v, noop as A, toValue as y, isObject as w, tryOnScopeDispose as E } from "../shared/index.mjs"; import { watch as L } from "vue"; const m = v ? window : void 0; function b(e) { var t; const n = y(e); return (t = n == null ? void 0 : n.$el) != null ? t : n; } function j(...e) { let t, n, o, s; if (typeof e[0] == "string" || Array.isArray(e[0]) ? ([n, o, s] = e, t = m) : [t, n, o, s] = e, !t) return A; Array.isArray(n) || (n = [n]), Array.isArray(o) || (o = [o]); const u = [], f = () => { u.forEach((r) => r()), u.length = 0; }, p = (r, i, l, c) => (r.addEventListener(i, l, c), () => r.removeEventListener(i, l, c)), a = L( () => [b(t), y(s)], ([r, i]) => { if (f(), !r) return; const l = w(i) ? { ...i } : i; u.push( ...n.flatMap((c) => o.map((h) => p(r, c, h, l))) ); }, { immediate: !0, flush: "post" } ), d = () => { a(), f(); }; return E(d), d; } function C(e) { return typeof e == "function" ? e : typeof e == "string" ? (t) => t.key === e : Array.isArray(e) ? (t) => e.includes(t.key) : () => !0; } function S(...e) { let t, n, o = {}; e.length === 3 ? (t = e[0], n = e[1], o = e[2]) : e.length === 2 ? typeof e[1] == "object" ? (t = !0, n = e[0], o = e[1]) : (t = e[0], n = e[1]) : (t = !0, n = e[0]); const { target: s = m, eventName: u = "keydown", passive: f = !1, dedupe: p = !1 } = o, a = C(t); return j(s, u, (r) => { r.repeat && y(p) || a(r) && n(r); }, f); } export { m as defaultWindow, v as isClient, w as isObject, A as noop, S as onKeyStroke, y as toValue, E as tryOnScopeDispose, b as unrefElement, j as useEventListener }; //# sourceMappingURL=index.mjs.map