@sledge-app/react-instant-search 0.0.39 → 0.0.41
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/ProductFilterWidget.d.ts +2 -1
- package/dist/components/ProductFilterWidget/ProductFilterWidget.d.ts.map +1 -1
- 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 +2 -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 +72 -45
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@ import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9,
|
|
|
2
2
|
import React__default, { createElement } from "react";
|
|
3
3
|
import { SledgeContext } from "@sledge-app/core";
|
|
4
4
|
import "react-dom";
|
|
5
|
-
const ProductFilterWidget = (props) => {
|
|
5
|
+
const ProductFilterWidget = React__default.memo((props) => {
|
|
6
6
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(SearchResultWidget, { layoutType: "product-filter", ...props });
|
|
7
|
-
};
|
|
7
|
+
});
|
|
8
8
|
const API_URL = "https://sledge-api-preprod.offstack.io";
|
|
9
9
|
const INSTANT_SEARCH_ENGINE_URL = "https://instant-search-engine.offstack.io";
|
|
10
10
|
const LOCAL_STORAGE_KEY = {
|
|
@@ -22,7 +22,13 @@ 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"
|
|
27
|
+
};
|
|
28
|
+
const ELEMENT_ID = {
|
|
29
|
+
PRODUCT_REVIEW: {
|
|
30
|
+
ELEMENT_WIDGET: "product-review-widget"
|
|
31
|
+
}
|
|
26
32
|
};
|
|
27
33
|
const sanitizeDataId = (id) => {
|
|
28
34
|
if (!id)
|
|
@@ -36,6 +42,16 @@ const sanitizeDataId = (id) => {
|
|
|
36
42
|
}
|
|
37
43
|
};
|
|
38
44
|
const isFunction = (data) => typeof data === "function";
|
|
45
|
+
const scrollToElement = (element, headerOffset) => {
|
|
46
|
+
if (!element)
|
|
47
|
+
return;
|
|
48
|
+
var elementPosition = element == null ? void 0 : element.getBoundingClientRect().top;
|
|
49
|
+
var offsetPosition = elementPosition + window.scrollY - headerOffset;
|
|
50
|
+
window.scrollTo({
|
|
51
|
+
top: offsetPosition,
|
|
52
|
+
behavior: "smooth"
|
|
53
|
+
});
|
|
54
|
+
};
|
|
39
55
|
const SearchIconWidget$1 = "";
|
|
40
56
|
const root = "";
|
|
41
57
|
const Loading = "";
|
|
@@ -1156,7 +1172,7 @@ const getReviewInfo = async (id) => {
|
|
|
1156
1172
|
};
|
|
1157
1173
|
const Rating = (props) => {
|
|
1158
1174
|
var _a;
|
|
1159
|
-
const { value, size = "md", data, withSkeletonLoading = true } = props;
|
|
1175
|
+
const { value, size = "md", data, withSkeletonLoading = true, isScrollToElementWidget = true } = props;
|
|
1160
1176
|
const { productId } = data || {};
|
|
1161
1177
|
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
1162
1178
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
@@ -1211,6 +1227,13 @@ const Rating = (props) => {
|
|
|
1211
1227
|
await handleProductRatingInfo();
|
|
1212
1228
|
}
|
|
1213
1229
|
};
|
|
1230
|
+
const handleOnClick = () => {
|
|
1231
|
+
if (!isScrollToElementWidget)
|
|
1232
|
+
return;
|
|
1233
|
+
setTimeout(() => {
|
|
1234
|
+
scrollToElement(document.getElementById(ELEMENT_ID.PRODUCT_REVIEW.ELEMENT_WIDGET), 50);
|
|
1235
|
+
}, 200);
|
|
1236
|
+
};
|
|
1214
1237
|
React__default.useEffect(() => {
|
|
1215
1238
|
if (!(isRenderApp == null ? void 0 : isRenderApp.productReview))
|
|
1216
1239
|
return;
|
|
@@ -1235,7 +1258,7 @@ const Rating = (props) => {
|
|
|
1235
1258
|
setIsFirstLoading(true);
|
|
1236
1259
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || "");
|
|
1237
1260
|
}, [isRenderApp, productId]);
|
|
1238
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__rating", children: isFirstLoading && withSkeletonLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "230px", height: "28px", color: "grey-100", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1261
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__rating", onClick: handleOnClick, children: isFirstLoading && withSkeletonLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "230px", height: "28px", color: "grey-100", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1239
1262
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", style: { display: "none" }, id: "sledge-product-review-rating-icon-svg-store", children: [
|
|
1240
1263
|
/* @__PURE__ */ jsxRuntimeExports.jsx("symbol", { id: "sledge-product-review-icons-rating-icon-fill", viewBox: "0 0 30 29", fill: fill_color || "#23BC45", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1241
1264
|
"path",
|
|
@@ -1460,7 +1483,7 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1460
1483
|
{
|
|
1461
1484
|
trigger: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs(motion.div, { initial: false, animate: isOpen ? "open" : "closed", className: "sledge-product-review__widget-summary-trigger", children: [
|
|
1462
1485
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-average", children: averageReview }),
|
|
1463
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-rating", children: !isRefreshRating && /* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { value: String(averageReview), size: "md", withSkeletonLoading: false }) }),
|
|
1486
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-rating", children: !isRefreshRating && /* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { value: String(averageReview), size: "md", withSkeletonLoading: false, isScrollToElementWidget: false }) }),
|
|
1464
1487
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__widget-summary-total", children: [
|
|
1465
1488
|
totalReview,
|
|
1466
1489
|
" ",
|
|
@@ -1497,7 +1520,7 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1497
1520
|
] }, index);
|
|
1498
1521
|
}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-dist", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-dist-progress", children: [5, 4, 3, 2, 1].map((item, index) => {
|
|
1499
1522
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__widget-summary-dist-progress-item", children: [
|
|
1500
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { value: item, size: "sm", withSkeletonLoading: false }),
|
|
1523
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { value: item, size: "sm", withSkeletonLoading: false, isScrollToElementWidget: false }),
|
|
1501
1524
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1502
1525
|
Progress,
|
|
1503
1526
|
{
|
|
@@ -1805,7 +1828,8 @@ const ProductGrid = ({
|
|
|
1805
1828
|
productId: id
|
|
1806
1829
|
},
|
|
1807
1830
|
size: "xs",
|
|
1808
|
-
withSkeletonLoading: false
|
|
1831
|
+
withSkeletonLoading: false,
|
|
1832
|
+
isScrollToElementWidget: false
|
|
1809
1833
|
}
|
|
1810
1834
|
) })
|
|
1811
1835
|
] })
|
|
@@ -2188,16 +2212,15 @@ const SkeletonLoading = {
|
|
|
2188
2212
|
BlogGrid: SkeletonBlogGrid
|
|
2189
2213
|
};
|
|
2190
2214
|
const SearchIconWidget = (props) => {
|
|
2215
|
+
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
2191
2216
|
const { size = "sm", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props || {};
|
|
2192
2217
|
let productCardsComponent = null;
|
|
2193
2218
|
let suggestionKeywordListsComponent = null;
|
|
2194
2219
|
let otherIndexListsComponent = null;
|
|
2195
2220
|
let searchViewMoreResultComponent = null;
|
|
2196
|
-
let separateJsVersionComponent = false;
|
|
2197
2221
|
React__default.Children.map(children, (child) => {
|
|
2198
2222
|
if (React__default.isValidElement(child) && isFunction(child.type)) {
|
|
2199
|
-
const { component
|
|
2200
|
-
separateJsVersionComponent = isJsVersion;
|
|
2223
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
2201
2224
|
switch (child.type.name) {
|
|
2202
2225
|
case SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS:
|
|
2203
2226
|
productCardsComponent = component;
|
|
@@ -2214,7 +2237,6 @@ const SearchIconWidget = (props) => {
|
|
|
2214
2237
|
}
|
|
2215
2238
|
}
|
|
2216
2239
|
});
|
|
2217
|
-
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
2218
2240
|
const [sizing, setSizing] = React__default.useState({
|
|
2219
2241
|
width: 0,
|
|
2220
2242
|
height: 0
|
|
@@ -2246,7 +2268,7 @@ const SearchIconWidget = (props) => {
|
|
|
2246
2268
|
onAfterAddWishlist,
|
|
2247
2269
|
onAfterRemoveWishlist,
|
|
2248
2270
|
onAfterRenderProduct,
|
|
2249
|
-
|
|
2271
|
+
isJsVersion,
|
|
2250
2272
|
productCardsComponent,
|
|
2251
2273
|
suggestionKeywordListsComponent,
|
|
2252
2274
|
otherIndexListsComponent,
|
|
@@ -2321,7 +2343,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2321
2343
|
},
|
|
2322
2344
|
onAfterRenderProduct: (state) => {
|
|
2323
2345
|
},
|
|
2324
|
-
|
|
2346
|
+
isJsVersion: null,
|
|
2325
2347
|
productCardsComponent: null,
|
|
2326
2348
|
suggestionKeywordListsComponent: null,
|
|
2327
2349
|
otherIndexListsComponent: null,
|
|
@@ -2419,7 +2441,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2419
2441
|
},
|
|
2420
2442
|
onAfterRenderProduct = () => {
|
|
2421
2443
|
},
|
|
2422
|
-
|
|
2444
|
+
isJsVersion = null,
|
|
2423
2445
|
productCardsComponent = () => {
|
|
2424
2446
|
},
|
|
2425
2447
|
suggestionKeywordListsComponent = () => {
|
|
@@ -2435,7 +2457,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2435
2457
|
onAfterAddWishlist,
|
|
2436
2458
|
onAfterRemoveWishlist,
|
|
2437
2459
|
onAfterRenderProduct,
|
|
2438
|
-
|
|
2460
|
+
isJsVersion,
|
|
2439
2461
|
productCardsComponent,
|
|
2440
2462
|
suggestionKeywordListsComponent,
|
|
2441
2463
|
otherIndexListsComponent,
|
|
@@ -2525,7 +2547,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2525
2547
|
{
|
|
2526
2548
|
listsComponent: handleFunctions.suggestionKeywordListsComponent,
|
|
2527
2549
|
keywords: suggestionSettings[suggestionIndex].keywords.list,
|
|
2528
|
-
isComponentJsVersion: handleFunctions.
|
|
2550
|
+
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2529
2551
|
}
|
|
2530
2552
|
) : null,
|
|
2531
2553
|
searchResultOther && searchResultOther.map((item, index) => {
|
|
@@ -2536,7 +2558,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2536
2558
|
listsComponent: handleFunctions.otherIndexListsComponent,
|
|
2537
2559
|
name,
|
|
2538
2560
|
items: hits,
|
|
2539
|
-
isComponentJsVersion: handleFunctions.
|
|
2561
|
+
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2540
2562
|
}
|
|
2541
2563
|
) }, index);
|
|
2542
2564
|
})
|
|
@@ -2560,7 +2582,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2560
2582
|
show_price: (_i = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _i.show_price
|
|
2561
2583
|
},
|
|
2562
2584
|
showOptionOutOfStock: true,
|
|
2563
|
-
isComponentJsVersion: handleFunctions.
|
|
2585
|
+
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
2564
2586
|
cards: handleFunctions.productCardsComponent,
|
|
2565
2587
|
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2566
2588
|
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
@@ -2592,7 +2614,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2592
2614
|
show_price: (_q = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _q.show_price
|
|
2593
2615
|
},
|
|
2594
2616
|
showOptionOutOfStock: true,
|
|
2595
|
-
isComponentJsVersion: handleFunctions.
|
|
2617
|
+
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
2596
2618
|
cards: handleFunctions.productCardsComponent,
|
|
2597
2619
|
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2598
2620
|
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
@@ -2609,7 +2631,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2609
2631
|
{
|
|
2610
2632
|
component: handleFunctions.searchViewMoreResultComponent,
|
|
2611
2633
|
keyword,
|
|
2612
|
-
isComponentJsVersion: handleFunctions.
|
|
2634
|
+
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2613
2635
|
}
|
|
2614
2636
|
) }) : null
|
|
2615
2637
|
] })
|
|
@@ -2618,21 +2640,19 @@ const SearchIconWidgetPopup = () => {
|
|
|
2618
2640
|
] }) });
|
|
2619
2641
|
};
|
|
2620
2642
|
const SearchResultWidget$1 = "";
|
|
2621
|
-
const SearchResultWidget = (props) => {
|
|
2643
|
+
const SearchResultWidget = React__default.memo((props) => {
|
|
2622
2644
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2645
|
+
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
2623
2646
|
const { layoutType = "default", query, data, children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
|
|
2624
2647
|
const { keyword: queryKeyword = "" } = query || {};
|
|
2625
2648
|
const { collectionId } = data || {};
|
|
2626
2649
|
let productCardsComponent = null;
|
|
2627
|
-
let separateJsVersionComponent = false;
|
|
2628
2650
|
React__default.Children.map(children, (child) => {
|
|
2629
2651
|
if (React__default.isValidElement(child) && isFunction(child.type) && child.type.name === SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS) {
|
|
2630
|
-
const { component
|
|
2652
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
2631
2653
|
productCardsComponent = component;
|
|
2632
|
-
separateJsVersionComponent = isJsVersion;
|
|
2633
2654
|
}
|
|
2634
2655
|
});
|
|
2635
|
-
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
2636
2656
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
2637
2657
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
2638
2658
|
const [keyword, setKeyword] = React__default.useState("");
|
|
@@ -2651,6 +2671,7 @@ const SearchResultWidget = (props) => {
|
|
|
2651
2671
|
const [colorSwatches, setColorSwatches] = React__default.useState([]);
|
|
2652
2672
|
const [defaultSort, setDefaultSort] = React__default.useState("");
|
|
2653
2673
|
const [showOutOfStock, setShowOutOfStock] = React__default.useState(false);
|
|
2674
|
+
const searchResultContainerRef = React__default.useRef(null);
|
|
2654
2675
|
const previousState = usePrevious({ keyword });
|
|
2655
2676
|
const handleChangeTabIndex = (id, name, e) => {
|
|
2656
2677
|
setClickedTabIndexId(id);
|
|
@@ -3060,7 +3081,7 @@ const SearchResultWidget = (props) => {
|
|
|
3060
3081
|
/* @__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" }) })
|
|
3061
3082
|
] })
|
|
3062
3083
|
] });
|
|
3063
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-container", children: [
|
|
3084
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-container", ref: searchResultContainerRef, children: [
|
|
3064
3085
|
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) => {
|
|
3065
3086
|
const { name, index, total } = item;
|
|
3066
3087
|
let isActive = clickedTabIndexId === index;
|
|
@@ -3096,7 +3117,7 @@ const SearchResultWidget = (props) => {
|
|
|
3096
3117
|
showOutOfStock,
|
|
3097
3118
|
query,
|
|
3098
3119
|
data,
|
|
3099
|
-
|
|
3120
|
+
isJsVersion,
|
|
3100
3121
|
productCardsComponent,
|
|
3101
3122
|
onAfterAddToCart,
|
|
3102
3123
|
onAfterAddWishlist,
|
|
@@ -3107,10 +3128,11 @@ const SearchResultWidget = (props) => {
|
|
|
3107
3128
|
filterHorizontalSkeleton,
|
|
3108
3129
|
filterVerticalSkeleton,
|
|
3109
3130
|
productGridSkeleton,
|
|
3110
|
-
searchAndSelectOptionSkeleton
|
|
3131
|
+
searchAndSelectOptionSkeleton,
|
|
3132
|
+
searchResultContainerRef
|
|
3111
3133
|
})
|
|
3112
3134
|
] });
|
|
3113
|
-
};
|
|
3135
|
+
});
|
|
3114
3136
|
const ResultProduct = (props) => {
|
|
3115
3137
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
3116
3138
|
const {
|
|
@@ -3128,7 +3150,7 @@ const ResultProduct = (props) => {
|
|
|
3128
3150
|
showOutOfStock,
|
|
3129
3151
|
query,
|
|
3130
3152
|
data,
|
|
3131
|
-
|
|
3153
|
+
isJsVersion,
|
|
3132
3154
|
productCardsComponent,
|
|
3133
3155
|
setKeyword,
|
|
3134
3156
|
filterHorizontalSkeleton,
|
|
@@ -3138,7 +3160,8 @@ const ResultProduct = (props) => {
|
|
|
3138
3160
|
onAfterAddToCart,
|
|
3139
3161
|
onAfterAddWishlist,
|
|
3140
3162
|
onAfterRemoveWishlist,
|
|
3141
|
-
onAfterRenderProduct
|
|
3163
|
+
onAfterRenderProduct,
|
|
3164
|
+
searchResultContainerRef
|
|
3142
3165
|
} = props || {};
|
|
3143
3166
|
const { keyword: queryKeyword = "" } = query || {};
|
|
3144
3167
|
const { collectionId } = data || {};
|
|
@@ -3395,6 +3418,9 @@ const ResultProduct = (props) => {
|
|
|
3395
3418
|
};
|
|
3396
3419
|
const handlePageChange = (page) => {
|
|
3397
3420
|
setCurrentPage(page);
|
|
3421
|
+
setTimeout(() => {
|
|
3422
|
+
scrollToElement(searchResultContainerRef.current, 50);
|
|
3423
|
+
}, 200);
|
|
3398
3424
|
};
|
|
3399
3425
|
const handleChangeKeyword = (value) => {
|
|
3400
3426
|
const searchParams = new URLSearchParams(document.location.search);
|
|
@@ -3614,7 +3640,7 @@ const ResultProduct = (props) => {
|
|
|
3614
3640
|
});
|
|
3615
3641
|
const paginationComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Pagination, { currentPage, totalPage, totalResult: totalSearchResult, onChange: (page) => handlePageChange(page) });
|
|
3616
3642
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3617
|
-
((_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 ?
|
|
3643
|
+
((_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 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-loading", children: filterHorizontalSkeleton }) : filterHorizontalComponents.every((currentValue) => !currentValue) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal-wrapper", children: [
|
|
3618
3644
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal", children: filterHorizontalComponents }),
|
|
3619
3645
|
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: [
|
|
3620
3646
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -3637,7 +3663,7 @@ const ResultProduct = (props) => {
|
|
|
3637
3663
|
] }) }) : null
|
|
3638
3664
|
] }) }) }) : null,
|
|
3639
3665
|
/* @__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: [
|
|
3640
|
-
((_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 ?
|
|
3666
|
+
((_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 ? filterVerticalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3641
3667
|
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: [
|
|
3642
3668
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title-refine", children: [
|
|
3643
3669
|
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { className: "sledge-instant-search__result-filter-item-title-refine-heading", children: "Filter" }),
|
|
@@ -3739,7 +3765,7 @@ const ResultProduct = (props) => {
|
|
|
3739
3765
|
show_sku: (_s = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _s.show_sku,
|
|
3740
3766
|
show_price: (_t = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _t.show_price
|
|
3741
3767
|
},
|
|
3742
|
-
isComponentJsVersion:
|
|
3768
|
+
isComponentJsVersion: isJsVersion,
|
|
3743
3769
|
cards: productCardsComponent,
|
|
3744
3770
|
showOptionOutOfStock: true,
|
|
3745
3771
|
onAfterAddToCart,
|
|
@@ -3757,7 +3783,7 @@ const ResultProduct = (props) => {
|
|
|
3757
3783
|
};
|
|
3758
3784
|
const ResultCategory = (props) => {
|
|
3759
3785
|
var _a, _b, _c, _d;
|
|
3760
|
-
const { keyword, clickedTabIndexId, clickedTabIndexName, setKeyword } = props || {};
|
|
3786
|
+
const { keyword, clickedTabIndexId, clickedTabIndexName, setKeyword, searchResultContainerRef } = props || {};
|
|
3761
3787
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
3762
3788
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
3763
3789
|
const [clickedSortId, setClickedSortId] = React__default.useState("");
|
|
@@ -3810,6 +3836,9 @@ const ResultCategory = (props) => {
|
|
|
3810
3836
|
};
|
|
3811
3837
|
const handlePageChange = (page) => {
|
|
3812
3838
|
setCurrentPage(page);
|
|
3839
|
+
setTimeout(() => {
|
|
3840
|
+
scrollToElement(searchResultContainerRef.current, 50);
|
|
3841
|
+
}, 200);
|
|
3813
3842
|
};
|
|
3814
3843
|
React__default.useEffect(() => {
|
|
3815
3844
|
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
@@ -3888,16 +3917,15 @@ const ResultEmpty = (props) => {
|
|
|
3888
3917
|
const SearchWidget$1 = "";
|
|
3889
3918
|
const SearchWidget = (props) => {
|
|
3890
3919
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
3920
|
+
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
3891
3921
|
const { width = "400px", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
|
|
3892
3922
|
let productCardsComponent = null;
|
|
3893
3923
|
let suggestionKeywordListsComponent = null;
|
|
3894
3924
|
let otherIndexListsComponent = null;
|
|
3895
3925
|
let searchViewMoreResultComponent = null;
|
|
3896
|
-
let separateJsVersionComponent = false;
|
|
3897
3926
|
React__default.Children.map(children, (child) => {
|
|
3898
3927
|
if (React__default.isValidElement(child) && isFunction(child.type)) {
|
|
3899
|
-
const { component
|
|
3900
|
-
separateJsVersionComponent = isJsVersion;
|
|
3928
|
+
const { component } = (child == null ? void 0 : child.props) || {};
|
|
3901
3929
|
switch (child.type.name) {
|
|
3902
3930
|
case SEPARATE_COMPONENT_DISPLAY_NAME.PRODUCT.CARDS:
|
|
3903
3931
|
productCardsComponent = component;
|
|
@@ -3914,7 +3942,6 @@ const SearchWidget = (props) => {
|
|
|
3914
3942
|
}
|
|
3915
3943
|
}
|
|
3916
3944
|
});
|
|
3917
|
-
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
3918
3945
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
3919
3946
|
const [keyword, setKeyword] = React__default.useState("");
|
|
3920
3947
|
const [suffixIndexProduct, setSuffixIndexProduct] = React__default.useState("");
|
|
@@ -4084,12 +4111,12 @@ const SearchWidget = (props) => {
|
|
|
4084
4111
|
{
|
|
4085
4112
|
listsComponent: suggestionKeywordListsComponent,
|
|
4086
4113
|
keywords: suggestionSettings[suggestionIndex].keywords.list,
|
|
4087
|
-
isComponentJsVersion:
|
|
4114
|
+
isComponentJsVersion: isJsVersion
|
|
4088
4115
|
}
|
|
4089
4116
|
) : null,
|
|
4090
4117
|
searchResultOther.map((item, index) => {
|
|
4091
4118
|
const { hits, name } = item;
|
|
4092
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Global.OtherIndexLists, { listsComponent: otherIndexListsComponent, name, items: hits, isComponentJsVersion:
|
|
4119
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Global.OtherIndexLists, { listsComponent: otherIndexListsComponent, name, items: hits, isComponentJsVersion: isJsVersion }) }, index);
|
|
4093
4120
|
})
|
|
4094
4121
|
] }),
|
|
4095
4122
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-product", children: [
|
|
@@ -4112,7 +4139,7 @@ const SearchWidget = (props) => {
|
|
|
4112
4139
|
show_price: (_h = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _h.show_price
|
|
4113
4140
|
},
|
|
4114
4141
|
showOptionOutOfStock: true,
|
|
4115
|
-
isComponentJsVersion:
|
|
4142
|
+
isComponentJsVersion: isJsVersion,
|
|
4116
4143
|
cards: productCardsComponent,
|
|
4117
4144
|
onAfterAddToCart,
|
|
4118
4145
|
onAfterAddWishlist,
|
|
@@ -4145,7 +4172,7 @@ const SearchWidget = (props) => {
|
|
|
4145
4172
|
show_price: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_price
|
|
4146
4173
|
},
|
|
4147
4174
|
showOptionOutOfStock: true,
|
|
4148
|
-
isComponentJsVersion:
|
|
4175
|
+
isComponentJsVersion: isJsVersion,
|
|
4149
4176
|
cards: productCardsComponent,
|
|
4150
4177
|
onAfterAddToCart,
|
|
4151
4178
|
onAfterAddWishlist,
|
|
@@ -4156,7 +4183,7 @@ const SearchWidget = (props) => {
|
|
|
4156
4183
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-product-disabled", children: "No product were found" })
|
|
4157
4184
|
] })
|
|
4158
4185
|
] }),
|
|
4159
|
-
(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:
|
|
4186
|
+
(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
|
|
4160
4187
|
] }) }) })
|
|
4161
4188
|
] });
|
|
4162
4189
|
};
|