@toolbox-web/grid 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/all.d.ts +19 -19
- package/all.d.ts.map +1 -1
- package/all.js +1775 -1202
- package/all.js.map +1 -1
- package/index.js +2143 -2015
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +22 -12
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/columns.d.ts +0 -9
- package/lib/core/internal/columns.d.ts.map +1 -1
- package/lib/core/internal/config-manager.d.ts +236 -0
- package/lib/core/internal/config-manager.d.ts.map +1 -0
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/render-scheduler.d.ts +123 -0
- package/lib/core/internal/render-scheduler.d.ts.map +1 -0
- package/lib/core/internal/rows.d.ts +8 -3
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/sanitize.d.ts +10 -2
- package/lib/core/internal/sanitize.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +40 -2
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/internal/validate-config.d.ts +11 -0
- package/lib/core/internal/validate-config.d.ts.map +1 -0
- package/lib/core/plugin/base-plugin.d.ts +70 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +13 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +17 -3
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +112 -12
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +50 -18
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +60 -25
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +51 -16
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +117 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -0
- package/lib/{core/internal → plugins/editing}/editors.d.ts +1 -1
- package/lib/plugins/editing/editors.d.ts.map +1 -0
- package/lib/plugins/editing/index.d.ts +8 -0
- package/lib/plugins/editing/index.d.ts.map +1 -0
- package/lib/plugins/editing/index.js +705 -0
- package/lib/plugins/editing/index.js.map +1 -0
- package/lib/plugins/editing/types.d.ts +45 -0
- package/lib/plugins/editing/types.d.ts.map +1 -0
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
- package/lib/plugins/export/index.js +74 -39
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +87 -50
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +4 -4
- package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +59 -24
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +46 -11
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +140 -102
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +12 -2
- package/lib/plugins/master-detail/types.d.ts.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +59 -22
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +41 -6
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +45 -9
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +42 -7
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +59 -19
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +41 -6
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +48 -13
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +3 -3
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +165 -126
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/tree-data.d.ts +6 -6
- package/lib/plugins/tree/tree-data.d.ts.map +1 -1
- package/lib/plugins/tree/tree-detect.d.ts +5 -9
- package/lib/plugins/tree/tree-detect.d.ts.map +1 -1
- package/lib/plugins/tree/types.d.ts +16 -4
- package/lib/plugins/tree/types.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +46 -11
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +37 -2
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +104 -13
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +31 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +18 -6
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +2 -0
- package/umd/plugins/editing.umd.js.map +1 -0
- package/umd/plugins/export.umd.js +2 -2
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- 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/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.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 +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/lib/core/internal/column-state.d.ts +0 -124
- package/lib/core/internal/column-state.d.ts.map +0 -1
- package/lib/core/internal/editing.d.ts +0 -76
- package/lib/core/internal/editing.d.ts.map +0 -1
- package/lib/core/internal/editors.d.ts.map +0 -1
- package/lib/core/internal/grid-internals.d.ts +0 -83
- package/lib/core/internal/grid-internals.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const m = /{{\s*([^}]+)\s*}}/g, f = "__DG_EMPTY__", R = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, x = /__(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/, b = /* @__PURE__ */ new Set([
|
|
2
2
|
"script",
|
|
3
3
|
"iframe",
|
|
4
4
|
"object",
|
|
@@ -23,8 +23,8 @@ const R = /{{\s*([^}]+)\s*}}/g, f = "__DG_EMPTY__", x = /^[\w$. '?+\-*/%:()!<>=,
|
|
|
23
23
|
"plaintext",
|
|
24
24
|
"xmp",
|
|
25
25
|
"listing"
|
|
26
|
-
]), w = /^on\w+$/i,
|
|
27
|
-
function
|
|
26
|
+
]), w = /^on\w+$/i, E = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), v = /^\s*(javascript|vbscript|data|blob):/i;
|
|
27
|
+
function y(i) {
|
|
28
28
|
if (!i || typeof i != "string") return "";
|
|
29
29
|
if (i.indexOf("<") === -1) return i;
|
|
30
30
|
const e = document.createElement("template");
|
|
@@ -33,66 +33,66 @@ function S(i) {
|
|
|
33
33
|
function C(i) {
|
|
34
34
|
const e = [], t = i.querySelectorAll("*");
|
|
35
35
|
for (const n of t) {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
36
|
+
const s = n.tagName.toLowerCase();
|
|
37
|
+
if (b.has(s)) {
|
|
38
38
|
e.push(n);
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
|
-
if ((
|
|
42
|
-
(
|
|
41
|
+
if ((s === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
|
|
42
|
+
(o) => w.test(o.name) || o.name === "href" || o.name === "xlink:href"
|
|
43
43
|
)) {
|
|
44
44
|
e.push(n);
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const a = [];
|
|
48
48
|
for (const r of n.attributes) {
|
|
49
|
-
const
|
|
50
|
-
if (w.test(
|
|
51
|
-
|
|
49
|
+
const o = r.name.toLowerCase();
|
|
50
|
+
if (w.test(o)) {
|
|
51
|
+
a.push(r.name);
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
|
|
54
|
+
if (E.has(o) && v.test(r.value)) {
|
|
55
|
+
a.push(r.name);
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
if (
|
|
59
|
-
|
|
58
|
+
if (o === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
|
|
59
|
+
a.push(r.name);
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
a.forEach((r) => n.removeAttribute(r));
|
|
64
64
|
}
|
|
65
65
|
e.forEach((n) => n.remove());
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function S(i, e) {
|
|
68
68
|
if (!i || i.indexOf("{{") === -1) return i;
|
|
69
|
-
const t = [], n = i.replace(
|
|
70
|
-
const d =
|
|
71
|
-
return t.push({ expr:
|
|
72
|
-
}),
|
|
73
|
-
return /Reflect\.|\bProxy\b|ownKeys\(/.test(i) ||
|
|
69
|
+
const t = [], n = i.replace(m, (o, l) => {
|
|
70
|
+
const d = A(l, e);
|
|
71
|
+
return t.push({ expr: l.trim(), result: d }), d;
|
|
72
|
+
}), s = D(n), a = t.length && t.every((o) => o.result === "" || o.result === f);
|
|
73
|
+
return /Reflect\.|\bProxy\b|ownKeys\(/.test(i) || a ? "" : s;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function A(i, e) {
|
|
76
76
|
if (i = (i || "").trim(), !i || /\b(Reflect|Proxy|ownKeys)\b/.test(i)) return f;
|
|
77
77
|
if (i === "value") return e.value == null ? f : String(e.value);
|
|
78
78
|
if (i.startsWith("row.") && !/[()?]/.test(i) && !i.includes(":")) {
|
|
79
|
-
const n = i.slice(4),
|
|
80
|
-
return
|
|
79
|
+
const n = i.slice(4), s = e.row ? e.row[n] : void 0;
|
|
80
|
+
return s == null ? f : String(s);
|
|
81
81
|
}
|
|
82
|
-
if (i.length > 80 || !
|
|
82
|
+
if (i.length > 80 || !R.test(i) || x.test(i)) return f;
|
|
83
83
|
const t = i.match(/\./g);
|
|
84
84
|
if (t && t.length > 1) return f;
|
|
85
85
|
try {
|
|
86
|
-
const
|
|
87
|
-
return /Reflect|Proxy|ownKeys/.test(
|
|
86
|
+
const s = new Function("value", "row", `return (${i});`)(e.value, e.row), a = s == null ? "" : String(s);
|
|
87
|
+
return /Reflect|Proxy|ownKeys/.test(a) ? f : a || f;
|
|
88
88
|
} catch {
|
|
89
89
|
return f;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function D(i) {
|
|
93
93
|
return i && i.replace(new RegExp(f, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const H = {
|
|
96
96
|
expand: "▶",
|
|
97
97
|
collapse: "▼",
|
|
98
98
|
sortAsc: "▲",
|
|
@@ -119,6 +119,12 @@ class _ {
|
|
|
119
119
|
config;
|
|
120
120
|
/** User-provided configuration from constructor */
|
|
121
121
|
userConfig;
|
|
122
|
+
/**
|
|
123
|
+
* Plugin-level AbortController for event listener cleanup.
|
|
124
|
+
* Created fresh in attach(), aborted in detach().
|
|
125
|
+
* This ensures event listeners are properly cleaned up when plugins are re-attached.
|
|
126
|
+
*/
|
|
127
|
+
#e;
|
|
122
128
|
/**
|
|
123
129
|
* Default configuration - subclasses should override this getter.
|
|
124
130
|
* Note: This must be a getter (not property initializer) for proper inheritance
|
|
@@ -133,19 +139,48 @@ class _ {
|
|
|
133
139
|
/**
|
|
134
140
|
* Called when the plugin is attached to a grid.
|
|
135
141
|
* Override to set up event listeners, initialize state, etc.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* attach(grid: GridElement): void {
|
|
146
|
+
* super.attach(grid);
|
|
147
|
+
* // Set up document-level listeners with auto-cleanup
|
|
148
|
+
* document.addEventListener('keydown', this.handleEscape, {
|
|
149
|
+
* signal: this.disconnectSignal
|
|
150
|
+
* });
|
|
151
|
+
* }
|
|
152
|
+
* ```
|
|
136
153
|
*/
|
|
137
154
|
attach(e) {
|
|
138
|
-
this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
|
|
155
|
+
this.#e?.abort(), this.#e = new AbortController(), this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
|
|
139
156
|
}
|
|
140
157
|
/**
|
|
141
158
|
* Called when the plugin is detached from a grid.
|
|
142
159
|
* Override to clean up event listeners, timers, etc.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* detach(): void {
|
|
164
|
+
* // Clean up any state not handled by disconnectSignal
|
|
165
|
+
* this.selectedRows.clear();
|
|
166
|
+
* this.cache = null;
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
143
169
|
*/
|
|
144
170
|
detach() {
|
|
171
|
+
this.#e?.abort(), this.#e = void 0;
|
|
145
172
|
}
|
|
146
173
|
/**
|
|
147
174
|
* Get another plugin instance from the same grid.
|
|
148
175
|
* Use for inter-plugin communication.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const selection = this.getPlugin(SelectionPlugin);
|
|
180
|
+
* if (selection) {
|
|
181
|
+
* const selectedRows = selection.getSelectedRows();
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
149
184
|
*/
|
|
150
185
|
getPlugin(e) {
|
|
151
186
|
return this.grid?.getPlugin(e);
|
|
@@ -219,7 +254,7 @@ class _ {
|
|
|
219
254
|
* document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
|
|
220
255
|
*/
|
|
221
256
|
get disconnectSignal() {
|
|
222
|
-
return this.grid?.disconnectSignal;
|
|
257
|
+
return this.#e?.signal ?? this.grid?.disconnectSignal;
|
|
223
258
|
}
|
|
224
259
|
/**
|
|
225
260
|
* Get the grid-level icons configuration.
|
|
@@ -227,7 +262,7 @@ class _ {
|
|
|
227
262
|
*/
|
|
228
263
|
get gridIcons() {
|
|
229
264
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
230
|
-
return { ...
|
|
265
|
+
return { ...H, ...e };
|
|
231
266
|
}
|
|
232
267
|
/**
|
|
233
268
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -262,26 +297,26 @@ function p(i, e) {
|
|
|
262
297
|
const t = new Set(i);
|
|
263
298
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
264
299
|
}
|
|
265
|
-
function
|
|
300
|
+
function k(i, e) {
|
|
266
301
|
const t = new Set(i);
|
|
267
302
|
return t.add(e), t;
|
|
268
303
|
}
|
|
269
|
-
function
|
|
304
|
+
function L(i, e) {
|
|
270
305
|
const t = new Set(i);
|
|
271
306
|
return t.delete(e), t;
|
|
272
307
|
}
|
|
273
|
-
function
|
|
308
|
+
function T(i, e) {
|
|
274
309
|
return i.has(e);
|
|
275
310
|
}
|
|
276
|
-
function
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
311
|
+
function I(i, e, t, n) {
|
|
312
|
+
const s = document.createElement("div");
|
|
313
|
+
s.className = "master-detail-row", s.setAttribute("data-detail-for", String(e)), s.setAttribute("role", "row");
|
|
314
|
+
const a = document.createElement("div");
|
|
315
|
+
a.className = "master-detail-cell", a.setAttribute("role", "cell"), a.style.gridColumn = `1 / ${n + 1}`;
|
|
281
316
|
const r = t(i, e);
|
|
282
|
-
return typeof r == "string" ?
|
|
317
|
+
return typeof r == "string" ? a.innerHTML = r : r instanceof HTMLElement && a.appendChild(r), s.appendChild(a), s;
|
|
283
318
|
}
|
|
284
|
-
const
|
|
319
|
+
const O = ".master-detail-cell-wrapper{display:flex;align-items:center;gap:4px}.master-detail-toggle{cursor:pointer;opacity:.7;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border));overflow:hidden}.master-detail-cell{padding:16px;overflow:auto}.master-detail-row.tbw-expanding{animation:tbw-detail-expand var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}.master-detail-row.tbw-collapsing{animation:tbw-detail-collapse var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-detail-expand{0%{opacity:0;max-height:0;padding-top:0;padding-bottom:0}to{opacity:1;max-height:500px;padding-top:16px;padding-bottom:16px}}@keyframes tbw-detail-collapse{0%{opacity:1;max-height:500px}to{opacity:0;max-height:0}}";
|
|
285
320
|
class q extends _ {
|
|
286
321
|
name = "masterDetail";
|
|
287
322
|
version = "1.0.0";
|
|
@@ -338,12 +373,12 @@ class q extends _ {
|
|
|
338
373
|
return;
|
|
339
374
|
}
|
|
340
375
|
}
|
|
341
|
-
const
|
|
342
|
-
|
|
376
|
+
const s = t.getAttribute("animation"), a = t.getAttribute("show-expand-column"), r = t.getAttribute("expand-on-row-click"), o = t.getAttribute("collapse-on-click-outside"), l = t.getAttribute("height"), d = {};
|
|
377
|
+
s !== null && (d.animation = s === "false" ? !1 : s), a !== null && (d.showExpandColumn = a !== "false"), r !== null && (d.expandOnRowClick = r === "true"), o !== null && (d.collapseOnClickOutside = o === "true"), l !== null && (d.detailHeight = l === "auto" ? "auto" : parseInt(l, 10));
|
|
343
378
|
const u = t.innerHTML.trim();
|
|
344
379
|
u && !this.config.detailRenderer && (d.detailRenderer = (c, h) => {
|
|
345
|
-
const g =
|
|
346
|
-
return
|
|
380
|
+
const g = S(u, { value: c, row: c });
|
|
381
|
+
return y(g);
|
|
347
382
|
}), Object.keys(d).length > 0 && (this.config = { ...this.config, ...d });
|
|
348
383
|
}
|
|
349
384
|
// #endregion
|
|
@@ -418,31 +453,23 @@ class q extends _ {
|
|
|
418
453
|
return [...e];
|
|
419
454
|
const t = [...e];
|
|
420
455
|
if (t.length > 0) {
|
|
421
|
-
const n = { ...t[0] },
|
|
422
|
-
if (
|
|
456
|
+
const n = { ...t[0] }, s = n.viewRenderer;
|
|
457
|
+
if (s?.__masterDetailWrapped)
|
|
423
458
|
return t;
|
|
424
|
-
const
|
|
425
|
-
const { value:
|
|
459
|
+
const a = (r) => {
|
|
460
|
+
const { value: o, row: l } = r, d = this.expandedRows.has(l), u = document.createElement("span");
|
|
426
461
|
u.className = "master-detail-cell-wrapper";
|
|
427
462
|
const c = document.createElement("span");
|
|
428
|
-
c.className = `master-detail-toggle${d ? " expanded" : ""}`, this.setIcon(c, this.resolveIcon(d ? "collapse" : "expand")), c.setAttribute("role", "button"), c.setAttribute("tabindex", "0"), c.setAttribute("aria-expanded", String(d)), c.setAttribute("aria-label", d ? "Collapse details" : "Expand details"),
|
|
429
|
-
g.stopPropagation();
|
|
430
|
-
const m = this.rows.indexOf(a);
|
|
431
|
-
this.expandedRows = p(this.expandedRows, a), this.emit("detail-expand", {
|
|
432
|
-
rowIndex: m,
|
|
433
|
-
row: a,
|
|
434
|
-
expanded: this.expandedRows.has(a)
|
|
435
|
-
}), this.requestRender();
|
|
436
|
-
}), u.appendChild(c);
|
|
463
|
+
c.className = `master-detail-toggle${d ? " expanded" : ""}`, this.setIcon(c, this.resolveIcon(d ? "collapse" : "expand")), c.setAttribute("role", "button"), c.setAttribute("tabindex", "0"), c.setAttribute("aria-expanded", String(d)), c.setAttribute("aria-label", d ? "Collapse details" : "Expand details"), u.appendChild(c);
|
|
437
464
|
const h = document.createElement("span");
|
|
438
|
-
if (
|
|
439
|
-
const g =
|
|
440
|
-
g instanceof Node ? h.appendChild(g) : h.textContent = String(g ??
|
|
465
|
+
if (s) {
|
|
466
|
+
const g = s(r);
|
|
467
|
+
g instanceof Node ? h.appendChild(g) : h.textContent = String(g ?? o ?? "");
|
|
441
468
|
} else
|
|
442
|
-
h.textContent = String(
|
|
469
|
+
h.textContent = String(o ?? "");
|
|
443
470
|
return u.appendChild(h), u;
|
|
444
471
|
};
|
|
445
|
-
|
|
472
|
+
a.__masterDetailWrapped = !0, n.viewRenderer = a, t[0] = n;
|
|
446
473
|
}
|
|
447
474
|
return t;
|
|
448
475
|
}
|
|
@@ -454,7 +481,15 @@ class q extends _ {
|
|
|
454
481
|
expanded: this.expandedRows.has(e.row)
|
|
455
482
|
}), this.requestRender(), !1;
|
|
456
483
|
}
|
|
457
|
-
onCellClick() {
|
|
484
|
+
onCellClick(e) {
|
|
485
|
+
if (e.originalEvent?.target?.classList.contains("master-detail-toggle")) {
|
|
486
|
+
const n = e.row, s = e.rowIndex;
|
|
487
|
+
return this.expandedRows = p(this.expandedRows, n), this.emit("detail-expand", {
|
|
488
|
+
rowIndex: s,
|
|
489
|
+
row: n,
|
|
490
|
+
expanded: this.expandedRows.has(n)
|
|
491
|
+
}), this.requestRender(), !0;
|
|
492
|
+
}
|
|
458
493
|
this.expandedRows.size > 0 && queueMicrotask(() => this.#e());
|
|
459
494
|
}
|
|
460
495
|
afterRender() {
|
|
@@ -475,26 +510,26 @@ class q extends _ {
|
|
|
475
510
|
if (!this.config.detailRenderer) return;
|
|
476
511
|
const e = this.shadowRoot?.querySelector(".rows");
|
|
477
512
|
if (!e) return;
|
|
478
|
-
const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"),
|
|
513
|
+
const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"), s = this.columns.length;
|
|
479
514
|
for (const r of n) {
|
|
480
|
-
const
|
|
481
|
-
|
|
515
|
+
const o = r.querySelector(".cell[data-row]"), l = o ? parseInt(o.getAttribute("data-row") ?? "-1", 10) : -1;
|
|
516
|
+
l >= 0 && t.set(l, r);
|
|
482
517
|
}
|
|
483
|
-
const
|
|
484
|
-
for (const r of
|
|
485
|
-
const
|
|
486
|
-
(!d || !u) && (r.remove(),
|
|
518
|
+
const a = e.querySelectorAll(".master-detail-row");
|
|
519
|
+
for (const r of a) {
|
|
520
|
+
const o = parseInt(r.getAttribute("data-detail-for") ?? "-1", 10), l = o >= 0 ? this.rows[o] : void 0, d = l && this.expandedRows.has(l), u = t.has(o);
|
|
521
|
+
(!d || !u) && (r.remove(), l && this.detailElements.delete(l));
|
|
487
522
|
}
|
|
488
|
-
for (const [r,
|
|
489
|
-
const
|
|
490
|
-
if (!
|
|
491
|
-
const d = this.detailElements.get(
|
|
523
|
+
for (const [r, o] of t) {
|
|
524
|
+
const l = this.rows[r];
|
|
525
|
+
if (!l || !this.expandedRows.has(l)) continue;
|
|
526
|
+
const d = this.detailElements.get(l);
|
|
492
527
|
if (d) {
|
|
493
|
-
d.previousElementSibling !==
|
|
528
|
+
d.previousElementSibling !== o && o.after(d);
|
|
494
529
|
continue;
|
|
495
530
|
}
|
|
496
|
-
const u =
|
|
497
|
-
typeof this.config.detailHeight == "number" && (u.style.height = `${this.config.detailHeight}px`),
|
|
531
|
+
const u = I(l, r, this.config.detailRenderer, s);
|
|
532
|
+
typeof this.config.detailHeight == "number" && (u.style.height = `${this.config.detailHeight}px`), o.after(u), this.detailElements.set(l, u), this.animateExpand(u);
|
|
498
533
|
}
|
|
499
534
|
}
|
|
500
535
|
/**
|
|
@@ -508,8 +543,8 @@ class q extends _ {
|
|
|
508
543
|
if (n)
|
|
509
544
|
e += n.offsetHeight;
|
|
510
545
|
else {
|
|
511
|
-
const
|
|
512
|
-
e += typeof
|
|
546
|
+
const s = this.config?.detailHeight;
|
|
547
|
+
e += typeof s == "number" ? s : 150;
|
|
513
548
|
}
|
|
514
549
|
}
|
|
515
550
|
return e;
|
|
@@ -521,11 +556,11 @@ class q extends _ {
|
|
|
521
556
|
getExtraHeightBefore(e) {
|
|
522
557
|
let t = 0;
|
|
523
558
|
for (const n of this.expandedRows) {
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
t +=
|
|
559
|
+
const s = this.rows.indexOf(n);
|
|
560
|
+
if (s >= 0 && s < e) {
|
|
561
|
+
const a = this.detailElements.get(n);
|
|
562
|
+
if (a)
|
|
563
|
+
t += a.offsetHeight;
|
|
529
564
|
else {
|
|
530
565
|
const r = this.config?.detailHeight;
|
|
531
566
|
t += typeof r == "number" ? r : 150;
|
|
@@ -540,18 +575,18 @@ class q extends _ {
|
|
|
540
575
|
*/
|
|
541
576
|
adjustVirtualStart(e, t, n) {
|
|
542
577
|
if (this.expandedRows.size === 0) return e;
|
|
543
|
-
const
|
|
544
|
-
for (const
|
|
545
|
-
const
|
|
546
|
-
|
|
578
|
+
const s = [];
|
|
579
|
+
for (const o of this.expandedRows) {
|
|
580
|
+
const l = this.rows.indexOf(o);
|
|
581
|
+
l >= 0 && s.push({ index: l, row: o });
|
|
547
582
|
}
|
|
548
|
-
|
|
549
|
-
let
|
|
550
|
-
for (const { index:
|
|
551
|
-
const d =
|
|
552
|
-
r += c, !(
|
|
583
|
+
s.sort((o, l) => o.index - l.index);
|
|
584
|
+
let a = e, r = 0;
|
|
585
|
+
for (const { index: o, row: l } of s) {
|
|
586
|
+
const d = o * n + r, c = this.detailElements.get(l)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), h = d + n + c;
|
|
587
|
+
r += c, !(o >= e) && h > t && o < a && (a = o);
|
|
553
588
|
}
|
|
554
|
-
return
|
|
589
|
+
return a;
|
|
555
590
|
}
|
|
556
591
|
// #endregion
|
|
557
592
|
// #region Public API
|
|
@@ -561,7 +596,7 @@ class q extends _ {
|
|
|
561
596
|
*/
|
|
562
597
|
expand(e) {
|
|
563
598
|
const t = this.rows[e];
|
|
564
|
-
t && (this.expandedRows =
|
|
599
|
+
t && (this.expandedRows = k(this.expandedRows, t), this.requestRender());
|
|
565
600
|
}
|
|
566
601
|
/**
|
|
567
602
|
* Collapse the detail row at the given index.
|
|
@@ -569,7 +604,7 @@ class q extends _ {
|
|
|
569
604
|
*/
|
|
570
605
|
collapse(e) {
|
|
571
606
|
const t = this.rows[e];
|
|
572
|
-
t && (this.expandedRows =
|
|
607
|
+
t && (this.expandedRows = L(this.expandedRows, t), this.requestRender());
|
|
573
608
|
}
|
|
574
609
|
/**
|
|
575
610
|
* Toggle the detail row at the given index.
|
|
@@ -586,7 +621,7 @@ class q extends _ {
|
|
|
586
621
|
*/
|
|
587
622
|
isExpanded(e) {
|
|
588
623
|
const t = this.rows[e];
|
|
589
|
-
return t ?
|
|
624
|
+
return t ? T(this.expandedRows, t) : !1;
|
|
590
625
|
}
|
|
591
626
|
/**
|
|
592
627
|
* Expand all detail rows.
|
|
@@ -632,11 +667,14 @@ class q extends _ {
|
|
|
632
667
|
*/
|
|
633
668
|
refreshDetailRenderer() {
|
|
634
669
|
const e = this.config.detailRenderer;
|
|
635
|
-
this.config = { ...this.config, detailRenderer: void 0 }, this.parseLightDomDetail(), !this.config.detailRenderer && e && (this.config = { ...this.config, detailRenderer: e })
|
|
670
|
+
if (this.config = { ...this.config, detailRenderer: void 0 }, this.parseLightDomDetail(), !this.config.detailRenderer && e && (this.config = { ...this.config, detailRenderer: e }), this.config.detailRenderer) {
|
|
671
|
+
const t = this.grid;
|
|
672
|
+
typeof t.refreshColumns == "function" ? t.refreshColumns() : this.requestRender();
|
|
673
|
+
}
|
|
636
674
|
}
|
|
637
675
|
// #endregion
|
|
638
676
|
// #region Styles
|
|
639
|
-
styles =
|
|
677
|
+
styles = O;
|
|
640
678
|
// #endregion
|
|
641
679
|
}
|
|
642
680
|
export {
|