@tanstack/table-core 8.0.0-alpha.28 → 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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.30",
|
|
5
5
|
"description": "Hooks for building lightweight, fast and extendable datagrids for React",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/react-table#readme",
|
package/src/core.tsx
CHANGED
|
@@ -84,6 +84,11 @@ export type CoreOptions<TGenerics extends AnyGenerics> = {
|
|
|
84
84
|
parent?: Row<TGenerics>
|
|
85
85
|
) => string
|
|
86
86
|
autoResetAll?: boolean
|
|
87
|
+
mergeOptions?: (
|
|
88
|
+
defaultOptions: TableFeature,
|
|
89
|
+
options: Partial<Options<TGenerics>>
|
|
90
|
+
) => Options<TGenerics>
|
|
91
|
+
meta?: TGenerics['TableMeta'] extends {} ? TGenerics['TableMeta'] : any
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
export type TableCore<TGenerics extends AnyGenerics> = {
|
|
@@ -249,9 +254,15 @@ export function createTableInstance<TGenerics extends AnyGenerics>(
|
|
|
249
254
|
instance.setState(instance.initialState)
|
|
250
255
|
},
|
|
251
256
|
setOptions: updater => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
257
|
+
const newOptions = functionalUpdate(updater, instance.options)
|
|
258
|
+
if (instance.options.mergeOptions) {
|
|
259
|
+
instance.options = instance.options.mergeOptions(
|
|
260
|
+
defaultOptions,
|
|
261
|
+
newOptions
|
|
262
|
+
)
|
|
263
|
+
} else {
|
|
264
|
+
instance.options = buildOptions(newOptions)
|
|
265
|
+
}
|
|
255
266
|
},
|
|
256
267
|
render: (template, props) => {
|
|
257
268
|
if (typeof instance.options.render === 'function') {
|
package/src/createTable.tsx
CHANGED
|
@@ -14,13 +14,9 @@ export type CreateTableFactory<TGenerics extends AnyGenerics> = <
|
|
|
14
14
|
TSubGenerics extends {
|
|
15
15
|
Row: any
|
|
16
16
|
ColumnMeta?: object
|
|
17
|
+
TableMeta?: object
|
|
17
18
|
}
|
|
18
|
-
>() => Table<
|
|
19
|
-
Overwrite<
|
|
20
|
-
TGenerics,
|
|
21
|
-
{ Row: TSubGenerics['Row']; ColumnMeta: TSubGenerics['ColumnMeta'] }
|
|
22
|
-
>
|
|
23
|
-
>
|
|
19
|
+
>() => Table<Overwrite<TGenerics, TSubGenerics>>
|
|
24
20
|
|
|
25
21
|
export type CreateTableFactoryOptions<
|
|
26
22
|
TRender extends AnyRender,
|
|
@@ -211,7 +211,7 @@ export const Expanding = {
|
|
|
211
211
|
title: canExpand ? 'Toggle Expanded' : undefined,
|
|
212
212
|
onClick: canExpand
|
|
213
213
|
? (e: MouseEvent | TouchEvent) => {
|
|
214
|
-
e.persist()
|
|
214
|
+
e.persist?.()
|
|
215
215
|
instance.toggleRowExpanded(rowId)
|
|
216
216
|
}
|
|
217
217
|
: undefined,
|
|
@@ -223,7 +223,7 @@ export const Expanding = {
|
|
|
223
223
|
const initialProps: ToggleExpandedProps = {
|
|
224
224
|
title: 'Toggle All Expanded',
|
|
225
225
|
onClick: (e: MouseEvent | TouchEvent) => {
|
|
226
|
-
e.persist()
|
|
226
|
+
e.persist?.()
|
|
227
227
|
instance.toggleAllRowsExpanded()
|
|
228
228
|
},
|
|
229
229
|
}
|
package/src/features/Filters.ts
CHANGED
|
@@ -187,7 +187,7 @@ export const Pagination = {
|
|
|
187
187
|
getCanPreviousPage: () => instance.getState().pagination.pageIndex > 0,
|
|
188
188
|
|
|
189
189
|
getCanNextPage: () => {
|
|
190
|
-
const { pageIndex
|
|
190
|
+
const { pageIndex } = instance.getState().pagination
|
|
191
191
|
|
|
192
192
|
const pageCount = instance.getPageCount()
|
|
193
193
|
|
|
@@ -199,13 +199,7 @@ export const Pagination = {
|
|
|
199
199
|
return false
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
return
|
|
203
|
-
pageIndex <
|
|
204
|
-
Math.ceil(
|
|
205
|
-
instance.getPrePaginationRowModel().rows.length / pageSize
|
|
206
|
-
) -
|
|
207
|
-
1
|
|
208
|
-
)
|
|
202
|
+
return pageIndex < pageCount - 1
|
|
209
203
|
},
|
|
210
204
|
|
|
211
205
|
previousPage: () => {
|
package/src/features/Sorting.ts
CHANGED
package/src/types.ts
CHANGED
package/src/utils.tsx
CHANGED
|
@@ -91,7 +91,7 @@ export function memo<TDeps extends readonly any[], TResult>(
|
|
|
91
91
|
|
|
92
92
|
return () => {
|
|
93
93
|
let depTime: number
|
|
94
|
-
if (opts.key && opts.debug) depTime =
|
|
94
|
+
if (opts.key && opts.debug) depTime = Date.now()
|
|
95
95
|
|
|
96
96
|
const newDeps = getDeps()
|
|
97
97
|
|
|
@@ -102,17 +102,16 @@ export function memo<TDeps extends readonly any[], TResult>(
|
|
|
102
102
|
if (depsChanged) {
|
|
103
103
|
let oldResult = result
|
|
104
104
|
let resultTime: number
|
|
105
|
-
if (opts.key && opts.debug) resultTime =
|
|
105
|
+
if (opts.key && opts.debug) resultTime = Date.now()
|
|
106
106
|
result = fn(...newDeps)
|
|
107
107
|
deps = newDeps
|
|
108
108
|
opts?.onChange?.(result, oldResult)
|
|
109
109
|
|
|
110
110
|
if (opts.key && opts.debug) {
|
|
111
111
|
if (opts?.debug()) {
|
|
112
|
-
const depEndTime =
|
|
113
|
-
Math.round((performance.now() - depTime!) * 100) / 100
|
|
112
|
+
const depEndTime = Math.round((Date.now() - depTime!) * 100) / 100
|
|
114
113
|
const resultEndTime =
|
|
115
|
-
Math.round((
|
|
114
|
+
Math.round((Date.now() - resultTime!) * 100) / 100
|
|
116
115
|
const resultFpsPercentage = resultEndTime / 16
|
|
117
116
|
|
|
118
117
|
const pad = (str: number | string, num: number) => {
|