@tanstack/table-core 8.0.0-alpha.58 → 8.0.0-alpha.61

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 (98) hide show
  1. package/build/cjs/core.js +10 -21
  2. package/build/cjs/core.js.map +1 -1
  3. package/build/cjs/createTable.js +3 -3
  4. package/build/cjs/createTable.js.map +1 -1
  5. package/build/cjs/features/Cells.js +0 -15
  6. package/build/cjs/features/Cells.js.map +1 -1
  7. package/build/cjs/features/ColumnSizing.js +8 -19
  8. package/build/cjs/features/ColumnSizing.js.map +1 -1
  9. package/build/cjs/features/Columns.js.map +1 -1
  10. package/build/cjs/features/Expanding.js +12 -22
  11. package/build/cjs/features/Expanding.js.map +1 -1
  12. package/build/cjs/features/Filters.js +0 -23
  13. package/build/cjs/features/Filters.js.map +1 -1
  14. package/build/cjs/features/Grouping.js +6 -27
  15. package/build/cjs/features/Grouping.js.map +1 -1
  16. package/build/cjs/features/Headers.js +1 -67
  17. package/build/cjs/features/Headers.js.map +1 -1
  18. package/build/cjs/features/Pagination.js +4 -4
  19. package/build/cjs/features/Pagination.js.map +1 -1
  20. package/build/cjs/features/Pinning.js.map +1 -1
  21. package/build/cjs/features/RowSelection.js +15 -79
  22. package/build/cjs/features/RowSelection.js.map +1 -1
  23. package/build/cjs/features/Rows.js +0 -15
  24. package/build/cjs/features/Rows.js.map +1 -1
  25. package/build/cjs/features/Sorting.js +7 -28
  26. package/build/cjs/features/Sorting.js.map +1 -1
  27. package/build/cjs/features/Visibility.js +8 -21
  28. package/build/cjs/features/Visibility.js.map +1 -1
  29. package/build/cjs/filterFns.js +16 -0
  30. package/build/cjs/filterFns.js.map +1 -1
  31. package/build/cjs/index.js +0 -1
  32. package/build/cjs/index.js.map +1 -1
  33. package/build/cjs/utils/getColumnFilteredRowModelSync.js +1 -1
  34. package/build/cjs/utils/getColumnFilteredRowModelSync.js.map +1 -1
  35. package/build/cjs/utils/getCoreRowModelAsync.js +1 -2
  36. package/build/cjs/utils/getCoreRowModelAsync.js.map +1 -1
  37. package/build/cjs/utils/getCoreRowModelSync.js +1 -2
  38. package/build/cjs/utils/getCoreRowModelSync.js.map +1 -1
  39. package/build/cjs/utils/getGlobalFilteredRowModelSync.js +1 -1
  40. package/build/cjs/utils/getGlobalFilteredRowModelSync.js.map +1 -1
  41. package/build/cjs/utils/getGroupedRowModel.js +3 -1
  42. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  43. package/build/cjs/utils/getSortedRowModelSync.js +1 -1
  44. package/build/cjs/utils/getSortedRowModelSync.js.map +1 -1
  45. package/build/cjs/utils.js +0 -16
  46. package/build/cjs/utils.js.map +1 -1
  47. package/build/esm/index.js +100 -369
  48. package/build/esm/index.js.map +1 -1
  49. package/build/stats-html.html +1 -1
  50. package/build/stats-react.json +360 -360
  51. package/build/types/core.d.ts +8 -10
  52. package/build/types/createTable.d.ts +10 -11
  53. package/build/types/features/Cells.d.ts +1 -2
  54. package/build/types/features/ColumnSizing.d.ts +4 -18
  55. package/build/types/features/Expanding.d.ts +5 -9
  56. package/build/types/features/Filters.d.ts +0 -3
  57. package/build/types/features/Grouping.d.ts +4 -11
  58. package/build/types/features/Headers.d.ts +1 -5
  59. package/build/types/features/Pagination.d.ts +6 -7
  60. package/build/types/features/RowSelection.d.ts +5 -14
  61. package/build/types/features/Rows.d.ts +2 -4
  62. package/build/types/features/Sorting.d.ts +3 -9
  63. package/build/types/features/Visibility.d.ts +3 -6
  64. package/build/types/filterFns.d.ts +5 -0
  65. package/build/types/types.d.ts +10 -60
  66. package/build/types/utils.d.ts +1 -4
  67. package/build/umd/index.development.js +99 -369
  68. package/build/umd/index.development.js.map +1 -1
  69. package/build/umd/index.production.js +1 -1
  70. package/build/umd/index.production.js.map +1 -1
  71. package/package.json +1 -1
  72. package/src/core.ts +29 -53
  73. package/src/createTable.ts +13 -17
  74. package/src/features/Cells.ts +1 -27
  75. package/src/features/ColumnSizing.ts +14 -44
  76. package/src/features/Columns.ts +0 -2
  77. package/src/features/Expanding.ts +16 -44
  78. package/src/features/Filters.ts +0 -33
  79. package/src/features/Grouping.ts +10 -62
  80. package/src/features/Headers.ts +1 -95
  81. package/src/features/Pagination.ts +11 -4
  82. package/src/features/Pinning.ts +1 -1
  83. package/src/features/RowSelection.ts +25 -116
  84. package/src/features/Rows.ts +2 -30
  85. package/src/features/Sorting.ts +17 -63
  86. package/src/features/Visibility.ts +15 -43
  87. package/src/filterFns.ts +20 -0
  88. package/src/types.ts +36 -98
  89. package/src/utils/getColumnFilteredRowModelAsync.ts +2 -6
  90. package/src/utils/getColumnFilteredRowModelSync.ts +1 -1
  91. package/src/utils/getCoreRowModelAsync.ts +1 -2
  92. package/src/utils/getCoreRowModelSync.ts +1 -2
  93. package/src/utils/getGlobalFilteredRowModelAsync.ts +3 -7
  94. package/src/utils/getGlobalFilteredRowModelSync.ts +1 -1
  95. package/src/utils/getGroupedRowModel.ts +2 -1
  96. package/src/utils/getSortedRowModelAsync.ts +1 -2
  97. package/src/utils/getSortedRowModelSync.ts +1 -1
  98. package/src/utils.ts +1 -28
@@ -7,24 +7,14 @@ import {
7
7
 
8
8
  import {
9
9
  Column,
10
- Getter,
11
- Header,
12
10
  OnChangeFn,
13
11
  TableGenerics,
14
- PropGetterValue,
15
12
  TableInstance,
16
13
  Row,
17
14
  Updater,
18
15
  } from '../types'
19
16
 
20
- import {
21
- functionalUpdate,
22
- isFunction,
23
- makeStateUpdater,
24
- memo,
25
- Overwrite,
26
- propGetter,
27
- } from '../utils'
17
+ import { isFunction, makeStateUpdater, Overwrite } from '../utils'
28
18
 
29
19
  export type SortDirection = 'asc' | 'desc'
30
20
 
@@ -72,16 +62,13 @@ export type SortingColumn<TGenerics extends TableGenerics> = {
72
62
  getIsSorted: () => false | SortDirection
73
63
  resetSorting: () => void
74
64
  toggleSorting: (desc?: boolean, isMulti?: boolean) => void
75
- getToggleSortingProps: <TGetter extends Getter<ToggleSortingProps>>(
76
- userProps?: TGetter
77
- ) => undefined | PropGetterValue<ToggleSortingProps, TGetter>
65
+ getToggleSortingHandler: () => undefined | ((event: unknown) => void)
78
66
  }
79
67
 
80
68
  export type SortingOptions<TGenerics extends TableGenerics> = {
81
69
  manualSorting?: boolean
82
70
  sortingFns?: TGenerics['SortingFns']
83
71
  onSortingChange?: OnChangeFn<SortingState>
84
- autoResetSorting?: boolean
85
72
  enableSorting?: boolean
86
73
  enableSortingRemoval?: boolean
87
74
  enableMultiRemove?: boolean
@@ -94,13 +81,7 @@ export type SortingOptions<TGenerics extends TableGenerics> = {
94
81
  isMultiSortEvent?: (e: unknown) => boolean
95
82
  }
96
83
 
97
- export type ToggleSortingProps = {
98
- title?: string
99
- onClick?: (event: unknown) => void
100
- }
101
-
102
84
  export type SortingInstance<TGenerics extends TableGenerics> = {
103
- queueResetSorting: () => void
104
85
  getColumnAutoSortingFn: (columnId: string) => SortingFn<TGenerics> | undefined
105
86
  getColumnAutoSortDir: (columnId: string) => SortDirection
106
87
 
@@ -117,10 +98,9 @@ export type SortingInstance<TGenerics extends TableGenerics> = {
117
98
  getColumnCanMultiSort: (columnId: string) => boolean
118
99
  getColumnIsSorted: (columnId: string) => false | 'asc' | 'desc'
119
100
  getColumnSortIndex: (columnId: string) => number
120
- getToggleSortingProps: <TGetter extends Getter<ToggleSortingProps>>(
121
- columnId: string,
122
- userProps?: TGetter
123
- ) => undefined | PropGetterValue<ToggleSortingProps, TGetter>
101
+ getToggleSortingHandler: (
102
+ columnId: string
103
+ ) => undefined | ((event: unknown) => void)
124
104
  getPreSortedRowModel: () => RowModel<TGenerics>
125
105
  getSortedRowModel: () => RowModel<TGenerics>
126
106
  _getSortedRowModel?: () => RowModel<TGenerics>
@@ -148,7 +128,6 @@ export const Sorting = {
148
128
  ): SortingOptions<TGenerics> => {
149
129
  return {
150
130
  onSortingChange: makeStateUpdater('sorting', instance),
151
- autoResetSorting: true,
152
131
  isMultiSortEvent: (e: unknown) => {
153
132
  return (e as MouseEvent).shiftKey
154
133
  },
@@ -168,8 +147,8 @@ export const Sorting = {
168
147
  resetSorting: () => instance.resetSorting(column.id),
169
148
  toggleSorting: (desc, isMulti) =>
170
149
  instance.toggleColumnSorting(column.id, desc, isMulti),
171
- getToggleSortingProps: userProps =>
172
- instance.getToggleSortingProps(column.id, userProps),
150
+ getToggleSortingHandler: () =>
151
+ instance.getToggleSortingHandler(column.id)!,
173
152
  }
174
153
  },
175
154
 
@@ -179,25 +158,6 @@ export const Sorting = {
179
158
  let registered = false
180
159
 
181
160
  return {
182
- queueResetSorting: () => {
183
- instance.queueResetGrouping()
184
-
185
- if (!registered) {
186
- registered = true
187
- return
188
- }
189
-
190
- if (instance.options.autoResetAll === false) {
191
- return
192
- }
193
-
194
- if (
195
- instance.options.autoResetAll === true ||
196
- instance.options.autoResetSorting
197
- ) {
198
- instance.resetSorting()
199
- }
200
- },
201
161
  getColumnAutoSortingFn: columnId => {
202
162
  const firstRows = instance
203
163
  .getGlobalFilteredRowModel()
@@ -416,7 +376,7 @@ export const Sorting = {
416
376
  }
417
377
  },
418
378
 
419
- getToggleSortingProps: (columnId, userProps) => {
379
+ getToggleSortingHandler: columnId => {
420
380
  const column = instance.getColumn(columnId)
421
381
 
422
382
  if (!column) {
@@ -425,22 +385,16 @@ export const Sorting = {
425
385
 
426
386
  const canSort = column.getCanSort()
427
387
 
428
- const initialProps: ToggleSortingProps = {
429
- title: canSort ? 'Toggle Sorting' : undefined,
430
- onClick: canSort
431
- ? (e: unknown) => {
432
- ;(e as any).persist?.()
433
- column.toggleSorting?.(
434
- undefined,
435
- column.getCanMultiSort()
436
- ? instance.options.isMultiSortEvent?.(e)
437
- : false
438
- )
439
- }
440
- : undefined,
388
+ return (e: unknown) => {
389
+ if (!canSort) return
390
+ ;(e as any).persist?.()
391
+ column.toggleSorting?.(
392
+ undefined,
393
+ column.getCanMultiSort()
394
+ ? instance.options.isMultiSortEvent?.(e)
395
+ : false
396
+ )
441
397
  }
442
-
443
- return propGetter(initialProps, userProps)
444
398
  },
445
399
 
446
400
  getPreSortedRowModel: () => instance.getGlobalFilteredRowModel(),
@@ -1,15 +1,13 @@
1
1
  import {
2
2
  Cell,
3
3
  Column,
4
- Getter,
5
4
  OnChangeFn,
6
5
  TableGenerics,
7
- PropGetterValue,
8
6
  TableInstance,
9
7
  Updater,
10
8
  Row,
11
9
  } from '../types'
12
- import { makeStateUpdater, memo, propGetter } from '../utils'
10
+ import { makeStateUpdater, memo } from '../utils'
13
11
 
14
12
  export type VisibilityOptions = {
15
13
  onColumnVisibilityChange?: OnChangeFn<VisibilityState>
@@ -39,16 +37,11 @@ export type VisibilityInstance<TGenerics extends TableGenerics> = {
39
37
  getColumnCanHide: (columnId: string) => boolean
40
38
  getIsAllColumnsVisible: () => boolean
41
39
  getIsSomeColumnsVisible: () => boolean
42
- getToggleAllColumnsVisibilityProps: <
43
- TGetter extends Getter<ToggleAllColumnsVisibilityProps>
44
- >(
45
- userProps?: TGetter
46
- ) => undefined | PropGetterValue<ToggleAllColumnsVisibilityProps, TGetter>
40
+ getToggleAllColumnsVisibilityHandler: () =>
41
+ | undefined
42
+ | ((event: unknown) => void)
47
43
  }
48
44
 
49
- type ToggleVisibilityProps = {}
50
- type ToggleAllColumnsVisibilityProps = {}
51
-
52
45
  export type VisibilityColumnDef = {
53
46
  enableHiding?: boolean
54
47
  defaultCanHide?: boolean
@@ -64,9 +57,7 @@ export type VisibilityColumn = {
64
57
  getCanHide: () => boolean
65
58
  getIsVisible: () => boolean
66
59
  toggleVisibility: (value?: boolean) => void
67
- getToggleVisibilityProps: <TGetter extends Getter<ToggleVisibilityProps>>(
68
- userProps?: TGetter
69
- ) => PropGetterValue<ToggleVisibilityProps, TGetter>
60
+ getToggleVisibilityHandler: () => (event: unknown) => void
70
61
  }
71
62
 
72
63
  //
@@ -101,19 +92,12 @@ export const Visibility = {
101
92
  getIsVisible: () => instance.getColumnIsVisible(column.id),
102
93
  toggleVisibility: value =>
103
94
  instance.toggleColumnVisibility(column.id, value),
104
- getToggleVisibilityProps: userProps => {
105
- const props: ToggleVisibilityProps = {
106
- type: 'checkbox',
107
- checked: column.getIsVisible?.(),
108
- title: 'Toggle Column Visibility',
109
- onChange: (e: unknown) => {
110
- column.toggleVisibility?.(
111
- ((e as MouseEvent).target as HTMLInputElement).checked
112
- )
113
- },
95
+ getToggleVisibilityHandler: () => {
96
+ return (e: unknown) => {
97
+ column.toggleVisibility?.(
98
+ ((e as MouseEvent).target as HTMLInputElement).checked
99
+ )
114
100
  }
115
-
116
- return propGetter(props, userProps)
117
101
  },
118
102
  }
119
103
  },
@@ -265,24 +249,12 @@ export const Visibility = {
265
249
  getIsSomeColumnsVisible: () =>
266
250
  instance.getAllLeafColumns().some(column => column.getIsVisible?.()),
267
251
 
268
- getToggleAllColumnsVisibilityProps: userProps => {
269
- const props: ToggleAllColumnsVisibilityProps = {
270
- onChange: (e: MouseEvent) => {
271
- instance.toggleAllColumnsVisible(
272
- (e.target as HTMLInputElement)?.checked
273
- )
274
- },
275
- type: 'checkbox',
276
- title: 'Toggle visibility for all columns',
277
- checked: instance.getIsAllColumnsVisible(),
278
- indeterminate:
279
- !instance.getIsAllColumnsVisible() &&
280
- instance.getIsSomeColumnsVisible()
281
- ? 'indeterminate'
282
- : undefined,
252
+ getToggleAllColumnsVisibilityHandler: () => {
253
+ return (e: unknown) => {
254
+ instance.toggleAllColumnsVisible(
255
+ ((e as MouseEvent).target as HTMLInputElement)?.checked
256
+ )
283
257
  }
284
-
285
- return propGetter(props, userProps)
286
258
  },
287
259
  }
288
260
  },
package/src/filterFns.ts CHANGED
@@ -7,6 +7,7 @@ export const filterFns = {
7
7
  equalsStringSensitive,
8
8
  arrIncludes,
9
9
  arrIncludesAll,
10
+ arrIncludesSome,
10
11
  equals,
11
12
  weakEquals,
12
13
  betweenNumberRange,
@@ -117,6 +118,25 @@ function arrIncludesAll<TGenerics extends TableGenerics>(
117
118
 
118
119
  arrIncludesAll.autoRemove = (val: any) => testFalsey(val) || !val?.length
119
120
 
121
+ function arrIncludesSome<TGenerics extends TableGenerics>(
122
+ rows: Row<TGenerics>[],
123
+ columnIds: string[],
124
+ 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
+ })
136
+ }
137
+
138
+ arrIncludesSome.autoRemove = (val: any) => testFalsey(val) || !val?.length
139
+
120
140
  function equals<TGenerics extends TableGenerics>(
121
141
  rows: Row<TGenerics>[],
122
142
  columnIds: string[],
package/src/types.ts CHANGED
@@ -62,6 +62,7 @@ import {
62
62
  ColumnSizingTableState,
63
63
  } from './features/ColumnSizing'
64
64
  import {
65
+ PaginationInitialTableState,
65
66
  PaginationInstance,
66
67
  PaginationOptions,
67
68
  PaginationTableState,
@@ -85,19 +86,17 @@ export type TableGenerics = {
85
86
  FilterFns?: any
86
87
  SortingFns?: any
87
88
  AggregationFns?: any
88
- Render?: any
89
+ Renderer?: any
90
+ Rendered?: any
89
91
  ColumnMeta?: any
90
92
  TableMeta?: any
91
93
  }
92
94
 
93
95
  export type AnyRender = (Comp: any, props: any) => any
94
96
 
95
- export type UseRenderer<TGenerics extends TableGenerics> =
96
- TGenerics['Render'] extends (...args: any) => any ? TGenerics['Render'] : any
97
-
98
97
  export type TableFeature = {
99
98
  getDefaultOptions?: (instance: any) => any
100
- getInitialState?: () => any
99
+ getInitialState?: (initialState?: InitialTableState) => any
101
100
  createInstance?: (instance: any) => any
102
101
  getDefaultColumn?: () => any
103
102
  createColumn?: (column: any, instance: any) => any
@@ -123,19 +122,20 @@ export type TableInstance<TGenerics extends TableGenerics> =
123
122
  PaginationInstance<TGenerics> &
124
123
  RowSelectionInstance<TGenerics>
125
124
 
126
- export type Options<TGenerics extends TableGenerics> = CoreOptions<TGenerics> &
127
- ColumnsOptions<TGenerics> &
128
- RowsOptions<TGenerics> &
129
- VisibilityOptions &
130
- ColumnOrderOptions &
131
- ColumnPinningOptions &
132
- FiltersOptions<TGenerics> &
133
- SortingOptions<TGenerics> &
134
- GroupingOptions<TGenerics> &
135
- ExpandedOptions<TGenerics> &
136
- ColumnSizingOptions &
137
- PaginationOptions<TGenerics> &
138
- RowSelectionOptions<TGenerics>
125
+ export type TableOptions<TGenerics extends TableGenerics> =
126
+ CoreOptions<TGenerics> &
127
+ ColumnsOptions<TGenerics> &
128
+ RowsOptions<TGenerics> &
129
+ VisibilityOptions &
130
+ ColumnOrderOptions &
131
+ ColumnPinningOptions &
132
+ FiltersOptions<TGenerics> &
133
+ SortingOptions<TGenerics> &
134
+ GroupingOptions<TGenerics> &
135
+ ExpandedOptions<TGenerics> &
136
+ ColumnSizingOptions &
137
+ PaginationOptions<TGenerics> &
138
+ RowSelectionOptions<TGenerics>
139
139
 
140
140
  export type TableState = CoreTableState &
141
141
  VisibilityTableState &
@@ -149,6 +149,20 @@ export type TableState = CoreTableState &
149
149
  PaginationTableState &
150
150
  RowSelectionTableState
151
151
 
152
+ export type InitialTableState = Partial<
153
+ CoreTableState &
154
+ VisibilityTableState &
155
+ ColumnOrderTableState &
156
+ ColumnPinningTableState &
157
+ FiltersTableState &
158
+ SortingTableState &
159
+ ExpandedTableState &
160
+ GroupingTableState &
161
+ ColumnSizingTableState &
162
+ PaginationInitialTableState &
163
+ RowSelectionTableState
164
+ >
165
+
152
166
  export type Row<TGenerics extends TableGenerics> = CoreRow<TGenerics> &
153
167
  CellsRow<TGenerics> &
154
168
  VisibilityRow<TGenerics> &
@@ -171,7 +185,7 @@ export type AccessorFn<TData> = (originalRow: TData, index: number) => any
171
185
 
172
186
  export type Renderable<TGenerics extends TableGenerics, TProps> =
173
187
  | string
174
- | ((props: TProps) => ReturnType<UseRenderer<TGenerics>>)
188
+ | ((props: TProps) => TGenerics['Rendered'])
175
189
 
176
190
  export type ColumnDef<TGenerics extends TableGenerics> =
177
191
  CoreColumnDef<TGenerics> &
@@ -201,8 +215,7 @@ export type CoreCell<TGenerics extends TableGenerics> = {
201
215
  value: TGenerics['Value']
202
216
  row: Row<TGenerics>
203
217
  column: Column<TGenerics>
204
- getCellProps: PropGetter<CellProps>
205
- renderCell: () => string | null | ReturnType<UseRenderer<TGenerics>>
218
+ renderCell: () => string | null | TGenerics['Rendered']
206
219
  }
207
220
 
208
221
  export type Header<TGenerics extends TableGenerics> = CoreHeader<TGenerics> &
@@ -219,25 +232,21 @@ export type CoreHeader<TGenerics extends TableGenerics> = {
219
232
  subHeaders: Header<TGenerics>[]
220
233
  colSpan?: number
221
234
  rowSpan?: number
222
- getHeaderProps: PropGetter<HeaderProps>
223
- getFooterProps: PropGetter<HeaderProps>
224
235
  getLeafHeaders: () => Header<TGenerics>[]
225
236
  isPlaceholder?: boolean
226
237
  placeholderId?: string
227
238
  renderHeader: (options?: {
228
239
  renderPlaceholder?: boolean
229
- }) => string | null | ReturnType<UseRenderer<TGenerics>>
240
+ }) => string | null | TGenerics['Rendered']
230
241
  renderFooter: (options?: {
231
242
  renderPlaceholder?: boolean
232
- }) => string | null | ReturnType<UseRenderer<TGenerics>>
243
+ }) => string | null | TGenerics['Rendered']
233
244
  }
234
245
 
235
246
  export type HeaderGroup<TGenerics extends TableGenerics> = {
236
247
  id: string
237
248
  depth: number
238
249
  headers: Header<TGenerics>[]
239
- getHeaderGroupProps: PropGetter<HeaderGroupProps>
240
- getFooterGroupProps: PropGetter<FooterGroupProps>
241
250
  }
242
251
 
243
252
  export type HeaderRenderProps<THeader> = {
@@ -253,75 +262,4 @@ export type CellRenderProps<TCell, TRow> = {
253
262
  row: TRow
254
263
  }
255
264
 
256
- export type TableProps = {
257
- role: string
258
- }
259
-
260
- export type TableBodyProps = {
261
- role: string
262
- }
263
-
264
- export type TableHeadProps = {
265
- key: string
266
- role: string
267
- }
268
-
269
- export type TableFooterProps = {
270
- key: string
271
- role: string
272
- }
273
-
274
- export type HeaderGroupProps = {
275
- key: string
276
- role: string
277
- }
278
-
279
- export type FooterGroupProps = {
280
- key: string
281
- role: string
282
- }
283
-
284
- export type HeaderProps = {
285
- key: string
286
- role: string
287
- colSpan?: number
288
- rowSpan?: number
289
- }
290
-
291
- export type FooterProps = {
292
- key: string
293
- role: string
294
- colSpan?: number
295
- rowSpan?: number
296
- }
297
-
298
- export type RowProps = {
299
- key: string
300
- role: string
301
- }
302
-
303
- export type CellProps = {
304
- key: string
305
- role: string
306
- }
307
-
308
- //
309
-
310
- export type PropGetter<TBase> = <TGetter extends Getter<TBase>>(
311
- userProps?: TGetter
312
- ) => PropGetterValue<TBase, TGetter>
313
-
314
- export type Getter<TInitial> =
315
- | ((initial: TInitial) => object)
316
- | object
317
- | undefined
318
-
319
- export type PropGetterValue<TBase, TGetter> = TGetter extends undefined
320
- ? TBase
321
- : TGetter extends (...args: any[]) => infer TReturn
322
- ? Overwrite<TBase, TReturn>
323
- : TGetter extends object
324
- ? Overwrite<TBase, TGetter>
325
- : never
326
-
327
265
  export type NoInfer<A extends any> = [A][A extends any ? 0 : never]
@@ -1,9 +1,5 @@
1
1
  import { TableInstance, RowModel, TableGenerics, Row } from '../types'
2
- import { incrementalMemo, memo } from '../utils'
3
- import {
4
- filterRowModelFromLeafs,
5
- filterRowModelFromRoot,
6
- } from './filterRowsUtils'
2
+ import { incrementalMemo } from '../utils'
7
3
 
8
4
  export function getColumnFilteredRowModelAsync<
9
5
  TGenerics extends TableGenerics
@@ -114,7 +110,7 @@ export function getColumnFilteredRowModelAsync<
114
110
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
115
111
  onChange: () => {
116
112
  instance.queue(() => {
117
- instance.queueResetSorting()
113
+ instance._autoResetPageIndex()
118
114
  })
119
115
  },
120
116
  }
@@ -94,7 +94,7 @@ export function getColumnFilteredRowModelSync<
94
94
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
95
95
  onChange: () => {
96
96
  instance.queue(() => {
97
- instance.queueResetSorting()
97
+ instance._autoResetPageIndex()
98
98
  })
99
99
  },
100
100
  }
@@ -96,8 +96,7 @@ export function getCoreRowModelAsync<TGenerics extends TableGenerics>(opts?: {
96
96
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
97
97
  onChange: () => {
98
98
  instance.queue(() => {
99
- instance.queueResetFilters()
100
- instance.queueResetRowSelection()
99
+ instance._autoResetPageIndex()
101
100
  })
102
101
  },
103
102
  }
@@ -98,8 +98,7 @@ export function getCoreRowModelSync<TGenerics extends TableGenerics>(): (
98
98
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
99
99
  onChange: () => {
100
100
  instance.queue(() => {
101
- instance.queueResetFilters()
102
- instance.queueResetRowSelection()
101
+ instance._autoResetPageIndex()
103
102
  })
104
103
  },
105
104
  }
@@ -1,9 +1,5 @@
1
- import { TableInstance, RowModel, TableGenerics, Row } from '../types'
2
- import { incrementalMemo, memo } from '../utils'
3
- import {
4
- filterRowModelFromLeafs,
5
- filterRowModelFromRoot,
6
- } from './filterRowsUtils'
1
+ import { TableInstance, RowModel, TableGenerics } from '../types'
2
+ import { incrementalMemo } from '../utils'
7
3
 
8
4
  export function getGlobalFilteredRowModelAsync<
9
5
  TGenerics extends TableGenerics
@@ -92,7 +88,7 @@ export function getGlobalFilteredRowModelAsync<
92
88
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
93
89
  onChange: () => {
94
90
  instance.queue(() => {
95
- instance.queueResetSorting()
91
+ instance._autoResetPageIndex()
96
92
  })
97
93
  },
98
94
  }
@@ -71,7 +71,7 @@ export function getGlobalFilteredRowModelSync<
71
71
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
72
72
  onChange: () => {
73
73
  instance.queue(() => {
74
- instance.queueResetSorting()
74
+ instance._autoResetPageIndex()
75
75
  })
76
76
  },
77
77
  }
@@ -165,7 +165,8 @@ export function getGroupedRowModelSync<TGenerics extends TableGenerics>(): (
165
165
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
166
166
  onChange: () => {
167
167
  instance.queue(() => {
168
- instance.queueResetExpanded()
168
+ instance._autoResetExpanded()
169
+ instance._autoResetPageIndex()
169
170
  })
170
171
  },
171
172
  }
@@ -1,5 +1,4 @@
1
1
  import { TableInstance, Row, RowModel, TableGenerics } from '../types'
2
- import { SortingFn } from '../features/Sorting'
3
2
  import { incrementalMemo, memo } from '../utils'
4
3
 
5
4
  export function getSortedRowModelSync<TGenerics extends TableGenerics>(opts?: {
@@ -84,7 +83,7 @@ export function getSortedRowModelSync<TGenerics extends TableGenerics>(opts?: {
84
83
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
85
84
  onChange: () => {
86
85
  instance.queue(() => {
87
- instance.queueResetGrouping()
86
+ instance._autoResetPageIndex()
88
87
  })
89
88
  },
90
89
  }
@@ -110,7 +110,7 @@ export function getSortedRowModelSync<TGenerics extends TableGenerics>(): (
110
110
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
111
111
  onChange: () => {
112
112
  instance.queue(() => {
113
- instance.queueResetGrouping()
113
+ instance._autoResetPageIndex()
114
114
  })
115
115
  },
116
116
  }
package/src/utils.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { Getter, NoInfer, PropGetterValue, TableState, Updater } from './types'
1
+ import { NoInfer, TableState, Updater } from './types'
2
2
 
3
- export type IsAny<T> = 0 extends 1 & T ? true : false
4
3
  export type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
5
4
  export type RequiredKeys<T, K extends keyof T> = Omit<T, K> &
6
5
  Required<Pick<T, K>>
@@ -12,15 +11,6 @@ export type Overwrite<T, U extends { [TKey in keyof T]?: any }> = Omit<
12
11
 
13
12
  export type IfDefined<T, N> = 0 extends 1 & T ? N : T extends {} ? T : N
14
13
 
15
- // export type DefinedGenericKeys<T extends TableGenerics> = {
16
- // [K in keyof T]: 0 extends 1 & T[K] ? never : T[K] extends {} ? K : never
17
- // }[keyof T]
18
-
19
- // export type DefinedGenerics<T extends TableGenerics> = Pick<
20
- // T,
21
- // DefinedGenericKeys<T>
22
- // >
23
-
24
14
  export function functionalUpdate<T>(updater: Updater<T>, input: T): T {
25
15
  return typeof updater === 'function'
26
16
  ? (updater as (input: T) => T)(input)
@@ -98,23 +88,6 @@ export function flattenBy<TNode>(
98
88
  return flat
99
89
  }
100
90
 
101
- type PropGetterImpl = <TBaseProps, TGetter extends Getter<TBaseProps>>(
102
- initial: TBaseProps,
103
- userProps?: TGetter
104
- ) => PropGetterValue<TBaseProps, TGetter>
105
-
106
- // @ts-ignore // Just rely on the type, not the implementation
107
- export const propGetter: PropGetterImpl = (initial, getter) => {
108
- if (isFunction(getter)) {
109
- return getter(initial)
110
- }
111
-
112
- return {
113
- ...initial,
114
- ...(getter ?? {}),
115
- }
116
- }
117
-
118
91
  export function memo<TDeps extends readonly any[], TResult>(
119
92
  getDeps: () => [...TDeps],
120
93
  fn: (...args: NoInfer<[...TDeps]>) => TResult,