@toolbox-web/grid 0.0.5 → 0.0.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 (61) hide show
  1. package/README.md +43 -0
  2. package/all.d.ts +1680 -129
  3. package/all.js +440 -340
  4. package/all.js.map +1 -1
  5. package/custom-elements.json +1852 -0
  6. package/index.d.ts +133 -1
  7. package/index.js +726 -637
  8. package/index.js.map +1 -1
  9. package/lib/plugins/clipboard/index.js +62 -24
  10. package/lib/plugins/clipboard/index.js.map +1 -1
  11. package/lib/plugins/column-virtualization/index.js +82 -44
  12. package/lib/plugins/column-virtualization/index.js.map +1 -1
  13. package/lib/plugins/context-menu/index.js +141 -93
  14. package/lib/plugins/context-menu/index.js.map +1 -1
  15. package/lib/plugins/export/index.js +47 -9
  16. package/lib/plugins/export/index.js.map +1 -1
  17. package/lib/plugins/filtering/index.js +89 -51
  18. package/lib/plugins/filtering/index.js.map +1 -1
  19. package/lib/plugins/grouping-columns/index.js +71 -33
  20. package/lib/plugins/grouping-columns/index.js.map +1 -1
  21. package/lib/plugins/grouping-rows/index.js +91 -55
  22. package/lib/plugins/grouping-rows/index.js.map +1 -1
  23. package/lib/plugins/master-detail/index.js +176 -54
  24. package/lib/plugins/master-detail/index.js.map +1 -1
  25. package/lib/plugins/multi-sort/index.js +83 -45
  26. package/lib/plugins/multi-sort/index.js.map +1 -1
  27. package/lib/plugins/pinned-columns/index.js +54 -16
  28. package/lib/plugins/pinned-columns/index.js.map +1 -1
  29. package/lib/plugins/pinned-rows/index.js +45 -7
  30. package/lib/plugins/pinned-rows/index.js.map +1 -1
  31. package/lib/plugins/pivot/index.js +97 -59
  32. package/lib/plugins/pivot/index.js.map +1 -1
  33. package/lib/plugins/reorder/index.js +71 -33
  34. package/lib/plugins/reorder/index.js.map +1 -1
  35. package/lib/plugins/selection/index.js +132 -94
  36. package/lib/plugins/selection/index.js.map +1 -1
  37. package/lib/plugins/server-side/index.js +76 -38
  38. package/lib/plugins/server-side/index.js.map +1 -1
  39. package/lib/plugins/tree/index.js +76 -38
  40. package/lib/plugins/tree/index.js.map +1 -1
  41. package/lib/plugins/undo-redo/index.js +50 -12
  42. package/lib/plugins/undo-redo/index.js.map +1 -1
  43. package/lib/plugins/visibility/index.js +62 -24
  44. package/lib/plugins/visibility/index.js.map +1 -1
  45. package/package.json +1 -1
  46. package/umd/grid.all.umd.js +31 -31
  47. package/umd/grid.all.umd.js.map +1 -1
  48. package/umd/grid.umd.js +14 -14
  49. package/umd/grid.umd.js.map +1 -1
  50. package/umd/plugins/context-menu.umd.js +2 -2
  51. package/umd/plugins/context-menu.umd.js.map +1 -1
  52. package/umd/plugins/grouping-rows.umd.js +2 -2
  53. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  54. package/umd/plugins/master-detail.umd.js +2 -2
  55. package/umd/plugins/master-detail.umd.js.map +1 -1
  56. package/umd/plugins/multi-sort.umd.js +1 -1
  57. package/umd/plugins/multi-sort.umd.js.map +1 -1
  58. package/umd/plugins/tree.umd.js +2 -2
  59. package/umd/plugins/tree.umd.js.map +1 -1
  60. package/umd/plugins/visibility.umd.js +1 -1
  61. package/umd/plugins/visibility.umd.js.map +1 -1
package/index.d.ts CHANGED
@@ -198,6 +198,28 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> {
198
198
  * document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
199
199
  */
200
200
  protected get disconnectSignal(): AbortSignal;
201
+ /**
202
+ * Get the grid-level icons configuration.
203
+ * Returns merged icons (user config + defaults).
204
+ */
205
+ protected get gridIcons(): typeof DEFAULT_GRID_ICONS;
206
+ /**
207
+ * Resolve an icon value to string or HTMLElement.
208
+ * Checks plugin config first, then grid-level icons, then defaults.
209
+ *
210
+ * @param iconKey - The icon key in GridIcons (e.g., 'expand', 'collapse')
211
+ * @param pluginOverride - Optional plugin-level override
212
+ * @returns The resolved icon value
213
+ */
214
+ protected resolveIcon(iconKey: keyof typeof DEFAULT_GRID_ICONS, pluginOverride?: IconValue): IconValue;
215
+ /**
216
+ * Set an icon value on an element.
217
+ * Handles both string (text/HTML) and HTMLElement values.
218
+ *
219
+ * @param element - The element to set the icon on
220
+ * @param icon - The icon value (string or HTMLElement)
221
+ */
222
+ protected setIcon(element: HTMLElement, icon: IconValue): void;
201
223
  /**
202
224
  * Log a warning message.
203
225
  */
@@ -295,6 +317,68 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> {
295
317
  * ```
296
318
  */
297
319
  onScrollRender?(): void;
320
+ /**
321
+ * Return extra height contributed by this plugin (e.g., expanded detail rows).
322
+ * Used to adjust scrollbar height calculations for virtualization.
323
+ *
324
+ * @returns Total extra height in pixels
325
+ *
326
+ * @example
327
+ * ```ts
328
+ * getExtraHeight(): number {
329
+ * return this.expandedRows.size * this.detailHeight;
330
+ * }
331
+ * ```
332
+ */
333
+ getExtraHeight?(): number;
334
+ /**
335
+ * Return extra height that appears before a given row index.
336
+ * Used by virtualization to correctly calculate scroll positions when
337
+ * there's variable height content (like expanded detail rows) above the viewport.
338
+ *
339
+ * @param beforeRowIndex - The row index to calculate extra height before
340
+ * @returns Extra height in pixels that appears before this row
341
+ *
342
+ * @example
343
+ * ```ts
344
+ * getExtraHeightBefore(beforeRowIndex: number): number {
345
+ * let height = 0;
346
+ * for (const expandedRowIndex of this.expandedRowIndices) {
347
+ * if (expandedRowIndex < beforeRowIndex) {
348
+ * height += this.getDetailHeight(expandedRowIndex);
349
+ * }
350
+ * }
351
+ * return height;
352
+ * }
353
+ * ```
354
+ */
355
+ getExtraHeightBefore?(beforeRowIndex: number): number;
356
+ /**
357
+ * Adjust the virtualization start index to render additional rows before the visible range.
358
+ * Use this when expanded content (like detail rows) needs its parent row to remain rendered
359
+ * even when the parent row itself has scrolled above the viewport.
360
+ *
361
+ * @param start - The calculated start row index
362
+ * @param scrollTop - The current scroll position
363
+ * @param rowHeight - The height of a single row
364
+ * @returns The adjusted start index (lower than or equal to original start)
365
+ *
366
+ * @example
367
+ * ```ts
368
+ * adjustVirtualStart(start: number, scrollTop: number, rowHeight: number): number {
369
+ * // If row 5 is expanded and scrolled partially, keep it rendered
370
+ * for (const expandedRowIndex of this.expandedRowIndices) {
371
+ * const expandedRowTop = expandedRowIndex * rowHeight;
372
+ * const expandedRowBottom = expandedRowTop + rowHeight + this.detailHeight;
373
+ * if (expandedRowBottom > scrollTop && expandedRowIndex < start) {
374
+ * return expandedRowIndex;
375
+ * }
376
+ * }
377
+ * return start;
378
+ * }
379
+ * ```
380
+ */
381
+ adjustVirtualStart?(start: number, scrollTop: number, rowHeight: number): number;
298
382
  /**
299
383
  * Render a custom row, bypassing the default row rendering.
300
384
  * Use this for special row types like group headers, detail rows, or footers.
@@ -1168,6 +1252,9 @@ export declare interface DataGridEventMap<TRow = any> {
1168
1252
  'column-state-change': GridColumnState;
1169
1253
  }
1170
1254
 
1255
+ /** Default icons used when not overridden */
1256
+ export declare const DEFAULT_GRID_ICONS: Required<GridIcons>;
1257
+
1171
1258
  export declare type DGEventName = (typeof DGEvents)[keyof typeof DGEvents];
1172
1259
 
1173
1260
  export declare const DGEvents: {
@@ -1471,6 +1558,12 @@ export declare interface GridConfig<TRow = any> {
1471
1558
  * When configured, adds an optional wrapper with title, toolbar, and collapsible side panels.
1472
1559
  */
1473
1560
  shell?: ShellConfig;
1561
+ /**
1562
+ * Grid-wide icon configuration.
1563
+ * Provides consistent icons across all plugins (tree, grouping, sorting, etc.).
1564
+ * Plugins will use these by default but can override with their own config.
1565
+ */
1566
+ icons?: GridIcons;
1474
1567
  }
1475
1568
 
1476
1569
  export declare type GridCSSVar = (typeof GridCSSVars)[keyof typeof GridCSSVars];
@@ -1529,6 +1622,27 @@ export declare interface GridElement {
1529
1622
  dispatchEvent(event: Event): boolean;
1530
1623
  }
1531
1624
 
1625
+ /**
1626
+ * Grid-wide icon configuration.
1627
+ * All icons are optional - sensible defaults are used when not specified.
1628
+ */
1629
+ export declare interface GridIcons {
1630
+ /** Expand icon for collapsed items (trees, groups, details). Default: '▶' */
1631
+ expand?: IconValue;
1632
+ /** Collapse icon for expanded items (trees, groups, details). Default: '▼' */
1633
+ collapse?: IconValue;
1634
+ /** Sort ascending indicator. Default: '▲' */
1635
+ sortAsc?: IconValue;
1636
+ /** Sort descending indicator. Default: '▼' */
1637
+ sortDesc?: IconValue;
1638
+ /** Sort neutral/unsorted indicator. Default: '⇅' */
1639
+ sortNone?: IconValue;
1640
+ /** Submenu arrow for context menus. Default: '▶' */
1641
+ submenuArrow?: IconValue;
1642
+ /** Drag handle icon for reordering. Default: '⋮⋮' */
1643
+ dragHandle?: IconValue;
1644
+ }
1645
+
1532
1646
  /**
1533
1647
  * Common CSS selectors for querying grid elements.
1534
1648
  * Built from the class constants for consistency.
@@ -1561,7 +1675,7 @@ export declare interface GroupingRowsConfig {
1561
1675
  groupOn?: (row: any) => any[] | any | null | false;
1562
1676
  /** Whether groups are expanded by default (default: false) */
1563
1677
  defaultExpanded?: boolean;
1564
- /** Custom group row renderer */
1678
+ /** Custom group row renderer - takes full control of group row rendering */
1565
1679
  groupRowRenderer?: (params: GroupRowRenderParams) => HTMLElement | string | void;
1566
1680
  /** Show row count in group headers (default: true) */
1567
1681
  showRowCount?: boolean;
@@ -1621,6 +1735,9 @@ export declare interface HeaderContentDefinition {
1621
1735
  */
1622
1736
  export declare type HeaderRenderer = (ctx: PluginHeaderRenderContext) => string | HTMLElement;
1623
1737
 
1738
+ /** Icon value - can be a string (text/HTML) or HTMLElement */
1739
+ export declare type IconValue = string | HTMLElement;
1740
+
1624
1741
  /** Result of automatic column inference from sample rows. */
1625
1742
  export declare interface InferredColumnResult<TRow = any> {
1626
1743
  columns: ColumnConfigMap<TRow>;
@@ -1893,6 +2010,21 @@ export declare class PluginManager {
1893
2010
  * Called after scroll-triggered row rendering for lightweight visual state updates.
1894
2011
  */
1895
2012
  onScrollRender(): void;
2013
+ /**
2014
+ * Get total extra height contributed by plugins (e.g., expanded detail rows).
2015
+ * Used to adjust scrollbar height calculations.
2016
+ */
2017
+ getExtraHeight(): number;
2018
+ /**
2019
+ * Get extra height from plugins that appears before a given row index.
2020
+ * Used by virtualization to correctly position the scroll window.
2021
+ */
2022
+ getExtraHeightBefore(beforeRowIndex: number): number;
2023
+ /**
2024
+ * Adjust the virtualization start index based on plugin needs.
2025
+ * Returns the minimum start index from all plugins.
2026
+ */
2027
+ adjustVirtualStart(start: number, scrollTop: number, rowHeight: number): number;
1896
2028
  /**
1897
2029
  * Execute renderRow hook on all plugins.
1898
2030
  * Returns true if any plugin handled the row.