@tanstack/table-core 8.11.1 → 8.11.3
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/LICENSE +21 -0
- package/build/lib/aggregationFns.js +9 -11
- package/build/lib/aggregationFns.js.map +1 -1
- package/build/lib/columnHelper.js +9 -11
- package/build/lib/columnHelper.js.map +1 -1
- package/build/lib/core/cell.js +9 -11
- package/build/lib/core/cell.js.map +1 -1
- package/build/lib/core/column.js +9 -11
- package/build/lib/core/column.js.map +1 -1
- package/build/lib/core/headers.js +9 -11
- package/build/lib/core/headers.js.map +1 -1
- package/build/lib/core/row.js +9 -11
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/core/table.js +17 -15
- package/build/lib/core/table.js.map +1 -1
- package/build/lib/features/ColumnSizing.d.ts +1 -1
- package/build/lib/features/ColumnSizing.js +9 -11
- package/build/lib/features/ColumnSizing.js.map +1 -1
- package/build/lib/features/Expanding.js +9 -11
- package/build/lib/features/Expanding.js.map +1 -1
- package/build/lib/features/Filters.js +9 -11
- package/build/lib/features/Filters.js.map +1 -1
- package/build/lib/features/Grouping.js +9 -11
- package/build/lib/features/Grouping.js.map +1 -1
- package/build/lib/features/Ordering.js +9 -11
- package/build/lib/features/Ordering.js.map +1 -1
- package/build/lib/features/Pagination.js +9 -11
- package/build/lib/features/Pagination.js.map +1 -1
- package/build/lib/features/Pinning.js +9 -11
- package/build/lib/features/Pinning.js.map +1 -1
- package/build/lib/features/RowSelection.js +10 -12
- package/build/lib/features/RowSelection.js.map +1 -1
- package/build/lib/features/Sorting.js +9 -11
- package/build/lib/features/Sorting.js.map +1 -1
- package/build/lib/features/Visibility.js +9 -11
- package/build/lib/features/Visibility.js.map +1 -1
- package/build/lib/filterFns.js +9 -11
- package/build/lib/filterFns.js.map +1 -1
- package/build/lib/index.esm.js +18 -14
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +9 -11
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +18 -14
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/sortingFns.js +9 -11
- package/build/lib/sortingFns.js.map +1 -1
- package/build/lib/utils/filterRowsUtils.js +9 -11
- package/build/lib/utils/filterRowsUtils.js.map +1 -1
- package/build/lib/utils/getCoreRowModel.js +9 -11
- package/build/lib/utils/getCoreRowModel.js.map +1 -1
- package/build/lib/utils/getExpandedRowModel.js +9 -11
- package/build/lib/utils/getExpandedRowModel.js.map +1 -1
- package/build/lib/utils/getFacetedMinMaxValues.js +9 -11
- package/build/lib/utils/getFacetedMinMaxValues.js.map +1 -1
- package/build/lib/utils/getFacetedRowModel.js +9 -11
- package/build/lib/utils/getFacetedRowModel.js.map +1 -1
- package/build/lib/utils/getFacetedUniqueValues.js +9 -11
- package/build/lib/utils/getFacetedUniqueValues.js.map +1 -1
- package/build/lib/utils/getFilteredRowModel.js +9 -11
- package/build/lib/utils/getFilteredRowModel.js.map +1 -1
- package/build/lib/utils/getGroupedRowModel.js +9 -11
- package/build/lib/utils/getGroupedRowModel.js.map +1 -1
- package/build/lib/utils/getPaginationRowModel.js +9 -11
- package/build/lib/utils/getPaginationRowModel.js.map +1 -1
- package/build/lib/utils/getSortedRowModel.js +9 -11
- package/build/lib/utils/getSortedRowModel.js.map +1 -1
- package/build/lib/utils.js +9 -11
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +17 -15
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +10 -10
- package/build/umd/index.production.js.map +1 -1
- package/package.json +13 -3
- package/src/aggregationFns.ts +0 -0
- package/src/columnHelper.ts +3 -3
- package/src/core/row.ts +2 -1
- package/src/core/table.ts +10 -5
- package/src/features/ColumnSizing.ts +11 -6
- package/src/features/Filters.ts +9 -9
- package/src/features/Grouping.ts +7 -5
- package/src/features/RowSelection.ts +1 -1
- package/src/features/Sorting.ts +3 -3
- package/src/index.ts +0 -0
- package/src/types.ts +4 -2
- package/src/utils/getSortedRowModel.ts +5 -5
- package/src/utils.ts +14 -14
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.11.
|
|
4
|
+
"version": "8.11.3",
|
|
5
5
|
"description": "Headless UI for building powerful tables & datagrids for TS/JS.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/table#readme",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"type": "github",
|
|
25
25
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
26
26
|
},
|
|
27
|
+
"type": "commonjs",
|
|
27
28
|
"module": "build/lib/index.esm.js",
|
|
28
29
|
"main": "build/lib/index.js",
|
|
29
30
|
"types": "build/lib/index.d.ts",
|
|
@@ -43,5 +44,14 @@
|
|
|
43
44
|
"build/lib/*",
|
|
44
45
|
"build/umd/*",
|
|
45
46
|
"src"
|
|
46
|
-
]
|
|
47
|
-
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"clean": "rimraf ./build",
|
|
50
|
+
"test:lib": "vitest",
|
|
51
|
+
"test:lib:dev": "pnpm test:lib --watch",
|
|
52
|
+
"test:types": "tsc --noEmit",
|
|
53
|
+
"build": "pnpm build:rollup && pnpm build:types",
|
|
54
|
+
"build:rollup": "rollup --config rollup.config.mjs",
|
|
55
|
+
"build:types": "tsc --emitDeclarationOnly"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/aggregationFns.ts
CHANGED
|
File without changes
|
package/src/columnHelper.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
IdentifiedColumnDef,
|
|
7
7
|
RowData,
|
|
8
8
|
} from './types'
|
|
9
|
-
import { DeepKeys, DeepValue
|
|
9
|
+
import { DeepKeys, DeepValue } from './utils'
|
|
10
10
|
|
|
11
11
|
// type Person = {
|
|
12
12
|
// firstName: string
|
|
@@ -55,8 +55,8 @@ export type ColumnHelper<TData extends RowData> = {
|
|
|
55
55
|
TValue extends TAccessor extends AccessorFn<TData, infer TReturn>
|
|
56
56
|
? TReturn
|
|
57
57
|
: TAccessor extends DeepKeys<TData>
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
? DeepValue<TData, TAccessor>
|
|
59
|
+
: never,
|
|
60
60
|
>(
|
|
61
61
|
accessor: TAccessor,
|
|
62
62
|
column: TAccessor extends AccessorFn<TData>
|
package/src/core/row.ts
CHANGED
|
@@ -154,7 +154,8 @@ export const createRow = <TData extends RowData>(
|
|
|
154
154
|
row.getValue(columnId) ?? table.options.renderFallbackValue,
|
|
155
155
|
subRows: subRows ?? [],
|
|
156
156
|
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
157
|
-
getParentRow: () =>
|
|
157
|
+
getParentRow: () =>
|
|
158
|
+
row.parentId ? table.getRow(row.parentId, true) : undefined,
|
|
158
159
|
getParentRows: () => {
|
|
159
160
|
let parentRows: Row<TData>[] = []
|
|
160
161
|
let currentRow = row
|
package/src/core/table.ts
CHANGED
|
@@ -374,15 +374,20 @@ export function createTable<TData extends RowData>(
|
|
|
374
374
|
getRowModel: () => {
|
|
375
375
|
return table.getPaginationRowModel()
|
|
376
376
|
},
|
|
377
|
+
//in next version, we should just pass in the row model as the optional 2nd arg
|
|
377
378
|
getRow: (id: string, searchAll?: boolean) => {
|
|
378
|
-
|
|
379
|
-
.
|
|
379
|
+
let row = (
|
|
380
|
+
searchAll ? table.getPrePaginationRowModel() : table.getRowModel()
|
|
381
|
+
).rowsById[id]
|
|
380
382
|
|
|
381
383
|
if (!row) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
+
row = table.getCoreRowModel().rowsById[id]
|
|
385
|
+
if (!row) {
|
|
386
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
387
|
+
throw new Error(`getRow could not find row with ID: ${id}`)
|
|
388
|
+
}
|
|
389
|
+
throw new Error()
|
|
384
390
|
}
|
|
385
|
-
throw new Error()
|
|
386
391
|
}
|
|
387
392
|
|
|
388
393
|
return row
|
|
@@ -40,7 +40,7 @@ export interface ColumnSizingOptions {
|
|
|
40
40
|
enableColumnResizing?: boolean
|
|
41
41
|
/**
|
|
42
42
|
* Enables or disables right-to-left support for resizing the column. defaults to 'ltr'.
|
|
43
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#
|
|
43
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#columnResizeDirection)
|
|
44
44
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
45
45
|
*/
|
|
46
46
|
columnResizeDirection?: ColumnResizeDirection
|
|
@@ -60,7 +60,10 @@ export interface ColumnSizingOptions {
|
|
|
60
60
|
|
|
61
61
|
export type ColumnSizingDefaultOptions = Pick<
|
|
62
62
|
ColumnSizingOptions,
|
|
63
|
-
|
|
63
|
+
| 'columnResizeMode'
|
|
64
|
+
| 'onColumnSizingChange'
|
|
65
|
+
| 'onColumnSizingInfoChange'
|
|
66
|
+
| 'columnResizeDirection'
|
|
64
67
|
>
|
|
65
68
|
|
|
66
69
|
export interface ColumnSizingInstance {
|
|
@@ -258,8 +261,8 @@ export const ColumnSizing: TableFeature = {
|
|
|
258
261
|
const columns = !position
|
|
259
262
|
? table.getVisibleLeafColumns()
|
|
260
263
|
: position === 'left'
|
|
261
|
-
|
|
262
|
-
|
|
264
|
+
? table.getLeftVisibleLeafColumns()
|
|
265
|
+
: table.getRightVisibleLeafColumns()
|
|
263
266
|
|
|
264
267
|
const index = columns.findIndex(d => d.id === column.id)
|
|
265
268
|
|
|
@@ -355,8 +358,10 @@ export const ColumnSizing: TableFeature = {
|
|
|
355
358
|
}
|
|
356
359
|
|
|
357
360
|
table.setColumnSizingInfo(old => {
|
|
358
|
-
const deltaDirection =
|
|
359
|
-
|
|
361
|
+
const deltaDirection =
|
|
362
|
+
table.options.columnResizeDirection === 'rtl' ? -1 : 1
|
|
363
|
+
const deltaOffset =
|
|
364
|
+
(clientXPos - (old?.startOffset ?? 0)) * deltaDirection
|
|
360
365
|
const deltaPercentage = Math.max(
|
|
361
366
|
deltaOffset / (old?.startSize ?? 0),
|
|
362
367
|
-0.999999
|
package/src/features/Filters.ts
CHANGED
|
@@ -234,7 +234,7 @@ interface FiltersOptionsBase<TData extends RowData> {
|
|
|
234
234
|
enableGlobalFilter?: boolean
|
|
235
235
|
/**
|
|
236
236
|
* If provided, this function will be called with the column and should return `true` or `false` to indicate whether this column should be used for global filtering.
|
|
237
|
-
*
|
|
237
|
+
*
|
|
238
238
|
* This is useful if the column can contain data that is not `string` or `number` (i.e. `undefined`).
|
|
239
239
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getcolumncanglobalfilter)
|
|
240
240
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
@@ -434,10 +434,10 @@ export const Filters: TableFeature = {
|
|
|
434
434
|
return isFunction(column.columnDef.filterFn)
|
|
435
435
|
? column.columnDef.filterFn
|
|
436
436
|
: column.columnDef.filterFn === 'auto'
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
437
|
+
? column.getAutoFilterFn()
|
|
438
|
+
: // @ts-ignore
|
|
439
|
+
table.options.filterFns?.[column.columnDef.filterFn as string] ??
|
|
440
|
+
filterFns[column.columnDef.filterFn as BuiltInFilterFn]
|
|
441
441
|
}
|
|
442
442
|
column.getCanFilter = () => {
|
|
443
443
|
return (
|
|
@@ -556,10 +556,10 @@ export const Filters: TableFeature = {
|
|
|
556
556
|
return isFunction(globalFilterFn)
|
|
557
557
|
? globalFilterFn
|
|
558
558
|
: globalFilterFn === 'auto'
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
559
|
+
? table.getGlobalAutoFilterFn()
|
|
560
|
+
: // @ts-ignore
|
|
561
|
+
table.options.filterFns?.[globalFilterFn as string] ??
|
|
562
|
+
filterFns[globalFilterFn as BuiltInFilterFn]
|
|
563
563
|
}
|
|
564
564
|
|
|
565
565
|
table.setColumnFilters = (updater: Updater<ColumnFiltersState>) => {
|
package/src/features/Grouping.ts
CHANGED
|
@@ -326,11 +326,13 @@ export const Grouping: TableFeature = {
|
|
|
326
326
|
return isFunction(column.columnDef.aggregationFn)
|
|
327
327
|
? column.columnDef.aggregationFn
|
|
328
328
|
: column.columnDef.aggregationFn === 'auto'
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
329
|
+
? column.getAutoAggregationFn()
|
|
330
|
+
: table.options.aggregationFns?.[
|
|
331
|
+
column.columnDef.aggregationFn as string
|
|
332
|
+
] ??
|
|
333
|
+
aggregationFns[
|
|
334
|
+
column.columnDef.aggregationFn as BuiltInAggregationFn
|
|
335
|
+
]
|
|
334
336
|
}
|
|
335
337
|
},
|
|
336
338
|
|
package/src/features/Sorting.ts
CHANGED
|
@@ -348,9 +348,9 @@ export const Sorting: TableFeature = {
|
|
|
348
348
|
return isFunction(column.columnDef.sortingFn)
|
|
349
349
|
? column.columnDef.sortingFn
|
|
350
350
|
: column.columnDef.sortingFn === 'auto'
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
? column.getAutoSortingFn()
|
|
352
|
+
: table.options.sortingFns?.[column.columnDef.sortingFn as string] ??
|
|
353
|
+
sortingFns[column.columnDef.sortingFn as BuiltInSortingFn]
|
|
354
354
|
}
|
|
355
355
|
column.toggleSorting = (desc, multi) => {
|
|
356
356
|
// if (column.columns.length) {
|
package/src/index.ts
CHANGED
|
File without changes
|
package/src/types.ts
CHANGED
|
@@ -265,8 +265,10 @@ export type AccessorFnColumnDef<
|
|
|
265
265
|
TValue = unknown,
|
|
266
266
|
> = AccessorFnColumnDefBase<TData, TValue> & ColumnIdentifiers<TData, TValue>
|
|
267
267
|
|
|
268
|
-
export interface AccessorKeyColumnDefBase<
|
|
269
|
-
extends
|
|
268
|
+
export interface AccessorKeyColumnDefBase<
|
|
269
|
+
TData extends RowData,
|
|
270
|
+
TValue = unknown,
|
|
271
|
+
> extends ColumnDefBase<TData, TValue> {
|
|
270
272
|
id?: string
|
|
271
273
|
accessorKey: (string & {}) | keyof TData
|
|
272
274
|
}
|
|
@@ -18,8 +18,8 @@ export function getSortedRowModel<TData extends RowData>(): (
|
|
|
18
18
|
const sortedFlatRows: Row<TData>[] = []
|
|
19
19
|
|
|
20
20
|
// Filter out sortings that correspond to non existing columns
|
|
21
|
-
const availableSorting = sortingState.filter(
|
|
22
|
-
table.getColumn(sort.id)?.getCanSort()
|
|
21
|
+
const availableSorting = sortingState.filter(
|
|
22
|
+
sort => table.getColumn(sort.id)?.getCanSort()
|
|
23
23
|
)
|
|
24
24
|
|
|
25
25
|
const columnInfoById: Record<
|
|
@@ -45,7 +45,7 @@ export function getSortedRowModel<TData extends RowData>(): (
|
|
|
45
45
|
const sortData = (rows: Row<TData>[]) => {
|
|
46
46
|
// This will also perform a stable sorting using the row index
|
|
47
47
|
// if needed.
|
|
48
|
-
const sortedData = rows.map(row => ({...row}))
|
|
48
|
+
const sortedData = rows.map(row => ({ ...row }))
|
|
49
49
|
|
|
50
50
|
sortedData.sort((rowA, rowB) => {
|
|
51
51
|
for (let i = 0; i < availableSorting.length; i += 1) {
|
|
@@ -68,8 +68,8 @@ export function getSortedRowModel<TData extends RowData>(): (
|
|
|
68
68
|
aUndefined && bUndefined
|
|
69
69
|
? 0
|
|
70
70
|
: aUndefined
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
? columnInfo.sortUndefined
|
|
72
|
+
: -columnInfo.sortUndefined
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
package/src/utils.ts
CHANGED
|
@@ -40,24 +40,24 @@ type AllowedIndexes<
|
|
|
40
40
|
> = Tuple extends readonly []
|
|
41
41
|
? Keys
|
|
42
42
|
: Tuple extends readonly [infer _, ...infer Tail]
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
? AllowedIndexes<Tail, Keys | Tail['length']>
|
|
44
|
+
: Keys
|
|
45
45
|
|
|
46
46
|
export type DeepKeys<T, TDepth extends any[] = []> = TDepth['length'] extends 5
|
|
47
47
|
? never
|
|
48
48
|
: unknown extends T
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
? string
|
|
50
|
+
: object extends T
|
|
51
|
+
? string
|
|
52
|
+
: T extends readonly any[] & IsTuple<T>
|
|
53
|
+
? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>, TDepth>
|
|
54
|
+
: T extends any[]
|
|
55
|
+
? DeepKeys<T[number], [...TDepth, any]>
|
|
56
|
+
: T extends Date
|
|
57
|
+
? never
|
|
58
|
+
: T extends object
|
|
59
|
+
? (keyof T & string) | DeepKeysPrefix<T, keyof T, TDepth>
|
|
60
|
+
: never
|
|
61
61
|
|
|
62
62
|
type DeepKeysPrefix<
|
|
63
63
|
T,
|