@toolbox-web/grid 0.4.1 → 0.4.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 (157) hide show
  1. package/README.md +10 -13
  2. package/all.js +1101 -1048
  3. package/all.js.map +1 -1
  4. package/index.js +245 -137
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +10 -0
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/config-manager.d.ts +1 -0
  9. package/lib/core/internal/config-manager.d.ts.map +1 -1
  10. package/lib/core/internal/keyboard.d.ts.map +1 -1
  11. package/lib/core/internal/utils.d.ts +1 -0
  12. package/lib/core/internal/utils.d.ts.map +1 -1
  13. package/lib/core/plugin/base-plugin.d.ts +57 -1
  14. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  15. package/lib/core/plugin/expander-column.d.ts +51 -0
  16. package/lib/core/plugin/expander-column.d.ts.map +1 -0
  17. package/lib/core/plugin/types.d.ts +117 -1
  18. package/lib/core/plugin/types.d.ts.map +1 -1
  19. package/lib/core/types.d.ts +4 -2
  20. package/lib/core/types.d.ts.map +1 -1
  21. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +5 -4
  22. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  23. package/lib/plugins/clipboard/index.d.ts +1 -1
  24. package/lib/plugins/clipboard/index.d.ts.map +1 -1
  25. package/lib/plugins/clipboard/index.js +282 -188
  26. package/lib/plugins/clipboard/index.js.map +1 -1
  27. package/lib/plugins/clipboard/types.d.ts +72 -2
  28. package/lib/plugins/clipboard/types.d.ts.map +1 -1
  29. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -1
  30. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
  31. package/lib/plugins/column-virtualization/index.js +102 -26
  32. package/lib/plugins/column-virtualization/index.js.map +1 -1
  33. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +0 -1
  34. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  35. package/lib/plugins/context-menu/index.js +154 -78
  36. package/lib/plugins/context-menu/index.js.map +1 -1
  37. package/lib/plugins/editing/EditingPlugin.d.ts +1 -7
  38. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  39. package/lib/plugins/editing/index.js +200 -136
  40. package/lib/plugins/editing/index.js.map +1 -1
  41. package/lib/plugins/export/ExportPlugin.d.ts +0 -1
  42. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  43. package/lib/plugins/export/index.js +175 -99
  44. package/lib/plugins/export/index.js.map +1 -1
  45. package/lib/plugins/filtering/FilteringPlugin.d.ts +5 -2
  46. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  47. package/lib/plugins/filtering/index.js +129 -43
  48. package/lib/plugins/filtering/index.js.map +1 -1
  49. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -2
  50. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  51. package/lib/plugins/grouping-columns/grouping-columns.d.ts +1 -1
  52. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  53. package/lib/plugins/grouping-columns/index.js +144 -66
  54. package/lib/plugins/grouping-columns/index.js.map +1 -1
  55. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -2
  56. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  57. package/lib/plugins/grouping-rows/index.js +230 -138
  58. package/lib/plugins/grouping-rows/index.js.map +1 -1
  59. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +13 -11
  60. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  61. package/lib/plugins/master-detail/index.js +265 -196
  62. package/lib/plugins/master-detail/index.js.map +1 -1
  63. package/lib/plugins/master-detail/types.d.ts +0 -10
  64. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  65. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +1 -2
  66. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  67. package/lib/plugins/multi-sort/index.js +105 -31
  68. package/lib/plugins/multi-sort/index.js.map +1 -1
  69. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +0 -1
  70. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  71. package/lib/plugins/pinned-columns/index.js +128 -52
  72. package/lib/plugins/pinned-columns/index.js.map +1 -1
  73. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -2
  74. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  75. package/lib/plugins/pinned-rows/index.js +162 -88
  76. package/lib/plugins/pinned-rows/index.js.map +1 -1
  77. package/lib/plugins/pivot/PivotPlugin.d.ts +26 -4
  78. package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
  79. package/lib/plugins/pivot/index.js +398 -310
  80. package/lib/plugins/pivot/index.js.map +1 -1
  81. package/lib/plugins/pivot/pivot-rows.d.ts +2 -1
  82. package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -1
  83. package/lib/plugins/reorder/ReorderPlugin.d.ts +13 -10
  84. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  85. package/lib/plugins/reorder/index.js +288 -226
  86. package/lib/plugins/reorder/index.js.map +1 -1
  87. package/lib/plugins/selection/SelectionPlugin.d.ts +21 -3
  88. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  89. package/lib/plugins/selection/index.d.ts +2 -2
  90. package/lib/plugins/selection/index.d.ts.map +1 -1
  91. package/lib/plugins/selection/index.js +276 -145
  92. package/lib/plugins/selection/index.js.map +1 -1
  93. package/lib/plugins/selection/types.d.ts +24 -0
  94. package/lib/plugins/selection/types.d.ts.map +1 -1
  95. package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -1
  96. package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -1
  97. package/lib/plugins/server-side/index.js +83 -7
  98. package/lib/plugins/server-side/index.js.map +1 -1
  99. package/lib/plugins/tree/TreePlugin.d.ts +5 -1
  100. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  101. package/lib/plugins/tree/index.js +197 -112
  102. package/lib/plugins/tree/index.js.map +1 -1
  103. package/lib/plugins/tree/types.d.ts +0 -10
  104. package/lib/plugins/tree/types.d.ts.map +1 -1
  105. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +0 -1
  106. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  107. package/lib/plugins/undo-redo/index.js +93 -17
  108. package/lib/plugins/undo-redo/index.js.map +1 -1
  109. package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -4
  110. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  111. package/lib/plugins/visibility/index.js +144 -65
  112. package/lib/plugins/visibility/index.js.map +1 -1
  113. package/package.json +1 -1
  114. package/umd/grid.all.umd.js +17 -19
  115. package/umd/grid.all.umd.js.map +1 -1
  116. package/umd/grid.umd.js +7 -7
  117. package/umd/grid.umd.js.map +1 -1
  118. package/umd/plugins/clipboard.umd.js +5 -7
  119. package/umd/plugins/clipboard.umd.js.map +1 -1
  120. package/umd/plugins/column-virtualization.umd.js +1 -1
  121. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  122. package/umd/plugins/context-menu.umd.js +1 -1
  123. package/umd/plugins/context-menu.umd.js.map +1 -1
  124. package/umd/plugins/editing.umd.js +1 -1
  125. package/umd/plugins/editing.umd.js.map +1 -1
  126. package/umd/plugins/export.umd.js +1 -1
  127. package/umd/plugins/export.umd.js.map +1 -1
  128. package/umd/plugins/filtering.umd.js +1 -1
  129. package/umd/plugins/filtering.umd.js.map +1 -1
  130. package/umd/plugins/grouping-columns.umd.js +1 -1
  131. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  132. package/umd/plugins/grouping-rows.umd.js +1 -1
  133. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  134. package/umd/plugins/master-detail.umd.js +1 -1
  135. package/umd/plugins/master-detail.umd.js.map +1 -1
  136. package/umd/plugins/multi-sort.umd.js +1 -1
  137. package/umd/plugins/multi-sort.umd.js.map +1 -1
  138. package/umd/plugins/pinned-columns.umd.js +1 -1
  139. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  140. package/umd/plugins/pinned-rows.umd.js +1 -1
  141. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  142. package/umd/plugins/pivot.umd.js +1 -1
  143. package/umd/plugins/pivot.umd.js.map +1 -1
  144. package/umd/plugins/reorder.umd.js +1 -1
  145. package/umd/plugins/reorder.umd.js.map +1 -1
  146. package/umd/plugins/selection.umd.js +1 -1
  147. package/umd/plugins/selection.umd.js.map +1 -1
  148. package/umd/plugins/server-side.umd.js +1 -1
  149. package/umd/plugins/server-side.umd.js.map +1 -1
  150. package/umd/plugins/tree.umd.js +1 -1
  151. package/umd/plugins/tree.umd.js.map +1 -1
  152. package/umd/plugins/undo-redo.umd.js +1 -1
  153. package/umd/plugins/undo-redo.umd.js.map +1 -1
  154. package/umd/plugins/visibility.umd.js +1 -1
  155. package/umd/plugins/visibility.umd.js.map +1 -1
  156. package/lib/core/internal/editing.d.ts +0 -76
  157. package/lib/core/internal/editing.d.ts.map +0 -1
@@ -25,8 +25,11 @@ class I {
25
25
  * ```
26
26
  */
27
27
  static dependencies;
28
- /** Plugin version - override in subclass if needed */
29
- version = "1.0.0";
28
+ /**
29
+ * Plugin version - defaults to grid version for built-in plugins.
30
+ * Third-party plugins can override with their own semver.
31
+ */
32
+ version = typeof __GRID_VERSION__ < "u" ? __GRID_VERSION__ : "dev";
30
33
  /** CSS styles to inject into the grid's shadow DOM */
31
34
  styles;
32
35
  /** Custom cell renderers keyed by type name */
@@ -110,8 +113,16 @@ class I {
110
113
  /**
111
114
  * Emit a custom event from the grid.
112
115
  */
113
- emit(e, n) {
114
- this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: n, bubbles: !0 }));
116
+ emit(e, t) {
117
+ this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
118
+ }
119
+ /**
120
+ * Emit a cancelable custom event from the grid.
121
+ * @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
122
+ */
123
+ emitCancelable(e, t) {
124
+ const n = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
125
+ return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
115
126
  }
116
127
  /**
117
128
  * Request a re-render of the grid.
@@ -119,6 +130,14 @@ class I {
119
130
  requestRender() {
120
131
  this.grid?.requestRender?.();
121
132
  }
133
+ /**
134
+ * Request a re-render and restore focus styling afterward.
135
+ * Use this when a plugin action (like expand/collapse) triggers a render
136
+ * but needs to maintain keyboard navigation focus.
137
+ */
138
+ requestRenderWithFocus() {
139
+ this.grid?.requestRenderWithFocus?.();
140
+ }
122
141
  /**
123
142
  * Request a lightweight style update without rebuilding DOM.
124
143
  * Use this instead of requestRender() when only CSS classes need updating.
@@ -152,6 +171,19 @@ class I {
152
171
  get visibleColumns() {
153
172
  return this.grid?._visibleColumns ?? [];
154
173
  }
174
+ /**
175
+ * Get the grid as an HTMLElement for direct DOM operations.
176
+ * Use sparingly - prefer the typed GridElementRef API when possible.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * const width = this.gridElement.clientWidth;
181
+ * this.gridElement.classList.add('my-plugin-active');
182
+ * ```
183
+ */
184
+ get gridElement() {
185
+ return this.grid;
186
+ }
155
187
  /**
156
188
  * Get the shadow root of the grid.
157
189
  */
@@ -186,6 +218,51 @@ class I {
186
218
  const e = this.grid?.gridConfig?.icons ?? {};
187
219
  return { ...C, ...e };
188
220
  }
221
+ // #region Animation Helpers
222
+ /**
223
+ * Check if animations are enabled at the grid level.
224
+ * Respects gridConfig.animation.mode and the CSS variable set by the grid.
225
+ *
226
+ * Plugins should use this to skip animations when:
227
+ * - Animation mode is 'off' or `false`
228
+ * - User prefers reduced motion and mode is 'reduced-motion' (default)
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * private get animationStyle(): 'slide' | 'fade' | false {
233
+ * if (!this.isAnimationEnabled) return false;
234
+ * return this.config.animation ?? 'slide';
235
+ * }
236
+ * ```
237
+ */
238
+ get isAnimationEnabled() {
239
+ const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
240
+ if (e === !1 || e === "off") return !1;
241
+ if (e === !0 || e === "on") return !0;
242
+ const t = this.shadowRoot?.host;
243
+ return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
244
+ }
245
+ /**
246
+ * Get the animation duration in milliseconds from CSS variable.
247
+ * Falls back to 200ms if not set.
248
+ *
249
+ * Plugins can use this for their animation timing to stay consistent
250
+ * with the grid-level animation.duration setting.
251
+ *
252
+ * @example
253
+ * ```ts
254
+ * element.animate(keyframes, { duration: this.animationDuration });
255
+ * ```
256
+ */
257
+ get animationDuration() {
258
+ const e = this.shadowRoot?.host;
259
+ if (e) {
260
+ const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(t, 10);
261
+ if (!isNaN(n)) return n;
262
+ }
263
+ return 200;
264
+ }
265
+ // #endregion
189
266
  /**
190
267
  * Resolve an icon value to string or HTMLElement.
191
268
  * Checks plugin config first, then grid-level icons, then defaults.
@@ -194,8 +271,8 @@ class I {
194
271
  * @param pluginOverride - Optional plugin-level override
195
272
  * @returns The resolved icon value
196
273
  */
197
- resolveIcon(e, n) {
198
- return n !== void 0 ? n : this.gridIcons[e];
274
+ resolveIcon(e, t) {
275
+ return t !== void 0 ? t : this.gridIcons[e];
199
276
  }
200
277
  /**
201
278
  * Set an icon value on an element.
@@ -204,8 +281,8 @@ class I {
204
281
  * @param element - The element to set the icon on
205
282
  * @param icon - The icon value (string or HTMLElement)
206
283
  */
207
- setIcon(e, n) {
208
- typeof n == "string" ? e.innerHTML = n : n instanceof HTMLElement && (e.innerHTML = "", e.appendChild(n.cloneNode(!0)));
284
+ setIcon(e, t) {
285
+ typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.cloneNode(!0)));
209
286
  }
210
287
  /**
211
288
  * Log a warning message.
@@ -217,54 +294,54 @@ class I {
217
294
  }
218
295
  const g = ".tbw-context-menu{position:fixed;background:light-dark(#f5f5f5,#2a2a2a);color:light-dark(#222,#eee);border:1px solid light-dark(#d0d0d4,#454545);border-radius:4px;box-shadow:0 2px 10px #00000026;min-width:160px;padding:4px 0;z-index:10000;font-size:13px;font-family:system-ui,sans-serif}.tbw-context-menu-item{display:flex;align-items:center;padding:6px 12px;cursor:pointer;gap:8px}.tbw-context-menu-item:hover:not(.disabled){background:light-dark(#e8e8e8,#3a3a3a)}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:light-dark(#c00,#f66)}.tbw-context-menu-icon{width:16px;text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:light-dark(#888,#888);font-size:11px}.tbw-context-menu-arrow{font-size:10px;color:light-dark(#888,#888)}.tbw-context-menu-separator{height:1px;background:light-dark(#d0d0d4,#454545);margin:4px 0}";
219
296
  function w(s, e) {
220
- return (typeof s == "function" ? s(e) : s).filter((i) => !(i.hidden === !0 || typeof i.hidden == "function" && i.hidden(e)));
297
+ return (typeof s == "function" ? s(e) : s).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
221
298
  }
222
299
  function M(s, e) {
223
300
  return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
224
301
  }
225
- function v(s, e, n, i = C.submenuArrow) {
226
- const r = document.createElement("div");
227
- r.className = "tbw-context-menu", r.setAttribute("role", "menu");
302
+ function v(s, e, t, n = C.submenuArrow) {
303
+ const l = document.createElement("div");
304
+ l.className = "tbw-context-menu", l.setAttribute("role", "menu");
228
305
  for (const o of s) {
229
306
  if (o.separator) {
230
- const l = document.createElement("div");
231
- l.className = "tbw-context-menu-separator", l.setAttribute("role", "separator"), r.appendChild(l);
307
+ const r = document.createElement("div");
308
+ r.className = "tbw-context-menu-separator", r.setAttribute("role", "separator"), l.appendChild(r);
232
309
  continue;
233
310
  }
234
- const t = document.createElement("div");
235
- t.className = "tbw-context-menu-item", o.cssClass && t.classList.add(o.cssClass), t.setAttribute("role", "menuitem"), t.setAttribute("data-id", o.id);
236
- const c = M(o, e);
237
- if (c && (t.classList.add("disabled"), t.setAttribute("aria-disabled", "true")), o.icon) {
238
- const l = document.createElement("span");
239
- l.className = "tbw-context-menu-icon", l.innerHTML = o.icon, t.appendChild(l);
311
+ const i = document.createElement("div");
312
+ i.className = "tbw-context-menu-item", o.cssClass && i.classList.add(o.cssClass), i.setAttribute("role", "menuitem"), i.setAttribute("data-id", o.id);
313
+ const a = M(o, e);
314
+ if (a && (i.classList.add("disabled"), i.setAttribute("aria-disabled", "true")), o.icon) {
315
+ const r = document.createElement("span");
316
+ r.className = "tbw-context-menu-icon", r.innerHTML = o.icon, i.appendChild(r);
240
317
  }
241
318
  const d = document.createElement("span");
242
- if (d.className = "tbw-context-menu-label", d.textContent = o.name, t.appendChild(d), o.shortcut) {
243
- const l = document.createElement("span");
244
- l.className = "tbw-context-menu-shortcut", l.textContent = o.shortcut, t.appendChild(l);
319
+ if (d.className = "tbw-context-menu-label", d.textContent = o.name, i.appendChild(d), o.shortcut) {
320
+ const r = document.createElement("span");
321
+ r.className = "tbw-context-menu-shortcut", r.textContent = o.shortcut, i.appendChild(r);
245
322
  }
246
323
  if (o.subMenu?.length) {
247
- const l = document.createElement("span");
248
- l.className = "tbw-context-menu-arrow", typeof i == "string" ? l.innerHTML = i : i instanceof HTMLElement && l.appendChild(i.cloneNode(!0)), t.appendChild(l), t.addEventListener("mouseenter", () => {
249
- if (t.querySelector(".tbw-context-menu") || !o.subMenu) return;
250
- const h = w(o.subMenu, e), a = v(h, e, n, i);
251
- a.classList.add("tbw-context-submenu"), a.style.position = "absolute", a.style.left = "100%", a.style.top = "0", t.style.position = "relative", t.appendChild(a);
252
- }), t.addEventListener("mouseleave", () => {
253
- const u = t.querySelector(".tbw-context-menu");
324
+ const r = document.createElement("span");
325
+ r.className = "tbw-context-menu-arrow", typeof n == "string" ? r.innerHTML = n : n instanceof HTMLElement && r.appendChild(n.cloneNode(!0)), i.appendChild(r), i.addEventListener("mouseenter", () => {
326
+ if (i.querySelector(".tbw-context-menu") || !o.subMenu) return;
327
+ const h = w(o.subMenu, e), c = v(h, e, t, n);
328
+ c.classList.add("tbw-context-submenu"), c.style.position = "absolute", c.style.left = "100%", c.style.top = "0", i.style.position = "relative", i.appendChild(c);
329
+ }), i.addEventListener("mouseleave", () => {
330
+ const u = i.querySelector(".tbw-context-menu");
254
331
  u && u.remove();
255
332
  });
256
333
  }
257
- !c && o.action && !o.subMenu && t.addEventListener("click", (l) => {
258
- l.stopPropagation(), n(o);
259
- }), r.appendChild(t);
334
+ !a && o.action && !o.subMenu && i.addEventListener("click", (r) => {
335
+ r.stopPropagation(), t(o);
336
+ }), l.appendChild(i);
260
337
  }
261
- return r;
338
+ return l;
262
339
  }
263
- function y(s, e, n) {
264
- s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${n}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
265
- const i = s.getBoundingClientRect(), r = window.innerWidth, o = window.innerHeight;
266
- let t = e, c = n;
267
- e + i.width > r && (t = e - i.width), n + i.height > o && (c = n - i.height), t = Math.max(0, t), c = Math.max(0, c), s.style.left = `${t}px`, s.style.top = `${c}px`, s.style.visibility = "visible";
340
+ function y(s, e, t) {
341
+ s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${t}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
342
+ const n = s.getBoundingClientRect(), l = window.innerWidth, o = window.innerHeight;
343
+ let i = e, a = t;
344
+ e + n.width > l && (i = e - n.width), t + n.height > o && (a = t - n.height), i = Math.max(0, i), a = Math.max(0, a), s.style.left = `${i}px`, s.style.top = `${a}px`, s.style.visibility = "visible";
268
345
  }
269
346
  let f = null, p = null, m = null, b = 0;
270
347
  const x = [
@@ -285,9 +362,8 @@ const x = [
285
362
  }
286
363
  }
287
364
  ];
288
- class H extends I {
365
+ class R extends I {
289
366
  name = "contextMenu";
290
- version = "1.0.0";
291
367
  get defaultConfig() {
292
368
  return {
293
369
  items: x
@@ -310,9 +386,9 @@ class H extends I {
310
386
  // #region Private Methods
311
387
  installGlobalHandlers() {
312
388
  !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)), f || (f = () => {
313
- document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
389
+ document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
314
390
  }, document.addEventListener("click", f)), p || (p = (e) => {
315
- e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((i) => i.remove());
391
+ e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
316
392
  }, document.addEventListener("keydown", p));
317
393
  }
318
394
  /**
@@ -327,26 +403,26 @@ class H extends I {
327
403
  afterRender() {
328
404
  const e = this.shadowRoot;
329
405
  if (!e) return;
330
- const n = e.children[0];
331
- n && n.getAttribute("data-context-menu-bound") !== "true" && (n.setAttribute("data-context-menu-bound", "true"), n.addEventListener("contextmenu", (i) => {
332
- const r = i;
333
- r.preventDefault();
334
- const o = r.target, t = o.closest("[data-row][data-col]"), c = o.closest(".header-cell");
406
+ const t = e.children[0];
407
+ t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (n) => {
408
+ const l = n;
409
+ l.preventDefault();
410
+ const o = l.target, i = o.closest("[data-row][data-col]"), a = o.closest(".header-cell");
335
411
  let d;
336
- if (t) {
337
- const u = parseInt(t.getAttribute("data-row") ?? "-1", 10), h = parseInt(t.getAttribute("data-col") ?? "-1", 10), a = this.columns[h], E = this.rows[u];
412
+ if (i) {
413
+ const u = parseInt(i.getAttribute("data-row") ?? "-1", 10), h = parseInt(i.getAttribute("data-col") ?? "-1", 10), c = this.columns[h], E = this.rows[u];
338
414
  d = {
339
415
  row: E,
340
416
  rowIndex: u,
341
- column: a,
417
+ column: c,
342
418
  columnIndex: h,
343
- field: a?.field ?? "",
344
- value: E?.[a?.field] ?? null,
419
+ field: c?.field ?? "",
420
+ value: E?.[c?.field] ?? null,
345
421
  isHeader: !1,
346
- event: r
422
+ event: l
347
423
  };
348
- } else if (c) {
349
- const u = parseInt(c.getAttribute("data-col") ?? "-1", 10), h = this.columns[u];
424
+ } else if (a) {
425
+ const u = parseInt(a.getAttribute("data-col") ?? "-1", 10), h = this.columns[u];
350
426
  d = {
351
427
  row: null,
352
428
  rowIndex: -1,
@@ -355,20 +431,20 @@ class H extends I {
355
431
  field: h?.field ?? "",
356
432
  value: null,
357
433
  isHeader: !0,
358
- event: r
434
+ event: l
359
435
  };
360
436
  } else
361
437
  return;
362
- this.params = d, this.position = { x: r.clientX, y: r.clientY };
363
- const l = w(this.config.items ?? x, d);
364
- l.length && (this.menuElement && this.menuElement.remove(), this.menuElement = v(
365
- l,
438
+ this.params = d, this.position = { x: l.clientX, y: l.clientY };
439
+ const r = w(this.config.items ?? x, d);
440
+ r.length && (this.menuElement && this.menuElement.remove(), this.menuElement = v(
441
+ r,
366
442
  d,
367
443
  (u) => {
368
444
  u.action && u.action(d), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
369
445
  },
370
446
  this.gridIcons.submenuArrow
371
- ), document.body.appendChild(this.menuElement), y(this.menuElement, r.clientX, r.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: d, items: l }));
447
+ ), document.body.appendChild(this.menuElement), y(this.menuElement, l.clientX, l.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: d, items: r }));
372
448
  }));
373
449
  }
374
450
  // #endregion
@@ -379,25 +455,25 @@ class H extends I {
379
455
  * @param y - Y coordinate
380
456
  * @param params - Partial context menu parameters
381
457
  */
382
- showMenu(e, n, i) {
383
- const r = {
384
- row: i.row ?? null,
385
- rowIndex: i.rowIndex ?? -1,
386
- column: i.column ?? null,
387
- columnIndex: i.columnIndex ?? -1,
388
- field: i.field ?? "",
389
- value: i.value ?? null,
390
- isHeader: i.isHeader ?? !1,
391
- event: i.event ?? new MouseEvent("contextmenu")
392
- }, o = w(this.config.items ?? x, r);
458
+ showMenu(e, t, n) {
459
+ const l = {
460
+ row: n.row ?? null,
461
+ rowIndex: n.rowIndex ?? -1,
462
+ column: n.column ?? null,
463
+ columnIndex: n.columnIndex ?? -1,
464
+ field: n.field ?? "",
465
+ value: n.value ?? null,
466
+ isHeader: n.isHeader ?? !1,
467
+ event: n.event ?? new MouseEvent("contextmenu")
468
+ }, o = w(this.config.items ?? x, l);
393
469
  this.menuElement && this.menuElement.remove(), this.menuElement = v(
394
470
  o,
395
- r,
396
- (t) => {
397
- t.action && t.action(r), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
471
+ l,
472
+ (i) => {
473
+ i.action && i.action(l), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
398
474
  },
399
475
  this.gridIcons.submenuArrow
400
- ), document.body.appendChild(this.menuElement), y(this.menuElement, e, n), this.isOpen = !0;
476
+ ), document.body.appendChild(this.menuElement), y(this.menuElement, e, t), this.isOpen = !0;
401
477
  }
402
478
  /**
403
479
  * Hide the context menu.
@@ -416,6 +492,6 @@ class H extends I {
416
492
  // Styles are injected globally via installGlobalHandlers() since menu renders in document.body
417
493
  }
418
494
  export {
419
- H as ContextMenuPlugin
495
+ R as ContextMenuPlugin
420
496
  };
421
497
  //# sourceMappingURL=index.js.map