@toolbox-web/grid 0.0.4 → 0.0.5
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/all.d.ts +29 -6
- package/all.js +421 -421
- package/all.js.map +1 -1
- package/index.d.ts +28 -0
- package/index.js +774 -726
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +55 -35
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +49 -29
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +35 -15
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +52 -32
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +116 -99
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +42 -22
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +20 -0
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +50 -27
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +25 -5
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +20 -0
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +20 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +20 -0
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +48 -28
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +51 -31
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +20 -0
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +76 -53
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +20 -0
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +20 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +25 -25
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +12 -12
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +3 -3
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +2 -2
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +2 -2
- package/umd/plugins/tree.umd.js.map +1 -1
package/index.js
CHANGED
|
@@ -9,19 +9,19 @@ function be(o) {
|
|
|
9
9
|
function ae(o, e) {
|
|
10
10
|
const t = o._columns, n = be(o);
|
|
11
11
|
return {
|
|
12
|
-
columns: t.map((
|
|
12
|
+
columns: t.map((i, s) => {
|
|
13
13
|
const l = {
|
|
14
|
-
field:
|
|
15
|
-
order:
|
|
14
|
+
field: i.field,
|
|
15
|
+
order: s,
|
|
16
16
|
visible: !0
|
|
17
17
|
// If it's in _columns, it's visible (hidden columns are filtered out)
|
|
18
|
-
}, r =
|
|
19
|
-
r.__renderedWidth !== void 0 ? l.width = r.__renderedWidth :
|
|
20
|
-
const a = n.get(
|
|
18
|
+
}, r = i;
|
|
19
|
+
r.__renderedWidth !== void 0 ? l.width = r.__renderedWidth : i.width !== void 0 && (l.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
|
|
20
|
+
const a = n.get(i.field);
|
|
21
21
|
a && (l.sort = a);
|
|
22
22
|
for (const f of e)
|
|
23
23
|
if (f.getColumnState) {
|
|
24
|
-
const p = f.getColumnState(
|
|
24
|
+
const p = f.getColumnState(i.field);
|
|
25
25
|
p && Object.assign(l, p);
|
|
26
26
|
}
|
|
27
27
|
return l;
|
|
@@ -30,16 +30,16 @@ function ae(o, e) {
|
|
|
30
30
|
}
|
|
31
31
|
function ge(o, e, t, n) {
|
|
32
32
|
if (!e.columns || e.columns.length === 0) return;
|
|
33
|
-
const
|
|
34
|
-
const a =
|
|
33
|
+
const i = new Map(e.columns.map((r) => [r.field, r])), s = t.map((r) => {
|
|
34
|
+
const a = i.get(r.field);
|
|
35
35
|
if (!a) return r;
|
|
36
36
|
const f = { ...r };
|
|
37
37
|
return a.width !== void 0 && (f.width = a.width, f.__renderedWidth = a.width), a.visible !== void 0 && (f.hidden = !a.visible), f;
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
const f =
|
|
39
|
+
s.sort((r, a) => {
|
|
40
|
+
const f = i.get(r.field)?.order ?? 1 / 0, p = i.get(a.field)?.order ?? 1 / 0;
|
|
41
41
|
return f - p;
|
|
42
|
-
}), o._columns =
|
|
42
|
+
}), o._columns = s;
|
|
43
43
|
const l = e.columns.filter((r) => r.sort !== void 0).sort((r, a) => (r.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
|
|
44
44
|
if (l.length > 0) {
|
|
45
45
|
const r = l[0];
|
|
@@ -59,12 +59,12 @@ function me(o, e, t) {
|
|
|
59
59
|
return () => {
|
|
60
60
|
n !== null && clearTimeout(n), n = setTimeout(() => {
|
|
61
61
|
n = null;
|
|
62
|
-
const
|
|
63
|
-
t(
|
|
62
|
+
const i = ae(o, e());
|
|
63
|
+
t(i);
|
|
64
64
|
}, 100);
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const M = {
|
|
68
68
|
STRETCH: "stretch",
|
|
69
69
|
FIXED: "fixed"
|
|
70
70
|
};
|
|
@@ -73,20 +73,20 @@ function ve(o) {
|
|
|
73
73
|
}
|
|
74
74
|
function ce(o, e) {
|
|
75
75
|
if (e && e.length) {
|
|
76
|
-
const
|
|
76
|
+
const s = {};
|
|
77
77
|
return e.forEach((l) => {
|
|
78
|
-
l.type && (
|
|
79
|
-
}), { columns: e, typeMap:
|
|
80
|
-
}
|
|
81
|
-
const t = o[0] || {}, n = Object.keys(t).map((
|
|
82
|
-
const l = t[
|
|
83
|
-
return { field:
|
|
84
|
-
}),
|
|
85
|
-
return n.forEach((
|
|
86
|
-
s
|
|
87
|
-
}), { columns: n, typeMap:
|
|
88
|
-
}
|
|
89
|
-
const Ce = /{{\s*([^}]+)\s*}}/g,
|
|
78
|
+
l.type && (s[l.field] = l.type);
|
|
79
|
+
}), { columns: e, typeMap: s };
|
|
80
|
+
}
|
|
81
|
+
const t = o[0] || {}, n = Object.keys(t).map((s) => {
|
|
82
|
+
const l = t[s], r = ve(l);
|
|
83
|
+
return { field: s, header: s.charAt(0).toUpperCase() + s.slice(1), type: r };
|
|
84
|
+
}), i = {};
|
|
85
|
+
return n.forEach((s) => {
|
|
86
|
+
i[s.field] = s.type || "string";
|
|
87
|
+
}), { columns: n, typeMap: i };
|
|
88
|
+
}
|
|
89
|
+
const Ce = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, Ee = /__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/, Re = /* @__PURE__ */ new Set([
|
|
90
90
|
"script",
|
|
91
91
|
"iframe",
|
|
92
92
|
"object",
|
|
@@ -112,7 +112,7 @@ const Ce = /{{\s*([^}]+)\s*}}/g, R = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>
|
|
|
112
112
|
"xmp",
|
|
113
113
|
"listing"
|
|
114
114
|
]), U = /^on\w+$/i, _e = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), Ae = /^\s*(javascript|vbscript|data|blob):/i;
|
|
115
|
-
function
|
|
115
|
+
function z(o) {
|
|
116
116
|
if (!o || typeof o != "string") return "";
|
|
117
117
|
if (o.indexOf("<") === -1) return o;
|
|
118
118
|
const e = document.createElement("template");
|
|
@@ -121,34 +121,34 @@ function N(o) {
|
|
|
121
121
|
function Se(o) {
|
|
122
122
|
const e = [], t = o.querySelectorAll("*");
|
|
123
123
|
for (const n of t) {
|
|
124
|
-
const
|
|
125
|
-
if (Re.has(
|
|
124
|
+
const i = n.tagName.toLowerCase();
|
|
125
|
+
if (Re.has(i)) {
|
|
126
126
|
e.push(n);
|
|
127
127
|
continue;
|
|
128
128
|
}
|
|
129
|
-
if ((
|
|
129
|
+
if ((i === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
|
|
130
130
|
(r) => U.test(r.name) || r.name === "href" || r.name === "xlink:href"
|
|
131
131
|
)) {
|
|
132
132
|
e.push(n);
|
|
133
133
|
continue;
|
|
134
134
|
}
|
|
135
|
-
const
|
|
135
|
+
const s = [];
|
|
136
136
|
for (const l of n.attributes) {
|
|
137
137
|
const r = l.name.toLowerCase();
|
|
138
138
|
if (U.test(r)) {
|
|
139
|
-
|
|
139
|
+
s.push(l.name);
|
|
140
140
|
continue;
|
|
141
141
|
}
|
|
142
142
|
if (_e.has(r) && Ae.test(l.value)) {
|
|
143
|
-
|
|
143
|
+
s.push(l.name);
|
|
144
144
|
continue;
|
|
145
145
|
}
|
|
146
146
|
if (r === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(l.value)) {
|
|
147
|
-
|
|
147
|
+
s.push(l.name);
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
s.forEach((l) => n.removeAttribute(l));
|
|
152
152
|
}
|
|
153
153
|
e.forEach((n) => n.remove());
|
|
154
154
|
}
|
|
@@ -157,28 +157,28 @@ function de(o, e) {
|
|
|
157
157
|
const t = [], n = o.replace(Ce, (r, a) => {
|
|
158
158
|
const f = xe(a, e);
|
|
159
159
|
return t.push({ expr: a.trim(), result: f }), f;
|
|
160
|
-
}),
|
|
161
|
-
return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) ||
|
|
160
|
+
}), i = Te(n), s = t.length && t.every((r) => r.result === "" || r.result === A);
|
|
161
|
+
return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || s ? "" : i;
|
|
162
162
|
}
|
|
163
163
|
function xe(o, e) {
|
|
164
|
-
if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return
|
|
165
|
-
if (o === "value") return e.value == null ?
|
|
164
|
+
if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return A;
|
|
165
|
+
if (o === "value") return e.value == null ? A : String(e.value);
|
|
166
166
|
if (o.startsWith("row.") && !/[()?]/.test(o) && !o.includes(":")) {
|
|
167
|
-
const n = o.slice(4),
|
|
168
|
-
return
|
|
167
|
+
const n = o.slice(4), i = e.row ? e.row[n] : void 0;
|
|
168
|
+
return i == null ? A : String(i);
|
|
169
169
|
}
|
|
170
|
-
if (o.length > 80 || !ye.test(o) || Ee.test(o)) return
|
|
170
|
+
if (o.length > 80 || !ye.test(o) || Ee.test(o)) return A;
|
|
171
171
|
const t = o.match(/\./g);
|
|
172
|
-
if (t && t.length > 1) return
|
|
172
|
+
if (t && t.length > 1) return A;
|
|
173
173
|
try {
|
|
174
|
-
const
|
|
175
|
-
return /Reflect|Proxy|ownKeys/.test(
|
|
174
|
+
const i = new Function("value", "row", `return (${o});`)(e.value, e.row), s = i == null ? "" : String(i);
|
|
175
|
+
return /Reflect|Proxy|ownKeys/.test(s) ? A : s || A;
|
|
176
176
|
} catch {
|
|
177
|
-
return
|
|
177
|
+
return A;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
function Te(o) {
|
|
181
|
-
return o && o.replace(new RegExp(
|
|
181
|
+
return o && o.replace(new RegExp(A, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
182
182
|
}
|
|
183
183
|
function Le(o) {
|
|
184
184
|
if (/Reflect|Proxy|ownKeys/.test(o.textContent || "")) {
|
|
@@ -200,15 +200,15 @@ function ke(o) {
|
|
|
200
200
|
return Array.from(o.querySelectorAll("tbw-grid-column")).map((t) => {
|
|
201
201
|
const n = t.getAttribute("field") || "";
|
|
202
202
|
if (!n) return null;
|
|
203
|
-
const
|
|
203
|
+
const i = t.getAttribute("type") || void 0, l = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, r = t.getAttribute("header") || void 0, a = t.hasAttribute("sortable"), f = t.hasAttribute("editable"), p = { field: n, type: l, header: r, sortable: a, editable: f };
|
|
204
204
|
t.hasAttribute("resizable") && (p.resizable = !0), t.hasAttribute("sizable") && (p.resizable = !0);
|
|
205
205
|
const w = t.getAttribute("options");
|
|
206
|
-
w && (p.options = w.split(",").map((
|
|
207
|
-
const [
|
|
208
|
-
return { value:
|
|
206
|
+
w && (p.options = w.split(",").map((d) => {
|
|
207
|
+
const [g, m] = d.includes(":") ? d.split(":") : [d.trim(), d.trim()];
|
|
208
|
+
return { value: g.trim(), label: m?.trim() || g.trim() };
|
|
209
209
|
}));
|
|
210
|
-
const
|
|
211
|
-
return
|
|
210
|
+
const u = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), h = t.querySelector("tbw-grid-column-header");
|
|
211
|
+
return u && (p.__viewTemplate = u), c && (p.__editorTemplate = c), h && (p.__headerTemplate = h), p;
|
|
212
212
|
}).filter((t) => !!t);
|
|
213
213
|
}
|
|
214
214
|
function Pe(o, e) {
|
|
@@ -216,14 +216,14 @@ function Pe(o, e) {
|
|
|
216
216
|
if (!o || !o.length) return e || [];
|
|
217
217
|
if (!e || !e.length) return o;
|
|
218
218
|
const t = {};
|
|
219
|
-
e.forEach((
|
|
220
|
-
const n = o.map((
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
223
|
-
const l = { ...
|
|
224
|
-
return
|
|
219
|
+
e.forEach((i) => t[i.field] = i);
|
|
220
|
+
const n = o.map((i) => {
|
|
221
|
+
const s = t[i.field];
|
|
222
|
+
if (!s) return i;
|
|
223
|
+
const l = { ...i };
|
|
224
|
+
return s.header && !l.header && (l.header = s.header), s.type && !l.type && (l.type = s.type), l.sortable = i.sortable || s.sortable, (i.resizable === !0 || s.resizable === !0) && (l.resizable = !0), l.editable = i.editable || s.editable, s.__viewTemplate && (l.__viewTemplate = s.__viewTemplate), s.__editorTemplate && (l.__editorTemplate = s.__editorTemplate), s.__headerTemplate && (l.__headerTemplate = s.__headerTemplate), delete t[i.field], l;
|
|
225
225
|
});
|
|
226
|
-
return Object.keys(t).forEach((
|
|
226
|
+
return Object.keys(t).forEach((i) => n.push(t[i])), n;
|
|
227
227
|
}
|
|
228
228
|
function B(o, e) {
|
|
229
229
|
try {
|
|
@@ -233,39 +233,39 @@ function B(o, e) {
|
|
|
233
233
|
const t = o.getAttribute("part");
|
|
234
234
|
t ? t.split(/\s+/).includes(e) || o.setAttribute("part", t + " " + e) : o.setAttribute("part", e);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function Me(o) {
|
|
237
237
|
o.__lightDomColumnsCache || (o.__originalColumnNodes = Array.from(
|
|
238
238
|
o.querySelectorAll("tbw-grid-column")
|
|
239
239
|
), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? ke(o) : []);
|
|
240
240
|
const e = o.__lightDomColumnsCache, t = Pe(o._columns, e);
|
|
241
|
-
t.forEach((
|
|
242
|
-
|
|
241
|
+
t.forEach((i) => {
|
|
242
|
+
i.__viewTemplate && !i.__compiledView && (i.__compiledView = X(i.__viewTemplate.innerHTML)), i.__editorTemplate && !i.__compiledEditor && (i.__compiledEditor = X(i.__editorTemplate.innerHTML));
|
|
243
243
|
});
|
|
244
244
|
const { columns: n } = ce(o._rows, t);
|
|
245
245
|
o._columns = n;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
const e = o.effectiveConfig?.fitMode || o.fitMode ||
|
|
249
|
-
if (e !==
|
|
247
|
+
function Oe(o) {
|
|
248
|
+
const e = o.effectiveConfig?.fitMode || o.fitMode || M.STRETCH;
|
|
249
|
+
if (e !== M.STRETCH && e !== M.FIXED || o.__didInitialAutoSize || !o.isConnected) return;
|
|
250
250
|
const t = o.headerRowEl?.children || [];
|
|
251
251
|
if (!t.length) return;
|
|
252
252
|
let n = !1;
|
|
253
|
-
o.visibleColumns.forEach((
|
|
254
|
-
if (
|
|
255
|
-
const l = t[
|
|
253
|
+
o.visibleColumns.forEach((i, s) => {
|
|
254
|
+
if (i.width) return;
|
|
255
|
+
const l = t[s];
|
|
256
256
|
let r = l ? l.scrollWidth : 0;
|
|
257
257
|
for (const a of o.rowPool) {
|
|
258
|
-
const f = a.children[
|
|
258
|
+
const f = a.children[s];
|
|
259
259
|
if (f) {
|
|
260
260
|
const p = f.scrollWidth;
|
|
261
261
|
p > r && (r = p);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
r > 0 && (
|
|
264
|
+
r > 0 && (i.width = r + 2, i.__autoSized = !0, n = !0);
|
|
265
265
|
}), n && he(o), o.__didInitialAutoSize = !0;
|
|
266
266
|
}
|
|
267
267
|
function he(o) {
|
|
268
|
-
(o.effectiveConfig?.fitMode || o.fitMode ||
|
|
268
|
+
(o.effectiveConfig?.fitMode || o.fitMode || M.STRETCH) === M.STRETCH ? o.gridTemplate = o.visibleColumns.map((t) => {
|
|
269
269
|
if (t.width) return `${t.width}px`;
|
|
270
270
|
const n = t.minWidth;
|
|
271
271
|
return n != null ? `minmax(${n}px, 1fr)` : "1fr";
|
|
@@ -296,21 +296,21 @@ function De(o) {
|
|
|
296
296
|
case "typeahead":
|
|
297
297
|
return (e) => {
|
|
298
298
|
const t = document.createElement("select");
|
|
299
|
-
e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((
|
|
299
|
+
e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((s) => {
|
|
300
300
|
const l = document.createElement("option");
|
|
301
|
-
l.value = String(
|
|
301
|
+
l.value = String(s.value), l.textContent = s.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(s.value) || !e.column.multi && e.value === s.value) && (l.selected = !0), t.appendChild(l);
|
|
302
302
|
});
|
|
303
|
-
const
|
|
303
|
+
const i = () => {
|
|
304
304
|
if (e.column.multi) {
|
|
305
|
-
const
|
|
305
|
+
const s = [];
|
|
306
306
|
Array.from(t.selectedOptions).forEach((l) => {
|
|
307
|
-
|
|
308
|
-
}), e.commit(
|
|
307
|
+
s.push(l.value);
|
|
308
|
+
}), e.commit(s);
|
|
309
309
|
} else
|
|
310
310
|
e.commit(t.value);
|
|
311
311
|
};
|
|
312
|
-
return t.addEventListener("change",
|
|
313
|
-
|
|
312
|
+
return t.addEventListener("change", i), t.addEventListener("blur", i), t.addEventListener("keydown", (s) => {
|
|
313
|
+
s.key === "Escape" && e.cancel();
|
|
314
314
|
}), t.focus(), t;
|
|
315
315
|
};
|
|
316
316
|
default:
|
|
@@ -325,22 +325,22 @@ function De(o) {
|
|
|
325
325
|
function He(o, e) {
|
|
326
326
|
if (o.dispatchKeyDown?.(e))
|
|
327
327
|
return;
|
|
328
|
-
const t = o._rows.length - 1, n = o.visibleColumns.length - 1,
|
|
328
|
+
const t = o._rows.length - 1, n = o.visibleColumns.length - 1, i = o.activeEditRows !== void 0 && o.activeEditRows !== -1, l = o.visibleColumns[o.focusCol]?.type, r = e.composedPath ? e.composedPath() : [], a = r && r.length ? r[0] : e.target, f = (p) => {
|
|
329
329
|
if (!p) return !1;
|
|
330
330
|
const w = p.tagName;
|
|
331
331
|
return !!(w === "INPUT" || w === "SELECT" || w === "TEXTAREA" || p.isContentEditable);
|
|
332
332
|
};
|
|
333
|
-
if (!(f(a) && (e.key === "Home" || e.key === "End")) && !(f(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(
|
|
333
|
+
if (!(f(a) && (e.key === "Home" || e.key === "End")) && !(f(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(i && (l === "select" || l === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
|
|
334
334
|
switch (e.key) {
|
|
335
335
|
case "Tab": {
|
|
336
|
-
e.preventDefault(), !e.shiftKey ? o.focusCol < n ? o.focusCol += 1 : (typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow < t && (o.focusRow += 1, o.focusCol = 0)) : o.focusCol > 0 ? o.focusCol -= 1 : o.focusRow > 0 && (typeof o.commitActiveRowEdit == "function" && o.activeEditRows === o.focusRow && o.commitActiveRowEdit(), o.focusRow -= 1, o.focusCol = n),
|
|
336
|
+
e.preventDefault(), !e.shiftKey ? o.focusCol < n ? o.focusCol += 1 : (typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow < t && (o.focusRow += 1, o.focusCol = 0)) : o.focusCol > 0 ? o.focusCol -= 1 : o.focusRow > 0 && (typeof o.commitActiveRowEdit == "function" && o.activeEditRows === o.focusRow && o.commitActiveRowEdit(), o.focusRow -= 1, o.focusCol = n), O(o);
|
|
337
337
|
return;
|
|
338
338
|
}
|
|
339
339
|
case "ArrowDown":
|
|
340
|
-
|
|
340
|
+
i && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.min(t, o.focusRow + 1), e.preventDefault();
|
|
341
341
|
break;
|
|
342
342
|
case "ArrowUp":
|
|
343
|
-
|
|
343
|
+
i && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.max(0, o.focusRow - 1), e.preventDefault();
|
|
344
344
|
break;
|
|
345
345
|
case "ArrowRight":
|
|
346
346
|
o.focusCol = Math.min(n, o.focusCol + 1), e.preventDefault();
|
|
@@ -363,27 +363,27 @@ function He(o, e) {
|
|
|
363
363
|
case "Enter":
|
|
364
364
|
return typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(o.focusRow) : o.dispatchEvent(
|
|
365
365
|
new CustomEvent("activate-cell", { detail: { row: o.focusRow, col: o.focusCol } })
|
|
366
|
-
),
|
|
366
|
+
), O(o);
|
|
367
367
|
default:
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
370
|
-
|
|
370
|
+
O(o);
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
function
|
|
373
|
+
function O(o) {
|
|
374
374
|
if (o.virtualization?.enabled) {
|
|
375
|
-
const { rowHeight:
|
|
376
|
-
l <
|
|
375
|
+
const { rowHeight: i } = o.virtualization, s = o, l = o.focusRow * i;
|
|
376
|
+
l < s.scrollTop ? s.scrollTop = l : l + i > s.scrollTop + s.clientHeight && (s.scrollTop = l - s.clientHeight + i);
|
|
377
377
|
}
|
|
378
|
-
o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((
|
|
379
|
-
|
|
378
|
+
o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((i) => i.classList.remove("cell-focus")), Array.from(o.bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((i) => {
|
|
379
|
+
i.setAttribute("aria-selected", "false");
|
|
380
380
|
});
|
|
381
381
|
const e = o.focusRow, t = o.virtualization.start ?? 0, n = o.virtualization.end ?? o._rows.length;
|
|
382
382
|
if (e >= t && e < n) {
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
if (
|
|
386
|
-
const l =
|
|
383
|
+
const s = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
|
|
384
|
+
if (s) {
|
|
385
|
+
if (s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && s.classList.contains("editing")) {
|
|
386
|
+
const l = s.querySelector(
|
|
387
387
|
'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
|
|
388
388
|
);
|
|
389
389
|
if (l && document.activeElement !== l)
|
|
@@ -391,10 +391,10 @@ function M(o) {
|
|
|
391
391
|
l.focus();
|
|
392
392
|
} catch {
|
|
393
393
|
}
|
|
394
|
-
} else if (!
|
|
395
|
-
|
|
394
|
+
} else if (!s.contains(document.activeElement)) {
|
|
395
|
+
s.hasAttribute("tabindex") || s.setAttribute("tabindex", "-1");
|
|
396
396
|
try {
|
|
397
|
-
|
|
397
|
+
s.focus({ preventScroll: !0 });
|
|
398
398
|
} catch {
|
|
399
399
|
}
|
|
400
400
|
}
|
|
@@ -405,125 +405,131 @@ const ze = "__cellDisplayCache", Ne = "__cellCacheEpoch";
|
|
|
405
405
|
function j(o) {
|
|
406
406
|
o[ze] = void 0, o[Ne] = void 0, o.__hasSpecialColumns = void 0;
|
|
407
407
|
}
|
|
408
|
-
function qe(o, e, t, n,
|
|
409
|
-
const
|
|
408
|
+
function qe(o, e, t, n, i) {
|
|
409
|
+
const s = Math.max(0, t - e), l = o.bodyEl, r = o.visibleColumns, a = r.length;
|
|
410
410
|
let f = o.__cachedHeaderRowCount;
|
|
411
|
-
for (f === void 0 && (f = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = f); o.rowPool.length <
|
|
411
|
+
for (f === void 0 && (f = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = f); o.rowPool.length < s; ) {
|
|
412
412
|
const w = document.createElement("div");
|
|
413
|
-
w.className = "data-grid-row", w.setAttribute("role", "row"), w.addEventListener("click", (
|
|
413
|
+
w.className = "data-grid-row", w.setAttribute("role", "row"), w.addEventListener("click", (u) => Z(o, u, w, !1)), w.addEventListener("dblclick", (u) => Z(o, u, w, !0)), o.rowPool.push(w);
|
|
414
414
|
}
|
|
415
|
-
if (o.rowPool.length >
|
|
416
|
-
for (let w =
|
|
417
|
-
const
|
|
418
|
-
|
|
415
|
+
if (o.rowPool.length > s) {
|
|
416
|
+
for (let w = s; w < o.rowPool.length; w++) {
|
|
417
|
+
const u = o.rowPool[w];
|
|
418
|
+
u.parentNode === l && u.remove();
|
|
419
419
|
}
|
|
420
|
-
o.rowPool.length =
|
|
420
|
+
o.rowPool.length = s;
|
|
421
421
|
}
|
|
422
|
-
const p =
|
|
423
|
-
for (let w = 0; w <
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
426
|
-
|
|
422
|
+
const p = i && o.__hasRenderRowPlugins !== !1;
|
|
423
|
+
for (let w = 0; w < s; w++) {
|
|
424
|
+
const u = e + w, c = o._rows[u], h = o.rowPool[w];
|
|
425
|
+
if (h.setAttribute("aria-rowindex", String(u + f + 1)), p && i(c, h, u)) {
|
|
426
|
+
h.__epoch = n, h.__rowDataRef = c, h.parentNode !== l && l.appendChild(h);
|
|
427
427
|
continue;
|
|
428
428
|
}
|
|
429
|
-
const
|
|
430
|
-
let
|
|
431
|
-
if (
|
|
432
|
-
for (let
|
|
433
|
-
if (r[
|
|
434
|
-
|
|
429
|
+
const d = h.__epoch, g = h.__rowDataRef, m = h.children.length, R = d === n && m === a, E = g !== c;
|
|
430
|
+
let _ = !1;
|
|
431
|
+
if (R && E) {
|
|
432
|
+
for (let S = 0; S < a; S++)
|
|
433
|
+
if (r[S].externalView && !h.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
|
|
434
|
+
_ = !0;
|
|
435
435
|
break;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
!
|
|
439
|
-
const
|
|
440
|
-
|
|
438
|
+
!R || _ ? (h.__isCustomRow && (h.className = "data-grid-row", h.setAttribute("role", "row"), h.__isCustomRow = !1), F(o, h, c, u), h.__epoch = n, h.__rowDataRef = c) : E ? (Y(o, h, c, u), h.__rowDataRef = c) : Y(o, h, c, u);
|
|
439
|
+
const b = o._changedRowIndices.has(u), v = h.classList.contains("changed");
|
|
440
|
+
b !== v && h.classList.toggle("changed", b), h.parentNode !== l && l.appendChild(h);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
function Y(o, e, t, n) {
|
|
444
|
-
const
|
|
444
|
+
const i = e.children, s = o.visibleColumns, l = s.length, r = i.length, a = l < r ? l : r, f = o.focusRow, p = o.focusCol;
|
|
445
445
|
let w = o.__hasSpecialColumns;
|
|
446
446
|
if (w === void 0) {
|
|
447
447
|
w = !1;
|
|
448
448
|
for (let c = 0; c < l; c++) {
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
449
|
+
const h = s[c];
|
|
450
|
+
if (h.__viewTemplate || h.__compiledView || h.viewRenderer || h.externalView || h.format || h.type === "date" || h.type === "boolean") {
|
|
451
451
|
w = !0;
|
|
452
452
|
break;
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
o.__hasSpecialColumns = w;
|
|
456
456
|
}
|
|
457
|
-
const
|
|
457
|
+
const u = String(n);
|
|
458
458
|
if (!w) {
|
|
459
459
|
for (let c = 0; c < a; c++) {
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
const
|
|
463
|
-
|
|
460
|
+
const h = i[c], d = t[s[c].field];
|
|
461
|
+
h.textContent = d == null ? "" : String(d), h.getAttribute("data-row") !== u && h.setAttribute("data-row", u);
|
|
462
|
+
const g = f === n && p === c, m = h.classList.contains("cell-focus");
|
|
463
|
+
g !== m && (h.classList.toggle("cell-focus", g), h.setAttribute("aria-selected", String(g)));
|
|
464
464
|
}
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
467
|
for (let c = 0; c < a; c++)
|
|
468
|
-
if (
|
|
468
|
+
if (s[c].externalView && !i[c].querySelector("[data-external-view]")) {
|
|
469
469
|
F(o, e, t, n);
|
|
470
470
|
return;
|
|
471
471
|
}
|
|
472
472
|
for (let c = 0; c < a; c++) {
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
473
|
+
const h = s[c], d = i[c];
|
|
474
|
+
d.getAttribute("data-row") !== u && d.setAttribute("data-row", u);
|
|
475
|
+
const g = f === n && p === c, m = d.classList.contains("cell-focus");
|
|
476
|
+
if (g !== m && (d.classList.toggle("cell-focus", g), d.setAttribute("aria-selected", String(g))), d.classList.contains("editing")) continue;
|
|
477
|
+
if (h.viewRenderer) {
|
|
478
|
+
const E = t[h.field], _ = h.viewRenderer({ row: t, value: E, field: h.field, column: h });
|
|
479
|
+
typeof _ == "string" ? d.innerHTML = z(_) : _ ? (d.innerHTML = "", d.appendChild(_)) : d.textContent = E == null ? "" : String(E);
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
if (h.__viewTemplate || h.__compiledView || h.externalView)
|
|
477
483
|
continue;
|
|
478
|
-
const
|
|
479
|
-
let
|
|
480
|
-
if (
|
|
484
|
+
const C = t[h.field];
|
|
485
|
+
let R;
|
|
486
|
+
if (h.format)
|
|
481
487
|
try {
|
|
482
|
-
const
|
|
483
|
-
|
|
488
|
+
const E = h.format(C, t);
|
|
489
|
+
R = E == null ? "" : String(E);
|
|
484
490
|
} catch {
|
|
485
|
-
|
|
491
|
+
R = C == null ? "" : String(C);
|
|
486
492
|
}
|
|
487
|
-
else if (
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
else if (
|
|
491
|
-
|
|
493
|
+
else if (h.type === "date")
|
|
494
|
+
if (C == null || C === "")
|
|
495
|
+
R = "";
|
|
496
|
+
else if (C instanceof Date)
|
|
497
|
+
R = isNaN(C.getTime()) ? "" : C.toLocaleDateString();
|
|
492
498
|
else {
|
|
493
|
-
const
|
|
494
|
-
|
|
499
|
+
const E = new Date(C);
|
|
500
|
+
R = isNaN(E.getTime()) ? "" : E.toLocaleDateString();
|
|
495
501
|
}
|
|
496
|
-
else
|
|
497
|
-
|
|
502
|
+
else h.type === "boolean" ? (R = C ? "🗹" : "☐", d.setAttribute("aria-checked", String(!!C))) : R = C == null ? "" : String(C);
|
|
503
|
+
d.textContent = R;
|
|
498
504
|
}
|
|
499
505
|
}
|
|
500
506
|
function F(o, e, t, n) {
|
|
501
507
|
e.innerHTML = "";
|
|
502
|
-
const
|
|
503
|
-
for (let w = 0; w <
|
|
504
|
-
const
|
|
505
|
-
c.className = "cell", B(c, "cell"),
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
let
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
508
|
+
const i = o.visibleColumns, s = i.length, l = o.focusRow, r = o.focusCol, a = o.effectiveConfig?.editOn || o.editOn, f = o, p = document.createDocumentFragment();
|
|
509
|
+
for (let w = 0; w < s; w++) {
|
|
510
|
+
const u = i[w], c = document.createElement("div");
|
|
511
|
+
c.className = "cell", B(c, "cell"), u.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(w)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(w + 1)), u.type && c.setAttribute("data-type", u.type);
|
|
512
|
+
const h = u.sticky;
|
|
513
|
+
h === "left" ? c.classList.add("sticky-left") : h === "right" && c.classList.add("sticky-right");
|
|
514
|
+
let d = t[u.field];
|
|
515
|
+
const g = u.format;
|
|
516
|
+
if (g)
|
|
511
517
|
try {
|
|
512
|
-
|
|
518
|
+
d = g(d, t);
|
|
513
519
|
} catch {
|
|
514
520
|
}
|
|
515
|
-
const
|
|
516
|
-
let
|
|
517
|
-
if (
|
|
518
|
-
const
|
|
519
|
-
typeof
|
|
520
|
-
} else if (
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
521
|
+
const m = u.__compiledView, C = u.__viewTemplate, R = u.viewRenderer, E = u.externalView;
|
|
522
|
+
let _ = !1;
|
|
523
|
+
if (R) {
|
|
524
|
+
const b = R({ row: t, value: d, field: u.field, column: u });
|
|
525
|
+
typeof b == "string" ? (c.innerHTML = z(b), _ = !0) : b ? c.appendChild(b) : c.textContent = d == null ? "" : String(d);
|
|
526
|
+
} else if (E) {
|
|
527
|
+
const b = E, v = document.createElement("div");
|
|
528
|
+
v.setAttribute("data-external-view", ""), v.setAttribute("data-field", u.field), c.appendChild(v);
|
|
529
|
+
const S = { row: t, value: d, field: u.field, column: u };
|
|
530
|
+
if (b.mount)
|
|
525
531
|
try {
|
|
526
|
-
|
|
532
|
+
b.mount({ placeholder: v, context: S, spec: b });
|
|
527
533
|
} catch {
|
|
528
534
|
}
|
|
529
535
|
else
|
|
@@ -533,86 +539,86 @@ function F(o, e, t, n) {
|
|
|
533
539
|
new CustomEvent("mount-external-view", {
|
|
534
540
|
bubbles: !0,
|
|
535
541
|
composed: !0,
|
|
536
|
-
detail: { placeholder:
|
|
542
|
+
detail: { placeholder: v, spec: b, context: S }
|
|
537
543
|
})
|
|
538
544
|
);
|
|
539
545
|
} catch {
|
|
540
546
|
}
|
|
541
547
|
});
|
|
542
|
-
|
|
543
|
-
} else if (
|
|
544
|
-
const
|
|
545
|
-
c.innerHTML =
|
|
546
|
-
} else if (
|
|
547
|
-
const
|
|
548
|
-
/Reflect\.|\bProxy\b|ownKeys\(/.test(
|
|
549
|
-
} else if (
|
|
550
|
-
if (
|
|
548
|
+
v.setAttribute("data-mounted", "");
|
|
549
|
+
} else if (m) {
|
|
550
|
+
const b = m({ row: t, value: d, field: u.field, column: u }), v = m.__blocked;
|
|
551
|
+
c.innerHTML = v ? "" : z(b), _ = !0, v && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
|
|
552
|
+
} else if (C) {
|
|
553
|
+
const b = C.innerHTML;
|
|
554
|
+
/Reflect\.|\bProxy\b|ownKeys\(/.test(b) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = z(de(b, { row: t, value: d })), _ = !0);
|
|
555
|
+
} else if (u.type === "date")
|
|
556
|
+
if (d == null || d === "")
|
|
551
557
|
c.textContent = "";
|
|
552
558
|
else {
|
|
553
|
-
let
|
|
554
|
-
if (
|
|
555
|
-
else if (typeof
|
|
556
|
-
const
|
|
557
|
-
isNaN(
|
|
559
|
+
let b = null;
|
|
560
|
+
if (d instanceof Date) b = d;
|
|
561
|
+
else if (typeof d == "number" || typeof d == "string") {
|
|
562
|
+
const v = new Date(d);
|
|
563
|
+
isNaN(v.getTime()) || (b = v);
|
|
558
564
|
}
|
|
559
|
-
c.textContent =
|
|
565
|
+
c.textContent = b ? b.toLocaleDateString() : "";
|
|
560
566
|
}
|
|
561
|
-
else if (
|
|
562
|
-
const
|
|
563
|
-
c.innerHTML =
|
|
567
|
+
else if (u.type === "boolean") {
|
|
568
|
+
const b = !!d;
|
|
569
|
+
c.innerHTML = b ? "🗹" : "☐", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(b)), c.setAttribute("aria-label", String(b));
|
|
564
570
|
} else
|
|
565
|
-
c.textContent =
|
|
566
|
-
if (
|
|
571
|
+
c.textContent = d == null ? "" : String(d);
|
|
572
|
+
if (_) {
|
|
567
573
|
Le(c);
|
|
568
|
-
const
|
|
569
|
-
/Proxy|Reflect\.ownKeys/.test(
|
|
570
|
-
}
|
|
571
|
-
c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""),
|
|
572
|
-
o.focusRow = n, o.focusCol = w,
|
|
573
|
-
}), a === "click" ? c.addEventListener("click", (
|
|
574
|
-
c.classList.contains("editing") || (
|
|
575
|
-
}) : c.addEventListener("dblclick", (
|
|
576
|
-
|
|
577
|
-
const
|
|
578
|
-
if (
|
|
579
|
-
const
|
|
580
|
-
for (let k = 0; k <
|
|
574
|
+
const b = c.textContent || "";
|
|
575
|
+
/Proxy|Reflect\.ownKeys/.test(b) && (c.textContent = b.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
|
|
576
|
+
}
|
|
577
|
+
c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), u.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
|
|
578
|
+
o.focusRow = n, o.focusCol = w, O(o);
|
|
579
|
+
}), a === "click" ? c.addEventListener("click", (b) => {
|
|
580
|
+
c.classList.contains("editing") || (b.stopPropagation(), o.focusRow = n, o.focusCol = w, L(o, t, n, u, c));
|
|
581
|
+
}) : c.addEventListener("dblclick", (b) => {
|
|
582
|
+
b.stopPropagation(), T(o, n, t);
|
|
583
|
+
const v = o.findRenderedRowElement?.(n);
|
|
584
|
+
if (v) {
|
|
585
|
+
const S = v.children;
|
|
586
|
+
for (let k = 0; k < S.length; k++) {
|
|
581
587
|
const D = o.visibleColumns[k];
|
|
582
|
-
D && D.editable && L(o, t, n, D,
|
|
588
|
+
D && D.editable && L(o, t, n, D, S[k]);
|
|
583
589
|
}
|
|
584
590
|
}
|
|
585
|
-
}), c.addEventListener("keydown", (
|
|
586
|
-
if ((
|
|
587
|
-
|
|
588
|
-
const
|
|
591
|
+
}), c.addEventListener("keydown", (b) => {
|
|
592
|
+
if ((u.type === "select" || u.type === "typeahead") && !c.classList.contains("editing") && b.key === "Enter") {
|
|
593
|
+
b.preventDefault(), o.activeEditRows !== n && T(o, n, t), L(o, t, n, u, c), setTimeout(() => {
|
|
594
|
+
const v = c.querySelector("select");
|
|
589
595
|
try {
|
|
590
|
-
|
|
596
|
+
v?.showPicker?.();
|
|
591
597
|
} catch {
|
|
592
598
|
}
|
|
593
|
-
|
|
599
|
+
v?.focus();
|
|
594
600
|
}, 0);
|
|
595
601
|
return;
|
|
596
602
|
}
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
const
|
|
600
|
-
$(o, n,
|
|
603
|
+
if (u.type === "boolean" && b.key === " " && !c.classList.contains("editing")) {
|
|
604
|
+
b.preventDefault(), o.activeEditRows !== n && T(o, n, t);
|
|
605
|
+
const v = !t[u.field];
|
|
606
|
+
$(o, n, u, v, t), c.innerHTML = v ? "🗹" : "☐", c.setAttribute("aria-label", String(!!v));
|
|
601
607
|
return;
|
|
602
608
|
}
|
|
603
|
-
if (
|
|
604
|
-
|
|
609
|
+
if (b.key === "Enter" && !c.classList.contains("editing")) {
|
|
610
|
+
b.preventDefault(), o.focusRow = n, o.focusCol = w, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : L(o, t, n, u, c);
|
|
605
611
|
return;
|
|
606
612
|
}
|
|
607
|
-
if (
|
|
608
|
-
|
|
613
|
+
if (b.key === "F2" && !c.classList.contains("editing")) {
|
|
614
|
+
b.preventDefault(), L(o, t, n, u, c);
|
|
609
615
|
return;
|
|
610
616
|
}
|
|
611
|
-
})) :
|
|
612
|
-
if (
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
o.activeEditRows !== n && T(o, n, t), $(o, n,
|
|
617
|
+
})) : u.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (b) => {
|
|
618
|
+
if (b.key === " ") {
|
|
619
|
+
b.preventDefault();
|
|
620
|
+
const v = !t[u.field];
|
|
621
|
+
o.activeEditRows !== n && T(o, n, t), $(o, n, u, v, t), c.innerHTML = v ? "🗹" : "☐", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!v)), c.setAttribute("aria-label", String(!!v));
|
|
616
622
|
}
|
|
617
623
|
})), l === n && r === w ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), p.appendChild(c);
|
|
618
624
|
}
|
|
@@ -620,19 +626,19 @@ function F(o, e, t, n) {
|
|
|
620
626
|
}
|
|
621
627
|
function Z(o, e, t, n) {
|
|
622
628
|
if (e.target?.closest(".resize-handle")) return;
|
|
623
|
-
const
|
|
624
|
-
if (!
|
|
625
|
-
const
|
|
626
|
-
if (isNaN(
|
|
627
|
-
const l = o._rows[
|
|
629
|
+
const i = t.querySelector(".cell[data-row]");
|
|
630
|
+
if (!i) return;
|
|
631
|
+
const s = Number(i.getAttribute("data-row"));
|
|
632
|
+
if (isNaN(s)) return;
|
|
633
|
+
const l = o._rows[s];
|
|
628
634
|
if (!l) return;
|
|
629
635
|
const r = e.target?.closest(".cell[data-col]");
|
|
630
636
|
if (r) {
|
|
631
637
|
const f = Number(r.getAttribute("data-col"));
|
|
632
638
|
if (!isNaN(f)) {
|
|
633
|
-
if (o.dispatchCellClick?.(e,
|
|
639
|
+
if (o.dispatchCellClick?.(e, s, f, r))
|
|
634
640
|
return;
|
|
635
|
-
o.focusRow =
|
|
641
|
+
o.focusRow = s, o.focusCol = f, O(o);
|
|
636
642
|
}
|
|
637
643
|
}
|
|
638
644
|
if (t.querySelector(".cell.editing")) {
|
|
@@ -641,11 +647,11 @@ function Z(o, e, t, n) {
|
|
|
641
647
|
f.forEach((p) => p.classList.remove("editing"));
|
|
642
648
|
}
|
|
643
649
|
const a = o.effectiveConfig?.editOn || o.editOn || "doubleClick";
|
|
644
|
-
if (a === "click" || a === "doubleClick" && n) T(o,
|
|
650
|
+
if (a === "click" || a === "doubleClick" && n) T(o, s, l);
|
|
645
651
|
else return;
|
|
646
652
|
Array.from(t.children).forEach((f, p) => {
|
|
647
653
|
const w = o.visibleColumns[p];
|
|
648
|
-
w && w.editable && L(o, l,
|
|
654
|
+
w && w.editable && L(o, l, s, w, f);
|
|
649
655
|
}), r && queueMicrotask(() => {
|
|
650
656
|
const f = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
|
|
651
657
|
if (f?.classList.contains("editing")) {
|
|
@@ -664,16 +670,16 @@ function T(o, e, t) {
|
|
|
664
670
|
}
|
|
665
671
|
function Ie(o, e, t) {
|
|
666
672
|
if (o.activeEditRows !== e) return;
|
|
667
|
-
const n = o.rowEditSnapshots.get(e),
|
|
668
|
-
if (t && n &&
|
|
669
|
-
Object.keys(n).forEach((l) =>
|
|
673
|
+
const n = o.rowEditSnapshots.get(e), i = o._rows[e];
|
|
674
|
+
if (t && n && i)
|
|
675
|
+
Object.keys(n).forEach((l) => i[l] = n[l]), o._changedRowIndices.delete(e);
|
|
670
676
|
else if (!t) {
|
|
671
677
|
const l = o._changedRowIndices.has(e);
|
|
672
678
|
o.dispatchEvent(
|
|
673
679
|
new CustomEvent("row-commit", {
|
|
674
680
|
detail: {
|
|
675
681
|
rowIndex: e,
|
|
676
|
-
row:
|
|
682
|
+
row: i,
|
|
677
683
|
changed: l,
|
|
678
684
|
changedRows: o.changedRows,
|
|
679
685
|
changedRowIndices: o.changedRowIndices
|
|
@@ -682,8 +688,8 @@ function Ie(o, e, t) {
|
|
|
682
688
|
);
|
|
683
689
|
}
|
|
684
690
|
o.rowEditSnapshots.delete(e), o.activeEditRows = -1;
|
|
685
|
-
const
|
|
686
|
-
|
|
691
|
+
const s = o.findRenderedRowElement?.(e);
|
|
692
|
+
s && (F(o, s, o._rows[e], e), o._changedRowIndices.has(e) ? s.classList.add("changed") : s.classList.remove("changed")), t && queueMicrotask(() => {
|
|
687
693
|
try {
|
|
688
694
|
o.focus();
|
|
689
695
|
const l = o.focusRow, r = o.focusCol, a = o.findRenderedRowElement?.(l);
|
|
@@ -698,18 +704,18 @@ function Ie(o, e, t) {
|
|
|
698
704
|
}
|
|
699
705
|
});
|
|
700
706
|
}
|
|
701
|
-
function $(o, e, t, n,
|
|
702
|
-
const
|
|
703
|
-
if (s
|
|
704
|
-
s
|
|
707
|
+
function $(o, e, t, n, i) {
|
|
708
|
+
const s = t.field;
|
|
709
|
+
if (i[s] === n) return;
|
|
710
|
+
i[s] = n;
|
|
705
711
|
const r = !o._changedRowIndices.has(e);
|
|
706
712
|
o._changedRowIndices.add(e);
|
|
707
713
|
const a = o.findRenderedRowElement?.(e);
|
|
708
714
|
a && a.classList.add("changed"), o.dispatchEvent(
|
|
709
715
|
new CustomEvent("cell-commit", {
|
|
710
716
|
detail: {
|
|
711
|
-
row:
|
|
712
|
-
field:
|
|
717
|
+
row: i,
|
|
718
|
+
field: s,
|
|
713
719
|
value: n,
|
|
714
720
|
rowIndex: e,
|
|
715
721
|
changedRows: o.changedRows,
|
|
@@ -719,63 +725,63 @@ function $(o, e, t, n, s) {
|
|
|
719
725
|
})
|
|
720
726
|
);
|
|
721
727
|
}
|
|
722
|
-
function L(o, e, t, n,
|
|
723
|
-
if (!n.editable || (o.activeEditRows !== t && T(o, t, e),
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
const l = (
|
|
727
|
-
$(o, t, n,
|
|
728
|
+
function L(o, e, t, n, i) {
|
|
729
|
+
if (!n.editable || (o.activeEditRows !== t && T(o, t, e), i.classList.contains("editing"))) return;
|
|
730
|
+
const s = e[n.field];
|
|
731
|
+
i.classList.add("editing");
|
|
732
|
+
const l = (u) => {
|
|
733
|
+
$(o, t, n, u, e);
|
|
728
734
|
}, r = () => {
|
|
729
|
-
e[n.field] =
|
|
730
|
-
const
|
|
731
|
-
|
|
735
|
+
e[n.field] = s;
|
|
736
|
+
const u = i.querySelector("input,textarea,select");
|
|
737
|
+
u && (typeof HTMLInputElement < "u" && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked = !!s : "value" in u && (u.value = s ?? ""));
|
|
732
738
|
}, a = document.createElement("div");
|
|
733
|
-
a.style.display = "contents",
|
|
734
|
-
const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)), w =
|
|
739
|
+
a.style.display = "contents", i.innerHTML = "", i.appendChild(a);
|
|
740
|
+
const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)), w = s;
|
|
735
741
|
if (p === "template" && f) {
|
|
736
|
-
const
|
|
737
|
-
c ?
|
|
738
|
-
|
|
739
|
-
const
|
|
740
|
-
return
|
|
742
|
+
const u = f.cloneNode(!0), c = n.__compiledEditor;
|
|
743
|
+
c ? u.innerHTML = c({ row: e, value: s, field: n.field, column: n }) : u.querySelectorAll("*").forEach((d) => {
|
|
744
|
+
d.childNodes.length === 1 && d.firstChild?.nodeType === Node.TEXT_NODE && (d.textContent = d.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (g, m) => {
|
|
745
|
+
const C = e[m];
|
|
746
|
+
return C == null ? "" : String(C);
|
|
741
747
|
}) || "");
|
|
742
748
|
});
|
|
743
|
-
const
|
|
744
|
-
if (
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
const
|
|
748
|
-
l(
|
|
749
|
-
}),
|
|
750
|
-
if (
|
|
751
|
-
const
|
|
752
|
-
l(
|
|
749
|
+
const h = u.querySelector("input,textarea,select");
|
|
750
|
+
if (h) {
|
|
751
|
+
const d = typeof HTMLInputElement < "u";
|
|
752
|
+
d && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!s : "value" in h && (h.value = s ?? ""), h.addEventListener("blur", () => {
|
|
753
|
+
const g = d && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked : h.value;
|
|
754
|
+
l(g);
|
|
755
|
+
}), h.addEventListener("keydown", (g) => {
|
|
756
|
+
if (g.key === "Enter") {
|
|
757
|
+
const m = d && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked : h.value;
|
|
758
|
+
l(m);
|
|
753
759
|
}
|
|
754
|
-
|
|
755
|
-
}),
|
|
756
|
-
const
|
|
757
|
-
l(
|
|
758
|
-
}), setTimeout(() =>
|
|
760
|
+
g.key === "Escape" && r();
|
|
761
|
+
}), d && h instanceof HTMLInputElement && h.type === "checkbox" && h.addEventListener("change", () => {
|
|
762
|
+
const g = h.checked;
|
|
763
|
+
l(g);
|
|
764
|
+
}), setTimeout(() => h.focus(), 0);
|
|
759
765
|
}
|
|
760
|
-
a.appendChild(
|
|
766
|
+
a.appendChild(u);
|
|
761
767
|
} else if (typeof p == "string") {
|
|
762
|
-
const
|
|
763
|
-
|
|
768
|
+
const u = document.createElement(p);
|
|
769
|
+
u.value = w, u.addEventListener("change", () => l(u.value)), a.appendChild(u);
|
|
764
770
|
} else if (typeof p == "function") {
|
|
765
|
-
const
|
|
766
|
-
typeof
|
|
771
|
+
const u = p({ row: e, value: w, field: n.field, column: n, commit: l, cancel: r });
|
|
772
|
+
typeof u == "string" ? a.innerHTML = u : a.appendChild(u);
|
|
767
773
|
} else if (p && typeof p == "object") {
|
|
768
|
-
const
|
|
769
|
-
|
|
774
|
+
const u = document.createElement("div");
|
|
775
|
+
u.setAttribute("data-external-editor", ""), u.setAttribute("data-field", n.field), a.appendChild(u);
|
|
770
776
|
const c = { row: e, value: w, field: n.field, column: n, commit: l, cancel: r };
|
|
771
777
|
if (p.mount)
|
|
772
778
|
try {
|
|
773
|
-
p.mount({ placeholder:
|
|
779
|
+
p.mount({ placeholder: u, context: c, spec: p });
|
|
774
780
|
} catch {
|
|
775
781
|
}
|
|
776
782
|
else
|
|
777
783
|
o.dispatchEvent(
|
|
778
|
-
new CustomEvent("mount-external-editor", { detail: { placeholder:
|
|
784
|
+
new CustomEvent("mount-external-editor", { detail: { placeholder: u, spec: p, context: c } })
|
|
779
785
|
);
|
|
780
786
|
}
|
|
781
787
|
}
|
|
@@ -788,8 +794,8 @@ function J(o, e) {
|
|
|
788
794
|
}
|
|
789
795
|
function Q(o, e, t) {
|
|
790
796
|
o.sortState = { field: e.field, direction: t };
|
|
791
|
-
const n = e.sortComparator || ((
|
|
792
|
-
o._rows.sort((
|
|
797
|
+
const n = e.sortComparator || ((i, s) => i == null && s == null ? 0 : i == null ? -1 : s == null || i > s ? 1 : i < s ? -1 : 0);
|
|
798
|
+
o._rows.sort((i, s) => n(i[e.field], s[e.field], i, s) * t), o.__rowRenderEpoch++, o.rowPool.forEach((i) => i.__epoch = -1), V(o), o.refreshVirtualWindow(!0), o.dispatchEvent(
|
|
793
799
|
new CustomEvent("sort-change", { detail: { field: e.field, direction: t } })
|
|
794
800
|
), o.requestStateChange?.();
|
|
795
801
|
}
|
|
@@ -797,41 +803,41 @@ function V(o) {
|
|
|
797
803
|
o.headerRowEl = o.findHeaderRow();
|
|
798
804
|
const e = o.headerRowEl;
|
|
799
805
|
e.innerHTML = "", e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1"), o.visibleColumns.forEach((t, n) => {
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
const
|
|
803
|
-
if (
|
|
806
|
+
const i = document.createElement("div");
|
|
807
|
+
i.className = "cell", B(i, "header-cell"), i.setAttribute("role", "columnheader"), i.setAttribute("aria-colindex", String(n + 1)), i.setAttribute("data-field", t.field), i.setAttribute("data-col", String(n)), t.sticky === "left" ? i.classList.add("sticky-left") : t.sticky === "right" && i.classList.add("sticky-right");
|
|
808
|
+
const s = t.__headerTemplate;
|
|
809
|
+
if (s) Array.from(s.childNodes).forEach((l) => i.appendChild(l.cloneNode(!0)));
|
|
804
810
|
else {
|
|
805
811
|
const l = t.header || t.field, r = document.createElement("span");
|
|
806
|
-
r.textContent = l,
|
|
812
|
+
r.textContent = l, i.appendChild(r);
|
|
807
813
|
}
|
|
808
814
|
if (t.sortable) {
|
|
809
|
-
|
|
815
|
+
i.classList.add("sortable"), i.tabIndex = 0;
|
|
810
816
|
const l = document.createElement("span");
|
|
811
817
|
B(l, "sort-indicator"), l.style.opacity = "0.6";
|
|
812
818
|
const r = o.sortState?.field === t.field ? o.sortState.direction : 0;
|
|
813
|
-
l.textContent = r === 1 ? "▲" : r === -1 ? "▼" : "⇅",
|
|
814
|
-
o.resizeController?.isResizing || o.dispatchHeaderClick?.(a, n,
|
|
815
|
-
}),
|
|
819
|
+
l.textContent = r === 1 ? "▲" : r === -1 ? "▼" : "⇅", i.appendChild(l), i.setAttribute("aria-sort", r === 0 ? "none" : r === 1 ? "ascending" : "descending"), i.addEventListener("click", (a) => {
|
|
820
|
+
o.resizeController?.isResizing || o.dispatchHeaderClick?.(a, n, i) || J(o, t);
|
|
821
|
+
}), i.addEventListener("keydown", (a) => {
|
|
816
822
|
if (a.key === "Enter" || a.key === " ") {
|
|
817
|
-
if (a.preventDefault(), o.dispatchHeaderClick?.(a, n,
|
|
823
|
+
if (a.preventDefault(), o.dispatchHeaderClick?.(a, n, i)) return;
|
|
818
824
|
J(o, t);
|
|
819
825
|
}
|
|
820
826
|
});
|
|
821
827
|
}
|
|
822
828
|
if (t.resizable) {
|
|
823
|
-
t.sticky || (
|
|
829
|
+
t.sticky || (i.style.position = "relative");
|
|
824
830
|
const l = document.createElement("div");
|
|
825
831
|
l.className = "resize-handle", l.setAttribute("aria-hidden", "true"), l.addEventListener("mousedown", (r) => {
|
|
826
|
-
r.stopPropagation(), r.preventDefault(), o.resizeController.start(r, n,
|
|
827
|
-
}),
|
|
832
|
+
r.stopPropagation(), r.preventDefault(), o.resizeController.start(r, n, i);
|
|
833
|
+
}), i.appendChild(l);
|
|
828
834
|
}
|
|
829
|
-
e.appendChild(
|
|
835
|
+
e.appendChild(i);
|
|
830
836
|
});
|
|
831
837
|
try {
|
|
832
838
|
const t = o.shadowRoot;
|
|
833
|
-
t && t.querySelectorAll(".header-group-row .cell").forEach((
|
|
834
|
-
|
|
839
|
+
t && t.querySelectorAll(".header-group-row .cell").forEach((i) => {
|
|
840
|
+
i.getAttribute("data-group") && i.classList.add("grouped");
|
|
835
841
|
});
|
|
836
842
|
} catch {
|
|
837
843
|
}
|
|
@@ -840,8 +846,8 @@ function V(o) {
|
|
|
840
846
|
});
|
|
841
847
|
}
|
|
842
848
|
function Be(o) {
|
|
843
|
-
let e = null, t = null, n = null,
|
|
844
|
-
const
|
|
849
|
+
let e = null, t = null, n = null, i = null;
|
|
850
|
+
const s = (a) => {
|
|
845
851
|
if (!e) return;
|
|
846
852
|
const f = a.clientX - e.startX, p = Math.max(40, e.startWidth + f), w = o.visibleColumns[e.colIndex];
|
|
847
853
|
w.width = p, w.__userResized = !0, w.__renderedWidth = p, t == null && (t = requestAnimationFrame(() => {
|
|
@@ -855,7 +861,7 @@ function Be(o) {
|
|
|
855
861
|
const a = e !== null;
|
|
856
862
|
a && (l = !0, requestAnimationFrame(() => {
|
|
857
863
|
l = !1;
|
|
858
|
-
})), window.removeEventListener("mousemove",
|
|
864
|
+
})), window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", r), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, a && o.requestStateChange && o.requestStateChange();
|
|
859
865
|
};
|
|
860
866
|
return {
|
|
861
867
|
get isResizing() {
|
|
@@ -864,7 +870,7 @@ function Be(o) {
|
|
|
864
870
|
start(a, f, p) {
|
|
865
871
|
a.preventDefault();
|
|
866
872
|
const w = p.getBoundingClientRect();
|
|
867
|
-
e = { startX: a.clientX, colIndex: f, startWidth: w.width }, window.addEventListener("mousemove",
|
|
873
|
+
e = { startX: a.clientX, colIndex: f, startWidth: w.width }, window.addEventListener("mousemove", s), window.addEventListener("mouseup", r), n === null && (n = document.documentElement.style.cursor), document.documentElement.style.cursor = "e-resize", i === null && (i = document.body.style.userSelect), document.body.style.userSelect = "none";
|
|
868
874
|
},
|
|
869
875
|
dispose() {
|
|
870
876
|
r();
|
|
@@ -888,20 +894,20 @@ function Ke(o, e) {
|
|
|
888
894
|
return !!(o?.header?.title || o?.header?.toolbarButtons?.length || e.toolPanels.size > 0 || e.headerContents.size > 0 || e.toolbarButtons.size > 0 || e.lightDomButtons.length > 0 || e.lightDomHeaderContent.length > 0);
|
|
889
895
|
}
|
|
890
896
|
function We(o, e) {
|
|
891
|
-
const t = o?.header?.title ?? "", n = !!t,
|
|
892
|
-
let
|
|
893
|
-
for (const
|
|
894
|
-
|
|
895
|
-
for (const
|
|
896
|
-
|
|
897
|
-
for (const
|
|
898
|
-
(
|
|
899
|
-
for (const
|
|
900
|
-
(
|
|
901
|
-
r && (
|
|
902
|
-
for (const
|
|
903
|
-
const
|
|
904
|
-
|
|
897
|
+
const t = o?.header?.title ?? "", n = !!t, i = o?.header?.toolbarButtons ?? [], s = i.length > 0, l = e.toolbarButtons.size > 0, r = e.lightDomButtons.length > 0, a = e.toolPanels.size > 0, p = (s || l || r) && a, w = [...i].sort((d, g) => (d.order ?? 100) - (g.order ?? 100)), u = [...e.toolbarButtons.values()].sort((d, g) => (d.order ?? 100) - (g.order ?? 100)), c = [...e.toolPanels.values()].sort((d, g) => (d.order ?? 100) - (g.order ?? 100));
|
|
898
|
+
let h = "";
|
|
899
|
+
for (const d of w)
|
|
900
|
+
d.icon && d.action && (h += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
|
|
901
|
+
for (const d of u)
|
|
902
|
+
d.icon && d.action && (h += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
|
|
903
|
+
for (const d of w)
|
|
904
|
+
(d.element || d.render) && (h += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
|
|
905
|
+
for (const d of u)
|
|
906
|
+
(d.element || d.render) && (h += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
|
|
907
|
+
r && (h += '<slot name="toolbar"></slot>'), p && (h += '<div class="tbw-toolbar-separator"></div>');
|
|
908
|
+
for (const d of c) {
|
|
909
|
+
const g = e.activePanel === d.id;
|
|
910
|
+
h += `<button class="tbw-toolbar-btn${g ? " active" : ""}" data-panel="${d.id}" title="${d.tooltip ?? d.title}" aria-label="${d.tooltip ?? d.title}" aria-pressed="${g}" aria-controls="tbw-panel-${d.id}">${d.icon}</button>`;
|
|
905
911
|
}
|
|
906
912
|
return `
|
|
907
913
|
<div class="tbw-shell-header" part="shell-header" role="banner">
|
|
@@ -910,14 +916,14 @@ function We(o, e) {
|
|
|
910
916
|
<slot name="header-content"></slot>
|
|
911
917
|
</div>
|
|
912
918
|
<div class="tbw-shell-toolbar" part="shell-toolbar" role="toolbar" aria-label="Grid tools">
|
|
913
|
-
${
|
|
919
|
+
${h}
|
|
914
920
|
</div>
|
|
915
921
|
</div>
|
|
916
922
|
`;
|
|
917
923
|
}
|
|
918
924
|
function Fe(o, e, t) {
|
|
919
|
-
const n = o?.toolPanel?.position ?? "right",
|
|
920
|
-
<aside class="tbw-tool-panel${
|
|
925
|
+
const n = o?.toolPanel?.position ?? "right", i = e.toolPanels.size > 0, s = e.activePanel !== null, l = e.activePanel ? e.toolPanels.get(e.activePanel) : null, r = i ? `
|
|
926
|
+
<aside class="tbw-tool-panel${s ? " open" : ""}" part="tool-panel" data-position="${n}" role="complementary" aria-label="${l?.title ?? "Tool panel"}" id="tbw-panel-${e.activePanel ?? "closed"}">
|
|
921
927
|
<div class="tbw-tool-panel-header">
|
|
922
928
|
<span class="tbw-tool-panel-title">${l?.title ?? ""}</span>
|
|
923
929
|
<button class="tbw-tool-panel-close" aria-label="Close panel">✕</button>
|
|
@@ -946,20 +952,20 @@ function ee(o, e) {
|
|
|
946
952
|
if (!t) return;
|
|
947
953
|
t.style.display = "none";
|
|
948
954
|
const n = t.querySelectorAll("tbw-grid-header-content");
|
|
949
|
-
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((
|
|
950
|
-
|
|
955
|
+
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((s, l) => {
|
|
956
|
+
s.setAttribute("slot", "header-content");
|
|
951
957
|
});
|
|
952
|
-
const
|
|
953
|
-
e.lightDomButtons = Array.from(
|
|
954
|
-
const r = parseInt(
|
|
958
|
+
const i = t.querySelectorAll("tbw-grid-tool-button");
|
|
959
|
+
e.lightDomButtons = Array.from(i), e.lightDomButtons.sort((s, l) => {
|
|
960
|
+
const r = parseInt(s.getAttribute("order") ?? "100", 10), a = parseInt(l.getAttribute("order") ?? "100", 10);
|
|
955
961
|
return r - a;
|
|
956
|
-
}), e.lightDomButtons.forEach((
|
|
957
|
-
|
|
962
|
+
}), e.lightDomButtons.forEach((s) => {
|
|
963
|
+
s.setAttribute("slot", "toolbar");
|
|
958
964
|
});
|
|
959
965
|
}
|
|
960
966
|
function Ve(o, e, t, n) {
|
|
961
|
-
const
|
|
962
|
-
|
|
967
|
+
const i = o.querySelector(".tbw-shell-toolbar");
|
|
968
|
+
i && i.addEventListener("click", (l) => {
|
|
963
969
|
const r = l.target, a = r.closest("[data-panel]");
|
|
964
970
|
if (a) {
|
|
965
971
|
const p = a.getAttribute("data-panel");
|
|
@@ -972,36 +978,36 @@ function Ve(o, e, t, n) {
|
|
|
972
978
|
p && n.onToolbarButtonClick(p);
|
|
973
979
|
}
|
|
974
980
|
});
|
|
975
|
-
const
|
|
976
|
-
|
|
981
|
+
const s = o.querySelector(".tbw-tool-panel-close");
|
|
982
|
+
s && s.addEventListener("click", () => {
|
|
977
983
|
n.onPanelClose();
|
|
978
984
|
});
|
|
979
985
|
}
|
|
980
986
|
function Ge(o, e, t) {
|
|
981
987
|
const n = [...e?.header?.toolbarButtons ?? [], ...t.toolbarButtons.values()];
|
|
982
|
-
for (const
|
|
983
|
-
const
|
|
984
|
-
if (!
|
|
985
|
-
const l = t.toolbarButtonCleanups.get(
|
|
986
|
-
if (l && (l(), t.toolbarButtonCleanups.delete(
|
|
987
|
-
|
|
988
|
-
else if (
|
|
989
|
-
const r =
|
|
990
|
-
r && t.toolbarButtonCleanups.set(
|
|
988
|
+
for (const i of n) {
|
|
989
|
+
const s = o.querySelector(`[data-btn-slot="${i.id}"]`);
|
|
990
|
+
if (!s) continue;
|
|
991
|
+
const l = t.toolbarButtonCleanups.get(i.id);
|
|
992
|
+
if (l && (l(), t.toolbarButtonCleanups.delete(i.id)), i.element)
|
|
993
|
+
s.appendChild(i.element);
|
|
994
|
+
else if (i.render) {
|
|
995
|
+
const r = i.render(s);
|
|
996
|
+
r && t.toolbarButtonCleanups.set(i.id, r);
|
|
991
997
|
}
|
|
992
998
|
}
|
|
993
999
|
}
|
|
994
1000
|
function te(o, e) {
|
|
995
1001
|
const t = o.querySelector(".tbw-shell-content");
|
|
996
1002
|
if (!t) return;
|
|
997
|
-
const n = [...e.headerContents.values()].sort((
|
|
998
|
-
for (const
|
|
999
|
-
const l = e.headerContentCleanups.get(
|
|
1000
|
-
l && (l(), e.headerContentCleanups.delete(
|
|
1001
|
-
let r = t.querySelector(`[data-header-content="${
|
|
1002
|
-
r || (r = document.createElement("div"), r.setAttribute("data-header-content",
|
|
1003
|
-
const a =
|
|
1004
|
-
a && e.headerContentCleanups.set(
|
|
1003
|
+
const n = [...e.headerContents.values()].sort((s, l) => (s.order ?? 100) - (l.order ?? 100)), i = t.querySelector('slot[name="header-content"]');
|
|
1004
|
+
for (const s of n) {
|
|
1005
|
+
const l = e.headerContentCleanups.get(s.id);
|
|
1006
|
+
l && (l(), e.headerContentCleanups.delete(s.id));
|
|
1007
|
+
let r = t.querySelector(`[data-header-content="${s.id}"]`);
|
|
1008
|
+
r || (r = document.createElement("div"), r.setAttribute("data-header-content", s.id), i ? t.insertBefore(r, i) : t.appendChild(r));
|
|
1009
|
+
const a = s.render(r);
|
|
1010
|
+
a && e.headerContentCleanups.set(s.id, a);
|
|
1005
1011
|
}
|
|
1006
1012
|
}
|
|
1007
1013
|
function Ue(o, e) {
|
|
@@ -1011,13 +1017,13 @@ function Ue(o, e) {
|
|
|
1011
1017
|
const n = o.querySelector(".tbw-tool-panel-content");
|
|
1012
1018
|
if (!n) return;
|
|
1013
1019
|
e.activePanelCleanup && (e.activePanelCleanup(), e.activePanelCleanup = null), n.innerHTML = "";
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1020
|
+
const i = t.render(n);
|
|
1021
|
+
i && (e.activePanelCleanup = i);
|
|
1016
1022
|
}
|
|
1017
1023
|
function oe(o, e) {
|
|
1018
1024
|
o.querySelectorAll("[data-panel]").forEach((n) => {
|
|
1019
|
-
const
|
|
1020
|
-
n.classList.toggle("active",
|
|
1025
|
+
const s = n.getAttribute("data-panel") === e.activePanel;
|
|
1026
|
+
n.classList.toggle("active", s), n.setAttribute("aria-pressed", String(s));
|
|
1021
1027
|
});
|
|
1022
1028
|
}
|
|
1023
1029
|
function ne(o, e) {
|
|
@@ -1025,8 +1031,8 @@ function ne(o, e) {
|
|
|
1025
1031
|
if (!t) return;
|
|
1026
1032
|
const n = e.activePanel !== null;
|
|
1027
1033
|
if (t.classList.toggle("open", n), n && e.activePanel) {
|
|
1028
|
-
const
|
|
1029
|
-
|
|
1034
|
+
const i = e.toolPanels.get(e.activePanel), s = t.querySelector(".tbw-tool-panel-title");
|
|
1035
|
+
s && (s.textContent = i?.title ?? ""), t.setAttribute("aria-label", `${i?.title ?? "Tool"} panel`), t.id = `tbw-panel-${e.activePanel}`;
|
|
1030
1036
|
}
|
|
1031
1037
|
}
|
|
1032
1038
|
function Xe(o, e) {
|
|
@@ -1046,11 +1052,11 @@ function Xe(o, e) {
|
|
|
1046
1052
|
source: "config"
|
|
1047
1053
|
});
|
|
1048
1054
|
for (let n = 0; n < e.lightDomButtons.length; n++) {
|
|
1049
|
-
const
|
|
1055
|
+
const s = e.lightDomButtons[n].querySelector("button");
|
|
1050
1056
|
t.push({
|
|
1051
1057
|
id: `light-dom-${n}`,
|
|
1052
|
-
label:
|
|
1053
|
-
disabled:
|
|
1058
|
+
label: s?.getAttribute("title") ?? s?.getAttribute("aria-label") ?? "",
|
|
1059
|
+
disabled: s?.disabled ?? !1,
|
|
1054
1060
|
source: "light-dom"
|
|
1055
1061
|
});
|
|
1056
1062
|
}
|
|
@@ -1211,8 +1217,8 @@ class Ye {
|
|
|
1211
1217
|
* Returns true if any plugin handled the row.
|
|
1212
1218
|
*/
|
|
1213
1219
|
renderRow(e, t, n) {
|
|
1214
|
-
for (const
|
|
1215
|
-
if (
|
|
1220
|
+
for (const i of this.plugins)
|
|
1221
|
+
if (i.renderRow?.(e, t, n))
|
|
1216
1222
|
return !0;
|
|
1217
1223
|
return !1;
|
|
1218
1224
|
}
|
|
@@ -1299,8 +1305,8 @@ class Ye {
|
|
|
1299
1305
|
getContextMenuItems(e) {
|
|
1300
1306
|
const t = [];
|
|
1301
1307
|
for (const n of this.plugins) {
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1308
|
+
const i = n.getContextMenuItems?.(e);
|
|
1309
|
+
i && t.push(...i);
|
|
1304
1310
|
}
|
|
1305
1311
|
return t;
|
|
1306
1312
|
}
|
|
@@ -1333,46 +1339,45 @@ class Ye {
|
|
|
1333
1339
|
class q extends HTMLElement {
|
|
1334
1340
|
// TODO: Rename to 'data-grid' when migration is complete
|
|
1335
1341
|
static tagName = "tbw-grid";
|
|
1336
|
-
#
|
|
1342
|
+
#o;
|
|
1337
1343
|
#i = !1;
|
|
1338
1344
|
// ---------------- Ready Promise ----------------
|
|
1345
|
+
#H;
|
|
1339
1346
|
#z;
|
|
1340
|
-
#N;
|
|
1341
1347
|
// ================== INPUT PROPERTIES ==================
|
|
1342
1348
|
// These backing fields store raw user input. They are merged into
|
|
1343
1349
|
// #effectiveConfig by #mergeEffectiveConfig(). Never read directly
|
|
1344
1350
|
// for rendering logic - always use effectiveConfig or derived state.
|
|
1345
1351
|
#l = [];
|
|
1346
1352
|
#r;
|
|
1353
|
+
#p;
|
|
1347
1354
|
#g;
|
|
1348
|
-
#
|
|
1349
|
-
#y;
|
|
1355
|
+
#m;
|
|
1350
1356
|
// ================== SINGLE SOURCE OF TRUTH ==================
|
|
1351
1357
|
// All input sources converge here. This is the canonical config
|
|
1352
1358
|
// that all rendering and logic should read from.
|
|
1353
|
-
#
|
|
1354
|
-
#
|
|
1355
|
-
#
|
|
1356
|
-
#
|
|
1357
|
-
#
|
|
1359
|
+
#n = {};
|
|
1360
|
+
#f = !1;
|
|
1361
|
+
#T = 0;
|
|
1362
|
+
#v = null;
|
|
1363
|
+
#C = !1;
|
|
1358
1364
|
// Cached flag for plugin scroll handlers
|
|
1359
|
-
#
|
|
1365
|
+
#L;
|
|
1360
1366
|
// Cached hook to avoid closures
|
|
1361
|
-
#
|
|
1362
|
-
#
|
|
1363
|
-
#
|
|
1364
|
-
#
|
|
1365
|
-
#b;
|
|
1367
|
+
#y = !1;
|
|
1368
|
+
#E = null;
|
|
1369
|
+
#R = null;
|
|
1370
|
+
#_ = null;
|
|
1366
1371
|
#A = null;
|
|
1367
|
-
#
|
|
1372
|
+
#a;
|
|
1368
1373
|
// ---------------- Plugin System ----------------
|
|
1369
1374
|
#t;
|
|
1370
1375
|
// ---------------- Column State ----------------
|
|
1371
|
-
#
|
|
1372
|
-
#
|
|
1376
|
+
#k;
|
|
1377
|
+
#h;
|
|
1373
1378
|
// ---------------- Shell State ----------------
|
|
1374
1379
|
#e = $e();
|
|
1375
|
-
#
|
|
1380
|
+
#c = !1;
|
|
1376
1381
|
// ================== DERIVED STATE ==================
|
|
1377
1382
|
// _rows: result of applying plugin processRows hooks
|
|
1378
1383
|
_rows = [];
|
|
@@ -1380,10 +1385,10 @@ class q extends HTMLElement {
|
|
|
1380
1385
|
// This ensures effectiveConfig.columns is the single source of truth for columns
|
|
1381
1386
|
// _columns always contains ALL columns (including hidden)
|
|
1382
1387
|
get _columns() {
|
|
1383
|
-
return this.#
|
|
1388
|
+
return this.#n.columns ?? [];
|
|
1384
1389
|
}
|
|
1385
1390
|
set _columns(e) {
|
|
1386
|
-
this.#
|
|
1391
|
+
this.#n.columns = e;
|
|
1387
1392
|
}
|
|
1388
1393
|
// visibleColumns returns only visible columns for rendering
|
|
1389
1394
|
// This is what header/row rendering should use
|
|
@@ -1433,7 +1438,7 @@ class q extends HTMLElement {
|
|
|
1433
1438
|
}
|
|
1434
1439
|
set rows(e) {
|
|
1435
1440
|
const t = this.#l;
|
|
1436
|
-
this.#l = e, t !== e && this.#
|
|
1441
|
+
this.#l = e, t !== e && this.#Y();
|
|
1437
1442
|
}
|
|
1438
1443
|
/**
|
|
1439
1444
|
* Get the original unfiltered/unprocessed rows.
|
|
@@ -1447,41 +1452,51 @@ class q extends HTMLElement {
|
|
|
1447
1452
|
}
|
|
1448
1453
|
set columns(e) {
|
|
1449
1454
|
const t = this.#r;
|
|
1450
|
-
this.#r = e, t !== e && this.#
|
|
1455
|
+
this.#r = e, t !== e && this.#Z();
|
|
1451
1456
|
}
|
|
1452
1457
|
get gridConfig() {
|
|
1453
|
-
return this.#
|
|
1458
|
+
return this.#n;
|
|
1454
1459
|
}
|
|
1455
1460
|
set gridConfig(e) {
|
|
1456
|
-
const t = this.#
|
|
1457
|
-
this.#
|
|
1461
|
+
const t = this.#p;
|
|
1462
|
+
this.#p = e, t !== e && this.#J();
|
|
1458
1463
|
}
|
|
1459
1464
|
get fitMode() {
|
|
1460
|
-
return this.#
|
|
1465
|
+
return this.#n.fitMode ?? "stretch";
|
|
1461
1466
|
}
|
|
1462
1467
|
set fitMode(e) {
|
|
1463
|
-
const t = this.#
|
|
1464
|
-
this.#
|
|
1468
|
+
const t = this.#g;
|
|
1469
|
+
this.#g = e, t !== e && this.#X();
|
|
1465
1470
|
}
|
|
1466
1471
|
get editOn() {
|
|
1467
|
-
return this.#
|
|
1472
|
+
return this.#n.editOn;
|
|
1468
1473
|
}
|
|
1469
1474
|
set editOn(e) {
|
|
1470
|
-
const t = this.#
|
|
1471
|
-
this.#
|
|
1475
|
+
const t = this.#m;
|
|
1476
|
+
this.#m = e, t !== e && this.#j();
|
|
1472
1477
|
}
|
|
1473
1478
|
// Effective config accessor for internal modules and plugins
|
|
1474
1479
|
// Returns the merged config (single source of truth) before plugin processing
|
|
1475
1480
|
// Use this when you need the raw merged config (e.g., for column definitions including hidden)
|
|
1476
1481
|
get effectiveConfig() {
|
|
1477
|
-
return this.#
|
|
1482
|
+
return this.#n;
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Get the disconnect signal for event listener cleanup.
|
|
1486
|
+
* This signal is aborted when the grid disconnects from the DOM.
|
|
1487
|
+
* Plugins and internal code can use this for automatic listener cleanup.
|
|
1488
|
+
* @example
|
|
1489
|
+
* element.addEventListener('click', handler, { signal: this.grid.disconnectSignal });
|
|
1490
|
+
*/
|
|
1491
|
+
get disconnectSignal() {
|
|
1492
|
+
return this.#a || (this.#a = new AbortController()), this.#a.signal;
|
|
1478
1493
|
}
|
|
1479
1494
|
constructor() {
|
|
1480
|
-
super(), this.#
|
|
1495
|
+
super(), this.#o = this.attachShadow({ mode: "open" }), this.#F(), this.#H = new Promise((e) => this.#z = e);
|
|
1481
1496
|
}
|
|
1482
|
-
#
|
|
1497
|
+
#F() {
|
|
1483
1498
|
const e = new CSSStyleSheet();
|
|
1484
|
-
e.replaceSync(we), this.#
|
|
1499
|
+
e.replaceSync(we), this.#o.adoptedStyleSheets = [e];
|
|
1485
1500
|
}
|
|
1486
1501
|
// ---------------- Plugin System ----------------
|
|
1487
1502
|
/**
|
|
@@ -1504,7 +1519,7 @@ class q extends HTMLElement {
|
|
|
1504
1519
|
* Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
|
|
1505
1520
|
*/
|
|
1506
1521
|
requestRender() {
|
|
1507
|
-
this.#
|
|
1522
|
+
this.#x(), this.#P(), this.#S(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
1508
1523
|
}
|
|
1509
1524
|
/**
|
|
1510
1525
|
* Request a lightweight style update without rebuilding DOM.
|
|
@@ -1512,46 +1527,46 @@ class q extends HTMLElement {
|
|
|
1512
1527
|
* This runs all plugin afterRender hooks without rebuilding row/column DOM.
|
|
1513
1528
|
*/
|
|
1514
1529
|
requestAfterRender() {
|
|
1515
|
-
this.#
|
|
1530
|
+
this.#w();
|
|
1516
1531
|
}
|
|
1517
1532
|
/**
|
|
1518
1533
|
* Initialize plugin system with instances from config.
|
|
1519
1534
|
* Plugins are class instances passed in gridConfig.plugins[].
|
|
1520
1535
|
*/
|
|
1521
|
-
#
|
|
1536
|
+
#N() {
|
|
1522
1537
|
this.#t = new Ye(this);
|
|
1523
|
-
const e = this.#
|
|
1538
|
+
const e = this.#n?.plugins, t = Array.isArray(e) ? e : [];
|
|
1524
1539
|
this.#t.attachAll(t);
|
|
1525
1540
|
}
|
|
1526
1541
|
/**
|
|
1527
1542
|
* Inject all plugin styles into the shadow DOM.
|
|
1528
1543
|
* Must be called after #render() since innerHTML wipes existing content.
|
|
1529
1544
|
*/
|
|
1530
|
-
#
|
|
1545
|
+
#q() {
|
|
1531
1546
|
const e = this.#t?.getAllStyles() ?? "";
|
|
1532
1547
|
if (e) {
|
|
1533
1548
|
const t = document.createElement("style");
|
|
1534
|
-
t.setAttribute("data-plugin", "all"), t.textContent = e, this.#
|
|
1549
|
+
t.setAttribute("data-plugin", "all"), t.textContent = e, this.#o.appendChild(t);
|
|
1535
1550
|
}
|
|
1536
1551
|
}
|
|
1537
1552
|
/**
|
|
1538
1553
|
* Update plugins when grid config changes.
|
|
1539
1554
|
* With class-based plugins, we need to detach old and attach new.
|
|
1540
1555
|
*/
|
|
1541
|
-
#
|
|
1542
|
-
this.#t && this.#t.detachAll(), this.#
|
|
1556
|
+
#I() {
|
|
1557
|
+
this.#t && this.#t.detachAll(), this.#N(), this.#q(), this.#C = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
|
|
1543
1558
|
}
|
|
1544
1559
|
/**
|
|
1545
1560
|
* Clean up plugin states when grid disconnects.
|
|
1546
1561
|
*/
|
|
1547
|
-
#
|
|
1562
|
+
#V() {
|
|
1548
1563
|
this.#t?.detachAll();
|
|
1549
1564
|
}
|
|
1550
1565
|
/**
|
|
1551
1566
|
* Collect tool panels and header content from all plugins.
|
|
1552
1567
|
* Called after plugins are attached but before render.
|
|
1553
1568
|
*/
|
|
1554
|
-
#
|
|
1569
|
+
#G() {
|
|
1555
1570
|
if (!this.#t) return;
|
|
1556
1571
|
const e = this.#t.getToolPanels();
|
|
1557
1572
|
for (const { panel: n } of e)
|
|
@@ -1562,75 +1577,85 @@ class q extends HTMLElement {
|
|
|
1562
1577
|
}
|
|
1563
1578
|
// ---------------- Lifecycle ----------------
|
|
1564
1579
|
connectedCallback() {
|
|
1565
|
-
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#
|
|
1580
|
+
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#a?.abort(), this.#a = new AbortController(), this.#u(), this.#N(), this.#G(), this.#i || (this.#W(), this.#q(), this.#i = !0), this.#B();
|
|
1566
1581
|
}
|
|
1567
1582
|
disconnectedCallback() {
|
|
1568
|
-
this.#
|
|
1583
|
+
this.#V(), je(this.#e), this.#c = !1, this.#a && (this.#a.abort(), this.#a = void 0), this.resizeController && this.resizeController.dispose(), this.#f = !1;
|
|
1569
1584
|
}
|
|
1570
|
-
|
|
1571
|
-
const t = this.#
|
|
1572
|
-
if (this.headerRowEl = t?.querySelector(".header-row"), this.virtualization.totalHeightEl = t?.querySelector(".faux-vscroll-spacer"), this.virtualization.viewportEl = t?.querySelector(".rows-viewport"), this.bodyEl = t?.querySelector(".rows"), this.#
|
|
1573
|
-
te(this.#
|
|
1574
|
-
const
|
|
1575
|
-
|
|
1576
|
-
}
|
|
1577
|
-
this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1585
|
+
#B() {
|
|
1586
|
+
const t = this.#o.querySelector(".tbw-grid-content") ?? this.#o.querySelector(".tbw-grid-root");
|
|
1587
|
+
if (this.headerRowEl = t?.querySelector(".header-row"), this.virtualization.totalHeightEl = t?.querySelector(".faux-vscroll-spacer"), this.virtualization.viewportEl = t?.querySelector(".rows-viewport"), this.bodyEl = t?.querySelector(".rows"), this.#c) {
|
|
1588
|
+
te(this.#o, this.#e), Ge(this.#o, this.#n?.shell, this.#e);
|
|
1589
|
+
const l = this.#n?.shell?.toolPanel?.defaultOpen;
|
|
1590
|
+
l && this.#e.toolPanels.has(l) && this.openToolPanel(l);
|
|
1591
|
+
}
|
|
1592
|
+
this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#f = !0;
|
|
1593
|
+
const n = this.disconnectSignal;
|
|
1594
|
+
this.#d(), this.addEventListener("keydown", (l) => He(this, l), { signal: n }), document.addEventListener(
|
|
1595
|
+
"keydown",
|
|
1596
|
+
(l) => {
|
|
1597
|
+
l.key === "Escape" && this.activeEditRows !== -1 && this.#O(this.activeEditRows, !0);
|
|
1598
|
+
},
|
|
1599
|
+
{ capture: !0, signal: n }
|
|
1600
|
+
), document.addEventListener(
|
|
1601
|
+
"mousedown",
|
|
1602
|
+
(l) => {
|
|
1603
|
+
if (this.activeEditRows === -1) return;
|
|
1604
|
+
const r = this.findRenderedRowElement(this.activeEditRows);
|
|
1605
|
+
!r || (l.composedPath && l.composedPath() || []).includes(r) || this.#O(this.activeEditRows, !1);
|
|
1606
|
+
},
|
|
1607
|
+
{ signal: n }
|
|
1608
|
+
);
|
|
1609
|
+
const i = t?.querySelector(".faux-vscroll"), s = t?.querySelector(".rows");
|
|
1610
|
+
if (this.virtualization.container = i ?? this, this.#C = this.#t?.getAll().some((l) => l.onScroll) ?? !1, i && s) {
|
|
1611
|
+
i.addEventListener(
|
|
1587
1612
|
"scroll",
|
|
1588
1613
|
() => {
|
|
1589
|
-
if (!this.virtualization.enabled && !this.#
|
|
1590
|
-
const
|
|
1591
|
-
s.style.transform = `translateY(${
|
|
1592
|
-
this.#
|
|
1614
|
+
if (!this.virtualization.enabled && !this.#C) return;
|
|
1615
|
+
const a = i.scrollTop, f = this.virtualization.rowHeight, p = -(a % f);
|
|
1616
|
+
s.style.transform = `translateY(${p}px)`, this.#v = a, this.#T || (this.#T = requestAnimationFrame(() => {
|
|
1617
|
+
this.#T = 0, this.#v !== null && (this.#oe(this.#v), this.#v = null);
|
|
1593
1618
|
}));
|
|
1594
1619
|
},
|
|
1595
|
-
{ passive: !0 }
|
|
1620
|
+
{ passive: !0, signal: n }
|
|
1596
1621
|
);
|
|
1597
|
-
const
|
|
1598
|
-
|
|
1622
|
+
const l = this.#o.querySelector(".tbw-grid-content"), r = this.#o.querySelector(".tbw-scroll-area");
|
|
1623
|
+
l && (l.addEventListener(
|
|
1599
1624
|
"wheel",
|
|
1600
|
-
(
|
|
1601
|
-
|
|
1625
|
+
(a) => {
|
|
1626
|
+
a.preventDefault(), a.shiftKey || Math.abs(a.deltaX) > Math.abs(a.deltaY) ? r && (r.scrollLeft += a.shiftKey ? a.deltaY : a.deltaX) : i.scrollTop += a.deltaY;
|
|
1602
1627
|
},
|
|
1603
|
-
{ passive: !1 }
|
|
1604
|
-
),
|
|
1628
|
+
{ passive: !1, signal: n }
|
|
1629
|
+
), l.addEventListener(
|
|
1605
1630
|
"touchstart",
|
|
1606
|
-
(
|
|
1607
|
-
|
|
1631
|
+
(a) => {
|
|
1632
|
+
a.touches.length === 1 && (this.#E = a.touches[0].clientY, this.#R = a.touches[0].clientX, this.#_ = i.scrollTop, this.#A = r?.scrollLeft ?? 0);
|
|
1608
1633
|
},
|
|
1609
|
-
{ passive: !0 }
|
|
1610
|
-
),
|
|
1634
|
+
{ passive: !0, signal: n }
|
|
1635
|
+
), l.addEventListener(
|
|
1611
1636
|
"touchmove",
|
|
1612
|
-
(
|
|
1613
|
-
if (
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1637
|
+
(a) => {
|
|
1638
|
+
if (a.touches.length === 1 && this.#E !== null && this.#R !== null && this.#_ !== null && this.#A !== null) {
|
|
1639
|
+
const f = this.#E - a.touches[0].clientY, p = this.#R - a.touches[0].clientX;
|
|
1640
|
+
i.scrollTop = this.#_ + f, r && (r.scrollLeft = this.#A + p), a.preventDefault();
|
|
1616
1641
|
}
|
|
1617
1642
|
},
|
|
1618
|
-
{ passive: !1 }
|
|
1619
|
-
),
|
|
1643
|
+
{ passive: !1, signal: n }
|
|
1644
|
+
), l.addEventListener(
|
|
1620
1645
|
"touchend",
|
|
1621
1646
|
() => {
|
|
1622
|
-
this.#
|
|
1647
|
+
this.#E = null, this.#R = null, this.#_ = null, this.#A = null;
|
|
1623
1648
|
},
|
|
1624
|
-
{ passive: !0 }
|
|
1649
|
+
{ passive: !0, signal: n }
|
|
1625
1650
|
));
|
|
1626
1651
|
}
|
|
1627
|
-
this.resizeController = Be(this), this.#
|
|
1628
|
-
const
|
|
1629
|
-
if (
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1652
|
+
this.resizeController = Be(this), this.#o.addEventListener("mousedown", (l) => this.#ne(l), { signal: n }), document.addEventListener("mousemove", (l) => this.#ie(l), { signal: n }), document.addEventListener("mouseup", (l) => this.#se(l), { signal: n }), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
|
|
1653
|
+
const l = this.bodyEl.querySelector(".data-grid-row");
|
|
1654
|
+
if (l) {
|
|
1655
|
+
const r = l.getBoundingClientRect().height;
|
|
1656
|
+
r && Math.abs(r - this.virtualization.rowHeight) > 0.1 && (this.virtualization.rowHeight = r, this.refreshVirtualWindow(!0));
|
|
1632
1657
|
}
|
|
1633
|
-
}), queueMicrotask(() => this.#
|
|
1658
|
+
}), queueMicrotask(() => this.#U()), requestAnimationFrame(() => requestAnimationFrame(() => this.#z?.()));
|
|
1634
1659
|
}
|
|
1635
1660
|
// ---------------- Event Emitters ----------------
|
|
1636
1661
|
#s(e, t) {
|
|
@@ -1652,65 +1677,65 @@ class q extends HTMLElement {
|
|
|
1652
1677
|
this.#s("activate-cell", e);
|
|
1653
1678
|
}
|
|
1654
1679
|
/** Update ARIA selection attributes on rendered rows/cells */
|
|
1655
|
-
#
|
|
1680
|
+
#U() {
|
|
1656
1681
|
this.bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t, n) => {
|
|
1657
|
-
const
|
|
1658
|
-
t.setAttribute("aria-selected", String(
|
|
1659
|
-
|
|
1682
|
+
const i = n === this.focusRow;
|
|
1683
|
+
t.setAttribute("aria-selected", String(i)), t.querySelectorAll(".cell").forEach((s, l) => {
|
|
1684
|
+
s.setAttribute("aria-selected", String(i && l === this.focusCol));
|
|
1660
1685
|
});
|
|
1661
1686
|
});
|
|
1662
1687
|
}
|
|
1663
1688
|
// ---------------- Watch Handlers ----------------
|
|
1664
|
-
#
|
|
1665
|
-
if (!this.#
|
|
1666
|
-
this.#
|
|
1689
|
+
#X() {
|
|
1690
|
+
if (!this.#f) return;
|
|
1691
|
+
this.#u(), this.#n.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#$()) : (this._columns.forEach((t) => {
|
|
1667
1692
|
!t.__userResized && t.__autoSized && delete t.width;
|
|
1668
1693
|
}), this.updateTemplate());
|
|
1669
1694
|
}
|
|
1695
|
+
#j() {
|
|
1696
|
+
this.#f && (this.#u(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
|
|
1697
|
+
}
|
|
1670
1698
|
#Y() {
|
|
1671
|
-
this
|
|
1699
|
+
this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#x(), !this.#r || Array.isArray(this.#r) && this.#r.length === 0 ? this.#d() : this.refreshVirtualWindow(!0);
|
|
1672
1700
|
}
|
|
1673
1701
|
#Z() {
|
|
1674
|
-
|
|
1702
|
+
j(this), this.#f && (this.#u(), this.#d());
|
|
1675
1703
|
}
|
|
1676
1704
|
#J() {
|
|
1677
|
-
|
|
1678
|
-
}
|
|
1679
|
-
#Q() {
|
|
1680
|
-
this.#u && (this.#h(), this.#B(), this.#T(), this.#O(), this.#x(), this.updateTemplate(), this.refreshVirtualWindow(!0));
|
|
1705
|
+
this.#f && (this.#u(), this.#I(), this.#x(), this.#P(), this.#S(), this.updateTemplate(), this.refreshVirtualWindow(!0));
|
|
1681
1706
|
}
|
|
1682
1707
|
// ---------------- Helper Wrappers ----------------
|
|
1683
|
-
#
|
|
1684
|
-
|
|
1708
|
+
#Q() {
|
|
1709
|
+
Me(this);
|
|
1685
1710
|
}
|
|
1686
|
-
#
|
|
1711
|
+
#S() {
|
|
1687
1712
|
V(this);
|
|
1688
1713
|
}
|
|
1689
1714
|
updateTemplate() {
|
|
1690
1715
|
he(this);
|
|
1691
1716
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1717
|
+
#$() {
|
|
1718
|
+
Oe(this);
|
|
1694
1719
|
}
|
|
1695
|
-
#
|
|
1720
|
+
#P() {
|
|
1696
1721
|
if (this.#t) {
|
|
1697
1722
|
const e = this._columns.filter((n) => !n.hidden), t = this.#t.processColumns([...e]);
|
|
1698
1723
|
if (t !== e) {
|
|
1699
|
-
const n = new Map(t.map((
|
|
1700
|
-
if (
|
|
1701
|
-
const l = n.get(
|
|
1702
|
-
return l ? l.col :
|
|
1724
|
+
const n = new Map(t.map((s, l) => [s.field, { col: s, order: l }])), i = this._columns.map((s) => {
|
|
1725
|
+
if (s.hidden) return s;
|
|
1726
|
+
const l = n.get(s.field);
|
|
1727
|
+
return l ? l.col : s;
|
|
1703
1728
|
});
|
|
1704
|
-
this._columns =
|
|
1729
|
+
this._columns = i;
|
|
1705
1730
|
}
|
|
1706
1731
|
}
|
|
1707
1732
|
}
|
|
1708
1733
|
/** Execute all plugin afterRender hooks */
|
|
1709
|
-
#
|
|
1734
|
+
#w() {
|
|
1710
1735
|
this.#t?.afterRender();
|
|
1711
1736
|
}
|
|
1712
1737
|
/** Recompute row model via plugin hooks (grouping, tree, filtering, etc.). */
|
|
1713
|
-
#
|
|
1738
|
+
#x() {
|
|
1714
1739
|
j(this);
|
|
1715
1740
|
const e = Array.isArray(this.#l) ? [...this.#l] : [], t = this.#t?.processRows(e) ?? e;
|
|
1716
1741
|
this._rows = t;
|
|
@@ -1733,75 +1758,75 @@ class q extends HTMLElement {
|
|
|
1733
1758
|
* - `_columns` is NOT set here (done by #getColumnConfiguration + #processColumns)
|
|
1734
1759
|
* - Plugins receive config via their attach() method
|
|
1735
1760
|
*/
|
|
1736
|
-
#
|
|
1737
|
-
const e = this.#
|
|
1761
|
+
#u() {
|
|
1762
|
+
const e = this.#p ? { ...this.#p } : {};
|
|
1738
1763
|
let t = Array.isArray(e.columns) ? [...e.columns] : [];
|
|
1739
|
-
const n = (this.__lightDomColumnsCache || []).map((
|
|
1740
|
-
...
|
|
1764
|
+
const n = (this.__lightDomColumnsCache || []).map((i) => ({
|
|
1765
|
+
...i
|
|
1741
1766
|
}));
|
|
1742
1767
|
if (n.length) {
|
|
1743
|
-
const
|
|
1744
|
-
t.forEach((
|
|
1745
|
-
const l = s
|
|
1746
|
-
l ? (
|
|
1768
|
+
const i = {};
|
|
1769
|
+
t.forEach((s) => i[s.field] = s), n.forEach((s) => {
|
|
1770
|
+
const l = i[s.field];
|
|
1771
|
+
l ? (s.header && !l.header && (l.header = s.header), s.type && !l.type && (l.type = s.type), l.sortable = l.sortable || s.sortable, s.resizable && (l.resizable = !0), s.editable && (l.editable = !0)) : (t.push(s), i[s.field] = s);
|
|
1747
1772
|
});
|
|
1748
1773
|
}
|
|
1749
1774
|
if (this.#r && this.#r.length && (t = [...this.#r]), (!t || t.length === 0) && this._rows.length && (t = ce(this._rows).columns), t.length) {
|
|
1750
1775
|
t.forEach((l) => {
|
|
1751
1776
|
l.sortable === void 0 && (l.sortable = !0), l.resizable === void 0 && (l.resizable = !0);
|
|
1752
1777
|
});
|
|
1753
|
-
const
|
|
1754
|
-
|
|
1778
|
+
const i = this.#n.columns;
|
|
1779
|
+
i?.some((l) => l.__compiledView || l.__compiledEditor) ? e.columns = i : e.columns = t;
|
|
1755
1780
|
} else {
|
|
1756
|
-
const
|
|
1757
|
-
|
|
1781
|
+
const i = this.#n.columns;
|
|
1782
|
+
i?.some((s) => s.__compiledView || s.__compiledEditor) && (e.columns = i);
|
|
1758
1783
|
}
|
|
1759
|
-
this.#
|
|
1760
|
-
|
|
1784
|
+
this.#g && (e.fitMode = this.#g), e.fitMode || (e.fitMode = "stretch"), this.#m && (e.editOn = this.#m), e.columnState && !this.#h && (this.#h = e.columnState), this.#n = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
|
|
1785
|
+
i.width == null && (i.width = 80);
|
|
1761
1786
|
});
|
|
1762
1787
|
}
|
|
1763
1788
|
// ---------------- Delegate Wrappers ----------------
|
|
1764
1789
|
#M(e, t, n = this.__rowRenderEpoch) {
|
|
1765
|
-
this.#
|
|
1790
|
+
this.#L || (this.#L = (i, s, l) => this.#t?.renderRow(i, s, l) ?? !1), qe(this, e, t, n, this.#L);
|
|
1766
1791
|
}
|
|
1767
|
-
#
|
|
1792
|
+
#ee(e, t) {
|
|
1768
1793
|
T(this, e, t);
|
|
1769
1794
|
}
|
|
1770
|
-
#
|
|
1795
|
+
#O(e, t) {
|
|
1771
1796
|
Ie(this, e, t);
|
|
1772
1797
|
}
|
|
1773
1798
|
// ---------------- Core Helpers ----------------
|
|
1774
|
-
#
|
|
1799
|
+
#d() {
|
|
1775
1800
|
if (!this.isConnected || !this.headerRowEl || !this.bodyEl)
|
|
1776
1801
|
return;
|
|
1777
|
-
const e = this.#
|
|
1802
|
+
const e = this.#p?.columns || this.#r || [];
|
|
1778
1803
|
if (e.length) {
|
|
1779
|
-
const n = new Map(this._columns.filter((
|
|
1780
|
-
...
|
|
1781
|
-
hidden: n.get(
|
|
1804
|
+
const n = new Map(this._columns.filter((s) => s.hidden).map((s) => [s.field, !0])), i = e.map((s) => ({
|
|
1805
|
+
...s,
|
|
1806
|
+
hidden: n.get(s.field) ?? s.hidden
|
|
1782
1807
|
}));
|
|
1783
|
-
this._columns =
|
|
1808
|
+
this._columns = i;
|
|
1784
1809
|
}
|
|
1785
|
-
if (this.#
|
|
1786
|
-
const n = this.#
|
|
1787
|
-
this.#
|
|
1810
|
+
if (this.#Q(), this.#u(), this.#I(), this.#x(), this.#P(), this.#h) {
|
|
1811
|
+
const n = this.#h;
|
|
1812
|
+
this.#h = void 0, this.#K(n);
|
|
1788
1813
|
}
|
|
1789
|
-
this.#
|
|
1814
|
+
this.#S(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#n.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#$()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#w());
|
|
1790
1815
|
}
|
|
1791
1816
|
/** Internal method to apply column state without triggering setup loop */
|
|
1792
|
-
#
|
|
1793
|
-
const t = this.#
|
|
1817
|
+
#K(e) {
|
|
1818
|
+
const t = this.#n.columns ?? [], n = this.#t?.getAll() ?? [];
|
|
1794
1819
|
ge(this, e, t, n);
|
|
1795
|
-
for (const
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1820
|
+
for (const i of e.columns) {
|
|
1821
|
+
const s = t.find((l) => l.field === i.field);
|
|
1822
|
+
s && (s.hidden = !i.visible);
|
|
1798
1823
|
}
|
|
1799
1824
|
}
|
|
1800
|
-
#
|
|
1825
|
+
#te() {
|
|
1801
1826
|
return this._rows.length <= this.virtualization.bypassThreshold;
|
|
1802
1827
|
}
|
|
1803
|
-
#
|
|
1804
|
-
if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#
|
|
1828
|
+
#oe(e) {
|
|
1829
|
+
if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#C) {
|
|
1805
1830
|
const t = this.virtualization.container, n = {
|
|
1806
1831
|
scrollTop: e,
|
|
1807
1832
|
scrollLeft: t?.scrollLeft ?? 0,
|
|
@@ -1815,7 +1840,7 @@ class q extends HTMLElement {
|
|
|
1815
1840
|
}
|
|
1816
1841
|
}
|
|
1817
1842
|
findHeaderRow() {
|
|
1818
|
-
return this.#
|
|
1843
|
+
return this.#o.querySelector(".header-row");
|
|
1819
1844
|
}
|
|
1820
1845
|
findRenderedRowElement(e) {
|
|
1821
1846
|
return Array.from(this.bodyEl.querySelectorAll(".data-grid-row")).find((t) => {
|
|
@@ -1827,16 +1852,16 @@ class q extends HTMLElement {
|
|
|
1827
1852
|
* Dispatch a cell click event to the plugin system.
|
|
1828
1853
|
* Returns true if any plugin handled the event.
|
|
1829
1854
|
*/
|
|
1830
|
-
dispatchCellClick(e, t, n,
|
|
1831
|
-
const
|
|
1832
|
-
if (!
|
|
1855
|
+
dispatchCellClick(e, t, n, i) {
|
|
1856
|
+
const s = this._rows[t], l = this._columns[n];
|
|
1857
|
+
if (!s || !l) return !1;
|
|
1833
1858
|
const r = {
|
|
1834
|
-
row:
|
|
1859
|
+
row: s,
|
|
1835
1860
|
rowIndex: t,
|
|
1836
1861
|
colIndex: n,
|
|
1837
1862
|
field: l.field,
|
|
1838
|
-
value:
|
|
1839
|
-
cellEl:
|
|
1863
|
+
value: s[l.field],
|
|
1864
|
+
cellEl: i,
|
|
1840
1865
|
originalEvent: e
|
|
1841
1866
|
};
|
|
1842
1867
|
return this.#t?.onCellClick(r) ?? !1;
|
|
@@ -1846,16 +1871,16 @@ class q extends HTMLElement {
|
|
|
1846
1871
|
* Returns true if any plugin handled the event.
|
|
1847
1872
|
*/
|
|
1848
1873
|
dispatchHeaderClick(e, t, n) {
|
|
1849
|
-
const
|
|
1850
|
-
if (!
|
|
1851
|
-
const
|
|
1874
|
+
const i = this._columns[t];
|
|
1875
|
+
if (!i) return !1;
|
|
1876
|
+
const s = {
|
|
1852
1877
|
colIndex: t,
|
|
1853
|
-
field:
|
|
1854
|
-
column:
|
|
1878
|
+
field: i.field,
|
|
1879
|
+
column: i,
|
|
1855
1880
|
headerEl: n,
|
|
1856
1881
|
originalEvent: e
|
|
1857
1882
|
};
|
|
1858
|
-
return this.#t?.onHeaderClick(
|
|
1883
|
+
return this.#t?.onHeaderClick(s) ?? !1;
|
|
1859
1884
|
}
|
|
1860
1885
|
/**
|
|
1861
1886
|
* Dispatch a keyboard event to the plugin system.
|
|
@@ -1868,25 +1893,25 @@ class q extends HTMLElement {
|
|
|
1868
1893
|
* Build a CellMouseEvent from a native MouseEvent.
|
|
1869
1894
|
* Extracts cell/row information from the event target.
|
|
1870
1895
|
*/
|
|
1871
|
-
#
|
|
1896
|
+
#D(e, t) {
|
|
1872
1897
|
let n = null;
|
|
1873
|
-
const
|
|
1874
|
-
if (
|
|
1875
|
-
const
|
|
1876
|
-
|
|
1877
|
-
}
|
|
1878
|
-
const
|
|
1879
|
-
let a, f, p, w,
|
|
1880
|
-
return
|
|
1898
|
+
const i = e.composedPath?.();
|
|
1899
|
+
if (i && i.length > 0 ? n = i[0] : n = e.target, n && !this.#o.contains(n)) {
|
|
1900
|
+
const h = this.#o.elementFromPoint(e.clientX, e.clientY);
|
|
1901
|
+
h && (n = h);
|
|
1902
|
+
}
|
|
1903
|
+
const s = n?.closest?.("[data-col]"), l = n?.closest?.(".data-grid-row"), r = n?.closest?.(".header-row");
|
|
1904
|
+
let a, f, p, w, u, c;
|
|
1905
|
+
return s && (a = parseInt(s.getAttribute("data-row") ?? "-1", 10), f = parseInt(s.getAttribute("data-col") ?? "-1", 10), a >= 0 && f >= 0 && (p = this._rows[a], c = this._columns[f], w = c?.field, u = p && w ? p[w] : void 0)), {
|
|
1881
1906
|
type: t,
|
|
1882
1907
|
row: p,
|
|
1883
1908
|
rowIndex: a !== void 0 && a >= 0 ? a : void 0,
|
|
1884
1909
|
colIndex: f !== void 0 && f >= 0 ? f : void 0,
|
|
1885
1910
|
field: w,
|
|
1886
|
-
value:
|
|
1911
|
+
value: u,
|
|
1887
1912
|
column: c,
|
|
1888
1913
|
originalEvent: e,
|
|
1889
|
-
cellElement:
|
|
1914
|
+
cellElement: s ?? void 0,
|
|
1890
1915
|
rowElement: l ?? void 0,
|
|
1891
1916
|
isHeader: !!r,
|
|
1892
1917
|
cell: a !== void 0 && f !== void 0 && a >= 0 && f >= 0 ? { row: a, col: f } : void 0
|
|
@@ -1895,25 +1920,25 @@ class q extends HTMLElement {
|
|
|
1895
1920
|
/**
|
|
1896
1921
|
* Handle mousedown events and dispatch to plugin system.
|
|
1897
1922
|
*/
|
|
1898
|
-
#
|
|
1899
|
-
const t = this.#
|
|
1900
|
-
(this.#t?.onCellMouseDown(t) ?? !1) && (this.#
|
|
1923
|
+
#ne(e) {
|
|
1924
|
+
const t = this.#D(e, "mousedown");
|
|
1925
|
+
(this.#t?.onCellMouseDown(t) ?? !1) && (this.#y = !0);
|
|
1901
1926
|
}
|
|
1902
1927
|
/**
|
|
1903
1928
|
* Handle mousemove events (only when dragging).
|
|
1904
1929
|
*/
|
|
1905
|
-
#
|
|
1906
|
-
if (!this.#
|
|
1907
|
-
const t = this.#
|
|
1930
|
+
#ie(e) {
|
|
1931
|
+
if (!this.#y) return;
|
|
1932
|
+
const t = this.#D(e, "mousemove");
|
|
1908
1933
|
this.#t?.onCellMouseMove(t);
|
|
1909
1934
|
}
|
|
1910
1935
|
/**
|
|
1911
1936
|
* Handle mouseup events.
|
|
1912
1937
|
*/
|
|
1913
|
-
#
|
|
1914
|
-
if (!this.#
|
|
1915
|
-
const t = this.#
|
|
1916
|
-
this.#t?.onCellMouseUp(t), this.#
|
|
1938
|
+
#se(e) {
|
|
1939
|
+
if (!this.#y) return;
|
|
1940
|
+
const t = this.#D(e, "mouseup");
|
|
1941
|
+
this.#t?.onCellMouseUp(t), this.#y = !1;
|
|
1917
1942
|
}
|
|
1918
1943
|
// API consumed by internal utils (rows.ts)
|
|
1919
1944
|
get changedRows() {
|
|
@@ -1926,20 +1951,20 @@ class q extends HTMLElement {
|
|
|
1926
1951
|
this._changedRowIndices.clear(), e || this.#s("changed-rows-reset", { rows: this.changedRows, indices: this.changedRowIndices }), this.rowPool.forEach((t) => t.classList.remove("changed"));
|
|
1927
1952
|
}
|
|
1928
1953
|
async beginBulkEdit(e) {
|
|
1929
|
-
this.#
|
|
1954
|
+
this.#ee(e, this._rows[e]);
|
|
1930
1955
|
}
|
|
1931
1956
|
async commitActiveRowEdit() {
|
|
1932
|
-
this.activeEditRows !== -1 && this.#
|
|
1957
|
+
this.activeEditRows !== -1 && this.#O(this.activeEditRows, !1);
|
|
1933
1958
|
}
|
|
1934
1959
|
async ready() {
|
|
1935
|
-
return this.#
|
|
1960
|
+
return this.#H;
|
|
1936
1961
|
}
|
|
1937
1962
|
async forceLayout() {
|
|
1938
|
-
this.#
|
|
1963
|
+
this.#d(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
|
|
1939
1964
|
}
|
|
1940
1965
|
/** Public method: returns a frozen snapshot of the merged effective configuration */
|
|
1941
1966
|
async getConfig() {
|
|
1942
|
-
return Object.freeze({ ...this.#
|
|
1967
|
+
return Object.freeze({ ...this.#n || {} });
|
|
1943
1968
|
}
|
|
1944
1969
|
// ---------------- Column Visibility API ----------------
|
|
1945
1970
|
/**
|
|
@@ -1949,15 +1974,15 @@ class q extends HTMLElement {
|
|
|
1949
1974
|
* @returns True if visibility was changed, false if column not found or locked
|
|
1950
1975
|
*/
|
|
1951
1976
|
setColumnVisible(e, t) {
|
|
1952
|
-
const n = this.#
|
|
1953
|
-
if (!
|
|
1977
|
+
const n = this.#n.columns, i = n?.find((r) => r.field === e);
|
|
1978
|
+
if (!i || !t && i.lockVisible || !t && (n ?? []).filter((a) => !a.hidden && a.field !== e).length === 0)
|
|
1954
1979
|
return !1;
|
|
1955
|
-
const
|
|
1956
|
-
return
|
|
1980
|
+
const s = !!i.hidden, l = !t;
|
|
1981
|
+
return s !== l ? (i.hidden = l, this.#s("column-visibility", {
|
|
1957
1982
|
field: e,
|
|
1958
1983
|
visible: t,
|
|
1959
1984
|
visibleColumns: (n ?? []).filter((r) => !r.hidden).map((r) => r.field)
|
|
1960
|
-
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#
|
|
1985
|
+
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#d(), this.requestStateChange(), !0) : !1;
|
|
1961
1986
|
}
|
|
1962
1987
|
/**
|
|
1963
1988
|
* Toggle the visibility of a column.
|
|
@@ -1965,8 +1990,8 @@ class q extends HTMLElement {
|
|
|
1965
1990
|
* @returns True if visibility was toggled, false if column not found or locked
|
|
1966
1991
|
*/
|
|
1967
1992
|
toggleColumnVisibility(e) {
|
|
1968
|
-
const
|
|
1969
|
-
return this.setColumnVisible(e,
|
|
1993
|
+
const i = !!this.#n.columns?.find((s) => s.field === e)?.hidden;
|
|
1994
|
+
return this.setColumnVisible(e, i);
|
|
1970
1995
|
}
|
|
1971
1996
|
/**
|
|
1972
1997
|
* Check if a column is currently visible.
|
|
@@ -1974,19 +1999,19 @@ class q extends HTMLElement {
|
|
|
1974
1999
|
* @returns True if visible, false if hidden or not found
|
|
1975
2000
|
*/
|
|
1976
2001
|
isColumnVisible(e) {
|
|
1977
|
-
const n = this.#
|
|
2002
|
+
const n = this.#n.columns?.find((i) => i.field === e);
|
|
1978
2003
|
return n ? !n.hidden : !1;
|
|
1979
2004
|
}
|
|
1980
2005
|
/**
|
|
1981
2006
|
* Show all columns.
|
|
1982
2007
|
*/
|
|
1983
2008
|
showAllColumns() {
|
|
1984
|
-
const e = this.#
|
|
2009
|
+
const e = this.#n.columns;
|
|
1985
2010
|
e?.some((n) => n.hidden) && (e?.forEach((n) => {
|
|
1986
2011
|
n.hidden = !1;
|
|
1987
2012
|
}), this.#s("column-visibility", {
|
|
1988
2013
|
visibleColumns: (e ?? []).map((n) => n.field)
|
|
1989
|
-
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#
|
|
2014
|
+
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#d(), this.requestStateChange());
|
|
1990
2015
|
}
|
|
1991
2016
|
/**
|
|
1992
2017
|
* Get list of all column fields (including hidden).
|
|
@@ -1995,7 +2020,7 @@ class q extends HTMLElement {
|
|
|
1995
2020
|
* @returns Array of all field names with their visibility status
|
|
1996
2021
|
*/
|
|
1997
2022
|
getAllColumns() {
|
|
1998
|
-
return (this.#
|
|
2023
|
+
return (this.#n.columns ?? []).map((t) => ({
|
|
1999
2024
|
field: t.field,
|
|
2000
2025
|
header: t.header || t.field,
|
|
2001
2026
|
visible: !t.hidden,
|
|
@@ -2009,14 +2034,14 @@ class q extends HTMLElement {
|
|
|
2009
2034
|
*/
|
|
2010
2035
|
setColumnOrder(e) {
|
|
2011
2036
|
if (!e.length) return;
|
|
2012
|
-
const t = new Map(this._columns.map((
|
|
2013
|
-
for (const
|
|
2014
|
-
const
|
|
2015
|
-
|
|
2037
|
+
const t = new Map(this._columns.map((i) => [i.field, i])), n = [];
|
|
2038
|
+
for (const i of e) {
|
|
2039
|
+
const s = t.get(i);
|
|
2040
|
+
s && (n.push(s), t.delete(i));
|
|
2016
2041
|
}
|
|
2017
|
-
for (const
|
|
2018
|
-
n.push(
|
|
2019
|
-
this._columns = n, this.#
|
|
2042
|
+
for (const i of t.values())
|
|
2043
|
+
n.push(i);
|
|
2044
|
+
this._columns = n, this.#S(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
2020
2045
|
}
|
|
2021
2046
|
/**
|
|
2022
2047
|
* Get the current column order as an array of field names.
|
|
@@ -2039,7 +2064,7 @@ class q extends HTMLElement {
|
|
|
2039
2064
|
* Use this to restore previously saved column state.
|
|
2040
2065
|
*/
|
|
2041
2066
|
set columnState(e) {
|
|
2042
|
-
e && (this.#
|
|
2067
|
+
e && (this.#h = e, this.#i && this.#le(e));
|
|
2043
2068
|
}
|
|
2044
2069
|
/**
|
|
2045
2070
|
* Get the current column state.
|
|
@@ -2050,10 +2075,10 @@ class q extends HTMLElement {
|
|
|
2050
2075
|
/**
|
|
2051
2076
|
* Apply column state internally.
|
|
2052
2077
|
*/
|
|
2053
|
-
#
|
|
2054
|
-
(this.#
|
|
2078
|
+
#le(e) {
|
|
2079
|
+
(this.#n.columns ?? []).forEach((n) => {
|
|
2055
2080
|
n.hidden = !1;
|
|
2056
|
-
}), this.#
|
|
2081
|
+
}), this.#K(e), this.#d();
|
|
2057
2082
|
}
|
|
2058
2083
|
/**
|
|
2059
2084
|
* Request a state change event to be emitted.
|
|
@@ -2062,26 +2087,26 @@ class q extends HTMLElement {
|
|
|
2062
2087
|
* The event is debounced to avoid excessive events during drag operations.
|
|
2063
2088
|
*/
|
|
2064
2089
|
requestStateChange() {
|
|
2065
|
-
this.#
|
|
2090
|
+
this.#k || (this.#k = me(
|
|
2066
2091
|
this,
|
|
2067
2092
|
() => this.#t?.getAll() ?? [],
|
|
2068
2093
|
(e) => this.#s("column-state-change", e)
|
|
2069
|
-
)), this.#
|
|
2094
|
+
)), this.#k();
|
|
2070
2095
|
}
|
|
2071
2096
|
/**
|
|
2072
2097
|
* Reset column state to initial configuration.
|
|
2073
2098
|
* Clears all user modifications (order, width, visibility, sort).
|
|
2074
2099
|
*/
|
|
2075
2100
|
resetColumnState() {
|
|
2076
|
-
this.#
|
|
2101
|
+
this.#h = void 0, (this.#n.columns ?? []).forEach((n) => {
|
|
2077
2102
|
n.hidden = !1;
|
|
2078
|
-
}), this.sortState = null, this.__originalOrder = [], this.#
|
|
2103
|
+
}), this.sortState = null, this.__originalOrder = [], this.#u(), this.#d();
|
|
2079
2104
|
const t = this.#t?.getAll() ?? [];
|
|
2080
2105
|
for (const n of t)
|
|
2081
2106
|
if (n.applyColumnState)
|
|
2082
|
-
for (const
|
|
2083
|
-
n.applyColumnState(
|
|
2084
|
-
field:
|
|
2107
|
+
for (const i of this._columns)
|
|
2108
|
+
n.applyColumnState(i.field, {
|
|
2109
|
+
field: i.field,
|
|
2085
2110
|
order: 0,
|
|
2086
2111
|
visible: !0
|
|
2087
2112
|
});
|
|
@@ -2103,7 +2128,7 @@ class q extends HTMLElement {
|
|
|
2103
2128
|
console.warn(`[tbw-grid] Tool panel "${e}" not found`);
|
|
2104
2129
|
return;
|
|
2105
2130
|
}
|
|
2106
|
-
this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#
|
|
2131
|
+
this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#o, this.#e), ne(this.#o, this.#e), Ue(this.#o, this.#e), this.#s("tool-panel-open", { id: e });
|
|
2107
2132
|
}
|
|
2108
2133
|
/**
|
|
2109
2134
|
* Close the currently open tool panel.
|
|
@@ -2111,7 +2136,7 @@ class q extends HTMLElement {
|
|
|
2111
2136
|
closeToolPanel() {
|
|
2112
2137
|
if (!this.#e.activePanel) return;
|
|
2113
2138
|
const e = this.#e.activePanel, t = this.#e.toolPanels.get(e);
|
|
2114
|
-
this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null), t?.onClose?.(), this.#e.activePanel = null, oe(this.#
|
|
2139
|
+
this.#e.activePanelCleanup && (this.#e.activePanelCleanup(), this.#e.activePanelCleanup = null), t?.onClose?.(), this.#e.activePanel = null, oe(this.#o, this.#e), ne(this.#o, this.#e), this.#s("tool-panel-close", { id: e });
|
|
2115
2140
|
}
|
|
2116
2141
|
/**
|
|
2117
2142
|
* Toggle a tool panel open/closed.
|
|
@@ -2133,13 +2158,13 @@ class q extends HTMLElement {
|
|
|
2133
2158
|
console.warn(`[tbw-grid] Tool panel "${e.id}" already registered`);
|
|
2134
2159
|
return;
|
|
2135
2160
|
}
|
|
2136
|
-
this.#e.toolPanels.set(e.id, e), this.#
|
|
2161
|
+
this.#e.toolPanels.set(e.id, e), this.#c && this.#b();
|
|
2137
2162
|
}
|
|
2138
2163
|
/**
|
|
2139
2164
|
* Unregister a custom tool panel.
|
|
2140
2165
|
*/
|
|
2141
2166
|
unregisterToolPanel(e) {
|
|
2142
|
-
this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#
|
|
2167
|
+
this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#c && this.#b();
|
|
2143
2168
|
}
|
|
2144
2169
|
/**
|
|
2145
2170
|
* Get registered header content definitions.
|
|
@@ -2155,20 +2180,20 @@ class q extends HTMLElement {
|
|
|
2155
2180
|
console.warn(`[tbw-grid] Header content "${e.id}" already registered`);
|
|
2156
2181
|
return;
|
|
2157
2182
|
}
|
|
2158
|
-
this.#e.headerContents.set(e.id, e), this.#
|
|
2183
|
+
this.#e.headerContents.set(e.id, e), this.#c && te(this.#o, this.#e);
|
|
2159
2184
|
}
|
|
2160
2185
|
/**
|
|
2161
2186
|
* Unregister custom header content.
|
|
2162
2187
|
*/
|
|
2163
2188
|
unregisterHeaderContent(e) {
|
|
2164
2189
|
const t = this.#e.headerContentCleanups.get(e);
|
|
2165
|
-
t && (t(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#
|
|
2190
|
+
t && (t(), this.#e.headerContentCleanups.delete(e)), this.#e.headerContents.get(e)?.onDestroy?.(), this.#e.headerContents.delete(e), this.#o.querySelector(`[data-header-content="${e}"]`)?.remove();
|
|
2166
2191
|
}
|
|
2167
2192
|
/**
|
|
2168
2193
|
* Get all registered toolbar buttons.
|
|
2169
2194
|
*/
|
|
2170
2195
|
getToolbarButtons() {
|
|
2171
|
-
return Xe(this.#
|
|
2196
|
+
return Xe(this.#n?.shell, this.#e);
|
|
2172
2197
|
}
|
|
2173
2198
|
/**
|
|
2174
2199
|
* Register a custom toolbar button programmatically.
|
|
@@ -2178,14 +2203,14 @@ class q extends HTMLElement {
|
|
|
2178
2203
|
console.warn(`[tbw-grid] Toolbar button "${e.id}" already registered`);
|
|
2179
2204
|
return;
|
|
2180
2205
|
}
|
|
2181
|
-
this.#e.toolbarButtons.set(e.id, e), this.#
|
|
2206
|
+
this.#e.toolbarButtons.set(e.id, e), this.#c && this.#b();
|
|
2182
2207
|
}
|
|
2183
2208
|
/**
|
|
2184
2209
|
* Unregister a custom toolbar button.
|
|
2185
2210
|
*/
|
|
2186
2211
|
unregisterToolbarButton(e) {
|
|
2187
2212
|
const t = this.#e.toolbarButtonCleanups.get(e);
|
|
2188
|
-
t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#
|
|
2213
|
+
t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#c && this.#b();
|
|
2189
2214
|
}
|
|
2190
2215
|
/**
|
|
2191
2216
|
* Enable/disable a toolbar button by ID.
|
|
@@ -2193,21 +2218,21 @@ class q extends HTMLElement {
|
|
|
2193
2218
|
setToolbarButtonDisabled(e, t) {
|
|
2194
2219
|
const n = this.#e.toolbarButtons.get(e);
|
|
2195
2220
|
n && (n.disabled = t);
|
|
2196
|
-
const
|
|
2197
|
-
|
|
2221
|
+
const i = this.#o.querySelector(`[data-btn="${e}"]`);
|
|
2222
|
+
i && (i.disabled = t);
|
|
2198
2223
|
}
|
|
2199
2224
|
/**
|
|
2200
2225
|
* Re-parse light DOM shell elements and refresh shell header.
|
|
2201
2226
|
* Call this after dynamically modifying <tbw-grid-header> children.
|
|
2202
2227
|
*/
|
|
2203
2228
|
refreshShellHeader() {
|
|
2204
|
-
this.#
|
|
2229
|
+
this.#b();
|
|
2205
2230
|
}
|
|
2206
2231
|
/**
|
|
2207
2232
|
* Internal shell header refresh.
|
|
2208
2233
|
*/
|
|
2209
|
-
#
|
|
2210
|
-
ee(this, this.#e), this.#
|
|
2234
|
+
#b() {
|
|
2235
|
+
ee(this, this.#e), this.#W(), this.#B();
|
|
2211
2236
|
}
|
|
2212
2237
|
// ---------------- Virtual Window ----------------
|
|
2213
2238
|
/**
|
|
@@ -2218,26 +2243,26 @@ class q extends HTMLElement {
|
|
|
2218
2243
|
if (!this.bodyEl) return;
|
|
2219
2244
|
const t = this._rows.length;
|
|
2220
2245
|
if (!this.virtualization.enabled) {
|
|
2221
|
-
this.#M(0, t), this.#
|
|
2246
|
+
this.#M(0, t), this.#w();
|
|
2222
2247
|
return;
|
|
2223
2248
|
}
|
|
2224
|
-
if (this.#
|
|
2225
|
-
this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#M(0, t, this.__rowRenderEpoch), this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * this.virtualization.rowHeight}px`), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), this.#
|
|
2249
|
+
if (this.#te()) {
|
|
2250
|
+
this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#M(0, t, this.__rowRenderEpoch), this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * this.virtualization.rowHeight}px`), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), this.#w();
|
|
2226
2251
|
return;
|
|
2227
2252
|
}
|
|
2228
|
-
const n = this.virtualization.container ?? this,
|
|
2253
|
+
const n = this.virtualization.container ?? this, s = (this.virtualization.viewportEl ?? n).clientHeight, l = this.virtualization.rowHeight, r = n.scrollTop;
|
|
2229
2254
|
let a = Math.floor(r / l);
|
|
2230
2255
|
a < 0 && (a = 0);
|
|
2231
|
-
const f = Math.ceil(
|
|
2256
|
+
const f = Math.ceil(s / l) + 2;
|
|
2232
2257
|
let p = a + f;
|
|
2233
2258
|
p > t && (p = t), this.virtualization.start = a, this.virtualization.end = p, this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * l}px`);
|
|
2234
2259
|
const w = -(r % l);
|
|
2235
|
-
this.bodyEl.style.transform = `translateY(${w}px)`, this.#M(a, p, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#
|
|
2260
|
+
this.bodyEl.style.transform = `translateY(${w}px)`, this.#M(a, p, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#w();
|
|
2236
2261
|
}
|
|
2237
2262
|
// ---------------- Render ----------------
|
|
2238
|
-
#
|
|
2263
|
+
#W() {
|
|
2239
2264
|
ee(this, this.#e);
|
|
2240
|
-
const e = this.#
|
|
2265
|
+
const e = this.#n?.shell, t = Ke(e, this.#e), n = `
|
|
2241
2266
|
<div class="tbw-scroll-area">
|
|
2242
2267
|
<div class="rows-body-wrapper">
|
|
2243
2268
|
<div class="rows-body">
|
|
@@ -2257,15 +2282,15 @@ class q extends HTMLElement {
|
|
|
2257
2282
|
</div>
|
|
2258
2283
|
`;
|
|
2259
2284
|
if (t) {
|
|
2260
|
-
const
|
|
2261
|
-
this.#
|
|
2285
|
+
const i = We(e, this.#e), s = Fe(e, this.#e, n);
|
|
2286
|
+
this.#o.innerHTML = `
|
|
2262
2287
|
<div class="tbw-grid-root has-shell">
|
|
2263
|
-
${s}
|
|
2264
2288
|
${i}
|
|
2289
|
+
${s}
|
|
2265
2290
|
</div>
|
|
2266
|
-
`, this.#
|
|
2291
|
+
`, this.#re(), this.#c = !0;
|
|
2267
2292
|
} else
|
|
2268
|
-
this.#
|
|
2293
|
+
this.#o.innerHTML = `
|
|
2269
2294
|
<div class="tbw-grid-root">
|
|
2270
2295
|
<div class="tbw-grid-content">
|
|
2271
2296
|
${n}
|
|
@@ -2276,24 +2301,24 @@ class q extends HTMLElement {
|
|
|
2276
2301
|
/**
|
|
2277
2302
|
* Set up shell event listeners after render.
|
|
2278
2303
|
*/
|
|
2279
|
-
#
|
|
2280
|
-
Ve(this.#
|
|
2304
|
+
#re() {
|
|
2305
|
+
Ve(this.#o, this.#n?.shell, this.#e, {
|
|
2281
2306
|
onPanelToggle: (e) => this.toggleToolPanel(e),
|
|
2282
2307
|
onPanelClose: () => this.closeToolPanel(),
|
|
2283
|
-
onToolbarButtonClick: (e) => this.#
|
|
2308
|
+
onToolbarButtonClick: (e) => this.#ae(e)
|
|
2284
2309
|
});
|
|
2285
2310
|
}
|
|
2286
2311
|
/**
|
|
2287
2312
|
* Handle toolbar button click (for config buttons with action).
|
|
2288
2313
|
*/
|
|
2289
|
-
#
|
|
2290
|
-
const n = (this.#
|
|
2314
|
+
#ae(e) {
|
|
2315
|
+
const n = (this.#n?.shell?.header?.toolbarButtons ?? []).find((s) => s.id === e);
|
|
2291
2316
|
if (n?.action) {
|
|
2292
2317
|
n.action();
|
|
2293
2318
|
return;
|
|
2294
2319
|
}
|
|
2295
|
-
const
|
|
2296
|
-
|
|
2320
|
+
const i = this.#e.toolbarButtons.get(e);
|
|
2321
|
+
i?.action && i.action();
|
|
2297
2322
|
}
|
|
2298
2323
|
}
|
|
2299
2324
|
customElements.get(q.tagName) || customElements.define(q.tagName, q);
|
|
@@ -2396,6 +2421,26 @@ class ue {
|
|
|
2396
2421
|
get shadowRoot() {
|
|
2397
2422
|
return this.grid?.shadowRoot ?? null;
|
|
2398
2423
|
}
|
|
2424
|
+
/**
|
|
2425
|
+
* Get the disconnect signal for event listener cleanup.
|
|
2426
|
+
* This signal is aborted when the grid disconnects from the DOM.
|
|
2427
|
+
* Use this when adding event listeners that should be cleaned up automatically.
|
|
2428
|
+
*
|
|
2429
|
+
* Best for:
|
|
2430
|
+
* - Document/window-level listeners added in attach()
|
|
2431
|
+
* - Listeners on the grid element itself
|
|
2432
|
+
* - Any listener that should persist across renders
|
|
2433
|
+
*
|
|
2434
|
+
* Not needed for:
|
|
2435
|
+
* - Listeners on elements created in afterRender() (removed with element)
|
|
2436
|
+
*
|
|
2437
|
+
* @example
|
|
2438
|
+
* element.addEventListener('click', handler, { signal: this.disconnectSignal });
|
|
2439
|
+
* document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
|
|
2440
|
+
*/
|
|
2441
|
+
get disconnectSignal() {
|
|
2442
|
+
return this.grid?.disconnectSignal;
|
|
2443
|
+
}
|
|
2399
2444
|
/**
|
|
2400
2445
|
* Log a warning message.
|
|
2401
2446
|
*/
|
|
@@ -2403,7 +2448,7 @@ class ue {
|
|
|
2403
2448
|
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
2404
2449
|
}
|
|
2405
2450
|
}
|
|
2406
|
-
function
|
|
2451
|
+
function N(o) {
|
|
2407
2452
|
return {
|
|
2408
2453
|
startRow: Math.min(o.startRow, o.endRow),
|
|
2409
2454
|
startCol: Math.min(o.startCol, o.endCol),
|
|
@@ -2412,7 +2457,7 @@ function z(o) {
|
|
|
2412
2457
|
};
|
|
2413
2458
|
}
|
|
2414
2459
|
function Ze(o) {
|
|
2415
|
-
const e =
|
|
2460
|
+
const e = N(o);
|
|
2416
2461
|
return {
|
|
2417
2462
|
from: { row: e.startRow, col: e.startCol },
|
|
2418
2463
|
to: { row: e.endRow, col: e.endCol }
|
|
@@ -2422,17 +2467,17 @@ function K(o) {
|
|
|
2422
2467
|
return o.map(Ze);
|
|
2423
2468
|
}
|
|
2424
2469
|
function Je(o, e, t) {
|
|
2425
|
-
const n =
|
|
2470
|
+
const n = N(t);
|
|
2426
2471
|
return o >= n.startRow && o <= n.endRow && e >= n.startCol && e <= n.endCol;
|
|
2427
2472
|
}
|
|
2428
2473
|
function ie(o, e, t) {
|
|
2429
2474
|
return t.some((n) => Je(o, e, n));
|
|
2430
2475
|
}
|
|
2431
2476
|
function Qe(o) {
|
|
2432
|
-
const e = [], t =
|
|
2477
|
+
const e = [], t = N(o);
|
|
2433
2478
|
for (let n = t.startRow; n <= t.endRow; n++)
|
|
2434
|
-
for (let
|
|
2435
|
-
e.push({ row: n, col:
|
|
2479
|
+
for (let i = t.startCol; i <= t.endCol; i++)
|
|
2480
|
+
e.push({ row: n, col: i });
|
|
2436
2481
|
return e;
|
|
2437
2482
|
}
|
|
2438
2483
|
function et(o) {
|
|
@@ -2462,9 +2507,9 @@ function tt(o, e, t) {
|
|
|
2462
2507
|
]
|
|
2463
2508
|
};
|
|
2464
2509
|
if (o === "row" && e.selected.size > 0) {
|
|
2465
|
-
const n = [...e.selected].map((
|
|
2466
|
-
from: { row:
|
|
2467
|
-
to: { row:
|
|
2510
|
+
const n = [...e.selected].map((i) => ({
|
|
2511
|
+
from: { row: i, col: 0 },
|
|
2512
|
+
to: { row: i, col: t - 1 }
|
|
2468
2513
|
}));
|
|
2469
2514
|
return { mode: o, ranges: n };
|
|
2470
2515
|
}
|
|
@@ -2496,13 +2541,13 @@ class st extends ue {
|
|
|
2496
2541
|
}
|
|
2497
2542
|
// ===== Event Handlers =====
|
|
2498
2543
|
onCellClick(e) {
|
|
2499
|
-
const { rowIndex: t, colIndex: n, originalEvent:
|
|
2500
|
-
if (
|
|
2544
|
+
const { rowIndex: t, colIndex: n, originalEvent: i } = e, { mode: s } = this.config;
|
|
2545
|
+
if (s === "cell")
|
|
2501
2546
|
return this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2502
|
-
if (
|
|
2547
|
+
if (s === "row")
|
|
2503
2548
|
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2504
|
-
if (
|
|
2505
|
-
const l =
|
|
2549
|
+
if (s === "range") {
|
|
2550
|
+
const l = i.shiftKey, r = i.ctrlKey || i.metaKey;
|
|
2506
2551
|
if (l && this.cellAnchor) {
|
|
2507
2552
|
const a = se(this.cellAnchor, { row: t, col: n });
|
|
2508
2553
|
r ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
|
|
@@ -2532,15 +2577,15 @@ class st extends ue {
|
|
|
2532
2577
|
if (e.key === "Escape")
|
|
2533
2578
|
return t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2534
2579
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
2535
|
-
const n = this.rows.length,
|
|
2536
|
-
if (n > 0 &&
|
|
2537
|
-
const
|
|
2580
|
+
const n = this.rows.length, i = this.columns.length;
|
|
2581
|
+
if (n > 0 && i > 0) {
|
|
2582
|
+
const s = {
|
|
2538
2583
|
startRow: 0,
|
|
2539
2584
|
startCol: 0,
|
|
2540
2585
|
endRow: n - 1,
|
|
2541
|
-
endCol:
|
|
2586
|
+
endCol: i - 1
|
|
2542
2587
|
};
|
|
2543
|
-
return this.ranges = [
|
|
2588
|
+
return this.ranges = [s], this.activeRange = s, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2544
2589
|
}
|
|
2545
2590
|
}
|
|
2546
2591
|
return !1;
|
|
@@ -2551,13 +2596,13 @@ class st extends ue {
|
|
|
2551
2596
|
this.isDragging = !0;
|
|
2552
2597
|
const t = e.rowIndex, n = e.colIndex;
|
|
2553
2598
|
this.cellAnchor = { row: t, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
2554
|
-
const
|
|
2599
|
+
const s = {
|
|
2555
2600
|
startRow: t,
|
|
2556
2601
|
startCol: n,
|
|
2557
2602
|
endRow: t,
|
|
2558
2603
|
endCol: n
|
|
2559
2604
|
};
|
|
2560
|
-
return this.ranges.push(
|
|
2605
|
+
return this.ranges.push(s), this.activeRange = s, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2561
2606
|
}
|
|
2562
2607
|
onCellMouseMove(e) {
|
|
2563
2608
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
@@ -2572,40 +2617,40 @@ class st extends ue {
|
|
|
2572
2617
|
* Apply selection classes to visible cells/rows.
|
|
2573
2618
|
* Shared by afterRender and onScrollRender.
|
|
2574
2619
|
*/
|
|
2575
|
-
#
|
|
2620
|
+
#o() {
|
|
2576
2621
|
const e = this.shadowRoot;
|
|
2577
2622
|
if (!e) return;
|
|
2578
2623
|
const { mode: t } = this.config;
|
|
2579
|
-
e.querySelectorAll(".cell").forEach((
|
|
2580
|
-
|
|
2624
|
+
e.querySelectorAll(".cell").forEach((s) => {
|
|
2625
|
+
s.classList.remove("selected", "top", "bottom", "first", "last");
|
|
2581
2626
|
});
|
|
2582
|
-
const
|
|
2583
|
-
if (
|
|
2584
|
-
|
|
2585
|
-
}), t === "row" &&
|
|
2586
|
-
const l =
|
|
2587
|
-
r >= 0 && this.selected.has(r) && (
|
|
2627
|
+
const i = e.querySelectorAll(".data-grid-row");
|
|
2628
|
+
if (i.forEach((s) => {
|
|
2629
|
+
s.classList.remove("selected", "row-focus");
|
|
2630
|
+
}), t === "row" && i.forEach((s) => {
|
|
2631
|
+
const l = s.querySelector(".cell[data-row]"), r = parseInt(l?.getAttribute("data-row") ?? "-1", 10);
|
|
2632
|
+
r >= 0 && this.selected.has(r) && (s.classList.add("selected", "row-focus"), s.querySelectorAll(".cell-focus").forEach((a) => a.classList.remove("cell-focus")));
|
|
2588
2633
|
}), t === "range" && this.ranges.length > 0) {
|
|
2589
|
-
const
|
|
2634
|
+
const s = this.activeRange ? N(this.activeRange) : null;
|
|
2590
2635
|
e.querySelectorAll(".cell[data-row][data-col]").forEach((r) => {
|
|
2591
2636
|
const a = parseInt(r.getAttribute("data-row") ?? "-1", 10), f = parseInt(r.getAttribute("data-col") ?? "-1", 10);
|
|
2592
|
-
a >= 0 && f >= 0 && ie(a, f, this.ranges) && (r.classList.add("selected"), r.classList.remove("cell-focus"),
|
|
2637
|
+
a >= 0 && f >= 0 && ie(a, f, this.ranges) && (r.classList.add("selected"), r.classList.remove("cell-focus"), s && (a === s.startRow && r.classList.add("top"), a === s.endRow && r.classList.add("bottom"), f === s.startCol && r.classList.add("first"), f === s.endCol && r.classList.add("last")));
|
|
2593
2638
|
});
|
|
2594
2639
|
}
|
|
2595
|
-
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((
|
|
2640
|
+
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((s) => s.classList.remove("cell-focus"));
|
|
2596
2641
|
}
|
|
2597
2642
|
afterRender() {
|
|
2598
2643
|
const e = this.shadowRoot;
|
|
2599
2644
|
if (!e) return;
|
|
2600
2645
|
const t = e.children[0], { mode: n } = this.config;
|
|
2601
|
-
this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#
|
|
2646
|
+
this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#o();
|
|
2602
2647
|
}
|
|
2603
2648
|
/**
|
|
2604
2649
|
* Called after scroll-triggered row rendering.
|
|
2605
2650
|
* Reapplies selection classes to recycled DOM elements.
|
|
2606
2651
|
*/
|
|
2607
2652
|
onScrollRender() {
|
|
2608
|
-
this.#
|
|
2653
|
+
this.#o();
|
|
2609
2654
|
}
|
|
2610
2655
|
// ===== Public API =====
|
|
2611
2656
|
/**
|
|
@@ -2708,19 +2753,19 @@ class st extends ue {
|
|
|
2708
2753
|
function G(o, e, t) {
|
|
2709
2754
|
return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
|
|
2710
2755
|
}
|
|
2711
|
-
function fe(o, e, t, n = null,
|
|
2712
|
-
const
|
|
2756
|
+
function fe(o, e, t, n = null, i = 0) {
|
|
2757
|
+
const s = e.childrenField ?? "children", l = [];
|
|
2713
2758
|
for (let r = 0; r < o.length; r++) {
|
|
2714
|
-
const a = o[r], f = G(a, r, n), p = a[
|
|
2759
|
+
const a = o[r], f = G(a, r, n), p = a[s], w = Array.isArray(p) && p.length > 0, u = t.has(f);
|
|
2715
2760
|
if (l.push({
|
|
2716
2761
|
key: f,
|
|
2717
2762
|
data: a,
|
|
2718
|
-
depth:
|
|
2763
|
+
depth: i,
|
|
2719
2764
|
hasChildren: w,
|
|
2720
|
-
isExpanded:
|
|
2765
|
+
isExpanded: u,
|
|
2721
2766
|
parentKey: n
|
|
2722
|
-
}), w &&
|
|
2723
|
-
const c = fe(p, e, t, f,
|
|
2767
|
+
}), w && u) {
|
|
2768
|
+
const c = fe(p, e, t, f, i + 1);
|
|
2724
2769
|
l.push(...c);
|
|
2725
2770
|
}
|
|
2726
2771
|
}
|
|
@@ -2731,29 +2776,29 @@ function le(o, e) {
|
|
|
2731
2776
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
2732
2777
|
}
|
|
2733
2778
|
function W(o, e, t = null, n = 0) {
|
|
2734
|
-
const
|
|
2779
|
+
const i = e.childrenField ?? "children", s = /* @__PURE__ */ new Set();
|
|
2735
2780
|
for (let l = 0; l < o.length; l++) {
|
|
2736
|
-
const r = o[l], a = G(r, l, t), f = r[
|
|
2781
|
+
const r = o[l], a = G(r, l, t), f = r[i];
|
|
2737
2782
|
if (Array.isArray(f) && f.length > 0) {
|
|
2738
|
-
|
|
2783
|
+
s.add(a);
|
|
2739
2784
|
const p = W(f, e, a, n + 1);
|
|
2740
|
-
for (const w of p)
|
|
2785
|
+
for (const w of p) s.add(w);
|
|
2741
2786
|
}
|
|
2742
2787
|
}
|
|
2743
|
-
return
|
|
2788
|
+
return s;
|
|
2744
2789
|
}
|
|
2745
2790
|
function ot() {
|
|
2746
2791
|
return /* @__PURE__ */ new Set();
|
|
2747
2792
|
}
|
|
2748
|
-
function pe(o, e, t, n = null,
|
|
2749
|
-
const
|
|
2793
|
+
function pe(o, e, t, n = null, i = 0) {
|
|
2794
|
+
const s = t.childrenField ?? "children";
|
|
2750
2795
|
for (let l = 0; l < o.length; l++) {
|
|
2751
2796
|
const r = o[l], a = G(r, l, n);
|
|
2752
2797
|
if (a === e)
|
|
2753
2798
|
return [a];
|
|
2754
|
-
const f = r[
|
|
2799
|
+
const f = r[s];
|
|
2755
2800
|
if (Array.isArray(f) && f.length > 0) {
|
|
2756
|
-
const p = pe(f, e, t, a,
|
|
2801
|
+
const p = pe(f, e, t, a, i + 1);
|
|
2757
2802
|
if (p)
|
|
2758
2803
|
return [a, ...p];
|
|
2759
2804
|
}
|
|
@@ -2761,12 +2806,12 @@ function pe(o, e, t, n = null, s = 0) {
|
|
|
2761
2806
|
return null;
|
|
2762
2807
|
}
|
|
2763
2808
|
function nt(o, e, t, n) {
|
|
2764
|
-
const
|
|
2765
|
-
if (!
|
|
2766
|
-
const
|
|
2767
|
-
for (let l = 0; l <
|
|
2768
|
-
|
|
2769
|
-
return
|
|
2809
|
+
const i = pe(o, e, t);
|
|
2810
|
+
if (!i) return n;
|
|
2811
|
+
const s = new Set(n);
|
|
2812
|
+
for (let l = 0; l < i.length - 1; l++)
|
|
2813
|
+
s.add(i[l]);
|
|
2814
|
+
return s;
|
|
2770
2815
|
}
|
|
2771
2816
|
function re(o, e = "children") {
|
|
2772
2817
|
if (!Array.isArray(o) || o.length === 0) return !1;
|
|
@@ -2840,28 +2885,31 @@ class lt extends ue {
|
|
|
2840
2885
|
}
|
|
2841
2886
|
processColumns(e) {
|
|
2842
2887
|
if (this.flattenedRows.length === 0) return [...e];
|
|
2843
|
-
const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0,
|
|
2844
|
-
if (
|
|
2845
|
-
const
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2888
|
+
const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, i = [...e];
|
|
2889
|
+
if (i.length > 0) {
|
|
2890
|
+
const s = { ...i[0] }, l = s.viewRenderer;
|
|
2891
|
+
if (l?.__treeWrapped)
|
|
2892
|
+
return i;
|
|
2893
|
+
const r = (a) => {
|
|
2894
|
+
const { value: f, row: p, column: w } = a, u = p.__treeDepth ?? 0, c = p.__treeHasChildren ?? !1, h = p.__treeExpanded ?? !1, d = document.createElement("span");
|
|
2895
|
+
if (d.style.display = "flex", d.style.alignItems = "center", d.style.paddingLeft = `${u * t}px`, c && n) {
|
|
2896
|
+
const m = document.createElement("span");
|
|
2897
|
+
m.className = "tree-toggle", m.textContent = h ? "▼" : "▶", m.style.cursor = "pointer", m.style.marginRight = "4px", m.style.fontSize = "10px", m.setAttribute("data-tree-key", p.__treeKey), d.appendChild(m);
|
|
2851
2898
|
} else if (n) {
|
|
2852
|
-
const
|
|
2853
|
-
|
|
2899
|
+
const m = document.createElement("span");
|
|
2900
|
+
m.style.width = "14px", m.style.display = "inline-block", d.appendChild(m);
|
|
2854
2901
|
}
|
|
2855
|
-
const
|
|
2902
|
+
const g = document.createElement("span");
|
|
2856
2903
|
if (l) {
|
|
2857
|
-
const
|
|
2858
|
-
|
|
2904
|
+
const m = l(a);
|
|
2905
|
+
m instanceof Node ? g.appendChild(m) : g.textContent = String(m ?? f ?? "");
|
|
2859
2906
|
} else
|
|
2860
|
-
|
|
2861
|
-
return d.appendChild(
|
|
2862
|
-
}
|
|
2907
|
+
g.textContent = String(f ?? "");
|
|
2908
|
+
return d.appendChild(g), d;
|
|
2909
|
+
};
|
|
2910
|
+
r.__treeWrapped = !0, s.viewRenderer = r, i[0] = s;
|
|
2863
2911
|
}
|
|
2864
|
-
return
|
|
2912
|
+
return i;
|
|
2865
2913
|
}
|
|
2866
2914
|
// ===== Event Handlers =====
|
|
2867
2915
|
onCellClick(e) {
|
|
@@ -2869,12 +2917,12 @@ class lt extends ue {
|
|
|
2869
2917
|
if (!t?.classList.contains("tree-toggle")) return !1;
|
|
2870
2918
|
const n = t.getAttribute("data-tree-key");
|
|
2871
2919
|
if (!n) return !1;
|
|
2872
|
-
const
|
|
2873
|
-
return
|
|
2920
|
+
const i = this.rowKeyMap.get(n);
|
|
2921
|
+
return i ? (this.expandedKeys = le(this.expandedKeys, n), this.emit("tree-expand", {
|
|
2874
2922
|
key: n,
|
|
2875
|
-
row:
|
|
2923
|
+
row: i.data,
|
|
2876
2924
|
expanded: this.expandedKeys.has(n),
|
|
2877
|
-
depth:
|
|
2925
|
+
depth: i.depth
|
|
2878
2926
|
}), this.requestRender(), !0) : !1;
|
|
2879
2927
|
}
|
|
2880
2928
|
// ===== Public API =====
|
|
@@ -2950,7 +2998,7 @@ class lt extends ue {
|
|
|
2950
2998
|
}
|
|
2951
2999
|
`;
|
|
2952
3000
|
}
|
|
2953
|
-
const
|
|
3001
|
+
const y = {
|
|
2954
3002
|
// Root structure
|
|
2955
3003
|
ROOT: "tbw-grid-root",
|
|
2956
3004
|
HEADER: "header",
|
|
@@ -3003,22 +3051,22 @@ const C = {
|
|
|
3003
3051
|
TREE_LEVEL: "data-tree-level",
|
|
3004
3052
|
STICKY: "data-sticky"
|
|
3005
3053
|
}, rt = {
|
|
3006
|
-
ROOT: `.${
|
|
3007
|
-
HEADER: `.${
|
|
3008
|
-
HEADER_ROW: `.${
|
|
3009
|
-
HEADER_CELL: `.${
|
|
3010
|
-
ROWS_VIEWPORT: `.${
|
|
3011
|
-
ROWS_CONTAINER: `.${
|
|
3012
|
-
DATA_ROW: `.${
|
|
3013
|
-
DATA_CELL: `.${
|
|
3014
|
-
GROUP_ROW: `.${
|
|
3054
|
+
ROOT: `.${y.ROOT}`,
|
|
3055
|
+
HEADER: `.${y.HEADER}`,
|
|
3056
|
+
HEADER_ROW: `.${y.HEADER_ROW}`,
|
|
3057
|
+
HEADER_CELL: `.${y.HEADER_CELL}`,
|
|
3058
|
+
ROWS_VIEWPORT: `.${y.ROWS_VIEWPORT}`,
|
|
3059
|
+
ROWS_CONTAINER: `.${y.ROWS_CONTAINER}`,
|
|
3060
|
+
DATA_ROW: `.${y.DATA_ROW}`,
|
|
3061
|
+
DATA_CELL: `.${y.DATA_CELL}`,
|
|
3062
|
+
GROUP_ROW: `.${y.GROUP_ROW}`,
|
|
3015
3063
|
// By data attribute
|
|
3016
|
-
ROW_BY_INDEX: (o) => `.${
|
|
3017
|
-
CELL_BY_FIELD: (o) => `.${
|
|
3018
|
-
CELL_AT: (o, e) => `.${
|
|
3064
|
+
ROW_BY_INDEX: (o) => `.${y.DATA_ROW}[${H.ROW_INDEX}="${o}"]`,
|
|
3065
|
+
CELL_BY_FIELD: (o) => `.${y.DATA_CELL}[${H.FIELD}="${o}"]`,
|
|
3066
|
+
CELL_AT: (o, e) => `.${y.DATA_ROW}[${H.ROW_INDEX}="${o}"] .${y.DATA_CELL}[${H.COL_INDEX}="${e}"]`,
|
|
3019
3067
|
// State selectors
|
|
3020
|
-
SELECTED_ROWS: `.${
|
|
3021
|
-
EDITING_CELL: `.${
|
|
3068
|
+
SELECTED_ROWS: `.${y.DATA_ROW}.${y.SELECTED}`,
|
|
3069
|
+
EDITING_CELL: `.${y.DATA_CELL}.${y.EDITING}`
|
|
3022
3070
|
}, at = {
|
|
3023
3071
|
// Colors
|
|
3024
3072
|
COLOR_BG: "--tbw-color-bg",
|
|
@@ -3086,7 +3134,7 @@ const C = {
|
|
|
3086
3134
|
}, I = {
|
|
3087
3135
|
sum: (o, e) => o.reduce((t, n) => t + (Number(n[e]) || 0), 0),
|
|
3088
3136
|
avg: (o, e) => {
|
|
3089
|
-
const t = o.reduce((n,
|
|
3137
|
+
const t = o.reduce((n, i) => n + (Number(i[e]) || 0), 0);
|
|
3090
3138
|
return o.length ? t / o.length : 0;
|
|
3091
3139
|
},
|
|
3092
3140
|
count: (o) => o.length,
|
|
@@ -3094,7 +3142,7 @@ const C = {
|
|
|
3094
3142
|
max: (o, e) => Math.max(...o.map((t) => Number(t[e]) || -1 / 0)),
|
|
3095
3143
|
first: (o, e) => o[0]?.[e],
|
|
3096
3144
|
last: (o, e) => o[o.length - 1]?.[e]
|
|
3097
|
-
}, P = /* @__PURE__ */ new Map(),
|
|
3145
|
+
}, P = /* @__PURE__ */ new Map(), x = {
|
|
3098
3146
|
/**
|
|
3099
3147
|
* Register a custom aggregator function.
|
|
3100
3148
|
*/
|
|
@@ -3118,8 +3166,8 @@ const C = {
|
|
|
3118
3166
|
* Run an aggregator on a set of rows.
|
|
3119
3167
|
*/
|
|
3120
3168
|
run(o, e, t, n) {
|
|
3121
|
-
const
|
|
3122
|
-
return
|
|
3169
|
+
const i = this.get(o);
|
|
3170
|
+
return i ? i(e, t, n) : void 0;
|
|
3123
3171
|
},
|
|
3124
3172
|
/**
|
|
3125
3173
|
* Check if an aggregator exists.
|
|
@@ -3133,14 +3181,14 @@ const C = {
|
|
|
3133
3181
|
list() {
|
|
3134
3182
|
return [...Object.keys(I), ...P.keys()];
|
|
3135
3183
|
}
|
|
3136
|
-
}, ht =
|
|
3184
|
+
}, ht = x.register.bind(x), ut = x.unregister.bind(x), ft = x.get.bind(x), pt = x.run.bind(x), wt = x.list.bind(x);
|
|
3137
3185
|
export {
|
|
3138
3186
|
ue as BaseGridPlugin,
|
|
3139
3187
|
ct as DGEvents,
|
|
3140
3188
|
q as DataGridElement,
|
|
3141
|
-
|
|
3189
|
+
M as FitModeEnum,
|
|
3142
3190
|
at as GridCSSVars,
|
|
3143
|
-
|
|
3191
|
+
y as GridClasses,
|
|
3144
3192
|
H as GridDataAttrs,
|
|
3145
3193
|
q as GridElement,
|
|
3146
3194
|
rt as GridSelectors,
|
|
@@ -3148,7 +3196,7 @@ export {
|
|
|
3148
3196
|
Ye as PluginManager,
|
|
3149
3197
|
st as SelectionPlugin,
|
|
3150
3198
|
lt as TreePlugin,
|
|
3151
|
-
|
|
3199
|
+
x as aggregatorRegistry,
|
|
3152
3200
|
ft as getAggregator,
|
|
3153
3201
|
wt as listAggregators,
|
|
3154
3202
|
ht as registerAggregator,
|