@toolbox-web/grid 0.2.5 → 0.2.7

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 (71) hide show
  1. package/all.d.ts +486 -80
  2. package/all.js +1364 -1029
  3. package/all.js.map +1 -1
  4. package/index-DG2CZ_Zo.js +3229 -0
  5. package/index-DG2CZ_Zo.js.map +1 -0
  6. package/index.d.ts +222 -11
  7. package/index.js +25 -3143
  8. package/index.js.map +1 -1
  9. package/lib/plugins/clipboard/index.js +1 -1
  10. package/lib/plugins/clipboard/index.js.map +1 -1
  11. package/lib/plugins/column-virtualization/index.js +1 -1
  12. package/lib/plugins/column-virtualization/index.js.map +1 -1
  13. package/lib/plugins/context-menu/index.js +1 -1
  14. package/lib/plugins/context-menu/index.js.map +1 -1
  15. package/lib/plugins/export/index.js +1 -1
  16. package/lib/plugins/export/index.js.map +1 -1
  17. package/lib/plugins/filtering/index.js +184 -149
  18. package/lib/plugins/filtering/index.js.map +1 -1
  19. package/lib/plugins/grouping-columns/index.js +46 -45
  20. package/lib/plugins/grouping-columns/index.js.map +1 -1
  21. package/lib/plugins/grouping-rows/index.js +117 -83
  22. package/lib/plugins/grouping-rows/index.js.map +1 -1
  23. package/lib/plugins/master-detail/index.js +140 -82
  24. package/lib/plugins/master-detail/index.js.map +1 -1
  25. package/lib/plugins/multi-sort/index.js +18 -18
  26. package/lib/plugins/multi-sort/index.js.map +1 -1
  27. package/lib/plugins/pinned-columns/index.js +1 -1
  28. package/lib/plugins/pinned-columns/index.js.map +1 -1
  29. package/lib/plugins/pinned-rows/index.js +55 -47
  30. package/lib/plugins/pinned-rows/index.js.map +1 -1
  31. package/lib/plugins/pivot/index.js +385 -351
  32. package/lib/plugins/pivot/index.js.map +1 -1
  33. package/lib/plugins/reorder/index.js +278 -85
  34. package/lib/plugins/reorder/index.js.map +1 -1
  35. package/lib/plugins/selection/index.js +28 -27
  36. package/lib/plugins/selection/index.js.map +1 -1
  37. package/lib/plugins/server-side/index.js +2 -2
  38. package/lib/plugins/server-side/index.js.map +1 -1
  39. package/lib/plugins/tree/index.js +181 -170
  40. package/lib/plugins/tree/index.js.map +1 -1
  41. package/lib/plugins/undo-redo/index.js +1 -1
  42. package/lib/plugins/undo-redo/index.js.map +1 -1
  43. package/lib/plugins/visibility/index.js +1 -1
  44. package/lib/plugins/visibility/index.js.map +1 -1
  45. package/package.json +1 -1
  46. package/umd/grid.all.umd.js +22 -22
  47. package/umd/grid.all.umd.js.map +1 -1
  48. package/umd/grid.umd.js +12 -12
  49. package/umd/grid.umd.js.map +1 -1
  50. package/umd/plugins/filtering.umd.js +1 -1
  51. package/umd/plugins/filtering.umd.js.map +1 -1
  52. package/umd/plugins/grouping-columns.umd.js +1 -1
  53. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  54. package/umd/plugins/grouping-rows.umd.js +1 -1
  55. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  56. package/umd/plugins/master-detail.umd.js +1 -1
  57. package/umd/plugins/master-detail.umd.js.map +1 -1
  58. package/umd/plugins/multi-sort.umd.js +1 -1
  59. package/umd/plugins/multi-sort.umd.js.map +1 -1
  60. package/umd/plugins/pinned-rows.umd.js +1 -1
  61. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  62. package/umd/plugins/pivot.umd.js +1 -1
  63. package/umd/plugins/pivot.umd.js.map +1 -1
  64. package/umd/plugins/reorder.umd.js +1 -1
  65. package/umd/plugins/reorder.umd.js.map +1 -1
  66. package/umd/plugins/selection.umd.js +1 -1
  67. package/umd/plugins/selection.umd.js.map +1 -1
  68. package/umd/plugins/server-side.umd.js +1 -1
  69. package/umd/plugins/server-side.umd.js.map +1 -1
  70. package/umd/plugins/tree.umd.js +1 -1
  71. package/umd/plugins/tree.umd.js.map +1 -1
package/index.d.ts CHANGED
@@ -61,6 +61,48 @@ export declare const aggregatorRegistry: {
61
61
  list(): string[];
62
62
  };
63
63
 
64
+ /**
65
+ * Grid-wide animation configuration.
66
+ * Controls global animation behavior - individual plugins define their own animation styles.
67
+ * Duration and easing values set corresponding CSS variables on the grid element.
68
+ */
69
+ export declare interface AnimationConfig {
70
+ /**
71
+ * Global animation mode.
72
+ * @default 'reduced-motion'
73
+ */
74
+ mode?: AnimationMode;
75
+ /**
76
+ * Default animation duration in milliseconds.
77
+ * Sets `--tbw-animation-duration` CSS variable.
78
+ * @default 200
79
+ */
80
+ duration?: number;
81
+ /**
82
+ * Default easing function.
83
+ * Sets `--tbw-animation-easing` CSS variable.
84
+ * @default 'ease-out'
85
+ */
86
+ easing?: string;
87
+ }
88
+
89
+ /**
90
+ * Animation behavior mode.
91
+ * - `true` or `'on'`: Animations always enabled
92
+ * - `false` or `'off'`: Animations always disabled
93
+ * - `'reduced-motion'`: Respects `prefers-reduced-motion` media query (default)
94
+ */
95
+ export declare type AnimationMode = boolean | 'on' | 'off' | 'reduced-motion';
96
+
97
+ /**
98
+ * Animation style for visual transitions.
99
+ * - `'slide'`: Slide/transform animation (e.g., expand down, slide left/right)
100
+ * - `'fade'`: Opacity fade animation
101
+ * - `'flip'`: FLIP technique for position changes (First, Last, Invert, Play)
102
+ * - `false`: No animation for this specific feature
103
+ */
104
+ export declare type AnimationStyle = 'slide' | 'fade' | 'flip' | false;
105
+
64
106
  /**
65
107
  * Base contract for a column. Public; kept intentionally lean so host apps can extend via intersection types.
66
108
  * Prefer adding optional properties here only when broadly useful to most grids.
@@ -125,7 +167,7 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> implements GridP
125
167
  /** Plugin configuration - merged with defaults in attach() */
126
168
  protected config: TConfig;
127
169
  /** User-provided configuration from constructor */
128
- private readonly userConfig;
170
+ protected readonly userConfig: Partial<TConfig>;
129
171
  /**
130
172
  * Default configuration - subclasses should override this getter.
131
173
  * Note: This must be a getter (not property initializer) for proper inheritance
@@ -697,6 +739,12 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> implements GridP
697
739
  getHeaderContent?(): HeaderContentDefinition | undefined;
698
740
  }
699
741
 
742
+ /**
743
+ * Built-in sort implementation using column comparator or default.
744
+ * This is the default sortHandler when none is configured.
745
+ */
746
+ export declare function builtInSort<T>(rows: T[], sortState: SortState, columns: ColumnConfig<T>[]): T[];
747
+
700
748
  /**
701
749
  * Cell click event
702
750
  */
@@ -1047,6 +1095,11 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
1047
1095
  * Returns true if any plugin handled the event.
1048
1096
  */
1049
1097
  _dispatchCellClick(event: MouseEvent, rowIndex: number, colIndex: number, cellEl: HTMLElement): boolean;
1098
+ /**
1099
+ * Dispatch a row click event to the plugin system.
1100
+ * Returns true if any plugin handled the event.
1101
+ */
1102
+ _dispatchRowClick(event: MouseEvent, rowIndex: number, row: any, rowEl: HTMLElement): boolean;
1050
1103
  /**
1051
1104
  * Dispatch a header click event to the plugin system.
1052
1105
  * Returns true if any plugin handled the event.
@@ -1206,9 +1259,18 @@ export declare interface DataGridEventMap<TRow = unknown> {
1206
1259
  'column-state-change': GridColumnState;
1207
1260
  }
1208
1261
 
1262
+ /** Default animation configuration */
1263
+ export declare const DEFAULT_ANIMATION_CONFIG: Required<Omit<AnimationConfig, 'sort'>>;
1264
+
1209
1265
  /** Default icons used when not overridden */
1210
1266
  export declare const DEFAULT_GRID_ICONS: Required<GridIcons>;
1211
1267
 
1268
+ /**
1269
+ * Default comparator for sorting values.
1270
+ * Handles nulls (pushed to end), numbers, and string fallback.
1271
+ */
1272
+ export declare function defaultComparator(a: unknown, b: unknown): number;
1273
+
1212
1274
  export declare type DGEventName = (typeof DGEvents)[keyof typeof DGEvents];
1213
1275
 
1214
1276
  export declare const DGEvents: {
@@ -1248,6 +1310,20 @@ declare interface EditorExecContext<T = any> extends CellContext<T> {
1248
1310
  cancel: () => void;
1249
1311
  }
1250
1312
 
1313
+ /**
1314
+ * Tree Data Plugin Types
1315
+ *
1316
+ * Type definitions for hierarchical tree data with expand/collapse functionality.
1317
+ */
1318
+ /** Animation style for expand/collapse */
1319
+ declare type ExpandCollapseAnimation = false | 'slide' | 'fade';
1320
+
1321
+ /** Animation style for expand/collapse */
1322
+ declare type ExpandCollapseAnimation_2 = false | 'slide' | 'fade';
1323
+
1324
+ /** Animation style for expand/collapse */
1325
+ declare type ExpandCollapseAnimation_3 = false | 'slide' | 'fade';
1326
+
1251
1327
  /**
1252
1328
  * Export Plugin Types
1253
1329
  *
@@ -1299,7 +1375,7 @@ export declare interface ExternalMountViewDetail<TRow = unknown> {
1299
1375
  }
1300
1376
 
1301
1377
  /** Configuration options for the filtering plugin */
1302
- export declare interface FilterConfig {
1378
+ export declare interface FilterConfig<TRow = unknown> {
1303
1379
  /** Debounce delay in ms for filter input (default: 300) */
1304
1380
  debounceMs?: number;
1305
1381
  /** Whether text filtering is case sensitive (default: false) */
@@ -1310,8 +1386,46 @@ export declare interface FilterConfig {
1310
1386
  useWorker?: boolean;
1311
1387
  /** Custom filter panel renderer (replaces default panel content) */
1312
1388
  filterPanelRenderer?: FilterPanelRenderer;
1389
+ /**
1390
+ * Async handler for fetching unique values from a server.
1391
+ * When provided, this is called instead of extracting values from local rows.
1392
+ * Useful for server-side datasets where not all data is loaded.
1393
+ */
1394
+ valuesHandler?: FilterValuesHandler;
1395
+ /**
1396
+ * Async handler for applying filters on a server.
1397
+ * When provided, filtering is delegated to the server instead of local filtering.
1398
+ * Should return the filtered rows from the server.
1399
+ *
1400
+ * Note: When using filterHandler, processRows() becomes a passthrough
1401
+ * and the returned rows replace the grid's data.
1402
+ */
1403
+ filterHandler?: FilterHandler<TRow>;
1313
1404
  }
1314
1405
 
1406
+ /**
1407
+ * Async handler for applying filters on a server.
1408
+ *
1409
+ * For server-side filtering, this handler is called when filters change.
1410
+ * It should fetch filtered data from the server and return the new rows.
1411
+ * The plugin will replace the grid's rows with the returned data.
1412
+ *
1413
+ * @param filters - Current active filter models
1414
+ * @param currentRows - Current row array (for reference/optimistic updates)
1415
+ * @returns Promise resolving to filtered rows
1416
+ *
1417
+ * @example
1418
+ * ```ts
1419
+ * filterHandler: async (filters) => {
1420
+ * const params = new URLSearchParams();
1421
+ * filters.forEach(f => params.append(f.field, `${f.operator}:${f.value}`));
1422
+ * const response = await fetch(`/api/data?${params}`);
1423
+ * return response.json();
1424
+ * }
1425
+ * ```
1426
+ */
1427
+ export declare type FilterHandler<TRow = unknown> = (filters: FilterModel[], currentRows: TRow[]) => TRow[] | Promise<TRow[]>;
1428
+
1315
1429
  /** Filter model representing a single filter condition */
1316
1430
  export declare interface FilterModel {
1317
1431
  /** The field/column to filter on */
@@ -1357,6 +1471,27 @@ declare type FilterPanelRenderer = (container: HTMLElement, params: FilterPanelP
1357
1471
  /** Supported filter types */
1358
1472
  export declare type FilterType = 'text' | 'number' | 'date' | 'set' | 'boolean';
1359
1473
 
1474
+ /**
1475
+ * Async handler for fetching unique filter values from a server.
1476
+ *
1477
+ * For server-side datasets where not all values are available locally,
1478
+ * this handler is called when the filter panel opens to fetch all
1479
+ * possible values for the column.
1480
+ *
1481
+ * @param field - The field/column name
1482
+ * @param column - The column configuration
1483
+ * @returns Promise resolving to array of unique values
1484
+ *
1485
+ * @example
1486
+ * ```ts
1487
+ * valuesHandler: async (field, column) => {
1488
+ * const response = await fetch(`/api/distinct/${field}`);
1489
+ * return response.json(); // ['Engineering', 'Marketing', 'Sales', ...]
1490
+ * }
1491
+ * ```
1492
+ */
1493
+ export declare type FilterValuesHandler = (field: string, column: ColumnConfig) => Promise<unknown[]>;
1494
+
1360
1495
  export declare type FitMode = (typeof FitModeEnum)[keyof typeof FitModeEnum];
1361
1496
 
1362
1497
  export declare const FitModeEnum: {
@@ -1534,6 +1669,41 @@ export declare interface GridConfig<TRow = any> {
1534
1669
  * Plugins will use these by default but can override with their own config.
1535
1670
  */
1536
1671
  icons?: GridIcons;
1672
+ /**
1673
+ * Grid-wide animation configuration.
1674
+ * Controls animations for expand/collapse, reordering, and other visual transitions.
1675
+ * Individual plugins can override these defaults in their own config.
1676
+ */
1677
+ animation?: AnimationConfig;
1678
+ /**
1679
+ * Custom sort handler for full control over sorting behavior.
1680
+ *
1681
+ * When provided, this handler is called instead of the built-in sorting logic.
1682
+ * Enables custom sorting algorithms, server-side sorting, or plugin-specific sorting.
1683
+ *
1684
+ * The handler receives:
1685
+ * - `rows`: Current row array to sort
1686
+ * - `sortState`: Sort field and direction (1 = asc, -1 = desc)
1687
+ * - `columns`: Column configurations (for accessing sortComparator)
1688
+ *
1689
+ * Return the sorted array (sync) or a Promise that resolves to the sorted array (async).
1690
+ * For server-side sorting, return a Promise that resolves when data is fetched.
1691
+ *
1692
+ * @example
1693
+ * ```ts
1694
+ * // Custom stable sort
1695
+ * sortHandler: (rows, state, cols) => {
1696
+ * return stableSort(rows, (a, b) => compare(a[state.field], b[state.field]) * state.direction);
1697
+ * }
1698
+ *
1699
+ * // Server-side sorting
1700
+ * sortHandler: async (rows, state) => {
1701
+ * const response = await fetch(`/api/data?sort=${state.field}&dir=${state.direction}`);
1702
+ * return response.json();
1703
+ * }
1704
+ * ```
1705
+ */
1706
+ sortHandler?: SortHandler<TRow>;
1537
1707
  }
1538
1708
 
1539
1709
  export declare type GridCSSVar = (typeof GridCSSVars)[keyof typeof GridCSSVars];
@@ -1582,10 +1752,8 @@ export declare interface GridElement {
1582
1752
  rows: any[];
1583
1753
  columns: ColumnConfig[];
1584
1754
  gridConfig: any;
1585
- /** Current focused row index */
1586
- focusRow: number;
1587
- /** Current focused column index */
1588
- focusCol: number;
1755
+ /* Excluded from this release type: _focusRow */
1756
+ /* Excluded from this release type: _focusCol */
1589
1757
  /** AbortSignal that is aborted when the grid disconnects from the DOM */
1590
1758
  disconnectSignal: AbortSignal;
1591
1759
  requestRender(): void;
@@ -1675,6 +1843,14 @@ export declare interface GroupingRowsConfig {
1675
1843
  formatLabel?: (value: any, depth: number, key: string) => string;
1676
1844
  /** Whether to render group row as full-width spanning cell (default: true) */
1677
1845
  fullWidth?: boolean;
1846
+ /**
1847
+ * Animation style for expanding/collapsing groups.
1848
+ * - `false`: No animation
1849
+ * - `'slide'`: Slide animation (default)
1850
+ * - `'fade'`: Fade animation
1851
+ * @default 'slide'
1852
+ */
1853
+ animation?: ExpandCollapseAnimation_3;
1678
1854
  }
1679
1855
 
1680
1856
  /** Parameters passed to custom group row renderer */
@@ -1772,6 +1948,8 @@ declare interface InternalGrid<T = any> extends PublicGrid<T>, GridConfig<T> {
1772
1948
  commitActiveRowEdit?: () => void;
1773
1949
  /** Dispatch cell click to plugin system, returns true if handled */
1774
1950
  _dispatchCellClick?: (event: MouseEvent, rowIndex: number, colIndex: number, cellEl: HTMLElement) => boolean;
1951
+ /** Dispatch row click to plugin system, returns true if handled */
1952
+ _dispatchRowClick?: (event: MouseEvent, rowIndex: number, row: any, rowEl: HTMLElement) => boolean;
1775
1953
  /** Dispatch header click to plugin system, returns true if handled */
1776
1954
  _dispatchHeaderClick?: (event: MouseEvent, colIndex: number, headerEl: HTMLElement) => boolean;
1777
1955
  /** Dispatch keydown to plugin system, returns true if handled */
@@ -1846,6 +2024,16 @@ export declare interface PivotConfig {
1846
2024
  defaultExpanded?: boolean;
1847
2025
  /** Indent width per depth level in pixels (default: 20) */
1848
2026
  indentWidth?: number;
2027
+ /** Whether to show the pivot configuration tool panel (default: true) */
2028
+ showToolPanel?: boolean;
2029
+ /**
2030
+ * Animation style for expanding/collapsing groups.
2031
+ * - `false`: No animation
2032
+ * - `'slide'`: Slide animation (default)
2033
+ * - `'fade'`: Fade animation
2034
+ * @default 'slide'
2035
+ */
2036
+ animation?: ExpandCollapseAnimation_2;
1849
2037
  }
1850
2038
 
1851
2039
  export declare interface PivotResult {
@@ -2320,6 +2508,16 @@ export declare interface SortChangeDetail {
2320
2508
  direction: 1 | -1 | 0;
2321
2509
  }
2322
2510
 
2511
+ /**
2512
+ * Custom sort handler function signature.
2513
+ *
2514
+ * @param rows - Current row array to sort
2515
+ * @param sortState - Sort field and direction
2516
+ * @param columns - Column configurations (for accessing sortComparator)
2517
+ * @returns Sorted array (sync) or Promise resolving to sorted array (async)
2518
+ */
2519
+ export declare type SortHandler<TRow = any> = (rows: TRow[], sortState: SortState, columns: ColumnConfig<TRow>[]) => TRow[] | Promise<TRow[]>;
2520
+
2323
2521
  /**
2324
2522
  * Multi-Sort Plugin Types
2325
2523
  *
@@ -2333,6 +2531,16 @@ export declare interface SortModel {
2333
2531
  direction: 'asc' | 'desc';
2334
2532
  }
2335
2533
 
2534
+ /**
2535
+ * Sort state passed to custom sort handlers.
2536
+ */
2537
+ export declare interface SortState {
2538
+ /** Field to sort by */
2539
+ field: string;
2540
+ /** Sort direction: 1 = ascending, -1 = descending */
2541
+ direction: 1 | -1;
2542
+ }
2543
+
2336
2544
  /**
2337
2545
  * Toolbar button defined via config (programmatic approach).
2338
2546
  * Supports three modes:
@@ -2413,11 +2621,6 @@ export declare interface ToolPanelDefinition {
2413
2621
  order?: number;
2414
2622
  }
2415
2623
 
2416
- /**
2417
- * Tree Data Plugin Types
2418
- *
2419
- * Type definitions for hierarchical tree data with expand/collapse functionality.
2420
- */
2421
2624
  /** Configuration options for the tree plugin */
2422
2625
  export declare interface TreeConfig {
2423
2626
  /** Field name containing child rows (default: 'children') */
@@ -2430,6 +2633,14 @@ export declare interface TreeConfig {
2430
2633
  indentWidth?: number;
2431
2634
  /** Show expand/collapse icons (default: true) */
2432
2635
  showExpandIcons?: boolean;
2636
+ /**
2637
+ * Animation style for expanding/collapsing tree nodes.
2638
+ * - `false`: No animation
2639
+ * - `'slide'`: Slide animation (default)
2640
+ * - `'fade'`: Fade animation
2641
+ * @default 'slide'
2642
+ */
2643
+ animation?: ExpandCollapseAnimation;
2433
2644
  }
2434
2645
 
2435
2646
  /** Event detail emitted when a tree node is expanded or collapsed */