@toolbox-web/grid 1.6.2 → 1.8.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 (114) hide show
  1. package/README.md +51 -15
  2. package/all.js +267 -158
  3. package/all.js.map +1 -1
  4. package/index.js +866 -722
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +68 -1
  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/plugin/base-plugin.d.ts +182 -1
  10. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  11. package/lib/core/plugin/index.d.ts +1 -1
  12. package/lib/core/plugin/index.d.ts.map +1 -1
  13. package/lib/core/plugin/plugin-manager.d.ts +56 -1
  14. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  15. package/lib/core/plugin/types.d.ts +36 -0
  16. package/lib/core/plugin/types.d.ts.map +1 -1
  17. package/lib/core/types.d.ts +1349 -31
  18. package/lib/core/types.d.ts.map +1 -1
  19. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  20. package/lib/plugins/clipboard/index.js +140 -87
  21. package/lib/plugins/clipboard/index.js.map +1 -1
  22. package/lib/plugins/column-virtualization/index.js +64 -7
  23. package/lib/plugins/column-virtualization/index.js.map +1 -1
  24. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  25. package/lib/plugins/context-menu/index.js +123 -65
  26. package/lib/plugins/context-menu/index.js.map +1 -1
  27. package/lib/plugins/editing/EditingPlugin.d.ts +6 -1
  28. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  29. package/lib/plugins/editing/index.js +95 -13
  30. package/lib/plugins/editing/index.js.map +1 -1
  31. package/lib/plugins/export/index.js +91 -34
  32. package/lib/plugins/export/index.js.map +1 -1
  33. package/lib/plugins/filtering/FilteringPlugin.d.ts +6 -1
  34. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  35. package/lib/plugins/filtering/index.js +192 -123
  36. package/lib/plugins/filtering/index.js.map +1 -1
  37. package/lib/plugins/grouping-columns/index.js +57 -0
  38. package/lib/plugins/grouping-columns/index.js.map +1 -1
  39. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +7 -2
  40. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  41. package/lib/plugins/grouping-rows/index.js +142 -60
  42. package/lib/plugins/grouping-rows/index.js.map +1 -1
  43. package/lib/plugins/master-detail/index.js +69 -12
  44. package/lib/plugins/master-detail/index.js.map +1 -1
  45. package/lib/plugins/multi-sort/index.js +70 -13
  46. package/lib/plugins/multi-sort/index.js.map +1 -1
  47. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +3 -3
  48. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  49. package/lib/plugins/pinned-columns/index.js +106 -36
  50. package/lib/plugins/pinned-columns/index.js.map +1 -1
  51. package/lib/plugins/pinned-rows/index.js +57 -0
  52. package/lib/plugins/pinned-rows/index.js.map +1 -1
  53. package/lib/plugins/pivot/index.js +57 -0
  54. package/lib/plugins/pivot/index.js.map +1 -1
  55. package/lib/plugins/print/PrintPlugin.d.ts.map +1 -1
  56. package/lib/plugins/print/index.js +58 -1
  57. package/lib/plugins/print/index.js.map +1 -1
  58. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  59. package/lib/plugins/reorder/column-drag.d.ts +2 -2
  60. package/lib/plugins/reorder/index.js +68 -17
  61. package/lib/plugins/reorder/index.js.map +1 -1
  62. package/lib/plugins/responsive/ResponsivePlugin.d.ts +6 -1
  63. package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
  64. package/lib/plugins/responsive/index.js +125 -54
  65. package/lib/plugins/responsive/index.js.map +1 -1
  66. package/lib/plugins/row-reorder/index.js +169 -112
  67. package/lib/plugins/row-reorder/index.js.map +1 -1
  68. package/lib/plugins/selection/SelectionPlugin.d.ts +14 -2
  69. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  70. package/lib/plugins/selection/index.js +84 -7
  71. package/lib/plugins/selection/index.js.map +1 -1
  72. package/lib/plugins/server-side/index.js +79 -22
  73. package/lib/plugins/server-side/index.js.map +1 -1
  74. package/lib/plugins/tree/TreePlugin.d.ts +7 -1
  75. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  76. package/lib/plugins/tree/index.js +140 -58
  77. package/lib/plugins/tree/index.js.map +1 -1
  78. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +6 -1
  79. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  80. package/lib/plugins/undo-redo/index.js +79 -10
  81. package/lib/plugins/undo-redo/index.js.map +1 -1
  82. package/lib/plugins/visibility/index.js +57 -0
  83. package/lib/plugins/visibility/index.js.map +1 -1
  84. package/package.json +1 -1
  85. package/public.d.ts +80 -2
  86. package/public.d.ts.map +1 -1
  87. package/umd/grid.all.umd.js +25 -25
  88. package/umd/grid.all.umd.js.map +1 -1
  89. package/umd/grid.umd.js +15 -15
  90. package/umd/grid.umd.js.map +1 -1
  91. package/umd/plugins/clipboard.umd.js +5 -5
  92. package/umd/plugins/clipboard.umd.js.map +1 -1
  93. package/umd/plugins/context-menu.umd.js +1 -1
  94. package/umd/plugins/context-menu.umd.js.map +1 -1
  95. package/umd/plugins/editing.umd.js +1 -1
  96. package/umd/plugins/editing.umd.js.map +1 -1
  97. package/umd/plugins/filtering.umd.js +1 -1
  98. package/umd/plugins/filtering.umd.js.map +1 -1
  99. package/umd/plugins/grouping-rows.umd.js +2 -2
  100. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  101. package/umd/plugins/pinned-columns.umd.js +1 -1
  102. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  103. package/umd/plugins/print.umd.js +1 -1
  104. package/umd/plugins/print.umd.js.map +1 -1
  105. package/umd/plugins/reorder.umd.js +1 -1
  106. package/umd/plugins/reorder.umd.js.map +1 -1
  107. package/umd/plugins/responsive.umd.js +1 -1
  108. package/umd/plugins/responsive.umd.js.map +1 -1
  109. package/umd/plugins/selection.umd.js +2 -2
  110. package/umd/plugins/selection.umd.js.map +1 -1
  111. package/umd/plugins/tree.umd.js +1 -1
  112. package/umd/plugins/tree.umd.js.map +1 -1
  113. package/umd/plugins/undo-redo.umd.js +1 -1
  114. package/umd/plugins/undo-redo.umd.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ReorderPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder/ReorderPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAAkB,MAAM,+BAA+B,CAAC;AAI/E,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,cAAc,CAAC,aAAa,CAAC;IAC9D,gBAAgB;IAChB,QAAQ,CAAC,IAAI,aAAa;IAC1B,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,CAI7D;IAED;;;OAGG;IACH,OAAO,KAAK,aAAa,GAQxB;IAED;;;OAGG;IACH,cAAuB,iBAAiB,IAAI,MAAM,CAMjD;IAGD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAAuB;IAExC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAiBhF,gBAAgB;IACP,MAAM,I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AuB;IAC3C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAAuB;IAExC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAOhC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAiBhF,gBAAgB;IACP,MAAM,IAAI,IAAI;IAUvB,gBAAgB;IACP,WAAW,IAAI,IAAI;IAiG5B;;;OAGG;IACM,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,IAAI;IAyCxD;;;OAGG;IACH,cAAc,IAAI,MAAM,EAAE;IAI1B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAoBhD;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAIrC;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAQxB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAmDnB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAgDnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAqB1B"}
@@ -4,8 +4,8 @@ import { ColumnConfig } from '../../core/types';
4
4
  * This checks column-level properties like lockPosition and suppressMovable.
5
5
  *
6
6
  * Note: For full movability checks including plugin constraints (e.g., pinned columns),
7
- * use `grid.queryPlugins({ type: PLUGIN_QUERIES.CAN_MOVE_COLUMN, context: column })`
8
- * which queries all plugins via the generic plugin query system.
7
+ * use `grid.query<boolean>('canMoveColumn', column)` which queries all plugins that
8
+ * declare the 'canMoveColumn' query in their manifest.
9
9
  *
10
10
  * @param column - The column configuration to check
11
11
  * @returns True if the column can be moved based on its metadata
@@ -1,4 +1,4 @@
1
- function b(l) {
1
+ function v(l) {
2
2
  l && l.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
3
3
  }
4
4
  const C = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])', E = document.createElement("template");
@@ -14,7 +14,7 @@ function y(l, e) {
14
14
  }
15
15
  }
16
16
  const t = l._activeEditRows !== void 0 && l._activeEditRows !== -1;
17
- t || l.refreshVirtualWindow(!1), b(l._bodyEl), Array.from(l._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((a) => {
17
+ t || l.refreshVirtualWindow(!1), v(l._bodyEl), Array.from(l._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((a) => {
18
18
  a.setAttribute("aria-selected", "false");
19
19
  });
20
20
  const i = l._focusRow, n = l._virtualization.start ?? 0, d = l._virtualization.end ?? l._rows.length;
@@ -60,11 +60,8 @@ const p = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
60
60
  filter: p,
61
61
  filterActive: p,
62
62
  print: "🖨️"
63
- }, A = {
64
- /** Ask if a column can be moved. Context: ColumnConfig. Response: boolean | undefined */
65
- CAN_MOVE_COLUMN: "canMoveColumn"
66
63
  };
67
- class O {
64
+ class A {
68
65
  /**
69
66
  * Plugin dependencies - declare other plugins this one requires.
70
67
  *
@@ -202,6 +199,63 @@ class O {
202
199
  const i = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
203
200
  return this.grid?.dispatchEvent?.(i), i.defaultPrevented;
204
201
  }
202
+ // =========================================================================
203
+ // Event Bus - Plugin-to-Plugin Communication
204
+ // =========================================================================
205
+ /**
206
+ * Subscribe to an event from another plugin.
207
+ * The subscription is automatically cleaned up when this plugin is detached.
208
+ *
209
+ * @category Plugin Development
210
+ * @param eventType - The event type to listen for (e.g., 'filter-change')
211
+ * @param callback - The callback to invoke when the event is emitted
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * // In attach() or other initialization
216
+ * this.on('filter-change', (detail) => {
217
+ * console.log('Filter changed:', detail);
218
+ * });
219
+ * ```
220
+ */
221
+ on(e, t) {
222
+ this.grid?._pluginManager?.subscribe(this, e, t);
223
+ }
224
+ /**
225
+ * Unsubscribe from a plugin event.
226
+ *
227
+ * @category Plugin Development
228
+ * @param eventType - The event type to stop listening for
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * this.off('filter-change');
233
+ * ```
234
+ */
235
+ off(e) {
236
+ this.grid?._pluginManager?.unsubscribe(this, e);
237
+ }
238
+ /**
239
+ * Emit an event to other plugins via the Event Bus.
240
+ * This is for inter-plugin communication only; it does NOT dispatch DOM events.
241
+ * Use `emit()` to dispatch DOM events that external consumers can listen to.
242
+ *
243
+ * @category Plugin Development
244
+ * @param eventType - The event type to emit (should be declared in manifest.events)
245
+ * @param detail - The event payload
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * // Emit to other plugins (not DOM)
250
+ * this.emitPluginEvent('filter-change', { field: 'name', value: 'Alice' });
251
+ *
252
+ * // For DOM events that consumers can addEventListener to:
253
+ * this.emit('filter-change', { field: 'name', value: 'Alice' });
254
+ * ```
255
+ */
256
+ emitPluginEvent(e, t) {
257
+ this.grid?._pluginManager?.emitPluginEvent(e, t);
258
+ }
205
259
  /**
206
260
  * Request a re-render of the grid.
207
261
  */
@@ -368,17 +422,17 @@ function _(l) {
368
422
  const e = l.meta ?? {};
369
423
  return e.lockPosition !== !0 && e.suppressMovable !== !0;
370
424
  }
371
- function v(l, e, t) {
425
+ function b(l, e, t) {
372
426
  if (e === t || e < 0 || e >= l.length || t < 0 || t > l.length) return l;
373
427
  const i = [...l], [n] = i.splice(e, 1);
374
428
  return i.splice(t, 0, n), i;
375
429
  }
376
- const R = '@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';
377
- class x extends O {
430
+ const O = '@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';
431
+ class R extends A {
378
432
  /** @internal */
379
433
  name = "reorder";
380
434
  /** @internal */
381
- styles = R;
435
+ styles = O;
382
436
  /** @internal */
383
437
  get defaultConfig() {
384
438
  return {
@@ -409,10 +463,7 @@ class x extends O {
409
463
  * Check if a column can be moved, considering both column config and plugin queries.
410
464
  */
411
465
  canMoveColumnWithPlugins(e) {
412
- return !e || !_(e) ? !1 : !this.grid.queryPlugins({
413
- type: A.CAN_MOVE_COLUMN,
414
- context: e
415
- }).includes(!1);
466
+ return !e || !_(e) ? !1 : !this.grid.query("canMoveColumn", e).includes(!1);
416
467
  }
417
468
  /**
418
469
  * Clear all drag-related classes from header cells.
@@ -469,7 +520,7 @@ class x extends O {
469
520
  const s = this.draggedField, o = this.draggedIndex, c = this.dropIndex;
470
521
  if (!this.isDragging || s === null || o === null || c === null)
471
522
  return;
472
- const u = c > o ? c - 1 : c, f = this.getColumnOrder(), g = v(f, o, u), h = {
523
+ const u = c > o ? c - 1 : c, f = this.getColumnOrder(), g = b(f, o, u), h = {
473
524
  field: s,
474
525
  fromIndex: o,
475
526
  toIndex: u,
@@ -515,7 +566,7 @@ class x extends O {
515
566
  moveColumn(e, t) {
516
567
  const i = this.getColumnOrder(), n = i.indexOf(e);
517
568
  if (n === -1) return;
518
- const d = v(i, n, t);
569
+ const d = b(i, n, t);
519
570
  this.emitCancelable("column-move", {
520
571
  field: e,
521
572
  fromIndex: n,
@@ -636,6 +687,6 @@ class x extends O {
636
687
  // #endregion
637
688
  }
638
689
  export {
639
- x as ReorderPlugin
690
+ R as ReorderPlugin
640
691
  };
641
692
  //# sourceMappingURL=index.js.map