@tanstack/table-core 8.0.0-alpha.18 → 8.0.0-alpha.21
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.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 +11 -16
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +264 -282
- package/build/types/core.d.ts +1 -2
- package/build/types/createTable.d.ts +14 -12
- package/build/types/features/Expanding.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 +10 -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 -35
- 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 +1 -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,32 +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: PartialKeys<
|
|
34
|
-
|
|
34
|
+
createDisplayColumn: (column: Overwrite<PartialKeys<ColumnDef<TGenerics>, 'accessorFn' | 'accessorKey'>, {
|
|
35
|
+
columns?: ColumnDef<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, {
|
|
35
38
|
Value: ReturnType<TAccessor>;
|
|
36
|
-
}
|
|
39
|
+
}>> : TAccessor extends keyof TGenerics['Row'] ? Overwrite<ColumnDef<Overwrite<TGenerics, {
|
|
37
40
|
Value: TGenerics['Row'][TAccessor];
|
|
38
|
-
}
|
|
41
|
+
}>>, {
|
|
39
42
|
id?: string;
|
|
40
43
|
}> : never, {
|
|
41
44
|
accessorFn?: never;
|
|
42
45
|
accessorKey?: never;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}>>;
|
|
46
|
+
columns?: ColumnDef<any>[];
|
|
47
|
+
}>) => ColumnDef<TGenerics>;
|
|
46
48
|
};
|
|
47
49
|
declare type InitTable<TRender extends AnyRender> = {
|
|
48
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>;
|
|
@@ -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() {
|
|
@@ -2780,9 +2777,6 @@
|
|
|
2780
2777
|
return {
|
|
2781
2778
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
2782
2779
|
autoResetExpanded: true,
|
|
2783
|
-
getIsRowExpanded: function getIsRowExpanded(row) {
|
|
2784
|
-
return !!(row == null ? void 0 : row.original).expanded;
|
|
2785
|
-
},
|
|
2786
2780
|
expandSubRows: true,
|
|
2787
2781
|
paginateExpandedRows: true
|
|
2788
2782
|
};
|
|
@@ -2857,7 +2851,7 @@
|
|
|
2857
2851
|
getIsRowExpanded: function getIsRowExpanded(rowId) {
|
|
2858
2852
|
var _instance$options$get;
|
|
2859
2853
|
|
|
2860
|
-
var row = instance.
|
|
2854
|
+
var row = instance.getPreExpandedRowModel().rowsById[rowId];
|
|
2861
2855
|
|
|
2862
2856
|
if (!row) {
|
|
2863
2857
|
{
|
|
@@ -2868,7 +2862,7 @@
|
|
|
2868
2862
|
}
|
|
2869
2863
|
|
|
2870
2864
|
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]));
|
|
2865
|
+
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
2866
|
},
|
|
2873
2867
|
getRowCanExpand: function getRowCanExpand(rowId) {
|
|
2874
2868
|
var _ref, _ref2, _instance$options$get2, _row$subRows;
|
|
@@ -2912,6 +2906,10 @@
|
|
|
2912
2906
|
};
|
|
2913
2907
|
return propGetter(initialProps, userProps);
|
|
2914
2908
|
},
|
|
2909
|
+
getIsSomeRowsExpanded: function getIsSomeRowsExpanded() {
|
|
2910
|
+
var expanded = instance.getState().expanded;
|
|
2911
|
+
return expanded === true || Object.values(expanded).some(Boolean);
|
|
2912
|
+
},
|
|
2915
2913
|
getIsAllRowsExpanded: function getIsAllRowsExpanded() {
|
|
2916
2914
|
var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
|
|
2917
2915
|
|
|
@@ -2942,7 +2940,7 @@
|
|
|
2942
2940
|
return [instance.getState().expanded, instance.getGroupedRowModel(), instance.options.expandRowsFn, instance.options.paginateExpandedRows];
|
|
2943
2941
|
}, function (expanded, rowModel, expandRowsFn, paginateExpandedRows) {
|
|
2944
2942
|
if (!expandRowsFn || // Do not expand if rows are not included in pagination
|
|
2945
|
-
!paginateExpandedRows || !Object.keys(expanded != null ? expanded : {}).length) {
|
|
2943
|
+
!paginateExpandedRows || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
|
|
2946
2944
|
return rowModel;
|
|
2947
2945
|
}
|
|
2948
2946
|
|
|
@@ -2953,9 +2951,6 @@
|
|
|
2953
2951
|
var _instance$options$deb;
|
|
2954
2952
|
|
|
2955
2953
|
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
|
|
2956
|
-
},
|
|
2957
|
-
onChange: function onChange() {
|
|
2958
|
-
instance._notifyPageIndexReset();
|
|
2959
2954
|
}
|
|
2960
2955
|
}),
|
|
2961
2956
|
getPreExpandedRowModel: function getPreExpandedRowModel() {
|
|
@@ -3107,8 +3102,8 @@
|
|
|
3107
3102
|
getCanNextPage: function getCanNextPage() {
|
|
3108
3103
|
var _instance$getState$pa = instance.getState().pagination,
|
|
3109
3104
|
pageIndex = _instance$getState$pa.pageIndex,
|
|
3110
|
-
pageCount = _instance$getState$pa.pageCount,
|
|
3111
3105
|
pageSize = _instance$getState$pa.pageSize;
|
|
3106
|
+
var pageCount = instance.getPageCount();
|
|
3112
3107
|
|
|
3113
3108
|
if (pageCount === -1) {
|
|
3114
3109
|
return true;
|
|
@@ -4200,6 +4195,7 @@
|
|
|
4200
4195
|
|
|
4201
4196
|
function _createTable(_, __, __options) {
|
|
4202
4197
|
return {
|
|
4198
|
+
generics: undefined,
|
|
4203
4199
|
__options: __options != null ? __options : {
|
|
4204
4200
|
render: function render() {
|
|
4205
4201
|
throw new Error();
|
|
@@ -4656,14 +4652,13 @@
|
|
|
4656
4652
|
|
|
4657
4653
|
function expandRowsFn(instance, sortedRowModel) {
|
|
4658
4654
|
var expandedRows = [];
|
|
4659
|
-
var expandSubRows = instance.options.expandSubRows;
|
|
4660
4655
|
|
|
4661
4656
|
var handleRow = function handleRow(row) {
|
|
4662
4657
|
var _row$subRows;
|
|
4663
4658
|
|
|
4664
4659
|
expandedRows.push(row);
|
|
4665
4660
|
|
|
4666
|
-
if (expandSubRows && (_row$subRows = row.subRows) != null && _row$subRows.length && instance.getIsRowExpanded(row.id)) {
|
|
4661
|
+
if (instance.options.expandSubRows && (_row$subRows = row.subRows) != null && _row$subRows.length && instance.getIsRowExpanded(row.id)) {
|
|
4667
4662
|
row.subRows.forEach(handleRow);
|
|
4668
4663
|
}
|
|
4669
4664
|
};
|
|
@@ -4710,7 +4705,6 @@
|
|
|
4710
4705
|
exports.Ordering = Ordering;
|
|
4711
4706
|
exports.Pagination = Pagination;
|
|
4712
4707
|
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
4708
|
exports.RowSelection = RowSelection;
|
|
4715
4709
|
exports.Sorting = Sorting;
|
|
4716
4710
|
exports.Visibility = Visibility;
|