@tanstack/table-core 8.19.3 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
- "version": "8.19.3",
3
+ "version": "8.19.4",
4
4
  "description": "Headless UI for building powerful tables & datagrids for TS/JS.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -11,31 +11,22 @@ export function getFacetedMinMaxValues<TData extends RowData>(): (
11
11
  facetedRowModel => {
12
12
  if (!facetedRowModel) return undefined
13
13
 
14
- const firstValue =
15
- facetedRowModel.flatRows[0]?.getUniqueValues(columnId)
14
+ const uniqueValues = facetedRowModel.flatRows
15
+ .flatMap(flatRow => flatRow.getUniqueValues(columnId) ?? [])
16
+ .map(Number)
17
+ .filter(value => !Number.isNaN(value))
16
18
 
17
- if (typeof firstValue === 'undefined') {
18
- return undefined
19
- }
20
-
21
- let facetedMinMaxValues: [any, any] = [firstValue, firstValue]
22
-
23
- for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
24
- const values =
25
- facetedRowModel.flatRows[i]!.getUniqueValues<number>(columnId)
19
+ if (!uniqueValues.length) return
26
20
 
27
- for (let j = 0; j < values.length; j++) {
28
- const value = values[j]!
21
+ let facetedMinValue = uniqueValues[0]!
22
+ let facetedMaxValue = uniqueValues[uniqueValues.length - 1]!
29
23
 
30
- if (value < facetedMinMaxValues[0]) {
31
- facetedMinMaxValues[0] = value
32
- } else if (value > facetedMinMaxValues[1]) {
33
- facetedMinMaxValues[1] = value
34
- }
35
- }
24
+ for (const value of uniqueValues) {
25
+ if (value < facetedMinValue) facetedMinValue = value
26
+ else if (value > facetedMaxValue) facetedMaxValue = value
36
27
  }
37
28
 
38
- return facetedMinMaxValues
29
+ return [facetedMinValue, facetedMaxValue]
39
30
  },
40
31
  getMemoOptions(table.options, 'debugTable', 'getFacetedMinMaxValues')
41
32
  )