@tanstack/react-table 8.0.0-alpha.6 → 8.0.0-alpha.9
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 +66 -73
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +47 -33
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +23 -22
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +10 -22
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +27 -58
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +10 -27
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +108 -28
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +2 -2
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +24 -29
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +23 -38
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +10 -22
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +10 -2
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterTypes.js.map +1 -1
- package/build/cjs/index.js +12 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortTypes.js.map +1 -1
- package/build/cjs/types.js +22 -0
- package/build/cjs/types.js.map +1 -0
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/expandRowsFn.js.map +1 -1
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/paginateRowsFn.js.map +1 -1
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/cjs/utils.js +44 -18
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +1388 -1355
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +337 -307
- package/build/types/core.d.ts +63 -67
- package/build/types/createTable.d.ts +34 -44
- package/build/types/features/ColumnSizing.d.ts +13 -7
- package/build/types/features/Expanding.d.ts +11 -16
- package/build/types/features/Filters.d.ts +39 -47
- package/build/types/features/Grouping.d.ts +28 -27
- package/build/types/features/Headers.d.ts +30 -30
- package/build/types/features/Ordering.d.ts +5 -5
- package/build/types/features/Pagination.d.ts +11 -16
- package/build/types/features/Pinning.d.ts +5 -5
- package/build/types/features/RowSelection.d.ts +15 -23
- package/build/types/features/Sorting.d.ts +26 -25
- package/build/types/features/Visibility.d.ts +9 -9
- package/build/types/filterTypes.d.ts +10 -10
- package/build/types/index.d.ts +1 -0
- package/build/types/sortTypes.d.ts +7 -7
- package/build/types/types.d.ts +34 -23
- package/build/types/utils/columnFilterRowsFn.d.ts +2 -2
- package/build/types/utils/expandRowsFn.d.ts +2 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +2 -2
- package/build/types/utils/groupRowsFn.d.ts +2 -2
- package/build/types/utils/paginateRowsFn.d.ts +2 -2
- package/build/types/utils/sortRowsFn.d.ts +2 -2
- package/build/types/utils.d.ts +5 -6
- package/build/umd/index.development.js +1397 -1354
- 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 +192 -520
- package/src/createTable.tsx +137 -192
- package/src/features/ColumnSizing.ts +48 -77
- package/src/features/Expanding.ts +25 -113
- package/src/features/Filters.ts +91 -293
- package/src/features/Grouping.ts +60 -165
- package/src/features/Headers.ts +148 -331
- package/src/features/Ordering.ts +19 -42
- package/src/features/Pagination.ts +35 -110
- package/src/features/Pinning.ts +16 -40
- package/src/features/RowSelection.ts +47 -227
- package/src/features/Sorting.ts +49 -143
- package/src/features/Visibility.ts +23 -64
- package/src/filterTypes.ts +19 -82
- package/src/index.tsx +1 -0
- package/src/sortTypes.ts +19 -31
- package/src/types.ts +80 -100
- package/src/utils/columnFilterRowsFn.ts +11 -53
- package/src/utils/expandRowsFn.ts +7 -27
- package/src/utils/globalFilterRowsFn.ts +10 -43
- package/src/utils/groupRowsFn.ts +13 -37
- package/src/utils/paginateRowsFn.ts +5 -11
- package/src/utils/sortRowsFn.ts +8 -28
- package/src/utils.tsx +61 -35
|
@@ -3,8 +3,9 @@ import { RowModel } from '..'
|
|
|
3
3
|
import {
|
|
4
4
|
Getter,
|
|
5
5
|
OnChangeFn,
|
|
6
|
+
PartialGenerics,
|
|
6
7
|
PropGetterValue,
|
|
7
|
-
|
|
8
|
+
TableInstance,
|
|
8
9
|
Row,
|
|
9
10
|
Updater,
|
|
10
11
|
} from '../types'
|
|
@@ -25,34 +26,18 @@ export type ExpandedRow = {
|
|
|
25
26
|
) => undefined | PropGetterValue<ToggleExpandedProps, TGetter>
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
export type ExpandedOptions<
|
|
29
|
-
TData,
|
|
30
|
-
TValue,
|
|
31
|
-
TFilterFns,
|
|
32
|
-
TSortingFns,
|
|
33
|
-
TAggregationFns
|
|
34
|
-
> = {
|
|
29
|
+
export type ExpandedOptions<TGenerics extends PartialGenerics> = {
|
|
35
30
|
onExpandedChange?: OnChangeFn<ExpandedState>
|
|
36
31
|
autoResetExpanded?: boolean
|
|
37
32
|
enableExpanded?: boolean
|
|
38
33
|
expandRowsFn?: (
|
|
39
|
-
instance:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
TFilterFns,
|
|
43
|
-
TSortingFns,
|
|
44
|
-
TAggregationFns
|
|
45
|
-
>,
|
|
46
|
-
rowModel: RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
47
|
-
) => RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
34
|
+
instance: TableInstance<TGenerics>,
|
|
35
|
+
rowModel: RowModel<TGenerics>
|
|
36
|
+
) => RowModel<TGenerics>
|
|
48
37
|
expandSubRows?: boolean
|
|
49
38
|
defaultCanExpand?: boolean
|
|
50
|
-
getIsRowExpanded?: (
|
|
51
|
-
|
|
52
|
-
) => boolean
|
|
53
|
-
getRowCanExpand?: (
|
|
54
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
55
|
-
) => boolean
|
|
39
|
+
getIsRowExpanded?: (row: Row<TGenerics>) => boolean
|
|
40
|
+
getRowCanExpand?: (row: Row<TGenerics>) => boolean
|
|
56
41
|
paginateExpandedRows?: boolean
|
|
57
42
|
}
|
|
58
43
|
|
|
@@ -61,13 +46,7 @@ export type ToggleExpandedProps = {
|
|
|
61
46
|
onClick?: (event: MouseEvent | TouchEvent) => void
|
|
62
47
|
}
|
|
63
48
|
|
|
64
|
-
export type ExpandedInstance<
|
|
65
|
-
TData,
|
|
66
|
-
TValue,
|
|
67
|
-
TFilterFns,
|
|
68
|
-
TSortingFns,
|
|
69
|
-
TAggregationFns
|
|
70
|
-
> = {
|
|
49
|
+
export type ExpandedInstance<TGenerics extends PartialGenerics> = {
|
|
71
50
|
_notifyExpandedReset: () => void
|
|
72
51
|
setExpanded: (updater: Updater<ExpandedState>) => void
|
|
73
52
|
toggleRowExpanded: (rowId: string, expanded?: boolean) => void
|
|
@@ -84,49 +63,8 @@ export type ExpandedInstance<
|
|
|
84
63
|
) => undefined | PropGetterValue<ToggleExpandedProps, TGetter>
|
|
85
64
|
getIsAllRowsExpanded: () => boolean
|
|
86
65
|
getExpandedDepth: () => number
|
|
87
|
-
getExpandedRowModel: () => RowModel<
|
|
88
|
-
|
|
89
|
-
TValue,
|
|
90
|
-
TFilterFns,
|
|
91
|
-
TSortingFns,
|
|
92
|
-
TAggregationFns
|
|
93
|
-
>
|
|
94
|
-
getPreExpandedRows: () => Row<
|
|
95
|
-
TData,
|
|
96
|
-
TValue,
|
|
97
|
-
TFilterFns,
|
|
98
|
-
TSortingFns,
|
|
99
|
-
TAggregationFns
|
|
100
|
-
>[]
|
|
101
|
-
getPreExpandedFlatRows: () => Row<
|
|
102
|
-
TData,
|
|
103
|
-
TValue,
|
|
104
|
-
TFilterFns,
|
|
105
|
-
TSortingFns,
|
|
106
|
-
TAggregationFns
|
|
107
|
-
>[]
|
|
108
|
-
getPreExpandedRowsById: () => Record<
|
|
109
|
-
string,
|
|
110
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
111
|
-
>
|
|
112
|
-
getExpandedRows: () => Row<
|
|
113
|
-
TData,
|
|
114
|
-
TValue,
|
|
115
|
-
TFilterFns,
|
|
116
|
-
TSortingFns,
|
|
117
|
-
TAggregationFns
|
|
118
|
-
>[]
|
|
119
|
-
getExpandedFlatRows: () => Row<
|
|
120
|
-
TData,
|
|
121
|
-
TValue,
|
|
122
|
-
TFilterFns,
|
|
123
|
-
TSortingFns,
|
|
124
|
-
TAggregationFns
|
|
125
|
-
>[]
|
|
126
|
-
getExpandedRowsById: () => Record<
|
|
127
|
-
string,
|
|
128
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
129
|
-
>
|
|
66
|
+
getExpandedRowModel: () => RowModel<TGenerics>
|
|
67
|
+
getPreExpandedRowModel: () => RowModel<TGenerics>
|
|
130
68
|
}
|
|
131
69
|
|
|
132
70
|
//
|
|
@@ -137,15 +75,9 @@ export function getInitialState(): ExpandedTableState {
|
|
|
137
75
|
}
|
|
138
76
|
}
|
|
139
77
|
|
|
140
|
-
export function getDefaultOptions<
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
TFilterFns,
|
|
144
|
-
TSortingFns,
|
|
145
|
-
TAggregationFns
|
|
146
|
-
>(
|
|
147
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
148
|
-
): ExpandedOptions<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
78
|
+
export function getDefaultOptions<TGenerics extends PartialGenerics>(
|
|
79
|
+
instance: TableInstance<TGenerics>
|
|
80
|
+
): ExpandedOptions<TGenerics> {
|
|
149
81
|
return {
|
|
150
82
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
151
83
|
autoResetExpanded: true,
|
|
@@ -155,15 +87,9 @@ export function getDefaultOptions<
|
|
|
155
87
|
}
|
|
156
88
|
}
|
|
157
89
|
|
|
158
|
-
export function getInstance<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
TFilterFns,
|
|
162
|
-
TSortingFns,
|
|
163
|
-
TAggregationFns
|
|
164
|
-
>(
|
|
165
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
166
|
-
): ExpandedInstance<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
90
|
+
export function getInstance<TGenerics extends PartialGenerics>(
|
|
91
|
+
instance: TableInstance<TGenerics>
|
|
92
|
+
): ExpandedInstance<TGenerics> {
|
|
167
93
|
let registered = false
|
|
168
94
|
|
|
169
95
|
return {
|
|
@@ -198,7 +124,7 @@ export function getInstance<
|
|
|
198
124
|
let oldExpanded: ExpandedStateList = {}
|
|
199
125
|
|
|
200
126
|
if (old === true) {
|
|
201
|
-
Object.keys(instance.
|
|
127
|
+
Object.keys(instance.getRowModel().rowsById).forEach(rowId => {
|
|
202
128
|
oldExpanded[rowId] = true
|
|
203
129
|
})
|
|
204
130
|
} else {
|
|
@@ -312,7 +238,7 @@ export function getInstance<
|
|
|
312
238
|
|
|
313
239
|
// If any row is not expanded, return false
|
|
314
240
|
if (
|
|
315
|
-
Object.keys(instance.
|
|
241
|
+
Object.keys(instance.getRowModel().rowsById).some(
|
|
316
242
|
id => !instance.getIsRowExpanded(id)
|
|
317
243
|
)
|
|
318
244
|
) {
|
|
@@ -327,7 +253,7 @@ export function getInstance<
|
|
|
327
253
|
|
|
328
254
|
const rowIds =
|
|
329
255
|
instance.getState().expanded === true
|
|
330
|
-
? Object.keys(instance.
|
|
256
|
+
? Object.keys(instance.getRowModel().rowsById)
|
|
331
257
|
: Object.keys(instance.getState().expanded)
|
|
332
258
|
|
|
333
259
|
rowIds.forEach(id => {
|
|
@@ -354,38 +280,24 @@ export function getInstance<
|
|
|
354
280
|
return rowModel
|
|
355
281
|
}
|
|
356
282
|
|
|
357
|
-
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
358
|
-
console.info('Expanding...')
|
|
359
|
-
|
|
360
283
|
return expandRowsFn(instance, rowModel)
|
|
361
284
|
},
|
|
362
285
|
{
|
|
363
286
|
key: 'getExpandedRowModel',
|
|
364
|
-
debug: instance.options.
|
|
287
|
+
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
365
288
|
onChange: () => {
|
|
366
289
|
instance._notifyPageIndexReset()
|
|
367
290
|
},
|
|
368
291
|
}
|
|
369
292
|
),
|
|
370
293
|
|
|
371
|
-
|
|
372
|
-
getPreExpandedFlatRows: () => instance.getGroupedRowModel().flatRows,
|
|
373
|
-
getPreExpandedRowsById: () => instance.getGroupedRowModel().rowsById,
|
|
374
|
-
getExpandedRows: () => instance.getExpandedRowModel().rows,
|
|
375
|
-
getExpandedFlatRows: () => instance.getExpandedRowModel().flatRows,
|
|
376
|
-
getExpandedRowsById: () => instance.getExpandedRowModel().rowsById,
|
|
294
|
+
getPreExpandedRowModel: () => instance.getGroupedRowModel(),
|
|
377
295
|
}
|
|
378
296
|
}
|
|
379
297
|
|
|
380
|
-
export function createRow<
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
TFilterFns,
|
|
384
|
-
TSortingFns,
|
|
385
|
-
TAggregationFns
|
|
386
|
-
>(
|
|
387
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
388
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
298
|
+
export function createRow<TGenerics extends PartialGenerics>(
|
|
299
|
+
row: Row<TGenerics>,
|
|
300
|
+
instance: TableInstance<TGenerics>
|
|
389
301
|
): ExpandedRow {
|
|
390
302
|
return {
|
|
391
303
|
toggleExpanded: expanded =>
|