y11n-spreadsheet 1.0.2 → 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/README.md +64 -11
- package/dist/controllers/clipboard-manager.d.ts +0 -7
- package/dist/controllers/clipboard-manager.d.ts.map +1 -1
- package/dist/controllers/selection-manager.d.ts +57 -1
- package/dist/controllers/selection-manager.d.ts.map +1 -1
- package/dist/engine/formula-engine.d.ts +6 -0
- package/dist/engine/formula-engine.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +714 -244
- package/dist/types.d.ts +44 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/delimited.d.ts +40 -0
- package/dist/utils/delimited.d.ts.map +1 -0
- package/dist/y11n-spreadsheet.d.ts +76 -1
- package/dist/y11n-spreadsheet.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,64 +10,90 @@ function u(e, t) {
|
|
|
10
10
|
return n.length === r.length && n.every((n) => n === "numberFormat" ? d(e.numberFormat, t.numberFormat) : e[n] === t[n]);
|
|
11
11
|
}
|
|
12
12
|
function d(e, t) {
|
|
13
|
-
return e === t ? !0 : !e || !t ? !1 : e.type === t.type && e.decimals === t.decimals && e.currencySymbol === t.currencySymbol && e.thousandsSep === t.thousandsSep;
|
|
13
|
+
return e === t ? !0 : !e || !t ? !1 : e.type === t.type && e.decimals === t.decimals && e.currencySymbol === t.currencySymbol && e.thousandsSep === t.thousandsSep && e.datePattern === t.datePattern;
|
|
14
14
|
}
|
|
15
15
|
function f(e, t) {
|
|
16
16
|
let n = t.decimals ?? 2;
|
|
17
17
|
switch (t.type) {
|
|
18
|
-
case "percent": return
|
|
18
|
+
case "percent": return _((e * 100).toFixed(n)) + "%";
|
|
19
19
|
case "scientific": return e.toExponential(n);
|
|
20
20
|
case "currency": {
|
|
21
|
-
let r = t.currencySymbol ?? "$", i = t.thousandsSep !== !1, a = Math.abs(e), o = i ?
|
|
21
|
+
let r = t.currencySymbol ?? "$", i = t.thousandsSep !== !1, a = Math.abs(e), o = i ? v(a.toFixed(n)) : a.toFixed(n);
|
|
22
22
|
return e < 0 && parseFloat(o) !== 0 ? `-${r}${o}` : `${r}${o}`;
|
|
23
23
|
}
|
|
24
24
|
case "number": {
|
|
25
|
-
let r = t.thousandsSep !== !1, i =
|
|
26
|
-
return r ?
|
|
25
|
+
let r = t.thousandsSep !== !1, i = _(e.toFixed(n));
|
|
26
|
+
return r ? v(i) : i;
|
|
27
27
|
}
|
|
28
|
+
case "date": return ee(e, t.datePattern ?? "YYYY-MM-DD");
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
var p = Date.UTC(1899, 11, 30), m = 864e5;
|
|
32
|
+
function h(e) {
|
|
33
|
+
let t = Math.round(e * m);
|
|
34
|
+
return new Date(p + Math.floor(t / 1e3) * 1e3);
|
|
35
|
+
}
|
|
36
|
+
function g(e, t, n, r = 0, i = 0, a = 0) {
|
|
37
|
+
let o = /* @__PURE__ */ new Date(0);
|
|
38
|
+
return o.setUTCFullYear(e, t, n), o.setUTCHours(r, i, a, 0), (o.getTime() - p) / m;
|
|
39
|
+
}
|
|
40
|
+
function ee(e, t) {
|
|
41
|
+
if (!Number.isFinite(e)) return String(e);
|
|
42
|
+
let n = h(e), r = (e, t = 2) => String(e).padStart(t, "0"), i = {
|
|
43
|
+
YYYY: r(n.getUTCFullYear(), 4),
|
|
44
|
+
YY: r(n.getUTCFullYear() % 100),
|
|
45
|
+
MM: r(n.getUTCMonth() + 1),
|
|
46
|
+
M: String(n.getUTCMonth() + 1),
|
|
47
|
+
DD: r(n.getUTCDate()),
|
|
48
|
+
D: String(n.getUTCDate()),
|
|
49
|
+
HH: r(n.getUTCHours()),
|
|
50
|
+
H: String(n.getUTCHours()),
|
|
51
|
+
mm: r(n.getUTCMinutes()),
|
|
52
|
+
ss: r(n.getUTCSeconds())
|
|
53
|
+
};
|
|
54
|
+
return t.replace(/YYYY|YY|MM|M|DD|D|HH|H|mm|ss/g, (e) => i[e]);
|
|
55
|
+
}
|
|
56
|
+
function _(e) {
|
|
31
57
|
return e === "-0" || parseFloat(e) === 0 && e.startsWith("-") ? e.slice(1) : e;
|
|
32
58
|
}
|
|
33
|
-
function
|
|
59
|
+
function v(e) {
|
|
34
60
|
let [t, n] = e.split("."), r = t.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
35
61
|
return n === void 0 ? r : `${r}.${n}`;
|
|
36
62
|
}
|
|
37
|
-
function
|
|
63
|
+
function y(e, t) {
|
|
38
64
|
return `${e}:${t}`;
|
|
39
65
|
}
|
|
40
|
-
function
|
|
66
|
+
function b(e) {
|
|
41
67
|
let [t, n] = e.split(":").map(Number);
|
|
42
68
|
return {
|
|
43
69
|
row: t,
|
|
44
70
|
col: n
|
|
45
71
|
};
|
|
46
72
|
}
|
|
47
|
-
function
|
|
73
|
+
function x(e) {
|
|
48
74
|
let t = "", n = e;
|
|
49
75
|
for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
|
|
50
76
|
return t;
|
|
51
77
|
}
|
|
52
|
-
function
|
|
78
|
+
function S(e) {
|
|
53
79
|
let t = 0;
|
|
54
80
|
for (let n = 0; n < e.length; n++) t = t * 26 + (e.charCodeAt(n) - 64);
|
|
55
81
|
return t - 1;
|
|
56
82
|
}
|
|
57
|
-
function
|
|
83
|
+
function C(e) {
|
|
58
84
|
let t = e.replace(/\$/g, "").match(/^([A-Z]+)(\d+)$/i);
|
|
59
85
|
if (!t) throw Error(`Invalid cell reference: ${e}`);
|
|
60
|
-
let n =
|
|
86
|
+
let n = S(t[1].toUpperCase());
|
|
61
87
|
return {
|
|
62
88
|
row: parseInt(t[2], 10) - 1,
|
|
63
89
|
col: n
|
|
64
90
|
};
|
|
65
91
|
}
|
|
66
|
-
function
|
|
67
|
-
return `${
|
|
92
|
+
function w(e) {
|
|
93
|
+
return `${x(e.col)}${e.row + 1}`;
|
|
68
94
|
}
|
|
69
95
|
// src/controllers/selection-manager.ts
|
|
70
|
-
var
|
|
96
|
+
var T = class {
|
|
71
97
|
constructor(e, t, n) {
|
|
72
98
|
this.anchor = {
|
|
73
99
|
row: 0,
|
|
@@ -75,14 +101,14 @@ var x = class {
|
|
|
75
101
|
}, this.head = {
|
|
76
102
|
row: 0,
|
|
77
103
|
col: 0
|
|
78
|
-
}, this._isDragging = !1, this.host = e, this._maxRows = t, this._maxCols = n, e.addController(this);
|
|
104
|
+
}, this._active = null, this._isDragging = !1, this.host = e, this._maxRows = t, this._maxCols = n, e.addController(this);
|
|
79
105
|
}
|
|
80
106
|
hostConnected() {}
|
|
81
107
|
hostDisconnected() {
|
|
82
108
|
this._isDragging = !1;
|
|
83
109
|
}
|
|
84
110
|
setBounds(e, t) {
|
|
85
|
-
this._maxRows = e, this._maxCols = t, this.anchor = this.clamp(this.anchor), this.head = this.clamp(this.head);
|
|
111
|
+
this._maxRows = e, this._maxCols = t, this.anchor = this.clamp(this.anchor), this.head = this.clamp(this.head), this._active &&= this.clamp(this._active);
|
|
86
112
|
}
|
|
87
113
|
get range() {
|
|
88
114
|
return {
|
|
@@ -96,18 +122,22 @@ var x = class {
|
|
|
96
122
|
}
|
|
97
123
|
};
|
|
98
124
|
}
|
|
125
|
+
get activeOverride() {
|
|
126
|
+
return this._active ? { ...this._active } : null;
|
|
127
|
+
}
|
|
99
128
|
get activeCell() {
|
|
100
|
-
return { ...this.head };
|
|
129
|
+
return { ...this._active ?? this.head };
|
|
101
130
|
}
|
|
102
131
|
isCellSelected(e, t) {
|
|
103
132
|
let n = this.range;
|
|
104
133
|
return e >= n.start.row && e <= n.end.row && t >= n.start.col && t <= n.end.col;
|
|
105
134
|
}
|
|
106
135
|
isCellActive(e, t) {
|
|
107
|
-
|
|
136
|
+
let n = this._active ?? this.head;
|
|
137
|
+
return e === n.row && t === n.col;
|
|
108
138
|
}
|
|
109
139
|
startSelection(e, t, n = !1) {
|
|
110
|
-
if (n) this.head = this.clamp({
|
|
140
|
+
if (this._active = null, n) this.head = this.clamp({
|
|
111
141
|
row: e,
|
|
112
142
|
col: t
|
|
113
143
|
});
|
|
@@ -133,21 +163,24 @@ var x = class {
|
|
|
133
163
|
return this._isDragging;
|
|
134
164
|
}
|
|
135
165
|
move(e, t, n = !1) {
|
|
136
|
-
let r = this.clamp({
|
|
137
|
-
row:
|
|
138
|
-
col:
|
|
166
|
+
let r = n ? this.head : this.activeCell, i = this.clamp({
|
|
167
|
+
row: r.row + e,
|
|
168
|
+
col: r.col + t
|
|
139
169
|
});
|
|
140
|
-
this.head =
|
|
170
|
+
this.head = i, n || (this.anchor = { ...i }), this._syncActive(n), this.host.requestUpdate();
|
|
141
171
|
}
|
|
142
172
|
moveTo(e, t, n = !1) {
|
|
143
173
|
let r = this.clamp({
|
|
144
174
|
row: e,
|
|
145
175
|
col: t
|
|
146
176
|
});
|
|
147
|
-
this.head = r, n || (this.anchor = { ...r }), this.host.requestUpdate();
|
|
177
|
+
this.head = r, n || (this.anchor = { ...r }), this._syncActive(n), this.host.requestUpdate();
|
|
178
|
+
}
|
|
179
|
+
setSelection(e, t, n) {
|
|
180
|
+
this.anchor = this.clamp(e), this.head = this.clamp(t), this._active = n ? this.clamp(n) : null, this._syncActive(!0), this.host.requestUpdate();
|
|
148
181
|
}
|
|
149
182
|
selectAll() {
|
|
150
|
-
this.anchor = {
|
|
183
|
+
this._active = null, this.anchor = {
|
|
151
184
|
row: 0,
|
|
152
185
|
col: 0
|
|
153
186
|
}, this.head = {
|
|
@@ -155,8 +188,38 @@ var x = class {
|
|
|
155
188
|
col: this._maxCols - 1
|
|
156
189
|
}, this.host.requestUpdate();
|
|
157
190
|
}
|
|
191
|
+
selectColumns(e, t, n) {
|
|
192
|
+
let r = n ?? {
|
|
193
|
+
row: this.activeCell.row,
|
|
194
|
+
col: t
|
|
195
|
+
};
|
|
196
|
+
this.anchor = this.clamp({
|
|
197
|
+
row: 0,
|
|
198
|
+
col: e
|
|
199
|
+
}), this.head = this.clamp({
|
|
200
|
+
row: this._maxRows - 1,
|
|
201
|
+
col: t
|
|
202
|
+
}), this._active = this.clamp(r), this._syncActive(!0), this.host.requestUpdate();
|
|
203
|
+
}
|
|
204
|
+
selectRows(e, t, n) {
|
|
205
|
+
let r = n ?? {
|
|
206
|
+
row: t,
|
|
207
|
+
col: this.activeCell.col
|
|
208
|
+
};
|
|
209
|
+
this.anchor = this.clamp({
|
|
210
|
+
row: e,
|
|
211
|
+
col: 0
|
|
212
|
+
}), this.head = this.clamp({
|
|
213
|
+
row: t,
|
|
214
|
+
col: this._maxCols - 1
|
|
215
|
+
}), this._active = this.clamp(r), this._syncActive(!0), this.host.requestUpdate();
|
|
216
|
+
}
|
|
158
217
|
clearSelection() {
|
|
159
|
-
|
|
218
|
+
let e = this.activeCell;
|
|
219
|
+
this._active = null, this.anchor = { ...e }, this.head = { ...e }, this.host.requestUpdate();
|
|
220
|
+
}
|
|
221
|
+
_syncActive(e) {
|
|
222
|
+
this._active && (e && this.isCellSelected(this._active.row, this._active.col) || (this._active = null));
|
|
160
223
|
}
|
|
161
224
|
clamp(e) {
|
|
162
225
|
return {
|
|
@@ -164,21 +227,67 @@ var x = class {
|
|
|
164
227
|
col: Math.max(0, Math.min(e.col, this._maxCols - 1))
|
|
165
228
|
};
|
|
166
229
|
}
|
|
167
|
-
}
|
|
230
|
+
};
|
|
231
|
+
function te(e, t, n, r, i, a) {
|
|
232
|
+
let o = (e, t) => e >= 0 && e < r && t >= 0 && t < i, { row: s, col: c } = e;
|
|
233
|
+
if (!o(s + t, c + n)) return {
|
|
234
|
+
row: s,
|
|
235
|
+
col: c
|
|
236
|
+
};
|
|
237
|
+
if (a(s, c) && a(s + t, c + n)) {
|
|
238
|
+
for (; o(s + t, c + n) && a(s + t, c + n);) s += t, c += n;
|
|
239
|
+
return {
|
|
240
|
+
row: s,
|
|
241
|
+
col: c
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
for (s += t, c += n; !a(s, c) && o(s + t, c + n);) s += t, c += n;
|
|
245
|
+
return {
|
|
246
|
+
row: s,
|
|
247
|
+
col: c
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
// src/utils/delimited.ts
|
|
251
|
+
function E(e, t = ",") {
|
|
252
|
+
let n = [], r = [], i = "", a = !1, o = !1, s = +(e.charCodeAt(0) === 65279), c = () => {
|
|
253
|
+
r.push(i), i = "", o = !1, n.push(r), r = [];
|
|
254
|
+
};
|
|
255
|
+
for (; s < e.length;) {
|
|
256
|
+
let n = e[s];
|
|
257
|
+
a ? n === "\"" ? e[s + 1] === "\"" ? (i += "\"", s += 2) : (a = !1, s++) : (i += n, s++) : n === "\"" && i === "" && !o ? (a = !0, o = !0, s++) : n === t ? (r.push(i), i = "", o = !1, s++) : n === "\r" ? (c(), s += e[s + 1] === "\n" ? 2 : 1) : n === "\n" ? (c(), s++) : (i += n, s++);
|
|
258
|
+
}
|
|
259
|
+
return r.push(i), (r.length > 1 || r[0] !== "" || o) && n.push(r), n;
|
|
260
|
+
}
|
|
261
|
+
function D(e, t = ",") {
|
|
262
|
+
return e.includes(t) || e.includes("\"") || e.includes("\n") || e.includes("\r") ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
263
|
+
}
|
|
264
|
+
function O(e, t = ",") {
|
|
265
|
+
return e.map((e) => e.length === 1 && e[0] === "" ? "\"\"" : e.map((e) => D(e, t)).join(t)).join("\n");
|
|
266
|
+
}
|
|
267
|
+
// src/engine/formula-engine.ts
|
|
268
|
+
var k = 64, ne = /* @__PURE__ */ new Set([
|
|
168
269
|
"SUM",
|
|
169
270
|
"AVERAGE",
|
|
170
271
|
"MIN",
|
|
171
272
|
"MAX",
|
|
172
273
|
"COUNT",
|
|
173
274
|
"COUNTA",
|
|
174
|
-
"CONCAT"
|
|
175
|
-
|
|
275
|
+
"CONCAT",
|
|
276
|
+
"PRODUCT",
|
|
277
|
+
"MEDIAN"
|
|
278
|
+
]), re = /* @__PURE__ */ new Set(["NOW", "TODAY"]), ie = /* @__PURE__ */ new Set([
|
|
176
279
|
"SUM",
|
|
177
280
|
"AVERAGE",
|
|
178
281
|
"MIN",
|
|
179
282
|
"MAX",
|
|
180
|
-
"CONCAT"
|
|
181
|
-
|
|
283
|
+
"CONCAT",
|
|
284
|
+
"PRODUCT",
|
|
285
|
+
"MEDIAN"
|
|
286
|
+
]), ae = { XLOOKUP: 3 }, A = class {
|
|
287
|
+
constructor(e) {
|
|
288
|
+
this.code = e;
|
|
289
|
+
}
|
|
290
|
+
}, oe = 1e5, j = /* @__PURE__ */ new Set([
|
|
182
291
|
"#ERROR!",
|
|
183
292
|
"#REF!",
|
|
184
293
|
"#DIV/0!",
|
|
@@ -188,29 +297,29 @@ var x = class {
|
|
|
188
297
|
"#N/A",
|
|
189
298
|
"#NUM!"
|
|
190
299
|
]);
|
|
191
|
-
function
|
|
192
|
-
return typeof e == "string" &&
|
|
300
|
+
function M(e) {
|
|
301
|
+
return typeof e == "string" && j.has(e);
|
|
193
302
|
}
|
|
194
|
-
function
|
|
303
|
+
function N(e) {
|
|
195
304
|
let t = e instanceof Error ? e.message : "";
|
|
196
305
|
return t.startsWith("#") ? t : "#ERROR!";
|
|
197
306
|
}
|
|
198
|
-
function
|
|
307
|
+
function se(e) {
|
|
199
308
|
let t = e.toUpperCase();
|
|
200
|
-
return [...
|
|
309
|
+
return [...re].some((e) => t.includes(e + "("));
|
|
201
310
|
}
|
|
202
|
-
function
|
|
311
|
+
function P(e) {
|
|
203
312
|
if (typeof e == "number") return e;
|
|
204
313
|
if (typeof e == "boolean") return +!!e;
|
|
205
314
|
if (e == null || e === "") return 0;
|
|
206
315
|
if (typeof e == "string") {
|
|
207
|
-
if (
|
|
316
|
+
if (j.has(e)) throw Error(e);
|
|
208
317
|
let t = Number(e);
|
|
209
318
|
if (e.trim() !== "" && !isNaN(t)) return t;
|
|
210
319
|
}
|
|
211
320
|
throw Error("#VALUE!");
|
|
212
321
|
}
|
|
213
|
-
function
|
|
322
|
+
function F(e, t) {
|
|
214
323
|
let n = (e) => typeof e == "number" || typeof e == "string" && e.trim() !== "" && !isNaN(Number(e));
|
|
215
324
|
if (e === void 0 || t === void 0) return NaN;
|
|
216
325
|
if (n(e) && n(t)) return Number(e) - Number(t);
|
|
@@ -218,10 +327,10 @@ function M(e, t) {
|
|
|
218
327
|
let r = String(e).toLowerCase(), i = String(t).toLowerCase();
|
|
219
328
|
return r < i ? -1 : +(r > i);
|
|
220
329
|
}
|
|
221
|
-
function
|
|
330
|
+
function I(e, t) {
|
|
222
331
|
let n = -1;
|
|
223
332
|
for (let r = 0; r < e.length; r++) {
|
|
224
|
-
let i =
|
|
333
|
+
let i = F(e[r], t);
|
|
225
334
|
if (!isNaN(i)) {
|
|
226
335
|
if (i > 0) break;
|
|
227
336
|
n = r;
|
|
@@ -229,11 +338,11 @@ function N(e, t) {
|
|
|
229
338
|
}
|
|
230
339
|
return n;
|
|
231
340
|
}
|
|
232
|
-
var
|
|
341
|
+
var L = class extends Error {
|
|
233
342
|
constructor(e) {
|
|
234
343
|
super("#ERROR!"), this.key = e;
|
|
235
344
|
}
|
|
236
|
-
},
|
|
345
|
+
}, R = class {
|
|
237
346
|
constructor(e, t, n) {
|
|
238
347
|
this.values = e, this.rows = t, this.cols = n;
|
|
239
348
|
}
|
|
@@ -250,15 +359,15 @@ var P = class extends Error {
|
|
|
250
359
|
return t;
|
|
251
360
|
}
|
|
252
361
|
};
|
|
253
|
-
function
|
|
362
|
+
function z(e, t) {
|
|
254
363
|
let n = "=", r = t;
|
|
255
364
|
t.startsWith("<>") ? (n = "<>", r = t.substring(2)) : t.startsWith(">=") ? (n = ">=", r = t.substring(2)) : t.startsWith("<=") ? (n = "<=", r = t.substring(2)) : t.startsWith(">") ? (n = ">", r = t.substring(1)) : t.startsWith("<") ? (n = "<", r = t.substring(1)) : t.startsWith("=") && (n = "=", r = t.substring(1));
|
|
256
365
|
let i = Number(r), a = Number(e), o = !isNaN(i) && r.trim() !== "", s = !isNaN(a) && String(e).trim() !== "", c = o && s;
|
|
257
366
|
if (n !== "=" && n !== "<>" && o !== s) return !1;
|
|
258
|
-
let l = String(e).toLowerCase(), u = r.toLowerCase();
|
|
367
|
+
let l = String(e).toLowerCase(), u = r.toLowerCase(), d = (n === "=" || n === "<>") && !c ? ce(r) : null, f = () => typeof e == "string" && !M(e) && le(d, e);
|
|
259
368
|
switch (n) {
|
|
260
|
-
case "=": return c ? a === i : l === u;
|
|
261
|
-
case "<>": return c ? a !== i : l !== u;
|
|
369
|
+
case "=": return c ? a === i : d ? f() : l === u;
|
|
370
|
+
case "<>": return c ? a !== i : d ? !f() : l !== u;
|
|
262
371
|
case ">": return c ? a > i : l > u;
|
|
263
372
|
case "<": return c ? a < i : l < u;
|
|
264
373
|
case ">=": return c ? a >= i : l >= u;
|
|
@@ -266,7 +375,68 @@ function I(e, t) {
|
|
|
266
375
|
default: return !1;
|
|
267
376
|
}
|
|
268
377
|
}
|
|
269
|
-
|
|
378
|
+
function ce(e) {
|
|
379
|
+
if (!/[*?~]/.test(e)) return null;
|
|
380
|
+
let t = [], n = [...e];
|
|
381
|
+
for (let e = 0; e < n.length; e++) {
|
|
382
|
+
let r = n[e];
|
|
383
|
+
r === "~" && e + 1 < n.length && "*?~".includes(n[e + 1]) ? t.push({
|
|
384
|
+
kind: "lit",
|
|
385
|
+
ch: n[++e].toLowerCase()
|
|
386
|
+
}) : r === "*" ? t[t.length - 1]?.kind !== "star" && t.push({ kind: "star" }) : r === "?" ? t.push({ kind: "any" }) : t.push({
|
|
387
|
+
kind: "lit",
|
|
388
|
+
ch: r.toLowerCase()
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
return t;
|
|
392
|
+
}
|
|
393
|
+
function le(e, t) {
|
|
394
|
+
let n = [...t], r = 0, i = 0, a = -1, o = 0;
|
|
395
|
+
for (; i < n.length;) {
|
|
396
|
+
let t = e[r];
|
|
397
|
+
if (t && (t.kind === "any" || t.kind === "lit" && t.ch === n[i].toLowerCase())) r++, i++;
|
|
398
|
+
else if (t && t.kind === "star") a = r++, o = i;
|
|
399
|
+
else if (a !== -1) r = a + 1, i = ++o;
|
|
400
|
+
else return !1;
|
|
401
|
+
}
|
|
402
|
+
for (; e[r]?.kind === "star";) r++;
|
|
403
|
+
return r === e.length;
|
|
404
|
+
}
|
|
405
|
+
function ue(e, t) {
|
|
406
|
+
return e === void 0 ? t === "" || t === "=" : z(e, t);
|
|
407
|
+
}
|
|
408
|
+
function B(e) {
|
|
409
|
+
return e instanceof R ? [e.rows, e.cols] : Array.isArray(e) ? [e.length, 1] : [1, 1];
|
|
410
|
+
}
|
|
411
|
+
function V(e) {
|
|
412
|
+
return e instanceof R ? e.values : Array.isArray(e) ? e : [e];
|
|
413
|
+
}
|
|
414
|
+
function H(e, t) {
|
|
415
|
+
if (e.length === 0 || e.length % 2 != 0) throw Error("#VALUE!");
|
|
416
|
+
let [n, r] = B(t), i = n * r, a = Array(i).fill(!0);
|
|
417
|
+
for (let t = 0; t < e.length; t += 2) {
|
|
418
|
+
let o = V(e[t]), [s, c] = B(e[t]);
|
|
419
|
+
if (s !== n || c !== r) throw Error("#VALUE!");
|
|
420
|
+
let l = String(e[t + 1]);
|
|
421
|
+
for (let e = 0; e < i; e++) a[e] && !ue(o[e], l) && (a[e] = !1);
|
|
422
|
+
}
|
|
423
|
+
return a;
|
|
424
|
+
}
|
|
425
|
+
function U(e) {
|
|
426
|
+
let t = [];
|
|
427
|
+
for (let n of e) typeof n == "number" ? t.push(n) : typeof n == "string" && n.trim() !== "" && !isNaN(Number(n)) && t.push(Number(n));
|
|
428
|
+
return t;
|
|
429
|
+
}
|
|
430
|
+
function W(e, t, n) {
|
|
431
|
+
let r = 10 ** t, i = parseFloat((Math.abs(e) * r).toPrecision(15));
|
|
432
|
+
return Math.sign(e) * n(i) / r;
|
|
433
|
+
}
|
|
434
|
+
function G(e) {
|
|
435
|
+
let t = P(e);
|
|
436
|
+
if (t < 0) throw Error("#NUM!");
|
|
437
|
+
return h(Math.floor(t));
|
|
438
|
+
}
|
|
439
|
+
var K = class {
|
|
270
440
|
constructor() {
|
|
271
441
|
this._functions = /* @__PURE__ */ new Map(), this._builtinFunctionNames = /* @__PURE__ */ new Set(), this._data = /* @__PURE__ */ new Map(), this._evaluating = /* @__PURE__ */ new Set(), this._evalDepth = 0, this._deps = /* @__PURE__ */ new Map(), this._reverseDeps = /* @__PURE__ */ new Map(), this._trackingCellKey = null, this._cache = /* @__PURE__ */ new Map(), this._memo = null, this.registerBuiltins(), this._builtinFunctionNames = new Set(this._functions.keys());
|
|
272
442
|
}
|
|
@@ -302,7 +472,7 @@ var L = class {
|
|
|
302
472
|
if (r === null) return this._evaluateTopLevel(e, t);
|
|
303
473
|
this._evaluateFormulaCell(r, this._data.get(r)?.rawValue ?? ""), n.pop();
|
|
304
474
|
} catch (e) {
|
|
305
|
-
if (!(e instanceof
|
|
475
|
+
if (!(e instanceof L)) {
|
|
306
476
|
n.pop();
|
|
307
477
|
continue;
|
|
308
478
|
}
|
|
@@ -312,7 +482,7 @@ var L = class {
|
|
|
312
482
|
n.length = t;
|
|
313
483
|
continue;
|
|
314
484
|
}
|
|
315
|
-
if (n.length >=
|
|
485
|
+
if (n.length >= oe) return {
|
|
316
486
|
displayValue: "#ERROR!",
|
|
317
487
|
type: "error"
|
|
318
488
|
};
|
|
@@ -336,7 +506,7 @@ var L = class {
|
|
|
336
506
|
type: "text"
|
|
337
507
|
};
|
|
338
508
|
if (!e.startsWith("=")) return t && (this._clearDepsFor(t), this._cache.delete(t)), this.coerceValue(e);
|
|
339
|
-
let n =
|
|
509
|
+
let n = se(e);
|
|
340
510
|
if (t && !n) {
|
|
341
511
|
let n = this._cache.get(t);
|
|
342
512
|
if (n && n.rawValue === e) return {
|
|
@@ -353,9 +523,9 @@ var L = class {
|
|
|
353
523
|
rawValue: e
|
|
354
524
|
})), o;
|
|
355
525
|
} catch (r) {
|
|
356
|
-
if (r instanceof
|
|
526
|
+
if (r instanceof L) throw r;
|
|
357
527
|
let i = {
|
|
358
|
-
displayValue:
|
|
528
|
+
displayValue: N(r),
|
|
359
529
|
type: "error"
|
|
360
530
|
};
|
|
361
531
|
return t && (this._memo?.set(t, { error: i.displayValue }), n || this._cache.set(t, {
|
|
@@ -379,13 +549,13 @@ var L = class {
|
|
|
379
549
|
} : typeof e == "boolean" ? {
|
|
380
550
|
displayValue: e ? "TRUE" : "FALSE",
|
|
381
551
|
type: "boolean"
|
|
382
|
-
} : typeof e == "string" ?
|
|
552
|
+
} : typeof e == "string" ? M(e) ? {
|
|
383
553
|
displayValue: e,
|
|
384
554
|
type: "error"
|
|
385
555
|
} : {
|
|
386
556
|
displayValue: e,
|
|
387
557
|
type: "text"
|
|
388
|
-
} : e instanceof
|
|
558
|
+
} : e instanceof R ? {
|
|
389
559
|
displayValue: "#VALUE!",
|
|
390
560
|
type: "error"
|
|
391
561
|
} : e == null ? {
|
|
@@ -584,7 +754,7 @@ var L = class {
|
|
|
584
754
|
return e.pos++, n;
|
|
585
755
|
}
|
|
586
756
|
parseExpression(e) {
|
|
587
|
-
if (++this._evalDepth >
|
|
757
|
+
if (++this._evalDepth > k) throw this._evalDepth--, Error("#ERROR!");
|
|
588
758
|
try {
|
|
589
759
|
let t = {
|
|
590
760
|
tokens: this.tokenize(e),
|
|
@@ -624,7 +794,7 @@ var L = class {
|
|
|
624
794
|
let t = this._parseMulDiv(e);
|
|
625
795
|
for (; this._peek(e).type === "OPERATOR" && (this._peek(e).value === "+" || this._peek(e).value === "-");) {
|
|
626
796
|
let n = this._consume(e).value, r = this._parseMulDiv(e);
|
|
627
|
-
t = n === "+" ?
|
|
797
|
+
t = n === "+" ? P(t) + P(r) : P(t) - P(r);
|
|
628
798
|
}
|
|
629
799
|
return t;
|
|
630
800
|
}
|
|
@@ -632,9 +802,9 @@ var L = class {
|
|
|
632
802
|
let t = this._parseUnary(e);
|
|
633
803
|
for (; this._peek(e).type === "OPERATOR" && (this._peek(e).value === "*" || this._peek(e).value === "/");) {
|
|
634
804
|
let n = this._consume(e).value, r = this._parseUnary(e);
|
|
635
|
-
if (n === "*") t =
|
|
805
|
+
if (n === "*") t = P(t) * P(r);
|
|
636
806
|
else {
|
|
637
|
-
let e =
|
|
807
|
+
let e = P(t), n = P(r);
|
|
638
808
|
if (n === 0) throw Error("#DIV/0!");
|
|
639
809
|
t = e / n;
|
|
640
810
|
}
|
|
@@ -642,7 +812,7 @@ var L = class {
|
|
|
642
812
|
return t;
|
|
643
813
|
}
|
|
644
814
|
_parseUnary(e) {
|
|
645
|
-
return this._peek(e).type === "OPERATOR" && this._peek(e).value === "-" ? (this._consume(e), -
|
|
815
|
+
return this._peek(e).type === "OPERATOR" && this._peek(e).value === "-" ? (this._consume(e), -P(this._parseUnary(e))) : this._peek(e).type === "OPERATOR" && this._peek(e).value === "+" ? (this._consume(e), P(this._parseUnary(e))) : this._parsePrimary(e);
|
|
646
816
|
}
|
|
647
817
|
_parsePrimary(e) {
|
|
648
818
|
let t = this._peek(e);
|
|
@@ -664,39 +834,64 @@ var L = class {
|
|
|
664
834
|
let t = this._consume(e, "FUNC").value;
|
|
665
835
|
if (this._consume(e, "LPAREN"), t === "IFERROR") return this._parseIFERROR(e);
|
|
666
836
|
if (t === "IF") return this._parseIF(e);
|
|
667
|
-
|
|
668
|
-
|
|
837
|
+
if (t === "IFS") return this._parseIFS(e);
|
|
838
|
+
let n = ae[t], r = () => {
|
|
839
|
+
let t = this._peek(e).type;
|
|
840
|
+
if (t === "COMMA" || t === "RPAREN") return;
|
|
841
|
+
if (i.length !== n) return this._parseComparison(e);
|
|
842
|
+
let r = e.pos;
|
|
843
|
+
try {
|
|
844
|
+
return this._parseComparison(e);
|
|
845
|
+
} catch (t) {
|
|
846
|
+
if (t instanceof L) throw t;
|
|
847
|
+
return e.pos = r, this._skipArgument(e), new A(N(t));
|
|
848
|
+
}
|
|
849
|
+
}, i = [];
|
|
850
|
+
if (this._peek(e).type !== "RPAREN") for (i.push(r()); this._peek(e).type === "COMMA";) this._consume(e), i.push(r());
|
|
669
851
|
this._consume(e, "RPAREN");
|
|
670
|
-
let
|
|
671
|
-
if (!
|
|
672
|
-
let
|
|
673
|
-
if (
|
|
852
|
+
let a = this._functions.get(t);
|
|
853
|
+
if (!a) throw Error("#NAME?");
|
|
854
|
+
let o = this._createContext();
|
|
855
|
+
if (ne.has(t)) {
|
|
674
856
|
let e = [];
|
|
675
|
-
for (let t of
|
|
857
|
+
for (let t of i) if (t instanceof R) for (let n of t.values) n !== void 0 && e.push(n);
|
|
676
858
|
else Array.isArray(t) ? e.push(...t) : e.push(t);
|
|
677
|
-
if (
|
|
678
|
-
let t = e.find(
|
|
859
|
+
if (ie.has(t)) {
|
|
860
|
+
let t = e.find(M);
|
|
679
861
|
if (t !== void 0) throw Error(t);
|
|
680
862
|
}
|
|
681
|
-
return
|
|
863
|
+
return a(o, ...e) ?? 0;
|
|
682
864
|
}
|
|
683
|
-
return
|
|
865
|
+
return a(o, ...i) ?? 0;
|
|
684
866
|
}
|
|
685
867
|
_parseIFERROR(e) {
|
|
686
868
|
let t = e.pos, n, r = !1;
|
|
687
869
|
try {
|
|
688
870
|
n = this._parseComparison(e);
|
|
689
871
|
} catch (n) {
|
|
690
|
-
if (n instanceof
|
|
872
|
+
if (n instanceof L) throw n;
|
|
691
873
|
r = !0, e.pos = t, this._skipArgument(e);
|
|
692
874
|
}
|
|
693
875
|
let i = "";
|
|
694
|
-
return this._peek(e).type === "COMMA" && (this._consume(e), i = this._parseComparison(e)), this._consume(e, "RPAREN"), r ||
|
|
876
|
+
return this._peek(e).type === "COMMA" && (this._consume(e), i = this._parseComparison(e)), this._consume(e, "RPAREN"), r || M(n) ? i : n;
|
|
695
877
|
}
|
|
696
878
|
_parseIF(e) {
|
|
697
879
|
let t = this._parseComparison(e), n = t ? 0 : !1;
|
|
698
880
|
return this._peek(e).type === "COMMA" && (this._consume(e), t ? n = this._parseComparison(e) : this._skipArgument(e), this._peek(e).type === "COMMA" && (this._consume(e), t ? this._skipArgument(e) : n = this._parseComparison(e))), this._consume(e, "RPAREN"), n;
|
|
699
881
|
}
|
|
882
|
+
_parseIFS(e) {
|
|
883
|
+
let t = !1, n;
|
|
884
|
+
for (;;) {
|
|
885
|
+
let r = !1;
|
|
886
|
+
if (t) this._skipArgument(e);
|
|
887
|
+
else if (r = this._parseComparison(e), M(r)) throw Error(r);
|
|
888
|
+
if (this._peek(e).type !== "COMMA") throw Error("#VALUE!");
|
|
889
|
+
if (this._consume(e), !t && r ? (n = this._parseComparison(e), t = !0) : this._skipArgument(e), this._peek(e).type !== "COMMA") break;
|
|
890
|
+
this._consume(e);
|
|
891
|
+
}
|
|
892
|
+
if (this._consume(e, "RPAREN"), !t) throw Error("#N/A");
|
|
893
|
+
return n;
|
|
894
|
+
}
|
|
700
895
|
_skipArgument(e) {
|
|
701
896
|
let t = 0;
|
|
702
897
|
for (; this._peek(e).type !== "EOF";) {
|
|
@@ -739,7 +934,7 @@ var L = class {
|
|
|
739
934
|
}
|
|
740
935
|
}
|
|
741
936
|
_resolveRef(e) {
|
|
742
|
-
let t =
|
|
937
|
+
let t = C(e.replace(/\$/g, "")), n = y(t.row, t.col);
|
|
743
938
|
if (this._trackDep(n), this._evaluating.has(n)) throw Error("#CIRC!");
|
|
744
939
|
let r = this._data.get(n);
|
|
745
940
|
if (!r) return 0;
|
|
@@ -754,31 +949,31 @@ var L = class {
|
|
|
754
949
|
if (n.error !== void 0) throw Error(n.error);
|
|
755
950
|
return n.value;
|
|
756
951
|
}
|
|
757
|
-
if (this._evalDepth >=
|
|
952
|
+
if (this._evalDepth >= k) throw new L(e);
|
|
758
953
|
this._evaluating.add(e);
|
|
759
954
|
try {
|
|
760
955
|
let n = this.parseExpression(t.substring(1));
|
|
761
956
|
return this._memo?.set(e, { value: n }), n;
|
|
762
957
|
} catch (t) {
|
|
763
|
-
if (t instanceof
|
|
764
|
-
let n =
|
|
958
|
+
if (t instanceof L) throw t;
|
|
959
|
+
let n = N(t);
|
|
765
960
|
throw this._memo?.set(e, { error: n }), Error(n);
|
|
766
961
|
} finally {
|
|
767
962
|
this._evaluating.delete(e);
|
|
768
963
|
}
|
|
769
964
|
}
|
|
770
965
|
_resolveRange(e) {
|
|
771
|
-
let [t, n] = e.split(":"), r =
|
|
966
|
+
let [t, n] = e.split(":"), r = C(t.replace(/\$/g, "")), i = C(n.replace(/\$/g, "")), a = Math.min(r.row, i.row), o = Math.max(r.row, i.row), s = Math.min(r.col, i.col), c = Math.max(r.col, i.col), l = o - a + 1, u = c - s + 1, d = [];
|
|
772
967
|
for (let e = a; e <= o; e++) for (let t = s; t <= c; t++) {
|
|
773
|
-
let n =
|
|
968
|
+
let n = y(e, t);
|
|
774
969
|
this._trackDep(n);
|
|
775
970
|
let r = this._data.get(n);
|
|
776
971
|
if (r) {
|
|
777
972
|
if (r.rawValue.startsWith("=")) try {
|
|
778
973
|
d.push(this._evaluateFormulaCell(n, r.rawValue));
|
|
779
974
|
} catch (e) {
|
|
780
|
-
if (e instanceof
|
|
781
|
-
d.push(
|
|
975
|
+
if (e instanceof L) throw e;
|
|
976
|
+
d.push(N(e));
|
|
782
977
|
}
|
|
783
978
|
else if (r.rawValue === "") d.push(void 0);
|
|
784
979
|
else {
|
|
@@ -787,7 +982,7 @@ var L = class {
|
|
|
787
982
|
}
|
|
788
983
|
} else d.push(void 0);
|
|
789
984
|
}
|
|
790
|
-
return new
|
|
985
|
+
return new R(d, l, u);
|
|
791
986
|
}
|
|
792
987
|
_createContext() {
|
|
793
988
|
return {
|
|
@@ -801,9 +996,9 @@ var L = class {
|
|
|
801
996
|
return this._resolveRef(e);
|
|
802
997
|
},
|
|
803
998
|
getRangeValues: (e, t) => {
|
|
804
|
-
let n =
|
|
999
|
+
let n = C(e), r = C(t), i = Math.min(n.row, r.row), a = Math.max(n.row, r.row), o = Math.min(n.col, r.col), s = Math.max(n.col, r.col), c = [];
|
|
805
1000
|
for (let e = i; e <= a; e++) for (let t = o; t <= s; t++) {
|
|
806
|
-
let n =
|
|
1001
|
+
let n = y(e, t), r = this._data.get(n);
|
|
807
1002
|
if (r) {
|
|
808
1003
|
let e = Number(r.rawValue);
|
|
809
1004
|
c.push(!isNaN(e) && r.rawValue.trim() !== "" ? e : r.rawValue);
|
|
@@ -831,39 +1026,102 @@ var L = class {
|
|
|
831
1026
|
let r = String(t);
|
|
832
1027
|
return r === "#ERROR!" || r === "#REF!" || r === "#DIV/0!" || r === "#NAME?" || r === "#CIRC!" || r === "#VALUE!" || r === "#N/A" ? n : t;
|
|
833
1028
|
}), this.registerFunction("AND", (e, ...t) => {
|
|
834
|
-
for (let e of t) if (e instanceof
|
|
1029
|
+
for (let e of t) if (e instanceof R) {
|
|
835
1030
|
for (let t of e.values) if (t !== void 0 && !t) return !1;
|
|
836
1031
|
} else if (!e) return !1;
|
|
837
1032
|
return !0;
|
|
838
1033
|
}), this.registerFunction("OR", (e, ...t) => {
|
|
839
|
-
for (let e of t) if (e instanceof
|
|
1034
|
+
for (let e of t) if (e instanceof R) {
|
|
840
1035
|
for (let t of e.values) if (t !== void 0 && t) return !0;
|
|
841
1036
|
} else if (e) return !0;
|
|
842
1037
|
return !1;
|
|
843
1038
|
}), this.registerFunction("NOT", (e, t) => !t), this.registerFunction("SUMIF", (e, t, n, r) => {
|
|
844
|
-
let i = String(n), a = t instanceof
|
|
1039
|
+
let i = String(n), a = t instanceof R ? t.values : Array.isArray(t) ? t : [t], o = r instanceof R ? r.values : Array.isArray(r) ? r : void 0, s = 0;
|
|
845
1040
|
for (let e = 0; e < a.length; e++) {
|
|
846
1041
|
let t = a[e];
|
|
847
|
-
(t === void 0 ? i === "" || i === "=" :
|
|
1042
|
+
(t === void 0 ? i === "" || i === "=" : z(t, i)) && (s += o ? Number(o[e]) || 0 : Number(t) || 0);
|
|
848
1043
|
}
|
|
849
1044
|
return s;
|
|
850
1045
|
}), this.registerFunction("COUNTIF", (e, t, n) => {
|
|
851
|
-
let r = String(n), i = t instanceof
|
|
852
|
-
for (let e of i) e === void 0 ? (r === "" || r === "=") && a++ :
|
|
1046
|
+
let r = String(n), i = t instanceof R ? t.values : Array.isArray(t) ? t : [t], a = 0;
|
|
1047
|
+
for (let e of i) e === void 0 ? (r === "" || r === "=") && a++ : z(e, r) && a++;
|
|
853
1048
|
return a;
|
|
854
1049
|
}), this.registerFunction("AVERAGEIF", (e, t, n, r) => {
|
|
855
|
-
let i = String(n), a = t instanceof
|
|
1050
|
+
let i = String(n), a = t instanceof R ? t.values : Array.isArray(t) ? t : [t], o = r instanceof R ? r.values : Array.isArray(r) ? r : void 0, s = 0, c = 0;
|
|
856
1051
|
for (let e = 0; e < a.length; e++) {
|
|
857
1052
|
let t = a[e];
|
|
858
|
-
if (t !== void 0 &&
|
|
1053
|
+
if (t !== void 0 && z(t, i)) {
|
|
859
1054
|
let n = Number(o ? o[e] : t);
|
|
860
1055
|
isNaN(n) || (s += n, c++);
|
|
861
1056
|
}
|
|
862
1057
|
}
|
|
863
1058
|
if (c === 0) throw Error("#DIV/0!");
|
|
864
1059
|
return s / c;
|
|
1060
|
+
}), this.registerFunction("SUMIFS", (e, t, ...n) => {
|
|
1061
|
+
let r = V(t), i = H(n, t), a = 0;
|
|
1062
|
+
for (let e = 0; e < r.length; e++) {
|
|
1063
|
+
if (!i[e]) continue;
|
|
1064
|
+
let t = r[e];
|
|
1065
|
+
if (M(t)) throw Error(t);
|
|
1066
|
+
typeof t == "number" && (a += t);
|
|
1067
|
+
}
|
|
1068
|
+
return a;
|
|
1069
|
+
}), this.registerFunction("COUNTIFS", (e, ...t) => {
|
|
1070
|
+
if (t.length === 0) throw Error("#VALUE!");
|
|
1071
|
+
return H(t, t[0]).filter(Boolean).length;
|
|
1072
|
+
}), this.registerFunction("AVERAGEIFS", (e, t, ...n) => {
|
|
1073
|
+
let r = V(t), i = H(n, t), a = 0, o = 0;
|
|
1074
|
+
for (let e = 0; e < r.length; e++) {
|
|
1075
|
+
let t = r[e];
|
|
1076
|
+
if (i[e]) {
|
|
1077
|
+
if (M(t)) throw Error(t);
|
|
1078
|
+
typeof t == "number" && (a += t, o++);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
if (o === 0) throw Error("#DIV/0!");
|
|
1082
|
+
return a / o;
|
|
1083
|
+
}), this.registerFunction("XLOOKUP", (e, t, n, r, i, a, o) => {
|
|
1084
|
+
if (!(n instanceof R) || !(r instanceof R)) throw Error("#VALUE!");
|
|
1085
|
+
let s = n.cols === 1;
|
|
1086
|
+
if (!s && n.rows !== 1) throw Error("#VALUE!");
|
|
1087
|
+
let c = n.values;
|
|
1088
|
+
if ((s ? r.rows : r.cols) !== c.length) throw Error("#VALUE!");
|
|
1089
|
+
let l = a === void 0 ? 0 : Math.trunc(Number(a));
|
|
1090
|
+
if (l !== 0 && l !== -1 && l !== 1) throw Error("#VALUE!");
|
|
1091
|
+
let u = o === void 0 ? 1 : Math.trunc(Number(o));
|
|
1092
|
+
if (![
|
|
1093
|
+
1,
|
|
1094
|
+
-1,
|
|
1095
|
+
2,
|
|
1096
|
+
-2
|
|
1097
|
+
].includes(u)) throw Error("#VALUE!");
|
|
1098
|
+
let d = -1;
|
|
1099
|
+
for (let e = 0; e < c.length; e++) {
|
|
1100
|
+
let n = u < 0 ? c.length - 1 - e : e, r = c[n];
|
|
1101
|
+
if (typeof t == "boolean" || typeof r == "boolean") {
|
|
1102
|
+
if (r === t) {
|
|
1103
|
+
d = n;
|
|
1104
|
+
break;
|
|
1105
|
+
}
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
let i = F(r, t);
|
|
1109
|
+
if (isNaN(i)) continue;
|
|
1110
|
+
if (i === 0) {
|
|
1111
|
+
d = n;
|
|
1112
|
+
break;
|
|
1113
|
+
}
|
|
1114
|
+
let a = d === -1 || (l === -1 ? F(c[n], c[d]) > 0 : F(c[n], c[d]) < 0);
|
|
1115
|
+
(l === -1 && i < 0 || l === 1 && i > 0) && a && (d = n);
|
|
1116
|
+
}
|
|
1117
|
+
if (d === -1) {
|
|
1118
|
+
if (i instanceof A) throw Error(i.code);
|
|
1119
|
+
if (i !== void 0) return i;
|
|
1120
|
+
throw Error("#N/A");
|
|
1121
|
+
}
|
|
1122
|
+
return s ? r.get(d, 0) : r.get(0, d);
|
|
865
1123
|
}), this.registerFunction("VLOOKUP", (e, t, n, r, i) => {
|
|
866
|
-
if (!(n instanceof
|
|
1124
|
+
if (!(n instanceof R)) throw Error("#VALUE!");
|
|
867
1125
|
let a = Math.trunc(Number(r));
|
|
868
1126
|
if (a < 1 || a > n.cols) throw Error("#REF!");
|
|
869
1127
|
let o = i === !1 || i === 0, s = n.getCol(0);
|
|
@@ -872,12 +1130,12 @@ var L = class {
|
|
|
872
1130
|
if (!isNaN(r) && !isNaN(i) && String(t).trim() !== "" && String(s[e]).trim() !== "" ? r === i : String(s[e]).toLowerCase() === String(t).toLowerCase()) return n.get(e, a - 1);
|
|
873
1131
|
}
|
|
874
1132
|
if (!o) {
|
|
875
|
-
let e =
|
|
1133
|
+
let e = I(s, t);
|
|
876
1134
|
if (e !== -1) return n.get(e, a - 1);
|
|
877
1135
|
}
|
|
878
1136
|
throw Error("#N/A");
|
|
879
1137
|
}), this.registerFunction("HLOOKUP", (e, t, n, r, i) => {
|
|
880
|
-
if (!(n instanceof
|
|
1138
|
+
if (!(n instanceof R)) throw Error("#VALUE!");
|
|
881
1139
|
let a = Math.trunc(Number(r));
|
|
882
1140
|
if (a < 1 || a > n.rows) throw Error("#REF!");
|
|
883
1141
|
let o = i === !1 || i === 0, s = n.getRow(0);
|
|
@@ -886,12 +1144,12 @@ var L = class {
|
|
|
886
1144
|
if (!isNaN(r) && !isNaN(i) && String(t).trim() !== "" && String(s[e]).trim() !== "" ? r === i : String(s[e]).toLowerCase() === String(t).toLowerCase()) return n.get(a - 1, e);
|
|
887
1145
|
}
|
|
888
1146
|
if (!o) {
|
|
889
|
-
let e =
|
|
1147
|
+
let e = I(s, t);
|
|
890
1148
|
if (e !== -1) return n.get(a - 1, e);
|
|
891
1149
|
}
|
|
892
1150
|
throw Error("#N/A");
|
|
893
1151
|
}), this.registerFunction("INDEX", (e, t, n, r) => {
|
|
894
|
-
if (t instanceof
|
|
1152
|
+
if (t instanceof R) {
|
|
895
1153
|
let e = Math.trunc(Number(n)) - 1, i = r === void 0 ? 0 : Math.trunc(Number(r)) - 1;
|
|
896
1154
|
if (e < 0 || e >= t.rows || i < 0 || i >= t.cols) throw Error("#REF!");
|
|
897
1155
|
let a = t.get(e, i);
|
|
@@ -900,7 +1158,7 @@ var L = class {
|
|
|
900
1158
|
throw Error("#VALUE!");
|
|
901
1159
|
}), this.registerFunction("MATCH", (e, t, n, r) => {
|
|
902
1160
|
let i;
|
|
903
|
-
if (n instanceof
|
|
1161
|
+
if (n instanceof R) i = n.values;
|
|
904
1162
|
else if (Array.isArray(n)) i = n;
|
|
905
1163
|
else throw Error("#VALUE!");
|
|
906
1164
|
let a = r === void 0 ? 1 : Number(r);
|
|
@@ -912,13 +1170,13 @@ var L = class {
|
|
|
912
1170
|
throw Error("#N/A");
|
|
913
1171
|
}
|
|
914
1172
|
if (a === 1) {
|
|
915
|
-
let e =
|
|
1173
|
+
let e = I(i, t);
|
|
916
1174
|
if (e === -1) throw Error("#N/A");
|
|
917
1175
|
return e + 1;
|
|
918
1176
|
}
|
|
919
1177
|
{
|
|
920
1178
|
let e = -1;
|
|
921
|
-
for (let n = 0; n < i.length; n++)
|
|
1179
|
+
for (let n = 0; n < i.length; n++) F(i[n], t) >= 0 && (e = n);
|
|
922
1180
|
if (e === -1) throw Error("#N/A");
|
|
923
1181
|
return e + 1;
|
|
924
1182
|
}
|
|
@@ -940,6 +1198,27 @@ var L = class {
|
|
|
940
1198
|
if (i === 0) return 0;
|
|
941
1199
|
let a = parseFloat((r / i).toPrecision(10));
|
|
942
1200
|
return Math.floor(a) * i;
|
|
1201
|
+
});
|
|
1202
|
+
let e = (e) => e === void 0 ? 0 : Math.trunc(P(e));
|
|
1203
|
+
this.registerFunction("ROUNDUP", (t, n, r) => W(P(n), e(r), Math.ceil)), this.registerFunction("ROUNDDOWN", (t, n, r) => W(P(n), e(r), Math.floor)), this.registerFunction("INT", (e, t) => Math.floor(P(t))), this.registerFunction("SQRT", (e, t) => {
|
|
1204
|
+
let n = P(t);
|
|
1205
|
+
if (n < 0) throw Error("#NUM!");
|
|
1206
|
+
return Math.sqrt(n);
|
|
1207
|
+
}), this.registerFunction("PRODUCT", (e, ...t) => {
|
|
1208
|
+
let n = U(t);
|
|
1209
|
+
return n.length ? n.reduce((e, t) => e * t, 1) : 0;
|
|
1210
|
+
}), this.registerFunction("MEDIAN", (e, ...t) => {
|
|
1211
|
+
let n = U(t).sort((e, t) => e - t);
|
|
1212
|
+
if (n.length === 0) throw Error("#NUM!");
|
|
1213
|
+
let r = Math.floor(n.length / 2);
|
|
1214
|
+
return n.length % 2 ? n[r] : (n[r - 1] + n[r]) / 2;
|
|
1215
|
+
}), this.registerFunction("TEXTJOIN", (e, t, n, ...r) => {
|
|
1216
|
+
let i = [];
|
|
1217
|
+
for (let e of r) for (let t of V(e)) {
|
|
1218
|
+
if (M(t)) throw Error(t);
|
|
1219
|
+
t === void 0 || t === "" ? n || i.push("") : typeof t == "boolean" ? i.push(t ? "TRUE" : "FALSE") : i.push(String(t));
|
|
1220
|
+
}
|
|
1221
|
+
return i.join(String(t ?? ""));
|
|
943
1222
|
}), this.registerFunction("LEFT", (e, t, n) => {
|
|
944
1223
|
let r = n === void 0 ? 1 : Number(n);
|
|
945
1224
|
if (!(r >= 0)) throw Error("#VALUE!");
|
|
@@ -1003,11 +1282,22 @@ var L = class {
|
|
|
1003
1282
|
let l = s.getTime() - c.getTime();
|
|
1004
1283
|
return Math.round(l / 864e5);
|
|
1005
1284
|
}), this.registerFunction("NOW", () => {
|
|
1006
|
-
let e = /* @__PURE__ */ new Date()
|
|
1007
|
-
return (e.
|
|
1285
|
+
let e = /* @__PURE__ */ new Date();
|
|
1286
|
+
return g(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds()) + e.getMilliseconds() / 864e5;
|
|
1287
|
+
}), this.registerFunction("TODAY", () => {
|
|
1288
|
+
let e = /* @__PURE__ */ new Date();
|
|
1289
|
+
return g(e.getFullYear(), e.getMonth(), e.getDate());
|
|
1290
|
+
}), this.registerFunction("YEAR", (e, t) => G(t).getUTCFullYear()), this.registerFunction("MONTH", (e, t) => G(t).getUTCMonth() + 1), this.registerFunction("DAY", (e, t) => G(t).getUTCDate()), this.registerFunction("WEEKDAY", (e, t, n) => {
|
|
1291
|
+
let r = G(t).getUTCDay();
|
|
1292
|
+
switch (n === void 0 ? 1 : Math.trunc(Number(n))) {
|
|
1293
|
+
case 1: return r + 1;
|
|
1294
|
+
case 2: return (r + 6) % 7 + 1;
|
|
1295
|
+
case 3: return (r + 6) % 7;
|
|
1296
|
+
default: throw Error("#NUM!");
|
|
1297
|
+
}
|
|
1008
1298
|
});
|
|
1009
1299
|
}
|
|
1010
|
-
},
|
|
1300
|
+
}, q = class {
|
|
1011
1301
|
constructor() {
|
|
1012
1302
|
this._copySourceRange = null, this._copySourceData = null, this._lastWrittenText = null;
|
|
1013
1303
|
}
|
|
@@ -1015,7 +1305,7 @@ var L = class {
|
|
|
1015
1305
|
this._copySourceRange = t;
|
|
1016
1306
|
let n = /* @__PURE__ */ new Map();
|
|
1017
1307
|
for (let r = t.start.row; r <= t.end.row; r++) for (let i = t.start.col; i <= t.end.col; i++) {
|
|
1018
|
-
let t =
|
|
1308
|
+
let t = y(r, i), a = e.get(t);
|
|
1019
1309
|
a && n.set(t, { ...a });
|
|
1020
1310
|
}
|
|
1021
1311
|
this._copySourceData = n;
|
|
@@ -1039,7 +1329,7 @@ var L = class {
|
|
|
1039
1329
|
async cut(e, t) {
|
|
1040
1330
|
await this.copy(e, t);
|
|
1041
1331
|
let n = [];
|
|
1042
|
-
for (let e = t.start.row; e <= t.end.row; e++) for (let r = t.start.col; r <= t.end.col; r++) n.push(
|
|
1332
|
+
for (let e = t.start.row; e <= t.end.row; e++) for (let r = t.start.col; r <= t.end.col; r++) n.push(y(e, r));
|
|
1043
1333
|
return n;
|
|
1044
1334
|
}
|
|
1045
1335
|
async paste(e, t, n, r) {
|
|
@@ -1078,10 +1368,10 @@ var L = class {
|
|
|
1078
1368
|
for (let e = i.start.row; e <= i.end.row; e++) for (let t = i.start.col; t <= i.end.col; t++) {
|
|
1079
1369
|
let i = e + o, l = t + s;
|
|
1080
1370
|
if (i >= n || l >= r) continue;
|
|
1081
|
-
let u = a.get(
|
|
1371
|
+
let u = a.get(y(e, t)), d = u?.rawValue ?? "";
|
|
1082
1372
|
d.startsWith("=") && (d = this.adjustFormulaReferences(d, o, s));
|
|
1083
1373
|
let f = {
|
|
1084
|
-
id:
|
|
1374
|
+
id: y(i, l),
|
|
1085
1375
|
value: d
|
|
1086
1376
|
};
|
|
1087
1377
|
u?.format && (f.format = { ...u.format }), c.push(f);
|
|
@@ -1118,7 +1408,7 @@ var L = class {
|
|
|
1118
1408
|
let c = t + o, l = n + s;
|
|
1119
1409
|
if (c < r && l < i) {
|
|
1120
1410
|
let { value: t, format: n } = e[o][s], r = {
|
|
1121
|
-
id:
|
|
1411
|
+
id: y(c, l),
|
|
1122
1412
|
value: t
|
|
1123
1413
|
};
|
|
1124
1414
|
n && (r.format = n), a.push(r);
|
|
@@ -1127,27 +1417,19 @@ var L = class {
|
|
|
1127
1417
|
return a;
|
|
1128
1418
|
}
|
|
1129
1419
|
parseTSV(e, t, n, r, i) {
|
|
1130
|
-
let a =
|
|
1420
|
+
let a = E(e, " "), o = [];
|
|
1131
1421
|
for (let e = 0; e < a.length; e++) {
|
|
1132
1422
|
let s = a[e];
|
|
1133
1423
|
for (let a = 0; a < s.length; a++) {
|
|
1134
1424
|
let c = t + e, l = n + a;
|
|
1135
1425
|
c < r && l < i && o.push({
|
|
1136
|
-
id:
|
|
1426
|
+
id: y(c, l),
|
|
1137
1427
|
value: s[a]
|
|
1138
1428
|
});
|
|
1139
1429
|
}
|
|
1140
1430
|
}
|
|
1141
1431
|
return o;
|
|
1142
1432
|
}
|
|
1143
|
-
_parseTSVRows(e) {
|
|
1144
|
-
let t = [], n = [], r = "", i = !1, a = 0;
|
|
1145
|
-
for (; a < e.length;) {
|
|
1146
|
-
let o = e[a];
|
|
1147
|
-
i ? o === "\"" ? a + 1 < e.length && e[a + 1] === "\"" ? (r += "\"", a += 2) : (i = !1, a++) : (r += o, a++) : o === "\"" && r === "" ? (i = !0, a++) : o === " " ? (n.push(r), r = "", a++) : o === "\r" ? (n.push(r), r = "", a + 1 < e.length && e[a + 1] === "\n" ? a += 2 : a++, t.push(n), n = []) : o === "\n" ? (n.push(r), r = "", a++, t.push(n), n = []) : (r += o, a++);
|
|
1148
|
-
}
|
|
1149
|
-
return n.push(r), (n.length > 1 || n[0] !== "") && t.push(n), t;
|
|
1150
|
-
}
|
|
1151
1433
|
adjustFormulaReferences(e, t, n) {
|
|
1152
1434
|
if (!e.startsWith("=")) return e;
|
|
1153
1435
|
let r = [], i = [], a = 0, o = "";
|
|
@@ -1160,8 +1442,8 @@ var L = class {
|
|
|
1160
1442
|
o && (r.push(o), i.push(!1));
|
|
1161
1443
|
let s = /(?<![A-Z0-9_.$])(\$?)([A-Z]+)(\$?)(\d+)(?![A-Z0-9_.]|\s*\()/gi;
|
|
1162
1444
|
return r.map((e, r) => i[r] ? e : e.replace(s, (e, r, i, a, o) => {
|
|
1163
|
-
let s =
|
|
1164
|
-
return l < 0 || u < 0 ? "#REF!" : `${r}${
|
|
1445
|
+
let s = S(i.toUpperCase()), c = parseInt(o, 10) - 1, l = r === "$" ? s : s + n, u = a === "$" ? c : c + t;
|
|
1446
|
+
return l < 0 || u < 0 ? "#REF!" : `${r}${x(l)}${a}${u + 1}`;
|
|
1165
1447
|
})).join("");
|
|
1166
1448
|
}
|
|
1167
1449
|
serializeRange(e, t) {
|
|
@@ -1169,22 +1451,19 @@ var L = class {
|
|
|
1169
1451
|
for (let r = t.start.row; r <= t.end.row; r++) {
|
|
1170
1452
|
let i = [];
|
|
1171
1453
|
for (let n = t.start.col; n <= t.end.col; n++) {
|
|
1172
|
-
let t = e.get(
|
|
1173
|
-
i.push(
|
|
1454
|
+
let t = e.get(y(r, n))?.displayValue ?? "";
|
|
1455
|
+
i.push(D(t, " "));
|
|
1174
1456
|
}
|
|
1175
1457
|
n.push(i.join(" "));
|
|
1176
1458
|
}
|
|
1177
1459
|
return n.join("\n");
|
|
1178
1460
|
}
|
|
1179
|
-
_quoteTSVField(e) {
|
|
1180
|
-
return e.includes(" ") || e.includes("\n") || e.includes("\r") || e.includes("\"") ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
1181
|
-
}
|
|
1182
1461
|
_serializeRangeAsHTML(e, t) {
|
|
1183
1462
|
let n = [];
|
|
1184
1463
|
for (let r = t.start.row; r <= t.end.row; r++) {
|
|
1185
1464
|
let i = [];
|
|
1186
1465
|
for (let n = t.start.col; n <= t.end.col; n++) {
|
|
1187
|
-
let t = e.get(
|
|
1466
|
+
let t = e.get(y(r, n)), a = t?.displayValue ?? "", o = t?.rawValue ?? "", s = [];
|
|
1188
1467
|
if (o && o !== a && s.push(`data-raw="${this._escapeHTML(o)}"`), t?.format) {
|
|
1189
1468
|
let e = this._formatToInlineStyle(t.format);
|
|
1190
1469
|
e && s.push(`style="${this._escapeHTML(e)}"`), s.push(`data-format="${this._escapeHTML(JSON.stringify(t.format))}"`);
|
|
@@ -1200,7 +1479,7 @@ var L = class {
|
|
|
1200
1479
|
let t = [];
|
|
1201
1480
|
e.bold && t.push("font-weight: bold"), e.italic && t.push("font-style: italic");
|
|
1202
1481
|
let n = [];
|
|
1203
|
-
return e.underline && n.push("underline"), e.strikethrough && n.push("line-through"), n.length > 0 && t.push(`text-decoration: ${n.join(" ")}`), e.textColor && t.push(`color: ${e.textColor}`), e.backgroundColor && t.push(`background-color: ${e.backgroundColor}`), e.textAlign && t.push(`text-align: ${e.textAlign}`), e.fontSize && t.push(`font-size: ${e.fontSize}px`), t.join("; ");
|
|
1482
|
+
return e.underline && n.push("underline"), e.strikethrough && n.push("line-through"), n.length > 0 && t.push(`text-decoration: ${n.join(" ")}`), e.textColor && t.push(`color: ${e.textColor}`), e.backgroundColor && t.push(`background-color: ${e.backgroundColor}`), e.textAlign && t.push(`text-align: ${e.textAlign}`), e.verticalAlign && t.push(`vertical-align: ${e.verticalAlign}`), e.wrap && t.push("white-space: normal"), e.fontSize && t.push(`font-size: ${e.fontSize}px`), t.join("; ");
|
|
1204
1483
|
}
|
|
1205
1484
|
_parseStyleToFormat(e) {
|
|
1206
1485
|
if (!e) return;
|
|
@@ -1227,10 +1506,14 @@ var L = class {
|
|
|
1227
1506
|
"left",
|
|
1228
1507
|
"center",
|
|
1229
1508
|
"right"
|
|
1509
|
+
]), a = /* @__PURE__ */ new Set([
|
|
1510
|
+
"top",
|
|
1511
|
+
"middle",
|
|
1512
|
+
"bottom"
|
|
1230
1513
|
]);
|
|
1231
|
-
typeof t.bold == "boolean" && (n.bold = t.bold), typeof t.italic == "boolean" && (n.italic = t.italic), typeof t.underline == "boolean" && (n.underline = t.underline), typeof t.strikethrough == "boolean" && (n.strikethrough = t.strikethrough), typeof t.textColor == "string" && t.textColor.length <= 100 && r.test(t.textColor) && (n.textColor = t.textColor), typeof t.backgroundColor == "string" && t.backgroundColor.length <= 100 && r.test(t.backgroundColor) && (n.backgroundColor = t.backgroundColor), typeof t.textAlign == "string" && i.has(t.textAlign) && (n.textAlign = t.textAlign), typeof t.fontSize == "number" && t.fontSize > 0 && t.fontSize <= 200 && (n.fontSize = t.fontSize);
|
|
1232
|
-
let
|
|
1233
|
-
return
|
|
1514
|
+
typeof t.bold == "boolean" && (n.bold = t.bold), typeof t.italic == "boolean" && (n.italic = t.italic), typeof t.underline == "boolean" && (n.underline = t.underline), typeof t.strikethrough == "boolean" && (n.strikethrough = t.strikethrough), typeof t.textColor == "string" && t.textColor.length <= 100 && r.test(t.textColor) && (n.textColor = t.textColor), typeof t.backgroundColor == "string" && t.backgroundColor.length <= 100 && r.test(t.backgroundColor) && (n.backgroundColor = t.backgroundColor), typeof t.textAlign == "string" && i.has(t.textAlign) && (n.textAlign = t.textAlign), typeof t.verticalAlign == "string" && a.has(t.verticalAlign) && (n.verticalAlign = t.verticalAlign), typeof t.wrap == "boolean" && (n.wrap = t.wrap), typeof t.fontSize == "number" && t.fontSize > 0 && t.fontSize <= 200 && (n.fontSize = t.fontSize);
|
|
1515
|
+
let o = this._sanitizeNumberFormat(t.numberFormat);
|
|
1516
|
+
return o && (n.numberFormat = o), Object.keys(n).length > 0 ? n : void 0;
|
|
1234
1517
|
}
|
|
1235
1518
|
_sanitizeNumberFormat(e) {
|
|
1236
1519
|
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
@@ -1238,11 +1521,12 @@ var L = class {
|
|
|
1238
1521
|
"number",
|
|
1239
1522
|
"currency",
|
|
1240
1523
|
"percent",
|
|
1241
|
-
"scientific"
|
|
1524
|
+
"scientific",
|
|
1525
|
+
"date"
|
|
1242
1526
|
]);
|
|
1243
1527
|
if (typeof t.type != "string" || !n.has(t.type)) return;
|
|
1244
1528
|
let r = { type: t.type };
|
|
1245
|
-
return typeof t.decimals == "number" && Number.isInteger(t.decimals) && t.decimals >= 0 && t.decimals <= 20 && (r.decimals = t.decimals), typeof t.currencySymbol == "string" && t.currencySymbol.length <= 8 && (r.currencySymbol = t.currencySymbol), typeof t.thousandsSep == "boolean" && (r.thousandsSep = t.thousandsSep), r;
|
|
1529
|
+
return typeof t.decimals == "number" && Number.isInteger(t.decimals) && t.decimals >= 0 && t.decimals <= 20 && (r.decimals = t.decimals), typeof t.currencySymbol == "string" && t.currencySymbol.length <= 8 && (r.currencySymbol = t.currencySymbol), typeof t.thousandsSep == "boolean" && (r.thousandsSep = t.thousandsSep), typeof t.datePattern == "string" && t.datePattern.length <= 64 && (r.datePattern = t.datePattern), r;
|
|
1246
1530
|
}
|
|
1247
1531
|
_extractStyleProp(e, t) {
|
|
1248
1532
|
let n = RegExp(`(?<![\\w-])${t}\\s*:\\s*([^;]+)`, "i"), r = e.match(n);
|
|
@@ -1262,14 +1546,14 @@ var L = class {
|
|
|
1262
1546
|
}
|
|
1263
1547
|
};
|
|
1264
1548
|
// \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
|
|
1265
|
-
function
|
|
1549
|
+
function J(e, t, n, r) {
|
|
1266
1550
|
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
1267
1551
|
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
1268
1552
|
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
1269
1553
|
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
1270
1554
|
}
|
|
1271
1555
|
// src/components/y11n-formula-bar.ts
|
|
1272
|
-
var
|
|
1556
|
+
var Y = class extends e {
|
|
1273
1557
|
constructor(...e) {
|
|
1274
1558
|
super(...e), this.cellRef = "A1", this.rawValue = "", this.displayValue = "", this.mode = "raw", this.readOnly = !1, this._draft = "";
|
|
1275
1559
|
}
|
|
@@ -1410,43 +1694,48 @@ var B = class extends e {
|
|
|
1410
1694
|
`;
|
|
1411
1695
|
}
|
|
1412
1696
|
};
|
|
1413
|
-
|
|
1697
|
+
J([a({
|
|
1414
1698
|
type: String,
|
|
1415
1699
|
attribute: "cell-ref"
|
|
1416
|
-
})],
|
|
1700
|
+
})], Y.prototype, "cellRef", void 0), J([a({
|
|
1417
1701
|
type: String,
|
|
1418
1702
|
attribute: "raw-value"
|
|
1419
|
-
})],
|
|
1703
|
+
})], Y.prototype, "rawValue", void 0), J([a({
|
|
1420
1704
|
type: String,
|
|
1421
1705
|
attribute: "display-value"
|
|
1422
|
-
})],
|
|
1706
|
+
})], Y.prototype, "displayValue", void 0), J([a({ type: String })], Y.prototype, "mode", void 0), J([a({
|
|
1423
1707
|
type: Boolean,
|
|
1424
1708
|
attribute: "read-only",
|
|
1425
1709
|
reflect: !0
|
|
1426
|
-
})],
|
|
1710
|
+
})], Y.prototype, "readOnly", void 0), J([s()], Y.prototype, "_draft", void 0), Y = J([i("y11n-formula-bar")], Y);
|
|
1427
1711
|
// src/y11n-spreadsheet.ts
|
|
1428
|
-
var
|
|
1429
|
-
function
|
|
1712
|
+
var X;
|
|
1713
|
+
function de(e) {
|
|
1430
1714
|
let t = { ...e };
|
|
1431
1715
|
return e.format && (t.format = { ...e.format }, e.format.numberFormat && (t.format.numberFormat = { ...e.format.numberFormat })), t;
|
|
1432
1716
|
}
|
|
1433
|
-
function
|
|
1717
|
+
function Z(e, t, n, r) {
|
|
1434
1718
|
let i = [], a = 0;
|
|
1435
1719
|
for (let t of e) t > a && i.push(r(a, t - a)), i.push(n(t)), a = t + 1;
|
|
1436
1720
|
return t > a && i.push(r(a, t - a)), i;
|
|
1437
1721
|
}
|
|
1438
|
-
function
|
|
1722
|
+
function fe(e, t, n) {
|
|
1439
1723
|
let r = [];
|
|
1440
1724
|
for (let n = e; n < t; n++) r.push(n);
|
|
1441
1725
|
for (let i of n) (i < e || i >= t) && !r.includes(i) && r.push(i);
|
|
1442
1726
|
return r.sort((e, t) => e - t);
|
|
1443
1727
|
}
|
|
1444
|
-
var
|
|
1728
|
+
var pe = {
|
|
1729
|
+
ArrowUp: [-1, 0],
|
|
1730
|
+
ArrowDown: [1, 0],
|
|
1731
|
+
ArrowLeft: [0, -1],
|
|
1732
|
+
ArrowRight: [0, 1]
|
|
1733
|
+
}, Q = class extends e {
|
|
1445
1734
|
static {
|
|
1446
|
-
|
|
1735
|
+
X = this;
|
|
1447
1736
|
}
|
|
1448
1737
|
constructor(...e) {
|
|
1449
|
-
super(...e), this.rows = 100, this.cols = 26, this.data = /* @__PURE__ */ new Map(), this.readOnly = !1, this.gridLabel = "Spreadsheet", this.functions = {}, this._isEditing = !1, this._editValue = "", this._formulaBarMode = "raw", this._editorNeedsCursorReset = !1, this._refMode = !1, this._modeAnnouncement = "", this._scrollTop = 0, this._scrollLeft = 0, this._selection = new
|
|
1738
|
+
super(...e), this.rows = 100, this.cols = 26, this.data = /* @__PURE__ */ new Map(), this.readOnly = !1, this.gridLabel = "Spreadsheet", this.functions = {}, this._isEditing = !1, this._editValue = "", this._formulaBarMode = "raw", this._editorNeedsCursorReset = !1, this._refMode = !1, this._modeAnnouncement = "", this._scrollTop = 0, this._scrollLeft = 0, this._selection = new T(this, this.rows, this.cols), this._formulaEngine = new K(), this._clipboardManager = new q(), this._internalData = /* @__PURE__ */ new Map(), this._lastSyncedDataRef = null, this._editingCellKey = null, this._undoStack = [], this._redoStack = [], this._maxHistory = 100, this._refCursorRow = 0, this._refCursorCol = 0, this._refInsertStart = 0, this._refInsertEnd = 0, this._pasteInProgress = !1;
|
|
1450
1739
|
}
|
|
1451
1740
|
static {
|
|
1452
1741
|
this.PASTE_CHUNK_SIZE = 500;
|
|
@@ -1465,7 +1754,7 @@ var G = class extends e {
|
|
|
1465
1754
|
}
|
|
1466
1755
|
getData() {
|
|
1467
1756
|
let e = /* @__PURE__ */ new Map();
|
|
1468
|
-
for (let [t, n] of this._internalData) e.set(t,
|
|
1757
|
+
for (let [t, n] of this._internalData) e.set(t, de(n));
|
|
1469
1758
|
return e;
|
|
1470
1759
|
}
|
|
1471
1760
|
setData(e) {
|
|
@@ -1474,6 +1763,58 @@ var G = class extends e {
|
|
|
1474
1763
|
registerFunction(e, t) {
|
|
1475
1764
|
this._formulaEngine.registerFunction(e, t), this._recalcAll();
|
|
1476
1765
|
}
|
|
1766
|
+
toCSV(e = {}) {
|
|
1767
|
+
let { delimiter: t = ",", values: n = "display" } = e, r = e.range;
|
|
1768
|
+
if (!r) {
|
|
1769
|
+
let e = -1, t = -1;
|
|
1770
|
+
for (let [n, r] of this._internalData) {
|
|
1771
|
+
if (r.rawValue === "") continue;
|
|
1772
|
+
let { row: i, col: a } = b(n);
|
|
1773
|
+
i > e && (e = i), a > t && (t = a);
|
|
1774
|
+
}
|
|
1775
|
+
if (e < 0) return "";
|
|
1776
|
+
r = {
|
|
1777
|
+
start: {
|
|
1778
|
+
row: 0,
|
|
1779
|
+
col: 0
|
|
1780
|
+
},
|
|
1781
|
+
end: {
|
|
1782
|
+
row: e,
|
|
1783
|
+
col: t
|
|
1784
|
+
}
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
let i = [];
|
|
1788
|
+
for (let e = r.start.row; e <= r.end.row; e++) {
|
|
1789
|
+
let t = [];
|
|
1790
|
+
for (let i = r.start.col; i <= r.end.col; i++) {
|
|
1791
|
+
let r = this._internalData.get(y(e, i));
|
|
1792
|
+
t.push((n === "raw" ? r?.rawValue : r?.displayValue) ?? "");
|
|
1793
|
+
}
|
|
1794
|
+
i.push(t);
|
|
1795
|
+
}
|
|
1796
|
+
return O(i, t);
|
|
1797
|
+
}
|
|
1798
|
+
fromCSV(e, t = {}) {
|
|
1799
|
+
if (this._pasteInProgress) return;
|
|
1800
|
+
let { delimiter: n = ",", start: r = {
|
|
1801
|
+
row: 0,
|
|
1802
|
+
col: 0
|
|
1803
|
+
} } = t;
|
|
1804
|
+
if (!Number.isInteger(r.row) || !Number.isInteger(r.col) || r.row < 0 || r.col < 0) throw RangeError("fromCSV: start must be a cell with non-negative integer row and col");
|
|
1805
|
+
let i = [];
|
|
1806
|
+
E(e, n).forEach((e, t) => {
|
|
1807
|
+
e.forEach((e, n) => {
|
|
1808
|
+
let a = r.row + t, o = r.col + n;
|
|
1809
|
+
a < this.rows && o < this.cols && i.push({
|
|
1810
|
+
id: y(a, o),
|
|
1811
|
+
value: e
|
|
1812
|
+
});
|
|
1813
|
+
});
|
|
1814
|
+
});
|
|
1815
|
+
let a = this._snapshotSelection(), o = this._buildCellBatch(i, "import", a);
|
|
1816
|
+
o && (this._applyBatch(o, "programmatic"), this._pushHistory(o));
|
|
1817
|
+
}
|
|
1477
1818
|
getCellFormat(e) {
|
|
1478
1819
|
return this._internalData.get(e)?.format;
|
|
1479
1820
|
}
|
|
@@ -1482,7 +1823,7 @@ var G = class extends e {
|
|
|
1482
1823
|
}
|
|
1483
1824
|
setRangeFormat(e, t) {
|
|
1484
1825
|
let n = [];
|
|
1485
|
-
for (let t = e.start.row; t <= e.end.row; t++) for (let r = e.start.col; r <= e.end.col; r++) n.push(
|
|
1826
|
+
for (let t = e.start.row; t <= e.end.row; t++) for (let r = e.start.col; r <= e.end.col; r++) n.push(y(t, r));
|
|
1486
1827
|
this._applyFormat(n, t, "programmatic");
|
|
1487
1828
|
}
|
|
1488
1829
|
clearCellFormat(e) {
|
|
@@ -1490,14 +1831,14 @@ var G = class extends e {
|
|
|
1490
1831
|
}
|
|
1491
1832
|
clearRangeFormat(e) {
|
|
1492
1833
|
let t = [];
|
|
1493
|
-
for (let n = e.start.row; n <= e.end.row; n++) for (let r = e.start.col; r <= e.end.col; r++) t.push(
|
|
1834
|
+
for (let n = e.start.row; n <= e.end.row; n++) for (let r = e.start.col; r <= e.end.col; r++) t.push(y(n, r));
|
|
1494
1835
|
this._clearFormat(t, "programmatic");
|
|
1495
1836
|
}
|
|
1496
1837
|
toggleFormat(e) {
|
|
1497
1838
|
if (this.readOnly || this._pasteInProgress) return;
|
|
1498
1839
|
let t = this._selection.range, n = [], r = !0;
|
|
1499
1840
|
for (let i = t.start.row; i <= t.end.row; i++) for (let a = t.start.col; a <= t.end.col; a++) {
|
|
1500
|
-
let t =
|
|
1841
|
+
let t = y(i, a);
|
|
1501
1842
|
n.push(t), this._internalData.get(t)?.format?.[e] || (r = !1);
|
|
1502
1843
|
}
|
|
1503
1844
|
let i = { [e]: !r };
|
|
@@ -1569,11 +1910,15 @@ var G = class extends e {
|
|
|
1569
1910
|
left: "flex-start",
|
|
1570
1911
|
center: "center",
|
|
1571
1912
|
right: "flex-end"
|
|
1572
|
-
}[i.textAlign]), r
|
|
1913
|
+
}[i.textAlign]), i.verticalAlign && (r["align-items"] = {
|
|
1914
|
+
top: "flex-start",
|
|
1915
|
+
middle: "center",
|
|
1916
|
+
bottom: "flex-end"
|
|
1917
|
+
}[i.verticalAlign]), i.wrap && (r["white-space"] = "normal", r["overflow-wrap"] = "anywhere"), r;
|
|
1573
1918
|
}
|
|
1574
1919
|
_syncData() {
|
|
1575
1920
|
let e = this._internalData, t = /* @__PURE__ */ new Map();
|
|
1576
|
-
for (let [e, n] of this.data) t.set(e,
|
|
1921
|
+
for (let [e, n] of this.data) t.set(e, de(n));
|
|
1577
1922
|
let n = [];
|
|
1578
1923
|
for (let [r, i] of t) {
|
|
1579
1924
|
let t = e.get(r);
|
|
@@ -1612,7 +1957,7 @@ var G = class extends e {
|
|
|
1612
1957
|
t.type === "number" && t.format?.numberFormat && (t.displayValue = f(t.rawValue.startsWith("=") ? Number(this._formulaEngine.evaluate(t.rawValue).displayValue) : Number(t.rawValue), t.format.numberFormat));
|
|
1613
1958
|
}
|
|
1614
1959
|
_getCell(e, t) {
|
|
1615
|
-
return this._internalData.get(
|
|
1960
|
+
return this._internalData.get(y(e, t));
|
|
1616
1961
|
}
|
|
1617
1962
|
_getCellDisplay(e, t) {
|
|
1618
1963
|
return this._getCell(e, t)?.displayValue ?? "";
|
|
@@ -1622,10 +1967,10 @@ var G = class extends e {
|
|
|
1622
1967
|
}
|
|
1623
1968
|
_getActiveCellKey() {
|
|
1624
1969
|
let { row: e, col: t } = this._selection.activeCell;
|
|
1625
|
-
return
|
|
1970
|
+
return y(e, t);
|
|
1626
1971
|
}
|
|
1627
1972
|
_getActiveCellRef() {
|
|
1628
|
-
return
|
|
1973
|
+
return w(this._selection.activeCell);
|
|
1629
1974
|
}
|
|
1630
1975
|
_setCellRaw(e, t) {
|
|
1631
1976
|
let n = this._internalData.get(e), r = this._formulaEngine.evaluate(t, e), i = r.displayValue, a = n?.format?.numberFormat;
|
|
@@ -1650,11 +1995,12 @@ var G = class extends e {
|
|
|
1650
1995
|
_snapshotSelection() {
|
|
1651
1996
|
return {
|
|
1652
1997
|
anchor: { ...this._selection.anchor },
|
|
1653
|
-
head: { ...this._selection.head }
|
|
1998
|
+
head: { ...this._selection.head },
|
|
1999
|
+
active: this._selection.activeOverride
|
|
1654
2000
|
};
|
|
1655
2001
|
}
|
|
1656
2002
|
_restoreSelection(e) {
|
|
1657
|
-
this._selection.
|
|
2003
|
+
this._selection.setSelection(e.anchor, e.head, e.active), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
1658
2004
|
}
|
|
1659
2005
|
_buildCommandBatch(e, t, n, r) {
|
|
1660
2006
|
let i = [];
|
|
@@ -1673,6 +2019,38 @@ var G = class extends e {
|
|
|
1673
2019
|
operation: t
|
|
1674
2020
|
};
|
|
1675
2021
|
}
|
|
2022
|
+
_buildCellBatch(e, t, n) {
|
|
2023
|
+
let r = [];
|
|
2024
|
+
for (let t of e) {
|
|
2025
|
+
let e = this._internalData.get(t.id), n = e?.rawValue ?? "", i = {
|
|
2026
|
+
id: t.id,
|
|
2027
|
+
before: n,
|
|
2028
|
+
after: t.value
|
|
2029
|
+
};
|
|
2030
|
+
if (t.format !== void 0) {
|
|
2031
|
+
let n = t.format && Object.keys(t.format).length > 0 ? { ...t.format } : void 0;
|
|
2032
|
+
u(e?.format, n) || (i.formatBefore = e?.format ? { ...e.format } : void 0, i.formatAfter = n);
|
|
2033
|
+
}
|
|
2034
|
+
(n !== t.value || "formatAfter" in i) && r.push(i);
|
|
2035
|
+
}
|
|
2036
|
+
return r.length === 0 ? null : {
|
|
2037
|
+
deltas: r,
|
|
2038
|
+
selectionBefore: n,
|
|
2039
|
+
selectionAfter: n,
|
|
2040
|
+
operation: t
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
async _runUserBatch(e) {
|
|
2044
|
+
if (e.deltas.length <= X.PASTE_CHUNK_SIZE) this._executeUserBatch(e);
|
|
2045
|
+
else {
|
|
2046
|
+
this._pasteInProgress = !0;
|
|
2047
|
+
try {
|
|
2048
|
+
await this._applyBatchProgressive(e), this._pushHistory(e);
|
|
2049
|
+
} finally {
|
|
2050
|
+
this._pasteInProgress = !1;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
1676
2054
|
_pushHistory(e) {
|
|
1677
2055
|
this._undoStack.push(e), this._redoStack = [], this._undoStack.length > this._maxHistory && this._undoStack.shift();
|
|
1678
2056
|
}
|
|
@@ -1753,10 +2131,10 @@ var G = class extends e {
|
|
|
1753
2131
|
}
|
|
1754
2132
|
_startEditing(e) {
|
|
1755
2133
|
if (this.readOnly || this._isEditing || this._pasteInProgress) return;
|
|
1756
|
-
let { row: t, col: n } = this._selection.activeCell, r =
|
|
2134
|
+
let { row: t, col: n } = this._selection.activeCell, r = y(t, n);
|
|
1757
2135
|
this._editingCellKey = r;
|
|
1758
2136
|
let i = this._internalData.get(r);
|
|
1759
|
-
this._editValue = e ?? i?.rawValue ?? "", this._isEditing = !0, this._editorNeedsCursorReset = !0, this._modeAnnouncement = `Editing ${
|
|
2137
|
+
this._editValue = e ?? i?.rawValue ?? "", this._isEditing = !0, this._editorNeedsCursorReset = !0, this._modeAnnouncement = `Editing ${w(this._selection.activeCell)}`;
|
|
1760
2138
|
}
|
|
1761
2139
|
_commitEdit() {
|
|
1762
2140
|
if (!this._isEditing || !this._editingCellKey) return;
|
|
@@ -1793,7 +2171,7 @@ var G = class extends e {
|
|
|
1793
2171
|
col: this._refCursorCol + n
|
|
1794
2172
|
});
|
|
1795
2173
|
this._refCursorRow = e.row, this._refCursorCol = e.col;
|
|
1796
|
-
let r =
|
|
2174
|
+
let r = w({
|
|
1797
2175
|
row: this._refCursorRow,
|
|
1798
2176
|
col: this._refCursorCol
|
|
1799
2177
|
});
|
|
@@ -1803,13 +2181,13 @@ var G = class extends e {
|
|
|
1803
2181
|
row: e + t,
|
|
1804
2182
|
col: r + n
|
|
1805
2183
|
});
|
|
1806
|
-
this._refCursorRow = i.row, this._refCursorCol = i.col, this._refMode = !0, this._modeAnnouncement = `Reference selection mode. Selecting ${
|
|
2184
|
+
this._refCursorRow = i.row, this._refCursorCol = i.col, this._refMode = !0, this._modeAnnouncement = `Reference selection mode. Selecting ${w({
|
|
1807
2185
|
row: this._refCursorRow,
|
|
1808
2186
|
col: this._refCursorCol
|
|
1809
2187
|
})}`;
|
|
1810
2188
|
let a = this._editor?.selectionStart ?? this._editValue.length;
|
|
1811
2189
|
this._refInsertStart = a;
|
|
1812
|
-
let o =
|
|
2190
|
+
let o = w({
|
|
1813
2191
|
row: this._refCursorRow,
|
|
1814
2192
|
col: this._refCursorCol
|
|
1815
2193
|
});
|
|
@@ -1846,24 +2224,29 @@ var G = class extends e {
|
|
|
1846
2224
|
return;
|
|
1847
2225
|
}
|
|
1848
2226
|
let t = e.shiftKey, n = e.ctrlKey || e.metaKey;
|
|
2227
|
+
if (e.key === " " && (n || t) && !e.altKey) {
|
|
2228
|
+
e.preventDefault(), e.stopPropagation(), this._selectWholeRowsOrColumns(n, t);
|
|
2229
|
+
return;
|
|
2230
|
+
}
|
|
1849
2231
|
if (!n && !e.altKey && [...e.key].length === 1) {
|
|
1850
2232
|
this.readOnly || (e.preventDefault(), e.stopPropagation(), this._startEditing(e.key));
|
|
1851
2233
|
return;
|
|
1852
2234
|
}
|
|
1853
|
-
let r = !0;
|
|
1854
|
-
switch (
|
|
2235
|
+
let r = !0, i = n && e.key.length === 1 ? e.key.toLowerCase() : e.key;
|
|
2236
|
+
switch (i) {
|
|
1855
2237
|
case "ArrowUp":
|
|
1856
|
-
e.preventDefault(), this._selection.move(-1, 0, t), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
1857
|
-
break;
|
|
1858
2238
|
case "ArrowDown":
|
|
1859
|
-
e.preventDefault(), this._selection.move(1, 0, t), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
1860
|
-
break;
|
|
1861
2239
|
case "ArrowLeft":
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
2240
|
+
case "ArrowRight": {
|
|
2241
|
+
e.preventDefault();
|
|
2242
|
+
let [r, a] = pe[i];
|
|
2243
|
+
if (n) {
|
|
2244
|
+
let e = te(t ? this._selection.head : this._selection.activeCell, r, a, this.rows, this.cols, (e, t) => this._isCellFilled(e, t));
|
|
2245
|
+
this._selection.moveTo(e.row, e.col, t);
|
|
2246
|
+
} else this._selection.move(r, a, t);
|
|
2247
|
+
this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
1866
2248
|
break;
|
|
2249
|
+
}
|
|
1867
2250
|
case "Enter":
|
|
1868
2251
|
e.preventDefault(), this.readOnly || this._startEditing();
|
|
1869
2252
|
break;
|
|
@@ -1885,13 +2268,13 @@ var G = class extends e {
|
|
|
1885
2268
|
break;
|
|
1886
2269
|
case "PageDown": {
|
|
1887
2270
|
e.preventDefault();
|
|
1888
|
-
let n = this._getCSSVarPx("--ls-cell-height", 28), r = this._grid?.clientHeight || n *
|
|
2271
|
+
let n = this._getCSSVarPx("--ls-cell-height", 28), r = this._grid?.clientHeight || n * X.INITIAL_VIEW_ROWS, i = Math.max(1, Math.floor(r / n) - 1);
|
|
1889
2272
|
this._selection.move(i, 0, t), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
1890
2273
|
break;
|
|
1891
2274
|
}
|
|
1892
2275
|
case "PageUp": {
|
|
1893
2276
|
e.preventDefault();
|
|
1894
|
-
let n = this._getCSSVarPx("--ls-cell-height", 28), r = this._grid?.clientHeight || n *
|
|
2277
|
+
let n = this._getCSSVarPx("--ls-cell-height", 28), r = this._grid?.clientHeight || n * X.INITIAL_VIEW_ROWS, i = Math.max(1, Math.floor(r / n) - 1);
|
|
1895
2278
|
this._selection.move(-i, 0, t), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
1896
2279
|
break;
|
|
1897
2280
|
}
|
|
@@ -1916,6 +2299,12 @@ var G = class extends e {
|
|
|
1916
2299
|
case "u":
|
|
1917
2300
|
n ? (e.preventDefault(), this.toggleFormat("underline")) : r = !1;
|
|
1918
2301
|
break;
|
|
2302
|
+
case "d":
|
|
2303
|
+
n && !t ? (e.preventDefault(), this._fillSelection("down")) : r = !1;
|
|
2304
|
+
break;
|
|
2305
|
+
case "r":
|
|
2306
|
+
n && !t ? (e.preventDefault(), this._fillSelection("right")) : r = !1;
|
|
2307
|
+
break;
|
|
1919
2308
|
case "y":
|
|
1920
2309
|
n ? (e.preventDefault(), this._redo()) : r = !1;
|
|
1921
2310
|
break;
|
|
@@ -1929,7 +2318,11 @@ var G = class extends e {
|
|
|
1929
2318
|
_handleEditorKeydown(e) {
|
|
1930
2319
|
switch (e.stopPropagation(), e.key) {
|
|
1931
2320
|
case "Enter":
|
|
1932
|
-
e.preventDefault(), this._exitRefMode(),
|
|
2321
|
+
if (e.preventDefault(), this._exitRefMode(), e.ctrlKey || e.metaKey) {
|
|
2322
|
+
this._commitEditToSelection();
|
|
2323
|
+
break;
|
|
2324
|
+
}
|
|
2325
|
+
this._commitEdit(), this._selection.move(e.shiftKey ? -1 : 1, 0), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
1933
2326
|
break;
|
|
1934
2327
|
case "Tab":
|
|
1935
2328
|
e.preventDefault(), this._exitRefMode(), this._commitEdit(), e.shiftKey ? this._selection.move(0, -1) : this._selection.move(0, 1), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
@@ -1946,6 +2339,45 @@ var G = class extends e {
|
|
|
1946
2339
|
case "F4": this._editValue.startsWith("=") && (e.preventDefault(), this._cycleReferenceMode());
|
|
1947
2340
|
}
|
|
1948
2341
|
}
|
|
2342
|
+
_isCellFilled(e, t) {
|
|
2343
|
+
let n = this._internalData.get(y(e, t));
|
|
2344
|
+
return n !== void 0 && n.rawValue !== "";
|
|
2345
|
+
}
|
|
2346
|
+
_selectWholeRowsOrColumns(e, t) {
|
|
2347
|
+
let n = this._selection, r = n.activeCell;
|
|
2348
|
+
e && t ? n.selectAll() : e ? n.selectColumns(n.anchor.col, n.head.col, r) : n.selectRows(n.anchor.row, n.head.row, r), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
2349
|
+
}
|
|
2350
|
+
_handleHeaderPointerDown(e) {
|
|
2351
|
+
if (e.button !== 0) return;
|
|
2352
|
+
let t = e.target.closest("[data-header-col], [data-header-row]");
|
|
2353
|
+
if (!t) return;
|
|
2354
|
+
e.preventDefault(), this._isEditing && this._commitEdit();
|
|
2355
|
+
let n = t.dataset.headerCol !== void 0, r = n ? "headerCol" : "headerRow", i = parseInt(t.dataset[r], 10), a = this._selection, o = e.shiftKey ? n ? a.anchor.col : a.anchor.row : i, s = (t) => {
|
|
2356
|
+
let r = Math.min(o, t), i = Math.max(o, t), s = a.activeCell;
|
|
2357
|
+
if (n) {
|
|
2358
|
+
let n = e.shiftKey && s.col >= r && s.col <= i ? s.col : o;
|
|
2359
|
+
a.selectColumns(o, t, {
|
|
2360
|
+
row: s.row,
|
|
2361
|
+
col: n
|
|
2362
|
+
});
|
|
2363
|
+
} else {
|
|
2364
|
+
let n = e.shiftKey && s.row >= r && s.row <= i ? s.row : o;
|
|
2365
|
+
a.selectRows(o, t, {
|
|
2366
|
+
row: n,
|
|
2367
|
+
col: s.col
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2370
|
+
this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
2371
|
+
};
|
|
2372
|
+
s(i);
|
|
2373
|
+
let c = new AbortController(), { signal: l } = c, u = i, d = (e) => {
|
|
2374
|
+
let t = (this.shadowRoot?.elementFromPoint(e.clientX, e.clientY))?.closest?.(n ? "[data-header-col]" : "[data-header-row]");
|
|
2375
|
+
if (!t) return;
|
|
2376
|
+
let i = parseInt(t.dataset[r], 10);
|
|
2377
|
+
i !== u && (u = i, s(i));
|
|
2378
|
+
}, f = () => c.abort();
|
|
2379
|
+
document.addEventListener("pointermove", d, { signal: l }), document.addEventListener("pointerup", f, { signal: l }), document.addEventListener("pointercancel", f, { signal: l }), window.addEventListener("blur", f, { signal: l });
|
|
2380
|
+
}
|
|
1949
2381
|
_handleSelectAll() {
|
|
1950
2382
|
this._selection.selectAll(), this._dispatchSelectionChange(), this.updateComplete.then(() => this._focusActiveCell());
|
|
1951
2383
|
}
|
|
@@ -1992,51 +2424,17 @@ var G = class extends e {
|
|
|
1992
2424
|
if (this.readOnly || this._pasteInProgress) return;
|
|
1993
2425
|
let { row: e, col: t } = this._selection.range.start, n = await this._clipboardManager.paste(e, t, this.rows, this.cols);
|
|
1994
2426
|
if (!n || n.length === 0) return;
|
|
1995
|
-
let r = this._snapshotSelection(), i = n.map((e) => ({
|
|
2427
|
+
let r = this._snapshotSelection(), i = this._buildCellBatch(n.map((e) => ({
|
|
1996
2428
|
id: e.id,
|
|
1997
|
-
value: e.value
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
selectionBefore: r,
|
|
2002
|
-
selectionAfter: r,
|
|
2003
|
-
operation: "paste"
|
|
2004
|
-
};
|
|
2005
|
-
let o = new Map(n.map((e) => [e.id, e]));
|
|
2006
|
-
for (let e of a.deltas) {
|
|
2007
|
-
let t = o.get(e.id);
|
|
2008
|
-
if (t?.format) {
|
|
2009
|
-
let n = this._internalData.get(e.id);
|
|
2010
|
-
e.formatBefore = n?.format ? { ...n.format } : void 0, e.formatAfter = t.format;
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
let s = new Set(a.deltas.map((e) => e.id));
|
|
2014
|
-
for (let e of n) if (e.format && !s.has(e.id)) {
|
|
2015
|
-
let t = this._internalData.get(e.id);
|
|
2016
|
-
a.deltas.push({
|
|
2017
|
-
id: e.id,
|
|
2018
|
-
before: t?.rawValue ?? "",
|
|
2019
|
-
after: e.value,
|
|
2020
|
-
formatBefore: t?.format ? { ...t.format } : void 0,
|
|
2021
|
-
formatAfter: e.format
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
2024
|
-
if (a.deltas.length !== 0) {
|
|
2025
|
-
if (a.deltas.length <= V.PASTE_CHUNK_SIZE) this._executeUserBatch(a);
|
|
2026
|
-
else {
|
|
2027
|
-
this._pasteInProgress = !0;
|
|
2028
|
-
try {
|
|
2029
|
-
await this._applyBatchProgressive(a), this._pushHistory(a);
|
|
2030
|
-
} finally {
|
|
2031
|
-
this._pasteInProgress = !1;
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2429
|
+
value: e.value,
|
|
2430
|
+
format: e.format
|
|
2431
|
+
})), "paste", r);
|
|
2432
|
+
i && await this._runUserBatch(i);
|
|
2035
2433
|
}
|
|
2036
2434
|
_applyBatchProgressive(e) {
|
|
2037
2435
|
return new Promise((t) => {
|
|
2038
2436
|
let n = e.deltas, r = 0, i = () => {
|
|
2039
|
-
let a = Math.min(r +
|
|
2437
|
+
let a = Math.min(r + X.PASTE_CHUNK_SIZE, n.length);
|
|
2040
2438
|
for (let e = r; e < a; e++) {
|
|
2041
2439
|
let t = n[e];
|
|
2042
2440
|
this._applyRawValueByString(t.id, t.after), "formatAfter" in t && this._applyCellFormat(t.id, t.formatAfter);
|
|
@@ -2050,7 +2448,7 @@ var G = class extends e {
|
|
|
2050
2448
|
if (this._pasteInProgress) return;
|
|
2051
2449
|
let e = this._selection.range, t = [], n = this._snapshotSelection();
|
|
2052
2450
|
for (let n = e.start.row; n <= e.end.row; n++) for (let r = e.start.col; r <= e.end.col; r++) {
|
|
2053
|
-
let e =
|
|
2451
|
+
let e = y(n, r);
|
|
2054
2452
|
this._internalData.has(e) && t.push({
|
|
2055
2453
|
id: e,
|
|
2056
2454
|
value: ""
|
|
@@ -2059,6 +2457,46 @@ var G = class extends e {
|
|
|
2059
2457
|
let r = this._buildCommandBatch(t, "clear", n, n);
|
|
2060
2458
|
r && this._executeUserBatch(r);
|
|
2061
2459
|
}
|
|
2460
|
+
_fillSelection(e) {
|
|
2461
|
+
if (this.readOnly || this._pasteInProgress) return;
|
|
2462
|
+
let { start: t, end: n } = this._selection.range, r = e === "down", i = r ? t.row : t.col, a = r ? n.row : n.col;
|
|
2463
|
+
if (a === i) {
|
|
2464
|
+
if (i === 0) return;
|
|
2465
|
+
--i;
|
|
2466
|
+
}
|
|
2467
|
+
let o = [], s = r ? t.col : t.row, c = r ? n.col : n.row;
|
|
2468
|
+
for (let e = i + 1; e <= a; e++) for (let t = s; t <= c; t++) {
|
|
2469
|
+
let n = r ? y(i, t) : y(t, i), a = r ? y(e, t) : y(t, e), s = this._internalData.get(n), c = e - i;
|
|
2470
|
+
o.push({
|
|
2471
|
+
id: a,
|
|
2472
|
+
value: this._shiftFormula(s?.rawValue ?? "", r ? c : 0, r ? 0 : c),
|
|
2473
|
+
format: s?.format ?? null
|
|
2474
|
+
});
|
|
2475
|
+
}
|
|
2476
|
+
let l = this._buildCellBatch(o, "fill", this._snapshotSelection());
|
|
2477
|
+
l && this._runUserBatch(l);
|
|
2478
|
+
}
|
|
2479
|
+
_shiftFormula(e, t, n) {
|
|
2480
|
+
return !e.startsWith("=") || t === 0 && n === 0 ? e : this._clipboardManager.adjustFormulaReferences(e, t, n);
|
|
2481
|
+
}
|
|
2482
|
+
_commitEditToSelection() {
|
|
2483
|
+
if (!this._isEditing || !this._editingCellKey) return;
|
|
2484
|
+
let e = b(this._editingCellKey), t = this._editValue, { start: n, end: r } = this._selection.range;
|
|
2485
|
+
if (n.row === r.row && n.col === r.col) {
|
|
2486
|
+
this._commitEdit();
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
this._isEditing = !1, this._editingCellKey = null;
|
|
2490
|
+
let i = [];
|
|
2491
|
+
for (let a = n.row; a <= r.row; a++) for (let o = n.col; o <= r.col; o++) i.push({
|
|
2492
|
+
id: y(a, o),
|
|
2493
|
+
value: this._shiftFormula(t, a - e.row, o - e.col)
|
|
2494
|
+
});
|
|
2495
|
+
let a = i.length;
|
|
2496
|
+
this._modeAnnouncement = `Filled ${a} cells`;
|
|
2497
|
+
let o = this._buildCellBatch(i, "fill", this._snapshotSelection());
|
|
2498
|
+
o && this._runUserBatch(o), this.updateComplete.then(() => this._focusActiveCell());
|
|
2499
|
+
}
|
|
2062
2500
|
_handleScroll(e) {
|
|
2063
2501
|
let t = e.target;
|
|
2064
2502
|
this._scrollTop = t.scrollTop, this._scrollLeft = t.scrollLeft;
|
|
@@ -2077,8 +2515,8 @@ var G = class extends e {
|
|
|
2077
2515
|
let t;
|
|
2078
2516
|
if (this._editingCellKey) t = this._editingCellKey;
|
|
2079
2517
|
else {
|
|
2080
|
-
let n =
|
|
2081
|
-
t = n ?
|
|
2518
|
+
let n = C(e.detail.cellRef);
|
|
2519
|
+
t = n ? y(n.row, n.col) : this._getActiveCellKey();
|
|
2082
2520
|
}
|
|
2083
2521
|
this._isEditing && (this._isEditing = !1, this._editingCellKey = null), this._commitRawValue(t, e.detail.value);
|
|
2084
2522
|
}
|
|
@@ -2112,16 +2550,16 @@ var G = class extends e {
|
|
|
2112
2550
|
}));
|
|
2113
2551
|
}
|
|
2114
2552
|
_getVisibleRange() {
|
|
2115
|
-
let e = this._getCSSVarPx("--ls-cell-height", 28), t = this._getCSSVarPx("--ls-cell-width", 100), n = this._grid, r = n?.clientHeight || e *
|
|
2553
|
+
let e = this._getCSSVarPx("--ls-cell-height", 28), t = this._getCSSVarPx("--ls-cell-width", 100), n = this._grid, r = n?.clientHeight || e * X.INITIAL_VIEW_ROWS, i = n?.clientWidth || t * X.INITIAL_VIEW_COLS, a = Math.max(0, Math.floor(this._scrollTop / e) - 5), o = Math.min(this.rows, Math.ceil((this._scrollTop + r) / e) + 5), s = Math.max(0, Math.floor(this._scrollLeft / t) - 5), c = Math.min(this.cols, Math.ceil((this._scrollLeft + i) / t) + 5), { row: l, col: u } = this._selection.activeCell, d = [l], f = [u];
|
|
2116
2554
|
return this._refMode && (d.push(this._refCursorRow), f.push(this._refCursorCol)), {
|
|
2117
|
-
rows:
|
|
2118
|
-
cols:
|
|
2555
|
+
rows: fe(a, o, d),
|
|
2556
|
+
cols: fe(s, c, f)
|
|
2119
2557
|
};
|
|
2120
2558
|
}
|
|
2121
2559
|
_ensureCellVisible(e, t) {
|
|
2122
2560
|
let n = this._grid;
|
|
2123
2561
|
if (!n) return;
|
|
2124
|
-
let r = this._getCSSVarPx("--ls-cell-height", 28), i = this._getCSSVarPx("--ls-cell-width", 100), a = n.clientHeight || r *
|
|
2562
|
+
let r = this._getCSSVarPx("--ls-cell-height", 28), i = this._getCSSVarPx("--ls-cell-width", 100), a = n.clientHeight || r * X.INITIAL_VIEW_ROWS, o = n.clientWidth || i * X.INITIAL_VIEW_COLS, s = Math.max(i, o - X.ROW_HEADER_WIDTH), c = Math.max(r, a - r), l = e * r, u = l + r, d = t * i, f = d + i, p = this._scrollTop;
|
|
2125
2563
|
l < p ? p = l : u > p + c && (p = u - c);
|
|
2126
2564
|
let m = this._scrollLeft;
|
|
2127
2565
|
d < m ? m = d : f > m + s && (m = f - s), (p !== this._scrollTop || m !== this._scrollLeft) && (this._scrollTop = p, this._scrollLeft = m, n.scrollTop = p, n.scrollLeft = m);
|
|
@@ -2136,7 +2574,7 @@ var G = class extends e {
|
|
|
2136
2574
|
}
|
|
2137
2575
|
_getEditorStyle() {
|
|
2138
2576
|
if (!this._isEditing) return { display: "none" };
|
|
2139
|
-
let { row: e, col: t } = this._selection.activeCell, n = this._getCSSVarPx("--ls-cell-height", 28), r = this._getCSSVarPx("--ls-cell-width", 100), i =
|
|
2577
|
+
let { row: e, col: t } = this._selection.activeCell, n = this._getCSSVarPx("--ls-cell-height", 28), r = this._getCSSVarPx("--ls-cell-width", 100), i = X.ROW_HEADER_WIDTH, a = (e + 1) * n - this._scrollTop, o = i + t * r - this._scrollLeft, s = {
|
|
2140
2578
|
display: "block",
|
|
2141
2579
|
position: "absolute",
|
|
2142
2580
|
top: `${a}px`,
|
|
@@ -2145,7 +2583,13 @@ var G = class extends e {
|
|
|
2145
2583
|
height: `${n}px`,
|
|
2146
2584
|
"z-index": "10"
|
|
2147
2585
|
}, c = this._getCellStyles(e, t);
|
|
2148
|
-
for (let [e, t] of Object.entries(c))
|
|
2586
|
+
for (let [e, t] of Object.entries(c)) [
|
|
2587
|
+
"justify-content",
|
|
2588
|
+
"background-color",
|
|
2589
|
+
"align-items",
|
|
2590
|
+
"white-space",
|
|
2591
|
+
"overflow-wrap"
|
|
2592
|
+
].includes(e) || (s[e] = t);
|
|
2149
2593
|
return s;
|
|
2150
2594
|
}
|
|
2151
2595
|
static {
|
|
@@ -2234,6 +2678,16 @@ var G = class extends e {
|
|
|
2234
2678
|
scroll-snap-align: start;
|
|
2235
2679
|
}
|
|
2236
2680
|
|
|
2681
|
+
.ls-col-header,
|
|
2682
|
+
.ls-row-header {
|
|
2683
|
+
cursor: pointer;
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
.ls-col-header.in-selection,
|
|
2687
|
+
.ls-row-header.in-selection {
|
|
2688
|
+
background: var(--ls-header-selected-bg, #dbe7fb);
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2237
2691
|
.ls-row-header {
|
|
2238
2692
|
position: sticky;
|
|
2239
2693
|
left: 0;
|
|
@@ -2376,6 +2830,7 @@ var G = class extends e {
|
|
|
2376
2830
|
return n`<div style="grid-column: span ${e};"></div>`;
|
|
2377
2831
|
}
|
|
2378
2832
|
_renderHeaderRow(e) {
|
|
2833
|
+
let t = this._selection.range, i = t.start.row === 0 && t.end.row === this.rows - 1;
|
|
2379
2834
|
return n`
|
|
2380
2835
|
<div class="ls-header-row" role="row" aria-rowindex="1">
|
|
2381
2836
|
<div
|
|
@@ -2387,21 +2842,24 @@ var G = class extends e {
|
|
|
2387
2842
|
@click="${this._handleSelectAll}"
|
|
2388
2843
|
@keydown="${this._handleCornerKeydown}"
|
|
2389
2844
|
><span class="sr-only">Select all</span></div>
|
|
2390
|
-
${
|
|
2845
|
+
${Z(e, this.cols, (e) => n`
|
|
2391
2846
|
<div
|
|
2392
|
-
class="ls-col-header"
|
|
2847
|
+
class="ls-col-header ${e >= t.start.col && e <= t.end.col ? "in-selection" : ""}"
|
|
2393
2848
|
role="columnheader"
|
|
2394
2849
|
aria-colindex="${e + 2}"
|
|
2395
|
-
aria-label="Column ${
|
|
2850
|
+
aria-label="Column ${x(e)}"
|
|
2851
|
+
aria-selected="${i && e >= t.start.col && e <= t.end.col ? "true" : r}"
|
|
2852
|
+
data-header-col="${e}"
|
|
2853
|
+
@pointerdown="${this._handleHeaderPointerDown}"
|
|
2396
2854
|
>
|
|
2397
|
-
${
|
|
2855
|
+
${x(e)}
|
|
2398
2856
|
</div>
|
|
2399
2857
|
`, (e, t) => this._renderColumnSpacer(t))}
|
|
2400
2858
|
</div>
|
|
2401
2859
|
`;
|
|
2402
2860
|
}
|
|
2403
2861
|
_renderRows(e, t) {
|
|
2404
|
-
let r = this._getCSSVarPx("--ls-cell-height", 28), i =
|
|
2862
|
+
let r = this._getCSSVarPx("--ls-cell-height", 28), i = Z(e, this.rows, (e) => ({
|
|
2405
2863
|
key: `r${e}`,
|
|
2406
2864
|
row: e,
|
|
2407
2865
|
gap: 0
|
|
@@ -2415,7 +2873,7 @@ var G = class extends e {
|
|
|
2415
2873
|
`;
|
|
2416
2874
|
}
|
|
2417
2875
|
_renderCell(e, t) {
|
|
2418
|
-
let i = this._selection.isCellSelected(e, t), a = this._selection.isCellActive(e, t), o = this._refMode && e === this._refCursorRow && t === this._refCursorCol, s = this._getCellDisplay(e, t), c =
|
|
2876
|
+
let i = this._selection.isCellSelected(e, t), a = this._selection.isCellActive(e, t), o = this._refMode && e === this._refCursorRow && t === this._refCursorCol, s = this._getCellDisplay(e, t), c = y(e, t), u = this._getCellStyles(e, t);
|
|
2419
2877
|
return n`
|
|
2420
2878
|
<div
|
|
2421
2879
|
class="ls-cell ${a ? "active-cell" : ""} ${o ? "ref-highlight" : ""}"
|
|
@@ -2437,15 +2895,19 @@ var G = class extends e {
|
|
|
2437
2895
|
`;
|
|
2438
2896
|
}
|
|
2439
2897
|
_renderRow(e, t) {
|
|
2898
|
+
let i = this._selection.range, a = e >= i.start.row && e <= i.end.row, o = a && i.start.col === 0 && i.end.col === this.cols - 1;
|
|
2440
2899
|
return n`
|
|
2441
2900
|
<div class="ls-row" role="row" aria-rowindex="${e + 2}">
|
|
2442
2901
|
<div
|
|
2443
|
-
class="ls-row-header"
|
|
2902
|
+
class="ls-row-header ${a ? "in-selection" : ""}"
|
|
2444
2903
|
role="rowheader"
|
|
2445
2904
|
aria-colindex="1"
|
|
2446
2905
|
aria-label="Row ${e + 1}"
|
|
2906
|
+
aria-selected="${o ? "true" : r}"
|
|
2907
|
+
data-header-row="${e}"
|
|
2908
|
+
@pointerdown="${this._handleHeaderPointerDown}"
|
|
2447
2909
|
>${e + 1}</div>
|
|
2448
|
-
${c(
|
|
2910
|
+
${c(Z(t, this.cols, (t) => ({
|
|
2449
2911
|
key: `c${t}`,
|
|
2450
2912
|
tpl: this._renderCell(e, t)
|
|
2451
2913
|
}), (e, t) => ({
|
|
@@ -2456,23 +2918,31 @@ var G = class extends e {
|
|
|
2456
2918
|
`;
|
|
2457
2919
|
}
|
|
2458
2920
|
_getAnnouncement(e) {
|
|
2459
|
-
let t = `${
|
|
2460
|
-
|
|
2921
|
+
let t = `${x(e.col)}${e.row + 1}`, n = this._getCellDisplay(e.row, e.col), r = n ? `${t}: ${n}` : t, i = this._selection.range, a = i.end.row - i.start.row + 1, o = i.end.col - i.start.col + 1;
|
|
2922
|
+
if (a > 1 || o > 1) {
|
|
2923
|
+
let e = a === this.rows, t = o === this.cols;
|
|
2924
|
+
if (e && !t) {
|
|
2925
|
+
let e = x(i.start.col);
|
|
2926
|
+
return `${r}, ${o > 1 ? `Columns ${e} to ${x(i.end.col)}` : `Column ${e}`} selected`;
|
|
2927
|
+
}
|
|
2928
|
+
return t && !e ? `${r}, ${a > 1 ? `Rows ${i.start.row + 1} to ${i.end.row + 1}` : `Row ${i.start.row + 1}`} selected` : `${r}, ${a} row${a > 1 ? "s" : ""}, ${o} column${o > 1 ? "s" : ""} selected`;
|
|
2929
|
+
}
|
|
2930
|
+
return r;
|
|
2461
2931
|
}
|
|
2462
2932
|
updated() {
|
|
2463
2933
|
this._isEditing && this._editor && (this._editor.focus(), this._refMode ? this._editor.setSelectionRange(this._refInsertEnd, this._refInsertEnd) : this._editorNeedsCursorReset && (this._editorNeedsCursorReset = !1, this._editor.setSelectionRange(this._editValue.length, this._editValue.length)));
|
|
2464
2934
|
}
|
|
2465
2935
|
};
|
|
2466
|
-
|
|
2936
|
+
J([a({ type: Number })], Q.prototype, "rows", void 0), J([a({ type: Number })], Q.prototype, "cols", void 0), J([a({ attribute: !1 })], Q.prototype, "data", void 0), J([a({
|
|
2467
2937
|
type: Boolean,
|
|
2468
2938
|
attribute: "read-only",
|
|
2469
2939
|
reflect: !0
|
|
2470
|
-
})],
|
|
2940
|
+
})], Q.prototype, "readOnly", void 0), J([a({
|
|
2471
2941
|
type: String,
|
|
2472
2942
|
attribute: "grid-label"
|
|
2473
|
-
})],
|
|
2943
|
+
})], Q.prototype, "gridLabel", void 0), J([a({ attribute: !1 })], Q.prototype, "functions", void 0), J([s()], Q.prototype, "_isEditing", void 0), J([s()], Q.prototype, "_editValue", void 0), J([s()], Q.prototype, "_formulaBarMode", void 0), J([s()], Q.prototype, "_refMode", void 0), J([s()], Q.prototype, "_modeAnnouncement", void 0), J([s()], Q.prototype, "_scrollTop", void 0), J([s()], Q.prototype, "_scrollLeft", void 0), J([o("#editor")], Q.prototype, "_editor", void 0), J([o(".ls-grid")], Q.prototype, "_grid", void 0), Q = X = J([i("y11n-spreadsheet")], Q);
|
|
2474
2944
|
// src/components/y11n-format-toolbar.ts
|
|
2475
|
-
var
|
|
2945
|
+
var $ = class extends e {
|
|
2476
2946
|
constructor(...e) {
|
|
2477
2947
|
super(...e), this.bold = !1, this.italic = !1, this.underline = !1, this.strikethrough = !1, this.textColor = "#000000", this.backgroundColor = "#ffffff", this.textAlign = "left", this.fontSize = 13, this.readOnly = !1;
|
|
2478
2948
|
}
|
|
@@ -2821,12 +3291,12 @@ var K = class extends e {
|
|
|
2821
3291
|
`;
|
|
2822
3292
|
}
|
|
2823
3293
|
};
|
|
2824
|
-
|
|
3294
|
+
J([a({ type: Boolean })], $.prototype, "bold", void 0), J([a({ type: Boolean })], $.prototype, "italic", void 0), J([a({ type: Boolean })], $.prototype, "underline", void 0), J([a({ type: Boolean })], $.prototype, "strikethrough", void 0), J([a({ type: String })], $.prototype, "textColor", void 0), J([a({ type: String })], $.prototype, "backgroundColor", void 0), J([a({ type: String })], $.prototype, "textAlign", void 0), J([a({ type: Number })], $.prototype, "fontSize", void 0), J([a({
|
|
2825
3295
|
type: Boolean,
|
|
2826
3296
|
attribute: "read-only",
|
|
2827
3297
|
reflect: !0
|
|
2828
|
-
})],
|
|
2829
|
-
function
|
|
3298
|
+
})], $.prototype, "readOnly", void 0), $ = J([i("y11n-format-toolbar")], $);
|
|
3299
|
+
function me(e, t) {
|
|
2830
3300
|
let n, r, i, a, o, s, c, l, u = !0;
|
|
2831
3301
|
for (let d = t.start.row; d <= t.end.row; d++) for (let f = t.start.col; f <= t.end.col; f++) {
|
|
2832
3302
|
let t = e(`${d}:${f}`)?.format;
|
|
@@ -2835,4 +3305,4 @@ function q(e, t) {
|
|
|
2835
3305
|
let d = {};
|
|
2836
3306
|
return n && (d.bold = !0), r && (d.italic = !0), i && (d.underline = !0), a && (d.strikethrough = !0), o !== void 0 && (d.textColor = o), s !== void 0 && (d.backgroundColor = s), c !== void 0 && (d.textAlign = c), l !== void 0 && (d.fontSize = l), d;
|
|
2837
3307
|
}
|
|
2838
|
-
export {
|
|
3308
|
+
export { q as ClipboardManager, K as FormulaEngine, R as RangeValue, T as SelectionManager, $ as Y11nFormatToolbar, Y as Y11nFormulaBar, Q as Y11nSpreadsheet, y as cellKey, x as colToLetter, me as computeSelectionFormat, w as coordToRef, h as dateSerialToDate, g as dateToSerial, te as findDataEdge, f as formatNumber, u as formatsEqual, S as letterToCol, E as parseDelimited, b as parseKey, D as quoteDelimitedField, C as refToCoord, O as serializeDelimited };
|