@toolbox-web/grid 0.4.1 → 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 (157) hide show
  1. package/README.md +10 -13
  2. package/all.js +1101 -1048
  3. package/all.js.map +1 -1
  4. package/index.js +245 -137
  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/plugin/base-plugin.d.ts +57 -1
  14. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  15. package/lib/core/plugin/expander-column.d.ts +51 -0
  16. package/lib/core/plugin/expander-column.d.ts.map +1 -0
  17. package/lib/core/plugin/types.d.ts +117 -1
  18. package/lib/core/plugin/types.d.ts.map +1 -1
  19. package/lib/core/types.d.ts +4 -2
  20. package/lib/core/types.d.ts.map +1 -1
  21. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +5 -4
  22. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  23. package/lib/plugins/clipboard/index.d.ts +1 -1
  24. package/lib/plugins/clipboard/index.d.ts.map +1 -1
  25. package/lib/plugins/clipboard/index.js +282 -188
  26. package/lib/plugins/clipboard/index.js.map +1 -1
  27. package/lib/plugins/clipboard/types.d.ts +72 -2
  28. package/lib/plugins/clipboard/types.d.ts.map +1 -1
  29. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -1
  30. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
  31. package/lib/plugins/column-virtualization/index.js +102 -26
  32. package/lib/plugins/column-virtualization/index.js.map +1 -1
  33. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +0 -1
  34. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  35. package/lib/plugins/context-menu/index.js +154 -78
  36. package/lib/plugins/context-menu/index.js.map +1 -1
  37. package/lib/plugins/editing/EditingPlugin.d.ts +1 -7
  38. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  39. package/lib/plugins/editing/index.js +200 -136
  40. package/lib/plugins/editing/index.js.map +1 -1
  41. package/lib/plugins/export/ExportPlugin.d.ts +0 -1
  42. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  43. package/lib/plugins/export/index.js +175 -99
  44. package/lib/plugins/export/index.js.map +1 -1
  45. package/lib/plugins/filtering/FilteringPlugin.d.ts +5 -2
  46. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  47. package/lib/plugins/filtering/index.js +129 -43
  48. package/lib/plugins/filtering/index.js.map +1 -1
  49. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -2
  50. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  51. package/lib/plugins/grouping-columns/grouping-columns.d.ts +1 -1
  52. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  53. package/lib/plugins/grouping-columns/index.js +144 -66
  54. package/lib/plugins/grouping-columns/index.js.map +1 -1
  55. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -2
  56. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  57. package/lib/plugins/grouping-rows/index.js +230 -138
  58. package/lib/plugins/grouping-rows/index.js.map +1 -1
  59. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +13 -11
  60. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  61. package/lib/plugins/master-detail/index.js +265 -196
  62. package/lib/plugins/master-detail/index.js.map +1 -1
  63. package/lib/plugins/master-detail/types.d.ts +0 -10
  64. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  65. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +1 -2
  66. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  67. package/lib/plugins/multi-sort/index.js +105 -31
  68. package/lib/plugins/multi-sort/index.js.map +1 -1
  69. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +0 -1
  70. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  71. package/lib/plugins/pinned-columns/index.js +128 -52
  72. package/lib/plugins/pinned-columns/index.js.map +1 -1
  73. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -2
  74. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  75. package/lib/plugins/pinned-rows/index.js +162 -88
  76. package/lib/plugins/pinned-rows/index.js.map +1 -1
  77. package/lib/plugins/pivot/PivotPlugin.d.ts +26 -4
  78. package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
  79. package/lib/plugins/pivot/index.js +398 -310
  80. package/lib/plugins/pivot/index.js.map +1 -1
  81. package/lib/plugins/pivot/pivot-rows.d.ts +2 -1
  82. package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -1
  83. package/lib/plugins/reorder/ReorderPlugin.d.ts +13 -10
  84. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  85. package/lib/plugins/reorder/index.js +288 -226
  86. package/lib/plugins/reorder/index.js.map +1 -1
  87. package/lib/plugins/selection/SelectionPlugin.d.ts +21 -3
  88. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  89. package/lib/plugins/selection/index.d.ts +2 -2
  90. package/lib/plugins/selection/index.d.ts.map +1 -1
  91. package/lib/plugins/selection/index.js +276 -145
  92. package/lib/plugins/selection/index.js.map +1 -1
  93. package/lib/plugins/selection/types.d.ts +24 -0
  94. package/lib/plugins/selection/types.d.ts.map +1 -1
  95. package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -1
  96. package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -1
  97. package/lib/plugins/server-side/index.js +83 -7
  98. package/lib/plugins/server-side/index.js.map +1 -1
  99. package/lib/plugins/tree/TreePlugin.d.ts +5 -1
  100. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  101. package/lib/plugins/tree/index.js +197 -112
  102. package/lib/plugins/tree/index.js.map +1 -1
  103. package/lib/plugins/tree/types.d.ts +0 -10
  104. package/lib/plugins/tree/types.d.ts.map +1 -1
  105. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +0 -1
  106. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  107. package/lib/plugins/undo-redo/index.js +93 -17
  108. package/lib/plugins/undo-redo/index.js.map +1 -1
  109. package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -4
  110. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  111. package/lib/plugins/visibility/index.js +144 -65
  112. package/lib/plugins/visibility/index.js.map +1 -1
  113. package/package.json +1 -1
  114. package/umd/grid.all.umd.js +17 -19
  115. package/umd/grid.all.umd.js.map +1 -1
  116. package/umd/grid.umd.js +7 -7
  117. package/umd/grid.umd.js.map +1 -1
  118. package/umd/plugins/clipboard.umd.js +5 -7
  119. package/umd/plugins/clipboard.umd.js.map +1 -1
  120. package/umd/plugins/column-virtualization.umd.js +1 -1
  121. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  122. package/umd/plugins/context-menu.umd.js +1 -1
  123. package/umd/plugins/context-menu.umd.js.map +1 -1
  124. package/umd/plugins/editing.umd.js +1 -1
  125. package/umd/plugins/editing.umd.js.map +1 -1
  126. package/umd/plugins/export.umd.js +1 -1
  127. package/umd/plugins/export.umd.js.map +1 -1
  128. package/umd/plugins/filtering.umd.js +1 -1
  129. package/umd/plugins/filtering.umd.js.map +1 -1
  130. package/umd/plugins/grouping-columns.umd.js +1 -1
  131. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  132. package/umd/plugins/grouping-rows.umd.js +1 -1
  133. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  134. package/umd/plugins/master-detail.umd.js +1 -1
  135. package/umd/plugins/master-detail.umd.js.map +1 -1
  136. package/umd/plugins/multi-sort.umd.js +1 -1
  137. package/umd/plugins/multi-sort.umd.js.map +1 -1
  138. package/umd/plugins/pinned-columns.umd.js +1 -1
  139. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  140. package/umd/plugins/pinned-rows.umd.js +1 -1
  141. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  142. package/umd/plugins/pivot.umd.js +1 -1
  143. package/umd/plugins/pivot.umd.js.map +1 -1
  144. package/umd/plugins/reorder.umd.js +1 -1
  145. package/umd/plugins/reorder.umd.js.map +1 -1
  146. package/umd/plugins/selection.umd.js +1 -1
  147. package/umd/plugins/selection.umd.js.map +1 -1
  148. package/umd/plugins/server-side.umd.js +1 -1
  149. package/umd/plugins/server-side.umd.js.map +1 -1
  150. package/umd/plugins/tree.umd.js +1 -1
  151. package/umd/plugins/tree.umd.js.map +1 -1
  152. package/umd/plugins/undo-redo.umd.js +1 -1
  153. package/umd/plugins/undo-redo.umd.js.map +1 -1
  154. package/umd/plugins/visibility.umd.js +1 -1
  155. package/umd/plugins/visibility.umd.js.map +1 -1
  156. package/lib/core/internal/editing.d.ts +0 -76
  157. package/lib/core/internal/editing.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- const A = {
1
+ const R = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,7 +8,7 @@ const A = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class R {
11
+ class A {
12
12
  /**
13
13
  * Plugin dependencies - declare other plugins this one requires.
14
14
  *
@@ -25,8 +25,11 @@ class R {
25
25
  * ```
26
26
  */
27
27
  static dependencies;
28
- /** Plugin version - override in subclass if needed */
29
- version = "1.0.0";
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";
30
33
  /** CSS styles to inject into the grid's shadow DOM */
31
34
  styles;
32
35
  /** Custom cell renderers keyed by type name */
@@ -110,8 +113,16 @@ class R {
110
113
  /**
111
114
  * Emit a custom event from the grid.
112
115
  */
113
- emit(t, n) {
114
- 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;
115
126
  }
116
127
  /**
117
128
  * Request a re-render of the grid.
@@ -119,6 +130,14 @@ class R {
119
130
  requestRender() {
120
131
  this.grid?.requestRender?.();
121
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
+ }
122
141
  /**
123
142
  * Request a lightweight style update without rebuilding DOM.
124
143
  * Use this instead of requestRender() when only CSS classes need updating.
@@ -152,6 +171,19 @@ class R {
152
171
  get visibleColumns() {
153
172
  return this.grid?._visibleColumns ?? [];
154
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
+ }
155
187
  /**
156
188
  * Get the shadow root of the grid.
157
189
  */
@@ -184,8 +216,53 @@ class R {
184
216
  */
185
217
  get gridIcons() {
186
218
  const t = this.grid?.gridConfig?.icons ?? {};
187
- return { ...A, ...t };
219
+ return { ...R, ...t };
188
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
189
266
  /**
190
267
  * Resolve an icon value to string or HTMLElement.
191
268
  * Checks plugin config first, then grid-level icons, then defaults.
@@ -194,8 +271,8 @@ class R {
194
271
  * @param pluginOverride - Optional plugin-level override
195
272
  * @returns The resolved icon value
196
273
  */
197
- resolveIcon(t, n) {
198
- return n !== void 0 ? n : this.gridIcons[t];
274
+ resolveIcon(t, e) {
275
+ return e !== void 0 ? e : this.gridIcons[t];
199
276
  }
200
277
  /**
201
278
  * Set an icon value on an element.
@@ -204,8 +281,8 @@ class R {
204
281
  * @param element - The element to set the icon on
205
282
  * @param icon - The icon value (string or HTMLElement)
206
283
  */
207
- setIcon(t, n) {
208
- 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)));
209
286
  }
210
287
  /**
211
288
  * Log a warning message.
@@ -216,87 +293,87 @@ class R {
216
293
  // #endregion
217
294
  }
218
295
  const p = {
219
- sum: (e, t) => e.reduce((n, i) => n + (Number(i[t]) || 0), 0),
220
- avg: (e, t) => {
221
- const n = e.reduce((i, r) => i + (Number(r[t]) || 0), 0);
222
- 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;
223
300
  },
224
- count: (e) => e.length,
225
- min: (e, t) => Math.min(...e.map((n) => Number(n[t]) || 1 / 0)),
226
- max: (e, t) => Math.max(...e.map((n) => Number(n[t]) || -1 / 0)),
227
- first: (e, t) => e[0]?.[t],
228
- last: (e, t) => e[e.length - 1]?.[t]
229
- }, 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 = {
230
307
  /**
231
308
  * Register a custom aggregator function.
232
309
  */
233
- register(e, t) {
234
- u.set(e, t);
310
+ register(n, t) {
311
+ f.set(n, t);
235
312
  },
236
313
  /**
237
314
  * Unregister a custom aggregator function.
238
315
  */
239
- unregister(e) {
240
- u.delete(e);
316
+ unregister(n) {
317
+ f.delete(n);
241
318
  },
242
319
  /**
243
320
  * Get an aggregator function by reference.
244
321
  */
245
- get(e) {
246
- if (e !== void 0)
247
- 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];
248
325
  },
249
326
  /**
250
327
  * Run an aggregator on a set of rows.
251
328
  */
252
- run(e, t, n, i) {
253
- const r = this.get(e);
254
- 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;
255
332
  },
256
333
  /**
257
334
  * Check if an aggregator exists.
258
335
  */
259
- has(e) {
260
- return u.has(e) || e in p;
336
+ has(n) {
337
+ return f.has(n) || n in p;
261
338
  },
262
339
  /**
263
340
  * List all available aggregator names.
264
341
  */
265
342
  list() {
266
- return [...Object.keys(p), ...u.keys()];
343
+ return [...Object.keys(p), ...f.keys()];
267
344
  }
268
345
  };
269
346
  d.register.bind(d);
270
347
  d.unregister.bind(d);
271
- const w = d.get.bind(d);
348
+ const b = d.get.bind(d);
272
349
  d.run.bind(d);
273
350
  d.list.bind(d);
274
- function E(e) {
275
- return typeof e == "object" && e !== null && "aggFunc" in e;
351
+ function E(n) {
352
+ return typeof n == "object" && n !== null && "aggFunc" in n;
276
353
  }
277
- function m(e, t) {
278
- const n = document.createElement("div");
279
- 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");
280
357
  const i = document.createElement("div");
281
358
  i.className = "tbw-pinned-rows-left";
282
359
  const r = document.createElement("div");
283
360
  r.className = "tbw-pinned-rows-center";
284
361
  const s = document.createElement("div");
285
- if (s.className = "tbw-pinned-rows-right", e.showRowCount !== !1) {
362
+ if (s.className = "tbw-pinned-rows-right", n.showRowCount !== !1) {
286
363
  const o = document.createElement("span");
287
364
  o.className = "tbw-status-panel tbw-status-panel-row-count", o.textContent = `Total: ${t.totalRows} rows`, i.appendChild(o);
288
365
  }
289
- if (e.showFilteredCount && t.filteredRows !== t.totalRows) {
366
+ if (n.showFilteredCount && t.filteredRows !== t.totalRows) {
290
367
  const o = document.createElement("span");
291
368
  o.className = "tbw-status-panel tbw-status-panel-filtered-count", o.textContent = `Filtered: ${t.filteredRows}`, i.appendChild(o);
292
369
  }
293
- if (e.showSelectedCount && t.selectedRows > 0) {
370
+ if (n.showSelectedCount && t.selectedRows > 0) {
294
371
  const o = document.createElement("span");
295
372
  o.className = "tbw-status-panel tbw-status-panel-selected-count", o.textContent = `Selected: ${t.selectedRows}`, s.appendChild(o);
296
373
  }
297
- if (e.customPanels)
298
- for (const o of e.customPanels) {
299
- const a = x(o, t);
374
+ if (n.customPanels)
375
+ for (const o of n.customPanels) {
376
+ const a = y(o, t);
300
377
  switch (o.position) {
301
378
  case "left":
302
379
  i.appendChild(a);
@@ -309,62 +386,62 @@ function m(e, t) {
309
386
  break;
310
387
  }
311
388
  }
312
- return n.appendChild(i), n.appendChild(r), n.appendChild(s), n;
389
+ return e.appendChild(i), e.appendChild(r), e.appendChild(s), e;
313
390
  }
314
- function b(e) {
391
+ function w(n) {
315
392
  const t = document.createElement("div");
316
- 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;
317
394
  }
318
- function C(e, t, n, i) {
319
- e.innerHTML = "";
395
+ function C(n, t, e, i) {
396
+ n.innerHTML = "";
320
397
  for (const r of t) {
321
398
  const s = document.createElement("div");
322
399
  if (s.className = "tbw-aggregation-row", s.setAttribute("role", "presentation"), r.id && s.setAttribute("data-aggregation-id", r.id), r.fullWidth) {
323
400
  const o = document.createElement("div");
324
401
  o.className = "tbw-aggregation-cell tbw-aggregation-cell-full", o.style.gridColumn = "1 / -1", o.textContent = r.label || "", s.appendChild(o);
325
402
  } else
326
- for (const o of n) {
403
+ for (const o of e) {
327
404
  const a = document.createElement("div");
328
405
  a.className = "tbw-aggregation-cell", a.setAttribute("data-field", o.field);
329
- let l, f;
406
+ let l, u;
330
407
  const h = r.aggregators?.[o.field];
331
408
  if (h)
332
409
  if (E(h)) {
333
- const g = w(h.aggFunc);
334
- 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;
335
412
  } else {
336
- const g = w(h);
413
+ const g = b(h);
337
414
  g && (l = g(i, o.field, o));
338
415
  }
339
416
  else if (r.cells && Object.prototype.hasOwnProperty.call(r.cells, o.field)) {
340
417
  const g = r.cells[o.field];
341
418
  typeof g == "function" ? l = g(i, o.field, o) : l = g;
342
419
  }
343
- 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);
344
421
  }
345
- e.appendChild(s);
422
+ n.appendChild(s);
346
423
  }
347
424
  }
348
- function x(e, t) {
349
- const n = document.createElement("div");
350
- n.className = "tbw-status-panel tbw-status-panel-custom", n.id = `status-panel-${e.id}`;
351
- const i = e.render(t);
352
- 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;
353
430
  }
354
- function v(e, t, n, i, r) {
431
+ function v(n, t, e, i, r) {
355
432
  return {
356
- totalRows: e.length,
357
- filteredRows: r?.cachedResult?.length ?? e.length,
433
+ totalRows: n.length,
434
+ filteredRows: r?.cachedResult?.length ?? n.length,
358
435
  selectedRows: i?.selected?.size ?? 0,
359
436
  columns: t,
360
- rows: e,
361
- grid: n
437
+ rows: n,
438
+ grid: e
362
439
  };
363
440
  }
364
- 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}";
365
- 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 {
366
443
  name = "pinnedRows";
367
- version = "1.0.0";
444
+ styles = S;
368
445
  get defaultConfig() {
369
446
  return {
370
447
  position: "bottom",
@@ -388,9 +465,9 @@ class y extends R {
388
465
  afterRender() {
389
466
  const t = this.shadowRoot;
390
467
  if (!t) return;
391
- const n = t.querySelector(".tbw-scroll-area") ?? t.querySelector(".tbw-grid-content") ?? t.children[0];
392
- if (!n) return;
393
- 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);
394
471
  const i = this.getSelectionState(), r = this.getFilterState(), s = v(
395
472
  this.rows,
396
473
  this.columns,
@@ -400,9 +477,9 @@ class y extends R {
400
477
  ), o = this.config.aggregationRows || [], a = o.filter((c) => c.position === "top"), l = o.filter((c) => c.position !== "top");
401
478
  if (a.length > 0) {
402
479
  if (!this.topAggregationContainer) {
403
- this.topAggregationContainer = b("top");
480
+ this.topAggregationContainer = w("top");
404
481
  const c = t.querySelector(".header");
405
- 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);
406
483
  }
407
484
  C(
408
485
  this.topAggregationContainer,
@@ -411,16 +488,16 @@ class y extends R {
411
488
  this.rows
412
489
  );
413
490
  } else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
414
- 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;
415
- 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")
416
493
  if (!this.infoBarElement)
417
- 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);
418
495
  else {
419
496
  const c = m(this.config, s);
420
497
  this.infoBarElement.replaceWith(c), this.infoBarElement = c;
421
498
  }
422
499
  else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
423
- 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(
424
501
  this.bottomAggregationContainer,
425
502
  l,
426
503
  this.visibleColumns,
@@ -462,13 +539,13 @@ class y extends R {
462
539
  * @returns The context with row counts and other info
463
540
  */
464
541
  getContext() {
465
- const t = this.getSelectionState(), n = this.getFilterState();
542
+ const t = this.getSelectionState(), e = this.getFilterState();
466
543
  return v(
467
544
  this.rows,
468
545
  this.columns,
469
546
  this.grid,
470
547
  t,
471
- n
548
+ e
472
549
  );
473
550
  }
474
551
  /**
@@ -483,7 +560,7 @@ class y extends R {
483
560
  * @param id - The panel ID to remove
484
561
  */
485
562
  removePanel(t) {
486
- 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());
487
564
  }
488
565
  /**
489
566
  * Add an aggregation row.
@@ -497,14 +574,11 @@ class y extends R {
497
574
  * @param id - The aggregation row ID to remove
498
575
  */
499
576
  removeAggregationRow(t) {
500
- 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());
501
578
  }
502
579
  // #endregion
503
- // #region Styles
504
- styles = B;
505
- // #endregion
506
580
  }
507
581
  export {
508
- y as PinnedRowsPlugin
582
+ x as PinnedRowsPlugin
509
583
  };
510
584
  //# sourceMappingURL=index.js.map