@fileverse-dev/dsheet 4.1.23 → 4.1.24-stabilise-package-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/README.md +10 -0
- package/dist/editor/contexts/editor-context.d.ts +10 -0
- package/dist/editor/hooks/use-celldata-compaction.d.ts +44 -2
- package/dist/editor/hooks/use-celldata-compaction.test.d.ts +1 -0
- package/dist/editor/hooks/use-editor-data.d.ts +1 -0
- package/dist/editor/hooks/use-editor-sync.d.ts +5 -1
- package/dist/editor/hooks/use-editor-sync.test.d.ts +1 -0
- package/dist/editor/types.d.ts +44 -1
- package/dist/editor/utils/active-sheet-keeper.test.d.ts +1 -0
- package/dist/editor/utils/after-update-cell.d.ts +6 -0
- package/dist/editor/utils/after-update-cell.test.d.ts +1 -0
- package/dist/editor/utils/apply-comment-markers.d.ts +3 -1
- package/dist/editor/utils/apply-comment-markers.test.d.ts +1 -0
- package/dist/editor/utils/calc-chain-ydoc-update.test.d.ts +1 -0
- package/dist/editor/utils/content-change.d.ts +48 -0
- package/dist/editor/utils/content-change.test.d.ts +1 -0
- package/dist/editor/utils/content-fingerprint.d.ts +37 -0
- package/dist/editor/utils/content-fingerprint.test.d.ts +1 -0
- package/dist/editor/utils/editor-handle.d.ts +1 -1
- package/dist/editor/utils/format-gate.d.ts +27 -0
- package/dist/editor/utils/format-gate.test.d.ts +1 -0
- package/dist/editor/utils/legacy-on-change.d.ts +20 -0
- package/dist/editor/utils/legacy-on-change.test.d.ts +1 -0
- package/dist/editor/utils/patch-plain-celldata.d.ts +19 -0
- package/dist/editor/utils/patch-plain-celldata.test.d.ts +1 -0
- package/dist/editor/utils/rebuild-indexeddb-store.d.ts +19 -0
- package/dist/editor/utils/rebuild-indexeddb-store.failure.test.d.ts +1 -0
- package/dist/editor/utils/rebuild-indexeddb-store.test.d.ts +1 -0
- package/dist/editor/utils/remote-apply-guard.d.ts +45 -0
- package/dist/editor/utils/remote-apply-guard.test.d.ts +1 -0
- package/dist/editor/utils/sheet-ydoc-sync-utils.d.ts +13 -4
- package/dist/editor/utils/sheet-ydoc-sync-utils.test.d.ts +1 -0
- package/dist/editor/utils/structural-edit-formula-sync.test.d.ts +1 -0
- package/dist/editor/utils/structural-edit-other-tabs.test.d.ts +1 -0
- package/dist/editor/utils/update-ydoc.d.ts +9 -1
- package/dist/editor/utils/wait-for-sync.d.ts +35 -0
- package/dist/editor/utils/wait-for-sync.test.d.ts +1 -0
- package/dist/editor/utils/xlsx-export-impl.d.ts +1 -0
- package/dist/editor/utils/xlsx-export.d.ts +1 -0
- package/dist/{executeStringFunction-ZHYCWIpK.js → executeStringFunction-CT-4of9q.js} +13725 -12781
- package/dist/formula.js +1 -1
- package/dist/{index-8_qnUyMl.js → index-CfRtF9ry.js} +23233 -21903
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +44 -43
- package/dist/persistence-utils-CSKBobX8.js +151 -0
- package/dist/persistence-utils.d.ts +2 -0
- package/dist/persistence.append.test.d.ts +1 -0
- package/dist/persistence.d.ts +13 -0
- package/dist/persistence.fingerprint.test.d.ts +1 -0
- package/dist/persistence.js +122 -74
- package/dist/sheet-engine/core/api/cell.d.ts +25 -1
- package/dist/sheet-engine/core/api/remote-apply.test.d.ts +1 -0
- package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +1 -0
- package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.test.d.ts +1 -0
- package/dist/sheet-engine/core/index.d.ts +1 -1
- package/dist/sheet-engine/core/modules/b6-ydoc-writes.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/border.d.ts +9 -0
- package/dist/sheet-engine/core/modules/cell-shift.d.ts +11 -0
- package/dist/sheet-engine/core/modules/cell.commit-ydoc.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/dataVerification.d.ts +15 -0
- package/dist/sheet-engine/core/modules/engine-hot-spots.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/formula-arrow-mode.d.ts +81 -0
- package/dist/sheet-engine/core/modules/formula-arrow-mode.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +5 -0
- package/dist/sheet-engine/core/modules/formula-dep-text.d.ts +23 -0
- package/dist/sheet-engine/core/modules/formula-dep-text.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/formula-edge-update.d.ts +13 -0
- package/dist/sheet-engine/core/modules/formula-narrowing.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +2 -0
- package/dist/sheet-engine/core/modules/formula-tab-load.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +26 -1
- package/dist/sheet-engine/core/modules/formula-warmup.d.ts +33 -0
- package/dist/sheet-engine/core/modules/formula-warmup.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/formula.d.ts +119 -2
- package/dist/sheet-engine/core/modules/formula.dep-graph.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/formula.str-change.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/formula.wide-seed.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/history-calc-chain.d.ts +39 -0
- package/dist/sheet-engine/core/modules/history-calc-chain.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/history-celldata.d.ts +25 -0
- package/dist/sheet-engine/core/modules/history-grid-size.d.ts +16 -0
- package/dist/sheet-engine/core/modules/history-grid-size.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/index.d.ts +4 -3
- package/dist/sheet-engine/core/modules/rowcol-refused-edit.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/rowcol-unloaded-history.test.d.ts +1 -0
- package/dist/sheet-engine/core/modules/rowcol.d.ts +8 -0
- package/dist/sheet-engine/core/modules/structural-edit-prep.d.ts +36 -0
- package/dist/sheet-engine/core/modules/structural-edit-prep.test.d.ts +1 -0
- package/dist/sheet-engine/core/paste/paste-dep-graph.test.d.ts +1 -0
- package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.d.ts +14 -0
- package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.test.d.ts +1 -0
- package/dist/sheet-engine/core/settings.d.ts +11 -1
- package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +29 -2
- package/dist/sheet-engine/react/components/ContextMenu/FilterMenu.d.ts +2 -2
- package/dist/sheet-engine/react/components/ContextMenu/SheetTab.d.ts +2 -2
- package/dist/sheet-engine/react/components/ContextMenu/index.d.ts +2 -2
- package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.d.ts +20 -0
- package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.test.d.ts +1 -0
- package/dist/sheet-engine/react/components/SVGDefines.d.ts +2 -2
- package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.d.ts +7 -0
- package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.test.d.ts +1 -0
- package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.d.ts +44 -0
- package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.test.d.ts +1 -0
- package/dist/sheet-engine/react/components/SheetTab/index.d.ts +2 -2
- package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.d.ts +9 -0
- package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.test.d.ts +1 -0
- package/dist/sheet-engine/react/components/Toolbar/index.d.ts +2 -2
- package/dist/sheet-engine/react/components/Workbook/api.d.ts +4 -0
- package/dist/sheet-engine/react/components/Workbook/denomination-scan.d.ts +16 -0
- package/dist/sheet-engine/react/components/Workbook/denomination-scan.test.d.ts +1 -0
- package/dist/sheet-engine/react/components/Workbook/index.d.ts +2 -0
- package/dist/sheet-engine/react/components/Workbook/stable-handle.d.ts +8 -0
- package/dist/sheet-engine/react/components/Workbook/stable-handle.test.d.ts +1 -0
- package/dist/sheet-engine/react/context/index.d.ts +15 -0
- package/dist/sheet-engine/react/context/use-workbook-store.d.ts +30 -0
- package/dist/sheet-engine/react/context/workbook-store.d.ts +30 -0
- package/dist/sheet-engine/react/context/workbook-store.test.d.ts +1 -0
- package/dist/style.css +1 -1
- package/dist/sync-local/SyncManager.d.ts +2 -2
- package/dist/sync-local/SyncManager.remote-apply.test.d.ts +1 -0
- package/dist/sync-local/SyncManager.test.d.ts +1 -0
- package/dist/sync-local/socketClient.d.ts +2 -0
- package/dist/sync-local/socketClient.test.d.ts +1 -0
- package/dist/sync-local/types/index.d.ts +5 -1
- package/dist/{use-xlsx-import-impl-cgDH14_y.js → use-xlsx-import-impl-Yyav1K_X.js} +120 -119
- package/dist/{xlsx-defined-names-DCK7aKIO.js → xlsx-defined-names-D6d7zKHF.js} +2 -2
- package/dist/xlsx-export-impl-BHJqLH7w.js +903 -0
- package/dist/{xlsx-hyperlink-inline-T4GsXFm7.js → xlsx-hyperlink-inline-DGb-w2IM.js} +2 -2
- package/package.json +1 -1
- package/dist/persistence-utils-BXFajzvq.js +0 -98
- package/dist/xlsx-export-impl-BHDWz0aW.js +0 -880
|
@@ -1,880 +0,0 @@
|
|
|
1
|
-
import { utils as S, write as nt } from "xlsx-js-style";
|
|
2
|
-
import { Workbook as pt } from "exceljs";
|
|
3
|
-
import { toast as rt } from "@fileverse/ui";
|
|
4
|
-
import { J as dt, c as X, g as ht, a as mt } from "./xlsx-hyperlink-inline-T4GsXFm7.js";
|
|
5
|
-
import { b as gt } from "./executeStringFunction-ZHYCWIpK.js";
|
|
6
|
-
import { e as bt } from "./index-8_qnUyMl.js";
|
|
7
|
-
const xt = {
|
|
8
|
-
1: "thin",
|
|
9
|
-
2: "hair",
|
|
10
|
-
3: "dotted",
|
|
11
|
-
4: "dashed",
|
|
12
|
-
5: "dashDot",
|
|
13
|
-
6: "dashDotDot",
|
|
14
|
-
7: "double",
|
|
15
|
-
8: "medium",
|
|
16
|
-
9: "mediumDashed",
|
|
17
|
-
10: "mediumDashDot",
|
|
18
|
-
11: "mediumDashDotDot",
|
|
19
|
-
12: "slantDashDot",
|
|
20
|
-
13: "thick"
|
|
21
|
-
}, yt = (t) => {
|
|
22
|
-
if (typeof t != "string") return "000000";
|
|
23
|
-
const r = t.replace("#", "").toUpperCase();
|
|
24
|
-
return r.length === 3 ? r.replace(/(.)/g, "$1$1") : r.length === 6 ? r : "000000";
|
|
25
|
-
}, q = (t, r) => {
|
|
26
|
-
const e = Number(t);
|
|
27
|
-
if (e)
|
|
28
|
-
return {
|
|
29
|
-
style: xt[e] ?? "thin",
|
|
30
|
-
color: { rgb: yt(r) }
|
|
31
|
-
};
|
|
32
|
-
}, _ = (t, r, e, o, n) => {
|
|
33
|
-
if (!n || !o.l && !o.r && !o.t && !o.b) return;
|
|
34
|
-
const i = S.encode_cell({ r, c: e }), c = {
|
|
35
|
-
...t[i] || { t: "z" }
|
|
36
|
-
}, u = { ...c.s || {} }, d = { ...u.border || {} };
|
|
37
|
-
o.l && (d.left = n), o.r && (d.right = n), o.t && (d.top = n), o.b && (d.bottom = n), u.border = d, c.s = u, t[i] = c;
|
|
38
|
-
}, Ct = (t, r) => {
|
|
39
|
-
r.forEach((e) => {
|
|
40
|
-
if (e.rangeType === "cell") {
|
|
41
|
-
if (!e.value) return;
|
|
42
|
-
const { row_index: o, col_index: n } = e.value;
|
|
43
|
-
if (o == null || n == null) return;
|
|
44
|
-
const i = e.value, c = S.encode_cell({ r: o, c: n }), u = {
|
|
45
|
-
...t[c] || { t: "z" }
|
|
46
|
-
}, d = { ...u.s || {} }, s = { ...d.border || {} };
|
|
47
|
-
i.l && (s.left = q(i.l.style, i.l.color)), i.r && (s.right = q(i.r.style, i.r.color)), i.t && (s.top = q(i.t.style, i.t.color)), i.b && (s.bottom = q(i.b.style, i.b.color)), d.border = s, u.s = d, t[c] = u;
|
|
48
|
-
} else if (e.rangeType === "range") {
|
|
49
|
-
const { borderType: o, style: n, color: i, range: c } = e;
|
|
50
|
-
if (o === "border-none" || !Array.isArray(c) || !n)
|
|
51
|
-
return;
|
|
52
|
-
const u = q(n, i);
|
|
53
|
-
if (!u) return;
|
|
54
|
-
c.forEach((d) => {
|
|
55
|
-
const [s, C] = d.row, [k, T] = d.column;
|
|
56
|
-
for (let x = s; x <= C; x++)
|
|
57
|
-
for (let E = k; E <= T; E++)
|
|
58
|
-
switch (o) {
|
|
59
|
-
case "border-all":
|
|
60
|
-
_(
|
|
61
|
-
t,
|
|
62
|
-
x,
|
|
63
|
-
E,
|
|
64
|
-
{ l: !0, r: !0, t: !0, b: !0 },
|
|
65
|
-
u
|
|
66
|
-
);
|
|
67
|
-
break;
|
|
68
|
-
case "border-outside":
|
|
69
|
-
_(
|
|
70
|
-
t,
|
|
71
|
-
x,
|
|
72
|
-
E,
|
|
73
|
-
{ l: E === k, r: E === T, t: x === s, b: x === C },
|
|
74
|
-
u
|
|
75
|
-
);
|
|
76
|
-
break;
|
|
77
|
-
case "border-inside":
|
|
78
|
-
_(
|
|
79
|
-
t,
|
|
80
|
-
x,
|
|
81
|
-
E,
|
|
82
|
-
{ r: E < T, b: x < C },
|
|
83
|
-
u
|
|
84
|
-
);
|
|
85
|
-
break;
|
|
86
|
-
case "border-horizontal":
|
|
87
|
-
_(t, x, E, { b: x < C }, u);
|
|
88
|
-
break;
|
|
89
|
-
case "border-vertical":
|
|
90
|
-
_(t, x, E, { r: E < T }, u);
|
|
91
|
-
break;
|
|
92
|
-
case "border-left":
|
|
93
|
-
E === k && _(t, x, E, { l: !0 }, u);
|
|
94
|
-
break;
|
|
95
|
-
case "border-right":
|
|
96
|
-
E === T && _(t, x, E, { r: !0 }, u);
|
|
97
|
-
break;
|
|
98
|
-
case "border-top":
|
|
99
|
-
x === s && _(t, x, E, { t: !0 }, u);
|
|
100
|
-
break;
|
|
101
|
-
case "border-bottom":
|
|
102
|
-
x === C && _(t, x, E, { b: !0 }, u);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
function K(t) {
|
|
110
|
-
if (!t || typeof t != "string") return null;
|
|
111
|
-
const r = t.trim();
|
|
112
|
-
if (r.startsWith("#")) {
|
|
113
|
-
const o = r.replace("#", "").toUpperCase();
|
|
114
|
-
return o.length === 3 ? "FF" + o.split("").map((n) => n + n).join("") : o.length === 6 ? "FF" + o : null;
|
|
115
|
-
}
|
|
116
|
-
const e = r.match(/rgba?\s*\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);
|
|
117
|
-
if (e) {
|
|
118
|
-
const o = (n) => Math.min(255, Math.max(0, Math.round(n))).toString(16).padStart(2, "0").toUpperCase();
|
|
119
|
-
return "FF" + o(parseFloat(e[1])) + o(parseFloat(e[2])) + o(parseFloat(e[3]));
|
|
120
|
-
}
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
function Et(t) {
|
|
124
|
-
const r = {}, e = {};
|
|
125
|
-
if (t.textColor && t.textColor.toLowerCase() !== "#000000") {
|
|
126
|
-
const n = K(t.textColor);
|
|
127
|
-
n && (e.color = { argb: n });
|
|
128
|
-
}
|
|
129
|
-
t.bold && (e.bold = !0), t.italic && (e.italic = !0), t.underline && (e.underline = !0), t.strikethrough && (e.strike = !0), Object.keys(e).length > 0 && (r.font = e);
|
|
130
|
-
const o = t.cellColor;
|
|
131
|
-
if (o && o.toLowerCase() !== "#ffffff") {
|
|
132
|
-
const n = K(o);
|
|
133
|
-
n && (r.fill = { type: "pattern", pattern: "solid", fgColor: { argb: n } });
|
|
134
|
-
}
|
|
135
|
-
return r;
|
|
136
|
-
}
|
|
137
|
-
function Tt(t) {
|
|
138
|
-
return !Array.isArray(t) || t.length === 0 ? "" : t.map((e) => {
|
|
139
|
-
const [o, n] = e.row, [i, c] = e.column, u = S.encode_cell({ r: o, c: i }), d = S.encode_cell({ r: n, c });
|
|
140
|
-
return u === d ? u : `${u}:${d}`;
|
|
141
|
-
}).filter(Boolean).join(" ");
|
|
142
|
-
}
|
|
143
|
-
function wt(t, r, e) {
|
|
144
|
-
const { conditionName: o, conditionValue: n = [], format: i = {} } = t, c = Et(i), u = (s) => s.replace(/"/g, '""'), d = r.split(/[\s:]/)[0];
|
|
145
|
-
switch (o) {
|
|
146
|
-
case "greaterThan":
|
|
147
|
-
case "greaterThanOrEqual":
|
|
148
|
-
case "lessThan":
|
|
149
|
-
case "lessThanOrEqual":
|
|
150
|
-
case "equal":
|
|
151
|
-
return n[0] ? {
|
|
152
|
-
type: "cellIs",
|
|
153
|
-
operator: o,
|
|
154
|
-
formulae: [n[0]],
|
|
155
|
-
priority: e,
|
|
156
|
-
style: c
|
|
157
|
-
} : null;
|
|
158
|
-
case "notEqual":
|
|
159
|
-
return n[0] ? {
|
|
160
|
-
type: "cellIs",
|
|
161
|
-
operator: "notEqual",
|
|
162
|
-
formulae: [n[0]],
|
|
163
|
-
priority: e,
|
|
164
|
-
style: c
|
|
165
|
-
} : null;
|
|
166
|
-
case "between":
|
|
167
|
-
return n.length < 2 ? null : {
|
|
168
|
-
type: "cellIs",
|
|
169
|
-
operator: "between",
|
|
170
|
-
formulae: [n[0], n[1]],
|
|
171
|
-
priority: e,
|
|
172
|
-
style: c
|
|
173
|
-
};
|
|
174
|
-
case "notBetween":
|
|
175
|
-
return n.length < 2 ? null : {
|
|
176
|
-
type: "cellIs",
|
|
177
|
-
operator: "notBetween",
|
|
178
|
-
formulae: [n[0], n[1]],
|
|
179
|
-
priority: e,
|
|
180
|
-
style: c
|
|
181
|
-
};
|
|
182
|
-
case "textContains": {
|
|
183
|
-
if (!n[0]) return null;
|
|
184
|
-
const s = n[0];
|
|
185
|
-
return {
|
|
186
|
-
type: "containsText",
|
|
187
|
-
operator: "containsText",
|
|
188
|
-
text: s,
|
|
189
|
-
formulae: [
|
|
190
|
-
`NOT(ISERROR(SEARCH("${u(s)}",${d})))`
|
|
191
|
-
],
|
|
192
|
-
priority: e,
|
|
193
|
-
style: c
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
case "containsText": {
|
|
197
|
-
if (!n[0]) return null;
|
|
198
|
-
const s = n[0];
|
|
199
|
-
return {
|
|
200
|
-
type: "containsText",
|
|
201
|
-
operator: "containsText",
|
|
202
|
-
text: s,
|
|
203
|
-
formulae: [
|
|
204
|
-
`NOT(ISERROR(SEARCH("${u(s)}",${d})))`
|
|
205
|
-
],
|
|
206
|
-
priority: e,
|
|
207
|
-
style: c
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
case "textDoesNotContain": {
|
|
211
|
-
if (!n[0]) return null;
|
|
212
|
-
const s = n[0];
|
|
213
|
-
return {
|
|
214
|
-
type: "notContainsText",
|
|
215
|
-
operator: "notContainsText",
|
|
216
|
-
text: s,
|
|
217
|
-
formulae: [`ISERROR(SEARCH("${u(s)}",${d}))`],
|
|
218
|
-
priority: e,
|
|
219
|
-
style: c
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
case "notContainsText":
|
|
223
|
-
case "notContains": {
|
|
224
|
-
if (!n[0]) return null;
|
|
225
|
-
const s = n[0];
|
|
226
|
-
return {
|
|
227
|
-
type: "notContainsText",
|
|
228
|
-
operator: "notContainsText",
|
|
229
|
-
text: s,
|
|
230
|
-
formulae: [`ISERROR(SEARCH("${u(s)}",${d}))`],
|
|
231
|
-
priority: e,
|
|
232
|
-
style: c
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
case "textStartsWith": {
|
|
236
|
-
if (!n[0]) return null;
|
|
237
|
-
const s = n[0];
|
|
238
|
-
return {
|
|
239
|
-
type: "beginsWith",
|
|
240
|
-
operator: "beginsWith",
|
|
241
|
-
text: s,
|
|
242
|
-
formulae: [
|
|
243
|
-
`LEFT(${d},${s.length})="${u(s)}"`
|
|
244
|
-
],
|
|
245
|
-
priority: e,
|
|
246
|
-
style: c
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
case "beginsWith": {
|
|
250
|
-
if (!n[0]) return null;
|
|
251
|
-
const s = n[0];
|
|
252
|
-
return {
|
|
253
|
-
type: "beginsWith",
|
|
254
|
-
operator: "beginsWith",
|
|
255
|
-
text: s,
|
|
256
|
-
formulae: [
|
|
257
|
-
`LEFT(${d},${s.length})="${u(s)}"`
|
|
258
|
-
],
|
|
259
|
-
priority: e,
|
|
260
|
-
style: c
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
case "textEndsWith": {
|
|
264
|
-
if (!n[0]) return null;
|
|
265
|
-
const s = n[0];
|
|
266
|
-
return {
|
|
267
|
-
type: "endsWith",
|
|
268
|
-
operator: "endsWith",
|
|
269
|
-
text: s,
|
|
270
|
-
formulae: [
|
|
271
|
-
`RIGHT(${d},${s.length})="${u(s)}"`
|
|
272
|
-
],
|
|
273
|
-
priority: e,
|
|
274
|
-
style: c
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
case "endsWith": {
|
|
278
|
-
if (!n[0]) return null;
|
|
279
|
-
const s = n[0];
|
|
280
|
-
return {
|
|
281
|
-
type: "endsWith",
|
|
282
|
-
operator: "endsWith",
|
|
283
|
-
text: s,
|
|
284
|
-
formulae: [
|
|
285
|
-
`RIGHT(${d},${s.length})="${u(s)}"`
|
|
286
|
-
],
|
|
287
|
-
priority: e,
|
|
288
|
-
style: c
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
case "textExactly": {
|
|
292
|
-
if (!n[0]) return null;
|
|
293
|
-
const s = n[0];
|
|
294
|
-
return {
|
|
295
|
-
// Keep this in the text-rule family so Google/OOXML readers preserve it
|
|
296
|
-
// similarly to other text CF rules.
|
|
297
|
-
type: "containsText",
|
|
298
|
-
operator: "equal",
|
|
299
|
-
text: s,
|
|
300
|
-
formulae: [`EXACT(${d},"${u(s)}")`],
|
|
301
|
-
priority: e,
|
|
302
|
-
style: c
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
case "empty":
|
|
306
|
-
return {
|
|
307
|
-
type: "containsText",
|
|
308
|
-
operator: "containsBlanks",
|
|
309
|
-
formulae: [`LEN(TRIM(${d}))=0`],
|
|
310
|
-
priority: e,
|
|
311
|
-
style: c
|
|
312
|
-
};
|
|
313
|
-
case "containsBlanks":
|
|
314
|
-
return {
|
|
315
|
-
type: "containsText",
|
|
316
|
-
operator: "containsBlanks",
|
|
317
|
-
formulae: [`LEN(TRIM(${d}))=0`],
|
|
318
|
-
priority: e,
|
|
319
|
-
style: c
|
|
320
|
-
};
|
|
321
|
-
case "notEmpty":
|
|
322
|
-
return {
|
|
323
|
-
type: "containsText",
|
|
324
|
-
operator: "notContainsBlanks",
|
|
325
|
-
formulae: [`LEN(TRIM(${d}))>0`],
|
|
326
|
-
priority: e,
|
|
327
|
-
style: c
|
|
328
|
-
};
|
|
329
|
-
case "notContainsBlanks":
|
|
330
|
-
return {
|
|
331
|
-
type: "containsText",
|
|
332
|
-
operator: "notContainsBlanks",
|
|
333
|
-
formulae: [`LEN(TRIM(${d}))>0`],
|
|
334
|
-
priority: e,
|
|
335
|
-
style: c
|
|
336
|
-
};
|
|
337
|
-
case "top10":
|
|
338
|
-
return {
|
|
339
|
-
type: "top10",
|
|
340
|
-
rank: parseInt(n[0] || "10", 10) || 10,
|
|
341
|
-
percent: !1,
|
|
342
|
-
bottom: !1,
|
|
343
|
-
priority: e,
|
|
344
|
-
style: c
|
|
345
|
-
};
|
|
346
|
-
case "top10Percent":
|
|
347
|
-
case "top10_percent":
|
|
348
|
-
return {
|
|
349
|
-
type: "top10",
|
|
350
|
-
rank: parseInt(n[0] || "10", 10) || 10,
|
|
351
|
-
percent: !0,
|
|
352
|
-
bottom: !1,
|
|
353
|
-
priority: e,
|
|
354
|
-
style: c
|
|
355
|
-
};
|
|
356
|
-
case "last10":
|
|
357
|
-
return {
|
|
358
|
-
type: "top10",
|
|
359
|
-
rank: parseInt(n[0] || "10", 10) || 10,
|
|
360
|
-
percent: !1,
|
|
361
|
-
bottom: !0,
|
|
362
|
-
priority: e,
|
|
363
|
-
style: c
|
|
364
|
-
};
|
|
365
|
-
case "last10Percent":
|
|
366
|
-
case "last10_percent":
|
|
367
|
-
return {
|
|
368
|
-
type: "top10",
|
|
369
|
-
rank: parseInt(n[0] || "10", 10) || 10,
|
|
370
|
-
percent: !0,
|
|
371
|
-
bottom: !0,
|
|
372
|
-
priority: e,
|
|
373
|
-
style: c
|
|
374
|
-
};
|
|
375
|
-
case "aboveAverage":
|
|
376
|
-
return { type: "aboveAverage", aboveAverage: !0, priority: e, style: c };
|
|
377
|
-
case "belowAverage":
|
|
378
|
-
return { type: "aboveAverage", aboveAverage: !1, priority: e, style: c };
|
|
379
|
-
case "date":
|
|
380
|
-
case "dateIs":
|
|
381
|
-
case "dateBefore":
|
|
382
|
-
case "dateAfter": {
|
|
383
|
-
const s = String(n[0] ?? ""), C = s.startsWith("preset:") ? s.slice(7) : s.toLowerCase();
|
|
384
|
-
return C === "today" || C === "tomorrow" || C === "yesterday" ? { type: "timePeriod", timePeriod: C, priority: e, style: c } : C === "pastWeek" ? { type: "timePeriod", timePeriod: "last7Days", priority: e, style: c } : C === "pastMonth" ? { type: "timePeriod", timePeriod: "lastMonth", priority: e, style: c } : C === "pastYear" ? { type: "timePeriod", timePeriod: "lastYear", priority: e, style: c } : null;
|
|
385
|
-
}
|
|
386
|
-
default:
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
function $t(t, r, e) {
|
|
391
|
-
var c;
|
|
392
|
-
const o = r.luckysheet_conditionformat_save, n = [];
|
|
393
|
-
if (!Array.isArray(o) || o.length === 0)
|
|
394
|
-
return { nextPriority: e, pendingDuplicateValues: n };
|
|
395
|
-
let i = e;
|
|
396
|
-
for (const u of o) {
|
|
397
|
-
if (u.type !== "default") continue;
|
|
398
|
-
const d = Tt(u.cellrange);
|
|
399
|
-
if (!d) continue;
|
|
400
|
-
if (u.conditionName === "duplicateValue") {
|
|
401
|
-
const C = String(((c = u.conditionValue) == null ? void 0 : c[0]) ?? "0") === "1" ? "uniqueValues" : "duplicateValues";
|
|
402
|
-
n.push({
|
|
403
|
-
ref: d,
|
|
404
|
-
format: u.format || {},
|
|
405
|
-
priority: i,
|
|
406
|
-
type: C
|
|
407
|
-
}), i++;
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
const s = wt(u, d, i);
|
|
411
|
-
s && (t.addConditionalFormatting({ ref: d, rules: [s] }), i++);
|
|
412
|
-
}
|
|
413
|
-
return { nextPriority: i, pendingDuplicateValues: n };
|
|
414
|
-
}
|
|
415
|
-
function At(t) {
|
|
416
|
-
let r = "";
|
|
417
|
-
const e = [];
|
|
418
|
-
if (t.bold && e.push("<b/>"), t.italic && e.push("<i/>"), t.underline && e.push("<u/>"), t.strikethrough && e.push("<strike/>"), t.textColor && t.textColor.toLowerCase() !== "#000000") {
|
|
419
|
-
const n = K(t.textColor);
|
|
420
|
-
n && e.push(`<color rgb="${n}"/>`);
|
|
421
|
-
}
|
|
422
|
-
e.length > 0 && (r += `<font>${e.join("")}</font>`);
|
|
423
|
-
const o = t.cellColor;
|
|
424
|
-
if (o && o.toLowerCase() !== "#ffffff") {
|
|
425
|
-
const n = K(o);
|
|
426
|
-
n && (r += `<fill><patternFill patternType="solid"><fgColor rgb="${n}"/></patternFill></fill>`);
|
|
427
|
-
}
|
|
428
|
-
return `<dxf>${r}</dxf>`;
|
|
429
|
-
}
|
|
430
|
-
function kt(t, r) {
|
|
431
|
-
const e = t.match(/<dxfs count="(\d+)"/);
|
|
432
|
-
if (e) {
|
|
433
|
-
const o = parseInt(e[1], 10);
|
|
434
|
-
return {
|
|
435
|
-
xml: t.replace(/<dxfs count="\d+"/, `<dxfs count="${o + 1}"`).replace("</dxfs>", r + "</dxfs>"),
|
|
436
|
-
dxfId: o
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
return t.includes("<dxfs/>") ? {
|
|
440
|
-
xml: t.replace("<dxfs/>", `<dxfs count="1">${r}</dxfs>`),
|
|
441
|
-
dxfId: 0
|
|
442
|
-
} : {
|
|
443
|
-
xml: t.replace(
|
|
444
|
-
"</styleSheet>",
|
|
445
|
-
`<dxfs count="1">${r}</dxfs></styleSheet>`
|
|
446
|
-
),
|
|
447
|
-
dxfId: 0
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
function Rt(t) {
|
|
451
|
-
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
452
|
-
}
|
|
453
|
-
function Ft(t, r, e) {
|
|
454
|
-
const o = new RegExp(
|
|
455
|
-
`(<conditionalFormatting[^>]*\\bsqref="${Rt(r)}"[^>]*>)`
|
|
456
|
-
);
|
|
457
|
-
if (o.test(t))
|
|
458
|
-
return t.replace(o, `$1${e}`);
|
|
459
|
-
const n = `<conditionalFormatting sqref="${r}">${e}</conditionalFormatting>`;
|
|
460
|
-
for (const i of [
|
|
461
|
-
"<pageMargins",
|
|
462
|
-
"<pageSetup",
|
|
463
|
-
"<headerFooter",
|
|
464
|
-
"<drawing",
|
|
465
|
-
"</worksheet>"
|
|
466
|
-
])
|
|
467
|
-
if (t.includes(i))
|
|
468
|
-
return t.replace(i, n + i);
|
|
469
|
-
return t + n;
|
|
470
|
-
}
|
|
471
|
-
function St(t) {
|
|
472
|
-
return t.replace(
|
|
473
|
-
/<cfRule([^>]*)type="containsText"([^>]*?)>([\s\S]*?)<\/cfRule>/g,
|
|
474
|
-
(r, e, o, n) => {
|
|
475
|
-
if (/\btext=/.test(e) || /\btext=/.test(o)) return r;
|
|
476
|
-
const i = n.match(/<formula[^>]*>([\s\S]*?)<\/formula>/);
|
|
477
|
-
if (!i) return r;
|
|
478
|
-
const u = i[1].replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").match(/SEARCH\s*\(\s*"([^"]*)"/i);
|
|
479
|
-
if (!u) return r;
|
|
480
|
-
const d = u[1].replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
481
|
-
return `<cfRule${e}type="containsText"${o} text="${d}">${n}</cfRule>`;
|
|
482
|
-
}
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
async function vt(t, r) {
|
|
486
|
-
var c;
|
|
487
|
-
const e = await dt.loadAsync(t), o = e.file("xl/styles.xml");
|
|
488
|
-
let n = o ? await o.async("text") : "", i = !1;
|
|
489
|
-
for (const [u, d] of Object.entries(e.files)) {
|
|
490
|
-
if (d.dir) continue;
|
|
491
|
-
const s = u.match(/^xl\/worksheets\/sheet(\d+)\.xml$/);
|
|
492
|
-
if (!s) continue;
|
|
493
|
-
const C = parseInt(s[1], 10) - 1;
|
|
494
|
-
let k = await d.async("text"), T = !1;
|
|
495
|
-
const x = St(k);
|
|
496
|
-
x !== k && (k = x, T = !0);
|
|
497
|
-
const E = ((c = r[C]) == null ? void 0 : c.duplicateValues) ?? [];
|
|
498
|
-
for (const F of E) {
|
|
499
|
-
const V = At(F.format), { xml: U, dxfId: J } = kt(n, V);
|
|
500
|
-
n = U, i = !0;
|
|
501
|
-
const Y = `<cfRule type="${F.type}" dxfId="${J}" priority="${F.priority}"/>`;
|
|
502
|
-
k = Ft(k, F.ref, Y), T = !0;
|
|
503
|
-
}
|
|
504
|
-
T && e.file(u, k);
|
|
505
|
-
}
|
|
506
|
-
return i && o && e.file("xl/styles.xml", n), e.generateAsync({ type: "arraybuffer", compression: "DEFLATE" });
|
|
507
|
-
}
|
|
508
|
-
const Mt = (t) => {
|
|
509
|
-
if (!t || typeof t != "string") return null;
|
|
510
|
-
const r = t.trim().toLowerCase();
|
|
511
|
-
if (r.startsWith("#")) {
|
|
512
|
-
const n = r.replace("#", "").toUpperCase();
|
|
513
|
-
return n.length === 3 ? n.split("").map((i) => i + i).join("").toUpperCase() : n.length === 6 ? n : null;
|
|
514
|
-
}
|
|
515
|
-
const e = /rgba?\s*\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+[\d.]+)?\s*\)/i, o = r.match(e);
|
|
516
|
-
if (o) {
|
|
517
|
-
const n = Math.min(255, Math.max(0, parseFloat(o[1]))), i = Math.min(255, Math.max(0, parseFloat(o[2]))), c = Math.min(255, Math.max(0, parseFloat(o[3])));
|
|
518
|
-
return ((1 << 24) + (n << 16) + (i << 8) + c).toString(16).slice(1).toUpperCase();
|
|
519
|
-
}
|
|
520
|
-
return null;
|
|
521
|
-
};
|
|
522
|
-
function Nt(t) {
|
|
523
|
-
const r = {};
|
|
524
|
-
if (t.bl === 1 && (r.bold = !0), t.it === 1 && (r.italic = !0), t.un === 1 && (r.underline = !0), t.cl === 1 && (r.strike = !0), t.fs && (r.size = Number(t.fs)), typeof t.ff == "string" && t.ff && (r.name = t.ff), t.fc) {
|
|
525
|
-
const e = Mt(t.fc);
|
|
526
|
-
e && (r.color = { argb: `FF${e}` });
|
|
527
|
-
}
|
|
528
|
-
return Object.keys(r).length > 0 ? r : void 0;
|
|
529
|
-
}
|
|
530
|
-
function ot(t) {
|
|
531
|
-
if (!Array.isArray(t) || t.length === 0) return null;
|
|
532
|
-
const r = [];
|
|
533
|
-
for (const e of t) {
|
|
534
|
-
const o = String(e.v ?? "");
|
|
535
|
-
if (o === "" && !e.bl && !e.it && !e.un && !e.cl) continue;
|
|
536
|
-
const n = Nt(e), i = { text: o };
|
|
537
|
-
n && (i.font = n), r.push(i);
|
|
538
|
-
}
|
|
539
|
-
return r.length === 0 || !r.some((e) => e.text !== "") ? null : { richText: r };
|
|
540
|
-
}
|
|
541
|
-
function Wt(t, r) {
|
|
542
|
-
r.forEach((e, o) => {
|
|
543
|
-
const n = t.getCell(o);
|
|
544
|
-
n.value = e;
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
const It = /* @__PURE__ */ new Set(["b", "n", "e", "s", "d", "z", "str"]);
|
|
548
|
-
function st(t, r) {
|
|
549
|
-
return t === "d" ? "n" : t === "inlineStr" || t === "g" ? "s" : typeof t == "string" && It.has(t) ? t : typeof r == "number" && Number.isFinite(r) ? "n" : typeof r == "boolean" ? "b" : r instanceof Date ? "d" : "s";
|
|
550
|
-
}
|
|
551
|
-
function _t(t) {
|
|
552
|
-
const r = st(t.t, t.v);
|
|
553
|
-
let e = t.v;
|
|
554
|
-
r === "s" && e != null && typeof e != "string" && (e = String(e));
|
|
555
|
-
const o = { t: r, v: e };
|
|
556
|
-
typeof t.f == "string" && t.f && (o.f = t.f), t.w != null && (o.w = t.w), typeof t.z == "string" && t.z && t.z !== "General" && (o.z = t.z), Object.keys(t).forEach((n) => {
|
|
557
|
-
delete t[n];
|
|
558
|
-
}), Object.assign(t, o);
|
|
559
|
-
}
|
|
560
|
-
function jt(t) {
|
|
561
|
-
delete t.sheetFormat, Object.keys(t).forEach((r) => {
|
|
562
|
-
if (r.startsWith("!")) return;
|
|
563
|
-
const e = t[r];
|
|
564
|
-
e && typeof e == "object" && _t(e);
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
function Bt(t) {
|
|
568
|
-
const r = t == null ? void 0 : t.filter, e = t == null ? void 0 : t.filter_select, o = !!(r && Object.keys(r).length > 0), n = !!e && (Array.isArray(e.row) || Array.isArray(e.column));
|
|
569
|
-
return o || n;
|
|
570
|
-
}
|
|
571
|
-
const Z = (t) => {
|
|
572
|
-
if (!t || typeof t != "string") return null;
|
|
573
|
-
const r = t.trim().toLowerCase();
|
|
574
|
-
if (r.startsWith("#")) {
|
|
575
|
-
const n = r.replace("#", "").toUpperCase();
|
|
576
|
-
return n.length === 3 ? n.split("").map((i) => i + i).join("").toUpperCase() : n.length === 6 ? n : null;
|
|
577
|
-
}
|
|
578
|
-
const e = /rgba?\s*\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+[\d.]+)?\s*\)/i, o = r.match(e);
|
|
579
|
-
if (o) {
|
|
580
|
-
const n = Math.min(255, Math.max(0, parseFloat(o[1]))), i = Math.min(255, Math.max(0, parseFloat(o[2]))), c = Math.min(255, Math.max(0, parseFloat(o[3])));
|
|
581
|
-
return ((1 << 24) + (n << 16) + (i << 8) + c).toString(16).slice(1).toUpperCase();
|
|
582
|
-
}
|
|
583
|
-
return null;
|
|
584
|
-
}, Ht = async (t, r, e, o) => at(
|
|
585
|
-
t,
|
|
586
|
-
r,
|
|
587
|
-
e,
|
|
588
|
-
o,
|
|
589
|
-
"xlsx"
|
|
590
|
-
), zt = async (t, r, e, o) => at(
|
|
591
|
-
t,
|
|
592
|
-
r,
|
|
593
|
-
e,
|
|
594
|
-
o,
|
|
595
|
-
"ods"
|
|
596
|
-
), at = async (t, r, e, o, n) => {
|
|
597
|
-
var i, c, u, d, s, C, k;
|
|
598
|
-
if (!(!t.current || !r.current))
|
|
599
|
-
try {
|
|
600
|
-
const T = (c = (i = t.current).getWorkbookContext) == null ? void 0 : c.call(i), x = T == null ? void 0 : T.luckysheetfile;
|
|
601
|
-
Array.isArray(x) && x.some(Bt) && rt({
|
|
602
|
-
title: "Filters are not supported in Export",
|
|
603
|
-
variant: "warning",
|
|
604
|
-
showCloseButton: !0,
|
|
605
|
-
duration: 30 * 1e3
|
|
606
|
-
}), r.current.getArray(e);
|
|
607
|
-
const F = t.current.getAllSheets();
|
|
608
|
-
F.forEach((m) => bt(m));
|
|
609
|
-
const V = S.book_new(), U = F.map(() => /* @__PURE__ */ new Map()), J = /* @__PURE__ */ new Set();
|
|
610
|
-
F.forEach((m, M) => {
|
|
611
|
-
var G, I, z, D, P;
|
|
612
|
-
const w = gt(m), h = S.aoa_to_sheet(w);
|
|
613
|
-
Object.keys(h).forEach((l) => {
|
|
614
|
-
if (l.startsWith("!")) return;
|
|
615
|
-
const g = h[l];
|
|
616
|
-
g && (g.t === "s" || g.t === void 0) && g.v !== "" && !isNaN(Number(g.v)) && (h[l] = { ...g, v: Number(g.v), t: "n" });
|
|
617
|
-
}), h["!merges"] = [], (G = m.config) != null && G.merge && Object.values(m.config.merge).forEach((l) => {
|
|
618
|
-
h["!merges"].push({
|
|
619
|
-
s: { r: l.r, c: l.c },
|
|
620
|
-
e: { r: l.r + l.rs - 1, c: l.c + l.cs - 1 }
|
|
621
|
-
});
|
|
622
|
-
});
|
|
623
|
-
{
|
|
624
|
-
const g = Math.round(3437.714285714286) / 256, f = m.column || 36;
|
|
625
|
-
h["!cols"] = [];
|
|
626
|
-
for (let a = 0; a < f; a++) {
|
|
627
|
-
const b = (z = (I = m.config) == null ? void 0 : I.columnlen) == null ? void 0 : z[a];
|
|
628
|
-
if (b !== void 0) {
|
|
629
|
-
const p = Math.max(
|
|
630
|
-
0,
|
|
631
|
-
Math.round((Number(b) - 5) / 7 * 256) / 256
|
|
632
|
-
);
|
|
633
|
-
h["!cols"][a] = { wch: p };
|
|
634
|
-
} else
|
|
635
|
-
h["!cols"][a] = { wch: g };
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
{
|
|
639
|
-
const l = Math.round(60.48) / 4;
|
|
640
|
-
h.sheetFormat = {
|
|
641
|
-
...h.sheetFormat || {},
|
|
642
|
-
defaultRowHeight: String(l)
|
|
643
|
-
}, (D = m.config) != null && D.rowlen && (h["!rows"] = [], Object.entries(m.config.rowlen).forEach(([g, f]) => {
|
|
644
|
-
const a = Math.round(Number(f) * 0.72 * 4) / 4;
|
|
645
|
-
h["!rows"][Number(g)] = { hpt: a };
|
|
646
|
-
}));
|
|
647
|
-
}
|
|
648
|
-
const O = /* @__PURE__ */ new Set();
|
|
649
|
-
(m.celldata ?? []).forEach((l) => {
|
|
650
|
-
var R, v, A, j, L;
|
|
651
|
-
const g = l.r, f = l.c, a = l.v || {}, b = S.encode_cell({ r: g, c: f });
|
|
652
|
-
let p = h[b] || {};
|
|
653
|
-
if (p = { ...p }, a.f && (p.f = a.f.replace(/^=/, "")), !a.f && ((R = a.ct) == null ? void 0 : R.t) === "inlineStr" && Array.isArray(a.ct.s) ? (p.v = X(a.ct.s), p.t = "s") : p.v = a.v ?? ((j = (A = (v = a == null ? void 0 : a.ct) == null ? void 0 : v.s) == null ? void 0 : A[0]) == null ? void 0 : j.v), a.m && (p.w = a.m), !a.f && ((L = a.ct) == null ? void 0 : L.t) === "inlineStr" && Array.isArray(a.ct.s)) {
|
|
654
|
-
const W = ot(a.ct.s);
|
|
655
|
-
W && U[M].set(b, W);
|
|
656
|
-
}
|
|
657
|
-
if (a.ct && (a.ct.fa && (p.z = a.ct.fa), a.ct.t && a.ct.t !== "inlineStr" && (p.t = st(a.ct.t, p.v))), typeof p.v == "number" && !p.t && (p.t = "n"), p.s = p.s || {}, a.bg) {
|
|
658
|
-
const W = Z(a.bg);
|
|
659
|
-
W && (p.s.fill = {
|
|
660
|
-
patternType: "solid",
|
|
661
|
-
fgColor: { rgb: W }
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
p.s.font = {
|
|
665
|
-
...p.s.font || {},
|
|
666
|
-
bold: a.bl === 1 || void 0,
|
|
667
|
-
italic: a.it === 1 || void 0,
|
|
668
|
-
strike: a.cl === 1 || void 0,
|
|
669
|
-
underline: a.un === 1 || void 0,
|
|
670
|
-
sz: a.fs ?? 10,
|
|
671
|
-
name: a.ff ?? void 0,
|
|
672
|
-
color: (() => {
|
|
673
|
-
const W = Z(a.fc);
|
|
674
|
-
return W ? { rgb: W } : void 0;
|
|
675
|
-
})()
|
|
676
|
-
};
|
|
677
|
-
const $ = { 0: "center", 1: "left", 2: "right" }, y = { 0: "center", 1: "top", 2: "bottom" };
|
|
678
|
-
p.s.alignment = {
|
|
679
|
-
...p.s.alignment || {},
|
|
680
|
-
wrapText: a.tb === "1" || a.tb === "2" ? !0 : void 0,
|
|
681
|
-
textRotation: a.tr !== void 0 ? a.tr : void 0
|
|
682
|
-
}, p.s.alignment.horizontal = $[a.ht] || void 0, p.s.alignment.vertical = y[a.vt] || void 0, a.tb !== void 0 && (p.s.alignment = p.s.alignment || {}, a.tb === "1" ? p.s.alignment.wrapText = !0 : a.tb === "2" && (p.s.alignment.shrinkToFit = !0)), O.add(b), h[b] = p;
|
|
683
|
-
}), w.forEach((l, g) => {
|
|
684
|
-
Array.isArray(l) && l.forEach((f, a) => {
|
|
685
|
-
if (!f || typeof f != "object") return;
|
|
686
|
-
const b = S.encode_cell({ r: g, c: a });
|
|
687
|
-
if (O.has(b)) return;
|
|
688
|
-
const p = !!f.f, $ = f.bg || f.bl || f.it || f.cl || f.un || f.fs || f.ff || f.fc || f.ht !== void 0 || f.vt !== void 0 || f.tb !== void 0 || f.tr !== void 0;
|
|
689
|
-
if (!p && !$) return;
|
|
690
|
-
const y = { ...h[b] || {} };
|
|
691
|
-
if (y.s = y.s || {}, p && (y.f = f.f.replace(/^=/, "")), f.bg) {
|
|
692
|
-
const A = Z(f.bg);
|
|
693
|
-
A && (y.s.fill = { patternType: "solid", fgColor: { rgb: A } });
|
|
694
|
-
}
|
|
695
|
-
y.s.font = {
|
|
696
|
-
...y.s.font || {},
|
|
697
|
-
bold: f.bl === 1 || void 0,
|
|
698
|
-
italic: f.it === 1 || void 0,
|
|
699
|
-
strike: f.cl === 1 || void 0,
|
|
700
|
-
underline: f.un === 1 || void 0,
|
|
701
|
-
sz: f.fs ?? 10,
|
|
702
|
-
name: f.ff ?? void 0,
|
|
703
|
-
color: (() => {
|
|
704
|
-
const A = Z(f.fc);
|
|
705
|
-
return A ? { rgb: A } : void 0;
|
|
706
|
-
})()
|
|
707
|
-
};
|
|
708
|
-
const R = { 0: "center", 1: "left", 2: "right" }, v = { 0: "center", 1: "top", 2: "bottom" };
|
|
709
|
-
y.s.alignment = {
|
|
710
|
-
...y.s.alignment || {},
|
|
711
|
-
horizontal: R[f.ht] || void 0,
|
|
712
|
-
vertical: v[f.vt] || void 0,
|
|
713
|
-
textRotation: f.tr !== void 0 ? f.tr : void 0
|
|
714
|
-
}, f.tb === "1" ? y.s.alignment.wrapText = !0 : f.tb === "2" && (y.s.alignment.shrinkToFit = !0), h[b] = y;
|
|
715
|
-
});
|
|
716
|
-
}), w.forEach((l, g) => {
|
|
717
|
-
Array.isArray(l) && l.forEach((f, a) => {
|
|
718
|
-
var y;
|
|
719
|
-
if (!f || ((y = f.ct) == null ? void 0 : y.t) !== "inlineStr" || !Array.isArray(f.ct.s)) return;
|
|
720
|
-
const b = S.encode_cell({ r: g, c: a }), p = X(f.ct.s);
|
|
721
|
-
h[b] = {
|
|
722
|
-
...h[b] || {},
|
|
723
|
-
v: p,
|
|
724
|
-
t: "s"
|
|
725
|
-
};
|
|
726
|
-
const $ = ot(f.ct.s);
|
|
727
|
-
$ && U[M].set(b, $);
|
|
728
|
-
});
|
|
729
|
-
}), (P = m.config) != null && P.borderInfo && Ct(h, m.config.borderInfo), Object.keys(h).forEach((l) => {
|
|
730
|
-
if (l.startsWith("!")) return;
|
|
731
|
-
const g = h[l];
|
|
732
|
-
g && g.s && g.t == null && g.v == null && g.f == null && (g.t = "s", g.v = "");
|
|
733
|
-
});
|
|
734
|
-
const N = m.name.length > 30 ? m.name.slice(0, 30) : m.name;
|
|
735
|
-
if (J.has(N)) {
|
|
736
|
-
const l = N !== m.name ? `"${m.name}" is too long and collides with another sheet after being shortened to "${N}"` : `Two sheets share the name "${m.name}"`;
|
|
737
|
-
throw new Error(
|
|
738
|
-
`${l}. Sheet names must be unique. Rename one and try again.`
|
|
739
|
-
);
|
|
740
|
-
}
|
|
741
|
-
J.add(N), n === "ods" && jt(h), S.book_append_sheet(V, h, N);
|
|
742
|
-
});
|
|
743
|
-
const Y = await (o == null ? void 0 : o(e)) || "Untitled";
|
|
744
|
-
if (n === "ods") {
|
|
745
|
-
const m = nt(V, {
|
|
746
|
-
bookType: "ods",
|
|
747
|
-
type: "array",
|
|
748
|
-
compression: !0
|
|
749
|
-
}), M = new Blob([m], {
|
|
750
|
-
type: "application/vnd.oasis.opendocument.spreadsheet"
|
|
751
|
-
}), w = URL.createObjectURL(M), h = document.createElement("a");
|
|
752
|
-
h.href = w, h.download = `${Y}.ods`, h.click(), URL.revokeObjectURL(w);
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
const it = nt(V, {
|
|
756
|
-
bookType: "xlsx",
|
|
757
|
-
type: "array",
|
|
758
|
-
compression: !0
|
|
759
|
-
}), B = new pt();
|
|
760
|
-
await B.xlsx.load(it);
|
|
761
|
-
const H = B.model;
|
|
762
|
-
(d = (u = H == null ? void 0 : H.styles) == null ? void 0 : u.fonts) != null && d[0] && (H.styles.fonts[0] = { ...H.styles.fonts[0], size: 10 });
|
|
763
|
-
const tt = F.map(() => ({
|
|
764
|
-
duplicateValues: []
|
|
765
|
-
}));
|
|
766
|
-
F.forEach((m, M) => {
|
|
767
|
-
const w = B.worksheets[M];
|
|
768
|
-
if (!w) return;
|
|
769
|
-
Wt(w, U[M]);
|
|
770
|
-
const h = m.data;
|
|
771
|
-
Object.entries(m.hyperlink || {}).forEach(([D, P]) => {
|
|
772
|
-
var R, v, A, j;
|
|
773
|
-
const l = ht(P);
|
|
774
|
-
if (!(l != null && l.linkAddress)) return;
|
|
775
|
-
const [g, f] = D.split("_").map(Number);
|
|
776
|
-
if (Number.isNaN(g) || Number.isNaN(f)) return;
|
|
777
|
-
const a = S.encode_cell({ r: g, c: f }), b = w.getCell(a), p = (R = h == null ? void 0 : h[g]) == null ? void 0 : R[f];
|
|
778
|
-
let $ = "";
|
|
779
|
-
p && typeof p == "object" && ((v = p.ct) == null ? void 0 : v.t) === "inlineStr" && Array.isArray(p.ct.s) && ($ = X(p.ct.s));
|
|
780
|
-
const y = $ || (typeof b.text == "string" && b.text.length > 0 ? b.text : ((A = b.value) == null ? void 0 : A.text) || (Array.isArray((j = b.value) == null ? void 0 : j.richText) ? b.value.richText.map((L) => L.text || "").join("") : "") || "");
|
|
781
|
-
b.value = {
|
|
782
|
-
text: y || l.linkAddress,
|
|
783
|
-
hyperlink: l.linkAddress
|
|
784
|
-
};
|
|
785
|
-
});
|
|
786
|
-
const { nextPriority: O, pendingDuplicateValues: N } = $t(w, m, 1);
|
|
787
|
-
tt[M] = { duplicateValues: N };
|
|
788
|
-
let G = O;
|
|
789
|
-
if (!m.dataVerification) return;
|
|
790
|
-
const I = w;
|
|
791
|
-
I.dataValidations || (I.dataValidations = { model: {} }), I.dataValidations.model || (I.dataValidations.model = {});
|
|
792
|
-
const z = I.dataValidations.model;
|
|
793
|
-
Object.entries(m.dataVerification).forEach(([D, P]) => {
|
|
794
|
-
const l = P;
|
|
795
|
-
if (l.type !== "dropdown" && l.type !== "checkbox") return;
|
|
796
|
-
const [g, f] = D.split("_").map(Number), a = S.encode_cell({ r: g, c: f });
|
|
797
|
-
if (l.type === "checkbox") {
|
|
798
|
-
const p = (l.value1 || "TRUE").trim(), $ = (l.value2 || "FALSE").trim(), y = [p, $].filter(Boolean);
|
|
799
|
-
z[a] = {
|
|
800
|
-
type: "list",
|
|
801
|
-
allowBlank: !0,
|
|
802
|
-
formulae: [`"${y.join(",")}"`],
|
|
803
|
-
showInputMessage: !!l.hintShow,
|
|
804
|
-
prompt: l.hintValue || "",
|
|
805
|
-
showErrorMessage: !!l.prohibitInput
|
|
806
|
-
};
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
const b = (l.value1 || "").split(",").map((p) => p.trim()).filter(Boolean);
|
|
810
|
-
if (b.length !== 0 && (z[a] = {
|
|
811
|
-
type: "list",
|
|
812
|
-
allowBlank: !0,
|
|
813
|
-
formulae: [`"${b.join(",")}"`],
|
|
814
|
-
showInputMessage: !!l.hintShow,
|
|
815
|
-
prompt: l.hintValue || "",
|
|
816
|
-
showErrorMessage: !!l.prohibitInput
|
|
817
|
-
}, l.color)) {
|
|
818
|
-
const p = l.color.split(",").map((R) => parseInt(R.trim(), 10)), $ = (R) => Math.max(0, Math.min(255, R)).toString(16).padStart(2, "0").toUpperCase(), y = b.map((R, v) => {
|
|
819
|
-
const A = p[v * 3], j = p[v * 3 + 1], L = p[v * 3 + 2];
|
|
820
|
-
if (isNaN(A) || isNaN(j) || isNaN(L)) return null;
|
|
821
|
-
const W = `FF${$(A)}${$(j)}${$(L)}`;
|
|
822
|
-
return {
|
|
823
|
-
type: "cellIs",
|
|
824
|
-
operator: "equal",
|
|
825
|
-
formulae: [`"${R}"`],
|
|
826
|
-
priority: G++,
|
|
827
|
-
style: {
|
|
828
|
-
fill: {
|
|
829
|
-
type: "pattern",
|
|
830
|
-
pattern: "solid",
|
|
831
|
-
fgColor: { argb: W }
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
};
|
|
835
|
-
}).filter(Boolean);
|
|
836
|
-
y.length > 0 && I.addConditionalFormatting({
|
|
837
|
-
ref: a,
|
|
838
|
-
rules: y
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
}), F.forEach((m, M) => {
|
|
843
|
-
var N;
|
|
844
|
-
if (!((N = m.images) != null && N.length)) return;
|
|
845
|
-
const w = B.worksheets[M];
|
|
846
|
-
if (!w) return;
|
|
847
|
-
const h = Number(m.defaultColWidth) || 99, O = Number(m.defaultRowHeight) || 21;
|
|
848
|
-
mt(
|
|
849
|
-
w,
|
|
850
|
-
B,
|
|
851
|
-
m.images,
|
|
852
|
-
m,
|
|
853
|
-
h,
|
|
854
|
-
O
|
|
855
|
-
);
|
|
856
|
-
});
|
|
857
|
-
const { applyDefinedNamesToExcelWorkbook: ct } = await import("./xlsx-defined-names-DCK7aKIO.js");
|
|
858
|
-
ct(
|
|
859
|
-
B,
|
|
860
|
-
(k = (C = (s = t.current).getWorkbookContext) == null ? void 0 : C.call(s)) == null ? void 0 : k.definedNames,
|
|
861
|
-
F
|
|
862
|
-
);
|
|
863
|
-
const lt = await B.xlsx.writeBuffer(), ft = await vt(lt, tt), ut = new Blob([ft], {
|
|
864
|
-
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
865
|
-
}), et = URL.createObjectURL(ut), Q = document.createElement("a");
|
|
866
|
-
Q.href = et, Q.download = `${Y}.xlsx`, Q.click(), URL.revokeObjectURL(et);
|
|
867
|
-
} catch (T) {
|
|
868
|
-
console.error("Export failed:", T), rt({
|
|
869
|
-
title: "Export failed",
|
|
870
|
-
description: T instanceof Error && T.message ? T.message : `Something went wrong while exporting to .${n}. Please try again.`,
|
|
871
|
-
variant: "error",
|
|
872
|
-
showCloseButton: !0,
|
|
873
|
-
duration: 10 * 1e3
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
export {
|
|
878
|
-
zt as handleExportToODS,
|
|
879
|
-
Ht as handleExportToXLSX
|
|
880
|
-
};
|