@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
|
@@ -13,8 +13,9 @@ import { ColumnGroup, GroupingColumnsConfig } from './types';
|
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
export declare class GroupingColumnsPlugin extends BaseGridPlugin<GroupingColumnsConfig> {
|
|
16
|
+
#private;
|
|
16
17
|
readonly name = "groupingColumns";
|
|
17
|
-
readonly
|
|
18
|
+
readonly styles: string;
|
|
18
19
|
protected get defaultConfig(): Partial<GroupingColumnsConfig>;
|
|
19
20
|
private groups;
|
|
20
21
|
private isActive;
|
|
@@ -46,6 +47,5 @@ export declare class GroupingColumnsPlugin extends BaseGridPlugin<GroupingColumn
|
|
|
46
47
|
* Refresh column groups (recompute from current columns).
|
|
47
48
|
*/
|
|
48
49
|
refresh(): void;
|
|
49
|
-
readonly styles: string;
|
|
50
50
|
}
|
|
51
51
|
//# sourceMappingURL=GroupingColumnsPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingColumnsPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/grouping-columns/GroupingColumnsPlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQrD,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAElE;;;;;;;;;;GAUG;AACH,qBAAa,qBAAsB,SAAQ,cAAc,CAAC,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"file":"GroupingColumnsPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/grouping-columns/GroupingColumnsPlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQrD,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAElE;;;;;;;;;;GAUG;AACH,qBAAa,qBAAsB,SAAQ,cAAc,CAAC,qBAAqB,CAAC;;IAC9E,QAAQ,CAAC,IAAI,qBAAqB;IAClC,SAAkB,MAAM,SAAU;IAElC,cAAuB,aAAa,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAIrE;IAGD,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,QAAQ,CAAS;IAKhB,MAAM,IAAI,IAAI;IAQvB;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO;IAchD,cAAc,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,EAAE;IA0ChE,WAAW,IAAI,IAAI;IAkF5B;;;OAGG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;;OAGG;IACH,SAAS,IAAI,WAAW,EAAE;IAI1B;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE;IAKhD;;OAEG;IACH,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -20,7 +20,7 @@ export declare function applyGroupedHeaderCellClasses(headerRowEl: HTMLElement |
|
|
|
20
20
|
* Build the group header row element.
|
|
21
21
|
*
|
|
22
22
|
* @param groups - The computed column groups
|
|
23
|
-
* @param columns - The column configurations
|
|
23
|
+
* @param columns - The column configurations (final array including any plugin-added columns)
|
|
24
24
|
* @returns The group header row element, or null if no groups
|
|
25
25
|
*/
|
|
26
26
|
export declare function buildGroupHeaderRow(groups: ColumnGroup[], columns: ColumnConfig[]): HTMLElement | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouping-columns.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/grouping-columns/grouping-columns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,SAAS,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CA+DnF;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,WAAW,GAAG,IAAI,EAC/B,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,EAAE,YAAY,EAAE,GACtB,IAAI,CA8BN;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"grouping-columns.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/grouping-columns/grouping-columns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,SAAS,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CA+DnF;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,WAAW,GAAG,IAAI,EAC/B,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,EAAE,YAAY,EAAE,GACtB,IAAI,CA8BN;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,WAAW,GAAG,IAAI,CA4BtG;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAIzE"}
|
|
@@ -8,7 +8,7 @@ const g = {
|
|
|
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 a {
|
|
|
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 a {
|
|
|
113
116
|
emit(e, r) {
|
|
114
117
|
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: r, 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, r) {
|
|
124
|
+
const t = new CustomEvent(e, { detail: r, bubbles: !0, cancelable: !0 });
|
|
125
|
+
return this.grid?.dispatchEvent?.(t), t.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 a {
|
|
|
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.
|
|
@@ -186,6 +229,51 @@ class a {
|
|
|
186
229
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
187
230
|
return { ...g, ...e };
|
|
188
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 r = this.gridElement;
|
|
254
|
+
return r ? getComputedStyle(r).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
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 r = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), t = parseInt(r, 10);
|
|
272
|
+
if (!isNaN(t)) return t;
|
|
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,55 +303,55 @@ class a {
|
|
|
215
303
|
}
|
|
216
304
|
// #endregion
|
|
217
305
|
}
|
|
218
|
-
function
|
|
306
|
+
function c(u) {
|
|
219
307
|
if (!u.length) return [];
|
|
220
|
-
const e = /* @__PURE__ */ new Map(), r = [], t = (o,
|
|
221
|
-
if (!
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
|
|
308
|
+
const e = /* @__PURE__ */ new Map(), r = [], t = (o, l) => {
|
|
309
|
+
if (!l.length) return;
|
|
310
|
+
const s = r[r.length - 1];
|
|
311
|
+
if (s && s.implicit && s.firstIndex + s.columns.length === o) {
|
|
312
|
+
s.columns.push(...l);
|
|
225
313
|
return;
|
|
226
314
|
}
|
|
227
315
|
r.push({
|
|
228
316
|
id: "__implicit__" + o,
|
|
229
317
|
label: void 0,
|
|
230
|
-
columns:
|
|
318
|
+
columns: l,
|
|
231
319
|
firstIndex: o,
|
|
232
320
|
implicit: !0
|
|
233
321
|
});
|
|
234
322
|
};
|
|
235
|
-
let i = [],
|
|
236
|
-
return u.forEach((o,
|
|
237
|
-
const
|
|
238
|
-
if (!
|
|
239
|
-
i.length === 0 && (
|
|
323
|
+
let i = [], n = 0;
|
|
324
|
+
return u.forEach((o, l) => {
|
|
325
|
+
const s = o.group;
|
|
326
|
+
if (!s) {
|
|
327
|
+
i.length === 0 && (n = l), i.push(o);
|
|
240
328
|
return;
|
|
241
329
|
}
|
|
242
|
-
i.length && (t(
|
|
243
|
-
const
|
|
244
|
-
let
|
|
245
|
-
|
|
246
|
-
id:
|
|
247
|
-
label: typeof
|
|
330
|
+
i.length && (t(n, i.slice()), i = []);
|
|
331
|
+
const d = typeof s == "string" ? s : s.id;
|
|
332
|
+
let a = e.get(d);
|
|
333
|
+
a || (a = {
|
|
334
|
+
id: d,
|
|
335
|
+
label: typeof s == "string" ? void 0 : s.label,
|
|
248
336
|
columns: [],
|
|
249
|
-
firstIndex:
|
|
250
|
-
}, e.set(
|
|
251
|
-
}), i.length && t(
|
|
337
|
+
firstIndex: l
|
|
338
|
+
}, e.set(d, a), r.push(a)), a.columns.push(o);
|
|
339
|
+
}), i.length && t(n, i), r.length === 1 && r[0].implicit && r[0].columns.length === u.length ? [] : r;
|
|
252
340
|
}
|
|
253
|
-
function
|
|
341
|
+
function h(u, e, r) {
|
|
254
342
|
if (!e.length || !u) return;
|
|
255
343
|
const t = /* @__PURE__ */ new Map();
|
|
256
|
-
for (const
|
|
257
|
-
for (const o of
|
|
258
|
-
o.field && t.set(o.field,
|
|
344
|
+
for (const n of e)
|
|
345
|
+
for (const o of n.columns)
|
|
346
|
+
o.field && t.set(o.field, n.id);
|
|
259
347
|
const i = Array.from(u.querySelectorAll(".cell[data-field]"));
|
|
260
|
-
i.forEach((
|
|
261
|
-
const o =
|
|
262
|
-
|
|
348
|
+
i.forEach((n) => {
|
|
349
|
+
const o = n.getAttribute("data-field") || "", l = t.get(o);
|
|
350
|
+
l && (n.classList.add("grouped"), n.getAttribute("data-group") || n.setAttribute("data-group", l));
|
|
263
351
|
});
|
|
264
|
-
for (const
|
|
265
|
-
const o =
|
|
266
|
-
|
|
352
|
+
for (const n of e) {
|
|
353
|
+
const o = n.columns[n.columns.length - 1], l = i.find((s) => s.getAttribute("data-field") === o.field);
|
|
354
|
+
l && l.classList.add("group-end");
|
|
267
355
|
}
|
|
268
356
|
}
|
|
269
357
|
function f(u, e) {
|
|
@@ -271,18 +359,20 @@ function f(u, e) {
|
|
|
271
359
|
const r = document.createElement("div");
|
|
272
360
|
r.className = "header-group-row", r.setAttribute("role", "row");
|
|
273
361
|
for (const t of u) {
|
|
274
|
-
const i = t.
|
|
275
|
-
|
|
362
|
+
const i = t.columns[0], n = i ? e.findIndex((d) => d.field === i.field) : -1;
|
|
363
|
+
if (n === -1) continue;
|
|
364
|
+
const o = String(t.id).startsWith("__implicit__"), l = o ? "" : t.label || t.id, s = document.createElement("div");
|
|
365
|
+
s.className = "cell header-group-cell", o && s.classList.add("implicit-group"), s.setAttribute("data-group", String(t.id)), s.style.gridColumn = `${n + 1} / span ${t.columns.length}`, s.textContent = l, r.appendChild(s);
|
|
276
366
|
}
|
|
277
367
|
return r;
|
|
278
368
|
}
|
|
279
369
|
function m(u) {
|
|
280
370
|
return u.some((e) => e.group != null);
|
|
281
371
|
}
|
|
282
|
-
const b = ".header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:
|
|
283
|
-
class w extends
|
|
372
|
+
const b = "@layer tbw-plugins{.header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:var(--tbw-button-padding-sm, .25rem .5rem);font-weight:600;font-size:var(--tbw-font-size-sm, .9em);text-transform:uppercase;letter-spacing:.5px;border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-row .cell.group-end:last-child{border-right:none}.rows .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.rows .cell.group-end:last-child{border-right:none}.header-group-row.no-borders{border-bottom:none}.header-group-row.no-borders .header-group-cell{border-right:none}.header-row.no-group-borders .cell.group-end{border-right:1px solid var(--tbw-color-border)}}";
|
|
373
|
+
class w extends p {
|
|
284
374
|
name = "groupingColumns";
|
|
285
|
-
|
|
375
|
+
styles = b;
|
|
286
376
|
get defaultConfig() {
|
|
287
377
|
return {
|
|
288
378
|
showGroupBorders: !0
|
|
@@ -314,37 +404,58 @@ class w extends a {
|
|
|
314
404
|
const r = this.grid?.gridConfig?.columnGroups;
|
|
315
405
|
let t;
|
|
316
406
|
if (r && Array.isArray(r) && r.length > 0) {
|
|
317
|
-
const
|
|
407
|
+
const n = /* @__PURE__ */ new Map();
|
|
318
408
|
for (const o of r)
|
|
319
|
-
for (const
|
|
320
|
-
|
|
409
|
+
for (const l of o.children)
|
|
410
|
+
n.set(l, { id: o.id, label: o.header });
|
|
321
411
|
t = e.map((o) => {
|
|
322
|
-
const
|
|
323
|
-
return
|
|
412
|
+
const l = n.get(o.field);
|
|
413
|
+
return l && !o.group ? { ...o, group: l } : o;
|
|
324
414
|
});
|
|
325
415
|
} else
|
|
326
416
|
t = [...e];
|
|
327
|
-
const i =
|
|
417
|
+
const i = c(t);
|
|
328
418
|
return i.length === 0 ? (this.isActive = !1, this.groups = [], t) : (this.isActive = !0, this.groups = i, t);
|
|
329
419
|
}
|
|
330
420
|
afterRender() {
|
|
331
|
-
if (!this.isActive
|
|
332
|
-
const
|
|
333
|
-
|
|
421
|
+
if (!this.isActive) {
|
|
422
|
+
const s = this.gridElement?.querySelector(".header")?.querySelector(".header-group-row");
|
|
423
|
+
s && s.remove();
|
|
334
424
|
return;
|
|
335
425
|
}
|
|
336
|
-
const e = this.
|
|
426
|
+
const e = this.gridElement?.querySelector(".header");
|
|
337
427
|
if (!e) return;
|
|
338
428
|
const r = e.querySelector(".header-group-row");
|
|
339
429
|
r && r.remove();
|
|
340
|
-
const t =
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
430
|
+
const t = this.columns, i = c(t);
|
|
431
|
+
if (i.length === 0) return;
|
|
432
|
+
const n = f(i, t);
|
|
433
|
+
if (n) {
|
|
434
|
+
n.classList.toggle("no-borders", !this.config.showGroupBorders);
|
|
435
|
+
const l = e.querySelector(".header-row");
|
|
436
|
+
l ? e.insertBefore(n, l) : e.appendChild(n);
|
|
437
|
+
}
|
|
438
|
+
const o = e.querySelector(".header-row");
|
|
439
|
+
o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders), h(o, i)), this.#e(i);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Apply group-end class to all data cells in the last column of each group.
|
|
443
|
+
* This extends the strong border separator through all data rows.
|
|
444
|
+
*/
|
|
445
|
+
#e(e) {
|
|
446
|
+
if (!this.config.showGroupBorders) return;
|
|
447
|
+
const r = this.gridElement;
|
|
448
|
+
if (!r) return;
|
|
449
|
+
const t = /* @__PURE__ */ new Set();
|
|
450
|
+
for (const n of e) {
|
|
451
|
+
const o = n.columns[n.columns.length - 1];
|
|
452
|
+
o?.field && t.add(o.field);
|
|
453
|
+
}
|
|
454
|
+
const i = r.querySelectorAll(".rows .cell[data-field]");
|
|
455
|
+
for (const n of i) {
|
|
456
|
+
const o = n.getAttribute("data-field");
|
|
457
|
+
o && t.has(o) ? n.classList.add("group-end") : n.classList.remove("group-end");
|
|
345
458
|
}
|
|
346
|
-
const i = e.querySelector(".header-row");
|
|
347
|
-
i && (i.classList.toggle("no-group-borders", !this.config.showGroupBorders), p(i, this.groups, this.columns));
|
|
348
459
|
}
|
|
349
460
|
// #endregion
|
|
350
461
|
// #region Public API
|
|
@@ -378,9 +489,6 @@ class w extends a {
|
|
|
378
489
|
this.requestRender();
|
|
379
490
|
}
|
|
380
491
|
// #endregion
|
|
381
|
-
// #region Styles
|
|
382
|
-
styles = b;
|
|
383
|
-
// #endregion
|
|
384
492
|
}
|
|
385
493
|
export {
|
|
386
494
|
w as GroupingColumnsPlugin
|