@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.
- package/README.md +10 -13
- package/all.js +1124 -1047
- package/all.js.map +1 -1
- package/index.js +688 -515
- 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/internal/validate-config.d.ts +14 -0
- package/lib/core/internal/validate-config.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +105 -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/index.d.ts +1 -0
- package/lib/core/plugin/index.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +1 -1
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- 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 +9 -2
- 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 +303 -185
- 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 +116 -24
- 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 +164 -72
- 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 +213 -133
- 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 +195 -103
- 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 +145 -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 +162 -68
- 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 +246 -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 +281 -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 +121 -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 +144 -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 +178 -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 +414 -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 +304 -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 +292 -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 +95 -3
- 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 +213 -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 +7 -2
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +112 -12
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +14 -5
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +168 -65
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +21 -17
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +14 -8
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
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
|
|
12
|
-
/**
|
|
13
|
-
|
|
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 { ...
|
|
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
|
|
203
|
-
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) {
|
|
204
297
|
const e = u.meta ?? {};
|
|
205
298
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
206
299
|
}
|
|
207
|
-
class
|
|
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:
|
|
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(
|
|
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.
|
|
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((
|
|
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((
|
|
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.
|
|
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.
|
|
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
|
|
446
|
+
* @returns True if the panel section is expanded
|
|
339
447
|
*/
|
|
340
448
|
isPanelVisible() {
|
|
341
|
-
return this.grid.
|
|
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 =
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
return
|
|
356
|
-
|
|
357
|
-
}),
|
|
358
|
-
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();
|
|
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.
|
|
481
|
+
const t = this.hasReorderPlugin();
|
|
374
482
|
e.innerHTML = "";
|
|
375
|
-
const
|
|
376
|
-
for (let
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
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
|
|
386
|
-
if (
|
|
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",
|
|
496
|
+
c.className = "tbw-visibility-handle", this.setIcon(c, this.resolveIcon("dragHandle")), c.title = "Drag to reorder", s.appendChild(c);
|
|
389
497
|
}
|
|
390
|
-
|
|
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,
|
|
505
|
+
setupDragListeners(e, t, r, n) {
|
|
398
506
|
e.addEventListener("dragstart", (i) => {
|
|
399
|
-
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");
|
|
400
508
|
}), e.addEventListener("dragend", () => {
|
|
401
|
-
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null,
|
|
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
|
|
407
|
-
this.dropIndex = i.clientY <
|
|
408
|
-
|
|
409
|
-
}), 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);
|
|
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
|
|
415
|
-
if (!this.isDragging ||
|
|
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
|
|
418
|
-
if (
|
|
419
|
-
const
|
|
420
|
-
field:
|
|
421
|
-
fromIndex:
|
|
422
|
-
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
|
|
423
529
|
};
|
|
424
|
-
this.emit("column-reorder-request",
|
|
425
|
-
this.rebuildToggles(
|
|
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
|
-
|
|
539
|
+
a as VisibilityPlugin
|
|
437
540
|
};
|
|
438
541
|
//# sourceMappingURL=index.js.map
|