@tanstack/table-core 8.0.0-alpha.55 → 8.0.0-alpha.57
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 +9 -384
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/features/Cells.js +122 -0
- package/build/cjs/features/Cells.js.map +1 -0
- package/build/cjs/features/ColumnSizing.js +90 -37
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Columns.js +216 -0
- package/build/cjs/features/Columns.js.map +1 -0
- package/build/cjs/features/Expanding.js +1 -1
- 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/Grouping.js +1 -1
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +78 -153
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +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 +172 -2
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Rows.js +99 -0
- package/build/cjs/features/Rows.js.map +1 -0
- package/build/cjs/features/Sorting.js +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +51 -17
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +876 -690
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +418 -316
- package/build/types/core.d.ts +2 -79
- package/build/types/features/Cells.d.ts +14 -0
- package/build/types/features/ColumnSizing.d.ts +23 -15
- package/build/types/features/Columns.d.ts +54 -0
- package/build/types/features/Expanding.d.ts +1 -1
- package/build/types/features/Filters.d.ts +1 -1
- package/build/types/features/Grouping.d.ts +1 -1
- package/build/types/features/Headers.d.ts +3 -11
- package/build/types/features/Ordering.d.ts +1 -1
- package/build/types/features/Pagination.d.ts +1 -1
- package/build/types/features/Pinning.d.ts +18 -4
- package/build/types/features/RowSelection.d.ts +1 -1
- package/build/types/features/Rows.d.ts +29 -0
- package/build/types/features/Sorting.d.ts +1 -1
- package/build/types/features/Visibility.d.ts +7 -2
- package/build/types/types.d.ts +18 -10
- package/build/types/utils.d.ts +0 -1
- package/build/umd/index.development.js +854 -668
- 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.ts +28 -550
- package/src/features/Cells.ts +156 -0
- package/src/features/ColumnSizing.ts +99 -47
- package/src/features/Columns.ts +290 -0
- package/src/features/Expanding.ts +1 -1
- package/src/features/Filters.ts +1 -1
- package/src/features/Grouping.ts +1 -1
- package/src/features/Headers.ts +48 -138
- package/src/features/Ordering.ts +1 -1
- package/src/features/Pagination.ts +1 -1
- package/src/features/Pinning.ts +194 -3
- package/src/features/RowSelection.ts +1 -1
- package/src/features/Rows.ts +151 -0
- package/src/features/Sorting.ts +1 -1
- package/src/features/Visibility.ts +67 -20
- package/src/types.ts +25 -37
- package/src/utils.ts +1 -3
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Cell,
|
|
3
|
+
TableGenerics,
|
|
4
|
+
TableInstance,
|
|
5
|
+
Row,
|
|
6
|
+
Column,
|
|
7
|
+
CoreCell,
|
|
8
|
+
Getter,
|
|
9
|
+
CellProps,
|
|
10
|
+
PropGetterValue,
|
|
11
|
+
RowProps,
|
|
12
|
+
RowModel,
|
|
13
|
+
RowValues,
|
|
14
|
+
PropGetter,
|
|
15
|
+
} from '../types'
|
|
16
|
+
import { flattenBy, memo, propGetter } from '../utils'
|
|
17
|
+
|
|
18
|
+
export type CoreRow<TGenerics extends TableGenerics> = {
|
|
19
|
+
id: string
|
|
20
|
+
index: number
|
|
21
|
+
original?: TGenerics['Row']
|
|
22
|
+
depth: number
|
|
23
|
+
values: RowValues
|
|
24
|
+
subRows: Row<TGenerics>[]
|
|
25
|
+
getLeafRows: () => Row<TGenerics>[]
|
|
26
|
+
getRowProps: PropGetter<RowProps>
|
|
27
|
+
originalSubRows?: TGenerics['Row'][]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type RowsOptions<TGenerics extends TableGenerics> = {
|
|
31
|
+
getCoreRowModel: (
|
|
32
|
+
instance: TableInstance<TGenerics>
|
|
33
|
+
) => () => RowModel<TGenerics>
|
|
34
|
+
getSubRows?: (
|
|
35
|
+
originalRow: TGenerics['Row'],
|
|
36
|
+
index: number
|
|
37
|
+
) => TGenerics['Row'][]
|
|
38
|
+
getRowId?: (
|
|
39
|
+
originalRow: TGenerics['Row'],
|
|
40
|
+
index: number,
|
|
41
|
+
parent?: Row<TGenerics>
|
|
42
|
+
) => string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type RowsInstance<TGenerics extends TableGenerics> = {
|
|
46
|
+
getRowId: (
|
|
47
|
+
_: TGenerics['Row'],
|
|
48
|
+
index: number,
|
|
49
|
+
parent?: Row<TGenerics>
|
|
50
|
+
) => string
|
|
51
|
+
createRow: (
|
|
52
|
+
id: string,
|
|
53
|
+
original: TGenerics['Row'] | undefined,
|
|
54
|
+
rowIndex: number,
|
|
55
|
+
depth: number,
|
|
56
|
+
values: Record<string, any>
|
|
57
|
+
) => Row<TGenerics>
|
|
58
|
+
getCoreRowModel: () => RowModel<TGenerics>
|
|
59
|
+
_getCoreRowModel?: () => RowModel<TGenerics>
|
|
60
|
+
getRowModel: () => RowModel<TGenerics>
|
|
61
|
+
getRow: (id: string) => Row<TGenerics>
|
|
62
|
+
getRowProps: <TGetter extends Getter<RowProps>>(
|
|
63
|
+
rowId: string,
|
|
64
|
+
userProps?: TGetter
|
|
65
|
+
) => undefined | PropGetterValue<RowProps, TGetter>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//
|
|
69
|
+
|
|
70
|
+
export const Rows = {
|
|
71
|
+
// createRow: <TGenerics extends TableGenerics>(
|
|
72
|
+
// row: Row<TGenerics>,
|
|
73
|
+
// instance: TableInstance<TGenerics>
|
|
74
|
+
// ): CellsRow<TGenerics> => {
|
|
75
|
+
// return {}
|
|
76
|
+
// },
|
|
77
|
+
|
|
78
|
+
createInstance: <TGenerics extends TableGenerics>(
|
|
79
|
+
instance: TableInstance<TGenerics>
|
|
80
|
+
): RowsInstance<TGenerics> => {
|
|
81
|
+
return {
|
|
82
|
+
getRowId: (
|
|
83
|
+
row: TGenerics['Row'],
|
|
84
|
+
index: number,
|
|
85
|
+
parent?: Row<TGenerics>
|
|
86
|
+
) =>
|
|
87
|
+
instance.options.getRowId?.(row, index, parent) ??
|
|
88
|
+
`${parent ? [parent.id, index].join('.') : index}`,
|
|
89
|
+
createRow: (id, original, rowIndex, depth, values) => {
|
|
90
|
+
let row: CoreRow<TGenerics> = {
|
|
91
|
+
id,
|
|
92
|
+
index: rowIndex,
|
|
93
|
+
original,
|
|
94
|
+
depth,
|
|
95
|
+
values,
|
|
96
|
+
subRows: [],
|
|
97
|
+
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
98
|
+
getRowProps: userProps => instance.getRowProps(row.id, userProps)!,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
for (let i = 0; i < instance._features.length; i++) {
|
|
102
|
+
const feature = instance._features[i]
|
|
103
|
+
Object.assign(row, feature.createRow?.(row, instance))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return row as Row<TGenerics>
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
getCoreRowModel: () => {
|
|
110
|
+
if (!instance._getCoreRowModel) {
|
|
111
|
+
instance._getCoreRowModel = instance.options.getCoreRowModel(instance)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return instance._getCoreRowModel()
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// The final calls start at the bottom of the model,
|
|
118
|
+
// expanded rows, which then work their way up
|
|
119
|
+
|
|
120
|
+
getRowModel: () => {
|
|
121
|
+
return instance.getPaginationRowModel()
|
|
122
|
+
},
|
|
123
|
+
getRow: (id: string) => {
|
|
124
|
+
const row = instance.getRowModel().rowsById[id]
|
|
125
|
+
|
|
126
|
+
if (!row) {
|
|
127
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
128
|
+
throw new Error(`getRow expected an ID, but got ${id}`)
|
|
129
|
+
}
|
|
130
|
+
throw new Error()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return row
|
|
134
|
+
},
|
|
135
|
+
getRowProps: (rowId, userProps) => {
|
|
136
|
+
const row = instance.getRow(rowId)
|
|
137
|
+
if (!row) {
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return propGetter(
|
|
142
|
+
{
|
|
143
|
+
key: row.id,
|
|
144
|
+
role: 'row',
|
|
145
|
+
},
|
|
146
|
+
userProps
|
|
147
|
+
)
|
|
148
|
+
},
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
}
|
package/src/features/Sorting.ts
CHANGED
|
@@ -172,7 +172,7 @@ export const Sorting = {
|
|
|
172
172
|
}
|
|
173
173
|
},
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
createInstance: <TGenerics extends TableGenerics>(
|
|
176
176
|
instance: TableInstance<TGenerics>
|
|
177
177
|
): SortingInstance<TGenerics> => {
|
|
178
178
|
let registered = false
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
PropGetterValue,
|
|
8
8
|
TableInstance,
|
|
9
9
|
Updater,
|
|
10
|
+
Row,
|
|
10
11
|
} from '../types'
|
|
11
12
|
import { makeStateUpdater, memo, propGetter } from '../utils'
|
|
12
13
|
|
|
@@ -28,6 +29,9 @@ export type VisibilityTableState = {
|
|
|
28
29
|
export type VisibilityInstance<TGenerics extends TableGenerics> = {
|
|
29
30
|
getVisibleFlatColumns: () => Column<TGenerics>[]
|
|
30
31
|
getVisibleLeafColumns: () => Column<TGenerics>[]
|
|
32
|
+
getLeftVisibleLeafColumns: () => Column<TGenerics>[]
|
|
33
|
+
getRightVisibleLeafColumns: () => Column<TGenerics>[]
|
|
34
|
+
getCenterVisibleLeafColumns: () => Column<TGenerics>[]
|
|
31
35
|
setColumnVisibility: (updater: Updater<VisibilityState>) => void
|
|
32
36
|
toggleColumnVisibility: (columnId: string, value?: boolean) => void
|
|
33
37
|
toggleAllColumnsVisible: (value?: boolean) => void
|
|
@@ -52,6 +56,7 @@ export type VisibilityColumnDef = {
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
export type VisibilityRow<TGenerics extends TableGenerics> = {
|
|
59
|
+
_getAllVisibleCells: () => Cell<TGenerics>[]
|
|
55
60
|
getVisibleCells: () => Cell<TGenerics>[]
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -113,46 +118,88 @@ export const Visibility = {
|
|
|
113
118
|
}
|
|
114
119
|
},
|
|
115
120
|
|
|
116
|
-
|
|
121
|
+
createRow: <TGenerics extends TableGenerics>(
|
|
122
|
+
row: Row<TGenerics>,
|
|
117
123
|
instance: TableInstance<TGenerics>
|
|
118
|
-
):
|
|
124
|
+
): VisibilityRow<TGenerics> => {
|
|
119
125
|
return {
|
|
120
|
-
|
|
126
|
+
_getAllVisibleCells: memo(
|
|
121
127
|
() => [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
.
|
|
125
|
-
.filter(d => d.getIsVisible?.())
|
|
128
|
+
row
|
|
129
|
+
.getAllCells()
|
|
130
|
+
.filter(cell => cell.column.getIsVisible())
|
|
126
131
|
.map(d => d.id)
|
|
127
132
|
.join('_'),
|
|
128
133
|
],
|
|
129
|
-
|
|
130
|
-
return
|
|
134
|
+
_ => {
|
|
135
|
+
return row.getAllCells().filter(cell => cell.column.getIsVisible())
|
|
131
136
|
},
|
|
132
137
|
{
|
|
133
|
-
key: '
|
|
134
|
-
debug: () =>
|
|
135
|
-
|
|
138
|
+
key: 'row._getAllVisibleCells',
|
|
139
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
getVisibleCells: memo(
|
|
143
|
+
() => [
|
|
144
|
+
row.getLeftVisibleCells(),
|
|
145
|
+
row.getCenterVisibleCells(),
|
|
146
|
+
row.getRightVisibleCells(),
|
|
147
|
+
],
|
|
148
|
+
(left, center, right) => [...left, ...center, ...right],
|
|
149
|
+
{
|
|
150
|
+
key: 'row.getVisibleCells',
|
|
151
|
+
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
136
152
|
}
|
|
137
153
|
),
|
|
154
|
+
}
|
|
155
|
+
},
|
|
138
156
|
|
|
139
|
-
|
|
157
|
+
createInstance: <TGenerics extends TableGenerics>(
|
|
158
|
+
instance: TableInstance<TGenerics>
|
|
159
|
+
): VisibilityInstance<TGenerics> => {
|
|
160
|
+
const makeVisibleColumnsMethod = (
|
|
161
|
+
key: string,
|
|
162
|
+
getColumns: () => Column<TGenerics>[]
|
|
163
|
+
): (() => Column<TGenerics>[]) => {
|
|
164
|
+
return memo(
|
|
140
165
|
() => [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
.filter(d => d.getIsVisible?.())
|
|
166
|
+
getColumns(),
|
|
167
|
+
getColumns()
|
|
168
|
+
.filter(d => d.getIsVisible())
|
|
145
169
|
.map(d => d.id)
|
|
146
170
|
.join('_'),
|
|
147
171
|
],
|
|
148
|
-
|
|
149
|
-
return
|
|
172
|
+
columns => {
|
|
173
|
+
return columns.filter(d => d.getIsVisible?.())
|
|
150
174
|
},
|
|
151
175
|
{
|
|
152
|
-
key
|
|
176
|
+
key,
|
|
153
177
|
debug: () =>
|
|
154
178
|
instance.options.debugAll ?? instance.options.debugColumns,
|
|
155
179
|
}
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
getVisibleFlatColumns: makeVisibleColumnsMethod(
|
|
185
|
+
'getVisibleFlatColumns',
|
|
186
|
+
() => instance.getAllFlatColumns()
|
|
187
|
+
),
|
|
188
|
+
getVisibleLeafColumns: makeVisibleColumnsMethod(
|
|
189
|
+
'getVisibleLeafColumns',
|
|
190
|
+
() => instance.getAllLeafColumns()
|
|
191
|
+
),
|
|
192
|
+
getLeftVisibleLeafColumns: makeVisibleColumnsMethod(
|
|
193
|
+
'getLeftVisibleLeafColumns',
|
|
194
|
+
() => instance.getLeftLeafColumns()
|
|
195
|
+
),
|
|
196
|
+
getRightVisibleLeafColumns: makeVisibleColumnsMethod(
|
|
197
|
+
'getRightVisibleLeafColumns',
|
|
198
|
+
() => instance.getRightLeafColumns()
|
|
199
|
+
),
|
|
200
|
+
getCenterVisibleLeafColumns: makeVisibleColumnsMethod(
|
|
201
|
+
'getCenterVisibleLeafColumns',
|
|
202
|
+
() => instance.getCenterLeafColumns()
|
|
156
203
|
),
|
|
157
204
|
|
|
158
205
|
setColumnVisibility: updater =>
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
CoreColumnDef,
|
|
4
|
-
CoreOptions,
|
|
5
|
-
CoreRow,
|
|
6
|
-
CoreTableState,
|
|
7
|
-
TableCore,
|
|
8
|
-
} from './core'
|
|
1
|
+
import { CoreOptions, CoreTableState, TableCore } from './core'
|
|
2
|
+
import { ColumnsOptions, CoreColumn, CoreColumnDef } from './features/Columns'
|
|
9
3
|
import {
|
|
10
4
|
VisibilityInstance,
|
|
11
5
|
VisibilityTableState,
|
|
@@ -24,9 +18,11 @@ import {
|
|
|
24
18
|
ColumnPinningColumnDef,
|
|
25
19
|
ColumnPinningInstance,
|
|
26
20
|
ColumnPinningOptions,
|
|
21
|
+
ColumnPinningPosition,
|
|
22
|
+
ColumnPinningRow,
|
|
27
23
|
ColumnPinningTableState,
|
|
28
24
|
} from './features/Pinning'
|
|
29
|
-
import { HeadersInstance
|
|
25
|
+
import { HeadersInstance } from './features/Headers'
|
|
30
26
|
import {
|
|
31
27
|
FiltersColumn,
|
|
32
28
|
FiltersColumnDef,
|
|
@@ -56,7 +52,7 @@ import {
|
|
|
56
52
|
ExpandedTableState,
|
|
57
53
|
ExpandedRow,
|
|
58
54
|
} from './features/Expanding'
|
|
59
|
-
import { Overwrite
|
|
55
|
+
import { Overwrite } from './utils'
|
|
60
56
|
import {
|
|
61
57
|
ColumnSizingColumn,
|
|
62
58
|
ColumnSizingColumnDef,
|
|
@@ -76,6 +72,12 @@ import {
|
|
|
76
72
|
RowSelectionRow,
|
|
77
73
|
RowSelectionTableState,
|
|
78
74
|
} from './features/RowSelection'
|
|
75
|
+
import { ColumnsInstance } from './features/Columns'
|
|
76
|
+
import { CellsInstance, CellsRow } from './features/Cells'
|
|
77
|
+
import { CoreRow, RowsInstance, RowsOptions } from './features/Rows'
|
|
78
|
+
|
|
79
|
+
export type Updater<T> = T | ((old: T) => T)
|
|
80
|
+
export type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void
|
|
79
81
|
|
|
80
82
|
export type TableGenerics = {
|
|
81
83
|
Row?: any
|
|
@@ -96,15 +98,19 @@ export type UseRenderer<TGenerics extends TableGenerics> =
|
|
|
96
98
|
export type TableFeature = {
|
|
97
99
|
getDefaultOptions?: (instance: any) => any
|
|
98
100
|
getInitialState?: () => any
|
|
99
|
-
|
|
101
|
+
createInstance?: (instance: any) => any
|
|
100
102
|
getDefaultColumn?: () => any
|
|
101
103
|
createColumn?: (column: any, instance: any) => any
|
|
104
|
+
createHeader?: (column: any, instance: any) => any
|
|
102
105
|
createCell?: (cell: any, column: any, row: any, instance: any) => any
|
|
103
106
|
createRow?: (row: any, instance: any) => any
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
export type TableInstance<TGenerics extends TableGenerics> =
|
|
107
110
|
TableCore<TGenerics> &
|
|
111
|
+
ColumnsInstance<TGenerics> &
|
|
112
|
+
RowsInstance<TGenerics> &
|
|
113
|
+
CellsInstance<TGenerics> &
|
|
108
114
|
VisibilityInstance<TGenerics> &
|
|
109
115
|
ColumnOrderInstance<TGenerics> &
|
|
110
116
|
ColumnPinningInstance<TGenerics> &
|
|
@@ -117,9 +123,9 @@ export type TableInstance<TGenerics extends TableGenerics> =
|
|
|
117
123
|
PaginationInstance<TGenerics> &
|
|
118
124
|
RowSelectionInstance<TGenerics>
|
|
119
125
|
|
|
120
|
-
//
|
|
121
|
-
|
|
122
126
|
export type Options<TGenerics extends TableGenerics> = CoreOptions<TGenerics> &
|
|
127
|
+
ColumnsOptions<TGenerics> &
|
|
128
|
+
RowsOptions<TGenerics> &
|
|
123
129
|
VisibilityOptions &
|
|
124
130
|
ColumnOrderOptions &
|
|
125
131
|
ColumnPinningOptions &
|
|
@@ -131,9 +137,6 @@ export type Options<TGenerics extends TableGenerics> = CoreOptions<TGenerics> &
|
|
|
131
137
|
PaginationOptions<TGenerics> &
|
|
132
138
|
RowSelectionOptions<TGenerics>
|
|
133
139
|
|
|
134
|
-
export type Updater<T> = T | ((old: T) => T)
|
|
135
|
-
export type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void
|
|
136
|
-
|
|
137
140
|
export type TableState = CoreTableState &
|
|
138
141
|
VisibilityTableState &
|
|
139
142
|
ColumnOrderTableState &
|
|
@@ -147,8 +150,9 @@ export type TableState = CoreTableState &
|
|
|
147
150
|
RowSelectionTableState
|
|
148
151
|
|
|
149
152
|
export type Row<TGenerics extends TableGenerics> = CoreRow<TGenerics> &
|
|
153
|
+
CellsRow<TGenerics> &
|
|
150
154
|
VisibilityRow<TGenerics> &
|
|
151
|
-
|
|
155
|
+
ColumnPinningRow<TGenerics> &
|
|
152
156
|
GroupingRow &
|
|
153
157
|
RowSelectionRow &
|
|
154
158
|
ExpandedRow
|
|
@@ -165,25 +169,6 @@ export type RowModel<TGenerics extends TableGenerics> = {
|
|
|
165
169
|
|
|
166
170
|
export type AccessorFn<TData> = (originalRow: TData, index: number) => any
|
|
167
171
|
|
|
168
|
-
// export type UserColumnDef<TGenerics extends TableGenerics> = Overwrite<
|
|
169
|
-
// ColumnDef<TGenerics>,
|
|
170
|
-
// GeneratedProperties<false>
|
|
171
|
-
// >
|
|
172
|
-
|
|
173
|
-
// type _GeneratedProperties = {
|
|
174
|
-
// ['Column definitions should be generated with the table.createColumn() (and related) utilities']: false
|
|
175
|
-
// }
|
|
176
|
-
|
|
177
|
-
// export type GeneratedProperties<T> = T extends true
|
|
178
|
-
// ? {
|
|
179
|
-
// [TKey in keyof _GeneratedProperties]: true
|
|
180
|
-
// }
|
|
181
|
-
// : T extends false
|
|
182
|
-
// ? {
|
|
183
|
-
// [TKey in keyof _GeneratedProperties]?: false
|
|
184
|
-
// }
|
|
185
|
-
// : never
|
|
186
|
-
|
|
187
172
|
export type Renderable<TGenerics extends TableGenerics, TProps> =
|
|
188
173
|
| string
|
|
189
174
|
| ((props: TProps) => ReturnType<UseRenderer<TGenerics>>)
|
|
@@ -225,9 +210,12 @@ export type Header<TGenerics extends TableGenerics> = CoreHeader<TGenerics> &
|
|
|
225
210
|
|
|
226
211
|
export type CoreHeader<TGenerics extends TableGenerics> = {
|
|
227
212
|
id: string
|
|
213
|
+
index: number
|
|
228
214
|
depth: number
|
|
229
215
|
column: Column<TGenerics>
|
|
230
|
-
|
|
216
|
+
getStart: () => number
|
|
217
|
+
getSize: () => number
|
|
218
|
+
headerGroup: HeaderGroup<TGenerics>
|
|
231
219
|
subHeaders: Header<TGenerics>[]
|
|
232
220
|
colSpan?: number
|
|
233
221
|
rowSpan?: number
|
package/src/utils.ts
CHANGED
|
@@ -21,11 +21,9 @@ export type IfDefined<T, N> = 0 extends 1 & T ? N : T extends {} ? T : N
|
|
|
21
21
|
// DefinedGenericKeys<T>
|
|
22
22
|
// >
|
|
23
23
|
|
|
24
|
-
export type DataUpdateFunction<T> = (input: T) => T
|
|
25
|
-
|
|
26
24
|
export function functionalUpdate<T>(updater: Updater<T>, input: T): T {
|
|
27
25
|
return typeof updater === 'function'
|
|
28
|
-
? (updater as
|
|
26
|
+
? (updater as (input: T) => T)(input)
|
|
29
27
|
: updater
|
|
30
28
|
}
|
|
31
29
|
|