@toolbox-web/grid 0.4.0 → 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 (161) hide show
  1. package/README.md +10 -13
  2. package/all.js +1124 -1047
  3. package/all.js.map +1 -1
  4. package/index.js +688 -515
  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/internal/validate-config.d.ts +14 -0
  14. package/lib/core/internal/validate-config.d.ts.map +1 -1
  15. package/lib/core/plugin/base-plugin.d.ts +105 -1
  16. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  17. package/lib/core/plugin/expander-column.d.ts +51 -0
  18. package/lib/core/plugin/expander-column.d.ts.map +1 -0
  19. package/lib/core/plugin/index.d.ts +1 -0
  20. package/lib/core/plugin/index.d.ts.map +1 -1
  21. package/lib/core/plugin/plugin-manager.d.ts +1 -1
  22. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  23. package/lib/core/plugin/types.d.ts +117 -1
  24. package/lib/core/plugin/types.d.ts.map +1 -1
  25. package/lib/core/types.d.ts +4 -2
  26. package/lib/core/types.d.ts.map +1 -1
  27. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +9 -2
  28. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  29. package/lib/plugins/clipboard/index.d.ts +1 -1
  30. package/lib/plugins/clipboard/index.d.ts.map +1 -1
  31. package/lib/plugins/clipboard/index.js +303 -185
  32. package/lib/plugins/clipboard/index.js.map +1 -1
  33. package/lib/plugins/clipboard/types.d.ts +72 -2
  34. package/lib/plugins/clipboard/types.d.ts.map +1 -1
  35. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -1
  36. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
  37. package/lib/plugins/column-virtualization/index.js +116 -24
  38. package/lib/plugins/column-virtualization/index.js.map +1 -1
  39. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +0 -1
  40. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  41. package/lib/plugins/context-menu/index.js +164 -72
  42. package/lib/plugins/context-menu/index.js.map +1 -1
  43. package/lib/plugins/editing/EditingPlugin.d.ts +1 -7
  44. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  45. package/lib/plugins/editing/index.js +213 -133
  46. package/lib/plugins/editing/index.js.map +1 -1
  47. package/lib/plugins/export/ExportPlugin.d.ts +0 -1
  48. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  49. package/lib/plugins/export/index.js +195 -103
  50. package/lib/plugins/export/index.js.map +1 -1
  51. package/lib/plugins/filtering/FilteringPlugin.d.ts +5 -2
  52. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  53. package/lib/plugins/filtering/index.js +145 -43
  54. package/lib/plugins/filtering/index.js.map +1 -1
  55. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -2
  56. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  57. package/lib/plugins/grouping-columns/grouping-columns.d.ts +1 -1
  58. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  59. package/lib/plugins/grouping-columns/index.js +162 -68
  60. package/lib/plugins/grouping-columns/index.js.map +1 -1
  61. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -2
  62. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  63. package/lib/plugins/grouping-rows/index.js +246 -138
  64. package/lib/plugins/grouping-rows/index.js.map +1 -1
  65. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +13 -11
  66. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  67. package/lib/plugins/master-detail/index.js +281 -196
  68. package/lib/plugins/master-detail/index.js.map +1 -1
  69. package/lib/plugins/master-detail/types.d.ts +0 -10
  70. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  71. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +1 -2
  72. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  73. package/lib/plugins/multi-sort/index.js +121 -31
  74. package/lib/plugins/multi-sort/index.js.map +1 -1
  75. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +0 -1
  76. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  77. package/lib/plugins/pinned-columns/index.js +144 -52
  78. package/lib/plugins/pinned-columns/index.js.map +1 -1
  79. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -2
  80. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  81. package/lib/plugins/pinned-rows/index.js +178 -88
  82. package/lib/plugins/pinned-rows/index.js.map +1 -1
  83. package/lib/plugins/pivot/PivotPlugin.d.ts +26 -4
  84. package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
  85. package/lib/plugins/pivot/index.js +414 -310
  86. package/lib/plugins/pivot/index.js.map +1 -1
  87. package/lib/plugins/pivot/pivot-rows.d.ts +2 -1
  88. package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -1
  89. package/lib/plugins/reorder/ReorderPlugin.d.ts +13 -10
  90. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  91. package/lib/plugins/reorder/index.js +304 -226
  92. package/lib/plugins/reorder/index.js.map +1 -1
  93. package/lib/plugins/selection/SelectionPlugin.d.ts +21 -3
  94. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  95. package/lib/plugins/selection/index.d.ts +2 -2
  96. package/lib/plugins/selection/index.d.ts.map +1 -1
  97. package/lib/plugins/selection/index.js +292 -145
  98. package/lib/plugins/selection/index.js.map +1 -1
  99. package/lib/plugins/selection/types.d.ts +24 -0
  100. package/lib/plugins/selection/types.d.ts.map +1 -1
  101. package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -1
  102. package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -1
  103. package/lib/plugins/server-side/index.js +95 -3
  104. package/lib/plugins/server-side/index.js.map +1 -1
  105. package/lib/plugins/tree/TreePlugin.d.ts +5 -1
  106. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  107. package/lib/plugins/tree/index.js +213 -112
  108. package/lib/plugins/tree/index.js.map +1 -1
  109. package/lib/plugins/tree/types.d.ts +0 -10
  110. package/lib/plugins/tree/types.d.ts.map +1 -1
  111. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +7 -2
  112. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  113. package/lib/plugins/undo-redo/index.js +112 -12
  114. package/lib/plugins/undo-redo/index.js.map +1 -1
  115. package/lib/plugins/visibility/VisibilityPlugin.d.ts +14 -5
  116. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  117. package/lib/plugins/visibility/index.js +168 -65
  118. package/lib/plugins/visibility/index.js.map +1 -1
  119. package/package.json +1 -1
  120. package/umd/grid.all.umd.js +21 -17
  121. package/umd/grid.all.umd.js.map +1 -1
  122. package/umd/grid.umd.js +14 -8
  123. package/umd/grid.umd.js.map +1 -1
  124. package/umd/plugins/clipboard.umd.js +5 -7
  125. package/umd/plugins/clipboard.umd.js.map +1 -1
  126. package/umd/plugins/column-virtualization.umd.js +1 -1
  127. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  128. package/umd/plugins/context-menu.umd.js +1 -1
  129. package/umd/plugins/context-menu.umd.js.map +1 -1
  130. package/umd/plugins/editing.umd.js +1 -1
  131. package/umd/plugins/editing.umd.js.map +1 -1
  132. package/umd/plugins/export.umd.js +1 -1
  133. package/umd/plugins/export.umd.js.map +1 -1
  134. package/umd/plugins/filtering.umd.js +1 -1
  135. package/umd/plugins/filtering.umd.js.map +1 -1
  136. package/umd/plugins/grouping-columns.umd.js +1 -1
  137. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  138. package/umd/plugins/grouping-rows.umd.js +1 -1
  139. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  140. package/umd/plugins/master-detail.umd.js +1 -1
  141. package/umd/plugins/master-detail.umd.js.map +1 -1
  142. package/umd/plugins/multi-sort.umd.js +1 -1
  143. package/umd/plugins/multi-sort.umd.js.map +1 -1
  144. package/umd/plugins/pinned-columns.umd.js +1 -1
  145. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  146. package/umd/plugins/pinned-rows.umd.js +1 -1
  147. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  148. package/umd/plugins/pivot.umd.js +1 -1
  149. package/umd/plugins/pivot.umd.js.map +1 -1
  150. package/umd/plugins/reorder.umd.js +1 -1
  151. package/umd/plugins/reorder.umd.js.map +1 -1
  152. package/umd/plugins/selection.umd.js +1 -1
  153. package/umd/plugins/selection.umd.js.map +1 -1
  154. package/umd/plugins/server-side.umd.js +1 -1
  155. package/umd/plugins/server-side.umd.js.map +1 -1
  156. package/umd/plugins/tree.umd.js +1 -1
  157. package/umd/plugins/tree.umd.js.map +1 -1
  158. package/umd/plugins/undo-redo.umd.js +1 -1
  159. package/umd/plugins/undo-redo.umd.js.map +1 -1
  160. package/umd/plugins/visibility.umd.js +1 -1
  161. package/umd/plugins/visibility.umd.js.map +1 -1
@@ -1,4 +1,4 @@
1
- const p = {
1
+ const h = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,9 +8,28 @@ const p = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class f {
12
- /** Plugin version - override in subclass if needed */
13
- version = "1.0.0";
11
+ class p {
12
+ /**
13
+ * Plugin dependencies - declare other plugins this one requires.
14
+ *
15
+ * Dependencies are validated when the plugin is attached.
16
+ * Required dependencies throw an error if missing.
17
+ * Optional dependencies log an info message if missing.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * static readonly dependencies: PluginDependency[] = [
22
+ * { name: 'editing', required: true, reason: 'Tracks cell edits for undo/redo' },
23
+ * { name: 'selection', required: false, reason: 'Enables selection-based undo' },
24
+ * ];
25
+ * ```
26
+ */
27
+ static dependencies;
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";
14
33
  /** CSS styles to inject into the grid's shadow DOM */
15
34
  styles;
16
35
  /** Custom cell renderers keyed by type name */
@@ -97,12 +116,28 @@ class f {
97
116
  emit(e, t) {
98
117
  this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
99
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 r = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
125
+ return this.grid?.dispatchEvent?.(r), r.defaultPrevented;
126
+ }
100
127
  /**
101
128
  * Request a re-render of the grid.
102
129
  */
103
130
  requestRender() {
104
131
  this.grid?.requestRender?.();
105
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
+ }
106
141
  /**
107
142
  * Request a lightweight style update without rebuilding DOM.
108
143
  * Use this instead of requestRender() when only CSS classes need updating.
@@ -136,6 +171,19 @@ class f {
136
171
  get visibleColumns() {
137
172
  return this.grid?._visibleColumns ?? [];
138
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
+ }
139
187
  /**
140
188
  * Get the shadow root of the grid.
141
189
  */
@@ -168,8 +216,53 @@ class f {
168
216
  */
169
217
  get gridIcons() {
170
218
  const e = this.grid?.gridConfig?.icons ?? {};
171
- return { ...p, ...e };
219
+ return { ...h, ...e };
172
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(), r = parseInt(t, 10);
261
+ if (!isNaN(r)) return r;
262
+ }
263
+ return 200;
264
+ }
265
+ // #endregion
173
266
  /**
174
267
  * Resolve an icon value to string or HTMLElement.
175
268
  * Checks plugin config first, then grid-level icons, then defaults.
@@ -199,16 +292,24 @@ class f {
199
292
  }
200
293
  // #endregion
201
294
  }
202
- const v = '.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:8px}.tbw-visibility-row{display:flex;align-items:center;gap:8px;padding:6px 4px;cursor:pointer;font-size:13px;border-radius:var(--tbw-border-radius, 4px);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:10px;letter-spacing:-2px;-webkit-user-select:none;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:8px;flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:8px;padding:8px 12px;border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, 4px);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:13px}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}';
203
- function h(u) {
295
+ const f = '.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:8px}.tbw-visibility-row{display:flex;align-items:center;gap:8px;padding:6px 4px;cursor:pointer;font-size:13px;border-radius:var(--tbw-border-radius, 4px);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:10px;letter-spacing:-2px;-webkit-user-select:none;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:8px;flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:8px;padding:8px 12px;border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, 4px);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:13px}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}';
296
+ function b(u) {
204
297
  const e = u.meta ?? {};
205
298
  return e.lockPosition !== !0 && e.suppressMovable !== !0;
206
299
  }
207
- class g extends f {
300
+ class a extends p {
301
+ /**
302
+ * Plugin dependencies - VisibilityPlugin optionally uses ReorderPlugin for drag-drop reordering.
303
+ *
304
+ * When ReorderPlugin is present, columns in the visibility panel become draggable.
305
+ */
306
+ static dependencies = [
307
+ { name: "reorder", required: !1, reason: "Enables drag-to-reorder columns in visibility panel" }
308
+ ];
208
309
  name = "visibility";
209
- version = "1.0.0";
210
310
  /** Tool panel ID for shell integration */
211
311
  static PANEL_ID = "columns";
312
+ styles = f;
212
313
  get defaultConfig() {
213
314
  return {
214
315
  allowHideAll: !1
@@ -221,6 +322,12 @@ class g extends f {
221
322
  draggedField = null;
222
323
  draggedIndex = null;
223
324
  dropIndex = null;
325
+ /** Clear drag-related classes from all rows in a list. */
326
+ clearDragClasses(e) {
327
+ e.querySelectorAll(".tbw-visibility-row").forEach((t) => {
328
+ t.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
329
+ });
330
+ }
224
331
  // #endregion
225
332
  // #region Lifecycle
226
333
  detach() {
@@ -233,7 +340,7 @@ class g extends f {
233
340
  */
234
341
  getToolPanel() {
235
342
  return {
236
- id: g.PANEL_ID,
343
+ id: a.PANEL_ID,
237
344
  title: "Columns",
238
345
  icon: "☰",
239
346
  tooltip: "Column visibility",
@@ -246,9 +353,10 @@ class g extends f {
246
353
  // #region Public API
247
354
  /**
248
355
  * Show the visibility sidebar panel.
356
+ * Opens the tool panel and ensures this section is expanded.
249
357
  */
250
358
  show() {
251
- this.grid.openToolPanel(g.PANEL_ID);
359
+ this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(a.PANEL_ID) || this.grid.toggleToolPanelSection(a.PANEL_ID);
252
360
  }
253
361
  /**
254
362
  * Hide the visibility sidebar panel.
@@ -257,10 +365,10 @@ class g extends f {
257
365
  this.grid.closeToolPanel();
258
366
  }
259
367
  /**
260
- * Toggle the visibility sidebar panel.
368
+ * Toggle the visibility sidebar panel section.
261
369
  */
262
370
  toggle() {
263
- this.grid.toggleToolPanel(g.PANEL_ID);
371
+ this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(a.PANEL_ID);
264
372
  }
265
373
  /**
266
374
  * Check if a specific column is visible.
@@ -285,14 +393,14 @@ class g extends f {
285
393
  * @returns Array of visible field names
286
394
  */
287
395
  getVisibleColumns() {
288
- return this.grid.getAllColumns().filter((t) => t.visible).map((t) => t.field);
396
+ return this.grid.getAllColumns().filter((e) => e.visible).map((e) => e.field);
289
397
  }
290
398
  /**
291
399
  * Get list of all hidden column fields.
292
400
  * @returns Array of hidden field names
293
401
  */
294
402
  getHiddenColumns() {
295
- return this.grid.getAllColumns().filter((t) => !t.visible).map((t) => t.field);
403
+ return this.grid.getAllColumns().filter((e) => !e.visible).map((e) => e.field);
296
404
  }
297
405
  /**
298
406
  * Show all columns.
@@ -315,7 +423,7 @@ class g extends f {
315
423
  * @param field - The field name of the column to show
316
424
  */
317
425
  showColumn(e) {
318
- this.grid.setColumnVisible(e, !0);
426
+ this.setColumnVisible(e, !0);
319
427
  }
320
428
  /**
321
429
  * Hide a specific column.
@@ -323,7 +431,7 @@ class g extends f {
323
431
  * @param field - The field name of the column to hide
324
432
  */
325
433
  hideColumn(e) {
326
- this.grid.setColumnVisible(e, !1);
434
+ this.setColumnVisible(e, !1);
327
435
  }
328
436
  /**
329
437
  * Get all columns with their visibility status.
@@ -335,10 +443,10 @@ class g extends f {
335
443
  }
336
444
  /**
337
445
  * Check if the sidebar panel is currently open.
338
- * @returns True if the panel is open
446
+ * @returns True if the panel section is expanded
339
447
  */
340
448
  isPanelVisible() {
341
- return this.grid.activeToolPanel === g.PANEL_ID;
449
+ return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(a.PANEL_ID);
342
450
  }
343
451
  // #endregion
344
452
  // #region Private Methods
@@ -347,15 +455,15 @@ class g extends f {
347
455
  * Returns a cleanup function.
348
456
  */
349
457
  renderPanelContent(e) {
350
- const t = this.grid, l = document.createElement("div");
351
- l.className = "tbw-visibility-content";
352
- const o = document.createElement("div");
353
- o.className = "tbw-visibility-list", l.appendChild(o);
354
- const i = document.createElement("button");
355
- return i.className = "tbw-visibility-show-all", i.textContent = "Show All", i.addEventListener("click", () => {
356
- t.showAllColumns(), this.rebuildToggles(o);
357
- }), l.appendChild(i), this.columnListElement = o, this.rebuildToggles(o), e.appendChild(l), () => {
358
- this.columnListElement = null, l.remove();
458
+ const t = document.createElement("div");
459
+ t.className = "tbw-visibility-content";
460
+ const r = document.createElement("div");
461
+ r.className = "tbw-visibility-list", t.appendChild(r);
462
+ const n = document.createElement("button");
463
+ return n.className = "tbw-visibility-show-all", n.textContent = "Show All", n.addEventListener("click", () => {
464
+ this.grid.showAllColumns(), this.rebuildToggles(r);
465
+ }), t.appendChild(n), this.columnListElement = r, this.rebuildToggles(r), e.appendChild(t), () => {
466
+ this.columnListElement = null, t.remove();
359
467
  };
360
468
  }
361
469
  /**
@@ -370,69 +478,64 @@ class g extends f {
370
478
  * When a reorder plugin is present, adds drag handles for reordering.
371
479
  */
372
480
  rebuildToggles(e) {
373
- const t = this.grid, l = this.hasReorderPlugin();
481
+ const t = this.hasReorderPlugin();
374
482
  e.innerHTML = "";
375
- const o = t.getAllColumns();
376
- for (let i = 0; i < o.length; i++) {
377
- const s = o[i], n = s.header || s.field, r = document.createElement("div");
378
- r.className = s.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", r.setAttribute("data-field", s.field), r.setAttribute("data-index", String(i)), l && h(s) && (r.draggable = !0, r.classList.add("reorderable"), this.setupDragListeners(r, s.field, i, e));
379
- const d = document.createElement("label");
380
- d.className = "tbw-visibility-label";
381
- const a = document.createElement("input");
382
- a.type = "checkbox", a.checked = s.visible, a.disabled = s.lockVisible ?? !1, a.addEventListener("change", () => {
383
- t.toggleColumnVisibility(s.field), setTimeout(() => this.rebuildToggles(e), 0);
483
+ const r = this.grid.getAllColumns().filter((n) => !n.utility);
484
+ for (let n = 0; n < r.length; n++) {
485
+ const i = r[n], d = i.header || i.field, s = document.createElement("div");
486
+ s.className = i.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", s.setAttribute("data-field", i.field), s.setAttribute("data-index", String(n)), t && b(i) && (s.draggable = !0, s.classList.add("reorderable"), this.setupDragListeners(s, i.field, n, e));
487
+ const o = document.createElement("label");
488
+ o.className = "tbw-visibility-label";
489
+ const l = document.createElement("input");
490
+ l.type = "checkbox", l.checked = i.visible, l.disabled = i.lockVisible ?? !1, l.addEventListener("change", () => {
491
+ this.grid.toggleColumnVisibility(i.field), setTimeout(() => this.rebuildToggles(e), 0);
384
492
  });
385
- const b = document.createElement("span");
386
- if (b.textContent = n, d.appendChild(a), d.appendChild(b), l && h(s)) {
493
+ const g = document.createElement("span");
494
+ if (g.textContent = d, o.appendChild(l), o.appendChild(g), t && b(i)) {
387
495
  const c = document.createElement("span");
388
- c.className = "tbw-visibility-handle", this.setIcon(c, this.resolveIcon("dragHandle")), c.title = "Drag to reorder", r.appendChild(c);
496
+ c.className = "tbw-visibility-handle", this.setIcon(c, this.resolveIcon("dragHandle")), c.title = "Drag to reorder", s.appendChild(c);
389
497
  }
390
- r.appendChild(d), e.appendChild(r);
498
+ s.appendChild(o), e.appendChild(s);
391
499
  }
392
500
  }
393
501
  /**
394
502
  * Set up drag-and-drop event listeners for a row.
395
503
  * On drop, emits a 'column-reorder-request' event for other plugins to handle.
396
504
  */
397
- setupDragListeners(e, t, l, o) {
505
+ setupDragListeners(e, t, r, n) {
398
506
  e.addEventListener("dragstart", (i) => {
399
- this.isDragging = !0, this.draggedField = t, this.draggedIndex = l, i.dataTransfer && (i.dataTransfer.effectAllowed = "move", i.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
507
+ this.isDragging = !0, this.draggedField = t, this.draggedIndex = r, i.dataTransfer && (i.dataTransfer.effectAllowed = "move", i.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
400
508
  }), e.addEventListener("dragend", () => {
401
- this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, o.querySelectorAll(".tbw-visibility-row").forEach((i) => {
402
- i.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
403
- });
509
+ this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses(n);
404
510
  }), e.addEventListener("dragover", (i) => {
405
511
  if (i.preventDefault(), !this.isDragging || this.draggedField === t) return;
406
- const s = e.getBoundingClientRect(), n = s.top + s.height / 2;
407
- this.dropIndex = i.clientY < n ? l : l + 1, o.querySelectorAll(".tbw-visibility-row").forEach((r) => {
408
- r !== e && r.classList.remove("drop-target", "drop-before", "drop-after");
409
- }), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY < n), e.classList.toggle("drop-after", i.clientY >= n);
512
+ const d = e.getBoundingClientRect(), s = d.top + d.height / 2;
513
+ this.dropIndex = i.clientY < s ? r : r + 1, n.querySelectorAll(".tbw-visibility-row").forEach((o) => {
514
+ o !== e && o.classList.remove("drop-target", "drop-before", "drop-after");
515
+ }), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY < s), e.classList.toggle("drop-after", i.clientY >= s);
410
516
  }), e.addEventListener("dragleave", () => {
411
517
  e.classList.remove("drop-target", "drop-before", "drop-after");
412
518
  }), e.addEventListener("drop", (i) => {
413
519
  i.preventDefault();
414
- const s = this.draggedField, n = this.draggedIndex, r = this.dropIndex;
415
- if (!this.isDragging || s === null || n === null || r === null)
520
+ const d = this.draggedField, s = this.draggedIndex, o = this.dropIndex;
521
+ if (!this.isDragging || d === null || s === null || o === null)
416
522
  return;
417
- const d = r > n ? r - 1 : r;
418
- if (d !== n) {
419
- const a = {
420
- field: s,
421
- fromIndex: n,
422
- toIndex: d
523
+ const l = o > s ? o - 1 : o;
524
+ if (l !== s) {
525
+ const g = {
526
+ field: d,
527
+ fromIndex: s,
528
+ toIndex: l
423
529
  };
424
- this.emit("column-reorder-request", a), setTimeout(() => {
425
- this.rebuildToggles(o);
530
+ this.emit("column-reorder-request", g), setTimeout(() => {
531
+ this.rebuildToggles(n);
426
532
  }, 0);
427
533
  }
428
534
  });
429
535
  }
430
536
  // #endregion
431
- // #region Styles
432
- styles = v;
433
- // #endregion
434
537
  }
435
538
  export {
436
- g as VisibilityPlugin
539
+ a as VisibilityPlugin
437
540
  };
438
541
  //# sourceMappingURL=index.js.map