@sledge-app/react-instant-search 2.0.33 → 2.0.35
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/utils.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 +27 -11
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -6681,11 +6681,12 @@ const keyOpenFilters = ({ items = [] }) => {
|
|
|
6681
6681
|
}).filter((item) => item) : [];
|
|
6682
6682
|
};
|
|
6683
6683
|
const handleSearchResponse = async (props) => {
|
|
6684
|
+
var _a, _b, _c;
|
|
6684
6685
|
const {
|
|
6685
6686
|
layoutType = "default",
|
|
6686
6687
|
clickedTabIndexId,
|
|
6687
6688
|
clickedTabIndexType = "product",
|
|
6688
|
-
keyword,
|
|
6689
|
+
keyword: keywordProp,
|
|
6689
6690
|
sort = [],
|
|
6690
6691
|
page = 1,
|
|
6691
6692
|
limit = 1,
|
|
@@ -6709,6 +6710,7 @@ const handleSearchResponse = async (props) => {
|
|
|
6709
6710
|
tabs = [],
|
|
6710
6711
|
instantSearchSettings
|
|
6711
6712
|
} = props;
|
|
6713
|
+
let keyword = keywordProp;
|
|
6712
6714
|
const isResultForProduct = clickedTabIndexType === "product";
|
|
6713
6715
|
const isTypeCategoryHasPublished = ({ usePublishedFilter: usePublishedFilter2, type }) => Boolean(usePublishedFilter2 && type && ["collection", "page", "article"].includes(type));
|
|
6714
6716
|
const { separator: hierarchical_separator, hiddens: hierarchical_hiddens } = hierarchicalProductTypeSettings || {};
|
|
@@ -6718,6 +6720,17 @@ const handleSearchResponse = async (props) => {
|
|
|
6718
6720
|
hidden_ids: hierarchical_collections_hidden_ids,
|
|
6719
6721
|
structure: hierarchical_collections_structure
|
|
6720
6722
|
} = hierarchicalCollectionsSettings || {};
|
|
6723
|
+
const searchableAttributes = ((_a = instantSearchSettings == null ? void 0 : instantSearchSettings.search_field_priority) == null ? void 0 : _a.length) ? (_c = (_b = instantSearchSettings.search_field_priority.map((item) => {
|
|
6724
|
+
if (!(item == null ? void 0 : item.active))
|
|
6725
|
+
return;
|
|
6726
|
+
return item == null ? void 0 : item.value;
|
|
6727
|
+
})) == null ? void 0 : _b.filter) == null ? void 0 : _c.call(_b, (item) => item) : [];
|
|
6728
|
+
const isContainsFilter = (instantSearchSettings == null ? void 0 : instantSearchSettings.contains_filter) && (searchableAttributes == null ? void 0 : searchableAttributes.length) && (keywordProp == null ? void 0 : keywordProp.length);
|
|
6729
|
+
let containsFilter = null;
|
|
6730
|
+
if (isContainsFilter) {
|
|
6731
|
+
containsFilter = searchableAttributes.map((item) => `'${item}' CONTAINS ${JSON.stringify(keywordProp)}`).join(" OR ");
|
|
6732
|
+
keyword = "";
|
|
6733
|
+
}
|
|
6721
6734
|
let response;
|
|
6722
6735
|
let filterProduct = createQueryFilter({
|
|
6723
6736
|
facets,
|
|
@@ -6740,7 +6753,8 @@ const handleSearchResponse = async (props) => {
|
|
|
6740
6753
|
additional: [
|
|
6741
6754
|
(hiddenTags == null ? void 0 : hiddenTags.length) ? `'tags' NOT IN ${JSON.stringify(hiddenTags)}` : null,
|
|
6742
6755
|
collectionId ? `'collections.id' = '${collectionId}'` : null,
|
|
6743
|
-
!showOutOfStock ? `'availability' IN ${JSON.stringify(["in stock"])}` : null
|
|
6756
|
+
!showOutOfStock ? `'availability' IN ${JSON.stringify(["in stock"])}` : null,
|
|
6757
|
+
containsFilter
|
|
6744
6758
|
],
|
|
6745
6759
|
allowedFilterSlider,
|
|
6746
6760
|
hierarchicalFacetAliases,
|
|
@@ -9454,7 +9468,7 @@ const SearchResultWidget = (props) => {
|
|
|
9454
9468
|
return;
|
|
9455
9469
|
};
|
|
9456
9470
|
const handleSettings = ({ LOCAL_STORAGE_INSTANT_SEARCH_SETTING, isPreviewSettings = false }) => {
|
|
9457
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
9471
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
|
|
9458
9472
|
setIsLoadingSetting(true);
|
|
9459
9473
|
let response;
|
|
9460
9474
|
let responseGeneral;
|
|
@@ -9504,9 +9518,11 @@ const SearchResultWidget = (props) => {
|
|
|
9504
9518
|
setHiddenTags(hidden_tags);
|
|
9505
9519
|
setDisplaySettings(display);
|
|
9506
9520
|
setColorSwatches(colors);
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9521
|
+
let valueDefaultSort = (searchParams == null ? void 0 : searchParams.get(querySortBy)) ? searchParams == null ? void 0 : searchParams.get(querySortBy) : collectionId ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collectionId)) : collections_all_id ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collections_all_id)) : String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID) ? (_a2 = valueAllowedSorts[0]) == null ? void 0 : _a2.value : default_sort;
|
|
9522
|
+
if (!((_d2 = (_c2 = (_b2 = allowed_sorts == null ? void 0 : allowed_sorts.map) == null ? void 0 : _b2.call(allowed_sorts, (item) => item.value)) == null ? void 0 : _c2.includes) == null ? void 0 : _d2.call(_c2, default_sort))) {
|
|
9523
|
+
valueDefaultSort = (_e2 = valueAllowedSorts == null ? void 0 : valueAllowedSorts[0]) == null ? void 0 : _e2.value;
|
|
9524
|
+
}
|
|
9525
|
+
setDefaultSort(valueDefaultSort);
|
|
9510
9526
|
setDefaultLimit(instantSearchPreviewSettings ? limit : (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT)) || limit);
|
|
9511
9527
|
setLanguageSettings(languages);
|
|
9512
9528
|
setHierarchicalProductTypeSettings(hierarchical_product_type);
|
|
@@ -9518,7 +9534,7 @@ const SearchResultWidget = (props) => {
|
|
|
9518
9534
|
setShowOutOfStock(show_out_of_stock);
|
|
9519
9535
|
setTabs(tabs2);
|
|
9520
9536
|
if (!clickedTabIndexId) {
|
|
9521
|
-
getFirstIndex = (
|
|
9537
|
+
getFirstIndex = (_f2 = tabs2 == null ? void 0 : tabs2.find) == null ? void 0 : _f2.call(tabs2, ({ index }) => index.includes(index_product));
|
|
9522
9538
|
if (Object.keys(getFirstIndex).length) {
|
|
9523
9539
|
setClickedTabIndexId(getFirstIndex.index);
|
|
9524
9540
|
setClickedTabIndexName(getFirstIndex.name);
|
|
@@ -9527,12 +9543,12 @@ const SearchResultWidget = (props) => {
|
|
|
9527
9543
|
}
|
|
9528
9544
|
setIsLoadingSetting(false);
|
|
9529
9545
|
if (isPreviewSettings) {
|
|
9530
|
-
let valueHideFilterWhenOneValue = ((
|
|
9546
|
+
let valueHideFilterWhenOneValue = ((_g2 = display == null ? void 0 : display.filter) == null ? void 0 : _g2.hide_when_one_value) && totalHitsProduct <= 1;
|
|
9531
9547
|
const { isSetFilter, valueAllowedFilter, valueDefaultFilterItems, valueAllowedFilterSlider, valueHierarchicalFacetAliases } = handleFilterStates({
|
|
9532
9548
|
data: response,
|
|
9533
9549
|
valueSearchResultFacets: searchResultFacets
|
|
9534
9550
|
});
|
|
9535
|
-
if (!(!((
|
|
9551
|
+
if (!(!((_h2 = display == null ? void 0 : display.filter) == null ? void 0 : _h2.enable_on_search) || valueHideFilterWhenOneValue)) {
|
|
9536
9552
|
if (isSetFilter)
|
|
9537
9553
|
setAllowedFilter(valueAllowedFilter);
|
|
9538
9554
|
if (valueAllowedFilter == null ? void 0 : valueAllowedFilter.length) {
|
|
@@ -9542,7 +9558,7 @@ const SearchResultWidget = (props) => {
|
|
|
9542
9558
|
}
|
|
9543
9559
|
}
|
|
9544
9560
|
setAllowedTabs(
|
|
9545
|
-
(
|
|
9561
|
+
(_k2 = (_j2 = (_i2 = tabs2 == null ? void 0 : tabs2.map) == null ? void 0 : _i2.call(tabs2, (allowedTab) => {
|
|
9546
9562
|
var _a3, _b3;
|
|
9547
9563
|
const { type } = allowedTab;
|
|
9548
9564
|
const total = ((_b3 = (_a3 = allowedTabs == null ? void 0 : allowedTabs.find) == null ? void 0 : _a3.call(allowedTabs, (tab) => (tab == null ? void 0 : tab.type) === type)) == null ? void 0 : _b3.total) || 0;
|
|
@@ -9552,7 +9568,7 @@ const SearchResultWidget = (props) => {
|
|
|
9552
9568
|
total
|
|
9553
9569
|
}
|
|
9554
9570
|
};
|
|
9555
|
-
})) == null ? void 0 :
|
|
9571
|
+
})) == null ? void 0 : _j2.filter) == null ? void 0 : _k2.call(_j2, (item) => item)
|
|
9556
9572
|
);
|
|
9557
9573
|
}
|
|
9558
9574
|
};
|