@tanstack/table-core 8.13.2 → 8.15.1
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.
- package/build/lib/aggregationFns.d.ts +1 -1
- package/build/lib/aggregationFns.js.map +1 -1
- package/build/lib/core/column.js +1 -1
- package/build/lib/core/column.js.map +1 -1
- package/build/lib/core/headers.d.ts +1 -2
- package/build/lib/core/headers.js.map +1 -1
- package/build/lib/core/row.d.ts +1 -1
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/core/table.d.ts +7 -11
- package/build/lib/core/table.js +24 -13
- package/build/lib/core/table.js.map +1 -1
- package/build/lib/features/ColumnFaceting.d.ts +34 -0
- package/build/lib/features/ColumnFaceting.js +42 -0
- package/build/lib/features/ColumnFaceting.js.map +1 -0
- package/build/lib/features/ColumnFiltering.d.ts +194 -0
- package/build/lib/features/{Filters.js → ColumnFiltering.js} +8 -83
- package/build/lib/features/ColumnFiltering.js.map +1 -0
- package/build/lib/features/{Grouping.d.ts → ColumnGrouping.d.ts} +2 -3
- package/build/lib/features/{Grouping.js → ColumnGrouping.js} +3 -3
- package/build/lib/features/ColumnGrouping.js.map +1 -0
- package/build/lib/features/{Ordering.d.ts → ColumnOrdering.d.ts} +2 -3
- package/build/lib/features/{Ordering.js → ColumnOrdering.js} +9 -9
- package/build/lib/features/ColumnOrdering.js.map +1 -0
- package/build/lib/features/ColumnPinning.d.ts +126 -0
- package/build/lib/features/{Pinning.js → ColumnPinning.js} +4 -115
- package/build/lib/features/ColumnPinning.js.map +1 -0
- package/build/lib/features/ColumnSizing.d.ts +2 -3
- package/build/lib/features/ColumnSizing.js +3 -3
- package/build/lib/features/ColumnSizing.js.map +1 -1
- package/build/lib/features/{Visibility.d.ts → ColumnVisibility.d.ts} +2 -3
- package/build/lib/features/{Visibility.js → ColumnVisibility.js} +3 -3
- package/build/lib/features/ColumnVisibility.js.map +1 -0
- package/build/lib/features/GlobalFaceting.d.ts +26 -0
- package/build/lib/features/GlobalFaceting.js +42 -0
- package/build/lib/features/GlobalFaceting.js.map +1 -0
- package/build/lib/features/GlobalFiltering.d.ts +79 -0
- package/build/lib/features/GlobalFiltering.js +63 -0
- package/build/lib/features/GlobalFiltering.js.map +1 -0
- package/build/lib/features/{Expanding.d.ts → RowExpanding.d.ts} +2 -3
- package/build/lib/features/{Expanding.js → RowExpanding.js} +3 -3
- package/build/lib/features/RowExpanding.js.map +1 -0
- package/build/lib/features/{Pagination.d.ts → RowPagination.d.ts} +2 -3
- package/build/lib/features/{Pagination.js → RowPagination.js} +3 -3
- package/build/lib/features/RowPagination.js.map +1 -0
- package/build/lib/features/RowPinning.d.ts +98 -0
- package/build/lib/features/RowPinning.js +145 -0
- package/build/lib/features/RowPinning.js.map +1 -0
- package/build/lib/features/RowSelection.d.ts +1 -2
- package/build/lib/features/RowSelection.js.map +1 -1
- package/build/lib/features/{Sorting.d.ts → RowSorting.d.ts} +5 -3
- package/build/lib/features/{Sorting.js → RowSorting.js} +3 -3
- package/build/lib/features/RowSorting.js.map +1 -0
- package/build/lib/filterFns.d.ts +1 -1
- package/build/lib/filterFns.js.map +1 -1
- package/build/lib/index.d.ts +22 -18
- package/build/lib/index.esm.js +1509 -1457
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +49 -41
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +1509 -1457
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/sortingFns.d.ts +1 -1
- package/build/lib/sortingFns.js.map +1 -1
- package/build/lib/types.d.ts +32 -17
- package/build/lib/utils/getFilteredRowModel.js.map +1 -1
- package/build/lib/utils/getSortedRowModel.js.map +1 -1
- package/build/umd/index.development.js +1520 -1464
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/aggregationFns.ts +1 -1
- package/src/core/column.ts +2 -2
- package/src/core/headers.ts +9 -3
- package/src/core/row.ts +1 -1
- package/src/core/table.ts +42 -32
- package/src/features/ColumnFaceting.ts +84 -0
- package/src/features/ColumnFiltering.ts +429 -0
- package/src/features/{Grouping.ts → ColumnGrouping.ts} +6 -6
- package/src/features/{Ordering.ts → ColumnOrdering.ts} +11 -5
- package/src/features/ColumnPinning.ts +336 -0
- package/src/features/ColumnSizing.ts +10 -3
- package/src/features/{Visibility.ts → ColumnVisibility.ts} +2 -2
- package/src/features/GlobalFaceting.ts +66 -0
- package/src/features/GlobalFiltering.ts +162 -0
- package/src/features/{Expanding.ts → RowExpanding.ts} +9 -3
- package/src/features/{Pagination.ts → RowPagination.ts} +9 -3
- package/src/features/RowPinning.ts +273 -0
- package/src/features/RowSelection.ts +9 -2
- package/src/features/{Sorting.ts → RowSorting.ts} +5 -2
- package/src/filterFns.ts +1 -1
- package/src/index.ts +31 -18
- package/src/sortingFns.ts +1 -1
- package/src/types.ts +66 -25
- package/src/utils/getFilteredRowModel.ts +1 -1
- package/src/utils/getSortedRowModel.ts +1 -1
- package/build/lib/features/Expanding.js.map +0 -1
- package/build/lib/features/Filters.d.ts +0 -297
- package/build/lib/features/Filters.js.map +0 -1
- package/build/lib/features/Grouping.js.map +0 -1
- package/build/lib/features/Ordering.js.map +0 -1
- package/build/lib/features/Pagination.js.map +0 -1
- package/build/lib/features/Pinning.d.ts +0 -222
- package/build/lib/features/Pinning.js.map +0 -1
- package/build/lib/features/Sorting.js.map +0 -1
- package/build/lib/features/Visibility.js.map +0 -1
- package/src/features/Filters.ts +0 -664
- 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 {
|
|
2
|
-
|
|
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
|
|
278
|
+
export const RowSorting: TableFeature = {
|
|
276
279
|
getInitialState: (state): SortingTableState => {
|
|
277
280
|
return {
|
|
278
281
|
sorting: [],
|
package/src/filterFns.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
|
|
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/
|
|
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/
|
|
9
|
-
export * from './features/
|
|
10
|
-
export * from './features/
|
|
11
|
-
export * from './features/
|
|
12
|
-
export * from './features/
|
|
13
|
-
export * from './features/
|
|
19
|
+
export * from './features/ColumnVisibility'
|
|
20
|
+
export * from './features/GlobalFaceting'
|
|
21
|
+
export * from './features/GlobalFiltering'
|
|
22
|
+
export * from './features/RowExpanding'
|
|
23
|
+
export * from './features/RowPagination'
|
|
24
|
+
export * from './features/RowPinning'
|
|
14
25
|
export * from './features/RowSelection'
|
|
15
|
-
export * from './features/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export * from './sortingFns'
|
|
19
|
-
export * from './aggregationFns'
|
|
20
|
-
export * from './columnHelper'
|
|
26
|
+
export * from './features/RowSorting'
|
|
27
|
+
|
|
28
|
+
//utils
|
|
21
29
|
export * from './utils'
|
|
22
30
|
export * from './utils/getCoreRowModel'
|
|
23
|
-
export * from './utils/
|
|
31
|
+
export * from './utils/getExpandedRowModel'
|
|
32
|
+
export * from './utils/getFacetedMinMaxValues'
|
|
24
33
|
export * from './utils/getFacetedRowModel'
|
|
25
34
|
export * from './utils/getFacetedUniqueValues'
|
|
26
|
-
export * from './utils/
|
|
27
|
-
export * from './utils/getSortedRowModel'
|
|
35
|
+
export * from './utils/getFilteredRowModel'
|
|
28
36
|
export * from './utils/getGroupedRowModel'
|
|
29
|
-
export * from './utils/getExpandedRowModel'
|
|
30
37
|
export * from './utils/getPaginationRowModel'
|
|
38
|
+
export * from './utils/getSortedRowModel'
|
|
39
|
+
|
|
40
|
+
//fns
|
|
41
|
+
export * from './aggregationFns'
|
|
42
|
+
export * from './filterFns'
|
|
43
|
+
export * from './sortingFns'
|
package/src/sortingFns.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
VisibilityOptions,
|
|
7
7
|
VisibilityColumnDef,
|
|
8
8
|
VisibilityRow,
|
|
9
|
-
} from './features/
|
|
9
|
+
} from './features/ColumnVisibility'
|
|
10
10
|
import {
|
|
11
11
|
ColumnOrderColumn,
|
|
12
12
|
ColumnOrderInstance,
|
|
13
13
|
ColumnOrderOptions,
|
|
14
14
|
ColumnOrderTableState,
|
|
15
|
-
} from './features/
|
|
15
|
+
} from './features/ColumnOrdering'
|
|
16
16
|
import {
|
|
17
17
|
ColumnPinningColumn,
|
|
18
18
|
ColumnPinningColumnDef,
|
|
@@ -20,32 +20,43 @@ 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/
|
|
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 { GlobalFacetingInstance } from './features/GlobalFaceting'
|
|
38
|
+
import {
|
|
39
|
+
ColumnFiltersColumn,
|
|
40
|
+
ColumnFiltersColumnDef,
|
|
41
|
+
ColumnFiltersInstance,
|
|
42
|
+
ColumnFiltersOptions,
|
|
43
|
+
ColumnFiltersRow,
|
|
44
|
+
ColumnFiltersTableState,
|
|
45
|
+
} from './features/ColumnFiltering'
|
|
34
46
|
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} from './features/Filters'
|
|
47
|
+
GlobalFilterColumn,
|
|
48
|
+
GlobalFilterColumnDef,
|
|
49
|
+
GlobalFilterInstance,
|
|
50
|
+
GlobalFilterOptions,
|
|
51
|
+
GlobalFilterTableState,
|
|
52
|
+
} from './features/GlobalFiltering'
|
|
42
53
|
import {
|
|
43
54
|
SortingColumn,
|
|
44
55
|
SortingColumnDef,
|
|
45
56
|
SortingInstance,
|
|
46
57
|
SortingOptions,
|
|
47
58
|
SortingTableState,
|
|
48
|
-
} from './features/
|
|
59
|
+
} from './features/RowSorting'
|
|
49
60
|
import {
|
|
50
61
|
GroupingCell,
|
|
51
62
|
GroupingColumn,
|
|
@@ -54,13 +65,13 @@ import {
|
|
|
54
65
|
GroupingOptions,
|
|
55
66
|
GroupingRow,
|
|
56
67
|
GroupingTableState,
|
|
57
|
-
} from './features/
|
|
68
|
+
} from './features/ColumnGrouping'
|
|
58
69
|
import {
|
|
59
70
|
ExpandedInstance,
|
|
60
71
|
ExpandedOptions,
|
|
61
72
|
ExpandedTableState,
|
|
62
73
|
ExpandedRow,
|
|
63
|
-
} from './features/
|
|
74
|
+
} from './features/RowExpanding'
|
|
64
75
|
import {
|
|
65
76
|
ColumnSizingColumn,
|
|
66
77
|
ColumnSizingColumnDef,
|
|
@@ -74,7 +85,7 @@ import {
|
|
|
74
85
|
PaginationInstance,
|
|
75
86
|
PaginationOptions,
|
|
76
87
|
PaginationTableState,
|
|
77
|
-
} from './features/
|
|
88
|
+
} from './features/RowPagination'
|
|
78
89
|
import {
|
|
79
90
|
RowSelectionInstance,
|
|
80
91
|
RowSelectionOptions,
|
|
@@ -86,6 +97,24 @@ import { PartialKeys, UnionToIntersection } from './utils'
|
|
|
86
97
|
import { CellContext, CoreCell } from './core/cell'
|
|
87
98
|
import { CoreColumn } from './core/column'
|
|
88
99
|
|
|
100
|
+
export interface TableFeature<TData extends RowData = any> {
|
|
101
|
+
createCell?: (
|
|
102
|
+
cell: Cell<TData, unknown>,
|
|
103
|
+
column: Column<TData>,
|
|
104
|
+
row: Row<TData>,
|
|
105
|
+
table: Table<TData>
|
|
106
|
+
) => void
|
|
107
|
+
createColumn?: (column: Column<TData, unknown>, table: Table<TData>) => void
|
|
108
|
+
createHeader?: (header: Header<TData, unknown>, table: Table<TData>) => void
|
|
109
|
+
createRow?: (row: Row<TData>, table: Table<TData>) => void
|
|
110
|
+
createTable?: (table: Table<TData>) => void
|
|
111
|
+
getDefaultColumnDef?: () => Partial<ColumnDef<TData, unknown>>
|
|
112
|
+
getDefaultOptions?: (
|
|
113
|
+
table: Table<TData>
|
|
114
|
+
) => Partial<TableOptionsResolved<TData>>
|
|
115
|
+
getInitialState?: (initialState?: InitialTableState) => Partial<TableState>
|
|
116
|
+
}
|
|
117
|
+
|
|
89
118
|
export interface TableMeta<TData extends RowData> {}
|
|
90
119
|
|
|
91
120
|
export interface ColumnMeta<TData extends RowData, TValue> {}
|
|
@@ -112,7 +141,9 @@ export interface Table<TData extends RowData>
|
|
|
112
141
|
ColumnOrderInstance<TData>,
|
|
113
142
|
ColumnPinningInstance<TData>,
|
|
114
143
|
RowPinningInstance<TData>,
|
|
115
|
-
|
|
144
|
+
ColumnFiltersInstance<TData>,
|
|
145
|
+
GlobalFilterInstance<TData>,
|
|
146
|
+
GlobalFacetingInstance<TData>,
|
|
116
147
|
SortingInstance<TData>,
|
|
117
148
|
GroupingInstance<TData>,
|
|
118
149
|
ColumnSizingInstance,
|
|
@@ -125,7 +156,9 @@ interface FeatureOptions<TData extends RowData>
|
|
|
125
156
|
ColumnOrderOptions,
|
|
126
157
|
ColumnPinningOptions,
|
|
127
158
|
RowPinningOptions<TData>,
|
|
128
|
-
|
|
159
|
+
FacetedOptions<TData>,
|
|
160
|
+
ColumnFiltersOptions<TData>,
|
|
161
|
+
GlobalFilterOptions<TData>,
|
|
129
162
|
SortingOptions<TData>,
|
|
130
163
|
GroupingOptions,
|
|
131
164
|
ExpandedOptions<TData>,
|
|
@@ -133,8 +166,9 @@ interface FeatureOptions<TData extends RowData>
|
|
|
133
166
|
PaginationOptions,
|
|
134
167
|
RowSelectionOptions<TData> {}
|
|
135
168
|
|
|
136
|
-
export
|
|
137
|
-
|
|
169
|
+
export interface TableOptionsResolved<TData extends RowData>
|
|
170
|
+
extends CoreOptions<TData>,
|
|
171
|
+
FeatureOptions<TData> {}
|
|
138
172
|
|
|
139
173
|
export interface TableOptions<TData extends RowData>
|
|
140
174
|
extends PartialKeys<
|
|
@@ -148,7 +182,8 @@ export interface TableState
|
|
|
148
182
|
ColumnOrderTableState,
|
|
149
183
|
ColumnPinningTableState,
|
|
150
184
|
RowPinningTableState,
|
|
151
|
-
|
|
185
|
+
ColumnFiltersTableState,
|
|
186
|
+
GlobalFilterTableState,
|
|
152
187
|
SortingTableState,
|
|
153
188
|
ExpandedTableState,
|
|
154
189
|
GroupingTableState,
|
|
@@ -162,7 +197,8 @@ interface CompleteInitialTableState
|
|
|
162
197
|
ColumnOrderTableState,
|
|
163
198
|
ColumnPinningTableState,
|
|
164
199
|
RowPinningTableState,
|
|
165
|
-
|
|
200
|
+
ColumnFiltersTableState,
|
|
201
|
+
GlobalFilterTableState,
|
|
166
202
|
SortingTableState,
|
|
167
203
|
ExpandedTableState,
|
|
168
204
|
GroupingTableState,
|
|
@@ -177,7 +213,7 @@ export interface Row<TData extends RowData>
|
|
|
177
213
|
VisibilityRow<TData>,
|
|
178
214
|
ColumnPinningRow<TData>,
|
|
179
215
|
RowPinningRow,
|
|
180
|
-
|
|
216
|
+
ColumnFiltersRow<TData>,
|
|
181
217
|
GroupingRow,
|
|
182
218
|
RowSelectionRow,
|
|
183
219
|
ExpandedRow {}
|
|
@@ -220,7 +256,8 @@ type ColumnIdentifiers<TData extends RowData, TValue> =
|
|
|
220
256
|
interface ColumnDefExtensions<TData extends RowData, TValue = unknown>
|
|
221
257
|
extends VisibilityColumnDef,
|
|
222
258
|
ColumnPinningColumnDef,
|
|
223
|
-
|
|
259
|
+
ColumnFiltersColumnDef<TData>,
|
|
260
|
+
GlobalFilterColumnDef,
|
|
224
261
|
SortingColumnDef<TData>,
|
|
225
262
|
GroupingColumnDef<TData, TValue>,
|
|
226
263
|
ColumnSizingColumnDef {}
|
|
@@ -256,8 +293,10 @@ export type GroupColumnDef<
|
|
|
256
293
|
TValue = unknown,
|
|
257
294
|
> = GroupColumnDefBase<TData, TValue> & ColumnIdentifiers<TData, TValue>
|
|
258
295
|
|
|
259
|
-
interface AccessorFnColumnDefBase<
|
|
260
|
-
extends
|
|
296
|
+
export interface AccessorFnColumnDefBase<
|
|
297
|
+
TData extends RowData,
|
|
298
|
+
TValue = unknown,
|
|
299
|
+
> extends ColumnDefBase<TData, TValue> {
|
|
261
300
|
accessorFn: AccessorFn<TData, TValue>
|
|
262
301
|
}
|
|
263
302
|
|
|
@@ -302,7 +341,9 @@ export interface Column<TData extends RowData, TValue = unknown>
|
|
|
302
341
|
extends CoreColumn<TData, TValue>,
|
|
303
342
|
ColumnVisibilityColumn,
|
|
304
343
|
ColumnPinningColumn,
|
|
305
|
-
|
|
344
|
+
FacetedColumn<TData>,
|
|
345
|
+
ColumnFiltersColumn<TData>,
|
|
346
|
+
GlobalFilterColumn,
|
|
306
347
|
SortingColumn<TData>,
|
|
307
348
|
GroupingColumn<TData>,
|
|
308
349
|
ColumnSizingColumn,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedColumnFilter } from '../features/
|
|
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/
|
|
2
|
+
import { SortingFn } from '../features/RowSorting'
|
|
3
3
|
import { getMemoOptions, memo } from '../utils'
|
|
4
4
|
|
|
5
5
|
export function getSortedRowModel<TData extends RowData>(): (
|