@sledge-app/react-instant-search 1.0.35 → 1.0.37

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.
@@ -40,6 +40,8 @@ const DATASET_ATTRIBUTE_KEY = {
40
40
  SECTION_TITLE: "data-section-title",
41
41
  SECTION_DESCRIPTION: "data-section-description",
42
42
  USE_SLIDER: "data-use-slider",
43
+ FILL_COLOR: "data-fill-color",
44
+ OUTLINE_COLOR: "data-outline-color",
43
45
  POSITION_WIDGET: "data-position-widget"
44
46
  },
45
47
  WISHLIST: {
@@ -54,6 +56,7 @@ const DATASET_ATTRIBUTE_KEY = {
54
56
  RATING_TOTAL: "data-rating-total",
55
57
  RATING_AVERAGE: "data-rating-average",
56
58
  RENDER_REVIEW_PRODUCT_INFO: "data-render-review-product-info",
59
+ TRUST_BADGE_VARIANT: "data-trust-badge-variant",
57
60
  SHOW_RATING_AVERAGE: "data-show-rating-average"
58
61
  },
59
62
  INSTANT_SEARCH: {
@@ -72,7 +75,7 @@ const DATASET_ATTRIBUTE_KEY = {
72
75
  RENDER_ARTICLE_CARD: "data-render-article-card"
73
76
  },
74
77
  PRODUCT_RECOMMENDATION: {
75
- LIMIT_TO_DISPLAY: "data-limit-to-display",
78
+ DISPLAY_LIMIT: "data-display-limit",
76
79
  HIDDEN_PRODUCT_IDS: "data-hidden-product-ids"
77
80
  }
78
81
  };
@@ -103,6 +106,7 @@ const INTERNAL_SELECTOR_VALUE = {
103
106
  PRODUCT_REVIEW: {
104
107
  ELEMENT_WIDGET_POPUP_DETAIL: "product-review-widget-popup-detail",
105
108
  ELEMENT_WIDGET_FORM_ADD: "product-review-widget-form-add",
109
+ ELEMENT_STICKY_BADGE: "product-review-sticky-badge",
106
110
  ELEMENT_HAPPY_CUSTOMERS_PAGE_POPUP: "product-review-happy-customers-page-popup"
107
111
  },
108
112
  INSTANT_SEARCH: {
@@ -124,7 +128,9 @@ const SELECTOR = {
124
128
  ELEMENT_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-widget"]`,
125
129
  ELEMENT_HAPPY_CUSTOMERS_PAGE: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-happy-customers-page"]`,
126
130
  ELEMENT_RATING: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-rating"]`,
127
- ELEMENT_STICKY_SIDEBAR_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-sticky-sidebar-widget"]`
131
+ ELEMENT_TRUST_BADGE: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-trust-badge"]`,
132
+ ELEMENT_STICKY_SIDEBAR_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-sticky-sidebar-widget"]`,
133
+ ELEMENT_SNIPPET: `[${SELECTOR_ATTRIBUTE_KEY}="product-review-snippet"]`
128
134
  },
129
135
  INSTANT_SEARCH: {
130
136
  ELEMENT_SEARCH_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-widget"]`,
@@ -133,7 +139,8 @@ const SELECTOR = {
133
139
  ELEMENT_PLP_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-product-filter-widget"]`
134
140
  },
135
141
  PRODUCT_RECOMMENDATION: {
136
- ELEMENT_RECENTLY_VIEWED_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="product-recommendation-recently-viewed-widget"]`
142
+ ELEMENT_RECENTLY_VIEWED: `[${SELECTOR_ATTRIBUTE_KEY}="product-recommendation-recently-viewed"]`,
143
+ ELEMENT_RELATED_PRODUCTS: `[${SELECTOR_ATTRIBUTE_KEY}="product-recommendation-related-prodcuts"]`
137
144
  }
138
145
  };
139
146
  const DEFAULT_MAX_WIDTH_COMPONENT = "1180px";
@@ -150,7 +157,10 @@ const OBJECT_DATA_STRING_KEY = {
150
157
  CURRENT_PAGE: "{{ current_page }}",
151
158
  TOTAL_PAGE: "{{ total_page }}",
152
159
  TOTAL_RESULT: "{{ total_result }}",
153
- COLLECTION_NAME: "{{ collection_name }}"
160
+ COLLECTION_NAME: "{{ collection_name }}",
161
+ TOTAL_WISHLIST: "{{ total_wishlist }}",
162
+ ACCEPTED_FILETYPE_MEDIA: "{{ accepted_filetype_media }}",
163
+ MAX_SIZE_MEDIA: "{{ max_size_media }}"
154
164
  };
155
165
  const ELEMENT_ID = {
156
166
  PRODUCT_REVIEW: {
@@ -165,6 +175,213 @@ const PAYLOAD_API_ALIASES = {
165
175
  PUT: "dEnOjbvTzULLK",
166
176
  DELETE: "pLC93Tvsu6g7H"
167
177
  };
178
+ async function swr(url, options) {
179
+ if (typeof localStorage !== "undefined" && typeof caches !== "undefined" && options.method === "GET" && !(options == null ? void 0 : options.ignoreSWR)) {
180
+ const data = await getData(url);
181
+ return await data.json();
182
+ } else
183
+ return fetch(url, options).then((response) => response.json());
184
+ }
185
+ async function getData(url) {
186
+ const cacheVersion = 1;
187
+ const cacheName = `sledge-${cacheVersion}`;
188
+ return caches.open(cacheName).then((cache) => {
189
+ return cache.match(url).then((cachedResponse) => {
190
+ const fetchedResponse = fetch(url).then(async (networkResponse) => {
191
+ const mainUrl = url.split("?")[0];
192
+ const cacheMatches = await cache.matchAll();
193
+ const filteredCaches = await cacheMatches.filter((f) => f.url.includes(mainUrl) && f.url !== url);
194
+ for (const c of filteredCaches) {
195
+ await cache.delete(c.url);
196
+ }
197
+ cache.put(url, networkResponse.clone());
198
+ return networkResponse;
199
+ });
200
+ return cachedResponse || fetchedResponse;
201
+ });
202
+ });
203
+ }
204
+ const usePrevious = (value) => {
205
+ const ref = React__default.useRef();
206
+ React__default.useEffect(() => {
207
+ ref.current = value;
208
+ });
209
+ return ref.current;
210
+ };
211
+ const sanitizeDataId = (id) => {
212
+ if (!id)
213
+ return "";
214
+ let getId = String(id);
215
+ if (getId.includes("shopify") && getId.includes("/")) {
216
+ let arrId = getId.split("/");
217
+ return arrId[arrId.length - 1] || getId;
218
+ } else {
219
+ return getId;
220
+ }
221
+ };
222
+ const isFunction = (data) => typeof data === "function";
223
+ const scrollToElement = (params) => {
224
+ const { element, headerOffset } = params;
225
+ if (!element)
226
+ return;
227
+ var elementPosition = element == null ? void 0 : element.getBoundingClientRect().top;
228
+ var offsetPosition = elementPosition + window.scrollY - headerOffset;
229
+ window.scrollTo({
230
+ top: offsetPosition,
231
+ behavior: "smooth"
232
+ });
233
+ };
234
+ const getUnixTimestamp = (params) => {
235
+ const { addMoreTime = 0, addMoreTimeBy = "day" } = params || {};
236
+ let moreTime = 0;
237
+ if (addMoreTime) {
238
+ if (addMoreTimeBy === "day")
239
+ moreTime = addMoreTime * 60 * 60 * 24;
240
+ if (addMoreTimeBy === "hour")
241
+ moreTime = addMoreTime * 60 * 60;
242
+ if (addMoreTimeBy === "minute")
243
+ moreTime = addMoreTime * 60;
244
+ if (addMoreTimeBy === "second")
245
+ moreTime = addMoreTime;
246
+ }
247
+ return Math.floor(Date.now() / 1e3) + moreTime;
248
+ };
249
+ const fetchApi = async (params) => {
250
+ const { url, method, authorization = "", payload = {}, headers = {}, isSimpleRequest = true, isUploadFile = false, ignoreSWR = false } = params;
251
+ var myHeaders = new Headers();
252
+ if (!isSimpleRequest) {
253
+ if (authorization)
254
+ myHeaders.append("Authorization", `Bearer ${authorization}`);
255
+ if (Object.keys(headers).length)
256
+ Object.keys(headers).forEach(function(key) {
257
+ myHeaders.append(key, headers[key]);
258
+ });
259
+ }
260
+ var formdata = new FormData();
261
+ if (isSimpleRequest || isUploadFile) {
262
+ if (authorization && isSimpleRequest)
263
+ formdata.append(PAYLOAD_API_ALIASES.Authorization, authorization);
264
+ formdata.append(PAYLOAD_API_ALIASES.Method, PAYLOAD_API_ALIASES[method]);
265
+ if (Object.keys(payload).length)
266
+ Object.keys(payload).forEach(function(key) {
267
+ if (isUploadFile && (payload == null ? void 0 : payload.files))
268
+ [...payload.files].map((item) => {
269
+ formdata.append("files", item, item.name);
270
+ });
271
+ formdata.append(key, payload[key]);
272
+ });
273
+ }
274
+ const fixMethod = isSimpleRequest ? "POST" : method;
275
+ var requestOptions = {
276
+ method: fixMethod,
277
+ redirect: "follow",
278
+ headers: myHeaders,
279
+ body: fixMethod === "GET" ? null : isSimpleRequest || isUploadFile ? formdata : JSON.stringify(payload),
280
+ ignoreSWR
281
+ };
282
+ return await swr(`${url}`, requestOptions);
283
+ };
284
+ const convertDate = (date, options = {
285
+ timeZone: "Asia/Jakarta",
286
+ year: "numeric",
287
+ month: "numeric",
288
+ day: "numeric"
289
+ }) => new Date(date).toLocaleString("en-US", options);
290
+ const watchElement = ({ selector = null, init = null, customInit = false }) => {
291
+ if (!selector || !init)
292
+ return;
293
+ var observer = new MutationObserver(function(mutations) {
294
+ mutations.forEach(function(mutation) {
295
+ var nodes = Array.prototype.slice.call(mutation.addedNodes);
296
+ nodes.forEach(function(node) {
297
+ if (node.nodeType === 1 && (node.matches(selector) || node.querySelector(selector))) {
298
+ if (!customInit) {
299
+ let elementNode = Array.from(node.querySelectorAll(selector));
300
+ if (elementNode.length) {
301
+ elementNode.map((item) => {
302
+ init(item);
303
+ });
304
+ }
305
+ } else {
306
+ init();
307
+ }
308
+ }
309
+ });
310
+ });
311
+ });
312
+ observer.observe(document.body, {
313
+ childList: true,
314
+ subtree: true,
315
+ attributes: false,
316
+ characterData: false
317
+ });
318
+ };
319
+ const getFillRating = ({
320
+ average,
321
+ item,
322
+ index,
323
+ productId,
324
+ customComponentId,
325
+ unixTimestamp
326
+ }) => {
327
+ let ratingValue = Math.floor(parseFloat(average));
328
+ let getCommaValue = String(average).includes(",") ? String(average).split(",") : [];
329
+ let getCommaValueDot = String(average).includes(".") ? String(average).split(".") : [];
330
+ let isHaveCommaValue = getCommaValue.length || getCommaValueDot.length;
331
+ let commaValue = isHaveCommaValue ? getCommaValue[1] || getCommaValueDot[1] : 0;
332
+ let fillOther = "fill-0";
333
+ if (item > ratingValue && ratingValue + 1 === item) {
334
+ fillOther = `fill-${commaValue}`;
335
+ }
336
+ fillOther = item <= ratingValue ? "full" : fillOther;
337
+ let offset;
338
+ if (fillOther === "fill-0") {
339
+ offset = "0%";
340
+ }
341
+ if (fillOther === "fill-1") {
342
+ offset = "25%";
343
+ }
344
+ if (fillOther === "fill-2") {
345
+ offset = "35%";
346
+ }
347
+ if (fillOther === "fill-3") {
348
+ offset = "40%";
349
+ }
350
+ if (fillOther === "fill-4") {
351
+ offset = "45%";
352
+ }
353
+ if (fillOther === "fill-5") {
354
+ offset = "50%";
355
+ }
356
+ if (fillOther === "fill-6") {
357
+ offset = "60%";
358
+ }
359
+ if (fillOther === "fill-7") {
360
+ offset = "70%";
361
+ }
362
+ if (fillOther === "fill-8") {
363
+ offset = "80%";
364
+ }
365
+ if (fillOther === "fill-9") {
366
+ offset = "90%";
367
+ }
368
+ if (fillOther === "full") {
369
+ offset = "100%";
370
+ }
371
+ let suffixGradientId = `-${fillOther}-${index}-${productId ? productId : unixTimestamp}${customComponentId ? `-${customComponentId}` : ""}`;
372
+ let strokeGradientId = `rating-stroke${suffixGradientId}`;
373
+ let fillGradientId = `rating-gradient${suffixGradientId}`;
374
+ return {
375
+ suffixGradientId,
376
+ strokeGradientId,
377
+ fillGradientId,
378
+ offset,
379
+ fillOther
380
+ };
381
+ };
382
+ const stripTags = (html) => {
383
+ return html.replace(/(<([^>]+)>)/gi, "");
384
+ };
168
385
  const root = "";
169
386
  const Loading = "";
170
387
  const ConfirmationPopup = "";
@@ -700,150 +917,6 @@ const SelectField = (props) => {
700
917
  ) });
701
918
  };
702
919
  const ProductGrid$1 = "";
703
- async function swr(url, options) {
704
- if (typeof localStorage !== "undefined" && typeof caches !== "undefined" && options.method === "GET" && !(options == null ? void 0 : options.ignoreSWR)) {
705
- const data = await getData(url);
706
- return await data.json();
707
- } else
708
- return fetch(url, options).then((response) => response.json());
709
- }
710
- async function getData(url) {
711
- const cacheVersion = 1;
712
- const cacheName = `sledge-${cacheVersion}`;
713
- return caches.open(cacheName).then((cache) => {
714
- return cache.match(url).then((cachedResponse) => {
715
- const fetchedResponse = fetch(url).then(async (networkResponse) => {
716
- const mainUrl = url.split("?")[0];
717
- const cacheMatches = await cache.matchAll();
718
- const filteredCaches = await cacheMatches.filter((f) => f.url.includes(mainUrl) && f.url !== url);
719
- for (const c of filteredCaches) {
720
- await cache.delete(c.url);
721
- }
722
- cache.put(url, networkResponse.clone());
723
- return networkResponse;
724
- });
725
- return cachedResponse || fetchedResponse;
726
- });
727
- });
728
- }
729
- const usePrevious = (value) => {
730
- const ref = React__default.useRef();
731
- React__default.useEffect(() => {
732
- ref.current = value;
733
- });
734
- return ref.current;
735
- };
736
- const sanitizeDataId = (id) => {
737
- if (!id)
738
- return "";
739
- let getId = String(id);
740
- if (getId.includes("shopify") && getId.includes("/")) {
741
- let arrId = getId.split("/");
742
- return arrId[arrId.length - 1] || getId;
743
- } else {
744
- return getId;
745
- }
746
- };
747
- const isFunction = (data) => typeof data === "function";
748
- const scrollToElement = (params) => {
749
- const { element, headerOffset } = params;
750
- if (!element)
751
- return;
752
- var elementPosition = element == null ? void 0 : element.getBoundingClientRect().top;
753
- var offsetPosition = elementPosition + window.scrollY - headerOffset;
754
- window.scrollTo({
755
- top: offsetPosition,
756
- behavior: "smooth"
757
- });
758
- };
759
- const getUnixTimestamp = (params) => {
760
- const { addMoreTime = 0, addMoreTimeBy = "day" } = params || {};
761
- let moreTime = 0;
762
- if (addMoreTime) {
763
- if (addMoreTimeBy === "day")
764
- moreTime = addMoreTime * 60 * 60 * 24;
765
- if (addMoreTimeBy === "hour")
766
- moreTime = addMoreTime * 60 * 60;
767
- if (addMoreTimeBy === "minute")
768
- moreTime = addMoreTime * 60;
769
- if (addMoreTimeBy === "second")
770
- moreTime = addMoreTime;
771
- }
772
- return Math.floor(Date.now() / 1e3) + moreTime;
773
- };
774
- const fetchApi = async (params) => {
775
- const { url, method, authorization = "", payload = {}, headers = {}, isSimpleRequest = true, isUploadFile = false, ignoreSWR = false } = params;
776
- var myHeaders = new Headers();
777
- if (!isSimpleRequest) {
778
- if (authorization)
779
- myHeaders.append("Authorization", `Bearer ${authorization}`);
780
- if (Object.keys(headers).length)
781
- Object.keys(headers).forEach(function(key) {
782
- myHeaders.append(key, headers[key]);
783
- });
784
- }
785
- var formdata = new FormData();
786
- if (isSimpleRequest || isUploadFile) {
787
- if (authorization && isSimpleRequest)
788
- formdata.append(PAYLOAD_API_ALIASES.Authorization, authorization);
789
- formdata.append(PAYLOAD_API_ALIASES.Method, PAYLOAD_API_ALIASES[method]);
790
- if (Object.keys(payload).length)
791
- Object.keys(payload).forEach(function(key) {
792
- if (isUploadFile && (payload == null ? void 0 : payload.files))
793
- [...payload.files].map((item) => {
794
- formdata.append("files", item, item.name);
795
- });
796
- formdata.append(key, payload[key]);
797
- });
798
- }
799
- const fixMethod = isSimpleRequest ? "POST" : method;
800
- var requestOptions = {
801
- method: fixMethod,
802
- redirect: "follow",
803
- headers: myHeaders,
804
- body: fixMethod === "GET" ? null : isSimpleRequest || isUploadFile ? formdata : JSON.stringify(payload),
805
- ignoreSWR
806
- };
807
- return await swr(`${url}`, requestOptions);
808
- };
809
- const convertDate = (date, options = {
810
- timeZone: "Asia/Jakarta",
811
- year: "numeric",
812
- month: "numeric",
813
- day: "numeric"
814
- }) => new Date(date).toLocaleString("en-US", options);
815
- const watchElement = ({ selector = null, init = null, customInit = false }) => {
816
- if (!selector || !init)
817
- return;
818
- var observer = new MutationObserver(function(mutations) {
819
- mutations.forEach(function(mutation) {
820
- var nodes = Array.prototype.slice.call(mutation.addedNodes);
821
- nodes.forEach(function(node) {
822
- if (node.nodeType === 1 && (node.matches(selector) || node.querySelector(selector))) {
823
- if (!customInit) {
824
- let elementNode = Array.from(node.querySelectorAll(selector));
825
- if (elementNode.length) {
826
- elementNode.map((item) => {
827
- init(item);
828
- });
829
- }
830
- } else {
831
- init();
832
- }
833
- }
834
- });
835
- });
836
- });
837
- observer.observe(document.body, {
838
- childList: true,
839
- subtree: true,
840
- attributes: false,
841
- characterData: false
842
- });
843
- };
844
- const stripTags = (html) => {
845
- return html.replace(/(<([^>]+)>)/gi, "");
846
- };
847
920
  const addToCart = async (data) => {
848
921
  var _a, _b;
849
922
  let items = [];
@@ -991,7 +1064,7 @@ const addToCartTrigger$1 = async (data) => {
991
1064
  });
992
1065
  };
993
1066
  const Badge = (props) => {
994
- var _a;
1067
+ var _a, _b;
995
1068
  const { useProxyUrl = false, data: propsData, position: positionProp } = props;
996
1069
  const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
997
1070
  const { wishlist: isRenderAppWishlist } = isRenderApp || {};
@@ -1006,17 +1079,18 @@ const Badge = (props) => {
1006
1079
  const [dataSettings, setDataSettings] = React__default.useState({});
1007
1080
  const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
1008
1081
  const { floating_button_type } = (dataSettings == null ? void 0 : dataSettings.launch_point) || {};
1082
+ const { alert_login, alert, login_button } = ((_b = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _b.widget) || {};
1009
1083
  const defaultPosition = positionProp || floating_button_type;
1010
1084
  const position = defaultPosition ? defaultPosition : "none";
1011
1085
  const handleGetWishlistInfo = async () => {
1012
- var _a2, _b;
1086
+ var _a2, _b2;
1013
1087
  let response;
1014
1088
  let run = false;
1015
1089
  let valueTotalWishlist;
1016
1090
  let valueProxyUrl;
1017
1091
  response = await getWishlistInfo();
1018
1092
  run = ((_a2 = response == null ? void 0 : response.status) == null ? void 0 : _a2.code) === 200 || false;
1019
- valueTotalWishlist = !((_b = response == null ? void 0 : response.data) == null ? void 0 : _b.total_data) ? 0 : response.data.total_data;
1093
+ valueTotalWishlist = !((_b2 = response == null ? void 0 : response.data) == null ? void 0 : _b2.total_data) ? 0 : response.data.total_data;
1020
1094
  valueProxyUrl = DEFAULT_WISHLIST_URL;
1021
1095
  if (run) {
1022
1096
  setTotalWishlist(valueTotalWishlist);
@@ -1043,10 +1117,9 @@ const Badge = (props) => {
1043
1117
  if (isRequiredLogin) {
1044
1118
  if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
1045
1119
  window.sledgeConfirmationPopup({
1046
- title: "Login required!",
1047
- message: "Please login to save your wishlist across devices.",
1048
- textSubmit: "Login",
1049
- textCancel: "Cancel",
1120
+ title: alert_login || "Login required!",
1121
+ message: alert || "Please login to save your wishlist across devices.",
1122
+ textSubmit: login_button || "Login",
1050
1123
  buttonSubmitType: "info",
1051
1124
  onSubmit: () => window.location.href = "/account/login"
1052
1125
  });
@@ -1192,7 +1265,7 @@ const BadgeInitSelector = () => {
1192
1265
  }
1193
1266
  };
1194
1267
  const Trigger = (props) => {
1195
- var _a, _b, _c, _d;
1268
+ var _a, _b, _c, _d, _e;
1196
1269
  const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked } = props;
1197
1270
  const { productId, productVariantId } = params || {};
1198
1271
  const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
@@ -1218,6 +1291,7 @@ const Trigger = (props) => {
1218
1291
  const { is_required_login } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.global) || {};
1219
1292
  const { show: show_notification, location: location_notification } = ((_c = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _c.notification) || {};
1220
1293
  const { title_added_to_wishlist, text_added_to_wishlist, title_removed_to_wishlist, text_removed_to_wishlist, title_fail_add_to_wishlist, text_fail_add_to_wishlist } = ((_d = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _d.notification) || {};
1294
+ const { alert_login, alert, login_button } = ((_e = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _e.widget) || {};
1221
1295
  const handleCheckWishlist = async () => {
1222
1296
  let response;
1223
1297
  if (typeof wishlistChecked === "boolean" && isFirstTime) {
@@ -1234,10 +1308,9 @@ const Trigger = (props) => {
1234
1308
  if (isRequiredLogin) {
1235
1309
  if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
1236
1310
  window.sledgeConfirmationPopup({
1237
- title: "Login required!",
1238
- message: "Please login to save your wishlist across devices.",
1239
- textSubmit: "Login",
1240
- textCancel: "Cancel",
1311
+ title: alert_login || "Login required!",
1312
+ message: alert || "Please login to save your wishlist across devices.",
1313
+ textSubmit: login_button || "Login",
1241
1314
  buttonSubmitType: "info",
1242
1315
  onSubmit: () => window.location.href = "/account/login"
1243
1316
  });
@@ -1387,7 +1460,6 @@ const WidgetHeaderClearTrigger = ({ buttonText, shareId, dataSettings, isFirstLo
1387
1460
  title: title_confirm_clear_all_wishlist,
1388
1461
  message: text_confirm_clear_all_wishlist,
1389
1462
  textSubmit: button_submit_confirm_clear_all_wishlist,
1390
- textCancel: button_cancel_confirm_clear_all_wishlist,
1391
1463
  buttonSubmitType: "danger",
1392
1464
  onSubmit: window.sledgeWishlistWidgetClearList || {}
1393
1465
  });
@@ -1412,8 +1484,8 @@ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger,
1412
1484
  font_weight: display_button_share_font_weight,
1413
1485
  text_transform: display_button_share_text_transform
1414
1486
  } = ((_d = (_c = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _c.widget) == null ? void 0 : _d.button_share) || {};
1415
- const { title_share_wishlist } = ((_e = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _e.popup) || {};
1416
- const { button_share } = ((_f = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _f.widget) || {};
1487
+ const { title_share_wishlist, title_confirm_add_to_your_wishlist, text_confirm_add_to_your_wishlist, button_confirm_add_to_your_wishlist } = ((_e = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _e.popup) || {};
1488
+ const { button_share, button_add_to_your_wishlist } = ((_f = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _f.widget) || {};
1417
1489
  const { show: show_notification, location: location_notification } = ((_g = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _g.notification) || {};
1418
1490
  const { title_added_all_to_wishlist, text_added_all_to_wishlist, title_fail_add_to_wishlist, text_fail_add_to_wishlist } = ((_h = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _h.notification) || {};
1419
1491
  const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
@@ -1507,12 +1579,14 @@ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger,
1507
1579
  }
1508
1580
  };
1509
1581
  const handleClick = async () => {
1582
+ let getMessage = text_confirm_add_to_your_wishlist;
1583
+ if (getMessage)
1584
+ getMessage = getMessage.replaceAll(OBJECT_DATA_STRING_KEY.TOTAL_WISHLIST, wishlistData.length);
1510
1585
  if (shareId && wishlistData.length) {
1511
1586
  window.sledgeConfirmationPopup({
1512
- title: "Are you sure want to add this to your wishlist item?",
1513
- message: `This action cannot be undone. This will adding <strong>${wishlistData.length}</strong> item to your wishlist page.`,
1514
- textSubmit: "Add to your wishlist",
1515
- textCancel: "Cancel",
1587
+ title: title_confirm_add_to_your_wishlist || "Are you sure want to add this to your wishlist item?",
1588
+ message: getMessage || `This action cannot be undone. This will adding <strong>${wishlistData.length}</strong> item to your wishlist page.`,
1589
+ textSubmit: button_confirm_add_to_your_wishlist || "Add to your wishlist",
1516
1590
  buttonSubmitType: "info",
1517
1591
  onSubmit: handleBulkAddWishlist || {}
1518
1592
  });
@@ -1550,7 +1624,7 @@ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger,
1550
1624
  children: shareId ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1551
1625
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-wishlist__badge-counter sledge-wishlist__badge-counter-top-right", children: wishlistData.length }),
1552
1626
  isLoadingBulkAdd ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingDots, {}) : null,
1553
- "Add to your wishlist"
1627
+ button_add_to_your_wishlist || "Add to your wishlist"
1554
1628
  ] }) : buttonText ? buttonText : button_share || "Share Wishlist"
1555
1629
  }
1556
1630
  ) }) }) }) });
@@ -1898,53 +1972,14 @@ const Rating = (props) => {
1898
1972
  [1, 2, 3, 4, 5].map((item, index) => {
1899
1973
  if (!(item <= numberOfIcons))
1900
1974
  return;
1901
- let ratingValue = Math.floor(parseFloat(averageReview));
1902
- let getCommaValue = String(averageReview).includes(",") ? String(averageReview).split(",") : [];
1903
- let getCommaValueDot = String(averageReview).includes(".") ? String(averageReview).split(".") : [];
1904
- let isHaveCommaValue = getCommaValue.length || getCommaValueDot.length;
1905
- let commaValue = isHaveCommaValue ? getCommaValue[1] || getCommaValueDot[1] : 0;
1906
- let fillOther = "fill-0";
1907
- if (item > ratingValue && ratingValue + 1 === item) {
1908
- fillOther = `fill-${commaValue}`;
1909
- }
1910
- fillOther = item <= ratingValue ? "full" : fillOther;
1911
- let offset;
1912
- if (fillOther === "fill-0") {
1913
- offset = "0%";
1914
- }
1915
- if (fillOther === "fill-1") {
1916
- offset = "25%";
1917
- }
1918
- if (fillOther === "fill-2") {
1919
- offset = "35%";
1920
- }
1921
- if (fillOther === "fill-3") {
1922
- offset = "40%";
1923
- }
1924
- if (fillOther === "fill-4") {
1925
- offset = "45%";
1926
- }
1927
- if (fillOther === "fill-5") {
1928
- offset = "50%";
1929
- }
1930
- if (fillOther === "fill-6") {
1931
- offset = "60%";
1932
- }
1933
- if (fillOther === "fill-7") {
1934
- offset = "70%";
1935
- }
1936
- if (fillOther === "fill-8") {
1937
- offset = "80%";
1938
- }
1939
- if (fillOther === "fill-9") {
1940
- offset = "90%";
1941
- }
1942
- if (fillOther === "full") {
1943
- offset = "100%";
1944
- }
1945
- let suffixGradientId = `-${fillOther}-${index}-${productId ? productId : unixTimestamp}${customComponentId ? `-${customComponentId}` : ""}`;
1946
- let strokeGradientId = `rating-stroke${suffixGradientId}`;
1947
- let fillGradientId = `rating-gradient${suffixGradientId}`;
1975
+ const { strokeGradientId, suffixGradientId, offset, fillGradientId, fillOther } = getFillRating({
1976
+ average: averageReview,
1977
+ item,
1978
+ index,
1979
+ productId,
1980
+ unixTimestamp,
1981
+ customComponentId
1982
+ });
1948
1983
  return /* @__PURE__ */ createElement("svg", { xmlns: "http://www.w3.org/2000/svg", ...sizing, viewBox: "0 0 32 32", key: suffixGradientId }, /* @__PURE__ */ jsxRuntimeExports.jsxs("defs", { children: [
1949
1984
  /* @__PURE__ */ jsxRuntimeExports.jsxs("linearGradient", { id: strokeGradientId, children: [
1950
1985
  /* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset, stopColor: fillColor || fill_color }),
@@ -2717,10 +2752,13 @@ const ProductGrid = (props) => {
2717
2752
  }
2718
2753
  };
2719
2754
  const Container = useSlider ? Carousel : "div";
2755
+ const carouselSourceProp = useSlider && {
2756
+ carouselSourceWidget: "productGrid"
2757
+ } || null;
2720
2758
  React__default.useEffect(() => {
2721
2759
  onAfterRenderProduct && onAfterRenderProduct("success");
2722
2760
  }, []);
2723
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: `sledge__product-grid ${className}`, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
2761
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { className: `sledge__product-grid ${className}`, ...carouselSourceProp, "data-grid-type": type, children: data == null ? void 0 : data.map((item, index) => {
2724
2762
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ProductCard, { item, handleAddToCart, clickedAddToCartId, ...props }, `sledge-product-card_${index}`);
2725
2763
  }) });
2726
2764
  };
@@ -3087,11 +3125,10 @@ const LoadingDots = () => {
3087
3125
  };
3088
3126
  const Carousel$1 = "";
3089
3127
  const Carousel = (props) => {
3090
- const { children, className = "", "data-grid-type": dataGridType } = props;
3128
+ const { children, className = "", "data-grid-type": dataGridType, carouselSourceWidget } = props;
3091
3129
  const [active, setActive] = React__default.useState(true);
3092
3130
  const {
3093
3131
  options = {
3094
- active,
3095
3132
  slidesToScroll: "auto",
3096
3133
  align: "start",
3097
3134
  dragFree: true,
@@ -3101,12 +3138,28 @@ const Carousel = (props) => {
3101
3138
  const [carouselRef, carouselApi] = useEmblaCarousel(options);
3102
3139
  const [prevBtnDisabled, setPrevBtnDisabled] = React__default.useState(true);
3103
3140
  const [nextBtnDisabled, setNextBtnDisabled] = React__default.useState(true);
3141
+ const [selectedIndex, setSelectedIndex] = React__default.useState(0);
3142
+ const [scrollSnaps, setScrollSnaps] = React__default.useState([]);
3104
3143
  const scrollPrev = React__default.useCallback(() => carouselApi && carouselApi.scrollPrev(), [carouselApi]);
3105
3144
  const scrollNext = React__default.useCallback(() => carouselApi && carouselApi.scrollNext(), [carouselApi]);
3145
+ const scrollTo = React__default.useCallback((index) => carouselApi && carouselApi.scrollTo(index), [carouselApi]);
3106
3146
  const onSelect = React__default.useCallback((carouselApi2) => {
3147
+ setSelectedIndex(carouselApi2.selectedScrollSnap());
3107
3148
  setPrevBtnDisabled(!carouselApi2.canScrollPrev());
3108
3149
  setNextBtnDisabled(!carouselApi2.canScrollNext());
3109
3150
  }, []);
3151
+ const onInit = React__default.useCallback((carouselApi2) => {
3152
+ setScrollSnaps(carouselApi2.scrollSnapList());
3153
+ }, []);
3154
+ React__default.useEffect(() => {
3155
+ if (!carouselApi)
3156
+ return;
3157
+ onInit(carouselApi);
3158
+ onSelect(carouselApi);
3159
+ carouselApi.on("reInit", onInit);
3160
+ carouselApi.on("reInit", onSelect);
3161
+ carouselApi.on("select", onSelect);
3162
+ }, [carouselApi, onSelect]);
3110
3163
  React__default.useEffect(() => {
3111
3164
  if (!carouselApi)
3112
3165
  return;
@@ -3118,10 +3171,30 @@ const Carousel = (props) => {
3118
3171
  React__default.useEffect(() => {
3119
3172
  if (!carouselApi)
3120
3173
  return;
3121
- onSelect(carouselApi);
3122
- carouselApi.on("reInit", onSelect);
3123
- carouselApi.on("select", onSelect);
3124
- }, [carouselApi, onSelect]);
3174
+ carouselApi.reInit(options);
3175
+ }, [carouselApi, React__default.Children.count(children)]);
3176
+ React__default.useEffect(() => {
3177
+ if (!carouselApi)
3178
+ return;
3179
+ if (!active)
3180
+ carouselApi == null ? void 0 : carouselApi.internalEngine().dragHandler.destroy();
3181
+ else
3182
+ carouselApi == null ? void 0 : carouselApi.internalEngine().dragHandler.init(carouselApi);
3183
+ }, [active]);
3184
+ let carouselAttributes = {};
3185
+ switch (carouselSourceWidget) {
3186
+ case "productGrid":
3187
+ carouselAttributes = {
3188
+ className: "sledge__carousel-container sledge__product-grid",
3189
+ "data-grid-type": dataGridType
3190
+ };
3191
+ break;
3192
+ default:
3193
+ carouselAttributes = {
3194
+ className: "sledge__carousel-container"
3195
+ };
3196
+ break;
3197
+ }
3125
3198
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `sledge__carousel ${className}`, children: [
3126
3199
  /* @__PURE__ */ jsxRuntimeExports.jsx(
3127
3200
  Navigation,
@@ -3136,7 +3209,7 @@ const Carousel = (props) => {
3136
3209
  className: "sledge__carousel-button-prev"
3137
3210
  }
3138
3211
  ),
3139
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__carousel-viewport", ref: carouselRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__carousel-container sledge__product-grid", "data-grid-type": dataGridType, children }) }),
3212
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge__carousel-viewport ${active && "is-active" || ""}`, ref: carouselRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ...carouselAttributes, children }) }),
3140
3213
  /* @__PURE__ */ jsxRuntimeExports.jsx(
3141
3214
  Navigation,
3142
3215
  {
@@ -3149,7 +3222,8 @@ const Carousel = (props) => {
3149
3222
  onClick: scrollNext,
3150
3223
  className: "sledge__carousel-button-next"
3151
3224
  }
3152
- )
3225
+ ),
3226
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__carousel-dots", children: scrollSnaps.map((_, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(DotButton, { onClick: () => scrollTo(index), className: "sledge__carousel-dot".concat(index === selectedIndex ? " sledge__carousel-dot--selected" : "") }, index)) })
3153
3227
  ] });
3154
3228
  };
3155
3229
  const Navigation = (props) => {
@@ -3174,6 +3248,10 @@ const Navigation = (props) => {
3174
3248
  const Icon = () => position === "left" ? LeftIcon : RightIcon;
3175
3249
  return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: `sledge__carousel-button ${className}`, type: "button", ...restProps, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, {}) });
3176
3250
  };
3251
+ const DotButton = (props) => {
3252
+ const { children, ...restProps } = props;
3253
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", ...restProps, children });
3254
+ };
3177
3255
  const SearchIconWidget = (props) => {
3178
3256
  const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
3179
3257
  const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
@@ -4330,7 +4408,7 @@ const ResultProduct = (props) => {
4330
4408
  if (isSummaryTextFromLanguage) {
4331
4409
  getSummaryText = getSummaryText.replaceAll(OBJECT_DATA_STRING_KEY.TOTAL_RESULT, totalResult);
4332
4410
  if (layoutType === "product-filter")
4333
- getSummaryText = getSummaryText.replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_NAME, collectionName || "");
4411
+ getSummaryText = getSummaryText.replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_NAME, collectionName || "Products");
4334
4412
  }
4335
4413
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-item", children: ((_a2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a2.show_total_products) ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-data-summary-text", children: isSummaryTextFromLanguage ? getSummaryText : defaultSummaryText }) : null });
4336
4414
  };