@trackunit/filters-filter-bar 2.6.50 → 2.6.52
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/index.cjs.js +7 -5
- package/index.esm.js +7 -5
- package/package.json +12 -12
package/index.cjs.js
CHANGED
|
@@ -546,16 +546,18 @@ const DefaultMinMaxFilter = ({ filterDefinition, filterName, value, setValue, fi
|
|
|
546
546
|
}, [value]);
|
|
547
547
|
const { logEvent } = reactCoreHooks.useAnalytics(FilterEvents);
|
|
548
548
|
const handleApply = () => {
|
|
549
|
-
|
|
550
|
-
|
|
549
|
+
// Keep 0 unless the definition puts it out of range. Filters with no declared minimum,
|
|
550
|
+
// a zero floor, or a negative floor all treat 0 as a valid bound.
|
|
551
|
+
const zeroIsValidBound = filterDefinition.type === "minMax" &&
|
|
552
|
+
(filterDefinition.minimumNumber === undefined || filterDefinition.minimumNumber <= 0);
|
|
553
|
+
const realMinValue = minValue === 0 && !zeroIsValidBound ? undefined : minValue;
|
|
554
|
+
const realMaxValue = maxValue === 0 && !zeroIsValidBound ? undefined : maxValue;
|
|
551
555
|
logEvent("Filters Applied - V2", {
|
|
552
556
|
type: filterName ?? `${stringTs.capitalize(filterDefinition.filterKey)}Filter`,
|
|
553
557
|
value: JSON.stringify({ min: realMinValue, max: realMaxValue }),
|
|
554
558
|
});
|
|
555
559
|
setValue(() => {
|
|
556
|
-
return realMinValue !== undefined || realMaxValue !== undefined
|
|
557
|
-
? { min: realMinValue, max: realMaxValue }
|
|
558
|
-
: {};
|
|
560
|
+
return realMinValue !== undefined || realMaxValue !== undefined ? { min: realMinValue, max: realMaxValue } : {};
|
|
559
561
|
});
|
|
560
562
|
};
|
|
561
563
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactFilterComponents.FilterHeader, { onReset: () => filterBarActions.resetIndividualFilterToInitialState(filterDefinition.filterKey), resetLabel: t("filtersBar.resetFilter"), showReset: filterBarActions.appliedFilterKeys().includes(filterDefinition.filterKey), title: filterDefinition.title }), jsxRuntime.jsxs(reactFilterComponents.FilterBody, { children: [jsxRuntime.jsxs("div", { className: "flex gap-1 px-1 pb-0.5 pt-1", children: [jsxRuntime.jsx(reactFormComponents.NumberField, { addonAfter: unit, className: "w-40", label: t("filtersBar.defaultMinMaxFilters.min"), max: filterDefinition.type === "minMax" ? filterDefinition.maximumNumber : undefined, min: filterDefinition.type === "minMax" ? filterDefinition.minimumNumber : undefined, onChange: e => setMinValue(e.target.value === "" ? undefined : Number(e.target.value)), value: minValue ?? "" }), jsxRuntime.jsx(reactFormComponents.NumberField, { addonAfter: unit, className: "w-40", label: t("filtersBar.defaultMinMaxFilters.max"), max: filterDefinition.type === "minMax" ? filterDefinition.maximumNumber : undefined, min: filterDefinition.type === "minMax" ? filterDefinition.minimumNumber : undefined, onChange: e => setMaxValue(e.target.value === "" ? undefined : Number(e.target.value)), value: maxValue ?? "" })] }), jsxRuntime.jsx(reactFilterComponents.FilterFooter, { children: jsxRuntime.jsx(reactComponents.Button, { onClick: handleApply, size: "small", variant: "primary", children: t("filtersBar.defaultMinMaxFilters.apply") }) })] })] }));
|
package/index.esm.js
CHANGED
|
@@ -544,16 +544,18 @@ const DefaultMinMaxFilter = ({ filterDefinition, filterName, value, setValue, fi
|
|
|
544
544
|
}, [value]);
|
|
545
545
|
const { logEvent } = useAnalytics(FilterEvents);
|
|
546
546
|
const handleApply = () => {
|
|
547
|
-
|
|
548
|
-
|
|
547
|
+
// Keep 0 unless the definition puts it out of range. Filters with no declared minimum,
|
|
548
|
+
// a zero floor, or a negative floor all treat 0 as a valid bound.
|
|
549
|
+
const zeroIsValidBound = filterDefinition.type === "minMax" &&
|
|
550
|
+
(filterDefinition.minimumNumber === undefined || filterDefinition.minimumNumber <= 0);
|
|
551
|
+
const realMinValue = minValue === 0 && !zeroIsValidBound ? undefined : minValue;
|
|
552
|
+
const realMaxValue = maxValue === 0 && !zeroIsValidBound ? undefined : maxValue;
|
|
549
553
|
logEvent("Filters Applied - V2", {
|
|
550
554
|
type: filterName ?? `${capitalize(filterDefinition.filterKey)}Filter`,
|
|
551
555
|
value: JSON.stringify({ min: realMinValue, max: realMaxValue }),
|
|
552
556
|
});
|
|
553
557
|
setValue(() => {
|
|
554
|
-
return realMinValue !== undefined || realMaxValue !== undefined
|
|
555
|
-
? { min: realMinValue, max: realMaxValue }
|
|
556
|
-
: {};
|
|
558
|
+
return realMinValue !== undefined || realMaxValue !== undefined ? { min: realMinValue, max: realMaxValue } : {};
|
|
557
559
|
});
|
|
558
560
|
};
|
|
559
561
|
return (jsxs(Fragment, { children: [jsx(FilterHeader$1, { onReset: () => filterBarActions.resetIndividualFilterToInitialState(filterDefinition.filterKey), resetLabel: t("filtersBar.resetFilter"), showReset: filterBarActions.appliedFilterKeys().includes(filterDefinition.filterKey), title: filterDefinition.title }), jsxs(FilterBody, { children: [jsxs("div", { className: "flex gap-1 px-1 pb-0.5 pt-1", children: [jsx(NumberField, { addonAfter: unit, className: "w-40", label: t("filtersBar.defaultMinMaxFilters.min"), max: filterDefinition.type === "minMax" ? filterDefinition.maximumNumber : undefined, min: filterDefinition.type === "minMax" ? filterDefinition.minimumNumber : undefined, onChange: e => setMinValue(e.target.value === "" ? undefined : Number(e.target.value)), value: minValue ?? "" }), jsx(NumberField, { addonAfter: unit, className: "w-40", label: t("filtersBar.defaultMinMaxFilters.max"), max: filterDefinition.type === "minMax" ? filterDefinition.maximumNumber : undefined, min: filterDefinition.type === "minMax" ? filterDefinition.minimumNumber : undefined, onChange: e => setMaxValue(e.target.value === "" ? undefined : Number(e.target.value)), value: maxValue ?? "" })] }), jsx(FilterFooter, { children: jsx(Button, { onClick: handleApply, size: "small", variant: "primary", children: t("filtersBar.defaultMinMaxFilters.apply") }) })] })] }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/filters-filter-bar",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.52",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
"tailwind-merge": "^2.0.0",
|
|
12
12
|
"string-ts": "^2.0.0",
|
|
13
13
|
"zod": "^3.25.76",
|
|
14
|
-
"@trackunit/iris-app-api": "2.4.
|
|
15
|
-
"@trackunit/react-core-hooks": "1.21.
|
|
16
|
-
"@trackunit/react-filter-components": "2.6.
|
|
17
|
-
"@trackunit/react-date-and-time-components": "2.6.
|
|
18
|
-
"@trackunit/shared-utils": "1.16.
|
|
19
|
-
"@trackunit/react-form-components": "2.6.
|
|
20
|
-
"@trackunit/iris-app-runtime-core-api": "1.17.
|
|
21
|
-
"@trackunit/geo-json-utils": "1.15.
|
|
22
|
-
"@trackunit/i18n-library-translation": "2.4.
|
|
23
|
-
"@trackunit/css-class-variance-utilities": "2.0.
|
|
24
|
-
"@trackunit/react-components": "2.13.
|
|
14
|
+
"@trackunit/iris-app-api": "2.4.34",
|
|
15
|
+
"@trackunit/react-core-hooks": "1.21.44",
|
|
16
|
+
"@trackunit/react-filter-components": "2.6.51",
|
|
17
|
+
"@trackunit/react-date-and-time-components": "2.6.51",
|
|
18
|
+
"@trackunit/shared-utils": "1.16.35",
|
|
19
|
+
"@trackunit/react-form-components": "2.6.51",
|
|
20
|
+
"@trackunit/iris-app-runtime-core-api": "1.17.44",
|
|
21
|
+
"@trackunit/geo-json-utils": "1.15.34",
|
|
22
|
+
"@trackunit/i18n-library-translation": "2.4.44",
|
|
23
|
+
"@trackunit/css-class-variance-utilities": "2.0.2",
|
|
24
|
+
"@trackunit/react-components": "2.13.3"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@apollo/client": "^3.13.8",
|