@tanstack/table-core 8.0.0-alpha.64 → 8.0.0-alpha.65

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.
Files changed (96) hide show
  1. package/build/cjs/core.js +1 -0
  2. package/build/cjs/core.js.map +1 -1
  3. package/build/cjs/features/Cells.js +1 -1
  4. package/build/cjs/features/Cells.js.map +1 -1
  5. package/build/cjs/features/Columns.js +7 -7
  6. package/build/cjs/features/Columns.js.map +1 -1
  7. package/build/cjs/features/Filters.js +153 -77
  8. package/build/cjs/features/Filters.js.map +1 -1
  9. package/build/cjs/features/Headers.js +16 -16
  10. package/build/cjs/features/Headers.js.map +1 -1
  11. package/build/cjs/features/Ordering.js +1 -1
  12. package/build/cjs/features/Ordering.js.map +1 -1
  13. package/build/cjs/features/Pagination.js +1 -1
  14. package/build/cjs/features/Pagination.js.map +1 -1
  15. package/build/cjs/features/Pinning.js +6 -6
  16. package/build/cjs/features/Pinning.js.map +1 -1
  17. package/build/cjs/features/RowSelection.js +5 -5
  18. package/build/cjs/features/RowSelection.js.map +1 -1
  19. package/build/cjs/features/Sorting.js +3 -3
  20. package/build/cjs/features/Sorting.js.map +1 -1
  21. package/build/cjs/features/Visibility.js +2 -2
  22. package/build/cjs/features/Visibility.js.map +1 -1
  23. package/build/cjs/filterFns.js +51 -108
  24. package/build/cjs/filterFns.js.map +1 -1
  25. package/build/cjs/index.js +4 -4
  26. package/build/cjs/utils/filterRowsUtils.js +21 -0
  27. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  28. package/build/cjs/utils/getCoreRowModelAsync.js +1 -1
  29. package/build/cjs/utils/getCoreRowModelAsync.js.map +1 -1
  30. package/build/cjs/utils/getCoreRowModelSync.js +1 -1
  31. package/build/cjs/utils/getCoreRowModelSync.js.map +1 -1
  32. package/build/cjs/utils/getExpandedRowModel.js +1 -1
  33. package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
  34. package/build/cjs/utils/getFilteredRowModelSync.js +130 -0
  35. package/build/cjs/utils/getFilteredRowModelSync.js.map +1 -0
  36. package/build/cjs/utils/getGroupedRowModel.js +1 -1
  37. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  38. package/build/cjs/utils/getPaginationRowModel.js +1 -1
  39. package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
  40. package/build/cjs/utils/getSortedRowModelSync.js +1 -1
  41. package/build/cjs/utils/getSortedRowModelSync.js.map +1 -1
  42. package/build/cjs/utils.js +2 -6
  43. package/build/cjs/utils.js.map +1 -1
  44. package/build/esm/index.js +422 -446
  45. package/build/esm/index.js.map +1 -1
  46. package/build/stats-html.html +1 -1
  47. package/build/stats-react.json +363 -395
  48. package/build/types/features/Filters.d.ts +24 -15
  49. package/build/types/filterFns.d.ts +10 -52
  50. package/build/types/index.d.ts +1 -2
  51. package/build/types/types.d.ts +2 -2
  52. package/build/types/utils/filterRowsUtils.d.ts +1 -0
  53. package/build/types/utils/{getColumnFilteredRowModelAsync.d.ts → getFilteredRowModelAsync.d.ts} +1 -1
  54. package/build/types/utils/getFilteredRowModelSync.d.ts +2 -0
  55. package/build/types/utils.d.ts +2 -2
  56. package/build/umd/index.development.js +424 -447
  57. package/build/umd/index.development.js.map +1 -1
  58. package/build/umd/index.production.js +1 -1
  59. package/build/umd/index.production.js.map +1 -1
  60. package/package.json +2 -1
  61. package/src/core.ts +1 -0
  62. package/src/features/Cells.ts +3 -1
  63. package/src/features/Columns.ts +11 -7
  64. package/src/features/Filters.ts +202 -94
  65. package/src/features/Headers.ts +16 -16
  66. package/src/features/Ordering.ts +1 -1
  67. package/src/features/Pagination.ts +1 -1
  68. package/src/features/Pinning.ts +10 -6
  69. package/src/features/RowSelection.ts +9 -6
  70. package/src/features/Sorting.ts +3 -5
  71. package/src/features/Visibility.ts +3 -2
  72. package/src/filterFns.ts +74 -147
  73. package/src/index.ts +1 -2
  74. package/src/types.ts +2 -0
  75. package/src/utils/filterRowsUtils.ts +24 -0
  76. package/src/utils/getCoreRowModelAsync.ts +1 -1
  77. package/src/utils/getCoreRowModelSync.ts +1 -1
  78. package/src/utils/getExpandedRowModel.ts +1 -1
  79. package/src/utils/getFilteredRowModelAsync.ts +49 -0
  80. package/src/utils/getFilteredRowModelSync.ts +150 -0
  81. package/src/utils/getGroupedRowModel.ts +1 -1
  82. package/src/utils/getPaginationRowModel.ts +1 -1
  83. package/src/utils/getSortedRowModelAsync.ts +1 -1
  84. package/src/utils/getSortedRowModelSync.ts +1 -1
  85. package/src/utils.ts +2 -4
  86. package/build/cjs/utils/getColumnFilteredRowModelSync.js +0 -115
  87. package/build/cjs/utils/getColumnFilteredRowModelSync.js.map +0 -1
  88. package/build/cjs/utils/getGlobalFilteredRowModelSync.js +0 -91
  89. package/build/cjs/utils/getGlobalFilteredRowModelSync.js.map +0 -1
  90. package/build/types/utils/getColumnFilteredRowModelSync.d.ts +0 -2
  91. package/build/types/utils/getGlobalFilteredRowModelAsync.d.ts +0 -4
  92. package/build/types/utils/getGlobalFilteredRowModelSync.d.ts +0 -2
  93. package/src/utils/getColumnFilteredRowModelAsync.ts +0 -118
  94. package/src/utils/getColumnFilteredRowModelSync.ts +0 -102
  95. package/src/utils/getGlobalFilteredRowModelAsync.ts +0 -96
  96. package/src/utils/getGlobalFilteredRowModelSync.ts +0 -79
@@ -184,7 +184,7 @@ export const Pagination: TableFeature = {
184
184
  return pageOptions
185
185
  },
186
186
  {
187
- key: 'getPageOptions',
187
+ key: process.env.NODE_ENV === 'production' && 'getPageOptions',
188
188
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
189
189
  }
190
190
  ),
@@ -110,7 +110,9 @@ export const Pinning: TableFeature = {
110
110
  return allCells.filter(d => !leftAndRight.includes(d.columnId))
111
111
  },
112
112
  {
113
- key: 'row.getCenterVisibleCells',
113
+ key:
114
+ process.env.NODE_ENV === 'production' &&
115
+ 'row.getCenterVisibleCells',
114
116
  debug: () => instance.options.debugAll ?? instance.options.debugRows,
115
117
  }
116
118
  ),
@@ -129,7 +131,8 @@ export const Pinning: TableFeature = {
129
131
  return cells
130
132
  },
131
133
  {
132
- key: 'row.getLeftVisibleCells',
134
+ key:
135
+ process.env.NODE_ENV === 'production' && 'row.getLeftVisibleCells',
133
136
  debug: () => instance.options.debugAll ?? instance.options.debugRows,
134
137
  }
135
138
  ),
@@ -147,7 +150,8 @@ export const Pinning: TableFeature = {
147
150
  return cells
148
151
  },
149
152
  {
150
- key: 'row.getRightVisibleCells',
153
+ key:
154
+ process.env.NODE_ENV === 'production' && 'row.getRightVisibleCells',
151
155
  debug: () => instance.options.debugAll ?? instance.options.debugRows,
152
156
  }
153
157
  ),
@@ -259,7 +263,7 @@ export const Pinning: TableFeature = {
259
263
  .filter(Boolean)
260
264
  },
261
265
  {
262
- key: 'getLeftLeafColumns',
266
+ key: process.env.NODE_ENV === 'production' && 'getLeftLeafColumns',
263
267
  debug: () =>
264
268
  instance.options.debugAll ?? instance.options.debugColumns,
265
269
  }
@@ -276,7 +280,7 @@ export const Pinning: TableFeature = {
276
280
  .filter(Boolean)
277
281
  },
278
282
  {
279
- key: 'getRightLeafColumns',
283
+ key: process.env.NODE_ENV === 'production' && 'getRightLeafColumns',
280
284
  debug: () =>
281
285
  instance.options.debugAll ?? instance.options.debugColumns,
282
286
  }
@@ -294,7 +298,7 @@ export const Pinning: TableFeature = {
294
298
  return allColumns.filter(d => !leftAndRight.includes(d.id))
295
299
  },
296
300
  {
297
- key: 'getCenterLeafColumns',
301
+ key: process.env.NODE_ENV === 'production' && 'getCenterLeafColumns',
298
302
  debug: () =>
299
303
  instance.options.debugAll ?? instance.options.debugColumns,
300
304
  }
@@ -239,7 +239,7 @@ export const RowSelection: TableFeature = {
239
239
  return selectRowsFn(instance, rowModel)
240
240
  },
241
241
  {
242
- key: 'getSelectedRowModel',
242
+ key: process.env.NODE_ENV === 'production' && 'getSelectedRowModel',
243
243
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
244
244
  }
245
245
  ),
@@ -247,7 +247,7 @@ export const RowSelection: TableFeature = {
247
247
  getFilteredSelectedRowModel: memo(
248
248
  () => [
249
249
  instance.getState().rowSelection,
250
- instance.getGlobalFilteredRowModel(),
250
+ instance.getFilteredRowModel(),
251
251
  ],
252
252
  (rowSelection, rowModel) => {
253
253
  if (!Object.keys(rowSelection).length) {
@@ -261,7 +261,9 @@ export const RowSelection: TableFeature = {
261
261
  return selectRowsFn(instance, rowModel)
262
262
  },
263
263
  {
264
- key: 'getFilteredSelectedRowModel',
264
+ key:
265
+ process.env.NODE_ENV === 'production' &&
266
+ 'getFilteredSelectedRowModel',
265
267
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
266
268
  }
267
269
  ),
@@ -280,7 +282,9 @@ export const RowSelection: TableFeature = {
280
282
  return selectRowsFn(instance, rowModel)
281
283
  },
282
284
  {
283
- key: 'getGroupedSelectedRowModel',
285
+ key:
286
+ process.env.NODE_ENV === 'production' &&
287
+ 'getGroupedSelectedRowModel',
284
288
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
285
289
  }
286
290
  ),
@@ -366,8 +370,7 @@ export const RowSelection: TableFeature = {
366
370
  // },
367
371
 
368
372
  getIsAllRowsSelected: () => {
369
- const preFilteredFlatRows =
370
- instance.getPreGlobalFilteredRowModel().flatRows
373
+ const preFilteredFlatRows = instance.getPreFilteredRowModel().flatRows
371
374
  const { rowSelection } = instance.getState()
372
375
 
373
376
  let isAllRowsSelected = Boolean(
@@ -161,9 +161,7 @@ export const Sorting: TableFeature = {
161
161
 
162
162
  return {
163
163
  getColumnAutoSortingFn: columnId => {
164
- const firstRows = instance
165
- .getGlobalFilteredRowModel()
166
- .flatRows.slice(100)
164
+ const firstRows = instance.getFilteredRowModel().flatRows.slice(100)
167
165
 
168
166
  let isString = false
169
167
 
@@ -190,7 +188,7 @@ export const Sorting: TableFeature = {
190
188
  return sortingFns.basic
191
189
  },
192
190
  getColumnAutoSortDir: columnId => {
193
- const firstRow = instance.getGlobalFilteredRowModel().flatRows[0]
191
+ const firstRow = instance.getFilteredRowModel().flatRows[0]
194
192
 
195
193
  const value = firstRow?.values[columnId]
196
194
 
@@ -399,7 +397,7 @@ export const Sorting: TableFeature = {
399
397
  }
400
398
  },
401
399
 
402
- getPreSortedRowModel: () => instance.getGlobalFilteredRowModel(),
400
+ getPreSortedRowModel: () => instance.getFilteredRowModel(),
403
401
  getSortedRowModel: () => {
404
402
  if (
405
403
  !instance._getSortedRowModel &&
@@ -121,7 +121,8 @@ export const Visibility: TableFeature = {
121
121
  return row.getAllCells().filter(cell => cell.column.getIsVisible())
122
122
  },
123
123
  {
124
- key: 'row._getAllVisibleCells',
124
+ key:
125
+ process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
125
126
  debug: () => instance.options.debugAll ?? instance.options.debugRows,
126
127
  }
127
128
  ),
@@ -133,7 +134,7 @@ export const Visibility: TableFeature = {
133
134
  ],
134
135
  (left, center, right) => [...left, ...center, ...right],
135
136
  {
136
- key: 'row.getVisibleCells',
137
+ key: process.env.NODE_ENV === 'production' && 'row.getVisibleCells',
137
138
  debug: () => instance.options.debugAll ?? instance.options.debugRows,
138
139
  }
139
140
  ),
package/src/filterFns.ts CHANGED
@@ -1,179 +1,95 @@
1
- import { TableGenerics, Row } from './types'
2
-
3
- export const filterFns = {
4
- includesString,
5
- includesStringSensitive,
6
- equalsString,
7
- equalsStringSensitive,
8
- arrIncludes,
9
- arrIncludesAll,
10
- arrIncludesSome,
11
- equals,
12
- weakEquals,
13
- betweenNumberRange,
14
- }
15
-
16
- export type BuiltInFilterFn = keyof typeof filterFns
17
-
18
- function includesString<TGenerics extends TableGenerics>(
19
- rows: Row<TGenerics>[],
20
- columnIds: string[],
21
- filterValue: unknown
22
- ) {
23
- const search = String(filterValue).toLowerCase()
24
-
25
- rows = rows.filter(row => {
26
- return columnIds.some(id => {
27
- return String(row.values[id]).toLowerCase().includes(search)
28
- })
29
- })
30
- return rows
1
+ import { FilterFn } from './features/Filters'
2
+
3
+ const includesString: FilterFn<any> = (
4
+ row,
5
+ columnId: string,
6
+ filterValue: string
7
+ ) => {
8
+ const search = filterValue.toLowerCase()
9
+ return row.values[columnId].toLowerCase().includes(search)
31
10
  }
32
11
 
33
12
  includesString.autoRemove = (val: any) => testFalsey(val)
34
13
 
35
- function includesStringSensitive<TGenerics extends TableGenerics>(
36
- rows: Row<TGenerics>[],
37
- columnIds: string[],
38
- filterValue: unknown
39
- ) {
40
- const search = String(filterValue)
41
-
42
- rows = rows.filter(row => {
43
- return columnIds.some(id => {
44
- return String(row.values[id]).includes(search)
45
- })
46
- })
47
- return rows
14
+ const includesStringSensitive: FilterFn<any> = (
15
+ row,
16
+ columnId: string,
17
+ filterValue: string
18
+ ) => {
19
+ return row.values[columnId].includes(filterValue)
48
20
  }
49
21
 
50
22
  includesStringSensitive.autoRemove = (val: any) => testFalsey(val)
51
23
 
52
- function equalsString<TGenerics extends TableGenerics>(
53
- rows: Row<TGenerics>[],
54
- columnIds: string[],
55
- filterValue: unknown
56
- ) {
57
- const search = String(filterValue).toLowerCase()
58
-
59
- return rows.filter(row => {
60
- return columnIds.some(id => {
61
- const rowValue = row.values[id]
62
- return rowValue !== undefined
63
- ? String(rowValue).toLowerCase() === search
64
- : true
65
- })
66
- })
24
+ const equalsString: FilterFn<any> = (
25
+ row,
26
+ columnId: string,
27
+ filterValue: string
28
+ ) => {
29
+ return row.values[columnId].toLowerCase() === filterValue.toLowerCase()
67
30
  }
68
31
 
69
32
  equalsString.autoRemove = (val: any) => testFalsey(val)
70
33
 
71
- function equalsStringSensitive<TGenerics extends TableGenerics>(
72
- rows: Row<TGenerics>[],
73
- columnIds: string[],
34
+ const arrIncludes: FilterFn<any> = (
35
+ row,
36
+ columnId: string,
74
37
  filterValue: unknown
75
- ) {
76
- const search = String(filterValue)
77
- return rows.filter(row => {
78
- return columnIds.some(id => {
79
- const rowValue = row.values[id]
80
- return rowValue !== undefined ? String(rowValue) === search : true
81
- })
82
- })
83
- }
84
-
85
- equalsStringSensitive.autoRemove = (val: any) => testFalsey(val)
86
-
87
- function arrIncludes<TGenerics extends TableGenerics>(
88
- rows: Row<TGenerics>[],
89
- columnIds: string[],
90
- filterValue: unknown
91
- ) {
92
- return rows.filter(row => {
93
- return columnIds.some(id => {
94
- const rowValue = row.values[id]
95
- return rowValue.includes(filterValue)
96
- })
97
- })
38
+ ) => {
39
+ return row.values[columnId].includes(filterValue)
98
40
  }
99
41
 
100
42
  arrIncludes.autoRemove = (val: any) => testFalsey(val) || !val?.length
101
43
 
102
- function arrIncludesAll<TGenerics extends TableGenerics>(
103
- rows: Row<TGenerics>[],
104
- columnIds: string[],
44
+ const arrIncludesAll: FilterFn<any> = (
45
+ row,
46
+ columnId: string,
105
47
  filterValue: unknown[]
106
- ) {
107
- return rows.filter(row => {
108
- return columnIds.some(id => {
109
- const rowValue = row.values[id]
110
- return (
111
- rowValue &&
112
- rowValue.length &&
113
- filterValue.every(val => rowValue.includes(val))
114
- )
115
- })
116
- })
48
+ ) => {
49
+ return !filterValue.some(val => !row.values[columnId].includes(val))
117
50
  }
118
51
 
119
52
  arrIncludesAll.autoRemove = (val: any) => testFalsey(val) || !val?.length
120
53
 
121
- function arrIncludesSome<TGenerics extends TableGenerics>(
122
- rows: Row<TGenerics>[],
123
- columnIds: string[],
54
+ const arrIncludesSome: FilterFn<any> = (
55
+ row,
56
+ columnId: string,
124
57
  filterValue: unknown[]
125
- ) {
126
- return rows.filter(row => {
127
- return columnIds.some(id => {
128
- const rowValue = row.values[id]
129
- return (
130
- rowValue &&
131
- rowValue.length &&
132
- filterValue.some(val => rowValue.includes(val))
133
- )
134
- })
135
- })
58
+ ) => {
59
+ return filterValue.some(val => row.values[columnId].includes(val))
136
60
  }
137
61
 
138
62
  arrIncludesSome.autoRemove = (val: any) => testFalsey(val) || !val?.length
139
63
 
140
- function equals<TGenerics extends TableGenerics>(
141
- rows: Row<TGenerics>[],
142
- columnIds: string[],
143
- filterValue: unknown
144
- ) {
145
- return rows.filter(row => {
146
- return columnIds.some(id => {
147
- const rowValue = row.values[id]
148
- return rowValue === filterValue
149
- })
150
- })
64
+ const equals: FilterFn<any> = (row, columnId: string, filterValue: unknown) => {
65
+ return row.values[columnId] === filterValue
151
66
  }
152
67
 
153
68
  equals.autoRemove = (val: any) => testFalsey(val)
154
69
 
155
- function weakEquals<TGenerics extends TableGenerics>(
156
- rows: Row<TGenerics>[],
157
- columnIds: string[],
70
+ const weakEquals: FilterFn<any> = (
71
+ row,
72
+ columnId: string,
158
73
  filterValue: unknown
159
- ) {
160
- return rows.filter(row => {
161
- return columnIds.some(id => {
162
- const rowValue = row.values[id]
163
- // eslint-disable-next-line eqeqeq
164
- return rowValue == filterValue
165
- })
166
- })
74
+ ) => {
75
+ return row.values[columnId] == filterValue
167
76
  }
168
77
 
169
78
  weakEquals.autoRemove = (val: any) => testFalsey(val)
170
79
 
171
- function betweenNumberRange<TGenerics extends TableGenerics>(
172
- rows: Row<TGenerics>[],
173
- columnIds: string[],
174
- filterValue: [unknown, unknown]
175
- ) {
176
- let [unsafeMin, unsafeMax] = filterValue || []
80
+ const inNumberRange: FilterFn<any> = (
81
+ row,
82
+ columnId: string,
83
+ filterValue: [number, number]
84
+ ) => {
85
+ let [min, max] = filterValue
86
+
87
+ const rowValue = row.values[columnId]
88
+ return rowValue >= min && rowValue <= max
89
+ }
90
+
91
+ inNumberRange.resolveFilterValue = (val: [any, any]) => {
92
+ let [unsafeMin, unsafeMax] = val
177
93
 
178
94
  let parsedMin =
179
95
  typeof unsafeMin !== 'number' ? parseFloat(unsafeMin as string) : unsafeMin
@@ -190,17 +106,28 @@ function betweenNumberRange<TGenerics extends TableGenerics>(
190
106
  max = temp
191
107
  }
192
108
 
193
- return rows.filter(row => {
194
- return columnIds.some(id => {
195
- const rowValue = row.values[id]
196
- return rowValue >= min && rowValue <= max
197
- })
198
- })
109
+ return [min, max] as const
199
110
  }
200
111
 
201
- betweenNumberRange.autoRemove = (val: any) =>
112
+ inNumberRange.autoRemove = (val: any) =>
202
113
  testFalsey(val) || (testFalsey(val[0]) && testFalsey(val[1]))
203
114
 
115
+ // Export
116
+
117
+ export const filterFns = {
118
+ includesString,
119
+ includesStringSensitive,
120
+ equalsString,
121
+ arrIncludes,
122
+ arrIncludesAll,
123
+ arrIncludesSome,
124
+ equals,
125
+ weakEquals,
126
+ inNumberRange,
127
+ }
128
+
129
+ export type BuiltInFilterFn = keyof typeof filterFns
130
+
204
131
  // Utils
205
132
 
206
133
  function testFalsey(val: any) {
package/src/index.ts CHANGED
@@ -17,8 +17,7 @@ export * from './features/Expanding'
17
17
  export * from './utils'
18
18
  export * from './utils/getCoreRowModelSync'
19
19
  export * from './utils/getCoreRowModelAsync'
20
- export * from './utils/getColumnFilteredRowModelSync'
21
- export * from './utils/getGlobalFilteredRowModelSync'
20
+ export * from './utils/getFilteredRowModelSync'
22
21
  export * from './utils/getSortedRowModelSync'
23
22
  export * from './utils/getGroupedRowModel'
24
23
  export * from './utils/getExpandedRowModel'
package/src/types.ts CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  FiltersColumnDef,
29
29
  FiltersInstance,
30
30
  FiltersOptions,
31
+ FiltersRow,
31
32
  FiltersTableState,
32
33
  } from './features/Filters'
33
34
  import {
@@ -167,6 +168,7 @@ export type Row<TGenerics extends TableGenerics> = CoreRow<TGenerics> &
167
168
  CellsRow<TGenerics> &
168
169
  VisibilityRow<TGenerics> &
169
170
  ColumnPinningRow<TGenerics> &
171
+ FiltersRow<TGenerics> &
170
172
  GroupingRow &
171
173
  RowSelectionRow &
172
174
  ExpandedRow
@@ -1,5 +1,29 @@
1
1
  import { TableGenerics, Row, RowModel, TableInstance } from '../types'
2
2
 
3
+ export function filterRows<TGenerics extends TableGenerics>(
4
+ rows: Row<TGenerics>[],
5
+ columnIds: string[],
6
+ instance: TableInstance<TGenerics>
7
+ ) {
8
+ const filterRowImpl = (rowsToFilter: Row<TGenerics>[]) => {
9
+ // Horizontally filter rows through each column
10
+ return rowsToFilter.filter(row => {
11
+ for (let i = 0; i < columnIds.length; i++) {
12
+ if (row.columnFilterMap[columnIds[i]] === false) {
13
+ return false
14
+ }
15
+ }
16
+ return true
17
+ })
18
+ }
19
+
20
+ if (instance.options.filterFromLeafRows) {
21
+ return filterRowModelFromLeafs(rows, filterRowImpl, instance)
22
+ }
23
+
24
+ return filterRowModelFromRoot(rows, filterRowImpl, instance)
25
+ }
26
+
3
27
  export function filterRowModelFromLeafs<TGenerics extends TableGenerics>(
4
28
  rowsToFilter: Row<TGenerics>[],
5
29
  filterRows: (
@@ -88,7 +88,7 @@ export function getCoreRowModelAsync<TGenerics extends TableGenerics>(opts?: {
88
88
  accessRows(data)
89
89
  },
90
90
  {
91
- key: 'getRowModel',
91
+ key: process.env.NODE_ENV === 'production' && 'getRowModel',
92
92
  initialSync: opts?.initialSync,
93
93
  onProgress: progress => {
94
94
  instance.setState(old => ({ ...old, coreProgress: progress }))
@@ -94,7 +94,7 @@ export function getCoreRowModelSync<TGenerics extends TableGenerics>(): (
94
94
  return { rows, flatRows, rowsById }
95
95
  },
96
96
  {
97
- key: 'getRowModel',
97
+ key: process.env.NODE_ENV === 'production' && 'getRowModel',
98
98
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
99
99
  onChange: () => {
100
100
  instance.queue(() => {
@@ -24,7 +24,7 @@ export function getExpandedRowModel<TGenerics extends TableGenerics>(): (
24
24
  return expandRows(rowModel, instance)
25
25
  },
26
26
  {
27
- key: 'getExpandedRowModel',
27
+ key: process.env.NODE_ENV === 'production' && 'getExpandedRowModel',
28
28
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
29
29
  }
30
30
  )
@@ -0,0 +1,49 @@
1
+ import { TableInstance, RowModel, TableGenerics, Row } from '../types'
2
+ import { incrementalMemo } from '../utils'
3
+
4
+ export function getFilteredRowModelAsync<
5
+ TGenerics extends TableGenerics
6
+ >(opts?: {
7
+ initialSync?: boolean
8
+ }): (instance: TableInstance<TGenerics>) => () => RowModel<TGenerics> {
9
+ return instance =>
10
+ incrementalMemo(
11
+ () => [
12
+ instance.getState().columnFilters,
13
+ instance.getPreFilteredRowModel(),
14
+ ],
15
+ (_sorting, rowModel): RowModel<TGenerics> => {
16
+ return {
17
+ rows: rowModel.rows.slice(),
18
+ flatRows: [],
19
+ rowsById: rowModel.rowsById,
20
+ }
21
+ },
22
+ (columnFilters, rowModel) => rowModelRef => scheduleTask => {
23
+ // TODO: Figure out how to do scheduled filtering
24
+ // The trick will be batching those tasks in a way
25
+ // that makes them fast. JS work loops don't tend to do well with
26
+ // a high number of tasks that do one thing. Instead, shoot for each
27
+ // task to have a few thousand opts (or whatever amount is generally
28
+ // fast for most devices).
29
+ throw new Error('')
30
+ },
31
+ {
32
+ key:
33
+ process.env.NODE_ENV === 'production' && 'getFilteredRowModelAsync',
34
+ initialSync: opts?.initialSync,
35
+ onProgress: progress => {
36
+ instance.setState(old => ({
37
+ ...old,
38
+ columnFiltersProgress: progress,
39
+ }))
40
+ },
41
+ debug: () => instance.options.debugAll ?? instance.options.debugTable,
42
+ onChange: () => {
43
+ instance.queue(() => {
44
+ instance._autoResetPageIndex()
45
+ })
46
+ },
47
+ }
48
+ )
49
+ }