@sledge-app/react-instant-search 0.0.78 → 0.0.80
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 -0
- package/dist/components/ProductFilterWidget/ProductFilterWidget.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 +22 -17
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1159,7 +1159,7 @@ const Rating = (props) => {
|
|
|
1159
1159
|
var _a;
|
|
1160
1160
|
const { value, size = "md", params, withSkeletonLoading = true, isScrollToElementWidget = true, data: propsData } = props;
|
|
1161
1161
|
const { productId } = params || {};
|
|
1162
|
-
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
1162
|
+
const { isRenderApp, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
|
|
1163
1163
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
1164
1164
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
1165
1165
|
const [sizing, setSizing] = React__default.useState({
|
|
@@ -1171,15 +1171,17 @@ const Rating = (props) => {
|
|
|
1171
1171
|
const [dataSettings, setDataSettings] = React__default.useState({});
|
|
1172
1172
|
const previousState = usePrevious({ productId });
|
|
1173
1173
|
const { fill_color, outline_color } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.rating) || {};
|
|
1174
|
-
const handleProductRatingInfo = async (
|
|
1175
|
-
var _a2;
|
|
1174
|
+
const handleProductRatingInfo = async (paramsProductId, isTriggerMultiComponent = false) => {
|
|
1175
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1176
|
+
if (paramsProductId !== productId)
|
|
1177
|
+
return;
|
|
1176
1178
|
let response;
|
|
1177
1179
|
let run = false;
|
|
1178
1180
|
let valueTotalReview = 0;
|
|
1179
1181
|
let valueAverageReview;
|
|
1180
1182
|
let data;
|
|
1181
1183
|
if (!propsData) {
|
|
1182
|
-
response = await getReviewInfo(
|
|
1184
|
+
response = await getReviewInfo(paramsProductId);
|
|
1183
1185
|
if (!response)
|
|
1184
1186
|
return;
|
|
1185
1187
|
const { status } = response;
|
|
@@ -1197,6 +1199,8 @@ const Rating = (props) => {
|
|
|
1197
1199
|
setAverageReview(valueAverageReview);
|
|
1198
1200
|
setIsLoading(false);
|
|
1199
1201
|
setIsFirstLoading(false);
|
|
1202
|
+
if (isTriggerMultiComponent && ((_c = (_b = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _b.rating) == null ? void 0 : _c.value) && ((_e = (_d = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _d.rating) == null ? void 0 : _e.trigger))
|
|
1203
|
+
(_g = (_f = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _f.rating) == null ? void 0 : _g.trigger("");
|
|
1200
1204
|
}
|
|
1201
1205
|
};
|
|
1202
1206
|
const handleRefreshProductRating = async () => {
|
|
@@ -1226,12 +1230,6 @@ const Rating = (props) => {
|
|
|
1226
1230
|
React__default.useEffect(() => {
|
|
1227
1231
|
if (!(isRenderApp == null ? void 0 : isRenderApp.productReview))
|
|
1228
1232
|
return;
|
|
1229
|
-
if (typeof window !== "undefined") {
|
|
1230
|
-
window.sledgeProductReviewRatingUpdate = () => {
|
|
1231
|
-
setIsLoading(true);
|
|
1232
|
-
handleRefreshProductRating();
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
1233
|
if (size === "xs") {
|
|
1236
1234
|
setSizing({
|
|
1237
1235
|
width: 14.4,
|
|
@@ -1253,6 +1251,13 @@ const Rating = (props) => {
|
|
|
1253
1251
|
setIsFirstLoading(true);
|
|
1254
1252
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || "");
|
|
1255
1253
|
}, [isRenderApp, productId]);
|
|
1254
|
+
React__default.useEffect(() => {
|
|
1255
|
+
var _a2, _b, _c, _d;
|
|
1256
|
+
if (!productId || productId && ((_b = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _a2.rating) == null ? void 0 : _b.value) !== productId)
|
|
1257
|
+
return;
|
|
1258
|
+
setIsFirstLoading(true);
|
|
1259
|
+
handleProductRatingInfo((_d = (_c = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _c.rating) == null ? void 0 : _d.value, true);
|
|
1260
|
+
}, [productId, triggerRenderMultipleComponent]);
|
|
1256
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: [
|
|
1257
1262
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", style: { display: "none" }, id: "sledge-product-review-rating-icon-svg-store", children: [
|
|
1258
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(
|
|
@@ -2666,7 +2671,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
2666
2671
|
] }) });
|
|
2667
2672
|
};
|
|
2668
2673
|
const SearchResultWidget = (props) => {
|
|
2669
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
2674
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2670
2675
|
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
2671
2676
|
const { layoutType = "default", query, params, children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct, data: propsData } = props;
|
|
2672
2677
|
const { keyword: queryKeyword = "" } = query || {};
|
|
@@ -2680,7 +2685,7 @@ const SearchResultWidget = (props) => {
|
|
|
2680
2685
|
}
|
|
2681
2686
|
});
|
|
2682
2687
|
const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
|
|
2683
|
-
const [settings] = React__default.useState(typeof localStorage !== "undefined" ?
|
|
2688
|
+
const [settings] = React__default.useState(typeof localStorage !== "undefined" ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}") : {});
|
|
2684
2689
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
2685
2690
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
2686
2691
|
const [keyword, setKeyword] = React__default.useState(searchParams == null ? void 0 : searchParams.get(queryKeyword));
|
|
@@ -2848,8 +2853,8 @@ const SearchResultWidget = (props) => {
|
|
|
2848
2853
|
}
|
|
2849
2854
|
}, [keyword]);
|
|
2850
2855
|
const tabSkeleton = layoutType === "default" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-tab-list sledge-instant-search__result-tab-list-skeleton", children: [1, 2, 3, 4, 5].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "122px", height: "28px", rounded: "md", color: "grey-100", animationDuration: "15s" }, index)) }) : null;
|
|
2851
|
-
const filterHorizontalSkeleton = ((
|
|
2852
|
-
const filterVerticalSkeleton = ((
|
|
2856
|
+
const filterHorizontalSkeleton = ((_b = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b.enable_on_search) && ((_c = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _c.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-skeleton", children: [1, 2, 3, 4, 5, 6, 7].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "106px", height: "42px", rounded: "md", color: "grey-100", animationDuration: "13s" }, index)) }) : null;
|
|
2857
|
+
const filterVerticalSkeleton = ((_d = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _d.enable_on_search) && ((_e = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _e.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2853
2858
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2854
2859
|
"div",
|
|
2855
2860
|
{
|
|
@@ -3065,7 +3070,7 @@ const SearchResultWidget = (props) => {
|
|
|
3065
3070
|
)
|
|
3066
3071
|
] }) : null;
|
|
3067
3072
|
const productGridSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3068
|
-
((
|
|
3073
|
+
((_f = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _f.show_total_products) && ((_g = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _g.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3069
3074
|
SkeletonLoading.Item,
|
|
3070
3075
|
{
|
|
3071
3076
|
width: "117px",
|
|
@@ -3081,7 +3086,7 @@ const SearchResultWidget = (props) => {
|
|
|
3081
3086
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 12, type: "large" })
|
|
3082
3087
|
] });
|
|
3083
3088
|
const searchAndSelectOptionSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
3084
|
-
((
|
|
3089
|
+
((_h = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _h.show_total_products) && ((_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "grey-100", rounded: "md", animationDuration: "13s" }) }) : null,
|
|
3085
3090
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-keyword-form", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3086
3091
|
SkeletonLoading.Item,
|
|
3087
3092
|
{
|
|
@@ -3112,7 +3117,7 @@ const SearchResultWidget = (props) => {
|
|
|
3112
3117
|
tabSkeleton,
|
|
3113
3118
|
filterHorizontalSkeleton,
|
|
3114
3119
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-wrapper sledge-instant-search__result-wrapper-skeleton", children: [
|
|
3115
|
-
((
|
|
3120
|
+
((_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" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : null,
|
|
3116
3121
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
|
|
3117
3122
|
searchAndSelectOptionSkeleton,
|
|
3118
3123
|
productGridSkeleton
|