@tanstack/table-core 8.0.0-alpha.44 → 8.0.0-alpha.45
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/{aggregationTypes.js → aggregationFns.js} +3 -3
- package/build/cjs/aggregationFns.js.map +1 -0
- package/build/cjs/core.js +2 -2
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +25 -18
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/Filters.js +13 -13
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +8 -8
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Sorting.js +10 -10
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/{filterTypes.js → filterFns.js} +3 -3
- package/build/cjs/filterFns.js.map +1 -0
- package/build/cjs/index.js +1 -1
- package/build/cjs/{sortTypes.js → sortingFns.js} +3 -3
- package/build/cjs/sortingFns.js.map +1 -0
- package/build/cjs/utils/getColumnFilteredRowModelSync.js +1 -1
- package/build/cjs/utils/getColumnFilteredRowModelSync.js.map +1 -1
- package/build/cjs/utils/getGroupedRowModel.js +1 -1
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils.js +7 -0
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +64 -50
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +312 -312
- package/build/types/{aggregationTypes.d.ts → aggregationFns.d.ts} +2 -2
- package/build/types/createTable.d.ts +28 -25
- package/build/types/features/Filters.d.ts +5 -5
- package/build/types/features/Grouping.d.ts +4 -4
- package/build/types/features/Sorting.d.ts +4 -4
- package/build/types/{filterTypes.d.ts → filterFns.d.ts} +2 -2
- package/build/types/{sortTypes.d.ts → sortingFns.d.ts} +2 -2
- package/build/types/utils.d.ts +1 -0
- package/build/umd/index.development.js +64 -50
- 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/{aggregationTypes.ts → aggregationFns.ts} +2 -2
- package/src/core.ts +1 -2
- package/src/createTable.ts +73 -52
- package/src/features/Filters.ts +22 -22
- package/src/features/Grouping.ts +16 -16
- package/src/features/Sorting.ts +17 -17
- package/src/{filterTypes.ts → filterFns.ts} +2 -2
- package/src/{sortTypes.ts → sortingFns.ts} +2 -2
- package/src/utils/getColumnFilteredRowModelAsync.ts +1 -1
- package/src/utils/getColumnFilteredRowModelSync.ts +1 -1
- package/src/utils/getGroupedRowModel.ts +1 -1
- package/src/utils.ts +12 -1
- package/build/cjs/aggregationTypes.js.map +0 -1
- package/build/cjs/filterTypes.js.map +0 -1
- package/build/cjs/sortTypes.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const aggregationFns: {
|
|
2
2
|
sum: typeof sum;
|
|
3
3
|
min: typeof min;
|
|
4
4
|
max: typeof max;
|
|
@@ -9,7 +9,7 @@ export declare const aggregationTypes: {
|
|
|
9
9
|
uniqueCount: typeof uniqueCount;
|
|
10
10
|
count: typeof count;
|
|
11
11
|
};
|
|
12
|
-
export declare type BuiltInAggregationType = keyof typeof
|
|
12
|
+
export declare type BuiltInAggregationType = keyof typeof aggregationFns;
|
|
13
13
|
declare function sum(_getLeafValues: () => unknown[], getChildValues: () => unknown[]): number;
|
|
14
14
|
declare function min(_getLeafValues: () => unknown[], getChildValues: () => unknown[]): number | undefined;
|
|
15
15
|
declare function max(_getLeafValues: () => unknown[], getChildValues: () => unknown[]): number | undefined;
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import { CustomFilterTypes } from './features/Filters';
|
|
2
|
-
import { CustomAggregationTypes } from './features/Grouping';
|
|
3
|
-
import { CustomSortingTypes } from './features/Sorting';
|
|
4
|
-
import { ColumnDef, AccessorFn,
|
|
5
|
-
import { Overwrite, PartialKeys } from './utils';
|
|
6
|
-
export declare type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
TableMeta?: object;
|
|
10
|
-
}>() => Table<Overwrite<TGenerics, TSubGenerics>>;
|
|
11
|
-
export declare type CreateTableFactoryOptions<TRender extends AnyRender, TFilterFns extends CustomFilterTypes<any>, TSortingFns extends CustomSortingTypes<any>, TAggregationFns extends CustomAggregationTypes<any>> = {
|
|
12
|
-
render: TRender;
|
|
1
|
+
import { CustomFilterTypes, FilterFn } from './features/Filters';
|
|
2
|
+
import { AggregationFn, CustomAggregationTypes } from './features/Grouping';
|
|
3
|
+
import { CustomSortingTypes, SortingFn } from './features/Sorting';
|
|
4
|
+
import { ColumnDef, AccessorFn, AnyRender, AnyGenerics, Options } from './types';
|
|
5
|
+
import { IfDefined, Overwrite, PartialKeys } from './utils';
|
|
6
|
+
export declare type TableFactory<TGenerics extends AnyGenerics> = () => Table<TGenerics>;
|
|
7
|
+
export declare type CreateTableOptions<TRender extends AnyRender, TFilterFns extends CustomFilterTypes<any>, TSortingFns extends CustomSortingTypes<any>, TAggregationFns extends CustomAggregationTypes<any>, TGenerics extends AnyGenerics> = Partial<{
|
|
8
|
+
render?: TRender;
|
|
13
9
|
filterFns?: TFilterFns;
|
|
14
10
|
sortingFns?: TSortingFns;
|
|
15
11
|
aggregationFns?: TAggregationFns;
|
|
16
|
-
}
|
|
12
|
+
} & Omit<Options<TGenerics>, 'filterFns' | 'sortingFns' | 'aggregationFns'>>;
|
|
17
13
|
export declare type Table<TGenerics extends AnyGenerics> = {
|
|
18
14
|
generics: TGenerics;
|
|
19
|
-
|
|
15
|
+
options: Partial<Options<TGenerics>>;
|
|
16
|
+
setRowType: <TRow extends object>() => Table<Overwrite<TGenerics, {
|
|
17
|
+
Row: TRow;
|
|
18
|
+
}>>;
|
|
19
|
+
setTableMetaType: <TTableMeta extends object>() => Table<Overwrite<TGenerics, {
|
|
20
|
+
TableMeta: TTableMeta;
|
|
21
|
+
}>>;
|
|
22
|
+
setColumnMetaType: <TColumnMeta extends object>() => Table<Overwrite<TGenerics, {
|
|
23
|
+
ColumnMeta: TColumnMeta;
|
|
24
|
+
}>>;
|
|
25
|
+
setOptions: <TFilterFns extends Record<string, FilterFn<any>>, TSortingFns extends Record<string, SortingFn<any>>, TAggregationFns extends Record<string, AggregationFn<any>>>(options: CreateTableOptions<any, TFilterFns, TSortingFns, TAggregationFns, TGenerics>) => Table<Overwrite<TGenerics, {
|
|
26
|
+
FilterFns: IfDefined<TFilterFns, TGenerics['FilterFns']>;
|
|
27
|
+
SortingFns: IfDefined<TSortingFns, TGenerics['SortingFns']>;
|
|
28
|
+
AggregationFns: IfDefined<TAggregationFns, TGenerics['AggregationFns']>;
|
|
29
|
+
}>>;
|
|
20
30
|
createColumns: <TColumnDef extends ColumnDef<any>>(columns: TColumnDef[]) => TColumnDef[];
|
|
21
31
|
createGroup: (column: Overwrite<Overwrite<ColumnDef<any>, {
|
|
22
32
|
header: string;
|
|
@@ -44,15 +54,8 @@ export declare type Table<TGenerics extends AnyGenerics> = {
|
|
|
44
54
|
columns?: ColumnDef<any>[];
|
|
45
55
|
}>) => ColumnDef<TGenerics>;
|
|
46
56
|
};
|
|
47
|
-
declare
|
|
48
|
-
createTableFactory: <TGenerics extends AnyGenerics>(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: {
|
|
57
|
+
export declare function createTableFactory<TRender extends AnyRender>(opts: {
|
|
56
58
|
render: TRender;
|
|
57
|
-
}):
|
|
58
|
-
|
|
59
|
+
}): () => Table<{
|
|
60
|
+
Render: TRender;
|
|
61
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RowModel } from '..';
|
|
2
|
-
import { BuiltInFilterType } from '../
|
|
2
|
+
import { BuiltInFilterType } from '../filterFns';
|
|
3
3
|
import { Column, OnChangeFn, AnyGenerics, TableInstance, Row, Updater } from '../types';
|
|
4
4
|
import { Overwrite } from '../utils';
|
|
5
5
|
export declare type ColumnFilter = {
|
|
@@ -19,9 +19,9 @@ export declare type FiltersTableState = {
|
|
|
19
19
|
columnFiltersProgress: number;
|
|
20
20
|
globalFilterProgress: number;
|
|
21
21
|
};
|
|
22
|
-
export declare type FilterType<TGenerics extends AnyGenerics> = 'auto' | BuiltInFilterType | TGenerics['FilterFns'] | FilterFn<TGenerics>;
|
|
22
|
+
export declare type FilterType<TGenerics extends AnyGenerics> = 'auto' | BuiltInFilterType | keyof TGenerics['FilterFns'] | FilterFn<TGenerics>;
|
|
23
23
|
export declare type FiltersColumnDef<TGenerics extends AnyGenerics> = {
|
|
24
|
-
|
|
24
|
+
filterFn?: FilterType<Overwrite<TGenerics, {
|
|
25
25
|
Value: any;
|
|
26
26
|
}>>;
|
|
27
27
|
enableAllFilters?: boolean;
|
|
@@ -32,7 +32,7 @@ export declare type FiltersColumnDef<TGenerics extends AnyGenerics> = {
|
|
|
32
32
|
defaultCanGlobalFilter?: boolean;
|
|
33
33
|
};
|
|
34
34
|
export declare type FiltersColumn<TGenerics extends AnyGenerics> = {
|
|
35
|
-
|
|
35
|
+
filterFn: FilterType<Overwrite<TGenerics, {
|
|
36
36
|
Value: any;
|
|
37
37
|
}>>;
|
|
38
38
|
getCanColumnFilter: () => boolean;
|
|
@@ -47,7 +47,7 @@ export declare type FiltersColumn<TGenerics extends AnyGenerics> = {
|
|
|
47
47
|
};
|
|
48
48
|
export declare type FiltersOptions<TGenerics extends AnyGenerics> = {
|
|
49
49
|
filterFromLeafRows?: boolean;
|
|
50
|
-
|
|
50
|
+
filterFns?: TGenerics['FilterFns'];
|
|
51
51
|
enableFilters?: boolean;
|
|
52
52
|
onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>;
|
|
53
53
|
autoResetColumnFilters?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RowModel } from '..';
|
|
2
|
-
import { BuiltInAggregationType } from '../
|
|
2
|
+
import { BuiltInAggregationType } from '../aggregationFns';
|
|
3
3
|
import { Cell, Column, Getter, OnChangeFn, PropGetterValue, TableInstance, Row, Updater, Renderable, UseRenderer, AnyGenerics } from '../types';
|
|
4
4
|
import { Overwrite } from '../utils';
|
|
5
5
|
export declare type GroupingState = string[];
|
|
@@ -10,7 +10,7 @@ export declare type GroupingTableState = {
|
|
|
10
10
|
grouping: GroupingState;
|
|
11
11
|
};
|
|
12
12
|
export declare type GroupingColumnDef<TGenerics extends AnyGenerics> = {
|
|
13
|
-
|
|
13
|
+
aggregationFn?: AggregationType<Overwrite<TGenerics, {
|
|
14
14
|
Value: any;
|
|
15
15
|
}>>;
|
|
16
16
|
aggregateValue?: (columnValue: unknown) => any;
|
|
@@ -25,7 +25,7 @@ export declare type GroupingColumnDef<TGenerics extends AnyGenerics> = {
|
|
|
25
25
|
defaultCanGroup?: boolean;
|
|
26
26
|
};
|
|
27
27
|
export declare type GroupingColumn<TGenerics extends AnyGenerics> = {
|
|
28
|
-
|
|
28
|
+
aggregationFn?: AggregationType<Overwrite<TGenerics, {
|
|
29
29
|
Value: any;
|
|
30
30
|
}>>;
|
|
31
31
|
getCanGroup: () => boolean;
|
|
@@ -51,7 +51,7 @@ export declare type ColumnDefaultOptions = {
|
|
|
51
51
|
enableGrouping: boolean;
|
|
52
52
|
};
|
|
53
53
|
export declare type GroupingOptions<TGenerics extends AnyGenerics> = {
|
|
54
|
-
|
|
54
|
+
aggregationFns?: TGenerics['AggregationFns'];
|
|
55
55
|
onGroupingChange?: OnChangeFn<GroupingState>;
|
|
56
56
|
autoResetGrouping?: boolean;
|
|
57
57
|
enableGrouping?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RowModel } from '..';
|
|
2
|
-
import { BuiltInSortType } from '../
|
|
2
|
+
import { BuiltInSortType } from '../sortingFns';
|
|
3
3
|
import { Column, Getter, OnChangeFn, AnyGenerics, PropGetterValue, TableInstance, Row, Updater } from '../types';
|
|
4
4
|
import { Overwrite } from '../utils';
|
|
5
5
|
export declare type SortDirection = 'asc' | 'desc';
|
|
@@ -17,7 +17,7 @@ export declare type SortingTableState = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare type SortType<TGenerics extends AnyGenerics> = 'auto' | BuiltInSortType | keyof TGenerics['SortingFns'] | SortingFn<TGenerics>;
|
|
19
19
|
export declare type SortingColumnDef<TGenerics extends AnyGenerics> = {
|
|
20
|
-
|
|
20
|
+
sortingFn?: SortType<Overwrite<TGenerics, {
|
|
21
21
|
Value: any;
|
|
22
22
|
}>>;
|
|
23
23
|
sortDescFirst?: boolean;
|
|
@@ -28,7 +28,7 @@ export declare type SortingColumnDef<TGenerics extends AnyGenerics> = {
|
|
|
28
28
|
sortUndefined?: false | -1 | 1;
|
|
29
29
|
};
|
|
30
30
|
export declare type SortingColumn<TGenerics extends AnyGenerics> = {
|
|
31
|
-
|
|
31
|
+
sortingFn: SortType<Overwrite<TGenerics, {
|
|
32
32
|
Value: any;
|
|
33
33
|
}>>;
|
|
34
34
|
getCanSort: () => boolean;
|
|
@@ -40,7 +40,7 @@ export declare type SortingColumn<TGenerics extends AnyGenerics> = {
|
|
|
40
40
|
getToggleSortingProps: <TGetter extends Getter<ToggleSortingProps>>(userProps?: TGetter) => undefined | PropGetterValue<ToggleSortingProps, TGetter>;
|
|
41
41
|
};
|
|
42
42
|
export declare type SortingOptions<TGenerics extends AnyGenerics> = {
|
|
43
|
-
|
|
43
|
+
sortingFns?: TGenerics['SortingFns'];
|
|
44
44
|
onSortingChange?: OnChangeFn<SortingState>;
|
|
45
45
|
autoResetSorting?: boolean;
|
|
46
46
|
enableSorting?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyGenerics, Row } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const filterFns: {
|
|
3
3
|
includesString: typeof includesString;
|
|
4
4
|
includesStringSensitive: typeof includesStringSensitive;
|
|
5
5
|
equalsString: typeof equalsString;
|
|
@@ -10,7 +10,7 @@ export declare const filterTypes: {
|
|
|
10
10
|
weakEquals: typeof weakEquals;
|
|
11
11
|
betweenNumberRange: typeof betweenNumberRange;
|
|
12
12
|
};
|
|
13
|
-
export declare type BuiltInFilterType = keyof typeof
|
|
13
|
+
export declare type BuiltInFilterType = keyof typeof filterFns;
|
|
14
14
|
declare function includesString<TGenerics extends AnyGenerics>(rows: Row<TGenerics>[], columnIds: string[], filterValue: unknown): Row<TGenerics>[];
|
|
15
15
|
declare namespace includesString {
|
|
16
16
|
var autoRemove: (val: any) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyGenerics, Row } from './types';
|
|
2
2
|
export declare const reSplitAlphaNumeric: RegExp;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const sortingFns: {
|
|
4
4
|
alphanumeric: typeof alphanumeric;
|
|
5
5
|
alphanumericCaseSensitive: typeof alphanumericCaseSensitive;
|
|
6
6
|
text: typeof text;
|
|
@@ -8,7 +8,7 @@ export declare const sortTypes: {
|
|
|
8
8
|
datetime: typeof datetime;
|
|
9
9
|
basic: typeof basic;
|
|
10
10
|
};
|
|
11
|
-
export declare type BuiltInSortType = keyof typeof
|
|
11
|
+
export declare type BuiltInSortType = keyof typeof sortingFns;
|
|
12
12
|
declare function alphanumeric<TGenerics extends AnyGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
13
13
|
declare function alphanumericCaseSensitive<TGenerics extends AnyGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
14
14
|
declare function text<TGenerics extends AnyGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 0 | 1 | -1;
|
package/build/types/utils.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare type RequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<P
|
|
|
5
5
|
export declare type Overwrite<T, U extends {
|
|
6
6
|
[TKey in keyof T]?: any;
|
|
7
7
|
}> = Omit<T, keyof U> & U;
|
|
8
|
+
export declare type IfDefined<T, N> = 0 extends 1 & T ? N : T extends {} ? T : N;
|
|
8
9
|
export declare type DataUpdateFunction<T> = (input: T) => T;
|
|
9
10
|
export declare function functionalUpdate<T>(updater: Updater<T>, input: T): T;
|
|
10
11
|
export declare function noop(): void;
|
|
@@ -104,6 +104,13 @@
|
|
|
104
104
|
return typeof key === "symbol" ? key : String(key);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
// export type DefinedGenericKeys<T extends AnyGenerics> = {
|
|
108
|
+
// [K in keyof T]: 0 extends 1 & T[K] ? never : T[K] extends {} ? K : never
|
|
109
|
+
// }[keyof T]
|
|
110
|
+
// export type DefinedGenerics<T extends AnyGenerics> = Pick<
|
|
111
|
+
// T,
|
|
112
|
+
// DefinedGenericKeys<T>
|
|
113
|
+
// >
|
|
107
114
|
function functionalUpdate(updater, input) {
|
|
108
115
|
return typeof updater === 'function' ? updater(input) : updater;
|
|
109
116
|
}
|
|
@@ -881,7 +888,7 @@
|
|
|
881
888
|
}
|
|
882
889
|
};
|
|
883
890
|
|
|
884
|
-
var
|
|
891
|
+
var filterFns = {
|
|
885
892
|
includesString: includesString,
|
|
886
893
|
includesStringSensitive: includesStringSensitive,
|
|
887
894
|
equalsString: equalsString,
|
|
@@ -1041,7 +1048,7 @@
|
|
|
1041
1048
|
var Filters = {
|
|
1042
1049
|
getDefaultColumn: function getDefaultColumn() {
|
|
1043
1050
|
return {
|
|
1044
|
-
|
|
1051
|
+
filterFn: 'auto'
|
|
1045
1052
|
};
|
|
1046
1053
|
},
|
|
1047
1054
|
getInitialState: function getInitialState() {
|
|
@@ -1114,7 +1121,7 @@
|
|
|
1114
1121
|
}
|
|
1115
1122
|
});
|
|
1116
1123
|
return {
|
|
1117
|
-
|
|
1124
|
+
filterFn: column.filterFn,
|
|
1118
1125
|
getCanColumnFilter: function getCanColumnFilter() {
|
|
1119
1126
|
return instance.getColumnCanColumnFilter(column.id);
|
|
1120
1127
|
},
|
|
@@ -1172,45 +1179,45 @@
|
|
|
1172
1179
|
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
1173
1180
|
|
|
1174
1181
|
if (typeof value === 'string') {
|
|
1175
|
-
return
|
|
1182
|
+
return filterFns.includesString;
|
|
1176
1183
|
}
|
|
1177
1184
|
|
|
1178
1185
|
if (typeof value === 'number') {
|
|
1179
|
-
return
|
|
1186
|
+
return filterFns.betweenNumberRange;
|
|
1180
1187
|
}
|
|
1181
1188
|
|
|
1182
1189
|
if (value !== null && typeof value === 'object') {
|
|
1183
|
-
return
|
|
1190
|
+
return filterFns.equals;
|
|
1184
1191
|
}
|
|
1185
1192
|
|
|
1186
1193
|
if (Array.isArray(value)) {
|
|
1187
|
-
return
|
|
1194
|
+
return filterFns.arrIncludes;
|
|
1188
1195
|
}
|
|
1189
1196
|
|
|
1190
|
-
return
|
|
1197
|
+
return filterFns.weakEquals;
|
|
1191
1198
|
},
|
|
1192
1199
|
getGlobalAutoFilterFn: function getGlobalAutoFilterFn() {
|
|
1193
|
-
return
|
|
1200
|
+
return filterFns.includesString;
|
|
1194
1201
|
},
|
|
1195
1202
|
getColumnFilterFn: function getColumnFilterFn(columnId) {
|
|
1196
1203
|
var _ref;
|
|
1197
1204
|
|
|
1198
1205
|
var column = instance.getColumn(columnId);
|
|
1199
|
-
var userFilterTypes = instance.options.
|
|
1206
|
+
var userFilterTypes = instance.options.filterFns;
|
|
1200
1207
|
|
|
1201
1208
|
if (!column) {
|
|
1202
1209
|
throw new Error();
|
|
1203
1210
|
}
|
|
1204
1211
|
|
|
1205
|
-
return isFunction(column.
|
|
1212
|
+
return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? instance.getColumnAutoFilterFn(columnId) : (_ref = userFilterTypes == null ? void 0 : userFilterTypes[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
|
|
1206
1213
|
},
|
|
1207
1214
|
getGlobalFilterFn: function getGlobalFilterFn() {
|
|
1208
1215
|
var _ref2;
|
|
1209
1216
|
|
|
1210
1217
|
var _instance$options = instance.options,
|
|
1211
|
-
userFilterTypes = _instance$options.
|
|
1218
|
+
userFilterTypes = _instance$options.filterFns,
|
|
1212
1219
|
globalFilterType = _instance$options.globalFilterType;
|
|
1213
|
-
return isFunction(globalFilterType) ? globalFilterType : globalFilterType === 'auto' ? instance.getGlobalAutoFilterFn() : (_ref2 = userFilterTypes == null ? void 0 : userFilterTypes[globalFilterType]) != null ? _ref2 :
|
|
1220
|
+
return isFunction(globalFilterType) ? globalFilterType : globalFilterType === 'auto' ? instance.getGlobalAutoFilterFn() : (_ref2 = userFilterTypes == null ? void 0 : userFilterTypes[globalFilterType]) != null ? _ref2 : filterFns[globalFilterType];
|
|
1214
1221
|
},
|
|
1215
1222
|
setColumnFilters: function setColumnFilters(updater) {
|
|
1216
1223
|
var leafColumns = instance.getAllLeafColumns();
|
|
@@ -1376,7 +1383,7 @@
|
|
|
1376
1383
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1377
1384
|
}
|
|
1378
1385
|
|
|
1379
|
-
var
|
|
1386
|
+
var aggregationFns = {
|
|
1380
1387
|
sum: sum,
|
|
1381
1388
|
min: min,
|
|
1382
1389
|
max: max,
|
|
@@ -1494,7 +1501,7 @@
|
|
|
1494
1501
|
var Grouping = {
|
|
1495
1502
|
getDefaultColumn: function getDefaultColumn() {
|
|
1496
1503
|
return {
|
|
1497
|
-
|
|
1504
|
+
aggregationFn: 'auto'
|
|
1498
1505
|
};
|
|
1499
1506
|
},
|
|
1500
1507
|
getInitialState: function getInitialState() {
|
|
@@ -1511,7 +1518,7 @@
|
|
|
1511
1518
|
},
|
|
1512
1519
|
createColumn: function createColumn(column, instance) {
|
|
1513
1520
|
return {
|
|
1514
|
-
|
|
1521
|
+
aggregationFn: column.aggregationFn,
|
|
1515
1522
|
getCanGroup: function getCanGroup() {
|
|
1516
1523
|
return instance.getColumnCanGroup(column.id);
|
|
1517
1524
|
},
|
|
@@ -1553,26 +1560,26 @@
|
|
|
1553
1560
|
var value = firstRow == null ? void 0 : firstRow.values[columnId];
|
|
1554
1561
|
|
|
1555
1562
|
if (typeof value === 'number') {
|
|
1556
|
-
return
|
|
1563
|
+
return aggregationFns.sum;
|
|
1557
1564
|
}
|
|
1558
1565
|
|
|
1559
1566
|
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
1560
|
-
return
|
|
1567
|
+
return aggregationFns.extent;
|
|
1561
1568
|
}
|
|
1562
1569
|
|
|
1563
|
-
return
|
|
1570
|
+
return aggregationFns.count;
|
|
1564
1571
|
},
|
|
1565
1572
|
getColumnAggregationFn: function getColumnAggregationFn(columnId) {
|
|
1566
1573
|
var _ref;
|
|
1567
1574
|
|
|
1568
1575
|
var column = instance.getColumn(columnId);
|
|
1569
|
-
var userAggregationTypes = instance.options.
|
|
1576
|
+
var userAggregationTypes = instance.options.aggregationFns;
|
|
1570
1577
|
|
|
1571
1578
|
if (!column) {
|
|
1572
1579
|
throw new Error();
|
|
1573
1580
|
}
|
|
1574
1581
|
|
|
1575
|
-
return isFunction(column.
|
|
1582
|
+
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? instance.getColumnAutoAggregationFn(columnId) : (_ref = userAggregationTypes == null ? void 0 : userAggregationTypes[column.aggregationFn]) != null ? _ref : aggregationFns[column.aggregationFn];
|
|
1576
1583
|
},
|
|
1577
1584
|
setGrouping: function setGrouping(updater) {
|
|
1578
1585
|
return instance.options.onGroupingChange == null ? void 0 : instance.options.onGroupingChange(updater, functionalUpdate(updater, instance.getState().grouping));
|
|
@@ -2584,7 +2591,7 @@
|
|
|
2584
2591
|
}
|
|
2585
2592
|
|
|
2586
2593
|
var reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2587
|
-
var
|
|
2594
|
+
var sortingFns = {
|
|
2588
2595
|
alphanumeric: alphanumeric,
|
|
2589
2596
|
alphanumericCaseSensitive: alphanumericCaseSensitive,
|
|
2590
2597
|
text: text,
|
|
@@ -2692,7 +2699,7 @@
|
|
|
2692
2699
|
var Sorting = {
|
|
2693
2700
|
getDefaultColumn: function getDefaultColumn() {
|
|
2694
2701
|
return {
|
|
2695
|
-
|
|
2702
|
+
sortingFn: 'auto'
|
|
2696
2703
|
};
|
|
2697
2704
|
},
|
|
2698
2705
|
getInitialState: function getInitialState() {
|
|
@@ -2711,7 +2718,7 @@
|
|
|
2711
2718
|
},
|
|
2712
2719
|
createColumn: function createColumn(column, instance) {
|
|
2713
2720
|
return {
|
|
2714
|
-
|
|
2721
|
+
sortingFn: column.sortingFn,
|
|
2715
2722
|
getCanSort: function getCanSort() {
|
|
2716
2723
|
return instance.getColumnCanSort(column.id);
|
|
2717
2724
|
},
|
|
@@ -2763,23 +2770,23 @@
|
|
|
2763
2770
|
var value = row == null ? void 0 : row.values[columnId];
|
|
2764
2771
|
|
|
2765
2772
|
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
2766
|
-
return
|
|
2773
|
+
return sortingFns.datetime;
|
|
2767
2774
|
}
|
|
2768
2775
|
|
|
2769
2776
|
if (typeof value === 'string') {
|
|
2770
2777
|
isString = true;
|
|
2771
2778
|
|
|
2772
2779
|
if (value.split(reSplitAlphaNumeric).length > 1) {
|
|
2773
|
-
return
|
|
2780
|
+
return sortingFns.alphanumeric;
|
|
2774
2781
|
}
|
|
2775
2782
|
}
|
|
2776
2783
|
}
|
|
2777
2784
|
|
|
2778
2785
|
if (isString) {
|
|
2779
|
-
return
|
|
2786
|
+
return sortingFns.text;
|
|
2780
2787
|
}
|
|
2781
2788
|
|
|
2782
|
-
return
|
|
2789
|
+
return sortingFns.basic;
|
|
2783
2790
|
},
|
|
2784
2791
|
getColumnAutoSortDir: function getColumnAutoSortDir(columnId) {
|
|
2785
2792
|
var firstRow = instance.getGlobalFilteredRowModel().flatRows[0];
|
|
@@ -2795,13 +2802,13 @@
|
|
|
2795
2802
|
var _ref;
|
|
2796
2803
|
|
|
2797
2804
|
var column = instance.getColumn(columnId);
|
|
2798
|
-
var userSortTypes = instance.options.
|
|
2805
|
+
var userSortTypes = instance.options.sortingFns;
|
|
2799
2806
|
|
|
2800
2807
|
if (!column) {
|
|
2801
2808
|
throw new Error();
|
|
2802
2809
|
}
|
|
2803
2810
|
|
|
2804
|
-
return isFunction(column.
|
|
2811
|
+
return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? instance.getColumnAutoSortingFn(columnId) : (_ref = userSortTypes == null ? void 0 : userSortTypes[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
|
|
2805
2812
|
},
|
|
2806
2813
|
setSorting: function setSorting(updater) {
|
|
2807
2814
|
return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));
|
|
@@ -4229,26 +4236,32 @@
|
|
|
4229
4236
|
}
|
|
4230
4237
|
|
|
4231
4238
|
//
|
|
4232
|
-
function
|
|
4233
|
-
return {
|
|
4234
|
-
|
|
4235
|
-
return function () {
|
|
4236
|
-
return _createTable(undefined, undefined, _extends({}, factoryOptions, opts));
|
|
4237
|
-
};
|
|
4238
|
-
},
|
|
4239
|
-
createTable: function createTable() {
|
|
4240
|
-
return _createTable(undefined, undefined, opts);
|
|
4241
|
-
}
|
|
4239
|
+
function createTableFactory(opts) {
|
|
4240
|
+
return function () {
|
|
4241
|
+
return createTable(undefined, undefined, opts);
|
|
4242
4242
|
};
|
|
4243
|
-
}
|
|
4243
|
+
} // A lot of returns in here are `as any` for a reason. Unless you
|
|
4244
|
+
// can find a better way to do this, then don't worry about them
|
|
4244
4245
|
|
|
4245
|
-
function
|
|
4246
|
-
|
|
4246
|
+
function createTable(_, __, options) {
|
|
4247
|
+
var table = {
|
|
4247
4248
|
generics: undefined,
|
|
4248
|
-
|
|
4249
|
-
render: function
|
|
4250
|
-
throw new Error();
|
|
4251
|
-
}
|
|
4249
|
+
options: options != null ? options : {
|
|
4250
|
+
render: function () {
|
|
4251
|
+
throw new Error('');
|
|
4252
|
+
}()
|
|
4253
|
+
},
|
|
4254
|
+
setRowType: function setRowType() {
|
|
4255
|
+
return table;
|
|
4256
|
+
},
|
|
4257
|
+
setTableMetaType: function setTableMetaType() {
|
|
4258
|
+
return table;
|
|
4259
|
+
},
|
|
4260
|
+
setColumnMetaType: function setColumnMetaType() {
|
|
4261
|
+
return table;
|
|
4262
|
+
},
|
|
4263
|
+
setOptions: function setOptions(newOptions) {
|
|
4264
|
+
return createTable(_, __, _extends({}, options, newOptions));
|
|
4252
4265
|
},
|
|
4253
4266
|
createColumns: function createColumns(columns) {
|
|
4254
4267
|
return columns;
|
|
@@ -4287,6 +4300,7 @@
|
|
|
4287
4300
|
throw new Error('Invalid accessor');
|
|
4288
4301
|
}
|
|
4289
4302
|
};
|
|
4303
|
+
return table;
|
|
4290
4304
|
}
|
|
4291
4305
|
|
|
4292
4306
|
function getCoreRowModelSync() {
|
|
@@ -4608,7 +4622,7 @@
|
|
|
4608
4622
|
|
|
4609
4623
|
if (!filterFn) {
|
|
4610
4624
|
{
|
|
4611
|
-
console.warn("Could not find a valid 'column.
|
|
4625
|
+
console.warn("Could not find a valid 'column.filterFn' for column with the ID: " + column.id + ".");
|
|
4612
4626
|
}
|
|
4613
4627
|
|
|
4614
4628
|
continue;
|
|
@@ -4877,7 +4891,7 @@
|
|
|
4877
4891
|
return row.values[column.id];
|
|
4878
4892
|
});
|
|
4879
4893
|
});
|
|
4880
|
-
} else if (column.
|
|
4894
|
+
} else if (column.aggregationFn) {
|
|
4881
4895
|
console.info({
|
|
4882
4896
|
column: column
|
|
4883
4897
|
});
|
|
@@ -5088,6 +5102,7 @@
|
|
|
5088
5102
|
exports.Sorting = Sorting;
|
|
5089
5103
|
exports.Visibility = Visibility;
|
|
5090
5104
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
5105
|
+
exports.createTableFactory = createTableFactory;
|
|
5091
5106
|
exports.createTableInstance = createTableInstance;
|
|
5092
5107
|
exports.defaultColumnSizing = defaultColumnSizing;
|
|
5093
5108
|
exports.expandRows = expandRows;
|
|
@@ -5103,7 +5118,6 @@
|
|
|
5103
5118
|
exports.getPaginationRowModel = getPaginationRowModel;
|
|
5104
5119
|
exports.getSortedRowModelSync = getSortedRowModelSync;
|
|
5105
5120
|
exports.incrementalMemo = incrementalMemo;
|
|
5106
|
-
exports.init = init;
|
|
5107
5121
|
exports.isFunction = isFunction;
|
|
5108
5122
|
exports.isRowSelected = isRowSelected;
|
|
5109
5123
|
exports.makeStateUpdater = makeStateUpdater;
|