@toolbox-web/grid 0.2.2 → 0.2.4

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 (36) hide show
  1. package/README.md +70 -0
  2. package/all.d.ts +373 -261
  3. package/all.js +328 -287
  4. package/all.js.map +1 -1
  5. package/index.d.ts +265 -196
  6. package/index.js +1307 -1179
  7. package/index.js.map +1 -1
  8. package/lib/plugins/clipboard/index.js.map +1 -1
  9. package/lib/plugins/column-virtualization/index.js.map +1 -1
  10. package/lib/plugins/context-menu/index.js.map +1 -1
  11. package/lib/plugins/export/index.js.map +1 -1
  12. package/lib/plugins/filtering/index.js.map +1 -1
  13. package/lib/plugins/grouping-columns/index.js.map +1 -1
  14. package/lib/plugins/grouping-rows/index.js.map +1 -1
  15. package/lib/plugins/master-detail/index.js.map +1 -1
  16. package/lib/plugins/multi-sort/index.js.map +1 -1
  17. package/lib/plugins/pinned-columns/index.js +91 -48
  18. package/lib/plugins/pinned-columns/index.js.map +1 -1
  19. package/lib/plugins/pinned-rows/index.js.map +1 -1
  20. package/lib/plugins/pivot/index.js.map +1 -1
  21. package/lib/plugins/reorder/index.js +38 -35
  22. package/lib/plugins/reorder/index.js.map +1 -1
  23. package/lib/plugins/selection/index.js.map +1 -1
  24. package/lib/plugins/server-side/index.js.map +1 -1
  25. package/lib/plugins/tree/index.js.map +1 -1
  26. package/lib/plugins/undo-redo/index.js.map +1 -1
  27. package/lib/plugins/visibility/index.js.map +1 -1
  28. package/package.json +2 -2
  29. package/umd/grid.all.umd.js +19 -19
  30. package/umd/grid.all.umd.js.map +1 -1
  31. package/umd/grid.umd.js +16 -16
  32. package/umd/grid.umd.js.map +1 -1
  33. package/umd/plugins/pinned-columns.umd.js +1 -1
  34. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  35. package/umd/plugins/reorder.umd.js +1 -1
  36. package/umd/plugins/reorder.umd.js.map +1 -1
package/README.md CHANGED
@@ -126,6 +126,30 @@ When the same property is set via multiple methods, higher precedence wins:
126
126
  <tbw-grid></tbw-grid>
127
127
  ```
128
128
 
129
+ ### HTML Attributes
130
+
131
+ The grid supports configuration via HTML attributes with JSON-serialized values:
132
+
133
+ | Attribute | Type | Description |
134
+ | ------------- | ------ | ------------------------------------------- |
135
+ | `rows` | JSON | Data array (JSON-serialized) |
136
+ | `columns` | JSON | Column definitions (JSON-serialized) |
137
+ | `grid-config` | JSON | Full configuration object (JSON-serialized) |
138
+ | `fit-mode` | string | Column sizing: `'stretch'` or `'fixed'` |
139
+ | `edit-on` | string | Edit trigger: `'click'` or `'dblclick'` |
140
+
141
+ **Example with HTML attributes:**
142
+
143
+ ```html
144
+ <tbw-grid
145
+ rows='[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]'
146
+ columns='[{"field":"id","header":"ID"},{"field":"name","header":"Name"}]'
147
+ fit-mode="stretch"
148
+ edit-on="dblclick"
149
+ >
150
+ </tbw-grid>
151
+ ```
152
+
129
153
  ### Properties
130
154
 
131
155
  | Property | Type | Description |
@@ -423,6 +447,52 @@ export class MyPlugin extends BaseGridPlugin<MyPluginConfig> {
423
447
  }
424
448
  ```
425
449
 
450
+ ### Inter-Plugin Communication
451
+
452
+ Plugins can communicate with each other using the generic query system. This allows plugins to expose capabilities or constraints without the core knowing about specific plugin concepts.
453
+
454
+ **Responding to queries (in your plugin):**
455
+
456
+ ```typescript
457
+ import { BaseGridPlugin, PLUGIN_QUERIES, PluginQuery } from '@toolbox-web/grid';
458
+
459
+ export class MyPlugin extends BaseGridPlugin<MyConfig> {
460
+ override onPluginQuery(query: PluginQuery): unknown {
461
+ switch (query.type) {
462
+ case PLUGIN_QUERIES.CAN_MOVE_COLUMN:
463
+ // Veto column movement for locked columns
464
+ const column = query.context as ColumnConfig;
465
+ if (this.isLocked(column)) return false;
466
+ return undefined; // Let other plugins decide
467
+ default:
468
+ return undefined;
469
+ }
470
+ }
471
+ }
472
+ ```
473
+
474
+ **Querying other plugins:**
475
+
476
+ ```typescript
477
+ import { PLUGIN_QUERIES } from '@toolbox-web/grid';
478
+
479
+ // In your plugin or application code
480
+ const responses = grid.queryPlugins<boolean>({
481
+ type: PLUGIN_QUERIES.CAN_MOVE_COLUMN,
482
+ context: column,
483
+ });
484
+ const canMove = !responses.includes(false);
485
+ ```
486
+
487
+ **Built-in query types:**
488
+
489
+ | Query Type | Context | Response | Description |
490
+ | ------------------------ | ------------------- | ------------------- | ------------------------------- |
491
+ | `CAN_MOVE_COLUMN` | `ColumnConfig` | `boolean` | Can the column be reordered? |
492
+ | `GET_CONTEXT_MENU_ITEMS` | `ContextMenuParams` | `ContextMenuItem[]` | Get menu items for context menu |
493
+
494
+ Plugins can also define custom query types for their own inter-plugin communication.
495
+
426
496
  ### Accessing Plugin Instances
427
497
 
428
498
  Use `grid.getPlugin()` to get a plugin instance for inter-plugin communication or API access: