@databiosphere/findable-ui 51.0.1 → 51.0.2

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.
@@ -10,3 +10,17 @@ import { RangeCategoryView } from "../../views/range/types";
10
10
  * @returns Full built range category view, ready for display.
11
11
  */
12
12
  export declare function buildRangeCategoryView(category: RangeCategory, categoryConfigs: CategoryConfig[], categorySelectedFilter?: SelectedFilter): RangeCategoryView;
13
+ /**
14
+ * Returns the maximum value from a faceted min/max tuple, falling back to Infinity.
15
+ * Uses nullish coalescing to correctly handle a max of 0.
16
+ * @param minMax - Faceted min/max values, or undefined.
17
+ * @returns The maximum value.
18
+ */
19
+ export declare function getRangeMax(minMax: [number, number] | undefined): number;
20
+ /**
21
+ * Returns the minimum value from a faceted min/max tuple, falling back to -Infinity.
22
+ * Uses nullish coalescing to correctly handle a min of 0.
23
+ * @param minMax - Faceted min/max values, or undefined.
24
+ * @returns The minimum value.
25
+ */
26
+ export declare function getRangeMin(minMax: [number, number] | undefined): number;
@@ -12,7 +12,7 @@ export function buildRangeCategoryView(category, categoryConfigs, categorySelect
12
12
  const [selectedMin, selectedMax] = getRangeSelectedValue(categorySelectedFilter);
13
13
  return {
14
14
  annotation: categoryConfig?.annotation,
15
- isDisabled: false,
15
+ isDisabled: !Number.isFinite(category.min) && !Number.isFinite(category.max),
16
16
  key: category.key,
17
17
  label: categoryConfig?.label || category.key,
18
18
  max: category.max,
@@ -22,3 +22,21 @@ export function buildRangeCategoryView(category, categoryConfigs, categorySelect
22
22
  unit: categoryConfig?.unit,
23
23
  };
24
24
  }
25
+ /**
26
+ * Returns the maximum value from a faceted min/max tuple, falling back to Infinity.
27
+ * Uses nullish coalescing to correctly handle a max of 0.
28
+ * @param minMax - Faceted min/max values, or undefined.
29
+ * @returns The maximum value.
30
+ */
31
+ export function getRangeMax(minMax) {
32
+ return minMax?.[1] ?? Infinity;
33
+ }
34
+ /**
35
+ * Returns the minimum value from a faceted min/max tuple, falling back to -Infinity.
36
+ * Uses nullish coalescing to correctly handle a min of 0.
37
+ * @param minMax - Faceted min/max values, or undefined.
38
+ * @returns The minimum value.
39
+ */
40
+ export function getRangeMin(minMax) {
41
+ return minMax?.[0] ?? -Infinity;
42
+ }
@@ -1,4 +1,5 @@
1
1
  import { isRangeCategoryConfig } from "../../../../../../common/categories/config/range/typeGuards";
2
+ import { getRangeMax, getRangeMin, } from "../../../../../../common/categories/views/range/utils";
2
3
  import { FILTER_SORT } from "../../../../../../common/filters/sort/config/types";
3
4
  import { sortCategoryValueViews } from "../../../../../../common/filters/sort/models/utils";
4
5
  import { getSelectCategoryValue } from "../../../../../../hooks/useCategoryFilter";
@@ -117,8 +118,8 @@ function mapColumnToRangeCategoryView(column, categoryConfig) {
117
118
  isDisabled,
118
119
  key: column.id,
119
120
  label: getColumnHeader(column),
120
- max: minMax?.[1] || Infinity,
121
- min: minMax?.[0] || -Infinity,
121
+ max: getRangeMax(minMax),
122
+ min: getRangeMin(minMax),
122
123
  selectedMax: filterValue[1],
123
124
  selectedMin: filterValue[0],
124
125
  ...categoryConfig,
@@ -1,4 +1,5 @@
1
1
  import { memo, sortingFns, } from "@tanstack/react-table";
2
+ import { getRangeMax, getRangeMin, } from "../../../common/categories/views/range/utils";
2
3
  import { EXPLORE_MODE } from "../../../hooks/useExploreMode/types";
3
4
  /**
4
5
  * Build view-specific models from react table faceted values function.
@@ -20,8 +21,8 @@ export function buildCategoryViews(columns, columnFilters) {
20
21
  categoryViews.push({
21
22
  key,
22
23
  label,
23
- max: minMax?.[1] || Infinity,
24
- min: minMax?.[0] || -Infinity,
24
+ max: getRangeMax(minMax),
25
+ min: getRangeMin(minMax),
25
26
  selectedMax: null, // Selected state updated in reducer.
26
27
  selectedMin: null, // Selected state updated in reducer.
27
28
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databiosphere/findable-ui",
3
- "version": "51.0.1",
3
+ "version": "51.0.2",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",