@toolbox-web/grid 1.2.0 → 1.3.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.
Files changed (79) hide show
  1. package/README.md +80 -22
  2. package/all.js +619 -571
  3. package/all.js.map +1 -1
  4. package/index.js +362 -302
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +64 -1
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/row-animation.d.ts +37 -0
  9. package/lib/core/internal/row-animation.d.ts.map +1 -0
  10. package/lib/core/types.d.ts +17 -0
  11. package/lib/core/types.d.ts.map +1 -1
  12. package/lib/plugins/clipboard/index.js +82 -76
  13. package/lib/plugins/clipboard/index.js.map +1 -1
  14. package/lib/plugins/clipboard/types.d.ts +1 -0
  15. package/lib/plugins/clipboard/types.d.ts.map +1 -1
  16. package/lib/plugins/column-virtualization/index.js +43 -41
  17. package/lib/plugins/column-virtualization/index.js.map +1 -1
  18. package/lib/plugins/context-menu/index.js +24 -22
  19. package/lib/plugins/context-menu/index.js.map +1 -1
  20. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  21. package/lib/plugins/editing/index.js +83 -52
  22. package/lib/plugins/editing/index.js.map +1 -1
  23. package/lib/plugins/export/index.js +22 -20
  24. package/lib/plugins/export/index.js.map +1 -1
  25. package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
  26. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  27. package/lib/plugins/filtering/index.js +160 -125
  28. package/lib/plugins/filtering/index.js.map +1 -1
  29. package/lib/plugins/grouping-columns/index.js +20 -18
  30. package/lib/plugins/grouping-columns/index.js.map +1 -1
  31. package/lib/plugins/grouping-rows/index.js +66 -64
  32. package/lib/plugins/grouping-rows/index.js.map +1 -1
  33. package/lib/plugins/master-detail/index.js +51 -49
  34. package/lib/plugins/master-detail/index.js.map +1 -1
  35. package/lib/plugins/multi-sort/index.js +17 -15
  36. package/lib/plugins/multi-sort/index.js.map +1 -1
  37. package/lib/plugins/pinned-columns/index.js +24 -22
  38. package/lib/plugins/pinned-columns/index.js.map +1 -1
  39. package/lib/plugins/pinned-rows/index.js +25 -23
  40. package/lib/plugins/pinned-rows/index.js.map +1 -1
  41. package/lib/plugins/pivot/index.js +49 -47
  42. package/lib/plugins/pivot/index.js.map +1 -1
  43. package/lib/plugins/reorder/index.js +24 -22
  44. package/lib/plugins/reorder/index.js.map +1 -1
  45. package/lib/plugins/responsive/index.js +19 -17
  46. package/lib/plugins/responsive/index.js.map +1 -1
  47. package/lib/plugins/row-reorder/index.js +38 -36
  48. package/lib/plugins/row-reorder/index.js.map +1 -1
  49. package/lib/plugins/selection/SelectionPlugin.d.ts +13 -0
  50. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  51. package/lib/plugins/selection/index.d.ts +1 -1
  52. package/lib/plugins/selection/index.d.ts.map +1 -1
  53. package/lib/plugins/selection/index.js +118 -85
  54. package/lib/plugins/selection/index.js.map +1 -1
  55. package/lib/plugins/selection/types.d.ts +50 -6
  56. package/lib/plugins/selection/types.d.ts.map +1 -1
  57. package/lib/plugins/server-side/index.js +34 -32
  58. package/lib/plugins/server-side/index.js.map +1 -1
  59. package/lib/plugins/tree/index.js +25 -23
  60. package/lib/plugins/tree/index.js.map +1 -1
  61. package/lib/plugins/undo-redo/index.js +22 -20
  62. package/lib/plugins/undo-redo/index.js.map +1 -1
  63. package/lib/plugins/visibility/index.js +21 -19
  64. package/lib/plugins/visibility/index.js.map +1 -1
  65. package/package.json +21 -4
  66. package/public.d.ts +1 -1
  67. package/public.d.ts.map +1 -1
  68. package/umd/grid.all.umd.js +19 -19
  69. package/umd/grid.all.umd.js.map +1 -1
  70. package/umd/grid.umd.js +9 -9
  71. package/umd/grid.umd.js.map +1 -1
  72. package/umd/plugins/clipboard.umd.js +5 -5
  73. package/umd/plugins/clipboard.umd.js.map +1 -1
  74. package/umd/plugins/editing.umd.js +1 -1
  75. package/umd/plugins/editing.umd.js.map +1 -1
  76. package/umd/plugins/filtering.umd.js +1 -1
  77. package/umd/plugins/filtering.umd.js.map +1 -1
  78. package/umd/plugins/selection.umd.js +2 -2
  79. package/umd/plugins/selection.umd.js.map +1 -1
package/README.md CHANGED
@@ -16,16 +16,35 @@ npm install @toolbox-web/grid
16
16
 
17
17
  ```typescript
18
18
  import '@toolbox-web/grid';
19
+ import { createGrid } from '@toolbox-web/grid';
19
20
 
20
- const grid = document.createElement('tbw-grid');
21
- grid.columns = [
22
- { field: 'name', header: 'Name' },
23
- { field: 'email', header: 'Email' },
24
- ];
21
+ const grid = createGrid<Employee>({
22
+ columns: [
23
+ { field: 'name', header: 'Name' },
24
+ { field: 'email', header: 'Email' },
25
+ ],
26
+ });
25
27
  grid.rows = data;
26
28
  document.body.appendChild(grid);
27
29
  ```
28
30
 
31
+ ### Factory Functions
32
+
33
+ Use `createGrid<T>()` for typed grid creation (avoids manual casting):
34
+
35
+ ```typescript
36
+ import { createGrid, queryGrid } from '@toolbox-web/grid';
37
+
38
+ // Create a new typed grid
39
+ const grid = createGrid<Employee>({
40
+ columns: [{ field: 'name' }],
41
+ plugins: [new SelectionPlugin()],
42
+ });
43
+
44
+ // Query an existing grid with proper typing
45
+ const existing = queryGrid<Employee>('#my-grid');
46
+ ```
47
+
29
48
  > [!TIP]
30
49
  > For complete examples, see the [Storybook documentation](https://toolboxjs.com/).
31
50
 
@@ -159,23 +178,26 @@ The grid supports configuration via HTML attributes with JSON-serialized values:
159
178
 
160
179
  ### Methods
161
180
 
162
- | Method | Returns | Description |
163
- | ---------------------------------- | --------------------- | -------------------------------------- |
164
- | `ready()` | `Promise<void>` | Resolves when fully initialized |
165
- | `forceLayout()` | `Promise<void>` | Force re-layout |
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 |
171
- | `resetChangedRows(silent?)` | `Promise<void>` | Clear change tracking |
172
- | `beginBulkEdit(rowIndex)` | `Promise<void>` | Start row editing |
173
- | `commitActiveRowEdit()` | `Promise<void>` | Commit current edit |
174
- | `setColumnVisible(field, visible)` | `boolean` | Set column visibility |
175
- | `setColumnOrder(order)` | `void` | Reorder columns by field array |
176
- | `getAllColumns()` | `ColumnInfo[]` | Get all columns with visibility status |
177
- | `getPlugin(PluginClass)` | `P \| undefined` | Get plugin instance by class |
178
- | `getPluginByName(name)` | `Plugin \| undefined` | Get plugin instance by name |
181
+ | Method | Returns | Description |
182
+ | ---------------------------------- | --------------------- | ------------------------------------------- |
183
+ | `ready()` | `Promise<void>` | Resolves when fully initialized |
184
+ | `forceLayout()` | `Promise<void>` | Force re-layout |
185
+ | `getConfig()` | `Promise<GridConfig>` | Get effective configuration |
186
+ | `getRowId(row)` | `string` | Get unique identifier for a row |
187
+ | `getRow(id)` | `T \| undefined` | Get row by its ID |
188
+ | `updateRow(id, changes, source?)` | `void` | Update a single row by ID |
189
+ | `updateRows(updates, source?)` | `void` | Batch update multiple rows |
190
+ | `resetChangedRows(silent?)` | `Promise<void>` | Clear change tracking |
191
+ | `beginBulkEdit(rowIndex)` | `Promise<void>` | Start row editing |
192
+ | `commitActiveRowEdit()` | `Promise<void>` | Commit current edit |
193
+ | `setColumnVisible(field, visible)` | `boolean` | Set column visibility |
194
+ | `setColumnOrder(order)` | `void` | Reorder columns by field array |
195
+ | `getAllColumns()` | `ColumnInfo[]` | Get all columns with visibility status |
196
+ | `getPlugin(PluginClass)` | `P \| undefined` | Get plugin instance by class |
197
+ | `getPluginByName(name)` | `Plugin \| undefined` | Get plugin instance by name |
198
+ | `animateRow(index, type)` | `void` | Animate a single row (change/insert/remove) |
199
+ | `animateRows(indices, type)` | `void` | Animate multiple rows at once |
200
+ | `animateRowById(id, type)` | `boolean` | Animate row by ID (returns true if found) |
179
201
 
180
202
  ### Events
181
203
 
@@ -200,6 +222,42 @@ import { DGEvents } from '@toolbox-web/grid';
200
222
  grid.addEventListener(DGEvents.CELL_COMMIT, handler);
201
223
  ```
202
224
 
225
+ ### Row Animation API
226
+
227
+ Trigger visual feedback when rows change:
228
+
229
+ ```typescript
230
+ // Flash highlight for updated row
231
+ grid.animateRow(5, 'change');
232
+
233
+ // Slide-in for new row
234
+ grid.animateRow(0, 'insert');
235
+
236
+ // Fade-out for removed row
237
+ grid.animateRow(3, 'remove');
238
+
239
+ // Animate by row ID
240
+ grid.animateRowById('emp-123', 'change');
241
+ ```
242
+
243
+ **Animation Types:** `'change'` | `'insert'` | `'remove'`
244
+
245
+ ### Animation Configuration
246
+
247
+ Configure animation behavior globally:
248
+
249
+ ```typescript
250
+ grid.gridConfig = {
251
+ animation: {
252
+ mode: 'on', // 'on' | 'off' | 'reduced-motion'
253
+ style: 'smooth', // Animation easing
254
+ duration: 200, // Default duration in ms
255
+ },
256
+ };
257
+ ```
258
+
259
+ The grid respects `prefers-reduced-motion` media query automatically when `mode` is `'reduced-motion'`.
260
+
203
261
  ---
204
262
 
205
263
  ## Column Configuration