@sledge-app/react-instant-search 1.0.69 → 1.0.70

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.
@@ -9,6 +9,80 @@ const API_URL = "https://api.sledge-app.com";
9
9
  const INSTANT_SEARCH_ENGINE_URL = "https://instant-search-engine.sledge-app.com";
10
10
  const CDN_URL = "https://sledgeassets.nyc3.cdn.digitaloceanspaces.com";
11
11
  const SELECTOR_ATTRIBUTE_KEY = "data-component";
12
+ const DATASET_ATTRIBUTE_KEY = {
13
+ GLOBAL: {
14
+ ON_AFTER_ADD_WISHLIST: "data-on-after-add-wishlist",
15
+ ON_AFTER_REMOVE_WISHLIST: "data-on-after-remove-wishlist",
16
+ ON_AFTER_ADD_TO_CART: "data-on-after-add-to-cart",
17
+ ON_AFTER_ADD_REVIEW: "data-on-after-add-review",
18
+ ON_AFTER_RENDER_PRODUCT: "data-on-after-render-product",
19
+ PRODUCT_ID: "data-product-id",
20
+ PRODUCT_VARIANT_ID: "data-product-variant-id",
21
+ PRODUCT_NAME: "data-product-name",
22
+ PRODUCT_VENDOR: "data-product-vendor",
23
+ PRODUCT_SKU: "data-product-sku",
24
+ PRODUCT_VARIANT_NAME: "data-product-variant-name",
25
+ PRODUCT_LINK: "data-product-link",
26
+ PRODUCT_IMAGE: "data-product-image",
27
+ PRODUCT_CURRENCY: "data-product-currency",
28
+ PRODUCT_PRICE: "data-product-price",
29
+ USER_ID: "data-user-id",
30
+ USER_EMAIL: "data-user-email",
31
+ USER_FULLNAME: "data-user-fullname",
32
+ COLLECTION_ID: "data-collection-id",
33
+ COLLECTION_NAME: "data-collection-name",
34
+ WIDTH_ELEMENT: "data-width-element",
35
+ ICON_SIZE: "data-icon-size",
36
+ API_KEY: "data-api-key",
37
+ INSTANT_SEARCH_API_KEY: "data-instant-search-api-key",
38
+ RENDER_PRODUCT_CARD: "data-render-product-card",
39
+ WITH_SKELETON_LOADING: "data-with-skeleton-loading",
40
+ SECTION_TITLE: "data-section-title",
41
+ SECTION_DESCRIPTION: "data-section-description",
42
+ USE_SLIDER: "data-use-slider",
43
+ FILL_COLOR: "data-fill-color",
44
+ OUTLINE_COLOR: "data-outline-color",
45
+ POSITION_WIDGET: "data-position-widget"
46
+ },
47
+ WISHLIST: {
48
+ SHARE_ID: "data-share-id",
49
+ QUERY_SHARE_ID: "data-query-share-id",
50
+ RENDER_WISHLIST_WIDGET_ALERT: "data-render-wishlist-widget-alert",
51
+ USE_PROXY_URL: "data-use-proxy-url",
52
+ LIMIT_OPTIONS: "data-limit-options",
53
+ TRIGGER_BADGE: "data-trigger-badge"
54
+ },
55
+ PRODUCT_REVIEW: {
56
+ RATING_SIZE: "data-rating-size",
57
+ RATING_TOTAL: "data-rating-total",
58
+ RATING_AVERAGE: "data-rating-average",
59
+ RENDER_REVIEW_PRODUCT_INFO: "data-render-review-product-info",
60
+ TRUST_BADGE_VARIANT: "data-trust-badge-variant",
61
+ SHOW_RATING_AVERAGE: "data-show-rating-average"
62
+ },
63
+ INSTANT_SEARCH: {
64
+ ON_AFTER_RENDER_COLLECTION: "data-on-after-render-collection",
65
+ ON_AFTER_RENDER_PAGE: "data-on-after-render-page",
66
+ ON_AFTER_RENDER_BLOG: "data-on-after-render-blog",
67
+ ON_AFTER_RENDER_ARTICLE: "data-on-after-render-article",
68
+ QUERY_KEYWORD: "data-query-keyword",
69
+ QUERY_SORT_BY: "data-query-sort-by",
70
+ QUERY_PAGE: "data-query-page",
71
+ QUERY_LIMIT: "data-query-limit",
72
+ URL_SEARCH_RESULT: "data-url-search-result",
73
+ RENDER_SUGGESTION_KEYWORD_LIST: "data-render-suggestion-keyword-list",
74
+ RENDER_OTHER_INDEX_LIST: "data-render-other-index-list",
75
+ RENDER_SEARCH_VIEW_MORE_RESULT: "data-render-search-view-more-result",
76
+ RENDER_COLLECTION_CARD: "data-render-collection-card",
77
+ RENDER_PAGE_CARD: "data-render-page-card",
78
+ RENDER_BLOG_CARD: "data-render-blog-card",
79
+ RENDER_ARTICLE_CARD: "data-render-article-card"
80
+ },
81
+ PRODUCT_RECOMMENDATION: {
82
+ DISPLAY_LIMIT: "data-display-limit",
83
+ HIDDEN_PRODUCT_IDS: "data-hidden-product-ids"
84
+ }
85
+ };
12
86
  const LOCAL_STORAGE_KEY = {
13
87
  ANONYM_ID: "sledge-anonym-id",
14
88
  AUTH_APP: "sledge-auth-app",
@@ -651,13 +725,13 @@ const Pagination = (props) => {
651
725
  };
652
726
  const RadioGroup$1 = "";
653
727
  const rowRenderer = ({ virtualized, item, id, labelStyle, useVirtualized }) => {
654
- const { index, key = "", style = {}, isScrolling = false, isVisible = false } = virtualized || {};
728
+ const { index, key = "", style = {} } = virtualized || {};
655
729
  const { label, value } = item;
656
730
  const content = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
657
731
  /* @__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" }) }),
658
732
  /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "sledge__radio-group-label", htmlFor: `${id}${index}`, style: labelStyle, children: label })
659
733
  ] });
660
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-item-flex", style, children: !useVirtualized ? content : !isVisible && isScrolling ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingDots, {}) : content }, key || index);
734
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-item-flex", style, children: content }, key || index);
661
735
  };
662
736
  const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {}, onValueChange, scrollElement, useVirtualized = false }) => {
663
737
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("form", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -678,13 +752,11 @@ const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {},
678
752
  },
679
753
  rowCount: items == null ? void 0 : items.length,
680
754
  rowHeight: 36,
681
- rowRenderer: ({ index, key, style, isScrolling, isVisible }) => rowRenderer({
755
+ rowRenderer: ({ index, key, style }) => rowRenderer({
682
756
  virtualized: {
683
757
  index,
684
758
  key,
685
- style,
686
- isScrolling,
687
- isVisible
759
+ style
688
760
  },
689
761
  item: items[index],
690
762
  id,
@@ -1211,6 +1283,154 @@ const BadgeCounter = (props) => {
1211
1283
  const defaultTotalWishlist = isJsVersion ? (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || null : null;
1212
1284
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading ? defaultTotalWishlist : isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 });
1213
1285
  };
1286
+ const Badge = (props) => {
1287
+ var _a, _b;
1288
+ const { useProxyUrl = false, data: propsData, position: positionProp } = props;
1289
+ const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion } = React__default.useContext(SledgeContext);
1290
+ const { wishlist: isRenderAppWishlist } = isRenderApp || {};
1291
+ const { value: valueRenderWishlistBadge, trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
1292
+ const defaultColorIcon = "currentColor";
1293
+ const [colorIcon, setColorIcon] = React__default.useState(defaultColorIcon);
1294
+ const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
1295
+ const [isMaximizeTotalWishlist, setIsMaximizeTotalWishlist] = React__default.useState(false);
1296
+ const [proxyUrl, setProxyUrl] = React__default.useState((propsData == null ? void 0 : propsData.proxy_url) || "");
1297
+ const [dataSettings, setDataSettings] = React__default.useState({});
1298
+ const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
1299
+ const [data, setData] = React__default.useState({});
1300
+ const { floating_button_type } = (dataSettings == null ? void 0 : dataSettings.launch_point) || {};
1301
+ const { alert_login, alert, login_button } = ((_b = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _b.widget) || {};
1302
+ const defaultPosition = positionProp || floating_button_type;
1303
+ const position = defaultPosition ? defaultPosition : "none";
1304
+ const handleGetWishlistInfo = async () => {
1305
+ await wishlistInfo({
1306
+ callback: ({ totalWishlist: valueTotalWishlist, proxyUrl: valueProxyUrl, data: valueData }) => {
1307
+ setIsMaximizeTotalWishlist(valueTotalWishlist > 99);
1308
+ setProxyUrl(valueProxyUrl);
1309
+ setIsFirstLoading(false);
1310
+ setData(valueData);
1311
+ localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, valueTotalWishlist);
1312
+ }
1313
+ });
1314
+ };
1315
+ const handleSettings = async (LOCAL_STORAGE_WISHLIST_SETTING) => {
1316
+ let response;
1317
+ response = JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
1318
+ if (!response)
1319
+ return;
1320
+ const { is_required_login } = response || {};
1321
+ setDataSettings(response);
1322
+ setIsRequiredLogin(sledgeAnonymId && is_required_login);
1323
+ };
1324
+ const handleRequiredLogin = (e) => {
1325
+ if (isRequiredLogin) {
1326
+ e.preventDefault();
1327
+ e.stopPropagation();
1328
+ }
1329
+ if (isRequiredLogin) {
1330
+ if (typeof window !== "undefined" && window.sledgeConfirmationPopup)
1331
+ window.sledgeConfirmationPopup({
1332
+ title: alert_login || "Login required!",
1333
+ message: alert || "Please login to save your wishlist across devices.",
1334
+ textSubmit: login_button || "Login",
1335
+ buttonSubmitType: "info",
1336
+ onSubmit: () => window.location.href = "/account/login"
1337
+ });
1338
+ } else {
1339
+ if (useProxyUrl)
1340
+ window.location.href = proxyUrl || "/";
1341
+ }
1342
+ };
1343
+ React__default.useEffect(() => {
1344
+ if (!isRenderAppWishlist)
1345
+ return;
1346
+ handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
1347
+ }, [isRenderAppWishlist]);
1348
+ React__default.useEffect(() => {
1349
+ if (!(dataSettings == null ? void 0 : dataSettings.launch_point))
1350
+ return;
1351
+ handleGetWishlistInfo();
1352
+ }, [dataSettings]);
1353
+ React__default.useEffect(() => {
1354
+ if (!valueRenderWishlistBadge)
1355
+ return;
1356
+ if (triggerRenderWishlistBadge)
1357
+ triggerRenderWishlistBadge(false);
1358
+ handleGetWishlistInfo();
1359
+ }, [valueRenderWishlistBadge]);
1360
+ const HeaderMenu = () => {
1361
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge", onClick: handleRequiredLogin, onMouseEnter: () => setColorIcon("#F85538"), onMouseLeave: () => setColorIcon(defaultColorIcon), children: [
1362
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 20, height: 20, type: "outline", color: colorIcon }),
1363
+ !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx(
1364
+ "span",
1365
+ {
1366
+ className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`,
1367
+ "data-component": "wishlist-badge-counter",
1368
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component": "container-widget", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1369
+ BadgeCounter,
1370
+ {
1371
+ data: isJsVersion ? {
1372
+ ...data,
1373
+ ...{
1374
+ total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
1375
+ }
1376
+ } : data
1377
+ }
1378
+ ) })
1379
+ }
1380
+ )
1381
+ ] });
1382
+ };
1383
+ const FloatingFull = () => {
1384
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge-wishlist__badge-floating sledge__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: [
1385
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-wishlist__badge-floating-text", children: "My Wishlist" }),
1386
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
1387
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 18, height: 18, type: "fill", color: "#000000" }),
1388
+ !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx(
1389
+ "span",
1390
+ {
1391
+ className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`,
1392
+ "data-component": "wishlist-badge-counter",
1393
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component": "container-widget", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1394
+ BadgeCounter,
1395
+ {
1396
+ data: isJsVersion ? {
1397
+ ...data,
1398
+ ...{
1399
+ total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
1400
+ }
1401
+ } : data
1402
+ }
1403
+ ) })
1404
+ }
1405
+ )
1406
+ ] })
1407
+ ] }) });
1408
+ };
1409
+ const FloatingIcon = () => {
1410
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sledge-wishlist__badge-floating-icon sledge-wishlist__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
1411
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 27.01, height: 25.73, type: "outline", color: "#000000" }),
1412
+ !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx(
1413
+ "span",
1414
+ {
1415
+ className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`,
1416
+ "data-component": "wishlist-badge-counter",
1417
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component": "container-widget", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1418
+ BadgeCounter,
1419
+ {
1420
+ data: isJsVersion ? {
1421
+ ...data,
1422
+ ...{
1423
+ total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
1424
+ }
1425
+ } : data
1426
+ }
1427
+ ) })
1428
+ }
1429
+ )
1430
+ ] }) }) });
1431
+ };
1432
+ return isFirstLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: position === "none" ? /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderMenu, {}) : String(position).includes("bottom") ? /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingIcon, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingFull, {}) });
1433
+ };
1214
1434
  const BadgeCounterInitSelector = () => {
1215
1435
  let element = Array.from(document.querySelectorAll(SELECTOR.WISHLIST.ELEMENT_BADGE_COUNTER));
1216
1436
  let isElementDetected = !element || element && !element.length;
@@ -1243,11 +1463,107 @@ const BadgeCounterInitSelector = () => {
1243
1463
  }
1244
1464
  });
1245
1465
  };
1466
+ const BadgeInitSelector = () => {
1467
+ const sledgeWishlistSettings = localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null) : null;
1468
+ let element = Array.from(document.querySelectorAll(SELECTOR.WISHLIST.ELEMENT_BADGE));
1469
+ let isElementDetected = !element || element && !element.length;
1470
+ if (!sledgeWishlistSettings || isElementDetected)
1471
+ return;
1472
+ const { floating_button_type } = (sledgeWishlistSettings == null ? void 0 : sledgeWishlistSettings.launch_point) || {};
1473
+ const isBottomFloatingType = String(floating_button_type).includes("bottom");
1474
+ if (floating_button_type !== "none") {
1475
+ if (isBottomFloatingType) {
1476
+ element.map((item, index) => {
1477
+ if (item && !index) {
1478
+ if (item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`))
1479
+ item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`).remove();
1480
+ let elementContainerWidget = document.createElement("div");
1481
+ elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
1482
+ item.appendChild(elementContainerWidget);
1483
+ const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
1484
+ client.createRoot(elementContainerWidget).render(
1485
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1486
+ SledgeContext.Provider,
1487
+ {
1488
+ value: {
1489
+ isRenderApp: {
1490
+ wishlist: true,
1491
+ productReview: true,
1492
+ instantSearch: true
1493
+ },
1494
+ sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
1495
+ isJsVersion: true
1496
+ },
1497
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"), position: floating_button_type })
1498
+ }
1499
+ ) })
1500
+ );
1501
+ }
1502
+ });
1503
+ } else {
1504
+ element.map((item, index) => {
1505
+ if (item && !index) {
1506
+ if (item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`))
1507
+ item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`).remove();
1508
+ let elementContainerWidget = document.createElement("div");
1509
+ elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
1510
+ item.appendChild(elementContainerWidget);
1511
+ const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
1512
+ client.createRoot(elementContainerWidget).render(
1513
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1514
+ SledgeContext.Provider,
1515
+ {
1516
+ value: {
1517
+ isRenderApp: {
1518
+ wishlist: true,
1519
+ productReview: true,
1520
+ instantSearch: true
1521
+ },
1522
+ sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
1523
+ isJsVersion: true
1524
+ },
1525
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"), position: floating_button_type })
1526
+ }
1527
+ ) })
1528
+ );
1529
+ }
1530
+ });
1531
+ }
1532
+ } else {
1533
+ element.map((item) => {
1534
+ if (item) {
1535
+ const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
1536
+ if (item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`))
1537
+ item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`).remove();
1538
+ let elementContainerWidget = document.createElement("div");
1539
+ elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
1540
+ item.appendChild(elementContainerWidget);
1541
+ client.createRoot(elementContainerWidget).render(
1542
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1543
+ SledgeContext.Provider,
1544
+ {
1545
+ value: {
1546
+ isRenderApp: {
1547
+ wishlist: true,
1548
+ productReview: true,
1549
+ instantSearch: true
1550
+ },
1551
+ sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
1552
+ isJsVersion: true
1553
+ },
1554
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true") })
1555
+ }
1556
+ ) })
1557
+ );
1558
+ }
1559
+ });
1560
+ }
1561
+ };
1246
1562
  const Trigger = (props) => {
1247
1563
  var _a, _b, _c, _d, _e;
1248
- const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked } = props;
1564
+ const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked, triggerBadge = "default" } = props;
1249
1565
  const { productId, productVariantId } = params || {};
1250
- const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
1566
+ const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion } = React__default.useContext(SledgeContext);
1251
1567
  const { wishlist: isRenderAppWishlist } = isRenderApp || {};
1252
1568
  const { trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
1253
1569
  const defaultColorIcon = "#767676";
@@ -1308,7 +1624,13 @@ const Trigger = (props) => {
1308
1624
  setIsWishlist(!isWishlist);
1309
1625
  if (triggerRenderWishlistBadge)
1310
1626
  triggerRenderWishlistBadge(true);
1311
- BadgeCounterInitSelector();
1627
+ if (isJsVersion) {
1628
+ if (triggerBadge === "rerender") {
1629
+ BadgeInitSelector();
1630
+ } else {
1631
+ BadgeCounterInitSelector();
1632
+ }
1633
+ }
1312
1634
  if (typeof window !== "undefined") {
1313
1635
  if (window.sledgeWishlistWidgetListUpdate)
1314
1636
  window.sledgeWishlistWidgetListUpdate();
@@ -1455,9 +1777,9 @@ const WidgetHeaderClearTrigger = ({ buttonText, shareId, dataSettings, isFirstLo
1455
1777
  };
1456
1778
  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: "lighten", 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: buttonText ? buttonText : button_clear_all || "Clear Wishlist" }) }) }) }) });
1457
1779
  };
1458
- const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger, shareLink, shareId, dataSettings, isFirstLoading }) => {
1780
+ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger, shareLink, shareId, dataSettings, isFirstLoading, triggerBadge }) => {
1459
1781
  var _a, _b, _c, _d, _e, _f, _g, _h;
1460
- const { triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
1782
+ const { triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion } = React__default.useContext(SledgeContext);
1461
1783
  const { trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
1462
1784
  const { is_required_login } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.global) || {};
1463
1785
  const {
@@ -1523,7 +1845,13 @@ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger,
1523
1845
  if (typeof window !== "undefined") {
1524
1846
  if (triggerRenderWishlistBadge)
1525
1847
  triggerRenderWishlistBadge(true);
1526
- BadgeCounterInitSelector();
1848
+ if (isJsVersion) {
1849
+ if (triggerBadge === "rerender") {
1850
+ BadgeInitSelector();
1851
+ } else {
1852
+ BadgeCounterInitSelector();
1853
+ }
1854
+ }
1527
1855
  if (window.sledgeInfoPopup)
1528
1856
  window.sledgeInfoPopup({
1529
1857
  title: title_added_all_to_wishlist,
@@ -4127,7 +4455,8 @@ const FacetComponent = (props) => {
4127
4455
  setValueFilterPriceChange,
4128
4456
  separatedFilterItem,
4129
4457
  setSeparatedFilterItem,
4130
- settings
4458
+ settings,
4459
+ filterItemRef
4131
4460
  } = props;
4132
4461
  let aliases = {};
4133
4462
  if (filter.value === "hierarchicalProductType")
@@ -4224,7 +4553,7 @@ const FacetComponent = (props) => {
4224
4553
  const handleFacetCheckbox = (props2) => {
4225
4554
  var _a2, _b2;
4226
4555
  const { facetValues, virtualized } = props2;
4227
- const { index, key, style, isScrolling, isVisible } = virtualized || {};
4556
+ const { index, key, style } = virtualized || {};
4228
4557
  return (_b2 = handleFacetValues(virtualized && ((_a2 = Object.keys(virtualized)) == null ? void 0 : _a2.length) ? [facetValues[index]] : facetValues)) == null ? void 0 : _b2.map((facetValue) => {
4229
4558
  var _a3;
4230
4559
  const { labelName, value: itemValue, counter, children, level } = facetValue;
@@ -4237,7 +4566,7 @@ const FacetComponent = (props) => {
4237
4566
  const blockComponentChildren = handleFacetCheckbox({
4238
4567
  facetValues: currentItems2
4239
4568
  });
4240
- const content = !isVisible && isScrolling ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingDots, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(
4569
+ const content = /* @__PURE__ */ jsxRuntimeExports.jsx(
4241
4570
  Checkbox,
4242
4571
  {
4243
4572
  id: `${value}_${index}${isFacetHierarchical ? `_${stringToSlug(itemValue)}` : ""}`,
@@ -4283,7 +4612,7 @@ const FacetComponent = (props) => {
4283
4612
  ] });
4284
4613
  });
4285
4614
  };
4286
- let scrollElement = document.querySelector(`#filter-component-${stringToSlug(value)} .sledge-instant-search__result-filter-item-list`);
4615
+ let scrollElement = filterItemRef == null ? void 0 : filterItemRef.current;
4287
4616
  if (isDisplaySlider) {
4288
4617
  items = (defaultFacetStats == null ? void 0 : defaultFacetStats[value]) && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
4289
4618
  let defaultValueMin = valueFilterPriceChange[0] || (items == null ? void 0 : items.min);
@@ -4405,6 +4734,20 @@ const FacetComponent = (props) => {
4405
4734
  }
4406
4735
  return blockComponent;
4407
4736
  };
4737
+ const FilterVerticalComponent = (props) => {
4738
+ const { filter, indexFilter, isRender, classesUlElement, getFacetComponent, filterTitleStyle: filter_title_style = {}, handleOpenFilterVertical, clickedOpenFilters } = props;
4739
+ const { value, label } = filter;
4740
+ const filterItemRef = React__default.useRef(null);
4741
+ return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", id: `filter-component-${stringToSlug(value)}`, children: [
4742
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title", onClick: () => handleOpenFilterVertical(value), children: [
4743
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-title", style: filter_title_style, children: label }),
4744
+ /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: false, animate: clickedOpenFilters.includes(value) ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" }) })
4745
+ ] }),
4746
+ clickedOpenFilters.includes(value) && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), ref: filterItemRef, children: getFacetComponent({
4747
+ filterItemRef
4748
+ }) })
4749
+ ] }, indexFilter) : null;
4750
+ };
4408
4751
  const ButtonLoadMore = ({ text, onClick, isInfiniteScroll, currentPage, totalPage, totalResult, pageInfo: pageInfoProp, isVisibleLoadMore, ...otherProps }) => {
4409
4752
  const [ref, entry] = useIntersectionObserver({
4410
4753
  threshold: 0,
@@ -5548,7 +5891,7 @@ const ResultProduct = (props) => {
5548
5891
  isRender = !defaultValueMin && !defaultValueMax ? false : true;
5549
5892
  }
5550
5893
  let classesUlElement = ["sledge-instant-search__result-filter-item-list"];
5551
- const getFacetComponent = () => /* @__PURE__ */ jsxRuntimeExports.jsx(
5894
+ const getFacetComponent = ({ filterItemRef }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
5552
5895
  FacetComponent,
5553
5896
  {
5554
5897
  filter: {
@@ -5566,7 +5909,8 @@ const ResultProduct = (props) => {
5566
5909
  valueFilterPriceChange,
5567
5910
  setValueFilterPriceChange,
5568
5911
  separatedFilterItem,
5569
- setSeparatedFilterItem
5912
+ setSeparatedFilterItem,
5913
+ filterItemRef
5570
5914
  }
5571
5915
  );
5572
5916
  if (display.toLowerCase() === "swatch" && (items == null ? void 0 : items.length))
@@ -5594,15 +5938,20 @@ const ResultProduct = (props) => {
5594
5938
  }) })
5595
5939
  ] }) : null;
5596
5940
  const filterVerticalComponents = allowedFilter == null ? void 0 : allowedFilter.map((filter, indexFilter) => {
5597
- const { value, label } = filter;
5598
5941
  const { isRender, classesUlElement, getFacetComponent } = filterSettings(filter);
5599
- return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", id: `filter-component-${stringToSlug(value)}`, children: [
5600
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title", onClick: () => handleOpenFilterVertical(value), children: [
5601
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-title", style: filter_title_style, children: label }),
5602
- /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: false, animate: clickedOpenFilters.includes(value) ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" }) })
5603
- ] }),
5604
- clickedOpenFilters.includes(value) && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: getFacetComponent() })
5605
- ] }, indexFilter) : null;
5942
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
5943
+ FilterVerticalComponent,
5944
+ {
5945
+ filter,
5946
+ indexFilter,
5947
+ isRender,
5948
+ classesUlElement,
5949
+ getFacetComponent,
5950
+ filterTitleStyle: filter_title_style,
5951
+ handleOpenFilterVertical,
5952
+ clickedOpenFilters
5953
+ }
5954
+ );
5606
5955
  });
5607
5956
  const filterHorizontalComponents = allowedFilter == null ? void 0 : allowedFilter.map((filter, indexFilter) => {
5608
5957
  const { value, label } = filter;