@sledge-app/react-instant-search 1.0.19 → 1.0.21
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/sledge-react-instant-search.cjs +1 -1
- package/dist/sledge-react-instant-search.cjs.map +1 -1
- package/dist/sledge-react-instant-search.js +455 -309
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/{vendor-9c93dcff.cjs → vendor-db1ee31a.cjs} +2 -2
- package/dist/vendor-db1ee31a.cjs.map +1 -0
- package/dist/{vendor-efe38901.js → vendor-eadacf73.js} +1719 -11
- package/dist/vendor-eadacf73.js.map +1 -0
- package/package.json +2 -1
- package/dist/vendor-9c93dcff.cjs.map +0 -1
- package/dist/vendor-efe38901.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
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 client, F as $a093c7e1ec25a057$export$2881499e37b75b9a, G as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, H as $a093c7e1ec25a057$export$41fb9f06171c75f4, I as $a093c7e1ec25a057$export$602eac185826482c, J as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, K as $a093c7e1ec25a057$export$21b07c8f274aebd5, L as $57acba87d6e25586$export$be92b6f5f03c0fe9, M as $57acba87d6e25586$export$d5c6c08dc2d3ca7, N as $57acba87d6e25586$export$9a4e88b92edfce6b, O as $57acba87d6e25586$export$6521433ed15a34db, P as MasonryResponsive, Q as Masonry, R as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9,
|
|
2
|
-
import React__default from "react";
|
|
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 client, F as $a093c7e1ec25a057$export$2881499e37b75b9a, G as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, H as $a093c7e1ec25a057$export$41fb9f06171c75f4, I as $a093c7e1ec25a057$export$602eac185826482c, J as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, K as $a093c7e1ec25a057$export$21b07c8f274aebd5, L as $57acba87d6e25586$export$be92b6f5f03c0fe9, M as $57acba87d6e25586$export$d5c6c08dc2d3ca7, N as $57acba87d6e25586$export$9a4e88b92edfce6b, O as $57acba87d6e25586$export$6521433ed15a34db, P as MasonryResponsive, Q as Masonry, R as useEmblaCarousel, S as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, T as $5d3850c4d0b4e6c7$export$602eac185826482c, U as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, V as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-eadacf73.js";
|
|
2
|
+
import React__default, { createElement } from "react";
|
|
3
3
|
import { SledgeContext } from "@sledge-app/core";
|
|
4
4
|
import "react-dom";
|
|
5
5
|
const ProductFilterWidget = (props) => {
|
|
@@ -7,6 +7,7 @@ const ProductFilterWidget = (props) => {
|
|
|
7
7
|
};
|
|
8
8
|
const API_URL = "https://api.sledge-app.com";
|
|
9
9
|
const INSTANT_SEARCH_ENGINE_URL = "https://instant-search-engine.sledge-app.com";
|
|
10
|
+
const CDN_URL = "https://sledgeassets.nyc3.cdn.digitaloceanspaces.com";
|
|
10
11
|
const SELECTOR_ATTRIBUTE_KEY = "data-component";
|
|
11
12
|
const DATASET_ATTRIBUTE_KEY = {
|
|
12
13
|
GLOBAL: {
|
|
@@ -34,7 +35,11 @@ const DATASET_ATTRIBUTE_KEY = {
|
|
|
34
35
|
API_KEY: "data-api-key",
|
|
35
36
|
INSTANT_SEARCH_API_KEY: "data-instant-search-api-key",
|
|
36
37
|
RENDER_PRODUCT_CARD: "data-render-product-card",
|
|
37
|
-
WITH_SKELETON_LOADING: "data-with-skeleton-loading"
|
|
38
|
+
WITH_SKELETON_LOADING: "data-with-skeleton-loading",
|
|
39
|
+
SECTION_TITLE: "data-section-title",
|
|
40
|
+
SECTION_DESCRIPTION: "data-section-description",
|
|
41
|
+
USE_SLIDER: "data-use-slider",
|
|
42
|
+
POSITION_WIDGET: "data-position-widget"
|
|
38
43
|
},
|
|
39
44
|
WISHLIST: {
|
|
40
45
|
SHARE_ID: "data-share-id",
|
|
@@ -46,7 +51,9 @@ const DATASET_ATTRIBUTE_KEY = {
|
|
|
46
51
|
PRODUCT_REVIEW: {
|
|
47
52
|
RATING_SIZE: "data-rating-size",
|
|
48
53
|
RATING_TOTAL: "data-rating-total",
|
|
49
|
-
RATING_AVERAGE: "data-rating-average"
|
|
54
|
+
RATING_AVERAGE: "data-rating-average",
|
|
55
|
+
RENDER_REVIEW_PRODUCT_INFO: "data-render-review-product-info",
|
|
56
|
+
SHOW_RATING_AVERAGE: "data-show-rating-average"
|
|
50
57
|
},
|
|
51
58
|
INSTANT_SEARCH: {
|
|
52
59
|
ON_AFTER_RENDER_COLLECTION: "data-on-after-render-collection",
|
|
@@ -62,6 +69,10 @@ const DATASET_ATTRIBUTE_KEY = {
|
|
|
62
69
|
RENDER_PAGE_CARD: "data-render-page-card",
|
|
63
70
|
RENDER_BLOG_CARD: "data-render-blog-card",
|
|
64
71
|
RENDER_ARTICLE_CARD: "data-render-article-card"
|
|
72
|
+
},
|
|
73
|
+
PRODUCT_RECOMMENDATION: {
|
|
74
|
+
LIMIT_TO_DISPLAY: "data-limit-to-display",
|
|
75
|
+
HIDDEN_PRODUCT_IDS: "data-hidden-product-ids"
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
78
|
const LOCAL_STORAGE_KEY = {
|
|
@@ -73,22 +84,25 @@ const LOCAL_STORAGE_KEY = {
|
|
|
73
84
|
WISHLIST_SETTING: "sledge-wishlist-setting",
|
|
74
85
|
PRODUCT_REVIEW_SETTING: "sledge-product-review-setting",
|
|
75
86
|
INSTANT_SEARCH_SETTING: "sledge-instant-search-setting",
|
|
87
|
+
PRODUCT_RECOMMENDATION_SETTING: "sledge-product-recommendation-setting",
|
|
76
88
|
ISSUED_AUTH_APP: "sledge-issued-auth-app",
|
|
77
|
-
EXPIRED_AUTH_APP: "sledge-expired-auth-app"
|
|
89
|
+
EXPIRED_AUTH_APP: "sledge-expired-auth-app",
|
|
90
|
+
RECENTLY_VIEWED_APP: "sledge-recently-viewed"
|
|
78
91
|
};
|
|
79
92
|
const INTERNAL_SELECTOR_VALUE = {
|
|
80
93
|
ELEMENT_TOAST_NOTIFICATION: "toast-notification",
|
|
81
94
|
ELEMENT_CONFIRMATION_POPUP: "confirmation-popup",
|
|
82
95
|
ELEMENT_INFO_POPUP: "info-popup",
|
|
83
96
|
ELEMENT_CONTAINER_WIDGET: "container-widget",
|
|
97
|
+
ELEMENT_FLOATING_LEFT_WIDGET: "floating-left-widget",
|
|
98
|
+
ELEMENT_FLOATING_RIGHT_WIDGET: "floating-right-widget",
|
|
84
99
|
WISHLIST: {
|
|
85
|
-
ELEMENT_BADGE_FLOATING_ICON: "wishlist-badge-floating-icon",
|
|
86
|
-
ELEMENT_BADGE_FLOATING_FULL: "wishlist-badge-floating-full",
|
|
87
100
|
ELEMENT_WIDGET_POPUP: "wishlist-widget-popup"
|
|
88
101
|
},
|
|
89
102
|
PRODUCT_REVIEW: {
|
|
90
103
|
ELEMENT_WIDGET_POPUP_DETAIL: "product-review-widget-popup-detail",
|
|
91
|
-
ELEMENT_WIDGET_FORM_ADD: "product-review-widget-form-add"
|
|
104
|
+
ELEMENT_WIDGET_FORM_ADD: "product-review-widget-form-add",
|
|
105
|
+
ELEMENT_HAPPY_CUSTOMERS_PAGE_POPUP: "product-review-happy-customers-page-popup"
|
|
92
106
|
},
|
|
93
107
|
INSTANT_SEARCH: {
|
|
94
108
|
ELEMENT_SEARCH_ICON_WIDGET_POPUP: "instant-search-icon-widget-popup"
|
|
@@ -107,13 +121,18 @@ const SELECTOR = {
|
|
|
107
121
|
},
|
|
108
122
|
PRODUCT_REVIEW: {
|
|
109
123
|
ELEMENT_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-widget"]`,
|
|
110
|
-
|
|
124
|
+
ELEMENT_HAPPY_CUSTOMERS_PAGE: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-happy-customers-page"]`,
|
|
125
|
+
ELEMENT_RATING: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-rating"]`,
|
|
126
|
+
ELEMENT_STICKY_SIDEBAR_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-sticky-sidebar-widget"]`
|
|
111
127
|
},
|
|
112
128
|
INSTANT_SEARCH: {
|
|
113
129
|
ELEMENT_SEARCH_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-widget"]`,
|
|
114
130
|
ELEMENT_SEARCH_ICON_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-icon-widget"]`,
|
|
115
131
|
ELEMENT_SEARCH_RESULT_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-result-widget"]`,
|
|
116
132
|
ELEMENT_PLP_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-product-filter-widget"]`
|
|
133
|
+
},
|
|
134
|
+
PRODUCT_RECOMMENDATION: {
|
|
135
|
+
ELEMENT_RECENTLY_VIEWED_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="product-recommendation-recently-viewed-widget"]`
|
|
117
136
|
}
|
|
118
137
|
};
|
|
119
138
|
const DEFAULT_SEARCH_RESULT_URL = "/apps/sledge/search";
|
|
@@ -557,8 +576,18 @@ const NoteIcon = ({ width, height, color }) => {
|
|
|
557
576
|
};
|
|
558
577
|
const Button$1 = "";
|
|
559
578
|
const Button = React__default.forwardRef((props, buttonRef) => {
|
|
560
|
-
const { className = "", children, colorType = "light", fullWidth = false, elementType = "button", link = "", ...otherProps } = props;
|
|
561
|
-
return elementType === "hyperlink" && (link == null ? void 0 : link.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: link, className: `sledge__button ${className || ""}`, "data-button-color-type": colorType, "data-button-full-width": fullWidth, ref: buttonRef, ...otherProps, children }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
579
|
+
const { className = "", children, colorType = "light", fullWidth = false, elementType = "button", link = "", isActive, ...otherProps } = props;
|
|
580
|
+
return elementType === "hyperlink" && (link == null ? void 0 : link.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: link, className: `sledge__button ${className || ""}`, "data-button-color-type": colorType, "data-button-full-width": fullWidth, ref: buttonRef, ...otherProps, children }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
581
|
+
"button",
|
|
582
|
+
{
|
|
583
|
+
className: `sledge__button ${className || ""} ${isActive ? "sledge__button-active" : ""}`,
|
|
584
|
+
"data-button-color-type": colorType,
|
|
585
|
+
"data-button-full-width": fullWidth,
|
|
586
|
+
ref: buttonRef,
|
|
587
|
+
...otherProps,
|
|
588
|
+
children
|
|
589
|
+
}
|
|
590
|
+
);
|
|
562
591
|
});
|
|
563
592
|
const SearchInputField$1 = "";
|
|
564
593
|
const SearchInputField = (props) => {
|
|
@@ -647,7 +676,7 @@ const SelectField = (props) => {
|
|
|
647
676
|
};
|
|
648
677
|
const ProductGrid$1 = "";
|
|
649
678
|
async function swr(url, options) {
|
|
650
|
-
if (typeof localStorage !== "undefined" && typeof caches !== "undefined" && options.method === "GET") {
|
|
679
|
+
if (typeof localStorage !== "undefined" && typeof caches !== "undefined" && options.method === "GET" && !(options == null ? void 0 : options.ignoreSWR)) {
|
|
651
680
|
const data = await getData(url);
|
|
652
681
|
return await data.json();
|
|
653
682
|
} else
|
|
@@ -702,8 +731,23 @@ const scrollToElement = (params) => {
|
|
|
702
731
|
behavior: "smooth"
|
|
703
732
|
});
|
|
704
733
|
};
|
|
734
|
+
const getUnixTimestamp = (params) => {
|
|
735
|
+
const { addMoreTime = 0, addMoreTimeBy = "day" } = params || {};
|
|
736
|
+
let moreTime = 0;
|
|
737
|
+
if (addMoreTime) {
|
|
738
|
+
if (addMoreTimeBy === "day")
|
|
739
|
+
moreTime = addMoreTime * 60 * 60 * 24;
|
|
740
|
+
if (addMoreTimeBy === "hour")
|
|
741
|
+
moreTime = addMoreTime * 60 * 60;
|
|
742
|
+
if (addMoreTimeBy === "minute")
|
|
743
|
+
moreTime = addMoreTime * 60;
|
|
744
|
+
if (addMoreTimeBy === "second")
|
|
745
|
+
moreTime = addMoreTime;
|
|
746
|
+
}
|
|
747
|
+
return Math.floor(Date.now() / 1e3) + moreTime;
|
|
748
|
+
};
|
|
705
749
|
const fetchApi = async (params) => {
|
|
706
|
-
const { url, method, authorization = "", payload = {}, headers = {}, isSimpleRequest = true, isUploadFile = false } = params;
|
|
750
|
+
const { url, method, authorization = "", payload = {}, headers = {}, isSimpleRequest = true, isUploadFile = false, ignoreSWR = false } = params;
|
|
707
751
|
var myHeaders = new Headers();
|
|
708
752
|
if (!isSimpleRequest) {
|
|
709
753
|
if (authorization)
|
|
@@ -732,7 +776,8 @@ const fetchApi = async (params) => {
|
|
|
732
776
|
method: fixMethod,
|
|
733
777
|
redirect: "follow",
|
|
734
778
|
headers: myHeaders,
|
|
735
|
-
body: fixMethod === "GET" ? null : isSimpleRequest || isUploadFile ? formdata : JSON.stringify(payload)
|
|
779
|
+
body: fixMethod === "GET" ? null : isSimpleRequest || isUploadFile ? formdata : JSON.stringify(payload),
|
|
780
|
+
ignoreSWR
|
|
736
781
|
};
|
|
737
782
|
return await swr(`${url}`, requestOptions);
|
|
738
783
|
};
|
|
@@ -742,6 +787,35 @@ const convertDate = (date, options = {
|
|
|
742
787
|
month: "numeric",
|
|
743
788
|
day: "numeric"
|
|
744
789
|
}) => new Date(date).toLocaleString("en-US", options);
|
|
790
|
+
const watchElement = ({ selector = null, init = null, customInit = false }) => {
|
|
791
|
+
if (!selector || !init)
|
|
792
|
+
return;
|
|
793
|
+
var observer = new MutationObserver(function(mutations) {
|
|
794
|
+
mutations.forEach(function(mutation) {
|
|
795
|
+
var nodes = Array.prototype.slice.call(mutation.addedNodes);
|
|
796
|
+
nodes.forEach(function(node) {
|
|
797
|
+
if (node.nodeType === 1 && (node.matches(selector) || node.querySelector(selector))) {
|
|
798
|
+
if (!customInit) {
|
|
799
|
+
let elementNode = Array.from(node.querySelectorAll(selector));
|
|
800
|
+
if (elementNode.length) {
|
|
801
|
+
elementNode.map((item) => {
|
|
802
|
+
init(item);
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
} else {
|
|
806
|
+
init();
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
});
|
|
812
|
+
observer.observe(document.body, {
|
|
813
|
+
childList: true,
|
|
814
|
+
subtree: true,
|
|
815
|
+
attributes: false,
|
|
816
|
+
characterData: false
|
|
817
|
+
});
|
|
818
|
+
};
|
|
745
819
|
const addToCart = async (data) => {
|
|
746
820
|
var _a, _b;
|
|
747
821
|
let items = [];
|
|
@@ -773,113 +847,6 @@ const addToCart = async (data) => {
|
|
|
773
847
|
return;
|
|
774
848
|
});
|
|
775
849
|
};
|
|
776
|
-
const BadgeFloatingFull = (props) => {
|
|
777
|
-
var _a;
|
|
778
|
-
const { sledgeAnonymId } = React__default.useContext(SledgeContext);
|
|
779
|
-
const { isFirstLoading, isLoading, totalWishlist, isMaximizeTotalWishlist, proxyUrl, position = "left", dataSettings, useProxyUrl } = props || {};
|
|
780
|
-
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
781
|
-
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
782
|
-
React__default.useEffect(() => {
|
|
783
|
-
setIsRequiredLogin(sledgeAnonymId && is_required_login);
|
|
784
|
-
}, [sledgeAnonymId]);
|
|
785
|
-
const handleRequiredLogin = (e) => {
|
|
786
|
-
if (isRequiredLogin) {
|
|
787
|
-
e.preventDefault();
|
|
788
|
-
e.stopPropagation();
|
|
789
|
-
}
|
|
790
|
-
if (isRequiredLogin) {
|
|
791
|
-
if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
|
|
792
|
-
window.sledgeConfirmationPopup({
|
|
793
|
-
title: "Login required!",
|
|
794
|
-
message: "Please login to save your wishlist across devices.",
|
|
795
|
-
textSubmit: "Login",
|
|
796
|
-
textCancel: "Cancel",
|
|
797
|
-
buttonSubmitType: "info",
|
|
798
|
-
onSubmit: () => window.location.href = "/account/login"
|
|
799
|
-
});
|
|
800
|
-
} else {
|
|
801
|
-
if (useProxyUrl)
|
|
802
|
-
window.location.href = proxyUrl || "/";
|
|
803
|
-
}
|
|
804
|
-
};
|
|
805
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge-wishlist__badge-floating sledge-wishlist__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: [
|
|
806
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-wishlist__badge-floating-text", children: "My Wishlist" }),
|
|
807
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
|
|
808
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 18, height: 18, type: "fill", color: "#000000" }),
|
|
809
|
-
!isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
|
|
810
|
-
] })
|
|
811
|
-
] }) });
|
|
812
|
-
};
|
|
813
|
-
const BadgeFloatingIcon = (props) => {
|
|
814
|
-
var _a;
|
|
815
|
-
const { sledgeAnonymId } = React__default.useContext(SledgeContext);
|
|
816
|
-
const { isFirstLoading, isLoading, totalWishlist, isMaximizeTotalWishlist, proxyUrl, position = "bottom-right", dataSettings, useProxyUrl } = props || {};
|
|
817
|
-
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
818
|
-
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
819
|
-
React__default.useEffect(() => {
|
|
820
|
-
setIsRequiredLogin(sledgeAnonymId && is_required_login);
|
|
821
|
-
}, [sledgeAnonymId]);
|
|
822
|
-
const handleRequiredLogin = (e) => {
|
|
823
|
-
if (isRequiredLogin) {
|
|
824
|
-
e.preventDefault();
|
|
825
|
-
e.stopPropagation();
|
|
826
|
-
}
|
|
827
|
-
if (isRequiredLogin) {
|
|
828
|
-
if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
|
|
829
|
-
window.sledgeConfirmationPopup({
|
|
830
|
-
title: "Login required!",
|
|
831
|
-
message: "Please login to save your wishlist across devices.",
|
|
832
|
-
textSubmit: "Login",
|
|
833
|
-
textCancel: "Cancel",
|
|
834
|
-
buttonSubmitType: "info",
|
|
835
|
-
onSubmit: () => window.location.href = "/account/login"
|
|
836
|
-
});
|
|
837
|
-
} else {
|
|
838
|
-
if (useProxyUrl)
|
|
839
|
-
window.location.href = proxyUrl || "/";
|
|
840
|
-
}
|
|
841
|
-
};
|
|
842
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge-wishlist__badge-floating-icon sledge-wishlist__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
|
|
843
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 27.01, height: 25.73, type: "outline", color: "#000000" }),
|
|
844
|
-
!isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
|
|
845
|
-
] }) }) });
|
|
846
|
-
};
|
|
847
|
-
const BadgeHeaderMenu = (props) => {
|
|
848
|
-
var _a;
|
|
849
|
-
const { sledgeAnonymId } = React__default.useContext(SledgeContext);
|
|
850
|
-
const { isFirstLoading, isLoading, totalWishlist, isMaximizeTotalWishlist, proxyUrl, dataSettings, useProxyUrl } = props || {};
|
|
851
|
-
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
852
|
-
const defaultColorIcon = "currentColor";
|
|
853
|
-
const [colorIcon, setColorIcon] = React__default.useState(defaultColorIcon);
|
|
854
|
-
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
855
|
-
React__default.useEffect(() => {
|
|
856
|
-
setIsRequiredLogin(sledgeAnonymId && is_required_login);
|
|
857
|
-
}, [sledgeAnonymId]);
|
|
858
|
-
const handleRequiredLogin = (e) => {
|
|
859
|
-
if (isRequiredLogin) {
|
|
860
|
-
e.preventDefault();
|
|
861
|
-
e.stopPropagation();
|
|
862
|
-
}
|
|
863
|
-
if (isRequiredLogin) {
|
|
864
|
-
if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
|
|
865
|
-
window.sledgeConfirmationPopup({
|
|
866
|
-
title: "Login required!",
|
|
867
|
-
message: "Please login to save your wishlist across devices.",
|
|
868
|
-
textSubmit: "Login",
|
|
869
|
-
textCancel: "Cancel",
|
|
870
|
-
buttonSubmitType: "info",
|
|
871
|
-
onSubmit: () => window.location.href = "/account/login"
|
|
872
|
-
});
|
|
873
|
-
} else {
|
|
874
|
-
if (useProxyUrl)
|
|
875
|
-
window.location.href = proxyUrl || "/";
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge", onClick: handleRequiredLogin, onMouseEnter: () => setColorIcon("#F85538"), onMouseLeave: () => setColorIcon(defaultColorIcon), children: [
|
|
879
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 20, height: 20, type: "outline", color: colorIcon }),
|
|
880
|
-
!isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
|
|
881
|
-
] });
|
|
882
|
-
};
|
|
883
850
|
const addWishlist = async (data) => {
|
|
884
851
|
const { productId, productVariantId, productName, productVendor, productSku, productVariantName, productLink, productImage, productCurrency, productPrice } = data;
|
|
885
852
|
let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
|
|
@@ -995,18 +962,24 @@ const addToCartTrigger$1 = async (data) => {
|
|
|
995
962
|
return;
|
|
996
963
|
});
|
|
997
964
|
};
|
|
998
|
-
const
|
|
965
|
+
const Badge = (props) => {
|
|
999
966
|
var _a;
|
|
1000
|
-
const {
|
|
1001
|
-
const { isRenderApp, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
|
|
967
|
+
const { useProxyUrl = false, data: propsData, position: positionProp } = props;
|
|
968
|
+
const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
|
|
1002
969
|
const { wishlist: isRenderAppWishlist } = isRenderApp || {};
|
|
1003
970
|
const { value: valueRenderWishlistBadge, trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
|
|
971
|
+
const defaultColorIcon = "currentColor";
|
|
972
|
+
const [colorIcon, setColorIcon] = React__default.useState(defaultColorIcon);
|
|
1004
973
|
const [totalWishlist, setTotalWishlist] = React__default.useState((propsData == null ? void 0 : propsData.total_data) || 0);
|
|
1005
974
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
|
|
1006
975
|
const [isLoading, setIsLoading] = React__default.useState(!propsData);
|
|
1007
976
|
const [isMaximizeTotalWishlist, setIsMaximizeTotalWishlist] = React__default.useState(false);
|
|
1008
977
|
const [proxyUrl, setProxyUrl] = React__default.useState((propsData == null ? void 0 : propsData.proxy_url) || "");
|
|
1009
978
|
const [dataSettings, setDataSettings] = React__default.useState({});
|
|
979
|
+
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
980
|
+
const { floating_button_type } = (dataSettings == null ? void 0 : dataSettings.launch_point) || {};
|
|
981
|
+
const defaultPosition = positionProp || floating_button_type;
|
|
982
|
+
const position = defaultPosition ? defaultPosition : "none";
|
|
1010
983
|
const handleGetWishlistInfo = async () => {
|
|
1011
984
|
var _a2, _b;
|
|
1012
985
|
let response;
|
|
@@ -1030,14 +1003,40 @@ const BadgeRoot = (props) => {
|
|
|
1030
1003
|
response = JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
|
|
1031
1004
|
if (!response)
|
|
1032
1005
|
return;
|
|
1006
|
+
const { is_required_login } = response || {};
|
|
1033
1007
|
setDataSettings(response);
|
|
1034
|
-
|
|
1008
|
+
setIsRequiredLogin(sledgeAnonymId && is_required_login);
|
|
1009
|
+
};
|
|
1010
|
+
const handleRequiredLogin = (e) => {
|
|
1011
|
+
if (isRequiredLogin) {
|
|
1012
|
+
e.preventDefault();
|
|
1013
|
+
e.stopPropagation();
|
|
1014
|
+
}
|
|
1015
|
+
if (isRequiredLogin) {
|
|
1016
|
+
if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
|
|
1017
|
+
window.sledgeConfirmationPopup({
|
|
1018
|
+
title: "Login required!",
|
|
1019
|
+
message: "Please login to save your wishlist across devices.",
|
|
1020
|
+
textSubmit: "Login",
|
|
1021
|
+
textCancel: "Cancel",
|
|
1022
|
+
buttonSubmitType: "info",
|
|
1023
|
+
onSubmit: () => window.location.href = "/account/login"
|
|
1024
|
+
});
|
|
1025
|
+
} else {
|
|
1026
|
+
if (useProxyUrl)
|
|
1027
|
+
window.location.href = proxyUrl || "/";
|
|
1028
|
+
}
|
|
1035
1029
|
};
|
|
1036
1030
|
React__default.useEffect(() => {
|
|
1037
1031
|
if (!isRenderAppWishlist)
|
|
1038
1032
|
return;
|
|
1039
1033
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
|
|
1040
1034
|
}, [isRenderAppWishlist]);
|
|
1035
|
+
React__default.useEffect(() => {
|
|
1036
|
+
if (!(dataSettings == null ? void 0 : dataSettings.launch_point))
|
|
1037
|
+
return;
|
|
1038
|
+
handleGetWishlistInfo();
|
|
1039
|
+
}, [dataSettings]);
|
|
1041
1040
|
React__default.useEffect(() => {
|
|
1042
1041
|
if (!valueRenderWishlistBadge)
|
|
1043
1042
|
return;
|
|
@@ -1045,86 +1044,96 @@ const BadgeRoot = (props) => {
|
|
|
1045
1044
|
triggerRenderWishlistBadge(false);
|
|
1046
1045
|
handleGetWishlistInfo();
|
|
1047
1046
|
}, [valueRenderWishlistBadge]);
|
|
1048
|
-
|
|
1049
|
-
children
|
|
1050
|
-
|
|
1051
|
-
isFirstLoading,
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1047
|
+
const HeaderMenu = () => {
|
|
1048
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge", onClick: handleRequiredLogin, onMouseEnter: () => setColorIcon("#F85538"), onMouseLeave: () => setColorIcon(defaultColorIcon), children: [
|
|
1049
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 20, height: 20, type: "outline", color: colorIcon }),
|
|
1050
|
+
!isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
|
|
1051
|
+
] });
|
|
1052
|
+
};
|
|
1053
|
+
const FloatingFull = () => {
|
|
1054
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge-wishlist__badge-floating sledge__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: [
|
|
1055
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-wishlist__badge-floating-text", children: "My Wishlist" }),
|
|
1056
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
|
|
1057
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 18, height: 18, type: "fill", color: "#000000" }),
|
|
1058
|
+
!isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
|
|
1059
|
+
] })
|
|
1060
|
+
] }) });
|
|
1061
|
+
};
|
|
1062
|
+
const FloatingIcon = () => {
|
|
1063
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge-wishlist__badge-floating-icon sledge-wishlist__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
|
|
1064
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 27.01, height: 25.73, type: "outline", color: "#000000" }),
|
|
1065
|
+
!isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
|
|
1066
|
+
] }) }) });
|
|
1067
|
+
};
|
|
1068
|
+
return isFirstLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: position === "none" ? /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderMenu, {}) : String(position).includes("bottom") ? /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingIcon, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingFull, {}) });
|
|
1060
1069
|
};
|
|
1061
|
-
const Badge = ({ children }) => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.count(children) && React__default.Children.map(children, (child) => React__default.cloneElement(child, {})) });
|
|
1062
|
-
Badge.Root = BadgeRoot;
|
|
1063
|
-
Badge.HeaderMenu = BadgeHeaderMenu;
|
|
1064
|
-
Badge.FloatingFull = BadgeFloatingFull;
|
|
1065
|
-
Badge.FloatingIcon = BadgeFloatingIcon;
|
|
1066
1070
|
const BadgeInitSelector = () => {
|
|
1067
1071
|
const sledgeWishlistSettings = localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || "") : null;
|
|
1068
|
-
|
|
1072
|
+
let element = Array.from(document.querySelectorAll(SELECTOR.WISHLIST.ELEMENT_BADGE));
|
|
1073
|
+
let isElementDetected = !element || element && !element.length;
|
|
1074
|
+
if (!sledgeWishlistSettings || isElementDetected)
|
|
1069
1075
|
return;
|
|
1070
1076
|
const { floating_button_type } = (sledgeWishlistSettings == null ? void 0 : sledgeWishlistSettings.launch_point) || {};
|
|
1071
1077
|
const isBottomFloatingType = String(floating_button_type).includes("bottom");
|
|
1072
1078
|
if (floating_button_type !== "none") {
|
|
1073
1079
|
if (isBottomFloatingType) {
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
{
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1080
|
+
element.map((item, index) => {
|
|
1081
|
+
if (item && !index) {
|
|
1082
|
+
if (item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`))
|
|
1083
|
+
item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`).remove();
|
|
1084
|
+
let elementContainerWidget = document.createElement("div");
|
|
1085
|
+
elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
|
|
1086
|
+
item.appendChild(elementContainerWidget);
|
|
1087
|
+
const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
|
|
1088
|
+
client.createRoot(elementContainerWidget).render(
|
|
1089
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1090
|
+
SledgeContext.Provider,
|
|
1091
|
+
{
|
|
1092
|
+
value: {
|
|
1093
|
+
isRenderApp: {
|
|
1094
|
+
wishlist: true,
|
|
1095
|
+
productReview: true,
|
|
1096
|
+
instantSearch: true
|
|
1097
|
+
},
|
|
1098
|
+
sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
|
|
1099
|
+
isJsVersion: true
|
|
1089
1100
|
},
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
);
|
|
1097
|
-
}
|
|
1101
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"), position: floating_button_type })
|
|
1102
|
+
}
|
|
1103
|
+
) })
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1098
1107
|
} else {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
{
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1108
|
+
element.map((item, index) => {
|
|
1109
|
+
if (item && !index) {
|
|
1110
|
+
if (item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`))
|
|
1111
|
+
item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`).remove();
|
|
1112
|
+
let elementContainerWidget = document.createElement("div");
|
|
1113
|
+
elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
|
|
1114
|
+
item.appendChild(elementContainerWidget);
|
|
1115
|
+
const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
|
|
1116
|
+
client.createRoot(elementContainerWidget).render(
|
|
1117
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1118
|
+
SledgeContext.Provider,
|
|
1119
|
+
{
|
|
1120
|
+
value: {
|
|
1121
|
+
isRenderApp: {
|
|
1122
|
+
wishlist: true,
|
|
1123
|
+
productReview: true,
|
|
1124
|
+
instantSearch: true
|
|
1125
|
+
},
|
|
1126
|
+
sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
|
|
1127
|
+
isJsVersion: true
|
|
1114
1128
|
},
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
);
|
|
1122
|
-
}
|
|
1129
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"), position: floating_button_type })
|
|
1130
|
+
}
|
|
1131
|
+
) })
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1123
1135
|
}
|
|
1124
1136
|
} else {
|
|
1125
|
-
let element = Array.from(document.querySelectorAll(SELECTOR.WISHLIST.ELEMENT_BADGE));
|
|
1126
|
-
if (!element || element && !element.length)
|
|
1127
|
-
return;
|
|
1128
1137
|
element.map((item) => {
|
|
1129
1138
|
if (item) {
|
|
1130
1139
|
const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
|
|
@@ -1146,7 +1155,7 @@ const BadgeInitSelector = () => {
|
|
|
1146
1155
|
sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
|
|
1147
1156
|
isJsVersion: true
|
|
1148
1157
|
},
|
|
1149
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge
|
|
1158
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true") })
|
|
1150
1159
|
}
|
|
1151
1160
|
) })
|
|
1152
1161
|
);
|
|
@@ -1206,11 +1215,11 @@ const Trigger = (props) => {
|
|
|
1206
1215
|
});
|
|
1207
1216
|
return;
|
|
1208
1217
|
}
|
|
1209
|
-
setIsWishlist(!isWishlist);
|
|
1210
1218
|
let resAddWishlist = await addWishlist(params);
|
|
1211
1219
|
const { status, data: response_data } = resAddWishlist || {};
|
|
1212
1220
|
const { code } = status || {};
|
|
1213
1221
|
if (code === 200) {
|
|
1222
|
+
setIsWishlist(!isWishlist);
|
|
1214
1223
|
if (triggerRenderWishlistBadge)
|
|
1215
1224
|
triggerRenderWishlistBadge(true);
|
|
1216
1225
|
BadgeInitSelector();
|
|
@@ -1495,20 +1504,9 @@ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger,
|
|
|
1495
1504
|
React__default.useEffect(() => {
|
|
1496
1505
|
setIsRequiredLogin(sledgeAnonymId && is_required_login);
|
|
1497
1506
|
}, [sledgeAnonymId]);
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
nodes.forEach(function(node) {
|
|
1502
|
-
if (node.nodeType === 1 && node.querySelector(".sledge-wishlist__widget-box-copy"))
|
|
1503
|
-
handleCopyShareLink();
|
|
1504
|
-
});
|
|
1505
|
-
});
|
|
1506
|
-
});
|
|
1507
|
-
observer.observe(document.body, {
|
|
1508
|
-
childList: true,
|
|
1509
|
-
subtree: true,
|
|
1510
|
-
attributes: false,
|
|
1511
|
-
characterData: false
|
|
1507
|
+
watchElement({
|
|
1508
|
+
selector: ".sledge-wishlist__widget-box-copy",
|
|
1509
|
+
init: handleCopyShareLink
|
|
1512
1510
|
});
|
|
1513
1511
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isRequiredLogin && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: showShareTrigger && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "136px", height: "46px", color: "lighten", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__widget-header-item sledge-wishlist__widget-header-share-trigger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1514
1512
|
Button,
|
|
@@ -1689,10 +1687,15 @@ WidgetHeader$1.ShareTrigger = WidgetHeaderShareTrigger;
|
|
|
1689
1687
|
WidgetHeader$1.ClearTrigger = WidgetHeaderClearTrigger;
|
|
1690
1688
|
WidgetHeader$1.Sort = WidgetHeaderSort$1;
|
|
1691
1689
|
WidgetHeader$1.Limit = WidgetHeaderLimit;
|
|
1692
|
-
const getReviewInfo = async (
|
|
1693
|
-
|
|
1690
|
+
const getReviewInfo = async (props) => {
|
|
1691
|
+
const { productId = null, query = null } = props || {};
|
|
1692
|
+
let convertId = productId ? sanitizeDataId(productId) : "";
|
|
1694
1693
|
let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
|
|
1695
|
-
let
|
|
1694
|
+
let queryParams = "?" + new URLSearchParams({
|
|
1695
|
+
[PAYLOAD_API_ALIASES.Authorization]: sledgeAuthApp,
|
|
1696
|
+
...query
|
|
1697
|
+
}).toString();
|
|
1698
|
+
let url = `${API_URL}/review/info/${convertId}${queryParams}`;
|
|
1696
1699
|
return await fetchApi({
|
|
1697
1700
|
url,
|
|
1698
1701
|
method: "GET",
|
|
@@ -1721,7 +1724,22 @@ const getProductsReviewInfo = async (ids, token) => {
|
|
|
1721
1724
|
};
|
|
1722
1725
|
const Rating = (props) => {
|
|
1723
1726
|
var _a, _b, _c;
|
|
1724
|
-
const {
|
|
1727
|
+
const {
|
|
1728
|
+
total,
|
|
1729
|
+
average,
|
|
1730
|
+
size = "sm",
|
|
1731
|
+
params,
|
|
1732
|
+
withSkeletonLoading = true,
|
|
1733
|
+
withTotal = true,
|
|
1734
|
+
isScrollToElementWidget = true,
|
|
1735
|
+
data: propsData,
|
|
1736
|
+
sledgeSettings,
|
|
1737
|
+
fillColor = "",
|
|
1738
|
+
outlineColor = "",
|
|
1739
|
+
withOutlineColor = true,
|
|
1740
|
+
customComponentId = "",
|
|
1741
|
+
numberOfIcons = 5
|
|
1742
|
+
} = props;
|
|
1725
1743
|
const { productId } = params || {};
|
|
1726
1744
|
const { isRenderApp, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
|
|
1727
1745
|
const { productReview: isRenderAppProductReview } = isRenderApp || {};
|
|
@@ -1744,6 +1762,7 @@ const Rating = (props) => {
|
|
|
1744
1762
|
const [isFirstTime, setIsFirstTime] = React__default.useState(true);
|
|
1745
1763
|
const previousState = usePrevious({ productId });
|
|
1746
1764
|
const { fill_color = "#23BC45", outline_color = "#8D9196" } = ((_c = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _c.rating) || {};
|
|
1765
|
+
const unixTimestamp = getUnixTimestamp();
|
|
1747
1766
|
const handleProductRatingInfo = async (paramsProductId, isTriggerMultiComponent = false) => {
|
|
1748
1767
|
var _a2;
|
|
1749
1768
|
if (paramsProductId !== productId)
|
|
@@ -1758,7 +1777,9 @@ const Rating = (props) => {
|
|
|
1758
1777
|
run = true;
|
|
1759
1778
|
setIsFirstTime(false);
|
|
1760
1779
|
} else {
|
|
1761
|
-
response = await getReviewInfo(
|
|
1780
|
+
response = await getReviewInfo({
|
|
1781
|
+
productId: paramsProductId
|
|
1782
|
+
});
|
|
1762
1783
|
if (!response)
|
|
1763
1784
|
return;
|
|
1764
1785
|
const { status } = response;
|
|
@@ -1835,94 +1856,114 @@ const Rating = (props) => {
|
|
|
1835
1856
|
setIsFirstLoading(true);
|
|
1836
1857
|
handleProductRatingInfo(valueRenderProductReviewRating, true);
|
|
1837
1858
|
}, [productId, valueRenderProductReviewRating]);
|
|
1838
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
offset = "35%";
|
|
1859
|
-
}
|
|
1860
|
-
if (fillOther === "fill-3") {
|
|
1861
|
-
offset = "40%";
|
|
1862
|
-
}
|
|
1863
|
-
if (fillOther === "fill-4") {
|
|
1864
|
-
offset = "45%";
|
|
1865
|
-
}
|
|
1866
|
-
if (fillOther === "fill-5") {
|
|
1867
|
-
offset = "50%";
|
|
1868
|
-
}
|
|
1869
|
-
if (fillOther === "fill-6") {
|
|
1870
|
-
offset = "60%";
|
|
1871
|
-
}
|
|
1872
|
-
if (fillOther === "fill-7") {
|
|
1873
|
-
offset = "70%";
|
|
1874
|
-
}
|
|
1875
|
-
if (fillOther === "fill-8") {
|
|
1876
|
-
offset = "80%";
|
|
1877
|
-
}
|
|
1878
|
-
if (fillOther === "fill-9") {
|
|
1879
|
-
offset = "90%";
|
|
1880
|
-
}
|
|
1881
|
-
if (fillOther === "full") {
|
|
1882
|
-
offset = "100%";
|
|
1883
|
-
}
|
|
1884
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", ...sizing, viewBox: "0 0 32 32", children: [
|
|
1885
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("defs", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("linearGradient", { id: `rating-gradient-${fillOther}-${index}-${productId}`, children: [
|
|
1886
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset, stopColor: fill_color }),
|
|
1887
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset, stopColor: "transparent" })
|
|
1888
|
-
] }) }),
|
|
1889
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1890
|
-
"path",
|
|
1891
|
-
{
|
|
1892
|
-
fill: `url(#rating-gradient-${fillOther}-${index}-${productId})`,
|
|
1893
|
-
d: "M9.18817 19.8162L9.25542 19.4179L8.94431 19.1604L3.14591 14.3604L3.14598 14.3603L3.13673 14.3529C2.5294 13.8672 2.784 12.8955 3.54372 12.7636L11.7291 12.3989L12.1807 12.3788L12.3481 11.959L15.8472 3.18648C15.977 2.94796 16.2257 2.79961 16.4979 2.79961C16.769 2.79961 17.0185 2.94848 17.1489 3.18698L20.6478 11.959L20.8152 12.3788L21.2668 12.3989L29.4522 12.7636C30.2119 12.8955 30.4665 13.8672 29.8592 14.3529L29.8591 14.3528L29.85 14.3604L24.0516 19.1604L23.7405 19.4179L23.8077 19.8162L25.3884 29.1774C25.4834 29.8833 24.7613 30.4104 24.1224 30.1159L16.8734 25.5088L16.498 25.2702L16.1226 25.5088L8.87373 30.1141C8.23317 30.409 7.51248 29.8817 7.60746 29.1758L9.18817 19.8162Z",
|
|
1894
|
-
stroke: outline_color,
|
|
1895
|
-
strokeWidth: "1.4"
|
|
1859
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1860
|
+
"div",
|
|
1861
|
+
{
|
|
1862
|
+
className: "sledge-product-review__rating",
|
|
1863
|
+
onClick: handleOnClick,
|
|
1864
|
+
...typeof size === "string" ? {
|
|
1865
|
+
["data-rating-size"]: size
|
|
1866
|
+
} : {},
|
|
1867
|
+
children: isFirstLoading && withSkeletonLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "230px", height: "28px", color: "lighten", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isLoading && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1868
|
+
[1, 2, 3, 4, 5].map((item, index) => {
|
|
1869
|
+
if (!(item <= numberOfIcons))
|
|
1870
|
+
return;
|
|
1871
|
+
let ratingValue = Math.floor(parseFloat(averageReview));
|
|
1872
|
+
let getCommaValue = String(averageReview).includes(",") ? String(averageReview).split(",") : [];
|
|
1873
|
+
let getCommaValueDot = String(averageReview).includes(".") ? String(averageReview).split(".") : [];
|
|
1874
|
+
let isHaveCommaValue = getCommaValue.length || getCommaValueDot.length;
|
|
1875
|
+
let commaValue = isHaveCommaValue ? getCommaValue[1] || getCommaValueDot[1] : 0;
|
|
1876
|
+
let fillOther = "fill-0";
|
|
1877
|
+
if (item > ratingValue && ratingValue + 1 === item) {
|
|
1878
|
+
fillOther = `fill-${commaValue}`;
|
|
1896
1879
|
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1880
|
+
fillOther = item <= ratingValue ? "full" : fillOther;
|
|
1881
|
+
let offset;
|
|
1882
|
+
if (fillOther === "fill-0") {
|
|
1883
|
+
offset = "0%";
|
|
1884
|
+
}
|
|
1885
|
+
if (fillOther === "fill-1") {
|
|
1886
|
+
offset = "25%";
|
|
1887
|
+
}
|
|
1888
|
+
if (fillOther === "fill-2") {
|
|
1889
|
+
offset = "35%";
|
|
1890
|
+
}
|
|
1891
|
+
if (fillOther === "fill-3") {
|
|
1892
|
+
offset = "40%";
|
|
1893
|
+
}
|
|
1894
|
+
if (fillOther === "fill-4") {
|
|
1895
|
+
offset = "45%";
|
|
1896
|
+
}
|
|
1897
|
+
if (fillOther === "fill-5") {
|
|
1898
|
+
offset = "50%";
|
|
1899
|
+
}
|
|
1900
|
+
if (fillOther === "fill-6") {
|
|
1901
|
+
offset = "60%";
|
|
1902
|
+
}
|
|
1903
|
+
if (fillOther === "fill-7") {
|
|
1904
|
+
offset = "70%";
|
|
1905
|
+
}
|
|
1906
|
+
if (fillOther === "fill-8") {
|
|
1907
|
+
offset = "80%";
|
|
1908
|
+
}
|
|
1909
|
+
if (fillOther === "fill-9") {
|
|
1910
|
+
offset = "90%";
|
|
1911
|
+
}
|
|
1912
|
+
if (fillOther === "full") {
|
|
1913
|
+
offset = "100%";
|
|
1914
|
+
}
|
|
1915
|
+
let suffixGradientId = `-${fillOther}-${index}-${productId ? productId : unixTimestamp}${customComponentId ? `-${customComponentId}` : ""}`;
|
|
1916
|
+
let strokeGradientId = `rating-stroke${suffixGradientId}`;
|
|
1917
|
+
let fillGradientId = `rating-gradient${suffixGradientId}`;
|
|
1918
|
+
return /* @__PURE__ */ createElement("svg", { xmlns: "http://www.w3.org/2000/svg", ...sizing, viewBox: "0 0 32 32", key: suffixGradientId }, /* @__PURE__ */ jsxRuntimeExports.jsxs("defs", { children: [
|
|
1919
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("linearGradient", { id: strokeGradientId, children: [
|
|
1920
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset, stopColor: fillColor || fill_color }),
|
|
1921
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset, stopColor: fillOther === "full" ? fillColor || fill_color : outlineColor || outline_color })
|
|
1922
|
+
] }),
|
|
1923
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("linearGradient", { id: fillGradientId, children: [
|
|
1924
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset, stopColor: fillColor || fill_color }),
|
|
1925
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset, stopColor: "transparent" })
|
|
1926
|
+
] })
|
|
1927
|
+
] }), /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1928
|
+
"path",
|
|
1929
|
+
{
|
|
1930
|
+
fill: `url(#${fillGradientId})`,
|
|
1931
|
+
d: "M9.18817 19.8162L9.25542 19.4179L8.94431 19.1604L3.14591 14.3604L3.14598 14.3603L3.13673 14.3529C2.5294 13.8672 2.784 12.8955 3.54372 12.7636L11.7291 12.3989L12.1807 12.3788L12.3481 11.959L15.8472 3.18648C15.977 2.94796 16.2257 2.79961 16.4979 2.79961C16.769 2.79961 17.0185 2.94848 17.1489 3.18698L20.6478 11.959L20.8152 12.3788L21.2668 12.3989L29.4522 12.7636C30.2119 12.8955 30.4665 13.8672 29.8592 14.3529L29.8591 14.3528L29.85 14.3604L24.0516 19.1604L23.7405 19.4179L23.8077 19.8162L25.3884 29.1774C25.4834 29.8833 24.7613 30.4104 24.1224 30.1159L16.8734 25.5088L16.498 25.2702L16.1226 25.5088L8.87373 30.1141C8.23317 30.409 7.51248 29.8817 7.60746 29.1758L9.18817 19.8162Z",
|
|
1932
|
+
...withOutlineColor ? {
|
|
1933
|
+
stroke: `url(#${strokeGradientId})`,
|
|
1934
|
+
strokeWidth: "1.4"
|
|
1935
|
+
} : {}
|
|
1936
|
+
}
|
|
1937
|
+
));
|
|
1938
|
+
}),
|
|
1939
|
+
withTotal ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__rating-summary-total", children: [
|
|
1940
|
+
"(",
|
|
1941
|
+
totalReview,
|
|
1942
|
+
")"
|
|
1943
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})
|
|
1944
|
+
] }) })
|
|
1945
|
+
}
|
|
1946
|
+
);
|
|
1906
1947
|
};
|
|
1907
1948
|
const getSizing = (size) => {
|
|
1908
1949
|
if (size === "xs") {
|
|
1909
1950
|
return {
|
|
1910
|
-
width: 14
|
|
1911
|
-
height: 14
|
|
1951
|
+
width: 14,
|
|
1952
|
+
height: 14
|
|
1912
1953
|
};
|
|
1913
1954
|
} else if (size === "sm") {
|
|
1914
1955
|
return {
|
|
1915
|
-
width:
|
|
1916
|
-
height:
|
|
1956
|
+
width: 20,
|
|
1957
|
+
height: 20
|
|
1917
1958
|
};
|
|
1918
1959
|
} else {
|
|
1919
1960
|
return {
|
|
1920
|
-
width:
|
|
1921
|
-
height:
|
|
1961
|
+
width: 32,
|
|
1962
|
+
height: 32
|
|
1922
1963
|
};
|
|
1923
1964
|
}
|
|
1924
1965
|
};
|
|
1925
|
-
const WidgetHeaderAddTrigger = ({
|
|
1966
|
+
const WidgetHeaderAddTrigger = ({ isFirstLoadingHeader, text, dataSettings, params, onAfterAddReview, tabIndex }) => {
|
|
1926
1967
|
var _a, _b, _c;
|
|
1927
1968
|
const {
|
|
1928
1969
|
text_color: display_button_write_review_text_color,
|
|
@@ -1951,13 +1992,13 @@ const WidgetHeaderAddTrigger = ({ isFirstLoading, text, dataSettings, params, on
|
|
|
1951
1992
|
...display_button_write_review_font_weight && { fontWeight: display_button_write_review_font_weight },
|
|
1952
1993
|
...display_button_write_review_text_transform && { textTransform: display_button_write_review_text_transform }
|
|
1953
1994
|
};
|
|
1954
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-header-item", children:
|
|
1995
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-header-item", children: isFirstLoadingHeader ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "134px", height: "42px", rounded: "lg", color: "lighten" }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1955
1996
|
Button,
|
|
1956
1997
|
{
|
|
1957
1998
|
type: "button",
|
|
1958
1999
|
colorType: "success",
|
|
1959
2000
|
className: "sledge-product-review__widget-header-add-trigger",
|
|
1960
|
-
onClick: () => typeof window !== "undefined" && window.sledgeProductReviewWidgetFormAdd && window.sledgeProductReviewWidgetFormAdd(params, onAfterAddReview),
|
|
2001
|
+
onClick: () => typeof window !== "undefined" && window.sledgeProductReviewWidgetFormAdd && window.sledgeProductReviewWidgetFormAdd(params, onAfterAddReview, tabIndex),
|
|
1961
2002
|
style: display_button_write_review_style,
|
|
1962
2003
|
children: [
|
|
1963
2004
|
/* @__PURE__ */ jsxRuntimeExports.jsx(MessageAddIcon, { width: 16, height: 16, color: "currentColor" }),
|
|
@@ -1966,7 +2007,7 @@ const WidgetHeaderAddTrigger = ({ isFirstLoading, text, dataSettings, params, on
|
|
|
1966
2007
|
}
|
|
1967
2008
|
) });
|
|
1968
2009
|
};
|
|
1969
|
-
const WidgetHeaderSort = ({
|
|
2010
|
+
const WidgetHeaderSort = ({ isFirstLoadingHeader, productReviewSort, dataSettings, setSelectedSort, setIsRefreshWidgetList }) => {
|
|
1970
2011
|
var _a, _b;
|
|
1971
2012
|
const { default_sort, show_sorting_options } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.widget) || {};
|
|
1972
2013
|
const [clickedSortId, setClickedSortId] = React__default.useState(default_sort || null);
|
|
@@ -1976,7 +2017,7 @@ const WidgetHeaderSort = ({ isFirstLoading, productReviewSort, dataSettings, set
|
|
|
1976
2017
|
setSelectedSort && setSelectedSort(value);
|
|
1977
2018
|
};
|
|
1978
2019
|
const getSelectedSort = clickedSortId || ((_b = productReviewSort[0]) == null ? void 0 : _b.value);
|
|
1979
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !show_sorting_options ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-header-item", children:
|
|
2020
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !show_sorting_options ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-header-item", children: isFirstLoadingHeader ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "134px", height: "42px", rounded: "lg", color: "lighten" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1980
2021
|
SelectField,
|
|
1981
2022
|
{
|
|
1982
2023
|
align: "end",
|
|
@@ -2006,7 +2047,7 @@ const WidgetHeaderSummary = (props) => {
|
|
|
2006
2047
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
2007
2048
|
const [isRefreshRating, setIsRefreshRating] = React__default.useState(summaryData ? false : true);
|
|
2008
2049
|
const [isOpen, setIsOpen] = React__default.useState(false);
|
|
2009
|
-
const [totalReview, setTotalReview] = React__default.useState((summaryData == null ? void 0 : summaryData.review_count)
|
|
2050
|
+
const [totalReview, setTotalReview] = React__default.useState((summaryData == null ? void 0 : summaryData.review_count) || 0);
|
|
2010
2051
|
const [ratingList, setRatingList] = React__default.useState(
|
|
2011
2052
|
(summaryData == null ? void 0 : summaryData.rating) || {
|
|
2012
2053
|
5: 0,
|
|
@@ -2032,7 +2073,9 @@ const WidgetHeaderSummary = (props) => {
|
|
|
2032
2073
|
run = true;
|
|
2033
2074
|
setIsFirstTime(false);
|
|
2034
2075
|
} else {
|
|
2035
|
-
response = await getReviewInfo(
|
|
2076
|
+
response = await getReviewInfo({
|
|
2077
|
+
productId
|
|
2078
|
+
});
|
|
2036
2079
|
if (!response)
|
|
2037
2080
|
return;
|
|
2038
2081
|
const { status } = response;
|
|
@@ -2442,7 +2485,7 @@ const ProductCard = (props) => {
|
|
|
2442
2485
|
productSku: sku,
|
|
2443
2486
|
productVariantName: variant_title,
|
|
2444
2487
|
productLink: url,
|
|
2445
|
-
productImage: (image == null ? void 0 : image.src) || `${
|
|
2488
|
+
productImage: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`,
|
|
2446
2489
|
productCurrency: currency,
|
|
2447
2490
|
productPrice: price
|
|
2448
2491
|
},
|
|
@@ -2452,7 +2495,7 @@ const ProductCard = (props) => {
|
|
|
2452
2495
|
wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
|
|
2453
2496
|
}
|
|
2454
2497
|
),
|
|
2455
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${
|
|
2498
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`, alt: "sledge-card-image", loading: "lazy", className: "sledge__product-grid-card-image-featured-image" }),
|
|
2456
2499
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: images == null ? void 0 : images.map((image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2457
2500
|
"img",
|
|
2458
2501
|
{
|
|
@@ -2586,7 +2629,7 @@ ${selectedOption === item2 ? "sledge__product-variant-size-swatch-active" : ""}
|
|
|
2586
2629
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: component }, id);
|
|
2587
2630
|
};
|
|
2588
2631
|
const ProductGrid = (props) => {
|
|
2589
|
-
const { type, className = "", data, setting, sourceApp = null, onAfterAddToCart, onAfterRenderProduct } = props;
|
|
2632
|
+
const { type, className = "", data, setting, sourceApp = null, useSlider = false, onAfterAddToCart, onAfterRenderProduct } = props;
|
|
2590
2633
|
const { redirect_add_to_cart = true } = setting || {};
|
|
2591
2634
|
const [clickedAddToCartId, setClickedAddToCartId] = React__default.useState(null);
|
|
2592
2635
|
const handleAddToCart = async (data2) => {
|
|
@@ -2636,10 +2679,11 @@ const ProductGrid = (props) => {
|
|
|
2636
2679
|
}, 1e3);
|
|
2637
2680
|
}
|
|
2638
2681
|
};
|
|
2682
|
+
const Container = useSlider ? Carousel : "div";
|
|
2639
2683
|
React__default.useEffect(() => {
|
|
2640
2684
|
onAfterRenderProduct && onAfterRenderProduct("success");
|
|
2641
2685
|
}, []);
|
|
2642
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2686
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: `sledge__product-grid ${className}`, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
|
|
2643
2687
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(ProductCard, { item, handleAddToCart, clickedAddToCartId, ...props }, `sledge-product-card_${index}`);
|
|
2644
2688
|
}) });
|
|
2645
2689
|
};
|
|
@@ -2657,7 +2701,7 @@ const CollectionGrid = ({ className = "", data, cards: CardsComponent, isCompone
|
|
|
2657
2701
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: CardsComponent({ ...CardsProps }) } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CardsComponent, { ...CardsProps }) }, index);
|
|
2658
2702
|
} else {
|
|
2659
2703
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__collection-grid-card", children: [
|
|
2660
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-image-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${
|
|
2704
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-image-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`, alt: "sledge-card-image", loading: "lazy" }) }) }),
|
|
2661
2705
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__collection-grid-card-content", children: [
|
|
2662
2706
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-content-title", children: title }),
|
|
2663
2707
|
body_html ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-content-description", dangerouslySetInnerHTML: { __html: body_html } }) : null
|
|
@@ -2678,7 +2722,7 @@ const PageGrid = ({ className = "", data, cards: CardsComponent, isComponentJsVe
|
|
|
2678
2722
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: CardsComponent({ ...CardsProps }) } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CardsComponent, { ...CardsProps }) }, index);
|
|
2679
2723
|
} else {
|
|
2680
2724
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__page-grid-card", children: [
|
|
2681
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-image-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${
|
|
2725
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-image-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`, alt: "sledge-card-image", loading: "lazy" }) }) }),
|
|
2682
2726
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__page-grid-card-content", children: [
|
|
2683
2727
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-content-title", children: title }),
|
|
2684
2728
|
body_html ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-content-description", dangerouslySetInnerHTML: { __html: body_html } }) : null
|
|
@@ -2700,7 +2744,7 @@ const BlogGrid = ({ className = "", data, cards: CardsComponent, isComponentJsVe
|
|
|
2700
2744
|
} else {
|
|
2701
2745
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__blog-grid-card", children: [
|
|
2702
2746
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__blog-grid-content", children: [
|
|
2703
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${
|
|
2747
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`, alt: "sledge-card-image", loading: "lazy" }) }) }),
|
|
2704
2748
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__blog-grid-card-desc", children: [
|
|
2705
2749
|
/* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card-title", children: title }) }),
|
|
2706
2750
|
created_at ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-badge-vendor", children: convertDate(created_at) }) : null
|
|
@@ -2727,7 +2771,7 @@ const ArticleGrid = ({ className = "", data, cards: CardsComponent, isComponentJ
|
|
|
2727
2771
|
} else {
|
|
2728
2772
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__article-grid-card", children: [
|
|
2729
2773
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__article-grid-content", children: [
|
|
2730
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__article-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${
|
|
2774
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__article-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || `${CDN_URL}/images/blank-image.png`, alt: "sledge-card-image", loading: "lazy" }) }) }),
|
|
2731
2775
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__article-grid-card-desc", children: [
|
|
2732
2776
|
/* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__article-grid-card-title", children: title }) }),
|
|
2733
2777
|
created_at ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__article-grid-badge-vendor", children: convertDate(created_at) }) : null,
|
|
@@ -2857,13 +2901,21 @@ const SkeletonReviewGrid = ({ count, type, gridItemHeights = [] }) => {
|
|
|
2857
2901
|
let components = [];
|
|
2858
2902
|
for (let i = 0; i < count; i++) {
|
|
2859
2903
|
components.push(
|
|
2860
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-review-card", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2904
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-review-card", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2905
|
+
SkeletonItem,
|
|
2906
|
+
{
|
|
2907
|
+
width: "100%",
|
|
2908
|
+
height: type === "list" || (type === "grid" || type === "image_grid") && !(gridItemHeights == null ? void 0 : gridItemHeights.length) ? "111px" : gridItemHeights[i],
|
|
2909
|
+
color: "lighten",
|
|
2910
|
+
rounded: "md"
|
|
2911
|
+
}
|
|
2912
|
+
) }, i)
|
|
2861
2913
|
);
|
|
2862
2914
|
}
|
|
2863
2915
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2864
2916
|
MasonryResponsive,
|
|
2865
2917
|
{
|
|
2866
|
-
columnsCountBreakPoints: type === "
|
|
2918
|
+
columnsCountBreakPoints: type === "list" ? { 350: 1 } : { 350: 1, 750: 3, 1024: 4 },
|
|
2867
2919
|
className: "sledge-product-review__widget-review-grid sledge__skeleton-review-grid sledge__skeleton-pointer-events-none",
|
|
2868
2920
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Masonry, { gutter: "30px", children: components })
|
|
2869
2921
|
}
|
|
@@ -2996,6 +3048,95 @@ const LoadingDots = () => {
|
|
|
2996
3048
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__loading-icon-dot" })
|
|
2997
3049
|
] });
|
|
2998
3050
|
};
|
|
3051
|
+
const Carousel$1 = "";
|
|
3052
|
+
const Carousel = (props) => {
|
|
3053
|
+
const { children, className = "", "data-grid-type": dataGridType } = props;
|
|
3054
|
+
const [active, setActive] = React__default.useState(true);
|
|
3055
|
+
const {
|
|
3056
|
+
options = {
|
|
3057
|
+
active,
|
|
3058
|
+
slidesToScroll: "auto",
|
|
3059
|
+
align: "start",
|
|
3060
|
+
dragFree: true,
|
|
3061
|
+
duration: 35
|
|
3062
|
+
}
|
|
3063
|
+
} = props;
|
|
3064
|
+
const [carouselRef, carouselApi] = useEmblaCarousel(options);
|
|
3065
|
+
const [prevBtnDisabled, setPrevBtnDisabled] = React__default.useState(true);
|
|
3066
|
+
const [nextBtnDisabled, setNextBtnDisabled] = React__default.useState(true);
|
|
3067
|
+
const scrollPrev = React__default.useCallback(() => carouselApi && carouselApi.scrollPrev(), [carouselApi]);
|
|
3068
|
+
const scrollNext = React__default.useCallback(() => carouselApi && carouselApi.scrollNext(), [carouselApi]);
|
|
3069
|
+
const onSelect = React__default.useCallback((carouselApi2) => {
|
|
3070
|
+
setPrevBtnDisabled(!carouselApi2.canScrollPrev());
|
|
3071
|
+
setNextBtnDisabled(!carouselApi2.canScrollNext());
|
|
3072
|
+
}, []);
|
|
3073
|
+
React__default.useEffect(() => {
|
|
3074
|
+
if (!carouselApi)
|
|
3075
|
+
return;
|
|
3076
|
+
if (prevBtnDisabled && nextBtnDisabled)
|
|
3077
|
+
setActive(false);
|
|
3078
|
+
else
|
|
3079
|
+
setActive(true);
|
|
3080
|
+
}, [carouselApi, prevBtnDisabled, nextBtnDisabled]);
|
|
3081
|
+
React__default.useEffect(() => {
|
|
3082
|
+
if (!carouselApi)
|
|
3083
|
+
return;
|
|
3084
|
+
onSelect(carouselApi);
|
|
3085
|
+
carouselApi.on("reInit", onSelect);
|
|
3086
|
+
carouselApi.on("select", onSelect);
|
|
3087
|
+
}, [carouselApi, onSelect]);
|
|
3088
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `sledge__carousel ${className}`, children: [
|
|
3089
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3090
|
+
Navigation,
|
|
3091
|
+
{
|
|
3092
|
+
state: {
|
|
3093
|
+
prevBtnDisabled,
|
|
3094
|
+
nextBtnDisabled
|
|
3095
|
+
},
|
|
3096
|
+
position: "left",
|
|
3097
|
+
disabled: prevBtnDisabled,
|
|
3098
|
+
onClick: scrollPrev,
|
|
3099
|
+
className: "sledge__carousel-button-prev"
|
|
3100
|
+
}
|
|
3101
|
+
),
|
|
3102
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__carousel-viewport", ref: carouselRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__carousel-container sledge__product-grid", "data-grid-type": dataGridType, children }) }),
|
|
3103
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3104
|
+
Navigation,
|
|
3105
|
+
{
|
|
3106
|
+
state: {
|
|
3107
|
+
prevBtnDisabled,
|
|
3108
|
+
nextBtnDisabled
|
|
3109
|
+
},
|
|
3110
|
+
position: "right",
|
|
3111
|
+
disabled: nextBtnDisabled,
|
|
3112
|
+
onClick: scrollNext,
|
|
3113
|
+
className: "sledge__carousel-button-next"
|
|
3114
|
+
}
|
|
3115
|
+
)
|
|
3116
|
+
] });
|
|
3117
|
+
};
|
|
3118
|
+
const Navigation = (props) => {
|
|
3119
|
+
const { children, state, className, position, ...restProps } = props;
|
|
3120
|
+
const { prevBtnDisabled, nextBtnDisabled } = state;
|
|
3121
|
+
if (prevBtnDisabled && nextBtnDisabled)
|
|
3122
|
+
return null;
|
|
3123
|
+
const LeftIcon = /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3124
|
+
"path",
|
|
3125
|
+
{
|
|
3126
|
+
d: "M10.6875 2.97945C10.865 3.15697 10.8812 3.43474 10.7359 3.63048L10.6875 3.68656L6.37465 7.99967L10.6875 12.3128C10.865 12.4903 10.8812 12.7681 10.7359 12.9638L10.6875 13.0199C10.51 13.1974 10.2323 13.2135 10.0365 13.0683L9.98043 13.0199L5.31377 8.35323C5.13625 8.17572 5.12012 7.89794 5.26535 7.7022L5.31377 7.64612L9.98043 2.97945C10.1757 2.78419 10.4923 2.78419 10.6875 2.97945Z",
|
|
3127
|
+
fill: "#767676"
|
|
3128
|
+
}
|
|
3129
|
+
) });
|
|
3130
|
+
const RightIcon = /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 17, height: 17, viewBox: "0 0 17 17", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3131
|
+
"path",
|
|
3132
|
+
{
|
|
3133
|
+
d: "M5.60738 13.1299C5.42987 12.9524 5.41374 12.6746 5.55897 12.4789L5.60738 12.4228L9.92027 8.1097L5.60738 3.79659C5.42987 3.61908 5.41374 3.3413 5.55897 3.14556L5.60738 3.08948C5.7849 2.91197 6.06267 2.89583 6.25841 3.04107L6.31449 3.08948L10.9812 7.75615C11.1587 7.93366 11.1748 8.21143 11.0296 8.40718L10.9812 8.46325L6.31449 13.1299C6.11923 13.3252 5.80265 13.3252 5.60738 13.1299Z",
|
|
3134
|
+
fill: "#767676"
|
|
3135
|
+
}
|
|
3136
|
+
) });
|
|
3137
|
+
const Icon = () => position === "left" ? LeftIcon : RightIcon;
|
|
3138
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: `sledge__carousel-button ${className}`, type: "button", ...restProps, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, {}) });
|
|
3139
|
+
};
|
|
2999
3140
|
const SearchIconWidget = (props) => {
|
|
3000
3141
|
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
3001
3142
|
const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
|
|
@@ -3594,7 +3735,7 @@ const SearchResultWidget = (props) => {
|
|
|
3594
3735
|
let isHasProductFacets = isProductIndex && getFacets.length;
|
|
3595
3736
|
let additionalFilter = [];
|
|
3596
3737
|
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
3597
|
-
additionalFilter.push(`tags NOT IN
|
|
3738
|
+
additionalFilter.push(`tags NOT IN ${JSON.stringify(hidden_tags)}`);
|
|
3598
3739
|
if (!show_out_of_stock)
|
|
3599
3740
|
additionalFilter.push("variants.inventory_quantity > 0");
|
|
3600
3741
|
if (collectionId)
|
|
@@ -4319,15 +4460,15 @@ const ResultProduct = (props) => {
|
|
|
4319
4460
|
let isCustom = ["variants.inventory_quantity"].includes(value);
|
|
4320
4461
|
let isRange = ["variants.price"].includes(value);
|
|
4321
4462
|
let isArray = ["tags"].includes(value);
|
|
4322
|
-
let items = Array.isArray(facet[1]) && ((_a3 = facet[1]) == null ? void 0 : _a3.length) > 1 ? isRange ? `${value} >= ${facet[1][0]} AND ${value} <= ${facet[1][1]}` : isArray ? `${value} IN
|
|
4463
|
+
let items = Array.isArray(facet[1]) && ((_a3 = facet[1]) == null ? void 0 : _a3.length) > 1 ? isRange ? `${value} >= ${facet[1][0]} AND ${value} <= ${facet[1][1]}` : isArray ? `${value} IN ${JSON.stringify(facet[1])}` : (_b3 = facet[1]) == null ? void 0 : _b3.map((item) => {
|
|
4323
4464
|
return isCustom ? `${value} ${item}` : `${value} = '${item}'`;
|
|
4324
|
-
}).join(" OR ") : isCustom ? `${value} ${facet[1]}` : isArray ? `${value} IN
|
|
4465
|
+
}).join(" OR ") : isCustom ? `${value} ${facet[1]}` : isArray ? `${value} IN ${JSON.stringify(facet[1])}` : `${value} = '${facet[1]}'`;
|
|
4325
4466
|
return items;
|
|
4326
4467
|
} else
|
|
4327
4468
|
return null;
|
|
4328
4469
|
}).filter((item) => item);
|
|
4329
4470
|
if (hiddenTags == null ? void 0 : hiddenTags.length)
|
|
4330
|
-
filters.push(`tags NOT IN
|
|
4471
|
+
filters.push(`tags NOT IN ${JSON.stringify(hiddenTags)}`);
|
|
4331
4472
|
if (collectionId)
|
|
4332
4473
|
filters.push(`collections.id = '${collectionId}'`);
|
|
4333
4474
|
let body = {
|
|
@@ -4350,19 +4491,24 @@ const ResultProduct = (props) => {
|
|
|
4350
4491
|
if (!((_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.enable_on_search) || hideFilterWhenOneValue)
|
|
4351
4492
|
return;
|
|
4352
4493
|
let isSetFilter = false;
|
|
4494
|
+
let valueAllowedFilter = [];
|
|
4353
4495
|
if (!isSetFilter)
|
|
4354
4496
|
allowedFilters == null ? void 0 : allowedFilters.map((filter) => {
|
|
4355
4497
|
const { collections, items } = filter;
|
|
4356
4498
|
if (collectionId && (collections == null ? void 0 : collections.includes(Number(collectionId)))) {
|
|
4357
4499
|
isSetFilter = true;
|
|
4358
|
-
|
|
4500
|
+
valueAllowedFilter = items;
|
|
4359
4501
|
} else {
|
|
4360
4502
|
if (collections == null ? void 0 : collections.includes("all")) {
|
|
4361
4503
|
isSetFilter = true;
|
|
4362
|
-
|
|
4504
|
+
valueAllowedFilter = items;
|
|
4363
4505
|
}
|
|
4364
4506
|
}
|
|
4365
4507
|
});
|
|
4508
|
+
if (isSetFilter) {
|
|
4509
|
+
setAllowedFilter(valueAllowedFilter);
|
|
4510
|
+
setClickedOpenFilters((valueAllowedFilter == null ? void 0 : valueAllowedFilter.length) ? valueAllowedFilter.map(({ value }) => value) : []);
|
|
4511
|
+
}
|
|
4366
4512
|
};
|
|
4367
4513
|
const handlePageChange = (page) => {
|
|
4368
4514
|
setCurrentPage(page);
|