@sledge-app/react-instant-search 0.0.71 → 0.0.72

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.
@@ -1,4 +1,4 @@
1
- import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as $a093c7e1ec25a057$export$2881499e37b75b9a, F as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, G as $a093c7e1ec25a057$export$41fb9f06171c75f4, H as $a093c7e1ec25a057$export$602eac185826482c, I as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, J as $a093c7e1ec25a057$export$21b07c8f274aebd5, K as $57acba87d6e25586$export$be92b6f5f03c0fe9, L as $57acba87d6e25586$export$d5c6c08dc2d3ca7, M as $57acba87d6e25586$export$9a4e88b92edfce6b, N as $57acba87d6e25586$export$6521433ed15a34db, O as $57acba87d6e25586$export$ac61190d9fc311a9, P as MasonryResponsive, Q as Masonry, R as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, S as $5d3850c4d0b4e6c7$export$602eac185826482c, T as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, U as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-90dfd914.js";
1
+ import { j as jsxRuntimeExports, $ as $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, a as $cb5cc270b50c6fcd$export$41fb9f06171c75f4, b as $cb5cc270b50c6fcd$export$602eac185826482c, c as $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, d as $cb5cc270b50c6fcd$export$f39c2d165cd861fe, e as $cb5cc270b50c6fcd$export$21b07c8f274aebd5, f as $67824d98245208a0$export$be92b6f5f03c0fe9, g as $67824d98245208a0$export$adb584737d712b70, h as $e698a72e93240346$export$be92b6f5f03c0fe9, i as $e698a72e93240346$export$adb584737d712b70, k as $faa2e61a3361514f$export$be92b6f5f03c0fe9, l as $faa2e61a3361514f$export$13921ac0cc260818, m as $faa2e61a3361514f$export$9a58ef0d7ad3278c, n as $faa2e61a3361514f$export$6521433ed15a34db, o as $f99a8c78507165f7$export$be92b6f5f03c0fe9, p as $f99a8c78507165f7$export$6d08773d2e66f8f2, q as $f99a8c78507165f7$export$adb584737d712b70, r as $cc7e05a45900e73f$export$6d08773d2e66f8f2, s as $cc7e05a45900e73f$export$d6e5bf9c43ea9319, t as $cc7e05a45900e73f$export$c3468e2714d175fa, u as $cc7e05a45900e73f$export$be92b6f5f03c0fe9, v as $cc7e05a45900e73f$export$41fb9f06171c75f4, w as $cc7e05a45900e73f$export$4c8d1a57a761ef94, x as $cc7e05a45900e73f$export$f04a61298a47a40f, y as $cc7e05a45900e73f$export$602eac185826482c, z as $cc7e05a45900e73f$export$7c6e2c02157bb7d2, A as $cc7e05a45900e73f$export$2f60d3ec9ad468f2, B as $cc7e05a45900e73f$export$d5c6c08dc2d3ca7, C as $cc7e05a45900e73f$export$bf1aedc3039c8d63, D as motion, E as $a093c7e1ec25a057$export$2881499e37b75b9a, F as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, G as $a093c7e1ec25a057$export$41fb9f06171c75f4, H as $a093c7e1ec25a057$export$602eac185826482c, I as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, J as $a093c7e1ec25a057$export$21b07c8f274aebd5, K as $57acba87d6e25586$export$be92b6f5f03c0fe9, L as $57acba87d6e25586$export$d5c6c08dc2d3ca7, M as $57acba87d6e25586$export$9a4e88b92edfce6b, N as $57acba87d6e25586$export$6521433ed15a34db, O as $57acba87d6e25586$export$ac61190d9fc311a9, P as MasonryResponsive, Q as Masonry, R as $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, S as $5d3850c4d0b4e6c7$export$602eac185826482c, T as $5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, U as $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2 } from "./vendor-eeee87f8.js";
2
2
  import React__default, { createElement } from "react";
3
3
  import { SledgeContext } from "@sledge-app/core";
4
4
  import "react-dom";
@@ -619,7 +619,7 @@ const addToCartTrigger$1 = async (data) => {
619
619
  };
620
620
  const Trigger = (props) => {
621
621
  var _a, _b, _c;
622
- const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist } = props;
622
+ const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked } = props;
623
623
  const { productId, productVariantId } = params || {};
624
624
  const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId } = React__default.useContext(SledgeContext);
625
625
  const defaultColorIcon = "#767676";
@@ -639,9 +639,13 @@ const Trigger = (props) => {
639
639
  const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
640
640
  const { show: show_notification, location: location_notification } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.notification) || {};
641
641
  const { title_added_to_wishlist, text_added_to_wishlist, title_removed_to_wishlist, text_removed_to_wishlist } = ((_c = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _c.notification) || {};
642
- const handleCheckWishlist = async () => {
642
+ const handleCheckWishlist = async (init) => {
643
643
  let response;
644
- response = await checkWishlist(productId, productVariantId);
644
+ if (typeof wishlistChecked === "boolean" && init) {
645
+ response = wishlistChecked;
646
+ } else {
647
+ response = await checkWishlist(productId, productVariantId);
648
+ }
645
649
  setIsWishlist(forceActive ? forceActive : response);
646
650
  };
647
651
  const handleClick = async (e) => {
@@ -667,7 +671,7 @@ const Trigger = (props) => {
667
671
  if (code === 200) {
668
672
  if (typeof window !== "undefined") {
669
673
  if (window.sledgeWishlistBadgeUpdate) {
670
- if ((_b2 = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a2.badge) == null ? void 0 : _b2.trigger)
674
+ if (((_b2 = (_a2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _a2.badge) == null ? void 0 : _b2.trigger) && typeof wishlistChecked !== "boolean")
671
675
  (_f = (_c2 = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _c2.badge) == null ? void 0 : _f.trigger(!((_e = (_d = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.wishlist) == null ? void 0 : _d.badge) == null ? void 0 : _e.value));
672
676
  window.sledgeWishlistBadgeUpdate();
673
677
  }
@@ -709,24 +713,18 @@ const Trigger = (props) => {
709
713
  const handleSettings = async (LOCAL_STORAGE_WISHLIST_SETTING) => {
710
714
  setIsLoading(true);
711
715
  let response;
712
- let run = false;
713
716
  response = JSON.parse(LOCAL_STORAGE_WISHLIST_SETTING);
714
717
  if (!response)
715
718
  return;
716
- const { status, data } = response;
717
- const { code } = status;
718
- run = code === 200 || false;
719
- if (run) {
720
- setDataSettings(data);
721
- setIsLoading(false);
722
- }
719
+ setDataSettings(response);
720
+ setIsLoading(false);
723
721
  };
724
722
  React__default.useEffect(() => {
725
723
  if (!(isRenderApp == null ? void 0 : isRenderApp.wishlist))
726
724
  return;
727
725
  if (typeof window !== "undefined") {
728
726
  window.sledgeWishlistTriggerUpdate = () => {
729
- handleCheckWishlist();
727
+ handleCheckWishlist(true);
730
728
  };
731
729
  }
732
730
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || "");
@@ -737,7 +735,7 @@ const Trigger = (props) => {
737
735
  React__default.useEffect(() => {
738
736
  if (!(isRenderApp == null ? void 0 : isRenderApp.wishlist))
739
737
  return;
740
- handleCheckWishlist();
738
+ handleCheckWishlist(true);
741
739
  }, [isRenderApp, productVariantId]);
742
740
  const isActive = (isWishlist || forceActive) && !isRequiredLogin;
743
741
  React__default.useEffect(() => {
@@ -1159,7 +1157,7 @@ const getReviewInfo = async (id) => {
1159
1157
  };
1160
1158
  const Rating = (props) => {
1161
1159
  var _a;
1162
- const { value, size = "md", params, withSkeletonLoading = true, isScrollToElementWidget = true, defaultData } = props;
1160
+ const { value, size = "md", params, withSkeletonLoading = true, isScrollToElementWidget = true, data: propsData } = props;
1163
1161
  const { productId } = params || {};
1164
1162
  const { isRenderApp, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
1165
1163
  const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
@@ -1180,7 +1178,7 @@ const Rating = (props) => {
1180
1178
  let valueTotalReview = 0;
1181
1179
  let valueAverageReview;
1182
1180
  let data;
1183
- if (!defaultData) {
1181
+ if (!propsData) {
1184
1182
  response = await getReviewInfo(validateProductId);
1185
1183
  if (!response)
1186
1184
  return;
@@ -1189,7 +1187,7 @@ const Rating = (props) => {
1189
1187
  const { code } = status;
1190
1188
  run = code === 200 || false;
1191
1189
  } else {
1192
- data = defaultData;
1190
+ data = propsData;
1193
1191
  run = true;
1194
1192
  }
1195
1193
  valueTotalReview = (data == null ? void 0 : data.review_count) ? data.review_count : 0;
@@ -1212,17 +1210,11 @@ const Rating = (props) => {
1212
1210
  const handleSettings = async (LOCAL_STORAGE_PRODUCT_REVIEW_SETTING) => {
1213
1211
  setIsLoading(true);
1214
1212
  let response;
1215
- let run = false;
1216
1213
  response = JSON.parse(LOCAL_STORAGE_PRODUCT_REVIEW_SETTING);
1217
1214
  if (!response)
1218
1215
  return;
1219
- const { status, data } = response;
1220
- const { code } = status;
1221
- run = code === 200 || false;
1222
- if (run) {
1223
- setDataSettings(data);
1224
- await handleRefreshProductRating();
1225
- }
1216
+ setDataSettings(response);
1217
+ await handleRefreshProductRating();
1226
1218
  };
1227
1219
  const handleOnClick = () => {
1228
1220
  if (!isScrollToElementWidget)
@@ -1680,7 +1672,8 @@ const ProductGrid = ({
1680
1672
  onAfterRemoveWishlist,
1681
1673
  onAfterRenderProduct,
1682
1674
  showPopupComponent,
1683
- setShowPopupComponent
1675
+ setShowPopupComponent,
1676
+ dataReviews
1684
1677
  }) => {
1685
1678
  const {
1686
1679
  show_vendor = true,
@@ -1842,7 +1835,8 @@ const ProductGrid = ({
1842
1835
  },
1843
1836
  size: "xs",
1844
1837
  withSkeletonLoading: false,
1845
- isScrollToElementWidget: false
1838
+ isScrollToElementWidget: false,
1839
+ data: dataReviews == null ? void 0 : dataReviews[id]
1846
1840
  }
1847
1841
  ) })
1848
1842
  ] })
@@ -2438,22 +2432,16 @@ const SearchIconWidgetPopup = () => {
2438
2432
  if (!showInfo)
2439
2433
  return;
2440
2434
  let response;
2441
- let run = false;
2442
2435
  response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
2443
2436
  if (!response)
2444
2437
  return;
2445
- const { status, data } = response;
2446
- const { code } = status;
2447
- const { tabs, suffix_index_product, hidden_tags, display } = data;
2448
- run = code === 200 || false;
2449
- if (run) {
2450
- setAllowedTabs(tabs);
2451
- setSuffixIndexProduct(suffix_index_product);
2452
- setHiddenTags(hidden_tags);
2453
- setDisplaySettings(display);
2454
- setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
2455
- await handleMultiSearch(data);
2456
- }
2438
+ const { tabs, suffix_index_product, hidden_tags, display } = response;
2439
+ setAllowedTabs(tabs);
2440
+ setSuffixIndexProduct(suffix_index_product);
2441
+ setHiddenTags(hidden_tags);
2442
+ setDisplaySettings(display);
2443
+ setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
2444
+ await handleMultiSearch(response);
2457
2445
  };
2458
2446
  React__default.useEffect(() => {
2459
2447
  if (typeof window !== "undefined") {
@@ -2811,33 +2799,27 @@ const SearchResultWidget = (props) => {
2811
2799
  const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
2812
2800
  setIsLoadingSetting(true);
2813
2801
  let response;
2814
- let run = false;
2815
2802
  let getFirstIndex;
2816
2803
  response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
2817
2804
  if (!response)
2818
2805
  return;
2819
- const { status, data } = response;
2820
- const { code } = status;
2821
- const { allowed_sorts, default_sort, filters, tabs, suffix_index_product, hidden_tags, display, colors, show_out_of_stock } = data;
2822
- run = code === 200 || false;
2823
- if (run) {
2824
- setAllowedSorts((allowed_sorts == null ? void 0 : allowed_sorts.length) ? allowed_sorts : []);
2825
- setAllowedFilters((filters == null ? void 0 : filters.length) ? filters : []);
2826
- setSuffixIndexProduct(suffix_index_product);
2827
- setHiddenTags(hidden_tags);
2828
- setDisplaySettings(display);
2829
- setColorSwatches(colors);
2830
- setDefaultSort(default_sort);
2831
- setShowOutOfStock(show_out_of_stock);
2832
- getFirstIndex = tabs.find(({ index }) => index.includes(suffix_index_product));
2833
- if (Object.keys(getFirstIndex).length) {
2834
- setClickedTabIndexId(getFirstIndex.index);
2835
- setClickedTabIndexName(getFirstIndex.name);
2836
- }
2837
- await handleInitStates(data, "default");
2838
- if (layoutType === "default")
2839
- await handleInitStates(data, "totalDataPerIndex");
2806
+ const { allowed_sorts, default_sort, filters, tabs, suffix_index_product, hidden_tags, display, colors, show_out_of_stock } = response;
2807
+ setAllowedSorts((allowed_sorts == null ? void 0 : allowed_sorts.length) ? allowed_sorts : []);
2808
+ setAllowedFilters((filters == null ? void 0 : filters.length) ? filters : []);
2809
+ setSuffixIndexProduct(suffix_index_product);
2810
+ setHiddenTags(hidden_tags);
2811
+ setDisplaySettings(display);
2812
+ setColorSwatches(colors);
2813
+ setDefaultSort(default_sort);
2814
+ setShowOutOfStock(show_out_of_stock);
2815
+ getFirstIndex = tabs.find(({ index }) => index.includes(suffix_index_product));
2816
+ if (Object.keys(getFirstIndex).length) {
2817
+ setClickedTabIndexId(getFirstIndex.index);
2818
+ setClickedTabIndexName(getFirstIndex.name);
2840
2819
  }
2820
+ await handleInitStates(response, "default");
2821
+ if (layoutType === "default")
2822
+ await handleInitStates(response, "totalDataPerIndex");
2841
2823
  };
2842
2824
  React__default.useEffect(() => {
2843
2825
  if (!(isRenderApp == null ? void 0 : isRenderApp.instantSearch))
@@ -4044,22 +4026,16 @@ const SearchWidget = (props) => {
4044
4026
  if (!keyword.length)
4045
4027
  return;
4046
4028
  let response;
4047
- let run = false;
4048
4029
  response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
4049
4030
  if (!response)
4050
4031
  return;
4051
- const { status, data } = response;
4052
- const { code } = status;
4053
- const { tabs, suffix_index_product, hidden_tags, display } = data;
4054
- run = code === 200 || false;
4055
- if (run) {
4056
- setAllowedTabs(tabs);
4057
- setSuffixIndexProduct(suffix_index_product);
4058
- setHiddenTags(hidden_tags);
4059
- setDisplaySettings(display);
4060
- setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
4061
- await handleMultiSearch(data);
4062
- }
4032
+ const { tabs, suffix_index_product, hidden_tags, display } = response;
4033
+ setAllowedTabs(tabs);
4034
+ setSuffixIndexProduct(suffix_index_product);
4035
+ setHiddenTags(hidden_tags);
4036
+ setDisplaySettings(display);
4037
+ setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
4038
+ await handleMultiSearch(response);
4063
4039
  };
4064
4040
  React__default.useEffect(() => {
4065
4041
  if (!(isRenderApp == null ? void 0 : isRenderApp.instantSearch))