@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
@@ -1,4 +1,4 @@
1
- const p = {
1
+ const h = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,7 +8,7 @@ const p = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class f {
11
+ class p {
12
12
  /**
13
13
  * Plugin dependencies - declare other plugins this one requires.
14
14
  *
@@ -25,8 +25,11 @@ class f {
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 */
@@ -113,12 +116,28 @@ class f {
113
116
  emit(e, t) {
114
117
  this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
115
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
+ }
116
127
  /**
117
128
  * Request a re-render of the grid.
118
129
  */
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 f {
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
  */
@@ -184,8 +216,53 @@ class f {
184
216
  */
185
217
  get gridIcons() {
186
218
  const e = this.grid?.gridConfig?.icons ?? {};
187
- return { ...p, ...e };
219
+ return { ...h, ...e };
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;
188
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
189
266
  /**
190
267
  * Resolve an icon value to string or HTMLElement.
191
268
  * Checks plugin config first, then grid-level icons, then defaults.
@@ -215,12 +292,12 @@ class f {
215
292
  }
216
293
  // #endregion
217
294
  }
218
- 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))}';
219
- 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) {
220
297
  const e = u.meta ?? {};
221
298
  return e.lockPosition !== !0 && e.suppressMovable !== !0;
222
299
  }
223
- class g extends f {
300
+ class a extends p {
224
301
  /**
225
302
  * Plugin dependencies - VisibilityPlugin optionally uses ReorderPlugin for drag-drop reordering.
226
303
  *
@@ -230,9 +307,9 @@ class g extends f {
230
307
  { name: "reorder", required: !1, reason: "Enables drag-to-reorder columns in visibility panel" }
231
308
  ];
232
309
  name = "visibility";
233
- version = "1.0.0";
234
310
  /** Tool panel ID for shell integration */
235
311
  static PANEL_ID = "columns";
312
+ styles = f;
236
313
  get defaultConfig() {
237
314
  return {
238
315
  allowHideAll: !1
@@ -245,6 +322,12 @@ class g extends f {
245
322
  draggedField = null;
246
323
  draggedIndex = null;
247
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
+ }
248
331
  // #endregion
249
332
  // #region Lifecycle
250
333
  detach() {
@@ -257,7 +340,7 @@ class g extends f {
257
340
  */
258
341
  getToolPanel() {
259
342
  return {
260
- id: g.PANEL_ID,
343
+ id: a.PANEL_ID,
261
344
  title: "Columns",
262
345
  icon: "☰",
263
346
  tooltip: "Column visibility",
@@ -270,9 +353,10 @@ class g extends f {
270
353
  // #region Public API
271
354
  /**
272
355
  * Show the visibility sidebar panel.
356
+ * Opens the tool panel and ensures this section is expanded.
273
357
  */
274
358
  show() {
275
- this.grid.openToolPanel(g.PANEL_ID);
359
+ this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(a.PANEL_ID) || this.grid.toggleToolPanelSection(a.PANEL_ID);
276
360
  }
277
361
  /**
278
362
  * Hide the visibility sidebar panel.
@@ -281,10 +365,10 @@ class g extends f {
281
365
  this.grid.closeToolPanel();
282
366
  }
283
367
  /**
284
- * Toggle the visibility sidebar panel.
368
+ * Toggle the visibility sidebar panel section.
285
369
  */
286
370
  toggle() {
287
- this.grid.toggleToolPanel(g.PANEL_ID);
371
+ this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(a.PANEL_ID);
288
372
  }
289
373
  /**
290
374
  * Check if a specific column is visible.
@@ -309,14 +393,14 @@ class g extends f {
309
393
  * @returns Array of visible field names
310
394
  */
311
395
  getVisibleColumns() {
312
- 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);
313
397
  }
314
398
  /**
315
399
  * Get list of all hidden column fields.
316
400
  * @returns Array of hidden field names
317
401
  */
318
402
  getHiddenColumns() {
319
- 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);
320
404
  }
321
405
  /**
322
406
  * Show all columns.
@@ -339,7 +423,7 @@ class g extends f {
339
423
  * @param field - The field name of the column to show
340
424
  */
341
425
  showColumn(e) {
342
- this.grid.setColumnVisible(e, !0);
426
+ this.setColumnVisible(e, !0);
343
427
  }
344
428
  /**
345
429
  * Hide a specific column.
@@ -347,7 +431,7 @@ class g extends f {
347
431
  * @param field - The field name of the column to hide
348
432
  */
349
433
  hideColumn(e) {
350
- this.grid.setColumnVisible(e, !1);
434
+ this.setColumnVisible(e, !1);
351
435
  }
352
436
  /**
353
437
  * Get all columns with their visibility status.
@@ -359,10 +443,10 @@ class g extends f {
359
443
  }
360
444
  /**
361
445
  * Check if the sidebar panel is currently open.
362
- * @returns True if the panel is open
446
+ * @returns True if the panel section is expanded
363
447
  */
364
448
  isPanelVisible() {
365
- return this.grid.activeToolPanel === g.PANEL_ID;
449
+ return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(a.PANEL_ID);
366
450
  }
367
451
  // #endregion
368
452
  // #region Private Methods
@@ -371,15 +455,15 @@ class g extends f {
371
455
  * Returns a cleanup function.
372
456
  */
373
457
  renderPanelContent(e) {
374
- const t = this.grid, l = document.createElement("div");
375
- l.className = "tbw-visibility-content";
376
- const o = document.createElement("div");
377
- o.className = "tbw-visibility-list", l.appendChild(o);
378
- const i = document.createElement("button");
379
- return i.className = "tbw-visibility-show-all", i.textContent = "Show All", i.addEventListener("click", () => {
380
- t.showAllColumns(), this.rebuildToggles(o);
381
- }), l.appendChild(i), this.columnListElement = o, this.rebuildToggles(o), e.appendChild(l), () => {
382
- 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();
383
467
  };
384
468
  }
385
469
  /**
@@ -394,69 +478,64 @@ class g extends f {
394
478
  * When a reorder plugin is present, adds drag handles for reordering.
395
479
  */
396
480
  rebuildToggles(e) {
397
- const t = this.grid, l = this.hasReorderPlugin();
481
+ const t = this.hasReorderPlugin();
398
482
  e.innerHTML = "";
399
- const o = t.getAllColumns();
400
- for (let i = 0; i < o.length; i++) {
401
- const s = o[i], n = s.header || s.field, r = document.createElement("div");
402
- 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));
403
- const d = document.createElement("label");
404
- d.className = "tbw-visibility-label";
405
- const a = document.createElement("input");
406
- a.type = "checkbox", a.checked = s.visible, a.disabled = s.lockVisible ?? !1, a.addEventListener("change", () => {
407
- 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);
408
492
  });
409
- const b = document.createElement("span");
410
- 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)) {
411
495
  const c = document.createElement("span");
412
- 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);
413
497
  }
414
- r.appendChild(d), e.appendChild(r);
498
+ s.appendChild(o), e.appendChild(s);
415
499
  }
416
500
  }
417
501
  /**
418
502
  * Set up drag-and-drop event listeners for a row.
419
503
  * On drop, emits a 'column-reorder-request' event for other plugins to handle.
420
504
  */
421
- setupDragListeners(e, t, l, o) {
505
+ setupDragListeners(e, t, r, n) {
422
506
  e.addEventListener("dragstart", (i) => {
423
- 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");
424
508
  }), e.addEventListener("dragend", () => {
425
- this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, o.querySelectorAll(".tbw-visibility-row").forEach((i) => {
426
- i.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
427
- });
509
+ this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses(n);
428
510
  }), e.addEventListener("dragover", (i) => {
429
511
  if (i.preventDefault(), !this.isDragging || this.draggedField === t) return;
430
- const s = e.getBoundingClientRect(), n = s.top + s.height / 2;
431
- this.dropIndex = i.clientY < n ? l : l + 1, o.querySelectorAll(".tbw-visibility-row").forEach((r) => {
432
- r !== e && r.classList.remove("drop-target", "drop-before", "drop-after");
433
- }), 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);
434
516
  }), e.addEventListener("dragleave", () => {
435
517
  e.classList.remove("drop-target", "drop-before", "drop-after");
436
518
  }), e.addEventListener("drop", (i) => {
437
519
  i.preventDefault();
438
- const s = this.draggedField, n = this.draggedIndex, r = this.dropIndex;
439
- 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)
440
522
  return;
441
- const d = r > n ? r - 1 : r;
442
- if (d !== n) {
443
- const a = {
444
- field: s,
445
- fromIndex: n,
446
- 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
447
529
  };
448
- this.emit("column-reorder-request", a), setTimeout(() => {
449
- this.rebuildToggles(o);
530
+ this.emit("column-reorder-request", g), setTimeout(() => {
531
+ this.rebuildToggles(n);
450
532
  }, 0);
451
533
  }
452
534
  });
453
535
  }
454
536
  // #endregion
455
- // #region Styles
456
- styles = v;
457
- // #endregion
458
537
  }
459
538
  export {
460
- g as VisibilityPlugin
539
+ a as VisibilityPlugin
461
540
  };
462
541
  //# sourceMappingURL=index.js.map