@sledge-app/react-instant-search 0.0.80 → 0.0.82
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 +1 -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/SearchIconWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts +1 -0
- 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 +149 -99
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/vendor-024ba8ae.cjs +2 -0
- package/dist/vendor-024ba8ae.cjs.map +1 -0
- package/dist/{vendor-eeee87f8.js → vendor-90dfd914.js} +18 -637
- package/dist/vendor-90dfd914.js.map +1 -0
- package/package.json +1 -1
- package/dist/vendor-b4f78627.cjs +0 -2
- package/dist/vendor-b4f78627.cjs.map +0 -1
- package/dist/vendor-eeee87f8.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as $a093c7e1ec25a057$export$2881499e37b75b9a, F as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, G as $a093c7e1ec25a057$export$41fb9f06171c75f4, H as $a093c7e1ec25a057$export$602eac185826482c, I as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, J as $a093c7e1ec25a057$export$21b07c8f274aebd5, K as $57acba87d6e25586$export$be92b6f5f03c0fe9, L as $57acba87d6e25586$export$d5c6c08dc2d3ca7, M as $57acba87d6e25586$export$9a4e88b92edfce6b, N as $57acba87d6e25586$export$6521433ed15a34db, O as $57acba87d6e25586$export$ac61190d9fc311a9, P as MasonryResponsive, Q as Masonry, R as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, S as $5d3850c4d0b4e6c7$export$602eac185826482c, T as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, U as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-
|
|
1
|
+
import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as $a093c7e1ec25a057$export$2881499e37b75b9a, F as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, G as $a093c7e1ec25a057$export$41fb9f06171c75f4, H as $a093c7e1ec25a057$export$602eac185826482c, I as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, J as $a093c7e1ec25a057$export$21b07c8f274aebd5, K as $57acba87d6e25586$export$be92b6f5f03c0fe9, L as $57acba87d6e25586$export$d5c6c08dc2d3ca7, M as $57acba87d6e25586$export$9a4e88b92edfce6b, N as $57acba87d6e25586$export$6521433ed15a34db, O as $57acba87d6e25586$export$ac61190d9fc311a9, P as MasonryResponsive, Q as Masonry, R as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, S as $5d3850c4d0b4e6c7$export$602eac185826482c, T as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, U as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-90dfd914.js";
|
|
2
2
|
import React__default, { createElement } from "react";
|
|
3
3
|
import { SledgeContext } from "@sledge-app/core";
|
|
4
4
|
import "react-dom";
|
|
@@ -13,7 +13,8 @@ const LOCAL_STORAGE_KEY = {
|
|
|
13
13
|
INSTANT_SEARCH_AUTH_APP: "sledge-instant-search-auth-app",
|
|
14
14
|
WISHLIST_SETTING: "sledge-wishlist-setting",
|
|
15
15
|
PRODUCT_REVIEW_SETTING: "sledge-product-review-setting",
|
|
16
|
-
INSTANT_SEARCH_SETTING: "sledge-instant-search-setting"
|
|
16
|
+
INSTANT_SEARCH_SETTING: "sledge-instant-search-setting",
|
|
17
|
+
EXPIRY_SETTING: "sledge-expiry-setting"
|
|
17
18
|
};
|
|
18
19
|
const SEARCH_RESULT_URL = "/pages/search-result";
|
|
19
20
|
const ELEMENT_ID = {
|
|
@@ -626,23 +627,27 @@ const Trigger = (props) => {
|
|
|
626
627
|
const defaultTypeIcon = "outline";
|
|
627
628
|
const activeColorIcon = "#F85538";
|
|
628
629
|
const activeTypeIcon = "fill";
|
|
629
|
-
const
|
|
630
|
-
const
|
|
631
|
-
const [
|
|
632
|
-
const [
|
|
630
|
+
const wishlistCheckedFilled = typeof wishlistChecked === "boolean";
|
|
631
|
+
const isWishlisted = wishlistCheckedFilled ? wishlistChecked : false;
|
|
632
|
+
const [colorIcon, setColorIcon] = React__default.useState(isWishlisted ? activeColorIcon : defaultColorIcon);
|
|
633
|
+
const [typeIcon, setTypeIcon] = React__default.useState(isWishlisted ? activeTypeIcon : defaultTypeIcon);
|
|
634
|
+
const [isWishlist, setIsWishlist] = React__default.useState(!!wishlistChecked);
|
|
635
|
+
const [isLoading, setIsLoading] = React__default.useState(!wishlistCheckedFilled);
|
|
633
636
|
const [dataSettings, setDataSettings] = React__default.useState({});
|
|
634
637
|
const [handleFunctions, _setHandleFunctions] = React__default.useState({
|
|
635
638
|
onAfterAddWishlist,
|
|
636
639
|
onAfterRemoveWishlist
|
|
637
640
|
});
|
|
638
641
|
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
642
|
+
const [isFirstTime, setIsFirstTime] = React__default.useState(true);
|
|
639
643
|
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
640
644
|
const { show: show_notification, location: location_notification } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.notification) || {};
|
|
641
645
|
const { title_added_to_wishlist, text_added_to_wishlist, title_removed_to_wishlist, text_removed_to_wishlist } = ((_c = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _c.notification) || {};
|
|
642
|
-
const handleCheckWishlist = async (
|
|
646
|
+
const handleCheckWishlist = async () => {
|
|
643
647
|
let response;
|
|
644
|
-
if (typeof wishlistChecked === "boolean" &&
|
|
648
|
+
if (typeof wishlistChecked === "boolean" && isFirstTime) {
|
|
645
649
|
response = wishlistChecked;
|
|
650
|
+
setIsFirstTime(false);
|
|
646
651
|
} else {
|
|
647
652
|
response = await checkWishlist(productId, productVariantId);
|
|
648
653
|
}
|
|
@@ -724,7 +729,7 @@ const Trigger = (props) => {
|
|
|
724
729
|
return;
|
|
725
730
|
if (typeof window !== "undefined") {
|
|
726
731
|
window.sledgeWishlistTriggerUpdate = () => {
|
|
727
|
-
handleCheckWishlist(
|
|
732
|
+
handleCheckWishlist();
|
|
728
733
|
};
|
|
729
734
|
}
|
|
730
735
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || "");
|
|
@@ -735,7 +740,7 @@ const Trigger = (props) => {
|
|
|
735
740
|
React__default.useEffect(() => {
|
|
736
741
|
if (!(isRenderApp == null ? void 0 : isRenderApp.wishlist))
|
|
737
742
|
return;
|
|
738
|
-
handleCheckWishlist(
|
|
743
|
+
handleCheckWishlist();
|
|
739
744
|
}, [isRenderApp, productVariantId]);
|
|
740
745
|
const isActive = (isWishlist || forceActive) && !isRequiredLogin;
|
|
741
746
|
React__default.useEffect(() => {
|
|
@@ -1156,23 +1161,27 @@ const getReviewInfo = async (id) => {
|
|
|
1156
1161
|
});
|
|
1157
1162
|
};
|
|
1158
1163
|
const Rating = (props) => {
|
|
1159
|
-
var _a;
|
|
1160
|
-
const { value, size = "md", params, withSkeletonLoading = true, isScrollToElementWidget = true, data: propsData } = props;
|
|
1164
|
+
var _a, _b;
|
|
1165
|
+
const { value, size = "md", params, withSkeletonLoading = true, isScrollToElementWidget = true, data: propsData, sledgeSettings } = props;
|
|
1161
1166
|
const { productId } = params || {};
|
|
1162
1167
|
const { isRenderApp, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
|
|
1163
|
-
const
|
|
1164
|
-
const [
|
|
1165
|
-
const [
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1168
|
+
const initLoading = propsData || value ? false : true;
|
|
1169
|
+
const [isFirstLoading, setIsFirstLoading] = React__default.useState(initLoading);
|
|
1170
|
+
const [isLoading, setIsLoading] = React__default.useState(initLoading);
|
|
1171
|
+
const [sizing, setSizing] = React__default.useState(
|
|
1172
|
+
propsData || value ? getSizing(size) : {
|
|
1173
|
+
width: 0,
|
|
1174
|
+
height: 0
|
|
1175
|
+
}
|
|
1176
|
+
);
|
|
1177
|
+
const [totalReview, setTotalReview] = React__default.useState((propsData == null ? void 0 : propsData.review_count) || 0);
|
|
1178
|
+
const [averageReview, setAverageReview] = React__default.useState(((_a = propsData == null ? void 0 : propsData.rating) == null ? void 0 : _a.average) || value || "0");
|
|
1179
|
+
const [dataSettings, setDataSettings] = React__default.useState((sledgeSettings == null ? void 0 : sledgeSettings.review) || {});
|
|
1180
|
+
const [isFirstTime, setIsFirstTime] = React__default.useState(true);
|
|
1172
1181
|
const previousState = usePrevious({ productId });
|
|
1173
|
-
const { fill_color, outline_color } = ((
|
|
1182
|
+
const { fill_color, outline_color } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.rating) || {};
|
|
1174
1183
|
const handleProductRatingInfo = async (paramsProductId, isTriggerMultiComponent = false) => {
|
|
1175
|
-
var _a2,
|
|
1184
|
+
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
1176
1185
|
if (paramsProductId !== productId)
|
|
1177
1186
|
return;
|
|
1178
1187
|
let response;
|
|
@@ -1180,7 +1189,11 @@ const Rating = (props) => {
|
|
|
1180
1189
|
let valueTotalReview = 0;
|
|
1181
1190
|
let valueAverageReview;
|
|
1182
1191
|
let data;
|
|
1183
|
-
if (
|
|
1192
|
+
if (propsData && isFirstTime) {
|
|
1193
|
+
data = propsData;
|
|
1194
|
+
run = true;
|
|
1195
|
+
setIsFirstTime(false);
|
|
1196
|
+
} else {
|
|
1184
1197
|
response = await getReviewInfo(paramsProductId);
|
|
1185
1198
|
if (!response)
|
|
1186
1199
|
return;
|
|
@@ -1188,9 +1201,6 @@ const Rating = (props) => {
|
|
|
1188
1201
|
data = response.data;
|
|
1189
1202
|
const { code } = status;
|
|
1190
1203
|
run = code === 200 || false;
|
|
1191
|
-
} else {
|
|
1192
|
-
data = propsData;
|
|
1193
|
-
run = true;
|
|
1194
1204
|
}
|
|
1195
1205
|
valueTotalReview = (data == null ? void 0 : data.review_count) ? data.review_count : 0;
|
|
1196
1206
|
valueAverageReview = ((_a2 = data == null ? void 0 : data.rating) == null ? void 0 : _a2.average) ? data.rating.average : 0;
|
|
@@ -1199,7 +1209,7 @@ const Rating = (props) => {
|
|
|
1199
1209
|
setAverageReview(valueAverageReview);
|
|
1200
1210
|
setIsLoading(false);
|
|
1201
1211
|
setIsFirstLoading(false);
|
|
1202
|
-
if (isTriggerMultiComponent && ((_c = (
|
|
1212
|
+
if (isTriggerMultiComponent && ((_c = (_b2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _b2.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
1213
|
(_g = (_f = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _f.rating) == null ? void 0 : _g.trigger("");
|
|
1204
1214
|
}
|
|
1205
1215
|
};
|
|
@@ -1252,8 +1262,8 @@ const Rating = (props) => {
|
|
|
1252
1262
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || "");
|
|
1253
1263
|
}, [isRenderApp, productId]);
|
|
1254
1264
|
React__default.useEffect(() => {
|
|
1255
|
-
var _a2,
|
|
1256
|
-
if (!productId || productId && ((
|
|
1265
|
+
var _a2, _b2, _c, _d;
|
|
1266
|
+
if (!productId || productId && ((_b2 = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _a2.rating) == null ? void 0 : _b2.value) !== productId)
|
|
1257
1267
|
return;
|
|
1258
1268
|
setIsFirstLoading(true);
|
|
1259
1269
|
handleProductRatingInfo((_d = (_c = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.productReview) == null ? void 0 : _c.rating) == null ? void 0 : _d.value, true);
|
|
@@ -1303,6 +1313,24 @@ const Rating = (props) => {
|
|
|
1303
1313
|
] })
|
|
1304
1314
|
] }) });
|
|
1305
1315
|
};
|
|
1316
|
+
const getSizing = (size) => {
|
|
1317
|
+
if (size === "xs") {
|
|
1318
|
+
return {
|
|
1319
|
+
width: 14.4,
|
|
1320
|
+
height: 14.4
|
|
1321
|
+
};
|
|
1322
|
+
} else if (size === "sm") {
|
|
1323
|
+
return {
|
|
1324
|
+
width: 18,
|
|
1325
|
+
height: 18
|
|
1326
|
+
};
|
|
1327
|
+
} else {
|
|
1328
|
+
return {
|
|
1329
|
+
width: 28.8,
|
|
1330
|
+
height: 28.8
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1306
1334
|
const WidgetHeaderAddTrigger = ({ isFirstLoading, text, dataSettings, params, onAfterAddReview }) => {
|
|
1307
1335
|
var _a, _b, _c;
|
|
1308
1336
|
const {
|
|
@@ -1354,7 +1382,7 @@ const WidgetHeaderAddTrigger = ({ isFirstLoading, text, dataSettings, params, on
|
|
|
1354
1382
|
}
|
|
1355
1383
|
) });
|
|
1356
1384
|
};
|
|
1357
|
-
const WidgetHeaderSort = ({ isFirstLoading, productReviewSort, dataSettings, setSelectedSort, setIsRefreshWidgetList
|
|
1385
|
+
const WidgetHeaderSort = ({ isFirstLoading, productReviewSort, dataSettings, setSelectedSort, setIsRefreshWidgetList }) => {
|
|
1358
1386
|
var _a, _b;
|
|
1359
1387
|
const { default_sort, show_sorting_options } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.widget) || {};
|
|
1360
1388
|
const [clickedSortId, setClickedSortId] = React__default.useState(default_sort || null);
|
|
@@ -1387,7 +1415,6 @@ const WidgetHeaderSort = ({ isFirstLoading, productReviewSort, dataSettings, set
|
|
|
1387
1415
|
}),
|
|
1388
1416
|
value: getSelectedSort,
|
|
1389
1417
|
onChange: ({ value }) => handleChangeSort(value),
|
|
1390
|
-
LinkComponent,
|
|
1391
1418
|
link: "?page=1&sort=value"
|
|
1392
1419
|
}
|
|
1393
1420
|
) }) });
|
|
@@ -1415,25 +1442,28 @@ const VISIBLE_ANIMATION = {
|
|
|
1415
1442
|
}
|
|
1416
1443
|
};
|
|
1417
1444
|
const WidgetHeaderSummary = (props) => {
|
|
1418
|
-
var _a, _b, _c;
|
|
1419
|
-
const { params, dataSettings, summaryData } = props;
|
|
1445
|
+
var _a, _b, _c, _d;
|
|
1446
|
+
const { params, dataSettings, summaryData, sledgeSettings } = props;
|
|
1420
1447
|
const { productId } = params || {};
|
|
1421
1448
|
const { fill_color: display_summary_bar_fill_color, outline_color: display_summary_bar_outline_color } = ((_b = (_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.widget) == null ? void 0 : _b.summary_bar) || {};
|
|
1422
1449
|
const { review_singular, review_plural } = ((_c = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _c.widget) || {};
|
|
1423
1450
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
1424
1451
|
const [isFirstLoadingSummary, setIsFirstLoadingSummary] = React__default.useState(true);
|
|
1425
1452
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
1426
|
-
const [isRefreshRating, setIsRefreshRating] = React__default.useState(true);
|
|
1453
|
+
const [isRefreshRating, setIsRefreshRating] = React__default.useState(summaryData ? false : true);
|
|
1427
1454
|
const [isOpen, setIsOpen] = React__default.useState(false);
|
|
1428
|
-
const [totalReview, setTotalReview] = React__default.useState(0);
|
|
1429
|
-
const [ratingList, setRatingList] = React__default.useState(
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1455
|
+
const [totalReview, setTotalReview] = React__default.useState((summaryData == null ? void 0 : summaryData.review_count) | 0);
|
|
1456
|
+
const [ratingList, setRatingList] = React__default.useState(
|
|
1457
|
+
(summaryData == null ? void 0 : summaryData.rating) || {
|
|
1458
|
+
5: 0,
|
|
1459
|
+
4: 0,
|
|
1460
|
+
3: 0,
|
|
1461
|
+
2: 0,
|
|
1462
|
+
1: 0
|
|
1463
|
+
}
|
|
1464
|
+
);
|
|
1465
|
+
const [averageReview, setAverageReview] = React__default.useState(((_d = summaryData == null ? void 0 : summaryData.rating) == null ? void 0 : _d.average) || "0");
|
|
1466
|
+
const [isFirstTime, setIsFirstTime] = React__default.useState(true);
|
|
1437
1467
|
const previousState = usePrevious({ productId });
|
|
1438
1468
|
const handleProductReviewInfo = async () => {
|
|
1439
1469
|
var _a2;
|
|
@@ -1443,7 +1473,11 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1443
1473
|
let valueTotalReview = 0;
|
|
1444
1474
|
let valueRatingList;
|
|
1445
1475
|
let valueAverageReview;
|
|
1446
|
-
if (
|
|
1476
|
+
if (summaryData && isFirstTime) {
|
|
1477
|
+
data = summaryData;
|
|
1478
|
+
run = true;
|
|
1479
|
+
setIsFirstTime(false);
|
|
1480
|
+
} else {
|
|
1447
1481
|
response = await getReviewInfo(productId);
|
|
1448
1482
|
if (!response)
|
|
1449
1483
|
return;
|
|
@@ -1451,9 +1485,6 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1451
1485
|
const { code } = status;
|
|
1452
1486
|
data = response.data;
|
|
1453
1487
|
run = code === 200 || false;
|
|
1454
|
-
} else {
|
|
1455
|
-
data = summaryData;
|
|
1456
|
-
run = true;
|
|
1457
1488
|
}
|
|
1458
1489
|
valueTotalReview = (data == null ? void 0 : data.review_count) ? data.review_count : 0;
|
|
1459
1490
|
valueRatingList = (data == null ? void 0 : data.rating) ? {
|
|
@@ -1486,12 +1517,12 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1486
1517
|
setIsFirstLoading(true);
|
|
1487
1518
|
handleProductReviewInfo();
|
|
1488
1519
|
}, [isOpen, productId]);
|
|
1489
|
-
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(
|
|
1520
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary", children: isFirstLoading && !summaryData ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "630px", height: "42px", color: "grey-100", rounded: "md", animationDuration: "5s" }) : isLoading && !summaryData ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1490
1521
|
Popover,
|
|
1491
1522
|
{
|
|
1492
1523
|
trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(motion.div, { initial: false, animate: isOpen ? "open" : "closed", className: "sledge-product-review__widget-summary-trigger", children: [
|
|
1493
1524
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-average", children: averageReview }),
|
|
1494
|
-
/* @__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 }) }),
|
|
1525
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-rating", children: !isRefreshRating && /* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { data: summaryData, sledgeSettings, value: String(averageReview), size: "md", withSkeletonLoading: false, isScrollToElementWidget: false }) }),
|
|
1495
1526
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__widget-summary-total", children: [
|
|
1496
1527
|
totalReview,
|
|
1497
1528
|
" ",
|
|
@@ -1528,7 +1559,7 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1528
1559
|
] }, index);
|
|
1529
1560
|
}) }) : /* @__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) => {
|
|
1530
1561
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__widget-summary-dist-progress-item", children: [
|
|
1531
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { value: item, size: "sm", withSkeletonLoading: false, isScrollToElementWidget: false }),
|
|
1562
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { data: summaryData, sledgeSettings, value: item, size: "sm", withSkeletonLoading: false, isScrollToElementWidget: false }),
|
|
1532
1563
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1533
1564
|
Progress,
|
|
1534
1565
|
{
|
|
@@ -1555,7 +1586,7 @@ const WidgetHeaderSummary = (props) => {
|
|
|
1555
1586
|
) });
|
|
1556
1587
|
};
|
|
1557
1588
|
const WidgetHeader = (props) => {
|
|
1558
|
-
const [isLoading, setIsLoading] = React__default.useState(
|
|
1589
|
+
const [isLoading, setIsLoading] = React__default.useState(!props.data);
|
|
1559
1590
|
React__default.useEffect(() => {
|
|
1560
1591
|
setIsLoading(false);
|
|
1561
1592
|
}, []);
|
|
@@ -2382,18 +2413,17 @@ const SearchIconWidgetPopup = () => {
|
|
|
2382
2413
|
if (!showInfo)
|
|
2383
2414
|
return;
|
|
2384
2415
|
setIsLoading(true);
|
|
2385
|
-
const { tabs, suffix_index_product, hidden_tags, display } = data;
|
|
2416
|
+
const { tabs, suffix_index_product, hidden_tags, display, show_out_of_stock } = data;
|
|
2386
2417
|
const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
|
|
2387
2418
|
let response;
|
|
2388
2419
|
let body = {
|
|
2389
2420
|
queries: tabs.map((tab) => {
|
|
2390
|
-
var _a3;
|
|
2391
2421
|
const { index } = tab;
|
|
2392
2422
|
let isProductIndex = index.includes(suffix_index_product);
|
|
2393
2423
|
let additionalFilter = [];
|
|
2394
2424
|
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
2395
2425
|
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
2396
|
-
if (!
|
|
2426
|
+
if (!show_out_of_stock)
|
|
2397
2427
|
additionalFilter.push("variants.inventory_quantity > 0");
|
|
2398
2428
|
return {
|
|
2399
2429
|
indexUid: index,
|
|
@@ -2496,8 +2526,10 @@ const SearchIconWidgetPopup = () => {
|
|
|
2496
2526
|
}, [showInfo]);
|
|
2497
2527
|
React__default.useEffect(() => {
|
|
2498
2528
|
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
2529
|
+
const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
2499
2530
|
const delayDebounceFn = setTimeout(() => {
|
|
2500
|
-
|
|
2531
|
+
if (INSTANT_SEARCH_SETTING)
|
|
2532
|
+
handleMultiSearch(INSTANT_SEARCH_SETTING, true);
|
|
2501
2533
|
}, 500);
|
|
2502
2534
|
return () => clearTimeout(delayDebounceFn);
|
|
2503
2535
|
}
|
|
@@ -2671,9 +2703,9 @@ const SearchIconWidgetPopup = () => {
|
|
|
2671
2703
|
] }) });
|
|
2672
2704
|
};
|
|
2673
2705
|
const SearchResultWidget = (props) => {
|
|
2674
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2706
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2675
2707
|
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
2676
|
-
const { layoutType = "default", query, params, children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct, data: propsData } = props;
|
|
2708
|
+
const { layoutType = "default", query, params, children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct, data: propsData, sledgeSettings } = props;
|
|
2677
2709
|
const { keyword: queryKeyword = "" } = query || {};
|
|
2678
2710
|
const { collectionId } = params || {};
|
|
2679
2711
|
let productCardsComponent = null;
|
|
@@ -2686,24 +2718,24 @@ const SearchResultWidget = (props) => {
|
|
|
2686
2718
|
});
|
|
2687
2719
|
const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
|
|
2688
2720
|
const [settings] = React__default.useState(typeof localStorage !== "undefined" ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}") : {});
|
|
2689
|
-
const [isFirstLoading, setIsFirstLoading] = React__default.useState(
|
|
2690
|
-
const [isLoading, setIsLoading] = React__default.useState(
|
|
2721
|
+
const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
|
|
2722
|
+
const [isLoading, setIsLoading] = React__default.useState(!propsData);
|
|
2691
2723
|
const [keyword, setKeyword] = React__default.useState(searchParams == null ? void 0 : searchParams.get(queryKeyword));
|
|
2692
2724
|
const [clickedTabIndexId, setClickedTabIndexId] = React__default.useState(null);
|
|
2693
2725
|
const [clickedTabIndexName, setClickedTabIndexName] = React__default.useState();
|
|
2694
2726
|
const [resultComponent, setResultComponent] = React__default.useState(/* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}));
|
|
2695
|
-
const [isLoadingSetting, setIsLoadingSetting] = React__default.useState(
|
|
2696
|
-
const [allowedSorts, setAllowedSorts] = React__default.useState([]);
|
|
2697
|
-
const [allowedFilters, setAllowedFilters] = React__default.useState([]);
|
|
2727
|
+
const [isLoadingSetting, setIsLoadingSetting] = React__default.useState(!propsData);
|
|
2728
|
+
const [allowedSorts, setAllowedSorts] = React__default.useState(((_b = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _b.allowed_sorts) || []);
|
|
2729
|
+
const [allowedFilters, setAllowedFilters] = React__default.useState(((_c = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c.filters) || []);
|
|
2698
2730
|
const [allowedTabs, setAllowedTabs] = React__default.useState([]);
|
|
2699
2731
|
const [facets, setFacets] = React__default.useState([]);
|
|
2700
|
-
const [suffixIndexProduct, setSuffixIndexProduct] = React__default.useState("");
|
|
2732
|
+
const [suffixIndexProduct, setSuffixIndexProduct] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.suffix_index_product) || "");
|
|
2701
2733
|
const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
|
|
2702
|
-
const [hiddenTags, setHiddenTags] = React__default.useState([]);
|
|
2703
|
-
const [displaySettings, setDisplaySettings] = React__default.useState({});
|
|
2704
|
-
const [colorSwatches, setColorSwatches] = React__default.useState([]);
|
|
2705
|
-
const [defaultSort, setDefaultSort] = React__default.useState("");
|
|
2706
|
-
const [showOutOfStock, setShowOutOfStock] = React__default.useState(
|
|
2734
|
+
const [hiddenTags, setHiddenTags] = React__default.useState(((_e = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _e.hidden_tags) || []);
|
|
2735
|
+
const [displaySettings, setDisplaySettings] = React__default.useState(((_f = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _f.display) || {});
|
|
2736
|
+
const [colorSwatches, setColorSwatches] = React__default.useState(((_g = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _g.colors) || []);
|
|
2737
|
+
const [defaultSort, setDefaultSort] = React__default.useState(((_h = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _h.default_sort) || "");
|
|
2738
|
+
const [showOutOfStock, setShowOutOfStock] = React__default.useState((_i = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _i.show_out_of_stock);
|
|
2707
2739
|
const [initStatesFirstTime, setInitStatesFirstTime] = React__default.useState(true);
|
|
2708
2740
|
const searchResultContainerRef = React__default.useRef(null);
|
|
2709
2741
|
const previousState = usePrevious({ keyword });
|
|
@@ -2713,7 +2745,7 @@ const SearchResultWidget = (props) => {
|
|
|
2713
2745
|
setResultComponent(id.includes(suffixIndexProduct) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultCategory, {}));
|
|
2714
2746
|
};
|
|
2715
2747
|
const handleInitStates = async (data, type) => {
|
|
2716
|
-
const { filters, tabs, suffix_index_product, hidden_tags,
|
|
2748
|
+
const { filters, tabs, suffix_index_product, hidden_tags, show_out_of_stock } = data;
|
|
2717
2749
|
let getTabs = layoutType === "product-filter" ? tabs.filter(({ index }) => index == null ? void 0 : index.includes(suffix_index_product)) : tabs;
|
|
2718
2750
|
let response;
|
|
2719
2751
|
let body = {
|
|
@@ -2811,6 +2843,7 @@ const SearchResultWidget = (props) => {
|
|
|
2811
2843
|
}
|
|
2812
2844
|
};
|
|
2813
2845
|
const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
|
|
2846
|
+
console.log("handleSettings running");
|
|
2814
2847
|
setIsLoadingSetting(true);
|
|
2815
2848
|
let response;
|
|
2816
2849
|
let getFirstIndex;
|
|
@@ -2853,8 +2886,8 @@ const SearchResultWidget = (props) => {
|
|
|
2853
2886
|
}
|
|
2854
2887
|
}, [keyword]);
|
|
2855
2888
|
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;
|
|
2856
|
-
const filterHorizontalSkeleton = ((
|
|
2857
|
-
const filterVerticalSkeleton = ((
|
|
2889
|
+
const filterHorizontalSkeleton = ((_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) === "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;
|
|
2890
|
+
const filterVerticalSkeleton = ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.enable_on_search) && ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2858
2891
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2859
2892
|
"div",
|
|
2860
2893
|
{
|
|
@@ -3070,7 +3103,7 @@ const SearchResultWidget = (props) => {
|
|
|
3070
3103
|
)
|
|
3071
3104
|
] }) : null;
|
|
3072
3105
|
const productGridSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3073
|
-
((
|
|
3106
|
+
((_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.show_total_products) && ((_o = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _o.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3074
3107
|
SkeletonLoading.Item,
|
|
3075
3108
|
{
|
|
3076
3109
|
width: "117px",
|
|
@@ -3086,7 +3119,7 @@ const SearchResultWidget = (props) => {
|
|
|
3086
3119
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 12, type: "large" })
|
|
3087
3120
|
] });
|
|
3088
3121
|
const searchAndSelectOptionSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
3089
|
-
((
|
|
3122
|
+
((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.show_total_products) && ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.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,
|
|
3090
3123
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-keyword-form", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3091
3124
|
SkeletonLoading.Item,
|
|
3092
3125
|
{
|
|
@@ -3117,7 +3150,7 @@ const SearchResultWidget = (props) => {
|
|
|
3117
3150
|
tabSkeleton,
|
|
3118
3151
|
filterHorizontalSkeleton,
|
|
3119
3152
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-wrapper sledge-instant-search__result-wrapper-skeleton", children: [
|
|
3120
|
-
((
|
|
3153
|
+
((_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.enable_on_search) && ((_s = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _s.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : null,
|
|
3121
3154
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
|
|
3122
3155
|
searchAndSelectOptionSkeleton,
|
|
3123
3156
|
productGridSkeleton
|
|
@@ -3159,7 +3192,7 @@ const SearchResultWidget = (props) => {
|
|
|
3159
3192
|
] });
|
|
3160
3193
|
};
|
|
3161
3194
|
const ResultProduct = (props) => {
|
|
3162
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
3195
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
3163
3196
|
const {
|
|
3164
3197
|
keyword,
|
|
3165
3198
|
clickedTabIndexId,
|
|
@@ -3192,8 +3225,8 @@ const ResultProduct = (props) => {
|
|
|
3192
3225
|
} = props || {};
|
|
3193
3226
|
const { keyword: queryKeyword = "" } = query || {};
|
|
3194
3227
|
const { collectionId } = params || {};
|
|
3195
|
-
const [isFirstLoading, setIsFirstLoading] = React__default.useState(
|
|
3196
|
-
const [isLoading, setIsLoading] = React__default.useState(
|
|
3228
|
+
const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
|
|
3229
|
+
const [isLoading, setIsLoading] = React__default.useState(!propsData);
|
|
3197
3230
|
const [isOpenSort, setIsOpenSort] = React__default.useState(false);
|
|
3198
3231
|
const [isOpenLimit, setIsOpenLimit] = React__default.useState(false);
|
|
3199
3232
|
const [clickedSortId, setClickedSortId] = React__default.useState(defaultSort || "");
|
|
@@ -3206,24 +3239,40 @@ const ResultProduct = (props) => {
|
|
|
3206
3239
|
} : {}
|
|
3207
3240
|
});
|
|
3208
3241
|
const [triggerClickedFacets, setTriggerClickedFacets] = React__default.useState(false);
|
|
3209
|
-
const [searchResult, setSearchResult] = React__default.useState([]);
|
|
3242
|
+
const [searchResult, setSearchResult] = React__default.useState(((_e = (_d = (_c = propsData == null ? void 0 : propsData.result) == null ? void 0 : _c.results) == null ? void 0 : _d[0]) == null ? void 0 : _e.hits) || []);
|
|
3210
3243
|
const [searchProcessingTimeMs, setSearchProcessingTimeMs] = React__default.useState(0);
|
|
3211
3244
|
const [currentPage, setCurrentPage] = React__default.useState(1);
|
|
3212
3245
|
const [totalPage, setTotalPage] = React__default.useState(0);
|
|
3213
|
-
const [totalSearchResult, setTotalSearchResult] = React__default.useState(0);
|
|
3246
|
+
const [totalSearchResult, setTotalSearchResult] = React__default.useState(((_h = (_g = (_f = propsData == null ? void 0 : propsData.result) == null ? void 0 : _f.results) == null ? void 0 : _g[0]) == null ? void 0 : _h.totalHits) || 0);
|
|
3214
3247
|
const [valueFilterPriceChange, setValueFilterPriceChange] = React__default.useState([]);
|
|
3215
3248
|
const [allowedFilter, setAllowedFilter] = React__default.useState([]);
|
|
3216
3249
|
const [isFilterChanged, setIsFilterChanged] = React__default.useState(false);
|
|
3217
|
-
const [summaryText, setSummaryText] = React__default.useState(null);
|
|
3218
3250
|
const [handleSearchResultFirstTime, setHandleSearchResultFirstTime] = React__default.useState(true);
|
|
3251
|
+
const summaryTextGenerator = () => {
|
|
3252
|
+
var _a2;
|
|
3253
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-item", children: ((_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.show_total_products) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-data-summary-text", children: [
|
|
3254
|
+
totalSearchResult,
|
|
3255
|
+
" result",
|
|
3256
|
+
" ",
|
|
3257
|
+
(keyword == null ? void 0 : keyword.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3258
|
+
"for ",
|
|
3259
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-data-summary-text-keyword", children: [
|
|
3260
|
+
'"',
|
|
3261
|
+
keyword,
|
|
3262
|
+
'"'
|
|
3263
|
+
] })
|
|
3264
|
+
] }) : null
|
|
3265
|
+
] }) : null });
|
|
3266
|
+
};
|
|
3267
|
+
const [summaryText, setSummaryText] = React__default.useState(propsData ? summaryTextGenerator() : null);
|
|
3219
3268
|
const previousState = usePrevious({ keyword, clickedLimitId, clickedFacets });
|
|
3220
|
-
const { color: filter_title_color, font_size: filter_title_font_size, font_weight: filter_title_font_weight, text_transform: filter_title_text_transform } = ((
|
|
3269
|
+
const { color: filter_title_color, font_size: filter_title_font_size, font_weight: filter_title_font_weight, text_transform: filter_title_text_transform } = ((_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.title) || {};
|
|
3221
3270
|
const {
|
|
3222
3271
|
color: filter_option_color,
|
|
3223
3272
|
font_size: filter_option_font_size,
|
|
3224
3273
|
font_weight: filter_option_font_weight,
|
|
3225
3274
|
text_transform: filter_option_text_transform
|
|
3226
|
-
} = ((
|
|
3275
|
+
} = ((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.option) || {};
|
|
3227
3276
|
const {
|
|
3228
3277
|
text_color: filter_button_text_color,
|
|
3229
3278
|
border_color: filter_button_border_color,
|
|
@@ -3236,7 +3285,7 @@ const ResultProduct = (props) => {
|
|
|
3236
3285
|
font_size: filter_button_font_size,
|
|
3237
3286
|
font_weight: filter_button_font_weight,
|
|
3238
3287
|
text_transform: filter_button_text_transform
|
|
3239
|
-
} = ((
|
|
3288
|
+
} = ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.button) || {};
|
|
3240
3289
|
const filter_title_style = {
|
|
3241
3290
|
...filter_title_color && { color: filter_title_color },
|
|
3242
3291
|
...filter_title_font_size && { fontSize: filter_title_font_size },
|
|
@@ -3673,9 +3722,9 @@ const ResultProduct = (props) => {
|
|
|
3673
3722
|
});
|
|
3674
3723
|
const paginationComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Pagination, { currentPage, totalPage, totalResult: totalSearchResult, onChange: (page) => handlePageChange(page) });
|
|
3675
3724
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3676
|
-
((
|
|
3725
|
+
((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.enable_on_search) && ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading && !propsData ? filterHorizontalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoadingSetting && !propsData ? /* @__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: [
|
|
3677
3726
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal", children: filterHorizontalComponents }),
|
|
3678
|
-
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((
|
|
3727
|
+
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.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: [
|
|
3679
3728
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3680
3729
|
"div",
|
|
3681
3730
|
{
|
|
@@ -3695,9 +3744,9 @@ const ResultProduct = (props) => {
|
|
|
3695
3744
|
})
|
|
3696
3745
|
] }) }) : null
|
|
3697
3746
|
] }) }) }) : null,
|
|
3698
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", "data-filter-layout": (
|
|
3699
|
-
((
|
|
3700
|
-
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((
|
|
3747
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", "data-filter-layout": (_o = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _o.layout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3748
|
+
((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.enable_on_search) && ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.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: [
|
|
3749
|
+
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.show_refine_by_block)) ? Boolean(dataClickedFacets.every((currentValue) => !currentValue)) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
|
|
3701
3750
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title-refine", children: [
|
|
3702
3751
|
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { className: "sledge-instant-search__result-filter-item-title-refine-heading", children: "Filter" }),
|
|
3703
3752
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-item-title-refine-clear", onClick: handleFilterReset, children: "Clear All" })
|
|
@@ -3716,7 +3765,7 @@ const ResultProduct = (props) => {
|
|
|
3716
3765
|
] }) }) : null,
|
|
3717
3766
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
|
|
3718
3767
|
isFirstLoading ? searchAndSelectOptionSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
3719
|
-
((
|
|
3768
|
+
((_s = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _s.layout) === "horizontal" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal", children: summaryText }),
|
|
3720
3769
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3721
3770
|
SearchInputField,
|
|
3722
3771
|
{
|
|
@@ -3758,7 +3807,7 @@ const ResultProduct = (props) => {
|
|
|
3758
3807
|
] }),
|
|
3759
3808
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-summary-select-field-item", children: [
|
|
3760
3809
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Limit:" }),
|
|
3761
|
-
((
|
|
3810
|
+
((_t = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _t.allowed_limit) && Boolean((_v = (_u = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _u.allowed_limit) == null ? void 0 : _v.length) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3762
3811
|
SelectField,
|
|
3763
3812
|
{
|
|
3764
3813
|
align: "end",
|
|
@@ -3779,7 +3828,7 @@ const ResultProduct = (props) => {
|
|
|
3779
3828
|
productGridSkeleton,
|
|
3780
3829
|
(searchResult == null ? void 0 : searchResult.length) ? paginationComponent : null
|
|
3781
3830
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3782
|
-
((
|
|
3831
|
+
((_w = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _w.layout) === "vertical" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-vertical", children: summaryText }),
|
|
3783
3832
|
(searchResult == null ? void 0 : searchResult.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3784
3833
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3785
3834
|
ProductGrid,
|
|
@@ -3794,9 +3843,9 @@ const ResultProduct = (props) => {
|
|
|
3794
3843
|
};
|
|
3795
3844
|
}),
|
|
3796
3845
|
setting: {
|
|
3797
|
-
show_vendor: (
|
|
3798
|
-
show_sku: (
|
|
3799
|
-
show_price: (
|
|
3846
|
+
show_vendor: (_x = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _x.show_vendor,
|
|
3847
|
+
show_sku: (_y = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _y.show_sku,
|
|
3848
|
+
show_price: (_z = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _z.show_price
|
|
3800
3849
|
},
|
|
3801
3850
|
isComponentJsVersion: isJsVersion,
|
|
3802
3851
|
cards: productCardsComponent,
|
|
@@ -3986,18 +4035,17 @@ const SearchWidget = (props) => {
|
|
|
3986
4035
|
if (!keyword.length)
|
|
3987
4036
|
return;
|
|
3988
4037
|
setIsLoading(true);
|
|
3989
|
-
const { tabs, suffix_index_product, hidden_tags, display } = data;
|
|
4038
|
+
const { tabs, suffix_index_product, hidden_tags, display, show_out_of_stock } = data;
|
|
3990
4039
|
const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
|
|
3991
4040
|
let response;
|
|
3992
4041
|
let body = {
|
|
3993
4042
|
queries: tabs.map((tab) => {
|
|
3994
|
-
var _a3;
|
|
3995
4043
|
const { index } = tab;
|
|
3996
4044
|
let isProductIndex = index.includes(suffix_index_product);
|
|
3997
4045
|
let additionalFilter = [];
|
|
3998
4046
|
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
3999
4047
|
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
4000
|
-
if (!
|
|
4048
|
+
if (!show_out_of_stock)
|
|
4001
4049
|
additionalFilter.push("variants.inventory_quantity > 0");
|
|
4002
4050
|
return {
|
|
4003
4051
|
indexUid: index,
|
|
@@ -4061,8 +4109,10 @@ const SearchWidget = (props) => {
|
|
|
4061
4109
|
}, [keyword]);
|
|
4062
4110
|
React__default.useEffect(() => {
|
|
4063
4111
|
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
4112
|
+
const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
4064
4113
|
const delayDebounceFn = setTimeout(() => {
|
|
4065
|
-
|
|
4114
|
+
if (INSTANT_SEARCH_SETTING)
|
|
4115
|
+
handleMultiSearch(INSTANT_SEARCH_SETTING, true);
|
|
4066
4116
|
}, 500);
|
|
4067
4117
|
return () => clearTimeout(delayDebounceFn);
|
|
4068
4118
|
}
|