@tanstack/table-core 8.0.0-alpha.62 → 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 (113) hide show
  1. package/build/cjs/core.js +8 -5
  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/ColumnSizing.js +3 -3
  6. package/build/cjs/features/ColumnSizing.js.map +1 -1
  7. package/build/cjs/features/Columns.js +7 -7
  8. package/build/cjs/features/Columns.js.map +1 -1
  9. package/build/cjs/features/Expanding.js +3 -3
  10. package/build/cjs/features/Expanding.js.map +1 -1
  11. package/build/cjs/features/Filters.js +158 -80
  12. package/build/cjs/features/Filters.js.map +1 -1
  13. package/build/cjs/features/Grouping.js +24 -22
  14. package/build/cjs/features/Grouping.js.map +1 -1
  15. package/build/cjs/features/Headers.js +16 -16
  16. package/build/cjs/features/Headers.js.map +1 -1
  17. package/build/cjs/features/Ordering.js +6 -5
  18. package/build/cjs/features/Ordering.js.map +1 -1
  19. package/build/cjs/features/Pagination.js +5 -5
  20. package/build/cjs/features/Pagination.js.map +1 -1
  21. package/build/cjs/features/Pinning.js +17 -78
  22. package/build/cjs/features/Pinning.js.map +1 -1
  23. package/build/cjs/features/RowSelection.js +8 -8
  24. package/build/cjs/features/RowSelection.js.map +1 -1
  25. package/build/cjs/features/Sorting.js +8 -8
  26. package/build/cjs/features/Sorting.js.map +1 -1
  27. package/build/cjs/features/Visibility.js +5 -5
  28. package/build/cjs/features/Visibility.js.map +1 -1
  29. package/build/cjs/filterFns.js +51 -108
  30. package/build/cjs/filterFns.js.map +1 -1
  31. package/build/cjs/index.js +5 -4
  32. package/build/cjs/index.js.map +1 -1
  33. package/build/cjs/utils/filterRowsUtils.js +21 -0
  34. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  35. package/build/cjs/utils/getCoreRowModelAsync.js +1 -1
  36. package/build/cjs/utils/getCoreRowModelAsync.js.map +1 -1
  37. package/build/cjs/utils/getCoreRowModelSync.js +1 -1
  38. package/build/cjs/utils/getCoreRowModelSync.js.map +1 -1
  39. package/build/cjs/utils/getExpandedRowModel.js +1 -1
  40. package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
  41. package/build/cjs/utils/getFilteredRowModelSync.js +130 -0
  42. package/build/cjs/utils/getFilteredRowModelSync.js.map +1 -0
  43. package/build/cjs/utils/getGroupedRowModel.js +1 -1
  44. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  45. package/build/cjs/utils/getPaginationRowModel.js +1 -1
  46. package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
  47. package/build/cjs/utils/getSortedRowModelSync.js +1 -1
  48. package/build/cjs/utils/getSortedRowModelSync.js.map +1 -1
  49. package/build/cjs/utils.js +2 -6
  50. package/build/cjs/utils.js.map +1 -1
  51. package/build/esm/index.js +491 -573
  52. package/build/esm/index.js.map +1 -1
  53. package/build/stats-html.html +1 -1
  54. package/build/stats-react.json +388 -402
  55. package/build/types/features/Expanding.d.ts +2 -7
  56. package/build/types/features/Filters.d.ts +27 -29
  57. package/build/types/features/Grouping.d.ts +3 -11
  58. package/build/types/features/Ordering.d.ts +2 -6
  59. package/build/types/features/Pinning.d.ts +2 -15
  60. package/build/types/features/RowSelection.d.ts +3 -8
  61. package/build/types/features/Sorting.d.ts +2 -8
  62. package/build/types/features/Visibility.d.ts +2 -11
  63. package/build/types/filterFns.d.ts +10 -52
  64. package/build/types/index.d.ts +1 -2
  65. package/build/types/types.d.ts +2 -2
  66. package/build/types/utils/filterRowsUtils.d.ts +1 -0
  67. package/build/types/utils/{getColumnFilteredRowModelAsync.d.ts → getFilteredRowModelAsync.d.ts} +1 -1
  68. package/build/types/utils/getFilteredRowModelSync.d.ts +2 -0
  69. package/build/types/utils.d.ts +2 -2
  70. package/build/umd/index.development.js +494 -574
  71. package/build/umd/index.development.js.map +1 -1
  72. package/build/umd/index.production.js +1 -1
  73. package/build/umd/index.production.js.map +1 -1
  74. package/package.json +2 -1
  75. package/src/core.ts +6 -5
  76. package/src/features/Cells.ts +3 -1
  77. package/src/features/ColumnSizing.ts +2 -1
  78. package/src/features/Columns.ts +11 -7
  79. package/src/features/Expanding.ts +4 -2
  80. package/src/features/Filters.ts +216 -116
  81. package/src/features/Grouping.ts +23 -21
  82. package/src/features/Headers.ts +16 -16
  83. package/src/features/Ordering.ts +7 -9
  84. package/src/features/Pagination.ts +4 -3
  85. package/src/features/Pinning.ts +16 -80
  86. package/src/features/RowSelection.ts +14 -9
  87. package/src/features/Sorting.ts +12 -12
  88. package/src/features/Visibility.ts +7 -4
  89. package/src/filterFns.ts +74 -147
  90. package/src/index.ts +1 -2
  91. package/src/types.ts +2 -0
  92. package/src/utils/filterRowsUtils.ts +24 -0
  93. package/src/utils/getCoreRowModelAsync.ts +1 -1
  94. package/src/utils/getCoreRowModelSync.ts +1 -1
  95. package/src/utils/getExpandedRowModel.ts +1 -1
  96. package/src/utils/getFilteredRowModelAsync.ts +49 -0
  97. package/src/utils/getFilteredRowModelSync.ts +150 -0
  98. package/src/utils/getGroupedRowModel.ts +1 -1
  99. package/src/utils/getPaginationRowModel.ts +1 -1
  100. package/src/utils/getSortedRowModelAsync.ts +1 -1
  101. package/src/utils/getSortedRowModelSync.ts +1 -1
  102. package/src/utils.ts +2 -4
  103. package/build/cjs/utils/getColumnFilteredRowModelSync.js +0 -115
  104. package/build/cjs/utils/getColumnFilteredRowModelSync.js.map +0 -1
  105. package/build/cjs/utils/getGlobalFilteredRowModelSync.js +0 -91
  106. package/build/cjs/utils/getGlobalFilteredRowModelSync.js.map +0 -1
  107. package/build/types/utils/getColumnFilteredRowModelSync.d.ts +0 -2
  108. package/build/types/utils/getGlobalFilteredRowModelAsync.d.ts +0 -4
  109. package/build/types/utils/getGlobalFilteredRowModelSync.d.ts +0 -2
  110. package/src/utils/getColumnFilteredRowModelAsync.ts +0 -118
  111. package/src/utils/getColumnFilteredRowModelSync.ts +0 -102
  112. package/src/utils/getGlobalFilteredRowModelAsync.ts +0 -96
  113. package/src/utils/getGlobalFilteredRowModelSync.ts +0 -79
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
+ }
@@ -0,0 +1,150 @@
1
+ import { ColumnFilter, FilterFn } from '../features/Filters'
2
+ import { TableInstance, RowModel, TableGenerics, Row } from '../types'
3
+ import { memo } from '../utils'
4
+ import { filterRows } from './filterRowsUtils'
5
+
6
+ type ResolvedColumnFilter<TGenerics extends TableGenerics> = {
7
+ id: string
8
+ filterFn: FilterFn<TGenerics>
9
+ resolvedFilterValue: unknown
10
+ }
11
+
12
+ export function getFilteredRowModelSync<TGenerics extends TableGenerics>(): (
13
+ instance: TableInstance<TGenerics>
14
+ ) => () => RowModel<TGenerics> {
15
+ return instance =>
16
+ memo(
17
+ () => [
18
+ instance.getPreFilteredRowModel(),
19
+ instance.getState().columnFilters,
20
+ instance.getState().globalFilter,
21
+ ],
22
+ (rowModel, columnFilters, globalFilter) => {
23
+ const columnFilteredRowModel: RowModel<TGenerics> = (() => {
24
+ if (
25
+ !rowModel.rows.length ||
26
+ (!columnFilters?.length && !globalFilter)
27
+ ) {
28
+ return rowModel
29
+ }
30
+
31
+ const resolvedColumnFilters: ResolvedColumnFilter<TGenerics>[] = []
32
+ const resolvedGlobalFilters: ResolvedColumnFilter<TGenerics>[] = []
33
+
34
+ ;(columnFilters ?? []).forEach(d => {
35
+ const column = instance.getColumn(d.id)
36
+
37
+ if (!column) {
38
+ if (process.env.NODE_ENV !== 'production') {
39
+ console.warn(
40
+ `Table: Could not find a column to filter with columnId: ${d.id}`
41
+ )
42
+ }
43
+ }
44
+
45
+ const filterFn = instance.getColumnFilterFn(column.id)!
46
+
47
+ if (!filterFn) {
48
+ if (process.env.NODE_ENV !== 'production') {
49
+ console.warn(
50
+ `Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`
51
+ )
52
+ }
53
+ return
54
+ }
55
+
56
+ resolvedColumnFilters.push({
57
+ id: d.id,
58
+ filterFn,
59
+ resolvedFilterValue:
60
+ filterFn.resolveFilterValue?.(d.value) ?? d.value,
61
+ })
62
+ })
63
+
64
+ const filterableIds = columnFilters.map(d => d.id)
65
+
66
+ const globalFilterFn = instance.getGlobalFilterFn()
67
+
68
+ const globallyFilterableColumns = instance
69
+ .getAllLeafColumns()
70
+ .filter(column => column.getCanGlobalFilter())
71
+
72
+ if (
73
+ globalFilter &&
74
+ globalFilterFn &&
75
+ globallyFilterableColumns.length
76
+ ) {
77
+ filterableIds.push('__global__')
78
+
79
+ globallyFilterableColumns.forEach(column => {
80
+ resolvedGlobalFilters.push({
81
+ id: column.id,
82
+ filterFn: globalFilterFn,
83
+ resolvedFilterValue:
84
+ globalFilterFn.resolveFilterValue?.(globalFilter) ??
85
+ globalFilter,
86
+ })
87
+ })
88
+ }
89
+
90
+ // Flag the prefiltered row model with each filter state
91
+ for (let j = 0; j < rowModel.flatRows.length; j++) {
92
+ const row = rowModel.flatRows[j]
93
+
94
+ row.columnFilterMap = {}
95
+
96
+ if (resolvedColumnFilters.length) {
97
+ for (let i = 0; i < resolvedColumnFilters.length; i++) {
98
+ const columnFilter = resolvedColumnFilters[i]
99
+
100
+ // Tag the row with the column filter state
101
+ row.columnFilterMap[columnFilter.id] = columnFilter.filterFn(
102
+ row,
103
+ columnFilter.id,
104
+ columnFilter.resolvedFilterValue
105
+ )
106
+ }
107
+ }
108
+
109
+ if (resolvedGlobalFilters.length) {
110
+ let hit = false
111
+
112
+ for (let i = 0; i < resolvedGlobalFilters.length; i++) {
113
+ const globalFilter = resolvedGlobalFilters[i]
114
+ // Tag the row with the first truthy global filter state
115
+ if (
116
+ globalFilter.filterFn(
117
+ row,
118
+ globalFilter.id,
119
+ globalFilter.resolvedFilterValue
120
+ )
121
+ ) {
122
+ hit = true
123
+ row.columnFilterMap.__global__ = true
124
+ break
125
+ }
126
+ }
127
+
128
+ if (row.columnFilterMap.__global__ !== true) {
129
+ row.columnFilterMap.__global__ = false
130
+ }
131
+ }
132
+ }
133
+
134
+ // Filter final rows using all of the active filters
135
+ return filterRows(rowModel.rows, filterableIds, instance)
136
+ })()
137
+
138
+ return columnFilteredRowModel
139
+ },
140
+ {
141
+ key: process.env.NODE_ENV === 'production' && 'getFilteredRowModelSync',
142
+ debug: () => instance.options.debugAll ?? instance.options.debugTable,
143
+ onChange: () => {
144
+ instance.queue(() => {
145
+ instance._autoResetPageIndex()
146
+ })
147
+ },
148
+ }
149
+ )
150
+ }
@@ -161,7 +161,7 @@ export function getGroupedRowModelSync<TGenerics extends TableGenerics>(): (
161
161
  }
162
162
  },
163
163
  {
164
- key: 'getGroupedRowModel',
164
+ key: process.env.NODE_ENV === 'production' && 'getGroupedRowModel',
165
165
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
166
166
  onChange: () => {
167
167
  instance.queue(() => {
@@ -41,7 +41,7 @@ export function getPaginationRowModel<TGenerics extends TableGenerics>(opts?: {
41
41
  }
42
42
  },
43
43
  {
44
- key: 'getPaginationRowModel',
44
+ key: process.env.NODE_ENV === 'production' && 'getPaginationRowModel',
45
45
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
46
46
  }
47
47
  )
@@ -75,7 +75,7 @@ export function getSortedRowModelSync<TGenerics extends TableGenerics>(opts?: {
75
75
  // sortData(rowModelRef.current.rows)
76
76
  },
77
77
  {
78
- key: 'getSortedRowModel',
78
+ key: process.env.NODE_ENV === 'production' && 'getSortedRowModel',
79
79
  initialSync: opts?.initialSync,
80
80
  onProgress: progress => {
81
81
  instance.setState(old => ({ ...old, sortingProgress: progress }))
@@ -106,7 +106,7 @@ export function getSortedRowModelSync<TGenerics extends TableGenerics>(): (
106
106
  }
107
107
  },
108
108
  {
109
- key: 'getSortedRowModel',
109
+ key: process.env.NODE_ENV === 'production' && 'getSortedRowModel',
110
110
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
111
111
  onChange: () => {
112
112
  instance.queue(() => {
package/src/utils.ts CHANGED
@@ -92,7 +92,7 @@ export function memo<TDeps extends readonly any[], TResult>(
92
92
  getDeps: () => [...TDeps],
93
93
  fn: (...args: NoInfer<[...TDeps]>) => TResult,
94
94
  opts: {
95
- key: string
95
+ key: any
96
96
  debug?: () => any
97
97
  onChange?: (result: TResult, previousResult?: TResult) => void
98
98
  }
@@ -161,7 +161,6 @@ export function memo<TDeps extends readonly any[], TResult>(
161
161
  }),
162
162
  {}
163
163
  ),
164
- parent,
165
164
  }
166
165
  )
167
166
  }
@@ -185,7 +184,7 @@ export function incrementalMemo<TDeps extends readonly any[], TResult>(
185
184
  current: TResult
186
185
  }) => (scheduler: (workFn: WorkFn) => void) => void,
187
186
  opts: {
188
- key: string
187
+ key: any
189
188
  onProgress: (
190
189
  progress: number,
191
190
  nextResult: TResult,
@@ -286,7 +285,6 @@ export function incrementalMemo<TDeps extends readonly any[], TResult>(
286
285
  }),
287
286
  {}
288
287
  ),
289
- parent,
290
288
  }
291
289
  )
292
290
  }