@tanstack/react-table 8.0.14 → 8.1.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.
@@ -2197,13 +2197,19 @@ const RowSelection = {
2197
2197
  const {
2198
2198
  rowSelection
2199
2199
  } = table.getState();
2200
- return isRowSelected(row, rowSelection) === true;
2200
+ return isRowSelected(row, rowSelection);
2201
2201
  },
2202
2202
  getIsSomeSelected: () => {
2203
2203
  const {
2204
2204
  rowSelection
2205
2205
  } = table.getState();
2206
- return isRowSelected(row, rowSelection) === 'some';
2206
+ return isSubRowSelected(row, rowSelection) === 'some';
2207
+ },
2208
+ getIsAllSubRowsSelected: () => {
2209
+ const {
2210
+ rowSelection
2211
+ } = table.getState();
2212
+ return isSubRowSelected(row, rowSelection) === 'all';
2207
2213
  },
2208
2214
  getCanSelect: () => {
2209
2215
  var _table$options$enable;
@@ -2255,6 +2261,10 @@ const mutateRowIsSelected = (selectedRowIds, id, value, table) => {
2255
2261
  // ) {
2256
2262
 
2257
2263
  if (value) {
2264
+ if (!row.getCanMultiSelect()) {
2265
+ Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
2266
+ }
2267
+
2258
2268
  selectedRowIds[id] = true;
2259
2269
  } else {
2260
2270
  delete selectedRowIds[id];
@@ -2276,7 +2286,7 @@ function selectRowsFn(table, rowModel) {
2276
2286
  return rows.map(row => {
2277
2287
  var _row$subRows2;
2278
2288
 
2279
- const isSelected = isRowSelected(row, rowSelection) === true;
2289
+ const isSelected = isRowSelected(row, rowSelection);
2280
2290
 
2281
2291
  if (isSelected) {
2282
2292
  newSelectedFlatRows.push(row);
@@ -2301,11 +2311,12 @@ function selectRowsFn(table, rowModel) {
2301
2311
  rowsById: newSelectedRowsById
2302
2312
  };
2303
2313
  }
2304
- function isRowSelected(row, selection, table) {
2305
- if (selection[row.id]) {
2306
- return true;
2307
- }
2314
+ function isRowSelected(row, selection) {
2315
+ var _selection$row$id;
2308
2316
 
2317
+ return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
2318
+ }
2319
+ function isSubRowSelected(row, selection, table) {
2309
2320
  if (row.subRows && row.subRows.length) {
2310
2321
  let allChildrenSelected = true;
2311
2322
  let someSelected = false;
@@ -2321,7 +2332,7 @@ function isRowSelected(row, selection, table) {
2321
2332
  allChildrenSelected = false;
2322
2333
  }
2323
2334
  });
2324
- return allChildrenSelected ? true : someSelected ? 'some' : false;
2335
+ return allChildrenSelected ? 'all' : someSelected ? 'some' : false;
2325
2336
  }
2326
2337
 
2327
2338
  return false;
@@ -3811,5 +3822,5 @@ function useReactTable(options) {
3811
3822
  return tableRef.current;
3812
3823
  }
3813
3824
 
3814
- export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createRow, createTable, defaultColumnSizing, expandRows, filterFns, flattenBy, flexRender, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useReactTable };
3825
+ export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createRow, createTable, defaultColumnSizing, expandRows, filterFns, flattenBy, flexRender, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, isSubRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useReactTable };
3815
3826
  //# sourceMappingURL=index.js.map