@toolbox-web/grid 0.2.6 → 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 (52) hide show
  1. package/all.d.ts +434 -61
  2. package/all.js +844 -541
  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 +210 -6
  7. package/index.js +25 -3194
  8. package/index.js.map +1 -1
  9. package/lib/plugins/clipboard/index.js.map +1 -1
  10. package/lib/plugins/column-virtualization/index.js.map +1 -1
  11. package/lib/plugins/context-menu/index.js.map +1 -1
  12. package/lib/plugins/export/index.js.map +1 -1
  13. package/lib/plugins/filtering/index.js +183 -148
  14. package/lib/plugins/filtering/index.js.map +1 -1
  15. package/lib/plugins/grouping-columns/index.js.map +1 -1
  16. package/lib/plugins/grouping-rows/index.js +116 -82
  17. package/lib/plugins/grouping-rows/index.js.map +1 -1
  18. package/lib/plugins/master-detail/index.js +139 -81
  19. package/lib/plugins/master-detail/index.js.map +1 -1
  20. package/lib/plugins/multi-sort/index.js +17 -17
  21. package/lib/plugins/multi-sort/index.js.map +1 -1
  22. package/lib/plugins/pinned-columns/index.js.map +1 -1
  23. package/lib/plugins/pinned-rows/index.js.map +1 -1
  24. package/lib/plugins/pivot/index.js +369 -337
  25. package/lib/plugins/pivot/index.js.map +1 -1
  26. package/lib/plugins/reorder/index.js +264 -91
  27. package/lib/plugins/reorder/index.js.map +1 -1
  28. package/lib/plugins/selection/index.js.map +1 -1
  29. package/lib/plugins/server-side/index.js.map +1 -1
  30. package/lib/plugins/tree/index.js +180 -169
  31. package/lib/plugins/tree/index.js.map +1 -1
  32. package/lib/plugins/undo-redo/index.js.map +1 -1
  33. package/lib/plugins/visibility/index.js.map +1 -1
  34. package/package.json +1 -1
  35. package/umd/grid.all.umd.js +21 -21
  36. package/umd/grid.all.umd.js.map +1 -1
  37. package/umd/grid.umd.js +12 -12
  38. package/umd/grid.umd.js.map +1 -1
  39. package/umd/plugins/filtering.umd.js +1 -1
  40. package/umd/plugins/filtering.umd.js.map +1 -1
  41. package/umd/plugins/grouping-rows.umd.js +1 -1
  42. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  43. package/umd/plugins/master-detail.umd.js +1 -1
  44. package/umd/plugins/master-detail.umd.js.map +1 -1
  45. package/umd/plugins/multi-sort.umd.js +1 -1
  46. package/umd/plugins/multi-sort.umd.js.map +1 -1
  47. package/umd/plugins/pivot.umd.js +1 -1
  48. package/umd/plugins/pivot.umd.js.map +1 -1
  49. package/umd/plugins/reorder.umd.js +1 -1
  50. package/umd/plugins/reorder.umd.js.map +1 -1
  51. package/umd/plugins/tree.umd.js +1 -1
  52. 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.
@@ -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
  */
@@ -1211,9 +1259,18 @@ export declare interface DataGridEventMap<TRow = unknown> {
1211
1259
  'column-state-change': GridColumnState;
1212
1260
  }
1213
1261
 
1262
+ /** Default animation configuration */
1263
+ export declare const DEFAULT_ANIMATION_CONFIG: Required<Omit<AnimationConfig, 'sort'>>;
1264
+
1214
1265
  /** Default icons used when not overridden */
1215
1266
  export declare const DEFAULT_GRID_ICONS: Required<GridIcons>;
1216
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
+
1217
1274
  export declare type DGEventName = (typeof DGEvents)[keyof typeof DGEvents];
1218
1275
 
1219
1276
  export declare const DGEvents: {
@@ -1253,6 +1310,20 @@ declare interface EditorExecContext<T = any> extends CellContext<T> {
1253
1310
  cancel: () => void;
1254
1311
  }
1255
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
+
1256
1327
  /**
1257
1328
  * Export Plugin Types
1258
1329
  *
@@ -1304,7 +1375,7 @@ export declare interface ExternalMountViewDetail<TRow = unknown> {
1304
1375
  }
1305
1376
 
1306
1377
  /** Configuration options for the filtering plugin */
1307
- export declare interface FilterConfig {
1378
+ export declare interface FilterConfig<TRow = unknown> {
1308
1379
  /** Debounce delay in ms for filter input (default: 300) */
1309
1380
  debounceMs?: number;
1310
1381
  /** Whether text filtering is case sensitive (default: false) */
@@ -1315,8 +1386,46 @@ export declare interface FilterConfig {
1315
1386
  useWorker?: boolean;
1316
1387
  /** Custom filter panel renderer (replaces default panel content) */
1317
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>;
1318
1404
  }
1319
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
+
1320
1429
  /** Filter model representing a single filter condition */
1321
1430
  export declare interface FilterModel {
1322
1431
  /** The field/column to filter on */
@@ -1362,6 +1471,27 @@ declare type FilterPanelRenderer = (container: HTMLElement, params: FilterPanelP
1362
1471
  /** Supported filter types */
1363
1472
  export declare type FilterType = 'text' | 'number' | 'date' | 'set' | 'boolean';
1364
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
+
1365
1495
  export declare type FitMode = (typeof FitModeEnum)[keyof typeof FitModeEnum];
1366
1496
 
1367
1497
  export declare const FitModeEnum: {
@@ -1539,6 +1669,41 @@ export declare interface GridConfig<TRow = any> {
1539
1669
  * Plugins will use these by default but can override with their own config.
1540
1670
  */
1541
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>;
1542
1707
  }
1543
1708
 
1544
1709
  export declare type GridCSSVar = (typeof GridCSSVars)[keyof typeof GridCSSVars];
@@ -1678,6 +1843,14 @@ export declare interface GroupingRowsConfig {
1678
1843
  formatLabel?: (value: any, depth: number, key: string) => string;
1679
1844
  /** Whether to render group row as full-width spanning cell (default: true) */
1680
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;
1681
1854
  }
1682
1855
 
1683
1856
  /** Parameters passed to custom group row renderer */
@@ -1853,6 +2026,14 @@ export declare interface PivotConfig {
1853
2026
  indentWidth?: number;
1854
2027
  /** Whether to show the pivot configuration tool panel (default: true) */
1855
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;
1856
2037
  }
1857
2038
 
1858
2039
  export declare interface PivotResult {
@@ -2327,6 +2508,16 @@ export declare interface SortChangeDetail {
2327
2508
  direction: 1 | -1 | 0;
2328
2509
  }
2329
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
+
2330
2521
  /**
2331
2522
  * Multi-Sort Plugin Types
2332
2523
  *
@@ -2340,6 +2531,16 @@ export declare interface SortModel {
2340
2531
  direction: 'asc' | 'desc';
2341
2532
  }
2342
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
+
2343
2544
  /**
2344
2545
  * Toolbar button defined via config (programmatic approach).
2345
2546
  * Supports three modes:
@@ -2420,11 +2621,6 @@ export declare interface ToolPanelDefinition {
2420
2621
  order?: number;
2421
2622
  }
2422
2623
 
2423
- /**
2424
- * Tree Data Plugin Types
2425
- *
2426
- * Type definitions for hierarchical tree data with expand/collapse functionality.
2427
- */
2428
2624
  /** Configuration options for the tree plugin */
2429
2625
  export declare interface TreeConfig {
2430
2626
  /** Field name containing child rows (default: 'children') */
@@ -2437,6 +2633,14 @@ export declare interface TreeConfig {
2437
2633
  indentWidth?: number;
2438
2634
  /** Show expand/collapse icons (default: true) */
2439
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;
2440
2644
  }
2441
2645
 
2442
2646
  /** Event detail emitted when a tree node is expanded or collapsed */