@tanstack/table-core 8.0.0-alpha.19 → 8.0.0-alpha.22
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.map +1 -1
- package/build/cjs/createTable.js +1 -0
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +7 -9
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +1 -1
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +6 -0
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterTypes.js.map +1 -1
- package/build/cjs/index.js +0 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortTypes.js.map +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js +1 -2
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/esm/index.js +17 -16
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +266 -284
- package/build/types/core.d.ts +1 -2
- package/build/types/createTable.d.ts +12 -13
- package/build/types/features/Expanding.d.ts +1 -0
- package/build/types/features/Pinning.d.ts +1 -0
- package/build/types/features/RowSelection.d.ts +2 -2
- package/build/types/types.d.ts +1 -5
- package/build/umd/index.development.js +16 -16
- 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 +1 -2
- package/src/createTable.tsx +19 -43
- package/src/features/ColumnSizing.ts +1 -0
- package/src/features/Expanding.ts +9 -7
- package/src/features/Filters.ts +1 -0
- package/src/features/Grouping.ts +1 -0
- package/src/features/Headers.ts +1 -0
- package/src/features/Ordering.ts +1 -0
- package/src/features/Pagination.ts +4 -2
- package/src/features/Pinning.ts +8 -0
- package/src/features/RowSelection.ts +2 -2
- package/src/features/Sorting.ts +1 -0
- package/src/features/Visibility.ts +1 -0
- package/src/filterTypes.ts +1 -1
- package/src/sortTypes.ts +1 -1
- package/src/types.ts +19 -10
- package/src/utils/columnFilterRowsFn.ts +7 -1
- package/src/utils/expandRowsFn.ts +8 -4
- package/src/utils/globalFilterRowsFn.ts +7 -1
- package/src/utils/groupRowsFn.ts +8 -2
- package/src/utils/sortRowsFn.ts +7 -1
- package/build/cjs/types.js +0 -19
- package/build/cjs/types.js.map +0 -1
package/build/types/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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, PartialGenerics, Renderable, UseRenderer } from './types';
|
|
3
3
|
import { RowModel } from '.';
|
|
4
4
|
export declare type CoreOptions<TGenerics extends PartialGenerics> = {
|
|
5
5
|
data: TGenerics['Row'][];
|
|
@@ -91,7 +91,6 @@ export declare type CoreColumnDef<TGenerics extends PartialGenerics> = {
|
|
|
91
91
|
value: TGenerics['Value'];
|
|
92
92
|
}>;
|
|
93
93
|
meta?: TGenerics['ColumnMeta'];
|
|
94
|
-
[Please_use_the_create_table_column_utilities_to_define_columns]: true;
|
|
95
94
|
};
|
|
96
95
|
export declare type CoreColumn<TGenerics extends PartialGenerics> = {
|
|
97
96
|
id: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
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, PartialGenerics,
|
|
4
|
+
import { ColumnDef, AccessorFn, PartialGenerics, AnyRender } from './types';
|
|
5
5
|
import { Overwrite, PartialKeys } from './utils';
|
|
6
6
|
export declare type CreateTableFactory<TGenerics extends PartialGenerics> = <TSubGenerics extends {
|
|
7
7
|
Row: any;
|
|
@@ -17,35 +17,34 @@ export declare type CreateTableFactoryOptions<TRender extends AnyRender, TFilter
|
|
|
17
17
|
aggregationFns?: TAggregationFns;
|
|
18
18
|
};
|
|
19
19
|
export declare type Table<TGenerics extends PartialGenerics> = {
|
|
20
|
+
generics: TGenerics;
|
|
20
21
|
__options: CreateTableFactoryOptions<any, any, any, any>;
|
|
21
|
-
createColumns: (columns:
|
|
22
|
-
createGroup: (column: Overwrite<Overwrite<
|
|
22
|
+
createColumns: <TColumnDef extends ColumnDef<any>>(columns: TColumnDef[]) => TColumnDef[];
|
|
23
|
+
createGroup: (column: Overwrite<Overwrite<ColumnDef<any>, {
|
|
23
24
|
header: string;
|
|
24
25
|
id?: string;
|
|
25
|
-
}> | Overwrite<
|
|
26
|
+
}> | Overwrite<ColumnDef<any>, {
|
|
26
27
|
id: string;
|
|
27
|
-
header?: string |
|
|
28
|
+
header?: string | ((...any: any) => any);
|
|
28
29
|
}>, {
|
|
29
30
|
accessorFn?: never;
|
|
30
31
|
accessorKey?: never;
|
|
31
32
|
columns?: ColumnDef<any>[];
|
|
32
33
|
}>) => ColumnDef<TGenerics>;
|
|
33
|
-
createDisplayColumn: (column:
|
|
34
|
+
createDisplayColumn: (column: Overwrite<PartialKeys<ColumnDef<TGenerics>, 'accessorFn' | 'accessorKey'>, {
|
|
34
35
|
columns?: ColumnDef<any>[];
|
|
35
|
-
}
|
|
36
|
-
createDataColumn: <TAccessor extends AccessorFn<TGenerics['Row']> | keyof TGenerics['Row']>(accessor: TAccessor, column: Overwrite<TAccessor extends (...args: any[]) => any ?
|
|
36
|
+
}>) => ColumnDef<TGenerics>;
|
|
37
|
+
createDataColumn: <TAccessor extends AccessorFn<TGenerics['Row']> | keyof TGenerics['Row']>(accessor: TAccessor, column: Overwrite<TAccessor extends (...args: any[]) => any ? ColumnDef<Overwrite<TGenerics, {
|
|
37
38
|
Value: ReturnType<TAccessor>;
|
|
38
|
-
}
|
|
39
|
+
}>> : TAccessor extends keyof TGenerics['Row'] ? Overwrite<ColumnDef<Overwrite<TGenerics, {
|
|
39
40
|
Value: TGenerics['Row'][TAccessor];
|
|
40
|
-
}
|
|
41
|
+
}>>, {
|
|
41
42
|
id?: string;
|
|
42
43
|
}> : never, {
|
|
43
44
|
accessorFn?: never;
|
|
44
45
|
accessorKey?: never;
|
|
45
46
|
columns?: ColumnDef<any>[];
|
|
46
|
-
}>) => ColumnDef<
|
|
47
|
-
Value: TAccessor extends (...args: any[]) => any ? ReturnType<TAccessor> : TAccessor extends keyof TGenerics['Row'] ? TGenerics['Row'][TAccessor] : never;
|
|
48
|
-
}>>;
|
|
47
|
+
}>) => ColumnDef<TGenerics>;
|
|
49
48
|
};
|
|
50
49
|
declare type InitTable<TRender extends AnyRender> = {
|
|
51
50
|
createTableFactory: <TGenerics extends PartialGenerics>(options?: CreateTableFactoryOptions<TRender, any, any, any>) => CreateTableFactory<Overwrite<TGenerics, {
|
|
@@ -37,6 +37,7 @@ export declare type ExpandedInstance<TGenerics extends PartialGenerics> = {
|
|
|
37
37
|
getIsRowExpanded: (rowId: string) => boolean;
|
|
38
38
|
getToggleExpandedProps: <TGetter extends Getter<ToggleExpandedProps>>(rowId: string, userProps?: TGetter) => undefined | PropGetterValue<ToggleExpandedProps, TGetter>;
|
|
39
39
|
getToggleAllRowsExpandedProps: <TGetter extends Getter<ToggleExpandedProps>>(userProps?: TGetter) => undefined | PropGetterValue<ToggleExpandedProps, TGetter>;
|
|
40
|
+
getIsSomeRowsExpanded: () => boolean;
|
|
40
41
|
getIsAllRowsExpanded: () => boolean;
|
|
41
42
|
getExpandedDepth: () => number;
|
|
42
43
|
getExpandedRowModel: () => RowModel<TGenerics>;
|
|
@@ -31,6 +31,7 @@ export declare type ColumnPinningInstance<TGenerics extends PartialGenerics> = {
|
|
|
31
31
|
getColumnCanPin: (columnId: string) => boolean;
|
|
32
32
|
getColumnIsPinned: (columnId: string) => ColumnPinningPosition;
|
|
33
33
|
getColumnPinnedIndex: (columnId: string) => number;
|
|
34
|
+
getIsSomeColumnsPinned: () => boolean;
|
|
34
35
|
};
|
|
35
36
|
export declare const Pinning: {
|
|
36
37
|
getInitialState: () => ColumnPinningTableState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Getter, OnChangeFn, PartialGenerics, PropGetterValue, TableInstance, Row, RowModel, Updater
|
|
1
|
+
import { Getter, OnChangeFn, PartialGenerics, PropGetterValue, TableInstance, Row, RowModel, Updater } from '../types';
|
|
2
2
|
export declare type RowSelectionState = Record<string, boolean>;
|
|
3
3
|
export declare type RowSelectionTableState = {
|
|
4
4
|
rowSelection: RowSelectionState;
|
|
@@ -54,6 +54,6 @@ export declare const RowSelection: {
|
|
|
54
54
|
getInstance: <TGenerics_1 extends Partial<import("../types").DefaultGenerics>>(instance: TableInstance<TGenerics_1>) => RowSelectionInstance<TGenerics_1>;
|
|
55
55
|
createRow: <TGenerics_2 extends Partial<import("../types").DefaultGenerics>>(row: Row<TGenerics_2>, instance: TableInstance<TGenerics_2>) => RowSelectionRow;
|
|
56
56
|
};
|
|
57
|
-
export declare function selectRowsFn<TGenerics extends
|
|
57
|
+
export declare function selectRowsFn<TGenerics extends PartialGenerics>(instance: TableInstance<TGenerics>, rowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
|
58
58
|
export declare function isRowSelected<TGenerics extends PartialGenerics>(row: Row<TGenerics>, selection: Record<string, boolean>, instance: TableInstance<TGenerics>): boolean | 'some';
|
|
59
59
|
export {};
|
package/build/types/types.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare type AnyRender = (Comp: any, props: any) => any;
|
|
|
24
24
|
export declare type UseRenderer<TGenerics extends PartialGenerics> = TGenerics['Render'] extends (...args: any) => any ? TGenerics['Render'] : any;
|
|
25
25
|
export declare type PartialGenerics = Partial<DefaultGenerics>;
|
|
26
26
|
export declare type AnyGenerics = {
|
|
27
|
-
[TKey in keyof PartialGenerics]
|
|
27
|
+
[TKey in keyof PartialGenerics]?: any;
|
|
28
28
|
};
|
|
29
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>;
|
|
30
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>;
|
|
@@ -41,10 +41,6 @@ export declare type RowModel<TGenerics extends PartialGenerics> = {
|
|
|
41
41
|
rowsById: Record<string, Row<TGenerics>>;
|
|
42
42
|
};
|
|
43
43
|
export declare type AccessorFn<TData> = (originalRow: TData, index: number) => any;
|
|
44
|
-
export declare const Please_use_the_create_table_column_utilities_to_define_columns: unique symbol;
|
|
45
|
-
export declare type _NonGenerated<T> = Overwrite<T, {
|
|
46
|
-
[Please_use_the_create_table_column_utilities_to_define_columns]?: never;
|
|
47
|
-
}>;
|
|
48
44
|
export declare type Renderable<TGenerics extends PartialGenerics, TProps> = string | ((props: TProps) => ReturnType<UseRenderer<TGenerics>>);
|
|
49
45
|
export declare type ColumnDef<TGenerics extends PartialGenerics> = CoreColumnDef<TGenerics> & VisibilityColumnDef & ColumnPinningColumnDef & FiltersColumnDef<TGenerics> & SortingColumnDef<TGenerics> & GroupingColumnDef<TGenerics> & ColumnSizingColumnDef;
|
|
50
46
|
export declare type Column<TGenerics extends PartialGenerics> = ColumnDef<TGenerics> & CoreColumn<TGenerics> & ColumnVisibilityColumn & ColumnPinningColumn & FiltersColumn<TGenerics> & SortingColumn<TGenerics> & GroupingColumn<TGenerics> & ColumnSizingColumn<TGenerics>;
|
|
@@ -223,9 +223,6 @@
|
|
|
223
223
|
// return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString()
|
|
224
224
|
// }
|
|
225
225
|
|
|
226
|
-
//
|
|
227
|
-
var Please_use_the_create_table_column_utilities_to_define_columns = Symbol();
|
|
228
|
-
|
|
229
226
|
//
|
|
230
227
|
var Visibility = {
|
|
231
228
|
getInitialState: function getInitialState() {
|
|
@@ -902,6 +899,12 @@
|
|
|
902
899
|
|
|
903
900
|
var position = instance.getColumnIsPinned(columnId);
|
|
904
901
|
return position ? (_instance$getState$co2 = (_instance$getState$co3 = instance.getState().columnPinning) == null ? void 0 : (_instance$getState$co4 = _instance$getState$co3[position]) == null ? void 0 : _instance$getState$co4.indexOf(columnId)) != null ? _instance$getState$co2 : -1 : 0;
|
|
902
|
+
},
|
|
903
|
+
getIsSomeColumnsPinned: function getIsSomeColumnsPinned() {
|
|
904
|
+
var _instance$getState$co5 = instance.getState().columnPinning,
|
|
905
|
+
left = _instance$getState$co5.left,
|
|
906
|
+
right = _instance$getState$co5.right;
|
|
907
|
+
return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
|
|
905
908
|
}
|
|
906
909
|
};
|
|
907
910
|
}
|
|
@@ -2780,9 +2783,6 @@
|
|
|
2780
2783
|
return {
|
|
2781
2784
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
2782
2785
|
autoResetExpanded: true,
|
|
2783
|
-
getIsRowExpanded: function getIsRowExpanded(row) {
|
|
2784
|
-
return !!(row == null ? void 0 : row.original).expanded;
|
|
2785
|
-
},
|
|
2786
2786
|
expandSubRows: true,
|
|
2787
2787
|
paginateExpandedRows: true
|
|
2788
2788
|
};
|
|
@@ -2857,7 +2857,7 @@
|
|
|
2857
2857
|
getIsRowExpanded: function getIsRowExpanded(rowId) {
|
|
2858
2858
|
var _instance$options$get;
|
|
2859
2859
|
|
|
2860
|
-
var row = instance.
|
|
2860
|
+
var row = instance.getPreExpandedRowModel().rowsById[rowId];
|
|
2861
2861
|
|
|
2862
2862
|
if (!row) {
|
|
2863
2863
|
{
|
|
@@ -2868,7 +2868,7 @@
|
|
|
2868
2868
|
}
|
|
2869
2869
|
|
|
2870
2870
|
var expanded = instance.getState().expanded;
|
|
2871
|
-
return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded || (expanded == null ? void 0 : expanded[rowId]));
|
|
2871
|
+
return !!((_instance$options$get = instance.options.getIsRowExpanded == null ? void 0 : instance.options.getIsRowExpanded(row)) != null ? _instance$options$get : expanded === true || (expanded == null ? void 0 : expanded[rowId]));
|
|
2872
2872
|
},
|
|
2873
2873
|
getRowCanExpand: function getRowCanExpand(rowId) {
|
|
2874
2874
|
var _ref, _ref2, _instance$options$get2, _row$subRows;
|
|
@@ -2912,6 +2912,10 @@
|
|
|
2912
2912
|
};
|
|
2913
2913
|
return propGetter(initialProps, userProps);
|
|
2914
2914
|
},
|
|
2915
|
+
getIsSomeRowsExpanded: function getIsSomeRowsExpanded() {
|
|
2916
|
+
var expanded = instance.getState().expanded;
|
|
2917
|
+
return expanded === true || Object.values(expanded).some(Boolean);
|
|
2918
|
+
},
|
|
2915
2919
|
getIsAllRowsExpanded: function getIsAllRowsExpanded() {
|
|
2916
2920
|
var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
|
|
2917
2921
|
|
|
@@ -2942,7 +2946,7 @@
|
|
|
2942
2946
|
return [instance.getState().expanded, instance.getGroupedRowModel(), instance.options.expandRowsFn, instance.options.paginateExpandedRows];
|
|
2943
2947
|
}, function (expanded, rowModel, expandRowsFn, paginateExpandedRows) {
|
|
2944
2948
|
if (!expandRowsFn || // Do not expand if rows are not included in pagination
|
|
2945
|
-
!paginateExpandedRows || !Object.keys(expanded != null ? expanded : {}).length) {
|
|
2949
|
+
!paginateExpandedRows || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
|
|
2946
2950
|
return rowModel;
|
|
2947
2951
|
}
|
|
2948
2952
|
|
|
@@ -2953,9 +2957,6 @@
|
|
|
2953
2957
|
var _instance$options$deb;
|
|
2954
2958
|
|
|
2955
2959
|
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
|
|
2956
|
-
},
|
|
2957
|
-
onChange: function onChange() {
|
|
2958
|
-
instance._notifyPageIndexReset();
|
|
2959
2960
|
}
|
|
2960
2961
|
}),
|
|
2961
2962
|
getPreExpandedRowModel: function getPreExpandedRowModel() {
|
|
@@ -3107,8 +3108,8 @@
|
|
|
3107
3108
|
getCanNextPage: function getCanNextPage() {
|
|
3108
3109
|
var _instance$getState$pa = instance.getState().pagination,
|
|
3109
3110
|
pageIndex = _instance$getState$pa.pageIndex,
|
|
3110
|
-
pageCount = _instance$getState$pa.pageCount,
|
|
3111
3111
|
pageSize = _instance$getState$pa.pageSize;
|
|
3112
|
+
var pageCount = instance.getPageCount();
|
|
3112
3113
|
|
|
3113
3114
|
if (pageCount === -1) {
|
|
3114
3115
|
return true;
|
|
@@ -4200,6 +4201,7 @@
|
|
|
4200
4201
|
|
|
4201
4202
|
function _createTable(_, __, __options) {
|
|
4202
4203
|
return {
|
|
4204
|
+
generics: undefined,
|
|
4203
4205
|
__options: __options != null ? __options : {
|
|
4204
4206
|
render: function render() {
|
|
4205
4207
|
throw new Error();
|
|
@@ -4656,14 +4658,13 @@
|
|
|
4656
4658
|
|
|
4657
4659
|
function expandRowsFn(instance, sortedRowModel) {
|
|
4658
4660
|
var expandedRows = [];
|
|
4659
|
-
var expandSubRows = instance.options.expandSubRows;
|
|
4660
4661
|
|
|
4661
4662
|
var handleRow = function handleRow(row) {
|
|
4662
4663
|
var _row$subRows;
|
|
4663
4664
|
|
|
4664
4665
|
expandedRows.push(row);
|
|
4665
4666
|
|
|
4666
|
-
if (expandSubRows && (_row$subRows = row.subRows) != null && _row$subRows.length && instance.getIsRowExpanded(row.id)) {
|
|
4667
|
+
if (instance.options.expandSubRows && (_row$subRows = row.subRows) != null && _row$subRows.length && instance.getIsRowExpanded(row.id)) {
|
|
4667
4668
|
row.subRows.forEach(handleRow);
|
|
4668
4669
|
}
|
|
4669
4670
|
};
|
|
@@ -4710,7 +4711,6 @@
|
|
|
4710
4711
|
exports.Ordering = Ordering;
|
|
4711
4712
|
exports.Pagination = Pagination;
|
|
4712
4713
|
exports.Pinning = Pinning;
|
|
4713
|
-
exports.Please_use_the_create_table_column_utilities_to_define_columns = Please_use_the_create_table_column_utilities_to_define_columns;
|
|
4714
4714
|
exports.RowSelection = RowSelection;
|
|
4715
4715
|
exports.Sorting = Sorting;
|
|
4716
4716
|
exports.Visibility = Visibility;
|