@sledge-app/react-instant-search 2.0.63 → 2.0.64

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.
@@ -68,7 +68,8 @@ const DATASET_ATTRIBUTE_KEY = {
68
68
  RENDER_PAGE_CARD: "data-render-page-card",
69
69
  RENDER_BLOG_CARD: "data-render-blog-card",
70
70
  RENDER_ARTICLE_CARD: "data-render-article-card",
71
- CURRENT_TAGS: "data-current-tags"
71
+ CURRENT_TAGS: "data-current-tags",
72
+ COLLECTION_DEFAULT_SORT_BY: "data-collection-default-sort-by"
72
73
  },
73
74
  PRODUCT_RECOMMENDATION: {
74
75
  DISPLAY_LIMIT: "data-display-limit",
@@ -702,6 +703,23 @@ const translate = (props) => {
702
703
  const translation = (_a = translationObject == null ? void 0 : translationObject[locale]) == null ? void 0 : _a[objectKey];
703
704
  return translation || callbackValue;
704
705
  };
706
+ const getSortMap = ({
707
+ activeCollectionId = "",
708
+ collectionAllId = ""
709
+ }) => {
710
+ activeCollectionId = activeCollectionId || "default";
711
+ collectionAllId = collectionAllId || "all";
712
+ return {
713
+ "best-selling": `bestSellingSort.${collectionAllId}:asc`,
714
+ "manual": `featuredSort.${activeCollectionId}:asc`,
715
+ "created-ascending": "created_at:asc",
716
+ "created-descending": "created_at:desc",
717
+ "price-ascending": `first_available_variant.price:asc`,
718
+ "price-descending": `first_available_variant.price:desc`,
719
+ "title-ascending": "title:asc",
720
+ "title-descending": "title:desc"
721
+ };
722
+ };
705
723
  const root = "";
706
724
  const Loading = "";
707
725
  const ConfirmationPopup = "";
@@ -2781,9 +2799,8 @@ const WidgetRoot = (props) => {
2781
2799
  }
2782
2800
  }
2783
2801
  ) : WishlistWidgetAlert ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: WishlistWidgetAlert() } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(WishlistWidgetAlert, {}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-wishlist__widget-alert", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-wishlist__widget-alert-text", children: [
2784
- alert || "Please login to save your wishlist across devices.",
2785
- " ",
2786
- /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: "/account/login", className: "sledge-wishlist__widget-alert-link", children: alert_login || "Login Here" })
2802
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { dangerouslySetInnerHTML: { __html: alert || "Please login to save your wishlist across devices." } }),
2803
+ /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: "/account/login", className: "sledge-wishlist__widget-alert-link", dangerouslySetInnerHTML: { __html: alert_login || "Login Here" } })
2787
2804
  ] }) }) }) }),
2788
2805
  React__default.Children.count(children) && React__default.Children.map(children, (child) => {
2789
2806
  return React__default.cloneElement(child, {
@@ -2830,7 +2847,7 @@ Widget.Root = WidgetRoot;
2830
2847
  Widget.Header = WidgetHeader$1;
2831
2848
  Widget.List = WidgetList;
2832
2849
  const Badge = (props) => {
2833
- var _a, _b, _c;
2850
+ var _a, _b, _c, _d;
2834
2851
  const {
2835
2852
  children,
2836
2853
  useProxyUrl = false,
@@ -2859,6 +2876,7 @@ const Badge = (props) => {
2859
2876
  const { use_wishlist_flyout } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.widget) || {};
2860
2877
  const { floating_button_type } = (dataSettings == null ? void 0 : dataSettings.launch_point) || {};
2861
2878
  const { alert_login, alert, login_button, header_title: language_header_title, see_all_wishlist } = ((_c = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _c.widget) || {};
2879
+ const { is_required_login } = ((_d = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _d.global) || {};
2862
2880
  const defaultPosition = positionProp || floating_button_type;
2863
2881
  const position = defaultPosition ? defaultPosition : "none";
2864
2882
  const urlWishlistWidget = urlWishlistWidgetProp || proxyUrl;
@@ -2880,9 +2898,9 @@ const Badge = (props) => {
2880
2898
  response = wishlistPreviewSettings || JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
2881
2899
  if (!response)
2882
2900
  return;
2883
- const { is_required_login } = response || {};
2901
+ const { is_required_login: is_required_login2 } = response || {};
2884
2902
  setDataSettings(response);
2885
- setIsRequiredLogin(sledgeAnonymId && is_required_login);
2903
+ setIsRequiredLogin(sledgeAnonymId && is_required_login2);
2886
2904
  setIsFirstLoading(false);
2887
2905
  };
2888
2906
  const handleConfirmationPopup = (props2) => {
@@ -2906,8 +2924,12 @@ const Badge = (props) => {
2906
2924
  if (useWishlistFlyout) {
2907
2925
  setOpenFlyoutWishlistWidget(true);
2908
2926
  } else {
2909
- if (useProxyUrl)
2927
+ if (useProxyUrl) {
2910
2928
  window.location.href = proxyUrl || "/";
2929
+ } else {
2930
+ if (urlWishlistWidgetProp)
2931
+ window.location.href = urlWishlistWidgetProp;
2932
+ }
2911
2933
  }
2912
2934
  }
2913
2935
  };
@@ -2946,27 +2968,46 @@ const Badge = (props) => {
2946
2968
  });
2947
2969
  }
2948
2970
  const HeaderMenu = () => {
2949
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `${mainClassName} sledge-wishlist__badge`, onClick: handleRequiredLogin, onMouseEnter: () => setColorIcon("#F85538"), onMouseLeave: () => setColorIcon(defaultColorIcon), children: [
2950
- /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 20, height: 20, type: "outline", color: colorIcon }),
2951
- !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx(
2952
- "span",
2953
- {
2954
- className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`,
2955
- "data-component": INTERNAL_SELECTOR_VALUE.WISHLIST.ELEMENT_BADGE_COUNTER,
2956
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component": INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2957
- BadgeCounter,
2971
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2972
+ "span",
2973
+ {
2974
+ className: `${mainClassName} sledge-wishlist__badge`,
2975
+ onClick: handleRequiredLogin,
2976
+ onMouseEnter: () => {
2977
+ var _a2, _b2;
2978
+ if ((_b2 = (_a2 = window == null ? void 0 : window.matchMedia) == null ? void 0 : _a2.call(window, "(pointer: coarse)")) == null ? void 0 : _b2.matches)
2979
+ return;
2980
+ setColorIcon("#F85538");
2981
+ },
2982
+ onMouseLeave: () => {
2983
+ var _a2, _b2;
2984
+ if ((_b2 = (_a2 = window == null ? void 0 : window.matchMedia) == null ? void 0 : _a2.call(window, "(pointer: coarse)")) == null ? void 0 : _b2.matches)
2985
+ return;
2986
+ setColorIcon(defaultColorIcon);
2987
+ },
2988
+ children: [
2989
+ /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 20, height: 20, type: "outline", color: colorIcon }),
2990
+ !isFirstLoading && /* @__PURE__ */ jsxRuntimeExports.jsx(
2991
+ "span",
2958
2992
  {
2959
- data: isJsVersion ? {
2960
- ...data,
2961
- ...{
2962
- total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
2993
+ className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`,
2994
+ "data-component": INTERNAL_SELECTOR_VALUE.WISHLIST.ELEMENT_BADGE_COUNTER,
2995
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component": INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2996
+ BadgeCounter,
2997
+ {
2998
+ data: isJsVersion ? {
2999
+ ...data,
3000
+ ...{
3001
+ total_data: (localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_BADGE_COUNTER)) || (data == null ? void 0 : data.total_data)
3002
+ }
3003
+ } : data
2963
3004
  }
2964
- } : data
3005
+ ) })
2965
3006
  }
2966
- ) })
2967
- }
2968
- )
2969
- ] });
3007
+ )
3008
+ ]
3009
+ }
3010
+ );
2970
3011
  };
2971
3012
  const FloatingFull = () => {
2972
3013
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${mainClassName} sledge-wishlist__badge-floating sledge__badge-floating-${position}`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { onClick: handleRequiredLogin, className: "sledge-wishlist__badge-floating-icon-link", children: [
@@ -3042,6 +3083,9 @@ const Badge = (props) => {
3042
3083
  }
3043
3084
  )
3044
3085
  ] }),
3086
+ ...sledgeAnonymId && !is_required_login ? {
3087
+ flyoutInfoContent: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { dangerouslySetInnerHTML: { __html: alert || "Please login to save your wishlist across devices." } })
3088
+ } : {},
3045
3089
  content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-flyout-widget__wishlist-content", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Widget.Root, { isFlyout: useWishlistFlyout, children: [
3046
3090
  /* @__PURE__ */ jsxRuntimeExports.jsx(CustomComponents, { productCard: productCardsComponent }),
3047
3091
  /* @__PURE__ */ jsxRuntimeExports.jsx(Widget.List, {})
@@ -3127,7 +3171,9 @@ const BadgeInitSelector = (props) => {
3127
3171
  const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
3128
3172
  const USE_WISHLIST_FLYOUT = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_WISHLIST_FLYOUT);
3129
3173
  const URL_WISHLIST_WIDGET = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.URL_WISHLIST_WIDGET);
3174
+ const POSITION_WIDGET = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.POSITION_WIDGET);
3130
3175
  const PRODUCT_CARDS = (_a2 = item.querySelector(SELECTOR.GLOBAL.ELEMENT_CUSTOM_COMPONENTS)) == null ? void 0 : _a2.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.RENDER_PRODUCT_CARD);
3176
+ const isPositionFromProps = ["none", "left", "right", "bottom-left", "bottom-right"].includes(POSITION_WIDGET);
3131
3177
  client.createRoot(elementContainerWidget).render(
3132
3178
  /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3133
3179
  SledgeContext.Provider,
@@ -3147,7 +3193,7 @@ const BadgeInitSelector = (props) => {
3147
3193
  previewSettings,
3148
3194
  useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"),
3149
3195
  useWishlistFlyout: Boolean(USE_WISHLIST_FLYOUT && USE_WISHLIST_FLYOUT === "true"),
3150
- position: floating_button_type,
3196
+ position: isPositionFromProps ? POSITION_WIDGET : floating_button_type,
3151
3197
  urlWishlistWidget: URL_WISHLIST_WIDGET,
3152
3198
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(CustomComponents, { productCard: stringToFunction(PRODUCT_CARDS) })
3153
3199
  }
@@ -3176,7 +3222,9 @@ const BadgeInitSelector = (props) => {
3176
3222
  const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
3177
3223
  const USE_WISHLIST_FLYOUT = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_WISHLIST_FLYOUT);
3178
3224
  const URL_WISHLIST_WIDGET = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.URL_WISHLIST_WIDGET);
3225
+ const POSITION_WIDGET = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.POSITION_WIDGET);
3179
3226
  const PRODUCT_CARDS = (_a2 = item.querySelector(SELECTOR.GLOBAL.ELEMENT_CUSTOM_COMPONENTS)) == null ? void 0 : _a2.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.RENDER_PRODUCT_CARD);
3227
+ const isPositionFromProps = ["none", "left", "right", "bottom-left", "bottom-right"].includes(POSITION_WIDGET);
3180
3228
  client.createRoot(elementContainerWidget).render(
3181
3229
  /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3182
3230
  SledgeContext.Provider,
@@ -3196,7 +3244,7 @@ const BadgeInitSelector = (props) => {
3196
3244
  previewSettings,
3197
3245
  useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"),
3198
3246
  useWishlistFlyout: Boolean(USE_WISHLIST_FLYOUT && USE_WISHLIST_FLYOUT === "true"),
3199
- position: floating_button_type,
3247
+ position: isPositionFromProps ? POSITION_WIDGET : floating_button_type,
3200
3248
  urlWishlistWidget: URL_WISHLIST_WIDGET,
3201
3249
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(CustomComponents, { productCard: stringToFunction(PRODUCT_CARDS) })
3202
3250
  }
@@ -3217,7 +3265,9 @@ const BadgeInitSelector = (props) => {
3217
3265
  const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
3218
3266
  const USE_WISHLIST_FLYOUT = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_WISHLIST_FLYOUT);
3219
3267
  const URL_WISHLIST_WIDGET = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.URL_WISHLIST_WIDGET);
3268
+ const POSITION_WIDGET = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.POSITION_WIDGET);
3220
3269
  const PRODUCT_CARDS = (_a2 = item.querySelector(SELECTOR.GLOBAL.ELEMENT_CUSTOM_COMPONENTS)) == null ? void 0 : _a2.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.RENDER_PRODUCT_CARD);
3270
+ const isPositionFromProps = ["none", "left", "right", "bottom-left", "bottom-right"].includes(POSITION_WIDGET);
3221
3271
  const elementPreload = item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="preload"]`);
3222
3272
  if (elementPreload)
3223
3273
  elementPreload.remove();
@@ -3247,6 +3297,7 @@ const BadgeInitSelector = (props) => {
3247
3297
  useProxyUrl: Boolean(USE_PROXY_URL && USE_PROXY_URL === "true"),
3248
3298
  useWishlistFlyout: Boolean(USE_WISHLIST_FLYOUT && USE_WISHLIST_FLYOUT === "true"),
3249
3299
  urlWishlistWidget: URL_WISHLIST_WIDGET,
3300
+ ...isPositionFromProps ? { position: POSITION_WIDGET } : {},
3250
3301
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(CustomComponents, { productCard: stringToFunction(PRODUCT_CARDS) })
3251
3302
  }
3252
3303
  )
@@ -3368,6 +3419,10 @@ const Trigger = (props) => {
3368
3419
  } else {
3369
3420
  BadgeCounterInitSelector({ reload: true });
3370
3421
  }
3422
+ TriggerInitSelector({
3423
+ selector: `[${DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_ID}="${productId}"][${DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_VARIANT_ID}="${productVariantId}"]${SELECTOR.WISHLIST.ELEMENT_TRIGGER}`,
3424
+ reload: true
3425
+ });
3371
3426
  }
3372
3427
  if (typeof window !== "undefined") {
3373
3428
  if (window.sledgeWishlistWidgetListUpdate)
@@ -3494,6 +3549,83 @@ const Trigger = (props) => {
3494
3549
  }
3495
3550
  ) });
3496
3551
  };
3552
+ const ElementInit = (item, reload, previewSettings) => {
3553
+ if ((item == null ? void 0 : item.hasAttribute("loaded")) && !reload)
3554
+ return;
3555
+ item.setAttribute("loaded", "");
3556
+ if (item.parentNode)
3557
+ item.parentNode.classList.add("sledge-wishlist__trigger-parent-element");
3558
+ item.classList.add("sledge-wishlist__trigger-wrapper");
3559
+ const PRODUCT_ID = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_ID);
3560
+ const PRODUCT_VARIANT_ID = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_VARIANT_ID);
3561
+ const PRODUCT_NAME = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_NAME);
3562
+ const PRODUCT_VENDOR = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_VENDOR);
3563
+ const PRODUCT_SKU = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_SKU);
3564
+ const PRODUCT_VARIANT_NAME = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_VARIANT_NAME);
3565
+ const PRODUCT_LINK = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_LINK);
3566
+ const PRODUCT_IMAGE = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_IMAGE);
3567
+ const PRODUCT_CURRENCY = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_CURRENCY);
3568
+ const PRODUCT_PRICE = item.getAttribute(DATASET_ATTRIBUTE_KEY.GLOBAL.PRODUCT_PRICE);
3569
+ const TRIGGER_BADGE = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.TRIGGER_BADGE);
3570
+ const getElementContainerWidgetQuery = item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`);
3571
+ if (getElementContainerWidgetQuery)
3572
+ getElementContainerWidgetQuery.remove();
3573
+ let elementContainerWidget = document.createElement("div");
3574
+ elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
3575
+ item.appendChild(elementContainerWidget);
3576
+ client.createRoot(elementContainerWidget).render(
3577
+ /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3578
+ SledgeContext.Provider,
3579
+ {
3580
+ value: {
3581
+ isRenderApp: {
3582
+ wishlist: true,
3583
+ productReview: true,
3584
+ instantSearch: true
3585
+ },
3586
+ sledgeAnonymId: localStorage.getItem(LOCAL_STORAGE_KEY.ANONYM_ID) || "",
3587
+ isJsVersion: true
3588
+ },
3589
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3590
+ Trigger,
3591
+ {
3592
+ params: {
3593
+ productId: PRODUCT_ID || "",
3594
+ productVariantId: PRODUCT_VARIANT_ID || "",
3595
+ productName: PRODUCT_NAME || "",
3596
+ productVendor: PRODUCT_VENDOR || "",
3597
+ productSku: PRODUCT_SKU || "",
3598
+ productVariantName: PRODUCT_VARIANT_NAME || "",
3599
+ productLink: PRODUCT_LINK || "",
3600
+ productImage: PRODUCT_IMAGE || "",
3601
+ productCurrency: PRODUCT_CURRENCY || "",
3602
+ productPrice: PRODUCT_PRICE || ""
3603
+ },
3604
+ ...TRIGGER_BADGE && {
3605
+ triggerBadge: TRIGGER_BADGE
3606
+ },
3607
+ reload,
3608
+ previewSettings
3609
+ }
3610
+ )
3611
+ }
3612
+ ) })
3613
+ );
3614
+ };
3615
+ const TriggerInitSelector = (props) => {
3616
+ const { selector = "", reload = false, previewSettings = null } = props || {};
3617
+ const getSelector = selector || SELECTOR.WISHLIST.ELEMENT_TRIGGER;
3618
+ watchElement({
3619
+ selector: getSelector,
3620
+ init: ElementInit
3621
+ });
3622
+ let element = Array.from(document.querySelectorAll(getSelector));
3623
+ if (!element || element && !element.length)
3624
+ return;
3625
+ element.map((item) => {
3626
+ ElementInit(item, reload, previewSettings);
3627
+ });
3628
+ };
3497
3629
  const getReviewInfo = async (props) => {
3498
3630
  const { productId = null, query = null } = props || {};
3499
3631
  let convertId = productId ? sanitizeDataId(productId) : "";
@@ -3704,6 +3836,7 @@ const Rating = (props) => {
3704
3836
  ["data-rating-size"]: size
3705
3837
  } : {},
3706
3838
  ref: rootRef,
3839
+ "data-review-counter": totalReview || 0,
3707
3840
  children: isFirstLoading && withSkeletonLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "230px", height: "28px", color: "lighten", rounded: "md" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isLoading && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3708
3841
  [1, 2, 3, 4, 5].map((item, index) => {
3709
3842
  if (!(item <= numberOfIcons))
@@ -5612,7 +5745,7 @@ const DotButton = (props) => {
5612
5745
  return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", ...restProps, children });
5613
5746
  };
5614
5747
  const FlyoutSidebar$1 = "";
5615
- const FlyoutSidebar = ({ title, content, footer = null, open, setOpen, position = "left", className = "", withBlurEffect = false }) => {
5748
+ const FlyoutSidebar = ({ title, content, footer = null, open, setOpen, position = "left", className = "", withBlurEffect = false, flyoutInfoContent = null }) => {
5616
5749
  const [isLoading, setIsLoading] = React__default.useState(false);
5617
5750
  const [isScrollAtBottom, setIsScrollAtBottom] = React__default.useState(false);
5618
5751
  const contentContainerRef = React__default.useRef(null);
@@ -5639,10 +5772,13 @@ const FlyoutSidebar = ({ title, content, footer = null, open, setOpen, position
5639
5772
  if (!open)
5640
5773
  return;
5641
5774
  setIsLoading(true);
5642
- setTimeout(() => {
5643
- setIsLoading(false);
5644
- }, 0);
5645
5775
  }, [open]);
5776
+ React__default.useEffect(() => {
5777
+ if (isLoading) {
5778
+ const id = requestAnimationFrame(() => setIsLoading(false));
5779
+ return () => cancelAnimationFrame(id);
5780
+ }
5781
+ }, [isLoading]);
5646
5782
  const showBlurEffect = withBlurEffect && !isScrollAtBottom;
5647
5783
  return createPortal(
5648
5784
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `sledge__flyout-mobile ${className}`, "data-open": open, "data-position": position, children: [
@@ -5652,6 +5788,7 @@ const FlyoutSidebar = ({ title, content, footer = null, open, setOpen, position
5652
5788
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__flyout-mobile-title", children: title }),
5653
5789
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__flyout-close-field-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "sledge__flyout-close-field", type: "button", onClick: () => setOpen(false), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CloseIcon, { width: 14, height: 14, color: "#393d4e" }) }) })
5654
5790
  ] }),
5791
+ flyoutInfoContent ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__flyout-mobile-info", children: flyoutInfoContent }) : null,
5655
5792
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: contentContainerRef, className: `sledge__flyout-mobile-content ${showBlurEffect ? "sledge__flyout-mobile-content-blur-effect" : ""}`, children: isLoading ? null : content }),
5656
5793
  footer ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__flyout-mobile-footer", children: isLoading ? null : footer }) : null
5657
5794
  ] })
@@ -9202,7 +9339,8 @@ const SearchResultWidget = (props) => {
9202
9339
  data: propsData,
9203
9340
  sledgeSettings,
9204
9341
  previewSettings: previewSettingsProp,
9205
- currentTags = []
9342
+ currentTags = [],
9343
+ collectionDefaultSortBy
9206
9344
  } = props;
9207
9345
  const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
9208
9346
  const querySortBy = (query == null ? void 0 : query.sortBy) ? query.sortBy : DEFAULT_QUERY_PARAM.SORT_BY;
@@ -9578,6 +9716,7 @@ const SearchResultWidget = (props) => {
9578
9716
  active_tabs,
9579
9717
  allowed_sorts,
9580
9718
  default_sort,
9719
+ featured_as_collection_default_sort,
9581
9720
  index_product,
9582
9721
  tabs: tabs2,
9583
9722
  hidden_tags,
@@ -10088,7 +10227,8 @@ const SearchResultWidget = (props) => {
10088
10227
  instantSearchSettings,
10089
10228
  currentColumnGrid,
10090
10229
  setCurrentColumnGrid,
10091
- currentTags
10230
+ currentTags,
10231
+ collectionDefaultSortBy
10092
10232
  })
10093
10233
  ] });
10094
10234
  };
@@ -10176,7 +10316,8 @@ const ResultProduct = React__default.memo((props) => {
10176
10316
  instantSearchSettings,
10177
10317
  currentColumnGrid,
10178
10318
  setCurrentColumnGrid,
10179
- currentTags
10319
+ currentTags,
10320
+ collectionDefaultSortBy
10180
10321
  } = props || {};
10181
10322
  const { collectionId, collectionName } = params || {};
10182
10323
  const isLoadMore = ["load_more", "infinite_scroll"].includes((_a = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _a.pagination_type);
@@ -10552,7 +10693,7 @@ const ResultProduct = React__default.memo((props) => {
10552
10693
  setSearchFacetDistribution(facetDistribution);
10553
10694
  };
10554
10695
  const handleSearchResult = async (props2) => {
10555
- var _a2, _b2;
10696
+ var _a2, _b2, _c2;
10556
10697
  if (!clickedTabIndexId)
10557
10698
  return;
10558
10699
  const { isLoadMore: isLoadMore2 = false, isReplaceData = false, onSearch } = props2;
@@ -10576,8 +10717,20 @@ const ResultProduct = React__default.memo((props) => {
10576
10717
  let sort = soldProductAtEnd ? ["availability:asc"] : [];
10577
10718
  if (clickedSortId)
10578
10719
  sort.push(clickedSortId);
10720
+ if (collectionDefaultSortBy && ((_a2 = sort == null ? void 0 : sort.some) == null ? void 0 : _a2.call(sort, (item) => item.includes("featuredSort."))) && (instantSearchSettings == null ? void 0 : instantSearchSettings.featured_as_collection_default_sort)) {
10721
+ const sortMap = getSortMap({
10722
+ activeCollectionId: collectionId,
10723
+ collectionAllId: instantSearchSettings == null ? void 0 : instantSearchSettings.collections_all_id
10724
+ });
10725
+ sort = sort.map((item) => {
10726
+ if (item.includes("featuredSort.")) {
10727
+ return sortMap[collectionDefaultSortBy];
10728
+ }
10729
+ return item;
10730
+ });
10731
+ }
10579
10732
  if (propsData && handleSearchResultFirstTime) {
10580
- response = (_b2 = (_a2 = propsData == null ? void 0 : propsData.result) == null ? void 0 : _a2.results) == null ? void 0 : _b2[0];
10733
+ response = (_c2 = (_b2 = propsData == null ? void 0 : propsData.result) == null ? void 0 : _b2.results) == null ? void 0 : _c2[0];
10581
10734
  } else {
10582
10735
  response = await handleSearchResponse({
10583
10736
  layoutType,