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