@tanstack/table-core 8.0.0-alpha.24 → 8.0.0-alpha.25

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 (61) hide show
  1. package/build/cjs/core.js +9 -21
  2. package/build/cjs/core.js.map +1 -1
  3. package/build/cjs/createTable.js +2 -2
  4. package/build/cjs/createTable.js.map +1 -1
  5. package/build/cjs/features/ColumnSizing.js +23 -8
  6. package/build/cjs/features/ColumnSizing.js.map +1 -1
  7. package/build/cjs/features/Expanding.js.map +1 -1
  8. package/build/cjs/features/Filters.js.map +1 -1
  9. package/build/cjs/features/Grouping.js.map +1 -1
  10. package/build/cjs/features/Headers.js.map +1 -1
  11. package/build/cjs/features/Ordering.js.map +1 -1
  12. package/build/cjs/features/Pagination.js.map +1 -1
  13. package/build/cjs/features/Pinning.js.map +1 -1
  14. package/build/cjs/features/RowSelection.js.map +1 -1
  15. package/build/cjs/features/Sorting.js.map +1 -1
  16. package/build/cjs/features/Visibility.js.map +1 -1
  17. package/build/cjs/filterTypes.js.map +1 -1
  18. package/build/cjs/sortTypes.js.map +1 -1
  19. package/build/cjs/utils/groupRowsFn.js.map +1 -1
  20. package/build/esm/index.js +2606 -2603
  21. package/build/esm/index.js.map +1 -1
  22. package/build/stats-html.html +1 -1
  23. package/build/stats-react.json +334 -334
  24. package/build/types/core.d.ts +7 -12
  25. package/build/types/createTable.d.ts +4 -4
  26. package/build/types/features/ColumnSizing.d.ts +13 -8
  27. package/build/types/features/Expanding.d.ts +6 -6
  28. package/build/types/features/Filters.d.ts +14 -14
  29. package/build/types/features/Grouping.d.ts +16 -16
  30. package/build/types/features/Headers.d.ts +6 -6
  31. package/build/types/features/Ordering.d.ts +4 -4
  32. package/build/types/features/Pagination.d.ts +5 -5
  33. package/build/types/features/Pinning.d.ts +5 -5
  34. package/build/types/features/RowSelection.d.ts +8 -8
  35. package/build/types/features/Sorting.d.ts +12 -12
  36. package/build/types/features/Visibility.d.ts +6 -6
  37. package/build/types/filterTypes.d.ts +10 -10
  38. package/build/types/sortTypes.d.ts +7 -7
  39. package/build/types/types.d.ts +22 -13
  40. package/build/umd/index.development.js +2606 -2603
  41. package/build/umd/index.development.js.map +1 -1
  42. package/build/umd/index.production.js +1 -1
  43. package/build/umd/index.production.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/core.tsx +26 -50
  46. package/src/createTable.tsx +17 -11
  47. package/src/features/ColumnSizing.ts +31 -7
  48. package/src/features/Expanding.ts +5 -5
  49. package/src/features/Filters.ts +13 -13
  50. package/src/features/Grouping.ts +16 -15
  51. package/src/features/Headers.ts +5 -5
  52. package/src/features/Ordering.ts +3 -3
  53. package/src/features/Pagination.ts +4 -4
  54. package/src/features/Pinning.ts +4 -4
  55. package/src/features/RowSelection.ts +8 -8
  56. package/src/features/Sorting.ts +11 -11
  57. package/src/features/Visibility.ts +5 -5
  58. package/src/filterTypes.ts +9 -9
  59. package/src/sortTypes.ts +6 -6
  60. package/src/types.ts +34 -25
  61. package/src/utils/groupRowsFn.ts +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "8.0.0-alpha.24",
4
+ "version": "8.0.0-alpha.25",
5
5
  "description": "Hooks for building lightweight, fast and extendable datagrids for React",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/tanstack/react-table#readme",
package/src/core.tsx CHANGED
@@ -30,36 +30,38 @@ import {
30
30
  CoreCell,
31
31
  Renderable,
32
32
  UseRenderer,
33
+ RowModel,
34
+ TableFeature,
35
+ AnyGenerics,
33
36
  } from './types'
34
37
 
35
- import { Visibility } from './features/Visibility'
36
- import { Ordering } from './features/Ordering'
37
- import { Pinning } from './features/Pinning'
38
- import { Headers } from './features/Headers'
38
+ import { ColumnSizing } from './features/ColumnSizing'
39
+ import { Expanding } from './features/Expanding'
39
40
  import { Filters } from './features/Filters'
40
- import { Sorting } from './features/Sorting'
41
41
  import { Grouping } from './features/Grouping'
42
- import { Expanding } from './features/Expanding'
43
- import { ColumnSizing, defaultColumnSizing } from './features/ColumnSizing'
42
+ import { Ordering } from './features/Ordering'
44
43
  import { Pagination } from './features/Pagination'
44
+ import { Pinning } from './features/Pinning'
45
45
  import { RowSelection } from './features/RowSelection'
46
- import { RowModel } from '.'
46
+ import { Sorting } from './features/Sorting'
47
+ import { Visibility } from './features/Visibility'
48
+ import { Headers } from './features/Headers'
47
49
 
48
- const features = [
50
+ const features: TableFeature[] = [
51
+ Headers,
49
52
  Visibility,
50
53
  Ordering,
51
54
  Pinning,
52
- Headers,
53
55
  Filters,
54
56
  Sorting,
55
57
  Grouping,
56
58
  Expanding,
57
- ColumnSizing,
58
59
  Pagination,
59
60
  RowSelection,
61
+ ColumnSizing,
60
62
  ]
61
63
 
62
- export type CoreOptions<TGenerics extends PartialGenerics> = {
64
+ export type CoreOptions<TGenerics extends AnyGenerics> = {
63
65
  data: TGenerics['Row'][]
64
66
  columns: ColumnDef<TGenerics>[]
65
67
  state: Partial<TableState>
@@ -84,7 +86,7 @@ export type CoreOptions<TGenerics extends PartialGenerics> = {
84
86
  autoResetAll?: boolean
85
87
  }
86
88
 
87
- export type TableCore<TGenerics extends PartialGenerics> = {
89
+ export type TableCore<TGenerics extends AnyGenerics> = {
88
90
  initialState: TableState
89
91
  reset: () => void
90
92
  options: RequiredKeys<Options<TGenerics>, 'state'>
@@ -108,7 +110,6 @@ export type TableCore<TGenerics extends PartialGenerics> = {
108
110
  getAllFlatColumnsById: () => Record<string, Column<TGenerics>>
109
111
  getAllLeafColumns: () => Column<TGenerics>[]
110
112
  getColumn: (columnId: string) => Column<TGenerics>
111
- getColumnWidth: (columnId: string) => number
112
113
  getTotalWidth: () => number
113
114
  createCell: (
114
115
  row: Row<TGenerics>,
@@ -147,7 +148,7 @@ export type TableCore<TGenerics extends PartialGenerics> = {
147
148
  ) => string | null | ReturnType<UseRenderer<TGenerics>>
148
149
  }
149
150
 
150
- export type CoreRow<TGenerics extends PartialGenerics> = {
151
+ export type CoreRow<TGenerics extends AnyGenerics> = {
151
152
  id: string
152
153
  index: number
153
154
  original?: TGenerics['Row']
@@ -161,13 +162,10 @@ export type CoreRow<TGenerics extends PartialGenerics> = {
161
162
  getAllCellsByColumnId: () => Record<string, Cell<TGenerics>>
162
163
  }
163
164
 
164
- export type CoreColumnDef<TGenerics extends PartialGenerics> = {
165
+ export type CoreColumnDef<TGenerics extends AnyGenerics> = {
165
166
  id: string
166
167
  accessorKey?: string & keyof TGenerics['Row']
167
168
  accessorFn?: AccessorFn<TGenerics['Row']>
168
- width?: number
169
- minWidth?: number
170
- maxWidth?: number
171
169
  columns?: ColumnDef<TGenerics>[]
172
170
  header?: Renderable<
173
171
  TGenerics,
@@ -199,7 +197,7 @@ export type CoreColumnDef<TGenerics extends PartialGenerics> = {
199
197
  }
200
198
  // & GeneratedProperties<true>
201
199
 
202
- export type CoreColumn<TGenerics extends PartialGenerics> = {
200
+ export type CoreColumn<TGenerics extends AnyGenerics> = {
203
201
  id: string
204
202
  depth: number
205
203
  accessorFn?: AccessorFn<TGenerics['Row']>
@@ -211,7 +209,7 @@ export type CoreColumn<TGenerics extends PartialGenerics> = {
211
209
  getLeafColumns: () => Column<TGenerics>[]
212
210
  }
213
211
 
214
- export function createTableInstance<TGenerics extends PartialGenerics>(
212
+ export function createTableInstance<TGenerics extends AnyGenerics>(
215
213
  options: Options<TGenerics>
216
214
  ): TableInstance<TGenerics> {
217
215
  if (options.debugAll || options.debugTable) {
@@ -221,7 +219,7 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
221
219
  let instance = {} as TableInstance<TGenerics>
222
220
 
223
221
  const defaultOptions = features.reduce((obj, feature) => {
224
- return Object.assign(obj, (feature as any).getDefaultOptions?.(instance))
222
+ return Object.assign(obj, feature.getDefaultOptions?.(instance))
225
223
  }, {})
226
224
 
227
225
  const buildOptions = (options: Options<TGenerics>) => ({
@@ -233,7 +231,7 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
233
231
 
234
232
  const initialState = {
235
233
  ...features.reduce((obj, feature) => {
236
- return Object.assign(obj, (feature as any).getInitialState?.())
234
+ return Object.assign(obj, feature.getInitialState?.())
237
235
  }, {}),
238
236
  ...(options.initialState ?? {}),
239
237
  } as TableState
@@ -241,7 +239,7 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
241
239
  const finalInstance: TableInstance<TGenerics> = {
242
240
  ...instance,
243
241
  ...features.reduce((obj, feature) => {
244
- return Object.assign(obj, (feature as any).getInstance?.(instance))
242
+ return Object.assign(obj, feature.getInstance?.(instance))
245
243
  }, {}),
246
244
  initialState,
247
245
  reset: () => {
@@ -288,7 +286,7 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
288
286
  cell: ({ value = '' }: { value: any }): JSX.Element =>
289
287
  typeof value === 'boolean' ? value.toString() : value,
290
288
  ...features.reduce((obj, feature) => {
291
- return Object.assign(obj, (feature as any).getDefaultColumn?.())
289
+ return Object.assign(obj, feature.getDefaultColumn?.())
292
290
  }, {}),
293
291
  ...defaultColumn,
294
292
  } as Partial<ColumnDef<TGenerics>>
@@ -330,7 +328,6 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
330
328
  }
331
329
 
332
330
  let column: CoreColumn<TGenerics> = {
333
- ...defaultColumnSizing,
334
331
  ...defaultColumn,
335
332
  ...columnDef,
336
333
  id: `${id}`,
@@ -376,10 +373,7 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
376
373
  }
377
374
 
378
375
  column = features.reduce((obj, feature) => {
379
- return Object.assign(
380
- obj,
381
- (feature as any).createColumn?.(column, instance)
382
- )
376
+ return Object.assign(obj, feature.createColumn?.(column, instance))
383
377
  }, column)
384
378
 
385
379
  // Yes, we have to convert instance to uknown, because we know more than the compiler here.
@@ -465,24 +459,6 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
465
459
  return column
466
460
  },
467
461
 
468
- getColumnWidth: (columnId: string) => {
469
- const column = instance.getColumn(columnId)
470
-
471
- if (!column) {
472
- throw new Error()
473
- }
474
-
475
- const columnSize = instance.getState().columnSizing[column.id]
476
-
477
- return Math.min(
478
- Math.max(
479
- column.minWidth ?? defaultColumnSizing.minWidth,
480
- columnSize ?? column.width ?? defaultColumnSizing.width
481
- ),
482
- column.maxWidth ?? defaultColumnSizing.maxWidth
483
- )
484
- },
485
-
486
462
  createCell: (row, column, value) => {
487
463
  const cell: CoreCell<TGenerics> = {
488
464
  id: `${row.id}_${column.id}`,
@@ -508,7 +484,7 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
508
484
  features.forEach(feature => {
509
485
  Object.assign(
510
486
  cell,
511
- (feature as any).createCell?.(
487
+ feature.createCell?.(
512
488
  cell as Cell<TGenerics>,
513
489
  column,
514
490
  row as Row<TGenerics>,
@@ -567,7 +543,7 @@ export function createTableInstance<TGenerics extends PartialGenerics>(
567
543
 
568
544
  for (let i = 0; i < features.length; i++) {
569
545
  const feature = features[i]
570
- Object.assign(row, (feature as any).createRow?.(row, instance))
546
+ Object.assign(row, feature.createRow?.(row, instance))
571
547
  }
572
548
 
573
549
  return row as Row<TGenerics>
@@ -1,10 +1,16 @@
1
1
  import { CustomFilterTypes } from './features/Filters'
2
2
  import { CustomAggregationTypes } from './features/Grouping'
3
3
  import { CustomSortingTypes } from './features/Sorting'
4
- import { ColumnDef, AccessorFn, PartialGenerics, AnyRender } from './types'
4
+ import {
5
+ ColumnDef,
6
+ AccessorFn,
7
+ PartialGenerics,
8
+ AnyRender,
9
+ AnyGenerics,
10
+ } from './types'
5
11
  import { Overwrite, PartialKeys } from './utils'
6
12
 
7
- export type CreateTableFactory<TGenerics extends PartialGenerics> = <
13
+ export type CreateTableFactory<TGenerics extends AnyGenerics> = <
8
14
  TSubGenerics extends {
9
15
  Row: any
10
16
  ColumnMeta?: object
@@ -28,7 +34,7 @@ export type CreateTableFactoryOptions<
28
34
  aggregationFns?: TAggregationFns
29
35
  }
30
36
 
31
- export type Table<TGenerics extends PartialGenerics> = {
37
+ export type Table<TGenerics extends AnyGenerics> = {
32
38
  generics: TGenerics
33
39
  __options: CreateTableFactoryOptions<any, any, any, any>
34
40
  createColumns: <TColumnDef extends ColumnDef<any>>(
@@ -94,8 +100,8 @@ export type Table<TGenerics extends PartialGenerics> = {
94
100
  }
95
101
 
96
102
  type InitTable<TRender extends AnyRender> = {
97
- createTableFactory: <TGenerics extends PartialGenerics>(
98
- options?: CreateTableFactoryOptions<TRender, any, any, any>
103
+ createTableFactory: <TGenerics extends AnyGenerics>(
104
+ options: CreateTableFactoryOptions<TRender, any, any, any>
99
105
  ) => CreateTableFactory<Overwrite<TGenerics, { Render: TRender }>>
100
106
  createTable: CreateTableFactory<
101
107
  Overwrite<PartialGenerics, { Render: TRender }>
@@ -108,16 +114,16 @@ export function init<TRender extends AnyRender>(opts: {
108
114
  render: TRender
109
115
  }): InitTable<TRender> {
110
116
  return {
111
- createTableFactory: options => () =>
112
- _createTable(undefined, undefined, { ...options, ...opts }),
117
+ createTableFactory: factoryOptions => () =>
118
+ _createTable(undefined, undefined, { ...factoryOptions, ...opts }),
113
119
  createTable: () => _createTable(undefined, undefined, opts),
114
120
  }
115
121
  }
116
122
 
117
- function _createTable<TGenerics extends PartialGenerics>(
118
- _?: undefined,
119
- __?: undefined,
120
- __options?: CreateTableFactoryOptions<any, any, any, any>
123
+ function _createTable<TGenerics extends AnyGenerics>(
124
+ _: undefined,
125
+ __: undefined,
126
+ __options: CreateTableFactoryOptions<any, any, any, any>
121
127
  ): Table<TGenerics> {
122
128
  return {
123
129
  generics: undefined!,
@@ -52,7 +52,8 @@ export type ColumnResizerProps = {
52
52
  role?: string
53
53
  }
54
54
 
55
- export type ColumnSizingInstance<TGenerics extends PartialGenerics> = {
55
+ export type ColumnSizingInstance<TGenerics extends AnyGenerics> = {
56
+ getColumnWidth: (columnId: string) => number
56
57
  setColumnSizing: (updater: Updater<ColumnSizing>) => void
57
58
  setColumnSizingInfo: (updater: Updater<ColumnSizingInfoState>) => void
58
59
  resetColumnSizing: () => void
@@ -72,15 +73,18 @@ export type ColumnSizingInstance<TGenerics extends PartialGenerics> = {
72
73
  export type ColumnSizingColumnDef = {
73
74
  enableResizing?: boolean
74
75
  defaultCanResize?: boolean
76
+ width?: number
77
+ minWidth?: number
78
+ maxWidth?: number
75
79
  }
76
80
 
77
- export type ColumnSizingColumn<TGenerics extends PartialGenerics> = {
81
+ export type ColumnSizingColumn<TGenerics extends AnyGenerics> = {
78
82
  getCanResize: () => boolean
79
83
  getIsResizing: () => boolean
80
84
  resetSize: () => void
81
85
  }
82
86
 
83
- export type ColumnSizingHeader<TGenerics extends PartialGenerics> = {
87
+ export type ColumnSizingHeader<TGenerics extends AnyGenerics> = {
84
88
  getCanResize: () => boolean
85
89
  getIsResizing: () => boolean
86
90
  getResizerProps: <TGetter extends Getter<ColumnResizerProps>>(
@@ -98,6 +102,9 @@ export const defaultColumnSizing = {
98
102
  }
99
103
 
100
104
  export const ColumnSizing = {
105
+ getDefaultColumn: (): ColumnSizingColumnDef => {
106
+ return defaultColumnSizing
107
+ },
101
108
  getInitialState: (): ColumnSizingTableState => {
102
109
  return {
103
110
  columnSizing: {},
@@ -112,7 +119,7 @@ export const ColumnSizing = {
112
119
  }
113
120
  },
114
121
 
115
- getDefaultOptions: <TGenerics extends PartialGenerics>(
122
+ getDefaultOptions: <TGenerics extends AnyGenerics>(
116
123
  instance: TableInstance<TGenerics>
117
124
  ): ColumnSizingDefaultOptions => {
118
125
  return {
@@ -122,10 +129,27 @@ export const ColumnSizing = {
122
129
  }
123
130
  },
124
131
 
125
- getInstance: <TGenerics extends PartialGenerics>(
132
+ getInstance: <TGenerics extends AnyGenerics>(
126
133
  instance: TableInstance<TGenerics>
127
134
  ): ColumnSizingInstance<TGenerics> => {
128
135
  return {
136
+ getColumnWidth: (columnId: string) => {
137
+ const column = instance.getColumn(columnId)
138
+
139
+ if (!column) {
140
+ throw new Error()
141
+ }
142
+
143
+ const columnSize = instance.getState().columnSizing[column.id]
144
+
145
+ return Math.min(
146
+ Math.max(
147
+ column.minWidth ?? defaultColumnSizing.minWidth,
148
+ columnSize ?? column.width ?? defaultColumnSizing.width
149
+ ),
150
+ column.maxWidth ?? defaultColumnSizing.maxWidth
151
+ )
152
+ },
129
153
  setColumnSizing: updater =>
130
154
  instance.options.onColumnSizingChange?.(
131
155
  updater,
@@ -373,7 +397,7 @@ export const ColumnSizing = {
373
397
  }
374
398
  },
375
399
 
376
- createColumn: <TGenerics extends PartialGenerics>(
400
+ createColumn: <TGenerics extends AnyGenerics>(
377
401
  column: Column<TGenerics>,
378
402
  instance: TableInstance<TGenerics>
379
403
  ): ColumnSizingColumn<TGenerics> => {
@@ -384,7 +408,7 @@ export const ColumnSizing = {
384
408
  }
385
409
  },
386
410
 
387
- createHeader: <TGenerics extends PartialGenerics>(
411
+ createHeader: <TGenerics extends AnyGenerics>(
388
412
  header: Header<TGenerics>,
389
413
  instance: TableInstance<TGenerics>
390
414
  ): ColumnSizingHeader<TGenerics> => {
@@ -27,7 +27,7 @@ export type ExpandedRow = {
27
27
  ) => undefined | PropGetterValue<ToggleExpandedProps, TGetter>
28
28
  }
29
29
 
30
- export type ExpandedOptions<TGenerics extends PartialGenerics> = {
30
+ export type ExpandedOptions<TGenerics extends AnyGenerics> = {
31
31
  onExpandedChange?: OnChangeFn<ExpandedState>
32
32
  autoResetExpanded?: boolean
33
33
  enableExpanded?: boolean
@@ -47,7 +47,7 @@ export type ToggleExpandedProps = {
47
47
  onClick?: (event: MouseEvent | TouchEvent) => void
48
48
  }
49
49
 
50
- export type ExpandedInstance<TGenerics extends PartialGenerics> = {
50
+ export type ExpandedInstance<TGenerics extends AnyGenerics> = {
51
51
  _notifyExpandedReset: () => void
52
52
  setExpanded: (updater: Updater<ExpandedState>) => void
53
53
  toggleRowExpanded: (rowId: string, expanded?: boolean) => void
@@ -78,7 +78,7 @@ export const Expanding = {
78
78
  }
79
79
  },
80
80
 
81
- getDefaultOptions: <TGenerics extends PartialGenerics>(
81
+ getDefaultOptions: <TGenerics extends AnyGenerics>(
82
82
  instance: TableInstance<TGenerics>
83
83
  ): ExpandedOptions<TGenerics> => {
84
84
  return {
@@ -89,7 +89,7 @@ export const Expanding = {
89
89
  }
90
90
  },
91
91
 
92
- getInstance: <TGenerics extends PartialGenerics>(
92
+ getInstance: <TGenerics extends AnyGenerics>(
93
93
  instance: TableInstance<TGenerics>
94
94
  ): ExpandedInstance<TGenerics> => {
95
95
  let registered = false
@@ -298,7 +298,7 @@ export const Expanding = {
298
298
  }
299
299
  },
300
300
 
301
- createRow: <TGenerics extends PartialGenerics>(
301
+ createRow: <TGenerics extends AnyGenerics>(
302
302
  row: Row<TGenerics>,
303
303
  instance: TableInstance<TGenerics>
304
304
  ): ExpandedRow => {
@@ -24,17 +24,17 @@ export type ColumnFilter = {
24
24
 
25
25
  export type ColumnFiltersState = ColumnFilter[]
26
26
 
27
- export type FilterFn<TGenerics extends PartialGenerics> = {
27
+ export type FilterFn<TGenerics extends AnyGenerics> = {
28
28
  (rows: Row<TGenerics>[], columnIds: string[], filterValue: any): any
29
29
  autoRemove?: ColumnFilterAutoRemoveTestFn<TGenerics>
30
30
  }
31
31
 
32
- export type ColumnFilterAutoRemoveTestFn<TGenerics extends PartialGenerics> = (
32
+ export type ColumnFilterAutoRemoveTestFn<TGenerics extends AnyGenerics> = (
33
33
  value: unknown,
34
34
  column?: Column<TGenerics>
35
35
  ) => boolean
36
36
 
37
- export type CustomFilterTypes<TGenerics extends PartialGenerics> = Record<
37
+ export type CustomFilterTypes<TGenerics extends AnyGenerics> = Record<
38
38
  string,
39
39
  FilterFn<TGenerics>
40
40
  >
@@ -44,13 +44,13 @@ export type FiltersTableState = {
44
44
  globalFilter: any
45
45
  }
46
46
 
47
- export type FilterType<TGenerics extends PartialGenerics> =
47
+ export type FilterType<TGenerics extends AnyGenerics> =
48
48
  | 'auto'
49
49
  | BuiltInFilterType
50
50
  | TGenerics['FilterFns']
51
51
  | FilterFn<TGenerics>
52
52
 
53
- export type FiltersColumnDef<TGenerics extends PartialGenerics> = {
53
+ export type FiltersColumnDef<TGenerics extends AnyGenerics> = {
54
54
  filterType?: FilterType<Overwrite<TGenerics, { Value: any }>>
55
55
  enableAllFilters?: boolean
56
56
  enableColumnFilter?: boolean
@@ -60,7 +60,7 @@ export type FiltersColumnDef<TGenerics extends PartialGenerics> = {
60
60
  defaultCanGlobalFilter?: boolean
61
61
  }
62
62
 
63
- export type FiltersColumn<TGenerics extends PartialGenerics> = {
63
+ export type FiltersColumn<TGenerics extends AnyGenerics> = {
64
64
  filterType: FilterType<Overwrite<TGenerics, { Value: any }>>
65
65
  getCanColumnFilter: () => boolean
66
66
  getCanGlobalFilter: () => boolean
@@ -73,7 +73,7 @@ export type FiltersColumn<TGenerics extends PartialGenerics> = {
73
73
  getPreFilteredMinMaxValues: () => [any, any]
74
74
  }
75
75
 
76
- export type FiltersOptions<TGenerics extends PartialGenerics> = {
76
+ export type FiltersOptions<TGenerics extends AnyGenerics> = {
77
77
  filterFromLeafRows?: boolean
78
78
  filterTypes?: TGenerics['FilterFns']
79
79
  enableFilters?: boolean
@@ -98,7 +98,7 @@ export type FiltersOptions<TGenerics extends PartialGenerics> = {
98
98
  getColumnCanGlobalFilterFn?: (column: Column<TGenerics>) => boolean
99
99
  }
100
100
 
101
- export type FiltersInstance<TGenerics extends PartialGenerics> = {
101
+ export type FiltersInstance<TGenerics extends AnyGenerics> = {
102
102
  _notifyFiltersReset: () => void
103
103
  getColumnAutoFilterFn: (columnId: string) => FilterFn<TGenerics> | undefined
104
104
 
@@ -135,7 +135,7 @@ export type FiltersInstance<TGenerics extends PartialGenerics> = {
135
135
 
136
136
  export const Filters = {
137
137
  getDefaultColumn: <
138
- TGenerics extends PartialGenerics
138
+ TGenerics extends AnyGenerics
139
139
  >(): FiltersColumnDef<TGenerics> => {
140
140
  return {
141
141
  filterType: 'auto',
@@ -149,7 +149,7 @@ export const Filters = {
149
149
  }
150
150
  },
151
151
 
152
- getDefaultOptions: <TGenerics extends PartialGenerics>(
152
+ getDefaultOptions: <TGenerics extends AnyGenerics>(
153
153
  instance: TableInstance<TGenerics>
154
154
  ): FiltersOptions<TGenerics> => {
155
155
  return {
@@ -169,7 +169,7 @@ export const Filters = {
169
169
  }
170
170
  },
171
171
 
172
- createColumn: <TGenerics extends PartialGenerics>(
172
+ createColumn: <TGenerics extends AnyGenerics>(
173
173
  column: Column<TGenerics>,
174
174
  instance: TableInstance<TGenerics>
175
175
  ): FiltersColumn<TGenerics> => {
@@ -228,7 +228,7 @@ export const Filters = {
228
228
  }
229
229
  },
230
230
 
231
- getInstance: <TGenerics extends PartialGenerics>(
231
+ getInstance: <TGenerics extends AnyGenerics>(
232
232
  instance: TableInstance<TGenerics>
233
233
  ): FiltersInstance<TGenerics> => {
234
234
  let registered = false
@@ -553,7 +553,7 @@ export const Filters = {
553
553
  },
554
554
  }
555
555
 
556
- export function shouldAutoRemoveFilter<TGenerics extends PartialGenerics>(
556
+ export function shouldAutoRemoveFilter<TGenerics extends AnyGenerics>(
557
557
  filterFn?: FilterFn<TGenerics>,
558
558
  value?: any,
559
559
  column?: Column<TGenerics>
@@ -12,6 +12,7 @@ import {
12
12
  PartialGenerics,
13
13
  Renderable,
14
14
  UseRenderer,
15
+ AnyGenerics,
15
16
  } from '../types'
16
17
  import {
17
18
  functionalUpdate,
@@ -24,17 +25,17 @@ import {
24
25
 
25
26
  export type GroupingState = string[]
26
27
 
27
- export type AggregationFn<TGenerics extends PartialGenerics> = (
28
+ export type AggregationFn<TGenerics extends AnyGenerics> = (
28
29
  getLeafValues: () => TGenerics['Row'][],
29
30
  getChildValues: () => TGenerics['Row'][]
30
31
  ) => any
31
32
 
32
- export type CustomAggregationTypes<TGenerics extends PartialGenerics> = Record<
33
+ export type CustomAggregationTypes<TGenerics extends AnyGenerics> = Record<
33
34
  string,
34
35
  AggregationFn<TGenerics>
35
36
  >
36
37
 
37
- export type AggregationType<TGenerics extends PartialGenerics> =
38
+ export type AggregationType<TGenerics extends AnyGenerics> =
38
39
  | 'auto'
39
40
  | BuiltInAggregationType
40
41
  | keyof TGenerics['AggregationFns']
@@ -44,7 +45,7 @@ export type GroupingTableState = {
44
45
  grouping: GroupingState
45
46
  }
46
47
 
47
- export type GroupingColumnDef<TGenerics extends PartialGenerics> = {
48
+ export type GroupingColumnDef<TGenerics extends AnyGenerics> = {
48
49
  aggregationType?: AggregationType<Overwrite<TGenerics, { Value: any }>>
49
50
  aggregateValue?: (columnValue: unknown) => any
50
51
  aggregatedCell?: Renderable<
@@ -61,7 +62,7 @@ export type GroupingColumnDef<TGenerics extends PartialGenerics> = {
61
62
  defaultCanGroup?: boolean
62
63
  }
63
64
 
64
- export type GroupingColumn<TGenerics extends PartialGenerics> = {
65
+ export type GroupingColumn<TGenerics extends AnyGenerics> = {
65
66
  aggregationType?: AggregationType<Overwrite<TGenerics, { Value: any }>>
66
67
  getCanGroup: () => boolean
67
68
  getIsGrouped: () => boolean
@@ -78,7 +79,7 @@ export type GroupingRow = {
78
79
  getIsGrouped: () => boolean
79
80
  }
80
81
 
81
- export type GroupingCell<TGenerics extends PartialGenerics> = {
82
+ export type GroupingCell<TGenerics extends AnyGenerics> = {
82
83
  getIsGrouped: () => boolean
83
84
  getIsPlaceholder: () => boolean
84
85
  getIsAggregated: () => boolean
@@ -92,7 +93,7 @@ export type ColumnDefaultOptions = {
92
93
  enableGrouping: boolean
93
94
  }
94
95
 
95
- export type GroupingOptions<TGenerics extends PartialGenerics> = {
96
+ export type GroupingOptions<TGenerics extends AnyGenerics> = {
96
97
  aggregationTypes?: TGenerics['AggregationFns']
97
98
  onGroupingChange?: OnChangeFn<GroupingState>
98
99
  autoResetGrouping?: boolean
@@ -113,7 +114,7 @@ export type ToggleGroupingProps = {
113
114
  onClick?: (event: MouseEvent | TouchEvent) => void
114
115
  }
115
116
 
116
- export type GroupingInstance<TGenerics extends PartialGenerics> = {
117
+ export type GroupingInstance<TGenerics extends AnyGenerics> = {
117
118
  _notifyGroupingReset: () => void
118
119
  getColumnAutoAggregationFn: (
119
120
  columnId: string
@@ -140,7 +141,7 @@ export type GroupingInstance<TGenerics extends PartialGenerics> = {
140
141
 
141
142
  export const Grouping = {
142
143
  getDefaultColumn: <
143
- TGenerics extends PartialGenerics
144
+ TGenerics extends AnyGenerics
144
145
  >(): GroupingColumnDef<TGenerics> => {
145
146
  return {
146
147
  aggregationType: 'auto',
@@ -153,7 +154,7 @@ export const Grouping = {
153
154
  }
154
155
  },
155
156
 
156
- getDefaultOptions: <TGenerics extends PartialGenerics>(
157
+ getDefaultOptions: <TGenerics extends AnyGenerics>(
157
158
  instance: TableInstance<TGenerics>
158
159
  ): GroupingOptions<TGenerics> => {
159
160
  return {
@@ -163,7 +164,7 @@ export const Grouping = {
163
164
  }
164
165
  },
165
166
 
166
- createColumn: <TGenerics extends PartialGenerics>(
167
+ createColumn: <TGenerics extends AnyGenerics>(
167
168
  column: Column<TGenerics>,
168
169
  instance: TableInstance<TGenerics>
169
170
  ): GroupingColumn<TGenerics> => {
@@ -178,7 +179,7 @@ export const Grouping = {
178
179
  }
179
180
  },
180
181
 
181
- getInstance: <TGenerics extends PartialGenerics>(
182
+ getInstance: <TGenerics extends AnyGenerics>(
182
183
  instance: TableInstance<TGenerics>
183
184
  ): GroupingInstance<TGenerics> => {
184
185
  let registered = false
@@ -321,7 +322,7 @@ export const Grouping = {
321
322
  }
322
323
  },
323
324
 
324
- createRow: <TGenerics extends PartialGenerics>(
325
+ createRow: <TGenerics extends AnyGenerics>(
325
326
  row: Row<TGenerics>,
326
327
  instance: TableInstance<TGenerics>
327
328
  ): GroupingRow => {
@@ -330,7 +331,7 @@ export const Grouping = {
330
331
  }
331
332
  },
332
333
 
333
- createCell: <TGenerics extends PartialGenerics>(
334
+ createCell: <TGenerics extends AnyGenerics>(
334
335
  cell: Cell<TGenerics>,
335
336
  column: Column<TGenerics>,
336
337
  row: Row<TGenerics>,
@@ -360,7 +361,7 @@ export const Grouping = {
360
361
  }
361
362
  },
362
363
 
363
- orderColumns: <TGenerics extends PartialGenerics>(
364
+ orderColumns: <TGenerics extends AnyGenerics>(
364
365
  leafColumns: Column<TGenerics>[],
365
366
  grouping: string[],
366
367
  groupedColumnMode?: GroupingColumnMode