@tanstack/table-core 8.0.0-alpha.46 → 8.0.0-alpha.49

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.
@@ -9,7 +9,7 @@ export declare const aggregationFns: {
9
9
  uniqueCount: typeof uniqueCount;
10
10
  count: typeof count;
11
11
  };
12
- export declare type BuiltInAggregationType = keyof typeof aggregationFns;
12
+ export declare type BuiltInAggregationFn = 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,10 +1,10 @@
1
- import { CustomFilterTypes, FilterFn } from './features/Filters';
2
- import { AggregationFn, CustomAggregationTypes } from './features/Grouping';
3
- import { CustomSortingTypes, SortingFn } from './features/Sorting';
1
+ import { CustomFilterFns, FilterFn } from './features/Filters';
2
+ import { AggregationFn, CustomAggregationFns } from './features/Grouping';
3
+ import { CustomSortingFns, SortingFn } from './features/Sorting';
4
4
  import { ColumnDef, AccessorFn, AnyRender, AnyGenerics, Options } from './types';
5
5
  import { IfDefined, Overwrite, PartialKeys } from './utils';
6
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<{
7
+ export declare type CreateTableOptions<TRender extends AnyRender, TFilterFns extends CustomFilterFns<any>, TSortingFns extends CustomSortingFns<any>, TAggregationFns extends CustomAggregationFns<any>, TGenerics extends AnyGenerics> = Partial<{
8
8
  render?: TRender;
9
9
  filterFns?: TFilterFns;
10
10
  sortingFns?: TSortingFns;
@@ -13,13 +13,13 @@ export declare type CreateTableOptions<TRender extends AnyRender, TFilterFns ext
13
13
  export declare type Table<TGenerics extends AnyGenerics> = {
14
14
  generics: TGenerics;
15
15
  options: Partial<Options<TGenerics>>;
16
- setRowType: <TRow extends object>() => Table<Overwrite<TGenerics, {
16
+ setRowType: <TRow>() => Table<Overwrite<TGenerics, {
17
17
  Row: TRow;
18
18
  }>>;
19
- setTableMetaType: <TTableMeta extends object>() => Table<Overwrite<TGenerics, {
19
+ setTableMetaType: <TTableMeta>() => Table<Overwrite<TGenerics, {
20
20
  TableMeta: TTableMeta;
21
21
  }>>;
22
- setColumnMetaType: <TColumnMeta extends object>() => Table<Overwrite<TGenerics, {
22
+ setColumnMetaType: <TColumnMeta>() => Table<Overwrite<TGenerics, {
23
23
  ColumnMeta: TColumnMeta;
24
24
  }>>;
25
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, {
@@ -1,27 +1,27 @@
1
1
  import { RowModel } from '..';
2
- import { BuiltInFilterType } from '../filterFns';
2
+ import { BuiltInFilterFn } from '../filterFns';
3
3
  import { Column, OnChangeFn, AnyGenerics, TableInstance, Row, Updater } from '../types';
4
4
  import { Overwrite } from '../utils';
5
+ export declare type FiltersTableState = {
6
+ columnFilters: ColumnFiltersState;
7
+ globalFilter: any;
8
+ columnFiltersProgress: number;
9
+ globalFilterProgress: number;
10
+ };
11
+ export declare type ColumnFiltersState = ColumnFilter[];
5
12
  export declare type ColumnFilter = {
6
13
  id: string;
7
14
  value: unknown;
8
15
  };
9
- export declare type ColumnFiltersState = ColumnFilter[];
10
16
  export declare type FilterFn<TGenerics extends AnyGenerics> = {
11
17
  (rows: Row<TGenerics>[], columnIds: string[], filterValue: any): any;
12
18
  autoRemove?: ColumnFilterAutoRemoveTestFn<TGenerics>;
13
19
  };
14
20
  export declare type ColumnFilterAutoRemoveTestFn<TGenerics extends AnyGenerics> = (value: unknown, column?: Column<TGenerics>) => boolean;
15
- export declare type CustomFilterTypes<TGenerics extends AnyGenerics> = Record<string, FilterFn<TGenerics>>;
16
- export declare type FiltersTableState = {
17
- columnFilters: ColumnFiltersState;
18
- globalFilter: any;
19
- columnFiltersProgress: number;
20
- globalFilterProgress: number;
21
- };
22
- export declare type FilterType<TGenerics extends AnyGenerics> = 'auto' | BuiltInFilterType | keyof TGenerics['FilterFns'] | FilterFn<TGenerics>;
21
+ export declare type CustomFilterFns<TGenerics extends AnyGenerics> = Record<string, FilterFn<TGenerics>>;
22
+ export declare type FilterFnOption<TGenerics extends AnyGenerics> = 'auto' | BuiltInFilterFn | keyof TGenerics['FilterFns'] | FilterFn<TGenerics>;
23
23
  export declare type FiltersColumnDef<TGenerics extends AnyGenerics> = {
24
- filterFn?: FilterType<Overwrite<TGenerics, {
24
+ filterFn?: FilterFnOption<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
- filterFn: FilterType<Overwrite<TGenerics, {
35
+ filterFn: FilterFnOption<Overwrite<TGenerics, {
36
36
  Value: any;
37
37
  }>>;
38
38
  getCanColumnFilter: () => boolean;
@@ -53,7 +53,7 @@ export declare type FiltersOptions<TGenerics extends AnyGenerics> = {
53
53
  autoResetColumnFilters?: boolean;
54
54
  enableColumnFilters?: boolean;
55
55
  getColumnFilteredRowModel?: (instance: TableInstance<TGenerics>) => () => RowModel<TGenerics>;
56
- globalFilterType?: FilterType<TGenerics>;
56
+ globalFilterFn?: FilterFnOption<TGenerics>;
57
57
  onGlobalFilterChange?: OnChangeFn<any>;
58
58
  autoResetGlobalFilter?: boolean;
59
59
  enableGlobalFilter?: boolean;
@@ -1,16 +1,16 @@
1
1
  import { RowModel } from '..';
2
- import { BuiltInAggregationType } from '../aggregationFns';
2
+ import { BuiltInAggregationFn } 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[];
6
6
  export declare type AggregationFn<TGenerics extends AnyGenerics> = (getLeafValues: () => TGenerics['Row'][], getChildValues: () => TGenerics['Row'][]) => any;
7
- export declare type CustomAggregationTypes<TGenerics extends AnyGenerics> = Record<string, AggregationFn<TGenerics>>;
8
- export declare type AggregationType<TGenerics extends AnyGenerics> = 'auto' | BuiltInAggregationType | keyof TGenerics['AggregationFns'] | AggregationFn<TGenerics>;
7
+ export declare type CustomAggregationFns<TGenerics extends AnyGenerics> = Record<string, AggregationFn<TGenerics>>;
8
+ export declare type AggregationFnOption<TGenerics extends AnyGenerics> = 'auto' | BuiltInAggregationFn | keyof TGenerics['AggregationFns'] | AggregationFn<TGenerics>;
9
9
  export declare type GroupingTableState = {
10
10
  grouping: GroupingState;
11
11
  };
12
12
  export declare type GroupingColumnDef<TGenerics extends AnyGenerics> = {
13
- aggregationFn?: AggregationType<Overwrite<TGenerics, {
13
+ aggregationFn?: AggregationFnOption<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
- aggregationFn?: AggregationType<Overwrite<TGenerics, {
28
+ aggregationFn?: AggregationFnOption<Overwrite<TGenerics, {
29
29
  Value: any;
30
30
  }>>;
31
31
  getCanGroup: () => boolean;
@@ -1,5 +1,5 @@
1
1
  import { RowModel } from '..';
2
- import { BuiltInSortType } from '../sortingFns';
2
+ import { BuiltInSortingFn } 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';
@@ -11,13 +11,13 @@ export declare type SortingState = ColumnSort[];
11
11
  export declare type SortingFn<TGenerics extends AnyGenerics> = {
12
12
  (rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
13
13
  };
14
- export declare type CustomSortingTypes<TGenerics extends AnyGenerics> = Record<string, SortingFn<TGenerics>>;
14
+ export declare type CustomSortingFns<TGenerics extends AnyGenerics> = Record<string, SortingFn<TGenerics>>;
15
15
  export declare type SortingTableState = {
16
16
  sorting: SortingState;
17
17
  };
18
- export declare type SortType<TGenerics extends AnyGenerics> = 'auto' | BuiltInSortType | keyof TGenerics['SortingFns'] | SortingFn<TGenerics>;
18
+ export declare type SortingFnOption<TGenerics extends AnyGenerics> = 'auto' | BuiltInSortingFn | keyof TGenerics['SortingFns'] | SortingFn<TGenerics>;
19
19
  export declare type SortingColumnDef<TGenerics extends AnyGenerics> = {
20
- sortingFn?: SortType<Overwrite<TGenerics, {
20
+ sortingFn?: SortingFnOption<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
- sortingFn: SortType<Overwrite<TGenerics, {
31
+ sortingFn: SortingFnOption<Overwrite<TGenerics, {
32
32
  Value: any;
33
33
  }>>;
34
34
  getCanSort: () => boolean;
@@ -10,7 +10,7 @@ export declare const filterFns: {
10
10
  weakEquals: typeof weakEquals;
11
11
  betweenNumberRange: typeof betweenNumberRange;
12
12
  };
13
- export declare type BuiltInFilterType = keyof typeof filterFns;
13
+ export declare type BuiltInFilterFn = 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;
@@ -8,7 +8,7 @@ export declare const sortingFns: {
8
8
  datetime: typeof datetime;
9
9
  basic: typeof basic;
10
10
  };
11
- export declare type BuiltInSortType = keyof typeof sortingFns;
11
+ export declare type BuiltInSortingFn = 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;
@@ -1066,7 +1066,7 @@
1066
1066
  autoResetColumnFilters: true,
1067
1067
  filterFromLeafRows: true,
1068
1068
  autoResetGlobalFilter: true,
1069
- globalFilterType: 'auto',
1069
+ globalFilterFn: 'auto',
1070
1070
  getColumnCanGlobalFilterFn: function getColumnCanGlobalFilterFn(column) {
1071
1071
  var _instance$getCoreRowM, _instance$getCoreRowM2;
1072
1072
 
@@ -1203,21 +1203,21 @@
1203
1203
  var _ref;
1204
1204
 
1205
1205
  var column = instance.getColumn(columnId);
1206
- var userFilterTypes = instance.options.filterFns;
1206
+ var userFilterFns = instance.options.filterFns;
1207
1207
 
1208
1208
  if (!column) {
1209
1209
  throw new Error();
1210
1210
  }
1211
1211
 
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];
1212
+ return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? instance.getColumnAutoFilterFn(columnId) : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
1213
1213
  },
1214
1214
  getGlobalFilterFn: function getGlobalFilterFn() {
1215
1215
  var _ref2;
1216
1216
 
1217
1217
  var _instance$options = instance.options,
1218
- userFilterTypes = _instance$options.filterFns,
1219
- globalFilterType = _instance$options.globalFilterType;
1220
- return isFunction(globalFilterType) ? globalFilterType : globalFilterType === 'auto' ? instance.getGlobalAutoFilterFn() : (_ref2 = userFilterTypes == null ? void 0 : userFilterTypes[globalFilterType]) != null ? _ref2 : filterFns[globalFilterType];
1218
+ userFilterFns = _instance$options.filterFns,
1219
+ globalFilterFn = _instance$options.globalFilterFn;
1220
+ return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? instance.getGlobalAutoFilterFn() : (_ref2 = userFilterFns == null ? void 0 : userFilterFns[globalFilterFn]) != null ? _ref2 : filterFns[globalFilterFn];
1221
1221
  },
1222
1222
  setColumnFilters: function setColumnFilters(updater) {
1223
1223
  var leafColumns = instance.getAllLeafColumns();
@@ -1259,7 +1259,7 @@
1259
1259
  throw new Error();
1260
1260
  }
1261
1261
 
1262
- return (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_column$enableAllFilt = column.enableAllFilters) != null ? _column$enableAllFilt : column.enableColumnFilter) != null ? _ref7 : instance.options.enableFilters) != null ? _ref6 : instance.options.enableColumnFilters) != null ? _ref5 : column.defaultCanFilter) != null ? _ref4 : column.defaultCanColumnFilter) != null ? _ref3 : !!column.accessorFn;
1262
+ return (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_column$enableAllFilt = column.enableAllFilters) != null ? _column$enableAllFilt : column.enableColumnFilter) != null ? _ref7 : instance.options.enableFilters) != null ? _ref6 : instance.options.enableColumnFilters) != null ? _ref5 : column.defaultCanColumnFilter) != null ? _ref4 : column.defaultCanFilter) != null ? _ref3 : !!column.accessorFn;
1263
1263
  },
1264
1264
  getColumnCanGlobalFilter: function getColumnCanGlobalFilter(columnId) {
1265
1265
  var _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _instance$options$ena;
@@ -1270,7 +1270,7 @@
1270
1270
  throw new Error();
1271
1271
  }
1272
1272
 
1273
- return (_ref8 = ((_ref9 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = (_instance$options$ena = instance.options.enableFilters) != null ? _instance$options$ena : instance.options.enableGlobalFilter) != null ? _ref13 : column.enableAllFilters) != null ? _ref12 : column.enableGlobalFilter) != null ? _ref11 : column.defaultCanFilter) != null ? _ref10 : column.defaultCanGlobalFilter) != null ? _ref9 : !!column.accessorFn) && (instance.options.getColumnCanGlobalFilterFn == null ? void 0 : instance.options.getColumnCanGlobalFilterFn(column))) != null ? _ref8 : true;
1273
+ return (_ref8 = ((_ref9 = (_ref10 = (_ref11 = (_ref12 = (_ref13 = (_instance$options$ena = instance.options.enableFilters) != null ? _instance$options$ena : instance.options.enableGlobalFilter) != null ? _ref13 : column.enableAllFilters) != null ? _ref12 : column.enableGlobalFilter) != null ? _ref11 : column.defaultCanGlobalFilter) != null ? _ref10 : column.defaultCanFilter) != null ? _ref9 : !!column.accessorFn) && (instance.options.getColumnCanGlobalFilterFn == null ? void 0 : instance.options.getColumnCanGlobalFilterFn(column))) != null ? _ref8 : true;
1274
1274
  },
1275
1275
  getColumnIsFiltered: function getColumnIsFiltered(columnId) {
1276
1276
  return instance.getColumnFilterIndex(columnId) > -1;
@@ -1573,13 +1573,13 @@
1573
1573
  var _ref;
1574
1574
 
1575
1575
  var column = instance.getColumn(columnId);
1576
- var userAggregationTypes = instance.options.aggregationFns;
1576
+ var userAggregationFns = instance.options.aggregationFns;
1577
1577
 
1578
1578
  if (!column) {
1579
1579
  throw new Error();
1580
1580
  }
1581
1581
 
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];
1582
+ return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? instance.getColumnAutoAggregationFn(columnId) : (_ref = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref : aggregationFns[column.aggregationFn];
1583
1583
  },
1584
1584
  setGrouping: function setGrouping(updater) {
1585
1585
  return instance.options.onGroupingChange == null ? void 0 : instance.options.onGroupingChange(updater, functionalUpdate(updater, instance.getState().grouping));
@@ -2802,13 +2802,13 @@
2802
2802
  var _ref;
2803
2803
 
2804
2804
  var column = instance.getColumn(columnId);
2805
- var userSortTypes = instance.options.sortingFns;
2805
+ var userSortingFn = instance.options.sortingFns;
2806
2806
 
2807
2807
  if (!column) {
2808
2808
  throw new Error();
2809
2809
  }
2810
2810
 
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];
2811
+ return isFunction(column.sortingFn) ? column.sortingFn : column.sortingFn === 'auto' ? instance.getColumnAutoSortingFn(columnId) : (_ref = userSortingFn == null ? void 0 : userSortingFn[column.sortingFn]) != null ? _ref : sortingFns[column.sortingFn];
2812
2812
  },
2813
2813
  setSorting: function setSorting(updater) {
2814
2814
  return instance.options.onSortingChange == null ? void 0 : instance.options.onSortingChange(updater, functionalUpdate(updater, instance.getState().sorting));