@tanstack/table-core 8.0.0-alpha.82 → 8.0.0-alpha.85

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 (108) hide show
  1. package/build/cjs/aggregationFns.js +50 -51
  2. package/build/cjs/aggregationFns.js.map +1 -1
  3. package/build/cjs/core/cell.js +38 -0
  4. package/build/cjs/core/cell.js.map +1 -0
  5. package/build/cjs/core/column.js +88 -0
  6. package/build/cjs/core/column.js.map +1 -0
  7. package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
  8. package/build/cjs/core/headers.js.map +1 -0
  9. package/build/cjs/core/instance.js +255 -0
  10. package/build/cjs/core/instance.js.map +1 -0
  11. package/build/cjs/core/row.js +77 -0
  12. package/build/cjs/core/row.js.map +1 -0
  13. package/build/cjs/createTable.js +3 -2
  14. package/build/cjs/createTable.js.map +1 -1
  15. package/build/cjs/features/ColumnSizing.js +5 -5
  16. package/build/cjs/features/ColumnSizing.js.map +1 -1
  17. package/build/cjs/features/Expanding.js.map +1 -1
  18. package/build/cjs/features/Filters.js +11 -8
  19. package/build/cjs/features/Filters.js.map +1 -1
  20. package/build/cjs/features/Grouping.js +10 -10
  21. package/build/cjs/features/Grouping.js.map +1 -1
  22. package/build/cjs/features/Ordering.js.map +1 -1
  23. package/build/cjs/features/Pagination.js.map +1 -1
  24. package/build/cjs/features/Pinning.js +17 -11
  25. package/build/cjs/features/Pinning.js.map +1 -1
  26. package/build/cjs/features/RowSelection.js.map +1 -1
  27. package/build/cjs/features/Sorting.js +8 -8
  28. package/build/cjs/features/Sorting.js.map +1 -1
  29. package/build/cjs/features/Visibility.js +3 -3
  30. package/build/cjs/features/Visibility.js.map +1 -1
  31. package/build/cjs/index.js +9 -6
  32. package/build/cjs/index.js.map +1 -1
  33. package/build/cjs/utils/filterRowsUtils.js +23 -21
  34. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  35. package/build/cjs/utils/getCoreRowModel.js +9 -8
  36. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  37. package/build/cjs/utils/getGroupedRowModel.js +13 -20
  38. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  39. package/build/cjs/utils/getSortedRowModel.js +2 -2
  40. package/build/cjs/utils/getSortedRowModel.js.map +1 -1
  41. package/build/esm/index.js +764 -865
  42. package/build/esm/index.js.map +1 -1
  43. package/build/stats-html.html +1 -1
  44. package/build/stats-react.json +404 -381
  45. package/build/types/aggregationFns.d.ts +10 -19
  46. package/build/types/core/cell.d.ts +9 -0
  47. package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
  48. package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
  49. package/build/types/core/instance.d.ts +57 -0
  50. package/build/types/core/row.d.ts +15 -0
  51. package/build/types/createTable.d.ts +4 -4
  52. package/build/types/features/ColumnSizing.d.ts +2 -1
  53. package/build/types/features/Expanding.d.ts +2 -1
  54. package/build/types/features/Filters.d.ts +2 -3
  55. package/build/types/features/Grouping.d.ts +8 -9
  56. package/build/types/features/Ordering.d.ts +2 -1
  57. package/build/types/features/Pagination.d.ts +2 -1
  58. package/build/types/features/Pinning.d.ts +3 -2
  59. package/build/types/features/RowSelection.d.ts +2 -1
  60. package/build/types/features/Sorting.d.ts +2 -1
  61. package/build/types/features/Visibility.d.ts +2 -1
  62. package/build/types/index.d.ts +4 -2
  63. package/build/types/sortingFns.d.ts +4 -4
  64. package/build/types/types.d.ts +12 -53
  65. package/build/umd/index.development.js +767 -863
  66. package/build/umd/index.development.js.map +1 -1
  67. package/build/umd/index.production.js +1 -1
  68. package/build/umd/index.production.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/aggregationFns.ts +44 -40
  71. package/src/core/cell.ts +47 -0
  72. package/src/core/column.ts +148 -0
  73. package/src/{features/Headers.ts → core/headers.ts} +98 -99
  74. package/src/core/instance.ts +361 -0
  75. package/src/core/row.ts +85 -0
  76. package/src/createTable.ts +7 -4
  77. package/src/features/ColumnSizing.ts +6 -6
  78. package/src/features/Expanding.ts +1 -2
  79. package/src/features/Filters.ts +9 -10
  80. package/src/features/Grouping.ts +20 -22
  81. package/src/features/Ordering.ts +1 -1
  82. package/src/features/Pagination.ts +1 -1
  83. package/src/features/Pinning.ts +18 -9
  84. package/src/features/RowSelection.ts +1 -1
  85. package/src/features/Sorting.ts +10 -10
  86. package/src/features/Visibility.ts +3 -3
  87. package/src/index.ts +4 -8
  88. package/src/types.ts +16 -64
  89. package/src/utils/filterRowsUtils.ts +4 -2
  90. package/src/utils/getCoreRowModel.ts +4 -2
  91. package/src/utils/getGroupedRowModel.ts +14 -22
  92. package/src/utils/getSortedRowModel.ts +2 -2
  93. package/build/cjs/core.js +0 -168
  94. package/build/cjs/core.js.map +0 -1
  95. package/build/cjs/features/Cells.js +0 -101
  96. package/build/cjs/features/Cells.js.map +0 -1
  97. package/build/cjs/features/Columns.js +0 -189
  98. package/build/cjs/features/Columns.js.map +0 -1
  99. package/build/cjs/features/Headers.js.map +0 -1
  100. package/build/cjs/features/Rows.js +0 -94
  101. package/build/cjs/features/Rows.js.map +0 -1
  102. package/build/types/core.d.ts +0 -30
  103. package/build/types/features/Cells.d.ts +0 -13
  104. package/build/types/features/Rows.d.ts +0 -28
  105. package/src/core.ts +0 -246
  106. package/src/features/Cells.ts +0 -128
  107. package/src/features/Columns.ts +0 -289
  108. package/src/features/Rows.ts +0 -142
@@ -0,0 +1,361 @@
1
+ import { flattenBy, functionalUpdate, memo, RequiredKeys } from '../utils'
2
+
3
+ import {
4
+ Updater,
5
+ TableOptionsResolved,
6
+ TableState,
7
+ TableInstance,
8
+ Renderable,
9
+ TableGenerics,
10
+ InitialTableState,
11
+ Row,
12
+ Column,
13
+ RowModel,
14
+ ColumnDef,
15
+ } from '../types'
16
+
17
+ //
18
+ import { createColumn } from './column'
19
+ import { Headers } from './headers'
20
+ //
21
+
22
+ import { ColumnSizing } from '../features/ColumnSizing'
23
+ import { Expanding } from '../features/Expanding'
24
+ import { Filters } from '../features/Filters'
25
+ import { Grouping } from '../features/Grouping'
26
+ import { Ordering } from '../features/Ordering'
27
+ import { Pagination } from '../features/Pagination'
28
+ import { Pinning } from '../features/Pinning'
29
+ import { RowSelection } from '../features/RowSelection'
30
+ import { Sorting } from '../features/Sorting'
31
+ import { Visibility } from '../features/Visibility'
32
+
33
+ export type TableFeature = {
34
+ getDefaultOptions?: (instance: any) => any
35
+ getInitialState?: (initialState?: InitialTableState) => any
36
+ createInstance?: (instance: any) => any
37
+ getDefaultColumnDef?: () => any
38
+ createColumn?: (column: any, instance: any) => any
39
+ createHeader?: (column: any, instance: any) => any
40
+ createCell?: (cell: any, column: any, row: any, instance: any) => any
41
+ createRow?: (row: any, instance: any) => any
42
+ }
43
+
44
+ const features = [
45
+ Headers,
46
+ Visibility,
47
+ Ordering,
48
+ Pinning,
49
+ Filters,
50
+ Sorting,
51
+ Grouping,
52
+ Expanding,
53
+ Pagination,
54
+ RowSelection,
55
+ ColumnSizing,
56
+ ] as const
57
+
58
+ //
59
+
60
+ export type CoreTableState = {}
61
+
62
+ export type CoreOptions<TGenerics extends TableGenerics> = {
63
+ data: TGenerics['Row'][]
64
+ state: Partial<TableState>
65
+ onStateChange: (updater: Updater<TableState>) => void
66
+ render: TGenerics['Renderer']
67
+ debugAll?: boolean
68
+ debugTable?: boolean
69
+ debugHeaders?: boolean
70
+ debugColumns?: boolean
71
+ debugRows?: boolean
72
+ initialState?: InitialTableState
73
+ autoResetAll?: boolean
74
+ mergeOptions?: <T>(defaultOptions: T, options: Partial<T>) => T
75
+ meta?: TGenerics['TableMeta']
76
+ getCoreRowModel: (
77
+ instance: TableInstance<TGenerics>
78
+ ) => () => RowModel<TGenerics>
79
+ getSubRows?: (
80
+ originalRow: TGenerics['Row'],
81
+ index: number
82
+ ) => undefined | TGenerics['Row'][]
83
+ getRowId?: (
84
+ originalRow: TGenerics['Row'],
85
+ index: number,
86
+ parent?: Row<TGenerics>
87
+ ) => string
88
+ columns: ColumnDef<TGenerics>[]
89
+ defaultColumn?: Partial<ColumnDef<TGenerics>>
90
+ }
91
+
92
+ export type CoreInstance<TGenerics extends TableGenerics> = {
93
+ initialState: TableState
94
+ reset: () => void
95
+ options: RequiredKeys<TableOptionsResolved<TGenerics>, 'state'>
96
+ setOptions: (newOptions: Updater<TableOptionsResolved<TGenerics>>) => void
97
+ getState: () => TableState
98
+ setState: (updater: Updater<TableState>) => void
99
+ _features: readonly TableFeature[]
100
+ _queue: (cb: () => void) => void
101
+ _render: <TProps>(
102
+ template: Renderable<TGenerics, TProps>,
103
+ props: TProps
104
+ ) => string | null | TGenerics['Rendered']
105
+ _getRowId: (
106
+ _: TGenerics['Row'],
107
+ index: number,
108
+ parent?: Row<TGenerics>
109
+ ) => string
110
+ getCoreRowModel: () => RowModel<TGenerics>
111
+ _getCoreRowModel?: () => RowModel<TGenerics>
112
+ getRowModel: () => RowModel<TGenerics>
113
+ getRow: (id: string) => Row<TGenerics>
114
+ _getDefaultColumnDef: () => Partial<ColumnDef<TGenerics>>
115
+ _getColumnDefs: () => ColumnDef<TGenerics>[]
116
+ _getAllFlatColumnsById: () => Record<string, Column<TGenerics>>
117
+ getAllColumns: () => Column<TGenerics>[]
118
+ getAllFlatColumns: () => Column<TGenerics>[]
119
+ getAllLeafColumns: () => Column<TGenerics>[]
120
+ getColumn: (columnId: string) => Column<TGenerics>
121
+ }
122
+
123
+ export function createTableInstance<TGenerics extends TableGenerics>(
124
+ options: TableOptionsResolved<TGenerics>
125
+ ): TableInstance<TGenerics> {
126
+ if (options.debugAll || options.debugTable) {
127
+ console.info('Creating Table Instance...')
128
+ }
129
+
130
+ let instance = { _features: features } as unknown as TableInstance<TGenerics>
131
+
132
+ const defaultOptions = instance._features.reduce((obj, feature) => {
133
+ return Object.assign(obj, feature.getDefaultOptions?.(instance))
134
+ }, {}) as TableOptionsResolved<TGenerics>
135
+
136
+ const mergeOptions = (options: TableOptionsResolved<TGenerics>) => {
137
+ if (instance.options.mergeOptions) {
138
+ return instance.options.mergeOptions(defaultOptions, options)
139
+ }
140
+
141
+ return {
142
+ ...defaultOptions,
143
+ ...options,
144
+ }
145
+ }
146
+
147
+ const coreInitialState: CoreTableState = {}
148
+
149
+ let initialState = {
150
+ ...coreInitialState,
151
+ ...(options.initialState ?? {}),
152
+ } as TableState
153
+
154
+ instance._features.forEach(feature => {
155
+ initialState = feature.getInitialState?.(initialState) ?? initialState
156
+ })
157
+
158
+ const queued: (() => void)[] = []
159
+ let queuedTimeout = false
160
+
161
+ const coreInstance: CoreInstance<TGenerics> = {
162
+ _features: features,
163
+ options: {
164
+ ...defaultOptions,
165
+ ...options,
166
+ },
167
+ initialState,
168
+ _queue: cb => {
169
+ queued.push(cb)
170
+
171
+ if (!queuedTimeout) {
172
+ queuedTimeout = true
173
+
174
+ // Schedule a microtask to run the queued callbacks after
175
+ // the current call stack (render, etc) has finished.
176
+ Promise.resolve()
177
+ .then(() => {
178
+ while (queued.length) {
179
+ queued.shift()!()
180
+ }
181
+ queuedTimeout = false
182
+ })
183
+ .catch(error =>
184
+ setTimeout(() => {
185
+ throw error
186
+ })
187
+ )
188
+ }
189
+ },
190
+ reset: () => {
191
+ instance.setState(instance.initialState)
192
+ },
193
+ setOptions: updater => {
194
+ const newOptions = functionalUpdate(updater, instance.options)
195
+ instance.options = mergeOptions(newOptions)
196
+ },
197
+ _render: (template, props) => {
198
+ if (typeof instance.options.render === 'function') {
199
+ return instance.options.render(template, props)
200
+ }
201
+
202
+ if (typeof template === 'function') {
203
+ return (template as Function)(props)
204
+ }
205
+
206
+ return template
207
+ },
208
+
209
+ getState: () => {
210
+ return instance.options.state as TableState
211
+ },
212
+
213
+ setState: (updater: Updater<TableState>) => {
214
+ instance.options.onStateChange?.(updater)
215
+ },
216
+
217
+ _getRowId: (
218
+ row: TGenerics['Row'],
219
+ index: number,
220
+ parent?: Row<TGenerics>
221
+ ) =>
222
+ instance.options.getRowId?.(row, index, parent) ??
223
+ `${parent ? [parent.id, index].join('.') : index}`,
224
+
225
+ getCoreRowModel: () => {
226
+ if (!instance._getCoreRowModel) {
227
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance)
228
+ }
229
+
230
+ return instance._getCoreRowModel()
231
+ },
232
+
233
+ // The final calls start at the bottom of the model,
234
+ // expanded rows, which then work their way up
235
+
236
+ getRowModel: () => {
237
+ return instance.getPaginationRowModel()
238
+ },
239
+ getRow: (id: string) => {
240
+ const row = instance.getRowModel().rowsById[id]
241
+
242
+ if (!row) {
243
+ if (process.env.NODE_ENV !== 'production') {
244
+ throw new Error(`getRow expected an ID, but got ${id}`)
245
+ }
246
+ throw new Error()
247
+ }
248
+
249
+ return row
250
+ },
251
+ _getDefaultColumnDef: memo(
252
+ () => [instance.options.defaultColumn],
253
+ defaultColumn => {
254
+ defaultColumn = (defaultColumn ?? {}) as Partial<ColumnDef<TGenerics>>
255
+
256
+ return {
257
+ header: props => props.header.column.id,
258
+ footer: props => props.header.column.id,
259
+ cell: props => props.getValue().toString?.() ?? null,
260
+ ...instance._features.reduce((obj, feature) => {
261
+ return Object.assign(obj, feature.getDefaultColumnDef?.())
262
+ }, {}),
263
+ ...defaultColumn,
264
+ } as Partial<ColumnDef<TGenerics>>
265
+ },
266
+ {
267
+ debug: () => instance.options.debugAll ?? instance.options.debugColumns,
268
+ key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef',
269
+ }
270
+ ),
271
+
272
+ _getColumnDefs: () => instance.options.columns,
273
+
274
+ getAllColumns: memo(
275
+ () => [instance._getColumnDefs()],
276
+ columnDefs => {
277
+ const recurseColumns = (
278
+ columnDefs: ColumnDef<TGenerics>[],
279
+ parent?: Column<TGenerics>,
280
+ depth = 0
281
+ ): Column<TGenerics>[] => {
282
+ return columnDefs.map(columnDef => {
283
+ const column = createColumn(instance, columnDef, depth, parent)
284
+
285
+ column.columns = columnDef.columns
286
+ ? recurseColumns(columnDef.columns, column, depth + 1)
287
+ : []
288
+
289
+ return column
290
+ })
291
+ }
292
+
293
+ return recurseColumns(columnDefs)
294
+ },
295
+ {
296
+ key: process.env.NODE_ENV === 'development' && 'getAllColumns',
297
+ debug: () => instance.options.debugAll ?? instance.options.debugColumns,
298
+ }
299
+ ),
300
+
301
+ getAllFlatColumns: memo(
302
+ () => [instance.getAllColumns()],
303
+ allColumns => {
304
+ return allColumns.flatMap(column => {
305
+ return column.getFlatColumns()
306
+ })
307
+ },
308
+ {
309
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
310
+ debug: () => instance.options.debugAll ?? instance.options.debugColumns,
311
+ }
312
+ ),
313
+
314
+ _getAllFlatColumnsById: memo(
315
+ () => [instance.getAllFlatColumns()],
316
+ flatColumns => {
317
+ return flatColumns.reduce((acc, column) => {
318
+ acc[column.id] = column
319
+ return acc
320
+ }, {} as Record<string, Column<TGenerics>>)
321
+ },
322
+ {
323
+ key: process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
324
+ debug: () => instance.options.debugAll ?? instance.options.debugColumns,
325
+ }
326
+ ),
327
+
328
+ getAllLeafColumns: memo(
329
+ () => [instance.getAllColumns(), instance._getOrderColumnsFn()],
330
+ (allColumns, orderColumns) => {
331
+ let leafColumns = allColumns.flatMap(column => column.getLeafColumns())
332
+ return orderColumns(leafColumns)
333
+ },
334
+ {
335
+ key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
336
+ debug: () => instance.options.debugAll ?? instance.options.debugColumns,
337
+ }
338
+ ),
339
+
340
+ getColumn: columnId => {
341
+ const column = instance._getAllFlatColumnsById()[columnId]
342
+
343
+ if (!column) {
344
+ if (process.env.NODE_ENV !== 'production') {
345
+ console.warn(`[Table] Column with id ${columnId} does not exist.`)
346
+ }
347
+ throw new Error()
348
+ }
349
+
350
+ return column
351
+ },
352
+ }
353
+
354
+ Object.assign(instance, coreInstance)
355
+
356
+ instance._features.forEach(feature => {
357
+ return Object.assign(instance, feature.createInstance?.(instance))
358
+ })
359
+
360
+ return instance
361
+ }
@@ -0,0 +1,85 @@
1
+ import { Cell, Row, TableGenerics, TableInstance } from '../types'
2
+ import { flattenBy, memo } from '../utils'
3
+ import { createCell } from './cell'
4
+
5
+ export type CoreRow<TGenerics extends TableGenerics> = {
6
+ id: string
7
+ index: number
8
+ original?: TGenerics['Row']
9
+ depth: number
10
+ _valuesCache: Record<string, any>
11
+ getValue: (columnId: string) => any
12
+ subRows: Row<TGenerics>[]
13
+ getLeafRows: () => Row<TGenerics>[]
14
+ originalSubRows?: TGenerics['Row'][]
15
+ getAllCells: () => Cell<TGenerics>[]
16
+ _getAllCellsByColumnId: () => Record<string, Cell<TGenerics>>
17
+ }
18
+
19
+ export const createRow = <TGenerics extends TableGenerics>(
20
+ instance: TableInstance<TGenerics>,
21
+ id: string,
22
+ original: TGenerics['Row'] | undefined,
23
+ rowIndex: number,
24
+ depth: number,
25
+ subRows?: Row<TGenerics>[]
26
+ ): Row<TGenerics> => {
27
+ let row: CoreRow<TGenerics> = {
28
+ id,
29
+ index: rowIndex,
30
+ original,
31
+ depth,
32
+ _valuesCache: {},
33
+ getValue: columnId => {
34
+ if (row._valuesCache.hasOwnProperty(columnId)) {
35
+ return row._valuesCache[columnId]
36
+ }
37
+
38
+ const column = instance.getColumn(columnId)
39
+
40
+ if (!column.accessorFn) {
41
+ return undefined
42
+ }
43
+
44
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex)
45
+
46
+ return row._valuesCache[columnId]
47
+ },
48
+ subRows: subRows ?? [],
49
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
50
+ getAllCells: memo(
51
+ () => [instance.getAllLeafColumns()],
52
+ leafColumns => {
53
+ return leafColumns.map(column => {
54
+ return createCell(instance, row as Row<TGenerics>, column, column.id)
55
+ })
56
+ },
57
+ {
58
+ key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
59
+ debug: () => instance.options.debugAll ?? instance.options.debugRows,
60
+ }
61
+ ),
62
+
63
+ _getAllCellsByColumnId: memo(
64
+ () => [row.getAllCells()],
65
+ allCells => {
66
+ return allCells.reduce((acc, cell) => {
67
+ acc[cell.column.id] = cell
68
+ return acc
69
+ }, {} as Record<string, Cell<TGenerics>>)
70
+ },
71
+ {
72
+ key:
73
+ process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',
74
+ debug: () => instance.options.debugAll ?? instance.options.debugRows,
75
+ }
76
+ ),
77
+ }
78
+
79
+ for (let i = 0; i < instance._features.length; i++) {
80
+ const feature = instance._features[i]
81
+ Object.assign(row, feature?.createRow?.(row, instance))
82
+ }
83
+
84
+ return row as Row<TGenerics>
85
+ }
@@ -6,6 +6,7 @@ import {
6
6
  AccessorFn,
7
7
  AnyRender,
8
8
  TableGenerics,
9
+ TableOptionsResolved,
9
10
  TableOptions,
10
11
  } from './types'
11
12
  import { IfDefined, Overwrite } from './utils'
@@ -26,15 +27,15 @@ export type CreateTableOptions<
26
27
  sortingFns?: TSortingFns
27
28
  aggregationFns?: TAggregationFns
28
29
  } & Omit<
29
- TableOptions<TGenerics>,
30
+ TableOptionsResolved<TGenerics>,
30
31
  'filterFns' | 'sortingFns' | 'aggregationFns'
31
32
  >
32
33
  >
33
34
 
34
35
  export type Table<TGenerics extends TableGenerics> = {
35
36
  generics: TGenerics
36
- options: Partial<TableOptions<TGenerics>>
37
- setGenerics: <T extends TableGenerics>() => Table<T>
37
+ options: Partial<TableOptionsResolved<TGenerics>>
38
+ // setGenerics: <T extends TableGenerics>() => Table<T>
38
39
  setRowType: <TRow>() => Table<Overwrite<TGenerics, { Row: TRow }>>
39
40
  setTableMetaType: <TTableMeta>() => Table<
40
41
  Overwrite<TGenerics, { TableMeta: TTableMeta }>
@@ -119,6 +120,7 @@ export type Table<TGenerics extends TableGenerics> = {
119
120
  }
120
121
  >
121
122
  ) => ColumnDef<TGenerics>
123
+ createOptions: (options: TableOptions<TGenerics>) => TableOptions<TGenerics>
122
124
  }
123
125
 
124
126
  //
@@ -143,7 +145,7 @@ function createTable<TGenerics extends TableGenerics>(
143
145
  throw new Error('')
144
146
  })(),
145
147
  },
146
- setGenerics: () => table as any,
148
+ // setGenerics: () => table as any,
147
149
  setRowType: () => table as any,
148
150
  setTableMetaType: () => table as any,
149
151
  setColumnMetaType: () => table as any,
@@ -179,6 +181,7 @@ function createTable<TGenerics extends TableGenerics>(
179
181
 
180
182
  throw new Error('Invalid accessor')
181
183
  },
184
+ createOptions: options => options,
182
185
  }
183
186
 
184
187
  return table
@@ -1,3 +1,4 @@
1
+ import { TableFeature } from '../core/instance'
1
2
  import {
2
3
  Column,
3
4
  Header,
@@ -5,7 +6,6 @@ import {
5
6
  TableGenerics,
6
7
  TableInstance,
7
8
  Updater,
8
- TableFeature,
9
9
  } from '../types'
10
10
  import { makeStateUpdater } from '../utils'
11
11
  import { ColumnPinningPosition } from './Pinning'
@@ -93,7 +93,7 @@ const getDefaultColumnSizingInfoState = (): ColumnSizingInfoState => ({
93
93
  })
94
94
 
95
95
  export const ColumnSizing: TableFeature = {
96
- getDefaultColumn: (): ColumnSizingColumnDef => {
96
+ getDefaultColumnDef: (): ColumnSizingColumnDef => {
97
97
  return defaultColumnSizing
98
98
  },
99
99
  getInitialState: (state): ColumnSizingTableState => {
@@ -124,10 +124,10 @@ export const ColumnSizing: TableFeature = {
124
124
 
125
125
  return Math.min(
126
126
  Math.max(
127
- column.minSize ?? defaultColumnSizing.minSize,
128
- columnSize ?? column.size ?? defaultColumnSizing.size
127
+ column.columnDef.minSize ?? defaultColumnSizing.minSize,
128
+ columnSize ?? column.columnDef.size ?? defaultColumnSizing.size
129
129
  ),
130
- column.maxSize ?? defaultColumnSizing.maxSize
130
+ column.columnDef.maxSize ?? defaultColumnSizing.maxSize
131
131
  )
132
132
  },
133
133
  getStart: position => {
@@ -156,7 +156,7 @@ export const ColumnSizing: TableFeature = {
156
156
  },
157
157
  getCanResize: () => {
158
158
  return (
159
- (column.enableResizing ?? true) &&
159
+ (column.columnDef.enableResizing ?? true) &&
160
160
  (instance.options.enableColumnResizing ?? true)
161
161
  )
162
162
  },
@@ -1,14 +1,13 @@
1
1
  import { RowModel } from '..'
2
+ import { TableFeature } from '../core/instance'
2
3
  import {
3
4
  OnChangeFn,
4
5
  TableGenerics,
5
6
  TableInstance,
6
7
  Row,
7
8
  Updater,
8
- TableFeature,
9
9
  } from '../types'
10
10
  import { makeStateUpdater } from '../utils'
11
- import { Rows } from './Rows'
12
11
 
13
12
  export type ExpandedStateList = Record<string, boolean>
14
13
  export type ExpandedState = true | Record<string, boolean>
@@ -1,4 +1,5 @@
1
1
  import { RowModel } from '..'
2
+ import { TableFeature } from '../core/instance'
2
3
  import { BuiltInFilterFn, filterFns } from '../filterFns'
3
4
  import {
4
5
  Column,
@@ -7,7 +8,6 @@ import {
7
8
  TableInstance,
8
9
  Row,
9
10
  Updater,
10
- TableFeature,
11
11
  } from '../types'
12
12
  import {
13
13
  functionalUpdate,
@@ -20,8 +20,6 @@ import {
20
20
  export type FiltersTableState = {
21
21
  columnFilters: ColumnFiltersState
22
22
  globalFilter: any
23
- // filtersProgress: number
24
- // facetProgress: Record<string, number>
25
23
  }
26
24
 
27
25
  export type ColumnFiltersState = ColumnFilter[]
@@ -74,7 +72,6 @@ export type FiltersColumnDef<TGenerics extends TableGenerics> = {
74
72
  filterFn?: FilterFnOption<Overwrite<TGenerics, { Value: any }>>
75
73
  enableColumnFilter?: boolean
76
74
  enableGlobalFilter?: boolean
77
- enableFaceting?: boolean
78
75
  }
79
76
 
80
77
  export type FiltersColumn<TGenerics extends TableGenerics> = {
@@ -98,7 +95,6 @@ export type FiltersColumn<TGenerics extends TableGenerics> = {
98
95
  export type FiltersRow<TGenerics extends TableGenerics> = {
99
96
  columnFilters: Record<string, boolean>
100
97
  columnFiltersMeta: Record<string, TGenerics['FilterMeta']>
101
- subRowsByFacetId: Record<string, Row<TGenerics>[]>
102
98
  }
103
99
 
104
100
  export type FiltersOptions<TGenerics extends TableGenerics> = {
@@ -161,7 +157,7 @@ export type FiltersInstance<TGenerics extends TableGenerics> = {
161
157
  //
162
158
 
163
159
  export const Filters: TableFeature = {
164
- getDefaultColumn: <
160
+ getDefaultColumnDef: <
165
161
  TGenerics extends TableGenerics
166
162
  >(): FiltersColumnDef<TGenerics> => {
167
163
  return {
@@ -190,7 +186,7 @@ export const Filters: TableFeature = {
190
186
  getColumnCanGlobalFilter: column => {
191
187
  const value = instance
192
188
  .getCoreRowModel()
193
- .flatRows[0]?.getAllCellsByColumnId()
189
+ .flatRows[0]?._getAllCellsByColumnId()
194
190
  [column.id]?.getValue()
195
191
 
196
192
  return typeof value === 'string'
@@ -217,6 +213,10 @@ export const Filters: TableFeature = {
217
213
  return filterFns.inNumberRange
218
214
  }
219
215
 
216
+ if (typeof value === 'boolean') {
217
+ return filterFns.equals
218
+ }
219
+
220
220
  if (value !== null && typeof value === 'object') {
221
221
  return filterFns.equals
222
222
  }
@@ -243,7 +243,7 @@ export const Filters: TableFeature = {
243
243
  },
244
244
  getCanFilter: () => {
245
245
  return (
246
- (column.enableColumnFilter ?? true) &&
246
+ (column.columnDef.enableColumnFilter ?? true) &&
247
247
  (instance.options.enableColumnFilters ?? true) &&
248
248
  (instance.options.enableFilters ?? true) &&
249
249
  !!column.accessorFn
@@ -252,7 +252,7 @@ export const Filters: TableFeature = {
252
252
 
253
253
  getCanGlobalFilter: () => {
254
254
  return (
255
- (column.enableGlobalFilter ?? true) &&
255
+ (column.columnDef.enableGlobalFilter ?? true) &&
256
256
  (instance.options.enableGlobalFilter ?? true) &&
257
257
  (instance.options.enableFilters ?? true) &&
258
258
  (instance.options.getColumnCanGlobalFilter?.(column) ?? true) &&
@@ -352,7 +352,6 @@ export const Filters: TableFeature = {
352
352
  return {
353
353
  columnFilters: {},
354
354
  columnFiltersMeta: {},
355
- subRowsByFacetId: {},
356
355
  }
357
356
  },
358
357