@tanstack/table-core 8.5.20 → 8.5.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/columnHelper.js.map +1 -1
- package/build/cjs/core/cell.js.map +1 -1
- package/build/cjs/core/column.js.map +1 -1
- package/build/cjs/core/headers.js.map +1 -1
- package/build/cjs/core/row.js.map +1 -1
- package/build/cjs/core/table.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- 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/Ordering.js.map +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/utils.js +4 -0
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +4 -0
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +312 -312
- package/build/types/index.d.ts +199 -253
- package/build/umd/index.development.js +4 -0
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/columnHelper.ts +20 -27
- package/src/core/cell.ts +3 -3
- package/src/core/column.ts +5 -2
- package/src/core/headers.ts +5 -5
- package/src/core/row.ts +1 -1
- package/src/core/table.ts +7 -6
- package/src/features/ColumnSizing.ts +8 -8
- package/src/features/Expanding.ts +4 -4
- package/src/features/Filters.ts +11 -17
- package/src/features/Grouping.ts +10 -16
- package/src/features/Ordering.ts +5 -5
- package/src/features/Pagination.ts +6 -6
- package/src/features/Pinning.ts +8 -8
- package/src/features/RowSelection.ts +4 -4
- package/src/features/Sorting.ts +9 -15
- package/src/features/Visibility.ts +7 -7
- package/src/types.ts +110 -133
- package/src/utils.ts +46 -59
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.5.
|
|
4
|
+
"version": "8.5.21",
|
|
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",
|
package/src/columnHelper.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AccessorColumnDef,
|
|
3
2
|
AccessorFn,
|
|
3
|
+
ColumnDef,
|
|
4
4
|
DisplayColumnDef,
|
|
5
5
|
GroupColumnDef,
|
|
6
6
|
IdentifiedColumnDef,
|
|
7
7
|
RowData,
|
|
8
8
|
} from './types'
|
|
9
|
-
import { DeepValue } from './utils'
|
|
9
|
+
import { DeepKeys, DeepValue, RequiredKeys } from './utils'
|
|
10
10
|
|
|
11
11
|
// type Person = {
|
|
12
12
|
// firstName: string
|
|
@@ -49,29 +49,22 @@ import { DeepValue } from './utils'
|
|
|
49
49
|
// cell: info => info.getValue(),
|
|
50
50
|
// })
|
|
51
51
|
|
|
52
|
-
type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
) =>
|
|
68
|
-
? never
|
|
69
|
-
: AccessorColumnDef<TData, AccessorType<TData, TAccessor>>
|
|
70
|
-
|
|
71
|
-
export interface ColumnHelper<TData extends RowData> {
|
|
72
|
-
accessor: Accessor<TData>
|
|
73
|
-
display: (column: DisplayColumnDef<TData>) => DisplayColumnDef<TData>
|
|
74
|
-
group: (column: GroupColumnDef<TData>) => GroupColumnDef<TData>
|
|
52
|
+
export type ColumnHelper<TData extends RowData> = {
|
|
53
|
+
accessor: <
|
|
54
|
+
TAccessor extends AccessorFn<TData> | DeepKeys<TData>,
|
|
55
|
+
TValue extends TAccessor extends AccessorFn<TData, infer TReturn>
|
|
56
|
+
? TReturn
|
|
57
|
+
: TAccessor extends DeepKeys<TData>
|
|
58
|
+
? DeepValue<TData, TAccessor>
|
|
59
|
+
: never
|
|
60
|
+
>(
|
|
61
|
+
accessor: TAccessor,
|
|
62
|
+
column: TAccessor extends AccessorFn<TData>
|
|
63
|
+
? DisplayColumnDef<TData, TValue>
|
|
64
|
+
: IdentifiedColumnDef<TData, TValue>
|
|
65
|
+
) => ColumnDef<TData, TValue>
|
|
66
|
+
display: (column: DisplayColumnDef<TData>) => ColumnDef<TData, unknown>
|
|
67
|
+
group: (column: GroupColumnDef<TData>) => ColumnDef<TData, unknown>
|
|
75
68
|
}
|
|
76
69
|
|
|
77
70
|
export function createColumnHelper<
|
|
@@ -89,7 +82,7 @@ export function createColumnHelper<
|
|
|
89
82
|
accessorKey: accessor,
|
|
90
83
|
}
|
|
91
84
|
},
|
|
92
|
-
display: column => column as
|
|
93
|
-
group: column => column as
|
|
85
|
+
display: column => column as ColumnDef<TData, unknown>,
|
|
86
|
+
group: column => column as ColumnDef<TData, unknown>,
|
|
94
87
|
}
|
|
95
88
|
}
|
package/src/core/cell.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RowData, Cell, Column, Row, Table } from '../types'
|
|
2
2
|
import { Getter, memo } from '../utils'
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export type CellContext<TData extends RowData, TValue> = {
|
|
5
5
|
table: Table<TData>
|
|
6
6
|
column: Column<TData, TValue>
|
|
7
7
|
row: Row<TData>
|
|
@@ -10,7 +10,7 @@ export interface CellContext<TData extends RowData, TValue> {
|
|
|
10
10
|
renderValue: Getter<TValue | null>
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export type CoreCell<TData extends RowData, TValue> = {
|
|
14
14
|
id: string
|
|
15
15
|
getValue: CellContext<TData, TValue>['getValue']
|
|
16
16
|
renderValue: CellContext<TData, TValue>['renderValue']
|
|
@@ -24,7 +24,7 @@ export function createCell<TData extends RowData, TValue>(
|
|
|
24
24
|
row: Row<TData>,
|
|
25
25
|
column: Column<TData, TValue>,
|
|
26
26
|
columnId: string
|
|
27
|
-
)
|
|
27
|
+
) {
|
|
28
28
|
const getRenderValue = () =>
|
|
29
29
|
cell.getValue() ?? table.options.renderFallbackValue
|
|
30
30
|
|
package/src/core/column.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { TaggedTemplateExpression } from '@babel/types'
|
|
1
2
|
import {
|
|
2
3
|
Column,
|
|
3
4
|
Table,
|
|
4
5
|
AccessorFn,
|
|
5
6
|
ColumnDef,
|
|
7
|
+
ColumnDefTemplate,
|
|
6
8
|
RowData,
|
|
9
|
+
ColumnMeta,
|
|
7
10
|
ColumnDefResolved,
|
|
8
11
|
} from '../types'
|
|
9
12
|
import { memo } from '../utils'
|
|
10
13
|
|
|
11
|
-
export
|
|
14
|
+
export type CoreColumn<TData extends RowData, TValue> = {
|
|
12
15
|
id: string
|
|
13
16
|
depth: number
|
|
14
17
|
accessorFn?: AccessorFn<TData, TValue>
|
|
@@ -24,7 +27,7 @@ export function createColumn<TData extends RowData, TValue>(
|
|
|
24
27
|
columnDef: ColumnDef<TData, TValue>,
|
|
25
28
|
depth: number,
|
|
26
29
|
parent?: Column<TData, TValue>
|
|
27
|
-
)
|
|
30
|
+
) {
|
|
28
31
|
const defaultColumn = table._getDefaultColumnDef()
|
|
29
32
|
|
|
30
33
|
const resolvedColumnDef = {
|
package/src/core/headers.ts
CHANGED
|
@@ -2,19 +2,19 @@ import { RowData, Column, Header, HeaderGroup, Table } from '../types'
|
|
|
2
2
|
import { memo } from '../utils'
|
|
3
3
|
import { TableFeature } from './table'
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export type CoreHeaderGroup<TData extends RowData> = {
|
|
6
6
|
id: string
|
|
7
7
|
depth: number
|
|
8
8
|
headers: Header<TData, unknown>[]
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export type HeaderContext<TData, TValue> = {
|
|
12
12
|
table: Table<TData>
|
|
13
13
|
header: Header<TData, TValue>
|
|
14
14
|
column: Column<TData, TValue>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export type CoreHeader<TData extends RowData, TValue> = {
|
|
18
18
|
id: string
|
|
19
19
|
index: number
|
|
20
20
|
depth: number
|
|
@@ -29,7 +29,7 @@ export interface CoreHeader<TData extends RowData, TValue> {
|
|
|
29
29
|
getContext: () => HeaderContext<TData, TValue>
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export
|
|
32
|
+
export type HeadersInstance<TData extends RowData> = {
|
|
33
33
|
getHeaderGroups: () => HeaderGroup<TData>[]
|
|
34
34
|
getLeftHeaderGroups: () => HeaderGroup<TData>[]
|
|
35
35
|
getCenterHeaderGroups: () => HeaderGroup<TData>[]
|
|
@@ -63,7 +63,7 @@ function createHeader<TData extends RowData, TValue>(
|
|
|
63
63
|
index: number
|
|
64
64
|
depth: number
|
|
65
65
|
}
|
|
66
|
-
)
|
|
66
|
+
) {
|
|
67
67
|
const id = options.id ?? column.id
|
|
68
68
|
|
|
69
69
|
let header: CoreHeader<TData, TValue> = {
|
package/src/core/row.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { RowData, Cell, Row, Table } from '../types'
|
|
|
2
2
|
import { flattenBy, memo } from '../utils'
|
|
3
3
|
import { createCell } from './cell'
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export type CoreRow<TData extends RowData> = {
|
|
6
6
|
id: string
|
|
7
7
|
index: number
|
|
8
8
|
original: TData
|
package/src/core/table.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { functionalUpdate, memo, RequiredKeys } from '../utils'
|
|
1
|
+
import { flattenBy, functionalUpdate, memo, RequiredKeys } from '../utils'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
Updater,
|
|
5
5
|
TableOptionsResolved,
|
|
6
6
|
TableState,
|
|
7
7
|
Table,
|
|
8
|
+
ColumnDefTemplate,
|
|
8
9
|
InitialTableState,
|
|
9
10
|
Row,
|
|
10
11
|
Column,
|
|
@@ -25,7 +26,7 @@ import { Headers } from './headers'
|
|
|
25
26
|
import { ColumnSizing } from '../features/ColumnSizing'
|
|
26
27
|
import { Expanding } from '../features/Expanding'
|
|
27
28
|
import { Filters } from '../features/Filters'
|
|
28
|
-
import { Grouping } from '../features/Grouping'
|
|
29
|
+
import { Grouping, GroupingColumnDef } from '../features/Grouping'
|
|
29
30
|
import { Ordering } from '../features/Ordering'
|
|
30
31
|
import { Pagination } from '../features/Pagination'
|
|
31
32
|
import { Pinning } from '../features/Pinning'
|
|
@@ -33,7 +34,7 @@ import { RowSelection } from '../features/RowSelection'
|
|
|
33
34
|
import { Sorting } from '../features/Sorting'
|
|
34
35
|
import { Visibility } from '../features/Visibility'
|
|
35
36
|
|
|
36
|
-
export
|
|
37
|
+
export type TableFeature = {
|
|
37
38
|
getDefaultOptions?: (table: any) => any
|
|
38
39
|
getInitialState?: (initialState?: InitialTableState) => any
|
|
39
40
|
createTable?: (table: any) => any
|
|
@@ -60,9 +61,9 @@ const features = [
|
|
|
60
61
|
|
|
61
62
|
//
|
|
62
63
|
|
|
63
|
-
export
|
|
64
|
+
export type CoreTableState = {}
|
|
64
65
|
|
|
65
|
-
export
|
|
66
|
+
export type CoreOptions<TData extends RowData> = {
|
|
66
67
|
data: TData[]
|
|
67
68
|
state: Partial<TableState>
|
|
68
69
|
onStateChange: (updater: Updater<TableState>) => void
|
|
@@ -86,7 +87,7 @@ export interface CoreOptions<TData extends RowData> {
|
|
|
86
87
|
renderFallbackValue: any
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
export
|
|
90
|
+
export type CoreInstance<TData extends RowData> = {
|
|
90
91
|
initialState: TableState
|
|
91
92
|
reset: () => void
|
|
92
93
|
options: RequiredKeys<TableOptionsResolved<TData>, 'state'>
|
|
@@ -5,14 +5,14 @@ import { ColumnPinningPosition } from './Pinning'
|
|
|
5
5
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export type ColumnSizingTableState = {
|
|
9
9
|
columnSizing: ColumnSizingState
|
|
10
10
|
columnSizingInfo: ColumnSizingInfoState
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export type ColumnSizingState = Record<string, number>
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export type ColumnSizingInfoState = {
|
|
16
16
|
startOffset: null | number
|
|
17
17
|
startSize: null | number
|
|
18
18
|
deltaOffset: null | number
|
|
@@ -23,20 +23,20 @@ export interface ColumnSizingInfoState {
|
|
|
23
23
|
|
|
24
24
|
export type ColumnResizeMode = 'onChange' | 'onEnd'
|
|
25
25
|
|
|
26
|
-
export
|
|
26
|
+
export type ColumnSizingOptions = {
|
|
27
27
|
enableColumnResizing?: boolean
|
|
28
28
|
columnResizeMode?: ColumnResizeMode
|
|
29
29
|
onColumnSizingChange?: OnChangeFn<ColumnSizingState>
|
|
30
30
|
onColumnSizingInfoChange?: OnChangeFn<ColumnSizingInfoState>
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export
|
|
33
|
+
export type ColumnSizingDefaultOptions = {
|
|
34
34
|
columnResizeMode: ColumnResizeMode
|
|
35
35
|
onColumnSizingChange: OnChangeFn<ColumnSizingState>
|
|
36
36
|
onColumnSizingInfoChange: OnChangeFn<ColumnSizingInfoState>
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export
|
|
39
|
+
export type ColumnSizingInstance = {
|
|
40
40
|
setColumnSizing: (updater: Updater<ColumnSizingState>) => void
|
|
41
41
|
setColumnSizingInfo: (updater: Updater<ColumnSizingInfoState>) => void
|
|
42
42
|
resetColumnSizing: (defaultState?: boolean) => void
|
|
@@ -47,14 +47,14 @@ export interface ColumnSizingInstance {
|
|
|
47
47
|
getRightTotalSize: () => number
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export
|
|
50
|
+
export type ColumnSizingColumnDef = {
|
|
51
51
|
enableResizing?: boolean
|
|
52
52
|
size?: number
|
|
53
53
|
minSize?: number
|
|
54
54
|
maxSize?: number
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export
|
|
57
|
+
export type ColumnSizingColumn = {
|
|
58
58
|
getSize: () => number
|
|
59
59
|
getStart: (position?: ColumnPinningPosition) => number
|
|
60
60
|
getCanResize: () => boolean
|
|
@@ -62,7 +62,7 @@ export interface ColumnSizingColumn {
|
|
|
62
62
|
resetSize: () => void
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export
|
|
65
|
+
export type ColumnSizingHeader = {
|
|
66
66
|
getSize: () => number
|
|
67
67
|
getStart: (position?: ColumnPinningPosition) => number
|
|
68
68
|
getResizeHandler: () => (event: unknown) => void
|
|
@@ -5,18 +5,18 @@ import { makeStateUpdater } from '../utils'
|
|
|
5
5
|
|
|
6
6
|
export type ExpandedStateList = Record<string, boolean>
|
|
7
7
|
export type ExpandedState = true | Record<string, boolean>
|
|
8
|
-
export
|
|
8
|
+
export type ExpandedTableState = {
|
|
9
9
|
expanded: ExpandedState
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export type ExpandedRow = {
|
|
13
13
|
toggleExpanded: (expanded?: boolean) => void
|
|
14
14
|
getIsExpanded: () => boolean
|
|
15
15
|
getCanExpand: () => boolean
|
|
16
16
|
getToggleExpandedHandler: () => () => void
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export
|
|
19
|
+
export type ExpandedOptions<TData extends RowData> = {
|
|
20
20
|
manualExpanding?: boolean
|
|
21
21
|
onExpandedChange?: OnChangeFn<ExpandedState>
|
|
22
22
|
autoResetExpanded?: boolean
|
|
@@ -27,7 +27,7 @@ export interface ExpandedOptions<TData extends RowData> {
|
|
|
27
27
|
paginateExpandedRows?: boolean
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export
|
|
30
|
+
export type ExpandedInstance<TData extends RowData> = {
|
|
31
31
|
_autoResetExpanded: () => void
|
|
32
32
|
setExpanded: (updater: Updater<ExpandedState>) => void
|
|
33
33
|
toggleAllRowsExpanded: (expanded?: boolean) => void
|
package/src/features/Filters.ts
CHANGED
|
@@ -13,25 +13,25 @@ import {
|
|
|
13
13
|
} from '../types'
|
|
14
14
|
import { functionalUpdate, isFunction, makeStateUpdater } from '../utils'
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export type FiltersTableState = {
|
|
17
17
|
columnFilters: ColumnFiltersState
|
|
18
18
|
globalFilter: any
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export type ColumnFiltersState = ColumnFilter[]
|
|
22
22
|
|
|
23
|
-
export
|
|
23
|
+
export type ColumnFilter = {
|
|
24
24
|
id: string
|
|
25
25
|
value: unknown
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export
|
|
28
|
+
export type ResolvedColumnFilter<TData extends RowData> = {
|
|
29
29
|
id: string
|
|
30
30
|
resolvedValue: unknown
|
|
31
31
|
filterFn: FilterFn<TData>
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export
|
|
34
|
+
export type FilterFn<TData extends RowData> = {
|
|
35
35
|
(
|
|
36
36
|
row: Row<TData>,
|
|
37
37
|
columnId: string,
|
|
@@ -64,13 +64,13 @@ export type FilterFnOption<TData extends RowData> =
|
|
|
64
64
|
| keyof FilterFns
|
|
65
65
|
| FilterFn<TData>
|
|
66
66
|
|
|
67
|
-
export
|
|
67
|
+
export type FiltersColumnDef<TData extends RowData> = {
|
|
68
68
|
filterFn?: FilterFnOption<TData>
|
|
69
69
|
enableColumnFilter?: boolean
|
|
70
70
|
enableGlobalFilter?: boolean
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export
|
|
73
|
+
export type FiltersColumn<TData extends RowData> = {
|
|
74
74
|
getAutoFilterFn: () => FilterFn<TData> | undefined
|
|
75
75
|
getFilterFn: () => FilterFn<TData> | undefined
|
|
76
76
|
setFilterValue: (updater: Updater<any>) => void
|
|
@@ -87,12 +87,12 @@ export interface FiltersColumn<TData extends RowData> {
|
|
|
87
87
|
_getFacetedMinMaxValues?: () => undefined | [number, number]
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
export
|
|
90
|
+
export type FiltersRow<TData extends RowData> = {
|
|
91
91
|
columnFilters: Record<string, boolean>
|
|
92
92
|
columnFiltersMeta: Record<string, FilterMeta>
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
export type FiltersOptions<TData extends RowData> = {
|
|
96
96
|
enableFilters?: boolean
|
|
97
97
|
manualFiltering?: boolean
|
|
98
98
|
filterFromLeafRows?: boolean
|
|
@@ -121,21 +121,15 @@ interface FiltersOptionsBase<TData extends RowData> {
|
|
|
121
121
|
table: Table<TData>,
|
|
122
122
|
columnId: string
|
|
123
123
|
) => () => undefined | [number, number]
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
type ResolvedFilterFns = keyof FilterFns extends never
|
|
124
|
+
} & (keyof FilterFns extends never
|
|
127
125
|
? {
|
|
128
126
|
filterFns?: Record<string, FilterFn<any>>
|
|
129
127
|
}
|
|
130
128
|
: {
|
|
131
129
|
filterFns: Record<keyof FilterFns, FilterFn<any>>
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface FiltersOptions<TData extends RowData>
|
|
135
|
-
extends FiltersOptionsBase<TData>,
|
|
136
|
-
ResolvedFilterFns {}
|
|
130
|
+
})
|
|
137
131
|
|
|
138
|
-
export
|
|
132
|
+
export type FiltersInstance<TData extends RowData> = {
|
|
139
133
|
setColumnFilters: (updater: Updater<ColumnFiltersState>) => void
|
|
140
134
|
|
|
141
135
|
resetColumnFilters: (defaultState?: boolean) => void
|
package/src/features/Grouping.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { isFunction, makeStateUpdater } from '../utils'
|
|
|
16
16
|
|
|
17
17
|
export type GroupingState = string[]
|
|
18
18
|
|
|
19
|
-
export
|
|
19
|
+
export type GroupingTableState = {
|
|
20
20
|
grouping: GroupingState
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -34,7 +34,7 @@ export type AggregationFnOption<TData extends RowData> =
|
|
|
34
34
|
| BuiltInAggregationFn
|
|
35
35
|
| AggregationFn<TData>
|
|
36
36
|
|
|
37
|
-
export
|
|
37
|
+
export type GroupingColumnDef<TData extends RowData, TValue> = {
|
|
38
38
|
aggregationFn?: AggregationFnOption<TData>
|
|
39
39
|
aggregatedCell?: ColumnDefTemplate<
|
|
40
40
|
ReturnType<Cell<TData, TValue>['getContext']>
|
|
@@ -42,7 +42,7 @@ export interface GroupingColumnDef<TData extends RowData, TValue> {
|
|
|
42
42
|
enableGrouping?: boolean
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export
|
|
45
|
+
export type GroupingColumn<TData extends RowData> = {
|
|
46
46
|
getCanGroup: () => boolean
|
|
47
47
|
getIsGrouped: () => boolean
|
|
48
48
|
getGroupedIndex: () => number
|
|
@@ -52,48 +52,42 @@ export interface GroupingColumn<TData extends RowData> {
|
|
|
52
52
|
getAggregationFn: () => AggregationFn<TData> | undefined
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export
|
|
55
|
+
export type GroupingRow = {
|
|
56
56
|
groupingColumnId?: string
|
|
57
57
|
groupingValue?: unknown
|
|
58
58
|
getIsGrouped: () => boolean
|
|
59
59
|
_groupingValuesCache: Record<string, any>
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export
|
|
62
|
+
export type GroupingCell = {
|
|
63
63
|
getIsGrouped: () => boolean
|
|
64
64
|
getIsPlaceholder: () => boolean
|
|
65
65
|
getIsAggregated: () => boolean
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export
|
|
68
|
+
export type ColumnDefaultOptions = {
|
|
69
69
|
// Column
|
|
70
70
|
onGroupingChange: OnChangeFn<GroupingState>
|
|
71
71
|
enableGrouping: boolean
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
export type GroupingOptions = {
|
|
75
75
|
manualGrouping?: boolean
|
|
76
76
|
onGroupingChange?: OnChangeFn<GroupingState>
|
|
77
77
|
enableGrouping?: boolean
|
|
78
78
|
getGroupedRowModel?: (table: Table<any>) => () => RowModel<any>
|
|
79
79
|
groupedColumnMode?: false | 'reorder' | 'remove'
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
type ResolvedAggregationFns = keyof AggregationFns extends never
|
|
80
|
+
} & (keyof AggregationFns extends never
|
|
83
81
|
? {
|
|
84
82
|
aggregationFns?: Record<string, AggregationFn<any>>
|
|
85
83
|
}
|
|
86
84
|
: {
|
|
87
85
|
aggregationFns: Record<keyof AggregationFns, AggregationFn<any>>
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface GroupingOptions
|
|
91
|
-
extends GroupingOptionsBase,
|
|
92
|
-
ResolvedAggregationFns {}
|
|
86
|
+
})
|
|
93
87
|
|
|
94
88
|
export type GroupingColumnMode = false | 'reorder' | 'remove'
|
|
95
89
|
|
|
96
|
-
export
|
|
90
|
+
export type GroupingInstance<TData extends RowData> = {
|
|
97
91
|
setGrouping: (updater: Updater<GroupingState>) => void
|
|
98
92
|
resetGrouping: (defaultState?: boolean) => void
|
|
99
93
|
getPreGroupedRowModel: () => RowModel<TData>
|
package/src/features/Ordering.ts
CHANGED
|
@@ -2,24 +2,24 @@ import { makeStateUpdater, memo } from '../utils'
|
|
|
2
2
|
|
|
3
3
|
import { Table, OnChangeFn, Updater, Column, RowData } from '../types'
|
|
4
4
|
|
|
5
|
-
import { orderColumns } from './Grouping'
|
|
5
|
+
import { Grouping, orderColumns } from './Grouping'
|
|
6
6
|
import { TableFeature } from '../core/table'
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export type ColumnOrderTableState = {
|
|
9
9
|
columnOrder: ColumnOrderState
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export type ColumnOrderState = string[]
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type ColumnOrderOptions = {
|
|
15
15
|
onColumnOrderChange?: OnChangeFn<ColumnOrderState>
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export type ColumnOrderDefaultOptions = {
|
|
19
19
|
onColumnOrderChange: OnChangeFn<ColumnOrderState>
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export
|
|
22
|
+
export type ColumnOrderInstance<TData extends RowData> = {
|
|
23
23
|
setColumnOrder: (updater: Updater<ColumnOrderState>) => void
|
|
24
24
|
resetColumnOrder: (defaultState?: boolean) => void
|
|
25
25
|
_getOrderColumnsFn: () => (
|
|
@@ -2,20 +2,20 @@ import { TableFeature } from '../core/table'
|
|
|
2
2
|
import { OnChangeFn, Table, RowModel, Updater, RowData } from '../types'
|
|
3
3
|
import { functionalUpdate, makeStateUpdater, memo } from '../utils'
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export type PaginationState = {
|
|
6
6
|
pageIndex: number
|
|
7
7
|
pageSize: number
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export type PaginationTableState = {
|
|
11
11
|
pagination: PaginationState
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type PaginationInitialTableState = {
|
|
15
15
|
pagination?: Partial<PaginationState>
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export type PaginationOptions = {
|
|
19
19
|
pageCount?: number
|
|
20
20
|
manualPagination?: boolean
|
|
21
21
|
onPaginationChange?: OnChangeFn<PaginationState>
|
|
@@ -23,11 +23,11 @@ export interface PaginationOptions {
|
|
|
23
23
|
getPaginationRowModel?: (table: Table<any>) => () => RowModel<any>
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export
|
|
26
|
+
export type PaginationDefaultOptions = {
|
|
27
27
|
onPaginationChange: OnChangeFn<PaginationState>
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export
|
|
30
|
+
export type PaginationInstance<TData extends RowData> = {
|
|
31
31
|
_autoResetPageIndex: () => void
|
|
32
32
|
setPagination: (updater: Updater<PaginationState>) => void
|
|
33
33
|
resetPagination: (defaultState?: boolean) => void
|
package/src/features/Pinning.ts
CHANGED
|
@@ -12,42 +12,42 @@ import { makeStateUpdater, memo } from '../utils'
|
|
|
12
12
|
|
|
13
13
|
export type ColumnPinningPosition = false | 'left' | 'right'
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export type ColumnPinningState = {
|
|
16
16
|
left?: string[]
|
|
17
17
|
right?: string[]
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export
|
|
20
|
+
export type ColumnPinningTableState = {
|
|
21
21
|
columnPinning: ColumnPinningState
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export
|
|
24
|
+
export type ColumnPinningOptions = {
|
|
25
25
|
onColumnPinningChange?: OnChangeFn<ColumnPinningState>
|
|
26
26
|
enablePinning?: boolean
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export
|
|
29
|
+
export type ColumnPinningDefaultOptions = {
|
|
30
30
|
onColumnPinningChange: OnChangeFn<ColumnPinningState>
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export
|
|
33
|
+
export type ColumnPinningColumnDef = {
|
|
34
34
|
enablePinning?: boolean
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export
|
|
37
|
+
export type ColumnPinningColumn = {
|
|
38
38
|
getCanPin: () => boolean
|
|
39
39
|
getPinnedIndex: () => number
|
|
40
40
|
getIsPinned: () => ColumnPinningPosition
|
|
41
41
|
pin: (position: ColumnPinningPosition) => void
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export
|
|
44
|
+
export type ColumnPinningRow<TData extends RowData> = {
|
|
45
45
|
getLeftVisibleCells: () => Cell<TData, unknown>[]
|
|
46
46
|
getCenterVisibleCells: () => Cell<TData, unknown>[]
|
|
47
47
|
getRightVisibleCells: () => Cell<TData, unknown>[]
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export
|
|
50
|
+
export type ColumnPinningInstance<TData extends RowData> = {
|
|
51
51
|
setColumnPinning: (updater: Updater<ColumnPinningState>) => void
|
|
52
52
|
resetColumnPinning: (defaultState?: boolean) => void
|
|
53
53
|
getIsSomeColumnsPinned: (position?: ColumnPinningPosition) => boolean
|
|
@@ -4,11 +4,11 @@ import { makeStateUpdater, memo } from '../utils'
|
|
|
4
4
|
|
|
5
5
|
export type RowSelectionState = Record<string, boolean>
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export type RowSelectionTableState = {
|
|
8
8
|
rowSelection: RowSelectionState
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export type RowSelectionOptions<TData extends RowData> = {
|
|
12
12
|
enableRowSelection?: boolean | ((row: Row<TData>) => boolean)
|
|
13
13
|
enableMultiRowSelection?: boolean | ((row: Row<TData>) => boolean)
|
|
14
14
|
enableSubRowSelection?: boolean | ((row: Row<TData>) => boolean)
|
|
@@ -26,7 +26,7 @@ export interface RowSelectionOptions<TData extends RowData> {
|
|
|
26
26
|
// ) => RowModel<TData>
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export
|
|
29
|
+
export type RowSelectionRow = {
|
|
30
30
|
getIsSelected: () => boolean
|
|
31
31
|
getIsSomeSelected: () => boolean
|
|
32
32
|
getIsAllSubRowsSelected: () => boolean
|
|
@@ -37,7 +37,7 @@ export interface RowSelectionRow {
|
|
|
37
37
|
getToggleSelectedHandler: () => (event: unknown) => void
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export
|
|
40
|
+
export type RowSelectionInstance<TData extends RowData> = {
|
|
41
41
|
getToggleAllRowsSelectedHandler: () => (event: unknown) => void
|
|
42
42
|
getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void
|
|
43
43
|
setRowSelection: (updater: Updater<RowSelectionState>) => void
|