@sledge-app/react-instant-search 1.0.92 → 1.0.94
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/dist/components/SearchResultWidget/Atoms.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts.map +1 -1
- package/dist/sledge-react-instant-search.cjs +1 -1
- package/dist/sledge-react-instant-search.cjs.map +1 -1
- package/dist/sledge-react-instant-search.js +68 -22
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -644,7 +644,8 @@ const Checkbox = ({ id, name, value, required, label, checked, labelStyle = {},
|
|
|
644
644
|
};
|
|
645
645
|
const Slider$1 = "";
|
|
646
646
|
const Slider = (props) => {
|
|
647
|
-
const { value, min, max, step = 1, setValueCommit, setValueChange } = props;
|
|
647
|
+
const { value, textValue = [], min, max, step = 1, setValueCommit, setValueChange } = props;
|
|
648
|
+
let content = (textValue == null ? void 0 : textValue.length) ? textValue : value;
|
|
648
649
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("form", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
649
650
|
$faa2e61a3361514f$export$be92b6f5f03c0fe9,
|
|
650
651
|
{
|
|
@@ -663,7 +664,11 @@ const Slider = (props) => {
|
|
|
663
664
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
664
665
|
Tooltip,
|
|
665
666
|
{
|
|
666
|
-
|
|
667
|
+
...(textValue == null ? void 0 : textValue.length) ? {
|
|
668
|
+
innerHTMLContent: content[0]
|
|
669
|
+
} : {
|
|
670
|
+
content: content[0]
|
|
671
|
+
},
|
|
667
672
|
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>`,
|
|
668
673
|
wrapTrigger: false,
|
|
669
674
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb" })
|
|
@@ -672,7 +677,11 @@ const Slider = (props) => {
|
|
|
672
677
|
!value[1] ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
673
678
|
Tooltip,
|
|
674
679
|
{
|
|
675
|
-
|
|
680
|
+
...(textValue == null ? void 0 : textValue.length) ? {
|
|
681
|
+
innerHTMLContent: content[1]
|
|
682
|
+
} : {
|
|
683
|
+
content: content[1]
|
|
684
|
+
},
|
|
676
685
|
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>`,
|
|
677
686
|
wrapTrigger: false,
|
|
678
687
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb" })
|
|
@@ -2918,6 +2927,16 @@ const ProductCard = (props) => {
|
|
|
2918
2927
|
const [selectedVariantStock, setSelectedVariantStock] = React__default.useState(defaultSelectedVariantStock);
|
|
2919
2928
|
const [selectedVariantInventoryManagement, setSelectedVariantInventoryManagement] = React__default.useState(defaultSelectedVariantInventoryManagement);
|
|
2920
2929
|
const [selectedVariantInventoryPolicy, setSelectedVariantInventoryPolicy] = React__default.useState(defaultSelectedVariantInventoryPolicy);
|
|
2930
|
+
const [hasEntryImage, setHasEntryImage] = React__default.useState(false);
|
|
2931
|
+
const [imageRef, imageEntry] = useIntersectionObserver({
|
|
2932
|
+
threshold: 0.1,
|
|
2933
|
+
root: null,
|
|
2934
|
+
rootMargin: "0px"
|
|
2935
|
+
});
|
|
2936
|
+
React__default.useEffect(() => {
|
|
2937
|
+
if (!hasEntryImage && (imageEntry == null ? void 0 : imageEntry.isIntersecting))
|
|
2938
|
+
setHasEntryImage(imageEntry == null ? void 0 : imageEntry.isIntersecting);
|
|
2939
|
+
}, [imageEntry]);
|
|
2921
2940
|
let isLoadingAddToCart = clickedAddToCartId == selectedVariantId;
|
|
2922
2941
|
let isOutOfStock = showOptionOutOfStock ? !Boolean(selectedVariantStock > 0 || selectedVariantInventoryManagement === null || selectedVariantInventoryPolicy === "continue") : false;
|
|
2923
2942
|
let isOnSale = parseFloat(String(compare_at_price)) ? parseFloat(String(compare_at_price)) > parseFloat(String(price)) : false;
|
|
@@ -3076,10 +3095,16 @@ const ProductCard = (props) => {
|
|
|
3076
3095
|
wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
|
|
3077
3096
|
}
|
|
3078
3097
|
),
|
|
3079
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3098
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-featured-image-element", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3080
3099
|
"img",
|
|
3081
3100
|
{
|
|
3082
|
-
|
|
3101
|
+
ref: imageRef,
|
|
3102
|
+
...hasEntryImage ? {
|
|
3103
|
+
src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
|
|
3104
|
+
["loaded"]: ""
|
|
3105
|
+
} : {
|
|
3106
|
+
["data-src"]: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`
|
|
3107
|
+
},
|
|
3083
3108
|
alt: "sledge-card-image",
|
|
3084
3109
|
loading: "lazy",
|
|
3085
3110
|
className: "sledge__product-grid-card-image-featured-image",
|
|
@@ -3090,7 +3115,7 @@ const ProductCard = (props) => {
|
|
|
3090
3115
|
currentTarget.src = `${CDN_URL}/images/blank-image.png`;
|
|
3091
3116
|
}
|
|
3092
3117
|
}
|
|
3093
|
-
),
|
|
3118
|
+
) }),
|
|
3094
3119
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: images == null ? void 0 : images.map((image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3095
3120
|
"img",
|
|
3096
3121
|
{
|
|
@@ -3324,7 +3349,7 @@ const ProductGrid = (props) => {
|
|
|
3324
3349
|
onAfterRenderProduct && onAfterRenderProduct("success");
|
|
3325
3350
|
handleSettings();
|
|
3326
3351
|
}, []);
|
|
3327
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: `sledge__product-grid ${className}`, ...carouselSourceProp, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
|
|
3352
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: `sledge__product-grid ${className}`, ...carouselSourceProp, "data-grid-type": type, "data-custom-card": Boolean(props == null ? void 0 : props.cards), children: data == null ? void 0 : data.map((item, index) => {
|
|
3328
3353
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3329
3354
|
ProductCard,
|
|
3330
3355
|
{
|
|
@@ -3450,7 +3475,7 @@ const ArticleGrid = ({ className = "", data, cards: CardsComponent, isComponentJ
|
|
|
3450
3475
|
}) }) });
|
|
3451
3476
|
};
|
|
3452
3477
|
const Tooltip$1 = "";
|
|
3453
|
-
const Tooltip = ({ children, content, withArrow = true, customArrow = "", sideOffset = 5, alignOffset = 0, wrapTrigger = true }) => {
|
|
3478
|
+
const Tooltip = ({ children, content = null, innerHTMLContent = "", withArrow = true, customArrow = "", sideOffset = 5, alignOffset = 0, wrapTrigger = true }) => {
|
|
3454
3479
|
const [open, setOpen] = React__default.useState(false);
|
|
3455
3480
|
React__default.useEffect(() => {
|
|
3456
3481
|
var _a;
|
|
@@ -3464,6 +3489,7 @@ const Tooltip = ({ children, content, withArrow = true, customArrow = "", sideOf
|
|
|
3464
3489
|
/* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: wrapTrigger ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children }) : children }),
|
|
3465
3490
|
/* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { className: "sledge__tooltip-content", sideOffset, alignOffset, children: [
|
|
3466
3491
|
content,
|
|
3492
|
+
innerHTMLContent && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: innerHTMLContent } }),
|
|
3467
3493
|
withArrow ? /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$21b07c8f274aebd5, { className: "sledge__tooltip-arrow" }) : null
|
|
3468
3494
|
] }) })
|
|
3469
3495
|
] }) });
|
|
@@ -4673,7 +4699,7 @@ const handleFacetValues = ({
|
|
|
4673
4699
|
return facetValues;
|
|
4674
4700
|
};
|
|
4675
4701
|
const FacetComponent = (props) => {
|
|
4676
|
-
var _a, _b, _c;
|
|
4702
|
+
var _a, _b, _c, _d;
|
|
4677
4703
|
const {
|
|
4678
4704
|
filter,
|
|
4679
4705
|
isFirstLoading,
|
|
@@ -4706,6 +4732,7 @@ const FacetComponent = (props) => {
|
|
|
4706
4732
|
const [showFacet, setShowFacet] = React__default.useState(false);
|
|
4707
4733
|
const searchFacetRef = React__default.useRef(null);
|
|
4708
4734
|
const previousState = usePrevious({ keywordFacet });
|
|
4735
|
+
const { money_format } = generalDataSettings || {};
|
|
4709
4736
|
const { button_load_more } = (generalDataSettings == null ? void 0 : generalDataSettings.languages) || {};
|
|
4710
4737
|
const { search_filter_placeholder, search_filter_show_more_result, search_filter_no_result } = languageSettings || {};
|
|
4711
4738
|
const {
|
|
@@ -4925,19 +4952,32 @@ const FacetComponent = (props) => {
|
|
|
4925
4952
|
}
|
|
4926
4953
|
if (isDisplaySlider) {
|
|
4927
4954
|
items = (defaultFacetStats == null ? void 0 : defaultFacetStats[value]) && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
|
|
4955
|
+
if (items && ((_c = Object.keys(items)) == null ? void 0 : _c.length)) {
|
|
4956
|
+
items = {
|
|
4957
|
+
min: (items == null ? void 0 : items.min) < 0 ? 0 : items == null ? void 0 : items.min,
|
|
4958
|
+
max: items == null ? void 0 : items.max
|
|
4959
|
+
};
|
|
4960
|
+
}
|
|
4928
4961
|
let valueFilterSliderChange = [];
|
|
4962
|
+
let isPriceValue = false;
|
|
4963
|
+
let isSalePercent = false;
|
|
4929
4964
|
if (value === "variants.price") {
|
|
4930
4965
|
valueFilterSliderChange = valueFilterPriceChange;
|
|
4966
|
+
isPriceValue = true;
|
|
4931
4967
|
} else if (value === "variants.sale_percent") {
|
|
4932
4968
|
valueFilterSliderChange = valueFilterOnSaleChange;
|
|
4969
|
+
isSalePercent = true;
|
|
4933
4970
|
}
|
|
4934
4971
|
let defaultValueMin = (valueFilterSliderChange == null ? void 0 : valueFilterSliderChange[0]) || (items == null ? void 0 : items.min);
|
|
4935
4972
|
let defaultValueMax = (valueFilterSliderChange == null ? void 0 : valueFilterSliderChange[1]) || (items == null ? void 0 : items.max);
|
|
4973
|
+
let contentDefaultValueMin = isPriceValue ? shopifyFormatMoney(defaultValueMin * 100, money_format) : isSalePercent ? `${defaultValueMin}%` : defaultValueMin;
|
|
4974
|
+
let contentDefaultValueMax = isPriceValue ? shopifyFormatMoney(defaultValueMax * 100, money_format) : isSalePercent ? `${defaultValueMax}%` : defaultValueMax;
|
|
4936
4975
|
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider", children: [
|
|
4937
4976
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4938
4977
|
Slider,
|
|
4939
4978
|
{
|
|
4940
4979
|
value: defaultValueMin === defaultValueMax ? [defaultValueMax] : [defaultValueMin, defaultValueMax],
|
|
4980
|
+
textValue: defaultValueMin === defaultValueMax ? [contentDefaultValueMax] : [contentDefaultValueMin, contentDefaultValueMax],
|
|
4941
4981
|
...(items == null ? void 0 : items.min) === (items == null ? void 0 : items.max) ? {} : {
|
|
4942
4982
|
min: items == null ? void 0 : items.min
|
|
4943
4983
|
},
|
|
@@ -4957,8 +4997,8 @@ const FacetComponent = (props) => {
|
|
|
4957
4997
|
}
|
|
4958
4998
|
),
|
|
4959
4999
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider-minmax", children: [
|
|
4960
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field",
|
|
4961
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field",
|
|
5000
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", dangerouslySetInnerHTML: { __html: contentDefaultValueMin } }),
|
|
5001
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", dangerouslySetInnerHTML: { __html: contentDefaultValueMax } })
|
|
4962
5002
|
] })
|
|
4963
5003
|
] });
|
|
4964
5004
|
} else if ((display.toLowerCase() === "checkbox" || display.toLowerCase() === "tree") && (currentItems == null ? void 0 : currentItems.length)) {
|
|
@@ -4996,7 +5036,7 @@ const FacetComponent = (props) => {
|
|
|
4996
5036
|
value: value2
|
|
4997
5037
|
};
|
|
4998
5038
|
}),
|
|
4999
|
-
defaultValue: clickedFacets && ((
|
|
5039
|
+
defaultValue: clickedFacets && ((_d = clickedFacets[value]) == null ? void 0 : _d.length) ? clickedFacets[value][0] : "",
|
|
5000
5040
|
labelStyle: filter_option_style,
|
|
5001
5041
|
useVirtualized: true,
|
|
5002
5042
|
selector: scrollElementSelector,
|
|
@@ -5384,14 +5424,16 @@ const SearchResultWidget = (props) => {
|
|
|
5384
5424
|
let valueAllowedFilter = [];
|
|
5385
5425
|
if (!isSetFilter)
|
|
5386
5426
|
allowedFilters == null ? void 0 : allowedFilters.map((filter) => {
|
|
5387
|
-
const { collections, items } = filter;
|
|
5427
|
+
const { active, collections, items } = filter;
|
|
5428
|
+
if (!active)
|
|
5429
|
+
return;
|
|
5388
5430
|
const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => {
|
|
5389
5431
|
return {
|
|
5390
5432
|
...otherItem,
|
|
5391
5433
|
value: (otherItem == null ? void 0 : otherItem.display) === "tree" ? HIERARCHICAL_FACET_OBJECT_ALIASES[value] : value
|
|
5392
5434
|
};
|
|
5393
5435
|
});
|
|
5394
|
-
if (collectionId && (collections == null ? void 0 : collections.includes(
|
|
5436
|
+
if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
|
|
5395
5437
|
isSetFilter = true;
|
|
5396
5438
|
valueAllowedFilter = newItems;
|
|
5397
5439
|
} else {
|
|
@@ -5414,7 +5456,7 @@ const SearchResultWidget = (props) => {
|
|
|
5414
5456
|
let items = [];
|
|
5415
5457
|
if (display2.toLowerCase() === "tree") {
|
|
5416
5458
|
for (let level = 0; level < MAX_LIMIT_HIERARCHICAL; level++) {
|
|
5417
|
-
items = [...items, ...valueSearchResultFacets[`${value}.lvl${level}`]];
|
|
5459
|
+
items = [...items, ...(valueSearchResultFacets == null ? void 0 : valueSearchResultFacets[`${value}.lvl${level}`]) || []];
|
|
5418
5460
|
}
|
|
5419
5461
|
} else {
|
|
5420
5462
|
items = valueSearchResultFacets[value];
|
|
@@ -6002,6 +6044,7 @@ const ResultProduct = (props) => {
|
|
|
6002
6044
|
} = languageSettings || {};
|
|
6003
6045
|
const { separator: hierarchical_separator, hiddens: hierarchical_hiddens } = hierarchicalProductTypeSettings || {};
|
|
6004
6046
|
const { separator: hierarchical_collections_separator, hiddens: hierarchical_collections_hiddens } = hierarchicalCollectionsSettings || {};
|
|
6047
|
+
const { money_format } = generalDataSettings || {};
|
|
6005
6048
|
const { button_load_more, button_loading, mobile_sort_placeholder } = (generalDataSettings == null ? void 0 : generalDataSettings.languages) || {};
|
|
6006
6049
|
const summaryTextGenerator = (totalResult) => {
|
|
6007
6050
|
var _a2;
|
|
@@ -6332,10 +6375,17 @@ const ResultProduct = (props) => {
|
|
|
6332
6375
|
});
|
|
6333
6376
|
const facetBlockSelected = ({ label, name, value, index }) => {
|
|
6334
6377
|
var _a2, _b2, _c2;
|
|
6335
|
-
let valueText = value;
|
|
6378
|
+
let valueText = (languageSettings == null ? void 0 : languageSettings[value]) || value;
|
|
6336
6379
|
let isRange = ["variants.price", "variants.sale_percent"].includes(name);
|
|
6337
6380
|
let getLabel = label;
|
|
6338
6381
|
let getSettings = {};
|
|
6382
|
+
let isPriceValue = false;
|
|
6383
|
+
let isSalePercent = false;
|
|
6384
|
+
if (name === "variants.price") {
|
|
6385
|
+
isPriceValue = true;
|
|
6386
|
+
} else if (name === "variants.sale_percent") {
|
|
6387
|
+
isSalePercent = true;
|
|
6388
|
+
}
|
|
6339
6389
|
if (defaultFilterItems == null ? void 0 : defaultFilterItems.length) {
|
|
6340
6390
|
defaultFilterItems.map((defaultFilterItem) => {
|
|
6341
6391
|
const { label: defaultFilterItemLabel, items, settings: defaultFilterItemSettings } = defaultFilterItem;
|
|
@@ -6350,7 +6400,7 @@ const ResultProduct = (props) => {
|
|
|
6350
6400
|
valueText = String(valueText).replace(deletePrefix, "");
|
|
6351
6401
|
});
|
|
6352
6402
|
if (isRange)
|
|
6353
|
-
valueText = value == null ? void 0 : value.join(" - ");
|
|
6403
|
+
valueText = value == null ? void 0 : value.map((valueItem) => isPriceValue ? shopifyFormatMoney(valueItem * 100, money_format) : isSalePercent ? `${valueItem}%` : valueItem).join(" - ");
|
|
6354
6404
|
else
|
|
6355
6405
|
valueText = (_b2 = String(valueText)) == null ? void 0 : _b2.replaceAll(hierarchical_collections_separator, " > ");
|
|
6356
6406
|
valueText = (_c2 = String(valueText)) == null ? void 0 : _c2.replaceAll("_", " ");
|
|
@@ -6374,11 +6424,7 @@ const ResultProduct = (props) => {
|
|
|
6374
6424
|
aliasValue = newSplitedValues.join(" > ");
|
|
6375
6425
|
}
|
|
6376
6426
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-refine-selected", style: filter_option_style, children: [
|
|
6377
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
6378
|
-
getLabel,
|
|
6379
|
-
": ",
|
|
6380
|
-
aliasValue || valueText
|
|
6381
|
-
] }),
|
|
6427
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-item-title-refine-list", dangerouslySetInnerHTML: { __html: `${getLabel}: ${aliasValue || valueText}` } }),
|
|
6382
6428
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6383
6429
|
"span",
|
|
6384
6430
|
{
|