@tanstack/table-core 8.13.1 → 8.14.0

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 (104) hide show
  1. package/build/lib/aggregationFns.d.ts +1 -1
  2. package/build/lib/aggregationFns.js.map +1 -1
  3. package/build/lib/core/column.js +1 -1
  4. package/build/lib/core/column.js.map +1 -1
  5. package/build/lib/core/headers.d.ts +1 -2
  6. package/build/lib/core/headers.js.map +1 -1
  7. package/build/lib/core/row.js.map +1 -1
  8. package/build/lib/core/table.d.ts +7 -11
  9. package/build/lib/core/table.js +21 -13
  10. package/build/lib/core/table.js.map +1 -1
  11. package/build/lib/features/ColumnFaceting.d.ts +34 -0
  12. package/build/lib/features/ColumnFaceting.js +42 -0
  13. package/build/lib/features/ColumnFaceting.js.map +1 -0
  14. package/build/lib/features/{Filters.d.ts → ColumnFiltering.d.ts} +29 -132
  15. package/build/lib/features/{Filters.js → ColumnFiltering.js} +8 -83
  16. package/build/lib/features/ColumnFiltering.js.map +1 -0
  17. package/build/lib/features/{Grouping.d.ts → ColumnGrouping.d.ts} +2 -3
  18. package/build/lib/features/{Grouping.js → ColumnGrouping.js} +3 -3
  19. package/build/lib/features/ColumnGrouping.js.map +1 -0
  20. package/build/lib/features/{Ordering.d.ts → ColumnOrdering.d.ts} +2 -3
  21. package/build/lib/features/{Ordering.js → ColumnOrdering.js} +9 -9
  22. package/build/lib/features/ColumnOrdering.js.map +1 -0
  23. package/build/lib/features/ColumnPinning.d.ts +126 -0
  24. package/build/lib/features/{Pinning.js → ColumnPinning.js} +4 -115
  25. package/build/lib/features/ColumnPinning.js.map +1 -0
  26. package/build/lib/features/ColumnSizing.d.ts +2 -3
  27. package/build/lib/features/ColumnSizing.js +3 -3
  28. package/build/lib/features/ColumnSizing.js.map +1 -1
  29. package/build/lib/features/{Visibility.d.ts → ColumnVisibility.d.ts} +2 -3
  30. package/build/lib/features/{Visibility.js → ColumnVisibility.js} +3 -3
  31. package/build/lib/features/ColumnVisibility.js.map +1 -0
  32. package/build/lib/features/GlobalFiltering.d.ts +100 -0
  33. package/build/lib/features/GlobalFiltering.js +85 -0
  34. package/build/lib/features/GlobalFiltering.js.map +1 -0
  35. package/build/lib/features/{Expanding.d.ts → RowExpanding.d.ts} +2 -3
  36. package/build/lib/features/{Expanding.js → RowExpanding.js} +3 -3
  37. package/build/lib/features/RowExpanding.js.map +1 -0
  38. package/build/lib/features/{Pagination.d.ts → RowPagination.d.ts} +2 -3
  39. package/build/lib/features/{Pagination.js → RowPagination.js} +3 -3
  40. package/build/lib/features/RowPagination.js.map +1 -0
  41. package/build/lib/features/RowPinning.d.ts +98 -0
  42. package/build/lib/features/RowPinning.js +145 -0
  43. package/build/lib/features/RowPinning.js.map +1 -0
  44. package/build/lib/features/RowSelection.d.ts +1 -2
  45. package/build/lib/features/RowSelection.js.map +1 -1
  46. package/build/lib/features/{Sorting.d.ts → RowSorting.d.ts} +5 -3
  47. package/build/lib/features/{Sorting.js → RowSorting.js} +3 -3
  48. package/build/lib/features/RowSorting.js.map +1 -0
  49. package/build/lib/filterFns.d.ts +1 -1
  50. package/build/lib/filterFns.js.map +1 -1
  51. package/build/lib/index.d.ts +21 -18
  52. package/build/lib/index.esm.js +1490 -1446
  53. package/build/lib/index.esm.js.map +1 -1
  54. package/build/lib/index.js +47 -41
  55. package/build/lib/index.js.map +1 -1
  56. package/build/lib/index.mjs +1490 -1446
  57. package/build/lib/index.mjs.map +1 -1
  58. package/build/lib/sortingFns.d.ts +1 -1
  59. package/build/lib/sortingFns.js.map +1 -1
  60. package/build/lib/types.d.ts +30 -16
  61. package/build/lib/utils/getFilteredRowModel.js.map +1 -1
  62. package/build/lib/utils/getSortedRowModel.js.map +1 -1
  63. package/build/lib/utils.d.ts +1 -1
  64. package/build/lib/utils.js.map +1 -1
  65. package/build/umd/index.development.js +1500 -1453
  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 +1 -1
  71. package/src/core/column.ts +2 -2
  72. package/src/core/headers.ts +9 -3
  73. package/src/core/row.ts +1 -1
  74. package/src/core/table.ts +40 -32
  75. package/src/features/ColumnFaceting.ts +84 -0
  76. package/src/features/{Filters.ts → ColumnFiltering.ts} +44 -279
  77. package/src/features/{Grouping.ts → ColumnGrouping.ts} +6 -6
  78. package/src/features/{Ordering.ts → ColumnOrdering.ts} +11 -5
  79. package/src/features/ColumnPinning.ts +336 -0
  80. package/src/features/ColumnSizing.ts +10 -3
  81. package/src/features/{Visibility.ts → ColumnVisibility.ts} +2 -2
  82. package/src/features/GlobalFiltering.ts +218 -0
  83. package/src/features/{Expanding.ts → RowExpanding.ts} +9 -3
  84. package/src/features/{Pagination.ts → RowPagination.ts} +9 -3
  85. package/src/features/RowPinning.ts +273 -0
  86. package/src/features/RowSelection.ts +9 -2
  87. package/src/features/{Sorting.ts → RowSorting.ts} +5 -2
  88. package/src/filterFns.ts +1 -1
  89. package/src/index.ts +30 -18
  90. package/src/sortingFns.ts +1 -1
  91. package/src/types.ts +60 -23
  92. package/src/utils/getFilteredRowModel.ts +1 -1
  93. package/src/utils/getSortedRowModel.ts +1 -1
  94. package/src/utils.ts +9 -11
  95. package/build/lib/features/Expanding.js.map +0 -1
  96. package/build/lib/features/Filters.js.map +0 -1
  97. package/build/lib/features/Grouping.js.map +0 -1
  98. package/build/lib/features/Ordering.js.map +0 -1
  99. package/build/lib/features/Pagination.js.map +0 -1
  100. package/build/lib/features/Pinning.d.ts +0 -222
  101. package/build/lib/features/Pinning.js.map +0 -1
  102. package/build/lib/features/Sorting.js.map +0 -1
  103. package/build/lib/features/Visibility.js.map +0 -1
  104. package/src/features/Pinning.ts +0 -573
@@ -0,0 +1,273 @@
1
+ import {
2
+ OnChangeFn,
3
+ Updater,
4
+ Table,
5
+ Row,
6
+ RowData,
7
+ TableFeature,
8
+ } from '../types'
9
+ import { getMemoOptions, makeStateUpdater, memo } from '../utils'
10
+
11
+ export type RowPinningPosition = false | 'top' | 'bottom'
12
+
13
+ export interface RowPinningState {
14
+ bottom?: string[]
15
+ top?: string[]
16
+ }
17
+
18
+ export interface RowPinningTableState {
19
+ rowPinning: RowPinningState
20
+ }
21
+
22
+ export interface RowPinningOptions<TData extends RowData> {
23
+ /**
24
+ * Enables/disables row pinning for the table. Defaults to `true`.
25
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#enablerowpinning)
26
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
27
+ */
28
+ enableRowPinning?: boolean | ((row: Row<TData>) => boolean)
29
+ /**
30
+ * When `false`, pinned rows will not be visible if they are filtered or paginated out of the table. When `true`, pinned rows will always be visible regardless of filtering or pagination. Defaults to `true`.
31
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#keeppinnedrows)
32
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
33
+ */
34
+ keepPinnedRows?: boolean
35
+ /**
36
+ * If provided, this function will be called with an `updaterFn` when `state.rowPinning` changes. This overrides the default internal state management, so you will also need to supply `state.rowPinning` from your own managed state.
37
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#onrowpinningchange)
38
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/onrowpinningchange)
39
+ */
40
+ onRowPinningChange?: OnChangeFn<RowPinningState>
41
+ }
42
+
43
+ export interface RowPinningDefaultOptions {
44
+ onRowPinningChange: OnChangeFn<RowPinningState>
45
+ }
46
+
47
+ export interface RowPinningRow {
48
+ /**
49
+ * Returns whether or not the row can be pinned.
50
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getcanpin-1)
51
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
52
+ */
53
+ getCanPin: () => boolean
54
+ /**
55
+ * Returns the pinned position of the row. (`'top'`, `'bottom'` or `false`)
56
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getispinned-1)
57
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
58
+ */
59
+ getIsPinned: () => RowPinningPosition
60
+ /**
61
+ * Returns the numeric pinned index of the row within a pinned row group.
62
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getpinnedindex-1)
63
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
64
+ */
65
+ getPinnedIndex: () => number
66
+ /**
67
+ * Pins a row to the `'top'` or `'bottom'`, or unpins the row to the center if `false` is passed.
68
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#pin-1)
69
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
70
+ */
71
+ pin: (
72
+ position: RowPinningPosition,
73
+ includeLeafRows?: boolean,
74
+ includeParentRows?: boolean
75
+ ) => void
76
+ }
77
+
78
+ export interface RowPinningInstance<TData extends RowData> {
79
+ _getPinnedRows: (position: 'top' | 'bottom') => Row<TData>[]
80
+ /**
81
+ * Returns all bottom pinned rows.
82
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getbottomrows)
83
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
84
+ */
85
+ getBottomRows: () => Row<TData>[]
86
+ /**
87
+ * Returns all rows that are not pinned to the top or bottom.
88
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getcenterrows)
89
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
90
+ */
91
+ getCenterRows: () => Row<TData>[]
92
+ /**
93
+ * Returns whether or not any rows are pinned. Optionally specify to only check for pinned rows in either the `top` or `bottom` position.
94
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getissomerowspinned)
95
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
96
+ */
97
+ getIsSomeRowsPinned: (position?: RowPinningPosition) => boolean
98
+ /**
99
+ * Returns all top pinned rows.
100
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#gettoprows)
101
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
102
+ */
103
+ getTopRows: () => Row<TData>[]
104
+ /**
105
+ * Resets the **rowPinning** state to `initialState.rowPinning`, or `true` can be passed to force a default blank state reset to `{ top: [], bottom: [], }`.
106
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#resetrowpinning)
107
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
108
+ */
109
+ resetRowPinning: (defaultState?: boolean) => void
110
+ /**
111
+ * Sets or updates the `state.rowPinning` state.
112
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#setrowpinning)
113
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)
114
+ */
115
+ setRowPinning: (updater: Updater<RowPinningState>) => void
116
+ }
117
+
118
+ //
119
+
120
+ const getDefaultRowPinningState = (): RowPinningState => ({
121
+ top: [],
122
+ bottom: [],
123
+ })
124
+
125
+ export const RowPinning: TableFeature = {
126
+ getInitialState: (state): RowPinningTableState => {
127
+ return {
128
+ rowPinning: getDefaultRowPinningState(),
129
+ ...state,
130
+ }
131
+ },
132
+
133
+ getDefaultOptions: <TData extends RowData>(
134
+ table: Table<TData>
135
+ ): RowPinningDefaultOptions => {
136
+ return {
137
+ onRowPinningChange: makeStateUpdater('rowPinning', table),
138
+ }
139
+ },
140
+
141
+ createRow: <TData extends RowData>(
142
+ row: Row<TData>,
143
+ table: Table<TData>
144
+ ): void => {
145
+ row.pin = (position, includeLeafRows, includeParentRows) => {
146
+ const leafRowIds = includeLeafRows
147
+ ? row.getLeafRows().map(({ id }) => id)
148
+ : []
149
+ const parentRowIds = includeParentRows
150
+ ? row.getParentRows().map(({ id }) => id)
151
+ : []
152
+ const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds])
153
+
154
+ table.setRowPinning(old => {
155
+ if (position === 'bottom') {
156
+ return {
157
+ top: (old?.top ?? []).filter(d => !rowIds?.has(d)),
158
+ bottom: [
159
+ ...(old?.bottom ?? []).filter(d => !rowIds?.has(d)),
160
+ ...Array.from(rowIds),
161
+ ],
162
+ }
163
+ }
164
+
165
+ if (position === 'top') {
166
+ return {
167
+ top: [
168
+ ...(old?.top ?? []).filter(d => !rowIds?.has(d)),
169
+ ...Array.from(rowIds),
170
+ ],
171
+ bottom: (old?.bottom ?? []).filter(d => !rowIds?.has(d)),
172
+ }
173
+ }
174
+
175
+ return {
176
+ top: (old?.top ?? []).filter(d => !rowIds?.has(d)),
177
+ bottom: (old?.bottom ?? []).filter(d => !rowIds?.has(d)),
178
+ }
179
+ })
180
+ }
181
+ row.getCanPin = () => {
182
+ const { enableRowPinning, enablePinning } = table.options
183
+ if (typeof enableRowPinning === 'function') {
184
+ return enableRowPinning(row)
185
+ }
186
+ return enableRowPinning ?? enablePinning ?? true
187
+ }
188
+ row.getIsPinned = () => {
189
+ const rowIds = [row.id]
190
+
191
+ const { top, bottom } = table.getState().rowPinning
192
+
193
+ const isTop = rowIds.some(d => top?.includes(d))
194
+ const isBottom = rowIds.some(d => bottom?.includes(d))
195
+
196
+ return isTop ? 'top' : isBottom ? 'bottom' : false
197
+ }
198
+ row.getPinnedIndex = () => {
199
+ const position = row.getIsPinned()
200
+ if (!position) return -1
201
+
202
+ const visiblePinnedRowIds = table
203
+ ._getPinnedRows(position)
204
+ ?.map(({ id }) => id)
205
+
206
+ return visiblePinnedRowIds?.indexOf(row.id) ?? -1
207
+ }
208
+ },
209
+
210
+ createTable: <TData extends RowData>(table: Table<TData>): void => {
211
+ table.setRowPinning = updater => table.options.onRowPinningChange?.(updater)
212
+
213
+ table.resetRowPinning = defaultState =>
214
+ table.setRowPinning(
215
+ defaultState
216
+ ? getDefaultRowPinningState()
217
+ : table.initialState?.rowPinning ?? getDefaultRowPinningState()
218
+ )
219
+
220
+ table.getIsSomeRowsPinned = position => {
221
+ const pinningState = table.getState().rowPinning
222
+
223
+ if (!position) {
224
+ return Boolean(pinningState.top?.length || pinningState.bottom?.length)
225
+ }
226
+ return Boolean(pinningState[position]?.length)
227
+ }
228
+
229
+ table._getPinnedRows = memo(
230
+ position => [
231
+ table.getRowModel().rows,
232
+ table.getState().rowPinning[position!],
233
+ position,
234
+ ],
235
+ (visibleRows, pinnedRowIds, position) => {
236
+ const rows =
237
+ table.options.keepPinnedRows ?? true
238
+ ? //get all rows that are pinned even if they would not be otherwise visible
239
+ //account for expanded parent rows, but not pagination or filtering
240
+ (pinnedRowIds ?? []).map(rowId => {
241
+ const row = table.getRow(rowId, true)
242
+ return row.getIsAllParentsExpanded() ? row : null
243
+ })
244
+ : //else get only visible rows that are pinned
245
+ (pinnedRowIds ?? []).map(
246
+ rowId => visibleRows.find(row => row.id === rowId)!
247
+ )
248
+
249
+ return rows
250
+ .filter(Boolean)
251
+ .map(d => ({ ...d, position })) as Row<TData>[]
252
+ },
253
+ getMemoOptions(table.options, 'debugRows', '_getPinnedRows')
254
+ )
255
+
256
+ table.getTopRows = () => table._getPinnedRows('top')
257
+
258
+ table.getBottomRows = () => table._getPinnedRows('bottom')
259
+
260
+ table.getCenterRows = memo(
261
+ () => [
262
+ table.getRowModel().rows,
263
+ table.getState().rowPinning.top,
264
+ table.getState().rowPinning.bottom,
265
+ ],
266
+ (allRows, top, bottom) => {
267
+ const topAndBottom = new Set([...(top ?? []), ...(bottom ?? [])])
268
+ return allRows.filter(d => !topAndBottom.has(d.id))
269
+ },
270
+ getMemoOptions(table.options, 'debugRows', 'getCenterRows')
271
+ )
272
+ },
273
+ }
@@ -1,5 +1,12 @@
1
- import { TableFeature } from '../core/table'
2
- import { OnChangeFn, Table, Row, RowModel, Updater, RowData } from '../types'
1
+ import {
2
+ OnChangeFn,
3
+ Table,
4
+ Row,
5
+ RowModel,
6
+ Updater,
7
+ RowData,
8
+ TableFeature,
9
+ } from '../types'
3
10
  import { getMemoOptions, makeStateUpdater, memo } from '../utils'
4
11
 
5
12
  export type RowSelectionState = Record<string, boolean>
@@ -1,5 +1,4 @@
1
1
  import { RowModel } from '..'
2
- import { TableFeature } from '../core/table'
3
2
  import {
4
3
  BuiltInSortingFn,
5
4
  reSplitAlphaNumeric,
@@ -14,6 +13,7 @@ import {
14
13
  Updater,
15
14
  RowData,
16
15
  SortingFns,
16
+ TableFeature,
17
17
  } from '../types'
18
18
 
19
19
  import { isFunction, makeStateUpdater } from '../utils'
@@ -80,12 +80,15 @@ export interface SortingColumnDef<TData extends RowData> {
80
80
  */
81
81
  sortingFn?: SortingFnOption<TData>
82
82
  /**
83
+ * The priority of undefined values when sorting this column.
83
84
  * - `false`
84
85
  * - Undefined values will be considered tied and need to be sorted by the next column filter or original index (whichever applies)
85
86
  * - `-1`
86
87
  * - Undefined values will be sorted with higher priority (ascending) (if ascending, undefined will appear on the beginning of the list)
87
88
  * - `1`
88
89
  * - Undefined values will be sorted with lower priority (descending) (if ascending, undefined will appear on the end of the list)
90
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortundefined)
91
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)
89
92
  */
90
93
  sortUndefined?: false | -1 | 1
91
94
  }
@@ -272,7 +275,7 @@ export interface SortingInstance<TData extends RowData> {
272
275
 
273
276
  //
274
277
 
275
- export const Sorting: TableFeature = {
278
+ export const RowSorting: TableFeature = {
276
279
  getInitialState: (state): SortingTableState => {
277
280
  return {
278
281
  sorting: [],
package/src/filterFns.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FilterFn } from './features/Filters'
1
+ import { FilterFn } from './features/ColumnFiltering'
2
2
 
3
3
  const includesString: FilterFn<any> = (
4
4
  row,
package/src/index.ts CHANGED
@@ -1,30 +1,42 @@
1
- export * from './core/table'
1
+ //types
2
+ export * from './columnHelper'
2
3
  export * from './types'
4
+
5
+ //core
6
+ export * from './core/cell'
3
7
  export * from './core/column'
4
8
  export * from './core/headers'
5
9
  export * from './core/row'
6
- export * from './core/cell'
10
+ export * from './core/table'
11
+
12
+ //features
13
+ export * from './features/ColumnFaceting'
14
+ export * from './features/ColumnFiltering'
15
+ export * from './features/ColumnGrouping'
16
+ export * from './features/ColumnOrdering'
17
+ export * from './features/ColumnPinning'
7
18
  export * from './features/ColumnSizing'
8
- export * from './features/Expanding'
9
- export * from './features/Filters'
10
- export * from './features/Grouping'
11
- export * from './features/Ordering'
12
- export * from './features/Pagination'
13
- export * from './features/Pinning'
19
+ export * from './features/ColumnVisibility'
20
+ export * from './features/GlobalFiltering'
21
+ export * from './features/RowExpanding'
22
+ export * from './features/RowPagination'
23
+ export * from './features/RowPinning'
14
24
  export * from './features/RowSelection'
15
- export * from './features/Sorting'
16
- export * from './features/Visibility'
17
- export * from './filterFns'
18
- export * from './sortingFns'
19
- export * from './aggregationFns'
20
- export * from './columnHelper'
25
+ export * from './features/RowSorting'
26
+
27
+ //utils
21
28
  export * from './utils'
22
29
  export * from './utils/getCoreRowModel'
23
- export * from './utils/getFilteredRowModel'
30
+ export * from './utils/getExpandedRowModel'
31
+ export * from './utils/getFacetedMinMaxValues'
24
32
  export * from './utils/getFacetedRowModel'
25
33
  export * from './utils/getFacetedUniqueValues'
26
- export * from './utils/getFacetedMinMaxValues'
27
- export * from './utils/getSortedRowModel'
34
+ export * from './utils/getFilteredRowModel'
28
35
  export * from './utils/getGroupedRowModel'
29
- export * from './utils/getExpandedRowModel'
30
36
  export * from './utils/getPaginationRowModel'
37
+ export * from './utils/getSortedRowModel'
38
+
39
+ //fns
40
+ export * from './aggregationFns'
41
+ export * from './filterFns'
42
+ export * from './sortingFns'
package/src/sortingFns.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SortingFn } from './features/Sorting'
1
+ import { SortingFn } from './features/RowSorting'
2
2
 
3
3
  export const reSplitAlphaNumeric = /([0-9]+)/gm
4
4
 
package/src/types.ts CHANGED
@@ -6,13 +6,13 @@ import {
6
6
  VisibilityOptions,
7
7
  VisibilityColumnDef,
8
8
  VisibilityRow,
9
- } from './features/Visibility'
9
+ } from './features/ColumnVisibility'
10
10
  import {
11
11
  ColumnOrderColumn,
12
12
  ColumnOrderInstance,
13
13
  ColumnOrderOptions,
14
14
  ColumnOrderTableState,
15
- } from './features/Ordering'
15
+ } from './features/ColumnOrdering'
16
16
  import {
17
17
  ColumnPinningColumn,
18
18
  ColumnPinningColumnDef,
@@ -20,32 +20,42 @@ import {
20
20
  ColumnPinningOptions,
21
21
  ColumnPinningRow,
22
22
  ColumnPinningTableState,
23
+ } from './features/ColumnPinning'
24
+ import {
23
25
  RowPinningInstance,
24
26
  RowPinningOptions,
25
27
  RowPinningRow,
26
28
  RowPinningTableState,
27
- } from './features/Pinning'
29
+ } from './features/RowPinning'
28
30
  import {
29
31
  CoreHeader,
30
32
  CoreHeaderGroup,
31
33
  HeaderContext,
32
34
  HeadersInstance,
33
35
  } from './core/headers'
36
+ import { FacetedColumn, FacetedOptions } from './features/ColumnFaceting'
37
+ import {
38
+ ColumnFiltersColumn,
39
+ ColumnFiltersColumnDef,
40
+ ColumnFiltersInstance,
41
+ ColumnFiltersOptions,
42
+ ColumnFiltersRow,
43
+ ColumnFiltersTableState,
44
+ } from './features/ColumnFiltering'
34
45
  import {
35
- FiltersColumn,
36
- FiltersColumnDef,
37
- FiltersInstance,
38
- FiltersOptions,
39
- FiltersRow,
40
- FiltersTableState,
41
- } from './features/Filters'
46
+ GlobalFilterColumn,
47
+ GlobalFilterColumnDef,
48
+ GlobalFilterInstance,
49
+ GlobalFilterOptions,
50
+ GlobalFilterTableState,
51
+ } from './features/GlobalFiltering'
42
52
  import {
43
53
  SortingColumn,
44
54
  SortingColumnDef,
45
55
  SortingInstance,
46
56
  SortingOptions,
47
57
  SortingTableState,
48
- } from './features/Sorting'
58
+ } from './features/RowSorting'
49
59
  import {
50
60
  GroupingCell,
51
61
  GroupingColumn,
@@ -54,13 +64,13 @@ import {
54
64
  GroupingOptions,
55
65
  GroupingRow,
56
66
  GroupingTableState,
57
- } from './features/Grouping'
67
+ } from './features/ColumnGrouping'
58
68
  import {
59
69
  ExpandedInstance,
60
70
  ExpandedOptions,
61
71
  ExpandedTableState,
62
72
  ExpandedRow,
63
- } from './features/Expanding'
73
+ } from './features/RowExpanding'
64
74
  import {
65
75
  ColumnSizingColumn,
66
76
  ColumnSizingColumnDef,
@@ -74,7 +84,7 @@ import {
74
84
  PaginationInstance,
75
85
  PaginationOptions,
76
86
  PaginationTableState,
77
- } from './features/Pagination'
87
+ } from './features/RowPagination'
78
88
  import {
79
89
  RowSelectionInstance,
80
90
  RowSelectionOptions,
@@ -86,6 +96,24 @@ import { PartialKeys, UnionToIntersection } from './utils'
86
96
  import { CellContext, CoreCell } from './core/cell'
87
97
  import { CoreColumn } from './core/column'
88
98
 
99
+ export interface TableFeature<TData extends RowData = any> {
100
+ createCell?: (
101
+ cell: Cell<TData, unknown>,
102
+ column: Column<TData>,
103
+ row: Row<TData>,
104
+ table: Table<TData>
105
+ ) => void
106
+ createColumn?: (column: Column<TData, unknown>, table: Table<TData>) => void
107
+ createHeader?: (header: Header<TData, unknown>, table: Table<TData>) => void
108
+ createRow?: (row: Row<TData>, table: Table<TData>) => void
109
+ createTable?: (table: Table<TData>) => void
110
+ getDefaultColumnDef?: () => Partial<ColumnDef<TData, unknown>>
111
+ getDefaultOptions?: (
112
+ table: Table<TData>
113
+ ) => Partial<TableOptionsResolved<TData>>
114
+ getInitialState?: (initialState?: InitialTableState) => Partial<TableState>
115
+ }
116
+
89
117
  export interface TableMeta<TData extends RowData> {}
90
118
 
91
119
  export interface ColumnMeta<TData extends RowData, TValue> {}
@@ -112,7 +140,8 @@ export interface Table<TData extends RowData>
112
140
  ColumnOrderInstance<TData>,
113
141
  ColumnPinningInstance<TData>,
114
142
  RowPinningInstance<TData>,
115
- FiltersInstance<TData>,
143
+ ColumnFiltersInstance<TData>,
144
+ GlobalFilterInstance<TData>,
116
145
  SortingInstance<TData>,
117
146
  GroupingInstance<TData>,
118
147
  ColumnSizingInstance,
@@ -125,7 +154,9 @@ interface FeatureOptions<TData extends RowData>
125
154
  ColumnOrderOptions,
126
155
  ColumnPinningOptions,
127
156
  RowPinningOptions<TData>,
128
- FiltersOptions<TData>,
157
+ FacetedOptions<TData>,
158
+ ColumnFiltersOptions<TData>,
159
+ GlobalFilterOptions<TData>,
129
160
  SortingOptions<TData>,
130
161
  GroupingOptions,
131
162
  ExpandedOptions<TData>,
@@ -133,8 +164,9 @@ interface FeatureOptions<TData extends RowData>
133
164
  PaginationOptions,
134
165
  RowSelectionOptions<TData> {}
135
166
 
136
- export type TableOptionsResolved<TData extends RowData> = CoreOptions<TData> &
137
- FeatureOptions<TData>
167
+ export interface TableOptionsResolved<TData extends RowData>
168
+ extends CoreOptions<TData>,
169
+ FeatureOptions<TData> {}
138
170
 
139
171
  export interface TableOptions<TData extends RowData>
140
172
  extends PartialKeys<
@@ -148,7 +180,8 @@ export interface TableState
148
180
  ColumnOrderTableState,
149
181
  ColumnPinningTableState,
150
182
  RowPinningTableState,
151
- FiltersTableState,
183
+ ColumnFiltersTableState,
184
+ GlobalFilterTableState,
152
185
  SortingTableState,
153
186
  ExpandedTableState,
154
187
  GroupingTableState,
@@ -162,7 +195,8 @@ interface CompleteInitialTableState
162
195
  ColumnOrderTableState,
163
196
  ColumnPinningTableState,
164
197
  RowPinningTableState,
165
- FiltersTableState,
198
+ ColumnFiltersTableState,
199
+ GlobalFilterTableState,
166
200
  SortingTableState,
167
201
  ExpandedTableState,
168
202
  GroupingTableState,
@@ -177,7 +211,7 @@ export interface Row<TData extends RowData>
177
211
  VisibilityRow<TData>,
178
212
  ColumnPinningRow<TData>,
179
213
  RowPinningRow,
180
- FiltersRow<TData>,
214
+ ColumnFiltersRow<TData>,
181
215
  GroupingRow,
182
216
  RowSelectionRow,
183
217
  ExpandedRow {}
@@ -220,7 +254,8 @@ type ColumnIdentifiers<TData extends RowData, TValue> =
220
254
  interface ColumnDefExtensions<TData extends RowData, TValue = unknown>
221
255
  extends VisibilityColumnDef,
222
256
  ColumnPinningColumnDef,
223
- FiltersColumnDef<TData>,
257
+ ColumnFiltersColumnDef<TData>,
258
+ GlobalFilterColumnDef,
224
259
  SortingColumnDef<TData>,
225
260
  GroupingColumnDef<TData, TValue>,
226
261
  ColumnSizingColumnDef {}
@@ -302,7 +337,9 @@ export interface Column<TData extends RowData, TValue = unknown>
302
337
  extends CoreColumn<TData, TValue>,
303
338
  ColumnVisibilityColumn,
304
339
  ColumnPinningColumn,
305
- FiltersColumn<TData>,
340
+ FacetedColumn<TData>,
341
+ ColumnFiltersColumn<TData>,
342
+ GlobalFilterColumn,
306
343
  SortingColumn<TData>,
307
344
  GroupingColumn<TData>,
308
345
  ColumnSizingColumn,
@@ -1,4 +1,4 @@
1
- import { ResolvedColumnFilter } from '../features/Filters'
1
+ import { ResolvedColumnFilter } from '../features/ColumnFiltering'
2
2
  import { Table, RowModel, Row, RowData } from '../types'
3
3
  import { getMemoOptions, memo } from '../utils'
4
4
  import { filterRows } from './filterRowsUtils'
@@ -1,5 +1,5 @@
1
1
  import { Table, Row, RowModel, RowData } from '../types'
2
- import { SortingFn } from '../features/Sorting'
2
+ import { SortingFn } from '../features/RowSorting'
3
3
  import { getMemoOptions, memo } from '../utils'
4
4
 
5
5
  export function getSortedRowModel<TData extends RowData>(): (
package/src/utils.ts CHANGED
@@ -47,17 +47,15 @@ export type DeepKeys<T, TDepth extends any[] = []> = TDepth['length'] extends 5
47
47
  ? never
48
48
  : unknown extends T
49
49
  ? string
50
- : object extends T
51
- ? string
52
- : T extends readonly any[] & IsTuple<T>
53
- ? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>, TDepth>
54
- : T extends any[]
55
- ? DeepKeys<T[number], [...TDepth, any]>
56
- : T extends Date
57
- ? never
58
- : T extends object
59
- ? (keyof T & string) | DeepKeysPrefix<T, keyof T, TDepth>
60
- : never
50
+ : T extends readonly any[] & IsTuple<T>
51
+ ? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>, TDepth>
52
+ : T extends any[]
53
+ ? DeepKeys<T[number], [...TDepth, any]>
54
+ : T extends Date
55
+ ? never
56
+ : T extends object
57
+ ? (keyof T & string) | DeepKeysPrefix<T, keyof T, TDepth>
58
+ : never
61
59
 
62
60
  type DeepKeysPrefix<
63
61
  T,