@extable/core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/fillHandle.d.ts +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1928 -1124
- package/dist/index.js.map +1 -1
- package/dist/selectionManager.d.ts +4 -1
- package/dist/types.d.ts +2 -0
- package/package.json +7 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function
|
|
2
|
-
const t =
|
|
1
|
+
function se(l) {
|
|
2
|
+
const t = l.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 oe {
|
|
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 = se(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,41 +42,41 @@ class Gt {
|
|
|
42
42
|
this.applied = [], this.undone = [];
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function It() {
|
|
46
46
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `row_${Math.random().toString(16).slice(2)}`;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
if (
|
|
50
|
-
return Array.isArray(
|
|
48
|
+
function Et(l) {
|
|
49
|
+
if (l !== void 0)
|
|
50
|
+
return Array.isArray(l) ? l : [l];
|
|
51
51
|
}
|
|
52
|
-
function _(
|
|
53
|
-
if (
|
|
52
|
+
function _(l) {
|
|
53
|
+
if (l)
|
|
54
54
|
try {
|
|
55
|
-
|
|
55
|
+
l.remove();
|
|
56
56
|
} catch {
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
yyyy: (
|
|
61
|
-
MM: (
|
|
62
|
-
dd: (
|
|
63
|
-
HH: (
|
|
64
|
-
hh: (
|
|
65
|
-
const t =
|
|
66
|
-
return
|
|
59
|
+
const Q = (l, t = 2) => l.toString().padStart(t, "0"), Lt = {
|
|
60
|
+
yyyy: (l) => Q(l.getFullYear(), 4),
|
|
61
|
+
MM: (l) => Q(l.getMonth() + 1),
|
|
62
|
+
dd: (l) => Q(l.getDate()),
|
|
63
|
+
HH: (l) => Q(l.getHours()),
|
|
64
|
+
hh: (l) => {
|
|
65
|
+
const t = l.getHours() % 12 || 12;
|
|
66
|
+
return Q(t);
|
|
67
67
|
},
|
|
68
|
-
mm: (
|
|
69
|
-
ss: (
|
|
70
|
-
a: (
|
|
71
|
-
},
|
|
68
|
+
mm: (l) => Q(l.getMinutes()),
|
|
69
|
+
ss: (l) => Q(l.getSeconds()),
|
|
70
|
+
a: (l) => l.getHours() >= 12 ? "PM" : "AM"
|
|
71
|
+
}, Vt = Object.keys(Lt).sort((l, t) => t.length - l.length), _t = /* @__PURE__ */ new Set(["yyyy", "MM", "dd"]), Pt = /* @__PURE__ */ new Set(["HH", "hh", "mm", "ss", "a"]), le = /* @__PURE__ */ new Set([..._t, ...Pt]), rt = {
|
|
72
72
|
iso: "yyyy-MM-dd",
|
|
73
73
|
us: "MM/dd/yyyy",
|
|
74
74
|
eu: "dd.MM.yyyy"
|
|
75
|
-
},
|
|
75
|
+
}, at = {
|
|
76
76
|
iso: "HH:mm:ss",
|
|
77
77
|
"24h": "HH:mm",
|
|
78
78
|
"12h": "hh:mm a"
|
|
79
|
-
},
|
|
79
|
+
}, ct = {
|
|
80
80
|
iso: "yyyy-MM-dd'T'HH:mm:ss'Z'",
|
|
81
81
|
"iso-24h": "yyyy-MM-dd'T'HH:mm:ss'Z'",
|
|
82
82
|
"iso-12h": "yyyy-MM-dd hh:mm a",
|
|
@@ -87,11 +87,11 @@ const j = (c, t = 2) => c.toString().padStart(t, "0"), Et = {
|
|
|
87
87
|
"eu-24h": "dd.MM.yyyy HH:mm",
|
|
88
88
|
"eu-12h": "dd.MM.yyyy hh:mm a"
|
|
89
89
|
};
|
|
90
|
-
function
|
|
91
|
-
const t = new Date(
|
|
90
|
+
function bt(l) {
|
|
91
|
+
const t = new Date(l);
|
|
92
92
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function Bt(l, t) {
|
|
95
95
|
let e = "", i = 0, n = !1;
|
|
96
96
|
for (; i < t.length; ) {
|
|
97
97
|
const s = t[i];
|
|
@@ -104,22 +104,22 @@ function At(c, t) {
|
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
106
|
let o = !1;
|
|
107
|
-
for (const r of
|
|
107
|
+
for (const r of Vt)
|
|
108
108
|
if (t.startsWith(r, i)) {
|
|
109
|
-
e +=
|
|
109
|
+
e += Lt[r](l), i += r.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 re(l, t) {
|
|
117
|
+
return t === "date" ? _t.has(l) : t === "time" ? Pt.has(l) : le.has(l);
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function ae(l, t) {
|
|
120
120
|
let e = 0, i = !1;
|
|
121
|
-
for (; e <
|
|
122
|
-
if (
|
|
121
|
+
for (; e < l.length; ) {
|
|
122
|
+
if (l[e] === "'") {
|
|
123
123
|
i = !i, e += 1;
|
|
124
124
|
continue;
|
|
125
125
|
}
|
|
@@ -128,9 +128,9 @@ function Jt(c, t) {
|
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
130
|
let s = !1;
|
|
131
|
-
for (const o of
|
|
132
|
-
if (
|
|
133
|
-
if (!
|
|
131
|
+
for (const o of Vt)
|
|
132
|
+
if (l.startsWith(o, e)) {
|
|
133
|
+
if (!re(o, t)) return !1;
|
|
134
134
|
e += o.length, s = !0;
|
|
135
135
|
break;
|
|
136
136
|
}
|
|
@@ -138,27 +138,27 @@ function Jt(c, t) {
|
|
|
138
138
|
}
|
|
139
139
|
return !0;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
if (!
|
|
143
|
-
return t === "date" ?
|
|
144
|
-
if (t === "date" &&
|
|
145
|
-
if (t === "time" &&
|
|
146
|
-
if (t === "datetime" &&
|
|
147
|
-
const e = t === "date" ?
|
|
148
|
-
return
|
|
141
|
+
function J(l, t) {
|
|
142
|
+
if (!l)
|
|
143
|
+
return t === "date" ? rt.iso : t === "time" ? at.iso : ct.iso;
|
|
144
|
+
if (t === "date" && rt[l]) return rt[l];
|
|
145
|
+
if (t === "time" && at[l]) return at[l];
|
|
146
|
+
if (t === "datetime" && ct[l]) return ct[l];
|
|
147
|
+
const e = t === "date" ? rt.iso : t === "time" ? at.iso : ct.iso;
|
|
148
|
+
return ae(l, t) ? l : e;
|
|
149
149
|
}
|
|
150
|
-
const
|
|
151
|
-
if (typeof
|
|
152
|
-
if (
|
|
153
|
-
const t =
|
|
150
|
+
const Tt = (l) => !Number.isNaN(l.getTime()), ce = (l) => {
|
|
151
|
+
if (typeof l == "string") return l;
|
|
152
|
+
if (l && typeof l == "object") {
|
|
153
|
+
const t = l;
|
|
154
154
|
if (t.kind === "enum")
|
|
155
155
|
return typeof t.value == "string" ? t.value : null;
|
|
156
156
|
}
|
|
157
157
|
return null;
|
|
158
|
-
},
|
|
159
|
-
if (Array.isArray(
|
|
160
|
-
if (
|
|
161
|
-
const t =
|
|
158
|
+
}, de = (l) => {
|
|
159
|
+
if (Array.isArray(l) && l.every((t) => typeof t == "string")) return l;
|
|
160
|
+
if (l && typeof l == "object") {
|
|
161
|
+
const t = l;
|
|
162
162
|
if (t.kind === "tags") {
|
|
163
163
|
const e = t.values;
|
|
164
164
|
return Array.isArray(e) && e.every((i) => typeof i == "string") ? e : null;
|
|
@@ -166,32 +166,32 @@ const St = (c) => !Number.isNaN(c.getTime()), te = (c) => {
|
|
|
166
166
|
}
|
|
167
167
|
return null;
|
|
168
168
|
};
|
|
169
|
-
function
|
|
170
|
-
if (
|
|
169
|
+
function he(l, t) {
|
|
170
|
+
if (l == null) return null;
|
|
171
171
|
switch (t.type) {
|
|
172
172
|
case "string": {
|
|
173
|
-
if (typeof
|
|
174
|
-
if (t.string?.maxLength !== void 0 &&
|
|
173
|
+
if (typeof l != "string") return "Expected a string";
|
|
174
|
+
if (t.string?.maxLength !== void 0 && l.length > t.string.maxLength)
|
|
175
175
|
return `Too long (max ${t.string.maxLength})`;
|
|
176
176
|
if (t.string?.regex)
|
|
177
177
|
try {
|
|
178
|
-
if (!new RegExp(t.string.regex).test(
|
|
178
|
+
if (!new RegExp(t.string.regex).test(l)) return "Does not match pattern";
|
|
179
179
|
} catch {
|
|
180
180
|
}
|
|
181
181
|
return null;
|
|
182
182
|
}
|
|
183
183
|
case "number":
|
|
184
|
-
return typeof
|
|
184
|
+
return typeof l != "number" || !Number.isFinite(l) ? "Expected a number" : t.number?.signed === !1 && l < 0 ? "Expected a non-negative number" : null;
|
|
185
185
|
case "boolean":
|
|
186
|
-
return typeof
|
|
186
|
+
return typeof l != "boolean" ? "Expected a boolean" : null;
|
|
187
187
|
case "enum": {
|
|
188
|
-
const e =
|
|
188
|
+
const e = ce(l);
|
|
189
189
|
if (!e) return "Expected an enum value";
|
|
190
190
|
const i = t.enum?.allowCustom ?? !1, n = t.enum?.options ?? [];
|
|
191
191
|
return !i && n.length && !n.includes(e) ? "Not in allowed options" : null;
|
|
192
192
|
}
|
|
193
193
|
case "tags": {
|
|
194
|
-
const e =
|
|
194
|
+
const e = de(l);
|
|
195
195
|
if (!e) return "Expected a list of tags";
|
|
196
196
|
const i = t.tags?.allowCustom ?? !1, n = t.tags?.options ?? [];
|
|
197
197
|
if (!i && n.length) {
|
|
@@ -203,10 +203,10 @@ function ie(c, t) {
|
|
|
203
203
|
case "date":
|
|
204
204
|
case "time":
|
|
205
205
|
case "datetime": {
|
|
206
|
-
if (t.type === "date" ?
|
|
207
|
-
if (typeof
|
|
208
|
-
const e =
|
|
209
|
-
return e &&
|
|
206
|
+
if (t.type === "date" ? J(t.dateFormat, "date") : t.type === "time" ? J(t.timeFormat, "time") : J(t.dateTimeFormat, "datetime"), l instanceof Date) return Tt(l) ? null : "Invalid date";
|
|
207
|
+
if (typeof l == "string") {
|
|
208
|
+
const e = bt(l);
|
|
209
|
+
return e && Tt(e) ? null : "Invalid date/time";
|
|
210
210
|
}
|
|
211
211
|
return "Expected a date/time string";
|
|
212
212
|
}
|
|
@@ -214,7 +214,7 @@ function ie(c, t) {
|
|
|
214
214
|
return null;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
class
|
|
217
|
+
class ue {
|
|
218
218
|
constructor(t, e, i) {
|
|
219
219
|
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 ?? []);
|
|
220
220
|
}
|
|
@@ -238,7 +238,7 @@ class ne {
|
|
|
238
238
|
}
|
|
239
239
|
setData(t) {
|
|
240
240
|
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) => {
|
|
241
|
-
const n =
|
|
241
|
+
const n = It();
|
|
242
242
|
return this.rowVersion.set(n, 0), {
|
|
243
243
|
id: n,
|
|
244
244
|
raw: e,
|
|
@@ -330,16 +330,16 @@ class ne {
|
|
|
330
330
|
const s = this.findRow(t);
|
|
331
331
|
if (!s) return;
|
|
332
332
|
const o = s.row, r = () => {
|
|
333
|
-
const
|
|
334
|
-
this.rowVersion.set(t,
|
|
333
|
+
const c = this.rowVersion.get(t) ?? 0;
|
|
334
|
+
this.rowVersion.set(t, c + 1);
|
|
335
335
|
};
|
|
336
336
|
if (n)
|
|
337
337
|
o.raw[e] = i, this.pending.delete(t), r();
|
|
338
338
|
else {
|
|
339
|
-
const
|
|
340
|
-
this.isEqual(
|
|
339
|
+
const c = this.getRawCell(t, e), u = this.pending.get(t) ?? {};
|
|
340
|
+
this.isEqual(c, i) ? delete u[e] : u[e] = i, Object.keys(u).length > 0 ? this.pending.set(t, u) : this.pending.delete(t), r();
|
|
341
341
|
}
|
|
342
|
-
this.updateValidationForCell(t, e, this.getCell(t, e)), this.schema.columns.find((
|
|
342
|
+
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();
|
|
343
343
|
}
|
|
344
344
|
applyPending(t) {
|
|
345
345
|
this.dataVersion += 1;
|
|
@@ -350,7 +350,7 @@ class ne {
|
|
|
350
350
|
const n = i.row, s = /* @__PURE__ */ new Set();
|
|
351
351
|
for (const [o, r] of Object.entries(e)) {
|
|
352
352
|
n.raw[o] = r, this.updateValidationForCell(t, o, r);
|
|
353
|
-
const a = this.schema.columns.find((
|
|
353
|
+
const a = this.schema.columns.find((c) => String(c.key) === String(o));
|
|
354
354
|
a?.unique && s.add(a.key), this.clearDiagnosticsForCell(t, o);
|
|
355
355
|
}
|
|
356
356
|
this.pending.delete(t);
|
|
@@ -372,7 +372,7 @@ class ne {
|
|
|
372
372
|
}
|
|
373
373
|
insertRowAt(t, e, i) {
|
|
374
374
|
this.dataVersion += 1;
|
|
375
|
-
const n = i ??
|
|
375
|
+
const n = i ?? It(), s = Math.max(0, Math.min(e, this.rows.length));
|
|
376
376
|
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;
|
|
377
377
|
}
|
|
378
378
|
removeRow(t) {
|
|
@@ -410,30 +410,30 @@ class ne {
|
|
|
410
410
|
getFilterSortKey(t) {
|
|
411
411
|
const e = t?.excludeColumnKey, i = t?.includeSort ?? !0, n = this.view, s = (n.filters ?? []).filter((a) => {
|
|
412
412
|
if (e === void 0) return !0;
|
|
413
|
-
const
|
|
414
|
-
return String(
|
|
413
|
+
const c = a?.key;
|
|
414
|
+
return String(c) !== String(e);
|
|
415
415
|
}).map((a) => {
|
|
416
416
|
if (a?.kind === "values") {
|
|
417
|
-
const
|
|
417
|
+
const d = a;
|
|
418
418
|
return {
|
|
419
419
|
kind: "values",
|
|
420
|
-
key: String(
|
|
421
|
-
includeBlanks: !!
|
|
422
|
-
values: (
|
|
420
|
+
key: String(d.key),
|
|
421
|
+
includeBlanks: !!d.includeBlanks,
|
|
422
|
+
values: (d.values ?? []).map((f) => this.stableValueKey(f))
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
|
-
const
|
|
425
|
+
const u = a;
|
|
426
426
|
return {
|
|
427
427
|
kind: "op",
|
|
428
|
-
key: String(
|
|
429
|
-
op: String(
|
|
430
|
-
value: this.stableValueKey(
|
|
428
|
+
key: String(u.key),
|
|
429
|
+
op: String(u.op ?? ""),
|
|
430
|
+
value: this.stableValueKey(u.value)
|
|
431
431
|
};
|
|
432
|
-
}).sort((a,
|
|
432
|
+
}).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]) => ({
|
|
433
433
|
key: String(a),
|
|
434
|
-
errors: !!
|
|
435
|
-
warnings: !!
|
|
436
|
-
})).filter((a) => a.errors || a.warnings).sort((a,
|
|
434
|
+
errors: !!c?.errors,
|
|
435
|
+
warnings: !!c?.warnings
|
|
436
|
+
})).filter((a) => a.errors || a.warnings).sort((a, c) => a.key < c.key ? -1 : a.key > c.key ? 1 : 0), r = i ? (n.sorts ?? []).slice(0, 1).map((a) => ({ key: String(a.key), dir: a.dir })) : [];
|
|
437
437
|
return JSON.stringify({ filters: s, columnDiagnosticsEntries: o, sorts: r });
|
|
438
438
|
}
|
|
439
439
|
stableValueKey(t) {
|
|
@@ -477,58 +477,58 @@ class ne {
|
|
|
477
477
|
rowPassesColumnDiagnostics(t, e, i) {
|
|
478
478
|
const n = !!i.errors, s = !!i.warnings;
|
|
479
479
|
if (!n && !s) return !0;
|
|
480
|
-
const o = this.resolveFilterColumnKey(e), r = this.getColumns().find((
|
|
480
|
+
const o = this.resolveFilterColumnKey(e), r = this.getColumns().find((c) => String(c.key) === String(o));
|
|
481
481
|
r && (this.resolveCellValue(t, r), this.resolveConditionalStyle(t, r));
|
|
482
482
|
const a = this.getCellMarker(t, o);
|
|
483
483
|
return a ? a.level === "error" ? n : s : !1;
|
|
484
484
|
}
|
|
485
485
|
computeRowsAfterFilter(t) {
|
|
486
|
-
const e = t?.excludeColumnKey, i = t?.includeSort ?? !0, n = this.view, s = this.getSchema(), o = (n.filters ?? []).filter((
|
|
486
|
+
const e = t?.excludeColumnKey, i = t?.includeSort ?? !0, n = this.view, s = this.getSchema(), o = (n.filters ?? []).filter((p) => {
|
|
487
487
|
if (e === void 0) return !0;
|
|
488
|
-
const
|
|
489
|
-
return String(
|
|
488
|
+
const h = p?.key;
|
|
489
|
+
return String(h) !== String(e);
|
|
490
490
|
}), r = Object.entries(n.columnDiagnostics ?? {}).filter(
|
|
491
|
-
([
|
|
491
|
+
([p]) => e !== void 0 ? String(p) !== String(e) : !0
|
|
492
492
|
), a = [];
|
|
493
|
-
for (const
|
|
494
|
-
let
|
|
495
|
-
for (const
|
|
496
|
-
if (
|
|
497
|
-
|
|
493
|
+
for (const p of this.rows) {
|
|
494
|
+
let h = !0;
|
|
495
|
+
for (const m of o)
|
|
496
|
+
if (m?.kind === "values" && !this.valuesFilterMatches(p.id, m)) {
|
|
497
|
+
h = !1;
|
|
498
498
|
break;
|
|
499
499
|
}
|
|
500
|
-
if (
|
|
501
|
-
for (const [
|
|
502
|
-
if (!this.rowPassesColumnDiagnostics(
|
|
503
|
-
|
|
500
|
+
if (h) {
|
|
501
|
+
for (const [m, y] of r)
|
|
502
|
+
if (!this.rowPassesColumnDiagnostics(p.id, m, y)) {
|
|
503
|
+
h = !1;
|
|
504
504
|
break;
|
|
505
505
|
}
|
|
506
|
-
|
|
506
|
+
h && a.push(p);
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
if (!i) return a;
|
|
510
|
-
const
|
|
511
|
-
if (!
|
|
512
|
-
const
|
|
513
|
-
if (!
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
return { row:
|
|
517
|
-
}),
|
|
518
|
-
if (
|
|
519
|
-
if (
|
|
520
|
-
if (typeof
|
|
521
|
-
if (typeof
|
|
522
|
-
const
|
|
523
|
-
return
|
|
510
|
+
const c = (n.sorts ?? []).slice(0, 1)[0];
|
|
511
|
+
if (!c) return a;
|
|
512
|
+
const u = s.columns.find((p) => String(p.key) === String(c.key));
|
|
513
|
+
if (!u) return a;
|
|
514
|
+
const d = c.dir === "desc" ? -1 : 1, f = a.map((p) => {
|
|
515
|
+
const h = this.getFilterCellValue(p.id, u.key), m = this.isBlankValue(h), y = this.baseIndexById.get(p.id) ?? 0;
|
|
516
|
+
return { row: p, v: h, blank: m, baseIndex: y };
|
|
517
|
+
}), g = (p, h) => {
|
|
518
|
+
if (p === h) return 0;
|
|
519
|
+
if (p instanceof Date && h instanceof Date) return p.getTime() - h.getTime();
|
|
520
|
+
if (typeof p == "number" && typeof h == "number") return p - h;
|
|
521
|
+
if (typeof p == "boolean" && typeof h == "boolean") return p === h ? 0 : p ? 1 : -1;
|
|
522
|
+
const m = p instanceof Date ? p.toISOString() : typeof p == "string" ? p : String(p), y = h instanceof Date ? h.toISOString() : typeof h == "string" ? h : String(h);
|
|
523
|
+
return m === y ? 0 : m < y ? -1 : 1;
|
|
524
524
|
};
|
|
525
|
-
return f.sort((
|
|
526
|
-
if (
|
|
527
|
-
if (
|
|
528
|
-
if (
|
|
529
|
-
const
|
|
530
|
-
return
|
|
531
|
-
}), f.map((
|
|
525
|
+
return f.sort((p, h) => {
|
|
526
|
+
if (p.blank && h.blank) return p.baseIndex - h.baseIndex;
|
|
527
|
+
if (p.blank) return 1;
|
|
528
|
+
if (h.blank) return -1;
|
|
529
|
+
const m = g(p.v, h.v);
|
|
530
|
+
return m !== 0 ? m * d : p.baseIndex - h.baseIndex;
|
|
531
|
+
}), f.map((p) => p.row);
|
|
532
532
|
}
|
|
533
533
|
computeVisibleRows() {
|
|
534
534
|
const t = this.getFilterSortKey(), e = this.visibleRowsCache;
|
|
@@ -544,44 +544,44 @@ class ne {
|
|
|
544
544
|
getDistinctValuesForColumn(t) {
|
|
545
545
|
const e = `${String(t)}|${this.getFilterSortKey({ excludeColumnKey: t, includeSort: !1 })}`, i = this.distinctValueCache.get(e);
|
|
546
546
|
if (i && i.version === this.dataVersion) return i;
|
|
547
|
-
const n = this.computeRowsAfterFilter({ excludeColumnKey: t, includeSort: !1 }), s = this.getSchema().columns.find((
|
|
547
|
+
const n = this.computeRowsAfterFilter({ excludeColumnKey: t, includeSort: !1 }), s = this.getSchema().columns.find((u) => String(u.key) === String(t));
|
|
548
548
|
if (!s) {
|
|
549
|
-
const
|
|
550
|
-
return this.distinctValueCache.set(e,
|
|
549
|
+
const u = { version: this.dataVersion, values: [], hasBlanks: !1, total: 0 };
|
|
550
|
+
return this.distinctValueCache.set(e, u), u;
|
|
551
551
|
}
|
|
552
552
|
const o = /* @__PURE__ */ new Map();
|
|
553
553
|
let r = !1;
|
|
554
|
-
for (const
|
|
555
|
-
const
|
|
556
|
-
if (this.isBlankValue(
|
|
554
|
+
for (const u of n) {
|
|
555
|
+
const d = this.getFilterCellValue(u.id, s.key);
|
|
556
|
+
if (this.isBlankValue(d)) {
|
|
557
557
|
r = !0;
|
|
558
558
|
continue;
|
|
559
559
|
}
|
|
560
|
-
const f = this.stableValueKey(
|
|
560
|
+
const f = this.stableValueKey(d);
|
|
561
561
|
if (o.has(f)) continue;
|
|
562
|
-
const
|
|
563
|
-
if (
|
|
564
|
-
if (typeof
|
|
565
|
-
if (typeof
|
|
566
|
-
if (typeof
|
|
567
|
-
const
|
|
568
|
-
if (
|
|
569
|
-
if (
|
|
570
|
-
return
|
|
562
|
+
const g = (() => {
|
|
563
|
+
if (d instanceof Date) return d.toISOString();
|
|
564
|
+
if (typeof d == "string") return d;
|
|
565
|
+
if (typeof d == "number" || typeof d == "boolean") return String(d);
|
|
566
|
+
if (typeof d == "object" && d) {
|
|
567
|
+
const p = d, h = p.kind;
|
|
568
|
+
if (h === "enum" && typeof p.value == "string") return p.value;
|
|
569
|
+
if (h === "tags" && Array.isArray(p.values))
|
|
570
|
+
return p.values.filter((m) => typeof m == "string").join(", ");
|
|
571
571
|
}
|
|
572
|
-
return String(
|
|
572
|
+
return String(d);
|
|
573
573
|
})();
|
|
574
|
-
o.set(f, { value:
|
|
574
|
+
o.set(f, { value: d, label: g });
|
|
575
575
|
}
|
|
576
576
|
const a = [...o.values()].sort(
|
|
577
|
-
(
|
|
578
|
-
),
|
|
577
|
+
(u, d) => u.label < d.label ? -1 : u.label > d.label ? 1 : 0
|
|
578
|
+
), c = {
|
|
579
579
|
version: this.dataVersion,
|
|
580
580
|
values: a,
|
|
581
581
|
hasBlanks: r,
|
|
582
582
|
total: a.length + (r ? 1 : 0)
|
|
583
583
|
};
|
|
584
|
-
return this.distinctValueCache.set(e,
|
|
584
|
+
return this.distinctValueCache.set(e, c), c;
|
|
585
585
|
}
|
|
586
586
|
cellStyleKey(t, e) {
|
|
587
587
|
return `${t}::${String(e)}`;
|
|
@@ -637,24 +637,24 @@ class ne {
|
|
|
637
637
|
try {
|
|
638
638
|
const r = e.formula(o);
|
|
639
639
|
if (Array.isArray(r) && r.length >= 2 && r[1] instanceof Error) {
|
|
640
|
-
const
|
|
640
|
+
const c = {
|
|
641
641
|
level: "warning",
|
|
642
642
|
message: r[1].message,
|
|
643
643
|
source: "formula"
|
|
644
|
-
},
|
|
645
|
-
return this.computedCache.set(n, { version: i, formulaRef: e.formula, value:
|
|
644
|
+
}, u = r[0];
|
|
645
|
+
return this.computedCache.set(n, { version: i, formulaRef: e.formula, value: u, diagnostic: c }), this.formulaDiagnostics.set(n, c), { value: u, diagnostic: c };
|
|
646
646
|
}
|
|
647
647
|
const a = r;
|
|
648
648
|
return this.computedCache.set(n, { version: i, formulaRef: e.formula, value: a, diagnostic: null }), this.formulaDiagnostics.delete(n), { value: a, diagnostic: null };
|
|
649
649
|
} catch (r) {
|
|
650
|
-
const
|
|
650
|
+
const c = { level: "error", message: r instanceof Error ? r.message : String(r), source: "formula" };
|
|
651
651
|
return this.computedCache.set(n, {
|
|
652
652
|
version: i,
|
|
653
653
|
formulaRef: e.formula,
|
|
654
654
|
value: null,
|
|
655
655
|
textOverride: "#ERROR",
|
|
656
|
-
diagnostic:
|
|
657
|
-
}), this.formulaDiagnostics.set(n,
|
|
656
|
+
diagnostic: c
|
|
657
|
+
}), this.formulaDiagnostics.set(n, c), { value: null, textOverride: "#ERROR", diagnostic: c };
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
setCellConditionalStyle(t, e, i) {
|
|
@@ -696,28 +696,28 @@ class ne {
|
|
|
696
696
|
return this.rowConditionalCache.set(t, { version: i, fnRef: e, ...o }), o;
|
|
697
697
|
}
|
|
698
698
|
resolveConditionalStyle(t, e) {
|
|
699
|
-
const i = this.getRowVersion(t), n = this.cellStyleKey(t, e.key), s = this.getRowObjectEffective(t), o = this.resolveRowConditionalStyle(t), r = (f,
|
|
700
|
-
let a = null,
|
|
701
|
-
if (a = r(a, o.delta), o.diagnostic && (
|
|
702
|
-
const f = `${t}::${String(e.key)}::col`,
|
|
703
|
-
if (
|
|
704
|
-
a = r(a,
|
|
699
|
+
const i = this.getRowVersion(t), n = this.cellStyleKey(t, e.key), s = this.getRowObjectEffective(t), o = this.resolveRowConditionalStyle(t), r = (f, g) => g ? f ? { ...f, ...g } : { ...g } : f;
|
|
700
|
+
let a = null, c = null, u = !1;
|
|
701
|
+
if (a = r(a, o.delta), o.diagnostic && (c = o.diagnostic), u = u || o.forceErrorText, e.conditionalStyle && s) {
|
|
702
|
+
const f = `${t}::${String(e.key)}::col`, g = this.conditionalCache.get(f);
|
|
703
|
+
if (g && g.version === i && g.fnRef === e.conditionalStyle)
|
|
704
|
+
a = r(a, g.delta), g.diagnostic && (c === null || c.level !== "error") && (c = g.diagnostic), u = u || g.forceErrorText;
|
|
705
705
|
else {
|
|
706
|
-
const
|
|
707
|
-
this.conditionalCache.set(f, { version: i, fnRef: e.conditionalStyle, ...
|
|
706
|
+
const p = this.evalConditionalStyleFn(e.conditionalStyle, s);
|
|
707
|
+
this.conditionalCache.set(f, { version: i, fnRef: e.conditionalStyle, ...p }), a = r(a, p.delta), p.diagnostic && (c === null || c.level !== "error") && (c = p.diagnostic), u = u || p.forceErrorText;
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
710
|
+
const d = this.cellConditionalStyles.get(n);
|
|
711
|
+
if (d && s) {
|
|
712
712
|
const f = this.conditionalCache.get(n);
|
|
713
|
-
if (f && f.version === i && f.fnRef ===
|
|
714
|
-
a = r(a, f.delta), f.diagnostic && (
|
|
713
|
+
if (f && f.version === i && f.fnRef === d)
|
|
714
|
+
a = r(a, f.delta), f.diagnostic && (c === null || c.level !== "error") && (c = f.diagnostic), u = u || f.forceErrorText;
|
|
715
715
|
else {
|
|
716
|
-
const
|
|
717
|
-
this.conditionalCache.set(n, { version: i, fnRef:
|
|
716
|
+
const g = this.evalConditionalStyleFn(d, s);
|
|
717
|
+
this.conditionalCache.set(n, { version: i, fnRef: d, ...g }), a = r(a, g.delta), g.diagnostic && (c === null || c.level !== "error") && (c = g.diagnostic), u = u || g.forceErrorText;
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
|
-
return
|
|
720
|
+
return c ? this.conditionalDiagnostics.set(n, c) : this.conditionalDiagnostics.delete(n), { delta: a, diagnostic: c, forceErrorText: u };
|
|
721
721
|
}
|
|
722
722
|
getValidationErrors() {
|
|
723
723
|
const t = /* @__PURE__ */ new Map();
|
|
@@ -750,7 +750,7 @@ ${s}` : n : s;
|
|
|
750
750
|
updateValidationForCell(t, e, i) {
|
|
751
751
|
const n = this.schema.columns.find((r) => String(r.key) === String(e));
|
|
752
752
|
if (!n) return;
|
|
753
|
-
const s =
|
|
753
|
+
const s = he(i, n), o = this.cellStyleKey(t, e);
|
|
754
754
|
s ? this.baseValidationErrors.set(o, { rowId: t, colKey: e, message: s }) : this.baseValidationErrors.delete(o);
|
|
755
755
|
}
|
|
756
756
|
recomputeValidationErrors() {
|
|
@@ -831,23 +831,23 @@ Rows: ${o}`
|
|
|
831
831
|
e.displayIndex = t, t += 1;
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
|
-
function
|
|
835
|
-
const e =
|
|
834
|
+
function fe(l, t) {
|
|
835
|
+
const e = l.getSchema(), i = l.listRows(), n = (o, r) => {
|
|
836
836
|
if (!Number.isInteger(o) || !Number.isInteger(r) || o < 0 || o >= i.length || r < 0 || r >= e.columns.length) return null;
|
|
837
|
-
const a = i[o],
|
|
838
|
-
return { rowId: a.id, colKey:
|
|
837
|
+
const a = i[o], c = e.columns[r];
|
|
838
|
+
return { rowId: a.id, colKey: c.key, rowIndex: o, colIndex: r };
|
|
839
839
|
}, s = (o, r) => {
|
|
840
|
-
const a =
|
|
840
|
+
const a = l.getRowIndex(o);
|
|
841
841
|
if (a < 0) return null;
|
|
842
|
-
const
|
|
843
|
-
return
|
|
842
|
+
const c = e.columns.findIndex((u) => u.key === r);
|
|
843
|
+
return c < 0 ? null : { rowId: o, colKey: r, rowIndex: a, colIndex: c };
|
|
844
844
|
};
|
|
845
845
|
if ("rowId" in t && "colKey" in t)
|
|
846
846
|
return s(t.rowId, t.colKey);
|
|
847
847
|
if ("rowIndex" in t && "colIndex" in t)
|
|
848
848
|
return n(t.rowIndex, t.colIndex);
|
|
849
849
|
if ("rowId" in t && "colIndex" in t) {
|
|
850
|
-
const o =
|
|
850
|
+
const o = l.getRowIndex(t.rowId);
|
|
851
851
|
return o < 0 ? null : n(o, t.colIndex);
|
|
852
852
|
}
|
|
853
853
|
if ("rowIndex" in t && "colKey" in t) {
|
|
@@ -856,35 +856,35 @@ function se(c, t) {
|
|
|
856
856
|
}
|
|
857
857
|
return null;
|
|
858
858
|
}
|
|
859
|
-
function
|
|
859
|
+
function ge() {
|
|
860
860
|
return { caseInsensitive: !1, regex: !1 };
|
|
861
861
|
}
|
|
862
|
-
function
|
|
863
|
-
if (
|
|
864
|
-
if (
|
|
865
|
-
if (typeof
|
|
866
|
-
if (typeof
|
|
867
|
-
if (typeof
|
|
868
|
-
const e =
|
|
862
|
+
function mt(l, t) {
|
|
863
|
+
if (l == null) return "";
|
|
864
|
+
if (l instanceof Date) return l.toISOString();
|
|
865
|
+
if (typeof l == "string") return l;
|
|
866
|
+
if (typeof l == "number" || typeof l == "boolean") return String(l);
|
|
867
|
+
if (typeof l == "object") {
|
|
868
|
+
const e = l, i = e.kind;
|
|
869
869
|
if (i === "enum" && typeof e.value == "string") return e.value;
|
|
870
870
|
if (i === "tags" && Array.isArray(e.values))
|
|
871
871
|
return e.values.filter((n) => typeof n == "string").join(", ");
|
|
872
872
|
}
|
|
873
|
-
return t.type === "boolean" ? String(
|
|
873
|
+
return t.type === "boolean" ? String(l).toLowerCase() === "true" ? "TRUE" : "FALSE" : String(l);
|
|
874
874
|
}
|
|
875
|
-
function
|
|
876
|
-
return
|
|
875
|
+
function pe(l) {
|
|
876
|
+
return l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
877
877
|
}
|
|
878
|
-
function
|
|
879
|
-
return t <= 0 ? -1 : Math.max(0, Math.min(t - 1,
|
|
878
|
+
function At(l, t) {
|
|
879
|
+
return t <= 0 ? -1 : Math.max(0, Math.min(t - 1, l));
|
|
880
880
|
}
|
|
881
|
-
class
|
|
881
|
+
class me {
|
|
882
882
|
constructor(t, e, i, n) {
|
|
883
883
|
this.dataModel = t, this.navigateToCell = e, this.applyEdit = i, this.canEdit = n, this.state = {
|
|
884
884
|
query: "",
|
|
885
885
|
replace: "",
|
|
886
886
|
mode: "find",
|
|
887
|
-
options:
|
|
887
|
+
options: ge(),
|
|
888
888
|
matches: [],
|
|
889
889
|
activeIndex: -1,
|
|
890
890
|
error: null
|
|
@@ -924,7 +924,7 @@ class le {
|
|
|
924
924
|
this.activateIndex(t);
|
|
925
925
|
}
|
|
926
926
|
activateIndex(t) {
|
|
927
|
-
const e =
|
|
927
|
+
const e = At(t, this.state.matches.length);
|
|
928
928
|
if (e < 0) return;
|
|
929
929
|
const i = this.state.matches[e];
|
|
930
930
|
i && (this.setState({ ...this.state, activeIndex: e }), this.navigateToCell(i.rowId, i.colKey));
|
|
@@ -936,7 +936,7 @@ class le {
|
|
|
936
936
|
if (!e || !this.canEdit(e.rowId, e.colKey)) return;
|
|
937
937
|
const n = this.dataModel.getSchema().columns[e.colIndex];
|
|
938
938
|
if (!n) return;
|
|
939
|
-
const s = this.dataModel.getCell(e.rowId, e.colKey), o =
|
|
939
|
+
const s = this.dataModel.getCell(e.rowId, e.colKey), o = mt(s, n), r = this.applyReplacement(o, e);
|
|
940
940
|
this.applyEdit(e.rowId, e.colKey, r), this.recompute();
|
|
941
941
|
}
|
|
942
942
|
replaceAll() {
|
|
@@ -947,10 +947,10 @@ class le {
|
|
|
947
947
|
for (const [i, n] of e.entries()) {
|
|
948
948
|
const [s, o] = i.split("|"), r = n[0];
|
|
949
949
|
if (!r) continue;
|
|
950
|
-
const a = r.colIndex,
|
|
951
|
-
if (!
|
|
952
|
-
const
|
|
953
|
-
this.applyEdit(s,
|
|
950
|
+
const a = r.colIndex, c = t.columns[a];
|
|
951
|
+
if (!c || !s || !o) continue;
|
|
952
|
+
const u = o, d = this.dataModel.getCell(s, u), f = mt(d, c), g = this.applyReplacementAllInCell(f, n);
|
|
953
|
+
this.applyEdit(s, u, g);
|
|
954
954
|
}
|
|
955
955
|
this.recompute();
|
|
956
956
|
}
|
|
@@ -961,9 +961,9 @@ class le {
|
|
|
961
961
|
try {
|
|
962
962
|
const o = `g${s.caseInsensitive ? "i" : ""}`, r = new RegExp(i, o);
|
|
963
963
|
let a = -1;
|
|
964
|
-
return t.replace(r, (
|
|
965
|
-
const
|
|
966
|
-
return typeof
|
|
964
|
+
return t.replace(r, (c, ...u) => {
|
|
965
|
+
const d = u[u.length - 2];
|
|
966
|
+
return typeof d != "number" || d !== e.start || a === d ? c : (a = d, n);
|
|
967
967
|
});
|
|
968
968
|
} catch {
|
|
969
969
|
return t;
|
|
@@ -976,12 +976,12 @@ class le {
|
|
|
976
976
|
if (!i) return t;
|
|
977
977
|
if (s.regex)
|
|
978
978
|
try {
|
|
979
|
-
const a = `g${s.caseInsensitive ? "i" : ""}`,
|
|
980
|
-
return t.replace(
|
|
979
|
+
const a = `g${s.caseInsensitive ? "i" : ""}`, c = new RegExp(i, a);
|
|
980
|
+
return t.replace(c, n);
|
|
981
981
|
} catch {
|
|
982
982
|
return t;
|
|
983
983
|
}
|
|
984
|
-
const o = [...e].sort((a,
|
|
984
|
+
const o = [...e].sort((a, c) => c.start - a.start);
|
|
985
985
|
let r = t;
|
|
986
986
|
for (const a of o)
|
|
987
987
|
r = r.slice(0, a.start) + n + r.slice(a.end);
|
|
@@ -1002,14 +1002,14 @@ class le {
|
|
|
1002
1002
|
let r = null, a = null;
|
|
1003
1003
|
if (e.regex)
|
|
1004
1004
|
try {
|
|
1005
|
-
const
|
|
1006
|
-
a = new RegExp(t,
|
|
1007
|
-
} catch (
|
|
1008
|
-
r =
|
|
1005
|
+
const u = `g${e.caseInsensitive ? "i" : ""}`;
|
|
1006
|
+
a = new RegExp(t, u);
|
|
1007
|
+
} catch (u) {
|
|
1008
|
+
r = u instanceof Error ? u.message : "Invalid pattern";
|
|
1009
1009
|
}
|
|
1010
1010
|
else {
|
|
1011
|
-
const
|
|
1012
|
-
a = new RegExp(
|
|
1011
|
+
const u = e.caseInsensitive ? "gi" : "g";
|
|
1012
|
+
a = new RegExp(pe(t), u);
|
|
1013
1013
|
}
|
|
1014
1014
|
if (!a || r) {
|
|
1015
1015
|
this.setState({
|
|
@@ -1020,40 +1020,40 @@ class le {
|
|
|
1020
1020
|
});
|
|
1021
1021
|
return;
|
|
1022
1022
|
}
|
|
1023
|
-
for (let
|
|
1024
|
-
const
|
|
1025
|
-
if (
|
|
1023
|
+
for (let u = 0; u < s.length; u += 1) {
|
|
1024
|
+
const d = s[u];
|
|
1025
|
+
if (d)
|
|
1026
1026
|
for (let f = 0; f < i.columns.length; f += 1) {
|
|
1027
|
-
const
|
|
1028
|
-
if (!
|
|
1029
|
-
const
|
|
1030
|
-
if (!
|
|
1027
|
+
const g = i.columns[f];
|
|
1028
|
+
if (!g || n.hiddenColumns?.some((y) => String(y) === String(g.key))) continue;
|
|
1029
|
+
const p = this.dataModel.getCell(d.id, g.key), h = mt(p, g);
|
|
1030
|
+
if (!h) continue;
|
|
1031
1031
|
a.lastIndex = 0;
|
|
1032
|
-
let
|
|
1033
|
-
for (;
|
|
1034
|
-
const y =
|
|
1032
|
+
let m = a.exec(h);
|
|
1033
|
+
for (; m; ) {
|
|
1034
|
+
const y = m.index, w = y + (m[0]?.length ?? 0);
|
|
1035
1035
|
if (o.push({
|
|
1036
|
-
rowId:
|
|
1037
|
-
colKey:
|
|
1038
|
-
rowIndex:
|
|
1036
|
+
rowId: d.id,
|
|
1037
|
+
colKey: g.key,
|
|
1038
|
+
rowIndex: u,
|
|
1039
1039
|
colIndex: f,
|
|
1040
1040
|
start: y,
|
|
1041
1041
|
end: w,
|
|
1042
|
-
text:
|
|
1043
|
-
}),
|
|
1044
|
-
|
|
1042
|
+
text: h
|
|
1043
|
+
}), m[0] === "") break;
|
|
1044
|
+
m = a.exec(h);
|
|
1045
1045
|
}
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
const
|
|
1049
|
-
this.setState({ ...this.state, matches: o, activeIndex:
|
|
1048
|
+
const c = o.length ? At(this.state.activeIndex, o.length) : -1;
|
|
1049
|
+
this.setState({ ...this.state, matches: o, activeIndex: c, error: null });
|
|
1050
1050
|
}
|
|
1051
1051
|
setState(t) {
|
|
1052
1052
|
this.state = t;
|
|
1053
1053
|
for (const e of this.listeners) e(this.state);
|
|
1054
1054
|
}
|
|
1055
1055
|
}
|
|
1056
|
-
class
|
|
1056
|
+
class ye {
|
|
1057
1057
|
constructor(t, e, i) {
|
|
1058
1058
|
this.lockedRows = /* @__PURE__ */ new Set(), this.mode = "none", this.mode = t, this.server = e, this.user = i;
|
|
1059
1059
|
}
|
|
@@ -1094,66 +1094,819 @@ class ae {
|
|
|
1094
1094
|
return new Set(this.lockedRows);
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
|
-
const
|
|
1098
|
-
function
|
|
1099
|
-
const t =
|
|
1097
|
+
const yt = 864e5;
|
|
1098
|
+
function Ht(l) {
|
|
1099
|
+
const t = bt(l);
|
|
1100
1100
|
return t ? Number.isNaN(t.getTime()) ? null : t : null;
|
|
1101
1101
|
}
|
|
1102
|
-
function
|
|
1103
|
-
const t = /* @__PURE__ */ new Date(`1970-01-01T${
|
|
1102
|
+
function we(l) {
|
|
1103
|
+
const t = /* @__PURE__ */ new Date(`1970-01-01T${l}`);
|
|
1104
1104
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
1105
1105
|
}
|
|
1106
|
-
function
|
|
1106
|
+
function be(l, t, e) {
|
|
1107
1107
|
if (t == null || e.type === "string") return null;
|
|
1108
1108
|
if (e.type === "boolean") return String(!!t);
|
|
1109
1109
|
if (e.type === "number" && typeof t == "number") return String(t);
|
|
1110
1110
|
if (e.type === "datetime") {
|
|
1111
|
-
const i = t instanceof Date ? t :
|
|
1111
|
+
const i = t instanceof Date ? t : Ht(String(t));
|
|
1112
1112
|
return i ? String(i.getTime()) : null;
|
|
1113
1113
|
}
|
|
1114
1114
|
if (e.type === "date") {
|
|
1115
|
-
const i = t instanceof Date ? t :
|
|
1115
|
+
const i = t instanceof Date ? t : Ht(String(t));
|
|
1116
1116
|
if (!i) return null;
|
|
1117
|
-
const n = Math.floor(i.getTime() /
|
|
1117
|
+
const n = Math.floor(i.getTime() / yt) * yt;
|
|
1118
1118
|
return String(n);
|
|
1119
1119
|
}
|
|
1120
1120
|
if (e.type === "time") {
|
|
1121
|
-
const i = t instanceof Date ? t :
|
|
1122
|
-
return i ? String(i.getTime() %
|
|
1121
|
+
const i = t instanceof Date ? t : we(String(t));
|
|
1122
|
+
return i ? String(i.getTime() % yt) : null;
|
|
1123
1123
|
}
|
|
1124
1124
|
return null;
|
|
1125
1125
|
}
|
|
1126
|
-
const
|
|
1127
|
-
function
|
|
1126
|
+
const nt = 24, Y = 48, st = 24;
|
|
1127
|
+
function X(l, t, e = 100) {
|
|
1128
1128
|
const i = {
|
|
1129
1129
|
// Reserve extra space for browser UI affordances (e.g. date picker icon) and formatting.
|
|
1130
1130
|
date: 8
|
|
1131
1131
|
};
|
|
1132
|
-
return
|
|
1132
|
+
return l.columns.map((n) => {
|
|
1133
1133
|
const s = t.columnWidths?.[String(n.key)] ?? n.width ?? e, o = i[n.type] ?? 0;
|
|
1134
1134
|
return s + o;
|
|
1135
1135
|
});
|
|
1136
1136
|
}
|
|
1137
|
-
|
|
1137
|
+
const dt = (l) => l.trim().normalize("NFKC").toLowerCase().replace(/\s+/g, " "), Se = (l) => {
|
|
1138
|
+
const t = [];
|
|
1139
|
+
if (l)
|
|
1140
|
+
for (const e of l) {
|
|
1141
|
+
const i = e.trim();
|
|
1142
|
+
!i || t.includes(i) || t.push(i);
|
|
1143
|
+
}
|
|
1144
|
+
return t.length === 0 ? t.push("en") : t.includes("en") || t.push("en"), t;
|
|
1145
|
+
}, ve = (l, t) => {
|
|
1146
|
+
const e = l.items.indexOf(t);
|
|
1147
|
+
if (e !== -1)
|
|
1148
|
+
return e;
|
|
1149
|
+
if (!l.aliases)
|
|
1150
|
+
return null;
|
|
1151
|
+
const i = l.aliases[t];
|
|
1152
|
+
if (!i)
|
|
1153
|
+
return null;
|
|
1154
|
+
const n = l.items.indexOf(i);
|
|
1155
|
+
return n === -1 ? null : n;
|
|
1156
|
+
}, Ce = (l, t) => {
|
|
1157
|
+
const e = dt(t);
|
|
1158
|
+
if (dt(l.id).includes(e))
|
|
1159
|
+
return !0;
|
|
1160
|
+
for (const i of l.items)
|
|
1161
|
+
if (dt(i).includes(e))
|
|
1162
|
+
return !0;
|
|
1163
|
+
return l.aliases ? Object.keys(l.aliases).some(
|
|
1164
|
+
(i) => dt(i).includes(e)
|
|
1165
|
+
) : !1;
|
|
1166
|
+
}, xe = (l, t) => {
|
|
1167
|
+
if (l.langs.length === 0)
|
|
1168
|
+
return 0;
|
|
1169
|
+
let e = Number.POSITIVE_INFINITY;
|
|
1170
|
+
for (const i of l.langs) {
|
|
1171
|
+
const n = t.indexOf(i);
|
|
1172
|
+
n !== -1 && n < e && (e = n);
|
|
1173
|
+
}
|
|
1174
|
+
return e;
|
|
1175
|
+
}, Re = (l, t) => !l.langs || l.langs.length === 0 ? !0 : l.langs.some((e) => t.includes(e));
|
|
1176
|
+
class Me {
|
|
1177
|
+
constructor(t) {
|
|
1178
|
+
this.lists = [], this.matchers = [], this.langs = Se(t?.langs);
|
|
1179
|
+
}
|
|
1180
|
+
register(t) {
|
|
1181
|
+
const e = this.lists.findIndex((i) => i.id === t.id);
|
|
1182
|
+
e === -1 ? this.lists.push(t) : this.lists[e] = t;
|
|
1183
|
+
}
|
|
1184
|
+
registerMatch(t) {
|
|
1185
|
+
const e = this.matchers.findIndex((i) => i.id === t.id);
|
|
1186
|
+
e === -1 ? this.matchers.push(t) : this.matchers[e] = t;
|
|
1187
|
+
}
|
|
1188
|
+
unregister(t) {
|
|
1189
|
+
this.lists = this.lists.filter((e) => e.id !== t), this.matchers = this.matchers.filter((e) => e.id !== t);
|
|
1190
|
+
}
|
|
1191
|
+
list(t) {
|
|
1192
|
+
let e = [...this.lists];
|
|
1193
|
+
if (t?.enabledIds && t.enabledIds.length > 0) {
|
|
1194
|
+
const n = new Set(t.enabledIds);
|
|
1195
|
+
e = e.filter((s) => n.has(s.id));
|
|
1196
|
+
}
|
|
1197
|
+
const i = t?.queryText;
|
|
1198
|
+
return i && (e = e.filter((n) => Ce(n, i))), e;
|
|
1199
|
+
}
|
|
1200
|
+
match(t, e) {
|
|
1201
|
+
if (t.length === 0)
|
|
1202
|
+
return null;
|
|
1203
|
+
let i = null, n = Number.NEGATIVE_INFINITY;
|
|
1204
|
+
const s = e?.enabledIds ? new Set(e.enabledIds) : null;
|
|
1205
|
+
for (const r of this.matchers) {
|
|
1206
|
+
if (s && !s.has(r.id) || !Re(r, this.langs))
|
|
1207
|
+
continue;
|
|
1208
|
+
const a = r.match(t);
|
|
1209
|
+
if (!a)
|
|
1210
|
+
continue;
|
|
1211
|
+
const c = a.score;
|
|
1212
|
+
Number.isFinite(c) && c > n && (n = c, i = {
|
|
1213
|
+
kind: "matcher",
|
|
1214
|
+
matcher: r,
|
|
1215
|
+
step: a.step ?? 1,
|
|
1216
|
+
state: a.state
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
const o = this.list(e).map((r) => ({ list: r, rank: xe(r, this.langs) })).filter((r) => Number.isFinite(r.rank)).sort((r, a) => r.rank - a.rank);
|
|
1220
|
+
for (const { list: r, rank: a } of o) {
|
|
1221
|
+
const c = [];
|
|
1222
|
+
let u = !1;
|
|
1223
|
+
for (const g of t) {
|
|
1224
|
+
const p = ve(r, g);
|
|
1225
|
+
if (p === null) {
|
|
1226
|
+
u = !0;
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1229
|
+
c.push(p);
|
|
1230
|
+
}
|
|
1231
|
+
if (u)
|
|
1232
|
+
continue;
|
|
1233
|
+
const d = this.inferStep(r, c);
|
|
1234
|
+
if (d === null)
|
|
1235
|
+
continue;
|
|
1236
|
+
const f = 10 - a;
|
|
1237
|
+
f > n && (n = f, i = {
|
|
1238
|
+
kind: "list",
|
|
1239
|
+
list: r,
|
|
1240
|
+
startIndex: c[c.length - 1] ?? 0,
|
|
1241
|
+
step: d
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
return i;
|
|
1245
|
+
}
|
|
1246
|
+
inferStep(t, e) {
|
|
1247
|
+
if (e.length < 2)
|
|
1248
|
+
return 1;
|
|
1249
|
+
const i = t.items.length, n = this.stepBetween(t.mode, i, e[0], e[1]);
|
|
1250
|
+
if (n === null)
|
|
1251
|
+
return null;
|
|
1252
|
+
for (let s = 2; s < e.length; s += 1) {
|
|
1253
|
+
const o = this.nextIndex(t.mode, i, e[s - 1], n);
|
|
1254
|
+
if (o === null || o !== e[s])
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1257
|
+
return n;
|
|
1258
|
+
}
|
|
1259
|
+
stepBetween(t, e, i, n) {
|
|
1260
|
+
if (t === "cycle")
|
|
1261
|
+
return (n - i + e) % e;
|
|
1262
|
+
const s = n - i;
|
|
1263
|
+
return s < 0 ? null : s;
|
|
1264
|
+
}
|
|
1265
|
+
nextIndex(t, e, i, n) {
|
|
1266
|
+
if (t === "cycle")
|
|
1267
|
+
return (i + n) % e;
|
|
1268
|
+
const s = i + n;
|
|
1269
|
+
return s >= e ? null : s;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
const ke = {
|
|
1273
|
+
id: "weekdays-en",
|
|
1274
|
+
mode: "cycle",
|
|
1275
|
+
langs: ["en"],
|
|
1276
|
+
items: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
|
1277
|
+
aliases: {
|
|
1278
|
+
Mon: "Monday",
|
|
1279
|
+
Tue: "Tuesday",
|
|
1280
|
+
Tues: "Tuesday",
|
|
1281
|
+
Wed: "Wednesday",
|
|
1282
|
+
Thu: "Thursday",
|
|
1283
|
+
Thur: "Thursday",
|
|
1284
|
+
Thurs: "Thursday",
|
|
1285
|
+
Fri: "Friday",
|
|
1286
|
+
Sat: "Saturday",
|
|
1287
|
+
Sun: "Sunday"
|
|
1288
|
+
}
|
|
1289
|
+
}, Ie = {
|
|
1290
|
+
id: "weekdays-ja",
|
|
1291
|
+
mode: "cycle",
|
|
1292
|
+
langs: ["ja"],
|
|
1293
|
+
items: ["月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日"],
|
|
1294
|
+
aliases: {
|
|
1295
|
+
月曜: "月曜日",
|
|
1296
|
+
月: "月曜日",
|
|
1297
|
+
火曜: "火曜日",
|
|
1298
|
+
火: "火曜日",
|
|
1299
|
+
水曜: "水曜日",
|
|
1300
|
+
水: "水曜日",
|
|
1301
|
+
木曜: "木曜日",
|
|
1302
|
+
木: "木曜日",
|
|
1303
|
+
金曜: "金曜日",
|
|
1304
|
+
金: "金曜日",
|
|
1305
|
+
土曜: "土曜日",
|
|
1306
|
+
土: "土曜日",
|
|
1307
|
+
日曜: "日曜日",
|
|
1308
|
+
日: "日曜日"
|
|
1309
|
+
}
|
|
1310
|
+
}, Ee = {
|
|
1311
|
+
id: "months-en",
|
|
1312
|
+
mode: "cycle",
|
|
1313
|
+
langs: ["en"],
|
|
1314
|
+
items: [
|
|
1315
|
+
"January",
|
|
1316
|
+
"February",
|
|
1317
|
+
"March",
|
|
1318
|
+
"April",
|
|
1319
|
+
"May",
|
|
1320
|
+
"June",
|
|
1321
|
+
"July",
|
|
1322
|
+
"August",
|
|
1323
|
+
"September",
|
|
1324
|
+
"October",
|
|
1325
|
+
"November",
|
|
1326
|
+
"December"
|
|
1327
|
+
],
|
|
1328
|
+
aliases: {
|
|
1329
|
+
Jan: "January",
|
|
1330
|
+
Feb: "February",
|
|
1331
|
+
Mar: "March",
|
|
1332
|
+
Apr: "April",
|
|
1333
|
+
Jun: "June",
|
|
1334
|
+
Jul: "July",
|
|
1335
|
+
Aug: "August",
|
|
1336
|
+
Sep: "September",
|
|
1337
|
+
Sept: "September",
|
|
1338
|
+
Oct: "October",
|
|
1339
|
+
Nov: "November",
|
|
1340
|
+
Dec: "December"
|
|
1341
|
+
}
|
|
1342
|
+
}, Te = {
|
|
1343
|
+
id: "months-ja",
|
|
1344
|
+
mode: "cycle",
|
|
1345
|
+
langs: ["ja"],
|
|
1346
|
+
items: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
|
|
1347
|
+
}, Ae = {
|
|
1348
|
+
id: "months-ja-traditional",
|
|
1349
|
+
mode: "cycle",
|
|
1350
|
+
langs: ["ja"],
|
|
1351
|
+
items: ["睦月", "如月", "弥生", "卯月", "皐月", "水無月", "文月", "葉月", "長月", "神無月", "霜月", "師走"]
|
|
1352
|
+
}, He = {
|
|
1353
|
+
id: "quarters-en",
|
|
1354
|
+
mode: "cycle",
|
|
1355
|
+
langs: ["en"],
|
|
1356
|
+
items: ["Q1", "Q2", "Q3", "Q4"]
|
|
1357
|
+
}, De = {
|
|
1358
|
+
id: "quarters-ja",
|
|
1359
|
+
mode: "cycle",
|
|
1360
|
+
langs: ["ja"],
|
|
1361
|
+
items: ["第1四半期", "第2四半期", "第3四半期", "第4四半期"]
|
|
1362
|
+
}, Ke = {
|
|
1363
|
+
id: "zodiac-animals-ja",
|
|
1364
|
+
mode: "cycle",
|
|
1365
|
+
langs: ["ja"],
|
|
1366
|
+
items: ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
|
|
1367
|
+
}, Fe = {
|
|
1368
|
+
id: "zodiac-signs-en",
|
|
1369
|
+
mode: "cycle",
|
|
1370
|
+
langs: ["en"],
|
|
1371
|
+
items: [
|
|
1372
|
+
"Aries",
|
|
1373
|
+
"Taurus",
|
|
1374
|
+
"Gemini",
|
|
1375
|
+
"Cancer",
|
|
1376
|
+
"Leo",
|
|
1377
|
+
"Virgo",
|
|
1378
|
+
"Libra",
|
|
1379
|
+
"Scorpio",
|
|
1380
|
+
"Sagittarius",
|
|
1381
|
+
"Capricorn",
|
|
1382
|
+
"Aquarius",
|
|
1383
|
+
"Pisces"
|
|
1384
|
+
]
|
|
1385
|
+
}, Le = {
|
|
1386
|
+
id: "zodiac-signs-ja",
|
|
1387
|
+
mode: "cycle",
|
|
1388
|
+
langs: ["ja"],
|
|
1389
|
+
items: ["牡羊座", "牡牛座", "双子座", "蟹座", "獅子座", "乙女座", "天秤座", "蠍座", "射手座", "山羊座", "水瓶座", "魚座"],
|
|
1390
|
+
aliases: {
|
|
1391
|
+
さそり座: "蠍座"
|
|
1392
|
+
}
|
|
1393
|
+
}, Ve = {
|
|
1394
|
+
id: "directions-16-en",
|
|
1395
|
+
mode: "cycle",
|
|
1396
|
+
langs: ["en"],
|
|
1397
|
+
items: [
|
|
1398
|
+
"North",
|
|
1399
|
+
"North-Northeast",
|
|
1400
|
+
"Northeast",
|
|
1401
|
+
"East-Northeast",
|
|
1402
|
+
"East",
|
|
1403
|
+
"East-Southeast",
|
|
1404
|
+
"Southeast",
|
|
1405
|
+
"South-Southeast",
|
|
1406
|
+
"South",
|
|
1407
|
+
"South-Southwest",
|
|
1408
|
+
"Southwest",
|
|
1409
|
+
"West-Southwest",
|
|
1410
|
+
"West",
|
|
1411
|
+
"West-Northwest",
|
|
1412
|
+
"Northwest",
|
|
1413
|
+
"North-Northwest"
|
|
1414
|
+
]
|
|
1415
|
+
}, _e = {
|
|
1416
|
+
id: "directions-16-ja",
|
|
1417
|
+
mode: "cycle",
|
|
1418
|
+
langs: ["ja"],
|
|
1419
|
+
items: [
|
|
1420
|
+
"北",
|
|
1421
|
+
"北北東",
|
|
1422
|
+
"北東",
|
|
1423
|
+
"東北東",
|
|
1424
|
+
"東",
|
|
1425
|
+
"東南東",
|
|
1426
|
+
"南東",
|
|
1427
|
+
"南南東",
|
|
1428
|
+
"南",
|
|
1429
|
+
"南南西",
|
|
1430
|
+
"南西",
|
|
1431
|
+
"西南西",
|
|
1432
|
+
"西",
|
|
1433
|
+
"西北西",
|
|
1434
|
+
"北西",
|
|
1435
|
+
"北北西"
|
|
1436
|
+
]
|
|
1437
|
+
}, Pe = {
|
|
1438
|
+
id: "ampm-en",
|
|
1439
|
+
mode: "cycle",
|
|
1440
|
+
langs: ["en"],
|
|
1441
|
+
items: ["AM", "PM"],
|
|
1442
|
+
aliases: {
|
|
1443
|
+
"A.M.": "AM",
|
|
1444
|
+
"P.M.": "PM"
|
|
1445
|
+
}
|
|
1446
|
+
}, Be = {
|
|
1447
|
+
id: "ampm-ja",
|
|
1448
|
+
mode: "cycle",
|
|
1449
|
+
langs: ["ja"],
|
|
1450
|
+
items: ["午前", "午後"]
|
|
1451
|
+
}, Ne = {
|
|
1452
|
+
id: "seasons-en",
|
|
1453
|
+
mode: "cycle",
|
|
1454
|
+
langs: ["en"],
|
|
1455
|
+
items: ["Spring", "Summer", "Autumn", "Winter"],
|
|
1456
|
+
aliases: {
|
|
1457
|
+
Fall: "Autumn"
|
|
1458
|
+
}
|
|
1459
|
+
}, $e = {
|
|
1460
|
+
id: "seasons-ja",
|
|
1461
|
+
mode: "cycle",
|
|
1462
|
+
langs: ["ja"],
|
|
1463
|
+
items: ["春", "夏", "秋", "冬"]
|
|
1464
|
+
}, Oe = {
|
|
1465
|
+
id: "solfege-ja",
|
|
1466
|
+
mode: "cycle",
|
|
1467
|
+
langs: ["ja"],
|
|
1468
|
+
items: ["ド", "レ", "ミ", "ファ", "ソ", "ラ", "シ"]
|
|
1469
|
+
}, qe = {
|
|
1470
|
+
id: "solfege-en",
|
|
1471
|
+
mode: "cycle",
|
|
1472
|
+
langs: ["en"],
|
|
1473
|
+
items: ["Do", "Re", "Mi", "Fa", "Sol", "La", "Ti"],
|
|
1474
|
+
aliases: {
|
|
1475
|
+
So: "Sol",
|
|
1476
|
+
Si: "Ti"
|
|
1477
|
+
}
|
|
1478
|
+
}, We = {
|
|
1479
|
+
id: "greek-letters-en",
|
|
1480
|
+
mode: "cycle",
|
|
1481
|
+
langs: ["en"],
|
|
1482
|
+
items: [
|
|
1483
|
+
"Alpha",
|
|
1484
|
+
"Beta",
|
|
1485
|
+
"Gamma",
|
|
1486
|
+
"Delta",
|
|
1487
|
+
"Epsilon",
|
|
1488
|
+
"Zeta",
|
|
1489
|
+
"Eta",
|
|
1490
|
+
"Theta",
|
|
1491
|
+
"Iota",
|
|
1492
|
+
"Kappa",
|
|
1493
|
+
"Lambda",
|
|
1494
|
+
"Mu",
|
|
1495
|
+
"Nu",
|
|
1496
|
+
"Xi",
|
|
1497
|
+
"Omicron",
|
|
1498
|
+
"Pi",
|
|
1499
|
+
"Rho",
|
|
1500
|
+
"Sigma",
|
|
1501
|
+
"Tau",
|
|
1502
|
+
"Upsilon",
|
|
1503
|
+
"Phi",
|
|
1504
|
+
"Chi",
|
|
1505
|
+
"Psi",
|
|
1506
|
+
"Omega"
|
|
1507
|
+
]
|
|
1508
|
+
}, je = {
|
|
1509
|
+
id: "greek-letters-ja",
|
|
1510
|
+
mode: "cycle",
|
|
1511
|
+
langs: ["ja"],
|
|
1512
|
+
items: [
|
|
1513
|
+
"アルファ",
|
|
1514
|
+
"ベータ",
|
|
1515
|
+
"ガンマ",
|
|
1516
|
+
"デルタ",
|
|
1517
|
+
"イプシロン",
|
|
1518
|
+
"ゼータ",
|
|
1519
|
+
"イータ",
|
|
1520
|
+
"シータ",
|
|
1521
|
+
"イオタ",
|
|
1522
|
+
"カッパ",
|
|
1523
|
+
"ラムダ",
|
|
1524
|
+
"ミュー",
|
|
1525
|
+
"ニュー",
|
|
1526
|
+
"クサイ",
|
|
1527
|
+
"オミクロン",
|
|
1528
|
+
"パイ",
|
|
1529
|
+
"ロー",
|
|
1530
|
+
"シグマ",
|
|
1531
|
+
"タウ",
|
|
1532
|
+
"ウプシロン",
|
|
1533
|
+
"ファイ",
|
|
1534
|
+
"カイ",
|
|
1535
|
+
"プサイ",
|
|
1536
|
+
"オメガ"
|
|
1537
|
+
]
|
|
1538
|
+
}, Ue = {
|
|
1539
|
+
id: "greek-letters-symbols",
|
|
1540
|
+
mode: "cycle",
|
|
1541
|
+
langs: ["en", "ja"],
|
|
1542
|
+
items: [
|
|
1543
|
+
"α",
|
|
1544
|
+
"β",
|
|
1545
|
+
"γ",
|
|
1546
|
+
"δ",
|
|
1547
|
+
"ε",
|
|
1548
|
+
"ζ",
|
|
1549
|
+
"η",
|
|
1550
|
+
"θ",
|
|
1551
|
+
"ι",
|
|
1552
|
+
"κ",
|
|
1553
|
+
"λ",
|
|
1554
|
+
"μ",
|
|
1555
|
+
"ν",
|
|
1556
|
+
"ξ",
|
|
1557
|
+
"ο",
|
|
1558
|
+
"π",
|
|
1559
|
+
"ρ",
|
|
1560
|
+
"σ",
|
|
1561
|
+
"τ",
|
|
1562
|
+
"υ",
|
|
1563
|
+
"φ",
|
|
1564
|
+
"χ",
|
|
1565
|
+
"ψ",
|
|
1566
|
+
"ω"
|
|
1567
|
+
],
|
|
1568
|
+
aliases: {
|
|
1569
|
+
ς: "σ"
|
|
1570
|
+
}
|
|
1571
|
+
}, Xe = {
|
|
1572
|
+
id: "rokuyo-ja",
|
|
1573
|
+
mode: "cycle",
|
|
1574
|
+
langs: ["ja"],
|
|
1575
|
+
items: ["先勝", "友引", "先負", "仏滅", "大安", "赤口"]
|
|
1576
|
+
}, ze = {
|
|
1577
|
+
id: "heavenly-stems-ja",
|
|
1578
|
+
mode: "finite",
|
|
1579
|
+
langs: ["ja"],
|
|
1580
|
+
items: ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
|
|
1581
|
+
}, Ge = {
|
|
1582
|
+
id: "planets-en",
|
|
1583
|
+
mode: "finite",
|
|
1584
|
+
langs: ["en"],
|
|
1585
|
+
items: ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
|
|
1586
|
+
}, Qe = {
|
|
1587
|
+
id: "planets-ja",
|
|
1588
|
+
mode: "finite",
|
|
1589
|
+
langs: ["ja"],
|
|
1590
|
+
items: ["水星", "金星", "地球", "火星", "木星", "土星", "天王星", "海王星"]
|
|
1591
|
+
}, Ye = {
|
|
1592
|
+
id: "kuji-in-ja",
|
|
1593
|
+
mode: "finite",
|
|
1594
|
+
langs: ["ja"],
|
|
1595
|
+
items: ["臨", "兵", "闘", "者", "皆", "陣", "烈", "在", "前"]
|
|
1596
|
+
}, Je = {
|
|
1597
|
+
id: "eight-virtues-ja",
|
|
1598
|
+
mode: "finite",
|
|
1599
|
+
langs: ["ja"],
|
|
1600
|
+
items: ["仁", "義", "礼", "智", "忠", "信", "孝", "悌"]
|
|
1601
|
+
}, Ze = [
|
|
1602
|
+
ke,
|
|
1603
|
+
Ie,
|
|
1604
|
+
Ee,
|
|
1605
|
+
Te,
|
|
1606
|
+
Ae,
|
|
1607
|
+
He,
|
|
1608
|
+
De,
|
|
1609
|
+
Ke,
|
|
1610
|
+
Fe,
|
|
1611
|
+
Le,
|
|
1612
|
+
Ve,
|
|
1613
|
+
_e,
|
|
1614
|
+
Pe,
|
|
1615
|
+
Be,
|
|
1616
|
+
Ne,
|
|
1617
|
+
$e,
|
|
1618
|
+
Oe,
|
|
1619
|
+
qe,
|
|
1620
|
+
We,
|
|
1621
|
+
je,
|
|
1622
|
+
Ue,
|
|
1623
|
+
Xe,
|
|
1624
|
+
ze,
|
|
1625
|
+
Ge,
|
|
1626
|
+
Qe,
|
|
1627
|
+
Ye,
|
|
1628
|
+
Je
|
|
1629
|
+
], Nt = (l) => {
|
|
1630
|
+
const t = l % 100;
|
|
1631
|
+
if (t >= 11 && t <= 13) return "th";
|
|
1632
|
+
const e = l % 10;
|
|
1633
|
+
return e === 1 ? "st" : e === 2 ? "nd" : e === 3 ? "rd" : "th";
|
|
1634
|
+
}, Dt = (l) => {
|
|
1635
|
+
const t = /^(\d+)(st|nd|rd|th)$/.exec(l);
|
|
1636
|
+
if (!t) return null;
|
|
1637
|
+
const e = Number(t[1]);
|
|
1638
|
+
if (!Number.isFinite(e) || e <= 0) return null;
|
|
1639
|
+
const i = t[2];
|
|
1640
|
+
return Nt(e) !== i ? null : e;
|
|
1641
|
+
}, ti = {
|
|
1642
|
+
id: "ordinal-en",
|
|
1643
|
+
langs: ["en"],
|
|
1644
|
+
match(l) {
|
|
1645
|
+
if (l.length < 2) return null;
|
|
1646
|
+
const t = l.map((n) => Dt(n));
|
|
1647
|
+
if (t.some((n) => n === null)) return null;
|
|
1648
|
+
const e = t, i = e[1] - e[0];
|
|
1649
|
+
for (let n = 2; n < e.length; n += 1)
|
|
1650
|
+
if (e[n] - e[n - 1] !== i) return null;
|
|
1651
|
+
return { score: 80, step: i };
|
|
1652
|
+
},
|
|
1653
|
+
createIterator(l, t) {
|
|
1654
|
+
let e = Dt(l[l.length - 1] ?? "") ?? 0;
|
|
1655
|
+
return {
|
|
1656
|
+
next() {
|
|
1657
|
+
return e += t.step, e <= 0 || !Number.isFinite(e) ? { value: void 0, done: !0 } : { value: `${e}${Nt(e)}`, done: !1 };
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
}, ei = (l) => {
|
|
1662
|
+
for (const t of Ze)
|
|
1663
|
+
l.register(t);
|
|
1664
|
+
}, ii = (l) => {
|
|
1665
|
+
l.registerMatch(ti);
|
|
1666
|
+
}, $t = (l) => {
|
|
1667
|
+
const t = new Me({ langs: l });
|
|
1668
|
+
return ei(t), ii(t), t;
|
|
1669
|
+
}, ni = (l) => {
|
|
1670
|
+
let t = 0;
|
|
1138
1671
|
return {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1672
|
+
next() {
|
|
1673
|
+
if (l.length === 0)
|
|
1674
|
+
return { value: void 0, done: !0 };
|
|
1675
|
+
const e = l[t % l.length];
|
|
1676
|
+
return t += 1, { value: e, done: !1 };
|
|
1677
|
+
}
|
|
1144
1678
|
};
|
|
1679
|
+
};
|
|
1680
|
+
class U {
|
|
1681
|
+
constructor(...t) {
|
|
1682
|
+
const e = t;
|
|
1683
|
+
this.seed = e, this.kind = e.length === 1 ? "copy" : "seed-repeat", this.iterator = ni(e);
|
|
1684
|
+
}
|
|
1685
|
+
static fromSeed(t, e, i) {
|
|
1686
|
+
const n = new U(...t);
|
|
1687
|
+
return n.kind = e, n.iterator = i, n;
|
|
1688
|
+
}
|
|
1689
|
+
next() {
|
|
1690
|
+
return this.iterator.next();
|
|
1691
|
+
}
|
|
1692
|
+
[Symbol.iterator]() {
|
|
1693
|
+
return this;
|
|
1694
|
+
}
|
|
1145
1695
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1696
|
+
const Ot = 1e-9, si = 100, oi = (l) => ({
|
|
1697
|
+
next() {
|
|
1698
|
+
return { value: l, done: !1 };
|
|
1699
|
+
}
|
|
1700
|
+
}), Kt = (l) => {
|
|
1701
|
+
let t = 0;
|
|
1702
|
+
return {
|
|
1703
|
+
next() {
|
|
1704
|
+
if (l.length === 0)
|
|
1705
|
+
return { value: void 0, done: !0 };
|
|
1706
|
+
const e = l[t % l.length];
|
|
1707
|
+
return t += 1, { value: e, done: !1 };
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
}, li = (l, t) => {
|
|
1711
|
+
let e = 0;
|
|
1712
|
+
return {
|
|
1713
|
+
next() {
|
|
1714
|
+
return e += 1, { value: l + t * e, done: !1 };
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
}, ri = (l, t) => {
|
|
1718
|
+
let e = 0;
|
|
1719
|
+
return {
|
|
1720
|
+
next() {
|
|
1721
|
+
return e += 1, { value: new Date(l.getTime() + t * e), done: !1 };
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
}, ai = (l, t) => {
|
|
1725
|
+
let e = 0;
|
|
1726
|
+
return {
|
|
1727
|
+
next() {
|
|
1728
|
+
return e += 1, { value: l * t ** e, done: !1 };
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
}, ci = (l, t) => {
|
|
1732
|
+
if (l.kind === "matcher")
|
|
1733
|
+
return l.matcher.createIterator(t, { step: l.step, state: l.state });
|
|
1734
|
+
const { list: e, startIndex: i, step: n } = l, s = e.items.length;
|
|
1735
|
+
let o = i;
|
|
1736
|
+
return {
|
|
1737
|
+
next() {
|
|
1738
|
+
if (e.mode === "finite") {
|
|
1739
|
+
const r = o + n;
|
|
1740
|
+
return r >= s ? { value: void 0, done: !0 } : (o = r, { value: e.items[o], done: !1 });
|
|
1741
|
+
}
|
|
1742
|
+
return o = (o + n) % s, { value: e.items[o], done: !1 };
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
}, di = (l) => l.every((t) => typeof t == "number" && Number.isFinite(t)), hi = (l) => l.every((t) => t instanceof Date && !Number.isNaN(t.getTime())), ui = (l) => l.every((t) => typeof t == "string"), fi = (l) => {
|
|
1746
|
+
const t = /^(.*?)(-?\d+)([^0-9]*)$/.exec(l);
|
|
1747
|
+
if (!t)
|
|
1748
|
+
return null;
|
|
1749
|
+
const e = t[1] ?? "", i = t[2] ?? "", n = t[3] ?? "", s = Number(i);
|
|
1750
|
+
if (!Number.isFinite(s))
|
|
1751
|
+
return null;
|
|
1752
|
+
const o = i.replace("-", "").length;
|
|
1753
|
+
return { prefix: e, num: s, width: o, suffix: n };
|
|
1754
|
+
}, gi = (l, t, e) => {
|
|
1755
|
+
let i = 0;
|
|
1756
|
+
return {
|
|
1757
|
+
next() {
|
|
1758
|
+
i += 1;
|
|
1759
|
+
const n = t + e * i, s = n < 0 ? "-" : "", o = Math.abs(n).toString().padStart(l.width, "0");
|
|
1760
|
+
return { value: `${l.prefix}${s}${o}${l.suffix}`, done: !1 };
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
}, qt = [
|
|
1764
|
+
["C", 100],
|
|
1765
|
+
["XC", 90],
|
|
1766
|
+
["L", 50],
|
|
1767
|
+
["XL", 40],
|
|
1768
|
+
["X", 10],
|
|
1769
|
+
["IX", 9],
|
|
1770
|
+
["V", 5],
|
|
1771
|
+
["IV", 4],
|
|
1772
|
+
["I", 1]
|
|
1773
|
+
], Wt = (l) => {
|
|
1774
|
+
if (l < 1 || l > si)
|
|
1775
|
+
return null;
|
|
1776
|
+
let t = l, e = "";
|
|
1777
|
+
for (const [i, n] of qt)
|
|
1778
|
+
for (; t >= n; )
|
|
1779
|
+
e += i, t -= n;
|
|
1780
|
+
return e;
|
|
1781
|
+
}, pi = (l) => {
|
|
1782
|
+
if (l.length === 0 || l !== l.toUpperCase())
|
|
1783
|
+
return null;
|
|
1784
|
+
let t = l, e = 0;
|
|
1785
|
+
for (const [n, s] of qt)
|
|
1786
|
+
for (; t.startsWith(n); )
|
|
1787
|
+
e += s, t = t.slice(n.length);
|
|
1788
|
+
if (t.length > 0)
|
|
1789
|
+
return null;
|
|
1790
|
+
const i = Wt(e);
|
|
1791
|
+
return !i || i !== l ? null : e;
|
|
1792
|
+
}, mi = (l, t) => {
|
|
1793
|
+
let e = 0;
|
|
1794
|
+
return {
|
|
1795
|
+
next() {
|
|
1796
|
+
e += 1;
|
|
1797
|
+
const i = l + t * e, n = Wt(i);
|
|
1798
|
+
return n ? { value: n, done: !1 } : { value: void 0, done: !0 };
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
}, ut = (l) => {
|
|
1802
|
+
if (l.length < 2)
|
|
1803
|
+
return null;
|
|
1804
|
+
const t = l[1] - l[0];
|
|
1805
|
+
for (let e = 2; e < l.length; e += 1)
|
|
1806
|
+
if (Math.abs(l[e] - l[e - 1] - t) > Ot)
|
|
1807
|
+
return null;
|
|
1808
|
+
return t;
|
|
1809
|
+
}, yi = (l) => {
|
|
1810
|
+
if (l.length < 2 || l[0] === 0)
|
|
1811
|
+
return null;
|
|
1812
|
+
const t = l[1] / l[0];
|
|
1813
|
+
for (let e = 2; e < l.length; e += 1)
|
|
1814
|
+
if (l[e - 1] === 0 || Math.abs(l[e] / l[e - 1] - t) > Ot)
|
|
1815
|
+
return null;
|
|
1816
|
+
return t;
|
|
1817
|
+
}, wi = (l) => {
|
|
1818
|
+
const t = l.map((i) => fi(i));
|
|
1819
|
+
if (t.every(Boolean)) {
|
|
1820
|
+
const i = t[0], n = t[t.length - 1];
|
|
1821
|
+
if (t.every(
|
|
1822
|
+
(s) => s?.prefix === i.prefix && s?.suffix === i.suffix
|
|
1823
|
+
)) {
|
|
1824
|
+
const s = t.map((r) => r?.num ?? 0), o = ut(s);
|
|
1825
|
+
if (o !== null)
|
|
1826
|
+
return {
|
|
1827
|
+
kind: "arithmetic",
|
|
1828
|
+
iterator: gi(
|
|
1829
|
+
{ prefix: n.prefix, suffix: n.suffix, width: n.width },
|
|
1830
|
+
n.num,
|
|
1831
|
+
o
|
|
1832
|
+
)
|
|
1833
|
+
};
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
const e = l.map((i) => pi(i));
|
|
1837
|
+
if (e.every((i) => i !== null)) {
|
|
1838
|
+
const i = e, n = ut(i);
|
|
1839
|
+
if (n !== null) {
|
|
1840
|
+
const s = i[i.length - 1];
|
|
1841
|
+
return {
|
|
1842
|
+
kind: "arithmetic",
|
|
1843
|
+
iterator: mi(s, n)
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
return null;
|
|
1848
|
+
}, bi = (l, t) => {
|
|
1849
|
+
const e = t.match(l);
|
|
1850
|
+
return e ? {
|
|
1851
|
+
kind: "list",
|
|
1852
|
+
iterator: ci(e, l)
|
|
1853
|
+
} : null;
|
|
1854
|
+
};
|
|
1855
|
+
function wt(l, t) {
|
|
1856
|
+
const e = t?.registry ?? $t();
|
|
1857
|
+
if (l.length === 0)
|
|
1858
|
+
return U.fromSeed(l, "seed-repeat", Kt(l));
|
|
1859
|
+
if (l.length === 1)
|
|
1860
|
+
return U.fromSeed(l, "copy", oi(l[0]));
|
|
1861
|
+
if (ui(l)) {
|
|
1862
|
+
const i = bi(l, e);
|
|
1863
|
+
if (i)
|
|
1864
|
+
return U.fromSeed(l, i.kind, i.iterator);
|
|
1865
|
+
const n = wi(l);
|
|
1866
|
+
if (n)
|
|
1867
|
+
return U.fromSeed(l, n.kind, n.iterator);
|
|
1868
|
+
}
|
|
1869
|
+
if (di(l)) {
|
|
1870
|
+
const i = ut(l);
|
|
1871
|
+
if (i !== null)
|
|
1872
|
+
return U.fromSeed(
|
|
1873
|
+
l,
|
|
1874
|
+
"arithmetic",
|
|
1875
|
+
li(l[l.length - 1], i)
|
|
1876
|
+
);
|
|
1877
|
+
const n = yi(l);
|
|
1878
|
+
if (n !== null)
|
|
1879
|
+
return U.fromSeed(
|
|
1880
|
+
l,
|
|
1881
|
+
"geometric",
|
|
1882
|
+
ai(l[l.length - 1], n)
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1885
|
+
if (hi(l)) {
|
|
1886
|
+
const i = l.map((s) => s.getTime()), n = ut(i);
|
|
1887
|
+
if (n !== null)
|
|
1888
|
+
return U.fromSeed(
|
|
1889
|
+
l,
|
|
1890
|
+
"arithmetic",
|
|
1891
|
+
ri(l[l.length - 1], n)
|
|
1892
|
+
);
|
|
1893
|
+
}
|
|
1894
|
+
return U.fromSeed(l, "seed-repeat", Kt(l));
|
|
1151
1895
|
}
|
|
1152
|
-
function
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1896
|
+
function Si(l) {
|
|
1897
|
+
return {
|
|
1898
|
+
...l,
|
|
1899
|
+
startRow: Math.min(l.startRow, l.endRow),
|
|
1900
|
+
endRow: Math.max(l.startRow, l.endRow),
|
|
1901
|
+
startCol: Math.min(l.startCol, l.endCol),
|
|
1902
|
+
endCol: Math.max(l.startCol, l.endCol)
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
function vi(l) {
|
|
1906
|
+
if (l instanceof Date) return l;
|
|
1907
|
+
if (typeof l == "number" && Number.isFinite(l)) return new Date(l);
|
|
1908
|
+
if (typeof l == "string") {
|
|
1909
|
+
const t = l.trim();
|
|
1157
1910
|
if (/^\d{1,2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/.test(t)) {
|
|
1158
1911
|
const i = /* @__PURE__ */ new Date(`1970-01-01T${t}`);
|
|
1159
1912
|
return Number.isNaN(i.getTime()) ? null : i;
|
|
@@ -1163,150 +1916,117 @@ function Mt(c) {
|
|
|
1163
1916
|
}
|
|
1164
1917
|
return null;
|
|
1165
1918
|
}
|
|
1166
|
-
function
|
|
1167
|
-
if (
|
|
1168
|
-
if (typeof
|
|
1169
|
-
if (typeof
|
|
1170
|
-
const t = new Date(
|
|
1919
|
+
function Ci(l) {
|
|
1920
|
+
if (l instanceof Date) return l;
|
|
1921
|
+
if (typeof l == "number" && Number.isFinite(l)) return new Date(l);
|
|
1922
|
+
if (typeof l == "string") {
|
|
1923
|
+
const t = new Date(l);
|
|
1171
1924
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
1172
1925
|
}
|
|
1173
1926
|
return null;
|
|
1174
1927
|
}
|
|
1175
|
-
function
|
|
1176
|
-
return new Date(Date.UTC(c, t + 1, 0)).getUTCDate();
|
|
1177
|
-
}
|
|
1178
|
-
function Kt(c, t) {
|
|
1179
|
-
const e = c.getUTCFullYear(), i = c.getUTCMonth(), n = c.getUTCDate(), s = c.getUTCHours(), o = c.getUTCMinutes(), r = c.getUTCSeconds(), a = c.getUTCMilliseconds(), l = e * 12 + i + t, h = Math.floor(l / 12), u = (l % 12 + 12) % 12, f = ue(h, u), p = Math.min(n, f);
|
|
1180
|
-
return new Date(Date.UTC(h, u, p, s, o, r, a));
|
|
1181
|
-
}
|
|
1182
|
-
function fe(c, t) {
|
|
1183
|
-
return Kt(c, t * 12);
|
|
1184
|
-
}
|
|
1185
|
-
function Lt(c, t) {
|
|
1186
|
-
const e = c.getFullYear(), i = c.getMonth(), n = c.getDate(), s = c.getHours(), o = c.getMinutes(), r = c.getSeconds(), a = c.getMilliseconds(), l = e * 12 + i + t, h = Math.floor(l / 12), u = (l % 12 + 12) % 12, f = new Date(h, u + 1, 0).getDate(), p = Math.min(n, f);
|
|
1187
|
-
return new Date(h, u, p, s, o, r, a);
|
|
1188
|
-
}
|
|
1189
|
-
function pe(c, t) {
|
|
1190
|
-
return Lt(c, t * 12);
|
|
1191
|
-
}
|
|
1192
|
-
function Vt(c, t) {
|
|
1928
|
+
function jt(l, t) {
|
|
1193
1929
|
if (t.length !== 1) return null;
|
|
1194
|
-
const e =
|
|
1930
|
+
const e = Si(t[0]);
|
|
1195
1931
|
if (e.kind !== "cells") return null;
|
|
1196
1932
|
const i = e.endCol - e.startCol + 1, n = e.endRow - e.startRow + 1;
|
|
1197
|
-
if (i !== 1 || n
|
|
1198
|
-
const o =
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
mode: "copy"
|
|
1207
|
-
};
|
|
1208
|
-
if (n === 1)
|
|
1209
|
-
return {
|
|
1210
|
-
colKey: o.key,
|
|
1211
|
-
colIndex: e.startCol,
|
|
1212
|
-
startRowIndex: e.startRow,
|
|
1213
|
-
endRowIndex: e.endRow,
|
|
1214
|
-
mode: "copy"
|
|
1215
|
-
};
|
|
1216
|
-
if (o.type === "string") {
|
|
1217
|
-
const r = c.listRows(), a = r[e.startRow], l = r[e.endRow];
|
|
1218
|
-
if (!a || !l) return null;
|
|
1219
|
-
const h = String(c.getCell(a.id, o.key) ?? ""), u = String(c.getCell(l.id, o.key) ?? ""), f = st(h), p = st(u);
|
|
1220
|
-
return !f || !p || f.prefix !== p.prefix || f.width !== p.width ? null : {
|
|
1221
|
-
colKey: o.key,
|
|
1222
|
-
colIndex: e.startCol,
|
|
1223
|
-
startRowIndex: e.startRow,
|
|
1224
|
-
endRowIndex: e.endRow,
|
|
1225
|
-
mode: "sequence"
|
|
1226
|
-
};
|
|
1227
|
-
}
|
|
1228
|
-
return o.type === "number" || o.type === "date" || o.type === "time" || o.type === "datetime" ? {
|
|
1933
|
+
if (i !== 1 || n < 1) return null;
|
|
1934
|
+
const o = l.getSchema().columns[e.startCol];
|
|
1935
|
+
return o ? n === 1 ? {
|
|
1936
|
+
colKey: o.key,
|
|
1937
|
+
colIndex: e.startCol,
|
|
1938
|
+
startRowIndex: e.startRow,
|
|
1939
|
+
endRowIndex: e.endRow,
|
|
1940
|
+
mode: "copy"
|
|
1941
|
+
} : o.type === "boolean" ? null : o.type === "number" || o.type === "date" || o.type === "time" || o.type === "datetime" || o.type === "string" ? {
|
|
1229
1942
|
colKey: o.key,
|
|
1230
1943
|
colIndex: e.startCol,
|
|
1231
1944
|
startRowIndex: e.startRow,
|
|
1232
1945
|
endRowIndex: e.endRow,
|
|
1233
1946
|
mode: "sequence"
|
|
1234
|
-
} : null;
|
|
1947
|
+
} : null : null;
|
|
1235
1948
|
}
|
|
1236
|
-
function
|
|
1237
|
-
const
|
|
1238
|
-
if (!
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1949
|
+
function xi(l, t, e) {
|
|
1950
|
+
const i = l.getSchema(), n = l.listRows(), s = i.columns[t.colIndex];
|
|
1951
|
+
if (!s) return null;
|
|
1952
|
+
const o = [];
|
|
1953
|
+
for (let a = t.startRowIndex; a <= t.endRowIndex; a += 1) {
|
|
1954
|
+
const c = n[a];
|
|
1955
|
+
if (!c) return null;
|
|
1956
|
+
o.push(l.getCell(c.id, s.key));
|
|
1957
|
+
}
|
|
1958
|
+
if (t.mode === "copy") {
|
|
1959
|
+
const a = o[o.length - 1];
|
|
1243
1960
|
return () => a;
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
const d = l.getUTCDate() === h.getUTCDate();
|
|
1258
|
-
if (d && l.getUTCMonth() === h.getUTCMonth()) {
|
|
1259
|
-
const g = h.getUTCFullYear() - l.getUTCFullYear();
|
|
1260
|
-
if (g !== 0) {
|
|
1261
|
-
const y = new Date(Date.UTC(h.getUTCFullYear(), h.getUTCMonth(), h.getUTCDate()));
|
|
1262
|
-
return (w) => fe(y, g * w);
|
|
1263
|
-
}
|
|
1264
|
-
} else if (d) {
|
|
1265
|
-
const g = (h.getUTCFullYear() - l.getUTCFullYear()) * 12 + (h.getUTCMonth() - l.getUTCMonth());
|
|
1266
|
-
if (g !== 0) {
|
|
1267
|
-
const y = new Date(Date.UTC(h.getUTCFullYear(), h.getUTCMonth(), h.getUTCDate()));
|
|
1268
|
-
return (w) => Kt(y, g * w);
|
|
1961
|
+
}
|
|
1962
|
+
const r = $t(e);
|
|
1963
|
+
if (s.type === "number") {
|
|
1964
|
+
const a = o.map((f) => typeof f == "number" ? f : Number(f));
|
|
1965
|
+
if (!a.every((f) => Number.isFinite(f))) return null;
|
|
1966
|
+
const c = wt(a, { registry: r }), u = [];
|
|
1967
|
+
let d = !1;
|
|
1968
|
+
return (f) => {
|
|
1969
|
+
for (; !d && u.length < f; ) {
|
|
1970
|
+
const g = c.next();
|
|
1971
|
+
if (g.done) {
|
|
1972
|
+
d = !0;
|
|
1973
|
+
break;
|
|
1269
1974
|
}
|
|
1975
|
+
u.push(g.value);
|
|
1270
1976
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1977
|
+
return f <= 0 ? null : u[f - 1] ?? null;
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
if (s.type === "date" || s.type === "time" || s.type === "datetime") {
|
|
1981
|
+
const a = o.map(
|
|
1982
|
+
(f) => s.type === "time" ? vi(f) : Ci(f)
|
|
1983
|
+
);
|
|
1984
|
+
if (!a.every((f) => f instanceof Date)) return null;
|
|
1985
|
+
const c = wt(a, { registry: r }), u = [];
|
|
1986
|
+
let d = !1;
|
|
1987
|
+
return (f) => {
|
|
1988
|
+
for (; !d && u.length < f; ) {
|
|
1989
|
+
const g = c.next();
|
|
1990
|
+
if (g.done) {
|
|
1991
|
+
d = !0;
|
|
1992
|
+
break;
|
|
1993
|
+
}
|
|
1994
|
+
u.push(g.value);
|
|
1281
1995
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1996
|
+
return f <= 0 ? null : u[f - 1] ?? null;
|
|
1997
|
+
};
|
|
1284
1998
|
}
|
|
1285
|
-
if (
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1999
|
+
if (s.type === "string") {
|
|
2000
|
+
const a = o.map((f) => String(f ?? "")), c = wt(a, { registry: r }), u = [];
|
|
2001
|
+
let d = !1;
|
|
2002
|
+
return (f) => {
|
|
2003
|
+
for (; !d && u.length < f; ) {
|
|
2004
|
+
const g = c.next();
|
|
2005
|
+
if (g.done) {
|
|
2006
|
+
d = !0;
|
|
2007
|
+
break;
|
|
2008
|
+
}
|
|
2009
|
+
u.push(g.value);
|
|
2010
|
+
}
|
|
2011
|
+
return f <= 0 ? null : u[f - 1] ?? null;
|
|
1292
2012
|
};
|
|
1293
2013
|
}
|
|
1294
2014
|
return null;
|
|
1295
2015
|
}
|
|
1296
|
-
const
|
|
1297
|
-
function
|
|
1298
|
-
return new DOMRect(
|
|
2016
|
+
const Ut = 12, Xt = 14;
|
|
2017
|
+
function zt(l, t = Ut) {
|
|
2018
|
+
return new DOMRect(l.right - t - 1, l.bottom - t - 1, t, t);
|
|
1299
2019
|
}
|
|
1300
|
-
function
|
|
1301
|
-
return
|
|
2020
|
+
function Gt(l, t, e) {
|
|
2021
|
+
return l >= e.left && l <= e.right && t >= e.top && t <= e.bottom;
|
|
1302
2022
|
}
|
|
1303
|
-
function
|
|
2023
|
+
function ft(l, t, e, i, n) {
|
|
1304
2024
|
if (n === "readonly") return !1;
|
|
1305
|
-
const s =
|
|
1306
|
-
return !(!s || !e || e === "__all__" || i === null || i === "__all__" || i === null || i !== s.colKey ||
|
|
2025
|
+
const s = jt(l, t);
|
|
2026
|
+
return !(!s || !e || e === "__all__" || i === null || i === "__all__" || i === null || i !== s.colKey || l.isReadonly(e, i));
|
|
1307
2027
|
}
|
|
1308
|
-
function
|
|
1309
|
-
const t =
|
|
2028
|
+
function St(l) {
|
|
2029
|
+
const t = l.style, e = t?.decorations;
|
|
1310
2030
|
return {
|
|
1311
2031
|
backgroundColor: t?.backgroundColor,
|
|
1312
2032
|
textColor: t?.textColor,
|
|
@@ -1316,59 +2036,59 @@ function ft(c) {
|
|
|
1316
2036
|
strike: e?.strike
|
|
1317
2037
|
};
|
|
1318
2038
|
}
|
|
1319
|
-
function
|
|
2039
|
+
function Z(l, t) {
|
|
1320
2040
|
return t ? {
|
|
1321
|
-
backgroundColor: t.backgroundColor ??
|
|
1322
|
-
textColor: t.textColor ??
|
|
1323
|
-
bold: t.bold ??
|
|
1324
|
-
italic: t.italic ??
|
|
1325
|
-
underline: t.underline ??
|
|
1326
|
-
strike: t.strike ??
|
|
1327
|
-
} :
|
|
2041
|
+
backgroundColor: t.backgroundColor ?? l.backgroundColor,
|
|
2042
|
+
textColor: t.textColor ?? l.textColor,
|
|
2043
|
+
bold: t.bold ?? l.bold,
|
|
2044
|
+
italic: t.italic ?? l.italic,
|
|
2045
|
+
underline: t.underline ?? l.underline,
|
|
2046
|
+
strike: t.strike ?? l.strike
|
|
2047
|
+
} : l;
|
|
1328
2048
|
}
|
|
1329
|
-
function
|
|
1330
|
-
const i =
|
|
2049
|
+
function Ri(l, t, e) {
|
|
2050
|
+
const i = St(e), n = l.resolveConditionalStyle(t, e).delta ?? {}, s = l.getCellStyle(t, e.key) ?? {}, o = Z(Z(i, n), s);
|
|
1331
2051
|
return { columnStyle: i, cellStyle: s, resolved: o };
|
|
1332
2052
|
}
|
|
1333
|
-
function
|
|
2053
|
+
function Ft(l) {
|
|
1334
2054
|
let t = "";
|
|
1335
|
-
|
|
2055
|
+
l.backgroundColor && (t += `background-color:${l.backgroundColor};`), l.textColor && (t += `color:${l.textColor};`), l.bold && (t += "font-weight:600;"), l.italic && (t += "font-style:italic;");
|
|
1336
2056
|
const e = [];
|
|
1337
|
-
return
|
|
2057
|
+
return l.underline && e.push("underline"), l.strike && e.push("line-through"), e.length && (t += `text-decoration-line:${e.join(" ")};`), t;
|
|
1338
2058
|
}
|
|
1339
|
-
function
|
|
1340
|
-
const e =
|
|
2059
|
+
function Qt(l, t) {
|
|
2060
|
+
const e = l.sorts?.[0];
|
|
1341
2061
|
return e && e.key === t ? e.dir : null;
|
|
1342
2062
|
}
|
|
1343
|
-
function
|
|
1344
|
-
if ((
|
|
2063
|
+
function Yt(l, t) {
|
|
2064
|
+
if ((l.filters ?? []).some((n) => {
|
|
1345
2065
|
const s = n;
|
|
1346
2066
|
return s?.kind === "values" && s.key === t;
|
|
1347
2067
|
})) return !0;
|
|
1348
|
-
const i =
|
|
2068
|
+
const i = l.columnDiagnostics?.[t];
|
|
1349
2069
|
return !!(i?.errors || i?.warnings);
|
|
1350
2070
|
}
|
|
1351
|
-
function
|
|
2071
|
+
function Mi() {
|
|
1352
2072
|
return `
|
|
1353
2073
|
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false">
|
|
1354
2074
|
<path d="M3 5h18l-7 8v6l-4 2v-8L3 5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/>
|
|
1355
2075
|
</svg>
|
|
1356
2076
|
`.trim();
|
|
1357
2077
|
}
|
|
1358
|
-
function
|
|
2078
|
+
function ki(l) {
|
|
1359
2079
|
return `
|
|
1360
2080
|
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false">
|
|
1361
|
-
<path d="${
|
|
2081
|
+
<path d="${l === "asc" ? "M12 6l6 8H6l6-8z" : "M12 18l-6-8h12l-6 8z"}" fill="currentColor"/>
|
|
1362
2082
|
</svg>
|
|
1363
2083
|
`.trim();
|
|
1364
2084
|
}
|
|
1365
|
-
function
|
|
2085
|
+
function Ii(l, t, e, i, n, s) {
|
|
1366
2086
|
const o = Math.min(10, Math.floor(Math.min(i, n) / 2));
|
|
1367
2087
|
if (o <= 0) return;
|
|
1368
2088
|
const r = s === "error" ? "#ef4444" : "#f59e0b";
|
|
1369
|
-
|
|
2089
|
+
l.save(), l.fillStyle = r, l.beginPath(), l.moveTo(t + i, e), l.lineTo(t + i - o, e), l.lineTo(t + i, e + o), l.closePath(), l.fill(), l.restore();
|
|
1370
2090
|
}
|
|
1371
|
-
class
|
|
2091
|
+
class Jt {
|
|
1372
2092
|
constructor() {
|
|
1373
2093
|
this.numberFormatCache = /* @__PURE__ */ new Map(), this.dateParseCache = /* @__PURE__ */ new Map();
|
|
1374
2094
|
}
|
|
@@ -1380,22 +2100,22 @@ class qt {
|
|
|
1380
2100
|
parseIsoDate(t) {
|
|
1381
2101
|
const e = this.dateParseCache.get(t);
|
|
1382
2102
|
if (e) return e;
|
|
1383
|
-
const i =
|
|
2103
|
+
const i = bt(t);
|
|
1384
2104
|
return !i || Number.isNaN(i.getTime()) ? null : (this.dateParseCache.set(t, i), i);
|
|
1385
2105
|
}
|
|
1386
2106
|
}
|
|
1387
|
-
function
|
|
1388
|
-
|
|
2107
|
+
function Ei(l, t, e, i, n) {
|
|
2108
|
+
l.save(), l.globalAlpha = n, l.strokeStyle = "rgba(15,23,42,1)", l.lineWidth = 2, l.lineJoin = "round", l.beginPath(), l.moveTo(t, e), l.lineTo(t + i, e), l.lineTo(t + Math.round(i * 0.62), e + Math.round(i * 0.46)), l.lineTo(t + Math.round(i * 0.38), e + Math.round(i * 0.46)), l.closePath(), l.stroke(), l.beginPath(), l.moveTo(t + Math.round(i * 0.46), e + Math.round(i * 0.46)), l.lineTo(t + Math.round(i * 0.46), e + i), l.lineTo(t + Math.round(i * 0.54), e + i - 2), l.lineTo(t + Math.round(i * 0.54), e + Math.round(i * 0.46)), l.stroke(), l.restore();
|
|
1389
2109
|
}
|
|
1390
|
-
function
|
|
1391
|
-
|
|
2110
|
+
function Ti(l, t, e, i, n, s) {
|
|
2111
|
+
l.save(), l.globalAlpha = n, l.fillStyle = "rgba(15,23,42,1)", l.beginPath(), s === "asc" ? (l.moveTo(t + i / 2, e), l.lineTo(t + i, e + i), l.lineTo(t, e + i)) : (l.moveTo(t, e), l.lineTo(t + i, e), l.lineTo(t + i / 2, e + i)), l.closePath(), l.fill(), l.restore();
|
|
1392
2112
|
}
|
|
1393
|
-
class
|
|
2113
|
+
class vt {
|
|
1394
2114
|
constructor(t) {
|
|
1395
2115
|
this.n = t, this.tree = new Array(t + 1).fill(0);
|
|
1396
2116
|
}
|
|
1397
2117
|
static from(t) {
|
|
1398
|
-
const e = new
|
|
2118
|
+
const e = new vt(t.length);
|
|
1399
2119
|
for (let i = 0; i < t.length; i += 1) e.add(i, t[i] ?? 0);
|
|
1400
2120
|
return e;
|
|
1401
2121
|
}
|
|
@@ -1435,9 +2155,9 @@ class pt {
|
|
|
1435
2155
|
return Math.min(this.n - 1, i);
|
|
1436
2156
|
}
|
|
1437
2157
|
}
|
|
1438
|
-
class
|
|
2158
|
+
class ht {
|
|
1439
2159
|
constructor(t) {
|
|
1440
|
-
this.dataModel = t, this.tableEl = null, this.defaultRowHeight =
|
|
2160
|
+
this.dataModel = t, this.tableEl = null, this.defaultRowHeight = st, this.rowHeaderWidth = Y, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new Jt(), this.measureCache = /* @__PURE__ */ new Map(), this.frame = 0;
|
|
1441
2161
|
}
|
|
1442
2162
|
mount(t) {
|
|
1443
2163
|
this.tableEl = document.createElement("table"), this.tableEl.dataset.extableRenderer = "html", t.innerHTML = "", t.appendChild(this.tableEl), this.render();
|
|
@@ -1452,19 +2172,19 @@ class nt {
|
|
|
1452
2172
|
if (this.frame += 1, !this.tableEl) return;
|
|
1453
2173
|
const e = this.tableEl.parentElement, i = e?.scrollTop ?? 0, n = e?.scrollLeft ?? 0, s = this.dataModel.getSchema(), o = this.dataModel.getView(), r = this.dataModel.listRows();
|
|
1454
2174
|
this.tableEl.innerHTML = "";
|
|
1455
|
-
const a =
|
|
1456
|
-
|
|
1457
|
-
for (const
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
}
|
|
1461
|
-
this.tableEl.appendChild(f), this.tableEl.style.width = `${
|
|
1462
|
-
const
|
|
1463
|
-
for (const
|
|
1464
|
-
|
|
1465
|
-
this.tableEl.appendChild(
|
|
1466
|
-
for (const [
|
|
1467
|
-
|
|
2175
|
+
const a = X(s, o), c = s.columns.map((h) => St(h)), u = c.map((h) => Ft(h)), d = this.rowHeaderWidth + a.reduce((h, m) => h + (m ?? 0), 0), f = document.createElement("colgroup"), g = document.createElement("col");
|
|
2176
|
+
g.style.width = `${this.rowHeaderWidth}px`, f.appendChild(g);
|
|
2177
|
+
for (const h of a) {
|
|
2178
|
+
const m = document.createElement("col");
|
|
2179
|
+
h && (m.style.width = `${h}px`), f.appendChild(m);
|
|
2180
|
+
}
|
|
2181
|
+
this.tableEl.appendChild(f), this.tableEl.style.width = `${d}px`, this.tableEl.appendChild(this.renderHeader(s, a));
|
|
2182
|
+
const p = document.createElement("tbody");
|
|
2183
|
+
for (const h of r)
|
|
2184
|
+
p.appendChild(this.renderRow(h, s, a, c, u));
|
|
2185
|
+
this.tableEl.appendChild(p), this.updateActiveClasses(), this.applySelectionClasses(), e && (e.scrollTop = i, e.scrollLeft = n);
|
|
2186
|
+
for (const [h, m] of Array.from(this.measureCache.entries()))
|
|
2187
|
+
m.frame !== this.frame && this.measureCache.delete(h);
|
|
1468
2188
|
}
|
|
1469
2189
|
destroy() {
|
|
1470
2190
|
_(this.tableEl), this.tableEl = null;
|
|
@@ -1509,18 +2229,18 @@ class nt {
|
|
|
1509
2229
|
for (let r = 0; r < t.columns.length; r += 1) {
|
|
1510
2230
|
const a = t.columns[r];
|
|
1511
2231
|
if (!a) continue;
|
|
1512
|
-
const
|
|
1513
|
-
|
|
1514
|
-
const
|
|
1515
|
-
|
|
2232
|
+
const c = document.createElement("th");
|
|
2233
|
+
c.dataset.colKey = a.key;
|
|
2234
|
+
const u = Qt(o, a.key), d = Yt(o, a.key);
|
|
2235
|
+
u ? c.dataset.extableSortDir = u : c.removeAttribute("data-extable-sort-dir"), d ? c.dataset.extableFsActive = "1" : c.removeAttribute("data-extable-fs-active");
|
|
1516
2236
|
const f = document.createElement("div");
|
|
1517
2237
|
f.className = "extable-col-header";
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
-
const
|
|
1523
|
-
|
|
2238
|
+
const g = document.createElement("span");
|
|
2239
|
+
g.className = "extable-col-header-text", g.textContent = a.header ?? a.key;
|
|
2240
|
+
const p = document.createElement("button");
|
|
2241
|
+
p.type = "button", p.className = "extable-filter-sort-trigger", p.dataset.extableFsOpen = "1", p.dataset.extableColKey = a.key, p.title = "Filter / Sort", p.innerHTML = u ? ki(u) : Mi(), f.appendChild(g), f.appendChild(p), c.appendChild(f);
|
|
2242
|
+
const h = e[r] ?? a.width;
|
|
2243
|
+
h && (c.style.width = `${h}px`), c.dataset.colKey = a.key, this.activeColKey !== null && this.activeColKey === a.key && c.classList.add("extable-active-col-header"), n.appendChild(c);
|
|
1524
2244
|
}
|
|
1525
2245
|
return i.appendChild(n), i;
|
|
1526
2246
|
}
|
|
@@ -1529,59 +2249,59 @@ class nt {
|
|
|
1529
2249
|
o.dataset.rowId = t.id;
|
|
1530
2250
|
const r = this.dataModel.getView(), a = document.createElement("th");
|
|
1531
2251
|
a.scope = "row", a.classList.add("extable-row-header");
|
|
1532
|
-
const
|
|
1533
|
-
a.textContent = String(
|
|
1534
|
-
for (let
|
|
1535
|
-
const f = e.columns[
|
|
2252
|
+
const c = this.dataModel.getDisplayIndex(t.id) ?? "";
|
|
2253
|
+
a.textContent = String(c), a.style.width = `${this.rowHeaderWidth}px`, this.activeRowId === t.id && a.classList.add("extable-active-row-header"), o.appendChild(a);
|
|
2254
|
+
for (let d = 0; d < e.columns.length; d += 1) {
|
|
2255
|
+
const f = e.columns[d];
|
|
1536
2256
|
if (!f) continue;
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1539
|
-
const
|
|
1540
|
-
if (!
|
|
1541
|
-
const M = s[
|
|
1542
|
-
M && (
|
|
2257
|
+
const g = document.createElement("td");
|
|
2258
|
+
g.classList.add("extable-cell"), g.dataset.colKey = f.key, f.type === "boolean" && g.classList.add("extable-boolean");
|
|
2259
|
+
const p = this.dataModel.hasPending(t.id, f.key), h = this.dataModel.resolveConditionalStyle(t.id, f), m = this.dataModel.getCellStyle(t.id, f.key);
|
|
2260
|
+
if (!m && !h.delta && !p) {
|
|
2261
|
+
const M = s[d] ?? "";
|
|
2262
|
+
M && (g.style.cssText = M);
|
|
1543
2263
|
} else {
|
|
1544
|
-
const M = n[
|
|
1545
|
-
|
|
2264
|
+
const M = n[d] ?? {}, P = h.delta ? Z(M, h.delta) : M, H = m ? Z(P, m) : P, D = p ? { ...H, textColor: void 0 } : H, F = Ft(D);
|
|
2265
|
+
F && (g.style.cssText = F);
|
|
1546
2266
|
}
|
|
1547
|
-
const y = i[
|
|
1548
|
-
y && (
|
|
2267
|
+
const y = i[d] ?? r.columnWidths?.[f.key] ?? f.width;
|
|
2268
|
+
y && (g.style.width = `${y}px`);
|
|
1549
2269
|
const w = r.wrapText?.[f.key] ?? f.wrapText;
|
|
1550
|
-
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1557
|
-
const
|
|
1558
|
-
if (
|
|
1559
|
-
|
|
2270
|
+
g.classList.add(w ? "cell-wrap" : "cell-nowrap");
|
|
2271
|
+
const C = this.dataModel.getRawCell(t.id, f.key), v = this.dataModel.resolveCellValue(t.id, f), b = v.textOverride ?? (h.forceErrorText ? "#ERROR" : void 0), S = b ? { text: b } : this.formatValue(v.value, f);
|
|
2272
|
+
g.textContent = S.text, S.color && (g.style.color = S.color);
|
|
2273
|
+
const x = this.dataModel.getCellMarker(t.id, f.key);
|
|
2274
|
+
x ? (g.classList.toggle("extable-diag-warning", x.level === "warning"), g.classList.toggle("extable-diag-error", x.level === "error"), g.dataset.extableDiagMessage = x.message) : (g.classList.remove("extable-diag-warning", "extable-diag-error"), g.removeAttribute("data-extable-diag-message"));
|
|
2275
|
+
const R = f.style?.align ?? (f.type === "number" ? "right" : "left");
|
|
2276
|
+
g.classList.add(R === "right" ? "align-right" : "align-left");
|
|
2277
|
+
const E = be(C, v.value, f);
|
|
2278
|
+
if (E !== null)
|
|
2279
|
+
g.dataset.raw = E;
|
|
1560
2280
|
else {
|
|
1561
|
-
const M =
|
|
1562
|
-
|
|
2281
|
+
const M = C == null ? "" : String(C);
|
|
2282
|
+
g.dataset.raw = M;
|
|
1563
2283
|
}
|
|
1564
|
-
|
|
2284
|
+
p && g.classList.add("pending"), this.dataModel.isReadonly(t.id, f.key) ? g.classList.add("extable-readonly", "extable-readonly-muted") : g.classList.add("extable-editable"), this.activeRowId === t.id && this.activeColKey !== null && this.activeColKey === f.key && g.classList.add("extable-active-cell"), o.appendChild(g);
|
|
1565
2285
|
}
|
|
1566
|
-
if (e.columns.some((
|
|
1567
|
-
let
|
|
2286
|
+
if (e.columns.some((d) => r.wrapText?.[d.key] ?? d.wrapText)) {
|
|
2287
|
+
let d = this.defaultRowHeight;
|
|
1568
2288
|
for (let f = 0; f < e.columns.length; f += 1) {
|
|
1569
|
-
const
|
|
1570
|
-
if (!
|
|
1571
|
-
const
|
|
1572
|
-
if (
|
|
1573
|
-
|
|
2289
|
+
const g = e.columns[f];
|
|
2290
|
+
if (!g || !g.wrapText) continue;
|
|
2291
|
+
const p = i[f] ?? r.columnWidths?.[g.key] ?? g.width ?? 100, h = this.dataModel.resolveCellValue(t.id, g), m = this.dataModel.resolveConditionalStyle(t.id, g), w = h.textOverride ?? (m.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : h.value === null || h.value === void 0 ? "" : String(h.value), C = this.dataModel.getRowVersion(t.id), v = `${t.id}|${g.key}|${C}|${p}|${w}`, b = this.measureCache.get(v);
|
|
2292
|
+
if (b) {
|
|
2293
|
+
b.frame = this.frame, this.measureCache.set(v, b), d = Math.max(d, b.height);
|
|
1574
2294
|
continue;
|
|
1575
2295
|
}
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1578
|
-
const
|
|
1579
|
-
if (!
|
|
1580
|
-
|
|
1581
|
-
const
|
|
1582
|
-
|
|
2296
|
+
const S = document.createElement("span");
|
|
2297
|
+
S.style.visibility = "hidden", S.style.position = "absolute", S.style.left = "-10000px", S.style.top = "0", S.style.whiteSpace = "pre-wrap", S.style.overflowWrap = "anywhere", S.style.display = "inline-block", S.style.width = `${p}px`, S.textContent = w;
|
|
2298
|
+
const x = this.tableEl?.parentElement;
|
|
2299
|
+
if (!x) continue;
|
|
2300
|
+
x.appendChild(S);
|
|
2301
|
+
const R = S.clientHeight + 10;
|
|
2302
|
+
S.remove(), this.measureCache.set(v, { height: R, frame: this.frame }), d = Math.max(d, R);
|
|
1583
2303
|
}
|
|
1584
|
-
o.style.height = `${
|
|
2304
|
+
o.style.height = `${d}px`, this.dataModel.setRowHeight(t.id, d);
|
|
1585
2305
|
} else
|
|
1586
2306
|
o.style.height = `${this.defaultRowHeight}px`, this.dataModel.setRowHeight(t.id, this.defaultRowHeight);
|
|
1587
2307
|
return o;
|
|
@@ -1626,14 +2346,14 @@ class nt {
|
|
|
1626
2346
|
for (const i of this.selection) {
|
|
1627
2347
|
const n = Math.max(0, Math.min(i.startRow, i.endRow)), s = Math.min(t.length - 1, Math.max(i.startRow, i.endRow)), o = Math.max(0, Math.min(i.startCol, i.endCol)), r = Math.min(e.columns.length - 1, Math.max(i.startCol, i.endCol));
|
|
1628
2348
|
for (let a = n; a <= s; a += 1) {
|
|
1629
|
-
const
|
|
1630
|
-
if (!
|
|
1631
|
-
const
|
|
1632
|
-
|
|
1633
|
-
const
|
|
2349
|
+
const c = t[a];
|
|
2350
|
+
if (!c) continue;
|
|
2351
|
+
const u = c.querySelector("th.extable-row-header");
|
|
2352
|
+
u && u.classList.add("extable-selected");
|
|
2353
|
+
const d = Array.from(c.querySelectorAll("td"));
|
|
1634
2354
|
for (let f = o; f <= r; f += 1) {
|
|
1635
|
-
const
|
|
1636
|
-
|
|
2355
|
+
const g = d[f];
|
|
2356
|
+
g && g.classList.add("extable-selected");
|
|
1637
2357
|
}
|
|
1638
2358
|
}
|
|
1639
2359
|
}
|
|
@@ -1649,35 +2369,35 @@ class nt {
|
|
|
1649
2369
|
return { text: s, color: o };
|
|
1650
2370
|
}
|
|
1651
2371
|
if ((e.type === "date" || e.type === "time" || e.type === "datetime") && (t instanceof Date || typeof t == "string")) {
|
|
1652
|
-
const i = e.type === "date" ?
|
|
2372
|
+
const i = e.type === "date" ? J(e.dateFormat, "date") : e.type === "time" ? J(e.timeFormat, "time") : J(e.dateTimeFormat, "datetime");
|
|
1653
2373
|
let n = null;
|
|
1654
|
-
return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text:
|
|
2374
|
+
return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text: Bt(n, i) } : { text: String(t) };
|
|
1655
2375
|
}
|
|
1656
2376
|
return { text: String(t) };
|
|
1657
2377
|
}
|
|
1658
2378
|
}
|
|
1659
|
-
const
|
|
2379
|
+
const W = class W {
|
|
1660
2380
|
constructor(t, e = () => "direct") {
|
|
1661
|
-
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 =
|
|
2381
|
+
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 = st, this.headerHeight = nt, this.lineHeight = 16, this.padding = 12, this.rowHeaderWidth = Y, this.activeRowId = null, this.activeColKey = null, this.selection = [], this.valueFormatCache = new Jt(), this.textMeasureCache = /* @__PURE__ */ new Map(), this.frame = 0, this.cursorTimer = null, this.pendingCursorPoint = null, this.hoverHeaderColKey = null, this.hoverHeaderIcon = !1, this.rowHeightCacheKey = null, this.rowHeightMeasuredVersion = /* @__PURE__ */ new Map(), this.rowHeightMeasureRaf = null, this.rowHeightMeasureTask = null, this.heightIndex = null, this.handleClick = (i) => {
|
|
1662
2382
|
if (!this.root || !this.canvas) return;
|
|
1663
2383
|
const n = this.canvas.getBoundingClientRect(), s = i.clientX - n.left, o = i.clientY - n.top, r = s + this.root.scrollLeft, a = o;
|
|
1664
2384
|
if (a >= this.headerHeight || r < this.rowHeaderWidth) return;
|
|
1665
|
-
const
|
|
1666
|
-
let f = this.rowHeaderWidth,
|
|
1667
|
-
for (let
|
|
1668
|
-
const
|
|
1669
|
-
if (r >= f && r <= f +
|
|
1670
|
-
|
|
2385
|
+
const c = this.dataModel.getSchema(), u = this.dataModel.getView(), d = X(c, u);
|
|
2386
|
+
let f = this.rowHeaderWidth, g = -1;
|
|
2387
|
+
for (let b = 0; b < d.length; b += 1) {
|
|
2388
|
+
const S = d[b] ?? 100;
|
|
2389
|
+
if (r >= f && r <= f + S) {
|
|
2390
|
+
g = b;
|
|
1671
2391
|
break;
|
|
1672
2392
|
}
|
|
1673
|
-
f +=
|
|
2393
|
+
f += S;
|
|
1674
2394
|
}
|
|
1675
|
-
if (
|
|
1676
|
-
const
|
|
1677
|
-
if (!
|
|
1678
|
-
const
|
|
1679
|
-
r >= w && r <= w +
|
|
1680
|
-
new CustomEvent("extable:filter-sort-open", { bubbles: !0, detail: { colKey:
|
|
2395
|
+
if (g < 0) return;
|
|
2396
|
+
const p = c.columns[g];
|
|
2397
|
+
if (!p) return;
|
|
2398
|
+
const h = d[g] ?? 100, m = 18, w = f + h - m - 4, C = Math.floor((this.headerHeight - m) / 2);
|
|
2399
|
+
r >= w && r <= w + m && a >= C && a <= C + m && this.root.dispatchEvent(
|
|
2400
|
+
new CustomEvent("extable:filter-sort-open", { bubbles: !0, detail: { colKey: p.key } })
|
|
1681
2401
|
);
|
|
1682
2402
|
}, this.handlePointerMove = (i) => {
|
|
1683
2403
|
this.pendingCursorPoint = { x: i.clientX, y: i.clientY }, !this.cursorTimer && (this.cursorTimer = window.setTimeout(() => {
|
|
@@ -1691,7 +2411,7 @@ const O = class O {
|
|
|
1691
2411
|
}
|
|
1692
2412
|
mount(t) {
|
|
1693
2413
|
this.root = t, this.canvas = document.createElement("canvas");
|
|
1694
|
-
const e =
|
|
2414
|
+
const e = W.MAX_CANVAS_DIM_PX;
|
|
1695
2415
|
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();
|
|
1696
2416
|
}
|
|
1697
2417
|
setActiveCell(t, e) {
|
|
@@ -1707,142 +2427,138 @@ const O = class O {
|
|
|
1707
2427
|
if (!e) return;
|
|
1708
2428
|
e.font = "14px sans-serif";
|
|
1709
2429
|
let i = e.font;
|
|
1710
|
-
const n = this.activeRowId === "__all__" && this.activeColKey === "__all__", s = this.dataModel.getSchema(), o = this.dataModel.getView(), r = this.dataModel.listRows(), a =
|
|
1711
|
-
f !== this.rowHeightCacheKey && (this.rowHeightCacheKey = f, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null),
|
|
1712
|
-
const
|
|
1713
|
-
if (!
|
|
1714
|
-
const
|
|
1715
|
-
this.canvas.width !== w && (this.canvas.width = w), this.canvas.height !==
|
|
1716
|
-
const
|
|
1717
|
-
const
|
|
2430
|
+
const n = this.activeRowId === "__all__" && this.activeColKey === "__all__", s = this.dataModel.getSchema(), o = this.dataModel.getView(), r = this.dataModel.listRows(), a = X(s, o), c = s.columns.map((k) => St(k)), u = /* @__PURE__ */ new Map(), d = s.columns.some((k) => o.wrapText?.[k.key] ?? k.wrapText), f = d ? this.getRowHeightCacheKey(s, o, a) : null;
|
|
2431
|
+
f !== this.rowHeightCacheKey && (this.rowHeightCacheKey = f, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null), d || this.cancelRowHeightMeasurement(), this.ensureHeightIndex(r, d ? f : null, d);
|
|
2432
|
+
const g = this.heightIndex;
|
|
2433
|
+
if (!g) return;
|
|
2434
|
+
const p = this.rowHeaderWidth + a.reduce((k, A) => k + (A ?? 0), 0), h = t?.clientWidth ?? (this.root.clientWidth || 600), m = t?.clientHeight ?? (this.root.clientHeight || this.canvas.height || 400), y = W.MAX_CANVAS_DIM_PX, w = Math.max(1, Math.min(y, Math.floor(h))), C = Math.max(1, Math.min(y, Math.floor(m)));
|
|
2435
|
+
this.canvas.width !== w && (this.canvas.width = w), this.canvas.height !== C && (this.canvas.height = C), this.canvas.style.width = `${w}px`, this.canvas.style.height = `${C}px`, e.font = "14px sans-serif", i = e.font, this.refreshTooltipPosition();
|
|
2436
|
+
const v = t?.scrollTop ?? this.root.scrollTop, b = t?.scrollLeft ?? this.root.scrollLeft, S = (k) => {
|
|
2437
|
+
const A = k + 1, I = Math.max(
|
|
1718
2438
|
0,
|
|
1719
|
-
Math.min(r.length - 1,
|
|
1720
|
-
),
|
|
1721
|
-
let
|
|
1722
|
-
const
|
|
1723
|
-
for (let T =
|
|
1724
|
-
$ +=
|
|
1725
|
-
return { accum:
|
|
2439
|
+
Math.min(r.length - 1, g.fenwick.lowerBound(A))
|
|
2440
|
+
), j = g.fenwick.sum(I);
|
|
2441
|
+
let K = I, $ = 0;
|
|
2442
|
+
const N = (this.canvas?.height ?? 0) + this.rowHeight * 2;
|
|
2443
|
+
for (let T = I; T < r.length && $ < N; T += 1)
|
|
2444
|
+
$ += g.heights[T] ?? this.rowHeight, K = T + 1;
|
|
2445
|
+
return { accum: j, visibleStart: I, visibleEnd: K };
|
|
1726
2446
|
};
|
|
1727
|
-
let
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
if (u && f) {
|
|
2447
|
+
let x = g.fenwick.total();
|
|
2448
|
+
const R = this.canvas?.height ?? this.root.clientHeight, E = Math.max(0, R - this.headerHeight);
|
|
2449
|
+
let M = Math.max(0, x - E), P = Math.max(0, Math.min(v, M)), { accum: H, visibleStart: D, visibleEnd: F } = S(P);
|
|
2450
|
+
if (d && f) {
|
|
1732
2451
|
const k = {};
|
|
1733
|
-
for (let
|
|
1734
|
-
const
|
|
1735
|
-
if (!
|
|
1736
|
-
const
|
|
1737
|
-
if (this.rowHeightMeasuredVersion.get(
|
|
1738
|
-
const
|
|
1739
|
-
k[
|
|
2452
|
+
for (let A = D; A < F; A += 1) {
|
|
2453
|
+
const I = r[A];
|
|
2454
|
+
if (!I) continue;
|
|
2455
|
+
const j = this.dataModel.getRowVersion(I.id);
|
|
2456
|
+
if (this.rowHeightMeasuredVersion.get(I.id) === j) continue;
|
|
2457
|
+
const K = this.measureRowHeight(e, I, s, a);
|
|
2458
|
+
k[I.id] = K, this.rowHeightMeasuredVersion.set(I.id, j);
|
|
1740
2459
|
}
|
|
1741
|
-
this.applyRowHeightUpdates(k),
|
|
1742
|
-
0,
|
|
1743
|
-
Math.min(b, Math.max(0, R - this.rowHeight))
|
|
1744
|
-
), { accum: x, visibleStart: M, visibleEnd: A } = v(I), (this.rowHeightMeasureTask || Object.keys(k).length > 0) && this.scheduleRowHeightMeasurement();
|
|
2460
|
+
this.applyRowHeightUpdates(k), x = g.fenwick.total(), this.dataModel.setRowHeightsBulk(k), M = Math.max(0, x - E), P = Math.max(0, Math.min(v, M)), { accum: H, visibleStart: D, visibleEnd: F } = S(P), (this.rowHeightMeasureTask || Object.keys(k).length > 0) && this.scheduleRowHeightMeasurement();
|
|
1745
2461
|
}
|
|
1746
|
-
this.spacer && (this.spacer.style.height = `${
|
|
1747
|
-
const
|
|
2462
|
+
this.spacer && (this.spacer.style.height = `${M}px`, this.spacer.style.width = `${p}px`);
|
|
2463
|
+
const O = this.rowHeaderWidth - b;
|
|
1748
2464
|
e.clearRect(0, 0, this.canvas.width, this.canvas.height), e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.rowHeaderWidth, this.canvas.height);
|
|
1749
|
-
let
|
|
1750
|
-
for (let k =
|
|
1751
|
-
const
|
|
1752
|
-
e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0,
|
|
1753
|
-
const
|
|
1754
|
-
this.activeRowId ===
|
|
2465
|
+
let B = this.headerHeight + H - P;
|
|
2466
|
+
for (let k = D; k < F; k += 1) {
|
|
2467
|
+
const A = r[k], I = g.heights[k] ?? this.rowHeight;
|
|
2468
|
+
e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0, B, this.rowHeaderWidth, I), e.strokeRect(0, B, this.rowHeaderWidth, I);
|
|
2469
|
+
const j = this.dataModel.getDisplayIndex(A.id) ?? "";
|
|
2470
|
+
this.activeRowId === A.id && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(0, B, this.rowHeaderWidth, I)), e.fillStyle = "#0f172a", e.font = "bold 14px sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText(String(j), this.rowHeaderWidth / 2, B + I / 2), e.font = i, e.textAlign = "left", e.textBaseline = "alphabetic", e.save(), e.beginPath(), e.rect(
|
|
1755
2471
|
this.rowHeaderWidth,
|
|
1756
2472
|
this.headerHeight,
|
|
1757
2473
|
this.canvas.width - this.rowHeaderWidth,
|
|
1758
2474
|
this.canvas.height - this.headerHeight
|
|
1759
|
-
), e.clip(), e.translate(
|
|
1760
|
-
let
|
|
1761
|
-
for (let
|
|
1762
|
-
const T = s.columns[
|
|
2475
|
+
), e.clip(), e.translate(O, 0);
|
|
2476
|
+
let K = 0, $ = "";
|
|
2477
|
+
for (let N = 0; N < s.columns.length; N += 1) {
|
|
2478
|
+
const T = s.columns[N], L = a[N] ?? 100;
|
|
1763
2479
|
if (!T) {
|
|
1764
|
-
|
|
2480
|
+
K += L;
|
|
1765
2481
|
continue;
|
|
1766
2482
|
}
|
|
1767
|
-
const V = this.dataModel.isReadonly(
|
|
2483
|
+
const V = this.dataModel.isReadonly(A.id, T.key);
|
|
1768
2484
|
e.strokeStyle = "#d0d7de";
|
|
1769
|
-
const
|
|
1770
|
-
e.fillStyle =
|
|
1771
|
-
const
|
|
1772
|
-
if (this.activeRowId ===
|
|
2485
|
+
const ot = this.dataModel.resolveConditionalStyle(A.id, T), tt = this.dataModel.getCellStyle(A.id, T.key), et = c[N] ?? {}, Ct = ot.delta ? Z(et, ot.delta) : et, G = tt ? Z(Ct, tt) : Ct, Zt = V ? "#f3f4f6" : G.backgroundColor ?? "#ffffff";
|
|
2486
|
+
e.fillStyle = Zt, e.fillRect(K, B, L, I), e.strokeRect(K, B, L, I);
|
|
2487
|
+
const xt = this.dataModel.resolveCellValue(A.id, T), pt = xt.textOverride ?? (ot.forceErrorText ? "#ERROR" : void 0) ? { text: "#ERROR" } : this.formatValue(xt.value, T), te = pt.text, ee = T.style?.align ?? (T.type === "number" ? "right" : "left");
|
|
2488
|
+
if (this.activeRowId === A.id && this.activeColKey !== null && this.activeColKey === T.key && (e.strokeStyle = "#3b82f6", e.lineWidth = 2, e.strokeRect(K + 1, B + 1, L - 2, I - 2), e.lineWidth = 1, ft(
|
|
1773
2489
|
this.dataModel,
|
|
1774
2490
|
this.selection,
|
|
1775
2491
|
this.activeRowId,
|
|
1776
2492
|
this.activeColKey,
|
|
1777
2493
|
this.getEditMode()
|
|
1778
2494
|
))) {
|
|
1779
|
-
const
|
|
1780
|
-
e.fillStyle = "#3b82f6", e.fillRect(
|
|
2495
|
+
const q = Ut, it = K + L - q - 1, lt = B + I - q - 1;
|
|
2496
|
+
e.fillStyle = "#3b82f6", e.fillRect(it, lt, q, q), e.strokeStyle = "#ffffff", e.strokeRect(it + 0.5, lt + 0.5, q - 1, q - 1);
|
|
1781
2497
|
}
|
|
1782
|
-
e.fillStyle = this.dataModel.hasPending(
|
|
1783
|
-
const
|
|
1784
|
-
if (
|
|
2498
|
+
e.fillStyle = this.dataModel.hasPending(A.id, T.key) ? "#b91c1c" : pt.color ? pt.color : V ? "#94a3b8" : G.textColor ?? "#0f172a";
|
|
2499
|
+
const ie = o.wrapText?.[T.key] ?? T.wrapText ?? !1, Rt = T.type === "boolean" && (!T.booleanDisplay || T.booleanDisplay === "checkbox"), ne = T.type === "boolean" && !!(T.booleanDisplay && T.booleanDisplay !== "checkbox");
|
|
2500
|
+
if (Rt)
|
|
1785
2501
|
e.font = i, $ = "";
|
|
1786
2502
|
else {
|
|
1787
|
-
const
|
|
1788
|
-
if (
|
|
1789
|
-
const
|
|
1790
|
-
if (
|
|
2503
|
+
const q = `${G.italic ? "i" : ""}${G.bold ? "b" : ""}`;
|
|
2504
|
+
if (q !== $) {
|
|
2505
|
+
const it = u.get(q);
|
|
2506
|
+
if (it) e.font = it;
|
|
1791
2507
|
else {
|
|
1792
|
-
const
|
|
1793
|
-
|
|
2508
|
+
const lt = G.bold ? "600 " : "", kt = `${G.italic ? "italic " : ""}${lt}14px sans-serif`.trim();
|
|
2509
|
+
u.set(q, kt), e.font = kt;
|
|
1794
2510
|
}
|
|
1795
|
-
$ =
|
|
2511
|
+
$ = q;
|
|
1796
2512
|
}
|
|
1797
2513
|
}
|
|
1798
2514
|
this.drawCellText(
|
|
1799
2515
|
e,
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
2516
|
+
te,
|
|
2517
|
+
K + 8,
|
|
2518
|
+
B + 2,
|
|
1803
2519
|
L - 12,
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
{ underline: !!
|
|
2520
|
+
I - 8,
|
|
2521
|
+
ie,
|
|
2522
|
+
ee,
|
|
2523
|
+
Rt,
|
|
2524
|
+
ne,
|
|
2525
|
+
{ underline: !!G.underline, strike: !!G.strike }
|
|
1810
2526
|
);
|
|
1811
|
-
const
|
|
1812
|
-
|
|
2527
|
+
const Mt = this.dataModel.getCellMarker(A.id, T.key);
|
|
2528
|
+
Mt && Ii(e, K, B, L, I, Mt.level), K += L;
|
|
1813
2529
|
}
|
|
1814
|
-
e.restore(),
|
|
2530
|
+
e.restore(), B += I;
|
|
1815
2531
|
}
|
|
1816
|
-
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(
|
|
1817
|
-
let
|
|
2532
|
+
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(O, 0);
|
|
2533
|
+
let z = 0;
|
|
1818
2534
|
for (let k = 0; k < s.columns.length; k += 1) {
|
|
1819
|
-
const
|
|
1820
|
-
if (!
|
|
1821
|
-
|
|
2535
|
+
const A = s.columns[k], I = a[k] ?? 100;
|
|
2536
|
+
if (!A) {
|
|
2537
|
+
z += I;
|
|
1822
2538
|
continue;
|
|
1823
2539
|
}
|
|
1824
|
-
this.activeColKey !== null && this.activeColKey ===
|
|
1825
|
-
const
|
|
1826
|
-
if (!!
|
|
1827
|
-
const L =
|
|
1828
|
-
|
|
2540
|
+
this.activeColKey !== null && this.activeColKey === A.key && (e.fillStyle = "rgba(59,130,246,0.16)", e.fillRect(z, 0, I, this.headerHeight)), e.strokeStyle = "#d0d7de", e.strokeRect(z, 0, I, this.headerHeight), e.fillStyle = "#0f172a", e.font = "bold 14px sans-serif", e.fillText(A.header ?? A.key, z + 8, this.headerHeight - 8), e.font = i;
|
|
2541
|
+
const K = Qt(o, A.key), $ = Yt(o, A.key), N = this.hoverHeaderColKey !== null && this.hoverHeaderColKey === A.key;
|
|
2542
|
+
if (!!K || $ || N) {
|
|
2543
|
+
const L = N ? 0.9 : $ || K ? 0.75 : 0.45, V = 16, tt = z + I - V - 6, et = Math.floor((this.headerHeight - V) / 2);
|
|
2544
|
+
K ? Ti(e, tt + 3, et + 3, V - 6, L, K) : Ei(e, tt + 2, et + 2, V - 4, L);
|
|
1829
2545
|
}
|
|
1830
|
-
|
|
2546
|
+
z += I;
|
|
1831
2547
|
}
|
|
1832
2548
|
if (e.restore(), this.selection.length) {
|
|
1833
2549
|
e.save(), e.strokeStyle = "#3b82f6", e.fillStyle = "rgba(59,130,246,0.12)";
|
|
1834
2550
|
for (const k of this.selection) {
|
|
1835
|
-
const
|
|
2551
|
+
const A = Math.max(0, Math.min(k.startRow, k.endRow)), I = Math.min(r.length - 1, Math.max(k.startRow, k.endRow)), j = Math.max(0, Math.min(k.startCol, k.endCol)), K = Math.min(
|
|
1836
2552
|
s.columns.length - 1,
|
|
1837
2553
|
Math.max(k.startCol, k.endCol)
|
|
1838
|
-
), $ = this.headerHeight +
|
|
2554
|
+
), $ = this.headerHeight + g.fenwick.sum(A) - P, N = g.fenwick.sum(I + 1) - g.fenwick.sum(A);
|
|
1839
2555
|
let T = this.rowHeaderWidth;
|
|
1840
|
-
for (let V = 0; V <
|
|
2556
|
+
for (let V = 0; V < j; V += 1)
|
|
1841
2557
|
T += a[V] ?? 100;
|
|
1842
2558
|
let L = 0;
|
|
1843
|
-
for (let V =
|
|
2559
|
+
for (let V = j; V <= K; V += 1)
|
|
1844
2560
|
L += a[V] ?? 100;
|
|
1845
|
-
T -=
|
|
2561
|
+
T -= b, e.fillRect(T, $, L, N), e.strokeRect(T + 0.5, $ + 0.5, L - 1, N - 1);
|
|
1846
2562
|
}
|
|
1847
2563
|
e.restore();
|
|
1848
2564
|
}
|
|
@@ -1862,19 +2578,19 @@ const O = class O {
|
|
|
1862
2578
|
const a = t[r];
|
|
1863
2579
|
if (!a) continue;
|
|
1864
2580
|
o.set(a.id, r);
|
|
1865
|
-
let
|
|
2581
|
+
let c = this.rowHeight;
|
|
1866
2582
|
if (i && e) {
|
|
1867
|
-
const
|
|
1868
|
-
|
|
2583
|
+
const u = this.dataModel.getRowVersion(a.id), d = this.rowHeightMeasuredVersion.get(a.id), f = this.dataModel.getRowHeight(a.id);
|
|
2584
|
+
d === u && typeof f == "number" && (c = f);
|
|
1869
2585
|
}
|
|
1870
|
-
s[r] =
|
|
2586
|
+
s[r] = c;
|
|
1871
2587
|
}
|
|
1872
2588
|
this.heightIndex = {
|
|
1873
2589
|
key: e,
|
|
1874
2590
|
rowsRef: t,
|
|
1875
2591
|
idToIndex: o,
|
|
1876
2592
|
heights: s,
|
|
1877
|
-
fenwick:
|
|
2593
|
+
fenwick: vt.from(s)
|
|
1878
2594
|
};
|
|
1879
2595
|
}
|
|
1880
2596
|
applyRowHeightUpdates(t) {
|
|
@@ -1904,101 +2620,95 @@ const O = class O {
|
|
|
1904
2620
|
const t = this.canvas.getContext("2d");
|
|
1905
2621
|
if (!t) return;
|
|
1906
2622
|
t.font = "14px sans-serif";
|
|
1907
|
-
const e = this.dataModel.getSchema(), i = this.dataModel.getView(), n =
|
|
2623
|
+
const e = this.dataModel.getSchema(), i = this.dataModel.getView(), n = X(e, i);
|
|
1908
2624
|
if (!e.columns.some((f) => i.wrapText?.[f.key] ?? f.wrapText)) return;
|
|
1909
2625
|
const o = this.getRowHeightCacheKey(e, i, n);
|
|
1910
2626
|
this.rowHeightCacheKey !== o && (this.rowHeightCacheKey = o, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null);
|
|
1911
2627
|
const r = this.rowHeightMeasureTask ?? { key: o, nextIndex: 0 };
|
|
1912
2628
|
if (r.key !== o) return;
|
|
1913
|
-
const a = this.dataModel.listRows(),
|
|
1914
|
-
let
|
|
1915
|
-
const
|
|
1916
|
-
for (; r.nextIndex < a.length &&
|
|
2629
|
+
const a = this.dataModel.listRows(), c = {};
|
|
2630
|
+
let u = 0;
|
|
2631
|
+
const d = performance.now();
|
|
2632
|
+
for (; r.nextIndex < a.length && u < W.ROW_HEIGHT_MEASURE_CHUNK && !(performance.now() - d > W.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS); ) {
|
|
1917
2633
|
const f = a[r.nextIndex];
|
|
1918
2634
|
if (r.nextIndex += 1, !f) continue;
|
|
1919
|
-
const
|
|
1920
|
-
if (this.rowHeightMeasuredVersion.get(f.id) ===
|
|
1921
|
-
const
|
|
1922
|
-
|
|
2635
|
+
const g = this.dataModel.getRowVersion(f.id);
|
|
2636
|
+
if (this.rowHeightMeasuredVersion.get(f.id) === g) continue;
|
|
2637
|
+
const p = this.measureRowHeight(t, f, e, n);
|
|
2638
|
+
c[f.id] = p, this.rowHeightMeasuredVersion.set(f.id, g), u += 1;
|
|
1923
2639
|
}
|
|
1924
|
-
this.rowHeightMeasureTask = r.nextIndex < a.length ? r : null, this.ensureHeightIndex(a, this.rowHeightCacheKey, !0), this.applyRowHeightUpdates(
|
|
2640
|
+
this.rowHeightMeasureTask = r.nextIndex < a.length ? r : null, this.ensureHeightIndex(a, this.rowHeightCacheKey, !0), this.applyRowHeightUpdates(c), this.dataModel.setRowHeightsBulk(c), this.rowHeightMeasureTask && this.scheduleRowHeightMeasurement();
|
|
1925
2641
|
}
|
|
1926
2642
|
getCellElements() {
|
|
1927
2643
|
return null;
|
|
1928
2644
|
}
|
|
1929
2645
|
hitTest(t) {
|
|
1930
2646
|
if (!this.root || !this.canvas) return null;
|
|
1931
|
-
const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, n = t.clientY - e.top, s = i + this.root.scrollLeft, o = this.dataModel.getSchema(), r = this.dataModel.getView(), a = this.dataModel.listRows(),
|
|
1932
|
-
this.ensureHeightIndex(a, f,
|
|
1933
|
-
const
|
|
1934
|
-
if (!
|
|
1935
|
-
const
|
|
1936
|
-
|
|
1937
|
-
Math.min(
|
|
1938
|
-
this.root.scrollTop - this.headerHeight,
|
|
1939
|
-
Math.max(0, d - this.rowHeight)
|
|
1940
|
-
)
|
|
1941
|
-
);
|
|
1942
|
-
if (n < l && i < this.rowHeaderWidth)
|
|
2647
|
+
const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, n = t.clientY - e.top, s = i + this.root.scrollLeft, o = this.dataModel.getSchema(), r = this.dataModel.getView(), a = this.dataModel.listRows(), c = this.headerHeight, u = X(o, r), d = o.columns.some((H) => r.wrapText?.[H.key] ?? H.wrapText), f = d ? this.getRowHeightCacheKey(o, r, u) : null;
|
|
2648
|
+
this.ensureHeightIndex(a, f, d);
|
|
2649
|
+
const g = this.heightIndex;
|
|
2650
|
+
if (!g) return null;
|
|
2651
|
+
const p = g.fenwick.total(), h = this.canvas?.height ?? this.root.clientHeight, m = Math.max(0, h - this.headerHeight), y = Math.max(0, p - m), w = Math.max(0, Math.min(this.root.scrollTop, y));
|
|
2652
|
+
if (n < c && i < this.rowHeaderWidth)
|
|
1943
2653
|
return {
|
|
1944
2654
|
rowId: "__all__",
|
|
1945
2655
|
colKey: "__all__",
|
|
1946
|
-
rect: new DOMRect(e.left, e.top, this.rowHeaderWidth,
|
|
2656
|
+
rect: new DOMRect(e.left, e.top, this.rowHeaderWidth, c)
|
|
1947
2657
|
};
|
|
1948
|
-
if (n <
|
|
1949
|
-
let
|
|
1950
|
-
for (let
|
|
1951
|
-
const
|
|
1952
|
-
if (s >=
|
|
1953
|
-
|
|
2658
|
+
if (n < c) {
|
|
2659
|
+
let H = this.rowHeaderWidth, D = -1;
|
|
2660
|
+
for (let F = 0; F < u.length; F += 1) {
|
|
2661
|
+
const O = u[F] ?? 100;
|
|
2662
|
+
if (s >= H && s <= H + O) {
|
|
2663
|
+
D = F;
|
|
1954
2664
|
break;
|
|
1955
2665
|
}
|
|
1956
|
-
|
|
2666
|
+
H += O;
|
|
1957
2667
|
}
|
|
1958
|
-
if (
|
|
1959
|
-
const
|
|
1960
|
-
e.left +
|
|
2668
|
+
if (D >= 0) {
|
|
2669
|
+
const F = o.columns[D], O = new DOMRect(
|
|
2670
|
+
e.left + H - this.root.scrollLeft,
|
|
1961
2671
|
e.top,
|
|
1962
|
-
|
|
1963
|
-
|
|
2672
|
+
u[D] ?? 100,
|
|
2673
|
+
c
|
|
1964
2674
|
);
|
|
1965
|
-
return { rowId: "__header__", colKey:
|
|
2675
|
+
return { rowId: "__header__", colKey: F.key, rect: O };
|
|
1966
2676
|
}
|
|
1967
2677
|
return null;
|
|
1968
2678
|
}
|
|
1969
2679
|
if (i < this.rowHeaderWidth) {
|
|
1970
|
-
const
|
|
2680
|
+
const H = n - c + w, D = Math.max(
|
|
1971
2681
|
0,
|
|
1972
|
-
Math.min(a.length - 1,
|
|
1973
|
-
),
|
|
1974
|
-
if (
|
|
1975
|
-
const
|
|
2682
|
+
Math.min(a.length - 1, g.fenwick.lowerBound(H + 1))
|
|
2683
|
+
), F = g.fenwick.sum(D);
|
|
2684
|
+
if (D < 0 || D >= a.length) return null;
|
|
2685
|
+
const O = a[D], B = e.top + c + F - w, z = new DOMRect(
|
|
1976
2686
|
e.left,
|
|
1977
|
-
|
|
2687
|
+
B,
|
|
1978
2688
|
this.rowHeaderWidth,
|
|
1979
|
-
|
|
2689
|
+
g.heights[D] ?? this.rowHeight
|
|
1980
2690
|
);
|
|
1981
|
-
return { rowId:
|
|
1982
|
-
}
|
|
1983
|
-
const
|
|
1984
|
-
if (
|
|
1985
|
-
let S = this.rowHeaderWidth,
|
|
1986
|
-
for (let
|
|
1987
|
-
const
|
|
1988
|
-
if (s >= S && s <= S +
|
|
1989
|
-
|
|
2691
|
+
return { rowId: O.id, colKey: null, rect: z };
|
|
2692
|
+
}
|
|
2693
|
+
const C = n - c + w, v = Math.max(0, Math.min(a.length - 1, g.fenwick.lowerBound(C + 1))), b = g.fenwick.sum(v);
|
|
2694
|
+
if (v < 0 || v >= a.length) return null;
|
|
2695
|
+
let S = this.rowHeaderWidth, x = -1;
|
|
2696
|
+
for (let H = 0; H < u.length; H += 1) {
|
|
2697
|
+
const D = u[H] ?? 100;
|
|
2698
|
+
if (s >= S && s <= S + D) {
|
|
2699
|
+
x = H;
|
|
1990
2700
|
break;
|
|
1991
2701
|
}
|
|
1992
|
-
S +=
|
|
2702
|
+
S += D;
|
|
1993
2703
|
}
|
|
1994
|
-
if (
|
|
1995
|
-
const
|
|
2704
|
+
if (x === -1) return null;
|
|
2705
|
+
const R = a[v], E = o.columns[x], M = b, P = new DOMRect(
|
|
1996
2706
|
e.left + S - this.root.scrollLeft,
|
|
1997
|
-
e.top +
|
|
1998
|
-
|
|
1999
|
-
|
|
2707
|
+
e.top + c + M - this.root.scrollTop,
|
|
2708
|
+
u[x] ?? 100,
|
|
2709
|
+
g.heights[v] ?? this.rowHeight
|
|
2000
2710
|
);
|
|
2001
|
-
return { rowId:
|
|
2711
|
+
return { rowId: R.id, colKey: E.key, rect: P };
|
|
2002
2712
|
}
|
|
2003
2713
|
isPointInSelection(t, e) {
|
|
2004
2714
|
if (!this.selection.length) return !1;
|
|
@@ -2006,8 +2716,8 @@ const O = class O {
|
|
|
2006
2716
|
if (n < 0 || s < 0) return !1;
|
|
2007
2717
|
for (const o of this.selection) {
|
|
2008
2718
|
if (o.kind !== "cells") continue;
|
|
2009
|
-
const r = Math.min(o.startRow, o.endRow), a = Math.max(o.startRow, o.endRow),
|
|
2010
|
-
if (n >= r && n <= a && s >=
|
|
2719
|
+
const r = Math.min(o.startRow, o.endRow), a = Math.max(o.startRow, o.endRow), c = Math.min(o.startCol, o.endCol), u = Math.max(o.startCol, o.endCol);
|
|
2720
|
+
if (n >= r && n <= a && s >= c && s <= u)
|
|
2011
2721
|
return !0;
|
|
2012
2722
|
}
|
|
2013
2723
|
return !1;
|
|
@@ -2016,8 +2726,8 @@ const O = class O {
|
|
|
2016
2726
|
if (!this.tooltip || !this.root) return;
|
|
2017
2727
|
const e = 8, i = this.root.getBoundingClientRect(), n = this.root.clientWidth, s = this.root.clientHeight;
|
|
2018
2728
|
let o = t.right - i.left + e, r = t.top - i.top + e, a = "right";
|
|
2019
|
-
const
|
|
2020
|
-
o +
|
|
2729
|
+
const c = this.tooltip.getBoundingClientRect();
|
|
2730
|
+
o + c.width > n && (o = Math.max(0, t.left - i.left - c.width - e), a = "left"), r + c.height > s && (r = Math.max(0, s - c.height - e)), this.tooltip.style.left = `${o}px`, this.tooltip.style.top = `${r}px`, this.tooltip.dataset.side = a;
|
|
2021
2731
|
}
|
|
2022
2732
|
refreshTooltipPosition() {
|
|
2023
2733
|
if (!this.tooltip || this.tooltip.dataset.visible !== "1" || !this.tooltipTarget || !this.tooltipMessage) return;
|
|
@@ -2030,20 +2740,20 @@ const O = class O {
|
|
|
2030
2740
|
}
|
|
2031
2741
|
getCellRect(t, e) {
|
|
2032
2742
|
if (!this.root || !this.canvas) return null;
|
|
2033
|
-
const i = this.canvas.getBoundingClientRect(), n = this.dataModel.getSchema(), s = this.dataModel.getView(), o = this.dataModel.listRows(), r = this.dataModel.getRowIndex(t), a = n.columns.findIndex((
|
|
2743
|
+
const i = this.canvas.getBoundingClientRect(), n = this.dataModel.getSchema(), s = this.dataModel.getView(), o = this.dataModel.listRows(), r = this.dataModel.getRowIndex(t), a = n.columns.findIndex((h) => h.key === e);
|
|
2034
2744
|
if (r < 0 || a < 0) return null;
|
|
2035
|
-
const
|
|
2036
|
-
this.ensureHeightIndex(o,
|
|
2745
|
+
const c = X(n, s), u = n.columns.some((h) => s.wrapText?.[h.key] ?? h.wrapText), d = u ? this.getRowHeightCacheKey(n, s, c) : null;
|
|
2746
|
+
this.ensureHeightIndex(o, d, u);
|
|
2037
2747
|
const f = this.heightIndex;
|
|
2038
2748
|
if (!f) return null;
|
|
2039
|
-
const
|
|
2040
|
-
let
|
|
2041
|
-
for (let
|
|
2042
|
-
|
|
2749
|
+
const g = f.fenwick.sum(r);
|
|
2750
|
+
let p = this.rowHeaderWidth;
|
|
2751
|
+
for (let h = 0; h < a; h += 1)
|
|
2752
|
+
p += c[h] ?? 100;
|
|
2043
2753
|
return new DOMRect(
|
|
2044
|
-
i.left +
|
|
2045
|
-
i.top + this.headerHeight +
|
|
2046
|
-
|
|
2754
|
+
i.left + p - this.root.scrollLeft,
|
|
2755
|
+
i.top + this.headerHeight + g - this.root.scrollTop,
|
|
2756
|
+
c[a] ?? 100,
|
|
2047
2757
|
f.heights[r] ?? this.rowHeight
|
|
2048
2758
|
);
|
|
2049
2759
|
}
|
|
@@ -2054,28 +2764,28 @@ const O = class O {
|
|
|
2054
2764
|
return;
|
|
2055
2765
|
}
|
|
2056
2766
|
{
|
|
2057
|
-
const
|
|
2058
|
-
let
|
|
2059
|
-
if (
|
|
2060
|
-
const
|
|
2061
|
-
let
|
|
2062
|
-
for (let
|
|
2063
|
-
const M =
|
|
2064
|
-
if (f >=
|
|
2065
|
-
|
|
2767
|
+
const c = this.canvas.getBoundingClientRect(), u = t - c.left, d = e - c.top, f = u + this.root.scrollLeft, g = d, p = this.hoverHeaderColKey, h = this.hoverHeaderIcon;
|
|
2768
|
+
let m = null, y = !1;
|
|
2769
|
+
if (g >= 0 && g < this.headerHeight && f >= this.rowHeaderWidth) {
|
|
2770
|
+
const C = this.dataModel.getSchema(), v = this.dataModel.getView(), b = X(C, v);
|
|
2771
|
+
let S = this.rowHeaderWidth, x = -1;
|
|
2772
|
+
for (let E = 0; E < b.length; E += 1) {
|
|
2773
|
+
const M = b[E] ?? 100;
|
|
2774
|
+
if (f >= S && f <= S + M) {
|
|
2775
|
+
x = E;
|
|
2066
2776
|
break;
|
|
2067
2777
|
}
|
|
2068
|
-
|
|
2778
|
+
S += M;
|
|
2069
2779
|
}
|
|
2070
|
-
const
|
|
2071
|
-
if (
|
|
2072
|
-
|
|
2073
|
-
const
|
|
2074
|
-
y = f >=
|
|
2780
|
+
const R = x >= 0 ? C.columns[x] : null;
|
|
2781
|
+
if (R) {
|
|
2782
|
+
m = R.key;
|
|
2783
|
+
const E = b[x] ?? 100, M = 18, H = S + E - M - 4, D = Math.floor((this.headerHeight - M) / 2);
|
|
2784
|
+
y = f >= H && f <= H + M && g >= D && g <= D + M;
|
|
2075
2785
|
}
|
|
2076
2786
|
}
|
|
2077
|
-
const w = String(
|
|
2078
|
-
if (this.hoverHeaderColKey =
|
|
2787
|
+
const w = String(p ?? "") !== String(m ?? "") || !!h != !!y;
|
|
2788
|
+
if (this.hoverHeaderColKey = m, this.hoverHeaderIcon = y, m !== null) {
|
|
2079
2789
|
this.canvas.style.cursor = y ? "pointer" : "default", this.tooltip && (this.tooltip.dataset.visible = "0"), this.tooltipTarget = null, this.tooltipMessage = null, w && this.render();
|
|
2080
2790
|
return;
|
|
2081
2791
|
}
|
|
@@ -2097,11 +2807,11 @@ const O = class O {
|
|
|
2097
2807
|
}
|
|
2098
2808
|
const s = this.dataModel.getCellMarker(n.rowId, n.colKey);
|
|
2099
2809
|
if (this.tooltip && s) {
|
|
2100
|
-
const
|
|
2101
|
-
if (!
|
|
2810
|
+
const c = this.tooltipTarget && this.tooltipTarget.rowId === n.rowId && this.tooltipTarget.colKey === n.colKey, u = this.tooltipMessage === s.message;
|
|
2811
|
+
if (!c || !u || this.tooltip.dataset.visible !== "1") {
|
|
2102
2812
|
this.tooltipTarget = { rowId: n.rowId, colKey: n.colKey }, this.tooltipMessage = s.message, this.tooltip.textContent = s.message;
|
|
2103
|
-
const
|
|
2104
|
-
|
|
2813
|
+
const d = this.getCellRect(n.rowId, n.colKey);
|
|
2814
|
+
d ? (this.positionTooltipAtRect(d), this.tooltip.dataset.visible = "1") : this.tooltip.dataset.visible = "0";
|
|
2105
2815
|
}
|
|
2106
2816
|
} else this.tooltip && (this.tooltip.dataset.visible = "0", this.tooltipTarget = null, this.tooltipMessage = null);
|
|
2107
2817
|
if (!this.isPointInSelection(n.rowId, n.colKey)) {
|
|
@@ -2112,23 +2822,23 @@ const O = class O {
|
|
|
2112
2822
|
this.canvas.style.cursor = "cell";
|
|
2113
2823
|
return;
|
|
2114
2824
|
}
|
|
2115
|
-
if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" &&
|
|
2825
|
+
if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" && ft(
|
|
2116
2826
|
this.dataModel,
|
|
2117
2827
|
this.selection,
|
|
2118
2828
|
this.activeRowId,
|
|
2119
2829
|
this.activeColKey,
|
|
2120
2830
|
this.getEditMode()
|
|
2121
2831
|
)) {
|
|
2122
|
-
const
|
|
2123
|
-
if (
|
|
2124
|
-
const
|
|
2125
|
-
if (
|
|
2832
|
+
const c = this.getCellRect(this.activeRowId, this.activeColKey);
|
|
2833
|
+
if (c) {
|
|
2834
|
+
const u = zt(c, Xt);
|
|
2835
|
+
if (Gt(t, e, u)) {
|
|
2126
2836
|
this.canvas.style.cursor = "crosshair";
|
|
2127
2837
|
return;
|
|
2128
2838
|
}
|
|
2129
2839
|
}
|
|
2130
2840
|
}
|
|
2131
|
-
const r = this.dataModel.getSchema().columns.find((
|
|
2841
|
+
const r = this.dataModel.getSchema().columns.find((c) => c.key === n.colKey);
|
|
2132
2842
|
this.dataModel.isReadonly(n.rowId, n.colKey) || r?.type === "boolean" ? i = "default" : i = "text", this.canvas.style.cursor = i;
|
|
2133
2843
|
}
|
|
2134
2844
|
measureRowHeight(t, e, i, n) {
|
|
@@ -2137,8 +2847,8 @@ const O = class O {
|
|
|
2137
2847
|
for (let r = 0; r < i.columns.length; r += 1) {
|
|
2138
2848
|
const a = i.columns[r];
|
|
2139
2849
|
if (!a || !(o.wrapText?.[a.key] ?? a.wrapText)) continue;
|
|
2140
|
-
const
|
|
2141
|
-
s = Math.max(s,
|
|
2850
|
+
const u = (n[r] ?? 100) - this.padding, d = this.dataModel.resolveCellValue(e.id, a), f = this.dataModel.resolveConditionalStyle(e.id, a), p = d.textOverride ?? (f.forceErrorText ? "#ERROR" : void 0) ? "#ERROR" : this.formatValue(d.value, a).text, m = this.wrapLines(t, p, u).length * this.lineHeight + this.padding;
|
|
2851
|
+
s = Math.max(s, m);
|
|
2142
2852
|
}
|
|
2143
2853
|
return s;
|
|
2144
2854
|
}
|
|
@@ -2149,59 +2859,59 @@ const O = class O {
|
|
|
2149
2859
|
const o = e.split(`
|
|
2150
2860
|
`), r = [];
|
|
2151
2861
|
for (const a of o) {
|
|
2152
|
-
let
|
|
2153
|
-
for (; t.measureText(
|
|
2154
|
-
let
|
|
2155
|
-
for (;
|
|
2156
|
-
|
|
2157
|
-
r.push(
|
|
2862
|
+
let c = a;
|
|
2863
|
+
for (; t.measureText(c).width > i && c.length > 1; ) {
|
|
2864
|
+
let u = c.length;
|
|
2865
|
+
for (; u > 1 && t.measureText(c.slice(0, u)).width > i; )
|
|
2866
|
+
u -= 1;
|
|
2867
|
+
r.push(c.slice(0, u)), c = c.slice(u);
|
|
2158
2868
|
}
|
|
2159
|
-
r.push(
|
|
2869
|
+
r.push(c);
|
|
2160
2870
|
}
|
|
2161
|
-
for (this.textMeasureCache.set(n, { lines: r }); this.textMeasureCache.size >
|
|
2871
|
+
for (this.textMeasureCache.set(n, { lines: r }); this.textMeasureCache.size > W.TEXT_MEASURE_CACHE_MAX; ) {
|
|
2162
2872
|
const a = this.textMeasureCache.keys().next().value;
|
|
2163
2873
|
if (!a) break;
|
|
2164
2874
|
this.textMeasureCache.delete(a);
|
|
2165
2875
|
}
|
|
2166
2876
|
return r;
|
|
2167
2877
|
}
|
|
2168
|
-
drawCellText(t, e, i, n, s, o, r, a = "left",
|
|
2878
|
+
drawCellText(t, e, i, n, s, o, r, a = "left", c = !1, u = !1, d) {
|
|
2169
2879
|
t.save(), t.beginPath(), t.rect(i - 4, n - 4, s + 8, o + 8), t.clip();
|
|
2170
2880
|
const f = t.font;
|
|
2171
|
-
|
|
2172
|
-
const
|
|
2173
|
-
const
|
|
2881
|
+
c ? t.font = "28px sans-serif" : u && (t.font = "14px sans-serif");
|
|
2882
|
+
const g = (p, h) => {
|
|
2883
|
+
const m = n + this.lineHeight * h;
|
|
2174
2884
|
let y = i, w = i;
|
|
2175
2885
|
if (a === "right")
|
|
2176
|
-
t.textAlign = "right", w = i + s, y = w - t.measureText(
|
|
2886
|
+
t.textAlign = "right", w = i + s, y = w - t.measureText(p).width, t.fillText(p, w, m);
|
|
2177
2887
|
else if (a === "center") {
|
|
2178
2888
|
t.textAlign = "center";
|
|
2179
|
-
const
|
|
2180
|
-
y =
|
|
2889
|
+
const C = i + s / 2, v = t.measureText(p).width;
|
|
2890
|
+
y = C - v / 2, w = C + v / 2, t.fillText(p, C, m);
|
|
2181
2891
|
} else
|
|
2182
|
-
t.textAlign = "left", y = i, w = i + t.measureText(
|
|
2183
|
-
if (
|
|
2184
|
-
const
|
|
2185
|
-
if (t.strokeStyle = t.fillStyle, t.lineWidth = 1, t.beginPath(),
|
|
2186
|
-
const
|
|
2187
|
-
t.moveTo(y,
|
|
2892
|
+
t.textAlign = "left", y = i, w = i + t.measureText(p).width, t.fillText(p, i, m);
|
|
2893
|
+
if (d?.underline || d?.strike) {
|
|
2894
|
+
const C = t.strokeStyle, v = t.lineWidth;
|
|
2895
|
+
if (t.strokeStyle = t.fillStyle, t.lineWidth = 1, t.beginPath(), d.underline) {
|
|
2896
|
+
const b = m + 2;
|
|
2897
|
+
t.moveTo(y, b), t.lineTo(w, b);
|
|
2188
2898
|
}
|
|
2189
|
-
if (
|
|
2190
|
-
const
|
|
2191
|
-
t.moveTo(y,
|
|
2899
|
+
if (d.strike) {
|
|
2900
|
+
const b = m - Math.floor(this.lineHeight / 2) + 2;
|
|
2901
|
+
t.moveTo(y, b), t.lineTo(w, b);
|
|
2192
2902
|
}
|
|
2193
|
-
t.stroke(), t.strokeStyle =
|
|
2903
|
+
t.stroke(), t.strokeStyle = C, t.lineWidth = v;
|
|
2194
2904
|
}
|
|
2195
2905
|
};
|
|
2196
2906
|
if (r) {
|
|
2197
|
-
const
|
|
2198
|
-
for (let
|
|
2199
|
-
p
|
|
2907
|
+
const p = this.wrapLines(t, e, s);
|
|
2908
|
+
for (let h = 0; h < p.length; h += 1)
|
|
2909
|
+
g(p[h], h + 1);
|
|
2200
2910
|
} else {
|
|
2201
|
-
let
|
|
2202
|
-
for (; t.measureText(
|
|
2203
|
-
|
|
2204
|
-
p
|
|
2911
|
+
let p = e;
|
|
2912
|
+
for (; t.measureText(p).width > s && p.length > 1; )
|
|
2913
|
+
p = `${p.slice(0, -2)}…`;
|
|
2914
|
+
g(p, 1);
|
|
2205
2915
|
}
|
|
2206
2916
|
t.textAlign = "left", t.font = f, t.restore();
|
|
2207
2917
|
}
|
|
@@ -2218,52 +2928,56 @@ const O = class O {
|
|
|
2218
2928
|
if ((e.type === "date" || e.type === "time" || e.type === "datetime") && (t instanceof Date || typeof t == "string")) {
|
|
2219
2929
|
const i = e.type === "date" ? e.dateFormat ?? "yyyy-MM-dd" : e.type === "time" ? e.timeFormat ?? "HH:mm" : e.dateTimeFormat ?? "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
|
2220
2930
|
let n = null;
|
|
2221
|
-
return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text:
|
|
2931
|
+
return t instanceof Date ? n = t : n = this.valueFormatCache.parseIsoDate(t), n ? { text: Bt(n, i) } : { text: String(t) };
|
|
2222
2932
|
}
|
|
2223
2933
|
return { text: String(t) };
|
|
2224
2934
|
}
|
|
2225
2935
|
};
|
|
2226
|
-
|
|
2227
|
-
let
|
|
2228
|
-
class
|
|
2229
|
-
constructor(t, e, i, n, s, o, r, a,
|
|
2230
|
-
this.dataModel = r, this.onActiveChange =
|
|
2231
|
-
if (
|
|
2232
|
-
const
|
|
2233
|
-
|
|
2936
|
+
W.MAX_CANVAS_DIM_PX = 8192, W.ROW_HEIGHT_MEASURE_CHUNK = 500, W.ROW_HEIGHT_MEASURE_TIME_BUDGET_MS = 8, W.TEXT_MEASURE_CACHE_MAX = 2e3;
|
|
2937
|
+
let gt = W;
|
|
2938
|
+
class Ai {
|
|
2939
|
+
constructor(t, e, i, n, s, o, r, a, c, u, d, f, g, p) {
|
|
2940
|
+
this.dataModel = r, this.onActiveChange = u, this.onSelectionChange = f, this.onUndo = g, this.onRedo = p, 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.handleSelectionBlur = () => this.teardownSelectionInput(), this.handleRootKeydown = async (h) => {
|
|
2941
|
+
if (h.defaultPrevented || !this.selectionMode || this.inputEl || h.isComposing || this.composing || !(typeof navigator < "u" && /mac/i.test(navigator.platform) ? h.metaKey : h.ctrlKey)) return;
|
|
2942
|
+
const w = h.key.toLowerCase();
|
|
2943
|
+
w === "c" ? (h.preventDefault(), await this.copySelection()) : w === "x" && (h.preventDefault(), await this.copySelection(), this.clearSelectionValues());
|
|
2944
|
+
}, this.handlePointerDown = (h) => {
|
|
2945
|
+
if (h.button !== 0) return;
|
|
2946
|
+
const m = h.target;
|
|
2947
|
+
if (m?.closest('button[data-extable-fs-open="1"]') || m?.closest(".extable-filter-sort-trigger") || this.inputEl && h.target && this.inputEl.contains(h.target)) return;
|
|
2234
2948
|
if (this.inputEl && this.activeCell && this.activeCell.colKey !== null) {
|
|
2235
|
-
const { rowId: R, colKey:
|
|
2236
|
-
this.commitEdit(R,
|
|
2949
|
+
const { rowId: R, colKey: E } = this.activeCell, M = this.readActiveValue();
|
|
2950
|
+
this.commitEdit(R, E, M), this.onMove(R), this.teardownInput(!1);
|
|
2237
2951
|
}
|
|
2238
2952
|
if (this.fillDragging) return;
|
|
2239
|
-
const
|
|
2240
|
-
if (!
|
|
2241
|
-
const
|
|
2242
|
-
if (
|
|
2243
|
-
const R = this.dataModel.getSchema(),
|
|
2244
|
-
if (
|
|
2245
|
-
const
|
|
2246
|
-
if (
|
|
2953
|
+
const y = this.hitTest(h);
|
|
2954
|
+
if (!y || y.rowId === "__all__" && y.colKey === "__all__" || y.colKey === "__all__") return;
|
|
2955
|
+
const w = jt(this.dataModel, this.selectionRanges);
|
|
2956
|
+
if (w && this.activeCell) {
|
|
2957
|
+
const R = this.dataModel.getSchema(), E = this.dataModel.listRows(), M = w.endRowIndex, P = w.colIndex, H = E[M], D = R.columns[P];
|
|
2958
|
+
if (H && D) {
|
|
2959
|
+
const F = this.findHtmlCellElement(H.id, D.key)?.getBoundingClientRect() ?? this.computeCanvasCellRect(H.id, D.key);
|
|
2960
|
+
if (F && ft(
|
|
2247
2961
|
this.dataModel,
|
|
2248
2962
|
this.selectionRanges,
|
|
2249
2963
|
this.activeCell.rowId,
|
|
2250
2964
|
this.activeCell.colKey,
|
|
2251
2965
|
this.editMode
|
|
2252
2966
|
)) {
|
|
2253
|
-
const
|
|
2254
|
-
if (
|
|
2255
|
-
|
|
2967
|
+
const O = zt(F, Xt);
|
|
2968
|
+
if (Gt(h.clientX, h.clientY, O)) {
|
|
2969
|
+
h.preventDefault(), this.fillDragging = !0, this.fillSource = w, this.fillEndRowIndex = w.endRowIndex, this.root.dataset.extableFillDragging = "1", this.rootCursorBackup === null && (this.rootCursorBackup = this.root.style.cursor || ""), this.root.style.cursor = "crosshair", this.lastPointerClient = { x: h.clientX, y: h.clientY }, this.dragging = !1, this.dragStart = null, this.suppressNextClick = !0;
|
|
2256
2970
|
try {
|
|
2257
|
-
|
|
2971
|
+
h.target?.setPointerCapture?.(h.pointerId);
|
|
2258
2972
|
} catch {
|
|
2259
2973
|
}
|
|
2260
2974
|
this.selectionRanges = [
|
|
2261
2975
|
{
|
|
2262
2976
|
kind: "cells",
|
|
2263
|
-
startRow:
|
|
2264
|
-
endRow:
|
|
2265
|
-
startCol:
|
|
2266
|
-
endCol:
|
|
2977
|
+
startRow: w.startRowIndex,
|
|
2978
|
+
endRow: w.endRowIndex,
|
|
2979
|
+
startCol: w.colIndex,
|
|
2980
|
+
endCol: w.colIndex
|
|
2267
2981
|
}
|
|
2268
2982
|
], this.onSelectionChange(this.selectionRanges), this.startAutoScroll();
|
|
2269
2983
|
return;
|
|
@@ -2271,52 +2985,52 @@ class Se {
|
|
|
2271
2985
|
}
|
|
2272
2986
|
}
|
|
2273
2987
|
}
|
|
2274
|
-
const
|
|
2275
|
-
if (
|
|
2276
|
-
if (
|
|
2277
|
-
if (!
|
|
2988
|
+
const C = this.dataModel.getSchema(), v = this.dataModel.listRows(), b = y.rowId === "__header__" ? 0 : this.dataModel.getRowIndex(y.rowId), S = C.columns.findIndex((R) => String(R.key) === String(y.colKey));
|
|
2989
|
+
if (S < 0) return;
|
|
2990
|
+
if (y.rowId === "__header__") {
|
|
2991
|
+
if (!v.length) return;
|
|
2278
2992
|
const R = {
|
|
2279
2993
|
kind: "cells",
|
|
2280
2994
|
startRow: 0,
|
|
2281
|
-
endRow:
|
|
2282
|
-
startCol:
|
|
2283
|
-
endCol:
|
|
2995
|
+
endRow: v.length - 1,
|
|
2996
|
+
startCol: S,
|
|
2997
|
+
endCol: S
|
|
2284
2998
|
};
|
|
2285
|
-
this.selectionRanges = [R], this.onSelectionChange(this.selectionRanges), this.dragging = !1, this.selectionMode = !
|
|
2286
|
-
const
|
|
2287
|
-
|
|
2999
|
+
this.selectionRanges = [R], this.onSelectionChange(this.selectionRanges), this.dragging = !1, this.selectionMode = !0, this.dragStart = null, this.selectionAnchor = null, this.suppressNextClick = !1;
|
|
3000
|
+
const E = v[0], M = C.columns[S];
|
|
3001
|
+
E && M && (this.activeCell = { rowId: E.id, colKey: M.key }, this.onActiveChange(E.id, M.key)), this.focusSelectionInput("");
|
|
2288
3002
|
return;
|
|
2289
3003
|
}
|
|
2290
3004
|
if (b < 0) return;
|
|
2291
|
-
const
|
|
2292
|
-
this.dragging = !0, this.pointerDownClient = { x:
|
|
3005
|
+
const x = y.colKey === null ? "rows" : "cells";
|
|
3006
|
+
this.dragging = !0, this.pointerDownClient = { x: h.clientX, y: h.clientY }, this.dragMoved = !1, this.dragSelectionChanged = !1, this.dragStart = { rowIndex: b, colIndex: S, kind: x }, this.suppressNextClick = !1, this.selectionMode = !0, this.selectionAnchor = null, this.lastPointerClient = { x: h.clientX, y: h.clientY };
|
|
2293
3007
|
try {
|
|
2294
|
-
|
|
3008
|
+
h.target?.setPointerCapture?.(h.pointerId);
|
|
2295
3009
|
} catch {
|
|
2296
3010
|
}
|
|
2297
3011
|
this.startAutoScroll();
|
|
2298
|
-
}, this.handlePointerMove = (
|
|
2299
|
-
if (this.lastPointerClient = { x:
|
|
2300
|
-
this.updateFillDragFromClientPoint(
|
|
3012
|
+
}, this.handlePointerMove = (h) => {
|
|
3013
|
+
if (this.lastPointerClient = { x: h.clientX, y: h.clientY }, this.fillDragging && this.fillSource) {
|
|
3014
|
+
this.updateFillDragFromClientPoint(h.clientX, h.clientY);
|
|
2301
3015
|
return;
|
|
2302
3016
|
}
|
|
2303
3017
|
if (!(!this.dragging || !this.dragStart)) {
|
|
2304
3018
|
if (!this.dragMoved && this.pointerDownClient) {
|
|
2305
|
-
const m =
|
|
2306
|
-
if (m * m +
|
|
3019
|
+
const m = h.clientX - this.pointerDownClient.x, y = h.clientY - this.pointerDownClient.y;
|
|
3020
|
+
if (m * m + y * y < 9) return;
|
|
2307
3021
|
this.dragMoved = !0;
|
|
2308
3022
|
}
|
|
2309
|
-
this.updateDragFromClientPoint(
|
|
3023
|
+
this.updateDragFromClientPoint(h.clientX, h.clientY);
|
|
2310
3024
|
}
|
|
2311
|
-
}, this.handlePointerUp = (
|
|
3025
|
+
}, this.handlePointerUp = (h) => {
|
|
2312
3026
|
if (this.fillDragging && this.fillSource) {
|
|
2313
|
-
const
|
|
3027
|
+
const y = this.fillSource, w = this.fillEndRowIndex ?? y.endRowIndex;
|
|
2314
3028
|
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();
|
|
2315
3029
|
try {
|
|
2316
|
-
|
|
3030
|
+
h.target?.releasePointerCapture?.(h.pointerId);
|
|
2317
3031
|
} catch {
|
|
2318
3032
|
}
|
|
2319
|
-
this.commitFill(
|
|
3033
|
+
this.commitFill(y, w), this.suppressNextClick = !0;
|
|
2320
3034
|
return;
|
|
2321
3035
|
}
|
|
2322
3036
|
if (!this.dragging) return;
|
|
@@ -2324,48 +3038,48 @@ class Se {
|
|
|
2324
3038
|
const m = this.dragSelectionChanged;
|
|
2325
3039
|
this.pointerDownClient = null, this.dragMoved = !1, this.dragSelectionChanged = !1, this.stopAutoScroll();
|
|
2326
3040
|
try {
|
|
2327
|
-
|
|
3041
|
+
h.target?.releasePointerCapture?.(h.pointerId);
|
|
2328
3042
|
} catch {
|
|
2329
3043
|
}
|
|
2330
3044
|
if (m && (this.suppressNextClick = !0), this.suppressNextClick && this.activeCell && this.activeCell.colKey !== null) {
|
|
2331
|
-
const
|
|
2332
|
-
this.focusSelectionInput(this.cellToClipboardString(
|
|
3045
|
+
const y = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey);
|
|
3046
|
+
this.focusSelectionInput(this.cellToClipboardString(y));
|
|
2333
3047
|
}
|
|
2334
|
-
}, this.handleSelectionCopy = (
|
|
3048
|
+
}, this.handleSelectionCopy = (h) => {
|
|
2335
3049
|
if (!this.selectionMode) return;
|
|
2336
3050
|
const m = this.buildSelectionClipboardPayload();
|
|
2337
|
-
m && (
|
|
2338
|
-
}, this.handleSelectionCut = (
|
|
3051
|
+
m && (h.preventDefault(), h.clipboardData?.setData("text/plain", m.text), h.clipboardData?.setData("text/tab-separated-values", m.text), h.clipboardData?.setData("text/html", m.html), this.showCopyToast(`Copied ${m.cellCount} cells`, "info"));
|
|
3052
|
+
}, this.handleSelectionCut = (h) => {
|
|
2339
3053
|
if (!this.selectionMode) return;
|
|
2340
3054
|
const m = this.buildSelectionClipboardPayload();
|
|
2341
|
-
m && (
|
|
2342
|
-
}, this.handleSelectionPaste = (
|
|
3055
|
+
m && (h.preventDefault(), h.clipboardData?.setData("text/plain", m.text), h.clipboardData?.setData("text/tab-separated-values", m.text), h.clipboardData?.setData("text/html", m.html), this.clearSelectionValues());
|
|
3056
|
+
}, this.handleSelectionPaste = (h) => {
|
|
2343
3057
|
if (!this.selectionMode) return;
|
|
2344
|
-
|
|
2345
|
-
const m =
|
|
2346
|
-
|
|
3058
|
+
h.preventDefault();
|
|
3059
|
+
const m = h.clipboardData?.getData("text/html") ?? "", y = h.clipboardData?.getData("text/tab-separated-values") ?? "", w = h.clipboardData?.getData("text/plain") ?? "", C = this.parseClipboardGrid({ html: m, tsv: y, text: w });
|
|
3060
|
+
C && this.applyClipboardGrid(C);
|
|
2347
3061
|
}, this.handleSelectionCompositionStart = () => {
|
|
2348
3062
|
this.selectionMode && (this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell());
|
|
2349
|
-
}, this.handleSelectionKeydown = (
|
|
2350
|
-
if (!this.selectionMode || !this.activeCell ||
|
|
3063
|
+
}, this.handleSelectionKeydown = async (h) => {
|
|
3064
|
+
if (!this.selectionMode || !this.activeCell || h.isComposing || this.composing || h.key === "Shift" || h.key === "Control" || h.key === "Alt" || h.key === "Meta" || h.key === "CapsLock" || h.key === "NumLock" || h.key === "ScrollLock")
|
|
2351
3065
|
return;
|
|
2352
3066
|
const m = typeof navigator < "u" && /mac/i.test(navigator.platform);
|
|
2353
|
-
if (m ?
|
|
2354
|
-
const b =
|
|
3067
|
+
if (m ? h.metaKey : h.ctrlKey) {
|
|
3068
|
+
const b = h.key.toLowerCase();
|
|
2355
3069
|
if (b === "z") {
|
|
2356
|
-
|
|
3070
|
+
h.preventDefault(), m && h.shiftKey ? this.onRedo() : this.onUndo(), this.selectionAnchor = null;
|
|
2357
3071
|
return;
|
|
2358
3072
|
}
|
|
2359
3073
|
if (b === "y") {
|
|
2360
|
-
|
|
3074
|
+
h.preventDefault(), this.onRedo(), this.selectionAnchor = null;
|
|
2361
3075
|
return;
|
|
2362
3076
|
}
|
|
2363
3077
|
if (b === "c") {
|
|
2364
|
-
|
|
3078
|
+
h.preventDefault(), await this.copySelection(), this.selectionAnchor = null;
|
|
2365
3079
|
return;
|
|
2366
3080
|
}
|
|
2367
3081
|
if (b === "x") {
|
|
2368
|
-
|
|
3082
|
+
h.preventDefault(), await this.copySelection(), this.clearSelectionValues(), this.selectionAnchor = null;
|
|
2369
3083
|
return;
|
|
2370
3084
|
}
|
|
2371
3085
|
if (b === "v") {
|
|
@@ -2373,74 +3087,104 @@ class Se {
|
|
|
2373
3087
|
return;
|
|
2374
3088
|
}
|
|
2375
3089
|
}
|
|
2376
|
-
if (
|
|
2377
|
-
this.findColumn(this.activeCell.colKey)?.type === "boolean" && (
|
|
3090
|
+
if (h.key === " " && this.activeCell.colKey !== null) {
|
|
3091
|
+
this.findColumn(this.activeCell.colKey)?.type === "boolean" && (h.preventDefault(), this.toggleBoolean(this.activeCell.rowId, this.activeCell.colKey)), this.selectionAnchor = null;
|
|
2378
3092
|
return;
|
|
2379
3093
|
}
|
|
2380
|
-
const
|
|
2381
|
-
if (
|
|
2382
|
-
if (
|
|
2383
|
-
this.moveActiveCell(0,
|
|
3094
|
+
const w = h.key === "Tab", C = h.key === "Enter", v = h.key === "ArrowLeft" || h.key === "ArrowRight" || h.key === "ArrowUp" || h.key === "ArrowDown";
|
|
3095
|
+
if (w || C || v) {
|
|
3096
|
+
if (h.preventDefault(), this.teardownSelectionInput(), w) {
|
|
3097
|
+
this.moveActiveCell(0, h.shiftKey ? -1 : 1, !1);
|
|
2384
3098
|
return;
|
|
2385
3099
|
}
|
|
2386
|
-
if (
|
|
2387
|
-
this.moveActiveCell(
|
|
3100
|
+
if (C) {
|
|
3101
|
+
this.moveActiveCell(h.shiftKey ? -1 : 1, 0, !1);
|
|
2388
3102
|
return;
|
|
2389
3103
|
}
|
|
2390
|
-
const b =
|
|
2391
|
-
|
|
3104
|
+
const b = h.shiftKey;
|
|
3105
|
+
h.key === "ArrowLeft" ? this.moveActiveCell(0, -1, b) : h.key === "ArrowRight" ? this.moveActiveCell(0, 1, b) : h.key === "ArrowUp" ? this.moveActiveCell(-1, 0, b) : h.key === "ArrowDown" && this.moveActiveCell(1, 0, b);
|
|
2392
3106
|
return;
|
|
2393
3107
|
}
|
|
2394
3108
|
this.selectionMode = !1, this.selectionAnchor = null, this.teardownSelectionInput(), this.openEditorAtActiveCell();
|
|
2395
|
-
}, this.handleClick = (
|
|
2396
|
-
if (
|
|
3109
|
+
}, this.handleClick = (h) => {
|
|
3110
|
+
if (h.button !== 0 || h.target?.closest('button[data-extable-fs-open="1"]'))
|
|
2397
3111
|
return;
|
|
2398
3112
|
if (this.suppressNextClick) {
|
|
2399
3113
|
this.suppressNextClick = !1;
|
|
2400
3114
|
return;
|
|
2401
3115
|
}
|
|
2402
|
-
if (this.inputEl &&
|
|
3116
|
+
if (this.inputEl && h.target && this.inputEl.contains(h.target))
|
|
2403
3117
|
return;
|
|
2404
3118
|
if (this.inputEl && this.activeCell && this.activeCell.colKey !== null) {
|
|
2405
|
-
const { rowId:
|
|
2406
|
-
this.commitEdit(
|
|
3119
|
+
const { rowId: x, colKey: R } = this.activeCell, E = this.readActiveValue();
|
|
3120
|
+
this.commitEdit(x, R, E), this.onMove(x), this.teardownInput(!1);
|
|
2407
3121
|
}
|
|
2408
|
-
const
|
|
2409
|
-
if (!
|
|
2410
|
-
const
|
|
2411
|
-
if (
|
|
2412
|
-
this.
|
|
3122
|
+
const y = typeof document.elementFromPoint == "function" ? this.getHitAtClientPoint(h.clientX, h.clientY) : this.hitTest(h);
|
|
3123
|
+
if (!y) return;
|
|
3124
|
+
const w = this.selectionMode && !h.shiftKey && !h.metaKey && !h.ctrlKey && this.activeCell?.rowId === y.rowId && String(this.activeCell?.colKey) === String(y.colKey);
|
|
3125
|
+
if (y.rowId === "__all__" && y.colKey === "__all__") {
|
|
3126
|
+
const x = this.dataModel.getSchema(), R = this.dataModel.listRows();
|
|
3127
|
+
this.teardownInput(!1), R.length && x.columns.length ? (this.selectionRanges = [
|
|
3128
|
+
{
|
|
3129
|
+
kind: "cells",
|
|
3130
|
+
startRow: 0,
|
|
3131
|
+
endRow: R.length - 1,
|
|
3132
|
+
startCol: 0,
|
|
3133
|
+
endCol: x.columns.length - 1
|
|
3134
|
+
}
|
|
3135
|
+
], this.activeCell = { rowId: "__all__", colKey: "__all__" }, this.onActiveChange("__all__", "__all__"), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("")) : (this.activeCell = null, this.onActiveChange("__all__", "__all__"), this.selectionAnchor = null);
|
|
3136
|
+
return;
|
|
3137
|
+
}
|
|
3138
|
+
if (this.onRowSelect(y.rowId), y.rowId === "__header__") {
|
|
3139
|
+
const x = this.dataModel.getSchema(), R = this.dataModel.listRows(), E = x.columns.findIndex((M) => String(M.key) === String(y.colKey));
|
|
3140
|
+
R.length && E >= 0 && (this.selectionRanges = [
|
|
3141
|
+
{
|
|
3142
|
+
kind: "cells",
|
|
3143
|
+
startRow: 0,
|
|
3144
|
+
endRow: R.length - 1,
|
|
3145
|
+
startCol: E,
|
|
3146
|
+
endCol: E
|
|
3147
|
+
}
|
|
3148
|
+
], this.activeCell = { rowId: R[0].id, colKey: y.colKey }, this.onActiveChange(this.activeCell.rowId, this.activeCell.colKey), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput(""));
|
|
3149
|
+
return;
|
|
3150
|
+
}
|
|
3151
|
+
if (this.applySelectionFromHit(h, y), y.colKey === null || y.colKey === "__all__") {
|
|
3152
|
+
this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("");
|
|
2413
3153
|
return;
|
|
2414
3154
|
}
|
|
2415
|
-
if (
|
|
3155
|
+
if (y.rowId === "__header__") {
|
|
3156
|
+
this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("");
|
|
2416
3157
|
return;
|
|
2417
|
-
|
|
2418
|
-
|
|
3158
|
+
}
|
|
3159
|
+
if (this.isCellReadonly(y.rowId, y.colKey)) {
|
|
3160
|
+
this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1);
|
|
3161
|
+
const x = this.dataModel.getCell(y.rowId, y.colKey);
|
|
3162
|
+
this.focusSelectionInput(this.cellToClipboardString(x));
|
|
2419
3163
|
return;
|
|
2420
3164
|
}
|
|
2421
|
-
if (this.findColumn(
|
|
2422
|
-
const
|
|
2423
|
-
if (this.lastBooleanCell = { rowId:
|
|
2424
|
-
this.toggleBoolean(
|
|
3165
|
+
if (this.findColumn(y.colKey)?.type === "boolean") {
|
|
3166
|
+
const x = this.lastBooleanCell?.rowId === y.rowId && String(this.lastBooleanCell?.colKey) === String(y.colKey);
|
|
3167
|
+
if (this.lastBooleanCell = { rowId: y.rowId, colKey: y.colKey }, this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1), this.teardownSelectionInput(), x) {
|
|
3168
|
+
this.toggleBoolean(y.rowId, y.colKey), this.focusSelectionInput("");
|
|
2425
3169
|
return;
|
|
2426
3170
|
}
|
|
2427
3171
|
this.focusSelectionInput("");
|
|
2428
3172
|
return;
|
|
2429
3173
|
}
|
|
2430
3174
|
this.lastBooleanCell = null, this.selectionAnchor = null, this.teardownInput(!1);
|
|
2431
|
-
const b = this.dataModel.getCell(
|
|
2432
|
-
this.focusSelectionInput(
|
|
2433
|
-
}, this.handleContextMenu = (
|
|
2434
|
-
const m =
|
|
2435
|
-
if (
|
|
2436
|
-
|
|
3175
|
+
const b = this.dataModel.getCell(y.rowId, y.colKey), S = this.cellToClipboardString(b);
|
|
3176
|
+
this.focusSelectionInput(S), w && (this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell());
|
|
3177
|
+
}, this.handleContextMenu = (h) => {
|
|
3178
|
+
const m = h.target;
|
|
3179
|
+
if (h.ctrlKey) {
|
|
3180
|
+
h.preventDefault();
|
|
2437
3181
|
return;
|
|
2438
3182
|
}
|
|
2439
3183
|
if (!m || !this.root.contains(m)) return;
|
|
2440
|
-
|
|
2441
|
-
const
|
|
2442
|
-
this.onContextMenu(
|
|
2443
|
-
}, this.root = t, this.editMode = e, this.onEdit = i, this.onRowSelect = n, this.onMove = s, this.hitTest = o, this.
|
|
3184
|
+
h.preventDefault(), h.stopPropagation();
|
|
3185
|
+
const y = this.hitTest(h), w = y?.rowId ?? null, C = y?.colKey ?? null;
|
|
3186
|
+
this.onContextMenu(w, C, h.clientX, h.clientY);
|
|
3187
|
+
}, this.root = t, this.editMode = e, this.onEdit = i, this.onRowSelect = n, this.onMove = s, this.hitTest = o, this.sequenceLangs = a, this.isCellReadonly = c, this.onContextMenu = d, this.bind();
|
|
2444
3188
|
}
|
|
2445
3189
|
setEditMode(t) {
|
|
2446
3190
|
this.editMode = t;
|
|
@@ -2465,37 +3209,37 @@ class Se {
|
|
|
2465
3209
|
}
|
|
2466
3210
|
], w = !0;
|
|
2467
3211
|
else {
|
|
2468
|
-
const
|
|
2469
|
-
const
|
|
2470
|
-
...
|
|
2471
|
-
startRow:
|
|
2472
|
-
endRow:
|
|
2473
|
-
startCol:
|
|
2474
|
-
endCol:
|
|
3212
|
+
const C = this.selectionRanges.map((v) => {
|
|
3213
|
+
const b = (x, R) => Math.max(0, Math.min(R, x)), S = {
|
|
3214
|
+
...v,
|
|
3215
|
+
startRow: b(v.startRow, i),
|
|
3216
|
+
endRow: b(v.endRow, i),
|
|
3217
|
+
startCol: b(v.startCol, n),
|
|
3218
|
+
endCol: b(v.endCol, n)
|
|
2475
3219
|
};
|
|
2476
|
-
return (
|
|
3220
|
+
return (S.startRow !== v.startRow || S.endRow !== v.endRow || S.startCol !== v.startCol || S.endCol !== v.endCol) && (w = !0), S;
|
|
2477
3221
|
});
|
|
2478
|
-
this.selectionRanges =
|
|
3222
|
+
this.selectionRanges = C;
|
|
2479
3223
|
}
|
|
2480
3224
|
w && this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
|
|
2481
3225
|
return;
|
|
2482
3226
|
}
|
|
2483
|
-
const
|
|
2484
|
-
let
|
|
2485
|
-
|
|
2486
|
-
const
|
|
2487
|
-
if (!
|
|
2488
|
-
const
|
|
3227
|
+
const c = o ?? t.columns[0]?.key ?? "";
|
|
3228
|
+
let u = t.columns.findIndex((w) => String(w.key) === String(c));
|
|
3229
|
+
u < 0 && (u = 0);
|
|
3230
|
+
const d = t.columns[u]?.key ?? "", f = s ? this.dataModel.getBaseRowIndex(s) : 0, g = e[e.length - 1] ?? e[0] ?? null, p = e.find((w) => this.dataModel.getBaseRowIndex(w.id) >= f) ?? g;
|
|
3231
|
+
if (!p) return;
|
|
3232
|
+
const h = p.id, m = this.dataModel.getRowIndex(h);
|
|
2489
3233
|
this.selectionAnchor = null, this.lastBooleanCell = null, this.teardownInput(!1), this.selectionRanges = [
|
|
2490
3234
|
{
|
|
2491
3235
|
kind: "cells",
|
|
2492
|
-
startRow:
|
|
2493
|
-
endRow:
|
|
2494
|
-
startCol:
|
|
2495
|
-
endCol:
|
|
3236
|
+
startRow: m,
|
|
3237
|
+
endRow: m,
|
|
3238
|
+
startCol: u,
|
|
3239
|
+
endCol: u
|
|
2496
3240
|
}
|
|
2497
|
-
], this.activeCell = { rowId:
|
|
2498
|
-
const y = this.dataModel.getCell(
|
|
3241
|
+
], this.activeCell = { rowId: h, colKey: d }, this.onActiveChange(h, d), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(h, d);
|
|
3242
|
+
const y = this.dataModel.getCell(h, d);
|
|
2499
3243
|
this.focusSelectionInput(this.cellToClipboardString(y)), this.updateFillHandleFlag();
|
|
2500
3244
|
}
|
|
2501
3245
|
navigateToCell(t, e) {
|
|
@@ -2517,17 +3261,17 @@ class Se {
|
|
|
2517
3261
|
this.teardownInput(!0);
|
|
2518
3262
|
}
|
|
2519
3263
|
destroy() {
|
|
2520
|
-
this.root.removeEventListener("click", this.handleClick), this.root.removeEventListener("pointerdown", this.handlePointerDown), this.root.removeEventListener("pointermove", this.handlePointerMove), this.root.removeEventListener("pointerup", this.handlePointerUp), this.root.removeEventListener("pointercancel", this.handlePointerUp), this.handleDocumentContextMenu && document.removeEventListener("contextmenu", this.handleDocumentContextMenu, !0), this.teardownInput(!0), this.teardownSelectionInput(), this.teardownCopyToast(), this.stopAutoScroll();
|
|
3264
|
+
this.root.removeEventListener("click", this.handleClick), this.root.removeEventListener("pointerdown", this.handlePointerDown), this.root.removeEventListener("pointermove", this.handlePointerMove), this.root.removeEventListener("pointerup", this.handlePointerUp), this.root.removeEventListener("pointercancel", this.handlePointerUp), this.root.removeEventListener("keydown", this.handleRootKeydown), this.handleDocumentContextMenu && document.removeEventListener("contextmenu", this.handleDocumentContextMenu, !0), this.teardownInput(!0), this.teardownSelectionInput(), this.teardownCopyToast(), this.stopAutoScroll();
|
|
2521
3265
|
}
|
|
2522
3266
|
onScroll(t, e) {
|
|
2523
3267
|
this.positionCopyToast();
|
|
2524
3268
|
}
|
|
2525
3269
|
bind() {
|
|
2526
|
-
this.root.addEventListener("click", this.handleClick), this.root.addEventListener("pointerdown", this.handlePointerDown), this.root.addEventListener("pointermove", this.handlePointerMove), this.root.addEventListener("pointerup", this.handlePointerUp), this.root.addEventListener("pointercancel", this.handlePointerUp), this.handleDocumentContextMenu = (t) => this.handleContextMenu(t), document.addEventListener("contextmenu", this.handleDocumentContextMenu, { capture: !0 });
|
|
3270
|
+
this.root.addEventListener("click", this.handleClick), this.root.addEventListener("pointerdown", this.handlePointerDown), this.root.addEventListener("pointermove", this.handlePointerMove), this.root.addEventListener("pointerup", this.handlePointerUp), this.root.addEventListener("pointercancel", this.handlePointerUp), this.root.addEventListener("keydown", this.handleRootKeydown), this.handleDocumentContextMenu = (t) => this.handleContextMenu(t), document.addEventListener("contextmenu", this.handleDocumentContextMenu, { capture: !0 });
|
|
2527
3271
|
}
|
|
2528
3272
|
updateFillHandleFlag() {
|
|
2529
3273
|
const t = this.activeCell?.colKey ?? null, e = this.activeCell?.rowId ?? null;
|
|
2530
|
-
this.root.dataset.extableFillHandle =
|
|
3274
|
+
this.root.dataset.extableFillHandle = ft(
|
|
2531
3275
|
this.dataModel,
|
|
2532
3276
|
this.selectionRanges,
|
|
2533
3277
|
e,
|
|
@@ -2576,20 +3320,25 @@ class Se {
|
|
|
2576
3320
|
if (this.copyToastEl) return this.copyToastEl;
|
|
2577
3321
|
window.getComputedStyle(this.root).position === "static" && (this.root.style.position = "relative");
|
|
2578
3322
|
const e = document.createElement("div");
|
|
2579
|
-
return e.className = "extable-toast", e.dataset.extableCopyToast = "1", e.
|
|
3323
|
+
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;
|
|
2580
3324
|
}
|
|
2581
3325
|
teardownCopyToast() {
|
|
2582
|
-
this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastEl && (this.copyToastEl.
|
|
3326
|
+
this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastEl && (this.copyToastEl.style.display = "none", _(this.copyToastEl), this.copyToastEl = null);
|
|
2583
3327
|
}
|
|
2584
3328
|
positionCopyToast() {
|
|
2585
3329
|
if (!this.copyToastEl) return;
|
|
2586
|
-
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);
|
|
3330
|
+
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), r = Math.max(0, this.root.scrollTop + i), a = this.root.getBoundingClientRect(), c = this.getActiveCellRect();
|
|
3331
|
+
if (c) {
|
|
3332
|
+
const u = c.right - a.left + this.root.scrollLeft - t + 8, d = c.top - a.top + this.root.scrollTop - e + 8, f = Math.min(n, Math.max(o, u)), g = Math.min(s, Math.max(r, d));
|
|
3333
|
+
this.copyToastEl.style.left = `${f}px`, this.copyToastEl.style.top = `${g}px`;
|
|
3334
|
+
return;
|
|
3335
|
+
}
|
|
2587
3336
|
this.copyToastEl.style.left = `${n}px`, this.copyToastEl.style.top = `${s}px`;
|
|
2588
3337
|
}
|
|
2589
3338
|
showCopyToast(t, e = "info", i = 1200) {
|
|
2590
3339
|
const n = this.ensureCopyToast();
|
|
2591
|
-
n.textContent = t, n.dataset.variant = e, n.
|
|
2592
|
-
n.
|
|
3340
|
+
n.textContent = t, n.dataset.variant = e, n.style.display = "block", this.positionCopyToast(), this.copyToastTimer && (window.clearTimeout(this.copyToastTimer), this.copyToastTimer = null), this.copyToastTimer = window.setTimeout(() => {
|
|
3341
|
+
n.style.display = "none";
|
|
2593
3342
|
}, i);
|
|
2594
3343
|
}
|
|
2595
3344
|
ensureSelectionInput() {
|
|
@@ -2642,20 +3391,66 @@ class Se {
|
|
|
2642
3391
|
) ? this.getCanvasCellMetrics(t, e) : null;
|
|
2643
3392
|
}
|
|
2644
3393
|
getCanvasCellMetrics(t, e) {
|
|
2645
|
-
const i = this.dataModel.getSchema(), n = this.dataModel.getView(), s = this.dataModel.listRows(), o = s.findIndex((
|
|
3394
|
+
const i = this.dataModel.getSchema(), n = this.dataModel.getView(), s = this.dataModel.listRows(), o = s.findIndex((m) => m.id === t), r = i.columns.findIndex((m) => String(m.key) === String(e));
|
|
2646
3395
|
if (o < 0 || r < 0) return null;
|
|
2647
|
-
const a =
|
|
2648
|
-
let f =
|
|
2649
|
-
for (let
|
|
2650
|
-
let
|
|
2651
|
-
for (let
|
|
2652
|
-
const y = s[
|
|
3396
|
+
const a = nt, c = Y, u = st, d = X(i, n);
|
|
3397
|
+
let f = c;
|
|
3398
|
+
for (let m = 0; m < r; m += 1) f += d[m] ?? 100;
|
|
3399
|
+
let g = a;
|
|
3400
|
+
for (let m = 0; m < o; m += 1) {
|
|
3401
|
+
const y = s[m];
|
|
2653
3402
|
if (!y) return null;
|
|
2654
|
-
const w = this.dataModel.getRowHeight(y.id) ??
|
|
2655
|
-
|
|
3403
|
+
const w = this.dataModel.getRowHeight(y.id) ?? u;
|
|
3404
|
+
g += w;
|
|
3405
|
+
}
|
|
3406
|
+
const p = this.dataModel.getRowHeight(t) ?? u, h = d[r] ?? 100;
|
|
3407
|
+
return { left: f, top: g, width: h, height: p, rowIndex: o, colIndex: r };
|
|
3408
|
+
}
|
|
3409
|
+
getActiveCellRect() {
|
|
3410
|
+
const t = this.activeCell;
|
|
3411
|
+
if (!t) return null;
|
|
3412
|
+
const e = this.root.getBoundingClientRect(), i = this.dataModel.getSchema(), n = this.dataModel.getView();
|
|
3413
|
+
if (t.rowId === "__all__" && t.colKey === "__all__")
|
|
3414
|
+
return new DOMRect(e.left, e.top, Y, nt);
|
|
3415
|
+
if (t.rowId === "__header__" && t.colKey !== null) {
|
|
3416
|
+
const o = this.escapeCssAttrValue(String(t.colKey)), r = this.root.querySelector(`th[data-col-key="${o}"]`);
|
|
3417
|
+
if (r) return r.getBoundingClientRect();
|
|
3418
|
+
const a = i.columns.findIndex((c) => String(c.key) === String(t.colKey));
|
|
3419
|
+
if (a >= 0) {
|
|
3420
|
+
const c = X(i, n);
|
|
3421
|
+
let u = Y;
|
|
3422
|
+
for (let f = 0; f < a; f += 1) u += c[f] ?? 100;
|
|
3423
|
+
const d = c[a] ?? 100;
|
|
3424
|
+
return new DOMRect(
|
|
3425
|
+
e.left + u - this.root.scrollLeft,
|
|
3426
|
+
e.top,
|
|
3427
|
+
d,
|
|
3428
|
+
nt
|
|
3429
|
+
);
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
if (t.colKey === null) {
|
|
3433
|
+
const o = this.dataModel.getRowIndex(t.rowId);
|
|
3434
|
+
if (o >= 0) {
|
|
3435
|
+
let r = nt;
|
|
3436
|
+
const a = this.dataModel.listRows();
|
|
3437
|
+
for (let u = 0; u < o; u += 1) {
|
|
3438
|
+
const d = a[u];
|
|
3439
|
+
if (!d) break;
|
|
3440
|
+
r += this.dataModel.getRowHeight(d.id) ?? st;
|
|
3441
|
+
}
|
|
3442
|
+
const c = this.dataModel.getRowHeight(t.rowId) ?? st;
|
|
3443
|
+
return new DOMRect(
|
|
3444
|
+
e.left,
|
|
3445
|
+
e.top + r - this.root.scrollTop,
|
|
3446
|
+
Y,
|
|
3447
|
+
c
|
|
3448
|
+
);
|
|
3449
|
+
}
|
|
2656
3450
|
}
|
|
2657
|
-
|
|
2658
|
-
|
|
3451
|
+
if (t.colKey === null) return null;
|
|
3452
|
+
const s = this.findHtmlCellElement(t.rowId, t.colKey);
|
|
3453
|
+
return s ? s.getBoundingClientRect() : this.computeCanvasCellRect(t.rowId, t.colKey);
|
|
2659
3454
|
}
|
|
2660
3455
|
ensureVisibleCell(t, e) {
|
|
2661
3456
|
const i = this.findHtmlCellElement(t, e);
|
|
@@ -2665,8 +3460,8 @@ class Se {
|
|
|
2665
3460
|
}
|
|
2666
3461
|
const n = this.getCanvasCellMetrics(t, e);
|
|
2667
3462
|
if (!n) return;
|
|
2668
|
-
const s = n.left, o = n.left + n.width, r = n.top, a = n.top + n.height,
|
|
2669
|
-
s <
|
|
3463
|
+
const s = n.left, o = n.left + n.width, r = n.top, a = n.top + n.height, c = this.root.scrollLeft, u = this.root.scrollLeft + this.root.clientWidth, d = this.root.scrollTop, f = this.root.scrollTop + this.root.clientHeight;
|
|
3464
|
+
s < c ? this.root.scrollLeft = Math.max(0, s) : o > u && (this.root.scrollLeft = Math.max(0, o - this.root.clientWidth)), r < d ? this.root.scrollTop = Math.max(0, r) : a > f && (this.root.scrollTop = Math.max(0, a - this.root.clientHeight));
|
|
2670
3465
|
}
|
|
2671
3466
|
moveActiveCell(t, e, i = !1) {
|
|
2672
3467
|
const n = this.dataModel.getSchema(), s = this.dataModel.listRows();
|
|
@@ -2675,27 +3470,27 @@ class Se {
|
|
|
2675
3470
|
i || (this.selectionAnchor = null);
|
|
2676
3471
|
const a = i && this.selectionAnchor ? this.selectionAnchor : i ? { rowIndex: o, colIndex: r } : null;
|
|
2677
3472
|
i && !this.selectionAnchor && (this.selectionAnchor = { rowIndex: o, colIndex: r });
|
|
2678
|
-
const
|
|
3473
|
+
const c = Math.max(0, Math.min(s.length - 1, o + t)), u = Math.max(0, Math.min(n.columns.length - 1, r + e));
|
|
2679
3474
|
{
|
|
2680
|
-
const
|
|
2681
|
-
if (!
|
|
2682
|
-
const f = n.columns[
|
|
3475
|
+
const d = s[c];
|
|
3476
|
+
if (!d) return;
|
|
3477
|
+
const f = n.columns[u];
|
|
2683
3478
|
if (!f) return;
|
|
2684
|
-
const
|
|
3479
|
+
const g = d.id, p = f.key, h = a ? {
|
|
2685
3480
|
kind: "cells",
|
|
2686
3481
|
startRow: a.rowIndex,
|
|
2687
|
-
endRow:
|
|
3482
|
+
endRow: c,
|
|
2688
3483
|
startCol: a.colIndex,
|
|
2689
|
-
endCol:
|
|
3484
|
+
endCol: u
|
|
2690
3485
|
} : {
|
|
2691
3486
|
kind: "cells",
|
|
2692
|
-
startRow:
|
|
2693
|
-
endRow:
|
|
2694
|
-
startCol:
|
|
2695
|
-
endCol:
|
|
3487
|
+
startRow: c,
|
|
3488
|
+
endRow: c,
|
|
3489
|
+
startCol: u,
|
|
3490
|
+
endCol: u
|
|
2696
3491
|
};
|
|
2697
|
-
this.selectionRanges = [
|
|
2698
|
-
const
|
|
3492
|
+
this.selectionRanges = [h], this.activeCell = { rowId: g, colKey: p }, this.onActiveChange(g, p), this.onSelectionChange(this.selectionRanges), this.ensureVisibleCell(g, p);
|
|
3493
|
+
const m = this.dataModel.getCell(g, p), y = this.cellToClipboardString(m);
|
|
2699
3494
|
this.focusSelectionInput(y), this.updateFillHandleFlag();
|
|
2700
3495
|
return;
|
|
2701
3496
|
}
|
|
@@ -2714,10 +3509,10 @@ class Se {
|
|
|
2714
3509
|
};
|
|
2715
3510
|
const s = i.closest("th.extable-row-header:not(.extable-corner)");
|
|
2716
3511
|
if (s) {
|
|
2717
|
-
const
|
|
2718
|
-
if (
|
|
3512
|
+
const c = s.closest("tr[data-row-id]");
|
|
3513
|
+
if (c)
|
|
2719
3514
|
return {
|
|
2720
|
-
rowId:
|
|
3515
|
+
rowId: c.dataset.rowId ?? "",
|
|
2721
3516
|
colKey: null,
|
|
2722
3517
|
element: s,
|
|
2723
3518
|
rect: s.getBoundingClientRect()
|
|
@@ -2749,34 +3544,34 @@ class Se {
|
|
|
2749
3544
|
return;
|
|
2750
3545
|
const n = this.dataModel.getSchema(), s = this.dataModel.listRows(), o = this.dataModel.getRowIndex(i.rowId);
|
|
2751
3546
|
if (o < 0) return;
|
|
2752
|
-
const r = this.dragStart.kind === "rows" ? n.columns.length - 1 : n.columns.findIndex((
|
|
3547
|
+
const r = this.dragStart.kind === "rows" ? n.columns.length - 1 : n.columns.findIndex((p) => String(p.key) === String(i.colKey));
|
|
2753
3548
|
if (r < 0) return;
|
|
2754
|
-
const a = this.dragStart.rowIndex,
|
|
2755
|
-
(o !== a ||
|
|
2756
|
-
const
|
|
3549
|
+
const a = this.dragStart.rowIndex, c = this.dragStart.kind === "rows" ? 0 : this.dragStart.colIndex, u = this.dragStart.kind === "rows" ? n.columns.length - 1 : r;
|
|
3550
|
+
(o !== a || u !== c) && (this.dragSelectionChanged = !0);
|
|
3551
|
+
const d = {
|
|
2757
3552
|
kind: this.dragStart.kind,
|
|
2758
3553
|
startRow: a,
|
|
2759
3554
|
endRow: o,
|
|
2760
|
-
startCol:
|
|
2761
|
-
endCol:
|
|
3555
|
+
startCol: c,
|
|
3556
|
+
endCol: u
|
|
2762
3557
|
};
|
|
2763
|
-
this.selectionRanges = [
|
|
2764
|
-
const f = s[o]?.id ?? i.rowId,
|
|
2765
|
-
this.activeCell = { rowId: f, colKey:
|
|
3558
|
+
this.selectionRanges = [d];
|
|
3559
|
+
const f = s[o]?.id ?? i.rowId, g = this.dragStart.kind === "rows" ? n.columns[0]?.key ?? i.colKey : n.columns[r]?.key ?? i.colKey;
|
|
3560
|
+
this.activeCell = { rowId: f, colKey: g }, this.onActiveChange(f, g), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag();
|
|
2766
3561
|
}
|
|
2767
3562
|
updateFillDragFromClientPoint(t, e) {
|
|
2768
3563
|
if (!this.fillDragging || !this.fillSource) return;
|
|
2769
3564
|
const i = this.getHitAtClientPoint(t, e);
|
|
2770
3565
|
if (!i || i.colKey === "__all__" || i.colKey === null) return;
|
|
2771
3566
|
const n = this.dataModel.getSchema(), s = this.dataModel.listRows(), o = this.dataModel.getRowIndex(i.rowId);
|
|
2772
|
-
if (o < 0 || n.columns.findIndex((
|
|
3567
|
+
if (o < 0 || n.columns.findIndex((c) => String(c.key) === String(i.colKey)) !== this.fillSource.colIndex) return;
|
|
2773
3568
|
const a = Math.max(this.fillSource.endRowIndex, o);
|
|
2774
3569
|
if (this.fillEndRowIndex !== a) {
|
|
2775
3570
|
this.fillEndRowIndex = a;
|
|
2776
|
-
const
|
|
2777
|
-
if (!
|
|
2778
|
-
const
|
|
2779
|
-
this.activeCell = { rowId:
|
|
3571
|
+
const c = s[a]?.id ?? i.rowId, u = n.columns[this.fillSource.colIndex];
|
|
3572
|
+
if (!u) return;
|
|
3573
|
+
const d = u.key;
|
|
3574
|
+
this.activeCell = { rowId: c, colKey: d }, this.onActiveChange(c, d), this.selectionRanges = [
|
|
2780
3575
|
{
|
|
2781
3576
|
kind: "cells",
|
|
2782
3577
|
startRow: this.fillSource.startRowIndex,
|
|
@@ -2819,24 +3614,24 @@ class Se {
|
|
|
2819
3614
|
commitFill(t, e) {
|
|
2820
3615
|
const i = this.dataModel.getSchema(), n = this.dataModel.listRows(), s = i.columns[t.colIndex];
|
|
2821
3616
|
if (!s || e <= t.endRowIndex) return;
|
|
2822
|
-
const o =
|
|
3617
|
+
const o = xi(this.dataModel, t, this.sequenceLangs);
|
|
2823
3618
|
if (!o) return;
|
|
2824
3619
|
const r = this.editMode === "direct", a = `fill:${Date.now()}:${Math.random().toString(16).slice(2)}`;
|
|
2825
|
-
for (let
|
|
2826
|
-
const f = n[
|
|
3620
|
+
for (let d = t.endRowIndex + 1; d <= e; d += 1) {
|
|
3621
|
+
const f = n[d];
|
|
2827
3622
|
if (!f) break;
|
|
2828
3623
|
if (this.isCellReadonly(f.id, s.key)) continue;
|
|
2829
|
-
const
|
|
3624
|
+
const g = d - t.endRowIndex, p = o(g), h = {
|
|
2830
3625
|
kind: "edit",
|
|
2831
3626
|
rowId: f.id,
|
|
2832
3627
|
colKey: s.key,
|
|
2833
|
-
next:
|
|
3628
|
+
next: p,
|
|
2834
3629
|
payload: { batchId: a }
|
|
2835
3630
|
};
|
|
2836
|
-
this.onEdit(
|
|
3631
|
+
this.onEdit(h, r);
|
|
2837
3632
|
}
|
|
2838
|
-
const
|
|
2839
|
-
if (!
|
|
3633
|
+
const c = n[e];
|
|
3634
|
+
if (!c) return;
|
|
2840
3635
|
this.selectionRanges = [
|
|
2841
3636
|
{
|
|
2842
3637
|
kind: "cells",
|
|
@@ -2845,9 +3640,9 @@ class Se {
|
|
|
2845
3640
|
startCol: t.colIndex,
|
|
2846
3641
|
endCol: t.colIndex
|
|
2847
3642
|
}
|
|
2848
|
-
], this.activeCell = { rowId:
|
|
2849
|
-
const
|
|
2850
|
-
this.focusSelectionInput(this.cellToClipboardString(
|
|
3643
|
+
], 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);
|
|
3644
|
+
const u = this.dataModel.getCell(c.id, s.key);
|
|
3645
|
+
this.focusSelectionInput(this.cellToClipboardString(u));
|
|
2851
3646
|
}
|
|
2852
3647
|
teardownSelectionInput() {
|
|
2853
3648
|
const t = this.selectionInput;
|
|
@@ -2874,8 +3669,8 @@ class Se {
|
|
|
2874
3669
|
}
|
|
2875
3670
|
return !1;
|
|
2876
3671
|
}, o = () => {
|
|
2877
|
-
const a = this.ensureSelectionInput(),
|
|
2878
|
-
a.value = e, a.select(), document.execCommand?.("copy"), a.value =
|
|
3672
|
+
const a = this.ensureSelectionInput(), c = a.value;
|
|
3673
|
+
a.value = e, a.select(), document.execCommand?.("copy"), a.value = c;
|
|
2879
3674
|
};
|
|
2880
3675
|
await s() || o(), this.showCopyToast(`Copied ${n} cells`, "info");
|
|
2881
3676
|
}
|
|
@@ -2909,7 +3704,15 @@ class Se {
|
|
|
2909
3704
|
const t = this.dataModel.getSchema();
|
|
2910
3705
|
if (this.selectionRanges.length > 0) {
|
|
2911
3706
|
const s = this.selectionRanges[0];
|
|
2912
|
-
|
|
3707
|
+
if (!s) return null;
|
|
3708
|
+
const o = this.normalizeRange(s);
|
|
3709
|
+
return o.kind === "rows" ? {
|
|
3710
|
+
kind: "cells",
|
|
3711
|
+
startRow: o.startRow,
|
|
3712
|
+
endRow: o.endRow,
|
|
3713
|
+
startCol: o.startCol,
|
|
3714
|
+
endCol: o.endCol
|
|
3715
|
+
} : o;
|
|
2913
3716
|
}
|
|
2914
3717
|
if (!this.activeCell) return null;
|
|
2915
3718
|
const e = this.activeCell;
|
|
@@ -2938,21 +3741,21 @@ class Se {
|
|
|
2938
3741
|
if (!i || i.kind !== "cells") return null;
|
|
2939
3742
|
const n = [], s = [], o = "border-collapse:collapse;border-spacing:0;", r = "border:1px solid #d0d7de;padding:4px 6px;vertical-align:top;";
|
|
2940
3743
|
let a = 0;
|
|
2941
|
-
for (let
|
|
2942
|
-
const f = e[
|
|
3744
|
+
for (let d = i.startRow; d <= i.endRow; d += 1) {
|
|
3745
|
+
const f = e[d];
|
|
2943
3746
|
if (!f) continue;
|
|
2944
|
-
const
|
|
2945
|
-
for (let
|
|
2946
|
-
const
|
|
2947
|
-
if (!
|
|
2948
|
-
const y = this.dataModel.getCell(f.id,
|
|
2949
|
-
|
|
3747
|
+
const g = [], p = [];
|
|
3748
|
+
for (let h = i.startCol; h <= i.endCol; h += 1) {
|
|
3749
|
+
const m = t.columns[h];
|
|
3750
|
+
if (!m) continue;
|
|
3751
|
+
const y = this.dataModel.getCell(f.id, m.key), w = this.cellToClipboardString(y);
|
|
3752
|
+
g.push(w), p.push(`<td style="${r}">${this.escapeHtml(w)}</td>`), a += 1;
|
|
2950
3753
|
}
|
|
2951
|
-
n.push(
|
|
3754
|
+
n.push(g.join(" ")), s.push(`<tr>${p.join("")}</tr>`);
|
|
2952
3755
|
}
|
|
2953
|
-
const
|
|
2954
|
-
`),
|
|
2955
|
-
return { text:
|
|
3756
|
+
const c = n.join(`\r
|
|
3757
|
+
`), u = `<table style="${o}"><tbody>${s.join("")}</tbody></table>`;
|
|
3758
|
+
return { text: c, html: u, cellCount: a };
|
|
2956
3759
|
}
|
|
2957
3760
|
clearSelectionValues() {
|
|
2958
3761
|
const t = this.dataModel.getSchema(), e = this.dataModel.listRows(), i = this.getCopyRange();
|
|
@@ -2962,16 +3765,16 @@ class Se {
|
|
|
2962
3765
|
const r = e[o];
|
|
2963
3766
|
if (r)
|
|
2964
3767
|
for (let a = i.startCol; a <= i.endCol; a += 1) {
|
|
2965
|
-
const
|
|
2966
|
-
if (!
|
|
2967
|
-
const
|
|
3768
|
+
const c = t.columns[a];
|
|
3769
|
+
if (!c || this.isCellReadonly(r.id, c.key)) continue;
|
|
3770
|
+
const u = c.type === "boolean" ? !1 : "", d = {
|
|
2968
3771
|
kind: "edit",
|
|
2969
3772
|
rowId: r.id,
|
|
2970
|
-
colKey:
|
|
2971
|
-
next:
|
|
3773
|
+
colKey: c.key,
|
|
3774
|
+
next: u,
|
|
2972
3775
|
payload: { batchId: s }
|
|
2973
3776
|
};
|
|
2974
|
-
this.onEdit(
|
|
3777
|
+
this.onEdit(d, n);
|
|
2975
3778
|
}
|
|
2976
3779
|
}
|
|
2977
3780
|
}
|
|
@@ -2996,10 +3799,10 @@ class Se {
|
|
|
2996
3799
|
for (const r of s) {
|
|
2997
3800
|
const a = Array.from(r.querySelectorAll("th,td"));
|
|
2998
3801
|
if (a.some(
|
|
2999
|
-
(
|
|
3802
|
+
(c) => c.rowSpan > 1 || c.colSpan > 1
|
|
3000
3803
|
))
|
|
3001
3804
|
return null;
|
|
3002
|
-
o.push(a.map((
|
|
3805
|
+
o.push(a.map((c) => (c.textContent ?? "").trim()));
|
|
3003
3806
|
}
|
|
3004
3807
|
return o.length ? o : null;
|
|
3005
3808
|
} catch {
|
|
@@ -3023,21 +3826,21 @@ class Se {
|
|
|
3023
3826
|
applyClipboardGrid(t) {
|
|
3024
3827
|
const e = this.dataModel.getSchema(), i = this.dataModel.listRows(), { rowIndex: n, colIndex: s } = this.getActiveIndices(), o = this.editMode === "direct", r = `paste:${Date.now()}:${Math.random().toString(16).slice(2)}`;
|
|
3025
3828
|
for (let a = 0; a < t.length; a += 1) {
|
|
3026
|
-
const
|
|
3027
|
-
if (!
|
|
3028
|
-
const
|
|
3029
|
-
for (let
|
|
3030
|
-
const f = e.columns[s +
|
|
3829
|
+
const c = i[n + a];
|
|
3830
|
+
if (!c) break;
|
|
3831
|
+
const u = t[a] ?? [];
|
|
3832
|
+
for (let d = 0; d < u.length; d += 1) {
|
|
3833
|
+
const f = e.columns[s + d];
|
|
3031
3834
|
if (!f) break;
|
|
3032
|
-
if (this.isCellReadonly(
|
|
3033
|
-
const
|
|
3835
|
+
if (this.isCellReadonly(c.id, f.key)) continue;
|
|
3836
|
+
const g = this.coerceCellValue(u[d] ?? "", f.key), p = {
|
|
3034
3837
|
kind: "edit",
|
|
3035
|
-
rowId:
|
|
3838
|
+
rowId: c.id,
|
|
3036
3839
|
colKey: f.key,
|
|
3037
|
-
next:
|
|
3840
|
+
next: g,
|
|
3038
3841
|
payload: { batchId: r }
|
|
3039
3842
|
};
|
|
3040
|
-
this.onEdit(
|
|
3843
|
+
this.onEdit(p, o);
|
|
3041
3844
|
}
|
|
3042
3845
|
}
|
|
3043
3846
|
}
|
|
@@ -3065,28 +3868,28 @@ class Se {
|
|
|
3065
3868
|
if (i?.type === "enum" || i?.type === "tags") {
|
|
3066
3869
|
const o = i.enum?.allowCustom ?? i.tags?.allowCustom, r = i.enum?.options ?? i.tags?.options ?? [];
|
|
3067
3870
|
if (o === !1) {
|
|
3068
|
-
const
|
|
3069
|
-
f.value = "", f.textContent = "",
|
|
3070
|
-
for (const
|
|
3071
|
-
const
|
|
3072
|
-
|
|
3871
|
+
const d = document.createElement("select"), f = document.createElement("option");
|
|
3872
|
+
f.value = "", f.textContent = "", d.appendChild(f);
|
|
3873
|
+
for (const g of r) {
|
|
3874
|
+
const p = document.createElement("option");
|
|
3875
|
+
p.value = g, p.textContent = g, e === g && (p.selected = !0), d.appendChild(p);
|
|
3073
3876
|
}
|
|
3074
|
-
return { control:
|
|
3877
|
+
return { control: d, value: e };
|
|
3075
3878
|
}
|
|
3076
3879
|
const a = document.createElement("input");
|
|
3077
3880
|
a.type = "text";
|
|
3078
|
-
const
|
|
3079
|
-
a.setAttribute("list",
|
|
3080
|
-
let
|
|
3081
|
-
if (!
|
|
3082
|
-
|
|
3083
|
-
for (const
|
|
3881
|
+
const c = `extable-datalist-${String(t)}`;
|
|
3882
|
+
a.setAttribute("list", c), a.value = e;
|
|
3883
|
+
let u = document.getElementById(c);
|
|
3884
|
+
if (!u) {
|
|
3885
|
+
u = document.createElement("datalist"), u.id = c;
|
|
3886
|
+
for (const d of r) {
|
|
3084
3887
|
const f = document.createElement("option");
|
|
3085
|
-
f.value =
|
|
3888
|
+
f.value = d, u.appendChild(f);
|
|
3086
3889
|
}
|
|
3087
|
-
this.root.appendChild(
|
|
3890
|
+
this.root.appendChild(u);
|
|
3088
3891
|
}
|
|
3089
|
-
return { control: a, value: e, datalistId:
|
|
3892
|
+
return { control: a, value: e, datalistId: c };
|
|
3090
3893
|
}
|
|
3091
3894
|
const s = document.createElement("input");
|
|
3092
3895
|
return s.type = "text", s.value = e, { control: s, value: e };
|
|
@@ -3106,7 +3909,7 @@ class Se {
|
|
|
3106
3909
|
this.onEdit(o, r), this.onMove(t);
|
|
3107
3910
|
}
|
|
3108
3911
|
applySelectionFromHit(t, e) {
|
|
3109
|
-
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((
|
|
3912
|
+
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((u) => String(u.key) === String(e.colKey));
|
|
3110
3913
|
if (o < 0) return;
|
|
3111
3914
|
const r = s ? {
|
|
3112
3915
|
kind: "rows",
|
|
@@ -3123,24 +3926,24 @@ class Se {
|
|
|
3123
3926
|
};
|
|
3124
3927
|
let a = [];
|
|
3125
3928
|
if (t.shiftKey && this.activeCell) {
|
|
3126
|
-
const
|
|
3929
|
+
const u = this.activeCell, d = this.dataModel.getRowIndex(u.rowId), f = i.columns.findIndex((p) => String(p.key) === String(u.colKey));
|
|
3127
3930
|
a = [s ? {
|
|
3128
3931
|
kind: "rows",
|
|
3129
|
-
startRow:
|
|
3932
|
+
startRow: d,
|
|
3130
3933
|
endRow: n,
|
|
3131
3934
|
startCol: 0,
|
|
3132
3935
|
endCol: i.columns.length - 1
|
|
3133
3936
|
} : {
|
|
3134
3937
|
kind: "cells",
|
|
3135
|
-
startRow:
|
|
3938
|
+
startRow: d,
|
|
3136
3939
|
endRow: n,
|
|
3137
3940
|
startCol: Math.max(0, f),
|
|
3138
3941
|
endCol: Math.max(0, o)
|
|
3139
3942
|
}];
|
|
3140
3943
|
} else t.metaKey || t.ctrlKey ? a = [...this.selectionRanges, r] : a = [r];
|
|
3141
3944
|
this.selectionRanges = this.mergeRanges(a);
|
|
3142
|
-
const
|
|
3143
|
-
this.activeCell =
|
|
3945
|
+
const c = r.kind === "rows" ? { rowId: e.rowId, colKey: i.columns[o]?.key ?? null } : { rowId: e.rowId, colKey: e.colKey };
|
|
3946
|
+
this.activeCell = c, this.onActiveChange(c.rowId, c.colKey), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), r.kind === "rows" && (this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput(""));
|
|
3144
3947
|
}
|
|
3145
3948
|
mergeRanges(t) {
|
|
3146
3949
|
const e = [], i = [...t].sort((n, s) => n.kind !== s.kind ? n.kind === "rows" ? -1 : 1 : n.startRow !== s.startRow ? n.startRow - s.startRow : n.startCol !== s.startCol ? n.startCol - s.startCol : n.endRow !== s.endRow ? n.endRow - s.endRow : n.endCol - s.endCol);
|
|
@@ -3160,12 +3963,12 @@ class Se {
|
|
|
3160
3963
|
continue;
|
|
3161
3964
|
}
|
|
3162
3965
|
} else {
|
|
3163
|
-
const o = s.startCol === n.startCol && s.endCol === n.endCol, r = s.startRow === n.startRow && s.endRow === n.endRow, a = s.startRow <= n.endRow + 1 && n.startRow <= s.endRow + 1,
|
|
3966
|
+
const o = s.startCol === n.startCol && s.endCol === n.endCol, r = s.startRow === n.startRow && s.endRow === n.endRow, a = s.startRow <= n.endRow + 1 && n.startRow <= s.endRow + 1, c = s.startCol <= n.endCol + 1 && n.startCol <= s.endCol + 1;
|
|
3164
3967
|
if (o && a) {
|
|
3165
3968
|
s.startRow = Math.min(s.startRow, n.startRow), s.endRow = Math.max(s.endRow, n.endRow);
|
|
3166
3969
|
continue;
|
|
3167
3970
|
}
|
|
3168
|
-
if (r &&
|
|
3971
|
+
if (r && c) {
|
|
3169
3972
|
s.startCol = Math.min(s.startCol, n.startCol), s.endCol = Math.max(s.endCol, n.endCol);
|
|
3170
3973
|
continue;
|
|
3171
3974
|
}
|
|
@@ -3176,18 +3979,18 @@ class Se {
|
|
|
3176
3979
|
}
|
|
3177
3980
|
activateCellElement(t, e, i, n) {
|
|
3178
3981
|
this.teardownInput(), this.activeCell = { rowId: e, colKey: i }, this.activeHost = t, this.activeHostOriginalText = t.textContent ?? "";
|
|
3179
|
-
const s = this.dataModel.getCell(e, i), o = n?.initialValueOverride ?? (s == null ? "" : String(s)), { control: r, value: a } = this.createEditor(i, o),
|
|
3180
|
-
|
|
3181
|
-
const
|
|
3182
|
-
if (
|
|
3183
|
-
(
|
|
3184
|
-
}), this.bindImmediateCommit(
|
|
3185
|
-
|
|
3186
|
-
}),
|
|
3187
|
-
const
|
|
3188
|
-
|
|
3189
|
-
}
|
|
3190
|
-
this.inputEl =
|
|
3982
|
+
const s = this.dataModel.getCell(e, i), o = n?.initialValueOverride ?? (s == null ? "" : String(s)), { control: r, value: a } = this.createEditor(i, o), c = r;
|
|
3983
|
+
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";
|
|
3984
|
+
const u = this.findColumn(i);
|
|
3985
|
+
if (c.style.textAlign = u?.style?.align ?? (u?.type === "number" ? "right" : "left"), c.addEventListener("keydown", (d) => this.handleKey(d, t)), c.addEventListener("focus", () => {
|
|
3986
|
+
(c instanceof HTMLInputElement || c instanceof HTMLTextAreaElement) && c.select();
|
|
3987
|
+
}), this.bindImmediateCommit(c), t.textContent = "", t.appendChild(c), c.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
|
|
3988
|
+
c instanceof HTMLTextAreaElement && this.autosize(c);
|
|
3989
|
+
}), c.focus({ preventScroll: !0 }), n?.placeCursorAtEnd && (c instanceof HTMLInputElement || c instanceof HTMLTextAreaElement)) {
|
|
3990
|
+
const d = c.value.length;
|
|
3991
|
+
c.setSelectionRange(d, d);
|
|
3992
|
+
}
|
|
3993
|
+
this.inputEl = c;
|
|
3191
3994
|
}
|
|
3192
3995
|
activateFloating(t, e, i, n) {
|
|
3193
3996
|
this.teardownInput(), this.activeCell = { rowId: e, colKey: i };
|
|
@@ -3195,18 +3998,18 @@ class Se {
|
|
|
3195
3998
|
if (!s) return;
|
|
3196
3999
|
const o = document.createElement("div");
|
|
3197
4000
|
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";
|
|
3198
|
-
const r = this.dataModel.getCell(e, i), a = n?.initialValueOverride ?? (r == null ? "" : String(r)), { control:
|
|
3199
|
-
|
|
4001
|
+
const r = this.dataModel.getCell(e, i), a = n?.initialValueOverride ?? (r == null ? "" : String(r)), { control: c, value: u } = this.createEditor(i, a), d = c;
|
|
4002
|
+
d.value = u, 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";
|
|
3200
4003
|
const f = this.findColumn(i);
|
|
3201
|
-
if (
|
|
3202
|
-
(
|
|
3203
|
-
}), this.bindImmediateCommit(
|
|
3204
|
-
|
|
3205
|
-
}), this.root.appendChild(o), this.positionFloatingContentBox(s, o),
|
|
3206
|
-
const
|
|
3207
|
-
|
|
4004
|
+
if (d.style.textAlign = f?.style?.align ?? (f?.type === "number" ? "right" : "left"), d.style.pointerEvents = "auto", d.addEventListener("keydown", (g) => this.handleKey(g, o)), d.addEventListener("focus", () => {
|
|
4005
|
+
(d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement) && d.select();
|
|
4006
|
+
}), this.bindImmediateCommit(d), o.appendChild(d), d.tagName.toLowerCase() === "textarea" && requestAnimationFrame(() => {
|
|
4007
|
+
d instanceof HTMLTextAreaElement && this.autosize(d);
|
|
4008
|
+
}), this.root.appendChild(o), this.positionFloatingContentBox(s, o), d.focus({ preventScroll: !0 }), n?.placeCursorAtEnd && (d instanceof HTMLInputElement || d instanceof HTMLTextAreaElement)) {
|
|
4009
|
+
const g = d.value.length;
|
|
4010
|
+
d.setSelectionRange(g, g);
|
|
3208
4011
|
}
|
|
3209
|
-
this.inputEl =
|
|
4012
|
+
this.inputEl = d, this.floatingInputWrapper = o;
|
|
3210
4013
|
}
|
|
3211
4014
|
handleKey(t, e) {
|
|
3212
4015
|
if (!this.activeCell || !this.inputEl) return;
|
|
@@ -3214,9 +4017,9 @@ class Se {
|
|
|
3214
4017
|
if (t.isComposing || this.composing || i - this.lastCompositionEnd < 24) return;
|
|
3215
4018
|
const { rowId: n, colKey: s } = this.activeCell;
|
|
3216
4019
|
if (s === null) return;
|
|
3217
|
-
const o = this.inputEl.tagName.toLowerCase() === "textarea", r = t.key === "Enter" && t.altKey, a = (
|
|
3218
|
-
const
|
|
3219
|
-
this.commitEdit(n, s,
|
|
4020
|
+
const o = this.inputEl.tagName.toLowerCase() === "textarea", r = t.key === "Enter" && t.altKey, a = (c, u) => {
|
|
4021
|
+
const d = this.readActiveValue();
|
|
4022
|
+
this.commitEdit(n, s, d), this.onMove(n), this.teardownInput(!1), this.moveActiveCell(c, u);
|
|
3220
4023
|
};
|
|
3221
4024
|
if (t.key === "Tab") {
|
|
3222
4025
|
t.preventDefault(), a(0, t.shiftKey ? -1 : 1);
|
|
@@ -3230,8 +4033,8 @@ class Se {
|
|
|
3230
4033
|
}
|
|
3231
4034
|
if (t.key === "Escape") {
|
|
3232
4035
|
if (t.preventDefault(), this.cancelEdit(e), this.onMove(), this.activeCell && this.activeCell.colKey !== null) {
|
|
3233
|
-
const
|
|
3234
|
-
this.focusSelectionInput(
|
|
4036
|
+
const c = this.dataModel.getCell(this.activeCell.rowId, this.activeCell.colKey), u = this.cellToClipboardString(c);
|
|
4037
|
+
this.focusSelectionInput(u);
|
|
3235
4038
|
}
|
|
3236
4039
|
} else t.key === "Backspace" && this.inputEl.value === "" && (t.preventDefault(), this.commitEdit(n, s, ""), this.onMove(n), this.teardownInput(!1), this.moveActiveCell(0, 0));
|
|
3237
4040
|
}
|
|
@@ -3291,16 +4094,16 @@ class Se {
|
|
|
3291
4094
|
_(this.inputEl), _(this.floatingInputWrapper), this.activeHost && this.activeHostOriginalText !== null && (this.activeHost.textContent = this.activeHostOriginalText), this.inputEl = null, this.floatingInputWrapper = null, this.activeHost = null, this.activeHostOriginalText = null, t && (this.activeCell = null, this.onActiveChange(null, null));
|
|
3292
4095
|
}
|
|
3293
4096
|
}
|
|
3294
|
-
const
|
|
3295
|
-
class
|
|
4097
|
+
const Li = (l) => l;
|
|
4098
|
+
class Hi {
|
|
3296
4099
|
constructor(t) {
|
|
3297
|
-
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.findReplace = null, this.findReplaceSidebar = null, this.findReplaceSidebarUnsub = null, this.findReplaceEnabled = !0, this.findReplaceUiEnabled = !0, this.findReplaceEnableSearch = !1, 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.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.loadingEnabled = t.options?.loading?.enabled ?? !0, this.findReplaceEnabled = t.options?.findReplace?.enabled ?? !0, this.findReplaceUiEnabled = t.options?.findReplace?.sidebar ?? t.options?.findReplace?.dialog ?? !0, this.findReplaceEnableSearch = t.options?.findReplace?.enableSearch ?? !0, this.server = t.options?.server, this.user = t.options?.user;
|
|
4100
|
+
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.findReplace = null, this.findReplaceSidebar = null, this.findReplaceSidebarUnsub = null, this.findReplaceEnabled = !0, this.findReplaceUiEnabled = !0, this.findReplaceEnableSearch = !1, 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.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.loadingEnabled = t.options?.loading?.enabled ?? !0, this.findReplaceEnabled = t.options?.findReplace?.enabled ?? !0, this.findReplaceUiEnabled = t.options?.findReplace?.sidebar ?? t.options?.findReplace?.dialog ?? !0, this.findReplaceEnableSearch = t.options?.findReplace?.enableSearch ?? !0, this.server = t.options?.server, this.user = t.options?.user, this.sequenceLangs = t.options?.langs;
|
|
3298
4101
|
const e = t.defaultData ?? null, i = e ?? [];
|
|
3299
|
-
this.dataLoaded = e != null, this.dataModel = new
|
|
4102
|
+
this.dataLoaded = e != null, this.dataModel = new ue(
|
|
3300
4103
|
i,
|
|
3301
4104
|
t.schema,
|
|
3302
4105
|
t.defaultView
|
|
3303
|
-
), this.commandQueue = new
|
|
4106
|
+
), this.commandQueue = new oe(), this.lockManager = new ye(this.lockMode, this.server, this.user), this.renderer = this.chooseRenderer(this.renderMode), this.applyRootDecor(t.options), this.applyReadonlyClass(), this.loadInitial();
|
|
3304
4107
|
}
|
|
3305
4108
|
isCellReadonly(t, e) {
|
|
3306
4109
|
return this.editMode === "readonly" || this.dataModel.isReadonly(t, e);
|
|
@@ -3336,7 +4139,7 @@ class xe {
|
|
|
3336
4139
|
this.mount();
|
|
3337
4140
|
}
|
|
3338
4141
|
applyRootDecor(t) {
|
|
3339
|
-
const e =
|
|
4142
|
+
const e = Et(t?.defaultClass);
|
|
3340
4143
|
if (e?.length && this.root.classList.add(...e), t?.defaultStyle)
|
|
3341
4144
|
for (const [i, n] of Object.entries(t.defaultStyle))
|
|
3342
4145
|
this.root.style[i] = n ?? "";
|
|
@@ -3347,11 +4150,11 @@ class xe {
|
|
|
3347
4150
|
chooseRenderer(t) {
|
|
3348
4151
|
if (t === "auto") {
|
|
3349
4152
|
const e = typeof navigator < "u" ? navigator.userAgent : "";
|
|
3350
|
-
return /bot|crawl|spider/i.test(e) || typeof navigator < "u" && "userAgentData" in navigator && navigator.userAgentData?.brands?.some(
|
|
4153
|
+
return /bot|crawl|spider|playwright|puppeteer|selenium|phantomjs/i.test(e) || typeof navigator < "u" && "userAgentData" in navigator && navigator.userAgentData?.brands?.some(
|
|
3351
4154
|
(n) => /bot/i.test(n.brand ?? "")
|
|
3352
|
-
) ? new
|
|
4155
|
+
) ? new ht(this.dataModel) : new gt(this.dataModel, () => this.editMode);
|
|
3353
4156
|
}
|
|
3354
|
-
return t === "html" ? new
|
|
4157
|
+
return t === "html" ? new ht(this.dataModel) : new gt(this.dataModel, () => this.editMode);
|
|
3355
4158
|
}
|
|
3356
4159
|
ensureShell() {
|
|
3357
4160
|
if (this.shell && this.viewportEl && this.shell.parentElement === this.root) return;
|
|
@@ -3376,7 +4179,7 @@ class xe {
|
|
|
3376
4179
|
this.root.dataset.extable = "loading", this.bindViewport(), this.ensureFindReplace(), this.ensureFilterSort(), this.emitTableState(), this.emitSelection("data");
|
|
3377
4180
|
return;
|
|
3378
4181
|
}
|
|
3379
|
-
this.selectionManager = new
|
|
4182
|
+
this.selectionManager = new Ai(
|
|
3380
4183
|
e,
|
|
3381
4184
|
this.editMode,
|
|
3382
4185
|
(i, n) => this.handleEdit(i, n),
|
|
@@ -3388,6 +4191,7 @@ class xe {
|
|
|
3388
4191
|
},
|
|
3389
4192
|
(i) => this.renderer.hitTest(i),
|
|
3390
4193
|
this.dataModel,
|
|
4194
|
+
this.sequenceLangs,
|
|
3391
4195
|
(i, n) => this.isCellReadonly(i, n),
|
|
3392
4196
|
(i, n) => {
|
|
3393
4197
|
const s = i && n !== null ? { rowId: i, colKey: n } : null;
|
|
@@ -3406,7 +4210,7 @@ class xe {
|
|
|
3406
4210
|
}
|
|
3407
4211
|
// editMode/lockMode are configured only at construction time for consistency.
|
|
3408
4212
|
setRootClass(t) {
|
|
3409
|
-
this.root.className = "", this.root.classList.add(...
|
|
4213
|
+
this.root.className = "", this.root.classList.add(...Et(t) ?? []);
|
|
3410
4214
|
}
|
|
3411
4215
|
setRootStyle(t) {
|
|
3412
4216
|
for (const [e, i] of Object.entries(t))
|
|
@@ -3528,7 +4332,7 @@ class xe {
|
|
|
3528
4332
|
const a = r;
|
|
3529
4333
|
if (a.kind === "enum" && typeof a.value == "string") return a.value;
|
|
3530
4334
|
if (a.kind === "tags" && Array.isArray(a.values))
|
|
3531
|
-
return a.values.filter((
|
|
4335
|
+
return a.values.filter((u) => typeof u == "string").join(", ");
|
|
3532
4336
|
}
|
|
3533
4337
|
return String(r);
|
|
3534
4338
|
}
|
|
@@ -3728,11 +4532,11 @@ class xe {
|
|
|
3728
4532
|
if (this.ensureContextMenu(), !this.contextMenu || !this.contextMenu.isConnected && (this.contextMenu = null, this.ensureContextMenu(), !this.contextMenu))
|
|
3729
4533
|
return;
|
|
3730
4534
|
this.contextMenuRowId = t;
|
|
3731
|
-
for (const
|
|
4535
|
+
for (const c of Array.from(
|
|
3732
4536
|
this.contextMenu.querySelectorAll("button[data-action]")
|
|
3733
4537
|
)) {
|
|
3734
|
-
const
|
|
3735
|
-
|
|
4538
|
+
const u = c.dataset.action;
|
|
4539
|
+
u === "undo" ? c.disabled = !this.commandQueue.canUndo() : u === "redo" && (c.disabled = !this.commandQueue.canRedo());
|
|
3736
4540
|
}
|
|
3737
4541
|
const n = window.innerWidth, s = window.innerHeight, o = { width: 220, height: 160 };
|
|
3738
4542
|
let r = e, a = i;
|
|
@@ -3838,25 +4642,25 @@ class xe {
|
|
|
3838
4642
|
}
|
|
3839
4643
|
// Public API: table-level state callbacks
|
|
3840
4644
|
getTableState() {
|
|
3841
|
-
const t = this.renderer instanceof
|
|
3842
|
-
const
|
|
3843
|
-
for (const
|
|
3844
|
-
|
|
3845
|
-
return
|
|
3846
|
-
})(), o = this.dataModel.getValidationErrors().map((
|
|
4645
|
+
const t = this.renderer instanceof ht ? "html" : "canvas", e = this.commandQueue.listApplied(), i = this.editMode === "commit" ? e : [], n = i.length, s = (() => {
|
|
4646
|
+
const c = /* @__PURE__ */ new Set();
|
|
4647
|
+
for (const u of i)
|
|
4648
|
+
u.kind === "edit" && (!u.rowId || u.colKey === void 0 || c.add(`${u.rowId}::${String(u.colKey)}`));
|
|
4649
|
+
return c.size;
|
|
4650
|
+
})(), o = this.dataModel.getValidationErrors().map((c) => ({
|
|
3847
4651
|
scope: "validation",
|
|
3848
|
-
message:
|
|
3849
|
-
target: { rowId:
|
|
3850
|
-
})), r = this.dataModel.getDiagnostics().map((
|
|
3851
|
-
scope:
|
|
3852
|
-
message:
|
|
3853
|
-
target: { rowId:
|
|
4652
|
+
message: c.message,
|
|
4653
|
+
target: { rowId: c.rowId, colKey: c.colKey }
|
|
4654
|
+
})), r = this.dataModel.getDiagnostics().map((c) => c.diag ? {
|
|
4655
|
+
scope: c.diag.source,
|
|
4656
|
+
message: c.diag.message,
|
|
4657
|
+
target: { rowId: c.rowId, colKey: c.colKey }
|
|
3854
4658
|
} : null).filter(Boolean);
|
|
3855
|
-
r.sort((
|
|
3856
|
-
const
|
|
3857
|
-
if (
|
|
3858
|
-
const
|
|
3859
|
-
return
|
|
4659
|
+
r.sort((c, u) => {
|
|
4660
|
+
const d = c.target?.rowId ? this.dataModel.getRowIndex(c.target.rowId) : -1, f = u.target?.rowId ? this.dataModel.getRowIndex(u.target.rowId) : -1;
|
|
4661
|
+
if (d !== f) return d - f;
|
|
4662
|
+
const g = c.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(c.target.colKey) : -1, p = u.target?.colKey !== void 0 ? this.dataModel.getColumnIndex(u.target.colKey) : -1;
|
|
4663
|
+
return g !== p ? g - p : c.scope !== u.scope ? c.scope < u.scope ? -1 : 1 : c.message < u.message ? -1 : c.message > u.message ? 1 : 0;
|
|
3860
4664
|
});
|
|
3861
4665
|
const a = [
|
|
3862
4666
|
...o,
|
|
@@ -3882,8 +4686,8 @@ class xe {
|
|
|
3882
4686
|
for (let s = 0; s < t.activeErrors.length; s += 1) {
|
|
3883
4687
|
const o = e.activeErrors[s], r = t.activeErrors[s];
|
|
3884
4688
|
if (!o || !r || o.scope !== r.scope || o.message !== r.message) return !1;
|
|
3885
|
-
const a = o.target,
|
|
3886
|
-
if (!(!a && !
|
|
4689
|
+
const a = o.target, c = r.target;
|
|
4690
|
+
if (!(!a && !c) && (!a || !c || (a.rowId ?? null) !== (c.rowId ?? null) || String(a.colKey ?? "") !== String(c.colKey ?? "")))
|
|
3887
4691
|
return !1;
|
|
3888
4692
|
}
|
|
3889
4693
|
return !0;
|
|
@@ -3895,29 +4699,29 @@ class xe {
|
|
|
3895
4699
|
}
|
|
3896
4700
|
// Public API: selection callbacks
|
|
3897
4701
|
getSelectionSnapshot() {
|
|
3898
|
-
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, r = s !== null ? e.columns.findIndex((y) => String(y.key) === String(s)) : null, a = r !== null && r >= 0 ? e.columns[r] : null,
|
|
3899
|
-
if (
|
|
4702
|
+
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, r = s !== null ? e.columns.findIndex((y) => String(y.key) === String(s)) : null, a = r !== null && r >= 0 ? e.columns[r] : null, c = n && a ? this.dataModel.resolveCellValue(n, a) : null, u = n && a ? this.dataModel.resolveConditionalStyle(n, a) : null, d = c?.textOverride ?? (u?.forceErrorText ? "#ERROR" : void 0), f = c ? c.value : null, g = (() => {
|
|
4703
|
+
if (d) return d;
|
|
3900
4704
|
const y = f;
|
|
3901
4705
|
if (y == null) return "";
|
|
3902
4706
|
if (y instanceof Date) return y.toISOString();
|
|
3903
4707
|
if (typeof y == "string") return y;
|
|
3904
4708
|
if (typeof y == "number" || typeof y == "boolean") return String(y);
|
|
3905
4709
|
if (typeof y == "object") {
|
|
3906
|
-
const w = y,
|
|
3907
|
-
if (
|
|
3908
|
-
if (
|
|
3909
|
-
return w.values.filter((
|
|
4710
|
+
const w = y, C = w.kind;
|
|
4711
|
+
if (C === "enum" && typeof w.value == "string") return w.value;
|
|
4712
|
+
if (C === "tags" && Array.isArray(w.values))
|
|
4713
|
+
return w.values.filter((v) => typeof v == "string").join(", ");
|
|
3910
4714
|
}
|
|
3911
4715
|
return String(y);
|
|
3912
|
-
})(),
|
|
4716
|
+
})(), p = a?.type ?? null, h = n && s !== null ? this.dataModel.getCellDiagnostic(n, s) : null, m = (() => {
|
|
3913
4717
|
if (!n || !a)
|
|
3914
4718
|
return { columnStyle: {}, cellStyle: {}, resolved: {} };
|
|
3915
|
-
const { columnStyle: y, cellStyle: w, resolved:
|
|
4719
|
+
const { columnStyle: y, cellStyle: w, resolved: C } = Ri(
|
|
3916
4720
|
this.dataModel,
|
|
3917
4721
|
n,
|
|
3918
4722
|
a
|
|
3919
4723
|
);
|
|
3920
|
-
return { columnStyle: y, cellStyle: w, resolved:
|
|
4724
|
+
return { columnStyle: y, cellStyle: w, resolved: C };
|
|
3921
4725
|
})();
|
|
3922
4726
|
return {
|
|
3923
4727
|
ranges: [...t],
|
|
@@ -3926,10 +4730,10 @@ class xe {
|
|
|
3926
4730
|
activeColumnIndex: r !== null && r >= 0 ? r : null,
|
|
3927
4731
|
activeColumnKey: s,
|
|
3928
4732
|
activeValueRaw: f,
|
|
3929
|
-
activeValueDisplay:
|
|
3930
|
-
activeValueType:
|
|
3931
|
-
diagnostic:
|
|
3932
|
-
styles:
|
|
4733
|
+
activeValueDisplay: g,
|
|
4734
|
+
activeValueType: p,
|
|
4735
|
+
diagnostic: h,
|
|
4736
|
+
styles: m
|
|
3933
4737
|
};
|
|
3934
4738
|
}
|
|
3935
4739
|
subscribeSelection(t) {
|
|
@@ -3978,7 +4782,7 @@ class xe {
|
|
|
3978
4782
|
}
|
|
3979
4783
|
// Public API: value updates
|
|
3980
4784
|
setCellValue(t, e, i) {
|
|
3981
|
-
const n = typeof t == "string" ? t : this.dataModel.listRows()[t]?.id, s = n ?
|
|
4785
|
+
const n = typeof t == "string" ? t : this.dataModel.listRows()[t]?.id, s = n ? fe(this.dataModel, { rowId: n, colKey: e }) : null;
|
|
3982
4786
|
if (!s || this.isCellReadonly(s.rowId, s.colKey)) return;
|
|
3983
4787
|
const o = this.dataModel.getCell(s.rowId, s.colKey), r = typeof i == "function" ? i(o) : i;
|
|
3984
4788
|
this.handleEdit(
|
|
@@ -3990,18 +4794,18 @@ class xe {
|
|
|
3990
4794
|
const e = this.dataModel.getSchema(), i = this.dataModel.listRows(), n = /* @__PURE__ */ new Set();
|
|
3991
4795
|
for (const s of this.selectionRanges) {
|
|
3992
4796
|
if (s.kind !== "cells") continue;
|
|
3993
|
-
const o = Math.min(s.startRow, s.endRow), r = Math.max(s.startRow, s.endRow), a = Math.min(s.startCol, s.endCol),
|
|
3994
|
-
for (let
|
|
3995
|
-
const
|
|
3996
|
-
if (
|
|
3997
|
-
for (let f = a; f <=
|
|
3998
|
-
const
|
|
3999
|
-
if (!
|
|
4000
|
-
const
|
|
4001
|
-
if (n.has(
|
|
4002
|
-
const
|
|
4797
|
+
const o = Math.min(s.startRow, s.endRow), r = Math.max(s.startRow, s.endRow), a = Math.min(s.startCol, s.endCol), c = Math.max(s.startCol, s.endCol);
|
|
4798
|
+
for (let u = o; u <= r; u += 1) {
|
|
4799
|
+
const d = i[u];
|
|
4800
|
+
if (d)
|
|
4801
|
+
for (let f = a; f <= c; f += 1) {
|
|
4802
|
+
const g = e.columns[f];
|
|
4803
|
+
if (!g) continue;
|
|
4804
|
+
const p = `${d.id}::${String(g.key)}`;
|
|
4805
|
+
if (n.has(p) || (n.add(p), this.isCellReadonly(d.id, g.key))) continue;
|
|
4806
|
+
const h = this.dataModel.getCell(d.id, g.key), m = typeof t == "function" ? t(h) : t;
|
|
4003
4807
|
this.handleEdit(
|
|
4004
|
-
{ kind: "edit", rowId:
|
|
4808
|
+
{ kind: "edit", rowId: d.id, colKey: g.key, next: m },
|
|
4005
4809
|
this.editMode === "direct"
|
|
4006
4810
|
);
|
|
4007
4811
|
}
|
|
@@ -4016,7 +4820,7 @@ class xe {
|
|
|
4016
4820
|
this.hideSearchPanel();
|
|
4017
4821
|
}
|
|
4018
4822
|
ensureFindReplace() {
|
|
4019
|
-
this.findReplaceEnabled && (this.findReplace || (this.findReplace = new
|
|
4823
|
+
this.findReplaceEnabled && (this.findReplace || (this.findReplace = new me(
|
|
4020
4824
|
this.dataModel,
|
|
4021
4825
|
(t, e) => this.selectionManager?.navigateToCell(t, e),
|
|
4022
4826
|
(t, e, i) => this.handleEdit({ kind: "edit", rowId: t, colKey: e, next: i }, this.editMode === "direct"),
|
|
@@ -4076,12 +4880,12 @@ class xe {
|
|
|
4076
4880
|
'input[data-extable-fr="replace-toggle"]'
|
|
4077
4881
|
), o = e.querySelector(
|
|
4078
4882
|
'[data-extable-fr="replace-toggle-row"]'
|
|
4079
|
-
), r = e.querySelector('input[data-extable-fr="case"]'), a = e.querySelector('input[data-extable-fr="regex"]'),
|
|
4883
|
+
), r = e.querySelector('input[data-extable-fr="case"]'), a = e.querySelector('input[data-extable-fr="regex"]'), c = e.querySelector('button[data-extable-fr="prev"]'), u = e.querySelector('button[data-extable-fr="next"]'), d = e.querySelector(
|
|
4080
4884
|
'button[data-extable-fr="replace-current"]'
|
|
4081
4885
|
), f = e.querySelector(
|
|
4082
4886
|
'button[data-extable-fr="replace-all"]'
|
|
4083
|
-
),
|
|
4084
|
-
if (!i || !n || !s || !o || !r || !a || !
|
|
4887
|
+
), g = e.querySelector('button[data-extable-fr="close"]'), p = e.querySelector('[data-extable-fr="results-tbody"]');
|
|
4888
|
+
if (!i || !n || !s || !o || !r || !a || !c || !u || !d || !f || !g || !p) {
|
|
4085
4889
|
_(e), this.findReplaceSidebar = null;
|
|
4086
4890
|
return;
|
|
4087
4891
|
}
|
|
@@ -4096,30 +4900,30 @@ class xe {
|
|
|
4096
4900
|
s.checked = !1, this.findReplace?.setMode("find"), e.dataset.extableFrMode = "find";
|
|
4097
4901
|
return;
|
|
4098
4902
|
}
|
|
4099
|
-
const
|
|
4100
|
-
this.findReplace?.setMode(
|
|
4101
|
-
}), this.updateFindReplaceReadonlyUI(),
|
|
4102
|
-
const
|
|
4103
|
-
|
|
4104
|
-
const y =
|
|
4903
|
+
const m = s.checked ? "replace" : "find";
|
|
4904
|
+
this.findReplace?.setMode(m), e.dataset.extableFrMode = m;
|
|
4905
|
+
}), this.updateFindReplaceReadonlyUI(), c.addEventListener("click", () => this.findReplace?.prev()), u.addEventListener("click", () => this.findReplace?.next()), d.addEventListener("click", () => this.findReplace?.replaceCurrent()), f.addEventListener("click", () => this.findReplace?.replaceAll()), g.addEventListener("click", () => this.hideSearchPanel());
|
|
4906
|
+
const h = (m, y = 140) => m.length > y ? `${m.slice(0, y - 1)}…` : m;
|
|
4907
|
+
p.addEventListener("click", (m) => {
|
|
4908
|
+
const y = m.target?.closest("tr[data-index]"), w = y ? Number(y.dataset.index) : -1;
|
|
4105
4909
|
Number.isFinite(w) && w >= 0 && this.findReplace?.activateIndex(w);
|
|
4106
|
-
}),
|
|
4107
|
-
if (
|
|
4108
|
-
const y =
|
|
4910
|
+
}), p.addEventListener("keydown", (m) => {
|
|
4911
|
+
if (m.key !== "Enter") return;
|
|
4912
|
+
const y = m.target?.closest("tr[data-index]"), w = y ? Number(y.dataset.index) : -1;
|
|
4109
4913
|
Number.isFinite(w) && w >= 0 && this.findReplace?.activateIndex(w);
|
|
4110
|
-
}), this.updateFindReplaceReadonlyUI(), this.findReplaceSidebarUnsub = this.findReplace?.subscribe((
|
|
4111
|
-
const y = e.querySelector('[data-extable-fr="replace-row"]'), w = e.querySelector('[data-extable-fr="status"]'),
|
|
4112
|
-
if (!(!y || !w || !
|
|
4113
|
-
i.value =
|
|
4114
|
-
for (let
|
|
4115
|
-
const
|
|
4116
|
-
if (!
|
|
4117
|
-
const
|
|
4118
|
-
|
|
4119
|
-
const
|
|
4120
|
-
|
|
4121
|
-
const
|
|
4122
|
-
|
|
4914
|
+
}), this.updateFindReplaceReadonlyUI(), this.findReplaceSidebarUnsub = this.findReplace?.subscribe((m) => {
|
|
4915
|
+
const y = e.querySelector('[data-extable-fr="replace-row"]'), w = e.querySelector('[data-extable-fr="status"]'), C = e.querySelector('[data-extable-fr="error"]');
|
|
4916
|
+
if (!(!y || !w || !C)) {
|
|
4917
|
+
i.value = m.query, n.value = m.replace, r.checked = m.options.caseInsensitive, a.checked = m.options.regex, s.checked = m.mode === "replace", y.style.display = m.mode === "replace" ? "block" : "none", d.style.display = m.mode === "replace" ? "inline-block" : "none", f.style.display = m.mode === "replace" ? "inline-block" : "none", w.textContent = `${m.matches.length} matches`, C.textContent = m.error ?? "", c.disabled = m.matches.length === 0, u.disabled = m.matches.length === 0, d.disabled = m.matches.length === 0 || m.activeIndex < 0, f.disabled = m.matches.length === 0, p.innerHTML = "";
|
|
4918
|
+
for (let v = 0; v < m.matches.length; v += 1) {
|
|
4919
|
+
const b = m.matches[v];
|
|
4920
|
+
if (!b) continue;
|
|
4921
|
+
const S = document.createElement("tr");
|
|
4922
|
+
S.dataset.index = String(v), S.tabIndex = 0, S.className = "extable-search-result-row", v === m.activeIndex && (S.dataset.active = "1");
|
|
4923
|
+
const x = document.createElement("td");
|
|
4924
|
+
x.textContent = `R${b.rowIndex + 1}C${b.colIndex + 1}`;
|
|
4925
|
+
const R = document.createElement("td"), E = h(b.text);
|
|
4926
|
+
R.textContent = E, R.title = b.text, S.appendChild(x), S.appendChild(R), p.appendChild(S);
|
|
4123
4927
|
}
|
|
4124
4928
|
}
|
|
4125
4929
|
}) ?? null;
|
|
@@ -4210,16 +5014,16 @@ class xe {
|
|
|
4210
5014
|
`, t.appendChild(e), this.filterSortSidebar = e;
|
|
4211
5015
|
const i = e.querySelector('button[data-extable-fs="close"]'), n = e.querySelector('input[data-extable-fs="col-errors"]'), s = e.querySelector(
|
|
4212
5016
|
'input[data-extable-fs="col-warnings"]'
|
|
4213
|
-
), o = e.querySelector('input[data-extable-fs="search"]'), r = e.querySelector('[data-extable-fs="values"]'), a = e.querySelector('button[data-extable-fs="select-all"]'),
|
|
5017
|
+
), o = e.querySelector('input[data-extable-fs="search"]'), r = e.querySelector('[data-extable-fs="values"]'), a = e.querySelector('button[data-extable-fs="select-all"]'), c = e.querySelector('button[data-extable-fs="select-none"]'), u = e.querySelector(
|
|
4214
5018
|
'button[data-extable-fs="apply-filter"]'
|
|
4215
|
-
),
|
|
5019
|
+
), d = e.querySelector(
|
|
4216
5020
|
'button[data-extable-fs="clear-filter"]'
|
|
4217
|
-
), f = e.querySelector('button[data-extable-fs="sort-asc"]'),
|
|
5021
|
+
), f = e.querySelector('button[data-extable-fs="sort-asc"]'), g = e.querySelector(
|
|
4218
5022
|
'button[data-extable-fs="sort-desc"]'
|
|
4219
|
-
),
|
|
5023
|
+
), p = e.querySelector(
|
|
4220
5024
|
'button[data-extable-fs="clear-sort"]'
|
|
4221
5025
|
);
|
|
4222
|
-
if (!i || !n || !s || !o || !r || !a || !
|
|
5026
|
+
if (!i || !n || !s || !o || !r || !a || !c || !u || !d || !f || !g || !p) {
|
|
4223
5027
|
_(e), this.filterSortSidebar = null;
|
|
4224
5028
|
return;
|
|
4225
5029
|
}
|
|
@@ -4229,18 +5033,18 @@ class xe {
|
|
|
4229
5033
|
this.filterSortDraft && (this.filterSortDraft.diagWarnings = s.checked);
|
|
4230
5034
|
}), o.addEventListener("input", () => {
|
|
4231
5035
|
this.filterSortDraft && (this.filterSortDraft.search = o.value, this.renderFilterSortValues());
|
|
4232
|
-
}), r.addEventListener("change", (
|
|
4233
|
-
const
|
|
5036
|
+
}), r.addEventListener("change", (h) => {
|
|
5037
|
+
const m = h.target?.closest(
|
|
4234
5038
|
'input[type="checkbox"][data-fs-val]'
|
|
4235
5039
|
);
|
|
4236
|
-
if (!
|
|
4237
|
-
const y =
|
|
4238
|
-
y && (y === "__blanks__" ? this.filterSortDraft.includeBlanks =
|
|
5040
|
+
if (!m || !this.filterSortDraft) return;
|
|
5041
|
+
const y = m.dataset.fsVal ?? "";
|
|
5042
|
+
y && (y === "__blanks__" ? this.filterSortDraft.includeBlanks = m.checked : m.checked ? this.filterSortDraft.selected.add(y) : this.filterSortDraft.selected.delete(y));
|
|
4239
5043
|
}), a.addEventListener("click", () => {
|
|
4240
|
-
this.filterSortDraft && (this.filterSortDraft.selected = new Set(this.filterSortDraft.values.map((
|
|
4241
|
-
}),
|
|
5044
|
+
this.filterSortDraft && (this.filterSortDraft.selected = new Set(this.filterSortDraft.values.map((h) => h.key)), this.filterSortDraft.includeBlanks = this.filterSortDraft.hasBlanks, this.renderFilterSortValues());
|
|
5045
|
+
}), c.addEventListener("click", () => {
|
|
4242
5046
|
this.filterSortDraft && (this.filterSortDraft.selected = /* @__PURE__ */ new Set(), this.filterSortDraft.includeBlanks = !1, this.renderFilterSortValues());
|
|
4243
|
-
}),
|
|
5047
|
+
}), u.addEventListener("click", () => this.applyFilterSortDraft()), d.addEventListener("click", () => this.clearFilterSortForActiveColumn()), f.addEventListener("click", () => this.setSortForActiveColumn("asc")), g.addEventListener("click", () => this.setSortForActiveColumn("desc")), p.addEventListener("click", () => this.clearSort()), this.filterSortSidebarUnsub = this.dataModel.subscribe(() => {
|
|
4244
5048
|
this.isFilterSortPanelVisible() && this.filterSortActiveColumnKey && (this.buildFilterSortDraft(this.filterSortActiveColumnKey), this.renderFilterSortSidebar());
|
|
4245
5049
|
});
|
|
4246
5050
|
}
|
|
@@ -4261,20 +5065,20 @@ class xe {
|
|
|
4261
5065
|
}
|
|
4262
5066
|
const s = this.filterSortDraft && String(this.filterSortDraft.colKey) === String(n.key) ? this.filterSortDraft.search : "", o = this.dataModel.getDistinctValuesForColumn(n.key), r = o.values.map((f) => ({ ...f, key: this.stableValueKey(f.value) })), a = (e.filters ?? []).find(
|
|
4263
5067
|
(f) => f.kind === "values" && String(f.key) === String(n.key)
|
|
4264
|
-
),
|
|
5068
|
+
), c = /* @__PURE__ */ new Set();
|
|
4265
5069
|
if (a)
|
|
4266
|
-
for (const f of a.values ?? [])
|
|
5070
|
+
for (const f of a.values ?? []) c.add(this.stableValueKey(f));
|
|
4267
5071
|
else
|
|
4268
|
-
for (const f of r)
|
|
4269
|
-
const
|
|
5072
|
+
for (const f of r) c.add(f.key);
|
|
5073
|
+
const u = a ? !!a.includeBlanks : o.hasBlanks, d = e.columnDiagnostics?.[String(n.key)];
|
|
4270
5074
|
this.filterSortDraft = {
|
|
4271
5075
|
colKey: n.key,
|
|
4272
5076
|
values: r,
|
|
4273
5077
|
hasBlanks: o.hasBlanks,
|
|
4274
|
-
selected:
|
|
4275
|
-
includeBlanks:
|
|
4276
|
-
diagErrors: !!
|
|
4277
|
-
diagWarnings: !!
|
|
5078
|
+
selected: c,
|
|
5079
|
+
includeBlanks: u,
|
|
5080
|
+
diagErrors: !!d?.errors,
|
|
5081
|
+
diagWarnings: !!d?.warnings,
|
|
4278
5082
|
search: s
|
|
4279
5083
|
};
|
|
4280
5084
|
}
|
|
@@ -4297,9 +5101,9 @@ class xe {
|
|
|
4297
5101
|
t.textContent = "Sort/Filter", e.checked = !1, i.checked = !1, n.value = "", s && (s.dataset.active = "0"), o && (o.dataset.active = "0"), this.renderFilterSortValues();
|
|
4298
5102
|
return;
|
|
4299
5103
|
}
|
|
4300
|
-
const
|
|
4301
|
-
t.textContent = `Sort/Filter: ${
|
|
4302
|
-
const f = this.dataModel.getView().sorts?.find((
|
|
5104
|
+
const u = this.dataModel.getSchema().columns.find((g) => String(g.key) === String(r.colKey))?.header ?? String(r.colKey);
|
|
5105
|
+
t.textContent = `Sort/Filter: ${u}`, e.checked = r.diagErrors, i.checked = r.diagWarnings, n.value = r.search;
|
|
5106
|
+
const f = this.dataModel.getView().sorts?.find((g) => String(g.key) === String(r.colKey));
|
|
4303
5107
|
s && (s.dataset.active = f?.dir === "asc" ? "1" : "0"), o && (o.dataset.active = f?.dir === "desc" ? "1" : "0"), this.renderFilterSortValues();
|
|
4304
5108
|
}
|
|
4305
5109
|
renderFilterSortValues() {
|
|
@@ -4325,8 +5129,8 @@ class xe {
|
|
|
4325
5129
|
for (const o of s.slice(0, 200)) {
|
|
4326
5130
|
const r = document.createElement("label"), a = document.createElement("input");
|
|
4327
5131
|
a.type = "checkbox", a.dataset.fsVal = o.key, a.checked = e.selected.has(o.key);
|
|
4328
|
-
const
|
|
4329
|
-
|
|
5132
|
+
const c = document.createElement("span");
|
|
5133
|
+
c.textContent = o.label, r.appendChild(a), r.appendChild(c), t.appendChild(r);
|
|
4330
5134
|
}
|
|
4331
5135
|
}
|
|
4332
5136
|
applyFilterSortDraft() {
|
|
@@ -4420,26 +5224,26 @@ class xe {
|
|
|
4420
5224
|
this.viewportState = i, this.rafId === null && (this.rafId = requestAnimationFrame(() => this.flushRender()));
|
|
4421
5225
|
}
|
|
4422
5226
|
flushRender() {
|
|
4423
|
-
this.rafId = null, this.viewportState && (this.selectionManager?.onScroll(this.viewportState.scrollTop, this.viewportState.scrollLeft), !(this.renderer instanceof
|
|
5227
|
+
this.rafId = null, this.viewportState && (this.selectionManager?.onScroll(this.viewportState.scrollTop, this.viewportState.scrollLeft), !(this.renderer instanceof ht) && this.safeRender(this.viewportState));
|
|
4424
5228
|
}
|
|
4425
5229
|
}
|
|
4426
|
-
function
|
|
4427
|
-
return new
|
|
5230
|
+
function Vi(l, t) {
|
|
5231
|
+
return new Hi({
|
|
4428
5232
|
root: document.createElement("div"),
|
|
4429
|
-
defaultData:
|
|
4430
|
-
defaultView:
|
|
4431
|
-
schema:
|
|
5233
|
+
defaultData: l.data,
|
|
5234
|
+
defaultView: l.view,
|
|
5235
|
+
schema: l.schema,
|
|
4432
5236
|
options: t
|
|
4433
5237
|
});
|
|
4434
5238
|
}
|
|
4435
|
-
function
|
|
4436
|
-
return t.remount(
|
|
5239
|
+
function _i(l, t) {
|
|
5240
|
+
return t.remount(l), t;
|
|
4437
5241
|
}
|
|
4438
5242
|
export {
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
5243
|
+
Hi as ExtableCore,
|
|
5244
|
+
me as FindReplaceController,
|
|
5245
|
+
Vi as createTablePlaceholder,
|
|
5246
|
+
Li as defineSchema,
|
|
5247
|
+
_i as mountTable
|
|
4444
5248
|
};
|
|
4445
5249
|
//# sourceMappingURL=index.js.map
|