@sledge-app/react-instant-search 0.0.113 → 0.0.114
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/sledge-react-instant-search.cjs +1 -1
- package/dist/sledge-react-instant-search.cjs.map +1 -1
- package/dist/sledge-react-instant-search.js +17 -17
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -2944,13 +2944,13 @@ const SearchIconWidgetPopup = () => {
|
|
|
2944
2944
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
|
|
2945
2945
|
const { data, onSearch = false, withFetchReviewInfo = false } = params;
|
|
2946
2946
|
setIsLoading(true);
|
|
2947
|
-
const {
|
|
2947
|
+
const { index_product, tabs, hidden_tags, display, show_out_of_stock } = data;
|
|
2948
2948
|
const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
|
|
2949
2949
|
let response;
|
|
2950
2950
|
let body = {
|
|
2951
2951
|
queries: tabs.map((tab) => {
|
|
2952
2952
|
const { index } = tab;
|
|
2953
|
-
let isProductIndex = index.includes(
|
|
2953
|
+
let isProductIndex = index.includes(index_product);
|
|
2954
2954
|
let additionalFilter = [];
|
|
2955
2955
|
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
2956
2956
|
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
@@ -2968,14 +2968,14 @@ const SearchIconWidgetPopup = () => {
|
|
|
2968
2968
|
if (!response)
|
|
2969
2969
|
return;
|
|
2970
2970
|
const { results } = response;
|
|
2971
|
-
let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(
|
|
2971
|
+
let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(index_product));
|
|
2972
2972
|
if (onSearch && (keyword == null ? void 0 : keyword.length)) {
|
|
2973
2973
|
searchTrigger({
|
|
2974
2974
|
keyword,
|
|
2975
2975
|
resultCount: ((_b2 = valueSearchResultProduct[0]) == null ? void 0 : _b2.totalHits) || 0
|
|
2976
2976
|
});
|
|
2977
2977
|
}
|
|
2978
|
-
let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(
|
|
2978
|
+
let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _c2.map((result) => {
|
|
2979
2979
|
const { indexUid } = result;
|
|
2980
2980
|
const { name } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
|
|
2981
2981
|
return {
|
|
@@ -3296,7 +3296,7 @@ const SearchResultWidget = (props) => {
|
|
|
3296
3296
|
const [allowedFilters, setAllowedFilters] = React__default.useState(((_c = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c.filters) || []);
|
|
3297
3297
|
const [allowedTabs, setAllowedTabs] = React__default.useState([]);
|
|
3298
3298
|
const [facets, setFacets] = React__default.useState([]);
|
|
3299
|
-
const [
|
|
3299
|
+
const [indexProduct, setIndexProduct] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.index_product) || "");
|
|
3300
3300
|
const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
|
|
3301
3301
|
const [hiddenTags, setHiddenTags] = React__default.useState(((_e = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _e.hidden_tags) || []);
|
|
3302
3302
|
const [displaySettings, setDisplaySettings] = React__default.useState(((_f = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _f.display) || {});
|
|
@@ -3309,11 +3309,11 @@ const SearchResultWidget = (props) => {
|
|
|
3309
3309
|
const handleChangeTabIndex = (id, name, e) => {
|
|
3310
3310
|
setClickedTabIndexId(id);
|
|
3311
3311
|
setClickedTabIndexName(name);
|
|
3312
|
-
setResultComponent(id.includes(
|
|
3312
|
+
setResultComponent(id.includes(indexProduct) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultCategory, {}));
|
|
3313
3313
|
};
|
|
3314
3314
|
const handleInitStates = async (data, type) => {
|
|
3315
|
-
const { filters,
|
|
3316
|
-
let getTabs = layoutType === "product-filter" ? tabs.filter(({ index }) => index == null ? void 0 : index.includes(
|
|
3315
|
+
const { filters, index_product, tabs, hidden_tags, show_out_of_stock } = data;
|
|
3316
|
+
let getTabs = layoutType === "product-filter" ? tabs.filter(({ index }) => index == null ? void 0 : index.includes(index_product)) : tabs;
|
|
3317
3317
|
let response;
|
|
3318
3318
|
let body = {
|
|
3319
3319
|
queries: getTabs.map((tab) => {
|
|
@@ -3331,7 +3331,7 @@ const SearchResultWidget = (props) => {
|
|
|
3331
3331
|
}
|
|
3332
3332
|
}
|
|
3333
3333
|
}) : [];
|
|
3334
|
-
let isProductIndex = index.includes(
|
|
3334
|
+
let isProductIndex = index.includes(index_product);
|
|
3335
3335
|
let isHasProductFacets = isProductIndex && getFacets.length;
|
|
3336
3336
|
let additionalFilter = [];
|
|
3337
3337
|
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
@@ -3376,7 +3376,7 @@ const SearchResultWidget = (props) => {
|
|
|
3376
3376
|
})
|
|
3377
3377
|
);
|
|
3378
3378
|
} else {
|
|
3379
|
-
const { facetDistribution, facetStats } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(
|
|
3379
|
+
const { facetDistribution, facetStats } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(index_product))) || {};
|
|
3380
3380
|
setSearchResultFacets(
|
|
3381
3381
|
facetDistribution ? Object.fromEntries(
|
|
3382
3382
|
Object.entries(facetDistribution).map((facet) => {
|
|
@@ -3416,16 +3416,16 @@ const SearchResultWidget = (props) => {
|
|
|
3416
3416
|
response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
3417
3417
|
if (!response)
|
|
3418
3418
|
return;
|
|
3419
|
-
const { allowed_sorts, default_sort, filters,
|
|
3419
|
+
const { allowed_sorts, default_sort, filters, index_product, tabs, hidden_tags, display, colors, show_out_of_stock } = response;
|
|
3420
3420
|
setAllowedSorts((allowed_sorts == null ? void 0 : allowed_sorts.length) ? allowed_sorts : []);
|
|
3421
3421
|
setAllowedFilters((filters == null ? void 0 : filters.length) ? filters : []);
|
|
3422
|
-
|
|
3422
|
+
setIndexProduct(index_product);
|
|
3423
3423
|
setHiddenTags(hidden_tags);
|
|
3424
3424
|
setDisplaySettings(display);
|
|
3425
3425
|
setColorSwatches(colors);
|
|
3426
3426
|
setDefaultSort(default_sort);
|
|
3427
3427
|
setShowOutOfStock(show_out_of_stock);
|
|
3428
|
-
getFirstIndex = tabs.find(({ index }) => index.includes(
|
|
3428
|
+
getFirstIndex = tabs.find(({ index }) => index.includes(index_product));
|
|
3429
3429
|
if (Object.keys(getFirstIndex).length) {
|
|
3430
3430
|
setClickedTabIndexId(getFirstIndex.index);
|
|
3431
3431
|
setClickedTabIndexName(getFirstIndex.name);
|
|
@@ -4613,13 +4613,13 @@ const SearchWidget = (props) => {
|
|
|
4613
4613
|
if (!keyword.length)
|
|
4614
4614
|
return;
|
|
4615
4615
|
setIsLoading(true);
|
|
4616
|
-
const {
|
|
4616
|
+
const { index_product, tabs, hidden_tags, display, show_out_of_stock } = data;
|
|
4617
4617
|
const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
|
|
4618
4618
|
let response;
|
|
4619
4619
|
let body = {
|
|
4620
4620
|
queries: tabs.map((tab) => {
|
|
4621
4621
|
const { index } = tab;
|
|
4622
|
-
let isProductIndex = index.includes(
|
|
4622
|
+
let isProductIndex = index.includes(index_product);
|
|
4623
4623
|
let additionalFilter = [];
|
|
4624
4624
|
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
4625
4625
|
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
@@ -4637,14 +4637,14 @@ const SearchWidget = (props) => {
|
|
|
4637
4637
|
if (!response)
|
|
4638
4638
|
return;
|
|
4639
4639
|
const { results } = response;
|
|
4640
|
-
let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(
|
|
4640
|
+
let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(index_product));
|
|
4641
4641
|
if (onSearch && (keyword == null ? void 0 : keyword.length)) {
|
|
4642
4642
|
searchTrigger({
|
|
4643
4643
|
keyword,
|
|
4644
4644
|
resultCount: ((_b2 = valueSearchResultProduct[0]) == null ? void 0 : _b2.totalHits) || 0
|
|
4645
4645
|
});
|
|
4646
4646
|
}
|
|
4647
|
-
let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(
|
|
4647
|
+
let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _c2.map((result) => {
|
|
4648
4648
|
const { indexUid } = result;
|
|
4649
4649
|
const { name } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
|
|
4650
4650
|
return {
|