@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
package/src/sortTypes.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Row } from './types'
|
|
1
|
+
import { PartialGenerics, Row } from './types'
|
|
2
2
|
|
|
3
3
|
export const reSplitAlphaNumeric = /([0-9]+)/gm
|
|
4
4
|
|
|
@@ -13,9 +13,9 @@ export const sortTypes = {
|
|
|
13
13
|
|
|
14
14
|
export type BuiltInSortType = keyof typeof sortTypes
|
|
15
15
|
|
|
16
|
-
function alphanumeric<
|
|
17
|
-
rowA: Row<
|
|
18
|
-
rowB: Row<
|
|
16
|
+
function alphanumeric<TGenerics extends PartialGenerics>(
|
|
17
|
+
rowA: Row<TGenerics>,
|
|
18
|
+
rowB: Row<TGenerics>,
|
|
19
19
|
columnId: string
|
|
20
20
|
) {
|
|
21
21
|
return compareAlphanumeric(
|
|
@@ -24,15 +24,9 @@ function alphanumeric<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>(
|
|
|
24
24
|
)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function alphanumericCaseSensitive<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
TFilterFns,
|
|
31
|
-
TSortingFns,
|
|
32
|
-
TAggregationFns
|
|
33
|
-
>(
|
|
34
|
-
rowA: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
35
|
-
rowB: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
27
|
+
function alphanumericCaseSensitive<TGenerics extends PartialGenerics>(
|
|
28
|
+
rowA: Row<TGenerics>,
|
|
29
|
+
rowB: Row<TGenerics>,
|
|
36
30
|
columnId: string
|
|
37
31
|
) {
|
|
38
32
|
return compareAlphanumeric(
|
|
@@ -90,9 +84,9 @@ function compareAlphanumeric(aStr: string, bStr: string) {
|
|
|
90
84
|
|
|
91
85
|
// The text filter is more basic (less numeric support)
|
|
92
86
|
// but is much faster
|
|
93
|
-
function text<
|
|
94
|
-
rowA: Row<
|
|
95
|
-
rowB: Row<
|
|
87
|
+
function text<TGenerics extends PartialGenerics>(
|
|
88
|
+
rowA: Row<TGenerics>,
|
|
89
|
+
rowB: Row<TGenerics>,
|
|
96
90
|
columnId: string
|
|
97
91
|
) {
|
|
98
92
|
return compareBasic(
|
|
@@ -103,15 +97,9 @@ function text<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>(
|
|
|
103
97
|
|
|
104
98
|
// The text filter is more basic (less numeric support)
|
|
105
99
|
// but is much faster
|
|
106
|
-
function textCaseSensitive<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
TFilterFns,
|
|
110
|
-
TSortingFns,
|
|
111
|
-
TAggregationFns
|
|
112
|
-
>(
|
|
113
|
-
rowA: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
114
|
-
rowB: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
100
|
+
function textCaseSensitive<TGenerics extends PartialGenerics>(
|
|
101
|
+
rowA: Row<TGenerics>,
|
|
102
|
+
rowB: Row<TGenerics>,
|
|
115
103
|
columnId: string
|
|
116
104
|
) {
|
|
117
105
|
return compareBasic(
|
|
@@ -120,9 +108,9 @@ function textCaseSensitive<
|
|
|
120
108
|
)
|
|
121
109
|
}
|
|
122
110
|
|
|
123
|
-
function datetime<
|
|
124
|
-
rowA: Row<
|
|
125
|
-
rowB: Row<
|
|
111
|
+
function datetime<TGenerics extends PartialGenerics>(
|
|
112
|
+
rowA: Row<TGenerics>,
|
|
113
|
+
rowB: Row<TGenerics>,
|
|
126
114
|
columnId: string
|
|
127
115
|
) {
|
|
128
116
|
return compareBasic(
|
|
@@ -131,9 +119,9 @@ function datetime<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>(
|
|
|
131
119
|
)
|
|
132
120
|
}
|
|
133
121
|
|
|
134
|
-
function basic<
|
|
135
|
-
rowA: Row<
|
|
136
|
-
rowB: Row<
|
|
122
|
+
function basic<TGenerics extends PartialGenerics>(
|
|
123
|
+
rowA: Row<TGenerics>,
|
|
124
|
+
rowB: Row<TGenerics>,
|
|
137
125
|
columnId: string
|
|
138
126
|
) {
|
|
139
127
|
return compareBasic(rowA.values[columnId], rowB.values[columnId])
|
package/src/types.ts
CHANGED
|
@@ -53,11 +53,13 @@ import {
|
|
|
53
53
|
ExpandedInstance,
|
|
54
54
|
ExpandedOptions,
|
|
55
55
|
ExpandedTableState,
|
|
56
|
+
ExpandedRow,
|
|
56
57
|
} from './features/Expanding'
|
|
57
58
|
import { Overwrite } from './utils'
|
|
58
59
|
import {
|
|
59
60
|
ColumnSizingColumn,
|
|
60
61
|
ColumnSizingColumnDef,
|
|
62
|
+
ColumnSizingHeader,
|
|
61
63
|
ColumnSizingInstance,
|
|
62
64
|
ColumnSizingOptions,
|
|
63
65
|
ColumnSizingTableState,
|
|
@@ -78,36 +80,29 @@ import {
|
|
|
78
80
|
// const process.env.NODE_ENV !== 'production': boolean
|
|
79
81
|
// }
|
|
80
82
|
|
|
81
|
-
export type
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
TFilterFns,
|
|
105
|
-
TSortingFns,
|
|
106
|
-
TAggregationFns
|
|
107
|
-
> &
|
|
108
|
-
ExpandedInstance<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> &
|
|
109
|
-
PaginationInstance<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> &
|
|
110
|
-
RowSelectionInstance<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
83
|
+
export type DefaultGenerics = {
|
|
84
|
+
Row: unknown
|
|
85
|
+
Value: unknown
|
|
86
|
+
FilterFns: object
|
|
87
|
+
SortingFns: object
|
|
88
|
+
AggregationFns: object
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type PartialGenerics = Partial<DefaultGenerics>
|
|
92
|
+
|
|
93
|
+
export type TableInstance<TGenerics extends PartialGenerics> =
|
|
94
|
+
TableCore<TGenerics> &
|
|
95
|
+
VisibilityInstance<TGenerics> &
|
|
96
|
+
ColumnOrderInstance<TGenerics> &
|
|
97
|
+
ColumnPinningInstance<TGenerics> &
|
|
98
|
+
HeadersInstance<TGenerics> &
|
|
99
|
+
FiltersInstance<TGenerics> &
|
|
100
|
+
SortingInstance<TGenerics> &
|
|
101
|
+
GroupingInstance<TGenerics> &
|
|
102
|
+
ColumnSizingInstance<TGenerics> &
|
|
103
|
+
ExpandedInstance<TGenerics> &
|
|
104
|
+
PaginationInstance<TGenerics> &
|
|
105
|
+
RowSelectionInstance<TGenerics>
|
|
111
106
|
|
|
112
107
|
export type Renderable<TProps> =
|
|
113
108
|
| React.ReactNode
|
|
@@ -116,18 +111,18 @@ export type Renderable<TProps> =
|
|
|
116
111
|
|
|
117
112
|
//
|
|
118
113
|
|
|
119
|
-
export type Options<
|
|
120
|
-
CoreOptions<
|
|
114
|
+
export type Options<TGenerics extends PartialGenerics> =
|
|
115
|
+
CoreOptions<TGenerics> &
|
|
121
116
|
VisibilityOptions &
|
|
122
117
|
ColumnOrderOptions &
|
|
123
118
|
ColumnPinningOptions &
|
|
124
|
-
FiltersOptions<
|
|
125
|
-
SortingOptions<
|
|
126
|
-
GroupingOptions<
|
|
127
|
-
ExpandedOptions<
|
|
119
|
+
FiltersOptions<TGenerics> &
|
|
120
|
+
SortingOptions<TGenerics> &
|
|
121
|
+
GroupingOptions<TGenerics> &
|
|
122
|
+
ExpandedOptions<TGenerics> &
|
|
128
123
|
ColumnSizingOptions &
|
|
129
|
-
PaginationOptions<
|
|
130
|
-
RowSelectionOptions<
|
|
124
|
+
PaginationOptions<TGenerics> &
|
|
125
|
+
RowSelectionOptions<TGenerics>
|
|
131
126
|
|
|
132
127
|
export type Updater<T> = T | ((old: T) => T)
|
|
133
128
|
export type OnChangeFn<T> = (updaterOrValue: Updater<T>, value: T) => void
|
|
@@ -143,101 +138,88 @@ export type TableState = VisibilityTableState &
|
|
|
143
138
|
PaginationTableState &
|
|
144
139
|
RowSelectionTableState
|
|
145
140
|
|
|
146
|
-
export type Row<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
141
|
+
export type Row<TGenerics extends PartialGenerics> = CoreRow<TGenerics> &
|
|
142
|
+
VisibilityRow<TGenerics> &
|
|
143
|
+
HeadersRow<TGenerics> &
|
|
144
|
+
GroupingRow &
|
|
145
|
+
RowSelectionRow &
|
|
146
|
+
ExpandedRow
|
|
152
147
|
|
|
153
148
|
export type RowValues = {
|
|
154
149
|
[key: string]: any
|
|
155
150
|
}
|
|
156
151
|
|
|
157
|
-
export type RowModel<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
string,
|
|
163
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
164
|
-
>
|
|
165
|
-
}
|
|
152
|
+
export type RowModel<TGenerics extends PartialGenerics> = {
|
|
153
|
+
rows: Row<TGenerics>[]
|
|
154
|
+
flatRows: Row<TGenerics>[]
|
|
155
|
+
rowsById: Record<string, Row<TGenerics>>
|
|
156
|
+
}
|
|
166
157
|
|
|
167
158
|
export type AccessorFn<TData> = (originalRow: TData, index: number) => any
|
|
168
159
|
|
|
169
|
-
export
|
|
170
|
-
|
|
160
|
+
export const Please_use_the_create_table_column_utilities_to_define_columns: unique symbol =
|
|
161
|
+
Symbol()
|
|
162
|
+
|
|
163
|
+
export type _NonGenerated<T> = Overwrite<
|
|
164
|
+
T,
|
|
165
|
+
{
|
|
166
|
+
[Please_use_the_create_table_column_utilities_to_define_columns]?: never
|
|
167
|
+
}
|
|
168
|
+
>
|
|
169
|
+
|
|
170
|
+
export type ColumnDef<TGenerics extends PartialGenerics> =
|
|
171
|
+
CoreColumnDef<TGenerics> &
|
|
171
172
|
VisibilityColumnDef &
|
|
172
173
|
ColumnPinningColumnDef &
|
|
173
|
-
FiltersColumnDef<
|
|
174
|
-
SortingColumnDef<
|
|
175
|
-
GroupingColumnDef<
|
|
174
|
+
FiltersColumnDef<TGenerics> &
|
|
175
|
+
SortingColumnDef<TGenerics> &
|
|
176
|
+
GroupingColumnDef<TGenerics> &
|
|
176
177
|
ColumnSizingColumnDef
|
|
177
178
|
|
|
178
|
-
export type Column<
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
export type Cell<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> = {
|
|
179
|
+
export type Column<TGenerics extends PartialGenerics> = ColumnDef<TGenerics> &
|
|
180
|
+
CoreColumn<TGenerics> &
|
|
181
|
+
ColumnVisibilityColumn &
|
|
182
|
+
ColumnPinningColumn &
|
|
183
|
+
FiltersColumn<TGenerics> &
|
|
184
|
+
SortingColumn<TGenerics> &
|
|
185
|
+
GroupingColumn<TGenerics> &
|
|
186
|
+
ColumnSizingColumn<TGenerics>
|
|
187
|
+
|
|
188
|
+
export type Cell<TGenerics extends PartialGenerics> = {
|
|
189
189
|
id: string
|
|
190
190
|
rowId: string
|
|
191
191
|
columnId: string
|
|
192
|
-
value:
|
|
193
|
-
row: Row<
|
|
194
|
-
column: Column<
|
|
192
|
+
value: TGenerics['Value']
|
|
193
|
+
row: Row<TGenerics>
|
|
194
|
+
column: Column<TGenerics>
|
|
195
195
|
getCellProps: PropGetter<CellProps>
|
|
196
196
|
renderCell: () => React.ReactNode
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
export type Header<
|
|
200
|
-
|
|
199
|
+
export type Header<TGenerics extends PartialGenerics> = CoreHeader<TGenerics> &
|
|
200
|
+
ColumnSizingHeader<TGenerics>
|
|
201
201
|
|
|
202
|
-
export type CoreHeader<
|
|
203
|
-
TData,
|
|
204
|
-
TValue,
|
|
205
|
-
TFilterFns,
|
|
206
|
-
TSortingFns,
|
|
207
|
-
TAggregationFns
|
|
208
|
-
> = {
|
|
202
|
+
export type CoreHeader<TGenerics extends PartialGenerics> = {
|
|
209
203
|
id: string
|
|
210
204
|
depth: number
|
|
211
|
-
column: Column<
|
|
205
|
+
column: Column<TGenerics>
|
|
212
206
|
getWidth: () => number
|
|
213
|
-
subHeaders: Header<
|
|
207
|
+
subHeaders: Header<TGenerics>[]
|
|
214
208
|
colSpan?: number
|
|
215
209
|
rowSpan?: number
|
|
216
210
|
getHeaderProps: PropGetter<HeaderProps>
|
|
217
211
|
getFooterProps: PropGetter<HeaderProps>
|
|
218
|
-
getLeafHeaders: () => Header<
|
|
219
|
-
TData,
|
|
220
|
-
TValue,
|
|
221
|
-
TFilterFns,
|
|
222
|
-
TSortingFns,
|
|
223
|
-
TAggregationFns
|
|
224
|
-
>[]
|
|
212
|
+
getLeafHeaders: () => Header<TGenerics>[]
|
|
225
213
|
isPlaceholder?: boolean
|
|
226
214
|
placeholderId?: string
|
|
227
215
|
renderHeader: (options?: { renderPlaceholder?: boolean }) => React.ReactNode
|
|
228
216
|
renderFooter: (options?: { renderPlaceholder?: boolean }) => React.ReactNode
|
|
229
217
|
}
|
|
230
218
|
|
|
231
|
-
export type HeaderGroup<
|
|
232
|
-
TData,
|
|
233
|
-
TValue,
|
|
234
|
-
TFilterFns,
|
|
235
|
-
TSortingFns,
|
|
236
|
-
TAggregationFns
|
|
237
|
-
> = {
|
|
219
|
+
export type HeaderGroup<TGenerics extends PartialGenerics> = {
|
|
238
220
|
id: string
|
|
239
221
|
depth: number
|
|
240
|
-
headers: Header<
|
|
222
|
+
headers: Header<TGenerics>[]
|
|
241
223
|
getHeaderGroupProps: PropGetter<HeaderGroupProps>
|
|
242
224
|
getFooterGroupProps: PropGetter<FooterGroupProps>
|
|
243
225
|
}
|
|
@@ -307,8 +289,6 @@ export type CellProps = {
|
|
|
307
289
|
role: string
|
|
308
290
|
}
|
|
309
291
|
|
|
310
|
-
export type Listener<TArgs extends [...any]> = (...args: [...TArgs]) => void
|
|
311
|
-
|
|
312
292
|
//
|
|
313
293
|
|
|
314
294
|
export type PropGetter<TBase> = <TGetter extends Getter<TBase>>(
|
|
@@ -1,41 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export function columnFilterRowsFn<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
TSortingFns,
|
|
8
|
-
TAggregationFns
|
|
9
|
-
>(
|
|
10
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
11
|
-
rowModel: RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
12
|
-
): RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
1
|
+
import { PartialGenerics, TableInstance, Row, RowModel } from '../types'
|
|
2
|
+
|
|
3
|
+
export function columnFilterRowsFn<TGenerics extends PartialGenerics>(
|
|
4
|
+
instance: TableInstance<TGenerics>,
|
|
5
|
+
rowModel: RowModel<TGenerics>
|
|
6
|
+
): RowModel<TGenerics> {
|
|
13
7
|
const columnFilters = instance.getState().columnFilters
|
|
14
8
|
|
|
15
|
-
const newFilteredFlatRows: Row<
|
|
16
|
-
|
|
17
|
-
TValue,
|
|
18
|
-
TFilterFns,
|
|
19
|
-
TSortingFns,
|
|
20
|
-
TAggregationFns
|
|
21
|
-
>[] = []
|
|
22
|
-
const newFilteredRowsById: Record<
|
|
23
|
-
string,
|
|
24
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
25
|
-
> = {}
|
|
9
|
+
const newFilteredFlatRows: Row<TGenerics>[] = []
|
|
10
|
+
const newFilteredRowsById: Record<string, Row<TGenerics>> = {}
|
|
26
11
|
|
|
27
12
|
const filterFromChildrenUp = instance.options.filterFromChildrenUp
|
|
28
13
|
|
|
29
|
-
const filterRows = (
|
|
30
|
-
rowsToFilter: Row<
|
|
31
|
-
TData,
|
|
32
|
-
TValue,
|
|
33
|
-
TFilterFns,
|
|
34
|
-
TSortingFns,
|
|
35
|
-
TAggregationFns
|
|
36
|
-
>[],
|
|
37
|
-
depth: number
|
|
38
|
-
) => {
|
|
14
|
+
const filterRows = (rowsToFilter: Row<TGenerics>[], depth: number) => {
|
|
39
15
|
columnFilters.forEach(({ id: columnId, value: filterValue }) => {
|
|
40
16
|
// Find the columnFilters column
|
|
41
17
|
const column = instance.getColumn(columnId)
|
|
@@ -74,16 +50,7 @@ export function columnFilterRowsFn<
|
|
|
74
50
|
}
|
|
75
51
|
|
|
76
52
|
if (filterFromChildrenUp) {
|
|
77
|
-
const recurseFilterRows = (
|
|
78
|
-
rowsToFilter: Row<
|
|
79
|
-
TData,
|
|
80
|
-
TValue,
|
|
81
|
-
TFilterFns,
|
|
82
|
-
TSortingFns,
|
|
83
|
-
TAggregationFns
|
|
84
|
-
>[],
|
|
85
|
-
depth = 0
|
|
86
|
-
) => {
|
|
53
|
+
const recurseFilterRows = (rowsToFilter: Row<TGenerics>[], depth = 0) => {
|
|
87
54
|
// Filter from children up
|
|
88
55
|
rowsToFilter = rowsToFilter.filter(row => {
|
|
89
56
|
if (!row.subRows?.length) {
|
|
@@ -114,16 +81,7 @@ export function columnFilterRowsFn<
|
|
|
114
81
|
}
|
|
115
82
|
|
|
116
83
|
// Filters top level and nested rows
|
|
117
|
-
const recurseFilterRows = (
|
|
118
|
-
rowsToFilter: Row<
|
|
119
|
-
TData,
|
|
120
|
-
TValue,
|
|
121
|
-
TFilterFns,
|
|
122
|
-
TSortingFns,
|
|
123
|
-
TAggregationFns
|
|
124
|
-
>[],
|
|
125
|
-
depth = 0
|
|
126
|
-
) => {
|
|
84
|
+
const recurseFilterRows = (rowsToFilter: Row<TGenerics>[], depth = 0) => {
|
|
127
85
|
// Filter from parents downward
|
|
128
86
|
rowsToFilter = filterRows(rowsToFilter, depth)
|
|
129
87
|
|
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PartialGenerics, TableInstance, Row, RowModel } from '../types'
|
|
2
2
|
|
|
3
|
-
export function expandRowsFn<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
TAggregationFns
|
|
9
|
-
>(
|
|
10
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
11
|
-
sortedRowModel: RowModel<
|
|
12
|
-
TData,
|
|
13
|
-
TValue,
|
|
14
|
-
TFilterFns,
|
|
15
|
-
TSortingFns,
|
|
16
|
-
TAggregationFns
|
|
17
|
-
>
|
|
18
|
-
): RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
19
|
-
const expandedRows: Row<
|
|
20
|
-
TData,
|
|
21
|
-
TValue,
|
|
22
|
-
TFilterFns,
|
|
23
|
-
TSortingFns,
|
|
24
|
-
TAggregationFns
|
|
25
|
-
>[] = []
|
|
3
|
+
export function expandRowsFn<TGenerics extends PartialGenerics>(
|
|
4
|
+
instance: TableInstance<TGenerics>,
|
|
5
|
+
sortedRowModel: RowModel<TGenerics>
|
|
6
|
+
): RowModel<TGenerics> {
|
|
7
|
+
const expandedRows: Row<TGenerics>[] = []
|
|
26
8
|
|
|
27
9
|
const { expandSubRows } = instance.options
|
|
28
10
|
|
|
29
|
-
const handleRow = (
|
|
30
|
-
row: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
31
|
-
) => {
|
|
11
|
+
const handleRow = (row: Row<TGenerics>) => {
|
|
32
12
|
expandedRows.push(row)
|
|
33
13
|
|
|
34
14
|
if (
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export function globalFilterRowsFn<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
TSortingFns,
|
|
8
|
-
TAggregationFns
|
|
9
|
-
>(
|
|
10
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
11
|
-
rowModel: RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
12
|
-
): RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
1
|
+
import { PartialGenerics, TableInstance, Row, RowModel } from '../types'
|
|
2
|
+
|
|
3
|
+
export function globalFilterRowsFn<TGenerics extends PartialGenerics>(
|
|
4
|
+
instance: TableInstance<TGenerics>,
|
|
5
|
+
rowModel: RowModel<TGenerics>
|
|
6
|
+
): RowModel<TGenerics> {
|
|
13
7
|
const globalFilter = instance.getState().globalFilter
|
|
14
|
-
const newFilteredFlatRows: Row<
|
|
15
|
-
|
|
16
|
-
TValue,
|
|
17
|
-
TFilterFns,
|
|
18
|
-
TSortingFns,
|
|
19
|
-
TAggregationFns
|
|
20
|
-
>[] = []
|
|
21
|
-
const newFilteredRowsById: Record<
|
|
22
|
-
string,
|
|
23
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
24
|
-
> = {}
|
|
8
|
+
const newFilteredFlatRows: Row<TGenerics>[] = []
|
|
9
|
+
const newFilteredRowsById: Record<string, Row<TGenerics>> = {}
|
|
25
10
|
|
|
26
11
|
const filterFromChildrenUp = instance.options.filterFromChildrenUp
|
|
27
12
|
|
|
@@ -41,16 +26,7 @@ export function globalFilterRowsFn<
|
|
|
41
26
|
const filterableColumnIds = filterableColumns.map(d => d.id)
|
|
42
27
|
|
|
43
28
|
if (filterFromChildrenUp) {
|
|
44
|
-
const recurseFilterRows = (
|
|
45
|
-
rowsToFilter: Row<
|
|
46
|
-
TData,
|
|
47
|
-
TValue,
|
|
48
|
-
TFilterFns,
|
|
49
|
-
TSortingFns,
|
|
50
|
-
TAggregationFns
|
|
51
|
-
>[],
|
|
52
|
-
depth = 0
|
|
53
|
-
) => {
|
|
29
|
+
const recurseFilterRows = (rowsToFilter: Row<TGenerics>[], depth = 0) => {
|
|
54
30
|
// Filter from children up
|
|
55
31
|
rowsToFilter = rowsToFilter.filter(row => {
|
|
56
32
|
if (!row.subRows?.length) {
|
|
@@ -81,16 +57,7 @@ export function globalFilterRowsFn<
|
|
|
81
57
|
}
|
|
82
58
|
|
|
83
59
|
// Filters top level and nested rows
|
|
84
|
-
const recurseFilterRows = (
|
|
85
|
-
rowsToFilter: Row<
|
|
86
|
-
TData,
|
|
87
|
-
TValue,
|
|
88
|
-
TFilterFns,
|
|
89
|
-
TSortingFns,
|
|
90
|
-
TAggregationFns
|
|
91
|
-
>[],
|
|
92
|
-
depth = 0
|
|
93
|
-
) => {
|
|
60
|
+
const recurseFilterRows = (rowsToFilter: Row<TGenerics>[], depth = 0) => {
|
|
94
61
|
// Filter from parents downward
|
|
95
62
|
rowsToFilter = filterFn(rowsToFilter, filterableColumnIds, globalFilter)
|
|
96
63
|
|
package/src/utils/groupRowsFn.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PartialGenerics, TableInstance, Row, RowModel } from '../types'
|
|
2
2
|
import { flattenBy } from '../utils'
|
|
3
3
|
|
|
4
|
-
export function groupRowsFn<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
TSortingFns,
|
|
9
|
-
TAggregationFns
|
|
10
|
-
>(
|
|
11
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
12
|
-
sortedRowModel: RowModel<
|
|
13
|
-
TData,
|
|
14
|
-
TValue,
|
|
15
|
-
TFilterFns,
|
|
16
|
-
TSortingFns,
|
|
17
|
-
TAggregationFns
|
|
18
|
-
>
|
|
19
|
-
): RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
4
|
+
export function groupRowsFn<TGenerics extends PartialGenerics>(
|
|
5
|
+
instance: TableInstance<TGenerics>,
|
|
6
|
+
sortedRowModel: RowModel<TGenerics>
|
|
7
|
+
): RowModel<TGenerics> {
|
|
20
8
|
const groupingState = instance.getState().grouping
|
|
21
9
|
// Filter the grouping list down to columns that exist
|
|
22
10
|
const existingGrouping = groupingState.filter(columnId =>
|
|
@@ -26,8 +14,8 @@ export function groupRowsFn<
|
|
|
26
14
|
// Find the columns that can or are aggregating
|
|
27
15
|
// Uses each column to aggregate rows into a single value
|
|
28
16
|
const aggregateRowsToValues = (
|
|
29
|
-
leafRows: Row<
|
|
30
|
-
groupedRows: Row<
|
|
17
|
+
leafRows: Row<TGenerics>[],
|
|
18
|
+
groupedRows: Row<TGenerics>[],
|
|
31
19
|
depth: number
|
|
32
20
|
) => {
|
|
33
21
|
const values: Record<string, unknown> = {}
|
|
@@ -75,17 +63,8 @@ export function groupRowsFn<
|
|
|
75
63
|
return values
|
|
76
64
|
}
|
|
77
65
|
|
|
78
|
-
const groupedFlatRows: Row<
|
|
79
|
-
|
|
80
|
-
TValue,
|
|
81
|
-
TFilterFns,
|
|
82
|
-
TSortingFns,
|
|
83
|
-
TAggregationFns
|
|
84
|
-
>[] = []
|
|
85
|
-
const groupedRowsById: Record<
|
|
86
|
-
string,
|
|
87
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
88
|
-
> = {}
|
|
66
|
+
const groupedFlatRows: Row<TGenerics>[] = []
|
|
67
|
+
const groupedRowsById: Record<string, Row<TGenerics>> = {}
|
|
89
68
|
// const onlyGroupedFlatRows: Row[] = [];
|
|
90
69
|
// const onlyGroupedRowsById: Record<RowId, Row> = {};
|
|
91
70
|
// const nonGroupedFlatRows: Row[] = [];
|
|
@@ -93,7 +72,7 @@ export function groupRowsFn<
|
|
|
93
72
|
|
|
94
73
|
// Recursively group the data
|
|
95
74
|
const groupUpRecursively = (
|
|
96
|
-
rows: Row<
|
|
75
|
+
rows: Row<TGenerics>[],
|
|
97
76
|
depth = 0,
|
|
98
77
|
parentId: string
|
|
99
78
|
) => {
|
|
@@ -172,14 +151,11 @@ export function groupRowsFn<
|
|
|
172
151
|
}
|
|
173
152
|
}
|
|
174
153
|
|
|
175
|
-
function groupBy<
|
|
176
|
-
rows: Row<
|
|
154
|
+
function groupBy<TGenerics extends PartialGenerics>(
|
|
155
|
+
rows: Row<TGenerics>[],
|
|
177
156
|
columnId: string
|
|
178
157
|
) {
|
|
179
|
-
const groupMap = new Map<
|
|
180
|
-
any,
|
|
181
|
-
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>[]
|
|
182
|
-
>()
|
|
158
|
+
const groupMap = new Map<any, Row<TGenerics>[]>()
|
|
183
159
|
|
|
184
160
|
return rows.reduce((map, row) => {
|
|
185
161
|
const resKey = `${row.values[columnId]}`
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PartialGenerics, TableInstance, RowModel } from '../types'
|
|
2
2
|
import { expandRowsFn } from './expandRowsFn'
|
|
3
3
|
|
|
4
|
-
export function paginateRowsFn<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
TSortingFns,
|
|
9
|
-
TAggregationFns
|
|
10
|
-
>(
|
|
11
|
-
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
12
|
-
rowModel: RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
13
|
-
): RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
4
|
+
export function paginateRowsFn<TGenerics extends PartialGenerics>(
|
|
5
|
+
instance: TableInstance<TGenerics>,
|
|
6
|
+
rowModel: RowModel<TGenerics>
|
|
7
|
+
): RowModel<TGenerics> {
|
|
14
8
|
const { pageSize, pageIndex } = instance.getState().pagination
|
|
15
9
|
let { rows, flatRows, rowsById } = rowModel
|
|
16
10
|
const pageStart = pageSize * pageIndex
|