ooxml-excel-editor 1.1.0
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/CHANGELOG.md +95 -0
- package/LICENSE +21 -0
- package/README.md +516 -0
- package/dist/chunks/plugin-overlay-Cfnn9EOi.js +7144 -0
- package/dist/chunks/worker-client.stub-BQVZfaLd.js +7 -0
- package/dist/components/ActionToolbar.vue.d.ts +9 -0
- package/dist/components/ExcelViewer.vue.d.ts +283 -0
- package/dist/components/ExportDialog.vue.d.ts +14 -0
- package/dist/components/FilterPopup.vue.d.ts +21 -0
- package/dist/components/FindBar.vue.d.ts +27 -0
- package/dist/components/SheetTabs.vue.d.ts +11 -0
- package/dist/components/ToolbarMenu.vue.d.ts +10 -0
- package/dist/components/ViewerToolbar.vue.d.ts +21 -0
- package/dist/components/export-types.d.ts +14 -0
- package/dist/components/toolbar-icons.d.ts +7 -0
- package/dist/components/toolbar-types.d.ts +18 -0
- package/dist/composables/useExcelDocument.d.ts +17 -0
- package/dist/composables/worker-client.d.ts +3 -0
- package/dist/composables/worker-client.stub.d.ts +3 -0
- package/dist/core/edit/commands.d.ts +94 -0
- package/dist/core/edit/default-editor.d.ts +2 -0
- package/dist/core/edit/edit-controller.d.ts +137 -0
- package/dist/core/edit/editor-context.d.ts +40 -0
- package/dist/core/edit/editor-host.d.ts +22 -0
- package/dist/core/edit/permissions.d.ts +3 -0
- package/dist/core/edit/types.d.ts +23 -0
- package/dist/core/export/composite.d.ts +18 -0
- package/dist/core/export/data-export.d.ts +9 -0
- package/dist/core/export/exporter.d.ts +64 -0
- package/dist/core/export/index.d.ts +9 -0
- package/dist/core/export/paginate.d.ts +36 -0
- package/dist/core/export/pdf.d.ts +28 -0
- package/dist/core/export/print.d.ts +3 -0
- package/dist/core/export/raster.d.ts +13 -0
- package/dist/core/export/types.d.ts +92 -0
- package/dist/core/export/vector-pdf.d.ts +42 -0
- package/dist/core/export/xlsx-writer.d.ts +15 -0
- package/dist/core/finalize.d.ts +10 -0
- package/dist/core/format/builtin-formats.d.ts +7 -0
- package/dist/core/format/color.d.ts +11 -0
- package/dist/core/format/date-serial.d.ts +16 -0
- package/dist/core/format/number-format.d.ts +5 -0
- package/dist/core/formula/engine.d.ts +27 -0
- package/dist/core/formula/hyperformula-adapter.d.ts +3 -0
- package/dist/core/formula/recalc.d.ts +9 -0
- package/dist/core/formula/refs.d.ts +21 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/layout/autofit.d.ts +2 -0
- package/dist/core/layout/freeze.d.ts +11 -0
- package/dist/core/layout/grid-metrics.d.ts +37 -0
- package/dist/core/layout/merges.d.ts +14 -0
- package/dist/core/layout/units.d.ts +20 -0
- package/dist/core/layout/viewport.d.ts +29 -0
- package/dist/core/loader.d.ts +5 -0
- package/dist/core/model/clone.d.ts +9 -0
- package/dist/core/model/data-access.d.ts +30 -0
- package/dist/core/model/mutations.d.ts +46 -0
- package/dist/core/model/snapshot.d.ts +14 -0
- package/dist/core/model/structure.d.ts +26 -0
- package/dist/core/model/types.d.ts +289 -0
- package/dist/core/overlay/anchor.d.ts +9 -0
- package/dist/core/overlay/chart-mapper.d.ts +3 -0
- package/dist/core/overlay/echarts-loader.d.ts +3 -0
- package/dist/core/parse.worker.d.ts +14 -0
- package/dist/core/parser/chart-parser.d.ts +3 -0
- package/dist/core/parser/drawing-parser.d.ts +3 -0
- package/dist/core/parser/exceljs-adapter.d.ts +8 -0
- package/dist/core/parser/index.d.ts +3 -0
- package/dist/core/parser/page-break-parser.d.ts +3 -0
- package/dist/core/parser/raw-xml.d.ts +15 -0
- package/dist/core/parser/sparkline-parser.d.ts +3 -0
- package/dist/core/parser/theme.d.ts +3 -0
- package/dist/core/plugin.d.ts +180 -0
- package/dist/core/progress.d.ts +7 -0
- package/dist/core/render/autofilter.d.ts +14 -0
- package/dist/core/render/borders.d.ts +13 -0
- package/dist/core/render/canvas-renderer.d.ts +225 -0
- package/dist/core/render/conditional.d.ts +25 -0
- package/dist/core/render/fills.d.ts +2 -0
- package/dist/core/render/text.d.ts +20 -0
- package/dist/core/render/theme.d.ts +19 -0
- package/dist/core/viewer/controller.d.ts +339 -0
- package/dist/core/viewer/overlay-manager.d.ts +27 -0
- package/dist/core/viewer/plugin-overlay.d.ts +8 -0
- package/dist/core.d.ts +2 -0
- package/dist/core.js +74 -0
- package/dist/demo-shared/demo-editor.d.ts +2 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1493 -0
- package/dist/react/ExcelViewer.d.ts +153 -0
- package/dist/react/index.d.ts +11 -0
- package/dist/react/use-excel-document.d.ts +17 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +838 -0
- package/dist/style.css +1 -0
- package/package.json +117 -0
package/dist/react.js
ADDED
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
import { jsxs as m, jsx as o, Fragment as Ue } from "react/jsx-runtime";
|
|
2
|
+
import { useState as F, useRef as g, useCallback as Ve, forwardRef as je, useReducer as Ze, useLayoutEffect as Te, useEffect as D, useImperativeHandle as qe } from "react";
|
|
3
|
+
import { r as Ge, l as Qe, d as _e, f as Ye, a as et, V as tt, P as nt, g as ze, s as Je, b as He, c as $e, e as Ke, h as he } from "./chunks/plugin-overlay-Cfnn9EOi.js";
|
|
4
|
+
import { p as rt } from "./chunks/worker-client.stub-BQVZfaLd.js";
|
|
5
|
+
function lt() {
|
|
6
|
+
const [f, i] = F(!1), [p, N] = F(null), [k, c] = F(null), [x, P] = F(null), [Z, R] = F(null), I = g(null), H = Ve(async (te, $) => {
|
|
7
|
+
i(!0), N(null), I.current && Ge(I.current), I.current = null, c(null), R(null), P({ stage: "read", ratio: 0 });
|
|
8
|
+
try {
|
|
9
|
+
const w = await Qe(
|
|
10
|
+
te,
|
|
11
|
+
(K, J) => P({ stage: "read", ratio: J ? K / J : void 0 })
|
|
12
|
+
), S = _e(w);
|
|
13
|
+
if (S === "xls") throw new Error("这是旧版 .xls(BIFF) 或加密文件,本预览器只支持 .xlsx/.xlsm。");
|
|
14
|
+
if (S === "not-zip") throw new Error("文件不是有效的 .xlsx(非 ZIP 包)。");
|
|
15
|
+
if (S === "empty") throw new Error("文件为空。");
|
|
16
|
+
let O = await rt(w, (K) => P(K));
|
|
17
|
+
$ && (O = $(O) ?? O), Ye(O), R(w.slice(0)), I.current = O, c(O);
|
|
18
|
+
} catch (w) {
|
|
19
|
+
const S = w == null ? void 0 : w.message;
|
|
20
|
+
N(S && /预览器|损坏|加密|为空|ZIP/.test(S) ? S : et(w)), console.error("[ooxml-preview] 解析失败:", w);
|
|
21
|
+
} finally {
|
|
22
|
+
i(!1), P(null);
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
return { loading: f, error: p, workbook: k, progress: x, load: H, sourceBuffer: Z };
|
|
26
|
+
}
|
|
27
|
+
function ee(f) {
|
|
28
|
+
return isFinite(f) ? f.toLocaleString("en-US", { maximumFractionDigits: 2 }) : "—";
|
|
29
|
+
}
|
|
30
|
+
const ut = je(function(i, p) {
|
|
31
|
+
const { loading: N, error: k, workbook: c, progress: x, load: P, sourceBuffer: Z } = lt(), [R, I] = F(0), [H, te] = F(1), [$, w] = F(!1), [, S] = Ze((e) => e + 1, 0), O = g(null), K = g(null), J = g(null), ve = g(null), ne = g(null), re = g(null), le = g(null), ce = g(null), r = g(null), oe = g(null), se = g(null), ae = g(null), q = g(null), ie = g(/* @__PURE__ */ new Map()), u = g(i);
|
|
32
|
+
u.current = i;
|
|
33
|
+
const G = i.plugins ?? [], L = g(G);
|
|
34
|
+
L.current = G;
|
|
35
|
+
const W = g(c);
|
|
36
|
+
W.current = c;
|
|
37
|
+
const ue = g(R);
|
|
38
|
+
ue.current = R;
|
|
39
|
+
function Le() {
|
|
40
|
+
const e = L.current, t = Object.assign({}, ...e.map((a) => a.theme || {}), u.current.theme || {}), n = e.map((a) => a.cellStyle).filter(Boolean);
|
|
41
|
+
u.current.cellStyle && n.push(u.current.cellStyle);
|
|
42
|
+
const l = n.length ? (a, v) => {
|
|
43
|
+
let s;
|
|
44
|
+
for (const d of n) {
|
|
45
|
+
const C = d(a, v);
|
|
46
|
+
C && (s = { ...s || {}, ...C });
|
|
47
|
+
}
|
|
48
|
+
return s;
|
|
49
|
+
} : void 0;
|
|
50
|
+
return { theme: t, cellStyle: l };
|
|
51
|
+
}
|
|
52
|
+
function Ce(e) {
|
|
53
|
+
let t = e;
|
|
54
|
+
for (const n of L.current) n.transformModel && (t = n.transformModel(t) ?? t);
|
|
55
|
+
return u.current.transformModel && (t = u.current.transformModel(t) ?? t), t;
|
|
56
|
+
}
|
|
57
|
+
function xe() {
|
|
58
|
+
const e = u.current;
|
|
59
|
+
return {
|
|
60
|
+
editable: e.editable,
|
|
61
|
+
cellReadOnly: e.cellReadOnly,
|
|
62
|
+
readOnlyRanges: e.readOnlyRanges,
|
|
63
|
+
recalc: e.recalc,
|
|
64
|
+
formulaEngine: e.formulaEngine
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function Re() {
|
|
68
|
+
if (u.current.editor || L.current.some((t) => t.editor))
|
|
69
|
+
return (t, n) => {
|
|
70
|
+
var a, v, s;
|
|
71
|
+
const l = (v = (a = u.current).editor) == null ? void 0 : v.call(a, t, n);
|
|
72
|
+
if (l) return l;
|
|
73
|
+
for (const d of L.current) {
|
|
74
|
+
const C = (s = d.editor) == null ? void 0 : s.call(d, t, n);
|
|
75
|
+
if (C) return C;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const X = (e, t) => {
|
|
80
|
+
var n;
|
|
81
|
+
return (n = ie.current.get(e)) == null ? void 0 : n.forEach((l) => l(t));
|
|
82
|
+
};
|
|
83
|
+
function de() {
|
|
84
|
+
const e = q.current, t = r.current;
|
|
85
|
+
if (!e || !t) return;
|
|
86
|
+
const n = {
|
|
87
|
+
rectOf: (l, a) => t.rectOf(l, a),
|
|
88
|
+
rectOfRange: (l) => t.rectOfRange(l),
|
|
89
|
+
tick: 0,
|
|
90
|
+
workbook: W.current
|
|
91
|
+
};
|
|
92
|
+
e.render(L.current, n);
|
|
93
|
+
}
|
|
94
|
+
Te(() => {
|
|
95
|
+
const e = K.current, t = O.current, n = J.current, l = ve.current;
|
|
96
|
+
if (!e || !t || !n || !l || !ae.current || !ne.current || !re.current || !le.current || !ce.current) return;
|
|
97
|
+
const a = new tt(
|
|
98
|
+
{
|
|
99
|
+
canvas: e,
|
|
100
|
+
renderArea: t,
|
|
101
|
+
scroller: n,
|
|
102
|
+
spacer: l,
|
|
103
|
+
overlays: { main: ne.current, frow: re.current, fcol: le.current, corner: ce.current },
|
|
104
|
+
editorSlot: ae.current
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
onRenderer: () => S(),
|
|
108
|
+
onRenderTick: () => de(),
|
|
109
|
+
// 插件 overlay 随每帧重定位(纯 DOM,不触发 React 重渲)
|
|
110
|
+
onSelectionChange: () => S(),
|
|
111
|
+
onCellClick: (s, d, C) => {
|
|
112
|
+
var T, z;
|
|
113
|
+
const b = { row: s, col: d, text: C };
|
|
114
|
+
(z = (T = u.current).onCellClick) == null || z.call(T, b), X("cell-click", b);
|
|
115
|
+
},
|
|
116
|
+
onCellDblClick: (s, d, C) => {
|
|
117
|
+
var T, z;
|
|
118
|
+
const b = { row: s, col: d, text: C };
|
|
119
|
+
(z = (T = u.current).onCellDblClick) == null || z.call(T, b), X("cell-dblclick", b);
|
|
120
|
+
},
|
|
121
|
+
onHyperlink: (s, d) => {
|
|
122
|
+
var C, b;
|
|
123
|
+
(b = (C = u.current).onHyperlinkClick) == null || b.call(C, { url: s, cell: d }), X("hyperlink-click", { url: s, cell: d }), u.current.openLinks !== !1 && window.open(s, "_blank", "noopener");
|
|
124
|
+
},
|
|
125
|
+
onTooltip: (s) => {
|
|
126
|
+
oe.current = s, S();
|
|
127
|
+
},
|
|
128
|
+
onFindChange: () => S(),
|
|
129
|
+
onFilterChange: () => S(),
|
|
130
|
+
onEditEvent: (s, d) => {
|
|
131
|
+
var C, b, T, z, Ee, Ne, ke, Ie, Oe, De, Fe, Pe, Me, Ae;
|
|
132
|
+
s === "cell-change" ? (b = (C = u.current).onCellChange) == null || b.call(C, d) : s === "edit-start" ? (z = (T = u.current).onEditStart) == null || z.call(T, d) : s === "edit-commit" ? (Ne = (Ee = u.current).onEditCommit) == null || Ne.call(Ee, d) : s === "dim-change" ? (Ie = (ke = u.current).onDimChange) == null || Ie.call(ke, d) : s === "dirty-change" ? (De = (Oe = u.current).onDirtyChange) == null || De.call(Oe, d) : s === "image-change" ? (Pe = (Fe = u.current).onImageChange) == null || Pe.call(Fe, d) : s === "struct-change" && ((Ae = (Me = u.current).onStructChange) == null || Ae.call(Me, d)), X(s, d);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
a.fileName = u.current.fileName, a.setEditConfig(xe()), a.setEditorResolver(Re()), r.current = a, se.current && (q.current = new nt(se.current));
|
|
137
|
+
const v = new ResizeObserver(() => {
|
|
138
|
+
a.measure(), a.render();
|
|
139
|
+
});
|
|
140
|
+
return v.observe(t), () => {
|
|
141
|
+
var s;
|
|
142
|
+
v.disconnect(), a.dispose(), (s = q.current) == null || s.dispose(), q.current = null, r.current = null;
|
|
143
|
+
};
|
|
144
|
+
}, []), D(() => {
|
|
145
|
+
i.src && P(i.src, Ce);
|
|
146
|
+
}, [i.src]), D(() => {
|
|
147
|
+
r.current && (r.current.fileName = i.fileName);
|
|
148
|
+
}, [i.fileName]), D(() => {
|
|
149
|
+
var e;
|
|
150
|
+
(e = r.current) == null || e.setEditConfig(xe());
|
|
151
|
+
}, [i.editable, i.cellReadOnly, i.readOnlyRanges, i.recalc, i.formulaEngine]), D(() => {
|
|
152
|
+
var e;
|
|
153
|
+
(e = r.current) == null || e.setEditorResolver(Re());
|
|
154
|
+
}, [i.editor, i.plugins]), D(() => {
|
|
155
|
+
var e, t;
|
|
156
|
+
c && (I(c.activeSheet), (t = (e = u.current).onRendered) == null || t.call(e, c));
|
|
157
|
+
}, [c]), D(() => {
|
|
158
|
+
var e, t;
|
|
159
|
+
k && ((t = (e = u.current).onError) == null || t.call(e, k));
|
|
160
|
+
}, [k]), Te(() => {
|
|
161
|
+
var l, a;
|
|
162
|
+
const e = r.current;
|
|
163
|
+
if (!e || !c) return;
|
|
164
|
+
const t = c.sheets[R] ?? c.sheets[0] ?? null;
|
|
165
|
+
if (!t) return;
|
|
166
|
+
e.rebuild(t, c, H, Le()), e.setSourceBuffer(Z), de();
|
|
167
|
+
const n = { index: R, name: t.name };
|
|
168
|
+
(a = (l = u.current).onSheetChange) == null || a.call(l, n), X("sheet-change", n);
|
|
169
|
+
}, [c, R, i.theme, i.cellStyle, i.plugins, Z]), D(() => {
|
|
170
|
+
var e;
|
|
171
|
+
(e = r.current) == null || e.setZoom(H);
|
|
172
|
+
}, [H]);
|
|
173
|
+
const we = g("");
|
|
174
|
+
D(() => {
|
|
175
|
+
var a, v;
|
|
176
|
+
const e = r.current;
|
|
177
|
+
if (!e) return;
|
|
178
|
+
const t = e.getSelection(), n = e.getActiveCell(), l = t && n ? `${t.top},${t.left},${t.bottom},${t.right}` : "";
|
|
179
|
+
if (l && l !== we.current && n) {
|
|
180
|
+
we.current = l;
|
|
181
|
+
const s = { range: t, active: n };
|
|
182
|
+
(v = (a = u.current).onSelectionChange) == null || v.call(a, s), X("selection-change", s);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
const B = (e) => (c == null ? void 0 : c.sheets[e ?? R]) ?? null, Se = (c == null ? void 0 : c.date1904) ?? !1, fe = (e) => ({ ...e, date1904: Se });
|
|
186
|
+
qe(
|
|
187
|
+
p,
|
|
188
|
+
() => ({
|
|
189
|
+
load: (e) => P(e, i.transformModel),
|
|
190
|
+
getWorkbook: () => c,
|
|
191
|
+
getActiveSheet: () => R,
|
|
192
|
+
setActiveSheet: (e) => (c == null ? void 0 : c.sheets[e]) && I(e),
|
|
193
|
+
getSelection: () => {
|
|
194
|
+
var e;
|
|
195
|
+
return ((e = r.current) == null ? void 0 : e.getSelection()) ?? null;
|
|
196
|
+
},
|
|
197
|
+
setSelection: (e) => {
|
|
198
|
+
var t;
|
|
199
|
+
return (t = r.current) == null ? void 0 : t.setSelectionRange(e);
|
|
200
|
+
},
|
|
201
|
+
rectOf: (e, t) => {
|
|
202
|
+
var n;
|
|
203
|
+
return ((n = r.current) == null ? void 0 : n.rectOf(e, t)) ?? null;
|
|
204
|
+
},
|
|
205
|
+
rectOfRange: (e) => {
|
|
206
|
+
var t;
|
|
207
|
+
return ((t = r.current) == null ? void 0 : t.rectOfRange(e)) ?? null;
|
|
208
|
+
},
|
|
209
|
+
redraw: () => {
|
|
210
|
+
var e;
|
|
211
|
+
return (e = r.current) == null ? void 0 : e.render();
|
|
212
|
+
},
|
|
213
|
+
isCellEditable: (e, t) => {
|
|
214
|
+
var n;
|
|
215
|
+
return ((n = r.current) == null ? void 0 : n.isCellEditable(e, t)) ?? !1;
|
|
216
|
+
},
|
|
217
|
+
editCell: (e, t, n) => {
|
|
218
|
+
var l;
|
|
219
|
+
return ((l = r.current) == null ? void 0 : l.editCell(e, t, n)) ?? !1;
|
|
220
|
+
},
|
|
221
|
+
editRange: (e, t) => {
|
|
222
|
+
var n;
|
|
223
|
+
return ((n = r.current) == null ? void 0 : n.editRange(e, t)) ?? !1;
|
|
224
|
+
},
|
|
225
|
+
clearRange: (e) => {
|
|
226
|
+
var t;
|
|
227
|
+
return ((t = r.current) == null ? void 0 : t.clearRange(e)) ?? !1;
|
|
228
|
+
},
|
|
229
|
+
setStyle: (e, t) => {
|
|
230
|
+
var n;
|
|
231
|
+
return ((n = r.current) == null ? void 0 : n.setStyle(e, t)) ?? !1;
|
|
232
|
+
},
|
|
233
|
+
getImages: () => {
|
|
234
|
+
var e;
|
|
235
|
+
return ((e = r.current) == null ? void 0 : e.getImages()) ?? [];
|
|
236
|
+
},
|
|
237
|
+
addImage: (e) => {
|
|
238
|
+
var t;
|
|
239
|
+
return ((t = r.current) == null ? void 0 : t.addImage(e)) ?? -1;
|
|
240
|
+
},
|
|
241
|
+
removeImage: (e) => {
|
|
242
|
+
var t;
|
|
243
|
+
return ((t = r.current) == null ? void 0 : t.removeImage(e)) ?? !1;
|
|
244
|
+
},
|
|
245
|
+
moveImage: (e, t, n) => {
|
|
246
|
+
var l;
|
|
247
|
+
return ((l = r.current) == null ? void 0 : l.moveImage(e, t, n)) ?? !1;
|
|
248
|
+
},
|
|
249
|
+
resizeImage: (e, t, n) => {
|
|
250
|
+
var l;
|
|
251
|
+
return ((l = r.current) == null ? void 0 : l.resizeImage(e, t, n)) ?? !1;
|
|
252
|
+
},
|
|
253
|
+
insertRows: (e, t) => {
|
|
254
|
+
var n;
|
|
255
|
+
return ((n = r.current) == null ? void 0 : n.insertRows(e, t)) ?? !1;
|
|
256
|
+
},
|
|
257
|
+
deleteRows: (e, t) => {
|
|
258
|
+
var n;
|
|
259
|
+
return ((n = r.current) == null ? void 0 : n.deleteRows(e, t)) ?? !1;
|
|
260
|
+
},
|
|
261
|
+
insertCols: (e, t) => {
|
|
262
|
+
var n;
|
|
263
|
+
return ((n = r.current) == null ? void 0 : n.insertCols(e, t)) ?? !1;
|
|
264
|
+
},
|
|
265
|
+
deleteCols: (e, t) => {
|
|
266
|
+
var n;
|
|
267
|
+
return ((n = r.current) == null ? void 0 : n.deleteCols(e, t)) ?? !1;
|
|
268
|
+
},
|
|
269
|
+
undo: () => {
|
|
270
|
+
var e;
|
|
271
|
+
return (e = r.current) == null ? void 0 : e.undo();
|
|
272
|
+
},
|
|
273
|
+
redo: () => {
|
|
274
|
+
var e;
|
|
275
|
+
return (e = r.current) == null ? void 0 : e.redo();
|
|
276
|
+
},
|
|
277
|
+
canUndo: () => {
|
|
278
|
+
var e;
|
|
279
|
+
return ((e = r.current) == null ? void 0 : e.canUndo()) ?? !1;
|
|
280
|
+
},
|
|
281
|
+
canRedo: () => {
|
|
282
|
+
var e;
|
|
283
|
+
return ((e = r.current) == null ? void 0 : e.canRedo()) ?? !1;
|
|
284
|
+
},
|
|
285
|
+
getEditingCell: () => {
|
|
286
|
+
var e;
|
|
287
|
+
return ((e = r.current) == null ? void 0 : e.getEditingCell()) ?? null;
|
|
288
|
+
},
|
|
289
|
+
getCellSnapshot: (e, t) => {
|
|
290
|
+
var n;
|
|
291
|
+
return ((n = r.current) == null ? void 0 : n.getCellSnapshot(e, t)) ?? null;
|
|
292
|
+
},
|
|
293
|
+
beginEdit: (e, t) => {
|
|
294
|
+
var n;
|
|
295
|
+
return ((n = r.current) == null ? void 0 : n.beginEdit(e, t)) ?? !1;
|
|
296
|
+
},
|
|
297
|
+
cancelEdit: () => {
|
|
298
|
+
var e;
|
|
299
|
+
return (e = r.current) == null ? void 0 : e.cancelEdit();
|
|
300
|
+
},
|
|
301
|
+
isEditing: () => {
|
|
302
|
+
var e;
|
|
303
|
+
return ((e = r.current) == null ? void 0 : e.isEditing()) ?? !1;
|
|
304
|
+
},
|
|
305
|
+
setColumnWidth: (e, t) => {
|
|
306
|
+
var n;
|
|
307
|
+
return ((n = r.current) == null ? void 0 : n.setColumnWidth(e, t)) ?? !1;
|
|
308
|
+
},
|
|
309
|
+
setRowHeight: (e, t) => {
|
|
310
|
+
var n;
|
|
311
|
+
return ((n = r.current) == null ? void 0 : n.setRowHeight(e, t)) ?? !1;
|
|
312
|
+
},
|
|
313
|
+
isRecalcReady: () => {
|
|
314
|
+
var e;
|
|
315
|
+
return ((e = r.current) == null ? void 0 : e.isRecalcReady()) ?? !1;
|
|
316
|
+
},
|
|
317
|
+
isDirty: () => {
|
|
318
|
+
var e;
|
|
319
|
+
return ((e = r.current) == null ? void 0 : e.isDirty()) ?? !1;
|
|
320
|
+
},
|
|
321
|
+
resetToOriginal: () => {
|
|
322
|
+
var e;
|
|
323
|
+
return ((e = r.current) == null ? void 0 : e.resetToOriginal()) ?? !1;
|
|
324
|
+
},
|
|
325
|
+
exportImage: (e) => r.current.exportImage(e),
|
|
326
|
+
downloadImage: (e) => r.current.downloadImage(e),
|
|
327
|
+
exportPdf: (e) => r.current.exportPdf(e),
|
|
328
|
+
downloadPdf: (e) => r.current.downloadPdf(e),
|
|
329
|
+
print: (e) => r.current.print(e),
|
|
330
|
+
exportXlsx: (e) => r.current.exportXlsx(e),
|
|
331
|
+
downloadXlsx: (e) => r.current.downloadXlsx(e),
|
|
332
|
+
exportJson: (e) => {
|
|
333
|
+
var t;
|
|
334
|
+
return ((t = r.current) == null ? void 0 : t.exportJson(e)) ?? "{}";
|
|
335
|
+
},
|
|
336
|
+
downloadJson: (e) => {
|
|
337
|
+
var t;
|
|
338
|
+
return (t = r.current) == null ? void 0 : t.downloadJson(e);
|
|
339
|
+
},
|
|
340
|
+
exportCsv: (e) => {
|
|
341
|
+
var t;
|
|
342
|
+
return ((t = r.current) == null ? void 0 : t.exportCsv(e)) ?? "";
|
|
343
|
+
},
|
|
344
|
+
downloadCsv: (e) => {
|
|
345
|
+
var t;
|
|
346
|
+
return (t = r.current) == null ? void 0 : t.downloadCsv(e);
|
|
347
|
+
},
|
|
348
|
+
getCellValue: (e, t, n) => {
|
|
349
|
+
const l = B(n);
|
|
350
|
+
return l ? Ke(l, e, t) : null;
|
|
351
|
+
},
|
|
352
|
+
getCellText: (e, t, n) => {
|
|
353
|
+
const l = B(n);
|
|
354
|
+
return l ? $e(l, e, t, Se) : "";
|
|
355
|
+
},
|
|
356
|
+
getSheetData: (e, t) => {
|
|
357
|
+
const n = B(t);
|
|
358
|
+
return n ? He(n, fe(e)) : [];
|
|
359
|
+
},
|
|
360
|
+
getSheetJSON: (e, t) => {
|
|
361
|
+
const n = B(t);
|
|
362
|
+
return n ? Je(n, fe(e)) : [];
|
|
363
|
+
},
|
|
364
|
+
getRangeData: (e, t, n) => {
|
|
365
|
+
const l = B(n);
|
|
366
|
+
return l ? ze(l, e, fe(t)) : [];
|
|
367
|
+
}
|
|
368
|
+
}),
|
|
369
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
370
|
+
[c, R]
|
|
371
|
+
);
|
|
372
|
+
const U = (e) => {
|
|
373
|
+
var t;
|
|
374
|
+
return ((t = W.current) == null ? void 0 : t.sheets[e ?? ue.current]) ?? null;
|
|
375
|
+
}, Q = () => {
|
|
376
|
+
var e;
|
|
377
|
+
return ((e = W.current) == null ? void 0 : e.date1904) ?? !1;
|
|
378
|
+
}, _ = g({
|
|
379
|
+
load: (e) => P(e, Ce),
|
|
380
|
+
getWorkbook: () => W.current,
|
|
381
|
+
getActiveSheet: () => ue.current,
|
|
382
|
+
setActiveSheet: (e) => {
|
|
383
|
+
var t;
|
|
384
|
+
(t = W.current) != null && t.sheets[e] && I(e);
|
|
385
|
+
},
|
|
386
|
+
getSelection: () => {
|
|
387
|
+
var e;
|
|
388
|
+
return ((e = r.current) == null ? void 0 : e.getSelection()) ?? null;
|
|
389
|
+
},
|
|
390
|
+
setSelection: (e) => {
|
|
391
|
+
var t;
|
|
392
|
+
return (t = r.current) == null ? void 0 : t.setSelectionRange(e);
|
|
393
|
+
},
|
|
394
|
+
rectOf: (e, t) => {
|
|
395
|
+
var n;
|
|
396
|
+
return ((n = r.current) == null ? void 0 : n.rectOf(e, t)) ?? null;
|
|
397
|
+
},
|
|
398
|
+
rectOfRange: (e) => {
|
|
399
|
+
var t;
|
|
400
|
+
return ((t = r.current) == null ? void 0 : t.rectOfRange(e)) ?? null;
|
|
401
|
+
},
|
|
402
|
+
redraw: () => {
|
|
403
|
+
var e;
|
|
404
|
+
return (e = r.current) == null ? void 0 : e.render();
|
|
405
|
+
},
|
|
406
|
+
isCellEditable: (e, t) => {
|
|
407
|
+
var n;
|
|
408
|
+
return ((n = r.current) == null ? void 0 : n.isCellEditable(e, t)) ?? !1;
|
|
409
|
+
},
|
|
410
|
+
editCell: (e, t, n) => {
|
|
411
|
+
var l;
|
|
412
|
+
return ((l = r.current) == null ? void 0 : l.editCell(e, t, n)) ?? !1;
|
|
413
|
+
},
|
|
414
|
+
editRange: (e, t) => {
|
|
415
|
+
var n;
|
|
416
|
+
return ((n = r.current) == null ? void 0 : n.editRange(e, t)) ?? !1;
|
|
417
|
+
},
|
|
418
|
+
clearRange: (e) => {
|
|
419
|
+
var t;
|
|
420
|
+
return ((t = r.current) == null ? void 0 : t.clearRange(e)) ?? !1;
|
|
421
|
+
},
|
|
422
|
+
setStyle: (e, t) => {
|
|
423
|
+
var n;
|
|
424
|
+
return ((n = r.current) == null ? void 0 : n.setStyle(e, t)) ?? !1;
|
|
425
|
+
},
|
|
426
|
+
getImages: () => {
|
|
427
|
+
var e;
|
|
428
|
+
return ((e = r.current) == null ? void 0 : e.getImages()) ?? [];
|
|
429
|
+
},
|
|
430
|
+
addImage: (e) => {
|
|
431
|
+
var t;
|
|
432
|
+
return ((t = r.current) == null ? void 0 : t.addImage(e)) ?? -1;
|
|
433
|
+
},
|
|
434
|
+
removeImage: (e) => {
|
|
435
|
+
var t;
|
|
436
|
+
return ((t = r.current) == null ? void 0 : t.removeImage(e)) ?? !1;
|
|
437
|
+
},
|
|
438
|
+
moveImage: (e, t, n) => {
|
|
439
|
+
var l;
|
|
440
|
+
return ((l = r.current) == null ? void 0 : l.moveImage(e, t, n)) ?? !1;
|
|
441
|
+
},
|
|
442
|
+
resizeImage: (e, t, n) => {
|
|
443
|
+
var l;
|
|
444
|
+
return ((l = r.current) == null ? void 0 : l.resizeImage(e, t, n)) ?? !1;
|
|
445
|
+
},
|
|
446
|
+
insertRows: (e, t) => {
|
|
447
|
+
var n;
|
|
448
|
+
return ((n = r.current) == null ? void 0 : n.insertRows(e, t)) ?? !1;
|
|
449
|
+
},
|
|
450
|
+
deleteRows: (e, t) => {
|
|
451
|
+
var n;
|
|
452
|
+
return ((n = r.current) == null ? void 0 : n.deleteRows(e, t)) ?? !1;
|
|
453
|
+
},
|
|
454
|
+
insertCols: (e, t) => {
|
|
455
|
+
var n;
|
|
456
|
+
return ((n = r.current) == null ? void 0 : n.insertCols(e, t)) ?? !1;
|
|
457
|
+
},
|
|
458
|
+
deleteCols: (e, t) => {
|
|
459
|
+
var n;
|
|
460
|
+
return ((n = r.current) == null ? void 0 : n.deleteCols(e, t)) ?? !1;
|
|
461
|
+
},
|
|
462
|
+
undo: () => {
|
|
463
|
+
var e;
|
|
464
|
+
return (e = r.current) == null ? void 0 : e.undo();
|
|
465
|
+
},
|
|
466
|
+
redo: () => {
|
|
467
|
+
var e;
|
|
468
|
+
return (e = r.current) == null ? void 0 : e.redo();
|
|
469
|
+
},
|
|
470
|
+
canUndo: () => {
|
|
471
|
+
var e;
|
|
472
|
+
return ((e = r.current) == null ? void 0 : e.canUndo()) ?? !1;
|
|
473
|
+
},
|
|
474
|
+
canRedo: () => {
|
|
475
|
+
var e;
|
|
476
|
+
return ((e = r.current) == null ? void 0 : e.canRedo()) ?? !1;
|
|
477
|
+
},
|
|
478
|
+
getEditingCell: () => {
|
|
479
|
+
var e;
|
|
480
|
+
return ((e = r.current) == null ? void 0 : e.getEditingCell()) ?? null;
|
|
481
|
+
},
|
|
482
|
+
getCellSnapshot: (e, t) => {
|
|
483
|
+
var n;
|
|
484
|
+
return ((n = r.current) == null ? void 0 : n.getCellSnapshot(e, t)) ?? null;
|
|
485
|
+
},
|
|
486
|
+
beginEdit: (e, t) => {
|
|
487
|
+
var n;
|
|
488
|
+
return ((n = r.current) == null ? void 0 : n.beginEdit(e, t)) ?? !1;
|
|
489
|
+
},
|
|
490
|
+
cancelEdit: () => {
|
|
491
|
+
var e;
|
|
492
|
+
return (e = r.current) == null ? void 0 : e.cancelEdit();
|
|
493
|
+
},
|
|
494
|
+
isEditing: () => {
|
|
495
|
+
var e;
|
|
496
|
+
return ((e = r.current) == null ? void 0 : e.isEditing()) ?? !1;
|
|
497
|
+
},
|
|
498
|
+
setColumnWidth: (e, t) => {
|
|
499
|
+
var n;
|
|
500
|
+
return ((n = r.current) == null ? void 0 : n.setColumnWidth(e, t)) ?? !1;
|
|
501
|
+
},
|
|
502
|
+
setRowHeight: (e, t) => {
|
|
503
|
+
var n;
|
|
504
|
+
return ((n = r.current) == null ? void 0 : n.setRowHeight(e, t)) ?? !1;
|
|
505
|
+
},
|
|
506
|
+
isRecalcReady: () => {
|
|
507
|
+
var e;
|
|
508
|
+
return ((e = r.current) == null ? void 0 : e.isRecalcReady()) ?? !1;
|
|
509
|
+
},
|
|
510
|
+
isDirty: () => {
|
|
511
|
+
var e;
|
|
512
|
+
return ((e = r.current) == null ? void 0 : e.isDirty()) ?? !1;
|
|
513
|
+
},
|
|
514
|
+
resetToOriginal: () => {
|
|
515
|
+
var e;
|
|
516
|
+
return ((e = r.current) == null ? void 0 : e.resetToOriginal()) ?? !1;
|
|
517
|
+
},
|
|
518
|
+
exportImage: (e) => r.current.exportImage(e),
|
|
519
|
+
downloadImage: (e) => r.current.downloadImage(e),
|
|
520
|
+
exportPdf: (e) => r.current.exportPdf(e),
|
|
521
|
+
downloadPdf: (e) => r.current.downloadPdf(e),
|
|
522
|
+
print: (e) => r.current.print(e),
|
|
523
|
+
exportXlsx: (e) => r.current.exportXlsx(e),
|
|
524
|
+
downloadXlsx: (e) => r.current.downloadXlsx(e),
|
|
525
|
+
exportJson: (e) => {
|
|
526
|
+
var t;
|
|
527
|
+
return ((t = r.current) == null ? void 0 : t.exportJson(e)) ?? "{}";
|
|
528
|
+
},
|
|
529
|
+
downloadJson: (e) => {
|
|
530
|
+
var t;
|
|
531
|
+
return (t = r.current) == null ? void 0 : t.downloadJson(e);
|
|
532
|
+
},
|
|
533
|
+
exportCsv: (e) => {
|
|
534
|
+
var t;
|
|
535
|
+
return ((t = r.current) == null ? void 0 : t.exportCsv(e)) ?? "";
|
|
536
|
+
},
|
|
537
|
+
downloadCsv: (e) => {
|
|
538
|
+
var t;
|
|
539
|
+
return (t = r.current) == null ? void 0 : t.downloadCsv(e);
|
|
540
|
+
},
|
|
541
|
+
getCellValue: (e, t, n) => {
|
|
542
|
+
const l = U(n);
|
|
543
|
+
return l ? Ke(l, e, t) : null;
|
|
544
|
+
},
|
|
545
|
+
getCellText: (e, t, n) => {
|
|
546
|
+
const l = U(n);
|
|
547
|
+
return l ? $e(l, e, t, Q()) : "";
|
|
548
|
+
},
|
|
549
|
+
getSheetData: (e, t) => {
|
|
550
|
+
const n = U(t);
|
|
551
|
+
return n ? He(n, { ...e, date1904: Q() }) : [];
|
|
552
|
+
},
|
|
553
|
+
getSheetJSON: (e, t) => {
|
|
554
|
+
const n = U(t);
|
|
555
|
+
return n ? Je(n, { ...e, date1904: Q() }) : [];
|
|
556
|
+
},
|
|
557
|
+
getRangeData: (e, t, n) => {
|
|
558
|
+
const l = U(n);
|
|
559
|
+
return l ? ze(l, e, { ...t, date1904: Q() }) : [];
|
|
560
|
+
}
|
|
561
|
+
}).current;
|
|
562
|
+
D(() => {
|
|
563
|
+
var l;
|
|
564
|
+
const e = /* @__PURE__ */ new Map(), t = [], n = (a, v) => {
|
|
565
|
+
let s = e.get(a);
|
|
566
|
+
s || e.set(a, s = /* @__PURE__ */ new Set()), s.add(v);
|
|
567
|
+
};
|
|
568
|
+
for (const a of G) {
|
|
569
|
+
if (a.events)
|
|
570
|
+
for (const [s, d] of Object.entries(a.events)) d && n(s, d);
|
|
571
|
+
const v = (l = a.setup) == null ? void 0 : l.call(a, { viewer: _, on: n, redraw: () => {
|
|
572
|
+
var s;
|
|
573
|
+
return (s = r.current) == null ? void 0 : s.render();
|
|
574
|
+
} });
|
|
575
|
+
typeof v == "function" && t.push(v);
|
|
576
|
+
}
|
|
577
|
+
return ie.current = e, de(), () => {
|
|
578
|
+
t.forEach((a) => a()), ie.current = /* @__PURE__ */ new Map();
|
|
579
|
+
};
|
|
580
|
+
}, [i.plugins]);
|
|
581
|
+
const We = (e) => {
|
|
582
|
+
(e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F") && (e.preventDefault(), w(!0));
|
|
583
|
+
}, ge = () => {
|
|
584
|
+
var e, t;
|
|
585
|
+
w(!1), (e = r.current) == null || e.clearFind(), (t = J.current) == null || t.focus();
|
|
586
|
+
}, Xe = () => {
|
|
587
|
+
var t;
|
|
588
|
+
const e = J.current;
|
|
589
|
+
e && (oe.current = null, (t = r.current) == null || t.setScroll(e.scrollLeft, e.scrollTop));
|
|
590
|
+
}, h = r.current, V = (h == null ? void 0 : h.renderer) ?? null, M = (h == null ? void 0 : h.getActiveCell()) ?? null, y = (h == null ? void 0 : h.getSelection()) ?? null, ye = M ? he(M.col) + (M.row + 1) : "", be = V && M ? V.cellFormula(M.row, M.col) ?? V.cellText(M.row, M.col) : "", Be = y && !(y.top === y.bottom && y.left === y.right) ? `${he(y.left)}${y.top + 1}:${he(y.right)}${y.bottom + 1}` : "", E = V && y ? V.selectionStats(y) : null, Y = (h == null ? void 0 : h.getFindState()) ?? { query: "", count: 0, index: -1 }, A = (h == null ? void 0 : h.getFilterPopup()) ?? null, j = oe.current, me = (c == null ? void 0 : c.sheets[R]) ?? null, pe = c ? c.sheets.map((e, t) => ({ s: e, i: t })).filter(({ s: e }) => e.state === "visible") : [];
|
|
591
|
+
return /* @__PURE__ */ m("div", { className: "rxl" + (i.className ? " " + i.className : ""), style: i.style, onKeyDown: We, children: [
|
|
592
|
+
c && /* @__PURE__ */ m("div", { className: "rxl-toolbar", children: [
|
|
593
|
+
/* @__PURE__ */ o(
|
|
594
|
+
"button",
|
|
595
|
+
{
|
|
596
|
+
className: $ ? "active" : "",
|
|
597
|
+
onClick: () => $ ? ge() : w(!0),
|
|
598
|
+
title: "查找 (Ctrl+F)",
|
|
599
|
+
children: "查找"
|
|
600
|
+
}
|
|
601
|
+
),
|
|
602
|
+
/* @__PURE__ */ o(
|
|
603
|
+
"button",
|
|
604
|
+
{
|
|
605
|
+
className: me != null && me.autoFilterRange ? "active" : "",
|
|
606
|
+
onClick: () => {
|
|
607
|
+
var e;
|
|
608
|
+
return (e = r.current) == null ? void 0 : e.toggleAutoFilter();
|
|
609
|
+
},
|
|
610
|
+
title: "切换自动筛选",
|
|
611
|
+
children: "筛选"
|
|
612
|
+
}
|
|
613
|
+
),
|
|
614
|
+
/* @__PURE__ */ o("button", { disabled: !(h != null && h.hasFilters()), onClick: () => {
|
|
615
|
+
var e;
|
|
616
|
+
return (e = r.current) == null ? void 0 : e.clearAllFilters();
|
|
617
|
+
}, children: "清除筛选" }),
|
|
618
|
+
/* @__PURE__ */ o("button", { disabled: !y, onClick: () => {
|
|
619
|
+
var e;
|
|
620
|
+
return void ((e = r.current) == null ? void 0 : e.copySelection());
|
|
621
|
+
}, title: "复制 (Ctrl+C)", children: "复制" }),
|
|
622
|
+
/* @__PURE__ */ o("button", { onClick: () => {
|
|
623
|
+
var e;
|
|
624
|
+
return void ((e = r.current) == null ? void 0 : e.downloadImage());
|
|
625
|
+
}, children: "导出 PNG" }),
|
|
626
|
+
/* @__PURE__ */ o("button", { onClick: () => {
|
|
627
|
+
var e;
|
|
628
|
+
return void ((e = r.current) == null ? void 0 : e.downloadPdf().catch((t) => {
|
|
629
|
+
var n, l;
|
|
630
|
+
return (l = (n = u.current).onError) == null ? void 0 : l.call(n, String((t == null ? void 0 : t.message) ?? t));
|
|
631
|
+
}));
|
|
632
|
+
}, children: "导出 PDF" }),
|
|
633
|
+
/* @__PURE__ */ o("select", { value: Math.round(H * 100), onChange: (e) => te(Number(e.target.value) / 100), title: "缩放", children: [50, 75, 100, 125, 150, 200].map((e) => /* @__PURE__ */ m("option", { value: e, children: [
|
|
634
|
+
e,
|
|
635
|
+
"%"
|
|
636
|
+
] }, e)) }),
|
|
637
|
+
G.flatMap((e) => e.toolbar ?? []).filter((e) => e.type !== "separator").map((e) => {
|
|
638
|
+
var t, n;
|
|
639
|
+
return /* @__PURE__ */ o(
|
|
640
|
+
"button",
|
|
641
|
+
{
|
|
642
|
+
className: (t = e.active) != null && t.call(e, _) ? "active" : "",
|
|
643
|
+
disabled: (n = e.disabled) == null ? void 0 : n.call(e, _),
|
|
644
|
+
title: e.title,
|
|
645
|
+
onClick: () => {
|
|
646
|
+
var l;
|
|
647
|
+
return (l = e.onClick) == null ? void 0 : l.call(e, _);
|
|
648
|
+
},
|
|
649
|
+
children: e.label ?? e.icon ?? e.id
|
|
650
|
+
},
|
|
651
|
+
e.id
|
|
652
|
+
);
|
|
653
|
+
})
|
|
654
|
+
] }),
|
|
655
|
+
c && /* @__PURE__ */ m("div", { className: "rxl-formula-bar", children: [
|
|
656
|
+
/* @__PURE__ */ o("span", { className: "addr", children: ye || "—" }),
|
|
657
|
+
/* @__PURE__ */ o("span", { className: "fx", children: "fx" }),
|
|
658
|
+
/* @__PURE__ */ o("span", { className: "content", title: be, children: be })
|
|
659
|
+
] }),
|
|
660
|
+
/* @__PURE__ */ m("div", { className: "rxl-render-area", ref: O, children: [
|
|
661
|
+
/* @__PURE__ */ o("canvas", { ref: K, className: "rxl-canvas" }),
|
|
662
|
+
/* @__PURE__ */ o("div", { className: "rxl-ov", ref: ne }),
|
|
663
|
+
/* @__PURE__ */ o("div", { className: "rxl-ov", ref: le }),
|
|
664
|
+
/* @__PURE__ */ o("div", { className: "rxl-ov", ref: re }),
|
|
665
|
+
/* @__PURE__ */ o("div", { className: "rxl-ov", ref: ce }),
|
|
666
|
+
/* @__PURE__ */ o(
|
|
667
|
+
"div",
|
|
668
|
+
{
|
|
669
|
+
className: "rxl-scroller",
|
|
670
|
+
ref: J,
|
|
671
|
+
tabIndex: 0,
|
|
672
|
+
onScroll: Xe,
|
|
673
|
+
onMouseDown: (e) => {
|
|
674
|
+
var t;
|
|
675
|
+
return (t = r.current) == null ? void 0 : t.onMouseDown(e.nativeEvent);
|
|
676
|
+
},
|
|
677
|
+
onMouseMove: (e) => {
|
|
678
|
+
var t;
|
|
679
|
+
return (t = r.current) == null ? void 0 : t.onMouseMove(e.nativeEvent);
|
|
680
|
+
},
|
|
681
|
+
onMouseUp: (e) => {
|
|
682
|
+
var t;
|
|
683
|
+
return (t = r.current) == null ? void 0 : t.onMouseUp(e.nativeEvent);
|
|
684
|
+
},
|
|
685
|
+
onMouseLeave: () => {
|
|
686
|
+
var e;
|
|
687
|
+
return (e = r.current) == null ? void 0 : e.onMouseLeave();
|
|
688
|
+
},
|
|
689
|
+
onDoubleClick: (e) => {
|
|
690
|
+
var t;
|
|
691
|
+
return (t = r.current) == null ? void 0 : t.onDblClick(e.nativeEvent);
|
|
692
|
+
},
|
|
693
|
+
onKeyDown: (e) => {
|
|
694
|
+
var t;
|
|
695
|
+
return (t = r.current) == null ? void 0 : t.onKeyDown(e.nativeEvent);
|
|
696
|
+
},
|
|
697
|
+
children: /* @__PURE__ */ o("div", { className: "rxl-spacer", ref: ve })
|
|
698
|
+
}
|
|
699
|
+
),
|
|
700
|
+
/* @__PURE__ */ o("div", { className: "rxl-ov-slot", children: /* @__PURE__ */ o("div", { ref: se }) }),
|
|
701
|
+
/* @__PURE__ */ o("div", { className: "rxl-editor-slot", ref: ae }),
|
|
702
|
+
$ && c && /* @__PURE__ */ m("div", { className: "rxl-findbar", children: [
|
|
703
|
+
/* @__PURE__ */ o(
|
|
704
|
+
"input",
|
|
705
|
+
{
|
|
706
|
+
autoFocus: !0,
|
|
707
|
+
placeholder: "查找…",
|
|
708
|
+
value: Y.query,
|
|
709
|
+
onChange: (e) => {
|
|
710
|
+
var t;
|
|
711
|
+
return (t = r.current) == null ? void 0 : t.setFindQuery(e.target.value);
|
|
712
|
+
},
|
|
713
|
+
onKeyDown: (e) => {
|
|
714
|
+
var t, n;
|
|
715
|
+
e.key === "Enter" ? e.shiftKey ? (t = r.current) == null || t.findPrev() : (n = r.current) == null || n.findNext() : e.key === "Escape" && ge();
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
),
|
|
719
|
+
/* @__PURE__ */ o("span", { className: "count", children: Y.count ? `${Y.index + 1}/${Y.count}` : "无结果" }),
|
|
720
|
+
/* @__PURE__ */ o("button", { onClick: () => {
|
|
721
|
+
var e;
|
|
722
|
+
return (e = r.current) == null ? void 0 : e.findPrev();
|
|
723
|
+
}, children: "↑" }),
|
|
724
|
+
/* @__PURE__ */ o("button", { onClick: () => {
|
|
725
|
+
var e;
|
|
726
|
+
return (e = r.current) == null ? void 0 : e.findNext();
|
|
727
|
+
}, children: "↓" }),
|
|
728
|
+
/* @__PURE__ */ o("button", { onClick: ge, children: "✕" })
|
|
729
|
+
] }),
|
|
730
|
+
A && /* @__PURE__ */ o(
|
|
731
|
+
ct,
|
|
732
|
+
{
|
|
733
|
+
values: A.values,
|
|
734
|
+
selected: A.selected,
|
|
735
|
+
x: A.x,
|
|
736
|
+
y: A.y,
|
|
737
|
+
sortDir: A.sortDir,
|
|
738
|
+
onApply: (e) => {
|
|
739
|
+
var t;
|
|
740
|
+
return (t = r.current) == null ? void 0 : t.applyFilterSelection(e);
|
|
741
|
+
},
|
|
742
|
+
onClear: () => {
|
|
743
|
+
var e;
|
|
744
|
+
return (e = r.current) == null ? void 0 : e.clearFilterColumn();
|
|
745
|
+
},
|
|
746
|
+
onClose: () => {
|
|
747
|
+
var e;
|
|
748
|
+
return (e = r.current) == null ? void 0 : e.closeFilterPopup();
|
|
749
|
+
},
|
|
750
|
+
onSort: (e) => {
|
|
751
|
+
var n, l;
|
|
752
|
+
const t = A.col;
|
|
753
|
+
(n = r.current) == null || n.closeFilterPopup(), (l = r.current) == null || l.sortColumn(t, e);
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
A.col
|
|
757
|
+
),
|
|
758
|
+
j && /* @__PURE__ */ o("div", { className: "rxl-tooltip " + j.kind, style: { left: j.x, top: j.y }, children: j.text }),
|
|
759
|
+
N && /* @__PURE__ */ o("div", { className: "rxl-state", children: (x == null ? void 0 : x.stage) === "read" ? "读取文件…" : (x == null ? void 0 : x.stage) === "parse" ? "解析中…" : "构建表格…" }),
|
|
760
|
+
!N && k && /* @__PURE__ */ m("div", { className: "rxl-state error", children: [
|
|
761
|
+
"解析失败:",
|
|
762
|
+
k
|
|
763
|
+
] }),
|
|
764
|
+
!N && !c && /* @__PURE__ */ o("div", { className: "rxl-state", children: "拖入或选择一个 .xlsx 文件" })
|
|
765
|
+
] }),
|
|
766
|
+
c && /* @__PURE__ */ m("div", { className: "rxl-status-bar", children: [
|
|
767
|
+
/* @__PURE__ */ o("span", { style: { color: "#888" }, children: Be || ye }),
|
|
768
|
+
/* @__PURE__ */ o("div", { className: "grow" }),
|
|
769
|
+
E && E.numCount > 0 ? /* @__PURE__ */ m(Ue, { children: [
|
|
770
|
+
/* @__PURE__ */ m("span", { children: [
|
|
771
|
+
"计数 ",
|
|
772
|
+
E.count
|
|
773
|
+
] }),
|
|
774
|
+
/* @__PURE__ */ m("span", { children: [
|
|
775
|
+
"求和 ",
|
|
776
|
+
ee(E.sum)
|
|
777
|
+
] }),
|
|
778
|
+
/* @__PURE__ */ m("span", { children: [
|
|
779
|
+
"平均 ",
|
|
780
|
+
ee(E.avg)
|
|
781
|
+
] }),
|
|
782
|
+
/* @__PURE__ */ m("span", { children: [
|
|
783
|
+
"最大 ",
|
|
784
|
+
ee(E.max)
|
|
785
|
+
] }),
|
|
786
|
+
/* @__PURE__ */ m("span", { children: [
|
|
787
|
+
"最小 ",
|
|
788
|
+
ee(E.min)
|
|
789
|
+
] })
|
|
790
|
+
] }) : E && E.count > 0 ? /* @__PURE__ */ m("span", { children: [
|
|
791
|
+
"计数 ",
|
|
792
|
+
E.count
|
|
793
|
+
] }) : null
|
|
794
|
+
] }),
|
|
795
|
+
c && pe.length > 0 && /* @__PURE__ */ o("div", { className: "rxl-tabs", children: pe.map(({ s: e, i: t }) => /* @__PURE__ */ o("button", { className: t === R ? "active" : "", onClick: () => I(t), children: e.name }, t)) })
|
|
796
|
+
] });
|
|
797
|
+
});
|
|
798
|
+
function ct(f) {
|
|
799
|
+
const i = f.selected.length ? new Set(f.selected) : new Set(f.values), [p, N] = F(i), k = (c) => {
|
|
800
|
+
const x = new Set(p);
|
|
801
|
+
x.has(c) ? x.delete(c) : x.add(c), N(x);
|
|
802
|
+
};
|
|
803
|
+
return /* @__PURE__ */ m("div", { className: "rxl-filterpop", style: { left: f.x, top: f.y }, children: [
|
|
804
|
+
/* @__PURE__ */ m("div", { className: "sort", children: [
|
|
805
|
+
/* @__PURE__ */ o("button", { className: f.sortDir === "asc" ? "on" : "", onClick: () => f.onSort("asc"), children: "↑ 升序" }),
|
|
806
|
+
/* @__PURE__ */ o("button", { className: f.sortDir === "desc" ? "on" : "", onClick: () => f.onSort("desc"), children: "↓ 降序" })
|
|
807
|
+
] }),
|
|
808
|
+
/* @__PURE__ */ m("div", { className: "list", children: [
|
|
809
|
+
/* @__PURE__ */ m("label", { children: [
|
|
810
|
+
/* @__PURE__ */ o(
|
|
811
|
+
"input",
|
|
812
|
+
{
|
|
813
|
+
type: "checkbox",
|
|
814
|
+
checked: p.size === f.values.length,
|
|
815
|
+
ref: (c) => {
|
|
816
|
+
c && (c.indeterminate = p.size > 0 && p.size < f.values.length);
|
|
817
|
+
},
|
|
818
|
+
onChange: (c) => N(c.target.checked ? new Set(f.values) : /* @__PURE__ */ new Set())
|
|
819
|
+
}
|
|
820
|
+
),
|
|
821
|
+
"(全选)"
|
|
822
|
+
] }),
|
|
823
|
+
f.values.map((c) => /* @__PURE__ */ m("label", { children: [
|
|
824
|
+
/* @__PURE__ */ o("input", { type: "checkbox", checked: p.has(c), onChange: () => k(c) }),
|
|
825
|
+
c
|
|
826
|
+
] }, c))
|
|
827
|
+
] }),
|
|
828
|
+
/* @__PURE__ */ m("div", { className: "foot", children: [
|
|
829
|
+
/* @__PURE__ */ o("button", { onClick: f.onClear, children: "清除" }),
|
|
830
|
+
/* @__PURE__ */ o("button", { onClick: () => f.onApply([...p]), children: "确定" }),
|
|
831
|
+
/* @__PURE__ */ o("button", { onClick: f.onClose, children: "取消" })
|
|
832
|
+
] })
|
|
833
|
+
] });
|
|
834
|
+
}
|
|
835
|
+
export {
|
|
836
|
+
ut as ExcelViewer,
|
|
837
|
+
lt as useExcelDocument
|
|
838
|
+
};
|