@toolbox-web/grid 0.0.1
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/all.d.ts +3518 -0
- package/all.js +3762 -0
- package/all.js.map +1 -0
- package/index.d.ts +2367 -0
- package/index.js +3105 -0
- package/index.js.map +1 -0
- package/lib/plugins/clipboard/index.js +365 -0
- package/lib/plugins/clipboard/index.js.map +1 -0
- package/lib/plugins/column-virtualization/index.js +255 -0
- package/lib/plugins/column-virtualization/index.js.map +1 -0
- package/lib/plugins/context-menu/index.js +341 -0
- package/lib/plugins/context-menu/index.js.map +1 -0
- package/lib/plugins/export/index.js +305 -0
- package/lib/plugins/export/index.js.map +1 -0
- package/lib/plugins/filtering/index.js +759 -0
- package/lib/plugins/filtering/index.js.map +1 -0
- package/lib/plugins/grouping-columns/index.js +283 -0
- package/lib/plugins/grouping-columns/index.js.map +1 -0
- package/lib/plugins/grouping-rows/index.js +494 -0
- package/lib/plugins/grouping-rows/index.js.map +1 -0
- package/lib/plugins/master-detail/index.js +303 -0
- package/lib/plugins/master-detail/index.js.map +1 -0
- package/lib/plugins/multi-sort/index.js +270 -0
- package/lib/plugins/multi-sort/index.js.map +1 -0
- package/lib/plugins/pinned-columns/index.js +221 -0
- package/lib/plugins/pinned-columns/index.js.map +1 -0
- package/lib/plugins/pinned-rows/index.js +459 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -0
- package/lib/plugins/pivot/index.js +326 -0
- package/lib/plugins/pivot/index.js.map +1 -0
- package/lib/plugins/reorder/index.js +260 -0
- package/lib/plugins/reorder/index.js.map +1 -0
- package/lib/plugins/selection/index.js +426 -0
- package/lib/plugins/selection/index.js.map +1 -0
- package/lib/plugins/server-side/index.js +241 -0
- package/lib/plugins/server-side/index.js.map +1 -0
- package/lib/plugins/tree/index.js +383 -0
- package/lib/plugins/tree/index.js.map +1 -0
- package/lib/plugins/undo-redo/index.js +289 -0
- package/lib/plugins/undo-redo/index.js.map +1 -0
- package/lib/plugins/visibility/index.js +430 -0
- package/lib/plugins/visibility/index.js.map +1 -0
- package/package.json +53 -0
- package/themes/dg-theme-contrast.css +43 -0
- package/themes/dg-theme-large.css +54 -0
- package/themes/dg-theme-standard.css +19 -0
- package/themes/dg-theme-vibrant.css +16 -0
- package/umd/grid.all.umd.js +660 -0
- package/umd/grid.all.umd.js.map +1 -0
- package/umd/grid.umd.js +105 -0
- package/umd/grid.umd.js.map +1 -0
- package/umd/plugins/clipboard.umd.js +9 -0
- package/umd/plugins/clipboard.umd.js.map +1 -0
- package/umd/plugins/column-virtualization.umd.js +2 -0
- package/umd/plugins/column-virtualization.umd.js.map +1 -0
- package/umd/plugins/context-menu.umd.js +53 -0
- package/umd/plugins/context-menu.umd.js.map +1 -0
- package/umd/plugins/export.umd.js +14 -0
- package/umd/plugins/export.umd.js.map +1 -0
- package/umd/plugins/filtering.umd.js +175 -0
- package/umd/plugins/filtering.umd.js.map +1 -0
- package/umd/plugins/grouping-columns.umd.js +29 -0
- package/umd/plugins/grouping-columns.umd.js.map +1 -0
- package/umd/plugins/grouping-rows.umd.js +40 -0
- package/umd/plugins/grouping-rows.umd.js.map +1 -0
- package/umd/plugins/master-detail.umd.js +27 -0
- package/umd/plugins/master-detail.umd.js.map +1 -0
- package/umd/plugins/multi-sort.umd.js +26 -0
- package/umd/plugins/multi-sort.umd.js.map +1 -0
- package/umd/plugins/pinned-columns.umd.js +2 -0
- package/umd/plugins/pinned-columns.umd.js.map +1 -0
- package/umd/plugins/pinned-rows.umd.js +73 -0
- package/umd/plugins/pinned-rows.umd.js.map +1 -0
- package/umd/plugins/pivot.umd.js +8 -0
- package/umd/plugins/pivot.umd.js.map +1 -0
- package/umd/plugins/reorder.umd.js +31 -0
- package/umd/plugins/reorder.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +34 -0
- package/umd/plugins/selection.umd.js.map +1 -0
- package/umd/plugins/server-side.umd.js +2 -0
- package/umd/plugins/server-side.umd.js.map +1 -0
- package/umd/plugins/tree.umd.js +11 -0
- package/umd/plugins/tree.umd.js.map +1 -0
- package/umd/plugins/undo-redo.umd.js +2 -0
- package/umd/plugins/undo-redo.umd.js.map +1 -0
- package/umd/plugins/visibility.umd.js +94 -0
- package/umd/plugins/visibility.umd.js.map +1 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,2367 @@
|
|
|
1
|
+
/** Fired when keyboard navigation or programmatic focus changes active cell. */
|
|
2
|
+
export declare interface ActivateCellDetail {
|
|
3
|
+
/** Zero-based row index now focused. */
|
|
4
|
+
row: number;
|
|
5
|
+
/** Zero-based column index now focused. */
|
|
6
|
+
col: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Aggregators Core Registry
|
|
11
|
+
*
|
|
12
|
+
* Provides a central registry for aggregator functions.
|
|
13
|
+
* Built-in aggregators are provided by default.
|
|
14
|
+
* Plugins can register additional aggregators.
|
|
15
|
+
*
|
|
16
|
+
* The registry is exposed as a singleton object that can be accessed:
|
|
17
|
+
* - By ES module imports: import { aggregatorRegistry } from '@toolbox-web/grid'
|
|
18
|
+
* - By UMD/CDN: TbwGrid.aggregatorRegistry
|
|
19
|
+
* - By plugins via context: ctx.aggregatorRegistry
|
|
20
|
+
*/
|
|
21
|
+
export declare type AggregatorFn = (rows: any[], field: string, column?: any) => any;
|
|
22
|
+
|
|
23
|
+
/** Map of field names to aggregator references */
|
|
24
|
+
declare type AggregatorMap = Record<string, AggregatorRef_2>;
|
|
25
|
+
|
|
26
|
+
export declare type AggregatorRef = string | ((rows: any[], field: string, column?: any) => any);
|
|
27
|
+
|
|
28
|
+
declare type AggregatorRef_2 = string | AggregatorFn;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The aggregator registry singleton.
|
|
32
|
+
* Plugins should access this through context or the global namespace.
|
|
33
|
+
*/
|
|
34
|
+
export declare const aggregatorRegistry: {
|
|
35
|
+
/**
|
|
36
|
+
* Register a custom aggregator function.
|
|
37
|
+
*/
|
|
38
|
+
register(name: string, fn: AggregatorFn): void;
|
|
39
|
+
/**
|
|
40
|
+
* Unregister a custom aggregator function.
|
|
41
|
+
*/
|
|
42
|
+
unregister(name: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get an aggregator function by reference.
|
|
45
|
+
*/
|
|
46
|
+
get(ref: AggregatorRef_2 | undefined): AggregatorFn | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Run an aggregator on a set of rows.
|
|
49
|
+
*/
|
|
50
|
+
run(ref: AggregatorRef_2 | undefined, rows: any[], field: string, column?: any): any;
|
|
51
|
+
/**
|
|
52
|
+
* Check if an aggregator exists.
|
|
53
|
+
*/
|
|
54
|
+
has(name: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* List all available aggregator names.
|
|
57
|
+
*/
|
|
58
|
+
list(): string[];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Base contract for a column. Public; kept intentionally lean so host apps can extend via intersection types.
|
|
63
|
+
* Prefer adding optional properties here only when broadly useful to most grids.
|
|
64
|
+
*/
|
|
65
|
+
export declare interface BaseColumnConfig<TRow = any, TValue = any> {
|
|
66
|
+
/** Unique field key referencing property in row objects */
|
|
67
|
+
field: keyof TRow & string;
|
|
68
|
+
/** Visible header label; defaults to capitalized field */
|
|
69
|
+
header?: string;
|
|
70
|
+
/** Column data type; inferred if omitted */
|
|
71
|
+
type?: PrimitiveColumnType;
|
|
72
|
+
/** Column width in pixels; fixed size (no flexibility) */
|
|
73
|
+
width?: string | number;
|
|
74
|
+
/** Minimum column width in pixels (stretch mode only); when set, column uses minmax(minWidth, 1fr) */
|
|
75
|
+
minWidth?: number;
|
|
76
|
+
/** Whether column can be sorted */
|
|
77
|
+
sortable?: boolean;
|
|
78
|
+
/** Whether column can be resized by user */
|
|
79
|
+
resizable?: boolean;
|
|
80
|
+
/** Optional custom comparator for sorting (a,b) -> number */
|
|
81
|
+
sortComparator?: (a: TValue, b: TValue, rowA: TRow, rowB: TRow) => number;
|
|
82
|
+
/** Whether the field is editable (enables editors) */
|
|
83
|
+
editable?: boolean;
|
|
84
|
+
/** Optional custom editor factory or element tag name */
|
|
85
|
+
editor?: ColumnEditorSpec<TRow, TValue>;
|
|
86
|
+
/** For select/typeahead types - available options */
|
|
87
|
+
options?: Array<{
|
|
88
|
+
label: string;
|
|
89
|
+
value: any;
|
|
90
|
+
}> | (() => Array<{
|
|
91
|
+
label: string;
|
|
92
|
+
value: any;
|
|
93
|
+
}>);
|
|
94
|
+
/** For select/typeahead - allow multi select */
|
|
95
|
+
multi?: boolean;
|
|
96
|
+
/** Optional formatter */
|
|
97
|
+
format?: (value: TValue, row: TRow) => string;
|
|
98
|
+
/** Arbitrary extra metadata */
|
|
99
|
+
meta?: Record<string, any>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Abstract base class for all grid plugins.
|
|
104
|
+
*
|
|
105
|
+
* @template TConfig - Configuration type for the plugin
|
|
106
|
+
*/
|
|
107
|
+
export declare abstract class BaseGridPlugin<TConfig = unknown> {
|
|
108
|
+
/** Unique plugin identifier (derived from class name by default) */
|
|
109
|
+
abstract readonly name: string;
|
|
110
|
+
/** Plugin version - override in subclass if needed */
|
|
111
|
+
readonly version: string;
|
|
112
|
+
/** CSS styles to inject into the grid's shadow DOM */
|
|
113
|
+
readonly styles?: string;
|
|
114
|
+
/** Custom cell renderers keyed by type name */
|
|
115
|
+
readonly cellRenderers?: Record<string, CellRenderer>;
|
|
116
|
+
/** Custom header renderers keyed by type name */
|
|
117
|
+
readonly headerRenderers?: Record<string, HeaderRenderer>;
|
|
118
|
+
/** Custom cell editors keyed by type name */
|
|
119
|
+
readonly cellEditors?: Record<string, CellEditor>;
|
|
120
|
+
/** The grid instance this plugin is attached to */
|
|
121
|
+
protected grid: GridElement;
|
|
122
|
+
/** Plugin configuration - merged with defaults in attach() */
|
|
123
|
+
protected config: TConfig;
|
|
124
|
+
/** User-provided configuration from constructor */
|
|
125
|
+
private readonly userConfig;
|
|
126
|
+
/**
|
|
127
|
+
* Default configuration - subclasses should override this getter.
|
|
128
|
+
* Note: This must be a getter (not property initializer) for proper inheritance
|
|
129
|
+
* since property initializers run after parent constructor.
|
|
130
|
+
*/
|
|
131
|
+
protected get defaultConfig(): Partial<TConfig>;
|
|
132
|
+
constructor(config?: Partial<TConfig>);
|
|
133
|
+
/**
|
|
134
|
+
* Called when the plugin is attached to a grid.
|
|
135
|
+
* Override to set up event listeners, initialize state, etc.
|
|
136
|
+
*/
|
|
137
|
+
attach(grid: GridElement): void;
|
|
138
|
+
/**
|
|
139
|
+
* Called when the plugin is detached from a grid.
|
|
140
|
+
* Override to clean up event listeners, timers, etc.
|
|
141
|
+
*/
|
|
142
|
+
detach(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Get another plugin instance from the same grid.
|
|
145
|
+
* Use for inter-plugin communication.
|
|
146
|
+
*/
|
|
147
|
+
protected getPlugin<T extends BaseGridPlugin>(PluginClass: new (...args: any[]) => T): T | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Emit a custom event from the grid.
|
|
150
|
+
*/
|
|
151
|
+
protected emit<T>(eventName: string, detail: T): void;
|
|
152
|
+
/**
|
|
153
|
+
* Request a re-render of the grid.
|
|
154
|
+
*/
|
|
155
|
+
protected requestRender(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Request a lightweight style update without rebuilding DOM.
|
|
158
|
+
* Use this instead of requestRender() when only CSS classes need updating.
|
|
159
|
+
*/
|
|
160
|
+
protected requestAfterRender(): void;
|
|
161
|
+
/**
|
|
162
|
+
* Get the current rows from the grid.
|
|
163
|
+
*/
|
|
164
|
+
protected get rows(): any[];
|
|
165
|
+
/**
|
|
166
|
+
* Get the original unfiltered/unprocessed rows from the grid.
|
|
167
|
+
* Use this when you need all source data regardless of active filters.
|
|
168
|
+
*/
|
|
169
|
+
protected get sourceRows(): any[];
|
|
170
|
+
/**
|
|
171
|
+
* Get the current columns from the grid.
|
|
172
|
+
*/
|
|
173
|
+
protected get columns(): ColumnConfig[];
|
|
174
|
+
/**
|
|
175
|
+
* Get only visible columns from the grid (excludes hidden).
|
|
176
|
+
* Use this for rendering that needs to match the grid template.
|
|
177
|
+
*/
|
|
178
|
+
protected get visibleColumns(): ColumnConfig[];
|
|
179
|
+
/**
|
|
180
|
+
* Get the shadow root of the grid.
|
|
181
|
+
*/
|
|
182
|
+
protected get shadowRoot(): ShadowRoot | null;
|
|
183
|
+
/**
|
|
184
|
+
* Log a warning message.
|
|
185
|
+
*/
|
|
186
|
+
protected warn(message: string): void;
|
|
187
|
+
/**
|
|
188
|
+
* Transform rows before rendering.
|
|
189
|
+
* Called during each render cycle before rows are rendered to the DOM.
|
|
190
|
+
* Use this to filter, sort, or add computed properties to rows.
|
|
191
|
+
*
|
|
192
|
+
* @param rows - The current rows array (readonly to encourage returning a new array)
|
|
193
|
+
* @returns The modified rows array to render
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* processRows(rows: readonly any[]): any[] {
|
|
198
|
+
* // Filter out hidden rows
|
|
199
|
+
* return rows.filter(row => !row._hidden);
|
|
200
|
+
* }
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* processRows(rows: readonly any[]): any[] {
|
|
206
|
+
* // Add computed properties
|
|
207
|
+
* return rows.map(row => ({
|
|
208
|
+
* ...row,
|
|
209
|
+
* _fullName: `${row.firstName} ${row.lastName}`
|
|
210
|
+
* }));
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
processRows?(rows: readonly any[]): any[];
|
|
215
|
+
/**
|
|
216
|
+
* Transform columns before rendering.
|
|
217
|
+
* Called during each render cycle before column headers and cells are rendered.
|
|
218
|
+
* Use this to add, remove, or modify column definitions.
|
|
219
|
+
*
|
|
220
|
+
* @param columns - The current columns array (readonly to encourage returning a new array)
|
|
221
|
+
* @returns The modified columns array to render
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {
|
|
226
|
+
* // Add a selection checkbox column
|
|
227
|
+
* return [
|
|
228
|
+
* { field: '_select', header: '', width: 40 },
|
|
229
|
+
* ...columns
|
|
230
|
+
* ];
|
|
231
|
+
* }
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
processColumns?(columns: readonly ColumnConfig[]): ColumnConfig[];
|
|
235
|
+
/**
|
|
236
|
+
* Called before each render cycle begins.
|
|
237
|
+
* Use this to prepare state or cache values needed during rendering.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* beforeRender(): void {
|
|
242
|
+
* this.visibleRowCount = this.calculateVisibleRows();
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
beforeRender?(): void;
|
|
247
|
+
/**
|
|
248
|
+
* Called after each render cycle completes.
|
|
249
|
+
* Use this for DOM manipulation, adding event listeners to rendered elements,
|
|
250
|
+
* or applying visual effects like selection highlights.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* afterRender(): void {
|
|
255
|
+
* // Apply selection styling to rendered rows
|
|
256
|
+
* const rows = this.shadowRoot?.querySelectorAll('.data-row');
|
|
257
|
+
* rows?.forEach((row, i) => {
|
|
258
|
+
* row.classList.toggle('selected', this.selectedRows.has(i));
|
|
259
|
+
* });
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
afterRender?(): void;
|
|
264
|
+
/**
|
|
265
|
+
* Render a custom row, bypassing the default row rendering.
|
|
266
|
+
* Use this for special row types like group headers, detail rows, or footers.
|
|
267
|
+
*
|
|
268
|
+
* @param row - The row data object
|
|
269
|
+
* @param rowEl - The row DOM element to render into
|
|
270
|
+
* @param rowIndex - The index of the row in the data array
|
|
271
|
+
* @returns `true` if the plugin handled rendering (prevents default), `false`/`void` for default rendering
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```ts
|
|
275
|
+
* renderRow(row: any, rowEl: HTMLElement, rowIndex: number): boolean | void {
|
|
276
|
+
* if (row._isGroupHeader) {
|
|
277
|
+
* rowEl.innerHTML = `<div class="group-header">${row._groupLabel}</div>`;
|
|
278
|
+
* return true; // Handled - skip default rendering
|
|
279
|
+
* }
|
|
280
|
+
* // Return void to let default rendering proceed
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
renderRow?(row: any, rowEl: HTMLElement, rowIndex: number): boolean | void;
|
|
285
|
+
/**
|
|
286
|
+
* Handle keyboard events on the grid.
|
|
287
|
+
* Called when a key is pressed while the grid or a cell has focus.
|
|
288
|
+
*
|
|
289
|
+
* @param event - The native KeyboardEvent
|
|
290
|
+
* @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* onKeyDown(event: KeyboardEvent): boolean | void {
|
|
295
|
+
* // Handle Ctrl+A for select all
|
|
296
|
+
* if (event.ctrlKey && event.key === 'a') {
|
|
297
|
+
* this.selectAllRows();
|
|
298
|
+
* return true; // Prevent default browser select-all
|
|
299
|
+
* }
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
onKeyDown?(event: KeyboardEvent): boolean | void;
|
|
304
|
+
/**
|
|
305
|
+
* Handle cell click events.
|
|
306
|
+
* Called when a data cell is clicked (not headers).
|
|
307
|
+
*
|
|
308
|
+
* @param event - Cell click event with row/column context
|
|
309
|
+
* @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```ts
|
|
313
|
+
* onCellClick(event: CellClickEvent): boolean | void {
|
|
314
|
+
* if (event.field === '_select') {
|
|
315
|
+
* this.toggleRowSelection(event.rowIndex);
|
|
316
|
+
* return true; // Handled
|
|
317
|
+
* }
|
|
318
|
+
* }
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
onCellClick?(event: CellClickEvent): boolean | void;
|
|
322
|
+
/**
|
|
323
|
+
* Handle row click events.
|
|
324
|
+
* Called when any part of a data row is clicked.
|
|
325
|
+
* Note: This is called in addition to onCellClick, not instead of.
|
|
326
|
+
*
|
|
327
|
+
* @param event - Row click event with row context
|
|
328
|
+
* @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* onRowClick(event: RowClickEvent): boolean | void {
|
|
333
|
+
* if (this.config.mode === 'row') {
|
|
334
|
+
* this.selectRow(event.rowIndex, event.originalEvent);
|
|
335
|
+
* return true;
|
|
336
|
+
* }
|
|
337
|
+
* }
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
onRowClick?(event: RowClickEvent): boolean | void;
|
|
341
|
+
/**
|
|
342
|
+
* Handle header click events.
|
|
343
|
+
* Called when a column header is clicked. Commonly used for sorting.
|
|
344
|
+
*
|
|
345
|
+
* @param event - Header click event with column context
|
|
346
|
+
* @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* onHeaderClick(event: HeaderClickEvent): boolean | void {
|
|
351
|
+
* if (event.column.sortable !== false) {
|
|
352
|
+
* this.toggleSort(event.field);
|
|
353
|
+
* return true;
|
|
354
|
+
* }
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
onHeaderClick?(event: HeaderClickEvent): boolean | void;
|
|
359
|
+
/**
|
|
360
|
+
* Handle scroll events on the grid viewport.
|
|
361
|
+
* Called during scrolling. Note: This may be called frequently; debounce if needed.
|
|
362
|
+
*
|
|
363
|
+
* @param event - Scroll event with scroll position and viewport dimensions
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```ts
|
|
367
|
+
* onScroll(event: ScrollEvent): void {
|
|
368
|
+
* // Update sticky column positions
|
|
369
|
+
* this.updateStickyPositions(event.scrollLeft);
|
|
370
|
+
* }
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
onScroll?(event: ScrollEvent): void;
|
|
374
|
+
/**
|
|
375
|
+
* Handle cell mousedown events.
|
|
376
|
+
* Used for initiating drag operations like range selection or column resize.
|
|
377
|
+
*
|
|
378
|
+
* @param event - Mouse event with cell context
|
|
379
|
+
* @returns `true` to indicate drag started (prevents text selection), `false`/`void` otherwise
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```ts
|
|
383
|
+
* onCellMouseDown(event: CellMouseEvent): boolean | void {
|
|
384
|
+
* if (event.rowIndex !== undefined && this.config.mode === 'range') {
|
|
385
|
+
* this.startDragSelection(event.rowIndex, event.colIndex);
|
|
386
|
+
* return true; // Prevent text selection
|
|
387
|
+
* }
|
|
388
|
+
* }
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
onCellMouseDown?(event: CellMouseEvent): boolean | void;
|
|
392
|
+
/**
|
|
393
|
+
* Handle cell mousemove events during drag operations.
|
|
394
|
+
* Only called when a drag is in progress (after mousedown returned true).
|
|
395
|
+
*
|
|
396
|
+
* @param event - Mouse event with current cell context
|
|
397
|
+
* @returns `true` to continue handling the drag, `false`/`void` otherwise
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* onCellMouseMove(event: CellMouseEvent): boolean | void {
|
|
402
|
+
* if (this.isDragging && event.rowIndex !== undefined) {
|
|
403
|
+
* this.extendSelection(event.rowIndex, event.colIndex);
|
|
404
|
+
* return true;
|
|
405
|
+
* }
|
|
406
|
+
* }
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
onCellMouseMove?(event: CellMouseEvent): boolean | void;
|
|
410
|
+
/**
|
|
411
|
+
* Handle cell mouseup events to end drag operations.
|
|
412
|
+
*
|
|
413
|
+
* @param event - Mouse event with final cell context
|
|
414
|
+
* @returns `true` if drag was finalized, `false`/`void` otherwise
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* onCellMouseUp(event: CellMouseEvent): boolean | void {
|
|
419
|
+
* if (this.isDragging) {
|
|
420
|
+
* this.finalizeDragSelection();
|
|
421
|
+
* this.isDragging = false;
|
|
422
|
+
* return true;
|
|
423
|
+
* }
|
|
424
|
+
* }
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
onCellMouseUp?(event: CellMouseEvent): boolean | void;
|
|
428
|
+
/**
|
|
429
|
+
* Provide context menu items when right-clicking on the grid.
|
|
430
|
+
* Multiple plugins can contribute items; they are merged into a single menu.
|
|
431
|
+
*
|
|
432
|
+
* @param params - Context about where the menu was triggered (row, column, etc.)
|
|
433
|
+
* @returns Array of menu items to display
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```ts
|
|
437
|
+
* getContextMenuItems(params: ContextMenuParams): ContextMenuItem[] {
|
|
438
|
+
* if (params.isHeader) {
|
|
439
|
+
* return [
|
|
440
|
+
* { id: 'sort-asc', label: 'Sort Ascending', action: () => this.sortAsc(params.field) },
|
|
441
|
+
* { id: 'sort-desc', label: 'Sort Descending', action: () => this.sortDesc(params.field) },
|
|
442
|
+
* ];
|
|
443
|
+
* }
|
|
444
|
+
* return [
|
|
445
|
+
* { id: 'copy', label: 'Copy Cell', action: () => this.copyCell(params) },
|
|
446
|
+
* ];
|
|
447
|
+
* }
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
getContextMenuItems?(params: ContextMenuParams): ContextMenuItem[];
|
|
451
|
+
/**
|
|
452
|
+
* Contribute plugin-specific state for a column.
|
|
453
|
+
* Called by the grid when collecting column state for serialization.
|
|
454
|
+
* Plugins can add their own properties to the column state.
|
|
455
|
+
*
|
|
456
|
+
* @param field - The field name of the column
|
|
457
|
+
* @returns Partial column state with plugin-specific properties, or undefined if no state to contribute
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* getColumnState(field: string): Partial<ColumnState> | undefined {
|
|
462
|
+
* const filterModel = this.filterModels.get(field);
|
|
463
|
+
* if (filterModel) {
|
|
464
|
+
* // Uses module augmentation to add filter property to ColumnState
|
|
465
|
+
* return { filter: filterModel } as Partial<ColumnState>;
|
|
466
|
+
* }
|
|
467
|
+
* return undefined;
|
|
468
|
+
* }
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
getColumnState?(field: string): Partial<ColumnState> | undefined;
|
|
472
|
+
/**
|
|
473
|
+
* Apply plugin-specific state to a column.
|
|
474
|
+
* Called by the grid when restoring column state from serialized data.
|
|
475
|
+
* Plugins should restore their internal state based on the provided state.
|
|
476
|
+
*
|
|
477
|
+
* @param field - The field name of the column
|
|
478
|
+
* @param state - The column state to apply (may contain plugin-specific properties)
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```ts
|
|
482
|
+
* applyColumnState(field: string, state: ColumnState): void {
|
|
483
|
+
* // Check for filter property added via module augmentation
|
|
484
|
+
* const filter = (state as any).filter;
|
|
485
|
+
* if (filter) {
|
|
486
|
+
* this.filterModels.set(field, filter);
|
|
487
|
+
* this.applyFilter();
|
|
488
|
+
* }
|
|
489
|
+
* }
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
applyColumnState?(field: string, state: ColumnState): void;
|
|
493
|
+
/**
|
|
494
|
+
* Register a tool panel for this plugin.
|
|
495
|
+
* Return undefined if plugin has no tool panel.
|
|
496
|
+
* The shell will create a toolbar toggle button and render the panel content
|
|
497
|
+
* when the user opens the panel.
|
|
498
|
+
*
|
|
499
|
+
* @returns Tool panel definition, or undefined if plugin has no panel
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```ts
|
|
503
|
+
* getToolPanel(): ToolPanelDefinition | undefined {
|
|
504
|
+
* return {
|
|
505
|
+
* id: 'columns',
|
|
506
|
+
* title: 'Columns',
|
|
507
|
+
* icon: '☰',
|
|
508
|
+
* tooltip: 'Show/hide columns',
|
|
509
|
+
* order: 10,
|
|
510
|
+
* render: (container) => {
|
|
511
|
+
* this.renderColumnList(container);
|
|
512
|
+
* return () => this.cleanup();
|
|
513
|
+
* },
|
|
514
|
+
* };
|
|
515
|
+
* }
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
getToolPanel?(): ToolPanelDefinition | undefined;
|
|
519
|
+
/**
|
|
520
|
+
* Register content for the shell header center section.
|
|
521
|
+
* Return undefined if plugin has no header content.
|
|
522
|
+
* Examples: search input, selection summary, status indicators.
|
|
523
|
+
*
|
|
524
|
+
* @returns Header content definition, or undefined if plugin has no header content
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* ```ts
|
|
528
|
+
* getHeaderContent(): HeaderContentDefinition | undefined {
|
|
529
|
+
* return {
|
|
530
|
+
* id: 'quick-filter',
|
|
531
|
+
* order: 10,
|
|
532
|
+
* render: (container) => {
|
|
533
|
+
* const input = document.createElement('input');
|
|
534
|
+
* input.type = 'text';
|
|
535
|
+
* input.placeholder = 'Search...';
|
|
536
|
+
* input.addEventListener('input', this.handleInput);
|
|
537
|
+
* container.appendChild(input);
|
|
538
|
+
* return () => input.removeEventListener('input', this.handleInput);
|
|
539
|
+
* },
|
|
540
|
+
* };
|
|
541
|
+
* }
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
getHeaderContent?(): HeaderContentDefinition | undefined;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Cell click event
|
|
549
|
+
*/
|
|
550
|
+
export declare interface CellClickEvent {
|
|
551
|
+
rowIndex: number;
|
|
552
|
+
colIndex: number;
|
|
553
|
+
field: string;
|
|
554
|
+
value: any;
|
|
555
|
+
row: any;
|
|
556
|
+
cellEl: HTMLElement;
|
|
557
|
+
originalEvent: MouseEvent;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export declare interface CellCommitDetail<TRow = any> {
|
|
561
|
+
/** The mutated row after commit. */
|
|
562
|
+
row: TRow;
|
|
563
|
+
/** Field name whose value changed. */
|
|
564
|
+
field: string;
|
|
565
|
+
/** New value stored. */
|
|
566
|
+
value: any;
|
|
567
|
+
/** Index of the row in current data set. */
|
|
568
|
+
rowIndex: number;
|
|
569
|
+
/** All rows that have at least one committed change (snapshot list). */
|
|
570
|
+
changedRows: TRow[];
|
|
571
|
+
/** Indices parallel to changedRows. */
|
|
572
|
+
changedRowIndices: number[];
|
|
573
|
+
/** True if this row just entered the changed set. */
|
|
574
|
+
firstTimeForRow: boolean;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Runtime cell context used internally for compiled template execution.
|
|
579
|
+
*/
|
|
580
|
+
declare interface CellContext<T = any> {
|
|
581
|
+
row: T;
|
|
582
|
+
value: any;
|
|
583
|
+
field: string;
|
|
584
|
+
column: ColumnInternal<T>;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Cell coordinates
|
|
589
|
+
*/
|
|
590
|
+
export declare interface CellCoords {
|
|
591
|
+
row: number;
|
|
592
|
+
col: number;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Cell editor interface for plugins.
|
|
597
|
+
*/
|
|
598
|
+
export declare interface CellEditor {
|
|
599
|
+
create(ctx: PluginCellRenderContext, commitFn: (value: any) => void, cancelFn: () => void): HTMLElement;
|
|
600
|
+
getValue?(element: HTMLElement): any;
|
|
601
|
+
focus?(element: HTMLElement): void;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Cell mouse event (for drag operations, selection, etc.)
|
|
606
|
+
*/
|
|
607
|
+
export declare interface CellMouseEvent {
|
|
608
|
+
/** Event type: mousedown, mousemove, or mouseup */
|
|
609
|
+
type: 'mousedown' | 'mousemove' | 'mouseup';
|
|
610
|
+
/** Row index, undefined if not over a data cell */
|
|
611
|
+
rowIndex?: number;
|
|
612
|
+
/** Column index, undefined if not over a cell */
|
|
613
|
+
colIndex?: number;
|
|
614
|
+
/** Field name, undefined if not over a cell */
|
|
615
|
+
field?: string;
|
|
616
|
+
/** Cell value, undefined if not over a data cell */
|
|
617
|
+
value?: unknown;
|
|
618
|
+
/** Row data object, undefined if not over a data row */
|
|
619
|
+
row?: unknown;
|
|
620
|
+
/** Column configuration, undefined if not over a column */
|
|
621
|
+
column?: ColumnConfig;
|
|
622
|
+
/** The cell element, undefined if not over a cell */
|
|
623
|
+
cellElement?: HTMLElement;
|
|
624
|
+
/** The row element, undefined if not over a row */
|
|
625
|
+
rowElement?: HTMLElement;
|
|
626
|
+
/** Whether the event is over a header cell */
|
|
627
|
+
isHeader: boolean;
|
|
628
|
+
/** Cell coordinates if over a valid data cell */
|
|
629
|
+
cell?: CellCoords;
|
|
630
|
+
/** The original mouse event */
|
|
631
|
+
originalEvent: MouseEvent;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/** Public representation of a cell range (for events) */
|
|
635
|
+
export declare interface CellRange {
|
|
636
|
+
/** Starting cell coordinates */
|
|
637
|
+
from: {
|
|
638
|
+
row: number;
|
|
639
|
+
col: number;
|
|
640
|
+
};
|
|
641
|
+
/** Ending cell coordinates */
|
|
642
|
+
to: {
|
|
643
|
+
row: number;
|
|
644
|
+
col: number;
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Context passed to custom view renderers (pure display – no commit helpers).
|
|
650
|
+
*/
|
|
651
|
+
export declare interface CellRenderContext<TRow = any, TValue = any> {
|
|
652
|
+
/** Row object for the cell being rendered. */
|
|
653
|
+
row: TRow;
|
|
654
|
+
/** Value at field. */
|
|
655
|
+
value: TValue;
|
|
656
|
+
/** Field key. */
|
|
657
|
+
field: keyof TRow & string;
|
|
658
|
+
/** Column configuration reference. */
|
|
659
|
+
column: ColumnConfig<TRow>;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Cell renderer function type for plugins.
|
|
664
|
+
*/
|
|
665
|
+
export declare type CellRenderer = (ctx: PluginCellRenderContext) => string | HTMLElement;
|
|
666
|
+
|
|
667
|
+
/** Emitted when the changed rows tracking set is cleared programmatically. */
|
|
668
|
+
export declare interface ChangedRowsResetDetail<TRow = any> {
|
|
669
|
+
/** New (empty) changed rows array after reset. */
|
|
670
|
+
rows: TRow[];
|
|
671
|
+
/** Parallel indices (likely empty). */
|
|
672
|
+
indices: number[];
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Full column configuration including optional custom view/renderer & grouping metadata.
|
|
677
|
+
*/
|
|
678
|
+
export declare interface ColumnConfig<TRow = any> extends BaseColumnConfig<TRow, any> {
|
|
679
|
+
/** Optional custom view renderer used instead of default text rendering */
|
|
680
|
+
viewRenderer?: ColumnViewRenderer<TRow, any>;
|
|
681
|
+
/** External view spec (lets host app mount any framework component) */
|
|
682
|
+
externalView?: {
|
|
683
|
+
component: any;
|
|
684
|
+
props?: Record<string, any>;
|
|
685
|
+
mount?: (options: {
|
|
686
|
+
placeholder: HTMLElement;
|
|
687
|
+
context: CellRenderContext<TRow, any>;
|
|
688
|
+
spec: any;
|
|
689
|
+
}) => void | {
|
|
690
|
+
dispose?: () => void;
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
/** Whether the column is initially hidden */
|
|
694
|
+
hidden?: boolean;
|
|
695
|
+
/** Prevent this column from being hidden by the visibility plugin */
|
|
696
|
+
lockVisible?: boolean;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
export declare type ColumnConfigMap<TRow = any> = ColumnConfig<TRow>[];
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Context object provided to editor factories allowing mutation (commit/cancel) of a cell value.
|
|
703
|
+
*/
|
|
704
|
+
export declare interface ColumnEditorContext<TRow = any, TValue = any> {
|
|
705
|
+
/** Underlying full row object for the active edit. */
|
|
706
|
+
row: TRow;
|
|
707
|
+
/** Current cell value (mutable only via commit). */
|
|
708
|
+
value: TValue;
|
|
709
|
+
/** Field name being edited. */
|
|
710
|
+
field: keyof TRow & string;
|
|
711
|
+
/** Column configuration reference. */
|
|
712
|
+
column: ColumnConfig<TRow>;
|
|
713
|
+
/** Accept the edit; triggers change tracking + rerender. */
|
|
714
|
+
commit: (newValue: TValue) => void;
|
|
715
|
+
/** Abort edit without persisting changes. */
|
|
716
|
+
cancel: () => void;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/** External editor spec: tag name, factory function, or external mount spec */
|
|
720
|
+
export declare type ColumnEditorSpec<TRow = any, TValue = any> = string | ((context: ColumnEditorContext<TRow, TValue>) => HTMLElement | string) | {
|
|
721
|
+
/** Arbitrary component reference (class, function, token) */
|
|
722
|
+
component: any;
|
|
723
|
+
/** Optional static props passed to mount */
|
|
724
|
+
props?: Record<string, any>;
|
|
725
|
+
/** Optional custom mount function; if provided we call it directly instead of emitting an event */
|
|
726
|
+
mount?: (options: {
|
|
727
|
+
placeholder: HTMLElement;
|
|
728
|
+
context: ColumnEditorContext<TRow, TValue>;
|
|
729
|
+
spec: any;
|
|
730
|
+
}) => void | {
|
|
731
|
+
dispose?: () => void;
|
|
732
|
+
};
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
declare interface ColumnInternal<T = any> extends ColumnConfig<T> {
|
|
736
|
+
__autoSized?: boolean;
|
|
737
|
+
__userResized?: boolean;
|
|
738
|
+
__renderedWidth?: number;
|
|
739
|
+
__viewTemplate?: HTMLElement;
|
|
740
|
+
__editorTemplate?: HTMLElement;
|
|
741
|
+
__headerTemplate?: HTMLElement;
|
|
742
|
+
__compiledView?: (ctx: CellContext<T>) => string;
|
|
743
|
+
__compiledEditor?: (ctx: EditorExecContext<T>) => string;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** Column resize event detail containing final pixel width. */
|
|
747
|
+
export declare interface ColumnResizeDetail {
|
|
748
|
+
/** Resized column field key. */
|
|
749
|
+
field: string;
|
|
750
|
+
/** New width in pixels. */
|
|
751
|
+
width: number;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Sort state for a column
|
|
756
|
+
*/
|
|
757
|
+
export declare interface ColumnSortState {
|
|
758
|
+
/** Sort direction */
|
|
759
|
+
direction: 'asc' | 'desc';
|
|
760
|
+
/** Priority for multi-sort (0 = primary, 1 = secondary, etc.) */
|
|
761
|
+
priority: number;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* State for a single column. Captures user-driven changes at runtime.
|
|
766
|
+
* Plugins can extend this interface via module augmentation to add their own state.
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```ts
|
|
770
|
+
* // In filtering plugin
|
|
771
|
+
* declare module '@toolbox-web/grid' {
|
|
772
|
+
* interface ColumnState {
|
|
773
|
+
* filter?: FilterValue;
|
|
774
|
+
* }
|
|
775
|
+
* }
|
|
776
|
+
* ```
|
|
777
|
+
*/
|
|
778
|
+
export declare interface ColumnState {
|
|
779
|
+
/** Column field identifier */
|
|
780
|
+
field: string;
|
|
781
|
+
/** Position index after reordering (0-based) */
|
|
782
|
+
order: number;
|
|
783
|
+
/** Width in pixels (undefined = use default) */
|
|
784
|
+
width?: number;
|
|
785
|
+
/** Visibility state */
|
|
786
|
+
visible: boolean;
|
|
787
|
+
/** Sort state (undefined = not sorted) */
|
|
788
|
+
sort?: ColumnSortState;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
export declare type ColumnViewRenderer<TRow = any, TValue = any> = (ctx: CellRenderContext<TRow, TValue>) => Node | string | void;
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Context menu item
|
|
795
|
+
*/
|
|
796
|
+
export declare interface ContextMenuItem {
|
|
797
|
+
id: string;
|
|
798
|
+
label: string;
|
|
799
|
+
icon?: string;
|
|
800
|
+
disabled?: boolean;
|
|
801
|
+
separator?: boolean;
|
|
802
|
+
children?: ContextMenuItem[];
|
|
803
|
+
action?: (params: ContextMenuParams) => void;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Context menu parameters
|
|
808
|
+
*/
|
|
809
|
+
export declare interface ContextMenuParams {
|
|
810
|
+
x: number;
|
|
811
|
+
y: number;
|
|
812
|
+
rowIndex?: number;
|
|
813
|
+
colIndex?: number;
|
|
814
|
+
field?: string;
|
|
815
|
+
value?: any;
|
|
816
|
+
row?: any;
|
|
817
|
+
column?: ColumnConfig;
|
|
818
|
+
isHeader?: boolean;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
export declare type DataGridCustomEvent<K extends keyof DataGridEventMap<any>, TRow = any> = CustomEvent<DataGridEventMap<TRow>[K]>;
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* High-performance data grid web component.
|
|
825
|
+
* During migration, uses tbw-grid tag to avoid conflicts with existing datagrid.
|
|
826
|
+
* Will be renamed back to data-grid when migration is complete.
|
|
827
|
+
*
|
|
828
|
+
* ## Configuration Architecture
|
|
829
|
+
*
|
|
830
|
+
* The grid follows a **single source of truth** pattern where all configuration
|
|
831
|
+
* converges into `#effectiveConfig`. Users can set configuration via multiple inputs:
|
|
832
|
+
*
|
|
833
|
+
* **Input Sources (precedence low → high):**
|
|
834
|
+
* 1. `gridConfig` property - base configuration object
|
|
835
|
+
* 2. Light DOM elements:
|
|
836
|
+
* - `<tbw-grid-column>` → `effectiveConfig.columns`
|
|
837
|
+
* - `<tbw-grid-header title="...">` → `effectiveConfig.shell.header.title`
|
|
838
|
+
* - `<tbw-grid-header-content>` → `effectiveConfig.shell.header.content`
|
|
839
|
+
* 3. `columns` property → merged into `effectiveConfig.columns`
|
|
840
|
+
* 4. `fitMode` property → merged into `effectiveConfig.fitMode`
|
|
841
|
+
* 5. `editOn` property → merged into `effectiveConfig.editOn`
|
|
842
|
+
* 6. Column inference from first row (if no columns defined)
|
|
843
|
+
*
|
|
844
|
+
* **Derived State:**
|
|
845
|
+
* - `_columns` - processed columns from `effectiveConfig.columns` after plugin hooks
|
|
846
|
+
* - `_rows` - processed rows after plugin hooks (grouping, filtering, etc.)
|
|
847
|
+
*
|
|
848
|
+
* The `#mergeEffectiveConfig()` method is the single place where all inputs converge.
|
|
849
|
+
* All rendering and logic should read from `effectiveConfig` or derived state.
|
|
850
|
+
*
|
|
851
|
+
* @element tbw-grid
|
|
852
|
+
*
|
|
853
|
+
* @csspart container - The main grid container
|
|
854
|
+
* @csspart header - The header row container
|
|
855
|
+
* @csspart body - The body/rows container
|
|
856
|
+
*
|
|
857
|
+
* @fires cell-commit - Fired when a cell value is committed
|
|
858
|
+
* @fires row-commit - Fired when a bulk row edit session commits
|
|
859
|
+
* @fires changed-rows-reset - Fired after resetChangedRows() unless silent
|
|
860
|
+
* @fires mount-external-view - Fired to request mounting of an external view renderer
|
|
861
|
+
* @fires mount-external-editor - Fired to request mounting of an external editor renderer
|
|
862
|
+
* @fires sort-change - Fired when sort state changes for a column
|
|
863
|
+
* @fires column-resize - Fired after a column resize drag completes
|
|
864
|
+
* @fires activate-cell - Fired when a cell activation intent occurs
|
|
865
|
+
* @fires group-toggle - Fired when a group row is toggled
|
|
866
|
+
*
|
|
867
|
+
* @cssprop --tbw-color-bg - Background color
|
|
868
|
+
* @cssprop --tbw-color-fg - Foreground/text color
|
|
869
|
+
*/
|
|
870
|
+
export declare class DataGridElement<T = any> extends HTMLElement implements InternalGrid<T> {
|
|
871
|
+
#private;
|
|
872
|
+
static readonly tagName = "tbw-grid";
|
|
873
|
+
_rows: T[];
|
|
874
|
+
get _columns(): ColumnInternal<T>[];
|
|
875
|
+
set _columns(value: ColumnInternal<T>[]);
|
|
876
|
+
get visibleColumns(): ColumnInternal<T>[];
|
|
877
|
+
rowPool: HTMLElement[];
|
|
878
|
+
__rowRenderEpoch: number;
|
|
879
|
+
activeEditRows: number;
|
|
880
|
+
resizeController: ResizeController;
|
|
881
|
+
__didInitialAutoSize: boolean;
|
|
882
|
+
__lightDomColumnsCache?: ColumnInternal[];
|
|
883
|
+
__originalColumnNodes?: HTMLElement[];
|
|
884
|
+
headerRowEl: HTMLElement;
|
|
885
|
+
bodyEl: HTMLElement;
|
|
886
|
+
virtualization: VirtualState;
|
|
887
|
+
sortState: {
|
|
888
|
+
field: string;
|
|
889
|
+
direction: 1 | -1;
|
|
890
|
+
} | null;
|
|
891
|
+
__originalOrder: T[];
|
|
892
|
+
focusRow: number;
|
|
893
|
+
focusCol: number;
|
|
894
|
+
gridTemplate: string;
|
|
895
|
+
rowEditSnapshots: Map<number, T>;
|
|
896
|
+
_changedRowIndices: Set<number>;
|
|
897
|
+
get rows(): T[];
|
|
898
|
+
set rows(value: T[]);
|
|
899
|
+
/**
|
|
900
|
+
* Get the original unfiltered/unprocessed rows.
|
|
901
|
+
* Use this when you need access to all source data regardless of active filters.
|
|
902
|
+
*/
|
|
903
|
+
get sourceRows(): T[];
|
|
904
|
+
get columns(): ColumnConfig<T>[];
|
|
905
|
+
set columns(value: ColumnConfig<T>[] | ColumnConfigMap<T> | undefined);
|
|
906
|
+
get gridConfig(): GridConfig<T>;
|
|
907
|
+
set gridConfig(value: GridConfig<T> | undefined);
|
|
908
|
+
get fitMode(): FitMode;
|
|
909
|
+
set fitMode(value: FitMode | undefined);
|
|
910
|
+
get editOn(): string | undefined;
|
|
911
|
+
set editOn(value: string | undefined);
|
|
912
|
+
get effectiveConfig(): GridConfig<T>;
|
|
913
|
+
constructor();
|
|
914
|
+
/**
|
|
915
|
+
* Get a plugin instance by its class.
|
|
916
|
+
* Used by plugins for inter-plugin communication.
|
|
917
|
+
*/
|
|
918
|
+
getPlugin<P extends BaseGridPlugin>(PluginClass: new (...args: any[]) => P): P | undefined;
|
|
919
|
+
/**
|
|
920
|
+
* Get a plugin instance by its name.
|
|
921
|
+
* Used for loose coupling between plugins (avoids static imports).
|
|
922
|
+
*/
|
|
923
|
+
getPluginByName(name: string): BaseGridPlugin | undefined;
|
|
924
|
+
/**
|
|
925
|
+
* Request a full re-render of the grid.
|
|
926
|
+
* Called by plugins when they need the grid to update.
|
|
927
|
+
* Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
|
|
928
|
+
*/
|
|
929
|
+
requestRender(): void;
|
|
930
|
+
/**
|
|
931
|
+
* Request a lightweight style update without rebuilding DOM.
|
|
932
|
+
* Called by plugins when they only need to update CSS classes/styles.
|
|
933
|
+
* This runs all plugin afterRender hooks without rebuilding row/column DOM.
|
|
934
|
+
*/
|
|
935
|
+
requestAfterRender(): void;
|
|
936
|
+
connectedCallback(): void;
|
|
937
|
+
disconnectedCallback(): void;
|
|
938
|
+
emitCellCommit(detail: CellCommitDetail<T>): void;
|
|
939
|
+
emitRowCommit(detail: RowCommitDetail<T>): void;
|
|
940
|
+
emitSortChange(detail: SortChangeDetail): void;
|
|
941
|
+
emitColumnResize(detail: ColumnResizeDetail): void;
|
|
942
|
+
emitActivateCell(detail: ActivateCellDetail): void;
|
|
943
|
+
updateTemplate(): void;
|
|
944
|
+
findHeaderRow(): HTMLElement;
|
|
945
|
+
findRenderedRowElement(rowIndex: number): HTMLElement | null;
|
|
946
|
+
/**
|
|
947
|
+
* Dispatch a cell click event to the plugin system.
|
|
948
|
+
* Returns true if any plugin handled the event.
|
|
949
|
+
*/
|
|
950
|
+
dispatchCellClick(event: MouseEvent, rowIndex: number, colIndex: number, cellEl: HTMLElement): boolean;
|
|
951
|
+
/**
|
|
952
|
+
* Dispatch a header click event to the plugin system.
|
|
953
|
+
* Returns true if any plugin handled the event.
|
|
954
|
+
*/
|
|
955
|
+
dispatchHeaderClick(event: MouseEvent, colIndex: number, headerEl: HTMLElement): boolean;
|
|
956
|
+
/**
|
|
957
|
+
* Dispatch a keyboard event to the plugin system.
|
|
958
|
+
* Returns true if any plugin handled the event.
|
|
959
|
+
*/
|
|
960
|
+
dispatchKeyDown(event: KeyboardEvent): boolean;
|
|
961
|
+
get changedRows(): T[];
|
|
962
|
+
get changedRowIndices(): number[];
|
|
963
|
+
resetChangedRows(silent?: boolean): Promise<void>;
|
|
964
|
+
beginBulkEdit(rowIndex: number): Promise<void>;
|
|
965
|
+
commitActiveRowEdit(): Promise<void>;
|
|
966
|
+
ready(): Promise<void>;
|
|
967
|
+
forceLayout(): Promise<void>;
|
|
968
|
+
/** Public method: returns a frozen snapshot of the merged effective configuration */
|
|
969
|
+
getConfig(): Promise<Readonly<GridConfig<T>>>;
|
|
970
|
+
/**
|
|
971
|
+
* Set the visibility of a column.
|
|
972
|
+
* @param field - The field name of the column
|
|
973
|
+
* @param visible - Whether the column should be visible
|
|
974
|
+
* @returns True if visibility was changed, false if column not found or locked
|
|
975
|
+
*/
|
|
976
|
+
setColumnVisible(field: string, visible: boolean): boolean;
|
|
977
|
+
/**
|
|
978
|
+
* Toggle the visibility of a column.
|
|
979
|
+
* @param field - The field name of the column
|
|
980
|
+
* @returns True if visibility was toggled, false if column not found or locked
|
|
981
|
+
*/
|
|
982
|
+
toggleColumnVisibility(field: string): boolean;
|
|
983
|
+
/**
|
|
984
|
+
* Check if a column is currently visible.
|
|
985
|
+
* @param field - The field name of the column
|
|
986
|
+
* @returns True if visible, false if hidden or not found
|
|
987
|
+
*/
|
|
988
|
+
isColumnVisible(field: string): boolean;
|
|
989
|
+
/**
|
|
990
|
+
* Show all columns.
|
|
991
|
+
*/
|
|
992
|
+
showAllColumns(): void;
|
|
993
|
+
/**
|
|
994
|
+
* Get list of all column fields (including hidden).
|
|
995
|
+
* Returns columns reflecting current display order (after reordering).
|
|
996
|
+
* Hidden columns are interleaved at their original relative positions.
|
|
997
|
+
* @returns Array of all field names with their visibility status
|
|
998
|
+
*/
|
|
999
|
+
getAllColumns(): Array<{
|
|
1000
|
+
field: string;
|
|
1001
|
+
header: string;
|
|
1002
|
+
visible: boolean;
|
|
1003
|
+
lockVisible?: boolean;
|
|
1004
|
+
}>;
|
|
1005
|
+
/**
|
|
1006
|
+
* Reorder columns according to the specified field order.
|
|
1007
|
+
* This directly updates _columns in place without going through processColumns.
|
|
1008
|
+
* @param order - Array of field names in the desired order
|
|
1009
|
+
*/
|
|
1010
|
+
setColumnOrder(order: string[]): void;
|
|
1011
|
+
/**
|
|
1012
|
+
* Get the current column order as an array of field names.
|
|
1013
|
+
* @returns Array of field names in display order
|
|
1014
|
+
*/
|
|
1015
|
+
getColumnOrder(): string[];
|
|
1016
|
+
/**
|
|
1017
|
+
* Get the current column state, including order, width, visibility, sort, and plugin state.
|
|
1018
|
+
* Returns a serializable object suitable for localStorage or database storage.
|
|
1019
|
+
*/
|
|
1020
|
+
getColumnState(): GridColumnState;
|
|
1021
|
+
/**
|
|
1022
|
+
* Set the column state, restoring order, width, visibility, sort, and plugin state.
|
|
1023
|
+
* Use this to restore previously saved column state.
|
|
1024
|
+
*/
|
|
1025
|
+
set columnState(state: GridColumnState | undefined);
|
|
1026
|
+
/**
|
|
1027
|
+
* Get the current column state.
|
|
1028
|
+
*/
|
|
1029
|
+
get columnState(): GridColumnState | undefined;
|
|
1030
|
+
/**
|
|
1031
|
+
* Request a state change event to be emitted.
|
|
1032
|
+
* Called internally after resize, reorder, visibility, or sort changes.
|
|
1033
|
+
* Plugins should call this after changing their state.
|
|
1034
|
+
* The event is debounced to avoid excessive events during drag operations.
|
|
1035
|
+
*/
|
|
1036
|
+
requestStateChange(): void;
|
|
1037
|
+
/**
|
|
1038
|
+
* Reset column state to initial configuration.
|
|
1039
|
+
* Clears all user modifications (order, width, visibility, sort).
|
|
1040
|
+
*/
|
|
1041
|
+
resetColumnState(): void;
|
|
1042
|
+
/**
|
|
1043
|
+
* Get the currently active tool panel ID, or null if none is open.
|
|
1044
|
+
*/
|
|
1045
|
+
get activeToolPanel(): string | null;
|
|
1046
|
+
/**
|
|
1047
|
+
* Open a tool panel by ID.
|
|
1048
|
+
* Closes any currently open panel first.
|
|
1049
|
+
*/
|
|
1050
|
+
openToolPanel(panelId: string): void;
|
|
1051
|
+
/**
|
|
1052
|
+
* Close the currently open tool panel.
|
|
1053
|
+
*/
|
|
1054
|
+
closeToolPanel(): void;
|
|
1055
|
+
/**
|
|
1056
|
+
* Toggle a tool panel open/closed.
|
|
1057
|
+
*/
|
|
1058
|
+
toggleToolPanel(panelId: string): void;
|
|
1059
|
+
/**
|
|
1060
|
+
* Get registered tool panel definitions.
|
|
1061
|
+
*/
|
|
1062
|
+
getToolPanels(): ToolPanelDefinition[];
|
|
1063
|
+
/**
|
|
1064
|
+
* Register a custom tool panel (without creating a plugin).
|
|
1065
|
+
*/
|
|
1066
|
+
registerToolPanel(panel: ToolPanelDefinition): void;
|
|
1067
|
+
/**
|
|
1068
|
+
* Unregister a custom tool panel.
|
|
1069
|
+
*/
|
|
1070
|
+
unregisterToolPanel(panelId: string): void;
|
|
1071
|
+
/**
|
|
1072
|
+
* Get registered header content definitions.
|
|
1073
|
+
*/
|
|
1074
|
+
getHeaderContents(): HeaderContentDefinition[];
|
|
1075
|
+
/**
|
|
1076
|
+
* Register custom header content (without creating a plugin).
|
|
1077
|
+
*/
|
|
1078
|
+
registerHeaderContent(content: HeaderContentDefinition): void;
|
|
1079
|
+
/**
|
|
1080
|
+
* Unregister custom header content.
|
|
1081
|
+
*/
|
|
1082
|
+
unregisterHeaderContent(contentId: string): void;
|
|
1083
|
+
/**
|
|
1084
|
+
* Get all registered toolbar buttons.
|
|
1085
|
+
*/
|
|
1086
|
+
getToolbarButtons(): ToolbarButtonInfo[];
|
|
1087
|
+
/**
|
|
1088
|
+
* Register a custom toolbar button programmatically.
|
|
1089
|
+
*/
|
|
1090
|
+
registerToolbarButton(button: ToolbarButtonConfig): void;
|
|
1091
|
+
/**
|
|
1092
|
+
* Unregister a custom toolbar button.
|
|
1093
|
+
*/
|
|
1094
|
+
unregisterToolbarButton(buttonId: string): void;
|
|
1095
|
+
/**
|
|
1096
|
+
* Enable/disable a toolbar button by ID.
|
|
1097
|
+
*/
|
|
1098
|
+
setToolbarButtonDisabled(buttonId: string, disabled: boolean): void;
|
|
1099
|
+
/**
|
|
1100
|
+
* Re-parse light DOM shell elements and refresh shell header.
|
|
1101
|
+
* Call this after dynamically modifying <tbw-grid-header> children.
|
|
1102
|
+
*/
|
|
1103
|
+
refreshShellHeader(): void;
|
|
1104
|
+
/**
|
|
1105
|
+
* Core virtualization routine. Chooses between bypass (small datasets), grouped window rendering,
|
|
1106
|
+
* or standard row window rendering.
|
|
1107
|
+
*/
|
|
1108
|
+
refreshVirtualWindow(force?: boolean): void;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* The compiled webcomponent interface for DataGrid
|
|
1113
|
+
*/
|
|
1114
|
+
export declare interface DataGridElementInterface extends PublicGrid, HTMLElement {
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
export declare interface DataGridEventMap<TRow = any> {
|
|
1118
|
+
'cell-commit': CellCommitDetail<TRow>;
|
|
1119
|
+
'row-commit': RowCommitDetail<TRow>;
|
|
1120
|
+
'changed-rows-reset': ChangedRowsResetDetail<TRow>;
|
|
1121
|
+
'mount-external-view': ExternalMountViewDetail<TRow>;
|
|
1122
|
+
'mount-external-editor': ExternalMountEditorDetail<TRow>;
|
|
1123
|
+
'sort-change': SortChangeDetail;
|
|
1124
|
+
'column-resize': ColumnResizeDetail;
|
|
1125
|
+
'activate-cell': ActivateCellDetail;
|
|
1126
|
+
'column-state-change': GridColumnState;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
export declare type DGEventName = (typeof DGEvents)[keyof typeof DGEvents];
|
|
1130
|
+
|
|
1131
|
+
export declare const DGEvents: {
|
|
1132
|
+
readonly CELL_COMMIT: "cell-commit";
|
|
1133
|
+
readonly ROW_COMMIT: "row-commit";
|
|
1134
|
+
readonly CHANGED_ROWS_RESET: "changed-rows-reset";
|
|
1135
|
+
readonly MOUNT_EXTERNAL_VIEW: "mount-external-view";
|
|
1136
|
+
readonly MOUNT_EXTERNAL_EDITOR: "mount-external-editor";
|
|
1137
|
+
readonly SORT_CHANGE: "sort-change";
|
|
1138
|
+
readonly COLUMN_RESIZE: "column-resize";
|
|
1139
|
+
readonly ACTIVATE_CELL: "activate-cell";
|
|
1140
|
+
readonly GROUP_TOGGLE: "group-toggle";
|
|
1141
|
+
readonly COLUMN_STATE_CHANGE: "column-state-change";
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
/** Represents a single edit action that can be undone/redone */
|
|
1145
|
+
export declare interface EditAction {
|
|
1146
|
+
/** Type of action - currently only 'cell-edit' is supported */
|
|
1147
|
+
type: 'cell-edit';
|
|
1148
|
+
/** The row index where the edit occurred */
|
|
1149
|
+
rowIndex: number;
|
|
1150
|
+
/** The field (column key) that was edited */
|
|
1151
|
+
field: string;
|
|
1152
|
+
/** The value before the edit */
|
|
1153
|
+
oldValue: unknown;
|
|
1154
|
+
/** The value after the edit */
|
|
1155
|
+
newValue: unknown;
|
|
1156
|
+
/** Unix timestamp when the edit occurred */
|
|
1157
|
+
timestamp: number;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Internal editor execution context extending the generic cell context with commit helpers.
|
|
1162
|
+
*/
|
|
1163
|
+
declare interface EditorExecContext<T = any> extends CellContext<T> {
|
|
1164
|
+
commit: (newValue: any) => void;
|
|
1165
|
+
cancel: () => void;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Export Plugin Types
|
|
1170
|
+
*
|
|
1171
|
+
* Type definitions for the data export feature.
|
|
1172
|
+
*/
|
|
1173
|
+
/** Supported export formats */
|
|
1174
|
+
export declare type ExportFormat = 'csv' | 'excel' | 'json';
|
|
1175
|
+
|
|
1176
|
+
/** Parameters for a specific export operation */
|
|
1177
|
+
export declare interface ExportParams {
|
|
1178
|
+
/** Export format */
|
|
1179
|
+
format: ExportFormat;
|
|
1180
|
+
/** File name for the export (without extension) */
|
|
1181
|
+
fileName?: string;
|
|
1182
|
+
/** Specific column fields to export */
|
|
1183
|
+
columns?: string[];
|
|
1184
|
+
/** Specific row indices to export */
|
|
1185
|
+
rowIndices?: number[];
|
|
1186
|
+
/** Include column headers in export */
|
|
1187
|
+
includeHeaders?: boolean;
|
|
1188
|
+
/** Custom cell value processor */
|
|
1189
|
+
processCell?: (value: any, field: string, row: any) => any;
|
|
1190
|
+
/** Custom header processor */
|
|
1191
|
+
processHeader?: (header: string, field: string) => string;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
export declare interface ExternalMountEditorDetail<TRow = any> {
|
|
1195
|
+
placeholder: HTMLElement;
|
|
1196
|
+
spec: any;
|
|
1197
|
+
context: {
|
|
1198
|
+
row: TRow;
|
|
1199
|
+
value: any;
|
|
1200
|
+
field: string;
|
|
1201
|
+
column: any;
|
|
1202
|
+
commit: (v: any) => void;
|
|
1203
|
+
cancel: () => void;
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
export declare interface ExternalMountViewDetail<TRow = any> {
|
|
1208
|
+
placeholder: HTMLElement;
|
|
1209
|
+
spec: any;
|
|
1210
|
+
context: {
|
|
1211
|
+
row: TRow;
|
|
1212
|
+
value: any;
|
|
1213
|
+
field: string;
|
|
1214
|
+
column: any;
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/** Configuration options for the filtering plugin */
|
|
1219
|
+
export declare interface FilterConfig {
|
|
1220
|
+
/** Whether filtering is enabled (default: true) */
|
|
1221
|
+
enabled?: boolean;
|
|
1222
|
+
/** Debounce delay in ms for filter input (default: 300) */
|
|
1223
|
+
debounceMs?: number;
|
|
1224
|
+
/** Whether text filtering is case sensitive (default: false) */
|
|
1225
|
+
caseSensitive?: boolean;
|
|
1226
|
+
/** Whether to trim whitespace from filter input (default: true) */
|
|
1227
|
+
trimInput?: boolean;
|
|
1228
|
+
/** Use Web Worker for filtering large datasets >1000 rows (default: true) */
|
|
1229
|
+
useWorker?: boolean;
|
|
1230
|
+
/** Custom filter panel renderer (replaces default panel content) */
|
|
1231
|
+
filterPanelRenderer?: FilterPanelRenderer;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/** Filter model representing a single filter condition */
|
|
1235
|
+
export declare interface FilterModel {
|
|
1236
|
+
/** The field/column to filter on */
|
|
1237
|
+
field: string;
|
|
1238
|
+
/** The type of filter */
|
|
1239
|
+
type: FilterType;
|
|
1240
|
+
/** The filter operator */
|
|
1241
|
+
operator: FilterOperator;
|
|
1242
|
+
/** The filter value (type depends on operator) */
|
|
1243
|
+
value: unknown;
|
|
1244
|
+
/** Secondary value for 'between' operator */
|
|
1245
|
+
valueTo?: unknown;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/** Filter operators for different filter types */
|
|
1249
|
+
export declare type FilterOperator = 'contains' | 'notContains' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'blank' | 'notBlank' | 'lessThan' | 'lessThanOrEqual' | 'greaterThan' | 'greaterThanOrEqual' | 'between' | 'in' | 'notIn';
|
|
1250
|
+
|
|
1251
|
+
/** Parameters passed to custom filter panel renderer */
|
|
1252
|
+
declare interface FilterPanelParams {
|
|
1253
|
+
/** The field being filtered */
|
|
1254
|
+
field: string;
|
|
1255
|
+
/** The column configuration */
|
|
1256
|
+
column: ColumnConfig;
|
|
1257
|
+
/** All unique values for this field */
|
|
1258
|
+
uniqueValues: unknown[];
|
|
1259
|
+
/** Currently excluded values (for set filter) */
|
|
1260
|
+
excludedValues: Set<unknown>;
|
|
1261
|
+
/** Current search text */
|
|
1262
|
+
searchText: string;
|
|
1263
|
+
/** Apply a set filter (exclude these values) */
|
|
1264
|
+
applySetFilter: (excludedValues: unknown[]) => void;
|
|
1265
|
+
/** Apply a text filter */
|
|
1266
|
+
applyTextFilter: (operator: FilterOperator, value: string, valueTo?: string) => void;
|
|
1267
|
+
/** Clear the filter for this field */
|
|
1268
|
+
clearFilter: () => void;
|
|
1269
|
+
/** Close the filter panel */
|
|
1270
|
+
closePanel: () => void;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/** Custom filter panel renderer function. Return undefined to use default panel for this column. */
|
|
1274
|
+
declare type FilterPanelRenderer = (container: HTMLElement, params: FilterPanelParams) => void | undefined;
|
|
1275
|
+
|
|
1276
|
+
/** Supported filter types */
|
|
1277
|
+
export declare type FilterType = 'text' | 'number' | 'date' | 'set' | 'boolean';
|
|
1278
|
+
|
|
1279
|
+
export declare type FitMode = (typeof FitModeEnum)[keyof typeof FitModeEnum];
|
|
1280
|
+
|
|
1281
|
+
export declare const FitModeEnum: {
|
|
1282
|
+
readonly STRETCH: "stretch";
|
|
1283
|
+
readonly FIXED: "fixed";
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
/** A flattened tree row with hierarchy metadata */
|
|
1287
|
+
declare interface FlattenedTreeRow {
|
|
1288
|
+
/** Unique key identifying this row */
|
|
1289
|
+
key: string;
|
|
1290
|
+
/** Original row data */
|
|
1291
|
+
data: any;
|
|
1292
|
+
/** Depth level in the tree (0 = root) */
|
|
1293
|
+
depth: number;
|
|
1294
|
+
/** Whether this row has children */
|
|
1295
|
+
hasChildren: boolean;
|
|
1296
|
+
/** Whether this row is currently expanded */
|
|
1297
|
+
isExpanded: boolean;
|
|
1298
|
+
/** Key of the parent row, or null for root level */
|
|
1299
|
+
parentKey: string | null;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
export declare const getAggregator: (ref: AggregatorRef_2 | undefined) => AggregatorFn | undefined;
|
|
1303
|
+
|
|
1304
|
+
export declare interface GetRowsParams {
|
|
1305
|
+
startRow: number;
|
|
1306
|
+
endRow: number;
|
|
1307
|
+
sortModel?: Array<{
|
|
1308
|
+
field: string;
|
|
1309
|
+
direction: 'asc' | 'desc';
|
|
1310
|
+
}>;
|
|
1311
|
+
filterModel?: Record<string, any>;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
export declare interface GetRowsResult {
|
|
1315
|
+
rows: any[];
|
|
1316
|
+
totalRowCount: number;
|
|
1317
|
+
lastRow?: number;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* CSS class names used in the grid's shadow DOM.
|
|
1322
|
+
* Use these when adding/removing classes or querying elements.
|
|
1323
|
+
*/
|
|
1324
|
+
export declare const GridClasses: {
|
|
1325
|
+
readonly ROOT: "tbw-grid-root";
|
|
1326
|
+
readonly HEADER: "header";
|
|
1327
|
+
readonly HEADER_ROW: "header-row";
|
|
1328
|
+
readonly HEADER_CELL: "header-cell";
|
|
1329
|
+
readonly ROWS_VIEWPORT: "rows-viewport";
|
|
1330
|
+
readonly ROWS_SPACER: "rows-spacer";
|
|
1331
|
+
readonly ROWS_CONTAINER: "rows";
|
|
1332
|
+
readonly DATA_ROW: "data-row";
|
|
1333
|
+
readonly GROUP_ROW: "group-row";
|
|
1334
|
+
readonly DATA_CELL: "data-cell";
|
|
1335
|
+
readonly SELECTED: "selected";
|
|
1336
|
+
readonly FOCUSED: "focused";
|
|
1337
|
+
readonly EDITING: "editing";
|
|
1338
|
+
readonly EXPANDED: "expanded";
|
|
1339
|
+
readonly COLLAPSED: "collapsed";
|
|
1340
|
+
readonly DRAGGING: "dragging";
|
|
1341
|
+
readonly RESIZING: "resizing";
|
|
1342
|
+
readonly SORTABLE: "sortable";
|
|
1343
|
+
readonly SORTED_ASC: "sorted-asc";
|
|
1344
|
+
readonly SORTED_DESC: "sorted-desc";
|
|
1345
|
+
readonly HIDDEN: "hidden";
|
|
1346
|
+
readonly STICKY_LEFT: "sticky-left";
|
|
1347
|
+
readonly STICKY_RIGHT: "sticky-right";
|
|
1348
|
+
readonly PINNED_TOP: "pinned-top";
|
|
1349
|
+
readonly PINNED_BOTTOM: "pinned-bottom";
|
|
1350
|
+
readonly TREE_TOGGLE: "tree-toggle";
|
|
1351
|
+
readonly TREE_INDENT: "tree-indent";
|
|
1352
|
+
readonly GROUP_TOGGLE: "group-toggle";
|
|
1353
|
+
readonly GROUP_LABEL: "group-label";
|
|
1354
|
+
readonly GROUP_COUNT: "group-count";
|
|
1355
|
+
readonly RANGE_SELECTION: "range-selection";
|
|
1356
|
+
readonly SELECTION_OVERLAY: "selection-overlay";
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1359
|
+
export declare type GridClassName = (typeof GridClasses)[keyof typeof GridClasses];
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Complete grid column state for persistence.
|
|
1363
|
+
* Contains state for all columns, including plugin-contributed properties.
|
|
1364
|
+
*/
|
|
1365
|
+
export declare interface GridColumnState {
|
|
1366
|
+
columns: ColumnState[];
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
/**
|
|
1370
|
+
* Grid configuration object - the **single source of truth** for grid behavior.
|
|
1371
|
+
*
|
|
1372
|
+
* Users can configure the grid via multiple input methods, all of which converge
|
|
1373
|
+
* into an effective `GridConfig` internally:
|
|
1374
|
+
*
|
|
1375
|
+
* **Configuration Input Methods:**
|
|
1376
|
+
* - `gridConfig` property - direct assignment of this object
|
|
1377
|
+
* - `columns` property - shorthand for `gridConfig.columns`
|
|
1378
|
+
* - `fitMode` property - shorthand for `gridConfig.fitMode`
|
|
1379
|
+
* - `editOn` property - shorthand for `gridConfig.editOn`
|
|
1380
|
+
* - Light DOM `<tbw-grid-column>` - declarative columns (merged into `columns`)
|
|
1381
|
+
* - Light DOM `<tbw-grid-header>` - declarative shell header (merged into `shell.header`)
|
|
1382
|
+
*
|
|
1383
|
+
* **Precedence (when same property set multiple ways):**
|
|
1384
|
+
* Individual props (`fitMode`, `editOn`) > `columns` prop > Light DOM > `gridConfig`
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* // Via gridConfig (recommended for complex setups)
|
|
1389
|
+
* grid.gridConfig = {
|
|
1390
|
+
* columns: [{ field: 'name' }, { field: 'age' }],
|
|
1391
|
+
* fitMode: 'stretch',
|
|
1392
|
+
* plugins: [new SelectionPlugin()],
|
|
1393
|
+
* shell: { header: { title: 'My Grid' } }
|
|
1394
|
+
* };
|
|
1395
|
+
*
|
|
1396
|
+
* // Via individual props (convenience for simple cases)
|
|
1397
|
+
* grid.columns = [{ field: 'name' }, { field: 'age' }];
|
|
1398
|
+
* grid.fitMode = 'stretch';
|
|
1399
|
+
* ```
|
|
1400
|
+
*/
|
|
1401
|
+
export declare interface GridConfig<TRow = any> {
|
|
1402
|
+
/** Column definitions. Can also be set via `columns` prop or `<tbw-grid-column>` light DOM. */
|
|
1403
|
+
columns?: ColumnConfigMap<TRow>;
|
|
1404
|
+
/** Sizing mode for columns. Can also be set via `fitMode` prop. */
|
|
1405
|
+
fitMode?: FitMode;
|
|
1406
|
+
/** Edit activation mode ('click' | 'dblclick'). Can also be set via `editOn` prop. */
|
|
1407
|
+
editOn?: string;
|
|
1408
|
+
/**
|
|
1409
|
+
* Array of plugin instances.
|
|
1410
|
+
* Each plugin is instantiated with its configuration and attached to this grid.
|
|
1411
|
+
*
|
|
1412
|
+
* @example
|
|
1413
|
+
* ```ts
|
|
1414
|
+
* plugins: [
|
|
1415
|
+
* new SelectionPlugin({ mode: 'range' }),
|
|
1416
|
+
* new MultiSortPlugin(),
|
|
1417
|
+
* new FilteringPlugin({ debounceMs: 150 }),
|
|
1418
|
+
* ]
|
|
1419
|
+
* ```
|
|
1420
|
+
*/
|
|
1421
|
+
plugins?: any[];
|
|
1422
|
+
/**
|
|
1423
|
+
* Saved column state to restore on initialization.
|
|
1424
|
+
* Includes order, width, visibility, sort, and plugin-contributed state.
|
|
1425
|
+
*/
|
|
1426
|
+
columnState?: GridColumnState;
|
|
1427
|
+
/**
|
|
1428
|
+
* Shell configuration for header bar and tool panels.
|
|
1429
|
+
* When configured, adds an optional wrapper with title, toolbar, and collapsible side panels.
|
|
1430
|
+
*/
|
|
1431
|
+
shell?: ShellConfig;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
export declare type GridCSSVar = (typeof GridCSSVars)[keyof typeof GridCSSVars];
|
|
1435
|
+
|
|
1436
|
+
/**
|
|
1437
|
+
* CSS custom property names for theming.
|
|
1438
|
+
* Use these when programmatically setting styles.
|
|
1439
|
+
*/
|
|
1440
|
+
export declare const GridCSSVars: {
|
|
1441
|
+
readonly COLOR_BG: "--tbw-color-bg";
|
|
1442
|
+
readonly COLOR_FG: "--tbw-color-fg";
|
|
1443
|
+
readonly COLOR_FG_MUTED: "--tbw-color-fg-muted";
|
|
1444
|
+
readonly COLOR_BORDER: "--tbw-color-border";
|
|
1445
|
+
readonly COLOR_ACCENT: "--tbw-color-accent";
|
|
1446
|
+
readonly COLOR_HEADER_BG: "--tbw-color-header-bg";
|
|
1447
|
+
readonly COLOR_HEADER_FG: "--tbw-color-header-fg";
|
|
1448
|
+
readonly COLOR_SELECTION: "--tbw-color-selection";
|
|
1449
|
+
readonly COLOR_ROW_HOVER: "--tbw-color-row-hover";
|
|
1450
|
+
readonly COLOR_ROW_ALT: "--tbw-color-row-alt";
|
|
1451
|
+
readonly ROW_HEIGHT: "--tbw-row-height";
|
|
1452
|
+
readonly HEADER_HEIGHT: "--tbw-header-height";
|
|
1453
|
+
readonly CELL_PADDING: "--tbw-cell-padding";
|
|
1454
|
+
readonly FONT_FAMILY: "--tbw-font-family";
|
|
1455
|
+
readonly FONT_SIZE: "--tbw-font-size";
|
|
1456
|
+
readonly BORDER_RADIUS: "--tbw-border-radius";
|
|
1457
|
+
readonly FOCUS_OUTLINE: "--tbw-focus-outline";
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
export declare type GridDataAttr = (typeof GridDataAttrs)[keyof typeof GridDataAttrs];
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Data attribute names used on grid elements.
|
|
1464
|
+
* Use these when getting/setting data attributes.
|
|
1465
|
+
*/
|
|
1466
|
+
export declare const GridDataAttrs: {
|
|
1467
|
+
readonly ROW_INDEX: "data-row-index";
|
|
1468
|
+
readonly COL_INDEX: "data-col-index";
|
|
1469
|
+
readonly FIELD: "data-field";
|
|
1470
|
+
readonly GROUP_KEY: "data-group-key";
|
|
1471
|
+
readonly TREE_LEVEL: "data-tree-level";
|
|
1472
|
+
readonly STICKY: "data-sticky";
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1475
|
+
export declare interface GridElement {
|
|
1476
|
+
shadowRoot: ShadowRoot | null;
|
|
1477
|
+
rows: any[];
|
|
1478
|
+
columns: ColumnConfig[];
|
|
1479
|
+
gridConfig: any;
|
|
1480
|
+
requestRender(): void;
|
|
1481
|
+
requestAfterRender(): void;
|
|
1482
|
+
forceLayout(): Promise<void>;
|
|
1483
|
+
getPlugin<T extends BaseGridPlugin>(PluginClass: new (...args: any[]) => T): T | undefined;
|
|
1484
|
+
getPluginByName(name: string): BaseGridPlugin | undefined;
|
|
1485
|
+
dispatchEvent(event: Event): boolean;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* Common CSS selectors for querying grid elements.
|
|
1490
|
+
* Built from the class constants for consistency.
|
|
1491
|
+
*/
|
|
1492
|
+
export declare const GridSelectors: {
|
|
1493
|
+
readonly ROOT: ".tbw-grid-root";
|
|
1494
|
+
readonly HEADER: ".header";
|
|
1495
|
+
readonly HEADER_ROW: ".header-row";
|
|
1496
|
+
readonly HEADER_CELL: ".header-cell";
|
|
1497
|
+
readonly ROWS_VIEWPORT: ".rows-viewport";
|
|
1498
|
+
readonly ROWS_CONTAINER: ".rows";
|
|
1499
|
+
readonly DATA_ROW: ".data-row";
|
|
1500
|
+
readonly DATA_CELL: ".data-cell";
|
|
1501
|
+
readonly GROUP_ROW: ".group-row";
|
|
1502
|
+
readonly ROW_BY_INDEX: (index: number) => string;
|
|
1503
|
+
readonly CELL_BY_FIELD: (field: string) => string;
|
|
1504
|
+
readonly CELL_AT: (row: number, col: number) => string;
|
|
1505
|
+
readonly SELECTED_ROWS: ".data-row.selected";
|
|
1506
|
+
readonly EDITING_CELL: ".data-cell.editing";
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
/** Configuration options for the row grouping plugin */
|
|
1510
|
+
export declare interface GroupingRowsConfig {
|
|
1511
|
+
/** Whether the plugin is enabled (default: true) */
|
|
1512
|
+
enabled?: boolean;
|
|
1513
|
+
/**
|
|
1514
|
+
* Callback to determine group path for a row.
|
|
1515
|
+
* Return an array of group keys, a single key, null/false to skip grouping.
|
|
1516
|
+
*/
|
|
1517
|
+
groupOn?: (row: any) => any[] | any | null | false;
|
|
1518
|
+
/** Whether groups are expanded by default (default: false) */
|
|
1519
|
+
defaultExpanded?: boolean;
|
|
1520
|
+
/** Custom group row renderer */
|
|
1521
|
+
groupRowRenderer?: (params: GroupRowRenderParams) => HTMLElement | string | void;
|
|
1522
|
+
/** Show row count in group headers (default: true) */
|
|
1523
|
+
showRowCount?: boolean;
|
|
1524
|
+
/** Indent width per depth level in pixels (default: 20) */
|
|
1525
|
+
indentWidth?: number;
|
|
1526
|
+
/** Aggregators for group row cells by field name */
|
|
1527
|
+
aggregators?: AggregatorMap;
|
|
1528
|
+
/** Custom format function for group label */
|
|
1529
|
+
formatLabel?: (value: any, depth: number, key: string) => string;
|
|
1530
|
+
/** Whether to render group row as full-width spanning cell (default: true) */
|
|
1531
|
+
fullWidth?: boolean;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
/** Parameters passed to custom group row renderer */
|
|
1535
|
+
declare interface GroupRowRenderParams {
|
|
1536
|
+
/** The group key */
|
|
1537
|
+
key: string;
|
|
1538
|
+
/** The group value (last segment of path) */
|
|
1539
|
+
value: any;
|
|
1540
|
+
/** Depth level (0-based) */
|
|
1541
|
+
depth: number;
|
|
1542
|
+
/** All data rows in this group (including nested) */
|
|
1543
|
+
rows: any[];
|
|
1544
|
+
/** Whether the group is expanded */
|
|
1545
|
+
expanded: boolean;
|
|
1546
|
+
/** Toggle expand/collapse */
|
|
1547
|
+
toggleExpand: () => void;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Header click event
|
|
1552
|
+
*/
|
|
1553
|
+
export declare interface HeaderClickEvent {
|
|
1554
|
+
colIndex: number;
|
|
1555
|
+
field: string;
|
|
1556
|
+
column: ColumnConfig;
|
|
1557
|
+
headerEl: HTMLElement;
|
|
1558
|
+
originalEvent: MouseEvent;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* Header content definition for plugins contributing to shell header center section.
|
|
1563
|
+
*/
|
|
1564
|
+
export declare interface HeaderContentDefinition {
|
|
1565
|
+
/** Unique content ID */
|
|
1566
|
+
id: string;
|
|
1567
|
+
/** Content factory - called once when shell header renders */
|
|
1568
|
+
render: (container: HTMLElement) => void | (() => void);
|
|
1569
|
+
/** Called when content is removed (for cleanup) */
|
|
1570
|
+
onDestroy?: () => void;
|
|
1571
|
+
/** Order priority (lower = first, default: 100) */
|
|
1572
|
+
order?: number;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* Header renderer function type for plugins.
|
|
1577
|
+
*/
|
|
1578
|
+
export declare type HeaderRenderer = (ctx: PluginHeaderRenderContext) => string | HTMLElement;
|
|
1579
|
+
|
|
1580
|
+
/** Result of automatic column inference from sample rows. */
|
|
1581
|
+
export declare interface InferredColumnResult<TRow = any> {
|
|
1582
|
+
columns: ColumnConfigMap<TRow>;
|
|
1583
|
+
typeMap: Record<string, PrimitiveColumnType>;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
/**
|
|
1587
|
+
* Internal-only augmented interface for DataGrid component
|
|
1588
|
+
*/
|
|
1589
|
+
declare interface InternalGrid<T = any> extends PublicGrid<T>, GridConfig<T> {
|
|
1590
|
+
shadowRoot: ShadowRoot | null;
|
|
1591
|
+
_rows: T[];
|
|
1592
|
+
_columns: ColumnInternal<T>[];
|
|
1593
|
+
/** Visible columns only (excludes hidden). Use for rendering. */
|
|
1594
|
+
visibleColumns: ColumnInternal<T>[];
|
|
1595
|
+
headerRowEl: HTMLElement;
|
|
1596
|
+
bodyEl: HTMLElement;
|
|
1597
|
+
rowPool: HTMLElement[];
|
|
1598
|
+
resizeController: ResizeController;
|
|
1599
|
+
sortState: {
|
|
1600
|
+
field: string;
|
|
1601
|
+
direction: 1 | -1;
|
|
1602
|
+
} | null;
|
|
1603
|
+
__originalOrder: T[];
|
|
1604
|
+
__rowRenderEpoch: number;
|
|
1605
|
+
__didInitialAutoSize?: boolean;
|
|
1606
|
+
__lightDomColumnsCache?: ColumnInternal[];
|
|
1607
|
+
__originalColumnNodes?: HTMLElement[];
|
|
1608
|
+
gridTemplate: string;
|
|
1609
|
+
virtualization: VirtualState;
|
|
1610
|
+
focusRow: number;
|
|
1611
|
+
focusCol: number;
|
|
1612
|
+
activeEditRows: number;
|
|
1613
|
+
rowEditSnapshots: Map<number, any>;
|
|
1614
|
+
_changedRowIndices: Set<number>;
|
|
1615
|
+
changedRows?: T[];
|
|
1616
|
+
changedRowIndices?: number[];
|
|
1617
|
+
effectiveConfig?: GridConfig<T>;
|
|
1618
|
+
findHeaderRow?: () => HTMLElement;
|
|
1619
|
+
refreshVirtualWindow: (full: boolean) => void;
|
|
1620
|
+
updateTemplate?: () => void;
|
|
1621
|
+
findRenderedRowElement?: (rowIndex: number) => HTMLElement | null;
|
|
1622
|
+
beginBulkEdit?: (rowIndex: number) => void;
|
|
1623
|
+
commitActiveRowEdit?: () => void;
|
|
1624
|
+
/** Dispatch cell click to plugin system, returns true if handled */
|
|
1625
|
+
dispatchCellClick?: (event: MouseEvent, rowIndex: number, colIndex: number, cellEl: HTMLElement) => boolean;
|
|
1626
|
+
/** Dispatch header click to plugin system, returns true if handled */
|
|
1627
|
+
dispatchHeaderClick?: (event: MouseEvent, colIndex: number, headerEl: HTMLElement) => boolean;
|
|
1628
|
+
/** Dispatch keydown to plugin system, returns true if handled */
|
|
1629
|
+
dispatchKeyDown?: (event: KeyboardEvent) => boolean;
|
|
1630
|
+
/** Request emission of column-state-change event (debounced) */
|
|
1631
|
+
requestStateChange?: () => void;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
/**
|
|
1635
|
+
* Keyboard modifier flags
|
|
1636
|
+
*/
|
|
1637
|
+
export declare interface KeyboardModifiers {
|
|
1638
|
+
ctrl?: boolean;
|
|
1639
|
+
shift?: boolean;
|
|
1640
|
+
alt?: boolean;
|
|
1641
|
+
meta?: boolean;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
export declare const listAggregators: () => string[];
|
|
1645
|
+
|
|
1646
|
+
/** Configuration options for the multi-sort plugin */
|
|
1647
|
+
export declare interface MultiSortConfig {
|
|
1648
|
+
/** Whether multi-sort is enabled (default: true) */
|
|
1649
|
+
enabled?: boolean;
|
|
1650
|
+
/** Maximum number of columns to sort by (default: 3) */
|
|
1651
|
+
maxSortColumns?: number;
|
|
1652
|
+
/** Whether to show sort order badges (1, 2, 3) on headers (default: true) */
|
|
1653
|
+
showSortIndex?: boolean;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
/** Context provided to panel renderers */
|
|
1657
|
+
export declare interface PinnedRowsContext {
|
|
1658
|
+
/** Total number of rows in the grid */
|
|
1659
|
+
totalRows: number;
|
|
1660
|
+
/** Number of rows after filtering */
|
|
1661
|
+
filteredRows: number;
|
|
1662
|
+
/** Number of selected rows */
|
|
1663
|
+
selectedRows: number;
|
|
1664
|
+
/** Current column configuration */
|
|
1665
|
+
columns: ColumnConfig[];
|
|
1666
|
+
/** Current row data */
|
|
1667
|
+
rows: unknown[];
|
|
1668
|
+
/** Reference to the grid element */
|
|
1669
|
+
grid: HTMLElement;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
/** Custom panel definition for the status bar */
|
|
1673
|
+
export declare interface PinnedRowsPanel {
|
|
1674
|
+
/** Unique identifier for the panel */
|
|
1675
|
+
id: string;
|
|
1676
|
+
/** Position within the status bar */
|
|
1677
|
+
position: 'left' | 'center' | 'right';
|
|
1678
|
+
/** Render function for the panel content */
|
|
1679
|
+
render: (context: PinnedRowsContext) => HTMLElement | string;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
export declare interface PivotConfig {
|
|
1683
|
+
enabled?: boolean;
|
|
1684
|
+
rowGroupFields?: string[];
|
|
1685
|
+
columnGroupFields?: string[];
|
|
1686
|
+
valueFields?: PivotValueField[];
|
|
1687
|
+
showTotals?: boolean;
|
|
1688
|
+
showGrandTotal?: boolean;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
export declare interface PivotResult {
|
|
1692
|
+
rows: PivotRow[];
|
|
1693
|
+
columnKeys: string[];
|
|
1694
|
+
totals: Record<string, number>;
|
|
1695
|
+
grandTotal: number;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
declare interface PivotRow {
|
|
1699
|
+
rowKey: string;
|
|
1700
|
+
rowLabel: string;
|
|
1701
|
+
depth: number;
|
|
1702
|
+
values: Record<string, number | null>;
|
|
1703
|
+
total?: number;
|
|
1704
|
+
isGroup: boolean;
|
|
1705
|
+
children?: PivotRow[];
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
export declare interface PivotValueField {
|
|
1709
|
+
field: string;
|
|
1710
|
+
aggFunc: 'sum' | 'avg' | 'count' | 'min' | 'max' | 'first' | 'last';
|
|
1711
|
+
header?: string;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
/**
|
|
1715
|
+
* Cell render context for plugin cell renderers.
|
|
1716
|
+
* Provides full context including position and editing state.
|
|
1717
|
+
*
|
|
1718
|
+
* Note: This differs from the core `CellRenderContext` in types.ts which is
|
|
1719
|
+
* simpler and used for column view renderers. This version provides additional
|
|
1720
|
+
* context needed by plugins that register custom cell renderers.
|
|
1721
|
+
*/
|
|
1722
|
+
export declare interface PluginCellRenderContext {
|
|
1723
|
+
/** The cell value */
|
|
1724
|
+
value: any;
|
|
1725
|
+
/** The field/column key */
|
|
1726
|
+
field: string;
|
|
1727
|
+
/** The row data object */
|
|
1728
|
+
row: any;
|
|
1729
|
+
/** Row index in the data array */
|
|
1730
|
+
rowIndex: number;
|
|
1731
|
+
/** Column index */
|
|
1732
|
+
colIndex: number;
|
|
1733
|
+
/** Column configuration */
|
|
1734
|
+
column: ColumnConfig;
|
|
1735
|
+
/** Whether the cell is currently in edit mode */
|
|
1736
|
+
isEditing: boolean;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
export declare type PluginEventName = (typeof PluginEvents)[keyof typeof PluginEvents];
|
|
1740
|
+
|
|
1741
|
+
export declare const PluginEvents: {
|
|
1742
|
+
readonly SELECTION_CHANGE: "selection-change";
|
|
1743
|
+
readonly TREE_EXPAND: "tree-expand";
|
|
1744
|
+
readonly FILTER_CHANGE: "filter-change";
|
|
1745
|
+
readonly SORT_MODEL_CHANGE: "sort-model-change";
|
|
1746
|
+
readonly EXPORT_START: "export-start";
|
|
1747
|
+
readonly EXPORT_COMPLETE: "export-complete";
|
|
1748
|
+
readonly CLIPBOARD_COPY: "clipboard-copy";
|
|
1749
|
+
readonly CLIPBOARD_PASTE: "clipboard-paste";
|
|
1750
|
+
readonly CONTEXT_MENU_OPEN: "context-menu-open";
|
|
1751
|
+
readonly CONTEXT_MENU_CLOSE: "context-menu-close";
|
|
1752
|
+
readonly HISTORY_CHANGE: "history-change";
|
|
1753
|
+
readonly SERVER_LOADING: "server-loading";
|
|
1754
|
+
readonly SERVER_ERROR: "server-error";
|
|
1755
|
+
readonly COLUMN_VISIBILITY_CHANGE: "column-visibility-change";
|
|
1756
|
+
readonly COLUMN_REORDER: "column-reorder";
|
|
1757
|
+
readonly DETAIL_EXPAND: "detail-expand";
|
|
1758
|
+
readonly GROUP_EXPAND: "group-expand";
|
|
1759
|
+
};
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* Header render context for plugin header renderers.
|
|
1763
|
+
*/
|
|
1764
|
+
export declare interface PluginHeaderRenderContext {
|
|
1765
|
+
/** Column configuration */
|
|
1766
|
+
column: ColumnConfig;
|
|
1767
|
+
/** Column index */
|
|
1768
|
+
colIndex: number;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* Manages plugins for a single grid instance.
|
|
1773
|
+
*/
|
|
1774
|
+
export declare class PluginManager {
|
|
1775
|
+
private grid;
|
|
1776
|
+
/** Plugin instances in order of attachment */
|
|
1777
|
+
private plugins;
|
|
1778
|
+
/** Map from plugin class to instance for fast lookup */
|
|
1779
|
+
private pluginMap;
|
|
1780
|
+
/** Cell renderers registered by plugins */
|
|
1781
|
+
private cellRenderers;
|
|
1782
|
+
/** Header renderers registered by plugins */
|
|
1783
|
+
private headerRenderers;
|
|
1784
|
+
/** Cell editors registered by plugins */
|
|
1785
|
+
private cellEditors;
|
|
1786
|
+
constructor(grid: any);
|
|
1787
|
+
/**
|
|
1788
|
+
* Attach all plugins from the config.
|
|
1789
|
+
*/
|
|
1790
|
+
attachAll(plugins: BaseGridPlugin[]): void;
|
|
1791
|
+
/**
|
|
1792
|
+
* Attach a plugin to this grid.
|
|
1793
|
+
*/
|
|
1794
|
+
attach(plugin: BaseGridPlugin): void;
|
|
1795
|
+
/**
|
|
1796
|
+
* Detach all plugins and clean up.
|
|
1797
|
+
*/
|
|
1798
|
+
detachAll(): void;
|
|
1799
|
+
/**
|
|
1800
|
+
* Get a plugin instance by its class.
|
|
1801
|
+
*/
|
|
1802
|
+
getPlugin<T extends BaseGridPlugin>(PluginClass: new (...args: any[]) => T): T | undefined;
|
|
1803
|
+
/**
|
|
1804
|
+
* Get a plugin instance by its name.
|
|
1805
|
+
*/
|
|
1806
|
+
getPluginByName(name: string): BaseGridPlugin | undefined;
|
|
1807
|
+
/**
|
|
1808
|
+
* Check if a plugin is attached.
|
|
1809
|
+
*/
|
|
1810
|
+
hasPlugin<T extends BaseGridPlugin>(PluginClass: new (...args: any[]) => T): boolean;
|
|
1811
|
+
/**
|
|
1812
|
+
* Get all attached plugins.
|
|
1813
|
+
*/
|
|
1814
|
+
getAll(): readonly BaseGridPlugin[];
|
|
1815
|
+
/**
|
|
1816
|
+
* Get a cell renderer by type name.
|
|
1817
|
+
*/
|
|
1818
|
+
getCellRenderer(type: string): CellRenderer | undefined;
|
|
1819
|
+
/**
|
|
1820
|
+
* Get a header renderer by type name.
|
|
1821
|
+
*/
|
|
1822
|
+
getHeaderRenderer(type: string): HeaderRenderer | undefined;
|
|
1823
|
+
/**
|
|
1824
|
+
* Get a cell editor by type name.
|
|
1825
|
+
*/
|
|
1826
|
+
getCellEditor(type: string): CellEditor | undefined;
|
|
1827
|
+
/**
|
|
1828
|
+
* Get all CSS styles from all plugins.
|
|
1829
|
+
*/
|
|
1830
|
+
getAllStyles(): string;
|
|
1831
|
+
/**
|
|
1832
|
+
* Execute processRows hook on all plugins.
|
|
1833
|
+
*/
|
|
1834
|
+
processRows(rows: readonly any[]): any[];
|
|
1835
|
+
/**
|
|
1836
|
+
* Execute processColumns hook on all plugins.
|
|
1837
|
+
*/
|
|
1838
|
+
processColumns(columns: readonly ColumnConfig[]): ColumnConfig[];
|
|
1839
|
+
/**
|
|
1840
|
+
* Execute beforeRender hook on all plugins.
|
|
1841
|
+
*/
|
|
1842
|
+
beforeRender(): void;
|
|
1843
|
+
/**
|
|
1844
|
+
* Execute afterRender hook on all plugins.
|
|
1845
|
+
*/
|
|
1846
|
+
afterRender(): void;
|
|
1847
|
+
/**
|
|
1848
|
+
* Execute renderRow hook on all plugins.
|
|
1849
|
+
* Returns true if any plugin handled the row.
|
|
1850
|
+
*/
|
|
1851
|
+
renderRow(row: any, rowEl: HTMLElement, rowIndex: number): boolean;
|
|
1852
|
+
/**
|
|
1853
|
+
* Execute onKeyDown hook on all plugins.
|
|
1854
|
+
* Returns true if any plugin handled the event.
|
|
1855
|
+
*/
|
|
1856
|
+
onKeyDown(event: KeyboardEvent): boolean;
|
|
1857
|
+
/**
|
|
1858
|
+
* Execute onCellClick hook on all plugins.
|
|
1859
|
+
* Returns true if any plugin handled the event.
|
|
1860
|
+
*/
|
|
1861
|
+
onCellClick(event: CellClickEvent): boolean;
|
|
1862
|
+
/**
|
|
1863
|
+
* Execute onRowClick hook on all plugins.
|
|
1864
|
+
* Returns true if any plugin handled the event.
|
|
1865
|
+
*/
|
|
1866
|
+
onRowClick(event: RowClickEvent): boolean;
|
|
1867
|
+
/**
|
|
1868
|
+
* Execute onHeaderClick hook on all plugins.
|
|
1869
|
+
* Returns true if any plugin handled the event.
|
|
1870
|
+
*/
|
|
1871
|
+
onHeaderClick(event: HeaderClickEvent): boolean;
|
|
1872
|
+
/**
|
|
1873
|
+
* Execute onScroll hook on all plugins.
|
|
1874
|
+
*/
|
|
1875
|
+
onScroll(event: ScrollEvent): void;
|
|
1876
|
+
/**
|
|
1877
|
+
* Execute onCellMouseDown hook on all plugins.
|
|
1878
|
+
* Returns true if any plugin handled the event.
|
|
1879
|
+
*/
|
|
1880
|
+
onCellMouseDown(event: CellMouseEvent): boolean;
|
|
1881
|
+
/**
|
|
1882
|
+
* Execute onCellMouseMove hook on all plugins.
|
|
1883
|
+
* Returns true if any plugin handled the event.
|
|
1884
|
+
*/
|
|
1885
|
+
onCellMouseMove(event: CellMouseEvent): boolean;
|
|
1886
|
+
/**
|
|
1887
|
+
* Execute onCellMouseUp hook on all plugins.
|
|
1888
|
+
* Returns true if any plugin handled the event.
|
|
1889
|
+
*/
|
|
1890
|
+
onCellMouseUp(event: CellMouseEvent): boolean;
|
|
1891
|
+
/**
|
|
1892
|
+
* Collect context menu items from all plugins.
|
|
1893
|
+
*/
|
|
1894
|
+
getContextMenuItems(params: ContextMenuParams): ContextMenuItem[];
|
|
1895
|
+
/**
|
|
1896
|
+
* Collect tool panels from all plugins.
|
|
1897
|
+
* Returns panels sorted by order (ascending).
|
|
1898
|
+
*/
|
|
1899
|
+
getToolPanels(): {
|
|
1900
|
+
plugin: BaseGridPlugin;
|
|
1901
|
+
panel: NonNullable<ReturnType<NonNullable<BaseGridPlugin['getToolPanel']>>>;
|
|
1902
|
+
}[];
|
|
1903
|
+
/**
|
|
1904
|
+
* Collect header contents from all plugins.
|
|
1905
|
+
* Returns contents sorted by order (ascending).
|
|
1906
|
+
*/
|
|
1907
|
+
getHeaderContents(): {
|
|
1908
|
+
plugin: BaseGridPlugin;
|
|
1909
|
+
content: NonNullable<ReturnType<NonNullable<BaseGridPlugin['getHeaderContent']>>>;
|
|
1910
|
+
}[];
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
export declare type PrimitiveColumnType = 'number' | 'string' | 'date' | 'boolean' | 'select' | 'typeahead';
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
* Public API interface for DataGrid component.
|
|
1917
|
+
*
|
|
1918
|
+
* **Property Getters vs Setters:**
|
|
1919
|
+
*
|
|
1920
|
+
* Property getters return the EFFECTIVE (resolved) value after merging all config sources.
|
|
1921
|
+
* This is the "current situation" - what consumers and plugins need to know.
|
|
1922
|
+
*
|
|
1923
|
+
* Property setters accept input values which are merged into the effective config.
|
|
1924
|
+
* Multiple sources can contribute (gridConfig, columns prop, light DOM, individual props).
|
|
1925
|
+
*
|
|
1926
|
+
* For example:
|
|
1927
|
+
* - `grid.fitMode` returns the resolved fitMode (e.g., 'stretch' even if you set undefined)
|
|
1928
|
+
* - `grid.columns` returns the effective columns after merging
|
|
1929
|
+
* - `grid.gridConfig` returns the full effective config
|
|
1930
|
+
*/
|
|
1931
|
+
export declare interface PublicGrid<T = any> {
|
|
1932
|
+
/**
|
|
1933
|
+
* Full config object. Setter merges with other inputs per precedence rules.
|
|
1934
|
+
* Getter returns the effective (resolved) config.
|
|
1935
|
+
*/
|
|
1936
|
+
gridConfig?: GridConfig<T>;
|
|
1937
|
+
/**
|
|
1938
|
+
* Column definitions.
|
|
1939
|
+
* Getter returns effective columns (after merging config, light DOM, inference).
|
|
1940
|
+
*/
|
|
1941
|
+
columns?: ColumnConfig<T>[];
|
|
1942
|
+
/** Current row data (after plugin processing like grouping, filtering). */
|
|
1943
|
+
rows?: T[];
|
|
1944
|
+
/** Resolves once the component has finished initial work (layout, inference). */
|
|
1945
|
+
ready?: () => Promise<void>;
|
|
1946
|
+
/** Force a layout / measurement pass (e.g. after container resize). */
|
|
1947
|
+
forceLayout?: () => Promise<void>;
|
|
1948
|
+
/** Return effective resolved config (after inference & precedence). */
|
|
1949
|
+
getConfig?: () => Promise<Readonly<GridConfig<T>>>;
|
|
1950
|
+
/** Toggle expansion state of a group row by its generated key. */
|
|
1951
|
+
toggleGroup?: (key: string) => Promise<void>;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
export declare const registerAggregator: (name: string, fn: AggregatorFn) => void;
|
|
1955
|
+
|
|
1956
|
+
/** Controller managing drag-based column resize lifecycle. */
|
|
1957
|
+
declare interface ResizeController {
|
|
1958
|
+
start: (e: MouseEvent, colIndex: number, cell: HTMLElement) => void;
|
|
1959
|
+
dispose: () => void;
|
|
1960
|
+
/** True while a resize drag is in progress (used to suppress header click/sort). */
|
|
1961
|
+
isResizing: boolean;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
/**
|
|
1965
|
+
* Row click event
|
|
1966
|
+
*/
|
|
1967
|
+
export declare interface RowClickEvent {
|
|
1968
|
+
rowIndex: number;
|
|
1969
|
+
row: any;
|
|
1970
|
+
rowEl: HTMLElement;
|
|
1971
|
+
originalEvent: MouseEvent;
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
/** Detail payload for a committed row edit (may or may not include changes). */
|
|
1975
|
+
export declare interface RowCommitDetail<TRow = any> {
|
|
1976
|
+
/** Row index that lost edit focus. */
|
|
1977
|
+
rowIndex: number;
|
|
1978
|
+
/** Row object reference. */
|
|
1979
|
+
row: TRow;
|
|
1980
|
+
/** Whether any cell changes were actually committed in this row during the session. */
|
|
1981
|
+
changed: boolean;
|
|
1982
|
+
/** Current changed row collection. */
|
|
1983
|
+
changedRows: TRow[];
|
|
1984
|
+
/** Indices of changed rows. */
|
|
1985
|
+
changedRowIndices: number[];
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
/**
|
|
1989
|
+
* Group row rendering customization options.
|
|
1990
|
+
* Used within grouping-rows plugin config for presentation of group rows.
|
|
1991
|
+
*/
|
|
1992
|
+
export declare interface RowGroupRenderConfig {
|
|
1993
|
+
/** If true, group rows span all columns (single full-width cell). Default false. */
|
|
1994
|
+
fullWidth?: boolean;
|
|
1995
|
+
/** Optional label formatter override. Receives raw group value + depth. */
|
|
1996
|
+
formatLabel?: (value: any, depth: number, key: string) => string;
|
|
1997
|
+
/** Optional aggregate overrides per field for group summary cells (only when not fullWidth). */
|
|
1998
|
+
aggregators?: Record<string, AggregatorRef>;
|
|
1999
|
+
/** Additional CSS class applied to each group row root element. */
|
|
2000
|
+
class?: string;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
export declare const runAggregator: (ref: AggregatorRef_2 | undefined, rows: any[], field: string, column?: any) => any;
|
|
2004
|
+
|
|
2005
|
+
/**
|
|
2006
|
+
* Scroll event
|
|
2007
|
+
*/
|
|
2008
|
+
export declare interface ScrollEvent {
|
|
2009
|
+
scrollTop: number;
|
|
2010
|
+
scrollLeft: number;
|
|
2011
|
+
scrollHeight: number;
|
|
2012
|
+
scrollWidth: number;
|
|
2013
|
+
clientHeight: number;
|
|
2014
|
+
clientWidth: number;
|
|
2015
|
+
originalEvent?: Event;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
/**
|
|
2019
|
+
* Unified event detail emitted when selection changes (all modes).
|
|
2020
|
+
* Provides a consistent structure for consumers to handle selection state.
|
|
2021
|
+
*/
|
|
2022
|
+
export declare interface SelectionChangeDetail {
|
|
2023
|
+
/** The selection mode that triggered this event */
|
|
2024
|
+
mode: SelectionMode_2;
|
|
2025
|
+
/** Selected cell ranges. For cell mode, contains a single-cell range. For row mode, contains full-row ranges. */
|
|
2026
|
+
ranges: CellRange[];
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
/** Configuration options for the selection plugin */
|
|
2030
|
+
export declare interface SelectionConfig {
|
|
2031
|
+
/** Selection mode (default: 'cell') */
|
|
2032
|
+
mode: SelectionMode_2;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
/**
|
|
2036
|
+
* Selection Plugin Types
|
|
2037
|
+
*
|
|
2038
|
+
* Type definitions for the selection feature.
|
|
2039
|
+
*/
|
|
2040
|
+
/**
|
|
2041
|
+
* Selection mode for the grid:
|
|
2042
|
+
* - 'cell': Single cell selection (default). No border, just focus highlight.
|
|
2043
|
+
* - 'row': Row selection. Clicking a cell selects the entire row. Uses focus outline color.
|
|
2044
|
+
* - 'range': Range selection. Shift+click or drag to select rectangular cell ranges. Uses success border color.
|
|
2045
|
+
*/
|
|
2046
|
+
declare type SelectionMode_2 = 'cell' | 'row' | 'range';
|
|
2047
|
+
export { SelectionMode_2 as SelectionMode }
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Selection Plugin for tbw-grid
|
|
2051
|
+
*
|
|
2052
|
+
* @example
|
|
2053
|
+
* ```ts
|
|
2054
|
+
* new SelectionPlugin({ mode: 'range' })
|
|
2055
|
+
* ```
|
|
2056
|
+
*/
|
|
2057
|
+
export declare class SelectionPlugin extends BaseGridPlugin<SelectionConfig> {
|
|
2058
|
+
#private;
|
|
2059
|
+
readonly name = "selection";
|
|
2060
|
+
readonly version = "1.0.0";
|
|
2061
|
+
protected get defaultConfig(): Partial<SelectionConfig>;
|
|
2062
|
+
/** Row selection state (row mode) */
|
|
2063
|
+
private selected;
|
|
2064
|
+
private lastSelected;
|
|
2065
|
+
private anchor;
|
|
2066
|
+
/** Range selection state (range mode) */
|
|
2067
|
+
private ranges;
|
|
2068
|
+
private activeRange;
|
|
2069
|
+
private cellAnchor;
|
|
2070
|
+
private isDragging;
|
|
2071
|
+
/** Cell selection state (cell mode) */
|
|
2072
|
+
private selectedCell;
|
|
2073
|
+
detach(): void;
|
|
2074
|
+
onCellClick(event: CellClickEvent): boolean;
|
|
2075
|
+
onKeyDown(event: KeyboardEvent): boolean;
|
|
2076
|
+
onCellMouseDown(event: CellMouseEvent): boolean | void;
|
|
2077
|
+
onCellMouseMove(event: CellMouseEvent): boolean | void;
|
|
2078
|
+
onCellMouseUp(_event: CellMouseEvent): boolean | void;
|
|
2079
|
+
afterRender(): void;
|
|
2080
|
+
/**
|
|
2081
|
+
* Get the selected cell (cell mode only).
|
|
2082
|
+
*/
|
|
2083
|
+
getSelectedCell(): {
|
|
2084
|
+
row: number;
|
|
2085
|
+
col: number;
|
|
2086
|
+
} | null;
|
|
2087
|
+
/**
|
|
2088
|
+
* Get all selected row indices (row mode).
|
|
2089
|
+
*/
|
|
2090
|
+
getSelectedRows(): number[];
|
|
2091
|
+
/**
|
|
2092
|
+
* Get all selected cell ranges in public format.
|
|
2093
|
+
*/
|
|
2094
|
+
getRanges(): CellRange[];
|
|
2095
|
+
/**
|
|
2096
|
+
* Get all selected cells across all ranges.
|
|
2097
|
+
*/
|
|
2098
|
+
getSelectedCells(): Array<{
|
|
2099
|
+
row: number;
|
|
2100
|
+
col: number;
|
|
2101
|
+
}>;
|
|
2102
|
+
/**
|
|
2103
|
+
* Check if a specific cell is in range selection.
|
|
2104
|
+
*/
|
|
2105
|
+
isCellSelected(row: number, col: number): boolean;
|
|
2106
|
+
/**
|
|
2107
|
+
* Clear all selection.
|
|
2108
|
+
*/
|
|
2109
|
+
clearSelection(): void;
|
|
2110
|
+
/**
|
|
2111
|
+
* Set selected ranges programmatically.
|
|
2112
|
+
*/
|
|
2113
|
+
setRanges(ranges: CellRange[]): void;
|
|
2114
|
+
readonly styles = "\n /* Prevent text selection during range drag */\n :host .selecting .data-grid-row > .cell {\n user-select: none;\n }\n\n /* Row selection - use accent color for row focus */\n :host .data-grid-row.row-focus {\n background-color: var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%));\n }\n\n /* Disable cell-focus outline in row mode - row is the focus unit */\n :host([data-selection-mode=\"row\"]) .cell-focus {\n outline: none;\n }\n\n /* Selection cell styles - for range mode */\n :host .data-grid-row > .cell.selected {\n background-color: var(--tbw-range-selection-bg);\n }\n :host .data-grid-row > .cell.selected.top {\n border-top: 2px solid var(--tbw-range-border-color);\n }\n :host .data-grid-row > .cell.selected.bottom {\n border-bottom: 2px solid var(--tbw-range-border-color);\n }\n :host .data-grid-row > .cell.selected.first {\n border-left: 2px solid var(--tbw-range-border-color);\n }\n :host .data-grid-row > .cell.selected.last {\n border-right: 2px solid var(--tbw-range-border-color);\n }\n ";
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
export declare interface ServerSideDataSource {
|
|
2118
|
+
getRows(params: GetRowsParams): Promise<GetRowsResult>;
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* Shell configuration for the grid's optional header bar and tool panels.
|
|
2123
|
+
*/
|
|
2124
|
+
export declare interface ShellConfig {
|
|
2125
|
+
/** Shell header bar configuration */
|
|
2126
|
+
header?: ShellHeaderConfig;
|
|
2127
|
+
/** Tool panel configuration */
|
|
2128
|
+
toolPanel?: ToolPanelConfig;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/**
|
|
2132
|
+
* Shell header bar configuration
|
|
2133
|
+
*/
|
|
2134
|
+
export declare interface ShellHeaderConfig {
|
|
2135
|
+
/** Grid title displayed on the left (optional) */
|
|
2136
|
+
title?: string;
|
|
2137
|
+
/** Custom toolbar buttons (rendered before tool panel toggles) */
|
|
2138
|
+
toolbarButtons?: ToolbarButtonConfig[];
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/** Detail for a sort change (direction 0 indicates cleared sort). */
|
|
2142
|
+
export declare interface SortChangeDetail {
|
|
2143
|
+
/** Sorted field key. */
|
|
2144
|
+
field: string;
|
|
2145
|
+
/** Direction: 1 ascending, -1 descending, 0 cleared. */
|
|
2146
|
+
direction: 1 | -1 | 0;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
/**
|
|
2150
|
+
* Multi-Sort Plugin Types
|
|
2151
|
+
*
|
|
2152
|
+
* Type definitions for the multi-column sorting feature.
|
|
2153
|
+
*/
|
|
2154
|
+
/** Represents a single column sort configuration */
|
|
2155
|
+
export declare interface SortModel {
|
|
2156
|
+
/** The field key to sort by */
|
|
2157
|
+
field: string;
|
|
2158
|
+
/** Sort direction */
|
|
2159
|
+
direction: 'asc' | 'desc';
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
/**
|
|
2163
|
+
* Toolbar button defined via config (programmatic approach).
|
|
2164
|
+
* Supports three modes:
|
|
2165
|
+
* - Simple: provide `icon` + `action` for grid to create button
|
|
2166
|
+
* - Element: provide `element` for user-created DOM
|
|
2167
|
+
* - Render: provide `render` function for complex widgets
|
|
2168
|
+
*/
|
|
2169
|
+
export declare interface ToolbarButtonConfig {
|
|
2170
|
+
/** Unique button ID */
|
|
2171
|
+
id: string;
|
|
2172
|
+
/** Tooltip / aria-label (required for accessibility) */
|
|
2173
|
+
label: string;
|
|
2174
|
+
/** Order priority (lower = first, default: 100) */
|
|
2175
|
+
order?: number;
|
|
2176
|
+
/** Whether button is disabled (only applies to grid-rendered buttons) */
|
|
2177
|
+
disabled?: boolean;
|
|
2178
|
+
/** Button content: SVG string, emoji, or text. Grid creates <button> with this. */
|
|
2179
|
+
icon?: string;
|
|
2180
|
+
/** Click handler (required when using icon) */
|
|
2181
|
+
action?: () => void;
|
|
2182
|
+
/**
|
|
2183
|
+
* User-provided element. Grid wraps it but doesn't modify it.
|
|
2184
|
+
* User is responsible for event handlers.
|
|
2185
|
+
*/
|
|
2186
|
+
element?: HTMLElement;
|
|
2187
|
+
/**
|
|
2188
|
+
* Render function called once. Receives container, user appends their DOM.
|
|
2189
|
+
* User is responsible for event handlers.
|
|
2190
|
+
* Return a cleanup function (optional).
|
|
2191
|
+
*/
|
|
2192
|
+
render?: (container: HTMLElement) => void | (() => void);
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* Toolbar button info returned by getToolbarButtons().
|
|
2197
|
+
*/
|
|
2198
|
+
declare interface ToolbarButtonInfo {
|
|
2199
|
+
id: string;
|
|
2200
|
+
label: string;
|
|
2201
|
+
disabled: boolean;
|
|
2202
|
+
/** Source of this button: 'config' | 'light-dom' | 'panel-toggle' */
|
|
2203
|
+
source: 'config' | 'light-dom' | 'panel-toggle';
|
|
2204
|
+
/** For panel toggles, the associated panel ID */
|
|
2205
|
+
panelId?: string;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
/**
|
|
2209
|
+
* Tool panel configuration
|
|
2210
|
+
*/
|
|
2211
|
+
export declare interface ToolPanelConfig {
|
|
2212
|
+
/** Panel position: 'left' | 'right' (default: 'right') */
|
|
2213
|
+
position?: 'left' | 'right';
|
|
2214
|
+
/** Default panel width in pixels (default: 280) */
|
|
2215
|
+
width?: number;
|
|
2216
|
+
/** Panel ID to open by default on load */
|
|
2217
|
+
defaultOpen?: string;
|
|
2218
|
+
/** Whether to persist open/closed state (requires Column State Events) */
|
|
2219
|
+
persistState?: boolean;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
/**
|
|
2223
|
+
* Tool panel definition registered by plugins or consumers.
|
|
2224
|
+
*/
|
|
2225
|
+
export declare interface ToolPanelDefinition {
|
|
2226
|
+
/** Unique panel ID */
|
|
2227
|
+
id: string;
|
|
2228
|
+
/** Panel title shown in header */
|
|
2229
|
+
title: string;
|
|
2230
|
+
/** Icon for toolbar button (SVG string or emoji) */
|
|
2231
|
+
icon: string;
|
|
2232
|
+
/** Toolbar button tooltip */
|
|
2233
|
+
tooltip?: string;
|
|
2234
|
+
/** Panel content factory - called when panel opens */
|
|
2235
|
+
render: (container: HTMLElement) => void | (() => void);
|
|
2236
|
+
/** Called when panel closes (for cleanup) */
|
|
2237
|
+
onClose?: () => void;
|
|
2238
|
+
/** Panel order priority (lower = first, default: 100) */
|
|
2239
|
+
order?: number;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
/**
|
|
2243
|
+
* Tree Data Plugin Types
|
|
2244
|
+
*
|
|
2245
|
+
* Type definitions for hierarchical tree data with expand/collapse functionality.
|
|
2246
|
+
*/
|
|
2247
|
+
/** Configuration options for the tree plugin */
|
|
2248
|
+
export declare interface TreeConfig {
|
|
2249
|
+
/** Whether tree functionality is enabled (default: true) */
|
|
2250
|
+
enabled?: boolean;
|
|
2251
|
+
/** Field name containing child rows (default: 'children') */
|
|
2252
|
+
childrenField?: string;
|
|
2253
|
+
/** Auto-detect tree structure from data (default: true) */
|
|
2254
|
+
autoDetect?: boolean;
|
|
2255
|
+
/** Whether nodes are expanded by default (default: false) */
|
|
2256
|
+
defaultExpanded?: boolean;
|
|
2257
|
+
/** Indentation width per level in pixels (default: 20) */
|
|
2258
|
+
indentWidth?: number;
|
|
2259
|
+
/** Show expand/collapse icons (default: true) */
|
|
2260
|
+
showExpandIcons?: boolean;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
/** Event detail emitted when a tree node is expanded or collapsed */
|
|
2264
|
+
export declare interface TreeExpandDetail {
|
|
2265
|
+
/** The row key that was toggled */
|
|
2266
|
+
key: string;
|
|
2267
|
+
/** The original row data */
|
|
2268
|
+
row: any;
|
|
2269
|
+
/** Whether the row is now expanded */
|
|
2270
|
+
expanded: boolean;
|
|
2271
|
+
/** Depth level of the row */
|
|
2272
|
+
depth: number;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
/**
|
|
2276
|
+
* Tree Data Plugin for tbw-grid
|
|
2277
|
+
*
|
|
2278
|
+
* Provides hierarchical tree data display with expand/collapse functionality.
|
|
2279
|
+
*
|
|
2280
|
+
* @example
|
|
2281
|
+
* ```ts
|
|
2282
|
+
* new TreePlugin({ defaultExpanded: true, indentWidth: 24 })
|
|
2283
|
+
* ```
|
|
2284
|
+
*/
|
|
2285
|
+
export declare class TreePlugin extends BaseGridPlugin<TreeConfig> {
|
|
2286
|
+
readonly name = "tree";
|
|
2287
|
+
readonly version = "1.0.0";
|
|
2288
|
+
protected get defaultConfig(): Partial<TreeConfig>;
|
|
2289
|
+
/** Set of expanded row keys */
|
|
2290
|
+
private expandedKeys;
|
|
2291
|
+
/** Whether initial expansion (based on defaultExpanded config) has been applied */
|
|
2292
|
+
private initialExpansionDone;
|
|
2293
|
+
/** Flattened tree rows for rendering */
|
|
2294
|
+
private flattenedRows;
|
|
2295
|
+
/** Map from key to flattened row for quick lookup */
|
|
2296
|
+
private rowKeyMap;
|
|
2297
|
+
detach(): void;
|
|
2298
|
+
/**
|
|
2299
|
+
* Detects if tree functionality should be enabled based on data structure.
|
|
2300
|
+
* Called by the grid during plugin initialization.
|
|
2301
|
+
*/
|
|
2302
|
+
detect(rows: readonly unknown[]): boolean;
|
|
2303
|
+
processRows(rows: readonly unknown[]): any[];
|
|
2304
|
+
processColumns(columns: readonly ColumnConfig[]): ColumnConfig[];
|
|
2305
|
+
onCellClick(event: CellClickEvent): boolean;
|
|
2306
|
+
/**
|
|
2307
|
+
* Expand a specific node by key.
|
|
2308
|
+
*/
|
|
2309
|
+
expand(key: string): void;
|
|
2310
|
+
/**
|
|
2311
|
+
* Collapse a specific node by key.
|
|
2312
|
+
*/
|
|
2313
|
+
collapse(key: string): void;
|
|
2314
|
+
/**
|
|
2315
|
+
* Toggle the expansion state of a node.
|
|
2316
|
+
*/
|
|
2317
|
+
toggle(key: string): void;
|
|
2318
|
+
/**
|
|
2319
|
+
* Expand all nodes in the tree.
|
|
2320
|
+
*/
|
|
2321
|
+
expandAll(): void;
|
|
2322
|
+
/**
|
|
2323
|
+
* Collapse all nodes in the tree.
|
|
2324
|
+
*/
|
|
2325
|
+
collapseAll(): void;
|
|
2326
|
+
/**
|
|
2327
|
+
* Check if a node is currently expanded.
|
|
2328
|
+
*/
|
|
2329
|
+
isExpanded(key: string): boolean;
|
|
2330
|
+
/**
|
|
2331
|
+
* Get all currently expanded keys.
|
|
2332
|
+
*/
|
|
2333
|
+
getExpandedKeys(): string[];
|
|
2334
|
+
/**
|
|
2335
|
+
* Get the flattened tree rows with metadata.
|
|
2336
|
+
*/
|
|
2337
|
+
getFlattenedRows(): FlattenedTreeRow[];
|
|
2338
|
+
/**
|
|
2339
|
+
* Get a row's original data by its key.
|
|
2340
|
+
*/
|
|
2341
|
+
getRowByKey(key: string): any | undefined;
|
|
2342
|
+
/**
|
|
2343
|
+
* Expand all ancestors of a node to make it visible.
|
|
2344
|
+
*/
|
|
2345
|
+
expandToKey(key: string): void;
|
|
2346
|
+
readonly styles = "\n .tree-toggle {\n cursor: pointer;\n user-select: none;\n transition: transform 0.2s;\n }\n .tree-toggle:hover {\n color: var(--tbw-tree-accent, var(--tbw-color-accent));\n }\n ";
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
export declare const unregisterAggregator: (name: string) => void;
|
|
2350
|
+
|
|
2351
|
+
/** Virtual window bookkeeping; modified in-place as scroll position changes. */
|
|
2352
|
+
declare interface VirtualState {
|
|
2353
|
+
enabled: boolean;
|
|
2354
|
+
rowHeight: number;
|
|
2355
|
+
/** Threshold for bypassing virtualization (renders all rows if totalRows <= bypassThreshold) */
|
|
2356
|
+
bypassThreshold: number;
|
|
2357
|
+
start: number;
|
|
2358
|
+
end: number;
|
|
2359
|
+
/** Faux scrollbar element that provides scroll events (AG Grid pattern) */
|
|
2360
|
+
container: HTMLElement | null;
|
|
2361
|
+
/** Rows viewport element for measuring visible area height */
|
|
2362
|
+
viewportEl: HTMLElement | null;
|
|
2363
|
+
/** Spacer element inside faux scrollbar for setting virtual height */
|
|
2364
|
+
totalHeightEl: HTMLElement | null;
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
export { }
|