@toolbox-web/grid 0.4.1 → 0.5.0
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 +9 -13
- package/all.js +1678 -1588
- package/all.js.map +1 -1
- package/index.js +762 -568
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +21 -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/dom-builder.d.ts +2 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/resize.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +19 -13
- package/lib/core/internal/shell.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 +70 -3
- 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/plugin-manager.d.ts +6 -2
- 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 +10 -5
- 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 +295 -190
- 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 +143 -56
- 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 +189 -102
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +2 -7
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +227 -150
- 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 +184 -97
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +14 -3
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +296 -176
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +2 -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 +169 -61
- 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 +243 -140
- 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 +278 -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 +125 -40
- 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 +156 -75
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +2 -2
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.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 +202 -117
- 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 +413 -314
- 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.d.ts +1 -1
- package/lib/plugins/reorder/index.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +296 -223
- 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 +282 -141
- 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 +96 -9
- 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 +209 -113
- 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 +98 -11
- 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 +155 -64
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dg-theme-bootstrap.css +55 -53
- package/themes/dg-theme-contrast.css +42 -40
- package/themes/dg-theme-large.css +38 -37
- package/themes/dg-theme-material.css +54 -52
- package/themes/dg-theme-standard.css +19 -17
- package/themes/dg-theme-vibrant.css +16 -14
- package/umd/grid.all.umd.js +23 -24
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +12 -11
- 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
|
@@ -28,15 +28,17 @@ export declare class VisibilityPlugin extends BaseGridPlugin<VisibilityConfig> {
|
|
|
28
28
|
*/
|
|
29
29
|
static readonly dependencies: PluginDependency[];
|
|
30
30
|
readonly name = "visibility";
|
|
31
|
-
readonly version = "1.0.0";
|
|
32
31
|
/** Tool panel ID for shell integration */
|
|
33
32
|
static readonly PANEL_ID = "columns";
|
|
33
|
+
readonly styles: string;
|
|
34
34
|
protected get defaultConfig(): Partial<VisibilityConfig>;
|
|
35
35
|
private columnListElement;
|
|
36
36
|
private isDragging;
|
|
37
37
|
private draggedField;
|
|
38
38
|
private draggedIndex;
|
|
39
39
|
private dropIndex;
|
|
40
|
+
/** Clear drag-related classes from all rows in a list. */
|
|
41
|
+
private clearDragClasses;
|
|
40
42
|
detach(): void;
|
|
41
43
|
/**
|
|
42
44
|
* Register the column visibility tool panel with the shell.
|
|
@@ -44,6 +46,7 @@ export declare class VisibilityPlugin extends BaseGridPlugin<VisibilityConfig> {
|
|
|
44
46
|
getToolPanel(): ToolPanelDefinition | undefined;
|
|
45
47
|
/**
|
|
46
48
|
* Show the visibility sidebar panel.
|
|
49
|
+
* Opens the tool panel and ensures this section is expanded.
|
|
47
50
|
*/
|
|
48
51
|
show(): void;
|
|
49
52
|
/**
|
|
@@ -51,7 +54,7 @@ export declare class VisibilityPlugin extends BaseGridPlugin<VisibilityConfig> {
|
|
|
51
54
|
*/
|
|
52
55
|
hide(): void;
|
|
53
56
|
/**
|
|
54
|
-
* Toggle the visibility sidebar panel.
|
|
57
|
+
* Toggle the visibility sidebar panel section.
|
|
55
58
|
*/
|
|
56
59
|
toggle(): void;
|
|
57
60
|
/**
|
|
@@ -111,10 +114,11 @@ export declare class VisibilityPlugin extends BaseGridPlugin<VisibilityConfig> {
|
|
|
111
114
|
header: string;
|
|
112
115
|
visible: boolean;
|
|
113
116
|
lockVisible?: boolean;
|
|
117
|
+
utility?: boolean;
|
|
114
118
|
}>;
|
|
115
119
|
/**
|
|
116
120
|
* Check if the sidebar panel is currently open.
|
|
117
|
-
* @returns True if the panel is
|
|
121
|
+
* @returns True if the panel section is expanded
|
|
118
122
|
*/
|
|
119
123
|
isPanelVisible(): boolean;
|
|
120
124
|
/**
|
|
@@ -136,6 +140,5 @@ export declare class VisibilityPlugin extends BaseGridPlugin<VisibilityConfig> {
|
|
|
136
140
|
* On drop, emits a 'column-reorder-request' event for other plugins to handle.
|
|
137
141
|
*/
|
|
138
142
|
private setupDragListeners;
|
|
139
|
-
readonly styles: string;
|
|
140
143
|
}
|
|
141
144
|
//# sourceMappingURL=VisibilityPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/visibility/VisibilityPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,KAAK,EAAgB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"VisibilityPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/visibility/VisibilityPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,KAAK,EAAgB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAWD;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,gBAAgB,CAAC;IACpE;;;;OAIG;IACH,gBAAyB,YAAY,EAAE,gBAAgB,EAAE,CAEvD;IAEF,QAAQ,CAAC,IAAI,gBAAgB;IAE7B,0CAA0C;IAC1C,MAAM,CAAC,QAAQ,CAAC,QAAQ,aAAa;IACrC,SAAkB,MAAM,SAAU;IAElC,cAAuB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAIhE;IAGD,OAAO,CAAC,iBAAiB,CAA4B;IAGrD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAAuB;IAExC,0DAA0D;IAC1D,OAAO,CAAC,gBAAgB;IASf,MAAM,IAAI,IAAI;IAWvB;;OAEG;IACM,YAAY,IAAI,mBAAmB,GAAG,SAAS;IAcxD;;;OAGG;IACH,IAAI,IAAI,IAAI;IAQZ;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,MAAM,IAAI,IAAI;IAQd;;;;;OAKG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIvC;;;;;OAKG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAIvD;;;OAGG;IACH,iBAAiB,IAAI,MAAM,EAAE;IAO7B;;;OAGG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAO5B;;;OAGG;IACH,OAAO,IAAI,IAAI;IAIf;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIjC;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/B;;;;OAIG;IACH,aAAa,IAAI,KAAK,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IAIF;;;OAGG;IACH,cAAc,IAAI,OAAO;IAOzB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAoC1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;OAGG;IACH,OAAO,CAAC,cAAc;IA4DtB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;CAqF3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const v = {
|
|
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 w {
|
|
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.
|
|
@@ -153,10 +172,34 @@ class f {
|
|
|
153
172
|
return this.grid?._visibleColumns ?? [];
|
|
154
173
|
}
|
|
155
174
|
/**
|
|
156
|
-
* Get the
|
|
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
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get the render root of the grid for DOM queries.
|
|
189
|
+
* @deprecated Use `gridElement` instead. This getter exists only for backward compatibility.
|
|
190
|
+
*
|
|
191
|
+
* With Shadow DOM removed, the grid element itself is the render root.
|
|
192
|
+
* All new code should use `this.gridElement` for DOM queries.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // OLD (deprecated)
|
|
196
|
+
* const rows = this.shadowRoot?.querySelector('.rows');
|
|
197
|
+
*
|
|
198
|
+
* // NEW (preferred)
|
|
199
|
+
* const rows = this.gridElement.querySelector('.rows');
|
|
157
200
|
*/
|
|
158
201
|
get shadowRoot() {
|
|
159
|
-
return this.
|
|
202
|
+
return this.gridElement;
|
|
160
203
|
}
|
|
161
204
|
/**
|
|
162
205
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -184,8 +227,53 @@ class f {
|
|
|
184
227
|
*/
|
|
185
228
|
get gridIcons() {
|
|
186
229
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
187
|
-
return { ...
|
|
230
|
+
return { ...v, ...e };
|
|
231
|
+
}
|
|
232
|
+
// #region Animation Helpers
|
|
233
|
+
/**
|
|
234
|
+
* Check if animations are enabled at the grid level.
|
|
235
|
+
* Respects gridConfig.animation.mode and the CSS variable set by the grid.
|
|
236
|
+
*
|
|
237
|
+
* Plugins should use this to skip animations when:
|
|
238
|
+
* - Animation mode is 'off' or `false`
|
|
239
|
+
* - User prefers reduced motion and mode is 'reduced-motion' (default)
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* private get animationStyle(): 'slide' | 'fade' | false {
|
|
244
|
+
* if (!this.isAnimationEnabled) return false;
|
|
245
|
+
* return this.config.animation ?? 'slide';
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
get isAnimationEnabled() {
|
|
250
|
+
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
251
|
+
if (e === !1 || e === "off") return !1;
|
|
252
|
+
if (e === !0 || e === "on") return !0;
|
|
253
|
+
const t = this.gridElement;
|
|
254
|
+
return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
188
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Get the animation duration in milliseconds from CSS variable.
|
|
258
|
+
* Falls back to 200ms if not set.
|
|
259
|
+
*
|
|
260
|
+
* Plugins can use this for their animation timing to stay consistent
|
|
261
|
+
* with the grid-level animation.duration setting.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* element.animate(keyframes, { duration: this.animationDuration });
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
get animationDuration() {
|
|
269
|
+
const e = this.gridElement;
|
|
270
|
+
if (e) {
|
|
271
|
+
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), r = parseInt(t, 10);
|
|
272
|
+
if (!isNaN(r)) return r;
|
|
273
|
+
}
|
|
274
|
+
return 200;
|
|
275
|
+
}
|
|
276
|
+
// #endregion
|
|
189
277
|
/**
|
|
190
278
|
* Resolve an icon value to string or HTMLElement.
|
|
191
279
|
* Checks plugin config first, then grid-level icons, then defaults.
|
|
@@ -215,12 +303,12 @@ class f {
|
|
|
215
303
|
}
|
|
216
304
|
// #endregion
|
|
217
305
|
}
|
|
218
|
-
const
|
|
219
|
-
function
|
|
220
|
-
const e =
|
|
306
|
+
const C = '@layer tbw-plugins{.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem))}.tbw-visibility-row{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-menu-item-padding, .375rem .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);border-radius:var(--tbw-border-radius, .25rem);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:var(--tbw-font-size-2xs, .625rem);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:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));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:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding, .5rem .75rem);border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, .25rem);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}}';
|
|
307
|
+
function m(b) {
|
|
308
|
+
const e = b.meta ?? {};
|
|
221
309
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
222
310
|
}
|
|
223
|
-
class g extends
|
|
311
|
+
class g extends w {
|
|
224
312
|
/**
|
|
225
313
|
* Plugin dependencies - VisibilityPlugin optionally uses ReorderPlugin for drag-drop reordering.
|
|
226
314
|
*
|
|
@@ -230,9 +318,9 @@ class g extends f {
|
|
|
230
318
|
{ name: "reorder", required: !1, reason: "Enables drag-to-reorder columns in visibility panel" }
|
|
231
319
|
];
|
|
232
320
|
name = "visibility";
|
|
233
|
-
version = "1.0.0";
|
|
234
321
|
/** Tool panel ID for shell integration */
|
|
235
322
|
static PANEL_ID = "columns";
|
|
323
|
+
styles = C;
|
|
236
324
|
get defaultConfig() {
|
|
237
325
|
return {
|
|
238
326
|
allowHideAll: !1
|
|
@@ -245,6 +333,12 @@ class g extends f {
|
|
|
245
333
|
draggedField = null;
|
|
246
334
|
draggedIndex = null;
|
|
247
335
|
dropIndex = null;
|
|
336
|
+
/** Clear drag-related classes from all rows in a list. */
|
|
337
|
+
clearDragClasses(e) {
|
|
338
|
+
e.querySelectorAll(".tbw-visibility-row").forEach((t) => {
|
|
339
|
+
t.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
|
|
340
|
+
});
|
|
341
|
+
}
|
|
248
342
|
// #endregion
|
|
249
343
|
// #region Lifecycle
|
|
250
344
|
detach() {
|
|
@@ -270,9 +364,10 @@ class g extends f {
|
|
|
270
364
|
// #region Public API
|
|
271
365
|
/**
|
|
272
366
|
* Show the visibility sidebar panel.
|
|
367
|
+
* Opens the tool panel and ensures this section is expanded.
|
|
273
368
|
*/
|
|
274
369
|
show() {
|
|
275
|
-
this.grid.openToolPanel(g.PANEL_ID);
|
|
370
|
+
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(g.PANEL_ID) || this.grid.toggleToolPanelSection(g.PANEL_ID);
|
|
276
371
|
}
|
|
277
372
|
/**
|
|
278
373
|
* Hide the visibility sidebar panel.
|
|
@@ -281,10 +376,10 @@ class g extends f {
|
|
|
281
376
|
this.grid.closeToolPanel();
|
|
282
377
|
}
|
|
283
378
|
/**
|
|
284
|
-
* Toggle the visibility sidebar panel.
|
|
379
|
+
* Toggle the visibility sidebar panel section.
|
|
285
380
|
*/
|
|
286
381
|
toggle() {
|
|
287
|
-
this.grid.
|
|
382
|
+
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(g.PANEL_ID);
|
|
288
383
|
}
|
|
289
384
|
/**
|
|
290
385
|
* Check if a specific column is visible.
|
|
@@ -309,14 +404,14 @@ class g extends f {
|
|
|
309
404
|
* @returns Array of visible field names
|
|
310
405
|
*/
|
|
311
406
|
getVisibleColumns() {
|
|
312
|
-
return this.grid.getAllColumns().filter((
|
|
407
|
+
return this.grid.getAllColumns().filter((e) => e.visible).map((e) => e.field);
|
|
313
408
|
}
|
|
314
409
|
/**
|
|
315
410
|
* Get list of all hidden column fields.
|
|
316
411
|
* @returns Array of hidden field names
|
|
317
412
|
*/
|
|
318
413
|
getHiddenColumns() {
|
|
319
|
-
return this.grid.getAllColumns().filter((
|
|
414
|
+
return this.grid.getAllColumns().filter((e) => !e.visible).map((e) => e.field);
|
|
320
415
|
}
|
|
321
416
|
/**
|
|
322
417
|
* Show all columns.
|
|
@@ -339,7 +434,7 @@ class g extends f {
|
|
|
339
434
|
* @param field - The field name of the column to show
|
|
340
435
|
*/
|
|
341
436
|
showColumn(e) {
|
|
342
|
-
this.
|
|
437
|
+
this.setColumnVisible(e, !0);
|
|
343
438
|
}
|
|
344
439
|
/**
|
|
345
440
|
* Hide a specific column.
|
|
@@ -347,7 +442,7 @@ class g extends f {
|
|
|
347
442
|
* @param field - The field name of the column to hide
|
|
348
443
|
*/
|
|
349
444
|
hideColumn(e) {
|
|
350
|
-
this.
|
|
445
|
+
this.setColumnVisible(e, !1);
|
|
351
446
|
}
|
|
352
447
|
/**
|
|
353
448
|
* Get all columns with their visibility status.
|
|
@@ -359,10 +454,10 @@ class g extends f {
|
|
|
359
454
|
}
|
|
360
455
|
/**
|
|
361
456
|
* Check if the sidebar panel is currently open.
|
|
362
|
-
* @returns True if the panel is
|
|
457
|
+
* @returns True if the panel section is expanded
|
|
363
458
|
*/
|
|
364
459
|
isPanelVisible() {
|
|
365
|
-
return this.grid.
|
|
460
|
+
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(g.PANEL_ID);
|
|
366
461
|
}
|
|
367
462
|
// #endregion
|
|
368
463
|
// #region Private Methods
|
|
@@ -371,15 +466,15 @@ class g extends f {
|
|
|
371
466
|
* Returns a cleanup function.
|
|
372
467
|
*/
|
|
373
468
|
renderPanelContent(e) {
|
|
374
|
-
const t =
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
return
|
|
380
|
-
|
|
381
|
-
}),
|
|
382
|
-
this.columnListElement = null,
|
|
469
|
+
const t = document.createElement("div");
|
|
470
|
+
t.className = "tbw-visibility-content";
|
|
471
|
+
const r = document.createElement("div");
|
|
472
|
+
r.className = "tbw-visibility-list", t.appendChild(r);
|
|
473
|
+
const s = document.createElement("button");
|
|
474
|
+
return s.className = "tbw-visibility-show-all", s.textContent = "Show All", s.addEventListener("click", () => {
|
|
475
|
+
this.grid.showAllColumns(), this.rebuildToggles(r);
|
|
476
|
+
}), t.appendChild(s), this.columnListElement = r, this.rebuildToggles(r), e.appendChild(t), () => {
|
|
477
|
+
this.columnListElement = null, t.remove();
|
|
383
478
|
};
|
|
384
479
|
}
|
|
385
480
|
/**
|
|
@@ -394,67 +489,63 @@ class g extends f {
|
|
|
394
489
|
* When a reorder plugin is present, adds drag handles for reordering.
|
|
395
490
|
*/
|
|
396
491
|
rebuildToggles(e) {
|
|
397
|
-
const t = this.
|
|
492
|
+
const t = this.hasReorderPlugin();
|
|
398
493
|
e.innerHTML = "";
|
|
399
|
-
const
|
|
400
|
-
for (let
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
494
|
+
const r = this.grid.getAllColumns().filter((s) => !s.utility);
|
|
495
|
+
for (let s = 0; s < r.length; s++) {
|
|
496
|
+
const i = r[s], d = i.header || i.field, n = document.createElement("div");
|
|
497
|
+
n.className = i.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", n.setAttribute("data-field", i.field), n.setAttribute("data-index", String(s)), t && m(i) && (n.draggable = !0, n.classList.add("reorderable"), this.setupDragListeners(n, i.field, s, e));
|
|
498
|
+
const l = document.createElement("label");
|
|
499
|
+
l.className = "tbw-visibility-label";
|
|
500
|
+
const o = document.createElement("input");
|
|
501
|
+
o.type = "checkbox", o.checked = i.visible, o.disabled = i.lockVisible ?? !1, o.addEventListener("change", () => {
|
|
502
|
+
this.grid.toggleColumnVisibility(i.field), setTimeout(() => this.rebuildToggles(e), 0);
|
|
408
503
|
});
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
504
|
+
const a = document.createElement("span");
|
|
505
|
+
if (a.textContent = d, l.appendChild(o), l.appendChild(a), t && m(i)) {
|
|
411
506
|
const c = document.createElement("span");
|
|
412
|
-
c.className = "tbw-visibility-handle", this.setIcon(c, this.resolveIcon("dragHandle")), c.title = "Drag to reorder",
|
|
507
|
+
c.className = "tbw-visibility-handle", this.setIcon(c, this.resolveIcon("dragHandle")), c.title = "Drag to reorder", n.appendChild(c);
|
|
413
508
|
}
|
|
414
|
-
|
|
509
|
+
n.appendChild(l), e.appendChild(n);
|
|
415
510
|
}
|
|
416
511
|
}
|
|
417
512
|
/**
|
|
418
513
|
* Set up drag-and-drop event listeners for a row.
|
|
419
514
|
* On drop, emits a 'column-reorder-request' event for other plugins to handle.
|
|
420
515
|
*/
|
|
421
|
-
setupDragListeners(e, t,
|
|
516
|
+
setupDragListeners(e, t, r, s) {
|
|
422
517
|
e.addEventListener("dragstart", (i) => {
|
|
423
|
-
this.isDragging = !0, this.draggedField = t, this.draggedIndex =
|
|
518
|
+
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
519
|
}), 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
|
-
});
|
|
520
|
+
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses(s);
|
|
428
521
|
}), e.addEventListener("dragover", (i) => {
|
|
429
522
|
if (i.preventDefault(), !this.isDragging || this.draggedField === t) return;
|
|
430
|
-
const
|
|
431
|
-
this.dropIndex = i.clientY < n ?
|
|
432
|
-
|
|
523
|
+
const d = e.getBoundingClientRect(), n = d.top + d.height / 2;
|
|
524
|
+
this.dropIndex = i.clientY < n ? r : r + 1, s.querySelectorAll(".tbw-visibility-row").forEach((l) => {
|
|
525
|
+
l !== e && l.classList.remove("drop-target", "drop-before", "drop-after");
|
|
433
526
|
}), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY < n), e.classList.toggle("drop-after", i.clientY >= n);
|
|
434
527
|
}), e.addEventListener("dragleave", () => {
|
|
435
528
|
e.classList.remove("drop-target", "drop-before", "drop-after");
|
|
436
529
|
}), e.addEventListener("drop", (i) => {
|
|
437
530
|
i.preventDefault();
|
|
438
|
-
const
|
|
439
|
-
if (!this.isDragging ||
|
|
531
|
+
const d = this.draggedField, n = this.draggedIndex, l = this.dropIndex;
|
|
532
|
+
if (!this.isDragging || d === null || n === null || l === null)
|
|
440
533
|
return;
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
const a = {
|
|
444
|
-
field:
|
|
534
|
+
const o = l > n ? l - 1 : l;
|
|
535
|
+
if (o !== n) {
|
|
536
|
+
const a = this.grid.getAllColumns(), h = a.filter((u) => !u.utility)[o]?.field, f = h ? a.findIndex((u) => u.field === h) : a.length, p = {
|
|
537
|
+
field: d,
|
|
445
538
|
fromIndex: n,
|
|
446
|
-
|
|
539
|
+
// Not used by ReorderPlugin, just for info
|
|
540
|
+
toIndex: f
|
|
447
541
|
};
|
|
448
|
-
this.emit("column-reorder-request",
|
|
449
|
-
this.rebuildToggles(
|
|
542
|
+
this.emit("column-reorder-request", p), setTimeout(() => {
|
|
543
|
+
this.rebuildToggles(s);
|
|
450
544
|
}, 0);
|
|
451
545
|
}
|
|
452
546
|
});
|
|
453
547
|
}
|
|
454
548
|
// #endregion
|
|
455
|
-
// #region Styles
|
|
456
|
-
styles = v;
|
|
457
|
-
// #endregion
|
|
458
549
|
}
|
|
459
550
|
export {
|
|
460
551
|
g as VisibilityPlugin
|