@tanstack/table-core 8.0.0-alpha.27 → 8.0.0-alpha.32
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/aggregationTypes.js +1 -0
- package/build/cjs/aggregationTypes.js.map +1 -1
- package/build/cjs/core.js +29 -79
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js +14 -18
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +29 -82
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +10 -16
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +10 -17
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +11 -17
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterTypes.js.map +1 -1
- package/build/cjs/index.js +19 -12
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortTypes.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/cjs/utils/getColumnFilteredRowModelSync.js +113 -0
- package/build/cjs/utils/getColumnFilteredRowModelSync.js.map +1 -0
- package/build/cjs/utils/getCoreRowModelAsync.js +125 -0
- package/build/cjs/utils/getCoreRowModelAsync.js.map +1 -0
- package/build/cjs/utils/getCoreRowModelSync.js +102 -0
- package/build/cjs/utils/getCoreRowModelSync.js.map +1 -0
- package/build/cjs/utils/getExpandedRowModel.js +61 -0
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -0
- package/build/cjs/utils/getGlobalFilteredRowModelSync.js +89 -0
- package/build/cjs/utils/getGlobalFilteredRowModelSync.js.map +1 -0
- package/build/cjs/utils/getGroupedRowModel.js +174 -0
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -0
- package/build/cjs/utils/getPaginationRowModel.js +61 -0
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -0
- package/build/cjs/utils/getSortedRowModelSync.js +116 -0
- package/build/cjs/utils/getSortedRowModelSync.js.map +1 -0
- package/build/cjs/utils.js +159 -21
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +857 -505
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +406 -312
- package/build/types/aggregationTypes.d.ts +1 -1
- package/build/types/core.d.ts +9 -1
- package/build/types/createTable.d.ts +2 -4
- package/build/types/features/Expanding.d.ts +2 -1
- package/build/types/features/Filters.d.ts +6 -2
- package/build/types/features/Grouping.d.ts +3 -2
- package/build/types/features/Pagination.d.ts +2 -1
- package/build/types/features/Sorting.d.ts +2 -1
- package/build/types/index.d.ts +8 -6
- package/build/types/types.d.ts +3 -2
- package/build/types/utils/getColumnFilteredRowModelAsync.d.ts +4 -0
- package/build/types/utils/getColumnFilteredRowModelSync.d.ts +2 -0
- package/build/types/utils/getCoreRowModelAsync.d.ts +4 -0
- package/build/types/utils/getCoreRowModelSync.d.ts +2 -0
- package/build/types/utils/getExpandedRowModel.d.ts +7 -0
- package/build/types/utils/getGlobalFilteredRowModelAsync.d.ts +4 -0
- package/build/types/utils/getGlobalFilteredRowModelSync.d.ts +2 -0
- package/build/types/utils/getGroupedRowModel.d.ts +2 -0
- package/build/types/utils/getPaginationRowModel.d.ts +4 -0
- package/build/types/utils/{sortRowsQuicksortFn.d.ts → getSortedRowModelAsync.d.ts} +3 -1
- package/build/types/utils/getSortedRowModelSync.d.ts +2 -0
- package/build/types/utils.d.ts +16 -0
- package/build/umd/index.development.js +872 -513
- 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/aggregationTypes.ts +1 -1
- package/src/core.tsx +46 -99
- package/src/createTable.tsx +2 -6
- package/src/features/Expanding.ts +21 -29
- package/src/features/Filters.ts +53 -100
- package/src/features/Grouping.ts +19 -21
- package/src/features/Pagination.ts +19 -28
- package/src/features/Sorting.ts +20 -24
- package/src/index.tsx +8 -6
- package/src/types.ts +4 -1
- package/src/utils/getColumnFilteredRowModelAsync.ts +117 -0
- package/src/utils/getColumnFilteredRowModelSync.ts +97 -0
- package/src/utils/getCoreRowModelAsync.ts +103 -0
- package/src/utils/getCoreRowModelSync.ts +105 -0
- package/src/utils/getExpandedRowModel.ts +58 -0
- package/src/utils/getGlobalFilteredRowModelAsync.ts +95 -0
- package/src/utils/getGlobalFilteredRowModelSync.ts +74 -0
- package/src/utils/getGroupedRowModel.ts +187 -0
- package/src/utils/getPaginationRowModel.ts +45 -0
- package/src/utils/getSortedRowModelAsync.ts +199 -0
- package/src/utils/getSortedRowModelSync.ts +116 -0
- package/src/utils.tsx +193 -22
- package/build/cjs/utils/columnFilterRowsFn.js +0 -73
- package/build/cjs/utils/columnFilterRowsFn.js.map +0 -1
- package/build/cjs/utils/expandRowsFn.js +0 -37
- package/build/cjs/utils/expandRowsFn.js.map +0 -1
- package/build/cjs/utils/globalFilterRowsFn.js +0 -49
- package/build/cjs/utils/globalFilterRowsFn.js.map +0 -1
- package/build/cjs/utils/groupRowsFn.js +0 -155
- package/build/cjs/utils/groupRowsFn.js.map +0 -1
- package/build/cjs/utils/paginateRowsFn.js +0 -44
- package/build/cjs/utils/paginateRowsFn.js.map +0 -1
- package/build/cjs/utils/sortRowsFn.js +0 -94
- package/build/cjs/utils/sortRowsFn.js.map +0 -1
- package/build/types/utils/columnFilterRowsFn.d.ts +0 -2
- package/build/types/utils/expandRowsFn.d.ts +0 -2
- package/build/types/utils/globalFilterRowsFn.d.ts +0 -2
- package/build/types/utils/groupRowsFn.d.ts +0 -2
- package/build/types/utils/paginateRowsFn.d.ts +0 -2
- package/build/types/utils/sortRowsFn.d.ts +0 -2
- package/src/utils/columnFilterRowsFn.ts +0 -56
- package/src/utils/expandRowsFn.ts +0 -34
- package/src/utils/globalFilterRowsFn.ts +0 -39
- package/src/utils/groupRowsFn.ts +0 -174
- package/src/utils/paginateRowsFn.ts +0 -28
- package/src/utils/sortRowsFn.ts +0 -99
- package/src/utils/sortRowsQuicksortFn.ts +0 -174
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { TableInstance, Row, RowModel, AnyGenerics } from '../types'
|
|
2
|
+
import { SortingFn } from '../features/Sorting'
|
|
3
|
+
import { memo } from '../utils'
|
|
4
|
+
|
|
5
|
+
export function getSortedRowModelSync<TGenerics extends AnyGenerics>(): (
|
|
6
|
+
instance: TableInstance<TGenerics>
|
|
7
|
+
) => () => RowModel<TGenerics> {
|
|
8
|
+
return instance =>
|
|
9
|
+
memo(
|
|
10
|
+
() => [instance.getState().sorting, instance.getGlobalFilteredRowModel()],
|
|
11
|
+
(sorting, rowModel) => {
|
|
12
|
+
if (!rowModel.rows.length || !sorting?.length) {
|
|
13
|
+
return rowModel
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const sortingState = instance.getState().sorting
|
|
17
|
+
|
|
18
|
+
const sortedFlatRows: Row<TGenerics>[] = []
|
|
19
|
+
|
|
20
|
+
// Filter out sortings that correspond to non existing columns
|
|
21
|
+
const availableSorting = sortingState.filter(sort =>
|
|
22
|
+
instance.getColumnCanSort(sort.id)
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const columnInfoById: Record<
|
|
26
|
+
string,
|
|
27
|
+
{
|
|
28
|
+
sortUndefined?: false | -1 | 1
|
|
29
|
+
invertSorting?: boolean
|
|
30
|
+
sortingFn: SortingFn<TGenerics>
|
|
31
|
+
}
|
|
32
|
+
> = {}
|
|
33
|
+
|
|
34
|
+
availableSorting.forEach(sortEntry => {
|
|
35
|
+
const column = instance.getColumn(sortEntry.id)!
|
|
36
|
+
|
|
37
|
+
columnInfoById[sortEntry.id] = {
|
|
38
|
+
sortUndefined: column.sortUndefined,
|
|
39
|
+
invertSorting: column.invertSorting,
|
|
40
|
+
sortingFn: instance.getColumnSortingFn(sortEntry.id)!,
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const sortData = (rows: Row<TGenerics>[]) => {
|
|
45
|
+
// This will also perform a stable sorting using the row index
|
|
46
|
+
// if needed.
|
|
47
|
+
const sortedData = rows.slice()
|
|
48
|
+
|
|
49
|
+
sortedData.sort((rowA, rowB) => {
|
|
50
|
+
for (let i = 0; i < availableSorting.length; i += 1) {
|
|
51
|
+
const sortEntry = availableSorting[i]!
|
|
52
|
+
const columnInfo = columnInfoById[sortEntry.id]!
|
|
53
|
+
const isDesc = sortEntry?.desc ?? false
|
|
54
|
+
|
|
55
|
+
if (columnInfo.sortUndefined) {
|
|
56
|
+
const aValue = rowA.values[sortEntry.id]
|
|
57
|
+
const bValue = rowB.values[sortEntry.id]
|
|
58
|
+
|
|
59
|
+
const aUndefined = typeof aValue === 'undefined'
|
|
60
|
+
const bUndefined = typeof bValue === 'undefined'
|
|
61
|
+
|
|
62
|
+
if (aUndefined || bUndefined) {
|
|
63
|
+
return aUndefined && bUndefined
|
|
64
|
+
? 0
|
|
65
|
+
: aUndefined
|
|
66
|
+
? columnInfo.sortUndefined
|
|
67
|
+
: -columnInfo.sortUndefined
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// This function should always return in ascending order
|
|
72
|
+
let sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id)
|
|
73
|
+
|
|
74
|
+
if (sortInt !== 0) {
|
|
75
|
+
if (isDesc) {
|
|
76
|
+
sortInt *= -1
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (columnInfo.invertSorting) {
|
|
80
|
+
sortInt *= -1
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return sortInt
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return rowA.index - rowB.index
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// If there are sub-rows, sort them
|
|
91
|
+
sortedData.forEach(row => {
|
|
92
|
+
sortedFlatRows.push(row)
|
|
93
|
+
if (!row.subRows || row.subRows.length <= 1) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
row.subRows = sortData(row.subRows)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
return sortedData
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
rows: sortData(rowModel.rows),
|
|
104
|
+
flatRows: sortedFlatRows,
|
|
105
|
+
rowsById: rowModel.rowsById,
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
key: 'getSortedRowModel',
|
|
110
|
+
debug: () => instance.options.debugAll ?? instance.options.debugTable,
|
|
111
|
+
onChange: () => {
|
|
112
|
+
instance._notifyGroupingReset()
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
}
|
package/src/utils.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { performance } from 'perf_hooks' //needed until node 16 is more universal
|
|
2
1
|
import { Getter, NoInfer, PropGetterValue, TableState, Updater } from './types'
|
|
3
2
|
|
|
4
3
|
export type IsAny<T> = 0 extends 1 & T ? true : false
|
|
@@ -23,6 +22,35 @@ export function noop() {
|
|
|
23
22
|
//
|
|
24
23
|
}
|
|
25
24
|
|
|
25
|
+
export function getBatchGroups<T>(arr: T[], count: number) {
|
|
26
|
+
const groups: { start: number; end: number; items: T[] }[] = [
|
|
27
|
+
{
|
|
28
|
+
start: 0,
|
|
29
|
+
end: count - 1,
|
|
30
|
+
items: [],
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
let groupIndex = 0
|
|
35
|
+
let group = groups[groupIndex]
|
|
36
|
+
|
|
37
|
+
for (let i = 0; i < arr.length; i++) {
|
|
38
|
+
if (i > group.end) {
|
|
39
|
+
groupIndex++
|
|
40
|
+
groups[groupIndex] = {
|
|
41
|
+
start: i,
|
|
42
|
+
end: i + count - 1,
|
|
43
|
+
items: [],
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
group = groups[groupIndex]
|
|
47
|
+
const item = arr[i]
|
|
48
|
+
group.items.push(item)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return groups
|
|
52
|
+
}
|
|
53
|
+
|
|
26
54
|
export function makeStateUpdater(key: keyof TableState, instance: unknown) {
|
|
27
55
|
return (updater: Updater<any>) => {
|
|
28
56
|
;(instance as any).setState(<TTableState,>(old: TTableState) => {
|
|
@@ -92,7 +120,7 @@ export function memo<TDeps extends readonly any[], TResult>(
|
|
|
92
120
|
|
|
93
121
|
return () => {
|
|
94
122
|
let depTime: number
|
|
95
|
-
if (opts.key && opts.debug) depTime =
|
|
123
|
+
if (opts.key && opts.debug) depTime = Date.now()
|
|
96
124
|
|
|
97
125
|
const newDeps = getDeps()
|
|
98
126
|
|
|
@@ -103,17 +131,16 @@ export function memo<TDeps extends readonly any[], TResult>(
|
|
|
103
131
|
if (depsChanged) {
|
|
104
132
|
let oldResult = result
|
|
105
133
|
let resultTime: number
|
|
106
|
-
if (opts.key && opts.debug) resultTime =
|
|
134
|
+
if (opts.key && opts.debug) resultTime = Date.now()
|
|
107
135
|
result = fn(...newDeps)
|
|
108
136
|
deps = newDeps
|
|
109
137
|
opts?.onChange?.(result, oldResult)
|
|
110
138
|
|
|
111
139
|
if (opts.key && opts.debug) {
|
|
112
140
|
if (opts?.debug()) {
|
|
113
|
-
const depEndTime =
|
|
114
|
-
Math.round((performance.now() - depTime!) * 100) / 100
|
|
141
|
+
const depEndTime = Math.round((Date.now() - depTime!) * 100) / 100
|
|
115
142
|
const resultEndTime =
|
|
116
|
-
Math.round((
|
|
143
|
+
Math.round((Date.now() - resultTime!) * 100) / 100
|
|
117
144
|
const resultFpsPercentage = resultEndTime / 16
|
|
118
145
|
|
|
119
146
|
const pad = (str: number | string, num: number) => {
|
|
@@ -165,19 +192,163 @@ export function memo<TDeps extends readonly any[], TResult>(
|
|
|
165
192
|
}
|
|
166
193
|
}
|
|
167
194
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
195
|
+
type WorkFn = () => void
|
|
196
|
+
|
|
197
|
+
export function incrementalMemo<TDeps extends readonly any[], TResult>(
|
|
198
|
+
getDeps: () => [...TDeps],
|
|
199
|
+
getInitialValue: (...args: NoInfer<[...TDeps]>) => TResult,
|
|
200
|
+
schedule: (
|
|
201
|
+
...args: NoInfer<[...TDeps]>
|
|
202
|
+
) => (resultRef: {
|
|
203
|
+
current: TResult
|
|
204
|
+
}) => (scheduler: (workFn: WorkFn) => void) => void,
|
|
205
|
+
opts: {
|
|
206
|
+
key: string
|
|
207
|
+
onProgress: (
|
|
208
|
+
progress: number,
|
|
209
|
+
nextResult: TResult,
|
|
210
|
+
result?: TResult
|
|
211
|
+
) => void
|
|
212
|
+
onChange: (result: TResult, previousResult?: TResult) => void
|
|
213
|
+
initialSync?: boolean
|
|
214
|
+
timeout?: number
|
|
215
|
+
debug?: () => any
|
|
216
|
+
}
|
|
217
|
+
): () => TResult {
|
|
218
|
+
let oldDeps: any[]
|
|
219
|
+
let deps: any[]
|
|
220
|
+
let result: TResult | undefined
|
|
221
|
+
let nextResultRef: { current: TResult }
|
|
222
|
+
let tasks: WorkFn[] = []
|
|
223
|
+
let totalTaskCount = 0
|
|
224
|
+
let resultStartTime: number
|
|
225
|
+
let batchIndex = 0
|
|
226
|
+
let progress = 0
|
|
227
|
+
let working = false
|
|
228
|
+
let callback: ReturnType<typeof requestIdleCallback>
|
|
229
|
+
|
|
230
|
+
const timeout = opts.timeout ?? 100
|
|
231
|
+
|
|
232
|
+
const onProgress = (latestResult: TResult, previousResult?: TResult) => {
|
|
233
|
+
progress = 1 - tasks.length / totalTaskCount
|
|
234
|
+
opts.onProgress(progress, latestResult, previousResult)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return () => {
|
|
238
|
+
const scheduleFn = (workFn: WorkFn) => {
|
|
239
|
+
totalTaskCount++
|
|
240
|
+
tasks.push(workFn)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const newDeps = getDeps()
|
|
244
|
+
|
|
245
|
+
let first = false
|
|
246
|
+
|
|
247
|
+
if (!deps) {
|
|
248
|
+
first = true
|
|
249
|
+
deps = []
|
|
250
|
+
result = getInitialValue(...newDeps)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const depsChanged =
|
|
254
|
+
newDeps.length !== deps.length ||
|
|
255
|
+
newDeps.some((dep: any, index: number) => deps[index] !== dep)
|
|
256
|
+
|
|
257
|
+
if (depsChanged) {
|
|
258
|
+
cancelIdleCallback(callback)
|
|
259
|
+
oldDeps = deps
|
|
260
|
+
deps = newDeps
|
|
261
|
+
totalTaskCount = 0
|
|
262
|
+
tasks = []
|
|
263
|
+
nextResultRef = { current: getInitialValue(...newDeps) }
|
|
264
|
+
resultStartTime = Date.now()
|
|
265
|
+
schedule(...newDeps)(nextResultRef)(scheduleFn)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const commitResult = () => {
|
|
269
|
+
cancelIdleCallback(callback)
|
|
270
|
+
|
|
271
|
+
if (opts.key && opts.debug) {
|
|
272
|
+
if (opts?.debug()) {
|
|
273
|
+
const resultEndTime =
|
|
274
|
+
Math.round((Date.now() - resultStartTime!) * 100) / 100
|
|
275
|
+
const resultFpsPercentage = resultEndTime / batchIndex / 16
|
|
276
|
+
|
|
277
|
+
console.info(
|
|
278
|
+
`%c⏱ ${resultEndTime} ms / ${batchIndex} tasks = ${Math.round(
|
|
279
|
+
resultEndTime / batchIndex
|
|
280
|
+
)} ms/task`,
|
|
281
|
+
`
|
|
282
|
+
font-size: .6rem;
|
|
283
|
+
font-weight: bold;
|
|
284
|
+
color: hsl(${Math.max(
|
|
285
|
+
0,
|
|
286
|
+
Math.min(120 - 120 * resultFpsPercentage, 120)
|
|
287
|
+
)}deg 100% 31%);`,
|
|
288
|
+
opts?.key,
|
|
289
|
+
{
|
|
290
|
+
length: `${oldDeps.length} -> ${deps.length}`,
|
|
291
|
+
...deps
|
|
292
|
+
.map((_, index) => {
|
|
293
|
+
if (oldDeps[index] !== deps[index]) {
|
|
294
|
+
return [index, oldDeps[index], deps[index]]
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return false
|
|
298
|
+
})
|
|
299
|
+
.filter(Boolean)
|
|
300
|
+
.reduce(
|
|
301
|
+
(accu, [a, b]: any) => ({
|
|
302
|
+
...accu,
|
|
303
|
+
[a]: b,
|
|
304
|
+
}),
|
|
305
|
+
{}
|
|
306
|
+
),
|
|
307
|
+
parent,
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
working = false
|
|
314
|
+
let previousResult = result
|
|
315
|
+
result = nextResultRef.current
|
|
316
|
+
onProgress(result, previousResult)
|
|
317
|
+
opts.onChange(result, previousResult)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (opts.initialSync && first) {
|
|
321
|
+
batchIndex = 1
|
|
322
|
+
first = false
|
|
323
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
324
|
+
tasks[i]()
|
|
325
|
+
}
|
|
326
|
+
tasks = []
|
|
327
|
+
commitResult()
|
|
328
|
+
} else if (!working && tasks.length) {
|
|
329
|
+
cancelIdleCallback(callback)
|
|
330
|
+
working = true
|
|
331
|
+
batchIndex = 0
|
|
332
|
+
|
|
333
|
+
const workLoop = (deadline: any) => {
|
|
334
|
+
while (tasks.length && deadline.timeRemaining() > 0) {
|
|
335
|
+
tasks.shift()!()
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (!tasks.length) {
|
|
339
|
+
commitResult()
|
|
340
|
+
} else {
|
|
341
|
+
++batchIndex
|
|
342
|
+
onProgress(nextResultRef.current, result)
|
|
343
|
+
callback = requestIdleCallback(workLoop, { timeout })
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
callback = requestIdleCallback(workLoop, { timeout })
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return result!
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// opts?.onChange?.(result, oldResult)
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* table-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var filterRowsUtils = require('./filterRowsUtils.js');
|
|
16
|
-
|
|
17
|
-
function columnFilterRowsFn(instance, rowModel) {
|
|
18
|
-
var columnFilters = instance.getState().columnFilters;
|
|
19
|
-
var filterFromLeafRows = instance.options.filterFromLeafRows;
|
|
20
|
-
|
|
21
|
-
var filterRows = function filterRows(rowsToFilter, depth) {
|
|
22
|
-
for (var i = 0; i < columnFilters.length; i++) {
|
|
23
|
-
var _columnFilters$i = columnFilters[i],
|
|
24
|
-
columnId = _columnFilters$i.id,
|
|
25
|
-
filterValue = _columnFilters$i.value; // Find the columnFilters column
|
|
26
|
-
|
|
27
|
-
var column = instance.getColumn(columnId);
|
|
28
|
-
|
|
29
|
-
if (!column) {
|
|
30
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
31
|
-
console.warn("Table: Could not find a column with id: " + columnId);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
throw new Error();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (depth === 0) {
|
|
38
|
-
(function () {
|
|
39
|
-
var preFilteredRows = [].concat(rowsToFilter);
|
|
40
|
-
|
|
41
|
-
column.getPreFilteredRows = function () {
|
|
42
|
-
return preFilteredRows;
|
|
43
|
-
};
|
|
44
|
-
})();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var filterFn = instance.getColumnFilterFn(column.id);
|
|
48
|
-
|
|
49
|
-
if (!filterFn) {
|
|
50
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
51
|
-
console.warn("Could not find a valid 'column.filterType' for column with the ID: " + column.id + ".");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
continue;
|
|
55
|
-
} // Pass the rows, id, filterValue and column to the filterFn
|
|
56
|
-
// to get the filtered rows back
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
rowsToFilter = filterFn(rowsToFilter, [columnId], filterValue);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return rowsToFilter;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
if (filterFromLeafRows) {
|
|
66
|
-
return filterRowsUtils.filterRowModelFromLeafs(rowModel.rows, filterRows, instance);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return filterRowsUtils.filterRowModelFromRoot(rowModel.rows, filterRows, instance);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
exports.columnFilterRowsFn = columnFilterRowsFn;
|
|
73
|
-
//# sourceMappingURL=columnFilterRowsFn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"columnFilterRowsFn.js","sources":["../../../src/utils/columnFilterRowsFn.ts"],"sourcesContent":["import { AnyGenerics, TableInstance, Row, RowModel } from '../types'\nimport {\n filterRowModelFromLeafs,\n filterRowModelFromRoot,\n} from './filterRowsUtils'\n\nexport function columnFilterRowsFn<TGenerics extends AnyGenerics>(\n instance: TableInstance<TGenerics>,\n rowModel: RowModel<TGenerics>\n): RowModel<TGenerics> {\n const columnFilters = instance.getState().columnFilters\n const filterFromLeafRows = instance.options.filterFromLeafRows\n\n const filterRows = (rowsToFilter: Row<TGenerics>[], depth: number) => {\n for (let i = 0; i < columnFilters.length; i++) {\n const { id: columnId, value: filterValue } = columnFilters[i]\n // Find the columnFilters column\n const column = instance.getColumn(columnId)\n\n if (!column) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Table: Could not find a column with id: ${columnId}`)\n }\n throw new Error()\n }\n\n if (depth === 0) {\n const preFilteredRows = [...rowsToFilter]\n column.getPreFilteredRows = () => preFilteredRows\n }\n\n const filterFn = instance.getColumnFilterFn(column.id)\n\n if (!filterFn) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Could not find a valid 'column.filterType' for column with the ID: ${column.id}.`\n )\n }\n continue\n }\n\n // Pass the rows, id, filterValue and column to the filterFn\n // to get the filtered rows back\n rowsToFilter = filterFn(rowsToFilter, [columnId], filterValue)\n }\n\n return rowsToFilter\n }\n\n if (filterFromLeafRows) {\n return filterRowModelFromLeafs(rowModel.rows, filterRows, instance)\n }\n\n return filterRowModelFromRoot(rowModel.rows, filterRows, instance)\n}\n"],"names":["columnFilterRowsFn","instance","rowModel","columnFilters","getState","filterFromLeafRows","options","filterRows","rowsToFilter","depth","i","length","columnId","id","filterValue","value","column","getColumn","process","env","NODE_ENV","console","warn","Error","preFilteredRows","getPreFilteredRows","filterFn","getColumnFilterFn","filterRowModelFromLeafs","rows","filterRowModelFromRoot"],"mappings":";;;;;;;;;;;;;;;;AAMO,SAASA,kBAAT,CACLC,QADK,EAELC,QAFK,EAGgB;AACrB,MAAMC,aAAa,GAAGF,QAAQ,CAACG,QAAT,GAAoBD,aAA1C;AACA,MAAME,kBAAkB,GAAGJ,QAAQ,CAACK,OAAT,CAAiBD,kBAA5C;;AAEA,MAAME,UAAU,GAAG,SAAbA,UAAa,CAACC,YAAD,EAAiCC,KAAjC,EAAmD;AACpE,SAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGP,aAAa,CAACQ,MAAlC,EAA0CD,CAAC,EAA3C,EAA+C;AAC7C,6BAA6CP,aAAa,CAACO,CAAD,CAA1D;AAAA,UAAYE,QAAZ,oBAAQC,EAAR;AAAA,UAA6BC,WAA7B,oBAAsBC,KAAtB,CAD6C;;AAG7C,UAAMC,MAAM,GAAGf,QAAQ,CAACgB,SAAT,CAAmBL,QAAnB,CAAf;;AAEA,UAAI,CAACI,MAAL,EAAa;AACX,YAAIE,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzCC,UAAAA,OAAO,CAACC,IAAR,8CAAwDV,QAAxD;AACD;;AACD,cAAM,IAAIW,KAAJ,EAAN;AACD;;AAED,UAAId,KAAK,KAAK,CAAd,EAAiB;AAAA;AACf,cAAMe,eAAe,aAAOhB,YAAP,CAArB;;AACAQ,UAAAA,MAAM,CAACS,kBAAP,GAA4B;AAAA,mBAAMD,eAAN;AAAA,WAA5B;AAFe;AAGhB;;AAED,UAAME,QAAQ,GAAGzB,QAAQ,CAAC0B,iBAAT,CAA2BX,MAAM,CAACH,EAAlC,CAAjB;;AAEA,UAAI,CAACa,QAAL,EAAe;AACb,YAAIR,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzCC,UAAAA,OAAO,CAACC,IAAR,yEACwEN,MAAM,CAACH,EAD/E;AAGD;;AACD;AACD,OA1B4C;AA6B7C;;;AACAL,MAAAA,YAAY,GAAGkB,QAAQ,CAAClB,YAAD,EAAe,CAACI,QAAD,CAAf,EAA2BE,WAA3B,CAAvB;AACD;;AAED,WAAON,YAAP;AACD,GAnCD;;AAqCA,MAAIH,kBAAJ,EAAwB;AACtB,WAAOuB,uCAAuB,CAAC1B,QAAQ,CAAC2B,IAAV,EAAgBtB,UAAhB,EAA4BN,QAA5B,CAA9B;AACD;;AAED,SAAO6B,sCAAsB,CAAC5B,QAAQ,CAAC2B,IAAV,EAAgBtB,UAAhB,EAA4BN,QAA5B,CAA7B;AACD;;;;"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* table-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function expandRowsFn(instance, sortedRowModel) {
|
|
16
|
-
var expandedRows = [];
|
|
17
|
-
|
|
18
|
-
var handleRow = function handleRow(row) {
|
|
19
|
-
var _row$subRows;
|
|
20
|
-
|
|
21
|
-
expandedRows.push(row);
|
|
22
|
-
|
|
23
|
-
if (instance.options.expandSubRows && (_row$subRows = row.subRows) != null && _row$subRows.length && instance.getIsRowExpanded(row.id)) {
|
|
24
|
-
row.subRows.forEach(handleRow);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
sortedRowModel.rows.forEach(handleRow);
|
|
29
|
-
return {
|
|
30
|
-
rows: expandedRows,
|
|
31
|
-
flatRows: sortedRowModel.flatRows,
|
|
32
|
-
rowsById: sortedRowModel.rowsById
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.expandRowsFn = expandRowsFn;
|
|
37
|
-
//# sourceMappingURL=expandRowsFn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expandRowsFn.js","sources":["../../../src/utils/expandRowsFn.ts"],"sourcesContent":["import {\n TableInstance,\n Row,\n RowModel,\n AnyGenerics,\n PartialGenerics,\n} from '../types'\n\nexport function expandRowsFn<TGenerics extends AnyGenerics>(\n instance: TableInstance<TGenerics>,\n sortedRowModel: RowModel<TGenerics>\n): RowModel<TGenerics> {\n const expandedRows: Row<TGenerics>[] = []\n\n const handleRow = (row: Row<TGenerics>) => {\n expandedRows.push(row)\n\n if (\n instance.options.expandSubRows &&\n row.subRows?.length &&\n instance.getIsRowExpanded(row.id)\n ) {\n row.subRows.forEach(handleRow)\n }\n }\n\n sortedRowModel.rows.forEach(handleRow)\n\n return {\n rows: expandedRows,\n flatRows: sortedRowModel.flatRows,\n rowsById: sortedRowModel.rowsById,\n }\n}\n"],"names":["expandRowsFn","instance","sortedRowModel","expandedRows","handleRow","row","push","options","expandSubRows","subRows","length","getIsRowExpanded","id","forEach","rows","flatRows","rowsById"],"mappings":";;;;;;;;;;;;;;AAQO,SAASA,YAAT,CACLC,QADK,EAELC,cAFK,EAGgB;AACrB,MAAMC,YAA8B,GAAG,EAAvC;;AAEA,MAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,GAAD,EAAyB;AAAA;;AACzCF,IAAAA,YAAY,CAACG,IAAb,CAAkBD,GAAlB;;AAEA,QACEJ,QAAQ,CAACM,OAAT,CAAiBC,aAAjB,oBACAH,GAAG,CAACI,OADJ,aACA,aAAaC,MADb,IAEAT,QAAQ,CAACU,gBAAT,CAA0BN,GAAG,CAACO,EAA9B,CAHF,EAIE;AACAP,MAAAA,GAAG,CAACI,OAAJ,CAAYI,OAAZ,CAAoBT,SAApB;AACD;AACF,GAVD;;AAYAF,EAAAA,cAAc,CAACY,IAAf,CAAoBD,OAApB,CAA4BT,SAA5B;AAEA,SAAO;AACLU,IAAAA,IAAI,EAAEX,YADD;AAELY,IAAAA,QAAQ,EAAEb,cAAc,CAACa,QAFpB;AAGLC,IAAAA,QAAQ,EAAEd,cAAc,CAACc;AAHpB,GAAP;AAKD;;;;"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* table-core
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var filterRowsUtils = require('./filterRowsUtils.js');
|
|
16
|
-
|
|
17
|
-
function globalFilterRowsFn(instance, rowModel) {
|
|
18
|
-
var globalFilter = instance.getState().globalFilter;
|
|
19
|
-
var filterFromLeafRows = instance.options.filterFromLeafRows;
|
|
20
|
-
var filterFn = instance.getGlobalFilterFn();
|
|
21
|
-
|
|
22
|
-
if (!filterFn) {
|
|
23
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
24
|
-
console.warn("Could not find a valid 'globalFilterType'");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return rowModel;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var filterableColumns = instance.getAllLeafColumns().filter(function (column) {
|
|
31
|
-
return column.getCanGlobalFilter();
|
|
32
|
-
});
|
|
33
|
-
var filterableColumnIds = filterableColumns.map(function (d) {
|
|
34
|
-
return d.id;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
var filterRows = function filterRows(rows) {
|
|
38
|
-
return filterFn(rows, filterableColumnIds, globalFilter);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
if (filterFromLeafRows) {
|
|
42
|
-
filterRowsUtils.filterRowModelFromLeafs(rowModel.rows, filterRows, instance);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return filterRowsUtils.filterRowModelFromRoot(rowModel.rows, filterRows, instance);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
exports.globalFilterRowsFn = globalFilterRowsFn;
|
|
49
|
-
//# sourceMappingURL=globalFilterRowsFn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"globalFilterRowsFn.js","sources":["../../../src/utils/globalFilterRowsFn.ts"],"sourcesContent":["import { TableInstance, Row, RowModel, AnyGenerics } from '../types'\nimport {\n filterRowModelFromLeafs,\n filterRowModelFromRoot,\n} from './filterRowsUtils'\n\nexport function globalFilterRowsFn<TGenerics extends AnyGenerics>(\n instance: TableInstance<TGenerics>,\n rowModel: RowModel<TGenerics>\n): RowModel<TGenerics> {\n const globalFilter = instance.getState().globalFilter\n\n const filterFromLeafRows = instance.options.filterFromLeafRows\n\n const filterFn = instance.getGlobalFilterFn()\n\n if (!filterFn) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Could not find a valid 'globalFilterType'`)\n }\n return rowModel\n }\n\n const filterableColumns = instance\n .getAllLeafColumns()\n .filter(column => column.getCanGlobalFilter())\n\n const filterableColumnIds = filterableColumns.map(d => d.id)\n\n const filterRows = (rows: Row<TGenerics>[]) => {\n return filterFn(rows, filterableColumnIds, globalFilter)\n }\n\n if (filterFromLeafRows) {\n filterRowModelFromLeafs(rowModel.rows, filterRows, instance)\n }\n\n return filterRowModelFromRoot(rowModel.rows, filterRows, instance)\n}\n"],"names":["globalFilterRowsFn","instance","rowModel","globalFilter","getState","filterFromLeafRows","options","filterFn","getGlobalFilterFn","process","env","NODE_ENV","console","warn","filterableColumns","getAllLeafColumns","filter","column","getCanGlobalFilter","filterableColumnIds","map","d","id","filterRows","rows","filterRowModelFromLeafs","filterRowModelFromRoot"],"mappings":";;;;;;;;;;;;;;;;AAMO,SAASA,kBAAT,CACLC,QADK,EAELC,QAFK,EAGgB;AACrB,MAAMC,YAAY,GAAGF,QAAQ,CAACG,QAAT,GAAoBD,YAAzC;AAEA,MAAME,kBAAkB,GAAGJ,QAAQ,CAACK,OAAT,CAAiBD,kBAA5C;AAEA,MAAME,QAAQ,GAAGN,QAAQ,CAACO,iBAAT,EAAjB;;AAEA,MAAI,CAACD,QAAL,EAAe;AACb,QAAIE,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzCC,MAAAA,OAAO,CAACC,IAAR;AACD;;AACD,WAAOX,QAAP;AACD;;AAED,MAAMY,iBAAiB,GAAGb,QAAQ,CAC/Bc,iBADuB,GAEvBC,MAFuB,CAEhB,UAAAC,MAAM;AAAA,WAAIA,MAAM,CAACC,kBAAP,EAAJ;AAAA,GAFU,CAA1B;AAIA,MAAMC,mBAAmB,GAAGL,iBAAiB,CAACM,GAAlB,CAAsB,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,EAAN;AAAA,GAAvB,CAA5B;;AAEA,MAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,IAAD,EAA4B;AAC7C,WAAOjB,QAAQ,CAACiB,IAAD,EAAOL,mBAAP,EAA4BhB,YAA5B,CAAf;AACD,GAFD;;AAIA,MAAIE,kBAAJ,EAAwB;AACtBoB,IAAAA,uCAAuB,CAACvB,QAAQ,CAACsB,IAAV,EAAgBD,UAAhB,EAA4BtB,QAA5B,CAAvB;AACD;;AAED,SAAOyB,sCAAsB,CAACxB,QAAQ,CAACsB,IAAV,EAAgBD,UAAhB,EAA4BtB,QAA5B,CAA7B;AACD;;;;"}
|