@timlassiter11/yatl 1.2.5 → 1.3.0
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/dist/index.d.mts +647 -510
- package/dist/index.d.ts +647 -510
- package/dist/index.js +659 -363
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +646 -356
- package/dist/index.mjs.map +1 -1
- package/dist/yatl.min.global.js +126 -45
- package/dist/yatl.min.global.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,260 @@
|
|
|
1
1
|
import * as lit from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import { ReactiveController, ReactiveControllerHost, TemplateResult, LitElement, nothing, PropertyValues } from 'lit';
|
|
3
3
|
import { DirectiveResult } from 'lit/directive.js';
|
|
4
|
+
import * as lit_html from 'lit-html';
|
|
5
|
+
|
|
6
|
+
declare class TypedEventTarget<TEventMap extends Record<string, Event>> extends EventTarget {
|
|
7
|
+
addEventListener<K extends keyof TEventMap>(type: K, listener: (this: TEventMap, ev: TEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
8
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
9
|
+
removeEventListener<K extends keyof TEventMap>(type: K, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
|
|
10
|
+
dispatchEvent<K extends keyof TEventMap>(event: TEventMap[K]): boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class YatlTableController<T extends object = UnspecifiedRecord> extends TypedEventTarget<ControllerEventMap> implements ReactiveController, YatlTableControllerApi<T> {
|
|
14
|
+
private hosts;
|
|
15
|
+
private _tokenizedSearch;
|
|
16
|
+
private _scoredSearch;
|
|
17
|
+
private _columns;
|
|
18
|
+
private _columnDefinitionMap;
|
|
19
|
+
private _columnStateMap;
|
|
20
|
+
private _rowSelectionMethod;
|
|
21
|
+
private _selectedRowIds;
|
|
22
|
+
private _storageOptions;
|
|
23
|
+
private _rowIdCallback;
|
|
24
|
+
private _data;
|
|
25
|
+
private _filteredData;
|
|
26
|
+
private _dataUpdateTimestamp;
|
|
27
|
+
private _searchQuery;
|
|
28
|
+
private _searchTokenizer;
|
|
29
|
+
private _filters;
|
|
30
|
+
private hasRestoredState;
|
|
31
|
+
private saveTimer;
|
|
32
|
+
private filterDirty;
|
|
33
|
+
private sortDirty;
|
|
34
|
+
private rowMetadata;
|
|
35
|
+
private idToRowMap;
|
|
36
|
+
private queryTokens;
|
|
37
|
+
get columns(): ColumnOptions<T>[];
|
|
38
|
+
set columns(columns: ColumnOptions<T>[]);
|
|
39
|
+
get displayColumns(): DisplayColumnOptions<T>[];
|
|
40
|
+
get columnStates(): ColumnState<T>[];
|
|
41
|
+
set columnStates(states: ColumnState<T>[]);
|
|
42
|
+
get data(): T[];
|
|
43
|
+
set data(data: T[]);
|
|
44
|
+
get filteredData(): T[];
|
|
45
|
+
get dataUpdateTimestamp(): Date | null;
|
|
46
|
+
get filters(): FilterCallback<T> | Partial<{ [K in NestedKeyOf<T>]: unknown; }> | null;
|
|
47
|
+
set filters(filters: FilterCallback<T> | Partial<{ [K in NestedKeyOf<T>]: unknown; }> | null);
|
|
48
|
+
get searchQuery(): string;
|
|
49
|
+
set searchQuery(query: string);
|
|
50
|
+
get tokenizedSearch(): boolean;
|
|
51
|
+
set tokenizedSearch(enable: boolean);
|
|
52
|
+
get scoredSearch(): boolean;
|
|
53
|
+
set scoredSearch(enable: boolean);
|
|
54
|
+
get searchTokenizer(): TokenizerCallback;
|
|
55
|
+
set searchTokenizer(tokenizer: TokenizerCallback);
|
|
56
|
+
get rowSelectionMethod(): RowSelectionMethod | null;
|
|
57
|
+
set rowSelectionMethod(selection: RowSelectionMethod | null);
|
|
58
|
+
get selectedRowIds(): RowId[];
|
|
59
|
+
set selectedRowIds(rows: RowId[]);
|
|
60
|
+
get rowIdCallback(): RowIdCallback<T>;
|
|
61
|
+
set rowIdCallback(callback: RowIdCallback<T>);
|
|
62
|
+
get storageOptions(): {
|
|
63
|
+
key: string;
|
|
64
|
+
storage?: StorageInterface;
|
|
65
|
+
saveSearchQuery?: boolean;
|
|
66
|
+
saveColumnSortOrders?: boolean;
|
|
67
|
+
saveColumnVisibility?: boolean;
|
|
68
|
+
saveColumnWidths?: boolean;
|
|
69
|
+
saveColumnOrder?: boolean;
|
|
70
|
+
saveSelectedRows?: boolean;
|
|
71
|
+
} | null;
|
|
72
|
+
set storageOptions(options: {
|
|
73
|
+
key: string;
|
|
74
|
+
storage?: StorageInterface;
|
|
75
|
+
saveSearchQuery?: boolean;
|
|
76
|
+
saveColumnSortOrders?: boolean;
|
|
77
|
+
saveColumnVisibility?: boolean;
|
|
78
|
+
saveColumnWidths?: boolean;
|
|
79
|
+
saveColumnOrder?: boolean;
|
|
80
|
+
saveSelectedRows?: boolean;
|
|
81
|
+
} | null);
|
|
82
|
+
constructor(host?: ReactiveControllerHost, options?: TableControllerOptions<T>);
|
|
83
|
+
attach(host: ReactiveControllerHost): void;
|
|
84
|
+
detach(host: ReactiveControllerHost): void;
|
|
85
|
+
getColumn(field: NestedKeyOf<T>): ColumnOptions<T> | undefined;
|
|
86
|
+
getDisplayColumn(field: NestedKeyOf<T>): DisplayColumnOptions<T> | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Gets a copy of the current state of the table.
|
|
89
|
+
*/
|
|
90
|
+
getTableState(): TableState<T>;
|
|
91
|
+
/**
|
|
92
|
+
* Restores the table to the provided state.
|
|
93
|
+
* @param state - The state to restore the table to.
|
|
94
|
+
*/
|
|
95
|
+
updateTableState(state: RestorableTableState<T>): void;
|
|
96
|
+
getColumnState(field: NestedKeyOf<T>): ColumnState<T>;
|
|
97
|
+
updateColumnState(field: NestedKeyOf<T>, state: RestorableColumnState<T>): void;
|
|
98
|
+
search(query: string): void;
|
|
99
|
+
getColumnFilterValues(field: NestedKeyOf<T>, includeNull?: boolean): Map<unknown, number>;
|
|
100
|
+
/**
|
|
101
|
+
* Sorts the table by a specified column and order.
|
|
102
|
+
* If `order` is `null`, the sort on this column is removed.
|
|
103
|
+
* @param field - The field name of the column to sort by.
|
|
104
|
+
* @param order - The sort order: 'asc', 'desc', or `null` to remove sorting for this column.
|
|
105
|
+
* @param clear - Clear all other sorting
|
|
106
|
+
*/
|
|
107
|
+
sort(field: NestedKeyOf<T>, order: SortOrder | null, clear?: boolean): void;
|
|
108
|
+
/**
|
|
109
|
+
* Toggles the visibility of hte specified column
|
|
110
|
+
* @param field - The field name of the column to toggle.
|
|
111
|
+
* @param visible - Optionally force the visibility state.
|
|
112
|
+
*/
|
|
113
|
+
toggleColumnVisibility(field: NestedKeyOf<T>, visible?: boolean): void;
|
|
114
|
+
/**
|
|
115
|
+
* Shows the specified column
|
|
116
|
+
* @param field - The field name of the column to show.
|
|
117
|
+
*/
|
|
118
|
+
showColumn(field: NestedKeyOf<T>): void;
|
|
119
|
+
/**
|
|
120
|
+
* Hides the specified column
|
|
121
|
+
* @param field - The field name of the column to hide.
|
|
122
|
+
*/
|
|
123
|
+
hideColumn(field: NestedKeyOf<T>): void;
|
|
124
|
+
/**
|
|
125
|
+
* Moves a column to a new position
|
|
126
|
+
* @param field - The column to move
|
|
127
|
+
* @param newPosition The index or field of the column to move it to.
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
moveColumn(field: NestedKeyOf<T>, newPosition: number | NestedKeyOf<T>): void;
|
|
131
|
+
resizeColumn(field: NestedKeyOf<T>, width: number | null): void;
|
|
132
|
+
isRowSelected(row: T): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Toggles the selection state of a specific row.
|
|
135
|
+
*/
|
|
136
|
+
toggleRowSelection(row: T, state?: boolean): void;
|
|
137
|
+
/**
|
|
138
|
+
* Selects a specific row.
|
|
139
|
+
*/
|
|
140
|
+
selectRow(row: T): void;
|
|
141
|
+
/**
|
|
142
|
+
* Deselects a specific row.
|
|
143
|
+
*/
|
|
144
|
+
deselectRow(row: T): void;
|
|
145
|
+
/**
|
|
146
|
+
* Selects all currently visible rows (for "Select All" checkbox).
|
|
147
|
+
*/
|
|
148
|
+
selectAll(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Clears all selection.
|
|
151
|
+
*/
|
|
152
|
+
deselectAll(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Export the current visible table data to a CSV file.
|
|
155
|
+
* @param options - Options for configuring what should be exported.
|
|
156
|
+
*/
|
|
157
|
+
export(options?: ExportOptions): Blob;
|
|
158
|
+
/**
|
|
159
|
+
* Gets the row associated with the provided ID.
|
|
160
|
+
* @param id - The ID of the row to get
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
getRow(id: RowId): T | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Finds the first row where {@link field} matches {@link value}
|
|
166
|
+
* @param field - The field name within the row data to search.
|
|
167
|
+
* @param value - The value to match against the field's content.
|
|
168
|
+
* @returns The found row, or undefined if no match is found.
|
|
169
|
+
*/
|
|
170
|
+
findRow(field: NestedKeyOf<T>, value: unknown): T | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Finds the original index of the first row where the specified field matches the given value.
|
|
173
|
+
* This searches through the original, unfiltered dataset.
|
|
174
|
+
* @param field - The field name within the row data to search.
|
|
175
|
+
* @param value - The value to match against the field's content.
|
|
176
|
+
* @returns The original index of the found row, or -1 if no match is found.
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const index = dataTable.indexOf('id', 12345);
|
|
180
|
+
* if (index >= 0) {
|
|
181
|
+
* dataTable.updateRow({description: "Updated description"}, index);
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
findRowIndex(field: NestedKeyOf<T>, value: unknown): number;
|
|
186
|
+
updateRow(rowId: RowId, data: Partial<T>): void;
|
|
187
|
+
/**
|
|
188
|
+
* Updates the data of a row at a specific original index.
|
|
189
|
+
* @param index - The original index of the row to update.
|
|
190
|
+
* @param data - An object containing the new data to assign to the row. Existing fields will be updated, and new fields will be added.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* const index = dataTable.indexOf('id', 12345);
|
|
195
|
+
* if (index >= 0) {
|
|
196
|
+
* dataTable.updateRow(index, {description: "Updated description"});
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
updateRowAtIndex(index: number, data: Partial<T>): void;
|
|
201
|
+
/**
|
|
202
|
+
* Deletes the row with the matching ID.
|
|
203
|
+
* @param rowIds - The IDs rows to delete
|
|
204
|
+
*/
|
|
205
|
+
deleteRow(...rowIds: RowId[]): void;
|
|
206
|
+
/**
|
|
207
|
+
* Deletes a row at a specific original index from the table.
|
|
208
|
+
* @param indexes - The original indexes of rows to delete.
|
|
209
|
+
*/
|
|
210
|
+
deleteRowAtIndex(...indexes: number[]): void;
|
|
211
|
+
getRowId(row: T): RowId;
|
|
212
|
+
getRowIndex(row: T): number;
|
|
213
|
+
getRowHighlightIndicies(row: T): Record<string, [number, number][]> | undefined;
|
|
214
|
+
hostConnected(): void;
|
|
215
|
+
hostDisconnected(): void;
|
|
216
|
+
hostUpdate(): void;
|
|
217
|
+
hostUpdated(): void;
|
|
218
|
+
requestUpdate(...props: (keyof YatlTableController)[]): void;
|
|
219
|
+
/**
|
|
220
|
+
* Calculates a relevance score for a given query against a target string.
|
|
221
|
+
*
|
|
222
|
+
* This function implements a tiered matching strategy:
|
|
223
|
+
* 1. **Exact Match**: The query exactly matches the target. This yields the highest score.
|
|
224
|
+
* 2. **Prefix Match**: The target starts with the query. This is the next most relevant.
|
|
225
|
+
* 3. **Substring Match**: The target contains the query somewhere. This is the least relevant.
|
|
226
|
+
*
|
|
227
|
+
* The final score is weighted and adjusted by the length difference between the query and the target
|
|
228
|
+
* to ensure that more specific matches (e.g., "apple" vs "application" for the query "apple") rank higher.
|
|
229
|
+
*
|
|
230
|
+
* @param query The search term (e.g., "app").
|
|
231
|
+
* @param target The string to be searched (e.g., "Apple" or "Application").
|
|
232
|
+
* @returns A numerical score representing the relevance of the match. Higher is better. Returns 0 if no match is found.
|
|
233
|
+
*/
|
|
234
|
+
private calculateSearchScore;
|
|
235
|
+
private searchField;
|
|
236
|
+
private filterField;
|
|
237
|
+
private filterRow;
|
|
238
|
+
private filterRows;
|
|
239
|
+
private compareRows;
|
|
240
|
+
private sortRows;
|
|
241
|
+
private createMetadata;
|
|
242
|
+
private updateRowData;
|
|
243
|
+
private updateInternalQuery;
|
|
244
|
+
private scheduleSave;
|
|
245
|
+
private saveStateToStorage;
|
|
246
|
+
private loadStateFromStorage;
|
|
247
|
+
}
|
|
248
|
+
type ControllerEventMap = {
|
|
249
|
+
[YatlColumnReorderEvent.EVENT_NAME]: YatlColumnReorderEvent;
|
|
250
|
+
[YatlColumnResizeEvent.EVENT_NAME]: YatlColumnResizeEvent;
|
|
251
|
+
[YatlColumnSortEvent.EVENT_NAME]: YatlColumnSortEvent;
|
|
252
|
+
[YatlColumnToggleEvent.EVENT_NAME]: YatlColumnToggleEvent;
|
|
253
|
+
[YatlRowSelectEvent.EVENT_NAME]: YatlRowSelectEvent;
|
|
254
|
+
[YatlTableSearchEvent.EVENT_NAME]: YatlTableSearchEvent;
|
|
255
|
+
[YatlTableStateChangeEvent.EVENT_NAME]: YatlTableStateChangeEvent;
|
|
256
|
+
[YatlTableViewChangeEvent.EVENT_NAME]: YatlTableViewChangeEvent;
|
|
257
|
+
};
|
|
4
258
|
|
|
5
259
|
type NestedKeyOf<ObjectType> = ObjectType extends object ? {
|
|
6
260
|
[Key in keyof ObjectType & (string | number)]: NonNullable<ObjectType[Key]> extends unknown[] ? `${Key}` : NonNullable<ObjectType[Key]> extends object ? // Recurse with the non-nullable type
|
|
@@ -22,12 +276,13 @@ type Compareable = string | number | boolean | Date;
|
|
|
22
276
|
* Safe types for render callbacks
|
|
23
277
|
*/
|
|
24
278
|
type Renderable = string | number | boolean | null | undefined | TemplateResult | DirectiveResult;
|
|
279
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
25
280
|
|
|
26
281
|
/**
|
|
27
282
|
* A filter object containing keys for the fields to be filtered,
|
|
28
283
|
* and the values used to compare against.
|
|
29
284
|
*/
|
|
30
|
-
type Filters<T> = Partial<{
|
|
285
|
+
type Filters<T extends object = UnspecifiedRecord> = Partial<{
|
|
31
286
|
[K in NestedKeyOf<T>]: unknown;
|
|
32
287
|
}>;
|
|
33
288
|
/**
|
|
@@ -36,7 +291,7 @@ type Filters<T> = Partial<{
|
|
|
36
291
|
* @param index - The index of the row.
|
|
37
292
|
* @returns True if the row matches the filter, false otherwise.
|
|
38
293
|
*/
|
|
39
|
-
type FilterCallback<T> = (row: T, index: number) => boolean;
|
|
294
|
+
type FilterCallback<T extends object = UnspecifiedRecord> = (row: T, index: number) => boolean;
|
|
40
295
|
/**
|
|
41
296
|
* Callback for filtering a field value against the filter data.
|
|
42
297
|
* @param value - The value to filter.
|
|
@@ -72,7 +327,7 @@ type ColumnRole = 'display' | 'internal';
|
|
|
72
327
|
* @param field - The field of the column.
|
|
73
328
|
* @param row - The row data.
|
|
74
329
|
*/
|
|
75
|
-
type CellPartsCallback<T> = (value: unknown, field: NestedKeyOf<T>, row: T) => string | string[] | undefined;
|
|
330
|
+
type CellPartsCallback<T extends object = UnspecifiedRecord> = (value: unknown, field: NestedKeyOf<T>, row: T) => string | string[] | undefined;
|
|
76
331
|
/**
|
|
77
332
|
* Callback for providing the full contents of a rendered cell.
|
|
78
333
|
* @param value - The value of the cell.
|
|
@@ -80,14 +335,14 @@ type CellPartsCallback<T> = (value: unknown, field: NestedKeyOf<T>, row: T) => s
|
|
|
80
335
|
* @param row - The row data.
|
|
81
336
|
* @returns - Should return an HTMLElement or anything Lit can render
|
|
82
337
|
*/
|
|
83
|
-
type CellRenderCallback<T> = (value: unknown, field: NestedKeyOf<T>, row: T) => Renderable;
|
|
338
|
+
type CellRenderCallback<T extends object = UnspecifiedRecord> = (value: unknown, field: NestedKeyOf<T>, row: T) => Renderable;
|
|
84
339
|
/**
|
|
85
340
|
* Callback for formatting the value of a cell.
|
|
86
341
|
* Called when the cell is created and when exporting to CSV.
|
|
87
342
|
* @param value - The value of the cell.
|
|
88
343
|
* @param row - The row data.
|
|
89
344
|
*/
|
|
90
|
-
type ValueFormatterCallback<T> = (value: unknown, row: T) => string | null;
|
|
345
|
+
type ValueFormatterCallback<T extends object = UnspecifiedRecord> = (value: unknown, row: T) => string | null;
|
|
91
346
|
/**
|
|
92
347
|
* Callback for caching the sort value of a field
|
|
93
348
|
* This function should derive a comparable value (often numerical or lowercase string) from the field's original value, to be used during sorting.
|
|
@@ -95,10 +350,44 @@ type ValueFormatterCallback<T> = (value: unknown, row: T) => string | null;
|
|
|
95
350
|
* @returns The derived value for sorting (e.g., a number or a standardized string).
|
|
96
351
|
*/
|
|
97
352
|
type SortValueCallback = (value: unknown) => Compareable;
|
|
353
|
+
/**
|
|
354
|
+
*
|
|
355
|
+
*/
|
|
356
|
+
interface CellEditor<T extends object = UnspecifiedRecord> {
|
|
357
|
+
/**
|
|
358
|
+
* Reset the state of the editor before a new cell uses it
|
|
359
|
+
* @returns
|
|
360
|
+
*/
|
|
361
|
+
reset: () => void;
|
|
362
|
+
/**
|
|
363
|
+
* A function to determine if editing should be allowed for the given row.
|
|
364
|
+
*/
|
|
365
|
+
canEdit: (field: NestedKeyOf<T>, row: T) => boolean;
|
|
366
|
+
/**
|
|
367
|
+
* A method for rendering the input element used for editing the cell
|
|
368
|
+
* @param value - The current value
|
|
369
|
+
* @param field - The field that is being edited
|
|
370
|
+
* @param row - The row
|
|
371
|
+
* @param controller - This table's controller
|
|
372
|
+
* @returns Should return a renderable object like TemplateResult
|
|
373
|
+
*/
|
|
374
|
+
render: (value: unknown, field: NestedKeyOf<T>, row: T, controller: YatlTableController<T>) => unknown;
|
|
375
|
+
/**
|
|
376
|
+
* A method for saving the data. If it's async,
|
|
377
|
+
* the promise will be awaited before closing the edit.
|
|
378
|
+
* @param originalValue - The value before editing
|
|
379
|
+
* @param field The field that is being edited
|
|
380
|
+
* @param row The row that is being edited
|
|
381
|
+
* @param controller The table's controller
|
|
382
|
+
* @returns The new value or a promise to the new value.
|
|
383
|
+
* If undefined is returned, the edit is cancelled
|
|
384
|
+
*/
|
|
385
|
+
save: (originalValue: unknown, field: NestedKeyOf<T>, row: T, controller: YatlTableController<T>) => MaybePromise<unknown | undefined>;
|
|
386
|
+
}
|
|
98
387
|
/**
|
|
99
388
|
* Shared options between both internal and displayed columns.
|
|
100
389
|
*/
|
|
101
|
-
interface BaseColumnOptions<T> {
|
|
390
|
+
interface BaseColumnOptions<T extends object = UnspecifiedRecord> {
|
|
102
391
|
/**
|
|
103
392
|
* The field name in the data object.
|
|
104
393
|
*/
|
|
@@ -139,7 +428,7 @@ interface BaseColumnOptions<T> {
|
|
|
139
428
|
/**
|
|
140
429
|
* Column options for the table.
|
|
141
430
|
*/
|
|
142
|
-
interface DisplayColumnOptions<T> extends BaseColumnOptions<T> {
|
|
431
|
+
interface DisplayColumnOptions<T extends object = UnspecifiedRecord> extends BaseColumnOptions<T> {
|
|
143
432
|
/**
|
|
144
433
|
* Determines if a column is intended to be displayed,
|
|
145
434
|
* or just for searching and filtering.
|
|
@@ -153,6 +442,10 @@ interface DisplayColumnOptions<T> extends BaseColumnOptions<T> {
|
|
|
153
442
|
* Whether the column should be resizable.
|
|
154
443
|
*/
|
|
155
444
|
resizable?: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Wheter the column's cells can be edited or not.
|
|
447
|
+
*/
|
|
448
|
+
editor?: CellEditor<T>;
|
|
156
449
|
/**
|
|
157
450
|
* A function to format the value for display.
|
|
158
451
|
*/
|
|
@@ -170,14 +463,14 @@ interface DisplayColumnOptions<T> extends BaseColumnOptions<T> {
|
|
|
170
463
|
/**
|
|
171
464
|
* Internal column definition used for searching and filtering
|
|
172
465
|
*/
|
|
173
|
-
interface InternalColumnOptions<T> extends BaseColumnOptions<T> {
|
|
466
|
+
interface InternalColumnOptions<T extends object = UnspecifiedRecord> extends BaseColumnOptions<T> {
|
|
174
467
|
/**
|
|
175
468
|
* Marks this column as internal-only.
|
|
176
469
|
* It will be indexed for search and filtering, but strictly excluded from the UI.
|
|
177
470
|
*/
|
|
178
471
|
role: 'internal';
|
|
179
472
|
}
|
|
180
|
-
type ColumnOptions<T> = DisplayColumnOptions<T> | InternalColumnOptions<T>;
|
|
473
|
+
type ColumnOptions<T extends object = UnspecifiedRecord> = DisplayColumnOptions<T> | InternalColumnOptions<T>;
|
|
181
474
|
/**
|
|
182
475
|
* Defines the possible sorting orders for columns.
|
|
183
476
|
*/
|
|
@@ -198,7 +491,7 @@ type SortState = {
|
|
|
198
491
|
/**
|
|
199
492
|
* Represents the current state of a column.
|
|
200
493
|
*/
|
|
201
|
-
interface ColumnState<T> {
|
|
494
|
+
interface ColumnState<T extends object = UnspecifiedRecord> {
|
|
202
495
|
/**
|
|
203
496
|
* The unique field name of the column.
|
|
204
497
|
*/
|
|
@@ -219,9 +512,9 @@ interface ColumnState<T> {
|
|
|
219
512
|
/**
|
|
220
513
|
* {@link ColumnState} with all properties optional except {@link ColumnState.field}
|
|
221
514
|
*/
|
|
222
|
-
type RestorableColumnState<T> = Partial<Omit<ColumnState<T>, 'field'>> & Pick<ColumnState<T>, 'field'>;
|
|
515
|
+
type RestorableColumnState<T extends object = UnspecifiedRecord> = Partial<Omit<ColumnState<T>, 'field'>> & Pick<ColumnState<T>, 'field'>;
|
|
223
516
|
|
|
224
|
-
type RowIdCallback<T> = (row: T, index: number) => RowId;
|
|
517
|
+
type RowIdCallback<T extends object = UnspecifiedRecord> = (row: T, index: number) => RowId;
|
|
225
518
|
/**
|
|
226
519
|
* The method used for selecting rows.
|
|
227
520
|
* * single - Only a single row can be selected at a time
|
|
@@ -234,7 +527,11 @@ type RowSelectionMethod = 'single' | 'multi';
|
|
|
234
527
|
* @param row - The row data.
|
|
235
528
|
* @returns the part string or list of part strings that should be added to this row.
|
|
236
529
|
*/
|
|
237
|
-
type RowPartsCallback<T> = (row: T) => string | string[] | undefined;
|
|
530
|
+
type RowPartsCallback<T extends object = UnspecifiedRecord> = (row: T) => string | string[] | undefined;
|
|
531
|
+
interface StorageInterface {
|
|
532
|
+
getItem: (key: string) => string | null;
|
|
533
|
+
setItem: (key: string, value: string) => void;
|
|
534
|
+
}
|
|
238
535
|
/**
|
|
239
536
|
* Options used to configure what state information
|
|
240
537
|
* should be saved and restored automatically.
|
|
@@ -245,12 +542,8 @@ interface StorageOptions {
|
|
|
245
542
|
* * @example "my-app-users-table-v1"
|
|
246
543
|
*/
|
|
247
544
|
key: string;
|
|
248
|
-
/**
|
|
249
|
-
|
|
250
|
-
* * 'local': Persists after browser is closed (Default).
|
|
251
|
-
* * 'session': Cleared when tab is closed.
|
|
252
|
-
*/
|
|
253
|
-
storage?: 'local' | 'session';
|
|
545
|
+
/** A storage client for getting and setting values. Defaults to window.localStorage */
|
|
546
|
+
storage?: StorageInterface;
|
|
254
547
|
/** Save the current search query */
|
|
255
548
|
saveSearchQuery?: boolean;
|
|
256
549
|
/** Save the current column sorting */
|
|
@@ -267,7 +560,7 @@ interface StorageOptions {
|
|
|
267
560
|
/**
|
|
268
561
|
* Represents the current state of the table
|
|
269
562
|
*/
|
|
270
|
-
interface TableState<T> {
|
|
563
|
+
interface TableState<T extends object = UnspecifiedRecord> {
|
|
271
564
|
/**
|
|
272
565
|
* A list of {@link ColumnState}s representing all of the columns in the table.
|
|
273
566
|
*/
|
|
@@ -281,7 +574,7 @@ interface TableState<T> {
|
|
|
281
574
|
*/
|
|
282
575
|
selectedRows: RowId[];
|
|
283
576
|
}
|
|
284
|
-
type RestorableTableState<T> = Partial<Omit<TableState<T>, 'columns'>> & {
|
|
577
|
+
type RestorableTableState<T extends object = UnspecifiedRecord> = Partial<Omit<TableState<T>, 'columns'>> & {
|
|
285
578
|
columns?: RestorableColumnState<T>[];
|
|
286
579
|
};
|
|
287
580
|
/**
|
|
@@ -298,9 +591,9 @@ interface ExportOptions {
|
|
|
298
591
|
/**
|
|
299
592
|
* Options for configuring a table controller
|
|
300
593
|
*/
|
|
301
|
-
interface TableControllerOptions<T extends object> {
|
|
302
|
-
|
|
303
|
-
|
|
594
|
+
interface TableControllerOptions<T extends object = UnspecifiedRecord> {
|
|
595
|
+
tokenizedSearch?: boolean;
|
|
596
|
+
scoredSearch?: boolean;
|
|
304
597
|
searchTokenizer?: TokenizerCallback;
|
|
305
598
|
rowIdCallback?: RowIdCallback<T>;
|
|
306
599
|
rowSelectionMethod?: RowSelectionMethod | null;
|
|
@@ -308,12 +601,182 @@ interface TableControllerOptions<T extends object> {
|
|
|
308
601
|
columns?: ColumnOptions<T>[];
|
|
309
602
|
data?: T[];
|
|
310
603
|
}
|
|
604
|
+
interface YatlTableControllerApi<T extends object = UnspecifiedRecord> {
|
|
605
|
+
/**
|
|
606
|
+
* The definitions for the columns to be rendered.
|
|
607
|
+
* This defines the field mapping, titles, sortability, and other static options.
|
|
608
|
+
*/
|
|
609
|
+
columns: ColumnOptions<T>[];
|
|
610
|
+
/**
|
|
611
|
+
* The dynamic runtime state of the table's columns (visibility, width, and sort order).
|
|
612
|
+
*
|
|
613
|
+
* Unlike the static `columns` definitions, `columnStates` represents the current,
|
|
614
|
+
* interactive state of the grid. This is primarily used for programmatic control,
|
|
615
|
+
* or for saving and restoring user preferences (e.g., from `localStorage`).
|
|
616
|
+
*/
|
|
617
|
+
columnStates: ColumnState<T>[];
|
|
618
|
+
/**
|
|
619
|
+
* The array of data objects to be displayed.
|
|
620
|
+
* Objects must satisfy the `WeakKey` constraint (objects only, no primitives).
|
|
621
|
+
*/
|
|
622
|
+
data: T[];
|
|
623
|
+
/**
|
|
624
|
+
* An optional set of criteria to filter the visible rows.
|
|
625
|
+
* This runs **before** the global search query is applied.
|
|
626
|
+
* * You can provide:
|
|
627
|
+
* 1. A **Partial Object**: matches rows where specific keys equal specific values (AND logic).
|
|
628
|
+
* 2. A **Callback Function**: returns `true` to keep the row, `false` to hide it.
|
|
629
|
+
* * @example
|
|
630
|
+
* // 1. Object Syntax (Simple Exact Match)
|
|
631
|
+
* // Shows rows where status is 'active' AND role is 'admin'
|
|
632
|
+
* table.filters = { status: 'active', role: 'admin' };
|
|
633
|
+
* * @example
|
|
634
|
+
* // 2. Callback Syntax (Complex Logic)
|
|
635
|
+
* // Shows rows where age is over 21 OR they are a VIP
|
|
636
|
+
* table.filters = (row) => row.age > 21 || row.isVip;
|
|
637
|
+
*/
|
|
638
|
+
filters: Filters<T> | FilterCallback<T> | null;
|
|
639
|
+
/**
|
|
640
|
+
* The current text string used to filter the table data.
|
|
641
|
+
* Setting this property triggers a new search and render cycle.
|
|
642
|
+
*/
|
|
643
|
+
searchQuery: string;
|
|
644
|
+
/**
|
|
645
|
+
* Enables tokenized search behavior.
|
|
646
|
+
* When enabled, the search query is split into individual tokens using the
|
|
647
|
+
* `searchTokenizer` function (defaults to splitting on whitespace).
|
|
648
|
+
* A row is considered a match if **ANY** of the tokens appear in the searchable fields.
|
|
649
|
+
*/
|
|
650
|
+
tokenizedSearch: boolean;
|
|
651
|
+
/**
|
|
652
|
+
* Enables weighted relevance scoring for search results.
|
|
653
|
+
* When enabled, exact matches and prefix matches are ranked higher than substring matches.
|
|
654
|
+
* Rows are sorted by their relevance score descending.
|
|
655
|
+
*/
|
|
656
|
+
scoredSearch: boolean;
|
|
657
|
+
/**
|
|
658
|
+
* A function that splits the search query into tokens.
|
|
659
|
+
* Only used if search tokenization is enabled.
|
|
660
|
+
* @default whitespaceTokenizer
|
|
661
|
+
*/
|
|
662
|
+
searchTokenizer: TokenizerCallback;
|
|
663
|
+
/**
|
|
664
|
+
* The row selection method to use.
|
|
665
|
+
* * single - Only a single row can be selected at a time
|
|
666
|
+
* * multi - Multiple rows can be selected at a time
|
|
667
|
+
* * null - Disable row selection
|
|
668
|
+
* @attr row-selection-method
|
|
669
|
+
*/
|
|
670
|
+
rowSelectionMethod: RowSelectionMethod | null;
|
|
671
|
+
/**
|
|
672
|
+
* List of currently selected row indexes.
|
|
673
|
+
* * **NOTE**: These indexes are based off the of
|
|
674
|
+
* the original data array index, *not* the filtered data.
|
|
675
|
+
*/
|
|
676
|
+
selectedRowIds: RowId[];
|
|
677
|
+
/**
|
|
678
|
+
* A callback function used to extract or generate a unique identifier for each row.
|
|
679
|
+
*
|
|
680
|
+
* A stable, unique ID is heavily relied upon by the grid engine for maintaining row selection
|
|
681
|
+
* state, tracking row metadata, and ensuring optimal rendering performance within the virtual
|
|
682
|
+
* scroller—especially when data is actively being sorted, filtered, or updated.
|
|
683
|
+
*
|
|
684
|
+
* **Default Behavior:** * If not provided, the table will automatically attempt to locate an `id`, `key`, or `_id`
|
|
685
|
+
* property on the row data object. If none are found, it falls back to using the row's original
|
|
686
|
+
* array index (which will trigger a console warning, as indices are inherently unstable during sorting).
|
|
687
|
+
*
|
|
688
|
+
* **Note:** Because this expects a JavaScript function, it is exposed strictly as a property
|
|
689
|
+
* and does not have a corresponding HTML attribute. You must use the property binding syntax
|
|
690
|
+
* (`.rowIdCallback`) in a Lit template.
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
* ```html
|
|
694
|
+
* * <yatl-table .rowIdCallback=${(row) => row.deviceUuid}></yatl-table>
|
|
695
|
+
* ```
|
|
696
|
+
*
|
|
697
|
+
* @example
|
|
698
|
+
* ```ts
|
|
699
|
+
* // Programmatic assignment using a composite key
|
|
700
|
+
* table.rowIdCallback = (row, index) => `${row.chassisId}-${row.slotNumber}`;
|
|
701
|
+
* ```
|
|
702
|
+
*/
|
|
703
|
+
rowIdCallback: RowIdCallback<T>;
|
|
704
|
+
/**
|
|
705
|
+
* Configuration options for automatically saving and restoring table state
|
|
706
|
+
* (column width, order, visibility, etc.) to the provided storage interface.
|
|
707
|
+
*/
|
|
708
|
+
storageOptions: StorageOptions | null;
|
|
709
|
+
}
|
|
710
|
+
interface YatlTableApi<T extends object = UnspecifiedRecord> extends YatlTableControllerApi<T> {
|
|
711
|
+
/**
|
|
712
|
+
* The table controller to use for this table component.
|
|
713
|
+
*/
|
|
714
|
+
controller: YatlTableController<T>;
|
|
715
|
+
/**
|
|
716
|
+
* Enables visual row striping
|
|
717
|
+
*/
|
|
718
|
+
striped: boolean;
|
|
719
|
+
/**
|
|
720
|
+
* Default sortability for all columns.
|
|
721
|
+
* Can be overridden by setting `sortable` on the specific column definition.
|
|
722
|
+
*
|
|
723
|
+
* **NOTE:** Changing this will not clear sorted column states.
|
|
724
|
+
*/
|
|
725
|
+
sortable: boolean;
|
|
726
|
+
/**
|
|
727
|
+
* Default resizability for all columns.
|
|
728
|
+
* Can be overridden by setting `resizable` on the specific column definition.
|
|
729
|
+
*
|
|
730
|
+
* **NOTE:** Changing this will not clear current column widths.
|
|
731
|
+
*/
|
|
732
|
+
resizable: boolean;
|
|
733
|
+
/**
|
|
734
|
+
* Allows users to reorder columns by dragging and dropping headers.
|
|
735
|
+
*/
|
|
736
|
+
reorderable: boolean;
|
|
737
|
+
/**
|
|
738
|
+
* When set, shows a column to the left of each row with its row number.
|
|
739
|
+
*/
|
|
740
|
+
rowNumbers: boolean;
|
|
741
|
+
/**
|
|
742
|
+
* When set, only the visible rows are rendered to the DOM, significantly improving
|
|
743
|
+
* performance for large datasets (1000+ rows).
|
|
744
|
+
*/
|
|
745
|
+
virtualScroll: boolean;
|
|
746
|
+
/**
|
|
747
|
+
* Hides the built-in footer row which displays the current record count.
|
|
748
|
+
* The footer content can be customized using the `slot="footer"` element.
|
|
749
|
+
*/
|
|
750
|
+
hideFooter: boolean;
|
|
751
|
+
/**
|
|
752
|
+
* When set, completely disables editing for all columns.
|
|
753
|
+
*/
|
|
754
|
+
disableEditing: boolean;
|
|
755
|
+
/**
|
|
756
|
+
* The string to display in a cell when the data value is `null` or `undefined`.
|
|
757
|
+
*/
|
|
758
|
+
nullValuePlaceholder: string;
|
|
759
|
+
/**
|
|
760
|
+
* The message displayed when the `data` array is empty.
|
|
761
|
+
*/
|
|
762
|
+
emptyMessage: string;
|
|
763
|
+
/**
|
|
764
|
+
* The message displayed when `data` exists but the current search/filter results in zero visible rows.
|
|
765
|
+
*/
|
|
766
|
+
noResultsMessage: string;
|
|
767
|
+
/**
|
|
768
|
+
* A callback function to conditionally apply CSS parts to table rows.
|
|
769
|
+
*/
|
|
770
|
+
rowParts: RowPartsCallback<T> | null;
|
|
771
|
+
}
|
|
311
772
|
|
|
312
773
|
/**
|
|
313
774
|
* Base event class that bubbles and is composed.
|
|
314
775
|
*/
|
|
315
776
|
declare abstract class YatlEvent extends Event {
|
|
316
777
|
constructor(name: string, options?: EventInit);
|
|
778
|
+
}
|
|
779
|
+
declare abstract class YatlTableControllerEvent extends YatlEvent {
|
|
317
780
|
abstract clone(): YatlEvent;
|
|
318
781
|
}
|
|
319
782
|
declare class YatlRowClickEvent<T extends object = UnspecifiedRecord> extends YatlEvent {
|
|
@@ -324,7 +787,6 @@ declare class YatlRowClickEvent<T extends object = UnspecifiedRecord> extends Ya
|
|
|
324
787
|
readonly originalEvent: MouseEvent;
|
|
325
788
|
static readonly EVENT_NAME = "yatl-row-click";
|
|
326
789
|
constructor(row: T, rowId: RowId, index: number, field: NestedKeyOf<T>, originalEvent: MouseEvent);
|
|
327
|
-
clone(): YatlRowClickEvent<T>;
|
|
328
790
|
}
|
|
329
791
|
declare class YatlRowSelectRequest extends YatlEvent {
|
|
330
792
|
readonly rowId: RowId;
|
|
@@ -332,9 +794,8 @@ declare class YatlRowSelectRequest extends YatlEvent {
|
|
|
332
794
|
readonly currentlySelectedRows: RowId[];
|
|
333
795
|
static readonly EVENT_NAME = "yatl-row-select-request";
|
|
334
796
|
constructor(rowId: RowId, selected: boolean, currentlySelectedRows: RowId[]);
|
|
335
|
-
clone(): YatlRowSelectRequest;
|
|
336
797
|
}
|
|
337
|
-
declare class YatlRowSelectEvent extends
|
|
798
|
+
declare class YatlRowSelectEvent extends YatlTableControllerEvent {
|
|
338
799
|
readonly selectedIds: RowId[];
|
|
339
800
|
readonly previouslySelectedRows: RowId[];
|
|
340
801
|
static readonly EVENT_NAME = "yatl-row-select";
|
|
@@ -347,9 +808,8 @@ declare class YatlColumnSortRequest<T extends object = UnspecifiedRecord> extend
|
|
|
347
808
|
readonly multisort: boolean;
|
|
348
809
|
static readonly EVENT_NAME = "yatl-column-sort-request";
|
|
349
810
|
constructor(field: NestedKeyOf<T>, order: SortOrder | null, multisort: boolean);
|
|
350
|
-
clone(): YatlColumnSortRequest<T>;
|
|
351
811
|
}
|
|
352
|
-
declare class YatlColumnSortEvent<T extends object = UnspecifiedRecord> extends
|
|
812
|
+
declare class YatlColumnSortEvent<T extends object = UnspecifiedRecord> extends YatlTableControllerEvent {
|
|
353
813
|
readonly field: NestedKeyOf<T>;
|
|
354
814
|
readonly order: SortOrder | null;
|
|
355
815
|
readonly multisort: boolean;
|
|
@@ -357,14 +817,14 @@ declare class YatlColumnSortEvent<T extends object = UnspecifiedRecord> extends
|
|
|
357
817
|
constructor(field: NestedKeyOf<T>, order: SortOrder | null, multisort: boolean);
|
|
358
818
|
clone(): YatlColumnSortEvent<T>;
|
|
359
819
|
}
|
|
360
|
-
declare class YatlColumnToggleEvent<T extends object = UnspecifiedRecord> extends
|
|
820
|
+
declare class YatlColumnToggleEvent<T extends object = UnspecifiedRecord> extends YatlTableControllerEvent {
|
|
361
821
|
readonly field: NestedKeyOf<T>;
|
|
362
822
|
readonly visible: boolean;
|
|
363
823
|
static readonly EVENT_NAME = "yatl-column-toggle";
|
|
364
824
|
constructor(field: NestedKeyOf<T>, visible: boolean);
|
|
365
825
|
clone(): YatlColumnToggleEvent<T>;
|
|
366
826
|
}
|
|
367
|
-
declare class YatlColumnResizeEvent<T extends object = UnspecifiedRecord> extends
|
|
827
|
+
declare class YatlColumnResizeEvent<T extends object = UnspecifiedRecord> extends YatlTableControllerEvent {
|
|
368
828
|
readonly field: NestedKeyOf<T>;
|
|
369
829
|
readonly width: number | null;
|
|
370
830
|
static readonly EVENT_NAME = "yatl-column-resize";
|
|
@@ -377,27 +837,35 @@ declare class YatlColumnReorderRequest<T extends object = UnspecifiedRecord> ext
|
|
|
377
837
|
readonly newIndex: number;
|
|
378
838
|
static readonly EVENT_NAME = "yatl-column-reorder-request";
|
|
379
839
|
constructor(movedColumn: NestedKeyOf<T>, originalIndex: number, newIndex: number);
|
|
380
|
-
clone(): YatlColumnReorderRequest<T>;
|
|
381
840
|
}
|
|
382
|
-
declare class YatlColumnReorderEvent<T extends object = UnspecifiedRecord> extends
|
|
841
|
+
declare class YatlColumnReorderEvent<T extends object = UnspecifiedRecord> extends YatlTableControllerEvent {
|
|
383
842
|
readonly order: NestedKeyOf<T>[];
|
|
384
843
|
static readonly EVENT_NAME = "yatl-column-reorder";
|
|
385
844
|
constructor(order: NestedKeyOf<T>[]);
|
|
386
845
|
clone(): YatlColumnReorderEvent<T>;
|
|
387
846
|
}
|
|
388
|
-
declare class
|
|
847
|
+
declare class YatlCellEditEvent<T extends object = UnspecifiedRecord> extends YatlEvent {
|
|
848
|
+
readonly row: T;
|
|
849
|
+
readonly rowId: RowId;
|
|
850
|
+
readonly field: NestedKeyOf<T>;
|
|
851
|
+
readonly originalValue: unknown;
|
|
852
|
+
readonly currentValue: unknown;
|
|
853
|
+
static readonly EVENT_NAME = "yatl-cell-edit";
|
|
854
|
+
constructor(row: T, rowId: RowId, field: NestedKeyOf<T>, originalValue: unknown, currentValue: unknown);
|
|
855
|
+
}
|
|
856
|
+
declare class YatlTableSearchEvent extends YatlTableControllerEvent {
|
|
389
857
|
readonly query: string;
|
|
390
858
|
static readonly EVENT_NAME = "yatl-table-search";
|
|
391
859
|
constructor(query: string);
|
|
392
860
|
clone(): YatlTableSearchEvent;
|
|
393
861
|
}
|
|
394
|
-
declare class YatlTableViewChangeEvent<T extends object = UnspecifiedRecord> extends
|
|
862
|
+
declare class YatlTableViewChangeEvent<T extends object = UnspecifiedRecord> extends YatlTableControllerEvent {
|
|
395
863
|
readonly data: T[];
|
|
396
864
|
static readonly EVENT_NAME = "yatl-table-view-change";
|
|
397
865
|
constructor(data: T[]);
|
|
398
866
|
clone(): YatlTableViewChangeEvent<T>;
|
|
399
867
|
}
|
|
400
|
-
declare class YatlTableStateChangeEvent<T extends object = UnspecifiedRecord> extends
|
|
868
|
+
declare class YatlTableStateChangeEvent<T extends object = UnspecifiedRecord> extends YatlTableControllerEvent {
|
|
401
869
|
readonly state: TableState<T>;
|
|
402
870
|
readonly triggers: string[];
|
|
403
871
|
static readonly EVENT_NAME = "yatl-table-state-change";
|
|
@@ -421,115 +889,135 @@ declare global {
|
|
|
421
889
|
}
|
|
422
890
|
}
|
|
423
891
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
892
|
+
interface BaseEditorOptions<T extends object = UnspecifiedRecord> {
|
|
893
|
+
canEdit?: (field: NestedKeyOf<T>, row: T) => boolean;
|
|
894
|
+
onSave?: (oldValue: unknown, newValue: unknown, field: NestedKeyOf<T>, row: T) => MaybePromise<unknown | undefined>;
|
|
895
|
+
}
|
|
896
|
+
declare abstract class BaseEditor<T extends object = UnspecifiedRecord> implements CellEditor<T> {
|
|
897
|
+
protected readonly options?: BaseEditorOptions<T> | undefined;
|
|
898
|
+
protected currentValue: unknown;
|
|
899
|
+
constructor(options?: BaseEditorOptions<T> | undefined);
|
|
900
|
+
reset(): void;
|
|
901
|
+
canEdit(field: NestedKeyOf<T>, row: T): boolean;
|
|
902
|
+
abstract render(value: unknown, field: NestedKeyOf<T>, row: T, controller: YatlTableController<T>): unknown;
|
|
903
|
+
save(originalValue: unknown, field: NestedKeyOf<T>, row: T, _controller: YatlTableController<T>): unknown;
|
|
429
904
|
}
|
|
430
905
|
|
|
431
|
-
declare class
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
private
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
906
|
+
declare class InputEditor<T extends object = UnspecifiedRecord> extends BaseEditor<T> {
|
|
907
|
+
readonly options?: InputEditorOptions<T> | undefined;
|
|
908
|
+
constructor(options?: InputEditorOptions<T> | undefined);
|
|
909
|
+
render(value: unknown, _field: NestedKeyOf<T>, _row: T, _controller: YatlTableController<T>): lit_html.TemplateResult<1>;
|
|
910
|
+
private handleChange;
|
|
911
|
+
}
|
|
912
|
+
type InputType = 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'month' | 'number' | 'range' | 'tel' | 'text' | 'time' | 'url' | 'week';
|
|
913
|
+
interface InputEditorOptions<T extends object = UnspecifiedRecord> extends BaseEditorOptions<T> {
|
|
914
|
+
type?: InputType;
|
|
915
|
+
minlength?: number;
|
|
916
|
+
maxlength?: number;
|
|
917
|
+
min?: number | string;
|
|
918
|
+
max?: number | string;
|
|
919
|
+
step?: number;
|
|
920
|
+
pattern?: string;
|
|
921
|
+
placeholder?: string;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
interface NumberEditorOptions<T extends object = UnspecifiedRecord> extends BaseEditorOptions<T> {
|
|
925
|
+
min?: number;
|
|
926
|
+
max?: number;
|
|
927
|
+
step?: number;
|
|
928
|
+
}
|
|
929
|
+
declare class NumberEditor<T extends object = UnspecifiedRecord> extends InputEditor<T> {
|
|
930
|
+
constructor(options?: NumberEditorOptions<T>);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
declare class SelectEditor<T extends object = UnspecifiedRecord> extends BaseEditor<T> {
|
|
934
|
+
protected readonly options?: SelectEditorOptions<T> | undefined;
|
|
935
|
+
constructor(options?: SelectEditorOptions<T> | undefined);
|
|
936
|
+
render(value: unknown, field: NestedKeyOf<T>, row: T, controller: YatlTableController<T>): lit_html.TemplateResult<1>;
|
|
937
|
+
renderOption(option: unknown, select: boolean): lit_html.TemplateResult<1>;
|
|
938
|
+
private handleChange;
|
|
939
|
+
}
|
|
940
|
+
interface SelectEditorOptions<T extends object = UnspecifiedRecord> extends BaseEditorOptions<T> {
|
|
941
|
+
labelRenderer?: (value: unknown) => [string, string];
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
interface TextEditorOptions<T extends object = UnspecifiedRecord> extends BaseEditorOptions<T> {
|
|
945
|
+
minlength?: number;
|
|
946
|
+
maxlength?: number;
|
|
947
|
+
pattern?: string;
|
|
948
|
+
placeholder?: string;
|
|
949
|
+
}
|
|
950
|
+
declare class TextEditor<T extends object = UnspecifiedRecord> extends InputEditor<T> {
|
|
951
|
+
constructor(options?: TextEditorOptions<T>);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* A virtualized data table capable of handling complex sorting, filtering, and tokenized searching.
|
|
956
|
+
*
|
|
957
|
+
* @element yatl-table
|
|
958
|
+
* @summary A high-performance grid engine for rugged environments.
|
|
959
|
+
*
|
|
960
|
+
* @fires yatl-cell-edit - Fired after a cell value has been edited.
|
|
961
|
+
* @fires yatl-row-click - Fired when a user clicks a row.
|
|
962
|
+
* @fires yatl-row-select-request - Fired before the row selection changes. Cancellable
|
|
963
|
+
* @fires yatl-row-select - Fired when the row selection changes.
|
|
964
|
+
* @fires yatl-column-sort-request - Fired before a column sort order changes. Cancellable.
|
|
965
|
+
* @fires yatl-column-sort - Fired when a column sort order changes.
|
|
966
|
+
* @fires yatl-column-toggle - Fired when a column's visibility changes.
|
|
967
|
+
* @fires yatl-column-resize - Fired after a column has been resized by the user.
|
|
968
|
+
* @fires yatl-column-reorder-request - Fired when the user drops a column into a new position. Cancellable.
|
|
969
|
+
* @fires yatl-column-reorder - Fired after the column order changes.
|
|
970
|
+
* @fires yatl-table-search - Fired when the search query is updated.
|
|
971
|
+
* @fires yatl-table-view-change - Fired when the visible slice of data changes due to sorting, filtering, or data updates. Payload contains the processed rows.
|
|
972
|
+
* @fires yatl-table-state-change - Fired when any persistable state (width, order, sort, query) changes. Used for syncing with local storage.
|
|
973
|
+
*/
|
|
974
|
+
declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement implements YatlTableApi<T> {
|
|
975
|
+
static styles: lit.CSSResult[];
|
|
976
|
+
private tableElement;
|
|
977
|
+
private virtualizer?;
|
|
978
|
+
private editor?;
|
|
979
|
+
private get virtualizerRef();
|
|
980
|
+
private resizeState;
|
|
981
|
+
private dragColumn;
|
|
982
|
+
private useYatlUi;
|
|
983
|
+
private editingState;
|
|
984
|
+
private _controller;
|
|
985
|
+
get controller(): YatlTableController<T>;
|
|
986
|
+
set controller(controller: YatlTableController<T>);
|
|
476
987
|
get columns(): ColumnOptions<T>[];
|
|
477
988
|
set columns(columns: ColumnOptions<T>[]);
|
|
989
|
+
/**
|
|
990
|
+
* Gets a list of columns with the display role
|
|
991
|
+
* **This will always be ordered the same as the visual column order**
|
|
992
|
+
*/
|
|
478
993
|
get displayColumns(): DisplayColumnOptions<T>[];
|
|
479
994
|
get columnStates(): ColumnState<T>[];
|
|
480
995
|
set columnStates(states: ColumnState<T>[]);
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
996
|
+
get data(): T[];
|
|
997
|
+
set data(value: T[]);
|
|
998
|
+
get filteredData(): T[];
|
|
999
|
+
get dataUpdateTimestamp(): Date | null;
|
|
1000
|
+
get filters(): Partial<{ [K in NestedKeyOf<T>]: unknown; }> | FilterCallback<T> | null;
|
|
1001
|
+
set filters(filters: Partial<{ [K in NestedKeyOf<T>]: unknown; }> | FilterCallback<T> | null);
|
|
1002
|
+
/** @attr search-query */
|
|
485
1003
|
get searchQuery(): string;
|
|
486
1004
|
set searchQuery(query: string);
|
|
487
|
-
/**
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
1005
|
+
/** @attr tokenized-search */
|
|
1006
|
+
get tokenizedSearch(): boolean;
|
|
1007
|
+
set tokenizedSearch(enable: boolean);
|
|
1008
|
+
/** @attr scored-search */
|
|
1009
|
+
get scoredSearch(): boolean;
|
|
1010
|
+
set scoredSearch(enable: boolean);
|
|
492
1011
|
get searchTokenizer(): TokenizerCallback;
|
|
493
1012
|
set searchTokenizer(tokenizer: TokenizerCallback);
|
|
494
|
-
/**
|
|
495
|
-
* An optional set of criteria to filter the visible rows.
|
|
496
|
-
* This runs **before** the global search query is applied.
|
|
497
|
-
* * You can provide:
|
|
498
|
-
* 1. A **Partial Object**: matches rows where specific keys equal specific values (AND logic).
|
|
499
|
-
* 2. A **Callback Function**: returns `true` to keep the row, `false` to hide it.
|
|
500
|
-
* * @example
|
|
501
|
-
* // 1. Object Syntax (Simple Exact Match)
|
|
502
|
-
* // Shows rows where status is 'active' AND role is 'admin'
|
|
503
|
-
* table.filters = { status: 'active', role: 'admin' };
|
|
504
|
-
* * @example
|
|
505
|
-
* // 2. Callback Syntax (Complex Logic)
|
|
506
|
-
* // Shows rows where age is over 21 OR they are a VIP
|
|
507
|
-
* table.filters = (row) => row.age > 21 || row.isVip;
|
|
508
|
-
*/
|
|
509
|
-
get filters(): Partial<{ [K in NestedKeyOf<T>]: unknown; }> | FilterCallback<T> | null;
|
|
510
|
-
set filters(filters: Partial<{ [K in NestedKeyOf<T>]: unknown; }> | FilterCallback<T> | null);
|
|
511
|
-
/**
|
|
512
|
-
* The row selection method to use.
|
|
513
|
-
* * single - Only a single row can be selected at a time
|
|
514
|
-
* * multi - Multiple rows can be selected at a time
|
|
515
|
-
* * null - Disable row selection
|
|
516
|
-
*/
|
|
1013
|
+
/** @attr row-selection-method */
|
|
517
1014
|
get rowSelectionMethod(): RowSelectionMethod | null;
|
|
518
1015
|
set rowSelectionMethod(selection: RowSelectionMethod | null);
|
|
519
|
-
/**
|
|
520
|
-
* List of currently selected row indexes.
|
|
521
|
-
* * **NOTE**: These indexes are based off the of
|
|
522
|
-
* the original data array index, *not* the filtered data.
|
|
523
|
-
*/
|
|
524
1016
|
get selectedRowIds(): RowId[];
|
|
525
1017
|
set selectedRowIds(rows: RowId[]);
|
|
526
|
-
/**
|
|
527
|
-
* Configuration options for automatically saving and restoring table state
|
|
528
|
-
* (column width, order, visibility, etc.) to browser storage.
|
|
529
|
-
*/
|
|
530
1018
|
get storageOptions(): {
|
|
531
1019
|
key: string;
|
|
532
|
-
storage?:
|
|
1020
|
+
storage?: StorageInterface;
|
|
533
1021
|
saveSearchQuery?: boolean;
|
|
534
1022
|
saveColumnSortOrders?: boolean;
|
|
535
1023
|
saveColumnVisibility?: boolean;
|
|
@@ -539,7 +1027,7 @@ declare class YatlTableController<T extends object = UnspecifiedRecord> extends
|
|
|
539
1027
|
} | null;
|
|
540
1028
|
set storageOptions(options: {
|
|
541
1029
|
key: string;
|
|
542
|
-
storage?:
|
|
1030
|
+
storage?: StorageInterface;
|
|
543
1031
|
saveSearchQuery?: boolean;
|
|
544
1032
|
saveColumnSortOrders?: boolean;
|
|
545
1033
|
saveColumnVisibility?: boolean;
|
|
@@ -549,393 +1037,34 @@ declare class YatlTableController<T extends object = UnspecifiedRecord> extends
|
|
|
549
1037
|
} | null);
|
|
550
1038
|
get rowIdCallback(): RowIdCallback<T>;
|
|
551
1039
|
set rowIdCallback(callback: RowIdCallback<T>);
|
|
552
|
-
/**
|
|
553
|
-
* The array of data objects to be displayed.
|
|
554
|
-
* Objects must satisfy the `WeakKey` constraint (objects only, no primitives).
|
|
555
|
-
*/
|
|
556
|
-
get data(): T[];
|
|
557
|
-
set data(data: T[]);
|
|
558
|
-
get filteredData(): T[];
|
|
559
|
-
get dataUpdateTimestamp(): Date | null;
|
|
560
|
-
constructor(host?: ReactiveControllerHost, options?: TableControllerOptions<T>);
|
|
561
|
-
attach(host: ReactiveControllerHost): void;
|
|
562
|
-
detach(host: ReactiveControllerHost): void;
|
|
563
|
-
getColumn(field: NestedKeyOf<T>): ColumnOptions<T> | undefined;
|
|
564
|
-
getDisplayColumn(field: NestedKeyOf<T>): DisplayColumnOptions<T> | undefined;
|
|
565
|
-
/**
|
|
566
|
-
* Gets a copy of the current state of the table.
|
|
567
|
-
*/
|
|
568
|
-
getTableState(): TableState<T>;
|
|
569
|
-
/**
|
|
570
|
-
* Restores the table to the provided state.
|
|
571
|
-
* @param state - The state to restore the table to.
|
|
572
|
-
*/
|
|
573
|
-
updateTableState(state: RestorableTableState<T>): void;
|
|
574
|
-
getColumnState(field: NestedKeyOf<T>): ColumnState<T>;
|
|
575
|
-
updateColumnState(field: NestedKeyOf<T>, state: RestorableColumnState<T>): void;
|
|
576
|
-
search(query: string): void;
|
|
577
|
-
getColumnFilterValues(field: NestedKeyOf<T>, includeNull?: boolean): Map<unknown, number>;
|
|
578
|
-
/**
|
|
579
|
-
* Sorts the table by a specified column and order.
|
|
580
|
-
* If `order` is `null`, the sort on this column is removed.
|
|
581
|
-
* @param field - The field name of the column to sort by.
|
|
582
|
-
* @param order - The sort order: 'asc', 'desc', or `null` to remove sorting for this column.
|
|
583
|
-
* @param clear - Clear all other sorting
|
|
584
|
-
*/
|
|
585
|
-
sort(field: NestedKeyOf<T>, order: SortOrder | null, clear?: boolean): void;
|
|
586
|
-
/**
|
|
587
|
-
* Toggles the visibility of hte specified column
|
|
588
|
-
* @param field - The field name of the column to toggle.
|
|
589
|
-
* @param visible - Optionally force the visibility state.
|
|
590
|
-
*/
|
|
591
|
-
toggleColumnVisibility(field: NestedKeyOf<T>, visible?: boolean): void;
|
|
592
|
-
/**
|
|
593
|
-
* Shows the specified column
|
|
594
|
-
* @param field - The field name of the column to show.
|
|
595
|
-
*/
|
|
596
|
-
showColumn(field: NestedKeyOf<T>): void;
|
|
597
|
-
/**
|
|
598
|
-
* Hides the specified column
|
|
599
|
-
* @param field - The field name of the column to hide.
|
|
600
|
-
*/
|
|
601
|
-
hideColumn(field: NestedKeyOf<T>): void;
|
|
602
|
-
/**
|
|
603
|
-
* Moves a column to a new position
|
|
604
|
-
* @param field - The column to move
|
|
605
|
-
* @param newPosition The index or field of the column to move it to.
|
|
606
|
-
* @returns
|
|
607
|
-
*/
|
|
608
|
-
moveColumn(field: NestedKeyOf<T>, newPosition: number | NestedKeyOf<T>): void;
|
|
609
|
-
resizeColumn(field: NestedKeyOf<T>, width: number | null): void;
|
|
610
|
-
isRowSelected(row: T): boolean;
|
|
611
|
-
/**
|
|
612
|
-
* Toggles the selection state of a specific row.
|
|
613
|
-
*/
|
|
614
|
-
toggleRowSelection(row: T, state?: boolean): void;
|
|
615
|
-
/**
|
|
616
|
-
* Selects a specific row.
|
|
617
|
-
*/
|
|
618
|
-
selectRow(row: T): void;
|
|
619
|
-
/**
|
|
620
|
-
* Deselects a specific row.
|
|
621
|
-
*/
|
|
622
|
-
deselectRow(row: T): void;
|
|
623
|
-
/**
|
|
624
|
-
* Selects all currently visible rows (for "Select All" checkbox).
|
|
625
|
-
*/
|
|
626
|
-
selectAll(): void;
|
|
627
|
-
/**
|
|
628
|
-
* Clears all selection.
|
|
629
|
-
*/
|
|
630
|
-
deselectAll(): void;
|
|
631
|
-
/**
|
|
632
|
-
* Export the current visible table data to a CSV file.
|
|
633
|
-
* @param options - Options for configuring what should be exported.
|
|
634
|
-
*/
|
|
635
|
-
export(options?: ExportOptions): Blob;
|
|
636
|
-
/**
|
|
637
|
-
* Gets the row associated with the provided ID.
|
|
638
|
-
* @param id - The ID of the row to get
|
|
639
|
-
* @returns
|
|
640
|
-
*/
|
|
641
|
-
getRow(id: RowId): T | undefined;
|
|
642
|
-
/**
|
|
643
|
-
* Finds the first row where {@link field} matches {@link value}
|
|
644
|
-
* @param field - The field name within the row data to search.
|
|
645
|
-
* @param value - The value to match against the field's content.
|
|
646
|
-
* @returns The found row, or undefined if no match is found.
|
|
647
|
-
*/
|
|
648
|
-
findRow(field: NestedKeyOf<T>, value: unknown): T | undefined;
|
|
649
|
-
/**
|
|
650
|
-
* Finds the original index of the first row where the specified field matches the given value.
|
|
651
|
-
* This searches through the original, unfiltered dataset.
|
|
652
|
-
* @param field - The field name within the row data to search.
|
|
653
|
-
* @param value - The value to match against the field's content.
|
|
654
|
-
* @returns The original index of the found row, or -1 if no match is found.
|
|
655
|
-
* @example
|
|
656
|
-
* ```ts
|
|
657
|
-
* const index = dataTable.indexOf('id', 12345);
|
|
658
|
-
* if (index >= 0) {
|
|
659
|
-
* dataTable.updateRow({description: "Updated description"}, index);
|
|
660
|
-
* }
|
|
661
|
-
* ```
|
|
662
|
-
*/
|
|
663
|
-
findRowIndex(field: NestedKeyOf<T>, value: unknown): number;
|
|
664
|
-
updateRow(rowId: RowId, data: Partial<T>): void;
|
|
665
|
-
/**
|
|
666
|
-
* Updates the data of a row at a specific original index.
|
|
667
|
-
* @param index - The original index of the row to update.
|
|
668
|
-
* @param data - An object containing the new data to assign to the row. Existing fields will be updated, and new fields will be added.
|
|
669
|
-
*
|
|
670
|
-
* @example
|
|
671
|
-
* ```ts
|
|
672
|
-
* const index = dataTable.indexOf('id', 12345);
|
|
673
|
-
* if (index >= 0) {
|
|
674
|
-
* dataTable.updateRow(index, {description: "Updated description"});
|
|
675
|
-
* }
|
|
676
|
-
* ```
|
|
677
|
-
*/
|
|
678
|
-
updateRowAtIndex(index: number, data: Partial<T>): void;
|
|
679
|
-
/**
|
|
680
|
-
* Deletes the row with the matching ID.
|
|
681
|
-
* @param rowIds - The IDs rows to delete
|
|
682
|
-
*/
|
|
683
|
-
deleteRow(...rowIds: RowId[]): void;
|
|
684
|
-
/**
|
|
685
|
-
* Deletes a row at a specific original index from the table.
|
|
686
|
-
* @param indexes - The original indexes of rows to delete.
|
|
687
|
-
*/
|
|
688
|
-
deleteRowAtIndex(...indexes: number[]): void;
|
|
689
|
-
getRowId(row: T): RowId;
|
|
690
|
-
getRowIndex(row: T): number;
|
|
691
|
-
getRowHighlightIndicies(row: T): Record<string, [number, number][]> | undefined;
|
|
692
|
-
hostConnected(): void;
|
|
693
|
-
hostDisconnected(): void;
|
|
694
|
-
hostUpdate(): void;
|
|
695
|
-
hostUpdated(): void;
|
|
696
|
-
requestUpdate(...props: (keyof YatlTableController)[]): void;
|
|
697
|
-
/**
|
|
698
|
-
* Calculates a relevance score for a given query against a target string.
|
|
699
|
-
*
|
|
700
|
-
* This function implements a tiered matching strategy:
|
|
701
|
-
* 1. **Exact Match**: The query exactly matches the target. This yields the highest score.
|
|
702
|
-
* 2. **Prefix Match**: The target starts with the query. This is the next most relevant.
|
|
703
|
-
* 3. **Substring Match**: The target contains the query somewhere. This is the least relevant.
|
|
704
|
-
*
|
|
705
|
-
* The final score is weighted and adjusted by the length difference between the query and the target
|
|
706
|
-
* to ensure that more specific matches (e.g., "apple" vs "application" for the query "apple") rank higher.
|
|
707
|
-
*
|
|
708
|
-
* @param query The search term (e.g., "app").
|
|
709
|
-
* @param target The string to be searched (e.g., "Apple" or "Application").
|
|
710
|
-
* @returns A numerical score representing the relevance of the match. Higher is better. Returns 0 if no match is found.
|
|
711
|
-
*/
|
|
712
|
-
private calculateSearchScore;
|
|
713
|
-
private searchField;
|
|
714
|
-
private filterField;
|
|
715
|
-
private filterRow;
|
|
716
|
-
private filterRows;
|
|
717
|
-
private compareRows;
|
|
718
|
-
private sortRows;
|
|
719
|
-
private createMetadata;
|
|
720
|
-
private updateInternalQuery;
|
|
721
|
-
private scheduleSave;
|
|
722
|
-
private saveStateToStorage;
|
|
723
|
-
private loadStateFromStorage;
|
|
724
|
-
}
|
|
725
|
-
type ControllerEventMap = {
|
|
726
|
-
[YatlColumnReorderEvent.EVENT_NAME]: YatlColumnReorderEvent;
|
|
727
|
-
[YatlColumnResizeEvent.EVENT_NAME]: YatlColumnResizeEvent;
|
|
728
|
-
[YatlColumnSortEvent.EVENT_NAME]: YatlColumnSortEvent;
|
|
729
|
-
[YatlColumnToggleEvent.EVENT_NAME]: YatlColumnToggleEvent;
|
|
730
|
-
[YatlRowSelectEvent.EVENT_NAME]: YatlRowSelectEvent;
|
|
731
|
-
[YatlTableSearchEvent.EVENT_NAME]: YatlTableSearchEvent;
|
|
732
|
-
[YatlTableStateChangeEvent.EVENT_NAME]: YatlTableStateChangeEvent;
|
|
733
|
-
[YatlTableViewChangeEvent.EVENT_NAME]: YatlTableViewChangeEvent;
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
/**
|
|
737
|
-
* A virtualized data table capable of handling complex sorting, filtering, and tokenized searching.
|
|
738
|
-
*
|
|
739
|
-
* @element yatl-table
|
|
740
|
-
* @summary A high-performance grid engine for rugged environments.
|
|
741
|
-
*
|
|
742
|
-
* @fires yatl-row-click - Fired when a user clicks a row.
|
|
743
|
-
* @fires yatl-row-select-request - Fired before the row selection changes. Cancellable
|
|
744
|
-
* @fires yatl-row-select - Fired when the row selection changes.
|
|
745
|
-
* @fires yatl-column-sort-request - Fired before a column sort order changes. Cancellable.
|
|
746
|
-
* @fires yatl-column-sort - Fired when a column sort order changes.
|
|
747
|
-
* @fires yatl-column-toggle - Fired when a column's visibility changes.
|
|
748
|
-
* @fires yatl-column-resize - Fired after a column has been resized by the user.
|
|
749
|
-
* @fires yatl-column-reorder-request - Fired when the user drops a column into a new position. Cancellable.
|
|
750
|
-
* @fires yatl-column-reorder - Fired after the column order changes.
|
|
751
|
-
* @fires yatl-table-search - Fired when the search query is updated.
|
|
752
|
-
* @fires yatl-table-view-change - Fired when the visible slice of data changes due to sorting, filtering, or data updates. Payload contains the processed rows.
|
|
753
|
-
* @fires yatl-table-state-change - Fired when any persistable state (width, order, sort, query) changes. Used for syncing with local storage.
|
|
754
|
-
*/
|
|
755
|
-
declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement {
|
|
756
|
-
static styles: lit.CSSResult[];
|
|
757
|
-
private tableElement;
|
|
758
|
-
private virtualizer?;
|
|
759
|
-
private get virtualizerRef();
|
|
760
|
-
private resizeState;
|
|
761
|
-
private dragColumn;
|
|
762
|
-
private useYatlUi;
|
|
763
|
-
private _controller;
|
|
764
|
-
get controller(): YatlTableController<T>;
|
|
765
|
-
set controller(controller: YatlTableController<T>);
|
|
766
1040
|
striped: boolean;
|
|
767
|
-
/**
|
|
768
|
-
* Default sortability for all columns.
|
|
769
|
-
* Can be overridden by setting `sortable` on the specific column definition.
|
|
770
|
-
* * **NOTE:** Changing this will not clear sorted column states.
|
|
771
|
-
* @default false
|
|
772
|
-
*/
|
|
773
1041
|
sortable: boolean;
|
|
774
|
-
/**
|
|
775
|
-
* Default resizability for all columns.
|
|
776
|
-
* Can be overridden by setting `resizable` on the specific column definition.
|
|
777
|
-
* * **NOTE:** Changing this will not clear current column widths.
|
|
778
|
-
* @default false
|
|
779
|
-
*/
|
|
780
1042
|
resizable: boolean;
|
|
1043
|
+
reorderable: boolean;
|
|
1044
|
+
/** @attr row-numbers */
|
|
1045
|
+
rowNumbers: boolean;
|
|
1046
|
+
/** @attr virtual-scroll */
|
|
1047
|
+
virtualScroll: boolean;
|
|
1048
|
+
/** @attr hide-footer */
|
|
1049
|
+
hideFooter: boolean;
|
|
1050
|
+
/** @attr disable-editing */
|
|
1051
|
+
disableEditing: boolean;
|
|
781
1052
|
/**
|
|
782
|
-
* Enables virtual scrolling for the table.
|
|
783
|
-
* When enabled, only the visible rows are rendered to the DOM, significantly improving
|
|
784
|
-
* performance for large datasets (1000+ rows).
|
|
785
|
-
* @default false
|
|
786
|
-
*/
|
|
787
|
-
enableVirtualScroll: boolean;
|
|
788
|
-
/**
|
|
789
|
-
* When enabled, text matching the current search query will be wrapped in `<mark>` tags.
|
|
790
|
-
* This applies to all visible cells that contain the search term.
|
|
791
|
-
* This does NOT apply to content rendered by the user such as the ColumnOptions.render callback.
|
|
792
|
-
* @default true
|
|
793
|
-
*/
|
|
794
|
-
enableSearchHighlight: boolean;
|
|
795
|
-
/**
|
|
796
|
-
* Enables tokenized search behavior.
|
|
797
|
-
* When enabled, the search query is split into individual tokens using the
|
|
798
|
-
* `searchTokenizer` function (defaults to splitting on whitespace).
|
|
799
|
-
* A row is considered a match if **ANY** of the tokens appear in the searchable fields.
|
|
800
|
-
* @default false
|
|
801
|
-
*/
|
|
802
|
-
get enableSearchTokenization(): boolean;
|
|
803
|
-
set enableSearchTokenization(enable: boolean);
|
|
804
|
-
/**
|
|
805
|
-
* Enables weighted relevance scoring for search results.
|
|
806
|
-
* When enabled, exact matches and prefix matches are ranked higher than substring matches.
|
|
807
|
-
* Rows are sorted by their relevance score descending.
|
|
808
|
-
* @default false
|
|
809
|
-
*/
|
|
810
|
-
get enableSearchScoring(): boolean;
|
|
811
|
-
set enableSearchScoring(enable: boolean);
|
|
812
|
-
/**
|
|
813
|
-
* Allows users to reorder columns by dragging and dropping headers.
|
|
814
|
-
* @default true
|
|
815
|
-
*/
|
|
816
|
-
enableColumnReorder: boolean;
|
|
817
|
-
/**
|
|
818
|
-
* Shows a column to the left of each row with its row number.
|
|
819
|
-
*/
|
|
820
|
-
enableRowNumberColumn: boolean;
|
|
821
|
-
/**
|
|
822
|
-
* Shows the built-in footer row which displays the current record count.
|
|
823
|
-
* The footer content can be customized using the `slot="footer"` element.
|
|
824
|
-
* @default false
|
|
825
|
-
*/
|
|
826
|
-
enableFooter: boolean;
|
|
827
|
-
/**
|
|
828
|
-
* The string to display in a cell when the data value is `null` or `undefined`.
|
|
829
1053
|
* @default "-"
|
|
1054
|
+
* @attr null-value-placeholder
|
|
830
1055
|
*/
|
|
831
1056
|
nullValuePlaceholder: string;
|
|
832
1057
|
/**
|
|
833
|
-
* The message displayed when the `data` array is empty.
|
|
834
1058
|
* @default "No records to display"
|
|
1059
|
+
* @attr emptry-message
|
|
835
1060
|
*/
|
|
836
1061
|
emptyMessage: string;
|
|
837
1062
|
/**
|
|
838
|
-
* The message displayed when `data` exists but the current search/filter
|
|
839
|
-
* results in zero visible rows.
|
|
840
1063
|
* @default "No matching records found"
|
|
1064
|
+
* @attr no-results-message
|
|
841
1065
|
*/
|
|
842
1066
|
noResultsMessage: string;
|
|
843
|
-
/**
|
|
844
|
-
* The definitions for the columns to be rendered.
|
|
845
|
-
* This defines the field mapping, titles, sortability, and other static options.
|
|
846
|
-
*/
|
|
847
|
-
get columns(): ColumnOptions<T>[];
|
|
848
|
-
set columns(columns: ColumnOptions<T>[]);
|
|
849
|
-
/**
|
|
850
|
-
* Gets a list of columns with the display role
|
|
851
|
-
* **This will always be ordered the same as the visual column order**
|
|
852
|
-
*/
|
|
853
|
-
get displayColumns(): DisplayColumnOptions<T>[];
|
|
854
|
-
get columnStates(): ColumnState<T>[];
|
|
855
|
-
set columnStates(states: ColumnState<T>[]);
|
|
856
|
-
/**
|
|
857
|
-
* The current text string used to filter the table data.
|
|
858
|
-
* Setting this property triggers a new search and render cycle.
|
|
859
|
-
*/
|
|
860
|
-
get searchQuery(): string;
|
|
861
|
-
set searchQuery(query: string);
|
|
862
|
-
/**
|
|
863
|
-
* A function that splits the search query into tokens.
|
|
864
|
-
* Only used if `enableSearchTokenization` is true.
|
|
865
|
-
* @default whitespaceTokenizer
|
|
866
|
-
*/
|
|
867
|
-
get searchTokenizer(): TokenizerCallback;
|
|
868
|
-
set searchTokenizer(tokenizer: TokenizerCallback);
|
|
869
|
-
/**
|
|
870
|
-
* An optional set of criteria to filter the visible rows.
|
|
871
|
-
* This runs **before** the global search query is applied.
|
|
872
|
-
* * You can provide:
|
|
873
|
-
* 1. A **Partial Object**: matches rows where specific keys equal specific values (AND logic).
|
|
874
|
-
* 2. A **Callback Function**: returns `true` to keep the row, `false` to hide it.
|
|
875
|
-
* * @example
|
|
876
|
-
* // 1. Object Syntax (Simple Exact Match)
|
|
877
|
-
* // Shows rows where status is 'active' AND role is 'admin'
|
|
878
|
-
* table.filters = { status: 'active', role: 'admin' };
|
|
879
|
-
* * @example
|
|
880
|
-
* // 2. Callback Syntax (Complex Logic)
|
|
881
|
-
* // Shows rows where age is over 21 OR they are a VIP
|
|
882
|
-
* table.filters = (row) => row.age > 21 || row.isVip;
|
|
883
|
-
*/
|
|
884
|
-
get filters(): Partial<{ [K in NestedKeyOf<T>]: unknown; }> | FilterCallback<T> | null;
|
|
885
|
-
set filters(filters: Partial<{ [K in NestedKeyOf<T>]: unknown; }> | FilterCallback<T> | null);
|
|
886
|
-
/**
|
|
887
|
-
* A callback function to conditionally apply CSS parts to table rows.
|
|
888
|
-
*/
|
|
889
1067
|
rowParts: RowPartsCallback<T> | null;
|
|
890
|
-
/**
|
|
891
|
-
* The row selection method to use.
|
|
892
|
-
* * single - Only a single row can be selected at a time
|
|
893
|
-
* * multi - Multiple rows can be selected at a time
|
|
894
|
-
* * null - Disable row selection
|
|
895
|
-
*/
|
|
896
|
-
get rowSelectionMethod(): RowSelectionMethod | null;
|
|
897
|
-
set rowSelectionMethod(selection: RowSelectionMethod | null);
|
|
898
|
-
/**
|
|
899
|
-
* List of currently selected row indexes.
|
|
900
|
-
* * **NOTE**: These indexes are based off the of
|
|
901
|
-
* the original data array index, *not* the filtered data.
|
|
902
|
-
*/
|
|
903
|
-
get selectedRowIds(): RowId[];
|
|
904
|
-
set selectedRowIds(rows: RowId[]);
|
|
905
|
-
/**
|
|
906
|
-
* Configuration options for automatically saving and restoring table state
|
|
907
|
-
* (column width, order, visibility, etc.) to browser storage.
|
|
908
|
-
*/
|
|
909
|
-
get storageOptions(): {
|
|
910
|
-
key: string;
|
|
911
|
-
storage?: "local" | "session";
|
|
912
|
-
saveSearchQuery?: boolean;
|
|
913
|
-
saveColumnSortOrders?: boolean;
|
|
914
|
-
saveColumnVisibility?: boolean;
|
|
915
|
-
saveColumnWidths?: boolean;
|
|
916
|
-
saveColumnOrder?: boolean;
|
|
917
|
-
saveSelectedRows?: boolean;
|
|
918
|
-
} | null;
|
|
919
|
-
set storageOptions(options: {
|
|
920
|
-
key: string;
|
|
921
|
-
storage?: "local" | "session";
|
|
922
|
-
saveSearchQuery?: boolean;
|
|
923
|
-
saveColumnSortOrders?: boolean;
|
|
924
|
-
saveColumnVisibility?: boolean;
|
|
925
|
-
saveColumnWidths?: boolean;
|
|
926
|
-
saveColumnOrder?: boolean;
|
|
927
|
-
saveSelectedRows?: boolean;
|
|
928
|
-
} | null);
|
|
929
|
-
get rowIdCallback(): RowIdCallback<T>;
|
|
930
|
-
set rowIdCallback(callback: RowIdCallback<T>);
|
|
931
|
-
/**
|
|
932
|
-
* The array of data objects to be displayed.
|
|
933
|
-
* Objects must satisfy the `WeakKey` constraint (objects only, no primitives).
|
|
934
|
-
*/
|
|
935
|
-
get data(): T[];
|
|
936
|
-
set data(value: T[]);
|
|
937
|
-
get filteredData(): T[];
|
|
938
|
-
get dataUpdateTimestamp(): Date | null;
|
|
939
1068
|
getColumn(field: NestedKeyOf<T>): ColumnOptions<T> | undefined;
|
|
940
1069
|
getDisplayColumn(field: NestedKeyOf<T>): DisplayColumnOptions<T> | undefined;
|
|
941
1070
|
/**
|
|
@@ -1008,6 +1137,7 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
|
|
|
1008
1137
|
* @param options - Options for configuring what should be exported.
|
|
1009
1138
|
*/
|
|
1010
1139
|
export(filename: string, options?: ExportOptions): void;
|
|
1140
|
+
print(title?: string): Promise<void>;
|
|
1011
1141
|
scrollToRow(row: T): Promise<void>;
|
|
1012
1142
|
/**
|
|
1013
1143
|
* Scrolls the table to bring the row at the specified original index into view.
|
|
@@ -1077,9 +1207,9 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
|
|
|
1077
1207
|
* @param index - The original index of the row to delete.
|
|
1078
1208
|
*/
|
|
1079
1209
|
deleteRowAtIndex(index: number): void;
|
|
1080
|
-
protected renderColumnSortIcon(column: DisplayColumnOptions<T>, state: ColumnState<T>): TemplateResult<1
|
|
1081
|
-
protected renderColumnResizer(column: DisplayColumnOptions<T>, _state: ColumnState<T>): TemplateResult<1
|
|
1082
|
-
protected renderHeaderCell(column: DisplayColumnOptions<T>): TemplateResult<1
|
|
1210
|
+
protected renderColumnSortIcon(column: DisplayColumnOptions<T>, state: ColumnState<T>): typeof nothing | TemplateResult<1>;
|
|
1211
|
+
protected renderColumnResizer(column: DisplayColumnOptions<T>, _state: ColumnState<T>): typeof nothing | TemplateResult<1>;
|
|
1212
|
+
protected renderHeaderCell(column: DisplayColumnOptions<T>): typeof nothing | TemplateResult<1>;
|
|
1083
1213
|
protected renderRowNumberHeader(): TemplateResult<1>;
|
|
1084
1214
|
protected renderSelectionHeader(): TemplateResult<1>;
|
|
1085
1215
|
protected renderHeader(): TemplateResult<1>;
|
|
@@ -1090,11 +1220,12 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
|
|
|
1090
1220
|
protected renderRowNumberCell(rowNumber: number): TemplateResult<1>;
|
|
1091
1221
|
protected renderRow(row: T, renderIndex: number): TemplateResult<1>;
|
|
1092
1222
|
protected renderBodyContents(): TemplateResult<1>;
|
|
1093
|
-
protected renderFooter(): TemplateResult<1
|
|
1223
|
+
protected renderFooter(): typeof nothing | TemplateResult<1>;
|
|
1094
1224
|
protected render(): TemplateResult<1>;
|
|
1095
1225
|
private renderCellWrapper;
|
|
1096
1226
|
connectedCallback(): void;
|
|
1097
1227
|
disconnectedCallback(): void;
|
|
1228
|
+
updated(changedProperties: PropertyValues): void;
|
|
1098
1229
|
private readonly eventNames;
|
|
1099
1230
|
private addControllerListeners;
|
|
1100
1231
|
private removeControllerListeners;
|
|
@@ -1105,8 +1236,14 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
|
|
|
1105
1236
|
* order they will appear in the grid.
|
|
1106
1237
|
*/
|
|
1107
1238
|
private getGridWidths;
|
|
1239
|
+
private getInputTypeFromValue;
|
|
1240
|
+
private getNextEditableField;
|
|
1241
|
+
private saveEdits;
|
|
1108
1242
|
private handleHeaderClicked;
|
|
1109
1243
|
private handleCellClick;
|
|
1244
|
+
private handleCellDoubleClick;
|
|
1245
|
+
private handleCellInputKeypress;
|
|
1246
|
+
private handleMouseDown;
|
|
1110
1247
|
private handleResizeMouseDown;
|
|
1111
1248
|
private handleResizeMouseMove;
|
|
1112
1249
|
private handleResizeMouseUp;
|
|
@@ -1127,10 +1264,10 @@ declare global {
|
|
|
1127
1264
|
declare function findColumn<TData extends Record<string, unknown>, TCol extends {
|
|
1128
1265
|
field: NestedKeyOf<TData>;
|
|
1129
1266
|
}>(columns: TCol[], field: NestedKeyOf<TData>): TCol | undefined;
|
|
1130
|
-
declare function isInternalColumn<T>(col: ColumnOptions<T> | undefined | null): col is InternalColumnOptions<T>;
|
|
1131
|
-
declare function isDisplayColumn<T>(col: ColumnOptions<T> | undefined | null): col is DisplayColumnOptions<T>;
|
|
1132
|
-
declare function createState<T>(field: NestedKeyOf<T>, defaults?: Partial<ColumnState<T>>): ColumnState<T>;
|
|
1133
|
-
declare function getColumnStateChanges<T>(oldState: ColumnState<T> | undefined, newState: ColumnState<T>): (keyof ColumnState<T>)[];
|
|
1267
|
+
declare function isInternalColumn<T extends object = UnspecifiedRecord>(col: ColumnOptions<T> | undefined | null): col is InternalColumnOptions<T>;
|
|
1268
|
+
declare function isDisplayColumn<T extends object = UnspecifiedRecord>(col: ColumnOptions<T> | undefined | null): col is DisplayColumnOptions<T>;
|
|
1269
|
+
declare function createState<T extends object = UnspecifiedRecord>(field: NestedKeyOf<T>, defaults?: Partial<ColumnState<T>>): ColumnState<T>;
|
|
1270
|
+
declare function getColumnStateChanges<T extends object = UnspecifiedRecord>(oldState: ColumnState<T> | undefined, newState: ColumnState<T>): (keyof ColumnState<T>)[];
|
|
1134
1271
|
|
|
1135
1272
|
declare function isRowIdType(value: unknown): value is RowId;
|
|
1136
1273
|
declare function isRowSelectionMethod(value: string | null): value is RowSelectionMethod;
|
|
@@ -1152,4 +1289,4 @@ declare const whitespaceTokenizer: (value: string) => {
|
|
|
1152
1289
|
quoted: boolean;
|
|
1153
1290
|
}[];
|
|
1154
1291
|
|
|
1155
|
-
export { type BaseColumnOptions, type CellPartsCallback, type CellRenderCallback, type ColumnFilterCallback, type ColumnOptions, type ColumnRole, type ColumnState, type Compareable, type ControllerEventMap, type DisplayColumnOptions, type ExportOptions, type FilterCallback, type Filters, type InternalColumnOptions, type NestedKeyOf, type QueryToken, type Renderable, type RestorableColumnState, type RestorableTableState, type RowId, type RowIdCallback, type RowPartsCallback, type RowSelectionMethod, type SortOrder, type SortState, type SortValueCallback, type StorageOptions, type TableControllerOptions, type TableState, type TokenizerCallback, TypedEventTarget, type UnspecifiedRecord, type ValueFormatterCallback, YatlColumnReorderEvent, YatlColumnReorderRequest, YatlColumnResizeEvent, YatlColumnSortEvent, YatlColumnSortRequest, YatlColumnToggleEvent, YatlEvent, YatlRowClickEvent, YatlRowSelectEvent, YatlRowSelectRequest, YatlTable, YatlTableController, YatlTableSearchEvent, YatlTableStateChangeEvent, YatlTableViewChangeEvent, createRegexTokenizer, createState, findColumn, getColumnStateChanges, getNestedValue, isDisplayColumn, isInternalColumn, isRowIdType, isRowSelectionMethod, setNestedValue, whitespaceTokenizer };
|
|
1292
|
+
export { type BaseColumnOptions, type CellEditor, type CellPartsCallback, type CellRenderCallback, type ColumnFilterCallback, type ColumnOptions, type ColumnRole, type ColumnState, type Compareable, type ControllerEventMap, type DisplayColumnOptions, type ExportOptions, type FilterCallback, type Filters, InputEditor, type InputEditorOptions, type InputType, type InternalColumnOptions, type MaybePromise, type NestedKeyOf, NumberEditor, type NumberEditorOptions, type QueryToken, type Renderable, type RestorableColumnState, type RestorableTableState, type RowId, type RowIdCallback, type RowPartsCallback, type RowSelectionMethod, SelectEditor, type SelectEditorOptions, type SortOrder, type SortState, type SortValueCallback, type StorageInterface, type StorageOptions, type TableControllerOptions, type TableState, TextEditor, type TextEditorOptions, type TokenizerCallback, TypedEventTarget, type UnspecifiedRecord, type ValueFormatterCallback, YatlCellEditEvent, YatlColumnReorderEvent, YatlColumnReorderRequest, YatlColumnResizeEvent, YatlColumnSortEvent, YatlColumnSortRequest, YatlColumnToggleEvent, YatlEvent, YatlRowClickEvent, YatlRowSelectEvent, YatlRowSelectRequest, YatlTable, type YatlTableApi, YatlTableController, type YatlTableControllerApi, YatlTableControllerEvent, YatlTableSearchEvent, YatlTableStateChangeEvent, YatlTableViewChangeEvent, createRegexTokenizer, createState, findColumn, getColumnStateChanges, getNestedValue, isDisplayColumn, isInternalColumn, isRowIdType, isRowSelectionMethod, setNestedValue, whitespaceTokenizer };
|