@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 _ = {
1
+ const S = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,7 +8,7 @@ const _ = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class S {
11
+ class _ {
12
12
  /**
13
13
  * Plugin dependencies - declare other plugins this one requires.
14
14
  *
@@ -185,10 +185,21 @@ class S {
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 S {
216
227
  */
217
228
  get gridIcons() {
218
229
  const e = this.grid?.gridConfig?.icons ?? {};
219
- return { ..._, ...e };
230
+ return { ...S, ...e };
220
231
  }
221
232
  // #region Animation Helpers
222
233
  /**
@@ -239,7 +250,7 @@ class S {
239
250
  const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
240
251
  if (e === !1 || e === "off") return !1;
241
252
  if (e === !0 || e === "on") return !0;
242
- const t = this.shadowRoot?.host;
253
+ const t = this.gridElement;
243
254
  return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
244
255
  }
245
256
  /**
@@ -255,7 +266,7 @@ class S {
255
266
  * ```
256
267
  */
257
268
  get animationDuration() {
258
- const e = this.shadowRoot?.host;
269
+ const e = this.gridElement;
259
270
  if (e) {
260
271
  const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(t, 10);
261
272
  if (!isNaN(n)) return n;
@@ -292,7 +303,7 @@ class S {
292
303
  }
293
304
  // #endregion
294
305
  }
295
- function b(s, e, t) {
306
+ function x(s, e, t) {
296
307
  return s.id !== void 0 ? String(s.id) : t ? `${t}-${e}` : String(e);
297
308
  }
298
309
  function y(s, e) {
@@ -302,7 +313,7 @@ function y(s, e) {
302
313
  function w(s, e, t = null, n = 0) {
303
314
  const i = e.childrenField ?? "children", o = /* @__PURE__ */ new Set();
304
315
  for (let r = 0; r < s.length; r++) {
305
- const l = s[r], a = b(l, r, t), d = l[i];
316
+ const l = s[r], a = x(l, r, t), d = l[i];
306
317
  if (Array.isArray(d) && d.length > 0) {
307
318
  o.add(a);
308
319
  const h = w(d, e, a, n + 1);
@@ -314,23 +325,23 @@ function w(s, e, t = null, n = 0) {
314
325
  function v() {
315
326
  return /* @__PURE__ */ new Set();
316
327
  }
317
- function x(s, e, t, n = null, i = 0) {
328
+ function R(s, e, t, n = null, i = 0) {
318
329
  const o = t.childrenField ?? "children";
319
330
  for (let r = 0; r < s.length; r++) {
320
- const l = s[r], a = b(l, r, n);
331
+ const l = s[r], a = x(l, r, n);
321
332
  if (a === e)
322
333
  return [a];
323
334
  const d = l[o];
324
335
  if (Array.isArray(d) && d.length > 0) {
325
- const h = x(d, e, t, a, i + 1);
336
+ const h = R(d, e, t, a, i + 1);
326
337
  if (h)
327
338
  return [a, ...h];
328
339
  }
329
340
  }
330
341
  return null;
331
342
  }
332
- function C(s, e, t, n) {
333
- const i = x(s, e, t);
343
+ function E(s, e, t, n) {
344
+ const i = R(s, e, t);
334
345
  if (!i) return n;
335
346
  const o = new Set(n);
336
347
  for (let r = 0; r < i.length - 1; r++)
@@ -347,7 +358,7 @@ function m(s, e = "children") {
347
358
  }
348
359
  return !1;
349
360
  }
350
- function E(s) {
361
+ function C(s) {
351
362
  if (!Array.isArray(s) || s.length === 0) return null;
352
363
  const e = ["children", "items", "nodes", "subRows", "nested"];
353
364
  for (const t of s)
@@ -383,8 +394,8 @@ function T(s, e = "children") {
383
394
  }
384
395
  return t;
385
396
  }
386
- const I = ".cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}.header-row .cell[data-field=__tbw_expander]{visibility:hidden;border:none!important;padding:0;overflow:hidden}.header-row .cell[data-field=__tbw_expander]+.cell{margin-left:-32px;padding-left:calc(var(--tbw-cell-padding, 8px) + 32px)}.tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}.tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}.tree-spacer{width:14px;display:inline-block}.data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}";
387
- class F extends S {
397
+ const I = "@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .tree-cell-wrapper{display:inline-flex;align-items:center;padding-left:calc(var(--tbw-tree-depth, 0) * var(--tbw-tree-indent-width, var(--tbw-tree-toggle-size, 1.25em)))}tbw-grid .tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);flex-shrink:0}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size, 1.25em);display:inline-block;flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}}";
398
+ class F extends _ {
388
399
  name = "tree";
389
400
  styles = I;
390
401
  get defaultConfig() {
@@ -421,7 +432,7 @@ class F extends S {
421
432
  // #region Auto-Detection
422
433
  detect(e) {
423
434
  if (!this.config.autoDetect) return !1;
424
- const t = e, n = this.config.childrenField ?? E(t) ?? "children";
435
+ const t = e, n = this.config.childrenField ?? C(t) ?? "children";
425
436
  return m(t, n);
426
437
  }
427
438
  // #endregion
@@ -487,22 +498,22 @@ class F extends S {
487
498
  const t = [...e];
488
499
  if (t.length === 0) return t;
489
500
  const n = t[0], i = n.viewRenderer, o = () => this.config, r = this.setIcon.bind(this), l = this.resolveIcon.bind(this), a = (d) => {
490
- const { row: h, value: u } = d, { indentWidth: R = 20, showExpandIcons: A = !0 } = o(), p = h, K = p.__treeDepth ?? 0, f = document.createElement("span");
491
- if (f.className = "tree-cell-wrapper", f.style.paddingLeft = `${Number(K) * R}px`, A)
492
- if (p.__treeHasChildren) {
501
+ const { row: h, value: u } = d, { showExpandIcons: A = !0, indentWidth: b } = o(), g = h, K = g.__treeDepth ?? 0, f = document.createElement("span");
502
+ if (f.className = "tree-cell-wrapper", f.style.setProperty("--tbw-tree-depth", String(K)), b !== void 0 && f.style.setProperty("--tbw-tree-indent-width", `${b}px`), A)
503
+ if (g.__treeHasChildren) {
493
504
  const c = document.createElement("span");
494
- c.className = `tree-toggle${p.__treeExpanded ? " expanded" : ""}`, r(c, l(p.__treeExpanded ? "collapse" : "expand")), c.setAttribute("data-tree-key", String(p.__treeKey ?? "")), f.appendChild(c);
505
+ c.className = `tree-toggle${g.__treeExpanded ? " expanded" : ""}`, r(c, l(g.__treeExpanded ? "collapse" : "expand")), c.setAttribute("data-tree-key", String(g.__treeKey ?? "")), f.appendChild(c);
495
506
  } else {
496
507
  const c = document.createElement("span");
497
508
  c.className = "tree-spacer", f.appendChild(c);
498
509
  }
499
- const g = document.createElement("span");
500
- if (g.className = "tree-content", i) {
510
+ const p = document.createElement("span");
511
+ if (p.className = "tree-content", i) {
501
512
  const c = i(d);
502
- c instanceof Node ? g.appendChild(c) : typeof c == "string" && (g.innerHTML = c);
513
+ c instanceof Node ? p.appendChild(c) : typeof c == "string" && (p.innerHTML = c);
503
514
  } else
504
- g.textContent = u != null ? String(u) : "";
505
- return f.appendChild(g), f;
515
+ p.textContent = u != null ? String(u) : "";
516
+ return f.appendChild(p), f;
506
517
  };
507
518
  return t[0] = { ...n, viewRenderer: a }, t;
508
519
  }
@@ -542,7 +553,7 @@ class F extends S {
542
553
  afterRender() {
543
554
  const e = this.animationStyle;
544
555
  if (e === !1 || this.keysToAnimate.size === 0) return;
545
- const t = this.shadowRoot?.querySelector(".rows");
556
+ const t = this.gridElement?.querySelector(".rows");
546
557
  if (!t) return;
547
558
  const n = e === "fade" ? "tbw-tree-fade-in" : "tbw-tree-slide-in";
548
559
  for (const i of t.querySelectorAll(".data-grid-row")) {
@@ -581,7 +592,7 @@ class F extends S {
581
592
  return this.rowKeyMap.get(e)?.data;
582
593
  }
583
594
  expandToKey(e) {
584
- this.expandedKeys = C(this.rows, e, this.config, this.expandedKeys), this.requestRender();
595
+ this.expandedKeys = E(this.rows, e, this.config, this.expandedKeys), this.requestRender();
585
596
  }
586
597
  // #endregion
587
598
  }
@@ -590,6 +601,6 @@ export {
590
601
  T as countNodes,
591
602
  m as detectTreeStructure,
592
603
  k as getMaxDepth,
593
- E as inferChildrenField
604
+ C as inferChildrenField
594
605
  };
595
606
  //# sourceMappingURL=index.js.map