@tanstack/table-core 8.9.3 → 8.9.8
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/core/cell.js +1 -1
- package/build/lib/core/cell.js.map +1 -1
- package/build/lib/core/column.js +3 -3
- package/build/lib/core/column.js.map +1 -1
- package/build/lib/core/headers.js +182 -181
- package/build/lib/core/headers.js.map +1 -1
- package/build/lib/core/row.js +1 -1
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/core/table.js +6 -5
- package/build/lib/core/table.js.map +1 -1
- package/build/lib/features/ColumnSizing.js +173 -179
- package/build/lib/features/ColumnSizing.js.map +1 -1
- package/build/lib/features/Expanding.js +119 -123
- package/build/lib/features/Expanding.js.map +1 -1
- package/build/lib/features/Filters.js +159 -167
- package/build/lib/features/Filters.js.map +1 -1
- package/build/lib/features/Grouping.js +72 -80
- package/build/lib/features/Grouping.js.map +1 -1
- package/build/lib/features/Ordering.js +32 -34
- package/build/lib/features/Ordering.js.map +1 -1
- package/build/lib/features/Pagination.js +112 -114
- package/build/lib/features/Pagination.js.map +1 -1
- package/build/lib/features/Pinning.js +120 -126
- package/build/lib/features/Pinning.js.map +1 -1
- package/build/lib/features/RowSelection.js +245 -247
- package/build/lib/features/RowSelection.js.map +1 -1
- package/build/lib/features/Sorting.js +163 -167
- package/build/lib/features/Sorting.js.map +1 -1
- package/build/lib/features/Visibility.js +60 -66
- package/build/lib/features/Visibility.js.map +1 -1
- package/build/lib/filterFns.js +6 -6
- package/build/lib/filterFns.js.map +1 -1
- package/build/lib/index.esm.js +1484 -1530
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +1484 -1530
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/utils/filterRowsUtils.js +3 -3
- package/build/lib/utils/filterRowsUtils.js.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +1484 -1530
- 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/core/cell.ts +5 -8
- package/src/core/column.ts +3 -3
- package/src/core/headers.ts +264 -280
- package/src/core/row.ts +1 -1
- package/src/core/table.ts +4 -3
- package/src/features/ColumnSizing.ts +220 -231
- package/src/features/Expanding.ts +132 -140
- package/src/features/Filters.ts +193 -206
- package/src/features/Grouping.ts +94 -110
- package/src/features/Ordering.ts +48 -51
- package/src/features/Pagination.ts +150 -154
- package/src/features/Pinning.ts +158 -178
- package/src/features/RowSelection.ts +280 -286
- package/src/features/Sorting.ts +196 -206
- package/src/features/Visibility.ts +98 -107
- package/src/utils/filterRowsUtils.ts +3 -3
package/src/features/Pinning.ts
CHANGED
|
@@ -82,206 +82,186 @@ export const Pinning: TableFeature = {
|
|
|
82
82
|
createColumn: <TData extends RowData, TValue>(
|
|
83
83
|
column: Column<TData, TValue>,
|
|
84
84
|
table: Table<TData>
|
|
85
|
-
):
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
right
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
],
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (position === 'left') {
|
|
105
|
-
return {
|
|
106
|
-
left: [
|
|
107
|
-
...(old?.left ?? []).filter(d => !columnIds?.includes(d)),
|
|
108
|
-
...columnIds,
|
|
109
|
-
],
|
|
110
|
-
right: (old?.right ?? []).filter(d => !columnIds?.includes(d)),
|
|
111
|
-
}
|
|
85
|
+
): void => {
|
|
86
|
+
column.pin = position => {
|
|
87
|
+
const columnIds = column
|
|
88
|
+
.getLeafColumns()
|
|
89
|
+
.map(d => d.id)
|
|
90
|
+
.filter(Boolean) as string[]
|
|
91
|
+
|
|
92
|
+
table.setColumnPinning(old => {
|
|
93
|
+
if (position === 'right') {
|
|
94
|
+
return {
|
|
95
|
+
left: (old?.left ?? []).filter(d => !columnIds?.includes(d)),
|
|
96
|
+
right: [
|
|
97
|
+
...(old?.right ?? []).filter(d => !columnIds?.includes(d)),
|
|
98
|
+
...columnIds,
|
|
99
|
+
],
|
|
112
100
|
}
|
|
101
|
+
}
|
|
113
102
|
|
|
103
|
+
if (position === 'left') {
|
|
114
104
|
return {
|
|
115
|
-
left:
|
|
105
|
+
left: [
|
|
106
|
+
...(old?.left ?? []).filter(d => !columnIds?.includes(d)),
|
|
107
|
+
...columnIds,
|
|
108
|
+
],
|
|
116
109
|
right: (old?.right ?? []).filter(d => !columnIds?.includes(d)),
|
|
117
110
|
}
|
|
118
|
-
}
|
|
119
|
-
},
|
|
111
|
+
}
|
|
120
112
|
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
return {
|
|
114
|
+
left: (old?.left ?? []).filter(d => !columnIds?.includes(d)),
|
|
115
|
+
right: (old?.right ?? []).filter(d => !columnIds?.includes(d)),
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
}
|
|
123
119
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
(d.columnDef.enablePinning ?? true) &&
|
|
127
|
-
(table.options.enablePinning ?? true)
|
|
128
|
-
)
|
|
129
|
-
},
|
|
120
|
+
column.getCanPin = () => {
|
|
121
|
+
const leafColumns = column.getLeafColumns()
|
|
130
122
|
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
return leafColumns.some(
|
|
124
|
+
d =>
|
|
125
|
+
(d.columnDef.enablePinning ?? true) &&
|
|
126
|
+
(table.options.enablePinning ?? true)
|
|
127
|
+
)
|
|
128
|
+
}
|
|
133
129
|
|
|
134
|
-
|
|
130
|
+
column.getIsPinned = () => {
|
|
131
|
+
const leafColumnIds = column.getLeafColumns().map(d => d.id)
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
const isRight = leafColumnIds.some(d => right?.includes(d))
|
|
133
|
+
const { left, right } = table.getState().columnPinning
|
|
138
134
|
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
const isLeft = leafColumnIds.some(d => left?.includes(d))
|
|
136
|
+
const isRight = leafColumnIds.some(d => right?.includes(d))
|
|
141
137
|
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
return isLeft ? 'left' : isRight ? 'right' : false
|
|
139
|
+
}
|
|
144
140
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
column.getPinnedIndex = () => {
|
|
142
|
+
const position = column.getIsPinned()
|
|
143
|
+
|
|
144
|
+
return position
|
|
145
|
+
? table.getState().columnPinning?.[position]?.indexOf(column.id) ?? -1
|
|
146
|
+
: 0
|
|
149
147
|
}
|
|
150
148
|
},
|
|
151
149
|
|
|
152
150
|
createRow: <TData extends RowData>(
|
|
153
151
|
row: Row<TData>,
|
|
154
152
|
table: Table<TData>
|
|
155
|
-
):
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
()
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
),
|
|
175
|
-
|
|
176
|
-
(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
.filter(Boolean)
|
|
205
|
-
.map(d => ({ ...d, position: 'right' } as Cell<TData, unknown>))
|
|
206
|
-
|
|
207
|
-
return cells
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
key:
|
|
211
|
-
process.env.NODE_ENV === 'production' && 'row.getRightVisibleCells',
|
|
212
|
-
debug: () => table.options.debugAll ?? table.options.debugRows,
|
|
213
|
-
}
|
|
214
|
-
),
|
|
215
|
-
}
|
|
153
|
+
): void => {
|
|
154
|
+
row.getCenterVisibleCells = memo(
|
|
155
|
+
() => [
|
|
156
|
+
row._getAllVisibleCells(),
|
|
157
|
+
table.getState().columnPinning.left,
|
|
158
|
+
table.getState().columnPinning.right,
|
|
159
|
+
],
|
|
160
|
+
(allCells, left, right) => {
|
|
161
|
+
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])]
|
|
162
|
+
|
|
163
|
+
return allCells.filter(d => !leftAndRight.includes(d.column.id))
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key:
|
|
167
|
+
process.env.NODE_ENV === 'production' && 'row.getCenterVisibleCells',
|
|
168
|
+
debug: () => table.options.debugAll ?? table.options.debugRows,
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
row.getLeftVisibleCells = memo(
|
|
172
|
+
() => [row._getAllVisibleCells(), table.getState().columnPinning.left, ,],
|
|
173
|
+
(allCells, left) => {
|
|
174
|
+
const cells = (left ?? [])
|
|
175
|
+
.map(columnId => allCells.find(cell => cell.column.id === columnId)!)
|
|
176
|
+
.filter(Boolean)
|
|
177
|
+
.map(d => ({ ...d, position: 'left' } as Cell<TData, unknown>))
|
|
178
|
+
|
|
179
|
+
return cells
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
key: process.env.NODE_ENV === 'production' && 'row.getLeftVisibleCells',
|
|
183
|
+
debug: () => table.options.debugAll ?? table.options.debugRows,
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
row.getRightVisibleCells = memo(
|
|
187
|
+
() => [row._getAllVisibleCells(), table.getState().columnPinning.right],
|
|
188
|
+
(allCells, right) => {
|
|
189
|
+
const cells = (right ?? [])
|
|
190
|
+
.map(columnId => allCells.find(cell => cell.column.id === columnId)!)
|
|
191
|
+
.filter(Boolean)
|
|
192
|
+
.map(d => ({ ...d, position: 'right' } as Cell<TData, unknown>))
|
|
193
|
+
|
|
194
|
+
return cells
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
key:
|
|
198
|
+
process.env.NODE_ENV === 'production' && 'row.getRightVisibleCells',
|
|
199
|
+
debug: () => table.options.debugAll ?? table.options.debugRows,
|
|
200
|
+
}
|
|
201
|
+
)
|
|
216
202
|
},
|
|
217
203
|
|
|
218
|
-
createTable: <TData extends RowData>(
|
|
219
|
-
table
|
|
220
|
-
|
|
221
|
-
return {
|
|
222
|
-
setColumnPinning: updater =>
|
|
223
|
-
table.options.onColumnPinningChange?.(updater),
|
|
224
|
-
|
|
225
|
-
resetColumnPinning: defaultState =>
|
|
226
|
-
table.setColumnPinning(
|
|
227
|
-
defaultState
|
|
228
|
-
? getDefaultPinningState()
|
|
229
|
-
: table.initialState?.columnPinning ?? getDefaultPinningState()
|
|
230
|
-
),
|
|
231
|
-
|
|
232
|
-
getIsSomeColumnsPinned: position => {
|
|
233
|
-
const pinningState = table.getState().columnPinning
|
|
234
|
-
|
|
235
|
-
if (!position) {
|
|
236
|
-
return Boolean(
|
|
237
|
-
pinningState.left?.length || pinningState.right?.length
|
|
238
|
-
)
|
|
239
|
-
}
|
|
240
|
-
return Boolean(pinningState[position]?.length)
|
|
241
|
-
},
|
|
204
|
+
createTable: <TData extends RowData>(table: Table<TData>): void => {
|
|
205
|
+
table.setColumnPinning = updater =>
|
|
206
|
+
table.options.onColumnPinningChange?.(updater)
|
|
242
207
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
() => [table.getAllLeafColumns(), table.getState().columnPinning.right],
|
|
258
|
-
(allColumns, right) => {
|
|
259
|
-
return (right ?? [])
|
|
260
|
-
.map(columnId => allColumns.find(column => column.id === columnId)!)
|
|
261
|
-
.filter(Boolean)
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
key: process.env.NODE_ENV === 'development' && 'getRightLeafColumns',
|
|
265
|
-
debug: () => table.options.debugAll ?? table.options.debugColumns,
|
|
266
|
-
}
|
|
267
|
-
),
|
|
268
|
-
|
|
269
|
-
getCenterLeafColumns: memo(
|
|
270
|
-
() => [
|
|
271
|
-
table.getAllLeafColumns(),
|
|
272
|
-
table.getState().columnPinning.left,
|
|
273
|
-
table.getState().columnPinning.right,
|
|
274
|
-
],
|
|
275
|
-
(allColumns, left, right) => {
|
|
276
|
-
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])]
|
|
277
|
-
|
|
278
|
-
return allColumns.filter(d => !leftAndRight.includes(d.id))
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
key: process.env.NODE_ENV === 'development' && 'getCenterLeafColumns',
|
|
282
|
-
debug: () => table.options.debugAll ?? table.options.debugColumns,
|
|
283
|
-
}
|
|
284
|
-
),
|
|
208
|
+
table.resetColumnPinning = defaultState =>
|
|
209
|
+
table.setColumnPinning(
|
|
210
|
+
defaultState
|
|
211
|
+
? getDefaultPinningState()
|
|
212
|
+
: table.initialState?.columnPinning ?? getDefaultPinningState()
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
table.getIsSomeColumnsPinned = position => {
|
|
216
|
+
const pinningState = table.getState().columnPinning
|
|
217
|
+
|
|
218
|
+
if (!position) {
|
|
219
|
+
return Boolean(pinningState.left?.length || pinningState.right?.length)
|
|
220
|
+
}
|
|
221
|
+
return Boolean(pinningState[position]?.length)
|
|
285
222
|
}
|
|
223
|
+
|
|
224
|
+
table.getLeftLeafColumns = memo(
|
|
225
|
+
() => [table.getAllLeafColumns(), table.getState().columnPinning.left],
|
|
226
|
+
(allColumns, left) => {
|
|
227
|
+
return (left ?? [])
|
|
228
|
+
.map(columnId => allColumns.find(column => column.id === columnId)!)
|
|
229
|
+
.filter(Boolean)
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
key: process.env.NODE_ENV === 'development' && 'getLeftLeafColumns',
|
|
233
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns,
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
table.getRightLeafColumns = memo(
|
|
238
|
+
() => [table.getAllLeafColumns(), table.getState().columnPinning.right],
|
|
239
|
+
(allColumns, right) => {
|
|
240
|
+
return (right ?? [])
|
|
241
|
+
.map(columnId => allColumns.find(column => column.id === columnId)!)
|
|
242
|
+
.filter(Boolean)
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
key: process.env.NODE_ENV === 'development' && 'getRightLeafColumns',
|
|
246
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns,
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
table.getCenterLeafColumns = memo(
|
|
251
|
+
() => [
|
|
252
|
+
table.getAllLeafColumns(),
|
|
253
|
+
table.getState().columnPinning.left,
|
|
254
|
+
table.getState().columnPinning.right,
|
|
255
|
+
],
|
|
256
|
+
(allColumns, left, right) => {
|
|
257
|
+
const leftAndRight: string[] = [...(left ?? []), ...(right ?? [])]
|
|
258
|
+
|
|
259
|
+
return allColumns.filter(d => !leftAndRight.includes(d.id))
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
key: process.env.NODE_ENV === 'development' && 'getCenterLeafColumns',
|
|
263
|
+
debug: () => table.options.debugAll ?? table.options.debugColumns,
|
|
264
|
+
}
|
|
265
|
+
)
|
|
286
266
|
},
|
|
287
267
|
}
|