@toolbox-web/grid 1.17.0 → 1.18.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 (61) hide show
  1. package/README.md +126 -41
  2. package/all.js +1045 -935
  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/index.js.map +1 -1
  47. package/lib/plugins/server-side/index.js.map +1 -1
  48. package/lib/plugins/tree/index.js.map +1 -1
  49. package/lib/plugins/undo-redo/index.js.map +1 -1
  50. package/lib/plugins/visibility/index.js.map +1 -1
  51. package/package.json +1 -1
  52. package/umd/grid.all.umd.js +29 -29
  53. package/umd/grid.all.umd.js.map +1 -1
  54. package/umd/grid.umd.js +2 -2
  55. package/umd/grid.umd.js.map +1 -1
  56. package/umd/plugins/editing.umd.js +1 -1
  57. package/umd/plugins/editing.umd.js.map +1 -1
  58. package/umd/plugins/filtering.umd.js +1 -1
  59. package/umd/plugins/filtering.umd.js.map +1 -1
  60. package/umd/plugins/multi-sort.umd.js +1 -1
  61. package/umd/plugins/multi-sort.umd.js.map +1 -1
package/index.js CHANGED
@@ -1092,19 +1092,22 @@ function $(t, e) {
1092
1092
  p < u ? a.scrollLeft = p - c.left : g > d && (a.scrollLeft = g - a.clientWidth + c.right);
1093
1093
  }
1094
1094
  }
1095
- if (t._activeEditRows !== void 0 && t._activeEditRows !== -1 && l.classList.contains("editing")) {
1095
+ if (i && l.classList.contains("editing")) {
1096
1096
  const c = l.querySelector(Je);
1097
1097
  if (c && document.activeElement !== c)
1098
1098
  try {
1099
1099
  c.focus({ preventScroll: !0 });
1100
1100
  } catch {
1101
1101
  }
1102
- } else if (!l.contains(document.activeElement)) {
1102
+ } else if (i && !l.contains(document.activeElement)) {
1103
1103
  l.hasAttribute("tabindex") || l.setAttribute("tabindex", "-1");
1104
1104
  try {
1105
1105
  l.focus({ preventScroll: !0 });
1106
1106
  } catch {
1107
1107
  }
1108
+ } else if (!i) {
1109
+ const c = t;
1110
+ document.activeElement !== c && c.focus({ preventScroll: !0 });
1108
1111
  }
1109
1112
  }
1110
1113
  }
@@ -1259,7 +1262,7 @@ function oe(t) {
1259
1262
  const e = t._headerRowEl;
1260
1263
  e && (e.innerHTML = "", t._visibleColumns.forEach((i, o) => {
1261
1264
  const n = document.createElement("div");
1262
- n.className = "cell", Ge(n, "header-cell"), n.setAttribute("role", "columnheader"), n.setAttribute("aria-colindex", String(o + 1)), n.setAttribute("data-field", i.field), n.setAttribute("data-col", String(o));
1265
+ n.className = "cell", Ge(n, "header-cell"), n.setAttribute("role", "columnheader"), n.setAttribute("aria-colindex", String(o + 1)), n.setAttribute("data-field", i.field), n.setAttribute("data-col", String(o)), i.type && n.setAttribute("data-type", i.type);
1263
1266
  const r = i.header ?? i.field, s = t._sortState?.field === i.field ? t._sortState.direction : 0, l = s === 1 ? "asc" : s === -1 ? "desc" : null;
1264
1267
  if (i.headerRenderer) {
1265
1268
  const a = {
@@ -2774,7 +2777,7 @@ ${Qi}
2774
2777
  `;
2775
2778
  class k extends HTMLElement {
2776
2779
  static tagName = "tbw-grid";
2777
- static version = "1.17.0";
2780
+ static version = "1.18.0";
2778
2781
  static #l = 0;
2779
2782
  static adapters = [];
2780
2783
  static registerAdapter(e) {
@@ -2818,7 +2821,7 @@ class k extends HTMLElement {
2818
2821
  #b;
2819
2822
  #y;
2820
2823
  #p;
2821
- #S;
2824
+ #R;
2822
2825
  #ee = {
2823
2826
  scrollTop: 0,
2824
2827
  scrollLeft: 0,
@@ -2831,7 +2834,7 @@ class k extends HTMLElement {
2831
2834
  #_;
2832
2835
  #N = !1;
2833
2836
  #D;
2834
- #B;
2837
+ #G;
2835
2838
  #O;
2836
2839
  #i;
2837
2840
  #e = hi();
@@ -2842,9 +2845,9 @@ class k extends HTMLElement {
2842
2845
  #E = /* @__PURE__ */ new Set();
2843
2846
  #H = /* @__PURE__ */ new Map();
2844
2847
  #W;
2845
- #R = /* @__PURE__ */ new Map();
2848
+ #S = /* @__PURE__ */ new Map();
2846
2849
  _rows = [];
2847
- #G = [];
2850
+ #X = [];
2848
2851
  get _columns() {
2849
2852
  return this.#o.columns ?? [];
2850
2853
  }
@@ -2974,7 +2977,7 @@ class k extends HTMLElement {
2974
2977
  constructor() {
2975
2978
  super(), this.#me(), this.#d = new Promise((e) => this.#h = e), this.#s = new ti({
2976
2979
  mergeConfig: () => {
2977
- this.#i.parseLightDomColumns(this), this.#i.merge(), this.#ie(), Mi(this.#o, this.#t?.getPlugins() ?? []), ki(this.#t?.getPlugins() ?? []), Ni(this.#t?.getPlugins() ?? []), this.#De(), this.#G = [...this._columns];
2980
+ this.#i.parseLightDomColumns(this), this.#i.merge(), this.#ie(), Mi(this.#o, this.#t?.getPlugins() ?? []), ki(this.#t?.getPlugins() ?? []), Ni(this.#t?.getPlugins() ?? []), this.#De(), this.#X = [...this._columns];
2978
2981
  },
2979
2982
  processColumns: () => this.#He(),
2980
2983
  processRows: () => this.#Pe(),
@@ -3089,7 +3092,7 @@ class k extends HTMLElement {
3089
3092
  const o = this.#g;
3090
3093
  if (this.#g = this.#t?.getAll().some((n) => n.onScroll) ?? !1, !o && this.#g) {
3091
3094
  const r = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
3092
- this.#X(r);
3095
+ this.#Y(r);
3093
3096
  }
3094
3097
  }
3095
3098
  #ve() {
@@ -3121,9 +3124,9 @@ class k extends HTMLElement {
3121
3124
  };
3122
3125
  }
3123
3126
  connectedCallback() {
3124
- this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", k.version), this.id || (this.id = `tbw-grid-${++k.#l}`), this._rows = Array.isArray(this.#a) ? [...this.#a] : [], this.#b && (this.#b.abort(), this.#N = !1), this.#b = new AbortController(), this.#S && (Oe(this.#S), this.#S = void 0), this.#k(), this.#i.parseLightDomColumns(this), this.#i.merge(), this.#te();
3127
+ this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", k.version), this.id || (this.id = `tbw-grid-${++k.#l}`), this._rows = Array.isArray(this.#a) ? [...this.#a] : [], this.#b && (this.#b.abort(), this.#N = !1), this.#b = new AbortController(), this.#R && (Oe(this.#R), this.#R = void 0), this.#k(), this.#i.parseLightDomColumns(this), this.#i.merge(), this.#te();
3125
3128
  const e = this.#o?.plugins;
3126
- this.#_ = Array.isArray(e) ? e : [], this.#oe(), this.#u || (this.#J(), this.#F(), this.#u = !0), this.#re(), this.#S = Xt(
3129
+ this.#_ = Array.isArray(e) ? e : [], this.#oe(), this.#u || (this.#J(), this.#F(), this.#u = !0), this.#re(), this.#R = Xt(
3127
3130
  () => {
3128
3131
  this.#Ie();
3129
3132
  },
@@ -3131,7 +3134,7 @@ class k extends HTMLElement {
3131
3134
  );
3132
3135
  }
3133
3136
  disconnectedCallback() {
3134
- this.#S && (Oe(this.#S), this.#S = void 0), this.#m && (clearTimeout(this.#m), this.#m = 0), this.#ve(), bi(this.#e), this.#c.setInitialized(!1), this.#q?.(), this.#q = void 0, this.#$?.(), this.#$ = void 0, lt(this.#I), this.#b && (this.#b.abort(), this.#b = void 0), this.#D?.abort(), this.#D = void 0, this.#N = !1, this._resizeController && this._resizeController.dispose(), this.#y && (this.#y.disconnect(), this.#y = void 0), this.#p && (this.#p.disconnect(), this.#p = void 0, this.#U = !1), Y(this), this.#A.clear(), this.#_ = void 0;
3137
+ this.#R && (Oe(this.#R), this.#R = void 0), this.#m && (clearTimeout(this.#m), this.#m = 0), this.#ve(), bi(this.#e), this.#c.setInitialized(!1), this.#q?.(), this.#q = void 0, this.#$?.(), this.#$ = void 0, lt(this.#I), this.#b && (this.#b.abort(), this.#b = void 0), this.#D?.abort(), this.#D = void 0, this.#N = !1, this._resizeController && this._resizeController.dispose(), this.#y && (this.#y.disconnect(), this.#y = void 0), this.#p && (this.#p.disconnect(), this.#p = void 0, this.#U = !1), Y(this), this.#A.clear(), this.#_ = void 0;
3135
3138
  for (const e of this._rowPool)
3136
3139
  e.remove();
3137
3140
  this._rowPool.length = 0, this.__rowsBodyEl = null, this.#f = !1;
@@ -3159,7 +3162,7 @@ class k extends HTMLElement {
3159
3162
  const n = this.#o?.shell?.toolPanel?.defaultOpen;
3160
3163
  n && this.#e.toolPanels.has(n) && (this.openToolPanel(), this.#e.expandedSections.add(n));
3161
3164
  }
3162
- if (this.setAttribute("data-upgraded", ""), this.#f = !0, this._resizeController = Me(this), this.#P(), this.#X(i), this.#N)
3165
+ if (this.setAttribute("data-upgraded", ""), this.#f = !0, this._resizeController = Me(this), this.#P(), this.#Y(i), this.#N)
3163
3166
  return;
3164
3167
  this.#N = !0;
3165
3168
  const o = this.disconnectSignal;
@@ -3198,7 +3201,7 @@ class k extends HTMLElement {
3198
3201
  this._virtualization.totalHeightEl.style.height = `${l}px`;
3199
3202
  }
3200
3203
  }
3201
- #X(e) {
3204
+ #Y(e) {
3202
3205
  this.#D?.abort(), this.#D = new AbortController();
3203
3206
  const i = this.#D.signal, o = e?.querySelector(".faux-vscroll"), n = e?.querySelector(".rows");
3204
3207
  if (this._virtualization.container = o ?? this, this.#g = this.#t?.getAll().some((r) => r.onScroll) ?? !1, o && n) {
@@ -3228,7 +3231,7 @@ class k extends HTMLElement {
3228
3231
  { passive: !0, signal: i }
3229
3232
  );
3230
3233
  const r = this.#n.querySelector(".tbw-scroll-area");
3231
- this.#B = r, this._virtualization.scrollAreaEl = r, r && this.#g && r.addEventListener(
3234
+ this.#G = r, this._virtualization.scrollAreaEl = r, r && this.#g && r.addEventListener(
3232
3235
  "scroll",
3233
3236
  () => {
3234
3237
  const a = this.#ee;
@@ -3236,7 +3239,7 @@ class k extends HTMLElement {
3236
3239
  },
3237
3240
  { passive: !0, signal: i }
3238
3241
  );
3239
- const s = this.#n.querySelector(".tbw-grid-content"), l = this.#B;
3242
+ const s = this.#n.querySelector(".tbw-grid-content"), l = this.#G;
3240
3243
  s && (s.addEventListener(
3241
3244
  "wheel",
3242
3245
  (a) => {
@@ -3320,14 +3323,14 @@ class k extends HTMLElement {
3320
3323
  e.columns && this.#Re(), e.rows && this.#ae(), e.fitMode && this.#Ae();
3321
3324
  }
3322
3325
  #ae() {
3323
- this._rows = Array.isArray(this.#a) ? [...this.#a] : [], this.#Y(), this.#s.requestPhase(A.ROWS, "applyRowsUpdate");
3326
+ this._rows = Array.isArray(this.#a) ? [...this.#a] : [], this.#B(), this.#s.requestPhase(A.ROWS, "applyRowsUpdate");
3324
3327
  }
3325
- #Y() {
3326
- this.#R.clear();
3328
+ #B() {
3329
+ this.#S.clear();
3327
3330
  const e = this.#o.getRowId;
3328
3331
  this._rows.forEach((i, o) => {
3329
3332
  const n = this.#ce(i, e);
3330
- n !== void 0 && this.#R.set(n, { row: i, index: o });
3333
+ n !== void 0 && this.#S.set(n, { row: i, index: o });
3331
3334
  });
3332
3335
  }
3333
3336
  #ce(e, i) {
@@ -3359,10 +3362,10 @@ class k extends HTMLElement {
3359
3362
  this.#i.parseLightDomColumns(this), this.#i.merge(), this.#ie(), qe(this, this.#e, this.#ne()), this.#i.markSourcesChanged(), this.#i.merge();
3360
3363
  const n = st(this.#o?.shell), r = (this.#o?.shell?.toolPanels?.length ?? 0) > 0, s = this.#o?.shell?.toolPanels?.length ?? 0;
3361
3364
  if (e !== n || !i && r || i && s !== o) {
3362
- he(this.#e), this.#J(), this.#F(), this.#re(), this.#Y();
3365
+ he(this.#e), this.#J(), this.#F(), this.#re(), this.#B();
3363
3366
  return;
3364
3367
  }
3365
- e && this.#xe(), this.#Y(), this.#s.requestPhase(A.COLUMNS, "applyGridConfigUpdate");
3368
+ e && this.#xe(), this.#B(), this.#s.requestPhase(A.COLUMNS, "applyGridConfigUpdate");
3366
3369
  }
3367
3370
  #xe() {
3368
3371
  const e = this.#n.querySelector(".tbw-shell-header");
@@ -3373,7 +3376,7 @@ class k extends HTMLElement {
3373
3376
  }
3374
3377
  #He() {
3375
3378
  if (this.#t) {
3376
- const e = this.#G.length > 0 ? this.#G : this._columns, i = e.filter((r) => !r.hidden), o = e.filter((r) => r.hidden), n = this.#t.processColumns([...i]);
3379
+ const e = this.#X.length > 0 ? this.#X : this._columns, i = e.filter((r) => !r.hidden), o = e.filter((r) => r.hidden), n = this.#t.processColumns([...i]);
3377
3380
  if (n !== i) {
3378
3381
  const r = new Set(n.map((l) => l.field));
3379
3382
  !i.some((l) => r.has(l.field)) && n.length > 0 ? this._columns = [...n, ...o] : this._columns = this.#Le(
@@ -3403,7 +3406,7 @@ class k extends HTMLElement {
3403
3406
  #Pe() {
3404
3407
  Y(this);
3405
3408
  const e = Array.isArray(this.#a) ? [...this.#a] : [], i = this.#t?.processRows(e) ?? e;
3406
- this._rows = i, this._virtualization.variableHeights && this.#Z();
3409
+ this._rows = i, this.#B(), this._virtualization.variableHeights && this.#Z();
3407
3410
  }
3408
3411
  #ze(e) {
3409
3412
  const i = {
@@ -3430,13 +3433,13 @@ class k extends HTMLElement {
3430
3433
  e && (this.#M ? (this.#W || (this.#W = Kt(this.#o?.loadingRenderer)), Qt(e, this.#W)) : Zt(this.#W));
3431
3434
  }
3432
3435
  #K(e, i) {
3433
- const o = this.#R.get(e);
3436
+ const o = this.#S.get(e);
3434
3437
  if (!o) return;
3435
3438
  const n = this.findRenderedRowElement?.(o.index);
3436
3439
  n && Jt(n, i);
3437
3440
  }
3438
3441
  #fe(e, i, o) {
3439
- const n = this.#R.get(e);
3442
+ const n = this.#S.get(e);
3440
3443
  if (!n) return;
3441
3444
  const r = this.findRenderedRowElement?.(n.index);
3442
3445
  if (!r) return;
@@ -3459,7 +3462,7 @@ class k extends HTMLElement {
3459
3462
  #Oe(e) {
3460
3463
  let i = 0, o = 0, n = 0, r = 0, s = 0;
3461
3464
  if (this.#g) {
3462
- const a = this._virtualization.container, c = this.#B;
3465
+ const a = this._virtualization.container, c = this.#G;
3463
3466
  i = c?.scrollLeft ?? 0, o = a?.scrollHeight ?? 0, n = c?.scrollWidth ?? 0, r = a?.clientHeight ?? 0, s = c?.clientWidth ?? 0;
3464
3467
  }
3465
3468
  if (this.refreshVirtualWindow(!1) && this.#t?.onScrollRender(), this._virtualization.variableHeights && (this.#m && clearTimeout(this.#m), this.#m = window.setTimeout(() => {
@@ -3578,10 +3581,13 @@ class k extends HTMLElement {
3578
3581
  return this.#Se(e, this.#o.getRowId);
3579
3582
  }
3580
3583
  getRow(e) {
3581
- return this.#R.get(e)?.row;
3584
+ return this.#S.get(e)?.row;
3585
+ }
3586
+ _getRowEntry(e) {
3587
+ return this.#S.get(e);
3582
3588
  }
3583
3589
  updateRow(e, i, o = "api") {
3584
- const n = this.#R.get(e);
3590
+ const n = this.#S.get(e);
3585
3591
  if (!n)
3586
3592
  throw new Error(
3587
3593
  `[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`
@@ -3607,7 +3613,7 @@ class k extends HTMLElement {
3607
3613
  updateRows(e, i = "api") {
3608
3614
  let o = !1;
3609
3615
  for (const { id: n, changes: r } of e) {
3610
- const s = this.#R.get(n);
3616
+ const s = this.#S.get(n);
3611
3617
  if (!s)
3612
3618
  throw new Error(
3613
3619
  `[tbw-grid] Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`
@@ -3745,7 +3751,7 @@ class k extends HTMLElement {
3745
3751
  const o = this.#o?.shell?.toolPanel?.defaultOpen;
3746
3752
  o && this.#e.toolPanels.has(o) && (this.openToolPanel(), this.#e.expandedSections.add(o));
3747
3753
  }
3748
- this._resizeController = Me(this), this.#X(i), this.#s.requestPhase(A.COLUMNS, "shellRefresh");
3754
+ this._resizeController = Me(this), this.#Y(i), this.#s.requestPhase(A.COLUMNS, "shellRefresh");
3749
3755
  }
3750
3756
  #A = /* @__PURE__ */ new Map();
3751
3757
  registerStyles(e, i) {
@@ -3972,7 +3978,7 @@ const lo = {
3972
3978
  class ao {
3973
3979
  static dependencies;
3974
3980
  static manifest;
3975
- version = "1.17.0";
3981
+ version = "1.18.0";
3976
3982
  styles;
3977
3983
  cellRenderers;
3978
3984
  headerRenderers;