@sledge-app/react-instant-search 2.0.58 → 2.0.60
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/SearchResultWidget.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/components/Facet.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/components/FacetBlockSelected.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 +70 -33
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -590,8 +590,7 @@ const stringToSlug = (text) => {
|
|
|
590
590
|
return text;
|
|
591
591
|
return text.toLowerCase().replace(/[^\w ]+/g, "").replace(/ +/g, "-");
|
|
592
592
|
};
|
|
593
|
-
const shopifyFormatMoney = (cents, format) => {
|
|
594
|
-
var _a;
|
|
593
|
+
const shopifyFormatMoney = (cents, format, selectedLocale) => {
|
|
595
594
|
if (typeof cents == "string") {
|
|
596
595
|
cents = cents.replace(".", "");
|
|
597
596
|
}
|
|
@@ -612,19 +611,31 @@ const shopifyFormatMoney = (cents, format) => {
|
|
|
612
611
|
var parts = number.split("."), dollars = parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + thousands), cents2 = parts[1] ? decimal + parts[1] : "";
|
|
613
612
|
return dollars + cents2;
|
|
614
613
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
614
|
+
function useFormatWithDelimiters() {
|
|
615
|
+
var _a;
|
|
616
|
+
switch ((_a = formatString.match(placeholderRegex)) == null ? void 0 : _a[1]) {
|
|
617
|
+
case "amount":
|
|
618
|
+
return formatWithDelimiters(cents, 2);
|
|
619
|
+
case "amount_no_decimals":
|
|
620
|
+
return formatWithDelimiters(cents, 0);
|
|
621
|
+
case "amount_with_comma_separator":
|
|
622
|
+
return formatWithDelimiters(cents, 2, ".", ",");
|
|
623
|
+
case "amount_no_decimals_with_comma_separator":
|
|
624
|
+
return formatWithDelimiters(cents, 0, ".", ",");
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (selectedLocale) {
|
|
628
|
+
if (cents) {
|
|
629
|
+
try {
|
|
630
|
+
value = new Intl.NumberFormat(selectedLocale).format(cents / 100);
|
|
631
|
+
} catch (error) {
|
|
632
|
+
value = useFormatWithDelimiters();
|
|
633
|
+
}
|
|
634
|
+
} else {
|
|
635
|
+
value = useFormatWithDelimiters();
|
|
636
|
+
}
|
|
637
|
+
} else {
|
|
638
|
+
value = useFormatWithDelimiters();
|
|
628
639
|
}
|
|
629
640
|
return formatString.replace(placeholderRegex, value);
|
|
630
641
|
};
|
|
@@ -7044,7 +7055,7 @@ const PaginationOrLoadMore = (props) => {
|
|
|
7044
7055
|
};
|
|
7045
7056
|
const FacetBlockSelected = React__default.memo(
|
|
7046
7057
|
(props) => {
|
|
7047
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7058
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
7048
7059
|
const {
|
|
7049
7060
|
label,
|
|
7050
7061
|
name,
|
|
@@ -7060,7 +7071,7 @@ const FacetBlockSelected = React__default.memo(
|
|
|
7060
7071
|
handleFilterChange,
|
|
7061
7072
|
allowedFilterSlider
|
|
7062
7073
|
} = props;
|
|
7063
|
-
const { money_format } = generalDataSettings || {};
|
|
7074
|
+
const { money_format: money_format_props } = generalDataSettings || {};
|
|
7064
7075
|
const { separator: hierarchical_collections_separator } = hierarchicalCollectionsSettings || {};
|
|
7065
7076
|
const {
|
|
7066
7077
|
color: filter_option_color,
|
|
@@ -7100,11 +7111,17 @@ const FacetBlockSelected = React__default.memo(
|
|
|
7100
7111
|
if (defaultFilterItems == null ? void 0 : defaultFilterItems.length) {
|
|
7101
7112
|
let isSetValue = false;
|
|
7102
7113
|
defaultFilterItems.map((defaultFilterItem) => {
|
|
7103
|
-
const { label: defaultFilterItemLabel, items, settings: defaultFilterItemSettings } = defaultFilterItem;
|
|
7114
|
+
const { label: defaultFilterItemLabel, items, settings: defaultFilterItemSettings, value: defaultFilterItemValue } = defaultFilterItem;
|
|
7104
7115
|
if ((items == null ? void 0 : items.includes(value)) && !isSetValue) {
|
|
7105
7116
|
getLabel = defaultFilterItemLabel;
|
|
7106
7117
|
getSettings = defaultFilterItemSettings;
|
|
7107
7118
|
isSetValue = true;
|
|
7119
|
+
} else {
|
|
7120
|
+
if (defaultFilterItemValue === name && isRange && !isSetValue) {
|
|
7121
|
+
getLabel = defaultFilterItemLabel;
|
|
7122
|
+
getSettings = defaultFilterItemSettings;
|
|
7123
|
+
isSetValue = true;
|
|
7124
|
+
}
|
|
7108
7125
|
}
|
|
7109
7126
|
});
|
|
7110
7127
|
}
|
|
@@ -7113,12 +7130,15 @@ const FacetBlockSelected = React__default.memo(
|
|
|
7113
7130
|
valueText = String(valueText).replace(deletePrefix, "");
|
|
7114
7131
|
});
|
|
7115
7132
|
if (isRange) {
|
|
7133
|
+
let money_format = money_format_props;
|
|
7134
|
+
if (getSettings == null ? void 0 : getSettings.rounded)
|
|
7135
|
+
money_format = (_f = money_format == null ? void 0 : money_format.replace) == null ? void 0 : _f.call(money_format, /\{\{\s*amount[^}]*\}\}/g, "{{amount_no_decimals}}");
|
|
7116
7136
|
const getValueRange = new Set(value).size === 1 ? [value[0]] : value;
|
|
7117
|
-
valueText = (
|
|
7137
|
+
valueText = (_g = getValueRange == null ? void 0 : getValueRange.map((valueItem) => isPriceValue ? shopifyFormatMoney(valueItem * 100, money_format) : isSalePercent ? `${valueItem}%` : valueItem)) == null ? void 0 : _g.join(" - ");
|
|
7118
7138
|
} else {
|
|
7119
|
-
valueText = (
|
|
7139
|
+
valueText = (_h = String(valueText)) == null ? void 0 : _h.replaceAll(hierarchical_collections_separator, " > ");
|
|
7120
7140
|
}
|
|
7121
|
-
valueText = (
|
|
7141
|
+
valueText = (_i = String(valueText)) == null ? void 0 : _i.replaceAll("_", " ");
|
|
7122
7142
|
let aliases = {};
|
|
7123
7143
|
let aliasValue = "";
|
|
7124
7144
|
let aliasSeparator = "";
|
|
@@ -7783,7 +7803,7 @@ const FilterActive = (props) => {
|
|
|
7783
7803
|
) }) : null });
|
|
7784
7804
|
};
|
|
7785
7805
|
const Facet = (props) => {
|
|
7786
|
-
var _a, _b, _c, _d, _e;
|
|
7806
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7787
7807
|
const {
|
|
7788
7808
|
filter,
|
|
7789
7809
|
isFirstLoading,
|
|
@@ -7816,12 +7836,13 @@ const Facet = (props) => {
|
|
|
7816
7836
|
keepCounterFacets,
|
|
7817
7837
|
allowedFilterSlider
|
|
7818
7838
|
} = props;
|
|
7839
|
+
const { isJsVersion, locale } = React__default.useContext(SledgeContext) || {};
|
|
7819
7840
|
const [keywordFacet, setKeywordFacet] = React__default.useState("");
|
|
7820
7841
|
const [showFacet, setShowFacet] = React__default.useState(false);
|
|
7821
7842
|
const searchFacetRef = React__default.useRef(null);
|
|
7822
7843
|
const ulListRef = React__default.useRef(null);
|
|
7823
7844
|
const previousState = usePrevious({ keywordFacet });
|
|
7824
|
-
const { money_format, default_currency_symbol } = generalDataSettings || {};
|
|
7845
|
+
const { money_format: money_format_props, default_currency_symbol } = generalDataSettings || {};
|
|
7825
7846
|
const { button_load_more } = (generalDataSettings == null ? void 0 : generalDataSettings.languages) || {};
|
|
7826
7847
|
const { search_filter_placeholder, search_filter_show_more_result, search_filter_no_result, filter_select_placeholder, highest_price_info } = languageSettings || {};
|
|
7827
7848
|
const {
|
|
@@ -7838,12 +7859,15 @@ const Facet = (props) => {
|
|
|
7838
7859
|
...filter_option_text_transform && { textTransform: filter_option_text_transform }
|
|
7839
7860
|
};
|
|
7840
7861
|
let { value, label, display, indexFilter, items, settings: filterSettings } = filter;
|
|
7841
|
-
const { show_search, auto_select_search, hide_filter_list, show_all_children_items } = filterSettings || {};
|
|
7862
|
+
const { show_search, auto_select_search, hide_filter_list, show_all_children_items, rounded } = filterSettings || {};
|
|
7863
|
+
let money_format = money_format_props;
|
|
7864
|
+
if (rounded)
|
|
7865
|
+
money_format = (_b = money_format == null ? void 0 : money_format.replace) == null ? void 0 : _b.call(money_format, /\{\{\s*amount[^}]*\}\}/g, "{{amount_no_decimals}}");
|
|
7842
7866
|
const show_filter_list_when_search = !hide_filter_list;
|
|
7843
7867
|
if (isFirstLoading)
|
|
7844
7868
|
return null;
|
|
7845
7869
|
let blockComponent = null;
|
|
7846
|
-
const isShowNumberMatchingProduct = (
|
|
7870
|
+
const isShowNumberMatchingProduct = (_c = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _c.show_number_matching_product;
|
|
7847
7871
|
const isDisplaySlider = ["slider", "input_range", "slider_with_input_range"].includes(display.toLowerCase());
|
|
7848
7872
|
const isDisplayColorSwatch = ["swatch", "swatch_with_label"].includes(display.toLowerCase());
|
|
7849
7873
|
const isDisplayInputRange = display.toLowerCase() === "input_range";
|
|
@@ -8086,11 +8110,17 @@ const Facet = (props) => {
|
|
|
8086
8110
|
}
|
|
8087
8111
|
if (isDisplaySlider) {
|
|
8088
8112
|
items = (defaultFacetStats == null ? void 0 : defaultFacetStats[value]) && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
|
|
8089
|
-
if (items && ((
|
|
8113
|
+
if (items && ((_d = Object.keys(items)) == null ? void 0 : _d.length)) {
|
|
8090
8114
|
items = {
|
|
8091
8115
|
min: (items == null ? void 0 : items.min) < 0 ? 0 : items == null ? void 0 : items.min,
|
|
8092
8116
|
max: items == null ? void 0 : items.max
|
|
8093
8117
|
};
|
|
8118
|
+
if (rounded) {
|
|
8119
|
+
items = {
|
|
8120
|
+
min: Math.floor(items == null ? void 0 : items.min),
|
|
8121
|
+
max: Math.floor(items == null ? void 0 : items.max)
|
|
8122
|
+
};
|
|
8123
|
+
}
|
|
8094
8124
|
}
|
|
8095
8125
|
let valueFilterSliderChange = [];
|
|
8096
8126
|
let isPriceValue = false;
|
|
@@ -8111,9 +8141,10 @@ const Facet = (props) => {
|
|
|
8111
8141
|
defaultValueMin = (items == null ? void 0 : items.min) && Number(defaultValueMin) < Number(items == null ? void 0 : items.min) ? items == null ? void 0 : items.min : defaultValueMin;
|
|
8112
8142
|
defaultValueMax = (items == null ? void 0 : items.max) && Number(defaultValueMax) > Number(items == null ? void 0 : items.max) ? items == null ? void 0 : items.max : defaultValueMax;
|
|
8113
8143
|
}
|
|
8114
|
-
|
|
8115
|
-
let
|
|
8116
|
-
let
|
|
8144
|
+
const selectedLocale = isJsVersion ? selectedLocaleJs() : locale;
|
|
8145
|
+
let contentDefaultValueMin = isPriceValue ? shopifyFormatMoney(defaultValueMin * 100, money_format, selectedLocale) : isSalePercent ? `${defaultValueMin}%` : defaultValueMin;
|
|
8146
|
+
let contentDefaultValueMax = isPriceValue ? shopifyFormatMoney(defaultValueMax * 100, money_format, selectedLocale) : isSalePercent ? `${defaultValueMax}%` : defaultValueMax;
|
|
8147
|
+
let contentFacetStatsMax = isPriceValue ? shopifyFormatMoney((items == null ? void 0 : items.max) * 100, money_format, selectedLocale) : isSalePercent ? `${items == null ? void 0 : items.max}%` : items == null ? void 0 : items.max;
|
|
8117
8148
|
let descriptionInputRange = highest_price_info ? String(highest_price_info).replaceAll(OBJECT_DATA_STRING_KEY.PRICE_MAX_MONEY_FORMAT, contentFacetStatsMax) : `The highest price is ${contentFacetStatsMax}`;
|
|
8118
8149
|
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8119
8150
|
Slider,
|
|
@@ -8186,7 +8217,7 @@ const Facet = (props) => {
|
|
|
8186
8217
|
value: value2
|
|
8187
8218
|
};
|
|
8188
8219
|
}),
|
|
8189
|
-
value: clickedFacets && ((
|
|
8220
|
+
value: clickedFacets && ((_e = clickedFacets[value]) == null ? void 0 : _e.length) ? clickedFacets[value][0] : "",
|
|
8190
8221
|
labelStyle: filter_option_style,
|
|
8191
8222
|
useVirtualized: true,
|
|
8192
8223
|
selector: scrollElementSelector,
|
|
@@ -8214,7 +8245,7 @@ const Facet = (props) => {
|
|
|
8214
8245
|
value: value2
|
|
8215
8246
|
};
|
|
8216
8247
|
}),
|
|
8217
|
-
defaultValue: clickedFacets && ((
|
|
8248
|
+
defaultValue: clickedFacets && ((_f = clickedFacets[value]) == null ? void 0 : _f.length) ? clickedFacets[value][0] : "",
|
|
8218
8249
|
labelStyle: filter_option_style,
|
|
8219
8250
|
loadMoreText: button_load_more || "Load More",
|
|
8220
8251
|
useLoadMore: true
|
|
@@ -9333,8 +9364,14 @@ const SearchResultWidget = (props) => {
|
|
|
9333
9364
|
const { value, label, display, settings: settings2 } = filter;
|
|
9334
9365
|
const { prefix, filter_list, selected_filter } = settings2 || {};
|
|
9335
9366
|
const isDisplaySlider = ["slider", "input_range", "slider_with_input_range"].includes(display.toLowerCase());
|
|
9336
|
-
if (isDisplaySlider)
|
|
9337
|
-
return
|
|
9367
|
+
if (isDisplaySlider) {
|
|
9368
|
+
return {
|
|
9369
|
+
value,
|
|
9370
|
+
label,
|
|
9371
|
+
settings: settings2,
|
|
9372
|
+
index
|
|
9373
|
+
};
|
|
9374
|
+
}
|
|
9338
9375
|
let items = [];
|
|
9339
9376
|
if (display.toLowerCase() === "tree") {
|
|
9340
9377
|
for (let level = 0; level < MAX_LIMIT_HIERARCHICAL; level++) {
|