@timlassiter11/yatl 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/datatable.css +2 -0
- package/dist/datatable.css.map +1 -0
- package/dist/datatable.d.mts +531 -0
- package/dist/datatable.d.ts +531 -0
- package/dist/datatable.global.js +4 -0
- package/dist/datatable.global.js.map +1 -0
- package/dist/datatable.js +4 -0
- package/dist/datatable.js.map +1 -0
- package/dist/datatable.mjs +4 -0
- package/dist/datatable.mjs.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the possible sorting orders for columns.
|
|
3
|
+
*/
|
|
4
|
+
type SortOrder = 'asc' | 'desc' | null;
|
|
5
|
+
/**
|
|
6
|
+
* Represents a generic data row in the table, an object with string keys and any values.
|
|
7
|
+
*/
|
|
8
|
+
type Row = Record<string, any>;
|
|
9
|
+
/**
|
|
10
|
+
* Represents filter data where the key should be a field in the Row data and the value
|
|
11
|
+
* should be comparable to the value of that field, or an array of values.
|
|
12
|
+
*/
|
|
13
|
+
type Filters = Record<string, any>;
|
|
14
|
+
/**
|
|
15
|
+
* Callback for formatting a row's HTML element.
|
|
16
|
+
* @param row - The row data.
|
|
17
|
+
* @param element - The row element.
|
|
18
|
+
*/
|
|
19
|
+
type RowFormatterCallback = (row: Row, element: HTMLElement) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Callback for formatting the value of a cell.
|
|
22
|
+
* Called when the cell is created and when exporting to CSV.
|
|
23
|
+
* @param value - The value of the cell.
|
|
24
|
+
* @param row - The row data.
|
|
25
|
+
*/
|
|
26
|
+
type ValueFormatterCallback = (value: any, row: Row) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Callback for formatting a cell's HTML element.
|
|
29
|
+
* @param value - The value of the field.
|
|
30
|
+
* @param row - The row data.
|
|
31
|
+
* @param element - The cell element.
|
|
32
|
+
*/
|
|
33
|
+
type CellFormatterCallback = (value: any, row: Row, element: HTMLElement) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Callback for comparing two values.
|
|
36
|
+
* @param a - The first value.
|
|
37
|
+
* @param b - The second value.
|
|
38
|
+
* @returns A negative number if a < b, a positive number if a > b, or 0 if they are equal.
|
|
39
|
+
*/
|
|
40
|
+
type ComparatorCallback = (a: any, b: any) => number;
|
|
41
|
+
/**
|
|
42
|
+
* Callback for caching the sort value of a field
|
|
43
|
+
* This function should derive a comparable value (often numerical or lowercase string) from the field's original value, to be used during sorting.
|
|
44
|
+
* @param value - The value of the field.
|
|
45
|
+
* @returns The derived value for sorting (e.g., a number or a standardized string).
|
|
46
|
+
*/
|
|
47
|
+
type SortValueCallback = (value: any) => number | string;
|
|
48
|
+
/**
|
|
49
|
+
* Callback for tokenizing a value into a list of string tokens.
|
|
50
|
+
* @param value - The value to tokenize.
|
|
51
|
+
* @returns An array of tokens.
|
|
52
|
+
*/
|
|
53
|
+
type TokenizerCallback = (value: any) => string[];
|
|
54
|
+
/**
|
|
55
|
+
* Callback for filtering a row.
|
|
56
|
+
* @param row - The row data.
|
|
57
|
+
* @param index - The index of the row.
|
|
58
|
+
* @returns True if the row matches the filter, false otherwise.
|
|
59
|
+
*/
|
|
60
|
+
type FilterCallback = (row: Row, index: number) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Callback for filtering a field value against the filter data.
|
|
63
|
+
* @param value - The value to filter.
|
|
64
|
+
* @param filter - The filter to apply.
|
|
65
|
+
* @returns True if the value matches the filter, false otherwise.
|
|
66
|
+
*/
|
|
67
|
+
type ColumnFilterCallback = (value: any, filter: any) => boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Column options for the table.
|
|
70
|
+
*/
|
|
71
|
+
interface ColumnOptions {
|
|
72
|
+
/**
|
|
73
|
+
* The field name in the data object.
|
|
74
|
+
*/
|
|
75
|
+
field: string;
|
|
76
|
+
/**
|
|
77
|
+
* The title to display in the header.
|
|
78
|
+
*/
|
|
79
|
+
title?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the column is sortable.
|
|
82
|
+
*/
|
|
83
|
+
sortable?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the column is searchable.
|
|
86
|
+
*/
|
|
87
|
+
searchable?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether the column's data should be tokenized for searching.
|
|
90
|
+
*/
|
|
91
|
+
tokenize?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* The initial sort order of the column.
|
|
94
|
+
*/
|
|
95
|
+
sortOrder?: SortOrder;
|
|
96
|
+
/**
|
|
97
|
+
* The initial sort priority of the column for sorting.
|
|
98
|
+
* Lower numbers are sorted first.
|
|
99
|
+
*/
|
|
100
|
+
sortPriority?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the column should be visible by default.
|
|
103
|
+
*/
|
|
104
|
+
visible?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Whether the column should be resizable.
|
|
107
|
+
* Defaults to the table's resizable option.
|
|
108
|
+
*/
|
|
109
|
+
resizable?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* The initial width of the column.
|
|
112
|
+
* Can be a number (in pixels) or a string (e.g. "100px", "50%").
|
|
113
|
+
*/
|
|
114
|
+
width?: string | number;
|
|
115
|
+
/**
|
|
116
|
+
* A function to format the value for display.
|
|
117
|
+
*/
|
|
118
|
+
valueFormatter?: ValueFormatterCallback;
|
|
119
|
+
/**
|
|
120
|
+
* A function to format the element for display.
|
|
121
|
+
*/
|
|
122
|
+
elementFormatter?: CellFormatterCallback;
|
|
123
|
+
/**
|
|
124
|
+
* A function to use for sorting the column.
|
|
125
|
+
* This overrides the default sorting behavior.
|
|
126
|
+
*/
|
|
127
|
+
sorter?: ComparatorCallback;
|
|
128
|
+
/**
|
|
129
|
+
* A function to derive a comparable value from the cell's original value, specifically for sorting this column.
|
|
130
|
+
* This can be used to preprocess and cache values (e.g., convert to lowercase, extract numbers) before comparison.
|
|
131
|
+
*/
|
|
132
|
+
sortValue?: SortValueCallback;
|
|
133
|
+
/**
|
|
134
|
+
* A custom function to determine if a cell's value in this column matches a given filter criterion.
|
|
135
|
+
* This is used when `DataTable.filter()` is called with an object-based filter that targets this column's field.
|
|
136
|
+
* @param value - The cell's value.
|
|
137
|
+
* @param filterCriterion - The criterion provided for this column in the main filter object.
|
|
138
|
+
*/
|
|
139
|
+
filter?: ColumnFilterCallback;
|
|
140
|
+
}
|
|
141
|
+
/** Represents the current state of a column, often used for saving and restoring column configurations. */
|
|
142
|
+
interface ColumnState {
|
|
143
|
+
/**
|
|
144
|
+
* The unique field name of the column.
|
|
145
|
+
*/
|
|
146
|
+
readonly field: string;
|
|
147
|
+
/**
|
|
148
|
+
* The user friendly title of the column.
|
|
149
|
+
*/
|
|
150
|
+
readonly title: string;
|
|
151
|
+
/**
|
|
152
|
+
* The current visibility of the column.
|
|
153
|
+
*/
|
|
154
|
+
visible: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* The current sort order of the column.
|
|
157
|
+
*/
|
|
158
|
+
sortOrder: SortOrder;
|
|
159
|
+
/**
|
|
160
|
+
* The current sort priority of the column.
|
|
161
|
+
* Lower numbers are sorted first.
|
|
162
|
+
*/
|
|
163
|
+
sortPriority: number;
|
|
164
|
+
/**
|
|
165
|
+
* The currently set width of the column.
|
|
166
|
+
*/
|
|
167
|
+
width: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Defines CSS classes to be applied to different parts of the table.
|
|
171
|
+
*/
|
|
172
|
+
interface TableClasses {
|
|
173
|
+
/**
|
|
174
|
+
* Classes for the scroller element.
|
|
175
|
+
*/
|
|
176
|
+
scroller?: string | string[];
|
|
177
|
+
/**
|
|
178
|
+
* Classes for the thead element.
|
|
179
|
+
*/
|
|
180
|
+
thead?: string | string[];
|
|
181
|
+
/**
|
|
182
|
+
* Classes for the tbody element.
|
|
183
|
+
*/
|
|
184
|
+
tbody?: string | string[];
|
|
185
|
+
/**
|
|
186
|
+
* Classes for the tfoot element.
|
|
187
|
+
*/
|
|
188
|
+
tfoot?: string | string[];
|
|
189
|
+
/**
|
|
190
|
+
* Classes for each table row element.
|
|
191
|
+
*/
|
|
192
|
+
tr?: string | string[];
|
|
193
|
+
/**
|
|
194
|
+
* Classes for each header element.
|
|
195
|
+
*/
|
|
196
|
+
th?: string | string[];
|
|
197
|
+
/**
|
|
198
|
+
* Classes for each cell element.
|
|
199
|
+
*/
|
|
200
|
+
td?: string | string[];
|
|
201
|
+
/**
|
|
202
|
+
* Classes for the mark elements used to highligh search results.
|
|
203
|
+
*/
|
|
204
|
+
mark?: string | string[];
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Options for configuring the table.
|
|
208
|
+
*/
|
|
209
|
+
interface TableOptions {
|
|
210
|
+
/**
|
|
211
|
+
* The column options for the table.
|
|
212
|
+
*/
|
|
213
|
+
columns?: ColumnOptions[];
|
|
214
|
+
/**
|
|
215
|
+
* The initial data to load into the table.
|
|
216
|
+
*/
|
|
217
|
+
data?: Row[];
|
|
218
|
+
/**
|
|
219
|
+
* Configures virtual scrolling.
|
|
220
|
+
*/
|
|
221
|
+
virtualScroll?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Whether to highlight search results in the table cells.
|
|
224
|
+
*/
|
|
225
|
+
highlightSearch?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Whether columns should be sortable by default.
|
|
228
|
+
* Can be overridden on individual columns.
|
|
229
|
+
*/
|
|
230
|
+
sortable?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Whether columns should be searchable by default.
|
|
233
|
+
* Can be overridden on individual columns.
|
|
234
|
+
*/
|
|
235
|
+
searchable?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Whether columns data should be tokenized for searching by default.
|
|
238
|
+
* Can be overridden on individual columns.
|
|
239
|
+
*/
|
|
240
|
+
tokenize?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Whether columns should be resizable by default.
|
|
243
|
+
* Can be overridden on individual columns.
|
|
244
|
+
*/
|
|
245
|
+
resizable?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Whether columns should be rearrangeable by drag and drop.
|
|
248
|
+
*/
|
|
249
|
+
rearrangeable?: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Additional fields to include in the search.
|
|
252
|
+
* Used for fields that are not displayed as columns.
|
|
253
|
+
*/
|
|
254
|
+
extraSearchFields?: string[];
|
|
255
|
+
/**
|
|
256
|
+
* The text to display when there is no data in the table.
|
|
257
|
+
*/
|
|
258
|
+
noDataText?: string;
|
|
259
|
+
/**
|
|
260
|
+
* The text to display when there are no matching records after filtering or searching.
|
|
261
|
+
*/
|
|
262
|
+
noMatchText?: string;
|
|
263
|
+
/**
|
|
264
|
+
* Custom CSS classes to apply to various table elements.
|
|
265
|
+
*/
|
|
266
|
+
classes?: TableClasses;
|
|
267
|
+
/**
|
|
268
|
+
* A function to format each row's HTML element.
|
|
269
|
+
*/
|
|
270
|
+
rowFormatter?: RowFormatterCallback;
|
|
271
|
+
/**
|
|
272
|
+
* A function to use for tokenizing values for searching.
|
|
273
|
+
*/
|
|
274
|
+
tokenizer?: TokenizerCallback;
|
|
275
|
+
}
|
|
276
|
+
interface LoadOptions {
|
|
277
|
+
/** If the data should replace or be added to the end of the current data */
|
|
278
|
+
append?: boolean;
|
|
279
|
+
/** If the current scroll position should be kepts */
|
|
280
|
+
keepScroll?: boolean;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Represents a dynamic and interactive table with features like sorting, searching, filtering,
|
|
285
|
+
* column resizing, column rearranging, and virtual scrolling.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* const tableElement = document.getElementById('myTable');
|
|
290
|
+
* const options = {
|
|
291
|
+
* columns: [
|
|
292
|
+
* { field: 'id', title: 'ID', sortable: true },
|
|
293
|
+
* { field: 'name', title: 'Name', searchable: true },
|
|
294
|
+
* { field: 'age', title: 'Age', sortable: true, valueFormatter: (value) => `${value} years` }
|
|
295
|
+
* ],
|
|
296
|
+
* data: [
|
|
297
|
+
* { id: 1, name: 'Alice', age: 30 },
|
|
298
|
+
* { id: 2, name: 'Bob', age: 24 },
|
|
299
|
+
* ],
|
|
300
|
+
* virtualScroll: true,
|
|
301
|
+
* resizable: true,
|
|
302
|
+
* rearrangeable: true,
|
|
303
|
+
* };
|
|
304
|
+
* const dataTable = new DataTable(tableElement, options);
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
declare class DataTable extends EventTarget {
|
|
308
|
+
#private;
|
|
309
|
+
private static readonly DEFAULT_OPTIONS;
|
|
310
|
+
/**
|
|
311
|
+
* Initializes a new instance of the DataTable.
|
|
312
|
+
* @param table - The HTMLTableElement or a CSS selector string for the table.
|
|
313
|
+
* @param options - Optional configuration options for the DataTable.
|
|
314
|
+
* @throws {SyntaxError} If the table selector does not find an element.
|
|
315
|
+
* @throws {TypeError} If the provided table element is not an HTMLTableElement or if columns option is not an array.
|
|
316
|
+
*/
|
|
317
|
+
constructor(table: string | HTMLTableElement, options?: TableOptions);
|
|
318
|
+
/**
|
|
319
|
+
* Gets or sets the state of all columns in the table.
|
|
320
|
+
* This can be used to save and restore column configurations like visibility, sort order, and width.
|
|
321
|
+
* When setting, it attempts to apply the states to existing columns.
|
|
322
|
+
*/
|
|
323
|
+
get columnStates(): ColumnState[];
|
|
324
|
+
set columnStates(states: ColumnState[]);
|
|
325
|
+
/**
|
|
326
|
+
* Gets the currently filtered and sorted rows displayed in the table.
|
|
327
|
+
*/
|
|
328
|
+
get rows(): Row[];
|
|
329
|
+
/**
|
|
330
|
+
* Gets the underlying data
|
|
331
|
+
*/
|
|
332
|
+
get data(): Row[];
|
|
333
|
+
/**
|
|
334
|
+
* Gets the total number of currently filtered and sorted rows.
|
|
335
|
+
*/
|
|
336
|
+
get length(): number;
|
|
337
|
+
/**
|
|
338
|
+
* Gets the underlying HTMLTableElement managed by this DataTable instance.
|
|
339
|
+
*/
|
|
340
|
+
get table(): HTMLTableElement;
|
|
341
|
+
/**
|
|
342
|
+
* Gets or sets the virtual scroll behavior for the table.
|
|
343
|
+
* When `true`, virtual scrolling is enabled, rendering only visible rows for performance with large datasets.
|
|
344
|
+
* When `false`, virtual scrolling is disabled, and all rows are rendered.
|
|
345
|
+
* @default true
|
|
346
|
+
*/
|
|
347
|
+
get virtualScroll(): boolean;
|
|
348
|
+
set virtualScroll(value: boolean);
|
|
349
|
+
/**
|
|
350
|
+
* Loads data into the table.
|
|
351
|
+
* @param rows - An array of row data objects to load.
|
|
352
|
+
* @param append - If true, appends the new rows to existing data. If false (default), overwrites existing data.
|
|
353
|
+
* @throws {TypeError} If `rows` is not an array.
|
|
354
|
+
*/
|
|
355
|
+
loadData(rows: Row[], options?: LoadOptions): void;
|
|
356
|
+
/**
|
|
357
|
+
* Displays a message in the table body, typically used for "no data" or "no results" states.
|
|
358
|
+
* The message is shown in a single row spanning all columns.
|
|
359
|
+
* @param text - The text or HTML message to display.
|
|
360
|
+
* @param classes - A string or array of strings for CSS classes to apply to the message row.
|
|
361
|
+
*/
|
|
362
|
+
showMessage(text: string, classes: string | string[]): void;
|
|
363
|
+
/**
|
|
364
|
+
* Clears the current message and dispalsy the normal table data.
|
|
365
|
+
*/
|
|
366
|
+
clearMessage(): void;
|
|
367
|
+
/**
|
|
368
|
+
* Filters rows based on a search query.
|
|
369
|
+
* The search is performed on columns marked as `searchable` and `extraSearchFields`.
|
|
370
|
+
* @param query - The search term (string) or a regular expression. An empty string clears the search.
|
|
371
|
+
*/
|
|
372
|
+
search(query?: string | RegExp): void;
|
|
373
|
+
/**
|
|
374
|
+
* Applies filters to the table rows.
|
|
375
|
+
* Filters can be an object where keys are field names and values are the criteria to filter by,
|
|
376
|
+
* or a callback function that receives a row and its index and returns `true` if the row should be included.
|
|
377
|
+
* @param filters - An object defining field-based filters or a custom filter callback function.
|
|
378
|
+
* @throws {TypeError} If `filters` is not an object or a function.
|
|
379
|
+
*/
|
|
380
|
+
filter(filters?: Filters | FilterCallback): void;
|
|
381
|
+
/**
|
|
382
|
+
* Sorts the table by a specified column and order.
|
|
383
|
+
* If `order` is `null`, the sort on this column is removed.
|
|
384
|
+
* @param colName - The field name of the column to sort by.
|
|
385
|
+
* @param order - The sort order: 'asc', 'desc', or `null` to remove sorting for this column.
|
|
386
|
+
*/
|
|
387
|
+
sort(colName: string, order: SortOrder): void;
|
|
388
|
+
/**
|
|
389
|
+
* Sets the visibility of a specified column.
|
|
390
|
+
* @param colName - The field name of the column.
|
|
391
|
+
* @param visisble - `true` to show the column, `false` to hide it.
|
|
392
|
+
*/
|
|
393
|
+
setColumnVisibility(colName: string, visisble: boolean): void;
|
|
394
|
+
/**
|
|
395
|
+
* Shows a previously hidden column.
|
|
396
|
+
* @param field - The field name of the column to show.
|
|
397
|
+
*/
|
|
398
|
+
showColumn(field: string): void;
|
|
399
|
+
/**
|
|
400
|
+
* Hides a visible column.
|
|
401
|
+
* @param field - The field name of the column to hide.
|
|
402
|
+
*/
|
|
403
|
+
hideColumn(field: string): void;
|
|
404
|
+
/**
|
|
405
|
+
* Export the current visible table data to a CSV file.
|
|
406
|
+
* @param filename - The name of the file to save.
|
|
407
|
+
* @param all - If `true`, exports all original data (ignoring filters). If `false` (default), exports only the currently visible (filtered and sorted) rows.
|
|
408
|
+
*/
|
|
409
|
+
export(filename: string, all?: boolean): void;
|
|
410
|
+
scrollToRow(row: Row): void;
|
|
411
|
+
/**
|
|
412
|
+
* Scrolls the table to bring the row at the specified original index into view.
|
|
413
|
+
* @param index - The original index of the row (from the initial dataset).
|
|
414
|
+
*/
|
|
415
|
+
scrollToOriginalIndex(index: number): void;
|
|
416
|
+
scrollToFilteredIndex(index: number): void;
|
|
417
|
+
scrollToPx(px: number): void;
|
|
418
|
+
/**
|
|
419
|
+
* Sets the display order of the columns in the table.
|
|
420
|
+
*
|
|
421
|
+
* @param fields - An array of field names representing the new order of columns. Columns not included in the array will be placed at the end.
|
|
422
|
+
* @throws {TypeError} If `fields` is not an array.
|
|
423
|
+
*/
|
|
424
|
+
setColumnOrder(fields: string[]): void;
|
|
425
|
+
/**
|
|
426
|
+
* Refreshes the table display. This re-applies filters, sorting, and updates headers and rows.
|
|
427
|
+
*/
|
|
428
|
+
refresh(): void;
|
|
429
|
+
/**
|
|
430
|
+
* Finds the original index of the first row where the specified field matches the given value.
|
|
431
|
+
* This searches through the original, unfiltered dataset.
|
|
432
|
+
* @param field - The field name within the row data to search.
|
|
433
|
+
* @param value - The value to match against the field's content.
|
|
434
|
+
* @returns The original index of the found row, or -1 if no match is found.
|
|
435
|
+
* @example
|
|
436
|
+
* ```ts
|
|
437
|
+
* const index = dataTable.indexOf('id', 12345);
|
|
438
|
+
* if (index >= 0) {
|
|
439
|
+
* dataTable.updateRow({description: "Updated description"}, index);
|
|
440
|
+
* }
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
indexOf(field: string, value: any): number;
|
|
444
|
+
/**
|
|
445
|
+
* Updates the data of a row at a specific original index.
|
|
446
|
+
* @param data - An object containing the new data to assign to the row. Existing fields will be updated, and new fields will be added.
|
|
447
|
+
* @param index - The original index of the row to update.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```ts
|
|
451
|
+
* const index = dataTable.indexOf('id', 12345);
|
|
452
|
+
* if (index >= 0) {
|
|
453
|
+
* dataTable.updateRow({description: "Updated description"}, index);
|
|
454
|
+
* }
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
updateRow(data: Row, index: number): void;
|
|
458
|
+
/**
|
|
459
|
+
* Deletes a row at a specific original index from the table.
|
|
460
|
+
* @param index - The original index of the row to delete.
|
|
461
|
+
*/
|
|
462
|
+
deleteRow(index: number): void;
|
|
463
|
+
/**
|
|
464
|
+
* Executes a callback function without triggering table updates (like re-rendering or event dispatches)
|
|
465
|
+
* until the callback has completed. This is useful for batching multiple operations.
|
|
466
|
+
* @param callback - A function to execute. It receives the DataTable instance as its argument.
|
|
467
|
+
* @example dataTable.withoutUpdates(dt => { dt.sort('name', 'asc'); dt.filter({ age: '>30' }); });
|
|
468
|
+
*/
|
|
469
|
+
withoutUpdates(callback: (datatable: DataTable) => void): void;
|
|
470
|
+
addEventListener<K extends keyof DataTableEventMap>(type: K, listener: (this: DataTable, ev: CustomEvent<DataTableEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
471
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Defines the mapping between event names and their detail object types.
|
|
475
|
+
*/
|
|
476
|
+
interface DataTableEventMap {
|
|
477
|
+
'dt.row.clicked': {
|
|
478
|
+
row: Row;
|
|
479
|
+
index: number;
|
|
480
|
+
column: string | undefined;
|
|
481
|
+
originalEvent: MouseEvent;
|
|
482
|
+
};
|
|
483
|
+
'dt.rows.changed': object;
|
|
484
|
+
'dt.col.sort': {
|
|
485
|
+
column: string;
|
|
486
|
+
order: SortOrder;
|
|
487
|
+
};
|
|
488
|
+
'dt.col.visibility': {
|
|
489
|
+
column: string;
|
|
490
|
+
visible: boolean;
|
|
491
|
+
};
|
|
492
|
+
'dt.col.resize': {
|
|
493
|
+
column: string;
|
|
494
|
+
width: number;
|
|
495
|
+
};
|
|
496
|
+
'dt.col.reorder': {
|
|
497
|
+
draggedColumn: string;
|
|
498
|
+
dropColumn: string;
|
|
499
|
+
order: string[];
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
interface Options {
|
|
504
|
+
saveColumnSorting: boolean;
|
|
505
|
+
saveColumnOrder: boolean;
|
|
506
|
+
saveColumnVisibility: boolean;
|
|
507
|
+
saveColumnWidth: boolean;
|
|
508
|
+
}
|
|
509
|
+
declare class LocalStorageAdapter {
|
|
510
|
+
#private;
|
|
511
|
+
/**
|
|
512
|
+
* @param dataTable - The DataTable instance to monitor.
|
|
513
|
+
* @param storageKey - The key to use for saving the state in localStorage.
|
|
514
|
+
* @param options - The key to use for saving the state in localStorage.
|
|
515
|
+
*/
|
|
516
|
+
constructor(dataTable: DataTable, storageKey: string, options?: Options);
|
|
517
|
+
/**
|
|
518
|
+
* Saves the current column state to localStorage.
|
|
519
|
+
*/
|
|
520
|
+
saveState(): void;
|
|
521
|
+
/**
|
|
522
|
+
* Restores the column state from localStorage.
|
|
523
|
+
*/
|
|
524
|
+
restoreState(): void;
|
|
525
|
+
/**
|
|
526
|
+
* Clears the saved state from localStorage.
|
|
527
|
+
*/
|
|
528
|
+
clearState(): void;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export { type CellFormatterCallback, type ColumnFilterCallback, type ColumnOptions, type ColumnState, type ComparatorCallback, DataTable, type DataTableEventMap, type FilterCallback, type Filters, type LoadOptions, LocalStorageAdapter, type Row, type RowFormatterCallback, type SortOrder, type SortValueCallback, type TableClasses, type TableOptions, type TokenizerCallback, type ValueFormatterCallback };
|