@toolbox-web/grid 0.3.3 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +19 -19
- package/all.d.ts.map +1 -1
- package/all.js +1798 -1201
- package/all.js.map +1 -1
- package/index.js +2215 -2026
- 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/editing.d.ts +3 -3
- package/lib/core/internal/editing.d.ts.map +1 -1
- 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 +2 -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 +25 -0
- package/lib/core/internal/validate-config.d.ts.map +1 -0
- package/lib/core/plugin/base-plugin.d.ts +118 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/index.d.ts +1 -0
- package/lib/core/plugin/index.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 +7 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +78 -22
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +72 -21
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +53 -2
- 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 +721 -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 +68 -17
- 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 +103 -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 +80 -29
- 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 +62 -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 +156 -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 +75 -22
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +57 -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 +61 -9
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +58 -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 +75 -19
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +57 -6
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +60 -9
- 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 +181 -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/UndoRedoPlugin.d.ts +7 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +65 -6
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +61 -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 +37 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +25 -7
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +2 -2
- 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/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.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/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: "▲",
|
|
@@ -103,6 +103,22 @@ const k = {
|
|
|
103
103
|
toolPanel: "☰"
|
|
104
104
|
};
|
|
105
105
|
class _ {
|
|
106
|
+
/**
|
|
107
|
+
* Plugin dependencies - declare other plugins this one requires.
|
|
108
|
+
*
|
|
109
|
+
* Dependencies are validated when the plugin is attached.
|
|
110
|
+
* Required dependencies throw an error if missing.
|
|
111
|
+
* Optional dependencies log an info message if missing.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* static readonly dependencies: PluginDependency[] = [
|
|
116
|
+
* { name: 'editing', required: true, reason: 'Tracks cell edits for undo/redo' },
|
|
117
|
+
* { name: 'selection', required: false, reason: 'Enables selection-based undo' },
|
|
118
|
+
* ];
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
static dependencies;
|
|
106
122
|
/** Plugin version - override in subclass if needed */
|
|
107
123
|
version = "1.0.0";
|
|
108
124
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
@@ -119,6 +135,12 @@ class _ {
|
|
|
119
135
|
config;
|
|
120
136
|
/** User-provided configuration from constructor */
|
|
121
137
|
userConfig;
|
|
138
|
+
/**
|
|
139
|
+
* Plugin-level AbortController for event listener cleanup.
|
|
140
|
+
* Created fresh in attach(), aborted in detach().
|
|
141
|
+
* This ensures event listeners are properly cleaned up when plugins are re-attached.
|
|
142
|
+
*/
|
|
143
|
+
#e;
|
|
122
144
|
/**
|
|
123
145
|
* Default configuration - subclasses should override this getter.
|
|
124
146
|
* Note: This must be a getter (not property initializer) for proper inheritance
|
|
@@ -133,19 +155,48 @@ class _ {
|
|
|
133
155
|
/**
|
|
134
156
|
* Called when the plugin is attached to a grid.
|
|
135
157
|
* Override to set up event listeners, initialize state, etc.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* attach(grid: GridElement): void {
|
|
162
|
+
* super.attach(grid);
|
|
163
|
+
* // Set up document-level listeners with auto-cleanup
|
|
164
|
+
* document.addEventListener('keydown', this.handleEscape, {
|
|
165
|
+
* signal: this.disconnectSignal
|
|
166
|
+
* });
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
136
169
|
*/
|
|
137
170
|
attach(e) {
|
|
138
|
-
this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
|
|
171
|
+
this.#e?.abort(), this.#e = new AbortController(), this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
|
|
139
172
|
}
|
|
140
173
|
/**
|
|
141
174
|
* Called when the plugin is detached from a grid.
|
|
142
175
|
* Override to clean up event listeners, timers, etc.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* detach(): void {
|
|
180
|
+
* // Clean up any state not handled by disconnectSignal
|
|
181
|
+
* this.selectedRows.clear();
|
|
182
|
+
* this.cache = null;
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
143
185
|
*/
|
|
144
186
|
detach() {
|
|
187
|
+
this.#e?.abort(), this.#e = void 0;
|
|
145
188
|
}
|
|
146
189
|
/**
|
|
147
190
|
* Get another plugin instance from the same grid.
|
|
148
191
|
* Use for inter-plugin communication.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const selection = this.getPlugin(SelectionPlugin);
|
|
196
|
+
* if (selection) {
|
|
197
|
+
* const selectedRows = selection.getSelectedRows();
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
149
200
|
*/
|
|
150
201
|
getPlugin(e) {
|
|
151
202
|
return this.grid?.getPlugin(e);
|
|
@@ -219,7 +270,7 @@ class _ {
|
|
|
219
270
|
* document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
|
|
220
271
|
*/
|
|
221
272
|
get disconnectSignal() {
|
|
222
|
-
return this.grid?.disconnectSignal;
|
|
273
|
+
return this.#e?.signal ?? this.grid?.disconnectSignal;
|
|
223
274
|
}
|
|
224
275
|
/**
|
|
225
276
|
* Get the grid-level icons configuration.
|
|
@@ -227,7 +278,7 @@ class _ {
|
|
|
227
278
|
*/
|
|
228
279
|
get gridIcons() {
|
|
229
280
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
230
|
-
return { ...
|
|
281
|
+
return { ...H, ...e };
|
|
231
282
|
}
|
|
232
283
|
/**
|
|
233
284
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -262,26 +313,26 @@ function p(i, e) {
|
|
|
262
313
|
const t = new Set(i);
|
|
263
314
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
264
315
|
}
|
|
265
|
-
function
|
|
316
|
+
function k(i, e) {
|
|
266
317
|
const t = new Set(i);
|
|
267
318
|
return t.add(e), t;
|
|
268
319
|
}
|
|
269
|
-
function
|
|
320
|
+
function L(i, e) {
|
|
270
321
|
const t = new Set(i);
|
|
271
322
|
return t.delete(e), t;
|
|
272
323
|
}
|
|
273
|
-
function
|
|
324
|
+
function T(i, e) {
|
|
274
325
|
return i.has(e);
|
|
275
326
|
}
|
|
276
|
-
function
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
327
|
+
function I(i, e, t, n) {
|
|
328
|
+
const s = document.createElement("div");
|
|
329
|
+
s.className = "master-detail-row", s.setAttribute("data-detail-for", String(e)), s.setAttribute("role", "row");
|
|
330
|
+
const a = document.createElement("div");
|
|
331
|
+
a.className = "master-detail-cell", a.setAttribute("role", "cell"), a.style.gridColumn = `1 / ${n + 1}`;
|
|
281
332
|
const r = t(i, e);
|
|
282
|
-
return typeof r == "string" ?
|
|
333
|
+
return typeof r == "string" ? a.innerHTML = r : r instanceof HTMLElement && a.appendChild(r), s.appendChild(a), s;
|
|
283
334
|
}
|
|
284
|
-
const
|
|
335
|
+
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
336
|
class q extends _ {
|
|
286
337
|
name = "masterDetail";
|
|
287
338
|
version = "1.0.0";
|
|
@@ -338,12 +389,12 @@ class q extends _ {
|
|
|
338
389
|
return;
|
|
339
390
|
}
|
|
340
391
|
}
|
|
341
|
-
const
|
|
342
|
-
|
|
392
|
+
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 = {};
|
|
393
|
+
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
394
|
const u = t.innerHTML.trim();
|
|
344
395
|
u && !this.config.detailRenderer && (d.detailRenderer = (c, h) => {
|
|
345
|
-
const g =
|
|
346
|
-
return
|
|
396
|
+
const g = S(u, { value: c, row: c });
|
|
397
|
+
return y(g);
|
|
347
398
|
}), Object.keys(d).length > 0 && (this.config = { ...this.config, ...d });
|
|
348
399
|
}
|
|
349
400
|
// #endregion
|
|
@@ -418,31 +469,23 @@ class q extends _ {
|
|
|
418
469
|
return [...e];
|
|
419
470
|
const t = [...e];
|
|
420
471
|
if (t.length > 0) {
|
|
421
|
-
const n = { ...t[0] },
|
|
422
|
-
if (
|
|
472
|
+
const n = { ...t[0] }, s = n.viewRenderer;
|
|
473
|
+
if (s?.__masterDetailWrapped)
|
|
423
474
|
return t;
|
|
424
|
-
const
|
|
425
|
-
const { value:
|
|
475
|
+
const a = (r) => {
|
|
476
|
+
const { value: o, row: l } = r, d = this.expandedRows.has(l), u = document.createElement("span");
|
|
426
477
|
u.className = "master-detail-cell-wrapper";
|
|
427
478
|
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);
|
|
479
|
+
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
480
|
const h = document.createElement("span");
|
|
438
|
-
if (
|
|
439
|
-
const g =
|
|
440
|
-
g instanceof Node ? h.appendChild(g) : h.textContent = String(g ??
|
|
481
|
+
if (s) {
|
|
482
|
+
const g = s(r);
|
|
483
|
+
g instanceof Node ? h.appendChild(g) : h.textContent = String(g ?? o ?? "");
|
|
441
484
|
} else
|
|
442
|
-
h.textContent = String(
|
|
485
|
+
h.textContent = String(o ?? "");
|
|
443
486
|
return u.appendChild(h), u;
|
|
444
487
|
};
|
|
445
|
-
|
|
488
|
+
a.__masterDetailWrapped = !0, n.viewRenderer = a, t[0] = n;
|
|
446
489
|
}
|
|
447
490
|
return t;
|
|
448
491
|
}
|
|
@@ -454,7 +497,15 @@ class q extends _ {
|
|
|
454
497
|
expanded: this.expandedRows.has(e.row)
|
|
455
498
|
}), this.requestRender(), !1;
|
|
456
499
|
}
|
|
457
|
-
onCellClick() {
|
|
500
|
+
onCellClick(e) {
|
|
501
|
+
if (e.originalEvent?.target?.classList.contains("master-detail-toggle")) {
|
|
502
|
+
const n = e.row, s = e.rowIndex;
|
|
503
|
+
return this.expandedRows = p(this.expandedRows, n), this.emit("detail-expand", {
|
|
504
|
+
rowIndex: s,
|
|
505
|
+
row: n,
|
|
506
|
+
expanded: this.expandedRows.has(n)
|
|
507
|
+
}), this.requestRender(), !0;
|
|
508
|
+
}
|
|
458
509
|
this.expandedRows.size > 0 && queueMicrotask(() => this.#e());
|
|
459
510
|
}
|
|
460
511
|
afterRender() {
|
|
@@ -475,26 +526,26 @@ class q extends _ {
|
|
|
475
526
|
if (!this.config.detailRenderer) return;
|
|
476
527
|
const e = this.shadowRoot?.querySelector(".rows");
|
|
477
528
|
if (!e) return;
|
|
478
|
-
const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"),
|
|
529
|
+
const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"), s = this.columns.length;
|
|
479
530
|
for (const r of n) {
|
|
480
|
-
const
|
|
481
|
-
|
|
531
|
+
const o = r.querySelector(".cell[data-row]"), l = o ? parseInt(o.getAttribute("data-row") ?? "-1", 10) : -1;
|
|
532
|
+
l >= 0 && t.set(l, r);
|
|
482
533
|
}
|
|
483
|
-
const
|
|
484
|
-
for (const r of
|
|
485
|
-
const
|
|
486
|
-
(!d || !u) && (r.remove(),
|
|
534
|
+
const a = e.querySelectorAll(".master-detail-row");
|
|
535
|
+
for (const r of a) {
|
|
536
|
+
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);
|
|
537
|
+
(!d || !u) && (r.remove(), l && this.detailElements.delete(l));
|
|
487
538
|
}
|
|
488
|
-
for (const [r,
|
|
489
|
-
const
|
|
490
|
-
if (!
|
|
491
|
-
const d = this.detailElements.get(
|
|
539
|
+
for (const [r, o] of t) {
|
|
540
|
+
const l = this.rows[r];
|
|
541
|
+
if (!l || !this.expandedRows.has(l)) continue;
|
|
542
|
+
const d = this.detailElements.get(l);
|
|
492
543
|
if (d) {
|
|
493
|
-
d.previousElementSibling !==
|
|
544
|
+
d.previousElementSibling !== o && o.after(d);
|
|
494
545
|
continue;
|
|
495
546
|
}
|
|
496
|
-
const u =
|
|
497
|
-
typeof this.config.detailHeight == "number" && (u.style.height = `${this.config.detailHeight}px`),
|
|
547
|
+
const u = I(l, r, this.config.detailRenderer, s);
|
|
548
|
+
typeof this.config.detailHeight == "number" && (u.style.height = `${this.config.detailHeight}px`), o.after(u), this.detailElements.set(l, u), this.animateExpand(u);
|
|
498
549
|
}
|
|
499
550
|
}
|
|
500
551
|
/**
|
|
@@ -508,8 +559,8 @@ class q extends _ {
|
|
|
508
559
|
if (n)
|
|
509
560
|
e += n.offsetHeight;
|
|
510
561
|
else {
|
|
511
|
-
const
|
|
512
|
-
e += typeof
|
|
562
|
+
const s = this.config?.detailHeight;
|
|
563
|
+
e += typeof s == "number" ? s : 150;
|
|
513
564
|
}
|
|
514
565
|
}
|
|
515
566
|
return e;
|
|
@@ -521,11 +572,11 @@ class q extends _ {
|
|
|
521
572
|
getExtraHeightBefore(e) {
|
|
522
573
|
let t = 0;
|
|
523
574
|
for (const n of this.expandedRows) {
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
t +=
|
|
575
|
+
const s = this.rows.indexOf(n);
|
|
576
|
+
if (s >= 0 && s < e) {
|
|
577
|
+
const a = this.detailElements.get(n);
|
|
578
|
+
if (a)
|
|
579
|
+
t += a.offsetHeight;
|
|
529
580
|
else {
|
|
530
581
|
const r = this.config?.detailHeight;
|
|
531
582
|
t += typeof r == "number" ? r : 150;
|
|
@@ -540,18 +591,18 @@ class q extends _ {
|
|
|
540
591
|
*/
|
|
541
592
|
adjustVirtualStart(e, t, n) {
|
|
542
593
|
if (this.expandedRows.size === 0) return e;
|
|
543
|
-
const
|
|
544
|
-
for (const
|
|
545
|
-
const
|
|
546
|
-
|
|
594
|
+
const s = [];
|
|
595
|
+
for (const o of this.expandedRows) {
|
|
596
|
+
const l = this.rows.indexOf(o);
|
|
597
|
+
l >= 0 && s.push({ index: l, row: o });
|
|
547
598
|
}
|
|
548
|
-
|
|
549
|
-
let
|
|
550
|
-
for (const { index:
|
|
551
|
-
const d =
|
|
552
|
-
r += c, !(
|
|
599
|
+
s.sort((o, l) => o.index - l.index);
|
|
600
|
+
let a = e, r = 0;
|
|
601
|
+
for (const { index: o, row: l } of s) {
|
|
602
|
+
const d = o * n + r, c = this.detailElements.get(l)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), h = d + n + c;
|
|
603
|
+
r += c, !(o >= e) && h > t && o < a && (a = o);
|
|
553
604
|
}
|
|
554
|
-
return
|
|
605
|
+
return a;
|
|
555
606
|
}
|
|
556
607
|
// #endregion
|
|
557
608
|
// #region Public API
|
|
@@ -561,7 +612,7 @@ class q extends _ {
|
|
|
561
612
|
*/
|
|
562
613
|
expand(e) {
|
|
563
614
|
const t = this.rows[e];
|
|
564
|
-
t && (this.expandedRows =
|
|
615
|
+
t && (this.expandedRows = k(this.expandedRows, t), this.requestRender());
|
|
565
616
|
}
|
|
566
617
|
/**
|
|
567
618
|
* Collapse the detail row at the given index.
|
|
@@ -569,7 +620,7 @@ class q extends _ {
|
|
|
569
620
|
*/
|
|
570
621
|
collapse(e) {
|
|
571
622
|
const t = this.rows[e];
|
|
572
|
-
t && (this.expandedRows =
|
|
623
|
+
t && (this.expandedRows = L(this.expandedRows, t), this.requestRender());
|
|
573
624
|
}
|
|
574
625
|
/**
|
|
575
626
|
* Toggle the detail row at the given index.
|
|
@@ -586,7 +637,7 @@ class q extends _ {
|
|
|
586
637
|
*/
|
|
587
638
|
isExpanded(e) {
|
|
588
639
|
const t = this.rows[e];
|
|
589
|
-
return t ?
|
|
640
|
+
return t ? T(this.expandedRows, t) : !1;
|
|
590
641
|
}
|
|
591
642
|
/**
|
|
592
643
|
* Expand all detail rows.
|
|
@@ -632,11 +683,14 @@ class q extends _ {
|
|
|
632
683
|
*/
|
|
633
684
|
refreshDetailRenderer() {
|
|
634
685
|
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 })
|
|
686
|
+
if (this.config = { ...this.config, detailRenderer: void 0 }, this.parseLightDomDetail(), !this.config.detailRenderer && e && (this.config = { ...this.config, detailRenderer: e }), this.config.detailRenderer) {
|
|
687
|
+
const t = this.grid;
|
|
688
|
+
typeof t.refreshColumns == "function" ? t.refreshColumns() : this.requestRender();
|
|
689
|
+
}
|
|
636
690
|
}
|
|
637
691
|
// #endregion
|
|
638
692
|
// #region Styles
|
|
639
|
-
styles =
|
|
693
|
+
styles = O;
|
|
640
694
|
// #endregion
|
|
641
695
|
}
|
|
642
696
|
export {
|