@work-zhanguo/light-file-preview 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +25 -1
  2. package/dist/{DocxRenderer-D0ngcG2T.js → DocxRenderer-DogNhBLd.js} +1 -1
  3. package/dist/PdfRenderer-Due2M5cA.js +57 -0
  4. package/dist/SheetRenderer-Dea6-NBg.js +315 -0
  5. package/dist/{UnsupportedRenderer-Y2AgN0-l.js → UnsupportedRenderer-DDB3UZdt.js} +1 -1
  6. package/dist/_commonjs-dynamic-modules-C74YT1gS.js +32 -0
  7. package/dist/{docx-preview-D_8kC8vU.js → docx-preview-BV-bQyiM.js} +75 -81
  8. package/dist/{index-DZOrV9D_.js → index-B8Ff5iZD.js} +1 -1
  9. package/dist/light-file-preview.js +1 -1
  10. package/dist/light-file-preview.umd.cjs +158 -161
  11. package/dist/pdf-BiKi76Et.js +15320 -0
  12. package/dist/standalone/light-file-preview.iife.js +160 -163
  13. package/dist/standalone/style.css +1 -1
  14. package/dist/style.css +1 -1
  15. package/dist/types/components/FilePreview.vue.d.ts +1 -1
  16. package/dist/vue2/{DocxRenderer-D-MItvaP.js → DocxRenderer-MIU7uOq2.js} +2 -2
  17. package/dist/vue2/PdfRenderer-t62Z-W1l.js +57 -0
  18. package/dist/vue2/SheetRenderer-DF_btSSa.js +315 -0
  19. package/dist/vue2/{TextRenderer-DOzgi4YR.js → TextRenderer-CURVfe6J.js} +1 -1
  20. package/dist/vue2/{UnsupportedRenderer-VozD1bVb.js → UnsupportedRenderer-CXW3m4B9.js} +1 -1
  21. package/dist/vue2/_commonjs-dynamic-modules-C74YT1gS.js +32 -0
  22. package/dist/vue2/{docx-preview-D_8kC8vU.js → docx-preview-BV-bQyiM.js} +75 -81
  23. package/dist/vue2/light-file-preview-vue2.js +1 -1
  24. package/dist/vue2/light-file-preview-vue2.umd.cjs +147 -150
  25. package/dist/vue2/pdf-BiKi76Et.js +15320 -0
  26. package/dist/vue2/{vue2-rrMAk2-n.js → vue2-DRZy2Bxs.js} +4 -2
  27. package/package.json +2 -2
  28. package/dist/PdfRenderer-SICIjXYT.js +0 -57
  29. package/dist/SheetRenderer-D4Y1dYZX.js +0 -77
  30. package/dist/pdf-CV932zwQ.js +0 -14611
  31. package/dist/vue2/PdfRenderer-rw-3PY9w.js +0 -57
  32. package/dist/vue2/SheetRenderer-BxfF54Q3.js +0 -77
  33. package/dist/vue2/pdf-CV932zwQ.js +0 -14611
@@ -0,0 +1,315 @@
1
+ import { defineComponent as xe, ref as C, computed as Se, onMounted as $e, onBeforeUnmount as Re, openBlock as u, createElementBlock as c, createElementVNode as p, Fragment as I, renderList as N, normalizeClass as x, toDisplayString as v, createCommentVNode as W, createTextVNode as ne, normalizeStyle as le } from "vue";
2
+ import { r as ke } from "./text-Bqxn_tMI.js";
3
+ const Ve = { class: "lfp-document lfp-sheet" }, Ie = { class: "lfp-sheet__toolbar" }, Ne = {
4
+ key: 0,
5
+ class: "lfp-sheet__tabs",
6
+ role: "tablist",
7
+ "aria-label": "工作表切换"
8
+ }, De = ["onClick"], Fe = { class: "lfp-sheet__tab-label" }, ze = { class: "lfp-sheet__tab-meta" }, Be = {
9
+ key: 1,
10
+ class: "lfp-sheet__summary"
11
+ }, Ae = { class: "lfp-sheet__summary-item" }, We = { class: "lfp-sheet__summary-item" }, Te = {
12
+ key: 0,
13
+ class: "lfp-hint"
14
+ }, Ee = {
15
+ key: 1,
16
+ class: "lfp-sheet__table-wrap"
17
+ }, je = { class: "lfp-sheet__table" }, He = { class: "lfp-sheet__header-row" }, Ke = ["rowspan", "colspan", "onMouseenter", "onFocus", "onClick"], Le = { class: "lfp-sheet__cell-text" }, Me = {
18
+ key: 2,
19
+ class: "lfp-sheet__empty"
20
+ }, qe = /* @__PURE__ */ xe({
21
+ __name: "SheetRenderer",
22
+ props: {
23
+ source: {},
24
+ maxRows: {},
25
+ maxCols: {}
26
+ },
27
+ emits: ["loading", "error"],
28
+ setup(re, { emit: ie }) {
29
+ const D = re, F = ie, T = new AbortController(), S = C(0), $ = C([]), m = C(""), z = C(null), B = C(null), i = Se(() => $.value[S.value]);
30
+ function ae(e) {
31
+ let o = e + 1, s = "";
32
+ for (; o > 0; ) {
33
+ const t = (o - 1) % 26;
34
+ s = String.fromCharCode(65 + t) + s, o = Math.floor((o - 1) / 26);
35
+ }
36
+ return s;
37
+ }
38
+ function y(e, o) {
39
+ z.value = e, B.value = o;
40
+ }
41
+ function ue(e) {
42
+ m.value = e;
43
+ }
44
+ function E(e, o) {
45
+ return e != null && (e === z.value || e === j()) || o != null && (o === B.value || o === H());
46
+ }
47
+ function j() {
48
+ if (!m.value)
49
+ return null;
50
+ const [e] = m.value.split(":");
51
+ return Number.isFinite(Number(e)) ? Number(e) : null;
52
+ }
53
+ function H() {
54
+ if (!m.value)
55
+ return null;
56
+ const [, e] = m.value.split(":");
57
+ return Number.isFinite(Number(e)) ? Number(e) : null;
58
+ }
59
+ function ce(e) {
60
+ if (e) {
61
+ if (["thin", "hair"].includes(e) || ["medium", "dashed", "dotted", "dashDot", "dashDotDot"].includes(e))
62
+ return "1px solid";
63
+ if (["thick", "double", "mediumDashed", "mediumDashDot", "mediumDashDotDot"].includes(e))
64
+ return "2px solid";
65
+ }
66
+ }
67
+ function R(e, o, s) {
68
+ var n;
69
+ if (!s)
70
+ return;
71
+ const t = ce(s.style), l = (n = k(s.color)) != null ? n : "rgba(31, 44, 61, 0.12)";
72
+ t && (o === "left" ? e.borderLeft = `${t} ${l}` : o === "right" ? e.borderRight = `${t} ${l}` : o === "top" ? e.borderTop = `${t} ${l}` : o === "bottom" && (e.borderBottom = `${t} ${l}`));
73
+ }
74
+ function k(e) {
75
+ if (!e || typeof e != "object")
76
+ return;
77
+ const o = "rgb" in e && typeof e.rgb == "string" ? e.rgb : "argb" in e && typeof e.argb == "string" ? e.argb : void 0;
78
+ if (!o)
79
+ return;
80
+ const s = o.replace(/^#/, "");
81
+ if (/^[0-9a-fA-F]{8}$/.test(s))
82
+ return `#${s.slice(2)}`;
83
+ if (/^[0-9a-fA-F]{6}$/.test(s))
84
+ return `#${s}`;
85
+ }
86
+ function fe(e) {
87
+ if (!e)
88
+ return;
89
+ const o = typeof e.hpx == "number" ? e.hpx : typeof e.hpt == "number" ? e.hpt * 1.3334 : void 0;
90
+ return o ? { height: `${Math.max(o, 24)}px` } : void 0;
91
+ }
92
+ function K(e) {
93
+ if (e) {
94
+ if (typeof e.wpx == "number")
95
+ return `${Math.max(e.wpx, 72)}px`;
96
+ if (typeof e.width == "number")
97
+ return `${Math.max(e.width * 8, 72)}px`;
98
+ }
99
+ }
100
+ function de(e) {
101
+ if (!e)
102
+ return {};
103
+ const o = {};
104
+ return e.horizontal && (o.textAlign = e.horizontal), e.vertical && (o.verticalAlign = e.vertical === "center" ? "middle" : e.vertical), e.wrapText && (o.whiteSpace = "pre-wrap", o.wordBreak = "break-word"), o;
105
+ }
106
+ function pe(e, o, s) {
107
+ var d;
108
+ const t = {};
109
+ if (s ? t.minWidth = s : o && (t.minWidth = o, t.width = o), !(e != null && e.s) || typeof e.s != "object")
110
+ return t;
111
+ const l = e.s.fill, n = e.s.font, r = e.s.border, f = (d = k(l == null ? void 0 : l.fgColor)) != null ? d : k(l == null ? void 0 : l.bgColor), h = k(n == null ? void 0 : n.color);
112
+ return f && (l == null ? void 0 : l.patternType) !== "none" && (t.backgroundColor = f), h && (t.color = h), n != null && n.bold && (t.fontWeight = "600"), n != null && n.italic && (t.fontStyle = "italic"), n != null && n.underline && (t.textDecoration = "underline"), typeof (n == null ? void 0 : n.sz) == "number" && (t.fontSize = `${n.sz}px`), typeof (n == null ? void 0 : n.name) == "string" && n.name.trim() && (t.fontFamily = n.name), Object.assign(t, de(e.s.alignment)), R(t, "left", r == null ? void 0 : r.left), R(t, "right", r == null ? void 0 : r.right), R(t, "top", r == null ? void 0 : r.top), R(t, "bottom", r == null ? void 0 : r.bottom), t;
113
+ }
114
+ function ve(e, o) {
115
+ var s, t;
116
+ return o ? typeof o.w == "string" ? o.w : (s = e.utils) != null && s.format_cell ? String(e.utils.format_cell(o, (t = o.v) != null ? t : "")) : o.v == null ? "" : String(o.v) : "";
117
+ }
118
+ function he(e, o, s) {
119
+ const t = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
120
+ for (const n of e) {
121
+ const r = o.filter((d) => d >= n.s.r && d <= n.e.r), f = s.filter((d) => d >= n.s.c && d <= n.e.c);
122
+ if (!r.length || !f.length)
123
+ continue;
124
+ const h = `${n.s.r}:${n.s.c}`;
125
+ l.set(h, {
126
+ rowSpan: r.length,
127
+ colSpan: f.length,
128
+ colsInRange: f
129
+ });
130
+ for (const d of r)
131
+ for (const V of f)
132
+ d === n.s.r && V === n.s.c || t.add(`${d}:${V}`);
133
+ }
134
+ return { coveredCells: t, mergeStarts: l };
135
+ }
136
+ function be(e, o, s) {
137
+ var L, M, O, U, q, G, J;
138
+ const t = s["!ref"];
139
+ if (!t)
140
+ return {
141
+ name: o,
142
+ rows: [],
143
+ totalRows: 0,
144
+ totalCols: 0,
145
+ visibleRows: 0,
146
+ visibleCols: 0,
147
+ visibleRowIndexes: [],
148
+ visibleColIndexes: [],
149
+ firstVisibleRow: 0,
150
+ firstVisibleCol: 0
151
+ };
152
+ const l = e.utils.decode_range(t), n = [], r = [];
153
+ for (let a = l.s.r; a <= l.e.r; a += 1)
154
+ (M = (L = s["!rows"]) == null ? void 0 : L[a]) != null && M.hidden || n.push(a);
155
+ for (let a = l.s.c; a <= l.e.c; a += 1)
156
+ (U = (O = s["!cols"]) == null ? void 0 : O[a]) != null && U.hidden || r.push(a);
157
+ const f = n.slice(0, D.maxRows), h = r.slice(0, D.maxCols), d = (q = s["!merges"]) != null ? q : [], { coveredCells: V, mergeStarts: _e } = he(d, f, h), ye = f.map((a) => {
158
+ var Q, Y, Z, X, ee;
159
+ const ge = (Q = s["!rows"]) == null ? void 0 : Q[a], we = fe(ge), P = [];
160
+ for (const g of h) {
161
+ const A = `${a}:${g}`;
162
+ if (V.has(A))
163
+ continue;
164
+ const Ce = e.utils.encode_cell({ r: a, c: g }), te = s[Ce], b = _e.get(A), oe = ((Y = b == null ? void 0 : b.colsInRange) != null ? Y : [g]).map((_) => {
165
+ var w;
166
+ return K((w = s["!cols"]) == null ? void 0 : w[_]);
167
+ }).filter(Boolean).reduce((_, w) => {
168
+ if (!w)
169
+ return _;
170
+ const se = Number.parseFloat(w);
171
+ return Number.isFinite(se) ? (_ != null ? _ : 0) + se : _;
172
+ }, null);
173
+ P.push({
174
+ key: A,
175
+ value: ve(e, te),
176
+ rowIndex: a,
177
+ colIndex: g,
178
+ rowSpan: (Z = b == null ? void 0 : b.rowSpan) != null ? Z : 1,
179
+ colSpan: (X = b == null ? void 0 : b.colSpan) != null ? X : 1,
180
+ style: pe(
181
+ te,
182
+ K((ee = s["!cols"]) == null ? void 0 : ee[g]),
183
+ oe ? `${oe}px` : void 0
184
+ )
185
+ });
186
+ }
187
+ return {
188
+ key: `${o}-${a}`,
189
+ rowIndex: a,
190
+ cells: P,
191
+ style: we
192
+ };
193
+ });
194
+ return {
195
+ name: o,
196
+ rows: ye,
197
+ totalRows: n.length,
198
+ totalCols: r.length,
199
+ visibleRows: f.length,
200
+ visibleCols: h.length,
201
+ visibleRowIndexes: f,
202
+ visibleColIndexes: h,
203
+ firstVisibleRow: (G = f[0]) != null ? G : 0,
204
+ firstVisibleCol: (J = h[0]) != null ? J : 0
205
+ };
206
+ }
207
+ async function me() {
208
+ F("loading", !0);
209
+ try {
210
+ const e = await ke(D.source, T.signal), o = await import("./xlsx-j9Zzywas.js"), s = o.read(e, {
211
+ type: "array",
212
+ cellStyles: !0,
213
+ cellNF: !0,
214
+ cellText: !0
215
+ });
216
+ $.value = s.SheetNames.map(
217
+ (t) => be(o, t, s.Sheets[t])
218
+ ), S.value = 0, m.value = "", y(null, null);
219
+ } catch (e) {
220
+ F("error", e instanceof Error ? e : new Error("表格预览失败"));
221
+ } finally {
222
+ F("loading", !1);
223
+ }
224
+ }
225
+ return $e(() => {
226
+ me();
227
+ }), Re(() => {
228
+ T.abort();
229
+ }), (e, o) => (u(), c("div", Ve, [
230
+ p("div", Ie, [
231
+ $.value.length > 1 ? (u(), c("div", Ne, [
232
+ (u(!0), c(I, null, N($.value, (s, t) => (u(), c("button", {
233
+ key: s.name,
234
+ class: x(["lfp-sheet__tab", { "is-active": t === S.value }]),
235
+ type: "button",
236
+ onClick: (l) => S.value = t
237
+ }, [
238
+ p("span", Fe, v(s.name), 1),
239
+ p("span", ze, v(s.totalRows) + " × " + v(s.totalCols), 1)
240
+ ], 10, De))), 128))
241
+ ])) : W("", !0),
242
+ i.value ? (u(), c("div", Be, [
243
+ p("span", Ae, [
244
+ o[2] || (o[2] = ne(" 当前工作表 ", -1)),
245
+ p("strong", null, v(i.value.name), 1)
246
+ ]),
247
+ p("span", We, [
248
+ o[3] || (o[3] = ne(" 总览 ", -1)),
249
+ p("strong", null, v(i.value.totalRows) + " 行 / " + v(i.value.totalCols) + " 列", 1)
250
+ ])
251
+ ])) : W("", !0)
252
+ ]),
253
+ i.value ? (u(), c("p", Te, " 共 " + v(i.value.totalRows) + " 行," + v(i.value.totalCols) + " 列。当前展示 " + v(i.value.visibleRows) + " 行、" + v(i.value.visibleCols) + " 列。 ", 1)) : W("", !0),
254
+ i.value ? (u(), c("div", Ee, [
255
+ p("table", je, [
256
+ p("tbody", null, [
257
+ p("tr", He, [
258
+ o[4] || (o[4] = p("th", {
259
+ class: "lfp-sheet__corner-header",
260
+ scope: "col",
261
+ "aria-label": "表格左上角"
262
+ }, null, -1)),
263
+ (u(!0), c(I, null, N(i.value.visibleColIndexes, (s) => (u(), c("th", {
264
+ key: `col-header-${s}`,
265
+ class: x(["lfp-sheet__col-header", {
266
+ "is-first-data-col": s === i.value.firstVisibleCol,
267
+ "is-related": E(null, s)
268
+ }]),
269
+ scope: "col"
270
+ }, v(ae(s)), 3))), 128))
271
+ ]),
272
+ (u(!0), c(I, null, N(i.value.rows, (s) => (u(), c("tr", {
273
+ key: s.key,
274
+ class: x(["lfp-sheet__row", { "is-first-row": s.rowIndex === i.value.firstVisibleRow }]),
275
+ style: le(s.style)
276
+ }, [
277
+ p("th", {
278
+ class: x(["lfp-sheet__row-header", {
279
+ "is-first-data-row": s.rowIndex === i.value.firstVisibleRow,
280
+ "is-related": E(s.rowIndex, null)
281
+ }]),
282
+ scope: "row"
283
+ }, v(s.rowIndex + 1), 3),
284
+ (u(!0), c(I, null, N(s.cells, (t) => (u(), c("td", {
285
+ key: t.key,
286
+ class: x({
287
+ "is-first-row": t.rowIndex === i.value.firstVisibleRow,
288
+ "is-first-col": t.colIndex === i.value.firstVisibleCol,
289
+ "is-corner-cell": t.rowIndex === i.value.firstVisibleRow && t.colIndex === i.value.firstVisibleCol,
290
+ "is-selected": m.value === t.key,
291
+ "is-row-active": z.value === t.rowIndex || j() === t.rowIndex,
292
+ "is-col-active": B.value === t.colIndex || H() === t.colIndex
293
+ }),
294
+ rowspan: t.rowSpan,
295
+ colspan: t.colSpan,
296
+ style: le(t.style),
297
+ tabindex: "0",
298
+ onMouseenter: (l) => y(t.rowIndex, t.colIndex),
299
+ onMouseleave: o[0] || (o[0] = (l) => y(null, null)),
300
+ onFocus: (l) => y(t.rowIndex, t.colIndex),
301
+ onBlur: o[1] || (o[1] = (l) => y(null, null)),
302
+ onClick: (l) => ue(t.key)
303
+ }, [
304
+ p("span", Le, v(t.value), 1)
305
+ ], 46, Ke))), 128))
306
+ ], 6))), 128))
307
+ ])
308
+ ])
309
+ ])) : (u(), c("p", Me, "当前工作表没有可展示的数据。"))
310
+ ]));
311
+ }
312
+ });
313
+ export {
314
+ qe as default
315
+ };
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as o, openBlock as l, createElementBlock as a, createElementVNode as t, toDisplayString as i, unref as r } from "vue";
2
- import { d as s } from "./index-DZOrV9D_.js";
2
+ import { d as s } from "./index-B8Ff5iZD.js";
3
3
  const d = { class: "lfp-empty" }, p = { class: "lfp-hint" }, c = /* @__PURE__ */ o({
4
4
  __name: "UnsupportedRenderer",
5
5
  props: {
@@ -0,0 +1,32 @@
1
+ var u = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
2
+ function i(e) {
3
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
+ }
5
+ function a(e) {
6
+ if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
7
+ var r = e.default;
8
+ if (typeof r == "function") {
9
+ var t = function o() {
10
+ return this instanceof o ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
11
+ };
12
+ t.prototype = r.prototype;
13
+ } else t = {};
14
+ return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(o) {
15
+ var n = Object.getOwnPropertyDescriptor(e, o);
16
+ Object.defineProperty(t, o, n.get ? n : {
17
+ enumerable: !0,
18
+ get: function() {
19
+ return e[o];
20
+ }
21
+ });
22
+ }), t;
23
+ }
24
+ function l(e) {
25
+ throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
26
+ }
27
+ export {
28
+ u as a,
29
+ i as b,
30
+ l as c,
31
+ a as g
32
+ };