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

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.
@@ -5820,7 +5820,7 @@ const df = ["aria-modal"], pf = {
5820
5820
  },
5821
5821
  emits: ["update:visible", "error"],
5822
5822
  setup(e, { emit: t }) {
5823
- const n = /* @__PURE__ */ Xt(() => import("./PdfRenderer-t62Z-W1l.js")), o = /* @__PURE__ */ Xt(() => import("./TextRenderer-CURVfe6J.js")), r = /* @__PURE__ */ Xt(() => import("./DocxRenderer-MIU7uOq2.js")), s = /* @__PURE__ */ Xt(() => import("./SheetRenderer-DF_btSSa.js")), i = /* @__PURE__ */ Xt(() => import("./UnsupportedRenderer-CXW3m4B9.js")), l = e, u = t, p = /* @__PURE__ */ Nt(null), f = /* @__PURE__ */ Nt(!1), a = /* @__PURE__ */ Nt(""), h = /* @__PURE__ */ Nt(gs(l.source, l.fileName)), m = Mt(() => uf(h.value.name)), O = Mt(() => l.fileName || h.value.name || l.dialogTitle), v = Mt(() => l.mode === "dialog"), j = Mt(() => v.value ? l.visible : !0), P = Mt(() => m.value === "image" ? "img" : m.value === "video" ? "video" : m.value === "audio" ? "audio" : null);
5823
+ const n = /* @__PURE__ */ Xt(() => import("./PdfRenderer-BDChtpiV.js")), o = /* @__PURE__ */ Xt(() => import("./TextRenderer-Bg2LfLu7.js")), r = /* @__PURE__ */ Xt(() => import("./DocxRenderer-pUvnG-5n.js")), s = /* @__PURE__ */ Xt(() => import("./SheetRenderer-BATFlzFf.js")), i = /* @__PURE__ */ Xt(() => import("./UnsupportedRenderer-CljMmiGZ.js")), l = e, u = t, p = /* @__PURE__ */ Nt(null), f = /* @__PURE__ */ Nt(!1), a = /* @__PURE__ */ Nt(""), h = /* @__PURE__ */ Nt(gs(l.source, l.fileName)), m = Mt(() => uf(h.value.name)), O = Mt(() => l.fileName || h.value.name || l.dialogTitle), v = Mt(() => l.mode === "dialog"), j = Mt(() => v.value ? l.visible : !0), P = Mt(() => m.value === "image" ? "img" : m.value === "video" ? "video" : m.value === "audio" ? "audio" : null);
5824
5824
  Ln(
5825
5825
  () => [l.source, l.fileName],
5826
5826
  () => {
@@ -6198,9 +6198,9 @@ export {
6198
6198
  Mt as g,
6199
6199
  Cf as h,
6200
6200
  du as i,
6201
- Yo as j,
6201
+ oo as j,
6202
6202
  af as k,
6203
- oo as n,
6203
+ Yo as n,
6204
6204
  fi as o,
6205
6205
  Nt as r,
6206
6206
  nn as t,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@work-zhanguo/light-file-preview",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "轻量级通用文件预览组件,支持 Vue3、Vue2 适配与独立产物嵌入。",
5
5
  "type": "module",
6
6
  "main": "./dist/light-file-preview.umd.cjs",
@@ -1,315 +0,0 @@
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,315 +0,0 @@
1
- import { d as xe, g as Se, o as $e, a as Re, b as u, c, f as p, F as I, h as F, e as W, i as ne, t as v, r as C, n as x, j as le } from "./vue2-DRZy2Bxs.js";
2
- import { r as ke } from "./text-Bqxn_tMI.js";
3
- const Ve = { class: "lfp-document lfp-sheet" }, Ie = { class: "lfp-sheet__toolbar" }, Fe = {
4
- key: 0,
5
- class: "lfp-sheet__tabs",
6
- role: "tablist",
7
- "aria-label": "工作表切换"
8
- }, Ne = ["onClick"], Be = { class: "lfp-sheet__tab-label" }, De = { class: "lfp-sheet__tab-meta" }, ze = {
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
- }, je = {
15
- key: 1,
16
- class: "lfp-sheet__table-wrap"
17
- }, Ee = { 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 N = re, B = ie, T = new AbortController(), S = C(0), $ = C([]), m = C(""), D = C(null), z = 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
- D.value = e, z.value = o;
40
- }
41
- function ue(e) {
42
- m.value = e;
43
- }
44
- function j(e, o) {
45
- return e != null && (e === D.value || e === E()) || o != null && (o === z.value || o === H());
46
- }
47
- function E() {
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, N.maxRows), h = r.slice(0, N.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
- B("loading", !0);
209
- try {
210
- const e = await ke(N.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
- B("error", e instanceof Error ? e : new Error("表格预览失败"));
221
- } finally {
222
- B("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", Fe, [
232
- (u(!0), c(I, null, F($.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", Be, v(s.name), 1),
239
- p("span", De, v(s.totalRows) + " × " + v(s.totalCols), 1)
240
- ], 10, Ne))), 128))
241
- ])) : W("", !0),
242
- i.value ? (u(), c("div", ze, [
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", je, [
255
- p("table", Ee, [
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, F(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": j(null, s)
268
- }]),
269
- scope: "col"
270
- }, v(ae(s)), 3))), 128))
271
- ]),
272
- (u(!0), c(I, null, F(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": j(s.rowIndex, null)
281
- }]),
282
- scope: "row"
283
- }, v(s.rowIndex + 1), 3),
284
- (u(!0), c(I, null, F(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": D.value === t.rowIndex || E() === t.rowIndex,
292
- "is-col-active": z.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
- };