@tanstack/table-core 8.19.2 → 8.19.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.
@@ -3003,25 +3003,18 @@ function getFacetedMinMaxValues() {
3003
3003
  var _table$getColumn;
3004
3004
  return [(_table$getColumn = table.getColumn(columnId)) == null ? void 0 : _table$getColumn.getFacetedRowModel()];
3005
3005
  }, facetedRowModel => {
3006
- var _facetedRowModel$flat;
3007
3006
  if (!facetedRowModel) return undefined;
3008
- const firstValue = (_facetedRowModel$flat = facetedRowModel.flatRows[0]) == null ? void 0 : _facetedRowModel$flat.getUniqueValues(columnId);
3009
- if (typeof firstValue === 'undefined') {
3010
- return undefined;
3007
+ const uniqueValues = facetedRowModel.flatRows.flatMap(flatRow => {
3008
+ var _flatRow$getUniqueVal;
3009
+ return (_flatRow$getUniqueVal = flatRow.getUniqueValues(columnId)) != null ? _flatRow$getUniqueVal : [];
3010
+ }).map(Number).filter(value => !Number.isNaN(value));
3011
+ if (!uniqueValues.length) return;
3012
+ let facetedMinValue = uniqueValues[0];
3013
+ let facetedMaxValue = uniqueValues[uniqueValues.length - 1];
3014
+ for (const value of uniqueValues) {
3015
+ if (value < facetedMinValue) facetedMinValue = value;else if (value > facetedMaxValue) facetedMaxValue = value;
3011
3016
  }
3012
- let facetedMinMaxValues = [firstValue, firstValue];
3013
- for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3014
- const values = facetedRowModel.flatRows[i].getUniqueValues(columnId);
3015
- for (let j = 0; j < values.length; j++) {
3016
- const value = values[j];
3017
- if (value < facetedMinMaxValues[0]) {
3018
- facetedMinMaxValues[0] = value;
3019
- } else if (value > facetedMinMaxValues[1]) {
3020
- facetedMinMaxValues[1] = value;
3021
- }
3022
- }
3023
- }
3024
- return facetedMinMaxValues;
3017
+ return [facetedMinValue, facetedMaxValue];
3025
3018
  }, getMemoOptions(table.options, 'debugTable', 'getFacetedMinMaxValues'));
3026
3019
  }
3027
3020
 
@@ -3259,6 +3252,10 @@ function getFilteredRowModel() {
3259
3252
  function getGroupedRowModel() {
3260
3253
  return table => memo(() => [table.getState().grouping, table.getPreGroupedRowModel()], (grouping, rowModel) => {
3261
3254
  if (!rowModel.rows.length || !grouping.length) {
3255
+ rowModel.rows.forEach(row => {
3256
+ row.depth = 0;
3257
+ row.parentId = undefined;
3258
+ });
3262
3259
  return rowModel;
3263
3260
  }
3264
3261
 
@@ -3294,7 +3291,7 @@ function getGroupedRowModel() {
3294
3291
  // Group the rows together for this level
3295
3292
  const rowGroupsMap = groupBy(rows, columnId);
3296
3293
 
3297
- // Peform aggregations for each group
3294
+ // Perform aggregations for each group
3298
3295
  const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
3299
3296
  let [groupingValue, groupedRows] = _ref;
3300
3297
  let id = `${columnId}:${groupingValue}`;
@@ -3302,6 +3299,9 @@ function getGroupedRowModel() {
3302
3299
 
3303
3300
  // First, Recurse to group sub rows before aggregation
3304
3301
  const subRows = groupUpRecursively(groupedRows, depth + 1, id);
3302
+ subRows.forEach(subRow => {
3303
+ subRow.parentId = id;
3304
+ });
3305
3305
 
3306
3306
  // Flatten the leaf rows of the rows in this group
3307
3307
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;