@sledge-app/react-instant-search 0.0.58 → 0.0.59
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/Global/OtherIndexLists.d.ts +3 -1
- package/dist/components/Global/OtherIndexLists.d.ts.map +1 -1
- package/dist/components/Global/SearchViewMoreResult.d.ts +3 -1
- package/dist/components/Global/SearchViewMoreResult.d.ts.map +1 -1
- package/dist/components/Global/SuggestionKeywordLists.d.ts +3 -1
- package/dist/components/Global/SuggestionKeywordLists.d.ts.map +1 -1
- package/dist/components/Global/index.d.ts +9 -3
- package/dist/components/Global/index.d.ts.map +1 -1
- 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 +73 -37
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1179,30 +1179,33 @@ const Rating = (props) => {
|
|
|
1179
1179
|
const [dataSettings, setDataSettings] = React__default.useState({});
|
|
1180
1180
|
const previousState = usePrevious({ productId });
|
|
1181
1181
|
const { fill_color, outline_color } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.rating) || {};
|
|
1182
|
-
const handleProductRatingInfo = async () => {
|
|
1182
|
+
const handleProductRatingInfo = async (validateProductId) => {
|
|
1183
1183
|
var _a2;
|
|
1184
|
+
let response;
|
|
1185
|
+
let run = false;
|
|
1186
|
+
let valueTotalReview = 0;
|
|
1187
|
+
let valueAverageReview;
|
|
1188
|
+
response = await getReviewInfo(validateProductId);
|
|
1189
|
+
if (!response)
|
|
1190
|
+
return;
|
|
1191
|
+
const { status, data: data2 } = response;
|
|
1192
|
+
const { code } = status;
|
|
1193
|
+
run = code === 200 || false;
|
|
1194
|
+
valueTotalReview = (data2 == null ? void 0 : data2.review_count) ? data2.review_count : 0;
|
|
1195
|
+
valueAverageReview = ((_a2 = data2 == null ? void 0 : data2.rating) == null ? void 0 : _a2.average) ? data2.rating.average : 0;
|
|
1196
|
+
if (run) {
|
|
1197
|
+
setTotalReview(valueTotalReview);
|
|
1198
|
+
setAverageReview(valueAverageReview);
|
|
1199
|
+
setIsLoading(false);
|
|
1200
|
+
setIsFirstLoading(false);
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
const handleRefreshProductRating = async () => {
|
|
1184
1204
|
if (value && !data) {
|
|
1185
1205
|
setAverageReview(value);
|
|
1186
1206
|
setIsLoading(false);
|
|
1187
1207
|
} else {
|
|
1188
|
-
|
|
1189
|
-
let run = false;
|
|
1190
|
-
let valueTotalReview = 0;
|
|
1191
|
-
let valueAverageReview;
|
|
1192
|
-
response = await getReviewInfo(productId);
|
|
1193
|
-
if (!response)
|
|
1194
|
-
return;
|
|
1195
|
-
const { status, data: data2 } = response;
|
|
1196
|
-
const { code } = status;
|
|
1197
|
-
run = code === 200 || false;
|
|
1198
|
-
valueTotalReview = (data2 == null ? void 0 : data2.review_count) ? data2.review_count : 0;
|
|
1199
|
-
valueAverageReview = ((_a2 = data2 == null ? void 0 : data2.rating) == null ? void 0 : _a2.average) ? data2.rating.average : 0;
|
|
1200
|
-
if (run) {
|
|
1201
|
-
setTotalReview(valueTotalReview);
|
|
1202
|
-
setAverageReview(valueAverageReview);
|
|
1203
|
-
setIsLoading(false);
|
|
1204
|
-
setIsFirstLoading(false);
|
|
1205
|
-
}
|
|
1208
|
+
handleProductRatingInfo(productId);
|
|
1206
1209
|
}
|
|
1207
1210
|
};
|
|
1208
1211
|
const handleSettings = async (LOCAL_STORAGE_PRODUCT_REVIEW_SETTING) => {
|
|
@@ -1217,7 +1220,7 @@ const Rating = (props) => {
|
|
|
1217
1220
|
run = code === 200 || false;
|
|
1218
1221
|
if (run) {
|
|
1219
1222
|
setDataSettings(data2);
|
|
1220
|
-
await
|
|
1223
|
+
await handleRefreshProductRating();
|
|
1221
1224
|
}
|
|
1222
1225
|
};
|
|
1223
1226
|
const handleOnClick = () => {
|
|
@@ -1230,10 +1233,10 @@ const Rating = (props) => {
|
|
|
1230
1233
|
React__default.useEffect(() => {
|
|
1231
1234
|
if (!(isRenderApp == null ? void 0 : isRenderApp.productReview))
|
|
1232
1235
|
return;
|
|
1233
|
-
console.log("triggered add product review");
|
|
1234
1236
|
if (typeof window !== "undefined") {
|
|
1235
1237
|
window.sledgeProductReviewRatingUpdate = () => {
|
|
1236
|
-
|
|
1238
|
+
setIsLoading(true);
|
|
1239
|
+
handleRefreshProductRating();
|
|
1237
1240
|
};
|
|
1238
1241
|
}
|
|
1239
1242
|
if (size === "xs") {
|
|
@@ -1476,10 +1479,10 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1476
1479
|
setIsFirstLoading(true);
|
|
1477
1480
|
handleProductReviewInfo();
|
|
1478
1481
|
}, [isOpen, productId]);
|
|
1479
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "630px", height: "42px", color: "grey-100", rounded: "md", animationDuration: "5s" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1482
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "630px", height: "42px", color: "grey-100", rounded: "md", animationDuration: "5s" }) : isLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1480
1483
|
Popover,
|
|
1481
1484
|
{
|
|
1482
|
-
trigger:
|
|
1485
|
+
trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(motion.div, { initial: false, animate: isOpen ? "open" : "closed", className: "sledge-product-review__widget-summary-trigger", children: [
|
|
1483
1486
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-average", children: averageReview }),
|
|
1484
1487
|
/* @__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 }) }),
|
|
1485
1488
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__widget-summary-total", children: [
|
|
@@ -1665,7 +1668,9 @@ const ProductGrid = ({
|
|
|
1665
1668
|
onAfterAddToCart,
|
|
1666
1669
|
onAfterAddWishlist,
|
|
1667
1670
|
onAfterRemoveWishlist,
|
|
1668
|
-
onAfterRenderProduct
|
|
1671
|
+
onAfterRenderProduct,
|
|
1672
|
+
showPopupComponent,
|
|
1673
|
+
setShowPopupComponent
|
|
1669
1674
|
}) => {
|
|
1670
1675
|
const {
|
|
1671
1676
|
show_vendor = true,
|
|
@@ -1747,7 +1752,9 @@ const ProductGrid = ({
|
|
|
1747
1752
|
};
|
|
1748
1753
|
})
|
|
1749
1754
|
}
|
|
1750
|
-
}
|
|
1755
|
+
},
|
|
1756
|
+
showPopupComponent,
|
|
1757
|
+
setShowPopupComponent
|
|
1751
1758
|
}) : null;
|
|
1752
1759
|
return cards ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: getCards } }) : getCards }, index) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
|
|
1753
1760
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
|
|
@@ -2273,8 +2280,15 @@ const SearchIconWidget = (props) => {
|
|
|
2273
2280
|
};
|
|
2274
2281
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__icon-widget", onClick: handleShowWidget, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { ...sizing, color: "currentColor" }) });
|
|
2275
2282
|
};
|
|
2276
|
-
const OtherIndexLists = ({
|
|
2277
|
-
|
|
2283
|
+
const OtherIndexLists = ({
|
|
2284
|
+
listsComponent,
|
|
2285
|
+
name,
|
|
2286
|
+
items,
|
|
2287
|
+
isComponentJsVersion,
|
|
2288
|
+
showPopupComponent,
|
|
2289
|
+
setShowPopupComponent
|
|
2290
|
+
}) => {
|
|
2291
|
+
const getListsComponent = listsComponent ? listsComponent({ name, items, showPopupComponent, setShowPopupComponent }) : null;
|
|
2278
2292
|
return listsComponent ? isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: getListsComponent } }) : getListsComponent : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2279
2293
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-title", children: name }),
|
|
2280
2294
|
(items == null ? void 0 : items.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__icon-widget-search-form-result-list", children: items.map((hit, index) => {
|
|
@@ -2287,8 +2301,14 @@ const OtherIndexLists = ({ listsComponent, name, items, isComponentJsVersion })
|
|
|
2287
2301
|
] }) })
|
|
2288
2302
|
] });
|
|
2289
2303
|
};
|
|
2290
|
-
const SuggestionKeywordLists = ({
|
|
2291
|
-
|
|
2304
|
+
const SuggestionKeywordLists = ({
|
|
2305
|
+
listsComponent,
|
|
2306
|
+
keywords,
|
|
2307
|
+
isComponentJsVersion = false,
|
|
2308
|
+
showPopupComponent,
|
|
2309
|
+
setShowPopupComponent
|
|
2310
|
+
}) => {
|
|
2311
|
+
const getListsComponent = listsComponent ? listsComponent({ keywords, showPopupComponent, setShowPopupComponent }) : null;
|
|
2292
2312
|
return listsComponent ? isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: getListsComponent } }) : getListsComponent : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2293
2313
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-title", children: "Suggestions" }),
|
|
2294
2314
|
/* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__icon-widget-search-form-result-list", children: keywords == null ? void 0 : keywords.map((keyword, index) => {
|
|
@@ -2307,8 +2327,14 @@ const SuggestionKeywordLists = ({ listsComponent, keywords, isComponentJsVersion
|
|
|
2307
2327
|
}) })
|
|
2308
2328
|
] });
|
|
2309
2329
|
};
|
|
2310
|
-
const SearchViewMoreResult = ({
|
|
2311
|
-
|
|
2330
|
+
const SearchViewMoreResult = ({
|
|
2331
|
+
component,
|
|
2332
|
+
keyword,
|
|
2333
|
+
isComponentJsVersion = false,
|
|
2334
|
+
showPopupComponent,
|
|
2335
|
+
setShowPopupComponent
|
|
2336
|
+
}) => {
|
|
2337
|
+
const getComponent = component ? component({ keyword, showPopupComponent, setShowPopupComponent }) : null;
|
|
2312
2338
|
return component ? isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: getComponent } }) : getComponent : /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: `${SEARCH_RESULT_URL}?q=${keyword}`, className: "sledge-instant-search__icon-widget-button-more", children: "View More Result" });
|
|
2313
2339
|
};
|
|
2314
2340
|
const Global = {
|
|
@@ -2542,7 +2568,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
2542
2568
|
{
|
|
2543
2569
|
listsComponent: handleFunctions.suggestionKeywordListsComponent,
|
|
2544
2570
|
keywords: suggestionSettings[suggestionIndex].keywords.list,
|
|
2545
|
-
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2571
|
+
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
2572
|
+
showPopupComponent: showInfo,
|
|
2573
|
+
setShowPopupComponent: setShowInfo
|
|
2546
2574
|
}
|
|
2547
2575
|
) : null,
|
|
2548
2576
|
searchResultOther && searchResultOther.map((item, index) => {
|
|
@@ -2553,7 +2581,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
2553
2581
|
listsComponent: handleFunctions.otherIndexListsComponent,
|
|
2554
2582
|
name,
|
|
2555
2583
|
items: hits,
|
|
2556
|
-
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2584
|
+
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
2585
|
+
showPopupComponent: showInfo,
|
|
2586
|
+
setShowPopupComponent: setShowInfo
|
|
2557
2587
|
}
|
|
2558
2588
|
) }, index);
|
|
2559
2589
|
})
|
|
@@ -2582,7 +2612,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
2582
2612
|
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2583
2613
|
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
2584
2614
|
onAfterRemoveWishlist: handleFunctions.onAfterRemoveWishlist,
|
|
2585
|
-
onAfterRenderProduct: handleFunctions.onAfterRenderProduct
|
|
2615
|
+
onAfterRenderProduct: handleFunctions.onAfterRenderProduct,
|
|
2616
|
+
showPopupComponent: showInfo,
|
|
2617
|
+
setShowPopupComponent: setShowInfo
|
|
2586
2618
|
}
|
|
2587
2619
|
) }) : Object.keys(suggestionSettings).length && ((_k = (_j = suggestionSettings[suggestionIndex]) == null ? void 0 : _j.products) == null ? void 0 : _k.active) && ((_n = (_m = (_l = suggestionSettings[suggestionIndex]) == null ? void 0 : _l.products) == null ? void 0 : _m.list) == null ? void 0 : _n.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2588
2620
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-product-suggestion-no-result-text", children: [
|
|
@@ -2614,7 +2646,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
2614
2646
|
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2615
2647
|
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
2616
2648
|
onAfterRemoveWishlist: handleFunctions.onAfterRemoveWishlist,
|
|
2617
|
-
onAfterRenderProduct: handleFunctions.onAfterRenderProduct
|
|
2649
|
+
onAfterRenderProduct: handleFunctions.onAfterRenderProduct,
|
|
2650
|
+
showPopupComponent: showInfo,
|
|
2651
|
+
setShowPopupComponent: setShowInfo
|
|
2618
2652
|
}
|
|
2619
2653
|
)
|
|
2620
2654
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
@@ -2626,7 +2660,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
2626
2660
|
{
|
|
2627
2661
|
component: handleFunctions.searchViewMoreResultComponent,
|
|
2628
2662
|
keyword,
|
|
2629
|
-
isComponentJsVersion: handleFunctions.isJsVersion
|
|
2663
|
+
isComponentJsVersion: handleFunctions.isJsVersion,
|
|
2664
|
+
showPopupComponent: showInfo,
|
|
2665
|
+
setShowPopupComponent: setShowInfo
|
|
2630
2666
|
}
|
|
2631
2667
|
) }) : null
|
|
2632
2668
|
] })
|