@toolbox-web/grid 0.0.4 → 0.0.6
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.
- package/README.md +24 -0
- package/all.d.ts +1709 -135
- package/all.js +745 -645
- package/all.js.map +1 -1
- package/index.d.ts +161 -1
- package/index.js +1050 -913
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +110 -52
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +78 -20
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +163 -95
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +93 -35
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +188 -133
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +69 -11
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +111 -55
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +196 -51
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +104 -46
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +74 -16
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +65 -7
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +117 -59
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +103 -45
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +139 -81
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +96 -38
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +108 -47
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +70 -12
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +82 -24
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +31 -31
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +2 -2
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +3 -3
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +2 -2
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +2 -2
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +2 -2
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -180,6 +180,46 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> {
|
|
|
180
180
|
* Get the shadow root of the grid.
|
|
181
181
|
*/
|
|
182
182
|
protected get shadowRoot(): ShadowRoot | null;
|
|
183
|
+
/**
|
|
184
|
+
* Get the disconnect signal for event listener cleanup.
|
|
185
|
+
* This signal is aborted when the grid disconnects from the DOM.
|
|
186
|
+
* Use this when adding event listeners that should be cleaned up automatically.
|
|
187
|
+
*
|
|
188
|
+
* Best for:
|
|
189
|
+
* - Document/window-level listeners added in attach()
|
|
190
|
+
* - Listeners on the grid element itself
|
|
191
|
+
* - Any listener that should persist across renders
|
|
192
|
+
*
|
|
193
|
+
* Not needed for:
|
|
194
|
+
* - Listeners on elements created in afterRender() (removed with element)
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* element.addEventListener('click', handler, { signal: this.disconnectSignal });
|
|
198
|
+
* document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
|
|
199
|
+
*/
|
|
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;
|
|
183
223
|
/**
|
|
184
224
|
* Log a warning message.
|
|
185
225
|
*/
|
|
@@ -277,6 +317,68 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> {
|
|
|
277
317
|
* ```
|
|
278
318
|
*/
|
|
279
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;
|
|
280
382
|
/**
|
|
281
383
|
* Render a custom row, bypassing the default row rendering.
|
|
282
384
|
* Use this for special row types like group headers, detail rows, or footers.
|
|
@@ -926,6 +1028,14 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
|
|
|
926
1028
|
get editOn(): string | undefined;
|
|
927
1029
|
set editOn(value: string | undefined);
|
|
928
1030
|
get effectiveConfig(): GridConfig<T>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Get the disconnect signal for event listener cleanup.
|
|
1033
|
+
* This signal is aborted when the grid disconnects from the DOM.
|
|
1034
|
+
* Plugins and internal code can use this for automatic listener cleanup.
|
|
1035
|
+
* @example
|
|
1036
|
+
* element.addEventListener('click', handler, { signal: this.grid.disconnectSignal });
|
|
1037
|
+
*/
|
|
1038
|
+
get disconnectSignal(): AbortSignal;
|
|
929
1039
|
constructor();
|
|
930
1040
|
/**
|
|
931
1041
|
* Get a plugin instance by its class.
|
|
@@ -1142,6 +1252,9 @@ export declare interface DataGridEventMap<TRow = any> {
|
|
|
1142
1252
|
'column-state-change': GridColumnState;
|
|
1143
1253
|
}
|
|
1144
1254
|
|
|
1255
|
+
/** Default icons used when not overridden */
|
|
1256
|
+
export declare const DEFAULT_GRID_ICONS: Required<GridIcons>;
|
|
1257
|
+
|
|
1145
1258
|
export declare type DGEventName = (typeof DGEvents)[keyof typeof DGEvents];
|
|
1146
1259
|
|
|
1147
1260
|
export declare const DGEvents: {
|
|
@@ -1445,6 +1558,12 @@ export declare interface GridConfig<TRow = any> {
|
|
|
1445
1558
|
* When configured, adds an optional wrapper with title, toolbar, and collapsible side panels.
|
|
1446
1559
|
*/
|
|
1447
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;
|
|
1448
1567
|
}
|
|
1449
1568
|
|
|
1450
1569
|
export declare type GridCSSVar = (typeof GridCSSVars)[keyof typeof GridCSSVars];
|
|
@@ -1493,6 +1612,8 @@ export declare interface GridElement {
|
|
|
1493
1612
|
rows: any[];
|
|
1494
1613
|
columns: ColumnConfig[];
|
|
1495
1614
|
gridConfig: any;
|
|
1615
|
+
/** AbortSignal that is aborted when the grid disconnects from the DOM */
|
|
1616
|
+
disconnectSignal: AbortSignal;
|
|
1496
1617
|
requestRender(): void;
|
|
1497
1618
|
requestAfterRender(): void;
|
|
1498
1619
|
forceLayout(): Promise<void>;
|
|
@@ -1501,6 +1622,27 @@ export declare interface GridElement {
|
|
|
1501
1622
|
dispatchEvent(event: Event): boolean;
|
|
1502
1623
|
}
|
|
1503
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
|
+
|
|
1504
1646
|
/**
|
|
1505
1647
|
* Common CSS selectors for querying grid elements.
|
|
1506
1648
|
* Built from the class constants for consistency.
|
|
@@ -1533,7 +1675,7 @@ export declare interface GroupingRowsConfig {
|
|
|
1533
1675
|
groupOn?: (row: any) => any[] | any | null | false;
|
|
1534
1676
|
/** Whether groups are expanded by default (default: false) */
|
|
1535
1677
|
defaultExpanded?: boolean;
|
|
1536
|
-
/** Custom group row renderer */
|
|
1678
|
+
/** Custom group row renderer - takes full control of group row rendering */
|
|
1537
1679
|
groupRowRenderer?: (params: GroupRowRenderParams) => HTMLElement | string | void;
|
|
1538
1680
|
/** Show row count in group headers (default: true) */
|
|
1539
1681
|
showRowCount?: boolean;
|
|
@@ -1593,6 +1735,9 @@ export declare interface HeaderContentDefinition {
|
|
|
1593
1735
|
*/
|
|
1594
1736
|
export declare type HeaderRenderer = (ctx: PluginHeaderRenderContext) => string | HTMLElement;
|
|
1595
1737
|
|
|
1738
|
+
/** Icon value - can be a string (text/HTML) or HTMLElement */
|
|
1739
|
+
export declare type IconValue = string | HTMLElement;
|
|
1740
|
+
|
|
1596
1741
|
/** Result of automatic column inference from sample rows. */
|
|
1597
1742
|
export declare interface InferredColumnResult<TRow = any> {
|
|
1598
1743
|
columns: ColumnConfigMap<TRow>;
|
|
@@ -1865,6 +2010,21 @@ export declare class PluginManager {
|
|
|
1865
2010
|
* Called after scroll-triggered row rendering for lightweight visual state updates.
|
|
1866
2011
|
*/
|
|
1867
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;
|
|
1868
2028
|
/**
|
|
1869
2029
|
* Execute renderRow hook on all plugins.
|
|
1870
2030
|
* Returns true if any plugin handled the row.
|