@tanstack/table-core 8.13.2 → 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.
- 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.js.map +1 -1
- package/build/lib/core/table.d.ts +7 -11
- package/build/lib/core/table.js +21 -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/{Filters.d.ts → ColumnFiltering.d.ts} +29 -132
- 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/GlobalFiltering.d.ts +100 -0
- package/build/lib/features/GlobalFiltering.js +85 -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 +21 -18
- package/build/lib/index.esm.js +1490 -1446
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +47 -41
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +1490 -1446
- 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 +30 -16
- package/build/lib/utils/getFilteredRowModel.js.map +1 -1
- package/build/lib/utils/getSortedRowModel.js.map +1 -1
- package/build/umd/index.development.js +1500 -1453
- 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 +40 -32
- package/src/features/ColumnFaceting.ts +84 -0
- package/src/features/{Filters.ts → ColumnFiltering.ts} +44 -279
- 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/GlobalFiltering.ts +218 -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 +30 -18
- package/src/sortingFns.ts +1 -1
- package/src/types.ts +60 -23
- 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.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/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,42 @@
|
|
|
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/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/
|
|
16
|
-
|
|
17
|
-
|
|
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/
|
|
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/
|
|
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
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,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/
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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/
|
|
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/
|
|
67
|
+
} from './features/ColumnGrouping'
|
|
58
68
|
import {
|
|
59
69
|
ExpandedInstance,
|
|
60
70
|
ExpandedOptions,
|
|
61
71
|
ExpandedTableState,
|
|
62
72
|
ExpandedRow,
|
|
63
|
-
} from './features/
|
|
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/
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
137
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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/
|
|
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>(): (
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Expanding.js","sources":["../../../src/features/Expanding.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { TableFeature } from '../core/table'\nimport { OnChangeFn, Table, Row, Updater, RowData } from '../types'\nimport { makeStateUpdater } from '../utils'\n\nexport type ExpandedStateList = Record<string, boolean>\nexport type ExpandedState = true | Record<string, boolean>\nexport interface ExpandedTableState {\n expanded: ExpandedState\n}\n\nexport interface ExpandedRow {\n /**\n * Returns whether the row can be expanded.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getcanexpand)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getCanExpand: () => boolean\n /**\n * Returns whether all parent rows of the row are expanded.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getisallparentsexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getIsAllParentsExpanded: () => boolean\n /**\n * Returns whether the row is expanded.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getisexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getIsExpanded: () => boolean\n /**\n * Returns a function that can be used to toggle the expanded state of the row. This function can be used to bind to an event handler to a button.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#gettoggleexpandedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getToggleExpandedHandler: () => () => void\n /**\n * Toggles the expanded state (or sets it if `expanded` is provided) for the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#toggleexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n toggleExpanded: (expanded?: boolean) => void\n}\n\nexport interface ExpandedOptions<TData extends RowData> {\n /**\n * Enable this setting to automatically reset the expanded state of the table when expanding state changes.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#autoresetexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n autoResetExpanded?: boolean\n /**\n * Enable/disable expanding for all rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#enableexpanding)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n enableExpanding?: boolean\n /**\n * This function is responsible for returning the expanded row model. If this function is not provided, the table will not expand rows. You can use the default exported `getExpandedRowModel` function to get the expanded row model or implement your own.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getexpandedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getExpandedRowModel?: (table: Table<any>) => () => RowModel<any>\n /**\n * If provided, allows you to override the default behavior of determining whether a row is currently expanded.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getisrowexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getIsRowExpanded?: (row: Row<TData>) => boolean\n /**\n * If provided, allows you to override the default behavior of determining whether a row can be expanded.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getrowcanexpand)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getRowCanExpand?: (row: Row<TData>) => boolean\n /**\n * Enables manual row expansion. If this is set to `true`, `getExpandedRowModel` will not be used to expand rows and you would be expected to perform the expansion in your own data model. This is useful if you are doing server-side expansion.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#manualexpanding)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n manualExpanding?: boolean\n /**\n * This function is called when the `expanded` table state changes. If a function is provided, you will be responsible for managing this state on your own. To pass the managed state back to the table, use the `tableOptions.state.expanded` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#onexpandedchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n onExpandedChange?: OnChangeFn<ExpandedState>\n /**\n * If `true` expanded rows will be paginated along with the rest of the table (which means expanded rows may span multiple pages). If `false` expanded rows will not be considered for pagination (which means expanded rows will always render on their parents page. This also means more rows will be rendered than the set page size)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#paginateexpandedrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n paginateExpandedRows?: boolean\n}\n\nexport interface ExpandedInstance<TData extends RowData> {\n _autoResetExpanded: () => void\n _getExpandedRowModel?: () => RowModel<TData>\n /**\n * Returns whether there are any rows that can be expanded.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getcansomerowsexpand)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getCanSomeRowsExpand: () => boolean\n /**\n * Returns the maximum depth of the expanded rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getexpandeddepth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getExpandedDepth: () => number\n /**\n * Returns the row model after expansion has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getexpandedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getExpandedRowModel: () => RowModel<TData>\n /**\n * Returns whether all rows are currently expanded.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getisallrowsexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getIsAllRowsExpanded: () => boolean\n /**\n * Returns whether there are any rows that are currently expanded.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getissomerowsexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getIsSomeRowsExpanded: () => boolean\n /**\n * Returns the row model before expansion has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#getpreexpandedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getPreExpandedRowModel: () => RowModel<TData>\n /**\n * Returns a handler that can be used to toggle the expanded state of all rows. This handler is meant to be used with an `input[type=checkbox]` element.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#gettoggleallrowsexpandedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n getToggleAllRowsExpandedHandler: () => (event: unknown) => void\n /**\n * Resets the expanded state of the table to the initial state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#resetexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n resetExpanded: (defaultState?: boolean) => void\n /**\n * Updates the expanded state of the table via an update function or value.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#setexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n setExpanded: (updater: Updater<ExpandedState>) => void\n /**\n * Toggles the expanded state for all rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/expanding#toggleallrowsexpanded)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/expanding)\n */\n toggleAllRowsExpanded: (expanded?: boolean) => void\n}\n\n//\n\nexport const Expanding: TableFeature = {\n getInitialState: (state): ExpandedTableState => {\n return {\n expanded: {},\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): ExpandedOptions<TData> => {\n return {\n onExpandedChange: makeStateUpdater('expanded', table),\n paginateExpandedRows: true,\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n let registered = false\n let queued = false\n\n table._autoResetExpanded = () => {\n if (!registered) {\n table._queue(() => {\n registered = true\n })\n return\n }\n\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n if (queued) return\n queued = true\n table._queue(() => {\n table.resetExpanded()\n queued = false\n })\n }\n }\n table.setExpanded = updater => table.options.onExpandedChange?.(updater)\n table.toggleAllRowsExpanded = expanded => {\n if (expanded ?? !table.getIsAllRowsExpanded()) {\n table.setExpanded(true)\n } else {\n table.setExpanded({})\n }\n }\n table.resetExpanded = defaultState => {\n table.setExpanded(defaultState ? {} : table.initialState?.expanded ?? {})\n }\n table.getCanSomeRowsExpand = () => {\n return table\n .getPrePaginationRowModel()\n .flatRows.some(row => row.getCanExpand())\n }\n table.getToggleAllRowsExpandedHandler = () => {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table.toggleAllRowsExpanded()\n }\n }\n table.getIsSomeRowsExpanded = () => {\n const expanded = table.getState().expanded\n return expanded === true || Object.values(expanded).some(Boolean)\n }\n table.getIsAllRowsExpanded = () => {\n const expanded = table.getState().expanded\n\n // If expanded is true, save some cycles and return true\n if (typeof expanded === 'boolean') {\n return expanded === true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n }\n table.getExpandedDepth = () => {\n let maxDepth = 0\n\n const rowIds =\n table.getState().expanded === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.getState().expanded)\n\n rowIds.forEach(id => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n }\n table.getPreExpandedRowModel = () => table.getSortedRowModel()\n table.getExpandedRowModel = () => {\n if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {\n table._getExpandedRowModel = table.options.getExpandedRowModel(table)\n }\n\n if (table.options.manualExpanding || !table._getExpandedRowModel) {\n return table.getPreExpandedRowModel()\n }\n\n return table._getExpandedRowModel()\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.toggleExpanded = expanded => {\n table.setExpanded(old => {\n const exists = old === true ? true : !!old?.[row.id]\n\n let oldExpanded: ExpandedStateList = {}\n\n if (old === true) {\n Object.keys(table.getRowModel().rowsById).forEach(rowId => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = old\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n return {\n ...oldExpanded,\n [row.id]: true,\n }\n }\n\n if (exists && !expanded) {\n const { [row.id]: _, ...rest } = oldExpanded\n return rest\n }\n\n return old\n })\n }\n row.getIsExpanded = () => {\n const expanded = table.getState().expanded\n\n return !!(\n table.options.getIsRowExpanded?.(row) ??\n (expanded === true || expanded?.[row.id])\n )\n }\n row.getCanExpand = () => {\n return (\n table.options.getRowCanExpand?.(row) ??\n ((table.options.enableExpanding ?? true) && !!row.subRows?.length)\n )\n }\n row.getIsAllParentsExpanded = () => {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = table.getRow(currentRow.parentId, true)\n isFullyExpanded = currentRow.getIsExpanded()\n }\n\n return isFullyExpanded\n }\n row.getToggleExpandedHandler = () => {\n const canExpand = row.getCanExpand()\n\n return () => {\n if (!canExpand) return\n row.toggleExpanded()\n }\n }\n },\n}\n"],"names":["Expanding","getInitialState","state","expanded","getDefaultOptions","table","onExpandedChange","makeStateUpdater","paginateExpandedRows","createTable","registered","queued","_autoResetExpanded","_ref","_table$options$autoRe","_queue","options","autoResetAll","autoResetExpanded","manualExpanding","resetExpanded","setExpanded","updater","toggleAllRowsExpanded","getIsAllRowsExpanded","defaultState","_table$initialState$e","_table$initialState","initialState","getCanSomeRowsExpand","getPrePaginationRowModel","flatRows","some","row","getCanExpand","getToggleAllRowsExpandedHandler","e","persist","getIsSomeRowsExpanded","getState","Object","values","Boolean","keys","length","getRowModel","getIsExpanded","getExpandedDepth","maxDepth","rowIds","rowsById","forEach","id","splitId","split","Math","max","getPreExpandedRowModel","getSortedRowModel","getExpandedRowModel","_getExpandedRowModel","createRow","toggleExpanded","old","_expanded","exists","oldExpanded","rowId","_","rest","_table$options$getIsR","getIsRowExpanded","_table$options$getRow","_table$options$enable","_row$subRows","getRowCanExpand","enableExpanding","subRows","getIsAllParentsExpanded","isFullyExpanded","currentRow","parentId","getRow","getToggleExpandedHandler","canExpand"],"mappings":";;;;;;;;;;;;;;AAgKA;;AAEO,MAAMA,SAAuB,GAAG;EACrCC,eAAe,EAAGC,KAAK,IAAyB;IAC9C,OAAO;MACLC,QAAQ,EAAE,EAAE;MACZ,GAAGD,KAAAA;KACJ,CAAA;GACF;EAEDE,iBAAiB,EACfC,KAAmB,IACQ;IAC3B,OAAO;AACLC,MAAAA,gBAAgB,EAAEC,sBAAgB,CAAC,UAAU,EAAEF,KAAK,CAAC;AACrDG,MAAAA,oBAAoB,EAAE,IAAA;KACvB,CAAA;GACF;EAEDC,WAAW,EAA0BJ,KAAmB,IAAW;IACjE,IAAIK,UAAU,GAAG,KAAK,CAAA;IACtB,IAAIC,MAAM,GAAG,KAAK,CAAA;IAElBN,KAAK,CAACO,kBAAkB,GAAG,MAAM;MAAA,IAAAC,IAAA,EAAAC,qBAAA,CAAA;MAC/B,IAAI,CAACJ,UAAU,EAAE;QACfL,KAAK,CAACU,MAAM,CAAC,MAAM;AACjBL,UAAAA,UAAU,GAAG,IAAI,CAAA;AACnB,SAAC,CAAC,CAAA;AACF,QAAA,OAAA;AACF,OAAA;MAEA,IAAAG,CAAAA,IAAA,GAAAC,CAAAA,qBAAA,GACET,KAAK,CAACW,OAAO,CAACC,YAAY,KAAAH,IAAAA,GAAAA,qBAAA,GAC1BT,KAAK,CAACW,OAAO,CAACE,iBAAiB,KAAA,IAAA,GAAAL,IAAA,GAC/B,CAACR,KAAK,CAACW,OAAO,CAACG,eAAe,EAC9B;AACA,QAAA,IAAIR,MAAM,EAAE,OAAA;AACZA,QAAAA,MAAM,GAAG,IAAI,CAAA;QACbN,KAAK,CAACU,MAAM,CAAC,MAAM;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