@extable/core 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.css +1 -1
- package/dist/dataModel.d.ts +6 -0
- package/dist/geometry.d.ts +3 -0
- package/dist/index.js +1117 -1011
- package/dist/index.js.map +1 -1
- package/dist/numberIO-BMnYEoog.js +1011 -0
- package/dist/numberIO-BMnYEoog.js.map +1 -0
- package/dist/numberIO-C1R2zgBN.js +1010 -0
- package/dist/numberIO-C1R2zgBN.js.map +1 -0
- package/dist/numberIO-CGTV3-KW.js +1017 -0
- package/dist/numberIO-CGTV3-KW.js.map +1 -0
- package/dist/selectionManager.d.ts +10 -2
- package/dist/ssr/index.js +1 -1
- package/dist/types.d.ts +8 -1
- package/package.json +2 -2
- package/src/styles.css +14 -0
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { D as ft, R as
|
|
2
|
-
function
|
|
1
|
+
import { D as ft, R as lt, g as Y, c as Ft, s as ne, r as O, m as rt, a as pt, b as mt, d as ct, e as ht, t as $e, C as at, f as Mt, h as Rt, i as Ot, j as Kt, k as de, H as st, l as ut, p as We, n as Vt, o as se, q as le, u as Oe, v as je, w as qe, x as re, y as ze } from "./numberIO-CGTV3-KW.js";
|
|
2
|
+
function Ue(c) {
|
|
3
3
|
const t = c.payload;
|
|
4
4
|
if (!t) return null;
|
|
5
5
|
const e = t.batchId;
|
|
6
6
|
return typeof e == "string" && e.length ? e : null;
|
|
7
7
|
}
|
|
8
|
-
class
|
|
8
|
+
class Xe {
|
|
9
9
|
constructor(t = 100) {
|
|
10
10
|
this.applied = [], this.undone = [], this.cap = t;
|
|
11
11
|
}
|
|
12
12
|
enqueue(t) {
|
|
13
|
-
const e =
|
|
13
|
+
const e = Ue(t), i = this.applied.at(-1);
|
|
14
14
|
for (e && i && i.batchId === e ? i.commands.push(t) : this.applied.push({ batchId: e, commands: [t] }); this.applied.length > this.cap; ) this.applied.shift();
|
|
15
15
|
this.undone = [];
|
|
16
16
|
}
|
|
@@ -43,7 +43,7 @@ class Ue {
|
|
|
43
43
|
this.applied = [], this.undone = [];
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function Ge(c, t) {
|
|
47
47
|
const e = c.getSchema(), i = c.listRows(), o = (s, l) => {
|
|
48
48
|
if (!Number.isInteger(s) || !Number.isInteger(l) || s < 0 || s >= i.length || l < 0 || l >= e.columns.length) return null;
|
|
49
49
|
const a = i[s], r = e.columns[l];
|
|
@@ -51,7 +51,7 @@ function ze(c, t) {
|
|
|
51
51
|
}, n = (s, l) => {
|
|
52
52
|
const a = c.getRowIndex(s);
|
|
53
53
|
if (a < 0) return null;
|
|
54
|
-
const r = e.columns.findIndex((
|
|
54
|
+
const r = e.columns.findIndex((h) => h.key === l);
|
|
55
55
|
return r < 0 ? null : { rowId: s, colKey: l, rowIndex: a, colIndex: r };
|
|
56
56
|
};
|
|
57
57
|
if ("rowId" in t && "colKey" in t)
|
|
@@ -68,7 +68,7 @@ function ze(c, t) {
|
|
|
68
68
|
}
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
|
-
class
|
|
71
|
+
class Ye {
|
|
72
72
|
constructor(t, e, i) {
|
|
73
73
|
this.lockedRows = /* @__PURE__ */ new Set(), this.mode = "none", this.mode = t, this.server = e, this.user = i;
|
|
74
74
|
}
|
|
@@ -109,7 +109,7 @@ class Xe {
|
|
|
109
109
|
return new Set(this.lockedRows);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const xt = (c) => c.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "), Qe = (c) => {
|
|
113
113
|
const t = [];
|
|
114
114
|
if (c)
|
|
115
115
|
for (const e of c) {
|
|
@@ -117,7 +117,7 @@ const bt = (c) => c.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "),
|
|
|
117
117
|
!i || t.includes(i) || t.push(i);
|
|
118
118
|
}
|
|
119
119
|
return t.length === 0 ? t.push("en") : t.includes("en") || t.push("en"), t;
|
|
120
|
-
},
|
|
120
|
+
}, Je = (c, t) => {
|
|
121
121
|
const e = c.items.indexOf(t);
|
|
122
122
|
if (e !== -1)
|
|
123
123
|
return e;
|
|
@@ -128,17 +128,17 @@ const bt = (c) => c.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "),
|
|
|
128
128
|
return null;
|
|
129
129
|
const o = c.items.indexOf(i);
|
|
130
130
|
return o === -1 ? null : o;
|
|
131
|
-
},
|
|
132
|
-
const e =
|
|
133
|
-
if (
|
|
131
|
+
}, Ze = (c, t) => {
|
|
132
|
+
const e = xt(t);
|
|
133
|
+
if (xt(c.id).includes(e))
|
|
134
134
|
return !0;
|
|
135
135
|
for (const i of c.items)
|
|
136
|
-
if (
|
|
136
|
+
if (xt(i).includes(e))
|
|
137
137
|
return !0;
|
|
138
138
|
return c.aliases ? Object.keys(c.aliases).some(
|
|
139
|
-
(i) =>
|
|
139
|
+
(i) => xt(i).includes(e)
|
|
140
140
|
) : !1;
|
|
141
|
-
},
|
|
141
|
+
}, ti = (c, t) => {
|
|
142
142
|
if (c.langs.length === 0)
|
|
143
143
|
return 0;
|
|
144
144
|
let e = Number.POSITIVE_INFINITY;
|
|
@@ -147,10 +147,10 @@ const bt = (c) => c.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "),
|
|
|
147
147
|
o !== -1 && o < e && (e = o);
|
|
148
148
|
}
|
|
149
149
|
return e;
|
|
150
|
-
},
|
|
151
|
-
class
|
|
150
|
+
}, ei = (c, t) => !c.langs || c.langs.length === 0 ? !0 : c.langs.some((e) => t.includes(e));
|
|
151
|
+
class ii {
|
|
152
152
|
constructor(t) {
|
|
153
|
-
this.lists = [], this.matchers = [], this.langs =
|
|
153
|
+
this.lists = [], this.matchers = [], this.langs = Qe(t?.langs);
|
|
154
154
|
}
|
|
155
155
|
register(t) {
|
|
156
156
|
const e = this.lists.findIndex((i) => i.id === t.id);
|
|
@@ -170,7 +170,7 @@ class ti {
|
|
|
170
170
|
e = e.filter((n) => o.has(n.id));
|
|
171
171
|
}
|
|
172
172
|
const i = t?.queryText;
|
|
173
|
-
return i && (e = e.filter((o) =>
|
|
173
|
+
return i && (e = e.filter((o) => Ze(o, i))), e;
|
|
174
174
|
}
|
|
175
175
|
match(t, e) {
|
|
176
176
|
if (t.length === 0)
|
|
@@ -178,7 +178,7 @@ class ti {
|
|
|
178
178
|
let i = null, o = Number.NEGATIVE_INFINITY;
|
|
179
179
|
const n = e?.enabledIds ? new Set(e.enabledIds) : null;
|
|
180
180
|
for (const l of this.matchers) {
|
|
181
|
-
if (n && !n.has(l.id) || !
|
|
181
|
+
if (n && !n.has(l.id) || !ei(l, this.langs))
|
|
182
182
|
continue;
|
|
183
183
|
const a = l.match(t);
|
|
184
184
|
if (!a)
|
|
@@ -191,29 +191,29 @@ class ti {
|
|
|
191
191
|
state: a.state
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
const s = this.list(e).map((l) => ({ list: l, rank:
|
|
194
|
+
const s = this.list(e).map((l) => ({ list: l, rank: ti(l, this.langs) })).filter((l) => Number.isFinite(l.rank)).sort((l, a) => l.rank - a.rank);
|
|
195
195
|
for (const { list: l, rank: a } of s) {
|
|
196
196
|
const r = [];
|
|
197
|
-
let
|
|
197
|
+
let h = !1;
|
|
198
198
|
for (const p of t) {
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
201
|
-
|
|
199
|
+
const m = Je(l, p);
|
|
200
|
+
if (m === null) {
|
|
201
|
+
h = !0;
|
|
202
202
|
break;
|
|
203
203
|
}
|
|
204
|
-
r.push(
|
|
204
|
+
r.push(m);
|
|
205
205
|
}
|
|
206
|
-
if (
|
|
206
|
+
if (h)
|
|
207
207
|
continue;
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
208
|
+
const d = this.inferStep(l, r);
|
|
209
|
+
if (d === null)
|
|
210
210
|
continue;
|
|
211
211
|
const u = 10 - a;
|
|
212
212
|
u > o && (o = u, i = {
|
|
213
213
|
kind: "list",
|
|
214
214
|
list: l,
|
|
215
215
|
startIndex: r[r.length - 1] ?? 0,
|
|
216
|
-
step:
|
|
216
|
+
step: d
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
return i;
|
|
@@ -244,12 +244,12 @@ class ti {
|
|
|
244
244
|
return n >= e ? null : n;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
const
|
|
247
|
+
const oi = {
|
|
248
248
|
id: "weekdays-en-long",
|
|
249
249
|
mode: "cycle",
|
|
250
250
|
langs: ["en"],
|
|
251
251
|
items: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
|
252
|
-
},
|
|
252
|
+
}, ni = {
|
|
253
253
|
id: "weekdays-en-short",
|
|
254
254
|
mode: "cycle",
|
|
255
255
|
langs: ["en"],
|
|
@@ -259,22 +259,22 @@ const ei = {
|
|
|
259
259
|
Thur: "Thu",
|
|
260
260
|
Thurs: "Thu"
|
|
261
261
|
}
|
|
262
|
-
},
|
|
262
|
+
}, si = {
|
|
263
263
|
id: "weekdays-ja-long",
|
|
264
264
|
mode: "cycle",
|
|
265
265
|
langs: ["ja"],
|
|
266
266
|
items: ["月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日"]
|
|
267
|
-
},
|
|
267
|
+
}, li = {
|
|
268
268
|
id: "weekdays-ja-short",
|
|
269
269
|
mode: "cycle",
|
|
270
270
|
langs: ["ja"],
|
|
271
271
|
items: ["月曜", "火曜", "水曜", "木曜", "金曜", "土曜", "日曜"]
|
|
272
|
-
},
|
|
272
|
+
}, ri = {
|
|
273
273
|
id: "weekdays-ja-single",
|
|
274
274
|
mode: "cycle",
|
|
275
275
|
langs: ["ja"],
|
|
276
276
|
items: ["月", "火", "水", "木", "金", "土", "日"]
|
|
277
|
-
},
|
|
277
|
+
}, ai = {
|
|
278
278
|
id: "months-en-long",
|
|
279
279
|
mode: "cycle",
|
|
280
280
|
langs: ["en"],
|
|
@@ -292,7 +292,7 @@ const ei = {
|
|
|
292
292
|
"November",
|
|
293
293
|
"December"
|
|
294
294
|
]
|
|
295
|
-
},
|
|
295
|
+
}, ci = {
|
|
296
296
|
id: "months-en-short",
|
|
297
297
|
mode: "cycle",
|
|
298
298
|
langs: ["en"],
|
|
@@ -300,32 +300,32 @@ const ei = {
|
|
|
300
300
|
aliases: {
|
|
301
301
|
Sept: "Sep"
|
|
302
302
|
}
|
|
303
|
-
},
|
|
303
|
+
}, hi = {
|
|
304
304
|
id: "months-ja",
|
|
305
305
|
mode: "cycle",
|
|
306
306
|
langs: ["ja"],
|
|
307
307
|
items: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
|
|
308
|
-
},
|
|
308
|
+
}, di = {
|
|
309
309
|
id: "months-ja-traditional",
|
|
310
310
|
mode: "cycle",
|
|
311
311
|
langs: ["ja"],
|
|
312
312
|
items: ["睦月", "如月", "弥生", "卯月", "皐月", "水無月", "文月", "葉月", "長月", "神無月", "霜月", "師走"]
|
|
313
|
-
},
|
|
313
|
+
}, ui = {
|
|
314
314
|
id: "quarters-en",
|
|
315
315
|
mode: "cycle",
|
|
316
316
|
langs: ["en"],
|
|
317
317
|
items: ["Q1", "Q2", "Q3", "Q4"]
|
|
318
|
-
},
|
|
318
|
+
}, fi = {
|
|
319
319
|
id: "quarters-ja",
|
|
320
320
|
mode: "cycle",
|
|
321
321
|
langs: ["ja"],
|
|
322
322
|
items: ["第1四半期", "第2四半期", "第3四半期", "第4四半期"]
|
|
323
|
-
},
|
|
323
|
+
}, pi = {
|
|
324
324
|
id: "zodiac-animals-ja",
|
|
325
325
|
mode: "cycle",
|
|
326
326
|
langs: ["ja"],
|
|
327
327
|
items: ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
|
|
328
|
-
},
|
|
328
|
+
}, mi = {
|
|
329
329
|
id: "zodiac-signs-en",
|
|
330
330
|
mode: "cycle",
|
|
331
331
|
langs: ["en"],
|
|
@@ -343,7 +343,7 @@ const ei = {
|
|
|
343
343
|
"Aquarius",
|
|
344
344
|
"Pisces"
|
|
345
345
|
]
|
|
346
|
-
},
|
|
346
|
+
}, gi = {
|
|
347
347
|
id: "zodiac-signs-ja",
|
|
348
348
|
mode: "cycle",
|
|
349
349
|
langs: ["ja"],
|
|
@@ -351,7 +351,7 @@ const ei = {
|
|
|
351
351
|
aliases: {
|
|
352
352
|
さそり座: "蠍座"
|
|
353
353
|
}
|
|
354
|
-
},
|
|
354
|
+
}, yi = {
|
|
355
355
|
id: "directions-16-en",
|
|
356
356
|
mode: "cycle",
|
|
357
357
|
langs: ["en"],
|
|
@@ -373,7 +373,7 @@ const ei = {
|
|
|
373
373
|
"Northwest",
|
|
374
374
|
"North-Northwest"
|
|
375
375
|
]
|
|
376
|
-
},
|
|
376
|
+
}, wi = {
|
|
377
377
|
id: "directions-16-ja",
|
|
378
378
|
mode: "cycle",
|
|
379
379
|
langs: ["ja"],
|
|
@@ -395,7 +395,7 @@ const ei = {
|
|
|
395
395
|
"北西",
|
|
396
396
|
"北北西"
|
|
397
397
|
]
|
|
398
|
-
},
|
|
398
|
+
}, vi = {
|
|
399
399
|
id: "ampm-en",
|
|
400
400
|
mode: "cycle",
|
|
401
401
|
langs: ["en"],
|
|
@@ -404,12 +404,12 @@ const ei = {
|
|
|
404
404
|
"A.M.": "AM",
|
|
405
405
|
"P.M.": "PM"
|
|
406
406
|
}
|
|
407
|
-
},
|
|
407
|
+
}, Ci = {
|
|
408
408
|
id: "ampm-ja",
|
|
409
409
|
mode: "cycle",
|
|
410
410
|
langs: ["ja"],
|
|
411
411
|
items: ["午前", "午後"]
|
|
412
|
-
},
|
|
412
|
+
}, bi = {
|
|
413
413
|
id: "seasons-en",
|
|
414
414
|
mode: "cycle",
|
|
415
415
|
langs: ["en"],
|
|
@@ -417,17 +417,17 @@ const ei = {
|
|
|
417
417
|
aliases: {
|
|
418
418
|
Fall: "Autumn"
|
|
419
419
|
}
|
|
420
|
-
},
|
|
420
|
+
}, xi = {
|
|
421
421
|
id: "seasons-ja",
|
|
422
422
|
mode: "cycle",
|
|
423
423
|
langs: ["ja"],
|
|
424
424
|
items: ["春", "夏", "秋", "冬"]
|
|
425
|
-
},
|
|
425
|
+
}, Si = {
|
|
426
426
|
id: "solfege-ja",
|
|
427
427
|
mode: "cycle",
|
|
428
428
|
langs: ["ja"],
|
|
429
429
|
items: ["ド", "レ", "ミ", "ファ", "ソ", "ラ", "シ"]
|
|
430
|
-
},
|
|
430
|
+
}, Mi = {
|
|
431
431
|
id: "solfege-en",
|
|
432
432
|
mode: "cycle",
|
|
433
433
|
langs: ["en"],
|
|
@@ -436,7 +436,7 @@ const ei = {
|
|
|
436
436
|
So: "Sol",
|
|
437
437
|
Si: "Ti"
|
|
438
438
|
}
|
|
439
|
-
},
|
|
439
|
+
}, Ri = {
|
|
440
440
|
id: "greek-letters-en",
|
|
441
441
|
mode: "cycle",
|
|
442
442
|
langs: ["en"],
|
|
@@ -466,7 +466,7 @@ const ei = {
|
|
|
466
466
|
"Psi",
|
|
467
467
|
"Omega"
|
|
468
468
|
]
|
|
469
|
-
},
|
|
469
|
+
}, ki = {
|
|
470
470
|
id: "greek-letters-ja",
|
|
471
471
|
mode: "cycle",
|
|
472
472
|
langs: ["ja"],
|
|
@@ -496,7 +496,7 @@ const ei = {
|
|
|
496
496
|
"プサイ",
|
|
497
497
|
"オメガ"
|
|
498
498
|
]
|
|
499
|
-
},
|
|
499
|
+
}, Ii = {
|
|
500
500
|
id: "greek-letters-symbols",
|
|
501
501
|
mode: "cycle",
|
|
502
502
|
langs: ["en", "ja"],
|
|
@@ -529,37 +529,37 @@ const ei = {
|
|
|
529
529
|
aliases: {
|
|
530
530
|
ς: "σ"
|
|
531
531
|
}
|
|
532
|
-
},
|
|
532
|
+
}, Ti = {
|
|
533
533
|
id: "rokuyo-ja",
|
|
534
534
|
mode: "cycle",
|
|
535
535
|
langs: ["ja"],
|
|
536
536
|
items: ["先勝", "友引", "先負", "仏滅", "大安", "赤口"]
|
|
537
|
-
},
|
|
537
|
+
}, Ei = {
|
|
538
538
|
id: "heavenly-stems-ja",
|
|
539
539
|
mode: "finite",
|
|
540
540
|
langs: ["ja"],
|
|
541
541
|
items: ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
|
|
542
|
-
},
|
|
542
|
+
}, Ai = {
|
|
543
543
|
id: "planets-en",
|
|
544
544
|
mode: "finite",
|
|
545
545
|
langs: ["en"],
|
|
546
546
|
items: ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
|
|
547
|
-
},
|
|
547
|
+
}, Hi = {
|
|
548
548
|
id: "planets-ja",
|
|
549
549
|
mode: "finite",
|
|
550
550
|
langs: ["ja"],
|
|
551
551
|
items: ["水星", "金星", "地球", "火星", "木星", "土星", "天王星", "海王星"]
|
|
552
|
-
},
|
|
552
|
+
}, Li = {
|
|
553
553
|
id: "kuji-in-ja",
|
|
554
554
|
mode: "finite",
|
|
555
555
|
langs: ["ja"],
|
|
556
556
|
items: ["臨", "兵", "闘", "者", "皆", "陣", "烈", "在", "前"]
|
|
557
|
-
},
|
|
557
|
+
}, Di = {
|
|
558
558
|
id: "eight-virtues-ja",
|
|
559
559
|
mode: "finite",
|
|
560
560
|
langs: ["ja"],
|
|
561
561
|
items: ["仁", "義", "礼", "智", "忠", "信", "孝", "悌"]
|
|
562
|
-
},
|
|
562
|
+
}, Ki = {
|
|
563
563
|
id: "element-symbols",
|
|
564
564
|
mode: "finite",
|
|
565
565
|
langs: ["ja", "en"],
|
|
@@ -683,7 +683,7 @@ const ei = {
|
|
|
683
683
|
"Ts",
|
|
684
684
|
"Og"
|
|
685
685
|
]
|
|
686
|
-
},
|
|
686
|
+
}, _i = {
|
|
687
687
|
id: "element-names-ja",
|
|
688
688
|
mode: "finite",
|
|
689
689
|
langs: ["ja"],
|
|
@@ -807,7 +807,7 @@ const ei = {
|
|
|
807
807
|
"テネシン",
|
|
808
808
|
"オガネソン"
|
|
809
809
|
]
|
|
810
|
-
},
|
|
810
|
+
}, Fi = {
|
|
811
811
|
id: "shoguns-kamakura-ja",
|
|
812
812
|
mode: "finite",
|
|
813
813
|
langs: ["ja"],
|
|
@@ -822,7 +822,7 @@ const ei = {
|
|
|
822
822
|
"久明親王",
|
|
823
823
|
"守邦親王"
|
|
824
824
|
]
|
|
825
|
-
},
|
|
825
|
+
}, Vi = {
|
|
826
826
|
id: "shoguns-ashikaga-ja",
|
|
827
827
|
mode: "finite",
|
|
828
828
|
langs: ["ja"],
|
|
@@ -843,7 +843,7 @@ const ei = {
|
|
|
843
843
|
"足利義栄",
|
|
844
844
|
"足利義昭"
|
|
845
845
|
]
|
|
846
|
-
},
|
|
846
|
+
}, Ni = {
|
|
847
847
|
id: "shoguns-ashikaga-given-ja",
|
|
848
848
|
mode: "finite",
|
|
849
849
|
langs: ["ja"],
|
|
@@ -864,7 +864,7 @@ const ei = {
|
|
|
864
864
|
"義栄",
|
|
865
865
|
"義昭"
|
|
866
866
|
]
|
|
867
|
-
},
|
|
867
|
+
}, Pi = {
|
|
868
868
|
id: "shoguns-tokugawa-ja",
|
|
869
869
|
mode: "finite",
|
|
870
870
|
langs: ["ja"],
|
|
@@ -885,7 +885,7 @@ const ei = {
|
|
|
885
885
|
"徳川家茂",
|
|
886
886
|
"徳川慶喜"
|
|
887
887
|
]
|
|
888
|
-
},
|
|
888
|
+
}, Bi = {
|
|
889
889
|
id: "shoguns-tokugawa-given-ja",
|
|
890
890
|
mode: "finite",
|
|
891
891
|
langs: ["ja"],
|
|
@@ -906,7 +906,7 @@ const ei = {
|
|
|
906
906
|
"家茂",
|
|
907
907
|
"慶喜"
|
|
908
908
|
]
|
|
909
|
-
},
|
|
909
|
+
}, ue = [
|
|
910
910
|
"北海道",
|
|
911
911
|
"青森県",
|
|
912
912
|
"岩手県",
|
|
@@ -954,7 +954,7 @@ const ei = {
|
|
|
954
954
|
"宮崎県",
|
|
955
955
|
"鹿児島県",
|
|
956
956
|
"沖縄県"
|
|
957
|
-
],
|
|
957
|
+
], $i = ue.reduce(
|
|
958
958
|
(c, t) => {
|
|
959
959
|
if (t === "北海道")
|
|
960
960
|
return c;
|
|
@@ -965,13 +965,13 @@ const ei = {
|
|
|
965
965
|
return c;
|
|
966
966
|
},
|
|
967
967
|
{}
|
|
968
|
-
),
|
|
968
|
+
), Wi = {
|
|
969
969
|
id: "prefectures-ja",
|
|
970
970
|
mode: "finite",
|
|
971
971
|
langs: ["ja"],
|
|
972
|
-
items:
|
|
973
|
-
aliases:
|
|
974
|
-
},
|
|
972
|
+
items: ue,
|
|
973
|
+
aliases: $i
|
|
974
|
+
}, Oi = {
|
|
975
975
|
id: "us-states-en",
|
|
976
976
|
mode: "finite",
|
|
977
977
|
langs: ["en"],
|
|
@@ -1027,7 +1027,7 @@ const ei = {
|
|
|
1027
1027
|
"Wisconsin",
|
|
1028
1028
|
"Wyoming"
|
|
1029
1029
|
]
|
|
1030
|
-
},
|
|
1030
|
+
}, ji = {
|
|
1031
1031
|
id: "us-states-abbrev-en",
|
|
1032
1032
|
mode: "finite",
|
|
1033
1033
|
langs: ["en"],
|
|
@@ -1083,7 +1083,7 @@ const ei = {
|
|
|
1083
1083
|
"WI",
|
|
1084
1084
|
"WY"
|
|
1085
1085
|
]
|
|
1086
|
-
},
|
|
1086
|
+
}, qi = {
|
|
1087
1087
|
id: "windows-versions",
|
|
1088
1088
|
mode: "finite",
|
|
1089
1089
|
langs: ["ja", "en"],
|
|
@@ -1106,7 +1106,7 @@ const ei = {
|
|
|
1106
1106
|
"Windows 10",
|
|
1107
1107
|
"Windows 11"
|
|
1108
1108
|
]
|
|
1109
|
-
},
|
|
1109
|
+
}, zi = {
|
|
1110
1110
|
id: "macos-versions",
|
|
1111
1111
|
mode: "finite",
|
|
1112
1112
|
langs: ["ja", "en"],
|
|
@@ -1134,7 +1134,7 @@ const ei = {
|
|
|
1134
1134
|
"Sequoia",
|
|
1135
1135
|
"Tahoe"
|
|
1136
1136
|
]
|
|
1137
|
-
},
|
|
1137
|
+
}, Ui = {
|
|
1138
1138
|
id: "debian-codenames",
|
|
1139
1139
|
mode: "finite",
|
|
1140
1140
|
langs: ["ja", "en"],
|
|
@@ -1158,9 +1158,7 @@ const ei = {
|
|
|
1158
1158
|
"bookworm",
|
|
1159
1159
|
"trixie"
|
|
1160
1160
|
]
|
|
1161
|
-
},
|
|
1162
|
-
ei,
|
|
1163
|
-
ii,
|
|
1161
|
+
}, Xi = [
|
|
1164
1162
|
oi,
|
|
1165
1163
|
ni,
|
|
1166
1164
|
si,
|
|
@@ -1179,12 +1177,12 @@ const ei = {
|
|
|
1179
1177
|
wi,
|
|
1180
1178
|
vi,
|
|
1181
1179
|
Ci,
|
|
1182
|
-
xi,
|
|
1183
1180
|
bi,
|
|
1181
|
+
xi,
|
|
1184
1182
|
Si,
|
|
1185
1183
|
Mi,
|
|
1186
|
-
ki,
|
|
1187
1184
|
Ri,
|
|
1185
|
+
ki,
|
|
1188
1186
|
Ii,
|
|
1189
1187
|
Ti,
|
|
1190
1188
|
Ei,
|
|
@@ -1193,22 +1191,24 @@ const ei = {
|
|
|
1193
1191
|
Li,
|
|
1194
1192
|
Di,
|
|
1195
1193
|
Ki,
|
|
1196
|
-
Fi,
|
|
1197
1194
|
_i,
|
|
1195
|
+
Fi,
|
|
1198
1196
|
Vi,
|
|
1199
1197
|
Ni,
|
|
1198
|
+
Pi,
|
|
1200
1199
|
Bi,
|
|
1201
|
-
$i,
|
|
1202
1200
|
Wi,
|
|
1203
1201
|
Oi,
|
|
1204
1202
|
ji,
|
|
1205
|
-
qi
|
|
1203
|
+
qi,
|
|
1204
|
+
zi,
|
|
1205
|
+
Ui
|
|
1206
1206
|
], Tt = (c) => {
|
|
1207
1207
|
const t = c % 100;
|
|
1208
1208
|
if (t >= 11 && t <= 13) return "th";
|
|
1209
1209
|
const e = c % 10;
|
|
1210
1210
|
return e === 1 ? "st" : e === 2 ? "nd" : e === 3 ? "rd" : "th";
|
|
1211
|
-
},
|
|
1211
|
+
}, Nt = {
|
|
1212
1212
|
1: "first",
|
|
1213
1213
|
2: "second",
|
|
1214
1214
|
3: "third",
|
|
@@ -1228,7 +1228,7 @@ const ei = {
|
|
|
1228
1228
|
17: "seventeenth",
|
|
1229
1229
|
18: "eighteenth",
|
|
1230
1230
|
19: "nineteenth"
|
|
1231
|
-
},
|
|
1231
|
+
}, Pt = {
|
|
1232
1232
|
20: "twentieth",
|
|
1233
1233
|
30: "thirtieth",
|
|
1234
1234
|
40: "fortieth",
|
|
@@ -1237,7 +1237,7 @@ const ei = {
|
|
|
1237
1237
|
70: "seventieth",
|
|
1238
1238
|
80: "eightieth",
|
|
1239
1239
|
90: "ninetieth"
|
|
1240
|
-
},
|
|
1240
|
+
}, fe = {
|
|
1241
1241
|
20: "twenty",
|
|
1242
1242
|
30: "thirty",
|
|
1243
1243
|
40: "forty",
|
|
@@ -1246,31 +1246,31 @@ const ei = {
|
|
|
1246
1246
|
70: "seventy",
|
|
1247
1247
|
80: "eighty",
|
|
1248
1248
|
90: "ninety"
|
|
1249
|
-
},
|
|
1250
|
-
Object.entries(
|
|
1251
|
-
),
|
|
1252
|
-
Object.entries(
|
|
1253
|
-
),
|
|
1254
|
-
Object.entries(
|
|
1255
|
-
),
|
|
1249
|
+
}, ae = Object.fromEntries(
|
|
1250
|
+
Object.entries(Nt).map(([c, t]) => [t, Number(c)])
|
|
1251
|
+
), Gi = Object.fromEntries(
|
|
1252
|
+
Object.entries(Pt).map(([c, t]) => [t, Number(c)])
|
|
1253
|
+
), Yi = Object.fromEntries(
|
|
1254
|
+
Object.entries(fe).map(([c, t]) => [t, Number(c)])
|
|
1255
|
+
), pe = (c) => {
|
|
1256
1256
|
const t = c.trim().toLowerCase();
|
|
1257
1257
|
if (!t) return null;
|
|
1258
|
-
const e =
|
|
1258
|
+
const e = ae[t] ?? Gi[t];
|
|
1259
1259
|
if (e) return e;
|
|
1260
1260
|
const i = t.split(/[-\s]+/);
|
|
1261
1261
|
if (i.length !== 2) return null;
|
|
1262
|
-
const o =
|
|
1262
|
+
const o = Yi[i[0] ?? ""], n = ae[i[1] ?? ""];
|
|
1263
1263
|
return !o || !n ? null : o + n;
|
|
1264
|
-
},
|
|
1264
|
+
}, me = (c) => {
|
|
1265
1265
|
if (!Number.isFinite(c) || c <= 0 || Math.floor(c) !== c) return null;
|
|
1266
|
-
if (c <= 19) return
|
|
1266
|
+
if (c <= 19) return Nt[c] ?? null;
|
|
1267
1267
|
if (c < 100) {
|
|
1268
|
-
if (
|
|
1269
|
-
const t = Math.floor(c / 10) * 10, e = c % 10, i =
|
|
1268
|
+
if (Pt[c]) return Pt[c] ?? null;
|
|
1269
|
+
const t = Math.floor(c / 10) * 10, e = c % 10, i = fe[t], o = Nt[e];
|
|
1270
1270
|
return !i || !o ? null : `${i}-${o}`;
|
|
1271
1271
|
}
|
|
1272
1272
|
return null;
|
|
1273
|
-
},
|
|
1273
|
+
}, ce = (c) => {
|
|
1274
1274
|
const t = /^(\d+)(st|nd|rd|th)$/i.exec(c);
|
|
1275
1275
|
if (t) {
|
|
1276
1276
|
const i = Number(t[1]);
|
|
@@ -1278,14 +1278,14 @@ const ei = {
|
|
|
1278
1278
|
const o = t[2]?.toLowerCase();
|
|
1279
1279
|
return Tt(i) !== o ? null : { value: i, format: "numeric" };
|
|
1280
1280
|
}
|
|
1281
|
-
const e =
|
|
1281
|
+
const e = pe(c);
|
|
1282
1282
|
return e !== null ? { value: e, format: "word" } : null;
|
|
1283
|
-
},
|
|
1283
|
+
}, Qi = {
|
|
1284
1284
|
id: "ordinal-en",
|
|
1285
1285
|
langs: ["en"],
|
|
1286
1286
|
match(c) {
|
|
1287
1287
|
if (c.length < 2) return null;
|
|
1288
|
-
const t = c.map((n) =>
|
|
1288
|
+
const t = c.map((n) => ce(n));
|
|
1289
1289
|
if (t.some((n) => n === null)) return null;
|
|
1290
1290
|
const e = t[0].format;
|
|
1291
1291
|
if (t.some((n) => n?.format !== e)) return null;
|
|
@@ -1295,29 +1295,29 @@ const ei = {
|
|
|
1295
1295
|
return { score: 80, step: o, state: { format: e } };
|
|
1296
1296
|
},
|
|
1297
1297
|
createIterator(c, t) {
|
|
1298
|
-
const e =
|
|
1298
|
+
const e = ce(c[c.length - 1] ?? ""), i = t.state?.format ?? "numeric";
|
|
1299
1299
|
let o = e?.value ?? 0;
|
|
1300
1300
|
return {
|
|
1301
1301
|
next() {
|
|
1302
1302
|
if (o += t.step, o <= 0 || !Number.isFinite(o))
|
|
1303
1303
|
return { value: void 0, done: !0 };
|
|
1304
1304
|
if (i === "word") {
|
|
1305
|
-
const n =
|
|
1305
|
+
const n = me(o);
|
|
1306
1306
|
return n ? { value: n, done: !1 } : { value: void 0, done: !0 };
|
|
1307
1307
|
}
|
|
1308
1308
|
return { value: `${o}${Tt(o)}`, done: !1 };
|
|
1309
1309
|
}
|
|
1310
1310
|
};
|
|
1311
1311
|
}
|
|
1312
|
-
}, Yi = (c) => {
|
|
1313
|
-
for (const t of Ui)
|
|
1314
|
-
c.register(t);
|
|
1315
|
-
}, Qi = (c) => {
|
|
1316
|
-
c.registerMatch(Gi);
|
|
1317
|
-
}, me = (c) => {
|
|
1318
|
-
const t = c ?? ["en", "ja"], e = new ti({ langs: t });
|
|
1319
|
-
return Yi(e), Qi(e), e;
|
|
1320
1312
|
}, Ji = (c) => {
|
|
1313
|
+
for (const t of Xi)
|
|
1314
|
+
c.register(t);
|
|
1315
|
+
}, Zi = (c) => {
|
|
1316
|
+
c.registerMatch(Qi);
|
|
1317
|
+
}, ge = (c) => {
|
|
1318
|
+
const t = c ?? ["en", "ja"], e = new ii({ langs: t });
|
|
1319
|
+
return Ji(e), Zi(e), e;
|
|
1320
|
+
}, to = (c) => {
|
|
1321
1321
|
let t = 0;
|
|
1322
1322
|
return {
|
|
1323
1323
|
next() {
|
|
@@ -1328,13 +1328,13 @@ const ei = {
|
|
|
1328
1328
|
}
|
|
1329
1329
|
};
|
|
1330
1330
|
};
|
|
1331
|
-
class
|
|
1331
|
+
class G {
|
|
1332
1332
|
constructor(...t) {
|
|
1333
1333
|
const e = t;
|
|
1334
|
-
this.seed = e, this.kind = e.length === 1 ? "copy" : "seed-repeat", this.iterator =
|
|
1334
|
+
this.seed = e, this.kind = e.length === 1 ? "copy" : "seed-repeat", this.iterator = to(e);
|
|
1335
1335
|
}
|
|
1336
1336
|
static fromSeed(t, e, i) {
|
|
1337
|
-
const o = new
|
|
1337
|
+
const o = new G(...t);
|
|
1338
1338
|
return o.kind = e, o.iterator = i, o;
|
|
1339
1339
|
}
|
|
1340
1340
|
next() {
|
|
@@ -1344,11 +1344,11 @@ class X {
|
|
|
1344
1344
|
return this;
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
1347
|
-
const
|
|
1347
|
+
const ye = 1e-9, eo = 100, io = (c) => ({
|
|
1348
1348
|
next() {
|
|
1349
1349
|
return { value: c, done: !1 };
|
|
1350
1350
|
}
|
|
1351
|
-
}),
|
|
1351
|
+
}), he = (c) => {
|
|
1352
1352
|
let t = 0;
|
|
1353
1353
|
return {
|
|
1354
1354
|
next() {
|
|
@@ -1358,28 +1358,28 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1358
1358
|
return t += 1, { value: e, done: !1 };
|
|
1359
1359
|
}
|
|
1360
1360
|
};
|
|
1361
|
-
},
|
|
1361
|
+
}, oo = (c, t) => {
|
|
1362
1362
|
let e = 0;
|
|
1363
1363
|
return {
|
|
1364
1364
|
next() {
|
|
1365
1365
|
return e += 1, { value: c + t * e, done: !1 };
|
|
1366
1366
|
}
|
|
1367
1367
|
};
|
|
1368
|
-
},
|
|
1368
|
+
}, no = (c, t) => {
|
|
1369
1369
|
let e = 0;
|
|
1370
1370
|
return {
|
|
1371
1371
|
next() {
|
|
1372
1372
|
return e += 1, { value: new Date(c.getTime() + t * e), done: !1 };
|
|
1373
1373
|
}
|
|
1374
1374
|
};
|
|
1375
|
-
},
|
|
1375
|
+
}, so = (c, t) => {
|
|
1376
1376
|
let e = 0;
|
|
1377
1377
|
return {
|
|
1378
1378
|
next() {
|
|
1379
1379
|
return e += 1, { value: c * t ** e, done: !1 };
|
|
1380
1380
|
}
|
|
1381
1381
|
};
|
|
1382
|
-
},
|
|
1382
|
+
}, lo = (c, t) => {
|
|
1383
1383
|
if (c.kind === "matcher")
|
|
1384
1384
|
return c.matcher.createIterator(t, { step: c.step, state: c.state });
|
|
1385
1385
|
const { list: e, startIndex: i, step: o } = c, n = e.items.length;
|
|
@@ -1393,7 +1393,7 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1393
1393
|
return s = (s + o) % n, { value: e.items[s], done: !1 };
|
|
1394
1394
|
}
|
|
1395
1395
|
};
|
|
1396
|
-
},
|
|
1396
|
+
}, ro = (c) => c.every((t) => typeof t == "number" && Number.isFinite(t)), ao = (c) => c.every((t) => t instanceof Date && !Number.isNaN(t.getTime())), co = (c) => c.every((t) => typeof t == "string"), ho = (c) => {
|
|
1397
1397
|
const t = /^(.*?)(-?\d+)([^0-9]*)$/.exec(c);
|
|
1398
1398
|
if (!t)
|
|
1399
1399
|
return null;
|
|
@@ -1402,7 +1402,7 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1402
1402
|
return null;
|
|
1403
1403
|
const s = i.replace("-", "").length;
|
|
1404
1404
|
return { prefix: e, num: n, width: s, suffix: o };
|
|
1405
|
-
},
|
|
1405
|
+
}, uo = (c) => {
|
|
1406
1406
|
const t = /^(.*?)(\d+)(st|nd|rd|th)([^0-9]*)$/i.exec(c);
|
|
1407
1407
|
if (t) {
|
|
1408
1408
|
const o = Number(t[2]);
|
|
@@ -1417,14 +1417,14 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1417
1417
|
}
|
|
1418
1418
|
const e = /^(.*?)([A-Za-z-]+)([^A-Za-z]*)$/.exec(c);
|
|
1419
1419
|
if (!e) return null;
|
|
1420
|
-
const i =
|
|
1420
|
+
const i = pe(e[2] ?? "");
|
|
1421
1421
|
return i === null ? null : {
|
|
1422
1422
|
prefix: e[1] ?? "",
|
|
1423
1423
|
num: i,
|
|
1424
1424
|
suffix: e[3] ?? "",
|
|
1425
1425
|
format: "word"
|
|
1426
1426
|
};
|
|
1427
|
-
},
|
|
1427
|
+
}, fo = (c, t, e) => {
|
|
1428
1428
|
let i = 0;
|
|
1429
1429
|
return {
|
|
1430
1430
|
next() {
|
|
@@ -1433,7 +1433,7 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1433
1433
|
if (o <= 0 || !Number.isFinite(o))
|
|
1434
1434
|
return { value: void 0, done: !0 };
|
|
1435
1435
|
if (c.format === "word") {
|
|
1436
|
-
const n =
|
|
1436
|
+
const n = me(o);
|
|
1437
1437
|
return n ? { value: `${c.prefix}${n}${c.suffix}`, done: !1 } : { value: void 0, done: !0 };
|
|
1438
1438
|
}
|
|
1439
1439
|
return {
|
|
@@ -1442,7 +1442,7 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1442
1442
|
};
|
|
1443
1443
|
}
|
|
1444
1444
|
};
|
|
1445
|
-
},
|
|
1445
|
+
}, po = (c, t, e) => {
|
|
1446
1446
|
let i = 0;
|
|
1447
1447
|
return {
|
|
1448
1448
|
next() {
|
|
@@ -1451,7 +1451,7 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1451
1451
|
return { value: `${c.prefix}${n}${s}${c.suffix}`, done: !1 };
|
|
1452
1452
|
}
|
|
1453
1453
|
};
|
|
1454
|
-
},
|
|
1454
|
+
}, we = [
|
|
1455
1455
|
["C", 100],
|
|
1456
1456
|
["XC", 90],
|
|
1457
1457
|
["L", 50],
|
|
@@ -1461,39 +1461,39 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1461
1461
|
["V", 5],
|
|
1462
1462
|
["IV", 4],
|
|
1463
1463
|
["I", 1]
|
|
1464
|
-
],
|
|
1465
|
-
if (c < 1 || c >
|
|
1464
|
+
], jt = (c) => {
|
|
1465
|
+
if (c < 1 || c > eo)
|
|
1466
1466
|
return null;
|
|
1467
1467
|
let t = c, e = "";
|
|
1468
|
-
for (const [i, o] of
|
|
1468
|
+
for (const [i, o] of we)
|
|
1469
1469
|
for (; t >= o; )
|
|
1470
1470
|
e += i, t -= o;
|
|
1471
1471
|
return e;
|
|
1472
|
-
},
|
|
1472
|
+
}, ve = (c) => {
|
|
1473
1473
|
if (c.length === 0 || c !== c.toUpperCase())
|
|
1474
1474
|
return null;
|
|
1475
1475
|
let t = c, e = 0;
|
|
1476
|
-
for (const [o, n] of
|
|
1476
|
+
for (const [o, n] of we)
|
|
1477
1477
|
for (; t.startsWith(o); )
|
|
1478
1478
|
e += n, t = t.slice(o.length);
|
|
1479
1479
|
if (t.length > 0)
|
|
1480
1480
|
return null;
|
|
1481
|
-
const i =
|
|
1481
|
+
const i = jt(e);
|
|
1482
1482
|
return !i || i !== c ? null : e;
|
|
1483
|
-
},
|
|
1483
|
+
}, mo = (c, t) => {
|
|
1484
1484
|
let e = 0;
|
|
1485
1485
|
return {
|
|
1486
1486
|
next() {
|
|
1487
1487
|
e += 1;
|
|
1488
|
-
const i = c + t * e, o =
|
|
1488
|
+
const i = c + t * e, o = jt(i);
|
|
1489
1489
|
return o ? { value: o, done: !1 } : { value: void 0, done: !0 };
|
|
1490
1490
|
}
|
|
1491
1491
|
};
|
|
1492
|
-
},
|
|
1492
|
+
}, go = (c) => new RegExp("\\p{White_Space}", "u").test(c) ? "space" : new RegExp("\\p{P}", "u").test(c) ? "punct" : new RegExp("\\p{S}", "u").test(c) ? "symbol" : new RegExp("\\p{Script=Latin}", "u").test(c) ? "latin" : new RegExp("\\p{Script=Han}", "u").test(c) ? "han" : new RegExp("\\p{Script=Hiragana}", "u").test(c) ? "hiragana" : new RegExp("\\p{Script=Katakana}", "u").test(c) ? "katakana" : new RegExp("\\p{N}", "u").test(c) ? "number" : "other", yo = (c) => {
|
|
1493
1493
|
const t = [];
|
|
1494
1494
|
let e = "", i = null;
|
|
1495
1495
|
for (const o of c) {
|
|
1496
|
-
const n =
|
|
1496
|
+
const n = go(o);
|
|
1497
1497
|
if (i === n) {
|
|
1498
1498
|
e += o;
|
|
1499
1499
|
continue;
|
|
@@ -1501,22 +1501,22 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1501
1501
|
i !== null && t.push({ value: e, group: i }), e = o, i = n;
|
|
1502
1502
|
}
|
|
1503
1503
|
return i !== null && t.push({ value: e, group: i }), t;
|
|
1504
|
-
},
|
|
1505
|
-
const t =
|
|
1504
|
+
}, wo = (c) => {
|
|
1505
|
+
const t = yo(c), e = t.map((l, a) => ({ index: a, num: ve(l.value) })).filter((l) => l.num !== null);
|
|
1506
1506
|
if (e.length !== 1)
|
|
1507
1507
|
return null;
|
|
1508
1508
|
const i = e[0].index, o = e[0].num, n = t.slice(0, i).map((l) => l.value).join(""), s = t.slice(i + 1).map((l) => l.value).join("");
|
|
1509
1509
|
return { prefix: n, num: o, suffix: s };
|
|
1510
|
-
},
|
|
1510
|
+
}, vo = (c, t, e) => {
|
|
1511
1511
|
let i = 0;
|
|
1512
1512
|
return {
|
|
1513
1513
|
next() {
|
|
1514
1514
|
i += 1;
|
|
1515
|
-
const o = t + e * i, n =
|
|
1515
|
+
const o = t + e * i, n = jt(o);
|
|
1516
1516
|
return n ? { value: `${c.prefix}${n}${c.suffix}`, done: !1 } : { value: void 0, done: !0 };
|
|
1517
1517
|
}
|
|
1518
1518
|
};
|
|
1519
|
-
},
|
|
1519
|
+
}, Bt = {
|
|
1520
1520
|
一: 1,
|
|
1521
1521
|
二: 2,
|
|
1522
1522
|
三: 3,
|
|
@@ -1526,7 +1526,7 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1526
1526
|
七: 7,
|
|
1527
1527
|
八: 8,
|
|
1528
1528
|
九: 9
|
|
1529
|
-
},
|
|
1529
|
+
}, $t = {
|
|
1530
1530
|
壱: 1,
|
|
1531
1531
|
弐: 2,
|
|
1532
1532
|
参: 3,
|
|
@@ -1536,42 +1536,42 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1536
1536
|
柒: 7,
|
|
1537
1537
|
捌: 8,
|
|
1538
1538
|
玖: 9
|
|
1539
|
-
},
|
|
1539
|
+
}, Ce = {
|
|
1540
1540
|
十: 10,
|
|
1541
1541
|
拾: 10,
|
|
1542
1542
|
百: 100,
|
|
1543
1543
|
佰: 100,
|
|
1544
1544
|
千: 1e3,
|
|
1545
1545
|
仟: 1e3
|
|
1546
|
-
},
|
|
1546
|
+
}, Co = {
|
|
1547
1547
|
万: 1e4,
|
|
1548
1548
|
萬: 1e4
|
|
1549
|
-
},
|
|
1550
|
-
...Object.keys(
|
|
1551
|
-
...Object.keys(
|
|
1552
|
-
...Object.keys(
|
|
1553
|
-
...Object.keys(
|
|
1554
|
-
]),
|
|
1549
|
+
}, bo = /* @__PURE__ */ new Set([
|
|
1550
|
+
...Object.keys(Bt),
|
|
1551
|
+
...Object.keys($t),
|
|
1552
|
+
...Object.keys(Ce),
|
|
1553
|
+
...Object.keys(Co)
|
|
1554
|
+
]), xo = (c) => bo.has(c), So = (c) => /[壱弐参肆伍陸柒捌玖拾萬佰仟]/.test(c) ? "traditional" : "modern", be = (c) => {
|
|
1555
1555
|
if (!c)
|
|
1556
1556
|
return null;
|
|
1557
|
-
const t =
|
|
1557
|
+
const t = So(c);
|
|
1558
1558
|
if (c.includes("万") || c.includes("萬")) {
|
|
1559
1559
|
const s = /^([一二三四五六七八九壱弐参肆伍陸柒捌玖])?(万|萬)$/.exec(c);
|
|
1560
1560
|
if (!s)
|
|
1561
1561
|
return null;
|
|
1562
1562
|
const l = s[1];
|
|
1563
|
-
return l ? (
|
|
1563
|
+
return l ? (Bt[l] ?? $t[l]) !== 1 ? null : { num: 1e4, style: t } : { num: 1e4, style: t };
|
|
1564
1564
|
}
|
|
1565
1565
|
let e = 0, i = 0, o = Number.POSITIVE_INFINITY, n = !1;
|
|
1566
1566
|
for (const s of c) {
|
|
1567
|
-
const l =
|
|
1567
|
+
const l = Bt[s] ?? $t[s];
|
|
1568
1568
|
if (l) {
|
|
1569
1569
|
if (n)
|
|
1570
1570
|
return null;
|
|
1571
1571
|
i = l, n = !0;
|
|
1572
1572
|
continue;
|
|
1573
1573
|
}
|
|
1574
|
-
const a =
|
|
1574
|
+
const a = Ce[s];
|
|
1575
1575
|
if (a) {
|
|
1576
1576
|
if (a >= o)
|
|
1577
1577
|
return null;
|
|
@@ -1581,13 +1581,13 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1581
1581
|
return null;
|
|
1582
1582
|
}
|
|
1583
1583
|
return e += i, e <= 0 || e > 1e4 ? null : { num: e, style: t };
|
|
1584
|
-
},
|
|
1584
|
+
}, Mo = (c) => {
|
|
1585
1585
|
const t = [];
|
|
1586
1586
|
let e = "", i = 0, o = 0;
|
|
1587
1587
|
for (const r of c)
|
|
1588
|
-
|
|
1588
|
+
xo(r) ? (e || (i = o), e += r) : e && (t.push({ start: i, end: o, text: e }), e = ""), o += r.length;
|
|
1589
1589
|
e && t.push({ start: i, end: o, text: e });
|
|
1590
|
-
const n = t.map((r) => ({ run: r, parsed:
|
|
1590
|
+
const n = t.map((r) => ({ run: r, parsed: be(r.text) })).filter((r) => r.parsed !== null);
|
|
1591
1591
|
if (n.length !== 1)
|
|
1592
1592
|
return null;
|
|
1593
1593
|
const s = n[0], l = c.slice(0, s.run.start), a = c.slice(s.run.end);
|
|
@@ -1610,7 +1610,7 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1610
1610
|
a > 0 && (a > 1 && (s += e[a]), s += "百", n %= 100);
|
|
1611
1611
|
const r = Math.floor(n / 10);
|
|
1612
1612
|
return r > 0 && (r > 1 && (s += e[r]), s += i, n %= 10), n > 0 && (s += e[n]), s || null;
|
|
1613
|
-
},
|
|
1613
|
+
}, Ro = (c, t, e) => {
|
|
1614
1614
|
let i = 0;
|
|
1615
1615
|
return {
|
|
1616
1616
|
next() {
|
|
@@ -1619,7 +1619,7 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1619
1619
|
return n ? { value: n, done: !1 } : { value: void 0, done: !0 };
|
|
1620
1620
|
}
|
|
1621
1621
|
};
|
|
1622
|
-
},
|
|
1622
|
+
}, ko = (c, t, e) => {
|
|
1623
1623
|
let i = 0;
|
|
1624
1624
|
return {
|
|
1625
1625
|
next() {
|
|
@@ -1628,176 +1628,176 @@ const ge = 1e-9, Zi = 100, to = (c) => ({
|
|
|
1628
1628
|
return n ? { value: `${c.prefix}${n}${c.suffix}`, done: !1 } : { value: void 0, done: !0 };
|
|
1629
1629
|
}
|
|
1630
1630
|
};
|
|
1631
|
-
},
|
|
1631
|
+
}, tt = (c) => {
|
|
1632
1632
|
if (c.length < 2)
|
|
1633
1633
|
return null;
|
|
1634
1634
|
const t = c[1] - c[0];
|
|
1635
1635
|
for (let e = 2; e < c.length; e += 1)
|
|
1636
|
-
if (Math.abs(c[e] - c[e - 1] - t) >
|
|
1636
|
+
if (Math.abs(c[e] - c[e - 1] - t) > ye)
|
|
1637
1637
|
return null;
|
|
1638
1638
|
return t;
|
|
1639
|
-
},
|
|
1639
|
+
}, Io = (c) => {
|
|
1640
1640
|
if (c.length < 2 || c[0] === 0)
|
|
1641
1641
|
return null;
|
|
1642
1642
|
const t = c[1] / c[0];
|
|
1643
1643
|
for (let e = 2; e < c.length; e += 1)
|
|
1644
|
-
if (c[e - 1] === 0 || Math.abs(c[e] / c[e - 1] - t) >
|
|
1644
|
+
if (c[e - 1] === 0 || Math.abs(c[e] / c[e - 1] - t) > ye)
|
|
1645
1645
|
return null;
|
|
1646
1646
|
return t;
|
|
1647
|
-
},
|
|
1648
|
-
const t = c.map((l) =>
|
|
1647
|
+
}, To = (c) => {
|
|
1648
|
+
const t = c.map((l) => uo(l));
|
|
1649
1649
|
if (t.every((l) => l !== null)) {
|
|
1650
1650
|
const l = t, a = l[0];
|
|
1651
1651
|
if (l.every(
|
|
1652
1652
|
(r) => r.prefix === a.prefix && r.suffix === a.suffix && r.format === a.format
|
|
1653
1653
|
)) {
|
|
1654
|
-
const r = l.map((
|
|
1655
|
-
if (
|
|
1656
|
-
const
|
|
1654
|
+
const r = l.map((d) => d.num), h = tt(r);
|
|
1655
|
+
if (h !== null) {
|
|
1656
|
+
const d = l[l.length - 1];
|
|
1657
1657
|
return {
|
|
1658
1658
|
kind: "arithmetic",
|
|
1659
|
-
iterator:
|
|
1659
|
+
iterator: fo(
|
|
1660
1660
|
{ prefix: a.prefix, suffix: a.suffix, format: a.format },
|
|
1661
|
-
|
|
1662
|
-
|
|
1661
|
+
d.num,
|
|
1662
|
+
h
|
|
1663
1663
|
)
|
|
1664
1664
|
};
|
|
1665
1665
|
}
|
|
1666
1666
|
}
|
|
1667
1667
|
}
|
|
1668
|
-
const e = c.map((l) =>
|
|
1668
|
+
const e = c.map((l) => ho(l));
|
|
1669
1669
|
if (e.every(Boolean)) {
|
|
1670
1670
|
const l = e[0], a = e[e.length - 1];
|
|
1671
1671
|
if (e.every(
|
|
1672
1672
|
(r) => r?.prefix === l.prefix && r?.suffix === l.suffix
|
|
1673
1673
|
)) {
|
|
1674
|
-
const r = e.map((
|
|
1675
|
-
if (
|
|
1674
|
+
const r = e.map((d) => d?.num ?? 0), h = tt(r);
|
|
1675
|
+
if (h !== null)
|
|
1676
1676
|
return {
|
|
1677
1677
|
kind: "arithmetic",
|
|
1678
|
-
iterator:
|
|
1678
|
+
iterator: po(
|
|
1679
1679
|
{ prefix: a.prefix, suffix: a.suffix, width: a.width },
|
|
1680
1680
|
a.num,
|
|
1681
|
-
|
|
1681
|
+
h
|
|
1682
1682
|
)
|
|
1683
1683
|
};
|
|
1684
1684
|
}
|
|
1685
1685
|
}
|
|
1686
|
-
const i = c.map((l) =>
|
|
1686
|
+
const i = c.map((l) => ve(l));
|
|
1687
1687
|
if (i.every((l) => l !== null)) {
|
|
1688
|
-
const l = i, a =
|
|
1688
|
+
const l = i, a = tt(l);
|
|
1689
1689
|
if (a !== null) {
|
|
1690
1690
|
const r = l[l.length - 1];
|
|
1691
1691
|
return {
|
|
1692
1692
|
kind: "arithmetic",
|
|
1693
|
-
iterator:
|
|
1693
|
+
iterator: mo(r, a)
|
|
1694
1694
|
};
|
|
1695
1695
|
}
|
|
1696
1696
|
}
|
|
1697
|
-
const o = c.map((l) =>
|
|
1697
|
+
const o = c.map((l) => be(l));
|
|
1698
1698
|
if (o.every((l) => l !== null)) {
|
|
1699
1699
|
const l = o, a = l[0].style;
|
|
1700
1700
|
if (l.every((r) => r.style === a)) {
|
|
1701
|
-
const r = l.map((
|
|
1702
|
-
if (
|
|
1703
|
-
const
|
|
1701
|
+
const r = l.map((d) => d.num), h = tt(r);
|
|
1702
|
+
if (h !== null) {
|
|
1703
|
+
const d = l[l.length - 1];
|
|
1704
1704
|
return {
|
|
1705
1705
|
kind: "arithmetic",
|
|
1706
|
-
iterator:
|
|
1706
|
+
iterator: Ro(d.num, h, d.style)
|
|
1707
1707
|
};
|
|
1708
1708
|
}
|
|
1709
1709
|
}
|
|
1710
1710
|
}
|
|
1711
|
-
const n = c.map((l) =>
|
|
1711
|
+
const n = c.map((l) => wo(l));
|
|
1712
1712
|
if (n.every((l) => l !== null)) {
|
|
1713
1713
|
const l = n, a = l[0];
|
|
1714
1714
|
if (l.every(
|
|
1715
1715
|
(r) => r.prefix === a.prefix && r.suffix === a.suffix
|
|
1716
1716
|
)) {
|
|
1717
|
-
const r = l.map((
|
|
1718
|
-
if (
|
|
1719
|
-
const
|
|
1717
|
+
const r = l.map((d) => d.num), h = tt(r);
|
|
1718
|
+
if (h !== null) {
|
|
1719
|
+
const d = r[r.length - 1];
|
|
1720
1720
|
return {
|
|
1721
1721
|
kind: "arithmetic",
|
|
1722
|
-
iterator:
|
|
1722
|
+
iterator: vo(
|
|
1723
1723
|
{ prefix: a.prefix, suffix: a.suffix },
|
|
1724
|
-
|
|
1725
|
-
|
|
1724
|
+
d,
|
|
1725
|
+
h
|
|
1726
1726
|
)
|
|
1727
1727
|
};
|
|
1728
1728
|
}
|
|
1729
1729
|
}
|
|
1730
1730
|
}
|
|
1731
|
-
const s = c.map((l) =>
|
|
1731
|
+
const s = c.map((l) => Mo(l));
|
|
1732
1732
|
if (s.every((l) => l !== null)) {
|
|
1733
1733
|
const l = s, a = l[0];
|
|
1734
1734
|
if (l.every(
|
|
1735
1735
|
(r) => r.prefix === a.prefix && r.suffix === a.suffix && r.style === a.style
|
|
1736
1736
|
)) {
|
|
1737
|
-
const r = l.map((
|
|
1738
|
-
if (
|
|
1739
|
-
const
|
|
1737
|
+
const r = l.map((d) => d.num), h = tt(r);
|
|
1738
|
+
if (h !== null) {
|
|
1739
|
+
const d = l[l.length - 1];
|
|
1740
1740
|
return {
|
|
1741
1741
|
kind: "arithmetic",
|
|
1742
|
-
iterator:
|
|
1742
|
+
iterator: ko(
|
|
1743
1743
|
{ prefix: a.prefix, suffix: a.suffix, style: a.style },
|
|
1744
|
-
|
|
1745
|
-
|
|
1744
|
+
d.num,
|
|
1745
|
+
h
|
|
1746
1746
|
)
|
|
1747
1747
|
};
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
1750
|
}
|
|
1751
1751
|
return null;
|
|
1752
|
-
},
|
|
1752
|
+
}, Eo = (c, t) => {
|
|
1753
1753
|
const e = t.match(c);
|
|
1754
1754
|
return e ? {
|
|
1755
1755
|
kind: "list",
|
|
1756
|
-
iterator:
|
|
1756
|
+
iterator: lo(e, c)
|
|
1757
1757
|
} : null;
|
|
1758
1758
|
};
|
|
1759
|
-
function
|
|
1760
|
-
const e = t?.registry ??
|
|
1759
|
+
function _t(c, t) {
|
|
1760
|
+
const e = t?.registry ?? ge();
|
|
1761
1761
|
if (c.length === 0)
|
|
1762
|
-
return
|
|
1762
|
+
return G.fromSeed(c, "seed-repeat", he(c));
|
|
1763
1763
|
if (c.length === 1)
|
|
1764
|
-
return
|
|
1765
|
-
if (
|
|
1766
|
-
const i =
|
|
1764
|
+
return G.fromSeed(c, "copy", io(c[0]));
|
|
1765
|
+
if (co(c)) {
|
|
1766
|
+
const i = Eo(c, e);
|
|
1767
1767
|
if (i)
|
|
1768
|
-
return
|
|
1769
|
-
const o =
|
|
1768
|
+
return G.fromSeed(c, i.kind, i.iterator);
|
|
1769
|
+
const o = To(c);
|
|
1770
1770
|
if (o)
|
|
1771
|
-
return
|
|
1771
|
+
return G.fromSeed(c, o.kind, o.iterator);
|
|
1772
1772
|
}
|
|
1773
|
-
if (
|
|
1774
|
-
const i =
|
|
1773
|
+
if (ro(c)) {
|
|
1774
|
+
const i = tt(c);
|
|
1775
1775
|
if (i !== null)
|
|
1776
|
-
return
|
|
1776
|
+
return G.fromSeed(
|
|
1777
1777
|
c,
|
|
1778
1778
|
"arithmetic",
|
|
1779
|
-
|
|
1779
|
+
oo(c[c.length - 1], i)
|
|
1780
1780
|
);
|
|
1781
|
-
const o =
|
|
1781
|
+
const o = Io(c);
|
|
1782
1782
|
if (o !== null)
|
|
1783
|
-
return
|
|
1783
|
+
return G.fromSeed(
|
|
1784
1784
|
c,
|
|
1785
1785
|
"geometric",
|
|
1786
|
-
|
|
1786
|
+
so(c[c.length - 1], o)
|
|
1787
1787
|
);
|
|
1788
1788
|
}
|
|
1789
|
-
if (
|
|
1790
|
-
const i = c.map((n) => n.getTime()), o =
|
|
1789
|
+
if (ao(c)) {
|
|
1790
|
+
const i = c.map((n) => n.getTime()), o = tt(i);
|
|
1791
1791
|
if (o !== null)
|
|
1792
|
-
return
|
|
1792
|
+
return G.fromSeed(
|
|
1793
1793
|
c,
|
|
1794
1794
|
"arithmetic",
|
|
1795
|
-
|
|
1795
|
+
no(c[c.length - 1], o)
|
|
1796
1796
|
);
|
|
1797
1797
|
}
|
|
1798
|
-
return
|
|
1798
|
+
return G.fromSeed(c, "seed-repeat", he(c));
|
|
1799
1799
|
}
|
|
1800
|
-
function
|
|
1800
|
+
function Ao(c) {
|
|
1801
1801
|
return {
|
|
1802
1802
|
...c,
|
|
1803
1803
|
startRow: Math.min(c.startRow, c.endRow),
|
|
@@ -1806,7 +1806,7 @@ function To(c) {
|
|
|
1806
1806
|
endCol: Math.max(c.startCol, c.endCol)
|
|
1807
1807
|
};
|
|
1808
1808
|
}
|
|
1809
|
-
function
|
|
1809
|
+
function Ho(c) {
|
|
1810
1810
|
if (c instanceof Date) return c;
|
|
1811
1811
|
if (typeof c == "number" && Number.isFinite(c)) return new Date(c);
|
|
1812
1812
|
if (typeof c == "string") {
|
|
@@ -1820,7 +1820,7 @@ function Eo(c) {
|
|
|
1820
1820
|
}
|
|
1821
1821
|
return null;
|
|
1822
1822
|
}
|
|
1823
|
-
function
|
|
1823
|
+
function Lo(c) {
|
|
1824
1824
|
if (c instanceof Date) return c;
|
|
1825
1825
|
if (typeof c == "number" && Number.isFinite(c)) return new Date(c);
|
|
1826
1826
|
if (typeof c == "string") {
|
|
@@ -1829,9 +1829,9 @@ function Ao(c) {
|
|
|
1829
1829
|
}
|
|
1830
1830
|
return null;
|
|
1831
1831
|
}
|
|
1832
|
-
function
|
|
1832
|
+
function Se(c, t) {
|
|
1833
1833
|
if (t.length !== 1) return null;
|
|
1834
|
-
const e =
|
|
1834
|
+
const e = Ao(t[0]);
|
|
1835
1835
|
if (e.kind !== "cells") return null;
|
|
1836
1836
|
const i = e.endCol - e.startCol + 1, o = e.endRow - e.startRow + 1;
|
|
1837
1837
|
if (i !== 1 || o < 1) return null;
|
|
@@ -1850,7 +1850,7 @@ function be(c, t) {
|
|
|
1850
1850
|
mode: "sequence"
|
|
1851
1851
|
} : null : null;
|
|
1852
1852
|
}
|
|
1853
|
-
function
|
|
1853
|
+
function Do(c, t, e) {
|
|
1854
1854
|
const i = c.getSchema(), o = c.listRows(), n = i.columns[t.colIndex];
|
|
1855
1855
|
if (!n) return null;
|
|
1856
1856
|
const s = [];
|
|
@@ -1863,78 +1863,78 @@ function Ho(c, t, e) {
|
|
|
1863
1863
|
const a = s[s.length - 1];
|
|
1864
1864
|
return () => a;
|
|
1865
1865
|
}
|
|
1866
|
-
const l =
|
|
1866
|
+
const l = ge(e);
|
|
1867
1867
|
if (n.type === "number") {
|
|
1868
1868
|
const a = s.map((u) => typeof u == "number" ? u : Number(u));
|
|
1869
1869
|
if (!a.every((u) => Number.isFinite(u))) return null;
|
|
1870
|
-
const r =
|
|
1871
|
-
let
|
|
1870
|
+
const r = _t(a, { registry: l }), h = [];
|
|
1871
|
+
let d = !1;
|
|
1872
1872
|
return (u) => {
|
|
1873
|
-
for (; !
|
|
1873
|
+
for (; !d && h.length < u; ) {
|
|
1874
1874
|
const p = r.next();
|
|
1875
1875
|
if (p.done) {
|
|
1876
|
-
|
|
1876
|
+
d = !0;
|
|
1877
1877
|
break;
|
|
1878
1878
|
}
|
|
1879
|
-
|
|
1879
|
+
h.push(p.value);
|
|
1880
1880
|
}
|
|
1881
|
-
return u <= 0 ? null :
|
|
1881
|
+
return u <= 0 ? null : h[u - 1] ?? null;
|
|
1882
1882
|
};
|
|
1883
1883
|
}
|
|
1884
1884
|
if (n.type === "date" || n.type === "time" || n.type === "datetime") {
|
|
1885
1885
|
const a = s.map(
|
|
1886
|
-
(u) => n.type === "time" ?
|
|
1886
|
+
(u) => n.type === "time" ? Ho(u) : Lo(u)
|
|
1887
1887
|
);
|
|
1888
1888
|
if (!a.every((u) => u instanceof Date)) return null;
|
|
1889
|
-
const r =
|
|
1890
|
-
let
|
|
1889
|
+
const r = _t(a, { registry: l }), h = [];
|
|
1890
|
+
let d = !1;
|
|
1891
1891
|
return (u) => {
|
|
1892
|
-
for (; !
|
|
1892
|
+
for (; !d && h.length < u; ) {
|
|
1893
1893
|
const p = r.next();
|
|
1894
1894
|
if (p.done) {
|
|
1895
|
-
|
|
1895
|
+
d = !0;
|
|
1896
1896
|
break;
|
|
1897
1897
|
}
|
|
1898
|
-
|
|
1898
|
+
h.push(p.value);
|
|
1899
1899
|
}
|
|
1900
|
-
return u <= 0 ? null :
|
|
1900
|
+
return u <= 0 ? null : h[u - 1] ?? null;
|
|
1901
1901
|
};
|
|
1902
1902
|
}
|
|
1903
1903
|
if (n.type === "string") {
|
|
1904
|
-
const a = s.map((u) => String(u ?? "")), r =
|
|
1905
|
-
let
|
|
1904
|
+
const a = s.map((u) => String(u ?? "")), r = _t(a, { registry: l }), h = [];
|
|
1905
|
+
let d = !1;
|
|
1906
1906
|
return (u) => {
|
|
1907
|
-
for (; !
|
|
1907
|
+
for (; !d && h.length < u; ) {
|
|
1908
1908
|
const p = r.next();
|
|
1909
1909
|
if (p.done) {
|
|
1910
|
-
|
|
1910
|
+
d = !0;
|
|
1911
1911
|
break;
|
|
1912
1912
|
}
|
|
1913
|
-
|
|
1913
|
+
h.push(p.value);
|
|
1914
1914
|
}
|
|
1915
|
-
return u <= 0 ? null :
|
|
1915
|
+
return u <= 0 ? null : h[u - 1] ?? null;
|
|
1916
1916
|
};
|
|
1917
1917
|
}
|
|
1918
1918
|
return null;
|
|
1919
1919
|
}
|
|
1920
|
-
const
|
|
1921
|
-
function ke(c, t =
|
|
1920
|
+
const Me = 12, Re = 14;
|
|
1921
|
+
function ke(c, t = Me) {
|
|
1922
1922
|
return new DOMRect(c.right - t - 1, c.bottom - t - 1, t, t);
|
|
1923
1923
|
}
|
|
1924
|
-
function
|
|
1924
|
+
function Ie(c, t, e) {
|
|
1925
1925
|
return c >= e.left && c <= e.right && t >= e.top && t <= e.bottom;
|
|
1926
1926
|
}
|
|
1927
|
-
function
|
|
1927
|
+
function kt(c, t, e, i, o) {
|
|
1928
1928
|
if (o === "readonly") return !1;
|
|
1929
|
-
const n =
|
|
1929
|
+
const n = Se(c, t);
|
|
1930
1930
|
return !(!n || !e || e === "__all__" || i === null || i === "__all__" || i === null || i !== n.colKey || c.isReadonly(e, i));
|
|
1931
1931
|
}
|
|
1932
|
-
const Q = '"Inter","Segoe UI",system-ui,-apple-system,"Helvetica Neue",sans-serif',
|
|
1933
|
-
function
|
|
1932
|
+
const Q = '"Inter","Segoe UI",system-ui,-apple-system,"Helvetica Neue",sans-serif', Z = 13.5, Ko = 10;
|
|
1933
|
+
function Te(c, t) {
|
|
1934
1934
|
const e = c.sorts?.[0];
|
|
1935
1935
|
return e && e.key === t ? e.dir : null;
|
|
1936
1936
|
}
|
|
1937
|
-
function
|
|
1937
|
+
function Ee(c, t) {
|
|
1938
1938
|
if ((c.filters ?? []).some((o) => {
|
|
1939
1939
|
const n = o;
|
|
1940
1940
|
return n?.kind === "values" && n.key === t;
|
|
@@ -1942,27 +1942,27 @@ function Te(c, t) {
|
|
|
1942
1942
|
const i = c.columnDiagnostics?.[t];
|
|
1943
1943
|
return !!(i?.errors || i?.warnings);
|
|
1944
1944
|
}
|
|
1945
|
-
function
|
|
1945
|
+
function _o() {
|
|
1946
1946
|
return `
|
|
1947
1947
|
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false">
|
|
1948
1948
|
<path d="M3 5h18l-7 8v6l-4 2v-8L3 5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/>
|
|
1949
1949
|
</svg>
|
|
1950
1950
|
`.trim();
|
|
1951
1951
|
}
|
|
1952
|
-
function
|
|
1952
|
+
function Fo(c) {
|
|
1953
1953
|
return `
|
|
1954
1954
|
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false">
|
|
1955
1955
|
<path d="${c === "asc" ? "M12 6l6 8H6l6-8z" : "M12 18l-6-8h12l-6 8z"}" fill="currentColor"/>
|
|
1956
1956
|
</svg>
|
|
1957
1957
|
`.trim();
|
|
1958
1958
|
}
|
|
1959
|
-
function
|
|
1959
|
+
function Vo(c, t, e, i, o, n) {
|
|
1960
1960
|
const s = Math.min(10, Math.floor(Math.min(i, o) / 2));
|
|
1961
1961
|
if (s <= 0) return;
|
|
1962
1962
|
const l = n === "error" ? "#ef4444" : "#f59e0b";
|
|
1963
1963
|
c.save(), c.fillStyle = l, c.beginPath(), c.moveTo(t + i, e), c.lineTo(t + i - s, e), c.lineTo(t + i, e + s), c.closePath(), c.fill(), c.restore();
|
|
1964
1964
|
}
|
|
1965
|
-
class
|
|
1965
|
+
class Ae {
|
|
1966
1966
|
constructor() {
|
|
1967
1967
|
this.numberFormatCache = /* @__PURE__ */ new Map(), this.dateParseCache = /* @__PURE__ */ new Map();
|
|
1968
1968
|
}
|
|
@@ -1974,17 +1974,17 @@ class Ee {
|
|
|
1974
1974
|
parseIsoDate(t) {
|
|
1975
1975
|
const e = this.dateParseCache.get(t);
|
|
1976
1976
|
if (e) return e;
|
|
1977
|
-
const i =
|
|
1977
|
+
const i = We(t);
|
|
1978
1978
|
return !i || Number.isNaN(i.getTime()) ? null : (this.dateParseCache.set(t, i), i);
|
|
1979
1979
|
}
|
|
1980
1980
|
}
|
|
1981
|
-
function
|
|
1981
|
+
function No(c, t, e, i, o) {
|
|
1982
1982
|
c.save(), c.globalAlpha = o, c.strokeStyle = "rgba(15,23,42,1)", c.lineWidth = 2, c.lineJoin = "round", c.beginPath(), c.moveTo(t, e), c.lineTo(t + i, e), c.lineTo(t + Math.round(i * 0.62), e + Math.round(i * 0.46)), c.lineTo(t + Math.round(i * 0.38), e + Math.round(i * 0.46)), c.closePath(), c.stroke(), c.beginPath(), c.moveTo(t + Math.round(i * 0.46), e + Math.round(i * 0.46)), c.lineTo(t + Math.round(i * 0.46), e + i), c.lineTo(t + Math.round(i * 0.54), e + i - 2), c.lineTo(t + Math.round(i * 0.54), e + Math.round(i * 0.46)), c.stroke(), c.restore();
|
|
1983
1983
|
}
|
|
1984
|
-
function
|
|
1984
|
+
function Po(c, t, e, i, o, n) {
|
|
1985
1985
|
c.save(), c.globalAlpha = o, c.fillStyle = "rgba(15,23,42,1)", c.beginPath(), n === "asc" ? (c.moveTo(t + i / 2, e), c.lineTo(t + i, e + i), c.lineTo(t, e + i)) : (c.moveTo(t, e), c.lineTo(t + i, e), c.lineTo(t + i / 2, e + i)), c.closePath(), c.fill(), c.restore();
|
|
1986
1986
|
}
|
|
1987
|
-
function
|
|
1987
|
+
function Wt(c) {
|
|
1988
1988
|
if (Array.isArray(c) && c.every((t) => typeof t == "string"))
|
|
1989
1989
|
return c;
|
|
1990
1990
|
if (c && typeof c == "object") {
|
|
@@ -1997,17 +1997,17 @@ function Bt(c) {
|
|
|
1997
1997
|
}
|
|
1998
1998
|
return null;
|
|
1999
1999
|
}
|
|
2000
|
-
function
|
|
2000
|
+
function He(c) {
|
|
2001
2001
|
if (!c || typeof c != "object") return null;
|
|
2002
2002
|
const t = c;
|
|
2003
2003
|
return typeof t.kind == "string" ? null : typeof t.label == "string" && "value" in t ? t.label : null;
|
|
2004
2004
|
}
|
|
2005
|
-
class
|
|
2005
|
+
class qt {
|
|
2006
2006
|
constructor(t) {
|
|
2007
2007
|
this.n = t, this.tree = new Array(t + 1).fill(0);
|
|
2008
2008
|
}
|
|
2009
2009
|
static from(t) {
|
|
2010
|
-
const e = new
|
|
2010
|
+
const e = new qt(t.length);
|
|
2011
2011
|
for (let i = 0; i < t.length; i += 1) e.add(i, t[i] ?? 0);
|
|
2012
2012
|
return e;
|
|
2013
2013
|
}
|
|
@@ -2049,7 +2049,7 @@ class Ot {
|
|
|
2049
2049
|
}
|
|
2050
2050
|
class St {
|
|
2051
2051
|
constructor(t) {
|
|
2052
|
-
this.dataModel = t, this.tableEl = null, this.defaultRowHeight = ft, this.rowHeaderWidth =
|
|
2052
|
+
this.dataModel = t, this.tableEl = null, this.defaultRowHeight = ft, this.rowHeaderWidth = lt, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new Ae(), this.measureCache = /* @__PURE__ */ new Map(), this.frame = 0;
|
|
2053
2053
|
}
|
|
2054
2054
|
mount(t) {
|
|
2055
2055
|
this.tableEl = document.createElement("table"), this.tableEl.dataset.extableRenderer = "html", t.innerHTML = "", t.appendChild(this.tableEl), this.render();
|
|
@@ -2064,17 +2064,17 @@ class St {
|
|
|
2064
2064
|
if (this.frame += 1, !this.tableEl) return;
|
|
2065
2065
|
const e = this.tableEl.parentElement, i = e?.scrollTop ?? 0, o = e?.scrollLeft ?? 0, n = this.dataModel.getSchema(), s = this.dataModel.getView(), l = this.dataModel.listRows();
|
|
2066
2066
|
this.tableEl.innerHTML = "";
|
|
2067
|
-
const a =
|
|
2068
|
-
this.tableEl.style.width = `${
|
|
2067
|
+
const a = Y(n, s), r = n.columns.map((p) => Ft(p)), h = r.map((p) => ne(p)), d = this.rowHeaderWidth + a.reduce((p, m) => p + (m ?? 0), 0);
|
|
2068
|
+
this.tableEl.style.width = `${d}px`, this.tableEl.appendChild(this.renderHeader(n, a));
|
|
2069
2069
|
const u = document.createElement("tbody");
|
|
2070
2070
|
for (const p of l)
|
|
2071
|
-
u.appendChild(this.renderRow(p, n, a, r,
|
|
2071
|
+
u.appendChild(this.renderRow(p, n, a, r, h));
|
|
2072
2072
|
this.tableEl.appendChild(u), this.updateActiveClasses(), this.applySelectionClasses(), e && (e.scrollTop = i, e.scrollLeft = o);
|
|
2073
|
-
for (const [p,
|
|
2074
|
-
|
|
2073
|
+
for (const [p, m] of Array.from(this.measureCache.entries()))
|
|
2074
|
+
m.frame !== this.frame && this.measureCache.delete(p);
|
|
2075
2075
|
}
|
|
2076
2076
|
destroy() {
|
|
2077
|
-
|
|
2077
|
+
O(this.tableEl), this.tableEl = null;
|
|
2078
2078
|
}
|
|
2079
2079
|
getCellElements() {
|
|
2080
2080
|
return this.tableEl?.querySelectorAll("tr[data-row-id] td[data-col-key]") ?? null;
|
|
@@ -2092,21 +2092,29 @@ class St {
|
|
|
2092
2092
|
};
|
|
2093
2093
|
const o = e.closest("th.extable-row-header:not(.extable-corner)");
|
|
2094
2094
|
if (o) {
|
|
2095
|
-
const
|
|
2096
|
-
if (
|
|
2095
|
+
const a = o.closest("tr[data-row-id]");
|
|
2096
|
+
if (a)
|
|
2097
2097
|
return {
|
|
2098
|
-
rowId:
|
|
2098
|
+
rowId: a.dataset.rowId ?? "",
|
|
2099
2099
|
colKey: null,
|
|
2100
2100
|
element: o,
|
|
2101
2101
|
rect: o.getBoundingClientRect()
|
|
2102
2102
|
};
|
|
2103
2103
|
}
|
|
2104
|
-
const n = e.closest("
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2104
|
+
const n = e.closest("th[data-col-key]:not(.extable-row-header)");
|
|
2105
|
+
if (n)
|
|
2106
|
+
return {
|
|
2107
|
+
rowId: "__header__",
|
|
2108
|
+
colKey: n.dataset.colKey ?? "",
|
|
2109
|
+
element: n,
|
|
2110
|
+
rect: n.getBoundingClientRect()
|
|
2111
|
+
};
|
|
2112
|
+
const s = e.closest("td[data-col-key]"), l = s?.closest("tr[data-row-id]");
|
|
2113
|
+
return !s || !l ? null : {
|
|
2114
|
+
rowId: l.dataset.rowId ?? "",
|
|
2115
|
+
colKey: s.dataset.colKey ?? "",
|
|
2116
|
+
element: s,
|
|
2117
|
+
rect: s.getBoundingClientRect()
|
|
2110
2118
|
};
|
|
2111
2119
|
}
|
|
2112
2120
|
hitTestAction(t) {
|
|
@@ -2116,12 +2124,12 @@ class St {
|
|
|
2116
2124
|
if (i && !i.disabled) {
|
|
2117
2125
|
const a = i.closest("td[data-col-key]"), r = a?.closest("tr[data-row-id]");
|
|
2118
2126
|
if (!a || !r) return null;
|
|
2119
|
-
const
|
|
2120
|
-
return Number.isFinite(
|
|
2127
|
+
const h = i.dataset.extableTagIndex, d = h ? Number.parseInt(h, 10) : Number.NaN;
|
|
2128
|
+
return Number.isFinite(d) ? {
|
|
2121
2129
|
rowId: r.dataset.rowId ?? "",
|
|
2122
2130
|
colKey: a.dataset.colKey ?? "",
|
|
2123
2131
|
kind: "tag-remove",
|
|
2124
|
-
tagIndex:
|
|
2132
|
+
tagIndex: d
|
|
2125
2133
|
} : null;
|
|
2126
2134
|
}
|
|
2127
2135
|
const o = e.closest("[data-extable-action]");
|
|
@@ -2146,89 +2154,95 @@ class St {
|
|
|
2146
2154
|
if (!a) continue;
|
|
2147
2155
|
const r = document.createElement("th");
|
|
2148
2156
|
r.dataset.colKey = a.key;
|
|
2149
|
-
const
|
|
2150
|
-
|
|
2157
|
+
const h = Te(s, a.key), d = Ee(s, a.key);
|
|
2158
|
+
h ? r.dataset.extableSortDir = h : r.removeAttribute("data-extable-sort-dir"), d ? r.dataset.extableFsActive = "1" : r.removeAttribute("data-extable-fs-active");
|
|
2151
2159
|
const u = document.createElement("div");
|
|
2152
2160
|
u.className = "extable-col-header";
|
|
2153
2161
|
const p = document.createElement("span");
|
|
2154
2162
|
p.className = "extable-col-header-text", p.textContent = a.header ?? a.key;
|
|
2155
|
-
const
|
|
2156
|
-
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2163
|
+
const m = document.createElement("button");
|
|
2164
|
+
m.type = "button", m.className = "extable-filter-sort-trigger", m.dataset.extableFsOpen = "1", m.dataset.extableColKey = a.key, m.title = "Filter / Sort", m.innerHTML = h ? Fo(h) : _o(), u.appendChild(p), u.appendChild(m), r.appendChild(u);
|
|
2165
|
+
const b = e[l] ?? a.width;
|
|
2166
|
+
b && (r.style.width = `${b}px`), r.dataset.colKey = a.key, this.activeColKey !== null && this.activeColKey === a.key && r.classList.add("extable-active-col-header"), o.appendChild(r);
|
|
2159
2167
|
}
|
|
2160
2168
|
return i.appendChild(o), i;
|
|
2161
2169
|
}
|
|
2162
2170
|
renderRow(t, e, i, o, n) {
|
|
2163
2171
|
const s = document.createElement("tr");
|
|
2164
|
-
s.dataset.rowId = t.id, s.style.height = `${this.defaultRowHeight}px
|
|
2165
|
-
const
|
|
2166
|
-
|
|
2167
|
-
const
|
|
2168
|
-
|
|
2169
|
-
for (let
|
|
2170
|
-
const
|
|
2171
|
-
if (!
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2174
|
-
const
|
|
2175
|
-
if (!
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2172
|
+
s.dataset.rowId = t.id, s.style.height = `${this.defaultRowHeight}px`, e.columns.some((u) => u && u.type === "boolean" && u.unique && this.dataModel.getCell(t.id, u.key) === !0) && s.classList.add("extable-row--unique-true");
|
|
2173
|
+
const a = this.dataModel.getView(), r = document.createElement("th");
|
|
2174
|
+
r.scope = "row", r.classList.add("extable-row-header");
|
|
2175
|
+
const h = this.dataModel.getDisplayIndex(t.id) ?? "";
|
|
2176
|
+
r.textContent = String(h), this.activeRowId === t.id && r.classList.add("extable-active-row-header"), s.appendChild(r);
|
|
2177
|
+
for (let u = 0; u < e.columns.length; u += 1) {
|
|
2178
|
+
const p = e.columns[u];
|
|
2179
|
+
if (!p) continue;
|
|
2180
|
+
const m = document.createElement("td");
|
|
2181
|
+
m.classList.add("extable-cell"), m.dataset.colKey = p.key, p.type === "boolean" && m.classList.add("extable-boolean");
|
|
2182
|
+
const b = this.dataModel.hasPending(t.id, p.key), x = this.dataModel.resolveConditionalStyle(t.id, p), w = this.dataModel.getCellStyle(t.id, p.key), f = !!(w?.textColor || x.delta?.textColor || p.style?.textColor);
|
|
2183
|
+
if (!w && !x.delta && !b) {
|
|
2184
|
+
const k = n[u] ?? "";
|
|
2185
|
+
k && (m.style.cssText = k);
|
|
2178
2186
|
} else {
|
|
2179
|
-
const
|
|
2180
|
-
|
|
2187
|
+
const k = o[u] ?? {}, N = x.delta ? rt(k, x.delta) : k, T = w ? rt(N, w) : N, E = b ? { ...T, textColor: void 0 } : T, H = ne(E);
|
|
2188
|
+
H && (m.style.cssText = H);
|
|
2181
2189
|
}
|
|
2182
|
-
const y =
|
|
2183
|
-
|
|
2184
|
-
const
|
|
2185
|
-
if (
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2188
|
-
const
|
|
2189
|
-
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2192
|
-
const
|
|
2193
|
-
|
|
2194
|
-
}),
|
|
2195
|
-
} else if (
|
|
2196
|
-
const
|
|
2197
|
-
|
|
2198
|
-
} else
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2190
|
+
const y = a.wrapText?.[p.key] ?? p.wrapText;
|
|
2191
|
+
m.classList.add(y ? "cell-wrap" : "cell-nowrap");
|
|
2192
|
+
const g = this.dataModel.getRawCell(t.id, p.key), v = this.dataModel.resolveCellValue(t.id, p), C = v.textOverride ?? (x.forceErrorText ? "#ERROR" : void 0), S = C ? { text: C } : this.formatValue(v.value, p), M = this.dataModel.getCellInteraction(t.id, p.key), L = p.type === "tags" && !C ? Wt(v.value) : null, _ = p.type === "button" || p.type === "link", K = _ ? p.type === "button" ? pt(v.value) : mt(v.value) : null, R = _ ? p.type === "button" ? ct(v.value) : ht(v.value) : "";
|
|
2193
|
+
if (L && L.length) {
|
|
2194
|
+
const k = document.createElement("div");
|
|
2195
|
+
k.className = "extable-tag-list", L.forEach((N, T) => {
|
|
2196
|
+
const E = document.createElement("span");
|
|
2197
|
+
E.className = "extable-tag";
|
|
2198
|
+
const H = document.createElement("span");
|
|
2199
|
+
H.className = "extable-tag-label", H.textContent = N;
|
|
2200
|
+
const P = document.createElement("button");
|
|
2201
|
+
P.type = "button", P.className = "extable-tag-remove", P.dataset.extableTagRemove = "1", P.dataset.extableTagIndex = String(T), P.textContent = "×", (M.readonly || M.disabled) && (P.disabled = !0), E.appendChild(H), E.appendChild(P), k.appendChild(E);
|
|
2202
|
+
}), m.replaceChildren(k);
|
|
2203
|
+
} else if (_ && !C && K && R) {
|
|
2204
|
+
const k = p.type === "button" ? document.createElement("button") : document.createElement("span");
|
|
2205
|
+
k instanceof HTMLButtonElement && (k.type = "button"), k.className = p.type === "button" ? "extable-action-button" : "extable-action-link", M.disabled && k.classList.add("extable-action-disabled"), p.type === "link" && f && (k.style.color = "inherit"), k.dataset.extableAction = p.type, k.textContent = R, m.replaceChildren(k);
|
|
2206
|
+
} else if (p.type === "boolean" && !C)
|
|
2207
|
+
if (p.unique) {
|
|
2208
|
+
const k = document.createElement("input");
|
|
2209
|
+
k.type = "radio", k.name = `extable-unique-${String(p.key)}`, k.checked = !!v.value, (M.readonly || M.disabled) && (k.disabled = !0), k.className = "extable-unique-radio", k.setAttribute("aria-label", p.header ?? String(p.key)), m.replaceChildren(k);
|
|
2210
|
+
} else
|
|
2211
|
+
m.textContent = S.text, S.color && (m.style.color = S.color);
|
|
2212
|
+
else
|
|
2213
|
+
m.textContent = R || S.text, S.color && (m.style.color = S.color);
|
|
2214
|
+
const A = this.dataModel.getCellMarker(t.id, p.key);
|
|
2215
|
+
A ? (m.classList.toggle("extable-diag-warning", A.level === "warning"), m.classList.toggle("extable-diag-error", A.level === "error"), m.dataset.extableDiagMessage = A.message) : (m.classList.remove("extable-diag-warning", "extable-diag-error"), m.removeAttribute("data-extable-diag-message"));
|
|
2216
|
+
const D = p.style?.align ?? (p.type === "number" || p.type === "int" || p.type === "uint" ? "right" : "left");
|
|
2217
|
+
m.classList.add(D === "right" ? "align-right" : "align-left");
|
|
2218
|
+
const V = $e(g, v.value, p);
|
|
2219
|
+
if (V !== null)
|
|
2220
|
+
m.dataset.raw = V;
|
|
2207
2221
|
else {
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2222
|
+
const k = g == null ? "" : String(g);
|
|
2223
|
+
m.dataset.raw = k;
|
|
2210
2224
|
}
|
|
2211
|
-
|
|
2212
|
-
}
|
|
2213
|
-
if (e.columns.some((
|
|
2214
|
-
let
|
|
2215
|
-
for (let
|
|
2216
|
-
const
|
|
2217
|
-
if (!
|
|
2218
|
-
const
|
|
2219
|
-
if (
|
|
2220
|
-
|
|
2225
|
+
b && m.classList.add("pending"), M.readonly ? (m.classList.add("extable-readonly"), p.formula && m.classList.add("extable-readonly-formula")) : m.classList.add("extable-editable"), M.muted && m.classList.add("extable-readonly-muted"), M.disabled && m.classList.add("extable-disabled"), this.activeRowId === t.id && this.activeColKey !== null && this.activeColKey === p.key && m.classList.add("extable-active-cell"), s.appendChild(m);
|
|
2226
|
+
}
|
|
2227
|
+
if (e.columns.some((u) => a.wrapText?.[u.key] ?? u.wrapText)) {
|
|
2228
|
+
let u = this.defaultRowHeight;
|
|
2229
|
+
for (let p = 0; p < e.columns.length; p += 1) {
|
|
2230
|
+
const m = e.columns[p];
|
|
2231
|
+
if (!m || !m.wrapText) continue;
|
|
2232
|
+
const b = i[p] ?? a.columnWidths?.[m.key] ?? m.width ?? 100, x = this.dataModel.resolveCellValue(t.id, m), w = this.dataModel.resolveConditionalStyle(t.id, m), y = x.textOverride ?? (w.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : this.formatValue(x.value, m).text, g = this.dataModel.getRowVersion(t.id), v = `${t.id}|${m.key}|${g}|${b}|${y}`, C = this.measureCache.get(v);
|
|
2233
|
+
if (C) {
|
|
2234
|
+
C.frame = this.frame, this.measureCache.set(v, C), u = Math.max(u, C.height);
|
|
2221
2235
|
continue;
|
|
2222
2236
|
}
|
|
2223
2237
|
const S = document.createElement("span");
|
|
2224
|
-
S.style.visibility = "hidden", S.style.position = "absolute", S.style.left = "-10000px", S.style.top = "0", S.style.whiteSpace = "pre-wrap", S.style.overflowWrap = "anywhere", S.style.display = "inline-block", S.style.width = `${
|
|
2225
|
-
const
|
|
2226
|
-
if (!
|
|
2227
|
-
|
|
2228
|
-
const
|
|
2229
|
-
S.remove(), this.measureCache.set(
|
|
2238
|
+
S.style.visibility = "hidden", S.style.position = "absolute", S.style.left = "-10000px", S.style.top = "0", S.style.whiteSpace = "pre-wrap", S.style.overflowWrap = "anywhere", S.style.display = "inline-block", S.style.width = `${b}px`, S.textContent = y;
|
|
2239
|
+
const M = this.tableEl?.parentElement;
|
|
2240
|
+
if (!M) continue;
|
|
2241
|
+
M.appendChild(S);
|
|
2242
|
+
const L = S.clientHeight + at + Mt + 2;
|
|
2243
|
+
S.remove(), this.measureCache.set(v, { height: L, frame: this.frame }), u = Math.max(u, L);
|
|
2230
2244
|
}
|
|
2231
|
-
s.style.height = `${
|
|
2245
|
+
s.style.height = `${u}px`, this.dataModel.setRowHeight(t.id, u);
|
|
2232
2246
|
} else
|
|
2233
2247
|
s.style.height = `${this.defaultRowHeight}px`, this.dataModel.setRowHeight(t.id, this.defaultRowHeight);
|
|
2234
2248
|
return s;
|
|
@@ -2275,11 +2289,11 @@ class St {
|
|
|
2275
2289
|
for (let a = o; a <= n; a += 1) {
|
|
2276
2290
|
const r = t[a];
|
|
2277
2291
|
if (!r) continue;
|
|
2278
|
-
const
|
|
2279
|
-
|
|
2280
|
-
const
|
|
2292
|
+
const h = r.querySelector("th.extable-row-header");
|
|
2293
|
+
h && h.classList.add("extable-selected");
|
|
2294
|
+
const d = Array.from(r.querySelectorAll("td"));
|
|
2281
2295
|
for (let u = s; u <= l; u += 1) {
|
|
2282
|
-
const p =
|
|
2296
|
+
const p = d[u];
|
|
2283
2297
|
p && p.classList.add("extable-selected");
|
|
2284
2298
|
}
|
|
2285
2299
|
}
|
|
@@ -2291,15 +2305,15 @@ class St {
|
|
|
2291
2305
|
const i = t;
|
|
2292
2306
|
if (i.kind === "lookup" && typeof i.label == "string")
|
|
2293
2307
|
return { text: i.label };
|
|
2294
|
-
const o =
|
|
2308
|
+
const o = He(t);
|
|
2295
2309
|
if (o !== null) return { text: o };
|
|
2296
2310
|
}
|
|
2297
2311
|
if (e.type === "button")
|
|
2298
|
-
return { text: at(t) || String(t) };
|
|
2299
|
-
if (e.type === "link")
|
|
2300
2312
|
return { text: ct(t) || String(t) };
|
|
2313
|
+
if (e.type === "link")
|
|
2314
|
+
return { text: ht(t) || String(t) };
|
|
2301
2315
|
if (e.type === "tags") {
|
|
2302
|
-
const i =
|
|
2316
|
+
const i = Wt(t);
|
|
2303
2317
|
if (i) return { text: i.join(", ") };
|
|
2304
2318
|
}
|
|
2305
2319
|
if (e.type === "boolean")
|
|
@@ -2307,8 +2321,8 @@ class St {
|
|
|
2307
2321
|
if (e.type === "number" && typeof t == "number") {
|
|
2308
2322
|
const i = t, o = e.format;
|
|
2309
2323
|
if ((o?.format ?? "decimal") === "scientific") {
|
|
2310
|
-
const r =
|
|
2311
|
-
return { text: r, color:
|
|
2324
|
+
const r = Rt(i, { format: "scientific", precision: o?.precision }), h = o?.negativeRed && i < 0 ? "#b91c1c" : void 0;
|
|
2325
|
+
return { text: r, color: h };
|
|
2312
2326
|
}
|
|
2313
2327
|
const s = {};
|
|
2314
2328
|
o?.scale !== void 0 && (s.minimumFractionDigits = o.scale, s.maximumFractionDigits = o.scale), s.useGrouping = !!o?.thousandSeparator;
|
|
@@ -2318,8 +2332,8 @@ class St {
|
|
|
2318
2332
|
if ((e.type === "int" || e.type === "uint") && typeof t == "number") {
|
|
2319
2333
|
const i = t, o = e.format, n = o?.format ?? "decimal";
|
|
2320
2334
|
if (n === "binary" || n === "octal" || n === "hex") {
|
|
2321
|
-
const r =
|
|
2322
|
-
return { text: r, color:
|
|
2335
|
+
const r = Ot(i, n), h = o?.negativeRed && i < 0 ? "#b91c1c" : void 0;
|
|
2336
|
+
return { text: r, color: h };
|
|
2323
2337
|
}
|
|
2324
2338
|
const s = {
|
|
2325
2339
|
minimumFractionDigits: 0,
|
|
@@ -2329,35 +2343,35 @@ class St {
|
|
|
2329
2343
|
return { text: l, color: a };
|
|
2330
2344
|
}
|
|
2331
2345
|
if ((e.type === "date" || e.type === "time" || e.type === "datetime") && (t instanceof Date || typeof t == "string")) {
|
|
2332
|
-
const i = e.format, o = e.type === "date" ?
|
|
2346
|
+
const i = e.format, o = e.type === "date" ? Kt(i, "date") : e.type === "time" ? Kt(i, "time") : Kt(i, "datetime");
|
|
2333
2347
|
let n = null;
|
|
2334
|
-
return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text:
|
|
2348
|
+
return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text: de(n, o) } : { text: String(t) };
|
|
2335
2349
|
}
|
|
2336
2350
|
return { text: String(t) };
|
|
2337
2351
|
}
|
|
2338
2352
|
}
|
|
2339
|
-
const
|
|
2353
|
+
const z = class z {
|
|
2340
2354
|
constructor(t, e = () => "direct") {
|
|
2341
|
-
this.getEditMode = e, this.root = null, this.canvas = null, this.spacer = null, this.overlayLayer = null, this.tooltip = null, this.tooltipTarget = null, this.tooltipMessage = null, this.rowHeight = ft, this.headerHeight =
|
|
2355
|
+
this.getEditMode = e, this.root = null, this.canvas = null, this.spacer = null, this.overlayLayer = null, this.tooltip = null, this.tooltipTarget = null, this.tooltipMessage = null, this.rowHeight = ft, this.headerHeight = st, this.lineHeight = 16, this.padding = 12, this.rowHeaderWidth = lt, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new Ae(), this.textMeasureCache = /* @__PURE__ */ new Map(), this.frame = 0, this.cursorTimer = null, this.pendingCursorPoint = null, this.hoverHeaderColKey = null, this.hoverHeaderIcon = !1, this.hoverActionKey = null, this.activeActionKey = null, this.rowHeightCacheKey = null, this.rowHeightMeasuredVersion = /* @__PURE__ */ new Map(), this.rowHeightMeasureRaf = null, this.rowHeightMeasureTask = null, this.heightIndex = null, this.handleClick = (i) => {
|
|
2342
2356
|
if (!this.root || !this.canvas) return;
|
|
2343
2357
|
const o = this.canvas.getBoundingClientRect(), n = i.clientX - o.left, s = i.clientY - o.top, l = n + this.root.scrollLeft, a = s;
|
|
2344
2358
|
if (a >= this.headerHeight || l < this.rowHeaderWidth) return;
|
|
2345
|
-
const r = this.dataModel.getSchema(),
|
|
2359
|
+
const r = this.dataModel.getSchema(), h = this.dataModel.getView(), d = Y(r, h);
|
|
2346
2360
|
let u = this.rowHeaderWidth, p = -1;
|
|
2347
|
-
for (let
|
|
2348
|
-
const
|
|
2349
|
-
if (l >= u && l <= u +
|
|
2350
|
-
p =
|
|
2361
|
+
for (let v = 0; v < d.length; v += 1) {
|
|
2362
|
+
const C = d[v] ?? 100;
|
|
2363
|
+
if (l >= u && l <= u + C) {
|
|
2364
|
+
p = v;
|
|
2351
2365
|
break;
|
|
2352
2366
|
}
|
|
2353
|
-
u +=
|
|
2367
|
+
u += C;
|
|
2354
2368
|
}
|
|
2355
2369
|
if (p < 0) return;
|
|
2356
|
-
const
|
|
2357
|
-
if (!
|
|
2358
|
-
const
|
|
2359
|
-
l >=
|
|
2360
|
-
new CustomEvent("extable:filter-sort-open", { bubbles: !0, detail: { colKey:
|
|
2370
|
+
const m = r.columns[p];
|
|
2371
|
+
if (!m) return;
|
|
2372
|
+
const b = d[p] ?? 100, x = 18, f = u + b - x - 4, y = Math.floor((this.headerHeight - x) / 2);
|
|
2373
|
+
l >= f && l <= f + x && a >= y && a <= y + x && this.root.dispatchEvent(
|
|
2374
|
+
new CustomEvent("extable:filter-sort-open", { bubbles: !0, detail: { colKey: m.key } })
|
|
2361
2375
|
);
|
|
2362
2376
|
}, this.handlePointerMove = (i) => {
|
|
2363
2377
|
this.pendingCursorPoint = { x: i.clientX, y: i.clientY }, !this.cursorTimer && (this.cursorTimer = window.setTimeout(() => {
|
|
@@ -2381,7 +2395,7 @@ const q = class q {
|
|
|
2381
2395
|
}
|
|
2382
2396
|
mount(t) {
|
|
2383
2397
|
this.root = t, this.canvas = document.createElement("canvas");
|
|
2384
|
-
const e =
|
|
2398
|
+
const e = z.MAX_CANVAS_DIM_PX;
|
|
2385
2399
|
this.canvas.width = Math.max(1, Math.min(e, Math.floor(t.clientWidth || 600))), this.canvas.height = Math.max(1, Math.min(e, Math.floor(t.clientHeight || 400))), this.canvas.style.width = `${this.canvas.width}px`, this.canvas.style.height = `${this.canvas.height}px`, this.canvas.dataset.extableRenderer = "canvas", this.canvas.style.position = "sticky", this.canvas.style.top = "0", this.canvas.style.left = "0", this.canvas.style.zIndex = "1", this.canvas.style.cursor = "cell", this.canvas.addEventListener("pointermove", this.handlePointerMove), this.canvas.addEventListener("pointerdown", this.handlePointerDown), this.canvas.addEventListener("pointerup", this.handlePointerUp), this.canvas.addEventListener("pointerleave", this.handlePointerLeave), this.canvas.addEventListener("click", this.handleClick), this.spacer = document.createElement("div"), this.spacer.style.width = "1px", this.tooltip && this.tooltip.remove(), this.overlayLayer && this.overlayLayer.remove(), this.overlayLayer = document.createElement("div"), this.overlayLayer.className = "extable-overlay-layer", this.tooltip = document.createElement("div"), this.tooltip.className = "extable-tooltip", this.tooltip.dataset.visible = "0", this.overlayLayer.appendChild(this.tooltip), t.innerHTML = "", t.style.position = "relative", t.appendChild(this.overlayLayer), t.appendChild(this.canvas), t.appendChild(this.spacer), this.render();
|
|
2386
2400
|
}
|
|
2387
2401
|
setActiveCell(t, e) {
|
|
@@ -2395,145 +2409,149 @@ const q = class q {
|
|
|
2395
2409
|
if (this.frame += 1, !this.canvas || !this.root) return;
|
|
2396
2410
|
const e = this.canvas.getContext("2d");
|
|
2397
2411
|
if (!e) return;
|
|
2398
|
-
e.font = `${
|
|
2412
|
+
e.font = `${Z}px ${Q}`;
|
|
2399
2413
|
let i = e.font;
|
|
2400
|
-
const o = this.activeRowId === "__all__" && this.activeColKey === "__all__", n = this.dataModel.getSchema(), s = this.dataModel.getView(), l = this.dataModel.listRows(), a =
|
|
2401
|
-
u !== this.rowHeightCacheKey && (this.rowHeightCacheKey = u, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null),
|
|
2414
|
+
const o = this.activeRowId === "__all__" && this.activeColKey === "__all__", n = this.dataModel.getSchema(), s = this.dataModel.getView(), l = this.dataModel.listRows(), a = Y(n, s), r = n.columns.map((T) => Ft(T)), h = /* @__PURE__ */ new Map(), d = n.columns.some((T) => s.wrapText?.[T.key] ?? T.wrapText), u = d ? this.getRowHeightCacheKey(n, s, a) : null;
|
|
2415
|
+
u !== this.rowHeightCacheKey && (this.rowHeightCacheKey = u, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null), d || this.cancelRowHeightMeasurement(), this.ensureHeightIndex(l, d ? u : null, d);
|
|
2402
2416
|
const p = this.heightIndex;
|
|
2403
2417
|
if (!p) return;
|
|
2404
|
-
const
|
|
2405
|
-
this.canvas.width !==
|
|
2406
|
-
const
|
|
2407
|
-
const
|
|
2418
|
+
const m = this.rowHeaderWidth + a.reduce((T, E) => T + (E ?? 0), 0), b = t?.clientWidth ?? (this.root.clientWidth || 600), x = t?.clientHeight ?? (this.root.clientHeight || this.canvas.height || 400), w = z.MAX_CANVAS_DIM_PX, f = Math.max(1, Math.min(w, Math.floor(b))), y = Math.max(1, Math.min(w, Math.floor(x)));
|
|
2419
|
+
this.canvas.width !== f && (this.canvas.width = f), this.canvas.height !== y && (this.canvas.height = y), this.canvas.style.width = `${f}px`, this.canvas.style.height = `${y}px`, e.font = `${Z}px ${Q}`, i = e.font, this.refreshTooltipPosition();
|
|
2420
|
+
const g = t?.scrollTop ?? this.root.scrollTop, v = t?.scrollLeft ?? this.root.scrollLeft, C = (T) => {
|
|
2421
|
+
const E = T + 1, H = Math.max(
|
|
2408
2422
|
0,
|
|
2409
|
-
Math.min(l.length - 1, p.fenwick.lowerBound(
|
|
2410
|
-
),
|
|
2411
|
-
let
|
|
2412
|
-
const
|
|
2413
|
-
for (let I =
|
|
2414
|
-
|
|
2415
|
-
return { accum:
|
|
2423
|
+
Math.min(l.length - 1, p.fenwick.lowerBound(E))
|
|
2424
|
+
), P = p.fenwick.sum(H);
|
|
2425
|
+
let F = H, q = 0;
|
|
2426
|
+
const j = (this.canvas?.height ?? 0) + this.rowHeight * 2;
|
|
2427
|
+
for (let I = H; I < l.length && q < j; I += 1)
|
|
2428
|
+
q += p.heights[I] ?? this.rowHeight, F = I + 1;
|
|
2429
|
+
return { accum: P, visibleStart: H, visibleEnd: F };
|
|
2416
2430
|
};
|
|
2417
|
-
let
|
|
2418
|
-
const
|
|
2419
|
-
let
|
|
2420
|
-
if (
|
|
2421
|
-
const
|
|
2422
|
-
for (let
|
|
2423
|
-
const
|
|
2424
|
-
if (!
|
|
2425
|
-
const
|
|
2426
|
-
if (this.rowHeightMeasuredVersion.get(
|
|
2427
|
-
const
|
|
2428
|
-
|
|
2431
|
+
let S = p.fenwick.total();
|
|
2432
|
+
const M = this.canvas?.height ?? this.root.clientHeight, L = Math.max(0, M - this.headerHeight);
|
|
2433
|
+
let _ = Math.max(0, S - L), K = Math.max(0, Math.min(g, _)), { accum: R, visibleStart: A, visibleEnd: D } = C(K);
|
|
2434
|
+
if (d && u) {
|
|
2435
|
+
const T = {};
|
|
2436
|
+
for (let E = A; E < D; E += 1) {
|
|
2437
|
+
const H = l[E];
|
|
2438
|
+
if (!H) continue;
|
|
2439
|
+
const P = this.dataModel.getRowVersion(H.id);
|
|
2440
|
+
if (this.rowHeightMeasuredVersion.get(H.id) === P) continue;
|
|
2441
|
+
const F = this.measureRowHeight(e, H, n, a);
|
|
2442
|
+
T[H.id] = F, this.rowHeightMeasuredVersion.set(H.id, P);
|
|
2429
2443
|
}
|
|
2430
|
-
this.applyRowHeightUpdates(
|
|
2444
|
+
this.applyRowHeightUpdates(T), S = p.fenwick.total(), this.dataModel.setRowHeightsBulk(T), _ = Math.max(0, S - L), K = Math.max(0, Math.min(g, _)), { accum: R, visibleStart: A, visibleEnd: D } = C(K), (this.rowHeightMeasureTask || Object.keys(T).length > 0) && this.scheduleRowHeightMeasurement();
|
|
2431
2445
|
}
|
|
2432
|
-
this.spacer && (this.spacer.style.height = `${
|
|
2433
|
-
const
|
|
2446
|
+
this.spacer && (this.spacer.style.height = `${_}px`, this.spacer.style.width = `${m}px`);
|
|
2447
|
+
const V = this.rowHeaderWidth - v;
|
|
2434
2448
|
e.clearRect(0, 0, this.canvas.width, this.canvas.height), e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.rowHeaderWidth, this.canvas.height);
|
|
2435
|
-
let
|
|
2436
|
-
for (let
|
|
2437
|
-
const
|
|
2438
|
-
e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0,
|
|
2439
|
-
const
|
|
2440
|
-
this.activeRowId ===
|
|
2449
|
+
let k = this.headerHeight + R - K;
|
|
2450
|
+
for (let T = A; T < D; T += 1) {
|
|
2451
|
+
const E = l[T], H = p.heights[T] ?? this.rowHeight;
|
|
2452
|
+
e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0, k, this.rowHeaderWidth, H), e.strokeRect(0, k, this.rowHeaderWidth, H);
|
|
2453
|
+
const P = this.dataModel.getDisplayIndex(E.id) ?? "";
|
|
2454
|
+
this.activeRowId === E.id && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, k, this.rowHeaderWidth, H)), e.fillStyle = "#0f172a", e.font = `bold ${Z}px ${Q}`, e.textAlign = "center", e.textBaseline = "middle", e.fillText(String(P), this.rowHeaderWidth / 2, k + H / 2), e.font = i, e.textAlign = "left", e.textBaseline = "alphabetic", e.save(), e.beginPath(), e.rect(
|
|
2441
2455
|
this.rowHeaderWidth,
|
|
2442
2456
|
this.headerHeight,
|
|
2443
2457
|
this.canvas.width - this.rowHeaderWidth,
|
|
2444
2458
|
this.canvas.height - this.headerHeight
|
|
2445
|
-
), e.clip(), e.translate(
|
|
2446
|
-
let
|
|
2447
|
-
for (let
|
|
2448
|
-
const I = n.columns[
|
|
2459
|
+
), e.clip(), e.translate(V, 0);
|
|
2460
|
+
let F = 0, q = "";
|
|
2461
|
+
for (let j = 0; j < n.columns.length; j += 1) {
|
|
2462
|
+
const I = n.columns[j], $ = a[j] ?? 100;
|
|
2449
2463
|
if (!I) {
|
|
2450
|
-
|
|
2464
|
+
F += $;
|
|
2451
2465
|
continue;
|
|
2452
2466
|
}
|
|
2453
|
-
const
|
|
2467
|
+
const W = this.dataModel.getCellInteraction(E.id, I.key), it = W.muted;
|
|
2454
2468
|
e.strokeStyle = "#d0d7de";
|
|
2455
|
-
const
|
|
2456
|
-
e.fillStyle =
|
|
2457
|
-
const
|
|
2458
|
-
|
|
2469
|
+
const ot = this.dataModel.resolveConditionalStyle(E.id, I), dt = this.dataModel.getCellStyle(E.id, I.key), zt = r[j] ?? {}, Ut = ot.delta ? rt(zt, ot.delta) : zt, U = dt ? rt(Ut, dt) : Ut, Le = n.columns.some((B) => B && B.type === "boolean" && B.unique && this.dataModel.getCell(E.id, B.key) === !0) ? "rgba(59,130,246,0.06)" : it ? "#f3f4f6" : U.backgroundColor ?? "#ffffff";
|
|
2470
|
+
e.fillStyle = Le, e.fillRect(F, k, $, H), e.strokeRect(F, k, $, H);
|
|
2471
|
+
const X = this.dataModel.resolveCellValue(E.id, I), Xt = X.textOverride ?? (ot.forceErrorText ? "#ERROR" : void 0), gt = Xt ? { text: "#ERROR" } : this.formatValue(X.value, I), Et = I.type === "button" || I.type === "link", Gt = Et ? I.type === "button" ? pt(X.value) : mt(X.value) : null, Yt = Et ? Gt?.label ?? (I.type === "button" ? ct(X.value) : ht(X.value)) : "", yt = !!(Et && Gt && Yt && !Xt);
|
|
2472
|
+
let At = Yt || gt.text;
|
|
2473
|
+
I.type === "boolean" && I.unique && (At = X.value === !0 || X.value === "true" || X.value === "1" || X.value === 1 ? "🔵" : "");
|
|
2474
|
+
const Qt = I.style?.align ?? (I.type === "number" ? "right" : "left");
|
|
2475
|
+
if (this.activeRowId === E.id && this.activeColKey !== null && this.activeColKey === I.key && (e.strokeStyle = "#3b82f6", e.lineWidth = 2, e.strokeRect(F + 1, k + 1, $ - 2, H - 2), e.lineWidth = 1, kt(
|
|
2459
2476
|
this.dataModel,
|
|
2460
2477
|
this.selection,
|
|
2461
2478
|
this.activeRowId,
|
|
2462
2479
|
this.activeColKey,
|
|
2463
2480
|
this.getEditMode()
|
|
2464
2481
|
))) {
|
|
2465
|
-
const
|
|
2466
|
-
e.fillStyle = "#3b82f6", e.fillRect(nt,
|
|
2482
|
+
const B = Me, nt = F + $ - B - 1, J = k + H - B - 1;
|
|
2483
|
+
e.fillStyle = "#3b82f6", e.fillRect(nt, J, B, B), e.strokeStyle = "#ffffff", e.strokeRect(nt + 0.5, J + 0.5, B - 1, B - 1);
|
|
2467
2484
|
}
|
|
2468
|
-
const
|
|
2469
|
-
e.fillStyle = this.dataModel.hasPending(
|
|
2470
|
-
const
|
|
2471
|
-
if (
|
|
2472
|
-
e.font = i,
|
|
2485
|
+
const Jt = yt && I.type === "link" && !it && !U.textColor ? "#2563eb" : void 0, De = this.getEditMode() === "readonly", Ke = !!(gt.color || U.textColor || Jt), _e = !De && I.formula && W.readonly && !it && !Ke ? "#99aaff" : void 0;
|
|
2486
|
+
e.fillStyle = this.dataModel.hasPending(E.id, I.key) ? "#b91c1c" : gt.color ? gt.color : it ? "#94a3b8" : Jt ?? U.textColor ?? _e ?? "#0f172a";
|
|
2487
|
+
const Zt = s.wrapText?.[I.key] ?? I.wrapText ?? !1, Ht = I.type === "boolean" && (!I.format || I.format === "checkbox"), Fe = I.type === "boolean" && !!(I.format && I.format !== "checkbox");
|
|
2488
|
+
if (Ht)
|
|
2489
|
+
e.font = i, q = "";
|
|
2473
2490
|
else {
|
|
2474
|
-
const
|
|
2475
|
-
if (
|
|
2476
|
-
const nt =
|
|
2491
|
+
const B = `${U.italic ? "i" : ""}${U.bold ? "b" : ""}`;
|
|
2492
|
+
if (B !== q) {
|
|
2493
|
+
const nt = h.get(B);
|
|
2477
2494
|
if (nt) e.font = nt;
|
|
2478
2495
|
else {
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2496
|
+
const J = U.bold ? "600 " : "", bt = `${U.italic ? "italic " : ""}${J}${Z}px ${Q}`.trim();
|
|
2497
|
+
h.set(B, bt), e.font = bt;
|
|
2481
2498
|
}
|
|
2482
|
-
|
|
2499
|
+
q = B;
|
|
2483
2500
|
}
|
|
2484
2501
|
}
|
|
2485
|
-
const wt =
|
|
2486
|
-
underline: !!
|
|
2487
|
-
strike: !!
|
|
2488
|
-
},
|
|
2502
|
+
const wt = F + ut, vt = k + at, Lt = Math.max(0, $ - ut * 2), Dt = Math.max(0, H - (at + Mt)), Ve = {
|
|
2503
|
+
underline: !!U.underline || yt && I.type === "link",
|
|
2504
|
+
strike: !!U.strike
|
|
2505
|
+
}, et = yt && !Ht ? this.measureTextBounds(
|
|
2489
2506
|
e,
|
|
2490
|
-
|
|
2507
|
+
At,
|
|
2491
2508
|
wt,
|
|
2492
2509
|
vt,
|
|
2493
|
-
Ht,
|
|
2494
2510
|
Lt,
|
|
2495
|
-
|
|
2496
|
-
|
|
2511
|
+
Dt,
|
|
2512
|
+
Zt,
|
|
2513
|
+
Qt
|
|
2497
2514
|
) : null;
|
|
2498
|
-
if (yt && I.type === "button" &&
|
|
2499
|
-
const
|
|
2515
|
+
if (yt && I.type === "button" && et) {
|
|
2516
|
+
const J = Math.max(wt, et.x - 6), Ct = Math.max(vt, et.y - 4), bt = Math.min(wt + Lt, et.x + et.width + 6), Ne = Math.min(vt + Dt, et.y + et.height + 4), ee = Math.max(0, bt - J), ie = Math.max(0, Ne - Ct);
|
|
2500
2517
|
e.save();
|
|
2501
|
-
const
|
|
2502
|
-
|
|
2518
|
+
const oe = `${E.id}::${I.key}::button`, Pe = this.hoverActionKey === oe, Be = this.activeActionKey === oe;
|
|
2519
|
+
it ? (e.fillStyle = "#f3f4f6", e.strokeStyle = "#e2e8f0") : Be ? (e.fillStyle = "#cbd5e1", e.strokeStyle = "#94a3b8") : Pe ? (e.fillStyle = "#e2e8f0", e.strokeStyle = "#94a3b8") : (e.fillStyle = "#f8fafc", e.strokeStyle = "#cbd5e1"), e.lineWidth = 1, e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(J, Ct, ee, ie, 6) : e.rect(J, Ct, ee, ie), e.fill(), e.stroke(), e.restore();
|
|
2503
2520
|
}
|
|
2504
2521
|
this.drawCellText(
|
|
2505
2522
|
e,
|
|
2506
|
-
|
|
2523
|
+
At,
|
|
2507
2524
|
wt,
|
|
2508
2525
|
vt,
|
|
2509
|
-
Ht,
|
|
2510
2526
|
Lt,
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2527
|
+
Dt,
|
|
2528
|
+
Zt,
|
|
2529
|
+
Qt,
|
|
2530
|
+
Ht,
|
|
2514
2531
|
Fe,
|
|
2515
|
-
|
|
2532
|
+
!!I.unique,
|
|
2533
|
+
Ve
|
|
2516
2534
|
);
|
|
2517
|
-
const
|
|
2518
|
-
|
|
2535
|
+
const te = this.dataModel.getCellMarker(E.id, I.key);
|
|
2536
|
+
te && Vo(e, F, k, $, H, te.level), F += $;
|
|
2519
2537
|
}
|
|
2520
|
-
e.restore(),
|
|
2538
|
+
e.restore(), k += H;
|
|
2521
2539
|
}
|
|
2522
|
-
e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.canvas.width, this.headerHeight), e.strokeStyle = "#d0d7de", e.strokeRect(0, 0, this.rowHeaderWidth, this.headerHeight), e.fillStyle = "#9ca3af", e.beginPath(), e.moveTo(4, 4), e.lineTo(16, 4), e.lineTo(4, 16), e.closePath(), e.fill(), this.activeRowId && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, 0, this.rowHeaderWidth, this.headerHeight)), e.save(), e.beginPath(), e.rect(this.rowHeaderWidth, 0, this.canvas.width - this.rowHeaderWidth, this.headerHeight), e.clip(), e.translate(
|
|
2540
|
+
e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.canvas.width, this.headerHeight), e.strokeStyle = "#d0d7de", e.strokeRect(0, 0, this.rowHeaderWidth, this.headerHeight), e.fillStyle = "#9ca3af", e.beginPath(), e.moveTo(4, 4), e.lineTo(16, 4), e.lineTo(4, 16), e.closePath(), e.fill(), this.activeRowId && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, 0, this.rowHeaderWidth, this.headerHeight)), e.save(), e.beginPath(), e.rect(this.rowHeaderWidth, 0, this.canvas.width - this.rowHeaderWidth, this.headerHeight), e.clip(), e.translate(V, 0);
|
|
2523
2541
|
let N = 0;
|
|
2524
|
-
for (let
|
|
2525
|
-
const
|
|
2526
|
-
if (!
|
|
2527
|
-
N +=
|
|
2542
|
+
for (let T = 0; T < n.columns.length; T += 1) {
|
|
2543
|
+
const E = n.columns[T], H = a[T] ?? 100;
|
|
2544
|
+
if (!E) {
|
|
2545
|
+
N += H;
|
|
2528
2546
|
continue;
|
|
2529
2547
|
}
|
|
2530
|
-
this.activeColKey !== null && this.activeColKey ===
|
|
2531
|
-
const
|
|
2532
|
-
if (!!
|
|
2533
|
-
const
|
|
2534
|
-
|
|
2548
|
+
this.activeColKey !== null && this.activeColKey === E.key && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(N, 0, H, this.headerHeight)), e.strokeStyle = "#d0d7de", e.strokeRect(N, 0, H, this.headerHeight), e.fillStyle = "#0f172a", e.font = `bold ${Z}px ${Q}`, e.fillText(E.header ?? E.key, N + 8, this.headerHeight - 8), e.font = i;
|
|
2549
|
+
const F = Te(s, E.key), q = Ee(s, E.key), j = this.hoverHeaderColKey !== null && this.hoverHeaderColKey === E.key;
|
|
2550
|
+
if (!!F || q || j) {
|
|
2551
|
+
const $ = j ? 0.9 : q || F ? 0.75 : 0.45, W = 16, ot = N + H - W - 6, dt = Math.floor((this.headerHeight - W) / 2);
|
|
2552
|
+
F ? Po(e, ot + 3, dt + 3, W - 6, $, F) : No(e, ot + 2, dt + 2, W - 4, $);
|
|
2535
2553
|
}
|
|
2536
|
-
N +=
|
|
2554
|
+
N += H;
|
|
2537
2555
|
}
|
|
2538
2556
|
if (e.restore(), this.selection.length) {
|
|
2539
2557
|
e.save(), e.beginPath(), e.rect(
|
|
@@ -2542,18 +2560,18 @@ const q = class q {
|
|
|
2542
2560
|
this.canvas.width - this.rowHeaderWidth,
|
|
2543
2561
|
this.canvas.height - this.headerHeight
|
|
2544
2562
|
), e.clip(), e.strokeStyle = "#3b82f6", e.fillStyle = "rgba(59,130,246,0.12)";
|
|
2545
|
-
for (const
|
|
2546
|
-
const
|
|
2563
|
+
for (const T of this.selection) {
|
|
2564
|
+
const E = Math.max(0, Math.min(T.startRow, T.endRow)), H = Math.min(l.length - 1, Math.max(T.startRow, T.endRow)), P = Math.max(0, Math.min(T.startCol, T.endCol)), F = Math.min(
|
|
2547
2565
|
n.columns.length - 1,
|
|
2548
|
-
Math.max(
|
|
2549
|
-
),
|
|
2566
|
+
Math.max(T.startCol, T.endCol)
|
|
2567
|
+
), q = this.headerHeight + p.fenwick.sum(E) - K, j = p.fenwick.sum(H + 1) - p.fenwick.sum(E);
|
|
2550
2568
|
let I = this.rowHeaderWidth;
|
|
2551
|
-
for (let
|
|
2552
|
-
I += a[
|
|
2553
|
-
let
|
|
2554
|
-
for (let
|
|
2555
|
-
|
|
2556
|
-
I -=
|
|
2569
|
+
for (let W = 0; W < P; W += 1)
|
|
2570
|
+
I += a[W] ?? 100;
|
|
2571
|
+
let $ = 0;
|
|
2572
|
+
for (let W = P; W <= F; W += 1)
|
|
2573
|
+
$ += a[W] ?? 100;
|
|
2574
|
+
I -= v, e.fillRect(I, q, $, j), e.strokeRect(I + 0.5, q + 0.5, $ - 1, j - 1);
|
|
2557
2575
|
}
|
|
2558
2576
|
e.restore();
|
|
2559
2577
|
}
|
|
@@ -2563,7 +2581,7 @@ const q = class q {
|
|
|
2563
2581
|
}
|
|
2564
2582
|
}
|
|
2565
2583
|
destroy() {
|
|
2566
|
-
this.cancelRowHeightMeasurement(), this.heightIndex = null, this.canvas && (this.canvas.removeEventListener("pointermove", this.handlePointerMove), this.canvas.removeEventListener("pointerdown", this.handlePointerDown), this.canvas.removeEventListener("pointerup", this.handlePointerUp), this.canvas.removeEventListener("pointerleave", this.handlePointerLeave), this.canvas.removeEventListener("click", this.handleClick)), this.cursorTimer && (window.clearTimeout(this.cursorTimer), this.cursorTimer = null), this.pendingCursorPoint = null,
|
|
2584
|
+
this.cancelRowHeightMeasurement(), this.heightIndex = null, this.canvas && (this.canvas.removeEventListener("pointermove", this.handlePointerMove), this.canvas.removeEventListener("pointerdown", this.handlePointerDown), this.canvas.removeEventListener("pointerup", this.handlePointerUp), this.canvas.removeEventListener("pointerleave", this.handlePointerLeave), this.canvas.removeEventListener("click", this.handleClick)), this.cursorTimer && (window.clearTimeout(this.cursorTimer), this.cursorTimer = null), this.pendingCursorPoint = null, O(this.canvas), O(this.spacer), O(this.overlayLayer), O(this.tooltip), this.canvas = null, this.spacer = null, this.overlayLayer = null, this.tooltip = null, this.tooltipTarget = null, this.tooltipMessage = null, this.root = null;
|
|
2567
2585
|
}
|
|
2568
2586
|
ensureHeightIndex(t, e, i) {
|
|
2569
2587
|
const o = this.heightIndex;
|
|
@@ -2575,8 +2593,8 @@ const q = class q {
|
|
|
2575
2593
|
s.set(a.id, l);
|
|
2576
2594
|
let r = this.rowHeight;
|
|
2577
2595
|
if (i && e) {
|
|
2578
|
-
const
|
|
2579
|
-
|
|
2596
|
+
const h = this.dataModel.getRowVersion(a.id), d = this.rowHeightMeasuredVersion.get(a.id), u = this.dataModel.getRowHeight(a.id);
|
|
2597
|
+
d === h && typeof u == "number" && (r = u);
|
|
2580
2598
|
}
|
|
2581
2599
|
n[l] = r;
|
|
2582
2600
|
}
|
|
@@ -2585,7 +2603,7 @@ const q = class q {
|
|
|
2585
2603
|
rowsRef: t,
|
|
2586
2604
|
idToIndex: s,
|
|
2587
2605
|
heights: n,
|
|
2588
|
-
fenwick:
|
|
2606
|
+
fenwick: qt.from(n)
|
|
2589
2607
|
};
|
|
2590
2608
|
}
|
|
2591
2609
|
applyRowHeightUpdates(t) {
|
|
@@ -2614,23 +2632,23 @@ const q = class q {
|
|
|
2614
2632
|
if (!this.canvas) return;
|
|
2615
2633
|
const t = this.canvas.getContext("2d");
|
|
2616
2634
|
if (!t) return;
|
|
2617
|
-
t.font = `${
|
|
2618
|
-
const e = this.dataModel.getSchema(), i = this.dataModel.getView(), o =
|
|
2635
|
+
t.font = `${Z}px ${Q}`;
|
|
2636
|
+
const e = this.dataModel.getSchema(), i = this.dataModel.getView(), o = Y(e, i);
|
|
2619
2637
|
if (!e.columns.some((u) => i.wrapText?.[u.key] ?? u.wrapText)) return;
|
|
2620
2638
|
const s = this.getRowHeightCacheKey(e, i, o);
|
|
2621
2639
|
this.rowHeightCacheKey !== s && (this.rowHeightCacheKey = s, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null);
|
|
2622
2640
|
const l = this.rowHeightMeasureTask ?? { key: s, nextIndex: 0 };
|
|
2623
2641
|
if (l.key !== s) return;
|
|
2624
2642
|
const a = this.dataModel.listRows(), r = {};
|
|
2625
|
-
let
|
|
2626
|
-
const
|
|
2627
|
-
for (; l.nextIndex < a.length &&
|
|
2643
|
+
let h = 0;
|
|
2644
|
+
const d = performance.now();
|
|
2645
|
+
for (; l.nextIndex < a.length && h < z.ROW_HEIGHT_MEASURE_CHUNK && !(performance.now() - d > z.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS); ) {
|
|
2628
2646
|
const u = a[l.nextIndex];
|
|
2629
2647
|
if (l.nextIndex += 1, !u) continue;
|
|
2630
2648
|
const p = this.dataModel.getRowVersion(u.id);
|
|
2631
2649
|
if (this.rowHeightMeasuredVersion.get(u.id) === p) continue;
|
|
2632
|
-
const
|
|
2633
|
-
r[u.id] =
|
|
2650
|
+
const m = this.measureRowHeight(t, u, e, o);
|
|
2651
|
+
r[u.id] = m, this.rowHeightMeasuredVersion.set(u.id, p), h += 1;
|
|
2634
2652
|
}
|
|
2635
2653
|
this.rowHeightMeasureTask = l.nextIndex < a.length ? l : null, this.ensureHeightIndex(a, this.rowHeightCacheKey, !0), this.applyRowHeightUpdates(r), this.dataModel.setRowHeightsBulk(r), this.rowHeightMeasureTask && this.scheduleRowHeightMeasurement();
|
|
2636
2654
|
}
|
|
@@ -2639,11 +2657,11 @@ const q = class q {
|
|
|
2639
2657
|
}
|
|
2640
2658
|
hitTest(t) {
|
|
2641
2659
|
if (!this.root || !this.canvas) return null;
|
|
2642
|
-
const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, o = t.clientY - e.top, n = i + this.root.scrollLeft, s = this.dataModel.getSchema(), l = this.dataModel.getView(), a = this.dataModel.listRows(), r = this.headerHeight,
|
|
2643
|
-
this.ensureHeightIndex(a, u,
|
|
2660
|
+
const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, o = t.clientY - e.top, n = i + this.root.scrollLeft, s = this.dataModel.getSchema(), l = this.dataModel.getView(), a = this.dataModel.listRows(), r = this.headerHeight, h = Y(s, l), d = s.columns.some((R) => l.wrapText?.[R.key] ?? R.wrapText), u = d ? this.getRowHeightCacheKey(s, l, h) : null;
|
|
2661
|
+
this.ensureHeightIndex(a, u, d);
|
|
2644
2662
|
const p = this.heightIndex;
|
|
2645
2663
|
if (!p) return null;
|
|
2646
|
-
const
|
|
2664
|
+
const m = p.fenwick.total(), b = this.canvas?.height ?? this.root.clientHeight, x = Math.max(0, b - this.headerHeight), w = Math.max(0, m - x), f = Math.max(0, Math.min(this.root.scrollTop, w));
|
|
2647
2665
|
if (o < r && i < this.rowHeaderWidth)
|
|
2648
2666
|
return {
|
|
2649
2667
|
rowId: "__all__",
|
|
@@ -2651,65 +2669,65 @@ const q = class q {
|
|
|
2651
2669
|
rect: new DOMRect(e.left, e.top, this.rowHeaderWidth, r)
|
|
2652
2670
|
};
|
|
2653
2671
|
if (o < r) {
|
|
2654
|
-
let
|
|
2655
|
-
for (let
|
|
2656
|
-
const
|
|
2657
|
-
if (n >=
|
|
2658
|
-
|
|
2672
|
+
let R = this.rowHeaderWidth, A = -1;
|
|
2673
|
+
for (let D = 0; D < h.length; D += 1) {
|
|
2674
|
+
const V = h[D] ?? 100;
|
|
2675
|
+
if (n >= R && n <= R + V) {
|
|
2676
|
+
A = D;
|
|
2659
2677
|
break;
|
|
2660
2678
|
}
|
|
2661
|
-
|
|
2679
|
+
R += V;
|
|
2662
2680
|
}
|
|
2663
|
-
if (
|
|
2664
|
-
const
|
|
2665
|
-
e.left +
|
|
2681
|
+
if (A >= 0) {
|
|
2682
|
+
const D = s.columns[A], V = new DOMRect(
|
|
2683
|
+
e.left + R - this.root.scrollLeft,
|
|
2666
2684
|
e.top,
|
|
2667
|
-
|
|
2685
|
+
h[A] ?? 100,
|
|
2668
2686
|
r
|
|
2669
2687
|
);
|
|
2670
|
-
return { rowId: "__header__", colKey:
|
|
2688
|
+
return { rowId: "__header__", colKey: D.key, rect: V };
|
|
2671
2689
|
}
|
|
2672
2690
|
return null;
|
|
2673
2691
|
}
|
|
2674
2692
|
if (i < this.rowHeaderWidth) {
|
|
2675
|
-
const
|
|
2693
|
+
const R = o - r + f, A = Math.max(
|
|
2676
2694
|
0,
|
|
2677
|
-
Math.min(a.length - 1, p.fenwick.lowerBound(
|
|
2678
|
-
),
|
|
2679
|
-
if (
|
|
2680
|
-
const
|
|
2695
|
+
Math.min(a.length - 1, p.fenwick.lowerBound(R + 1))
|
|
2696
|
+
), D = p.fenwick.sum(A);
|
|
2697
|
+
if (A < 0 || A >= a.length) return null;
|
|
2698
|
+
const V = a[A], k = e.top + r + D - f, N = new DOMRect(
|
|
2681
2699
|
e.left,
|
|
2682
|
-
|
|
2700
|
+
k,
|
|
2683
2701
|
this.rowHeaderWidth,
|
|
2684
|
-
p.heights[
|
|
2702
|
+
p.heights[A] ?? this.rowHeight
|
|
2685
2703
|
);
|
|
2686
|
-
return { rowId:
|
|
2687
|
-
}
|
|
2688
|
-
const
|
|
2689
|
-
if (
|
|
2690
|
-
let
|
|
2691
|
-
for (let
|
|
2692
|
-
const
|
|
2693
|
-
if (n >=
|
|
2694
|
-
|
|
2704
|
+
return { rowId: V.id, colKey: null, rect: N };
|
|
2705
|
+
}
|
|
2706
|
+
const y = o - r + f, g = Math.max(0, Math.min(a.length - 1, p.fenwick.lowerBound(y + 1))), v = p.fenwick.sum(g);
|
|
2707
|
+
if (g < 0 || g >= a.length) return null;
|
|
2708
|
+
let C = this.rowHeaderWidth, S = -1;
|
|
2709
|
+
for (let R = 0; R < h.length; R += 1) {
|
|
2710
|
+
const A = h[R] ?? 100;
|
|
2711
|
+
if (n >= C && n <= C + A) {
|
|
2712
|
+
S = R;
|
|
2695
2713
|
break;
|
|
2696
2714
|
}
|
|
2697
|
-
|
|
2698
|
-
}
|
|
2699
|
-
if (
|
|
2700
|
-
const
|
|
2701
|
-
e.left +
|
|
2702
|
-
e.top + r +
|
|
2703
|
-
|
|
2704
|
-
p.heights[
|
|
2715
|
+
C += A;
|
|
2716
|
+
}
|
|
2717
|
+
if (S === -1) return null;
|
|
2718
|
+
const M = a[g], L = s.columns[S], _ = v, K = new DOMRect(
|
|
2719
|
+
e.left + C - this.root.scrollLeft,
|
|
2720
|
+
e.top + r + _ - this.root.scrollTop,
|
|
2721
|
+
h[S] ?? 100,
|
|
2722
|
+
p.heights[g] ?? this.rowHeight
|
|
2705
2723
|
);
|
|
2706
|
-
return { rowId:
|
|
2724
|
+
return { rowId: M.id, colKey: L.key, rect: K };
|
|
2707
2725
|
}
|
|
2708
2726
|
hitTestAction(t) {
|
|
2709
2727
|
if (!this.root || !this.canvas) return null;
|
|
2710
2728
|
const e = this.hitTest(t);
|
|
2711
2729
|
if (!e || !e.rowId || !e.colKey || e.rowId === "__all__" || e.rowId === "__header__") return null;
|
|
2712
|
-
const o = this.dataModel.getSchema().columns.find((
|
|
2730
|
+
const o = this.dataModel.getSchema().columns.find((A) => String(A.key) === String(e.colKey));
|
|
2713
2731
|
if (!o || o.type !== "button" && o.type !== "link") return null;
|
|
2714
2732
|
const n = this.dataModel.resolveCellValue(e.rowId, o), s = this.dataModel.resolveConditionalStyle(e.rowId, o);
|
|
2715
2733
|
if (n.textOverride ?? (s.forceErrorText ? "#ERROR" : void 0)) return null;
|
|
@@ -2717,24 +2735,24 @@ const q = class q {
|
|
|
2717
2735
|
if (!a || !a.label) return null;
|
|
2718
2736
|
const r = this.canvas.getContext("2d");
|
|
2719
2737
|
if (!r) return null;
|
|
2720
|
-
const
|
|
2721
|
-
r.save(), r.font = `${
|
|
2722
|
-
const
|
|
2738
|
+
const h = Ft(o), d = s.delta ? rt(h, s.delta) : h, u = this.dataModel.getCellStyle(e.rowId, o.key), p = u ? rt(d, u) : d, m = p.bold ? "600 " : "", b = p.italic ? "italic " : "";
|
|
2739
|
+
r.save(), r.font = `${b}${m}${Z}px ${Q}`.trim(), r.textBaseline = "alphabetic";
|
|
2740
|
+
const w = this.dataModel.getView().wrapText?.[o.key] ?? o.wrapText ?? !1, f = o.style?.align ?? "left", y = e.rect.left + ut, g = e.rect.top + at, v = Math.max(0, e.rect.width - ut * 2), C = Math.max(
|
|
2723
2741
|
0,
|
|
2724
|
-
e.rect.height - (
|
|
2725
|
-
),
|
|
2742
|
+
e.rect.height - (at + Mt)
|
|
2743
|
+
), S = this.measureTextBounds(
|
|
2726
2744
|
r,
|
|
2727
2745
|
a.label,
|
|
2728
|
-
|
|
2746
|
+
y,
|
|
2747
|
+
g,
|
|
2748
|
+
v,
|
|
2749
|
+
C,
|
|
2729
2750
|
w,
|
|
2730
|
-
|
|
2731
|
-
S,
|
|
2732
|
-
f,
|
|
2733
|
-
y
|
|
2751
|
+
f
|
|
2734
2752
|
);
|
|
2735
|
-
if (r.restore(), !
|
|
2736
|
-
const
|
|
2737
|
-
return t.clientX >=
|
|
2753
|
+
if (r.restore(), !S) return null;
|
|
2754
|
+
const M = o.type === "button" ? 6 : 2, L = Math.max(e.rect.left, S.x - M), _ = Math.max(e.rect.top, S.y - M), K = Math.min(e.rect.right, S.x + S.width + M), R = Math.min(e.rect.bottom, S.y + S.height + M);
|
|
2755
|
+
return t.clientX >= L && t.clientX <= K && t.clientY >= _ && t.clientY <= R ? { rowId: e.rowId, colKey: String(e.colKey), kind: o.type } : null;
|
|
2738
2756
|
}
|
|
2739
2757
|
isPointInSelection(t, e) {
|
|
2740
2758
|
if (!this.selection.length) return !1;
|
|
@@ -2742,8 +2760,8 @@ const q = class q {
|
|
|
2742
2760
|
if (o < 0 || n < 0) return !1;
|
|
2743
2761
|
for (const s of this.selection) {
|
|
2744
2762
|
if (s.kind !== "cells") continue;
|
|
2745
|
-
const l = Math.min(s.startRow, s.endRow), a = Math.max(s.startRow, s.endRow), r = Math.min(s.startCol, s.endCol),
|
|
2746
|
-
if (o >= l && o <= a && n >= r && n <=
|
|
2763
|
+
const l = Math.min(s.startRow, s.endRow), a = Math.max(s.startRow, s.endRow), r = Math.min(s.startCol, s.endCol), h = Math.max(s.startCol, s.endCol);
|
|
2764
|
+
if (o >= l && o <= a && n >= r && n <= h)
|
|
2747
2765
|
return !0;
|
|
2748
2766
|
}
|
|
2749
2767
|
return !1;
|
|
@@ -2766,18 +2784,18 @@ const q = class q {
|
|
|
2766
2784
|
}
|
|
2767
2785
|
getCellRect(t, e) {
|
|
2768
2786
|
if (!this.root || !this.canvas) return null;
|
|
2769
|
-
const i = this.canvas.getBoundingClientRect(), o = this.dataModel.getSchema(), n = this.dataModel.getView(), s = this.dataModel.listRows(), l = this.dataModel.getRowIndex(t), a = o.columns.findIndex((
|
|
2787
|
+
const i = this.canvas.getBoundingClientRect(), o = this.dataModel.getSchema(), n = this.dataModel.getView(), s = this.dataModel.listRows(), l = this.dataModel.getRowIndex(t), a = o.columns.findIndex((b) => b.key === e);
|
|
2770
2788
|
if (l < 0 || a < 0) return null;
|
|
2771
|
-
const r =
|
|
2772
|
-
this.ensureHeightIndex(s,
|
|
2789
|
+
const r = Y(o, n), h = o.columns.some((b) => n.wrapText?.[b.key] ?? b.wrapText), d = h ? this.getRowHeightCacheKey(o, n, r) : null;
|
|
2790
|
+
this.ensureHeightIndex(s, d, h);
|
|
2773
2791
|
const u = this.heightIndex;
|
|
2774
2792
|
if (!u) return null;
|
|
2775
2793
|
const p = u.fenwick.sum(l);
|
|
2776
|
-
let
|
|
2777
|
-
for (let
|
|
2778
|
-
|
|
2794
|
+
let m = this.rowHeaderWidth;
|
|
2795
|
+
for (let b = 0; b < a; b += 1)
|
|
2796
|
+
m += r[b] ?? 100;
|
|
2779
2797
|
return new DOMRect(
|
|
2780
|
-
i.left +
|
|
2798
|
+
i.left + m - this.root.scrollLeft,
|
|
2781
2799
|
i.top + this.headerHeight + p - this.root.scrollTop,
|
|
2782
2800
|
r[a] ?? 100,
|
|
2783
2801
|
u.heights[l] ?? this.rowHeight
|
|
@@ -2789,33 +2807,41 @@ const q = class q {
|
|
|
2789
2807
|
this.canvas.style.cursor = "crosshair";
|
|
2790
2808
|
return;
|
|
2791
2809
|
}
|
|
2810
|
+
if (this.root.dataset.extableColumnResize === "1") {
|
|
2811
|
+
this.canvas.style.cursor = "col-resize";
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2792
2814
|
{
|
|
2793
|
-
const
|
|
2794
|
-
let
|
|
2795
|
-
if (
|
|
2796
|
-
const
|
|
2797
|
-
let
|
|
2798
|
-
for (let
|
|
2799
|
-
const
|
|
2800
|
-
if (
|
|
2801
|
-
|
|
2815
|
+
const d = this.canvas.getBoundingClientRect(), u = t - d.left, p = e - d.top, m = u + this.root.scrollLeft, b = p, x = this.hoverHeaderColKey, w = this.hoverHeaderIcon;
|
|
2816
|
+
let f = null, y = !1;
|
|
2817
|
+
if (b >= 0 && b < this.headerHeight && m >= this.rowHeaderWidth) {
|
|
2818
|
+
const v = this.dataModel.getSchema(), C = this.dataModel.getView(), S = Y(v, C);
|
|
2819
|
+
let M = this.rowHeaderWidth, L = -1;
|
|
2820
|
+
for (let K = 0; K < S.length; K += 1) {
|
|
2821
|
+
const R = S[K] ?? 100;
|
|
2822
|
+
if (m >= M && m <= M + R) {
|
|
2823
|
+
L = K;
|
|
2802
2824
|
break;
|
|
2803
2825
|
}
|
|
2804
|
-
|
|
2826
|
+
M += R;
|
|
2805
2827
|
}
|
|
2806
|
-
const
|
|
2807
|
-
if (
|
|
2808
|
-
|
|
2809
|
-
const
|
|
2810
|
-
|
|
2828
|
+
const _ = L >= 0 ? v.columns[L] : null;
|
|
2829
|
+
if (_) {
|
|
2830
|
+
f = _.key;
|
|
2831
|
+
const K = S[L] ?? 100, R = 18, D = M + K - R - 4, V = Math.floor((this.headerHeight - R) / 2);
|
|
2832
|
+
if (y = m >= D && m <= D + R && b >= V && b <= V + R, m >= M + K - Vt && m <= M + K + Vt && !y) {
|
|
2833
|
+
const N = String(x ?? "") !== String(f ?? "") || !!w != !!y;
|
|
2834
|
+
this.hoverHeaderColKey = f, this.hoverHeaderIcon = y, this.canvas.style.cursor = "col-resize", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null, N && this.render();
|
|
2835
|
+
return;
|
|
2836
|
+
}
|
|
2811
2837
|
}
|
|
2812
2838
|
}
|
|
2813
|
-
const
|
|
2814
|
-
if (this.hoverHeaderColKey =
|
|
2815
|
-
this.canvas.style.cursor =
|
|
2839
|
+
const g = String(x ?? "") !== String(f ?? "") || !!w != !!y;
|
|
2840
|
+
if (this.hoverHeaderColKey = f, this.hoverHeaderIcon = y, f !== null) {
|
|
2841
|
+
this.canvas.style.cursor = y ? "pointer" : "default", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null, g && this.render();
|
|
2816
2842
|
return;
|
|
2817
2843
|
}
|
|
2818
|
-
|
|
2844
|
+
g && this.render();
|
|
2819
2845
|
}
|
|
2820
2846
|
let i = "cell";
|
|
2821
2847
|
const o = this.hitTest(new MouseEvent("mousemove", { clientX: t, clientY: e }));
|
|
@@ -2833,8 +2859,8 @@ const q = class q {
|
|
|
2833
2859
|
}
|
|
2834
2860
|
const n = this.dataModel.getCellMarker(o.rowId, o.colKey);
|
|
2835
2861
|
if (this.tooltip && n) {
|
|
2836
|
-
const
|
|
2837
|
-
if (!
|
|
2862
|
+
const d = this.tooltipTarget && this.tooltipTarget.rowId === o.rowId && this.tooltipTarget.colKey === o.colKey, u = this.tooltipMessage === n.message;
|
|
2863
|
+
if (!d || !u || this.tooltip.dataset.visible !== "1") {
|
|
2838
2864
|
this.tooltipTarget = { rowId: o.rowId, colKey: o.colKey }, this.tooltipMessage = n.message, this.tooltip.textContent = n.message;
|
|
2839
2865
|
const p = this.getCellRect(o.rowId, o.colKey);
|
|
2840
2866
|
p ? (this.positionTooltipAtRect(p), this.tooltip.dataset.visible = "1") : this.tooltip.dataset.visible = "0";
|
|
@@ -2853,23 +2879,23 @@ const q = class q {
|
|
|
2853
2879
|
this.canvas.style.cursor = "cell";
|
|
2854
2880
|
return;
|
|
2855
2881
|
}
|
|
2856
|
-
if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" &&
|
|
2882
|
+
if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" && kt(
|
|
2857
2883
|
this.dataModel,
|
|
2858
2884
|
this.selection,
|
|
2859
2885
|
this.activeRowId,
|
|
2860
2886
|
this.activeColKey,
|
|
2861
2887
|
this.getEditMode()
|
|
2862
2888
|
)) {
|
|
2863
|
-
const
|
|
2864
|
-
if (
|
|
2865
|
-
const u = ke(
|
|
2866
|
-
if (
|
|
2889
|
+
const d = this.getCellRect(this.activeRowId, this.activeColKey);
|
|
2890
|
+
if (d) {
|
|
2891
|
+
const u = ke(d, Re);
|
|
2892
|
+
if (Ie(t, e, u)) {
|
|
2867
2893
|
this.canvas.style.cursor = "crosshair";
|
|
2868
2894
|
return;
|
|
2869
2895
|
}
|
|
2870
2896
|
}
|
|
2871
2897
|
}
|
|
2872
|
-
const r = this.dataModel.getSchema().columns.find((
|
|
2898
|
+
const r = this.dataModel.getSchema().columns.find((d) => d.key === o.colKey);
|
|
2873
2899
|
this.dataModel.getCellInteraction(o.rowId, o.colKey).readonly || r?.type === "boolean" ? i = "default" : i = "text", this.canvas.style.cursor = i;
|
|
2874
2900
|
}
|
|
2875
2901
|
measureRowHeight(t, e, i, o) {
|
|
@@ -2878,8 +2904,8 @@ const q = class q {
|
|
|
2878
2904
|
for (let l = 0; l < i.columns.length; l += 1) {
|
|
2879
2905
|
const a = i.columns[l];
|
|
2880
2906
|
if (!a || !(s.wrapText?.[a.key] ?? a.wrapText)) continue;
|
|
2881
|
-
const
|
|
2882
|
-
n = Math.max(n,
|
|
2907
|
+
const h = (o[l] ?? 100) - this.padding, d = this.dataModel.resolveCellValue(e.id, a), u = this.dataModel.resolveConditionalStyle(e.id, a), m = d.textOverride ?? (u.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : this.formatValue(d.value, a).text, x = this.wrapLines(t, m, h).length * this.lineHeight + this.padding;
|
|
2908
|
+
n = Math.max(n, x);
|
|
2883
2909
|
}
|
|
2884
2910
|
return n;
|
|
2885
2911
|
}
|
|
@@ -2892,14 +2918,14 @@ const q = class q {
|
|
|
2892
2918
|
for (const a of s) {
|
|
2893
2919
|
let r = a;
|
|
2894
2920
|
for (; t.measureText(r).width > i && r.length > 1; ) {
|
|
2895
|
-
let
|
|
2896
|
-
for (;
|
|
2897
|
-
|
|
2898
|
-
l.push(r.slice(0,
|
|
2921
|
+
let h = r.length;
|
|
2922
|
+
for (; h > 1 && t.measureText(r.slice(0, h)).width > i; )
|
|
2923
|
+
h -= 1;
|
|
2924
|
+
l.push(r.slice(0, h)), r = r.slice(h);
|
|
2899
2925
|
}
|
|
2900
2926
|
l.push(r);
|
|
2901
2927
|
}
|
|
2902
|
-
for (this.textMeasureCache.set(o, { lines: l }); this.textMeasureCache.size >
|
|
2928
|
+
for (this.textMeasureCache.set(o, { lines: l }); this.textMeasureCache.size > z.TEXT_MEASURE_CACHE_MAX; ) {
|
|
2903
2929
|
const a = this.textMeasureCache.keys().next().value;
|
|
2904
2930
|
if (!a) break;
|
|
2905
2931
|
this.textMeasureCache.delete(a);
|
|
@@ -2919,47 +2945,47 @@ const q = class q {
|
|
|
2919
2945
|
measureTextBounds(t, e, i, o, n, s, l, a) {
|
|
2920
2946
|
const r = this.getTextLinesForBounds(t, e, n, l, s);
|
|
2921
2947
|
if (!r.length) return null;
|
|
2922
|
-
let
|
|
2923
|
-
for (let
|
|
2924
|
-
const
|
|
2925
|
-
let
|
|
2926
|
-
a === "right" ?
|
|
2927
|
-
const
|
|
2928
|
-
|
|
2948
|
+
let h = Number.POSITIVE_INFINITY, d = Number.NEGATIVE_INFINITY, u = Number.POSITIVE_INFINITY, p = Number.NEGATIVE_INFINITY;
|
|
2949
|
+
for (let m = 0; m < r.length; m += 1) {
|
|
2950
|
+
const b = r[m] ?? "", x = t.measureText(b).width;
|
|
2951
|
+
let w = i;
|
|
2952
|
+
a === "right" ? w = i + n - x : a === "center" && (w = i + (n - x) / 2);
|
|
2953
|
+
const f = o + this.lineHeight * m, y = f + this.lineHeight;
|
|
2954
|
+
h = Math.min(h, w), d = Math.max(d, w + x), u = Math.min(u, f), p = Math.max(p, y);
|
|
2929
2955
|
}
|
|
2930
|
-
return !Number.isFinite(
|
|
2956
|
+
return !Number.isFinite(h) || !Number.isFinite(u) ? null : new DOMRect(h, u, d - h, p - u);
|
|
2931
2957
|
}
|
|
2932
|
-
drawCellText(t, e, i, o, n, s, l, a = "left", r = !1, d = !1,
|
|
2958
|
+
drawCellText(t, e, i, o, n, s, l, a = "left", r = !1, h = !1, d = !1, u) {
|
|
2933
2959
|
t.save(), t.beginPath(), t.rect(i - 4, o - 4, n + 8, s + 8), t.clip();
|
|
2934
|
-
const
|
|
2935
|
-
r ? t.font = "28px sans-serif" :
|
|
2936
|
-
const
|
|
2937
|
-
const
|
|
2938
|
-
let
|
|
2960
|
+
const p = t.font;
|
|
2961
|
+
r ? d ? t.font = `${Ko}px ${Q}` : t.font = "28px sans-serif" : h && (t.font = `${Z}px ${Q}`);
|
|
2962
|
+
const m = this.getTextLinesForBounds(t, e, n, l, s), b = m.length * this.lineHeight, x = o + Math.max(0, Math.floor((s - b) / 2)), w = (f, y) => {
|
|
2963
|
+
const g = x + this.lineHeight * y;
|
|
2964
|
+
let v = i, C = i;
|
|
2939
2965
|
if (a === "right")
|
|
2940
|
-
t.textAlign = "right",
|
|
2966
|
+
t.textAlign = "right", C = i + n, v = C - t.measureText(f).width, t.fillText(f, C, g);
|
|
2941
2967
|
else if (a === "center") {
|
|
2942
2968
|
t.textAlign = "center";
|
|
2943
|
-
const S = i + n / 2,
|
|
2944
|
-
|
|
2969
|
+
const S = i + n / 2, M = t.measureText(f).width;
|
|
2970
|
+
v = S - M / 2, C = S + M / 2, t.fillText(f, S, g);
|
|
2945
2971
|
} else
|
|
2946
|
-
t.textAlign = "left",
|
|
2947
|
-
if (
|
|
2948
|
-
const S = t.strokeStyle,
|
|
2949
|
-
if (t.strokeStyle = t.fillStyle, t.lineWidth = 1, t.beginPath(),
|
|
2950
|
-
const
|
|
2951
|
-
t.moveTo(
|
|
2972
|
+
t.textAlign = "left", v = i, C = i + t.measureText(f).width, t.fillText(f, i, g);
|
|
2973
|
+
if (u?.underline || u?.strike) {
|
|
2974
|
+
const S = t.strokeStyle, M = t.lineWidth;
|
|
2975
|
+
if (t.strokeStyle = t.fillStyle, t.lineWidth = 1, t.beginPath(), u.underline) {
|
|
2976
|
+
const L = g + 2;
|
|
2977
|
+
t.moveTo(v, L), t.lineTo(C, L);
|
|
2952
2978
|
}
|
|
2953
|
-
if (
|
|
2954
|
-
const
|
|
2955
|
-
t.moveTo(
|
|
2979
|
+
if (u.strike) {
|
|
2980
|
+
const L = g - Math.floor(this.lineHeight / 2) + 2;
|
|
2981
|
+
t.moveTo(v, L), t.lineTo(C, L);
|
|
2956
2982
|
}
|
|
2957
|
-
t.stroke(), t.strokeStyle = S, t.lineWidth =
|
|
2983
|
+
t.stroke(), t.strokeStyle = S, t.lineWidth = M;
|
|
2958
2984
|
}
|
|
2959
2985
|
};
|
|
2960
|
-
for (let f = 0; f <
|
|
2961
|
-
|
|
2962
|
-
t.textAlign = "left", t.font =
|
|
2986
|
+
for (let f = 0; f < m.length; f += 1)
|
|
2987
|
+
w(m[f] ?? "", f + 1);
|
|
2988
|
+
t.textAlign = "left", t.font = p, t.restore();
|
|
2963
2989
|
}
|
|
2964
2990
|
formatValue(t, e) {
|
|
2965
2991
|
if (t == null) return { text: "" };
|
|
@@ -2967,15 +2993,15 @@ const q = class q {
|
|
|
2967
2993
|
const i = t;
|
|
2968
2994
|
if (i.kind === "lookup" && typeof i.label == "string")
|
|
2969
2995
|
return { text: i.label };
|
|
2970
|
-
const o =
|
|
2996
|
+
const o = He(t);
|
|
2971
2997
|
if (o !== null) return { text: o };
|
|
2972
2998
|
}
|
|
2973
2999
|
if (e.type === "button")
|
|
2974
|
-
return { text: at(t) || String(t) };
|
|
2975
|
-
if (e.type === "link")
|
|
2976
3000
|
return { text: ct(t) || String(t) };
|
|
3001
|
+
if (e.type === "link")
|
|
3002
|
+
return { text: ht(t) || String(t) };
|
|
2977
3003
|
if (e.type === "tags") {
|
|
2978
|
-
const i =
|
|
3004
|
+
const i = Wt(t);
|
|
2979
3005
|
if (i) return { text: i.join(", ") };
|
|
2980
3006
|
}
|
|
2981
3007
|
if (e.type === "boolean")
|
|
@@ -2983,8 +3009,8 @@ const q = class q {
|
|
|
2983
3009
|
if (e.type === "number" && typeof t == "number") {
|
|
2984
3010
|
const i = t, o = e.format;
|
|
2985
3011
|
if ((o?.format ?? "decimal") === "scientific") {
|
|
2986
|
-
const r =
|
|
2987
|
-
return { text: r, color:
|
|
3012
|
+
const r = Rt(i, { format: "scientific", precision: o?.precision }), h = o?.negativeRed && i < 0 ? "#b91c1c" : void 0;
|
|
3013
|
+
return { text: r, color: h };
|
|
2988
3014
|
}
|
|
2989
3015
|
const s = {};
|
|
2990
3016
|
o?.scale !== void 0 && (s.minimumFractionDigits = o.scale, s.maximumFractionDigits = o.scale), s.useGrouping = !!o?.thousandSeparator;
|
|
@@ -2994,8 +3020,8 @@ const q = class q {
|
|
|
2994
3020
|
if ((e.type === "int" || e.type === "uint") && typeof t == "number") {
|
|
2995
3021
|
const i = t, o = e.format, n = o?.format ?? "decimal";
|
|
2996
3022
|
if (n === "binary" || n === "octal" || n === "hex") {
|
|
2997
|
-
const r =
|
|
2998
|
-
return { text: r, color:
|
|
3023
|
+
const r = Ot(i, n), h = o?.negativeRed && i < 0 ? "#b91c1c" : void 0;
|
|
3024
|
+
return { text: r, color: h };
|
|
2999
3025
|
}
|
|
3000
3026
|
const s = {
|
|
3001
3027
|
minimumFractionDigits: 0,
|
|
@@ -3007,16 +3033,16 @@ const q = class q {
|
|
|
3007
3033
|
if ((e.type === "date" || e.type === "time" || e.type === "datetime") && (t instanceof Date || typeof t == "string")) {
|
|
3008
3034
|
const i = e.format, o = e.type === "date" ? i ?? "yyyy-MM-dd" : e.type === "time" ? i ?? "HH:mm" : i ?? "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
|
3009
3035
|
let n = null;
|
|
3010
|
-
return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text:
|
|
3036
|
+
return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text: de(n, o) } : { text: String(t) };
|
|
3011
3037
|
}
|
|
3012
3038
|
return { text: String(t) };
|
|
3013
3039
|
}
|
|
3014
3040
|
};
|
|
3015
|
-
|
|
3016
|
-
let It =
|
|
3017
|
-
class
|
|
3018
|
-
constructor(t, e, i, o, n, s, l, a, r,
|
|
3019
|
-
this.dataModel = a, this.onActiveChange =
|
|
3041
|
+
z.MAX_CANVAS_DIM_PX = 8192, z.ROW_HEIGHT_MEASURE_CHUNK = 500, z.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS = 8, z.TEXT_MEASURE_CACHE_MAX = 2e3;
|
|
3042
|
+
let It = z;
|
|
3043
|
+
class Bo {
|
|
3044
|
+
constructor(t, e, i, o, n, s, l, a, r, h, d, u, p, m, b, x, w) {
|
|
3045
|
+
this.dataModel = a, this.onActiveChange = p, this.onSelectionChange = b, this.onUndo = x, this.onRedo = w, this.hitAction = null, this.handleDocumentContextMenu = null, this.selectionRanges = [], this.inputEl = null, this.floatingInputWrapper = null, this.selectionInput = null, this.copyToastEl = null, this.copyToastTimer = null, this.lookupDropdownEl = null, this.lookupDropdownTarget = null, this.lookupCandidates = [], this.lookupHighlightIndex = -1, this.lookupRequestId = 0, this.lookupAbort = null, this.lookupDebounceTimer = null, this.lookupInputCleanup = null, this.lookupRecentHistory = /* @__PURE__ */ new Map(), this.lastCommittedLookupCell = null, this.hoverTooltipEl = null, this.hoverTooltipTarget = null, this.hoverTooltipMessage = null, this.hoverTooltipRequestId = 0, this.hoverTooltipAbort = null, this.externalEditInFlight = !1, this.externalEditRequestId = 0, this.selectionMode = !0, this.lastBooleanCell = null, this.selectionAnchor = null, this.dragging = !1, this.dragStart = null, this.pointerDownClient = null, this.dragMoved = !1, this.dragSelectionChanged = !1, this.suppressNextClick = !1, this.fillDragging = !1, this.fillSource = null, this.fillEndRowIndex = null, this.columnResizing = !1, this.columnResizeState = null, this.rootCursorBackup = null, this.resizeCursorBackup = null, this.lastPointerClient = null, this.autoScrollRaf = null, this.autoScrollActive = !1, this.activeCell = null, this.activeHost = null, this.activeHostOriginalText = null, this.activeOriginalValue = null, this.composing = !1, this.lastCompositionEnd = 0, this.handleInputCompositionStart = () => {
|
|
3020
3046
|
this.composing = !0;
|
|
3021
3047
|
}, this.handleInputCompositionEnd = () => {
|
|
3022
3048
|
this.composing = !1, this.lastCompositionEnd = Date.now();
|
|
@@ -3024,31 +3050,40 @@ class Vo {
|
|
|
3024
3050
|
f?.relatedTarget instanceof HTMLElement && this.lookupDropdownEl?.contains(f.relatedTarget) || this.teardownSelectionInput();
|
|
3025
3051
|
}, this.handleRootKeydown = async (f) => {
|
|
3026
3052
|
if (f.defaultPrevented || !this.selectionMode || this.inputEl || f.isComposing || this.composing || !(typeof navigator < "u" && /mac/i.test(navigator.platform) ? f.metaKey : f.ctrlKey)) return;
|
|
3027
|
-
const
|
|
3028
|
-
|
|
3053
|
+
const v = f.key.toLowerCase();
|
|
3054
|
+
v === "c" ? (f.preventDefault(), await this.copySelection()) : v === "x" && (f.preventDefault(), await this.copySelection(), this.clearSelectionValues());
|
|
3029
3055
|
}, this.handlePointerLeave = () => {
|
|
3030
3056
|
this.hideHoverTooltip();
|
|
3031
3057
|
}, this.handlePointerDown = (f) => {
|
|
3032
3058
|
if (f.button !== 0) return;
|
|
3033
3059
|
const y = f.target;
|
|
3034
3060
|
if (y?.closest('button[data-extable-fs-open="1"]') || y?.closest(".extable-filter-sort-trigger") || y?.closest("button.extable-lookup-option") || this.inputEl && f.target && this.inputEl.contains(f.target) || this.inputEl && this.activeCell && this.activeCell.colKey !== null && !this.tryCommitActiveEditor() || this.fillDragging) return;
|
|
3035
|
-
const
|
|
3036
|
-
if (
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3061
|
+
const g = this.getColumnResizeHit(f.clientX, f.clientY, f.target);
|
|
3062
|
+
if (g) {
|
|
3063
|
+
f.preventDefault(), this.beginColumnResize(g.colKey, g.colIndex, f.clientX), this.suppressNextClick = !0;
|
|
3064
|
+
try {
|
|
3065
|
+
f.target?.setPointerCapture?.(f.pointerId);
|
|
3066
|
+
} catch {
|
|
3067
|
+
}
|
|
3068
|
+
return;
|
|
3069
|
+
}
|
|
3070
|
+
const v = this.hitTest(f);
|
|
3071
|
+
if (!v || v.rowId === "__all__" && v.colKey === "__all__" || v.colKey === "__all__") return;
|
|
3072
|
+
const C = Se(this.dataModel, this.selectionRanges);
|
|
3073
|
+
if (C && this.activeCell) {
|
|
3074
|
+
const R = this.dataModel.getSchema(), A = this.dataModel.listRows(), D = C.endRowIndex, V = C.colIndex, k = A[D], N = R.columns[V];
|
|
3075
|
+
if (k && N) {
|
|
3076
|
+
const T = this.findHtmlCellElement(k.id, N.key)?.getBoundingClientRect() ?? this.computeCanvasCellRect(k.id, N.key);
|
|
3077
|
+
if (T && kt(
|
|
3043
3078
|
this.dataModel,
|
|
3044
3079
|
this.selectionRanges,
|
|
3045
3080
|
this.activeCell.rowId,
|
|
3046
3081
|
this.activeCell.colKey,
|
|
3047
3082
|
this.editMode
|
|
3048
3083
|
)) {
|
|
3049
|
-
const
|
|
3050
|
-
if (
|
|
3051
|
-
f.preventDefault(), this.fillDragging = !0, this.fillSource =
|
|
3084
|
+
const E = ke(T, Re);
|
|
3085
|
+
if (Ie(f.clientX, f.clientY, E)) {
|
|
3086
|
+
f.preventDefault(), this.fillDragging = !0, this.fillSource = C, this.fillEndRowIndex = C.endRowIndex, this.root.dataset.extableFillDragging = "1", this.rootCursorBackup === null && (this.rootCursorBackup = this.root.style.cursor || ""), this.root.style.cursor = "crosshair", this.lastPointerClient = { x: f.clientX, y: f.clientY }, this.dragging = !1, this.dragStart = null, this.suppressNextClick = !0;
|
|
3052
3087
|
try {
|
|
3053
3088
|
f.target?.setPointerCapture?.(f.pointerId);
|
|
3054
3089
|
} catch {
|
|
@@ -3056,10 +3091,10 @@ class Vo {
|
|
|
3056
3091
|
this.selectionRanges = [
|
|
3057
3092
|
{
|
|
3058
3093
|
kind: "cells",
|
|
3059
|
-
startRow:
|
|
3060
|
-
endRow:
|
|
3061
|
-
startCol:
|
|
3062
|
-
endCol:
|
|
3094
|
+
startRow: C.startRowIndex,
|
|
3095
|
+
endRow: C.endRowIndex,
|
|
3096
|
+
startCol: C.colIndex,
|
|
3097
|
+
endCol: C.colIndex
|
|
3063
3098
|
}
|
|
3064
3099
|
], this.onSelectionChange(this.selectionRanges), this.startAutoScroll();
|
|
3065
3100
|
return;
|
|
@@ -3067,32 +3102,36 @@ class Vo {
|
|
|
3067
3102
|
}
|
|
3068
3103
|
}
|
|
3069
3104
|
}
|
|
3070
|
-
const
|
|
3071
|
-
if (
|
|
3072
|
-
if (
|
|
3073
|
-
if (!
|
|
3074
|
-
const
|
|
3105
|
+
const S = this.dataModel.getSchema(), M = this.dataModel.listRows(), L = v.rowId === "__header__" ? 0 : this.dataModel.getRowIndex(v.rowId), _ = S.columns.findIndex((R) => String(R.key) === String(v.colKey));
|
|
3106
|
+
if (_ < 0) return;
|
|
3107
|
+
if (v.rowId === "__header__") {
|
|
3108
|
+
if (!M.length) return;
|
|
3109
|
+
const R = {
|
|
3075
3110
|
kind: "cells",
|
|
3076
3111
|
startRow: 0,
|
|
3077
|
-
endRow:
|
|
3078
|
-
startCol:
|
|
3079
|
-
endCol:
|
|
3112
|
+
endRow: M.length - 1,
|
|
3113
|
+
startCol: _,
|
|
3114
|
+
endCol: _
|
|
3080
3115
|
};
|
|
3081
|
-
this.selectionRanges = [
|
|
3082
|
-
const
|
|
3083
|
-
|
|
3116
|
+
this.selectionRanges = [R], this.onSelectionChange(this.selectionRanges), this.dragging = !1, this.selectionMode = !0, this.dragStart = null, this.selectionAnchor = null, this.suppressNextClick = !1;
|
|
3117
|
+
const A = M[0], D = S.columns[_];
|
|
3118
|
+
A && D && (this.activeCell = { rowId: A.id, colKey: D.key }, this.onActiveChange(A.id, D.key)), this.focusSelectionInput("");
|
|
3084
3119
|
return;
|
|
3085
3120
|
}
|
|
3086
|
-
if (
|
|
3087
|
-
const
|
|
3088
|
-
this.dragging = !0, this.pointerDownClient = { x: f.clientX, y: f.clientY }, this.dragMoved = !1, this.dragSelectionChanged = !1, this.dragStart = { rowIndex:
|
|
3121
|
+
if (L < 0) return;
|
|
3122
|
+
const K = v.colKey === null ? "rows" : "cells";
|
|
3123
|
+
this.dragging = !0, this.pointerDownClient = { x: f.clientX, y: f.clientY }, this.dragMoved = !1, this.dragSelectionChanged = !1, this.dragStart = { rowIndex: L, colIndex: _, kind: K }, this.suppressNextClick = !1, this.selectionMode = !0, this.selectionAnchor = null, this.lastCommittedLookupCell = null, this.lastPointerClient = { x: f.clientX, y: f.clientY };
|
|
3089
3124
|
try {
|
|
3090
3125
|
f.target?.setPointerCapture?.(f.pointerId);
|
|
3091
3126
|
} catch {
|
|
3092
3127
|
}
|
|
3093
3128
|
this.startAutoScroll();
|
|
3094
3129
|
}, this.handlePointerMove = (f) => {
|
|
3095
|
-
if (this.lastPointerClient = { x: f.clientX, y: f.clientY }, this.
|
|
3130
|
+
if (this.lastPointerClient = { x: f.clientX, y: f.clientY }, this.columnResizing) {
|
|
3131
|
+
this.updateColumnResize(f.clientX);
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
if (this.fillDragging && this.fillSource) {
|
|
3096
3135
|
this.updateFillDragFromClientPoint(f.clientX, f.clientY);
|
|
3097
3136
|
return;
|
|
3098
3137
|
}
|
|
@@ -3101,20 +3140,29 @@ class Vo {
|
|
|
3101
3140
|
return;
|
|
3102
3141
|
}
|
|
3103
3142
|
if (!this.dragMoved && this.pointerDownClient) {
|
|
3104
|
-
const y = f.clientX - this.pointerDownClient.x,
|
|
3105
|
-
if (y * y +
|
|
3143
|
+
const y = f.clientX - this.pointerDownClient.x, g = f.clientY - this.pointerDownClient.y;
|
|
3144
|
+
if (y * y + g * g < 9) return;
|
|
3106
3145
|
this.dragMoved = !0;
|
|
3107
3146
|
}
|
|
3108
3147
|
this.updateDragFromClientPoint(f.clientX, f.clientY);
|
|
3109
3148
|
}, this.handlePointerUp = (f) => {
|
|
3149
|
+
if (this.columnResizing) {
|
|
3150
|
+
this.endColumnResize();
|
|
3151
|
+
try {
|
|
3152
|
+
f.target?.releasePointerCapture?.(f.pointerId);
|
|
3153
|
+
} catch {
|
|
3154
|
+
}
|
|
3155
|
+
this.suppressNextClick = !0;
|
|
3156
|
+
return;
|
|
3157
|
+
}
|
|
3110
3158
|
if (this.fillDragging && this.fillSource) {
|
|
3111
|
-
const
|
|
3159
|
+
const g = this.fillSource, v = this.fillEndRowIndex ?? g.endRowIndex;
|
|
3112
3160
|
this.fillDragging = !1, this.fillSource = null, this.fillEndRowIndex = null, this.root.dataset.extableFillDragging = "", this.rootCursorBackup !== null && (this.root.style.cursor = this.rootCursorBackup, this.rootCursorBackup = null), this.stopAutoScroll();
|
|
3113
3161
|
try {
|
|
3114
3162
|
f.target?.releasePointerCapture?.(f.pointerId);
|
|
3115
3163
|
} catch {
|
|
3116
3164
|
}
|
|
3117
|
-
this.commitFill(
|
|
3165
|
+
this.commitFill(g, v), this.suppressNextClick = !0;
|
|
3118
3166
|
return;
|
|
3119
3167
|
}
|
|
3120
3168
|
if (!this.dragging) return;
|
|
@@ -3126,8 +3174,8 @@ class Vo {
|
|
|
3126
3174
|
} catch {
|
|
3127
3175
|
}
|
|
3128
3176
|
if (y && (this.suppressNextClick = !0), this.suppressNextClick && this.activeCell && this.activeCell.colKey !== null) {
|
|
3129
|
-
const
|
|
3130
|
-
this.focusSelectionInput(this.cellToClipboardString(
|
|
3177
|
+
const g = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey);
|
|
3178
|
+
this.focusSelectionInput(this.cellToClipboardString(g));
|
|
3131
3179
|
}
|
|
3132
3180
|
}, this.handleSelectionCopy = (f) => {
|
|
3133
3181
|
if (!this.selectionMode) return;
|
|
@@ -3140,16 +3188,16 @@ class Vo {
|
|
|
3140
3188
|
}, this.handleSelectionPaste = (f) => {
|
|
3141
3189
|
if (!this.selectionMode) return;
|
|
3142
3190
|
f.preventDefault();
|
|
3143
|
-
const y = f.clipboardData?.getData("text/html") ?? "",
|
|
3144
|
-
|
|
3191
|
+
const y = f.clipboardData?.getData("text/html") ?? "", g = f.clipboardData?.getData("text/tab-separated-values") ?? "", v = f.clipboardData?.getData("text/plain") ?? "", C = this.parseClipboardGrid({ html: y, tsv: g, text: v });
|
|
3192
|
+
C && this.applyClipboardGrid(C);
|
|
3145
3193
|
}, this.handleSelectionCompositionStart = (f) => {
|
|
3146
3194
|
if (!this.selectionMode) return;
|
|
3147
3195
|
const y = this.activeCell;
|
|
3148
3196
|
if (!(!y || y.colKey === null)) {
|
|
3149
3197
|
if (this.isCellReadonly(y.rowId, y.colKey)) {
|
|
3150
3198
|
f?.preventDefault?.(), f?.stopPropagation?.();
|
|
3151
|
-
const
|
|
3152
|
-
this.teardownSelectionInput(), this.focusSelectionInput(
|
|
3199
|
+
const g = this.dataModel.getCell(y.rowId, y.colKey), v = this.cellToClipboardString(g);
|
|
3200
|
+
this.teardownSelectionInput(), this.focusSelectionInput(v);
|
|
3153
3201
|
return;
|
|
3154
3202
|
}
|
|
3155
3203
|
this.selectionMode = !1, this.openEditorAtActiveCell();
|
|
@@ -3160,8 +3208,8 @@ class Vo {
|
|
|
3160
3208
|
if (!(!y || y.colKey === null) && this.isCellReadonly(y.rowId, y.colKey)) {
|
|
3161
3209
|
f.preventDefault();
|
|
3162
3210
|
try {
|
|
3163
|
-
const
|
|
3164
|
-
|
|
3211
|
+
const g = this.dataModel.getCell(y.rowId, y.colKey), v = this.cellToClipboardString(g), C = this.ensureSelectionInput();
|
|
3212
|
+
C.value = v, C.select();
|
|
3165
3213
|
} catch {
|
|
3166
3214
|
}
|
|
3167
3215
|
}
|
|
@@ -3175,53 +3223,53 @@ class Vo {
|
|
|
3175
3223
|
return;
|
|
3176
3224
|
const y = typeof navigator < "u" && /mac/i.test(navigator.platform);
|
|
3177
3225
|
if (y ? f.metaKey : f.ctrlKey) {
|
|
3178
|
-
const
|
|
3179
|
-
if (
|
|
3226
|
+
const M = f.key.toLowerCase();
|
|
3227
|
+
if (M === "z") {
|
|
3180
3228
|
f.preventDefault(), y && f.shiftKey ? this.onRedo() : this.onUndo(), this.selectionAnchor = null;
|
|
3181
3229
|
return;
|
|
3182
3230
|
}
|
|
3183
|
-
if (
|
|
3231
|
+
if (M === "y") {
|
|
3184
3232
|
f.preventDefault(), this.onRedo(), this.selectionAnchor = null;
|
|
3185
3233
|
return;
|
|
3186
3234
|
}
|
|
3187
|
-
if (
|
|
3235
|
+
if (M === "c") {
|
|
3188
3236
|
f.preventDefault(), await this.copySelection(), this.selectionAnchor = null;
|
|
3189
3237
|
return;
|
|
3190
3238
|
}
|
|
3191
|
-
if (
|
|
3239
|
+
if (M === "x") {
|
|
3192
3240
|
f.preventDefault(), await this.copySelection(), this.clearSelectionValues(), this.selectionAnchor = null;
|
|
3193
3241
|
return;
|
|
3194
3242
|
}
|
|
3195
|
-
if (
|
|
3243
|
+
if (M === "v") {
|
|
3196
3244
|
this.selectionAnchor = null;
|
|
3197
3245
|
return;
|
|
3198
3246
|
}
|
|
3199
3247
|
}
|
|
3200
3248
|
if (f.key === " " && this.activeCell.colKey !== null) {
|
|
3201
|
-
const
|
|
3202
|
-
if (
|
|
3203
|
-
f.preventDefault(), this.triggerCellAction(this.activeCell.rowId, this.activeCell.colKey,
|
|
3249
|
+
const M = this.findColumn(this.activeCell.colKey);
|
|
3250
|
+
if (M?.type === "button" || M?.type === "link") {
|
|
3251
|
+
f.preventDefault(), this.triggerCellAction(this.activeCell.rowId, this.activeCell.colKey, M.type), this.selectionAnchor = null;
|
|
3204
3252
|
return;
|
|
3205
3253
|
}
|
|
3206
|
-
if (
|
|
3254
|
+
if (M?.type === "boolean") {
|
|
3207
3255
|
f.preventDefault(), this.toggleBoolean(this.activeCell.rowId, this.activeCell.colKey), this.selectionAnchor = null;
|
|
3208
3256
|
return;
|
|
3209
3257
|
}
|
|
3210
3258
|
this.selectionAnchor = null;
|
|
3211
3259
|
return;
|
|
3212
3260
|
}
|
|
3213
|
-
const
|
|
3214
|
-
if (
|
|
3215
|
-
if (f.preventDefault(), this.teardownSelectionInput(),
|
|
3261
|
+
const v = f.key === "Tab", C = f.key === "Enter", S = f.key === "ArrowLeft" || f.key === "ArrowRight" || f.key === "ArrowUp" || f.key === "ArrowDown";
|
|
3262
|
+
if (v || C || S) {
|
|
3263
|
+
if (f.preventDefault(), this.teardownSelectionInput(), v) {
|
|
3216
3264
|
this.moveActiveCell(0, f.shiftKey ? -1 : 1, !1);
|
|
3217
3265
|
return;
|
|
3218
3266
|
}
|
|
3219
|
-
if (
|
|
3267
|
+
if (C) {
|
|
3220
3268
|
this.moveActiveCell(f.shiftKey ? -1 : 1, 0, !1);
|
|
3221
3269
|
return;
|
|
3222
3270
|
}
|
|
3223
|
-
const
|
|
3224
|
-
f.key === "ArrowLeft" ? this.moveActiveCell(0, -1,
|
|
3271
|
+
const M = f.shiftKey;
|
|
3272
|
+
f.key === "ArrowLeft" ? this.moveActiveCell(0, -1, M) : f.key === "ArrowRight" ? this.moveActiveCell(0, 1, M) : f.key === "ArrowUp" ? this.moveActiveCell(-1, 0, M) : f.key === "ArrowDown" && this.moveActiveCell(1, 0, M);
|
|
3225
3273
|
return;
|
|
3226
3274
|
}
|
|
3227
3275
|
if (this.activeCell.colKey !== null && this.isCellReadonly(this.activeCell.rowId, this.activeCell.colKey)) {
|
|
@@ -3239,73 +3287,81 @@ class Vo {
|
|
|
3239
3287
|
}
|
|
3240
3288
|
if (this.inputEl && f.target && this.inputEl.contains(f.target) || this.inputEl && this.activeCell && this.activeCell.colKey !== null && !this.tryCommitActiveEditor())
|
|
3241
3289
|
return;
|
|
3242
|
-
const
|
|
3243
|
-
if (
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
if (
|
|
3247
|
-
|
|
3290
|
+
const g = this.getHitAtClientPoint(f.clientX, f.clientY, f.target);
|
|
3291
|
+
if (f.target?.closest("input.extable-unique-radio") && g) {
|
|
3292
|
+
if (g.colKey === null) return;
|
|
3293
|
+
const R = this.findColumn(g.colKey);
|
|
3294
|
+
if (R && R.type === "boolean" && R.unique) {
|
|
3295
|
+
this.toggleBoolean(g.rowId, g.colKey), f.preventDefault();
|
|
3296
|
+
return;
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
if (!g) return;
|
|
3300
|
+
const C = this.hitAction ? this.hitAction(f) : null;
|
|
3301
|
+
if (C) {
|
|
3302
|
+
if (C.kind === "tag-remove") {
|
|
3303
|
+
if (this.removeTagValue(C.rowId, C.colKey, C.tagIndex)) {
|
|
3248
3304
|
f.preventDefault();
|
|
3249
3305
|
return;
|
|
3250
3306
|
}
|
|
3251
|
-
} else if (this.triggerCellAction(
|
|
3307
|
+
} else if (this.triggerCellAction(C.rowId, C.colKey, C.kind)) {
|
|
3252
3308
|
f.preventDefault();
|
|
3253
3309
|
return;
|
|
3254
3310
|
}
|
|
3255
3311
|
}
|
|
3256
|
-
const
|
|
3257
|
-
if (
|
|
3258
|
-
const
|
|
3259
|
-
this.teardownInput(!1),
|
|
3312
|
+
const S = this.selectionMode && !f.shiftKey && !f.metaKey && !f.ctrlKey && this.activeCell?.rowId === g.rowId && String(this.activeCell?.colKey) === String(g.colKey);
|
|
3313
|
+
if (g.rowId === "__all__" && g.colKey === "__all__") {
|
|
3314
|
+
const R = this.dataModel.getSchema(), A = this.dataModel.listRows();
|
|
3315
|
+
this.teardownInput(!1), A.length && R.columns.length ? (this.selectionRanges = [
|
|
3260
3316
|
{
|
|
3261
3317
|
kind: "cells",
|
|
3262
3318
|
startRow: 0,
|
|
3263
|
-
endRow:
|
|
3319
|
+
endRow: A.length - 1,
|
|
3264
3320
|
startCol: 0,
|
|
3265
|
-
endCol:
|
|
3321
|
+
endCol: R.columns.length - 1
|
|
3266
3322
|
}
|
|
3267
3323
|
], this.activeCell = { rowId: "__all__", colKey: "__all__" }, this.onActiveChange("__all__", "__all__"), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("")) : (this.activeCell = null, this.onActiveChange("__all__", "__all__"), this.selectionAnchor = null);
|
|
3268
3324
|
return;
|
|
3269
3325
|
}
|
|
3270
|
-
if (this.onRowSelect(
|
|
3271
|
-
const
|
|
3272
|
-
|
|
3326
|
+
if (this.onRowSelect(g.rowId), g.rowId === "__header__") {
|
|
3327
|
+
const R = this.dataModel.getSchema(), A = this.dataModel.listRows(), D = R.columns.findIndex((V) => String(V.key) === String(g.colKey));
|
|
3328
|
+
A.length && D >= 0 && (this.selectionRanges = [
|
|
3273
3329
|
{
|
|
3274
3330
|
kind: "cells",
|
|
3275
3331
|
startRow: 0,
|
|
3276
|
-
endRow:
|
|
3277
|
-
startCol:
|
|
3278
|
-
endCol:
|
|
3332
|
+
endRow: A.length - 1,
|
|
3333
|
+
startCol: D,
|
|
3334
|
+
endCol: D
|
|
3279
3335
|
}
|
|
3280
|
-
], this.activeCell = { rowId:
|
|
3336
|
+
], this.activeCell = { rowId: A[0].id, colKey: g.colKey }, this.onActiveChange(this.activeCell.rowId, this.activeCell.colKey), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput(""));
|
|
3281
3337
|
return;
|
|
3282
3338
|
}
|
|
3283
|
-
if (this.applySelectionFromHit(f,
|
|
3339
|
+
if (this.applySelectionFromHit(f, g), g.colKey === null || g.colKey === "__all__") {
|
|
3284
3340
|
this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("");
|
|
3285
3341
|
return;
|
|
3286
3342
|
}
|
|
3287
|
-
if (
|
|
3343
|
+
if (g.rowId === "__header__") {
|
|
3288
3344
|
this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("");
|
|
3289
3345
|
return;
|
|
3290
3346
|
}
|
|
3291
|
-
if (this.isCellReadonly(
|
|
3347
|
+
if (this.isCellReadonly(g.rowId, g.colKey)) {
|
|
3292
3348
|
this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1);
|
|
3293
|
-
const
|
|
3294
|
-
this.focusSelectionInput(this.cellToClipboardString(
|
|
3349
|
+
const R = this.dataModel.getCell(g.rowId, g.colKey);
|
|
3350
|
+
this.focusSelectionInput(this.cellToClipboardString(R));
|
|
3295
3351
|
return;
|
|
3296
3352
|
}
|
|
3297
|
-
if (this.findColumn(
|
|
3298
|
-
const
|
|
3299
|
-
if (this.lastBooleanCell = { rowId:
|
|
3300
|
-
this.toggleBoolean(
|
|
3353
|
+
if (this.findColumn(g.colKey)?.type === "boolean") {
|
|
3354
|
+
const R = this.lastBooleanCell?.rowId === g.rowId && String(this.lastBooleanCell?.colKey) === String(g.colKey);
|
|
3355
|
+
if (this.lastBooleanCell = { rowId: g.rowId, colKey: g.colKey }, this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1), this.teardownSelectionInput(), R) {
|
|
3356
|
+
this.toggleBoolean(g.rowId, g.colKey), this.focusSelectionInput("");
|
|
3301
3357
|
return;
|
|
3302
3358
|
}
|
|
3303
3359
|
this.focusSelectionInput("");
|
|
3304
3360
|
return;
|
|
3305
3361
|
}
|
|
3306
3362
|
this.lastBooleanCell = null, this.selectionAnchor = null, this.teardownInput(!1);
|
|
3307
|
-
const
|
|
3308
|
-
this.focusSelectionInput(
|
|
3363
|
+
const _ = this.dataModel.getCell(g.rowId, g.colKey), K = this.cellToClipboardString(_);
|
|
3364
|
+
this.focusSelectionInput(K), S && (this.selectionMode = !1, this.openEditorAtActiveCell());
|
|
3309
3365
|
}, this.handleContextMenu = (f) => {
|
|
3310
3366
|
const y = f.target;
|
|
3311
3367
|
if (f.ctrlKey) {
|
|
@@ -3314,9 +3370,9 @@ class Vo {
|
|
|
3314
3370
|
}
|
|
3315
3371
|
if (!y || !this.root.contains(y)) return;
|
|
3316
3372
|
f.preventDefault(), f.stopPropagation();
|
|
3317
|
-
const
|
|
3318
|
-
this.onContextMenu(
|
|
3319
|
-
}, this.root = t, this.editMode = e, this.onEdit = i, this.onRowSelect = o, this.onMove = n, this.hitTest = s, this.hitAction = l, this.sequenceLangs = r, this.isCellReadonly =
|
|
3373
|
+
const g = this.hitTest(f), v = g?.rowId ?? null, C = g?.colKey ?? null;
|
|
3374
|
+
this.onContextMenu(v, C, f.clientX, f.clientY);
|
|
3375
|
+
}, this.root = t, this.editMode = e, this.onEdit = i, this.onRowSelect = o, this.onMove = n, this.hitTest = s, this.hitAction = l, this.sequenceLangs = r, this.isCellReadonly = h, this.onCellAction = d, this.onViewChange = u, this.onContextMenu = m, this.bind();
|
|
3320
3376
|
}
|
|
3321
3377
|
setEditMode(t) {
|
|
3322
3378
|
this.editMode = t;
|
|
@@ -3327,9 +3383,9 @@ class Vo {
|
|
|
3327
3383
|
this.selectionRanges = [], this.activeCell = null, this.selectionAnchor = null, this.lastBooleanCell = null, this.teardownInput(!0), this.onActiveChange(null, null), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
|
|
3328
3384
|
return;
|
|
3329
3385
|
}
|
|
3330
|
-
const i = e.length - 1, o = t.columns.length - 1, n = this.activeCell?.rowId ?? null, s = this.activeCell?.colKey ?? null, l = n ? this.dataModel.getRowIndex(n) : -1, a = s !== null ? t.columns.findIndex((
|
|
3386
|
+
const i = e.length - 1, o = t.columns.length - 1, n = this.activeCell?.rowId ?? null, s = this.activeCell?.colKey ?? null, l = n ? this.dataModel.getRowIndex(n) : -1, a = s !== null ? t.columns.findIndex((f) => String(f.key) === String(s)) : -1;
|
|
3331
3387
|
if (l >= 0 && a >= 0) {
|
|
3332
|
-
let
|
|
3388
|
+
let f = !1;
|
|
3333
3389
|
if (!this.selectionRanges.length)
|
|
3334
3390
|
this.selectionRanges = [
|
|
3335
3391
|
{
|
|
@@ -3339,40 +3395,40 @@ class Vo {
|
|
|
3339
3395
|
startCol: a,
|
|
3340
3396
|
endCol: a
|
|
3341
3397
|
}
|
|
3342
|
-
],
|
|
3398
|
+
], f = !0;
|
|
3343
3399
|
else {
|
|
3344
|
-
const
|
|
3345
|
-
const
|
|
3346
|
-
...
|
|
3347
|
-
startRow:
|
|
3348
|
-
endRow:
|
|
3349
|
-
startCol:
|
|
3350
|
-
endCol:
|
|
3400
|
+
const y = this.selectionRanges.map((g) => {
|
|
3401
|
+
const v = (S, M) => Math.max(0, Math.min(M, S)), C = {
|
|
3402
|
+
...g,
|
|
3403
|
+
startRow: v(g.startRow, i),
|
|
3404
|
+
endRow: v(g.endRow, i),
|
|
3405
|
+
startCol: v(g.startCol, o),
|
|
3406
|
+
endCol: v(g.endCol, o)
|
|
3351
3407
|
};
|
|
3352
|
-
return (
|
|
3408
|
+
return (C.startRow !== g.startRow || C.endRow !== g.endRow || C.startCol !== g.startCol || C.endCol !== g.endCol) && (f = !0), C;
|
|
3353
3409
|
});
|
|
3354
|
-
this.selectionRanges =
|
|
3410
|
+
this.selectionRanges = y;
|
|
3355
3411
|
}
|
|
3356
|
-
|
|
3412
|
+
f && this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
|
|
3357
3413
|
return;
|
|
3358
3414
|
}
|
|
3359
3415
|
const r = s ?? t.columns[0]?.key ?? "";
|
|
3360
|
-
let
|
|
3361
|
-
|
|
3362
|
-
const
|
|
3363
|
-
if (!
|
|
3364
|
-
const
|
|
3416
|
+
let h = t.columns.findIndex((f) => String(f.key) === String(r));
|
|
3417
|
+
h < 0 && (h = 0);
|
|
3418
|
+
const d = t.columns[h]?.key ?? "", u = n ? this.dataModel.getBaseRowIndex(n) : 0, p = e[e.length - 1] ?? e[0] ?? null, m = e.find((f) => this.dataModel.getBaseRowIndex(f.id) >= u) ?? p;
|
|
3419
|
+
if (!m) return;
|
|
3420
|
+
const b = m.id, x = this.dataModel.getRowIndex(b);
|
|
3365
3421
|
this.selectionAnchor = null, this.lastBooleanCell = null, this.teardownInput(!1), this.selectionRanges = [
|
|
3366
3422
|
{
|
|
3367
3423
|
kind: "cells",
|
|
3368
|
-
startRow:
|
|
3369
|
-
endRow:
|
|
3370
|
-
startCol:
|
|
3371
|
-
endCol:
|
|
3424
|
+
startRow: x,
|
|
3425
|
+
endRow: x,
|
|
3426
|
+
startCol: h,
|
|
3427
|
+
endCol: h
|
|
3372
3428
|
}
|
|
3373
|
-
], this.activeCell = { rowId:
|
|
3374
|
-
const
|
|
3375
|
-
this.focusSelectionInput(this.cellToClipboardString(
|
|
3429
|
+
], this.activeCell = { rowId: b, colKey: d }, this.onActiveChange(b, d), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(b, d);
|
|
3430
|
+
const w = this.dataModel.getCell(b, d);
|
|
3431
|
+
this.focusSelectionInput(this.cellToClipboardString(w)), this.updateFillHandleFlag();
|
|
3376
3432
|
}
|
|
3377
3433
|
navigateToCell(t, e) {
|
|
3378
3434
|
const i = this.dataModel.getSchema(), o = this.dataModel.getRowIndex(t), n = i.columns.findIndex((a) => String(a.key) === String(e));
|
|
@@ -3393,7 +3449,7 @@ class Vo {
|
|
|
3393
3449
|
this.teardownInput(!0);
|
|
3394
3450
|
}
|
|
3395
3451
|
destroy() {
|
|
3396
|
-
this.root.removeEventListener("click", this.handleClick), this.root.removeEventListener("pointerdown", this.handlePointerDown), this.root.removeEventListener("pointermove", this.handlePointerMove), this.root.removeEventListener("pointerup", this.handlePointerUp), this.root.removeEventListener("pointercancel", this.handlePointerUp), this.root.removeEventListener("pointerleave", this.handlePointerLeave), this.root.removeEventListener("keydown", this.handleRootKeydown), this.handleDocumentContextMenu && document.removeEventListener("contextmenu", this.handleDocumentContextMenu, !0), this.teardownInput(!0), this.teardownSelectionInput(), this.teardownCopyToast(),
|
|
3452
|
+
this.root.removeEventListener("click", this.handleClick), this.root.removeEventListener("pointerdown", this.handlePointerDown), this.root.removeEventListener("pointermove", this.handlePointerMove), this.root.removeEventListener("pointerup", this.handlePointerUp), this.root.removeEventListener("pointercancel", this.handlePointerUp), this.root.removeEventListener("pointerleave", this.handlePointerLeave), this.root.removeEventListener("keydown", this.handleRootKeydown), this.handleDocumentContextMenu && document.removeEventListener("contextmenu", this.handleDocumentContextMenu, !0), this.teardownInput(!0), this.teardownSelectionInput(), this.teardownCopyToast(), O(this.lookupDropdownEl), this.lookupDropdownEl = null, this.hideHoverTooltip(), this.teardownHoverTooltip(), this.stopAutoScroll(), this.endColumnResize();
|
|
3397
3453
|
}
|
|
3398
3454
|
onScroll(t, e) {
|
|
3399
3455
|
this.positionCopyToast(), this.refreshHoverTooltipPosition(), this.refreshLookupDropdownPosition();
|
|
@@ -3403,7 +3459,7 @@ class Vo {
|
|
|
3403
3459
|
}
|
|
3404
3460
|
updateFillHandleFlag() {
|
|
3405
3461
|
const t = this.activeCell?.colKey ?? null, e = this.activeCell?.rowId ?? null;
|
|
3406
|
-
this.root.dataset.extableFillHandle =
|
|
3462
|
+
this.root.dataset.extableFillHandle = kt(
|
|
3407
3463
|
this.dataModel,
|
|
3408
3464
|
this.selectionRanges,
|
|
3409
3465
|
e,
|
|
@@ -3455,13 +3511,13 @@ class Vo {
|
|
|
3455
3511
|
return e.className = "extable-toast", e.dataset.extableCopyToast = "1", e.style.position = "absolute", e.style.left = "0", e.style.top = "0", e.style.pointerEvents = "none", e.style.zIndex = "1000", e.style.display = "none", e.style.margin = "0", this.root.appendChild(e), this.copyToastEl = e, e;
|
|
3456
3512
|
}
|
|
3457
3513
|
teardownCopyToast() {
|
|
3458
|
-
this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastEl && (this.copyToastEl.style.display = "none",
|
|
3514
|
+
this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastEl && (this.copyToastEl.style.display = "none", O(this.copyToastEl), this.copyToastEl = null);
|
|
3459
3515
|
}
|
|
3460
3516
|
positionCopyToast() {
|
|
3461
3517
|
if (!this.copyToastEl) return;
|
|
3462
3518
|
const t = this.copyToastEl.offsetWidth || 0, e = this.copyToastEl.offsetHeight || 0, i = 16, o = Math.max(0, this.root.scrollLeft + this.root.clientWidth - t - i), n = Math.max(0, this.root.scrollTop + this.root.clientHeight - e - i), s = Math.max(0, this.root.scrollLeft + i), l = Math.max(0, this.root.scrollTop + i), a = this.root.getBoundingClientRect(), r = this.getActiveCellRect();
|
|
3463
3519
|
if (r) {
|
|
3464
|
-
const
|
|
3520
|
+
const h = r.right - a.left + this.root.scrollLeft - t + 8, d = r.top - a.top + this.root.scrollTop - e + 8, u = Math.min(o, Math.max(s, h)), p = Math.min(n, Math.max(l, d));
|
|
3465
3521
|
this.copyToastEl.style.left = `${u}px`, this.copyToastEl.style.top = `${p}px`;
|
|
3466
3522
|
return;
|
|
3467
3523
|
}
|
|
@@ -3480,7 +3536,7 @@ class Vo {
|
|
|
3480
3536
|
return e.className = "extable-tooltip", e.dataset.visible = "0", e.style.position = "absolute", e.style.left = "0", e.style.top = "0", e.style.pointerEvents = "none", e.style.zIndex = "1000", this.root.appendChild(e), this.hoverTooltipEl = e, e;
|
|
3481
3537
|
}
|
|
3482
3538
|
teardownHoverTooltip() {
|
|
3483
|
-
this.hoverTooltipAbort?.abort(), this.hoverTooltipAbort = null, this.hoverTooltipRequestId += 1, this.hoverTooltipTarget = null, this.hoverTooltipMessage = null,
|
|
3539
|
+
this.hoverTooltipAbort?.abort(), this.hoverTooltipAbort = null, this.hoverTooltipRequestId += 1, this.hoverTooltipTarget = null, this.hoverTooltipMessage = null, O(this.hoverTooltipEl), this.hoverTooltipEl = null;
|
|
3484
3540
|
}
|
|
3485
3541
|
hideHoverTooltip() {
|
|
3486
3542
|
this.hoverTooltipEl && (this.hoverTooltipEl.dataset.visible = "0"), this.hoverTooltipTarget = null, this.hoverTooltipMessage = null, this.hoverTooltipAbort?.abort(), this.hoverTooltipAbort = null, this.hoverTooltipRequestId += 1;
|
|
@@ -3494,8 +3550,8 @@ class Vo {
|
|
|
3494
3550
|
if (!e) return;
|
|
3495
3551
|
const i = 8, o = this.root.getBoundingClientRect(), n = this.root.clientWidth, s = this.root.clientHeight;
|
|
3496
3552
|
let l = t.right - o.left + i, a = t.top - o.top + i, r = "right";
|
|
3497
|
-
const
|
|
3498
|
-
l +
|
|
3553
|
+
const h = e.getBoundingClientRect();
|
|
3554
|
+
l + h.width > n && (l = Math.max(0, t.left - o.left - h.width - i), r = "left"), a + h.height > s && (a = Math.max(0, s - h.height - i)), e.style.left = `${l}px`, e.style.top = `${a}px`, e.dataset.side = r;
|
|
3499
3555
|
}
|
|
3500
3556
|
refreshHoverTooltipPosition() {
|
|
3501
3557
|
const t = this.hoverTooltipEl;
|
|
@@ -3535,26 +3591,59 @@ class Vo {
|
|
|
3535
3591
|
this.hoverTooltipAbort?.abort();
|
|
3536
3592
|
const r = new AbortController();
|
|
3537
3593
|
this.hoverTooltipAbort = r;
|
|
3538
|
-
const
|
|
3594
|
+
const h = this.hoverTooltipRequestId += 1;
|
|
3539
3595
|
this.hoverTooltipTarget = { rowId: o, colKey: i }, this.hoverTooltipMessage = null;
|
|
3540
|
-
const
|
|
3541
|
-
if (
|
|
3596
|
+
const d = this.dataModel.getCell(o, i), u = (p) => {
|
|
3597
|
+
if (h !== this.hoverTooltipRequestId || r.signal.aborted) return;
|
|
3542
3598
|
if (!p) {
|
|
3543
3599
|
this.hideHoverTooltip();
|
|
3544
3600
|
return;
|
|
3545
3601
|
}
|
|
3546
|
-
const
|
|
3547
|
-
this.hoverTooltipMessage = p,
|
|
3602
|
+
const m = this.ensureHoverTooltip();
|
|
3603
|
+
this.hoverTooltipMessage = p, m.textContent = p, this.positionTooltipAtRect(e.rect), m.dataset.visible = "1";
|
|
3548
3604
|
};
|
|
3549
3605
|
try {
|
|
3550
|
-
const p = l({ rowId: o, colKey: i, value:
|
|
3551
|
-
p && typeof p.then == "function" ? p.then(u).catch((
|
|
3552
|
-
|
|
3606
|
+
const p = l({ rowId: o, colKey: i, value: d, signal: r.signal });
|
|
3607
|
+
p && typeof p.then == "function" ? p.then(u).catch((m) => {
|
|
3608
|
+
h === this.hoverTooltipRequestId && (r.signal.aborted || (this.hideHoverTooltip(), this.showCopyToast("Tooltip failed", "error", 1800)));
|
|
3553
3609
|
}) : u(p);
|
|
3554
3610
|
} catch {
|
|
3555
3611
|
this.hideHoverTooltip(), this.showCopyToast("Tooltip failed", "error", 1800);
|
|
3556
3612
|
}
|
|
3557
3613
|
}
|
|
3614
|
+
getColumnResizeHit(t, e, i) {
|
|
3615
|
+
const o = this.getHitAtClientPoint(t, e, i);
|
|
3616
|
+
if (!o || o.rowId !== "__header__" || !o.colKey || o.colKey === "__all__" || Math.abs(t - o.rect.right) > Vt) return null;
|
|
3617
|
+
if (!o.element) {
|
|
3618
|
+
const r = o.rect.right - 18 - 4, h = o.rect.top + Math.floor((st - 18) / 2);
|
|
3619
|
+
if (t >= r && t <= r + 18 && e >= h && e <= h + 18) return null;
|
|
3620
|
+
}
|
|
3621
|
+
const s = this.dataModel.getSchema().columns.findIndex((l) => String(l.key) === String(o.colKey));
|
|
3622
|
+
return s < 0 ? null : { colKey: String(o.colKey), colIndex: s };
|
|
3623
|
+
}
|
|
3624
|
+
beginColumnResize(t, e, i) {
|
|
3625
|
+
const o = this.dataModel.getSchema(), n = this.dataModel.getView(), s = o.columns[e];
|
|
3626
|
+
if (!s) return;
|
|
3627
|
+
const l = String(t), a = n.columnWidths?.[l] ?? s.width ?? 100, h = Y(o, n)[e] ?? a, d = Math.max(0, h - a), u = je(0, d);
|
|
3628
|
+
this.columnResizing = !0, this.columnResizeState = {
|
|
3629
|
+
colKey: l,
|
|
3630
|
+
startX: i,
|
|
3631
|
+
startWidth: a,
|
|
3632
|
+
minWidth: u,
|
|
3633
|
+
lastWidth: a
|
|
3634
|
+
}, this.resizeCursorBackup === null && (this.resizeCursorBackup = this.root.style.cursor || ""), this.root.style.cursor = "col-resize", this.root.dataset.extableColumnResize = "1";
|
|
3635
|
+
}
|
|
3636
|
+
updateColumnResize(t) {
|
|
3637
|
+
if (!this.columnResizeState) return;
|
|
3638
|
+
const e = t - this.columnResizeState.startX, i = this.columnResizeState.startWidth + e, o = Math.round(Math.max(this.columnResizeState.minWidth, i));
|
|
3639
|
+
if (o === this.columnResizeState.lastWidth) return;
|
|
3640
|
+
this.columnResizeState.lastWidth = o;
|
|
3641
|
+
const n = this.dataModel.getView(), s = { ...n.columnWidths ?? {} };
|
|
3642
|
+
s[this.columnResizeState.colKey] = o, this.onViewChange({ ...n, columnWidths: s });
|
|
3643
|
+
}
|
|
3644
|
+
endColumnResize() {
|
|
3645
|
+
this.columnResizing && (this.columnResizing = !1, this.columnResizeState = null, this.resizeCursorBackup !== null && (this.root.style.cursor = this.resizeCursorBackup, this.resizeCursorBackup = null), this.root.dataset.extableColumnResize = "");
|
|
3646
|
+
}
|
|
3558
3647
|
ensureLookupDropdown() {
|
|
3559
3648
|
if (this.lookupDropdownEl)
|
|
3560
3649
|
return this.lookupDropdownEl;
|
|
@@ -3621,52 +3710,52 @@ class Vo {
|
|
|
3621
3710
|
i.readOnly = !1, i.inputMode = "text";
|
|
3622
3711
|
const r = this.getCellRect(t, e);
|
|
3623
3712
|
if (r) {
|
|
3624
|
-
const
|
|
3625
|
-
i.style.transform = "none", i.style.left = `${r.left -
|
|
3713
|
+
const h = this.root.getBoundingClientRect();
|
|
3714
|
+
i.style.transform = "none", i.style.left = `${r.left - h.left}px`, i.style.top = `${r.top - h.top}px`, i.style.width = `${r.width}px`, i.style.height = `${r.height}px`, i.style.opacity = "1", i.style.pointerEvents = "auto", i.style.padding = "2px 4px", i.style.border = "none", i.style.background = "#fff", i.style.color = "#000", i.style.fontSize = "14px", i.style.fontFamily = "inherit", i.style.boxSizing = "border-box", i.style.zIndex = "100", i.style.WebkitAppearance = "none", i.style.WebkitUserSelect = "text", i.style.WebkitUserModify = "read-write";
|
|
3626
3715
|
}
|
|
3627
3716
|
}
|
|
3628
3717
|
if (n.recentLookup !== !1) {
|
|
3629
3718
|
const r = this.dataModel.getCell(t, e);
|
|
3630
3719
|
if (typeof r == "object" && r !== null) {
|
|
3631
|
-
const
|
|
3632
|
-
typeof
|
|
3633
|
-
label:
|
|
3634
|
-
value:
|
|
3720
|
+
const h = r;
|
|
3721
|
+
typeof h.label == "string" && "value" in h && !h.kind && this.lookupRecentHistory.set(e, {
|
|
3722
|
+
label: h.label,
|
|
3723
|
+
value: h.value
|
|
3635
3724
|
});
|
|
3636
3725
|
}
|
|
3637
3726
|
}
|
|
3638
3727
|
let s = -1;
|
|
3639
3728
|
const l = n.debounceMs ?? 250, a = (r) => {
|
|
3640
|
-
const
|
|
3729
|
+
const h = typeof r == "boolean" ? r : !1, d = i.value;
|
|
3641
3730
|
this.lookupDebounceTimer && (window.clearTimeout(this.lookupDebounceTimer), this.lookupDebounceTimer = null), this.lookupAbort?.abort(), this.lookupAbort = null, this.lookupRequestId += 1;
|
|
3642
|
-
const u = this.lookupRequestId, p = s,
|
|
3731
|
+
const u = this.lookupRequestId, p = s, m = () => {
|
|
3643
3732
|
this.lookupDebounceTimer = null;
|
|
3644
|
-
const
|
|
3645
|
-
this.lookupAbort =
|
|
3646
|
-
if (u !== this.lookupRequestId ||
|
|
3733
|
+
const b = new AbortController();
|
|
3734
|
+
this.lookupAbort = b, n.fetchCandidates({ query: d, rowId: t, colKey: e, signal: b.signal }).then((x) => {
|
|
3735
|
+
if (u !== this.lookupRequestId || b.signal.aborted || !this.activeCell || this.activeCell.rowId !== t || this.activeCell.colKey !== e)
|
|
3647
3736
|
return;
|
|
3648
|
-
let
|
|
3737
|
+
let w = Array.from(x);
|
|
3649
3738
|
if (n.recentLookup !== !1) {
|
|
3650
|
-
const
|
|
3651
|
-
if (
|
|
3652
|
-
|
|
3653
|
-
const
|
|
3654
|
-
|
|
3739
|
+
const y = this.lookupRecentHistory.get(e);
|
|
3740
|
+
if (y) {
|
|
3741
|
+
w = w.filter((v) => !(v.label === y.label && v.value === y.value));
|
|
3742
|
+
const g = { ...y, isRecent: !0 };
|
|
3743
|
+
w.unshift(g);
|
|
3655
3744
|
}
|
|
3656
3745
|
}
|
|
3657
|
-
s =
|
|
3658
|
-
const
|
|
3659
|
-
if (!n.allowFreeInput && p > 1 &&
|
|
3660
|
-
const
|
|
3661
|
-
this.lookupCandidates =
|
|
3746
|
+
s = w.length;
|
|
3747
|
+
const f = w.filter((y) => !y.isRecent);
|
|
3748
|
+
if (!n.allowFreeInput && p > 1 && f.length === 1) {
|
|
3749
|
+
const y = w.indexOf(f[0]);
|
|
3750
|
+
this.lookupCandidates = w, this.lookupHighlightIndex = y, this.commitLookupCandidate(y);
|
|
3662
3751
|
return;
|
|
3663
3752
|
}
|
|
3664
|
-
this.lookupCandidates =
|
|
3665
|
-
}).catch((
|
|
3666
|
-
u === this.lookupRequestId && (
|
|
3753
|
+
this.lookupCandidates = w, this.lookupHighlightIndex = w.length ? 0 : -1, this.renderLookupDropdown();
|
|
3754
|
+
}).catch((x) => {
|
|
3755
|
+
u === this.lookupRequestId && (b.signal.aborted || (this.hideLookupDropdown(), this.showCopyToast("Lookup failed", "error", 1800)));
|
|
3667
3756
|
});
|
|
3668
3757
|
};
|
|
3669
|
-
|
|
3758
|
+
h ? m() : this.lookupDebounceTimer = window.setTimeout(m, l);
|
|
3670
3759
|
};
|
|
3671
3760
|
i.addEventListener("input", a), this.lookupInputCleanup = () => i.removeEventListener("input", a), a(!0);
|
|
3672
3761
|
}
|
|
@@ -3764,18 +3853,18 @@ class Vo {
|
|
|
3764
3853
|
a.readOnly = !1, a.inputMode = "text";
|
|
3765
3854
|
const r = this.getCellRect(e, i);
|
|
3766
3855
|
if (r) {
|
|
3767
|
-
const
|
|
3768
|
-
a.style.transform = "none", a.style.left = `${r.left -
|
|
3856
|
+
const h = this.root.getBoundingClientRect();
|
|
3857
|
+
a.style.transform = "none", a.style.left = `${r.left - h.left}px`, a.style.top = `${r.top - h.top}px`, a.style.width = `${r.width}px`, a.style.height = `${r.height}px`, a.style.opacity = "1", a.style.pointerEvents = "auto", a.style.padding = "2px 4px", a.style.border = "none", a.style.background = "#fff", a.style.color = "#000", a.style.fontSize = "14px", a.style.fontFamily = "inherit", a.style.boxSizing = "border-box", a.style.zIndex = "100", a.style.WebkitAppearance = "none", a.style.WebkitUserSelect = "text", a.style.WebkitUserModify = "read-write";
|
|
3769
3858
|
}
|
|
3770
3859
|
if (t?.initialValueOverride !== void 0)
|
|
3771
3860
|
a.value = t.initialValueOverride;
|
|
3772
3861
|
else {
|
|
3773
|
-
const
|
|
3774
|
-
a.value = this.getInitialEditValue(i,
|
|
3862
|
+
const h = this.dataModel.getCell(e, i);
|
|
3863
|
+
a.value = this.getInitialEditValue(i, h);
|
|
3775
3864
|
}
|
|
3776
3865
|
if (this.inputEl = a, this.activeOriginalValue = { rowId: e, colKey: i, value: this.dataModel.getCell(e, i) }, o?.edit?.lookup && this.setupLookupEditor(e, i, a), a.focus({ preventScroll: !0 }), t?.placeCursorAtEnd) {
|
|
3777
|
-
const
|
|
3778
|
-
a.setSelectionRange(
|
|
3866
|
+
const h = a.value.length;
|
|
3867
|
+
a.setSelectionRange(h, h);
|
|
3779
3868
|
}
|
|
3780
3869
|
return;
|
|
3781
3870
|
}
|
|
@@ -3818,59 +3907,59 @@ class Vo {
|
|
|
3818
3907
|
) ? this.getCanvasCellMetrics(t, e) : null;
|
|
3819
3908
|
}
|
|
3820
3909
|
getCanvasCellMetrics(t, e) {
|
|
3821
|
-
const i = this.dataModel.getSchema(), o = this.dataModel.getView(), n = this.dataModel.listRows(), s = n.findIndex((
|
|
3910
|
+
const i = this.dataModel.getSchema(), o = this.dataModel.getView(), n = this.dataModel.listRows(), s = n.findIndex((x) => x.id === t), l = i.columns.findIndex((x) => String(x.key) === String(e));
|
|
3822
3911
|
if (s < 0 || l < 0) return null;
|
|
3823
|
-
const a =
|
|
3912
|
+
const a = st, r = lt, h = ft, d = Y(i, o);
|
|
3824
3913
|
let u = r;
|
|
3825
|
-
for (let
|
|
3914
|
+
for (let x = 0; x < l; x += 1) u += d[x] ?? 100;
|
|
3826
3915
|
let p = a;
|
|
3827
|
-
for (let
|
|
3828
|
-
const
|
|
3829
|
-
if (!
|
|
3830
|
-
const
|
|
3831
|
-
p +=
|
|
3916
|
+
for (let x = 0; x < s; x += 1) {
|
|
3917
|
+
const w = n[x];
|
|
3918
|
+
if (!w) return null;
|
|
3919
|
+
const f = this.dataModel.getRowHeight(w.id) ?? h;
|
|
3920
|
+
p += f;
|
|
3832
3921
|
}
|
|
3833
|
-
const
|
|
3834
|
-
return { left: u, top: p, width:
|
|
3922
|
+
const m = this.dataModel.getRowHeight(t) ?? h, b = d[l] ?? 100;
|
|
3923
|
+
return { left: u, top: p, width: b, height: m, rowIndex: s, colIndex: l };
|
|
3835
3924
|
}
|
|
3836
3925
|
getActiveCellRect() {
|
|
3837
3926
|
const t = this.activeCell;
|
|
3838
3927
|
if (!t) return null;
|
|
3839
3928
|
const e = this.root.getBoundingClientRect(), i = this.dataModel.getSchema(), o = this.dataModel.getView();
|
|
3840
3929
|
if (t.rowId === "__all__" && t.colKey === "__all__")
|
|
3841
|
-
return new DOMRect(e.left, e.top,
|
|
3930
|
+
return new DOMRect(e.left, e.top, lt, st);
|
|
3842
3931
|
if (t.rowId === "__header__" && t.colKey !== null) {
|
|
3843
3932
|
const s = this.escapeCssAttrValue(String(t.colKey)), l = this.root.querySelector(`th[data-col-key="${s}"]`);
|
|
3844
3933
|
if (l) return l.getBoundingClientRect();
|
|
3845
3934
|
const a = i.columns.findIndex((r) => String(r.key) === String(t.colKey));
|
|
3846
3935
|
if (a >= 0) {
|
|
3847
|
-
const r =
|
|
3848
|
-
let
|
|
3849
|
-
for (let u = 0; u < a; u += 1)
|
|
3850
|
-
const
|
|
3936
|
+
const r = Y(i, o);
|
|
3937
|
+
let h = lt;
|
|
3938
|
+
for (let u = 0; u < a; u += 1) h += r[u] ?? 100;
|
|
3939
|
+
const d = r[a] ?? 100;
|
|
3851
3940
|
return new DOMRect(
|
|
3852
|
-
e.left +
|
|
3941
|
+
e.left + h - this.root.scrollLeft,
|
|
3853
3942
|
e.top,
|
|
3854
|
-
|
|
3855
|
-
|
|
3943
|
+
d,
|
|
3944
|
+
st
|
|
3856
3945
|
);
|
|
3857
3946
|
}
|
|
3858
3947
|
}
|
|
3859
3948
|
if (t.colKey === null) {
|
|
3860
3949
|
const s = this.dataModel.getRowIndex(t.rowId);
|
|
3861
3950
|
if (s >= 0) {
|
|
3862
|
-
let l =
|
|
3951
|
+
let l = st;
|
|
3863
3952
|
const a = this.dataModel.listRows();
|
|
3864
|
-
for (let
|
|
3865
|
-
const
|
|
3866
|
-
if (!
|
|
3867
|
-
l += this.dataModel.getRowHeight(
|
|
3953
|
+
for (let h = 0; h < s; h += 1) {
|
|
3954
|
+
const d = a[h];
|
|
3955
|
+
if (!d) break;
|
|
3956
|
+
l += this.dataModel.getRowHeight(d.id) ?? ft;
|
|
3868
3957
|
}
|
|
3869
3958
|
const r = this.dataModel.getRowHeight(t.rowId) ?? ft;
|
|
3870
3959
|
return new DOMRect(
|
|
3871
3960
|
e.left,
|
|
3872
3961
|
e.top + l - this.root.scrollTop,
|
|
3873
|
-
|
|
3962
|
+
lt,
|
|
3874
3963
|
r
|
|
3875
3964
|
);
|
|
3876
3965
|
}
|
|
@@ -3887,8 +3976,8 @@ class Vo {
|
|
|
3887
3976
|
}
|
|
3888
3977
|
const o = this.getCanvasCellMetrics(t, e);
|
|
3889
3978
|
if (!o) return;
|
|
3890
|
-
const n = o.left, s = o.left + o.width, l = o.top, a = o.top + o.height, r = this.root.scrollLeft,
|
|
3891
|
-
n < r ? this.root.scrollLeft = Math.max(0, n) : s >
|
|
3979
|
+
const n = o.left, s = o.left + o.width, l = o.top, a = o.top + o.height, r = this.root.scrollLeft, h = this.root.scrollLeft + this.root.clientWidth, d = this.root.scrollTop, u = this.root.scrollTop + this.root.clientHeight;
|
|
3980
|
+
n < r ? this.root.scrollLeft = Math.max(0, n) : s > h && (this.root.scrollLeft = Math.max(0, s - this.root.clientWidth)), l < d ? this.root.scrollTop = Math.max(0, l) : a > u && (this.root.scrollTop = Math.max(0, a - this.root.clientHeight));
|
|
3892
3981
|
}
|
|
3893
3982
|
moveActiveCell(t, e, i = !1) {
|
|
3894
3983
|
const o = this.dataModel.getSchema(), n = this.dataModel.listRows();
|
|
@@ -3897,28 +3986,28 @@ class Vo {
|
|
|
3897
3986
|
this.lastCommittedLookupCell = null, i || (this.selectionAnchor = null);
|
|
3898
3987
|
const a = i && this.selectionAnchor ? this.selectionAnchor : i ? { rowIndex: s, colIndex: l } : null;
|
|
3899
3988
|
i && !this.selectionAnchor && (this.selectionAnchor = { rowIndex: s, colIndex: l });
|
|
3900
|
-
const r = Math.max(0, Math.min(n.length - 1, s + t)),
|
|
3989
|
+
const r = Math.max(0, Math.min(n.length - 1, s + t)), h = Math.max(0, Math.min(o.columns.length - 1, l + e));
|
|
3901
3990
|
{
|
|
3902
|
-
const
|
|
3903
|
-
if (!
|
|
3904
|
-
const u = o.columns[
|
|
3991
|
+
const d = n[r];
|
|
3992
|
+
if (!d) return;
|
|
3993
|
+
const u = o.columns[h];
|
|
3905
3994
|
if (!u) return;
|
|
3906
|
-
const p =
|
|
3995
|
+
const p = d.id, m = u.key, b = a ? {
|
|
3907
3996
|
kind: "cells",
|
|
3908
3997
|
startRow: a.rowIndex,
|
|
3909
3998
|
endRow: r,
|
|
3910
3999
|
startCol: a.colIndex,
|
|
3911
|
-
endCol:
|
|
4000
|
+
endCol: h
|
|
3912
4001
|
} : {
|
|
3913
4002
|
kind: "cells",
|
|
3914
4003
|
startRow: r,
|
|
3915
4004
|
endRow: r,
|
|
3916
|
-
startCol:
|
|
3917
|
-
endCol:
|
|
4005
|
+
startCol: h,
|
|
4006
|
+
endCol: h
|
|
3918
4007
|
};
|
|
3919
|
-
this.selectionRanges = [
|
|
3920
|
-
const
|
|
3921
|
-
this.focusSelectionInput(
|
|
4008
|
+
this.selectionRanges = [b], this.activeCell = { rowId: p, colKey: m }, this.onActiveChange(p, m), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(p, m);
|
|
4009
|
+
const x = this.dataModel.getCell(p, m), w = this.cellToClipboardString(x);
|
|
4010
|
+
this.focusSelectionInput(w), this.updateFillHandleFlag();
|
|
3922
4011
|
return;
|
|
3923
4012
|
}
|
|
3924
4013
|
}
|
|
@@ -3935,10 +4024,10 @@ class Vo {
|
|
|
3935
4024
|
};
|
|
3936
4025
|
const l = o.closest("th.extable-row-header:not(.extable-corner)");
|
|
3937
4026
|
if (l) {
|
|
3938
|
-
const
|
|
3939
|
-
if (
|
|
4027
|
+
const d = l.closest("tr[data-row-id]");
|
|
4028
|
+
if (d)
|
|
3940
4029
|
return {
|
|
3941
|
-
rowId:
|
|
4030
|
+
rowId: d.dataset.rowId ?? "",
|
|
3942
4031
|
colKey: null,
|
|
3943
4032
|
element: l,
|
|
3944
4033
|
rect: l.getBoundingClientRect()
|
|
@@ -3952,10 +4041,10 @@ class Vo {
|
|
|
3952
4041
|
element: a,
|
|
3953
4042
|
rect: a.getBoundingClientRect()
|
|
3954
4043
|
};
|
|
3955
|
-
const r = o.closest("td[data-col-key]"),
|
|
3956
|
-
if (r &&
|
|
4044
|
+
const r = o.closest("td[data-col-key]"), h = r?.closest("tr[data-row-id]");
|
|
4045
|
+
if (r && h)
|
|
3957
4046
|
return {
|
|
3958
|
-
rowId:
|
|
4047
|
+
rowId: h.dataset.rowId ?? "",
|
|
3959
4048
|
colKey: r.dataset.colKey ?? "",
|
|
3960
4049
|
element: r,
|
|
3961
4050
|
rect: r.getBoundingClientRect()
|
|
@@ -3971,18 +4060,18 @@ class Vo {
|
|
|
3971
4060
|
return;
|
|
3972
4061
|
const o = this.dataModel.getSchema(), n = this.dataModel.listRows(), s = this.dataModel.getRowIndex(i.rowId);
|
|
3973
4062
|
if (s < 0) return;
|
|
3974
|
-
const l = this.dragStart.kind === "rows" ? o.columns.length - 1 : o.columns.findIndex((
|
|
4063
|
+
const l = this.dragStart.kind === "rows" ? o.columns.length - 1 : o.columns.findIndex((m) => String(m.key) === String(i.colKey));
|
|
3975
4064
|
if (l < 0) return;
|
|
3976
|
-
const a = this.dragStart.rowIndex, r = this.dragStart.kind === "rows" ? 0 : this.dragStart.colIndex,
|
|
3977
|
-
(s !== a ||
|
|
3978
|
-
const
|
|
4065
|
+
const a = this.dragStart.rowIndex, r = this.dragStart.kind === "rows" ? 0 : this.dragStart.colIndex, h = this.dragStart.kind === "rows" ? o.columns.length - 1 : l;
|
|
4066
|
+
(s !== a || h !== r) && (this.dragSelectionChanged = !0);
|
|
4067
|
+
const d = {
|
|
3979
4068
|
kind: this.dragStart.kind,
|
|
3980
4069
|
startRow: a,
|
|
3981
4070
|
endRow: s,
|
|
3982
4071
|
startCol: r,
|
|
3983
|
-
endCol:
|
|
4072
|
+
endCol: h
|
|
3984
4073
|
};
|
|
3985
|
-
this.selectionRanges = [
|
|
4074
|
+
this.selectionRanges = [d];
|
|
3986
4075
|
const u = n[s]?.id ?? i.rowId, p = this.dragStart.kind === "rows" ? o.columns[0]?.key ?? i.colKey : o.columns[l]?.key ?? i.colKey;
|
|
3987
4076
|
this.activeCell = { rowId: u, colKey: p }, this.onActiveChange(u, p), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
|
|
3988
4077
|
}
|
|
@@ -3995,10 +4084,10 @@ class Vo {
|
|
|
3995
4084
|
const a = Math.max(this.fillSource.endRowIndex, s);
|
|
3996
4085
|
if (this.fillEndRowIndex !== a) {
|
|
3997
4086
|
this.fillEndRowIndex = a;
|
|
3998
|
-
const r = n[a]?.id ?? i.rowId,
|
|
3999
|
-
if (!
|
|
4000
|
-
const
|
|
4001
|
-
this.activeCell = { rowId: r, colKey:
|
|
4087
|
+
const r = n[a]?.id ?? i.rowId, h = o.columns[this.fillSource.colIndex];
|
|
4088
|
+
if (!h) return;
|
|
4089
|
+
const d = h.key;
|
|
4090
|
+
this.activeCell = { rowId: r, colKey: d }, this.onActiveChange(r, d), this.selectionRanges = [
|
|
4002
4091
|
{
|
|
4003
4092
|
kind: "cells",
|
|
4004
4093
|
startRow: this.fillSource.startRowIndex,
|
|
@@ -4040,21 +4129,21 @@ class Vo {
|
|
|
4040
4129
|
commitFill(t, e) {
|
|
4041
4130
|
const i = this.dataModel.getSchema(), o = this.dataModel.listRows(), n = i.columns[t.colIndex];
|
|
4042
4131
|
if (!n || e <= t.endRowIndex) return;
|
|
4043
|
-
const s =
|
|
4132
|
+
const s = Do(this.dataModel, t, this.sequenceLangs);
|
|
4044
4133
|
if (!s) return;
|
|
4045
4134
|
const l = this.editMode === "direct", a = `fill:${Date.now()}:${Math.random().toString(16).slice(2)}`;
|
|
4046
|
-
for (let
|
|
4047
|
-
const u = o[
|
|
4135
|
+
for (let d = t.endRowIndex + 1; d <= e; d += 1) {
|
|
4136
|
+
const u = o[d];
|
|
4048
4137
|
if (!u) break;
|
|
4049
4138
|
if (this.isCellReadonly(u.id, n.key)) continue;
|
|
4050
|
-
const p =
|
|
4139
|
+
const p = d - t.endRowIndex, m = s(p), b = {
|
|
4051
4140
|
kind: "edit",
|
|
4052
4141
|
rowId: u.id,
|
|
4053
4142
|
colKey: n.key,
|
|
4054
|
-
next:
|
|
4143
|
+
next: m,
|
|
4055
4144
|
payload: { batchId: a }
|
|
4056
4145
|
};
|
|
4057
|
-
this.onEdit(
|
|
4146
|
+
this.onEdit(b, l);
|
|
4058
4147
|
}
|
|
4059
4148
|
const r = o[e];
|
|
4060
4149
|
if (!r) return;
|
|
@@ -4067,12 +4156,12 @@ class Vo {
|
|
|
4067
4156
|
endCol: t.colIndex
|
|
4068
4157
|
}
|
|
4069
4158
|
], this.activeCell = { rowId: r.id, colKey: n.key }, this.onActiveChange(r.id, n.key), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.ensureVisibleCell(r.id, n.key);
|
|
4070
|
-
const
|
|
4071
|
-
this.focusSelectionInput(this.cellToClipboardString(
|
|
4159
|
+
const h = this.dataModel.getCell(r.id, n.key);
|
|
4160
|
+
this.focusSelectionInput(this.cellToClipboardString(h));
|
|
4072
4161
|
}
|
|
4073
4162
|
teardownSelectionInput() {
|
|
4074
4163
|
const t = this.selectionInput;
|
|
4075
|
-
t && (this.selectionInput = null, t.removeEventListener("keydown", this.handleSelectionKeydown), t.removeEventListener("beforeinput", this.handleSelectionBeforeInput), t.removeEventListener("compositionstart", this.handleSelectionCompositionStart), t.removeEventListener("copy", this.handleSelectionCopy), t.removeEventListener("cut", this.handleSelectionCut), t.removeEventListener("paste", this.handleSelectionPaste), t.removeEventListener("blur", this.handleSelectionBlur),
|
|
4164
|
+
t && (this.selectionInput = null, t.removeEventListener("keydown", this.handleSelectionKeydown), t.removeEventListener("beforeinput", this.handleSelectionBeforeInput), t.removeEventListener("compositionstart", this.handleSelectionCompositionStart), t.removeEventListener("copy", this.handleSelectionCopy), t.removeEventListener("cut", this.handleSelectionCut), t.removeEventListener("paste", this.handleSelectionPaste), t.removeEventListener("blur", this.handleSelectionBlur), O(t));
|
|
4076
4165
|
}
|
|
4077
4166
|
async copySelection() {
|
|
4078
4167
|
const t = this.buildSelectionClipboardPayload();
|
|
@@ -4172,21 +4261,21 @@ class Vo {
|
|
|
4172
4261
|
if (!i || i.kind !== "cells") return null;
|
|
4173
4262
|
const o = [], n = [], s = "border-collapse:collapse;border-spacing:0;", l = "border:1px solid #d0d7de;padding:4px 6px;vertical-align:top;";
|
|
4174
4263
|
let a = 0;
|
|
4175
|
-
for (let
|
|
4176
|
-
const u = e[
|
|
4264
|
+
for (let d = i.startRow; d <= i.endRow; d += 1) {
|
|
4265
|
+
const u = e[d];
|
|
4177
4266
|
if (!u) continue;
|
|
4178
|
-
const p = [],
|
|
4179
|
-
for (let
|
|
4180
|
-
const
|
|
4181
|
-
if (!
|
|
4182
|
-
const
|
|
4183
|
-
p.push(
|
|
4267
|
+
const p = [], m = [];
|
|
4268
|
+
for (let b = i.startCol; b <= i.endCol; b += 1) {
|
|
4269
|
+
const x = t.columns[b];
|
|
4270
|
+
if (!x) continue;
|
|
4271
|
+
const w = this.dataModel.getCell(u.id, x.key), f = this.cellToClipboardString(w);
|
|
4272
|
+
p.push(f), m.push(`<td style="${l}">${this.escapeHtml(f)}</td>`), a += 1;
|
|
4184
4273
|
}
|
|
4185
|
-
o.push(p.join(" ")), n.push(`<tr>${
|
|
4274
|
+
o.push(p.join(" ")), n.push(`<tr>${m.join("")}</tr>`);
|
|
4186
4275
|
}
|
|
4187
4276
|
const r = o.join(`\r
|
|
4188
|
-
`),
|
|
4189
|
-
return { text: r, html:
|
|
4277
|
+
`), h = `<table style="${s}"><tbody>${n.join("")}</tbody></table>`;
|
|
4278
|
+
return { text: r, html: h, cellCount: a };
|
|
4190
4279
|
}
|
|
4191
4280
|
clearSelectionValues() {
|
|
4192
4281
|
const t = this.dataModel.getSchema(), e = this.dataModel.listRows(), i = this.getCopyRange();
|
|
@@ -4198,14 +4287,14 @@ class Vo {
|
|
|
4198
4287
|
for (let a = i.startCol; a <= i.endCol; a += 1) {
|
|
4199
4288
|
const r = t.columns[a];
|
|
4200
4289
|
if (!r || this.isCellReadonly(l.id, r.key)) continue;
|
|
4201
|
-
const
|
|
4290
|
+
const h = r.type === "boolean" ? !1 : "", d = {
|
|
4202
4291
|
kind: "edit",
|
|
4203
4292
|
rowId: l.id,
|
|
4204
4293
|
colKey: r.key,
|
|
4205
|
-
next:
|
|
4294
|
+
next: h,
|
|
4206
4295
|
payload: { batchId: n }
|
|
4207
4296
|
};
|
|
4208
|
-
this.onEdit(
|
|
4297
|
+
this.onEdit(d, o);
|
|
4209
4298
|
}
|
|
4210
4299
|
}
|
|
4211
4300
|
}
|
|
@@ -4245,9 +4334,9 @@ class Vo {
|
|
|
4245
4334
|
if (!i) return t;
|
|
4246
4335
|
if (t === "") return "";
|
|
4247
4336
|
if (i.type === "number" || i.type === "int" || i.type === "uint") {
|
|
4248
|
-
const o =
|
|
4337
|
+
const o = se(t);
|
|
4249
4338
|
if (!o.ok) return t;
|
|
4250
|
-
const n =
|
|
4339
|
+
const n = le(o.value, i.type);
|
|
4251
4340
|
return n.ok ? n.value : t;
|
|
4252
4341
|
}
|
|
4253
4342
|
if (i.type === "boolean") {
|
|
@@ -4261,19 +4350,19 @@ class Vo {
|
|
|
4261
4350
|
for (let a = 0; a < t.length; a += 1) {
|
|
4262
4351
|
const r = i[o + a];
|
|
4263
4352
|
if (!r) break;
|
|
4264
|
-
const
|
|
4265
|
-
for (let
|
|
4266
|
-
const u = e.columns[n +
|
|
4353
|
+
const h = t[a] ?? [];
|
|
4354
|
+
for (let d = 0; d < h.length; d += 1) {
|
|
4355
|
+
const u = e.columns[n + d];
|
|
4267
4356
|
if (!u) break;
|
|
4268
4357
|
if (this.isCellReadonly(r.id, u.key)) continue;
|
|
4269
|
-
const p = this.coerceCellValue(d
|
|
4358
|
+
const p = this.coerceCellValue(h[d] ?? "", u.key), m = {
|
|
4270
4359
|
kind: "edit",
|
|
4271
4360
|
rowId: r.id,
|
|
4272
4361
|
colKey: u.key,
|
|
4273
4362
|
next: p,
|
|
4274
4363
|
payload: { batchId: l }
|
|
4275
4364
|
};
|
|
4276
|
-
this.onEdit(
|
|
4365
|
+
this.onEdit(m, s);
|
|
4277
4366
|
}
|
|
4278
4367
|
}
|
|
4279
4368
|
}
|
|
@@ -4305,26 +4394,26 @@ class Vo {
|
|
|
4305
4394
|
if (i?.type === "enum" || i?.type === "tags") {
|
|
4306
4395
|
const s = i.enum?.allowCustom ?? i.tags?.allowCustom, l = i.enum?.options ?? i.tags?.options ?? [];
|
|
4307
4396
|
if (s === !1) {
|
|
4308
|
-
const
|
|
4309
|
-
u.value = "", u.textContent = "",
|
|
4397
|
+
const d = document.createElement("select"), u = document.createElement("option");
|
|
4398
|
+
u.value = "", u.textContent = "", d.appendChild(u);
|
|
4310
4399
|
for (const p of l) {
|
|
4311
|
-
const
|
|
4312
|
-
|
|
4400
|
+
const m = document.createElement("option");
|
|
4401
|
+
m.value = p, m.textContent = p, e === p && (m.selected = !0), d.appendChild(m);
|
|
4313
4402
|
}
|
|
4314
|
-
return { control:
|
|
4403
|
+
return { control: d, value: e };
|
|
4315
4404
|
}
|
|
4316
4405
|
const a = document.createElement("input");
|
|
4317
4406
|
a.type = "text";
|
|
4318
4407
|
const r = `extable-datalist-${String(t)}`;
|
|
4319
4408
|
a.setAttribute("list", r), a.value = e;
|
|
4320
|
-
let
|
|
4321
|
-
if (!
|
|
4322
|
-
|
|
4323
|
-
for (const
|
|
4409
|
+
let h = document.getElementById(r);
|
|
4410
|
+
if (!h) {
|
|
4411
|
+
h = document.createElement("datalist"), h.id = r;
|
|
4412
|
+
for (const d of l) {
|
|
4324
4413
|
const u = document.createElement("option");
|
|
4325
|
-
u.value =
|
|
4414
|
+
u.value = d, h.appendChild(u);
|
|
4326
4415
|
}
|
|
4327
|
-
this.root.appendChild(
|
|
4416
|
+
this.root.appendChild(h);
|
|
4328
4417
|
}
|
|
4329
4418
|
return { control: a, value: e, datalistId: r };
|
|
4330
4419
|
}
|
|
@@ -4343,10 +4432,10 @@ class Vo {
|
|
|
4343
4432
|
if ((i.type === "number" || i.type === "int" || i.type === "uint") && typeof e == "number") {
|
|
4344
4433
|
if (i.type === "number") {
|
|
4345
4434
|
const s = i.format;
|
|
4346
|
-
return (s?.format ?? "decimal") === "scientific" ?
|
|
4435
|
+
return (s?.format ?? "decimal") === "scientific" ? Rt(e, { format: "scientific", precision: s?.precision }) : Rt(e, { format: "decimal", scale: s?.scale });
|
|
4347
4436
|
}
|
|
4348
4437
|
const n = i.format?.format ?? "decimal";
|
|
4349
|
-
return n === "binary" || n === "octal" || n === "hex" ?
|
|
4438
|
+
return n === "binary" || n === "octal" || n === "hex" ? Ot(e, n) : String(e);
|
|
4350
4439
|
}
|
|
4351
4440
|
return String(e);
|
|
4352
4441
|
}
|
|
@@ -4355,11 +4444,11 @@ class Vo {
|
|
|
4355
4444
|
return { ok: !0, value: this.inputEl?.value ?? "" };
|
|
4356
4445
|
const t = this.findColumn(this.activeCell.colKey);
|
|
4357
4446
|
if (t && (t.type === "number" || t.type === "int" || t.type === "uint") && this.inputEl instanceof HTMLInputElement) {
|
|
4358
|
-
const e =
|
|
4447
|
+
const e = Oe(this.inputEl.value);
|
|
4359
4448
|
if (e === "") return { ok: !0, value: "" };
|
|
4360
|
-
const i =
|
|
4449
|
+
const i = se(e);
|
|
4361
4450
|
if (!i.ok) return { ok: !1 };
|
|
4362
|
-
const o =
|
|
4451
|
+
const o = le(i.value, t.type);
|
|
4363
4452
|
return o.ok ? { ok: !0, value: o.value } : { ok: !1 };
|
|
4364
4453
|
}
|
|
4365
4454
|
return { ok: !0, value: this.readActiveValue() };
|
|
@@ -4377,7 +4466,7 @@ class Vo {
|
|
|
4377
4466
|
t.rows = Math.max(1, o), t.style.minHeight = `${i}px`;
|
|
4378
4467
|
}
|
|
4379
4468
|
positionFloatingContentBox(t, e) {
|
|
4380
|
-
const i = ut, o =
|
|
4469
|
+
const i = ut, o = at, n = Mt;
|
|
4381
4470
|
e.style.left = `${t.left + i}px`, e.style.top = `${t.top + o}px`, e.style.width = `${Math.max(8, t.width - i * 2)}px`, e.style.height = `${Math.max(8, t.height - (o + n))}px`;
|
|
4382
4471
|
}
|
|
4383
4472
|
triggerCellAction(t, e, i) {
|
|
@@ -4401,13 +4490,13 @@ class Vo {
|
|
|
4401
4490
|
if (!o || o.type !== "tags") return !1;
|
|
4402
4491
|
const n = this.dataModel.getCell(t, e), s = this.normalizeTagValues(n);
|
|
4403
4492
|
if (!s || i < 0 || i >= s.length) return !1;
|
|
4404
|
-
const l = s.filter((
|
|
4493
|
+
const l = s.filter((d, u) => u !== i), a = n && typeof n == "object" && n.kind === "tags" ? { kind: "tags", values: l } : l, r = {
|
|
4405
4494
|
kind: "edit",
|
|
4406
4495
|
rowId: t,
|
|
4407
4496
|
colKey: e,
|
|
4408
4497
|
next: a
|
|
4409
|
-
},
|
|
4410
|
-
return this.onEdit(r,
|
|
4498
|
+
}, h = this.editMode === "direct";
|
|
4499
|
+
return this.onEdit(r, h), !0;
|
|
4411
4500
|
}
|
|
4412
4501
|
normalizeTagValues(t) {
|
|
4413
4502
|
if (Array.isArray(t) && t.every((e) => typeof e == "string"))
|
|
@@ -4429,11 +4518,27 @@ class Vo {
|
|
|
4429
4518
|
i.href = t, i.target = e ?? "_self", i.rel = "noopener noreferrer", i.style.display = "none", document.body.appendChild(i), i.click(), i.remove();
|
|
4430
4519
|
}
|
|
4431
4520
|
toggleBoolean(t, e) {
|
|
4432
|
-
const i = this.dataModel.getCell(t, e),
|
|
4433
|
-
|
|
4521
|
+
const i = this.dataModel.getCell(t, e), o = i === !0 || i === "true" || i === "1" || i === 1, n = this.findColumn(e), s = this.editMode === "direct";
|
|
4522
|
+
if (n && n.unique) {
|
|
4523
|
+
if (o)
|
|
4524
|
+
return;
|
|
4525
|
+
const r = `unique-bool:${Date.now()}:${Math.random().toString(16).slice(2)}`, h = [
|
|
4526
|
+
{ kind: "edit", rowId: t, colKey: e, next: !0, payload: { batchId: r } }
|
|
4527
|
+
], d = this.dataModel.listRows();
|
|
4528
|
+
for (const u of d) {
|
|
4529
|
+
if (!u || u.id === t) continue;
|
|
4530
|
+
const p = this.dataModel.getCell(u.id, e);
|
|
4531
|
+
(p === !0 || p === "true" || p === "1" || p === 1) && h.push({ kind: "edit", rowId: u.id, colKey: e, next: !1, payload: { batchId: r } });
|
|
4532
|
+
}
|
|
4533
|
+
for (const u of h) this.onEdit(u, s);
|
|
4534
|
+
this.onMove(t);
|
|
4535
|
+
return;
|
|
4536
|
+
}
|
|
4537
|
+
const a = { kind: "edit", rowId: t, colKey: e, next: !o };
|
|
4538
|
+
this.onEdit(a, s), this.onMove(t);
|
|
4434
4539
|
}
|
|
4435
4540
|
applySelectionFromHit(t, e) {
|
|
4436
|
-
const i = this.dataModel.getSchema(), o = this.dataModel.getRowIndex(e.rowId), n = e.colKey === null, s = n ? i.columns.length > 0 ? 0 : -1 : i.columns.findIndex((
|
|
4541
|
+
const i = this.dataModel.getSchema(), o = this.dataModel.getRowIndex(e.rowId), n = e.colKey === null, s = n ? i.columns.length > 0 ? 0 : -1 : i.columns.findIndex((h) => String(h.key) === String(e.colKey));
|
|
4437
4542
|
if (s < 0) return;
|
|
4438
4543
|
const l = n ? {
|
|
4439
4544
|
kind: "rows",
|
|
@@ -4450,16 +4555,16 @@ class Vo {
|
|
|
4450
4555
|
};
|
|
4451
4556
|
let a = [];
|
|
4452
4557
|
if (t.shiftKey && this.activeCell) {
|
|
4453
|
-
const
|
|
4558
|
+
const h = this.activeCell, d = this.dataModel.getRowIndex(h.rowId), u = i.columns.findIndex((m) => String(m.key) === String(h.colKey));
|
|
4454
4559
|
a = [n ? {
|
|
4455
4560
|
kind: "rows",
|
|
4456
|
-
startRow:
|
|
4561
|
+
startRow: d,
|
|
4457
4562
|
endRow: o,
|
|
4458
4563
|
startCol: 0,
|
|
4459
4564
|
endCol: i.columns.length - 1
|
|
4460
4565
|
} : {
|
|
4461
4566
|
kind: "cells",
|
|
4462
|
-
startRow:
|
|
4567
|
+
startRow: d,
|
|
4463
4568
|
endRow: o,
|
|
4464
4569
|
startCol: Math.max(0, u),
|
|
4465
4570
|
endCol: Math.max(0, s)
|
|
@@ -4507,10 +4612,10 @@ class Vo {
|
|
|
4507
4612
|
this.activeOriginalValue = { rowId: e, colKey: i, value: n };
|
|
4508
4613
|
const s = o?.initialValueOverride ?? this.getInitialEditValue(i, n), { control: l, value: a } = this.createEditor(i, s), r = l;
|
|
4509
4614
|
r.value = a;
|
|
4510
|
-
const
|
|
4511
|
-
r.style.width = "100%", r.style.boxSizing = "border-box", r.style.margin = "0", r.style.padding =
|
|
4512
|
-
const
|
|
4513
|
-
if (r.style.textAlign =
|
|
4615
|
+
const h = r instanceof HTMLInputElement && r.type === "checkbox";
|
|
4616
|
+
r.style.width = "100%", r.style.boxSizing = "border-box", r.style.margin = "0", r.style.padding = h ? "0" : "2px 4px", r.style.border = "none", r.style.borderRadius = "0", r.style.boxShadow = "none", r.style.background = "#fff", r.style.color = "#000", r.style.outline = "none", r.style.fontSize = "14px", r.style.fontFamily = "inherit", r.style.lineHeight = "16px", r.style.fontWeight = "inherit", r.style.WebkitAppearance = "none", r.style.WebkitBorderRadius = "0", r.style.WebkitBoxShadow = "none", r.style.WebkitUserSelect = "text", r.style.WebkitUserModify = "read-write", (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && (r.style.visibility = "visible", r.style.opacity = "1", r.style.display = "block"), h && (r.style.width = "auto", r.style.lineHeight = "normal");
|
|
4617
|
+
const d = this.findColumn(i);
|
|
4618
|
+
if (r.style.textAlign = d?.style?.align ?? (d?.type === "number" || d?.type === "int" || d?.type === "uint" ? "right" : "left"), r.addEventListener("keydown", (u) => this.handleKey(u, t)), r.addEventListener("focus", () => {
|
|
4514
4619
|
(r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && r.select();
|
|
4515
4620
|
}), this.bindImmediateCommit(r), t.textContent = "", t.appendChild(r), r.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
|
|
4516
4621
|
r instanceof HTMLTextAreaElement && this.autosize(r);
|
|
@@ -4528,20 +4633,20 @@ class Vo {
|
|
|
4528
4633
|
this.activeHost = s, this.activeHostOriginalText = null, s.style.position = "absolute", s.style.display = "block", s.style.visibility = "visible", s.dataset.extableFloating = "fixed", s.style.pointerEvents = "auto", s.style.padding = "0", s.style.zIndex = "10";
|
|
4529
4634
|
const l = this.dataModel.getCell(e, i);
|
|
4530
4635
|
this.activeOriginalValue = { rowId: e, colKey: i, value: l };
|
|
4531
|
-
const a = o?.initialValueOverride ?? this.getInitialEditValue(i, l), { control: r, value:
|
|
4532
|
-
|
|
4533
|
-
const u =
|
|
4534
|
-
|
|
4636
|
+
const a = o?.initialValueOverride ?? this.getInitialEditValue(i, l), { control: r, value: h } = this.createEditor(i, a), d = r;
|
|
4637
|
+
d.value = h;
|
|
4638
|
+
const u = d instanceof HTMLInputElement && d.type === "checkbox";
|
|
4639
|
+
d.style.width = "100%", d.style.height = "100%", d.style.boxSizing = "border-box", d.style.margin = "0", d.style.padding = u ? "0" : "2px 4px", d.style.border = "none", d.style.borderRadius = "0", d.style.boxShadow = "none", d.style.background = "#fff", d.style.color = "#000", d.style.outline = "none", d.style.fontSize = "14px", d.style.fontFamily = "inherit", d.style.lineHeight = "16px", d.style.fontWeight = "inherit", d.style.WebkitAppearance = "none", d.style.WebkitBorderRadius = "0", d.style.WebkitBoxShadow = "none", d.style.WebkitUserSelect = "text", d.style.WebkitUserModify = "read-write", (d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement) && (d.style.visibility = "visible", d.style.opacity = "1", d.style.display = "block"), u && (d.style.width = "auto", d.style.height = "auto", d.style.lineHeight = "normal");
|
|
4535
4640
|
const p = this.findColumn(i);
|
|
4536
|
-
if (
|
|
4537
|
-
(
|
|
4538
|
-
}), this.bindImmediateCommit(
|
|
4539
|
-
|
|
4540
|
-
}), this.root.appendChild(s), this.positionFloatingContentBox(n, s),
|
|
4541
|
-
const
|
|
4542
|
-
|
|
4641
|
+
if (d.style.textAlign = p?.style?.align ?? (p?.type === "number" || p?.type === "int" || p?.type === "uint" ? "right" : "left"), d.style.pointerEvents = "auto", d.addEventListener("keydown", (m) => this.handleKey(m, s)), d.addEventListener("compositionstart", this.handleInputCompositionStart), d.addEventListener("compositionend", this.handleInputCompositionEnd), d.addEventListener("focus", () => {
|
|
4642
|
+
(d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement) && d.select();
|
|
4643
|
+
}), this.bindImmediateCommit(d), s.appendChild(d), d.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
|
|
4644
|
+
d instanceof HTMLTextAreaElement && this.autosize(d);
|
|
4645
|
+
}), this.root.appendChild(s), this.positionFloatingContentBox(n, s), d.focus({ preventScroll: !0 }), o?.placeCursorAtEnd && (d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement)) {
|
|
4646
|
+
const m = d.value.length;
|
|
4647
|
+
d.setSelectionRange(m, m);
|
|
4543
4648
|
}
|
|
4544
|
-
this.inputEl =
|
|
4649
|
+
this.inputEl = d, this.floatingInputWrapper = s, this.setupLookupEditor(e, i, d);
|
|
4545
4650
|
}
|
|
4546
4651
|
handleKey(t, e) {
|
|
4547
4652
|
if (!this.activeCell || !this.inputEl) return;
|
|
@@ -4549,9 +4654,9 @@ class Vo {
|
|
|
4549
4654
|
if (t.isComposing || this.composing || i - this.lastCompositionEnd < 24 || this.handleLookupKeydown(t)) return;
|
|
4550
4655
|
const { rowId: o, colKey: n } = this.activeCell;
|
|
4551
4656
|
if (n === null) return;
|
|
4552
|
-
const s = this.inputEl.tagName.toLowerCase() === "textarea", l = t.key === "Enter" && t.altKey, a = (r,
|
|
4553
|
-
const
|
|
4554
|
-
|
|
4657
|
+
const s = this.inputEl.tagName.toLowerCase() === "textarea", l = t.key === "Enter" && t.altKey, a = (r, h) => {
|
|
4658
|
+
const d = this.readActiveValueForCommit();
|
|
4659
|
+
d.ok && (this.commitEdit(o, n, d.value), this.onMove(o), this.teardownInput(!1), this.moveActiveCell(r, h));
|
|
4555
4660
|
};
|
|
4556
4661
|
if (t.key === "Tab") {
|
|
4557
4662
|
t.preventDefault(), a(0, t.shiftKey ? -1 : 1);
|
|
@@ -4565,8 +4670,8 @@ class Vo {
|
|
|
4565
4670
|
}
|
|
4566
4671
|
if (t.key === "Escape") {
|
|
4567
4672
|
if (t.preventDefault(), this.cancelEdit(e), this.onMove(), this.activeCell && this.activeCell.colKey !== null) {
|
|
4568
|
-
const r = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey),
|
|
4569
|
-
this.focusSelectionInput(
|
|
4673
|
+
const r = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey), h = this.cellToClipboardString(r);
|
|
4674
|
+
this.focusSelectionInput(h);
|
|
4570
4675
|
}
|
|
4571
4676
|
} else t.key === "Backspace" && this.inputEl.value === "" && (t.preventDefault(), this.commitEdit(o, n, ""), this.onMove(o), this.teardownInput(!1), this.moveActiveCell(0, 0));
|
|
4572
4677
|
}
|
|
@@ -4610,33 +4715,33 @@ class Vo {
|
|
|
4610
4715
|
this.teardownInput(!1), t.blur();
|
|
4611
4716
|
return;
|
|
4612
4717
|
}
|
|
4613
|
-
const { rowId: i, colKey: o } = e, n = this.activeOriginalValue && this.activeOriginalValue.rowId === i && this.activeOriginalValue.colKey === o ? this.activeOriginalValue.value : this.dataModel.getCell(i, o), s = this.dataModel.getCell(i, o), l = (
|
|
4718
|
+
const { rowId: i, colKey: o } = e, n = this.activeOriginalValue && this.activeOriginalValue.rowId === i && this.activeOriginalValue.colKey === o ? this.activeOriginalValue.value : this.dataModel.getCell(i, o), s = this.dataModel.getCell(i, o), l = (h) => h ?? "", a = l(n), r = l(s);
|
|
4614
4719
|
if (!Object.is(r, a)) {
|
|
4615
|
-
const
|
|
4720
|
+
const h = {
|
|
4616
4721
|
kind: "edit",
|
|
4617
4722
|
rowId: i,
|
|
4618
4723
|
colKey: o,
|
|
4619
4724
|
next: a,
|
|
4620
4725
|
prev: r
|
|
4621
4726
|
};
|
|
4622
|
-
this.onEdit(
|
|
4727
|
+
this.onEdit(h, !0);
|
|
4623
4728
|
}
|
|
4624
4729
|
this.teardownInput(!1), t.blur();
|
|
4625
4730
|
}
|
|
4626
4731
|
teardownInput(t = !1) {
|
|
4627
|
-
this.teardownLookupEditor(), this.inputEl && this.inputEl !== this.selectionInput &&
|
|
4732
|
+
this.teardownLookupEditor(), this.inputEl && this.inputEl !== this.selectionInput && O(this.inputEl), O(this.floatingInputWrapper), this.activeHost && this.activeHostOriginalText !== null && (this.activeHost.textContent = this.activeHostOriginalText), this.inputEl = null, this.floatingInputWrapper = null, this.activeHost = null, this.activeHostOriginalText = null, this.activeOriginalValue = null, this.composing = !1, t && (this.activeCell = null, this.onActiveChange(null, null), this.hideHoverTooltip());
|
|
4628
4733
|
}
|
|
4629
4734
|
}
|
|
4630
|
-
const
|
|
4631
|
-
class
|
|
4735
|
+
const qo = (c) => c;
|
|
4736
|
+
class $o {
|
|
4632
4737
|
constructor(t) {
|
|
4633
4738
|
this.shell = null, this.viewportEl = null, this.viewportResizeObserver = null, this.selectionManager = null, this.resizeHandler = null, this.scrollHandler = null, this.viewportState = null, this.rafId = null, this.contextMenu = null, this.contextMenuRowId = null, this.handleGlobalPointer = null, this.toast = null, this.toastTimer = null, this.mounted = !1, this.filterSortSidebar = null, this.filterSortSidebarUnsub = null, this.filterSortKeydown = null, this.filterSortClickCapture = null, this.filterSortOpenEvent = null, this.filterSortActiveColumnKey = null, this.filterSortDraft = null, this.tableStateListeners = /* @__PURE__ */ new Set(), this.selectionListeners = /* @__PURE__ */ new Set(), this.lastTableState = null, this.lastSelectionSnapshot = null, this.lastAction = null, this.selectionRanges = [], this.activeCell = null, this.activeErrors = [], this.rowStateListeners = /* @__PURE__ */ new Set(), this.lastRowStates = /* @__PURE__ */ new Map(), this.root = t.root, this.root.classList.add("extable-root"), this.renderMode = t.options?.renderMode ?? "auto", this.editMode = t.options?.editMode ?? "direct", this.lockMode = t.options?.lockMode ?? "none", this.server = t.options?.server, this.user = t.options?.user, this.sequenceLangs = t.options?.langs;
|
|
4634
4739
|
const e = t.defaultData ?? null, i = e ?? [];
|
|
4635
|
-
this.dataLoaded = e != null, this.dataModel = new
|
|
4740
|
+
this.dataLoaded = e != null, this.dataModel = new qe(
|
|
4636
4741
|
i,
|
|
4637
4742
|
t.schema,
|
|
4638
4743
|
t.defaultView
|
|
4639
|
-
), this.commandQueue = new
|
|
4744
|
+
), this.commandQueue = new Xe(), this.lockManager = new Ye(this.lockMode, this.server, this.user), this.renderer = this.chooseRenderer(this.renderMode), this.applyRootDecor(t.options), this.applyReadonlyClass(), this.loadInitial();
|
|
4640
4745
|
}
|
|
4641
4746
|
isCellReadonly(t, e) {
|
|
4642
4747
|
return this.editMode === "readonly" || this.dataModel.isReadonly(t, e);
|
|
@@ -4669,7 +4774,7 @@ class No {
|
|
|
4669
4774
|
this.mount();
|
|
4670
4775
|
}
|
|
4671
4776
|
applyRootDecor(t) {
|
|
4672
|
-
const e =
|
|
4777
|
+
const e = re(t?.defaultClass);
|
|
4673
4778
|
if (e?.length && this.root.classList.add(...e), t?.defaultStyle)
|
|
4674
4779
|
for (const [i, o] of Object.entries(t.defaultStyle))
|
|
4675
4780
|
this.root.style[i] = o ?? "";
|
|
@@ -4707,7 +4812,7 @@ class No {
|
|
|
4707
4812
|
this.root.dataset.extable = "loading", this.bindViewport(), this.ensureFilterSort(), this.emitTableState(), this.emitSelection("data");
|
|
4708
4813
|
return;
|
|
4709
4814
|
}
|
|
4710
|
-
this.selectionManager = new
|
|
4815
|
+
this.selectionManager = new Bo(
|
|
4711
4816
|
e,
|
|
4712
4817
|
this.editMode,
|
|
4713
4818
|
(i, o) => this.handleEdit(i, o),
|
|
@@ -4723,6 +4828,7 @@ class No {
|
|
|
4723
4828
|
this.sequenceLangs,
|
|
4724
4829
|
(i, o) => this.isCellReadonly(i, o),
|
|
4725
4830
|
(i) => this.emitAction(i),
|
|
4831
|
+
(i) => this.setView(i),
|
|
4726
4832
|
(i, o) => {
|
|
4727
4833
|
const n = i && o !== null ? { rowId: i, colKey: o } : null;
|
|
4728
4834
|
n && this.renderer.setActiveCell(n.rowId, n.colKey), this.activeCell = n, this.emitSelection("selection");
|
|
@@ -4740,7 +4846,7 @@ class No {
|
|
|
4740
4846
|
}
|
|
4741
4847
|
// editMode/lockMode are configured only at construction time for consistency.
|
|
4742
4848
|
setRootClass(t) {
|
|
4743
|
-
this.root.className = "", this.root.classList.add(...
|
|
4849
|
+
this.root.className = "", this.root.classList.add(...re(t) ?? []);
|
|
4744
4850
|
}
|
|
4745
4851
|
setRootStyle(t) {
|
|
4746
4852
|
for (const [e, i] of Object.entries(t))
|
|
@@ -4855,9 +4961,9 @@ class No {
|
|
|
4855
4961
|
if (s.textOverride) return s.textOverride;
|
|
4856
4962
|
const l = s.value;
|
|
4857
4963
|
if (n.type === "button")
|
|
4858
|
-
return at(l) || (l == null ? "" : String(l));
|
|
4859
|
-
if (n.type === "link")
|
|
4860
4964
|
return ct(l) || (l == null ? "" : String(l));
|
|
4965
|
+
if (n.type === "link")
|
|
4966
|
+
return ht(l) || (l == null ? "" : String(l));
|
|
4861
4967
|
if (l == null) return "";
|
|
4862
4968
|
if (l instanceof Date) return l.toISOString();
|
|
4863
4969
|
if (typeof l == "string") return l;
|
|
@@ -4866,7 +4972,7 @@ class No {
|
|
|
4866
4972
|
const a = l;
|
|
4867
4973
|
if (a.kind === "enum" && typeof a.value == "string") return a.value;
|
|
4868
4974
|
if (a.kind === "tags" && Array.isArray(a.values))
|
|
4869
|
-
return a.values.filter((
|
|
4975
|
+
return a.values.filter((h) => typeof h == "string").join(", ");
|
|
4870
4976
|
}
|
|
4871
4977
|
return String(l);
|
|
4872
4978
|
}
|
|
@@ -5087,8 +5193,8 @@ class No {
|
|
|
5087
5193
|
for (const r of Array.from(
|
|
5088
5194
|
this.contextMenu.querySelectorAll("button[data-action]")
|
|
5089
5195
|
)) {
|
|
5090
|
-
const
|
|
5091
|
-
|
|
5196
|
+
const h = r.dataset.action;
|
|
5197
|
+
h === "undo" ? r.disabled = !this.commandQueue.canUndo() : h === "redo" && (r.disabled = !this.commandQueue.canRedo());
|
|
5092
5198
|
}
|
|
5093
5199
|
const o = window.innerWidth, n = window.innerHeight, s = { width: 220, height: 160 };
|
|
5094
5200
|
let l = e, a = i;
|
|
@@ -5161,7 +5267,7 @@ class No {
|
|
|
5161
5267
|
}, document.addEventListener("pointerdown", this.handleGlobalPointer, !0);
|
|
5162
5268
|
}
|
|
5163
5269
|
unbindViewport() {
|
|
5164
|
-
this.resizeHandler && window.removeEventListener("resize", this.resizeHandler), this.scrollHandler && this.getScrollHost().removeEventListener("scroll", this.scrollHandler), this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.handleGlobalPointer && (document.removeEventListener("pointerdown", this.handleGlobalPointer, !0), this.handleGlobalPointer = null), this.contextMenu && (this.contextMenu.hidePopover?.(), this.contextMenu.parentElement &&
|
|
5270
|
+
this.resizeHandler && window.removeEventListener("resize", this.resizeHandler), this.scrollHandler && this.getScrollHost().removeEventListener("scroll", this.scrollHandler), this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.handleGlobalPointer && (document.removeEventListener("pointerdown", this.handleGlobalPointer, !0), this.handleGlobalPointer = null), this.contextMenu && (this.contextMenu.hidePopover?.(), this.contextMenu.parentElement && O(this.contextMenu), this.contextMenu = null), this.toast && (this.toast.hidePopover?.(), this.toast.parentElement && O(this.toast), this.toast = null);
|
|
5165
5271
|
}
|
|
5166
5272
|
remount(t) {
|
|
5167
5273
|
this.unbindViewport(), this.teardownFilterSort(), this.selectionManager?.destroy(), this.renderer.destroy(), this.root = t, this.applyReadonlyClass(), this.shell = null, this.viewportEl = null, this.viewportResizeObserver?.disconnect(), this.viewportResizeObserver = null, this.renderer = this.chooseRenderer(this.renderMode), this.mounted = !1, this.mount(!0);
|
|
@@ -5170,8 +5276,8 @@ class No {
|
|
|
5170
5276
|
getTableState() {
|
|
5171
5277
|
const t = this.renderer instanceof St ? "html" : "canvas", e = this.commandQueue.listApplied(), i = this.editMode === "commit" ? e : [], o = i.length, n = (() => {
|
|
5172
5278
|
const r = /* @__PURE__ */ new Set();
|
|
5173
|
-
for (const
|
|
5174
|
-
|
|
5279
|
+
for (const h of i)
|
|
5280
|
+
h.kind === "edit" && (!h.rowId || h.colKey === void 0 || r.add(`${h.rowId}::${String(h.colKey)}`));
|
|
5175
5281
|
return r.size;
|
|
5176
5282
|
})(), s = this.dataModel.getValidationErrors().map((r) => ({
|
|
5177
5283
|
scope: "validation",
|
|
@@ -5182,11 +5288,11 @@ class No {
|
|
|
5182
5288
|
message: r.diag.message,
|
|
5183
5289
|
target: { rowId: r.rowId, colKey: r.colKey }
|
|
5184
5290
|
} : null).filter(Boolean);
|
|
5185
|
-
l.sort((r,
|
|
5186
|
-
const
|
|
5187
|
-
if (
|
|
5188
|
-
const p = r.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(r.target.colKey) : -1,
|
|
5189
|
-
return p !==
|
|
5291
|
+
l.sort((r, h) => {
|
|
5292
|
+
const d = r.target?.rowId ? this.dataModel.getRowIndex(r.target.rowId) : -1, u = h.target?.rowId ? this.dataModel.getRowIndex(h.target.rowId) : -1;
|
|
5293
|
+
if (d !== u) return d - u;
|
|
5294
|
+
const p = r.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(r.target.colKey) : -1, m = h.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(h.target.colKey) : -1;
|
|
5295
|
+
return p !== m ? p - m : r.scope !== h.scope ? r.scope < h.scope ? -1 : 1 : r.message < h.message ? -1 : r.message > h.message ? 1 : 0;
|
|
5190
5296
|
});
|
|
5191
5297
|
const a = [
|
|
5192
5298
|
...s,
|
|
@@ -5224,33 +5330,33 @@ class No {
|
|
|
5224
5330
|
}
|
|
5225
5331
|
// Public API: selection callbacks
|
|
5226
5332
|
getSelectionSnapshot() {
|
|
5227
|
-
const t = this.selectionRanges, e = this.dataModel.getSchema(), i = this.activeCell, o = i?.rowId ?? null, n = i?.colKey ?? null, s = o ? this.dataModel.getRowIndex(o) : null, l = n !== null ? e.columns.findIndex((
|
|
5228
|
-
if (
|
|
5229
|
-
const
|
|
5333
|
+
const t = this.selectionRanges, e = this.dataModel.getSchema(), i = this.activeCell, o = i?.rowId ?? null, n = i?.colKey ?? null, s = o ? this.dataModel.getRowIndex(o) : null, l = n !== null ? e.columns.findIndex((w) => String(w.key) === String(n)) : null, a = l !== null && l >= 0 ? e.columns[l] : null, r = o && a ? this.dataModel.resolveCellValue(o, a) : null, h = o && a ? this.dataModel.resolveConditionalStyle(o, a) : null, d = r?.textOverride ?? (h?.forceErrorText ? "#ERROR" : void 0), u = r ? r.value : null, p = (() => {
|
|
5334
|
+
if (d) return d;
|
|
5335
|
+
const w = u;
|
|
5230
5336
|
if (a?.type === "button")
|
|
5231
|
-
return
|
|
5337
|
+
return ct(w) || (w == null ? "" : String(w));
|
|
5232
5338
|
if (a?.type === "link")
|
|
5233
|
-
return
|
|
5234
|
-
if (
|
|
5235
|
-
if (
|
|
5236
|
-
if (typeof
|
|
5237
|
-
if (typeof
|
|
5238
|
-
if (typeof
|
|
5239
|
-
const
|
|
5240
|
-
if (
|
|
5241
|
-
if (
|
|
5242
|
-
return
|
|
5339
|
+
return ht(w) || (w == null ? "" : String(w));
|
|
5340
|
+
if (w == null) return "";
|
|
5341
|
+
if (w instanceof Date) return w.toISOString();
|
|
5342
|
+
if (typeof w == "string") return w;
|
|
5343
|
+
if (typeof w == "number" || typeof w == "boolean") return String(w);
|
|
5344
|
+
if (typeof w == "object") {
|
|
5345
|
+
const f = w, y = f.kind;
|
|
5346
|
+
if (y === "enum" && typeof f.value == "string") return f.value;
|
|
5347
|
+
if (y === "tags" && Array.isArray(f.values))
|
|
5348
|
+
return f.values.filter((g) => typeof g == "string").join(", ");
|
|
5243
5349
|
}
|
|
5244
|
-
return String(
|
|
5245
|
-
})(),
|
|
5350
|
+
return String(w);
|
|
5351
|
+
})(), m = a?.type ?? null, b = o && n !== null ? this.dataModel.getCellDiagnostic(o, n) : null, x = (() => {
|
|
5246
5352
|
if (!o || !a)
|
|
5247
5353
|
return { columnStyle: {}, cellStyle: {}, resolved: {} };
|
|
5248
|
-
const { columnStyle:
|
|
5354
|
+
const { columnStyle: w, cellStyle: f, resolved: y } = ze(
|
|
5249
5355
|
this.dataModel,
|
|
5250
5356
|
o,
|
|
5251
5357
|
a
|
|
5252
5358
|
);
|
|
5253
|
-
return { columnStyle:
|
|
5359
|
+
return { columnStyle: w, cellStyle: f, resolved: y };
|
|
5254
5360
|
})();
|
|
5255
5361
|
return {
|
|
5256
5362
|
ranges: [...t],
|
|
@@ -5260,10 +5366,10 @@ class No {
|
|
|
5260
5366
|
activeColumnKey: n,
|
|
5261
5367
|
activeValueRaw: u,
|
|
5262
5368
|
activeValueDisplay: p,
|
|
5263
|
-
activeValueType:
|
|
5264
|
-
diagnostic:
|
|
5369
|
+
activeValueType: m,
|
|
5370
|
+
diagnostic: b,
|
|
5265
5371
|
action: this.lastAction,
|
|
5266
|
-
styles:
|
|
5372
|
+
styles: x
|
|
5267
5373
|
};
|
|
5268
5374
|
}
|
|
5269
5375
|
subscribeSelection(t) {
|
|
@@ -5315,7 +5421,7 @@ class No {
|
|
|
5315
5421
|
}
|
|
5316
5422
|
// Public API: value updates
|
|
5317
5423
|
setCellValue(t, e, i) {
|
|
5318
|
-
const o = typeof t == "string" ? t : this.dataModel.listRows()[t]?.id, n = o ?
|
|
5424
|
+
const o = typeof t == "string" ? t : this.dataModel.listRows()[t]?.id, n = o ? Ge(this.dataModel, { rowId: o, colKey: e }) : null;
|
|
5319
5425
|
if (!n || this.isCellReadonly(n.rowId, n.colKey)) return;
|
|
5320
5426
|
const s = this.dataModel.getCell(n.rowId, n.colKey), l = typeof i == "function" ? i(s) : i;
|
|
5321
5427
|
this.handleEdit(
|
|
@@ -5328,17 +5434,17 @@ class No {
|
|
|
5328
5434
|
for (const n of this.selectionRanges) {
|
|
5329
5435
|
if (n.kind !== "cells") continue;
|
|
5330
5436
|
const s = Math.min(n.startRow, n.endRow), l = Math.max(n.startRow, n.endRow), a = Math.min(n.startCol, n.endCol), r = Math.max(n.startCol, n.endCol);
|
|
5331
|
-
for (let
|
|
5332
|
-
const
|
|
5333
|
-
if (
|
|
5437
|
+
for (let h = s; h <= l; h += 1) {
|
|
5438
|
+
const d = i[h];
|
|
5439
|
+
if (d)
|
|
5334
5440
|
for (let u = a; u <= r; u += 1) {
|
|
5335
5441
|
const p = e.columns[u];
|
|
5336
5442
|
if (!p) continue;
|
|
5337
|
-
const
|
|
5338
|
-
if (o.has(
|
|
5339
|
-
const
|
|
5443
|
+
const m = `${d.id}::${String(p.key)}`;
|
|
5444
|
+
if (o.has(m) || (o.add(m), this.isCellReadonly(d.id, p.key))) continue;
|
|
5445
|
+
const b = this.dataModel.getCell(d.id, p.key), x = typeof t == "function" ? t(b) : t;
|
|
5340
5446
|
this.handleEdit(
|
|
5341
|
-
{ kind: "edit", rowId:
|
|
5447
|
+
{ kind: "edit", rowId: d.id, colKey: p.key, next: x },
|
|
5342
5448
|
this.editMode === "direct"
|
|
5343
5449
|
);
|
|
5344
5450
|
}
|
|
@@ -5427,17 +5533,17 @@ class No {
|
|
|
5427
5533
|
`, t.appendChild(e), this.filterSortSidebar = e;
|
|
5428
5534
|
const i = e.querySelector('button[data-extable-fs="close"]'), o = e.querySelector('input[data-extable-fs="col-errors"]'), n = e.querySelector(
|
|
5429
5535
|
'input[data-extable-fs="col-warnings"]'
|
|
5430
|
-
), s = e.querySelector('input[data-extable-fs="search"]'), l = e.querySelector('[data-extable-fs="values"]'), a = e.querySelector('button[data-extable-fs="select-all"]'), r = e.querySelector('button[data-extable-fs="select-none"]'),
|
|
5536
|
+
), s = e.querySelector('input[data-extable-fs="search"]'), l = e.querySelector('[data-extable-fs="values"]'), a = e.querySelector('button[data-extable-fs="select-all"]'), r = e.querySelector('button[data-extable-fs="select-none"]'), h = e.querySelector(
|
|
5431
5537
|
'button[data-extable-fs="apply-filter"]'
|
|
5432
|
-
),
|
|
5538
|
+
), d = e.querySelector(
|
|
5433
5539
|
'button[data-extable-fs="clear-filter"]'
|
|
5434
5540
|
), u = e.querySelector('button[data-extable-fs="sort-asc"]'), p = e.querySelector(
|
|
5435
5541
|
'button[data-extable-fs="sort-desc"]'
|
|
5436
|
-
),
|
|
5542
|
+
), m = e.querySelector(
|
|
5437
5543
|
'button[data-extable-fs="clear-sort"]'
|
|
5438
5544
|
);
|
|
5439
|
-
if (!i || !o || !n || !s || !l || !a || !r || !
|
|
5440
|
-
|
|
5545
|
+
if (!i || !o || !n || !s || !l || !a || !r || !h || !d || !u || !p || !m) {
|
|
5546
|
+
O(e), this.filterSortSidebar = null;
|
|
5441
5547
|
return;
|
|
5442
5548
|
}
|
|
5443
5549
|
i.addEventListener("click", () => this.hideFilterSortPanel()), o.addEventListener("change", () => {
|
|
@@ -5446,18 +5552,18 @@ class No {
|
|
|
5446
5552
|
this.filterSortDraft && (this.filterSortDraft.diagWarnings = n.checked);
|
|
5447
5553
|
}), s.addEventListener("input", () => {
|
|
5448
5554
|
this.filterSortDraft && (this.filterSortDraft.search = s.value, this.renderFilterSortValues());
|
|
5449
|
-
}), l.addEventListener("change", (
|
|
5450
|
-
const
|
|
5555
|
+
}), l.addEventListener("change", (b) => {
|
|
5556
|
+
const x = b.target?.closest(
|
|
5451
5557
|
'input[type="checkbox"][data-fs-val]'
|
|
5452
5558
|
);
|
|
5453
|
-
if (!
|
|
5454
|
-
const
|
|
5455
|
-
|
|
5559
|
+
if (!x || !this.filterSortDraft) return;
|
|
5560
|
+
const w = x.dataset.fsVal ?? "";
|
|
5561
|
+
w && (w === "__blanks__" ? this.filterSortDraft.includeBlanks = x.checked : x.checked ? this.filterSortDraft.selected.add(w) : this.filterSortDraft.selected.delete(w));
|
|
5456
5562
|
}), a.addEventListener("click", () => {
|
|
5457
|
-
this.filterSortDraft && (this.filterSortDraft.selected = new Set(this.filterSortDraft.values.map((
|
|
5563
|
+
this.filterSortDraft && (this.filterSortDraft.selected = new Set(this.filterSortDraft.values.map((b) => b.key)), this.filterSortDraft.includeBlanks = this.filterSortDraft.hasBlanks, this.renderFilterSortValues());
|
|
5458
5564
|
}), r.addEventListener("click", () => {
|
|
5459
5565
|
this.filterSortDraft && (this.filterSortDraft.selected = /* @__PURE__ */ new Set(), this.filterSortDraft.includeBlanks = !1, this.renderFilterSortValues());
|
|
5460
|
-
}),
|
|
5566
|
+
}), h.addEventListener("click", () => this.applyFilterSortDraft()), d.addEventListener("click", () => this.clearFilterSortForActiveColumn()), u.addEventListener("click", () => this.setSortForActiveColumn("asc")), p.addEventListener("click", () => this.setSortForActiveColumn("desc")), m.addEventListener("click", () => this.clearSort()), this.filterSortSidebarUnsub = this.dataModel.subscribe(() => {
|
|
5461
5567
|
this.isFilterSortPanelVisible() && this.filterSortActiveColumnKey && (this.buildFilterSortDraft(this.filterSortActiveColumnKey), this.renderFilterSortSidebar());
|
|
5462
5568
|
});
|
|
5463
5569
|
}
|
|
@@ -5483,15 +5589,15 @@ class No {
|
|
|
5483
5589
|
for (const u of a.values ?? []) r.add(this.stableValueKey(u));
|
|
5484
5590
|
else
|
|
5485
5591
|
for (const u of l) r.add(u.key);
|
|
5486
|
-
const
|
|
5592
|
+
const h = a ? !!a.includeBlanks : s.hasBlanks, d = e.columnDiagnostics?.[String(o.key)];
|
|
5487
5593
|
this.filterSortDraft = {
|
|
5488
5594
|
colKey: o.key,
|
|
5489
5595
|
values: l,
|
|
5490
5596
|
hasBlanks: s.hasBlanks,
|
|
5491
5597
|
selected: r,
|
|
5492
|
-
includeBlanks:
|
|
5493
|
-
diagErrors: !!
|
|
5494
|
-
diagWarnings: !!
|
|
5598
|
+
includeBlanks: h,
|
|
5599
|
+
diagErrors: !!d?.errors,
|
|
5600
|
+
diagWarnings: !!d?.warnings,
|
|
5495
5601
|
search: n
|
|
5496
5602
|
};
|
|
5497
5603
|
}
|
|
@@ -5514,8 +5620,8 @@ class No {
|
|
|
5514
5620
|
t.textContent = "Sort/Filter", e.checked = !1, i.checked = !1, o.value = "", n && (n.dataset.active = "0"), s && (s.dataset.active = "0"), this.renderFilterSortValues();
|
|
5515
5621
|
return;
|
|
5516
5622
|
}
|
|
5517
|
-
const
|
|
5518
|
-
t.textContent = `Sort/Filter: ${
|
|
5623
|
+
const h = this.dataModel.getSchema().columns.find((p) => String(p.key) === String(l.colKey))?.header ?? String(l.colKey);
|
|
5624
|
+
t.textContent = `Sort/Filter: ${h}`, e.checked = l.diagErrors, i.checked = l.diagWarnings, o.value = l.search;
|
|
5519
5625
|
const u = this.dataModel.getView().sorts?.find((p) => String(p.key) === String(l.colKey));
|
|
5520
5626
|
n && (n.dataset.active = u?.dir === "asc" ? "1" : "0"), s && (s.dataset.active = u?.dir === "desc" ? "1" : "0"), this.renderFilterSortValues();
|
|
5521
5627
|
}
|
|
@@ -5598,7 +5704,7 @@ class No {
|
|
|
5598
5704
|
this.setView(e), this.filterSortActiveColumnKey !== null && (this.buildFilterSortDraft(this.filterSortActiveColumnKey), this.renderFilterSortSidebar());
|
|
5599
5705
|
}
|
|
5600
5706
|
teardownFilterSort() {
|
|
5601
|
-
this.filterSortSidebarUnsub?.(), this.filterSortSidebarUnsub = null, this.filterSortSidebar && (
|
|
5707
|
+
this.filterSortSidebarUnsub?.(), this.filterSortSidebarUnsub = null, this.filterSortSidebar && (O(this.filterSortSidebar), this.filterSortSidebar = null), this.filterSortKeydown && (document.removeEventListener("keydown", this.filterSortKeydown, !0), this.filterSortKeydown = null), this.filterSortClickCapture && ((this.viewportEl ?? this.root).removeEventListener(
|
|
5602
5708
|
"click",
|
|
5603
5709
|
this.filterSortClickCapture,
|
|
5604
5710
|
!0
|
|
@@ -5640,8 +5746,8 @@ class No {
|
|
|
5640
5746
|
this.rafId = null, this.viewportState && (this.selectionManager?.onScroll(this.viewportState.scrollTop, this.viewportState.scrollLeft), !(this.renderer instanceof St) && this.safeRender(this.viewportState));
|
|
5641
5747
|
}
|
|
5642
5748
|
}
|
|
5643
|
-
function
|
|
5644
|
-
return new
|
|
5749
|
+
function zo(c, t) {
|
|
5750
|
+
return new $o({
|
|
5645
5751
|
root: document.createElement("div"),
|
|
5646
5752
|
defaultData: c.data,
|
|
5647
5753
|
defaultView: c.view,
|
|
@@ -5649,13 +5755,13 @@ function Wo(c, t) {
|
|
|
5649
5755
|
options: t
|
|
5650
5756
|
});
|
|
5651
5757
|
}
|
|
5652
|
-
function
|
|
5758
|
+
function Uo(c, t) {
|
|
5653
5759
|
return t.remount(c), t;
|
|
5654
5760
|
}
|
|
5655
5761
|
export {
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5762
|
+
$o as ExtableCore,
|
|
5763
|
+
zo as createTablePlaceholder,
|
|
5764
|
+
qo as defineSchema,
|
|
5765
|
+
Uo as mountTable
|
|
5660
5766
|
};
|
|
5661
5767
|
//# sourceMappingURL=index.js.map
|