@tanstack/table-core 8.0.0-alpha.26 → 8.0.0-alpha.30
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 +7 -1
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.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/Pagination.js +2 -4
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Sorting.js +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/utils.js +4 -4
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +17 -13
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +269 -269
- package/build/types/core.d.ts +3 -1
- package/build/types/createTable.d.ts +2 -4
- package/build/types/types.d.ts +1 -0
- package/build/umd/index.development.js +17 -13
- 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 +14 -3
- package/src/createTable.tsx +2 -6
- package/src/features/Expanding.ts +2 -2
- package/src/features/Filters.ts +1 -1
- package/src/features/Pagination.ts +2 -8
- package/src/features/Sorting.ts +1 -1
- package/src/types.ts +1 -0
- package/src/utils.tsx +4 -5
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, Renderable, UseRenderer, RowModel, AnyGenerics } from './types';
|
|
2
|
+
import { Updater, PropGetterValue, Options, TableState, ColumnDef, Row, Column, Cell, Header, AccessorFn, TableProps, TableBodyProps, PropGetter, Getter, RowProps, CellProps, TableInstance, RowValues, Renderable, UseRenderer, RowModel, TableFeature, AnyGenerics } from './types';
|
|
3
3
|
export declare type CoreOptions<TGenerics extends AnyGenerics> = {
|
|
4
4
|
data: TGenerics['Row'][];
|
|
5
5
|
columns: ColumnDef<TGenerics>[];
|
|
@@ -16,6 +16,8 @@ export declare type CoreOptions<TGenerics extends AnyGenerics> = {
|
|
|
16
16
|
getSubRows?: (originalRow: TGenerics['Row'], index: number) => TGenerics['Row'][];
|
|
17
17
|
getRowId?: (originalRow: TGenerics['Row'], index: number, parent?: Row<TGenerics>) => string;
|
|
18
18
|
autoResetAll?: boolean;
|
|
19
|
+
mergeOptions?: (defaultOptions: TableFeature, options: Partial<Options<TGenerics>>) => Options<TGenerics>;
|
|
20
|
+
meta?: TGenerics['TableMeta'] extends {} ? TGenerics['TableMeta'] : any;
|
|
19
21
|
};
|
|
20
22
|
export declare type TableCore<TGenerics extends AnyGenerics> = {
|
|
21
23
|
initialState: TableState;
|
|
@@ -6,10 +6,8 @@ import { Overwrite, PartialKeys } from './utils';
|
|
|
6
6
|
export declare type CreateTableFactory<TGenerics extends AnyGenerics> = <TSubGenerics extends {
|
|
7
7
|
Row: any;
|
|
8
8
|
ColumnMeta?: object;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ColumnMeta: TSubGenerics['ColumnMeta'];
|
|
12
|
-
}>>;
|
|
9
|
+
TableMeta?: object;
|
|
10
|
+
}>() => Table<Overwrite<TGenerics, TSubGenerics>>;
|
|
13
11
|
export declare type CreateTableFactoryOptions<TRender extends AnyRender, TFilterFns extends CustomFilterTypes<any>, TSortingFns extends CustomSortingTypes<any>, TAggregationFns extends CustomAggregationTypes<any>> = {
|
|
14
12
|
render: TRender;
|
|
15
13
|
filterFns?: TFilterFns;
|
package/build/types/types.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare type DefaultGenerics = {
|
|
|
19
19
|
AggregationFns: object;
|
|
20
20
|
Render: unknown;
|
|
21
21
|
ColumnMeta: object;
|
|
22
|
+
TableMeta: object;
|
|
22
23
|
};
|
|
23
24
|
export declare type AnyRender = (Comp: any, props: any) => any;
|
|
24
25
|
export declare type UseRenderer<TGenerics extends AnyGenerics> = TGenerics['Render'] extends (...args: any) => any ? TGenerics['Render'] : any;
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
var result;
|
|
152
152
|
return function () {
|
|
153
153
|
var depTime;
|
|
154
|
-
if (opts.key && opts.debug) depTime =
|
|
154
|
+
if (opts.key && opts.debug) depTime = Date.now();
|
|
155
155
|
var newDeps = getDeps();
|
|
156
156
|
var depsChanged = newDeps.length !== deps.length || newDeps.some(function (dep, index) {
|
|
157
157
|
return deps[index] !== dep;
|
|
@@ -160,15 +160,15 @@
|
|
|
160
160
|
if (depsChanged) {
|
|
161
161
|
var oldResult = result;
|
|
162
162
|
var resultTime;
|
|
163
|
-
if (opts.key && opts.debug) resultTime =
|
|
163
|
+
if (opts.key && opts.debug) resultTime = Date.now();
|
|
164
164
|
result = fn.apply(void 0, newDeps);
|
|
165
165
|
deps = newDeps;
|
|
166
166
|
opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result, oldResult);
|
|
167
167
|
|
|
168
168
|
if (opts.key && opts.debug) {
|
|
169
169
|
if (opts != null && opts.debug()) {
|
|
170
|
-
var depEndTime = Math.round((
|
|
171
|
-
var resultEndTime = Math.round((
|
|
170
|
+
var depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
171
|
+
var resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
172
172
|
var resultFpsPercentage = resultEndTime / 16;
|
|
173
173
|
|
|
174
174
|
var pad = function pad(str, num) {
|
|
@@ -657,7 +657,7 @@
|
|
|
657
657
|
var initialProps = {
|
|
658
658
|
title: canExpand ? 'Toggle Expanded' : undefined,
|
|
659
659
|
onClick: canExpand ? function (e) {
|
|
660
|
-
e.persist();
|
|
660
|
+
e.persist == null ? void 0 : e.persist();
|
|
661
661
|
instance.toggleRowExpanded(rowId);
|
|
662
662
|
} : undefined
|
|
663
663
|
};
|
|
@@ -667,7 +667,7 @@
|
|
|
667
667
|
var initialProps = {
|
|
668
668
|
title: 'Toggle All Expanded',
|
|
669
669
|
onClick: function onClick(e) {
|
|
670
|
-
e.persist();
|
|
670
|
+
e.persist == null ? void 0 : e.persist();
|
|
671
671
|
instance.toggleAllRowsExpanded();
|
|
672
672
|
}
|
|
673
673
|
};
|
|
@@ -1103,7 +1103,7 @@
|
|
|
1103
1103
|
instance.options.onGlobalFilterChange == null ? void 0 : instance.options.onGlobalFilterChange(updater, functionalUpdate(updater, instance.getState().globalFilter));
|
|
1104
1104
|
},
|
|
1105
1105
|
resetGlobalFilter: function resetGlobalFilter() {
|
|
1106
|
-
instance.setGlobalFilter(
|
|
1106
|
+
instance.setGlobalFilter(instance.initialState.globalFilter);
|
|
1107
1107
|
},
|
|
1108
1108
|
getColumnCanColumnFilter: function getColumnCanColumnFilter(columnId) {
|
|
1109
1109
|
var _ref3, _ref4, _ref5, _ref6, _ref7, _column$enableAllFilt;
|
|
@@ -1808,9 +1808,7 @@
|
|
|
1808
1808
|
return instance.getState().pagination.pageIndex > 0;
|
|
1809
1809
|
},
|
|
1810
1810
|
getCanNextPage: function getCanNextPage() {
|
|
1811
|
-
var
|
|
1812
|
-
pageIndex = _instance$getState$pa.pageIndex,
|
|
1813
|
-
pageSize = _instance$getState$pa.pageSize;
|
|
1811
|
+
var pageIndex = instance.getState().pagination.pageIndex;
|
|
1814
1812
|
var pageCount = instance.getPageCount();
|
|
1815
1813
|
|
|
1816
1814
|
if (pageCount === -1) {
|
|
@@ -1821,7 +1819,7 @@
|
|
|
1821
1819
|
return false;
|
|
1822
1820
|
}
|
|
1823
1821
|
|
|
1824
|
-
return pageIndex <
|
|
1822
|
+
return pageIndex < pageCount - 1;
|
|
1825
1823
|
},
|
|
1826
1824
|
previousPage: function previousPage() {
|
|
1827
1825
|
return instance.setPageIndex(function (old) {
|
|
@@ -2882,7 +2880,7 @@
|
|
|
2882
2880
|
var initialProps = {
|
|
2883
2881
|
title: canSort ? 'Toggle Sorting' : undefined,
|
|
2884
2882
|
onClick: canSort ? function (e) {
|
|
2885
|
-
e.persist();
|
|
2883
|
+
e.persist == null ? void 0 : e.persist();
|
|
2886
2884
|
column.toggleSorting == null ? void 0 : column.toggleSorting(undefined, column.getCanMultiSort() ? instance.options.isMultiSortEvent == null ? void 0 : instance.options.isMultiSortEvent(e) : false);
|
|
2887
2885
|
} : undefined
|
|
2888
2886
|
};
|
|
@@ -3708,7 +3706,13 @@
|
|
|
3708
3706
|
instance.setState(instance.initialState);
|
|
3709
3707
|
},
|
|
3710
3708
|
setOptions: function setOptions(updater) {
|
|
3711
|
-
|
|
3709
|
+
var newOptions = functionalUpdate(updater, instance.options);
|
|
3710
|
+
|
|
3711
|
+
if (instance.options.mergeOptions) {
|
|
3712
|
+
instance.options = instance.options.mergeOptions(defaultOptions, newOptions);
|
|
3713
|
+
} else {
|
|
3714
|
+
instance.options = buildOptions(newOptions);
|
|
3715
|
+
}
|
|
3712
3716
|
},
|
|
3713
3717
|
render: function render(template, props) {
|
|
3714
3718
|
if (typeof instance.options.render === 'function') {
|