@tanstack/svelte-table 8.5.1 → 8.5.4

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.
@@ -2159,14 +2159,14 @@ const RowSelection = {
2159
2159
  // return table.options.enableGroupingRowSelection ?? false
2160
2160
  // },
2161
2161
  getIsAllRowsSelected: () => {
2162
- const preFilteredFlatRows = table.getPreFilteredRowModel().flatRows;
2162
+ const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
2163
2163
  const {
2164
2164
  rowSelection
2165
2165
  } = table.getState();
2166
- let isAllRowsSelected = Boolean(preFilteredFlatRows.length && Object.keys(rowSelection).length);
2166
+ let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
2167
2167
 
2168
2168
  if (isAllRowsSelected) {
2169
- if (preFilteredFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
2169
+ if (preGroupedFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
2170
2170
  isAllRowsSelected = false;
2171
2171
  }
2172
2172
  }
@@ -2190,7 +2190,7 @@ const RowSelection = {
2190
2190
  var _table$getState$rowSe;
2191
2191
 
2192
2192
  const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
2193
- return totalSelected > 0 && totalSelected < table.getCoreRowModel().flatRows.length;
2193
+ return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
2194
2194
  },
2195
2195
  getIsSomePageRowsSelected: () => {
2196
2196
  const paginationFlatRows = table.getPaginationRowModel().flatRows;
@@ -2936,8 +2936,20 @@ function createTable(options) {
2936
2936
 
2937
2937
  defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2938
2938
  return {
2939
- header: props => props.header.column.id,
2940
- footer: props => props.header.column.id,
2939
+ header: props => {
2940
+ const resolvedColumnDef = props.header.column.columnDef;
2941
+
2942
+ if (resolvedColumnDef.accessorKey) {
2943
+ return resolvedColumnDef.accessorKey;
2944
+ }
2945
+
2946
+ if (resolvedColumnDef.accessorFn) {
2947
+ return resolvedColumnDef.id;
2948
+ }
2949
+
2950
+ return null;
2951
+ },
2952
+ // footer: props => props.header.column.id,
2941
2953
  cell: props => {
2942
2954
  var _props$renderValue$to, _props$renderValue;
2943
2955
 
@@ -2965,7 +2977,8 @@ function createTable(options) {
2965
2977
 
2966
2978
  return columnDefs.map(columnDef => {
2967
2979
  const column = createColumn(table, columnDef, depth, parent);
2968
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
2980
+ const groupingColumnDef = columnDef;
2981
+ column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
2969
2982
  return column;
2970
2983
  });
2971
2984
  };