@toolbox-web/grid 0.6.0 → 1.0.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 +79 -26
- package/all.js +731 -1739
- package/all.js.map +1 -1
- package/index.js +1382 -2410
- package/index.js.map +1 -1
- package/lib/core/constants.d.ts +8 -0
- package/lib/core/constants.d.ts.map +1 -1
- package/lib/core/grid.d.ts +704 -55
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/config-manager.d.ts +3 -7
- package/lib/core/internal/config-manager.d.ts.map +1 -1
- package/lib/core/internal/dom-builder.d.ts +2 -10
- package/lib/core/internal/dom-builder.d.ts.map +1 -1
- package/lib/core/internal/inference.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/render-scheduler.d.ts +2 -0
- package/lib/core/internal/render-scheduler.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts +9 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +41 -41
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/internal/validate-config.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +2 -15
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +33 -6
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +376 -68
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +89 -2
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.d.ts +2 -0
- package/lib/plugins/clipboard/index.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +24 -35
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +57 -2
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.d.ts +2 -0
- package/lib/plugins/column-virtualization/index.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +7 -17
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +75 -5
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.d.ts +3 -1
- package/lib/plugins/context-menu/index.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +15 -27
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +101 -9
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/editors.d.ts +9 -1
- package/lib/plugins/editing/editors.d.ts.map +1 -1
- package/lib/plugins/editing/index.d.ts +4 -2
- package/lib/plugins/editing/index.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +412 -279
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +88 -0
- package/lib/plugins/editing/types.d.ts.map +1 -1
- package/lib/plugins/export/ExportPlugin.d.ts +73 -7
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
- package/lib/plugins/export/index.d.ts +2 -0
- package/lib/plugins/export/index.d.ts.map +1 -1
- package/lib/plugins/export/index.js +4 -19
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +98 -2
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.d.ts +2 -0
- package/lib/plugins/filtering/index.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +50 -58
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +80 -6
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.d.ts +2 -0
- package/lib/plugins/grouping-columns/index.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +10 -21
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +81 -5
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.d.ts +3 -1
- package/lib/plugins/grouping-rows/index.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +13 -21
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +90 -5
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.d.ts +2 -0
- package/lib/plugins/master-detail/index.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +11 -17
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +83 -2
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.d.ts +2 -0
- package/lib/plugins/multi-sort/index.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +11 -19
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +61 -2
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.d.ts +3 -1
- package/lib/plugins/pinned-columns/index.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +7 -17
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +71 -10
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.d.ts +3 -1
- package/lib/plugins/pinned-rows/index.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +5 -17
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts +81 -4
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
- package/lib/plugins/pivot/index.d.ts +2 -0
- package/lib/plugins/pivot/index.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +10 -17
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts +71 -3
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.d.ts +2 -0
- package/lib/plugins/reorder/index.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +8 -18
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/reorder/types.d.ts +0 -5
- package/lib/plugins/reorder/types.d.ts.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +84 -20
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.d.ts +2 -1
- package/lib/plugins/selection/index.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +70 -131
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +25 -4
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +65 -4
- package/lib/plugins/server-side/ServerSidePlugin.d.ts.map +1 -1
- package/lib/plugins/server-side/index.d.ts +3 -1
- package/lib/plugins/server-side/index.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js +5 -17
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +89 -2
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.d.ts +3 -2
- package/lib/plugins/tree/index.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +59 -94
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +66 -3
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.d.ts +3 -1
- package/lib/plugins/undo-redo/index.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +5 -17
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +86 -2
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.d.ts +2 -0
- package/lib/plugins/visibility/index.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +6 -17
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +30 -2
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +19 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +11 -11
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +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.map +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +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.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.map +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,6 @@ The grid supports multiple configuration methods, all converging into a **single
|
|
|
43
43
|
grid.gridConfig = {
|
|
44
44
|
columns: [{ field: 'name' }, { field: 'age', type: 'number' }],
|
|
45
45
|
fitMode: 'stretch',
|
|
46
|
-
editOn: 'dblClick',
|
|
47
46
|
plugins: [new SelectionPlugin({ mode: 'row' })],
|
|
48
47
|
shell: { header: { title: 'My Data Grid' } },
|
|
49
48
|
};
|
|
@@ -54,7 +53,6 @@ grid.gridConfig = {
|
|
|
54
53
|
```typescript
|
|
55
54
|
grid.columns = [{ field: 'name' }, { field: 'age' }];
|
|
56
55
|
grid.fitMode = 'stretch';
|
|
57
|
-
grid.editOn = 'dblClick';
|
|
58
56
|
```
|
|
59
57
|
|
|
60
58
|
**3. Via Light DOM (declarative HTML):**
|
|
@@ -75,7 +73,7 @@ grid.editOn = 'dblClick';
|
|
|
75
73
|
|
|
76
74
|
When the same property is set via multiple methods, higher precedence wins:
|
|
77
75
|
|
|
78
|
-
1. Individual props (`fitMode
|
|
76
|
+
1. Individual props (`fitMode`) - highest
|
|
79
77
|
2. `columns` prop
|
|
80
78
|
3. Light DOM elements
|
|
81
79
|
4. `gridConfig` property - lowest
|
|
@@ -137,7 +135,6 @@ The grid supports configuration via HTML attributes with JSON-serialized values:
|
|
|
137
135
|
| `columns` | JSON | Column definitions (JSON-serialized) |
|
|
138
136
|
| `grid-config` | JSON | Full configuration object (JSON-serialized) |
|
|
139
137
|
| `fit-mode` | string | Column sizing: `'stretch'` or `'fixed'` |
|
|
140
|
-
| `edit-on` | string | Edit trigger: `'click'` or `'dblClick'` |
|
|
141
138
|
|
|
142
139
|
**Example with HTML attributes:**
|
|
143
140
|
|
|
@@ -146,21 +143,19 @@ The grid supports configuration via HTML attributes with JSON-serialized values:
|
|
|
146
143
|
rows='[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]'
|
|
147
144
|
columns='[{"field":"id","header":"ID"},{"field":"name","header":"Name"}]'
|
|
148
145
|
fit-mode="stretch"
|
|
149
|
-
edit-on="dblClick"
|
|
150
146
|
>
|
|
151
147
|
</tbw-grid>
|
|
152
148
|
```
|
|
153
149
|
|
|
154
150
|
### Properties
|
|
155
151
|
|
|
156
|
-
| Property | Type
|
|
157
|
-
| ------------ |
|
|
158
|
-
| `rows` | `T[]`
|
|
159
|
-
| `sourceRows` | `T[]` (readonly)
|
|
160
|
-
| `columns` | `ColumnConfig[]`
|
|
161
|
-
| `gridConfig` | `GridConfig`
|
|
162
|
-
| `fitMode` | `'stretch' \| 'fixed'`
|
|
163
|
-
| `editOn` | `'click' \| 'dblClick' \| false` | Edit trigger (→ `gridConfig.editOn`). Set to `false` to disable editing. |
|
|
152
|
+
| Property | Type | Description |
|
|
153
|
+
| ------------ | ---------------------- | -------------------------------------------------- |
|
|
154
|
+
| `rows` | `T[]` | Data array |
|
|
155
|
+
| `sourceRows` | `T[]` (readonly) | Original unfiltered/unprocessed rows |
|
|
156
|
+
| `columns` | `ColumnConfig[]` | Column definitions (→ `gridConfig.columns`) |
|
|
157
|
+
| `gridConfig` | `GridConfig` | Full configuration object (single source of truth) |
|
|
158
|
+
| `fitMode` | `'stretch' \| 'fixed'` | Column sizing behavior (→ `gridConfig.fitMode`) |
|
|
164
159
|
|
|
165
160
|
### Methods
|
|
166
161
|
|
|
@@ -169,6 +164,10 @@ The grid supports configuration via HTML attributes with JSON-serialized values:
|
|
|
169
164
|
| `ready()` | `Promise<void>` | Resolves when fully initialized |
|
|
170
165
|
| `forceLayout()` | `Promise<void>` | Force re-layout |
|
|
171
166
|
| `getConfig()` | `Promise<GridConfig>` | Get effective configuration |
|
|
167
|
+
| `getRowId(row)` | `string` | Get unique identifier for a row |
|
|
168
|
+
| `getRow(id)` | `T \| undefined` | Get row by its ID |
|
|
169
|
+
| `updateRow(id, changes, source?)` | `void` | Update a single row by ID |
|
|
170
|
+
| `updateRows(updates, source?)` | `void` | Batch update multiple rows |
|
|
172
171
|
| `resetChangedRows(silent?)` | `Promise<void>` | Clear change tracking |
|
|
173
172
|
| `beginBulkEdit(rowIndex)` | `Promise<void>` | Start row editing |
|
|
174
173
|
| `commitActiveRowEdit()` | `Promise<void>` | Commit current edit |
|
|
@@ -180,18 +179,19 @@ The grid supports configuration via HTML attributes with JSON-serialized values:
|
|
|
180
179
|
|
|
181
180
|
### Events
|
|
182
181
|
|
|
183
|
-
| Event | Detail | Description
|
|
184
|
-
| ----------------------- | --------------------------- |
|
|
185
|
-
| `cell-commit` | `CellCommitDetail` | Cell value committed
|
|
186
|
-
| `
|
|
187
|
-
| `
|
|
188
|
-
| `
|
|
189
|
-
| `
|
|
190
|
-
| `column-
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
194
|
-
| `mount-external-
|
|
182
|
+
| Event | Detail | Description |
|
|
183
|
+
| ----------------------- | --------------------------- | ---------------------------------- |
|
|
184
|
+
| `cell-commit` | `CellCommitDetail` | Cell value committed (inline edit) |
|
|
185
|
+
| `cell-change` | `CellChangeDetail` | Row updated via Row Update API |
|
|
186
|
+
| `row-commit` | `RowCommitDetail` | Row edit committed |
|
|
187
|
+
| `changed-rows-reset` | `ChangedRowsResetDetail` | Change tracking cleared |
|
|
188
|
+
| `sort-change` | `SortChangeDetail` | Sort state changed |
|
|
189
|
+
| `column-resize` | `ColumnResizeDetail` | Column resized |
|
|
190
|
+
| `column-state-change` | `ColumnState` | Column state changed |
|
|
191
|
+
| `activate-cell` | `ActivateCellDetail` | Cell activated |
|
|
192
|
+
| `group-toggle` | `GroupToggleDetail` | Row group expanded/collapsed |
|
|
193
|
+
| `mount-external-view` | `ExternalMountViewDetail` | External view mount request |
|
|
194
|
+
| `mount-external-editor` | `ExternalMountEditorDetail` | External editor mount request |
|
|
195
195
|
|
|
196
196
|
Import event names from the `DGEvents` constant:
|
|
197
197
|
|
|
@@ -241,13 +241,25 @@ See [Storybook](https://oysteinamundsen.github.io/toolbox/) for complete configu
|
|
|
241
241
|
interface GridConfig {
|
|
242
242
|
columns?: ColumnConfig[];
|
|
243
243
|
fitMode?: 'stretch' | 'fixed';
|
|
244
|
-
editOn?: 'click' | 'dblClick' | false;
|
|
245
244
|
plugins?: BaseGridPlugin[]; // Array of plugin class instances
|
|
246
245
|
icons?: GridIcons; // Centralized icon configuration
|
|
247
246
|
shell?: ShellConfig; // Optional header bar and tool panels
|
|
247
|
+
getRowId?: (row: T) => string; // Custom row ID resolver
|
|
248
|
+
typeDefaults?: Record<string, TypeDefault<T>>; // Type-level renderers/editors
|
|
248
249
|
}
|
|
249
250
|
```
|
|
250
251
|
|
|
252
|
+
### Row Identification
|
|
253
|
+
|
|
254
|
+
The grid uses row IDs for the [Row Update API](#methods). By default, it looks for `id` or `_id` properties on row objects. Rows without an identifiable ID are not accessible via the Row Update API. For custom ID fields, provide a `getRowId` function:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
grid.gridConfig = {
|
|
258
|
+
columns: [...],
|
|
259
|
+
getRowId: (row) => row.employeeNumber, // Use custom field as ID
|
|
260
|
+
};
|
|
261
|
+
```
|
|
262
|
+
|
|
251
263
|
### Icons Configuration
|
|
252
264
|
|
|
253
265
|
The grid provides a centralized icon system via `gridConfig.icons`. All plugins (tree, grouping, sorting, context menus, etc.) automatically use these icons, ensuring visual consistency across the entire grid.
|
|
@@ -270,6 +282,47 @@ grid.gridConfig = {
|
|
|
270
282
|
|
|
271
283
|
Icons can be strings (text or HTML) or `HTMLElement` instances. Plugins use grid-level icons by default but can override with their own config when needed.
|
|
272
284
|
|
|
285
|
+
### Type-Level Defaults
|
|
286
|
+
|
|
287
|
+
Define renderers and editors at the type level that apply to all columns with matching `type`:
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
grid.gridConfig = {
|
|
291
|
+
typeDefaults: {
|
|
292
|
+
country: {
|
|
293
|
+
renderer: (ctx) => {
|
|
294
|
+
const span = document.createElement('span');
|
|
295
|
+
span.textContent = `🌍 ${ctx.value}`;
|
|
296
|
+
return span;
|
|
297
|
+
},
|
|
298
|
+
editor: (ctx) => {
|
|
299
|
+
const select = document.createElement('select');
|
|
300
|
+
['USA', 'UK', 'Germany'].forEach((c) => {
|
|
301
|
+
const opt = document.createElement('option');
|
|
302
|
+
opt.value = c;
|
|
303
|
+
opt.textContent = c;
|
|
304
|
+
select.appendChild(opt);
|
|
305
|
+
});
|
|
306
|
+
select.value = ctx.value;
|
|
307
|
+
select.onchange = () => ctx.commit(select.value);
|
|
308
|
+
return select;
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
currency: {
|
|
312
|
+
editorParams: { min: 0, step: 0.01 },
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
columns: [
|
|
316
|
+
{ field: 'country', type: 'country', editable: true }, // Uses country renderer/editor
|
|
317
|
+
{ field: 'salary', type: 'currency', editable: true }, // Uses currency editorParams
|
|
318
|
+
],
|
|
319
|
+
};
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**Resolution Priority:** Column-level → `gridConfig.typeDefaults` → Framework adapter → Built-in
|
|
323
|
+
|
|
324
|
+
Framework adapters (`@toolbox-web/grid-react`, `@toolbox-web/grid-angular`) provide app-level type registries for React/Angular components.
|
|
325
|
+
|
|
273
326
|
### Plugin Configuration Example
|
|
274
327
|
|
|
275
328
|
Plugins are class instances that you import and instantiate with their configuration:
|