@sledge-app/react-instant-search 1.0.38 → 1.0.39
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.
|
@@ -504,52 +504,38 @@ const Checkbox = ({ id, name, value, required, label, checked, labelStyle = {},
|
|
|
504
504
|
};
|
|
505
505
|
const Slider$1 = "";
|
|
506
506
|
const Slider = (props) => {
|
|
507
|
-
const {
|
|
508
|
-
const [valueSlider, setValueSlider] = React__default.useState(defaultValue);
|
|
509
|
-
const [hoverActiveMin, setHoverActiveMin] = React__default.useState(false);
|
|
510
|
-
const [hoverActiveMax, setHoverActiveMax] = React__default.useState(false);
|
|
511
|
-
React__default.useEffect(() => {
|
|
512
|
-
setValueSlider(defaultValue);
|
|
513
|
-
}, [defaultValue]);
|
|
507
|
+
const { value, min, max, step = 1, setValueCommit, setValueChange } = props;
|
|
514
508
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("form", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
515
509
|
$faa2e61a3361514f$export$be92b6f5f03c0fe9,
|
|
516
510
|
{
|
|
517
511
|
className: "sledge__SliderRoot",
|
|
518
|
-
|
|
519
|
-
value: valueSlider,
|
|
512
|
+
value,
|
|
520
513
|
...typeof min !== "undefined" ? {
|
|
521
514
|
min
|
|
522
515
|
} : {},
|
|
523
516
|
max,
|
|
524
517
|
step,
|
|
525
518
|
"aria-label": "Volume",
|
|
526
|
-
onValueCommit: (valueCommit) =>
|
|
527
|
-
|
|
528
|
-
},
|
|
529
|
-
onValueChange: (valueChange) => {
|
|
530
|
-
setValueChange == null ? void 0 : setValueChange(valueChange);
|
|
531
|
-
setValueSlider(valueChange);
|
|
532
|
-
},
|
|
519
|
+
onValueCommit: (valueCommit) => setValueCommit == null ? void 0 : setValueCommit(valueCommit),
|
|
520
|
+
onValueChange: (valueChange) => setValueChange == null ? void 0 : setValueChange(valueChange),
|
|
533
521
|
children: [
|
|
534
522
|
/* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$13921ac0cc260818, { className: "sledge__SliderTrack", children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$9a58ef0d7ad3278c, { className: "sledge__SliderRange" }) }),
|
|
535
523
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
536
524
|
Tooltip,
|
|
537
525
|
{
|
|
538
|
-
content:
|
|
526
|
+
content: value[0],
|
|
539
527
|
customArrow: `<svg width="19" height="5" viewBox="0 0 19 5" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 4.99998C9 9.48298e-05 16.4996 1.99678e-05 18.4999 0L9 2.2985e-06L0.5 2.04891e-06C9 2.2985e-06 9 4.99998 9 4.99998Z" fill="#43c6ac"/></svg>`,
|
|
540
528
|
wrapTrigger: false,
|
|
541
|
-
|
|
542
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb", onMouseEnter: () => setHoverActiveMin(true), onMouseLeave: () => setHoverActiveMin(false) })
|
|
529
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb" })
|
|
543
530
|
}
|
|
544
531
|
),
|
|
545
|
-
!
|
|
532
|
+
!value[1] ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
546
533
|
Tooltip,
|
|
547
534
|
{
|
|
548
|
-
content:
|
|
535
|
+
content: value[1],
|
|
549
536
|
customArrow: `<svg width="19" height="5" viewBox="0 0 19 5" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 4.99998C9 9.48298e-05 16.4996 1.99678e-05 18.4999 0L9 2.2985e-06L0.5 2.04891e-06C9 2.2985e-06 9 4.99998 9 4.99998Z" fill="#43c6ac"/></svg>`,
|
|
550
537
|
wrapTrigger: false,
|
|
551
|
-
|
|
552
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb", onMouseEnter: () => setHoverActiveMax(true), onMouseLeave: () => setHoverActiveMax(false) })
|
|
538
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb" })
|
|
553
539
|
}
|
|
554
540
|
)
|
|
555
541
|
]
|
|
@@ -2955,7 +2941,7 @@ const ArticleGrid = ({ className = "", data, cards: CardsComponent, isComponentJ
|
|
|
2955
2941
|
}) }) });
|
|
2956
2942
|
};
|
|
2957
2943
|
const Tooltip$1 = "";
|
|
2958
|
-
const Tooltip = ({ children, content, withArrow = true, customArrow = "", sideOffset = 5, alignOffset = 0, wrapTrigger = true
|
|
2944
|
+
const Tooltip = ({ children, content, withArrow = true, customArrow = "", sideOffset = 5, alignOffset = 0, wrapTrigger = true }) => {
|
|
2959
2945
|
const [open, setOpen] = React__default.useState(false);
|
|
2960
2946
|
React__default.useEffect(() => {
|
|
2961
2947
|
var _a;
|
|
@@ -2965,22 +2951,13 @@ const Tooltip = ({ children, content, withArrow = true, customArrow = "", sideOf
|
|
|
2965
2951
|
arrowElement.innerHTML = customArrow;
|
|
2966
2952
|
}
|
|
2967
2953
|
}, [open]);
|
|
2968
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$2881499e37b75b9a, { delayDuration: 0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2969
|
-
$a093c7e1ec25a057$export$
|
|
2970
|
-
{
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
children: [
|
|
2976
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: wrapTrigger ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children }) : children }),
|
|
2977
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { className: "sledge__tooltip-content", sideOffset, alignOffset, children: [
|
|
2978
|
-
content,
|
|
2979
|
-
withArrow ? /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$21b07c8f274aebd5, { className: "sledge__tooltip-arrow" }) : null
|
|
2980
|
-
] }) })
|
|
2981
|
-
]
|
|
2982
|
-
}
|
|
2983
|
-
) });
|
|
2954
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$2881499e37b75b9a, { delayDuration: 0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs($a093c7e1ec25a057$export$be92b6f5f03c0fe9, { onOpenChange: setOpen, children: [
|
|
2955
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: wrapTrigger ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children }) : children }),
|
|
2956
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { className: "sledge__tooltip-content", sideOffset, alignOffset, children: [
|
|
2957
|
+
content,
|
|
2958
|
+
withArrow ? /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$21b07c8f274aebd5, { className: "sledge__tooltip-arrow" }) : null
|
|
2959
|
+
] }) })
|
|
2960
|
+
] }) });
|
|
2984
2961
|
};
|
|
2985
2962
|
const ScrollArea$1 = "";
|
|
2986
2963
|
const ScrollArea = ({ children, isLoading = false, className = "" }) => {
|
|
@@ -4853,11 +4830,14 @@ const ResultProduct = (props) => {
|
|
|
4853
4830
|
) }) })
|
|
4854
4831
|
] }, index);
|
|
4855
4832
|
};
|
|
4856
|
-
const
|
|
4833
|
+
const handleConditionNotUpdateFacetDistribution = (value) => {
|
|
4834
|
+
let arrPriorityFacet = ["vendor"];
|
|
4857
4835
|
let isHasFacetSelected = arrFacetSelected == null ? void 0 : arrFacetSelected.length;
|
|
4858
|
-
let
|
|
4859
|
-
let
|
|
4860
|
-
|
|
4836
|
+
let isNoneFacetSelected = !isHasFacetSelected;
|
|
4837
|
+
let isOnFacetSelectedOne = isHasFacetSelected && arrFacetSelected.includes(value) && isHasFacetSelected === 1;
|
|
4838
|
+
let isSelectedFacetWithPrice = arrFacetSelected.includes("variants.price");
|
|
4839
|
+
let isPriorityFacet = isHasFacetSelected && !isOnFacetSelectedOne && arrPriorityFacet.includes(value) && !isSelectedFacetWithPrice;
|
|
4840
|
+
return isNoneFacetSelected || isOnFacetSelectedOne || isPriorityFacet;
|
|
4861
4841
|
};
|
|
4862
4842
|
const facetComponent = (filter) => {
|
|
4863
4843
|
var _a2, _b2;
|
|
@@ -4867,6 +4847,19 @@ const ResultProduct = (props) => {
|
|
|
4867
4847
|
let blockComponent = null;
|
|
4868
4848
|
let items = searchResultFacets[value];
|
|
4869
4849
|
let isShowNumberMatchingProduct = (_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.show_number_matching_product;
|
|
4850
|
+
let itemsComponent = [];
|
|
4851
|
+
if (["checkbox", "radio", "select"].includes(display.toLowerCase()))
|
|
4852
|
+
itemsComponent = items == null ? void 0 : items.map((item) => {
|
|
4853
|
+
let labelName = item.name;
|
|
4854
|
+
if (languageSettings && (languageSettings[item.value] || languageSettings[item.name]))
|
|
4855
|
+
labelName = languageSettings[item.value] || languageSettings[item.name];
|
|
4856
|
+
let counter = handleConditionNotUpdateFacetDistribution(value) ? (item == null ? void 0 : item.total) || 0 : searchFacetDistribution[value] && searchFacetDistribution[value][item.value] ? searchFacetDistribution[value][item.value] : 0;
|
|
4857
|
+
return {
|
|
4858
|
+
...item,
|
|
4859
|
+
labelName,
|
|
4860
|
+
counter
|
|
4861
|
+
};
|
|
4862
|
+
});
|
|
4870
4863
|
if (display.toLowerCase() === "slider") {
|
|
4871
4864
|
items = defaultFacetStats[value] && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
|
|
4872
4865
|
let defaultValueMin = valueFilterPriceChange[0] || (items == null ? void 0 : items.min);
|
|
@@ -4875,16 +4868,14 @@ const ResultProduct = (props) => {
|
|
|
4875
4868
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4876
4869
|
Slider,
|
|
4877
4870
|
{
|
|
4878
|
-
|
|
4871
|
+
value: defaultValueMin === defaultValueMax ? [defaultValueMax] : [defaultValueMin, defaultValueMax],
|
|
4879
4872
|
...(items == null ? void 0 : items.min) === (items == null ? void 0 : items.max) ? {} : {
|
|
4880
4873
|
min: items == null ? void 0 : items.min
|
|
4881
4874
|
},
|
|
4882
4875
|
max: items == null ? void 0 : items.max,
|
|
4883
4876
|
step: 1,
|
|
4884
|
-
setValueCommit: (valueCommit) =>
|
|
4885
|
-
|
|
4886
|
-
handleFilterChange(value, valueCommit);
|
|
4887
|
-
}
|
|
4877
|
+
setValueCommit: (valueCommit) => handleFilterChange(value, valueCommit),
|
|
4878
|
+
setValueChange: (valueChange) => setValueFilterPriceChange(valueChange)
|
|
4888
4879
|
}
|
|
4889
4880
|
),
|
|
4890
4881
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider-minmax", children: [
|
|
@@ -4893,21 +4884,18 @@ const ResultProduct = (props) => {
|
|
|
4893
4884
|
] })
|
|
4894
4885
|
] });
|
|
4895
4886
|
} else if (display.toLowerCase() === "checkbox" && (items == null ? void 0 : items.length)) {
|
|
4896
|
-
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children:
|
|
4887
|
+
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: itemsComponent == null ? void 0 : itemsComponent.map((item, index) => {
|
|
4897
4888
|
var _a3;
|
|
4898
|
-
|
|
4899
|
-
let labelTotal = handleConditionUpdateFacetDistribution(value) ? (item == null ? void 0 : item.total) || 0 : searchFacetDistribution[value] && searchFacetDistribution[value][item.value] ? searchFacetDistribution[value][item.value] : 0;
|
|
4900
|
-
if (languageSettings && (languageSettings[item.value] || languageSettings[item.name]))
|
|
4901
|
-
labelName = languageSettings[item.value] || languageSettings[item.name];
|
|
4889
|
+
const { labelName, value: itemValue, counter } = item;
|
|
4902
4890
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4903
4891
|
Checkbox,
|
|
4904
4892
|
{
|
|
4905
4893
|
id: `${value}_${index}`,
|
|
4906
4894
|
name: value,
|
|
4907
|
-
value:
|
|
4908
|
-
label: `${labelName}${
|
|
4895
|
+
value: itemValue,
|
|
4896
|
+
label: `${labelName}${counter !== void 0 && isShowNumberMatchingProduct ? ` (${counter})` : ""}`,
|
|
4909
4897
|
onClick: (e) => handleFilterChange(value, e.currentTarget.value),
|
|
4910
|
-
checked: Boolean(clickedFacets && ((_a3 = clickedFacets[value]) == null ? void 0 : _a3.includes(
|
|
4898
|
+
checked: Boolean(clickedFacets && ((_a3 = clickedFacets[value]) == null ? void 0 : _a3.includes(itemValue))),
|
|
4911
4899
|
labelStyle: filter_option_style
|
|
4912
4900
|
}
|
|
4913
4901
|
) }, index);
|
|
@@ -4920,14 +4908,10 @@ const ResultProduct = (props) => {
|
|
|
4920
4908
|
name: value,
|
|
4921
4909
|
onValueChange: (getValue) => handleFilterChange(value, getValue, true),
|
|
4922
4910
|
items: items == null ? void 0 : items.map((item) => {
|
|
4923
|
-
const {
|
|
4924
|
-
let labelTotal = handleConditionUpdateFacetDistribution(value) ? total || 0 : searchFacetDistribution[value] && searchFacetDistribution[value][itemValue] ? searchFacetDistribution[value][itemValue] : 0;
|
|
4925
|
-
let labelName = name;
|
|
4926
|
-
if (languageSettings && (languageSettings[itemValue] || languageSettings[name]))
|
|
4927
|
-
labelName = languageSettings[itemValue] || languageSettings[name];
|
|
4911
|
+
const { labelName, value: value2, counter } = item;
|
|
4928
4912
|
return {
|
|
4929
|
-
label: `${labelName} ${
|
|
4930
|
-
value:
|
|
4913
|
+
label: `${labelName} ${counter !== void 0 && isShowNumberMatchingProduct ? ` (${counter})` : ""}`,
|
|
4914
|
+
value: value2
|
|
4931
4915
|
};
|
|
4932
4916
|
}),
|
|
4933
4917
|
defaultValue: clickedFacets && ((_b2 = clickedFacets[value]) == null ? void 0 : _b2.length) ? clickedFacets[value][0] : "",
|
|
@@ -4942,14 +4926,10 @@ const ResultProduct = (props) => {
|
|
|
4942
4926
|
name: value,
|
|
4943
4927
|
onValueChange: (getValue) => handleFilterChange(value, getValue, true),
|
|
4944
4928
|
items: items == null ? void 0 : items.map((item) => {
|
|
4945
|
-
const {
|
|
4946
|
-
let labelTotal = handleConditionUpdateFacetDistribution(value) ? total || 0 : searchFacetDistribution[value] && searchFacetDistribution[value][itemValue] ? searchFacetDistribution[value][itemValue] : 0;
|
|
4947
|
-
let labelName = name;
|
|
4948
|
-
if (languageSettings && (languageSettings[itemValue] || languageSettings[name]))
|
|
4949
|
-
labelName = languageSettings[itemValue] || languageSettings[name];
|
|
4929
|
+
const { labelName, value: value2, counter } = item;
|
|
4950
4930
|
return {
|
|
4951
|
-
label: `${labelName} ${
|
|
4952
|
-
value:
|
|
4931
|
+
label: `${labelName} ${counter !== void 0 && isShowNumberMatchingProduct ? ` (${counter})` : ""}`,
|
|
4932
|
+
value: value2
|
|
4953
4933
|
};
|
|
4954
4934
|
}),
|
|
4955
4935
|
labelStyle: filter_option_style
|