@toolbox-web/grid 1.17.0 → 1.19.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 (66) hide show
  1. package/README.md +126 -41
  2. package/all.js +1065 -933
  3. package/all.js.map +1 -1
  4. package/index.js +39 -33
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +12 -2
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/header.d.ts.map +1 -1
  9. package/lib/core/internal/keyboard.d.ts.map +1 -1
  10. package/lib/core/types.d.ts +34 -1
  11. package/lib/core/types.d.ts.map +1 -1
  12. package/lib/plugins/clipboard/index.js.map +1 -1
  13. package/lib/plugins/column-virtualization/index.js.map +1 -1
  14. package/lib/plugins/context-menu/index.js.map +1 -1
  15. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  16. package/lib/plugins/editing/index.js +155 -145
  17. package/lib/plugins/editing/index.js.map +1 -1
  18. package/lib/plugins/export/index.js.map +1 -1
  19. package/lib/plugins/filtering/FilteringPlugin.d.ts +31 -0
  20. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  21. package/lib/plugins/filtering/filter-model.d.ts +30 -3
  22. package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
  23. package/lib/plugins/filtering/index.d.ts +1 -0
  24. package/lib/plugins/filtering/index.d.ts.map +1 -1
  25. package/lib/plugins/filtering/index.js +471 -361
  26. package/lib/plugins/filtering/index.js.map +1 -1
  27. package/lib/plugins/filtering/types.d.ts +32 -0
  28. package/lib/plugins/filtering/types.d.ts.map +1 -1
  29. package/lib/plugins/grouping-columns/index.js.map +1 -1
  30. package/lib/plugins/grouping-rows/index.js.map +1 -1
  31. package/lib/plugins/master-detail/index.js.map +1 -1
  32. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +4 -0
  33. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  34. package/lib/plugins/multi-sort/index.js +49 -39
  35. package/lib/plugins/multi-sort/index.js.map +1 -1
  36. package/lib/plugins/pinned-columns/index.js.map +1 -1
  37. package/lib/plugins/pinned-rows/index.js.map +1 -1
  38. package/lib/plugins/pivot/index.js.map +1 -1
  39. package/lib/plugins/print/index.js.map +1 -1
  40. package/lib/plugins/reorder/index.js +81 -78
  41. package/lib/plugins/reorder/index.js.map +1 -1
  42. package/lib/plugins/responsive/index.js +58 -55
  43. package/lib/plugins/responsive/index.js.map +1 -1
  44. package/lib/plugins/row-reorder/index.js +5 -2
  45. package/lib/plugins/row-reorder/index.js.map +1 -1
  46. package/lib/plugins/selection/SelectionPlugin.d.ts +18 -0
  47. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  48. package/lib/plugins/selection/index.js +110 -71
  49. package/lib/plugins/selection/index.js.map +1 -1
  50. package/lib/plugins/server-side/index.js.map +1 -1
  51. package/lib/plugins/tree/index.js.map +1 -1
  52. package/lib/plugins/undo-redo/index.js.map +1 -1
  53. package/lib/plugins/visibility/index.js.map +1 -1
  54. package/package.json +1 -1
  55. package/umd/grid.all.umd.js +29 -29
  56. package/umd/grid.all.umd.js.map +1 -1
  57. package/umd/grid.umd.js +2 -2
  58. package/umd/grid.umd.js.map +1 -1
  59. package/umd/plugins/editing.umd.js +1 -1
  60. package/umd/plugins/editing.umd.js.map +1 -1
  61. package/umd/plugins/filtering.umd.js +1 -1
  62. package/umd/plugins/filtering.umd.js.map +1 -1
  63. package/umd/plugins/multi-sort.umd.js +1 -1
  64. package/umd/plugins/multi-sort.umd.js.map +1 -1
  65. package/umd/plugins/selection.umd.js +2 -2
  66. package/umd/plugins/selection.umd.js.map +1 -1
@@ -44,36 +44,36 @@ function H(r) {
44
44
  t.push(i);
45
45
  continue;
46
46
  }
47
- const a = [];
47
+ const l = [];
48
48
  for (const s of i.attributes) {
49
49
  const o = s.name.toLowerCase();
50
50
  if (v.test(o)) {
51
- a.push(s.name);
51
+ l.push(s.name);
52
52
  continue;
53
53
  }
54
54
  if (A.has(o) && S.test(s.value)) {
55
- a.push(s.name);
55
+ l.push(s.name);
56
56
  continue;
57
57
  }
58
58
  if (o === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(s.value)) {
59
- a.push(s.name);
59
+ l.push(s.name);
60
60
  continue;
61
61
  }
62
62
  }
63
- a.forEach((s) => i.removeAttribute(s));
63
+ l.forEach((s) => i.removeAttribute(s));
64
64
  }
65
65
  t.forEach((i) => i.remove());
66
66
  }
67
67
  function T(r, t) {
68
68
  if (!r || r.indexOf("{{") === -1) return r;
69
69
  const e = [], i = r.replace(y, (o, c) => {
70
- const l = L(c, t);
71
- return e.push({ expr: c.trim(), result: l }), l;
72
- }), n = x(i), a = e.length && e.every((o) => o.result === "" || o.result === u);
73
- return m.test(r) || a ? "" : n;
70
+ const a = L(c, t);
71
+ return e.push({ expr: c.trim(), result: a }), a;
72
+ }), n = x(i), l = e.length && e.every((o) => o.result === "" || o.result === u);
73
+ return w.test(r) || l ? "" : n;
74
74
  }
75
75
  function L(r, t) {
76
- if (r = (r || "").trim(), !r || m.test(r)) return u;
76
+ if (r = (r || "").trim(), !r || w.test(r)) return u;
77
77
  if (r === "value") return t.value == null ? u : String(t.value);
78
78
  if (r.startsWith("row.") && !/[()?]/.test(r) && !r.includes(":")) {
79
79
  const i = r.slice(4), n = t.row ? t.row[i] : void 0;
@@ -83,13 +83,13 @@ function L(r, t) {
83
83
  const e = r.match(/\./g);
84
84
  if (e && e.length > 1) return u;
85
85
  try {
86
- const n = new Function("value", "row", `return (${r});`)(t.value, t.row), a = n == null ? "" : String(n);
87
- return m.test(a) ? u : a || u;
86
+ const n = new Function("value", "row", `return (${r});`)(t.value, t.row), l = n == null ? "" : String(n);
87
+ return w.test(l) ? u : l || u;
88
88
  } catch {
89
89
  return u;
90
90
  }
91
91
  }
92
- const m = /Reflect|Proxy|ownKeys/;
92
+ const w = /Reflect|Proxy|ownKeys/;
93
93
  function x(r) {
94
94
  return r && r.replace(new RegExp(u, "g"), "").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g, "");
95
95
  }
@@ -102,43 +102,46 @@ const N = document.createElement("template");
102
102
  N.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
103
103
  function g(r, t) {
104
104
  if (r._virtualization?.enabled) {
105
- const { rowHeight: s, container: o, viewportEl: c } = r._virtualization, l = o, h = c?.clientHeight ?? l?.clientHeight ?? 0;
106
- if (l && h > 0) {
105
+ const { rowHeight: s, container: o, viewportEl: c } = r._virtualization, a = o, h = c?.clientHeight ?? a?.clientHeight ?? 0;
106
+ if (a && h > 0) {
107
107
  const d = r._focusRow * s;
108
- d < l.scrollTop ? l.scrollTop = d : d + s > l.scrollTop + h && (l.scrollTop = d - h + s);
108
+ d < a.scrollTop ? a.scrollTop = d : d + s > a.scrollTop + h && (a.scrollTop = d - h + s);
109
109
  }
110
110
  }
111
111
  const e = r._activeEditRows !== void 0 && r._activeEditRows !== -1;
112
112
  e || r.refreshVirtualWindow(!1), M(r._bodyEl), Array.from(r._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
113
113
  s.setAttribute("aria-selected", "false");
114
114
  });
115
- const i = r._focusRow, n = r._virtualization.start ?? 0, a = r._virtualization.end ?? r._rows.length;
116
- if (i >= n && i < a) {
115
+ const i = r._focusRow, n = r._virtualization.start ?? 0, l = r._virtualization.end ?? r._rows.length;
116
+ if (i >= n && i < l) {
117
117
  const s = r._bodyEl.querySelectorAll(".data-grid-row")[i - n];
118
118
  let o = s?.children[r._focusCol];
119
119
  if ((!o || !o.classList?.contains("cell")) && (o = s?.querySelector(`.cell[data-col="${r._focusCol}"]`) ?? s?.querySelector(".cell[data-col]")), o) {
120
120
  o.classList.add("cell-focus"), o.setAttribute("aria-selected", "true");
121
121
  const c = r.querySelector(".tbw-scroll-area");
122
122
  if (c && o && (!e || t?.forceHorizontalScroll)) {
123
- const l = r._getHorizontalScrollOffsets?.(s ?? void 0, o) ?? { left: 0, right: 0 };
124
- if (!l.skipScroll) {
125
- const h = o.getBoundingClientRect(), d = c.getBoundingClientRect(), f = h.left - d.left + c.scrollLeft, w = f + h.width, p = c.scrollLeft + l.left, R = c.scrollLeft + c.clientWidth - l.right;
126
- f < p ? c.scrollLeft = f - l.left : w > R && (c.scrollLeft = w - c.clientWidth + l.right);
123
+ const a = r._getHorizontalScrollOffsets?.(s ?? void 0, o) ?? { left: 0, right: 0 };
124
+ if (!a.skipScroll) {
125
+ const h = o.getBoundingClientRect(), d = c.getBoundingClientRect(), f = h.left - d.left + c.scrollLeft, m = f + h.width, p = c.scrollLeft + a.left, R = c.scrollLeft + c.clientWidth - a.right;
126
+ f < p ? c.scrollLeft = f - a.left : m > R && (c.scrollLeft = m - c.clientWidth + a.right);
127
127
  }
128
128
  }
129
- if (r._activeEditRows !== void 0 && r._activeEditRows !== -1 && o.classList.contains("editing")) {
130
- const l = o.querySelector(D);
131
- if (l && document.activeElement !== l)
129
+ if (e && o.classList.contains("editing")) {
130
+ const a = o.querySelector(D);
131
+ if (a && document.activeElement !== a)
132
132
  try {
133
- l.focus({ preventScroll: !0 });
133
+ a.focus({ preventScroll: !0 });
134
134
  } catch {
135
135
  }
136
- } else if (!o.contains(document.activeElement)) {
136
+ } else if (e && !o.contains(document.activeElement)) {
137
137
  o.hasAttribute("tabindex") || o.setAttribute("tabindex", "-1");
138
138
  try {
139
139
  o.focus({ preventScroll: !0 });
140
140
  } catch {
141
141
  }
142
+ } else if (!e) {
143
+ const a = r;
144
+ document.activeElement !== a && a.focus({ preventScroll: !0 });
142
145
  }
143
146
  }
144
147
  }
@@ -646,20 +649,20 @@ class G extends z {
646
649
  const d = i.__frameworkAdapter.parseResponsiveCardElement(e);
647
650
  d && (this.config = { ...this.config, cardRenderer: d });
648
651
  }
649
- const n = e.getAttribute("breakpoint"), a = e.getAttribute("card-row-height"), s = e.getAttribute("hidden-columns"), o = e.getAttribute("hide-header"), c = e.getAttribute("debounce-ms"), l = {};
652
+ const n = e.getAttribute("breakpoint"), l = e.getAttribute("card-row-height"), s = e.getAttribute("hidden-columns"), o = e.getAttribute("hide-header"), c = e.getAttribute("debounce-ms"), a = {};
650
653
  if (n !== null) {
651
654
  const d = parseInt(n, 10);
652
- isNaN(d) || (l.breakpoint = d);
655
+ isNaN(d) || (a.breakpoint = d);
653
656
  }
654
- if (a !== null && (l.cardRowHeight = a === "auto" ? "auto" : parseInt(a, 10)), s !== null && (l.hiddenColumns = s.split(",").map((d) => d.trim()).filter((d) => d.length > 0)), o !== null && (l.hideHeader = o !== "false"), c !== null) {
657
+ if (l !== null && (a.cardRowHeight = l === "auto" ? "auto" : parseInt(l, 10)), s !== null && (a.hiddenColumns = s.split(",").map((d) => d.trim()).filter((d) => d.length > 0)), o !== null && (a.hideHeader = o !== "false"), c !== null) {
655
658
  const d = parseInt(c, 10);
656
- isNaN(d) || (l.debounceMs = d);
659
+ isNaN(d) || (a.debounceMs = d);
657
660
  }
658
661
  const h = e.innerHTML.trim();
659
- h && !this.config.cardRenderer && !i.__frameworkAdapter?.parseResponsiveCardElement && (l.cardRenderer = (d) => {
660
- const f = T(h, { value: d, row: d }), w = k(f), p = document.createElement("div");
661
- return p.className = "tbw-responsive-card-content", p.innerHTML = w, p;
662
- }), Object.keys(l).length > 0 && (this.config = { ...this.config, ...l });
662
+ h && !this.config.cardRenderer && !i.__frameworkAdapter?.parseResponsiveCardElement && (a.cardRenderer = (d) => {
663
+ const f = T(h, { value: d, row: d }), m = k(f), p = document.createElement("div");
664
+ return p.className = "tbw-responsive-card-content", p.innerHTML = m, p;
665
+ }), Object.keys(a).length > 0 && (this.config = { ...this.config, ...a });
663
666
  }
664
667
  // #endregion
665
668
  /**
@@ -693,9 +696,9 @@ class G extends z {
693
696
  if (!e && !i)
694
697
  return;
695
698
  const n = this.gridElement.querySelectorAll(".cell[data-field]");
696
- for (const a of n) {
697
- const s = a.getAttribute("data-field");
698
- s && (this.#s.has(s) ? (a.setAttribute("data-responsive-hidden", ""), a.removeAttribute("data-responsive-value-only")) : this.#l.has(s) ? (a.setAttribute("data-responsive-value-only", ""), a.removeAttribute("data-responsive-hidden")) : (a.removeAttribute("data-responsive-hidden"), a.removeAttribute("data-responsive-value-only")));
699
+ for (const l of n) {
700
+ const s = l.getAttribute("data-field");
701
+ s && (this.#s.has(s) ? (l.setAttribute("data-responsive-hidden", ""), l.removeAttribute("data-responsive-value-only")) : this.#l.has(s) ? (l.setAttribute("data-responsive-value-only", ""), l.removeAttribute("data-responsive-hidden")) : (l.removeAttribute("data-responsive-hidden"), l.removeAttribute("data-responsive-value-only")));
699
702
  }
700
703
  }
701
704
  /**
@@ -775,8 +778,8 @@ class G extends z {
775
778
  e.replaceChildren();
776
779
  const n = this.config.cardRenderer(t, i);
777
780
  e.className = "data-grid-row responsive-card";
778
- const a = this.config.cardRowHeight ?? "auto";
779
- return a !== "auto" ? e.style.height = `${a}px` : e.style.height = "auto", e.appendChild(n), !0;
781
+ const l = this.config.cardRowHeight ?? "auto";
782
+ return l !== "auto" ? e.style.height = `${l}px` : e.style.height = "auto", e.appendChild(n), !0;
780
783
  }
781
784
  /**
782
785
  * Handle keyboard navigation in responsive mode.
@@ -851,7 +854,7 @@ class G extends z {
851
854
  * Check if there are any group rows in the current dataset.
852
855
  * Used to determine if we have mixed row heights.
853
856
  */
854
- #w() {
857
+ #m() {
855
858
  for (const t of this.rows)
856
859
  if (t.__isGroupRow)
857
860
  return !0;
@@ -880,9 +883,9 @@ class G extends z {
880
883
  * @deprecated Use getRowHeight() instead. This hook will be removed in v3.0.
881
884
  */
882
885
  getExtraHeight() {
883
- if (!this.#t || !this.config.cardRenderer || !this.#w())
886
+ if (!this.#t || !this.config.cardRenderer || !this.#m())
884
887
  return 0;
885
- const t = this.#i ?? 28, e = this.#p(), i = this.#f(), { groupCount: n, cardCount: a } = this.#_(), s = n * Math.max(0, e - t), o = a * Math.max(0, i - t);
888
+ const t = this.#i ?? 28, e = this.#p(), i = this.#f(), { groupCount: n, cardCount: l } = this.#_(), s = n * Math.max(0, e - t), o = l * Math.max(0, i - t);
886
889
  return s + o;
887
890
  }
888
891
  /**
@@ -894,14 +897,14 @@ class G extends z {
894
897
  * @deprecated Use getRowHeight() instead. This hook will be removed in v3.0.
895
898
  */
896
899
  getExtraHeightBefore(t) {
897
- if (!this.#t || !this.config.cardRenderer || !this.#w())
900
+ if (!this.#t || !this.config.cardRenderer || !this.#m())
898
901
  return 0;
899
- const e = this.#i ?? 28, i = this.#p(), n = this.#f(), a = Math.max(0, i - e), s = Math.max(0, n - e);
902
+ const e = this.#i ?? 28, i = this.#p(), n = this.#f(), l = Math.max(0, i - e), s = Math.max(0, n - e);
900
903
  let o = 0, c = 0;
901
- const l = this.rows, h = Math.min(t, l.length);
904
+ const a = this.rows, h = Math.min(t, a.length);
902
905
  for (let d = 0; d < h; d++)
903
- l[d].__isGroupRow ? o++ : c++;
904
- return o * a + c * s;
906
+ a[d].__isGroupRow ? o++ : c++;
907
+ return o * l + c * s;
905
908
  }
906
909
  /**
907
910
  * Get the height of a specific row based on its type (group row vs card row).
@@ -925,7 +928,7 @@ class G extends z {
925
928
  return t;
926
929
  }
927
930
  /** Pending refresh scheduled via microtask */
928
- #m = !1;
931
+ #w = !1;
929
932
  /**
930
933
  * Measure card height from DOM after render and detect row count changes.
931
934
  * Called in afterRender to ensure scroll calculations are accurate.
@@ -945,7 +948,7 @@ class G extends z {
945
948
  if (!this.#t || !this.config.cardRenderer)
946
949
  return;
947
950
  let t = !1;
948
- const e = this.grid, i = this.#w(), n = this.#C();
951
+ const e = this.grid, i = this.#m(), n = this.#C();
949
952
  if (n !== this.#g && (this.#g = n, t = !0), i) {
950
953
  const s = this.gridElement.querySelector(".data-grid-row.group-row");
951
954
  if (s) {
@@ -953,13 +956,13 @@ class G extends z {
953
956
  o > 0 && o !== this.#o && (this.#o = o, t = !0);
954
957
  }
955
958
  }
956
- const a = this.gridElement.querySelector(".data-grid-row.responsive-card");
957
- if (a) {
958
- const s = a.getBoundingClientRect().height;
959
+ const l = this.gridElement.querySelector(".data-grid-row.responsive-card");
960
+ if (l) {
961
+ const s = l.getBoundingClientRect().height;
959
962
  s > 0 && s !== this.#r && (this.#r = s, t = !0, !i && e._virtualization && (e._virtualization.rowHeight = s));
960
963
  }
961
- t && !this.#m && (this.#m = !0, queueMicrotask(() => {
962
- this.#m = !1, this.grid && this.#t && this.grid.refreshVirtualWindow?.(!0, !0);
964
+ t && !this.#w && (this.#w = !0, queueMicrotask(() => {
965
+ this.#w = !1, this.grid && this.#t && this.grid.refreshVirtualWindow?.(!0, !0);
963
966
  }));
964
967
  }
965
968
  }