@toolbox-web/grid 0.2.2 → 0.2.4
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 +70 -0
- package/all.d.ts +373 -261
- package/all.js +328 -287
- package/all.js.map +1 -1
- package/index.d.ts +265 -196
- package/index.js +1307 -1179
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +91 -48
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +38 -35
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +2 -2
- package/umd/grid.all.umd.js +19 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +16 -16
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare type AggregatorFn = (rows: any[], field: string, column?: any) =>
|
|
|
26
26
|
/** Map of field names to aggregator references */
|
|
27
27
|
declare type AggregatorMap = Record<string, AggregatorRef_2>;
|
|
28
28
|
|
|
29
|
-
export declare type AggregatorRef = string | ((rows:
|
|
29
|
+
export declare type AggregatorRef = string | ((rows: unknown[], field: string, column?: unknown) => unknown);
|
|
30
30
|
|
|
31
31
|
declare type AggregatorRef_2 = string | AggregatorFn;
|
|
32
32
|
|
|
@@ -89,17 +89,17 @@ export declare interface BaseColumnConfig<TRow = any, TValue = any> {
|
|
|
89
89
|
/** For select/typeahead types - available options */
|
|
90
90
|
options?: Array<{
|
|
91
91
|
label: string;
|
|
92
|
-
value:
|
|
92
|
+
value: unknown;
|
|
93
93
|
}> | (() => Array<{
|
|
94
94
|
label: string;
|
|
95
|
-
value:
|
|
95
|
+
value: unknown;
|
|
96
96
|
}>);
|
|
97
97
|
/** For select/typeahead - allow multi select */
|
|
98
98
|
multi?: boolean;
|
|
99
99
|
/** Optional formatter */
|
|
100
100
|
format?: (value: TValue, row: TRow) => string;
|
|
101
101
|
/** Arbitrary extra metadata */
|
|
102
|
-
meta?: Record<string,
|
|
102
|
+
meta?: Record<string, unknown>;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
@@ -107,7 +107,7 @@ export declare interface BaseColumnConfig<TRow = any, TValue = any> {
|
|
|
107
107
|
*
|
|
108
108
|
* @template TConfig - Configuration type for the plugin
|
|
109
109
|
*/
|
|
110
|
-
export declare abstract class BaseGridPlugin<TConfig = unknown> {
|
|
110
|
+
export declare abstract class BaseGridPlugin<TConfig = unknown> implements GridPlugin {
|
|
111
111
|
/** Unique plugin identifier (derived from class name by default) */
|
|
112
112
|
abstract readonly name: string;
|
|
113
113
|
/** Plugin version - override in subclass if needed */
|
|
@@ -403,6 +403,33 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> {
|
|
|
403
403
|
* ```
|
|
404
404
|
*/
|
|
405
405
|
renderRow?(row: any, rowEl: HTMLElement, rowIndex: number): boolean | void;
|
|
406
|
+
/**
|
|
407
|
+
* Handle queries from other plugins.
|
|
408
|
+
* This is the generic mechanism for inter-plugin communication.
|
|
409
|
+
* Plugins can respond to well-known query types or define their own.
|
|
410
|
+
*
|
|
411
|
+
* @param query - The query object with type and context
|
|
412
|
+
* @returns Query-specific response, or undefined if not handling this query
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```ts
|
|
416
|
+
* onPluginQuery(query: PluginQuery): unknown {
|
|
417
|
+
* switch (query.type) {
|
|
418
|
+
* case PLUGIN_QUERIES.CAN_MOVE_COLUMN:
|
|
419
|
+
* // Prevent moving pinned columns
|
|
420
|
+
* const column = query.context as ColumnConfig;
|
|
421
|
+
* if (column.sticky === 'left' || column.sticky === 'right') {
|
|
422
|
+
* return false;
|
|
423
|
+
* }
|
|
424
|
+
* break;
|
|
425
|
+
* case PLUGIN_QUERIES.GET_CONTEXT_MENU_ITEMS:
|
|
426
|
+
* const params = query.context as ContextMenuParams;
|
|
427
|
+
* return [{ id: 'my-action', label: 'My Action', action: () => {} }];
|
|
428
|
+
* }
|
|
429
|
+
* }
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
onPluginQuery?(query: PluginQuery): unknown;
|
|
406
433
|
/**
|
|
407
434
|
* Handle keyboard events on the grid.
|
|
408
435
|
* Called when a key is pressed while the grid or a cell has focus.
|
|
@@ -546,29 +573,6 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> {
|
|
|
546
573
|
* ```
|
|
547
574
|
*/
|
|
548
575
|
onCellMouseUp?(event: CellMouseEvent): boolean | void;
|
|
549
|
-
/**
|
|
550
|
-
* Provide context menu items when right-clicking on the grid.
|
|
551
|
-
* Multiple plugins can contribute items; they are merged into a single menu.
|
|
552
|
-
*
|
|
553
|
-
* @param params - Context about where the menu was triggered (row, column, etc.)
|
|
554
|
-
* @returns Array of menu items to display
|
|
555
|
-
*
|
|
556
|
-
* @example
|
|
557
|
-
* ```ts
|
|
558
|
-
* getContextMenuItems(params: ContextMenuParams): ContextMenuItem[] {
|
|
559
|
-
* if (params.isHeader) {
|
|
560
|
-
* return [
|
|
561
|
-
* { id: 'sort-asc', label: 'Sort Ascending', action: () => this.sortAsc(params.field) },
|
|
562
|
-
* { id: 'sort-desc', label: 'Sort Descending', action: () => this.sortDesc(params.field) },
|
|
563
|
-
* ];
|
|
564
|
-
* }
|
|
565
|
-
* return [
|
|
566
|
-
* { id: 'copy', label: 'Copy Cell', action: () => this.copyCell(params) },
|
|
567
|
-
* ];
|
|
568
|
-
* }
|
|
569
|
-
* ```
|
|
570
|
-
*/
|
|
571
|
-
getContextMenuItems?(params: ContextMenuParams): ContextMenuItem[];
|
|
572
576
|
/**
|
|
573
577
|
* Contribute plugin-specific state for a column.
|
|
574
578
|
* Called by the grid when collecting column state for serialization.
|
|
@@ -611,6 +615,34 @@ export declare abstract class BaseGridPlugin<TConfig = unknown> {
|
|
|
611
615
|
* ```
|
|
612
616
|
*/
|
|
613
617
|
applyColumnState?(field: string, state: ColumnState): void;
|
|
618
|
+
/**
|
|
619
|
+
* Report horizontal scroll boundary offsets for this plugin.
|
|
620
|
+
* Plugins that obscure part of the scroll area (e.g., pinned/sticky columns)
|
|
621
|
+
* should return how much space they occupy on each side.
|
|
622
|
+
* The keyboard navigation uses this to ensure focused cells are fully visible.
|
|
623
|
+
*
|
|
624
|
+
* @param rowEl - The row element (optional, for calculating widths from rendered cells)
|
|
625
|
+
* @param focusedCell - The currently focused cell element (optional, to determine if scrolling should be skipped)
|
|
626
|
+
* @returns Object with left/right pixel offsets and optional skipScroll flag, or undefined if plugin has no offsets
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```ts
|
|
630
|
+
* getHorizontalScrollOffsets(rowEl?: HTMLElement, focusedCell?: HTMLElement): { left: number; right: number; skipScroll?: boolean } | undefined {
|
|
631
|
+
* // Calculate total width of left-pinned columns
|
|
632
|
+
* const leftCells = rowEl?.querySelectorAll('.sticky-left') ?? [];
|
|
633
|
+
* let left = 0;
|
|
634
|
+
* leftCells.forEach(el => { left += (el as HTMLElement).offsetWidth; });
|
|
635
|
+
* // Skip scroll if focused cell is pinned (always visible)
|
|
636
|
+
* const skipScroll = focusedCell?.classList.contains('sticky-left');
|
|
637
|
+
* return { left, right: 0, skipScroll };
|
|
638
|
+
* }
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
641
|
+
getHorizontalScrollOffsets?(rowEl?: HTMLElement, focusedCell?: HTMLElement): {
|
|
642
|
+
left: number;
|
|
643
|
+
right: number;
|
|
644
|
+
skipScroll?: boolean;
|
|
645
|
+
} | undefined;
|
|
614
646
|
/**
|
|
615
647
|
* Register a tool panel for this plugin.
|
|
616
648
|
* Return undefined if plugin has no tool panel.
|
|
@@ -678,13 +710,13 @@ export declare interface CellClickEvent {
|
|
|
678
710
|
originalEvent: MouseEvent;
|
|
679
711
|
}
|
|
680
712
|
|
|
681
|
-
export declare interface CellCommitDetail<TRow =
|
|
713
|
+
export declare interface CellCommitDetail<TRow = unknown> {
|
|
682
714
|
/** The mutated row after commit. */
|
|
683
715
|
row: TRow;
|
|
684
716
|
/** Field name whose value changed. */
|
|
685
717
|
field: string;
|
|
686
718
|
/** New value stored. */
|
|
687
|
-
value:
|
|
719
|
+
value: unknown;
|
|
688
720
|
/** Index of the row in current data set. */
|
|
689
721
|
rowIndex: number;
|
|
690
722
|
/** All rows that have at least one committed change (snapshot list). */
|
|
@@ -700,7 +732,7 @@ export declare interface CellCommitDetail<TRow = any> {
|
|
|
700
732
|
*/
|
|
701
733
|
declare interface CellContext<T = any> {
|
|
702
734
|
row: T;
|
|
703
|
-
value:
|
|
735
|
+
value: unknown;
|
|
704
736
|
field: string;
|
|
705
737
|
column: ColumnInternal<T>;
|
|
706
738
|
}
|
|
@@ -786,7 +818,7 @@ export declare interface CellRenderContext<TRow = any, TValue = any> {
|
|
|
786
818
|
export declare type CellRenderer = (ctx: PluginCellRenderContext) => string | HTMLElement;
|
|
787
819
|
|
|
788
820
|
/** Emitted when the changed rows tracking set is cleared programmatically. */
|
|
789
|
-
export declare interface ChangedRowsResetDetail<TRow =
|
|
821
|
+
export declare interface ChangedRowsResetDetail<TRow = unknown> {
|
|
790
822
|
/** New (empty) changed rows array after reset. */
|
|
791
823
|
rows: TRow[];
|
|
792
824
|
/** Parallel indices (likely empty). */
|
|
@@ -801,12 +833,12 @@ export declare interface ColumnConfig<TRow = any> extends BaseColumnConfig<TRow,
|
|
|
801
833
|
viewRenderer?: ColumnViewRenderer<TRow, any>;
|
|
802
834
|
/** External view spec (lets host app mount any framework component) */
|
|
803
835
|
externalView?: {
|
|
804
|
-
component:
|
|
805
|
-
props?: Record<string,
|
|
836
|
+
component: unknown;
|
|
837
|
+
props?: Record<string, unknown>;
|
|
806
838
|
mount?: (options: {
|
|
807
839
|
placeholder: HTMLElement;
|
|
808
|
-
context: CellRenderContext<TRow,
|
|
809
|
-
spec:
|
|
840
|
+
context: CellRenderContext<TRow, unknown>;
|
|
841
|
+
spec: unknown;
|
|
810
842
|
}) => void | {
|
|
811
843
|
dispose?: () => void;
|
|
812
844
|
};
|
|
@@ -838,16 +870,16 @@ export declare interface ColumnEditorContext<TRow = any, TValue = any> {
|
|
|
838
870
|
}
|
|
839
871
|
|
|
840
872
|
/** External editor spec: tag name, factory function, or external mount spec */
|
|
841
|
-
export declare type ColumnEditorSpec<TRow =
|
|
873
|
+
export declare type ColumnEditorSpec<TRow = unknown, TValue = unknown> = string | ((context: ColumnEditorContext<TRow, TValue>) => HTMLElement | string) | {
|
|
842
874
|
/** Arbitrary component reference (class, function, token) */
|
|
843
|
-
component:
|
|
875
|
+
component: unknown;
|
|
844
876
|
/** Optional static props passed to mount */
|
|
845
|
-
props?: Record<string,
|
|
877
|
+
props?: Record<string, unknown>;
|
|
846
878
|
/** Optional custom mount function; if provided we call it directly instead of emitting an event */
|
|
847
879
|
mount?: (options: {
|
|
848
880
|
placeholder: HTMLElement;
|
|
849
881
|
context: ColumnEditorContext<TRow, TValue>;
|
|
850
|
-
spec:
|
|
882
|
+
spec: unknown;
|
|
851
883
|
}) => void | {
|
|
852
884
|
dispose?: () => void;
|
|
853
885
|
};
|
|
@@ -909,10 +941,10 @@ export declare interface ColumnState {
|
|
|
909
941
|
sort?: ColumnSortState;
|
|
910
942
|
}
|
|
911
943
|
|
|
912
|
-
export declare type ColumnViewRenderer<TRow =
|
|
944
|
+
export declare type ColumnViewRenderer<TRow = unknown, TValue = unknown> = (ctx: CellRenderContext<TRow, TValue>) => Node | string | void;
|
|
913
945
|
|
|
914
946
|
/**
|
|
915
|
-
* Context menu item
|
|
947
|
+
* Context menu item (used by context-menu plugin query)
|
|
916
948
|
*/
|
|
917
949
|
export declare interface ContextMenuItem {
|
|
918
950
|
id: string;
|
|
@@ -939,36 +971,37 @@ export declare interface ContextMenuParams {
|
|
|
939
971
|
isHeader?: boolean;
|
|
940
972
|
}
|
|
941
973
|
|
|
942
|
-
export declare type DataGridCustomEvent<K extends keyof DataGridEventMap<
|
|
974
|
+
export declare type DataGridCustomEvent<K extends keyof DataGridEventMap<unknown>, TRow = unknown> = CustomEvent<DataGridEventMap<TRow>[K]>;
|
|
943
975
|
|
|
944
976
|
export declare class DataGridElement<T = any> extends HTMLElement implements InternalGrid<T> {
|
|
945
977
|
#private;
|
|
946
978
|
static readonly tagName = "tbw-grid";
|
|
947
979
|
static readonly version: string;
|
|
980
|
+
static get observedAttributes(): string[];
|
|
948
981
|
_rows: T[];
|
|
949
982
|
get _columns(): ColumnInternal<T>[];
|
|
950
983
|
set _columns(value: ColumnInternal<T>[]);
|
|
951
|
-
get
|
|
952
|
-
|
|
984
|
+
get _visibleColumns(): ColumnInternal<T>[];
|
|
985
|
+
_headerRowEl: HTMLElement;
|
|
986
|
+
_bodyEl: HTMLElement;
|
|
987
|
+
_rowPool: HTMLElement[];
|
|
988
|
+
_resizeController: ResizeController;
|
|
989
|
+
_virtualization: VirtualState;
|
|
990
|
+
_focusRow: number;
|
|
991
|
+
_focusCol: number;
|
|
992
|
+
_sortState: {
|
|
993
|
+
field: string;
|
|
994
|
+
direction: 1 | -1;
|
|
995
|
+
} | null;
|
|
996
|
+
_activeEditRows: number;
|
|
997
|
+
_rowEditSnapshots: Map<number, T>;
|
|
998
|
+
_changedRowIndices: Set<number>;
|
|
999
|
+
_gridTemplate: string;
|
|
953
1000
|
__rowRenderEpoch: number;
|
|
954
|
-
activeEditRows: number;
|
|
955
|
-
resizeController: ResizeController;
|
|
956
1001
|
__didInitialAutoSize: boolean;
|
|
957
1002
|
__lightDomColumnsCache?: ColumnInternal[];
|
|
958
1003
|
__originalColumnNodes?: HTMLElement[];
|
|
959
|
-
headerRowEl: HTMLElement;
|
|
960
|
-
bodyEl: HTMLElement;
|
|
961
|
-
virtualization: VirtualState;
|
|
962
|
-
sortState: {
|
|
963
|
-
field: string;
|
|
964
|
-
direction: 1 | -1;
|
|
965
|
-
} | null;
|
|
966
1004
|
__originalOrder: T[];
|
|
967
|
-
focusRow: number;
|
|
968
|
-
focusCol: number;
|
|
969
|
-
gridTemplate: string;
|
|
970
|
-
rowEditSnapshots: Map<number, T>;
|
|
971
|
-
_changedRowIndices: Set<number>;
|
|
972
1005
|
get rows(): T[];
|
|
973
1006
|
set rows(value: T[]);
|
|
974
1007
|
/**
|
|
@@ -984,63 +1017,54 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
|
|
|
984
1017
|
set fitMode(value: FitMode | undefined);
|
|
985
1018
|
get editOn(): string | undefined;
|
|
986
1019
|
set editOn(value: string | undefined);
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
* Get the disconnect signal for event listener cleanup.
|
|
990
|
-
* This signal is aborted when the grid disconnects from the DOM.
|
|
991
|
-
* Plugins and internal code can use this for automatic listener cleanup.
|
|
992
|
-
* @example
|
|
993
|
-
* element.addEventListener('click', handler, { signal: this.grid.disconnectSignal });
|
|
994
|
-
*/
|
|
995
|
-
get disconnectSignal(): AbortSignal;
|
|
1020
|
+
/* Excluded from this release type: effectiveConfig */
|
|
1021
|
+
/* Excluded from this release type: disconnectSignal */
|
|
996
1022
|
constructor();
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
getPlugin<P extends BaseGridPlugin>(PluginClass: new (...args: any[]) => P): P | undefined;
|
|
1002
|
-
/**
|
|
1003
|
-
* Get a plugin instance by its name.
|
|
1004
|
-
* Used for loose coupling between plugins (avoids static imports).
|
|
1005
|
-
*/
|
|
1006
|
-
getPluginByName(name: string): BaseGridPlugin | undefined;
|
|
1007
|
-
/**
|
|
1008
|
-
* Request a full re-render of the grid.
|
|
1009
|
-
* Called by plugins when they need the grid to update.
|
|
1010
|
-
* Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
|
|
1011
|
-
*/
|
|
1012
|
-
requestRender(): void;
|
|
1013
|
-
/**
|
|
1014
|
-
* Request a lightweight style update without rebuilding DOM.
|
|
1015
|
-
* Called by plugins when they only need to update CSS classes/styles.
|
|
1016
|
-
* This runs all plugin afterRender hooks without rebuilding row/column DOM.
|
|
1017
|
-
*/
|
|
1018
|
-
requestAfterRender(): void;
|
|
1023
|
+
/* Excluded from this release type: getPlugin */
|
|
1024
|
+
/* Excluded from this release type: getPluginByName */
|
|
1025
|
+
/* Excluded from this release type: requestRender */
|
|
1026
|
+
/* Excluded from this release type: requestAfterRender */
|
|
1019
1027
|
connectedCallback(): void;
|
|
1020
1028
|
disconnectedCallback(): void;
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
+
/**
|
|
1030
|
+
* Handle HTML attribute changes.
|
|
1031
|
+
* Only processes attribute values when SET (non-null).
|
|
1032
|
+
* Removing an attribute does NOT clear JS-set properties.
|
|
1033
|
+
*/
|
|
1034
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
1035
|
+
_emitCellCommit(detail: CellCommitDetail<T>): void;
|
|
1036
|
+
_emitRowCommit(detail: RowCommitDetail<T>): void;
|
|
1037
|
+
_emitSortChange(detail: SortChangeDetail): void;
|
|
1038
|
+
_emitColumnResize(detail: ColumnResizeDetail): void;
|
|
1039
|
+
_emitActivateCell(detail: ActivateCellDetail): void;
|
|
1040
|
+
/* Excluded from this release type: findHeaderRow */
|
|
1041
|
+
/* Excluded from this release type: findRenderedRowElement */
|
|
1029
1042
|
/**
|
|
1030
1043
|
* Dispatch a cell click event to the plugin system.
|
|
1031
1044
|
* Returns true if any plugin handled the event.
|
|
1032
1045
|
*/
|
|
1033
|
-
|
|
1046
|
+
_dispatchCellClick(event: MouseEvent, rowIndex: number, colIndex: number, cellEl: HTMLElement): boolean;
|
|
1034
1047
|
/**
|
|
1035
1048
|
* Dispatch a header click event to the plugin system.
|
|
1036
1049
|
* Returns true if any plugin handled the event.
|
|
1037
1050
|
*/
|
|
1038
|
-
|
|
1051
|
+
_dispatchHeaderClick(event: MouseEvent, colIndex: number, headerEl: HTMLElement): boolean;
|
|
1039
1052
|
/**
|
|
1040
1053
|
* Dispatch a keyboard event to the plugin system.
|
|
1041
1054
|
* Returns true if any plugin handled the event.
|
|
1042
1055
|
*/
|
|
1043
|
-
|
|
1056
|
+
_dispatchKeyDown(event: KeyboardEvent): boolean;
|
|
1057
|
+
/**
|
|
1058
|
+
* Get horizontal scroll boundary offsets from plugins.
|
|
1059
|
+
* Used by keyboard navigation to ensure focused cells are fully visible
|
|
1060
|
+
* when plugins like pinned columns obscure part of the scroll area.
|
|
1061
|
+
*/
|
|
1062
|
+
_getHorizontalScrollOffsets(rowEl?: HTMLElement, focusedCell?: HTMLElement): {
|
|
1063
|
+
left: number;
|
|
1064
|
+
right: number;
|
|
1065
|
+
skipScroll?: boolean;
|
|
1066
|
+
};
|
|
1067
|
+
/* Excluded from this release type: queryPlugins */
|
|
1044
1068
|
get changedRows(): T[];
|
|
1045
1069
|
get changedRowIndices(): number[];
|
|
1046
1070
|
resetChangedRows(silent?: boolean): Promise<void>;
|
|
@@ -1110,99 +1134,55 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
|
|
|
1110
1134
|
* Get the current column state.
|
|
1111
1135
|
*/
|
|
1112
1136
|
get columnState(): GridColumnState | undefined;
|
|
1113
|
-
|
|
1114
|
-
* Request a state change event to be emitted.
|
|
1115
|
-
* Called internally after resize, reorder, visibility, or sort changes.
|
|
1116
|
-
* Plugins should call this after changing their state.
|
|
1117
|
-
* The event is debounced to avoid excessive events during drag operations.
|
|
1118
|
-
*/
|
|
1119
|
-
requestStateChange(): void;
|
|
1137
|
+
/* Excluded from this release type: requestStateChange */
|
|
1120
1138
|
/**
|
|
1121
1139
|
* Reset column state to initial configuration.
|
|
1122
1140
|
* Clears all user modifications (order, width, visibility, sort).
|
|
1123
1141
|
*/
|
|
1124
1142
|
resetColumnState(): void;
|
|
1125
|
-
/**
|
|
1126
|
-
* Check if the tool panel is currently open.
|
|
1127
|
-
*/
|
|
1143
|
+
/** Check if the tool panel is currently open. */
|
|
1128
1144
|
get isToolPanelOpen(): boolean;
|
|
1129
1145
|
/**
|
|
1130
1146
|
* Get the currently active tool panel ID, or null if none is open.
|
|
1131
1147
|
* @deprecated Use isToolPanelOpen and expandedToolPanelSections instead.
|
|
1132
1148
|
*/
|
|
1133
1149
|
get activeToolPanel(): string | null;
|
|
1134
|
-
/**
|
|
1135
|
-
* Get the IDs of expanded accordion sections.
|
|
1136
|
-
*/
|
|
1150
|
+
/** Get the IDs of expanded accordion sections. */
|
|
1137
1151
|
get expandedToolPanelSections(): string[];
|
|
1138
|
-
/**
|
|
1139
|
-
* Open the tool panel (accordion view with all registered panels).
|
|
1140
|
-
*/
|
|
1152
|
+
/** Open the tool panel (accordion view with all registered panels). */
|
|
1141
1153
|
openToolPanel(): void;
|
|
1142
|
-
/**
|
|
1143
|
-
* Close the tool panel.
|
|
1144
|
-
*/
|
|
1154
|
+
/** Close the tool panel. */
|
|
1145
1155
|
closeToolPanel(): void;
|
|
1146
|
-
/**
|
|
1147
|
-
* Toggle the tool panel open/closed.
|
|
1148
|
-
*/
|
|
1156
|
+
/** Toggle the tool panel open/closed. */
|
|
1149
1157
|
toggleToolPanel(): void;
|
|
1150
|
-
/**
|
|
1151
|
-
* Toggle an accordion section expanded/collapsed.
|
|
1152
|
-
* Only one section can be expanded at a time (exclusive accordion).
|
|
1153
|
-
* When there's only one panel, toggling is disabled (always expanded).
|
|
1154
|
-
*/
|
|
1158
|
+
/** Toggle an accordion section expanded/collapsed. */
|
|
1155
1159
|
toggleToolPanelSection(sectionId: string): void;
|
|
1156
|
-
/**
|
|
1157
|
-
* Get registered tool panel definitions.
|
|
1158
|
-
*/
|
|
1160
|
+
/** Get registered tool panel definitions. */
|
|
1159
1161
|
getToolPanels(): ToolPanelDefinition[];
|
|
1160
|
-
/**
|
|
1161
|
-
* Register a custom tool panel (without creating a plugin).
|
|
1162
|
-
*/
|
|
1162
|
+
/** Register a custom tool panel (without creating a plugin). */
|
|
1163
1163
|
registerToolPanel(panel: ToolPanelDefinition): void;
|
|
1164
|
-
/**
|
|
1165
|
-
* Unregister a custom tool panel.
|
|
1166
|
-
*/
|
|
1164
|
+
/** Unregister a custom tool panel. */
|
|
1167
1165
|
unregisterToolPanel(panelId: string): void;
|
|
1168
|
-
/**
|
|
1169
|
-
* Get registered header content definitions.
|
|
1170
|
-
*/
|
|
1166
|
+
/** Get registered header content definitions. */
|
|
1171
1167
|
getHeaderContents(): HeaderContentDefinition[];
|
|
1172
|
-
/**
|
|
1173
|
-
* Register custom header content (without creating a plugin).
|
|
1174
|
-
*/
|
|
1168
|
+
/** Register custom header content (without creating a plugin). */
|
|
1175
1169
|
registerHeaderContent(content: HeaderContentDefinition): void;
|
|
1176
|
-
/**
|
|
1177
|
-
* Unregister custom header content.
|
|
1178
|
-
*/
|
|
1170
|
+
/** Unregister custom header content. */
|
|
1179
1171
|
unregisterHeaderContent(contentId: string): void;
|
|
1180
|
-
/**
|
|
1181
|
-
* Get all registered toolbar buttons.
|
|
1182
|
-
*/
|
|
1172
|
+
/** Get all registered toolbar buttons. */
|
|
1183
1173
|
getToolbarButtons(): ToolbarButtonInfo[];
|
|
1184
|
-
/**
|
|
1185
|
-
* Register a custom toolbar button programmatically.
|
|
1186
|
-
*/
|
|
1174
|
+
/** Register a custom toolbar button programmatically. */
|
|
1187
1175
|
registerToolbarButton(button: ToolbarButtonConfig): void;
|
|
1188
|
-
/**
|
|
1189
|
-
* Unregister a custom toolbar button.
|
|
1190
|
-
*/
|
|
1176
|
+
/** Unregister a custom toolbar button. */
|
|
1191
1177
|
unregisterToolbarButton(buttonId: string): void;
|
|
1192
|
-
/**
|
|
1193
|
-
* Enable/disable a toolbar button by ID.
|
|
1194
|
-
*/
|
|
1178
|
+
/** Enable/disable a toolbar button by ID. */
|
|
1195
1179
|
setToolbarButtonDisabled(buttonId: string, disabled: boolean): void;
|
|
1196
1180
|
/**
|
|
1197
1181
|
* Re-parse light DOM shell elements and refresh shell header.
|
|
1198
1182
|
* Call this after dynamically modifying <tbw-grid-header> children.
|
|
1199
1183
|
*/
|
|
1200
1184
|
refreshShellHeader(): void;
|
|
1201
|
-
|
|
1202
|
-
* Core virtualization routine. Chooses between bypass (small datasets), grouped window rendering,
|
|
1203
|
-
* or standard row window rendering.
|
|
1204
|
-
*/
|
|
1205
|
-
refreshVirtualWindow(force?: boolean): void;
|
|
1185
|
+
/* Excluded from this release type: refreshVirtualWindow */
|
|
1206
1186
|
}
|
|
1207
1187
|
|
|
1208
1188
|
/**
|
|
@@ -1211,7 +1191,7 @@ export declare class DataGridElement<T = any> extends HTMLElement implements Int
|
|
|
1211
1191
|
export declare interface DataGridElementInterface extends PublicGrid, HTMLElement {
|
|
1212
1192
|
}
|
|
1213
1193
|
|
|
1214
|
-
export declare interface DataGridEventMap<TRow =
|
|
1194
|
+
export declare interface DataGridEventMap<TRow = unknown> {
|
|
1215
1195
|
'cell-commit': CellCommitDetail<TRow>;
|
|
1216
1196
|
'row-commit': RowCommitDetail<TRow>;
|
|
1217
1197
|
'changed-rows-reset': ChangedRowsResetDetail<TRow>;
|
|
@@ -1261,7 +1241,7 @@ export declare interface EditAction {
|
|
|
1261
1241
|
* Internal editor execution context extending the generic cell context with commit helpers.
|
|
1262
1242
|
*/
|
|
1263
1243
|
declare interface EditorExecContext<T = any> extends CellContext<T> {
|
|
1264
|
-
commit: (newValue:
|
|
1244
|
+
commit: (newValue: unknown) => void;
|
|
1265
1245
|
cancel: () => void;
|
|
1266
1246
|
}
|
|
1267
1247
|
|
|
@@ -1291,27 +1271,27 @@ export declare interface ExportParams {
|
|
|
1291
1271
|
processHeader?: (header: string, field: string) => string;
|
|
1292
1272
|
}
|
|
1293
1273
|
|
|
1294
|
-
export declare interface ExternalMountEditorDetail<TRow =
|
|
1274
|
+
export declare interface ExternalMountEditorDetail<TRow = unknown> {
|
|
1295
1275
|
placeholder: HTMLElement;
|
|
1296
|
-
spec:
|
|
1276
|
+
spec: unknown;
|
|
1297
1277
|
context: {
|
|
1298
1278
|
row: TRow;
|
|
1299
|
-
value:
|
|
1279
|
+
value: unknown;
|
|
1300
1280
|
field: string;
|
|
1301
|
-
column:
|
|
1302
|
-
commit: (v:
|
|
1281
|
+
column: unknown;
|
|
1282
|
+
commit: (v: unknown) => void;
|
|
1303
1283
|
cancel: () => void;
|
|
1304
1284
|
};
|
|
1305
1285
|
}
|
|
1306
1286
|
|
|
1307
|
-
export declare interface ExternalMountViewDetail<TRow =
|
|
1287
|
+
export declare interface ExternalMountViewDetail<TRow = unknown> {
|
|
1308
1288
|
placeholder: HTMLElement;
|
|
1309
|
-
spec:
|
|
1289
|
+
spec: unknown;
|
|
1310
1290
|
context: {
|
|
1311
1291
|
row: TRow;
|
|
1312
|
-
value:
|
|
1292
|
+
value: unknown;
|
|
1313
1293
|
field: string;
|
|
1314
|
-
column:
|
|
1294
|
+
column: unknown;
|
|
1315
1295
|
};
|
|
1316
1296
|
}
|
|
1317
1297
|
|
|
@@ -1411,6 +1391,10 @@ export declare function getValueAggregator(aggFunc: string): ValueAggregatorFn;
|
|
|
1411
1391
|
/**
|
|
1412
1392
|
* CSS class names used in the grid's shadow DOM.
|
|
1413
1393
|
* Use these when adding/removing classes or querying elements.
|
|
1394
|
+
*
|
|
1395
|
+
* Classes are organized by:
|
|
1396
|
+
* - Core: Used by the grid core for structure and basic functionality
|
|
1397
|
+
* - Shared: Used by multiple features/plugins, styled by core CSS
|
|
1414
1398
|
*/
|
|
1415
1399
|
export declare const GridClasses: {
|
|
1416
1400
|
readonly ROOT: "tbw-grid-root";
|
|
@@ -1496,6 +1480,27 @@ export declare interface GridConfig<TRow = any> {
|
|
|
1496
1480
|
fitMode?: FitMode;
|
|
1497
1481
|
/** Edit activation mode ('click' | 'dblclick'). Can also be set via `editOn` prop. */
|
|
1498
1482
|
editOn?: string;
|
|
1483
|
+
/**
|
|
1484
|
+
* Row height in pixels for virtualization calculations.
|
|
1485
|
+
* The virtualization system assumes uniform row heights for performance.
|
|
1486
|
+
*
|
|
1487
|
+
* If not specified, the grid measures the first rendered row's height,
|
|
1488
|
+
* which respects the CSS variable `--tbw-row-height` set by themes.
|
|
1489
|
+
*
|
|
1490
|
+
* Set this explicitly when:
|
|
1491
|
+
* - Row content may wrap to multiple lines (also set `--tbw-cell-white-space: normal`)
|
|
1492
|
+
* - Using custom row templates with variable content
|
|
1493
|
+
* - You want to override theme-defined row height
|
|
1494
|
+
*
|
|
1495
|
+
* @default Auto-measured from first row (respects --tbw-row-height CSS variable)
|
|
1496
|
+
*
|
|
1497
|
+
* @example
|
|
1498
|
+
* ```ts
|
|
1499
|
+
* // Fixed height for rows that may wrap to 2 lines
|
|
1500
|
+
* gridConfig = { rowHeight: 56 };
|
|
1501
|
+
* ```
|
|
1502
|
+
*/
|
|
1503
|
+
rowHeight?: number;
|
|
1499
1504
|
/**
|
|
1500
1505
|
* Array of plugin instances.
|
|
1501
1506
|
* Each plugin is instantiated with its configuration and attached to this grid.
|
|
@@ -1509,7 +1514,7 @@ export declare interface GridConfig<TRow = any> {
|
|
|
1509
1514
|
* ]
|
|
1510
1515
|
* ```
|
|
1511
1516
|
*/
|
|
1512
|
-
plugins?:
|
|
1517
|
+
plugins?: GridPlugin[];
|
|
1513
1518
|
/**
|
|
1514
1519
|
* Saved column state to restore on initialization.
|
|
1515
1520
|
* Includes order, width, visibility, sort, and plugin-contributed state.
|
|
@@ -1611,6 +1616,20 @@ export declare interface GridIcons {
|
|
|
1611
1616
|
toolPanel?: IconValue;
|
|
1612
1617
|
}
|
|
1613
1618
|
|
|
1619
|
+
/**
|
|
1620
|
+
* Minimal plugin interface for type-checking.
|
|
1621
|
+
* This interface is defined here to avoid circular imports with BaseGridPlugin.
|
|
1622
|
+
* All plugins must satisfy this shape (BaseGridPlugin implements it).
|
|
1623
|
+
*/
|
|
1624
|
+
export declare interface GridPlugin {
|
|
1625
|
+
/** Unique plugin identifier */
|
|
1626
|
+
readonly name: string;
|
|
1627
|
+
/** Plugin version */
|
|
1628
|
+
readonly version: string;
|
|
1629
|
+
/** CSS styles to inject into grid's shadow DOM */
|
|
1630
|
+
readonly styles?: string;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1614
1633
|
/**
|
|
1615
1634
|
* Common CSS selectors for querying grid elements.
|
|
1616
1635
|
* Built from the class constants for consistency.
|
|
@@ -1705,7 +1724,7 @@ export declare type HeaderRenderer = (ctx: PluginHeaderRenderContext) => string
|
|
|
1705
1724
|
export declare type IconValue = string | HTMLElement;
|
|
1706
1725
|
|
|
1707
1726
|
/** Result of automatic column inference from sample rows. */
|
|
1708
|
-
export declare interface InferredColumnResult<TRow =
|
|
1727
|
+
export declare interface InferredColumnResult<TRow = unknown> {
|
|
1709
1728
|
columns: ColumnConfigMap<TRow>;
|
|
1710
1729
|
typeMap: Record<string, PrimitiveColumnType>;
|
|
1711
1730
|
}
|
|
@@ -1718,12 +1737,12 @@ declare interface InternalGrid<T = any> extends PublicGrid<T>, GridConfig<T> {
|
|
|
1718
1737
|
_rows: T[];
|
|
1719
1738
|
_columns: ColumnInternal<T>[];
|
|
1720
1739
|
/** Visible columns only (excludes hidden). Use for rendering. */
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1740
|
+
_visibleColumns: ColumnInternal<T>[];
|
|
1741
|
+
_headerRowEl: HTMLElement;
|
|
1742
|
+
_bodyEl: HTMLElement;
|
|
1743
|
+
_rowPool: HTMLElement[];
|
|
1744
|
+
_resizeController: ResizeController;
|
|
1745
|
+
_sortState: {
|
|
1727
1746
|
field: string;
|
|
1728
1747
|
direction: 1 | -1;
|
|
1729
1748
|
} | null;
|
|
@@ -1732,12 +1751,12 @@ declare interface InternalGrid<T = any> extends PublicGrid<T>, GridConfig<T> {
|
|
|
1732
1751
|
__didInitialAutoSize?: boolean;
|
|
1733
1752
|
__lightDomColumnsCache?: ColumnInternal[];
|
|
1734
1753
|
__originalColumnNodes?: HTMLElement[];
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1754
|
+
_gridTemplate: string;
|
|
1755
|
+
_virtualization: VirtualState;
|
|
1756
|
+
_focusRow: number;
|
|
1757
|
+
_focusCol: number;
|
|
1758
|
+
_activeEditRows: number;
|
|
1759
|
+
_rowEditSnapshots: Map<number, T>;
|
|
1741
1760
|
_changedRowIndices: Set<number>;
|
|
1742
1761
|
changedRows?: T[];
|
|
1743
1762
|
changedRowIndices?: number[];
|
|
@@ -1749,11 +1768,19 @@ declare interface InternalGrid<T = any> extends PublicGrid<T>, GridConfig<T> {
|
|
|
1749
1768
|
beginBulkEdit?: (rowIndex: number) => void;
|
|
1750
1769
|
commitActiveRowEdit?: () => void;
|
|
1751
1770
|
/** Dispatch cell click to plugin system, returns true if handled */
|
|
1752
|
-
|
|
1771
|
+
_dispatchCellClick?: (event: MouseEvent, rowIndex: number, colIndex: number, cellEl: HTMLElement) => boolean;
|
|
1753
1772
|
/** Dispatch header click to plugin system, returns true if handled */
|
|
1754
|
-
|
|
1773
|
+
_dispatchHeaderClick?: (event: MouseEvent, colIndex: number, headerEl: HTMLElement) => boolean;
|
|
1755
1774
|
/** Dispatch keydown to plugin system, returns true if handled */
|
|
1756
|
-
|
|
1775
|
+
_dispatchKeyDown?: (event: KeyboardEvent) => boolean;
|
|
1776
|
+
/** Get horizontal scroll boundary offsets from plugins (e.g., pinned columns) */
|
|
1777
|
+
_getHorizontalScrollOffsets?: (rowEl?: HTMLElement, focusedCell?: HTMLElement) => {
|
|
1778
|
+
left: number;
|
|
1779
|
+
right: number;
|
|
1780
|
+
skipScroll?: boolean;
|
|
1781
|
+
};
|
|
1782
|
+
/** Query all plugins with a generic query and collect responses */
|
|
1783
|
+
queryPlugins?: <T>(query: PluginQuery) => T[];
|
|
1757
1784
|
/** Request emission of column-state-change event (debounced) */
|
|
1758
1785
|
requestStateChange?: () => void;
|
|
1759
1786
|
}
|
|
@@ -1850,6 +1877,17 @@ export declare interface PivotValueField {
|
|
|
1850
1877
|
header?: string;
|
|
1851
1878
|
}
|
|
1852
1879
|
|
|
1880
|
+
/**
|
|
1881
|
+
* Well-known plugin query types.
|
|
1882
|
+
* Plugins can define additional query types beyond these.
|
|
1883
|
+
*/
|
|
1884
|
+
export declare const PLUGIN_QUERIES: {
|
|
1885
|
+
/** Ask if a column can be moved. Context: ColumnConfig. Response: boolean | undefined */
|
|
1886
|
+
readonly CAN_MOVE_COLUMN: "canMoveColumn";
|
|
1887
|
+
/** Get context menu items. Context: ContextMenuParams. Response: ContextMenuItem[] */
|
|
1888
|
+
readonly GET_CONTEXT_MENU_ITEMS: "getContextMenuItems";
|
|
1889
|
+
};
|
|
1890
|
+
|
|
1853
1891
|
/**
|
|
1854
1892
|
* Cell render context for plugin cell renderers.
|
|
1855
1893
|
* Provides full context including position and editing state.
|
|
@@ -2008,6 +2046,16 @@ export declare class PluginManager {
|
|
|
2008
2046
|
* Returns true if any plugin handled the row.
|
|
2009
2047
|
*/
|
|
2010
2048
|
renderRow(row: any, rowEl: HTMLElement, rowIndex: number): boolean;
|
|
2049
|
+
/**
|
|
2050
|
+
* Query all plugins with a generic query and collect responses.
|
|
2051
|
+
* This enables inter-plugin communication without the core knowing plugin-specific concepts.
|
|
2052
|
+
*
|
|
2053
|
+
* Common query types are defined in PLUGIN_QUERIES, but plugins can define their own.
|
|
2054
|
+
*
|
|
2055
|
+
* @param query - The query object containing type and context
|
|
2056
|
+
* @returns Array of non-undefined responses from plugins
|
|
2057
|
+
*/
|
|
2058
|
+
queryPlugins<T>(query: PluginQuery): T[];
|
|
2011
2059
|
/**
|
|
2012
2060
|
* Execute onKeyDown hook on all plugins.
|
|
2013
2061
|
* Returns true if any plugin handled the event.
|
|
@@ -2048,9 +2096,18 @@ export declare class PluginManager {
|
|
|
2048
2096
|
*/
|
|
2049
2097
|
onCellMouseUp(event: CellMouseEvent): boolean;
|
|
2050
2098
|
/**
|
|
2051
|
-
* Collect
|
|
2052
|
-
|
|
2053
|
-
|
|
2099
|
+
* Collect horizontal scroll boundary offsets from all plugins.
|
|
2100
|
+
* Combines offsets from all plugins that report them.
|
|
2101
|
+
*
|
|
2102
|
+
* @param rowEl - The row element (optional, for calculating widths from rendered cells)
|
|
2103
|
+
* @param focusedCell - The currently focused cell element (optional, to determine if scrolling should be skipped)
|
|
2104
|
+
* @returns Combined left and right pixel offsets, plus skipScroll if any plugin requests it
|
|
2105
|
+
*/
|
|
2106
|
+
getHorizontalScrollOffsets(rowEl?: HTMLElement, focusedCell?: HTMLElement): {
|
|
2107
|
+
left: number;
|
|
2108
|
+
right: number;
|
|
2109
|
+
skipScroll?: boolean;
|
|
2110
|
+
};
|
|
2054
2111
|
/**
|
|
2055
2112
|
* Collect tool panels from all plugins.
|
|
2056
2113
|
* Returns panels sorted by order (ascending).
|
|
@@ -2069,6 +2126,18 @@ export declare class PluginManager {
|
|
|
2069
2126
|
}[];
|
|
2070
2127
|
}
|
|
2071
2128
|
|
|
2129
|
+
/**
|
|
2130
|
+
* Generic plugin query for inter-plugin communication.
|
|
2131
|
+
* Plugins can define their own query types as string constants
|
|
2132
|
+
* and respond to queries from other plugins.
|
|
2133
|
+
*/
|
|
2134
|
+
export declare interface PluginQuery<T = unknown> {
|
|
2135
|
+
/** Query type identifier (e.g., 'canMoveColumn', 'getContextMenuItems') */
|
|
2136
|
+
type: string;
|
|
2137
|
+
/** Query-specific context/parameters */
|
|
2138
|
+
context: T;
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2072
2141
|
export declare type PrimitiveColumnType = 'number' | 'string' | 'date' | 'boolean' | 'select' | 'typeahead';
|
|
2073
2142
|
|
|
2074
2143
|
/**
|
|
@@ -2131,7 +2200,7 @@ export declare interface RowClickEvent {
|
|
|
2131
2200
|
}
|
|
2132
2201
|
|
|
2133
2202
|
/** Detail payload for a committed row edit (may or may not include changes). */
|
|
2134
|
-
export declare interface RowCommitDetail<TRow =
|
|
2203
|
+
export declare interface RowCommitDetail<TRow = unknown> {
|
|
2135
2204
|
/** Row index that lost edit focus. */
|
|
2136
2205
|
rowIndex: number;
|
|
2137
2206
|
/** Row object reference. */
|
|
@@ -2152,7 +2221,7 @@ export declare interface RowGroupRenderConfig {
|
|
|
2152
2221
|
/** If true, group rows span all columns (single full-width cell). Default false. */
|
|
2153
2222
|
fullWidth?: boolean;
|
|
2154
2223
|
/** Optional label formatter override. Receives raw group value + depth. */
|
|
2155
|
-
formatLabel?: (value:
|
|
2224
|
+
formatLabel?: (value: unknown, depth: number, key: string) => string;
|
|
2156
2225
|
/** Optional aggregate overrides per field for group summary cells (only when not fullWidth). */
|
|
2157
2226
|
aggregators?: Record<string, AggregatorRef>;
|
|
2158
2227
|
/** Additional CSS class applied to each group row root element. */
|