@janbox/storefront-ui 1.0.26 → 1.0.27
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-range-filter-panel.d.ts","sourceRoot":"","sources":["../../../src/lib/filter-panel/price-range-filter-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"price-range-filter-panel.d.ts","sourceRoot":"","sources":["../../../src/lib/filter-panel/price-range-filter-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAWrD,eAAO,MAAM,qBAAqB,sFAO/B,0BAA0B,qDAyH5B,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { TYPING_DEBOUNCE } from "../../constants/index.js";
|
|
3
3
|
import { useQueryParams } from "../../hooks/use-query-params.js";
|
|
4
4
|
import { useId } from "react";
|
|
5
|
-
import
|
|
5
|
+
import "lodash-es";
|
|
6
6
|
import "../../theme/palette.js";
|
|
7
7
|
import { StringParamParser, NumberParamParser } from "../../utils/query-params.js";
|
|
8
8
|
import { RadioButton } from "../radio-button/radio-button.js";
|
|
@@ -15,7 +15,7 @@ const PriceRangeFilterPanel = ({
|
|
|
15
15
|
onPriceChange,
|
|
16
16
|
onPriceTypeChange
|
|
17
17
|
}) => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f;
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
19
19
|
const uniqueId = useId();
|
|
20
20
|
const { queryParams, setQueryParams } = useQueryParams({
|
|
21
21
|
...((_a = queryParam == null ? void 0 : queryParam.from) == null ? void 0 : _a.key) ? {
|
|
@@ -43,25 +43,27 @@ const PriceRangeFilterPanel = ({
|
|
|
43
43
|
const finalValue = {
|
|
44
44
|
from: (value == null ? void 0 : value.from) ?? (((_d = queryParam == null ? void 0 : queryParam.from) == null ? void 0 : _d.key) ? queryParams[queryParam.from.key] : void 0),
|
|
45
45
|
to: (value == null ? void 0 : value.to) ?? (((_e = queryParam == null ? void 0 : queryParam.to) == null ? void 0 : _e.key) ? queryParams[queryParam.to.key] : void 0),
|
|
46
|
-
priceType: (value == null ? void 0 : value.priceType) ?? (((_f = queryParam == null ? void 0 : queryParam.priceType) == null ? void 0 : _f.key) ? queryParams[queryParam.priceType.key] : void 0)
|
|
46
|
+
priceType: (value == null ? void 0 : value.priceType) ?? (((_f = queryParam == null ? void 0 : queryParam.priceType) == null ? void 0 : _f.key) ? queryParams[queryParam.priceType.key] : void 0) ?? ((_g = priceTypes.find((priceType) => priceType.isDefault)) == null ? void 0 : _g.value)
|
|
47
47
|
};
|
|
48
48
|
const onInputRangeChange = (event, edge) => {
|
|
49
|
-
var _a2, _b2;
|
|
49
|
+
var _a2, _b2, _c2, _d2;
|
|
50
50
|
const valueAsNumber = event.target.valueAsNumber;
|
|
51
51
|
if (edge === "from" && ((_a2 = queryParam == null ? void 0 : queryParam.from) == null ? void 0 : _a2.key)) {
|
|
52
52
|
setQueryParams(
|
|
53
53
|
{
|
|
54
|
-
[queryParam.from.key]: isNaN(valueAsNumber) ? void 0 : valueAsNumber
|
|
54
|
+
[queryParam.from.key]: isNaN(valueAsNumber) ? void 0 : valueAsNumber,
|
|
55
|
+
...((_b2 = queryParam.priceType) == null ? void 0 : _b2.key) ? { [queryParam.priceType.key]: finalValue.priceType } : {}
|
|
55
56
|
},
|
|
56
57
|
{
|
|
57
58
|
preventScrollReset: true
|
|
58
59
|
}
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
|
-
if (edge === "to" && ((
|
|
62
|
+
if (edge === "to" && ((_c2 = queryParam == null ? void 0 : queryParam.to) == null ? void 0 : _c2.key)) {
|
|
62
63
|
setQueryParams(
|
|
63
64
|
{
|
|
64
|
-
[queryParam.to.key]: isNaN(valueAsNumber) ? void 0 : valueAsNumber
|
|
65
|
+
[queryParam.to.key]: isNaN(valueAsNumber) ? void 0 : valueAsNumber,
|
|
66
|
+
...((_d2 = queryParam.priceType) == null ? void 0 : _d2.key) ? { [queryParam.priceType.key]: finalValue.priceType } : {}
|
|
65
67
|
},
|
|
66
68
|
{
|
|
67
69
|
preventScrollReset: true
|
|
@@ -87,11 +89,10 @@ const PriceRangeFilterPanel = ({
|
|
|
87
89
|
return /* @__PURE__ */ jsxs("div", { css: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
88
90
|
/* @__PURE__ */ jsx("div", { css: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }, children: priceTypes.map((priceType) => {
|
|
89
91
|
var _a2;
|
|
90
|
-
const isChecked = isNil(finalValue.priceType) ? priceType.isDefault : ((_a2 = finalValue.priceType) == null ? void 0 : _a2.toString()) === priceType.value;
|
|
91
92
|
return /* @__PURE__ */ jsx(
|
|
92
93
|
RadioButton,
|
|
93
94
|
{
|
|
94
|
-
checked:
|
|
95
|
+
checked: ((_a2 = finalValue.priceType) == null ? void 0 : _a2.toString()) === priceType.value,
|
|
95
96
|
value: priceType.value,
|
|
96
97
|
onChange: onRadioInputChange,
|
|
97
98
|
name: `${uniqueId}-price-type`,
|