@toolbox-web/grid 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/all.d.ts +1709 -135
- package/all.js +745 -645
- package/all.js.map +1 -1
- package/index.d.ts +161 -1
- package/index.js +1050 -913
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +110 -52
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +78 -20
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +163 -95
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +93 -35
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +188 -133
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +69 -11
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +111 -55
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +196 -51
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +104 -46
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +74 -16
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +65 -7
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +117 -59
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +103 -45
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +139 -81
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +96 -38
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +108 -47
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +70 -12
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +82 -24
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +31 -31
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +2 -2
- package/umd/plugins/context-menu.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/grouping-rows.umd.js +2 -2
- package/umd/plugins/grouping-rows.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/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.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/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/index.js
CHANGED
|
@@ -9,84 +9,92 @@ 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((
|
|
13
|
-
const
|
|
14
|
-
field:
|
|
15
|
-
order:
|
|
12
|
+
columns: t.map((i, s) => {
|
|
13
|
+
const r = {
|
|
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
|
-
},
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
18
|
+
}, a = i;
|
|
19
|
+
a.__renderedWidth !== void 0 ? r.width = a.__renderedWidth : i.width !== void 0 && (r.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
|
|
20
|
+
const l = n.get(i.field);
|
|
21
|
+
l && (r.sort = l);
|
|
22
22
|
for (const f of e)
|
|
23
23
|
if (f.getColumnState) {
|
|
24
|
-
const p = f.getColumnState(
|
|
25
|
-
p && Object.assign(
|
|
24
|
+
const p = f.getColumnState(i.field);
|
|
25
|
+
p && Object.assign(r, p);
|
|
26
26
|
}
|
|
27
|
-
return
|
|
27
|
+
return r;
|
|
28
28
|
})
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function me(o, e, t, n) {
|
|
32
32
|
if (!e.columns || e.columns.length === 0) return;
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
const f = { ...
|
|
37
|
-
return
|
|
33
|
+
const i = new Map(e.columns.map((a) => [a.field, a])), s = t.map((a) => {
|
|
34
|
+
const l = i.get(a.field);
|
|
35
|
+
if (!l) return a;
|
|
36
|
+
const f = { ...a };
|
|
37
|
+
return l.width !== void 0 && (f.width = l.width, f.__renderedWidth = l.width), l.visible !== void 0 && (f.hidden = !l.visible), f;
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
const f =
|
|
39
|
+
s.sort((a, l) => {
|
|
40
|
+
const f = i.get(a.field)?.order ?? 1 / 0, p = i.get(l.field)?.order ?? 1 / 0;
|
|
41
41
|
return f - p;
|
|
42
|
-
}), o._columns =
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
field:
|
|
48
|
-
direction:
|
|
42
|
+
}), o._columns = s;
|
|
43
|
+
const r = e.columns.filter((a) => a.sort !== void 0).sort((a, l) => (a.sort?.priority ?? 0) - (l.sort?.priority ?? 0));
|
|
44
|
+
if (r.length > 0) {
|
|
45
|
+
const a = r[0];
|
|
46
|
+
a.sort && (o.sortState = {
|
|
47
|
+
field: a.field,
|
|
48
|
+
direction: a.sort.direction === "asc" ? 1 : -1
|
|
49
49
|
});
|
|
50
50
|
} else
|
|
51
51
|
o.sortState = null;
|
|
52
|
-
for (const
|
|
53
|
-
if (
|
|
54
|
-
for (const
|
|
55
|
-
|
|
52
|
+
for (const a of n)
|
|
53
|
+
if (a.applyColumnState)
|
|
54
|
+
for (const l of e.columns)
|
|
55
|
+
a.applyColumnState(l.field, l);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function ve(o, e, t) {
|
|
58
58
|
let n = null;
|
|
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
|
+
}, ce = {
|
|
71
|
+
expand: "▶",
|
|
72
|
+
collapse: "▼",
|
|
73
|
+
sortAsc: "▲",
|
|
74
|
+
sortDesc: "▼",
|
|
75
|
+
sortNone: "⇅",
|
|
76
|
+
submenuArrow: "▶",
|
|
77
|
+
dragHandle: "⋮⋮"
|
|
70
78
|
};
|
|
71
|
-
function
|
|
79
|
+
function Ce(o) {
|
|
72
80
|
return o == null ? "string" : typeof o == "number" ? "number" : typeof o == "boolean" ? "boolean" : o instanceof Date || typeof o == "string" && /\d{4}-\d{2}-\d{2}/.test(o) && !isNaN(Date.parse(o)) ? "date" : "string";
|
|
73
81
|
}
|
|
74
|
-
function
|
|
82
|
+
function de(o, e) {
|
|
75
83
|
if (e && e.length) {
|
|
76
|
-
const
|
|
77
|
-
return e.forEach((
|
|
78
|
-
|
|
79
|
-
}), { columns: e, typeMap:
|
|
80
|
-
}
|
|
81
|
-
const t = o[0] || {}, n = Object.keys(t).map((
|
|
82
|
-
const
|
|
83
|
-
return { field:
|
|
84
|
-
}),
|
|
85
|
-
return n.forEach((
|
|
86
|
-
s
|
|
87
|
-
}), { columns: n, typeMap:
|
|
88
|
-
}
|
|
89
|
-
const
|
|
84
|
+
const s = {};
|
|
85
|
+
return e.forEach((r) => {
|
|
86
|
+
r.type && (s[r.field] = r.type);
|
|
87
|
+
}), { columns: e, typeMap: s };
|
|
88
|
+
}
|
|
89
|
+
const t = o[0] || {}, n = Object.keys(t).map((s) => {
|
|
90
|
+
const r = t[s], a = Ce(r);
|
|
91
|
+
return { field: s, header: s.charAt(0).toUpperCase() + s.slice(1), type: a };
|
|
92
|
+
}), i = {};
|
|
93
|
+
return n.forEach((s) => {
|
|
94
|
+
i[s.field] = s.type || "string";
|
|
95
|
+
}), { columns: n, typeMap: i };
|
|
96
|
+
}
|
|
97
|
+
const Ee = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, Re = /__(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/, _e = /* @__PURE__ */ new Set([
|
|
90
98
|
"script",
|
|
91
99
|
"iframe",
|
|
92
100
|
"object",
|
|
@@ -111,76 +119,76 @@ const Ce = /{{\s*([^}]+)\s*}}/g, R = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>
|
|
|
111
119
|
"plaintext",
|
|
112
120
|
"xmp",
|
|
113
121
|
"listing"
|
|
114
|
-
]), U = /^on\w+$/i,
|
|
115
|
-
function
|
|
122
|
+
]), U = /^on\w+$/i, Ae = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), Se = /^\s*(javascript|vbscript|data|blob):/i;
|
|
123
|
+
function z(o) {
|
|
116
124
|
if (!o || typeof o != "string") return "";
|
|
117
125
|
if (o.indexOf("<") === -1) return o;
|
|
118
126
|
const e = document.createElement("template");
|
|
119
|
-
return e.innerHTML = o,
|
|
127
|
+
return e.innerHTML = o, xe(e.content), e.innerHTML;
|
|
120
128
|
}
|
|
121
|
-
function
|
|
129
|
+
function xe(o) {
|
|
122
130
|
const e = [], t = o.querySelectorAll("*");
|
|
123
131
|
for (const n of t) {
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
132
|
+
const i = n.tagName.toLowerCase();
|
|
133
|
+
if (_e.has(i)) {
|
|
126
134
|
e.push(n);
|
|
127
135
|
continue;
|
|
128
136
|
}
|
|
129
|
-
if ((
|
|
130
|
-
(
|
|
137
|
+
if ((i === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
|
|
138
|
+
(a) => U.test(a.name) || a.name === "href" || a.name === "xlink:href"
|
|
131
139
|
)) {
|
|
132
140
|
e.push(n);
|
|
133
141
|
continue;
|
|
134
142
|
}
|
|
135
|
-
const
|
|
136
|
-
for (const
|
|
137
|
-
const
|
|
138
|
-
if (U.test(
|
|
139
|
-
|
|
143
|
+
const s = [];
|
|
144
|
+
for (const r of n.attributes) {
|
|
145
|
+
const a = r.name.toLowerCase();
|
|
146
|
+
if (U.test(a)) {
|
|
147
|
+
s.push(r.name);
|
|
140
148
|
continue;
|
|
141
149
|
}
|
|
142
|
-
if (
|
|
143
|
-
|
|
150
|
+
if (Ae.has(a) && Se.test(r.value)) {
|
|
151
|
+
s.push(r.name);
|
|
144
152
|
continue;
|
|
145
153
|
}
|
|
146
|
-
if (
|
|
147
|
-
|
|
154
|
+
if (a === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
|
|
155
|
+
s.push(r.name);
|
|
148
156
|
continue;
|
|
149
157
|
}
|
|
150
158
|
}
|
|
151
|
-
|
|
159
|
+
s.forEach((r) => n.removeAttribute(r));
|
|
152
160
|
}
|
|
153
161
|
e.forEach((n) => n.remove());
|
|
154
162
|
}
|
|
155
|
-
function
|
|
163
|
+
function he(o, e) {
|
|
156
164
|
if (!o || o.indexOf("{{") === -1) return o;
|
|
157
|
-
const t = [], n = o.replace(
|
|
158
|
-
const f =
|
|
159
|
-
return t.push({ expr:
|
|
160
|
-
}),
|
|
161
|
-
return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) ||
|
|
162
|
-
}
|
|
163
|
-
function
|
|
164
|
-
if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return
|
|
165
|
-
if (o === "value") return e.value == null ?
|
|
165
|
+
const t = [], n = o.replace(Ee, (a, l) => {
|
|
166
|
+
const f = Te(l, e);
|
|
167
|
+
return t.push({ expr: l.trim(), result: f }), f;
|
|
168
|
+
}), i = Le(n), s = t.length && t.every((a) => a.result === "" || a.result === A);
|
|
169
|
+
return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || s ? "" : i;
|
|
170
|
+
}
|
|
171
|
+
function Te(o, e) {
|
|
172
|
+
if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return A;
|
|
173
|
+
if (o === "value") return e.value == null ? A : String(e.value);
|
|
166
174
|
if (o.startsWith("row.") && !/[()?]/.test(o) && !o.includes(":")) {
|
|
167
|
-
const n = o.slice(4),
|
|
168
|
-
return
|
|
175
|
+
const n = o.slice(4), i = e.row ? e.row[n] : void 0;
|
|
176
|
+
return i == null ? A : String(i);
|
|
169
177
|
}
|
|
170
|
-
if (o.length > 80 || !ye.test(o) ||
|
|
178
|
+
if (o.length > 80 || !ye.test(o) || Re.test(o)) return A;
|
|
171
179
|
const t = o.match(/\./g);
|
|
172
|
-
if (t && t.length > 1) return
|
|
180
|
+
if (t && t.length > 1) return A;
|
|
173
181
|
try {
|
|
174
|
-
const
|
|
175
|
-
return /Reflect|Proxy|ownKeys/.test(
|
|
182
|
+
const i = new Function("value", "row", `return (${o});`)(e.value, e.row), s = i == null ? "" : String(i);
|
|
183
|
+
return /Reflect|Proxy|ownKeys/.test(s) ? A : s || A;
|
|
176
184
|
} catch {
|
|
177
|
-
return
|
|
185
|
+
return A;
|
|
178
186
|
}
|
|
179
187
|
}
|
|
180
|
-
function Te(o) {
|
|
181
|
-
return o && o.replace(new RegExp(R, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
182
|
-
}
|
|
183
188
|
function Le(o) {
|
|
189
|
+
return o && o.replace(new RegExp(A, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
190
|
+
}
|
|
191
|
+
function ke(o) {
|
|
184
192
|
if (/Reflect|Proxy|ownKeys/.test(o.textContent || "")) {
|
|
185
193
|
if (Array.from(o.childNodes).forEach((e) => {
|
|
186
194
|
e.nodeType === Node.TEXT_NODE && /Reflect|Proxy|ownKeys/.test(e.textContent || "") && (e.textContent = "");
|
|
@@ -193,37 +201,37 @@ function Le(o) {
|
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
203
|
function X(o) {
|
|
196
|
-
const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(o), t = (n) => e ? "" :
|
|
204
|
+
const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(o), t = (n) => e ? "" : he(o, n);
|
|
197
205
|
return t.__blocked = e, t;
|
|
198
206
|
}
|
|
199
|
-
function
|
|
207
|
+
function Pe(o) {
|
|
200
208
|
return Array.from(o.querySelectorAll("tbw-grid-column")).map((t) => {
|
|
201
209
|
const n = t.getAttribute("field") || "";
|
|
202
210
|
if (!n) return null;
|
|
203
|
-
const
|
|
211
|
+
const i = t.getAttribute("type") || void 0, r = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, a = t.getAttribute("header") || void 0, l = t.hasAttribute("sortable"), f = t.hasAttribute("editable"), p = { field: n, type: r, header: a, sortable: l, editable: f };
|
|
204
212
|
t.hasAttribute("resizable") && (p.resizable = !0), t.hasAttribute("sizable") && (p.resizable = !0);
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
const [b,
|
|
208
|
-
return { value: b.trim(), label:
|
|
213
|
+
const g = t.getAttribute("options");
|
|
214
|
+
g && (p.options = g.split(",").map((d) => {
|
|
215
|
+
const [b, m] = d.includes(":") ? d.split(":") : [d.trim(), d.trim()];
|
|
216
|
+
return { value: b.trim(), label: m?.trim() || b.trim() };
|
|
209
217
|
}));
|
|
210
|
-
const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"),
|
|
211
|
-
return h && (p.__viewTemplate = h), c && (p.__editorTemplate = c),
|
|
218
|
+
const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), u = t.querySelector("tbw-grid-column-header");
|
|
219
|
+
return h && (p.__viewTemplate = h), c && (p.__editorTemplate = c), u && (p.__headerTemplate = u), p;
|
|
212
220
|
}).filter((t) => !!t);
|
|
213
221
|
}
|
|
214
|
-
function
|
|
222
|
+
function Me(o, e) {
|
|
215
223
|
if ((!o || !o.length) && (!e || !e.length)) return [];
|
|
216
224
|
if (!o || !o.length) return e || [];
|
|
217
225
|
if (!e || !e.length) return o;
|
|
218
226
|
const t = {};
|
|
219
|
-
e.forEach((
|
|
220
|
-
const n = o.map((
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
223
|
-
const
|
|
224
|
-
return
|
|
227
|
+
e.forEach((i) => t[i.field] = i);
|
|
228
|
+
const n = o.map((i) => {
|
|
229
|
+
const s = t[i.field];
|
|
230
|
+
if (!s) return i;
|
|
231
|
+
const r = { ...i };
|
|
232
|
+
return s.header && !r.header && (r.header = s.header), s.type && !r.type && (r.type = s.type), r.sortable = i.sortable || s.sortable, (i.resizable === !0 || s.resizable === !0) && (r.resizable = !0), r.editable = i.editable || s.editable, s.__viewTemplate && (r.__viewTemplate = s.__viewTemplate), s.__editorTemplate && (r.__editorTemplate = s.__editorTemplate), s.__headerTemplate && (r.__headerTemplate = s.__headerTemplate), delete t[i.field], r;
|
|
225
233
|
});
|
|
226
|
-
return Object.keys(t).forEach((
|
|
234
|
+
return Object.keys(t).forEach((i) => n.push(t[i])), n;
|
|
227
235
|
}
|
|
228
236
|
function B(o, e) {
|
|
229
237
|
try {
|
|
@@ -233,39 +241,39 @@ function B(o, e) {
|
|
|
233
241
|
const t = o.getAttribute("part");
|
|
234
242
|
t ? t.split(/\s+/).includes(e) || o.setAttribute("part", t + " " + e) : o.setAttribute("part", e);
|
|
235
243
|
}
|
|
236
|
-
function
|
|
244
|
+
function He(o) {
|
|
237
245
|
o.__lightDomColumnsCache || (o.__originalColumnNodes = Array.from(
|
|
238
246
|
o.querySelectorAll("tbw-grid-column")
|
|
239
|
-
), o.__lightDomColumnsCache = o.__originalColumnNodes.length ?
|
|
240
|
-
const e = o.__lightDomColumnsCache, t =
|
|
241
|
-
t.forEach((
|
|
242
|
-
|
|
247
|
+
), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? Pe(o) : []);
|
|
248
|
+
const e = o.__lightDomColumnsCache, t = Me(o._columns, e);
|
|
249
|
+
t.forEach((i) => {
|
|
250
|
+
i.__viewTemplate && !i.__compiledView && (i.__compiledView = X(i.__viewTemplate.innerHTML)), i.__editorTemplate && !i.__compiledEditor && (i.__compiledEditor = X(i.__editorTemplate.innerHTML));
|
|
243
251
|
});
|
|
244
|
-
const { columns: n } =
|
|
252
|
+
const { columns: n } = de(o._rows, t);
|
|
245
253
|
o._columns = n;
|
|
246
254
|
}
|
|
247
|
-
function
|
|
248
|
-
const e = o.effectiveConfig?.fitMode || o.fitMode ||
|
|
249
|
-
if (e !==
|
|
255
|
+
function Oe(o) {
|
|
256
|
+
const e = o.effectiveConfig?.fitMode || o.fitMode || M.STRETCH;
|
|
257
|
+
if (e !== M.STRETCH && e !== M.FIXED || o.__didInitialAutoSize || !o.isConnected) return;
|
|
250
258
|
const t = o.headerRowEl?.children || [];
|
|
251
259
|
if (!t.length) return;
|
|
252
260
|
let n = !1;
|
|
253
|
-
o.visibleColumns.forEach((
|
|
254
|
-
if (
|
|
255
|
-
const
|
|
256
|
-
let
|
|
257
|
-
for (const
|
|
258
|
-
const f =
|
|
261
|
+
o.visibleColumns.forEach((i, s) => {
|
|
262
|
+
if (i.width) return;
|
|
263
|
+
const r = t[s];
|
|
264
|
+
let a = r ? r.scrollWidth : 0;
|
|
265
|
+
for (const l of o.rowPool) {
|
|
266
|
+
const f = l.children[s];
|
|
259
267
|
if (f) {
|
|
260
268
|
const p = f.scrollWidth;
|
|
261
|
-
p >
|
|
269
|
+
p > a && (a = p);
|
|
262
270
|
}
|
|
263
271
|
}
|
|
264
|
-
|
|
265
|
-
}), n &&
|
|
272
|
+
a > 0 && (i.width = a + 2, i.__autoSized = !0, n = !0);
|
|
273
|
+
}), n && ue(o), o.__didInitialAutoSize = !0;
|
|
266
274
|
}
|
|
267
|
-
function
|
|
268
|
-
(o.effectiveConfig?.fitMode || o.fitMode ||
|
|
275
|
+
function ue(o) {
|
|
276
|
+
(o.effectiveConfig?.fitMode || o.fitMode || M.STRETCH) === M.STRETCH ? o.gridTemplate = o.visibleColumns.map((t) => {
|
|
269
277
|
if (t.width) return `${t.width}px`;
|
|
270
278
|
const n = t.minWidth;
|
|
271
279
|
return n != null ? `minmax(${n}px, 1fr)` : "1fr";
|
|
@@ -296,21 +304,21 @@ function De(o) {
|
|
|
296
304
|
case "typeahead":
|
|
297
305
|
return (e) => {
|
|
298
306
|
const t = document.createElement("select");
|
|
299
|
-
e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((
|
|
300
|
-
const
|
|
301
|
-
|
|
307
|
+
e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((s) => {
|
|
308
|
+
const r = document.createElement("option");
|
|
309
|
+
r.value = String(s.value), r.textContent = s.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(s.value) || !e.column.multi && e.value === s.value) && (r.selected = !0), t.appendChild(r);
|
|
302
310
|
});
|
|
303
|
-
const
|
|
311
|
+
const i = () => {
|
|
304
312
|
if (e.column.multi) {
|
|
305
|
-
const
|
|
306
|
-
Array.from(t.selectedOptions).forEach((
|
|
307
|
-
|
|
308
|
-
}), e.commit(
|
|
313
|
+
const s = [];
|
|
314
|
+
Array.from(t.selectedOptions).forEach((r) => {
|
|
315
|
+
s.push(r.value);
|
|
316
|
+
}), e.commit(s);
|
|
309
317
|
} else
|
|
310
318
|
e.commit(t.value);
|
|
311
319
|
};
|
|
312
|
-
return t.addEventListener("change",
|
|
313
|
-
|
|
320
|
+
return t.addEventListener("change", i), t.addEventListener("blur", i), t.addEventListener("keydown", (s) => {
|
|
321
|
+
s.key === "Escape" && e.cancel();
|
|
314
322
|
}), t.focus(), t;
|
|
315
323
|
};
|
|
316
324
|
default:
|
|
@@ -322,25 +330,25 @@ function De(o) {
|
|
|
322
330
|
};
|
|
323
331
|
}
|
|
324
332
|
}
|
|
325
|
-
function
|
|
333
|
+
function ze(o, e) {
|
|
326
334
|
if (o.dispatchKeyDown?.(e))
|
|
327
335
|
return;
|
|
328
|
-
const t = o._rows.length - 1, n = o.visibleColumns.length - 1,
|
|
336
|
+
const t = o._rows.length - 1, n = o.visibleColumns.length - 1, i = o.activeEditRows !== void 0 && o.activeEditRows !== -1, r = o.visibleColumns[o.focusCol]?.type, a = e.composedPath ? e.composedPath() : [], l = a && a.length ? a[0] : e.target, f = (p) => {
|
|
329
337
|
if (!p) return !1;
|
|
330
|
-
const
|
|
331
|
-
return !!(
|
|
338
|
+
const g = p.tagName;
|
|
339
|
+
return !!(g === "INPUT" || g === "SELECT" || g === "TEXTAREA" || p.isContentEditable);
|
|
332
340
|
};
|
|
333
|
-
if (!(f(
|
|
341
|
+
if (!(f(l) && (e.key === "Home" || e.key === "End")) && !(f(l) && (e.key === "ArrowUp" || e.key === "ArrowDown") && l.tagName === "INPUT" && l.type === "number") && !(i && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
|
|
334
342
|
switch (e.key) {
|
|
335
343
|
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),
|
|
344
|
+
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), H(o);
|
|
337
345
|
return;
|
|
338
346
|
}
|
|
339
347
|
case "ArrowDown":
|
|
340
|
-
|
|
348
|
+
i && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.min(t, o.focusRow + 1), e.preventDefault();
|
|
341
349
|
break;
|
|
342
350
|
case "ArrowUp":
|
|
343
|
-
|
|
351
|
+
i && typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow = Math.max(0, o.focusRow - 1), e.preventDefault();
|
|
344
352
|
break;
|
|
345
353
|
case "ArrowRight":
|
|
346
354
|
o.focusCol = Math.min(n, o.focusCol + 1), e.preventDefault();
|
|
@@ -363,167 +371,173 @@ function He(o, e) {
|
|
|
363
371
|
case "Enter":
|
|
364
372
|
return typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(o.focusRow) : o.dispatchEvent(
|
|
365
373
|
new CustomEvent("activate-cell", { detail: { row: o.focusRow, col: o.focusCol } })
|
|
366
|
-
),
|
|
374
|
+
), H(o);
|
|
367
375
|
default:
|
|
368
376
|
return;
|
|
369
377
|
}
|
|
370
|
-
|
|
378
|
+
H(o);
|
|
371
379
|
}
|
|
372
380
|
}
|
|
373
|
-
function
|
|
381
|
+
function H(o) {
|
|
374
382
|
if (o.virtualization?.enabled) {
|
|
375
|
-
const { rowHeight:
|
|
376
|
-
|
|
383
|
+
const { rowHeight: i } = o.virtualization, s = o, r = o.focusRow * i;
|
|
384
|
+
r < s.scrollTop ? s.scrollTop = r : r + i > s.scrollTop + s.clientHeight && (s.scrollTop = r - s.clientHeight + i);
|
|
377
385
|
}
|
|
378
|
-
o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((
|
|
379
|
-
|
|
386
|
+
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) => {
|
|
387
|
+
i.setAttribute("aria-selected", "false");
|
|
380
388
|
});
|
|
381
389
|
const e = o.focusRow, t = o.virtualization.start ?? 0, n = o.virtualization.end ?? o._rows.length;
|
|
382
390
|
if (e >= t && e < n) {
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
if (
|
|
386
|
-
const
|
|
391
|
+
const s = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
|
|
392
|
+
if (s) {
|
|
393
|
+
if (s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && s.classList.contains("editing")) {
|
|
394
|
+
const r = s.querySelector(
|
|
387
395
|
'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
|
|
388
396
|
);
|
|
389
|
-
if (
|
|
397
|
+
if (r && document.activeElement !== r)
|
|
390
398
|
try {
|
|
391
|
-
|
|
399
|
+
r.focus();
|
|
392
400
|
} catch {
|
|
393
401
|
}
|
|
394
|
-
} else if (!
|
|
395
|
-
|
|
402
|
+
} else if (!s.contains(document.activeElement)) {
|
|
403
|
+
s.hasAttribute("tabindex") || s.setAttribute("tabindex", "-1");
|
|
396
404
|
try {
|
|
397
|
-
|
|
405
|
+
s.focus({ preventScroll: !0 });
|
|
398
406
|
} catch {
|
|
399
407
|
}
|
|
400
408
|
}
|
|
401
409
|
}
|
|
402
410
|
}
|
|
403
411
|
}
|
|
404
|
-
const
|
|
412
|
+
const Ne = "__cellDisplayCache", Ie = "__cellCacheEpoch";
|
|
405
413
|
function j(o) {
|
|
406
|
-
o[
|
|
414
|
+
o[Ne] = void 0, o[Ie] = void 0, o.__hasSpecialColumns = void 0;
|
|
407
415
|
}
|
|
408
|
-
function qe(o, e, t, n,
|
|
409
|
-
const
|
|
416
|
+
function qe(o, e, t, n, i) {
|
|
417
|
+
const s = Math.max(0, t - e), r = o.bodyEl, a = o.visibleColumns, l = a.length;
|
|
410
418
|
let f = o.__cachedHeaderRowCount;
|
|
411
|
-
for (f === void 0 && (f = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = f); o.rowPool.length <
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
if (o.rowPool.length >
|
|
416
|
-
for (let
|
|
417
|
-
const h = o.rowPool[
|
|
418
|
-
h.parentNode ===
|
|
419
|
-
}
|
|
420
|
-
o.rowPool.length =
|
|
421
|
-
}
|
|
422
|
-
const p =
|
|
423
|
-
for (let
|
|
424
|
-
const h = e +
|
|
425
|
-
if (
|
|
426
|
-
|
|
419
|
+
for (f === void 0 && (f = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = f); o.rowPool.length < s; ) {
|
|
420
|
+
const g = document.createElement("div");
|
|
421
|
+
g.className = "data-grid-row", g.setAttribute("role", "row"), g.addEventListener("click", (h) => Z(o, h, g, !1)), g.addEventListener("dblclick", (h) => Z(o, h, g, !0)), o.rowPool.push(g);
|
|
422
|
+
}
|
|
423
|
+
if (o.rowPool.length > s) {
|
|
424
|
+
for (let g = s; g < o.rowPool.length; g++) {
|
|
425
|
+
const h = o.rowPool[g];
|
|
426
|
+
h.parentNode === r && h.remove();
|
|
427
|
+
}
|
|
428
|
+
o.rowPool.length = s;
|
|
429
|
+
}
|
|
430
|
+
const p = i && o.__hasRenderRowPlugins !== !1;
|
|
431
|
+
for (let g = 0; g < s; g++) {
|
|
432
|
+
const h = e + g, c = o._rows[h], u = o.rowPool[g];
|
|
433
|
+
if (u.setAttribute("aria-rowindex", String(h + f + 1)), p && i(c, u, h)) {
|
|
434
|
+
u.__epoch = n, u.__rowDataRef = c, u.parentNode !== r && r.appendChild(u);
|
|
427
435
|
continue;
|
|
428
436
|
}
|
|
429
|
-
const
|
|
430
|
-
let
|
|
431
|
-
if (
|
|
432
|
-
for (let
|
|
433
|
-
if (
|
|
434
|
-
|
|
437
|
+
const d = u.__epoch, b = u.__rowDataRef, m = u.children.length, R = d === n && m === l, E = b !== c;
|
|
438
|
+
let _ = !1;
|
|
439
|
+
if (R && E) {
|
|
440
|
+
for (let S = 0; S < l; S++)
|
|
441
|
+
if (a[S].externalView && !u.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
|
|
442
|
+
_ = !0;
|
|
435
443
|
break;
|
|
436
444
|
}
|
|
437
445
|
}
|
|
438
|
-
!
|
|
439
|
-
const
|
|
440
|
-
|
|
446
|
+
!R || _ ? (u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1), F(o, u, c, h), u.__epoch = n, u.__rowDataRef = c) : E ? (Y(o, u, c, h), u.__rowDataRef = c) : Y(o, u, c, h);
|
|
447
|
+
const w = o._changedRowIndices.has(h), v = u.classList.contains("changed");
|
|
448
|
+
w !== v && u.classList.toggle("changed", w), u.parentNode !== r && r.appendChild(u);
|
|
441
449
|
}
|
|
442
450
|
}
|
|
443
451
|
function Y(o, e, t, n) {
|
|
444
|
-
const
|
|
445
|
-
let
|
|
446
|
-
if (
|
|
447
|
-
|
|
448
|
-
for (let c = 0; c <
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
|
|
452
|
+
const i = e.children, s = o.visibleColumns, r = s.length, a = i.length, l = r < a ? r : a, f = o.focusRow, p = o.focusCol;
|
|
453
|
+
let g = o.__hasSpecialColumns;
|
|
454
|
+
if (g === void 0) {
|
|
455
|
+
g = !1;
|
|
456
|
+
for (let c = 0; c < r; c++) {
|
|
457
|
+
const u = s[c];
|
|
458
|
+
if (u.__viewTemplate || u.__compiledView || u.viewRenderer || u.externalView || u.format || u.type === "date" || u.type === "boolean") {
|
|
459
|
+
g = !0;
|
|
452
460
|
break;
|
|
453
461
|
}
|
|
454
462
|
}
|
|
455
|
-
o.__hasSpecialColumns =
|
|
463
|
+
o.__hasSpecialColumns = g;
|
|
456
464
|
}
|
|
457
465
|
const h = String(n);
|
|
458
|
-
if (!
|
|
459
|
-
for (let c = 0; c <
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
const b = f === n && p === c,
|
|
463
|
-
b !==
|
|
466
|
+
if (!g) {
|
|
467
|
+
for (let c = 0; c < l; c++) {
|
|
468
|
+
const u = i[c], d = t[s[c].field];
|
|
469
|
+
u.textContent = d == null ? "" : String(d), u.getAttribute("data-row") !== h && u.setAttribute("data-row", h);
|
|
470
|
+
const b = f === n && p === c, m = u.classList.contains("cell-focus");
|
|
471
|
+
b !== m && (u.classList.toggle("cell-focus", b), u.setAttribute("aria-selected", String(b)));
|
|
464
472
|
}
|
|
465
473
|
return;
|
|
466
474
|
}
|
|
467
|
-
for (let c = 0; c <
|
|
468
|
-
if (
|
|
475
|
+
for (let c = 0; c < l; c++)
|
|
476
|
+
if (s[c].externalView && !i[c].querySelector("[data-external-view]")) {
|
|
469
477
|
F(o, e, t, n);
|
|
470
478
|
return;
|
|
471
479
|
}
|
|
472
|
-
for (let c = 0; c <
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
const b = f === n && p === c,
|
|
476
|
-
if (b !==
|
|
480
|
+
for (let c = 0; c < l; c++) {
|
|
481
|
+
const u = s[c], d = i[c];
|
|
482
|
+
d.getAttribute("data-row") !== h && d.setAttribute("data-row", h);
|
|
483
|
+
const b = f === n && p === c, m = d.classList.contains("cell-focus");
|
|
484
|
+
if (b !== m && (d.classList.toggle("cell-focus", b), d.setAttribute("aria-selected", String(b))), d.classList.contains("editing")) continue;
|
|
485
|
+
if (u.viewRenderer) {
|
|
486
|
+
const E = t[u.field], _ = u.viewRenderer({ row: t, value: E, field: u.field, column: u });
|
|
487
|
+
typeof _ == "string" ? d.innerHTML = z(_) : _ ? (d.innerHTML = "", d.appendChild(_)) : d.textContent = E == null ? "" : String(E);
|
|
477
488
|
continue;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
489
|
+
}
|
|
490
|
+
if (u.__viewTemplate || u.__compiledView || u.externalView)
|
|
491
|
+
continue;
|
|
492
|
+
const C = t[u.field];
|
|
493
|
+
let R;
|
|
494
|
+
if (u.format)
|
|
481
495
|
try {
|
|
482
|
-
const
|
|
483
|
-
|
|
496
|
+
const E = u.format(C, t);
|
|
497
|
+
R = E == null ? "" : String(E);
|
|
484
498
|
} catch {
|
|
485
|
-
|
|
499
|
+
R = C == null ? "" : String(C);
|
|
486
500
|
}
|
|
487
|
-
else if (
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
else if (
|
|
491
|
-
|
|
501
|
+
else if (u.type === "date")
|
|
502
|
+
if (C == null || C === "")
|
|
503
|
+
R = "";
|
|
504
|
+
else if (C instanceof Date)
|
|
505
|
+
R = isNaN(C.getTime()) ? "" : C.toLocaleDateString();
|
|
492
506
|
else {
|
|
493
|
-
const
|
|
494
|
-
|
|
507
|
+
const E = new Date(C);
|
|
508
|
+
R = isNaN(E.getTime()) ? "" : E.toLocaleDateString();
|
|
495
509
|
}
|
|
496
|
-
else
|
|
497
|
-
|
|
510
|
+
else u.type === "boolean" ? (R = C ? "🗹" : "☐", d.setAttribute("aria-checked", String(!!C))) : R = C == null ? "" : String(C);
|
|
511
|
+
d.textContent = R;
|
|
498
512
|
}
|
|
499
513
|
}
|
|
500
514
|
function F(o, e, t, n) {
|
|
501
515
|
e.innerHTML = "";
|
|
502
|
-
const
|
|
503
|
-
for (let
|
|
504
|
-
const h =
|
|
505
|
-
c.className = "cell", B(c, "cell"), h.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
let
|
|
516
|
+
const i = o.visibleColumns, s = i.length, r = o.focusRow, a = o.focusCol, l = o.effectiveConfig?.editOn || o.editOn, f = o, p = document.createDocumentFragment();
|
|
517
|
+
for (let g = 0; g < s; g++) {
|
|
518
|
+
const h = i[g], c = document.createElement("div");
|
|
519
|
+
c.className = "cell", B(c, "cell"), h.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(g)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(g + 1)), h.type && c.setAttribute("data-type", h.type);
|
|
520
|
+
const u = h.sticky;
|
|
521
|
+
u === "left" ? c.classList.add("sticky-left") : u === "right" && c.classList.add("sticky-right");
|
|
522
|
+
let d = t[h.field];
|
|
509
523
|
const b = h.format;
|
|
510
524
|
if (b)
|
|
511
525
|
try {
|
|
512
|
-
|
|
526
|
+
d = b(d, t);
|
|
513
527
|
} catch {
|
|
514
528
|
}
|
|
515
|
-
const
|
|
516
|
-
let
|
|
517
|
-
if (
|
|
518
|
-
const
|
|
519
|
-
typeof
|
|
520
|
-
} else if (
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
529
|
+
const m = h.__compiledView, C = h.__viewTemplate, R = h.viewRenderer, E = h.externalView;
|
|
530
|
+
let _ = !1;
|
|
531
|
+
if (R) {
|
|
532
|
+
const w = R({ row: t, value: d, field: h.field, column: h });
|
|
533
|
+
typeof w == "string" ? (c.innerHTML = z(w), _ = !0) : w ? c.appendChild(w) : c.textContent = d == null ? "" : String(d);
|
|
534
|
+
} else if (E) {
|
|
535
|
+
const w = E, v = document.createElement("div");
|
|
536
|
+
v.setAttribute("data-external-view", ""), v.setAttribute("data-field", h.field), c.appendChild(v);
|
|
537
|
+
const S = { row: t, value: d, field: h.field, column: h };
|
|
538
|
+
if (w.mount)
|
|
525
539
|
try {
|
|
526
|
-
|
|
540
|
+
w.mount({ placeholder: v, context: S, spec: w });
|
|
527
541
|
} catch {
|
|
528
542
|
}
|
|
529
543
|
else
|
|
@@ -533,106 +547,106 @@ function F(o, e, t, n) {
|
|
|
533
547
|
new CustomEvent("mount-external-view", {
|
|
534
548
|
bubbles: !0,
|
|
535
549
|
composed: !0,
|
|
536
|
-
detail: { placeholder:
|
|
550
|
+
detail: { placeholder: v, spec: w, context: S }
|
|
537
551
|
})
|
|
538
552
|
);
|
|
539
553
|
} catch {
|
|
540
554
|
}
|
|
541
555
|
});
|
|
542
|
-
|
|
543
|
-
} else if (
|
|
544
|
-
const
|
|
545
|
-
c.innerHTML =
|
|
546
|
-
} else if (
|
|
547
|
-
const
|
|
548
|
-
/Reflect\.|\bProxy\b|ownKeys\(/.test(
|
|
556
|
+
v.setAttribute("data-mounted", "");
|
|
557
|
+
} else if (m) {
|
|
558
|
+
const w = m({ row: t, value: d, field: h.field, column: h }), v = m.__blocked;
|
|
559
|
+
c.innerHTML = v ? "" : z(w), _ = !0, v && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
|
|
560
|
+
} else if (C) {
|
|
561
|
+
const w = C.innerHTML;
|
|
562
|
+
/Reflect\.|\bProxy\b|ownKeys\(/.test(w) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = z(he(w, { row: t, value: d })), _ = !0);
|
|
549
563
|
} else if (h.type === "date")
|
|
550
|
-
if (
|
|
564
|
+
if (d == null || d === "")
|
|
551
565
|
c.textContent = "";
|
|
552
566
|
else {
|
|
553
|
-
let
|
|
554
|
-
if (
|
|
555
|
-
else if (typeof
|
|
556
|
-
const
|
|
557
|
-
isNaN(
|
|
567
|
+
let w = null;
|
|
568
|
+
if (d instanceof Date) w = d;
|
|
569
|
+
else if (typeof d == "number" || typeof d == "string") {
|
|
570
|
+
const v = new Date(d);
|
|
571
|
+
isNaN(v.getTime()) || (w = v);
|
|
558
572
|
}
|
|
559
|
-
c.textContent =
|
|
573
|
+
c.textContent = w ? w.toLocaleDateString() : "";
|
|
560
574
|
}
|
|
561
575
|
else if (h.type === "boolean") {
|
|
562
|
-
const
|
|
563
|
-
c.innerHTML =
|
|
576
|
+
const w = !!d;
|
|
577
|
+
c.innerHTML = w ? "🗹" : "☐", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(w)), c.setAttribute("aria-label", String(w));
|
|
564
578
|
} else
|
|
565
|
-
c.textContent =
|
|
566
|
-
if (
|
|
567
|
-
|
|
568
|
-
const
|
|
569
|
-
/Proxy|Reflect\.ownKeys/.test(
|
|
579
|
+
c.textContent = d == null ? "" : String(d);
|
|
580
|
+
if (_) {
|
|
581
|
+
ke(c);
|
|
582
|
+
const w = c.textContent || "";
|
|
583
|
+
/Proxy|Reflect\.ownKeys/.test(w) && (c.textContent = w.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
|
|
570
584
|
}
|
|
571
585
|
c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), h.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
|
|
572
|
-
o.focusRow = n, o.focusCol =
|
|
573
|
-
}),
|
|
574
|
-
c.classList.contains("editing") || (
|
|
575
|
-
}) : c.addEventListener("dblclick", (
|
|
576
|
-
|
|
577
|
-
const
|
|
578
|
-
if (
|
|
579
|
-
const
|
|
580
|
-
for (let k = 0; k <
|
|
581
|
-
const
|
|
582
|
-
|
|
586
|
+
o.focusRow = n, o.focusCol = g, H(o);
|
|
587
|
+
}), l === "click" ? c.addEventListener("click", (w) => {
|
|
588
|
+
c.classList.contains("editing") || (w.stopPropagation(), o.focusRow = n, o.focusCol = g, L(o, t, n, h, c));
|
|
589
|
+
}) : c.addEventListener("dblclick", (w) => {
|
|
590
|
+
w.stopPropagation(), T(o, n, t);
|
|
591
|
+
const v = o.findRenderedRowElement?.(n);
|
|
592
|
+
if (v) {
|
|
593
|
+
const S = v.children;
|
|
594
|
+
for (let k = 0; k < S.length; k++) {
|
|
595
|
+
const O = o.visibleColumns[k];
|
|
596
|
+
O && O.editable && L(o, t, n, O, S[k]);
|
|
583
597
|
}
|
|
584
598
|
}
|
|
585
|
-
}), c.addEventListener("keydown", (
|
|
586
|
-
if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") &&
|
|
587
|
-
|
|
588
|
-
const
|
|
599
|
+
}), c.addEventListener("keydown", (w) => {
|
|
600
|
+
if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") && w.key === "Enter") {
|
|
601
|
+
w.preventDefault(), o.activeEditRows !== n && T(o, n, t), L(o, t, n, h, c), setTimeout(() => {
|
|
602
|
+
const v = c.querySelector("select");
|
|
589
603
|
try {
|
|
590
|
-
|
|
604
|
+
v?.showPicker?.();
|
|
591
605
|
} catch {
|
|
592
606
|
}
|
|
593
|
-
|
|
607
|
+
v?.focus();
|
|
594
608
|
}, 0);
|
|
595
609
|
return;
|
|
596
610
|
}
|
|
597
|
-
if (h.type === "boolean" &&
|
|
598
|
-
|
|
599
|
-
const
|
|
600
|
-
$(o, n, h,
|
|
611
|
+
if (h.type === "boolean" && w.key === " " && !c.classList.contains("editing")) {
|
|
612
|
+
w.preventDefault(), o.activeEditRows !== n && T(o, n, t);
|
|
613
|
+
const v = !t[h.field];
|
|
614
|
+
$(o, n, h, v, t), c.innerHTML = v ? "🗹" : "☐", c.setAttribute("aria-label", String(!!v));
|
|
601
615
|
return;
|
|
602
616
|
}
|
|
603
|
-
if (
|
|
604
|
-
|
|
617
|
+
if (w.key === "Enter" && !c.classList.contains("editing")) {
|
|
618
|
+
w.preventDefault(), o.focusRow = n, o.focusCol = g, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : L(o, t, n, h, c);
|
|
605
619
|
return;
|
|
606
620
|
}
|
|
607
|
-
if (
|
|
608
|
-
|
|
621
|
+
if (w.key === "F2" && !c.classList.contains("editing")) {
|
|
622
|
+
w.preventDefault(), L(o, t, n, h, c);
|
|
609
623
|
return;
|
|
610
624
|
}
|
|
611
|
-
})) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (
|
|
612
|
-
if (
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
o.activeEditRows !== n && T(o, n, t), $(o, n, h,
|
|
625
|
+
})) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (w) => {
|
|
626
|
+
if (w.key === " ") {
|
|
627
|
+
w.preventDefault();
|
|
628
|
+
const v = !t[h.field];
|
|
629
|
+
o.activeEditRows !== n && T(o, n, t), $(o, n, h, v, t), c.innerHTML = v ? "🗹" : "☐", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!v)), c.setAttribute("aria-label", String(!!v));
|
|
616
630
|
}
|
|
617
|
-
})),
|
|
631
|
+
})), r === n && a === g ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), p.appendChild(c);
|
|
618
632
|
}
|
|
619
633
|
e.appendChild(p);
|
|
620
634
|
}
|
|
621
635
|
function Z(o, e, t, n) {
|
|
622
636
|
if (e.target?.closest(".resize-handle")) return;
|
|
623
|
-
const
|
|
624
|
-
if (!
|
|
625
|
-
const
|
|
626
|
-
if (isNaN(
|
|
627
|
-
const
|
|
628
|
-
if (!
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
631
|
-
const f = Number(
|
|
637
|
+
const i = t.querySelector(".cell[data-row]");
|
|
638
|
+
if (!i) return;
|
|
639
|
+
const s = Number(i.getAttribute("data-row"));
|
|
640
|
+
if (isNaN(s)) return;
|
|
641
|
+
const r = o._rows[s];
|
|
642
|
+
if (!r) return;
|
|
643
|
+
const a = e.target?.closest(".cell[data-col]");
|
|
644
|
+
if (a) {
|
|
645
|
+
const f = Number(a.getAttribute("data-col"));
|
|
632
646
|
if (!isNaN(f)) {
|
|
633
|
-
if (o.dispatchCellClick?.(e,
|
|
647
|
+
if (o.dispatchCellClick?.(e, s, f, a))
|
|
634
648
|
return;
|
|
635
|
-
o.focusRow =
|
|
649
|
+
o.focusRow = s, o.focusCol = f, H(o);
|
|
636
650
|
}
|
|
637
651
|
}
|
|
638
652
|
if (t.querySelector(".cell.editing")) {
|
|
@@ -640,13 +654,13 @@ function Z(o, e, t, n) {
|
|
|
640
654
|
if (!n) return;
|
|
641
655
|
f.forEach((p) => p.classList.remove("editing"));
|
|
642
656
|
}
|
|
643
|
-
const
|
|
644
|
-
if (
|
|
657
|
+
const l = o.effectiveConfig?.editOn || o.editOn || "doubleClick";
|
|
658
|
+
if (l === "click" || l === "doubleClick" && n) T(o, s, r);
|
|
645
659
|
else return;
|
|
646
660
|
Array.from(t.children).forEach((f, p) => {
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
}),
|
|
661
|
+
const g = o.visibleColumns[p];
|
|
662
|
+
g && g.editable && L(o, r, s, g, f);
|
|
663
|
+
}), a && queueMicrotask(() => {
|
|
650
664
|
const f = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
|
|
651
665
|
if (f?.classList.contains("editing")) {
|
|
652
666
|
const p = f.querySelector(
|
|
@@ -662,19 +676,19 @@ function Z(o, e, t, n) {
|
|
|
662
676
|
function T(o, e, t) {
|
|
663
677
|
o.activeEditRows !== e && (o.rowEditSnapshots.set(e, { ...t }), o.activeEditRows = e);
|
|
664
678
|
}
|
|
665
|
-
function
|
|
679
|
+
function Be(o, e, t) {
|
|
666
680
|
if (o.activeEditRows !== e) return;
|
|
667
|
-
const n = o.rowEditSnapshots.get(e),
|
|
668
|
-
if (t && n &&
|
|
669
|
-
Object.keys(n).forEach((
|
|
681
|
+
const n = o.rowEditSnapshots.get(e), i = o._rows[e];
|
|
682
|
+
if (t && n && i)
|
|
683
|
+
Object.keys(n).forEach((r) => i[r] = n[r]), o._changedRowIndices.delete(e);
|
|
670
684
|
else if (!t) {
|
|
671
|
-
const
|
|
685
|
+
const r = o._changedRowIndices.has(e);
|
|
672
686
|
o.dispatchEvent(
|
|
673
687
|
new CustomEvent("row-commit", {
|
|
674
688
|
detail: {
|
|
675
689
|
rowIndex: e,
|
|
676
|
-
row:
|
|
677
|
-
changed:
|
|
690
|
+
row: i,
|
|
691
|
+
changed: r,
|
|
678
692
|
changedRows: o.changedRows,
|
|
679
693
|
changedRowIndices: o.changedRowIndices
|
|
680
694
|
}
|
|
@@ -682,92 +696,92 @@ function Ie(o, e, t) {
|
|
|
682
696
|
);
|
|
683
697
|
}
|
|
684
698
|
o.rowEditSnapshots.delete(e), o.activeEditRows = -1;
|
|
685
|
-
const
|
|
686
|
-
|
|
699
|
+
const s = o.findRenderedRowElement?.(e);
|
|
700
|
+
s && (F(o, s, o._rows[e], e), o._changedRowIndices.has(e) ? s.classList.add("changed") : s.classList.remove("changed")), t && queueMicrotask(() => {
|
|
687
701
|
try {
|
|
688
702
|
o.focus();
|
|
689
|
-
const
|
|
690
|
-
if (
|
|
703
|
+
const r = o.focusRow, a = o.focusCol, l = o.findRenderedRowElement?.(r);
|
|
704
|
+
if (l) {
|
|
691
705
|
Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach(
|
|
692
706
|
(p) => p.classList.remove("cell-focus")
|
|
693
707
|
);
|
|
694
|
-
const f =
|
|
708
|
+
const f = l.querySelector(`.cell[data-row="${r}"][data-col="${a}"]`);
|
|
695
709
|
f && f.classList.add("cell-focus");
|
|
696
710
|
}
|
|
697
711
|
} catch {
|
|
698
712
|
}
|
|
699
713
|
});
|
|
700
714
|
}
|
|
701
|
-
function $(o, e, t, n,
|
|
702
|
-
const
|
|
703
|
-
if (s
|
|
704
|
-
s
|
|
705
|
-
const
|
|
715
|
+
function $(o, e, t, n, i) {
|
|
716
|
+
const s = t.field;
|
|
717
|
+
if (i[s] === n) return;
|
|
718
|
+
i[s] = n;
|
|
719
|
+
const a = !o._changedRowIndices.has(e);
|
|
706
720
|
o._changedRowIndices.add(e);
|
|
707
|
-
const
|
|
708
|
-
|
|
721
|
+
const l = o.findRenderedRowElement?.(e);
|
|
722
|
+
l && l.classList.add("changed"), o.dispatchEvent(
|
|
709
723
|
new CustomEvent("cell-commit", {
|
|
710
724
|
detail: {
|
|
711
|
-
row:
|
|
712
|
-
field:
|
|
725
|
+
row: i,
|
|
726
|
+
field: s,
|
|
713
727
|
value: n,
|
|
714
728
|
rowIndex: e,
|
|
715
729
|
changedRows: o.changedRows,
|
|
716
730
|
changedRowIndices: o.changedRowIndices,
|
|
717
|
-
firstTimeForRow:
|
|
731
|
+
firstTimeForRow: a
|
|
718
732
|
}
|
|
719
733
|
})
|
|
720
734
|
);
|
|
721
735
|
}
|
|
722
|
-
function L(o, e, t, n,
|
|
723
|
-
if (!n.editable || (o.activeEditRows !== t && T(o, t, e),
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
const
|
|
736
|
+
function L(o, e, t, n, i) {
|
|
737
|
+
if (!n.editable || (o.activeEditRows !== t && T(o, t, e), i.classList.contains("editing"))) return;
|
|
738
|
+
const s = e[n.field];
|
|
739
|
+
i.classList.add("editing");
|
|
740
|
+
const r = (h) => {
|
|
727
741
|
$(o, t, n, h, e);
|
|
728
|
-
},
|
|
729
|
-
e[n.field] =
|
|
730
|
-
const h =
|
|
731
|
-
h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!
|
|
732
|
-
},
|
|
733
|
-
|
|
734
|
-
const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)),
|
|
742
|
+
}, a = () => {
|
|
743
|
+
e[n.field] = s;
|
|
744
|
+
const h = i.querySelector("input,textarea,select");
|
|
745
|
+
h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!s : "value" in h && (h.value = s ?? ""));
|
|
746
|
+
}, l = document.createElement("div");
|
|
747
|
+
l.style.display = "contents", i.innerHTML = "", i.appendChild(l);
|
|
748
|
+
const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)), g = s;
|
|
735
749
|
if (p === "template" && f) {
|
|
736
750
|
const h = f.cloneNode(!0), c = n.__compiledEditor;
|
|
737
|
-
c ? h.innerHTML = c({ row: e, value:
|
|
738
|
-
|
|
739
|
-
const
|
|
740
|
-
return
|
|
751
|
+
c ? h.innerHTML = c({ row: e, value: s, field: n.field, column: n }) : h.querySelectorAll("*").forEach((d) => {
|
|
752
|
+
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, (b, m) => {
|
|
753
|
+
const C = e[m];
|
|
754
|
+
return C == null ? "" : String(C);
|
|
741
755
|
}) || "");
|
|
742
756
|
});
|
|
743
|
-
const
|
|
744
|
-
if (
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
const b =
|
|
748
|
-
|
|
749
|
-
}),
|
|
757
|
+
const u = h.querySelector("input,textarea,select");
|
|
758
|
+
if (u) {
|
|
759
|
+
const d = typeof HTMLInputElement < "u";
|
|
760
|
+
d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked = !!s : "value" in u && (u.value = s ?? ""), u.addEventListener("blur", () => {
|
|
761
|
+
const b = d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked : u.value;
|
|
762
|
+
r(b);
|
|
763
|
+
}), u.addEventListener("keydown", (b) => {
|
|
750
764
|
if (b.key === "Enter") {
|
|
751
|
-
const
|
|
752
|
-
|
|
765
|
+
const m = d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked : u.value;
|
|
766
|
+
r(m);
|
|
753
767
|
}
|
|
754
|
-
b.key === "Escape" &&
|
|
755
|
-
}),
|
|
756
|
-
const b =
|
|
757
|
-
|
|
758
|
-
}), setTimeout(() =>
|
|
768
|
+
b.key === "Escape" && a();
|
|
769
|
+
}), d && u instanceof HTMLInputElement && u.type === "checkbox" && u.addEventListener("change", () => {
|
|
770
|
+
const b = u.checked;
|
|
771
|
+
r(b);
|
|
772
|
+
}), setTimeout(() => u.focus(), 0);
|
|
759
773
|
}
|
|
760
|
-
|
|
774
|
+
l.appendChild(h);
|
|
761
775
|
} else if (typeof p == "string") {
|
|
762
776
|
const h = document.createElement(p);
|
|
763
|
-
h.value =
|
|
777
|
+
h.value = g, h.addEventListener("change", () => r(h.value)), l.appendChild(h);
|
|
764
778
|
} else if (typeof p == "function") {
|
|
765
|
-
const h = p({ row: e, value:
|
|
766
|
-
typeof h == "string" ?
|
|
779
|
+
const h = p({ row: e, value: g, field: n.field, column: n, commit: r, cancel: a });
|
|
780
|
+
typeof h == "string" ? l.innerHTML = h : l.appendChild(h);
|
|
767
781
|
} else if (p && typeof p == "object") {
|
|
768
782
|
const h = document.createElement("div");
|
|
769
|
-
h.setAttribute("data-external-editor", ""), h.setAttribute("data-field", n.field),
|
|
770
|
-
const c = { row: e, value:
|
|
783
|
+
h.setAttribute("data-external-editor", ""), h.setAttribute("data-field", n.field), l.appendChild(h);
|
|
784
|
+
const c = { row: e, value: g, field: n.field, column: n, commit: r, cancel: a };
|
|
771
785
|
if (p.mount)
|
|
772
786
|
try {
|
|
773
787
|
p.mount({ placeholder: h, context: c, spec: p });
|
|
@@ -788,50 +802,53 @@ function J(o, e) {
|
|
|
788
802
|
}
|
|
789
803
|
function Q(o, e, t) {
|
|
790
804
|
o.sortState = { field: e.field, direction: t };
|
|
791
|
-
const n = e.sortComparator || ((
|
|
792
|
-
o._rows.sort((
|
|
805
|
+
const n = e.sortComparator || ((i, s) => i == null && s == null ? 0 : i == null ? -1 : s == null || i > s ? 1 : i < s ? -1 : 0);
|
|
806
|
+
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
807
|
new CustomEvent("sort-change", { detail: { field: e.field, direction: t } })
|
|
794
808
|
), o.requestStateChange?.();
|
|
795
809
|
}
|
|
810
|
+
function $e(o, e) {
|
|
811
|
+
typeof e == "string" ? o.textContent = e : e instanceof HTMLElement && (o.innerHTML = "", o.appendChild(e.cloneNode(!0)));
|
|
812
|
+
}
|
|
796
813
|
function V(o) {
|
|
797
814
|
o.headerRowEl = o.findHeaderRow();
|
|
798
815
|
const e = o.headerRowEl;
|
|
799
816
|
e.innerHTML = "", e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1"), o.visibleColumns.forEach((t, n) => {
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
const
|
|
803
|
-
if (
|
|
817
|
+
const i = document.createElement("div");
|
|
818
|
+
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");
|
|
819
|
+
const s = t.__headerTemplate;
|
|
820
|
+
if (s) Array.from(s.childNodes).forEach((r) => i.appendChild(r.cloneNode(!0)));
|
|
804
821
|
else {
|
|
805
|
-
const
|
|
806
|
-
|
|
822
|
+
const r = t.header || t.field, a = document.createElement("span");
|
|
823
|
+
a.textContent = r, i.appendChild(a);
|
|
807
824
|
}
|
|
808
825
|
if (t.sortable) {
|
|
809
|
-
|
|
810
|
-
const
|
|
811
|
-
B(
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
o.resizeController?.isResizing || o.dispatchHeaderClick?.(
|
|
815
|
-
}),
|
|
816
|
-
if (
|
|
817
|
-
if (
|
|
826
|
+
i.classList.add("sortable"), i.tabIndex = 0;
|
|
827
|
+
const r = document.createElement("span");
|
|
828
|
+
B(r, "sort-indicator"), r.style.opacity = "0.6";
|
|
829
|
+
const a = o.sortState?.field === t.field ? o.sortState.direction : 0, l = { ...ce, ...o.icons }, f = a === 1 ? l.sortAsc : a === -1 ? l.sortDesc : l.sortNone;
|
|
830
|
+
$e(r, f), i.appendChild(r), i.setAttribute("aria-sort", a === 0 ? "none" : a === 1 ? "ascending" : "descending"), i.addEventListener("click", (p) => {
|
|
831
|
+
o.resizeController?.isResizing || o.dispatchHeaderClick?.(p, n, i) || J(o, t);
|
|
832
|
+
}), i.addEventListener("keydown", (p) => {
|
|
833
|
+
if (p.key === "Enter" || p.key === " ") {
|
|
834
|
+
if (p.preventDefault(), o.dispatchHeaderClick?.(p, n, i)) return;
|
|
818
835
|
J(o, t);
|
|
819
836
|
}
|
|
820
837
|
});
|
|
821
838
|
}
|
|
822
839
|
if (t.resizable) {
|
|
823
|
-
t.sticky || (
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
}),
|
|
840
|
+
t.sticky || (i.style.position = "relative");
|
|
841
|
+
const r = document.createElement("div");
|
|
842
|
+
r.className = "resize-handle", r.setAttribute("aria-hidden", "true"), r.addEventListener("mousedown", (a) => {
|
|
843
|
+
a.stopPropagation(), a.preventDefault(), o.resizeController.start(a, n, i);
|
|
844
|
+
}), i.appendChild(r);
|
|
828
845
|
}
|
|
829
|
-
e.appendChild(
|
|
846
|
+
e.appendChild(i);
|
|
830
847
|
});
|
|
831
848
|
try {
|
|
832
849
|
const t = o.shadowRoot;
|
|
833
|
-
t && t.querySelectorAll(".header-group-row .cell").forEach((
|
|
834
|
-
|
|
850
|
+
t && t.querySelectorAll(".header-group-row .cell").forEach((i) => {
|
|
851
|
+
i.getAttribute("data-group") && i.classList.add("grouped");
|
|
835
852
|
});
|
|
836
853
|
} catch {
|
|
837
854
|
}
|
|
@@ -839,39 +856,39 @@ function V(o) {
|
|
|
839
856
|
t.getAttribute("aria-sort") || t.setAttribute("aria-sort", "none");
|
|
840
857
|
});
|
|
841
858
|
}
|
|
842
|
-
function
|
|
843
|
-
let e = null, t = null, n = null,
|
|
844
|
-
const
|
|
859
|
+
function Ke(o) {
|
|
860
|
+
let e = null, t = null, n = null, i = null;
|
|
861
|
+
const s = (l) => {
|
|
845
862
|
if (!e) return;
|
|
846
|
-
const f =
|
|
847
|
-
|
|
863
|
+
const f = l.clientX - e.startX, p = Math.max(40, e.startWidth + f), g = o.visibleColumns[e.colIndex];
|
|
864
|
+
g.width = p, g.__userResized = !0, g.__renderedWidth = p, t == null && (t = requestAnimationFrame(() => {
|
|
848
865
|
t = null, o.updateTemplate?.();
|
|
849
866
|
})), o.dispatchEvent(
|
|
850
|
-
new CustomEvent("column-resize", { detail: { field:
|
|
867
|
+
new CustomEvent("column-resize", { detail: { field: g.field, width: p } })
|
|
851
868
|
);
|
|
852
869
|
};
|
|
853
|
-
let
|
|
854
|
-
const
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
})), window.removeEventListener("mousemove",
|
|
870
|
+
let r = !1;
|
|
871
|
+
const a = () => {
|
|
872
|
+
const l = e !== null;
|
|
873
|
+
l && (r = !0, requestAnimationFrame(() => {
|
|
874
|
+
r = !1;
|
|
875
|
+
})), window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", a), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, l && o.requestStateChange && o.requestStateChange();
|
|
859
876
|
};
|
|
860
877
|
return {
|
|
861
878
|
get isResizing() {
|
|
862
|
-
return e !== null ||
|
|
879
|
+
return e !== null || r;
|
|
863
880
|
},
|
|
864
|
-
start(
|
|
865
|
-
|
|
866
|
-
const
|
|
867
|
-
e = { startX:
|
|
881
|
+
start(l, f, p) {
|
|
882
|
+
l.preventDefault();
|
|
883
|
+
const g = p.getBoundingClientRect();
|
|
884
|
+
e = { startX: l.clientX, colIndex: f, startWidth: g.width }, window.addEventListener("mousemove", s), window.addEventListener("mouseup", a), 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
885
|
},
|
|
869
886
|
dispose() {
|
|
870
|
-
|
|
887
|
+
a();
|
|
871
888
|
}
|
|
872
889
|
};
|
|
873
890
|
}
|
|
874
|
-
function
|
|
891
|
+
function We() {
|
|
875
892
|
return {
|
|
876
893
|
toolPanels: /* @__PURE__ */ new Map(),
|
|
877
894
|
headerContents: /* @__PURE__ */ new Map(),
|
|
@@ -884,24 +901,24 @@ function $e() {
|
|
|
884
901
|
toolbarButtonCleanups: /* @__PURE__ */ new Map()
|
|
885
902
|
};
|
|
886
903
|
}
|
|
887
|
-
function
|
|
904
|
+
function Fe(o, e) {
|
|
888
905
|
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
906
|
}
|
|
890
|
-
function
|
|
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
|
-
|
|
902
|
-
for (const
|
|
903
|
-
const b = e.activePanel ===
|
|
904
|
-
|
|
907
|
+
function Ve(o, e) {
|
|
908
|
+
const t = o?.header?.title ?? "", n = !!t, i = o?.header?.toolbarButtons ?? [], s = i.length > 0, r = e.toolbarButtons.size > 0, a = e.lightDomButtons.length > 0, l = e.toolPanels.size > 0, p = (s || r || a) && l, g = [...i].sort((d, b) => (d.order ?? 100) - (b.order ?? 100)), h = [...e.toolbarButtons.values()].sort((d, b) => (d.order ?? 100) - (b.order ?? 100)), c = [...e.toolPanels.values()].sort((d, b) => (d.order ?? 100) - (b.order ?? 100));
|
|
909
|
+
let u = "";
|
|
910
|
+
for (const d of g)
|
|
911
|
+
d.icon && d.action && (u += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
|
|
912
|
+
for (const d of h)
|
|
913
|
+
d.icon && d.action && (u += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
|
|
914
|
+
for (const d of g)
|
|
915
|
+
(d.element || d.render) && (u += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
|
|
916
|
+
for (const d of h)
|
|
917
|
+
(d.element || d.render) && (u += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
|
|
918
|
+
a && (u += '<slot name="toolbar"></slot>'), p && (u += '<div class="tbw-toolbar-separator"></div>');
|
|
919
|
+
for (const d of c) {
|
|
920
|
+
const b = e.activePanel === d.id;
|
|
921
|
+
u += `<button class="tbw-toolbar-btn${b ? " active" : ""}" data-panel="${d.id}" title="${d.tooltip ?? d.title}" aria-label="${d.tooltip ?? d.title}" aria-pressed="${b}" aria-controls="tbw-panel-${d.id}">${d.icon}</button>`;
|
|
905
922
|
}
|
|
906
923
|
return `
|
|
907
924
|
<div class="tbw-shell-header" part="shell-header" role="banner">
|
|
@@ -910,16 +927,16 @@ function We(o, e) {
|
|
|
910
927
|
<slot name="header-content"></slot>
|
|
911
928
|
</div>
|
|
912
929
|
<div class="tbw-shell-toolbar" part="shell-toolbar" role="toolbar" aria-label="Grid tools">
|
|
913
|
-
${
|
|
930
|
+
${u}
|
|
914
931
|
</div>
|
|
915
932
|
</div>
|
|
916
933
|
`;
|
|
917
934
|
}
|
|
918
|
-
function
|
|
919
|
-
const n = o?.toolPanel?.position ?? "right",
|
|
920
|
-
<aside class="tbw-tool-panel${
|
|
935
|
+
function Ge(o, e, t) {
|
|
936
|
+
const n = o?.toolPanel?.position ?? "right", i = e.toolPanels.size > 0, s = e.activePanel !== null, r = e.activePanel ? e.toolPanels.get(e.activePanel) : null, a = i ? `
|
|
937
|
+
<aside class="tbw-tool-panel${s ? " open" : ""}" part="tool-panel" data-position="${n}" role="complementary" aria-label="${r?.title ?? "Tool panel"}" id="tbw-panel-${e.activePanel ?? "closed"}">
|
|
921
938
|
<div class="tbw-tool-panel-header">
|
|
922
|
-
<span class="tbw-tool-panel-title">${
|
|
939
|
+
<span class="tbw-tool-panel-title">${r?.title ?? ""}</span>
|
|
923
940
|
<button class="tbw-tool-panel-close" aria-label="Close panel">✕</button>
|
|
924
941
|
</div>
|
|
925
942
|
<div class="tbw-tool-panel-content" role="region"></div>
|
|
@@ -927,7 +944,7 @@ function Fe(o, e, t) {
|
|
|
927
944
|
` : "";
|
|
928
945
|
return n === "left" ? `
|
|
929
946
|
<div class="tbw-shell-body">
|
|
930
|
-
${
|
|
947
|
+
${a}
|
|
931
948
|
<div class="tbw-grid-content">
|
|
932
949
|
${t}
|
|
933
950
|
</div>
|
|
@@ -937,7 +954,7 @@ function Fe(o, e, t) {
|
|
|
937
954
|
<div class="tbw-grid-content">
|
|
938
955
|
${t}
|
|
939
956
|
</div>
|
|
940
|
-
${
|
|
957
|
+
${a}
|
|
941
958
|
</div>
|
|
942
959
|
`;
|
|
943
960
|
}
|
|
@@ -946,78 +963,78 @@ function ee(o, e) {
|
|
|
946
963
|
if (!t) return;
|
|
947
964
|
t.style.display = "none";
|
|
948
965
|
const n = t.querySelectorAll("tbw-grid-header-content");
|
|
949
|
-
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((
|
|
950
|
-
|
|
966
|
+
e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((s, r) => {
|
|
967
|
+
s.setAttribute("slot", "header-content");
|
|
951
968
|
});
|
|
952
|
-
const
|
|
953
|
-
e.lightDomButtons = Array.from(
|
|
954
|
-
const
|
|
955
|
-
return
|
|
956
|
-
}), e.lightDomButtons.forEach((
|
|
957
|
-
|
|
969
|
+
const i = t.querySelectorAll("tbw-grid-tool-button");
|
|
970
|
+
e.lightDomButtons = Array.from(i), e.lightDomButtons.sort((s, r) => {
|
|
971
|
+
const a = parseInt(s.getAttribute("order") ?? "100", 10), l = parseInt(r.getAttribute("order") ?? "100", 10);
|
|
972
|
+
return a - l;
|
|
973
|
+
}), e.lightDomButtons.forEach((s) => {
|
|
974
|
+
s.setAttribute("slot", "toolbar");
|
|
958
975
|
});
|
|
959
976
|
}
|
|
960
|
-
function
|
|
961
|
-
const
|
|
962
|
-
|
|
963
|
-
const
|
|
964
|
-
if (
|
|
965
|
-
const p =
|
|
977
|
+
function Ue(o, e, t, n) {
|
|
978
|
+
const i = o.querySelector(".tbw-shell-toolbar");
|
|
979
|
+
i && i.addEventListener("click", (r) => {
|
|
980
|
+
const a = r.target, l = a.closest("[data-panel]");
|
|
981
|
+
if (l) {
|
|
982
|
+
const p = l.getAttribute("data-panel");
|
|
966
983
|
p && n.onPanelToggle(p);
|
|
967
984
|
return;
|
|
968
985
|
}
|
|
969
|
-
const f =
|
|
986
|
+
const f = a.closest("[data-btn]");
|
|
970
987
|
if (f) {
|
|
971
988
|
const p = f.getAttribute("data-btn");
|
|
972
989
|
p && n.onToolbarButtonClick(p);
|
|
973
990
|
}
|
|
974
991
|
});
|
|
975
|
-
const
|
|
976
|
-
|
|
992
|
+
const s = o.querySelector(".tbw-tool-panel-close");
|
|
993
|
+
s && s.addEventListener("click", () => {
|
|
977
994
|
n.onPanelClose();
|
|
978
995
|
});
|
|
979
996
|
}
|
|
980
|
-
function
|
|
997
|
+
function Xe(o, e, t) {
|
|
981
998
|
const n = [...e?.header?.toolbarButtons ?? [], ...t.toolbarButtons.values()];
|
|
982
|
-
for (const
|
|
983
|
-
const
|
|
984
|
-
if (!
|
|
985
|
-
const
|
|
986
|
-
if (
|
|
987
|
-
|
|
988
|
-
else if (
|
|
989
|
-
const
|
|
990
|
-
|
|
999
|
+
for (const i of n) {
|
|
1000
|
+
const s = o.querySelector(`[data-btn-slot="${i.id}"]`);
|
|
1001
|
+
if (!s) continue;
|
|
1002
|
+
const r = t.toolbarButtonCleanups.get(i.id);
|
|
1003
|
+
if (r && (r(), t.toolbarButtonCleanups.delete(i.id)), i.element)
|
|
1004
|
+
s.appendChild(i.element);
|
|
1005
|
+
else if (i.render) {
|
|
1006
|
+
const a = i.render(s);
|
|
1007
|
+
a && t.toolbarButtonCleanups.set(i.id, a);
|
|
991
1008
|
}
|
|
992
1009
|
}
|
|
993
1010
|
}
|
|
994
1011
|
function te(o, e) {
|
|
995
1012
|
const t = o.querySelector(".tbw-shell-content");
|
|
996
1013
|
if (!t) return;
|
|
997
|
-
const n = [...e.headerContents.values()].sort((
|
|
998
|
-
for (const
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
let
|
|
1002
|
-
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1014
|
+
const n = [...e.headerContents.values()].sort((s, r) => (s.order ?? 100) - (r.order ?? 100)), i = t.querySelector('slot[name="header-content"]');
|
|
1015
|
+
for (const s of n) {
|
|
1016
|
+
const r = e.headerContentCleanups.get(s.id);
|
|
1017
|
+
r && (r(), e.headerContentCleanups.delete(s.id));
|
|
1018
|
+
let a = t.querySelector(`[data-header-content="${s.id}"]`);
|
|
1019
|
+
a || (a = document.createElement("div"), a.setAttribute("data-header-content", s.id), i ? t.insertBefore(a, i) : t.appendChild(a));
|
|
1020
|
+
const l = s.render(a);
|
|
1021
|
+
l && e.headerContentCleanups.set(s.id, l);
|
|
1005
1022
|
}
|
|
1006
1023
|
}
|
|
1007
|
-
function
|
|
1024
|
+
function je(o, e) {
|
|
1008
1025
|
if (!e.activePanel) return;
|
|
1009
1026
|
const t = e.toolPanels.get(e.activePanel);
|
|
1010
1027
|
if (!t) return;
|
|
1011
1028
|
const n = o.querySelector(".tbw-tool-panel-content");
|
|
1012
1029
|
if (!n) return;
|
|
1013
1030
|
e.activePanelCleanup && (e.activePanelCleanup(), e.activePanelCleanup = null), n.innerHTML = "";
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1031
|
+
const i = t.render(n);
|
|
1032
|
+
i && (e.activePanelCleanup = i);
|
|
1016
1033
|
}
|
|
1017
1034
|
function oe(o, e) {
|
|
1018
1035
|
o.querySelectorAll("[data-panel]").forEach((n) => {
|
|
1019
|
-
const
|
|
1020
|
-
n.classList.toggle("active",
|
|
1036
|
+
const s = n.getAttribute("data-panel") === e.activePanel;
|
|
1037
|
+
n.classList.toggle("active", s), n.setAttribute("aria-pressed", String(s));
|
|
1021
1038
|
});
|
|
1022
1039
|
}
|
|
1023
1040
|
function ne(o, e) {
|
|
@@ -1025,11 +1042,11 @@ function ne(o, e) {
|
|
|
1025
1042
|
if (!t) return;
|
|
1026
1043
|
const n = e.activePanel !== null;
|
|
1027
1044
|
if (t.classList.toggle("open", n), n && e.activePanel) {
|
|
1028
|
-
const
|
|
1029
|
-
|
|
1045
|
+
const i = e.toolPanels.get(e.activePanel), s = t.querySelector(".tbw-tool-panel-title");
|
|
1046
|
+
s && (s.textContent = i?.title ?? ""), t.setAttribute("aria-label", `${i?.title ?? "Tool"} panel`), t.id = `tbw-panel-${e.activePanel}`;
|
|
1030
1047
|
}
|
|
1031
1048
|
}
|
|
1032
|
-
function
|
|
1049
|
+
function Ye(o, e) {
|
|
1033
1050
|
const t = [];
|
|
1034
1051
|
for (const n of o?.header?.toolbarButtons ?? [])
|
|
1035
1052
|
t.push({
|
|
@@ -1046,11 +1063,11 @@ function Xe(o, e) {
|
|
|
1046
1063
|
source: "config"
|
|
1047
1064
|
});
|
|
1048
1065
|
for (let n = 0; n < e.lightDomButtons.length; n++) {
|
|
1049
|
-
const
|
|
1066
|
+
const s = e.lightDomButtons[n].querySelector("button");
|
|
1050
1067
|
t.push({
|
|
1051
1068
|
id: `light-dom-${n}`,
|
|
1052
|
-
label:
|
|
1053
|
-
disabled:
|
|
1069
|
+
label: s?.getAttribute("title") ?? s?.getAttribute("aria-label") ?? "",
|
|
1070
|
+
disabled: s?.disabled ?? !1,
|
|
1054
1071
|
source: "light-dom"
|
|
1055
1072
|
});
|
|
1056
1073
|
}
|
|
@@ -1064,7 +1081,7 @@ function Xe(o, e) {
|
|
|
1064
1081
|
});
|
|
1065
1082
|
return t;
|
|
1066
1083
|
}
|
|
1067
|
-
function
|
|
1084
|
+
function Ze(o) {
|
|
1068
1085
|
for (const e of o.headerContentCleanups.values())
|
|
1069
1086
|
e();
|
|
1070
1087
|
o.headerContentCleanups.clear(), o.activePanelCleanup && (o.activePanelCleanup(), o.activePanelCleanup = null);
|
|
@@ -1072,7 +1089,7 @@ function je(o) {
|
|
|
1072
1089
|
e();
|
|
1073
1090
|
o.toolbarButtonCleanups.clear(), o.activePanel && o.toolPanels.get(o.activePanel)?.onClose?.(), o.toolPanels.clear(), o.headerContents.clear(), o.toolbarButtons.clear(), o.lightDomButtons = [], o.lightDomHeaderContent = [], o.activePanel = null;
|
|
1074
1091
|
}
|
|
1075
|
-
class
|
|
1092
|
+
class Je {
|
|
1076
1093
|
constructor(e) {
|
|
1077
1094
|
this.grid = e;
|
|
1078
1095
|
}
|
|
@@ -1206,13 +1223,46 @@ class Ye {
|
|
|
1206
1223
|
for (const e of this.plugins)
|
|
1207
1224
|
e.onScrollRender?.();
|
|
1208
1225
|
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Get total extra height contributed by plugins (e.g., expanded detail rows).
|
|
1228
|
+
* Used to adjust scrollbar height calculations.
|
|
1229
|
+
*/
|
|
1230
|
+
getExtraHeight() {
|
|
1231
|
+
let e = 0;
|
|
1232
|
+
for (const t of this.plugins)
|
|
1233
|
+
typeof t.getExtraHeight == "function" && (e += t.getExtraHeight());
|
|
1234
|
+
return e;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Get extra height from plugins that appears before a given row index.
|
|
1238
|
+
* Used by virtualization to correctly position the scroll window.
|
|
1239
|
+
*/
|
|
1240
|
+
getExtraHeightBefore(e) {
|
|
1241
|
+
let t = 0;
|
|
1242
|
+
for (const n of this.plugins)
|
|
1243
|
+
typeof n.getExtraHeightBefore == "function" && (t += n.getExtraHeightBefore(e));
|
|
1244
|
+
return t;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Adjust the virtualization start index based on plugin needs.
|
|
1248
|
+
* Returns the minimum start index from all plugins.
|
|
1249
|
+
*/
|
|
1250
|
+
adjustVirtualStart(e, t, n) {
|
|
1251
|
+
let i = e;
|
|
1252
|
+
for (const s of this.plugins)
|
|
1253
|
+
if (typeof s.adjustVirtualStart == "function") {
|
|
1254
|
+
const r = s.adjustVirtualStart(e, t, n);
|
|
1255
|
+
r < i && (i = r);
|
|
1256
|
+
}
|
|
1257
|
+
return i;
|
|
1258
|
+
}
|
|
1209
1259
|
/**
|
|
1210
1260
|
* Execute renderRow hook on all plugins.
|
|
1211
1261
|
* Returns true if any plugin handled the row.
|
|
1212
1262
|
*/
|
|
1213
1263
|
renderRow(e, t, n) {
|
|
1214
|
-
for (const
|
|
1215
|
-
if (
|
|
1264
|
+
for (const i of this.plugins)
|
|
1265
|
+
if (i.renderRow?.(e, t, n))
|
|
1216
1266
|
return !0;
|
|
1217
1267
|
return !1;
|
|
1218
1268
|
}
|
|
@@ -1299,8 +1349,8 @@ class Ye {
|
|
|
1299
1349
|
getContextMenuItems(e) {
|
|
1300
1350
|
const t = [];
|
|
1301
1351
|
for (const n of this.plugins) {
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1352
|
+
const i = n.getContextMenuItems?.(e);
|
|
1353
|
+
i && t.push(...i);
|
|
1304
1354
|
}
|
|
1305
1355
|
return t;
|
|
1306
1356
|
}
|
|
@@ -1330,10 +1380,10 @@ class Ye {
|
|
|
1330
1380
|
return e.sort((t, n) => (t.content.order ?? 0) - (n.content.order ?? 0));
|
|
1331
1381
|
}
|
|
1332
1382
|
}
|
|
1333
|
-
class
|
|
1383
|
+
class I extends HTMLElement {
|
|
1334
1384
|
// TODO: Rename to 'data-grid' when migration is complete
|
|
1335
1385
|
static tagName = "tbw-grid";
|
|
1336
|
-
#
|
|
1386
|
+
#o;
|
|
1337
1387
|
#i = !1;
|
|
1338
1388
|
// ---------------- Ready Promise ----------------
|
|
1339
1389
|
#z;
|
|
@@ -1342,37 +1392,37 @@ class q extends HTMLElement {
|
|
|
1342
1392
|
// These backing fields store raw user input. They are merged into
|
|
1343
1393
|
// #effectiveConfig by #mergeEffectiveConfig(). Never read directly
|
|
1344
1394
|
// for rendering logic - always use effectiveConfig or derived state.
|
|
1345
|
-
#
|
|
1346
|
-
#
|
|
1395
|
+
#r = [];
|
|
1396
|
+
#l;
|
|
1347
1397
|
#g;
|
|
1398
|
+
#v;
|
|
1348
1399
|
#C;
|
|
1349
|
-
#y;
|
|
1350
1400
|
// ================== SINGLE SOURCE OF TRUTH ==================
|
|
1351
1401
|
// All input sources converge here. This is the canonical config
|
|
1352
1402
|
// that all rendering and logic should read from.
|
|
1353
|
-
#
|
|
1354
|
-
#
|
|
1355
|
-
#
|
|
1403
|
+
#n = {};
|
|
1404
|
+
#f = !1;
|
|
1405
|
+
#p = 0;
|
|
1356
1406
|
#E = null;
|
|
1357
|
-
#
|
|
1407
|
+
#y = !1;
|
|
1358
1408
|
// Cached flag for plugin scroll handlers
|
|
1359
1409
|
#k;
|
|
1360
1410
|
// Cached hook to avoid closures
|
|
1361
|
-
#
|
|
1362
|
-
#
|
|
1363
|
-
#_ = !1;
|
|
1364
|
-
#w;
|
|
1365
|
-
#b;
|
|
1411
|
+
#R = !1;
|
|
1412
|
+
#_ = null;
|
|
1366
1413
|
#A = null;
|
|
1367
1414
|
#S = null;
|
|
1415
|
+
#x = null;
|
|
1416
|
+
#a;
|
|
1417
|
+
#w;
|
|
1368
1418
|
// ---------------- Plugin System ----------------
|
|
1369
1419
|
#t;
|
|
1370
1420
|
// ---------------- Column State ----------------
|
|
1371
1421
|
#P;
|
|
1372
|
-
#
|
|
1422
|
+
#h;
|
|
1373
1423
|
// ---------------- Shell State ----------------
|
|
1374
|
-
#e =
|
|
1375
|
-
#
|
|
1424
|
+
#e = We();
|
|
1425
|
+
#c = !1;
|
|
1376
1426
|
// ================== DERIVED STATE ==================
|
|
1377
1427
|
// _rows: result of applying plugin processRows hooks
|
|
1378
1428
|
_rows = [];
|
|
@@ -1380,10 +1430,10 @@ class q extends HTMLElement {
|
|
|
1380
1430
|
// This ensures effectiveConfig.columns is the single source of truth for columns
|
|
1381
1431
|
// _columns always contains ALL columns (including hidden)
|
|
1382
1432
|
get _columns() {
|
|
1383
|
-
return this.#
|
|
1433
|
+
return this.#n.columns ?? [];
|
|
1384
1434
|
}
|
|
1385
1435
|
set _columns(e) {
|
|
1386
|
-
this.#
|
|
1436
|
+
this.#n.columns = e;
|
|
1387
1437
|
}
|
|
1388
1438
|
// visibleColumns returns only visible columns for rendering
|
|
1389
1439
|
// This is what header/row rendering should use
|
|
@@ -1432,56 +1482,66 @@ class q extends HTMLElement {
|
|
|
1432
1482
|
return this._rows;
|
|
1433
1483
|
}
|
|
1434
1484
|
set rows(e) {
|
|
1435
|
-
const t = this.#
|
|
1436
|
-
this.#
|
|
1485
|
+
const t = this.#r;
|
|
1486
|
+
this.#r = e, t !== e && this.#Z();
|
|
1437
1487
|
}
|
|
1438
1488
|
/**
|
|
1439
1489
|
* Get the original unfiltered/unprocessed rows.
|
|
1440
1490
|
* Use this when you need access to all source data regardless of active filters.
|
|
1441
1491
|
*/
|
|
1442
1492
|
get sourceRows() {
|
|
1443
|
-
return this.#
|
|
1493
|
+
return this.#r;
|
|
1444
1494
|
}
|
|
1445
1495
|
get columns() {
|
|
1446
1496
|
return [...this._columns];
|
|
1447
1497
|
}
|
|
1448
1498
|
set columns(e) {
|
|
1449
|
-
const t = this.#
|
|
1450
|
-
this.#
|
|
1499
|
+
const t = this.#l;
|
|
1500
|
+
this.#l = e, t !== e && this.#J();
|
|
1451
1501
|
}
|
|
1452
1502
|
get gridConfig() {
|
|
1453
|
-
return this.#
|
|
1503
|
+
return this.#n;
|
|
1454
1504
|
}
|
|
1455
1505
|
set gridConfig(e) {
|
|
1456
1506
|
const t = this.#g;
|
|
1457
1507
|
this.#g = e, t !== e && this.#Q();
|
|
1458
1508
|
}
|
|
1459
1509
|
get fitMode() {
|
|
1460
|
-
return this.#
|
|
1510
|
+
return this.#n.fitMode ?? "stretch";
|
|
1461
1511
|
}
|
|
1462
1512
|
set fitMode(e) {
|
|
1463
|
-
const t = this.#
|
|
1464
|
-
this.#
|
|
1513
|
+
const t = this.#v;
|
|
1514
|
+
this.#v = e, t !== e && this.#j();
|
|
1465
1515
|
}
|
|
1466
1516
|
get editOn() {
|
|
1467
|
-
return this.#
|
|
1517
|
+
return this.#n.editOn;
|
|
1468
1518
|
}
|
|
1469
1519
|
set editOn(e) {
|
|
1470
|
-
const t = this.#
|
|
1471
|
-
this.#
|
|
1520
|
+
const t = this.#C;
|
|
1521
|
+
this.#C = e, t !== e && this.#Y();
|
|
1472
1522
|
}
|
|
1473
1523
|
// Effective config accessor for internal modules and plugins
|
|
1474
1524
|
// Returns the merged config (single source of truth) before plugin processing
|
|
1475
1525
|
// Use this when you need the raw merged config (e.g., for column definitions including hidden)
|
|
1476
1526
|
get effectiveConfig() {
|
|
1477
|
-
return this.#
|
|
1527
|
+
return this.#n;
|
|
1528
|
+
}
|
|
1529
|
+
/**
|
|
1530
|
+
* Get the disconnect signal for event listener cleanup.
|
|
1531
|
+
* This signal is aborted when the grid disconnects from the DOM.
|
|
1532
|
+
* Plugins and internal code can use this for automatic listener cleanup.
|
|
1533
|
+
* @example
|
|
1534
|
+
* element.addEventListener('click', handler, { signal: this.grid.disconnectSignal });
|
|
1535
|
+
*/
|
|
1536
|
+
get disconnectSignal() {
|
|
1537
|
+
return this.#a || (this.#a = new AbortController()), this.#a.signal;
|
|
1478
1538
|
}
|
|
1479
1539
|
constructor() {
|
|
1480
|
-
super(), this.#
|
|
1540
|
+
super(), this.#o = this.attachShadow({ mode: "open" }), this.#V(), this.#z = new Promise((e) => this.#N = e);
|
|
1481
1541
|
}
|
|
1482
1542
|
#V() {
|
|
1483
1543
|
const e = new CSSStyleSheet();
|
|
1484
|
-
e.replaceSync(we), this.#
|
|
1544
|
+
e.replaceSync(we), this.#o.adoptedStyleSheets = [e];
|
|
1485
1545
|
}
|
|
1486
1546
|
// ---------------- Plugin System ----------------
|
|
1487
1547
|
/**
|
|
@@ -1504,7 +1564,7 @@ class q extends HTMLElement {
|
|
|
1504
1564
|
* Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
|
|
1505
1565
|
*/
|
|
1506
1566
|
requestRender() {
|
|
1507
|
-
this.#
|
|
1567
|
+
this.#L(), this.#M(), this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
1508
1568
|
}
|
|
1509
1569
|
/**
|
|
1510
1570
|
* Request a lightweight style update without rebuilding DOM.
|
|
@@ -1512,26 +1572,26 @@ class q extends HTMLElement {
|
|
|
1512
1572
|
* This runs all plugin afterRender hooks without rebuilding row/column DOM.
|
|
1513
1573
|
*/
|
|
1514
1574
|
requestAfterRender() {
|
|
1515
|
-
this.#
|
|
1575
|
+
this.#b();
|
|
1516
1576
|
}
|
|
1517
1577
|
/**
|
|
1518
1578
|
* Initialize plugin system with instances from config.
|
|
1519
1579
|
* Plugins are class instances passed in gridConfig.plugins[].
|
|
1520
1580
|
*/
|
|
1521
|
-
#
|
|
1522
|
-
this.#t = new
|
|
1523
|
-
const e = this.#
|
|
1581
|
+
#I() {
|
|
1582
|
+
this.#t = new Je(this);
|
|
1583
|
+
const e = this.#n?.plugins, t = Array.isArray(e) ? e : [];
|
|
1524
1584
|
this.#t.attachAll(t);
|
|
1525
1585
|
}
|
|
1526
1586
|
/**
|
|
1527
1587
|
* Inject all plugin styles into the shadow DOM.
|
|
1528
1588
|
* Must be called after #render() since innerHTML wipes existing content.
|
|
1529
1589
|
*/
|
|
1530
|
-
#
|
|
1590
|
+
#q() {
|
|
1531
1591
|
const e = this.#t?.getAllStyles() ?? "";
|
|
1532
1592
|
if (e) {
|
|
1533
1593
|
const t = document.createElement("style");
|
|
1534
|
-
t.setAttribute("data-plugin", "all"), t.textContent = e, this.#
|
|
1594
|
+
t.setAttribute("data-plugin", "all"), t.textContent = e, this.#o.appendChild(t);
|
|
1535
1595
|
}
|
|
1536
1596
|
}
|
|
1537
1597
|
/**
|
|
@@ -1539,7 +1599,7 @@ class q extends HTMLElement {
|
|
|
1539
1599
|
* With class-based plugins, we need to detach old and attach new.
|
|
1540
1600
|
*/
|
|
1541
1601
|
#B() {
|
|
1542
|
-
this.#t && this.#t.detachAll(), this.#
|
|
1602
|
+
this.#t && this.#t.detachAll(), this.#I(), this.#q(), this.#y = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
|
|
1543
1603
|
}
|
|
1544
1604
|
/**
|
|
1545
1605
|
* Clean up plugin states when grid disconnects.
|
|
@@ -1562,75 +1622,89 @@ class q extends HTMLElement {
|
|
|
1562
1622
|
}
|
|
1563
1623
|
// ---------------- Lifecycle ----------------
|
|
1564
1624
|
connectedCallback() {
|
|
1565
|
-
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#
|
|
1625
|
+
this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#a?.abort(), this.#a = new AbortController(), this.#u(), this.#I(), this.#U(), this.#i || (this.#F(), this.#q(), this.#i = !0), this.#$();
|
|
1566
1626
|
}
|
|
1567
1627
|
disconnectedCallback() {
|
|
1568
|
-
this.#G(),
|
|
1628
|
+
this.#G(), Ze(this.#e), this.#c = !1, this.#a && (this.#a.abort(), this.#a = void 0), this.resizeController && this.resizeController.dispose(), this.#w && (this.#w.disconnect(), this.#w = void 0), this.#f = !1;
|
|
1569
1629
|
}
|
|
1570
1630
|
#$() {
|
|
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
|
-
|
|
1631
|
+
const t = this.#o.querySelector(".tbw-grid-content") ?? this.#o.querySelector(".tbw-grid-root");
|
|
1632
|
+
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) {
|
|
1633
|
+
te(this.#o, this.#e), Xe(this.#o, this.#n?.shell, this.#e);
|
|
1634
|
+
const r = this.#n?.shell?.toolPanel?.defaultOpen;
|
|
1635
|
+
r && this.#e.toolPanels.has(r) && this.openToolPanel(r);
|
|
1636
|
+
}
|
|
1637
|
+
this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#f = !0;
|
|
1638
|
+
const n = this.disconnectSignal;
|
|
1639
|
+
this.#d(), this.addEventListener("keydown", (r) => ze(this, r), { signal: n }), document.addEventListener(
|
|
1640
|
+
"keydown",
|
|
1641
|
+
(r) => {
|
|
1642
|
+
r.key === "Escape" && this.activeEditRows !== -1 && this.#O(this.activeEditRows, !0);
|
|
1643
|
+
},
|
|
1644
|
+
{ capture: !0, signal: n }
|
|
1645
|
+
), document.addEventListener(
|
|
1646
|
+
"mousedown",
|
|
1647
|
+
(r) => {
|
|
1648
|
+
if (this.activeEditRows === -1) return;
|
|
1649
|
+
const a = this.findRenderedRowElement(this.activeEditRows);
|
|
1650
|
+
!a || (r.composedPath && r.composedPath() || []).includes(a) || this.#O(this.activeEditRows, !1);
|
|
1651
|
+
},
|
|
1652
|
+
{ signal: n }
|
|
1653
|
+
);
|
|
1654
|
+
const i = t?.querySelector(".faux-vscroll"), s = t?.querySelector(".rows");
|
|
1655
|
+
if (this.virtualization.container = i ?? this, this.#y = this.#t?.getAll().some((r) => r.onScroll) ?? !1, i && s) {
|
|
1656
|
+
i.addEventListener(
|
|
1587
1657
|
"scroll",
|
|
1588
1658
|
() => {
|
|
1589
|
-
if (!this.virtualization.enabled && !this.#
|
|
1590
|
-
const l =
|
|
1591
|
-
s.style.transform = `translateY(${
|
|
1592
|
-
this.#
|
|
1659
|
+
if (!this.virtualization.enabled && !this.#y) return;
|
|
1660
|
+
const l = i.scrollTop, f = this.virtualization.rowHeight, p = Math.floor(l / f), g = p - p % 2, h = -(l - g * f);
|
|
1661
|
+
s.style.transform = `translateY(${h}px)`, this.#E = l, this.#p || (this.#p = requestAnimationFrame(() => {
|
|
1662
|
+
this.#p = 0, this.#E !== null && (this.#ne(this.#E), this.#E = null);
|
|
1593
1663
|
}));
|
|
1594
1664
|
},
|
|
1595
|
-
{ passive: !0 }
|
|
1665
|
+
{ passive: !0, signal: n }
|
|
1596
1666
|
);
|
|
1597
|
-
const
|
|
1598
|
-
|
|
1667
|
+
const r = this.#o.querySelector(".tbw-grid-content"), a = this.#o.querySelector(".tbw-scroll-area");
|
|
1668
|
+
r && (r.addEventListener(
|
|
1599
1669
|
"wheel",
|
|
1600
1670
|
(l) => {
|
|
1601
|
-
l.preventDefault(),
|
|
1671
|
+
l.preventDefault(), l.shiftKey || Math.abs(l.deltaX) > Math.abs(l.deltaY) ? a && (a.scrollLeft += l.shiftKey ? l.deltaY : l.deltaX) : i.scrollTop += l.deltaY;
|
|
1602
1672
|
},
|
|
1603
|
-
{ passive: !1 }
|
|
1604
|
-
),
|
|
1673
|
+
{ passive: !1, signal: n }
|
|
1674
|
+
), r.addEventListener(
|
|
1605
1675
|
"touchstart",
|
|
1606
1676
|
(l) => {
|
|
1607
|
-
l.touches.length === 1 && (this.#
|
|
1677
|
+
l.touches.length === 1 && (this.#_ = l.touches[0].clientY, this.#A = l.touches[0].clientX, this.#S = i.scrollTop, this.#x = a?.scrollLeft ?? 0);
|
|
1608
1678
|
},
|
|
1609
|
-
{ passive: !0 }
|
|
1610
|
-
),
|
|
1679
|
+
{ passive: !0, signal: n }
|
|
1680
|
+
), r.addEventListener(
|
|
1611
1681
|
"touchmove",
|
|
1612
1682
|
(l) => {
|
|
1613
|
-
if (l.touches.length === 1 && this.#A !== null && this.#S !== null) {
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1683
|
+
if (l.touches.length === 1 && this.#_ !== null && this.#A !== null && this.#S !== null && this.#x !== null) {
|
|
1684
|
+
const f = this.#_ - l.touches[0].clientY, p = this.#A - l.touches[0].clientX;
|
|
1685
|
+
i.scrollTop = this.#S + f, a && (a.scrollLeft = this.#x + p), l.preventDefault();
|
|
1616
1686
|
}
|
|
1617
1687
|
},
|
|
1618
|
-
{ passive: !1 }
|
|
1619
|
-
),
|
|
1688
|
+
{ passive: !1, signal: n }
|
|
1689
|
+
), r.addEventListener(
|
|
1620
1690
|
"touchend",
|
|
1621
1691
|
() => {
|
|
1622
|
-
this.#A = null, this.#S = null;
|
|
1692
|
+
this.#_ = null, this.#A = null, this.#S = null, this.#x = null;
|
|
1623
1693
|
},
|
|
1624
|
-
{ passive: !0 }
|
|
1694
|
+
{ passive: !0, signal: n }
|
|
1625
1695
|
));
|
|
1626
1696
|
}
|
|
1627
|
-
this.resizeController =
|
|
1628
|
-
const
|
|
1629
|
-
if (
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1697
|
+
this.resizeController = Ke(this), this.#o.addEventListener("mousedown", (r) => this.#ie(r), { signal: n }), document.addEventListener("mousemove", (r) => this.#se(r), { signal: n }), document.addEventListener("mouseup", (r) => this.#re(r), { signal: n }), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
|
|
1698
|
+
const r = this.bodyEl.querySelector(".data-grid-row");
|
|
1699
|
+
if (r) {
|
|
1700
|
+
const a = r.getBoundingClientRect().height;
|
|
1701
|
+
a && Math.abs(a - this.virtualization.rowHeight) > 0.1 && (this.virtualization.rowHeight = a, this.refreshVirtualWindow(!0));
|
|
1632
1702
|
}
|
|
1633
|
-
}),
|
|
1703
|
+
}), this.virtualization.viewportEl && (this.#w = new ResizeObserver(() => {
|
|
1704
|
+
this.#p || (this.#p = requestAnimationFrame(() => {
|
|
1705
|
+
this.#p = 0, this.refreshVirtualWindow(!0);
|
|
1706
|
+
}));
|
|
1707
|
+
}), this.#w.observe(this.virtualization.viewportEl)), queueMicrotask(() => this.#X()), requestAnimationFrame(() => requestAnimationFrame(() => this.#N?.()));
|
|
1634
1708
|
}
|
|
1635
1709
|
// ---------------- Event Emitters ----------------
|
|
1636
1710
|
#s(e, t) {
|
|
@@ -1654,65 +1728,65 @@ class q extends HTMLElement {
|
|
|
1654
1728
|
/** Update ARIA selection attributes on rendered rows/cells */
|
|
1655
1729
|
#X() {
|
|
1656
1730
|
this.bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t, n) => {
|
|
1657
|
-
const
|
|
1658
|
-
t.setAttribute("aria-selected", String(
|
|
1659
|
-
|
|
1731
|
+
const i = n === this.focusRow;
|
|
1732
|
+
t.setAttribute("aria-selected", String(i)), t.querySelectorAll(".cell").forEach((s, r) => {
|
|
1733
|
+
s.setAttribute("aria-selected", String(i && r === this.focusCol));
|
|
1660
1734
|
});
|
|
1661
1735
|
});
|
|
1662
1736
|
}
|
|
1663
1737
|
// ---------------- Watch Handlers ----------------
|
|
1664
1738
|
#j() {
|
|
1665
|
-
if (!this.#
|
|
1666
|
-
this.#
|
|
1739
|
+
if (!this.#f) return;
|
|
1740
|
+
this.#u(), this.#n.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#K()) : (this._columns.forEach((t) => {
|
|
1667
1741
|
!t.__userResized && t.__autoSized && delete t.width;
|
|
1668
1742
|
}), this.updateTemplate());
|
|
1669
1743
|
}
|
|
1670
1744
|
#Y() {
|
|
1671
|
-
this.#
|
|
1745
|
+
this.#f && (this.#u(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
|
|
1672
1746
|
}
|
|
1673
1747
|
#Z() {
|
|
1674
|
-
this._rows = Array.isArray(this.#
|
|
1748
|
+
this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#L(), !this.#l || Array.isArray(this.#l) && this.#l.length === 0 ? this.#d() : this.refreshVirtualWindow(!0);
|
|
1675
1749
|
}
|
|
1676
1750
|
#J() {
|
|
1677
|
-
j(this), this.#
|
|
1751
|
+
j(this), this.#f && (this.#u(), this.#d());
|
|
1678
1752
|
}
|
|
1679
1753
|
#Q() {
|
|
1680
|
-
this.#
|
|
1754
|
+
this.#f && (this.#u(), this.#B(), this.#L(), this.#M(), this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0));
|
|
1681
1755
|
}
|
|
1682
1756
|
// ---------------- Helper Wrappers ----------------
|
|
1683
1757
|
#ee() {
|
|
1684
|
-
|
|
1758
|
+
He(this);
|
|
1685
1759
|
}
|
|
1686
|
-
#
|
|
1760
|
+
#T() {
|
|
1687
1761
|
V(this);
|
|
1688
1762
|
}
|
|
1689
1763
|
updateTemplate() {
|
|
1690
|
-
|
|
1764
|
+
ue(this);
|
|
1691
1765
|
}
|
|
1692
1766
|
#K() {
|
|
1693
|
-
|
|
1767
|
+
Oe(this);
|
|
1694
1768
|
}
|
|
1695
|
-
#
|
|
1769
|
+
#M() {
|
|
1696
1770
|
if (this.#t) {
|
|
1697
1771
|
const e = this._columns.filter((n) => !n.hidden), t = this.#t.processColumns([...e]);
|
|
1698
1772
|
if (t !== e) {
|
|
1699
|
-
const n = new Map(t.map((
|
|
1700
|
-
if (
|
|
1701
|
-
const
|
|
1702
|
-
return
|
|
1773
|
+
const n = new Map(t.map((s, r) => [s.field, { col: s, order: r }])), i = this._columns.map((s) => {
|
|
1774
|
+
if (s.hidden) return s;
|
|
1775
|
+
const r = n.get(s.field);
|
|
1776
|
+
return r ? r.col : s;
|
|
1703
1777
|
});
|
|
1704
|
-
this._columns =
|
|
1778
|
+
this._columns = i;
|
|
1705
1779
|
}
|
|
1706
1780
|
}
|
|
1707
1781
|
}
|
|
1708
1782
|
/** Execute all plugin afterRender hooks */
|
|
1709
|
-
#
|
|
1783
|
+
#b() {
|
|
1710
1784
|
this.#t?.afterRender();
|
|
1711
1785
|
}
|
|
1712
1786
|
/** Recompute row model via plugin hooks (grouping, tree, filtering, etc.). */
|
|
1713
|
-
#
|
|
1787
|
+
#L() {
|
|
1714
1788
|
j(this);
|
|
1715
|
-
const e = Array.isArray(this.#
|
|
1789
|
+
const e = Array.isArray(this.#r) ? [...this.#r] : [], t = this.#t?.processRows(e) ?? e;
|
|
1716
1790
|
this._rows = t;
|
|
1717
1791
|
}
|
|
1718
1792
|
/**
|
|
@@ -1733,75 +1807,75 @@ class q extends HTMLElement {
|
|
|
1733
1807
|
* - `_columns` is NOT set here (done by #getColumnConfiguration + #processColumns)
|
|
1734
1808
|
* - Plugins receive config via their attach() method
|
|
1735
1809
|
*/
|
|
1736
|
-
#
|
|
1810
|
+
#u() {
|
|
1737
1811
|
const e = this.#g ? { ...this.#g } : {};
|
|
1738
1812
|
let t = Array.isArray(e.columns) ? [...e.columns] : [];
|
|
1739
|
-
const n = (this.__lightDomColumnsCache || []).map((
|
|
1740
|
-
...
|
|
1813
|
+
const n = (this.__lightDomColumnsCache || []).map((i) => ({
|
|
1814
|
+
...i
|
|
1741
1815
|
}));
|
|
1742
1816
|
if (n.length) {
|
|
1743
|
-
const
|
|
1744
|
-
t.forEach((
|
|
1745
|
-
const
|
|
1746
|
-
|
|
1817
|
+
const i = {};
|
|
1818
|
+
t.forEach((s) => i[s.field] = s), n.forEach((s) => {
|
|
1819
|
+
const r = i[s.field];
|
|
1820
|
+
r ? (s.header && !r.header && (r.header = s.header), s.type && !r.type && (r.type = s.type), r.sortable = r.sortable || s.sortable, s.resizable && (r.resizable = !0), s.editable && (r.editable = !0)) : (t.push(s), i[s.field] = s);
|
|
1747
1821
|
});
|
|
1748
1822
|
}
|
|
1749
|
-
if (this.#
|
|
1750
|
-
t.forEach((
|
|
1751
|
-
|
|
1823
|
+
if (this.#l && this.#l.length && (t = [...this.#l]), (!t || t.length === 0) && this._rows.length && (t = de(this._rows).columns), t.length) {
|
|
1824
|
+
t.forEach((r) => {
|
|
1825
|
+
r.sortable === void 0 && (r.sortable = !0), r.resizable === void 0 && (r.resizable = !0);
|
|
1752
1826
|
});
|
|
1753
|
-
const
|
|
1754
|
-
|
|
1827
|
+
const i = this.#n.columns;
|
|
1828
|
+
i?.some((r) => r.__compiledView || r.__compiledEditor) ? e.columns = i : e.columns = t;
|
|
1755
1829
|
} else {
|
|
1756
|
-
const
|
|
1757
|
-
|
|
1830
|
+
const i = this.#n.columns;
|
|
1831
|
+
i?.some((s) => s.__compiledView || s.__compiledEditor) && (e.columns = i);
|
|
1758
1832
|
}
|
|
1759
|
-
this.#
|
|
1760
|
-
|
|
1833
|
+
this.#v && (e.fitMode = this.#v), e.fitMode || (e.fitMode = "stretch"), this.#C && (e.editOn = this.#C), e.columnState && !this.#h && (this.#h = e.columnState), this.#n = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
|
|
1834
|
+
i.width == null && (i.width = 80);
|
|
1761
1835
|
});
|
|
1762
1836
|
}
|
|
1763
1837
|
// ---------------- Delegate Wrappers ----------------
|
|
1764
|
-
#
|
|
1765
|
-
this.#k || (this.#k = (
|
|
1838
|
+
#H(e, t, n = this.__rowRenderEpoch) {
|
|
1839
|
+
this.#k || (this.#k = (i, s, r) => this.#t?.renderRow(i, s, r) ?? !1), qe(this, e, t, n, this.#k);
|
|
1766
1840
|
}
|
|
1767
1841
|
#te(e, t) {
|
|
1768
1842
|
T(this, e, t);
|
|
1769
1843
|
}
|
|
1770
|
-
#
|
|
1771
|
-
|
|
1844
|
+
#O(e, t) {
|
|
1845
|
+
Be(this, e, t);
|
|
1772
1846
|
}
|
|
1773
1847
|
// ---------------- Core Helpers ----------------
|
|
1774
|
-
#
|
|
1848
|
+
#d() {
|
|
1775
1849
|
if (!this.isConnected || !this.headerRowEl || !this.bodyEl)
|
|
1776
1850
|
return;
|
|
1777
|
-
const e = this.#g?.columns || this.#
|
|
1851
|
+
const e = this.#g?.columns || this.#l || [];
|
|
1778
1852
|
if (e.length) {
|
|
1779
|
-
const n = new Map(this._columns.filter((
|
|
1780
|
-
...
|
|
1781
|
-
hidden: n.get(
|
|
1853
|
+
const n = new Map(this._columns.filter((s) => s.hidden).map((s) => [s.field, !0])), i = e.map((s) => ({
|
|
1854
|
+
...s,
|
|
1855
|
+
hidden: n.get(s.field) ?? s.hidden
|
|
1782
1856
|
}));
|
|
1783
|
-
this._columns =
|
|
1857
|
+
this._columns = i;
|
|
1784
1858
|
}
|
|
1785
|
-
if (this.#ee(), this.#
|
|
1786
|
-
const n = this.#
|
|
1787
|
-
this.#
|
|
1859
|
+
if (this.#ee(), this.#u(), this.#B(), this.#L(), this.#M(), this.#h) {
|
|
1860
|
+
const n = this.#h;
|
|
1861
|
+
this.#h = void 0, this.#W(n);
|
|
1788
1862
|
}
|
|
1789
|
-
this.#
|
|
1863
|
+
this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#n.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#K()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#b());
|
|
1790
1864
|
}
|
|
1791
1865
|
/** Internal method to apply column state without triggering setup loop */
|
|
1792
1866
|
#W(e) {
|
|
1793
|
-
const t = this.#
|
|
1794
|
-
|
|
1795
|
-
for (const
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1867
|
+
const t = this.#n.columns ?? [], n = this.#t?.getAll() ?? [];
|
|
1868
|
+
me(this, e, t, n);
|
|
1869
|
+
for (const i of e.columns) {
|
|
1870
|
+
const s = t.find((r) => r.field === i.field);
|
|
1871
|
+
s && (s.hidden = !i.visible);
|
|
1798
1872
|
}
|
|
1799
1873
|
}
|
|
1800
1874
|
#oe() {
|
|
1801
1875
|
return this._rows.length <= this.virtualization.bypassThreshold;
|
|
1802
1876
|
}
|
|
1803
1877
|
#ne(e) {
|
|
1804
|
-
if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#
|
|
1878
|
+
if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#y) {
|
|
1805
1879
|
const t = this.virtualization.container, n = {
|
|
1806
1880
|
scrollTop: e,
|
|
1807
1881
|
scrollLeft: t?.scrollLeft ?? 0,
|
|
@@ -1815,7 +1889,7 @@ class q extends HTMLElement {
|
|
|
1815
1889
|
}
|
|
1816
1890
|
}
|
|
1817
1891
|
findHeaderRow() {
|
|
1818
|
-
return this.#
|
|
1892
|
+
return this.#o.querySelector(".header-row");
|
|
1819
1893
|
}
|
|
1820
1894
|
findRenderedRowElement(e) {
|
|
1821
1895
|
return Array.from(this.bodyEl.querySelectorAll(".data-grid-row")).find((t) => {
|
|
@@ -1827,35 +1901,35 @@ class q extends HTMLElement {
|
|
|
1827
1901
|
* Dispatch a cell click event to the plugin system.
|
|
1828
1902
|
* Returns true if any plugin handled the event.
|
|
1829
1903
|
*/
|
|
1830
|
-
dispatchCellClick(e, t, n,
|
|
1831
|
-
const
|
|
1832
|
-
if (!
|
|
1833
|
-
const
|
|
1834
|
-
row:
|
|
1904
|
+
dispatchCellClick(e, t, n, i) {
|
|
1905
|
+
const s = this._rows[t], r = this._columns[n];
|
|
1906
|
+
if (!s || !r) return !1;
|
|
1907
|
+
const a = {
|
|
1908
|
+
row: s,
|
|
1835
1909
|
rowIndex: t,
|
|
1836
1910
|
colIndex: n,
|
|
1837
|
-
field:
|
|
1838
|
-
value:
|
|
1839
|
-
cellEl:
|
|
1911
|
+
field: r.field,
|
|
1912
|
+
value: s[r.field],
|
|
1913
|
+
cellEl: i,
|
|
1840
1914
|
originalEvent: e
|
|
1841
1915
|
};
|
|
1842
|
-
return this.#t?.onCellClick(
|
|
1916
|
+
return this.#t?.onCellClick(a) ?? !1;
|
|
1843
1917
|
}
|
|
1844
1918
|
/**
|
|
1845
1919
|
* Dispatch a header click event to the plugin system.
|
|
1846
1920
|
* Returns true if any plugin handled the event.
|
|
1847
1921
|
*/
|
|
1848
1922
|
dispatchHeaderClick(e, t, n) {
|
|
1849
|
-
const
|
|
1850
|
-
if (!
|
|
1851
|
-
const
|
|
1923
|
+
const i = this._columns[t];
|
|
1924
|
+
if (!i) return !1;
|
|
1925
|
+
const s = {
|
|
1852
1926
|
colIndex: t,
|
|
1853
|
-
field:
|
|
1854
|
-
column:
|
|
1927
|
+
field: i.field,
|
|
1928
|
+
column: i,
|
|
1855
1929
|
headerEl: n,
|
|
1856
1930
|
originalEvent: e
|
|
1857
1931
|
};
|
|
1858
|
-
return this.#t?.onHeaderClick(
|
|
1932
|
+
return this.#t?.onHeaderClick(s) ?? !1;
|
|
1859
1933
|
}
|
|
1860
1934
|
/**
|
|
1861
1935
|
* Dispatch a keyboard event to the plugin system.
|
|
@@ -1868,52 +1942,52 @@ class q extends HTMLElement {
|
|
|
1868
1942
|
* Build a CellMouseEvent from a native MouseEvent.
|
|
1869
1943
|
* Extracts cell/row information from the event target.
|
|
1870
1944
|
*/
|
|
1871
|
-
#
|
|
1945
|
+
#D(e, t) {
|
|
1872
1946
|
let n = null;
|
|
1873
|
-
const
|
|
1874
|
-
if (
|
|
1875
|
-
const
|
|
1876
|
-
|
|
1877
|
-
}
|
|
1878
|
-
const
|
|
1879
|
-
let
|
|
1880
|
-
return
|
|
1947
|
+
const i = e.composedPath?.();
|
|
1948
|
+
if (i && i.length > 0 ? n = i[0] : n = e.target, n && !this.#o.contains(n)) {
|
|
1949
|
+
const u = this.#o.elementFromPoint(e.clientX, e.clientY);
|
|
1950
|
+
u && (n = u);
|
|
1951
|
+
}
|
|
1952
|
+
const s = n?.closest?.("[data-col]"), r = n?.closest?.(".data-grid-row"), a = n?.closest?.(".header-row");
|
|
1953
|
+
let l, f, p, g, h, c;
|
|
1954
|
+
return s && (l = parseInt(s.getAttribute("data-row") ?? "-1", 10), f = parseInt(s.getAttribute("data-col") ?? "-1", 10), l >= 0 && f >= 0 && (p = this._rows[l], c = this._columns[f], g = c?.field, h = p && g ? p[g] : void 0)), {
|
|
1881
1955
|
type: t,
|
|
1882
1956
|
row: p,
|
|
1883
|
-
rowIndex:
|
|
1957
|
+
rowIndex: l !== void 0 && l >= 0 ? l : void 0,
|
|
1884
1958
|
colIndex: f !== void 0 && f >= 0 ? f : void 0,
|
|
1885
|
-
field:
|
|
1959
|
+
field: g,
|
|
1886
1960
|
value: h,
|
|
1887
1961
|
column: c,
|
|
1888
1962
|
originalEvent: e,
|
|
1889
|
-
cellElement:
|
|
1890
|
-
rowElement:
|
|
1891
|
-
isHeader: !!
|
|
1892
|
-
cell:
|
|
1963
|
+
cellElement: s ?? void 0,
|
|
1964
|
+
rowElement: r ?? void 0,
|
|
1965
|
+
isHeader: !!a,
|
|
1966
|
+
cell: l !== void 0 && f !== void 0 && l >= 0 && f >= 0 ? { row: l, col: f } : void 0
|
|
1893
1967
|
};
|
|
1894
1968
|
}
|
|
1895
1969
|
/**
|
|
1896
1970
|
* Handle mousedown events and dispatch to plugin system.
|
|
1897
1971
|
*/
|
|
1898
1972
|
#ie(e) {
|
|
1899
|
-
const t = this.#
|
|
1900
|
-
(this.#t?.onCellMouseDown(t) ?? !1) && (this.#
|
|
1973
|
+
const t = this.#D(e, "mousedown");
|
|
1974
|
+
(this.#t?.onCellMouseDown(t) ?? !1) && (this.#R = !0);
|
|
1901
1975
|
}
|
|
1902
1976
|
/**
|
|
1903
1977
|
* Handle mousemove events (only when dragging).
|
|
1904
1978
|
*/
|
|
1905
1979
|
#se(e) {
|
|
1906
|
-
if (!this.#
|
|
1907
|
-
const t = this.#
|
|
1980
|
+
if (!this.#R) return;
|
|
1981
|
+
const t = this.#D(e, "mousemove");
|
|
1908
1982
|
this.#t?.onCellMouseMove(t);
|
|
1909
1983
|
}
|
|
1910
1984
|
/**
|
|
1911
1985
|
* Handle mouseup events.
|
|
1912
1986
|
*/
|
|
1913
|
-
#
|
|
1914
|
-
if (!this.#
|
|
1915
|
-
const t = this.#
|
|
1916
|
-
this.#t?.onCellMouseUp(t), this.#
|
|
1987
|
+
#re(e) {
|
|
1988
|
+
if (!this.#R) return;
|
|
1989
|
+
const t = this.#D(e, "mouseup");
|
|
1990
|
+
this.#t?.onCellMouseUp(t), this.#R = !1;
|
|
1917
1991
|
}
|
|
1918
1992
|
// API consumed by internal utils (rows.ts)
|
|
1919
1993
|
get changedRows() {
|
|
@@ -1929,17 +2003,17 @@ class q extends HTMLElement {
|
|
|
1929
2003
|
this.#te(e, this._rows[e]);
|
|
1930
2004
|
}
|
|
1931
2005
|
async commitActiveRowEdit() {
|
|
1932
|
-
this.activeEditRows !== -1 && this.#
|
|
2006
|
+
this.activeEditRows !== -1 && this.#O(this.activeEditRows, !1);
|
|
1933
2007
|
}
|
|
1934
2008
|
async ready() {
|
|
1935
2009
|
return this.#z;
|
|
1936
2010
|
}
|
|
1937
2011
|
async forceLayout() {
|
|
1938
|
-
this.#
|
|
2012
|
+
this.#d(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
|
|
1939
2013
|
}
|
|
1940
2014
|
/** Public method: returns a frozen snapshot of the merged effective configuration */
|
|
1941
2015
|
async getConfig() {
|
|
1942
|
-
return Object.freeze({ ...this.#
|
|
2016
|
+
return Object.freeze({ ...this.#n || {} });
|
|
1943
2017
|
}
|
|
1944
2018
|
// ---------------- Column Visibility API ----------------
|
|
1945
2019
|
/**
|
|
@@ -1949,15 +2023,15 @@ class q extends HTMLElement {
|
|
|
1949
2023
|
* @returns True if visibility was changed, false if column not found or locked
|
|
1950
2024
|
*/
|
|
1951
2025
|
setColumnVisible(e, t) {
|
|
1952
|
-
const n = this.#
|
|
1953
|
-
if (!
|
|
2026
|
+
const n = this.#n.columns, i = n?.find((a) => a.field === e);
|
|
2027
|
+
if (!i || !t && i.lockVisible || !t && (n ?? []).filter((l) => !l.hidden && l.field !== e).length === 0)
|
|
1954
2028
|
return !1;
|
|
1955
|
-
const
|
|
1956
|
-
return
|
|
2029
|
+
const s = !!i.hidden, r = !t;
|
|
2030
|
+
return s !== r ? (i.hidden = r, this.#s("column-visibility", {
|
|
1957
2031
|
field: e,
|
|
1958
2032
|
visible: t,
|
|
1959
|
-
visibleColumns: (n ?? []).filter((
|
|
1960
|
-
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#
|
|
2033
|
+
visibleColumns: (n ?? []).filter((a) => !a.hidden).map((a) => a.field)
|
|
2034
|
+
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#d(), this.requestStateChange(), !0) : !1;
|
|
1961
2035
|
}
|
|
1962
2036
|
/**
|
|
1963
2037
|
* Toggle the visibility of a column.
|
|
@@ -1965,8 +2039,8 @@ class q extends HTMLElement {
|
|
|
1965
2039
|
* @returns True if visibility was toggled, false if column not found or locked
|
|
1966
2040
|
*/
|
|
1967
2041
|
toggleColumnVisibility(e) {
|
|
1968
|
-
const
|
|
1969
|
-
return this.setColumnVisible(e,
|
|
2042
|
+
const i = !!this.#n.columns?.find((s) => s.field === e)?.hidden;
|
|
2043
|
+
return this.setColumnVisible(e, i);
|
|
1970
2044
|
}
|
|
1971
2045
|
/**
|
|
1972
2046
|
* Check if a column is currently visible.
|
|
@@ -1974,19 +2048,19 @@ class q extends HTMLElement {
|
|
|
1974
2048
|
* @returns True if visible, false if hidden or not found
|
|
1975
2049
|
*/
|
|
1976
2050
|
isColumnVisible(e) {
|
|
1977
|
-
const n = this.#
|
|
2051
|
+
const n = this.#n.columns?.find((i) => i.field === e);
|
|
1978
2052
|
return n ? !n.hidden : !1;
|
|
1979
2053
|
}
|
|
1980
2054
|
/**
|
|
1981
2055
|
* Show all columns.
|
|
1982
2056
|
*/
|
|
1983
2057
|
showAllColumns() {
|
|
1984
|
-
const e = this.#
|
|
2058
|
+
const e = this.#n.columns;
|
|
1985
2059
|
e?.some((n) => n.hidden) && (e?.forEach((n) => {
|
|
1986
2060
|
n.hidden = !1;
|
|
1987
2061
|
}), this.#s("column-visibility", {
|
|
1988
2062
|
visibleColumns: (e ?? []).map((n) => n.field)
|
|
1989
|
-
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#
|
|
2063
|
+
}), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#d(), this.requestStateChange());
|
|
1990
2064
|
}
|
|
1991
2065
|
/**
|
|
1992
2066
|
* Get list of all column fields (including hidden).
|
|
@@ -1995,7 +2069,7 @@ class q extends HTMLElement {
|
|
|
1995
2069
|
* @returns Array of all field names with their visibility status
|
|
1996
2070
|
*/
|
|
1997
2071
|
getAllColumns() {
|
|
1998
|
-
return (this.#
|
|
2072
|
+
return (this.#n.columns ?? []).map((t) => ({
|
|
1999
2073
|
field: t.field,
|
|
2000
2074
|
header: t.header || t.field,
|
|
2001
2075
|
visible: !t.hidden,
|
|
@@ -2009,14 +2083,14 @@ class q extends HTMLElement {
|
|
|
2009
2083
|
*/
|
|
2010
2084
|
setColumnOrder(e) {
|
|
2011
2085
|
if (!e.length) return;
|
|
2012
|
-
const t = new Map(this._columns.map((
|
|
2013
|
-
for (const
|
|
2014
|
-
const
|
|
2015
|
-
|
|
2086
|
+
const t = new Map(this._columns.map((i) => [i.field, i])), n = [];
|
|
2087
|
+
for (const i of e) {
|
|
2088
|
+
const s = t.get(i);
|
|
2089
|
+
s && (n.push(s), t.delete(i));
|
|
2016
2090
|
}
|
|
2017
|
-
for (const
|
|
2018
|
-
n.push(
|
|
2019
|
-
this._columns = n, this.#
|
|
2091
|
+
for (const i of t.values())
|
|
2092
|
+
n.push(i);
|
|
2093
|
+
this._columns = n, this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0);
|
|
2020
2094
|
}
|
|
2021
2095
|
/**
|
|
2022
2096
|
* Get the current column order as an array of field names.
|
|
@@ -2039,7 +2113,7 @@ class q extends HTMLElement {
|
|
|
2039
2113
|
* Use this to restore previously saved column state.
|
|
2040
2114
|
*/
|
|
2041
2115
|
set columnState(e) {
|
|
2042
|
-
e && (this.#
|
|
2116
|
+
e && (this.#h = e, this.#i && this.#le(e));
|
|
2043
2117
|
}
|
|
2044
2118
|
/**
|
|
2045
2119
|
* Get the current column state.
|
|
@@ -2050,10 +2124,10 @@ class q extends HTMLElement {
|
|
|
2050
2124
|
/**
|
|
2051
2125
|
* Apply column state internally.
|
|
2052
2126
|
*/
|
|
2053
|
-
#
|
|
2054
|
-
(this.#
|
|
2127
|
+
#le(e) {
|
|
2128
|
+
(this.#n.columns ?? []).forEach((n) => {
|
|
2055
2129
|
n.hidden = !1;
|
|
2056
|
-
}), this.#W(e), this.#
|
|
2130
|
+
}), this.#W(e), this.#d();
|
|
2057
2131
|
}
|
|
2058
2132
|
/**
|
|
2059
2133
|
* Request a state change event to be emitted.
|
|
@@ -2062,7 +2136,7 @@ class q extends HTMLElement {
|
|
|
2062
2136
|
* The event is debounced to avoid excessive events during drag operations.
|
|
2063
2137
|
*/
|
|
2064
2138
|
requestStateChange() {
|
|
2065
|
-
this.#P || (this.#P =
|
|
2139
|
+
this.#P || (this.#P = ve(
|
|
2066
2140
|
this,
|
|
2067
2141
|
() => this.#t?.getAll() ?? [],
|
|
2068
2142
|
(e) => this.#s("column-state-change", e)
|
|
@@ -2073,15 +2147,15 @@ class q extends HTMLElement {
|
|
|
2073
2147
|
* Clears all user modifications (order, width, visibility, sort).
|
|
2074
2148
|
*/
|
|
2075
2149
|
resetColumnState() {
|
|
2076
|
-
this.#
|
|
2150
|
+
this.#h = void 0, (this.#n.columns ?? []).forEach((n) => {
|
|
2077
2151
|
n.hidden = !1;
|
|
2078
|
-
}), this.sortState = null, this.__originalOrder = [], this.#
|
|
2152
|
+
}), this.sortState = null, this.__originalOrder = [], this.#u(), this.#d();
|
|
2079
2153
|
const t = this.#t?.getAll() ?? [];
|
|
2080
2154
|
for (const n of t)
|
|
2081
2155
|
if (n.applyColumnState)
|
|
2082
|
-
for (const
|
|
2083
|
-
n.applyColumnState(
|
|
2084
|
-
field:
|
|
2156
|
+
for (const i of this._columns)
|
|
2157
|
+
n.applyColumnState(i.field, {
|
|
2158
|
+
field: i.field,
|
|
2085
2159
|
order: 0,
|
|
2086
2160
|
visible: !0
|
|
2087
2161
|
});
|
|
@@ -2103,7 +2177,7 @@ class q extends HTMLElement {
|
|
|
2103
2177
|
console.warn(`[tbw-grid] Tool panel "${e}" not found`);
|
|
2104
2178
|
return;
|
|
2105
2179
|
}
|
|
2106
|
-
this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#
|
|
2180
|
+
this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#o, this.#e), ne(this.#o, this.#e), je(this.#o, this.#e), this.#s("tool-panel-open", { id: e });
|
|
2107
2181
|
}
|
|
2108
2182
|
/**
|
|
2109
2183
|
* Close the currently open tool panel.
|
|
@@ -2111,7 +2185,7 @@ class q extends HTMLElement {
|
|
|
2111
2185
|
closeToolPanel() {
|
|
2112
2186
|
if (!this.#e.activePanel) return;
|
|
2113
2187
|
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.#
|
|
2188
|
+
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
2189
|
}
|
|
2116
2190
|
/**
|
|
2117
2191
|
* Toggle a tool panel open/closed.
|
|
@@ -2133,13 +2207,13 @@ class q extends HTMLElement {
|
|
|
2133
2207
|
console.warn(`[tbw-grid] Tool panel "${e.id}" already registered`);
|
|
2134
2208
|
return;
|
|
2135
2209
|
}
|
|
2136
|
-
this.#e.toolPanels.set(e.id, e), this.#
|
|
2210
|
+
this.#e.toolPanels.set(e.id, e), this.#c && this.#m();
|
|
2137
2211
|
}
|
|
2138
2212
|
/**
|
|
2139
2213
|
* Unregister a custom tool panel.
|
|
2140
2214
|
*/
|
|
2141
2215
|
unregisterToolPanel(e) {
|
|
2142
|
-
this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#
|
|
2216
|
+
this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#c && this.#m();
|
|
2143
2217
|
}
|
|
2144
2218
|
/**
|
|
2145
2219
|
* Get registered header content definitions.
|
|
@@ -2155,20 +2229,20 @@ class q extends HTMLElement {
|
|
|
2155
2229
|
console.warn(`[tbw-grid] Header content "${e.id}" already registered`);
|
|
2156
2230
|
return;
|
|
2157
2231
|
}
|
|
2158
|
-
this.#e.headerContents.set(e.id, e), this.#
|
|
2232
|
+
this.#e.headerContents.set(e.id, e), this.#c && te(this.#o, this.#e);
|
|
2159
2233
|
}
|
|
2160
2234
|
/**
|
|
2161
2235
|
* Unregister custom header content.
|
|
2162
2236
|
*/
|
|
2163
2237
|
unregisterHeaderContent(e) {
|
|
2164
2238
|
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.#
|
|
2239
|
+
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
2240
|
}
|
|
2167
2241
|
/**
|
|
2168
2242
|
* Get all registered toolbar buttons.
|
|
2169
2243
|
*/
|
|
2170
2244
|
getToolbarButtons() {
|
|
2171
|
-
return
|
|
2245
|
+
return Ye(this.#n?.shell, this.#e);
|
|
2172
2246
|
}
|
|
2173
2247
|
/**
|
|
2174
2248
|
* Register a custom toolbar button programmatically.
|
|
@@ -2178,14 +2252,14 @@ class q extends HTMLElement {
|
|
|
2178
2252
|
console.warn(`[tbw-grid] Toolbar button "${e.id}" already registered`);
|
|
2179
2253
|
return;
|
|
2180
2254
|
}
|
|
2181
|
-
this.#e.toolbarButtons.set(e.id, e), this.#
|
|
2255
|
+
this.#e.toolbarButtons.set(e.id, e), this.#c && this.#m();
|
|
2182
2256
|
}
|
|
2183
2257
|
/**
|
|
2184
2258
|
* Unregister a custom toolbar button.
|
|
2185
2259
|
*/
|
|
2186
2260
|
unregisterToolbarButton(e) {
|
|
2187
2261
|
const t = this.#e.toolbarButtonCleanups.get(e);
|
|
2188
|
-
t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#
|
|
2262
|
+
t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#c && this.#m();
|
|
2189
2263
|
}
|
|
2190
2264
|
/**
|
|
2191
2265
|
* Enable/disable a toolbar button by ID.
|
|
@@ -2193,20 +2267,20 @@ class q extends HTMLElement {
|
|
|
2193
2267
|
setToolbarButtonDisabled(e, t) {
|
|
2194
2268
|
const n = this.#e.toolbarButtons.get(e);
|
|
2195
2269
|
n && (n.disabled = t);
|
|
2196
|
-
const
|
|
2197
|
-
|
|
2270
|
+
const i = this.#o.querySelector(`[data-btn="${e}"]`);
|
|
2271
|
+
i && (i.disabled = t);
|
|
2198
2272
|
}
|
|
2199
2273
|
/**
|
|
2200
2274
|
* Re-parse light DOM shell elements and refresh shell header.
|
|
2201
2275
|
* Call this after dynamically modifying <tbw-grid-header> children.
|
|
2202
2276
|
*/
|
|
2203
2277
|
refreshShellHeader() {
|
|
2204
|
-
this.#
|
|
2278
|
+
this.#m();
|
|
2205
2279
|
}
|
|
2206
2280
|
/**
|
|
2207
2281
|
* Internal shell header refresh.
|
|
2208
2282
|
*/
|
|
2209
|
-
#
|
|
2283
|
+
#m() {
|
|
2210
2284
|
ee(this, this.#e), this.#F(), this.#$();
|
|
2211
2285
|
}
|
|
2212
2286
|
// ---------------- Virtual Window ----------------
|
|
@@ -2218,26 +2292,36 @@ class q extends HTMLElement {
|
|
|
2218
2292
|
if (!this.bodyEl) return;
|
|
2219
2293
|
const t = this._rows.length;
|
|
2220
2294
|
if (!this.virtualization.enabled) {
|
|
2221
|
-
this.#
|
|
2295
|
+
this.#H(0, t), this.#b();
|
|
2222
2296
|
return;
|
|
2223
2297
|
}
|
|
2224
2298
|
if (this.#oe()) {
|
|
2225
|
-
this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#
|
|
2299
|
+
this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#H(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.#b();
|
|
2226
2300
|
return;
|
|
2227
2301
|
}
|
|
2228
|
-
const n = this.virtualization.container ?? this,
|
|
2229
|
-
let
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2302
|
+
const n = this.virtualization.container ?? this, s = (this.virtualization.viewportEl ?? n).clientHeight, r = this.virtualization.rowHeight, a = n.scrollTop;
|
|
2303
|
+
let l = Math.floor(a / r), f = 0;
|
|
2304
|
+
const p = 10;
|
|
2305
|
+
for (; f < p; ) {
|
|
2306
|
+
const R = this.#t?.getExtraHeightBefore?.(l) ?? 0, E = Math.floor((a - R) / r);
|
|
2307
|
+
if (E >= l || E < 0) break;
|
|
2308
|
+
l = E, f++;
|
|
2309
|
+
}
|
|
2310
|
+
l = l - l % 2, l < 0 && (l = 0);
|
|
2311
|
+
const g = this.#t?.adjustVirtualStart(l, a, r);
|
|
2312
|
+
g !== void 0 && g < l && (l = g, l = l - l % 2, l < 0 && (l = 0));
|
|
2313
|
+
const h = Math.ceil(s / r) + 3;
|
|
2314
|
+
let c = l + h;
|
|
2315
|
+
c > t && (c = t), this.virtualization.start = l, this.virtualization.end = c;
|
|
2316
|
+
const d = this.#o.querySelector(".tbw-footer")?.offsetHeight ?? 0, b = this.#t?.getExtraHeight() ?? 0;
|
|
2317
|
+
this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * r + r + d + b}px`);
|
|
2318
|
+
const m = this.#t?.getExtraHeightBefore?.(l) ?? 0, C = -(a - l * r - m);
|
|
2319
|
+
this.bodyEl.style.transform = `translateY(${C}px)`, this.#H(l, c, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#b();
|
|
2236
2320
|
}
|
|
2237
2321
|
// ---------------- Render ----------------
|
|
2238
2322
|
#F() {
|
|
2239
2323
|
ee(this, this.#e);
|
|
2240
|
-
const e = this.#
|
|
2324
|
+
const e = this.#n?.shell, t = Fe(e, this.#e), n = `
|
|
2241
2325
|
<div class="tbw-scroll-area">
|
|
2242
2326
|
<div class="rows-body-wrapper">
|
|
2243
2327
|
<div class="rows-body">
|
|
@@ -2257,15 +2341,15 @@ class q extends HTMLElement {
|
|
|
2257
2341
|
</div>
|
|
2258
2342
|
`;
|
|
2259
2343
|
if (t) {
|
|
2260
|
-
const
|
|
2261
|
-
this.#
|
|
2344
|
+
const i = Ve(e, this.#e), s = Ge(e, this.#e, n);
|
|
2345
|
+
this.#o.innerHTML = `
|
|
2262
2346
|
<div class="tbw-grid-root has-shell">
|
|
2263
|
-
${s}
|
|
2264
2347
|
${i}
|
|
2348
|
+
${s}
|
|
2265
2349
|
</div>
|
|
2266
|
-
`, this.#ae(), this.#
|
|
2350
|
+
`, this.#ae(), this.#c = !0;
|
|
2267
2351
|
} else
|
|
2268
|
-
this.#
|
|
2352
|
+
this.#o.innerHTML = `
|
|
2269
2353
|
<div class="tbw-grid-root">
|
|
2270
2354
|
<div class="tbw-grid-content">
|
|
2271
2355
|
${n}
|
|
@@ -2277,7 +2361,7 @@ class q extends HTMLElement {
|
|
|
2277
2361
|
* Set up shell event listeners after render.
|
|
2278
2362
|
*/
|
|
2279
2363
|
#ae() {
|
|
2280
|
-
|
|
2364
|
+
Ue(this.#o, this.#n?.shell, this.#e, {
|
|
2281
2365
|
onPanelToggle: (e) => this.toggleToolPanel(e),
|
|
2282
2366
|
onPanelClose: () => this.closeToolPanel(),
|
|
2283
2367
|
onToolbarButtonClick: (e) => this.#ce(e)
|
|
@@ -2287,17 +2371,17 @@ class q extends HTMLElement {
|
|
|
2287
2371
|
* Handle toolbar button click (for config buttons with action).
|
|
2288
2372
|
*/
|
|
2289
2373
|
#ce(e) {
|
|
2290
|
-
const n = (this.#
|
|
2374
|
+
const n = (this.#n?.shell?.header?.toolbarButtons ?? []).find((s) => s.id === e);
|
|
2291
2375
|
if (n?.action) {
|
|
2292
2376
|
n.action();
|
|
2293
2377
|
return;
|
|
2294
2378
|
}
|
|
2295
|
-
const
|
|
2296
|
-
|
|
2379
|
+
const i = this.#e.toolbarButtons.get(e);
|
|
2380
|
+
i?.action && i.action();
|
|
2297
2381
|
}
|
|
2298
2382
|
}
|
|
2299
|
-
customElements.get(
|
|
2300
|
-
class
|
|
2383
|
+
customElements.get(I.tagName) || customElements.define(I.tagName, I);
|
|
2384
|
+
class fe {
|
|
2301
2385
|
/** Plugin version - override in subclass if needed */
|
|
2302
2386
|
version = "1.0.0";
|
|
2303
2387
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
@@ -2396,6 +2480,55 @@ class ue {
|
|
|
2396
2480
|
get shadowRoot() {
|
|
2397
2481
|
return this.grid?.shadowRoot ?? null;
|
|
2398
2482
|
}
|
|
2483
|
+
/**
|
|
2484
|
+
* Get the disconnect signal for event listener cleanup.
|
|
2485
|
+
* This signal is aborted when the grid disconnects from the DOM.
|
|
2486
|
+
* Use this when adding event listeners that should be cleaned up automatically.
|
|
2487
|
+
*
|
|
2488
|
+
* Best for:
|
|
2489
|
+
* - Document/window-level listeners added in attach()
|
|
2490
|
+
* - Listeners on the grid element itself
|
|
2491
|
+
* - Any listener that should persist across renders
|
|
2492
|
+
*
|
|
2493
|
+
* Not needed for:
|
|
2494
|
+
* - Listeners on elements created in afterRender() (removed with element)
|
|
2495
|
+
*
|
|
2496
|
+
* @example
|
|
2497
|
+
* element.addEventListener('click', handler, { signal: this.disconnectSignal });
|
|
2498
|
+
* document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
|
|
2499
|
+
*/
|
|
2500
|
+
get disconnectSignal() {
|
|
2501
|
+
return this.grid?.disconnectSignal;
|
|
2502
|
+
}
|
|
2503
|
+
/**
|
|
2504
|
+
* Get the grid-level icons configuration.
|
|
2505
|
+
* Returns merged icons (user config + defaults).
|
|
2506
|
+
*/
|
|
2507
|
+
get gridIcons() {
|
|
2508
|
+
const e = this.grid?.gridConfig?.icons ?? {};
|
|
2509
|
+
return { ...ce, ...e };
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2512
|
+
* Resolve an icon value to string or HTMLElement.
|
|
2513
|
+
* Checks plugin config first, then grid-level icons, then defaults.
|
|
2514
|
+
*
|
|
2515
|
+
* @param iconKey - The icon key in GridIcons (e.g., 'expand', 'collapse')
|
|
2516
|
+
* @param pluginOverride - Optional plugin-level override
|
|
2517
|
+
* @returns The resolved icon value
|
|
2518
|
+
*/
|
|
2519
|
+
resolveIcon(e, t) {
|
|
2520
|
+
return t !== void 0 ? t : this.gridIcons[e];
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* Set an icon value on an element.
|
|
2524
|
+
* Handles both string (text/HTML) and HTMLElement values.
|
|
2525
|
+
*
|
|
2526
|
+
* @param element - The element to set the icon on
|
|
2527
|
+
* @param icon - The icon value (string or HTMLElement)
|
|
2528
|
+
*/
|
|
2529
|
+
setIcon(e, t) {
|
|
2530
|
+
typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.cloneNode(!0)));
|
|
2531
|
+
}
|
|
2399
2532
|
/**
|
|
2400
2533
|
* Log a warning message.
|
|
2401
2534
|
*/
|
|
@@ -2403,7 +2536,7 @@ class ue {
|
|
|
2403
2536
|
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
2404
2537
|
}
|
|
2405
2538
|
}
|
|
2406
|
-
function
|
|
2539
|
+
function N(o) {
|
|
2407
2540
|
return {
|
|
2408
2541
|
startRow: Math.min(o.startRow, o.endRow),
|
|
2409
2542
|
startCol: Math.min(o.startCol, o.endCol),
|
|
@@ -2411,34 +2544,34 @@ function z(o) {
|
|
|
2411
2544
|
endCol: Math.max(o.startCol, o.endCol)
|
|
2412
2545
|
};
|
|
2413
2546
|
}
|
|
2414
|
-
function
|
|
2415
|
-
const e =
|
|
2547
|
+
function Qe(o) {
|
|
2548
|
+
const e = N(o);
|
|
2416
2549
|
return {
|
|
2417
2550
|
from: { row: e.startRow, col: e.startCol },
|
|
2418
2551
|
to: { row: e.endRow, col: e.endCol }
|
|
2419
2552
|
};
|
|
2420
2553
|
}
|
|
2421
2554
|
function K(o) {
|
|
2422
|
-
return o.map(
|
|
2555
|
+
return o.map(Qe);
|
|
2423
2556
|
}
|
|
2424
|
-
function
|
|
2425
|
-
const n =
|
|
2557
|
+
function et(o, e, t) {
|
|
2558
|
+
const n = N(t);
|
|
2426
2559
|
return o >= n.startRow && o <= n.endRow && e >= n.startCol && e <= n.endCol;
|
|
2427
2560
|
}
|
|
2428
2561
|
function ie(o, e, t) {
|
|
2429
|
-
return t.some((n) =>
|
|
2562
|
+
return t.some((n) => et(o, e, n));
|
|
2430
2563
|
}
|
|
2431
|
-
function
|
|
2432
|
-
const e = [], t =
|
|
2564
|
+
function tt(o) {
|
|
2565
|
+
const e = [], t = N(o);
|
|
2433
2566
|
for (let n = t.startRow; n <= t.endRow; n++)
|
|
2434
|
-
for (let
|
|
2435
|
-
e.push({ row: n, col:
|
|
2567
|
+
for (let i = t.startCol; i <= t.endCol; i++)
|
|
2568
|
+
e.push({ row: n, col: i });
|
|
2436
2569
|
return e;
|
|
2437
2570
|
}
|
|
2438
|
-
function
|
|
2571
|
+
function ot(o) {
|
|
2439
2572
|
const e = /* @__PURE__ */ new Map();
|
|
2440
2573
|
for (const t of o)
|
|
2441
|
-
for (const n of
|
|
2574
|
+
for (const n of tt(t))
|
|
2442
2575
|
e.set(`${n.row},${n.col}`, n);
|
|
2443
2576
|
return [...e.values()];
|
|
2444
2577
|
}
|
|
@@ -2450,7 +2583,7 @@ function se(o, e) {
|
|
|
2450
2583
|
endCol: e.col
|
|
2451
2584
|
};
|
|
2452
2585
|
}
|
|
2453
|
-
function
|
|
2586
|
+
function nt(o, e, t) {
|
|
2454
2587
|
if (o === "cell" && e.selectedCell)
|
|
2455
2588
|
return {
|
|
2456
2589
|
mode: o,
|
|
@@ -2462,15 +2595,15 @@ function tt(o, e, t) {
|
|
|
2462
2595
|
]
|
|
2463
2596
|
};
|
|
2464
2597
|
if (o === "row" && e.selected.size > 0) {
|
|
2465
|
-
const n = [...e.selected].map((
|
|
2466
|
-
from: { row:
|
|
2467
|
-
to: { row:
|
|
2598
|
+
const n = [...e.selected].map((i) => ({
|
|
2599
|
+
from: { row: i, col: 0 },
|
|
2600
|
+
to: { row: i, col: t - 1 }
|
|
2468
2601
|
}));
|
|
2469
2602
|
return { mode: o, ranges: n };
|
|
2470
2603
|
}
|
|
2471
2604
|
return o === "range" && e.ranges.length > 0 ? { mode: o, ranges: K(e.ranges) } : { mode: o, ranges: [] };
|
|
2472
2605
|
}
|
|
2473
|
-
class
|
|
2606
|
+
class lt extends fe {
|
|
2474
2607
|
name = "selection";
|
|
2475
2608
|
version = "1.0.0";
|
|
2476
2609
|
get defaultConfig() {
|
|
@@ -2496,32 +2629,32 @@ class st extends ue {
|
|
|
2496
2629
|
}
|
|
2497
2630
|
// ===== Event Handlers =====
|
|
2498
2631
|
onCellClick(e) {
|
|
2499
|
-
const { rowIndex: t, colIndex: n, originalEvent:
|
|
2500
|
-
if (
|
|
2632
|
+
const { rowIndex: t, colIndex: n, originalEvent: i } = e, { mode: s } = this.config;
|
|
2633
|
+
if (s === "cell")
|
|
2501
2634
|
return this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2502
|
-
if (
|
|
2635
|
+
if (s === "row")
|
|
2503
2636
|
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2504
|
-
if (
|
|
2505
|
-
const
|
|
2506
|
-
if (
|
|
2507
|
-
const
|
|
2508
|
-
|
|
2509
|
-
} else if (
|
|
2510
|
-
const
|
|
2637
|
+
if (s === "range") {
|
|
2638
|
+
const r = i.shiftKey, a = i.ctrlKey || i.metaKey;
|
|
2639
|
+
if (r && this.cellAnchor) {
|
|
2640
|
+
const l = se(this.cellAnchor, { row: t, col: n });
|
|
2641
|
+
a ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l) : this.ranges = [l], this.activeRange = l;
|
|
2642
|
+
} else if (a) {
|
|
2643
|
+
const l = {
|
|
2511
2644
|
startRow: t,
|
|
2512
2645
|
startCol: n,
|
|
2513
2646
|
endRow: t,
|
|
2514
2647
|
endCol: n
|
|
2515
2648
|
};
|
|
2516
|
-
this.ranges.push(
|
|
2649
|
+
this.ranges.push(l), this.activeRange = l, this.cellAnchor = { row: t, col: n };
|
|
2517
2650
|
} else {
|
|
2518
|
-
const
|
|
2651
|
+
const l = {
|
|
2519
2652
|
startRow: t,
|
|
2520
2653
|
startCol: n,
|
|
2521
2654
|
endRow: t,
|
|
2522
2655
|
endCol: n
|
|
2523
2656
|
};
|
|
2524
|
-
this.ranges = [
|
|
2657
|
+
this.ranges = [l], this.activeRange = l, this.cellAnchor = { row: t, col: n };
|
|
2525
2658
|
}
|
|
2526
2659
|
return this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
|
|
2527
2660
|
}
|
|
@@ -2532,15 +2665,15 @@ class st extends ue {
|
|
|
2532
2665
|
if (e.key === "Escape")
|
|
2533
2666
|
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
2667
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
2535
|
-
const n = this.rows.length,
|
|
2536
|
-
if (n > 0 &&
|
|
2537
|
-
const
|
|
2668
|
+
const n = this.rows.length, i = this.columns.length;
|
|
2669
|
+
if (n > 0 && i > 0) {
|
|
2670
|
+
const s = {
|
|
2538
2671
|
startRow: 0,
|
|
2539
2672
|
startCol: 0,
|
|
2540
2673
|
endRow: n - 1,
|
|
2541
|
-
endCol:
|
|
2674
|
+
endCol: i - 1
|
|
2542
2675
|
};
|
|
2543
|
-
return this.ranges = [
|
|
2676
|
+
return this.ranges = [s], this.activeRange = s, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2544
2677
|
}
|
|
2545
2678
|
}
|
|
2546
2679
|
return !1;
|
|
@@ -2551,13 +2684,13 @@ class st extends ue {
|
|
|
2551
2684
|
this.isDragging = !0;
|
|
2552
2685
|
const t = e.rowIndex, n = e.colIndex;
|
|
2553
2686
|
this.cellAnchor = { row: t, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
2554
|
-
const
|
|
2687
|
+
const s = {
|
|
2555
2688
|
startRow: t,
|
|
2556
2689
|
startCol: n,
|
|
2557
2690
|
endRow: t,
|
|
2558
2691
|
endCol: n
|
|
2559
2692
|
};
|
|
2560
|
-
return this.ranges.push(
|
|
2693
|
+
return this.ranges.push(s), this.activeRange = s, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0;
|
|
2561
2694
|
}
|
|
2562
2695
|
onCellMouseMove(e) {
|
|
2563
2696
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
@@ -2572,40 +2705,40 @@ class st extends ue {
|
|
|
2572
2705
|
* Apply selection classes to visible cells/rows.
|
|
2573
2706
|
* Shared by afterRender and onScrollRender.
|
|
2574
2707
|
*/
|
|
2575
|
-
#
|
|
2708
|
+
#o() {
|
|
2576
2709
|
const e = this.shadowRoot;
|
|
2577
2710
|
if (!e) return;
|
|
2578
2711
|
const { mode: t } = this.config;
|
|
2579
|
-
e.querySelectorAll(".cell").forEach((
|
|
2580
|
-
|
|
2712
|
+
e.querySelectorAll(".cell").forEach((s) => {
|
|
2713
|
+
s.classList.remove("selected", "top", "bottom", "first", "last");
|
|
2581
2714
|
});
|
|
2582
|
-
const
|
|
2583
|
-
if (
|
|
2584
|
-
|
|
2585
|
-
}), t === "row" &&
|
|
2586
|
-
const
|
|
2587
|
-
|
|
2715
|
+
const i = e.querySelectorAll(".data-grid-row");
|
|
2716
|
+
if (i.forEach((s) => {
|
|
2717
|
+
s.classList.remove("selected", "row-focus");
|
|
2718
|
+
}), t === "row" && i.forEach((s) => {
|
|
2719
|
+
const r = s.querySelector(".cell[data-row]"), a = parseInt(r?.getAttribute("data-row") ?? "-1", 10);
|
|
2720
|
+
a >= 0 && this.selected.has(a) && (s.classList.add("selected", "row-focus"), s.querySelectorAll(".cell-focus").forEach((l) => l.classList.remove("cell-focus")));
|
|
2588
2721
|
}), t === "range" && this.ranges.length > 0) {
|
|
2589
|
-
const
|
|
2590
|
-
e.querySelectorAll(".cell[data-row][data-col]").forEach((
|
|
2591
|
-
const
|
|
2592
|
-
|
|
2722
|
+
const s = this.activeRange ? N(this.activeRange) : null;
|
|
2723
|
+
e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
2724
|
+
const l = parseInt(a.getAttribute("data-row") ?? "-1", 10), f = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
2725
|
+
l >= 0 && f >= 0 && ie(l, f, this.ranges) && (a.classList.add("selected"), a.classList.remove("cell-focus"), s && (l === s.startRow && a.classList.add("top"), l === s.endRow && a.classList.add("bottom"), f === s.startCol && a.classList.add("first"), f === s.endCol && a.classList.add("last")));
|
|
2593
2726
|
});
|
|
2594
2727
|
}
|
|
2595
|
-
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((
|
|
2728
|
+
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((s) => s.classList.remove("cell-focus"));
|
|
2596
2729
|
}
|
|
2597
2730
|
afterRender() {
|
|
2598
2731
|
const e = this.shadowRoot;
|
|
2599
2732
|
if (!e) return;
|
|
2600
2733
|
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.#
|
|
2734
|
+
this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#o();
|
|
2602
2735
|
}
|
|
2603
2736
|
/**
|
|
2604
2737
|
* Called after scroll-triggered row rendering.
|
|
2605
2738
|
* Reapplies selection classes to recycled DOM elements.
|
|
2606
2739
|
*/
|
|
2607
2740
|
onScrollRender() {
|
|
2608
|
-
this.#
|
|
2741
|
+
this.#o();
|
|
2609
2742
|
}
|
|
2610
2743
|
// ===== Public API =====
|
|
2611
2744
|
/**
|
|
@@ -2630,7 +2763,7 @@ class st extends ue {
|
|
|
2630
2763
|
* Get all selected cells across all ranges.
|
|
2631
2764
|
*/
|
|
2632
2765
|
getSelectedCells() {
|
|
2633
|
-
return
|
|
2766
|
+
return ot(this.ranges);
|
|
2634
2767
|
}
|
|
2635
2768
|
/**
|
|
2636
2769
|
* Check if a specific cell is in range selection.
|
|
@@ -2660,7 +2793,7 @@ class st extends ue {
|
|
|
2660
2793
|
}
|
|
2661
2794
|
// ===== Private Helpers =====
|
|
2662
2795
|
#i() {
|
|
2663
|
-
return
|
|
2796
|
+
return nt(
|
|
2664
2797
|
this.config.mode,
|
|
2665
2798
|
{
|
|
2666
2799
|
selectedCell: this.selectedCell,
|
|
@@ -2708,74 +2841,74 @@ class st extends ue {
|
|
|
2708
2841
|
function G(o, e, t) {
|
|
2709
2842
|
return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
|
|
2710
2843
|
}
|
|
2711
|
-
function
|
|
2712
|
-
const
|
|
2713
|
-
for (let
|
|
2714
|
-
const
|
|
2715
|
-
if (
|
|
2844
|
+
function pe(o, e, t, n = null, i = 0) {
|
|
2845
|
+
const s = e.childrenField ?? "children", r = [];
|
|
2846
|
+
for (let a = 0; a < o.length; a++) {
|
|
2847
|
+
const l = o[a], f = G(l, a, n), p = l[s], g = Array.isArray(p) && p.length > 0, h = t.has(f);
|
|
2848
|
+
if (r.push({
|
|
2716
2849
|
key: f,
|
|
2717
|
-
data:
|
|
2718
|
-
depth:
|
|
2719
|
-
hasChildren:
|
|
2850
|
+
data: l,
|
|
2851
|
+
depth: i,
|
|
2852
|
+
hasChildren: g,
|
|
2720
2853
|
isExpanded: h,
|
|
2721
2854
|
parentKey: n
|
|
2722
|
-
}),
|
|
2723
|
-
const c =
|
|
2724
|
-
|
|
2855
|
+
}), g && h) {
|
|
2856
|
+
const c = pe(p, e, t, f, i + 1);
|
|
2857
|
+
r.push(...c);
|
|
2725
2858
|
}
|
|
2726
2859
|
}
|
|
2727
|
-
return
|
|
2860
|
+
return r;
|
|
2728
2861
|
}
|
|
2729
|
-
function
|
|
2862
|
+
function re(o, e) {
|
|
2730
2863
|
const t = new Set(o);
|
|
2731
2864
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
2732
2865
|
}
|
|
2733
2866
|
function W(o, e, t = null, n = 0) {
|
|
2734
|
-
const
|
|
2735
|
-
for (let
|
|
2736
|
-
const
|
|
2867
|
+
const i = e.childrenField ?? "children", s = /* @__PURE__ */ new Set();
|
|
2868
|
+
for (let r = 0; r < o.length; r++) {
|
|
2869
|
+
const a = o[r], l = G(a, r, t), f = a[i];
|
|
2737
2870
|
if (Array.isArray(f) && f.length > 0) {
|
|
2738
|
-
|
|
2739
|
-
const p = W(f, e,
|
|
2740
|
-
for (const
|
|
2871
|
+
s.add(l);
|
|
2872
|
+
const p = W(f, e, l, n + 1);
|
|
2873
|
+
for (const g of p) s.add(g);
|
|
2741
2874
|
}
|
|
2742
2875
|
}
|
|
2743
|
-
return
|
|
2876
|
+
return s;
|
|
2744
2877
|
}
|
|
2745
|
-
function
|
|
2878
|
+
function it() {
|
|
2746
2879
|
return /* @__PURE__ */ new Set();
|
|
2747
2880
|
}
|
|
2748
|
-
function
|
|
2749
|
-
const
|
|
2750
|
-
for (let
|
|
2751
|
-
const
|
|
2752
|
-
if (
|
|
2753
|
-
return [
|
|
2754
|
-
const f =
|
|
2881
|
+
function ge(o, e, t, n = null, i = 0) {
|
|
2882
|
+
const s = t.childrenField ?? "children";
|
|
2883
|
+
for (let r = 0; r < o.length; r++) {
|
|
2884
|
+
const a = o[r], l = G(a, r, n);
|
|
2885
|
+
if (l === e)
|
|
2886
|
+
return [l];
|
|
2887
|
+
const f = a[s];
|
|
2755
2888
|
if (Array.isArray(f) && f.length > 0) {
|
|
2756
|
-
const p =
|
|
2889
|
+
const p = ge(f, e, t, l, i + 1);
|
|
2757
2890
|
if (p)
|
|
2758
|
-
return [
|
|
2891
|
+
return [l, ...p];
|
|
2759
2892
|
}
|
|
2760
2893
|
}
|
|
2761
2894
|
return null;
|
|
2762
2895
|
}
|
|
2763
|
-
function
|
|
2764
|
-
const
|
|
2765
|
-
if (!
|
|
2766
|
-
const
|
|
2767
|
-
for (let
|
|
2768
|
-
|
|
2769
|
-
return
|
|
2896
|
+
function st(o, e, t, n) {
|
|
2897
|
+
const i = ge(o, e, t);
|
|
2898
|
+
if (!i) return n;
|
|
2899
|
+
const s = new Set(n);
|
|
2900
|
+
for (let r = 0; r < i.length - 1; r++)
|
|
2901
|
+
s.add(i[r]);
|
|
2902
|
+
return s;
|
|
2770
2903
|
}
|
|
2771
|
-
function
|
|
2904
|
+
function le(o, e = "children") {
|
|
2772
2905
|
if (!Array.isArray(o) || o.length === 0) return !1;
|
|
2773
2906
|
for (const t of o)
|
|
2774
2907
|
if (t && Array.isArray(t[e]) && t[e].length > 0)
|
|
2775
2908
|
return !0;
|
|
2776
2909
|
return !1;
|
|
2777
2910
|
}
|
|
2778
|
-
function
|
|
2911
|
+
function rt(o) {
|
|
2779
2912
|
if (!Array.isArray(o) || o.length === 0) return null;
|
|
2780
2913
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
2781
2914
|
for (const t of o)
|
|
@@ -2786,7 +2919,7 @@ function it(o) {
|
|
|
2786
2919
|
}
|
|
2787
2920
|
return null;
|
|
2788
2921
|
}
|
|
2789
|
-
class
|
|
2922
|
+
class at extends fe {
|
|
2790
2923
|
name = "tree";
|
|
2791
2924
|
version = "1.0.0";
|
|
2792
2925
|
get defaultConfig() {
|
|
@@ -2819,15 +2952,15 @@ class lt extends ue {
|
|
|
2819
2952
|
*/
|
|
2820
2953
|
detect(e) {
|
|
2821
2954
|
if (!this.config.autoDetect) return !1;
|
|
2822
|
-
const t = this.config.childrenField ??
|
|
2823
|
-
return
|
|
2955
|
+
const t = this.config.childrenField ?? rt(e) ?? "children";
|
|
2956
|
+
return le(e, t);
|
|
2824
2957
|
}
|
|
2825
2958
|
// ===== Data Processing =====
|
|
2826
2959
|
processRows(e) {
|
|
2827
2960
|
const t = this.config.childrenField ?? "children";
|
|
2828
|
-
if (!
|
|
2961
|
+
if (!le(e, t))
|
|
2829
2962
|
return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
|
|
2830
|
-
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = W(e, this.config), this.initialExpansionDone = !0), this.flattenedRows =
|
|
2963
|
+
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = W(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = pe(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
|
|
2831
2964
|
for (const n of this.flattenedRows)
|
|
2832
2965
|
this.rowKeyMap.set(n.key, n);
|
|
2833
2966
|
return this.flattenedRows.map((n) => ({
|
|
@@ -2840,28 +2973,31 @@ class lt extends ue {
|
|
|
2840
2973
|
}
|
|
2841
2974
|
processColumns(e) {
|
|
2842
2975
|
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
|
-
|
|
2976
|
+
const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, i = [...e];
|
|
2977
|
+
if (i.length > 0) {
|
|
2978
|
+
const s = { ...i[0] }, r = s.viewRenderer;
|
|
2979
|
+
if (r?.__treeWrapped)
|
|
2980
|
+
return i;
|
|
2981
|
+
const a = (l) => {
|
|
2982
|
+
const { value: f, row: p, column: g } = l, h = p.__treeDepth ?? 0, c = p.__treeHasChildren ?? !1, u = p.__treeExpanded ?? !1, d = document.createElement("span");
|
|
2983
|
+
if (d.style.display = "flex", d.style.alignItems = "center", d.style.paddingLeft = `${h * t}px`, c && n) {
|
|
2984
|
+
const m = document.createElement("span");
|
|
2985
|
+
m.className = "tree-toggle", this.setIcon(m, this.resolveIcon(u ? "collapse" : "expand")), m.style.cursor = "pointer", m.style.marginRight = "4px", m.style.fontSize = "10px", m.setAttribute("data-tree-key", p.__treeKey), d.appendChild(m);
|
|
2851
2986
|
} else if (n) {
|
|
2852
|
-
const
|
|
2853
|
-
|
|
2987
|
+
const m = document.createElement("span");
|
|
2988
|
+
m.style.width = "14px", m.style.display = "inline-block", d.appendChild(m);
|
|
2854
2989
|
}
|
|
2855
|
-
const
|
|
2856
|
-
if (
|
|
2857
|
-
const
|
|
2858
|
-
|
|
2990
|
+
const b = document.createElement("span");
|
|
2991
|
+
if (r) {
|
|
2992
|
+
const m = r(l);
|
|
2993
|
+
m instanceof Node ? b.appendChild(m) : b.textContent = String(m ?? f ?? "");
|
|
2859
2994
|
} else
|
|
2860
|
-
|
|
2861
|
-
return d.appendChild(
|
|
2862
|
-
}
|
|
2995
|
+
b.textContent = String(f ?? "");
|
|
2996
|
+
return d.appendChild(b), d;
|
|
2997
|
+
};
|
|
2998
|
+
a.__treeWrapped = !0, s.viewRenderer = a, i[0] = s;
|
|
2863
2999
|
}
|
|
2864
|
-
return
|
|
3000
|
+
return i;
|
|
2865
3001
|
}
|
|
2866
3002
|
// ===== Event Handlers =====
|
|
2867
3003
|
onCellClick(e) {
|
|
@@ -2869,12 +3005,12 @@ class lt extends ue {
|
|
|
2869
3005
|
if (!t?.classList.contains("tree-toggle")) return !1;
|
|
2870
3006
|
const n = t.getAttribute("data-tree-key");
|
|
2871
3007
|
if (!n) return !1;
|
|
2872
|
-
const
|
|
2873
|
-
return
|
|
3008
|
+
const i = this.rowKeyMap.get(n);
|
|
3009
|
+
return i ? (this.expandedKeys = re(this.expandedKeys, n), this.emit("tree-expand", {
|
|
2874
3010
|
key: n,
|
|
2875
|
-
row:
|
|
3011
|
+
row: i.data,
|
|
2876
3012
|
expanded: this.expandedKeys.has(n),
|
|
2877
|
-
depth:
|
|
3013
|
+
depth: i.depth
|
|
2878
3014
|
}), this.requestRender(), !0) : !1;
|
|
2879
3015
|
}
|
|
2880
3016
|
// ===== Public API =====
|
|
@@ -2894,7 +3030,7 @@ class lt extends ue {
|
|
|
2894
3030
|
* Toggle the expansion state of a node.
|
|
2895
3031
|
*/
|
|
2896
3032
|
toggle(e) {
|
|
2897
|
-
this.expandedKeys =
|
|
3033
|
+
this.expandedKeys = re(this.expandedKeys, e), this.requestRender();
|
|
2898
3034
|
}
|
|
2899
3035
|
/**
|
|
2900
3036
|
* Expand all nodes in the tree.
|
|
@@ -2906,7 +3042,7 @@ class lt extends ue {
|
|
|
2906
3042
|
* Collapse all nodes in the tree.
|
|
2907
3043
|
*/
|
|
2908
3044
|
collapseAll() {
|
|
2909
|
-
this.expandedKeys =
|
|
3045
|
+
this.expandedKeys = it(), this.requestRender();
|
|
2910
3046
|
}
|
|
2911
3047
|
/**
|
|
2912
3048
|
* Check if a node is currently expanded.
|
|
@@ -2936,7 +3072,7 @@ class lt extends ue {
|
|
|
2936
3072
|
* Expand all ancestors of a node to make it visible.
|
|
2937
3073
|
*/
|
|
2938
3074
|
expandToKey(e) {
|
|
2939
|
-
this.expandedKeys =
|
|
3075
|
+
this.expandedKeys = st(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
2940
3076
|
}
|
|
2941
3077
|
// ===== Styles =====
|
|
2942
3078
|
styles = `
|
|
@@ -2950,7 +3086,7 @@ class lt extends ue {
|
|
|
2950
3086
|
}
|
|
2951
3087
|
`;
|
|
2952
3088
|
}
|
|
2953
|
-
const
|
|
3089
|
+
const y = {
|
|
2954
3090
|
// Root structure
|
|
2955
3091
|
ROOT: "tbw-grid-root",
|
|
2956
3092
|
HEADER: "header",
|
|
@@ -2995,31 +3131,31 @@ const C = {
|
|
|
2995
3131
|
// Selection
|
|
2996
3132
|
RANGE_SELECTION: "range-selection",
|
|
2997
3133
|
SELECTION_OVERLAY: "selection-overlay"
|
|
2998
|
-
},
|
|
3134
|
+
}, D = {
|
|
2999
3135
|
ROW_INDEX: "data-row-index",
|
|
3000
3136
|
COL_INDEX: "data-col-index",
|
|
3001
3137
|
FIELD: "data-field",
|
|
3002
3138
|
GROUP_KEY: "data-group-key",
|
|
3003
3139
|
TREE_LEVEL: "data-tree-level",
|
|
3004
3140
|
STICKY: "data-sticky"
|
|
3005
|
-
},
|
|
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: `.${
|
|
3141
|
+
}, ct = {
|
|
3142
|
+
ROOT: `.${y.ROOT}`,
|
|
3143
|
+
HEADER: `.${y.HEADER}`,
|
|
3144
|
+
HEADER_ROW: `.${y.HEADER_ROW}`,
|
|
3145
|
+
HEADER_CELL: `.${y.HEADER_CELL}`,
|
|
3146
|
+
ROWS_VIEWPORT: `.${y.ROWS_VIEWPORT}`,
|
|
3147
|
+
ROWS_CONTAINER: `.${y.ROWS_CONTAINER}`,
|
|
3148
|
+
DATA_ROW: `.${y.DATA_ROW}`,
|
|
3149
|
+
DATA_CELL: `.${y.DATA_CELL}`,
|
|
3150
|
+
GROUP_ROW: `.${y.GROUP_ROW}`,
|
|
3015
3151
|
// By data attribute
|
|
3016
|
-
ROW_BY_INDEX: (o) => `.${
|
|
3017
|
-
CELL_BY_FIELD: (o) => `.${
|
|
3018
|
-
CELL_AT: (o, e) => `.${
|
|
3152
|
+
ROW_BY_INDEX: (o) => `.${y.DATA_ROW}[${D.ROW_INDEX}="${o}"]`,
|
|
3153
|
+
CELL_BY_FIELD: (o) => `.${y.DATA_CELL}[${D.FIELD}="${o}"]`,
|
|
3154
|
+
CELL_AT: (o, e) => `.${y.DATA_ROW}[${D.ROW_INDEX}="${o}"] .${y.DATA_CELL}[${D.COL_INDEX}="${e}"]`,
|
|
3019
3155
|
// State selectors
|
|
3020
|
-
SELECTED_ROWS: `.${
|
|
3021
|
-
EDITING_CELL: `.${
|
|
3022
|
-
},
|
|
3156
|
+
SELECTED_ROWS: `.${y.DATA_ROW}.${y.SELECTED}`,
|
|
3157
|
+
EDITING_CELL: `.${y.DATA_CELL}.${y.EDITING}`
|
|
3158
|
+
}, dt = {
|
|
3023
3159
|
// Colors
|
|
3024
3160
|
COLOR_BG: "--tbw-color-bg",
|
|
3025
3161
|
COLOR_FG: "--tbw-color-fg",
|
|
@@ -3041,7 +3177,7 @@ const C = {
|
|
|
3041
3177
|
// Borders
|
|
3042
3178
|
BORDER_RADIUS: "--tbw-border-radius",
|
|
3043
3179
|
FOCUS_OUTLINE: "--tbw-focus-outline"
|
|
3044
|
-
},
|
|
3180
|
+
}, ht = {
|
|
3045
3181
|
CELL_COMMIT: "cell-commit",
|
|
3046
3182
|
ROW_COMMIT: "row-commit",
|
|
3047
3183
|
CHANGED_ROWS_RESET: "changed-rows-reset",
|
|
@@ -3052,7 +3188,7 @@ const C = {
|
|
|
3052
3188
|
ACTIVATE_CELL: "activate-cell",
|
|
3053
3189
|
GROUP_TOGGLE: "group-toggle",
|
|
3054
3190
|
COLUMN_STATE_CHANGE: "column-state-change"
|
|
3055
|
-
},
|
|
3191
|
+
}, ut = {
|
|
3056
3192
|
// Selection plugin
|
|
3057
3193
|
SELECTION_CHANGE: "selection-change",
|
|
3058
3194
|
// Tree plugin
|
|
@@ -3083,10 +3219,10 @@ const C = {
|
|
|
3083
3219
|
DETAIL_EXPAND: "detail-expand",
|
|
3084
3220
|
// Grouping rows plugin
|
|
3085
3221
|
GROUP_EXPAND: "group-expand"
|
|
3086
|
-
},
|
|
3222
|
+
}, q = {
|
|
3087
3223
|
sum: (o, e) => o.reduce((t, n) => t + (Number(n[e]) || 0), 0),
|
|
3088
3224
|
avg: (o, e) => {
|
|
3089
|
-
const t = o.reduce((n,
|
|
3225
|
+
const t = o.reduce((n, i) => n + (Number(i[e]) || 0), 0);
|
|
3090
3226
|
return o.length ? t / o.length : 0;
|
|
3091
3227
|
},
|
|
3092
3228
|
count: (o) => o.length,
|
|
@@ -3094,7 +3230,7 @@ const C = {
|
|
|
3094
3230
|
max: (o, e) => Math.max(...o.map((t) => Number(t[e]) || -1 / 0)),
|
|
3095
3231
|
first: (o, e) => o[0]?.[e],
|
|
3096
3232
|
last: (o, e) => o[o.length - 1]?.[e]
|
|
3097
|
-
}, P = /* @__PURE__ */ new Map(),
|
|
3233
|
+
}, P = /* @__PURE__ */ new Map(), x = {
|
|
3098
3234
|
/**
|
|
3099
3235
|
* Register a custom aggregator function.
|
|
3100
3236
|
*/
|
|
@@ -3112,47 +3248,48 @@ const C = {
|
|
|
3112
3248
|
*/
|
|
3113
3249
|
get(o) {
|
|
3114
3250
|
if (o !== void 0)
|
|
3115
|
-
return typeof o == "function" ? o : P.get(o) ??
|
|
3251
|
+
return typeof o == "function" ? o : P.get(o) ?? q[o];
|
|
3116
3252
|
},
|
|
3117
3253
|
/**
|
|
3118
3254
|
* Run an aggregator on a set of rows.
|
|
3119
3255
|
*/
|
|
3120
3256
|
run(o, e, t, n) {
|
|
3121
|
-
const
|
|
3122
|
-
return
|
|
3257
|
+
const i = this.get(o);
|
|
3258
|
+
return i ? i(e, t, n) : void 0;
|
|
3123
3259
|
},
|
|
3124
3260
|
/**
|
|
3125
3261
|
* Check if an aggregator exists.
|
|
3126
3262
|
*/
|
|
3127
3263
|
has(o) {
|
|
3128
|
-
return P.has(o) || o in
|
|
3264
|
+
return P.has(o) || o in q;
|
|
3129
3265
|
},
|
|
3130
3266
|
/**
|
|
3131
3267
|
* List all available aggregator names.
|
|
3132
3268
|
*/
|
|
3133
3269
|
list() {
|
|
3134
|
-
return [...Object.keys(
|
|
3270
|
+
return [...Object.keys(q), ...P.keys()];
|
|
3135
3271
|
}
|
|
3136
|
-
},
|
|
3272
|
+
}, ft = x.register.bind(x), pt = x.unregister.bind(x), gt = x.get.bind(x), wt = x.run.bind(x), bt = x.list.bind(x);
|
|
3137
3273
|
export {
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
lt as
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3274
|
+
fe as BaseGridPlugin,
|
|
3275
|
+
ce as DEFAULT_GRID_ICONS,
|
|
3276
|
+
ht as DGEvents,
|
|
3277
|
+
I as DataGridElement,
|
|
3278
|
+
M as FitModeEnum,
|
|
3279
|
+
dt as GridCSSVars,
|
|
3280
|
+
y as GridClasses,
|
|
3281
|
+
D as GridDataAttrs,
|
|
3282
|
+
I as GridElement,
|
|
3283
|
+
ct as GridSelectors,
|
|
3284
|
+
ut as PluginEvents,
|
|
3285
|
+
Je as PluginManager,
|
|
3286
|
+
lt as SelectionPlugin,
|
|
3287
|
+
at as TreePlugin,
|
|
3288
|
+
x as aggregatorRegistry,
|
|
3289
|
+
gt as getAggregator,
|
|
3290
|
+
bt as listAggregators,
|
|
3291
|
+
ft as registerAggregator,
|
|
3292
|
+
wt as runAggregator,
|
|
3293
|
+
pt as unregisterAggregator
|
|
3157
3294
|
};
|
|
3158
3295
|
//# sourceMappingURL=index.js.map
|