@extable/core 0.3.0 → 0.3.2
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/index.css +1 -1
- package/dist/index.js +1129 -871
- package/dist/index.js.map +1 -1
- package/dist/renderers.d.ts +14 -0
- package/dist/selectionManager.d.ts +10 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Pe(r) {
|
|
2
2
|
const t = r.payload;
|
|
3
3
|
if (!t) return null;
|
|
4
4
|
const e = t.batchId;
|
|
5
5
|
return typeof e == "string" && e.length ? e : null;
|
|
6
6
|
}
|
|
7
|
-
class
|
|
7
|
+
class $e {
|
|
8
8
|
constructor(t = 100) {
|
|
9
9
|
this.applied = [], this.undone = [], this.cap = t;
|
|
10
10
|
}
|
|
11
11
|
enqueue(t) {
|
|
12
|
-
const e =
|
|
12
|
+
const e = Pe(t), i = this.applied.at(-1);
|
|
13
13
|
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();
|
|
14
14
|
this.undone = [];
|
|
15
15
|
}
|
|
@@ -42,37 +42,37 @@ class He {
|
|
|
42
42
|
this.applied = [], this.undone = [];
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function ee() {
|
|
46
46
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `row_${Math.random().toString(16).slice(2)}`;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function ie(r) {
|
|
49
49
|
if (r !== void 0)
|
|
50
50
|
return Array.isArray(r) ? r : [r];
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function j(r) {
|
|
53
53
|
if (r)
|
|
54
54
|
try {
|
|
55
55
|
r.remove();
|
|
56
56
|
} catch {
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
yyyy: (r) =>
|
|
61
|
-
MM: (r) =>
|
|
62
|
-
dd: (r) =>
|
|
63
|
-
HH: (r) =>
|
|
59
|
+
const tt = (r, t = 2) => r.toString().padStart(t, "0"), ce = {
|
|
60
|
+
yyyy: (r) => tt(r.getFullYear(), 4),
|
|
61
|
+
MM: (r) => tt(r.getMonth() + 1),
|
|
62
|
+
dd: (r) => tt(r.getDate()),
|
|
63
|
+
HH: (r) => tt(r.getHours()),
|
|
64
64
|
hh: (r) => {
|
|
65
65
|
const t = r.getHours() % 12 || 12;
|
|
66
|
-
return
|
|
66
|
+
return tt(t);
|
|
67
67
|
},
|
|
68
|
-
mm: (r) =>
|
|
69
|
-
ss: (r) =>
|
|
68
|
+
mm: (r) => tt(r.getMinutes()),
|
|
69
|
+
ss: (r) => tt(r.getSeconds()),
|
|
70
70
|
a: (r) => r.getHours() >= 12 ? "PM" : "AM"
|
|
71
|
-
},
|
|
71
|
+
}, de = Object.keys(ce).sort((r, t) => t.length - r.length), he = /* @__PURE__ */ new Set(["yyyy", "MM", "dd"]), ue = /* @__PURE__ */ new Set(["HH", "hh", "mm", "ss", "a"]), Oe = /* @__PURE__ */ new Set([...he, ...ue]), vt = {
|
|
72
72
|
iso: "yyyy-MM-dd",
|
|
73
73
|
us: "MM/dd/yyyy",
|
|
74
74
|
eu: "dd.MM.yyyy"
|
|
75
|
-
},
|
|
75
|
+
}, Ct = {
|
|
76
76
|
iso: "HH:mm:ss",
|
|
77
77
|
"24h": "HH:mm",
|
|
78
78
|
"12h": "hh:mm a"
|
|
@@ -87,11 +87,11 @@ const Z = (r, t = 2) => r.toString().padStart(t, "0"), ne = {
|
|
|
87
87
|
"eu-24h": "dd.MM.yyyy HH:mm",
|
|
88
88
|
"eu-12h": "dd.MM.yyyy hh:mm a"
|
|
89
89
|
};
|
|
90
|
-
function
|
|
90
|
+
function Pt(r) {
|
|
91
91
|
const t = new Date(r);
|
|
92
92
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function fe(r, t) {
|
|
95
95
|
let e = "", i = 0, n = !1;
|
|
96
96
|
for (; i < t.length; ) {
|
|
97
97
|
const s = t[i];
|
|
@@ -104,19 +104,19 @@ function le(r, t) {
|
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
106
|
let o = !1;
|
|
107
|
-
for (const l of
|
|
107
|
+
for (const l of de)
|
|
108
108
|
if (t.startsWith(l, i)) {
|
|
109
|
-
e +=
|
|
109
|
+
e += ce[l](r), i += l.length, o = !0;
|
|
110
110
|
break;
|
|
111
111
|
}
|
|
112
112
|
o || (e += s, i += 1);
|
|
113
113
|
}
|
|
114
114
|
return e;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
return t === "date" ?
|
|
116
|
+
function je(r, t) {
|
|
117
|
+
return t === "date" ? he.has(r) : t === "time" ? ue.has(r) : Oe.has(r);
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function We(r, t) {
|
|
120
120
|
let e = 0, i = !1;
|
|
121
121
|
for (; e < r.length; ) {
|
|
122
122
|
if (r[e] === "'") {
|
|
@@ -128,9 +128,9 @@ function Le(r, t) {
|
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
130
|
let s = !1;
|
|
131
|
-
for (const o of
|
|
131
|
+
for (const o of de)
|
|
132
132
|
if (r.startsWith(o, e)) {
|
|
133
|
-
if (!
|
|
133
|
+
if (!je(o, t)) return !1;
|
|
134
134
|
e += o.length, s = !0;
|
|
135
135
|
break;
|
|
136
136
|
}
|
|
@@ -138,16 +138,16 @@ function Le(r, t) {
|
|
|
138
138
|
}
|
|
139
139
|
return !0;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function ot(r, t) {
|
|
142
142
|
if (!r)
|
|
143
|
-
return t === "date" ?
|
|
144
|
-
if (t === "date" &&
|
|
145
|
-
if (t === "time" &&
|
|
143
|
+
return t === "date" ? vt.iso : t === "time" ? Ct.iso : St.iso;
|
|
144
|
+
if (t === "date" && vt[r]) return vt[r];
|
|
145
|
+
if (t === "time" && Ct[r]) return Ct[r];
|
|
146
146
|
if (t === "datetime" && St[r]) return St[r];
|
|
147
|
-
const e = t === "date" ?
|
|
148
|
-
return
|
|
147
|
+
const e = t === "date" ? vt.iso : t === "time" ? Ct.iso : St.iso;
|
|
148
|
+
return We(r, t) ? r : e;
|
|
149
149
|
}
|
|
150
|
-
const
|
|
150
|
+
const ne = (r) => !Number.isNaN(r.getTime()), qe = (r) => {
|
|
151
151
|
if (typeof r == "string") return r;
|
|
152
152
|
if (r && typeof r == "object") {
|
|
153
153
|
const t = r;
|
|
@@ -155,7 +155,7 @@ const Jt = (r) => !Number.isNaN(r.getTime()), Ve = (r) => {
|
|
|
155
155
|
return typeof t.value == "string" ? t.value : null;
|
|
156
156
|
}
|
|
157
157
|
return null;
|
|
158
|
-
},
|
|
158
|
+
}, Ue = (r) => {
|
|
159
159
|
if (Array.isArray(r) && r.every((t) => typeof t == "string")) return r;
|
|
160
160
|
if (r && typeof r == "object") {
|
|
161
161
|
const t = r;
|
|
@@ -166,7 +166,7 @@ const Jt = (r) => !Number.isNaN(r.getTime()), Ve = (r) => {
|
|
|
166
166
|
}
|
|
167
167
|
return null;
|
|
168
168
|
};
|
|
169
|
-
function
|
|
169
|
+
function Xe(r, t) {
|
|
170
170
|
if (r == null) return null;
|
|
171
171
|
switch (t.type) {
|
|
172
172
|
case "string": {
|
|
@@ -186,13 +186,13 @@ function _e(r, t) {
|
|
|
186
186
|
case "boolean":
|
|
187
187
|
return typeof r != "boolean" ? "Expected a boolean" : null;
|
|
188
188
|
case "enum": {
|
|
189
|
-
const e =
|
|
189
|
+
const e = qe(r);
|
|
190
190
|
if (!e) return "Expected an enum value";
|
|
191
191
|
const i = t.enum?.allowCustom ?? !1, n = t.enum?.options ?? [];
|
|
192
192
|
return !i && n.length && !n.includes(e) ? "Not in allowed options" : null;
|
|
193
193
|
}
|
|
194
194
|
case "tags": {
|
|
195
|
-
const e =
|
|
195
|
+
const e = Ue(r);
|
|
196
196
|
if (!e) return "Expected a list of tags";
|
|
197
197
|
const i = t.tags?.allowCustom ?? !1, n = t.tags?.options ?? [];
|
|
198
198
|
if (!i && n.length) {
|
|
@@ -205,10 +205,10 @@ function _e(r, t) {
|
|
|
205
205
|
case "time":
|
|
206
206
|
case "datetime": {
|
|
207
207
|
const e = t.format;
|
|
208
|
-
if (t.type === "date" ?
|
|
208
|
+
if (t.type === "date" ? ot(e, "date") : t.type === "time" ? ot(e, "time") : ot(e, "datetime"), r instanceof Date) return ne(r) ? null : "Invalid date";
|
|
209
209
|
if (typeof r == "string") {
|
|
210
|
-
const i =
|
|
211
|
-
return i &&
|
|
210
|
+
const i = Pt(r);
|
|
211
|
+
return i && ne(i) ? null : "Invalid date/time";
|
|
212
212
|
}
|
|
213
213
|
return "Expected a date/time string";
|
|
214
214
|
}
|
|
@@ -216,7 +216,7 @@ function _e(r, t) {
|
|
|
216
216
|
return null;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
class
|
|
219
|
+
class ze {
|
|
220
220
|
constructor(t, e, i) {
|
|
221
221
|
this.rows = [], this.baseIndexById = /* @__PURE__ */ new Map(), this.dataVersion = 0, this.visibleRowsCache = null, this.distinctValueCache = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.rowVersion = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Set(), this.cellStyles = /* @__PURE__ */ new Map(), this.cellConditionalStyles = /* @__PURE__ */ new Map(), this.computedCache = /* @__PURE__ */ new Map(), this.conditionalCache = /* @__PURE__ */ new Map(), this.rowConditionalCache = /* @__PURE__ */ new Map(), this.formulaDiagnostics = /* @__PURE__ */ new Map(), this.conditionalDiagnostics = /* @__PURE__ */ new Map(), this.baseValidationErrors = /* @__PURE__ */ new Map(), this.uniqueValidationErrors = /* @__PURE__ */ new Map(), this.notifySuspended = !1, this.notifyDirty = !1, this.schema = e, this.view = i, this.setData(t ?? []);
|
|
222
222
|
}
|
|
@@ -240,7 +240,7 @@ class Ne {
|
|
|
240
240
|
}
|
|
241
241
|
setData(t) {
|
|
242
242
|
this.dataVersion += 1, this.pending.clear(), this.cellStyles.clear(), this.cellConditionalStyles.clear(), this.computedCache.clear(), this.conditionalCache.clear(), this.rowConditionalCache.clear(), this.formulaDiagnostics.clear(), this.conditionalDiagnostics.clear(), this.baseValidationErrors.clear(), this.uniqueValidationErrors.clear(), this.rows = (t ?? []).map((e, i) => {
|
|
243
|
-
const n =
|
|
243
|
+
const n = ee();
|
|
244
244
|
return this.rowVersion.set(n, 0), {
|
|
245
245
|
id: n,
|
|
246
246
|
raw: e,
|
|
@@ -331,10 +331,10 @@ class Ne {
|
|
|
331
331
|
return this.isActionType(e?.type) ? !0 : !!(e?.readonly || e?.formula);
|
|
332
332
|
}
|
|
333
333
|
getCellInteraction(t, e) {
|
|
334
|
-
const i = this.schema.columns.find((
|
|
334
|
+
const i = this.schema.columns.find((m) => String(m.key) === String(e));
|
|
335
335
|
if (!i) return { readonly: !1, disabled: !1, muted: !1 };
|
|
336
|
-
const n = this.isRowReadonly(t) || this.isColumnReadonly(e), s = this.resolveConditionalStyle(t, i).delta, o = this.getCellStyle(t, e), a = this.supportsConditionalReadonly(i.type) && !!(i.style?.readonly || s?.readonly || o?.readonly), c = this.isActionType(i.type),
|
|
337
|
-
return { readonly:
|
|
336
|
+
const n = this.isRowReadonly(t) || this.isColumnReadonly(e), s = this.resolveConditionalStyle(t, i).delta, o = this.getCellStyle(t, e), a = this.supportsConditionalReadonly(i.type) && !!(i.style?.readonly || s?.readonly || o?.readonly), c = this.isActionType(i.type), h = c && !!(i.style?.disabled || s?.disabled || o?.disabled), d = n || a || h, u = !!i.formula;
|
|
337
|
+
return { readonly: d, disabled: h, muted: h || d && !c && !u };
|
|
338
338
|
}
|
|
339
339
|
isReadonly(t, e) {
|
|
340
340
|
return this.getCellInteraction(t, e).readonly;
|
|
@@ -350,8 +350,8 @@ class Ne {
|
|
|
350
350
|
if (n)
|
|
351
351
|
o.raw[e] = i, this.pending.delete(t), l();
|
|
352
352
|
else {
|
|
353
|
-
const c = this.getRawCell(t, e),
|
|
354
|
-
this.isEqual(c, i) ? delete
|
|
353
|
+
const c = this.getRawCell(t, e), h = this.pending.get(t) ?? {};
|
|
354
|
+
this.isEqual(c, i) ? delete h[e] : h[e] = i, Object.keys(h).length > 0 ? this.pending.set(t, h) : this.pending.delete(t), l();
|
|
355
355
|
}
|
|
356
356
|
this.updateValidationForCell(t, e, this.getCell(t, e)), this.schema.columns.find((c) => c.key === e)?.unique && this.recomputeUniqueValidationForColumn(e), this.clearDiagnosticsForCell(t, e), this.notify();
|
|
357
357
|
}
|
|
@@ -386,7 +386,7 @@ class Ne {
|
|
|
386
386
|
}
|
|
387
387
|
insertRowAt(t, e, i) {
|
|
388
388
|
this.dataVersion += 1;
|
|
389
|
-
const n = i ??
|
|
389
|
+
const n = i ?? ee(), s = Math.max(0, Math.min(e, this.rows.length));
|
|
390
390
|
return this.rows.splice(s, 0, { id: n, raw: t, displayIndex: 0 }), this.reindexRows(), this.rowVersion.set(n, 0), this.rebuildBaseIndex(), this.recomputeValidationErrors(), this.notify(), n;
|
|
391
391
|
}
|
|
392
392
|
removeRow(t) {
|
|
@@ -428,20 +428,20 @@ class Ne {
|
|
|
428
428
|
return String(c) !== String(e);
|
|
429
429
|
}).map((a) => {
|
|
430
430
|
if (a?.kind === "values") {
|
|
431
|
-
const
|
|
431
|
+
const d = a;
|
|
432
432
|
return {
|
|
433
433
|
kind: "values",
|
|
434
|
-
key: String(
|
|
435
|
-
includeBlanks: !!
|
|
436
|
-
values: (
|
|
434
|
+
key: String(d.key),
|
|
435
|
+
includeBlanks: !!d.includeBlanks,
|
|
436
|
+
values: (d.values ?? []).map((u) => this.stableValueKey(u))
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
|
-
const
|
|
439
|
+
const h = a;
|
|
440
440
|
return {
|
|
441
441
|
kind: "op",
|
|
442
|
-
key: String(
|
|
443
|
-
op: String(
|
|
444
|
-
value: this.stableValueKey(
|
|
442
|
+
key: String(h.key),
|
|
443
|
+
op: String(h.op ?? ""),
|
|
444
|
+
value: this.stableValueKey(h.value)
|
|
445
445
|
};
|
|
446
446
|
}).sort((a, c) => a.key === c.key ? a.kind < c.kind ? -1 : 1 : a.key < c.key ? -1 : 1), o = Object.entries(n.columnDiagnostics ?? {}).filter(([a]) => e !== void 0 ? String(a) !== String(e) : !0).map(([a, c]) => ({
|
|
447
447
|
key: String(a),
|
|
@@ -506,14 +506,14 @@ class Ne {
|
|
|
506
506
|
), a = [];
|
|
507
507
|
for (const m of this.rows) {
|
|
508
508
|
let p = !0;
|
|
509
|
-
for (const
|
|
510
|
-
if (
|
|
509
|
+
for (const v of o)
|
|
510
|
+
if (v?.kind === "values" && !this.valuesFilterMatches(m.id, v)) {
|
|
511
511
|
p = !1;
|
|
512
512
|
break;
|
|
513
513
|
}
|
|
514
514
|
if (p) {
|
|
515
|
-
for (const [
|
|
516
|
-
if (!this.rowPassesColumnDiagnostics(m.id,
|
|
515
|
+
for (const [v, f] of l)
|
|
516
|
+
if (!this.rowPassesColumnDiagnostics(m.id, v, f)) {
|
|
517
517
|
p = !1;
|
|
518
518
|
break;
|
|
519
519
|
}
|
|
@@ -523,25 +523,25 @@ class Ne {
|
|
|
523
523
|
if (!i) return a;
|
|
524
524
|
const c = (n.sorts ?? []).slice(0, 1)[0];
|
|
525
525
|
if (!c) return a;
|
|
526
|
-
const
|
|
527
|
-
if (!
|
|
528
|
-
const
|
|
529
|
-
const p = this.getFilterCellValue(m.id,
|
|
530
|
-
return { row: m, v: p, blank:
|
|
526
|
+
const h = s.columns.find((m) => String(m.key) === String(c.key));
|
|
527
|
+
if (!h) return a;
|
|
528
|
+
const d = c.dir === "desc" ? -1 : 1, u = a.map((m) => {
|
|
529
|
+
const p = this.getFilterCellValue(m.id, h.key), v = this.isBlankValue(p), f = this.baseIndexById.get(m.id) ?? 0;
|
|
530
|
+
return { row: m, v: p, blank: v, baseIndex: f };
|
|
531
531
|
}), g = (m, p) => {
|
|
532
532
|
if (m === p) return 0;
|
|
533
533
|
if (m instanceof Date && p instanceof Date) return m.getTime() - p.getTime();
|
|
534
534
|
if (typeof m == "number" && typeof p == "number") return m - p;
|
|
535
535
|
if (typeof m == "boolean" && typeof p == "boolean") return m === p ? 0 : m ? 1 : -1;
|
|
536
|
-
const
|
|
537
|
-
return
|
|
536
|
+
const v = m instanceof Date ? m.toISOString() : typeof m == "string" ? m : String(m), f = p instanceof Date ? p.toISOString() : typeof p == "string" ? p : String(p);
|
|
537
|
+
return v === f ? 0 : v < f ? -1 : 1;
|
|
538
538
|
};
|
|
539
539
|
return u.sort((m, p) => {
|
|
540
540
|
if (m.blank && p.blank) return m.baseIndex - p.baseIndex;
|
|
541
541
|
if (m.blank) return 1;
|
|
542
542
|
if (p.blank) return -1;
|
|
543
|
-
const
|
|
544
|
-
return
|
|
543
|
+
const v = g(m.v, p.v);
|
|
544
|
+
return v !== 0 ? v * d : m.baseIndex - p.baseIndex;
|
|
545
545
|
}), u.map((m) => m.row);
|
|
546
546
|
}
|
|
547
547
|
computeVisibleRows() {
|
|
@@ -558,37 +558,37 @@ class Ne {
|
|
|
558
558
|
getDistinctValuesForColumn(t) {
|
|
559
559
|
const e = `${String(t)}|${this.getFilterSortKey({ excludeColumnKey: t, includeSort: !1 })}`, i = this.distinctValueCache.get(e);
|
|
560
560
|
if (i && i.version === this.dataVersion) return i;
|
|
561
|
-
const n = this.computeRowsAfterFilter({ excludeColumnKey: t, includeSort: !1 }), s = this.getSchema().columns.find((
|
|
561
|
+
const n = this.computeRowsAfterFilter({ excludeColumnKey: t, includeSort: !1 }), s = this.getSchema().columns.find((h) => String(h.key) === String(t));
|
|
562
562
|
if (!s) {
|
|
563
|
-
const
|
|
564
|
-
return this.distinctValueCache.set(e,
|
|
563
|
+
const h = { version: this.dataVersion, values: [], hasBlanks: !1, total: 0 };
|
|
564
|
+
return this.distinctValueCache.set(e, h), h;
|
|
565
565
|
}
|
|
566
566
|
const o = /* @__PURE__ */ new Map();
|
|
567
567
|
let l = !1;
|
|
568
|
-
for (const
|
|
569
|
-
const
|
|
570
|
-
if (this.isBlankValue(
|
|
568
|
+
for (const h of n) {
|
|
569
|
+
const d = this.getFilterCellValue(h.id, s.key);
|
|
570
|
+
if (this.isBlankValue(d)) {
|
|
571
571
|
l = !0;
|
|
572
572
|
continue;
|
|
573
573
|
}
|
|
574
|
-
const u = this.stableValueKey(
|
|
574
|
+
const u = this.stableValueKey(d);
|
|
575
575
|
if (o.has(u)) continue;
|
|
576
576
|
const g = (() => {
|
|
577
|
-
if (
|
|
578
|
-
if (typeof
|
|
579
|
-
if (typeof
|
|
580
|
-
if (typeof
|
|
581
|
-
const m =
|
|
577
|
+
if (d instanceof Date) return d.toISOString();
|
|
578
|
+
if (typeof d == "string") return d;
|
|
579
|
+
if (typeof d == "number" || typeof d == "boolean") return String(d);
|
|
580
|
+
if (typeof d == "object" && d) {
|
|
581
|
+
const m = d, p = m.kind;
|
|
582
582
|
if (p === "enum" && typeof m.value == "string") return m.value;
|
|
583
583
|
if (p === "tags" && Array.isArray(m.values))
|
|
584
|
-
return m.values.filter((
|
|
584
|
+
return m.values.filter((v) => typeof v == "string").join(", ");
|
|
585
585
|
}
|
|
586
|
-
return String(
|
|
586
|
+
return String(d);
|
|
587
587
|
})();
|
|
588
|
-
o.set(u, { value:
|
|
588
|
+
o.set(u, { value: d, label: g });
|
|
589
589
|
}
|
|
590
590
|
const a = [...o.values()].sort(
|
|
591
|
-
(
|
|
591
|
+
(h, d) => h.label < d.label ? -1 : h.label > d.label ? 1 : 0
|
|
592
592
|
), c = {
|
|
593
593
|
version: this.dataVersion,
|
|
594
594
|
values: a,
|
|
@@ -655,8 +655,8 @@ class Ne {
|
|
|
655
655
|
level: "warning",
|
|
656
656
|
message: l[1].message,
|
|
657
657
|
source: "formula"
|
|
658
|
-
},
|
|
659
|
-
return this.computedCache.set(n, { version: i, formulaRef: e.formula, value:
|
|
658
|
+
}, h = l[0];
|
|
659
|
+
return this.computedCache.set(n, { version: i, formulaRef: e.formula, value: h, diagnostic: c }), this.formulaDiagnostics.set(n, c), { value: h, diagnostic: c };
|
|
660
660
|
}
|
|
661
661
|
const a = l;
|
|
662
662
|
return this.computedCache.set(n, { version: i, formulaRef: e.formula, value: a, diagnostic: null }), this.formulaDiagnostics.delete(n), { value: a, diagnostic: null };
|
|
@@ -711,27 +711,27 @@ class Ne {
|
|
|
711
711
|
}
|
|
712
712
|
resolveConditionalStyle(t, e) {
|
|
713
713
|
const i = this.getRowVersion(t), n = this.cellStyleKey(t, e.key), s = this.getRowObjectEffective(t), o = this.resolveRowConditionalStyle(t), l = (u, g) => g ? u ? { ...u, ...g } : { ...g } : u;
|
|
714
|
-
let a = null, c = null,
|
|
715
|
-
if (a = l(a, o.delta), o.diagnostic && (c = o.diagnostic),
|
|
714
|
+
let a = null, c = null, h = !1;
|
|
715
|
+
if (a = l(a, o.delta), o.diagnostic && (c = o.diagnostic), h = h || o.forceErrorText, e.conditionalStyle && s) {
|
|
716
716
|
const u = `${t}::${String(e.key)}::col`, g = this.conditionalCache.get(u);
|
|
717
717
|
if (g && g.version === i && g.fnRef === e.conditionalStyle)
|
|
718
|
-
a = l(a, g.delta), g.diagnostic && (c === null || c.level !== "error") && (c = g.diagnostic),
|
|
718
|
+
a = l(a, g.delta), g.diagnostic && (c === null || c.level !== "error") && (c = g.diagnostic), h = h || g.forceErrorText;
|
|
719
719
|
else {
|
|
720
720
|
const m = this.evalConditionalStyleFn(e.conditionalStyle, s);
|
|
721
|
-
this.conditionalCache.set(u, { version: i, fnRef: e.conditionalStyle, ...m }), a = l(a, m.delta), m.diagnostic && (c === null || c.level !== "error") && (c = m.diagnostic),
|
|
721
|
+
this.conditionalCache.set(u, { version: i, fnRef: e.conditionalStyle, ...m }), a = l(a, m.delta), m.diagnostic && (c === null || c.level !== "error") && (c = m.diagnostic), h = h || m.forceErrorText;
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
|
-
const
|
|
725
|
-
if (
|
|
724
|
+
const d = this.cellConditionalStyles.get(n);
|
|
725
|
+
if (d && s) {
|
|
726
726
|
const u = this.conditionalCache.get(n);
|
|
727
|
-
if (u && u.version === i && u.fnRef ===
|
|
728
|
-
a = l(a, u.delta), u.diagnostic && (c === null || c.level !== "error") && (c = u.diagnostic),
|
|
727
|
+
if (u && u.version === i && u.fnRef === d)
|
|
728
|
+
a = l(a, u.delta), u.diagnostic && (c === null || c.level !== "error") && (c = u.diagnostic), h = h || u.forceErrorText;
|
|
729
729
|
else {
|
|
730
|
-
const g = this.evalConditionalStyleFn(
|
|
731
|
-
this.conditionalCache.set(n, { version: i, fnRef:
|
|
730
|
+
const g = this.evalConditionalStyleFn(d, s);
|
|
731
|
+
this.conditionalCache.set(n, { version: i, fnRef: d, ...g }), a = l(a, g.delta), g.diagnostic && (c === null || c.level !== "error") && (c = g.diagnostic), h = h || g.forceErrorText;
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
return c ? this.conditionalDiagnostics.set(n, c) : this.conditionalDiagnostics.delete(n), { delta: a, diagnostic: c, forceErrorText:
|
|
734
|
+
return c ? this.conditionalDiagnostics.set(n, c) : this.conditionalDiagnostics.delete(n), { delta: a, diagnostic: c, forceErrorText: h };
|
|
735
735
|
}
|
|
736
736
|
getValidationErrors() {
|
|
737
737
|
const t = /* @__PURE__ */ new Map();
|
|
@@ -764,7 +764,7 @@ ${s}` : n : s;
|
|
|
764
764
|
updateValidationForCell(t, e, i) {
|
|
765
765
|
const n = this.schema.columns.find((l) => String(l.key) === String(e));
|
|
766
766
|
if (!n) return;
|
|
767
|
-
const s =
|
|
767
|
+
const s = Xe(i, n), o = this.cellStyleKey(t, e);
|
|
768
768
|
s ? this.baseValidationErrors.set(o, { rowId: t, colKey: e, message: s }) : this.baseValidationErrors.delete(o);
|
|
769
769
|
}
|
|
770
770
|
recomputeValidationErrors() {
|
|
@@ -845,7 +845,7 @@ Rows: ${o}`
|
|
|
845
845
|
e.displayIndex = t, t += 1;
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
-
function
|
|
848
|
+
function Ge(r, t) {
|
|
849
849
|
const e = r.getSchema(), i = r.listRows(), n = (o, l) => {
|
|
850
850
|
if (!Number.isInteger(o) || !Number.isInteger(l) || o < 0 || o >= i.length || l < 0 || l >= e.columns.length) return null;
|
|
851
851
|
const a = i[o], c = e.columns[l];
|
|
@@ -853,7 +853,7 @@ function Be(r, t) {
|
|
|
853
853
|
}, s = (o, l) => {
|
|
854
854
|
const a = r.getRowIndex(o);
|
|
855
855
|
if (a < 0) return null;
|
|
856
|
-
const c = e.columns.findIndex((
|
|
856
|
+
const c = e.columns.findIndex((h) => h.key === l);
|
|
857
857
|
return c < 0 ? null : { rowId: o, colKey: l, rowIndex: a, colIndex: c };
|
|
858
858
|
};
|
|
859
859
|
if ("rowId" in t && "colKey" in t)
|
|
@@ -870,7 +870,7 @@ function Be(r, t) {
|
|
|
870
870
|
}
|
|
871
871
|
return null;
|
|
872
872
|
}
|
|
873
|
-
class
|
|
873
|
+
class Ye {
|
|
874
874
|
constructor(t, e, i) {
|
|
875
875
|
this.lockedRows = /* @__PURE__ */ new Set(), this.mode = "none", this.mode = t, this.server = e, this.user = i;
|
|
876
876
|
}
|
|
@@ -911,36 +911,36 @@ class Pe {
|
|
|
911
911
|
return new Set(this.lockedRows);
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
|
-
const
|
|
915
|
-
function
|
|
916
|
-
const t =
|
|
914
|
+
const Kt = 864e5;
|
|
915
|
+
function se(r) {
|
|
916
|
+
const t = Pt(r);
|
|
917
917
|
return t ? Number.isNaN(t.getTime()) ? null : t : null;
|
|
918
918
|
}
|
|
919
|
-
function
|
|
919
|
+
function Qe(r) {
|
|
920
920
|
const t = /* @__PURE__ */ new Date(`1970-01-01T${r}`);
|
|
921
921
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function Je(r, t, e) {
|
|
924
924
|
if (t == null || e.type === "string") return null;
|
|
925
925
|
if (e.type === "boolean") return String(!!t);
|
|
926
926
|
if (e.type === "number" && typeof t == "number") return String(t);
|
|
927
927
|
if (e.type === "datetime") {
|
|
928
|
-
const i = t instanceof Date ? t :
|
|
928
|
+
const i = t instanceof Date ? t : se(String(t));
|
|
929
929
|
return i ? String(i.getTime()) : null;
|
|
930
930
|
}
|
|
931
931
|
if (e.type === "date") {
|
|
932
|
-
const i = t instanceof Date ? t :
|
|
932
|
+
const i = t instanceof Date ? t : se(String(t));
|
|
933
933
|
if (!i) return null;
|
|
934
|
-
const n = Math.floor(i.getTime() /
|
|
934
|
+
const n = Math.floor(i.getTime() / Kt) * Kt;
|
|
935
935
|
return String(n);
|
|
936
936
|
}
|
|
937
937
|
if (e.type === "time") {
|
|
938
|
-
const i = t instanceof Date ? t :
|
|
939
|
-
return i ? String(i.getTime() %
|
|
938
|
+
const i = t instanceof Date ? t : Qe(String(t));
|
|
939
|
+
return i ? String(i.getTime() % Kt) : null;
|
|
940
940
|
}
|
|
941
941
|
return null;
|
|
942
942
|
}
|
|
943
|
-
const dt = 24,
|
|
943
|
+
const dt = 24, st = 48, ht = 24;
|
|
944
944
|
function G(r, t, e = 100) {
|
|
945
945
|
const i = {
|
|
946
946
|
// Reserve extra space for browser UI affordances (e.g. date picker icon) and formatting.
|
|
@@ -951,7 +951,7 @@ function G(r, t, e = 100) {
|
|
|
951
951
|
return s + o;
|
|
952
952
|
});
|
|
953
953
|
}
|
|
954
|
-
const xt = (r) => r.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "),
|
|
954
|
+
const xt = (r) => r.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "), Ze = (r) => {
|
|
955
955
|
const t = [];
|
|
956
956
|
if (r)
|
|
957
957
|
for (const e of r) {
|
|
@@ -959,7 +959,7 @@ const xt = (r) => r.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "),
|
|
|
959
959
|
!i || t.includes(i) || t.push(i);
|
|
960
960
|
}
|
|
961
961
|
return t.length === 0 ? t.push("en") : t.includes("en") || t.push("en"), t;
|
|
962
|
-
},
|
|
962
|
+
}, ti = (r, t) => {
|
|
963
963
|
const e = r.items.indexOf(t);
|
|
964
964
|
if (e !== -1)
|
|
965
965
|
return e;
|
|
@@ -970,7 +970,7 @@ const xt = (r) => r.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "),
|
|
|
970
970
|
return null;
|
|
971
971
|
const n = r.items.indexOf(i);
|
|
972
972
|
return n === -1 ? null : n;
|
|
973
|
-
},
|
|
973
|
+
}, ei = (r, t) => {
|
|
974
974
|
const e = xt(t);
|
|
975
975
|
if (xt(r.id).includes(e))
|
|
976
976
|
return !0;
|
|
@@ -980,7 +980,7 @@ const xt = (r) => r.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "),
|
|
|
980
980
|
return r.aliases ? Object.keys(r.aliases).some(
|
|
981
981
|
(i) => xt(i).includes(e)
|
|
982
982
|
) : !1;
|
|
983
|
-
},
|
|
983
|
+
}, ii = (r, t) => {
|
|
984
984
|
if (r.langs.length === 0)
|
|
985
985
|
return 0;
|
|
986
986
|
let e = Number.POSITIVE_INFINITY;
|
|
@@ -989,10 +989,10 @@ const xt = (r) => r.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "),
|
|
|
989
989
|
n !== -1 && n < e && (e = n);
|
|
990
990
|
}
|
|
991
991
|
return e;
|
|
992
|
-
},
|
|
993
|
-
class
|
|
992
|
+
}, ni = (r, t) => !r.langs || r.langs.length === 0 ? !0 : r.langs.some((e) => t.includes(e));
|
|
993
|
+
class si {
|
|
994
994
|
constructor(t) {
|
|
995
|
-
this.lists = [], this.matchers = [], this.langs =
|
|
995
|
+
this.lists = [], this.matchers = [], this.langs = Ze(t?.langs);
|
|
996
996
|
}
|
|
997
997
|
register(t) {
|
|
998
998
|
const e = this.lists.findIndex((i) => i.id === t.id);
|
|
@@ -1012,7 +1012,7 @@ class ze {
|
|
|
1012
1012
|
e = e.filter((s) => n.has(s.id));
|
|
1013
1013
|
}
|
|
1014
1014
|
const i = t?.queryText;
|
|
1015
|
-
return i && (e = e.filter((n) =>
|
|
1015
|
+
return i && (e = e.filter((n) => ei(n, i))), e;
|
|
1016
1016
|
}
|
|
1017
1017
|
match(t, e) {
|
|
1018
1018
|
if (t.length === 0)
|
|
@@ -1020,7 +1020,7 @@ class ze {
|
|
|
1020
1020
|
let i = null, n = Number.NEGATIVE_INFINITY;
|
|
1021
1021
|
const s = e?.enabledIds ? new Set(e.enabledIds) : null;
|
|
1022
1022
|
for (const l of this.matchers) {
|
|
1023
|
-
if (s && !s.has(l.id) || !
|
|
1023
|
+
if (s && !s.has(l.id) || !ni(l, this.langs))
|
|
1024
1024
|
continue;
|
|
1025
1025
|
const a = l.match(t);
|
|
1026
1026
|
if (!a)
|
|
@@ -1033,29 +1033,29 @@ class ze {
|
|
|
1033
1033
|
state: a.state
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
1036
|
-
const o = this.list(e).map((l) => ({ list: l, rank:
|
|
1036
|
+
const o = this.list(e).map((l) => ({ list: l, rank: ii(l, this.langs) })).filter((l) => Number.isFinite(l.rank)).sort((l, a) => l.rank - a.rank);
|
|
1037
1037
|
for (const { list: l, rank: a } of o) {
|
|
1038
1038
|
const c = [];
|
|
1039
|
-
let
|
|
1039
|
+
let h = !1;
|
|
1040
1040
|
for (const g of t) {
|
|
1041
|
-
const m =
|
|
1041
|
+
const m = ti(l, g);
|
|
1042
1042
|
if (m === null) {
|
|
1043
|
-
|
|
1043
|
+
h = !0;
|
|
1044
1044
|
break;
|
|
1045
1045
|
}
|
|
1046
1046
|
c.push(m);
|
|
1047
1047
|
}
|
|
1048
|
-
if (
|
|
1048
|
+
if (h)
|
|
1049
1049
|
continue;
|
|
1050
|
-
const
|
|
1051
|
-
if (
|
|
1050
|
+
const d = this.inferStep(l, c);
|
|
1051
|
+
if (d === null)
|
|
1052
1052
|
continue;
|
|
1053
1053
|
const u = 10 - a;
|
|
1054
1054
|
u > n && (n = u, i = {
|
|
1055
1055
|
kind: "list",
|
|
1056
1056
|
list: l,
|
|
1057
1057
|
startIndex: c[c.length - 1] ?? 0,
|
|
1058
|
-
step:
|
|
1058
|
+
step: d
|
|
1059
1059
|
});
|
|
1060
1060
|
}
|
|
1061
1061
|
return i;
|
|
@@ -1086,12 +1086,12 @@ class ze {
|
|
|
1086
1086
|
return s >= e ? null : s;
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
|
-
const
|
|
1089
|
+
const oi = {
|
|
1090
1090
|
id: "weekdays-en-long",
|
|
1091
1091
|
mode: "cycle",
|
|
1092
1092
|
langs: ["en"],
|
|
1093
1093
|
items: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
|
1094
|
-
},
|
|
1094
|
+
}, ri = {
|
|
1095
1095
|
id: "weekdays-en-short",
|
|
1096
1096
|
mode: "cycle",
|
|
1097
1097
|
langs: ["en"],
|
|
@@ -1101,22 +1101,22 @@ const Ge = {
|
|
|
1101
1101
|
Thur: "Thu",
|
|
1102
1102
|
Thurs: "Thu"
|
|
1103
1103
|
}
|
|
1104
|
-
},
|
|
1104
|
+
}, li = {
|
|
1105
1105
|
id: "weekdays-ja-long",
|
|
1106
1106
|
mode: "cycle",
|
|
1107
1107
|
langs: ["ja"],
|
|
1108
1108
|
items: ["月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日"]
|
|
1109
|
-
},
|
|
1109
|
+
}, ai = {
|
|
1110
1110
|
id: "weekdays-ja-short",
|
|
1111
1111
|
mode: "cycle",
|
|
1112
1112
|
langs: ["ja"],
|
|
1113
1113
|
items: ["月曜", "火曜", "水曜", "木曜", "金曜", "土曜", "日曜"]
|
|
1114
|
-
},
|
|
1114
|
+
}, ci = {
|
|
1115
1115
|
id: "weekdays-ja-single",
|
|
1116
1116
|
mode: "cycle",
|
|
1117
1117
|
langs: ["ja"],
|
|
1118
1118
|
items: ["月", "火", "水", "木", "金", "土", "日"]
|
|
1119
|
-
},
|
|
1119
|
+
}, di = {
|
|
1120
1120
|
id: "months-en-long",
|
|
1121
1121
|
mode: "cycle",
|
|
1122
1122
|
langs: ["en"],
|
|
@@ -1134,7 +1134,7 @@ const Ge = {
|
|
|
1134
1134
|
"November",
|
|
1135
1135
|
"December"
|
|
1136
1136
|
]
|
|
1137
|
-
},
|
|
1137
|
+
}, hi = {
|
|
1138
1138
|
id: "months-en-short",
|
|
1139
1139
|
mode: "cycle",
|
|
1140
1140
|
langs: ["en"],
|
|
@@ -1142,32 +1142,32 @@ const Ge = {
|
|
|
1142
1142
|
aliases: {
|
|
1143
1143
|
Sept: "Sep"
|
|
1144
1144
|
}
|
|
1145
|
-
},
|
|
1145
|
+
}, ui = {
|
|
1146
1146
|
id: "months-ja",
|
|
1147
1147
|
mode: "cycle",
|
|
1148
1148
|
langs: ["ja"],
|
|
1149
1149
|
items: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
|
|
1150
|
-
},
|
|
1150
|
+
}, fi = {
|
|
1151
1151
|
id: "months-ja-traditional",
|
|
1152
1152
|
mode: "cycle",
|
|
1153
1153
|
langs: ["ja"],
|
|
1154
1154
|
items: ["睦月", "如月", "弥生", "卯月", "皐月", "水無月", "文月", "葉月", "長月", "神無月", "霜月", "師走"]
|
|
1155
|
-
},
|
|
1155
|
+
}, gi = {
|
|
1156
1156
|
id: "quarters-en",
|
|
1157
1157
|
mode: "cycle",
|
|
1158
1158
|
langs: ["en"],
|
|
1159
1159
|
items: ["Q1", "Q2", "Q3", "Q4"]
|
|
1160
|
-
},
|
|
1160
|
+
}, mi = {
|
|
1161
1161
|
id: "quarters-ja",
|
|
1162
1162
|
mode: "cycle",
|
|
1163
1163
|
langs: ["ja"],
|
|
1164
1164
|
items: ["第1四半期", "第2四半期", "第3四半期", "第4四半期"]
|
|
1165
|
-
},
|
|
1165
|
+
}, pi = {
|
|
1166
1166
|
id: "zodiac-animals-ja",
|
|
1167
1167
|
mode: "cycle",
|
|
1168
1168
|
langs: ["ja"],
|
|
1169
1169
|
items: ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
|
|
1170
|
-
},
|
|
1170
|
+
}, yi = {
|
|
1171
1171
|
id: "zodiac-signs-en",
|
|
1172
1172
|
mode: "cycle",
|
|
1173
1173
|
langs: ["en"],
|
|
@@ -1185,7 +1185,7 @@ const Ge = {
|
|
|
1185
1185
|
"Aquarius",
|
|
1186
1186
|
"Pisces"
|
|
1187
1187
|
]
|
|
1188
|
-
},
|
|
1188
|
+
}, wi = {
|
|
1189
1189
|
id: "zodiac-signs-ja",
|
|
1190
1190
|
mode: "cycle",
|
|
1191
1191
|
langs: ["ja"],
|
|
@@ -1193,7 +1193,7 @@ const Ge = {
|
|
|
1193
1193
|
aliases: {
|
|
1194
1194
|
さそり座: "蠍座"
|
|
1195
1195
|
}
|
|
1196
|
-
},
|
|
1196
|
+
}, vi = {
|
|
1197
1197
|
id: "directions-16-en",
|
|
1198
1198
|
mode: "cycle",
|
|
1199
1199
|
langs: ["en"],
|
|
@@ -1215,7 +1215,7 @@ const Ge = {
|
|
|
1215
1215
|
"Northwest",
|
|
1216
1216
|
"North-Northwest"
|
|
1217
1217
|
]
|
|
1218
|
-
},
|
|
1218
|
+
}, Ci = {
|
|
1219
1219
|
id: "directions-16-ja",
|
|
1220
1220
|
mode: "cycle",
|
|
1221
1221
|
langs: ["ja"],
|
|
@@ -1237,7 +1237,7 @@ const Ge = {
|
|
|
1237
1237
|
"北西",
|
|
1238
1238
|
"北北西"
|
|
1239
1239
|
]
|
|
1240
|
-
},
|
|
1240
|
+
}, Si = {
|
|
1241
1241
|
id: "ampm-en",
|
|
1242
1242
|
mode: "cycle",
|
|
1243
1243
|
langs: ["en"],
|
|
@@ -1246,12 +1246,12 @@ const Ge = {
|
|
|
1246
1246
|
"A.M.": "AM",
|
|
1247
1247
|
"P.M.": "PM"
|
|
1248
1248
|
}
|
|
1249
|
-
},
|
|
1249
|
+
}, xi = {
|
|
1250
1250
|
id: "ampm-ja",
|
|
1251
1251
|
mode: "cycle",
|
|
1252
1252
|
langs: ["ja"],
|
|
1253
1253
|
items: ["午前", "午後"]
|
|
1254
|
-
},
|
|
1254
|
+
}, bi = {
|
|
1255
1255
|
id: "seasons-en",
|
|
1256
1256
|
mode: "cycle",
|
|
1257
1257
|
langs: ["en"],
|
|
@@ -1259,17 +1259,17 @@ const Ge = {
|
|
|
1259
1259
|
aliases: {
|
|
1260
1260
|
Fall: "Autumn"
|
|
1261
1261
|
}
|
|
1262
|
-
},
|
|
1262
|
+
}, Mi = {
|
|
1263
1263
|
id: "seasons-ja",
|
|
1264
1264
|
mode: "cycle",
|
|
1265
1265
|
langs: ["ja"],
|
|
1266
1266
|
items: ["春", "夏", "秋", "冬"]
|
|
1267
|
-
},
|
|
1267
|
+
}, Ri = {
|
|
1268
1268
|
id: "solfege-ja",
|
|
1269
1269
|
mode: "cycle",
|
|
1270
1270
|
langs: ["ja"],
|
|
1271
1271
|
items: ["ド", "レ", "ミ", "ファ", "ソ", "ラ", "シ"]
|
|
1272
|
-
},
|
|
1272
|
+
}, ki = {
|
|
1273
1273
|
id: "solfege-en",
|
|
1274
1274
|
mode: "cycle",
|
|
1275
1275
|
langs: ["en"],
|
|
@@ -1278,7 +1278,7 @@ const Ge = {
|
|
|
1278
1278
|
So: "Sol",
|
|
1279
1279
|
Si: "Ti"
|
|
1280
1280
|
}
|
|
1281
|
-
},
|
|
1281
|
+
}, Ii = {
|
|
1282
1282
|
id: "greek-letters-en",
|
|
1283
1283
|
mode: "cycle",
|
|
1284
1284
|
langs: ["en"],
|
|
@@ -1308,7 +1308,7 @@ const Ge = {
|
|
|
1308
1308
|
"Psi",
|
|
1309
1309
|
"Omega"
|
|
1310
1310
|
]
|
|
1311
|
-
},
|
|
1311
|
+
}, Ei = {
|
|
1312
1312
|
id: "greek-letters-ja",
|
|
1313
1313
|
mode: "cycle",
|
|
1314
1314
|
langs: ["ja"],
|
|
@@ -1338,7 +1338,7 @@ const Ge = {
|
|
|
1338
1338
|
"プサイ",
|
|
1339
1339
|
"オメガ"
|
|
1340
1340
|
]
|
|
1341
|
-
},
|
|
1341
|
+
}, Ti = {
|
|
1342
1342
|
id: "greek-letters-symbols",
|
|
1343
1343
|
mode: "cycle",
|
|
1344
1344
|
langs: ["en", "ja"],
|
|
@@ -1371,37 +1371,37 @@ const Ge = {
|
|
|
1371
1371
|
aliases: {
|
|
1372
1372
|
ς: "σ"
|
|
1373
1373
|
}
|
|
1374
|
-
},
|
|
1374
|
+
}, Ai = {
|
|
1375
1375
|
id: "rokuyo-ja",
|
|
1376
1376
|
mode: "cycle",
|
|
1377
1377
|
langs: ["ja"],
|
|
1378
1378
|
items: ["先勝", "友引", "先負", "仏滅", "大安", "赤口"]
|
|
1379
|
-
},
|
|
1379
|
+
}, Hi = {
|
|
1380
1380
|
id: "heavenly-stems-ja",
|
|
1381
1381
|
mode: "finite",
|
|
1382
1382
|
langs: ["ja"],
|
|
1383
1383
|
items: ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
|
|
1384
|
-
},
|
|
1384
|
+
}, Di = {
|
|
1385
1385
|
id: "planets-en",
|
|
1386
1386
|
mode: "finite",
|
|
1387
1387
|
langs: ["en"],
|
|
1388
1388
|
items: ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
|
|
1389
|
-
},
|
|
1389
|
+
}, Ki = {
|
|
1390
1390
|
id: "planets-ja",
|
|
1391
1391
|
mode: "finite",
|
|
1392
1392
|
langs: ["ja"],
|
|
1393
1393
|
items: ["水星", "金星", "地球", "火星", "木星", "土星", "天王星", "海王星"]
|
|
1394
|
-
},
|
|
1394
|
+
}, Li = {
|
|
1395
1395
|
id: "kuji-in-ja",
|
|
1396
1396
|
mode: "finite",
|
|
1397
1397
|
langs: ["ja"],
|
|
1398
1398
|
items: ["臨", "兵", "闘", "者", "皆", "陣", "烈", "在", "前"]
|
|
1399
|
-
},
|
|
1399
|
+
}, Vi = {
|
|
1400
1400
|
id: "eight-virtues-ja",
|
|
1401
1401
|
mode: "finite",
|
|
1402
1402
|
langs: ["ja"],
|
|
1403
1403
|
items: ["仁", "義", "礼", "智", "忠", "信", "孝", "悌"]
|
|
1404
|
-
},
|
|
1404
|
+
}, Fi = {
|
|
1405
1405
|
id: "element-symbols",
|
|
1406
1406
|
mode: "finite",
|
|
1407
1407
|
langs: ["ja", "en"],
|
|
@@ -1525,7 +1525,7 @@ const Ge = {
|
|
|
1525
1525
|
"Ts",
|
|
1526
1526
|
"Og"
|
|
1527
1527
|
]
|
|
1528
|
-
},
|
|
1528
|
+
}, _i = {
|
|
1529
1529
|
id: "element-names-ja",
|
|
1530
1530
|
mode: "finite",
|
|
1531
1531
|
langs: ["ja"],
|
|
@@ -1649,7 +1649,7 @@ const Ge = {
|
|
|
1649
1649
|
"テネシン",
|
|
1650
1650
|
"オガネソン"
|
|
1651
1651
|
]
|
|
1652
|
-
},
|
|
1652
|
+
}, Ni = {
|
|
1653
1653
|
id: "shoguns-kamakura-ja",
|
|
1654
1654
|
mode: "finite",
|
|
1655
1655
|
langs: ["ja"],
|
|
@@ -1664,7 +1664,7 @@ const Ge = {
|
|
|
1664
1664
|
"久明親王",
|
|
1665
1665
|
"守邦親王"
|
|
1666
1666
|
]
|
|
1667
|
-
},
|
|
1667
|
+
}, Bi = {
|
|
1668
1668
|
id: "shoguns-ashikaga-ja",
|
|
1669
1669
|
mode: "finite",
|
|
1670
1670
|
langs: ["ja"],
|
|
@@ -1685,7 +1685,7 @@ const Ge = {
|
|
|
1685
1685
|
"足利義栄",
|
|
1686
1686
|
"足利義昭"
|
|
1687
1687
|
]
|
|
1688
|
-
},
|
|
1688
|
+
}, Pi = {
|
|
1689
1689
|
id: "shoguns-ashikaga-given-ja",
|
|
1690
1690
|
mode: "finite",
|
|
1691
1691
|
langs: ["ja"],
|
|
@@ -1706,7 +1706,7 @@ const Ge = {
|
|
|
1706
1706
|
"義栄",
|
|
1707
1707
|
"義昭"
|
|
1708
1708
|
]
|
|
1709
|
-
},
|
|
1709
|
+
}, $i = {
|
|
1710
1710
|
id: "shoguns-tokugawa-ja",
|
|
1711
1711
|
mode: "finite",
|
|
1712
1712
|
langs: ["ja"],
|
|
@@ -1727,7 +1727,7 @@ const Ge = {
|
|
|
1727
1727
|
"徳川家茂",
|
|
1728
1728
|
"徳川慶喜"
|
|
1729
1729
|
]
|
|
1730
|
-
},
|
|
1730
|
+
}, Oi = {
|
|
1731
1731
|
id: "shoguns-tokugawa-given-ja",
|
|
1732
1732
|
mode: "finite",
|
|
1733
1733
|
langs: ["ja"],
|
|
@@ -1748,7 +1748,7 @@ const Ge = {
|
|
|
1748
1748
|
"家茂",
|
|
1749
1749
|
"慶喜"
|
|
1750
1750
|
]
|
|
1751
|
-
},
|
|
1751
|
+
}, ge = [
|
|
1752
1752
|
"北海道",
|
|
1753
1753
|
"青森県",
|
|
1754
1754
|
"岩手県",
|
|
@@ -1796,7 +1796,7 @@ const Ge = {
|
|
|
1796
1796
|
"宮崎県",
|
|
1797
1797
|
"鹿児島県",
|
|
1798
1798
|
"沖縄県"
|
|
1799
|
-
],
|
|
1799
|
+
], ji = ge.reduce(
|
|
1800
1800
|
(r, t) => {
|
|
1801
1801
|
if (t === "北海道")
|
|
1802
1802
|
return r;
|
|
@@ -1807,13 +1807,13 @@ const Ge = {
|
|
|
1807
1807
|
return r;
|
|
1808
1808
|
},
|
|
1809
1809
|
{}
|
|
1810
|
-
),
|
|
1810
|
+
), Wi = {
|
|
1811
1811
|
id: "prefectures-ja",
|
|
1812
1812
|
mode: "finite",
|
|
1813
1813
|
langs: ["ja"],
|
|
1814
|
-
items:
|
|
1815
|
-
aliases:
|
|
1816
|
-
},
|
|
1814
|
+
items: ge,
|
|
1815
|
+
aliases: ji
|
|
1816
|
+
}, qi = {
|
|
1817
1817
|
id: "us-states-en",
|
|
1818
1818
|
mode: "finite",
|
|
1819
1819
|
langs: ["en"],
|
|
@@ -1869,7 +1869,7 @@ const Ge = {
|
|
|
1869
1869
|
"Wisconsin",
|
|
1870
1870
|
"Wyoming"
|
|
1871
1871
|
]
|
|
1872
|
-
},
|
|
1872
|
+
}, Ui = {
|
|
1873
1873
|
id: "us-states-abbrev-en",
|
|
1874
1874
|
mode: "finite",
|
|
1875
1875
|
langs: ["en"],
|
|
@@ -1925,7 +1925,7 @@ const Ge = {
|
|
|
1925
1925
|
"WI",
|
|
1926
1926
|
"WY"
|
|
1927
1927
|
]
|
|
1928
|
-
},
|
|
1928
|
+
}, Xi = {
|
|
1929
1929
|
id: "windows-versions",
|
|
1930
1930
|
mode: "finite",
|
|
1931
1931
|
langs: ["ja", "en"],
|
|
@@ -1948,7 +1948,7 @@ const Ge = {
|
|
|
1948
1948
|
"Windows 10",
|
|
1949
1949
|
"Windows 11"
|
|
1950
1950
|
]
|
|
1951
|
-
},
|
|
1951
|
+
}, zi = {
|
|
1952
1952
|
id: "macos-versions",
|
|
1953
1953
|
mode: "finite",
|
|
1954
1954
|
langs: ["ja", "en"],
|
|
@@ -1976,7 +1976,7 @@ const Ge = {
|
|
|
1976
1976
|
"Sequoia",
|
|
1977
1977
|
"Tahoe"
|
|
1978
1978
|
]
|
|
1979
|
-
},
|
|
1979
|
+
}, Gi = {
|
|
1980
1980
|
id: "debian-codenames",
|
|
1981
1981
|
mode: "finite",
|
|
1982
1982
|
langs: ["ja", "en"],
|
|
@@ -2000,17 +2000,7 @@ const Ge = {
|
|
|
2000
2000
|
"bookworm",
|
|
2001
2001
|
"trixie"
|
|
2002
2002
|
]
|
|
2003
|
-
},
|
|
2004
|
-
Ge,
|
|
2005
|
-
Ye,
|
|
2006
|
-
Qe,
|
|
2007
|
-
Je,
|
|
2008
|
-
Ze,
|
|
2009
|
-
ti,
|
|
2010
|
-
ei,
|
|
2011
|
-
ii,
|
|
2012
|
-
ni,
|
|
2013
|
-
si,
|
|
2003
|
+
}, Yi = [
|
|
2014
2004
|
oi,
|
|
2015
2005
|
ri,
|
|
2016
2006
|
li,
|
|
@@ -2025,13 +2015,13 @@ const Ge = {
|
|
|
2025
2015
|
pi,
|
|
2026
2016
|
yi,
|
|
2027
2017
|
wi,
|
|
2028
|
-
Ci,
|
|
2029
2018
|
vi,
|
|
2019
|
+
Ci,
|
|
2030
2020
|
Si,
|
|
2031
2021
|
xi,
|
|
2032
2022
|
bi,
|
|
2033
|
-
Ri,
|
|
2034
2023
|
Mi,
|
|
2024
|
+
Ri,
|
|
2035
2025
|
ki,
|
|
2036
2026
|
Ii,
|
|
2037
2027
|
Ei,
|
|
@@ -2039,53 +2029,137 @@ const Ge = {
|
|
|
2039
2029
|
Ai,
|
|
2040
2030
|
Hi,
|
|
2041
2031
|
Di,
|
|
2032
|
+
Ki,
|
|
2042
2033
|
Li,
|
|
2043
2034
|
Vi,
|
|
2044
2035
|
Fi,
|
|
2045
2036
|
_i,
|
|
2046
2037
|
Ni,
|
|
2047
|
-
Bi
|
|
2048
|
-
|
|
2038
|
+
Bi,
|
|
2039
|
+
Pi,
|
|
2040
|
+
$i,
|
|
2041
|
+
Oi,
|
|
2042
|
+
Wi,
|
|
2043
|
+
qi,
|
|
2044
|
+
Ui,
|
|
2045
|
+
Xi,
|
|
2046
|
+
zi,
|
|
2047
|
+
Gi
|
|
2048
|
+
], It = (r) => {
|
|
2049
2049
|
const t = r % 100;
|
|
2050
2050
|
if (t >= 11 && t <= 13) return "th";
|
|
2051
2051
|
const e = r % 10;
|
|
2052
2052
|
return e === 1 ? "st" : e === 2 ? "nd" : e === 3 ? "rd" : "th";
|
|
2053
|
-
},
|
|
2054
|
-
|
|
2053
|
+
}, Vt = {
|
|
2054
|
+
1: "first",
|
|
2055
|
+
2: "second",
|
|
2056
|
+
3: "third",
|
|
2057
|
+
4: "fourth",
|
|
2058
|
+
5: "fifth",
|
|
2059
|
+
6: "sixth",
|
|
2060
|
+
7: "seventh",
|
|
2061
|
+
8: "eighth",
|
|
2062
|
+
9: "ninth",
|
|
2063
|
+
10: "tenth",
|
|
2064
|
+
11: "eleventh",
|
|
2065
|
+
12: "twelfth",
|
|
2066
|
+
13: "thirteenth",
|
|
2067
|
+
14: "fourteenth",
|
|
2068
|
+
15: "fifteenth",
|
|
2069
|
+
16: "sixteenth",
|
|
2070
|
+
17: "seventeenth",
|
|
2071
|
+
18: "eighteenth",
|
|
2072
|
+
19: "nineteenth"
|
|
2073
|
+
}, Ft = {
|
|
2074
|
+
20: "twentieth",
|
|
2075
|
+
30: "thirtieth",
|
|
2076
|
+
40: "fortieth",
|
|
2077
|
+
50: "fiftieth",
|
|
2078
|
+
60: "sixtieth",
|
|
2079
|
+
70: "seventieth",
|
|
2080
|
+
80: "eightieth",
|
|
2081
|
+
90: "ninetieth"
|
|
2082
|
+
}, me = {
|
|
2083
|
+
20: "twenty",
|
|
2084
|
+
30: "thirty",
|
|
2085
|
+
40: "forty",
|
|
2086
|
+
50: "fifty",
|
|
2087
|
+
60: "sixty",
|
|
2088
|
+
70: "seventy",
|
|
2089
|
+
80: "eighty",
|
|
2090
|
+
90: "ninety"
|
|
2091
|
+
}, oe = Object.fromEntries(
|
|
2092
|
+
Object.entries(Vt).map(([r, t]) => [t, Number(r)])
|
|
2093
|
+
), Qi = Object.fromEntries(
|
|
2094
|
+
Object.entries(Ft).map(([r, t]) => [t, Number(r)])
|
|
2095
|
+
), Ji = Object.fromEntries(
|
|
2096
|
+
Object.entries(me).map(([r, t]) => [t, Number(r)])
|
|
2097
|
+
), pe = (r) => {
|
|
2098
|
+
const t = r.trim().toLowerCase();
|
|
2055
2099
|
if (!t) return null;
|
|
2056
|
-
const e =
|
|
2057
|
-
if (
|
|
2058
|
-
const i = t[
|
|
2059
|
-
|
|
2060
|
-
|
|
2100
|
+
const e = oe[t] ?? Qi[t];
|
|
2101
|
+
if (e) return e;
|
|
2102
|
+
const i = t.split(/[-\s]+/);
|
|
2103
|
+
if (i.length !== 2) return null;
|
|
2104
|
+
const n = Ji[i[0] ?? ""], s = oe[i[1] ?? ""];
|
|
2105
|
+
return !n || !s ? null : n + s;
|
|
2106
|
+
}, ye = (r) => {
|
|
2107
|
+
if (!Number.isFinite(r) || r <= 0 || Math.floor(r) !== r) return null;
|
|
2108
|
+
if (r <= 19) return Vt[r] ?? null;
|
|
2109
|
+
if (r < 100) {
|
|
2110
|
+
if (Ft[r]) return Ft[r] ?? null;
|
|
2111
|
+
const t = Math.floor(r / 10) * 10, e = r % 10, i = me[t], n = Vt[e];
|
|
2112
|
+
return !i || !n ? null : `${i}-${n}`;
|
|
2113
|
+
}
|
|
2114
|
+
return null;
|
|
2115
|
+
}, re = (r) => {
|
|
2116
|
+
const t = /^(\d+)(st|nd|rd|th)$/i.exec(r);
|
|
2117
|
+
if (t) {
|
|
2118
|
+
const i = Number(t[1]);
|
|
2119
|
+
if (!Number.isFinite(i) || i <= 0) return null;
|
|
2120
|
+
const n = t[2]?.toLowerCase();
|
|
2121
|
+
return It(i) !== n ? null : { value: i, format: "numeric" };
|
|
2122
|
+
}
|
|
2123
|
+
const e = pe(r);
|
|
2124
|
+
return e !== null ? { value: e, format: "word" } : null;
|
|
2125
|
+
}, Zi = {
|
|
2061
2126
|
id: "ordinal-en",
|
|
2062
2127
|
langs: ["en"],
|
|
2063
2128
|
match(r) {
|
|
2064
2129
|
if (r.length < 2) return null;
|
|
2065
|
-
const t = r.map((
|
|
2066
|
-
if (t.some((
|
|
2067
|
-
const e = t
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2130
|
+
const t = r.map((s) => re(s));
|
|
2131
|
+
if (t.some((s) => s === null)) return null;
|
|
2132
|
+
const e = t[0].format;
|
|
2133
|
+
if (t.some((s) => s?.format !== e)) return null;
|
|
2134
|
+
const i = t.map((s) => s.value), n = i[1] - i[0];
|
|
2135
|
+
for (let s = 2; s < i.length; s += 1)
|
|
2136
|
+
if (i[s] - i[s - 1] !== n) return null;
|
|
2137
|
+
return { score: 80, step: n, state: { format: e } };
|
|
2071
2138
|
},
|
|
2072
2139
|
createIterator(r, t) {
|
|
2073
|
-
|
|
2140
|
+
const e = re(r[r.length - 1] ?? ""), i = t.state?.format ?? "numeric";
|
|
2141
|
+
let n = e?.value ?? 0;
|
|
2074
2142
|
return {
|
|
2075
2143
|
next() {
|
|
2076
|
-
|
|
2144
|
+
if (n += t.step, n <= 0 || !Number.isFinite(n))
|
|
2145
|
+
return { value: void 0, done: !0 };
|
|
2146
|
+
if (i === "word") {
|
|
2147
|
+
const s = ye(n);
|
|
2148
|
+
return s ? { value: s, done: !1 } : { value: void 0, done: !0 };
|
|
2149
|
+
}
|
|
2150
|
+
return { value: `${n}${It(n)}`, done: !1 };
|
|
2077
2151
|
}
|
|
2078
2152
|
};
|
|
2079
2153
|
}
|
|
2080
|
-
},
|
|
2081
|
-
for (const t of
|
|
2154
|
+
}, tn = (r) => {
|
|
2155
|
+
for (const t of Yi)
|
|
2082
2156
|
r.register(t);
|
|
2083
|
-
},
|
|
2084
|
-
r.registerMatch(
|
|
2085
|
-
},
|
|
2086
|
-
const t = r ?? ["en", "ja"], e = new
|
|
2087
|
-
return
|
|
2088
|
-
},
|
|
2157
|
+
}, en = (r) => {
|
|
2158
|
+
r.registerMatch(Zi);
|
|
2159
|
+
}, we = (r) => {
|
|
2160
|
+
const t = r ?? ["en", "ja"], e = new si({ langs: t });
|
|
2161
|
+
return tn(e), en(e), e;
|
|
2162
|
+
}, nn = (r) => {
|
|
2089
2163
|
let t = 0;
|
|
2090
2164
|
return {
|
|
2091
2165
|
next() {
|
|
@@ -2099,7 +2173,7 @@ const Ge = {
|
|
|
2099
2173
|
class X {
|
|
2100
2174
|
constructor(...t) {
|
|
2101
2175
|
const e = t;
|
|
2102
|
-
this.seed = e, this.kind = e.length === 1 ? "copy" : "seed-repeat", this.iterator =
|
|
2176
|
+
this.seed = e, this.kind = e.length === 1 ? "copy" : "seed-repeat", this.iterator = nn(e);
|
|
2103
2177
|
}
|
|
2104
2178
|
static fromSeed(t, e, i) {
|
|
2105
2179
|
const n = new X(...t);
|
|
@@ -2112,11 +2186,11 @@ class X {
|
|
|
2112
2186
|
return this;
|
|
2113
2187
|
}
|
|
2114
2188
|
}
|
|
2115
|
-
const
|
|
2189
|
+
const ve = 1e-9, sn = 100, on = (r) => ({
|
|
2116
2190
|
next() {
|
|
2117
2191
|
return { value: r, done: !1 };
|
|
2118
2192
|
}
|
|
2119
|
-
}),
|
|
2193
|
+
}), le = (r) => {
|
|
2120
2194
|
let t = 0;
|
|
2121
2195
|
return {
|
|
2122
2196
|
next() {
|
|
@@ -2126,28 +2200,28 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2126
2200
|
return t += 1, { value: e, done: !1 };
|
|
2127
2201
|
}
|
|
2128
2202
|
};
|
|
2129
|
-
},
|
|
2203
|
+
}, rn = (r, t) => {
|
|
2130
2204
|
let e = 0;
|
|
2131
2205
|
return {
|
|
2132
2206
|
next() {
|
|
2133
2207
|
return e += 1, { value: r + t * e, done: !1 };
|
|
2134
2208
|
}
|
|
2135
2209
|
};
|
|
2136
|
-
},
|
|
2210
|
+
}, ln = (r, t) => {
|
|
2137
2211
|
let e = 0;
|
|
2138
2212
|
return {
|
|
2139
2213
|
next() {
|
|
2140
2214
|
return e += 1, { value: new Date(r.getTime() + t * e), done: !1 };
|
|
2141
2215
|
}
|
|
2142
2216
|
};
|
|
2143
|
-
},
|
|
2217
|
+
}, an = (r, t) => {
|
|
2144
2218
|
let e = 0;
|
|
2145
2219
|
return {
|
|
2146
2220
|
next() {
|
|
2147
2221
|
return e += 1, { value: r * t ** e, done: !1 };
|
|
2148
2222
|
}
|
|
2149
2223
|
};
|
|
2150
|
-
},
|
|
2224
|
+
}, cn = (r, t) => {
|
|
2151
2225
|
if (r.kind === "matcher")
|
|
2152
2226
|
return r.matcher.createIterator(t, { step: r.step, state: r.state });
|
|
2153
2227
|
const { list: e, startIndex: i, step: n } = r, s = e.items.length;
|
|
@@ -2161,7 +2235,7 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2161
2235
|
return o = (o + n) % s, { value: e.items[o], done: !1 };
|
|
2162
2236
|
}
|
|
2163
2237
|
};
|
|
2164
|
-
},
|
|
2238
|
+
}, dn = (r) => r.every((t) => typeof t == "number" && Number.isFinite(t)), hn = (r) => r.every((t) => t instanceof Date && !Number.isNaN(t.getTime())), un = (r) => r.every((t) => typeof t == "string"), fn = (r) => {
|
|
2165
2239
|
const t = /^(.*?)(-?\d+)([^0-9]*)$/.exec(r);
|
|
2166
2240
|
if (!t)
|
|
2167
2241
|
return null;
|
|
@@ -2170,7 +2244,47 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2170
2244
|
return null;
|
|
2171
2245
|
const o = i.replace("-", "").length;
|
|
2172
2246
|
return { prefix: e, num: s, width: o, suffix: n };
|
|
2173
|
-
},
|
|
2247
|
+
}, gn = (r) => {
|
|
2248
|
+
const t = /^(.*?)(\d+)(st|nd|rd|th)([^0-9]*)$/i.exec(r);
|
|
2249
|
+
if (t) {
|
|
2250
|
+
const n = Number(t[2]);
|
|
2251
|
+
if (!Number.isFinite(n) || n <= 0) return null;
|
|
2252
|
+
const s = t[3]?.toLowerCase();
|
|
2253
|
+
return It(n) !== s ? null : {
|
|
2254
|
+
prefix: t[1] ?? "",
|
|
2255
|
+
num: n,
|
|
2256
|
+
suffix: t[4] ?? "",
|
|
2257
|
+
format: "numeric"
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
const e = /^(.*?)([A-Za-z-]+)([^A-Za-z]*)$/.exec(r);
|
|
2261
|
+
if (!e) return null;
|
|
2262
|
+
const i = pe(e[2] ?? "");
|
|
2263
|
+
return i === null ? null : {
|
|
2264
|
+
prefix: e[1] ?? "",
|
|
2265
|
+
num: i,
|
|
2266
|
+
suffix: e[3] ?? "",
|
|
2267
|
+
format: "word"
|
|
2268
|
+
};
|
|
2269
|
+
}, mn = (r, t, e) => {
|
|
2270
|
+
let i = 0;
|
|
2271
|
+
return {
|
|
2272
|
+
next() {
|
|
2273
|
+
i += 1;
|
|
2274
|
+
const n = t + e * i;
|
|
2275
|
+
if (n <= 0 || !Number.isFinite(n))
|
|
2276
|
+
return { value: void 0, done: !0 };
|
|
2277
|
+
if (r.format === "word") {
|
|
2278
|
+
const s = ye(n);
|
|
2279
|
+
return s ? { value: `${r.prefix}${s}${r.suffix}`, done: !1 } : { value: void 0, done: !0 };
|
|
2280
|
+
}
|
|
2281
|
+
return {
|
|
2282
|
+
value: `${r.prefix}${n}${It(n)}${r.suffix}`,
|
|
2283
|
+
done: !1
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
}, pn = (r, t, e) => {
|
|
2174
2288
|
let i = 0;
|
|
2175
2289
|
return {
|
|
2176
2290
|
next() {
|
|
@@ -2179,7 +2293,7 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2179
2293
|
return { value: `${r.prefix}${s}${o}${r.suffix}`, done: !1 };
|
|
2180
2294
|
}
|
|
2181
2295
|
};
|
|
2182
|
-
},
|
|
2296
|
+
}, Ce = [
|
|
2183
2297
|
["C", 100],
|
|
2184
2298
|
["XC", 90],
|
|
2185
2299
|
["L", 50],
|
|
@@ -2189,39 +2303,39 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2189
2303
|
["V", 5],
|
|
2190
2304
|
["IV", 4],
|
|
2191
2305
|
["I", 1]
|
|
2192
|
-
],
|
|
2193
|
-
if (r < 1 || r >
|
|
2306
|
+
], $t = (r) => {
|
|
2307
|
+
if (r < 1 || r > sn)
|
|
2194
2308
|
return null;
|
|
2195
2309
|
let t = r, e = "";
|
|
2196
|
-
for (const [i, n] of
|
|
2310
|
+
for (const [i, n] of Ce)
|
|
2197
2311
|
for (; t >= n; )
|
|
2198
2312
|
e += i, t -= n;
|
|
2199
2313
|
return e;
|
|
2200
|
-
},
|
|
2314
|
+
}, Se = (r) => {
|
|
2201
2315
|
if (r.length === 0 || r !== r.toUpperCase())
|
|
2202
2316
|
return null;
|
|
2203
2317
|
let t = r, e = 0;
|
|
2204
|
-
for (const [n, s] of
|
|
2318
|
+
for (const [n, s] of Ce)
|
|
2205
2319
|
for (; t.startsWith(n); )
|
|
2206
2320
|
e += s, t = t.slice(n.length);
|
|
2207
2321
|
if (t.length > 0)
|
|
2208
2322
|
return null;
|
|
2209
|
-
const i =
|
|
2323
|
+
const i = $t(e);
|
|
2210
2324
|
return !i || i !== r ? null : e;
|
|
2211
|
-
},
|
|
2325
|
+
}, yn = (r, t) => {
|
|
2212
2326
|
let e = 0;
|
|
2213
2327
|
return {
|
|
2214
2328
|
next() {
|
|
2215
2329
|
e += 1;
|
|
2216
|
-
const i = r + t * e, n =
|
|
2330
|
+
const i = r + t * e, n = $t(i);
|
|
2217
2331
|
return n ? { value: n, done: !1 } : { value: void 0, done: !0 };
|
|
2218
2332
|
}
|
|
2219
2333
|
};
|
|
2220
|
-
},
|
|
2334
|
+
}, wn = (r) => new RegExp("\\p{White_Space}", "u").test(r) ? "space" : new RegExp("\\p{P}", "u").test(r) ? "punct" : new RegExp("\\p{S}", "u").test(r) ? "symbol" : new RegExp("\\p{Script=Latin}", "u").test(r) ? "latin" : new RegExp("\\p{Script=Han}", "u").test(r) ? "han" : new RegExp("\\p{Script=Hiragana}", "u").test(r) ? "hiragana" : new RegExp("\\p{Script=Katakana}", "u").test(r) ? "katakana" : new RegExp("\\p{N}", "u").test(r) ? "number" : "other", vn = (r) => {
|
|
2221
2335
|
const t = [];
|
|
2222
2336
|
let e = "", i = null;
|
|
2223
2337
|
for (const n of r) {
|
|
2224
|
-
const s =
|
|
2338
|
+
const s = wn(n);
|
|
2225
2339
|
if (i === s) {
|
|
2226
2340
|
e += n;
|
|
2227
2341
|
continue;
|
|
@@ -2229,22 +2343,22 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2229
2343
|
i !== null && t.push({ value: e, group: i }), e = n, i = s;
|
|
2230
2344
|
}
|
|
2231
2345
|
return i !== null && t.push({ value: e, group: i }), t;
|
|
2232
|
-
},
|
|
2233
|
-
const t =
|
|
2346
|
+
}, Cn = (r) => {
|
|
2347
|
+
const t = vn(r), e = t.map((l, a) => ({ index: a, num: Se(l.value) })).filter((l) => l.num !== null);
|
|
2234
2348
|
if (e.length !== 1)
|
|
2235
2349
|
return null;
|
|
2236
2350
|
const i = e[0].index, n = e[0].num, s = t.slice(0, i).map((l) => l.value).join(""), o = t.slice(i + 1).map((l) => l.value).join("");
|
|
2237
2351
|
return { prefix: s, num: n, suffix: o };
|
|
2238
|
-
},
|
|
2352
|
+
}, Sn = (r, t, e) => {
|
|
2239
2353
|
let i = 0;
|
|
2240
2354
|
return {
|
|
2241
2355
|
next() {
|
|
2242
2356
|
i += 1;
|
|
2243
|
-
const n = t + e * i, s =
|
|
2357
|
+
const n = t + e * i, s = $t(n);
|
|
2244
2358
|
return s ? { value: `${r.prefix}${s}${r.suffix}`, done: !1 } : { value: void 0, done: !0 };
|
|
2245
2359
|
}
|
|
2246
2360
|
};
|
|
2247
|
-
},
|
|
2361
|
+
}, _t = {
|
|
2248
2362
|
一: 1,
|
|
2249
2363
|
二: 2,
|
|
2250
2364
|
三: 3,
|
|
@@ -2254,7 +2368,7 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2254
2368
|
七: 7,
|
|
2255
2369
|
八: 8,
|
|
2256
2370
|
九: 9
|
|
2257
|
-
},
|
|
2371
|
+
}, Nt = {
|
|
2258
2372
|
壱: 1,
|
|
2259
2373
|
弐: 2,
|
|
2260
2374
|
参: 3,
|
|
@@ -2264,42 +2378,42 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2264
2378
|
柒: 7,
|
|
2265
2379
|
捌: 8,
|
|
2266
2380
|
玖: 9
|
|
2267
|
-
},
|
|
2381
|
+
}, xe = {
|
|
2268
2382
|
十: 10,
|
|
2269
2383
|
拾: 10,
|
|
2270
2384
|
百: 100,
|
|
2271
2385
|
佰: 100,
|
|
2272
2386
|
千: 1e3,
|
|
2273
2387
|
仟: 1e3
|
|
2274
|
-
},
|
|
2388
|
+
}, xn = {
|
|
2275
2389
|
万: 1e4,
|
|
2276
2390
|
萬: 1e4
|
|
2277
|
-
},
|
|
2278
|
-
...Object.keys(
|
|
2279
|
-
...Object.keys(
|
|
2280
|
-
...Object.keys(
|
|
2281
|
-
...Object.keys(
|
|
2282
|
-
]),
|
|
2391
|
+
}, bn = /* @__PURE__ */ new Set([
|
|
2392
|
+
...Object.keys(_t),
|
|
2393
|
+
...Object.keys(Nt),
|
|
2394
|
+
...Object.keys(xe),
|
|
2395
|
+
...Object.keys(xn)
|
|
2396
|
+
]), Mn = (r) => bn.has(r), Rn = (r) => /[壱弐参肆伍陸柒捌玖拾萬佰仟]/.test(r) ? "traditional" : "modern", be = (r) => {
|
|
2283
2397
|
if (!r)
|
|
2284
2398
|
return null;
|
|
2285
|
-
const t =
|
|
2399
|
+
const t = Rn(r);
|
|
2286
2400
|
if (r.includes("万") || r.includes("萬")) {
|
|
2287
2401
|
const o = /^([一二三四五六七八九壱弐参肆伍陸柒捌玖])?(万|萬)$/.exec(r);
|
|
2288
2402
|
if (!o)
|
|
2289
2403
|
return null;
|
|
2290
2404
|
const l = o[1];
|
|
2291
|
-
return l ? (
|
|
2405
|
+
return l ? (_t[l] ?? Nt[l]) !== 1 ? null : { num: 1e4, style: t } : { num: 1e4, style: t };
|
|
2292
2406
|
}
|
|
2293
2407
|
let e = 0, i = 0, n = Number.POSITIVE_INFINITY, s = !1;
|
|
2294
2408
|
for (const o of r) {
|
|
2295
|
-
const l =
|
|
2409
|
+
const l = _t[o] ?? Nt[o];
|
|
2296
2410
|
if (l) {
|
|
2297
2411
|
if (s)
|
|
2298
2412
|
return null;
|
|
2299
2413
|
i = l, s = !0;
|
|
2300
2414
|
continue;
|
|
2301
2415
|
}
|
|
2302
|
-
const a =
|
|
2416
|
+
const a = xe[o];
|
|
2303
2417
|
if (a) {
|
|
2304
2418
|
if (a >= n)
|
|
2305
2419
|
return null;
|
|
@@ -2309,13 +2423,13 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2309
2423
|
return null;
|
|
2310
2424
|
}
|
|
2311
2425
|
return e += i, e <= 0 || e > 1e4 ? null : { num: e, style: t };
|
|
2312
|
-
},
|
|
2426
|
+
}, kn = (r) => {
|
|
2313
2427
|
const t = [];
|
|
2314
2428
|
let e = "", i = 0, n = 0;
|
|
2315
2429
|
for (const c of r)
|
|
2316
|
-
|
|
2430
|
+
Mn(c) ? (e || (i = n), e += c) : e && (t.push({ start: i, end: n, text: e }), e = ""), n += c.length;
|
|
2317
2431
|
e && t.push({ start: i, end: n, text: e });
|
|
2318
|
-
const s = t.map((c) => ({ run: c, parsed:
|
|
2432
|
+
const s = t.map((c) => ({ run: c, parsed: be(c.text) })).filter((c) => c.parsed !== null);
|
|
2319
2433
|
if (s.length !== 1)
|
|
2320
2434
|
return null;
|
|
2321
2435
|
const o = s[0], l = r.slice(0, o.run.start), a = r.slice(o.run.end);
|
|
@@ -2325,7 +2439,7 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2325
2439
|
suffix: a,
|
|
2326
2440
|
style: o.parsed.style
|
|
2327
2441
|
};
|
|
2328
|
-
},
|
|
2442
|
+
}, Me = (r, t) => {
|
|
2329
2443
|
if (!Number.isFinite(r) || r <= 0 || r > 1e4)
|
|
2330
2444
|
return null;
|
|
2331
2445
|
const e = t === "traditional" ? ["", "壱", "弐", "参", "肆", "伍", "陸", "柒", "捌", "玖"] : ["", "一", "二", "三", "四", "五", "六", "七", "八", "九"], i = t === "traditional" ? "拾" : "十", n = t === "traditional" ? "萬" : "万";
|
|
@@ -2338,174 +2452,194 @@ const he = 1e-9, qi = 100, Ui = (r) => ({
|
|
|
2338
2452
|
a > 0 && (a > 1 && (o += e[a]), o += "百", s %= 100);
|
|
2339
2453
|
const c = Math.floor(s / 10);
|
|
2340
2454
|
return c > 0 && (c > 1 && (o += e[c]), o += i, s %= 10), s > 0 && (o += e[s]), o || null;
|
|
2341
|
-
},
|
|
2455
|
+
}, In = (r, t, e) => {
|
|
2342
2456
|
let i = 0;
|
|
2343
2457
|
return {
|
|
2344
2458
|
next() {
|
|
2345
2459
|
i += 1;
|
|
2346
|
-
const n = r + t * i, s =
|
|
2460
|
+
const n = r + t * i, s = Me(n, e);
|
|
2347
2461
|
return s ? { value: s, done: !1 } : { value: void 0, done: !0 };
|
|
2348
2462
|
}
|
|
2349
2463
|
};
|
|
2350
|
-
},
|
|
2464
|
+
}, En = (r, t, e) => {
|
|
2351
2465
|
let i = 0;
|
|
2352
2466
|
return {
|
|
2353
2467
|
next() {
|
|
2354
2468
|
i += 1;
|
|
2355
|
-
const n = t + e * i, s =
|
|
2469
|
+
const n = t + e * i, s = Me(n, r.style);
|
|
2356
2470
|
return s ? { value: `${r.prefix}${s}${r.suffix}`, done: !1 } : { value: void 0, done: !0 };
|
|
2357
2471
|
}
|
|
2358
2472
|
};
|
|
2359
|
-
},
|
|
2473
|
+
}, Q = (r) => {
|
|
2360
2474
|
if (r.length < 2)
|
|
2361
2475
|
return null;
|
|
2362
2476
|
const t = r[1] - r[0];
|
|
2363
2477
|
for (let e = 2; e < r.length; e += 1)
|
|
2364
|
-
if (Math.abs(r[e] - r[e - 1] - t) >
|
|
2478
|
+
if (Math.abs(r[e] - r[e - 1] - t) > ve)
|
|
2365
2479
|
return null;
|
|
2366
2480
|
return t;
|
|
2367
|
-
},
|
|
2481
|
+
}, Tn = (r) => {
|
|
2368
2482
|
if (r.length < 2 || r[0] === 0)
|
|
2369
2483
|
return null;
|
|
2370
2484
|
const t = r[1] / r[0];
|
|
2371
2485
|
for (let e = 2; e < r.length; e += 1)
|
|
2372
|
-
if (r[e - 1] === 0 || Math.abs(r[e] / r[e - 1] - t) >
|
|
2486
|
+
if (r[e - 1] === 0 || Math.abs(r[e] / r[e - 1] - t) > ve)
|
|
2373
2487
|
return null;
|
|
2374
2488
|
return t;
|
|
2375
|
-
},
|
|
2376
|
-
const t = r.map((
|
|
2377
|
-
if (t.every(
|
|
2378
|
-
const
|
|
2379
|
-
if (
|
|
2380
|
-
(
|
|
2489
|
+
}, An = (r) => {
|
|
2490
|
+
const t = r.map((l) => gn(l));
|
|
2491
|
+
if (t.every((l) => l !== null)) {
|
|
2492
|
+
const l = t, a = l[0];
|
|
2493
|
+
if (l.every(
|
|
2494
|
+
(c) => c.prefix === a.prefix && c.suffix === a.suffix && c.format === a.format
|
|
2495
|
+
)) {
|
|
2496
|
+
const c = l.map((d) => d.num), h = Q(c);
|
|
2497
|
+
if (h !== null) {
|
|
2498
|
+
const d = l[l.length - 1];
|
|
2499
|
+
return {
|
|
2500
|
+
kind: "arithmetic",
|
|
2501
|
+
iterator: mn(
|
|
2502
|
+
{ prefix: a.prefix, suffix: a.suffix, format: a.format },
|
|
2503
|
+
d.num,
|
|
2504
|
+
h
|
|
2505
|
+
)
|
|
2506
|
+
};
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
const e = r.map((l) => fn(l));
|
|
2511
|
+
if (e.every(Boolean)) {
|
|
2512
|
+
const l = e[0], a = e[e.length - 1];
|
|
2513
|
+
if (e.every(
|
|
2514
|
+
(c) => c?.prefix === l.prefix && c?.suffix === l.suffix
|
|
2381
2515
|
)) {
|
|
2382
|
-
const
|
|
2383
|
-
if (
|
|
2516
|
+
const c = e.map((d) => d?.num ?? 0), h = Q(c);
|
|
2517
|
+
if (h !== null)
|
|
2384
2518
|
return {
|
|
2385
2519
|
kind: "arithmetic",
|
|
2386
|
-
iterator:
|
|
2387
|
-
{ prefix:
|
|
2388
|
-
|
|
2389
|
-
|
|
2520
|
+
iterator: pn(
|
|
2521
|
+
{ prefix: a.prefix, suffix: a.suffix, width: a.width },
|
|
2522
|
+
a.num,
|
|
2523
|
+
h
|
|
2390
2524
|
)
|
|
2391
2525
|
};
|
|
2392
2526
|
}
|
|
2393
2527
|
}
|
|
2394
|
-
const
|
|
2395
|
-
if (
|
|
2396
|
-
const
|
|
2397
|
-
if (
|
|
2398
|
-
const
|
|
2528
|
+
const i = r.map((l) => Se(l));
|
|
2529
|
+
if (i.every((l) => l !== null)) {
|
|
2530
|
+
const l = i, a = Q(l);
|
|
2531
|
+
if (a !== null) {
|
|
2532
|
+
const c = l[l.length - 1];
|
|
2399
2533
|
return {
|
|
2400
2534
|
kind: "arithmetic",
|
|
2401
|
-
iterator:
|
|
2535
|
+
iterator: yn(c, a)
|
|
2402
2536
|
};
|
|
2403
2537
|
}
|
|
2404
2538
|
}
|
|
2405
|
-
const
|
|
2406
|
-
if (
|
|
2407
|
-
const
|
|
2408
|
-
if (
|
|
2409
|
-
const
|
|
2410
|
-
if (
|
|
2411
|
-
const d =
|
|
2539
|
+
const n = r.map((l) => be(l));
|
|
2540
|
+
if (n.every((l) => l !== null)) {
|
|
2541
|
+
const l = n, a = l[0].style;
|
|
2542
|
+
if (l.every((c) => c.style === a)) {
|
|
2543
|
+
const c = l.map((d) => d.num), h = Q(c);
|
|
2544
|
+
if (h !== null) {
|
|
2545
|
+
const d = l[l.length - 1];
|
|
2412
2546
|
return {
|
|
2413
2547
|
kind: "arithmetic",
|
|
2414
|
-
iterator:
|
|
2548
|
+
iterator: In(d.num, h, d.style)
|
|
2415
2549
|
};
|
|
2416
2550
|
}
|
|
2417
2551
|
}
|
|
2418
2552
|
}
|
|
2419
|
-
const
|
|
2420
|
-
if (
|
|
2421
|
-
const
|
|
2422
|
-
if (
|
|
2423
|
-
(
|
|
2553
|
+
const s = r.map((l) => Cn(l));
|
|
2554
|
+
if (s.every((l) => l !== null)) {
|
|
2555
|
+
const l = s, a = l[0];
|
|
2556
|
+
if (l.every(
|
|
2557
|
+
(c) => c.prefix === a.prefix && c.suffix === a.suffix
|
|
2424
2558
|
)) {
|
|
2425
|
-
const
|
|
2426
|
-
if (
|
|
2427
|
-
const d =
|
|
2559
|
+
const c = l.map((d) => d.num), h = Q(c);
|
|
2560
|
+
if (h !== null) {
|
|
2561
|
+
const d = c[c.length - 1];
|
|
2428
2562
|
return {
|
|
2429
2563
|
kind: "arithmetic",
|
|
2430
|
-
iterator:
|
|
2431
|
-
{ prefix:
|
|
2564
|
+
iterator: Sn(
|
|
2565
|
+
{ prefix: a.prefix, suffix: a.suffix },
|
|
2432
2566
|
d,
|
|
2433
|
-
|
|
2567
|
+
h
|
|
2434
2568
|
)
|
|
2435
2569
|
};
|
|
2436
2570
|
}
|
|
2437
2571
|
}
|
|
2438
2572
|
}
|
|
2439
|
-
const
|
|
2440
|
-
if (
|
|
2441
|
-
const
|
|
2442
|
-
if (
|
|
2443
|
-
(
|
|
2573
|
+
const o = r.map((l) => kn(l));
|
|
2574
|
+
if (o.every((l) => l !== null)) {
|
|
2575
|
+
const l = o, a = l[0];
|
|
2576
|
+
if (l.every(
|
|
2577
|
+
(c) => c.prefix === a.prefix && c.suffix === a.suffix && c.style === a.style
|
|
2444
2578
|
)) {
|
|
2445
|
-
const
|
|
2446
|
-
if (
|
|
2447
|
-
const d =
|
|
2579
|
+
const c = l.map((d) => d.num), h = Q(c);
|
|
2580
|
+
if (h !== null) {
|
|
2581
|
+
const d = l[l.length - 1];
|
|
2448
2582
|
return {
|
|
2449
2583
|
kind: "arithmetic",
|
|
2450
|
-
iterator:
|
|
2451
|
-
{ prefix:
|
|
2584
|
+
iterator: En(
|
|
2585
|
+
{ prefix: a.prefix, suffix: a.suffix, style: a.style },
|
|
2452
2586
|
d.num,
|
|
2453
|
-
|
|
2587
|
+
h
|
|
2454
2588
|
)
|
|
2455
2589
|
};
|
|
2456
2590
|
}
|
|
2457
2591
|
}
|
|
2458
2592
|
}
|
|
2459
2593
|
return null;
|
|
2460
|
-
},
|
|
2594
|
+
}, Hn = (r, t) => {
|
|
2461
2595
|
const e = t.match(r);
|
|
2462
2596
|
return e ? {
|
|
2463
2597
|
kind: "list",
|
|
2464
|
-
iterator:
|
|
2598
|
+
iterator: cn(e, r)
|
|
2465
2599
|
} : null;
|
|
2466
2600
|
};
|
|
2467
|
-
function
|
|
2468
|
-
const e = t?.registry ??
|
|
2601
|
+
function Lt(r, t) {
|
|
2602
|
+
const e = t?.registry ?? we();
|
|
2469
2603
|
if (r.length === 0)
|
|
2470
|
-
return X.fromSeed(r, "seed-repeat",
|
|
2604
|
+
return X.fromSeed(r, "seed-repeat", le(r));
|
|
2471
2605
|
if (r.length === 1)
|
|
2472
|
-
return X.fromSeed(r, "copy",
|
|
2473
|
-
if (
|
|
2474
|
-
const i =
|
|
2606
|
+
return X.fromSeed(r, "copy", on(r[0]));
|
|
2607
|
+
if (un(r)) {
|
|
2608
|
+
const i = Hn(r, e);
|
|
2475
2609
|
if (i)
|
|
2476
2610
|
return X.fromSeed(r, i.kind, i.iterator);
|
|
2477
|
-
const n =
|
|
2611
|
+
const n = An(r);
|
|
2478
2612
|
if (n)
|
|
2479
2613
|
return X.fromSeed(r, n.kind, n.iterator);
|
|
2480
2614
|
}
|
|
2481
|
-
if (
|
|
2482
|
-
const i =
|
|
2615
|
+
if (dn(r)) {
|
|
2616
|
+
const i = Q(r);
|
|
2483
2617
|
if (i !== null)
|
|
2484
2618
|
return X.fromSeed(
|
|
2485
2619
|
r,
|
|
2486
2620
|
"arithmetic",
|
|
2487
|
-
|
|
2621
|
+
rn(r[r.length - 1], i)
|
|
2488
2622
|
);
|
|
2489
|
-
const n =
|
|
2623
|
+
const n = Tn(r);
|
|
2490
2624
|
if (n !== null)
|
|
2491
2625
|
return X.fromSeed(
|
|
2492
2626
|
r,
|
|
2493
2627
|
"geometric",
|
|
2494
|
-
|
|
2628
|
+
an(r[r.length - 1], n)
|
|
2495
2629
|
);
|
|
2496
2630
|
}
|
|
2497
|
-
if (
|
|
2498
|
-
const i = r.map((s) => s.getTime()), n =
|
|
2631
|
+
if (hn(r)) {
|
|
2632
|
+
const i = r.map((s) => s.getTime()), n = Q(i);
|
|
2499
2633
|
if (n !== null)
|
|
2500
2634
|
return X.fromSeed(
|
|
2501
2635
|
r,
|
|
2502
2636
|
"arithmetic",
|
|
2503
|
-
|
|
2637
|
+
ln(r[r.length - 1], n)
|
|
2504
2638
|
);
|
|
2505
2639
|
}
|
|
2506
|
-
return X.fromSeed(r, "seed-repeat",
|
|
2640
|
+
return X.fromSeed(r, "seed-repeat", le(r));
|
|
2507
2641
|
}
|
|
2508
|
-
function
|
|
2642
|
+
function Dn(r) {
|
|
2509
2643
|
return {
|
|
2510
2644
|
...r,
|
|
2511
2645
|
startRow: Math.min(r.startRow, r.endRow),
|
|
@@ -2514,7 +2648,7 @@ function wn(r) {
|
|
|
2514
2648
|
endCol: Math.max(r.startCol, r.endCol)
|
|
2515
2649
|
};
|
|
2516
2650
|
}
|
|
2517
|
-
function
|
|
2651
|
+
function Kn(r) {
|
|
2518
2652
|
if (r instanceof Date) return r;
|
|
2519
2653
|
if (typeof r == "number" && Number.isFinite(r)) return new Date(r);
|
|
2520
2654
|
if (typeof r == "string") {
|
|
@@ -2528,7 +2662,7 @@ function Cn(r) {
|
|
|
2528
2662
|
}
|
|
2529
2663
|
return null;
|
|
2530
2664
|
}
|
|
2531
|
-
function
|
|
2665
|
+
function Ln(r) {
|
|
2532
2666
|
if (r instanceof Date) return r;
|
|
2533
2667
|
if (typeof r == "number" && Number.isFinite(r)) return new Date(r);
|
|
2534
2668
|
if (typeof r == "string") {
|
|
@@ -2537,9 +2671,9 @@ function vn(r) {
|
|
|
2537
2671
|
}
|
|
2538
2672
|
return null;
|
|
2539
2673
|
}
|
|
2540
|
-
function
|
|
2674
|
+
function Re(r, t) {
|
|
2541
2675
|
if (t.length !== 1) return null;
|
|
2542
|
-
const e =
|
|
2676
|
+
const e = Dn(t[0]);
|
|
2543
2677
|
if (e.kind !== "cells") return null;
|
|
2544
2678
|
const i = e.endCol - e.startCol + 1, n = e.endRow - e.startRow + 1;
|
|
2545
2679
|
if (i !== 1 || n < 1) return null;
|
|
@@ -2558,7 +2692,7 @@ function ye(r, t) {
|
|
|
2558
2692
|
mode: "sequence"
|
|
2559
2693
|
} : null : null;
|
|
2560
2694
|
}
|
|
2561
|
-
function
|
|
2695
|
+
function Vn(r, t, e) {
|
|
2562
2696
|
const i = r.getSchema(), n = r.listRows(), s = i.columns[t.colIndex];
|
|
2563
2697
|
if (!s) return null;
|
|
2564
2698
|
const o = [];
|
|
@@ -2571,73 +2705,73 @@ function Sn(r, t, e) {
|
|
|
2571
2705
|
const a = o[o.length - 1];
|
|
2572
2706
|
return () => a;
|
|
2573
2707
|
}
|
|
2574
|
-
const l =
|
|
2708
|
+
const l = we(e);
|
|
2575
2709
|
if (s.type === "number") {
|
|
2576
2710
|
const a = o.map((u) => typeof u == "number" ? u : Number(u));
|
|
2577
2711
|
if (!a.every((u) => Number.isFinite(u))) return null;
|
|
2578
|
-
const c =
|
|
2579
|
-
let
|
|
2712
|
+
const c = Lt(a, { registry: l }), h = [];
|
|
2713
|
+
let d = !1;
|
|
2580
2714
|
return (u) => {
|
|
2581
|
-
for (; !
|
|
2715
|
+
for (; !d && h.length < u; ) {
|
|
2582
2716
|
const g = c.next();
|
|
2583
2717
|
if (g.done) {
|
|
2584
|
-
|
|
2718
|
+
d = !0;
|
|
2585
2719
|
break;
|
|
2586
2720
|
}
|
|
2587
|
-
|
|
2721
|
+
h.push(g.value);
|
|
2588
2722
|
}
|
|
2589
|
-
return u <= 0 ? null :
|
|
2723
|
+
return u <= 0 ? null : h[u - 1] ?? null;
|
|
2590
2724
|
};
|
|
2591
2725
|
}
|
|
2592
2726
|
if (s.type === "date" || s.type === "time" || s.type === "datetime") {
|
|
2593
2727
|
const a = o.map(
|
|
2594
|
-
(u) => s.type === "time" ?
|
|
2728
|
+
(u) => s.type === "time" ? Kn(u) : Ln(u)
|
|
2595
2729
|
);
|
|
2596
2730
|
if (!a.every((u) => u instanceof Date)) return null;
|
|
2597
|
-
const c =
|
|
2598
|
-
let
|
|
2731
|
+
const c = Lt(a, { registry: l }), h = [];
|
|
2732
|
+
let d = !1;
|
|
2599
2733
|
return (u) => {
|
|
2600
|
-
for (; !
|
|
2734
|
+
for (; !d && h.length < u; ) {
|
|
2601
2735
|
const g = c.next();
|
|
2602
2736
|
if (g.done) {
|
|
2603
|
-
|
|
2737
|
+
d = !0;
|
|
2604
2738
|
break;
|
|
2605
2739
|
}
|
|
2606
|
-
|
|
2740
|
+
h.push(g.value);
|
|
2607
2741
|
}
|
|
2608
|
-
return u <= 0 ? null :
|
|
2742
|
+
return u <= 0 ? null : h[u - 1] ?? null;
|
|
2609
2743
|
};
|
|
2610
2744
|
}
|
|
2611
2745
|
if (s.type === "string") {
|
|
2612
|
-
const a = o.map((u) => String(u ?? "")), c =
|
|
2613
|
-
let
|
|
2746
|
+
const a = o.map((u) => String(u ?? "")), c = Lt(a, { registry: l }), h = [];
|
|
2747
|
+
let d = !1;
|
|
2614
2748
|
return (u) => {
|
|
2615
|
-
for (; !
|
|
2749
|
+
for (; !d && h.length < u; ) {
|
|
2616
2750
|
const g = c.next();
|
|
2617
2751
|
if (g.done) {
|
|
2618
|
-
|
|
2752
|
+
d = !0;
|
|
2619
2753
|
break;
|
|
2620
2754
|
}
|
|
2621
|
-
|
|
2755
|
+
h.push(g.value);
|
|
2622
2756
|
}
|
|
2623
|
-
return u <= 0 ? null :
|
|
2757
|
+
return u <= 0 ? null : h[u - 1] ?? null;
|
|
2624
2758
|
};
|
|
2625
2759
|
}
|
|
2626
2760
|
return null;
|
|
2627
2761
|
}
|
|
2628
|
-
const
|
|
2629
|
-
function
|
|
2762
|
+
const ke = 12, Ie = 14;
|
|
2763
|
+
function Ee(r, t = ke) {
|
|
2630
2764
|
return new DOMRect(r.right - t - 1, r.bottom - t - 1, t, t);
|
|
2631
2765
|
}
|
|
2632
|
-
function
|
|
2766
|
+
function Te(r, t, e) {
|
|
2633
2767
|
return r >= e.left && r <= e.right && t >= e.top && t <= e.bottom;
|
|
2634
2768
|
}
|
|
2635
|
-
function
|
|
2769
|
+
function Mt(r, t, e, i, n) {
|
|
2636
2770
|
if (n === "readonly") return !1;
|
|
2637
|
-
const s =
|
|
2771
|
+
const s = Re(r, t);
|
|
2638
2772
|
return !(!s || !e || e === "__all__" || i === null || i === "__all__" || i === null || i !== s.colKey || r.isReadonly(e, i));
|
|
2639
2773
|
}
|
|
2640
|
-
function
|
|
2774
|
+
function Rt(r) {
|
|
2641
2775
|
const t = r.style, e = t?.decorations;
|
|
2642
2776
|
return {
|
|
2643
2777
|
backgroundColor: t?.backgroundColor,
|
|
@@ -2650,7 +2784,7 @@ function Mt(r) {
|
|
|
2650
2784
|
disabled: t?.disabled
|
|
2651
2785
|
};
|
|
2652
2786
|
}
|
|
2653
|
-
function
|
|
2787
|
+
function J(r, t) {
|
|
2654
2788
|
return t ? {
|
|
2655
2789
|
backgroundColor: t.backgroundColor ?? r.backgroundColor,
|
|
2656
2790
|
textColor: t.textColor ?? r.textColor,
|
|
@@ -2662,11 +2796,11 @@ function Q(r, t) {
|
|
|
2662
2796
|
disabled: t.disabled ?? r.disabled
|
|
2663
2797
|
} : r;
|
|
2664
2798
|
}
|
|
2665
|
-
function
|
|
2666
|
-
const i =
|
|
2799
|
+
function Fn(r, t, e) {
|
|
2800
|
+
const i = Rt(e), n = r.resolveConditionalStyle(t, e).delta ?? {}, s = r.getCellStyle(t, e.key) ?? {}, o = J(J(i, n), s);
|
|
2667
2801
|
return { columnStyle: i, cellStyle: s, resolved: o };
|
|
2668
2802
|
}
|
|
2669
|
-
function
|
|
2803
|
+
function ae(r) {
|
|
2670
2804
|
let t = "";
|
|
2671
2805
|
r.backgroundColor && (t += `background-color:${r.backgroundColor};`), r.textColor && (t += `color:${r.textColor};`), r.bold && (t += "font-weight:600;"), r.italic && (t += "font-style:italic;");
|
|
2672
2806
|
const e = [];
|
|
@@ -2678,7 +2812,7 @@ function ut(r) {
|
|
|
2678
2812
|
const t = r, e = t.label, i = t.command, n = t.commandfor;
|
|
2679
2813
|
return typeof e != "string" ? null : typeof i == "string" && typeof n == "string" ? { label: e, command: i, commandfor: n } : null;
|
|
2680
2814
|
}
|
|
2681
|
-
function
|
|
2815
|
+
function rt(r) {
|
|
2682
2816
|
if (typeof r == "string") return r;
|
|
2683
2817
|
if (!r || typeof r != "object") return "";
|
|
2684
2818
|
const t = r.label;
|
|
@@ -2690,17 +2824,17 @@ function ft(r) {
|
|
|
2690
2824
|
const t = r, e = t.label, i = t.href, n = t.target;
|
|
2691
2825
|
return typeof e != "string" || typeof i != "string" ? null : typeof n == "string" ? { label: e, href: i, target: n } : n === void 0 ? { label: e, href: i } : null;
|
|
2692
2826
|
}
|
|
2693
|
-
function
|
|
2827
|
+
function lt(r) {
|
|
2694
2828
|
if (typeof r == "string") return r;
|
|
2695
2829
|
if (!r || typeof r != "object") return "";
|
|
2696
2830
|
const t = r, e = t.label, i = t.href;
|
|
2697
2831
|
return typeof e == "string" ? e : typeof i == "string" ? i : "";
|
|
2698
2832
|
}
|
|
2699
|
-
function
|
|
2833
|
+
function Ae(r, t) {
|
|
2700
2834
|
const e = r.sorts?.[0];
|
|
2701
2835
|
return e && e.key === t ? e.dir : null;
|
|
2702
2836
|
}
|
|
2703
|
-
function
|
|
2837
|
+
function He(r, t) {
|
|
2704
2838
|
if ((r.filters ?? []).some((n) => {
|
|
2705
2839
|
const s = n;
|
|
2706
2840
|
return s?.kind === "values" && s.key === t;
|
|
@@ -2708,27 +2842,27 @@ function be(r, t) {
|
|
|
2708
2842
|
const i = r.columnDiagnostics?.[t];
|
|
2709
2843
|
return !!(i?.errors || i?.warnings);
|
|
2710
2844
|
}
|
|
2711
|
-
function
|
|
2845
|
+
function _n() {
|
|
2712
2846
|
return `
|
|
2713
2847
|
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false">
|
|
2714
2848
|
<path d="M3 5h18l-7 8v6l-4 2v-8L3 5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/>
|
|
2715
2849
|
</svg>
|
|
2716
2850
|
`.trim();
|
|
2717
2851
|
}
|
|
2718
|
-
function
|
|
2852
|
+
function Nn(r) {
|
|
2719
2853
|
return `
|
|
2720
2854
|
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false">
|
|
2721
2855
|
<path d="${r === "asc" ? "M12 6l6 8H6l6-8z" : "M12 18l-6-8h12l-6 8z"}" fill="currentColor"/>
|
|
2722
2856
|
</svg>
|
|
2723
2857
|
`.trim();
|
|
2724
2858
|
}
|
|
2725
|
-
function
|
|
2859
|
+
function Bn(r, t, e, i, n, s) {
|
|
2726
2860
|
const o = Math.min(10, Math.floor(Math.min(i, n) / 2));
|
|
2727
2861
|
if (o <= 0) return;
|
|
2728
2862
|
const l = s === "error" ? "#ef4444" : "#f59e0b";
|
|
2729
2863
|
r.save(), r.fillStyle = l, r.beginPath(), r.moveTo(t + i, e), r.lineTo(t + i - o, e), r.lineTo(t + i, e + o), r.closePath(), r.fill(), r.restore();
|
|
2730
2864
|
}
|
|
2731
|
-
class
|
|
2865
|
+
class De {
|
|
2732
2866
|
constructor() {
|
|
2733
2867
|
this.numberFormatCache = /* @__PURE__ */ new Map(), this.dateParseCache = /* @__PURE__ */ new Map();
|
|
2734
2868
|
}
|
|
@@ -2740,22 +2874,35 @@ class Re {
|
|
|
2740
2874
|
parseIsoDate(t) {
|
|
2741
2875
|
const e = this.dateParseCache.get(t);
|
|
2742
2876
|
if (e) return e;
|
|
2743
|
-
const i =
|
|
2877
|
+
const i = Pt(t);
|
|
2744
2878
|
return !i || Number.isNaN(i.getTime()) ? null : (this.dateParseCache.set(t, i), i);
|
|
2745
2879
|
}
|
|
2746
2880
|
}
|
|
2747
|
-
function
|
|
2881
|
+
function Pn(r, t, e, i, n) {
|
|
2748
2882
|
r.save(), r.globalAlpha = n, r.strokeStyle = "rgba(15,23,42,1)", r.lineWidth = 2, r.lineJoin = "round", r.beginPath(), r.moveTo(t, e), r.lineTo(t + i, e), r.lineTo(t + Math.round(i * 0.62), e + Math.round(i * 0.46)), r.lineTo(t + Math.round(i * 0.38), e + Math.round(i * 0.46)), r.closePath(), r.stroke(), r.beginPath(), r.moveTo(t + Math.round(i * 0.46), e + Math.round(i * 0.46)), r.lineTo(t + Math.round(i * 0.46), e + i), r.lineTo(t + Math.round(i * 0.54), e + i - 2), r.lineTo(t + Math.round(i * 0.54), e + Math.round(i * 0.46)), r.stroke(), r.restore();
|
|
2749
2883
|
}
|
|
2750
|
-
function
|
|
2884
|
+
function $n(r, t, e, i, n, s) {
|
|
2751
2885
|
r.save(), r.globalAlpha = n, r.fillStyle = "rgba(15,23,42,1)", r.beginPath(), s === "asc" ? (r.moveTo(t + i / 2, e), r.lineTo(t + i, e + i), r.lineTo(t, e + i)) : (r.moveTo(t, e), r.lineTo(t + i, e), r.lineTo(t + i / 2, e + i)), r.closePath(), r.fill(), r.restore();
|
|
2752
2886
|
}
|
|
2753
|
-
|
|
2887
|
+
function Bt(r) {
|
|
2888
|
+
if (Array.isArray(r) && r.every((t) => typeof t == "string"))
|
|
2889
|
+
return r;
|
|
2890
|
+
if (r && typeof r == "object") {
|
|
2891
|
+
const t = r;
|
|
2892
|
+
if (t.kind === "tags") {
|
|
2893
|
+
const e = t.values;
|
|
2894
|
+
if (Array.isArray(e))
|
|
2895
|
+
return e.filter((i) => typeof i == "string");
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
return null;
|
|
2899
|
+
}
|
|
2900
|
+
class Ot {
|
|
2754
2901
|
constructor(t) {
|
|
2755
2902
|
this.n = t, this.tree = new Array(t + 1).fill(0);
|
|
2756
2903
|
}
|
|
2757
2904
|
static from(t) {
|
|
2758
|
-
const e = new
|
|
2905
|
+
const e = new Ot(t.length);
|
|
2759
2906
|
for (let i = 0; i < t.length; i += 1) e.add(i, t[i] ?? 0);
|
|
2760
2907
|
return e;
|
|
2761
2908
|
}
|
|
@@ -2797,7 +2944,7 @@ class Nt {
|
|
|
2797
2944
|
}
|
|
2798
2945
|
class bt {
|
|
2799
2946
|
constructor(t) {
|
|
2800
|
-
this.dataModel = t, this.tableEl = null, this.defaultRowHeight = ht, this.rowHeaderWidth =
|
|
2947
|
+
this.dataModel = t, this.tableEl = null, this.defaultRowHeight = ht, this.rowHeaderWidth = st, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new De(), this.measureCache = /* @__PURE__ */ new Map(), this.frame = 0;
|
|
2801
2948
|
}
|
|
2802
2949
|
mount(t) {
|
|
2803
2950
|
this.tableEl = document.createElement("table"), this.tableEl.dataset.extableRenderer = "html", t.innerHTML = "", t.appendChild(this.tableEl), this.render();
|
|
@@ -2812,22 +2959,22 @@ class bt {
|
|
|
2812
2959
|
if (this.frame += 1, !this.tableEl) return;
|
|
2813
2960
|
const e = this.tableEl.parentElement, i = e?.scrollTop ?? 0, n = e?.scrollLeft ?? 0, s = this.dataModel.getSchema(), o = this.dataModel.getView(), l = this.dataModel.listRows();
|
|
2814
2961
|
this.tableEl.innerHTML = "";
|
|
2815
|
-
const a = G(s, o), c = s.columns.map((p) =>
|
|
2962
|
+
const a = G(s, o), c = s.columns.map((p) => Rt(p)), h = c.map((p) => ae(p)), d = this.rowHeaderWidth + a.reduce((p, v) => p + (v ?? 0), 0), u = document.createElement("colgroup"), g = document.createElement("col");
|
|
2816
2963
|
g.style.width = `${this.rowHeaderWidth}px`, u.appendChild(g);
|
|
2817
2964
|
for (const p of a) {
|
|
2818
|
-
const
|
|
2819
|
-
p && (
|
|
2965
|
+
const v = document.createElement("col");
|
|
2966
|
+
p && (v.style.width = `${p}px`), u.appendChild(v);
|
|
2820
2967
|
}
|
|
2821
|
-
this.tableEl.appendChild(u), this.tableEl.style.width = `${
|
|
2968
|
+
this.tableEl.appendChild(u), this.tableEl.style.width = `${d}px`, this.tableEl.appendChild(this.renderHeader(s, a));
|
|
2822
2969
|
const m = document.createElement("tbody");
|
|
2823
2970
|
for (const p of l)
|
|
2824
|
-
m.appendChild(this.renderRow(p, s, a, c,
|
|
2971
|
+
m.appendChild(this.renderRow(p, s, a, c, h));
|
|
2825
2972
|
this.tableEl.appendChild(m), this.updateActiveClasses(), this.applySelectionClasses(), e && (e.scrollTop = i, e.scrollLeft = n);
|
|
2826
|
-
for (const [p,
|
|
2827
|
-
|
|
2973
|
+
for (const [p, v] of Array.from(this.measureCache.entries()))
|
|
2974
|
+
v.frame !== this.frame && this.measureCache.delete(p);
|
|
2828
2975
|
}
|
|
2829
2976
|
destroy() {
|
|
2830
|
-
|
|
2977
|
+
j(this.tableEl), this.tableEl = null;
|
|
2831
2978
|
}
|
|
2832
2979
|
getCellElements() {
|
|
2833
2980
|
return this.tableEl?.querySelectorAll("tr[data-row-id] td[data-col-key]") ?? null;
|
|
@@ -2865,15 +3012,27 @@ class bt {
|
|
|
2865
3012
|
hitTestAction(t) {
|
|
2866
3013
|
const e = t.target;
|
|
2867
3014
|
if (!e) return null;
|
|
2868
|
-
const i = e.closest("[data-extable-
|
|
2869
|
-
if (!i)
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
3015
|
+
const i = e.closest("[data-extable-tag-remove]");
|
|
3016
|
+
if (i && !i.disabled) {
|
|
3017
|
+
const a = i.closest("td[data-col-key]"), c = a?.closest("tr[data-row-id]");
|
|
3018
|
+
if (!a || !c) return null;
|
|
3019
|
+
const h = i.dataset.extableTagIndex, d = h ? Number.parseInt(h, 10) : Number.NaN;
|
|
3020
|
+
return Number.isFinite(d) ? {
|
|
3021
|
+
rowId: c.dataset.rowId ?? "",
|
|
3022
|
+
colKey: a.dataset.colKey ?? "",
|
|
3023
|
+
kind: "tag-remove",
|
|
3024
|
+
tagIndex: d
|
|
3025
|
+
} : null;
|
|
3026
|
+
}
|
|
3027
|
+
const n = e.closest("[data-extable-action]");
|
|
3028
|
+
if (!n) return null;
|
|
3029
|
+
const s = n.closest("td[data-col-key]"), o = s?.closest("tr[data-row-id]");
|
|
3030
|
+
if (!s || !o) return null;
|
|
3031
|
+
const l = n.dataset.extableAction;
|
|
3032
|
+
return l !== "button" && l !== "link" ? null : {
|
|
3033
|
+
rowId: o.dataset.rowId ?? "",
|
|
3034
|
+
colKey: s.dataset.colKey ?? "",
|
|
3035
|
+
kind: l
|
|
2877
3036
|
};
|
|
2878
3037
|
}
|
|
2879
3038
|
renderHeader(t, e) {
|
|
@@ -2885,14 +3044,14 @@ class bt {
|
|
|
2885
3044
|
if (!a) continue;
|
|
2886
3045
|
const c = document.createElement("th");
|
|
2887
3046
|
c.dataset.colKey = a.key;
|
|
2888
|
-
const
|
|
2889
|
-
|
|
3047
|
+
const h = Ae(o, a.key), d = He(o, a.key);
|
|
3048
|
+
h ? c.dataset.extableSortDir = h : c.removeAttribute("data-extable-sort-dir"), d ? c.dataset.extableFsActive = "1" : c.removeAttribute("data-extable-fs-active");
|
|
2890
3049
|
const u = document.createElement("div");
|
|
2891
3050
|
u.className = "extable-col-header";
|
|
2892
3051
|
const g = document.createElement("span");
|
|
2893
3052
|
g.className = "extable-col-header-text", g.textContent = a.header ?? a.key;
|
|
2894
3053
|
const m = document.createElement("button");
|
|
2895
|
-
m.type = "button", m.className = "extable-filter-sort-trigger", m.dataset.extableFsOpen = "1", m.dataset.extableColKey = a.key, m.title = "Filter / Sort", m.innerHTML =
|
|
3054
|
+
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 ? Nn(h) : _n(), u.appendChild(g), u.appendChild(m), c.appendChild(u);
|
|
2896
3055
|
const p = e[l] ?? a.width;
|
|
2897
3056
|
p && (c.style.width = `${p}px`), c.dataset.colKey = a.key, this.activeColKey !== null && this.activeColKey === a.key && c.classList.add("extable-active-col-header"), n.appendChild(c);
|
|
2898
3057
|
}
|
|
@@ -2905,50 +3064,60 @@ class bt {
|
|
|
2905
3064
|
a.scope = "row", a.classList.add("extable-row-header");
|
|
2906
3065
|
const c = this.dataModel.getDisplayIndex(t.id) ?? "";
|
|
2907
3066
|
a.textContent = String(c), a.style.width = `${this.rowHeaderWidth}px`, this.activeRowId === t.id && a.classList.add("extable-active-row-header"), o.appendChild(a);
|
|
2908
|
-
for (let
|
|
2909
|
-
const u = e.columns[
|
|
3067
|
+
for (let d = 0; d < e.columns.length; d += 1) {
|
|
3068
|
+
const u = e.columns[d];
|
|
2910
3069
|
if (!u) continue;
|
|
2911
3070
|
const g = document.createElement("td");
|
|
2912
3071
|
g.classList.add("extable-cell"), g.dataset.colKey = u.key, u.type === "boolean" && g.classList.add("extable-boolean");
|
|
2913
|
-
const m = this.dataModel.hasPending(t.id, u.key), p = this.dataModel.resolveConditionalStyle(t.id, u),
|
|
2914
|
-
if (!
|
|
2915
|
-
const
|
|
2916
|
-
|
|
3072
|
+
const m = this.dataModel.hasPending(t.id, u.key), p = this.dataModel.resolveConditionalStyle(t.id, u), v = this.dataModel.getCellStyle(t.id, u.key), f = !!(v?.textColor || p.delta?.textColor || u.style?.textColor);
|
|
3073
|
+
if (!v && !p.delta && !m) {
|
|
3074
|
+
const E = s[d] ?? "";
|
|
3075
|
+
E && (g.style.cssText = E);
|
|
2917
3076
|
} else {
|
|
2918
|
-
const
|
|
2919
|
-
|
|
3077
|
+
const E = n[d] ?? {}, B = p.delta ? J(E, p.delta) : E, T = v ? J(B, v) : B, A = m ? { ...T, textColor: void 0 } : T, k = ae(A);
|
|
3078
|
+
k && (g.style.cssText = k);
|
|
2920
3079
|
}
|
|
2921
|
-
const y = i[
|
|
3080
|
+
const y = i[d] ?? l.columnWidths?.[u.key] ?? u.width;
|
|
2922
3081
|
y && (g.style.width = `${y}px`);
|
|
2923
3082
|
const w = l.wrapText?.[u.key] ?? u.wrapText;
|
|
2924
3083
|
g.classList.add(w ? "cell-wrap" : "cell-nowrap");
|
|
2925
|
-
const
|
|
2926
|
-
if (
|
|
2927
|
-
const
|
|
2928
|
-
|
|
3084
|
+
const C = this.dataModel.getRawCell(t.id, u.key), S = this.dataModel.resolveCellValue(t.id, u), b = S.textOverride ?? (p.forceErrorText ? "#ERROR" : void 0), x = b ? { text: b } : this.formatValue(S.value, u), D = this.dataModel.getCellInteraction(t.id, u.key), F = u.type === "tags" && !b ? Bt(S.value) : null, R = u.type === "button" || u.type === "link", H = R ? u.type === "button" ? ut(S.value) : ft(S.value) : null, M = R ? u.type === "button" ? rt(S.value) : lt(S.value) : "";
|
|
3085
|
+
if (F && F.length) {
|
|
3086
|
+
const E = document.createElement("div");
|
|
3087
|
+
E.className = "extable-tag-list", F.forEach((B, T) => {
|
|
3088
|
+
const A = document.createElement("span");
|
|
3089
|
+
A.className = "extable-tag";
|
|
3090
|
+
const k = document.createElement("span");
|
|
3091
|
+
k.className = "extable-tag-label", k.textContent = B;
|
|
3092
|
+
const N = document.createElement("button");
|
|
3093
|
+
N.type = "button", N.className = "extable-tag-remove", N.dataset.extableTagRemove = "1", N.dataset.extableTagIndex = String(T), N.textContent = "×", (D.readonly || D.disabled) && (N.disabled = !0), A.appendChild(k), A.appendChild(N), E.appendChild(A);
|
|
3094
|
+
}), g.replaceChildren(E);
|
|
3095
|
+
} else if (R && !b && H && M) {
|
|
3096
|
+
const E = u.type === "button" ? document.createElement("button") : document.createElement("span");
|
|
3097
|
+
E instanceof HTMLButtonElement && (E.type = "button"), E.className = u.type === "button" ? "extable-action-button" : "extable-action-link", D.disabled && E.classList.add("extable-action-disabled"), u.type === "link" && f && (E.style.color = "inherit"), E.dataset.extableAction = u.type, E.textContent = M, g.replaceChildren(E);
|
|
2929
3098
|
} else
|
|
2930
|
-
g.textContent =
|
|
2931
|
-
const
|
|
2932
|
-
|
|
2933
|
-
const
|
|
2934
|
-
g.classList.add(
|
|
2935
|
-
const
|
|
2936
|
-
if (
|
|
2937
|
-
g.dataset.raw =
|
|
3099
|
+
g.textContent = M || x.text, x.color && (g.style.color = x.color);
|
|
3100
|
+
const K = this.dataModel.getCellMarker(t.id, u.key);
|
|
3101
|
+
K ? (g.classList.toggle("extable-diag-warning", K.level === "warning"), g.classList.toggle("extable-diag-error", K.level === "error"), g.dataset.extableDiagMessage = K.message) : (g.classList.remove("extable-diag-warning", "extable-diag-error"), g.removeAttribute("data-extable-diag-message"));
|
|
3102
|
+
const L = u.style?.align ?? (u.type === "number" ? "right" : "left");
|
|
3103
|
+
g.classList.add(L === "right" ? "align-right" : "align-left");
|
|
3104
|
+
const _ = Je(C, S.value, u);
|
|
3105
|
+
if (_ !== null)
|
|
3106
|
+
g.dataset.raw = _;
|
|
2938
3107
|
else {
|
|
2939
|
-
const
|
|
2940
|
-
g.dataset.raw =
|
|
3108
|
+
const E = C == null ? "" : String(C);
|
|
3109
|
+
g.dataset.raw = E;
|
|
2941
3110
|
}
|
|
2942
|
-
m && g.classList.add("pending"),
|
|
3111
|
+
m && g.classList.add("pending"), D.readonly ? g.classList.add("extable-readonly") : g.classList.add("extable-editable"), D.muted && g.classList.add("extable-readonly-muted"), D.disabled && g.classList.add("extable-disabled"), this.activeRowId === t.id && this.activeColKey !== null && this.activeColKey === u.key && g.classList.add("extable-active-cell"), o.appendChild(g);
|
|
2943
3112
|
}
|
|
2944
|
-
if (e.columns.some((
|
|
2945
|
-
let
|
|
3113
|
+
if (e.columns.some((d) => l.wrapText?.[d.key] ?? d.wrapText)) {
|
|
3114
|
+
let d = this.defaultRowHeight;
|
|
2946
3115
|
for (let u = 0; u < e.columns.length; u += 1) {
|
|
2947
3116
|
const g = e.columns[u];
|
|
2948
3117
|
if (!g || !g.wrapText) continue;
|
|
2949
|
-
const m = i[u] ?? l.columnWidths?.[g.key] ?? g.width ?? 100, p = this.dataModel.resolveCellValue(t.id, g),
|
|
3118
|
+
const m = i[u] ?? l.columnWidths?.[g.key] ?? g.width ?? 100, p = this.dataModel.resolveCellValue(t.id, g), v = this.dataModel.resolveConditionalStyle(t.id, g), y = p.textOverride ?? (v.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : p.value === null || p.value === void 0 ? "" : String(p.value), w = this.dataModel.getRowVersion(t.id), C = `${t.id}|${g.key}|${w}|${m}|${y}`, S = this.measureCache.get(C);
|
|
2950
3119
|
if (S) {
|
|
2951
|
-
S.frame = this.frame, this.measureCache.set(
|
|
3120
|
+
S.frame = this.frame, this.measureCache.set(C, S), d = Math.max(d, S.height);
|
|
2952
3121
|
continue;
|
|
2953
3122
|
}
|
|
2954
3123
|
const b = document.createElement("span");
|
|
@@ -2956,10 +3125,10 @@ class bt {
|
|
|
2956
3125
|
const x = this.tableEl?.parentElement;
|
|
2957
3126
|
if (!x) continue;
|
|
2958
3127
|
x.appendChild(b);
|
|
2959
|
-
const
|
|
2960
|
-
b.remove(), this.measureCache.set(
|
|
3128
|
+
const D = b.clientHeight + 10;
|
|
3129
|
+
b.remove(), this.measureCache.set(C, { height: D, frame: this.frame }), d = Math.max(d, D);
|
|
2961
3130
|
}
|
|
2962
|
-
o.style.height = `${
|
|
3131
|
+
o.style.height = `${d}px`, this.dataModel.setRowHeight(t.id, d);
|
|
2963
3132
|
} else
|
|
2964
3133
|
o.style.height = `${this.defaultRowHeight}px`, this.dataModel.setRowHeight(t.id, this.defaultRowHeight);
|
|
2965
3134
|
return o;
|
|
@@ -3006,11 +3175,11 @@ class bt {
|
|
|
3006
3175
|
for (let a = n; a <= s; a += 1) {
|
|
3007
3176
|
const c = t[a];
|
|
3008
3177
|
if (!c) continue;
|
|
3009
|
-
const
|
|
3010
|
-
|
|
3011
|
-
const
|
|
3178
|
+
const h = c.querySelector("th.extable-row-header");
|
|
3179
|
+
h && h.classList.add("extable-selected");
|
|
3180
|
+
const d = Array.from(c.querySelectorAll("td"));
|
|
3012
3181
|
for (let u = o; u <= l; u += 1) {
|
|
3013
|
-
const g =
|
|
3182
|
+
const g = d[u];
|
|
3014
3183
|
g && g.classList.add("extable-selected");
|
|
3015
3184
|
}
|
|
3016
3185
|
}
|
|
@@ -3019,9 +3188,13 @@ class bt {
|
|
|
3019
3188
|
formatValue(t, e) {
|
|
3020
3189
|
if (t == null) return { text: "" };
|
|
3021
3190
|
if (e.type === "button")
|
|
3022
|
-
return { text:
|
|
3191
|
+
return { text: rt(t) || String(t) };
|
|
3023
3192
|
if (e.type === "link")
|
|
3024
|
-
return { text:
|
|
3193
|
+
return { text: lt(t) || String(t) };
|
|
3194
|
+
if (e.type === "tags") {
|
|
3195
|
+
const i = Bt(t);
|
|
3196
|
+
if (i) return { text: i.join(", ") };
|
|
3197
|
+
}
|
|
3025
3198
|
if (e.type === "boolean")
|
|
3026
3199
|
return e.format === "checkbox" || !e.format ? { text: t ? "☑" : "☐" } : Array.isArray(e.format) && e.format.length >= 2 ? { text: String(t ? e.format[0] : e.format[1]) } : { text: t ? String(e.format) : "" };
|
|
3027
3200
|
if (e.type === "number" && typeof t == "number") {
|
|
@@ -3031,23 +3204,23 @@ class bt {
|
|
|
3031
3204
|
return { text: o, color: l };
|
|
3032
3205
|
}
|
|
3033
3206
|
if ((e.type === "date" || e.type === "time" || e.type === "datetime") && (t instanceof Date || typeof t == "string")) {
|
|
3034
|
-
const i = e.format, n = e.type === "date" ?
|
|
3207
|
+
const i = e.format, n = e.type === "date" ? ot(i, "date") : e.type === "time" ? ot(i, "time") : ot(i, "datetime");
|
|
3035
3208
|
let s = null;
|
|
3036
|
-
return t instanceof Date ? s = t : s = this.valueFormatCache.parseIsoDate(t), s ? { text:
|
|
3209
|
+
return t instanceof Date ? s = t : s = this.valueFormatCache.parseIsoDate(t), s ? { text: fe(s, n) } : { text: String(t) };
|
|
3037
3210
|
}
|
|
3038
3211
|
return { text: String(t) };
|
|
3039
3212
|
}
|
|
3040
3213
|
}
|
|
3041
|
-
const
|
|
3214
|
+
const U = class U {
|
|
3042
3215
|
constructor(t, e = () => "direct") {
|
|
3043
|
-
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 = ht, this.headerHeight = dt, this.lineHeight = 16, this.padding = 12, this.rowHeaderWidth =
|
|
3216
|
+
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 = ht, this.headerHeight = dt, this.lineHeight = 16, this.padding = 12, this.rowHeaderWidth = st, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new De(), 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) => {
|
|
3044
3217
|
if (!this.root || !this.canvas) return;
|
|
3045
3218
|
const n = this.canvas.getBoundingClientRect(), s = i.clientX - n.left, o = i.clientY - n.top, l = s + this.root.scrollLeft, a = o;
|
|
3046
3219
|
if (a >= this.headerHeight || l < this.rowHeaderWidth) return;
|
|
3047
|
-
const c = this.dataModel.getSchema(),
|
|
3220
|
+
const c = this.dataModel.getSchema(), h = this.dataModel.getView(), d = G(c, h);
|
|
3048
3221
|
let u = this.rowHeaderWidth, g = -1;
|
|
3049
|
-
for (let S = 0; S <
|
|
3050
|
-
const b =
|
|
3222
|
+
for (let S = 0; S < d.length; S += 1) {
|
|
3223
|
+
const b = d[S] ?? 100;
|
|
3051
3224
|
if (l >= u && l <= u + b) {
|
|
3052
3225
|
g = S;
|
|
3053
3226
|
break;
|
|
@@ -3057,8 +3230,8 @@ const q = class q {
|
|
|
3057
3230
|
if (g < 0) return;
|
|
3058
3231
|
const m = c.columns[g];
|
|
3059
3232
|
if (!m) return;
|
|
3060
|
-
const p =
|
|
3061
|
-
l >= y && l <= y +
|
|
3233
|
+
const p = d[g] ?? 100, v = 18, y = u + p - v - 4, w = Math.floor((this.headerHeight - v) / 2);
|
|
3234
|
+
l >= y && l <= y + v && a >= w && a <= w + v && this.root.dispatchEvent(
|
|
3062
3235
|
new CustomEvent("extable:filter-sort-open", { bubbles: !0, detail: { colKey: m.key } })
|
|
3063
3236
|
);
|
|
3064
3237
|
}, this.handlePointerMove = (i) => {
|
|
@@ -3068,13 +3241,23 @@ const q = class q {
|
|
|
3068
3241
|
n && this.updateCanvasCursor(n.x, n.y);
|
|
3069
3242
|
}, 50));
|
|
3070
3243
|
}, this.handlePointerLeave = () => {
|
|
3071
|
-
this.canvas && (this.canvas.style.cursor = "cell", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null);
|
|
3244
|
+
this.canvas && (this.canvas.style.cursor = "cell", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null, (this.hoverActionKey || this.activeActionKey) && (this.hoverActionKey = null, this.activeActionKey = null, this.render()));
|
|
3245
|
+
}, this.handlePointerDown = (i) => {
|
|
3246
|
+
if (!this.canvas) return;
|
|
3247
|
+
const n = this.hitTestAction(
|
|
3248
|
+
new MouseEvent("mousemove", { clientX: i.clientX, clientY: i.clientY })
|
|
3249
|
+
);
|
|
3250
|
+
if (!n || n.kind !== "button" || this.dataModel.getCellInteraction(n.rowId, n.colKey).disabled) return;
|
|
3251
|
+
const o = `${n.rowId}::${n.colKey}::${n.kind}`;
|
|
3252
|
+
o !== this.activeActionKey && (this.activeActionKey = o, this.render());
|
|
3253
|
+
}, this.handlePointerUp = () => {
|
|
3254
|
+
this.activeActionKey && (this.activeActionKey = null, this.render());
|
|
3072
3255
|
}, this.dataModel = t;
|
|
3073
3256
|
}
|
|
3074
3257
|
mount(t) {
|
|
3075
3258
|
this.root = t, this.canvas = document.createElement("canvas");
|
|
3076
|
-
const e =
|
|
3077
|
-
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("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();
|
|
3259
|
+
const e = U.MAX_CANVAS_DIM_PX;
|
|
3260
|
+
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();
|
|
3078
3261
|
}
|
|
3079
3262
|
setActiveCell(t, e) {
|
|
3080
3263
|
this.activeRowId = t, this.activeColKey = e, this.render();
|
|
@@ -3089,156 +3272,163 @@ const q = class q {
|
|
|
3089
3272
|
if (!e) return;
|
|
3090
3273
|
e.font = "14px sans-serif";
|
|
3091
3274
|
let i = e.font;
|
|
3092
|
-
const n = this.activeRowId === "__all__" && this.activeColKey === "__all__", s = this.dataModel.getSchema(), o = this.dataModel.getView(), l = this.dataModel.listRows(), a = G(s, o), c = s.columns.map((
|
|
3093
|
-
u !== this.rowHeightCacheKey && (this.rowHeightCacheKey = u, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null),
|
|
3275
|
+
const n = this.activeRowId === "__all__" && this.activeColKey === "__all__", s = this.dataModel.getSchema(), o = this.dataModel.getView(), l = this.dataModel.listRows(), a = G(s, o), c = s.columns.map((T) => Rt(T)), h = /* @__PURE__ */ new Map(), d = s.columns.some((T) => o.wrapText?.[T.key] ?? T.wrapText), u = d ? this.getRowHeightCacheKey(s, o, a) : null;
|
|
3276
|
+
u !== this.rowHeightCacheKey && (this.rowHeightCacheKey = u, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null), d || this.cancelRowHeightMeasurement(), this.ensureHeightIndex(l, d ? u : null, d);
|
|
3094
3277
|
const g = this.heightIndex;
|
|
3095
3278
|
if (!g) return;
|
|
3096
|
-
const m = this.rowHeaderWidth + a.reduce((
|
|
3279
|
+
const m = this.rowHeaderWidth + a.reduce((T, A) => T + (A ?? 0), 0), p = t?.clientWidth ?? (this.root.clientWidth || 600), v = t?.clientHeight ?? (this.root.clientHeight || this.canvas.height || 400), f = U.MAX_CANVAS_DIM_PX, y = Math.max(1, Math.min(f, Math.floor(p))), w = Math.max(1, Math.min(f, Math.floor(v)));
|
|
3097
3280
|
this.canvas.width !== y && (this.canvas.width = y), this.canvas.height !== w && (this.canvas.height = w), this.canvas.style.width = `${y}px`, this.canvas.style.height = `${w}px`, e.font = "14px sans-serif", i = e.font, this.refreshTooltipPosition();
|
|
3098
|
-
const
|
|
3099
|
-
const A =
|
|
3281
|
+
const C = t?.scrollTop ?? this.root.scrollTop, S = t?.scrollLeft ?? this.root.scrollLeft, b = (T) => {
|
|
3282
|
+
const A = T + 1, k = Math.max(
|
|
3100
3283
|
0,
|
|
3101
3284
|
Math.min(l.length - 1, g.fenwick.lowerBound(A))
|
|
3102
|
-
),
|
|
3103
|
-
let V =
|
|
3104
|
-
const
|
|
3105
|
-
for (let I =
|
|
3106
|
-
|
|
3107
|
-
return { accum:
|
|
3285
|
+
), N = g.fenwick.sum(k);
|
|
3286
|
+
let V = k, W = 0;
|
|
3287
|
+
const $ = (this.canvas?.height ?? 0) + this.rowHeight * 2;
|
|
3288
|
+
for (let I = k; I < l.length && W < $; I += 1)
|
|
3289
|
+
W += g.heights[I] ?? this.rowHeight, V = I + 1;
|
|
3290
|
+
return { accum: N, visibleStart: k, visibleEnd: V };
|
|
3108
3291
|
};
|
|
3109
3292
|
let x = g.fenwick.total();
|
|
3110
|
-
const
|
|
3111
|
-
let R = Math.max(0, x -
|
|
3112
|
-
if (
|
|
3113
|
-
const
|
|
3293
|
+
const D = this.canvas?.height ?? this.root.clientHeight, F = Math.max(0, D - this.headerHeight);
|
|
3294
|
+
let R = Math.max(0, x - F), H = Math.max(0, Math.min(C, R)), { accum: M, visibleStart: K, visibleEnd: L } = b(H);
|
|
3295
|
+
if (d && u) {
|
|
3296
|
+
const T = {};
|
|
3114
3297
|
for (let A = K; A < L; A += 1) {
|
|
3115
|
-
const
|
|
3116
|
-
if (!
|
|
3117
|
-
const
|
|
3118
|
-
if (this.rowHeightMeasuredVersion.get(
|
|
3119
|
-
const V = this.measureRowHeight(e,
|
|
3120
|
-
|
|
3298
|
+
const k = l[A];
|
|
3299
|
+
if (!k) continue;
|
|
3300
|
+
const N = this.dataModel.getRowVersion(k.id);
|
|
3301
|
+
if (this.rowHeightMeasuredVersion.get(k.id) === N) continue;
|
|
3302
|
+
const V = this.measureRowHeight(e, k, s, a);
|
|
3303
|
+
T[k.id] = V, this.rowHeightMeasuredVersion.set(k.id, N);
|
|
3121
3304
|
}
|
|
3122
|
-
this.applyRowHeightUpdates(
|
|
3305
|
+
this.applyRowHeightUpdates(T), x = g.fenwick.total(), this.dataModel.setRowHeightsBulk(T), R = Math.max(0, x - F), H = Math.max(0, Math.min(C, R)), { accum: M, visibleStart: K, visibleEnd: L } = b(H), (this.rowHeightMeasureTask || Object.keys(T).length > 0) && this.scheduleRowHeightMeasurement();
|
|
3123
3306
|
}
|
|
3124
3307
|
this.spacer && (this.spacer.style.height = `${R}px`, this.spacer.style.width = `${m}px`);
|
|
3125
|
-
const
|
|
3308
|
+
const _ = this.rowHeaderWidth - S;
|
|
3126
3309
|
e.clearRect(0, 0, this.canvas.width, this.canvas.height), e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.rowHeaderWidth, this.canvas.height);
|
|
3127
|
-
let
|
|
3128
|
-
for (let
|
|
3129
|
-
const A = l[
|
|
3130
|
-
e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0,
|
|
3131
|
-
const
|
|
3132
|
-
this.activeRowId === A.id && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0,
|
|
3310
|
+
let E = this.headerHeight + M - H;
|
|
3311
|
+
for (let T = K; T < L; T += 1) {
|
|
3312
|
+
const A = l[T], k = g.heights[T] ?? this.rowHeight;
|
|
3313
|
+
e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0, E, this.rowHeaderWidth, k), e.strokeRect(0, E, this.rowHeaderWidth, k);
|
|
3314
|
+
const N = this.dataModel.getDisplayIndex(A.id) ?? "";
|
|
3315
|
+
this.activeRowId === A.id && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, E, this.rowHeaderWidth, k)), e.fillStyle = "#0f172a", e.font = "bold 14px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText(String(N), this.rowHeaderWidth / 2, E + k / 2), e.font = i, e.textAlign = "left", e.textBaseline = "alphabetic", e.save(), e.beginPath(), e.rect(
|
|
3133
3316
|
this.rowHeaderWidth,
|
|
3134
3317
|
this.headerHeight,
|
|
3135
3318
|
this.canvas.width - this.rowHeaderWidth,
|
|
3136
3319
|
this.canvas.height - this.headerHeight
|
|
3137
|
-
), e.clip(), e.translate(
|
|
3138
|
-
let V = 0,
|
|
3139
|
-
for (let
|
|
3140
|
-
const I = s.columns[
|
|
3320
|
+
), e.clip(), e.translate(_, 0);
|
|
3321
|
+
let V = 0, W = "";
|
|
3322
|
+
for (let $ = 0; $ < s.columns.length; $ += 1) {
|
|
3323
|
+
const I = s.columns[$], P = a[$] ?? 100;
|
|
3141
3324
|
if (!I) {
|
|
3142
|
-
V +=
|
|
3325
|
+
V += P;
|
|
3143
3326
|
continue;
|
|
3144
3327
|
}
|
|
3145
|
-
const
|
|
3328
|
+
const at = this.dataModel.getCellInteraction(A.id, I.key).muted;
|
|
3146
3329
|
e.strokeStyle = "#d0d7de";
|
|
3147
|
-
const
|
|
3148
|
-
e.fillStyle =
|
|
3149
|
-
const
|
|
3150
|
-
if (this.activeRowId === A.id && this.activeColKey !== null && this.activeColKey === I.key && (e.strokeStyle = "#3b82f6", e.lineWidth = 2, e.strokeRect(V + 1,
|
|
3330
|
+
const et = this.dataModel.resolveConditionalStyle(A.id, I), ct = this.dataModel.getCellStyle(A.id, I.key), jt = c[$] ?? {}, Wt = et.delta ? J(jt, et.delta) : jt, z = ct ? J(Wt, ct) : Wt, Ke = at ? "#f3f4f6" : z.backgroundColor ?? "#ffffff";
|
|
3331
|
+
e.fillStyle = Ke, e.fillRect(V, E, P, k), e.strokeRect(V, E, P, k);
|
|
3332
|
+
const it = this.dataModel.resolveCellValue(A.id, I), qt = it.textOverride ?? (et.forceErrorText ? "#ERROR" : void 0), Et = qt ? { text: "#ERROR" } : this.formatValue(it.value, I), Tt = I.type === "button" || I.type === "link", Ut = Tt ? I.type === "button" ? ut(it.value) : ft(it.value) : null, Xt = Tt ? Ut?.label ?? (I.type === "button" ? rt(it.value) : lt(it.value)) : "", gt = !!(Tt && Ut && Xt && !qt), zt = Xt || Et.text, Gt = I.style?.align ?? (I.type === "number" ? "right" : "left");
|
|
3333
|
+
if (this.activeRowId === A.id && this.activeColKey !== null && this.activeColKey === I.key && (e.strokeStyle = "#3b82f6", e.lineWidth = 2, e.strokeRect(V + 1, E + 1, P - 2, k - 2), e.lineWidth = 1, Mt(
|
|
3151
3334
|
this.dataModel,
|
|
3152
3335
|
this.selection,
|
|
3153
3336
|
this.activeRowId,
|
|
3154
3337
|
this.activeColKey,
|
|
3155
3338
|
this.getEditMode()
|
|
3156
3339
|
))) {
|
|
3157
|
-
const
|
|
3158
|
-
e.fillStyle = "#3b82f6", e.fillRect(
|
|
3340
|
+
const q = ke, nt = V + P - q - 1, Y = E + k - q - 1;
|
|
3341
|
+
e.fillStyle = "#3b82f6", e.fillRect(nt, Y, q, q), e.strokeStyle = "#ffffff", e.strokeRect(nt + 0.5, Y + 0.5, q - 1, q - 1);
|
|
3159
3342
|
}
|
|
3160
|
-
const
|
|
3161
|
-
e.fillStyle = this.dataModel.hasPending(A.id, I.key) ? "#b91c1c" :
|
|
3162
|
-
const
|
|
3163
|
-
if (
|
|
3164
|
-
e.font = i,
|
|
3343
|
+
const Le = gt && I.type === "link" && !at && !z.textColor ? "#2563eb" : void 0;
|
|
3344
|
+
e.fillStyle = this.dataModel.hasPending(A.id, I.key) ? "#b91c1c" : Et.color ? Et.color : at ? "#94a3b8" : Le ?? z.textColor ?? "#0f172a";
|
|
3345
|
+
const Yt = o.wrapText?.[I.key] ?? I.wrapText ?? !1, At = I.type === "boolean" && (!I.format || I.format === "checkbox"), Ve = I.type === "boolean" && !!(I.format && I.format !== "checkbox");
|
|
3346
|
+
if (At)
|
|
3347
|
+
e.font = i, W = "";
|
|
3165
3348
|
else {
|
|
3166
|
-
const
|
|
3167
|
-
if (
|
|
3168
|
-
const
|
|
3169
|
-
if (
|
|
3349
|
+
const q = `${z.italic ? "i" : ""}${z.bold ? "b" : ""}`;
|
|
3350
|
+
if (q !== W) {
|
|
3351
|
+
const nt = h.get(q);
|
|
3352
|
+
if (nt) e.font = nt;
|
|
3170
3353
|
else {
|
|
3171
3354
|
const Y = z.bold ? "600 " : "", wt = `${z.italic ? "italic " : ""}${Y}14px sans-serif`.trim();
|
|
3172
|
-
|
|
3355
|
+
h.set(q, wt), e.font = wt;
|
|
3173
3356
|
}
|
|
3174
|
-
|
|
3357
|
+
W = q;
|
|
3175
3358
|
}
|
|
3176
3359
|
}
|
|
3177
|
-
const mt = V + 8, pt =
|
|
3360
|
+
const mt = V + 8, pt = E + 2, Ht = Math.max(0, P - 12), Dt = Math.max(0, k - 8), Fe = {
|
|
3178
3361
|
underline: !!z.underline || gt && I.type === "link",
|
|
3179
3362
|
strike: !!z.strike
|
|
3180
|
-
},
|
|
3363
|
+
}, Z = gt && !At ? this.measureTextBounds(
|
|
3181
3364
|
e,
|
|
3182
|
-
|
|
3365
|
+
zt,
|
|
3183
3366
|
mt,
|
|
3184
3367
|
pt,
|
|
3185
|
-
At,
|
|
3186
3368
|
Ht,
|
|
3187
|
-
|
|
3188
|
-
|
|
3369
|
+
Dt,
|
|
3370
|
+
Yt,
|
|
3371
|
+
Gt
|
|
3189
3372
|
) : null;
|
|
3190
|
-
if (gt && I.type === "button" &&
|
|
3191
|
-
const Y = Math.max(mt,
|
|
3192
|
-
e.save()
|
|
3373
|
+
if (gt && I.type === "button" && Z) {
|
|
3374
|
+
const Y = Math.max(mt, Z.x - 6), yt = Math.max(pt, Z.y - 4), wt = Math.min(mt + Ht, Z.x + Z.width + 6), _e = Math.min(pt + Dt, Z.y + Z.height + 4), Jt = Math.max(0, wt - Y), Zt = Math.max(0, _e - yt);
|
|
3375
|
+
e.save();
|
|
3376
|
+
const te = `${A.id}::${I.key}::button`, Ne = this.hoverActionKey === te, Be = this.activeActionKey === te;
|
|
3377
|
+
at ? (e.fillStyle = "#f3f4f6", e.strokeStyle = "#e2e8f0") : Be ? (e.fillStyle = "#cbd5e1", e.strokeStyle = "#94a3b8") : Ne ? (e.fillStyle = "#e2e8f0", e.strokeStyle = "#94a3b8") : (e.fillStyle = "#f8fafc", e.strokeStyle = "#cbd5e1"), e.lineWidth = 1, e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(Y, yt, Jt, Zt, 6) : e.rect(Y, yt, Jt, Zt), e.fill(), e.stroke(), e.restore();
|
|
3193
3378
|
}
|
|
3194
3379
|
this.drawCellText(
|
|
3195
3380
|
e,
|
|
3196
|
-
|
|
3381
|
+
zt,
|
|
3197
3382
|
mt,
|
|
3198
3383
|
pt,
|
|
3199
|
-
At,
|
|
3200
3384
|
Ht,
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3385
|
+
Dt,
|
|
3386
|
+
Yt,
|
|
3387
|
+
Gt,
|
|
3388
|
+
At,
|
|
3389
|
+
Ve,
|
|
3390
|
+
Fe
|
|
3206
3391
|
);
|
|
3207
|
-
const
|
|
3208
|
-
|
|
3392
|
+
const Qt = this.dataModel.getCellMarker(A.id, I.key);
|
|
3393
|
+
Qt && Bn(e, V, E, P, k, Qt.level), V += P;
|
|
3209
3394
|
}
|
|
3210
|
-
e.restore(),
|
|
3395
|
+
e.restore(), E += k;
|
|
3211
3396
|
}
|
|
3212
|
-
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(
|
|
3397
|
+
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(_, 0);
|
|
3213
3398
|
let B = 0;
|
|
3214
|
-
for (let
|
|
3215
|
-
const A = s.columns[
|
|
3399
|
+
for (let T = 0; T < s.columns.length; T += 1) {
|
|
3400
|
+
const A = s.columns[T], k = a[T] ?? 100;
|
|
3216
3401
|
if (!A) {
|
|
3217
|
-
B +=
|
|
3402
|
+
B += k;
|
|
3218
3403
|
continue;
|
|
3219
3404
|
}
|
|
3220
|
-
this.activeColKey !== null && this.activeColKey === A.key && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(B, 0,
|
|
3221
|
-
const V =
|
|
3222
|
-
if (!!V ||
|
|
3223
|
-
const
|
|
3224
|
-
V ?
|
|
3405
|
+
this.activeColKey !== null && this.activeColKey === A.key && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(B, 0, k, this.headerHeight)), e.strokeStyle = "#d0d7de", e.strokeRect(B, 0, k, this.headerHeight), e.fillStyle = "#0f172a", e.font = "bold 14px sans-serif", e.fillText(A.header ?? A.key, B + 8, this.headerHeight - 8), e.font = i;
|
|
3406
|
+
const V = Ae(o, A.key), W = He(o, A.key), $ = this.hoverHeaderColKey !== null && this.hoverHeaderColKey === A.key;
|
|
3407
|
+
if (!!V || W || $) {
|
|
3408
|
+
const P = $ ? 0.9 : W || V ? 0.75 : 0.45, O = 16, et = B + k - O - 6, ct = Math.floor((this.headerHeight - O) / 2);
|
|
3409
|
+
V ? $n(e, et + 3, ct + 3, O - 6, P, V) : Pn(e, et + 2, ct + 2, O - 4, P);
|
|
3225
3410
|
}
|
|
3226
|
-
B +=
|
|
3411
|
+
B += k;
|
|
3227
3412
|
}
|
|
3228
3413
|
if (e.restore(), this.selection.length) {
|
|
3229
|
-
e.save(), e.
|
|
3230
|
-
|
|
3231
|
-
|
|
3414
|
+
e.save(), e.beginPath(), e.rect(
|
|
3415
|
+
this.rowHeaderWidth,
|
|
3416
|
+
this.headerHeight,
|
|
3417
|
+
this.canvas.width - this.rowHeaderWidth,
|
|
3418
|
+
this.canvas.height - this.headerHeight
|
|
3419
|
+
), e.clip(), e.strokeStyle = "#3b82f6", e.fillStyle = "rgba(59,130,246,0.12)";
|
|
3420
|
+
for (const T of this.selection) {
|
|
3421
|
+
const A = Math.max(0, Math.min(T.startRow, T.endRow)), k = Math.min(l.length - 1, Math.max(T.startRow, T.endRow)), N = Math.max(0, Math.min(T.startCol, T.endCol)), V = Math.min(
|
|
3232
3422
|
s.columns.length - 1,
|
|
3233
|
-
Math.max(
|
|
3234
|
-
),
|
|
3423
|
+
Math.max(T.startCol, T.endCol)
|
|
3424
|
+
), W = this.headerHeight + g.fenwick.sum(A) - H, $ = g.fenwick.sum(k + 1) - g.fenwick.sum(A);
|
|
3235
3425
|
let I = this.rowHeaderWidth;
|
|
3236
|
-
for (let O = 0; O <
|
|
3426
|
+
for (let O = 0; O < N; O += 1)
|
|
3237
3427
|
I += a[O] ?? 100;
|
|
3238
|
-
let
|
|
3239
|
-
for (let O =
|
|
3240
|
-
|
|
3241
|
-
I -= S, e.fillRect(I,
|
|
3428
|
+
let P = 0;
|
|
3429
|
+
for (let O = N; O <= V; O += 1)
|
|
3430
|
+
P += a[O] ?? 100;
|
|
3431
|
+
I -= S, e.fillRect(I, W, P, $), e.strokeRect(I + 0.5, W + 0.5, P - 1, $ - 1);
|
|
3242
3432
|
}
|
|
3243
3433
|
e.restore();
|
|
3244
3434
|
}
|
|
@@ -3248,7 +3438,7 @@ const q = class q {
|
|
|
3248
3438
|
}
|
|
3249
3439
|
}
|
|
3250
3440
|
destroy() {
|
|
3251
|
-
this.cancelRowHeightMeasurement(), this.heightIndex = null, this.canvas && (this.canvas.removeEventListener("pointermove", this.handlePointerMove), this.canvas.removeEventListener("pointerleave", this.handlePointerLeave), this.canvas.removeEventListener("click", this.handleClick)), this.cursorTimer && (window.clearTimeout(this.cursorTimer), this.cursorTimer = null), this.pendingCursorPoint = null,
|
|
3441
|
+
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, j(this.canvas), j(this.spacer), j(this.overlayLayer), j(this.tooltip), this.canvas = null, this.spacer = null, this.overlayLayer = null, this.tooltip = null, this.tooltipTarget = null, this.tooltipMessage = null, this.root = null;
|
|
3252
3442
|
}
|
|
3253
3443
|
ensureHeightIndex(t, e, i) {
|
|
3254
3444
|
const n = this.heightIndex;
|
|
@@ -3260,8 +3450,8 @@ const q = class q {
|
|
|
3260
3450
|
o.set(a.id, l);
|
|
3261
3451
|
let c = this.rowHeight;
|
|
3262
3452
|
if (i && e) {
|
|
3263
|
-
const
|
|
3264
|
-
|
|
3453
|
+
const h = this.dataModel.getRowVersion(a.id), d = this.rowHeightMeasuredVersion.get(a.id), u = this.dataModel.getRowHeight(a.id);
|
|
3454
|
+
d === h && typeof u == "number" && (c = u);
|
|
3265
3455
|
}
|
|
3266
3456
|
s[l] = c;
|
|
3267
3457
|
}
|
|
@@ -3270,7 +3460,7 @@ const q = class q {
|
|
|
3270
3460
|
rowsRef: t,
|
|
3271
3461
|
idToIndex: o,
|
|
3272
3462
|
heights: s,
|
|
3273
|
-
fenwick:
|
|
3463
|
+
fenwick: Ot.from(s)
|
|
3274
3464
|
};
|
|
3275
3465
|
}
|
|
3276
3466
|
applyRowHeightUpdates(t) {
|
|
@@ -3307,15 +3497,15 @@ const q = class q {
|
|
|
3307
3497
|
const l = this.rowHeightMeasureTask ?? { key: o, nextIndex: 0 };
|
|
3308
3498
|
if (l.key !== o) return;
|
|
3309
3499
|
const a = this.dataModel.listRows(), c = {};
|
|
3310
|
-
let
|
|
3311
|
-
const
|
|
3312
|
-
for (; l.nextIndex < a.length &&
|
|
3500
|
+
let h = 0;
|
|
3501
|
+
const d = performance.now();
|
|
3502
|
+
for (; l.nextIndex < a.length && h < U.ROW_HEIGHT_MEASURE_CHUNK && !(performance.now() - d > U.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS); ) {
|
|
3313
3503
|
const u = a[l.nextIndex];
|
|
3314
3504
|
if (l.nextIndex += 1, !u) continue;
|
|
3315
3505
|
const g = this.dataModel.getRowVersion(u.id);
|
|
3316
3506
|
if (this.rowHeightMeasuredVersion.get(u.id) === g) continue;
|
|
3317
3507
|
const m = this.measureRowHeight(t, u, e, n);
|
|
3318
|
-
c[u.id] = m, this.rowHeightMeasuredVersion.set(u.id, g),
|
|
3508
|
+
c[u.id] = m, this.rowHeightMeasuredVersion.set(u.id, g), h += 1;
|
|
3319
3509
|
}
|
|
3320
3510
|
this.rowHeightMeasureTask = l.nextIndex < a.length ? l : null, this.ensureHeightIndex(a, this.rowHeightCacheKey, !0), this.applyRowHeightUpdates(c), this.dataModel.setRowHeightsBulk(c), this.rowHeightMeasureTask && this.scheduleRowHeightMeasurement();
|
|
3321
3511
|
}
|
|
@@ -3324,11 +3514,11 @@ const q = class q {
|
|
|
3324
3514
|
}
|
|
3325
3515
|
hitTest(t) {
|
|
3326
3516
|
if (!this.root || !this.canvas) return null;
|
|
3327
|
-
const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, n = t.clientY - e.top, s = i + this.root.scrollLeft, o = this.dataModel.getSchema(), l = this.dataModel.getView(), a = this.dataModel.listRows(), c = this.headerHeight,
|
|
3328
|
-
this.ensureHeightIndex(a, u,
|
|
3517
|
+
const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, n = t.clientY - e.top, s = i + this.root.scrollLeft, o = this.dataModel.getSchema(), l = this.dataModel.getView(), a = this.dataModel.listRows(), c = this.headerHeight, h = G(o, l), d = o.columns.some((M) => l.wrapText?.[M.key] ?? M.wrapText), u = d ? this.getRowHeightCacheKey(o, l, h) : null;
|
|
3518
|
+
this.ensureHeightIndex(a, u, d);
|
|
3329
3519
|
const g = this.heightIndex;
|
|
3330
3520
|
if (!g) return null;
|
|
3331
|
-
const m = g.fenwick.total(), p = this.canvas?.height ?? this.root.clientHeight,
|
|
3521
|
+
const m = g.fenwick.total(), p = this.canvas?.height ?? this.root.clientHeight, v = Math.max(0, p - this.headerHeight), f = Math.max(0, m - v), y = Math.max(0, Math.min(this.root.scrollTop, f));
|
|
3332
3522
|
if (n < c && i < this.rowHeaderWidth)
|
|
3333
3523
|
return {
|
|
3334
3524
|
rowId: "__all__",
|
|
@@ -3337,22 +3527,22 @@ const q = class q {
|
|
|
3337
3527
|
};
|
|
3338
3528
|
if (n < c) {
|
|
3339
3529
|
let M = this.rowHeaderWidth, K = -1;
|
|
3340
|
-
for (let L = 0; L <
|
|
3341
|
-
const
|
|
3342
|
-
if (s >= M && s <= M +
|
|
3530
|
+
for (let L = 0; L < h.length; L += 1) {
|
|
3531
|
+
const _ = h[L] ?? 100;
|
|
3532
|
+
if (s >= M && s <= M + _) {
|
|
3343
3533
|
K = L;
|
|
3344
3534
|
break;
|
|
3345
3535
|
}
|
|
3346
|
-
M +=
|
|
3536
|
+
M += _;
|
|
3347
3537
|
}
|
|
3348
3538
|
if (K >= 0) {
|
|
3349
|
-
const L = o.columns[K],
|
|
3539
|
+
const L = o.columns[K], _ = new DOMRect(
|
|
3350
3540
|
e.left + M - this.root.scrollLeft,
|
|
3351
3541
|
e.top,
|
|
3352
|
-
|
|
3542
|
+
h[K] ?? 100,
|
|
3353
3543
|
c
|
|
3354
3544
|
);
|
|
3355
|
-
return { rowId: "__header__", colKey: L.key, rect:
|
|
3545
|
+
return { rowId: "__header__", colKey: L.key, rect: _ };
|
|
3356
3546
|
}
|
|
3357
3547
|
return null;
|
|
3358
3548
|
}
|
|
@@ -3362,19 +3552,19 @@ const q = class q {
|
|
|
3362
3552
|
Math.min(a.length - 1, g.fenwick.lowerBound(M + 1))
|
|
3363
3553
|
), L = g.fenwick.sum(K);
|
|
3364
3554
|
if (K < 0 || K >= a.length) return null;
|
|
3365
|
-
const
|
|
3555
|
+
const _ = a[K], E = e.top + c + L - y, B = new DOMRect(
|
|
3366
3556
|
e.left,
|
|
3367
|
-
|
|
3557
|
+
E,
|
|
3368
3558
|
this.rowHeaderWidth,
|
|
3369
3559
|
g.heights[K] ?? this.rowHeight
|
|
3370
3560
|
);
|
|
3371
|
-
return { rowId:
|
|
3561
|
+
return { rowId: _.id, colKey: null, rect: B };
|
|
3372
3562
|
}
|
|
3373
|
-
const w = n - c + y,
|
|
3374
|
-
if (
|
|
3563
|
+
const w = n - c + y, C = Math.max(0, Math.min(a.length - 1, g.fenwick.lowerBound(w + 1))), S = g.fenwick.sum(C);
|
|
3564
|
+
if (C < 0 || C >= a.length) return null;
|
|
3375
3565
|
let b = this.rowHeaderWidth, x = -1;
|
|
3376
|
-
for (let M = 0; M <
|
|
3377
|
-
const K =
|
|
3566
|
+
for (let M = 0; M < h.length; M += 1) {
|
|
3567
|
+
const K = h[M] ?? 100;
|
|
3378
3568
|
if (s >= b && s <= b + K) {
|
|
3379
3569
|
x = M;
|
|
3380
3570
|
break;
|
|
@@ -3382,13 +3572,13 @@ const q = class q {
|
|
|
3382
3572
|
b += K;
|
|
3383
3573
|
}
|
|
3384
3574
|
if (x === -1) return null;
|
|
3385
|
-
const
|
|
3575
|
+
const D = a[C], F = o.columns[x], R = S, H = new DOMRect(
|
|
3386
3576
|
e.left + b - this.root.scrollLeft,
|
|
3387
3577
|
e.top + c + R - this.root.scrollTop,
|
|
3388
|
-
|
|
3389
|
-
g.heights[
|
|
3578
|
+
h[x] ?? 100,
|
|
3579
|
+
g.heights[C] ?? this.rowHeight
|
|
3390
3580
|
);
|
|
3391
|
-
return { rowId:
|
|
3581
|
+
return { rowId: D.id, colKey: F.key, rect: H };
|
|
3392
3582
|
}
|
|
3393
3583
|
hitTestAction(t) {
|
|
3394
3584
|
if (!this.root || !this.canvas) return null;
|
|
@@ -3402,21 +3592,21 @@ const q = class q {
|
|
|
3402
3592
|
if (!a || !a.label) return null;
|
|
3403
3593
|
const c = this.canvas.getContext("2d");
|
|
3404
3594
|
if (!c) return null;
|
|
3405
|
-
const
|
|
3595
|
+
const h = Rt(n), d = o.delta ? J(h, o.delta) : h, u = this.dataModel.getCellStyle(e.rowId, n.key), g = u ? J(d, u) : d, m = g.bold ? "600 " : "", p = g.italic ? "italic " : "";
|
|
3406
3596
|
c.save(), c.font = `${p}${m}14px sans-serif`.trim() || "14px sans-serif", c.textBaseline = "alphabetic";
|
|
3407
|
-
const f = this.dataModel.getView().wrapText?.[n.key] ?? n.wrapText ?? !1, y = n.style?.align ?? "left", w = e.rect.left + 8,
|
|
3597
|
+
const f = this.dataModel.getView().wrapText?.[n.key] ?? n.wrapText ?? !1, y = n.style?.align ?? "left", w = e.rect.left + 8, C = e.rect.top + 2, S = Math.max(0, e.rect.width - 12), b = Math.max(0, e.rect.height - 8), x = this.measureTextBounds(
|
|
3408
3598
|
c,
|
|
3409
3599
|
a.label,
|
|
3410
3600
|
w,
|
|
3411
|
-
|
|
3601
|
+
C,
|
|
3412
3602
|
S,
|
|
3413
3603
|
b,
|
|
3414
3604
|
f,
|
|
3415
3605
|
y
|
|
3416
3606
|
);
|
|
3417
3607
|
if (c.restore(), !x) return null;
|
|
3418
|
-
const
|
|
3419
|
-
return t.clientX >=
|
|
3608
|
+
const D = n.type === "button" ? 6 : 2, F = Math.max(e.rect.left, x.x - D), R = Math.max(e.rect.top, x.y - D), H = Math.min(e.rect.right, x.x + x.width + D), M = Math.min(e.rect.bottom, x.y + x.height + D);
|
|
3609
|
+
return t.clientX >= F && t.clientX <= H && t.clientY >= R && t.clientY <= M ? { rowId: e.rowId, colKey: String(e.colKey), kind: n.type } : null;
|
|
3420
3610
|
}
|
|
3421
3611
|
isPointInSelection(t, e) {
|
|
3422
3612
|
if (!this.selection.length) return !1;
|
|
@@ -3424,8 +3614,8 @@ const q = class q {
|
|
|
3424
3614
|
if (n < 0 || s < 0) return !1;
|
|
3425
3615
|
for (const o of this.selection) {
|
|
3426
3616
|
if (o.kind !== "cells") continue;
|
|
3427
|
-
const l = Math.min(o.startRow, o.endRow), a = Math.max(o.startRow, o.endRow), c = Math.min(o.startCol, o.endCol),
|
|
3428
|
-
if (n >= l && n <= a && s >= c && s <=
|
|
3617
|
+
const l = Math.min(o.startRow, o.endRow), a = Math.max(o.startRow, o.endRow), c = Math.min(o.startCol, o.endCol), h = Math.max(o.startCol, o.endCol);
|
|
3618
|
+
if (n >= l && n <= a && s >= c && s <= h)
|
|
3429
3619
|
return !0;
|
|
3430
3620
|
}
|
|
3431
3621
|
return !1;
|
|
@@ -3450,8 +3640,8 @@ const q = class q {
|
|
|
3450
3640
|
if (!this.root || !this.canvas) return null;
|
|
3451
3641
|
const i = this.canvas.getBoundingClientRect(), n = this.dataModel.getSchema(), s = this.dataModel.getView(), o = this.dataModel.listRows(), l = this.dataModel.getRowIndex(t), a = n.columns.findIndex((p) => p.key === e);
|
|
3452
3642
|
if (l < 0 || a < 0) return null;
|
|
3453
|
-
const c = G(n, s),
|
|
3454
|
-
this.ensureHeightIndex(o,
|
|
3643
|
+
const c = G(n, s), h = n.columns.some((p) => s.wrapText?.[p.key] ?? p.wrapText), d = h ? this.getRowHeightCacheKey(n, s, c) : null;
|
|
3644
|
+
this.ensureHeightIndex(o, d, h);
|
|
3455
3645
|
const u = this.heightIndex;
|
|
3456
3646
|
if (!u) return null;
|
|
3457
3647
|
const g = u.fenwick.sum(l);
|
|
@@ -3472,41 +3662,41 @@ const q = class q {
|
|
|
3472
3662
|
return;
|
|
3473
3663
|
}
|
|
3474
3664
|
{
|
|
3475
|
-
const d = this.canvas.getBoundingClientRect(),
|
|
3476
|
-
let
|
|
3477
|
-
if (
|
|
3478
|
-
const
|
|
3479
|
-
let
|
|
3480
|
-
for (let
|
|
3481
|
-
const
|
|
3482
|
-
if (
|
|
3483
|
-
|
|
3665
|
+
const d = this.canvas.getBoundingClientRect(), u = t - d.left, g = e - d.top, m = u + this.root.scrollLeft, p = g, v = this.hoverHeaderColKey, f = this.hoverHeaderIcon;
|
|
3666
|
+
let y = null, w = !1;
|
|
3667
|
+
if (p >= 0 && p < this.headerHeight && m >= this.rowHeaderWidth) {
|
|
3668
|
+
const S = this.dataModel.getSchema(), b = this.dataModel.getView(), x = G(S, b);
|
|
3669
|
+
let D = this.rowHeaderWidth, F = -1;
|
|
3670
|
+
for (let H = 0; H < x.length; H += 1) {
|
|
3671
|
+
const M = x[H] ?? 100;
|
|
3672
|
+
if (m >= D && m <= D + M) {
|
|
3673
|
+
F = H;
|
|
3484
3674
|
break;
|
|
3485
3675
|
}
|
|
3486
|
-
|
|
3676
|
+
D += M;
|
|
3487
3677
|
}
|
|
3488
|
-
const
|
|
3489
|
-
if (
|
|
3490
|
-
|
|
3491
|
-
const
|
|
3492
|
-
|
|
3678
|
+
const R = F >= 0 ? S.columns[F] : null;
|
|
3679
|
+
if (R) {
|
|
3680
|
+
y = R.key;
|
|
3681
|
+
const H = x[F] ?? 100, M = 18, L = D + H - M - 4, _ = Math.floor((this.headerHeight - M) / 2);
|
|
3682
|
+
w = m >= L && m <= L + M && p >= _ && p <= _ + M;
|
|
3493
3683
|
}
|
|
3494
3684
|
}
|
|
3495
|
-
const
|
|
3496
|
-
if (this.hoverHeaderColKey =
|
|
3497
|
-
this.canvas.style.cursor =
|
|
3685
|
+
const C = String(v ?? "") !== String(y ?? "") || !!f != !!w;
|
|
3686
|
+
if (this.hoverHeaderColKey = y, this.hoverHeaderIcon = w, y !== null) {
|
|
3687
|
+
this.canvas.style.cursor = w ? "pointer" : "default", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null, C && this.render();
|
|
3498
3688
|
return;
|
|
3499
3689
|
}
|
|
3500
|
-
|
|
3690
|
+
C && this.render();
|
|
3501
3691
|
}
|
|
3502
3692
|
let i = "cell";
|
|
3503
3693
|
const n = this.hitTest(new MouseEvent("mousemove", { clientX: t, clientY: e }));
|
|
3504
3694
|
if (!n) {
|
|
3505
|
-
this.canvas.style.cursor = i, this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null;
|
|
3695
|
+
this.canvas.style.cursor = i, this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null, this.hoverActionKey = null;
|
|
3506
3696
|
return;
|
|
3507
3697
|
}
|
|
3508
3698
|
if (n.colKey === "__all__" || n.colKey === null) {
|
|
3509
|
-
this.canvas.style.cursor = "default", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null;
|
|
3699
|
+
this.canvas.style.cursor = "default", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null, this.hoverActionKey = null;
|
|
3510
3700
|
return;
|
|
3511
3701
|
}
|
|
3512
3702
|
if (this.getEditMode() === "readonly") {
|
|
@@ -3515,15 +3705,15 @@ const q = class q {
|
|
|
3515
3705
|
}
|
|
3516
3706
|
const s = this.dataModel.getCellMarker(n.rowId, n.colKey);
|
|
3517
3707
|
if (this.tooltip && s) {
|
|
3518
|
-
const d = this.tooltipTarget && this.tooltipTarget.rowId === n.rowId && this.tooltipTarget.colKey === n.colKey,
|
|
3519
|
-
if (!d || !
|
|
3708
|
+
const d = this.tooltipTarget && this.tooltipTarget.rowId === n.rowId && this.tooltipTarget.colKey === n.colKey, u = this.tooltipMessage === s.message;
|
|
3709
|
+
if (!d || !u || this.tooltip.dataset.visible !== "1") {
|
|
3520
3710
|
this.tooltipTarget = { rowId: n.rowId, colKey: n.colKey }, this.tooltipMessage = s.message, this.tooltip.textContent = s.message;
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3711
|
+
const g = this.getCellRect(n.rowId, n.colKey);
|
|
3712
|
+
g ? (this.positionTooltipAtRect(g), this.tooltip.dataset.visible = "1") : this.tooltip.dataset.visible = "0";
|
|
3523
3713
|
}
|
|
3524
3714
|
} else this.tooltip && (this.tooltip.dataset.visible = "0", this.tooltipTarget = null, this.tooltipMessage = null);
|
|
3525
|
-
const o = this.hitTestAction(new MouseEvent("mousemove", { clientX: t, clientY: e }));
|
|
3526
|
-
if (o && !this.dataModel.getCellInteraction(o.rowId, o.colKey).disabled) {
|
|
3715
|
+
const o = this.hitTestAction(new MouseEvent("mousemove", { clientX: t, clientY: e })), l = o ? `${o.rowId}::${o.colKey}::${o.kind}` : null;
|
|
3716
|
+
if (l !== this.hoverActionKey && (this.hoverActionKey = l, this.render()), o && !this.dataModel.getCellInteraction(o.rowId, o.colKey).disabled) {
|
|
3527
3717
|
this.canvas.style.cursor = "pointer";
|
|
3528
3718
|
return;
|
|
3529
3719
|
}
|
|
@@ -3535,7 +3725,7 @@ const q = class q {
|
|
|
3535
3725
|
this.canvas.style.cursor = "cell";
|
|
3536
3726
|
return;
|
|
3537
3727
|
}
|
|
3538
|
-
if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" &&
|
|
3728
|
+
if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" && Mt(
|
|
3539
3729
|
this.dataModel,
|
|
3540
3730
|
this.selection,
|
|
3541
3731
|
this.activeRowId,
|
|
@@ -3544,15 +3734,15 @@ const q = class q {
|
|
|
3544
3734
|
)) {
|
|
3545
3735
|
const d = this.getCellRect(this.activeRowId, this.activeColKey);
|
|
3546
3736
|
if (d) {
|
|
3547
|
-
const
|
|
3548
|
-
if (
|
|
3737
|
+
const u = Ee(d, Ie);
|
|
3738
|
+
if (Te(t, e, u)) {
|
|
3549
3739
|
this.canvas.style.cursor = "crosshair";
|
|
3550
3740
|
return;
|
|
3551
3741
|
}
|
|
3552
3742
|
}
|
|
3553
3743
|
}
|
|
3554
|
-
const
|
|
3555
|
-
this.dataModel.getCellInteraction(n.rowId, n.colKey).readonly ||
|
|
3744
|
+
const c = this.dataModel.getSchema().columns.find((d) => d.key === n.colKey);
|
|
3745
|
+
this.dataModel.getCellInteraction(n.rowId, n.colKey).readonly || c?.type === "boolean" ? i = "default" : i = "text", this.canvas.style.cursor = i;
|
|
3556
3746
|
}
|
|
3557
3747
|
measureRowHeight(t, e, i, n) {
|
|
3558
3748
|
let s = this.rowHeight;
|
|
@@ -3560,8 +3750,8 @@ const q = class q {
|
|
|
3560
3750
|
for (let l = 0; l < i.columns.length; l += 1) {
|
|
3561
3751
|
const a = i.columns[l];
|
|
3562
3752
|
if (!a || !(o.wrapText?.[a.key] ?? a.wrapText)) continue;
|
|
3563
|
-
const
|
|
3564
|
-
s = Math.max(s,
|
|
3753
|
+
const h = (n[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, v = this.wrapLines(t, m, h).length * this.lineHeight + this.padding;
|
|
3754
|
+
s = Math.max(s, v);
|
|
3565
3755
|
}
|
|
3566
3756
|
return s;
|
|
3567
3757
|
}
|
|
@@ -3574,14 +3764,14 @@ const q = class q {
|
|
|
3574
3764
|
for (const a of o) {
|
|
3575
3765
|
let c = a;
|
|
3576
3766
|
for (; t.measureText(c).width > i && c.length > 1; ) {
|
|
3577
|
-
let
|
|
3578
|
-
for (;
|
|
3579
|
-
|
|
3580
|
-
l.push(c.slice(0,
|
|
3767
|
+
let h = c.length;
|
|
3768
|
+
for (; h > 1 && t.measureText(c.slice(0, h)).width > i; )
|
|
3769
|
+
h -= 1;
|
|
3770
|
+
l.push(c.slice(0, h)), c = c.slice(h);
|
|
3581
3771
|
}
|
|
3582
3772
|
l.push(c);
|
|
3583
3773
|
}
|
|
3584
|
-
for (this.textMeasureCache.set(n, { lines: l }); this.textMeasureCache.size >
|
|
3774
|
+
for (this.textMeasureCache.set(n, { lines: l }); this.textMeasureCache.size > U.TEXT_MEASURE_CACHE_MAX; ) {
|
|
3585
3775
|
const a = this.textMeasureCache.keys().next().value;
|
|
3586
3776
|
if (!a) break;
|
|
3587
3777
|
this.textMeasureCache.delete(a);
|
|
@@ -3601,42 +3791,42 @@ const q = class q {
|
|
|
3601
3791
|
measureTextBounds(t, e, i, n, s, o, l, a) {
|
|
3602
3792
|
const c = this.getTextLinesForBounds(t, e, s, l, o);
|
|
3603
3793
|
if (!c.length) return null;
|
|
3604
|
-
let
|
|
3794
|
+
let h = Number.POSITIVE_INFINITY, d = Number.NEGATIVE_INFINITY, u = Number.POSITIVE_INFINITY, g = Number.NEGATIVE_INFINITY;
|
|
3605
3795
|
for (let m = 0; m < c.length; m += 1) {
|
|
3606
|
-
const p = c[m] ?? "",
|
|
3796
|
+
const p = c[m] ?? "", v = t.measureText(p).width;
|
|
3607
3797
|
let f = i;
|
|
3608
|
-
a === "right" ? f = i + s -
|
|
3798
|
+
a === "right" ? f = i + s - v : a === "center" && (f = i + (s - v) / 2);
|
|
3609
3799
|
const y = n + this.lineHeight * m, w = y + this.lineHeight;
|
|
3610
|
-
|
|
3800
|
+
h = Math.min(h, f), d = Math.max(d, f + v), u = Math.min(u, y), g = Math.max(g, w);
|
|
3611
3801
|
}
|
|
3612
|
-
return !Number.isFinite(
|
|
3802
|
+
return !Number.isFinite(h) || !Number.isFinite(u) ? null : new DOMRect(h, u, d - h, g - u);
|
|
3613
3803
|
}
|
|
3614
|
-
drawCellText(t, e, i, n, s, o, l, a = "left", c = !1,
|
|
3804
|
+
drawCellText(t, e, i, n, s, o, l, a = "left", c = !1, h = !1, d) {
|
|
3615
3805
|
t.save(), t.beginPath(), t.rect(i - 4, n - 4, s + 8, o + 8), t.clip();
|
|
3616
3806
|
const u = t.font;
|
|
3617
|
-
c ? t.font = "28px sans-serif" :
|
|
3807
|
+
c ? t.font = "28px sans-serif" : h && (t.font = "14px sans-serif");
|
|
3618
3808
|
const g = (m, p) => {
|
|
3619
|
-
const
|
|
3809
|
+
const v = n + this.lineHeight * p;
|
|
3620
3810
|
let f = i, y = i;
|
|
3621
3811
|
if (a === "right")
|
|
3622
|
-
t.textAlign = "right", y = i + s, f = y - t.measureText(m).width, t.fillText(m, y,
|
|
3812
|
+
t.textAlign = "right", y = i + s, f = y - t.measureText(m).width, t.fillText(m, y, v);
|
|
3623
3813
|
else if (a === "center") {
|
|
3624
3814
|
t.textAlign = "center";
|
|
3625
|
-
const w = i + s / 2,
|
|
3626
|
-
f = w -
|
|
3815
|
+
const w = i + s / 2, C = t.measureText(m).width;
|
|
3816
|
+
f = w - C / 2, y = w + C / 2, t.fillText(m, w, v);
|
|
3627
3817
|
} else
|
|
3628
|
-
t.textAlign = "left", f = i, y = i + t.measureText(m).width, t.fillText(m, i,
|
|
3629
|
-
if (
|
|
3630
|
-
const w = t.strokeStyle,
|
|
3631
|
-
if (t.strokeStyle = t.fillStyle, t.lineWidth = 1, t.beginPath(),
|
|
3632
|
-
const S =
|
|
3818
|
+
t.textAlign = "left", f = i, y = i + t.measureText(m).width, t.fillText(m, i, v);
|
|
3819
|
+
if (d?.underline || d?.strike) {
|
|
3820
|
+
const w = t.strokeStyle, C = t.lineWidth;
|
|
3821
|
+
if (t.strokeStyle = t.fillStyle, t.lineWidth = 1, t.beginPath(), d.underline) {
|
|
3822
|
+
const S = v + 2;
|
|
3633
3823
|
t.moveTo(f, S), t.lineTo(y, S);
|
|
3634
3824
|
}
|
|
3635
|
-
if (
|
|
3636
|
-
const S =
|
|
3825
|
+
if (d.strike) {
|
|
3826
|
+
const S = v - Math.floor(this.lineHeight / 2) + 2;
|
|
3637
3827
|
t.moveTo(f, S), t.lineTo(y, S);
|
|
3638
3828
|
}
|
|
3639
|
-
t.stroke(), t.strokeStyle = w, t.lineWidth =
|
|
3829
|
+
t.stroke(), t.strokeStyle = w, t.lineWidth = C;
|
|
3640
3830
|
}
|
|
3641
3831
|
};
|
|
3642
3832
|
if (l) {
|
|
@@ -3650,9 +3840,13 @@ const q = class q {
|
|
|
3650
3840
|
formatValue(t, e) {
|
|
3651
3841
|
if (t == null) return { text: "" };
|
|
3652
3842
|
if (e.type === "button")
|
|
3653
|
-
return { text:
|
|
3843
|
+
return { text: rt(t) || String(t) };
|
|
3654
3844
|
if (e.type === "link")
|
|
3655
|
-
return { text:
|
|
3845
|
+
return { text: lt(t) || String(t) };
|
|
3846
|
+
if (e.type === "tags") {
|
|
3847
|
+
const i = Bt(t);
|
|
3848
|
+
if (i) return { text: i.join(", ") };
|
|
3849
|
+
}
|
|
3656
3850
|
if (e.type === "boolean")
|
|
3657
3851
|
return e.format === "checkbox" || !e.format ? { text: t ? "☑" : "☐" } : Array.isArray(e.format) && e.format.length >= 2 ? { text: String(t ? e.format[0] : e.format[1]) } : { text: t ? String(e.format) : "" };
|
|
3658
3852
|
if (e.type === "number" && typeof t == "number") {
|
|
@@ -3664,45 +3858,49 @@ const q = class q {
|
|
|
3664
3858
|
if ((e.type === "date" || e.type === "time" || e.type === "datetime") && (t instanceof Date || typeof t == "string")) {
|
|
3665
3859
|
const i = e.format, n = e.type === "date" ? i ?? "yyyy-MM-dd" : e.type === "time" ? i ?? "HH:mm" : i ?? "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
|
3666
3860
|
let s = null;
|
|
3667
|
-
return t instanceof Date ? s = t : s = this.valueFormatCache.parseIsoDate(t), s ? { text:
|
|
3861
|
+
return t instanceof Date ? s = t : s = this.valueFormatCache.parseIsoDate(t), s ? { text: fe(s, n) } : { text: String(t) };
|
|
3668
3862
|
}
|
|
3669
3863
|
return { text: String(t) };
|
|
3670
3864
|
}
|
|
3671
3865
|
};
|
|
3672
|
-
|
|
3673
|
-
let kt =
|
|
3674
|
-
class
|
|
3675
|
-
constructor(t, e, i, n, s, o, l, a, c,
|
|
3676
|
-
this.dataModel = a, this.onActiveChange = u, this.onSelectionChange = m, this.onUndo = p, this.onRedo =
|
|
3866
|
+
U.MAX_CANVAS_DIM_PX = 8192, U.ROW_HEIGHT_MEASURE_CHUNK = 500, U.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS = 8, U.TEXT_MEASURE_CACHE_MAX = 2e3;
|
|
3867
|
+
let kt = U;
|
|
3868
|
+
class On {
|
|
3869
|
+
constructor(t, e, i, n, s, o, l, a, c, h, d, u, g, m, p, v) {
|
|
3870
|
+
this.dataModel = a, this.onActiveChange = u, this.onSelectionChange = m, this.onUndo = p, this.onRedo = v, this.hitAction = null, this.handleDocumentContextMenu = null, this.selectionRanges = [], this.inputEl = null, this.floatingInputWrapper = null, this.selectionInput = null, this.copyToastEl = null, this.copyToastTimer = null, 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.rootCursorBackup = null, this.lastPointerClient = null, this.autoScrollRaf = null, this.autoScrollActive = !1, this.activeCell = null, this.activeHost = null, this.activeHostOriginalText = null, this.composing = !1, this.lastCompositionEnd = 0, this.handleInputCompositionStart = () => {
|
|
3871
|
+
this.composing = !0;
|
|
3872
|
+
}, this.handleInputCompositionEnd = () => {
|
|
3873
|
+
this.composing = !1, this.lastCompositionEnd = Date.now();
|
|
3874
|
+
}, this.handleSelectionBlur = () => this.teardownSelectionInput(), this.handleRootKeydown = async (f) => {
|
|
3677
3875
|
if (f.defaultPrevented || !this.selectionMode || this.inputEl || f.isComposing || this.composing || !(typeof navigator < "u" && /mac/i.test(navigator.platform) ? f.metaKey : f.ctrlKey)) return;
|
|
3678
|
-
const
|
|
3679
|
-
|
|
3876
|
+
const C = f.key.toLowerCase();
|
|
3877
|
+
C === "c" ? (f.preventDefault(), await this.copySelection()) : C === "x" && (f.preventDefault(), await this.copySelection(), this.clearSelectionValues());
|
|
3680
3878
|
}, this.handlePointerDown = (f) => {
|
|
3681
3879
|
if (f.button !== 0) return;
|
|
3682
3880
|
const y = f.target;
|
|
3683
3881
|
if (y?.closest('button[data-extable-fs-open="1"]') || y?.closest(".extable-filter-sort-trigger") || this.inputEl && f.target && this.inputEl.contains(f.target)) return;
|
|
3684
3882
|
if (this.inputEl && this.activeCell && this.activeCell.colKey !== null) {
|
|
3685
|
-
const { rowId: R, colKey:
|
|
3686
|
-
this.commitEdit(R,
|
|
3883
|
+
const { rowId: R, colKey: H } = this.activeCell, M = this.readActiveValue();
|
|
3884
|
+
this.commitEdit(R, H, M), this.onMove(R), this.teardownInput(!1);
|
|
3687
3885
|
}
|
|
3688
3886
|
if (this.fillDragging) return;
|
|
3689
3887
|
const w = this.hitTest(f);
|
|
3690
3888
|
if (!w || w.rowId === "__all__" && w.colKey === "__all__" || w.colKey === "__all__") return;
|
|
3691
|
-
const
|
|
3692
|
-
if (
|
|
3693
|
-
const R = this.dataModel.getSchema(),
|
|
3694
|
-
if (L &&
|
|
3695
|
-
const
|
|
3696
|
-
if (
|
|
3889
|
+
const C = Re(this.dataModel, this.selectionRanges);
|
|
3890
|
+
if (C && this.activeCell) {
|
|
3891
|
+
const R = this.dataModel.getSchema(), H = this.dataModel.listRows(), M = C.endRowIndex, K = C.colIndex, L = H[M], _ = R.columns[K];
|
|
3892
|
+
if (L && _) {
|
|
3893
|
+
const E = this.findHtmlCellElement(L.id, _.key)?.getBoundingClientRect() ?? this.computeCanvasCellRect(L.id, _.key);
|
|
3894
|
+
if (E && Mt(
|
|
3697
3895
|
this.dataModel,
|
|
3698
3896
|
this.selectionRanges,
|
|
3699
3897
|
this.activeCell.rowId,
|
|
3700
3898
|
this.activeCell.colKey,
|
|
3701
3899
|
this.editMode
|
|
3702
3900
|
)) {
|
|
3703
|
-
const B =
|
|
3704
|
-
if (
|
|
3705
|
-
f.preventDefault(), this.fillDragging = !0, this.fillSource =
|
|
3901
|
+
const B = Ee(E, Ie);
|
|
3902
|
+
if (Te(f.clientX, f.clientY, B)) {
|
|
3903
|
+
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;
|
|
3706
3904
|
try {
|
|
3707
3905
|
f.target?.setPointerCapture?.(f.pointerId);
|
|
3708
3906
|
} catch {
|
|
@@ -3710,10 +3908,10 @@ class En {
|
|
|
3710
3908
|
this.selectionRanges = [
|
|
3711
3909
|
{
|
|
3712
3910
|
kind: "cells",
|
|
3713
|
-
startRow:
|
|
3714
|
-
endRow:
|
|
3715
|
-
startCol:
|
|
3716
|
-
endCol:
|
|
3911
|
+
startRow: C.startRowIndex,
|
|
3912
|
+
endRow: C.endRowIndex,
|
|
3913
|
+
startCol: C.colIndex,
|
|
3914
|
+
endCol: C.colIndex
|
|
3717
3915
|
}
|
|
3718
3916
|
], this.onSelectionChange(this.selectionRanges), this.startAutoScroll();
|
|
3719
3917
|
return;
|
|
@@ -3721,25 +3919,25 @@ class En {
|
|
|
3721
3919
|
}
|
|
3722
3920
|
}
|
|
3723
3921
|
}
|
|
3724
|
-
const S = this.dataModel.getSchema(), b = this.dataModel.listRows(), x = w.rowId === "__header__" ? 0 : this.dataModel.getRowIndex(w.rowId),
|
|
3725
|
-
if (
|
|
3922
|
+
const S = this.dataModel.getSchema(), b = this.dataModel.listRows(), x = w.rowId === "__header__" ? 0 : this.dataModel.getRowIndex(w.rowId), D = S.columns.findIndex((R) => String(R.key) === String(w.colKey));
|
|
3923
|
+
if (D < 0) return;
|
|
3726
3924
|
if (w.rowId === "__header__") {
|
|
3727
3925
|
if (!b.length) return;
|
|
3728
3926
|
const R = {
|
|
3729
3927
|
kind: "cells",
|
|
3730
3928
|
startRow: 0,
|
|
3731
3929
|
endRow: b.length - 1,
|
|
3732
|
-
startCol:
|
|
3733
|
-
endCol:
|
|
3930
|
+
startCol: D,
|
|
3931
|
+
endCol: D
|
|
3734
3932
|
};
|
|
3735
3933
|
this.selectionRanges = [R], this.onSelectionChange(this.selectionRanges), this.dragging = !1, this.selectionMode = !0, this.dragStart = null, this.selectionAnchor = null, this.suppressNextClick = !1;
|
|
3736
|
-
const
|
|
3737
|
-
|
|
3934
|
+
const H = b[0], M = S.columns[D];
|
|
3935
|
+
H && M && (this.activeCell = { rowId: H.id, colKey: M.key }, this.onActiveChange(H.id, M.key)), this.focusSelectionInput("");
|
|
3738
3936
|
return;
|
|
3739
3937
|
}
|
|
3740
3938
|
if (x < 0) return;
|
|
3741
|
-
const
|
|
3742
|
-
this.dragging = !0, this.pointerDownClient = { x: f.clientX, y: f.clientY }, this.dragMoved = !1, this.dragSelectionChanged = !1, this.dragStart = { rowIndex: x, colIndex:
|
|
3939
|
+
const F = w.colKey === null ? "rows" : "cells";
|
|
3940
|
+
this.dragging = !0, this.pointerDownClient = { x: f.clientX, y: f.clientY }, this.dragMoved = !1, this.dragSelectionChanged = !1, this.dragStart = { rowIndex: x, colIndex: D, kind: F }, this.suppressNextClick = !1, this.selectionMode = !0, this.selectionAnchor = null, this.lastPointerClient = { x: f.clientX, y: f.clientY };
|
|
3743
3941
|
try {
|
|
3744
3942
|
f.target?.setPointerCapture?.(f.pointerId);
|
|
3745
3943
|
} catch {
|
|
@@ -3760,13 +3958,13 @@ class En {
|
|
|
3760
3958
|
}
|
|
3761
3959
|
}, this.handlePointerUp = (f) => {
|
|
3762
3960
|
if (this.fillDragging && this.fillSource) {
|
|
3763
|
-
const w = this.fillSource,
|
|
3961
|
+
const w = this.fillSource, C = this.fillEndRowIndex ?? w.endRowIndex;
|
|
3764
3962
|
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();
|
|
3765
3963
|
try {
|
|
3766
3964
|
f.target?.releasePointerCapture?.(f.pointerId);
|
|
3767
3965
|
} catch {
|
|
3768
3966
|
}
|
|
3769
|
-
this.commitFill(w,
|
|
3967
|
+
this.commitFill(w, C), this.suppressNextClick = !0;
|
|
3770
3968
|
return;
|
|
3771
3969
|
}
|
|
3772
3970
|
if (!this.dragging) return;
|
|
@@ -3792,10 +3990,31 @@ class En {
|
|
|
3792
3990
|
}, this.handleSelectionPaste = (f) => {
|
|
3793
3991
|
if (!this.selectionMode) return;
|
|
3794
3992
|
f.preventDefault();
|
|
3795
|
-
const y = f.clipboardData?.getData("text/html") ?? "", w = f.clipboardData?.getData("text/tab-separated-values") ?? "",
|
|
3993
|
+
const y = f.clipboardData?.getData("text/html") ?? "", w = f.clipboardData?.getData("text/tab-separated-values") ?? "", C = f.clipboardData?.getData("text/plain") ?? "", S = this.parseClipboardGrid({ html: y, tsv: w, text: C });
|
|
3796
3994
|
S && this.applyClipboardGrid(S);
|
|
3797
|
-
}, this.handleSelectionCompositionStart = () => {
|
|
3798
|
-
|
|
3995
|
+
}, this.handleSelectionCompositionStart = (f) => {
|
|
3996
|
+
if (!this.selectionMode) return;
|
|
3997
|
+
const y = this.activeCell;
|
|
3998
|
+
if (!(!y || y.colKey === null)) {
|
|
3999
|
+
if (this.isCellReadonly(y.rowId, y.colKey)) {
|
|
4000
|
+
f?.preventDefault?.(), f?.stopPropagation?.();
|
|
4001
|
+
const w = this.dataModel.getCell(y.rowId, y.colKey), C = this.cellToClipboardString(w);
|
|
4002
|
+
this.teardownSelectionInput(), this.focusSelectionInput(C);
|
|
4003
|
+
return;
|
|
4004
|
+
}
|
|
4005
|
+
this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell();
|
|
4006
|
+
}
|
|
4007
|
+
}, this.handleSelectionBeforeInput = (f) => {
|
|
4008
|
+
if (!this.selectionMode) return;
|
|
4009
|
+
const y = this.activeCell;
|
|
4010
|
+
if (!(!y || y.colKey === null) && this.isCellReadonly(y.rowId, y.colKey)) {
|
|
4011
|
+
f.preventDefault();
|
|
4012
|
+
try {
|
|
4013
|
+
const w = this.dataModel.getCell(y.rowId, y.colKey), C = this.cellToClipboardString(w), S = this.ensureSelectionInput();
|
|
4014
|
+
S.value = C, S.select();
|
|
4015
|
+
} catch {
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
3799
4018
|
}, this.handleSelectionKeydown = async (f) => {
|
|
3800
4019
|
if (!this.selectionMode || !this.activeCell || f.isComposing || this.composing || f.key === "Shift" || f.key === "Control" || f.key === "Alt" || f.key === "Meta" || f.key === "CapsLock" || f.key === "NumLock" || f.key === "ScrollLock")
|
|
3801
4020
|
return;
|
|
@@ -3836,9 +4055,9 @@ class En {
|
|
|
3836
4055
|
this.selectionAnchor = null;
|
|
3837
4056
|
return;
|
|
3838
4057
|
}
|
|
3839
|
-
const
|
|
3840
|
-
if (
|
|
3841
|
-
if (f.preventDefault(), this.teardownSelectionInput(),
|
|
4058
|
+
const C = f.key === "Tab", S = f.key === "Enter", b = f.key === "ArrowLeft" || f.key === "ArrowRight" || f.key === "ArrowUp" || f.key === "ArrowDown";
|
|
4059
|
+
if (C || S || b) {
|
|
4060
|
+
if (f.preventDefault(), this.teardownSelectionInput(), C) {
|
|
3842
4061
|
this.moveActiveCell(0, f.shiftKey ? -1 : 1, !1);
|
|
3843
4062
|
return;
|
|
3844
4063
|
}
|
|
@@ -3850,6 +4069,10 @@ class En {
|
|
|
3850
4069
|
f.key === "ArrowLeft" ? this.moveActiveCell(0, -1, x) : f.key === "ArrowRight" ? this.moveActiveCell(0, 1, x) : f.key === "ArrowUp" ? this.moveActiveCell(-1, 0, x) : f.key === "ArrowDown" && this.moveActiveCell(1, 0, x);
|
|
3851
4070
|
return;
|
|
3852
4071
|
}
|
|
4072
|
+
if (this.activeCell.colKey !== null && this.isCellReadonly(this.activeCell.rowId, this.activeCell.colKey)) {
|
|
4073
|
+
f.preventDefault(), this.selectionAnchor = null;
|
|
4074
|
+
return;
|
|
4075
|
+
}
|
|
3853
4076
|
this.selectionMode = !1, this.selectionAnchor = null, this.teardownSelectionInput(), this.openEditorAtActiveCell();
|
|
3854
4077
|
}, this.handleClick = (f) => {
|
|
3855
4078
|
if (f.button !== 0 || f.target?.closest('button[data-extable-fs-open="1"]'))
|
|
@@ -3861,24 +4084,31 @@ class En {
|
|
|
3861
4084
|
if (this.inputEl && f.target && this.inputEl.contains(f.target))
|
|
3862
4085
|
return;
|
|
3863
4086
|
if (this.inputEl && this.activeCell && this.activeCell.colKey !== null) {
|
|
3864
|
-
const { rowId: R, colKey:
|
|
3865
|
-
this.commitEdit(R,
|
|
4087
|
+
const { rowId: R, colKey: H } = this.activeCell, M = this.readActiveValue();
|
|
4088
|
+
this.commitEdit(R, H, M), this.onMove(R), this.teardownInput(!1);
|
|
3866
4089
|
}
|
|
3867
4090
|
const w = typeof document.elementFromPoint == "function" ? this.getHitAtClientPoint(f.clientX, f.clientY) : this.hitTest(f);
|
|
3868
4091
|
if (!w) return;
|
|
3869
|
-
const
|
|
3870
|
-
if (
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
4092
|
+
const C = this.hitAction ? this.hitAction(f) : null;
|
|
4093
|
+
if (C) {
|
|
4094
|
+
if (globalThis.__EXTABLE_DEBUG_ACTIONS && console.log("[extable][canvas][action-click]", C), C.kind === "tag-remove") {
|
|
4095
|
+
if (this.removeTagValue(C.rowId, C.colKey, C.tagIndex)) {
|
|
4096
|
+
f.preventDefault();
|
|
4097
|
+
return;
|
|
4098
|
+
}
|
|
4099
|
+
} else if (this.triggerCellAction(C.rowId, C.colKey, C.kind)) {
|
|
4100
|
+
f.preventDefault();
|
|
4101
|
+
return;
|
|
4102
|
+
}
|
|
4103
|
+
} else globalThis.__EXTABLE_DEBUG_ACTIONS && console.log("[extable][canvas][action-click]", null);
|
|
3874
4104
|
const S = this.selectionMode && !f.shiftKey && !f.metaKey && !f.ctrlKey && this.activeCell?.rowId === w.rowId && String(this.activeCell?.colKey) === String(w.colKey);
|
|
3875
4105
|
if (w.rowId === "__all__" && w.colKey === "__all__") {
|
|
3876
|
-
const R = this.dataModel.getSchema(),
|
|
3877
|
-
this.teardownInput(!1),
|
|
4106
|
+
const R = this.dataModel.getSchema(), H = this.dataModel.listRows();
|
|
4107
|
+
this.teardownInput(!1), H.length && R.columns.length ? (this.selectionRanges = [
|
|
3878
4108
|
{
|
|
3879
4109
|
kind: "cells",
|
|
3880
4110
|
startRow: 0,
|
|
3881
|
-
endRow:
|
|
4111
|
+
endRow: H.length - 1,
|
|
3882
4112
|
startCol: 0,
|
|
3883
4113
|
endCol: R.columns.length - 1
|
|
3884
4114
|
}
|
|
@@ -3886,16 +4116,16 @@ class En {
|
|
|
3886
4116
|
return;
|
|
3887
4117
|
}
|
|
3888
4118
|
if (this.onRowSelect(w.rowId), w.rowId === "__header__") {
|
|
3889
|
-
const R = this.dataModel.getSchema(),
|
|
3890
|
-
|
|
4119
|
+
const R = this.dataModel.getSchema(), H = this.dataModel.listRows(), M = R.columns.findIndex((K) => String(K.key) === String(w.colKey));
|
|
4120
|
+
H.length && M >= 0 && (this.selectionRanges = [
|
|
3891
4121
|
{
|
|
3892
4122
|
kind: "cells",
|
|
3893
4123
|
startRow: 0,
|
|
3894
|
-
endRow:
|
|
4124
|
+
endRow: H.length - 1,
|
|
3895
4125
|
startCol: M,
|
|
3896
4126
|
endCol: M
|
|
3897
4127
|
}
|
|
3898
|
-
], this.activeCell = { rowId:
|
|
4128
|
+
], this.activeCell = { rowId: H[0].id, colKey: w.colKey }, this.onActiveChange(this.activeCell.rowId, this.activeCell.colKey), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput(""));
|
|
3899
4129
|
return;
|
|
3900
4130
|
}
|
|
3901
4131
|
if (this.applySelectionFromHit(f, w), w.colKey === null || w.colKey === "__all__") {
|
|
@@ -3922,8 +4152,8 @@ class En {
|
|
|
3922
4152
|
return;
|
|
3923
4153
|
}
|
|
3924
4154
|
this.lastBooleanCell = null, this.selectionAnchor = null, this.teardownInput(!1);
|
|
3925
|
-
const
|
|
3926
|
-
this.focusSelectionInput(
|
|
4155
|
+
const D = this.dataModel.getCell(w.rowId, w.colKey), F = this.cellToClipboardString(D);
|
|
4156
|
+
this.focusSelectionInput(F), S && (this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell());
|
|
3927
4157
|
}, this.handleContextMenu = (f) => {
|
|
3928
4158
|
const y = f.target;
|
|
3929
4159
|
if (f.ctrlKey) {
|
|
@@ -3932,9 +4162,9 @@ class En {
|
|
|
3932
4162
|
}
|
|
3933
4163
|
if (!y || !this.root.contains(y)) return;
|
|
3934
4164
|
f.preventDefault(), f.stopPropagation();
|
|
3935
|
-
const w = this.hitTest(f),
|
|
3936
|
-
this.onContextMenu(
|
|
3937
|
-
}, this.root = t, this.editMode = e, this.onEdit = i, this.onRowSelect = n, this.onMove = s, this.hitTest = o, this.hitAction = l, this.sequenceLangs = c, this.isCellReadonly =
|
|
4165
|
+
const w = this.hitTest(f), C = w?.rowId ?? null, S = w?.colKey ?? null;
|
|
4166
|
+
this.onContextMenu(C, S, f.clientX, f.clientY);
|
|
4167
|
+
}, this.root = t, this.editMode = e, this.onEdit = i, this.onRowSelect = n, this.onMove = s, this.hitTest = o, this.hitAction = l, this.sequenceLangs = c, this.isCellReadonly = h, this.onCellAction = d, this.onContextMenu = g, this.bind();
|
|
3938
4168
|
}
|
|
3939
4169
|
setEditMode(t) {
|
|
3940
4170
|
this.editMode = t;
|
|
@@ -3959,15 +4189,15 @@ class En {
|
|
|
3959
4189
|
}
|
|
3960
4190
|
], y = !0;
|
|
3961
4191
|
else {
|
|
3962
|
-
const w = this.selectionRanges.map((
|
|
3963
|
-
const S = (x,
|
|
3964
|
-
...
|
|
3965
|
-
startRow: S(
|
|
3966
|
-
endRow: S(
|
|
3967
|
-
startCol: S(
|
|
3968
|
-
endCol: S(
|
|
4192
|
+
const w = this.selectionRanges.map((C) => {
|
|
4193
|
+
const S = (x, D) => Math.max(0, Math.min(D, x)), b = {
|
|
4194
|
+
...C,
|
|
4195
|
+
startRow: S(C.startRow, i),
|
|
4196
|
+
endRow: S(C.endRow, i),
|
|
4197
|
+
startCol: S(C.startCol, n),
|
|
4198
|
+
endCol: S(C.endCol, n)
|
|
3969
4199
|
};
|
|
3970
|
-
return (b.startRow !==
|
|
4200
|
+
return (b.startRow !== C.startRow || b.endRow !== C.endRow || b.startCol !== C.startCol || b.endCol !== C.endCol) && (y = !0), b;
|
|
3971
4201
|
});
|
|
3972
4202
|
this.selectionRanges = w;
|
|
3973
4203
|
}
|
|
@@ -3975,21 +4205,21 @@ class En {
|
|
|
3975
4205
|
return;
|
|
3976
4206
|
}
|
|
3977
4207
|
const c = o ?? t.columns[0]?.key ?? "";
|
|
3978
|
-
let
|
|
3979
|
-
|
|
3980
|
-
const
|
|
4208
|
+
let h = t.columns.findIndex((y) => String(y.key) === String(c));
|
|
4209
|
+
h < 0 && (h = 0);
|
|
4210
|
+
const d = t.columns[h]?.key ?? "", u = s ? this.dataModel.getBaseRowIndex(s) : 0, g = e[e.length - 1] ?? e[0] ?? null, m = e.find((y) => this.dataModel.getBaseRowIndex(y.id) >= u) ?? g;
|
|
3981
4211
|
if (!m) return;
|
|
3982
|
-
const p = m.id,
|
|
4212
|
+
const p = m.id, v = this.dataModel.getRowIndex(p);
|
|
3983
4213
|
this.selectionAnchor = null, this.lastBooleanCell = null, this.teardownInput(!1), this.selectionRanges = [
|
|
3984
4214
|
{
|
|
3985
4215
|
kind: "cells",
|
|
3986
|
-
startRow:
|
|
3987
|
-
endRow:
|
|
3988
|
-
startCol:
|
|
3989
|
-
endCol:
|
|
4216
|
+
startRow: v,
|
|
4217
|
+
endRow: v,
|
|
4218
|
+
startCol: h,
|
|
4219
|
+
endCol: h
|
|
3990
4220
|
}
|
|
3991
|
-
], this.activeCell = { rowId: p, colKey:
|
|
3992
|
-
const f = this.dataModel.getCell(p,
|
|
4221
|
+
], this.activeCell = { rowId: p, colKey: d }, this.onActiveChange(p, d), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(p, d);
|
|
4222
|
+
const f = this.dataModel.getCell(p, d);
|
|
3993
4223
|
this.focusSelectionInput(this.cellToClipboardString(f)), this.updateFillHandleFlag();
|
|
3994
4224
|
}
|
|
3995
4225
|
navigateToCell(t, e) {
|
|
@@ -4021,7 +4251,7 @@ class En {
|
|
|
4021
4251
|
}
|
|
4022
4252
|
updateFillHandleFlag() {
|
|
4023
4253
|
const t = this.activeCell?.colKey ?? null, e = this.activeCell?.rowId ?? null;
|
|
4024
|
-
this.root.dataset.extableFillHandle =
|
|
4254
|
+
this.root.dataset.extableFillHandle = Mt(
|
|
4025
4255
|
this.dataModel,
|
|
4026
4256
|
this.selectionRanges,
|
|
4027
4257
|
e,
|
|
@@ -4073,13 +4303,13 @@ class En {
|
|
|
4073
4303
|
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;
|
|
4074
4304
|
}
|
|
4075
4305
|
teardownCopyToast() {
|
|
4076
|
-
this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastEl && (this.copyToastEl.style.display = "none",
|
|
4306
|
+
this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastEl && (this.copyToastEl.style.display = "none", j(this.copyToastEl), this.copyToastEl = null);
|
|
4077
4307
|
}
|
|
4078
4308
|
positionCopyToast() {
|
|
4079
4309
|
if (!this.copyToastEl) return;
|
|
4080
4310
|
const t = this.copyToastEl.offsetWidth || 0, e = this.copyToastEl.offsetHeight || 0, i = 16, n = Math.max(0, this.root.scrollLeft + this.root.clientWidth - t - i), s = Math.max(0, this.root.scrollTop + this.root.clientHeight - e - i), o = Math.max(0, this.root.scrollLeft + i), l = Math.max(0, this.root.scrollTop + i), a = this.root.getBoundingClientRect(), c = this.getActiveCellRect();
|
|
4081
4311
|
if (c) {
|
|
4082
|
-
const
|
|
4312
|
+
const h = c.right - a.left + this.root.scrollLeft - t + 8, d = c.top - a.top + this.root.scrollTop - e + 8, u = Math.min(n, Math.max(o, h)), g = Math.min(s, Math.max(l, d));
|
|
4083
4313
|
this.copyToastEl.style.left = `${u}px`, this.copyToastEl.style.top = `${g}px`;
|
|
4084
4314
|
return;
|
|
4085
4315
|
}
|
|
@@ -4094,7 +4324,7 @@ class En {
|
|
|
4094
4324
|
ensureSelectionInput() {
|
|
4095
4325
|
if (this.selectionInput) return this.selectionInput;
|
|
4096
4326
|
const t = document.createElement("input");
|
|
4097
|
-
return t.type = "text", t.autocomplete = "off", t.spellcheck = !1, t.style.position = "absolute", t.style.left = "0", t.style.top = "0", t.style.transform = "translate(-10000px, 0)", t.style.width = "1px", t.style.height = "1px", t.style.opacity = "0", t.style.pointerEvents = "none", t.addEventListener("keydown", this.handleSelectionKeydown), t.addEventListener("compositionstart", this.handleSelectionCompositionStart), t.addEventListener("copy", this.handleSelectionCopy), t.addEventListener("cut", this.handleSelectionCut), t.addEventListener("paste", this.handleSelectionPaste), t.addEventListener("blur", this.handleSelectionBlur), this.root.appendChild(t), this.selectionInput = t, t;
|
|
4327
|
+
return t.type = "text", t.readOnly = !0, t.inputMode = "none", t.autocomplete = "off", t.spellcheck = !1, t.style.position = "absolute", t.style.left = "0", t.style.top = "0", t.style.transform = "translate(-10000px, 0)", t.style.width = "1px", t.style.height = "1px", t.style.opacity = "0", t.style.pointerEvents = "none", t.addEventListener("keydown", this.handleSelectionKeydown), t.addEventListener("beforeinput", this.handleSelectionBeforeInput), t.addEventListener("compositionstart", this.handleSelectionCompositionStart), t.addEventListener("copy", this.handleSelectionCopy), t.addEventListener("cut", this.handleSelectionCut), t.addEventListener("paste", this.handleSelectionPaste), t.addEventListener("blur", this.handleSelectionBlur), this.root.appendChild(t), this.selectionInput = t, t;
|
|
4098
4328
|
}
|
|
4099
4329
|
focusSelectionInput(t) {
|
|
4100
4330
|
const e = this.ensureSelectionInput();
|
|
@@ -4141,19 +4371,19 @@ class En {
|
|
|
4141
4371
|
) ? this.getCanvasCellMetrics(t, e) : null;
|
|
4142
4372
|
}
|
|
4143
4373
|
getCanvasCellMetrics(t, e) {
|
|
4144
|
-
const i = this.dataModel.getSchema(), n = this.dataModel.getView(), s = this.dataModel.listRows(), o = s.findIndex((
|
|
4374
|
+
const i = this.dataModel.getSchema(), n = this.dataModel.getView(), s = this.dataModel.listRows(), o = s.findIndex((v) => v.id === t), l = i.columns.findIndex((v) => String(v.key) === String(e));
|
|
4145
4375
|
if (o < 0 || l < 0) return null;
|
|
4146
|
-
const a = dt, c =
|
|
4376
|
+
const a = dt, c = st, h = ht, d = G(i, n);
|
|
4147
4377
|
let u = c;
|
|
4148
|
-
for (let
|
|
4378
|
+
for (let v = 0; v < l; v += 1) u += d[v] ?? 100;
|
|
4149
4379
|
let g = a;
|
|
4150
|
-
for (let
|
|
4151
|
-
const f = s[
|
|
4380
|
+
for (let v = 0; v < o; v += 1) {
|
|
4381
|
+
const f = s[v];
|
|
4152
4382
|
if (!f) return null;
|
|
4153
|
-
const y = this.dataModel.getRowHeight(f.id) ??
|
|
4383
|
+
const y = this.dataModel.getRowHeight(f.id) ?? h;
|
|
4154
4384
|
g += y;
|
|
4155
4385
|
}
|
|
4156
|
-
const m = this.dataModel.getRowHeight(t) ??
|
|
4386
|
+
const m = this.dataModel.getRowHeight(t) ?? h, p = d[l] ?? 100;
|
|
4157
4387
|
return { left: u, top: g, width: p, height: m, rowIndex: o, colIndex: l };
|
|
4158
4388
|
}
|
|
4159
4389
|
getActiveCellRect() {
|
|
@@ -4161,20 +4391,20 @@ class En {
|
|
|
4161
4391
|
if (!t) return null;
|
|
4162
4392
|
const e = this.root.getBoundingClientRect(), i = this.dataModel.getSchema(), n = this.dataModel.getView();
|
|
4163
4393
|
if (t.rowId === "__all__" && t.colKey === "__all__")
|
|
4164
|
-
return new DOMRect(e.left, e.top,
|
|
4394
|
+
return new DOMRect(e.left, e.top, st, dt);
|
|
4165
4395
|
if (t.rowId === "__header__" && t.colKey !== null) {
|
|
4166
4396
|
const o = this.escapeCssAttrValue(String(t.colKey)), l = this.root.querySelector(`th[data-col-key="${o}"]`);
|
|
4167
4397
|
if (l) return l.getBoundingClientRect();
|
|
4168
4398
|
const a = i.columns.findIndex((c) => String(c.key) === String(t.colKey));
|
|
4169
4399
|
if (a >= 0) {
|
|
4170
4400
|
const c = G(i, n);
|
|
4171
|
-
let
|
|
4172
|
-
for (let u = 0; u < a; u += 1)
|
|
4173
|
-
const
|
|
4401
|
+
let h = st;
|
|
4402
|
+
for (let u = 0; u < a; u += 1) h += c[u] ?? 100;
|
|
4403
|
+
const d = c[a] ?? 100;
|
|
4174
4404
|
return new DOMRect(
|
|
4175
|
-
e.left +
|
|
4405
|
+
e.left + h - this.root.scrollLeft,
|
|
4176
4406
|
e.top,
|
|
4177
|
-
|
|
4407
|
+
d,
|
|
4178
4408
|
dt
|
|
4179
4409
|
);
|
|
4180
4410
|
}
|
|
@@ -4184,16 +4414,16 @@ class En {
|
|
|
4184
4414
|
if (o >= 0) {
|
|
4185
4415
|
let l = dt;
|
|
4186
4416
|
const a = this.dataModel.listRows();
|
|
4187
|
-
for (let
|
|
4188
|
-
const
|
|
4189
|
-
if (!
|
|
4190
|
-
l += this.dataModel.getRowHeight(
|
|
4417
|
+
for (let h = 0; h < o; h += 1) {
|
|
4418
|
+
const d = a[h];
|
|
4419
|
+
if (!d) break;
|
|
4420
|
+
l += this.dataModel.getRowHeight(d.id) ?? ht;
|
|
4191
4421
|
}
|
|
4192
4422
|
const c = this.dataModel.getRowHeight(t.rowId) ?? ht;
|
|
4193
4423
|
return new DOMRect(
|
|
4194
4424
|
e.left,
|
|
4195
4425
|
e.top + l - this.root.scrollTop,
|
|
4196
|
-
|
|
4426
|
+
st,
|
|
4197
4427
|
c
|
|
4198
4428
|
);
|
|
4199
4429
|
}
|
|
@@ -4210,8 +4440,8 @@ class En {
|
|
|
4210
4440
|
}
|
|
4211
4441
|
const n = this.getCanvasCellMetrics(t, e);
|
|
4212
4442
|
if (!n) return;
|
|
4213
|
-
const s = n.left, o = n.left + n.width, l = n.top, a = n.top + n.height, c = this.root.scrollLeft,
|
|
4214
|
-
s < c ? this.root.scrollLeft = Math.max(0, s) : o >
|
|
4443
|
+
const s = n.left, o = n.left + n.width, l = n.top, a = n.top + n.height, c = this.root.scrollLeft, h = this.root.scrollLeft + this.root.clientWidth, d = this.root.scrollTop, u = this.root.scrollTop + this.root.clientHeight;
|
|
4444
|
+
s < c ? this.root.scrollLeft = Math.max(0, s) : o > h && (this.root.scrollLeft = Math.max(0, o - this.root.clientWidth)), l < d ? this.root.scrollTop = Math.max(0, l) : a > u && (this.root.scrollTop = Math.max(0, a - this.root.clientHeight));
|
|
4215
4445
|
}
|
|
4216
4446
|
moveActiveCell(t, e, i = !1) {
|
|
4217
4447
|
const n = this.dataModel.getSchema(), s = this.dataModel.listRows();
|
|
@@ -4220,27 +4450,27 @@ class En {
|
|
|
4220
4450
|
i || (this.selectionAnchor = null);
|
|
4221
4451
|
const a = i && this.selectionAnchor ? this.selectionAnchor : i ? { rowIndex: o, colIndex: l } : null;
|
|
4222
4452
|
i && !this.selectionAnchor && (this.selectionAnchor = { rowIndex: o, colIndex: l });
|
|
4223
|
-
const c = Math.max(0, Math.min(s.length - 1, o + t)),
|
|
4453
|
+
const c = Math.max(0, Math.min(s.length - 1, o + t)), h = Math.max(0, Math.min(n.columns.length - 1, l + e));
|
|
4224
4454
|
{
|
|
4225
|
-
const
|
|
4226
|
-
if (!
|
|
4227
|
-
const u = n.columns[
|
|
4455
|
+
const d = s[c];
|
|
4456
|
+
if (!d) return;
|
|
4457
|
+
const u = n.columns[h];
|
|
4228
4458
|
if (!u) return;
|
|
4229
|
-
const g =
|
|
4459
|
+
const g = d.id, m = u.key, p = a ? {
|
|
4230
4460
|
kind: "cells",
|
|
4231
4461
|
startRow: a.rowIndex,
|
|
4232
4462
|
endRow: c,
|
|
4233
4463
|
startCol: a.colIndex,
|
|
4234
|
-
endCol:
|
|
4464
|
+
endCol: h
|
|
4235
4465
|
} : {
|
|
4236
4466
|
kind: "cells",
|
|
4237
4467
|
startRow: c,
|
|
4238
4468
|
endRow: c,
|
|
4239
|
-
startCol:
|
|
4240
|
-
endCol:
|
|
4469
|
+
startCol: h,
|
|
4470
|
+
endCol: h
|
|
4241
4471
|
};
|
|
4242
4472
|
this.selectionRanges = [p], this.activeCell = { rowId: g, colKey: m }, this.onActiveChange(g, m), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(g, m);
|
|
4243
|
-
const
|
|
4473
|
+
const v = this.dataModel.getCell(g, m), f = this.cellToClipboardString(v);
|
|
4244
4474
|
this.focusSelectionInput(f), this.updateFillHandleFlag();
|
|
4245
4475
|
return;
|
|
4246
4476
|
}
|
|
@@ -4296,16 +4526,16 @@ class En {
|
|
|
4296
4526
|
if (o < 0) return;
|
|
4297
4527
|
const l = this.dragStart.kind === "rows" ? n.columns.length - 1 : n.columns.findIndex((m) => String(m.key) === String(i.colKey));
|
|
4298
4528
|
if (l < 0) return;
|
|
4299
|
-
const a = this.dragStart.rowIndex, c = this.dragStart.kind === "rows" ? 0 : this.dragStart.colIndex,
|
|
4300
|
-
(o !== a ||
|
|
4301
|
-
const
|
|
4529
|
+
const a = this.dragStart.rowIndex, c = this.dragStart.kind === "rows" ? 0 : this.dragStart.colIndex, h = this.dragStart.kind === "rows" ? n.columns.length - 1 : l;
|
|
4530
|
+
(o !== a || h !== c) && (this.dragSelectionChanged = !0);
|
|
4531
|
+
const d = {
|
|
4302
4532
|
kind: this.dragStart.kind,
|
|
4303
4533
|
startRow: a,
|
|
4304
4534
|
endRow: o,
|
|
4305
4535
|
startCol: c,
|
|
4306
|
-
endCol:
|
|
4536
|
+
endCol: h
|
|
4307
4537
|
};
|
|
4308
|
-
this.selectionRanges = [
|
|
4538
|
+
this.selectionRanges = [d];
|
|
4309
4539
|
const u = s[o]?.id ?? i.rowId, g = this.dragStart.kind === "rows" ? n.columns[0]?.key ?? i.colKey : n.columns[l]?.key ?? i.colKey;
|
|
4310
4540
|
this.activeCell = { rowId: u, colKey: g }, this.onActiveChange(u, g), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
|
|
4311
4541
|
}
|
|
@@ -4318,10 +4548,10 @@ class En {
|
|
|
4318
4548
|
const a = Math.max(this.fillSource.endRowIndex, o);
|
|
4319
4549
|
if (this.fillEndRowIndex !== a) {
|
|
4320
4550
|
this.fillEndRowIndex = a;
|
|
4321
|
-
const c = s[a]?.id ?? i.rowId,
|
|
4322
|
-
if (!
|
|
4323
|
-
const
|
|
4324
|
-
this.activeCell = { rowId: c, colKey:
|
|
4551
|
+
const c = s[a]?.id ?? i.rowId, h = n.columns[this.fillSource.colIndex];
|
|
4552
|
+
if (!h) return;
|
|
4553
|
+
const d = h.key;
|
|
4554
|
+
this.activeCell = { rowId: c, colKey: d }, this.onActiveChange(c, d), this.selectionRanges = [
|
|
4325
4555
|
{
|
|
4326
4556
|
kind: "cells",
|
|
4327
4557
|
startRow: this.fillSource.startRowIndex,
|
|
@@ -4364,14 +4594,14 @@ class En {
|
|
|
4364
4594
|
commitFill(t, e) {
|
|
4365
4595
|
const i = this.dataModel.getSchema(), n = this.dataModel.listRows(), s = i.columns[t.colIndex];
|
|
4366
4596
|
if (!s || e <= t.endRowIndex) return;
|
|
4367
|
-
const o =
|
|
4597
|
+
const o = Vn(this.dataModel, t, this.sequenceLangs);
|
|
4368
4598
|
if (!o) return;
|
|
4369
4599
|
const l = this.editMode === "direct", a = `fill:${Date.now()}:${Math.random().toString(16).slice(2)}`;
|
|
4370
|
-
for (let
|
|
4371
|
-
const u = n[
|
|
4600
|
+
for (let d = t.endRowIndex + 1; d <= e; d += 1) {
|
|
4601
|
+
const u = n[d];
|
|
4372
4602
|
if (!u) break;
|
|
4373
4603
|
if (this.isCellReadonly(u.id, s.key)) continue;
|
|
4374
|
-
const g =
|
|
4604
|
+
const g = d - t.endRowIndex, m = o(g), p = {
|
|
4375
4605
|
kind: "edit",
|
|
4376
4606
|
rowId: u.id,
|
|
4377
4607
|
colKey: s.key,
|
|
@@ -4391,12 +4621,12 @@ class En {
|
|
|
4391
4621
|
endCol: t.colIndex
|
|
4392
4622
|
}
|
|
4393
4623
|
], this.activeCell = { rowId: c.id, colKey: s.key }, this.onActiveChange(c.id, s.key), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.ensureVisibleCell(c.id, s.key);
|
|
4394
|
-
const
|
|
4395
|
-
this.focusSelectionInput(this.cellToClipboardString(
|
|
4624
|
+
const h = this.dataModel.getCell(c.id, s.key);
|
|
4625
|
+
this.focusSelectionInput(this.cellToClipboardString(h));
|
|
4396
4626
|
}
|
|
4397
4627
|
teardownSelectionInput() {
|
|
4398
4628
|
const t = this.selectionInput;
|
|
4399
|
-
t && (this.selectionInput = null, t.removeEventListener("keydown", this.handleSelectionKeydown), 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),
|
|
4629
|
+
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), j(t));
|
|
4400
4630
|
}
|
|
4401
4631
|
async copySelection() {
|
|
4402
4632
|
const t = this.buildSelectionClipboardPayload();
|
|
@@ -4495,21 +4725,21 @@ class En {
|
|
|
4495
4725
|
if (!i || i.kind !== "cells") return null;
|
|
4496
4726
|
const n = [], s = [], o = "border-collapse:collapse;border-spacing:0;", l = "border:1px solid #d0d7de;padding:4px 6px;vertical-align:top;";
|
|
4497
4727
|
let a = 0;
|
|
4498
|
-
for (let
|
|
4499
|
-
const u = e[
|
|
4728
|
+
for (let d = i.startRow; d <= i.endRow; d += 1) {
|
|
4729
|
+
const u = e[d];
|
|
4500
4730
|
if (!u) continue;
|
|
4501
4731
|
const g = [], m = [];
|
|
4502
4732
|
for (let p = i.startCol; p <= i.endCol; p += 1) {
|
|
4503
|
-
const
|
|
4504
|
-
if (!
|
|
4505
|
-
const f = this.dataModel.getCell(u.id,
|
|
4733
|
+
const v = t.columns[p];
|
|
4734
|
+
if (!v) continue;
|
|
4735
|
+
const f = this.dataModel.getCell(u.id, v.key), y = this.cellToClipboardString(f);
|
|
4506
4736
|
g.push(y), m.push(`<td style="${l}">${this.escapeHtml(y)}</td>`), a += 1;
|
|
4507
4737
|
}
|
|
4508
4738
|
n.push(g.join(" ")), s.push(`<tr>${m.join("")}</tr>`);
|
|
4509
4739
|
}
|
|
4510
4740
|
const c = n.join(`\r
|
|
4511
|
-
`),
|
|
4512
|
-
return { text: c, html:
|
|
4741
|
+
`), h = `<table style="${o}"><tbody>${s.join("")}</tbody></table>`;
|
|
4742
|
+
return { text: c, html: h, cellCount: a };
|
|
4513
4743
|
}
|
|
4514
4744
|
clearSelectionValues() {
|
|
4515
4745
|
const t = this.dataModel.getSchema(), e = this.dataModel.listRows(), i = this.getCopyRange();
|
|
@@ -4521,14 +4751,14 @@ class En {
|
|
|
4521
4751
|
for (let a = i.startCol; a <= i.endCol; a += 1) {
|
|
4522
4752
|
const c = t.columns[a];
|
|
4523
4753
|
if (!c || this.isCellReadonly(l.id, c.key)) continue;
|
|
4524
|
-
const
|
|
4754
|
+
const h = c.type === "boolean" ? !1 : "", d = {
|
|
4525
4755
|
kind: "edit",
|
|
4526
4756
|
rowId: l.id,
|
|
4527
4757
|
colKey: c.key,
|
|
4528
|
-
next:
|
|
4758
|
+
next: h,
|
|
4529
4759
|
payload: { batchId: s }
|
|
4530
4760
|
};
|
|
4531
|
-
this.onEdit(
|
|
4761
|
+
this.onEdit(d, n);
|
|
4532
4762
|
}
|
|
4533
4763
|
}
|
|
4534
4764
|
}
|
|
@@ -4582,12 +4812,12 @@ class En {
|
|
|
4582
4812
|
for (let a = 0; a < t.length; a += 1) {
|
|
4583
4813
|
const c = i[n + a];
|
|
4584
4814
|
if (!c) break;
|
|
4585
|
-
const
|
|
4586
|
-
for (let
|
|
4587
|
-
const u = e.columns[s +
|
|
4815
|
+
const h = t[a] ?? [];
|
|
4816
|
+
for (let d = 0; d < h.length; d += 1) {
|
|
4817
|
+
const u = e.columns[s + d];
|
|
4588
4818
|
if (!u) break;
|
|
4589
4819
|
if (this.isCellReadonly(c.id, u.key)) continue;
|
|
4590
|
-
const g = this.coerceCellValue(d
|
|
4820
|
+
const g = this.coerceCellValue(h[d] ?? "", u.key), m = {
|
|
4591
4821
|
kind: "edit",
|
|
4592
4822
|
rowId: c.id,
|
|
4593
4823
|
colKey: u.key,
|
|
@@ -4622,26 +4852,26 @@ class En {
|
|
|
4622
4852
|
if (i?.type === "enum" || i?.type === "tags") {
|
|
4623
4853
|
const o = i.enum?.allowCustom ?? i.tags?.allowCustom, l = i.enum?.options ?? i.tags?.options ?? [];
|
|
4624
4854
|
if (o === !1) {
|
|
4625
|
-
const
|
|
4626
|
-
u.value = "", u.textContent = "",
|
|
4855
|
+
const d = document.createElement("select"), u = document.createElement("option");
|
|
4856
|
+
u.value = "", u.textContent = "", d.appendChild(u);
|
|
4627
4857
|
for (const g of l) {
|
|
4628
4858
|
const m = document.createElement("option");
|
|
4629
|
-
m.value = g, m.textContent = g, e === g && (m.selected = !0),
|
|
4859
|
+
m.value = g, m.textContent = g, e === g && (m.selected = !0), d.appendChild(m);
|
|
4630
4860
|
}
|
|
4631
|
-
return { control:
|
|
4861
|
+
return { control: d, value: e };
|
|
4632
4862
|
}
|
|
4633
4863
|
const a = document.createElement("input");
|
|
4634
4864
|
a.type = "text";
|
|
4635
4865
|
const c = `extable-datalist-${String(t)}`;
|
|
4636
4866
|
a.setAttribute("list", c), a.value = e;
|
|
4637
|
-
let
|
|
4638
|
-
if (!
|
|
4639
|
-
|
|
4640
|
-
for (const
|
|
4867
|
+
let h = document.getElementById(c);
|
|
4868
|
+
if (!h) {
|
|
4869
|
+
h = document.createElement("datalist"), h.id = c;
|
|
4870
|
+
for (const d of l) {
|
|
4641
4871
|
const u = document.createElement("option");
|
|
4642
|
-
u.value =
|
|
4872
|
+
u.value = d, h.appendChild(u);
|
|
4643
4873
|
}
|
|
4644
|
-
this.root.appendChild(
|
|
4874
|
+
this.root.appendChild(h);
|
|
4645
4875
|
}
|
|
4646
4876
|
return { control: a, value: e, datalistId: c };
|
|
4647
4877
|
}
|
|
@@ -4673,6 +4903,34 @@ class En {
|
|
|
4673
4903
|
}
|
|
4674
4904
|
return !1;
|
|
4675
4905
|
}
|
|
4906
|
+
removeTagValue(t, e, i) {
|
|
4907
|
+
if (this.isCellReadonly(t, e)) return !1;
|
|
4908
|
+
const n = this.findColumn(e);
|
|
4909
|
+
if (!n || n.type !== "tags") return !1;
|
|
4910
|
+
const s = this.dataModel.getCell(t, e), o = this.normalizeTagValues(s);
|
|
4911
|
+
if (!o || i < 0 || i >= o.length) return !1;
|
|
4912
|
+
const l = o.filter((d, u) => u !== i), a = s && typeof s == "object" && s.kind === "tags" ? { kind: "tags", values: l } : l, c = {
|
|
4913
|
+
kind: "edit",
|
|
4914
|
+
rowId: t,
|
|
4915
|
+
colKey: e,
|
|
4916
|
+
next: a
|
|
4917
|
+
}, h = this.editMode === "direct";
|
|
4918
|
+
return this.onEdit(c, h), !0;
|
|
4919
|
+
}
|
|
4920
|
+
normalizeTagValues(t) {
|
|
4921
|
+
if (Array.isArray(t) && t.every((e) => typeof e == "string"))
|
|
4922
|
+
return t;
|
|
4923
|
+
if (t && typeof t == "object") {
|
|
4924
|
+
const e = t;
|
|
4925
|
+
if (e.kind === "tags" && Array.isArray(e.values))
|
|
4926
|
+
return e.values.filter((i) => typeof i == "string");
|
|
4927
|
+
}
|
|
4928
|
+
if (typeof t == "string") {
|
|
4929
|
+
const e = t.trim();
|
|
4930
|
+
return e ? e.split(/\s*,\s*/).filter(Boolean) : [];
|
|
4931
|
+
}
|
|
4932
|
+
return null;
|
|
4933
|
+
}
|
|
4676
4934
|
openLink(t, e) {
|
|
4677
4935
|
if (typeof document > "u" || !t) return;
|
|
4678
4936
|
const i = document.createElement("a");
|
|
@@ -4683,7 +4941,7 @@ class En {
|
|
|
4683
4941
|
this.onEdit(o, l), this.onMove(t);
|
|
4684
4942
|
}
|
|
4685
4943
|
applySelectionFromHit(t, e) {
|
|
4686
|
-
const i = this.dataModel.getSchema(), n = this.dataModel.getRowIndex(e.rowId), s = e.colKey === null, o = s ? i.columns.length > 0 ? 0 : -1 : i.columns.findIndex((
|
|
4944
|
+
const i = this.dataModel.getSchema(), n = this.dataModel.getRowIndex(e.rowId), s = e.colKey === null, o = s ? i.columns.length > 0 ? 0 : -1 : i.columns.findIndex((h) => String(h.key) === String(e.colKey));
|
|
4687
4945
|
if (o < 0) return;
|
|
4688
4946
|
const l = s ? {
|
|
4689
4947
|
kind: "rows",
|
|
@@ -4700,16 +4958,16 @@ class En {
|
|
|
4700
4958
|
};
|
|
4701
4959
|
let a = [];
|
|
4702
4960
|
if (t.shiftKey && this.activeCell) {
|
|
4703
|
-
const
|
|
4961
|
+
const h = this.activeCell, d = this.dataModel.getRowIndex(h.rowId), u = i.columns.findIndex((m) => String(m.key) === String(h.colKey));
|
|
4704
4962
|
a = [s ? {
|
|
4705
4963
|
kind: "rows",
|
|
4706
|
-
startRow:
|
|
4964
|
+
startRow: d,
|
|
4707
4965
|
endRow: n,
|
|
4708
4966
|
startCol: 0,
|
|
4709
4967
|
endCol: i.columns.length - 1
|
|
4710
4968
|
} : {
|
|
4711
4969
|
kind: "cells",
|
|
4712
|
-
startRow:
|
|
4970
|
+
startRow: d,
|
|
4713
4971
|
endRow: n,
|
|
4714
4972
|
startCol: Math.max(0, u),
|
|
4715
4973
|
endCol: Math.max(0, o)
|
|
@@ -4755,14 +5013,14 @@ class En {
|
|
|
4755
5013
|
this.teardownInput(), this.activeCell = { rowId: e, colKey: i }, this.activeHost = t, this.activeHostOriginalText = t.textContent ?? "";
|
|
4756
5014
|
const s = this.dataModel.getCell(e, i), o = n?.initialValueOverride ?? (s == null ? "" : String(s)), { control: l, value: a } = this.createEditor(i, o), c = l;
|
|
4757
5015
|
c.value = a, c.style.width = "calc(100% - 4px)", c.style.boxSizing = "border-box", c.style.margin = "2px", c.style.padding = "4px 6px", c.style.border = "none", c.style.borderRadius = "0", c.style.boxShadow = "none", c.style.background = "#fff", c.style.outline = "none", c.style.fontSize = "14px", c.style.fontFamily = "inherit", c.style.lineHeight = "1.2", c.style.fontWeight = "inherit";
|
|
4758
|
-
const
|
|
4759
|
-
if (c.style.textAlign =
|
|
5016
|
+
const h = this.findColumn(i);
|
|
5017
|
+
if (c.style.textAlign = h?.style?.align ?? (h?.type === "number" ? "right" : "left"), c.addEventListener("keydown", (d) => this.handleKey(d, t)), c.addEventListener("focus", () => {
|
|
4760
5018
|
(c instanceof HTMLInputElement || c instanceof HTMLTextAreaElement) && c.select();
|
|
4761
5019
|
}), this.bindImmediateCommit(c), t.textContent = "", t.appendChild(c), c.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
|
|
4762
5020
|
c instanceof HTMLTextAreaElement && this.autosize(c);
|
|
4763
5021
|
}), c.focus({ preventScroll: !0 }), n?.placeCursorAtEnd && (c instanceof HTMLInputElement || c instanceof HTMLTextAreaElement)) {
|
|
4764
|
-
const
|
|
4765
|
-
c.setSelectionRange(
|
|
5022
|
+
const d = c.value.length;
|
|
5023
|
+
c.setSelectionRange(d, d);
|
|
4766
5024
|
}
|
|
4767
5025
|
this.inputEl = c;
|
|
4768
5026
|
}
|
|
@@ -4772,18 +5030,18 @@ class En {
|
|
|
4772
5030
|
if (!s) return;
|
|
4773
5031
|
const o = document.createElement("div");
|
|
4774
5032
|
this.activeHost = o, this.activeHostOriginalText = null, o.style.position = "absolute", o.dataset.extableFloating = "fixed", o.style.pointerEvents = "auto", o.style.padding = "0", o.style.zIndex = "10";
|
|
4775
|
-
const l = this.dataModel.getCell(e, i), a = n?.initialValueOverride ?? (l == null ? "" : String(l)), { control: c, value:
|
|
4776
|
-
|
|
5033
|
+
const l = this.dataModel.getCell(e, i), a = n?.initialValueOverride ?? (l == null ? "" : String(l)), { control: c, value: h } = this.createEditor(i, a), d = c;
|
|
5034
|
+
d.value = h, d.style.width = "calc(100% - 4px)", d.style.height = "calc(100% - 4px)", d.style.boxSizing = "border-box", d.style.margin = "2px", d.style.padding = "4px 6px", d.style.border = "none", d.style.borderRadius = "0", d.style.boxShadow = "none", d.style.background = "#fff", d.style.outline = "none", d.style.fontSize = "14px", d.style.fontFamily = "inherit", d.style.lineHeight = "1.2", d.style.fontWeight = "inherit";
|
|
4777
5035
|
const u = this.findColumn(i);
|
|
4778
|
-
if (
|
|
4779
|
-
(
|
|
4780
|
-
}), this.bindImmediateCommit(
|
|
4781
|
-
|
|
4782
|
-
}), this.root.appendChild(o), this.positionFloatingContentBox(s, o),
|
|
4783
|
-
const g =
|
|
4784
|
-
|
|
5036
|
+
if (d.style.textAlign = u?.style?.align ?? (u?.type === "number" ? "right" : "left"), d.style.pointerEvents = "auto", d.addEventListener("keydown", (g) => this.handleKey(g, o)), d.addEventListener("compositionstart", this.handleInputCompositionStart), d.addEventListener("compositionend", this.handleInputCompositionEnd), d.addEventListener("focus", () => {
|
|
5037
|
+
(d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement) && d.select();
|
|
5038
|
+
}), this.bindImmediateCommit(d), o.appendChild(d), d.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
|
|
5039
|
+
d instanceof HTMLTextAreaElement && this.autosize(d);
|
|
5040
|
+
}), this.root.appendChild(o), this.positionFloatingContentBox(s, o), d.focus({ preventScroll: !0 }), n?.placeCursorAtEnd && (d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement)) {
|
|
5041
|
+
const g = d.value.length;
|
|
5042
|
+
d.setSelectionRange(g, g);
|
|
4785
5043
|
}
|
|
4786
|
-
this.inputEl =
|
|
5044
|
+
this.inputEl = d, this.floatingInputWrapper = o;
|
|
4787
5045
|
}
|
|
4788
5046
|
handleKey(t, e) {
|
|
4789
5047
|
if (!this.activeCell || !this.inputEl) return;
|
|
@@ -4791,9 +5049,9 @@ class En {
|
|
|
4791
5049
|
if (t.isComposing || this.composing || i - this.lastCompositionEnd < 24) return;
|
|
4792
5050
|
const { rowId: n, colKey: s } = this.activeCell;
|
|
4793
5051
|
if (s === null) return;
|
|
4794
|
-
const o = this.inputEl.tagName.toLowerCase() === "textarea", l = t.key === "Enter" && t.altKey, a = (c,
|
|
4795
|
-
const
|
|
4796
|
-
this.commitEdit(n, s,
|
|
5052
|
+
const o = this.inputEl.tagName.toLowerCase() === "textarea", l = t.key === "Enter" && t.altKey, a = (c, h) => {
|
|
5053
|
+
const d = this.readActiveValue();
|
|
5054
|
+
this.commitEdit(n, s, d), this.onMove(n), this.teardownInput(!1), this.moveActiveCell(c, h);
|
|
4797
5055
|
};
|
|
4798
5056
|
if (t.key === "Tab") {
|
|
4799
5057
|
t.preventDefault(), a(0, t.shiftKey ? -1 : 1);
|
|
@@ -4807,8 +5065,8 @@ class En {
|
|
|
4807
5065
|
}
|
|
4808
5066
|
if (t.key === "Escape") {
|
|
4809
5067
|
if (t.preventDefault(), this.cancelEdit(e), this.onMove(), this.activeCell && this.activeCell.colKey !== null) {
|
|
4810
|
-
const c = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey),
|
|
4811
|
-
this.focusSelectionInput(
|
|
5068
|
+
const c = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey), h = this.cellToClipboardString(c);
|
|
5069
|
+
this.focusSelectionInput(h);
|
|
4812
5070
|
}
|
|
4813
5071
|
} else t.key === "Backspace" && this.inputEl.value === "" && (t.preventDefault(), this.commitEdit(n, s, ""), this.onMove(n), this.teardownInput(!1), this.moveActiveCell(0, 0));
|
|
4814
5072
|
}
|
|
@@ -4865,19 +5123,19 @@ class En {
|
|
|
4865
5123
|
this.teardownInput(!1), (t.dataset?.original !== void 0 || t.dataset?.value !== void 0) && (t.textContent = t.dataset.original ?? t.dataset.value ?? ""), t.blur();
|
|
4866
5124
|
}
|
|
4867
5125
|
teardownInput(t = !1) {
|
|
4868
|
-
|
|
5126
|
+
j(this.inputEl), j(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.composing = !1, t && (this.activeCell = null, this.onActiveChange(null, null));
|
|
4869
5127
|
}
|
|
4870
5128
|
}
|
|
4871
|
-
const
|
|
4872
|
-
class
|
|
5129
|
+
const qn = (r) => r;
|
|
5130
|
+
class jn {
|
|
4873
5131
|
constructor(t) {
|
|
4874
5132
|
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;
|
|
4875
5133
|
const e = t.defaultData ?? null, i = e ?? [];
|
|
4876
|
-
this.dataLoaded = e != null, this.dataModel = new
|
|
5134
|
+
this.dataLoaded = e != null, this.dataModel = new ze(
|
|
4877
5135
|
i,
|
|
4878
5136
|
t.schema,
|
|
4879
5137
|
t.defaultView
|
|
4880
|
-
), this.commandQueue = new
|
|
5138
|
+
), this.commandQueue = new $e(), this.lockManager = new Ye(this.lockMode, this.server, this.user), this.renderer = this.chooseRenderer(this.renderMode), this.applyRootDecor(t.options), this.applyReadonlyClass(), this.loadInitial();
|
|
4881
5139
|
}
|
|
4882
5140
|
isCellReadonly(t, e) {
|
|
4883
5141
|
return this.editMode === "readonly" || this.dataModel.isReadonly(t, e);
|
|
@@ -4910,7 +5168,7 @@ class Tn {
|
|
|
4910
5168
|
this.mount();
|
|
4911
5169
|
}
|
|
4912
5170
|
applyRootDecor(t) {
|
|
4913
|
-
const e =
|
|
5171
|
+
const e = ie(t?.defaultClass);
|
|
4914
5172
|
if (e?.length && this.root.classList.add(...e), t?.defaultStyle)
|
|
4915
5173
|
for (const [i, n] of Object.entries(t.defaultStyle))
|
|
4916
5174
|
this.root.style[i] = n ?? "";
|
|
@@ -4950,7 +5208,7 @@ class Tn {
|
|
|
4950
5208
|
this.root.dataset.extable = "loading", this.bindViewport(), this.ensureFilterSort(), this.emitTableState(), this.emitSelection("data");
|
|
4951
5209
|
return;
|
|
4952
5210
|
}
|
|
4953
|
-
this.selectionManager = new
|
|
5211
|
+
this.selectionManager = new On(
|
|
4954
5212
|
e,
|
|
4955
5213
|
this.editMode,
|
|
4956
5214
|
(i, n) => this.handleEdit(i, n),
|
|
@@ -4983,7 +5241,7 @@ class Tn {
|
|
|
4983
5241
|
}
|
|
4984
5242
|
// editMode/lockMode are configured only at construction time for consistency.
|
|
4985
5243
|
setRootClass(t) {
|
|
4986
|
-
this.root.className = "", this.root.classList.add(...
|
|
5244
|
+
this.root.className = "", this.root.classList.add(...ie(t) ?? []);
|
|
4987
5245
|
}
|
|
4988
5246
|
setRootStyle(t) {
|
|
4989
5247
|
for (const [e, i] of Object.entries(t))
|
|
@@ -5098,9 +5356,9 @@ class Tn {
|
|
|
5098
5356
|
if (o.textOverride) return o.textOverride;
|
|
5099
5357
|
const l = o.value;
|
|
5100
5358
|
if (s.type === "button")
|
|
5101
|
-
return
|
|
5359
|
+
return rt(l) || (l == null ? "" : String(l));
|
|
5102
5360
|
if (s.type === "link")
|
|
5103
|
-
return
|
|
5361
|
+
return lt(l) || (l == null ? "" : String(l));
|
|
5104
5362
|
if (l == null) return "";
|
|
5105
5363
|
if (l instanceof Date) return l.toISOString();
|
|
5106
5364
|
if (typeof l == "string") return l;
|
|
@@ -5109,7 +5367,7 @@ class Tn {
|
|
|
5109
5367
|
const a = l;
|
|
5110
5368
|
if (a.kind === "enum" && typeof a.value == "string") return a.value;
|
|
5111
5369
|
if (a.kind === "tags" && Array.isArray(a.values))
|
|
5112
|
-
return a.values.filter((
|
|
5370
|
+
return a.values.filter((h) => typeof h == "string").join(", ");
|
|
5113
5371
|
}
|
|
5114
5372
|
return String(l);
|
|
5115
5373
|
}
|
|
@@ -5330,8 +5588,8 @@ class Tn {
|
|
|
5330
5588
|
for (const c of Array.from(
|
|
5331
5589
|
this.contextMenu.querySelectorAll("button[data-action]")
|
|
5332
5590
|
)) {
|
|
5333
|
-
const
|
|
5334
|
-
|
|
5591
|
+
const h = c.dataset.action;
|
|
5592
|
+
h === "undo" ? c.disabled = !this.commandQueue.canUndo() : h === "redo" && (c.disabled = !this.commandQueue.canRedo());
|
|
5335
5593
|
}
|
|
5336
5594
|
const n = window.innerWidth, s = window.innerHeight, o = { width: 220, height: 160 };
|
|
5337
5595
|
let l = e, a = i;
|
|
@@ -5404,7 +5662,7 @@ class Tn {
|
|
|
5404
5662
|
}, document.addEventListener("pointerdown", this.handleGlobalPointer, !0);
|
|
5405
5663
|
}
|
|
5406
5664
|
unbindViewport() {
|
|
5407
|
-
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 &&
|
|
5665
|
+
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 && j(this.contextMenu), this.contextMenu = null), this.toast && (this.toast.hidePopover?.(), this.toast.parentElement && j(this.toast), this.toast = null);
|
|
5408
5666
|
}
|
|
5409
5667
|
remount(t) {
|
|
5410
5668
|
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);
|
|
@@ -5413,8 +5671,8 @@ class Tn {
|
|
|
5413
5671
|
getTableState() {
|
|
5414
5672
|
const t = this.renderer instanceof bt ? "html" : "canvas", e = this.commandQueue.listApplied(), i = this.editMode === "commit" ? e : [], n = i.length, s = (() => {
|
|
5415
5673
|
const c = /* @__PURE__ */ new Set();
|
|
5416
|
-
for (const
|
|
5417
|
-
|
|
5674
|
+
for (const h of i)
|
|
5675
|
+
h.kind === "edit" && (!h.rowId || h.colKey === void 0 || c.add(`${h.rowId}::${String(h.colKey)}`));
|
|
5418
5676
|
return c.size;
|
|
5419
5677
|
})(), o = this.dataModel.getValidationErrors().map((c) => ({
|
|
5420
5678
|
scope: "validation",
|
|
@@ -5425,11 +5683,11 @@ class Tn {
|
|
|
5425
5683
|
message: c.diag.message,
|
|
5426
5684
|
target: { rowId: c.rowId, colKey: c.colKey }
|
|
5427
5685
|
} : null).filter(Boolean);
|
|
5428
|
-
l.sort((c,
|
|
5429
|
-
const
|
|
5430
|
-
if (
|
|
5431
|
-
const g = c.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(c.target.colKey) : -1, m =
|
|
5432
|
-
return g !== m ? g - m : c.scope !==
|
|
5686
|
+
l.sort((c, h) => {
|
|
5687
|
+
const d = c.target?.rowId ? this.dataModel.getRowIndex(c.target.rowId) : -1, u = h.target?.rowId ? this.dataModel.getRowIndex(h.target.rowId) : -1;
|
|
5688
|
+
if (d !== u) return d - u;
|
|
5689
|
+
const g = c.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(c.target.colKey) : -1, m = h.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(h.target.colKey) : -1;
|
|
5690
|
+
return g !== m ? g - m : c.scope !== h.scope ? c.scope < h.scope ? -1 : 1 : c.message < h.message ? -1 : c.message > h.message ? 1 : 0;
|
|
5433
5691
|
});
|
|
5434
5692
|
const a = [
|
|
5435
5693
|
...o,
|
|
@@ -5467,13 +5725,13 @@ class Tn {
|
|
|
5467
5725
|
}
|
|
5468
5726
|
// Public API: selection callbacks
|
|
5469
5727
|
getSelectionSnapshot() {
|
|
5470
|
-
const t = this.selectionRanges, e = this.dataModel.getSchema(), i = this.activeCell, n = i?.rowId ?? null, s = i?.colKey ?? null, o = n ? this.dataModel.getRowIndex(n) : null, l = s !== null ? e.columns.findIndex((f) => String(f.key) === String(s)) : null, a = l !== null && l >= 0 ? e.columns[l] : null, c = n && a ? this.dataModel.resolveCellValue(n, a) : null,
|
|
5471
|
-
if (
|
|
5728
|
+
const t = this.selectionRanges, e = this.dataModel.getSchema(), i = this.activeCell, n = i?.rowId ?? null, s = i?.colKey ?? null, o = n ? this.dataModel.getRowIndex(n) : null, l = s !== null ? e.columns.findIndex((f) => String(f.key) === String(s)) : null, a = l !== null && l >= 0 ? e.columns[l] : null, c = n && a ? this.dataModel.resolveCellValue(n, a) : null, h = n && a ? this.dataModel.resolveConditionalStyle(n, a) : null, d = c?.textOverride ?? (h?.forceErrorText ? "#ERROR" : void 0), u = c ? c.value : null, g = (() => {
|
|
5729
|
+
if (d) return d;
|
|
5472
5730
|
const f = u;
|
|
5473
5731
|
if (a?.type === "button")
|
|
5474
|
-
return
|
|
5732
|
+
return rt(f) || (f == null ? "" : String(f));
|
|
5475
5733
|
if (a?.type === "link")
|
|
5476
|
-
return
|
|
5734
|
+
return lt(f) || (f == null ? "" : String(f));
|
|
5477
5735
|
if (f == null) return "";
|
|
5478
5736
|
if (f instanceof Date) return f.toISOString();
|
|
5479
5737
|
if (typeof f == "string") return f;
|
|
@@ -5482,13 +5740,13 @@ class Tn {
|
|
|
5482
5740
|
const y = f, w = y.kind;
|
|
5483
5741
|
if (w === "enum" && typeof y.value == "string") return y.value;
|
|
5484
5742
|
if (w === "tags" && Array.isArray(y.values))
|
|
5485
|
-
return y.values.filter((
|
|
5743
|
+
return y.values.filter((C) => typeof C == "string").join(", ");
|
|
5486
5744
|
}
|
|
5487
5745
|
return String(f);
|
|
5488
|
-
})(), m = a?.type ?? null, p = n && s !== null ? this.dataModel.getCellDiagnostic(n, s) : null,
|
|
5746
|
+
})(), m = a?.type ?? null, p = n && s !== null ? this.dataModel.getCellDiagnostic(n, s) : null, v = (() => {
|
|
5489
5747
|
if (!n || !a)
|
|
5490
5748
|
return { columnStyle: {}, cellStyle: {}, resolved: {} };
|
|
5491
|
-
const { columnStyle: f, cellStyle: y, resolved: w } =
|
|
5749
|
+
const { columnStyle: f, cellStyle: y, resolved: w } = Fn(
|
|
5492
5750
|
this.dataModel,
|
|
5493
5751
|
n,
|
|
5494
5752
|
a
|
|
@@ -5506,7 +5764,7 @@ class Tn {
|
|
|
5506
5764
|
activeValueType: m,
|
|
5507
5765
|
diagnostic: p,
|
|
5508
5766
|
action: this.lastAction,
|
|
5509
|
-
styles:
|
|
5767
|
+
styles: v
|
|
5510
5768
|
};
|
|
5511
5769
|
}
|
|
5512
5770
|
subscribeSelection(t) {
|
|
@@ -5558,7 +5816,7 @@ class Tn {
|
|
|
5558
5816
|
}
|
|
5559
5817
|
// Public API: value updates
|
|
5560
5818
|
setCellValue(t, e, i) {
|
|
5561
|
-
const n = typeof t == "string" ? t : this.dataModel.listRows()[t]?.id, s = n ?
|
|
5819
|
+
const n = typeof t == "string" ? t : this.dataModel.listRows()[t]?.id, s = n ? Ge(this.dataModel, { rowId: n, colKey: e }) : null;
|
|
5562
5820
|
if (!s || this.isCellReadonly(s.rowId, s.colKey)) return;
|
|
5563
5821
|
const o = this.dataModel.getCell(s.rowId, s.colKey), l = typeof i == "function" ? i(o) : i;
|
|
5564
5822
|
this.handleEdit(
|
|
@@ -5571,17 +5829,17 @@ class Tn {
|
|
|
5571
5829
|
for (const s of this.selectionRanges) {
|
|
5572
5830
|
if (s.kind !== "cells") continue;
|
|
5573
5831
|
const o = Math.min(s.startRow, s.endRow), l = Math.max(s.startRow, s.endRow), a = Math.min(s.startCol, s.endCol), c = Math.max(s.startCol, s.endCol);
|
|
5574
|
-
for (let
|
|
5575
|
-
const
|
|
5576
|
-
if (
|
|
5832
|
+
for (let h = o; h <= l; h += 1) {
|
|
5833
|
+
const d = i[h];
|
|
5834
|
+
if (d)
|
|
5577
5835
|
for (let u = a; u <= c; u += 1) {
|
|
5578
5836
|
const g = e.columns[u];
|
|
5579
5837
|
if (!g) continue;
|
|
5580
|
-
const m = `${
|
|
5581
|
-
if (n.has(m) || (n.add(m), this.isCellReadonly(
|
|
5582
|
-
const p = this.dataModel.getCell(
|
|
5838
|
+
const m = `${d.id}::${String(g.key)}`;
|
|
5839
|
+
if (n.has(m) || (n.add(m), this.isCellReadonly(d.id, g.key))) continue;
|
|
5840
|
+
const p = this.dataModel.getCell(d.id, g.key), v = typeof t == "function" ? t(p) : t;
|
|
5583
5841
|
this.handleEdit(
|
|
5584
|
-
{ kind: "edit", rowId:
|
|
5842
|
+
{ kind: "edit", rowId: d.id, colKey: g.key, next: v },
|
|
5585
5843
|
this.editMode === "direct"
|
|
5586
5844
|
);
|
|
5587
5845
|
}
|
|
@@ -5670,17 +5928,17 @@ class Tn {
|
|
|
5670
5928
|
`, t.appendChild(e), this.filterSortSidebar = e;
|
|
5671
5929
|
const i = e.querySelector('button[data-extable-fs="close"]'), n = e.querySelector('input[data-extable-fs="col-errors"]'), s = e.querySelector(
|
|
5672
5930
|
'input[data-extable-fs="col-warnings"]'
|
|
5673
|
-
), o = e.querySelector('input[data-extable-fs="search"]'), l = e.querySelector('[data-extable-fs="values"]'), a = e.querySelector('button[data-extable-fs="select-all"]'), c = e.querySelector('button[data-extable-fs="select-none"]'),
|
|
5931
|
+
), o = e.querySelector('input[data-extable-fs="search"]'), l = e.querySelector('[data-extable-fs="values"]'), a = e.querySelector('button[data-extable-fs="select-all"]'), c = e.querySelector('button[data-extable-fs="select-none"]'), h = e.querySelector(
|
|
5674
5932
|
'button[data-extable-fs="apply-filter"]'
|
|
5675
|
-
),
|
|
5933
|
+
), d = e.querySelector(
|
|
5676
5934
|
'button[data-extable-fs="clear-filter"]'
|
|
5677
5935
|
), u = e.querySelector('button[data-extable-fs="sort-asc"]'), g = e.querySelector(
|
|
5678
5936
|
'button[data-extable-fs="sort-desc"]'
|
|
5679
5937
|
), m = e.querySelector(
|
|
5680
5938
|
'button[data-extable-fs="clear-sort"]'
|
|
5681
5939
|
);
|
|
5682
|
-
if (!i || !n || !s || !o || !l || !a || !c || !
|
|
5683
|
-
|
|
5940
|
+
if (!i || !n || !s || !o || !l || !a || !c || !h || !d || !u || !g || !m) {
|
|
5941
|
+
j(e), this.filterSortSidebar = null;
|
|
5684
5942
|
return;
|
|
5685
5943
|
}
|
|
5686
5944
|
i.addEventListener("click", () => this.hideFilterSortPanel()), n.addEventListener("change", () => {
|
|
@@ -5690,17 +5948,17 @@ class Tn {
|
|
|
5690
5948
|
}), o.addEventListener("input", () => {
|
|
5691
5949
|
this.filterSortDraft && (this.filterSortDraft.search = o.value, this.renderFilterSortValues());
|
|
5692
5950
|
}), l.addEventListener("change", (p) => {
|
|
5693
|
-
const
|
|
5951
|
+
const v = p.target?.closest(
|
|
5694
5952
|
'input[type="checkbox"][data-fs-val]'
|
|
5695
5953
|
);
|
|
5696
|
-
if (!
|
|
5697
|
-
const f =
|
|
5698
|
-
f && (f === "__blanks__" ? this.filterSortDraft.includeBlanks =
|
|
5954
|
+
if (!v || !this.filterSortDraft) return;
|
|
5955
|
+
const f = v.dataset.fsVal ?? "";
|
|
5956
|
+
f && (f === "__blanks__" ? this.filterSortDraft.includeBlanks = v.checked : v.checked ? this.filterSortDraft.selected.add(f) : this.filterSortDraft.selected.delete(f));
|
|
5699
5957
|
}), a.addEventListener("click", () => {
|
|
5700
5958
|
this.filterSortDraft && (this.filterSortDraft.selected = new Set(this.filterSortDraft.values.map((p) => p.key)), this.filterSortDraft.includeBlanks = this.filterSortDraft.hasBlanks, this.renderFilterSortValues());
|
|
5701
5959
|
}), c.addEventListener("click", () => {
|
|
5702
5960
|
this.filterSortDraft && (this.filterSortDraft.selected = /* @__PURE__ */ new Set(), this.filterSortDraft.includeBlanks = !1, this.renderFilterSortValues());
|
|
5703
|
-
}),
|
|
5961
|
+
}), h.addEventListener("click", () => this.applyFilterSortDraft()), d.addEventListener("click", () => this.clearFilterSortForActiveColumn()), u.addEventListener("click", () => this.setSortForActiveColumn("asc")), g.addEventListener("click", () => this.setSortForActiveColumn("desc")), m.addEventListener("click", () => this.clearSort()), this.filterSortSidebarUnsub = this.dataModel.subscribe(() => {
|
|
5704
5962
|
this.isFilterSortPanelVisible() && this.filterSortActiveColumnKey && (this.buildFilterSortDraft(this.filterSortActiveColumnKey), this.renderFilterSortSidebar());
|
|
5705
5963
|
});
|
|
5706
5964
|
}
|
|
@@ -5726,15 +5984,15 @@ class Tn {
|
|
|
5726
5984
|
for (const u of a.values ?? []) c.add(this.stableValueKey(u));
|
|
5727
5985
|
else
|
|
5728
5986
|
for (const u of l) c.add(u.key);
|
|
5729
|
-
const
|
|
5987
|
+
const h = a ? !!a.includeBlanks : o.hasBlanks, d = e.columnDiagnostics?.[String(n.key)];
|
|
5730
5988
|
this.filterSortDraft = {
|
|
5731
5989
|
colKey: n.key,
|
|
5732
5990
|
values: l,
|
|
5733
5991
|
hasBlanks: o.hasBlanks,
|
|
5734
5992
|
selected: c,
|
|
5735
|
-
includeBlanks:
|
|
5736
|
-
diagErrors: !!
|
|
5737
|
-
diagWarnings: !!
|
|
5993
|
+
includeBlanks: h,
|
|
5994
|
+
diagErrors: !!d?.errors,
|
|
5995
|
+
diagWarnings: !!d?.warnings,
|
|
5738
5996
|
search: s
|
|
5739
5997
|
};
|
|
5740
5998
|
}
|
|
@@ -5757,8 +6015,8 @@ class Tn {
|
|
|
5757
6015
|
t.textContent = "Sort/Filter", e.checked = !1, i.checked = !1, n.value = "", s && (s.dataset.active = "0"), o && (o.dataset.active = "0"), this.renderFilterSortValues();
|
|
5758
6016
|
return;
|
|
5759
6017
|
}
|
|
5760
|
-
const
|
|
5761
|
-
t.textContent = `Sort/Filter: ${
|
|
6018
|
+
const h = this.dataModel.getSchema().columns.find((g) => String(g.key) === String(l.colKey))?.header ?? String(l.colKey);
|
|
6019
|
+
t.textContent = `Sort/Filter: ${h}`, e.checked = l.diagErrors, i.checked = l.diagWarnings, n.value = l.search;
|
|
5762
6020
|
const u = this.dataModel.getView().sorts?.find((g) => String(g.key) === String(l.colKey));
|
|
5763
6021
|
s && (s.dataset.active = u?.dir === "asc" ? "1" : "0"), o && (o.dataset.active = u?.dir === "desc" ? "1" : "0"), this.renderFilterSortValues();
|
|
5764
6022
|
}
|
|
@@ -5841,7 +6099,7 @@ class Tn {
|
|
|
5841
6099
|
this.setView(e), this.filterSortActiveColumnKey !== null && (this.buildFilterSortDraft(this.filterSortActiveColumnKey), this.renderFilterSortSidebar());
|
|
5842
6100
|
}
|
|
5843
6101
|
teardownFilterSort() {
|
|
5844
|
-
this.filterSortSidebarUnsub?.(), this.filterSortSidebarUnsub = null, this.filterSortSidebar && (
|
|
6102
|
+
this.filterSortSidebarUnsub?.(), this.filterSortSidebarUnsub = null, this.filterSortSidebar && (j(this.filterSortSidebar), this.filterSortSidebar = null), this.filterSortKeydown && (document.removeEventListener("keydown", this.filterSortKeydown, !0), this.filterSortKeydown = null), this.filterSortClickCapture && ((this.viewportEl ?? this.root).removeEventListener(
|
|
5845
6103
|
"click",
|
|
5846
6104
|
this.filterSortClickCapture,
|
|
5847
6105
|
!0
|
|
@@ -5883,8 +6141,8 @@ class Tn {
|
|
|
5883
6141
|
this.rafId = null, this.viewportState && (this.selectionManager?.onScroll(this.viewportState.scrollTop, this.viewportState.scrollLeft), !(this.renderer instanceof bt) && this.safeRender(this.viewportState));
|
|
5884
6142
|
}
|
|
5885
6143
|
}
|
|
5886
|
-
function
|
|
5887
|
-
return new
|
|
6144
|
+
function Un(r, t) {
|
|
6145
|
+
return new jn({
|
|
5888
6146
|
root: document.createElement("div"),
|
|
5889
6147
|
defaultData: r.data,
|
|
5890
6148
|
defaultView: r.view,
|
|
@@ -5892,13 +6150,13 @@ function Dn(r, t) {
|
|
|
5892
6150
|
options: t
|
|
5893
6151
|
});
|
|
5894
6152
|
}
|
|
5895
|
-
function
|
|
6153
|
+
function Xn(r, t) {
|
|
5896
6154
|
return t.remount(r), t;
|
|
5897
6155
|
}
|
|
5898
6156
|
export {
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
6157
|
+
jn as ExtableCore,
|
|
6158
|
+
Un as createTablePlaceholder,
|
|
6159
|
+
qn as defineSchema,
|
|
6160
|
+
Xn as mountTable
|
|
5903
6161
|
};
|
|
5904
6162
|
//# sourceMappingURL=index.js.map
|