@toolbox-web/grid 0.4.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +2 -3
  2. package/all.js +1063 -1024
  3. package/all.js.map +1 -1
  4. package/index.js +1078 -912
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +28 -0
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/dom-builder.d.ts +2 -0
  9. package/lib/core/internal/dom-builder.d.ts.map +1 -1
  10. package/lib/core/internal/event-delegation.d.ts +21 -0
  11. package/lib/core/internal/event-delegation.d.ts.map +1 -1
  12. package/lib/core/internal/header.d.ts.map +1 -1
  13. package/lib/core/internal/resize.d.ts.map +1 -1
  14. package/lib/core/internal/rows.d.ts +1 -1
  15. package/lib/core/internal/rows.d.ts.map +1 -1
  16. package/lib/core/internal/shell.d.ts +19 -13
  17. package/lib/core/internal/shell.d.ts.map +1 -1
  18. package/lib/core/plugin/base-plugin.d.ts +13 -2
  19. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  20. package/lib/core/plugin/expander-column.d.ts.map +1 -1
  21. package/lib/core/plugin/plugin-manager.d.ts +6 -2
  22. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  23. package/lib/core/types.d.ts +41 -3
  24. package/lib/core/types.d.ts.map +1 -1
  25. package/lib/plugins/clipboard/index.js +22 -11
  26. package/lib/plugins/clipboard/index.js.map +1 -1
  27. package/lib/plugins/column-virtualization/index.js +59 -48
  28. package/lib/plugins/column-virtualization/index.js.map +1 -1
  29. package/lib/plugins/context-menu/index.js +71 -60
  30. package/lib/plugins/context-menu/index.js.map +1 -1
  31. package/lib/plugins/editing/EditingPlugin.d.ts +1 -0
  32. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  33. package/lib/plugins/editing/index.js +93 -80
  34. package/lib/plugins/editing/index.js.map +1 -1
  35. package/lib/plugins/export/index.js +29 -18
  36. package/lib/plugins/export/index.js.map +1 -1
  37. package/lib/plugins/filtering/FilteringPlugin.d.ts +9 -1
  38. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  39. package/lib/plugins/filtering/index.js +199 -165
  40. package/lib/plugins/filtering/index.js.map +1 -1
  41. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -0
  42. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  43. package/lib/plugins/grouping-columns/index.js +79 -49
  44. package/lib/plugins/grouping-columns/index.js.map +1 -1
  45. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  46. package/lib/plugins/grouping-rows/index.js +98 -87
  47. package/lib/plugins/grouping-rows/index.js.map +1 -1
  48. package/lib/plugins/master-detail/index.js +70 -57
  49. package/lib/plugins/master-detail/index.js.map +1 -1
  50. package/lib/plugins/multi-sort/index.js +48 -37
  51. package/lib/plugins/multi-sort/index.js.map +1 -1
  52. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  53. package/lib/plugins/pinned-columns/index.js +71 -66
  54. package/lib/plugins/pinned-columns/index.js.map +1 -1
  55. package/lib/plugins/pinned-columns/pinned-columns.d.ts +2 -2
  56. package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
  57. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  58. package/lib/plugins/pinned-rows/index.js +63 -52
  59. package/lib/plugins/pinned-rows/index.js.map +1 -1
  60. package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
  61. package/lib/plugins/pivot/index.js +310 -299
  62. package/lib/plugins/pivot/index.js.map +1 -1
  63. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  64. package/lib/plugins/reorder/index.d.ts +1 -1
  65. package/lib/plugins/reorder/index.d.ts.map +1 -1
  66. package/lib/plugins/reorder/index.js +79 -68
  67. package/lib/plugins/reorder/index.js.map +1 -1
  68. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  69. package/lib/plugins/selection/index.js +115 -105
  70. package/lib/plugins/selection/index.js.map +1 -1
  71. package/lib/plugins/server-side/index.js +15 -4
  72. package/lib/plugins/server-side/index.js.map +1 -1
  73. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  74. package/lib/plugins/tree/index.js +41 -30
  75. package/lib/plugins/tree/index.js.map +1 -1
  76. package/lib/plugins/undo-redo/index.js +29 -18
  77. package/lib/plugins/undo-redo/index.js.map +1 -1
  78. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  79. package/lib/plugins/visibility/index.js +59 -47
  80. package/lib/plugins/visibility/index.js.map +1 -1
  81. package/package.json +6 -6
  82. package/public.d.ts +42 -0
  83. package/public.d.ts.map +1 -1
  84. package/themes/dg-theme-bootstrap.css +55 -53
  85. package/themes/dg-theme-contrast.css +42 -40
  86. package/themes/dg-theme-large.css +38 -37
  87. package/themes/dg-theme-material.css +54 -52
  88. package/themes/dg-theme-standard.css +19 -17
  89. package/themes/dg-theme-vibrant.css +16 -14
  90. package/umd/grid.all.umd.js +23 -22
  91. package/umd/grid.all.umd.js.map +1 -1
  92. package/umd/grid.umd.js +15 -14
  93. package/umd/grid.umd.js.map +1 -1
  94. package/umd/plugins/column-virtualization.umd.js +1 -1
  95. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  96. package/umd/plugins/context-menu.umd.js +1 -1
  97. package/umd/plugins/context-menu.umd.js.map +1 -1
  98. package/umd/plugins/editing.umd.js +1 -1
  99. package/umd/plugins/editing.umd.js.map +1 -1
  100. package/umd/plugins/filtering.umd.js +1 -1
  101. package/umd/plugins/filtering.umd.js.map +1 -1
  102. package/umd/plugins/grouping-columns.umd.js +1 -1
  103. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  104. package/umd/plugins/grouping-rows.umd.js +1 -1
  105. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  106. package/umd/plugins/master-detail.umd.js +1 -1
  107. package/umd/plugins/master-detail.umd.js.map +1 -1
  108. package/umd/plugins/multi-sort.umd.js +1 -1
  109. package/umd/plugins/multi-sort.umd.js.map +1 -1
  110. package/umd/plugins/pinned-columns.umd.js +1 -1
  111. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  112. package/umd/plugins/pinned-rows.umd.js +1 -1
  113. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  114. package/umd/plugins/pivot.umd.js +1 -1
  115. package/umd/plugins/pivot.umd.js.map +1 -1
  116. package/umd/plugins/reorder.umd.js +1 -1
  117. package/umd/plugins/reorder.umd.js.map +1 -1
  118. package/umd/plugins/selection.umd.js +1 -1
  119. package/umd/plugins/selection.umd.js.map +1 -1
  120. package/umd/plugins/tree.umd.js +1 -1
  121. package/umd/plugins/tree.umd.js.map +1 -1
  122. package/umd/plugins/visibility.umd.js +1 -1
  123. package/umd/plugins/visibility.umd.js.map +1 -1
@@ -1,4 +1,4 @@
1
- const x = {
1
+ const b = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,7 +8,7 @@ const x = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class b {
11
+ class x {
12
12
  /**
13
13
  * Plugin dependencies - declare other plugins this one requires.
14
14
  *
@@ -121,8 +121,8 @@ class b {
121
121
  * @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
122
122
  */
123
123
  emitCancelable(t, e) {
124
- const i = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
125
- return this.grid?.dispatchEvent?.(i), i.defaultPrevented;
124
+ const o = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
125
+ return this.grid?.dispatchEvent?.(o), o.defaultPrevented;
126
126
  }
127
127
  /**
128
128
  * Request a re-render of the grid.
@@ -185,10 +185,21 @@ class b {
185
185
  return this.grid;
186
186
  }
187
187
  /**
188
- * Get the shadow root of the grid.
188
+ * Get the render root of the grid for DOM queries.
189
+ * @deprecated Use `gridElement` instead. This getter exists only for backward compatibility.
190
+ *
191
+ * With Shadow DOM removed, the grid element itself is the render root.
192
+ * All new code should use `this.gridElement` for DOM queries.
193
+ *
194
+ * @example
195
+ * // OLD (deprecated)
196
+ * const rows = this.shadowRoot?.querySelector('.rows');
197
+ *
198
+ * // NEW (preferred)
199
+ * const rows = this.gridElement.querySelector('.rows');
189
200
  */
190
201
  get shadowRoot() {
191
- return this.grid?.shadowRoot ?? null;
202
+ return this.gridElement;
192
203
  }
193
204
  /**
194
205
  * Get the disconnect signal for event listener cleanup.
@@ -216,7 +227,7 @@ class b {
216
227
  */
217
228
  get gridIcons() {
218
229
  const t = this.grid?.gridConfig?.icons ?? {};
219
- return { ...x, ...t };
230
+ return { ...b, ...t };
220
231
  }
221
232
  // #region Animation Helpers
222
233
  /**
@@ -239,7 +250,7 @@ class b {
239
250
  const t = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
240
251
  if (t === !1 || t === "off") return !1;
241
252
  if (t === !0 || t === "on") return !0;
242
- const e = this.shadowRoot?.host;
253
+ const e = this.gridElement;
243
254
  return e ? getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
244
255
  }
245
256
  /**
@@ -255,10 +266,10 @@ class b {
255
266
  * ```
256
267
  */
257
268
  get animationDuration() {
258
- const t = this.shadowRoot?.host;
269
+ const t = this.gridElement;
259
270
  if (t) {
260
- const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), i = parseInt(e, 10);
261
- if (!isNaN(i)) return i;
271
+ const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), o = parseInt(e, 10);
272
+ if (!isNaN(o)) return o;
262
273
  }
263
274
  return 200;
264
275
  }
@@ -293,31 +304,31 @@ class b {
293
304
  // #endregion
294
305
  }
295
306
  function S(r, t, e) {
296
- return t.length ? [...r].sort((i, o) => {
307
+ return t.length ? [...r].sort((o, i) => {
297
308
  for (const n of t) {
298
- const d = e.find((c) => c.field === n.field)?.sortComparator ?? C, u = i[n.field], f = o[n.field], s = d(u, f, i, o);
309
+ const d = e.find((c) => c.field === n.field)?.sortComparator ?? y, u = o[n.field], f = i[n.field], s = d(u, f, o, i);
299
310
  if (s !== 0)
300
311
  return n.direction === "asc" ? s : -s;
301
312
  }
302
313
  return 0;
303
314
  }) : [...r];
304
315
  }
305
- function C(r, t) {
316
+ function y(r, t) {
306
317
  return r == null && t == null ? 0 : r == null ? 1 : t == null ? -1 : typeof r == "number" && typeof t == "number" ? r - t : r instanceof Date && t instanceof Date ? r.getTime() - t.getTime() : typeof r == "boolean" && typeof t == "boolean" ? r === t ? 0 : r ? -1 : 1 : String(r).localeCompare(String(t));
307
318
  }
308
- function y(r, t, e, i) {
309
- const o = r.find((n) => n.field === t);
310
- return e ? o ? o.direction === "asc" ? r.map((n) => n.field === t ? { ...n, direction: "desc" } : n) : r.filter((n) => n.field !== t) : r.length < i ? [...r, { field: t, direction: "asc" }] : r : o?.direction === "asc" ? [{ field: t, direction: "desc" }] : o?.direction === "desc" ? [] : [{ field: t, direction: "asc" }];
319
+ function C(r, t, e, o) {
320
+ const i = r.find((n) => n.field === t);
321
+ return e ? i ? i.direction === "asc" ? r.map((n) => n.field === t ? { ...n, direction: "desc" } : n) : r.filter((n) => n.field !== t) : r.length < o ? [...r, { field: t, direction: "asc" }] : r : i?.direction === "asc" ? [{ field: t, direction: "desc" }] : i?.direction === "desc" ? [] : [{ field: t, direction: "asc" }];
311
322
  }
312
- function g(r, t) {
313
- const e = r.findIndex((i) => i.field === t);
323
+ function h(r, t) {
324
+ const e = r.findIndex((o) => o.field === t);
314
325
  return e >= 0 ? e + 1 : void 0;
315
326
  }
316
327
  function m(r, t) {
317
328
  return r.find((e) => e.field === t)?.direction;
318
329
  }
319
- const M = '.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}';
320
- class w extends b {
330
+ const M = '@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}}';
331
+ class w extends x {
321
332
  name = "multiSort";
322
333
  styles = M;
323
334
  get defaultConfig() {
@@ -340,28 +351,28 @@ class w extends b {
340
351
  }
341
352
  onHeaderClick(t) {
342
353
  if (!this.columns.find((n) => n.field === t.field)?.sortable) return !1;
343
- const i = t.originalEvent.shiftKey, o = this.config.maxSortColumns ?? 3;
344
- return this.sortModel = y(this.sortModel, t.field, i, o), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
354
+ const o = t.originalEvent.shiftKey, i = this.config.maxSortColumns ?? 3;
355
+ return this.sortModel = C(this.sortModel, t.field, o, i), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
345
356
  }
346
357
  afterRender() {
347
- const t = this.shadowRoot;
358
+ const t = this.gridElement;
348
359
  if (!t) return;
349
360
  const e = this.config.showSortIndex !== !1;
350
- t.querySelectorAll(".header-row .cell[data-field]").forEach((o) => {
351
- const n = o.getAttribute("data-field");
361
+ t.querySelectorAll(".header-row .cell[data-field]").forEach((i) => {
362
+ const n = i.getAttribute("data-field");
352
363
  if (!n) return;
353
- const a = g(this.sortModel, n), d = m(this.sortModel, n);
354
- if (o.querySelector(".sort-index")?.remove(), d) {
355
- o.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), o.setAttribute("data-sort", d);
364
+ const a = h(this.sortModel, n), d = m(this.sortModel, n);
365
+ if (i.querySelector(".sort-index")?.remove(), d) {
366
+ i.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), i.setAttribute("data-sort", d);
356
367
  const s = document.createElement("span");
357
368
  s.className = "sort-indicator", this.setIcon(s, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc"));
358
- const c = o.querySelector(".tbw-filter-btn"), p = o.querySelector(".resize-handle"), h = c ?? p;
359
- if (h ? o.insertBefore(s, h) : o.appendChild(s), e && this.sortModel.length > 1 && a !== void 0) {
369
+ const c = i.querySelector(".tbw-filter-btn"), p = i.querySelector(".resize-handle"), g = c ?? p;
370
+ if (g ? i.insertBefore(s, g) : i.appendChild(s), e && this.sortModel.length > 1 && a !== void 0) {
360
371
  const l = document.createElement("span");
361
- l.className = "sort-index", l.textContent = String(a), s.nextSibling ? o.insertBefore(l, s.nextSibling) : o.appendChild(l);
372
+ l.className = "sort-index", l.textContent = String(a), s.nextSibling ? i.insertBefore(l, s.nextSibling) : i.appendChild(l);
362
373
  }
363
374
  } else
364
- o.removeAttribute("data-sort");
375
+ i.removeAttribute("data-sort");
365
376
  });
366
377
  }
367
378
  // #endregion
@@ -392,7 +403,7 @@ class w extends b {
392
403
  * @returns 1-based index or undefined if not sorted
393
404
  */
394
405
  getSortIndex(t) {
395
- return g(this.sortModel, t);
406
+ return h(this.sortModel, t);
396
407
  }
397
408
  /**
398
409
  * Get the sort direction for a specific field.
@@ -408,7 +419,7 @@ class w extends b {
408
419
  * Return sort state for a column if it's in the sort model.
409
420
  */
410
421
  getColumnState(t) {
411
- const e = this.sortModel.findIndex((o) => o.field === t);
422
+ const e = this.sortModel.findIndex((i) => i.field === t);
412
423
  return e === -1 ? void 0 : {
413
424
  sort: {
414
425
  direction: this.sortModel[e].direction,
@@ -425,11 +436,11 @@ class w extends b {
425
436
  this.sortModel = this.sortModel.filter((n) => n.field !== t);
426
437
  return;
427
438
  }
428
- const i = this.sortModel.findIndex((n) => n.field === t), o = {
439
+ const o = this.sortModel.findIndex((n) => n.field === t), i = {
429
440
  field: t,
430
441
  direction: e.sort.direction
431
442
  };
432
- i !== -1 ? this.sortModel[i] = o : this.sortModel.splice(e.sort.priority, 0, o);
443
+ o !== -1 ? this.sortModel[o] = i : this.sortModel.splice(e.sort.priority, 0, i);
433
444
  }
434
445
  // #endregion
435
446
  }