@tanstack/svelte-table 8.0.0-alpha.87 → 8.0.0-beta.1

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.
@@ -123,7 +123,7 @@ function createColumn(instance, columnDef, depth, parent) {
123
123
  throw new Error();
124
124
  }
125
125
 
126
- let column = { ...columnDef,
126
+ let column = {
127
127
  id: "" + id,
128
128
  accessorFn,
129
129
  parent: parent,
@@ -887,8 +887,12 @@ const Expanding = {
887
887
  getIsAllRowsExpanded: () => {
888
888
  const expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
889
889
 
890
- if (expanded === true) {
891
- return true;
890
+ if (typeof expanded === 'boolean') {
891
+ return expanded === true;
892
+ }
893
+
894
+ if (!Object.keys(expanded).length) {
895
+ return false;
892
896
  } // If any row is not expanded, return false
893
897
 
894
898
 
@@ -2699,8 +2703,8 @@ const Visibility = {
2699
2703
  },
2700
2704
  createRow: (row, instance) => {
2701
2705
  return {
2702
- _getAllVisibleCells: memo(() => [row.getAllCells().filter(cell => cell.column.getIsVisible()).map(d => d.id).join('_')], _ => {
2703
- return row.getAllCells().filter(cell => cell.column.getIsVisible());
2706
+ _getAllVisibleCells: memo(() => [row.getAllCells(), instance.getState().columnVisibility], cells => {
2707
+ return cells.filter(cell => cell.column.getIsVisible());
2704
2708
  }, {
2705
2709
  key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
2706
2710
  debug: () => {
@@ -3053,13 +3057,15 @@ function createCell(instance, row, column, columnId) {
3053
3057
  row,
3054
3058
  column,
3055
3059
  getValue: () => row.getValue(columnId),
3056
- renderCell: () => column.columnDef.cell ? instance._render(column.columnDef.cell, {
3057
- instance,
3058
- column,
3059
- row,
3060
- cell: cell,
3061
- getValue: cell.getValue
3062
- }) : null
3060
+ renderCell: () => {
3061
+ return column.columnDef.cell ? instance._render(column.columnDef.cell, {
3062
+ instance,
3063
+ column,
3064
+ row,
3065
+ cell: cell,
3066
+ getValue: cell.getValue
3067
+ }) : null;
3068
+ }
3063
3069
  };
3064
3070
 
3065
3071
  instance._features.forEach(feature => {
@@ -3134,27 +3140,23 @@ function getCoreRowModel() {
3134
3140
  flatRows: [],
3135
3141
  rowsById: {}
3136
3142
  };
3137
- let rows;
3138
- let row;
3139
- let originalRow;
3140
3143
 
3141
3144
  const accessRows = function (originalRows, depth, parent) {
3142
3145
  if (depth === void 0) {
3143
3146
  depth = 0;
3144
3147
  }
3145
3148
 
3146
- rows = [];
3149
+ const rows = [];
3147
3150
 
3148
3151
  for (let i = 0; i < originalRows.length; i++) {
3149
- originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
3152
+ // This could be an expensive check at scale, so we should move it somewhere else, but where?
3150
3153
  // if (!id) {
3151
3154
  // if (process.env.NODE_ENV !== 'production') {
3152
3155
  // throw new Error(`getRowId expected an ID, but got ${id}`)
3153
3156
  // }
3154
3157
  // }
3155
3158
  // Make the row
3156
-
3157
- row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3159
+ const row = createRow(instance, instance._getRowId(originalRows[i], i, parent), originalRows[i], i, depth); // Keep track of every row in a flat array
3158
3160
 
3159
3161
  rowModel.flatRows.push(row); // Also keep track of every row by its ID
3160
3162
 
@@ -3165,7 +3167,7 @@ function getCoreRowModel() {
3165
3167
  if (instance.options.getSubRows) {
3166
3168
  var _row$originalSubRows;
3167
3169
 
3168
- row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
3170
+ row.originalSubRows = instance.options.getSubRows(originalRows[i], i); // Then recursively access them
3169
3171
 
3170
3172
  if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
3171
3173
  row.subRows = accessRows(row.originalSubRows, depth + 1, row);