@toolbox-web/grid 0.4.0 → 0.4.2

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 (161) hide show
  1. package/README.md +10 -13
  2. package/all.js +1124 -1047
  3. package/all.js.map +1 -1
  4. package/index.js +688 -515
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +10 -0
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/config-manager.d.ts +1 -0
  9. package/lib/core/internal/config-manager.d.ts.map +1 -1
  10. package/lib/core/internal/keyboard.d.ts.map +1 -1
  11. package/lib/core/internal/utils.d.ts +1 -0
  12. package/lib/core/internal/utils.d.ts.map +1 -1
  13. package/lib/core/internal/validate-config.d.ts +14 -0
  14. package/lib/core/internal/validate-config.d.ts.map +1 -1
  15. package/lib/core/plugin/base-plugin.d.ts +105 -1
  16. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  17. package/lib/core/plugin/expander-column.d.ts +51 -0
  18. package/lib/core/plugin/expander-column.d.ts.map +1 -0
  19. package/lib/core/plugin/index.d.ts +1 -0
  20. package/lib/core/plugin/index.d.ts.map +1 -1
  21. package/lib/core/plugin/plugin-manager.d.ts +1 -1
  22. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  23. package/lib/core/plugin/types.d.ts +117 -1
  24. package/lib/core/plugin/types.d.ts.map +1 -1
  25. package/lib/core/types.d.ts +4 -2
  26. package/lib/core/types.d.ts.map +1 -1
  27. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +9 -2
  28. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  29. package/lib/plugins/clipboard/index.d.ts +1 -1
  30. package/lib/plugins/clipboard/index.d.ts.map +1 -1
  31. package/lib/plugins/clipboard/index.js +303 -185
  32. package/lib/plugins/clipboard/index.js.map +1 -1
  33. package/lib/plugins/clipboard/types.d.ts +72 -2
  34. package/lib/plugins/clipboard/types.d.ts.map +1 -1
  35. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -1
  36. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
  37. package/lib/plugins/column-virtualization/index.js +116 -24
  38. package/lib/plugins/column-virtualization/index.js.map +1 -1
  39. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +0 -1
  40. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  41. package/lib/plugins/context-menu/index.js +164 -72
  42. package/lib/plugins/context-menu/index.js.map +1 -1
  43. package/lib/plugins/editing/EditingPlugin.d.ts +1 -7
  44. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  45. package/lib/plugins/editing/index.js +213 -133
  46. package/lib/plugins/editing/index.js.map +1 -1
  47. package/lib/plugins/export/ExportPlugin.d.ts +0 -1
  48. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  49. package/lib/plugins/export/index.js +195 -103
  50. package/lib/plugins/export/index.js.map +1 -1
  51. package/lib/plugins/filtering/FilteringPlugin.d.ts +5 -2
  52. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  53. package/lib/plugins/filtering/index.js +145 -43
  54. package/lib/plugins/filtering/index.js.map +1 -1
  55. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -2
  56. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  57. package/lib/plugins/grouping-columns/grouping-columns.d.ts +1 -1
  58. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  59. package/lib/plugins/grouping-columns/index.js +162 -68
  60. package/lib/plugins/grouping-columns/index.js.map +1 -1
  61. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -2
  62. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  63. package/lib/plugins/grouping-rows/index.js +246 -138
  64. package/lib/plugins/grouping-rows/index.js.map +1 -1
  65. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +13 -11
  66. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  67. package/lib/plugins/master-detail/index.js +281 -196
  68. package/lib/plugins/master-detail/index.js.map +1 -1
  69. package/lib/plugins/master-detail/types.d.ts +0 -10
  70. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  71. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +1 -2
  72. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  73. package/lib/plugins/multi-sort/index.js +121 -31
  74. package/lib/plugins/multi-sort/index.js.map +1 -1
  75. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +0 -1
  76. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  77. package/lib/plugins/pinned-columns/index.js +144 -52
  78. package/lib/plugins/pinned-columns/index.js.map +1 -1
  79. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -2
  80. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  81. package/lib/plugins/pinned-rows/index.js +178 -88
  82. package/lib/plugins/pinned-rows/index.js.map +1 -1
  83. package/lib/plugins/pivot/PivotPlugin.d.ts +26 -4
  84. package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
  85. package/lib/plugins/pivot/index.js +414 -310
  86. package/lib/plugins/pivot/index.js.map +1 -1
  87. package/lib/plugins/pivot/pivot-rows.d.ts +2 -1
  88. package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -1
  89. package/lib/plugins/reorder/ReorderPlugin.d.ts +13 -10
  90. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  91. package/lib/plugins/reorder/index.js +304 -226
  92. package/lib/plugins/reorder/index.js.map +1 -1
  93. package/lib/plugins/selection/SelectionPlugin.d.ts +21 -3
  94. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  95. package/lib/plugins/selection/index.d.ts +2 -2
  96. package/lib/plugins/selection/index.d.ts.map +1 -1
  97. package/lib/plugins/selection/index.js +292 -145
  98. package/lib/plugins/selection/index.js.map +1 -1
  99. package/lib/plugins/selection/types.d.ts +24 -0
  100. package/lib/plugins/selection/types.d.ts.map +1 -1
  101. package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -1
  102. package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -1
  103. package/lib/plugins/server-side/index.js +95 -3
  104. package/lib/plugins/server-side/index.js.map +1 -1
  105. package/lib/plugins/tree/TreePlugin.d.ts +5 -1
  106. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  107. package/lib/plugins/tree/index.js +213 -112
  108. package/lib/plugins/tree/index.js.map +1 -1
  109. package/lib/plugins/tree/types.d.ts +0 -10
  110. package/lib/plugins/tree/types.d.ts.map +1 -1
  111. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +7 -2
  112. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  113. package/lib/plugins/undo-redo/index.js +112 -12
  114. package/lib/plugins/undo-redo/index.js.map +1 -1
  115. package/lib/plugins/visibility/VisibilityPlugin.d.ts +14 -5
  116. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  117. package/lib/plugins/visibility/index.js +168 -65
  118. package/lib/plugins/visibility/index.js.map +1 -1
  119. package/package.json +1 -1
  120. package/umd/grid.all.umd.js +21 -17
  121. package/umd/grid.all.umd.js.map +1 -1
  122. package/umd/grid.umd.js +14 -8
  123. package/umd/grid.umd.js.map +1 -1
  124. package/umd/plugins/clipboard.umd.js +5 -7
  125. package/umd/plugins/clipboard.umd.js.map +1 -1
  126. package/umd/plugins/column-virtualization.umd.js +1 -1
  127. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  128. package/umd/plugins/context-menu.umd.js +1 -1
  129. package/umd/plugins/context-menu.umd.js.map +1 -1
  130. package/umd/plugins/editing.umd.js +1 -1
  131. package/umd/plugins/editing.umd.js.map +1 -1
  132. package/umd/plugins/export.umd.js +1 -1
  133. package/umd/plugins/export.umd.js.map +1 -1
  134. package/umd/plugins/filtering.umd.js +1 -1
  135. package/umd/plugins/filtering.umd.js.map +1 -1
  136. package/umd/plugins/grouping-columns.umd.js +1 -1
  137. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  138. package/umd/plugins/grouping-rows.umd.js +1 -1
  139. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  140. package/umd/plugins/master-detail.umd.js +1 -1
  141. package/umd/plugins/master-detail.umd.js.map +1 -1
  142. package/umd/plugins/multi-sort.umd.js +1 -1
  143. package/umd/plugins/multi-sort.umd.js.map +1 -1
  144. package/umd/plugins/pinned-columns.umd.js +1 -1
  145. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  146. package/umd/plugins/pinned-rows.umd.js +1 -1
  147. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  148. package/umd/plugins/pivot.umd.js +1 -1
  149. package/umd/plugins/pivot.umd.js.map +1 -1
  150. package/umd/plugins/reorder.umd.js +1 -1
  151. package/umd/plugins/reorder.umd.js.map +1 -1
  152. package/umd/plugins/selection.umd.js +1 -1
  153. package/umd/plugins/selection.umd.js.map +1 -1
  154. package/umd/plugins/server-side.umd.js +1 -1
  155. package/umd/plugins/server-side.umd.js.map +1 -1
  156. package/umd/plugins/tree.umd.js +1 -1
  157. package/umd/plugins/tree.umd.js.map +1 -1
  158. package/umd/plugins/undo-redo.umd.js +1 -1
  159. package/umd/plugins/undo-redo.umd.js.map +1 -1
  160. package/umd/plugins/visibility.umd.js +1 -1
  161. package/umd/plugins/visibility.umd.js.map +1 -1
@@ -1,4 +1,4 @@
1
- const A = {
1
+ const R = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,9 +8,28 @@ const A = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class R {
12
- /** Plugin version - override in subclass if needed */
13
- version = "1.0.0";
11
+ class A {
12
+ /**
13
+ * Plugin dependencies - declare other plugins this one requires.
14
+ *
15
+ * Dependencies are validated when the plugin is attached.
16
+ * Required dependencies throw an error if missing.
17
+ * Optional dependencies log an info message if missing.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * static readonly dependencies: PluginDependency[] = [
22
+ * { name: 'editing', required: true, reason: 'Tracks cell edits for undo/redo' },
23
+ * { name: 'selection', required: false, reason: 'Enables selection-based undo' },
24
+ * ];
25
+ * ```
26
+ */
27
+ static dependencies;
28
+ /**
29
+ * Plugin version - defaults to grid version for built-in plugins.
30
+ * Third-party plugins can override with their own semver.
31
+ */
32
+ version = typeof __GRID_VERSION__ < "u" ? __GRID_VERSION__ : "dev";
14
33
  /** CSS styles to inject into the grid's shadow DOM */
15
34
  styles;
16
35
  /** Custom cell renderers keyed by type name */
@@ -94,8 +113,16 @@ class R {
94
113
  /**
95
114
  * Emit a custom event from the grid.
96
115
  */
97
- emit(t, n) {
98
- this.grid?.dispatchEvent?.(new CustomEvent(t, { detail: n, bubbles: !0 }));
116
+ emit(t, e) {
117
+ this.grid?.dispatchEvent?.(new CustomEvent(t, { detail: e, bubbles: !0 }));
118
+ }
119
+ /**
120
+ * Emit a cancelable custom event from the grid.
121
+ * @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
122
+ */
123
+ emitCancelable(t, e) {
124
+ const i = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
125
+ return this.grid?.dispatchEvent?.(i), i.defaultPrevented;
99
126
  }
100
127
  /**
101
128
  * Request a re-render of the grid.
@@ -103,6 +130,14 @@ class R {
103
130
  requestRender() {
104
131
  this.grid?.requestRender?.();
105
132
  }
133
+ /**
134
+ * Request a re-render and restore focus styling afterward.
135
+ * Use this when a plugin action (like expand/collapse) triggers a render
136
+ * but needs to maintain keyboard navigation focus.
137
+ */
138
+ requestRenderWithFocus() {
139
+ this.grid?.requestRenderWithFocus?.();
140
+ }
106
141
  /**
107
142
  * Request a lightweight style update without rebuilding DOM.
108
143
  * Use this instead of requestRender() when only CSS classes need updating.
@@ -136,6 +171,19 @@ class R {
136
171
  get visibleColumns() {
137
172
  return this.grid?._visibleColumns ?? [];
138
173
  }
174
+ /**
175
+ * Get the grid as an HTMLElement for direct DOM operations.
176
+ * Use sparingly - prefer the typed GridElementRef API when possible.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * const width = this.gridElement.clientWidth;
181
+ * this.gridElement.classList.add('my-plugin-active');
182
+ * ```
183
+ */
184
+ get gridElement() {
185
+ return this.grid;
186
+ }
139
187
  /**
140
188
  * Get the shadow root of the grid.
141
189
  */
@@ -168,8 +216,53 @@ class R {
168
216
  */
169
217
  get gridIcons() {
170
218
  const t = this.grid?.gridConfig?.icons ?? {};
171
- return { ...A, ...t };
219
+ return { ...R, ...t };
172
220
  }
221
+ // #region Animation Helpers
222
+ /**
223
+ * Check if animations are enabled at the grid level.
224
+ * Respects gridConfig.animation.mode and the CSS variable set by the grid.
225
+ *
226
+ * Plugins should use this to skip animations when:
227
+ * - Animation mode is 'off' or `false`
228
+ * - User prefers reduced motion and mode is 'reduced-motion' (default)
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * private get animationStyle(): 'slide' | 'fade' | false {
233
+ * if (!this.isAnimationEnabled) return false;
234
+ * return this.config.animation ?? 'slide';
235
+ * }
236
+ * ```
237
+ */
238
+ get isAnimationEnabled() {
239
+ const t = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
240
+ if (t === !1 || t === "off") return !1;
241
+ if (t === !0 || t === "on") return !0;
242
+ const e = this.shadowRoot?.host;
243
+ return e ? getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
244
+ }
245
+ /**
246
+ * Get the animation duration in milliseconds from CSS variable.
247
+ * Falls back to 200ms if not set.
248
+ *
249
+ * Plugins can use this for their animation timing to stay consistent
250
+ * with the grid-level animation.duration setting.
251
+ *
252
+ * @example
253
+ * ```ts
254
+ * element.animate(keyframes, { duration: this.animationDuration });
255
+ * ```
256
+ */
257
+ get animationDuration() {
258
+ const t = this.shadowRoot?.host;
259
+ if (t) {
260
+ const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), i = parseInt(e, 10);
261
+ if (!isNaN(i)) return i;
262
+ }
263
+ return 200;
264
+ }
265
+ // #endregion
173
266
  /**
174
267
  * Resolve an icon value to string or HTMLElement.
175
268
  * Checks plugin config first, then grid-level icons, then defaults.
@@ -178,8 +271,8 @@ class R {
178
271
  * @param pluginOverride - Optional plugin-level override
179
272
  * @returns The resolved icon value
180
273
  */
181
- resolveIcon(t, n) {
182
- return n !== void 0 ? n : this.gridIcons[t];
274
+ resolveIcon(t, e) {
275
+ return e !== void 0 ? e : this.gridIcons[t];
183
276
  }
184
277
  /**
185
278
  * Set an icon value on an element.
@@ -188,8 +281,8 @@ class R {
188
281
  * @param element - The element to set the icon on
189
282
  * @param icon - The icon value (string or HTMLElement)
190
283
  */
191
- setIcon(t, n) {
192
- typeof n == "string" ? t.innerHTML = n : n instanceof HTMLElement && (t.innerHTML = "", t.appendChild(n.cloneNode(!0)));
284
+ setIcon(t, e) {
285
+ typeof e == "string" ? t.innerHTML = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
193
286
  }
194
287
  /**
195
288
  * Log a warning message.
@@ -200,87 +293,87 @@ class R {
200
293
  // #endregion
201
294
  }
202
295
  const p = {
203
- sum: (e, t) => e.reduce((n, i) => n + (Number(i[t]) || 0), 0),
204
- avg: (e, t) => {
205
- const n = e.reduce((i, r) => i + (Number(r[t]) || 0), 0);
206
- return e.length ? n / e.length : 0;
296
+ sum: (n, t) => n.reduce((e, i) => e + (Number(i[t]) || 0), 0),
297
+ avg: (n, t) => {
298
+ const e = n.reduce((i, r) => i + (Number(r[t]) || 0), 0);
299
+ return n.length ? e / n.length : 0;
207
300
  },
208
- count: (e) => e.length,
209
- min: (e, t) => Math.min(...e.map((n) => Number(n[t]) || 1 / 0)),
210
- max: (e, t) => Math.max(...e.map((n) => Number(n[t]) || -1 / 0)),
211
- first: (e, t) => e[0]?.[t],
212
- last: (e, t) => e[e.length - 1]?.[t]
213
- }, u = /* @__PURE__ */ new Map(), d = {
301
+ count: (n) => n.length,
302
+ min: (n, t) => Math.min(...n.map((e) => Number(e[t]) || 1 / 0)),
303
+ max: (n, t) => Math.max(...n.map((e) => Number(e[t]) || -1 / 0)),
304
+ first: (n, t) => n[0]?.[t],
305
+ last: (n, t) => n[n.length - 1]?.[t]
306
+ }, f = /* @__PURE__ */ new Map(), d = {
214
307
  /**
215
308
  * Register a custom aggregator function.
216
309
  */
217
- register(e, t) {
218
- u.set(e, t);
310
+ register(n, t) {
311
+ f.set(n, t);
219
312
  },
220
313
  /**
221
314
  * Unregister a custom aggregator function.
222
315
  */
223
- unregister(e) {
224
- u.delete(e);
316
+ unregister(n) {
317
+ f.delete(n);
225
318
  },
226
319
  /**
227
320
  * Get an aggregator function by reference.
228
321
  */
229
- get(e) {
230
- if (e !== void 0)
231
- return typeof e == "function" ? e : u.get(e) ?? p[e];
322
+ get(n) {
323
+ if (n !== void 0)
324
+ return typeof n == "function" ? n : f.get(n) ?? p[n];
232
325
  },
233
326
  /**
234
327
  * Run an aggregator on a set of rows.
235
328
  */
236
- run(e, t, n, i) {
237
- const r = this.get(e);
238
- return r ? r(t, n, i) : void 0;
329
+ run(n, t, e, i) {
330
+ const r = this.get(n);
331
+ return r ? r(t, e, i) : void 0;
239
332
  },
240
333
  /**
241
334
  * Check if an aggregator exists.
242
335
  */
243
- has(e) {
244
- return u.has(e) || e in p;
336
+ has(n) {
337
+ return f.has(n) || n in p;
245
338
  },
246
339
  /**
247
340
  * List all available aggregator names.
248
341
  */
249
342
  list() {
250
- return [...Object.keys(p), ...u.keys()];
343
+ return [...Object.keys(p), ...f.keys()];
251
344
  }
252
345
  };
253
346
  d.register.bind(d);
254
347
  d.unregister.bind(d);
255
- const w = d.get.bind(d);
348
+ const b = d.get.bind(d);
256
349
  d.run.bind(d);
257
350
  d.list.bind(d);
258
- function E(e) {
259
- return typeof e == "object" && e !== null && "aggFunc" in e;
351
+ function E(n) {
352
+ return typeof n == "object" && n !== null && "aggFunc" in n;
260
353
  }
261
- function m(e, t) {
262
- const n = document.createElement("div");
263
- n.className = "tbw-pinned-rows", n.setAttribute("role", "presentation"), n.setAttribute("aria-live", "polite");
354
+ function m(n, t) {
355
+ const e = document.createElement("div");
356
+ e.className = "tbw-pinned-rows", e.setAttribute("role", "presentation"), e.setAttribute("aria-live", "polite");
264
357
  const i = document.createElement("div");
265
358
  i.className = "tbw-pinned-rows-left";
266
359
  const r = document.createElement("div");
267
360
  r.className = "tbw-pinned-rows-center";
268
361
  const s = document.createElement("div");
269
- if (s.className = "tbw-pinned-rows-right", e.showRowCount !== !1) {
362
+ if (s.className = "tbw-pinned-rows-right", n.showRowCount !== !1) {
270
363
  const o = document.createElement("span");
271
364
  o.className = "tbw-status-panel tbw-status-panel-row-count", o.textContent = `Total: ${t.totalRows} rows`, i.appendChild(o);
272
365
  }
273
- if (e.showFilteredCount && t.filteredRows !== t.totalRows) {
366
+ if (n.showFilteredCount && t.filteredRows !== t.totalRows) {
274
367
  const o = document.createElement("span");
275
368
  o.className = "tbw-status-panel tbw-status-panel-filtered-count", o.textContent = `Filtered: ${t.filteredRows}`, i.appendChild(o);
276
369
  }
277
- if (e.showSelectedCount && t.selectedRows > 0) {
370
+ if (n.showSelectedCount && t.selectedRows > 0) {
278
371
  const o = document.createElement("span");
279
372
  o.className = "tbw-status-panel tbw-status-panel-selected-count", o.textContent = `Selected: ${t.selectedRows}`, s.appendChild(o);
280
373
  }
281
- if (e.customPanels)
282
- for (const o of e.customPanels) {
283
- const a = x(o, t);
374
+ if (n.customPanels)
375
+ for (const o of n.customPanels) {
376
+ const a = y(o, t);
284
377
  switch (o.position) {
285
378
  case "left":
286
379
  i.appendChild(a);
@@ -293,62 +386,62 @@ function m(e, t) {
293
386
  break;
294
387
  }
295
388
  }
296
- return n.appendChild(i), n.appendChild(r), n.appendChild(s), n;
389
+ return e.appendChild(i), e.appendChild(r), e.appendChild(s), e;
297
390
  }
298
- function b(e) {
391
+ function w(n) {
299
392
  const t = document.createElement("div");
300
- return t.className = `tbw-aggregation-rows tbw-aggregation-rows-${e}`, t.setAttribute("role", "presentation"), t;
393
+ return t.className = `tbw-aggregation-rows tbw-aggregation-rows-${n}`, t.setAttribute("role", "presentation"), t;
301
394
  }
302
- function C(e, t, n, i) {
303
- e.innerHTML = "";
395
+ function C(n, t, e, i) {
396
+ n.innerHTML = "";
304
397
  for (const r of t) {
305
398
  const s = document.createElement("div");
306
399
  if (s.className = "tbw-aggregation-row", s.setAttribute("role", "presentation"), r.id && s.setAttribute("data-aggregation-id", r.id), r.fullWidth) {
307
400
  const o = document.createElement("div");
308
401
  o.className = "tbw-aggregation-cell tbw-aggregation-cell-full", o.style.gridColumn = "1 / -1", o.textContent = r.label || "", s.appendChild(o);
309
402
  } else
310
- for (const o of n) {
403
+ for (const o of e) {
311
404
  const a = document.createElement("div");
312
405
  a.className = "tbw-aggregation-cell", a.setAttribute("data-field", o.field);
313
- let l, f;
406
+ let l, u;
314
407
  const h = r.aggregators?.[o.field];
315
408
  if (h)
316
409
  if (E(h)) {
317
- const g = w(h.aggFunc);
318
- g && (l = g(i, o.field, o)), f = h.formatter;
410
+ const g = b(h.aggFunc);
411
+ g && (l = g(i, o.field, o)), u = h.formatter;
319
412
  } else {
320
- const g = w(h);
413
+ const g = b(h);
321
414
  g && (l = g(i, o.field, o));
322
415
  }
323
416
  else if (r.cells && Object.prototype.hasOwnProperty.call(r.cells, o.field)) {
324
417
  const g = r.cells[o.field];
325
418
  typeof g == "function" ? l = g(i, o.field, o) : l = g;
326
419
  }
327
- l != null ? a.textContent = f ? f(l, o.field, o) : String(l) : a.textContent = "", s.appendChild(a);
420
+ l != null ? a.textContent = u ? u(l, o.field, o) : String(l) : a.textContent = "", s.appendChild(a);
328
421
  }
329
- e.appendChild(s);
422
+ n.appendChild(s);
330
423
  }
331
424
  }
332
- function x(e, t) {
333
- const n = document.createElement("div");
334
- n.className = "tbw-status-panel tbw-status-panel-custom", n.id = `status-panel-${e.id}`;
335
- const i = e.render(t);
336
- return typeof i == "string" ? n.innerHTML = i : n.appendChild(i), n;
425
+ function y(n, t) {
426
+ const e = document.createElement("div");
427
+ e.className = "tbw-status-panel tbw-status-panel-custom", e.id = `status-panel-${n.id}`;
428
+ const i = n.render(t);
429
+ return typeof i == "string" ? e.innerHTML = i : e.appendChild(i), e;
337
430
  }
338
- function v(e, t, n, i, r) {
431
+ function v(n, t, e, i, r) {
339
432
  return {
340
- totalRows: e.length,
341
- filteredRows: r?.cachedResult?.length ?? e.length,
433
+ totalRows: n.length,
434
+ filteredRows: r?.cachedResult?.length ?? n.length,
342
435
  selectedRows: i?.selected?.size ?? 0,
343
436
  columns: t,
344
- rows: e,
345
- grid: n
437
+ rows: n,
438
+ grid: e
346
439
  };
347
440
  }
348
- const B = ".tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:12px;color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:16px}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, 2px 8px);min-height:var(--tbw-row-height, 28px);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}";
349
- class y extends R {
441
+ const S = ".tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:12px;color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:16px}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, 2px 8px);min-height:var(--tbw-row-height, 28px);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}";
442
+ class x extends A {
350
443
  name = "pinnedRows";
351
- version = "1.0.0";
444
+ styles = S;
352
445
  get defaultConfig() {
353
446
  return {
354
447
  position: "bottom",
@@ -372,9 +465,9 @@ class y extends R {
372
465
  afterRender() {
373
466
  const t = this.shadowRoot;
374
467
  if (!t) return;
375
- const n = t.querySelector(".tbw-scroll-area") ?? t.querySelector(".tbw-grid-content") ?? t.children[0];
376
- if (!n) return;
377
- this.footerWrapper && !n.contains(this.footerWrapper) && (this.footerWrapper = null, this.bottomAggregationContainer = null, this.infoBarElement = null), this.topAggregationContainer && !n.contains(this.topAggregationContainer) && (this.topAggregationContainer = null), this.infoBarElement && !n.contains(this.infoBarElement) && (this.infoBarElement = null);
468
+ const e = t.querySelector(".tbw-scroll-area") ?? t.querySelector(".tbw-grid-content") ?? t.children[0];
469
+ if (!e) return;
470
+ this.footerWrapper && !e.contains(this.footerWrapper) && (this.footerWrapper = null, this.bottomAggregationContainer = null, this.infoBarElement = null), this.topAggregationContainer && !e.contains(this.topAggregationContainer) && (this.topAggregationContainer = null), this.infoBarElement && !e.contains(this.infoBarElement) && (this.infoBarElement = null);
378
471
  const i = this.getSelectionState(), r = this.getFilterState(), s = v(
379
472
  this.rows,
380
473
  this.columns,
@@ -384,9 +477,9 @@ class y extends R {
384
477
  ), o = this.config.aggregationRows || [], a = o.filter((c) => c.position === "top"), l = o.filter((c) => c.position !== "top");
385
478
  if (a.length > 0) {
386
479
  if (!this.topAggregationContainer) {
387
- this.topAggregationContainer = b("top");
480
+ this.topAggregationContainer = w("top");
388
481
  const c = t.querySelector(".header");
389
- c && c.nextSibling ? n.insertBefore(this.topAggregationContainer, c.nextSibling) : n.appendChild(this.topAggregationContainer);
482
+ c && c.nextSibling ? e.insertBefore(this.topAggregationContainer, c.nextSibling) : e.appendChild(this.topAggregationContainer);
390
483
  }
391
484
  C(
392
485
  this.topAggregationContainer,
@@ -395,16 +488,16 @@ class y extends R {
395
488
  this.rows
396
489
  );
397
490
  } else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
398
- const f = this.config.showRowCount !== !1 || this.config.showSelectedCount && s.selectedRows > 0 || this.config.showFilteredCount && s.filteredRows !== s.totalRows || this.config.customPanels && this.config.customPanels.length > 0, h = f && this.config.position !== "top", g = l.length > 0 || h;
399
- if (f && this.config.position === "top")
491
+ const u = this.config.showRowCount !== !1 || this.config.showSelectedCount && s.selectedRows > 0 || this.config.showFilteredCount && s.filteredRows !== s.totalRows || this.config.customPanels && this.config.customPanels.length > 0, h = u && this.config.position !== "top", g = l.length > 0 || h;
492
+ if (u && this.config.position === "top")
400
493
  if (!this.infoBarElement)
401
- this.infoBarElement = m(this.config, s), n.insertBefore(this.infoBarElement, n.firstChild);
494
+ this.infoBarElement = m(this.config, s), e.insertBefore(this.infoBarElement, e.firstChild);
402
495
  else {
403
496
  const c = m(this.config, s);
404
497
  this.infoBarElement.replaceWith(c), this.infoBarElement = c;
405
498
  }
406
499
  else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
407
- g ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", n.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", l.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = b("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), C(
500
+ g ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", e.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", l.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = w("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), C(
408
501
  this.bottomAggregationContainer,
409
502
  l,
410
503
  this.visibleColumns,
@@ -446,13 +539,13 @@ class y extends R {
446
539
  * @returns The context with row counts and other info
447
540
  */
448
541
  getContext() {
449
- const t = this.getSelectionState(), n = this.getFilterState();
542
+ const t = this.getSelectionState(), e = this.getFilterState();
450
543
  return v(
451
544
  this.rows,
452
545
  this.columns,
453
546
  this.grid,
454
547
  t,
455
- n
548
+ e
456
549
  );
457
550
  }
458
551
  /**
@@ -467,7 +560,7 @@ class y extends R {
467
560
  * @param id - The panel ID to remove
468
561
  */
469
562
  removePanel(t) {
470
- this.config.customPanels && (this.config.customPanels = this.config.customPanels.filter((n) => n.id !== t), this.requestRender());
563
+ this.config.customPanels && (this.config.customPanels = this.config.customPanels.filter((e) => e.id !== t), this.requestRender());
471
564
  }
472
565
  /**
473
566
  * Add an aggregation row.
@@ -481,14 +574,11 @@ class y extends R {
481
574
  * @param id - The aggregation row ID to remove
482
575
  */
483
576
  removeAggregationRow(t) {
484
- this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((n) => n.id !== t), this.requestRender());
577
+ this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((e) => e.id !== t), this.requestRender());
485
578
  }
486
579
  // #endregion
487
- // #region Styles
488
- styles = B;
489
- // #endregion
490
580
  }
491
581
  export {
492
- y as PinnedRowsPlugin
582
+ x as PinnedRowsPlugin
493
583
  };
494
584
  //# sourceMappingURL=index.js.map