@sledge-app/react-instant-search 2.0.43 → 2.0.44
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 +59 -6
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -2342,7 +2342,7 @@ const WidgetListEmpty = (props) => {
|
|
|
2342
2342
|
] });
|
|
2343
2343
|
};
|
|
2344
2344
|
const ProductWrapper = (props) => {
|
|
2345
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2345
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2346
2346
|
const { isJsVersion } = React__default.useContext(SledgeContext);
|
|
2347
2347
|
const {
|
|
2348
2348
|
wishlistData,
|
|
@@ -2359,6 +2359,7 @@ const ProductWrapper = (props) => {
|
|
|
2359
2359
|
onAfterRenderProduct,
|
|
2360
2360
|
dataReviews,
|
|
2361
2361
|
generalDataSettings,
|
|
2362
|
+
instantSearchSettings,
|
|
2362
2363
|
previewSettings,
|
|
2363
2364
|
isFlyout
|
|
2364
2365
|
} = props || {};
|
|
@@ -2433,6 +2434,8 @@ const ProductWrapper = (props) => {
|
|
|
2433
2434
|
React__default.useEffect(() => {
|
|
2434
2435
|
setIsLoadingButtonLoadMore(false);
|
|
2435
2436
|
}, [wishlistData]);
|
|
2437
|
+
const isSplitProducts = Boolean((_i = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _i.enable);
|
|
2438
|
+
const bySplitProducts = (_j = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _j.by;
|
|
2436
2439
|
let dataWishlists = {};
|
|
2437
2440
|
for (const v of wishlistData)
|
|
2438
2441
|
dataWishlists[v.product.id] = true;
|
|
@@ -2443,10 +2446,14 @@ const ProductWrapper = (props) => {
|
|
|
2443
2446
|
sourceApp: "wishlist",
|
|
2444
2447
|
type: gridType,
|
|
2445
2448
|
data: wishlistData.map((item) => {
|
|
2449
|
+
var _a2;
|
|
2446
2450
|
const { id, variant_id, name, variant_name, url, image_url, currency, price, vendor, sku, variants, ...other_product } = (item == null ? void 0 : item.product) || {};
|
|
2447
2451
|
const productUrl = new URL(url);
|
|
2448
2452
|
const arrProductUrlPathname = productUrl.pathname.split("/");
|
|
2449
2453
|
const handle = arrProductUrlPathname[arrProductUrlPathname.length - 1];
|
|
2454
|
+
const optionFirst = isSplitProducts && bySplitProducts ? (_a2 = other_product == null ? void 0 : other_product.options) == null ? void 0 : _a2[bySplitProducts] : [];
|
|
2455
|
+
const optionFirstValue = (optionFirst == null ? void 0 : optionFirst.length) ? optionFirst == null ? void 0 : optionFirst[0] : "";
|
|
2456
|
+
const optionSelectedValue = isSplitProducts && (optionFirstValue == null ? void 0 : optionFirstValue.length) ? optionFirstValue : "";
|
|
2450
2457
|
return {
|
|
2451
2458
|
product: {
|
|
2452
2459
|
id,
|
|
@@ -2457,6 +2464,7 @@ const ProductWrapper = (props) => {
|
|
|
2457
2464
|
url,
|
|
2458
2465
|
vendor,
|
|
2459
2466
|
currency,
|
|
2467
|
+
optionSelectedValue,
|
|
2460
2468
|
...other_product
|
|
2461
2469
|
},
|
|
2462
2470
|
variants
|
|
@@ -2489,6 +2497,7 @@ const ProductWrapper = (props) => {
|
|
|
2489
2497
|
dataReviews,
|
|
2490
2498
|
dataWishlists,
|
|
2491
2499
|
previewSettings,
|
|
2500
|
+
instantSearchSettings,
|
|
2492
2501
|
isFlyout
|
|
2493
2502
|
}
|
|
2494
2503
|
) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}),
|
|
@@ -2533,7 +2542,7 @@ const WidgetRoot = (props) => {
|
|
|
2533
2542
|
const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion, locale } = React__default.useContext(SledgeContext);
|
|
2534
2543
|
const { wishlist: isRenderAppWishlist } = isRenderApp || {};
|
|
2535
2544
|
const { trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
|
|
2536
|
-
const { generalPreviewSettings, wishlistPreviewSettings, previewSettings } = usePreviewSettings({
|
|
2545
|
+
const { generalPreviewSettings, wishlistPreviewSettings, instantSearchPreviewSettings, previewSettings } = usePreviewSettings({
|
|
2537
2546
|
defaultSettings: previewSettingsProp,
|
|
2538
2547
|
nestedProperty: "sledge.wishlist.widget.preview"
|
|
2539
2548
|
});
|
|
@@ -2554,6 +2563,7 @@ const WidgetRoot = (props) => {
|
|
|
2554
2563
|
const [proxyUrl, setProxyUrl] = React__default.useState("");
|
|
2555
2564
|
const [dataSettings, setDataSettings] = React__default.useState({});
|
|
2556
2565
|
const [generalDataSettings, setGeneralDataSettings] = React__default.useState({});
|
|
2566
|
+
const [instantSearchSettings, setInstantSearchSettings] = React__default.useState({});
|
|
2557
2567
|
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(!!propsData);
|
|
2558
2568
|
const previousState = usePrevious({ keyword, currentPage });
|
|
2559
2569
|
const { alert, alert_login } = ((_c = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _c.widget) || {};
|
|
@@ -2660,8 +2670,10 @@ const WidgetRoot = (props) => {
|
|
|
2660
2670
|
const handleSettings = async (LOCAL_STORAGE_WISHLIST_SETTING) => {
|
|
2661
2671
|
let response;
|
|
2662
2672
|
let responseGeneral;
|
|
2673
|
+
let responseInstantSearch;
|
|
2663
2674
|
response = wishlistPreviewSettings || JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
|
|
2664
2675
|
responseGeneral = generalPreviewSettings || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
|
|
2676
|
+
responseInstantSearch = instantSearchPreviewSettings || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
|
|
2665
2677
|
if (!response)
|
|
2666
2678
|
return;
|
|
2667
2679
|
const { sorts } = response == null ? void 0 : response.display;
|
|
@@ -2669,6 +2681,8 @@ const WidgetRoot = (props) => {
|
|
|
2669
2681
|
setWishlistSort(sorts);
|
|
2670
2682
|
if (responseGeneral)
|
|
2671
2683
|
setGeneralDataSettings(responseGeneral);
|
|
2684
|
+
if (responseInstantSearch)
|
|
2685
|
+
setInstantSearchSettings(responseInstantSearch);
|
|
2672
2686
|
};
|
|
2673
2687
|
useEffectOnChange(() => {
|
|
2674
2688
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
|
|
@@ -2772,6 +2786,7 @@ const WidgetRoot = (props) => {
|
|
|
2772
2786
|
proxyUrl,
|
|
2773
2787
|
dataSettings,
|
|
2774
2788
|
generalDataSettings,
|
|
2789
|
+
instantSearchSettings,
|
|
2775
2790
|
productCardsComponent,
|
|
2776
2791
|
query,
|
|
2777
2792
|
setIsLoading,
|
|
@@ -5932,6 +5947,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
5932
5947
|
let response;
|
|
5933
5948
|
let body = {
|
|
5934
5949
|
queries: tabs.map((tab) => {
|
|
5950
|
+
var _a3, _b3, _c3;
|
|
5935
5951
|
const { index } = tab;
|
|
5936
5952
|
let isProductIndex = index.includes(index_product);
|
|
5937
5953
|
let additionalFilter = DEFAULT_QUERY_PRODUCT_MEILISEARCH;
|
|
@@ -5939,6 +5955,20 @@ const SearchIconWidgetPopup = () => {
|
|
|
5939
5955
|
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
5940
5956
|
if (!show_out_of_stock)
|
|
5941
5957
|
additionalFilter.push(`'availability' IN ${JSON.stringify(["in stock"])}`);
|
|
5958
|
+
let valueKeyword = keyword;
|
|
5959
|
+
let containsFilter = "";
|
|
5960
|
+
if (isProductIndex) {
|
|
5961
|
+
const searchableAttributes = ((_a3 = instantSearchSettings == null ? void 0 : instantSearchSettings.search_field_priority) == null ? void 0 : _a3.length) ? (_c3 = (_b3 = instantSearchSettings.search_field_priority.map((item) => {
|
|
5962
|
+
if (!(item == null ? void 0 : item.active))
|
|
5963
|
+
return;
|
|
5964
|
+
return item == null ? void 0 : item.value;
|
|
5965
|
+
})) == null ? void 0 : _b3.filter) == null ? void 0 : _c3.call(_b3, (item) => item) : [];
|
|
5966
|
+
const isContainsFilter = (instantSearchSettings == null ? void 0 : instantSearchSettings.contains_filter) && (searchableAttributes == null ? void 0 : searchableAttributes.length) && (keyword == null ? void 0 : keyword.length);
|
|
5967
|
+
if (isContainsFilter) {
|
|
5968
|
+
containsFilter = searchableAttributes.map((item) => `'${item}' CONTAINS ${JSON.stringify(keyword)}`).join(" OR ");
|
|
5969
|
+
valueKeyword = "";
|
|
5970
|
+
}
|
|
5971
|
+
}
|
|
5942
5972
|
let sort = [];
|
|
5943
5973
|
if (isProductIndex && search_use_default_sort && default_sort) {
|
|
5944
5974
|
if (String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID)) {
|
|
@@ -5949,12 +5979,15 @@ const SearchIconWidgetPopup = () => {
|
|
|
5949
5979
|
} else {
|
|
5950
5980
|
sort = [];
|
|
5951
5981
|
}
|
|
5982
|
+
let filterProduct = additionalFilter;
|
|
5983
|
+
if (containsFilter)
|
|
5984
|
+
filterProduct = filterProduct.concat(containsFilter);
|
|
5952
5985
|
return {
|
|
5953
5986
|
indexUid: index,
|
|
5954
|
-
q:
|
|
5987
|
+
q: valueKeyword,
|
|
5955
5988
|
sort,
|
|
5956
5989
|
hitsPerPage: isProductIndex ? instantSearchLimit : 4,
|
|
5957
|
-
filter: isProductIndex ? [...new Set(
|
|
5990
|
+
filter: isProductIndex ? [...new Set(filterProduct)].join(" AND ") : "",
|
|
5958
5991
|
attributesToRetrieve: attributes_to_retrieve
|
|
5959
5992
|
};
|
|
5960
5993
|
})
|
|
@@ -11319,6 +11352,7 @@ const SearchWidget = (props) => {
|
|
|
11319
11352
|
const [keyword, setKeyword] = React__default.useState((searchParams == null ? void 0 : searchParams.get(queryKeyword)) || "");
|
|
11320
11353
|
const [searchResultProduct, setSearchResultProduct] = React__default.useState([]);
|
|
11321
11354
|
const [searchResultOther, setSearchResultOther] = React__default.useState([]);
|
|
11355
|
+
const [instantSearchSettings, setInstantSearchSettings] = React__default.useState({});
|
|
11322
11356
|
const [displaySettings, setDisplaySettings] = React__default.useState({});
|
|
11323
11357
|
const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
|
|
11324
11358
|
const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
|
|
@@ -11348,6 +11382,7 @@ const SearchWidget = (props) => {
|
|
|
11348
11382
|
let response;
|
|
11349
11383
|
let body = {
|
|
11350
11384
|
queries: tabs.map((tab) => {
|
|
11385
|
+
var _a3, _b3, _c3;
|
|
11351
11386
|
const { index } = tab;
|
|
11352
11387
|
let isProductIndex = index.includes(index_product);
|
|
11353
11388
|
let additionalFilter = DEFAULT_QUERY_PRODUCT_MEILISEARCH;
|
|
@@ -11355,6 +11390,20 @@ const SearchWidget = (props) => {
|
|
|
11355
11390
|
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
11356
11391
|
if (!show_out_of_stock)
|
|
11357
11392
|
additionalFilter.push(`'availability' IN ${JSON.stringify(["in stock"])}`);
|
|
11393
|
+
let valueKeyword = keyword;
|
|
11394
|
+
let containsFilter = "";
|
|
11395
|
+
if (isProductIndex) {
|
|
11396
|
+
const searchableAttributes = ((_a3 = instantSearchSettings == null ? void 0 : instantSearchSettings.search_field_priority) == null ? void 0 : _a3.length) ? (_c3 = (_b3 = instantSearchSettings.search_field_priority.map((item) => {
|
|
11397
|
+
if (!(item == null ? void 0 : item.active))
|
|
11398
|
+
return;
|
|
11399
|
+
return item == null ? void 0 : item.value;
|
|
11400
|
+
})) == null ? void 0 : _b3.filter) == null ? void 0 : _c3.call(_b3, (item) => item) : [];
|
|
11401
|
+
const isContainsFilter = (instantSearchSettings == null ? void 0 : instantSearchSettings.contains_filter) && (searchableAttributes == null ? void 0 : searchableAttributes.length) && (keyword == null ? void 0 : keyword.length);
|
|
11402
|
+
if (isContainsFilter) {
|
|
11403
|
+
containsFilter = searchableAttributes.map((item) => `'${item}' CONTAINS ${JSON.stringify(keyword)}`).join(" OR ");
|
|
11404
|
+
valueKeyword = "";
|
|
11405
|
+
}
|
|
11406
|
+
}
|
|
11358
11407
|
let sort = [];
|
|
11359
11408
|
if (isProductIndex && search_use_default_sort && default_sort) {
|
|
11360
11409
|
if (String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID)) {
|
|
@@ -11365,12 +11414,15 @@ const SearchWidget = (props) => {
|
|
|
11365
11414
|
} else {
|
|
11366
11415
|
sort = [];
|
|
11367
11416
|
}
|
|
11417
|
+
let filterProduct = additionalFilter;
|
|
11418
|
+
if (containsFilter)
|
|
11419
|
+
filterProduct = filterProduct.concat(containsFilter);
|
|
11368
11420
|
return {
|
|
11369
11421
|
indexUid: index,
|
|
11370
|
-
q:
|
|
11422
|
+
q: valueKeyword,
|
|
11371
11423
|
sort,
|
|
11372
11424
|
hitsPerPage: isProductIndex ? instantSearchLimit : 4,
|
|
11373
|
-
filter: isProductIndex ? [...new Set(
|
|
11425
|
+
filter: isProductIndex ? [...new Set(filterProduct)].join(" AND ") : "",
|
|
11374
11426
|
attributesToRetrieve: attributes_to_retrieve
|
|
11375
11427
|
};
|
|
11376
11428
|
})
|
|
@@ -11413,6 +11465,7 @@ const SearchWidget = (props) => {
|
|
|
11413
11465
|
response = instantSearchPreviewSettings || JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
11414
11466
|
if (!response)
|
|
11415
11467
|
return;
|
|
11468
|
+
setInstantSearchSettings(response);
|
|
11416
11469
|
const { display, languages, redirects } = response;
|
|
11417
11470
|
setDisplaySettings(display);
|
|
11418
11471
|
setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
|