@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":"ContextMenuPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/context-menu/ContextMenuPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,iBAAiB,EAAmB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAkCrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,iBAAiB,CAAC;IACtE,gBAAgB;IAChB,QAAQ,CAAC,IAAI,iBAAiB;IAE9B,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAIjE;IAGD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,WAAW,CAA4B;IAK/C,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAMhF,gBAAgB;IACP,MAAM,IAAI,IAAI;IAavB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAoCtC;IAEF;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,qBAAqB;IAqC7B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAsB/B,gBAAgB;IACP,WAAW,IAAI,IAAI;IA2F5B;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAoCxE;;OAEG;IACH,QAAQ,IAAI,IAAI;IAQhB;;;OAGG;IACH,UAAU,IAAI,OAAO;CAMtB"}
1
+ {"version":3,"file":"ContextMenuPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/context-menu/ContextMenuPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,iBAAiB,EAAmB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAkCrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,iBAAiB,CAAC;IACtE,gBAAgB;IAChB,QAAQ,CAAC,IAAI,iBAAiB;IAE9B,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAIjE;IAGD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,WAAW,CAA4B;IAK/C,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAMhF,gBAAgB;IACP,MAAM,IAAI,IAAI;IAavB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAoCtC;IAEF;;;;OAIG;IACH,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,qBAAqB;IAqC7B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAsB/B,gBAAgB;IACP,WAAW,IAAI,IAAI;IA2F5B;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAoCxE;;OAEG;IACH,QAAQ,IAAI,IAAI;IAQhB;;;OAGG;IACH,UAAU,IAAI,OAAO;CAMtB"}
@@ -11,7 +11,7 @@ const y = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
11
11
  filterActive: y,
12
12
  print: "🖨️"
13
13
  };
14
- class M {
14
+ class S {
15
15
  /**
16
16
  * Plugin dependencies - declare other plugins this one requires.
17
17
  *
@@ -149,6 +149,63 @@ class M {
149
149
  const n = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
150
150
  return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
151
151
  }
152
+ // =========================================================================
153
+ // Event Bus - Plugin-to-Plugin Communication
154
+ // =========================================================================
155
+ /**
156
+ * Subscribe to an event from another plugin.
157
+ * The subscription is automatically cleaned up when this plugin is detached.
158
+ *
159
+ * @category Plugin Development
160
+ * @param eventType - The event type to listen for (e.g., 'filter-change')
161
+ * @param callback - The callback to invoke when the event is emitted
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * // In attach() or other initialization
166
+ * this.on('filter-change', (detail) => {
167
+ * console.log('Filter changed:', detail);
168
+ * });
169
+ * ```
170
+ */
171
+ on(e, t) {
172
+ this.grid?._pluginManager?.subscribe(this, e, t);
173
+ }
174
+ /**
175
+ * Unsubscribe from a plugin event.
176
+ *
177
+ * @category Plugin Development
178
+ * @param eventType - The event type to stop listening for
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * this.off('filter-change');
183
+ * ```
184
+ */
185
+ off(e) {
186
+ this.grid?._pluginManager?.unsubscribe(this, e);
187
+ }
188
+ /**
189
+ * Emit an event to other plugins via the Event Bus.
190
+ * This is for inter-plugin communication only; it does NOT dispatch DOM events.
191
+ * Use `emit()` to dispatch DOM events that external consumers can listen to.
192
+ *
193
+ * @category Plugin Development
194
+ * @param eventType - The event type to emit (should be declared in manifest.events)
195
+ * @param detail - The event payload
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * // Emit to other plugins (not DOM)
200
+ * this.emitPluginEvent('filter-change', { field: 'name', value: 'Alice' });
201
+ *
202
+ * // For DOM events that consumers can addEventListener to:
203
+ * this.emit('filter-change', { field: 'name', value: 'Alice' });
204
+ * ```
205
+ */
206
+ emitPluginEvent(e, t) {
207
+ this.grid?._pluginManager?.emitPluginEvent(e, t);
208
+ }
152
209
  /**
153
210
  * Request a re-render of the grid.
154
211
  */
@@ -311,31 +368,31 @@ class M {
311
368
  }
312
369
  // #endregion
313
370
  }
314
- const w = "@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg));color:var(--tbw-context-menu-fg, var(--tbw-color-fg));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border));border-radius:var(--tbw-context-menu-radius, var(--tbw-border-radius));box-shadow:0 2px 10px var(--tbw-context-menu-shadow, var(--tbw-color-shadow));min-width:var(--tbw-context-menu-min-width, var(--tbw-menu-min-width));padding:var(--tbw-spacing-xs) 0;z-index:10000;font-size:var(--tbw-context-menu-font-size, var(--tbw-font-size-sm));font-family:var(--tbw-context-menu-font-family, var(--tbw-font-family))}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-context-menu-item-padding, var(--tbw-menu-item-padding));cursor:pointer;gap:var(--tbw-context-menu-item-gap, var(--tbw-menu-item-gap))}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:var(--tbw-context-menu-danger, var(--tbw-color-danger))}.tbw-context-menu-icon{width:var(--tbw-context-menu-icon-size, var(--tbw-icon-size));text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted));font-size:var(--tbw-context-menu-shortcut-size, var(--tbw-font-size-xs))}.tbw-context-menu-arrow{font-size:var(--tbw-context-menu-arrow-size, var(--tbw-font-size-2xs));color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border));margin:var(--tbw-spacing-xs) 0}}";
315
- function x(r, e) {
316
- return (typeof r == "function" ? r(e) : r).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
371
+ const g = "@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg));color:var(--tbw-context-menu-fg, var(--tbw-color-fg));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border));border-radius:var(--tbw-context-menu-radius, var(--tbw-border-radius));box-shadow:var(--tbw-context-menu-shadow, 0 2px 10px var(--tbw-color-shadow));min-width:var(--tbw-context-menu-min-width, var(--tbw-menu-min-width));padding:var(--tbw-spacing-xs) 0;z-index:10000;font-size:var(--tbw-context-menu-font-size, var(--tbw-font-size-sm));font-family:var(--tbw-context-menu-font-family, var(--tbw-font-family))}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-context-menu-item-padding, var(--tbw-menu-item-padding));cursor:pointer;gap:var(--tbw-context-menu-item-gap, var(--tbw-menu-item-gap))}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:var(--tbw-context-menu-danger, var(--tbw-color-danger))}.tbw-context-menu-icon{width:var(--tbw-context-menu-icon-size, var(--tbw-icon-size));text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted));font-size:var(--tbw-context-menu-shortcut-size, var(--tbw-font-size-xs))}.tbw-context-menu-arrow{font-size:var(--tbw-context-menu-arrow-size, var(--tbw-font-size-2xs));color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border));margin:var(--tbw-spacing-xs) 0}}";
372
+ function x(s, e) {
373
+ return (typeof s == "function" ? s(e) : s).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
317
374
  }
318
- function z(r, e) {
319
- return r.disabled === !0 ? !0 : typeof r.disabled == "function" ? r.disabled(e) : !1;
375
+ function z(s, e) {
376
+ return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
320
377
  }
321
- function v(r, e, t, n = I.submenuArrow) {
322
- const s = document.createElement("div");
323
- s.className = "tbw-context-menu", s.setAttribute("role", "menu");
324
- for (const o of r) {
378
+ function v(s, e, t, n = I.submenuArrow) {
379
+ const r = document.createElement("div");
380
+ r.className = "tbw-context-menu", r.setAttribute("role", "menu");
381
+ for (const o of s) {
325
382
  if (o.separator) {
326
383
  const l = document.createElement("div");
327
- l.className = "tbw-context-menu-separator", l.setAttribute("role", "separator"), s.appendChild(l);
384
+ l.className = "tbw-context-menu-separator", l.setAttribute("role", "separator"), r.appendChild(l);
328
385
  continue;
329
386
  }
330
387
  const i = document.createElement("div");
331
388
  i.className = "tbw-context-menu-item", o.cssClass && i.classList.add(o.cssClass), i.setAttribute("role", "menuitem"), i.setAttribute("data-id", o.id);
332
- const c = z(o, e);
333
- if (c && (i.classList.add("disabled"), i.setAttribute("aria-disabled", "true")), o.icon) {
389
+ const u = z(o, e);
390
+ if (u && (i.classList.add("disabled"), i.setAttribute("aria-disabled", "true")), o.icon) {
334
391
  const l = document.createElement("span");
335
392
  l.className = "tbw-context-menu-icon", l.innerHTML = o.icon, i.appendChild(l);
336
393
  }
337
- const a = document.createElement("span");
338
- if (a.className = "tbw-context-menu-label", a.textContent = o.name, i.appendChild(a), o.shortcut) {
394
+ const c = document.createElement("span");
395
+ if (c.className = "tbw-context-menu-label", c.textContent = o.name, i.appendChild(c), o.shortcut) {
339
396
  const l = document.createElement("span");
340
397
  l.className = "tbw-context-menu-shortcut", l.textContent = o.shortcut, i.appendChild(l);
341
398
  }
@@ -346,42 +403,42 @@ function v(r, e, t, n = I.submenuArrow) {
346
403
  const b = x(o.subMenu, e), d = v(b, e, t, n);
347
404
  d.classList.add("tbw-context-submenu"), d.style.position = "absolute", d.style.left = "100%", d.style.top = "0", i.style.position = "relative", i.appendChild(d);
348
405
  }), i.addEventListener("mouseleave", () => {
349
- const u = i.querySelector(".tbw-context-menu");
350
- u && u.remove();
406
+ const a = i.querySelector(".tbw-context-menu");
407
+ a && a.remove();
351
408
  });
352
409
  }
353
- !c && o.action && !o.subMenu && i.addEventListener("click", (l) => {
410
+ !u && o.action && !o.subMenu && i.addEventListener("click", (l) => {
354
411
  l.stopPropagation(), t(o);
355
- }), s.appendChild(i);
412
+ }), r.appendChild(i);
356
413
  }
357
- return s;
414
+ return r;
358
415
  }
359
- function C(r, e, t) {
360
- r.style.position = "fixed", r.style.left = `${e}px`, r.style.top = `${t}px`, r.style.visibility = "hidden", r.style.zIndex = "10000";
361
- const n = r.getBoundingClientRect(), s = window.innerWidth, o = window.innerHeight;
362
- let i = e, c = t;
363
- e + n.width > s && (i = e - n.width), t + n.height > o && (c = t - n.height), i = Math.max(0, i), c = Math.max(0, c), r.style.left = `${i}px`, r.style.top = `${c}px`, r.style.visibility = "visible";
416
+ function C(s, e, t) {
417
+ s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${t}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
418
+ const n = s.getBoundingClientRect(), r = window.innerWidth, o = window.innerHeight;
419
+ let i = e, u = t;
420
+ e + n.width > r && (i = e - n.width), t + n.height > o && (u = t - n.height), i = Math.max(0, i), u = Math.max(0, u), s.style.left = `${i}px`, s.style.top = `${u}px`, s.style.visibility = "visible";
364
421
  }
365
- let h = null, f = null, m = null, g = 0;
422
+ let h = null, f = null, m = null, w = 0;
366
423
  const p = [
367
424
  {
368
425
  id: "copy",
369
426
  name: "Copy",
370
427
  shortcut: "Ctrl+C",
371
- action: (r) => {
372
- r.grid?.plugins?.clipboard?.copy?.();
428
+ action: (s) => {
429
+ s.grid?.plugins?.clipboard?.copy?.();
373
430
  }
374
431
  },
375
432
  { separator: !0, id: "sep1", name: "" },
376
433
  {
377
434
  id: "export-csv",
378
435
  name: "Export CSV",
379
- action: (r) => {
380
- r.grid?.plugins?.export?.exportCsv?.();
436
+ action: (s) => {
437
+ s.grid?.plugins?.export?.exportCsv?.();
381
438
  }
382
439
  }
383
440
  ];
384
- class S extends M {
441
+ class M extends S {
385
442
  /** @internal */
386
443
  name = "contextMenu";
387
444
  /** @internal */
@@ -399,7 +456,7 @@ class S extends M {
399
456
  // #region Lifecycle
400
457
  /** @internal */
401
458
  attach(e) {
402
- super.attach(e), this.installGlobalHandlers(), g++;
459
+ super.attach(e), this.installGlobalHandlers(), w++;
403
460
  }
404
461
  /** @internal */
405
462
  detach() {
@@ -456,18 +513,19 @@ class S extends M {
456
513
  copyGridStyles(e) {
457
514
  const t = this.gridElement;
458
515
  if (!t) return;
459
- const n = getComputedStyle(t), s = [];
460
- for (const o of S.CSS_VARS_TO_COPY) {
461
- const i = n.getPropertyValue(o).trim();
462
- i && s.push(`${o}: ${i}`);
516
+ const n = getComputedStyle(t), r = [], o = n.getPropertyValue("color-scheme").trim();
517
+ o && r.push(`color-scheme: ${o}`);
518
+ for (const i of M.CSS_VARS_TO_COPY) {
519
+ const u = n.getPropertyValue(i).trim();
520
+ u && r.push(`${i}: ${u}`);
463
521
  }
464
- if (s.length > 0) {
465
- const o = e.getAttribute("style") || "";
466
- e.setAttribute("style", o + s.join("; ") + ";");
522
+ if (r.length > 0) {
523
+ const i = e.getAttribute("style") || "";
524
+ e.setAttribute("style", i + r.join("; ") + ";");
467
525
  }
468
526
  }
469
527
  installGlobalHandlers() {
470
- !m && typeof document < "u" && typeof w == "string" && w && (m = document.createElement("style"), m.id = "tbw-context-menu-styles", m.textContent = w, document.head.appendChild(m)), h || (h = () => {
528
+ !m && typeof document < "u" && typeof g == "string" && g && (m = document.createElement("style"), m.id = "tbw-context-menu-styles", m.textContent = g, document.head.appendChild(m)), h || (h = () => {
471
529
  document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
472
530
  }, document.addEventListener("click", h)), f || (f = (e) => {
473
531
  e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
@@ -478,7 +536,7 @@ class S extends M {
478
536
  * Uses reference counting to ensure handlers persist while any grid uses the plugin.
479
537
  */
480
538
  uninstallGlobalHandlers() {
481
- g--, !(g > 0) && (h && (document.removeEventListener("click", h), h = null), f && (document.removeEventListener("keydown", f), f = null), m && (m.remove(), m = null));
539
+ w--, !(w > 0) && (h && (document.removeEventListener("click", h), h = null), f && (document.removeEventListener("keydown", f), f = null), m && (m.remove(), m = null));
482
540
  }
483
541
  // #endregion
484
542
  // #region Hooks
@@ -488,46 +546,46 @@ class S extends M {
488
546
  if (!e) return;
489
547
  const t = e.children[0];
490
548
  t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (n) => {
491
- const s = n;
492
- s.preventDefault();
493
- const o = s.target, i = o.closest("[data-row][data-col]"), c = o.closest(".header-cell");
494
- let a;
549
+ const r = n;
550
+ r.preventDefault();
551
+ const o = r.target, i = o.closest("[data-row][data-col]"), u = o.closest(".header-cell");
552
+ let c;
495
553
  if (i) {
496
- const u = parseInt(i.getAttribute("data-row") ?? "-1", 10), b = parseInt(i.getAttribute("data-col") ?? "-1", 10), d = this.columns[b], E = this.rows[u];
497
- a = {
554
+ const a = parseInt(i.getAttribute("data-row") ?? "-1", 10), b = parseInt(i.getAttribute("data-col") ?? "-1", 10), d = this.columns[b], E = this.rows[a];
555
+ c = {
498
556
  row: E,
499
- rowIndex: u,
557
+ rowIndex: a,
500
558
  column: d,
501
559
  columnIndex: b,
502
560
  field: d?.field ?? "",
503
561
  value: E?.[d?.field] ?? null,
504
562
  isHeader: !1,
505
- event: s
563
+ event: r
506
564
  };
507
- } else if (c) {
508
- const u = parseInt(c.getAttribute("data-col") ?? "-1", 10), b = this.columns[u];
509
- a = {
565
+ } else if (u) {
566
+ const a = parseInt(u.getAttribute("data-col") ?? "-1", 10), b = this.columns[a];
567
+ c = {
510
568
  row: null,
511
569
  rowIndex: -1,
512
570
  column: b,
513
- columnIndex: u,
571
+ columnIndex: a,
514
572
  field: b?.field ?? "",
515
573
  value: null,
516
574
  isHeader: !0,
517
- event: s
575
+ event: r
518
576
  };
519
577
  } else
520
578
  return;
521
- this.params = a, this.position = { x: s.clientX, y: s.clientY };
522
- const l = x(this.config.items ?? p, a);
579
+ this.params = c, this.position = { x: r.clientX, y: r.clientY };
580
+ const l = x(this.config.items ?? p, c);
523
581
  l.length && (this.menuElement && this.menuElement.remove(), this.menuElement = v(
524
582
  l,
525
- a,
526
- (u) => {
527
- u.action && u.action(a), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
583
+ c,
584
+ (a) => {
585
+ a.action && a.action(c), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
528
586
  },
529
587
  this.gridIcons.submenuArrow
530
- ), document.body.appendChild(this.menuElement), this.copyGridStyles(this.menuElement), C(this.menuElement, s.clientX, s.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: a, items: l }));
588
+ ), document.body.appendChild(this.menuElement), this.copyGridStyles(this.menuElement), C(this.menuElement, r.clientX, r.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: c, items: l }));
531
589
  }));
532
590
  }
533
591
  // #endregion
@@ -539,7 +597,7 @@ class S extends M {
539
597
  * @param params - Partial context menu parameters
540
598
  */
541
599
  showMenu(e, t, n) {
542
- const s = {
600
+ const r = {
543
601
  row: n.row ?? null,
544
602
  rowIndex: n.rowIndex ?? -1,
545
603
  column: n.column ?? null,
@@ -548,12 +606,12 @@ class S extends M {
548
606
  value: n.value ?? null,
549
607
  isHeader: n.isHeader ?? !1,
550
608
  event: n.event ?? new MouseEvent("contextmenu")
551
- }, o = x(this.config.items ?? p, s);
609
+ }, o = x(this.config.items ?? p, r);
552
610
  this.menuElement && this.menuElement.remove(), this.menuElement = v(
553
611
  o,
554
- s,
612
+ r,
555
613
  (i) => {
556
- i.action && i.action(s), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
614
+ i.action && i.action(r), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
557
615
  },
558
616
  this.gridIcons.submenuArrow
559
617
  ), document.body.appendChild(this.menuElement), this.copyGridStyles(this.menuElement), C(this.menuElement, e, t), this.isOpen = !0;
@@ -575,6 +633,6 @@ class S extends M {
575
633
  // Styles are injected globally via installGlobalHandlers() since menu renders in document.body
576
634
  }
577
635
  export {
578
- S as ContextMenuPlugin
636
+ M as ContextMenuPlugin
579
637
  };
580
638
  //# sourceMappingURL=index.js.map