@sledge-app/react-instant-search 1.0.102 → 1.0.104
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/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidget.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 +20 -18
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -4161,7 +4161,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
4161
4161
|
const previousState = usePrevious({ keyword });
|
|
4162
4162
|
const { direction: redirectObjectDirection } = redirectObject || {};
|
|
4163
4163
|
const handleMultiSearch = async (params) => {
|
|
4164
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
4164
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2;
|
|
4165
4165
|
const { data, onSearch = false, withFetchReviewInfo = false } = params;
|
|
4166
4166
|
const valueRedirectObject = redirectsSettings.find(({ keyword: redirectKeyword }) => {
|
|
4167
4167
|
var _a3;
|
|
@@ -4173,6 +4173,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
4173
4173
|
setIsLoading(true);
|
|
4174
4174
|
const { index_product, tabs, hidden_tags, display, show_out_of_stock, attributes_to_retrieve } = data;
|
|
4175
4175
|
const suggestion = ((_b2 = display == null ? void 0 : display.search) == null ? void 0 : _b2.suggestion) || {};
|
|
4176
|
+
const instantSearchLimit = Number(((_c2 = display == null ? void 0 : display.search) == null ? void 0 : _c2.instantsearch_limit) || 6);
|
|
4176
4177
|
let response;
|
|
4177
4178
|
let body = {
|
|
4178
4179
|
queries: tabs.map((tab) => {
|
|
@@ -4186,7 +4187,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
4186
4187
|
return {
|
|
4187
4188
|
indexUid: index,
|
|
4188
4189
|
q: keyword,
|
|
4189
|
-
hitsPerPage: isProductIndex ?
|
|
4190
|
+
hitsPerPage: isProductIndex ? instantSearchLimit : 4,
|
|
4190
4191
|
filter: isProductIndex ? [...new Set(additionalFilter)].join(" AND ") : "",
|
|
4191
4192
|
attributesToRetrieve: attributes_to_retrieve
|
|
4192
4193
|
};
|
|
@@ -4197,14 +4198,14 @@ const SearchIconWidgetPopup = () => {
|
|
|
4197
4198
|
return;
|
|
4198
4199
|
const { results } = response;
|
|
4199
4200
|
let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(index_product));
|
|
4200
|
-
setTotalHitsProduct(((
|
|
4201
|
+
setTotalHitsProduct(((_d2 = valueSearchResultProduct[0]) == null ? void 0 : _d2.totalHits) || 0);
|
|
4201
4202
|
if (onSearch && (keyword == null ? void 0 : keyword.length)) {
|
|
4202
4203
|
searchTrigger({
|
|
4203
4204
|
keyword,
|
|
4204
|
-
resultCount: ((
|
|
4205
|
+
resultCount: ((_e2 = valueSearchResultProduct[0]) == null ? void 0 : _e2.totalHits) || 0
|
|
4205
4206
|
});
|
|
4206
4207
|
}
|
|
4207
|
-
let valueSearchResultOther = ((
|
|
4208
|
+
let valueSearchResultOther = ((_f2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _f2.map((result) => {
|
|
4208
4209
|
const { indexUid } = result;
|
|
4209
4210
|
const { name, type } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
|
|
4210
4211
|
return {
|
|
@@ -4215,16 +4216,16 @@ const SearchIconWidgetPopup = () => {
|
|
|
4215
4216
|
}
|
|
4216
4217
|
};
|
|
4217
4218
|
})) || [];
|
|
4218
|
-
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (
|
|
4219
|
+
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_g2 = valueSearchResultProduct[0]) == null ? void 0 : _g2.hits : [];
|
|
4219
4220
|
let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
|
|
4220
4221
|
let isPriorityZeroCharacter = Boolean(
|
|
4221
|
-
!keyword.length && Object.keys(suggestion).length && ((
|
|
4222
|
+
!keyword.length && Object.keys(suggestion).length && ((_i2 = (_h2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _h2.products) == null ? void 0 : _i2.active) && ((_l2 = (_k2 = (_j2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _j2.products) == null ? void 0 : _k2.list) == null ? void 0 : _l2.length)
|
|
4222
4223
|
);
|
|
4223
|
-
let dataSearchResultProduct = isPriorityZeroCharacter ? (
|
|
4224
|
+
let dataSearchResultProduct = isPriorityZeroCharacter ? (_n2 = (_m2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _m2.products) == null ? void 0 : _n2.list : getValueSearchResultProduct;
|
|
4224
4225
|
if (withFetchReviewInfo) {
|
|
4225
4226
|
let searchResultProductIds = dataSearchResultProduct.map(({ id }) => id);
|
|
4226
4227
|
let valueDataReviews = await getProductsReviewInfo(searchResultProductIds);
|
|
4227
|
-
if (((
|
|
4228
|
+
if (((_o2 = valueDataReviews == null ? void 0 : valueDataReviews.status) == null ? void 0 : _o2.code) === 200)
|
|
4228
4229
|
setDataReviews(valueDataReviews == null ? void 0 : valueDataReviews.data);
|
|
4229
4230
|
} else {
|
|
4230
4231
|
setDataReviews({});
|
|
@@ -6705,7 +6706,7 @@ const ResultProduct = (props) => {
|
|
|
6705
6706
|
withClearField: true
|
|
6706
6707
|
}
|
|
6707
6708
|
);
|
|
6708
|
-
const
|
|
6709
|
+
const renderFilterLayoutOnMobile = () => {
|
|
6709
6710
|
var _a2;
|
|
6710
6711
|
switch ((_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.mobile_layout) {
|
|
6711
6712
|
case "flyout":
|
|
@@ -6768,7 +6769,7 @@ const ResultProduct = (props) => {
|
|
|
6768
6769
|
}
|
|
6769
6770
|
),
|
|
6770
6771
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-lg-on-mobile sledge-instant-search__search-field-lg", children: searchInputFieldComponent }),
|
|
6771
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-mobile-on-lg sledge-instant-search__filter-horizontal-block-mobile", children:
|
|
6772
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-mobile-on-lg sledge-instant-search__filter-horizontal-block-mobile", children: renderFilterLayoutOnMobile() }),
|
|
6772
6773
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-summary-item sledge-instant-search__result-data-summary-select-field", children: [
|
|
6773
6774
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-summary-select-field-item", children: [
|
|
6774
6775
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-data-summary-select-field-sort", children: [
|
|
@@ -7070,7 +7071,7 @@ const SearchWidget = (props) => {
|
|
|
7070
7071
|
const searchFieldRef = React__default.useRef(null);
|
|
7071
7072
|
const { direction: redirectObjectDirection } = redirectObject || {};
|
|
7072
7073
|
const handleMultiSearch = async (data, onSearch = false) => {
|
|
7073
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
|
|
7074
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2;
|
|
7074
7075
|
if (!keyword.length)
|
|
7075
7076
|
return;
|
|
7076
7077
|
const valueRedirectObject = redirectsSettings.find(({ keyword: redirectKeyword }) => {
|
|
@@ -7083,6 +7084,7 @@ const SearchWidget = (props) => {
|
|
|
7083
7084
|
setIsLoading(true);
|
|
7084
7085
|
const { index_product, tabs, hidden_tags, display, show_out_of_stock, attributes_to_retrieve } = data;
|
|
7085
7086
|
const suggestion = ((_b2 = display == null ? void 0 : display.search) == null ? void 0 : _b2.suggestion) || {};
|
|
7087
|
+
const instantSearchLimit = Number(((_c2 = display == null ? void 0 : display.search) == null ? void 0 : _c2.instantsearch_limit) || 6);
|
|
7086
7088
|
let response;
|
|
7087
7089
|
let body = {
|
|
7088
7090
|
queries: tabs.map((tab) => {
|
|
@@ -7096,7 +7098,7 @@ const SearchWidget = (props) => {
|
|
|
7096
7098
|
return {
|
|
7097
7099
|
indexUid: index,
|
|
7098
7100
|
q: keyword,
|
|
7099
|
-
hitsPerPage: isProductIndex ?
|
|
7101
|
+
hitsPerPage: isProductIndex ? instantSearchLimit : 4,
|
|
7100
7102
|
filter: isProductIndex ? [...new Set(additionalFilter)].join(" AND ") : "",
|
|
7101
7103
|
attributesToRetrieve: attributes_to_retrieve
|
|
7102
7104
|
};
|
|
@@ -7110,10 +7112,10 @@ const SearchWidget = (props) => {
|
|
|
7110
7112
|
if (onSearch && (keyword == null ? void 0 : keyword.length)) {
|
|
7111
7113
|
searchTrigger({
|
|
7112
7114
|
keyword,
|
|
7113
|
-
resultCount: ((
|
|
7115
|
+
resultCount: ((_d2 = valueSearchResultProduct[0]) == null ? void 0 : _d2.totalHits) || 0
|
|
7114
7116
|
});
|
|
7115
7117
|
}
|
|
7116
|
-
let valueSearchResultOther = ((
|
|
7118
|
+
let valueSearchResultOther = ((_e2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _e2.map((result) => {
|
|
7117
7119
|
const { indexUid } = result;
|
|
7118
7120
|
const { name, type } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
|
|
7119
7121
|
return {
|
|
@@ -7124,12 +7126,12 @@ const SearchWidget = (props) => {
|
|
|
7124
7126
|
}
|
|
7125
7127
|
};
|
|
7126
7128
|
})) || [];
|
|
7127
|
-
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (
|
|
7129
|
+
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_f2 = valueSearchResultProduct[0]) == null ? void 0 : _f2.hits : [];
|
|
7128
7130
|
let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
|
|
7129
7131
|
let isPriorityZeroCharacter = Boolean(
|
|
7130
|
-
!keyword.length && Object.keys(suggestion).length && ((
|
|
7132
|
+
!keyword.length && Object.keys(suggestion).length && ((_h2 = (_g2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _g2.products) == null ? void 0 : _h2.active) && ((_k2 = (_j2 = (_i2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _i2.products) == null ? void 0 : _j2.list) == null ? void 0 : _k2.length)
|
|
7131
7133
|
);
|
|
7132
|
-
setSearchResultProduct(isPriorityZeroCharacter ? (
|
|
7134
|
+
setSearchResultProduct(isPriorityZeroCharacter ? (_m2 = (_l2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _l2.products) == null ? void 0 : _m2.list : getValueSearchResultProduct);
|
|
7133
7135
|
setSearchResultOther(valueSearchResultOther);
|
|
7134
7136
|
setSuggestionIndex(valueSuggestionIndex);
|
|
7135
7137
|
setIsLoading(false);
|