@sledge-app/react-instant-search 0.0.1
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/README.md +1 -0
- package/dist/components/ProductFilterWidget/ProductFilterWidget.d.ts +15 -0
- package/dist/components/ProductFilterWidget/ProductFilterWidget.d.ts.map +1 -0
- package/dist/components/ProductFilterWidget/ProductFilterWidgetInitSelector.d.ts +2 -0
- package/dist/components/ProductFilterWidget/ProductFilterWidgetInitSelector.d.ts.map +1 -0
- package/dist/components/ProductFilterWidget/index.d.ts +3 -0
- package/dist/components/ProductFilterWidget/index.d.ts.map +1 -0
- package/dist/components/SearchIconWidget/SearchIconWidget.d.ts +10 -0
- package/dist/components/SearchIconWidget/SearchIconWidget.d.ts.map +1 -0
- package/dist/components/SearchIconWidget/SearchIconWidgetInitSelector.d.ts +2 -0
- package/dist/components/SearchIconWidget/SearchIconWidgetInitSelector.d.ts.map +1 -0
- package/dist/components/SearchIconWidget/SearchIconWidgetPopup.d.ts +7 -0
- package/dist/components/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -0
- package/dist/components/SearchIconWidget/SearchIconWidgetPopupInitSelector.d.ts +2 -0
- package/dist/components/SearchIconWidget/SearchIconWidgetPopupInitSelector.d.ts.map +1 -0
- package/dist/components/SearchIconWidget/index.d.ts +5 -0
- package/dist/components/SearchIconWidget/index.d.ts.map +1 -0
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts +16 -0
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts.map +1 -0
- package/dist/components/SearchResultWidget/SearchResultWidgetInitSelector.d.ts +2 -0
- package/dist/components/SearchResultWidget/SearchResultWidgetInitSelector.d.ts.map +1 -0
- package/dist/components/SearchResultWidget/index.d.ts +3 -0
- package/dist/components/SearchResultWidget/index.d.ts.map +1 -0
- package/dist/components/SearchWidget/SearchWidget.d.ts +10 -0
- package/dist/components/SearchWidget/SearchWidget.d.ts.map +1 -0
- package/dist/components/SearchWidget/SearchWidgetInitSelector.d.ts +2 -0
- package/dist/components/SearchWidget/SearchWidgetInitSelector.d.ts.map +1 -0
- package/dist/components/SearchWidget/index.d.ts +3 -0
- package/dist/components/SearchWidget/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/sledge-react-instant-search.cjs +2 -0
- package/dist/sledge-react-instant-search.cjs.map +1 -0
- package/dist/sledge-react-instant-search.js +4042 -0
- package/dist/sledge-react-instant-search.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/vendor-024ba8ae.cjs +2 -0
- package/dist/vendor-024ba8ae.cjs.map +1 -0
- package/dist/vendor-90dfd914.js +17140 -0
- package/dist/vendor-90dfd914.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,4042 @@
|
|
|
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
|
+
import React__default, { createElement } from "react";
|
|
3
|
+
import { SledgeContext } from "@sledge-app/react-core";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
const ProductFilterWidget = (props) => {
|
|
6
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SearchResultWidget, { layoutType: "product-filter", ...props });
|
|
7
|
+
};
|
|
8
|
+
const API_URL = "https://sledge-api-preprod.offstack.io";
|
|
9
|
+
const INSTANT_SEARCH_ENGINE_URL = "https://instant-search-engine.offstack.io";
|
|
10
|
+
const LOCAL_STORAGE_KEY = {
|
|
11
|
+
ANONYM_ID: "sledge-anonym-id",
|
|
12
|
+
AUTH_APP: "sledge-auth-app",
|
|
13
|
+
INSTANT_SEARCH_AUTH_APP: "sledge-instant-search-auth-app",
|
|
14
|
+
WISHLIST_SETTING: "sledge-wishlist-setting",
|
|
15
|
+
PRODUCT_REVIEW_SETTING: "sledge-product-review-setting",
|
|
16
|
+
INSTANT_SEARCH_SETTING: "sledge-instant-search-setting"
|
|
17
|
+
};
|
|
18
|
+
const SEARCH_RESULT_URL = "/pages/search-result";
|
|
19
|
+
const OBJECT_DATA_STRING_KEY = {
|
|
20
|
+
STORE: {
|
|
21
|
+
NAME: "{{ shop.name }}"
|
|
22
|
+
},
|
|
23
|
+
PRODUCT: {
|
|
24
|
+
TITLE: "{ product_title }",
|
|
25
|
+
VARIANT_TITLE: "{ product_variant_title }",
|
|
26
|
+
IMAGE: "{ product_image }",
|
|
27
|
+
CURRENCY: "{ product_currency }",
|
|
28
|
+
PRICE: "{ product_price }",
|
|
29
|
+
VENDOR: "{ product_vendor }",
|
|
30
|
+
SKU: "{ product_sku }"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const sanitizeDataId = (id) => {
|
|
34
|
+
if (!id)
|
|
35
|
+
return "";
|
|
36
|
+
let getId = String(id);
|
|
37
|
+
if (getId.includes("shopify") && getId.includes("/")) {
|
|
38
|
+
let arrId = getId.split("/");
|
|
39
|
+
return arrId[arrId.length - 1] || getId;
|
|
40
|
+
} else {
|
|
41
|
+
return getId;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const replaceString = (str, find, replace) => {
|
|
45
|
+
for (var i = 0; i < find.length; i++) {
|
|
46
|
+
str = str.replace(new RegExp(find[i], "gi"), replace[i]);
|
|
47
|
+
}
|
|
48
|
+
return str;
|
|
49
|
+
};
|
|
50
|
+
const SearchIconWidget$1 = "";
|
|
51
|
+
const root = "";
|
|
52
|
+
const Loading = "";
|
|
53
|
+
const ConfirmationPopup = "";
|
|
54
|
+
const InfoPopup = "";
|
|
55
|
+
const ToastNotification = "";
|
|
56
|
+
const Popover$1 = "";
|
|
57
|
+
const Popover = ({
|
|
58
|
+
trigger,
|
|
59
|
+
content,
|
|
60
|
+
isOpen,
|
|
61
|
+
setIsOpen,
|
|
62
|
+
hideCloseIcon,
|
|
63
|
+
align,
|
|
64
|
+
className,
|
|
65
|
+
withOpenState = true,
|
|
66
|
+
withArrow = true,
|
|
67
|
+
customArrow = "",
|
|
68
|
+
sideOffset = 5,
|
|
69
|
+
alignOffset = 0
|
|
70
|
+
}) => {
|
|
71
|
+
const [open, setOpen] = React__default.useState(withOpenState ? isOpen : false);
|
|
72
|
+
React__default.useEffect(() => {
|
|
73
|
+
var _a;
|
|
74
|
+
let arrowElement = (_a = document == null ? void 0 : document.querySelector(".PopoverArrow")) == null ? void 0 : _a.parentElement;
|
|
75
|
+
if (arrowElement && (customArrow == null ? void 0 : customArrow.length)) {
|
|
76
|
+
arrowElement.style.display = "inline-flex";
|
|
77
|
+
arrowElement.innerHTML = customArrow;
|
|
78
|
+
}
|
|
79
|
+
}, [open]);
|
|
80
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
81
|
+
$cb5cc270b50c6fcd$export$be92b6f5f03c0fe9,
|
|
82
|
+
{
|
|
83
|
+
...withOpenState && {
|
|
84
|
+
open: isOpen
|
|
85
|
+
},
|
|
86
|
+
...setIsOpen && {
|
|
87
|
+
onOpenChange: (open2) => {
|
|
88
|
+
setOpen(open2);
|
|
89
|
+
setIsOpen(open2);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cb5cc270b50c6fcd$export$41fb9f06171c75f4, { asChild: true, children: trigger }),
|
|
94
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cb5cc270b50c6fcd$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
95
|
+
$cb5cc270b50c6fcd$export$7c6e2c02157bb7d2,
|
|
96
|
+
{
|
|
97
|
+
className: `sledge__popover-content ${className ? className : ""}`,
|
|
98
|
+
sideOffset,
|
|
99
|
+
alignOffset,
|
|
100
|
+
align,
|
|
101
|
+
...setIsOpen && {
|
|
102
|
+
onOpenAutoFocus: () => setIsOpen(true),
|
|
103
|
+
onCloseAutoFocus: () => setIsOpen(false)
|
|
104
|
+
},
|
|
105
|
+
children: [
|
|
106
|
+
content,
|
|
107
|
+
!hideCloseIcon && /* @__PURE__ */ jsxRuntimeExports.jsx($cb5cc270b50c6fcd$export$f39c2d165cd861fe, { className: "PopoverClose", "aria-label": "Close", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
108
|
+
"path",
|
|
109
|
+
{
|
|
110
|
+
d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
|
|
111
|
+
fill: "currentColor",
|
|
112
|
+
fillRule: "evenodd",
|
|
113
|
+
clipRule: "evenodd"
|
|
114
|
+
}
|
|
115
|
+
) }) }),
|
|
116
|
+
withArrow ? /* @__PURE__ */ jsxRuntimeExports.jsx($cb5cc270b50c6fcd$export$21b07c8f274aebd5, { className: "PopoverArrow" }) : null
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
) })
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
const Progress$1 = "";
|
|
125
|
+
const Progress = ({ value, total, fillColor = "", outlineColor = "" }) => {
|
|
126
|
+
const [progress, setProgress] = React__default.useState(0);
|
|
127
|
+
React__default.useEffect(() => {
|
|
128
|
+
const timer = setTimeout(() => setProgress(+value / total * 100), 150);
|
|
129
|
+
return () => clearTimeout(timer);
|
|
130
|
+
}, []);
|
|
131
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
132
|
+
$67824d98245208a0$export$be92b6f5f03c0fe9,
|
|
133
|
+
{
|
|
134
|
+
className: "sledge__progress",
|
|
135
|
+
value: progress,
|
|
136
|
+
style: outlineColor ? {
|
|
137
|
+
borderWidth: "1px",
|
|
138
|
+
borderStyle: "solid",
|
|
139
|
+
borderColor: outlineColor
|
|
140
|
+
} : {},
|
|
141
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
142
|
+
$67824d98245208a0$export$adb584737d712b70,
|
|
143
|
+
{
|
|
144
|
+
className: "ProgressIndicator",
|
|
145
|
+
style: {
|
|
146
|
+
...{ transform: `translateX(-${100 - progress}%)` },
|
|
147
|
+
...fillColor && {
|
|
148
|
+
backgroundColor: fillColor
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
const Checkbox$1 = "";
|
|
157
|
+
const Checkbox = ({ id, name, value, required, label, defaultChecked, labelStyle = {}, onClick }) => {
|
|
158
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__checkbox-wrapper", children: [
|
|
159
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($e698a72e93240346$export$be92b6f5f03c0fe9, { className: "sledge__checkbox-root", defaultChecked, id, name, value, required, onClick, children: /* @__PURE__ */ jsxRuntimeExports.jsx($e698a72e93240346$export$adb584737d712b70, { className: "sledge__checkbox-indicator", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 10, height: 8, viewBox: "0 0 10 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
160
|
+
"path",
|
|
161
|
+
{
|
|
162
|
+
fillRule: "evenodd",
|
|
163
|
+
clipRule: "evenodd",
|
|
164
|
+
d: "M9.72318 0.237414C10.0707 0.574491 10.0942 1.14584 9.77561 1.51356L4.40976 7.70711C4.25243 7.88871 4.03181 7.99443 3.79903 7.99979C3.56625 8.00514 3.3415 7.90965 3.17686 7.73545L0.250031 4.63868C-0.0833435 4.28595 -0.0833435 3.71406 0.250031 3.36133C0.583405 3.00859 1.12391 3.00859 1.45729 3.36133L3.75367 5.79105L8.51706 0.292899C8.83564 -0.0748211 9.37564 -0.0996624 9.72318 0.237414Z",
|
|
165
|
+
fill: "white"
|
|
166
|
+
}
|
|
167
|
+
) }) }) }),
|
|
168
|
+
label && /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "sledge__checkbox-label", htmlFor: id, style: labelStyle, children: label })
|
|
169
|
+
] });
|
|
170
|
+
};
|
|
171
|
+
const Slider$1 = "";
|
|
172
|
+
const Slider = (props) => {
|
|
173
|
+
const { defaultValue, min, max, step = 1, setValueCommit, setValueChange } = props;
|
|
174
|
+
const [value, setValue] = React__default.useState(defaultValue);
|
|
175
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("form", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
176
|
+
$faa2e61a3361514f$export$be92b6f5f03c0fe9,
|
|
177
|
+
{
|
|
178
|
+
className: "sledge__SliderRoot",
|
|
179
|
+
defaultValue,
|
|
180
|
+
min,
|
|
181
|
+
max,
|
|
182
|
+
step,
|
|
183
|
+
"aria-label": "Volume",
|
|
184
|
+
onValueCommit: (valueCommit) => {
|
|
185
|
+
setValueCommit && setValueCommit(valueCommit);
|
|
186
|
+
setValue(valueCommit);
|
|
187
|
+
},
|
|
188
|
+
onValueChange: (valueChange) => {
|
|
189
|
+
setValueChange && setValueChange(valueChange);
|
|
190
|
+
setValue(valueChange);
|
|
191
|
+
},
|
|
192
|
+
children: [
|
|
193
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$13921ac0cc260818, { className: "sledge__SliderTrack", children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$9a58ef0d7ad3278c, { className: "sledge__SliderRange" }) }),
|
|
194
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
195
|
+
Tooltip,
|
|
196
|
+
{
|
|
197
|
+
content: value[0],
|
|
198
|
+
customArrow: `<svg width="19" height="5" viewBox="0 0 19 5" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 4.99998C9 9.48298e-05 16.4996 1.99678e-05 18.4999 0L9 2.2985e-06L0.5 2.04891e-06C9 2.2985e-06 9 4.99998 9 4.99998Z" fill="#23BC45"/></svg>`,
|
|
199
|
+
wrapTrigger: false,
|
|
200
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb" })
|
|
201
|
+
}
|
|
202
|
+
),
|
|
203
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
204
|
+
Tooltip,
|
|
205
|
+
{
|
|
206
|
+
content: value[1],
|
|
207
|
+
customArrow: `<svg width="19" height="5" viewBox="0 0 19 5" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 4.99998C9 9.48298e-05 16.4996 1.99678e-05 18.4999 0L9 2.2985e-06L0.5 2.04891e-06C9 2.2985e-06 9 4.99998 9 4.99998Z" fill="#23BC45"/></svg>`,
|
|
208
|
+
wrapTrigger: false,
|
|
209
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx($faa2e61a3361514f$export$6521433ed15a34db, { className: "sledge__SliderThumb" })
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
) });
|
|
215
|
+
};
|
|
216
|
+
const Pagination$1 = "";
|
|
217
|
+
const Pagination = ({ currentPage, totalPage, totalResult, onChange }) => {
|
|
218
|
+
const isDisabledPreviousPage = currentPage === 1;
|
|
219
|
+
const isDisabledNextPage = currentPage === totalPage;
|
|
220
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__pagination", children: [
|
|
221
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
222
|
+
"button",
|
|
223
|
+
{
|
|
224
|
+
type: "button",
|
|
225
|
+
className: "sledge__pagination-navigation",
|
|
226
|
+
...isDisabledPreviousPage ? {
|
|
227
|
+
disabled: true
|
|
228
|
+
} : {
|
|
229
|
+
onClick: () => onChange(currentPage - 1)
|
|
230
|
+
},
|
|
231
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowLeftIcon, { width: 17, height: 17, color: "black" })
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
235
|
+
"Page ",
|
|
236
|
+
currentPage,
|
|
237
|
+
" of ",
|
|
238
|
+
totalPage,
|
|
239
|
+
" - total ",
|
|
240
|
+
totalResult,
|
|
241
|
+
" result"
|
|
242
|
+
] }),
|
|
243
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
244
|
+
"button",
|
|
245
|
+
{
|
|
246
|
+
type: "button",
|
|
247
|
+
className: "sledge__pagination-navigation",
|
|
248
|
+
...isDisabledNextPage ? {
|
|
249
|
+
disabled: true
|
|
250
|
+
} : {
|
|
251
|
+
onClick: () => onChange(currentPage + 1)
|
|
252
|
+
},
|
|
253
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowRightIcon, { width: 17, height: 17, color: "black" })
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
] });
|
|
257
|
+
};
|
|
258
|
+
const RadioGroup$1 = "";
|
|
259
|
+
const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {}, onValueChange }) => {
|
|
260
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("form", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
261
|
+
$f99a8c78507165f7$export$be92b6f5f03c0fe9,
|
|
262
|
+
{
|
|
263
|
+
className: "sledge__radio-group-root",
|
|
264
|
+
"aria-label": "View density",
|
|
265
|
+
defaultValue,
|
|
266
|
+
id,
|
|
267
|
+
name,
|
|
268
|
+
required,
|
|
269
|
+
onValueChange,
|
|
270
|
+
children: items.map((item, index) => {
|
|
271
|
+
const { label, value } = item;
|
|
272
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__radio-group-item-flex", children: [
|
|
273
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($f99a8c78507165f7$export$6d08773d2e66f8f2, { className: "sledge__radio-group-item", value, id: `${id}${index}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx($f99a8c78507165f7$export$adb584737d712b70, { className: "sledge__radio-group-indicator" }) }),
|
|
274
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "sledge__radio-group-label", htmlFor: `${id}${index}`, style: labelStyle, children: label })
|
|
275
|
+
] }, index);
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
) }) });
|
|
279
|
+
};
|
|
280
|
+
const ColorSwatch$1 = "";
|
|
281
|
+
const ColorSwatch = ({ id, name, value, rgb, image, required, defaultChecked, onClick }) => {
|
|
282
|
+
const styles = {
|
|
283
|
+
...(image == null ? void 0 : image.length) ? {
|
|
284
|
+
backgroundImage: `url(${image})`
|
|
285
|
+
} : {
|
|
286
|
+
backgroundColor: rgb
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__color-swatch-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
290
|
+
$e698a72e93240346$export$be92b6f5f03c0fe9,
|
|
291
|
+
{
|
|
292
|
+
className: "sledge__color-swatch-root",
|
|
293
|
+
defaultChecked,
|
|
294
|
+
id,
|
|
295
|
+
name,
|
|
296
|
+
value,
|
|
297
|
+
required,
|
|
298
|
+
onClick,
|
|
299
|
+
style: styles
|
|
300
|
+
}
|
|
301
|
+
) });
|
|
302
|
+
};
|
|
303
|
+
const Select$1 = "";
|
|
304
|
+
const Select = ({ name, placeholder, required, defaultValue, items, labelStyle = {}, onValueChange }) => {
|
|
305
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__select-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsxs($cc7e05a45900e73f$export$be92b6f5f03c0fe9, { name, required, onValueChange, children: [
|
|
306
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs($cc7e05a45900e73f$export$41fb9f06171c75f4, { className: "sledge__select-trigger", children: [
|
|
307
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$4c8d1a57a761ef94, { placeholder }),
|
|
308
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$f04a61298a47a40f, { className: "sledge__select-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
309
|
+
"path",
|
|
310
|
+
{
|
|
311
|
+
d: "M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",
|
|
312
|
+
fill: "currentColor",
|
|
313
|
+
fillRule: "evenodd",
|
|
314
|
+
clipRule: "evenodd"
|
|
315
|
+
}
|
|
316
|
+
) }) })
|
|
317
|
+
] }),
|
|
318
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs($cc7e05a45900e73f$export$7c6e2c02157bb7d2, { className: "sledge__select-content", children: [
|
|
319
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$2f60d3ec9ad468f2, { className: "sledge__select-scroll-button", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
320
|
+
"path",
|
|
321
|
+
{
|
|
322
|
+
d: "M3.13523 8.84197C3.3241 9.04343 3.64052 9.05363 3.84197 8.86477L7.5 5.43536L11.158 8.86477C11.3595 9.05363 11.6759 9.04343 11.8648 8.84197C12.0536 8.64051 12.0434 8.32409 11.842 8.13523L7.84197 4.38523C7.64964 4.20492 7.35036 4.20492 7.15803 4.38523L3.15803 8.13523C2.95657 8.32409 2.94637 8.64051 3.13523 8.84197Z",
|
|
323
|
+
fill: "currentColor",
|
|
324
|
+
fillRule: "evenodd",
|
|
325
|
+
clipRule: "evenodd"
|
|
326
|
+
}
|
|
327
|
+
) }) }),
|
|
328
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$d5c6c08dc2d3ca7, { className: "sledge__select-viewport", children: items.map(
|
|
329
|
+
(item, index) => {
|
|
330
|
+
const { label, value } = item;
|
|
331
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItemComponent, { value, children: label }, index);
|
|
332
|
+
}
|
|
333
|
+
) }),
|
|
334
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$bf1aedc3039c8d63, { className: "sledge__select-scroll-button", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
335
|
+
"path",
|
|
336
|
+
{
|
|
337
|
+
d: "M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",
|
|
338
|
+
fill: "currentColor",
|
|
339
|
+
fillRule: "evenodd",
|
|
340
|
+
clipRule: "evenodd"
|
|
341
|
+
}
|
|
342
|
+
) }) })
|
|
343
|
+
] }) })
|
|
344
|
+
] }) });
|
|
345
|
+
};
|
|
346
|
+
const SelectItemComponent = React__default.forwardRef(({ children, className = "", ...props }, forwardedRef) => {
|
|
347
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs($cc7e05a45900e73f$export$6d08773d2e66f8f2, { className: `sledge__select-item ${className}`, ...props, ref: forwardedRef, children: [
|
|
348
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$d6e5bf9c43ea9319, { children }),
|
|
349
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$c3468e2714d175fa, { className: "sledge__select-item-indicator", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
350
|
+
"path",
|
|
351
|
+
{
|
|
352
|
+
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
|
353
|
+
fill: "currentColor",
|
|
354
|
+
fillRule: "evenodd",
|
|
355
|
+
clipRule: "evenodd"
|
|
356
|
+
}
|
|
357
|
+
) }) })
|
|
358
|
+
] });
|
|
359
|
+
});
|
|
360
|
+
const HeartIcon = ({ width, height, type, color }) => {
|
|
361
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-icon__heart", children: type === "outline" ? /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width, height, id: "sledge-icon-heart-line", viewBox: "0 0 18 17", fill: color, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
362
|
+
"path",
|
|
363
|
+
{
|
|
364
|
+
fillRule: "evenodd",
|
|
365
|
+
clipRule: "evenodd",
|
|
366
|
+
d: "M9.19515 0.86581C10.5501 0.00914308 12.3501 -0.227524 13.9051 0.27081C17.2876 1.36164 18.3376 5.04914 17.3985 7.98331C15.9493 12.5916 9.76015 16.0291 9.49765 16.1733C9.40431 16.225 9.30098 16.2508 9.19765 16.2508C9.09431 16.2508 8.99181 16.2258 8.89848 16.175C8.63765 16.0325 2.49348 12.6458 0.995979 7.98414L0.995146 7.98331C0.0551462 5.04831 1.10181 1.35998 4.48098 0.27081C6.06765 -0.242524 7.79681 -0.0166903 9.19515 0.86581ZM4.86431 1.46081C2.13015 2.34248 1.44348 5.28331 2.18598 7.60248C3.35431 11.2375 7.97015 14.1766 9.19681 14.9041C10.4276 14.1691 15.0768 11.1975 16.2076 7.60581C16.9501 5.28414 16.261 2.34331 13.5226 1.46081C12.196 1.03498 10.6485 1.29414 9.58015 2.12081C9.35681 2.29248 9.04681 2.29581 8.82181 2.12581C7.69015 1.27498 6.21181 1.02581 4.86431 1.46081ZM12.7226 3.11573C13.8585 3.48323 14.6543 4.48906 14.7518 5.67823C14.7793 6.02239 14.5235 6.32406 14.1793 6.35156C14.1618 6.35323 14.1451 6.35406 14.1276 6.35406C13.8051 6.35406 13.5318 6.10656 13.5051 5.77989C13.4501 5.09489 12.9918 4.51656 12.3393 4.30573C12.0101 4.19906 11.8301 3.84656 11.936 3.51906C12.0435 3.19073 12.3926 3.01239 12.7226 3.11573Z"
|
|
367
|
+
}
|
|
368
|
+
) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width, height, id: "sledge-icon-heart-fill", viewBox: "0 0 18 17", fill: color, children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M5.89936 0.0838691C6.42436 0.0998355 6.9327 0.191502 7.4252 0.359002H7.47436C7.5077 0.374836 7.5327 0.392336 7.54936 0.408169C7.73353 0.467336 7.9077 0.534002 8.07436 0.625669L8.39103 0.767336C8.51603 0.834002 8.66603 0.958169 8.74936 1.009C8.8327 1.05817 8.92436 1.109 8.99936 1.1665C9.9252 0.459002 11.0494 0.0756688 12.2077 0.0838691C12.7335 0.0838691 13.2585 0.158169 13.7577 0.325669C16.8335 1.32567 17.9419 4.70067 17.016 7.65067C16.491 9.15817 15.6327 10.534 14.5085 11.6582C12.8994 13.2165 11.1335 14.5998 9.2327 15.7915L9.02436 15.9173L8.8077 15.7832C6.9002 14.5998 5.12436 13.2165 3.5002 11.6498C2.38353 10.5257 1.52436 9.15817 0.991029 7.65067C0.0493627 4.70067 1.1577 1.32567 4.26686 0.308169C4.50853 0.224836 4.7577 0.166502 5.0077 0.134002H5.1077C5.34186 0.0998355 5.57436 0.0838691 5.8077 0.0838691H5.89936ZM13.3244 2.71734C12.9827 2.59984 12.6077 2.784 12.4827 3.134C12.366 3.484 12.5494 3.86734 12.8994 3.9915C13.4335 4.1915 13.791 4.71734 13.791 5.29984V5.32567C13.7752 5.5165 13.8327 5.70067 13.9494 5.84234C14.066 5.984 14.241 6.0665 14.4244 6.084C14.766 6.07484 15.0577 5.80067 15.0827 5.44984V5.35067C15.1077 4.18317 14.4002 3.12567 13.3244 2.71734Z" }) }) });
|
|
369
|
+
};
|
|
370
|
+
const ChevronArrowDownIcon = ({ width, height, color }) => {
|
|
371
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-icon__arrow-down", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width, height, viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx("g", { id: "Arrow - Down 2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("g", { id: "Iconly/Light-Outline/Arrow---Down-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("g", { id: "Arrow---Down-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
372
|
+
"path",
|
|
373
|
+
{
|
|
374
|
+
id: "Stroke-1",
|
|
375
|
+
d: "M3.72407 6.6414C3.94596 6.41951 4.29318 6.39934 4.53786 6.58089L4.60796 6.6414L9.99935 12.0325L15.3907 6.6414C15.6126 6.41951 15.9598 6.39934 16.2045 6.58089L16.2746 6.6414C16.4965 6.86329 16.5167 7.21051 16.3351 7.45519L16.2746 7.52529L10.4413 13.3586C10.2194 13.5805 9.87218 13.6007 9.62751 13.4191L9.55741 13.3586L3.72407 7.52529C3.48 7.28121 3.48 6.88548 3.72407 6.6414Z",
|
|
376
|
+
fill: color
|
|
377
|
+
}
|
|
378
|
+
) }) }) }) }) });
|
|
379
|
+
};
|
|
380
|
+
const ChevronArrowLeftIcon = ({ width, height, color }) => {
|
|
381
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-icon__arrow-left", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width, height, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
382
|
+
"path",
|
|
383
|
+
{
|
|
384
|
+
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",
|
|
385
|
+
fill: color
|
|
386
|
+
}
|
|
387
|
+
) }) });
|
|
388
|
+
};
|
|
389
|
+
const ChevronArrowRightIcon = ({ width, height, color }) => {
|
|
390
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-icon__arrow-right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width, height, viewBox: "0 0 17 17", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
391
|
+
"path",
|
|
392
|
+
{
|
|
393
|
+
d: "M5.60738 13.1302C5.42987 12.9527 5.41374 12.675 5.55897 12.4792L5.60738 12.4231L9.92027 8.11002L5.60738 3.79691C5.42987 3.6194 5.41374 3.34162 5.55897 3.14588L5.60738 3.0898C5.7849 2.91229 6.06267 2.89615 6.25841 3.04139L6.31449 3.0898L10.9812 7.75647C11.1587 7.93398 11.1748 8.21175 11.0296 8.4075L10.9812 8.46357L6.31449 13.1302C6.11923 13.3255 5.80265 13.3255 5.60738 13.1302Z",
|
|
394
|
+
fill: color
|
|
395
|
+
}
|
|
396
|
+
) }) });
|
|
397
|
+
};
|
|
398
|
+
const BagIcon = ({ width, height, color }) => {
|
|
399
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-icon__bag", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width, height, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
400
|
+
"path",
|
|
401
|
+
{
|
|
402
|
+
fillRule: "evenodd",
|
|
403
|
+
clipRule: "evenodd",
|
|
404
|
+
d: "M19.6334 3.33398C23.9899 3.33398 27.5887 6.65342 28.0324 10.8989L28.1562 10.9003C30.5729 10.9003 33.5112 12.5053 34.5029 17.007L35.8179 27.1853C36.2896 30.4703 35.6996 33.1053 34.0612 34.9953C32.4312 36.8753 29.8512 37.8703 26.5996 37.8703H12.6862C9.11458 37.8703 6.62625 36.9953 5.07792 35.197C3.52292 33.3936 3.00292 30.6886 3.53292 27.1586L4.82625 17.1153C5.67625 12.5103 8.78458 10.9003 11.1912 10.9003C11.399 8.98444 12.2629 7.16182 13.6334 5.79565C15.2084 4.23065 17.3801 3.33398 19.5984 3.33398H19.6334ZM28.1562 13.4003H11.1912C10.4562 13.4003 7.99958 13.697 7.29458 17.5036L6.00792 27.5036C5.58958 30.3086 5.91292 32.3386 6.97125 33.567C8.01625 34.7803 9.88625 35.3703 12.6862 35.3703H26.5996C28.3462 35.3703 30.7312 35.022 32.1712 33.3586C33.3146 32.0403 33.7079 30.077 33.3412 27.522L32.0429 17.4353C31.4896 14.9503 30.0296 13.4003 28.1562 13.4003ZM24.4942 18.0405C25.1842 18.0405 25.7826 18.6005 25.7826 19.2905C25.7826 19.9805 25.2609 20.5405 24.5709 20.5405H24.4942C23.8042 20.5405 23.2442 19.9805 23.2442 19.2905C23.2442 18.6005 23.8042 18.0405 24.4942 18.0405ZM14.7774 18.0405C15.4674 18.0405 16.0657 18.6005 16.0657 19.2905C16.0657 19.9805 15.5424 20.5405 14.8524 20.5405H14.7774C14.0874 20.5405 13.5274 19.9805 13.5274 19.2905C13.5274 18.6005 14.0874 18.0405 14.7774 18.0405ZM19.6284 5.83398H19.6034C18.0351 5.83398 16.5067 6.46565 15.3984 7.56732C14.4956 8.46609 13.9051 9.64764 13.7141 10.8995L25.5129 10.9C25.0846 8.03628 22.6082 5.83398 19.6284 5.83398Z",
|
|
405
|
+
fill: color
|
|
406
|
+
}
|
|
407
|
+
) }) });
|
|
408
|
+
};
|
|
409
|
+
const SearchIcon = ({ width, height, color }) => {
|
|
410
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-icon__search", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width, height, viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
411
|
+
"path",
|
|
412
|
+
{
|
|
413
|
+
fillRule: "evenodd",
|
|
414
|
+
clipRule: "evenodd",
|
|
415
|
+
d: "M9.78283 2.16669C14.2578 2.16669 17.8978 5.80669 17.8978 10.2817C17.8978 12.393 17.0876 14.3186 15.7617 15.7638L18.3707 18.3673C18.6148 18.6114 18.6157 19.0064 18.3715 19.2506C18.2498 19.3739 18.089 19.4348 17.929 19.4348C17.7698 19.4348 17.6098 19.3739 17.4873 19.2523L14.8469 16.6192C13.4579 17.7316 11.6967 18.3975 9.78283 18.3975C5.30783 18.3975 1.66699 14.7567 1.66699 10.2817C1.66699 5.80669 5.30783 2.16669 9.78283 2.16669ZM9.78283 3.41669C5.99699 3.41669 2.91699 6.49585 2.91699 10.2817C2.91699 14.0675 5.99699 17.1475 9.78283 17.1475C13.5678 17.1475 16.6478 14.0675 16.6478 10.2817C16.6478 6.49585 13.5678 3.41669 9.78283 3.41669Z",
|
|
416
|
+
fill: color
|
|
417
|
+
}
|
|
418
|
+
) }) });
|
|
419
|
+
};
|
|
420
|
+
const Button$1 = "";
|
|
421
|
+
const Button = React__default.forwardRef((props, buttonRef) => {
|
|
422
|
+
const { className = "", children, colorType = "light", fullWidth = false, elementType = "button", link = "", ...otherProps } = props;
|
|
423
|
+
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("button", { className: `sledge__button ${className || ""}`, "data-button-color-type": colorType, "data-button-full-width": fullWidth, ref: buttonRef, ...otherProps, children });
|
|
424
|
+
});
|
|
425
|
+
const SearchInputField$1 = "";
|
|
426
|
+
const SearchInputField = (props) => {
|
|
427
|
+
const { className = "", icon, value = "", withClearField, onChange, onResetField, fieldRef, ...otherProps } = props;
|
|
428
|
+
const [isVisibleClearField, setIsVisibleClearField] = React__default.useState(false);
|
|
429
|
+
const handleResetField = () => {
|
|
430
|
+
(fieldRef == null ? void 0 : fieldRef.current) && fieldRef.current.focus();
|
|
431
|
+
onChange && onChange({ value: "" });
|
|
432
|
+
onResetField && onResetField();
|
|
433
|
+
};
|
|
434
|
+
const handleChangeField = (e) => {
|
|
435
|
+
onChange && onChange({ value: e.target.value });
|
|
436
|
+
};
|
|
437
|
+
React__default.useEffect(() => {
|
|
438
|
+
setIsVisibleClearField(Boolean(value));
|
|
439
|
+
}, [value]);
|
|
440
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `sledge__search-input-field-wrapper ${className || ""}`, children: [
|
|
441
|
+
!icon ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__search-input-field-icon", children: icon }),
|
|
442
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("input", { className: "sledge__search-input-field", value, onChange: (e) => handleChangeField(e), ref: fieldRef, ...otherProps }),
|
|
443
|
+
isVisibleClearField && withClearField ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__clear-field-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "sledge__clear-field", type: "button", onClick: handleResetField, children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { viewBox: "0 0 20 20", focusable: "false", "aria-hidden": "true", width: 14, height: 14, children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "m11.414 10 6.293-6.293a1 1 0 1 0-1.414-1.414l-6.293 6.293-6.293-6.293a1 1 0 0 0-1.414 1.414l6.293 6.293-6.293 6.293a1 1 0 1 0 1.414 1.414l6.293-6.293 6.293 6.293a.998.998 0 0 0 1.707-.707.999.999 0 0 0-.293-.707l-6.293-6.293z" }) }) }) }) : null
|
|
444
|
+
] });
|
|
445
|
+
};
|
|
446
|
+
const SelectField$1 = "";
|
|
447
|
+
const SelectField = (props) => {
|
|
448
|
+
var _a;
|
|
449
|
+
const { className = "", placeholder = null, prefixLabel = null, prefixSelectedLabel = "", align = "end", onChange, value = "", options = [] } = props;
|
|
450
|
+
const [isOpen, setIsOpen] = React__default.useState(false);
|
|
451
|
+
const handleChangeField = (label, value2) => {
|
|
452
|
+
onChange && onChange({ label, value: value2 });
|
|
453
|
+
setIsOpen(false);
|
|
454
|
+
};
|
|
455
|
+
const selectedLabel = ((_a = options == null ? void 0 : options.filter(({ value: optionValue }) => optionValue === value)[0]) == null ? void 0 : _a.label) || placeholder;
|
|
456
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__select-field-wrapper ${className || ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
457
|
+
Popover,
|
|
458
|
+
{
|
|
459
|
+
trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { type: "button", className: "sledge__button sledge__select-field", "data-button-color-type": "light", "data-button-full-width": "true", children: [
|
|
460
|
+
!prefixLabel ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge__select-field-icon", children: prefixLabel }),
|
|
461
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (prefixSelectedLabel == null ? void 0 : prefixSelectedLabel.length) ? `${prefixSelectedLabel} ${selectedLabel}` : selectedLabel })
|
|
462
|
+
] }),
|
|
463
|
+
content: /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge__select-field-option", children: options == null ? void 0 : options.map((option, index) => {
|
|
464
|
+
const { label, value: optionValue } = option;
|
|
465
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
466
|
+
"li",
|
|
467
|
+
{
|
|
468
|
+
onClick: () => handleChangeField(label, optionValue),
|
|
469
|
+
...optionValue === value && {
|
|
470
|
+
["data-selected"]: true
|
|
471
|
+
},
|
|
472
|
+
children: label
|
|
473
|
+
},
|
|
474
|
+
index
|
|
475
|
+
);
|
|
476
|
+
}) }),
|
|
477
|
+
isOpen,
|
|
478
|
+
setIsOpen,
|
|
479
|
+
hideCloseIcon: true,
|
|
480
|
+
align,
|
|
481
|
+
className: "sledge__select-field-option-content",
|
|
482
|
+
withArrow: false
|
|
483
|
+
}
|
|
484
|
+
) });
|
|
485
|
+
};
|
|
486
|
+
const ProductGrid$1 = "";
|
|
487
|
+
const addToCart = async (data) => {
|
|
488
|
+
var _a;
|
|
489
|
+
var myHeaders = new Headers();
|
|
490
|
+
myHeaders.append("Content-Type", "application/json");
|
|
491
|
+
let items = [];
|
|
492
|
+
data.map((item) => {
|
|
493
|
+
const { id, quantity } = item;
|
|
494
|
+
items.push({
|
|
495
|
+
id,
|
|
496
|
+
quantity
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
var raw = JSON.stringify({
|
|
500
|
+
items
|
|
501
|
+
});
|
|
502
|
+
var requestOptions = {
|
|
503
|
+
method: "POST",
|
|
504
|
+
headers: myHeaders,
|
|
505
|
+
body: raw,
|
|
506
|
+
redirect: "follow"
|
|
507
|
+
};
|
|
508
|
+
if (!((_a = window == null ? void 0 : window.Shopify) == null ? void 0 : _a.routes))
|
|
509
|
+
return;
|
|
510
|
+
return await fetch(`${window.Shopify.routes.root}cart/add.js`, requestOptions).then((response) => response.json()).then((result) => {
|
|
511
|
+
return result;
|
|
512
|
+
}).catch(() => {
|
|
513
|
+
return;
|
|
514
|
+
});
|
|
515
|
+
};
|
|
516
|
+
const Badge = "";
|
|
517
|
+
const addWishlist = async (data) => {
|
|
518
|
+
const { productId, productVariantId, productName, productVendor, productSku, productVariantName, productLink, productImage, productCurrency, productPrice } = data;
|
|
519
|
+
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
520
|
+
var myHeaders = new Headers();
|
|
521
|
+
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
522
|
+
myHeaders.append("Content-Type", "application/json");
|
|
523
|
+
var raw = JSON.stringify({
|
|
524
|
+
product: {
|
|
525
|
+
id: sanitizeDataId(productId),
|
|
526
|
+
variant_id: sanitizeDataId(productVariantId),
|
|
527
|
+
name: productName,
|
|
528
|
+
vendor: productVendor,
|
|
529
|
+
sku: productSku,
|
|
530
|
+
variant_name: productVariantName,
|
|
531
|
+
url: productLink,
|
|
532
|
+
image_url: productImage,
|
|
533
|
+
currency: productCurrency,
|
|
534
|
+
price: productPrice
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
var requestOptions = {
|
|
538
|
+
method: "POST",
|
|
539
|
+
headers: myHeaders,
|
|
540
|
+
body: raw,
|
|
541
|
+
redirect: "follow"
|
|
542
|
+
};
|
|
543
|
+
return await fetch(`${API_URL}/wishlist`, requestOptions).then((response) => response.json()).then((result) => {
|
|
544
|
+
return result;
|
|
545
|
+
}).catch(() => {
|
|
546
|
+
return;
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
const bulkAddWishlist = async (data) => {
|
|
550
|
+
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
551
|
+
var myHeaders = new Headers();
|
|
552
|
+
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
553
|
+
myHeaders.append("Content-Type", "application/json");
|
|
554
|
+
let products = data.map((item) => {
|
|
555
|
+
const { productId, productVariantId, productName, productVariantName, productLink, productImage, productCurrency, productPrice } = item;
|
|
556
|
+
return {
|
|
557
|
+
id: sanitizeDataId(productId),
|
|
558
|
+
variant_id: sanitizeDataId(productVariantId),
|
|
559
|
+
name: productName,
|
|
560
|
+
variant_name: productVariantName,
|
|
561
|
+
url: productLink,
|
|
562
|
+
image_url: productImage,
|
|
563
|
+
currency: productCurrency,
|
|
564
|
+
price: productPrice
|
|
565
|
+
};
|
|
566
|
+
});
|
|
567
|
+
var raw = JSON.stringify({
|
|
568
|
+
products
|
|
569
|
+
});
|
|
570
|
+
var requestOptions = {
|
|
571
|
+
method: "POST",
|
|
572
|
+
headers: myHeaders,
|
|
573
|
+
body: raw,
|
|
574
|
+
redirect: "follow"
|
|
575
|
+
};
|
|
576
|
+
return await fetch(`${API_URL}/wishlist/bulk`, requestOptions).then((response) => response.json()).then((result) => {
|
|
577
|
+
return result;
|
|
578
|
+
}).catch(() => {
|
|
579
|
+
return;
|
|
580
|
+
});
|
|
581
|
+
};
|
|
582
|
+
const checkWishlist = async (id, variantId) => {
|
|
583
|
+
let convertId = sanitizeDataId(id);
|
|
584
|
+
let convertVariantId = variantId ? sanitizeDataId(variantId) : "";
|
|
585
|
+
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
586
|
+
let queryParams = "?" + new URLSearchParams({
|
|
587
|
+
variant_id: convertVariantId
|
|
588
|
+
}).toString();
|
|
589
|
+
var myHeaders = new Headers();
|
|
590
|
+
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
591
|
+
var requestOptions = {
|
|
592
|
+
method: "GET",
|
|
593
|
+
headers: myHeaders,
|
|
594
|
+
redirect: "follow"
|
|
595
|
+
};
|
|
596
|
+
return await fetch(`${API_URL}/wishlist/check/${convertId}${queryParams}`, requestOptions).then((response) => response.json()).then((result) => {
|
|
597
|
+
return Boolean(result.data);
|
|
598
|
+
}).catch(() => {
|
|
599
|
+
return;
|
|
600
|
+
});
|
|
601
|
+
};
|
|
602
|
+
const addToCartTrigger$1 = async (data) => {
|
|
603
|
+
const { productId } = data;
|
|
604
|
+
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
605
|
+
var myHeaders = new Headers();
|
|
606
|
+
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
607
|
+
myHeaders.append("Content-Type", "application/json");
|
|
608
|
+
var raw = JSON.stringify({
|
|
609
|
+
product: {
|
|
610
|
+
id: sanitizeDataId(productId)
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
var requestOptions = {
|
|
614
|
+
method: "POST",
|
|
615
|
+
headers: myHeaders,
|
|
616
|
+
body: raw,
|
|
617
|
+
redirect: "follow"
|
|
618
|
+
};
|
|
619
|
+
return await fetch(`${API_URL}/wishlist/cart`, requestOptions).then((response) => response.json()).then((result) => {
|
|
620
|
+
return result;
|
|
621
|
+
}).catch(() => {
|
|
622
|
+
return;
|
|
623
|
+
});
|
|
624
|
+
};
|
|
625
|
+
const ButtonDetail = "";
|
|
626
|
+
const Trigger$1 = "";
|
|
627
|
+
const Trigger = (props) => {
|
|
628
|
+
var _a, _b, _c;
|
|
629
|
+
const { data, forceActive, hidden, onAfterAddWishlist, onAfterRemoveWishlist } = props;
|
|
630
|
+
const { productId, productVariantId } = data || {};
|
|
631
|
+
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
632
|
+
const defaultColorIcon = "#767676";
|
|
633
|
+
const defaultTypeIcon = "outline";
|
|
634
|
+
const activeColorIcon = "#F85538";
|
|
635
|
+
const activeTypeIcon = "fill";
|
|
636
|
+
const [colorIcon, setColorIcon] = React__default.useState(defaultColorIcon);
|
|
637
|
+
const [typeIcon, setTypeIcon] = React__default.useState(defaultTypeIcon);
|
|
638
|
+
const [isWishlist, setIsWishlist] = React__default.useState(false);
|
|
639
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
640
|
+
const [dataSettings, setDataSettings] = React__default.useState({});
|
|
641
|
+
const [handleFunctions, _setHandleFunctions] = React__default.useState({
|
|
642
|
+
onAfterAddWishlist,
|
|
643
|
+
onAfterRemoveWishlist
|
|
644
|
+
});
|
|
645
|
+
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
646
|
+
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
647
|
+
const { show: show_notification, location: location_notification } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.notification) || {};
|
|
648
|
+
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) || {};
|
|
649
|
+
const handleCheckWishlist = async () => {
|
|
650
|
+
let response;
|
|
651
|
+
response = await checkWishlist(productId, productVariantId);
|
|
652
|
+
setIsWishlist(response);
|
|
653
|
+
};
|
|
654
|
+
const handleClick = async (e) => {
|
|
655
|
+
e.preventDefault();
|
|
656
|
+
e.stopPropagation();
|
|
657
|
+
if (isRequiredLogin) {
|
|
658
|
+
if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
|
|
659
|
+
window.sledgeConfirmationPopup({
|
|
660
|
+
title: "Login required!",
|
|
661
|
+
message: "Please login to save your wishlist across devices.",
|
|
662
|
+
textSubmit: "Login",
|
|
663
|
+
textCancel: "Cancel",
|
|
664
|
+
buttonSubmitType: "info",
|
|
665
|
+
onSubmit: () => window.location.href = "/account/login"
|
|
666
|
+
});
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
setIsWishlist(!isWishlist);
|
|
670
|
+
let resAddWishlist = await addWishlist(data);
|
|
671
|
+
const { status, data: response_data } = resAddWishlist || {};
|
|
672
|
+
const { code } = status || {};
|
|
673
|
+
if (code === 200) {
|
|
674
|
+
if (typeof window !== "undefined") {
|
|
675
|
+
if (window.sledgeWishlistBadgeUpdate)
|
|
676
|
+
window.sledgeWishlistBadgeUpdate();
|
|
677
|
+
if (window.sledgeWishlistWidgetListUpdate)
|
|
678
|
+
window.sledgeWishlistWidgetListUpdate();
|
|
679
|
+
if (window.sledgeWishlistButtonDetailUpdate)
|
|
680
|
+
window.sledgeWishlistButtonDetailUpdate();
|
|
681
|
+
}
|
|
682
|
+
handleCheckWishlist();
|
|
683
|
+
if (!isWishlist) {
|
|
684
|
+
handleFunctions.onAfterAddWishlist && handleFunctions.onAfterAddWishlist("success");
|
|
685
|
+
} else {
|
|
686
|
+
handleFunctions.onAfterRemoveWishlist && handleFunctions.onAfterRemoveWishlist("success");
|
|
687
|
+
}
|
|
688
|
+
if (typeof window !== "undefined" && window.sledgeToastNotification && show_notification)
|
|
689
|
+
window.sledgeToastNotification({
|
|
690
|
+
title: !isWishlist ? title_added_to_wishlist : title_removed_to_wishlist,
|
|
691
|
+
message: !isWishlist ? text_added_to_wishlist : text_removed_to_wishlist,
|
|
692
|
+
location: location_notification,
|
|
693
|
+
type: "success",
|
|
694
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 40, height: 40, color: "black", type: "outline" })
|
|
695
|
+
});
|
|
696
|
+
} else {
|
|
697
|
+
if (!isWishlist) {
|
|
698
|
+
handleFunctions.onAfterAddWishlist && handleFunctions.onAfterAddWishlist("failed");
|
|
699
|
+
} else {
|
|
700
|
+
handleFunctions.onAfterRemoveWishlist && handleFunctions.onAfterRemoveWishlist("failed");
|
|
701
|
+
}
|
|
702
|
+
if (typeof window !== "undefined" && window.sledgeToastNotification && show_notification)
|
|
703
|
+
window.sledgeToastNotification({
|
|
704
|
+
title: "Failed",
|
|
705
|
+
message: "failed add to wishlist",
|
|
706
|
+
location: location_notification,
|
|
707
|
+
type: "failed",
|
|
708
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 40, height: 40, color: "black", type: "outline" })
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
const handleSettings = async (LOCAL_STORAGE_WISHLIST_SETTING) => {
|
|
713
|
+
setIsLoading(true);
|
|
714
|
+
let response;
|
|
715
|
+
let run = false;
|
|
716
|
+
response = JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
|
|
717
|
+
if (!response)
|
|
718
|
+
return;
|
|
719
|
+
const { status, data: data2 } = response;
|
|
720
|
+
const { code } = status;
|
|
721
|
+
run = code === 200 || false;
|
|
722
|
+
if (run) {
|
|
723
|
+
setDataSettings(data2);
|
|
724
|
+
setIsLoading(false);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
React__default.useEffect(() => {
|
|
728
|
+
if (!(isRenderApp == null ? void 0 : isRenderApp.wishlist))
|
|
729
|
+
return;
|
|
730
|
+
if (typeof window !== "undefined") {
|
|
731
|
+
window.sledgeWishlistTriggerUpdate = () => {
|
|
732
|
+
handleCheckWishlist();
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
setIsRequiredLogin(localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) && is_required_login);
|
|
736
|
+
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || "");
|
|
737
|
+
}, [isRenderApp]);
|
|
738
|
+
React__default.useEffect(() => {
|
|
739
|
+
handleCheckWishlist();
|
|
740
|
+
}, [productVariantId]);
|
|
741
|
+
const isActive = (isWishlist || forceActive) && !isRequiredLogin;
|
|
742
|
+
React__default.useEffect(() => {
|
|
743
|
+
if (isActive) {
|
|
744
|
+
setColorIcon(activeColorIcon);
|
|
745
|
+
setTypeIcon(activeTypeIcon);
|
|
746
|
+
} else {
|
|
747
|
+
setColorIcon(defaultColorIcon);
|
|
748
|
+
setTypeIcon(defaultTypeIcon);
|
|
749
|
+
}
|
|
750
|
+
}, [isWishlist]);
|
|
751
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isLoading && !hidden && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__trigger-block", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
752
|
+
"span",
|
|
753
|
+
{
|
|
754
|
+
className: "sledge-wishlist__trigger",
|
|
755
|
+
onClick: (e) => handleClick(e),
|
|
756
|
+
onMouseEnter: () => {
|
|
757
|
+
if (isActive)
|
|
758
|
+
return;
|
|
759
|
+
setColorIcon(activeColorIcon);
|
|
760
|
+
setTypeIcon(activeTypeIcon);
|
|
761
|
+
},
|
|
762
|
+
onMouseLeave: () => {
|
|
763
|
+
if (isActive)
|
|
764
|
+
return;
|
|
765
|
+
setColorIcon(defaultColorIcon);
|
|
766
|
+
setTypeIcon(defaultTypeIcon);
|
|
767
|
+
},
|
|
768
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 16.67, height: 15.83, type: typeIcon, color: colorIcon })
|
|
769
|
+
}
|
|
770
|
+
) }) });
|
|
771
|
+
};
|
|
772
|
+
const Widget$1 = "";
|
|
773
|
+
const WidgetHeaderClearTrigger = ({ buttonText, shareId, dataSettings, isFirstLoading }) => {
|
|
774
|
+
var _a, _b, _c, _d, _e;
|
|
775
|
+
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
776
|
+
const {
|
|
777
|
+
text_color: display_button_clear_all_text_color,
|
|
778
|
+
border_color: display_button_clear_all_border_color,
|
|
779
|
+
border_radius: display_button_clear_all_border_radius,
|
|
780
|
+
padding_top: display_button_clear_all_padding_top,
|
|
781
|
+
padding_bottom: display_button_clear_all_padding_bottom,
|
|
782
|
+
padding_left: display_button_clear_all_padding_left,
|
|
783
|
+
padding_right: display_button_clear_all_padding_right,
|
|
784
|
+
background_color: display_button_clear_all_background_color,
|
|
785
|
+
font_size: display_button_clear_all_font_size,
|
|
786
|
+
font_weight: display_button_clear_all_font_weight,
|
|
787
|
+
text_transform: display_button_clear_all_text_transform
|
|
788
|
+
} = ((_c = (_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.widget) == null ? void 0 : _c.button_clear_all) || {};
|
|
789
|
+
const { title_confirm_clear_all_wishlist, text_confirm_clear_all_wishlist, button_submit_confirm_clear_all_wishlist, button_cancel_confirm_clear_all_wishlist } = ((_d = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _d.popup) || {};
|
|
790
|
+
const { button_clear_all } = ((_e = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _e.widget) || {};
|
|
791
|
+
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
792
|
+
const display_button_clear_all_style = {
|
|
793
|
+
...display_button_clear_all_text_color && { color: display_button_clear_all_text_color },
|
|
794
|
+
...display_button_clear_all_border_color && { borderColor: display_button_clear_all_border_color },
|
|
795
|
+
...display_button_clear_all_border_radius && { borderRadius: display_button_clear_all_border_radius },
|
|
796
|
+
...display_button_clear_all_padding_top && { paddingTop: display_button_clear_all_padding_top },
|
|
797
|
+
...display_button_clear_all_padding_bottom && { paddingBottom: display_button_clear_all_padding_bottom },
|
|
798
|
+
...display_button_clear_all_padding_left && { paddingLeft: display_button_clear_all_padding_left },
|
|
799
|
+
...display_button_clear_all_padding_right && { paddingRight: display_button_clear_all_padding_right },
|
|
800
|
+
...display_button_clear_all_background_color && { backgroundColor: display_button_clear_all_background_color },
|
|
801
|
+
...display_button_clear_all_font_size && { fontSize: display_button_clear_all_font_size },
|
|
802
|
+
...display_button_clear_all_font_weight && { fontWeight: display_button_clear_all_font_weight },
|
|
803
|
+
...display_button_clear_all_text_transform && { textTransform: display_button_clear_all_text_transform }
|
|
804
|
+
};
|
|
805
|
+
React__default.useEffect(() => {
|
|
806
|
+
setIsRequiredLogin(localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) && is_required_login);
|
|
807
|
+
}, []);
|
|
808
|
+
const handleClick = () => {
|
|
809
|
+
if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
|
|
810
|
+
window.sledgeConfirmationPopup({
|
|
811
|
+
title: title_confirm_clear_all_wishlist,
|
|
812
|
+
message: text_confirm_clear_all_wishlist,
|
|
813
|
+
textSubmit: button_submit_confirm_clear_all_wishlist,
|
|
814
|
+
textCancel: button_cancel_confirm_clear_all_wishlist,
|
|
815
|
+
buttonSubmitType: "danger",
|
|
816
|
+
onSubmit: window.sledgeWishlistWidgetClearList || {}
|
|
817
|
+
});
|
|
818
|
+
};
|
|
819
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isRequiredLogin && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !shareId && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "132px", height: "46px", color: "grey-100", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__widget-header-item", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "button", colorType: "danger", onClick: handleClick, style: display_button_clear_all_style, children: button_clear_all ? button_clear_all : buttonText || "Clear Wishlist" }) }) }) }) });
|
|
820
|
+
};
|
|
821
|
+
const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger, shareLink, shareId, dataSettings, isFirstLoading }) => {
|
|
822
|
+
var _a, _b, _c, _d, _e, _f;
|
|
823
|
+
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
824
|
+
const {
|
|
825
|
+
text_color: display_button_share_text_color,
|
|
826
|
+
border_color: display_button_share_border_color,
|
|
827
|
+
border_radius: display_button_share_border_radius,
|
|
828
|
+
padding_top: display_button_share_padding_top,
|
|
829
|
+
padding_bottom: display_button_share_padding_bottom,
|
|
830
|
+
padding_left: display_button_share_padding_left,
|
|
831
|
+
padding_right: display_button_share_padding_right,
|
|
832
|
+
background_color: display_button_share_background_color,
|
|
833
|
+
font_size: display_button_share_font_size,
|
|
834
|
+
font_weight: display_button_share_font_weight,
|
|
835
|
+
text_transform: display_button_share_text_transform
|
|
836
|
+
} = ((_c = (_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.widget) == null ? void 0 : _c.button_share) || {};
|
|
837
|
+
const { title_share_wishlist } = ((_d = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _d.popup) || {};
|
|
838
|
+
const { button_share } = ((_e = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _e.widget) || {};
|
|
839
|
+
const { title_added_all_to_wishlist, text_added_all_to_wishlist } = ((_f = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _f.notification) || {};
|
|
840
|
+
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
841
|
+
const display_button_share_style = {
|
|
842
|
+
...display_button_share_text_color && { color: display_button_share_text_color },
|
|
843
|
+
...display_button_share_border_color && { borderColor: display_button_share_border_color },
|
|
844
|
+
...display_button_share_border_radius && { borderRadius: display_button_share_border_radius },
|
|
845
|
+
...display_button_share_padding_top && { paddingTop: display_button_share_padding_top },
|
|
846
|
+
...display_button_share_padding_bottom && { paddingBottom: display_button_share_padding_bottom },
|
|
847
|
+
...display_button_share_padding_left && { paddingLeft: display_button_share_padding_left },
|
|
848
|
+
...display_button_share_padding_right && { paddingRight: display_button_share_padding_right },
|
|
849
|
+
...display_button_share_background_color && { backgroundColor: display_button_share_background_color },
|
|
850
|
+
...display_button_share_font_size && { fontSize: display_button_share_font_size },
|
|
851
|
+
...display_button_share_font_weight && { fontWeight: display_button_share_font_weight },
|
|
852
|
+
...display_button_share_text_transform && { textTransform: display_button_share_text_transform }
|
|
853
|
+
};
|
|
854
|
+
const [isLoadingBulkAdd, setIsLoadingBulkAdd] = React__default.useState(false);
|
|
855
|
+
let clipboardIcon = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
856
|
+
<path d="M15 17V20C15 20.2652 14.8946 20.5196 14.7071 20.7071C14.5196 20.8946 14.2652 21 14 21H4C3.73478 21 3.48043 20.8946 3.29289 20.7071C3.10536 20.5196 3 20.2652 3 20V8C3 7.73478 3.10536 7.48043 3.29289 7.29289C3.48043 7.10536 3.73478 7 4 7H7" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
857
|
+
<path d="M18 3H8C7.44772 3 7 3.44772 7 4V16C7 16.5523 7.44772 17 8 17H18C18.5523 17 19 16.5523 19 16V4C19 3.44772 18.5523 3 18 3Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
858
|
+
</svg>`;
|
|
859
|
+
let checkIcon = `<svg width="20" height="20" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`;
|
|
860
|
+
const handleBulkAddWishlist = async () => {
|
|
861
|
+
var _a2;
|
|
862
|
+
setIsLoadingBulkAdd(true);
|
|
863
|
+
let data = wishlistData.map((item) => {
|
|
864
|
+
const { id, variant_id, name, variant_name, url, image_url, currency, price } = item.product;
|
|
865
|
+
return {
|
|
866
|
+
productId: id,
|
|
867
|
+
productVariantId: variant_id,
|
|
868
|
+
productName: name,
|
|
869
|
+
productVariantName: variant_name,
|
|
870
|
+
productLink: url,
|
|
871
|
+
productImage: image_url,
|
|
872
|
+
productCurrency: currency,
|
|
873
|
+
productPrice: price
|
|
874
|
+
};
|
|
875
|
+
});
|
|
876
|
+
let resBulkAddWishlist = await bulkAddWishlist(data);
|
|
877
|
+
if (((_a2 = resBulkAddWishlist == null ? void 0 : resBulkAddWishlist.status) == null ? void 0 : _a2.code) === 200) {
|
|
878
|
+
if (typeof window !== "undefined") {
|
|
879
|
+
if (window.sledgeWishlistBadgeUpdate)
|
|
880
|
+
window.sledgeWishlistBadgeUpdate();
|
|
881
|
+
if (window.sledgeInfoPopup)
|
|
882
|
+
window.sledgeInfoPopup({
|
|
883
|
+
title: title_added_all_to_wishlist,
|
|
884
|
+
message: text_added_all_to_wishlist,
|
|
885
|
+
textCancel: "Cancel"
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
setIsLoadingBulkAdd(false);
|
|
889
|
+
} else {
|
|
890
|
+
if (typeof window !== "undefined" && window.sledgeInfoPopup)
|
|
891
|
+
window.sledgeInfoPopup({
|
|
892
|
+
title: "Failed",
|
|
893
|
+
message: "Failed add to wishlist, please try again",
|
|
894
|
+
textCancel: "Cancel"
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
const handleCopyShareLink = () => {
|
|
899
|
+
let running = true;
|
|
900
|
+
document.body.addEventListener("DOMNodeInserted", () => {
|
|
901
|
+
let boxCopyElement = document.querySelector(".sledge-wishlist__widget-box-copy");
|
|
902
|
+
if (boxCopyElement && running) {
|
|
903
|
+
running = false;
|
|
904
|
+
let copyTriggerElement = document.querySelector(".sledge-wishlist__widget-box-copy-icon");
|
|
905
|
+
copyTriggerElement == null ? void 0 : copyTriggerElement.addEventListener("click", () => {
|
|
906
|
+
var _a2;
|
|
907
|
+
let shareLink2 = (_a2 = document.querySelector(".sledge-wishlist__widget-box-copy-content")) == null ? void 0 : _a2.textContent;
|
|
908
|
+
if (shareLink2) {
|
|
909
|
+
navigator.clipboard.writeText(shareLink2);
|
|
910
|
+
if (copyTriggerElement) {
|
|
911
|
+
copyTriggerElement.classList.add("active");
|
|
912
|
+
copyTriggerElement.innerHTML = checkIcon;
|
|
913
|
+
setTimeout(() => {
|
|
914
|
+
if (copyTriggerElement) {
|
|
915
|
+
copyTriggerElement.classList.remove("active");
|
|
916
|
+
copyTriggerElement.innerHTML = clipboardIcon;
|
|
917
|
+
}
|
|
918
|
+
}, 2500);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
};
|
|
925
|
+
const handleClick = async () => {
|
|
926
|
+
if (shareId && wishlistData.length) {
|
|
927
|
+
window.sledgeConfirmationPopup({
|
|
928
|
+
title: "Are you sure want to add this to your wishlist item?",
|
|
929
|
+
message: `This action cannot be undone. This will adding <strong>${wishlistData.length}</strong> item to your wishlist page.`,
|
|
930
|
+
textSubmit: "Add to your wishlist",
|
|
931
|
+
textCancel: "Cancel",
|
|
932
|
+
buttonSubmitType: "info",
|
|
933
|
+
onSubmit: handleBulkAddWishlist || {}
|
|
934
|
+
});
|
|
935
|
+
} else {
|
|
936
|
+
if (typeof window !== "undefined" && window.sledgeInfoPopup) {
|
|
937
|
+
window.sledgeInfoPopup({
|
|
938
|
+
title: title_share_wishlist,
|
|
939
|
+
message: shareLink ? `<div class="sledge-wishlist__widget-box-copy">
|
|
940
|
+
<div class="sledge-wishlist__widget-box-copy-icon" title="Copy to clipboard">
|
|
941
|
+
${clipboardIcon}
|
|
942
|
+
</div>
|
|
943
|
+
<div class="sledge-wishlist__widget-box-copy-content">${shareLink}</div>
|
|
944
|
+
</div>` : "",
|
|
945
|
+
textCancel: "Cancel"
|
|
946
|
+
});
|
|
947
|
+
handleCopyShareLink();
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
React__default.useEffect(() => {
|
|
952
|
+
setIsRequiredLogin(localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) && is_required_login);
|
|
953
|
+
}, []);
|
|
954
|
+
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: "grey-100", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__widget-header-item sledge-wishlist__widget-header-share-trigger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
955
|
+
Button,
|
|
956
|
+
{
|
|
957
|
+
type: "button",
|
|
958
|
+
style: display_button_share_style,
|
|
959
|
+
...shareId && !wishlistData.length || isLoadingBulkAdd ? {
|
|
960
|
+
disabled: true
|
|
961
|
+
} : {
|
|
962
|
+
onClick: handleClick
|
|
963
|
+
},
|
|
964
|
+
children: shareId ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
965
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-wishlist__badge-counter sledge-wishlist__badge-counter-top-right", children: wishlistData.length }),
|
|
966
|
+
isLoadingBulkAdd ? "Adding..." : "Add to your wishlist"
|
|
967
|
+
] }) : button_share ? button_share : buttonText || "Share Wishlist"
|
|
968
|
+
}
|
|
969
|
+
) }) }) }) });
|
|
970
|
+
};
|
|
971
|
+
const WidgetHeaderSearchForm = ({ setIsLoading, setKeyword, keyword, placeholder, dataSettings }) => {
|
|
972
|
+
var _a, _b;
|
|
973
|
+
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
974
|
+
const { search_form_placeholder } = ((_b = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _b.widget) || {};
|
|
975
|
+
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
976
|
+
const searchFieldRef = React__default.useRef(null);
|
|
977
|
+
const handleResetField = () => {
|
|
978
|
+
var _a2;
|
|
979
|
+
setIsLoading && setIsLoading(true);
|
|
980
|
+
setKeyword && setKeyword("");
|
|
981
|
+
(_a2 = searchFieldRef == null ? void 0 : searchFieldRef.current) == null ? void 0 : _a2.focus();
|
|
982
|
+
};
|
|
983
|
+
const handleChangeField = (value) => {
|
|
984
|
+
setKeyword && setKeyword(value);
|
|
985
|
+
};
|
|
986
|
+
React__default.useEffect(() => {
|
|
987
|
+
setIsRequiredLogin(localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) && is_required_login);
|
|
988
|
+
}, []);
|
|
989
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isRequiredLogin && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
990
|
+
SearchInputField,
|
|
991
|
+
{
|
|
992
|
+
type: "text",
|
|
993
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
994
|
+
placeholder: search_form_placeholder ? search_form_placeholder : placeholder || "Search product...",
|
|
995
|
+
value: keyword,
|
|
996
|
+
fieldRef: searchFieldRef,
|
|
997
|
+
onChange: ({ value }) => handleChangeField(value),
|
|
998
|
+
onResetField: handleResetField,
|
|
999
|
+
className: "sledge-wishlist__widget-search-form",
|
|
1000
|
+
withClearField: true
|
|
1001
|
+
}
|
|
1002
|
+
) });
|
|
1003
|
+
};
|
|
1004
|
+
const WidgetHeaderTitle = ({ text, dataSettings }) => {
|
|
1005
|
+
var _a, _b, _c;
|
|
1006
|
+
const {
|
|
1007
|
+
color: display_header_title_color,
|
|
1008
|
+
font_size: display_header_title_font_size,
|
|
1009
|
+
font_weight: display_header_title_font_weight,
|
|
1010
|
+
text_transform: display_header_title_text_transform
|
|
1011
|
+
} = ((_b = (_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.widget) == null ? void 0 : _b.header_title) || {};
|
|
1012
|
+
const { header_title: language_header_title } = ((_c = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _c.widget) || {};
|
|
1013
|
+
const display_header_title_style = {
|
|
1014
|
+
...display_header_title_color && { color: display_header_title_color },
|
|
1015
|
+
...display_header_title_font_size && { fontSize: display_header_title_font_size },
|
|
1016
|
+
...display_header_title_font_weight && { fontWeight: display_header_title_font_weight },
|
|
1017
|
+
...display_header_title_text_transform && { textTransform: display_header_title_text_transform }
|
|
1018
|
+
};
|
|
1019
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__widget-header-item", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { style: display_header_title_style, children: language_header_title ? language_header_title : text || "My Wishlist" }) });
|
|
1020
|
+
};
|
|
1021
|
+
const WidgetHeaderLimit = ({ options, defaultLimitOptions, selectedLimit, setSelectedLimit, setIsRefreshWidgetList, dataSettings }) => {
|
|
1022
|
+
var _a;
|
|
1023
|
+
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
1024
|
+
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
1025
|
+
let getOptions = options || defaultLimitOptions;
|
|
1026
|
+
const handleChangeLimit = (value) => {
|
|
1027
|
+
setSelectedLimit && setSelectedLimit(value);
|
|
1028
|
+
setIsRefreshWidgetList && setIsRefreshWidgetList(true);
|
|
1029
|
+
};
|
|
1030
|
+
React__default.useEffect(() => {
|
|
1031
|
+
setIsRequiredLogin(localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) && is_required_login);
|
|
1032
|
+
}, []);
|
|
1033
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isRequiredLogin && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: getOptions && Boolean(getOptions == null ? void 0 : getOptions.length) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__widget-header-item", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1034
|
+
SelectField,
|
|
1035
|
+
{
|
|
1036
|
+
align: "end",
|
|
1037
|
+
options: getOptions.map((item) => {
|
|
1038
|
+
return {
|
|
1039
|
+
label: item,
|
|
1040
|
+
value: item
|
|
1041
|
+
};
|
|
1042
|
+
}),
|
|
1043
|
+
value: selectedLimit || getOptions[0],
|
|
1044
|
+
onChange: ({ value }) => handleChangeLimit(value)
|
|
1045
|
+
}
|
|
1046
|
+
) }) }) });
|
|
1047
|
+
};
|
|
1048
|
+
const WidgetHeaderSort$1 = ({ wishlistSort, selectedSort, setSelectedSort, setIsRefreshWidgetList, dataSettings }) => {
|
|
1049
|
+
var _a, _b;
|
|
1050
|
+
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
1051
|
+
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
1052
|
+
const handleChangeSort = (value) => {
|
|
1053
|
+
setSelectedSort && setSelectedSort(value);
|
|
1054
|
+
setIsRefreshWidgetList && setIsRefreshWidgetList(true);
|
|
1055
|
+
};
|
|
1056
|
+
React__default.useEffect(() => {
|
|
1057
|
+
setIsRequiredLogin(localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) && is_required_login);
|
|
1058
|
+
}, []);
|
|
1059
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isRequiredLogin && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: wishlistSort && Boolean(wishlistSort == null ? void 0 : wishlistSort.length) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__widget-header-item", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1060
|
+
SelectField,
|
|
1061
|
+
{
|
|
1062
|
+
align: "end",
|
|
1063
|
+
options: wishlistSort.map((item) => {
|
|
1064
|
+
const { name, value } = item;
|
|
1065
|
+
return {
|
|
1066
|
+
label: name,
|
|
1067
|
+
value
|
|
1068
|
+
};
|
|
1069
|
+
}),
|
|
1070
|
+
value: selectedSort || ((_b = wishlistSort[0]) == null ? void 0 : _b.value),
|
|
1071
|
+
onChange: ({ value }) => handleChangeSort(value)
|
|
1072
|
+
}
|
|
1073
|
+
) }) }) });
|
|
1074
|
+
};
|
|
1075
|
+
const WidgetHeader$1 = ({ isFirstLoading, ...props }) => {
|
|
1076
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__widget-header", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1077
|
+
"div",
|
|
1078
|
+
{
|
|
1079
|
+
style: {
|
|
1080
|
+
display: "flex",
|
|
1081
|
+
gap: "8px",
|
|
1082
|
+
width: "100%",
|
|
1083
|
+
justifyContent: "space-between"
|
|
1084
|
+
},
|
|
1085
|
+
children: [
|
|
1086
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "190px", height: "46px", color: "grey-100", rounded: "md" }),
|
|
1087
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1088
|
+
"div",
|
|
1089
|
+
{
|
|
1090
|
+
style: {
|
|
1091
|
+
display: "flex",
|
|
1092
|
+
gap: "8px"
|
|
1093
|
+
},
|
|
1094
|
+
children: [
|
|
1095
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "440px", height: "46px", color: "grey-100", rounded: "md" }),
|
|
1096
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "132px", height: "46px", color: "grey-100", rounded: "md" }),
|
|
1097
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "136px", height: "46px", color: "grey-100", rounded: "md" })
|
|
1098
|
+
]
|
|
1099
|
+
}
|
|
1100
|
+
),
|
|
1101
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1102
|
+
"div",
|
|
1103
|
+
{
|
|
1104
|
+
style: {
|
|
1105
|
+
display: "flex",
|
|
1106
|
+
gap: "26px"
|
|
1107
|
+
},
|
|
1108
|
+
children: [
|
|
1109
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "190px", height: "46px", color: "grey-100", rounded: "md" }),
|
|
1110
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "190px", height: "46px", color: "grey-100", rounded: "md" })
|
|
1111
|
+
]
|
|
1112
|
+
}
|
|
1113
|
+
)
|
|
1114
|
+
]
|
|
1115
|
+
}
|
|
1116
|
+
) : React__default.Children.count(props.children) && React__default.Children.map(
|
|
1117
|
+
props.children,
|
|
1118
|
+
(child) => React__default.cloneElement(child, {
|
|
1119
|
+
...props
|
|
1120
|
+
})
|
|
1121
|
+
) });
|
|
1122
|
+
};
|
|
1123
|
+
WidgetHeader$1.Title = WidgetHeaderTitle;
|
|
1124
|
+
WidgetHeader$1.SearchForm = WidgetHeaderSearchForm;
|
|
1125
|
+
WidgetHeader$1.ShareTrigger = WidgetHeaderShareTrigger;
|
|
1126
|
+
WidgetHeader$1.ClearTrigger = WidgetHeaderClearTrigger;
|
|
1127
|
+
WidgetHeader$1.Sort = WidgetHeaderSort$1;
|
|
1128
|
+
WidgetHeader$1.Limit = WidgetHeaderLimit;
|
|
1129
|
+
const usePrevious = (value) => {
|
|
1130
|
+
const ref = React__default.useRef();
|
|
1131
|
+
React__default.useEffect(() => {
|
|
1132
|
+
ref.current = value;
|
|
1133
|
+
});
|
|
1134
|
+
return ref.current;
|
|
1135
|
+
};
|
|
1136
|
+
const WidgetPopup = "";
|
|
1137
|
+
const Rating$1 = "";
|
|
1138
|
+
const getReviewInfo = async (id) => {
|
|
1139
|
+
let convertId = sanitizeDataId(id);
|
|
1140
|
+
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
1141
|
+
var myHeaders = new Headers();
|
|
1142
|
+
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
1143
|
+
var requestOptions = {
|
|
1144
|
+
method: "GET",
|
|
1145
|
+
headers: myHeaders,
|
|
1146
|
+
redirect: "follow"
|
|
1147
|
+
};
|
|
1148
|
+
return await fetch(`${API_URL}/review/info/${convertId}`, requestOptions).then((response) => response.json()).then((result) => {
|
|
1149
|
+
return result;
|
|
1150
|
+
}).catch(() => {
|
|
1151
|
+
return;
|
|
1152
|
+
});
|
|
1153
|
+
};
|
|
1154
|
+
const Rating = (props) => {
|
|
1155
|
+
var _a;
|
|
1156
|
+
const { value, size = "md", data, withSkeletonLoading = true } = props;
|
|
1157
|
+
const { productId } = data || {};
|
|
1158
|
+
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
1159
|
+
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
1160
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
1161
|
+
const [sizing, setSizing] = React__default.useState({
|
|
1162
|
+
width: 0,
|
|
1163
|
+
height: 0
|
|
1164
|
+
});
|
|
1165
|
+
const [totalReview, setTotalReview] = React__default.useState(0);
|
|
1166
|
+
const [averageReview, setAverageReview] = React__default.useState("0");
|
|
1167
|
+
const [dataSettings, setDataSettings] = React__default.useState({});
|
|
1168
|
+
const { fill_color, outline_color } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.rating) || {};
|
|
1169
|
+
const handleProductRatingInfo = async () => {
|
|
1170
|
+
var _a2;
|
|
1171
|
+
if (value && !data) {
|
|
1172
|
+
setAverageReview(value);
|
|
1173
|
+
setIsLoading(false);
|
|
1174
|
+
} else {
|
|
1175
|
+
let response;
|
|
1176
|
+
let run = false;
|
|
1177
|
+
let valueTotalReview = 0;
|
|
1178
|
+
let valueAverageReview;
|
|
1179
|
+
response = await getReviewInfo(productId);
|
|
1180
|
+
if (!response)
|
|
1181
|
+
return;
|
|
1182
|
+
const { status, data: data2 } = response;
|
|
1183
|
+
const { code } = status;
|
|
1184
|
+
run = code === 200 || false;
|
|
1185
|
+
valueTotalReview = (data2 == null ? void 0 : data2.review_count) ? data2.review_count : 0;
|
|
1186
|
+
valueAverageReview = ((_a2 = data2 == null ? void 0 : data2.rating) == null ? void 0 : _a2.average) ? data2.rating.average : 0;
|
|
1187
|
+
if (run) {
|
|
1188
|
+
setTotalReview(valueTotalReview);
|
|
1189
|
+
setAverageReview(valueAverageReview);
|
|
1190
|
+
setIsLoading(false);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
const handleSettings = async (LOCAL_STORAGE_PRODUCT_REVIEW_SETTING) => {
|
|
1195
|
+
setIsLoading(true);
|
|
1196
|
+
let response;
|
|
1197
|
+
let run = false;
|
|
1198
|
+
response = JSON.parse(LOCAL_STORAGE_PRODUCT_REVIEW_SETTING);
|
|
1199
|
+
if (!response)
|
|
1200
|
+
return;
|
|
1201
|
+
const { status, data: data2 } = response;
|
|
1202
|
+
const { code } = status;
|
|
1203
|
+
run = code === 200 || false;
|
|
1204
|
+
if (run) {
|
|
1205
|
+
setDataSettings(data2);
|
|
1206
|
+
await handleProductRatingInfo();
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
React__default.useEffect(() => {
|
|
1210
|
+
if (!(isRenderApp == null ? void 0 : isRenderApp.productReview))
|
|
1211
|
+
return;
|
|
1212
|
+
if (size === "xs") {
|
|
1213
|
+
setSizing({
|
|
1214
|
+
width: 14.4,
|
|
1215
|
+
height: 14.4
|
|
1216
|
+
});
|
|
1217
|
+
} else if (size === "sm") {
|
|
1218
|
+
setSizing({
|
|
1219
|
+
width: 18,
|
|
1220
|
+
height: 18
|
|
1221
|
+
});
|
|
1222
|
+
} else {
|
|
1223
|
+
setSizing({
|
|
1224
|
+
width: 28.8,
|
|
1225
|
+
height: 28.8
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.PRODUCT_REVIEW_SETTING) || "");
|
|
1229
|
+
setTimeout(() => {
|
|
1230
|
+
setIsFirstLoading(false);
|
|
1231
|
+
}, 1300);
|
|
1232
|
+
}, [isRenderApp]);
|
|
1233
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__rating", children: isFirstLoading && withSkeletonLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "230px", height: "28px", color: "grey-100", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1234
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", style: { display: "none" }, id: "sledge-product-review-rating-icon-svg-store", children: [
|
|
1235
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("symbol", { id: "sledge-product-review-icons-rating-icon-fill", viewBox: "0 0 30 29", fill: fill_color || "#23BC45", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1236
|
+
"path",
|
|
1237
|
+
{
|
|
1238
|
+
fillRule: "evenodd",
|
|
1239
|
+
clipRule: "evenodd",
|
|
1240
|
+
d: "M7.00014 17.7L1.20174 12.9C0.107339 12.0248 0.587339 10.2648 1.97614 10.0664L10.2001 9.69998L13.7121 0.895176C13.9569 0.407176 14.4545 0.0999756 15.0001 0.0999756C15.5457 0.0999756 16.0433 0.408776 16.2881 0.895176L19.8001 9.69998L28.0241 10.0664C29.4129 10.2648 29.8929 12.0248 28.7985 12.9L23.0001 17.7L24.5825 27.0712C24.7649 28.3496 23.4369 29.3064 22.2833 28.7288L15.0001 24.1L7.71694 28.7272C6.56174 29.3048 5.23534 28.348 5.41774 27.0696L7.00014 17.7Z"
|
|
1241
|
+
}
|
|
1242
|
+
) }),
|
|
1243
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("symbol", { id: "sledge-product-review-icons-rating-icon-line", viewBox: "0 0 30 29", stroke: outline_color || "#8D9196", fill: "none", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1244
|
+
"path",
|
|
1245
|
+
{
|
|
1246
|
+
fillRule: "evenodd",
|
|
1247
|
+
clipRule: "evenodd",
|
|
1248
|
+
d: "M7.00014 17.7L1.20174 12.9C0.107339 12.0248 0.587339 10.2648 1.97614 10.0664L10.2001 9.69998L13.7121 0.895176C13.9569 0.407176 14.4545 0.0999756 15.0001 0.0999756C15.5457 0.0999756 16.0433 0.408776 16.2881 0.895176L19.8001 9.69998L28.0241 10.0664C29.4129 10.2648 29.8929 12.0248 28.7985 12.9L23.0001 17.7L24.5825 27.0712C24.7649 28.3496 23.4369 29.3064 22.2833 28.7288L15.0001 24.1L7.71694 28.7272C6.56174 29.3048 5.23534 28.348 5.41774 27.0696L7.00014 17.7Z",
|
|
1249
|
+
strokeWidth: "1.4"
|
|
1250
|
+
}
|
|
1251
|
+
) }),
|
|
1252
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("defs", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("g", { id: "sledge-product-review-icons-rating-icon", children: [
|
|
1253
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#sledge-product-review-icons-rating-icon-line", className: "sledge-product-review__rating-icon-line" }),
|
|
1254
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#sledge-product-review-icons-rating-icon-fill", className: "sledge-product-review__rating-icon-fill" })
|
|
1255
|
+
] }) })
|
|
1256
|
+
] }),
|
|
1257
|
+
!isLoading && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1258
|
+
[1, 2, 3, 4, 5].map((item, index) => {
|
|
1259
|
+
let ratingValue = Math.floor(parseFloat(averageReview));
|
|
1260
|
+
let getCommaValue = String(averageReview).includes(",") ? String(averageReview).split(",") : [];
|
|
1261
|
+
let getCommaValueDot = String(averageReview).includes(".") ? String(averageReview).split(".") : [];
|
|
1262
|
+
let isHaveCommaValue = getCommaValue.length || getCommaValueDot.length;
|
|
1263
|
+
let commaValue = isHaveCommaValue ? getCommaValue[1] || getCommaValueDot[1] : 0;
|
|
1264
|
+
let fillOther = "fill-0";
|
|
1265
|
+
if (item > ratingValue && ratingValue + 1 === item) {
|
|
1266
|
+
fillOther = `fill-${commaValue}`;
|
|
1267
|
+
}
|
|
1268
|
+
return /* @__PURE__ */ createElement("svg", { ...sizing, viewBox: "0 0 30 29", "data-product-review-rating-fill": item <= ratingValue ? "full" : fillOther, key: index }, /* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#sledge-product-review-icons-rating-icon" }));
|
|
1269
|
+
}),
|
|
1270
|
+
!value && data ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__rating-summary-total", children: [
|
|
1271
|
+
"(",
|
|
1272
|
+
totalReview,
|
|
1273
|
+
")"
|
|
1274
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})
|
|
1275
|
+
] })
|
|
1276
|
+
] }) });
|
|
1277
|
+
};
|
|
1278
|
+
const Widget = "";
|
|
1279
|
+
const WidgetHeaderAddTrigger = ({ isFirstLoading, text, dataSettings, data, onAfterAddReview }) => {
|
|
1280
|
+
var _a, _b, _c;
|
|
1281
|
+
const {
|
|
1282
|
+
text_color: display_button_write_review_text_color,
|
|
1283
|
+
border_color: display_button_write_review_border_color,
|
|
1284
|
+
border_radius: display_button_write_review_border_radius,
|
|
1285
|
+
padding_top: display_button_write_review_padding_top,
|
|
1286
|
+
padding_bottom: display_button_write_review_padding_bottom,
|
|
1287
|
+
padding_left: display_button_write_review_padding_left,
|
|
1288
|
+
padding_right: display_button_write_review_padding_right,
|
|
1289
|
+
background_color: display_button_write_review_background_color,
|
|
1290
|
+
font_size: display_button_write_review_font_size,
|
|
1291
|
+
font_weight: display_button_write_review_font_weight,
|
|
1292
|
+
text_transform: display_button_write_review_text_transform
|
|
1293
|
+
} = ((_b = (_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.widget) == null ? void 0 : _b.button_write_review) || {};
|
|
1294
|
+
const { button_write_review } = ((_c = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _c.widget) || {};
|
|
1295
|
+
const display_button_write_review_style = {
|
|
1296
|
+
...display_button_write_review_text_color && { color: display_button_write_review_text_color },
|
|
1297
|
+
...display_button_write_review_border_color && { borderColor: display_button_write_review_border_color },
|
|
1298
|
+
...display_button_write_review_border_radius && { borderRadius: display_button_write_review_border_radius },
|
|
1299
|
+
...display_button_write_review_padding_top && { paddingTop: display_button_write_review_padding_top },
|
|
1300
|
+
...display_button_write_review_padding_bottom && { paddingBottom: display_button_write_review_padding_bottom },
|
|
1301
|
+
...display_button_write_review_padding_left && { paddingLeft: display_button_write_review_padding_left },
|
|
1302
|
+
...display_button_write_review_padding_right && { paddingRight: display_button_write_review_padding_right },
|
|
1303
|
+
...display_button_write_review_background_color && { backgroundColor: display_button_write_review_background_color },
|
|
1304
|
+
...display_button_write_review_font_size && { fontSize: display_button_write_review_font_size },
|
|
1305
|
+
...display_button_write_review_font_weight && { fontWeight: display_button_write_review_font_weight },
|
|
1306
|
+
...display_button_write_review_text_transform && { textTransform: display_button_write_review_text_transform }
|
|
1307
|
+
};
|
|
1308
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-header-item", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "134px", height: "42px", rounded: "lg", color: "grey-100" }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1309
|
+
Button,
|
|
1310
|
+
{
|
|
1311
|
+
type: "button",
|
|
1312
|
+
colorType: "success",
|
|
1313
|
+
onClick: () => typeof window !== "undefined" && window.sledgeProductReviewWidgetFormAdd && window.sledgeProductReviewWidgetFormAdd(data, onAfterAddReview),
|
|
1314
|
+
style: display_button_write_review_style,
|
|
1315
|
+
children: [
|
|
1316
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 16, height: 17, viewBox: "0 0 16 17", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1317
|
+
"path",
|
|
1318
|
+
{
|
|
1319
|
+
fillRule: "evenodd",
|
|
1320
|
+
clipRule: "evenodd",
|
|
1321
|
+
d: "M13.8323 14.1264C14.1083 14.1264 14.3323 14.3504 14.3323 14.6264C14.3323 14.9024 14.1083 15.1264 13.8323 15.1264H8.99701C8.72101 15.1264 8.49701 14.9024 8.49701 14.6264C8.49701 14.3504 8.72101 14.1264 8.99701 14.1264H13.8323ZM10.7429 2.93576C10.7762 2.96176 11.8915 3.82843 11.8915 3.82843C12.2969 4.06976 12.6135 4.5011 12.7335 5.01176C12.8529 5.5171 12.7662 6.03843 12.4882 6.47909C12.4864 6.48203 12.4845 6.48494 12.4781 6.49358L12.4731 6.50025C12.4279 6.55972 12.2318 6.80776 11.2417 8.04815C11.2325 8.06441 11.2221 8.07963 11.2107 8.09443C11.1941 8.11624 11.1759 8.13628 11.1565 8.15453C11.089 8.23956 11.0176 8.3289 10.9426 8.42283L10.7907 8.61313C10.4772 9.00579 10.1053 9.47139 9.66407 10.0236L9.43764 10.3071C8.58586 11.3732 7.49499 12.7382 6.09755 14.4864C5.79155 14.8678 5.33288 15.0898 4.84021 15.0958L2.41421 15.1264H2.40755C2.17621 15.1264 1.97488 14.9678 1.92088 14.7418L1.37488 12.4278C1.26221 11.9484 1.37421 11.4538 1.68155 11.0698L7.96155 3.2151C7.96421 3.21243 7.96621 3.2091 7.96888 3.20643C8.65755 2.3831 9.90288 2.26176 10.7429 2.93576ZM7.26136 5.69133L2.46221 11.6944C2.34821 11.8371 2.30621 12.0211 2.34821 12.1978L2.80221 14.1211L4.82821 14.0958C5.02088 14.0938 5.19888 14.0078 5.31688 13.8611C5.92454 13.1008 6.68825 12.1452 7.47345 11.1627L7.75125 10.815L8.02952 10.4668C8.76591 9.54526 9.4934 8.63471 10.1021 7.87258L7.26136 5.69133ZM8.73888 3.84443L7.88603 4.91L10.7265 7.09062C11.2733 6.4058 11.633 5.95476 11.6662 5.91176C11.7755 5.73443 11.8182 5.48376 11.7609 5.24243C11.7022 4.9951 11.5482 4.78509 11.3262 4.65109C11.2789 4.61843 10.1555 3.74643 10.1209 3.71909C9.69821 3.38043 9.08155 3.4391 8.73888 3.84443Z",
|
|
1322
|
+
fill: "currentColor"
|
|
1323
|
+
}
|
|
1324
|
+
) }),
|
|
1325
|
+
text ? text : button_write_review || "Add review"
|
|
1326
|
+
]
|
|
1327
|
+
}
|
|
1328
|
+
) });
|
|
1329
|
+
};
|
|
1330
|
+
const WidgetHeaderSort = ({ isFirstLoading, productReviewSort, dataSettings, setSelectedSort, setIsRefreshWidgetList }) => {
|
|
1331
|
+
var _a, _b;
|
|
1332
|
+
const { default_sort, show_sorting_options } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.widget) || {};
|
|
1333
|
+
const [clickedSortId, setClickedSortId] = React__default.useState(default_sort || null);
|
|
1334
|
+
const handleChangeSort = (value) => {
|
|
1335
|
+
setClickedSortId(value);
|
|
1336
|
+
setIsRefreshWidgetList && setIsRefreshWidgetList(true);
|
|
1337
|
+
setSelectedSort && setSelectedSort(value);
|
|
1338
|
+
};
|
|
1339
|
+
const getSelectedSort = clickedSortId || ((_b = productReviewSort[0]) == null ? void 0 : _b.value);
|
|
1340
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !show_sorting_options ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-header-item", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "134px", height: "42px", rounded: "lg", color: "grey-100" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1341
|
+
SelectField,
|
|
1342
|
+
{
|
|
1343
|
+
align: "end",
|
|
1344
|
+
prefixLabel: /* @__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(
|
|
1345
|
+
"path",
|
|
1346
|
+
{
|
|
1347
|
+
fillRule: "evenodd",
|
|
1348
|
+
clipRule: "evenodd",
|
|
1349
|
+
d: "M11.5919 9.13869C12.7359 9.13869 13.6666 10.0647 13.6666 11.2027C13.6666 12.3407 12.7359 13.2667 11.5919 13.2667C10.4473 13.2667 9.51593 12.3407 9.51593 11.2027C9.51593 10.0647 10.4473 9.13869 11.5919 9.13869ZM11.5919 10.1387C10.9986 10.1387 10.5159 10.616 10.5159 11.2027C10.5159 11.79 10.9986 12.2667 11.5919 12.2667C12.1846 12.2667 12.6666 11.79 12.6666 11.2027C12.6666 10.616 12.1846 10.1387 11.5919 10.1387ZM6.7202 10.7286C6.9962 10.7286 7.2202 10.9526 7.2202 11.2286C7.2202 11.5046 6.9962 11.7286 6.7202 11.7286H2.51953C2.24353 11.7286 2.01953 11.5046 2.01953 11.2286C2.01953 10.9526 2.24353 10.7286 2.51953 10.7286H6.7202ZM4.07533 2.66669C5.22 2.66669 6.15067 3.59335 6.15067 4.73135C6.15067 5.86935 5.22 6.79469 4.07533 6.79469C2.93133 6.79469 2 5.86935 2 4.73135C2 3.59335 2.93133 2.66669 4.07533 2.66669ZM4.07533 3.66669C3.48267 3.66669 3 4.14402 3 4.73135C3 5.31802 3.48267 5.79469 4.07533 5.79469C4.66867 5.79469 5.15067 5.31802 5.15067 4.73135C5.15067 4.14402 4.66867 3.66669 4.07533 3.66669ZM12.7941 4.26695C13.0701 4.26695 13.2941 4.49095 13.2941 4.76695C13.2941 5.04295 13.0701 5.26695 12.7941 5.26695H8.59407C8.31807 5.26695 8.09407 5.04295 8.09407 4.76695C8.09407 4.49095 8.31807 4.26695 8.59407 4.26695H12.7941Z",
|
|
1350
|
+
fill: "currentColor"
|
|
1351
|
+
}
|
|
1352
|
+
) }),
|
|
1353
|
+
prefixSelectedLabel: "Sort by",
|
|
1354
|
+
options: productReviewSort.map((item) => {
|
|
1355
|
+
const { name, value } = item;
|
|
1356
|
+
return {
|
|
1357
|
+
label: name,
|
|
1358
|
+
value
|
|
1359
|
+
};
|
|
1360
|
+
}),
|
|
1361
|
+
value: getSelectedSort,
|
|
1362
|
+
onChange: ({ value }) => handleChangeSort(value)
|
|
1363
|
+
}
|
|
1364
|
+
) }) });
|
|
1365
|
+
};
|
|
1366
|
+
const ROTATE_FILTER_ARROW_ANIMATION = {
|
|
1367
|
+
open: { rotate: 180 },
|
|
1368
|
+
closed: { rotate: 0 },
|
|
1369
|
+
transition: {
|
|
1370
|
+
type: "spring",
|
|
1371
|
+
duration: 0.2
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
const VISIBLE_ANIMATION = {
|
|
1375
|
+
hidden: { opacity: 0, scale: 0 },
|
|
1376
|
+
visible: (custom) => {
|
|
1377
|
+
const { duration } = custom || {};
|
|
1378
|
+
return {
|
|
1379
|
+
opacity: 1,
|
|
1380
|
+
scale: 1,
|
|
1381
|
+
transition: {
|
|
1382
|
+
type: "spring",
|
|
1383
|
+
duration: duration || 0.7
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
};
|
|
1388
|
+
const WidgetHeaderSummary = (props) => {
|
|
1389
|
+
var _a, _b, _c;
|
|
1390
|
+
const { data, dataSettings } = props;
|
|
1391
|
+
const { productId } = data || {};
|
|
1392
|
+
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) || {};
|
|
1393
|
+
const { review_singular, review_plural } = ((_c = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _c.widget) || {};
|
|
1394
|
+
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
1395
|
+
const [isFirstLoadingSummary, setIsFirstLoadingSummary] = React__default.useState(true);
|
|
1396
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
1397
|
+
const [isRefreshRating, setIsRefreshRating] = React__default.useState(true);
|
|
1398
|
+
const [isOpen, setIsOpen] = React__default.useState(false);
|
|
1399
|
+
const [totalReview, setTotalReview] = React__default.useState(0);
|
|
1400
|
+
const [ratingList, setRatingList] = React__default.useState({
|
|
1401
|
+
5: 0,
|
|
1402
|
+
4: 0,
|
|
1403
|
+
3: 0,
|
|
1404
|
+
2: 0,
|
|
1405
|
+
1: 0
|
|
1406
|
+
});
|
|
1407
|
+
const [averageReview, setAverageReview] = React__default.useState("0");
|
|
1408
|
+
const handleProductReviewInfo = async () => {
|
|
1409
|
+
var _a2;
|
|
1410
|
+
let response;
|
|
1411
|
+
let run = false;
|
|
1412
|
+
let valueTotalReview = 0;
|
|
1413
|
+
let valueRatingList;
|
|
1414
|
+
let valueAverageReview;
|
|
1415
|
+
response = await getReviewInfo(productId);
|
|
1416
|
+
if (!response)
|
|
1417
|
+
return;
|
|
1418
|
+
const { status, data: data2 } = response;
|
|
1419
|
+
const { code } = status;
|
|
1420
|
+
run = code === 200 || false;
|
|
1421
|
+
valueTotalReview = (data2 == null ? void 0 : data2.review_count) ? data2.review_count : 0;
|
|
1422
|
+
valueRatingList = (data2 == null ? void 0 : data2.rating) ? {
|
|
1423
|
+
5: data2.rating["5"] || 0,
|
|
1424
|
+
4: data2.rating["4"] || 0,
|
|
1425
|
+
3: data2.rating["3"] || 0,
|
|
1426
|
+
2: data2.rating["2"] || 0,
|
|
1427
|
+
1: data2.rating["1"] || 0
|
|
1428
|
+
} : ratingList;
|
|
1429
|
+
valueAverageReview = ((_a2 = data2 == null ? void 0 : data2.rating) == null ? void 0 : _a2.average) ? data2.rating.average : "0";
|
|
1430
|
+
if (run) {
|
|
1431
|
+
setTotalReview(valueTotalReview);
|
|
1432
|
+
setRatingList(valueRatingList);
|
|
1433
|
+
setAverageReview(valueAverageReview);
|
|
1434
|
+
setIsLoading(false);
|
|
1435
|
+
setIsRefreshRating(false);
|
|
1436
|
+
setIsFirstLoading(false);
|
|
1437
|
+
isOpen && setIsFirstLoadingSummary(false);
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
React__default.useEffect(() => {
|
|
1441
|
+
if (typeof window !== "undefined") {
|
|
1442
|
+
window.sledgeProductReviewWidgetSummaryUpdate = () => {
|
|
1443
|
+
setIsRefreshRating(true);
|
|
1444
|
+
handleProductReviewInfo();
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
handleProductReviewInfo();
|
|
1448
|
+
}, [isOpen]);
|
|
1449
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "630px", height: "42px", color: "grey-100", rounded: "md", animationDuration: "5s" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1450
|
+
Popover,
|
|
1451
|
+
{
|
|
1452
|
+
trigger: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs(motion.div, { initial: false, animate: isOpen ? "open" : "closed", className: "sledge-product-review__widget-summary-trigger", children: [
|
|
1453
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-average", children: averageReview }),
|
|
1454
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-rating", children: !isRefreshRating && /* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { value: String(averageReview), size: "md", withSkeletonLoading: false }) }),
|
|
1455
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__widget-summary-total", children: [
|
|
1456
|
+
totalReview,
|
|
1457
|
+
" ",
|
|
1458
|
+
totalReview > 1 ? review_plural || "Reviews" : review_singular || "Review"
|
|
1459
|
+
] }),
|
|
1460
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { variants: ROTATE_FILTER_ARROW_ANIMATION, className: "summary-trigger-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 20, height: 20, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1461
|
+
"path",
|
|
1462
|
+
{
|
|
1463
|
+
d: "M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",
|
|
1464
|
+
fill: "currentColor",
|
|
1465
|
+
fillRule: "evenodd",
|
|
1466
|
+
clipRule: "evenodd"
|
|
1467
|
+
}
|
|
1468
|
+
) }) })
|
|
1469
|
+
] }),
|
|
1470
|
+
content: isFirstLoadingSummary ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-summary-dist-progress", children: [5, 4, 3, 2, 1].map((index) => {
|
|
1471
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__widget-summary-dist-progress-item", children: [
|
|
1472
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "108px", height: "22px", color: "grey-100", rounded: "md", animationDuration: "15s" }),
|
|
1473
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1474
|
+
SkeletonLoading.Item,
|
|
1475
|
+
{
|
|
1476
|
+
width: "128px",
|
|
1477
|
+
height: "22px",
|
|
1478
|
+
color: "grey-100",
|
|
1479
|
+
rounded: "md",
|
|
1480
|
+
animationDuration: "13s",
|
|
1481
|
+
style: {
|
|
1482
|
+
marginLeft: "13px",
|
|
1483
|
+
marginRight: "12px"
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
),
|
|
1487
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "38px", height: "22px", color: "grey-100", rounded: "md", animationDuration: "42s" })
|
|
1488
|
+
] }, index);
|
|
1489
|
+
}) }) : /* @__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) => {
|
|
1490
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-product-review__widget-summary-dist-progress-item", children: [
|
|
1491
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Rating, { value: item, size: "sm", withSkeletonLoading: false }),
|
|
1492
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1493
|
+
Progress,
|
|
1494
|
+
{
|
|
1495
|
+
value: String(ratingList[item]),
|
|
1496
|
+
total: totalReview,
|
|
1497
|
+
fillColor: display_summary_bar_fill_color,
|
|
1498
|
+
outlineColor: display_summary_bar_outline_color
|
|
1499
|
+
}
|
|
1500
|
+
),
|
|
1501
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("small", { children: [
|
|
1502
|
+
"(",
|
|
1503
|
+
ratingList[item],
|
|
1504
|
+
")"
|
|
1505
|
+
] })
|
|
1506
|
+
] }, index);
|
|
1507
|
+
}) }) }),
|
|
1508
|
+
setIsOpen,
|
|
1509
|
+
hideCloseIcon: true,
|
|
1510
|
+
align: "end",
|
|
1511
|
+
alignOffset: -170,
|
|
1512
|
+
className: "sledge-product-review__widget-summary-content",
|
|
1513
|
+
withArrow: false
|
|
1514
|
+
}
|
|
1515
|
+
) });
|
|
1516
|
+
};
|
|
1517
|
+
const WidgetHeader = (props) => {
|
|
1518
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
1519
|
+
React__default.useEffect(() => {
|
|
1520
|
+
setIsLoading(false);
|
|
1521
|
+
}, []);
|
|
1522
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-header", children: React__default.Children.count(props.children) && React__default.Children.map(
|
|
1523
|
+
props.children,
|
|
1524
|
+
(child) => React__default.cloneElement(child, {
|
|
1525
|
+
...props
|
|
1526
|
+
})
|
|
1527
|
+
) }) });
|
|
1528
|
+
};
|
|
1529
|
+
WidgetHeader.Sort = WidgetHeaderSort;
|
|
1530
|
+
WidgetHeader.AddTrigger = WidgetHeaderAddTrigger;
|
|
1531
|
+
WidgetHeader.Summary = WidgetHeaderSummary;
|
|
1532
|
+
const WidgetPopupDetail = "";
|
|
1533
|
+
const WidgetFormAdd = "";
|
|
1534
|
+
const fetchApi = async (url, method, body) => {
|
|
1535
|
+
let sledgeInstantSearchAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_AUTH_APP);
|
|
1536
|
+
var myHeaders = new Headers();
|
|
1537
|
+
myHeaders.append("Authorization", `Bearer ${sledgeInstantSearchAuthApp}`);
|
|
1538
|
+
myHeaders.append("Content-Type", "application/json");
|
|
1539
|
+
var requestOptions = {
|
|
1540
|
+
...{
|
|
1541
|
+
method,
|
|
1542
|
+
headers: myHeaders,
|
|
1543
|
+
redirect: "follow"
|
|
1544
|
+
},
|
|
1545
|
+
...body && {
|
|
1546
|
+
body: JSON.stringify(body)
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
return await fetch(`${INSTANT_SEARCH_ENGINE_URL}${url}`, requestOptions).then((response) => response.json()).then((result) => result).catch(() => {
|
|
1550
|
+
return;
|
|
1551
|
+
});
|
|
1552
|
+
};
|
|
1553
|
+
const search = async (index, body) => {
|
|
1554
|
+
return await fetchApi(`/indexes/${index}/search`, "POST", body);
|
|
1555
|
+
};
|
|
1556
|
+
const multiSearch = async (body) => {
|
|
1557
|
+
return await fetchApi("/multi-search", "POST", body);
|
|
1558
|
+
};
|
|
1559
|
+
const searchTrigger = async (data) => {
|
|
1560
|
+
const { keyword, resultCount } = data;
|
|
1561
|
+
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
1562
|
+
var myHeaders = new Headers();
|
|
1563
|
+
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
1564
|
+
myHeaders.append("Content-Type", "application/json");
|
|
1565
|
+
var raw = JSON.stringify({
|
|
1566
|
+
keyword,
|
|
1567
|
+
result_count: resultCount
|
|
1568
|
+
});
|
|
1569
|
+
var requestOptions = {
|
|
1570
|
+
method: "POST",
|
|
1571
|
+
headers: myHeaders,
|
|
1572
|
+
body: raw,
|
|
1573
|
+
redirect: "follow"
|
|
1574
|
+
};
|
|
1575
|
+
return await fetch(`${API_URL}/instantsearch/statistics/search`, requestOptions).then((response) => response.json()).then((result) => {
|
|
1576
|
+
return result;
|
|
1577
|
+
}).catch(() => {
|
|
1578
|
+
return;
|
|
1579
|
+
});
|
|
1580
|
+
};
|
|
1581
|
+
const productClickTrigger = async (data) => {
|
|
1582
|
+
const { productId } = data;
|
|
1583
|
+
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
1584
|
+
var myHeaders = new Headers();
|
|
1585
|
+
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
1586
|
+
myHeaders.append("Content-Type", "application/json");
|
|
1587
|
+
var raw = JSON.stringify({
|
|
1588
|
+
product: {
|
|
1589
|
+
id: sanitizeDataId(productId)
|
|
1590
|
+
}
|
|
1591
|
+
});
|
|
1592
|
+
var requestOptions = {
|
|
1593
|
+
method: "POST",
|
|
1594
|
+
headers: myHeaders,
|
|
1595
|
+
body: raw,
|
|
1596
|
+
redirect: "follow"
|
|
1597
|
+
};
|
|
1598
|
+
return await fetch(`${API_URL}/instantsearch/statistics/click`, requestOptions).then((response) => response.json()).then((result) => {
|
|
1599
|
+
return result;
|
|
1600
|
+
}).catch(() => {
|
|
1601
|
+
return;
|
|
1602
|
+
});
|
|
1603
|
+
};
|
|
1604
|
+
const addToCartTrigger = async (data) => {
|
|
1605
|
+
const { productId } = data;
|
|
1606
|
+
let sledgeAuthApp = localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP);
|
|
1607
|
+
var myHeaders = new Headers();
|
|
1608
|
+
myHeaders.append("Authorization", `Bearer ${sledgeAuthApp}`);
|
|
1609
|
+
myHeaders.append("Content-Type", "application/json");
|
|
1610
|
+
var raw = JSON.stringify({
|
|
1611
|
+
product: {
|
|
1612
|
+
id: sanitizeDataId(productId)
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
var requestOptions = {
|
|
1616
|
+
method: "POST",
|
|
1617
|
+
headers: myHeaders,
|
|
1618
|
+
body: raw,
|
|
1619
|
+
redirect: "follow"
|
|
1620
|
+
};
|
|
1621
|
+
return await fetch(`${API_URL}/instantsearch/statistics/cart`, requestOptions).then((response) => response.json()).then((result) => {
|
|
1622
|
+
return result;
|
|
1623
|
+
}).catch(() => {
|
|
1624
|
+
return;
|
|
1625
|
+
});
|
|
1626
|
+
};
|
|
1627
|
+
const ProductGrid = ({
|
|
1628
|
+
type,
|
|
1629
|
+
className = "",
|
|
1630
|
+
data,
|
|
1631
|
+
setting,
|
|
1632
|
+
customProductCard,
|
|
1633
|
+
showOptionOutOfStock = false,
|
|
1634
|
+
triggerPropAdditional,
|
|
1635
|
+
sourceApp = null,
|
|
1636
|
+
onAfterAddToCart,
|
|
1637
|
+
onAfterAddWishlist,
|
|
1638
|
+
onAfterRemoveWishlist,
|
|
1639
|
+
onAfterRenderProduct
|
|
1640
|
+
}) => {
|
|
1641
|
+
const {
|
|
1642
|
+
show_vendor = true,
|
|
1643
|
+
show_sku = true,
|
|
1644
|
+
show_price = true,
|
|
1645
|
+
show_add_to_cart = true,
|
|
1646
|
+
redirect_add_to_cart = true,
|
|
1647
|
+
language_button_add_to_cart = "Add To Cart",
|
|
1648
|
+
display_product_name_style = {},
|
|
1649
|
+
display_price_style = {},
|
|
1650
|
+
display_button_add_to_cart_style = {}
|
|
1651
|
+
} = setting || {};
|
|
1652
|
+
let {
|
|
1653
|
+
image: productCardImage = false,
|
|
1654
|
+
outStock: productCardOutStock = "",
|
|
1655
|
+
title: productCardTitle = "",
|
|
1656
|
+
price: productCardPrice = "",
|
|
1657
|
+
text: productCardText = "",
|
|
1658
|
+
rating: productCardRating = false,
|
|
1659
|
+
buttonAddToCart: productCardButtonAddToCart = ""
|
|
1660
|
+
} = customProductCard || {};
|
|
1661
|
+
const [clickedAddToCartId, setClickedAddToCartId] = React__default.useState(null);
|
|
1662
|
+
const handleAddToCart = async (data2) => {
|
|
1663
|
+
var _a;
|
|
1664
|
+
const { id, quantity } = data2;
|
|
1665
|
+
setClickedAddToCartId(id);
|
|
1666
|
+
let resShopifyAddToCart = await addToCart([
|
|
1667
|
+
{
|
|
1668
|
+
id,
|
|
1669
|
+
quantity
|
|
1670
|
+
}
|
|
1671
|
+
]);
|
|
1672
|
+
if ((_a = resShopifyAddToCart == null ? void 0 : resShopifyAddToCart.items) == null ? void 0 : _a.length) {
|
|
1673
|
+
if (sourceApp === "wishlist") {
|
|
1674
|
+
await addToCartTrigger$1({
|
|
1675
|
+
productId: id
|
|
1676
|
+
});
|
|
1677
|
+
} else if (sourceApp === "instant-search") {
|
|
1678
|
+
await addToCartTrigger({
|
|
1679
|
+
productId: id
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
setClickedAddToCartId(null);
|
|
1683
|
+
onAfterAddToCart && onAfterAddToCart("success");
|
|
1684
|
+
if (redirect_add_to_cart) {
|
|
1685
|
+
window.location.href = "/cart";
|
|
1686
|
+
} else {
|
|
1687
|
+
window.sledgeToastNotification({
|
|
1688
|
+
title: "Cart added",
|
|
1689
|
+
message: "Successfully added to wishlist",
|
|
1690
|
+
type: "success",
|
|
1691
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 40, height: 40, color: "black" })
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
} else {
|
|
1695
|
+
onAfterAddToCart && onAfterAddToCart("failed");
|
|
1696
|
+
setTimeout(() => {
|
|
1697
|
+
var _a2;
|
|
1698
|
+
setClickedAddToCartId(null);
|
|
1699
|
+
if (typeof window !== "undefined" && window.sledgeToastNotification)
|
|
1700
|
+
window.sledgeToastNotification({
|
|
1701
|
+
title: "Failed",
|
|
1702
|
+
message: ((_a2 = resShopifyAddToCart == null ? void 0 : resShopifyAddToCart.description) == null ? void 0 : _a2.length) ? resShopifyAddToCart.description : "failed add to cart, please try again",
|
|
1703
|
+
type: "failed",
|
|
1704
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 40, height: 40, color: "black" })
|
|
1705
|
+
});
|
|
1706
|
+
}, 1e3);
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
React__default.useEffect(() => {
|
|
1710
|
+
onAfterRenderProduct && onAfterRenderProduct("success");
|
|
1711
|
+
}, []);
|
|
1712
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__product-grid ${className}`, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
|
|
1713
|
+
var _a;
|
|
1714
|
+
const { product, variants } = item || {};
|
|
1715
|
+
const { id, title, image, url, vendor = "", currency } = product || {};
|
|
1716
|
+
const { id: variant_id = "", title: variant_title = "", price = "", sku = "" } = (variants == null ? void 0 : variants.length) ? variants[0] : {};
|
|
1717
|
+
let totalStock = ((_a = variants == null ? void 0 : variants.map(({ inventory_quantity }) => inventory_quantity)) == null ? void 0 : _a.reduce((a, b) => a + b, 0)) || 0;
|
|
1718
|
+
let isLoadingAddToCart = clickedAddToCartId == variant_id;
|
|
1719
|
+
let isOutOfStock = !totalStock && showOptionOutOfStock && productCardOutStock;
|
|
1720
|
+
if (customProductCard && Object.keys(customProductCard).length) {
|
|
1721
|
+
productCardTitle = productCardTitle ? replaceString(productCardTitle, [OBJECT_DATA_STRING_KEY.PRODUCT.TITLE], [title]) : productCardTitle;
|
|
1722
|
+
productCardPrice = productCardPrice ? replaceString(productCardPrice, [OBJECT_DATA_STRING_KEY.PRODUCT.CURRENCY, OBJECT_DATA_STRING_KEY.PRODUCT.PRICE], [currency, price]) : productCardPrice;
|
|
1723
|
+
productCardText = productCardText ? replaceString(
|
|
1724
|
+
productCardText,
|
|
1725
|
+
[OBJECT_DATA_STRING_KEY.PRODUCT.VARIANT_TITLE, OBJECT_DATA_STRING_KEY.PRODUCT.VENDOR, OBJECT_DATA_STRING_KEY.PRODUCT.SKU],
|
|
1726
|
+
[variant_title, vendor, sku]
|
|
1727
|
+
) : productCardText;
|
|
1728
|
+
} else {
|
|
1729
|
+
productCardImage = true;
|
|
1730
|
+
productCardOutStock = "Sold out";
|
|
1731
|
+
productCardTitle = title;
|
|
1732
|
+
productCardPrice = `${currency}${price}`;
|
|
1733
|
+
productCardText = `
|
|
1734
|
+
<div>${variant_title}</div>
|
|
1735
|
+
<div>Vendor: ${vendor} | SKU: ${sku}</div>`;
|
|
1736
|
+
productCardRating = true;
|
|
1737
|
+
productCardButtonAddToCart = `
|
|
1738
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1739
|
+
<path
|
|
1740
|
+
fill-rule="evenodd"
|
|
1741
|
+
clip-rule="evenodd"
|
|
1742
|
+
d="M8.83562 1.50023C10.796 1.50023 12.4155 2.99397 12.6152 4.90442L12.6709 4.90507C13.7584 4.90507 15.0806 5.62732 15.5269 7.65307L16.1186 12.2333C16.3309 13.7116 16.0654 14.8973 15.3281 15.7478C14.5946 16.5938 13.4336 17.0416 11.9704 17.0416H5.7094C4.10215 17.0416 2.9824 16.6478 2.28565 15.8386C1.5859 15.0271 1.3519 13.8098 1.5904 12.2213L2.1724 7.70182C2.5549 5.62957 3.95365 4.90507 5.03665 4.90507C5.13014 4.04293 5.51889 3.22275 6.13562 2.60797C6.84437 1.90372 7.82162 1.50023 8.81987 1.50023H8.83562ZM12.6709 6.03007H5.03665C4.7059 6.03007 3.6004 6.16357 3.28315 7.87657L2.70415 12.3766C2.5159 13.6388 2.6614 14.5523 3.13765 15.1051C3.6079 15.6511 4.4494 15.9166 5.7094 15.9166H11.9704C12.7564 15.9166 13.8296 15.7598 14.4776 15.0113C14.9921 14.4181 15.1691 13.5346 15.0041 12.3848L14.4199 7.84582C14.1709 6.72757 13.5139 6.03007 12.6709 6.03007ZM11.023 8.11815C11.3335 8.11815 11.6027 8.37015 11.6027 8.68065C11.6027 8.99115 11.368 9.24315 11.0575 9.24315H11.023C10.7125 9.24315 10.4605 8.99115 10.4605 8.68065C10.4605 8.37015 10.7125 8.11815 11.023 8.11815ZM6.65042 8.11815C6.96092 8.11815 7.23017 8.37015 7.23017 8.68065C7.23017 8.99115 6.99467 9.24315 6.68417 9.24315H6.65042C6.33992 9.24315 6.08792 8.99115 6.08792 8.68065C6.08792 8.37015 6.33992 8.11815 6.65042 8.11815ZM8.83337 2.62522H8.82212C8.11637 2.62522 7.42862 2.90947 6.92987 3.40522C6.5236 3.80967 6.25789 4.34137 6.17193 4.90472L11.4814 4.90493C11.2887 3.61626 10.1743 2.62522 8.83337 2.62522Z"
|
|
1743
|
+
fill="#393D4E"
|
|
1744
|
+
></path></svg
|
|
1745
|
+
><span>Add To Cart</span>`;
|
|
1746
|
+
}
|
|
1747
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
|
|
1748
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
|
|
1749
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image", children: [
|
|
1750
|
+
productCardImage ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1751
|
+
"a",
|
|
1752
|
+
{
|
|
1753
|
+
href: url,
|
|
1754
|
+
onClick: () => sourceApp === "instant-search" && productClickTrigger({
|
|
1755
|
+
productId: id
|
|
1756
|
+
}),
|
|
1757
|
+
children: [
|
|
1758
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1759
|
+
Trigger,
|
|
1760
|
+
{
|
|
1761
|
+
data: {
|
|
1762
|
+
productId: id,
|
|
1763
|
+
productVariantId: variant_id,
|
|
1764
|
+
productName: title,
|
|
1765
|
+
productVendor: vendor,
|
|
1766
|
+
productSku: sku,
|
|
1767
|
+
productVariantName: variant_title,
|
|
1768
|
+
productLink: url,
|
|
1769
|
+
productImage: (image == null ? void 0 : image.src) || `${API_URL}/img/blank-image.png`,
|
|
1770
|
+
productCurrency: currency,
|
|
1771
|
+
productPrice: price
|
|
1772
|
+
},
|
|
1773
|
+
...triggerPropAdditional,
|
|
1774
|
+
onAfterAddWishlist,
|
|
1775
|
+
onAfterRemoveWishlist
|
|
1776
|
+
}
|
|
1777
|
+
),
|
|
1778
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (image == null ? void 0 : image.src) || "", alt: "sledge-product-card-image", loading: "lazy", onError: (event) => event.currentTarget.src = `${API_URL}/img/blank-image.png` })
|
|
1779
|
+
]
|
|
1780
|
+
}
|
|
1781
|
+
) : null,
|
|
1782
|
+
isOutOfStock ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-out-of-stock", dangerouslySetInnerHTML: { __html: productCardOutStock } }) : null
|
|
1783
|
+
] }),
|
|
1784
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc", children: [
|
|
1785
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-title", children: [
|
|
1786
|
+
productCardTitle ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1787
|
+
"a",
|
|
1788
|
+
{
|
|
1789
|
+
href: url,
|
|
1790
|
+
onClick: () => sourceApp === "instant-search" && productClickTrigger({
|
|
1791
|
+
productId: id
|
|
1792
|
+
}),
|
|
1793
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { style: display_product_name_style, dangerouslySetInnerHTML: { __html: productCardTitle } })
|
|
1794
|
+
}
|
|
1795
|
+
) }) : null,
|
|
1796
|
+
show_price && productCardPrice ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-price", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { style: display_price_style, dangerouslySetInnerHTML: { __html: productCardPrice } }) }) : null
|
|
1797
|
+
] }),
|
|
1798
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-text", dangerouslySetInnerHTML: { __html: productCardText } }),
|
|
1799
|
+
productCardRating ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-rating", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1800
|
+
Rating,
|
|
1801
|
+
{
|
|
1802
|
+
data: {
|
|
1803
|
+
productId: id
|
|
1804
|
+
},
|
|
1805
|
+
size: "xs",
|
|
1806
|
+
withSkeletonLoading: false
|
|
1807
|
+
}
|
|
1808
|
+
) }) : null
|
|
1809
|
+
] })
|
|
1810
|
+
] }),
|
|
1811
|
+
show_add_to_cart && productCardButtonAddToCart ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1812
|
+
Button,
|
|
1813
|
+
{
|
|
1814
|
+
type: "button",
|
|
1815
|
+
colorType: "light",
|
|
1816
|
+
style: {
|
|
1817
|
+
...display_button_add_to_cart_style,
|
|
1818
|
+
...isLoadingAddToCart && {
|
|
1819
|
+
cursor: "wait"
|
|
1820
|
+
}
|
|
1821
|
+
},
|
|
1822
|
+
dangerouslySetInnerHTML: { __html: isLoadingAddToCart ? "Adding..." : isOutOfStock ? "Sold out" : productCardButtonAddToCart },
|
|
1823
|
+
...isLoadingAddToCart || isOutOfStock ? {
|
|
1824
|
+
disabled: true
|
|
1825
|
+
} : {
|
|
1826
|
+
onClick: () => handleAddToCart({
|
|
1827
|
+
id: variant_id,
|
|
1828
|
+
quantity: 1
|
|
1829
|
+
})
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
) }) : null
|
|
1833
|
+
] }, index);
|
|
1834
|
+
}) });
|
|
1835
|
+
};
|
|
1836
|
+
const TextAreaField = "";
|
|
1837
|
+
const InputField = "";
|
|
1838
|
+
const CollectionGrid$1 = "";
|
|
1839
|
+
const CollectionGrid = ({ className = "", data }) => {
|
|
1840
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !(data == null ? void 0 : data.length) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__collection-grid ${className}`, children: data.map((item, index) => {
|
|
1841
|
+
const { id, title, description, url, image } = item;
|
|
1842
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__collection-grid-card", children: [
|
|
1843
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1844
|
+
"img",
|
|
1845
|
+
{
|
|
1846
|
+
src: image || `${API_URL}/img/blank-image.png`,
|
|
1847
|
+
alt: "sledge-product-card-image",
|
|
1848
|
+
loading: "lazy",
|
|
1849
|
+
onError: (event) => event.currentTarget.src = `${API_URL}/img/blank-image.png`
|
|
1850
|
+
}
|
|
1851
|
+
) }),
|
|
1852
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__collection-grid-card-content", children: [
|
|
1853
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__collection-grid-card-text", children: [
|
|
1854
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-content-title", children: title }),
|
|
1855
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-content-description", children: description })
|
|
1856
|
+
] }),
|
|
1857
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-content-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "button", colorType: "success", elementType: "hyperlink", link: url, children: "Shop Now" }) })
|
|
1858
|
+
] })
|
|
1859
|
+
] }, index);
|
|
1860
|
+
}) }) });
|
|
1861
|
+
};
|
|
1862
|
+
const PageGrid$1 = "";
|
|
1863
|
+
const PageGrid = ({ className = "", data }) => {
|
|
1864
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !(data == null ? void 0 : data.length) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__page-grid ${className}`, children: data.map((item, index) => {
|
|
1865
|
+
const { id, title, description, url, image } = item;
|
|
1866
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__page-grid-card", children: [
|
|
1867
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1868
|
+
"img",
|
|
1869
|
+
{
|
|
1870
|
+
src: image || `${API_URL}/img/blank-image.png`,
|
|
1871
|
+
alt: "sledge-product-card-image",
|
|
1872
|
+
loading: "lazy",
|
|
1873
|
+
onError: (event) => event.currentTarget.src = `${API_URL}/img/blank-image.png`
|
|
1874
|
+
}
|
|
1875
|
+
) }),
|
|
1876
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__page-grid-card-content", children: [
|
|
1877
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-content-title", children: title }),
|
|
1878
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-content-description", children: description })
|
|
1879
|
+
] })
|
|
1880
|
+
] }) }, index);
|
|
1881
|
+
}) }) });
|
|
1882
|
+
};
|
|
1883
|
+
const BlogGrid$1 = "";
|
|
1884
|
+
const BlogGrid = ({ className = "", data }) => {
|
|
1885
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !(data == null ? void 0 : data.length) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__blog-grid ${className}`, children: data == null ? void 0 : data.map((item, index) => {
|
|
1886
|
+
const { id, title, date, description, url, image } = item;
|
|
1887
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__blog-grid-card", children: [
|
|
1888
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__blog-grid-content", children: [
|
|
1889
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1890
|
+
"img",
|
|
1891
|
+
{
|
|
1892
|
+
src: image || `${API_URL}/img/blank-image.png`,
|
|
1893
|
+
alt: "sledge-blog-card-image",
|
|
1894
|
+
loading: "lazy",
|
|
1895
|
+
onError: (event) => event.currentTarget.src = `${API_URL}/img/blank-image.png`
|
|
1896
|
+
}
|
|
1897
|
+
) }) }),
|
|
1898
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__blog-grid-card-desc", children: [
|
|
1899
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card-title", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: title }) }) }) }),
|
|
1900
|
+
!(date == null ? void 0 : date.length) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card-date", children: date }),
|
|
1901
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card-text", children: description })
|
|
1902
|
+
] })
|
|
1903
|
+
] }),
|
|
1904
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "button", colorType: "light", elementType: "hyperlink", link: url, children: "Learn More" }) })
|
|
1905
|
+
] }, index);
|
|
1906
|
+
}) }) });
|
|
1907
|
+
};
|
|
1908
|
+
const Tooltip$1 = "";
|
|
1909
|
+
const Tooltip = ({ children, content, withArrow = true, customArrow = "", sideOffset = 5, alignOffset = 0, wrapTrigger = true }) => {
|
|
1910
|
+
const [open, setOpen] = React__default.useState(false);
|
|
1911
|
+
React__default.useEffect(() => {
|
|
1912
|
+
var _a;
|
|
1913
|
+
let arrowElement = (_a = document == null ? void 0 : document.querySelector(".sledge__tooltip-arrow")) == null ? void 0 : _a.parentElement;
|
|
1914
|
+
if (arrowElement && (customArrow == null ? void 0 : customArrow.length)) {
|
|
1915
|
+
arrowElement.classList.add("sledge__tooltip-arrow-parent");
|
|
1916
|
+
arrowElement.innerHTML = customArrow;
|
|
1917
|
+
}
|
|
1918
|
+
}, [open]);
|
|
1919
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$2881499e37b75b9a, { delayDuration: 0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs($a093c7e1ec25a057$export$be92b6f5f03c0fe9, { onOpenChange: setOpen, children: [
|
|
1920
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$41fb9f06171c75f4, { asChild: true, children: wrapTrigger ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children }) : children }),
|
|
1921
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs($a093c7e1ec25a057$export$7c6e2c02157bb7d2, { className: "sledge__tooltip-content", sideOffset, alignOffset, children: [
|
|
1922
|
+
content,
|
|
1923
|
+
withArrow ? /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$21b07c8f274aebd5, { className: "sledge__tooltip-arrow" }) : null
|
|
1924
|
+
] }) })
|
|
1925
|
+
] }) });
|
|
1926
|
+
};
|
|
1927
|
+
const ScrollArea$1 = "";
|
|
1928
|
+
const ScrollArea = ({ children, isLoading = false, className = "", withCorner = true }) => {
|
|
1929
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs($57acba87d6e25586$export$be92b6f5f03c0fe9, { className: `sledge__scroll-area-root ${className}`, children: [
|
|
1930
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($57acba87d6e25586$export$d5c6c08dc2d3ca7, { className: `sledge__scroll-area-viewport ${isLoading ? "sledge__scroll-area-viewport-loading" : ""}`, children }),
|
|
1931
|
+
!isLoading && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1932
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($57acba87d6e25586$export$9a4e88b92edfce6b, { className: "sledge__scroll-area-scrollbar", orientation: "vertical", children: /* @__PURE__ */ jsxRuntimeExports.jsx($57acba87d6e25586$export$6521433ed15a34db, { className: "sledge__scroll-area-thumb" }) }),
|
|
1933
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($57acba87d6e25586$export$9a4e88b92edfce6b, { className: "sledge__scroll-area-scrollbar", orientation: "horizontal", children: /* @__PURE__ */ jsxRuntimeExports.jsx($57acba87d6e25586$export$6521433ed15a34db, { className: "sledge__scroll-area-thumb" }) }),
|
|
1934
|
+
withCorner && /* @__PURE__ */ jsxRuntimeExports.jsx($57acba87d6e25586$export$ac61190d9fc311a9, { className: "sledge__scroll-area-corner" })
|
|
1935
|
+
] })
|
|
1936
|
+
] });
|
|
1937
|
+
};
|
|
1938
|
+
const SkeletonLoading$1 = "";
|
|
1939
|
+
const SkeletonItem = ({ width, height, rounded, color, animationDuration = "8s", disableAnimation = false, style = {}, className = "", ...otherProps }) => {
|
|
1940
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1941
|
+
"div",
|
|
1942
|
+
{
|
|
1943
|
+
className: `sledge__skeleton-item ${className} ${!disableAnimation ? "sledge__skeleton-item-animation" : ""}`,
|
|
1944
|
+
style: {
|
|
1945
|
+
...{
|
|
1946
|
+
width,
|
|
1947
|
+
height,
|
|
1948
|
+
WebkitAnimationDuration: animationDuration,
|
|
1949
|
+
animationDuration
|
|
1950
|
+
},
|
|
1951
|
+
...style
|
|
1952
|
+
},
|
|
1953
|
+
"data-skeleton-rounded": rounded,
|
|
1954
|
+
"data-skeleton-color": color,
|
|
1955
|
+
...otherProps
|
|
1956
|
+
}
|
|
1957
|
+
);
|
|
1958
|
+
};
|
|
1959
|
+
const SkeletonProductGrid = ({ count, type }) => {
|
|
1960
|
+
let components = [];
|
|
1961
|
+
for (let i = 0; i < count; i++) {
|
|
1962
|
+
components.push(
|
|
1963
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
|
|
1964
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
|
|
1965
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image sledge__skeleton-product-grid-card-image", children: [
|
|
1966
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__trigger-block", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "40px", height: "40px", color: "grey-300", rounded: "sm", disableAnimation: true }) }),
|
|
1967
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "100%", height: "100%", color: "grey-100", rounded: "md" })
|
|
1968
|
+
] }),
|
|
1969
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-desc", children: [
|
|
1970
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-title", children: [
|
|
1971
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "134px", height: "28px", color: "grey-100", rounded: "md", animationDuration: "15s" }),
|
|
1972
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "80px", height: "28px", color: "grey-100", rounded: "md", animationDuration: "20s" })
|
|
1973
|
+
] }),
|
|
1974
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-text", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1975
|
+
SkeletonItem,
|
|
1976
|
+
{
|
|
1977
|
+
width: "190px",
|
|
1978
|
+
height: "46px",
|
|
1979
|
+
color: "grey-100",
|
|
1980
|
+
rounded: "md",
|
|
1981
|
+
animationDuration: "13s",
|
|
1982
|
+
style: {
|
|
1983
|
+
marginBottom: "16px"
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
) })
|
|
1987
|
+
] })
|
|
1988
|
+
] }),
|
|
1989
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "117px", height: "40px", color: "grey-100", rounded: "md", animationDuration: "15s" }) })
|
|
1990
|
+
] }, i)
|
|
1991
|
+
);
|
|
1992
|
+
}
|
|
1993
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid sledge__skeleton-product-grid sledge__skeleton-pointer-events-none", "data-grid-type": type, children: components });
|
|
1994
|
+
};
|
|
1995
|
+
const SkeletonReviewGrid = ({ count, type, gridItemHeights = [] }) => {
|
|
1996
|
+
let components = [];
|
|
1997
|
+
for (let i = 0; i < count; i++) {
|
|
1998
|
+
components.push(
|
|
1999
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-review-card", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2000
|
+
SkeletonItem,
|
|
2001
|
+
{
|
|
2002
|
+
width: "100%",
|
|
2003
|
+
height: type === "list" || type === "grid" && !(gridItemHeights == null ? void 0 : gridItemHeights.length) ? "111px" : gridItemHeights[i],
|
|
2004
|
+
color: "grey-100",
|
|
2005
|
+
rounded: "md",
|
|
2006
|
+
animationDuration: type === "list" ? "2.5s" : "8s"
|
|
2007
|
+
}
|
|
2008
|
+
) }, i)
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2012
|
+
MasonryResponsive,
|
|
2013
|
+
{
|
|
2014
|
+
columnsCountBreakPoints: type === "grid" ? { 350: 1, 750: 3, 1024: 4 } : { 350: 1 },
|
|
2015
|
+
className: "sledge-product-review__widget-review-grid sledge__skeleton-review-grid sledge__skeleton-pointer-events-none",
|
|
2016
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Masonry, { gutter: "30px", children: components })
|
|
2017
|
+
}
|
|
2018
|
+
);
|
|
2019
|
+
};
|
|
2020
|
+
const SkeletonCollectionGrid = ({ count }) => {
|
|
2021
|
+
let components = [];
|
|
2022
|
+
for (let i = 0; i < count; i++) {
|
|
2023
|
+
components.push(
|
|
2024
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__collection-grid-card", children: [
|
|
2025
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "246px", height: "246px", color: "grey-300", rounded: "md" }) }),
|
|
2026
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__collection-grid-card-content", children: [
|
|
2027
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__collection-grid-card-text", children: [
|
|
2028
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-content-title", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "100%", height: "70px", color: "grey-300", rounded: "lg" }) }),
|
|
2029
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-content-description", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2030
|
+
SkeletonItem,
|
|
2031
|
+
{
|
|
2032
|
+
width: "100%",
|
|
2033
|
+
height: "47px",
|
|
2034
|
+
color: "grey-300",
|
|
2035
|
+
rounded: "md",
|
|
2036
|
+
style: {
|
|
2037
|
+
maxWidth: "357px"
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
) })
|
|
2041
|
+
] }),
|
|
2042
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid-card-content-button-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2043
|
+
SkeletonItem,
|
|
2044
|
+
{
|
|
2045
|
+
width: "100%",
|
|
2046
|
+
height: "40px",
|
|
2047
|
+
color: "grey-300",
|
|
2048
|
+
rounded: "md",
|
|
2049
|
+
animationDuration: "20s",
|
|
2050
|
+
style: {
|
|
2051
|
+
maxWidth: "117px"
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
) })
|
|
2055
|
+
] })
|
|
2056
|
+
] }, i)
|
|
2057
|
+
);
|
|
2058
|
+
}
|
|
2059
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__collection-grid sledge__skeleton-collection-grid sledge__skeleton-pointer-events-none", children: components });
|
|
2060
|
+
};
|
|
2061
|
+
const SkeletonPageGrid = ({ count }) => {
|
|
2062
|
+
let components = [];
|
|
2063
|
+
for (let i = 0; i < count; i++) {
|
|
2064
|
+
components.push(
|
|
2065
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__page-grid-card", children: [
|
|
2066
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2067
|
+
SkeletonItem,
|
|
2068
|
+
{
|
|
2069
|
+
width: "100%",
|
|
2070
|
+
height: "100%",
|
|
2071
|
+
color: "grey-300",
|
|
2072
|
+
rounded: "md",
|
|
2073
|
+
animationDuration: "13s",
|
|
2074
|
+
style: {
|
|
2075
|
+
borderTopRightRadius: 0,
|
|
2076
|
+
borderBottomRightRadius: 0
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
) }),
|
|
2080
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__page-grid-card-content", children: [
|
|
2081
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-content-title", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "100%", height: "40px", color: "grey-300", rounded: "md", animationDuration: "6s" }) }),
|
|
2082
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid-card-content-description", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2083
|
+
SkeletonItem,
|
|
2084
|
+
{
|
|
2085
|
+
width: "100%",
|
|
2086
|
+
height: "40px",
|
|
2087
|
+
color: "grey-300",
|
|
2088
|
+
rounded: "md",
|
|
2089
|
+
animationDuration: "17s",
|
|
2090
|
+
style: {
|
|
2091
|
+
maxWidth: "115px"
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
) })
|
|
2095
|
+
] })
|
|
2096
|
+
] }, i)
|
|
2097
|
+
);
|
|
2098
|
+
}
|
|
2099
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__page-grid sledge__skeleton-page-grid sledge__skeleton-pointer-events-none", children: components });
|
|
2100
|
+
};
|
|
2101
|
+
const SkeletonBlogGrid = ({ count }) => {
|
|
2102
|
+
let components = [];
|
|
2103
|
+
for (let i = 0; i < count; i++) {
|
|
2104
|
+
components.push(
|
|
2105
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__blog-grid-content", children: [
|
|
2106
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid-card-image", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonItem, { width: "100%", height: "100%", color: "grey-100", rounded: "md", animationDuration: "10s" }) }),
|
|
2107
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__blog-grid-card-desc", children: [
|
|
2108
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2109
|
+
SkeletonItem,
|
|
2110
|
+
{
|
|
2111
|
+
width: "100%",
|
|
2112
|
+
height: "28px",
|
|
2113
|
+
color: "grey-100",
|
|
2114
|
+
rounded: "md",
|
|
2115
|
+
style: {
|
|
2116
|
+
maxWidth: "242px",
|
|
2117
|
+
marginTop: "26px",
|
|
2118
|
+
marginBottom: "12px"
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
),
|
|
2122
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2123
|
+
SkeletonItem,
|
|
2124
|
+
{
|
|
2125
|
+
width: "100%",
|
|
2126
|
+
height: "28px",
|
|
2127
|
+
color: "grey-100",
|
|
2128
|
+
rounded: "md",
|
|
2129
|
+
animationDuration: "23s",
|
|
2130
|
+
style: {
|
|
2131
|
+
maxWidth: "80px",
|
|
2132
|
+
marginBottom: "27px"
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
),
|
|
2136
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2137
|
+
SkeletonItem,
|
|
2138
|
+
{
|
|
2139
|
+
width: "100%",
|
|
2140
|
+
height: "80px",
|
|
2141
|
+
color: "grey-100",
|
|
2142
|
+
rounded: "md",
|
|
2143
|
+
animationDuration: "13s",
|
|
2144
|
+
style: {
|
|
2145
|
+
maxWidth: "190px",
|
|
2146
|
+
marginBottom: "27px"
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
),
|
|
2150
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2151
|
+
SkeletonItem,
|
|
2152
|
+
{
|
|
2153
|
+
width: "100%",
|
|
2154
|
+
height: "40px",
|
|
2155
|
+
color: "grey-100",
|
|
2156
|
+
rounded: "md",
|
|
2157
|
+
animationDuration: "20s",
|
|
2158
|
+
style: {
|
|
2159
|
+
maxWidth: "117px"
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
)
|
|
2163
|
+
] })
|
|
2164
|
+
] }) }, i)
|
|
2165
|
+
);
|
|
2166
|
+
}
|
|
2167
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__blog-grid sledge__skeleton-blog-grid sledge__skeleton-pointer-events-none", children: components });
|
|
2168
|
+
};
|
|
2169
|
+
const SkeletonLoading = {
|
|
2170
|
+
Item: SkeletonItem,
|
|
2171
|
+
ReviewGrid: SkeletonReviewGrid,
|
|
2172
|
+
ProductGrid: SkeletonProductGrid,
|
|
2173
|
+
CollectionGrid: SkeletonCollectionGrid,
|
|
2174
|
+
PageGrid: SkeletonPageGrid,
|
|
2175
|
+
BlogGrid: SkeletonBlogGrid
|
|
2176
|
+
};
|
|
2177
|
+
const SearchIconWidget = (props) => {
|
|
2178
|
+
const { size = "sm", customProductCard, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props || {};
|
|
2179
|
+
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
2180
|
+
const [sizing, setSizing] = React__default.useState({
|
|
2181
|
+
width: 0,
|
|
2182
|
+
height: 0
|
|
2183
|
+
});
|
|
2184
|
+
React__default.useEffect(() => {
|
|
2185
|
+
if (!(isRenderApp == null ? void 0 : isRenderApp.instantSearch))
|
|
2186
|
+
return;
|
|
2187
|
+
if (size === "xs") {
|
|
2188
|
+
setSizing({
|
|
2189
|
+
width: 14,
|
|
2190
|
+
height: 14
|
|
2191
|
+
});
|
|
2192
|
+
} else if (size === "sm") {
|
|
2193
|
+
setSizing({
|
|
2194
|
+
width: 20,
|
|
2195
|
+
height: 20
|
|
2196
|
+
});
|
|
2197
|
+
} else {
|
|
2198
|
+
setSizing({
|
|
2199
|
+
width: 25,
|
|
2200
|
+
height: 25
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
}, [isRenderApp]);
|
|
2204
|
+
const handleShowWidget = () => {
|
|
2205
|
+
if (typeof window !== "undefined" && window.sledgeInstantSearchIconWidgetPopup)
|
|
2206
|
+
window.sledgeInstantSearchIconWidgetPopup(customProductCard, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct);
|
|
2207
|
+
};
|
|
2208
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__icon-widget", onClick: handleShowWidget, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { ...sizing, color: "currentColor" }) });
|
|
2209
|
+
};
|
|
2210
|
+
const SearchIconWidgetPopup$1 = "";
|
|
2211
|
+
const SearchIconWidgetPopup = () => {
|
|
2212
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
2213
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
2214
|
+
const [showInfo, setShowInfo] = React__default.useState(false);
|
|
2215
|
+
const [keyword, setKeyword] = React__default.useState("");
|
|
2216
|
+
const [suffixIndexProduct, setSuffixIndexProduct] = React__default.useState("");
|
|
2217
|
+
const [searchResultProduct, setSearchResultProduct] = React__default.useState([]);
|
|
2218
|
+
const [searchResultOther, setSearchResultOther] = React__default.useState([]);
|
|
2219
|
+
const [allowedTabs, setAllowedTabs] = React__default.useState([]);
|
|
2220
|
+
const [hiddenTags, setHiddenTags] = React__default.useState([]);
|
|
2221
|
+
const [displaySettings, setDisplaySettings] = React__default.useState({});
|
|
2222
|
+
const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
|
|
2223
|
+
const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
|
|
2224
|
+
const [handleFunctions, setHandleFunctions] = React__default.useState({
|
|
2225
|
+
onAfterAddToCart: (state) => {
|
|
2226
|
+
},
|
|
2227
|
+
onAfterAddWishlist: (state) => {
|
|
2228
|
+
},
|
|
2229
|
+
onAfterRemoveWishlist: (state) => {
|
|
2230
|
+
},
|
|
2231
|
+
onAfterRenderProduct: (state) => {
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
const [customProductCard, setCustomProductCard] = React__default.useState({});
|
|
2235
|
+
const searchFieldRef = React__default.useRef(null);
|
|
2236
|
+
const previousState = usePrevious({ keyword });
|
|
2237
|
+
const handleMultiSearch = async (data, onSearch = false) => {
|
|
2238
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
|
|
2239
|
+
if (!showInfo)
|
|
2240
|
+
return;
|
|
2241
|
+
setIsLoading(true);
|
|
2242
|
+
const { tabs, suffix_index_product, hidden_tags, display } = data;
|
|
2243
|
+
const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
|
|
2244
|
+
let response;
|
|
2245
|
+
let body = {
|
|
2246
|
+
queries: tabs.map((tab) => {
|
|
2247
|
+
var _a3;
|
|
2248
|
+
const { index } = tab;
|
|
2249
|
+
let isProductIndex = index.includes(suffix_index_product);
|
|
2250
|
+
let additionalFilter = [];
|
|
2251
|
+
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
2252
|
+
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
2253
|
+
if (!((_a3 = display == null ? void 0 : display.filter) == null ? void 0 : _a3.show_out_of_stock))
|
|
2254
|
+
additionalFilter.push("variants.inventory_quantity > 0");
|
|
2255
|
+
return {
|
|
2256
|
+
indexUid: index,
|
|
2257
|
+
q: keyword,
|
|
2258
|
+
hitsPerPage: isProductIndex ? 6 : 4,
|
|
2259
|
+
filter: isProductIndex ? additionalFilter.join(" AND ") : ""
|
|
2260
|
+
};
|
|
2261
|
+
})
|
|
2262
|
+
};
|
|
2263
|
+
response = await multiSearch(body);
|
|
2264
|
+
if (!response)
|
|
2265
|
+
return;
|
|
2266
|
+
const { results } = response;
|
|
2267
|
+
let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(suffix_index_product));
|
|
2268
|
+
if (onSearch && (keyword == null ? void 0 : keyword.length)) {
|
|
2269
|
+
searchTrigger({
|
|
2270
|
+
keyword,
|
|
2271
|
+
resultCount: ((_b2 = valueSearchResultProduct[0]) == null ? void 0 : _b2.totalHits) || 0
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2274
|
+
let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(suffix_index_product)))) == null ? void 0 : _c2.map((result) => {
|
|
2275
|
+
const { indexUid } = result;
|
|
2276
|
+
const { name } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
|
|
2277
|
+
return {
|
|
2278
|
+
...result,
|
|
2279
|
+
...{
|
|
2280
|
+
name: name || ""
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
})) || [];
|
|
2284
|
+
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_d2 = valueSearchResultProduct[0]) == null ? void 0 : _d2.hits : [];
|
|
2285
|
+
let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
|
|
2286
|
+
let isPriorityZeroCharacter = Boolean(
|
|
2287
|
+
!keyword.length && Object.keys(suggestion).length && ((_f2 = (_e2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _e2.products) == null ? void 0 : _f2.active) && ((_i2 = (_h2 = (_g2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _g2.products) == null ? void 0 : _h2.list) == null ? void 0 : _i2.length)
|
|
2288
|
+
);
|
|
2289
|
+
setSearchResultProduct(isPriorityZeroCharacter ? (_k2 = (_j2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _j2.products) == null ? void 0 : _k2.list : getValueSearchResultProduct);
|
|
2290
|
+
setSearchResultOther(valueSearchResultOther);
|
|
2291
|
+
setSuggestionIndex(valueSuggestionIndex);
|
|
2292
|
+
setIsLoading(false);
|
|
2293
|
+
};
|
|
2294
|
+
const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
|
|
2295
|
+
var _a2;
|
|
2296
|
+
if (!showInfo)
|
|
2297
|
+
return;
|
|
2298
|
+
let response;
|
|
2299
|
+
let run = false;
|
|
2300
|
+
response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
2301
|
+
if (!response)
|
|
2302
|
+
return;
|
|
2303
|
+
const { status, data } = response;
|
|
2304
|
+
const { code } = status;
|
|
2305
|
+
const { tabs, suffix_index_product, hidden_tags, display } = data;
|
|
2306
|
+
run = code === 200 || false;
|
|
2307
|
+
if (run) {
|
|
2308
|
+
setAllowedTabs(tabs);
|
|
2309
|
+
setSuffixIndexProduct(suffix_index_product);
|
|
2310
|
+
setHiddenTags(hidden_tags);
|
|
2311
|
+
setDisplaySettings(display);
|
|
2312
|
+
setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
|
|
2313
|
+
await handleMultiSearch(data);
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2316
|
+
React__default.useEffect(() => {
|
|
2317
|
+
if (typeof window !== "undefined") {
|
|
2318
|
+
window.sledgeInstantSearchIconWidgetPopup = (customProductCard2 = {}, onAfterAddToCart = () => {
|
|
2319
|
+
}, onAfterAddWishlist = () => {
|
|
2320
|
+
}, onAfterRemoveWishlist = () => {
|
|
2321
|
+
}, onAfterRenderProduct = () => {
|
|
2322
|
+
}) => {
|
|
2323
|
+
setShowInfo(true);
|
|
2324
|
+
setHandleFunctions({
|
|
2325
|
+
onAfterAddToCart,
|
|
2326
|
+
onAfterAddWishlist,
|
|
2327
|
+
onAfterRemoveWishlist,
|
|
2328
|
+
onAfterRenderProduct
|
|
2329
|
+
});
|
|
2330
|
+
setCustomProductCard(customProductCard2);
|
|
2331
|
+
setTimeout(() => {
|
|
2332
|
+
if (searchFieldRef == null ? void 0 : searchFieldRef.current) {
|
|
2333
|
+
searchFieldRef.current.focus();
|
|
2334
|
+
searchFieldRef.current.value = keyword;
|
|
2335
|
+
}
|
|
2336
|
+
}, 500);
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
2340
|
+
}, [showInfo]);
|
|
2341
|
+
React__default.useEffect(() => {
|
|
2342
|
+
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
2343
|
+
const delayDebounceFn = setTimeout(() => {
|
|
2344
|
+
handleMultiSearch({ tabs: allowedTabs, suffix_index_product: suffixIndexProduct, hidden_tags: hiddenTags, display: displaySettings }, true);
|
|
2345
|
+
}, 500);
|
|
2346
|
+
return () => clearTimeout(delayDebounceFn);
|
|
2347
|
+
}
|
|
2348
|
+
}, [keyword]);
|
|
2349
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx($5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, { open: showInfo, onOpenChange: setShowInfo, children: /* @__PURE__ */ jsxRuntimeExports.jsxs($5d3850c4d0b4e6c7$export$602eac185826482c, { children: [
|
|
2350
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, { className: "sledge__popup-overlay" }),
|
|
2351
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, { className: "sledge__popup-overlay-blur" }),
|
|
2352
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs($5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2, { className: "sledge-instant-search__icon-widget-popup-detail-content", "data-layout-type": ((_a = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _a.layout) || "", children: [
|
|
2353
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2354
|
+
SearchInputField,
|
|
2355
|
+
{
|
|
2356
|
+
type: "text",
|
|
2357
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 20, height: 20, color: "#000000" }),
|
|
2358
|
+
placeholder: "Search anything...",
|
|
2359
|
+
value: keyword,
|
|
2360
|
+
fieldRef: searchFieldRef,
|
|
2361
|
+
onChange: ({ value }) => setKeyword(value),
|
|
2362
|
+
className: "sledge-instant-search__icon-widget-search-form-field",
|
|
2363
|
+
withClearField: true
|
|
2364
|
+
}
|
|
2365
|
+
),
|
|
2366
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex", children: [
|
|
2367
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex-item-other sledge-instant-search__icon-widget-search-form-result-flex-item-other-skeleton", children: [0, 1, 2].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(React__default.Fragment, { children: [
|
|
2368
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2369
|
+
SkeletonLoading.Item,
|
|
2370
|
+
{
|
|
2371
|
+
width: "100%",
|
|
2372
|
+
height: "42px",
|
|
2373
|
+
color: "grey-100",
|
|
2374
|
+
rounded: "md",
|
|
2375
|
+
...Boolean(index) && {
|
|
2376
|
+
style: { marginTop: "12px" }
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
),
|
|
2380
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2381
|
+
"div",
|
|
2382
|
+
{
|
|
2383
|
+
style: {
|
|
2384
|
+
display: "flex",
|
|
2385
|
+
flexDirection: "column",
|
|
2386
|
+
justifyContent: "center",
|
|
2387
|
+
gap: "12px",
|
|
2388
|
+
marginTop: "12px"
|
|
2389
|
+
},
|
|
2390
|
+
children: [1, 2, 3].map((index2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2391
|
+
SkeletonLoading.Item,
|
|
2392
|
+
{
|
|
2393
|
+
width: "100%",
|
|
2394
|
+
height: "28px",
|
|
2395
|
+
color: "grey-100",
|
|
2396
|
+
rounded: "md",
|
|
2397
|
+
animationDuration: "13s",
|
|
2398
|
+
style: {
|
|
2399
|
+
maxWidth: "140px"
|
|
2400
|
+
}
|
|
2401
|
+
},
|
|
2402
|
+
index2
|
|
2403
|
+
))
|
|
2404
|
+
}
|
|
2405
|
+
)
|
|
2406
|
+
] }, index)) }),
|
|
2407
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex-item-product", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 6, type: "medium" }) })
|
|
2408
|
+
] }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex", children: [
|
|
2409
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex-item-other", children: [
|
|
2410
|
+
Object.keys(suggestionSettings).length && ((_c = (_b = suggestionSettings[suggestionIndex]) == null ? void 0 : _b.keywords) == null ? void 0 : _c.active) && ((_f = (_e = (_d = suggestionSettings[suggestionIndex]) == null ? void 0 : _d.keywords) == null ? void 0 : _e.list) == null ? void 0 : _f.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2411
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-title", children: "Suggestions" }),
|
|
2412
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__icon-widget-search-form-result-list", children: suggestionSettings[suggestionIndex].keywords.list.map((keyword2, index) => {
|
|
2413
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2414
|
+
"a",
|
|
2415
|
+
{
|
|
2416
|
+
href: `${SEARCH_RESULT_URL}?q=${keyword2}`,
|
|
2417
|
+
className: "sledge-instant-search__icon-widget-search-form-result-list-link sledge-instant-search__icon-widget-search-form-result-list-link-suggestion",
|
|
2418
|
+
children: [
|
|
2419
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 12, height: 12, color: "#677487" }),
|
|
2420
|
+
" ",
|
|
2421
|
+
keyword2
|
|
2422
|
+
]
|
|
2423
|
+
}
|
|
2424
|
+
) }, index);
|
|
2425
|
+
}) })
|
|
2426
|
+
] }) : null,
|
|
2427
|
+
searchResultOther && searchResultOther.map((item, index) => {
|
|
2428
|
+
const { hits, name } = item;
|
|
2429
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(React__default.Fragment, { children: [
|
|
2430
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-title", children: name }),
|
|
2431
|
+
(hits == null ? void 0 : hits.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__icon-widget-search-form-result-list", children: hits.map((hit, index2) => {
|
|
2432
|
+
const { title, url } = hit;
|
|
2433
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, className: "sledge-instant-search__icon-widget-search-form-result-list-link", children: title }) }, index2);
|
|
2434
|
+
}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__icon-widget-search-form-result-list", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "sledge-instant-search__icon-widget-search-form-result-item-disabled", children: [
|
|
2435
|
+
"No ",
|
|
2436
|
+
name.toLowerCase(),
|
|
2437
|
+
" were found"
|
|
2438
|
+
] }) })
|
|
2439
|
+
] }, index);
|
|
2440
|
+
})
|
|
2441
|
+
] }),
|
|
2442
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex-item-product", children: [
|
|
2443
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-product", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2444
|
+
ProductGrid,
|
|
2445
|
+
{
|
|
2446
|
+
sourceApp: "instant-search",
|
|
2447
|
+
type: "medium",
|
|
2448
|
+
data: searchResultProduct.map((item) => {
|
|
2449
|
+
const { id, title, currency, image, url, vendor, variants } = item || {};
|
|
2450
|
+
return {
|
|
2451
|
+
product: {
|
|
2452
|
+
id,
|
|
2453
|
+
title,
|
|
2454
|
+
image,
|
|
2455
|
+
url,
|
|
2456
|
+
vendor,
|
|
2457
|
+
currency
|
|
2458
|
+
},
|
|
2459
|
+
variants: (variants == null ? void 0 : variants.length) ? variants.map((variant) => {
|
|
2460
|
+
const { id: variant_id, title: variant_title, price, sku, inventory_quantity } = variant || {};
|
|
2461
|
+
return { id: variant_id, title: variant_title, price, sku, inventory_quantity };
|
|
2462
|
+
}) : []
|
|
2463
|
+
};
|
|
2464
|
+
}),
|
|
2465
|
+
setting: {
|
|
2466
|
+
show_vendor: (_g = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _g.show_vendor,
|
|
2467
|
+
show_sku: (_h = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _h.show_sku,
|
|
2468
|
+
show_price: (_i = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _i.show_price
|
|
2469
|
+
},
|
|
2470
|
+
customProductCard,
|
|
2471
|
+
showOptionOutOfStock: true,
|
|
2472
|
+
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2473
|
+
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
2474
|
+
onAfterRemoveWishlist: handleFunctions.onAfterRemoveWishlist,
|
|
2475
|
+
onAfterRenderProduct: handleFunctions.onAfterRenderProduct
|
|
2476
|
+
}
|
|
2477
|
+
) }) : Object.keys(suggestionSettings).length && ((_k = (_j = suggestionSettings[suggestionIndex]) == null ? void 0 : _j.products) == null ? void 0 : _k.active) && ((_n = (_m = (_l = suggestionSettings[suggestionIndex]) == null ? void 0 : _l.products) == null ? void 0 : _m.list) == null ? void 0 : _n.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2478
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-product-suggestion-no-result-text", children: [
|
|
2479
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Sorry" }),
|
|
2480
|
+
", nothing found for ",
|
|
2481
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: keyword }),
|
|
2482
|
+
". Did you mean:"
|
|
2483
|
+
] }),
|
|
2484
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2485
|
+
ProductGrid,
|
|
2486
|
+
{
|
|
2487
|
+
sourceApp: "instant-search",
|
|
2488
|
+
type: "medium",
|
|
2489
|
+
data: suggestionSettings[suggestionIndex].products.list.map((item) => {
|
|
2490
|
+
const { id, currency, title, image, url, vendor, variants } = item || {};
|
|
2491
|
+
return {
|
|
2492
|
+
product: {
|
|
2493
|
+
id,
|
|
2494
|
+
title,
|
|
2495
|
+
image,
|
|
2496
|
+
url,
|
|
2497
|
+
vendor,
|
|
2498
|
+
currency
|
|
2499
|
+
},
|
|
2500
|
+
variants: (variants == null ? void 0 : variants.length) ? variants.map((variant) => {
|
|
2501
|
+
const { id: variant_id, title: variant_title, price, sku, inventory_quantity } = variant || {};
|
|
2502
|
+
return { id: variant_id, title: variant_title, price, sku, inventory_quantity };
|
|
2503
|
+
}) : []
|
|
2504
|
+
};
|
|
2505
|
+
}),
|
|
2506
|
+
setting: {
|
|
2507
|
+
show_vendor: (_o = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _o.show_vendor,
|
|
2508
|
+
show_sku: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_sku,
|
|
2509
|
+
show_price: (_q = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _q.show_price
|
|
2510
|
+
},
|
|
2511
|
+
customProductCard,
|
|
2512
|
+
showOptionOutOfStock: true,
|
|
2513
|
+
onAfterAddToCart: handleFunctions.onAfterAddToCart,
|
|
2514
|
+
onAfterAddWishlist: handleFunctions.onAfterAddWishlist,
|
|
2515
|
+
onAfterRemoveWishlist: handleFunctions.onAfterRemoveWishlist,
|
|
2516
|
+
onAfterRenderProduct: handleFunctions.onAfterRenderProduct
|
|
2517
|
+
}
|
|
2518
|
+
)
|
|
2519
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2520
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-title", children: "Products" }),
|
|
2521
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-item-disabled", children: "No product were found" })
|
|
2522
|
+
] }),
|
|
2523
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_s = (_r = suggestionSettings[suggestionIndex]) == null ? void 0 : _r.products) == null ? void 0 : _s.active) && ((_v = (_u = (_t = suggestionSettings[suggestionIndex]) == null ? void 0 : _t.products) == null ? void 0 : _u.list) == null ? void 0 : _v.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: `${SEARCH_RESULT_URL}?q=${keyword}`, className: "sledge-instant-search__icon-widget-button-more", children: "View More Result" }) }) : null
|
|
2524
|
+
] })
|
|
2525
|
+
] }) }) }) })
|
|
2526
|
+
] })
|
|
2527
|
+
] }) });
|
|
2528
|
+
};
|
|
2529
|
+
const SearchResultWidget$1 = "";
|
|
2530
|
+
const SearchResultWidget = (props) => {
|
|
2531
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2532
|
+
const { layoutType = "default", query, data, customProductCard, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
|
|
2533
|
+
const { keyword: queryKeyword = "" } = query || {};
|
|
2534
|
+
const { collectionId } = data || {};
|
|
2535
|
+
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
2536
|
+
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
2537
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
2538
|
+
const [keyword, setKeyword] = React__default.useState("");
|
|
2539
|
+
const [clickedTabIndexId, setClickedTabIndexId] = React__default.useState(null);
|
|
2540
|
+
const [clickedTabIndexName, setClickedTabIndexName] = React__default.useState();
|
|
2541
|
+
const [resultComponent, setResultComponent] = React__default.useState(/* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}));
|
|
2542
|
+
const [isLoadingSetting, setIsLoadingSetting] = React__default.useState(true);
|
|
2543
|
+
const [allowedSorts, setAllowedSorts] = React__default.useState([]);
|
|
2544
|
+
const [allowedFilters, setAllowedFilters] = React__default.useState([]);
|
|
2545
|
+
const [allowedTabs, setAllowedTabs] = React__default.useState([]);
|
|
2546
|
+
const [facets, setFacets] = React__default.useState([]);
|
|
2547
|
+
const [suffixIndexProduct, setSuffixIndexProduct] = React__default.useState("");
|
|
2548
|
+
const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
|
|
2549
|
+
const [hiddenTags, setHiddenTags] = React__default.useState([]);
|
|
2550
|
+
const [displaySettings, setDisplaySettings] = React__default.useState({});
|
|
2551
|
+
const [colorSwatches, setColorSwatches] = React__default.useState([]);
|
|
2552
|
+
const [defaultSort, setDefaultSort] = React__default.useState("");
|
|
2553
|
+
const [showOutOfStock, setShowOutOfStock] = React__default.useState(false);
|
|
2554
|
+
const previousState = usePrevious({ keyword });
|
|
2555
|
+
const handleChangeTabIndex = (id, name, e) => {
|
|
2556
|
+
setClickedTabIndexId(id);
|
|
2557
|
+
setClickedTabIndexName(name);
|
|
2558
|
+
setResultComponent(id.includes(suffixIndexProduct) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultCategory, {}));
|
|
2559
|
+
};
|
|
2560
|
+
const handleInitStates = async (data2, type) => {
|
|
2561
|
+
const { filters, tabs, suffix_index_product, hidden_tags, display, show_out_of_stock } = data2;
|
|
2562
|
+
let getTabs = layoutType === "product-filter" ? tabs.filter(({ index }) => index == null ? void 0 : index.includes(suffix_index_product)) : tabs;
|
|
2563
|
+
let response;
|
|
2564
|
+
let body = {
|
|
2565
|
+
queries: getTabs.map((tab) => {
|
|
2566
|
+
const { index } = tab;
|
|
2567
|
+
let isSetFilter = false;
|
|
2568
|
+
let getFacets = !isSetFilter ? filters == null ? void 0 : filters.map((filter) => {
|
|
2569
|
+
const { collections, items } = filter;
|
|
2570
|
+
if (collectionId && (collections == null ? void 0 : collections.includes(Number(collectionId)))) {
|
|
2571
|
+
isSetFilter = true;
|
|
2572
|
+
return items == null ? void 0 : items.map(({ value }) => value);
|
|
2573
|
+
} else {
|
|
2574
|
+
if (collections == null ? void 0 : collections.includes("all")) {
|
|
2575
|
+
isSetFilter = true;
|
|
2576
|
+
return items == null ? void 0 : items.map(({ value }) => value);
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
}) : [];
|
|
2580
|
+
let isProductIndex = index.includes(suffix_index_product);
|
|
2581
|
+
let isHasProductFacets = isProductIndex && getFacets.length;
|
|
2582
|
+
let additionalFilter = [];
|
|
2583
|
+
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
2584
|
+
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
2585
|
+
if (!show_out_of_stock)
|
|
2586
|
+
additionalFilter.push("variants.inventory_quantity > 0");
|
|
2587
|
+
if (collectionId)
|
|
2588
|
+
additionalFilter.push(`collections.id = '${collectionId}'`);
|
|
2589
|
+
if (isHasProductFacets)
|
|
2590
|
+
setFacets(getFacets[0]);
|
|
2591
|
+
return {
|
|
2592
|
+
indexUid: index,
|
|
2593
|
+
q: type === "default" ? "" : keyword,
|
|
2594
|
+
hitsPerPage: 1,
|
|
2595
|
+
facets: isHasProductFacets ? getFacets[0] : [],
|
|
2596
|
+
filter: isProductIndex ? additionalFilter.join(" AND ") : ""
|
|
2597
|
+
};
|
|
2598
|
+
})
|
|
2599
|
+
};
|
|
2600
|
+
response = await multiSearch(body);
|
|
2601
|
+
if (!response)
|
|
2602
|
+
return;
|
|
2603
|
+
const { results } = response;
|
|
2604
|
+
setTimeout(() => {
|
|
2605
|
+
setIsFirstLoading(false);
|
|
2606
|
+
}, 1300);
|
|
2607
|
+
setIsLoadingSetting(false);
|
|
2608
|
+
setIsLoading(false);
|
|
2609
|
+
if (type === "totalDataPerIndex") {
|
|
2610
|
+
setAllowedTabs(
|
|
2611
|
+
tabs == null ? void 0 : tabs.map((tab) => {
|
|
2612
|
+
const { index } = tab;
|
|
2613
|
+
const { totalHits } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid === index)) || {};
|
|
2614
|
+
return {
|
|
2615
|
+
...tab,
|
|
2616
|
+
...{
|
|
2617
|
+
total: totalHits
|
|
2618
|
+
}
|
|
2619
|
+
};
|
|
2620
|
+
})
|
|
2621
|
+
);
|
|
2622
|
+
} else {
|
|
2623
|
+
const { facetDistribution, facetStats } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(suffix_index_product))) || {};
|
|
2624
|
+
setSearchResultFacets(
|
|
2625
|
+
facetDistribution ? Object.fromEntries(
|
|
2626
|
+
Object.entries(facetDistribution).map((facet) => {
|
|
2627
|
+
let value = facet[0];
|
|
2628
|
+
let items = [];
|
|
2629
|
+
if (value === "variants.inventory_quantity") {
|
|
2630
|
+
Object.keys(facetDistribution[value]).map((item) => {
|
|
2631
|
+
return Boolean(Number(item)) ? facetDistribution[value][item] : 0;
|
|
2632
|
+
});
|
|
2633
|
+
items = [
|
|
2634
|
+
{
|
|
2635
|
+
name: "In Stock",
|
|
2636
|
+
value: "> 0"
|
|
2637
|
+
}
|
|
2638
|
+
];
|
|
2639
|
+
} else if (value === "variants.price") {
|
|
2640
|
+
items = facetStats[value];
|
|
2641
|
+
} else {
|
|
2642
|
+
items = Object.keys(facetDistribution[value]).map((item) => {
|
|
2643
|
+
return {
|
|
2644
|
+
name: item,
|
|
2645
|
+
value: item,
|
|
2646
|
+
total: facetDistribution[value][item] || 0
|
|
2647
|
+
};
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
return [value, items];
|
|
2651
|
+
})
|
|
2652
|
+
) : {}
|
|
2653
|
+
);
|
|
2654
|
+
}
|
|
2655
|
+
};
|
|
2656
|
+
const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
|
|
2657
|
+
setIsLoadingSetting(true);
|
|
2658
|
+
let response;
|
|
2659
|
+
let run = false;
|
|
2660
|
+
let getFirstIndex;
|
|
2661
|
+
response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
2662
|
+
if (!response)
|
|
2663
|
+
return;
|
|
2664
|
+
const { status, data: data2 } = response;
|
|
2665
|
+
const { code } = status;
|
|
2666
|
+
const { allowed_sorts, default_sort, filters, tabs, suffix_index_product, hidden_tags, display, colors, show_out_of_stock } = data2;
|
|
2667
|
+
run = code === 200 || false;
|
|
2668
|
+
if (run) {
|
|
2669
|
+
setAllowedSorts((allowed_sorts == null ? void 0 : allowed_sorts.length) ? allowed_sorts : []);
|
|
2670
|
+
setAllowedFilters((filters == null ? void 0 : filters.length) ? filters : []);
|
|
2671
|
+
setSuffixIndexProduct(suffix_index_product);
|
|
2672
|
+
setHiddenTags(hidden_tags);
|
|
2673
|
+
setDisplaySettings(display);
|
|
2674
|
+
setColorSwatches(colors);
|
|
2675
|
+
setDefaultSort(default_sort);
|
|
2676
|
+
setShowOutOfStock(show_out_of_stock);
|
|
2677
|
+
getFirstIndex = tabs.find(({ index }) => index.includes(suffix_index_product));
|
|
2678
|
+
if (Object.keys(getFirstIndex).length) {
|
|
2679
|
+
setClickedTabIndexId(getFirstIndex.index);
|
|
2680
|
+
setClickedTabIndexName(getFirstIndex.name);
|
|
2681
|
+
}
|
|
2682
|
+
await handleInitStates(data2, "default");
|
|
2683
|
+
if (layoutType === "default")
|
|
2684
|
+
await handleInitStates(data2, "totalDataPerIndex");
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
React__default.useEffect(() => {
|
|
2688
|
+
if (!(isRenderApp == null ? void 0 : isRenderApp.instantSearch))
|
|
2689
|
+
return;
|
|
2690
|
+
const searchParams = new URLSearchParams(document.location.search);
|
|
2691
|
+
setKeyword((searchParams == null ? void 0 : searchParams.get(queryKeyword)) || "");
|
|
2692
|
+
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
2693
|
+
}, [isRenderApp]);
|
|
2694
|
+
React__default.useEffect(() => {
|
|
2695
|
+
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword) && layoutType === "default") {
|
|
2696
|
+
const delayDebounceFn = setTimeout(() => {
|
|
2697
|
+
handleInitStates(
|
|
2698
|
+
{
|
|
2699
|
+
filters: allowedFilters,
|
|
2700
|
+
tabs: allowedTabs,
|
|
2701
|
+
suffix_index_product: suffixIndexProduct,
|
|
2702
|
+
hidden_tags: hiddenTags,
|
|
2703
|
+
display: displaySettings,
|
|
2704
|
+
colors: colorSwatches,
|
|
2705
|
+
show_out_of_stock: showOutOfStock
|
|
2706
|
+
},
|
|
2707
|
+
"totalDataPerIndex"
|
|
2708
|
+
);
|
|
2709
|
+
}, 500);
|
|
2710
|
+
return () => clearTimeout(delayDebounceFn);
|
|
2711
|
+
}
|
|
2712
|
+
}, [keyword]);
|
|
2713
|
+
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;
|
|
2714
|
+
const filterHorizontalSkeleton = ((_a = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a.enable_on_search) && ((_b = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b.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;
|
|
2715
|
+
const filterVerticalSkeleton = ((_c = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _c.enable_on_search) && ((_d = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _d.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2716
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2717
|
+
"div",
|
|
2718
|
+
{
|
|
2719
|
+
style: {
|
|
2720
|
+
display: "flex",
|
|
2721
|
+
flexWrap: "wrap",
|
|
2722
|
+
alignItems: "center",
|
|
2723
|
+
gap: "8px",
|
|
2724
|
+
justifyContent: "space-between",
|
|
2725
|
+
marginBottom: "23px"
|
|
2726
|
+
},
|
|
2727
|
+
children: [
|
|
2728
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "grey-100", rounded: "md", animationDuration: "15s" }),
|
|
2729
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "80px", height: "28px", color: "grey-100", rounded: "md", animationDuration: "15s" })
|
|
2730
|
+
]
|
|
2731
|
+
}
|
|
2732
|
+
),
|
|
2733
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2734
|
+
SkeletonLoading.Item,
|
|
2735
|
+
{
|
|
2736
|
+
width: "100%",
|
|
2737
|
+
height: "28px",
|
|
2738
|
+
color: "grey-100",
|
|
2739
|
+
rounded: "md",
|
|
2740
|
+
style: {
|
|
2741
|
+
maxWidth: "270px",
|
|
2742
|
+
marginBottom: "18px"
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
),
|
|
2746
|
+
[1, 2, 3].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2747
|
+
SkeletonLoading.Item,
|
|
2748
|
+
{
|
|
2749
|
+
width: "100%",
|
|
2750
|
+
height: "28px",
|
|
2751
|
+
color: "grey-100",
|
|
2752
|
+
rounded: "md",
|
|
2753
|
+
style: {
|
|
2754
|
+
maxWidth: "163px",
|
|
2755
|
+
marginBottom: "9px"
|
|
2756
|
+
}
|
|
2757
|
+
},
|
|
2758
|
+
index
|
|
2759
|
+
)),
|
|
2760
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2761
|
+
SkeletonLoading.Item,
|
|
2762
|
+
{
|
|
2763
|
+
width: "100%",
|
|
2764
|
+
height: "28px",
|
|
2765
|
+
color: "grey-100",
|
|
2766
|
+
rounded: "md",
|
|
2767
|
+
style: {
|
|
2768
|
+
maxWidth: "163px",
|
|
2769
|
+
marginBottom: "18px"
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
),
|
|
2773
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2774
|
+
SkeletonLoading.Item,
|
|
2775
|
+
{
|
|
2776
|
+
width: "100%",
|
|
2777
|
+
height: "28px",
|
|
2778
|
+
color: "grey-100",
|
|
2779
|
+
rounded: "md",
|
|
2780
|
+
style: {
|
|
2781
|
+
maxWidth: "270px",
|
|
2782
|
+
marginBottom: "14px"
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
),
|
|
2786
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2787
|
+
SkeletonLoading.Item,
|
|
2788
|
+
{
|
|
2789
|
+
width: "100%",
|
|
2790
|
+
height: "28px",
|
|
2791
|
+
color: "grey-100",
|
|
2792
|
+
rounded: "md",
|
|
2793
|
+
style: {
|
|
2794
|
+
maxWidth: "163px",
|
|
2795
|
+
marginBottom: "9px"
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
),
|
|
2799
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2800
|
+
SkeletonLoading.Item,
|
|
2801
|
+
{
|
|
2802
|
+
width: "100%",
|
|
2803
|
+
height: "28px",
|
|
2804
|
+
color: "grey-100",
|
|
2805
|
+
rounded: "md",
|
|
2806
|
+
style: {
|
|
2807
|
+
maxWidth: "163px",
|
|
2808
|
+
marginBottom: "17px"
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
),
|
|
2812
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2813
|
+
SkeletonLoading.Item,
|
|
2814
|
+
{
|
|
2815
|
+
width: "100%",
|
|
2816
|
+
height: "28px",
|
|
2817
|
+
color: "grey-100",
|
|
2818
|
+
rounded: "md",
|
|
2819
|
+
style: {
|
|
2820
|
+
maxWidth: "270px",
|
|
2821
|
+
marginBottom: "38px"
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
),
|
|
2825
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2826
|
+
SkeletonLoading.Item,
|
|
2827
|
+
{
|
|
2828
|
+
width: "100%",
|
|
2829
|
+
height: "28px",
|
|
2830
|
+
color: "grey-100",
|
|
2831
|
+
rounded: "md",
|
|
2832
|
+
style: {
|
|
2833
|
+
maxWidth: "270px",
|
|
2834
|
+
marginBottom: "35px"
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
),
|
|
2838
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2839
|
+
SkeletonLoading.Item,
|
|
2840
|
+
{
|
|
2841
|
+
width: "100%",
|
|
2842
|
+
height: "28px",
|
|
2843
|
+
color: "grey-100",
|
|
2844
|
+
rounded: "md",
|
|
2845
|
+
style: {
|
|
2846
|
+
maxWidth: "270px",
|
|
2847
|
+
marginBottom: "12px"
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
),
|
|
2851
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2852
|
+
SkeletonLoading.Item,
|
|
2853
|
+
{
|
|
2854
|
+
width: "100%",
|
|
2855
|
+
height: "28px",
|
|
2856
|
+
color: "grey-100",
|
|
2857
|
+
rounded: "md",
|
|
2858
|
+
style: {
|
|
2859
|
+
maxWidth: "163px",
|
|
2860
|
+
marginBottom: "9px"
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
),
|
|
2864
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2865
|
+
SkeletonLoading.Item,
|
|
2866
|
+
{
|
|
2867
|
+
width: "100%",
|
|
2868
|
+
height: "28px",
|
|
2869
|
+
color: "grey-100",
|
|
2870
|
+
rounded: "md",
|
|
2871
|
+
style: {
|
|
2872
|
+
maxWidth: "163px",
|
|
2873
|
+
marginBottom: "20px"
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
),
|
|
2877
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2878
|
+
SkeletonLoading.Item,
|
|
2879
|
+
{
|
|
2880
|
+
width: "100%",
|
|
2881
|
+
height: "28px",
|
|
2882
|
+
color: "grey-100",
|
|
2883
|
+
rounded: "md",
|
|
2884
|
+
style: {
|
|
2885
|
+
maxWidth: "270px",
|
|
2886
|
+
marginBottom: "12px"
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
),
|
|
2890
|
+
[1, 2, 3].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2891
|
+
SkeletonLoading.Item,
|
|
2892
|
+
{
|
|
2893
|
+
width: "100%",
|
|
2894
|
+
height: "28px",
|
|
2895
|
+
color: "grey-100",
|
|
2896
|
+
rounded: "md",
|
|
2897
|
+
style: {
|
|
2898
|
+
maxWidth: "163px",
|
|
2899
|
+
marginBottom: "9px"
|
|
2900
|
+
}
|
|
2901
|
+
},
|
|
2902
|
+
index
|
|
2903
|
+
)),
|
|
2904
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2905
|
+
SkeletonLoading.Item,
|
|
2906
|
+
{
|
|
2907
|
+
width: "100%",
|
|
2908
|
+
height: "28px",
|
|
2909
|
+
color: "grey-100",
|
|
2910
|
+
rounded: "md",
|
|
2911
|
+
style: {
|
|
2912
|
+
maxWidth: "270px",
|
|
2913
|
+
marginBottom: "11px"
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
),
|
|
2917
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2918
|
+
"div",
|
|
2919
|
+
{
|
|
2920
|
+
style: {
|
|
2921
|
+
display: "flex",
|
|
2922
|
+
flexWrap: "wrap",
|
|
2923
|
+
alignItems: "center",
|
|
2924
|
+
gap: "12px"
|
|
2925
|
+
},
|
|
2926
|
+
children: [1, 2, 3, 4, 5, 6, 7, 8, 9].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "34px", height: "34px", color: "grey-100", rounded: "full", animationDuration: "40s" }, index))
|
|
2927
|
+
}
|
|
2928
|
+
)
|
|
2929
|
+
] }) : null;
|
|
2930
|
+
const productGridSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2931
|
+
((_e = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _e.show_total_products) && ((_f = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _f.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2932
|
+
SkeletonLoading.Item,
|
|
2933
|
+
{
|
|
2934
|
+
width: "117px",
|
|
2935
|
+
height: "28px",
|
|
2936
|
+
color: "grey-100",
|
|
2937
|
+
rounded: "md",
|
|
2938
|
+
animationDuration: "13s",
|
|
2939
|
+
style: {
|
|
2940
|
+
marginBottom: "21px"
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
) : null,
|
|
2944
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 12, type: "large" })
|
|
2945
|
+
] });
|
|
2946
|
+
const searchAndSelectOptionSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
2947
|
+
((_g = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _g.show_total_products) && ((_h = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _h.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,
|
|
2948
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-keyword-form", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2949
|
+
SkeletonLoading.Item,
|
|
2950
|
+
{
|
|
2951
|
+
width: "100%",
|
|
2952
|
+
height: "42px",
|
|
2953
|
+
color: "grey-100",
|
|
2954
|
+
rounded: "lg",
|
|
2955
|
+
style: {
|
|
2956
|
+
maxWidth: "630px"
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
) }),
|
|
2960
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-summary-item sledge-instant-search__result-data-summary-select-field", children: [
|
|
2961
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-select-field-item", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "150px", height: "42px", color: "grey-100", rounded: "lg" }) }),
|
|
2962
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-select-field-item", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "150px", height: "42px", color: "grey-100", rounded: "lg" }) })
|
|
2963
|
+
] })
|
|
2964
|
+
] });
|
|
2965
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-container", children: [
|
|
2966
|
+
isFirstLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${layoutType === "default" && (allowedTabs == null ? void 0 : allowedTabs.length) ? "sledge-instant-search__result-tab" : "sledge-instant-search__result-tab-no-index"}`, children: layoutType === "default" && (allowedTabs == null ? void 0 : allowedTabs.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__result-tab-list", children: allowedTabs.map((item) => {
|
|
2967
|
+
const { name, index, total } = item;
|
|
2968
|
+
let isActive = clickedTabIndexId === index;
|
|
2969
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { onClick: (e) => handleChangeTabIndex(index, name), className: `${isActive ? "sledge-instant-search__result-tab-list-item-active" : ""}`, children: [
|
|
2970
|
+
name,
|
|
2971
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-tab-total", children: total || 0 })
|
|
2972
|
+
] }, index);
|
|
2973
|
+
}) }) : null }),
|
|
2974
|
+
isFirstLoading && (layoutType == null ? void 0 : layoutType.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2975
|
+
tabSkeleton,
|
|
2976
|
+
filterHorizontalSkeleton,
|
|
2977
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-wrapper sledge-instant-search__result-wrapper-skeleton", children: [
|
|
2978
|
+
((_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.enable_on_search) && ((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : null,
|
|
2979
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
|
|
2980
|
+
searchAndSelectOptionSkeleton,
|
|
2981
|
+
productGridSkeleton
|
|
2982
|
+
] })
|
|
2983
|
+
] })
|
|
2984
|
+
] }) : React__default.cloneElement(resultComponent, {
|
|
2985
|
+
isLoading,
|
|
2986
|
+
keyword,
|
|
2987
|
+
clickedTabIndexId,
|
|
2988
|
+
clickedTabIndexName,
|
|
2989
|
+
isLoadingSetting,
|
|
2990
|
+
allowedSorts,
|
|
2991
|
+
allowedFilters,
|
|
2992
|
+
facets,
|
|
2993
|
+
searchResultFacets,
|
|
2994
|
+
hiddenTags,
|
|
2995
|
+
displaySettings,
|
|
2996
|
+
colorSwatches,
|
|
2997
|
+
defaultSort,
|
|
2998
|
+
showOutOfStock,
|
|
2999
|
+
data,
|
|
3000
|
+
customProductCard,
|
|
3001
|
+
onAfterAddToCart,
|
|
3002
|
+
onAfterAddWishlist,
|
|
3003
|
+
onAfterRemoveWishlist,
|
|
3004
|
+
onAfterRenderProduct,
|
|
3005
|
+
setIsLoading,
|
|
3006
|
+
setKeyword,
|
|
3007
|
+
filterHorizontalSkeleton,
|
|
3008
|
+
filterVerticalSkeleton,
|
|
3009
|
+
productGridSkeleton,
|
|
3010
|
+
searchAndSelectOptionSkeleton
|
|
3011
|
+
})
|
|
3012
|
+
] });
|
|
3013
|
+
};
|
|
3014
|
+
const ResultProduct = (props) => {
|
|
3015
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
3016
|
+
const {
|
|
3017
|
+
keyword,
|
|
3018
|
+
clickedTabIndexId,
|
|
3019
|
+
isLoadingSetting,
|
|
3020
|
+
allowedSorts,
|
|
3021
|
+
allowedFilters,
|
|
3022
|
+
facets,
|
|
3023
|
+
searchResultFacets,
|
|
3024
|
+
hiddenTags,
|
|
3025
|
+
displaySettings,
|
|
3026
|
+
colorSwatches,
|
|
3027
|
+
defaultSort,
|
|
3028
|
+
showOutOfStock,
|
|
3029
|
+
data,
|
|
3030
|
+
setKeyword,
|
|
3031
|
+
filterHorizontalSkeleton,
|
|
3032
|
+
filterVerticalSkeleton,
|
|
3033
|
+
productGridSkeleton,
|
|
3034
|
+
searchAndSelectOptionSkeleton,
|
|
3035
|
+
customProductCard,
|
|
3036
|
+
onAfterAddToCart,
|
|
3037
|
+
onAfterAddWishlist,
|
|
3038
|
+
onAfterRemoveWishlist,
|
|
3039
|
+
onAfterRenderProduct
|
|
3040
|
+
} = props || {};
|
|
3041
|
+
const { collectionId } = data || {};
|
|
3042
|
+
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
3043
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
3044
|
+
const [isOpenSort, setIsOpenSort] = React__default.useState(false);
|
|
3045
|
+
const [isOpenLimit, setIsOpenLimit] = React__default.useState(false);
|
|
3046
|
+
const [clickedSortId, setClickedSortId] = React__default.useState(defaultSort || "");
|
|
3047
|
+
const [clickedSortName, setClickedSortName] = React__default.useState(allowedSorts && Boolean(allowedSorts == null ? void 0 : allowedSorts.length) ? (_a = allowedSorts.find(({ value }) => value === defaultSort)) == null ? void 0 : _a.label : "");
|
|
3048
|
+
const [clickedLimitId, setClickedLimitId] = React__default.useState(((_b = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _b.limit) || 10);
|
|
3049
|
+
const [clickedOpenFilterId, setClickedOpenFilterId] = React__default.useState(null);
|
|
3050
|
+
const [clickedFacets, setClickedFacets] = React__default.useState({
|
|
3051
|
+
...!showOutOfStock ? {
|
|
3052
|
+
"variants.inventory_quantity": "> 0"
|
|
3053
|
+
} : {}
|
|
3054
|
+
});
|
|
3055
|
+
const [searchResult, setSearchResult] = React__default.useState([]);
|
|
3056
|
+
const [searchProcessingTimeMs, setSearchProcessingTimeMs] = React__default.useState(0);
|
|
3057
|
+
const [currentPage, setCurrentPage] = React__default.useState(1);
|
|
3058
|
+
const [totalPage, setTotalPage] = React__default.useState(0);
|
|
3059
|
+
const [totalSearchResult, setTotalSearchResult] = React__default.useState(0);
|
|
3060
|
+
const [valueFilterPriceChange, setValueFilterPriceChange] = React__default.useState([]);
|
|
3061
|
+
const [allowedFilter, setAllowedFilter] = React__default.useState([]);
|
|
3062
|
+
const [isFilterChanged, setIsFilterChanged] = React__default.useState(false);
|
|
3063
|
+
const [summaryText, setSummaryText] = React__default.useState(null);
|
|
3064
|
+
const previousState = usePrevious({ keyword, clickedLimitId, clickedFacets });
|
|
3065
|
+
const { color: filter_title_color, font_size: filter_title_font_size, font_weight: filter_title_font_weight, text_transform: filter_title_text_transform } = ((_c = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _c.title) || {};
|
|
3066
|
+
const {
|
|
3067
|
+
color: filter_option_color,
|
|
3068
|
+
font_size: filter_option_font_size,
|
|
3069
|
+
font_weight: filter_option_font_weight,
|
|
3070
|
+
text_transform: filter_option_text_transform
|
|
3071
|
+
} = ((_d = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _d.option) || {};
|
|
3072
|
+
const {
|
|
3073
|
+
text_color: filter_button_text_color,
|
|
3074
|
+
border_color: filter_button_border_color,
|
|
3075
|
+
border_radius: filter_button_border_radius,
|
|
3076
|
+
padding_top: filter_button_padding_top,
|
|
3077
|
+
padding_bottom: filter_button_padding_bottom,
|
|
3078
|
+
padding_left: filter_button_padding_left,
|
|
3079
|
+
padding_right: filter_button_padding_right,
|
|
3080
|
+
background_color: filter_button_background_color,
|
|
3081
|
+
font_size: filter_button_font_size,
|
|
3082
|
+
font_weight: filter_button_font_weight,
|
|
3083
|
+
text_transform: filter_button_text_transform
|
|
3084
|
+
} = ((_e = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _e.button) || {};
|
|
3085
|
+
const filter_title_style = {
|
|
3086
|
+
...filter_title_color && { color: filter_title_color },
|
|
3087
|
+
...filter_title_font_size && { fontSize: filter_title_font_size },
|
|
3088
|
+
...filter_title_font_weight && { fontWeight: filter_title_font_weight },
|
|
3089
|
+
...filter_title_text_transform && { textTransform: filter_title_text_transform }
|
|
3090
|
+
};
|
|
3091
|
+
const filter_option_style = {
|
|
3092
|
+
...filter_option_color && { color: filter_option_color },
|
|
3093
|
+
...filter_option_font_size && { fontSize: filter_option_font_size },
|
|
3094
|
+
...filter_option_font_weight && { fontWeight: filter_option_font_weight },
|
|
3095
|
+
...filter_option_text_transform && { textTransform: filter_option_text_transform }
|
|
3096
|
+
};
|
|
3097
|
+
({
|
|
3098
|
+
...filter_button_text_color && { color: filter_button_text_color },
|
|
3099
|
+
...filter_button_border_color && { borderColor: filter_button_border_color },
|
|
3100
|
+
...filter_button_border_radius && { borderRadius: filter_button_border_radius },
|
|
3101
|
+
...filter_button_padding_top && { paddingTop: filter_button_padding_top },
|
|
3102
|
+
...filter_button_padding_bottom && { paddingBottom: filter_button_padding_bottom },
|
|
3103
|
+
...filter_button_padding_left && { paddingLeft: filter_button_padding_left },
|
|
3104
|
+
...filter_button_padding_right && { paddingRight: filter_button_padding_right },
|
|
3105
|
+
...filter_button_background_color && { backgroundColor: filter_button_background_color },
|
|
3106
|
+
...filter_button_font_size && { fontSize: filter_button_font_size },
|
|
3107
|
+
...filter_button_font_weight && { fontWeight: filter_button_font_weight },
|
|
3108
|
+
...filter_button_text_transform && { textTransform: filter_button_text_transform }
|
|
3109
|
+
});
|
|
3110
|
+
const handleChangeSort = (label, value) => {
|
|
3111
|
+
setIsOpenSort(false);
|
|
3112
|
+
setClickedSortName(label);
|
|
3113
|
+
setClickedSortId(value);
|
|
3114
|
+
};
|
|
3115
|
+
const handleChangeLimit = (value) => {
|
|
3116
|
+
setIsOpenLimit(false);
|
|
3117
|
+
setClickedLimitId(value);
|
|
3118
|
+
};
|
|
3119
|
+
const handleOpenFilter = (id) => {
|
|
3120
|
+
setClickedOpenFilterId(id === clickedOpenFilterId ? "" : id);
|
|
3121
|
+
};
|
|
3122
|
+
const handleFilterReset = () => {
|
|
3123
|
+
setIsFilterChanged(true);
|
|
3124
|
+
setClickedFacets({});
|
|
3125
|
+
setValueFilterPriceChange([]);
|
|
3126
|
+
setTimeout(() => {
|
|
3127
|
+
setIsFilterChanged(false);
|
|
3128
|
+
}, 10);
|
|
3129
|
+
};
|
|
3130
|
+
const handleFilterChange = (parentId, value, force = false) => {
|
|
3131
|
+
var _a2;
|
|
3132
|
+
setIsFilterChanged(true);
|
|
3133
|
+
let facets2 = [value];
|
|
3134
|
+
let isRange = ["variants.price"].includes(parentId);
|
|
3135
|
+
if (clickedFacets) {
|
|
3136
|
+
if (force) {
|
|
3137
|
+
facets2 = [value];
|
|
3138
|
+
} else {
|
|
3139
|
+
if ((_a2 = clickedFacets[parentId]) == null ? void 0 : _a2.includes(value)) {
|
|
3140
|
+
facets2 = clickedFacets[parentId].filter((facet) => facet !== value);
|
|
3141
|
+
} else {
|
|
3142
|
+
if (isRange) {
|
|
3143
|
+
if (clickedFacets[parentId], clickedFacets[parentId] === value) {
|
|
3144
|
+
facets2 = [];
|
|
3145
|
+
setValueFilterPriceChange([]);
|
|
3146
|
+
} else {
|
|
3147
|
+
facets2 = value;
|
|
3148
|
+
}
|
|
3149
|
+
} else {
|
|
3150
|
+
facets2 = clickedFacets[parentId] ? [...clickedFacets[parentId], value] : [value];
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
setClickedFacets({
|
|
3156
|
+
...clickedFacets,
|
|
3157
|
+
...{
|
|
3158
|
+
[parentId]: facets2
|
|
3159
|
+
}
|
|
3160
|
+
});
|
|
3161
|
+
setTimeout(() => {
|
|
3162
|
+
setIsFilterChanged(false);
|
|
3163
|
+
}, 10);
|
|
3164
|
+
};
|
|
3165
|
+
const handleSearchResultData = (result, onSearch) => {
|
|
3166
|
+
var _a2;
|
|
3167
|
+
if (!result)
|
|
3168
|
+
return;
|
|
3169
|
+
const { hits, processingTimeMs, totalHits, totalPages } = result;
|
|
3170
|
+
if (onSearch && (keyword == null ? void 0 : keyword.length)) {
|
|
3171
|
+
searchTrigger({
|
|
3172
|
+
keyword,
|
|
3173
|
+
resultCount: totalHits || 0
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3176
|
+
setIsFirstLoading(false);
|
|
3177
|
+
setIsLoading(false);
|
|
3178
|
+
setSearchResult(hits);
|
|
3179
|
+
setSearchProcessingTimeMs(processingTimeMs || 0);
|
|
3180
|
+
setTotalPage(totalPages);
|
|
3181
|
+
setTotalSearchResult(totalHits || 0);
|
|
3182
|
+
setSummaryText(
|
|
3183
|
+
/* @__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: [
|
|
3184
|
+
totalHits,
|
|
3185
|
+
" result",
|
|
3186
|
+
" ",
|
|
3187
|
+
(keyword == null ? void 0 : keyword.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3188
|
+
"for ",
|
|
3189
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-data-summary-text-keyword", children: [
|
|
3190
|
+
'"',
|
|
3191
|
+
keyword,
|
|
3192
|
+
'"'
|
|
3193
|
+
] })
|
|
3194
|
+
] }) : null
|
|
3195
|
+
] }) : null })
|
|
3196
|
+
);
|
|
3197
|
+
};
|
|
3198
|
+
const handleSearchResult = async (isRefreshPage = false, onSearch = false) => {
|
|
3199
|
+
if (!clickedTabIndexId)
|
|
3200
|
+
return;
|
|
3201
|
+
if (isRefreshPage)
|
|
3202
|
+
setCurrentPage(1);
|
|
3203
|
+
setIsLoading(true);
|
|
3204
|
+
let response;
|
|
3205
|
+
let filters = Object.entries(clickedFacets).map((facet) => {
|
|
3206
|
+
var _a2, _b2;
|
|
3207
|
+
if ((facet == null ? void 0 : facet.length) && facet[1].length) {
|
|
3208
|
+
let value = facet[0];
|
|
3209
|
+
let isCustom = ["variants.inventory_quantity"].includes(value);
|
|
3210
|
+
let isRange = ["variants.price"].includes(value);
|
|
3211
|
+
let isArray = ["tags"].includes(value);
|
|
3212
|
+
let items = Array.isArray(facet[1]) && ((_a2 = facet[1]) == null ? void 0 : _a2.length) > 1 ? isRange ? `${value} >= ${facet[1][0]} AND ${value} <= ${facet[1][1]}` : isArray ? `${value} IN [${facet[1]}]` : (_b2 = facet[1]) == null ? void 0 : _b2.map((item) => {
|
|
3213
|
+
return isCustom ? `${value} ${item}` : `${value} = '${item}'`;
|
|
3214
|
+
}).join(" OR ") : isCustom ? `${value} ${facet[1]}` : isArray ? `${value} IN [${facet[1]}]` : `${value} = '${facet[1]}'`;
|
|
3215
|
+
return items;
|
|
3216
|
+
} else
|
|
3217
|
+
return null;
|
|
3218
|
+
}).filter((item) => item);
|
|
3219
|
+
if (hiddenTags == null ? void 0 : hiddenTags.length)
|
|
3220
|
+
filters.push(`tags NOT IN [${hiddenTags}]`);
|
|
3221
|
+
if (collectionId)
|
|
3222
|
+
filters.push(`collections.id = '${collectionId}'`);
|
|
3223
|
+
let body = {
|
|
3224
|
+
q: keyword,
|
|
3225
|
+
sort: clickedSortId ? [clickedSortId] : [],
|
|
3226
|
+
page: isRefreshPage ? 1 : currentPage,
|
|
3227
|
+
hitsPerPage: clickedLimitId,
|
|
3228
|
+
facets,
|
|
3229
|
+
filter: filters.join(" AND ")
|
|
3230
|
+
};
|
|
3231
|
+
response = await search(clickedTabIndexId, body);
|
|
3232
|
+
handleSearchResultData(response, onSearch);
|
|
3233
|
+
};
|
|
3234
|
+
const handleAllowedFilter = () => {
|
|
3235
|
+
var _a2, _b2;
|
|
3236
|
+
if (!((_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.enable_on_search) || ((_b2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b2.hide_when_one_value) && totalSearchResult <= 1)
|
|
3237
|
+
return;
|
|
3238
|
+
let isSetFilter = false;
|
|
3239
|
+
if (!isSetFilter)
|
|
3240
|
+
allowedFilters == null ? void 0 : allowedFilters.map((filter) => {
|
|
3241
|
+
const { collections, items } = filter;
|
|
3242
|
+
if (collectionId && (collections == null ? void 0 : collections.includes(Number(collectionId)))) {
|
|
3243
|
+
isSetFilter = true;
|
|
3244
|
+
setAllowedFilter(items);
|
|
3245
|
+
} else {
|
|
3246
|
+
if (collections == null ? void 0 : collections.includes("all")) {
|
|
3247
|
+
isSetFilter = true;
|
|
3248
|
+
setAllowedFilter(items);
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
});
|
|
3252
|
+
};
|
|
3253
|
+
const handlePageChange = (page) => {
|
|
3254
|
+
setCurrentPage(page);
|
|
3255
|
+
};
|
|
3256
|
+
React__default.useEffect(() => {
|
|
3257
|
+
let isRefreshSearchResult = Boolean(
|
|
3258
|
+
previousState && ((previousState == null ? void 0 : previousState.keyword) !== keyword || (previousState == null ? void 0 : previousState.clickedLimitId) !== clickedLimitId || (previousState == null ? void 0 : previousState.clickedFacets) !== clickedFacets)
|
|
3259
|
+
);
|
|
3260
|
+
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
3261
|
+
const delayDebounceFn = setTimeout(() => {
|
|
3262
|
+
handleSearchResult(true, true);
|
|
3263
|
+
}, 500);
|
|
3264
|
+
return () => clearTimeout(delayDebounceFn);
|
|
3265
|
+
} else {
|
|
3266
|
+
handleSearchResult(isRefreshSearchResult);
|
|
3267
|
+
}
|
|
3268
|
+
}, [clickedSortId, clickedLimitId, clickedFacets, keyword, currentPage, clickedTabIndexId]);
|
|
3269
|
+
React__default.useEffect(() => {
|
|
3270
|
+
handleAllowedFilter();
|
|
3271
|
+
}, [allowedFilters, searchResultFacets, totalSearchResult]);
|
|
3272
|
+
const facetBlockSelected = ({ label, name, value, index }) => {
|
|
3273
|
+
var _a2;
|
|
3274
|
+
let valueText = value;
|
|
3275
|
+
let isRange = ["variants.price"].includes(name);
|
|
3276
|
+
if (isRange)
|
|
3277
|
+
valueText = value == null ? void 0 : value.join(" - ");
|
|
3278
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-refine-selected", style: filter_option_style, children: [
|
|
3279
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-filter-item-title-refine-list", children: [
|
|
3280
|
+
label,
|
|
3281
|
+
": ",
|
|
3282
|
+
(_a2 = String(valueText)) == null ? void 0 : _a2.replaceAll("_", " ")
|
|
3283
|
+
] }),
|
|
3284
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-item-refine-title-clear", onClick: () => handleFilterChange(name, value), children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 12, height: 12, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3285
|
+
"path",
|
|
3286
|
+
{
|
|
3287
|
+
d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
|
|
3288
|
+
fill: "currentColor",
|
|
3289
|
+
fillRule: "evenodd",
|
|
3290
|
+
clipRule: "evenodd"
|
|
3291
|
+
}
|
|
3292
|
+
) }) })
|
|
3293
|
+
] }, index);
|
|
3294
|
+
};
|
|
3295
|
+
const facetComponent = (filter) => {
|
|
3296
|
+
var _a2, _b2;
|
|
3297
|
+
const { value, label, display } = filter;
|
|
3298
|
+
let blockComponent = null;
|
|
3299
|
+
let items = searchResultFacets[value];
|
|
3300
|
+
let isShowNumberMatchingProduct = (_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.show_number_matching_product;
|
|
3301
|
+
if (display.toLowerCase() === "slider") {
|
|
3302
|
+
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider", children: [
|
|
3303
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3304
|
+
Slider,
|
|
3305
|
+
{
|
|
3306
|
+
defaultValue: [valueFilterPriceChange[0] || (items == null ? void 0 : items.min), valueFilterPriceChange[1] || (items == null ? void 0 : items.max)],
|
|
3307
|
+
min: items == null ? void 0 : items.min,
|
|
3308
|
+
max: items == null ? void 0 : items.max,
|
|
3309
|
+
step: 1,
|
|
3310
|
+
setValueCommit: (valueCommit) => handleFilterChange(value, valueCommit),
|
|
3311
|
+
setValueChange: (valueChange) => setValueFilterPriceChange(valueChange)
|
|
3312
|
+
}
|
|
3313
|
+
),
|
|
3314
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-list-slider-minmax", children: [
|
|
3315
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", children: valueFilterPriceChange[0] || (items == null ? void 0 : items.min) }),
|
|
3316
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-minmax-field", children: valueFilterPriceChange[1] || (items == null ? void 0 : items.max) })
|
|
3317
|
+
] })
|
|
3318
|
+
] });
|
|
3319
|
+
} else if (display.toLowerCase() === "checkbox" && (items == null ? void 0 : items.length)) {
|
|
3320
|
+
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: items == null ? void 0 : items.map((item, index) => {
|
|
3321
|
+
var _a3;
|
|
3322
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3323
|
+
Checkbox,
|
|
3324
|
+
{
|
|
3325
|
+
id: `${value}_${index}`,
|
|
3326
|
+
name: value,
|
|
3327
|
+
value: item.value,
|
|
3328
|
+
label: `${item.name}${item.total !== void 0 && isShowNumberMatchingProduct ? ` (${item.total})` : ""}`,
|
|
3329
|
+
onClick: (e) => handleFilterChange(value, e.currentTarget.value),
|
|
3330
|
+
defaultChecked: clickedFacets && ((_a3 = clickedFacets[value]) == null ? void 0 : _a3.includes(item.value)),
|
|
3331
|
+
labelStyle: filter_option_style
|
|
3332
|
+
}
|
|
3333
|
+
) }, index);
|
|
3334
|
+
}) });
|
|
3335
|
+
} else if (display.toLowerCase() === "radio" && (items == null ? void 0 : items.length)) {
|
|
3336
|
+
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3337
|
+
RadioGroup,
|
|
3338
|
+
{
|
|
3339
|
+
id: value,
|
|
3340
|
+
name: value,
|
|
3341
|
+
onValueChange: (getValue) => handleFilterChange(value, getValue, true),
|
|
3342
|
+
items: items == null ? void 0 : items.map((item) => {
|
|
3343
|
+
const { name, value: value2, total } = item;
|
|
3344
|
+
return {
|
|
3345
|
+
label: `${name} ${total !== void 0 && isShowNumberMatchingProduct ? ` (${total})` : ""}`,
|
|
3346
|
+
value: value2
|
|
3347
|
+
};
|
|
3348
|
+
}),
|
|
3349
|
+
defaultValue: clickedFacets && ((_b2 = clickedFacets[value]) == null ? void 0 : _b2.length) ? clickedFacets[value][0] : "",
|
|
3350
|
+
labelStyle: filter_option_style
|
|
3351
|
+
}
|
|
3352
|
+
) });
|
|
3353
|
+
} else if (display.toLowerCase() === "select" && (items == null ? void 0 : items.length)) {
|
|
3354
|
+
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3355
|
+
Select,
|
|
3356
|
+
{
|
|
3357
|
+
placeholder: `Select ${label}`,
|
|
3358
|
+
name: value,
|
|
3359
|
+
onValueChange: (getValue) => handleFilterChange(value, getValue, true),
|
|
3360
|
+
items: items == null ? void 0 : items.map((item) => {
|
|
3361
|
+
const { name, value: value2, total } = item;
|
|
3362
|
+
return {
|
|
3363
|
+
label: `${name} ${total !== void 0 && isShowNumberMatchingProduct ? ` (${total})` : ""}`,
|
|
3364
|
+
value: value2
|
|
3365
|
+
};
|
|
3366
|
+
}),
|
|
3367
|
+
labelStyle: filter_option_style
|
|
3368
|
+
}
|
|
3369
|
+
) });
|
|
3370
|
+
} else if (display.toLowerCase() === "swatch" && (items == null ? void 0 : items.length)) {
|
|
3371
|
+
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: items == null ? void 0 : items.map((item, index) => {
|
|
3372
|
+
var _a3;
|
|
3373
|
+
let getColorSwatch = (colorSwatches == null ? void 0 : colorSwatches.filter(({ name }) => name == null ? void 0 : name.includes(item.value))[0]) || {};
|
|
3374
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3375
|
+
ColorSwatch,
|
|
3376
|
+
{
|
|
3377
|
+
id: `${value}_${index}`,
|
|
3378
|
+
name: value,
|
|
3379
|
+
value: item.value,
|
|
3380
|
+
rgb: getColorSwatch == null ? void 0 : getColorSwatch.rgb,
|
|
3381
|
+
image: getColorSwatch == null ? void 0 : getColorSwatch.image,
|
|
3382
|
+
onClick: (e) => handleFilterChange(value, e.currentTarget.value),
|
|
3383
|
+
defaultChecked: clickedFacets && ((_a3 = clickedFacets[value]) == null ? void 0 : _a3.includes(item.value))
|
|
3384
|
+
}
|
|
3385
|
+
) }, index);
|
|
3386
|
+
}) });
|
|
3387
|
+
}
|
|
3388
|
+
return blockComponent;
|
|
3389
|
+
};
|
|
3390
|
+
const filterVerticalComponents = allowedFilter.map((filter, indexFilter) => {
|
|
3391
|
+
const { value, label, display } = filter;
|
|
3392
|
+
let isActive = clickedOpenFilterId === value;
|
|
3393
|
+
let items = searchResultFacets[value];
|
|
3394
|
+
let isRender = Boolean(display.toLowerCase() === "slider" ? items : items == null ? void 0 : items.length);
|
|
3395
|
+
let isNotRerender = ["select"].includes(display.toLowerCase()) && (items == null ? void 0 : items.length);
|
|
3396
|
+
let classesUlElement = ["sledge-instant-search__result-filter-item-list"];
|
|
3397
|
+
let getFacetComponent = facetComponent(filter);
|
|
3398
|
+
if (display.toLowerCase() === "swatch" && (items == null ? void 0 : items.length)) {
|
|
3399
|
+
classesUlElement.push("sledge-instant-search__result-filter-item-color-swatches");
|
|
3400
|
+
}
|
|
3401
|
+
return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
|
|
3402
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title", onClick: () => handleOpenFilter(value), children: [
|
|
3403
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-title", style: filter_title_style, children: label }),
|
|
3404
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: false, animate: isActive ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" }) })
|
|
3405
|
+
] }),
|
|
3406
|
+
isActive && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: isNotRerender ? getFacetComponent : !isFilterChanged ? getFacetComponent : null })
|
|
3407
|
+
] }, indexFilter) : null;
|
|
3408
|
+
});
|
|
3409
|
+
const filterHorizontalComponents = allowedFilter.map((filter, indexFilter) => {
|
|
3410
|
+
const { value, label, display } = filter;
|
|
3411
|
+
let isActive = clickedOpenFilterId === value;
|
|
3412
|
+
let items = searchResultFacets[value];
|
|
3413
|
+
let isRender = Boolean(display.toLowerCase() === "slider" ? items : items == null ? void 0 : items.length);
|
|
3414
|
+
let isNotRerender = ["radio", "select"].includes(display.toLowerCase()) && (items == null ? void 0 : items.length);
|
|
3415
|
+
let classesUlElement = ["sledge-instant-search__result-filter-item-list"];
|
|
3416
|
+
let getFacetComponent = facetComponent(filter);
|
|
3417
|
+
if (display.toLowerCase() === "swatch" && (items == null ? void 0 : items.length)) {
|
|
3418
|
+
classesUlElement.push("sledge-instant-search__result-filter-item-color-swatches");
|
|
3419
|
+
}
|
|
3420
|
+
return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3421
|
+
Popover,
|
|
3422
|
+
{
|
|
3423
|
+
trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { type: "button", onClick: () => handleOpenFilter(value), children: [
|
|
3424
|
+
label,
|
|
3425
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "closed", animate: isActive ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, className: "sort-trigger-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 20, height: 20, color: "#000000" }) })
|
|
3426
|
+
] }),
|
|
3427
|
+
content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-facet", children: isActive && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: isNotRerender ? getFacetComponent : !isFilterChanged ? getFacetComponent : null }) }),
|
|
3428
|
+
withOpenState: false,
|
|
3429
|
+
setIsOpen: (open) => setClickedOpenFilterId(!open ? "" : value),
|
|
3430
|
+
hideCloseIcon: true,
|
|
3431
|
+
align: "center",
|
|
3432
|
+
className: "sledge-instant-search__filter-horizontal-facet-content",
|
|
3433
|
+
customArrow: `<svg style="transform: rotate(180deg); margin-bottom: 3px; stroke-dasharray: 0,0,36;" width="44" height="12" viewBox="0 0 44 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23.2222 1.99825e-06C23.2222 11.9998 4.88979 11.9999 0.000354767 12L23.2222 12L44 12C23.2222 12 23.2222 1.99825e-06 23.2222 1.99825e-06Z" fill="white" stroke="#393d4e" stroke-width="1px" /></svg>`
|
|
3434
|
+
}
|
|
3435
|
+
) }, indexFilter) : null;
|
|
3436
|
+
});
|
|
3437
|
+
let dataClickedFacets = [];
|
|
3438
|
+
Object.entries(clickedFacets).map((facet) => {
|
|
3439
|
+
var _a2, _b2;
|
|
3440
|
+
if ((facet == null ? void 0 : facet.length) && facet[1].length) {
|
|
3441
|
+
let getName = facet[0];
|
|
3442
|
+
let isAdditionalFilter = ["variants.inventory_quantity"].includes(getName);
|
|
3443
|
+
if (isAdditionalFilter)
|
|
3444
|
+
return;
|
|
3445
|
+
let isRange = ["variants.price"].includes(getName);
|
|
3446
|
+
let getAllowedFilterOne = allowedFilter.filter(({ value }) => value == null ? void 0 : value.includes(getName));
|
|
3447
|
+
let getLabel = (getAllowedFilterOne == null ? void 0 : getAllowedFilterOne.length) ? getAllowedFilterOne[0].label : getName;
|
|
3448
|
+
let items = Array.isArray(facet[1]) && ((_a2 = facet[1]) == null ? void 0 : _a2.length) > 1 ? isRange ? dataClickedFacets.push({
|
|
3449
|
+
label: getLabel,
|
|
3450
|
+
name: getName,
|
|
3451
|
+
value: facet[1]
|
|
3452
|
+
}) : (_b2 = facet[1]) == null ? void 0 : _b2.map((item) => {
|
|
3453
|
+
dataClickedFacets.push({
|
|
3454
|
+
label: getLabel,
|
|
3455
|
+
name: getName,
|
|
3456
|
+
value: item
|
|
3457
|
+
});
|
|
3458
|
+
}) : dataClickedFacets.push({
|
|
3459
|
+
label: getLabel,
|
|
3460
|
+
name: getName,
|
|
3461
|
+
value: facet[1][0]
|
|
3462
|
+
});
|
|
3463
|
+
return items;
|
|
3464
|
+
}
|
|
3465
|
+
});
|
|
3466
|
+
const paginationComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Pagination, { currentPage, totalPage, totalResult: totalSearchResult, onChange: (page) => handlePageChange(page) });
|
|
3467
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3468
|
+
((_f = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _f.enable_on_search) && ((_g = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _g.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading ? filterHorizontalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoadingSetting ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-loading", children: filterHorizontalSkeleton }) : filterHorizontalComponents.every((currentValue) => !currentValue) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal-wrapper", children: [
|
|
3469
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal", children: filterHorizontalComponents }),
|
|
3470
|
+
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_h = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _h.show_refine_by_block)) ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: Boolean(dataClickedFacets.every((currentValue) => !currentValue)) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal", children: [
|
|
3471
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3472
|
+
"div",
|
|
3473
|
+
{
|
|
3474
|
+
className: "sledge-instant-search__result-filter-horizontal-refine-item sledge-instant-search__result-filter-horizontal-refine-item-clear-all",
|
|
3475
|
+
onClick: handleFilterReset,
|
|
3476
|
+
children: "Clear All"
|
|
3477
|
+
}
|
|
3478
|
+
),
|
|
3479
|
+
dataClickedFacets.map((itemClickedFacet, index) => {
|
|
3480
|
+
const { label, name, value } = itemClickedFacet;
|
|
3481
|
+
return facetBlockSelected({
|
|
3482
|
+
label,
|
|
3483
|
+
name,
|
|
3484
|
+
value,
|
|
3485
|
+
index
|
|
3486
|
+
});
|
|
3487
|
+
})
|
|
3488
|
+
] }) }) : null
|
|
3489
|
+
] }) }) }) : null,
|
|
3490
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", "data-filter-layout": (_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.layout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3491
|
+
((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.enable_on_search) && ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.layout) === "vertical" ? isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : filterVerticalComponents.every((currentValue) => !currentValue) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: isLoadingSetting ? filterVerticalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3492
|
+
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.show_refine_by_block)) ? Boolean(dataClickedFacets.every((currentValue) => !currentValue)) ? null : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
|
|
3493
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title-refine", children: [
|
|
3494
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { className: "sledge-instant-search__result-filter-item-title-refine-heading", children: "Filter" }),
|
|
3495
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-item-title-refine-clear", onClick: handleFilterReset, children: "Clear All" })
|
|
3496
|
+
] }),
|
|
3497
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-item-refine-selected-flex", children: dataClickedFacets.map((itemClickedFacet, index) => {
|
|
3498
|
+
const { label, name, value } = itemClickedFacet;
|
|
3499
|
+
return facetBlockSelected({
|
|
3500
|
+
label,
|
|
3501
|
+
name,
|
|
3502
|
+
value,
|
|
3503
|
+
index
|
|
3504
|
+
});
|
|
3505
|
+
}) })
|
|
3506
|
+
] }) : null,
|
|
3507
|
+
filterVerticalComponents
|
|
3508
|
+
] }) }) : null,
|
|
3509
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
|
|
3510
|
+
isFirstLoading ? searchAndSelectOptionSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
3511
|
+
((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.layout) === "horizontal" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal", children: summaryText }),
|
|
3512
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3513
|
+
SearchInputField,
|
|
3514
|
+
{
|
|
3515
|
+
type: "text",
|
|
3516
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
3517
|
+
placeholder: "Search products...",
|
|
3518
|
+
value: keyword,
|
|
3519
|
+
onChange: ({ value }) => setKeyword && setKeyword(value),
|
|
3520
|
+
onResetField: () => setKeyword && setKeyword(""),
|
|
3521
|
+
className: "sledge-instant-search__result-data-keyword-form",
|
|
3522
|
+
withClearField: true
|
|
3523
|
+
}
|
|
3524
|
+
),
|
|
3525
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-summary-item sledge-instant-search__result-data-summary-select-field", children: [
|
|
3526
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-summary-select-field-item", children: [
|
|
3527
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Sort by:" }),
|
|
3528
|
+
allowedSorts && Boolean(allowedSorts == null ? void 0 : allowedSorts.length) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3529
|
+
SelectField,
|
|
3530
|
+
{
|
|
3531
|
+
align: "end",
|
|
3532
|
+
prefixLabel: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 18, height: 18, viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3533
|
+
"path",
|
|
3534
|
+
{
|
|
3535
|
+
d: "M12.6296 4.34737C12.9144 4.34737 13.1497 4.55898 13.1869 4.83354L13.1921 4.90987L13.192 13.7599L15.2892 11.6543C15.5083 11.4341 15.8645 11.4333 16.0847 11.6525C16.2848 11.8517 16.3037 12.1641 16.1408 12.3847L16.0865 12.4479L13.0282 15.5204C13.0097 15.5386 12.991 15.555 12.9712 15.5701L13.0282 15.5204C13.0006 15.5482 12.9708 15.5724 12.9394 15.5932C12.9285 15.6 12.9171 15.607 12.9055 15.6135C12.8946 15.62 12.8837 15.6258 12.8725 15.6311C12.8615 15.6359 12.8504 15.6408 12.8391 15.6454C12.8247 15.6515 12.8099 15.6568 12.795 15.6613C12.7862 15.6637 12.7772 15.6662 12.7681 15.6685C12.7519 15.673 12.7357 15.6763 12.7193 15.6789C12.7116 15.6798 12.7036 15.6809 12.6955 15.6819C12.677 15.6844 12.6587 15.6857 12.6404 15.686C12.6368 15.6857 12.6332 15.6857 12.6296 15.6857L12.6186 15.686C12.6003 15.6857 12.582 15.6844 12.5637 15.6823L12.6296 15.6857C12.5989 15.6857 12.5689 15.6833 12.5396 15.6785C12.5233 15.6763 12.5071 15.673 12.4909 15.6689C12.4824 15.6663 12.4738 15.6639 12.4654 15.6614C12.4493 15.6569 12.4332 15.6512 12.4174 15.6448C12.4088 15.6408 12.4005 15.6372 12.3922 15.6333C12.3793 15.6278 12.3663 15.6211 12.3535 15.6139C12.342 15.6069 12.3307 15.6 12.3196 15.5926C12.3109 15.5875 12.3024 15.5815 12.294 15.5752L12.288 15.5701C12.2682 15.555 12.2494 15.5386 12.2318 15.5209L12.2308 15.5204L9.1725 12.4479C8.95334 12.2278 8.95416 11.8716 9.17434 11.6525C9.3745 11.4532 9.68704 11.4358 9.90687 11.5997L9.96983 11.6543L12.067 13.7614L12.0671 4.90987C12.0671 4.59921 12.3189 4.34737 12.6296 4.34737ZM5.18325 2.3122L5.19421 2.31189C5.21254 2.31224 5.23085 2.31348 5.24908 2.31562L5.18325 2.3122C5.21389 2.3122 5.24396 2.31465 5.27328 2.31937C5.28931 2.32156 5.3054 2.32487 5.32136 2.32889C5.33074 2.33164 5.3403 2.33433 5.34975 2.33725C5.36452 2.34142 5.37882 2.34648 5.39293 2.35213C5.40313 2.35668 5.41346 2.36119 5.42362 2.366C5.4357 2.37123 5.4476 2.37737 5.45931 2.38397C5.46933 2.39014 5.47926 2.39616 5.48898 2.40246C5.49898 2.40841 5.50899 2.41537 5.51882 2.42269L5.582 2.47746L8.64033 5.54996C8.85949 5.77013 8.85867 6.12629 8.63849 6.34545C8.43833 6.54469 8.12579 6.56212 7.90596 6.39822L7.843 6.34361L5.74525 4.23564L5.74575 13.088C5.74575 13.3987 5.49391 13.6505 5.18325 13.6505C4.89848 13.6505 4.66313 13.4389 4.62588 13.1644L4.62075 13.088L4.62025 4.23639L2.52367 6.34361C2.32443 6.54377 2.01197 6.56265 1.79139 6.39977L1.72817 6.34545C1.52801 6.14621 1.50914 5.83376 1.67202 5.61317L1.72633 5.54996L4.78467 2.47746L4.81779 2.44709C4.82557 2.44043 4.83353 2.43399 4.84167 2.42776L4.78467 2.47746C4.81226 2.44974 4.84202 2.42549 4.87341 2.40473C4.88436 2.39791 4.89574 2.39094 4.90738 2.38438C4.91819 2.37787 4.92917 2.37215 4.9403 2.36682C4.95128 2.36196 4.96242 2.35706 4.97375 2.35251C4.98814 2.34636 5.00289 2.34115 5.0178 2.33657C5.02687 2.33414 5.03616 2.33154 5.04555 2.32918C5.06066 2.32503 5.07593 2.32186 5.09129 2.31932C5.10053 2.31817 5.10959 2.31691 5.11871 2.31586C5.13607 2.31348 5.15388 2.31227 5.17171 2.3119C5.17564 2.31224 5.17944 2.3122 5.18325 2.3122Z",
|
|
3536
|
+
fill: "black"
|
|
3537
|
+
}
|
|
3538
|
+
) }),
|
|
3539
|
+
options: allowedSorts.map((item) => {
|
|
3540
|
+
const { label, value } = item;
|
|
3541
|
+
return {
|
|
3542
|
+
label,
|
|
3543
|
+
value
|
|
3544
|
+
};
|
|
3545
|
+
}),
|
|
3546
|
+
value: clickedSortId,
|
|
3547
|
+
onChange: ({ label, value }) => handleChangeSort(label, value)
|
|
3548
|
+
}
|
|
3549
|
+
)
|
|
3550
|
+
] }),
|
|
3551
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-summary-select-field-item", children: [
|
|
3552
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Limit:" }),
|
|
3553
|
+
((_n = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _n.allowed_limit) && Boolean((_p = (_o = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _o.allowed_limit) == null ? void 0 : _p.length) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3554
|
+
SelectField,
|
|
3555
|
+
{
|
|
3556
|
+
align: "end",
|
|
3557
|
+
options: displaySettings.search.allowed_limit.map((item) => {
|
|
3558
|
+
return {
|
|
3559
|
+
label: item,
|
|
3560
|
+
value: item
|
|
3561
|
+
};
|
|
3562
|
+
}),
|
|
3563
|
+
value: clickedLimitId,
|
|
3564
|
+
onChange: ({ value }) => handleChangeLimit(value)
|
|
3565
|
+
}
|
|
3566
|
+
)
|
|
3567
|
+
] })
|
|
3568
|
+
] })
|
|
3569
|
+
] }),
|
|
3570
|
+
isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3571
|
+
productGridSkeleton,
|
|
3572
|
+
(searchResult == null ? void 0 : searchResult.length) ? paginationComponent : null
|
|
3573
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3574
|
+
((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.layout) === "vertical" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-vertical", children: summaryText }),
|
|
3575
|
+
(searchResult == null ? void 0 : searchResult.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3576
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3577
|
+
ProductGrid,
|
|
3578
|
+
{
|
|
3579
|
+
sourceApp: "instant-search",
|
|
3580
|
+
type: "large",
|
|
3581
|
+
data: searchResult.map((item) => {
|
|
3582
|
+
const { id, title, currency, image, url, vendor, variants } = item || {};
|
|
3583
|
+
return {
|
|
3584
|
+
product: {
|
|
3585
|
+
id,
|
|
3586
|
+
title,
|
|
3587
|
+
image,
|
|
3588
|
+
url,
|
|
3589
|
+
vendor,
|
|
3590
|
+
currency
|
|
3591
|
+
},
|
|
3592
|
+
variants: (variants == null ? void 0 : variants.length) ? variants.map((variant) => {
|
|
3593
|
+
const { id: variant_id, title: variant_title, price, sku, inventory_quantity } = variant || {};
|
|
3594
|
+
return { id: variant_id, title: variant_title, price, sku, inventory_quantity };
|
|
3595
|
+
}) : []
|
|
3596
|
+
};
|
|
3597
|
+
}),
|
|
3598
|
+
setting: {
|
|
3599
|
+
show_vendor: (_r = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _r.show_vendor,
|
|
3600
|
+
show_sku: (_s = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _s.show_sku,
|
|
3601
|
+
show_price: (_t = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _t.show_price
|
|
3602
|
+
},
|
|
3603
|
+
customProductCard,
|
|
3604
|
+
showOptionOutOfStock: true,
|
|
3605
|
+
onAfterAddToCart,
|
|
3606
|
+
onAfterAddWishlist,
|
|
3607
|
+
onAfterRemoveWishlist,
|
|
3608
|
+
onAfterRenderProduct
|
|
3609
|
+
}
|
|
3610
|
+
),
|
|
3611
|
+
paginationComponent
|
|
3612
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultEmpty, {})
|
|
3613
|
+
] })
|
|
3614
|
+
] })
|
|
3615
|
+
] }) })
|
|
3616
|
+
] });
|
|
3617
|
+
};
|
|
3618
|
+
const ResultCategory = (props) => {
|
|
3619
|
+
var _a, _b, _c, _d;
|
|
3620
|
+
const { keyword, clickedTabIndexId, clickedTabIndexName, setKeyword } = props || {};
|
|
3621
|
+
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
3622
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
3623
|
+
const [clickedSortId, setClickedSortId] = React__default.useState("");
|
|
3624
|
+
const [searchResult, setSearchResult] = React__default.useState([]);
|
|
3625
|
+
const [searchProcessingTimeMs, setSearchProcessingTimeMs] = React__default.useState(0);
|
|
3626
|
+
const [currentPage, setCurrentPage] = React__default.useState(1);
|
|
3627
|
+
const [totalPage, setTotalPage] = React__default.useState(0);
|
|
3628
|
+
const [totalSearchResult, setTotalSearchResult] = React__default.useState(0);
|
|
3629
|
+
const [summaryText, setSummaryText] = React__default.useState(null);
|
|
3630
|
+
const previousState = usePrevious({ keyword });
|
|
3631
|
+
const handleSearchResultData = (result) => {
|
|
3632
|
+
if (!result)
|
|
3633
|
+
return;
|
|
3634
|
+
const { hits, processingTimeMs, totalHits, totalPages } = result;
|
|
3635
|
+
setIsFirstLoading(false);
|
|
3636
|
+
setIsLoading(false);
|
|
3637
|
+
setSearchResult(hits);
|
|
3638
|
+
setSearchProcessingTimeMs(processingTimeMs || 0);
|
|
3639
|
+
setTotalPage(totalPages);
|
|
3640
|
+
setTotalSearchResult(totalHits || 0);
|
|
3641
|
+
setSummaryText(
|
|
3642
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-item", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-data-summary-text", children: [
|
|
3643
|
+
totalHits,
|
|
3644
|
+
" result",
|
|
3645
|
+
" ",
|
|
3646
|
+
(keyword == null ? void 0 : keyword.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3647
|
+
"for ",
|
|
3648
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-data-summary-text-keyword", children: [
|
|
3649
|
+
'"',
|
|
3650
|
+
keyword,
|
|
3651
|
+
'"'
|
|
3652
|
+
] })
|
|
3653
|
+
] }) : null
|
|
3654
|
+
] }) })
|
|
3655
|
+
);
|
|
3656
|
+
};
|
|
3657
|
+
const handleSearchResult = async () => {
|
|
3658
|
+
if (!clickedTabIndexId)
|
|
3659
|
+
return;
|
|
3660
|
+
setIsLoading(true);
|
|
3661
|
+
let response;
|
|
3662
|
+
let body = {
|
|
3663
|
+
q: keyword,
|
|
3664
|
+
sort: clickedSortId ? [clickedSortId] : [],
|
|
3665
|
+
page: currentPage,
|
|
3666
|
+
hitsPerPage: 12
|
|
3667
|
+
};
|
|
3668
|
+
response = await search(clickedTabIndexId, body);
|
|
3669
|
+
handleSearchResultData(response);
|
|
3670
|
+
};
|
|
3671
|
+
const handlePageChange = (page) => {
|
|
3672
|
+
setCurrentPage(page);
|
|
3673
|
+
};
|
|
3674
|
+
React__default.useEffect(() => {
|
|
3675
|
+
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
3676
|
+
const delayDebounceFn = setTimeout(() => {
|
|
3677
|
+
handleSearchResult();
|
|
3678
|
+
}, 500);
|
|
3679
|
+
return () => clearTimeout(delayDebounceFn);
|
|
3680
|
+
} else {
|
|
3681
|
+
handleSearchResult();
|
|
3682
|
+
}
|
|
3683
|
+
}, [clickedSortId, keyword, currentPage, clickedTabIndexId]);
|
|
3684
|
+
const searchKeywordComponent = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-keyword sledge-instant-search__result-data-keyword-category", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3685
|
+
SearchInputField,
|
|
3686
|
+
{
|
|
3687
|
+
type: "text",
|
|
3688
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
3689
|
+
placeholder: `Search ${clickedTabIndexName ? clickedTabIndexName.toLowerCase() : ""}...`,
|
|
3690
|
+
value: keyword,
|
|
3691
|
+
onChange: ({ value }) => setKeyword && setKeyword(value),
|
|
3692
|
+
onResetField: () => setKeyword && setKeyword(""),
|
|
3693
|
+
className: "sledge-instant-search__result-data-keyword-form",
|
|
3694
|
+
withClearField: true
|
|
3695
|
+
}
|
|
3696
|
+
) });
|
|
3697
|
+
const summaryTextSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "grey-100", rounded: "md", animationDuration: "18s" }) });
|
|
3698
|
+
const skeletonLoadingComponent = ((_a = String(clickedTabIndexId)) == null ? void 0 : _a.includes("collection")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.CollectionGrid, { count: 3 }) : ((_b = String(clickedTabIndexId)) == null ? void 0 : _b.includes("page")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.PageGrid, { count: 12 }) : ((_c = String(clickedTabIndexId)) == null ? void 0 : _c.includes("blog")) || ((_d = String(clickedTabIndexId)) == null ? void 0 : _d.includes("article")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.BlogGrid, { count: 12 }) : null;
|
|
3699
|
+
const ProvideElementFirstLoading = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-category-wrapper", children: [
|
|
3700
|
+
searchKeywordComponent,
|
|
3701
|
+
summaryTextSkeleton,
|
|
3702
|
+
skeletonLoadingComponent
|
|
3703
|
+
] });
|
|
3704
|
+
const ProvideElementLoading = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3705
|
+
searchKeywordComponent,
|
|
3706
|
+
summaryTextSkeleton,
|
|
3707
|
+
skeletonLoadingComponent
|
|
3708
|
+
] });
|
|
3709
|
+
const ProvideElement = (elementProps) => {
|
|
3710
|
+
var _a2, _b2, _c2, _d2;
|
|
3711
|
+
return ((_a2 = String(clickedTabIndexId)) == null ? void 0 : _a2.includes("collection")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(CollectionGrid, { ...elementProps }) : ((_b2 = String(clickedTabIndexId)) == null ? void 0 : _b2.includes("page")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(PageGrid, { ...elementProps }) : ((_c2 = String(clickedTabIndexId)) == null ? void 0 : _c2.includes("blog")) || ((_d2 = String(clickedTabIndexId)) == null ? void 0 : _d2.includes("article")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlogGrid, { ...elementProps }) : null;
|
|
3712
|
+
};
|
|
3713
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(ProvideElementFirstLoading, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-category-wrapper", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(ProvideElementLoading, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3714
|
+
searchKeywordComponent,
|
|
3715
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary", children: summaryText }),
|
|
3716
|
+
(searchResult == null ? void 0 : searchResult.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3717
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3718
|
+
ProvideElement,
|
|
3719
|
+
{
|
|
3720
|
+
data: searchResult.map((item) => {
|
|
3721
|
+
const { id, title, url } = item;
|
|
3722
|
+
return {
|
|
3723
|
+
id,
|
|
3724
|
+
title,
|
|
3725
|
+
description: `${title}${clickedTabIndexName ? ` ${clickedTabIndexName.toLowerCase()}` : ""}`,
|
|
3726
|
+
url,
|
|
3727
|
+
image: ""
|
|
3728
|
+
};
|
|
3729
|
+
})
|
|
3730
|
+
}
|
|
3731
|
+
),
|
|
3732
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Pagination, { currentPage, totalPage, totalResult: totalSearchResult, onChange: (page) => handlePageChange(page) })
|
|
3733
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultEmpty, {})
|
|
3734
|
+
] }) }) });
|
|
3735
|
+
};
|
|
3736
|
+
const ResultEmpty = (props) => {
|
|
3737
|
+
const [title, setTitle] = React__default.useState("");
|
|
3738
|
+
const [description, setDescription] = React__default.useState("");
|
|
3739
|
+
React__default.useEffect(() => {
|
|
3740
|
+
setTitle("No results found");
|
|
3741
|
+
setDescription("Your search did not match any results. <br/> Please try again");
|
|
3742
|
+
}, []);
|
|
3743
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-empty", children: [
|
|
3744
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-empty-title", dangerouslySetInnerHTML: { __html: title } }),
|
|
3745
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-empty-description", dangerouslySetInnerHTML: { __html: description } })
|
|
3746
|
+
] });
|
|
3747
|
+
};
|
|
3748
|
+
const SearchWidget$1 = "";
|
|
3749
|
+
const SearchWidget = (props) => {
|
|
3750
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
3751
|
+
const { width = "400px", customProductCard, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
|
|
3752
|
+
const { isRenderApp } = React__default.useContext(SledgeContext);
|
|
3753
|
+
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
3754
|
+
const [keyword, setKeyword] = React__default.useState("");
|
|
3755
|
+
const [suffixIndexProduct, setSuffixIndexProduct] = React__default.useState("");
|
|
3756
|
+
const [searchResultProduct, setSearchResultProduct] = React__default.useState([]);
|
|
3757
|
+
const [searchResultOther, setSearchResultOther] = React__default.useState([]);
|
|
3758
|
+
const [allowedTabs, setAllowedTabs] = React__default.useState([]);
|
|
3759
|
+
const [hiddenTags, setHiddenTags] = React__default.useState([]);
|
|
3760
|
+
const [displaySettings, setDisplaySettings] = React__default.useState({});
|
|
3761
|
+
const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
|
|
3762
|
+
const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
|
|
3763
|
+
const previousState = usePrevious({ keyword });
|
|
3764
|
+
const handleMultiSearch = async (data, onSearch = false) => {
|
|
3765
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
|
|
3766
|
+
if (!keyword.length)
|
|
3767
|
+
return;
|
|
3768
|
+
setIsLoading(true);
|
|
3769
|
+
const { tabs, suffix_index_product, hidden_tags, display } = data;
|
|
3770
|
+
const suggestion = ((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion) || {};
|
|
3771
|
+
let response;
|
|
3772
|
+
let body = {
|
|
3773
|
+
queries: tabs.map((tab) => {
|
|
3774
|
+
var _a3;
|
|
3775
|
+
const { index } = tab;
|
|
3776
|
+
let isProductIndex = index.includes(suffix_index_product);
|
|
3777
|
+
let additionalFilter = [];
|
|
3778
|
+
if (hidden_tags == null ? void 0 : hidden_tags.length)
|
|
3779
|
+
additionalFilter.push(`tags NOT IN [${hidden_tags}]`);
|
|
3780
|
+
if (!((_a3 = display == null ? void 0 : display.filter) == null ? void 0 : _a3.show_out_of_stock))
|
|
3781
|
+
additionalFilter.push("variants.inventory_quantity > 0");
|
|
3782
|
+
return {
|
|
3783
|
+
indexUid: index,
|
|
3784
|
+
q: keyword,
|
|
3785
|
+
hitsPerPage: isProductIndex ? 6 : 4,
|
|
3786
|
+
filter: isProductIndex ? additionalFilter.join(" AND ") : ""
|
|
3787
|
+
};
|
|
3788
|
+
})
|
|
3789
|
+
};
|
|
3790
|
+
response = await multiSearch(body);
|
|
3791
|
+
if (!response)
|
|
3792
|
+
return;
|
|
3793
|
+
const { results } = response;
|
|
3794
|
+
let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(suffix_index_product));
|
|
3795
|
+
if (onSearch && (keyword == null ? void 0 : keyword.length)) {
|
|
3796
|
+
searchTrigger({
|
|
3797
|
+
keyword,
|
|
3798
|
+
resultCount: ((_b2 = valueSearchResultProduct[0]) == null ? void 0 : _b2.totalHits) || 0
|
|
3799
|
+
});
|
|
3800
|
+
}
|
|
3801
|
+
let valueSearchResultOther = ((_c2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(suffix_index_product)))) == null ? void 0 : _c2.map((result) => {
|
|
3802
|
+
const { indexUid } = result;
|
|
3803
|
+
const { name } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
|
|
3804
|
+
return {
|
|
3805
|
+
...result,
|
|
3806
|
+
...{
|
|
3807
|
+
name: name || ""
|
|
3808
|
+
}
|
|
3809
|
+
};
|
|
3810
|
+
})) || [];
|
|
3811
|
+
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_d2 = valueSearchResultProduct[0]) == null ? void 0 : _d2.hits : [];
|
|
3812
|
+
let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
|
|
3813
|
+
let isPriorityZeroCharacter = Boolean(
|
|
3814
|
+
!keyword.length && Object.keys(suggestion).length && ((_f2 = (_e2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _e2.products) == null ? void 0 : _f2.active) && ((_i2 = (_h2 = (_g2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _g2.products) == null ? void 0 : _h2.list) == null ? void 0 : _i2.length)
|
|
3815
|
+
);
|
|
3816
|
+
setSearchResultProduct(isPriorityZeroCharacter ? (_k2 = (_j2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _j2.products) == null ? void 0 : _k2.list : getValueSearchResultProduct);
|
|
3817
|
+
setSearchResultOther(valueSearchResultOther);
|
|
3818
|
+
setSuggestionIndex(valueSuggestionIndex);
|
|
3819
|
+
setIsLoading(false);
|
|
3820
|
+
};
|
|
3821
|
+
const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
|
|
3822
|
+
var _a2;
|
|
3823
|
+
if (!keyword.length)
|
|
3824
|
+
return;
|
|
3825
|
+
let response;
|
|
3826
|
+
let run = false;
|
|
3827
|
+
response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
3828
|
+
if (!response)
|
|
3829
|
+
return;
|
|
3830
|
+
const { status, data } = response;
|
|
3831
|
+
const { code } = status;
|
|
3832
|
+
const { tabs, suffix_index_product, hidden_tags, display } = data;
|
|
3833
|
+
run = code === 200 || false;
|
|
3834
|
+
if (run) {
|
|
3835
|
+
setAllowedTabs(tabs);
|
|
3836
|
+
setSuffixIndexProduct(suffix_index_product);
|
|
3837
|
+
setHiddenTags(hidden_tags);
|
|
3838
|
+
setDisplaySettings(display);
|
|
3839
|
+
setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
|
|
3840
|
+
await handleMultiSearch(data);
|
|
3841
|
+
}
|
|
3842
|
+
};
|
|
3843
|
+
React__default.useEffect(() => {
|
|
3844
|
+
if (!(isRenderApp == null ? void 0 : isRenderApp.instantSearch))
|
|
3845
|
+
return;
|
|
3846
|
+
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
3847
|
+
}, [keyword]);
|
|
3848
|
+
React__default.useEffect(() => {
|
|
3849
|
+
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
3850
|
+
const delayDebounceFn = setTimeout(() => {
|
|
3851
|
+
handleMultiSearch({ tabs: allowedTabs, suffix_index_product: suffixIndexProduct, hidden_tags: hiddenTags, display: displaySettings }, true);
|
|
3852
|
+
}, 500);
|
|
3853
|
+
return () => clearTimeout(delayDebounceFn);
|
|
3854
|
+
}
|
|
3855
|
+
}, [keyword]);
|
|
3856
|
+
const wrapperStyle = {
|
|
3857
|
+
maxWidth: width
|
|
3858
|
+
};
|
|
3859
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-wrapper", style: wrapperStyle, children: [
|
|
3860
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3861
|
+
SearchInputField,
|
|
3862
|
+
{
|
|
3863
|
+
type: "text",
|
|
3864
|
+
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
3865
|
+
placeholder: "Search anything",
|
|
3866
|
+
value: keyword,
|
|
3867
|
+
onChange: ({ value }) => setKeyword(value),
|
|
3868
|
+
onResetField: () => setKeyword(""),
|
|
3869
|
+
withClearField: true
|
|
3870
|
+
}
|
|
3871
|
+
),
|
|
3872
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "hidden", animate: keyword.length ? "visible" : "hidden", variants: VISIBLE_ANIMATION, className: "sledge-instant-search__widget-search-form-result", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex", children: [
|
|
3873
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-other sledge-instant-search__widget-search-form-result-flex-item-other-skeleton", children: [0, 1, 2].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(React__default.Fragment, { children: [
|
|
3874
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3875
|
+
SkeletonLoading.Item,
|
|
3876
|
+
{
|
|
3877
|
+
width: "100%",
|
|
3878
|
+
height: "42px",
|
|
3879
|
+
color: "grey-100",
|
|
3880
|
+
rounded: "md",
|
|
3881
|
+
...Boolean(index) && {
|
|
3882
|
+
style: { marginTop: "12px" }
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
),
|
|
3886
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3887
|
+
"div",
|
|
3888
|
+
{
|
|
3889
|
+
style: {
|
|
3890
|
+
display: "flex",
|
|
3891
|
+
flexDirection: "column",
|
|
3892
|
+
justifyContent: "center",
|
|
3893
|
+
gap: "12px",
|
|
3894
|
+
marginTop: "12px"
|
|
3895
|
+
},
|
|
3896
|
+
children: [1, 2, 3].map((index2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3897
|
+
SkeletonLoading.Item,
|
|
3898
|
+
{
|
|
3899
|
+
width: "100%",
|
|
3900
|
+
height: "28px",
|
|
3901
|
+
color: "grey-100",
|
|
3902
|
+
rounded: "md",
|
|
3903
|
+
animationDuration: "13s",
|
|
3904
|
+
style: {
|
|
3905
|
+
maxWidth: "140px"
|
|
3906
|
+
}
|
|
3907
|
+
},
|
|
3908
|
+
index2
|
|
3909
|
+
))
|
|
3910
|
+
}
|
|
3911
|
+
)
|
|
3912
|
+
] }, index)) }),
|
|
3913
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-product", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 6, type: "small" }) })
|
|
3914
|
+
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { isLoading, withCorner: false, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3915
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex", children: [
|
|
3916
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-other", children: [
|
|
3917
|
+
Object.keys(suggestionSettings).length && ((_b = (_a = suggestionSettings[suggestionIndex]) == null ? void 0 : _a.keywords) == null ? void 0 : _b.active) && ((_e = (_d = (_c = suggestionSettings[suggestionIndex]) == null ? void 0 : _c.keywords) == null ? void 0 : _d.list) == null ? void 0 : _e.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3918
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-title", children: "Suggestions" }),
|
|
3919
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__widget-search-form-result-list", children: suggestionSettings[suggestionIndex].keywords.list.map((keyword2, index) => {
|
|
3920
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3921
|
+
"a",
|
|
3922
|
+
{
|
|
3923
|
+
href: `${SEARCH_RESULT_URL}?q=${keyword2}`,
|
|
3924
|
+
className: "sledge-instant-search__widget-search-form-result-list-link sledge-instant-search__widget-search-form-result-list-link-suggestion",
|
|
3925
|
+
children: [
|
|
3926
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 12, height: 12, color: "#677487" }),
|
|
3927
|
+
" ",
|
|
3928
|
+
keyword2
|
|
3929
|
+
]
|
|
3930
|
+
}
|
|
3931
|
+
) }, index);
|
|
3932
|
+
}) })
|
|
3933
|
+
] }) : null,
|
|
3934
|
+
searchResultOther.map((item, index) => {
|
|
3935
|
+
const { hits, name } = item;
|
|
3936
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(React__default.Fragment, { children: [
|
|
3937
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-title", children: name }),
|
|
3938
|
+
(hits == null ? void 0 : hits.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__widget-search-form-result-list", children: hits.map((hit, index2) => {
|
|
3939
|
+
const { title, url } = hit;
|
|
3940
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: url, className: "sledge-instant-search__widget-search-form-result-list-link", children: title }) }, index2);
|
|
3941
|
+
}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__widget-search-form-result-list", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "sledge-instant-search__widget-search-form-result-item-disabled", children: [
|
|
3942
|
+
"No ",
|
|
3943
|
+
name.toLowerCase(),
|
|
3944
|
+
" were found"
|
|
3945
|
+
] }) })
|
|
3946
|
+
] }, index);
|
|
3947
|
+
})
|
|
3948
|
+
] }),
|
|
3949
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-product", children: [
|
|
3950
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-title-product", children: "Products" }),
|
|
3951
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-product", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3952
|
+
ProductGrid,
|
|
3953
|
+
{
|
|
3954
|
+
sourceApp: "instant-search",
|
|
3955
|
+
type: "small",
|
|
3956
|
+
data: searchResultProduct.map((item) => {
|
|
3957
|
+
const { id, title, currency, image, url, vendor, variants } = item || {};
|
|
3958
|
+
return {
|
|
3959
|
+
product: {
|
|
3960
|
+
id,
|
|
3961
|
+
title,
|
|
3962
|
+
image,
|
|
3963
|
+
url,
|
|
3964
|
+
vendor,
|
|
3965
|
+
currency
|
|
3966
|
+
},
|
|
3967
|
+
variants: (variants == null ? void 0 : variants.length) ? variants.map((variant) => {
|
|
3968
|
+
const { id: variant_id, title: variant_title, price, sku, inventory_quantity } = variant || {};
|
|
3969
|
+
return { id: variant_id, title: variant_title, price, sku, inventory_quantity };
|
|
3970
|
+
}) : []
|
|
3971
|
+
};
|
|
3972
|
+
}),
|
|
3973
|
+
setting: {
|
|
3974
|
+
show_vendor: (_f = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _f.show_vendor,
|
|
3975
|
+
show_sku: (_g = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _g.show_sku,
|
|
3976
|
+
show_price: (_h = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _h.show_price
|
|
3977
|
+
},
|
|
3978
|
+
customProductCard,
|
|
3979
|
+
showOptionOutOfStock: true,
|
|
3980
|
+
onAfterAddToCart,
|
|
3981
|
+
onAfterAddWishlist,
|
|
3982
|
+
onAfterRemoveWishlist,
|
|
3983
|
+
onAfterRenderProduct
|
|
3984
|
+
}
|
|
3985
|
+
) }) : Object.keys(suggestionSettings).length && ((_j = (_i = suggestionSettings[suggestionIndex]) == null ? void 0 : _i.products) == null ? void 0 : _j.active) && ((_m = (_l = (_k = suggestionSettings[suggestionIndex]) == null ? void 0 : _k.products) == null ? void 0 : _l.list) == null ? void 0 : _m.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3986
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-product-suggestion-no-result-text", children: [
|
|
3987
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Sorry, nothing found for" }),
|
|
3988
|
+
" ",
|
|
3989
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: keyword }),
|
|
3990
|
+
". ",
|
|
3991
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Did you mean:" })
|
|
3992
|
+
] }),
|
|
3993
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3994
|
+
ProductGrid,
|
|
3995
|
+
{
|
|
3996
|
+
sourceApp: "instant-search",
|
|
3997
|
+
type: "small",
|
|
3998
|
+
data: suggestionSettings[suggestionIndex].products.list.map((item) => {
|
|
3999
|
+
const { id, title, currency, image, url, vendor, variants } = item || {};
|
|
4000
|
+
return {
|
|
4001
|
+
product: {
|
|
4002
|
+
id,
|
|
4003
|
+
title,
|
|
4004
|
+
image,
|
|
4005
|
+
url,
|
|
4006
|
+
vendor,
|
|
4007
|
+
currency
|
|
4008
|
+
},
|
|
4009
|
+
variants: (variants == null ? void 0 : variants.length) ? variants.map((variant) => {
|
|
4010
|
+
const { id: variant_id, title: variant_title, price, sku, inventory_quantity } = variant || {};
|
|
4011
|
+
return { id: variant_id, title: variant_title, price, sku, inventory_quantity };
|
|
4012
|
+
}) : []
|
|
4013
|
+
};
|
|
4014
|
+
}),
|
|
4015
|
+
setting: {
|
|
4016
|
+
show_vendor: (_n = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _n.show_vendor,
|
|
4017
|
+
show_sku: (_o = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _o.show_sku,
|
|
4018
|
+
show_price: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_price
|
|
4019
|
+
},
|
|
4020
|
+
customProductCard,
|
|
4021
|
+
showOptionOutOfStock: true,
|
|
4022
|
+
onAfterAddToCart,
|
|
4023
|
+
onAfterAddWishlist,
|
|
4024
|
+
onAfterRemoveWishlist,
|
|
4025
|
+
onAfterRenderProduct
|
|
4026
|
+
}
|
|
4027
|
+
)
|
|
4028
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-product-disabled", children: "No product were found" })
|
|
4029
|
+
] })
|
|
4030
|
+
] }),
|
|
4031
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_r = (_q = suggestionSettings[suggestionIndex]) == null ? void 0 : _q.products) == null ? void 0 : _r.active) && ((_u = (_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.list) == null ? void 0 : _u.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: `${SEARCH_RESULT_URL}?q=${keyword}`, className: "sledge-instant-search__widget-button-more", children: "View More Result" }) }) : null
|
|
4032
|
+
] }) }) })
|
|
4033
|
+
] });
|
|
4034
|
+
};
|
|
4035
|
+
export {
|
|
4036
|
+
ProductFilterWidget,
|
|
4037
|
+
SearchIconWidget,
|
|
4038
|
+
SearchIconWidgetPopup,
|
|
4039
|
+
SearchResultWidget,
|
|
4040
|
+
SearchWidget
|
|
4041
|
+
};
|
|
4042
|
+
//# sourceMappingURL=sledge-react-instant-search.js.map
|