@tanstack/react-table 0.0.1-alpha.0
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/dist/react-table.development.js +3406 -0
- package/dist/react-table.development.js.map +1 -0
- package/dist/react-table.production.min.js +2 -0
- package/dist/react-table.production.min.js.map +1 -0
- package/lib/index.js +65 -0
- package/package.json +122 -0
- package/src/.DS_Store +0 -0
- package/src/aggregationTypes.ts +115 -0
- package/src/core.tsx +1194 -0
- package/src/createTable.tsx +181 -0
- package/src/features/Expanding.ts +388 -0
- package/src/features/Filters.ts +707 -0
- package/src/features/Grouping.ts +451 -0
- package/src/features/Headers.ts +907 -0
- package/src/features/Ordering.ts +134 -0
- package/src/features/Pinning.ts +213 -0
- package/src/features/Sorting.ts +487 -0
- package/src/features/Visibility.ts +281 -0
- package/src/features/notest/useAbsoluteLayout.test.js +152 -0
- package/src/features/notest/useBlockLayout.test.js +158 -0
- package/src/features/notest/useColumnOrder.test.js +186 -0
- package/src/features/notest/useExpanded.test.js +125 -0
- package/src/features/notest/useFilters.test.js +393 -0
- package/src/features/notest/useFiltersAndRowSelect.test.js +256 -0
- package/src/features/notest/useFlexLayout.test.js +152 -0
- package/src/features/notest/useGroupBy.test.js +259 -0
- package/src/features/notest/usePagination.test.js +231 -0
- package/src/features/notest/useResizeColumns.test.js +229 -0
- package/src/features/notest/useRowSelect.test.js +250 -0
- package/src/features/notest/useRowState.test.js +178 -0
- package/src/features/tests/Visibility.test.tsx +225 -0
- package/src/features/tests/__snapshots__/Visibility.test.tsx.snap +390 -0
- package/src/features/tests/withSorting.notest.tsx +341 -0
- package/src/features/withColumnResizing.ts +281 -0
- package/src/features/withPagination.ts +208 -0
- package/src/features/withRowSelection.ts +467 -0
- package/src/filterTypes.ts +251 -0
- package/src/index.tsx +7 -0
- package/src/sortTypes.ts +159 -0
- package/src/test-utils/makeTestData.ts +41 -0
- package/src/tests/__snapshots__/core.test.tsx.snap +148 -0
- package/src/tests/core.test.tsx +241 -0
- package/src/types.ts +285 -0
- package/src/utils/columnFilterRowsFn.ts +162 -0
- package/src/utils/expandRowsFn.ts +53 -0
- package/src/utils/globalFilterRowsFn.ts +129 -0
- package/src/utils/groupRowsFn.ts +196 -0
- package/src/utils/sortRowsFn.ts +115 -0
- package/src/utils.tsx +243 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } from 'react'
|
|
2
|
+
import { RowModel } from '..'
|
|
3
|
+
import { BuiltInSortType, sortTypes } from '../sortTypes'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Column,
|
|
7
|
+
Getter,
|
|
8
|
+
OnChangeFn,
|
|
9
|
+
PropGetterValue,
|
|
10
|
+
ReactTable,
|
|
11
|
+
Row,
|
|
12
|
+
Updater,
|
|
13
|
+
} from '../types'
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
functionalUpdate,
|
|
17
|
+
isFunction,
|
|
18
|
+
makeStateUpdater,
|
|
19
|
+
memo,
|
|
20
|
+
propGetter,
|
|
21
|
+
} from '../utils'
|
|
22
|
+
|
|
23
|
+
export type ColumnSort = {
|
|
24
|
+
id: string
|
|
25
|
+
desc: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SortingState = ColumnSort[]
|
|
29
|
+
|
|
30
|
+
export type SortingFn<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> =
|
|
31
|
+
{
|
|
32
|
+
(
|
|
33
|
+
rowA: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
34
|
+
rowB: Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
35
|
+
columnId: string
|
|
36
|
+
): number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type SortingTableState = {
|
|
40
|
+
sorting: SortingState
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type SortType<TSortingFns> =
|
|
44
|
+
| 'auto'
|
|
45
|
+
| BuiltInSortType
|
|
46
|
+
| keyof TSortingFns
|
|
47
|
+
| SortingFn<any, any, any, TSortingFns, any>
|
|
48
|
+
|
|
49
|
+
export type SortingColumnDef<TFilterFns> = {
|
|
50
|
+
sortType?: SortType<TFilterFns>
|
|
51
|
+
sortDescFirst?: boolean
|
|
52
|
+
enableSorting?: boolean
|
|
53
|
+
enableMultiSort?: boolean
|
|
54
|
+
defaultCanSort?: boolean
|
|
55
|
+
invertSorting?: boolean
|
|
56
|
+
sortUndefined?: false | -1 | 1
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type SortingColumn<
|
|
60
|
+
_TData,
|
|
61
|
+
_TValue,
|
|
62
|
+
TFilterFns,
|
|
63
|
+
_TSortingFns,
|
|
64
|
+
_TAggregationFns
|
|
65
|
+
> = {
|
|
66
|
+
sortType: SortType<TFilterFns>
|
|
67
|
+
getCanSort: () => boolean
|
|
68
|
+
getCanMultiSort: () => boolean
|
|
69
|
+
getSortIndex: () => number
|
|
70
|
+
getIsSorted: () => false | 'asc' | 'desc'
|
|
71
|
+
toggleSorting: (desc?: boolean, isMulti?: boolean) => void
|
|
72
|
+
getToggleSortingProps: <TGetter extends Getter<ToggleSortingProps>>(
|
|
73
|
+
userProps?: TGetter
|
|
74
|
+
) => undefined | PropGetterValue<ToggleSortingProps, TGetter>
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type SortingOptions<
|
|
78
|
+
TData,
|
|
79
|
+
TValue,
|
|
80
|
+
TFilterFns,
|
|
81
|
+
TSortingFns,
|
|
82
|
+
TAggregationFns
|
|
83
|
+
> = {
|
|
84
|
+
sortTypes?: TSortingFns
|
|
85
|
+
onSortingChange?: OnChangeFn<SortingState>
|
|
86
|
+
autoResetSorting?: boolean
|
|
87
|
+
enableSorting?: boolean
|
|
88
|
+
enableSortingRemoval?: boolean
|
|
89
|
+
enableMultiRemove?: boolean
|
|
90
|
+
enableMultiSort?: boolean
|
|
91
|
+
sortDescFirst?: boolean
|
|
92
|
+
sortRowsFn?: (
|
|
93
|
+
instance: ReactTable<
|
|
94
|
+
TData,
|
|
95
|
+
TValue,
|
|
96
|
+
TFilterFns,
|
|
97
|
+
TSortingFns,
|
|
98
|
+
TAggregationFns
|
|
99
|
+
>,
|
|
100
|
+
sortingState: SortingState,
|
|
101
|
+
globalFilteredRowModel: RowModel<
|
|
102
|
+
TData,
|
|
103
|
+
TValue,
|
|
104
|
+
TFilterFns,
|
|
105
|
+
TSortingFns,
|
|
106
|
+
TAggregationFns
|
|
107
|
+
>
|
|
108
|
+
) => RowModel<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
109
|
+
maxMultiSortColCount?: number
|
|
110
|
+
isMultiSortEvent?: (e: MouseEvent | TouchEvent) => boolean
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type ToggleSortingProps = {
|
|
114
|
+
title?: string
|
|
115
|
+
onClick?: (event: MouseEvent | TouchEvent) => void
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type SortingInstance<
|
|
119
|
+
TData,
|
|
120
|
+
TValue,
|
|
121
|
+
TFilterFns,
|
|
122
|
+
TSortingFns,
|
|
123
|
+
TAggregationFns
|
|
124
|
+
> = {
|
|
125
|
+
getColumnAutoSortingFn: (
|
|
126
|
+
columnId: string
|
|
127
|
+
) => SortingFn<any, any, any, any, any> | undefined
|
|
128
|
+
|
|
129
|
+
getColumnSortingFn: (
|
|
130
|
+
columnId: string
|
|
131
|
+
) => SortingFn<any, any, any, any, any> | undefined
|
|
132
|
+
|
|
133
|
+
setSorting: (updater: Updater<SortingState>) => void
|
|
134
|
+
toggleColumnSorting: (
|
|
135
|
+
columnId: string,
|
|
136
|
+
desc?: boolean,
|
|
137
|
+
multi?: boolean
|
|
138
|
+
) => void
|
|
139
|
+
resetSorting: () => void
|
|
140
|
+
getColumnCanSort: (columnId: string) => boolean
|
|
141
|
+
getColumnCanMultiSort: (columnId: string) => boolean
|
|
142
|
+
getColumnIsSorted: (columnId: string) => false | 'asc' | 'desc'
|
|
143
|
+
getColumnSortIndex: (columnId: string) => number
|
|
144
|
+
getToggleSortingProps: <TGetter extends Getter<ToggleSortingProps>>(
|
|
145
|
+
columnId: string,
|
|
146
|
+
userProps?: TGetter
|
|
147
|
+
) => undefined | PropGetterValue<ToggleSortingProps, TGetter>
|
|
148
|
+
getSortedRowModel: () => RowModel<
|
|
149
|
+
TData,
|
|
150
|
+
TValue,
|
|
151
|
+
TFilterFns,
|
|
152
|
+
TSortingFns,
|
|
153
|
+
TAggregationFns
|
|
154
|
+
>
|
|
155
|
+
getPreSortedRows: () => Row<
|
|
156
|
+
TData,
|
|
157
|
+
TValue,
|
|
158
|
+
TFilterFns,
|
|
159
|
+
TSortingFns,
|
|
160
|
+
TAggregationFns
|
|
161
|
+
>[]
|
|
162
|
+
getPreSortedFlatRows: () => Row<
|
|
163
|
+
TData,
|
|
164
|
+
TValue,
|
|
165
|
+
TFilterFns,
|
|
166
|
+
TSortingFns,
|
|
167
|
+
TAggregationFns
|
|
168
|
+
>[]
|
|
169
|
+
getPreSortedRowsById: () => Record<
|
|
170
|
+
string,
|
|
171
|
+
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
172
|
+
>
|
|
173
|
+
getSortedRows: () => Row<
|
|
174
|
+
TData,
|
|
175
|
+
TValue,
|
|
176
|
+
TFilterFns,
|
|
177
|
+
TSortingFns,
|
|
178
|
+
TAggregationFns
|
|
179
|
+
>[]
|
|
180
|
+
getSortedFlatRows: () => Row<
|
|
181
|
+
TData,
|
|
182
|
+
TValue,
|
|
183
|
+
TFilterFns,
|
|
184
|
+
TSortingFns,
|
|
185
|
+
TAggregationFns
|
|
186
|
+
>[]
|
|
187
|
+
getSortedRowsById: () => Record<
|
|
188
|
+
string,
|
|
189
|
+
Row<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
190
|
+
>
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
//
|
|
194
|
+
|
|
195
|
+
export function getDefaultColumn<TFilterFns>(): SortingColumnDef<TFilterFns> {
|
|
196
|
+
return {
|
|
197
|
+
sortType: 'auto',
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function getInitialState(): SortingTableState {
|
|
202
|
+
return {
|
|
203
|
+
sorting: [],
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function getDefaultOptions<
|
|
208
|
+
TData,
|
|
209
|
+
TValue,
|
|
210
|
+
TFilterFns,
|
|
211
|
+
TSortingFns,
|
|
212
|
+
TAggregationFns
|
|
213
|
+
>(
|
|
214
|
+
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
215
|
+
): SortingOptions<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
216
|
+
return {
|
|
217
|
+
onSortingChange: makeStateUpdater('sorting', instance),
|
|
218
|
+
autoResetSorting: true,
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function createColumn<
|
|
223
|
+
TData,
|
|
224
|
+
TValue,
|
|
225
|
+
TFilterFns,
|
|
226
|
+
TSortingFns,
|
|
227
|
+
TAggregationFns
|
|
228
|
+
>(
|
|
229
|
+
column: Column<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>,
|
|
230
|
+
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
231
|
+
): SortingColumn<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
232
|
+
return {
|
|
233
|
+
sortType: column.sortType,
|
|
234
|
+
getCanSort: () => instance.getColumnCanSort(column.id),
|
|
235
|
+
getCanMultiSort: () => instance.getColumnCanMultiSort(column.id),
|
|
236
|
+
getSortIndex: () => instance.getColumnSortIndex(column.id),
|
|
237
|
+
getIsSorted: () => instance.getColumnIsSorted(column.id),
|
|
238
|
+
toggleSorting: (desc, isMulti) =>
|
|
239
|
+
instance.toggleColumnSorting(column.id, desc, isMulti),
|
|
240
|
+
getToggleSortingProps: userProps =>
|
|
241
|
+
instance.getToggleSortingProps(column.id, userProps),
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function getInstance<
|
|
246
|
+
TData,
|
|
247
|
+
TValue,
|
|
248
|
+
TFilterFns,
|
|
249
|
+
TSortingFns,
|
|
250
|
+
TAggregationFns
|
|
251
|
+
>(
|
|
252
|
+
instance: ReactTable<TData, TValue, TFilterFns, TSortingFns, TAggregationFns>
|
|
253
|
+
): SortingInstance<TData, TValue, TFilterFns, TSortingFns, TAggregationFns> {
|
|
254
|
+
return {
|
|
255
|
+
getColumnAutoSortingFn: columnId => {
|
|
256
|
+
const firstRow = instance.getGlobalFilteredRowModel().flatRows[0]
|
|
257
|
+
|
|
258
|
+
const value = firstRow?.values[columnId]
|
|
259
|
+
|
|
260
|
+
if (typeof value === 'string') {
|
|
261
|
+
return sortTypes.alphanumeric
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
265
|
+
return sortTypes.datetime
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return sortTypes.basic
|
|
269
|
+
},
|
|
270
|
+
getColumnSortingFn: columnId => {
|
|
271
|
+
const column = instance.getColumn(columnId)
|
|
272
|
+
const userSortTypes = instance.options.sortTypes
|
|
273
|
+
|
|
274
|
+
if (!column) {
|
|
275
|
+
throw new Error()
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return isFunction(column.sortType)
|
|
279
|
+
? column.sortType
|
|
280
|
+
: column.sortType === 'auto'
|
|
281
|
+
? instance.getColumnAutoFilterFn(columnId)
|
|
282
|
+
: (userSortTypes as Record<string, any>)?.[column.sortType as string] ??
|
|
283
|
+
(sortTypes[column.sortType as BuiltInSortType] as SortingFn<
|
|
284
|
+
TData,
|
|
285
|
+
TValue,
|
|
286
|
+
TFilterFns,
|
|
287
|
+
TSortingFns,
|
|
288
|
+
TAggregationFns
|
|
289
|
+
>)
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
setSorting: updater =>
|
|
293
|
+
instance.options.onSortingChange?.(
|
|
294
|
+
updater,
|
|
295
|
+
functionalUpdate(updater, instance.getState().sorting)
|
|
296
|
+
),
|
|
297
|
+
|
|
298
|
+
toggleColumnSorting: (columnId, desc, multi) => {
|
|
299
|
+
const column = instance.getColumn(columnId)
|
|
300
|
+
|
|
301
|
+
if (!column) {
|
|
302
|
+
throw new Error()
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
instance.setSorting(old => {
|
|
306
|
+
// Find any existing sorting for this column
|
|
307
|
+
const existingSorting = old?.find(d => d.id === columnId)
|
|
308
|
+
const existingIndex = old?.findIndex(d => d.id === columnId)
|
|
309
|
+
const hasDescDefined = typeof desc !== 'undefined' && desc !== null
|
|
310
|
+
|
|
311
|
+
let newSorting: SortingState = []
|
|
312
|
+
|
|
313
|
+
// What should we do with this sort action?
|
|
314
|
+
let sortAction
|
|
315
|
+
|
|
316
|
+
if (!column.getCanMultiSort() && multi) {
|
|
317
|
+
if (existingSorting) {
|
|
318
|
+
sortAction = 'toggle'
|
|
319
|
+
} else {
|
|
320
|
+
sortAction = 'add'
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
// Normal mode
|
|
324
|
+
if (old?.length && existingIndex !== old.length - 1) {
|
|
325
|
+
sortAction = 'replace'
|
|
326
|
+
} else if (existingSorting) {
|
|
327
|
+
sortAction = 'toggle'
|
|
328
|
+
} else {
|
|
329
|
+
sortAction = 'replace'
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const sortDescFirst =
|
|
334
|
+
column.sortDescFirst ?? instance.options.sortDescFirst
|
|
335
|
+
|
|
336
|
+
// Handle toggle states that will remove the sorting
|
|
337
|
+
if (
|
|
338
|
+
sortAction === 'toggle' && // Must be toggling
|
|
339
|
+
(instance.options.enableSortingRemoval ?? true) && // If enableSortRemove, enable in general
|
|
340
|
+
!hasDescDefined && // Must not be setting desc
|
|
341
|
+
(multi ? instance.options.enableMultiRemove ?? true : true) && // If multi, don't allow if enableMultiRemove
|
|
342
|
+
(existingSorting?.desc // Finally, detect if it should indeed be removed
|
|
343
|
+
? !sortDescFirst
|
|
344
|
+
: sortDescFirst)
|
|
345
|
+
) {
|
|
346
|
+
sortAction = 'remove'
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (sortAction === 'replace') {
|
|
350
|
+
newSorting = [
|
|
351
|
+
{
|
|
352
|
+
id: columnId,
|
|
353
|
+
desc: hasDescDefined ? desc! : !!sortDescFirst,
|
|
354
|
+
},
|
|
355
|
+
]
|
|
356
|
+
} else if (sortAction === 'add' && old?.length) {
|
|
357
|
+
newSorting = [
|
|
358
|
+
...old,
|
|
359
|
+
{
|
|
360
|
+
id: columnId,
|
|
361
|
+
desc: hasDescDefined ? desc! : !!sortDescFirst,
|
|
362
|
+
},
|
|
363
|
+
]
|
|
364
|
+
// Take latest n columns
|
|
365
|
+
newSorting.splice(
|
|
366
|
+
0,
|
|
367
|
+
newSorting.length -
|
|
368
|
+
(instance.options.maxMultiSortColCount ?? Number.MAX_SAFE_INTEGER)
|
|
369
|
+
)
|
|
370
|
+
} else if (sortAction === 'toggle' && old?.length) {
|
|
371
|
+
// This flips (or sets) the
|
|
372
|
+
newSorting = old.map(d => {
|
|
373
|
+
if (d.id === columnId) {
|
|
374
|
+
return {
|
|
375
|
+
...d,
|
|
376
|
+
desc: hasDescDefined ? desc! : !existingSorting?.desc,
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return d
|
|
380
|
+
})
|
|
381
|
+
} else if (sortAction === 'remove' && old?.length) {
|
|
382
|
+
newSorting = old.filter(d => d.id !== columnId)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return newSorting
|
|
386
|
+
})
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
getColumnCanSort: columnId => {
|
|
390
|
+
const column = instance.getColumn(columnId)
|
|
391
|
+
|
|
392
|
+
if (!column) {
|
|
393
|
+
throw new Error()
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
column.enableSorting ??
|
|
398
|
+
instance.options.enableSorting ??
|
|
399
|
+
column.defaultCanSort ??
|
|
400
|
+
!!column.accessorFn
|
|
401
|
+
)
|
|
402
|
+
},
|
|
403
|
+
|
|
404
|
+
getColumnCanMultiSort: columnId => {
|
|
405
|
+
const column = instance.getColumn(columnId)
|
|
406
|
+
|
|
407
|
+
if (!column) {
|
|
408
|
+
throw new Error()
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return (
|
|
412
|
+
column.enableMultiSort ??
|
|
413
|
+
instance.options.enableMultiSort ??
|
|
414
|
+
!!column.accessorFn
|
|
415
|
+
)
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
getColumnIsSorted: columnId => {
|
|
419
|
+
const columnSort = instance
|
|
420
|
+
.getState()
|
|
421
|
+
.sorting?.find(d => d.id === columnId)
|
|
422
|
+
|
|
423
|
+
return !columnSort ? false : columnSort.desc ? 'desc' : 'asc'
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
getColumnSortIndex: columnId =>
|
|
427
|
+
instance.getState().sorting?.findIndex(d => d.id === columnId) ?? -1,
|
|
428
|
+
|
|
429
|
+
resetSorting: () => {
|
|
430
|
+
instance.setSorting(instance.options?.initialState?.sorting ?? [])
|
|
431
|
+
},
|
|
432
|
+
|
|
433
|
+
getToggleSortingProps: (columnId, userProps) => {
|
|
434
|
+
const column = instance.getColumn(columnId)
|
|
435
|
+
|
|
436
|
+
if (!column) {
|
|
437
|
+
throw new Error()
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const canSort = column.getCanSort()
|
|
441
|
+
|
|
442
|
+
const initialProps: ToggleSortingProps = {
|
|
443
|
+
title: canSort ? 'Toggle Sorting' : undefined,
|
|
444
|
+
onClick: canSort
|
|
445
|
+
? (e: MouseEvent | TouchEvent) => {
|
|
446
|
+
e.persist()
|
|
447
|
+
column.toggleSorting?.(
|
|
448
|
+
undefined,
|
|
449
|
+
column.getCanMultiSort()
|
|
450
|
+
? instance.options.isMultiSortEvent?.(e)
|
|
451
|
+
: false
|
|
452
|
+
)
|
|
453
|
+
}
|
|
454
|
+
: undefined,
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return propGetter(initialProps, userProps)
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
getSortedRowModel: memo(
|
|
461
|
+
() => [
|
|
462
|
+
instance.getState().sorting,
|
|
463
|
+
instance.getGlobalFilteredRowModel(),
|
|
464
|
+
instance.options.sortRowsFn,
|
|
465
|
+
],
|
|
466
|
+
(sorting, rowModel, sortingFn) => {
|
|
467
|
+
if (!sortingFn || !sorting?.length) {
|
|
468
|
+
return rowModel
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (process.env.NODE_ENV !== 'production' && instance.options.debug)
|
|
472
|
+
console.info('Sorting...')
|
|
473
|
+
|
|
474
|
+
return sortingFn(instance, sorting, rowModel)
|
|
475
|
+
},
|
|
476
|
+
'getSortedRowModel',
|
|
477
|
+
instance.options.debug
|
|
478
|
+
),
|
|
479
|
+
|
|
480
|
+
getPreSortedRows: () => instance.getGlobalFilteredRowModel().rows,
|
|
481
|
+
getPreSortedFlatRows: () => instance.getGlobalFilteredRowModel().flatRows,
|
|
482
|
+
getPreSortedRowsById: () => instance.getGlobalFilteredRowModel().rowsById,
|
|
483
|
+
getSortedRows: () => instance.getSortedRowModel().rows,
|
|
484
|
+
getSortedFlatRows: () => instance.getSortedRowModel().flatRows,
|
|
485
|
+
getSortedRowsById: () => instance.getSortedRowModel().rowsById,
|
|
486
|
+
}
|
|
487
|
+
}
|