@toolbox-web/grid 1.25.0 → 1.25.1
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/all.js +2 -2
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +15 -1
- package/lib/plugins/grouping-columns/index.d.ts +1 -0
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-columns/types.d.ts +98 -8
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
|
@@ -38,7 +38,64 @@ declare module '../../core/types' {
|
|
|
38
38
|
}
|
|
39
39
|
/** Configuration options for the column groups plugin */
|
|
40
40
|
export interface GroupingColumnsConfig {
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Declarative column group definitions.
|
|
43
|
+
* When provided here, takes precedence over `gridConfig.columnGroups`.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* features: {
|
|
48
|
+
* groupingColumns: {
|
|
49
|
+
* columnGroups: [
|
|
50
|
+
* { header: 'Personal Info', children: ['firstName', 'lastName', 'email'] },
|
|
51
|
+
* { header: 'Work Info', children: ['department', 'title', 'salary'] },
|
|
52
|
+
* ],
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
columnGroups?: ColumnGroupDefinition[];
|
|
58
|
+
/**
|
|
59
|
+
* Group header renderer called for each column group.
|
|
60
|
+
* Receives the group's `id`, `label`, and `columns` in the params,
|
|
61
|
+
* so a single function can handle all groups or differentiate per group via `params.id`.
|
|
62
|
+
*
|
|
63
|
+
* When a {@link ColumnGroupDefinition.renderer | per-group renderer} is also defined,
|
|
64
|
+
* the per-group renderer takes precedence for that specific group.
|
|
65
|
+
*
|
|
66
|
+
* @example Uniform rendering for all groups:
|
|
67
|
+
* ```ts
|
|
68
|
+
* groupHeaderRenderer: (params) => {
|
|
69
|
+
* return `<strong>${params.label}</strong> (${params.columns.length} cols)`;
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example Per-group rendering via switch on `params.id`:
|
|
74
|
+
* ```ts
|
|
75
|
+
* groupHeaderRenderer: (params) => {
|
|
76
|
+
* const icons: Record<string, string> = { personal: '👤', work: '💼' };
|
|
77
|
+
* return `${icons[params.id] ?? '📁'} <strong>${params.label}</strong>`;
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @example Return an HTMLElement for full control:
|
|
82
|
+
* ```ts
|
|
83
|
+
* groupHeaderRenderer: (params) => {
|
|
84
|
+
* const el = document.createElement('span');
|
|
85
|
+
* el.style.cssText = 'display: flex; align-items: center; gap: 0.4em;';
|
|
86
|
+
* el.textContent = `${params.label} — ${params.columns.length} columns`;
|
|
87
|
+
* return el;
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @example Return void to keep the default text label:
|
|
92
|
+
* ```ts
|
|
93
|
+
* groupHeaderRenderer: (params) => {
|
|
94
|
+
* if (params.id === 'misc') return; // default label for this group
|
|
95
|
+
* return `<em>${params.label}</em>`;
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
42
99
|
groupHeaderRenderer?: (params: GroupHeaderRenderParams) => HTMLElement | string | void;
|
|
43
100
|
/** Whether to show group borders (default: true) */
|
|
44
101
|
showGroupBorders?: boolean;
|
|
@@ -51,12 +108,14 @@ export interface GroupingColumnsConfig {
|
|
|
51
108
|
lockGroupOrder?: boolean;
|
|
52
109
|
}
|
|
53
110
|
/**
|
|
54
|
-
* Parameters passed to the {@link GroupingColumnsConfig.groupHeaderRenderer | groupHeaderRenderer}
|
|
111
|
+
* Parameters passed to the {@link GroupingColumnsConfig.groupHeaderRenderer | groupHeaderRenderer}
|
|
112
|
+
* and {@link ColumnGroupDefinition.renderer | per-group renderer} callbacks.
|
|
55
113
|
*
|
|
56
|
-
* @example
|
|
114
|
+
* @example Render all groups with a shared function, differentiated by id:
|
|
57
115
|
* ```ts
|
|
58
116
|
* groupHeaderRenderer: (params) => {
|
|
59
|
-
*
|
|
117
|
+
* const icons = { personal: '👤', work: '💼' };
|
|
118
|
+
* return `${icons[params.id] ?? '📁'} <strong>${params.label}</strong>`;
|
|
60
119
|
* }
|
|
61
120
|
* ```
|
|
62
121
|
*
|
|
@@ -98,16 +157,42 @@ export interface GroupingColumnsState {
|
|
|
98
157
|
isActive: boolean;
|
|
99
158
|
}
|
|
100
159
|
/**
|
|
101
|
-
* Declarative column group definition for GridConfig.columnGroups
|
|
102
|
-
*
|
|
160
|
+
* Declarative column group definition for GridConfig.columnGroups or
|
|
161
|
+
* {@link GroupingColumnsConfig.columnGroups}.
|
|
162
|
+
*
|
|
163
|
+
* @example Minimal (id auto-generated from header)
|
|
164
|
+
* ```ts
|
|
165
|
+
* { header: 'Personal Info', children: ['firstName', 'lastName'] }
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @example With explicit id and per-group renderer
|
|
169
|
+
* ```ts
|
|
170
|
+
* {
|
|
171
|
+
* id: 'personal',
|
|
172
|
+
* header: 'Personal Info',
|
|
173
|
+
* children: ['firstName', 'lastName'],
|
|
174
|
+
* renderer: (params) => `<strong>${params.label}</strong>`,
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
103
177
|
*/
|
|
104
178
|
export interface ColumnGroupDefinition {
|
|
105
|
-
/**
|
|
106
|
-
|
|
179
|
+
/**
|
|
180
|
+
* Unique group identifier.
|
|
181
|
+
* When omitted, auto-generated as a slug of {@link header}
|
|
182
|
+
* (e.g. `'Personal Info'` → `'personal-info'`).
|
|
183
|
+
*
|
|
184
|
+
* Required when {@link renderer} is provided without a {@link header}.
|
|
185
|
+
*/
|
|
186
|
+
id?: string;
|
|
107
187
|
/** Display label for the group header */
|
|
108
188
|
header: string;
|
|
109
189
|
/** Array of column field names belonging to this group */
|
|
110
190
|
children: string[];
|
|
191
|
+
/**
|
|
192
|
+
* Custom renderer for this specific group's header cell.
|
|
193
|
+
* Takes precedence over {@link GroupingColumnsConfig.groupHeaderRenderer}.
|
|
194
|
+
*/
|
|
195
|
+
renderer?: (params: GroupHeaderRenderParams) => HTMLElement | string | void;
|
|
111
196
|
}
|
|
112
197
|
/** Column group definition (computed at runtime) */
|
|
113
198
|
export interface ColumnGroup<T = any> {
|
|
@@ -119,6 +204,11 @@ export interface ColumnGroup<T = any> {
|
|
|
119
204
|
columns: CoreColumnConfig<T>[];
|
|
120
205
|
/** Index of first column in this group */
|
|
121
206
|
firstIndex: number;
|
|
207
|
+
/**
|
|
208
|
+
* Per-group renderer. Resolved from the originating
|
|
209
|
+
* {@link ColumnGroupDefinition.renderer} when present.
|
|
210
|
+
*/
|
|
211
|
+
renderer?: (params: GroupHeaderRenderParams) => HTMLElement | string | void;
|
|
122
212
|
}
|
|
123
213
|
/** Extended column group with implicit flag */
|
|
124
214
|
export interface ColumnGroupInternal<T = any> extends ColumnGroup<T> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toolbox-web/grid",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.1",
|
|
4
4
|
"description": "Zero-dependency, framework-agnostic data grid web component with virtualization, sorting, filtering, editing, and 20+ plugins. Works in vanilla JS, React, Vue, Angular, and any framework.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|