@tanstack/table-core 8.0.0-alpha.12 → 8.0.0-alpha.16
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/build/cjs/core.js +17 -6
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +17 -9
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +2 -2
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +2 -2
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +1 -1
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +13 -2
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +4 -4
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +1 -3
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/types.js +0 -3
- package/build/cjs/types.js.map +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js +1 -1
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/paginateRowsFn.js.map +1 -1
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/cjs/utils.js +0 -24
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +58 -50
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +268 -282
- package/build/types/core.d.ts +11 -9
- package/build/types/createTable.d.ts +32 -16
- package/build/types/features/ColumnSizing.d.ts +2 -3
- package/build/types/features/Grouping.d.ts +11 -5
- package/build/types/features/RowSelection.d.ts +2 -3
- package/build/types/features/Visibility.d.ts +1 -0
- package/build/types/types.d.ts +14 -7
- package/build/types/utils/columnFilterRowsFn.d.ts +2 -2
- package/build/types/utils/expandRowsFn.d.ts +2 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +2 -2
- package/build/types/utils/groupRowsFn.d.ts +2 -2
- package/build/types/utils/paginateRowsFn.d.ts +2 -2
- package/build/types/utils/sortRowsFn.d.ts +2 -2
- package/build/types/utils.d.ts +4 -5
- package/build/umd/index.development.js +62 -58
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/core.tsx +63 -35
- package/src/createTable.tsx +69 -34
- package/src/features/ColumnSizing.ts +8 -14
- package/src/features/Expanding.ts +2 -2
- package/src/features/Filters.ts +1 -1
- package/src/features/Grouping.ts +30 -7
- package/src/features/Headers.ts +15 -3
- package/src/features/RowSelection.ts +2 -2
- package/src/features/Visibility.ts +1 -0
- package/src/types.ts +28 -15
- package/src/utils/columnFilterRowsFn.ts +3 -5
- package/src/utils/expandRowsFn.ts +2 -2
- package/src/utils/globalFilterRowsFn.ts +2 -2
- package/src/utils/groupRowsFn.ts +4 -4
- package/src/utils/paginateRowsFn.ts +2 -2
- package/src/utils/sortRowsFn.ts +2 -2
- package/src/utils.tsx +6 -45
package/build/types/core.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { RequiredKeys } from './utils';
|
|
2
|
-
import { Updater, PropGetterValue, Options, TableState, ColumnDef, Row, Column, Cell, Header, AccessorFn, TableProps, TableBodyProps, PropGetter, Getter, RowProps, CellProps, TableInstance, RowValues,
|
|
2
|
+
import { Updater, PropGetterValue, Options, TableState, ColumnDef, Row, Column, Cell, Header, AccessorFn, TableProps, TableBodyProps, PropGetter, Getter, RowProps, CellProps, TableInstance, RowValues, Please_use_the_create_table_column_utilities_to_define_columns, PartialGenerics, Renderable, UseRenderer } from './types';
|
|
3
3
|
import { RowModel } from '.';
|
|
4
4
|
export declare type CoreOptions<TGenerics extends PartialGenerics> = {
|
|
5
5
|
data: TGenerics['Row'][];
|
|
6
6
|
columns: ColumnDef<TGenerics>[];
|
|
7
7
|
state: Partial<TableState>;
|
|
8
8
|
onStateChange: (updater: Updater<TableState>) => void;
|
|
9
|
+
render: TGenerics['Render'];
|
|
9
10
|
debugAll?: boolean;
|
|
10
11
|
debugTable?: boolean;
|
|
11
12
|
debugHeaders?: boolean;
|
|
@@ -49,6 +50,7 @@ export declare type TableCore<TGenerics extends PartialGenerics> = {
|
|
|
49
50
|
getLeftTableWidth: () => number;
|
|
50
51
|
getCenterTableWidth: () => number;
|
|
51
52
|
getRightTableWidth: () => number;
|
|
53
|
+
render: <TProps>(template: Renderable<TGenerics, TProps>, props: TProps) => string | null | ReturnType<UseRenderer<TGenerics>>;
|
|
52
54
|
};
|
|
53
55
|
export declare type CoreRow<TGenerics extends PartialGenerics> = {
|
|
54
56
|
id: string;
|
|
@@ -67,28 +69,28 @@ export declare type CoreColumnDef<TGenerics extends PartialGenerics> = {
|
|
|
67
69
|
id: string;
|
|
68
70
|
accessorKey?: string & keyof TGenerics['Row'];
|
|
69
71
|
accessorFn?: AccessorFn<TGenerics['Row']>;
|
|
70
|
-
header?: string | Renderable<{
|
|
71
|
-
instance: TableInstance<TGenerics>;
|
|
72
|
-
header: Header<TGenerics>;
|
|
73
|
-
column: Column<TGenerics>;
|
|
74
|
-
}>;
|
|
75
72
|
width?: number;
|
|
76
73
|
minWidth?: number;
|
|
77
74
|
maxWidth?: number;
|
|
78
75
|
columns?: ColumnDef<TGenerics>[];
|
|
79
|
-
|
|
76
|
+
header?: Renderable<TGenerics, {
|
|
77
|
+
instance: TableInstance<TGenerics>;
|
|
78
|
+
header: Header<TGenerics>;
|
|
79
|
+
column: Column<TGenerics>;
|
|
80
|
+
}>;
|
|
81
|
+
footer?: Renderable<TGenerics, {
|
|
80
82
|
instance: TableInstance<TGenerics>;
|
|
81
83
|
header: Header<TGenerics>;
|
|
82
84
|
column: Column<TGenerics>;
|
|
83
85
|
}>;
|
|
84
|
-
cell?: Renderable<{
|
|
86
|
+
cell?: Renderable<TGenerics, {
|
|
85
87
|
instance: TableInstance<TGenerics>;
|
|
86
88
|
row: Row<TGenerics>;
|
|
87
89
|
column: Column<TGenerics>;
|
|
88
90
|
cell: Cell<TGenerics>;
|
|
89
91
|
value: TGenerics['Value'];
|
|
90
92
|
}>;
|
|
91
|
-
|
|
93
|
+
meta?: TGenerics['ColumnMeta'];
|
|
92
94
|
[Please_use_the_create_table_column_utilities_to_define_columns]: true;
|
|
93
95
|
};
|
|
94
96
|
export declare type CoreColumn<TGenerics extends PartialGenerics> = {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { CustomFilterTypes } from './features/Filters';
|
|
2
2
|
import { CustomAggregationTypes } from './features/Grouping';
|
|
3
3
|
import { CustomSortingTypes } from './features/Sorting';
|
|
4
|
-
import { ColumnDef, AccessorFn,
|
|
4
|
+
import { ColumnDef, AccessorFn, PartialGenerics, _NonGenerated, AnyRender } from './types';
|
|
5
5
|
import { Overwrite, PartialKeys } from './utils';
|
|
6
|
-
export declare type
|
|
7
|
-
Row:
|
|
6
|
+
export declare type CreateTableFactory<TGenerics extends PartialGenerics> = <TSubGenerics extends {
|
|
7
|
+
Row: any;
|
|
8
|
+
ColumnMeta?: object;
|
|
9
|
+
}>() => Table<Overwrite<TGenerics, {
|
|
10
|
+
Row: TSubGenerics['Row'];
|
|
11
|
+
ColumnMeta: TSubGenerics['ColumnMeta'];
|
|
8
12
|
}>>;
|
|
9
|
-
export declare type CreateTableFactoryOptions<TFilterFns extends CustomFilterTypes<any>, TSortingFns extends CustomSortingTypes<any>, TAggregationFns extends CustomAggregationTypes<any>> = {
|
|
13
|
+
export declare type CreateTableFactoryOptions<TRender extends AnyRender, TFilterFns extends CustomFilterTypes<any>, TSortingFns extends CustomSortingTypes<any>, TAggregationFns extends CustomAggregationTypes<any>> = {
|
|
14
|
+
render: TRender;
|
|
10
15
|
filterFns?: TFilterFns;
|
|
11
16
|
sortingFns?: TSortingFns;
|
|
12
17
|
aggregationFns?: TAggregationFns;
|
|
13
18
|
};
|
|
14
|
-
export declare
|
|
15
|
-
|
|
16
|
-
SortingFns: TSortingFns;
|
|
17
|
-
AggregationFns: TAggregationFns;
|
|
18
|
-
}>>;
|
|
19
|
-
export declare type TableFactory<TGenerics extends Partial<DefaultGenerics>> = {
|
|
20
|
-
__options: CreateTableFactoryOptions<any, any, any>;
|
|
19
|
+
export declare type Table<TGenerics extends PartialGenerics> = {
|
|
20
|
+
__options: CreateTableFactoryOptions<any, any, any, any>;
|
|
21
21
|
createColumns: (columns: ColumnDef<TGenerics>[]) => ColumnDef<TGenerics>[];
|
|
22
22
|
createGroup: (column: Overwrite<Overwrite<_NonGenerated<ColumnDef<TGenerics>>, {
|
|
23
23
|
header: string;
|
|
@@ -28,15 +28,31 @@ export declare type TableFactory<TGenerics extends Partial<DefaultGenerics>> = {
|
|
|
28
28
|
}>, {
|
|
29
29
|
accessorFn?: never;
|
|
30
30
|
accessorKey?: never;
|
|
31
|
+
columns?: ColumnDef<any>[];
|
|
31
32
|
}>) => ColumnDef<TGenerics>;
|
|
32
33
|
createDisplayColumn: (column: PartialKeys<_NonGenerated<ColumnDef<TGenerics>>, 'accessorFn' | 'accessorKey'>) => ColumnDef<TGenerics>;
|
|
33
|
-
createDataColumn: <TAccessor extends AccessorFn<TGenerics['Row']> | keyof TGenerics['Row']>(accessor: TAccessor, column: Overwrite<TAccessor extends (...args: any[]) => any ? _NonGenerated<ColumnDef<
|
|
34
|
+
createDataColumn: <TAccessor extends AccessorFn<TGenerics['Row']> | keyof TGenerics['Row']>(accessor: TAccessor, column: Overwrite<TAccessor extends (...args: any[]) => any ? _NonGenerated<ColumnDef<Overwrite<TGenerics, {
|
|
35
|
+
Value: ReturnType<TAccessor>;
|
|
36
|
+
}>>> : TAccessor extends keyof TGenerics['Row'] ? Overwrite<_NonGenerated<ColumnDef<Overwrite<TGenerics, {
|
|
37
|
+
Value: TGenerics['Row'][TAccessor];
|
|
38
|
+
}>>>, {
|
|
34
39
|
id?: string;
|
|
35
40
|
}> : never, {
|
|
36
41
|
accessorFn?: never;
|
|
37
42
|
accessorKey?: never;
|
|
38
|
-
}>) => ColumnDef<TGenerics
|
|
43
|
+
}>) => ColumnDef<Overwrite<TGenerics, {
|
|
44
|
+
Value: TAccessor extends (...args: any[]) => any ? ReturnType<TAccessor> : TAccessor extends keyof TGenerics['Row'] ? TGenerics['Row'][TAccessor] : never;
|
|
45
|
+
}>>;
|
|
39
46
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
declare type InitTable<TRender extends AnyRender> = {
|
|
48
|
+
createTableFactory: <TGenerics extends PartialGenerics>(options?: CreateTableFactoryOptions<TRender, any, any, any>) => CreateTableFactory<Overwrite<TGenerics, {
|
|
49
|
+
Render: TRender;
|
|
50
|
+
}>>;
|
|
51
|
+
createTable: CreateTableFactory<Overwrite<PartialGenerics, {
|
|
52
|
+
Render: TRender;
|
|
53
|
+
}>>;
|
|
54
|
+
};
|
|
55
|
+
export declare function init<TRender extends AnyRender>(opts: {
|
|
56
|
+
render: TRender;
|
|
57
|
+
}): InitTable<TRender>;
|
|
58
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MouseEvent as ReactMouseEvent, TouchEvent as ReactTouchEvent } from 'react';
|
|
2
1
|
import { Column, Getter, Header, OnChangeFn, PartialGenerics, PropGetterValue, TableInstance, Updater } from '../types';
|
|
3
2
|
export declare type ColumnSizing = Record<string, number>;
|
|
4
3
|
export declare type ColumnSizingInfoState = {
|
|
@@ -27,8 +26,8 @@ export declare type ColumnSizingDefaultOptions = {
|
|
|
27
26
|
};
|
|
28
27
|
export declare type ColumnResizerProps = {
|
|
29
28
|
title?: string;
|
|
30
|
-
onMouseDown?: (e:
|
|
31
|
-
onTouchStart?: (e:
|
|
29
|
+
onMouseDown?: (e: MouseEvent) => void;
|
|
30
|
+
onTouchStart?: (e: TouchEvent) => void;
|
|
32
31
|
draggable?: boolean;
|
|
33
32
|
role?: string;
|
|
34
33
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { MouseEvent, TouchEvent } from 'react';
|
|
2
1
|
import { RowModel } from '..';
|
|
3
2
|
import { BuiltInAggregationType } from '../aggregationTypes';
|
|
4
|
-
import { Cell, Column, Getter, OnChangeFn, PropGetterValue, TableInstance, Row, Updater, PartialGenerics } from '../types';
|
|
3
|
+
import { Cell, Column, Getter, OnChangeFn, PropGetterValue, TableInstance, Row, Updater, PartialGenerics, Renderable, UseRenderer } from '../types';
|
|
5
4
|
import { Overwrite } from '../utils';
|
|
6
5
|
export declare type GroupingState = string[];
|
|
7
6
|
export declare type AggregationFn<TGenerics extends PartialGenerics> = (leafValues: TGenerics['Row'][], childValues: TGenerics['Row'][]) => any;
|
|
@@ -15,7 +14,13 @@ export declare type GroupingColumnDef<TGenerics extends PartialGenerics> = {
|
|
|
15
14
|
Value: any;
|
|
16
15
|
}>>;
|
|
17
16
|
aggregateValue?: (columnValue: unknown) => any;
|
|
18
|
-
|
|
17
|
+
aggregatedCell?: Renderable<TGenerics, {
|
|
18
|
+
instance: TableInstance<TGenerics>;
|
|
19
|
+
row: Row<TGenerics>;
|
|
20
|
+
column: Column<TGenerics>;
|
|
21
|
+
cell: Cell<TGenerics>;
|
|
22
|
+
value: TGenerics['Value'];
|
|
23
|
+
}>;
|
|
19
24
|
enableGrouping?: boolean;
|
|
20
25
|
defaultCanGroup?: boolean;
|
|
21
26
|
};
|
|
@@ -34,10 +39,11 @@ export declare type GroupingRow = {
|
|
|
34
39
|
groupingValue?: any;
|
|
35
40
|
getIsGrouped: () => boolean;
|
|
36
41
|
};
|
|
37
|
-
export declare type GroupingCell = {
|
|
42
|
+
export declare type GroupingCell<TGenerics extends PartialGenerics> = {
|
|
38
43
|
getIsGrouped: () => boolean;
|
|
39
44
|
getIsPlaceholder: () => boolean;
|
|
40
45
|
getIsAggregated: () => boolean;
|
|
46
|
+
renderAggregatedCell: () => string | null | ReturnType<UseRenderer<TGenerics>>;
|
|
41
47
|
};
|
|
42
48
|
export declare type ColumnDefaultOptions = {
|
|
43
49
|
onGroupingChange: OnChangeFn<GroupingState>;
|
|
@@ -80,6 +86,6 @@ export declare const Grouping: {
|
|
|
80
86
|
createColumn: <TGenerics_2 extends Partial<import("..").DefaultGenerics>>(column: Column<TGenerics_2>, instance: TableInstance<TGenerics_2>) => GroupingColumn<TGenerics_2>;
|
|
81
87
|
getInstance: <TGenerics_3 extends Partial<import("..").DefaultGenerics>>(instance: TableInstance<TGenerics_3>) => GroupingInstance<TGenerics_3>;
|
|
82
88
|
createRow: <TGenerics_4 extends Partial<import("..").DefaultGenerics>>(row: Row<TGenerics_4>, instance: TableInstance<TGenerics_4>) => GroupingRow;
|
|
83
|
-
createCell: <TGenerics_5 extends Partial<import("..").DefaultGenerics>>(cell: Cell<TGenerics_5
|
|
89
|
+
createCell: <TGenerics_5 extends Partial<import("..").DefaultGenerics>>(cell: Cell<TGenerics_5>, column: Column<TGenerics_5>, row: Row<TGenerics_5>, instance: TableInstance<TGenerics_5>) => GroupingCell<TGenerics_5>;
|
|
84
90
|
orderColumns: <TGenerics_6 extends Partial<import("..").DefaultGenerics>>(leafColumns: Column<TGenerics_6>[], grouping: string[], groupedColumnMode?: GroupingColumnMode | undefined) => Column<TGenerics_6>[];
|
|
85
91
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Getter, OnChangeFn, PartialGenerics, PropGetterValue, TableInstance, Row, RowModel, Updater } from '../types';
|
|
1
|
+
import { Getter, OnChangeFn, PartialGenerics, PropGetterValue, TableInstance, Row, RowModel, Updater, AnyGenerics } from '../types';
|
|
3
2
|
export declare type RowSelectionState = Record<string, boolean>;
|
|
4
3
|
export declare type RowSelectionTableState = {
|
|
5
4
|
rowSelection: RowSelectionState;
|
|
@@ -55,6 +54,6 @@ export declare const RowSelection: {
|
|
|
55
54
|
getInstance: <TGenerics_1 extends Partial<import("../types").DefaultGenerics>>(instance: TableInstance<TGenerics_1>) => RowSelectionInstance<TGenerics_1>;
|
|
56
55
|
createRow: <TGenerics_2 extends Partial<import("../types").DefaultGenerics>>(row: Row<TGenerics_2>, instance: TableInstance<TGenerics_2>) => RowSelectionRow;
|
|
57
56
|
};
|
|
58
|
-
export declare function selectRowsFn<TGenerics extends
|
|
57
|
+
export declare function selectRowsFn<TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>, rowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
|
59
58
|
export declare function isRowSelected<TGenerics extends PartialGenerics>(row: Row<TGenerics>, selection: Record<string, boolean>, instance: TableInstance<TGenerics>): boolean | 'some';
|
|
60
59
|
export {};
|
|
@@ -27,6 +27,7 @@ declare type ToggleAllColumnsVisibilityProps = {};
|
|
|
27
27
|
export declare type VisibilityColumnDef = {
|
|
28
28
|
enableHiding?: boolean;
|
|
29
29
|
defaultCanHide?: boolean;
|
|
30
|
+
defaultIsVisible?: boolean;
|
|
30
31
|
};
|
|
31
32
|
export declare type VisibilityRow<TGenerics extends PartialGenerics> = {
|
|
32
33
|
getVisibleCells: () => Cell<TGenerics>[];
|
package/build/types/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { CoreColumn, CoreColumnDef, CoreOptions, CoreRow, TableCore } from './core';
|
|
3
2
|
import { VisibilityInstance, VisibilityTableState, VisibilityColumn as ColumnVisibilityColumn, VisibilityOptions, VisibilityColumnDef, VisibilityRow } from './features/Visibility';
|
|
4
3
|
import { ColumnOrderInstance, ColumnOrderOptions, ColumnOrderTableState } from './features/Ordering';
|
|
@@ -6,7 +5,7 @@ import { ColumnPinningColumn, ColumnPinningColumnDef, ColumnPinningInstance, Col
|
|
|
6
5
|
import { HeadersInstance, HeadersRow } from './features/Headers';
|
|
7
6
|
import { FiltersColumn, FiltersColumnDef, FiltersInstance, FiltersOptions, FiltersTableState } from './features/Filters';
|
|
8
7
|
import { SortingColumn, SortingColumnDef, SortingInstance, SortingOptions, SortingTableState } from './features/Sorting';
|
|
9
|
-
import { GroupingColumn, GroupingColumnDef, GroupingInstance, GroupingOptions, GroupingRow, GroupingTableState } from './features/Grouping';
|
|
8
|
+
import { GroupingCell, GroupingColumn, GroupingColumnDef, GroupingInstance, GroupingOptions, GroupingRow, GroupingTableState } from './features/Grouping';
|
|
10
9
|
import { ExpandedInstance, ExpandedOptions, ExpandedTableState, ExpandedRow } from './features/Expanding';
|
|
11
10
|
import { Overwrite } from './utils';
|
|
12
11
|
import { ColumnSizingColumn, ColumnSizingColumnDef, ColumnSizingHeader, ColumnSizingInstance, ColumnSizingOptions, ColumnSizingTableState } from './features/ColumnSizing';
|
|
@@ -18,10 +17,16 @@ export declare type DefaultGenerics = {
|
|
|
18
17
|
FilterFns: object;
|
|
19
18
|
SortingFns: object;
|
|
20
19
|
AggregationFns: object;
|
|
20
|
+
Render: unknown;
|
|
21
|
+
ColumnMeta: object;
|
|
21
22
|
};
|
|
23
|
+
export declare type AnyRender = (Comp: any, props: any) => any;
|
|
24
|
+
export declare type UseRenderer<TGenerics extends PartialGenerics> = TGenerics['Render'] extends (...args: any) => any ? TGenerics['Render'] : any;
|
|
22
25
|
export declare type PartialGenerics = Partial<DefaultGenerics>;
|
|
26
|
+
export declare type AnyGenerics = {
|
|
27
|
+
[TKey in keyof PartialGenerics]: any;
|
|
28
|
+
};
|
|
23
29
|
export declare type TableInstance<TGenerics extends PartialGenerics> = TableCore<TGenerics> & VisibilityInstance<TGenerics> & ColumnOrderInstance<TGenerics> & ColumnPinningInstance<TGenerics> & HeadersInstance<TGenerics> & FiltersInstance<TGenerics> & SortingInstance<TGenerics> & GroupingInstance<TGenerics> & ColumnSizingInstance<TGenerics> & ExpandedInstance<TGenerics> & PaginationInstance<TGenerics> & RowSelectionInstance<TGenerics>;
|
|
24
|
-
export declare type Renderable<TProps> = React.ReactNode | React.FunctionComponent<TProps> | React.Component<TProps>;
|
|
25
30
|
export declare type Options<TGenerics extends PartialGenerics> = CoreOptions<TGenerics> & VisibilityOptions & ColumnOrderOptions & ColumnPinningOptions & FiltersOptions<TGenerics> & SortingOptions<TGenerics> & GroupingOptions<TGenerics> & ExpandedOptions<TGenerics> & ColumnSizingOptions & PaginationOptions<TGenerics> & RowSelectionOptions<TGenerics>;
|
|
26
31
|
export declare type Updater<T> = T | ((old: T) => T);
|
|
27
32
|
export declare type OnChangeFn<T> = (updaterOrValue: Updater<T>, value: T) => void;
|
|
@@ -40,9 +45,11 @@ export declare const Please_use_the_create_table_column_utilities_to_define_colu
|
|
|
40
45
|
export declare type _NonGenerated<T> = Overwrite<T, {
|
|
41
46
|
[Please_use_the_create_table_column_utilities_to_define_columns]?: never;
|
|
42
47
|
}>;
|
|
48
|
+
export declare type Renderable<TGenerics extends PartialGenerics, TProps> = string | ((props: TProps) => ReturnType<UseRenderer<TGenerics>>);
|
|
43
49
|
export declare type ColumnDef<TGenerics extends PartialGenerics> = CoreColumnDef<TGenerics> & VisibilityColumnDef & ColumnPinningColumnDef & FiltersColumnDef<TGenerics> & SortingColumnDef<TGenerics> & GroupingColumnDef<TGenerics> & ColumnSizingColumnDef;
|
|
44
50
|
export declare type Column<TGenerics extends PartialGenerics> = ColumnDef<TGenerics> & CoreColumn<TGenerics> & ColumnVisibilityColumn & ColumnPinningColumn & FiltersColumn<TGenerics> & SortingColumn<TGenerics> & GroupingColumn<TGenerics> & ColumnSizingColumn<TGenerics>;
|
|
45
|
-
export declare type Cell<TGenerics extends PartialGenerics> =
|
|
51
|
+
export declare type Cell<TGenerics extends PartialGenerics> = CoreCell<TGenerics> & GroupingCell<TGenerics>;
|
|
52
|
+
export declare type CoreCell<TGenerics extends PartialGenerics> = {
|
|
46
53
|
id: string;
|
|
47
54
|
rowId: string;
|
|
48
55
|
columnId: string;
|
|
@@ -50,7 +57,7 @@ export declare type Cell<TGenerics extends PartialGenerics> = {
|
|
|
50
57
|
row: Row<TGenerics>;
|
|
51
58
|
column: Column<TGenerics>;
|
|
52
59
|
getCellProps: PropGetter<CellProps>;
|
|
53
|
-
renderCell: () =>
|
|
60
|
+
renderCell: () => string | null | ReturnType<UseRenderer<TGenerics>>;
|
|
54
61
|
};
|
|
55
62
|
export declare type Header<TGenerics extends PartialGenerics> = CoreHeader<TGenerics> & ColumnSizingHeader<TGenerics>;
|
|
56
63
|
export declare type CoreHeader<TGenerics extends PartialGenerics> = {
|
|
@@ -68,10 +75,10 @@ export declare type CoreHeader<TGenerics extends PartialGenerics> = {
|
|
|
68
75
|
placeholderId?: string;
|
|
69
76
|
renderHeader: (options?: {
|
|
70
77
|
renderPlaceholder?: boolean;
|
|
71
|
-
}) =>
|
|
78
|
+
}) => string | null | ReturnType<UseRenderer<TGenerics>>;
|
|
72
79
|
renderFooter: (options?: {
|
|
73
80
|
renderPlaceholder?: boolean;
|
|
74
|
-
}) =>
|
|
81
|
+
}) => string | null | ReturnType<UseRenderer<TGenerics>>;
|
|
75
82
|
};
|
|
76
83
|
export declare type HeaderGroup<TGenerics extends PartialGenerics> = {
|
|
77
84
|
id: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function columnFilterRowsFn<TGenerics extends
|
|
1
|
+
import { AnyGenerics, TableInstance, RowModel } from '../types';
|
|
2
|
+
export declare function columnFilterRowsFn<TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>, rowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function expandRowsFn<TGenerics extends
|
|
1
|
+
import { TableInstance, RowModel, AnyGenerics } from '../types';
|
|
2
|
+
export declare function expandRowsFn<TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>, sortedRowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function globalFilterRowsFn<TGenerics extends
|
|
1
|
+
import { TableInstance, RowModel, AnyGenerics } from '../types';
|
|
2
|
+
export declare function globalFilterRowsFn<TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>, rowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function groupRowsFn<TGenerics extends
|
|
1
|
+
import { TableInstance, RowModel, AnyGenerics } from '../types';
|
|
2
|
+
export declare function groupRowsFn<TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>, sortedRowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function paginateRowsFn<TGenerics extends
|
|
1
|
+
import { TableInstance, RowModel, AnyGenerics } from '../types';
|
|
2
|
+
export declare function paginateRowsFn<TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>, rowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function sortRowsFn<TGenerics extends
|
|
1
|
+
import { TableInstance, RowModel, AnyGenerics } from '../types';
|
|
2
|
+
export declare function sortRowsFn<TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>, rowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
package/build/types/utils.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Getter, NoInfer, PropGetterValue, Renderable, TableState, Updater } from './types';
|
|
1
|
+
import { Getter, NoInfer, PropGetterValue, TableState, Updater } from './types';
|
|
3
2
|
export declare type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
4
3
|
export declare type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
5
4
|
export declare type RequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
6
|
-
export declare type Overwrite<T, U
|
|
5
|
+
export declare type Overwrite<T, U extends {
|
|
6
|
+
[TKey in keyof T]?: any;
|
|
7
|
+
}> = Omit<T, keyof U> & U;
|
|
7
8
|
export declare type DataUpdateFunction<T> = (input: T) => T;
|
|
8
9
|
export declare function functionalUpdate<T>(updater: Updater<T>, input: T): T;
|
|
9
10
|
export declare function noop(): void;
|
|
@@ -18,6 +19,4 @@ export declare function memo<TDeps extends readonly any[], TResult>(getDeps: ()
|
|
|
18
19
|
debug?: () => any;
|
|
19
20
|
onChange?: (result: TResult, previousResult?: TResult) => void;
|
|
20
21
|
}): () => TResult;
|
|
21
|
-
export declare type Render = typeof flexRender;
|
|
22
|
-
export declare function flexRender<TProps extends {}>(Comp: Renderable<TProps>, props: TProps): React.ReactNode;
|
|
23
22
|
export {};
|
|
@@ -9,14 +9,10 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports
|
|
13
|
-
typeof define === 'function' && define.amd ? define(['exports'
|
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TableCore = {}
|
|
15
|
-
})(this, (function (exports
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
13
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
14
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TableCore = {}));
|
|
15
|
+
})(this, (function (exports) { 'use strict';
|
|
20
16
|
|
|
21
17
|
function _extends() {
|
|
22
18
|
_extends = Object.assign || function (target) {
|
|
@@ -210,24 +206,6 @@
|
|
|
210
206
|
|
|
211
207
|
return result;
|
|
212
208
|
};
|
|
213
|
-
}
|
|
214
|
-
function flexRender(Comp, props) {
|
|
215
|
-
return !Comp ? null : isReactComponent(Comp) ? /*#__PURE__*/React__default["default"].createElement(Comp, props) : Comp;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function isReactComponent(component) {
|
|
219
|
-
return isClassComponent(component) || typeof component === 'function' || isExoticComponent(component);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function isClassComponent(component) {
|
|
223
|
-
return typeof component === 'function' && function () {
|
|
224
|
-
var proto = Object.getPrototypeOf(component);
|
|
225
|
-
return proto.prototype && proto.prototype.isReactComponent;
|
|
226
|
-
}();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function isExoticComponent(component) {
|
|
230
|
-
return typeof component === 'object' && typeof component.$$typeof === 'symbol' && ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description);
|
|
231
209
|
} // export function hashString(str: string, seed = 0): string {
|
|
232
210
|
// let h1 = 0xdeadbeef ^ seed,
|
|
233
211
|
// h2 = 0x41c6ce57 ^ seed
|
|
@@ -245,9 +223,6 @@
|
|
|
245
223
|
// return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
|
|
246
224
|
// }
|
|
247
225
|
|
|
248
|
-
// declare global {
|
|
249
|
-
// const "development" !== 'production': boolean
|
|
250
|
-
// }
|
|
251
226
|
//
|
|
252
227
|
var Please_use_the_create_table_column_utilities_to_define_columns = Symbol();
|
|
253
228
|
|
|
@@ -645,7 +620,6 @@
|
|
|
645
620
|
var initialProps = {
|
|
646
621
|
title: canGroup ? 'Toggle Grouping' : undefined,
|
|
647
622
|
onClick: canGroup ? function (e) {
|
|
648
|
-
e.persist();
|
|
649
623
|
column.toggleGrouping == null ? void 0 : column.toggleGrouping();
|
|
650
624
|
} : undefined
|
|
651
625
|
};
|
|
@@ -687,7 +661,7 @@
|
|
|
687
661
|
}
|
|
688
662
|
};
|
|
689
663
|
},
|
|
690
|
-
createCell: function createCell(cell, column, row,
|
|
664
|
+
createCell: function createCell(cell, column, row, instance) {
|
|
691
665
|
return {
|
|
692
666
|
getIsGrouped: function getIsGrouped() {
|
|
693
667
|
return column.getIsGrouped() && column.id === row.groupingColumnId;
|
|
@@ -699,6 +673,18 @@
|
|
|
699
673
|
var _row$subRows;
|
|
700
674
|
|
|
701
675
|
return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
|
|
676
|
+
},
|
|
677
|
+
renderAggregatedCell: function renderAggregatedCell() {
|
|
678
|
+
var _column$aggregatedCel;
|
|
679
|
+
|
|
680
|
+
var template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
|
|
681
|
+
return template ? instance.render(template, {
|
|
682
|
+
instance: instance,
|
|
683
|
+
column: column,
|
|
684
|
+
row: row,
|
|
685
|
+
cell: cell,
|
|
686
|
+
value: cell.value
|
|
687
|
+
}) : null;
|
|
702
688
|
}
|
|
703
689
|
};
|
|
704
690
|
},
|
|
@@ -1144,11 +1130,11 @@
|
|
|
1144
1130
|
draggable: false,
|
|
1145
1131
|
role: 'separator',
|
|
1146
1132
|
onMouseDown: function onMouseDown(e) {
|
|
1147
|
-
e.persist();
|
|
1133
|
+
e.persist == null ? void 0 : e.persist();
|
|
1148
1134
|
onResizeStart(e);
|
|
1149
1135
|
},
|
|
1150
1136
|
onTouchStart: function onTouchStart(e) {
|
|
1151
|
-
e.persist();
|
|
1137
|
+
e.persist == null ? void 0 : e.persist();
|
|
1152
1138
|
onResizeStart(e);
|
|
1153
1139
|
}
|
|
1154
1140
|
} : {};
|
|
@@ -1353,18 +1339,18 @@
|
|
|
1353
1339
|
return instance.getFooterProps(header.id, userProps);
|
|
1354
1340
|
},
|
|
1355
1341
|
renderHeader: function renderHeader() {
|
|
1356
|
-
return
|
|
1342
|
+
return column.header ? instance.render(column.header, {
|
|
1357
1343
|
instance: instance,
|
|
1358
1344
|
header: header,
|
|
1359
1345
|
column: column
|
|
1360
|
-
});
|
|
1346
|
+
}) : null;
|
|
1361
1347
|
},
|
|
1362
1348
|
renderFooter: function renderFooter() {
|
|
1363
|
-
return
|
|
1349
|
+
return column.footer ? instance.render(column.footer, {
|
|
1364
1350
|
instance: instance,
|
|
1365
1351
|
header: header,
|
|
1366
1352
|
column: column
|
|
1367
|
-
});
|
|
1353
|
+
}) : null;
|
|
1368
1354
|
}
|
|
1369
1355
|
}; // Yes, we have to convert instance to unknown, because we know more than the compiler here.
|
|
1370
1356
|
|
|
@@ -2234,7 +2220,7 @@
|
|
|
2234
2220
|
|
|
2235
2221
|
if (!column) {
|
|
2236
2222
|
{
|
|
2237
|
-
console.warn("
|
|
2223
|
+
console.warn("Table: Could not find a column with id: " + columnId);
|
|
2238
2224
|
}
|
|
2239
2225
|
|
|
2240
2226
|
throw new Error();
|
|
@@ -2875,7 +2861,7 @@
|
|
|
2875
2861
|
|
|
2876
2862
|
if (!row) {
|
|
2877
2863
|
{
|
|
2878
|
-
console.warn("[
|
|
2864
|
+
console.warn("[Table] getIsRowExpanded: no row found with id " + rowId);
|
|
2879
2865
|
}
|
|
2880
2866
|
|
|
2881
2867
|
throw new Error();
|
|
@@ -2891,7 +2877,7 @@
|
|
|
2891
2877
|
|
|
2892
2878
|
if (!row) {
|
|
2893
2879
|
{
|
|
2894
|
-
console.warn("[
|
|
2880
|
+
console.warn("[Table] getRowCanExpand: no row found with id " + rowId);
|
|
2895
2881
|
}
|
|
2896
2882
|
|
|
2897
2883
|
throw new Error();
|
|
@@ -3685,7 +3671,7 @@
|
|
|
3685
3671
|
var _options$initialState;
|
|
3686
3672
|
|
|
3687
3673
|
if (options.debugAll || options.debugTable) {
|
|
3688
|
-
console.info('Creating
|
|
3674
|
+
console.info('Creating Table Instance...');
|
|
3689
3675
|
}
|
|
3690
3676
|
|
|
3691
3677
|
var instance = {};
|
|
@@ -3713,6 +3699,17 @@
|
|
|
3713
3699
|
setOptions: function setOptions(updater) {
|
|
3714
3700
|
instance.options = buildOptions(functionalUpdate(updater, instance.options));
|
|
3715
3701
|
},
|
|
3702
|
+
render: function render(template, props) {
|
|
3703
|
+
if (typeof instance.options.render === 'function') {
|
|
3704
|
+
return instance.options.render(template, props);
|
|
3705
|
+
}
|
|
3706
|
+
|
|
3707
|
+
if (typeof template === 'function') {
|
|
3708
|
+
return template(props);
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
return template;
|
|
3712
|
+
},
|
|
3716
3713
|
getRowId: function getRowId(_, index, parent) {
|
|
3717
3714
|
return "" + (parent ? [parent.id, index].join('.') : index);
|
|
3718
3715
|
},
|
|
@@ -3903,7 +3900,7 @@
|
|
|
3903
3900
|
|
|
3904
3901
|
if (!column) {
|
|
3905
3902
|
{
|
|
3906
|
-
console.warn("[
|
|
3903
|
+
console.warn("[Table] Column with id " + columnId + " does not exist.");
|
|
3907
3904
|
}
|
|
3908
3905
|
|
|
3909
3906
|
throw new Error();
|
|
@@ -3935,13 +3932,13 @@
|
|
|
3935
3932
|
return instance.getCellProps(row.id, column.id, userProps);
|
|
3936
3933
|
},
|
|
3937
3934
|
renderCell: function renderCell() {
|
|
3938
|
-
return
|
|
3935
|
+
return column.cell ? instance.render(column.cell, {
|
|
3939
3936
|
instance: instance,
|
|
3940
3937
|
column: column,
|
|
3941
3938
|
row: row,
|
|
3942
3939
|
cell: cell,
|
|
3943
3940
|
value: value
|
|
3944
|
-
});
|
|
3941
|
+
}) : null;
|
|
3945
3942
|
}
|
|
3946
3943
|
};
|
|
3947
3944
|
features.forEach(function (feature) {
|
|
@@ -4105,7 +4102,7 @@
|
|
|
4105
4102
|
|
|
4106
4103
|
if (!row) {
|
|
4107
4104
|
{
|
|
4108
|
-
throw new Error("[
|
|
4105
|
+
throw new Error("[Table] could not find row with id " + rowId);
|
|
4109
4106
|
}
|
|
4110
4107
|
}
|
|
4111
4108
|
|
|
@@ -4113,7 +4110,7 @@
|
|
|
4113
4110
|
|
|
4114
4111
|
if (!cell) {
|
|
4115
4112
|
{
|
|
4116
|
-
throw new Error("[
|
|
4113
|
+
throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
|
|
4117
4114
|
}
|
|
4118
4115
|
}
|
|
4119
4116
|
|
|
@@ -4187,18 +4184,27 @@
|
|
|
4187
4184
|
return instance;
|
|
4188
4185
|
}
|
|
4189
4186
|
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4187
|
+
//
|
|
4188
|
+
function init(opts) {
|
|
4189
|
+
return {
|
|
4190
|
+
createTableFactory: function createTableFactory(options) {
|
|
4191
|
+
return function () {
|
|
4192
|
+
return _createTable(undefined, undefined, _extends({}, options, opts));
|
|
4193
|
+
};
|
|
4194
|
+
},
|
|
4195
|
+
createTable: function createTable() {
|
|
4196
|
+
return _createTable(undefined, undefined, opts);
|
|
4197
|
+
}
|
|
4193
4198
|
};
|
|
4194
4199
|
}
|
|
4195
|
-
function createTable() {
|
|
4196
|
-
return _createTable();
|
|
4197
|
-
}
|
|
4198
4200
|
|
|
4199
4201
|
function _createTable(_, __, __options) {
|
|
4200
4202
|
return {
|
|
4201
|
-
__options: __options
|
|
4203
|
+
__options: __options != null ? __options : {
|
|
4204
|
+
render: function render() {
|
|
4205
|
+
throw new Error();
|
|
4206
|
+
}
|
|
4207
|
+
},
|
|
4202
4208
|
createColumns: function createColumns(columns) {
|
|
4203
4209
|
return columns;
|
|
4204
4210
|
},
|
|
@@ -4248,7 +4254,7 @@
|
|
|
4248
4254
|
|
|
4249
4255
|
if (!column) {
|
|
4250
4256
|
{
|
|
4251
|
-
console.warn("
|
|
4257
|
+
console.warn("Table: Could not find a column with id: " + columnId);
|
|
4252
4258
|
}
|
|
4253
4259
|
|
|
4254
4260
|
throw new Error();
|
|
@@ -4551,7 +4557,7 @@
|
|
|
4551
4557
|
console.info({
|
|
4552
4558
|
column: column
|
|
4553
4559
|
});
|
|
4554
|
-
throw new Error("
|
|
4560
|
+
throw new Error("Table: Invalid column.aggregateType option for column listed above" );
|
|
4555
4561
|
} else {
|
|
4556
4562
|
values[column.id] = null;
|
|
4557
4563
|
}
|
|
@@ -4710,17 +4716,15 @@
|
|
|
4710
4716
|
exports.Visibility = Visibility;
|
|
4711
4717
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
4712
4718
|
exports.columnFilterRowsFn = columnFilterRowsFn;
|
|
4713
|
-
exports.createTable = createTable;
|
|
4714
|
-
exports.createTableFactory = createTableFactory;
|
|
4715
4719
|
exports.createTableInstance = createTableInstance;
|
|
4716
4720
|
exports.defaultColumnSizing = defaultColumnSizing;
|
|
4717
4721
|
exports.expandRowsFn = expandRowsFn;
|
|
4718
4722
|
exports.flattenBy = flattenBy;
|
|
4719
|
-
exports.flexRender = flexRender;
|
|
4720
4723
|
exports.functionalUpdate = functionalUpdate;
|
|
4721
4724
|
exports.getDefaultColumn = getDefaultColumn;
|
|
4722
4725
|
exports.globalFilterRowsFn = globalFilterRowsFn;
|
|
4723
4726
|
exports.groupRowsFn = groupRowsFn;
|
|
4727
|
+
exports.init = init;
|
|
4724
4728
|
exports.isFunction = isFunction;
|
|
4725
4729
|
exports.isRowSelected = isRowSelected;
|
|
4726
4730
|
exports.makeStateUpdater = makeStateUpdater;
|