ooxml-excel-editor 1.2.0 → 1.3.1

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.
package/dist/react.js CHANGED
@@ -1,8 +1,8 @@
1
- import { jsx as s, jsxs as m, Fragment as ot } from "react/jsx-runtime";
2
- import { useState as R, useRef as C, useCallback as at, forwardRef as Pt, useReducer as Dt, useLayoutEffect as st, useEffect as p, useImperativeHandle as Ot } from "react";
3
- import { p as Ct, i as Wt, j as Lt, a as Bt } from "./chunks/worker-client.stub-CJlmpAgJ.js";
4
- import { r as it, l as ht, d as vt, f as xt, a as Ht, V as Vt, P as Jt, g as ut, s as dt, b as gt, e as ft, h as mt, i as Ne } from "./chunks/plugin-overlay-BBrNby8v.js";
5
- const zt = {
1
+ import { jsx as a, jsxs as g, Fragment as qt } from "react/jsx-runtime";
2
+ import { useState as y, useRef as v, useCallback as wt, forwardRef as Qt, useEffect as E, useReducer as Yt, useLayoutEffect as It, useImperativeHandle as en } from "react";
3
+ import { p as Tt, s as De, i as tn, j as nn, a as rn, T as ln } from "./chunks/toolbar-icons-BcnMin5s.js";
4
+ import { r as yt, l as Pt, d as Mt, f as At, a as on, V as cn, P as an, g as Rt, s as Et, b as Ft, c as kt, e as Nt, h as Oe } from "./chunks/plugin-overlay-DLb6sRhU.js";
5
+ const sn = {
6
6
  render: "渲染中",
7
7
  compose: "合成中",
8
8
  paginate: "分页中",
@@ -10,78 +10,94 @@ const zt = {
10
10
  zip: "zip 压缩",
11
11
  convert: "批量转换"
12
12
  };
13
- function Kt({
14
- state: g,
15
- busy: a,
16
- onCancel: I
13
+ function un({
14
+ state: f,
15
+ busy: c,
16
+ onCancel: k
17
17
  }) {
18
- if (!a) return null;
19
- const S = g == null ? void 0 : g.ratio, N = (g == null ? void 0 : g.label) || zt[(g == null ? void 0 : g.stage) ?? ""] || "处理中…";
20
- return /* @__PURE__ */ s("div", { className: "rxl-export-progress", role: "dialog", "aria-modal": "true", "aria-live": "polite", children: /* @__PURE__ */ m("div", { className: "card", children: [
21
- /* @__PURE__ */ s("div", { className: "title", children: N }),
22
- /* @__PURE__ */ s("div", { className: "bar" + (S == null ? " indeterminate" : ""), children: S != null ? /* @__PURE__ */ s("div", { className: "fill", style: { width: Math.round(S * 100) + "%" } }) : null }),
23
- /* @__PURE__ */ m("div", { className: "row", children: [
24
- /* @__PURE__ */ s("span", { className: "pct", children: S != null ? Math.round(S * 100) + "%" : "正在处理…" }),
25
- /* @__PURE__ */ s("button", { className: "cancel", onClick: I, title: "按 Esc 也可取消", children: "取消" })
18
+ if (!c) return null;
19
+ const w = f == null ? void 0 : f.ratio, T = (f == null ? void 0 : f.label) || sn[(f == null ? void 0 : f.stage) ?? ""] || "处理中…";
20
+ return /* @__PURE__ */ a("div", { className: "rxl-export-progress", role: "dialog", "aria-modal": "true", "aria-live": "polite", children: /* @__PURE__ */ g("div", { className: "card", children: [
21
+ /* @__PURE__ */ a("div", { className: "title", children: T }),
22
+ /* @__PURE__ */ a("div", { className: "bar" + (w == null ? " indeterminate" : ""), children: w != null ? /* @__PURE__ */ a("div", { className: "fill", style: { width: Math.round(w * 100) + "%" } }) : null }),
23
+ /* @__PURE__ */ g("div", { className: "row", children: [
24
+ /* @__PURE__ */ a("span", { className: "pct", children: w != null ? Math.round(w * 100) + "%" : "正在处理…" }),
25
+ /* @__PURE__ */ a("button", { className: "cancel", onClick: k, title: "按 Esc 也可取消", children: "取消" })
26
26
  ] })
27
27
  ] }) });
28
28
  }
29
- function $t() {
30
- const [g, a] = R(!1), [I, S] = R(null), [N, c] = R(null), [E, k] = R(null), [_, z] = R(null), D = C(null), y = at(async (A, J) => {
31
- a(!0), S(null), D.current && it(D.current), D.current = null, c(null), z(null), k({ stage: "read", ratio: 0 });
29
+ function dn() {
30
+ const [f, c] = y(!1), [k, w] = y(null), [T, s] = y(null), [F, A] = y(null), [Y, K] = y(null), W = v(null), N = wt(async (p, L) => {
31
+ c(!0), w(null), W.current && yt(W.current), W.current = null, s(null), K(null), A({ stage: "read", ratio: 0 });
32
32
  try {
33
- const w = await ht(
34
- A,
35
- ($, W) => k({ stage: "read", ratio: W ? $ / W : void 0 })
36
- ), M = vt(w);
37
- if (M === "xls") throw new Error("这是旧版 .xls(BIFF) 或加密文件,本预览器只支持 .xlsx/.xlsm。");
38
- if (M === "not-zip") throw new Error("文件不是有效的 .xlsx(非 ZIP 包)。");
39
- if (M === "empty") throw new Error("文件为空。");
40
- let O = await Ct(w, ($) => k($));
41
- J && (O = J(O) ?? O), xt(O), z(w.slice(0)), D.current = O, c(O);
42
- } catch (w) {
43
- const M = w == null ? void 0 : w.message;
44
- S(M && /预览器|损坏|加密|为空|ZIP/.test(M) ? M : Ht(w)), console.error("[ooxml-preview] 解析失败:", w);
33
+ const I = await Pt(
34
+ p,
35
+ (X, ee) => A({ stage: "read", ratio: ee ? X / ee : void 0 })
36
+ ), D = Mt(I);
37
+ if (D === "xls") throw new Error("这是旧版 .xls(BIFF) 或加密文件,本预览器只支持 .xlsx/.xlsm。");
38
+ if (D === "not-zip") throw new Error("文件不是有效的 .xlsx(非 ZIP 包)。");
39
+ if (D === "empty") throw new Error("文件为空。");
40
+ let H = await Tt(I, (X) => A(X));
41
+ L && (H = L(H) ?? H), At(H), K(I.slice(0)), W.current = H, s(H);
42
+ } catch (I) {
43
+ const D = I == null ? void 0 : I.message;
44
+ w(D && /预览器|损坏|加密|为空|ZIP/.test(D) ? D : on(I)), console.error("[ooxml-preview] 解析失败:", I);
45
45
  } finally {
46
- a(!1), k(null);
46
+ c(!1), A(null);
47
47
  }
48
- }, []), K = at((A, J) => {
49
- D.current && it(D.current), z(null), S(null), k(null);
50
- const w = J ? J(A) ?? A : A;
51
- D.current = w, c(w);
48
+ }, []), $ = wt((p, L) => {
49
+ W.current && yt(W.current), K(null), w(null), A(null);
50
+ const I = L ? L(p) ?? p : p;
51
+ W.current = I, s(I);
52
52
  }, []);
53
- return { loading: g, error: I, workbook: N, progress: E, load: y, loadModel: K, sourceBuffer: _ };
53
+ return { loading: f, error: k, workbook: T, progress: F, load: N, loadModel: $, sourceBuffer: Y };
54
54
  }
55
- function se(g) {
56
- return isFinite(g) ? g.toLocaleString("en-US", { maximumFractionDigits: 2 }) : "—";
55
+ function me(f) {
56
+ return isFinite(f) ? f.toLocaleString("en-US", { maximumFractionDigits: 2 }) : "—";
57
57
  }
58
- const Gt = Pt(function(a, I) {
59
- var Ue;
60
- const { loading: S, error: N, workbook: c, progress: E, load: k, loadModel: _, sourceBuffer: z } = $t(), D = (e) => e ? Wt(e) ? e : Lt(e, a.jsonOptions) : null, [y, K] = R(0), [A, J] = R(1), [w, M] = R(null), [O, $] = R(null), W = w ?? a.templateFile ?? null, X = O ?? a.templateName ?? "", bt = () => {
61
- M(null), $(null);
62
- }, Te = C(null), St = () => {
58
+ const vn = Qt(function(c, k) {
59
+ var it;
60
+ const { loading: w, error: T, workbook: s, progress: F, load: A, loadModel: Y, sourceBuffer: K } = dn(), W = (e) => e ? tn(e) ? e : nn(e, c.jsonOptions) : null, [N, $] = y(0), [p, L] = y(1), [I, D] = y(null), [H, X] = y(null), ee = I ?? c.templateFile ?? null, te = H ?? c.templateName ?? "", ze = () => {
61
+ D(null), X(null);
62
+ }, We = v(null), Dt = () => {
63
63
  var e;
64
- return (e = Te.current) == null ? void 0 : e.click();
65
- }, wt = (e) => {
64
+ return (e = We.current) == null ? void 0 : e.click();
65
+ }, Ot = (e) => {
66
66
  var n;
67
67
  const t = (n = e.target.files) == null ? void 0 : n[0];
68
- t && (M(t), $(t.name), e.target.value = "");
69
- }, ie = a.fileName || (a.workbook ? "JSON 数据" : ((Ue = c == null ? void 0 : c.sheets[0]) == null ? void 0 : Ue.name) || ""), [ue, de] = R(!1), [, L] = Dt((e) => e + 1, 0), [Rt, ke] = R(""), Q = C(!1), Ae = C(null), Me = C(null), j = C(null), Pe = C(null), ge = C(null), fe = C(null), me = C(null), Ce = C(null), r = C(null), he = C(null), ve = C(null), xe = C(null), re = C(null), be = C(/* @__PURE__ */ new Map()), u = C(a);
70
- u.current = a;
71
- const le = a.plugins ?? [], U = C(le);
72
- U.current = le;
73
- const Z = C(c);
74
- Z.current = c;
75
- const Se = C(y);
76
- Se.current = y;
77
- function Et() {
78
- const e = U.current, t = Object.assign({}, ...e.map((i) => i.theme || {}), u.current.theme || {}), n = e.map((i) => i.cellStyle).filter(Boolean);
68
+ t && (D(t), X(t.name), e.target.value = "");
69
+ }, Le = c.fileName || (c.workbook ? "JSON 数据" : ((it = s == null ? void 0 : s.sheets[0]) == null ? void 0 : it.name) || ""), [Ce, he] = y(!1), [se, j] = y(null);
70
+ E(() => {
71
+ if (typeof document > "u") return;
72
+ const e = (t) => {
73
+ var n;
74
+ (n = t.target) != null && n.closest("[data-tb-menu]") || j(null);
75
+ };
76
+ return document.addEventListener("click", e), () => document.removeEventListener("click", e);
77
+ }, []);
78
+ const [, B] = Yt((e) => e + 1, 0), [zt, He] = y(""), ne = v(!1), Be = v(null), Ve = () => {
79
+ const e = Be.current;
80
+ e && (e.style.height = "auto", e.style.height = e.scrollHeight + "px");
81
+ };
82
+ E(() => {
83
+ Ve();
84
+ });
85
+ const Je = v(null), _e = v(null), U = v(null), Ke = v(null), ve = v(null), xe = v(null), be = v(null), pe = v(null), r = v(null), Se = v(null), we = v(null), Ie = v(null), ie = v(null), ye = v(/* @__PURE__ */ new Map()), u = v(c);
86
+ u.current = c;
87
+ const ue = c.plugins ?? [], Z = v(ue);
88
+ Z.current = ue;
89
+ const G = v(s);
90
+ G.current = s;
91
+ const Re = v(N);
92
+ Re.current = N;
93
+ function Wt() {
94
+ const e = Z.current, t = Object.assign({}, ...e.map((o) => o.theme || {}), u.current.theme || {}), n = e.map((o) => o.cellStyle).filter(Boolean);
79
95
  u.current.cellStyle && n.push(u.current.cellStyle);
80
- const l = n.length ? (i, h, o) => {
96
+ const l = n.length ? (o, m, i) => {
81
97
  let d;
82
- for (const v of n) {
83
- const b = v(i, h, o);
84
- b && (d = { ...d || {}, ...b });
98
+ for (const x of n) {
99
+ const S = x(o, m, i);
100
+ S && (d = { ...d || {}, ...S });
85
101
  }
86
102
  return d;
87
103
  } : void 0;
@@ -89,10 +105,10 @@ const Gt = Pt(function(a, I) {
89
105
  }
90
106
  function q(e) {
91
107
  let t = e;
92
- for (const n of U.current) n.transformModel && (t = n.transformModel(t) ?? t);
108
+ for (const n of Z.current) n.transformModel && (t = n.transformModel(t) ?? t);
93
109
  return u.current.transformModel && (t = u.current.transformModel(t) ?? t), t;
94
110
  }
95
- function De() {
111
+ function $e() {
96
112
  const e = u.current;
97
113
  return {
98
114
  editable: e.editable,
@@ -104,204 +120,204 @@ const Gt = Pt(function(a, I) {
104
120
  formulaEngine: e.formulaEngine
105
121
  };
106
122
  }
107
- function Oe() {
108
- if (u.current.editor || U.current.some((t) => t.editor))
123
+ function Xe() {
124
+ if (u.current.editor || Z.current.some((t) => t.editor))
109
125
  return (t, n) => {
110
- var i, h, o;
111
- const l = (h = (i = u.current).editor) == null ? void 0 : h.call(i, t, n);
126
+ var o, m, i;
127
+ const l = (m = (o = u.current).editor) == null ? void 0 : m.call(o, t, n);
112
128
  if (l) return l;
113
- for (const d of U.current) {
114
- const v = (o = d.editor) == null ? void 0 : o.call(d, t, n);
115
- if (v) return v;
129
+ for (const d of Z.current) {
130
+ const x = (i = d.editor) == null ? void 0 : i.call(d, t, n);
131
+ if (x) return x;
116
132
  }
117
133
  };
118
134
  }
119
- const G = (e, t) => {
135
+ const Q = (e, t) => {
120
136
  var n;
121
- return (n = be.current.get(e)) == null ? void 0 : n.forEach((l) => l(t));
122
- }, We = (e) => {
137
+ return (n = ye.current.get(e)) == null ? void 0 : n.forEach((l) => l(t));
138
+ }, re = (e) => {
123
139
  var n, l;
124
140
  const t = String((e == null ? void 0 : e.message) ?? e);
125
141
  console.error("[ooxml-excel-editor] 导出失败:", e), (l = (n = u.current).onError) == null || l.call(n, t), typeof window < "u" && window.alert && window.alert(t);
126
- }, [Le, we] = R(null), [Be, He] = R(!1), Re = C(null), Ve = () => {
142
+ }, [je, Ee] = y(null), [Ue, Ze] = y(!1), Fe = v(null), Ge = () => {
127
143
  var e;
128
- return (e = Re.current) == null ? void 0 : e.abort();
144
+ return (e = Fe.current) == null ? void 0 : e.abort();
129
145
  };
130
- function x(e, t) {
146
+ function b(e, t) {
131
147
  if (u.current.exportProgress === !1) return t(e);
132
148
  const n = new AbortController();
133
- Re.current = n, e != null && e.signal && (e.signal.aborted ? n.abort() : e.signal.addEventListener("abort", () => n.abort(), { once: !0 })), He(!0), we(null);
134
- const i = { ...e ?? {}, onProgress: (h) => {
135
- var o;
136
- we(h), (o = e == null ? void 0 : e.onProgress) == null || o.call(e, h);
149
+ Fe.current = n, e != null && e.signal && (e.signal.aborted ? n.abort() : e.signal.addEventListener("abort", () => n.abort(), { once: !0 })), Ze(!0), Ee(null);
150
+ const o = { ...e ?? {}, onProgress: (m) => {
151
+ var i;
152
+ Ee(m), (i = e == null ? void 0 : e.onProgress) == null || i.call(e, m);
137
153
  }, signal: n.signal };
138
- return t(i).finally(() => {
139
- He(!1), we(null), Re.current = null;
154
+ return t(o).finally(() => {
155
+ Ze(!1), Ee(null), Fe.current = null;
140
156
  });
141
157
  }
142
- function Ee() {
143
- const e = re.current, t = r.current;
158
+ function ke() {
159
+ const e = ie.current, t = r.current;
144
160
  if (!e || !t) return;
145
161
  const n = {
146
- rectOf: (l, i) => t.rectOf(l, i),
162
+ rectOf: (l, o) => t.rectOf(l, o),
147
163
  rectOfRange: (l) => t.rectOfRange(l),
148
164
  tick: 0,
149
- workbook: Z.current
165
+ workbook: G.current
150
166
  };
151
- e.render(U.current, n);
167
+ e.render(Z.current, n);
152
168
  }
153
- st(() => {
154
- const e = Me.current, t = Ae.current, n = j.current, l = Pe.current;
155
- if (!e || !t || !n || !l || !xe.current || !ge.current || !fe.current || !me.current || !Ce.current) return;
156
- const i = new Vt(
169
+ It(() => {
170
+ const e = _e.current, t = Je.current, n = U.current, l = Ke.current;
171
+ if (!e || !t || !n || !l || !Ie.current || !ve.current || !xe.current || !be.current || !pe.current) return;
172
+ const o = new cn(
157
173
  {
158
174
  canvas: e,
159
175
  renderArea: t,
160
176
  scroller: n,
161
177
  spacer: l,
162
- overlays: { main: ge.current, frow: fe.current, fcol: me.current, corner: Ce.current },
163
- editorSlot: xe.current
178
+ overlays: { main: ve.current, frow: xe.current, fcol: be.current, corner: pe.current },
179
+ editorSlot: Ie.current
164
180
  },
165
181
  {
166
- onRenderer: () => L(),
167
- onRenderTick: () => Ee(),
182
+ onRenderer: () => B(),
183
+ onRenderTick: () => ke(),
168
184
  // 插件 overlay 随每帧重定位(纯 DOM,不触发 React 重渲)
169
- onSelectionChange: () => L(),
170
- onCellClick: (o, d, v) => {
171
- var T, V;
172
- const b = { row: o, col: d, text: v };
173
- (V = (T = u.current).onCellClick) == null || V.call(T, b), G("cell-click", b);
185
+ onSelectionChange: () => B(),
186
+ onCellClick: (i, d, x) => {
187
+ var M, _;
188
+ const S = { row: i, col: d, text: x };
189
+ (_ = (M = u.current).onCellClick) == null || _.call(M, S), Q("cell-click", S);
174
190
  },
175
- onCellDblClick: (o, d, v) => {
176
- var T, V;
177
- const b = { row: o, col: d, text: v };
178
- (V = (T = u.current).onCellDblClick) == null || V.call(T, b), G("cell-dblclick", b);
191
+ onCellDblClick: (i, d, x) => {
192
+ var M, _;
193
+ const S = { row: i, col: d, text: x };
194
+ (_ = (M = u.current).onCellDblClick) == null || _.call(M, S), Q("cell-dblclick", S);
179
195
  },
180
- onHyperlink: (o, d) => {
181
- var v, b;
182
- (b = (v = u.current).onHyperlinkClick) == null || b.call(v, { url: o, cell: d }), G("hyperlink-click", { url: o, cell: d }), u.current.openLinks !== !1 && window.open(o, "_blank", "noopener");
196
+ onHyperlink: (i, d) => {
197
+ var x, S;
198
+ (S = (x = u.current).onHyperlinkClick) == null || S.call(x, { url: i, cell: d }), Q("hyperlink-click", { url: i, cell: d }), u.current.openLinks !== !1 && window.open(i, "_blank", "noopener");
183
199
  },
184
- onTooltip: (o) => {
185
- he.current = o, L();
200
+ onTooltip: (i) => {
201
+ Se.current = i, B();
186
202
  },
187
- onFindChange: () => L(),
188
- onFilterChange: () => L(),
189
- onEditEvent: (o, d) => {
190
- var v, b, T, V, Ze, qe, Ge, _e, Qe, Ye, et, tt, nt, rt, lt, ct;
191
- o === "cell-change" ? (L(), (b = (v = u.current).onCellChange) == null || b.call(v, d)) : o === "edit-start" ? (V = (T = u.current).onEditStart) == null || V.call(T, d) : o === "edit-commit" ? (qe = (Ze = u.current).onEditCommit) == null || qe.call(Ze, d) : o === "dim-change" ? (_e = (Ge = u.current).onDimChange) == null || _e.call(Ge, d) : o === "dirty-change" ? (Ye = (Qe = u.current).onDirtyChange) == null || Ye.call(Qe, d) : o === "image-change" ? (tt = (et = u.current).onImageChange) == null || tt.call(et, d) : o === "struct-change" ? (rt = (nt = u.current).onStructChange) == null || rt.call(nt, d) : o === "permission-denied" && ((ct = (lt = u.current).onPermissionDenied) == null || ct.call(lt, d)), G(o, d);
203
+ onFindChange: () => B(),
204
+ onFilterChange: () => B(),
205
+ onEditEvent: (i, d) => {
206
+ var x, S, M, _, ut, dt, gt, ft, mt, Ct, ht, vt, xt, bt, pt, St;
207
+ i === "cell-change" ? (B(), (S = (x = u.current).onCellChange) == null || S.call(x, d)) : i === "edit-start" ? (_ = (M = u.current).onEditStart) == null || _.call(M, d) : i === "edit-commit" ? (dt = (ut = u.current).onEditCommit) == null || dt.call(ut, d) : i === "dim-change" ? (ft = (gt = u.current).onDimChange) == null || ft.call(gt, d) : i === "dirty-change" ? (Ct = (mt = u.current).onDirtyChange) == null || Ct.call(mt, d) : i === "image-change" ? (vt = (ht = u.current).onImageChange) == null || vt.call(ht, d) : i === "struct-change" ? (bt = (xt = u.current).onStructChange) == null || bt.call(xt, d) : i === "permission-denied" && ((St = (pt = u.current).onPermissionDenied) == null || St.call(pt, d)), Q(i, d);
192
208
  },
193
- onContextMenuBefore: (o) => {
194
- var d, v;
195
- for (const b of u.current.plugins ?? [])
196
- if (b.contextMenu) {
197
- const T = b.contextMenu(o.ctx, o.items);
198
- Array.isArray(T) && o.items.splice(0, o.items.length, ...T);
209
+ onContextMenuBefore: (i) => {
210
+ var d, x;
211
+ for (const S of u.current.plugins ?? [])
212
+ if (S.contextMenu) {
213
+ const M = S.contextMenu(i.ctx, i.items);
214
+ Array.isArray(M) && i.items.splice(0, i.items.length, ...M);
199
215
  }
200
- (v = (d = u.current).onBeforeContextMenu) == null || v.call(d, o), u.current.contextMenu === !1 && o.preventDefault();
216
+ (x = (d = u.current).onBeforeContextMenu) == null || x.call(d, i), u.current.contextMenu === !1 && i.preventDefault();
201
217
  },
202
- onContextMenuShow: (o) => {
203
- var d, v;
204
- return (v = (d = u.current).onContextMenuShow) == null ? void 0 : v.call(d, o);
218
+ onContextMenuShow: (i) => {
219
+ var d, x;
220
+ return (x = (d = u.current).onContextMenuShow) == null ? void 0 : x.call(d, i);
205
221
  }
206
222
  }
207
223
  );
208
- i.fileName = u.current.fileName, i.setEditConfig(De()), i.setEditorResolver(Oe()), i.setContextMenuTransform(typeof u.current.contextMenu == "function" ? u.current.contextMenu : null), i.setLightboxEnabled(u.current.imageLightbox !== !1), r.current = i, ve.current && (re.current = new Jt(ve.current));
209
- const h = new ResizeObserver(() => {
210
- i.measure(), i.render();
224
+ o.fileName = u.current.fileName, o.setEditConfig($e()), o.setEditorResolver(Xe()), o.setContextMenuTransform(typeof u.current.contextMenu == "function" ? u.current.contextMenu : null), o.setLightboxEnabled(u.current.imageLightbox !== !1), r.current = o, we.current && (ie.current = new an(we.current));
225
+ const m = new ResizeObserver(() => {
226
+ o.measure(), o.render();
211
227
  });
212
- return h.observe(t), () => {
213
- var o;
214
- h.disconnect(), i.dispose(), (o = re.current) == null || o.dispose(), re.current = null, r.current = null;
228
+ return m.observe(t), () => {
229
+ var i;
230
+ m.disconnect(), o.dispose(), (i = ie.current) == null || i.dispose(), ie.current = null, r.current = null;
215
231
  };
216
- }, []), p(() => {
217
- const e = W, t = D(a.workbook);
218
- async function n(i) {
219
- const h = await ht(i), o = vt(h);
220
- if (o === "xls") throw new Error("模板文件是旧版 .xls 或加密,仅支持 .xlsx/.xlsm");
221
- if (o === "not-zip") throw new Error("模板文件不是有效的 .xlsx(非 ZIP 包)");
222
- if (o === "empty") throw new Error("模板文件为空");
223
- const d = await Ct(h);
224
- return xt(d), d;
232
+ }, []), E(() => {
233
+ const e = ee, t = W(c.workbook);
234
+ async function n(o) {
235
+ const m = await Pt(o), i = Mt(m);
236
+ if (i === "xls") throw new Error("模板文件是旧版 .xls 或加密,仅支持 .xlsx/.xlsm");
237
+ if (i === "not-zip") throw new Error("模板文件不是有效的 .xlsx(非 ZIP 包)");
238
+ if (i === "empty") throw new Error("模板文件为空");
239
+ const d = await Tt(m);
240
+ return At(d), d;
225
241
  }
226
242
  async function l() {
227
- if (a.src) {
228
- e && console.warn("[ooxml-excel-editor] templateFile 只在 workbook (JSON / 模型) 数据源下生效;xlsx 数据源已自带格式,模板已忽略."), await k(a.src, q);
243
+ if (c.src) {
244
+ e && console.warn("[ooxml-excel-editor] templateFile 只在 workbook (JSON / 模型) 数据源下生效;xlsx 数据源已自带格式,模板已忽略."), await A(c.src, q);
229
245
  return;
230
246
  }
231
247
  if (t && e) {
232
248
  try {
233
- const i = await n(e), h = Bt(t, i);
234
- _(h, q);
235
- } catch (i) {
236
- console.error("[ooxml-excel-editor] 模板加载失败,降级为纯 JSON 渲染:", i), _(t, q);
249
+ const o = await n(e), m = rn(t, o);
250
+ Y(m, q);
251
+ } catch (o) {
252
+ console.error("[ooxml-excel-editor] 模板加载失败,降级为纯 JSON 渲染:", o), Y(t, q);
237
253
  }
238
254
  return;
239
255
  }
240
256
  if (t) {
241
- _(t, q);
257
+ Y(t, q);
242
258
  return;
243
259
  }
244
- e && await k(e, q);
260
+ e && await A(e, q);
245
261
  }
246
262
  l();
247
- }, [a.src, a.workbook, a.templateFile, w]), p(() => {
248
- r.current && (r.current.fileName = a.fileName);
249
- }, [a.fileName]), p(() => {
263
+ }, [c.src, c.workbook, c.templateFile, I]), E(() => {
264
+ r.current && (r.current.fileName = c.fileName);
265
+ }, [c.fileName]), E(() => {
250
266
  var e;
251
- (e = r.current) == null || e.setEditConfig(De());
252
- }, [a.editable, a.cellReadOnly, a.readOnlyRanges, a.editableTargets, a.strictDimensions, a.recalc, a.formulaEngine]), p(() => {
267
+ (e = r.current) == null || e.setEditConfig($e());
268
+ }, [c.editable, c.cellReadOnly, c.readOnlyRanges, c.editableTargets, c.strictDimensions, c.recalc, c.formulaEngine]), E(() => {
253
269
  var e;
254
270
  (e = r.current) == null || e.setContextMenuTransform(
255
- typeof a.contextMenu == "function" ? a.contextMenu : null
271
+ typeof c.contextMenu == "function" ? c.contextMenu : null
256
272
  );
257
- }, [a.contextMenu]), p(() => {
273
+ }, [c.contextMenu]), E(() => {
258
274
  var e;
259
- (e = r.current) == null || e.setEditorResolver(Oe());
260
- }, [a.editor, a.plugins]), p(() => {
275
+ (e = r.current) == null || e.setEditorResolver(Xe());
276
+ }, [c.editor, c.plugins]), E(() => {
261
277
  var e;
262
- a.cellImageFit && ((e = r.current) == null || e.setCellImageFit(a.cellImageFit));
263
- }, [a.cellImageFit]), p(() => {
278
+ c.cellImageFit && ((e = r.current) == null || e.setCellImageFit(c.cellImageFit));
279
+ }, [c.cellImageFit]), E(() => {
264
280
  var e;
265
- (e = r.current) == null || e.setLightboxEnabled(a.imageLightbox !== !1);
266
- }, [a.imageLightbox]), p(() => {
281
+ (e = r.current) == null || e.setLightboxEnabled(c.imageLightbox !== !1);
282
+ }, [c.imageLightbox]), E(() => {
267
283
  var e, t;
268
- c && (K(c.activeSheet), (t = (e = u.current).onRendered) == null || t.call(e, c));
269
- }, [c]), p(() => {
284
+ s && ($(s.activeSheet), (t = (e = u.current).onRendered) == null || t.call(e, s));
285
+ }, [s]), E(() => {
270
286
  var e, t;
271
- N && ((t = (e = u.current).onError) == null || t.call(e, N));
272
- }, [N]), st(() => {
273
- var l, i;
287
+ T && ((t = (e = u.current).onError) == null || t.call(e, T));
288
+ }, [T]), It(() => {
289
+ var l, o;
274
290
  const e = r.current;
275
- if (!e || !c) return;
276
- const t = c.sheets[y] ?? c.sheets[0] ?? null;
291
+ if (!e || !s) return;
292
+ const t = s.sheets[N] ?? s.sheets[0] ?? null;
277
293
  if (!t) return;
278
- e.rebuild(t, c, A, Et()), e.setSourceBuffer(z), Ee();
279
- const n = { index: y, name: t.name };
280
- (i = (l = u.current).onSheetChange) == null || i.call(l, n), G("sheet-change", n);
281
- }, [c, y, a.theme, a.cellStyle, a.plugins, z]), p(() => {
294
+ e.rebuild(t, s, p, Wt()), e.setSourceBuffer(K), ke();
295
+ const n = { index: N, name: t.name };
296
+ (o = (l = u.current).onSheetChange) == null || o.call(l, n), Q("sheet-change", n);
297
+ }, [s, N, c.theme, c.cellStyle, c.plugins, K]), E(() => {
282
298
  var e;
283
- (e = r.current) == null || e.setZoom(A);
284
- }, [A]);
285
- const Je = C("");
286
- p(() => {
287
- var i, h;
299
+ (e = r.current) == null || e.setZoom(p);
300
+ }, [p]);
301
+ const qe = v("");
302
+ E(() => {
303
+ var o, m;
288
304
  const e = r.current;
289
305
  if (!e) return;
290
306
  const t = e.getSelection(), n = e.getActiveCell(), l = t && n ? `${t.top},${t.left},${t.bottom},${t.right}` : "";
291
- if (l && l !== Je.current && n) {
292
- Je.current = l;
293
- const o = { range: t, active: n };
294
- (h = (i = u.current).onSelectionChange) == null || h.call(i, o), G("selection-change", o);
307
+ if (l && l !== qe.current && n) {
308
+ qe.current = l;
309
+ const i = { range: t, active: n };
310
+ (m = (o = u.current).onSelectionChange) == null || m.call(o, i), Q("selection-change", i);
295
311
  }
296
312
  });
297
- const Y = (e) => (c == null ? void 0 : c.sheets[e ?? y]) ?? null, ze = (c == null ? void 0 : c.date1904) ?? !1, Ie = (e) => ({ ...e, date1904: ze });
298
- Ot(
299
- I,
313
+ const le = (e) => (s == null ? void 0 : s.sheets[e ?? N]) ?? null, Qe = (s == null ? void 0 : s.date1904) ?? !1, Ne = (e) => ({ ...e, date1904: Qe });
314
+ en(
315
+ k,
300
316
  () => ({
301
- load: (e) => k(e, a.transformModel),
302
- getWorkbook: () => c,
303
- getActiveSheet: () => y,
304
- setActiveSheet: (e) => (c == null ? void 0 : c.sheets[e]) && K(e),
317
+ load: (e) => A(e, c.transformModel),
318
+ getWorkbook: () => s,
319
+ getActiveSheet: () => N,
320
+ setActiveSheet: (e) => (s == null ? void 0 : s.sheets[e]) && $(e),
305
321
  getSelection: () => {
306
322
  var e;
307
323
  return ((e = r.current) == null ? void 0 : e.getSelection()) ?? null;
@@ -454,13 +470,13 @@ const Gt = Pt(function(a, I) {
454
470
  var t;
455
471
  return ((t = r.current) == null ? void 0 : t.convertAllImagesToCells(e)) ?? 0;
456
472
  },
457
- convertImagesInRangeToCell: (e) => x({}, async (t) => {
473
+ convertImagesInRangeToCell: (e) => b({}, async (t) => {
458
474
  var n, l;
459
475
  return (n = t.onProgress) == null || n.call(t, { stage: "convert", label: "选区浮动图批量嵌入…" }), ((l = r.current) == null ? void 0 : l.convertImagesInRangeToCell(e)) ?? 0;
460
476
  }),
461
- convertCellImagesInRangeToFloat: (e, t) => x({}, async (n) => {
462
- var l, i;
463
- return (l = n.onProgress) == null || l.call(n, { stage: "convert", label: "选区内嵌图批量浮动化…" }), ((i = r.current) == null ? void 0 : i.convertCellImagesInRangeToFloat(e, t)) ?? 0;
477
+ convertCellImagesInRangeToFloat: (e, t) => b({}, async (n) => {
478
+ var l, o;
479
+ return (l = n.onProgress) == null || l.call(n, { stage: "convert", label: "选区内嵌图批量浮动化…" }), ((o = r.current) == null ? void 0 : o.convertCellImagesInRangeToFloat(e, t)) ?? 0;
464
480
  }),
465
481
  openContextMenu: (e, t, n) => {
466
482
  var l;
@@ -570,13 +586,13 @@ const Gt = Pt(function(a, I) {
570
586
  var e;
571
587
  return ((e = r.current) == null ? void 0 : e.resetToOriginal()) ?? !1;
572
588
  },
573
- exportImage: (e) => x(e, (t) => r.current.exportImage(t)),
574
- downloadImage: (e) => x(e, (t) => r.current.downloadImage(t)),
575
- exportPdf: (e) => x(e, (t) => r.current.exportPdf(t)),
576
- downloadPdf: (e) => x(e, (t) => r.current.downloadPdf(t)),
577
- print: (e) => x(e, (t) => r.current.print(t)),
578
- exportXlsx: (e) => x(e, (t) => r.current.exportXlsx(t)),
579
- downloadXlsx: (e) => x(e, (t) => r.current.downloadXlsx(t)),
589
+ exportImage: (e) => b(e, (t) => r.current.exportImage(t)),
590
+ downloadImage: (e) => b(e, (t) => r.current.downloadImage(t)),
591
+ exportPdf: (e) => b(e, (t) => r.current.exportPdf(t)),
592
+ downloadPdf: (e) => b(e, (t) => r.current.downloadPdf(t)),
593
+ print: (e) => b(e, (t) => r.current.print(t)),
594
+ exportXlsx: (e) => b(e, (t) => r.current.exportXlsx(t)),
595
+ downloadXlsx: (e) => b(e, (t) => r.current.downloadXlsx(t)),
580
596
  exportJson: (e) => {
581
597
  var t;
582
598
  return ((t = r.current) == null ? void 0 : t.exportJson(e)) ?? "{}";
@@ -594,42 +610,42 @@ const Gt = Pt(function(a, I) {
594
610
  return (t = r.current) == null ? void 0 : t.downloadCsv(e);
595
611
  },
596
612
  getCellValue: (e, t, n) => {
597
- const l = Y(n);
598
- return l ? mt(l, e, t) : null;
613
+ const l = le(n);
614
+ return l ? Nt(l, e, t) : null;
599
615
  },
600
616
  getCellText: (e, t, n) => {
601
- const l = Y(n);
602
- return l ? ft(l, e, t, ze) : "";
617
+ const l = le(n);
618
+ return l ? kt(l, e, t, Qe) : "";
603
619
  },
604
620
  getSheetData: (e, t) => {
605
- const n = Y(t);
606
- return n ? gt(n, Ie(e)) : [];
621
+ const n = le(t);
622
+ return n ? Ft(n, Ne(e)) : [];
607
623
  },
608
624
  getSheetJSON: (e, t) => {
609
- const n = Y(t);
610
- return n ? dt(n, Ie(e)) : [];
625
+ const n = le(t);
626
+ return n ? Et(n, Ne(e)) : [];
611
627
  },
612
628
  getRangeData: (e, t, n) => {
613
- const l = Y(n);
614
- return l ? ut(l, e, Ie(t)) : [];
629
+ const l = le(n);
630
+ return l ? Rt(l, e, Ne(t)) : [];
615
631
  }
616
632
  }),
617
633
  // eslint-disable-next-line react-hooks/exhaustive-deps
618
- [c, y]
634
+ [s, N]
619
635
  );
620
- const ee = (e) => {
636
+ const oe = (e) => {
621
637
  var t;
622
- return ((t = Z.current) == null ? void 0 : t.sheets[e ?? Se.current]) ?? null;
623
- }, ce = () => {
638
+ return ((t = G.current) == null ? void 0 : t.sheets[e ?? Re.current]) ?? null;
639
+ }, de = () => {
624
640
  var e;
625
- return ((e = Z.current) == null ? void 0 : e.date1904) ?? !1;
626
- }, oe = C({
627
- load: (e) => k(e, q),
628
- getWorkbook: () => Z.current,
629
- getActiveSheet: () => Se.current,
641
+ return ((e = G.current) == null ? void 0 : e.date1904) ?? !1;
642
+ }, ge = v({
643
+ load: (e) => A(e, q),
644
+ getWorkbook: () => G.current,
645
+ getActiveSheet: () => Re.current,
630
646
  setActiveSheet: (e) => {
631
647
  var t;
632
- (t = Z.current) != null && t.sheets[e] && K(e);
648
+ (t = G.current) != null && t.sheets[e] && $(e);
633
649
  },
634
650
  getSelection: () => {
635
651
  var e;
@@ -783,13 +799,13 @@ const Gt = Pt(function(a, I) {
783
799
  var t;
784
800
  return ((t = r.current) == null ? void 0 : t.convertAllImagesToCells(e)) ?? 0;
785
801
  },
786
- convertImagesInRangeToCell: (e) => x({}, async (t) => {
802
+ convertImagesInRangeToCell: (e) => b({}, async (t) => {
787
803
  var n, l;
788
804
  return (n = t.onProgress) == null || n.call(t, { stage: "convert", label: "选区浮动图批量嵌入…" }), ((l = r.current) == null ? void 0 : l.convertImagesInRangeToCell(e)) ?? 0;
789
805
  }),
790
- convertCellImagesInRangeToFloat: (e, t) => x({}, async (n) => {
791
- var l, i;
792
- return (l = n.onProgress) == null || l.call(n, { stage: "convert", label: "选区内嵌图批量浮动化…" }), ((i = r.current) == null ? void 0 : i.convertCellImagesInRangeToFloat(e, t)) ?? 0;
806
+ convertCellImagesInRangeToFloat: (e, t) => b({}, async (n) => {
807
+ var l, o;
808
+ return (l = n.onProgress) == null || l.call(n, { stage: "convert", label: "选区内嵌图批量浮动化…" }), ((o = r.current) == null ? void 0 : o.convertCellImagesInRangeToFloat(e, t)) ?? 0;
793
809
  }),
794
810
  openContextMenu: (e, t, n) => {
795
811
  var l;
@@ -899,13 +915,13 @@ const Gt = Pt(function(a, I) {
899
915
  var e;
900
916
  return ((e = r.current) == null ? void 0 : e.resetToOriginal()) ?? !1;
901
917
  },
902
- exportImage: (e) => x(e, (t) => r.current.exportImage(t)),
903
- downloadImage: (e) => x(e, (t) => r.current.downloadImage(t)),
904
- exportPdf: (e) => x(e, (t) => r.current.exportPdf(t)),
905
- downloadPdf: (e) => x(e, (t) => r.current.downloadPdf(t)),
906
- print: (e) => x(e, (t) => r.current.print(t)),
907
- exportXlsx: (e) => x(e, (t) => r.current.exportXlsx(t)),
908
- downloadXlsx: (e) => x(e, (t) => r.current.downloadXlsx(t)),
918
+ exportImage: (e) => b(e, (t) => r.current.exportImage(t)),
919
+ downloadImage: (e) => b(e, (t) => r.current.downloadImage(t)),
920
+ exportPdf: (e) => b(e, (t) => r.current.exportPdf(t)),
921
+ downloadPdf: (e) => b(e, (t) => r.current.downloadPdf(t)),
922
+ print: (e) => b(e, (t) => r.current.print(t)),
923
+ exportXlsx: (e) => b(e, (t) => r.current.exportXlsx(t)),
924
+ downloadXlsx: (e) => b(e, (t) => r.current.downloadXlsx(t)),
909
925
  exportJson: (e) => {
910
926
  var t;
911
927
  return ((t = r.current) == null ? void 0 : t.exportJson(e)) ?? "{}";
@@ -923,185 +939,335 @@ const Gt = Pt(function(a, I) {
923
939
  return (t = r.current) == null ? void 0 : t.downloadCsv(e);
924
940
  },
925
941
  getCellValue: (e, t, n) => {
926
- const l = ee(n);
927
- return l ? mt(l, e, t) : null;
942
+ const l = oe(n);
943
+ return l ? Nt(l, e, t) : null;
928
944
  },
929
945
  getCellText: (e, t, n) => {
930
- const l = ee(n);
931
- return l ? ft(l, e, t, ce()) : "";
946
+ const l = oe(n);
947
+ return l ? kt(l, e, t, de()) : "";
932
948
  },
933
949
  getSheetData: (e, t) => {
934
- const n = ee(t);
935
- return n ? gt(n, { ...e, date1904: ce() }) : [];
950
+ const n = oe(t);
951
+ return n ? Ft(n, { ...e, date1904: de() }) : [];
936
952
  },
937
953
  getSheetJSON: (e, t) => {
938
- const n = ee(t);
939
- return n ? dt(n, { ...e, date1904: ce() }) : [];
954
+ const n = oe(t);
955
+ return n ? Et(n, { ...e, date1904: de() }) : [];
940
956
  },
941
957
  getRangeData: (e, t, n) => {
942
- const l = ee(n);
943
- return l ? ut(l, e, { ...t, date1904: ce() }) : [];
958
+ const l = oe(n);
959
+ return l ? Rt(l, e, { ...t, date1904: de() }) : [];
944
960
  }
945
961
  }).current;
946
- p(() => {
962
+ E(() => {
947
963
  var l;
948
- const e = /* @__PURE__ */ new Map(), t = [], n = (i, h) => {
949
- let o = e.get(i);
950
- o || e.set(i, o = /* @__PURE__ */ new Set()), o.add(h);
964
+ const e = /* @__PURE__ */ new Map(), t = [], n = (o, m) => {
965
+ let i = e.get(o);
966
+ i || e.set(o, i = /* @__PURE__ */ new Set()), i.add(m);
951
967
  };
952
- for (const i of le) {
953
- if (i.events)
954
- for (const [o, d] of Object.entries(i.events)) d && n(o, d);
955
- const h = (l = i.setup) == null ? void 0 : l.call(i, { viewer: oe, on: n, redraw: () => {
956
- var o;
957
- return (o = r.current) == null ? void 0 : o.render();
968
+ for (const o of ue) {
969
+ if (o.events)
970
+ for (const [i, d] of Object.entries(o.events)) d && n(i, d);
971
+ const m = (l = o.setup) == null ? void 0 : l.call(o, { viewer: ge, on: n, redraw: () => {
972
+ var i;
973
+ return (i = r.current) == null ? void 0 : i.render();
958
974
  } });
959
- typeof h == "function" && t.push(h);
975
+ typeof m == "function" && t.push(m);
960
976
  }
961
- return be.current = e, Ee(), () => {
962
- t.forEach((i) => i()), be.current = /* @__PURE__ */ new Map();
977
+ return ye.current = e, ke(), () => {
978
+ t.forEach((o) => o()), ye.current = /* @__PURE__ */ new Map();
963
979
  };
964
- }, [a.plugins]);
965
- const It = (e) => {
966
- (e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F") && (e.preventDefault(), de(!0));
967
- }, ye = () => {
980
+ }, [c.plugins]);
981
+ const Lt = (e) => {
982
+ (e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F") && (e.preventDefault(), he(!0));
983
+ }, Te = () => {
968
984
  var e, t;
969
- de(!1), (e = r.current) == null || e.clearFind(), (t = j.current) == null || t.focus();
970
- }, yt = () => {
985
+ he(!1), (e = r.current) == null || e.clearFind(), (t = U.current) == null || t.focus();
986
+ }, Ht = () => {
971
987
  var t;
972
- const e = j.current;
973
- e && (he.current = null, (t = r.current) == null || t.setScroll(e.scrollLeft, e.scrollTop));
974
- }, f = r.current, te = (f == null ? void 0 : f.renderer) ?? null, B = (f == null ? void 0 : f.getActiveCell()) ?? null, F = (f == null ? void 0 : f.getSelection()) ?? null, Ke = B ? Ne(B.col) + (B.row + 1) : "", $e = te && B ? te.cellFormula(B.row, B.col) ?? te.cellText(B.row, B.col) : "", Ft = !!(f != null && f.canEditActiveCell()), pt = (f == null ? void 0 : f.getCellEditString()) ?? "", Fe = Q.current ? Rt : pt, Nt = () => {
975
- Q.current = !0, ke((f == null ? void 0 : f.getCellEditString()) ?? "");
976
- }, Xe = (e) => {
988
+ const e = U.current;
989
+ e && (Se.current = null, (t = r.current) == null || t.setScroll(e.scrollLeft, e.scrollTop));
990
+ }, h = r.current, ce = (h == null ? void 0 : h.renderer) ?? null, V = (h == null ? void 0 : h.getActiveCell()) ?? null, R = (h == null ? void 0 : h.getSelection()) ?? null, Ye = V ? Oe(V.col) + (V.row + 1) : "", et = ce && V ? ce.cellFormula(V.row, V.col) ?? ce.cellText(V.row, V.col) : "", Bt = !!(h != null && h.canEditActiveCell()), Vt = (h == null ? void 0 : h.getCellEditString()) ?? "", Pe = ne.current ? zt : Vt, Jt = () => {
991
+ ne.current = !0, He((h == null ? void 0 : h.getCellEditString()) ?? "");
992
+ }, tt = (e) => {
977
993
  var t;
978
- f == null || f.commitActiveCellValue(Fe, e), Q.current = !1, e === "down" && ((t = j.current) == null || t.focus()), L();
979
- }, Tt = () => {
994
+ h == null || h.commitActiveCellValue(Pe, e), ne.current = !1, e === "down" && ((t = U.current) == null || t.focus()), B();
995
+ }, _t = () => {
980
996
  var e;
981
- Q.current = !1, (e = j.current) == null || e.focus(), L();
982
- }, kt = () => {
983
- Q.current && Xe();
984
- }, At = (e) => {
985
- e.stopPropagation(), e.key === "Enter" ? (e.preventDefault(), Xe("down")) : e.key === "Escape" && (e.preventDefault(), Tt());
986
- }, Mt = F && !(F.top === F.bottom && F.left === F.right) ? `${Ne(F.left)}${F.top + 1}:${Ne(F.right)}${F.bottom + 1}` : "", P = te && F ? te.selectionStats(F) : null, ae = (f == null ? void 0 : f.getFindState()) ?? { query: "", count: 0, index: -1 }, H = (f == null ? void 0 : f.getFilterPopup()) ?? null, ne = he.current, pe = (c == null ? void 0 : c.sheets[y]) ?? null, je = c ? c.sheets.map((e, t) => ({ s: e, i: t })).filter(({ s: e }) => e.state === "visible") : [];
987
- return /* @__PURE__ */ m("div", { className: "rxl" + (a.className ? " " + a.className : ""), style: a.style, onKeyDown: It, children: [
988
- c && (ie || X) && /* @__PURE__ */ m("div", { className: "rxl-title", title: ie + (X ? " · 模板: " + X : ""), children: [
989
- /* @__PURE__ */ s("span", { className: "name", children: ie || "未命名工作簿" }),
990
- X && /* @__PURE__ */ m("span", { className: "tpl", children: [
991
- " · 模板: ",
992
- X
993
- ] })
994
- ] }),
995
- /* @__PURE__ */ s("input", { ref: Te, type: "file", accept: ".xlsx,.xlsm", hidden: !0, onChange: wt }),
996
- c && /* @__PURE__ */ m("div", { className: "rxl-toolbar", children: [
997
- /* @__PURE__ */ s(
998
- "button",
999
- {
1000
- className: ue ? "active" : "",
1001
- onClick: () => ue ? ye() : de(!0),
1002
- title: "查找 (Ctrl+F)",
1003
- children: "查找"
1004
- }
1005
- ),
1006
- /* @__PURE__ */ s(
1007
- "button",
1008
- {
1009
- className: pe != null && pe.autoFilterRange ? "active" : "",
1010
- onClick: () => {
1011
- var e;
1012
- return (e = r.current) == null ? void 0 : e.toggleAutoFilter();
1013
- },
1014
- title: "切换自动筛选",
1015
- children: "筛选"
997
+ ne.current = !1, (e = U.current) == null || e.focus(), B();
998
+ }, Kt = () => {
999
+ ne.current && tt();
1000
+ }, $t = (e) => {
1001
+ e.stopPropagation(), e.key === "Enter" ? (e.preventDefault(), tt("down")) : e.key === "Escape" && (e.preventDefault(), _t());
1002
+ }, Xt = R && !(R.top === R.bottom && R.left === R.right) ? `${Oe(R.left)}${R.top + 1}:${Oe(R.right)}${R.bottom + 1}` : "", O = ce && R ? ce.selectionStats(R) : null, fe = (h == null ? void 0 : h.getFindState()) ?? { query: "", count: 0, index: -1 }, P = (e) => ln[e], C = (e) => ({ kind: "builtin", ...e }), z = s == null ? void 0 : s.sheets[N], nt = () => {
1003
+ var e;
1004
+ return void ((e = r.current) == null ? void 0 : e.downloadPdf().catch(re));
1005
+ }, rt = () => {
1006
+ var e;
1007
+ return void ((e = r.current) == null ? void 0 : e.downloadPdf({ vector: !0 }).catch(re));
1008
+ }, lt = () => {
1009
+ var e;
1010
+ return void ((e = r.current) == null ? void 0 : e.print().catch(re));
1011
+ }, jt = () => {
1012
+ var l;
1013
+ const e = z, t = r.current;
1014
+ if (!e || !t) return;
1015
+ const n = e.freeze;
1016
+ if (n.frozenRows || n.frozenCols) e.freeze = { frozenRows: 0, frozenCols: 0 };
1017
+ else {
1018
+ const o = t.getActiveCell();
1019
+ e.freeze = { frozenRows: o ? o.row : 1, frozenCols: o ? o.col : 0 };
1020
+ }
1021
+ (l = t.renderer) == null || l.rebuildMetrics(), t.refreshContentSize(), t.render();
1022
+ };
1023
+ function Ut(e) {
1024
+ const t = r.current;
1025
+ switch (e) {
1026
+ case "find":
1027
+ return C({ id: e, iconSvg: P("find"), label: "查找", title: "查找 (Ctrl+F)", active: Ce, onClick: () => Ce ? Te() : he(!0) });
1028
+ case "filter":
1029
+ return C({ id: e, iconSvg: P("filter"), label: "筛选", title: "切换自动筛选", active: !!(z != null && z.autoFilterRange), onClick: () => t == null ? void 0 : t.toggleAutoFilter() });
1030
+ case "clear-filter":
1031
+ return C({ id: e, iconSvg: P("clear-filter"), label: "清除筛选", title: "清除当前表全部筛选", disabled: !(t != null && t.hasFilters()), onClick: () => t == null ? void 0 : t.clearAllFilters() });
1032
+ case "copy":
1033
+ return C({ id: e, iconSvg: P("copy"), label: "复制", title: "复制选区 (Ctrl+C)", disabled: !R, onClick: () => void (t == null ? void 0 : t.copySelection()) });
1034
+ case "wrap-text": {
1035
+ const n = (t == null ? void 0 : t.getSelectionWrapState()) ?? "none";
1036
+ return C({ id: e, iconSvg: P("wrap-text"), label: "自动换行", title: "自动换行(选区,WPS 风格 toggle)", active: n === "all", disabled: !R || !c.editable, onClick: () => void (t == null ? void 0 : t.toggleWrapTextOnSelection()) });
1037
+ }
1038
+ case "template": {
1039
+ const n = !!ee, l = te, o = !!c.src && !c.workbook;
1040
+ return C({
1041
+ id: e,
1042
+ iconSvg: P("template"),
1043
+ label: "模板",
1044
+ title: o ? "模板仅对 JSON / 模型数据源生效;当前是 .xlsx 数据源,模板不可用" : n ? `模板已加载:${l || "(未命名)"}` : "为 JSON / 模型数据源套用 .xlsx 模板的样式;模板的文字内容会被丢弃",
1045
+ active: n,
1046
+ disabled: o,
1047
+ items: [
1048
+ C({ id: "tpl-default", label: (n ? "" : "✓ ") + "默认渲染", title: "不套模板,数据按默认样式渲染", disabled: !n, onClick: ze }),
1049
+ C({ id: "tpl-sep", type: "separator" }),
1050
+ C({ id: "tpl-import", label: "导入 .xlsx 模板…", title: "选一份 .xlsx, 把它的 styling 套到当前 JSON 数据上", onClick: Dt }),
1051
+ C({ id: "tpl-clear", label: "清除模板", title: "切回默认样式渲染", disabled: !n, onClick: ze })
1052
+ ]
1053
+ });
1054
+ }
1055
+ case "image-tools": {
1056
+ const n = R, l = t == null ? void 0 : t.getActiveCell(), o = ((z == null ? void 0 : z.images.length) ?? 0) > 0;
1057
+ return C({
1058
+ id: e,
1059
+ iconSvg: P("image-tools"),
1060
+ label: "图片工具",
1061
+ title: "浮动图 ⇄ 单元格内嵌图(WPS DISPIMG)互转",
1062
+ disabled: !c.editable,
1063
+ items: [
1064
+ C({ id: "img-sel-to-cell", label: "选区:浮动 → 嵌入", title: '把选区里"中心格在选区内"的浮动图就近嵌入', disabled: !n || !o, onClick: () => n && (t == null ? void 0 : t.convertImagesInRangeToCell(n)) }),
1065
+ C({ id: "img-sel-to-float", label: "选区:嵌入 → 浮动", title: "把选区内所有 DISPIMG 格拎成浮动图", disabled: !n, onClick: () => n && (t == null ? void 0 : t.convertCellImagesInRangeToFloat(n)) }),
1066
+ C({ id: "img-sep", type: "separator" }),
1067
+ C({ id: "img-all-to-cell", label: "整表:浮动 → 嵌入", title: "全表浮动图按几何就近嵌入各自单元格", disabled: !o, onClick: () => t == null ? void 0 : t.convertAllImagesToCells() }),
1068
+ C({ id: "img-col-to-cell", label: "整列:浮动 → 嵌入(活动列)", title: "把中心落在活动列的浮动图就近嵌入", disabled: !o || !l, onClick: () => l && (t == null ? void 0 : t.convertAllImagesToCells(l.col)) })
1069
+ ]
1070
+ });
1071
+ }
1072
+ case "freeze": {
1073
+ const n = z == null ? void 0 : z.freeze;
1074
+ return C({ id: e, iconSvg: P("freeze"), label: "冻结", title: "冻结/取消冻结(在活动单元格)", active: !!(n && (n.frozenRows || n.frozenCols)), onClick: jt });
1075
+ }
1076
+ case "export":
1077
+ return C({
1078
+ id: e,
1079
+ iconSvg: P("export"),
1080
+ label: "导出",
1081
+ title: "导出 / 打印",
1082
+ items: [
1083
+ C({ id: "export-png", label: "导出为图片 (PNG)", onClick: () => void (t == null ? void 0 : t.downloadImage().catch(re)) }),
1084
+ C({ id: "export-pdf", label: "导出为 PDF (位图)", onClick: nt }),
1085
+ C({ id: "export-pdf-vector", label: "导出为 PDF (矢量·文字可选)", onClick: rt }),
1086
+ C({ id: "export-print", label: "打印…", onClick: lt })
1087
+ ]
1088
+ });
1089
+ case "zoom":
1090
+ return C({
1091
+ id: e,
1092
+ iconSvg: P("zoom"),
1093
+ label: Math.round(p * 100) + "%",
1094
+ title: "缩放",
1095
+ items: [50, 75, 100, 125, 150, 200].map((n) => C({ id: "zoom-" + n, label: n + "%", active: Math.round(p * 100) === n, onClick: () => L(n / 100) }))
1096
+ });
1097
+ }
1098
+ return null;
1099
+ }
1100
+ function Me(e, t) {
1101
+ var l;
1102
+ const n = { kind: t, id: e.id, type: e.type, icon: e.icon, label: e.label, title: e.title };
1103
+ return e.active && (n.active = !!e.active(ge)), e.disabled && (n.disabled = !!e.disabled(ge)), e.onClick && (n.onClick = () => {
1104
+ var o;
1105
+ return (o = e.onClick) == null ? void 0 : o.call(e, ge);
1106
+ }), (l = e.items) != null && l.length && (n.items = e.items.map((o) => Me(o, t))), n;
1107
+ }
1108
+ const ot = (() => {
1109
+ if (c.toolbar === !1) return [];
1110
+ const e = Array.isArray(c.toolbar) ? c.toolbar : ["find", "filter"], t = [];
1111
+ for (const n of e)
1112
+ if (typeof n == "string")
1113
+ if (n === "separator" || n === "|") t.push({ id: "sep-" + t.length, type: "separator", kind: "builtin" });
1114
+ else {
1115
+ const l = Ut(n);
1116
+ l && t.push(l);
1016
1117
  }
1017
- ),
1018
- /* @__PURE__ */ s("button", { disabled: !(f != null && f.hasFilters()), onClick: () => {
1019
- var e;
1020
- return (e = r.current) == null ? void 0 : e.clearAllFilters();
1021
- }, children: "清除筛选" }),
1022
- /* @__PURE__ */ s("button", { disabled: !F, onClick: () => {
1023
- var e;
1024
- return void ((e = r.current) == null ? void 0 : e.copySelection());
1025
- }, title: "复制 (Ctrl+C)", children: "复制" }),
1026
- /* @__PURE__ */ s("button", { onClick: () => {
1027
- var e;
1028
- return void ((e = r.current) == null ? void 0 : e.downloadImage().catch(We));
1029
- }, children: "导出 PNG" }),
1030
- /* @__PURE__ */ s("button", { onClick: () => {
1031
- var e;
1032
- return void ((e = r.current) == null ? void 0 : e.downloadPdf().catch(We));
1033
- }, children: "导出 PDF" }),
1034
- /* @__PURE__ */ s("select", { value: Math.round(A * 100), onChange: (e) => J(Number(e.target.value) / 100), title: "缩放", children: [50, 75, 100, 125, 150, 200].map((e) => /* @__PURE__ */ m("option", { value: e, children: [
1035
- e,
1036
- "%"
1037
- ] }, e)) }),
1038
- (() => {
1039
- const e = !!a.src && !a.workbook;
1040
- return /* @__PURE__ */ m(ot, { children: [
1041
- /* @__PURE__ */ m(
1042
- "button",
1043
- {
1044
- className: W ? "active" : "",
1045
- disabled: e,
1046
- onClick: St,
1047
- title: e ? "模板仅对 JSON / 模型数据源生效;当前是 xlsx 数据源,模板不可用" : W ? `模板已加载: ${X || "(未命名)"} — 点击重新导入` : "为 JSON / 模型数据源套用 .xlsx 模板的样式(模板的文字内容会被丢弃)",
1048
- children: [
1049
- "模板",
1050
- W ? " ▾" : ""
1051
- ]
1052
- }
1053
- ),
1054
- W && !e && /* @__PURE__ */ s("button", { onClick: bt, title: "清除模板,切回默认渲染", children: "清除模板" })
1055
- ] });
1056
- })(),
1057
- le.flatMap((e) => e.toolbar ?? []).filter((e) => e.type !== "separator").map((e) => {
1058
- var t, n;
1059
- return /* @__PURE__ */ s(
1118
+ else
1119
+ t.push(Me(n, "custom"));
1120
+ for (const n of ue) for (const l of n.toolbar ?? []) t.push(Me(l, "plugin"));
1121
+ return t;
1122
+ })(), Zt = c.toolbar !== !1 && ot.length > 0, Gt = s ? s.sheets.filter((e) => e.state === "visible").length : 0, ct = [0.5, 0.75, 1, 1.25, 1.5, 2], Ae = (e) => L(Math.min(3, Math.max(0.3, e))), at = ({ items: e, onPick: t, className: n = "rxl-tb-menu" }) => /* @__PURE__ */ a("div", { className: n, "data-tb-menu": "true", children: e.map((l) => l.type === "separator" ? /* @__PURE__ */ a("div", { className: "sep" }, l.id) : /* @__PURE__ */ g(
1123
+ "button",
1124
+ {
1125
+ className: "mi" + (l.active ? " active" : ""),
1126
+ disabled: !!l.disabled,
1127
+ title: l.title,
1128
+ onClick: (o) => {
1129
+ o.stopPropagation(), l.disabled || t(l);
1130
+ },
1131
+ children: [
1132
+ l.iconSvg ? /* @__PURE__ */ a("span", { className: "ic", dangerouslySetInnerHTML: { __html: De(l.iconSvg) } }) : l.icon ? /* @__PURE__ */ a("span", { className: "ic-e", children: l.icon }) : null,
1133
+ /* @__PURE__ */ a("span", { className: "lb", children: l.label || l.id })
1134
+ ]
1135
+ },
1136
+ l.id
1137
+ )) }), J = (h == null ? void 0 : h.getFilterPopup()) ?? null, ae = Se.current, st = s ? s.sheets.map((e, t) => ({ s: e, i: t })).filter(({ s: e }) => e.state === "visible") : [];
1138
+ return /* @__PURE__ */ g("div", { className: "rxl" + (c.className ? " " + c.className : ""), style: c.style, onKeyDown: Lt, children: [
1139
+ /* @__PURE__ */ a("input", { ref: We, type: "file", accept: ".xlsx,.xlsm", hidden: !0, onChange: Ot }),
1140
+ s && /* @__PURE__ */ g("div", { className: "rxl-toolbar", children: [
1141
+ /* @__PURE__ */ g("span", { className: "file", title: Le + (te ? " · 模板: " + te : ""), children: [
1142
+ Le || "未命名工作簿",
1143
+ te && /* @__PURE__ */ g("span", { className: "tpl", children: [
1144
+ " · 模板: ",
1145
+ te
1146
+ ] })
1147
+ ] }),
1148
+ /* @__PURE__ */ g("span", { className: "meta", children: [
1149
+ Gt,
1150
+ " 个工作表"
1151
+ ] }),
1152
+ /* @__PURE__ */ a("div", { className: "spacer" }),
1153
+ /* @__PURE__ */ g("div", { className: "rxl-export-wrap", "data-tb-menu": "true", children: [
1154
+ /* @__PURE__ */ g(
1060
1155
  "button",
1061
1156
  {
1062
- className: (t = e.active) != null && t.call(e, oe) ? "active" : "",
1063
- disabled: (n = e.disabled) == null ? void 0 : n.call(e, oe),
1064
- title: e.title,
1065
- onClick: () => {
1066
- var l;
1067
- return (l = e.onClick) == null ? void 0 : l.call(e, oe);
1157
+ className: "rxl-export-btn" + (se === "__header-export" ? " open" : ""),
1158
+ onClick: (e) => {
1159
+ e.stopPropagation(), j(se === "__header-export" ? null : "__header-export");
1068
1160
  },
1069
- children: e.label ?? e.icon ?? e.id
1070
- },
1071
- e.id
1072
- );
1073
- })
1161
+ title: "导出 / 打印",
1162
+ children: [
1163
+ "导出 ",
1164
+ /* @__PURE__ */ a("span", { className: "caret", children: "▾" })
1165
+ ]
1166
+ }
1167
+ ),
1168
+ se === "__header-export" && /* @__PURE__ */ a(
1169
+ at,
1170
+ {
1171
+ items: [
1172
+ C({ id: "h-png", label: "导出为图片 (PNG)", onClick: () => {
1173
+ var e;
1174
+ return void ((e = r.current) == null ? void 0 : e.downloadImage().catch(re));
1175
+ } }),
1176
+ C({ id: "h-pdf", label: "导出为 PDF (位图)", onClick: nt }),
1177
+ C({ id: "h-pdf-vec", label: "导出为 PDF (矢量·文字可选)", onClick: rt }),
1178
+ C({ id: "h-print", label: "打印…", onClick: lt })
1179
+ ],
1180
+ onPick: (e) => {
1181
+ var t;
1182
+ j(null), (t = e.onClick) == null || t.call(e);
1183
+ },
1184
+ className: "rxl-tb-menu header-menu"
1185
+ }
1186
+ )
1187
+ ] }),
1188
+ /* @__PURE__ */ g("div", { className: "rxl-zoom", children: [
1189
+ /* @__PURE__ */ a("button", { onClick: () => Ae(p - 0.1), title: "缩小", children: "−" }),
1190
+ /* @__PURE__ */ g("select", { value: p, onChange: (e) => Ae(parseFloat(e.target.value)), children: [
1191
+ ct.map((e) => /* @__PURE__ */ g("option", { value: e, children: [
1192
+ Math.round(e * 100),
1193
+ "%"
1194
+ ] }, e)),
1195
+ !ct.includes(p) && /* @__PURE__ */ g("option", { value: p, children: [
1196
+ Math.round(p * 100),
1197
+ "%"
1198
+ ] }, "cur")
1199
+ ] }),
1200
+ /* @__PURE__ */ a("button", { onClick: () => Ae(p + 0.1), title: "放大", children: "+" })
1201
+ ] })
1074
1202
  ] }),
1075
- c && /* @__PURE__ */ m("div", { className: "rxl-formula-bar", children: [
1076
- /* @__PURE__ */ s("span", { className: "addr", children: Ke || "—" }),
1077
- /* @__PURE__ */ s("span", { className: "fx", children: "fx" }),
1078
- Ft ? /* @__PURE__ */ s(
1079
- "input",
1203
+ s && Zt && /* @__PURE__ */ a("div", { className: "rxl-action-toolbar", children: ot.map((e) => {
1204
+ var l;
1205
+ if (e.type === "separator") return /* @__PURE__ */ a("span", { className: "rxl-at-divider" }, e.id);
1206
+ const t = !!((l = e.items) != null && l.length), n = se === e.id;
1207
+ return /* @__PURE__ */ g("div", { className: "rxl-at-dd", "data-tb-menu": "true", children: [
1208
+ /* @__PURE__ */ g(
1209
+ "button",
1210
+ {
1211
+ className: "rxl-at-tool" + (e.active ? " active" : "") + (n ? " open" : ""),
1212
+ disabled: !!e.disabled,
1213
+ title: e.title || e.label || e.id,
1214
+ onClick: (o) => {
1215
+ var m;
1216
+ o.stopPropagation(), !e.disabled && (t ? j(n ? null : e.id) : ((m = e.onClick) == null || m.call(e), j(null)));
1217
+ },
1218
+ children: [
1219
+ e.iconSvg ? /* @__PURE__ */ a("span", { className: "rxl-at-ic", dangerouslySetInnerHTML: { __html: De(e.iconSvg) } }) : e.icon ? /* @__PURE__ */ a("span", { className: "rxl-at-ic-e", children: e.icon }) : null,
1220
+ e.label && /* @__PURE__ */ a("span", { className: "rxl-at-lb", children: e.label }),
1221
+ t && /* @__PURE__ */ a("span", { className: "rxl-at-caret", dangerouslySetInnerHTML: { __html: De(P("caret")) } })
1222
+ ]
1223
+ }
1224
+ ),
1225
+ t && n && /* @__PURE__ */ a(
1226
+ at,
1227
+ {
1228
+ items: e.items,
1229
+ onPick: (o) => {
1230
+ var m;
1231
+ j(null), (m = o.onClick) == null || m.call(o);
1232
+ }
1233
+ }
1234
+ )
1235
+ ] }, e.id);
1236
+ }) }),
1237
+ s && /* @__PURE__ */ g("div", { className: "rxl-formula-bar", children: [
1238
+ /* @__PURE__ */ a("span", { className: "addr", children: Ye || "—" }),
1239
+ /* @__PURE__ */ a("span", { className: "fx", children: "fx" }),
1240
+ Bt ? /* @__PURE__ */ a(
1241
+ "textarea",
1080
1242
  {
1243
+ ref: Be,
1081
1244
  className: "content content-input",
1082
- value: Fe,
1083
- title: Fe,
1245
+ value: Pe,
1246
+ title: Pe,
1247
+ rows: 1,
1084
1248
  spellCheck: !1,
1085
- onFocus: Nt,
1086
- onChange: (e) => ke(e.target.value),
1087
- onKeyDown: At,
1088
- onBlur: kt
1249
+ onFocus: Jt,
1250
+ onChange: (e) => {
1251
+ He(e.target.value), Ve();
1252
+ },
1253
+ onKeyDown: $t,
1254
+ onBlur: Kt
1089
1255
  }
1090
- ) : /* @__PURE__ */ s("span", { className: "content", title: $e, children: $e })
1256
+ ) : /* @__PURE__ */ a("span", { className: "content", title: et, children: et })
1091
1257
  ] }),
1092
- /* @__PURE__ */ m("div", { className: "rxl-render-area", ref: Ae, children: [
1093
- /* @__PURE__ */ s("canvas", { ref: Me, className: "rxl-canvas" }),
1094
- /* @__PURE__ */ s("div", { className: "rxl-ov", ref: ge }),
1095
- /* @__PURE__ */ s("div", { className: "rxl-ov", ref: me }),
1096
- /* @__PURE__ */ s("div", { className: "rxl-ov", ref: fe }),
1097
- /* @__PURE__ */ s("div", { className: "rxl-ov", ref: Ce }),
1098
- /* @__PURE__ */ s(
1258
+ /* @__PURE__ */ g("div", { className: "rxl-render-area", ref: Je, children: [
1259
+ /* @__PURE__ */ a("canvas", { ref: _e, className: "rxl-canvas" }),
1260
+ /* @__PURE__ */ a("div", { className: "rxl-ov", ref: ve }),
1261
+ /* @__PURE__ */ a("div", { className: "rxl-ov", ref: be }),
1262
+ /* @__PURE__ */ a("div", { className: "rxl-ov", ref: xe }),
1263
+ /* @__PURE__ */ a("div", { className: "rxl-ov", ref: pe }),
1264
+ /* @__PURE__ */ a(
1099
1265
  "div",
1100
1266
  {
1101
1267
  className: "rxl-scroller",
1102
- ref: j,
1268
+ ref: U,
1103
1269
  tabIndex: 0,
1104
- onScroll: yt,
1270
+ onScroll: Ht,
1105
1271
  onMouseDown: (e) => {
1106
1272
  var t;
1107
1273
  return (t = r.current) == null ? void 0 : t.onMouseDown(e.nativeEvent);
@@ -1130,47 +1296,47 @@ const Gt = Pt(function(a, I) {
1130
1296
  var t;
1131
1297
  return (t = r.current) == null ? void 0 : t.onContextMenu(e.nativeEvent);
1132
1298
  },
1133
- children: /* @__PURE__ */ s("div", { className: "rxl-spacer", ref: Pe })
1299
+ children: /* @__PURE__ */ a("div", { className: "rxl-spacer", ref: Ke })
1134
1300
  }
1135
1301
  ),
1136
- /* @__PURE__ */ s("div", { className: "rxl-ov-slot", children: /* @__PURE__ */ s("div", { ref: ve }) }),
1137
- /* @__PURE__ */ s("div", { className: "rxl-editor-slot", ref: xe }),
1138
- ue && c && /* @__PURE__ */ m("div", { className: "rxl-findbar", children: [
1139
- /* @__PURE__ */ s(
1302
+ /* @__PURE__ */ a("div", { className: "rxl-ov-slot", children: /* @__PURE__ */ a("div", { ref: we }) }),
1303
+ /* @__PURE__ */ a("div", { className: "rxl-editor-slot", ref: Ie }),
1304
+ Ce && s && /* @__PURE__ */ g("div", { className: "rxl-findbar", children: [
1305
+ /* @__PURE__ */ a(
1140
1306
  "input",
1141
1307
  {
1142
1308
  autoFocus: !0,
1143
1309
  placeholder: "查找…",
1144
- value: ae.query,
1310
+ value: fe.query,
1145
1311
  onChange: (e) => {
1146
1312
  var t;
1147
1313
  return (t = r.current) == null ? void 0 : t.setFindQuery(e.target.value);
1148
1314
  },
1149
1315
  onKeyDown: (e) => {
1150
1316
  var t, n;
1151
- e.key === "Enter" ? e.shiftKey ? (t = r.current) == null || t.findPrev() : (n = r.current) == null || n.findNext() : e.key === "Escape" && ye();
1317
+ e.key === "Enter" ? e.shiftKey ? (t = r.current) == null || t.findPrev() : (n = r.current) == null || n.findNext() : e.key === "Escape" && Te();
1152
1318
  }
1153
1319
  }
1154
1320
  ),
1155
- /* @__PURE__ */ s("span", { className: "count", children: ae.count ? `${ae.index + 1}/${ae.count}` : "无结果" }),
1156
- /* @__PURE__ */ s("button", { onClick: () => {
1321
+ /* @__PURE__ */ a("span", { className: "count", children: fe.count ? `${fe.index + 1}/${fe.count}` : "无结果" }),
1322
+ /* @__PURE__ */ a("button", { onClick: () => {
1157
1323
  var e;
1158
1324
  return (e = r.current) == null ? void 0 : e.findPrev();
1159
1325
  }, children: "↑" }),
1160
- /* @__PURE__ */ s("button", { onClick: () => {
1326
+ /* @__PURE__ */ a("button", { onClick: () => {
1161
1327
  var e;
1162
1328
  return (e = r.current) == null ? void 0 : e.findNext();
1163
1329
  }, children: "↓" }),
1164
- /* @__PURE__ */ s("button", { onClick: ye, children: "✕" })
1330
+ /* @__PURE__ */ a("button", { onClick: Te, children: "✕" })
1165
1331
  ] }),
1166
- H && /* @__PURE__ */ s(
1167
- Xt,
1332
+ J && /* @__PURE__ */ a(
1333
+ gn,
1168
1334
  {
1169
- values: H.values,
1170
- selected: H.selected,
1171
- x: H.x,
1172
- y: H.y,
1173
- sortDir: H.sortDir,
1335
+ values: J.values,
1336
+ selected: J.selected,
1337
+ x: J.x,
1338
+ y: J.y,
1339
+ sortDir: J.sortDir,
1174
1340
  onApply: (e) => {
1175
1341
  var t;
1176
1342
  return (t = r.current) == null ? void 0 : t.applyFilterSelection(e);
@@ -1185,91 +1351,91 @@ const Gt = Pt(function(a, I) {
1185
1351
  },
1186
1352
  onSort: (e) => {
1187
1353
  var n, l;
1188
- const t = H.col;
1354
+ const t = J.col;
1189
1355
  (n = r.current) == null || n.closeFilterPopup(), (l = r.current) == null || l.sortColumn(t, e);
1190
1356
  }
1191
1357
  },
1192
- H.col
1358
+ J.col
1193
1359
  ),
1194
- ne && /* @__PURE__ */ s("div", { className: "rxl-tooltip " + ne.kind, style: { left: ne.x, top: ne.y }, children: ne.text }),
1195
- S && /* @__PURE__ */ s("div", { className: "rxl-state", children: (E == null ? void 0 : E.stage) === "read" ? "读取文件…" : (E == null ? void 0 : E.stage) === "parse" ? "解析中…" : "构建表格…" }),
1196
- !S && N && /* @__PURE__ */ m("div", { className: "rxl-state error", children: [
1360
+ ae && /* @__PURE__ */ a("div", { className: "rxl-tooltip " + ae.kind, style: { left: ae.x, top: ae.y }, children: ae.text }),
1361
+ w && /* @__PURE__ */ a("div", { className: "rxl-state", children: (F == null ? void 0 : F.stage) === "read" ? "读取文件…" : (F == null ? void 0 : F.stage) === "parse" ? "解析中…" : "构建表格…" }),
1362
+ !w && T && /* @__PURE__ */ g("div", { className: "rxl-state error", children: [
1197
1363
  "解析失败:",
1198
- N
1364
+ T
1199
1365
  ] }),
1200
- !S && !c && /* @__PURE__ */ s("div", { className: "rxl-state", children: "拖入或选择一个 .xlsx 文件" })
1366
+ !w && !s && /* @__PURE__ */ a("div", { className: "rxl-state", children: "拖入或选择一个 .xlsx 文件" })
1201
1367
  ] }),
1202
- c && /* @__PURE__ */ m("div", { className: "rxl-status-bar", children: [
1203
- /* @__PURE__ */ s("span", { style: { color: "#888" }, children: Mt || Ke }),
1204
- /* @__PURE__ */ s("div", { className: "grow" }),
1205
- P && P.numCount > 0 ? /* @__PURE__ */ m(ot, { children: [
1206
- /* @__PURE__ */ m("span", { children: [
1368
+ s && /* @__PURE__ */ g("div", { className: "rxl-status-bar", children: [
1369
+ /* @__PURE__ */ a("span", { style: { color: "#888" }, children: Xt || Ye }),
1370
+ /* @__PURE__ */ a("div", { className: "grow" }),
1371
+ O && O.numCount > 0 ? /* @__PURE__ */ g(qt, { children: [
1372
+ /* @__PURE__ */ g("span", { children: [
1207
1373
  "计数 ",
1208
- P.count
1374
+ O.count
1209
1375
  ] }),
1210
- /* @__PURE__ */ m("span", { children: [
1376
+ /* @__PURE__ */ g("span", { children: [
1211
1377
  "求和 ",
1212
- se(P.sum)
1378
+ me(O.sum)
1213
1379
  ] }),
1214
- /* @__PURE__ */ m("span", { children: [
1380
+ /* @__PURE__ */ g("span", { children: [
1215
1381
  "平均 ",
1216
- se(P.avg)
1382
+ me(O.avg)
1217
1383
  ] }),
1218
- /* @__PURE__ */ m("span", { children: [
1384
+ /* @__PURE__ */ g("span", { children: [
1219
1385
  "最大 ",
1220
- se(P.max)
1386
+ me(O.max)
1221
1387
  ] }),
1222
- /* @__PURE__ */ m("span", { children: [
1388
+ /* @__PURE__ */ g("span", { children: [
1223
1389
  "最小 ",
1224
- se(P.min)
1390
+ me(O.min)
1225
1391
  ] })
1226
- ] }) : P && P.count > 0 ? /* @__PURE__ */ m("span", { children: [
1392
+ ] }) : O && O.count > 0 ? /* @__PURE__ */ g("span", { children: [
1227
1393
  "计数 ",
1228
- P.count
1394
+ O.count
1229
1395
  ] }) : null
1230
1396
  ] }),
1231
- c && je.length > 0 && /* @__PURE__ */ s("div", { className: "rxl-tabs", children: je.map(({ s: e, i: t }) => /* @__PURE__ */ s("button", { className: t === y ? "active" : "", onClick: () => K(t), children: e.name }, t)) }),
1232
- a.exportProgress !== !1 && (a.renderExportProgress ? a.renderExportProgress({ state: Le, busy: Be, cancel: Ve }) : /* @__PURE__ */ s(Kt, { state: Le, busy: Be, onCancel: Ve }))
1397
+ s && st.length > 0 && /* @__PURE__ */ a("div", { className: "rxl-tabs", children: st.map(({ s: e, i: t }) => /* @__PURE__ */ a("button", { className: t === N ? "active" : "", onClick: () => $(t), children: e.name }, t)) }),
1398
+ c.exportProgress !== !1 && (c.renderExportProgress ? c.renderExportProgress({ state: je, busy: Ue, cancel: Ge }) : /* @__PURE__ */ a(un, { state: je, busy: Ue, onCancel: Ge }))
1233
1399
  ] });
1234
1400
  });
1235
- function Xt(g) {
1236
- const a = g.selected.length ? new Set(g.selected) : new Set(g.values), [I, S] = R(a), N = (c) => {
1237
- const E = new Set(I);
1238
- E.has(c) ? E.delete(c) : E.add(c), S(E);
1401
+ function gn(f) {
1402
+ const c = f.selected.length ? new Set(f.selected) : new Set(f.values), [k, w] = y(c), T = (s) => {
1403
+ const F = new Set(k);
1404
+ F.has(s) ? F.delete(s) : F.add(s), w(F);
1239
1405
  };
1240
- return /* @__PURE__ */ m("div", { className: "rxl-filterpop", style: { left: g.x, top: g.y }, children: [
1241
- /* @__PURE__ */ m("div", { className: "sort", children: [
1242
- /* @__PURE__ */ s("button", { className: g.sortDir === "asc" ? "on" : "", onClick: () => g.onSort("asc"), children: "↑ 升序" }),
1243
- /* @__PURE__ */ s("button", { className: g.sortDir === "desc" ? "on" : "", onClick: () => g.onSort("desc"), children: "↓ 降序" })
1406
+ return /* @__PURE__ */ g("div", { className: "rxl-filterpop", style: { left: f.x, top: f.y }, children: [
1407
+ /* @__PURE__ */ g("div", { className: "sort", children: [
1408
+ /* @__PURE__ */ a("button", { className: f.sortDir === "asc" ? "on" : "", onClick: () => f.onSort("asc"), children: "↑ 升序" }),
1409
+ /* @__PURE__ */ a("button", { className: f.sortDir === "desc" ? "on" : "", onClick: () => f.onSort("desc"), children: "↓ 降序" })
1244
1410
  ] }),
1245
- /* @__PURE__ */ m("div", { className: "list", children: [
1246
- /* @__PURE__ */ m("label", { children: [
1247
- /* @__PURE__ */ s(
1411
+ /* @__PURE__ */ g("div", { className: "list", children: [
1412
+ /* @__PURE__ */ g("label", { children: [
1413
+ /* @__PURE__ */ a(
1248
1414
  "input",
1249
1415
  {
1250
1416
  type: "checkbox",
1251
- checked: I.size === g.values.length,
1252
- ref: (c) => {
1253
- c && (c.indeterminate = I.size > 0 && I.size < g.values.length);
1417
+ checked: k.size === f.values.length,
1418
+ ref: (s) => {
1419
+ s && (s.indeterminate = k.size > 0 && k.size < f.values.length);
1254
1420
  },
1255
- onChange: (c) => S(c.target.checked ? new Set(g.values) : /* @__PURE__ */ new Set())
1421
+ onChange: (s) => w(s.target.checked ? new Set(f.values) : /* @__PURE__ */ new Set())
1256
1422
  }
1257
1423
  ),
1258
1424
  "(全选)"
1259
1425
  ] }),
1260
- g.values.map((c) => /* @__PURE__ */ m("label", { children: [
1261
- /* @__PURE__ */ s("input", { type: "checkbox", checked: I.has(c), onChange: () => N(c) }),
1262
- c
1263
- ] }, c))
1426
+ f.values.map((s) => /* @__PURE__ */ g("label", { children: [
1427
+ /* @__PURE__ */ a("input", { type: "checkbox", checked: k.has(s), onChange: () => T(s) }),
1428
+ s
1429
+ ] }, s))
1264
1430
  ] }),
1265
- /* @__PURE__ */ m("div", { className: "foot", children: [
1266
- /* @__PURE__ */ s("button", { onClick: g.onClear, children: "清除" }),
1267
- /* @__PURE__ */ s("button", { onClick: () => g.onApply([...I]), children: "确定" }),
1268
- /* @__PURE__ */ s("button", { onClick: g.onClose, children: "取消" })
1431
+ /* @__PURE__ */ g("div", { className: "foot", children: [
1432
+ /* @__PURE__ */ a("button", { onClick: f.onClear, children: "清除" }),
1433
+ /* @__PURE__ */ a("button", { onClick: () => f.onApply([...k]), children: "确定" }),
1434
+ /* @__PURE__ */ a("button", { onClick: f.onClose, children: "取消" })
1269
1435
  ] })
1270
1436
  ] });
1271
1437
  }
1272
1438
  export {
1273
- Gt as ExcelViewer,
1274
- $t as useExcelDocument
1439
+ vn as ExcelViewer,
1440
+ dn as useExcelDocument
1275
1441
  };