@timlassiter11/yatl 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -5,18 +5,6 @@ type NestedKeyOf<ObjectType> = ObjectType extends object ? {
5
5
  [Key in keyof ObjectType & (string | number)]: NonNullable<ObjectType[Key]> extends unknown[] ? `${Key}` : NonNullable<ObjectType[Key]> extends object ? // Recurse with the non-nullable type
6
6
  `${Key}` | `${Key}.${NestedKeyOf<NonNullable<ObjectType[Key]>>}` : `${Key}`;
7
7
  }[keyof ObjectType & (string | number)] : never;
8
- declare const createRegexTokenizer: (exp?: string) => (value: string) => {
9
- value: string;
10
- quoted: boolean;
11
- }[];
12
- declare const whitespaceTokenizer: (value: string) => {
13
- value: string;
14
- quoted: boolean;
15
- }[];
16
- declare function findColumn<T extends {
17
- field: string;
18
- }>(field: string, columns: T[]): T | undefined;
19
-
20
8
  /**
21
9
  * Default type for the table.
22
10
  */
@@ -140,6 +128,15 @@ interface BaseColumnOptions<T> {
140
128
  * or just for searching and filtering.
141
129
  */
142
130
  role?: ColumnRole;
131
+ /**
132
+ * Whether the column is sortable.
133
+ */
134
+ sortable?: boolean;
135
+ /**
136
+ * A function to use for sorting the column.
137
+ * This overrides the default sorting behavior.
138
+ */
139
+ sorter?: SortValueCallback;
143
140
  /**
144
141
  * Whether the column is searchable.
145
142
  */
@@ -172,10 +169,6 @@ interface DisplayColumnOptions<T> extends BaseColumnOptions<T> {
172
169
  * The title to display in the header.
173
170
  */
174
171
  title?: string;
175
- /**
176
- * Whether the column is sortable.
177
- */
178
- sortable?: boolean;
179
172
  /**
180
173
  * Whether the column should be resizable.
181
174
  */
@@ -193,16 +186,6 @@ interface DisplayColumnOptions<T> extends BaseColumnOptions<T> {
193
186
  * NOTE: Search highlighting will not work for this cell when used.
194
187
  */
195
188
  cellRenderer?: CellRenderCallback<T>;
196
- /**
197
- * A function to use for sorting the column.
198
- * This overrides the default sorting behavior.
199
- */
200
- sorter?: ComparatorCallback;
201
- /**
202
- * A function to derive a comparable value from the cell's original value, specifically for sorting this column.
203
- * This can be used to preprocess and cache values (e.g., convert to lowercase, extract numbers) before comparison.
204
- */
205
- sortValue?: SortValueCallback;
206
189
  }
207
190
  /**
208
191
  * Internal column definition used for searching and filtering
@@ -346,6 +329,15 @@ declare class YatlStateChangeEvent<T> extends YatlEvent<{
346
329
  constructor(state: TableState<T>, triggers: string[]);
347
330
  }
348
331
 
332
+ declare const createRegexTokenizer: (exp?: string) => (value: string) => {
333
+ value: string;
334
+ quoted: boolean;
335
+ }[];
336
+ declare const whitespaceTokenizer: (value: string) => {
337
+ value: string;
338
+ quoted: boolean;
339
+ }[];
340
+
349
341
  /**
350
342
  * Represents a dynamic and interactive table with features like sorting, searching, filtering,
351
343
  * column resizing, column rearranging, and virtual scrolling.
@@ -357,7 +349,8 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
357
349
  private _enableSearchTokenization;
358
350
  private _enableSearchScoring;
359
351
  private _columns;
360
- private _columnStates;
352
+ private _columnDefinitionMap;
353
+ private _columnStateMap;
361
354
  private _columnOrder;
362
355
  private _storageOptions;
363
356
  private _data;
@@ -452,6 +445,7 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
452
445
  */
453
446
  get columns(): ColumnOptions<T>[];
454
447
  set columns(columns: ColumnOptions<T>[]);
448
+ get displayColumns(): DisplayColumnOptions<T>[];
455
449
  /**
456
450
  * The current order of the columns.
457
451
  * * **NOTE:** This includes hidden columns but not internal columns
@@ -541,6 +535,8 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
541
535
  get data(): T[];
542
536
  set data(value: T[]);
543
537
  get filteredData(): T[];
538
+ getColumn(field: NestedKeyOf<T>): ColumnOptions<T> | undefined;
539
+ getDisplayColumn(field: NestedKeyOf<T>): DisplayColumnOptions<T> | undefined;
544
540
  /**
545
541
  * Gets a copy of the current state of the table.
546
542
  */
@@ -639,7 +635,7 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
639
635
  protected renderHeaderCell(field: NestedKeyOf<T>): TemplateResult<1> | typeof nothing;
640
636
  protected renderHeader(): TemplateResult<1>;
641
637
  protected renderCellContents(value: unknown, column: DisplayColumnOptions<T>, row: T): unknown;
642
- protected renderCell(field: NestedKeyOf<T>, row: T): TemplateResult<1> | typeof nothing;
638
+ protected renderCell(field: NestedKeyOf<T>, row: T): TemplateResult<1> | typeof nothing | undefined;
643
639
  protected renderRow(row: T, index: number): TemplateResult<1>;
644
640
  protected renderBody(): TemplateResult<1>;
645
641
  protected renderFooter(): TemplateResult<1> | typeof nothing;
@@ -670,15 +666,17 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
670
666
  private sortRows;
671
667
  private createMetadata;
672
668
  private updateInternalQuery;
673
- private getColumns;
674
- private getColumnData;
675
669
  /**
676
670
  * Gets the width of each column in the
677
671
  * order they will appear in the grid.
678
672
  */
679
673
  private getGridWidths;
680
674
  private scheduleSave;
681
- private getColumnState;
675
+ /**
676
+ * Gets the column state associated with the given field.
677
+ * If the state doesn't exist, a default state will be created.
678
+ */
679
+ private getOrCreateColumnState;
682
680
  private saveStateToStorage;
683
681
  private loadStateFromStorage;
684
682
  private handleHeaderClicked;
@@ -716,4 +714,4 @@ declare global {
716
714
  }
717
715
  }
718
716
 
719
- export { type BaseColumnOptions, type CellPartsCallback, type CellRenderCallback, type ColumnFilterCallback, type ColumnInitOptions, type ColumnOptions, type ColumnRole, type ColumnState, type ComparatorCallback, type Compareable, type DisplayColumnOptions, type FilterCallback, type Filters, type InternalColumnOptions, type NestedKeyOf, type QueryToken, type RestorableColumnState, type RestorableTableState, type RowPartsCallback, type SortOrder, type SortState, type SortValueCallback, type StorageOptions, type TableState, type TokenizerCallback, type UnspecifiedRecord, type ValueFormatterCallback, YatlChangeEvent, YatlColumnReorderEvent, YatlColumnResizeEvent, YatlColumnToggleEvent, YatlEvent, YatlRowClickEvent, YatlSearchEvent, YatlSortEvent, YatlStateChangeEvent, YatlTable, createRegexTokenizer, findColumn, whitespaceTokenizer };
717
+ export { type BaseColumnOptions, type CellPartsCallback, type CellRenderCallback, type ColumnFilterCallback, type ColumnInitOptions, type ColumnOptions, type ColumnRole, type ColumnState, type ComparatorCallback, type Compareable, type DisplayColumnOptions, type FilterCallback, type Filters, type InternalColumnOptions, type NestedKeyOf, type QueryToken, type RestorableColumnState, type RestorableTableState, type RowPartsCallback, type SortOrder, type SortState, type SortValueCallback, type StorageOptions, type TableState, type TokenizerCallback, type UnspecifiedRecord, type ValueFormatterCallback, YatlChangeEvent, YatlColumnReorderEvent, YatlColumnResizeEvent, YatlColumnToggleEvent, YatlEvent, YatlRowClickEvent, YatlSearchEvent, YatlSortEvent, YatlStateChangeEvent, YatlTable, createRegexTokenizer, whitespaceTokenizer };
package/dist/index.d.ts CHANGED
@@ -5,18 +5,6 @@ type NestedKeyOf<ObjectType> = ObjectType extends object ? {
5
5
  [Key in keyof ObjectType & (string | number)]: NonNullable<ObjectType[Key]> extends unknown[] ? `${Key}` : NonNullable<ObjectType[Key]> extends object ? // Recurse with the non-nullable type
6
6
  `${Key}` | `${Key}.${NestedKeyOf<NonNullable<ObjectType[Key]>>}` : `${Key}`;
7
7
  }[keyof ObjectType & (string | number)] : never;
8
- declare const createRegexTokenizer: (exp?: string) => (value: string) => {
9
- value: string;
10
- quoted: boolean;
11
- }[];
12
- declare const whitespaceTokenizer: (value: string) => {
13
- value: string;
14
- quoted: boolean;
15
- }[];
16
- declare function findColumn<T extends {
17
- field: string;
18
- }>(field: string, columns: T[]): T | undefined;
19
-
20
8
  /**
21
9
  * Default type for the table.
22
10
  */
@@ -140,6 +128,15 @@ interface BaseColumnOptions<T> {
140
128
  * or just for searching and filtering.
141
129
  */
142
130
  role?: ColumnRole;
131
+ /**
132
+ * Whether the column is sortable.
133
+ */
134
+ sortable?: boolean;
135
+ /**
136
+ * A function to use for sorting the column.
137
+ * This overrides the default sorting behavior.
138
+ */
139
+ sorter?: SortValueCallback;
143
140
  /**
144
141
  * Whether the column is searchable.
145
142
  */
@@ -172,10 +169,6 @@ interface DisplayColumnOptions<T> extends BaseColumnOptions<T> {
172
169
  * The title to display in the header.
173
170
  */
174
171
  title?: string;
175
- /**
176
- * Whether the column is sortable.
177
- */
178
- sortable?: boolean;
179
172
  /**
180
173
  * Whether the column should be resizable.
181
174
  */
@@ -193,16 +186,6 @@ interface DisplayColumnOptions<T> extends BaseColumnOptions<T> {
193
186
  * NOTE: Search highlighting will not work for this cell when used.
194
187
  */
195
188
  cellRenderer?: CellRenderCallback<T>;
196
- /**
197
- * A function to use for sorting the column.
198
- * This overrides the default sorting behavior.
199
- */
200
- sorter?: ComparatorCallback;
201
- /**
202
- * A function to derive a comparable value from the cell's original value, specifically for sorting this column.
203
- * This can be used to preprocess and cache values (e.g., convert to lowercase, extract numbers) before comparison.
204
- */
205
- sortValue?: SortValueCallback;
206
189
  }
207
190
  /**
208
191
  * Internal column definition used for searching and filtering
@@ -346,6 +329,15 @@ declare class YatlStateChangeEvent<T> extends YatlEvent<{
346
329
  constructor(state: TableState<T>, triggers: string[]);
347
330
  }
348
331
 
332
+ declare const createRegexTokenizer: (exp?: string) => (value: string) => {
333
+ value: string;
334
+ quoted: boolean;
335
+ }[];
336
+ declare const whitespaceTokenizer: (value: string) => {
337
+ value: string;
338
+ quoted: boolean;
339
+ }[];
340
+
349
341
  /**
350
342
  * Represents a dynamic and interactive table with features like sorting, searching, filtering,
351
343
  * column resizing, column rearranging, and virtual scrolling.
@@ -357,7 +349,8 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
357
349
  private _enableSearchTokenization;
358
350
  private _enableSearchScoring;
359
351
  private _columns;
360
- private _columnStates;
352
+ private _columnDefinitionMap;
353
+ private _columnStateMap;
361
354
  private _columnOrder;
362
355
  private _storageOptions;
363
356
  private _data;
@@ -452,6 +445,7 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
452
445
  */
453
446
  get columns(): ColumnOptions<T>[];
454
447
  set columns(columns: ColumnOptions<T>[]);
448
+ get displayColumns(): DisplayColumnOptions<T>[];
455
449
  /**
456
450
  * The current order of the columns.
457
451
  * * **NOTE:** This includes hidden columns but not internal columns
@@ -541,6 +535,8 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
541
535
  get data(): T[];
542
536
  set data(value: T[]);
543
537
  get filteredData(): T[];
538
+ getColumn(field: NestedKeyOf<T>): ColumnOptions<T> | undefined;
539
+ getDisplayColumn(field: NestedKeyOf<T>): DisplayColumnOptions<T> | undefined;
544
540
  /**
545
541
  * Gets a copy of the current state of the table.
546
542
  */
@@ -639,7 +635,7 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
639
635
  protected renderHeaderCell(field: NestedKeyOf<T>): TemplateResult<1> | typeof nothing;
640
636
  protected renderHeader(): TemplateResult<1>;
641
637
  protected renderCellContents(value: unknown, column: DisplayColumnOptions<T>, row: T): unknown;
642
- protected renderCell(field: NestedKeyOf<T>, row: T): TemplateResult<1> | typeof nothing;
638
+ protected renderCell(field: NestedKeyOf<T>, row: T): TemplateResult<1> | typeof nothing | undefined;
643
639
  protected renderRow(row: T, index: number): TemplateResult<1>;
644
640
  protected renderBody(): TemplateResult<1>;
645
641
  protected renderFooter(): TemplateResult<1> | typeof nothing;
@@ -670,15 +666,17 @@ declare class YatlTable<T extends object = UnspecifiedRecord> extends LitElement
670
666
  private sortRows;
671
667
  private createMetadata;
672
668
  private updateInternalQuery;
673
- private getColumns;
674
- private getColumnData;
675
669
  /**
676
670
  * Gets the width of each column in the
677
671
  * order they will appear in the grid.
678
672
  */
679
673
  private getGridWidths;
680
674
  private scheduleSave;
681
- private getColumnState;
675
+ /**
676
+ * Gets the column state associated with the given field.
677
+ * If the state doesn't exist, a default state will be created.
678
+ */
679
+ private getOrCreateColumnState;
682
680
  private saveStateToStorage;
683
681
  private loadStateFromStorage;
684
682
  private handleHeaderClicked;
@@ -716,4 +714,4 @@ declare global {
716
714
  }
717
715
  }
718
716
 
719
- export { type BaseColumnOptions, type CellPartsCallback, type CellRenderCallback, type ColumnFilterCallback, type ColumnInitOptions, type ColumnOptions, type ColumnRole, type ColumnState, type ComparatorCallback, type Compareable, type DisplayColumnOptions, type FilterCallback, type Filters, type InternalColumnOptions, type NestedKeyOf, type QueryToken, type RestorableColumnState, type RestorableTableState, type RowPartsCallback, type SortOrder, type SortState, type SortValueCallback, type StorageOptions, type TableState, type TokenizerCallback, type UnspecifiedRecord, type ValueFormatterCallback, YatlChangeEvent, YatlColumnReorderEvent, YatlColumnResizeEvent, YatlColumnToggleEvent, YatlEvent, YatlRowClickEvent, YatlSearchEvent, YatlSortEvent, YatlStateChangeEvent, YatlTable, createRegexTokenizer, findColumn, whitespaceTokenizer };
717
+ export { type BaseColumnOptions, type CellPartsCallback, type CellRenderCallback, type ColumnFilterCallback, type ColumnInitOptions, type ColumnOptions, type ColumnRole, type ColumnState, type ComparatorCallback, type Compareable, type DisplayColumnOptions, type FilterCallback, type Filters, type InternalColumnOptions, type NestedKeyOf, type QueryToken, type RestorableColumnState, type RestorableTableState, type RowPartsCallback, type SortOrder, type SortState, type SortValueCallback, type StorageOptions, type TableState, type TokenizerCallback, type UnspecifiedRecord, type ValueFormatterCallback, YatlChangeEvent, YatlColumnReorderEvent, YatlColumnResizeEvent, YatlColumnToggleEvent, YatlEvent, YatlRowClickEvent, YatlSearchEvent, YatlSortEvent, YatlStateChangeEvent, YatlTable, createRegexTokenizer, whitespaceTokenizer };