@sledge-app/react-instant-search 2.0.42 → 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 +64 -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,
|
|
@@ -4492,6 +4507,11 @@ const ProductCard = React__default.memo((props) => {
|
|
|
4492
4507
|
objectKey: "vendor",
|
|
4493
4508
|
callbackValue: product == null ? void 0 : product.vendor
|
|
4494
4509
|
}),
|
|
4510
|
+
handle: translate({
|
|
4511
|
+
...translateDefaultProps,
|
|
4512
|
+
objectKey: "handle",
|
|
4513
|
+
callbackValue: product == null ? void 0 : product.handle
|
|
4514
|
+
}),
|
|
4495
4515
|
product_type: translate({
|
|
4496
4516
|
...translateDefaultProps,
|
|
4497
4517
|
objectKey: "product_type",
|
|
@@ -5927,6 +5947,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
5927
5947
|
let response;
|
|
5928
5948
|
let body = {
|
|
5929
5949
|
queries: tabs.map((tab) => {
|
|
5950
|
+
var _a3, _b3, _c3;
|
|
5930
5951
|
const { index } = tab;
|
|
5931
5952
|
let isProductIndex = index.includes(index_product);
|
|
5932
5953
|
let additionalFilter = DEFAULT_QUERY_PRODUCT_MEILISEARCH;
|
|
@@ -5934,6 +5955,20 @@ const SearchIconWidgetPopup = () => {
|
|
|
5934
5955
|
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
5935
5956
|
if (!show_out_of_stock)
|
|
5936
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
|
+
}
|
|
5937
5972
|
let sort = [];
|
|
5938
5973
|
if (isProductIndex && search_use_default_sort && default_sort) {
|
|
5939
5974
|
if (String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID)) {
|
|
@@ -5944,12 +5979,15 @@ const SearchIconWidgetPopup = () => {
|
|
|
5944
5979
|
} else {
|
|
5945
5980
|
sort = [];
|
|
5946
5981
|
}
|
|
5982
|
+
let filterProduct = additionalFilter;
|
|
5983
|
+
if (containsFilter)
|
|
5984
|
+
filterProduct = filterProduct.concat(containsFilter);
|
|
5947
5985
|
return {
|
|
5948
5986
|
indexUid: index,
|
|
5949
|
-
q:
|
|
5987
|
+
q: valueKeyword,
|
|
5950
5988
|
sort,
|
|
5951
5989
|
hitsPerPage: isProductIndex ? instantSearchLimit : 4,
|
|
5952
|
-
filter: isProductIndex ? [...new Set(
|
|
5990
|
+
filter: isProductIndex ? [...new Set(filterProduct)].join(" AND ") : "",
|
|
5953
5991
|
attributesToRetrieve: attributes_to_retrieve
|
|
5954
5992
|
};
|
|
5955
5993
|
})
|
|
@@ -11314,6 +11352,7 @@ const SearchWidget = (props) => {
|
|
|
11314
11352
|
const [keyword, setKeyword] = React__default.useState((searchParams == null ? void 0 : searchParams.get(queryKeyword)) || "");
|
|
11315
11353
|
const [searchResultProduct, setSearchResultProduct] = React__default.useState([]);
|
|
11316
11354
|
const [searchResultOther, setSearchResultOther] = React__default.useState([]);
|
|
11355
|
+
const [instantSearchSettings, setInstantSearchSettings] = React__default.useState({});
|
|
11317
11356
|
const [displaySettings, setDisplaySettings] = React__default.useState({});
|
|
11318
11357
|
const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
|
|
11319
11358
|
const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
|
|
@@ -11343,6 +11382,7 @@ const SearchWidget = (props) => {
|
|
|
11343
11382
|
let response;
|
|
11344
11383
|
let body = {
|
|
11345
11384
|
queries: tabs.map((tab) => {
|
|
11385
|
+
var _a3, _b3, _c3;
|
|
11346
11386
|
const { index } = tab;
|
|
11347
11387
|
let isProductIndex = index.includes(index_product);
|
|
11348
11388
|
let additionalFilter = DEFAULT_QUERY_PRODUCT_MEILISEARCH;
|
|
@@ -11350,6 +11390,20 @@ const SearchWidget = (props) => {
|
|
|
11350
11390
|
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
11351
11391
|
if (!show_out_of_stock)
|
|
11352
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
|
+
}
|
|
11353
11407
|
let sort = [];
|
|
11354
11408
|
if (isProductIndex && search_use_default_sort && default_sort) {
|
|
11355
11409
|
if (String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID)) {
|
|
@@ -11360,12 +11414,15 @@ const SearchWidget = (props) => {
|
|
|
11360
11414
|
} else {
|
|
11361
11415
|
sort = [];
|
|
11362
11416
|
}
|
|
11417
|
+
let filterProduct = additionalFilter;
|
|
11418
|
+
if (containsFilter)
|
|
11419
|
+
filterProduct = filterProduct.concat(containsFilter);
|
|
11363
11420
|
return {
|
|
11364
11421
|
indexUid: index,
|
|
11365
|
-
q:
|
|
11422
|
+
q: valueKeyword,
|
|
11366
11423
|
sort,
|
|
11367
11424
|
hitsPerPage: isProductIndex ? instantSearchLimit : 4,
|
|
11368
|
-
filter: isProductIndex ? [...new Set(
|
|
11425
|
+
filter: isProductIndex ? [...new Set(filterProduct)].join(" AND ") : "",
|
|
11369
11426
|
attributesToRetrieve: attributes_to_retrieve
|
|
11370
11427
|
};
|
|
11371
11428
|
})
|
|
@@ -11408,6 +11465,7 @@ const SearchWidget = (props) => {
|
|
|
11408
11465
|
response = instantSearchPreviewSettings || JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
11409
11466
|
if (!response)
|
|
11410
11467
|
return;
|
|
11468
|
+
setInstantSearchSettings(response);
|
|
11411
11469
|
const { display, languages, redirects } = response;
|
|
11412
11470
|
setDisplaySettings(display);
|
|
11413
11471
|
setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
|