@tanstack/table-core 8.0.0-alpha.82 → 8.0.0-alpha.83
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.map +1 -1
- package/build/cjs/createTable.js +3 -2
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/Cells.js +1 -1
- package/build/cjs/features/Cells.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +5 -5
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Columns.js +8 -6
- package/build/cjs/features/Columns.js.map +1 -1
- package/build/cjs/features/Filters.js +9 -5
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +5 -5
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +2 -2
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Pinning.js +14 -8
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/Sorting.js +8 -8
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +3 -3
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/utils/getGroupedRowModel.js +2 -2
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils/getSortedRowModel.js +2 -2
- package/build/cjs/utils/getSortedRowModel.js.map +1 -1
- package/build/esm/index.js +62 -49
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +324 -324
- package/build/types/core.d.ts +4 -4
- package/build/types/createTable.d.ts +4 -4
- package/build/types/features/Columns.d.ts +2 -2
- package/build/types/features/Pinning.d.ts +1 -1
- package/build/types/types.d.ts +5 -3
- package/build/umd/index.development.js +62 -49
- 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 +6 -6
- package/src/createTable.ts +7 -4
- package/src/features/Cells.ts +2 -2
- package/src/features/ColumnSizing.ts +5 -5
- package/src/features/Columns.ts +12 -8
- package/src/features/Filters.ts +7 -3
- package/src/features/Grouping.ts +4 -3
- package/src/features/Headers.ts +4 -4
- package/src/features/Pinning.ts +10 -5
- package/src/features/Sorting.ts +9 -9
- package/src/features/Visibility.ts +2 -2
- package/src/types.ts +9 -5
- package/src/utils/getGroupedRowModel.ts +3 -2
- package/src/utils/getSortedRowModel.ts +2 -2
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.83",
|
|
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.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { functionalUpdate, RequiredKeys } from './utils'
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
Updater,
|
|
5
|
-
|
|
5
|
+
TableOptionsResolved,
|
|
6
6
|
TableState,
|
|
7
7
|
TableInstance,
|
|
8
8
|
Renderable,
|
|
@@ -52,8 +52,8 @@ export type CoreInstance<TGenerics extends TableGenerics> = {
|
|
|
52
52
|
// generics: TGenerics
|
|
53
53
|
initialState: TableState
|
|
54
54
|
reset: () => void
|
|
55
|
-
options: RequiredKeys<
|
|
56
|
-
setOptions: (newOptions: Updater<
|
|
55
|
+
options: RequiredKeys<TableOptionsResolved<TGenerics>, 'state'>
|
|
56
|
+
setOptions: (newOptions: Updater<TableOptionsResolved<TGenerics>>) => void
|
|
57
57
|
getState: () => TableState
|
|
58
58
|
setState: (updater: Updater<TableState>) => void
|
|
59
59
|
_queue: (cb: () => void) => void
|
|
@@ -89,7 +89,7 @@ export type CoreInstance<TGenerics extends TableGenerics> = {
|
|
|
89
89
|
// }
|
|
90
90
|
|
|
91
91
|
export function createTableInstance<TGenerics extends TableGenerics>(
|
|
92
|
-
options:
|
|
92
|
+
options: TableOptionsResolved<TGenerics>
|
|
93
93
|
): TableInstance<TGenerics> {
|
|
94
94
|
if (options.debugAll || options.debugTable) {
|
|
95
95
|
console.info('Creating Table Instance...')
|
|
@@ -116,9 +116,9 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
116
116
|
|
|
117
117
|
const defaultOptions = instance._features.reduce((obj, feature) => {
|
|
118
118
|
return Object.assign(obj, feature.getDefaultOptions?.(instance))
|
|
119
|
-
}, {}) as
|
|
119
|
+
}, {}) as TableOptionsResolved<TGenerics>
|
|
120
120
|
|
|
121
|
-
const mergeOptions = (options:
|
|
121
|
+
const mergeOptions = (options: TableOptionsResolved<TGenerics>) => {
|
|
122
122
|
if (instance.options.mergeOptions) {
|
|
123
123
|
return instance.options.mergeOptions(defaultOptions, options)
|
|
124
124
|
}
|
package/src/createTable.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
AccessorFn,
|
|
7
7
|
AnyRender,
|
|
8
8
|
TableGenerics,
|
|
9
|
+
TableOptionsResolved,
|
|
9
10
|
TableOptions,
|
|
10
11
|
} from './types'
|
|
11
12
|
import { IfDefined, Overwrite } from './utils'
|
|
@@ -26,15 +27,15 @@ export type CreateTableOptions<
|
|
|
26
27
|
sortingFns?: TSortingFns
|
|
27
28
|
aggregationFns?: TAggregationFns
|
|
28
29
|
} & Omit<
|
|
29
|
-
|
|
30
|
+
TableOptionsResolved<TGenerics>,
|
|
30
31
|
'filterFns' | 'sortingFns' | 'aggregationFns'
|
|
31
32
|
>
|
|
32
33
|
>
|
|
33
34
|
|
|
34
35
|
export type Table<TGenerics extends TableGenerics> = {
|
|
35
36
|
generics: TGenerics
|
|
36
|
-
options: Partial<
|
|
37
|
-
setGenerics: <T extends TableGenerics>() => Table<T>
|
|
37
|
+
options: Partial<TableOptionsResolved<TGenerics>>
|
|
38
|
+
// setGenerics: <T extends TableGenerics>() => Table<T>
|
|
38
39
|
setRowType: <TRow>() => Table<Overwrite<TGenerics, { Row: TRow }>>
|
|
39
40
|
setTableMetaType: <TTableMeta>() => Table<
|
|
40
41
|
Overwrite<TGenerics, { TableMeta: TTableMeta }>
|
|
@@ -119,6 +120,7 @@ export type Table<TGenerics extends TableGenerics> = {
|
|
|
119
120
|
}
|
|
120
121
|
>
|
|
121
122
|
) => ColumnDef<TGenerics>
|
|
123
|
+
createOptions: (options: TableOptions<TGenerics>) => TableOptions<TGenerics>
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
//
|
|
@@ -143,7 +145,7 @@ function createTable<TGenerics extends TableGenerics>(
|
|
|
143
145
|
throw new Error('')
|
|
144
146
|
})(),
|
|
145
147
|
},
|
|
146
|
-
setGenerics: () => table as any,
|
|
148
|
+
// setGenerics: () => table as any,
|
|
147
149
|
setRowType: () => table as any,
|
|
148
150
|
setTableMetaType: () => table as any,
|
|
149
151
|
setColumnMetaType: () => table as any,
|
|
@@ -179,6 +181,7 @@ function createTable<TGenerics extends TableGenerics>(
|
|
|
179
181
|
|
|
180
182
|
throw new Error('Invalid accessor')
|
|
181
183
|
},
|
|
184
|
+
createOptions: options => options,
|
|
182
185
|
}
|
|
183
186
|
|
|
184
187
|
return table
|
package/src/features/Cells.ts
CHANGED
|
@@ -93,7 +93,7 @@ const getDefaultColumnSizingInfoState = (): ColumnSizingInfoState => ({
|
|
|
93
93
|
})
|
|
94
94
|
|
|
95
95
|
export const ColumnSizing: TableFeature = {
|
|
96
|
-
|
|
96
|
+
getDefaultColumnDef: (): ColumnSizingColumnDef => {
|
|
97
97
|
return defaultColumnSizing
|
|
98
98
|
},
|
|
99
99
|
getInitialState: (state): ColumnSizingTableState => {
|
|
@@ -124,10 +124,10 @@ export const ColumnSizing: TableFeature = {
|
|
|
124
124
|
|
|
125
125
|
return Math.min(
|
|
126
126
|
Math.max(
|
|
127
|
-
column.minSize ?? defaultColumnSizing.minSize,
|
|
128
|
-
columnSize ?? column.size ?? defaultColumnSizing.size
|
|
127
|
+
column.columnDef.minSize ?? defaultColumnSizing.minSize,
|
|
128
|
+
columnSize ?? column.columnDef.size ?? defaultColumnSizing.size
|
|
129
129
|
),
|
|
130
|
-
column.maxSize ?? defaultColumnSizing.maxSize
|
|
130
|
+
column.columnDef.maxSize ?? defaultColumnSizing.maxSize
|
|
131
131
|
)
|
|
132
132
|
},
|
|
133
133
|
getStart: position => {
|
|
@@ -156,7 +156,7 @@ export const ColumnSizing: TableFeature = {
|
|
|
156
156
|
},
|
|
157
157
|
getCanResize: () => {
|
|
158
158
|
return (
|
|
159
|
-
(column.enableResizing ?? true) &&
|
|
159
|
+
(column.columnDef.enableResizing ?? true) &&
|
|
160
160
|
(instance.options.enableColumnResizing ?? true)
|
|
161
161
|
)
|
|
162
162
|
},
|
package/src/features/Columns.ts
CHANGED
|
@@ -61,11 +61,11 @@ export type CoreColumn<TGenerics extends TableGenerics> = {
|
|
|
61
61
|
|
|
62
62
|
export type ColumnsOptions<TGenerics extends TableGenerics> = {
|
|
63
63
|
columns: ColumnDef<TGenerics>[]
|
|
64
|
-
|
|
64
|
+
defaultColumnDef?: Partial<ColumnDef<TGenerics>>
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export type ColumnsInstance<TGenerics extends TableGenerics> = {
|
|
68
|
-
|
|
68
|
+
getDefaultColumnDef: () => Partial<ColumnDef<TGenerics>>
|
|
69
69
|
getColumnDefs: () => ColumnDef<TGenerics>[]
|
|
70
70
|
createColumn: (
|
|
71
71
|
columnDef: ColumnDef<TGenerics>,
|
|
@@ -86,8 +86,8 @@ export const Columns = {
|
|
|
86
86
|
instance: TableInstance<TGenerics>
|
|
87
87
|
): ColumnsInstance<TGenerics> => {
|
|
88
88
|
return {
|
|
89
|
-
|
|
90
|
-
() => [instance.options.
|
|
89
|
+
getDefaultColumnDef: memo(
|
|
90
|
+
() => [instance.options.defaultColumnDef],
|
|
91
91
|
defaultColumn => {
|
|
92
92
|
defaultColumn = (defaultColumn ?? {}) as Partial<ColumnDef<TGenerics>>
|
|
93
93
|
|
|
@@ -96,7 +96,7 @@ export const Columns = {
|
|
|
96
96
|
footer: props => props.header.column.id,
|
|
97
97
|
cell: props => props.getValue().toString?.() ?? null,
|
|
98
98
|
...instance._features.reduce((obj, feature) => {
|
|
99
|
-
return Object.assign(obj, feature.
|
|
99
|
+
return Object.assign(obj, feature.getDefaultColumnDef?.())
|
|
100
100
|
}, {}),
|
|
101
101
|
...defaultColumn,
|
|
102
102
|
} as Partial<ColumnDef<TGenerics>>
|
|
@@ -104,7 +104,7 @@ export const Columns = {
|
|
|
104
104
|
{
|
|
105
105
|
debug: () =>
|
|
106
106
|
instance.options.debugAll ?? instance.options.debugColumns,
|
|
107
|
-
key: process.env.NODE_ENV === 'development' && '
|
|
107
|
+
key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef',
|
|
108
108
|
}
|
|
109
109
|
),
|
|
110
110
|
|
|
@@ -115,7 +115,12 @@ export const Columns = {
|
|
|
115
115
|
depth: number,
|
|
116
116
|
parent
|
|
117
117
|
) => {
|
|
118
|
-
const
|
|
118
|
+
const defaultColumnDef = instance.getDefaultColumnDef()
|
|
119
|
+
|
|
120
|
+
columnDef = {
|
|
121
|
+
...defaultColumnDef,
|
|
122
|
+
...columnDef,
|
|
123
|
+
}
|
|
119
124
|
|
|
120
125
|
let id =
|
|
121
126
|
columnDef.id ??
|
|
@@ -143,7 +148,6 @@ export const Columns = {
|
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
let column: CoreColumn<TGenerics> = {
|
|
146
|
-
...defaultColumn,
|
|
147
151
|
...columnDef,
|
|
148
152
|
id: `${id}`,
|
|
149
153
|
accessorFn,
|
package/src/features/Filters.ts
CHANGED
|
@@ -161,7 +161,7 @@ export type FiltersInstance<TGenerics extends TableGenerics> = {
|
|
|
161
161
|
//
|
|
162
162
|
|
|
163
163
|
export const Filters: TableFeature = {
|
|
164
|
-
|
|
164
|
+
getDefaultColumnDef: <
|
|
165
165
|
TGenerics extends TableGenerics
|
|
166
166
|
>(): FiltersColumnDef<TGenerics> => {
|
|
167
167
|
return {
|
|
@@ -217,6 +217,10 @@ export const Filters: TableFeature = {
|
|
|
217
217
|
return filterFns.inNumberRange
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
if (typeof value === 'boolean') {
|
|
221
|
+
return filterFns.equals
|
|
222
|
+
}
|
|
223
|
+
|
|
220
224
|
if (value !== null && typeof value === 'object') {
|
|
221
225
|
return filterFns.equals
|
|
222
226
|
}
|
|
@@ -243,7 +247,7 @@ export const Filters: TableFeature = {
|
|
|
243
247
|
},
|
|
244
248
|
getCanFilter: () => {
|
|
245
249
|
return (
|
|
246
|
-
(column.enableColumnFilter ?? true) &&
|
|
250
|
+
(column.columnDef.enableColumnFilter ?? true) &&
|
|
247
251
|
(instance.options.enableColumnFilters ?? true) &&
|
|
248
252
|
(instance.options.enableFilters ?? true) &&
|
|
249
253
|
!!column.accessorFn
|
|
@@ -252,7 +256,7 @@ export const Filters: TableFeature = {
|
|
|
252
256
|
|
|
253
257
|
getCanGlobalFilter: () => {
|
|
254
258
|
return (
|
|
255
|
-
(column.enableGlobalFilter ?? true) &&
|
|
259
|
+
(column.columnDef.enableGlobalFilter ?? true) &&
|
|
256
260
|
(instance.options.enableGlobalFilter ?? true) &&
|
|
257
261
|
(instance.options.enableFilters ?? true) &&
|
|
258
262
|
(instance.options.getColumnCanGlobalFilter?.(column) ?? true) &&
|
package/src/features/Grouping.ts
CHANGED
|
@@ -108,7 +108,7 @@ export type GroupingInstance<TGenerics extends TableGenerics> = {
|
|
|
108
108
|
//
|
|
109
109
|
|
|
110
110
|
export const Grouping: TableFeature = {
|
|
111
|
-
|
|
111
|
+
getDefaultColumnDef: <
|
|
112
112
|
TGenerics extends TableGenerics
|
|
113
113
|
>(): GroupingColumnDef<TGenerics> => {
|
|
114
114
|
return {
|
|
@@ -150,7 +150,7 @@ export const Grouping: TableFeature = {
|
|
|
150
150
|
|
|
151
151
|
getCanGroup: () => {
|
|
152
152
|
return (
|
|
153
|
-
column.enableGrouping ??
|
|
153
|
+
column.columnDef.enableGrouping ??
|
|
154
154
|
true ??
|
|
155
155
|
instance.options.enableGrouping ??
|
|
156
156
|
true ??
|
|
@@ -264,7 +264,8 @@ export const Grouping: TableFeature = {
|
|
|
264
264
|
!cell.getIsPlaceholder() &&
|
|
265
265
|
row.subRows?.length > 1,
|
|
266
266
|
renderAggregatedCell: () => {
|
|
267
|
-
const template =
|
|
267
|
+
const template =
|
|
268
|
+
column.columnDef.aggregatedCell ?? column.columnDef.cell
|
|
268
269
|
|
|
269
270
|
return template
|
|
270
271
|
? instance._render(template, {
|
package/src/features/Headers.ts
CHANGED
|
@@ -87,16 +87,16 @@ export const Headers = {
|
|
|
87
87
|
return leafHeaders as Header<TGenerics>[]
|
|
88
88
|
},
|
|
89
89
|
renderHeader: () =>
|
|
90
|
-
column.header
|
|
91
|
-
? instance._render(column.header, {
|
|
90
|
+
column.columnDef.header
|
|
91
|
+
? instance._render(column.columnDef.header, {
|
|
92
92
|
instance,
|
|
93
93
|
header: header as Header<TGenerics>,
|
|
94
94
|
column,
|
|
95
95
|
})
|
|
96
96
|
: null,
|
|
97
97
|
renderFooter: () =>
|
|
98
|
-
column.footer
|
|
99
|
-
? instance._render(column.footer, {
|
|
98
|
+
column.columnDef.footer
|
|
99
|
+
? instance._render(column.columnDef.footer, {
|
|
100
100
|
instance,
|
|
101
101
|
header: header as Header<TGenerics>,
|
|
102
102
|
column,
|
package/src/features/Pinning.ts
CHANGED
|
@@ -50,7 +50,7 @@ export type ColumnPinningRow<TGenerics extends TableGenerics> = {
|
|
|
50
50
|
export type ColumnPinningInstance<TGenerics extends TableGenerics> = {
|
|
51
51
|
setColumnPinning: (updater: Updater<ColumnPinningState>) => void
|
|
52
52
|
resetColumnPinning: (defaultState?: boolean) => void
|
|
53
|
-
getIsSomeColumnsPinned: () => boolean
|
|
53
|
+
getIsSomeColumnsPinned: (position?: ColumnPinningPosition) => boolean
|
|
54
54
|
getLeftLeafColumns: () => Column<TGenerics>[]
|
|
55
55
|
getRightLeafColumns: () => Column<TGenerics>[]
|
|
56
56
|
getCenterLeafColumns: () => Column<TGenerics>[]
|
|
@@ -123,7 +123,7 @@ export const Pinning: TableFeature = {
|
|
|
123
123
|
|
|
124
124
|
return leafColumns.some(
|
|
125
125
|
d =>
|
|
126
|
-
(d.enablePinning ?? true) &&
|
|
126
|
+
(d.columnDef.enablePinning ?? true) &&
|
|
127
127
|
(instance.options.enablePinning ?? true)
|
|
128
128
|
)
|
|
129
129
|
},
|
|
@@ -229,10 +229,15 @@ export const Pinning: TableFeature = {
|
|
|
229
229
|
: instance.initialState?.columnPinning ?? getDefaultPinningState()
|
|
230
230
|
),
|
|
231
231
|
|
|
232
|
-
getIsSomeColumnsPinned:
|
|
233
|
-
const
|
|
232
|
+
getIsSomeColumnsPinned: position => {
|
|
233
|
+
const pinningState = instance.getState().columnPinning
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
if (!position) {
|
|
236
|
+
return Boolean(
|
|
237
|
+
pinningState.left?.length || pinningState.right?.length
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
return Boolean(pinningState[position]?.length)
|
|
236
241
|
},
|
|
237
242
|
|
|
238
243
|
getLeftLeafColumns: memo(
|
package/src/features/Sorting.ts
CHANGED
|
@@ -101,7 +101,7 @@ export const Sorting: TableFeature = {
|
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
getDefaultColumnDef: <
|
|
105
105
|
TGenerics extends TableGenerics
|
|
106
106
|
>(): SortingColumnDef<TGenerics> => {
|
|
107
107
|
return {
|
|
@@ -170,15 +170,15 @@ export const Sorting: TableFeature = {
|
|
|
170
170
|
throw new Error()
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
return isFunction(column.sortingFn)
|
|
174
|
-
? column.sortingFn
|
|
175
|
-
: column.sortingFn === 'auto'
|
|
173
|
+
return isFunction(column.columnDef.sortingFn)
|
|
174
|
+
? column.columnDef.sortingFn
|
|
175
|
+
: column.columnDef.sortingFn === 'auto'
|
|
176
176
|
? column.getAutoSortingFn()
|
|
177
177
|
: (userSortingFn as Record<string, any>)?.[
|
|
178
|
-
column.sortingFn as string
|
|
178
|
+
column.columnDef.sortingFn as string
|
|
179
179
|
] ??
|
|
180
180
|
(sortingFns[
|
|
181
|
-
column.sortingFn as BuiltInSortingFn
|
|
181
|
+
column.columnDef.sortingFn as BuiltInSortingFn
|
|
182
182
|
] as SortingFn<TGenerics>)
|
|
183
183
|
},
|
|
184
184
|
toggleSorting: (desc, multi) => {
|
|
@@ -220,7 +220,7 @@ export const Sorting: TableFeature = {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
const sortDescFirst =
|
|
223
|
-
column.sortDescFirst ??
|
|
223
|
+
column.columnDef.sortDescFirst ??
|
|
224
224
|
instance.options.sortDescFirst ??
|
|
225
225
|
column.getAutoSortDir() === 'desc'
|
|
226
226
|
|
|
@@ -280,7 +280,7 @@ export const Sorting: TableFeature = {
|
|
|
280
280
|
|
|
281
281
|
getCanSort: () => {
|
|
282
282
|
return (
|
|
283
|
-
(column.enableSorting ?? true) &&
|
|
283
|
+
(column.columnDef.enableSorting ?? true) &&
|
|
284
284
|
(instance.options.enableSorting ?? true) &&
|
|
285
285
|
!!column.accessorFn
|
|
286
286
|
)
|
|
@@ -288,7 +288,7 @@ export const Sorting: TableFeature = {
|
|
|
288
288
|
|
|
289
289
|
getCanMultiSort: () => {
|
|
290
290
|
return (
|
|
291
|
-
column.enableMultiSort ??
|
|
291
|
+
column.columnDef.enableMultiSort ??
|
|
292
292
|
instance.options.enableMultiSort ??
|
|
293
293
|
!!column.accessorFn
|
|
294
294
|
)
|
|
@@ -76,7 +76,7 @@ export const Visibility: TableFeature = {
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
getDefaultColumnDef: () => {
|
|
80
80
|
return {
|
|
81
81
|
defaultIsVisible: true,
|
|
82
82
|
}
|
|
@@ -101,7 +101,7 @@ export const Visibility: TableFeature = {
|
|
|
101
101
|
|
|
102
102
|
getCanHide: () => {
|
|
103
103
|
return (
|
|
104
|
-
(column.enableHiding ?? true) &&
|
|
104
|
+
(column.columnDef.enableHiding ?? true) &&
|
|
105
105
|
(instance.options.enableHiding ?? true)
|
|
106
106
|
)
|
|
107
107
|
},
|
package/src/types.ts
CHANGED
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
ExpandedTableState,
|
|
54
54
|
ExpandedRow,
|
|
55
55
|
} from './features/Expanding'
|
|
56
|
-
import { Overwrite } from './utils'
|
|
56
|
+
import { Overwrite, PartialKeys } from './utils'
|
|
57
57
|
import {
|
|
58
58
|
ColumnSizingColumn,
|
|
59
59
|
ColumnSizingColumnDef,
|
|
@@ -100,7 +100,7 @@ export type TableFeature = {
|
|
|
100
100
|
getDefaultOptions?: (instance: any) => any
|
|
101
101
|
getInitialState?: (initialState?: InitialTableState) => any
|
|
102
102
|
createInstance?: (instance: any) => any
|
|
103
|
-
|
|
103
|
+
getDefaultColumnDef?: () => any
|
|
104
104
|
createColumn?: (column: any, instance: any) => any
|
|
105
105
|
createHeader?: (column: any, instance: any) => any
|
|
106
106
|
createCell?: (cell: any, column: any, row: any, instance: any) => any
|
|
@@ -124,7 +124,7 @@ export type TableInstance<TGenerics extends TableGenerics> =
|
|
|
124
124
|
PaginationInstance<TGenerics> &
|
|
125
125
|
RowSelectionInstance<TGenerics>
|
|
126
126
|
|
|
127
|
-
export type
|
|
127
|
+
export type TableOptionsResolved<TGenerics extends TableGenerics> =
|
|
128
128
|
CoreOptions<TGenerics> &
|
|
129
129
|
ColumnsOptions<TGenerics> &
|
|
130
130
|
RowsOptions<TGenerics> &
|
|
@@ -139,6 +139,11 @@ export type TableOptions<TGenerics extends TableGenerics> =
|
|
|
139
139
|
PaginationOptions<TGenerics> &
|
|
140
140
|
RowSelectionOptions<TGenerics>
|
|
141
141
|
|
|
142
|
+
export type TableOptions<TGenerics extends TableGenerics> = Omit<
|
|
143
|
+
PartialKeys<TableOptionsResolved<TGenerics>, 'state' | 'onStateChange'>,
|
|
144
|
+
'render'
|
|
145
|
+
>
|
|
146
|
+
|
|
142
147
|
export type TableState = CoreTableState &
|
|
143
148
|
VisibilityTableState &
|
|
144
149
|
ColumnOrderTableState &
|
|
@@ -199,8 +204,7 @@ export type ColumnDef<TGenerics extends TableGenerics> =
|
|
|
199
204
|
GroupingColumnDef<TGenerics> &
|
|
200
205
|
ColumnSizingColumnDef
|
|
201
206
|
|
|
202
|
-
export type Column<TGenerics extends TableGenerics> =
|
|
203
|
-
CoreColumn<TGenerics> &
|
|
207
|
+
export type Column<TGenerics extends TableGenerics> = CoreColumn<TGenerics> &
|
|
204
208
|
ColumnVisibilityColumn &
|
|
205
209
|
ColumnPinningColumn &
|
|
206
210
|
FiltersColumn<TGenerics> &
|
|
@@ -91,8 +91,9 @@ export function getGroupedRowModel<TGenerics extends TableGenerics>(): (
|
|
|
91
91
|
leafRows.map(row => {
|
|
92
92
|
let columnValue = row.getValue(columnId)
|
|
93
93
|
|
|
94
|
-
if (!depth && column.aggregateValue) {
|
|
95
|
-
columnValue =
|
|
94
|
+
if (!depth && column.columnDef.aggregateValue) {
|
|
95
|
+
columnValue =
|
|
96
|
+
column.columnDef.aggregateValue(columnValue)
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
return columnValue
|
|
@@ -35,8 +35,8 @@ export function getSortedRowModel<TGenerics extends TableGenerics>(): (
|
|
|
35
35
|
const column = instance.getColumn(sortEntry.id)
|
|
36
36
|
|
|
37
37
|
columnInfoById[sortEntry.id] = {
|
|
38
|
-
sortUndefined: column.sortUndefined,
|
|
39
|
-
invertSorting: column.invertSorting,
|
|
38
|
+
sortUndefined: column.columnDef.sortUndefined,
|
|
39
|
+
invertSorting: column.columnDef.invertSorting,
|
|
40
40
|
sortingFn: column.getSortingFn(),
|
|
41
41
|
}
|
|
42
42
|
})
|