schummar-table 0.40.5 → 0.40.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/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/mui4Theme.d.cts +1 -1
- package/dist/mui4Theme.d.ts +1 -1
- package/dist/mui5Theme.d.cts +1 -1
- package/dist/mui5Theme.d.ts +1 -1
- package/dist/{types-3d4ARU6a.d.ts → types-DcnzwYBU.d.ts} +55 -62
- package/dist/{types-CYMVvUGJ.d.cts → types-xTAreHv_.d.cts} +55 -62
- package/package.json +1 -1
package/dist/mui4Theme.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { P as PartialTableTheme } from './types-
|
|
3
|
+
import { P as PartialTableTheme } from './types-xTAreHv_.cjs';
|
|
4
4
|
import '@emotion/react';
|
|
5
5
|
import './exporter-u6SatTo6.cjs';
|
|
6
6
|
|
package/dist/mui4Theme.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { P as PartialTableTheme } from './types-
|
|
3
|
+
import { P as PartialTableTheme } from './types-DcnzwYBU.js';
|
|
4
4
|
import '@emotion/react';
|
|
5
5
|
import './exporter-u6SatTo6.js';
|
|
6
6
|
|
package/dist/mui5Theme.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { P as PartialTableTheme } from './types-
|
|
3
|
+
import { P as PartialTableTheme } from './types-xTAreHv_.cjs';
|
|
4
4
|
import '@emotion/react';
|
|
5
5
|
import './exporter-u6SatTo6.cjs';
|
|
6
6
|
|
package/dist/mui5Theme.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { P as PartialTableTheme } from './types-
|
|
3
|
+
import { P as PartialTableTheme } from './types-DcnzwYBU.js';
|
|
4
4
|
import '@emotion/react';
|
|
5
5
|
import './exporter-u6SatTo6.js';
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ type FunctionWithDeps<F extends (...args: any[]) => any> = F | [function: F, ...
|
|
|
26
26
|
type MemoizedFunctions<T> = {
|
|
27
27
|
[K in keyof T]: Exclude<T[K], [function: (...args: any[]) => any, ...deps: DependencyList]>;
|
|
28
28
|
};
|
|
29
|
-
interface TableTheme<
|
|
29
|
+
interface TableTheme<TItem = unknown> {
|
|
30
30
|
/** Define display texts. */
|
|
31
31
|
text: {
|
|
32
32
|
selectColumns: ReactNode;
|
|
@@ -56,23 +56,23 @@ interface TableTheme<T = unknown> {
|
|
|
56
56
|
table?: string;
|
|
57
57
|
headerCell?: string;
|
|
58
58
|
footerCell?: string;
|
|
59
|
-
cell?: string | FunctionWithDeps<(item:
|
|
59
|
+
cell?: string | FunctionWithDeps<(item: TItem, index: number) => string | undefined>;
|
|
60
60
|
evenCell?: string;
|
|
61
61
|
oddCell?: string;
|
|
62
62
|
popover?: string;
|
|
63
63
|
popoverBackdrop?: string;
|
|
64
64
|
columnDivider?: string;
|
|
65
|
-
details?: string | FunctionWithDeps<(item:
|
|
65
|
+
details?: string | FunctionWithDeps<(item: TItem, index: number) => string | undefined>;
|
|
66
66
|
};
|
|
67
67
|
styles?: {
|
|
68
68
|
table?: Interpolation<Theme>;
|
|
69
69
|
headerCell?: Interpolation<Theme>;
|
|
70
70
|
footerCell?: Interpolation<Theme>;
|
|
71
|
-
cell?: Exclude<Interpolation<Theme>, ((...args: any[]) => any) | Array<any>> | FunctionWithDeps<(item:
|
|
71
|
+
cell?: Exclude<Interpolation<Theme>, ((...args: any[]) => any) | Array<any>> | FunctionWithDeps<(item: TItem, index: number) => Interpolation<Theme>>;
|
|
72
72
|
evenCell?: Interpolation<Theme>;
|
|
73
73
|
oddCell?: Interpolation<Theme>;
|
|
74
74
|
columnDivider?: Interpolation<Theme>;
|
|
75
|
-
details?: Exclude<Interpolation<Theme>, ((...args: any[]) => any) | Array<any>> | FunctionWithDeps<(item:
|
|
75
|
+
details?: Exclude<Interpolation<Theme>, ((...args: any[]) => any) | Array<any>> | FunctionWithDeps<(item: TItem, index: number) => Interpolation<Theme>>;
|
|
76
76
|
};
|
|
77
77
|
/** Define components to be used in the table. */
|
|
78
78
|
components: {
|
|
@@ -158,35 +158,35 @@ interface TableTheme<T = unknown> {
|
|
|
158
158
|
/** Locale for number and date rendering */
|
|
159
159
|
locale?: string;
|
|
160
160
|
}
|
|
161
|
-
type PartialTableTheme<
|
|
162
|
-
[K in keyof TableTheme<
|
|
161
|
+
type PartialTableTheme<TItem = unknown> = {
|
|
162
|
+
[K in keyof TableTheme<TItem>]?: TableTheme<TItem>[K] extends Record<string, any> ? Partial<TableTheme<TItem>[K]> : TableTheme<TItem>[K];
|
|
163
163
|
};
|
|
164
|
-
type MemoizedTableTheme<
|
|
165
|
-
classes: MemoizedFunctions<TableTheme<
|
|
166
|
-
styles: MemoizedFunctions<TableTheme<
|
|
167
|
-
text: MemoizedFunctions<TableTheme<
|
|
164
|
+
type MemoizedTableTheme<TItem> = Omit<TableTheme, 'classes' | 'styles' | 'text'> & {
|
|
165
|
+
classes: MemoizedFunctions<TableTheme<TItem>['classes']>;
|
|
166
|
+
styles: MemoizedFunctions<TableTheme<TItem>['styles']>;
|
|
167
|
+
text: MemoizedFunctions<TableTheme<TItem>['text']>;
|
|
168
168
|
};
|
|
169
|
-
interface TableProps<
|
|
169
|
+
interface TableProps<TItem> extends PartialTableTheme<TItem> {
|
|
170
170
|
/** The data to be rendered. One item per row. */
|
|
171
|
-
items?: readonly
|
|
171
|
+
items?: readonly TItem[];
|
|
172
172
|
/** Unique id for each item/row. */
|
|
173
|
-
id: FunctionWithDeps<(item:
|
|
173
|
+
id: FunctionWithDeps<(item: TItem) => Id> | KeyOfType<TItem, Id>;
|
|
174
174
|
/** Create a nested structure by assigning parents to items. Child items are hidden until the parent is expanded. */
|
|
175
|
-
parentId?: FunctionWithDeps<(item:
|
|
175
|
+
parentId?: FunctionWithDeps<(item: TItem) => Id | undefined> | KeyOfType<TItem, Id | undefined | null>;
|
|
176
176
|
/** If true for an item, it means that children will be loaded asynchronously as soon as item is expanded. */
|
|
177
|
-
hasDeferredChildren?: (item:
|
|
177
|
+
hasDeferredChildren?: (item: TItem) => boolean;
|
|
178
178
|
/** Column definitions. */
|
|
179
|
-
columns: Column<
|
|
179
|
+
columns: Column<TItem, any>[] | ((col: <TColumnValue>(value: (item: TItem) => TColumnValue, column: Omit<Column<TItem, TColumnValue>, 'value'>) => Column<TItem, TColumnValue>) => Column<TItem, any>[]);
|
|
180
180
|
/** Default props for all column. Will take effect if not overriden in column definition. */
|
|
181
|
-
defaultColumnProps?: Omit<Column<
|
|
181
|
+
defaultColumnProps?: Omit<Column<TItem, unknown>, 'id' | 'value'>;
|
|
182
182
|
/** Set props for multiple columns at once. Will take effect if not overriden in column definition. */
|
|
183
|
-
columnProps?: FunctionWithDeps<(id: Id) => Partial<Omit<Column<
|
|
183
|
+
columnProps?: FunctionWithDeps<(id: Id) => Partial<Omit<Column<TItem, unknown>, 'id'>>>;
|
|
184
184
|
/** Wrap each cell */
|
|
185
|
-
wrapCell?: FunctionWithDeps<(content: ReactNode, value: unknown, item:
|
|
185
|
+
wrapCell?: FunctionWithDeps<(content: ReactNode, value: unknown, item: TItem, index: number) => ReactNode>;
|
|
186
186
|
/** Display a cell at the start of each row. Useful for "go to details" button for example. */
|
|
187
|
-
rowAction?: ReactNode | FunctionWithDeps<(item:
|
|
187
|
+
rowAction?: ReactNode | FunctionWithDeps<(item: TItem, index: number) => ReactNode>;
|
|
188
188
|
/** Expand row to show details. */
|
|
189
|
-
rowDetails?: ReactNode | FunctionWithDeps<(item:
|
|
189
|
+
rowDetails?: ReactNode | FunctionWithDeps<(item: TItem, index: number) => ReactNode>;
|
|
190
190
|
/** Default sort order. */
|
|
191
191
|
defaultSort?: Sort[];
|
|
192
192
|
/** If given, controls the sort order. */
|
|
@@ -287,19 +287,19 @@ interface TableProps<T> extends PartialTableTheme<T> {
|
|
|
287
287
|
debugRender?: (...output: any) => void;
|
|
288
288
|
onReset?: (scope?: 'table' | 'filters') => void;
|
|
289
289
|
}
|
|
290
|
-
type InternalTableProps<
|
|
291
|
-
id: (item:
|
|
292
|
-
parentId?: (item:
|
|
293
|
-
columns: InternalColumn<
|
|
290
|
+
type InternalTableProps<TItem> = MemoizedFunctions<Omit<TableProps<TItem>, 'id' | 'parentId' | 'columns' | 'defaultColumnProps' | 'enableExport'> & {
|
|
291
|
+
id: (item: TItem) => Id;
|
|
292
|
+
parentId?: (item: TItem) => Id | undefined;
|
|
293
|
+
columns: InternalColumn<TItem, unknown>[];
|
|
294
294
|
enableExport: boolean | ExportOptions;
|
|
295
295
|
}>;
|
|
296
|
-
type TableItem<
|
|
296
|
+
type TableItem<TItem = unknown> = {
|
|
297
297
|
id: Id;
|
|
298
298
|
parentId?: Id | null;
|
|
299
|
-
children: TableItem<
|
|
300
|
-
value:
|
|
299
|
+
children: TableItem<TItem>[];
|
|
300
|
+
value: TItem;
|
|
301
301
|
};
|
|
302
|
-
type Column<
|
|
302
|
+
type Column<TItem, TColumnValue> = {
|
|
303
303
|
/** Column id. If not provided, the index in the column array will be used.
|
|
304
304
|
* An explicit id is better however for controlling column related states, persitance etc.
|
|
305
305
|
*/
|
|
@@ -310,13 +310,13 @@ type Column<T, V> = {
|
|
|
310
310
|
/** Render table header for this column. */
|
|
311
311
|
footer?: ReactNode;
|
|
312
312
|
/** Extract value for this column */
|
|
313
|
-
value: FunctionWithDeps<(item:
|
|
313
|
+
value: FunctionWithDeps<(item: TItem) => TColumnValue>;
|
|
314
314
|
/** Render table cell. If not provided, a string representation of the value will be rendered. */
|
|
315
|
-
renderCell?: FunctionWithDeps<(value:
|
|
315
|
+
renderCell?: FunctionWithDeps<(value: TColumnValue, item: TItem) => ReactNode>;
|
|
316
316
|
/** Serialize column value for exports. If not provided, a string representation of the value will be used. */
|
|
317
|
-
exportCell?: (value:
|
|
317
|
+
exportCell?: (value: TColumnValue, item: TItem) => string | number | Date;
|
|
318
318
|
/** Customize sort criteria. By default it will be the value itself in case it's a number or Date, or a string representation of the value otherwise. */
|
|
319
|
-
sortBy?: FunctionWithDeps<(value:
|
|
319
|
+
sortBy?: FunctionWithDeps<(value: TColumnValue, item: TItem) => unknown>[];
|
|
320
320
|
/** Disable sort for this column */
|
|
321
321
|
disableSort?: boolean;
|
|
322
322
|
/** Set filter component that will be displayed in the column header */
|
|
@@ -328,46 +328,46 @@ type Column<T, V> = {
|
|
|
328
328
|
*/
|
|
329
329
|
width?: string;
|
|
330
330
|
/** Provide css class names to override columns styles. */
|
|
331
|
-
classes?: Omit<NonNullable<TableTheme<
|
|
331
|
+
classes?: Omit<NonNullable<TableTheme<TItem>['classes']>, 'table' | 'details'>;
|
|
332
332
|
/** Provide css styles to override columns styles. */
|
|
333
|
-
styles?: Omit<NonNullable<TableTheme<
|
|
333
|
+
styles?: Omit<NonNullable<TableTheme<TItem>['styles']>, 'table' | 'details'>;
|
|
334
334
|
};
|
|
335
|
-
type InternalColumn<
|
|
335
|
+
type InternalColumn<TItem, TColumnValue> = MemoizedFunctions<Required<Omit<Column<TItem, TColumnValue>, 'id' | 'sortBy'>, 'header' | 'exportHeader' | 'renderCell' | 'exportCell' | 'sortBy'> & {
|
|
336
336
|
id: Id;
|
|
337
|
-
sortBy: ((value:
|
|
337
|
+
sortBy: ((value: TColumnValue, item: TItem) => unknown)[];
|
|
338
338
|
}>;
|
|
339
339
|
type Required<T, S> = T & {
|
|
340
340
|
[P in keyof T as P extends S ? P : never]-?: T[P];
|
|
341
341
|
};
|
|
342
|
-
type InternalTableState<
|
|
343
|
-
props: InternalTableProps<
|
|
342
|
+
type InternalTableState<TItem> = {
|
|
343
|
+
props: InternalTableProps<TItem>;
|
|
344
344
|
key: any;
|
|
345
345
|
sort: Sort[];
|
|
346
346
|
selection: Set<Id>;
|
|
347
347
|
expanded: Set<Id>;
|
|
348
348
|
rowHeights: Map<Id, number>;
|
|
349
|
-
filters: Map<Id, MemoizedFunctions<FilterImplementation<
|
|
349
|
+
filters: Map<Id, MemoizedFunctions<FilterImplementation<TItem, any, any, any>>>;
|
|
350
350
|
filterValues: Map<Id, any>;
|
|
351
351
|
hiddenColumns: Set<Id>;
|
|
352
352
|
columnWidths: Map<Id, string>;
|
|
353
353
|
columnOrder: Id[];
|
|
354
354
|
columnStyleOverride: Map<Id, CSSProperties>;
|
|
355
|
-
activeColumns: InternalColumn<
|
|
356
|
-
items: TableItem<
|
|
357
|
-
itemsById: Map<Id, TableItem<
|
|
358
|
-
activeItems: TableItem<
|
|
359
|
-
activeItemsById: Map<Id, TableItem<
|
|
355
|
+
activeColumns: InternalColumn<TItem, unknown>[];
|
|
356
|
+
items: TableItem<TItem>[];
|
|
357
|
+
itemsById: Map<Id, TableItem<TItem>>;
|
|
358
|
+
activeItems: TableItem<TItem>[];
|
|
359
|
+
activeItemsById: Map<Id, TableItem<TItem>>;
|
|
360
360
|
lastSelectedId?: Id;
|
|
361
361
|
};
|
|
362
|
-
type CommonFilterProps<
|
|
362
|
+
type CommonFilterProps<TItem, TColumnValue, TFilterBy, TFilterValue> = {
|
|
363
363
|
/** Filter by? By default the column value will be used. If filterBy returns an array, an items will be active if at least one entry matches the active filter. */
|
|
364
|
-
filterBy?: FunctionWithDeps<(value:
|
|
364
|
+
filterBy?: FunctionWithDeps<(value: TColumnValue, item: TItem) => TFilterBy | TFilterBy[]>;
|
|
365
365
|
/** Preselected filter value. */
|
|
366
|
-
defaultValue?:
|
|
366
|
+
defaultValue?: TFilterValue;
|
|
367
367
|
/** Controlled filter value. */
|
|
368
|
-
value?:
|
|
368
|
+
value?: TFilterValue;
|
|
369
369
|
/** Notifies on filter change. */
|
|
370
|
-
onChange?: (value?:
|
|
370
|
+
onChange?: (value?: TFilterValue) => void;
|
|
371
371
|
/** Table should not filter using this filter. It will be done externally, e.g. server side. */
|
|
372
372
|
external?: boolean;
|
|
373
373
|
/** Whether to persist filter value (given that filter persitance is enabled for the table).
|
|
@@ -379,20 +379,13 @@ type CommonFilterProps<T, V, F, S extends SerializableValue> = {
|
|
|
379
379
|
popoverBackdrop?: string;
|
|
380
380
|
};
|
|
381
381
|
};
|
|
382
|
-
type FilterImplementation<
|
|
382
|
+
type FilterImplementation<TItem, TColumnValue, TFilterBy, TFilterValue> = CommonFilterProps<TItem, TColumnValue, TFilterBy, TFilterValue> & {
|
|
383
383
|
/** Unique filter id. Used to persist filter values. */
|
|
384
384
|
id: string;
|
|
385
385
|
/** Whether the filter is active currently. */
|
|
386
|
-
isActive: (filterValue:
|
|
386
|
+
isActive: (filterValue: TFilterValue) => boolean;
|
|
387
387
|
/** When the filter is active, this function is used to filter the items to be displayed. */
|
|
388
|
-
test: (filterValue:
|
|
388
|
+
test: (filterValue: TFilterValue, value: TFilterBy) => boolean;
|
|
389
389
|
};
|
|
390
|
-
type SerializableValue = string | number | boolean | null | Date | SerializableArray | SerializableObject | SerializableSet | SerializableMap;
|
|
391
|
-
type SerializableObject = {
|
|
392
|
-
[key: string]: SerializableValue;
|
|
393
|
-
};
|
|
394
|
-
type SerializableArray = SerializableValue[];
|
|
395
|
-
type SerializableSet = Set<SerializableValue>;
|
|
396
|
-
type SerializableMap = Map<SerializableValue, SerializableValue>;
|
|
397
390
|
|
|
398
|
-
export type { CommonFilterProps as C, FilterImplementation as F, Id as I, MemoizedTableTheme as M, PartialTableTheme as P,
|
|
391
|
+
export type { CommonFilterProps as C, FilterImplementation as F, Id as I, MemoizedTableTheme as M, PartialTableTheme as P, Sort as S, TableTheme as T, TableProps as a, TableItem as b, InternalTableState as c, TableStateStorage as d, Column as e, FunctionWithDeps as f, InternalColumn as g, SortDirection as h };
|
|
@@ -26,7 +26,7 @@ type FunctionWithDeps<F extends (...args: any[]) => any> = F | [function: F, ...
|
|
|
26
26
|
type MemoizedFunctions<T> = {
|
|
27
27
|
[K in keyof T]: Exclude<T[K], [function: (...args: any[]) => any, ...deps: DependencyList]>;
|
|
28
28
|
};
|
|
29
|
-
interface TableTheme<
|
|
29
|
+
interface TableTheme<TItem = unknown> {
|
|
30
30
|
/** Define display texts. */
|
|
31
31
|
text: {
|
|
32
32
|
selectColumns: ReactNode;
|
|
@@ -56,23 +56,23 @@ interface TableTheme<T = unknown> {
|
|
|
56
56
|
table?: string;
|
|
57
57
|
headerCell?: string;
|
|
58
58
|
footerCell?: string;
|
|
59
|
-
cell?: string | FunctionWithDeps<(item:
|
|
59
|
+
cell?: string | FunctionWithDeps<(item: TItem, index: number) => string | undefined>;
|
|
60
60
|
evenCell?: string;
|
|
61
61
|
oddCell?: string;
|
|
62
62
|
popover?: string;
|
|
63
63
|
popoverBackdrop?: string;
|
|
64
64
|
columnDivider?: string;
|
|
65
|
-
details?: string | FunctionWithDeps<(item:
|
|
65
|
+
details?: string | FunctionWithDeps<(item: TItem, index: number) => string | undefined>;
|
|
66
66
|
};
|
|
67
67
|
styles?: {
|
|
68
68
|
table?: Interpolation<Theme>;
|
|
69
69
|
headerCell?: Interpolation<Theme>;
|
|
70
70
|
footerCell?: Interpolation<Theme>;
|
|
71
|
-
cell?: Exclude<Interpolation<Theme>, ((...args: any[]) => any) | Array<any>> | FunctionWithDeps<(item:
|
|
71
|
+
cell?: Exclude<Interpolation<Theme>, ((...args: any[]) => any) | Array<any>> | FunctionWithDeps<(item: TItem, index: number) => Interpolation<Theme>>;
|
|
72
72
|
evenCell?: Interpolation<Theme>;
|
|
73
73
|
oddCell?: Interpolation<Theme>;
|
|
74
74
|
columnDivider?: Interpolation<Theme>;
|
|
75
|
-
details?: Exclude<Interpolation<Theme>, ((...args: any[]) => any) | Array<any>> | FunctionWithDeps<(item:
|
|
75
|
+
details?: Exclude<Interpolation<Theme>, ((...args: any[]) => any) | Array<any>> | FunctionWithDeps<(item: TItem, index: number) => Interpolation<Theme>>;
|
|
76
76
|
};
|
|
77
77
|
/** Define components to be used in the table. */
|
|
78
78
|
components: {
|
|
@@ -158,35 +158,35 @@ interface TableTheme<T = unknown> {
|
|
|
158
158
|
/** Locale for number and date rendering */
|
|
159
159
|
locale?: string;
|
|
160
160
|
}
|
|
161
|
-
type PartialTableTheme<
|
|
162
|
-
[K in keyof TableTheme<
|
|
161
|
+
type PartialTableTheme<TItem = unknown> = {
|
|
162
|
+
[K in keyof TableTheme<TItem>]?: TableTheme<TItem>[K] extends Record<string, any> ? Partial<TableTheme<TItem>[K]> : TableTheme<TItem>[K];
|
|
163
163
|
};
|
|
164
|
-
type MemoizedTableTheme<
|
|
165
|
-
classes: MemoizedFunctions<TableTheme<
|
|
166
|
-
styles: MemoizedFunctions<TableTheme<
|
|
167
|
-
text: MemoizedFunctions<TableTheme<
|
|
164
|
+
type MemoizedTableTheme<TItem> = Omit<TableTheme, 'classes' | 'styles' | 'text'> & {
|
|
165
|
+
classes: MemoizedFunctions<TableTheme<TItem>['classes']>;
|
|
166
|
+
styles: MemoizedFunctions<TableTheme<TItem>['styles']>;
|
|
167
|
+
text: MemoizedFunctions<TableTheme<TItem>['text']>;
|
|
168
168
|
};
|
|
169
|
-
interface TableProps<
|
|
169
|
+
interface TableProps<TItem> extends PartialTableTheme<TItem> {
|
|
170
170
|
/** The data to be rendered. One item per row. */
|
|
171
|
-
items?: readonly
|
|
171
|
+
items?: readonly TItem[];
|
|
172
172
|
/** Unique id for each item/row. */
|
|
173
|
-
id: FunctionWithDeps<(item:
|
|
173
|
+
id: FunctionWithDeps<(item: TItem) => Id> | KeyOfType<TItem, Id>;
|
|
174
174
|
/** Create a nested structure by assigning parents to items. Child items are hidden until the parent is expanded. */
|
|
175
|
-
parentId?: FunctionWithDeps<(item:
|
|
175
|
+
parentId?: FunctionWithDeps<(item: TItem) => Id | undefined> | KeyOfType<TItem, Id | undefined | null>;
|
|
176
176
|
/** If true for an item, it means that children will be loaded asynchronously as soon as item is expanded. */
|
|
177
|
-
hasDeferredChildren?: (item:
|
|
177
|
+
hasDeferredChildren?: (item: TItem) => boolean;
|
|
178
178
|
/** Column definitions. */
|
|
179
|
-
columns: Column<
|
|
179
|
+
columns: Column<TItem, any>[] | ((col: <TColumnValue>(value: (item: TItem) => TColumnValue, column: Omit<Column<TItem, TColumnValue>, 'value'>) => Column<TItem, TColumnValue>) => Column<TItem, any>[]);
|
|
180
180
|
/** Default props for all column. Will take effect if not overriden in column definition. */
|
|
181
|
-
defaultColumnProps?: Omit<Column<
|
|
181
|
+
defaultColumnProps?: Omit<Column<TItem, unknown>, 'id' | 'value'>;
|
|
182
182
|
/** Set props for multiple columns at once. Will take effect if not overriden in column definition. */
|
|
183
|
-
columnProps?: FunctionWithDeps<(id: Id) => Partial<Omit<Column<
|
|
183
|
+
columnProps?: FunctionWithDeps<(id: Id) => Partial<Omit<Column<TItem, unknown>, 'id'>>>;
|
|
184
184
|
/** Wrap each cell */
|
|
185
|
-
wrapCell?: FunctionWithDeps<(content: ReactNode, value: unknown, item:
|
|
185
|
+
wrapCell?: FunctionWithDeps<(content: ReactNode, value: unknown, item: TItem, index: number) => ReactNode>;
|
|
186
186
|
/** Display a cell at the start of each row. Useful for "go to details" button for example. */
|
|
187
|
-
rowAction?: ReactNode | FunctionWithDeps<(item:
|
|
187
|
+
rowAction?: ReactNode | FunctionWithDeps<(item: TItem, index: number) => ReactNode>;
|
|
188
188
|
/** Expand row to show details. */
|
|
189
|
-
rowDetails?: ReactNode | FunctionWithDeps<(item:
|
|
189
|
+
rowDetails?: ReactNode | FunctionWithDeps<(item: TItem, index: number) => ReactNode>;
|
|
190
190
|
/** Default sort order. */
|
|
191
191
|
defaultSort?: Sort[];
|
|
192
192
|
/** If given, controls the sort order. */
|
|
@@ -287,19 +287,19 @@ interface TableProps<T> extends PartialTableTheme<T> {
|
|
|
287
287
|
debugRender?: (...output: any) => void;
|
|
288
288
|
onReset?: (scope?: 'table' | 'filters') => void;
|
|
289
289
|
}
|
|
290
|
-
type InternalTableProps<
|
|
291
|
-
id: (item:
|
|
292
|
-
parentId?: (item:
|
|
293
|
-
columns: InternalColumn<
|
|
290
|
+
type InternalTableProps<TItem> = MemoizedFunctions<Omit<TableProps<TItem>, 'id' | 'parentId' | 'columns' | 'defaultColumnProps' | 'enableExport'> & {
|
|
291
|
+
id: (item: TItem) => Id;
|
|
292
|
+
parentId?: (item: TItem) => Id | undefined;
|
|
293
|
+
columns: InternalColumn<TItem, unknown>[];
|
|
294
294
|
enableExport: boolean | ExportOptions;
|
|
295
295
|
}>;
|
|
296
|
-
type TableItem<
|
|
296
|
+
type TableItem<TItem = unknown> = {
|
|
297
297
|
id: Id;
|
|
298
298
|
parentId?: Id | null;
|
|
299
|
-
children: TableItem<
|
|
300
|
-
value:
|
|
299
|
+
children: TableItem<TItem>[];
|
|
300
|
+
value: TItem;
|
|
301
301
|
};
|
|
302
|
-
type Column<
|
|
302
|
+
type Column<TItem, TColumnValue> = {
|
|
303
303
|
/** Column id. If not provided, the index in the column array will be used.
|
|
304
304
|
* An explicit id is better however for controlling column related states, persitance etc.
|
|
305
305
|
*/
|
|
@@ -310,13 +310,13 @@ type Column<T, V> = {
|
|
|
310
310
|
/** Render table header for this column. */
|
|
311
311
|
footer?: ReactNode;
|
|
312
312
|
/** Extract value for this column */
|
|
313
|
-
value: FunctionWithDeps<(item:
|
|
313
|
+
value: FunctionWithDeps<(item: TItem) => TColumnValue>;
|
|
314
314
|
/** Render table cell. If not provided, a string representation of the value will be rendered. */
|
|
315
|
-
renderCell?: FunctionWithDeps<(value:
|
|
315
|
+
renderCell?: FunctionWithDeps<(value: TColumnValue, item: TItem) => ReactNode>;
|
|
316
316
|
/** Serialize column value for exports. If not provided, a string representation of the value will be used. */
|
|
317
|
-
exportCell?: (value:
|
|
317
|
+
exportCell?: (value: TColumnValue, item: TItem) => string | number | Date;
|
|
318
318
|
/** Customize sort criteria. By default it will be the value itself in case it's a number or Date, or a string representation of the value otherwise. */
|
|
319
|
-
sortBy?: FunctionWithDeps<(value:
|
|
319
|
+
sortBy?: FunctionWithDeps<(value: TColumnValue, item: TItem) => unknown>[];
|
|
320
320
|
/** Disable sort for this column */
|
|
321
321
|
disableSort?: boolean;
|
|
322
322
|
/** Set filter component that will be displayed in the column header */
|
|
@@ -328,46 +328,46 @@ type Column<T, V> = {
|
|
|
328
328
|
*/
|
|
329
329
|
width?: string;
|
|
330
330
|
/** Provide css class names to override columns styles. */
|
|
331
|
-
classes?: Omit<NonNullable<TableTheme<
|
|
331
|
+
classes?: Omit<NonNullable<TableTheme<TItem>['classes']>, 'table' | 'details'>;
|
|
332
332
|
/** Provide css styles to override columns styles. */
|
|
333
|
-
styles?: Omit<NonNullable<TableTheme<
|
|
333
|
+
styles?: Omit<NonNullable<TableTheme<TItem>['styles']>, 'table' | 'details'>;
|
|
334
334
|
};
|
|
335
|
-
type InternalColumn<
|
|
335
|
+
type InternalColumn<TItem, TColumnValue> = MemoizedFunctions<Required<Omit<Column<TItem, TColumnValue>, 'id' | 'sortBy'>, 'header' | 'exportHeader' | 'renderCell' | 'exportCell' | 'sortBy'> & {
|
|
336
336
|
id: Id;
|
|
337
|
-
sortBy: ((value:
|
|
337
|
+
sortBy: ((value: TColumnValue, item: TItem) => unknown)[];
|
|
338
338
|
}>;
|
|
339
339
|
type Required<T, S> = T & {
|
|
340
340
|
[P in keyof T as P extends S ? P : never]-?: T[P];
|
|
341
341
|
};
|
|
342
|
-
type InternalTableState<
|
|
343
|
-
props: InternalTableProps<
|
|
342
|
+
type InternalTableState<TItem> = {
|
|
343
|
+
props: InternalTableProps<TItem>;
|
|
344
344
|
key: any;
|
|
345
345
|
sort: Sort[];
|
|
346
346
|
selection: Set<Id>;
|
|
347
347
|
expanded: Set<Id>;
|
|
348
348
|
rowHeights: Map<Id, number>;
|
|
349
|
-
filters: Map<Id, MemoizedFunctions<FilterImplementation<
|
|
349
|
+
filters: Map<Id, MemoizedFunctions<FilterImplementation<TItem, any, any, any>>>;
|
|
350
350
|
filterValues: Map<Id, any>;
|
|
351
351
|
hiddenColumns: Set<Id>;
|
|
352
352
|
columnWidths: Map<Id, string>;
|
|
353
353
|
columnOrder: Id[];
|
|
354
354
|
columnStyleOverride: Map<Id, CSSProperties>;
|
|
355
|
-
activeColumns: InternalColumn<
|
|
356
|
-
items: TableItem<
|
|
357
|
-
itemsById: Map<Id, TableItem<
|
|
358
|
-
activeItems: TableItem<
|
|
359
|
-
activeItemsById: Map<Id, TableItem<
|
|
355
|
+
activeColumns: InternalColumn<TItem, unknown>[];
|
|
356
|
+
items: TableItem<TItem>[];
|
|
357
|
+
itemsById: Map<Id, TableItem<TItem>>;
|
|
358
|
+
activeItems: TableItem<TItem>[];
|
|
359
|
+
activeItemsById: Map<Id, TableItem<TItem>>;
|
|
360
360
|
lastSelectedId?: Id;
|
|
361
361
|
};
|
|
362
|
-
type CommonFilterProps<
|
|
362
|
+
type CommonFilterProps<TItem, TColumnValue, TFilterBy, TFilterValue> = {
|
|
363
363
|
/** Filter by? By default the column value will be used. If filterBy returns an array, an items will be active if at least one entry matches the active filter. */
|
|
364
|
-
filterBy?: FunctionWithDeps<(value:
|
|
364
|
+
filterBy?: FunctionWithDeps<(value: TColumnValue, item: TItem) => TFilterBy | TFilterBy[]>;
|
|
365
365
|
/** Preselected filter value. */
|
|
366
|
-
defaultValue?:
|
|
366
|
+
defaultValue?: TFilterValue;
|
|
367
367
|
/** Controlled filter value. */
|
|
368
|
-
value?:
|
|
368
|
+
value?: TFilterValue;
|
|
369
369
|
/** Notifies on filter change. */
|
|
370
|
-
onChange?: (value?:
|
|
370
|
+
onChange?: (value?: TFilterValue) => void;
|
|
371
371
|
/** Table should not filter using this filter. It will be done externally, e.g. server side. */
|
|
372
372
|
external?: boolean;
|
|
373
373
|
/** Whether to persist filter value (given that filter persitance is enabled for the table).
|
|
@@ -379,20 +379,13 @@ type CommonFilterProps<T, V, F, S extends SerializableValue> = {
|
|
|
379
379
|
popoverBackdrop?: string;
|
|
380
380
|
};
|
|
381
381
|
};
|
|
382
|
-
type FilterImplementation<
|
|
382
|
+
type FilterImplementation<TItem, TColumnValue, TFilterBy, TFilterValue> = CommonFilterProps<TItem, TColumnValue, TFilterBy, TFilterValue> & {
|
|
383
383
|
/** Unique filter id. Used to persist filter values. */
|
|
384
384
|
id: string;
|
|
385
385
|
/** Whether the filter is active currently. */
|
|
386
|
-
isActive: (filterValue:
|
|
386
|
+
isActive: (filterValue: TFilterValue) => boolean;
|
|
387
387
|
/** When the filter is active, this function is used to filter the items to be displayed. */
|
|
388
|
-
test: (filterValue:
|
|
388
|
+
test: (filterValue: TFilterValue, value: TFilterBy) => boolean;
|
|
389
389
|
};
|
|
390
|
-
type SerializableValue = string | number | boolean | null | Date | SerializableArray | SerializableObject | SerializableSet | SerializableMap;
|
|
391
|
-
type SerializableObject = {
|
|
392
|
-
[key: string]: SerializableValue;
|
|
393
|
-
};
|
|
394
|
-
type SerializableArray = SerializableValue[];
|
|
395
|
-
type SerializableSet = Set<SerializableValue>;
|
|
396
|
-
type SerializableMap = Map<SerializableValue, SerializableValue>;
|
|
397
390
|
|
|
398
|
-
export type { CommonFilterProps as C, FilterImplementation as F, Id as I, MemoizedTableTheme as M, PartialTableTheme as P,
|
|
391
|
+
export type { CommonFilterProps as C, FilterImplementation as F, Id as I, MemoizedTableTheme as M, PartialTableTheme as P, Sort as S, TableTheme as T, TableProps as a, TableItem as b, InternalTableState as c, TableStateStorage as d, Column as e, FunctionWithDeps as f, InternalColumn as g, SortDirection as h };
|