@timlassiter11/yatl 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- .data-table{--dt-header-sorter-width: 1ch;--dt-header-resizer-width: 10px;--dt-header-drop-color: rgba(255, 255, 255, .1);position:relative;white-space:nowrap;overflow:auto;width:100%;table-layout:fixed!important}.dt-headers{position:sticky;top:0;z-index:1}.dt-headers th{overflow:hidden;box-sizing:border-box}.dt-headers .dt-header-content{position:relative}.dt-sortable .dt-header-content{cursor:pointer}.dt-header-title-wrapper{display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;overflow:hidden}.dt-sort-icon{position:relative;width:var(--dt-header-sorter-width);align-self:stretch;padding:0 12px;overflow:hidden;flex-shrink:0}.dt-sort-icon:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.dt-sortable.dt-descending .dt-sort-icon:after{content:"\2191"}.dt-sortable.dt-ascending .dt-sort-icon:after{content:"\2193"}.dt-resizer{position:absolute;top:0;right:calc((var(--dt-header-resizer-width) / 2) * -1);height:100%;width:var(--dt-header-resizer-width);cursor:ew-resize;z-index:2}.dt-resizer:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:1px;height:60%;background-color:currentColor}.dt-headers>tr>th.dt-drag-over,.dt-headers>tr>th:has(.dt-drag-over){background-color:var(--dt-header-drop-color)}.data-table>tbody>tr>td,.dt-header-title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.dt-empty{text-align:center;pointer-events:none}
1
+ .data-table{--dt-header-sorter-width: 1ch;--dt-header-resizer-width: 10px;--dt-header-drop-color: rgba(255, 255, 255, .1);position:relative;white-space:nowrap;overflow:auto;table-layout:fixed}.dt-scroller{max-width:100%;max-height:100%;overflow:auto;position:relative}.dt-headers{position:sticky;top:0;z-index:1}.dt-headers th{overflow:hidden;box-sizing:border-box}.dt-headers .dt-header-content{position:relative}.dt-sortable .dt-header-content{cursor:pointer}.dt-header-title-wrapper{display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;overflow:hidden}.dt-sort-icon{position:relative;width:var(--dt-header-sorter-width);align-self:stretch;padding:0 12px;overflow:hidden;flex-shrink:0}.dt-sort-icon:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.dt-sortable.dt-descending .dt-sort-icon:after{content:"\2191"}.dt-sortable.dt-ascending .dt-sort-icon:after{content:"\2193"}.dt-resizer{position:absolute;top:0;right:calc((var(--dt-header-resizer-width) / 2) * -1);height:100%;width:var(--dt-header-resizer-width);cursor:ew-resize;z-index:2}.dt-resizer:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:1px;height:60%;background-color:currentColor}.dt-headers>tr>th.dt-drag-over,.dt-headers>tr>th:has(.dt-drag-over){background-color:var(--dt-header-drop-color)}.data-table>tbody>tr>td,.dt-header-title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.dt-empty{text-align:center;pointer-events:none}
2
2
  /*# sourceMappingURL=data-table.css.map */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/data-table/data-table.css"],"sourcesContent":[".data-table {\n --dt-header-sorter-width: 1ch;\n --dt-header-resizer-width: 10px;\n --dt-header-drop-color: rgba(255, 255, 255, 0.1);\n\n position: relative;\n white-space: nowrap;\n overflow: auto;\n width: 100%;\n table-layout: fixed !important;\n}\n\n.dt-headers {\n position: sticky;\n top: 0;\n z-index: 1;\n}\n\n.dt-headers th {\n overflow: hidden;\n box-sizing: border-box;\n}\n\n.dt-headers .dt-header-content {\n position: relative;\n}\n\n.dt-sortable .dt-header-content {\n cursor: pointer;\n}\n\n.dt-header-title-wrapper {\n display: flex;\n flex-direction: row;\n align-items: center;\n flex-wrap: nowrap;\n overflow: hidden;\n}\n\n.dt-sort-icon {\n position: relative;\n width: var(--dt-header-sorter-width);\n align-self: stretch;\n padding: 0 12px;\n overflow: hidden;\n flex-shrink: 0;\n}\n\n.dt-sort-icon::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n\n.dt-sortable.dt-descending .dt-sort-icon::after {\n content: '\\2191';\n}\n\n.dt-sortable.dt-ascending .dt-sort-icon::after {\n content: '\\2193';\n}\n\n.dt-resizer {\n position: absolute;\n top: 0;\n right: calc((var(--dt-header-resizer-width) / 2) * -1);\n height: 100%;\n width: var(--dt-header-resizer-width);\n cursor: ew-resize;\n z-index: 2;\n}\n\n.dt-resizer::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 1px;\n height: 60%;\n background-color: currentColor;\n}\n\n.dt-headers > tr > th.dt-drag-over,\n.dt-headers > tr > th:has(.dt-drag-over) {\n background-color: var(--dt-header-drop-color);\n}\n\n.data-table > tbody > tr > td,\n.dt-header-title {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n\n.dt-empty {\n text-align: center;\n pointer-events: none;\n}\n"],"mappings":"AAAA,CAAC,WACC,0BAA0B,IAC1B,2BAA2B,KAC3B,wBAAwB,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAE5C,SAAU,SACV,YAAa,OACb,SAAU,KACV,MAAO,KACP,aAAc,eAChB,CAEA,CAAC,WACC,SAAU,OACV,IAAK,EACL,QAAS,CACX,CAEA,CANC,WAMW,GACV,SAAU,OACV,WAAY,UACd,CAEA,CAXC,WAWW,CAAC,kBACX,SAAU,QACZ,CAEA,CAAC,YAAY,CAJA,kBAKX,OAAQ,OACV,CAEA,CAAC,wBACC,QAAS,KACT,eAAgB,IAChB,YAAa,OACb,UAAW,OACX,SAAU,MACZ,CAEA,CAAC,aACC,SAAU,SACV,MAAO,IAAI,0BACX,WAAY,QA1Cd,QA2CW,EAAE,KACX,SAAU,OACV,YAAa,CACf,CAEA,CATC,YASY,OACX,QAAS,GACT,SAAU,SACV,IAAK,IACL,KAAM,IACN,UAAW,UAAU,IAAI,CAAE,KAC7B,CAEA,CA7BC,WA6BW,CAAC,cAAc,CAjB1B,YAiBuC,OACtC,QAAS,OACX,CAEA,CAjCC,WAiCW,CAAC,aAAa,CArBzB,YAqBsC,OACrC,QAAS,OACX,CAEA,CAAC,WACC,SAAU,SACV,IAAK,EACL,MAAO,KAAK,CAAC,IAAI,2BAA2B,EAAE,GAAG,EAAE,IACnD,OAAQ,KACR,MAAO,IAAI,2BACX,OAAQ,UACR,QAAS,CACX,CAEA,CAVC,UAUU,OACT,QAAS,GACT,SAAU,SACV,IAAK,IACL,KAAM,IACN,UAAW,UAAU,IAAI,CAAE,MAC3B,MAAO,IACP,OAAQ,IACR,iBAAkB,YACpB,CAEA,CAzEC,UAyEW,CAAE,EAAG,CAAE,EAAE,CAAC,aACtB,CA1EC,UA0EW,CAAE,EAAG,CAAE,EAAE,KAAK,CADJ,cAEpB,iBAAkB,IAAI,uBACxB,CAEA,CA1FC,UA0FW,CAAE,KAAM,CAAE,EAAG,CAAE,GAC3B,CAAC,gBACC,cAAe,SACf,YAAa,OACb,SAAU,MACZ,CAEA,CAAC,SACC,WAAY,OACZ,eAAgB,IAClB","names":[]}
1
+ {"version":3,"sources":["../src/data-table/data-table.css"],"sourcesContent":[".data-table {\n --dt-header-sorter-width: 1ch;\n --dt-header-resizer-width: 10px;\n --dt-header-drop-color: rgba(255, 255, 255, 0.1);\n\n position: relative;\n white-space: nowrap;\n overflow: auto;\n table-layout: fixed;\n}\n\n.dt-scroller {\n max-width: 100%;\n max-height: 100%;\n overflow: auto;\n position: relative;\n}\n\n.dt-headers {\n position: sticky;\n top: 0;\n z-index: 1;\n}\n\n.dt-headers th {\n overflow: hidden;\n box-sizing: border-box;\n}\n\n.dt-headers .dt-header-content {\n position: relative;\n}\n\n.dt-sortable .dt-header-content {\n cursor: pointer;\n}\n\n.dt-header-title-wrapper {\n display: flex;\n flex-direction: row;\n align-items: center;\n flex-wrap: nowrap;\n overflow: hidden;\n}\n\n.dt-sort-icon {\n position: relative;\n width: var(--dt-header-sorter-width);\n align-self: stretch;\n padding: 0 12px;\n overflow: hidden;\n flex-shrink: 0;\n}\n\n.dt-sort-icon::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n\n.dt-sortable.dt-descending .dt-sort-icon::after {\n content: '\\2191';\n}\n\n.dt-sortable.dt-ascending .dt-sort-icon::after {\n content: '\\2193';\n}\n\n.dt-resizer {\n position: absolute;\n top: 0;\n right: calc((var(--dt-header-resizer-width) / 2) * -1);\n height: 100%;\n width: var(--dt-header-resizer-width);\n cursor: ew-resize;\n z-index: 2;\n}\n\n.dt-resizer::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 1px;\n height: 60%;\n background-color: currentColor;\n}\n\n.dt-headers > tr > th.dt-drag-over,\n.dt-headers > tr > th:has(.dt-drag-over) {\n background-color: var(--dt-header-drop-color);\n}\n\n.data-table > tbody > tr > td,\n.dt-header-title {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n\n.dt-empty {\n text-align: center;\n pointer-events: none;\n}\n"],"mappings":"AAAA,CAAC,WACC,0BAA0B,IAC1B,2BAA2B,KAC3B,wBAAwB,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAE5C,SAAU,SACV,YAAa,OACb,SAAU,KACV,aAAc,KAChB,CAEA,CAAC,YACC,UAAW,KACX,WAAY,KACZ,SAAU,KACV,SAAU,QACZ,CAEA,CAAC,WACC,SAAU,OACV,IAAK,EACL,QAAS,CACX,CAEA,CANC,WAMW,GACV,SAAU,OACV,WAAY,UACd,CAEA,CAXC,WAWW,CAAC,kBACX,SAAU,QACZ,CAEA,CAAC,YAAY,CAJA,kBAKX,OAAQ,OACV,CAEA,CAAC,wBACC,QAAS,KACT,eAAgB,IAChB,YAAa,OACb,UAAW,OACX,SAAU,MACZ,CAEA,CAAC,aACC,SAAU,SACV,MAAO,IAAI,0BACX,WAAY,QAhDd,QAiDW,EAAE,KACX,SAAU,OACV,YAAa,CACf,CAEA,CATC,YASY,OACX,QAAS,GACT,SAAU,SACV,IAAK,IACL,KAAM,IACN,UAAW,UAAU,IAAI,CAAE,KAC7B,CAEA,CA7BC,WA6BW,CAAC,cAAc,CAjB1B,YAiBuC,OACtC,QAAS,OACX,CAEA,CAjCC,WAiCW,CAAC,aAAa,CArBzB,YAqBsC,OACrC,QAAS,OACX,CAEA,CAAC,WACC,SAAU,SACV,IAAK,EACL,MAAO,KAAK,CAAC,IAAI,2BAA2B,EAAE,GAAG,EAAE,IACnD,OAAQ,KACR,MAAO,IAAI,2BACX,OAAQ,UACR,QAAS,CACX,CAEA,CAVC,UAUU,OACT,QAAS,GACT,SAAU,SACV,IAAK,IACL,KAAM,IACN,UAAW,UAAU,IAAI,CAAE,MAC3B,MAAO,IACP,OAAQ,IACR,iBAAkB,YACpB,CAEA,CAzEC,UAyEW,CAAE,EAAG,CAAE,EAAE,CAAC,aACtB,CA1EC,UA0EW,CAAE,EAAG,CAAE,EAAE,KAAK,CADJ,cAEpB,iBAAkB,IAAI,uBACxB,CAEA,CAhGC,UAgGW,CAAE,KAAM,CAAE,EAAG,CAAE,GAC3B,CAAC,gBACC,cAAe,SACf,YAAa,OACb,SAAU,MACZ,CAEA,CAAC,SACC,WAAY,OACZ,eAAgB,IAClB","names":[]}
@@ -28,7 +28,7 @@ interface IVirtualScrollConstructor {
28
28
  interface LoadOptions {
29
29
  /** If the data should replace or be added to the end of the current data */
30
30
  append?: boolean;
31
- /** If the current scroll position should be kepts */
31
+ /** If the current scroll position should be kept */
32
32
  keepScroll?: boolean;
33
33
  }
34
34
  /**
@@ -40,21 +40,22 @@ type SortOrder = 'asc' | 'desc';
40
40
  * @param row - The row data.
41
41
  * @param element - The row element.
42
42
  */
43
- type RowFormatterCallback<T extends object> = (row: T, element: HTMLElement) => void;
43
+ type RowFormatterCallback<T> = (row: T, element: HTMLElement) => void;
44
44
  /**
45
45
  * Callback for formatting the value of a cell.
46
46
  * Called when the cell is created and when exporting to CSV.
47
47
  * @param value - The value of the cell.
48
48
  * @param row - The row data.
49
49
  */
50
- type ValueFormatterCallback<T extends object> = (value: any, row: T) => string;
50
+ type ValueFormatterCallback<T> = (value: any, row: T) => string;
51
51
  /**
52
52
  * Callback for formatting a cell's HTML element.
53
+ * Called when the cell is created but NOT when exporting to CSV.
53
54
  * @param value - The value of the field.
54
55
  * @param row - The row data.
55
56
  * @param element - The cell element.
56
57
  */
57
- type CellFormatterCallback<T extends object> = (value: any, row: T, element: HTMLElement) => void;
58
+ type CellFormatterCallback<T> = (value: any, row: T, element: HTMLElement) => void;
58
59
  /**
59
60
  * Callback for comparing two values.
60
61
  * @param a - The first value.
@@ -74,7 +75,7 @@ type SortValueCallback = (value: any) => number | string;
74
75
  * and the values used to compare against.
75
76
  */
76
77
  type Filters<T extends object> = Partial<{
77
- [K in keyof T]: any;
78
+ [K in NestedKeyOf<T>]: any;
78
79
  }>;
79
80
  /**
80
81
  * A single query token derived from a larger string
@@ -102,7 +103,7 @@ type TokenizerCallback = (value: any) => QueryToken[];
102
103
  * @param index - The index of the row.
103
104
  * @returns True if the row matches the filter, false otherwise.
104
105
  */
105
- type FilterCallback = (row: any, index: number) => boolean;
106
+ type FilterCallback<T> = (row: T, index: number) => boolean;
106
107
  /**
107
108
  * Callback for filtering a field value against the filter data.
108
109
  * @param value - The value to filter.
@@ -110,6 +111,20 @@ type FilterCallback = (row: any, index: number) => boolean;
110
111
  * @returns True if the value matches the filter, false otherwise.
111
112
  */
112
113
  type ColumnFilterCallback = (value: any, filter: any) => boolean;
114
+ /**
115
+ * Represents the current sort state
116
+ */
117
+ interface SortState {
118
+ /**
119
+ * The sort order
120
+ */
121
+ order: SortOrder;
122
+ /**
123
+ * The sort priority.
124
+ * Lower priority means
125
+ */
126
+ priority: number;
127
+ }
113
128
  /**
114
129
  * Column options for the table.
115
130
  */
@@ -134,13 +149,8 @@ interface ColumnOptions<T extends object> {
134
149
  * Whether the column's data should be tokenized for searching.
135
150
  */
136
151
  tokenize?: boolean;
137
- /**
138
- * Whether the column should be visible by default.
139
- */
140
- visible?: boolean;
141
152
  /**
142
153
  * Whether the column should be resizable.
143
- * Defaults to the table's resizable option.
144
154
  */
145
155
  resizable?: boolean;
146
156
  /**
@@ -167,6 +177,27 @@ interface ColumnOptions<T extends object> {
167
177
  */
168
178
  filter?: ColumnFilterCallback | null;
169
179
  }
180
+ /**
181
+ * Represents the current state of a column.
182
+ */
183
+ interface ColumnState<T extends object> {
184
+ /**
185
+ * The unique field name of the column.
186
+ */
187
+ field: NestedKeyOf<T>;
188
+ /**
189
+ * The current visibility of the column.
190
+ */
191
+ visible: boolean;
192
+ /**
193
+ * The current sort order of the column.
194
+ */
195
+ sortState?: SortState | null;
196
+ /**
197
+ * The currently set width of the column in pixels.
198
+ */
199
+ width?: number | null;
200
+ }
170
201
  /**
171
202
  * Defines CSS classes to be applied to different parts of the table.
172
203
  */
@@ -204,10 +235,6 @@ interface TableClasses {
204
235
  * Options for configuring the table.
205
236
  */
206
237
  interface TableOptions<T extends object> {
207
- /**
208
- * Data to load into the table
209
- */
210
- data?: T[];
211
238
  /**
212
239
  * Configures virtual scrolling.
213
240
  */
@@ -225,16 +252,6 @@ interface TableOptions<T extends object> {
225
252
  * Scoring is very computationally expensive...
226
253
  */
227
254
  enableSearchScoring?: boolean;
228
- /**
229
- * Whether columns should be sortable by default.
230
- * Can be overridden on individual columns.
231
- */
232
- sortable?: boolean;
233
- /**
234
- * Whether columns should be resizable by default.
235
- * Can be overridden on individual columns.
236
- */
237
- resizable?: boolean;
238
255
  /**
239
256
  * Whether columns should be rearrangeable by drag and drop.
240
257
  */
@@ -264,53 +281,37 @@ interface TableOptions<T extends object> {
264
281
  * A function to use for tokenizing values for searching.
265
282
  */
266
283
  tokenizer?: TokenizerCallback;
284
+ /**
285
+ * A specific virtual scroll class to use
286
+ */
267
287
  virtualScrollClass?: IVirtualScrollConstructor;
268
288
  }
269
289
  /**
270
- * Represents the current sort state
290
+ * Represents the current state of the table
271
291
  */
272
- interface SortState {
273
- /**
274
- * The sort order
275
- */
276
- order: SortOrder;
277
- /**
278
- * The sort priority.
279
- * Lower priority means
280
- */
281
- priority: number;
282
- }
283
- /** Represents the current state of a column, often used for saving and restoring column configurations. */
284
- interface ColumnState<T extends object> {
285
- /**
286
- * The unique field name of the column.
287
- */
288
- field: NestedKeyOf<T>;
292
+ interface TableState<T extends object> {
289
293
  /**
290
- * The user friendly title of the column.
294
+ * A list of {@link ColumnState}s representing all of the columns in the table.
291
295
  */
292
- title: string;
296
+ columns: ColumnState<T>[];
293
297
  /**
294
- * The current visibility of the column.
298
+ * The current query applied to the table or null if no query is applied.
295
299
  */
296
- visible: boolean;
300
+ searchQuery: string | RegExp | null;
297
301
  /**
298
- * The current sort order of the column.
302
+ * The current filters applied to the table or null if no filters are applied.
299
303
  */
300
- sortState: SortState | null;
304
+ filters: Filters<T> | FilterCallback<T> | null;
301
305
  /**
302
- * The currently set width of the column.
306
+ * The current scroll position of the table
303
307
  */
304
- width: string;
305
- }
306
- interface TableState<T extends object> {
307
- columns: ColumnState<T>[];
308
- searchQuery?: string | RegExp;
309
- filters?: Filters<T> | FilterCallback;
310
308
  scrollPosition: {
311
309
  top: number;
312
310
  left: number;
313
311
  };
312
+ /**
313
+ * The current column order represented as a list of their fields from left to right.
314
+ */
314
315
  columnOrder: NestedKeyOf<T>[];
315
316
  }
316
317
  type RestorableColumnState<T extends object> = Partial<Omit<ColumnState<T>, 'field'>> & Pick<ColumnState<T>, 'field'>;
@@ -353,11 +354,11 @@ declare class DataTable<T extends object> extends EventTarget {
353
354
  * @throws {SyntaxError} If the table selector does not find an element.
354
355
  * @throws {TypeError} If the provided table element is not an HTMLTableElement or if columns option is not an array.
355
356
  */
356
- constructor(table: string | HTMLTableElement, columns: ColumnOptions<T>[], options?: TableOptions<T>);
357
+ constructor(table: string | HTMLTableElement, columns: ColumnInitOptions<T>[], options?: TableInitOptions<T>);
357
358
  /**
358
359
  * Gets the current options applied to the table.
359
360
  */
360
- get tableOptions(): RequiredTableOptions<T>;
361
+ get tableOptions(): ConcreteTableOptions<T>;
361
362
  /**
362
363
  * Gets the currently filtered and sorted rows displayed in the table.
363
364
  */
@@ -380,8 +381,8 @@ declare class DataTable<T extends object> extends EventTarget {
380
381
  */
381
382
  restoreState(state: RestorableTableState<T>): void;
382
383
  updateTableOptions(options: UpdatableTableOptions<T>): void;
383
- getColumnOptions(column: NestedKeyOf<T>): Required<Omit<ColumnOptions<T>, "field">>;
384
- updateColumnOptions(column: NestedKeyOf<T>, options: UpdateableColumnOptions<T>): void;
384
+ getColumnOptions(column: NestedKeyOf<T>): Required<ColumnOptionsWithoutField<T>>;
385
+ updateColumnOptions(column: NestedKeyOf<T>, options: ColumnOptionsWithoutField<T>): void;
385
386
  /**
386
387
  * Loads data into the table
387
388
  * @param rows - An array of data to be loaded
@@ -404,7 +405,7 @@ declare class DataTable<T extends object> extends EventTarget {
404
405
  * The search is performed on columns marked as `searchable` and `extraSearchFields`.
405
406
  * @param query - The search term (string) or a regular expression. An empty string clears the search.
406
407
  */
407
- search(query?: string | RegExp): void;
408
+ search(query?: string | RegExp | null): void;
408
409
  /**
409
410
  * Applies filters to the table rows.
410
411
  * Filters can be an object where keys are field names and values are the criteria to filter by,
@@ -412,7 +413,7 @@ declare class DataTable<T extends object> extends EventTarget {
412
413
  * @param filters - An object defining field-based filters or a custom filter callback function.
413
414
  * @throws {TypeError} If `filters` is not an object or a function.
414
415
  */
415
- filter(filters?: Filters<T> | FilterCallback): void;
416
+ filter(filters?: Filters<T> | FilterCallback<T> | null): void;
416
417
  /**
417
418
  * Sorts the table by a specified column and order.
418
419
  * If `order` is `null`, the sort on this column is removed.
@@ -504,7 +505,22 @@ declare class DataTable<T extends object> extends EventTarget {
504
505
  withoutUpdates(callback: (dataTable: DataTable<T>) => void): void;
505
506
  addEventListener<K extends keyof DataTableEventMap<T>>(type: K, listener: (this: DataTable<T>, ev: CustomEvent<DataTableEventMap<T>[K]>) => any, options?: boolean | AddEventListenerOptions): void;
506
507
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
508
+ private readonly TABLE_OPTION_CONFIGS;
509
+ private readonly COLUMN_OPTION_CONFIGS;
507
510
  }
511
+ type TableInitOptions<T extends object> = TableOptions<T> & {
512
+ data?: T[];
513
+ };
514
+ type ColumnInitOptions<T extends object> = ColumnOptions<T> & Partial<ColumnState<T>>;
515
+ type ConcreteTableClasses = Required<{
516
+ [K in keyof TableClasses]: string[];
517
+ }>;
518
+ type ConcreteTableOptions<T extends object> = Required<Omit<TableOptions<T>, 'data' | 'classes' | 'virtualScroll'>> & {
519
+ classes: ConcreteTableClasses;
520
+ virtualScroll: number;
521
+ };
522
+ type UpdatableTableOptions<T extends object> = TableOptions<T>;
523
+ type ColumnOptionsWithoutField<T extends object> = Omit<ColumnOptions<T>, 'field'>;
508
524
  /**
509
525
  * Defines the mapping between event names and their detail object types.
510
526
  */
@@ -537,15 +553,6 @@ interface DataTableEventMap<T> {
537
553
  query: string | RegExp | null;
538
554
  };
539
555
  }
540
- type ConcreteTableClasses = Required<{
541
- [K in keyof TableClasses]: string[];
542
- }>;
543
- type RequiredTableOptions<T extends object> = Required<Omit<TableOptions<T>, 'data' | 'classes' | 'virtualScroll'>> & {
544
- classes: ConcreteTableClasses;
545
- virtualScroll: number;
546
- };
547
- type UpdateableColumnOptions<T extends object> = Pick<ColumnOptions<T>, 'title' | 'searchable' | 'resizable' | 'sortable' | 'tokenize' | 'valueFormatter' | 'elementFormatter' | 'sorter'>;
548
- type UpdatableTableOptions<T extends object> = Pick<TableOptions<T>, 'virtualScroll' | 'highlightSearch' | 'tokenizeSearch' | 'enableSearchScoring' | 'rearrangeable' | 'extraSearchFields' | 'noMatchText' | 'noDataText' | 'classes'>;
549
556
 
550
557
  declare class VirtualScroll implements IVirtualScroll {
551
558
  #private;
@@ -567,7 +574,6 @@ declare class VirtualScrollError extends Error {
567
574
 
568
575
  interface LocalStorageAdapterOptions {
569
576
  saveSearch?: boolean;
570
- saveColumnTitle?: boolean;
571
577
  saveColumnSorting?: boolean;
572
578
  saveColumnOrder?: boolean;
573
579
  saveColumnVisibility?: boolean;
@@ -28,7 +28,7 @@ interface IVirtualScrollConstructor {
28
28
  interface LoadOptions {
29
29
  /** If the data should replace or be added to the end of the current data */
30
30
  append?: boolean;
31
- /** If the current scroll position should be kepts */
31
+ /** If the current scroll position should be kept */
32
32
  keepScroll?: boolean;
33
33
  }
34
34
  /**
@@ -40,21 +40,22 @@ type SortOrder = 'asc' | 'desc';
40
40
  * @param row - The row data.
41
41
  * @param element - The row element.
42
42
  */
43
- type RowFormatterCallback<T extends object> = (row: T, element: HTMLElement) => void;
43
+ type RowFormatterCallback<T> = (row: T, element: HTMLElement) => void;
44
44
  /**
45
45
  * Callback for formatting the value of a cell.
46
46
  * Called when the cell is created and when exporting to CSV.
47
47
  * @param value - The value of the cell.
48
48
  * @param row - The row data.
49
49
  */
50
- type ValueFormatterCallback<T extends object> = (value: any, row: T) => string;
50
+ type ValueFormatterCallback<T> = (value: any, row: T) => string;
51
51
  /**
52
52
  * Callback for formatting a cell's HTML element.
53
+ * Called when the cell is created but NOT when exporting to CSV.
53
54
  * @param value - The value of the field.
54
55
  * @param row - The row data.
55
56
  * @param element - The cell element.
56
57
  */
57
- type CellFormatterCallback<T extends object> = (value: any, row: T, element: HTMLElement) => void;
58
+ type CellFormatterCallback<T> = (value: any, row: T, element: HTMLElement) => void;
58
59
  /**
59
60
  * Callback for comparing two values.
60
61
  * @param a - The first value.
@@ -74,7 +75,7 @@ type SortValueCallback = (value: any) => number | string;
74
75
  * and the values used to compare against.
75
76
  */
76
77
  type Filters<T extends object> = Partial<{
77
- [K in keyof T]: any;
78
+ [K in NestedKeyOf<T>]: any;
78
79
  }>;
79
80
  /**
80
81
  * A single query token derived from a larger string
@@ -102,7 +103,7 @@ type TokenizerCallback = (value: any) => QueryToken[];
102
103
  * @param index - The index of the row.
103
104
  * @returns True if the row matches the filter, false otherwise.
104
105
  */
105
- type FilterCallback = (row: any, index: number) => boolean;
106
+ type FilterCallback<T> = (row: T, index: number) => boolean;
106
107
  /**
107
108
  * Callback for filtering a field value against the filter data.
108
109
  * @param value - The value to filter.
@@ -110,6 +111,20 @@ type FilterCallback = (row: any, index: number) => boolean;
110
111
  * @returns True if the value matches the filter, false otherwise.
111
112
  */
112
113
  type ColumnFilterCallback = (value: any, filter: any) => boolean;
114
+ /**
115
+ * Represents the current sort state
116
+ */
117
+ interface SortState {
118
+ /**
119
+ * The sort order
120
+ */
121
+ order: SortOrder;
122
+ /**
123
+ * The sort priority.
124
+ * Lower priority means
125
+ */
126
+ priority: number;
127
+ }
113
128
  /**
114
129
  * Column options for the table.
115
130
  */
@@ -134,13 +149,8 @@ interface ColumnOptions<T extends object> {
134
149
  * Whether the column's data should be tokenized for searching.
135
150
  */
136
151
  tokenize?: boolean;
137
- /**
138
- * Whether the column should be visible by default.
139
- */
140
- visible?: boolean;
141
152
  /**
142
153
  * Whether the column should be resizable.
143
- * Defaults to the table's resizable option.
144
154
  */
145
155
  resizable?: boolean;
146
156
  /**
@@ -167,6 +177,27 @@ interface ColumnOptions<T extends object> {
167
177
  */
168
178
  filter?: ColumnFilterCallback | null;
169
179
  }
180
+ /**
181
+ * Represents the current state of a column.
182
+ */
183
+ interface ColumnState<T extends object> {
184
+ /**
185
+ * The unique field name of the column.
186
+ */
187
+ field: NestedKeyOf<T>;
188
+ /**
189
+ * The current visibility of the column.
190
+ */
191
+ visible: boolean;
192
+ /**
193
+ * The current sort order of the column.
194
+ */
195
+ sortState?: SortState | null;
196
+ /**
197
+ * The currently set width of the column in pixels.
198
+ */
199
+ width?: number | null;
200
+ }
170
201
  /**
171
202
  * Defines CSS classes to be applied to different parts of the table.
172
203
  */
@@ -204,10 +235,6 @@ interface TableClasses {
204
235
  * Options for configuring the table.
205
236
  */
206
237
  interface TableOptions<T extends object> {
207
- /**
208
- * Data to load into the table
209
- */
210
- data?: T[];
211
238
  /**
212
239
  * Configures virtual scrolling.
213
240
  */
@@ -225,16 +252,6 @@ interface TableOptions<T extends object> {
225
252
  * Scoring is very computationally expensive...
226
253
  */
227
254
  enableSearchScoring?: boolean;
228
- /**
229
- * Whether columns should be sortable by default.
230
- * Can be overridden on individual columns.
231
- */
232
- sortable?: boolean;
233
- /**
234
- * Whether columns should be resizable by default.
235
- * Can be overridden on individual columns.
236
- */
237
- resizable?: boolean;
238
255
  /**
239
256
  * Whether columns should be rearrangeable by drag and drop.
240
257
  */
@@ -264,53 +281,37 @@ interface TableOptions<T extends object> {
264
281
  * A function to use for tokenizing values for searching.
265
282
  */
266
283
  tokenizer?: TokenizerCallback;
284
+ /**
285
+ * A specific virtual scroll class to use
286
+ */
267
287
  virtualScrollClass?: IVirtualScrollConstructor;
268
288
  }
269
289
  /**
270
- * Represents the current sort state
290
+ * Represents the current state of the table
271
291
  */
272
- interface SortState {
273
- /**
274
- * The sort order
275
- */
276
- order: SortOrder;
277
- /**
278
- * The sort priority.
279
- * Lower priority means
280
- */
281
- priority: number;
282
- }
283
- /** Represents the current state of a column, often used for saving and restoring column configurations. */
284
- interface ColumnState<T extends object> {
285
- /**
286
- * The unique field name of the column.
287
- */
288
- field: NestedKeyOf<T>;
292
+ interface TableState<T extends object> {
289
293
  /**
290
- * The user friendly title of the column.
294
+ * A list of {@link ColumnState}s representing all of the columns in the table.
291
295
  */
292
- title: string;
296
+ columns: ColumnState<T>[];
293
297
  /**
294
- * The current visibility of the column.
298
+ * The current query applied to the table or null if no query is applied.
295
299
  */
296
- visible: boolean;
300
+ searchQuery: string | RegExp | null;
297
301
  /**
298
- * The current sort order of the column.
302
+ * The current filters applied to the table or null if no filters are applied.
299
303
  */
300
- sortState: SortState | null;
304
+ filters: Filters<T> | FilterCallback<T> | null;
301
305
  /**
302
- * The currently set width of the column.
306
+ * The current scroll position of the table
303
307
  */
304
- width: string;
305
- }
306
- interface TableState<T extends object> {
307
- columns: ColumnState<T>[];
308
- searchQuery?: string | RegExp;
309
- filters?: Filters<T> | FilterCallback;
310
308
  scrollPosition: {
311
309
  top: number;
312
310
  left: number;
313
311
  };
312
+ /**
313
+ * The current column order represented as a list of their fields from left to right.
314
+ */
314
315
  columnOrder: NestedKeyOf<T>[];
315
316
  }
316
317
  type RestorableColumnState<T extends object> = Partial<Omit<ColumnState<T>, 'field'>> & Pick<ColumnState<T>, 'field'>;
@@ -353,11 +354,11 @@ declare class DataTable<T extends object> extends EventTarget {
353
354
  * @throws {SyntaxError} If the table selector does not find an element.
354
355
  * @throws {TypeError} If the provided table element is not an HTMLTableElement or if columns option is not an array.
355
356
  */
356
- constructor(table: string | HTMLTableElement, columns: ColumnOptions<T>[], options?: TableOptions<T>);
357
+ constructor(table: string | HTMLTableElement, columns: ColumnInitOptions<T>[], options?: TableInitOptions<T>);
357
358
  /**
358
359
  * Gets the current options applied to the table.
359
360
  */
360
- get tableOptions(): RequiredTableOptions<T>;
361
+ get tableOptions(): ConcreteTableOptions<T>;
361
362
  /**
362
363
  * Gets the currently filtered and sorted rows displayed in the table.
363
364
  */
@@ -380,8 +381,8 @@ declare class DataTable<T extends object> extends EventTarget {
380
381
  */
381
382
  restoreState(state: RestorableTableState<T>): void;
382
383
  updateTableOptions(options: UpdatableTableOptions<T>): void;
383
- getColumnOptions(column: NestedKeyOf<T>): Required<Omit<ColumnOptions<T>, "field">>;
384
- updateColumnOptions(column: NestedKeyOf<T>, options: UpdateableColumnOptions<T>): void;
384
+ getColumnOptions(column: NestedKeyOf<T>): Required<ColumnOptionsWithoutField<T>>;
385
+ updateColumnOptions(column: NestedKeyOf<T>, options: ColumnOptionsWithoutField<T>): void;
385
386
  /**
386
387
  * Loads data into the table
387
388
  * @param rows - An array of data to be loaded
@@ -404,7 +405,7 @@ declare class DataTable<T extends object> extends EventTarget {
404
405
  * The search is performed on columns marked as `searchable` and `extraSearchFields`.
405
406
  * @param query - The search term (string) or a regular expression. An empty string clears the search.
406
407
  */
407
- search(query?: string | RegExp): void;
408
+ search(query?: string | RegExp | null): void;
408
409
  /**
409
410
  * Applies filters to the table rows.
410
411
  * Filters can be an object where keys are field names and values are the criteria to filter by,
@@ -412,7 +413,7 @@ declare class DataTable<T extends object> extends EventTarget {
412
413
  * @param filters - An object defining field-based filters or a custom filter callback function.
413
414
  * @throws {TypeError} If `filters` is not an object or a function.
414
415
  */
415
- filter(filters?: Filters<T> | FilterCallback): void;
416
+ filter(filters?: Filters<T> | FilterCallback<T> | null): void;
416
417
  /**
417
418
  * Sorts the table by a specified column and order.
418
419
  * If `order` is `null`, the sort on this column is removed.
@@ -504,7 +505,22 @@ declare class DataTable<T extends object> extends EventTarget {
504
505
  withoutUpdates(callback: (dataTable: DataTable<T>) => void): void;
505
506
  addEventListener<K extends keyof DataTableEventMap<T>>(type: K, listener: (this: DataTable<T>, ev: CustomEvent<DataTableEventMap<T>[K]>) => any, options?: boolean | AddEventListenerOptions): void;
506
507
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
508
+ private readonly TABLE_OPTION_CONFIGS;
509
+ private readonly COLUMN_OPTION_CONFIGS;
507
510
  }
511
+ type TableInitOptions<T extends object> = TableOptions<T> & {
512
+ data?: T[];
513
+ };
514
+ type ColumnInitOptions<T extends object> = ColumnOptions<T> & Partial<ColumnState<T>>;
515
+ type ConcreteTableClasses = Required<{
516
+ [K in keyof TableClasses]: string[];
517
+ }>;
518
+ type ConcreteTableOptions<T extends object> = Required<Omit<TableOptions<T>, 'data' | 'classes' | 'virtualScroll'>> & {
519
+ classes: ConcreteTableClasses;
520
+ virtualScroll: number;
521
+ };
522
+ type UpdatableTableOptions<T extends object> = TableOptions<T>;
523
+ type ColumnOptionsWithoutField<T extends object> = Omit<ColumnOptions<T>, 'field'>;
508
524
  /**
509
525
  * Defines the mapping between event names and their detail object types.
510
526
  */
@@ -537,15 +553,6 @@ interface DataTableEventMap<T> {
537
553
  query: string | RegExp | null;
538
554
  };
539
555
  }
540
- type ConcreteTableClasses = Required<{
541
- [K in keyof TableClasses]: string[];
542
- }>;
543
- type RequiredTableOptions<T extends object> = Required<Omit<TableOptions<T>, 'data' | 'classes' | 'virtualScroll'>> & {
544
- classes: ConcreteTableClasses;
545
- virtualScroll: number;
546
- };
547
- type UpdateableColumnOptions<T extends object> = Pick<ColumnOptions<T>, 'title' | 'searchable' | 'resizable' | 'sortable' | 'tokenize' | 'valueFormatter' | 'elementFormatter' | 'sorter'>;
548
- type UpdatableTableOptions<T extends object> = Pick<TableOptions<T>, 'virtualScroll' | 'highlightSearch' | 'tokenizeSearch' | 'enableSearchScoring' | 'rearrangeable' | 'extraSearchFields' | 'noMatchText' | 'noDataText' | 'classes'>;
549
556
 
550
557
  declare class VirtualScroll implements IVirtualScroll {
551
558
  #private;
@@ -567,7 +574,6 @@ declare class VirtualScrollError extends Error {
567
574
 
568
575
  interface LocalStorageAdapterOptions {
569
576
  saveSearch?: boolean;
570
- saveColumnTitle?: boolean;
571
577
  saveColumnSorting?: boolean;
572
578
  saveColumnOrder?: boolean;
573
579
  saveColumnVisibility?: boolean;