@toolbox-web/grid 0.3.3 → 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.
Files changed (137) hide show
  1. package/all.d.ts +19 -19
  2. package/all.d.ts.map +1 -1
  3. package/all.js +1775 -1202
  4. package/all.js.map +1 -1
  5. package/index.js +2152 -2028
  6. package/index.js.map +1 -1
  7. package/lib/core/grid.d.ts +22 -12
  8. package/lib/core/grid.d.ts.map +1 -1
  9. package/lib/core/internal/columns.d.ts +0 -9
  10. package/lib/core/internal/columns.d.ts.map +1 -1
  11. package/lib/core/internal/config-manager.d.ts +236 -0
  12. package/lib/core/internal/config-manager.d.ts.map +1 -0
  13. package/lib/core/internal/event-delegation.d.ts.map +1 -1
  14. package/lib/core/internal/header.d.ts.map +1 -1
  15. package/lib/core/internal/keyboard.d.ts.map +1 -1
  16. package/lib/core/internal/render-scheduler.d.ts +123 -0
  17. package/lib/core/internal/render-scheduler.d.ts.map +1 -0
  18. package/lib/core/internal/rows.d.ts +8 -3
  19. package/lib/core/internal/rows.d.ts.map +1 -1
  20. package/lib/core/internal/sanitize.d.ts +2 -2
  21. package/lib/core/internal/sanitize.d.ts.map +1 -1
  22. package/lib/core/internal/shell.d.ts +40 -2
  23. package/lib/core/internal/shell.d.ts.map +1 -1
  24. package/lib/core/internal/validate-config.d.ts +11 -0
  25. package/lib/core/internal/validate-config.d.ts.map +1 -0
  26. package/lib/core/plugin/base-plugin.d.ts +70 -0
  27. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  28. package/lib/core/plugin/plugin-manager.d.ts +13 -2
  29. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  30. package/lib/core/plugin/types.d.ts +17 -3
  31. package/lib/core/plugin/types.d.ts.map +1 -1
  32. package/lib/core/types.d.ts +112 -12
  33. package/lib/core/types.d.ts.map +1 -1
  34. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  35. package/lib/plugins/clipboard/index.js +50 -18
  36. package/lib/plugins/clipboard/index.js.map +1 -1
  37. package/lib/plugins/column-virtualization/index.js +60 -25
  38. package/lib/plugins/column-virtualization/index.js.map +1 -1
  39. package/lib/plugins/context-menu/index.js +51 -16
  40. package/lib/plugins/context-menu/index.js.map +1 -1
  41. package/lib/plugins/editing/EditingPlugin.d.ts +117 -0
  42. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -0
  43. package/lib/{core/internal → plugins/editing}/editors.d.ts +1 -1
  44. package/lib/plugins/editing/editors.d.ts.map +1 -0
  45. package/lib/plugins/editing/index.d.ts +8 -0
  46. package/lib/plugins/editing/index.d.ts.map +1 -0
  47. package/lib/plugins/editing/index.js +705 -0
  48. package/lib/plugins/editing/index.js.map +1 -0
  49. package/lib/plugins/editing/types.d.ts +45 -0
  50. package/lib/plugins/editing/types.d.ts.map +1 -0
  51. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  52. package/lib/plugins/export/index.js +74 -39
  53. package/lib/plugins/export/index.js.map +1 -1
  54. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  55. package/lib/plugins/filtering/index.js +87 -50
  56. package/lib/plugins/filtering/index.js.map +1 -1
  57. package/lib/plugins/grouping-columns/grouping-columns.d.ts +4 -4
  58. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  59. package/lib/plugins/grouping-columns/index.js +59 -24
  60. package/lib/plugins/grouping-columns/index.js.map +1 -1
  61. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  62. package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
  63. package/lib/plugins/grouping-rows/index.js +46 -11
  64. package/lib/plugins/grouping-rows/index.js.map +1 -1
  65. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
  66. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  67. package/lib/plugins/master-detail/index.js +140 -102
  68. package/lib/plugins/master-detail/index.js.map +1 -1
  69. package/lib/plugins/master-detail/types.d.ts +12 -2
  70. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  71. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  72. package/lib/plugins/multi-sort/index.js +59 -22
  73. package/lib/plugins/multi-sort/index.js.map +1 -1
  74. package/lib/plugins/pinned-columns/index.js +41 -6
  75. package/lib/plugins/pinned-columns/index.js.map +1 -1
  76. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  77. package/lib/plugins/pinned-rows/index.js +45 -9
  78. package/lib/plugins/pinned-rows/index.js.map +1 -1
  79. package/lib/plugins/pivot/index.js +42 -7
  80. package/lib/plugins/pivot/index.js.map +1 -1
  81. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  82. package/lib/plugins/reorder/index.js +59 -19
  83. package/lib/plugins/reorder/index.js.map +1 -1
  84. package/lib/plugins/selection/index.js +41 -6
  85. package/lib/plugins/selection/index.js.map +1 -1
  86. package/lib/plugins/server-side/index.js +48 -13
  87. package/lib/plugins/server-side/index.js.map +1 -1
  88. package/lib/plugins/tree/TreePlugin.d.ts +3 -3
  89. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  90. package/lib/plugins/tree/index.js +165 -126
  91. package/lib/plugins/tree/index.js.map +1 -1
  92. package/lib/plugins/tree/tree-data.d.ts +6 -6
  93. package/lib/plugins/tree/tree-data.d.ts.map +1 -1
  94. package/lib/plugins/tree/tree-detect.d.ts +5 -9
  95. package/lib/plugins/tree/tree-detect.d.ts.map +1 -1
  96. package/lib/plugins/tree/types.d.ts +16 -4
  97. package/lib/plugins/tree/types.d.ts.map +1 -1
  98. package/lib/plugins/undo-redo/index.js +46 -11
  99. package/lib/plugins/undo-redo/index.js.map +1 -1
  100. package/lib/plugins/visibility/index.js +37 -2
  101. package/lib/plugins/visibility/index.js.map +1 -1
  102. package/package.json +1 -1
  103. package/public.d.ts +104 -13
  104. package/public.d.ts.map +1 -1
  105. package/umd/grid.all.umd.js +31 -19
  106. package/umd/grid.all.umd.js.map +1 -1
  107. package/umd/grid.umd.js +18 -6
  108. package/umd/grid.umd.js.map +1 -1
  109. package/umd/plugins/clipboard.umd.js +1 -1
  110. package/umd/plugins/clipboard.umd.js.map +1 -1
  111. package/umd/plugins/editing.umd.js +2 -0
  112. package/umd/plugins/editing.umd.js.map +1 -0
  113. package/umd/plugins/export.umd.js +2 -2
  114. package/umd/plugins/export.umd.js.map +1 -1
  115. package/umd/plugins/filtering.umd.js +1 -1
  116. package/umd/plugins/filtering.umd.js.map +1 -1
  117. package/umd/plugins/grouping-columns.umd.js +1 -1
  118. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  119. package/umd/plugins/grouping-rows.umd.js +1 -1
  120. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  121. package/umd/plugins/master-detail.umd.js +1 -1
  122. package/umd/plugins/master-detail.umd.js.map +1 -1
  123. package/umd/plugins/multi-sort.umd.js +1 -1
  124. package/umd/plugins/multi-sort.umd.js.map +1 -1
  125. package/umd/plugins/pinned-rows.umd.js +1 -1
  126. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  127. package/umd/plugins/reorder.umd.js +1 -1
  128. package/umd/plugins/reorder.umd.js.map +1 -1
  129. package/umd/plugins/tree.umd.js +1 -1
  130. package/umd/plugins/tree.umd.js.map +1 -1
  131. package/lib/core/internal/column-state.d.ts +0 -124
  132. package/lib/core/internal/column-state.d.ts.map +0 -1
  133. package/lib/core/internal/editing.d.ts +0 -76
  134. package/lib/core/internal/editing.d.ts.map +0 -1
  135. package/lib/core/internal/editors.d.ts.map +0 -1
  136. package/lib/core/internal/grid-internals.d.ts +0 -83
  137. package/lib/core/internal/grid-internals.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- const R = /{{\s*([^}]+)\s*}}/g, f = "__DG_EMPTY__", x = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, b = /__(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([
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, v = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), y = /^\s*(javascript|vbscript|data|blob):/i;
27
- function S(i) {
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 o = n.tagName.toLowerCase();
37
- if (E.has(o)) {
36
+ const s = n.tagName.toLowerCase();
37
+ if (b.has(s)) {
38
38
  e.push(n);
39
39
  continue;
40
40
  }
41
- if ((o === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
42
- (s) => w.test(s.name) || s.name === "href" || s.name === "xlink:href"
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 l = [];
47
+ const a = [];
48
48
  for (const r of n.attributes) {
49
- const s = r.name.toLowerCase();
50
- if (w.test(s)) {
51
- l.push(r.name);
49
+ const o = r.name.toLowerCase();
50
+ if (w.test(o)) {
51
+ a.push(r.name);
52
52
  continue;
53
53
  }
54
- if (v.has(s) && y.test(r.value)) {
55
- l.push(r.name);
54
+ if (E.has(o) && v.test(r.value)) {
55
+ a.push(r.name);
56
56
  continue;
57
57
  }
58
- if (s === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
59
- l.push(r.name);
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
- l.forEach((r) => n.removeAttribute(r));
63
+ a.forEach((r) => n.removeAttribute(r));
64
64
  }
65
65
  e.forEach((n) => n.remove());
66
66
  }
67
- function A(i, e) {
67
+ function S(i, e) {
68
68
  if (!i || i.indexOf("{{") === -1) return i;
69
- const t = [], n = i.replace(R, (s, a) => {
70
- const d = D(a, e);
71
- return t.push({ expr: a.trim(), result: d }), d;
72
- }), o = H(n), l = t.length && t.every((s) => s.result === "" || s.result === f);
73
- return /Reflect\.|\bProxy\b|ownKeys\(/.test(i) || l ? "" : o;
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 D(i, e) {
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), o = e.row ? e.row[n] : void 0;
80
- return o == null ? f : String(o);
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 || !x.test(i) || b.test(i)) return f;
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 o = new Function("value", "row", `return (${i});`)(e.value, e.row), l = o == null ? "" : String(o);
87
- return /Reflect|Proxy|ownKeys/.test(l) ? f : l || f;
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 H(i) {
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 k = {
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 { ...k, ...e };
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 L(i, e) {
300
+ function k(i, e) {
266
301
  const t = new Set(i);
267
302
  return t.add(e), t;
268
303
  }
269
- function T(i, e) {
304
+ function L(i, e) {
270
305
  const t = new Set(i);
271
306
  return t.delete(e), t;
272
307
  }
273
- function I(i, e) {
308
+ function T(i, e) {
274
309
  return i.has(e);
275
310
  }
276
- function O(i, e, t, n) {
277
- const o = document.createElement("div");
278
- o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
279
- const l = document.createElement("div");
280
- l.className = "master-detail-cell", l.setAttribute("role", "cell"), l.style.gridColumn = `1 / ${n + 1}`;
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" ? l.innerHTML = r : r instanceof HTMLElement && l.appendChild(r), o.appendChild(l), o;
317
+ return typeof r == "string" ? a.innerHTML = r : r instanceof HTMLElement && a.appendChild(r), s.appendChild(a), s;
283
318
  }
284
- const N = ".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}}";
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 o = t.getAttribute("animation"), l = t.getAttribute("show-expand-column"), r = t.getAttribute("expand-on-row-click"), s = t.getAttribute("collapse-on-click-outside"), a = t.getAttribute("height"), d = {};
342
- o !== null && (d.animation = o === "false" ? !1 : o), l !== null && (d.showExpandColumn = l !== "false"), r !== null && (d.expandOnRowClick = r === "true"), s !== null && (d.collapseOnClickOutside = s === "true"), a !== null && (d.detailHeight = a === "auto" ? "auto" : parseInt(a, 10));
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 = A(u, { value: c, row: c });
346
- return S(g);
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] }, o = n.viewRenderer;
422
- if (o?.__masterDetailWrapped)
456
+ const n = { ...t[0] }, s = n.viewRenderer;
457
+ if (s?.__masterDetailWrapped)
423
458
  return t;
424
- const l = (r) => {
425
- const { value: s, row: a } = r, d = this.expandedRows.has(a), u = document.createElement("span");
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"), c.addEventListener("click", (g) => {
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 (o) {
439
- const g = o(r);
440
- g instanceof Node ? h.appendChild(g) : h.textContent = String(g ?? s ?? "");
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(s ?? "");
469
+ h.textContent = String(o ?? "");
443
470
  return u.appendChild(h), u;
444
471
  };
445
- l.__masterDetailWrapped = !0, n.viewRenderer = l, t[0] = n;
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"), o = this.columns.length;
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 s = r.querySelector(".cell[data-row]"), a = s ? parseInt(s.getAttribute("data-row") ?? "-1", 10) : -1;
481
- a >= 0 && t.set(a, r);
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 l = e.querySelectorAll(".master-detail-row");
484
- for (const r of l) {
485
- const s = parseInt(r.getAttribute("data-detail-for") ?? "-1", 10), a = s >= 0 ? this.rows[s] : void 0, d = a && this.expandedRows.has(a), u = t.has(s);
486
- (!d || !u) && (r.remove(), a && this.detailElements.delete(a));
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, s] of t) {
489
- const a = this.rows[r];
490
- if (!a || !this.expandedRows.has(a)) continue;
491
- const d = this.detailElements.get(a);
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 !== s && s.after(d);
528
+ d.previousElementSibling !== o && o.after(d);
494
529
  continue;
495
530
  }
496
- const u = O(a, r, this.config.detailRenderer, o);
497
- typeof this.config.detailHeight == "number" && (u.style.height = `${this.config.detailHeight}px`), s.after(u), this.detailElements.set(a, u), this.animateExpand(u);
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 o = this.config?.detailHeight;
512
- e += typeof o == "number" ? o : 150;
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 o = this.rows.indexOf(n);
525
- if (o >= 0 && o < e) {
526
- const l = this.detailElements.get(n);
527
- if (l)
528
- t += l.offsetHeight;
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 o = [];
544
- for (const s of this.expandedRows) {
545
- const a = this.rows.indexOf(s);
546
- a >= 0 && o.push({ index: a, row: s });
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
- o.sort((s, a) => s.index - a.index);
549
- let l = e, r = 0;
550
- for (const { index: s, row: a } of o) {
551
- const d = s * n + r, c = this.detailElements.get(a)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), h = d + n + c;
552
- r += c, !(s >= e) && h > t && s < l && (l = s);
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 l;
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 = L(this.expandedRows, t), this.requestRender());
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 = T(this.expandedRows, t), this.requestRender());
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 ? I(this.expandedRows, t) : !1;
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 = N;
677
+ styles = O;
640
678
  // #endregion
641
679
  }
642
680
  export {