@sledge-app/react-instant-search 1.0.68 → 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.
@@ -49,7 +49,8 @@ const DATASET_ATTRIBUTE_KEY = {
49
49
  QUERY_SHARE_ID: "data-query-share-id",
50
50
  RENDER_WISHLIST_WIDGET_ALERT: "data-render-wishlist-widget-alert",
51
51
  USE_PROXY_URL: "data-use-proxy-url",
52
- LIMIT_OPTIONS: "data-limit-options"
52
+ LIMIT_OPTIONS: "data-limit-options",
53
+ TRIGGER_BADGE: "data-trigger-badge"
53
54
  },
54
55
  PRODUCT_REVIEW: {
55
56
  RATING_SIZE: "data-rating-size",
@@ -95,7 +96,8 @@ const LOCAL_STORAGE_KEY = {
95
96
  ISSUED_AUTH_APP: "sledge-issued-auth-app",
96
97
  EXPIRED_AUTH_APP: "sledge-expired-auth-app",
97
98
  RECENTLY_VIEWED_APP: "sledge-recently-viewed",
98
- LIMIT_PRODUCT: "sledge-limit-product"
99
+ LIMIT_PRODUCT: "sledge-limit-product",
100
+ WISHLIST_BADGE_COUNTER: "sledge-wishlist-badge-counter"
99
101
  };
100
102
  const INTERNAL_SELECTOR_VALUE = {
101
103
  ELEMENT_TOAST_NOTIFICATION: "toast-notification",
@@ -123,6 +125,7 @@ const SELECTOR = {
123
125
  },
124
126
  WISHLIST: {
125
127
  ELEMENT_BADGE: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-badge"]`,
128
+ ELEMENT_BADGE_COUNTER: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-badge-counter"]`,
126
129
  ELEMENT_BADGE_MENU_ITEM: `[href="#sledge-wishlist-badge-menu-item"]`,
127
130
  ELEMENT_TRIGGER: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-trigger"]`,
128
131
  ELEMENT_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-widget"]`,
@@ -721,13 +724,14 @@ const Pagination = (props) => {
721
724
  ] });
722
725
  };
723
726
  const RadioGroup$1 = "";
724
- const rowRenderer = ({ virtualized, item, id, labelStyle }) => {
727
+ const rowRenderer = ({ virtualized, item, id, labelStyle, useVirtualized }) => {
725
728
  const { index, key = "", style = {} } = virtualized || {};
726
729
  const { label, value } = item;
727
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__radio-group-item-flex", style, children: [
730
+ const content = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
728
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" }) }),
729
732
  /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "sledge__radio-group-label", htmlFor: `${id}${index}`, style: labelStyle, children: label })
730
- ] }, key || index);
733
+ ] });
734
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-item-flex", style, children: content }, key || index);
731
735
  };
732
736
  const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {}, onValueChange, scrollElement, useVirtualized = false }) => {
733
737
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__radio-group-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("form", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -756,7 +760,8 @@ const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {},
756
760
  },
757
761
  item: items[index],
758
762
  id,
759
- labelStyle
763
+ labelStyle,
764
+ useVirtualized
760
765
  })
761
766
  }
762
767
  ) : items.map(
@@ -766,7 +771,8 @@ const RadioGroup = ({ id, name, required, defaultValue, items, labelStyle = {},
766
771
  },
767
772
  item,
768
773
  id,
769
- labelStyle
774
+ labelStyle,
775
+ useVirtualized
770
776
  })
771
777
  )
772
778
  }
@@ -1204,42 +1210,107 @@ const addToCartTrigger$2 = async (data) => {
1204
1210
  return;
1205
1211
  });
1206
1212
  };
1213
+ const wishlistInfo = async ({ callback }) => {
1214
+ var _a, _b;
1215
+ let response;
1216
+ let run = false;
1217
+ let valueTotalWishlist;
1218
+ let valueProxyUrl;
1219
+ response = await getWishlistInfo();
1220
+ run = ((_a = response == null ? void 0 : response.status) == null ? void 0 : _a.code) === 200 || false;
1221
+ valueTotalWishlist = !((_b = response == null ? void 0 : response.data) == null ? void 0 : _b.total_data) ? 0 : response.data.total_data;
1222
+ valueProxyUrl = DEFAULT_WISHLIST_URL;
1223
+ if (run)
1224
+ callback({
1225
+ totalWishlist: valueTotalWishlist,
1226
+ proxyUrl: valueProxyUrl,
1227
+ data: response == null ? void 0 : response.data
1228
+ });
1229
+ };
1230
+ const BadgeCounter = (props) => {
1231
+ var _a;
1232
+ const { data: propsData } = props;
1233
+ const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion } = React__default.useContext(SledgeContext);
1234
+ const { wishlist: isRenderAppWishlist } = isRenderApp || {};
1235
+ const { value: valueRenderWishlistBadge, trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
1236
+ const [totalWishlist, setTotalWishlist] = React__default.useState((propsData == null ? void 0 : propsData.total_data) || 0);
1237
+ const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
1238
+ const [isLoading, setIsLoading] = React__default.useState(!propsData);
1239
+ const [isMaximizeTotalWishlist, setIsMaximizeTotalWishlist] = React__default.useState(false);
1240
+ const [dataSettings, setDataSettings] = React__default.useState({});
1241
+ const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
1242
+ const handleGetWishlistInfo = async () => {
1243
+ if (!propsData || propsData && !Object.keys(propsData).length) {
1244
+ await wishlistInfo({
1245
+ callback: ({ totalWishlist: valueTotalWishlist }) => {
1246
+ setTotalWishlist(valueTotalWishlist);
1247
+ setIsMaximizeTotalWishlist(valueTotalWishlist > 99);
1248
+ setIsFirstLoading(false);
1249
+ setIsLoading(false);
1250
+ localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, valueTotalWishlist);
1251
+ }
1252
+ });
1253
+ } else {
1254
+ localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER, totalWishlist);
1255
+ }
1256
+ };
1257
+ const handleSettings = async (LOCAL_STORAGE_WISHLIST_SETTING) => {
1258
+ let response;
1259
+ response = JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
1260
+ if (!response)
1261
+ return;
1262
+ const { is_required_login } = response || {};
1263
+ setDataSettings(response);
1264
+ setIsRequiredLogin(sledgeAnonymId && is_required_login);
1265
+ };
1266
+ React__default.useEffect(() => {
1267
+ if (!isRenderAppWishlist)
1268
+ return;
1269
+ handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null);
1270
+ }, [isRenderAppWishlist]);
1271
+ React__default.useEffect(() => {
1272
+ if (!(dataSettings == null ? void 0 : dataSettings.launch_point))
1273
+ return;
1274
+ handleGetWishlistInfo();
1275
+ }, [dataSettings]);
1276
+ React__default.useEffect(() => {
1277
+ if (!valueRenderWishlistBadge)
1278
+ return;
1279
+ if (triggerRenderWishlistBadge)
1280
+ triggerRenderWishlistBadge(false);
1281
+ handleGetWishlistInfo();
1282
+ }, [valueRenderWishlistBadge]);
1283
+ const defaultTotalWishlist = isJsVersion ? (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || null : null;
1284
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading ? defaultTotalWishlist : isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 });
1285
+ };
1207
1286
  const Badge = (props) => {
1208
1287
  var _a, _b;
1209
1288
  const { useProxyUrl = false, data: propsData, position: positionProp } = props;
1210
- const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
1289
+ const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion } = React__default.useContext(SledgeContext);
1211
1290
  const { wishlist: isRenderAppWishlist } = isRenderApp || {};
1212
1291
  const { value: valueRenderWishlistBadge, trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
1213
1292
  const defaultColorIcon = "currentColor";
1214
1293
  const [colorIcon, setColorIcon] = React__default.useState(defaultColorIcon);
1215
- const [totalWishlist, setTotalWishlist] = React__default.useState((propsData == null ? void 0 : propsData.total_data) || 0);
1216
1294
  const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
1217
- const [isLoading, setIsLoading] = React__default.useState(!propsData);
1218
1295
  const [isMaximizeTotalWishlist, setIsMaximizeTotalWishlist] = React__default.useState(false);
1219
1296
  const [proxyUrl, setProxyUrl] = React__default.useState((propsData == null ? void 0 : propsData.proxy_url) || "");
1220
1297
  const [dataSettings, setDataSettings] = React__default.useState({});
1221
1298
  const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
1299
+ const [data, setData] = React__default.useState({});
1222
1300
  const { floating_button_type } = (dataSettings == null ? void 0 : dataSettings.launch_point) || {};
1223
1301
  const { alert_login, alert, login_button } = ((_b = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _b.widget) || {};
1224
1302
  const defaultPosition = positionProp || floating_button_type;
1225
1303
  const position = defaultPosition ? defaultPosition : "none";
1226
1304
  const handleGetWishlistInfo = async () => {
1227
- var _a2, _b2;
1228
- let response;
1229
- let run = false;
1230
- let valueTotalWishlist;
1231
- let valueProxyUrl;
1232
- response = await getWishlistInfo();
1233
- run = ((_a2 = response == null ? void 0 : response.status) == null ? void 0 : _a2.code) === 200 || false;
1234
- valueTotalWishlist = !((_b2 = response == null ? void 0 : response.data) == null ? void 0 : _b2.total_data) ? 0 : response.data.total_data;
1235
- valueProxyUrl = DEFAULT_WISHLIST_URL;
1236
- if (run) {
1237
- setTotalWishlist(valueTotalWishlist);
1238
- setIsMaximizeTotalWishlist(valueTotalWishlist > 99);
1239
- setProxyUrl(valueProxyUrl);
1240
- setIsFirstLoading(false);
1241
- setIsLoading(false);
1242
- }
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
+ });
1243
1314
  };
1244
1315
  const handleSettings = async (LOCAL_STORAGE_WISHLIST_SETTING) => {
1245
1316
  let response;
@@ -1289,7 +1360,24 @@ const Badge = (props) => {
1289
1360
  const HeaderMenu = () => {
1290
1361
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge", onClick: handleRequiredLogin, onMouseEnter: () => setColorIcon("#F85538"), onMouseLeave: () => setColorIcon(defaultColorIcon), children: [
1291
1362
  /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 20, height: 20, type: "outline", color: colorIcon }),
1292
- !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
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
+ )
1293
1381
  ] });
1294
1382
  };
1295
1383
  const FloatingFull = () => {
@@ -1297,18 +1385,84 @@ const Badge = (props) => {
1297
1385
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-wishlist__badge-floating-text", children: "My Wishlist" }),
1298
1386
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-wishlist__badge-icon", children: [
1299
1387
  /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 18, height: 18, type: "fill", color: "#000000" }),
1300
- !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
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
+ )
1301
1406
  ] })
1302
1407
  ] }) });
1303
1408
  };
1304
1409
  const FloatingIcon = () => {
1305
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: [
1306
1411
  /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 27.01, height: 25.73, type: "outline", color: "#000000" }),
1307
- !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`, children: isLoading || isRequiredLogin ? 0 : `${isMaximizeTotalWishlist ? "99+" : totalWishlist}` || 0 })
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
+ )
1308
1430
  ] }) }) });
1309
1431
  };
1310
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, {}) });
1311
1433
  };
1434
+ const BadgeCounterInitSelector = () => {
1435
+ let element = Array.from(document.querySelectorAll(SELECTOR.WISHLIST.ELEMENT_BADGE_COUNTER));
1436
+ let isElementDetected = !element || element && !element.length;
1437
+ if (isElementDetected)
1438
+ return;
1439
+ element.map((item) => {
1440
+ if (item) {
1441
+ if (item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`))
1442
+ item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`).remove();
1443
+ let elementContainerWidget = document.createElement("div");
1444
+ elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
1445
+ item.appendChild(elementContainerWidget);
1446
+ client.createRoot(elementContainerWidget).render(
1447
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1448
+ SledgeContext.Provider,
1449
+ {
1450
+ value: {
1451
+ isRenderApp: {
1452
+ wishlist: true,
1453
+ productReview: true,
1454
+ instantSearch: true
1455
+ },
1456
+ sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
1457
+ isJsVersion: true
1458
+ },
1459
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(BadgeCounter, {})
1460
+ }
1461
+ ) })
1462
+ );
1463
+ }
1464
+ });
1465
+ };
1312
1466
  const BadgeInitSelector = () => {
1313
1467
  const sledgeWishlistSettings = localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null) : null;
1314
1468
  let element = Array.from(document.querySelectorAll(SELECTOR.WISHLIST.ELEMENT_BADGE));
@@ -1407,9 +1561,9 @@ const BadgeInitSelector = () => {
1407
1561
  };
1408
1562
  const Trigger = (props) => {
1409
1563
  var _a, _b, _c, _d, _e;
1410
- const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked } = props;
1564
+ const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked, triggerBadge = "default" } = props;
1411
1565
  const { productId, productVariantId } = params || {};
1412
- const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
1566
+ const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion } = React__default.useContext(SledgeContext);
1413
1567
  const { wishlist: isRenderAppWishlist } = isRenderApp || {};
1414
1568
  const { trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
1415
1569
  const defaultColorIcon = "#767676";
@@ -1470,7 +1624,13 @@ const Trigger = (props) => {
1470
1624
  setIsWishlist(!isWishlist);
1471
1625
  if (triggerRenderWishlistBadge)
1472
1626
  triggerRenderWishlistBadge(true);
1473
- BadgeInitSelector();
1627
+ if (isJsVersion) {
1628
+ if (triggerBadge === "rerender") {
1629
+ BadgeInitSelector();
1630
+ } else {
1631
+ BadgeCounterInitSelector();
1632
+ }
1633
+ }
1474
1634
  if (typeof window !== "undefined") {
1475
1635
  if (window.sledgeWishlistWidgetListUpdate)
1476
1636
  window.sledgeWishlistWidgetListUpdate();
@@ -1617,9 +1777,9 @@ const WidgetHeaderClearTrigger = ({ buttonText, shareId, dataSettings, isFirstLo
1617
1777
  };
1618
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" }) }) }) }) });
1619
1779
  };
1620
- const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger, shareLink, shareId, dataSettings, isFirstLoading }) => {
1780
+ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger, shareLink, shareId, dataSettings, isFirstLoading, triggerBadge }) => {
1621
1781
  var _a, _b, _c, _d, _e, _f, _g, _h;
1622
- const { triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
1782
+ const { triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion } = React__default.useContext(SledgeContext);
1623
1783
  const { trigger: triggerRenderWishlistBadge } = ((_a = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a.badge) || {};
1624
1784
  const { is_required_login } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.global) || {};
1625
1785
  const {
@@ -1685,7 +1845,13 @@ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger,
1685
1845
  if (typeof window !== "undefined") {
1686
1846
  if (triggerRenderWishlistBadge)
1687
1847
  triggerRenderWishlistBadge(true);
1688
- BadgeInitSelector();
1848
+ if (isJsVersion) {
1849
+ if (triggerBadge === "rerender") {
1850
+ BadgeInitSelector();
1851
+ } else {
1852
+ BadgeCounterInitSelector();
1853
+ }
1854
+ }
1689
1855
  if (window.sledgeInfoPopup)
1690
1856
  window.sledgeInfoPopup({
1691
1857
  title: title_added_all_to_wishlist,
@@ -4288,8 +4454,15 @@ const FacetComponent = (props) => {
4288
4454
  valueFilterPriceChange,
4289
4455
  setValueFilterPriceChange,
4290
4456
  separatedFilterItem,
4291
- setSeparatedFilterItem
4457
+ setSeparatedFilterItem,
4458
+ settings,
4459
+ filterItemRef
4292
4460
  } = props;
4461
+ let aliases = {};
4462
+ if (filter.value === "hierarchicalProductType")
4463
+ aliases = settings.productTypeAliases || {};
4464
+ if (filter.value === "hierarchicalCollections")
4465
+ aliases = settings.collectionAliases || {};
4293
4466
  const { button_load_more } = (generalDataSettings == null ? void 0 : generalDataSettings.languages) || {};
4294
4467
  const { colors: colorSwatches, languages: languageSettings } = displaySettings || {};
4295
4468
  const {
@@ -4332,7 +4505,7 @@ const FacetComponent = (props) => {
4332
4505
  if (!(isHideFacetWhenZeroValue && !counter))
4333
4506
  facetValues.push({
4334
4507
  ...item,
4335
- labelName,
4508
+ labelName: aliases[labelName] || labelName,
4336
4509
  counter
4337
4510
  });
4338
4511
  }
@@ -4393,39 +4566,40 @@ const FacetComponent = (props) => {
4393
4566
  const blockComponentChildren = handleFacetCheckbox({
4394
4567
  facetValues: currentItems2
4395
4568
  });
4569
+ const content = /* @__PURE__ */ jsxRuntimeExports.jsx(
4570
+ Checkbox,
4571
+ {
4572
+ id: `${value}_${index}${isFacetHierarchical ? `_${stringToSlug(itemValue)}` : ""}`,
4573
+ name: value,
4574
+ value: itemValue,
4575
+ label: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4576
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: `${labelName}${counter !== void 0 && isShowNumberMatchingProduct ? ` (${counter})` : ""}` }),
4577
+ isHasChildren ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4578
+ motion.div,
4579
+ {
4580
+ initial: false,
4581
+ animate: isChecked ? "open" : "closed",
4582
+ variants: ROTATE_FILTER_ARROW_ANIMATION,
4583
+ className: "sledge-instant-search__result-filter-checkbox-item-level-arrow",
4584
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" })
4585
+ }
4586
+ ) : null
4587
+ ] }),
4588
+ onClick: (e) => handleFilterChange({
4589
+ parentId: value,
4590
+ value: e.currentTarget.value
4591
+ }),
4592
+ checked: isChecked,
4593
+ labelStyle: filter_option_style
4594
+ }
4595
+ );
4396
4596
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4397
4597
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4398
4598
  "li",
4399
4599
  {
4400
4600
  className: `sledge-instant-search__result-filter-checkbox-item ${isFacetHierarchical ? `sledge-instant-search__result-filter-checkbox-item-level sledge-instant-search__result-filter-checkbox-item-level-${level}` : ""}`,
4401
4601
  style,
4402
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4403
- Checkbox,
4404
- {
4405
- id: `${value}_${index}${isFacetHierarchical ? `_${stringToSlug(itemValue)}` : ""}`,
4406
- name: value,
4407
- value: itemValue,
4408
- label: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4409
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: `${labelName}${counter !== void 0 && isShowNumberMatchingProduct ? ` (${counter})` : ""}` }),
4410
- isHasChildren ? /* @__PURE__ */ jsxRuntimeExports.jsx(
4411
- motion.div,
4412
- {
4413
- initial: false,
4414
- animate: isChecked ? "open" : "closed",
4415
- variants: ROTATE_FILTER_ARROW_ANIMATION,
4416
- className: "sledge-instant-search__result-filter-checkbox-item-level-arrow",
4417
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 15, height: 15, color: "#000000" })
4418
- }
4419
- ) : null
4420
- ] }),
4421
- onClick: (e) => handleFilterChange({
4422
- parentId: value,
4423
- value: e.currentTarget.value
4424
- }),
4425
- checked: isChecked,
4426
- labelStyle: filter_option_style
4427
- }
4428
- )
4602
+ children: content
4429
4603
  },
4430
4604
  key
4431
4605
  ),
@@ -4438,7 +4612,7 @@ const FacetComponent = (props) => {
4438
4612
  ] });
4439
4613
  });
4440
4614
  };
4441
- let scrollElement = document.querySelector(`#filter-component-${stringToSlug(value)} .sledge-instant-search__result-filter-item-list`);
4615
+ let scrollElement = filterItemRef == null ? void 0 : filterItemRef.current;
4442
4616
  if (isDisplaySlider) {
4443
4617
  items = (defaultFacetStats == null ? void 0 : defaultFacetStats[value]) && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
4444
4618
  let defaultValueMin = valueFilterPriceChange[0] || (items == null ? void 0 : items.min);
@@ -4560,6 +4734,20 @@ const FacetComponent = (props) => {
4560
4734
  }
4561
4735
  return blockComponent;
4562
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
+ };
4563
4751
  const ButtonLoadMore = ({ text, onClick, isInfiniteScroll, currentPage, totalPage, totalResult, pageInfo: pageInfoProp, isVisibleLoadMore, ...otherProps }) => {
4564
4752
  const [ref, entry] = useIntersectionObserver({
4565
4753
  threshold: 0,
@@ -5647,11 +5835,16 @@ const ResultProduct = (props) => {
5647
5835
  else
5648
5836
  valueText = (_a2 = String(valueText)) == null ? void 0 : _a2.replaceAll(hierarchical_collections_separator, " > ");
5649
5837
  valueText = (_b2 = String(valueText)) == null ? void 0 : _b2.replaceAll("_", " ");
5838
+ let aliases = {};
5839
+ if (name === "hierarchicalCollections")
5840
+ aliases = settings.collectionAliases || {};
5841
+ if (name === "hierarchicalProductType")
5842
+ aliases = settings.productTypeAliases || {};
5650
5843
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-refine-selected", style: filter_option_style, children: [
5651
5844
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "sledge-instant-search__result-filter-item-title-refine-list", children: [
5652
5845
  label,
5653
5846
  ": ",
5654
- valueText
5847
+ aliases[value] || valueText
5655
5848
  ] }),
5656
5849
  /* @__PURE__ */ jsxRuntimeExports.jsx(
5657
5850
  "span",
@@ -5698,7 +5891,7 @@ const ResultProduct = (props) => {
5698
5891
  isRender = !defaultValueMin && !defaultValueMax ? false : true;
5699
5892
  }
5700
5893
  let classesUlElement = ["sledge-instant-search__result-filter-item-list"];
5701
- const getFacetComponent = () => /* @__PURE__ */ jsxRuntimeExports.jsx(
5894
+ const getFacetComponent = ({ filterItemRef }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
5702
5895
  FacetComponent,
5703
5896
  {
5704
5897
  filter: {
@@ -5708,6 +5901,7 @@ const ResultProduct = (props) => {
5708
5901
  isFirstLoading,
5709
5902
  displaySettings,
5710
5903
  generalDataSettings,
5904
+ settings,
5711
5905
  searchFacetDistribution,
5712
5906
  clickedFacets,
5713
5907
  handleFilterChange,
@@ -5715,7 +5909,8 @@ const ResultProduct = (props) => {
5715
5909
  valueFilterPriceChange,
5716
5910
  setValueFilterPriceChange,
5717
5911
  separatedFilterItem,
5718
- setSeparatedFilterItem
5912
+ setSeparatedFilterItem,
5913
+ filterItemRef
5719
5914
  }
5720
5915
  );
5721
5916
  if (display.toLowerCase() === "swatch" && (items == null ? void 0 : items.length))
@@ -5743,15 +5938,20 @@ const ResultProduct = (props) => {
5743
5938
  }) })
5744
5939
  ] }) : null;
5745
5940
  const filterVerticalComponents = allowedFilter == null ? void 0 : allowedFilter.map((filter, indexFilter) => {
5746
- const { value, label } = filter;
5747
5941
  const { isRender, classesUlElement, getFacetComponent } = filterSettings(filter);
5748
- return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", id: `filter-component-${stringToSlug(value)}`, children: [
5749
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title", onClick: () => handleOpenFilterVertical(value), children: [
5750
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-title", style: filter_title_style, children: label }),
5751
- /* @__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" }) })
5752
- ] }),
5753
- clickedOpenFilters.includes(value) && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: getFacetComponent() })
5754
- ] }, 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
+ );
5755
5955
  });
5756
5956
  const filterHorizontalComponents = allowedFilter == null ? void 0 : allowedFilter.map((filter, indexFilter) => {
5757
5957
  const { value, label } = filter;