@toolbox-web/grid 1.9.0 → 1.9.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 (65) hide show
  1. package/all.js +712 -692
  2. package/all.js.map +1 -1
  3. package/index.js +321 -300
  4. package/index.js.map +1 -1
  5. package/lib/core/grid.d.ts +9 -0
  6. package/lib/core/grid.d.ts.map +1 -1
  7. package/lib/core/plugin/base-plugin.d.ts +11 -0
  8. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  9. package/lib/plugins/clipboard/index.js +9 -0
  10. package/lib/plugins/clipboard/index.js.map +1 -1
  11. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +3 -0
  12. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
  13. package/lib/plugins/column-virtualization/index.js +90 -57
  14. package/lib/plugins/column-virtualization/index.js.map +1 -1
  15. package/lib/plugins/context-menu/index.js +9 -0
  16. package/lib/plugins/context-menu/index.js.map +1 -1
  17. package/lib/plugins/editing/index.js +9 -0
  18. package/lib/plugins/editing/index.js.map +1 -1
  19. package/lib/plugins/export/index.js +38 -29
  20. package/lib/plugins/export/index.js.map +1 -1
  21. package/lib/plugins/filtering/index.js +14 -5
  22. package/lib/plugins/filtering/index.js.map +1 -1
  23. package/lib/plugins/grouping-columns/index.js +9 -0
  24. package/lib/plugins/grouping-columns/index.js.map +1 -1
  25. package/lib/plugins/grouping-rows/index.js +63 -54
  26. package/lib/plugins/grouping-rows/index.js.map +1 -1
  27. package/lib/plugins/master-detail/index.js +25 -16
  28. package/lib/plugins/master-detail/index.js.map +1 -1
  29. package/lib/plugins/multi-sort/index.js +13 -4
  30. package/lib/plugins/multi-sort/index.js.map +1 -1
  31. package/lib/plugins/pinned-columns/index.js +13 -4
  32. package/lib/plugins/pinned-columns/index.js.map +1 -1
  33. package/lib/plugins/pinned-rows/index.js +9 -0
  34. package/lib/plugins/pinned-rows/index.js.map +1 -1
  35. package/lib/plugins/pivot/index.js +13 -4
  36. package/lib/plugins/pivot/index.js.map +1 -1
  37. package/lib/plugins/print/index.js +9 -0
  38. package/lib/plugins/print/index.js.map +1 -1
  39. package/lib/plugins/reorder/index.js +13 -4
  40. package/lib/plugins/reorder/index.js.map +1 -1
  41. package/lib/plugins/responsive/index.js +42 -33
  42. package/lib/plugins/responsive/index.js.map +1 -1
  43. package/lib/plugins/row-reorder/index.js +10 -1
  44. package/lib/plugins/row-reorder/index.js.map +1 -1
  45. package/lib/plugins/selection/index.js +10 -1
  46. package/lib/plugins/selection/index.js.map +1 -1
  47. package/lib/plugins/server-side/index.js +29 -20
  48. package/lib/plugins/server-side/index.js.map +1 -1
  49. package/lib/plugins/tree/index.js +20 -11
  50. package/lib/plugins/tree/index.js.map +1 -1
  51. package/lib/plugins/undo-redo/index.js +15 -6
  52. package/lib/plugins/undo-redo/index.js.map +1 -1
  53. package/lib/plugins/visibility/index.js +9 -0
  54. package/lib/plugins/visibility/index.js.map +1 -1
  55. package/package.json +1 -1
  56. package/umd/grid.all.umd.js +14 -14
  57. package/umd/grid.all.umd.js.map +1 -1
  58. package/umd/grid.umd.js +14 -14
  59. package/umd/grid.umd.js.map +1 -1
  60. package/umd/plugins/column-virtualization.umd.js +1 -1
  61. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  62. package/umd/plugins/row-reorder.umd.js +1 -1
  63. package/umd/plugins/row-reorder.umd.js.map +1 -1
  64. package/umd/plugins/selection.umd.js +1 -1
  65. package/umd/plugins/selection.umd.js.map +1 -1
@@ -58,6 +58,7 @@ import { ColumnVirtualizationConfig } from './types';
58
58
  * @internal Extends BaseGridPlugin
59
59
  */
60
60
  export declare class ColumnVirtualizationPlugin extends BaseGridPlugin<ColumnVirtualizationConfig> {
61
+ #private;
61
62
  /** @internal */
62
63
  readonly name = "columnVirtualization";
63
64
  /** @internal */
@@ -69,6 +70,8 @@ export declare class ColumnVirtualizationPlugin extends BaseGridPlugin<ColumnVir
69
70
  private totalWidth;
70
71
  private columnWidths;
71
72
  private columnOffsets;
73
+ /** Store the original full column set for virtualization calculations */
74
+ private originalColumns;
72
75
  /** @internal */
73
76
  attach(grid: import('../../core/plugin/base-plugin').GridElement): void;
74
77
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnVirtualizationPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQrD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,qBAAa,0BAA2B,SAAQ,cAAc,CAAC,0BAA0B,CAAC;IACxF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,0BAA0B;IAEvC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,0BAA0B,CAAC,CAM1E;IAGD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,aAAa,CAAgB;IAKrC,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAWhF,gBAAgB;IACP,MAAM,IAAI,IAAI;IAavB,gBAAgB;IACP,cAAc,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,EAAE;IAgCzE,gBAAgB;IACP,WAAW,IAAI,IAAI;IA2B5B,gBAAgB;IACP,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAiB3C;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;OAEG;IACH,qBAAqB,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAIvD;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAOzC;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAI5C;;OAEG;IACH,aAAa,IAAI,MAAM;CAIxB"}
1
+ {"version":3,"file":"ColumnVirtualizationPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQrD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,qBAAa,0BAA2B,SAAQ,cAAc,CAAC,0BAA0B,CAAC;;IACxF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,0BAA0B;IAEvC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,0BAA0B,CAAC,CAM1E;IAGD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,aAAa,CAAgB;IACrC,yEAAyE;IACzE,OAAO,CAAC,eAAe,CAA+B;IAKtD,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAWhF,gBAAgB;IACP,MAAM,IAAI,IAAI;IA8CvB,gBAAgB;IACP,cAAc,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,EAAE;IAkDzE,gBAAgB;IACP,WAAW,IAAI,IAAI;IAmC5B,gBAAgB;IACP,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAmB3C;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;OAEG;IACH,qBAAqB,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAIvD;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAOzC;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAI5C;;OAEG;IACH,aAAa,IAAI,MAAM;CAIxB"}
@@ -1,4 +1,4 @@
1
- const d = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', b = {
1
+ const c = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', p = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -7,11 +7,11 @@ const d = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
7
7
  submenuArrow: "▶",
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰",
10
- filter: d,
11
- filterActive: d,
10
+ filter: c,
11
+ filterActive: c,
12
12
  print: "🖨️"
13
13
  };
14
- class p {
14
+ class b {
15
15
  /**
16
16
  * Plugin dependencies - declare other plugins this one requires.
17
17
  *
@@ -208,10 +208,19 @@ class p {
208
208
  }
209
209
  /**
210
210
  * Request a re-render of the grid.
211
+ * Uses ROWS phase - does NOT trigger processColumns hooks.
211
212
  */
212
213
  requestRender() {
213
214
  this.grid?.requestRender?.();
214
215
  }
216
+ /**
217
+ * Request a columns re-render of the grid.
218
+ * Uses COLUMNS phase - triggers processColumns hooks.
219
+ * Use this when your plugin needs to reprocess column configuration.
220
+ */
221
+ requestColumnsRender() {
222
+ this.grid?.requestColumnsRender?.();
223
+ }
215
224
  /**
216
225
  * Request a re-render and restore focus styling afterward.
217
226
  * Use this when a plugin action (like expand/collapse) triggers a render
@@ -292,7 +301,7 @@ class p {
292
301
  */
293
302
  get gridIcons() {
294
303
  const t = this.grid?.gridConfig?.icons ?? {};
295
- return { ...b, ...t };
304
+ return { ...p, ...t };
296
305
  }
297
306
  // #region Animation Helpers
298
307
  /**
@@ -368,61 +377,61 @@ class p {
368
377
  }
369
378
  // #endregion
370
379
  }
371
- const c = 100;
372
- function a(r) {
373
- if (r == null)
374
- return c;
375
- if (typeof r == "number")
376
- return r;
377
- const t = parseFloat(r);
378
- return isNaN(t) ? c : t;
380
+ const g = 100;
381
+ function h(s) {
382
+ if (s == null)
383
+ return g;
384
+ if (typeof s == "number")
385
+ return s;
386
+ const t = parseFloat(s);
387
+ return isNaN(t) ? g : t;
379
388
  }
380
- function f(r) {
381
- return r.map((t) => a(t.width));
389
+ function f(s) {
390
+ return s.map((t) => h(t.width));
382
391
  }
383
- function g(r) {
392
+ function m(s) {
384
393
  const t = [];
385
394
  let e = 0;
386
- for (const i of r)
387
- t.push(e), e += a(i.width);
395
+ for (const i of s)
396
+ t.push(e), e += h(i.width);
388
397
  return t;
389
398
  }
390
- function m(r) {
391
- return r.reduce((t, e) => t + a(e.width), 0);
399
+ function C(s) {
400
+ return s.reduce((t, e) => t + h(e.width), 0);
392
401
  }
393
- function w(r, t, e, i, n) {
394
- const s = e.length;
395
- if (s === 0)
402
+ function w(s, t, e, i, o) {
403
+ const r = e.length;
404
+ if (r === 0)
396
405
  return { startCol: 0, endCol: 0, visibleColumns: [] };
397
- let o = v(r, e, i);
398
- o = Math.max(0, o - n);
399
- const C = r + t;
400
- let u = o;
401
- for (let l = o; l < s; l++) {
402
- if (e[l] >= C) {
406
+ let n = y(s, e, i);
407
+ n = Math.max(0, n - o);
408
+ const a = s + t;
409
+ let u = n;
410
+ for (let l = n; l < r; l++) {
411
+ if (e[l] >= a) {
403
412
  u = l - 1;
404
413
  break;
405
414
  }
406
415
  u = l;
407
416
  }
408
- u = Math.min(s - 1, u + n);
409
- const h = [];
410
- for (let l = o; l <= u; l++)
411
- h.push(l);
412
- return { startCol: o, endCol: u, visibleColumns: h };
417
+ u = Math.min(r - 1, u + o);
418
+ const d = [];
419
+ for (let l = n; l <= u; l++)
420
+ d.push(l);
421
+ return { startCol: n, endCol: u, visibleColumns: d };
413
422
  }
414
- function v(r, t, e) {
415
- let i = 0, n = t.length - 1;
416
- for (; i < n; ) {
417
- const s = Math.floor((i + n) / 2);
418
- t[s] + e[s] <= r ? i = s + 1 : n = s;
423
+ function y(s, t, e) {
424
+ let i = 0, o = t.length - 1;
425
+ for (; i < o; ) {
426
+ const r = Math.floor((i + o) / 2);
427
+ t[r] + e[r] <= s ? i = r + 1 : o = r;
419
428
  }
420
429
  return i;
421
430
  }
422
- function E(r, t, e) {
423
- return e ? r > t : !1;
431
+ function R(s, t, e) {
432
+ return e ? s > t : !1;
424
433
  }
425
- class R extends p {
434
+ class E extends b {
426
435
  /** @internal */
427
436
  name = "columnVirtualization";
428
437
  /** @internal */
@@ -441,49 +450,73 @@ class R extends p {
441
450
  totalWidth = 0;
442
451
  columnWidths = [];
443
452
  columnOffsets = [];
453
+ /** Store the original full column set for virtualization calculations */
454
+ originalColumns = [];
444
455
  // #endregion
445
456
  // #region Lifecycle
446
457
  /** @internal */
447
458
  attach(t) {
448
459
  super.attach(t);
449
460
  const e = this.columns;
450
- this.columnWidths = f(e), this.columnOffsets = g(e), this.totalWidth = m(e), this.endCol = e.length - 1;
461
+ this.columnWidths = f(e), this.columnOffsets = m(e), this.totalWidth = C(e), this.endCol = e.length - 1;
451
462
  }
452
463
  /** @internal */
453
464
  detach() {
454
- this.columnWidths = [], this.columnOffsets = [], this.isVirtualized = !1, this.startCol = 0, this.endCol = 0, this.scrollLeft = 0, this.totalWidth = 0;
465
+ this.#t(), this.columnWidths = [], this.columnOffsets = [], this.originalColumns = [], this.isVirtualized = !1, this.startCol = 0, this.endCol = 0, this.scrollLeft = 0, this.totalWidth = 0;
466
+ }
467
+ /**
468
+ * Remove inline styles set by this plugin for proper cleanup.
469
+ */
470
+ #t() {
471
+ const t = this.gridElement;
472
+ if (!t) return;
473
+ const e = t.querySelector(".header-row");
474
+ e && (e.style.paddingLeft = "", e.style.minWidth = ""), t.querySelectorAll(".data-grid-row").forEach((n) => {
475
+ n.style.paddingLeft = "";
476
+ });
477
+ const o = t.querySelector(".rows-viewport .rows");
478
+ o && (o.style.width = "");
479
+ const r = t.querySelector(".rows-body");
480
+ r && (r.style.minWidth = "");
455
481
  }
456
482
  // #endregion
457
483
  // #region Hooks
458
484
  /** @internal */
459
485
  processColumns(t) {
460
- const e = E(t.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
461
- if (this.isVirtualized = e ?? !1, this.columnWidths = f(t), this.columnOffsets = g(t), this.totalWidth = m(t), !e)
462
- return this.startCol = 0, this.endCol = t.length - 1, [...t];
463
- const i = this.grid.clientWidth || 800, n = w(
486
+ (this.originalColumns.length === 0 || t.length > this.originalColumns.length) && (this.originalColumns = t, this.columnWidths = f(t), this.columnOffsets = m(t), this.totalWidth = C(t));
487
+ const i = this.originalColumns, o = R(
488
+ i.length,
489
+ this.config.threshold ?? 30,
490
+ this.config.autoEnable ?? !0
491
+ );
492
+ if (this.isVirtualized = o ?? !1, !o)
493
+ return this.startCol = 0, this.endCol = i.length - 1, [...i];
494
+ const r = this.grid.clientWidth || 800, n = w(
464
495
  this.scrollLeft,
465
- i,
496
+ r,
466
497
  this.columnOffsets,
467
498
  this.columnWidths,
468
499
  this.config.overscan ?? 3
469
500
  );
470
- return this.startCol = n.startCol, this.endCol = n.endCol, n.visibleColumns.map((s) => t[s]);
501
+ return this.startCol = n.startCol, this.endCol = n.endCol, n.visibleColumns.map((a) => i[a]);
471
502
  }
472
503
  /** @internal */
473
504
  afterRender() {
474
505
  if (!this.isVirtualized) return;
475
506
  const t = this.gridElement;
476
507
  if (!t) return;
477
- const e = this.columnOffsets[this.startCol] ?? 0, i = t.querySelector(".header-row"), n = t.querySelectorAll(".data-grid-row");
478
- i && (i.style.paddingLeft = `${e}px`), n.forEach((o) => {
479
- o.style.paddingLeft = `${e}px`;
508
+ const e = this.columnOffsets[this.startCol] ?? 0, i = t.querySelector(".header-row"), o = t.querySelectorAll(".data-grid-row");
509
+ i && (i.style.paddingLeft = `${e}px`, i.style.minWidth = `${this.totalWidth}px`), o.forEach((a) => {
510
+ a.style.paddingLeft = `${e}px`;
480
511
  });
481
- const s = t.querySelector(".rows-viewport .rows");
482
- s && (s.style.width = `${this.totalWidth}px`);
512
+ const r = t.querySelector(".rows-viewport .rows");
513
+ r && (r.style.width = `${this.totalWidth}px`);
514
+ const n = t.querySelector(".rows-body");
515
+ n && (n.style.minWidth = `${this.totalWidth}px`);
483
516
  }
484
517
  /** @internal */
485
518
  onScroll(t) {
486
- !this.isVirtualized || Math.abs(t.scrollLeft - this.scrollLeft) < 1 || (this.scrollLeft = t.scrollLeft, this.requestRender());
519
+ !this.isVirtualized || Math.abs(t.scrollLeft - this.scrollLeft) < 1 || (this.scrollLeft = t.scrollLeft, this.requestColumnsRender());
487
520
  }
488
521
  // #endregion
489
522
  // #region Public API
@@ -523,6 +556,6 @@ class R extends p {
523
556
  // #endregion
524
557
  }
525
558
  export {
526
- R as ColumnVirtualizationPlugin
559
+ E as ColumnVirtualizationPlugin
527
560
  };
528
561
  //# sourceMappingURL=index.js.map