@tanstack/table-core 8.9.7 → 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 +4 -3
- 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 +157 -165
- package/build/lib/features/Filters.js.map +1 -1
- package/build/lib/features/Grouping.js +71 -79
- 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/index.esm.js +1469 -1515
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +1469 -1515
- package/build/lib/index.mjs.map +1 -1
- package/build/umd/index.development.js +1469 -1515
- 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
|
@@ -78,340 +78,334 @@ export const RowSelection: TableFeature = {
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
|
|
81
|
-
createTable: <TData extends RowData>(
|
|
82
|
-
table
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
}
|
|
81
|
+
createTable: <TData extends RowData>(table: Table<TData>): void => {
|
|
82
|
+
table.setRowSelection = updater =>
|
|
83
|
+
table.options.onRowSelectionChange?.(updater)
|
|
84
|
+
table.resetRowSelection = defaultState =>
|
|
85
|
+
table.setRowSelection(
|
|
86
|
+
defaultState ? {} : table.initialState.rowSelection ?? {}
|
|
87
|
+
)
|
|
88
|
+
table.toggleAllRowsSelected = value => {
|
|
89
|
+
table.setRowSelection(old => {
|
|
90
|
+
value =
|
|
91
|
+
typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected()
|
|
92
|
+
|
|
93
|
+
const rowSelection = { ...old }
|
|
94
|
+
|
|
95
|
+
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows
|
|
96
|
+
|
|
97
|
+
// We don't use `mutateRowIsSelected` here for performance reasons.
|
|
98
|
+
// All of the rows are flat already, so it wouldn't be worth it
|
|
99
|
+
if (value) {
|
|
100
|
+
preGroupedFlatRows.forEach(row => {
|
|
101
|
+
if (!row.getCanSelect()) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
rowSelection[row.id] = true
|
|
105
|
+
})
|
|
106
|
+
} else {
|
|
107
|
+
preGroupedFlatRows.forEach(row => {
|
|
108
|
+
delete rowSelection[row.id]
|
|
109
|
+
})
|
|
110
|
+
}
|
|
113
111
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
112
|
+
return rowSelection
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
table.toggleAllPageRowsSelected = value =>
|
|
116
|
+
table.setRowSelection(old => {
|
|
117
|
+
const resolvedValue =
|
|
118
|
+
typeof value !== 'undefined'
|
|
119
|
+
? value
|
|
120
|
+
: !table.getIsAllPageRowsSelected()
|
|
123
121
|
|
|
124
|
-
|
|
122
|
+
const rowSelection: RowSelectionState = { ...old }
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
table.getRowModel().rows.forEach(row => {
|
|
125
|
+
mutateRowIsSelected(rowSelection, row.id, resolvedValue, table)
|
|
126
|
+
})
|
|
129
127
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// addRowSelectionRange: rowId => {
|
|
134
|
-
// const {
|
|
135
|
-
// rows,
|
|
136
|
-
// rowsById,
|
|
137
|
-
// options: { selectGroupingRows, selectSubRows },
|
|
138
|
-
// } = table
|
|
139
|
-
|
|
140
|
-
// const findSelectedRow = (rows: Row[]) => {
|
|
141
|
-
// let found
|
|
142
|
-
// rows.find(d => {
|
|
143
|
-
// if (d.getIsSelected()) {
|
|
144
|
-
// found = d
|
|
145
|
-
// return true
|
|
146
|
-
// }
|
|
147
|
-
// const subFound = findSelectedRow(d.subRows || [])
|
|
148
|
-
// if (subFound) {
|
|
149
|
-
// found = subFound
|
|
150
|
-
// return true
|
|
151
|
-
// }
|
|
152
|
-
// return false
|
|
153
|
-
// })
|
|
154
|
-
// return found
|
|
155
|
-
// }
|
|
156
|
-
|
|
157
|
-
// const firstRow = findSelectedRow(rows) || rows[0]
|
|
158
|
-
// const lastRow = rowsById[rowId]
|
|
159
|
-
|
|
160
|
-
// let include = false
|
|
161
|
-
// const selectedRowIds = {}
|
|
162
|
-
|
|
163
|
-
// const addRow = (row: Row) => {
|
|
164
|
-
// mutateRowIsSelected(selectedRowIds, row.id, true, {
|
|
165
|
-
// rowsById,
|
|
166
|
-
// selectGroupingRows: selectGroupingRows!,
|
|
167
|
-
// selectSubRows: selectSubRows!,
|
|
168
|
-
// })
|
|
169
|
-
// }
|
|
170
|
-
|
|
171
|
-
// table.rows.forEach(row => {
|
|
172
|
-
// const isFirstRow = row.id === firstRow.id
|
|
173
|
-
// const isLastRow = row.id === lastRow.id
|
|
174
|
-
|
|
175
|
-
// if (isFirstRow || isLastRow) {
|
|
176
|
-
// if (!include) {
|
|
177
|
-
// include = true
|
|
178
|
-
// } else if (include) {
|
|
179
|
-
// addRow(row)
|
|
180
|
-
// include = false
|
|
181
|
-
// }
|
|
182
|
-
// }
|
|
183
|
-
|
|
184
|
-
// if (include) {
|
|
185
|
-
// addRow(row)
|
|
186
|
-
// }
|
|
187
|
-
// })
|
|
188
|
-
|
|
189
|
-
// table.setRowSelection(selectedRowIds)
|
|
190
|
-
// },
|
|
191
|
-
getPreSelectedRowModel: () => table.getCoreRowModel(),
|
|
192
|
-
getSelectedRowModel: memo(
|
|
193
|
-
() => [table.getState().rowSelection, table.getCoreRowModel()],
|
|
194
|
-
(rowSelection, rowModel) => {
|
|
195
|
-
if (!Object.keys(rowSelection).length) {
|
|
196
|
-
return {
|
|
197
|
-
rows: [],
|
|
198
|
-
flatRows: [],
|
|
199
|
-
rowsById: {},
|
|
200
|
-
}
|
|
201
|
-
}
|
|
128
|
+
return rowSelection
|
|
129
|
+
})
|
|
202
130
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
131
|
+
// addRowSelectionRange: rowId => {
|
|
132
|
+
// const {
|
|
133
|
+
// rows,
|
|
134
|
+
// rowsById,
|
|
135
|
+
// options: { selectGroupingRows, selectSubRows },
|
|
136
|
+
// } = table
|
|
137
|
+
|
|
138
|
+
// const findSelectedRow = (rows: Row[]) => {
|
|
139
|
+
// let found
|
|
140
|
+
// rows.find(d => {
|
|
141
|
+
// if (d.getIsSelected()) {
|
|
142
|
+
// found = d
|
|
143
|
+
// return true
|
|
144
|
+
// }
|
|
145
|
+
// const subFound = findSelectedRow(d.subRows || [])
|
|
146
|
+
// if (subFound) {
|
|
147
|
+
// found = subFound
|
|
148
|
+
// return true
|
|
149
|
+
// }
|
|
150
|
+
// return false
|
|
151
|
+
// })
|
|
152
|
+
// return found
|
|
153
|
+
// }
|
|
154
|
+
|
|
155
|
+
// const firstRow = findSelectedRow(rows) || rows[0]
|
|
156
|
+
// const lastRow = rowsById[rowId]
|
|
157
|
+
|
|
158
|
+
// let include = false
|
|
159
|
+
// const selectedRowIds = {}
|
|
160
|
+
|
|
161
|
+
// const addRow = (row: Row) => {
|
|
162
|
+
// mutateRowIsSelected(selectedRowIds, row.id, true, {
|
|
163
|
+
// rowsById,
|
|
164
|
+
// selectGroupingRows: selectGroupingRows!,
|
|
165
|
+
// selectSubRows: selectSubRows!,
|
|
166
|
+
// })
|
|
167
|
+
// }
|
|
168
|
+
|
|
169
|
+
// table.rows.forEach(row => {
|
|
170
|
+
// const isFirstRow = row.id === firstRow.id
|
|
171
|
+
// const isLastRow = row.id === lastRow.id
|
|
172
|
+
|
|
173
|
+
// if (isFirstRow || isLastRow) {
|
|
174
|
+
// if (!include) {
|
|
175
|
+
// include = true
|
|
176
|
+
// } else if (include) {
|
|
177
|
+
// addRow(row)
|
|
178
|
+
// include = false
|
|
179
|
+
// }
|
|
180
|
+
// }
|
|
181
|
+
|
|
182
|
+
// if (include) {
|
|
183
|
+
// addRow(row)
|
|
184
|
+
// }
|
|
185
|
+
// })
|
|
186
|
+
|
|
187
|
+
// table.setRowSelection(selectedRowIds)
|
|
188
|
+
// },
|
|
189
|
+
table.getPreSelectedRowModel = () => table.getCoreRowModel()
|
|
190
|
+
table.getSelectedRowModel = memo(
|
|
191
|
+
() => [table.getState().rowSelection, table.getCoreRowModel()],
|
|
192
|
+
(rowSelection, rowModel) => {
|
|
193
|
+
if (!Object.keys(rowSelection).length) {
|
|
194
|
+
return {
|
|
195
|
+
rows: [],
|
|
196
|
+
flatRows: [],
|
|
197
|
+
rowsById: {},
|
|
220
198
|
}
|
|
221
|
-
|
|
222
|
-
return selectRowsFn(table, rowModel)
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
key:
|
|
226
|
-
process.env.NODE_ENV === 'production' &&
|
|
227
|
-
'getFilteredSelectedRowModel',
|
|
228
|
-
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
229
199
|
}
|
|
230
|
-
),
|
|
231
|
-
|
|
232
|
-
getGroupedSelectedRowModel: memo(
|
|
233
|
-
() => [table.getState().rowSelection, table.getSortedRowModel()],
|
|
234
|
-
(rowSelection, rowModel) => {
|
|
235
|
-
if (!Object.keys(rowSelection).length) {
|
|
236
|
-
return {
|
|
237
|
-
rows: [],
|
|
238
|
-
flatRows: [],
|
|
239
|
-
rowsById: {},
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
200
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
),
|
|
201
|
+
return selectRowsFn(table, rowModel)
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
key: process.env.NODE_ENV === 'development' && 'getSelectedRowModel',
|
|
205
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
206
|
+
}
|
|
207
|
+
)
|
|
252
208
|
|
|
253
|
-
|
|
209
|
+
table.getFilteredSelectedRowModel = memo(
|
|
210
|
+
() => [table.getState().rowSelection, table.getFilteredRowModel()],
|
|
211
|
+
(rowSelection, rowModel) => {
|
|
212
|
+
if (!Object.keys(rowSelection).length) {
|
|
213
|
+
return {
|
|
214
|
+
rows: [],
|
|
215
|
+
flatRows: [],
|
|
216
|
+
rowsById: {},
|
|
217
|
+
}
|
|
218
|
+
}
|
|
254
219
|
|
|
255
|
-
|
|
256
|
-
|
|
220
|
+
return selectRowsFn(table, rowModel)
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
key:
|
|
224
|
+
process.env.NODE_ENV === 'production' &&
|
|
225
|
+
'getFilteredSelectedRowModel',
|
|
226
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
227
|
+
}
|
|
228
|
+
)
|
|
257
229
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
230
|
+
table.getGroupedSelectedRowModel = memo(
|
|
231
|
+
() => [table.getState().rowSelection, table.getSortedRowModel()],
|
|
232
|
+
(rowSelection, rowModel) => {
|
|
233
|
+
if (!Object.keys(rowSelection).length) {
|
|
234
|
+
return {
|
|
235
|
+
rows: [],
|
|
236
|
+
flatRows: [],
|
|
237
|
+
rowsById: {},
|
|
238
|
+
}
|
|
239
|
+
}
|
|
261
240
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
241
|
+
return selectRowsFn(table, rowModel)
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
key:
|
|
245
|
+
process.env.NODE_ENV === 'production' && 'getGroupedSelectedRowModel',
|
|
246
|
+
debug: () => table.options.debugAll ?? table.options.debugTable,
|
|
247
|
+
}
|
|
248
|
+
)
|
|
265
249
|
|
|
266
|
-
|
|
267
|
-
// },
|
|
250
|
+
///
|
|
268
251
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const { rowSelection } = table.getState()
|
|
252
|
+
// getGroupingRowCanSelect: rowId => {
|
|
253
|
+
// const row = table.getRow(rowId)
|
|
272
254
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
255
|
+
// if (!row) {
|
|
256
|
+
// throw new Error()
|
|
257
|
+
// }
|
|
276
258
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
row => row.getCanSelect() && !rowSelection[row.id]
|
|
281
|
-
)
|
|
282
|
-
) {
|
|
283
|
-
isAllRowsSelected = false
|
|
284
|
-
}
|
|
285
|
-
}
|
|
259
|
+
// if (typeof table.options.enableGroupingRowSelection === 'function') {
|
|
260
|
+
// return table.options.enableGroupingRowSelection(row)
|
|
261
|
+
// }
|
|
286
262
|
|
|
287
|
-
|
|
288
|
-
|
|
263
|
+
// return table.options.enableGroupingRowSelection ?? false
|
|
264
|
+
// },
|
|
289
265
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
.flatRows.filter(row => row.getCanSelect())
|
|
294
|
-
const { rowSelection } = table.getState()
|
|
266
|
+
table.getIsAllRowsSelected = () => {
|
|
267
|
+
const preGroupedFlatRows = table.getFilteredRowModel().flatRows
|
|
268
|
+
const { rowSelection } = table.getState()
|
|
295
269
|
|
|
296
|
-
|
|
270
|
+
let isAllRowsSelected = Boolean(
|
|
271
|
+
preGroupedFlatRows.length && Object.keys(rowSelection).length
|
|
272
|
+
)
|
|
297
273
|
|
|
274
|
+
if (isAllRowsSelected) {
|
|
298
275
|
if (
|
|
299
|
-
|
|
300
|
-
|
|
276
|
+
preGroupedFlatRows.some(
|
|
277
|
+
row => row.getCanSelect() && !rowSelection[row.id]
|
|
278
|
+
)
|
|
301
279
|
) {
|
|
302
|
-
|
|
280
|
+
isAllRowsSelected = false
|
|
303
281
|
}
|
|
282
|
+
}
|
|
304
283
|
|
|
305
|
-
|
|
306
|
-
|
|
284
|
+
return isAllRowsSelected
|
|
285
|
+
}
|
|
307
286
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
)
|
|
312
|
-
|
|
313
|
-
totalSelected > 0 &&
|
|
314
|
-
totalSelected < table.getFilteredRowModel().flatRows.length
|
|
315
|
-
)
|
|
316
|
-
},
|
|
287
|
+
table.getIsAllPageRowsSelected = () => {
|
|
288
|
+
const paginationFlatRows = table
|
|
289
|
+
.getPaginationRowModel()
|
|
290
|
+
.flatRows.filter(row => row.getCanSelect())
|
|
291
|
+
const { rowSelection } = table.getState()
|
|
317
292
|
|
|
318
|
-
|
|
319
|
-
const paginationFlatRows = table.getPaginationRowModel().flatRows
|
|
320
|
-
return table.getIsAllPageRowsSelected()
|
|
321
|
-
? false
|
|
322
|
-
: paginationFlatRows
|
|
323
|
-
.filter(row => row.getCanSelect())
|
|
324
|
-
.some(d => d.getIsSelected() || d.getIsSomeSelected())
|
|
325
|
-
},
|
|
293
|
+
let isAllPageRowsSelected = !!paginationFlatRows.length
|
|
326
294
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
},
|
|
295
|
+
if (
|
|
296
|
+
isAllPageRowsSelected &&
|
|
297
|
+
paginationFlatRows.some(row => !rowSelection[row.id])
|
|
298
|
+
) {
|
|
299
|
+
isAllPageRowsSelected = false
|
|
300
|
+
}
|
|
334
301
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
|
|
302
|
+
return isAllPageRowsSelected
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
table.getIsSomeRowsSelected = () => {
|
|
306
|
+
const totalSelected = Object.keys(
|
|
307
|
+
table.getState().rowSelection ?? {}
|
|
308
|
+
).length
|
|
309
|
+
return (
|
|
310
|
+
totalSelected > 0 &&
|
|
311
|
+
totalSelected < table.getFilteredRowModel().flatRows.length
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
table.getIsSomePageRowsSelected = () => {
|
|
316
|
+
const paginationFlatRows = table.getPaginationRowModel().flatRows
|
|
317
|
+
return table.getIsAllPageRowsSelected()
|
|
318
|
+
? false
|
|
319
|
+
: paginationFlatRows
|
|
320
|
+
.filter(row => row.getCanSelect())
|
|
321
|
+
.some(d => d.getIsSelected() || d.getIsSomeSelected())
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
table.getToggleAllRowsSelectedHandler = () => {
|
|
325
|
+
return (e: unknown) => {
|
|
326
|
+
table.toggleAllRowsSelected(
|
|
327
|
+
((e as MouseEvent).target as HTMLInputElement).checked
|
|
328
|
+
)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
table.getToggleAllPageRowsSelectedHandler = () => {
|
|
333
|
+
return (e: unknown) => {
|
|
334
|
+
table.toggleAllPageRowsSelected(
|
|
335
|
+
((e as MouseEvent).target as HTMLInputElement).checked
|
|
336
|
+
)
|
|
337
|
+
}
|
|
342
338
|
}
|
|
343
339
|
},
|
|
344
340
|
|
|
345
341
|
createRow: <TData extends RowData>(
|
|
346
342
|
row: Row<TData>,
|
|
347
343
|
table: Table<TData>
|
|
348
|
-
):
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const isSelected = row.getIsSelected()
|
|
344
|
+
): void => {
|
|
345
|
+
row.toggleSelected = value => {
|
|
346
|
+
const isSelected = row.getIsSelected()
|
|
352
347
|
|
|
353
|
-
|
|
354
|
-
|
|
348
|
+
table.setRowSelection(old => {
|
|
349
|
+
value = typeof value !== 'undefined' ? value : !isSelected
|
|
355
350
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
351
|
+
if (isSelected === value) {
|
|
352
|
+
return old
|
|
353
|
+
}
|
|
359
354
|
|
|
360
|
-
|
|
355
|
+
const selectedRowIds = { ...old }
|
|
361
356
|
|
|
362
|
-
|
|
357
|
+
mutateRowIsSelected(selectedRowIds, row.id, value, table)
|
|
363
358
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
359
|
+
return selectedRowIds
|
|
360
|
+
})
|
|
361
|
+
}
|
|
362
|
+
row.getIsSelected = () => {
|
|
363
|
+
const { rowSelection } = table.getState()
|
|
364
|
+
return isRowSelected(row, rowSelection)
|
|
365
|
+
}
|
|
371
366
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
367
|
+
row.getIsSomeSelected = () => {
|
|
368
|
+
const { rowSelection } = table.getState()
|
|
369
|
+
return isSubRowSelected(row, rowSelection, table) === 'some'
|
|
370
|
+
}
|
|
376
371
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
372
|
+
row.getIsAllSubRowsSelected = () => {
|
|
373
|
+
const { rowSelection } = table.getState()
|
|
374
|
+
return isSubRowSelected(row, rowSelection, table) === 'all'
|
|
375
|
+
}
|
|
381
376
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
377
|
+
row.getCanSelect = () => {
|
|
378
|
+
if (typeof table.options.enableRowSelection === 'function') {
|
|
379
|
+
return table.options.enableRowSelection(row)
|
|
380
|
+
}
|
|
386
381
|
|
|
387
|
-
|
|
388
|
-
|
|
382
|
+
return table.options.enableRowSelection ?? true
|
|
383
|
+
}
|
|
389
384
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
385
|
+
row.getCanSelectSubRows = () => {
|
|
386
|
+
if (typeof table.options.enableSubRowSelection === 'function') {
|
|
387
|
+
return table.options.enableSubRowSelection(row)
|
|
388
|
+
}
|
|
394
389
|
|
|
395
|
-
|
|
396
|
-
|
|
390
|
+
return table.options.enableSubRowSelection ?? true
|
|
391
|
+
}
|
|
397
392
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
393
|
+
row.getCanMultiSelect = () => {
|
|
394
|
+
if (typeof table.options.enableMultiRowSelection === 'function') {
|
|
395
|
+
return table.options.enableMultiRowSelection(row)
|
|
396
|
+
}
|
|
402
397
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
398
|
+
return table.options.enableMultiRowSelection ?? true
|
|
399
|
+
}
|
|
400
|
+
row.getToggleSelectedHandler = () => {
|
|
401
|
+
const canSelect = row.getCanSelect()
|
|
407
402
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
},
|
|
403
|
+
return (e: unknown) => {
|
|
404
|
+
if (!canSelect) return
|
|
405
|
+
row.toggleSelected(
|
|
406
|
+
((e as MouseEvent).target as HTMLInputElement)?.checked
|
|
407
|
+
)
|
|
408
|
+
}
|
|
415
409
|
}
|
|
416
410
|
},
|
|
417
411
|
}
|