@toolbox-web/grid 1.2.0 → 1.3.1

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 (79) hide show
  1. package/README.md +80 -22
  2. package/all.js +619 -571
  3. package/all.js.map +1 -1
  4. package/index.js +362 -302
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +64 -1
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/row-animation.d.ts +37 -0
  9. package/lib/core/internal/row-animation.d.ts.map +1 -0
  10. package/lib/core/types.d.ts +17 -0
  11. package/lib/core/types.d.ts.map +1 -1
  12. package/lib/plugins/clipboard/index.js +82 -76
  13. package/lib/plugins/clipboard/index.js.map +1 -1
  14. package/lib/plugins/clipboard/types.d.ts +1 -0
  15. package/lib/plugins/clipboard/types.d.ts.map +1 -1
  16. package/lib/plugins/column-virtualization/index.js +43 -41
  17. package/lib/plugins/column-virtualization/index.js.map +1 -1
  18. package/lib/plugins/context-menu/index.js +24 -22
  19. package/lib/plugins/context-menu/index.js.map +1 -1
  20. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  21. package/lib/plugins/editing/index.js +83 -52
  22. package/lib/plugins/editing/index.js.map +1 -1
  23. package/lib/plugins/export/index.js +22 -20
  24. package/lib/plugins/export/index.js.map +1 -1
  25. package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
  26. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  27. package/lib/plugins/filtering/index.js +160 -125
  28. package/lib/plugins/filtering/index.js.map +1 -1
  29. package/lib/plugins/grouping-columns/index.js +20 -18
  30. package/lib/plugins/grouping-columns/index.js.map +1 -1
  31. package/lib/plugins/grouping-rows/index.js +66 -64
  32. package/lib/plugins/grouping-rows/index.js.map +1 -1
  33. package/lib/plugins/master-detail/index.js +51 -49
  34. package/lib/plugins/master-detail/index.js.map +1 -1
  35. package/lib/plugins/multi-sort/index.js +17 -15
  36. package/lib/plugins/multi-sort/index.js.map +1 -1
  37. package/lib/plugins/pinned-columns/index.js +24 -22
  38. package/lib/plugins/pinned-columns/index.js.map +1 -1
  39. package/lib/plugins/pinned-rows/index.js +25 -23
  40. package/lib/plugins/pinned-rows/index.js.map +1 -1
  41. package/lib/plugins/pivot/index.js +49 -47
  42. package/lib/plugins/pivot/index.js.map +1 -1
  43. package/lib/plugins/reorder/index.js +24 -22
  44. package/lib/plugins/reorder/index.js.map +1 -1
  45. package/lib/plugins/responsive/index.js +19 -17
  46. package/lib/plugins/responsive/index.js.map +1 -1
  47. package/lib/plugins/row-reorder/index.js +38 -36
  48. package/lib/plugins/row-reorder/index.js.map +1 -1
  49. package/lib/plugins/selection/SelectionPlugin.d.ts +13 -0
  50. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  51. package/lib/plugins/selection/index.d.ts +1 -1
  52. package/lib/plugins/selection/index.d.ts.map +1 -1
  53. package/lib/plugins/selection/index.js +118 -85
  54. package/lib/plugins/selection/index.js.map +1 -1
  55. package/lib/plugins/selection/types.d.ts +50 -6
  56. package/lib/plugins/selection/types.d.ts.map +1 -1
  57. package/lib/plugins/server-side/index.js +34 -32
  58. package/lib/plugins/server-side/index.js.map +1 -1
  59. package/lib/plugins/tree/index.js +25 -23
  60. package/lib/plugins/tree/index.js.map +1 -1
  61. package/lib/plugins/undo-redo/index.js +22 -20
  62. package/lib/plugins/undo-redo/index.js.map +1 -1
  63. package/lib/plugins/visibility/index.js +21 -19
  64. package/lib/plugins/visibility/index.js.map +1 -1
  65. package/package.json +21 -4
  66. package/public.d.ts +1 -1
  67. package/public.d.ts.map +1 -1
  68. package/umd/grid.all.umd.js +19 -19
  69. package/umd/grid.all.umd.js.map +1 -1
  70. package/umd/grid.umd.js +9 -9
  71. package/umd/grid.umd.js.map +1 -1
  72. package/umd/plugins/clipboard.umd.js +5 -5
  73. package/umd/plugins/clipboard.umd.js.map +1 -1
  74. package/umd/plugins/editing.umd.js +1 -1
  75. package/umd/plugins/editing.umd.js.map +1 -1
  76. package/umd/plugins/filtering.umd.js +1 -1
  77. package/umd/plugins/filtering.umd.js.map +1 -1
  78. package/umd/plugins/selection.umd.js +2 -2
  79. package/umd/plugins/selection.umd.js.map +1 -1
@@ -1,8 +1,4 @@
1
- /**
2
- * Selection Plugin Types
3
- *
4
- * Type definitions for the selection feature.
5
- */
1
+ import { ColumnConfig } from '../../core/types';
6
2
  /**
7
3
  * Selection mode for the grid.
8
4
  *
@@ -47,8 +43,31 @@ export type SelectionMode = 'cell' | 'row' | 'range';
47
43
  * ```
48
44
  */
49
45
  export type SelectionTrigger = 'click' | 'dblclick';
46
+ /**
47
+ * Callback that determines whether a specific row or cell can be selected.
48
+ *
49
+ * Return `true` if the row/cell should be selectable, `false` otherwise.
50
+ *
51
+ * @param row - The row data object
52
+ * @param rowIndex - The row index in the grid
53
+ * @param column - The column config (provided in cell/range modes, undefined in row mode)
54
+ * @param colIndex - The column index (provided in cell/range modes, undefined in row mode)
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * // Prevent selection of locked rows
59
+ * isSelectable: (row) => row.status !== 'locked'
60
+ *
61
+ * // Prevent selection of specific columns
62
+ * isSelectable: (row, rowIndex, col) => col?.field !== 'id'
63
+ *
64
+ * // Permission-based selection
65
+ * isSelectable: (row) => userPermissions.canSelect(row)
66
+ * ```
67
+ */
68
+ export type SelectableCallback<T = unknown> = (row: T, rowIndex: number, column?: ColumnConfig, colIndex?: number) => boolean;
50
69
  /** Configuration options for the selection plugin */
51
- export interface SelectionConfig {
70
+ export interface SelectionConfig<T = unknown> {
52
71
  /** Selection mode (default: 'cell') */
53
72
  mode: SelectionMode;
54
73
  /**
@@ -61,6 +80,31 @@ export interface SelectionConfig {
61
80
  * selection which is unaffected by this option.
62
81
  */
63
82
  triggerOn?: SelectionTrigger;
83
+ /**
84
+ * Callback that determines whether a specific row or cell can be selected.
85
+ *
86
+ * Non-selectable rows/cells:
87
+ * - Don't respond to click/keyboard selection
88
+ * - Are excluded from "select all" operations
89
+ * - Have visual indicator (muted styling via `[data-selectable="false"]`)
90
+ * - Remain focusable for navigation
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * // Prevent selection of locked rows
95
+ * new SelectionPlugin({
96
+ * mode: 'row',
97
+ * isSelectable: (row) => row.status !== 'locked',
98
+ * })
99
+ *
100
+ * // Prevent selection of specific columns (cell/range mode)
101
+ * new SelectionPlugin({
102
+ * mode: 'cell',
103
+ * isSelectable: (row, rowIndex, col) => col?.field !== 'id',
104
+ * })
105
+ * ```
106
+ */
107
+ isSelectable?: SelectableCallback<T>;
64
108
  }
65
109
  /** Internal state managed by the selection plugin */
66
110
  export interface SelectionState {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/selection/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;AAErD;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,UAAU,CAAC;AAEpD,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,IAAI,EAAE,aAAa,CAAC;IAEpB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,wDAAwD;IACxD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,iDAAiD;IACjD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAID,0DAA0D;AAC1D,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB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entColor" 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>', d = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -6,9 +6,11 @@ const a = {
6
6
  sortNone: "⇅",
7
7
  submenuArrow: "▶",
8
8
  dragHandle: "⋮⋮",
9
- toolPanel: "☰"
9
+ toolPanel: "☰",
10
+ filter: c,
11
+ filterActive: c
10
12
  };
11
- class d {
13
+ class u {
12
14
  /**
13
15
  * Plugin dependencies - declare other plugins this one requires.
14
16
  *
@@ -232,7 +234,7 @@ class d {
232
234
  */
233
235
  get gridIcons() {
234
236
  const e = this.grid?.gridConfig?.icons ?? {};
235
- return { ...a, ...e };
237
+ return { ...d, ...e };
236
238
  }
237
239
  // #region Animation Helpers
238
240
  /**
@@ -311,35 +313,35 @@ class d {
311
313
  function l(s, e) {
312
314
  return Math.floor(s / e);
313
315
  }
314
- function u(s, e) {
316
+ function h(s, e) {
315
317
  return {
316
318
  start: s * e,
317
319
  end: (s + 1) * e
318
320
  };
319
321
  }
320
- function h(s, e, t) {
321
- const o = l(s, t), i = l(e - 1, t), r = [];
322
- for (let n = o; n <= i; n++)
323
- r.push(n);
324
- return r;
322
+ function g(s, e, t) {
323
+ const o = l(s, t), r = l(e - 1, t), i = [];
324
+ for (let n = o; n <= r; n++)
325
+ i.push(n);
326
+ return i;
325
327
  }
326
- async function c(s, e, t, o) {
327
- const i = u(e, t);
328
+ async function a(s, e, t, o) {
329
+ const r = h(e, t);
328
330
  return s.getRows({
329
- startRow: i.start,
330
- endRow: i.end,
331
+ startRow: r.start,
332
+ endRow: r.end,
331
333
  sortModel: o.sortModel,
332
334
  filterModel: o.filterModel
333
335
  });
334
336
  }
335
- function g(s, e, t) {
336
- const o = l(s, e), i = t.get(o);
337
- if (!i) return;
338
- const r = s % e;
339
- return i[r];
337
+ function f(s, e, t) {
338
+ const o = l(s, e), r = t.get(o);
339
+ if (!r) return;
340
+ const i = s % e;
341
+ return r[i];
340
342
  }
341
- const f = 100;
342
- class R extends d {
343
+ const R = 100;
344
+ class k extends u {
343
345
  /** @internal */
344
346
  name = "serverSide";
345
347
  /** @internal */
@@ -370,15 +372,15 @@ class R extends d {
370
372
  */
371
373
  loadRequiredBlocks() {
372
374
  if (!this.dataSource) return;
373
- const e = this.grid, t = this.config.cacheBlockSize ?? 100, o = { startRow: e._virtualization.start, endRow: e._virtualization.end }, i = h(o.startRow, o.endRow, t);
374
- for (const r of i)
375
- if (!(this.loadedBlocks.has(r) || this.loadingBlocks.has(r))) {
375
+ const e = this.grid, t = this.config.cacheBlockSize ?? 100, o = { startRow: e._virtualization.start, endRow: e._virtualization.end }, r = g(o.startRow, o.endRow, t);
376
+ for (const i of r)
377
+ if (!(this.loadedBlocks.has(i) || this.loadingBlocks.has(i))) {
376
378
  if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
377
379
  break;
378
- this.loadingBlocks.add(r), c(this.dataSource, r, t, {}).then((n) => {
379
- this.loadedBlocks.set(r, n.rows), this.totalRowCount = n.totalRowCount, this.loadingBlocks.delete(r), this.requestRender(), this.loadRequiredBlocks();
380
+ this.loadingBlocks.add(i), a(this.dataSource, i, t, {}).then((n) => {
381
+ this.loadedBlocks.set(i, n.rows), this.totalRowCount = n.totalRowCount, this.loadingBlocks.delete(i), this.requestRender(), this.loadRequiredBlocks();
380
382
  }).catch(() => {
381
- this.loadingBlocks.delete(r);
383
+ this.loadingBlocks.delete(i);
382
384
  });
383
385
  }
384
386
  }
@@ -389,8 +391,8 @@ class R extends d {
389
391
  if (!this.dataSource) return [...e];
390
392
  const t = [];
391
393
  for (let o = 0; o < this.totalRowCount; o++) {
392
- const i = g(o, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
393
- t.push(i ?? { __loading: !0, __index: o });
394
+ const r = f(o, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
395
+ t.push(r ?? { __loading: !0, __index: o });
394
396
  }
395
397
  return t;
396
398
  }
@@ -398,7 +400,7 @@ class R extends d {
398
400
  onScroll(e) {
399
401
  this.dataSource && (this.loadRequiredBlocks(), this.scrollDebounceTimer && clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = setTimeout(() => {
400
402
  this.loadRequiredBlocks();
401
- }, f));
403
+ }, R));
402
404
  }
403
405
  // #endregion
404
406
  // #region Public API
@@ -409,7 +411,7 @@ class R extends d {
409
411
  setDataSource(e) {
410
412
  this.dataSource = e, this.loadedBlocks.clear(), this.loadingBlocks.clear();
411
413
  const t = this.config.cacheBlockSize ?? 100;
412
- c(e, 0, t, {}).then((o) => {
414
+ a(e, 0, t, {}).then((o) => {
413
415
  this.loadedBlocks.set(0, o.rows), this.totalRowCount = o.totalRowCount, this.requestRender();
414
416
  });
415
417
  }
@@ -448,6 +450,6 @@ class R extends d {
448
450
  // #endregion
449
451
  }
450
452
  export {
451
- R as ServerSidePlugin
453
+ k as ServerSidePlugin
452
454
  };
453
455
  //# sourceMappingURL=index.js.map