@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.
Files changed (148) hide show
  1. package/all.d.ts +19 -19
  2. package/all.d.ts.map +1 -1
  3. package/all.js +1798 -1201
  4. package/all.js.map +1 -1
  5. package/index.js +2215 -2026
  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/editing.d.ts +3 -3
  14. package/lib/core/internal/editing.d.ts.map +1 -1
  15. package/lib/core/internal/event-delegation.d.ts.map +1 -1
  16. package/lib/core/internal/header.d.ts.map +1 -1
  17. package/lib/core/internal/keyboard.d.ts.map +1 -1
  18. package/lib/core/internal/render-scheduler.d.ts +123 -0
  19. package/lib/core/internal/render-scheduler.d.ts.map +1 -0
  20. package/lib/core/internal/rows.d.ts +8 -3
  21. package/lib/core/internal/rows.d.ts.map +1 -1
  22. package/lib/core/internal/sanitize.d.ts +2 -2
  23. package/lib/core/internal/sanitize.d.ts.map +1 -1
  24. package/lib/core/internal/shell.d.ts +40 -2
  25. package/lib/core/internal/shell.d.ts.map +1 -1
  26. package/lib/core/internal/validate-config.d.ts +25 -0
  27. package/lib/core/internal/validate-config.d.ts.map +1 -0
  28. package/lib/core/plugin/base-plugin.d.ts +118 -0
  29. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  30. package/lib/core/plugin/index.d.ts +1 -0
  31. package/lib/core/plugin/index.d.ts.map +1 -1
  32. package/lib/core/plugin/plugin-manager.d.ts +13 -2
  33. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  34. package/lib/core/plugin/types.d.ts +17 -3
  35. package/lib/core/plugin/types.d.ts.map +1 -1
  36. package/lib/core/types.d.ts +112 -12
  37. package/lib/core/types.d.ts.map +1 -1
  38. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +7 -1
  39. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  40. package/lib/plugins/clipboard/index.js +78 -22
  41. package/lib/plugins/clipboard/index.js.map +1 -1
  42. package/lib/plugins/column-virtualization/index.js +72 -21
  43. package/lib/plugins/column-virtualization/index.js.map +1 -1
  44. package/lib/plugins/context-menu/index.js +53 -2
  45. package/lib/plugins/context-menu/index.js.map +1 -1
  46. package/lib/plugins/editing/EditingPlugin.d.ts +117 -0
  47. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -0
  48. package/lib/{core/internal → plugins/editing}/editors.d.ts +1 -1
  49. package/lib/plugins/editing/editors.d.ts.map +1 -0
  50. package/lib/plugins/editing/index.d.ts +8 -0
  51. package/lib/plugins/editing/index.d.ts.map +1 -0
  52. package/lib/plugins/editing/index.js +721 -0
  53. package/lib/plugins/editing/index.js.map +1 -0
  54. package/lib/plugins/editing/types.d.ts +45 -0
  55. package/lib/plugins/editing/types.d.ts.map +1 -0
  56. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  57. package/lib/plugins/export/index.js +68 -17
  58. package/lib/plugins/export/index.js.map +1 -1
  59. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  60. package/lib/plugins/filtering/index.js +103 -50
  61. package/lib/plugins/filtering/index.js.map +1 -1
  62. package/lib/plugins/grouping-columns/grouping-columns.d.ts +4 -4
  63. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  64. package/lib/plugins/grouping-columns/index.js +80 -29
  65. package/lib/plugins/grouping-columns/index.js.map +1 -1
  66. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  67. package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
  68. package/lib/plugins/grouping-rows/index.js +62 -11
  69. package/lib/plugins/grouping-rows/index.js.map +1 -1
  70. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
  71. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  72. package/lib/plugins/master-detail/index.js +156 -102
  73. package/lib/plugins/master-detail/index.js.map +1 -1
  74. package/lib/plugins/master-detail/types.d.ts +12 -2
  75. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  76. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  77. package/lib/plugins/multi-sort/index.js +75 -22
  78. package/lib/plugins/multi-sort/index.js.map +1 -1
  79. package/lib/plugins/pinned-columns/index.js +57 -6
  80. package/lib/plugins/pinned-columns/index.js.map +1 -1
  81. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  82. package/lib/plugins/pinned-rows/index.js +61 -9
  83. package/lib/plugins/pinned-rows/index.js.map +1 -1
  84. package/lib/plugins/pivot/index.js +58 -7
  85. package/lib/plugins/pivot/index.js.map +1 -1
  86. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  87. package/lib/plugins/reorder/index.js +75 -19
  88. package/lib/plugins/reorder/index.js.map +1 -1
  89. package/lib/plugins/selection/index.js +57 -6
  90. package/lib/plugins/selection/index.js.map +1 -1
  91. package/lib/plugins/server-side/index.js +60 -9
  92. package/lib/plugins/server-side/index.js.map +1 -1
  93. package/lib/plugins/tree/TreePlugin.d.ts +3 -3
  94. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  95. package/lib/plugins/tree/index.js +181 -126
  96. package/lib/plugins/tree/index.js.map +1 -1
  97. package/lib/plugins/tree/tree-data.d.ts +6 -6
  98. package/lib/plugins/tree/tree-data.d.ts.map +1 -1
  99. package/lib/plugins/tree/tree-detect.d.ts +5 -9
  100. package/lib/plugins/tree/tree-detect.d.ts.map +1 -1
  101. package/lib/plugins/tree/types.d.ts +16 -4
  102. package/lib/plugins/tree/types.d.ts.map +1 -1
  103. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +7 -1
  104. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  105. package/lib/plugins/undo-redo/index.js +65 -6
  106. package/lib/plugins/undo-redo/index.js.map +1 -1
  107. package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -1
  108. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  109. package/lib/plugins/visibility/index.js +61 -2
  110. package/lib/plugins/visibility/index.js.map +1 -1
  111. package/package.json +1 -1
  112. package/public.d.ts +104 -13
  113. package/public.d.ts.map +1 -1
  114. package/umd/grid.all.umd.js +37 -19
  115. package/umd/grid.all.umd.js.map +1 -1
  116. package/umd/grid.umd.js +25 -7
  117. package/umd/grid.umd.js.map +1 -1
  118. package/umd/plugins/clipboard.umd.js +2 -2
  119. package/umd/plugins/clipboard.umd.js.map +1 -1
  120. package/umd/plugins/editing.umd.js +2 -0
  121. package/umd/plugins/editing.umd.js.map +1 -0
  122. package/umd/plugins/export.umd.js +2 -2
  123. package/umd/plugins/export.umd.js.map +1 -1
  124. package/umd/plugins/filtering.umd.js +1 -1
  125. package/umd/plugins/filtering.umd.js.map +1 -1
  126. package/umd/plugins/grouping-columns.umd.js +1 -1
  127. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  128. package/umd/plugins/grouping-rows.umd.js +1 -1
  129. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  130. package/umd/plugins/master-detail.umd.js +1 -1
  131. package/umd/plugins/master-detail.umd.js.map +1 -1
  132. package/umd/plugins/multi-sort.umd.js +1 -1
  133. package/umd/plugins/multi-sort.umd.js.map +1 -1
  134. package/umd/plugins/pinned-rows.umd.js +1 -1
  135. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  136. package/umd/plugins/reorder.umd.js +1 -1
  137. package/umd/plugins/reorder.umd.js.map +1 -1
  138. package/umd/plugins/tree.umd.js +1 -1
  139. package/umd/plugins/tree.umd.js.map +1 -1
  140. package/umd/plugins/undo-redo.umd.js +1 -1
  141. package/umd/plugins/undo-redo.umd.js.map +1 -1
  142. package/umd/plugins/visibility.umd.js +1 -1
  143. package/umd/plugins/visibility.umd.js.map +1 -1
  144. package/lib/core/internal/column-state.d.ts +0 -124
  145. package/lib/core/internal/column-state.d.ts.map +0 -1
  146. package/lib/core/internal/editors.d.ts.map +0 -1
  147. package/lib/core/internal/grid-internals.d.ts +0 -83
  148. 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: "▲",
@@ -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 { ...k, ...e };
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 L(i, e) {
316
+ function k(i, e) {
266
317
  const t = new Set(i);
267
318
  return t.add(e), t;
268
319
  }
269
- function T(i, e) {
320
+ function L(i, e) {
270
321
  const t = new Set(i);
271
322
  return t.delete(e), t;
272
323
  }
273
- function I(i, e) {
324
+ function T(i, e) {
274
325
  return i.has(e);
275
326
  }
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}`;
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" ? l.innerHTML = r : r instanceof HTMLElement && l.appendChild(r), o.appendChild(l), o;
333
+ return typeof r == "string" ? a.innerHTML = r : r instanceof HTMLElement && a.appendChild(r), s.appendChild(a), s;
283
334
  }
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}}";
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 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));
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 = A(u, { value: c, row: c });
346
- return S(g);
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] }, o = n.viewRenderer;
422
- if (o?.__masterDetailWrapped)
472
+ const n = { ...t[0] }, s = n.viewRenderer;
473
+ if (s?.__masterDetailWrapped)
423
474
  return t;
424
- const l = (r) => {
425
- const { value: s, row: a } = r, d = this.expandedRows.has(a), u = document.createElement("span");
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"), 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);
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 (o) {
439
- const g = o(r);
440
- g instanceof Node ? h.appendChild(g) : h.textContent = String(g ?? s ?? "");
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(s ?? "");
485
+ h.textContent = String(o ?? "");
443
486
  return u.appendChild(h), u;
444
487
  };
445
- l.__masterDetailWrapped = !0, n.viewRenderer = l, t[0] = n;
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"), o = this.columns.length;
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 s = r.querySelector(".cell[data-row]"), a = s ? parseInt(s.getAttribute("data-row") ?? "-1", 10) : -1;
481
- a >= 0 && t.set(a, r);
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 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));
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, s] of t) {
489
- const a = this.rows[r];
490
- if (!a || !this.expandedRows.has(a)) continue;
491
- const d = this.detailElements.get(a);
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 !== s && s.after(d);
544
+ d.previousElementSibling !== o && o.after(d);
494
545
  continue;
495
546
  }
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);
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 o = this.config?.detailHeight;
512
- e += typeof o == "number" ? o : 150;
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 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;
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 o = [];
544
- for (const s of this.expandedRows) {
545
- const a = this.rows.indexOf(s);
546
- a >= 0 && o.push({ index: a, row: s });
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
- 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);
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 l;
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 = L(this.expandedRows, t), this.requestRender());
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 = T(this.expandedRows, t), this.requestRender());
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 ? I(this.expandedRows, t) : !1;
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 = N;
693
+ styles = O;
640
694
  // #endregion
641
695
  }
642
696
  export {