@sledge-app/react-instant-search 0.0.38 → 0.0.40
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/ProductFilterWidget/ProductFilterWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidget.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetPopup.d.ts +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidget.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidgetInitSelector.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 +50 -39
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,7 +22,8 @@ const SEPARATE_COMPONENT_DISPLAY_NAME = {
|
|
|
22
22
|
},
|
|
23
23
|
SUGGESTION_KEYWORD_LISTS: "SuggestionKeywordLists",
|
|
24
24
|
OTHER_INDEX_LISTS: "OtherIndexLists",
|
|
25
|
-
SEARCH_VIEW_MORE_RESULT: "SearchViewMoreResult"
|
|
25
|
+
SEARCH_VIEW_MORE_RESULT: "SearchViewMoreResult",
|
|
26
|
+
WISHLIST_WIDGET_ALERT: "WishlistWidgetAlert"
|
|
26
27
|
};
|
|
27
28
|
const sanitizeDataId = (id) => {
|
|
28
29
|
if (!id)
|
|
@@ -36,6 +37,14 @@ const sanitizeDataId = (id) => {
|
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
const isFunction = (data) => typeof data === "function";
|
|
40
|
+
const scrollToElement = (element, headerOffset) => {
|
|
41
|
+
var elementPosition = element == null ? void 0 : element.getBoundingClientRect().top;
|
|
42
|
+
var offsetPosition = elementPosition + window.scrollY - headerOffset;
|
|
43
|
+
window.scrollTo({
|
|
44
|
+
top: offsetPosition,
|
|
45
|
+
behavior: "smooth"
|
|
46
|
+
});
|
|
47
|
+
};
|
|
39
48
|
const SearchIconWidget$1 = "";
|
|
40
49
|
const root = "";
|
|
41
50
|
const Loading = "";
|
|
@@ -2188,16 +2197,15 @@ const SkeletonLoading = {
|
|
|
2188
2197
|
BlogGrid: SkeletonBlogGrid
|
|
2189
2198
|
};
|
|
2190
2199
|
const SearchIconWidget = (props) => {
|
|
2200
|
+
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
2191
2201
|
const { size = "sm", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props || {};
|
|
2192
2202
|
let productCardsComponent = null;
|
|
2193
2203
|
let suggestionKeywordListsComponent = null;
|
|
2194
2204
|
let otherIndexListsComponent = null;
|
|
2195
2205
|
let searchViewMoreResultComponent = null;
|
|
2196
|
-
let separateJsVersionComponent = false;
|
|
2197
2206
|
React__default.Children.map(children, (child) => {
|
|
2198
2207
|
if (React__default.isValidElement(child) && isFunction(child.type)) {
|
|
2199
|
-
const { component
|
|
2200
|
-
separateJsVersionComponent = isJsVersion;
|
|
2208
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
2201
2209
|
switch (child.type.name) {
|
|
2202
2210
|
case SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS:
|
|
2203
2211
|
productCardsComponent = component;
|
|
@@ -2214,7 +2222,6 @@ const SearchIconWidget = (props) => {
|
|
|
2214
2222
|
}
|
|
2215
2223
|
}
|
|
2216
2224
|
});
|
|
2217
|
-
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
2218
2225
|
const [sizing, setSizing] = React__default.useState({
|
|
2219
2226
|
width: 0,
|
|
2220
2227
|
height: 0
|
|
@@ -2246,7 +2253,7 @@ const SearchIconWidget = (props) => {
|
|
|
2246
2253
|
onAfterAddWishlist,
|
|
2247
2254
|
onAfterRemoveWishlist,
|
|
2248
2255
|
onAfterRenderProduct,
|
|
2249
|
-
|
|
2256
|
+
isJsVersion,
|
|
2250
2257
|
productCardsComponent,
|
|
2251
2258
|
suggestionKeywordListsComponent,
|
|
2252
2259
|
otherIndexListsComponent,
|
|
@@ -2321,7 +2328,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2321
2328
|
},
|
|
2322
2329
|
onAfterRenderProduct: (state) => {
|
|
2323
2330
|
},
|
|
2324
|
-
|
|
2331
|
+
isJsVersion: null,
|
|
2325
2332
|
productCardsComponent: null,
|
|
2326
2333
|
suggestionKeywordListsComponent: null,
|
|
2327
2334
|
otherIndexListsComponent: null,
|
|
@@ -2419,7 +2426,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2419
2426
|
},
|
|
2420
2427
|
onAfterRenderProduct = () => {
|
|
2421
2428
|
},
|
|
2422
|
-
|
|
2429
|
+
isJsVersion = null,
|
|
2423
2430
|
productCardsComponent = () => {
|
|
2424
2431
|
},
|
|
2425
2432
|
suggestionKeywordListsComponent = () => {
|
|
@@ -2435,7 +2442,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2435
2442
|
onAfterAddWishlist,
|
|
2436
2443
|
onAfterRemoveWishlist,
|
|
2437
2444
|
onAfterRenderProduct,
|
|
2438
|
-
|
|
2445
|
+
isJsVersion,
|
|
2439
2446
|
productCardsComponent,
|
|
2440
2447
|
suggestionKeywordListsComponent,
|
|
2441
2448
|
otherIndexListsComponent,
|
|
@@ -2525,7 +2532,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2525
2532
|
{
|
|
2526
2533
|
listsComponent: handleFunctions.suggestionKeywordListsComponent,
|
|
2527
2534
|
keywords: suggestionSettings[suggestionIndex].keywords.list,
|
|
2528
|
-
isComponentJsVersion: handleFunctions.
|
|
2535
|
+
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2529
2536
|
}
|
|
2530
2537
|
) : null,
|
|
2531
2538
|
searchResultOther && searchResultOther.map((item, index) => {
|
|
@@ -2536,7 +2543,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2536
2543
|
listsComponent: handleFunctions.otherIndexListsComponent,
|
|
2537
2544
|
name,
|
|
2538
2545
|
items: hits,
|
|
2539
|
-
isComponentJsVersion: handleFunctions.
|
|
2546
|
+
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2540
2547
|
}
|
|
2541
2548
|
) }, index);
|
|
2542
2549
|
})
|
|
@@ -2560,7 +2567,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2560
2567
|
show_price: (_i = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _i.show_price
|
|
2561
2568
|
},
|
|
2562
2569
|
showOptionOutOfStock: true,
|
|
2563
|
-
isComponentJsVersion: handleFunctions.
|
|
2570
|
+
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
2564
2571
|
cards: handleFunctions.productCardsComponent,
|
|
2565
2572
|
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2566
2573
|
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
@@ -2592,7 +2599,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2592
2599
|
show_price: (_q = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _q.show_price
|
|
2593
2600
|
},
|
|
2594
2601
|
showOptionOutOfStock: true,
|
|
2595
|
-
isComponentJsVersion: handleFunctions.
|
|
2602
|
+
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
2596
2603
|
cards: handleFunctions.productCardsComponent,
|
|
2597
2604
|
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2598
2605
|
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
@@ -2609,7 +2616,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2609
2616
|
{
|
|
2610
2617
|
component: handleFunctions.searchViewMoreResultComponent,
|
|
2611
2618
|
keyword,
|
|
2612
|
-
isComponentJsVersion: handleFunctions.
|
|
2619
|
+
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2613
2620
|
}
|
|
2614
2621
|
) }) : null
|
|
2615
2622
|
] })
|
|
@@ -2620,19 +2627,17 @@ const SearchIconWidgetPopup = () => {
|
|
|
2620
2627
|
const SearchResultWidget$1 = "";
|
|
2621
2628
|
const SearchResultWidget = (props) => {
|
|
2622
2629
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2630
|
+
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
2623
2631
|
const { layoutType = "default", query, data, children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
|
|
2624
2632
|
const { keyword: queryKeyword = "" } = query || {};
|
|
2625
2633
|
const { collectionId } = data || {};
|
|
2626
2634
|
let productCardsComponent = null;
|
|
2627
|
-
let separateJsVersionComponent = false;
|
|
2628
2635
|
React__default.Children.map(children, (child) => {
|
|
2629
2636
|
if (React__default.isValidElement(child) && isFunction(child.type) && child.type.name === SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS) {
|
|
2630
|
-
const { component
|
|
2637
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
2631
2638
|
productCardsComponent = component;
|
|
2632
|
-
separateJsVersionComponent = isJsVersion;
|
|
2633
2639
|
}
|
|
2634
2640
|
});
|
|
2635
|
-
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
2636
2641
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
2637
2642
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
2638
2643
|
const [keyword, setKeyword] = React__default.useState("");
|
|
@@ -2651,6 +2656,7 @@ const SearchResultWidget = (props) => {
|
|
|
2651
2656
|
const [colorSwatches, setColorSwatches] = React__default.useState([]);
|
|
2652
2657
|
const [defaultSort, setDefaultSort] = React__default.useState("");
|
|
2653
2658
|
const [showOutOfStock, setShowOutOfStock] = React__default.useState(false);
|
|
2659
|
+
const searchResultContainerRef = React__default.useRef(null);
|
|
2654
2660
|
const previousState = usePrevious({ keyword });
|
|
2655
2661
|
const handleChangeTabIndex = (id, name, e) => {
|
|
2656
2662
|
setClickedTabIndexId(id);
|
|
@@ -2701,9 +2707,7 @@ const SearchResultWidget = (props) => {
|
|
|
2701
2707
|
if (!response)
|
|
2702
2708
|
return;
|
|
2703
2709
|
const { results } = response;
|
|
2704
|
-
|
|
2705
|
-
setIsFirstLoading(false);
|
|
2706
|
-
}, 1300);
|
|
2710
|
+
setIsFirstLoading(false);
|
|
2707
2711
|
setIsLoadingSetting(false);
|
|
2708
2712
|
setIsLoading(false);
|
|
2709
2713
|
if (type === "totalDataPerIndex") {
|
|
@@ -2754,6 +2758,7 @@ const SearchResultWidget = (props) => {
|
|
|
2754
2758
|
}
|
|
2755
2759
|
};
|
|
2756
2760
|
const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
|
|
2761
|
+
setIsLoadingSetting(true);
|
|
2757
2762
|
let response;
|
|
2758
2763
|
let run = false;
|
|
2759
2764
|
let getFirstIndex;
|
|
@@ -3061,7 +3066,7 @@ const SearchResultWidget = (props) => {
|
|
|
3061
3066
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-select-field-item", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "150px", height: "42px", color: "grey-100", rounded: "lg" }) })
|
|
3062
3067
|
] })
|
|
3063
3068
|
] });
|
|
3064
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-container", children: [
|
|
3069
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-container", ref: searchResultContainerRef, children: [
|
|
3065
3070
|
isFirstLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${layoutType === "default" && (allowedTabs == null ? void 0 : allowedTabs.length) ? "sledge-instant-search__result-tab" : "sledge-instant-search__result-tab-no-index"}`, children: layoutType === "default" && (allowedTabs == null ? void 0 : allowedTabs.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__result-tab-list", children: allowedTabs.map((item) => {
|
|
3066
3071
|
const { name, index, total } = item;
|
|
3067
3072
|
let isActive = clickedTabIndexId === index;
|
|
@@ -3097,7 +3102,7 @@ const SearchResultWidget = (props) => {
|
|
|
3097
3102
|
showOutOfStock,
|
|
3098
3103
|
query,
|
|
3099
3104
|
data,
|
|
3100
|
-
|
|
3105
|
+
isJsVersion,
|
|
3101
3106
|
productCardsComponent,
|
|
3102
3107
|
onAfterAddToCart,
|
|
3103
3108
|
onAfterAddWishlist,
|
|
@@ -3108,7 +3113,8 @@ const SearchResultWidget = (props) => {
|
|
|
3108
3113
|
filterHorizontalSkeleton,
|
|
3109
3114
|
filterVerticalSkeleton,
|
|
3110
3115
|
productGridSkeleton,
|
|
3111
|
-
searchAndSelectOptionSkeleton
|
|
3116
|
+
searchAndSelectOptionSkeleton,
|
|
3117
|
+
searchResultContainerRef
|
|
3112
3118
|
})
|
|
3113
3119
|
] });
|
|
3114
3120
|
};
|
|
@@ -3129,7 +3135,7 @@ const ResultProduct = (props) => {
|
|
|
3129
3135
|
showOutOfStock,
|
|
3130
3136
|
query,
|
|
3131
3137
|
data,
|
|
3132
|
-
|
|
3138
|
+
isJsVersion,
|
|
3133
3139
|
productCardsComponent,
|
|
3134
3140
|
setKeyword,
|
|
3135
3141
|
filterHorizontalSkeleton,
|
|
@@ -3139,7 +3145,8 @@ const ResultProduct = (props) => {
|
|
|
3139
3145
|
onAfterAddToCart,
|
|
3140
3146
|
onAfterAddWishlist,
|
|
3141
3147
|
onAfterRemoveWishlist,
|
|
3142
|
-
onAfterRenderProduct
|
|
3148
|
+
onAfterRenderProduct,
|
|
3149
|
+
searchResultContainerRef
|
|
3143
3150
|
} = props || {};
|
|
3144
3151
|
const { keyword: queryKeyword = "" } = query || {};
|
|
3145
3152
|
const { collectionId } = data || {};
|
|
@@ -3396,6 +3403,9 @@ const ResultProduct = (props) => {
|
|
|
3396
3403
|
};
|
|
3397
3404
|
const handlePageChange = (page) => {
|
|
3398
3405
|
setCurrentPage(page);
|
|
3406
|
+
setTimeout(() => {
|
|
3407
|
+
scrollToElement(searchResultContainerRef.current, 50);
|
|
3408
|
+
}, 200);
|
|
3399
3409
|
};
|
|
3400
3410
|
const handleChangeKeyword = (value) => {
|
|
3401
3411
|
const searchParams = new URLSearchParams(document.location.search);
|
|
@@ -3615,7 +3625,7 @@ const ResultProduct = (props) => {
|
|
|
3615
3625
|
});
|
|
3616
3626
|
const paginationComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Pagination, { currentPage, totalPage, totalResult: totalSearchResult, onChange: (page) => handlePageChange(page) });
|
|
3617
3627
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3618
|
-
((_f = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _f.enable_on_search) && ((_g = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _g.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading ? filterHorizontalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoadingSetting ?
|
|
3628
|
+
((_f = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _f.enable_on_search) && ((_g = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _g.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading ? filterHorizontalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoadingSetting ? null : filterHorizontalComponents.every((currentValue) => !currentValue) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal-wrapper", children: [
|
|
3619
3629
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal", children: filterHorizontalComponents }),
|
|
3620
3630
|
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_h = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _h.show_refine_by_block)) ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: Boolean(dataClickedFacets.every((currentValue) => !currentValue)) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal", children: [
|
|
3621
3631
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3638,7 +3648,7 @@ const ResultProduct = (props) => {
|
|
|
3638
3648
|
] }) }) : null
|
|
3639
3649
|
] }) }) }) : null,
|
|
3640
3650
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", "data-filter-layout": (_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.layout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3641
|
-
((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.enable_on_search) && ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.layout) === "vertical" ? isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : filterVerticalComponents.every((currentValue) => !currentValue) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: isLoadingSetting ?
|
|
3651
|
+
((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.enable_on_search) && ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.layout) === "vertical" ? isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : filterVerticalComponents.every((currentValue) => !currentValue) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: isLoadingSetting ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3642
3652
|
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.show_refine_by_block)) ? Boolean(dataClickedFacets.every((currentValue) => !currentValue)) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
|
|
3643
3653
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title-refine", children: [
|
|
3644
3654
|
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { className: "sledge-instant-search__result-filter-item-title-refine-heading", children: "Filter" }),
|
|
@@ -3740,7 +3750,7 @@ const ResultProduct = (props) => {
|
|
|
3740
3750
|
show_sku: (_s = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _s.show_sku,
|
|
3741
3751
|
show_price: (_t = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _t.show_price
|
|
3742
3752
|
},
|
|
3743
|
-
isComponentJsVersion:
|
|
3753
|
+
isComponentJsVersion: isJsVersion,
|
|
3744
3754
|
cards: productCardsComponent,
|
|
3745
3755
|
showOptionOutOfStock: true,
|
|
3746
3756
|
onAfterAddToCart,
|
|
@@ -3758,7 +3768,7 @@ const ResultProduct = (props) => {
|
|
|
3758
3768
|
};
|
|
3759
3769
|
const ResultCategory = (props) => {
|
|
3760
3770
|
var _a, _b, _c, _d;
|
|
3761
|
-
const { keyword, clickedTabIndexId, clickedTabIndexName, setKeyword } = props || {};
|
|
3771
|
+
const { keyword, clickedTabIndexId, clickedTabIndexName, setKeyword, searchResultContainerRef } = props || {};
|
|
3762
3772
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
3763
3773
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
3764
3774
|
const [clickedSortId, setClickedSortId] = React__default.useState("");
|
|
@@ -3811,6 +3821,9 @@ const ResultCategory = (props) => {
|
|
|
3811
3821
|
};
|
|
3812
3822
|
const handlePageChange = (page) => {
|
|
3813
3823
|
setCurrentPage(page);
|
|
3824
|
+
setTimeout(() => {
|
|
3825
|
+
scrollToElement(searchResultContainerRef.current, 50);
|
|
3826
|
+
}, 200);
|
|
3814
3827
|
};
|
|
3815
3828
|
React__default.useEffect(() => {
|
|
3816
3829
|
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
@@ -3889,16 +3902,15 @@ const ResultEmpty = (props) => {
|
|
|
3889
3902
|
const SearchWidget$1 = "";
|
|
3890
3903
|
const SearchWidget = (props) => {
|
|
3891
3904
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
3905
|
+
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
3892
3906
|
const { width = "400px", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
|
|
3893
3907
|
let productCardsComponent = null;
|
|
3894
3908
|
let suggestionKeywordListsComponent = null;
|
|
3895
3909
|
let otherIndexListsComponent = null;
|
|
3896
3910
|
let searchViewMoreResultComponent = null;
|
|
3897
|
-
let separateJsVersionComponent = false;
|
|
3898
3911
|
React__default.Children.map(children, (child) => {
|
|
3899
3912
|
if (React__default.isValidElement(child) && isFunction(child.type)) {
|
|
3900
|
-
const { component
|
|
3901
|
-
separateJsVersionComponent = isJsVersion;
|
|
3913
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
3902
3914
|
switch (child.type.name) {
|
|
3903
3915
|
case SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS:
|
|
3904
3916
|
productCardsComponent = component;
|
|
@@ -3915,7 +3927,6 @@ const SearchWidget = (props) => {
|
|
|
3915
3927
|
}
|
|
3916
3928
|
}
|
|
3917
3929
|
});
|
|
3918
|
-
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
3919
3930
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
3920
3931
|
const [keyword, setKeyword] = React__default.useState("");
|
|
3921
3932
|
const [suffixIndexProduct, setSuffixIndexProduct] = React__default.useState("");
|
|
@@ -4085,12 +4096,12 @@ const SearchWidget = (props) => {
|
|
|
4085
4096
|
{
|
|
4086
4097
|
listsComponent: suggestionKeywordListsComponent,
|
|
4087
4098
|
keywords: suggestionSettings[suggestionIndex].keywords.list,
|
|
4088
|
-
isComponentJsVersion:
|
|
4099
|
+
isComponentJsVersion: isJsVersion
|
|
4089
4100
|
}
|
|
4090
4101
|
) : null,
|
|
4091
4102
|
searchResultOther.map((item, index) => {
|
|
4092
4103
|
const { hits, name } = item;
|
|
4093
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Global.OtherIndexLists, { listsComponent: otherIndexListsComponent, name, items: hits, isComponentJsVersion:
|
|
4104
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Global.OtherIndexLists, { listsComponent: otherIndexListsComponent, name, items: hits, isComponentJsVersion: isJsVersion }) }, index);
|
|
4094
4105
|
})
|
|
4095
4106
|
] }),
|
|
4096
4107
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-product", children: [
|
|
@@ -4113,7 +4124,7 @@ const SearchWidget = (props) => {
|
|
|
4113
4124
|
show_price: (_h = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _h.show_price
|
|
4114
4125
|
},
|
|
4115
4126
|
showOptionOutOfStock: true,
|
|
4116
|
-
isComponentJsVersion:
|
|
4127
|
+
isComponentJsVersion: isJsVersion,
|
|
4117
4128
|
cards: productCardsComponent,
|
|
4118
4129
|
onAfterAddToCart,
|
|
4119
4130
|
onAfterAddWishlist,
|
|
@@ -4146,7 +4157,7 @@ const SearchWidget = (props) => {
|
|
|
4146
4157
|
show_price: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_price
|
|
4147
4158
|
},
|
|
4148
4159
|
showOptionOutOfStock: true,
|
|
4149
|
-
isComponentJsVersion:
|
|
4160
|
+
isComponentJsVersion: isJsVersion,
|
|
4150
4161
|
cards: productCardsComponent,
|
|
4151
4162
|
onAfterAddToCart,
|
|
4152
4163
|
onAfterAddWishlist,
|
|
@@ -4157,7 +4168,7 @@ const SearchWidget = (props) => {
|
|
|
4157
4168
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-product-disabled", children: "No product were found" })
|
|
4158
4169
|
] })
|
|
4159
4170
|
] }),
|
|
4160
|
-
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_r = (_q = suggestionSettings[suggestionIndex]) == null ? void 0 : _q.products) == null ? void 0 : _r.active) && ((_u = (_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.list) == null ? void 0 : _u.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Global.SearchViewMoreResult, { component: searchViewMoreResultComponent, keyword, isComponentJsVersion:
|
|
4171
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_r = (_q = suggestionSettings[suggestionIndex]) == null ? void 0 : _q.products) == null ? void 0 : _r.active) && ((_u = (_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.list) == null ? void 0 : _u.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Global.SearchViewMoreResult, { component: searchViewMoreResultComponent, keyword, isComponentJsVersion: isJsVersion }) }) : null
|
|
4161
4172
|
] }) }) })
|
|
4162
4173
|
] });
|
|
4163
4174
|
};
|