@toolbox-web/grid 1.28.2 → 1.30.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.
Files changed (107) hide show
  1. package/all.js +2 -2
  2. package/all.js.map +1 -1
  3. package/custom-elements.json +43 -1
  4. package/index.js +1 -1
  5. package/index.js.map +1 -1
  6. package/lib/core/constants.d.ts +1 -7
  7. package/lib/core/grid.d.ts +47 -3
  8. package/lib/core/internal/render-scheduler.d.ts +3 -1
  9. package/lib/core/plugin/base-plugin.d.ts +1 -1
  10. package/lib/core/plugin/plugin-manager.d.ts +2 -0
  11. package/lib/core/types.d.ts +55 -0
  12. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +0 -21
  13. package/lib/plugins/clipboard/index.js.map +1 -1
  14. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +0 -16
  15. package/lib/plugins/column-virtualization/index.js.map +1 -1
  16. package/lib/plugins/context-menu/index.js.map +1 -1
  17. package/lib/plugins/editing/index.js +1 -1
  18. package/lib/plugins/editing/index.js.map +1 -1
  19. package/lib/plugins/export/ExportPlugin.d.ts +0 -18
  20. package/lib/plugins/export/index.js.map +1 -1
  21. package/lib/plugins/filtering/FilteringPlugin.d.ts +0 -21
  22. package/lib/plugins/filtering/filter-model.d.ts +8 -1
  23. package/lib/plugins/filtering/index.js +1 -1
  24. package/lib/plugins/filtering/index.js.map +1 -1
  25. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +0 -16
  26. package/lib/plugins/grouping-columns/grouping-columns.d.ts +23 -3
  27. package/lib/plugins/grouping-columns/index.js +1 -1
  28. package/lib/plugins/grouping-columns/index.js.map +1 -1
  29. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +0 -23
  30. package/lib/plugins/grouping-rows/index.js +2 -2
  31. package/lib/plugins/grouping-rows/index.js.map +1 -1
  32. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +0 -22
  33. package/lib/plugins/master-detail/index.js.map +1 -1
  34. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +0 -18
  35. package/lib/plugins/multi-sort/index.js +1 -1
  36. package/lib/plugins/multi-sort/index.js.map +1 -1
  37. package/lib/plugins/multi-sort/multi-sort.d.ts +7 -0
  38. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +18 -4
  39. package/lib/plugins/pinned-columns/index.js +1 -1
  40. package/lib/plugins/pinned-columns/index.js.map +1 -1
  41. package/lib/plugins/pinned-columns/pinned-columns.d.ts +38 -2
  42. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +0 -11
  43. package/lib/plugins/pinned-rows/index.js.map +1 -1
  44. package/lib/plugins/pivot/PivotPlugin.d.ts +0 -24
  45. package/lib/plugins/pivot/index.js +1 -1
  46. package/lib/plugins/pivot/index.js.map +1 -1
  47. package/lib/plugins/print/PrintPlugin.d.ts +2 -21
  48. package/lib/plugins/print/index.js.map +1 -1
  49. package/lib/plugins/reorder-columns/ReorderPlugin.d.ts +0 -7
  50. package/lib/plugins/reorder-columns/index.js +1 -1
  51. package/lib/plugins/reorder-columns/index.js.map +1 -1
  52. package/lib/plugins/reorder-rows/RowReorderPlugin.d.ts +1 -13
  53. package/lib/plugins/reorder-rows/index.js +1 -1
  54. package/lib/plugins/reorder-rows/index.js.map +1 -1
  55. package/lib/plugins/responsive/index.js +1 -1
  56. package/lib/plugins/responsive/index.js.map +1 -1
  57. package/lib/plugins/selection/index.js +1 -1
  58. package/lib/plugins/selection/index.js.map +1 -1
  59. package/lib/plugins/server-side/ServerSidePlugin.d.ts +0 -16
  60. package/lib/plugins/server-side/index.js.map +1 -1
  61. package/lib/plugins/tooltip/index.js.map +1 -1
  62. package/lib/plugins/tree/TreePlugin.d.ts +0 -22
  63. package/lib/plugins/tree/index.js +1 -1
  64. package/lib/plugins/tree/index.js.map +1 -1
  65. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +0 -19
  66. package/lib/plugins/undo-redo/index.js +1 -1
  67. package/lib/plugins/undo-redo/index.js.map +1 -1
  68. package/lib/plugins/visibility/VisibilityPlugin.d.ts +0 -16
  69. package/lib/plugins/visibility/index.js +1 -1
  70. package/lib/plugins/visibility/index.js.map +1 -1
  71. package/package.json +1 -1
  72. package/themes/dg-theme-material.css +5 -0
  73. package/umd/grid.all.umd.js +1 -1
  74. package/umd/grid.all.umd.js.map +1 -1
  75. package/umd/grid.umd.js +1 -1
  76. package/umd/grid.umd.js.map +1 -1
  77. package/umd/plugins/clipboard.umd.js.map +1 -1
  78. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  79. package/umd/plugins/export.umd.js.map +1 -1
  80. package/umd/plugins/filtering.umd.js +1 -1
  81. package/umd/plugins/filtering.umd.js.map +1 -1
  82. package/umd/plugins/grouping-columns.umd.js +1 -1
  83. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  84. package/umd/plugins/grouping-rows.umd.js +1 -1
  85. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  86. package/umd/plugins/master-detail.umd.js.map +1 -1
  87. package/umd/plugins/multi-sort.umd.js +1 -1
  88. package/umd/plugins/multi-sort.umd.js.map +1 -1
  89. package/umd/plugins/pinned-columns.umd.js +1 -1
  90. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  91. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  92. package/umd/plugins/pivot.umd.js +1 -1
  93. package/umd/plugins/pivot.umd.js.map +1 -1
  94. package/umd/plugins/print.umd.js.map +1 -1
  95. package/umd/plugins/reorder-columns.umd.js +1 -1
  96. package/umd/plugins/reorder-columns.umd.js.map +1 -1
  97. package/umd/plugins/reorder-rows.umd.js +1 -1
  98. package/umd/plugins/reorder-rows.umd.js.map +1 -1
  99. package/umd/plugins/selection.umd.js +1 -1
  100. package/umd/plugins/selection.umd.js.map +1 -1
  101. package/umd/plugins/server-side.umd.js.map +1 -1
  102. package/umd/plugins/tree.umd.js +1 -1
  103. package/umd/plugins/tree.umd.js.map +1 -1
  104. package/umd/plugins/undo-redo.umd.js +1 -1
  105. package/umd/plugins/undo-redo.umd.js.map +1 -1
  106. package/umd/plugins/visibility.umd.js +1 -1
  107. package/umd/plugins/visibility.umd.js.map +1 -1
@@ -12,7 +12,7 @@
12
12
  * See each plugin's index.ts for plugin-specific exports.
13
13
  */
14
14
  /**
15
- * CSS class names used in the grid's shadow DOM.
15
+ * CSS class names used in the grid's DOM.
16
16
  * Use these when adding/removing classes or querying elements.
17
17
  *
18
18
  * Classes are organized by:
@@ -62,12 +62,8 @@ export declare const GridClasses: {
62
62
  * @category Plugin Development
63
63
  */
64
64
  export declare const GridDataAttrs: {
65
- readonly ROW_INDEX: "data-row-index";
66
- readonly COL_INDEX: "data-col-index";
67
65
  readonly FIELD: "data-field";
68
66
  readonly GROUP_KEY: "data-group-key";
69
- readonly TREE_LEVEL: "data-tree-level";
70
- readonly STICKY: "data-sticky";
71
67
  };
72
68
  /**
73
69
  * Common CSS selectors for querying grid elements.
@@ -85,9 +81,7 @@ export declare const GridSelectors: {
85
81
  readonly DATA_ROW: ".data-row";
86
82
  readonly DATA_CELL: ".data-cell";
87
83
  readonly GROUP_ROW: ".group-row";
88
- readonly ROW_BY_INDEX: (index: number) => string;
89
84
  readonly CELL_BY_FIELD: (field: string) => string;
90
- readonly CELL_AT: (row: number, col: number) => string;
91
85
  readonly SELECTED_ROWS: ".data-row.selected";
92
86
  readonly EDITING_CELL: ".data-cell.editing";
93
87
  };
@@ -52,6 +52,13 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
52
52
  get _columns(): ColumnInternal<T>[];
53
53
  set _columns(value: ColumnInternal<T>[]);
54
54
  get _visibleColumns(): ColumnInternal<T>[];
55
+ /**
56
+ * Clear the cached _visibleColumns so the next access recomputes from _columns.
57
+ * Called by ConfigManager when it mutates effectiveConfig.columns directly
58
+ * (bypassing the _columns setter which normally handles invalidation).
59
+ * @internal
60
+ */
61
+ _invalidateVisibleColumnsCache(): void;
55
62
  _headerRowEl: HTMLElement;
56
63
  _bodyEl: HTMLElement;
57
64
  _rowPool: RowElementInternal[];
@@ -551,7 +558,7 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
551
558
  /** @internal Apply animation configuration to host element. */
552
559
  _applyAnimationConfig(config: GridConfig<T>): void;
553
560
  /**
554
- * Find the header row element in the shadow DOM.
561
+ * Find the header row element.
555
562
  * Used by plugins that need to access header cells for styling or measurement.
556
563
  * @group DOM Access
557
564
  * @internal Plugin API
@@ -1272,6 +1279,43 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
1272
1279
  * @group State Persistence
1273
1280
  */
1274
1281
  get columnState(): GridColumnState | undefined;
1282
+ /**
1283
+ * Get the current single-column sort state.
1284
+ *
1285
+ * Returns `null` when no sort is active.
1286
+ *
1287
+ * @group Sorting
1288
+ *
1289
+ * @example
1290
+ * ```typescript
1291
+ * const sort = grid.sortModel;
1292
+ * // { field: 'name', direction: 'desc' } | null
1293
+ * ```
1294
+ */
1295
+ get sortModel(): {
1296
+ field: string;
1297
+ direction: 'asc' | 'desc';
1298
+ } | null;
1299
+ /**
1300
+ * Sort by a column, toggle a column's sort direction, or clear sorting.
1301
+ *
1302
+ * - `sort('id', 'desc')` — apply sort with explicit direction
1303
+ * - `sort('id')` — toggle: none → asc → desc → none
1304
+ * - `sort(null)` — clear sort, restore original row order
1305
+ *
1306
+ * @param field - Column field to sort by, or `null` to clear
1307
+ * @param direction - Explicit direction; omit to toggle
1308
+ *
1309
+ * @group Sorting
1310
+ *
1311
+ * @example
1312
+ * ```typescript
1313
+ * grid.sort('id', 'desc'); // sort descending
1314
+ * grid.sort('price'); // toggle sort on price
1315
+ * grid.sort(null); // clear sort
1316
+ * ```
1317
+ */
1318
+ sort(field: string | null, direction?: 'asc' | 'desc'): void;
1275
1319
  /**
1276
1320
  * Request a state change event to be emitted.
1277
1321
  * Called internally after resize, reorder, visibility, or sort changes.
@@ -1600,10 +1644,10 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
1600
1644
  */
1601
1645
  refreshShellHeader(): void;
1602
1646
  /**
1603
- * Register custom CSS styles to be injected into the grid's shadow DOM.
1647
+ * Register custom CSS styles via `document.adoptedStyleSheets`.
1604
1648
  * Use this to style custom cell renderers, editors, or detail panels.
1605
1649
  *
1606
- * Uses adoptedStyleSheets for efficiency - styles survive shadow DOM rebuilds.
1650
+ * Uses adoptedStyleSheets for efficiency - styles survive DOM rebuilds.
1607
1651
  *
1608
1652
  * @group Custom Styles
1609
1653
  * @param id - Unique identifier for the style block (for removal/updates)
@@ -56,7 +56,9 @@ export declare class RenderScheduler {
56
56
  */
57
57
  get isPending(): boolean;
58
58
  /**
59
- * Get the current pending phase (0 if none).
59
+ * The current pending phase (0 if nothing is pending).
60
+ * Used by `forceLayout()` to flush at the correct phase
61
+ * without unnecessarily escalating to FULL.
60
62
  */
61
63
  get pendingPhase(): RenderPhase | 0;
62
64
  }
@@ -334,7 +334,7 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> implements GridP
334
334
  * Third-party plugins can override with their own semver.
335
335
  */
336
336
  readonly version: string;
337
- /** CSS styles to inject into the grid's shadow DOM */
337
+ /** CSS styles to inject via `document.adoptedStyleSheets` */
338
338
  readonly styles?: string;
339
339
  /** Custom cell renderers keyed by type name */
340
340
  readonly cellRenderers?: Record<string, CellRenderer>;
@@ -24,6 +24,7 @@ export declare class PluginManager {
24
24
  /** Cached hook presence flags — invalidated on plugin attach/detach */
25
25
  private _hasAfterCellRender;
26
26
  private _hasAfterRowRender;
27
+ private _hasProcessRows;
27
28
  /**
28
29
  * Event listeners indexed by event type.
29
30
  * Maps event type → Map<plugin instance → callback>.
@@ -108,6 +109,7 @@ export declare class PluginManager {
108
109
  }>;
109
110
  /**
110
111
  * Execute processRows hook on all plugins.
112
+ * Returns a mutable copy only when at least one plugin transforms rows.
111
113
  */
112
114
  processRows(rows: readonly any[]): any[];
113
115
  /**
@@ -232,6 +232,39 @@ export interface PublicGrid<T = any> {
232
232
  * ```
233
233
  */
234
234
  columnState?: GridColumnState;
235
+ /**
236
+ * Get the current sort state.
237
+ *
238
+ * Returns `null` when no sort is active.
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * const sort = grid.sortModel;
243
+ * // { field: 'id', direction: 'desc' } | null
244
+ * ```
245
+ */
246
+ readonly sortModel?: {
247
+ field: string;
248
+ direction: 'asc' | 'desc';
249
+ } | null;
250
+ /**
251
+ * Sort by a column, toggle a column's sort direction, or clear sorting.
252
+ *
253
+ * - `sort('id', 'desc')` — apply sort with explicit direction
254
+ * - `sort('id')` — toggle: none → asc → desc → none
255
+ * - `sort(null)` — clear sort, restore original row order
256
+ *
257
+ * @param field - Column field to sort by, or `null` to clear
258
+ * @param direction - Explicit direction; omit to toggle
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * grid.sort('id', 'desc'); // sort descending
263
+ * grid.sort('price'); // toggle sort on price
264
+ * grid.sort(null); // clear sort
265
+ * ```
266
+ */
267
+ sort?(field: string | null, direction?: 'asc' | 'desc'): void;
235
268
  /**
236
269
  * Whether the grid is currently in a loading state.
237
270
  * When true, displays a loading overlay with spinner.
@@ -506,6 +539,8 @@ export interface InternalGrid<T = any> extends PublicGrid<T>, GridConfig<T> {
506
539
  queryPlugins?: <T>(query: PluginQuery) => T[];
507
540
  /** Request emission of column-state-change event (debounced) */
508
541
  requestStateChange?: () => void;
542
+ /** @internal Clear the cached _visibleColumns array so the next read recomputes from _columns. */
543
+ _invalidateVisibleColumnsCache(): void;
509
544
  /** @internal */ _renderVisibleRows(start: number, end: number, epoch?: number): void;
510
545
  /** @internal */ _updateAriaCounts(totalRows: number, totalCols: number): void;
511
546
  /** @internal */ _requestSchedulerPhase(phase: number, source: string): void;
@@ -2159,6 +2194,26 @@ export interface GridConfig<TRow = any> {
2159
2194
  * ```
2160
2195
  */
2161
2196
  sortHandler?: SortHandler<TRow>;
2197
+ /**
2198
+ * Initial sort state applied when the grid first renders.
2199
+ *
2200
+ * Equivalent to calling `grid.sort(field, direction)` after the grid is created,
2201
+ * but avoids the imperative call and extra render cycle.
2202
+ *
2203
+ * @example
2204
+ * ```ts
2205
+ * gridConfig = {
2206
+ * initialSort: { field: 'salary', direction: 'desc' },
2207
+ * };
2208
+ * ```
2209
+ *
2210
+ * @see {@link DataGrid.sort} for runtime sorting
2211
+ * @see {@link DataGrid.sortModel} for reading current sort state
2212
+ */
2213
+ initialSort?: {
2214
+ field: string;
2215
+ direction: 'asc' | 'desc';
2216
+ };
2162
2217
  /**
2163
2218
  * Function to extract a unique identifier from a row.
2164
2219
  * Used by `updateRow()`, `getRow()`, and ID-based tracking.
@@ -16,17 +16,6 @@ import { ClipboardConfig, CopyOptions } from './types';
16
16
  * import { ClipboardPlugin } from '@toolbox-web/grid/plugins/clipboard';
17
17
  * ```
18
18
  *
19
- * ## Configuration Options
20
- *
21
- * | Option | Type | Default | Description |
22
- * |--------|------|---------|-------------|
23
- * | `includeHeaders` | `boolean` | `false` | Include column headers in copied data |
24
- * | `delimiter` | `string` | `'\t'` | Column delimiter (tab for Excel compatibility) |
25
- * | `newline` | `string` | `'\n'` | Row delimiter |
26
- * | `quoteStrings` | `boolean` | `false` | Wrap string values in quotes |
27
- * | `processCell` | `(value, field, row) => string` | - | Custom cell value processor (overrides copy-what-you-see) |
28
- * | `pasteHandler` | `PasteHandler \| null` | `defaultPasteHandler` | Custom paste handler |
29
- *
30
19
  * ## Keyboard Shortcuts
31
20
  *
32
21
  * | Shortcut | Action |
@@ -44,16 +33,6 @@ import { ClipboardConfig, CopyOptions } from './types';
44
33
  * | Row selection | Paste is clipped to the selected rows |
45
34
  * | No selection | Paste starts at row 0, column 0 |
46
35
  *
47
- * ## Programmatic API
48
- *
49
- * | Method | Signature | Description |
50
- * |--------|-----------|-------------|
51
- * | `copy` | `(options?: CopyOptions) => Promise<string>` | Copy to clipboard with optional column/row control |
52
- * | `copyRows` | `(indices, options?) => Promise<string>` | Copy specific rows to clipboard |
53
- * | `paste` | `() => Promise<string[][] \| null>` | Read and parse clipboard content |
54
- * | `getSelectionAsText` | `(options?: CopyOptions) => string` | Get clipboard text without writing to clipboard |
55
- * | `getLastCopied` | `() => { text, timestamp } \| null` | Get info about last copy operation |
56
- *
57
36
  * @example Basic Usage with Excel Compatibility
58
37
  * ```ts
59
38
  * import '@toolbox-web/grid';