@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.
- package/README.md +10 -13
- package/all.js +1101 -1048
- package/all.js.map +1 -1
- package/index.js +245 -137
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +10 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/config-manager.d.ts +1 -0
- package/lib/core/internal/config-manager.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/utils.d.ts +1 -0
- package/lib/core/internal/utils.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +57 -1
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/expander-column.d.ts +51 -0
- package/lib/core/plugin/expander-column.d.ts.map +1 -0
- package/lib/core/plugin/types.d.ts +117 -1
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +4 -2
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +5 -4
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.d.ts +1 -1
- package/lib/plugins/clipboard/index.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +282 -188
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +72 -2
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -1
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +102 -26
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +0 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +154 -78
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -7
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +200 -136
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/ExportPlugin.d.ts +0 -1
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
- package/lib/plugins/export/index.js +175 -99
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +5 -2
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +129 -43
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -2
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +144 -66
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -2
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +230 -138
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +13 -11
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +265 -196
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +0 -10
- package/lib/plugins/master-detail/types.d.ts.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +1 -2
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +105 -31
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +0 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +128 -52
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -2
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +162 -88
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts +26 -4
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +398 -310
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/pivot/pivot-rows.d.ts +2 -1
- package/lib/plugins/pivot/pivot-rows.d.ts.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts +13 -10
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +288 -226
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +21 -3
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.d.ts +2 -2
- package/lib/plugins/selection/index.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +276 -145
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +24 -0
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -1
- package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js +83 -7
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +5 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +197 -112
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/types.d.ts +0 -10
- package/lib/plugins/tree/types.d.ts.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +0 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +93 -17
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -4
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +144 -65
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +17 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +7 -7
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -7
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/export.umd.js +1 -1
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
- package/lib/core/internal/editing.d.ts +0 -76
- package/lib/core/internal/editing.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
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
|
|
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
|
-
/**
|
|
29
|
-
|
|
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 { ...
|
|
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
|
|
219
|
-
function
|
|
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
|
|
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:
|
|
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(
|
|
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.
|
|
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((
|
|
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((
|
|
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.
|
|
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.
|
|
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
|
|
446
|
+
* @returns True if the panel section is expanded
|
|
363
447
|
*/
|
|
364
448
|
isPanelVisible() {
|
|
365
|
-
return this.grid.
|
|
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 =
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
return
|
|
380
|
-
|
|
381
|
-
}),
|
|
382
|
-
this.columnListElement = null,
|
|
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.
|
|
481
|
+
const t = this.hasReorderPlugin();
|
|
398
482
|
e.innerHTML = "";
|
|
399
|
-
const
|
|
400
|
-
for (let
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
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
|
|
410
|
-
if (
|
|
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",
|
|
496
|
+
c.className = "tbw-visibility-handle", this.setIcon(c, this.resolveIcon("dragHandle")), c.title = "Drag to reorder", s.appendChild(c);
|
|
413
497
|
}
|
|
414
|
-
|
|
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,
|
|
505
|
+
setupDragListeners(e, t, r, n) {
|
|
422
506
|
e.addEventListener("dragstart", (i) => {
|
|
423
|
-
this.isDragging = !0, this.draggedField = t, this.draggedIndex =
|
|
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,
|
|
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
|
|
431
|
-
this.dropIndex = i.clientY <
|
|
432
|
-
|
|
433
|
-
}), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY <
|
|
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
|
|
439
|
-
if (!this.isDragging ||
|
|
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
|
|
442
|
-
if (
|
|
443
|
-
const
|
|
444
|
-
field:
|
|
445
|
-
fromIndex:
|
|
446
|
-
toIndex:
|
|
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",
|
|
449
|
-
this.rebuildToggles(
|
|
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
|
-
|
|
539
|
+
a as VisibilityPlugin
|
|
461
540
|
};
|
|
462
541
|
//# sourceMappingURL=index.js.map
|