@sledge-app/react-instant-search 2.0.2 → 2.0.4

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.
@@ -1094,7 +1094,7 @@ const Pagination = (props) => {
1094
1094
  };
1095
1095
  React__default.useEffect(() => {
1096
1096
  handlePageInfo();
1097
- }, []);
1097
+ }, [pageInfoProp]);
1098
1098
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__pagination", "data-pagination-type": type, children: renderPaginationLayout() });
1099
1099
  };
1100
1100
  const RadioGroup$1 = "";
@@ -2519,7 +2519,7 @@ const WidgetRoot = (props) => {
2519
2519
  }
2520
2520
  };
2521
2521
  const handleSetWishlistData = async (isLoadMore = false, init = false) => {
2522
- var _a2, _b2, _c2, _d;
2522
+ var _a2, _b2, _c2;
2523
2523
  const searchParams = new URLSearchParams(document.location.search);
2524
2524
  const getShareId = (params == null ? void 0 : params.shareId) ? params.shareId : (searchParams == null ? void 0 : searchParams.get(queryShareId)) || "";
2525
2525
  setIsLoading(isRefreshWidgetList ? true : !isLoadMore);
@@ -2530,7 +2530,6 @@ const WidgetRoot = (props) => {
2530
2530
  let response;
2531
2531
  let run = false;
2532
2532
  let valueWishlistData;
2533
- let valueWishlistSort;
2534
2533
  let valueTotalPage = 0;
2535
2534
  let queryParam = {
2536
2535
  page: isLoadMore ? currentPage : 1,
@@ -2549,11 +2548,9 @@ const WidgetRoot = (props) => {
2549
2548
  response = await getWishlist(queryParam);
2550
2549
  run = ((_a2 = response == null ? void 0 : response.status) == null ? void 0 : _a2.code) === 200 || false;
2551
2550
  valueWishlistData = !((_b2 = response.data) == null ? void 0 : _b2.length) ? [] : (prevState) => (wishlistData == null ? void 0 : wishlistData.length) && isLoadMore ? [...prevState, ...response.data] : response.data;
2552
- valueWishlistSort = !((_c2 = response.sorts) == null ? void 0 : _c2.length) ? [] : response.sorts;
2553
- valueTotalPage = ((_d = response == null ? void 0 : response.page) == null ? void 0 : _d.total_page) || 1;
2551
+ valueTotalPage = ((_c2 = response == null ? void 0 : response.page) == null ? void 0 : _c2.total_page) || 1;
2554
2552
  if (run) {
2555
2553
  setWishlistData(valueWishlistData);
2556
- setWishlistSort(valueWishlistSort);
2557
2554
  setTotalPage(valueTotalPage);
2558
2555
  setIsLoading(false);
2559
2556
  setIsRefreshWidgetList(false);
@@ -2600,7 +2597,9 @@ const WidgetRoot = (props) => {
2600
2597
  responseGeneral = generalPreviewSettings || JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
2601
2598
  if (!response)
2602
2599
  return;
2600
+ const { sorts } = response == null ? void 0 : response.display;
2603
2601
  setDataSettings(response);
2602
+ setWishlistSort(sorts);
2604
2603
  if (responseGeneral)
2605
2604
  setGeneralDataSettings(responseGeneral);
2606
2605
  };
@@ -4218,8 +4217,8 @@ const VariantSelector = (props) => {
4218
4217
  /* @__PURE__ */ jsxRuntimeExports.jsx("select", { className: "variant-picker sledge__product-grid-card-variant-picker", children: variants == null ? void 0 : variants.map((variant) => {
4219
4218
  const { title, option1, option2, position, id: id2, admin_graphql_api_id, image_id, inventory_quantity, inventory_management, inventory_policy } = variant;
4220
4219
  let optionAttributes = {
4221
- "data-option-1": option1,
4222
- "data-option-2": option2,
4220
+ "data-option-1": stringToSlug(option1),
4221
+ "data-option-2": stringToSlug(option2),
4223
4222
  "data-inventory-quantity": inventory_quantity,
4224
4223
  "data-inventory-management": inventory_management,
4225
4224
  "data-inventory-policy": inventory_policy,
@@ -4266,7 +4265,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
4266
4265
  ] });
4267
4266
  };
4268
4267
  const ProductCard = React__default.memo((props) => {
4269
- var _a, _b, _c, _d, _e;
4268
+ var _a, _b, _c, _d, _e, _f, _g;
4270
4269
  const {
4271
4270
  item,
4272
4271
  handleAddToCart,
@@ -4490,7 +4489,10 @@ const ProductCard = React__default.memo((props) => {
4490
4489
  ...triggerPropAdditional,
4491
4490
  onAfterAddWishlist,
4492
4491
  onAfterRemoveWishlist,
4493
- wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id]
4492
+ wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id],
4493
+ ...objectPresent(previewSettings) && ((_e = (_d = previewSettings == null ? void 0 : previewSettings.settings) == null ? void 0 : _d.general) == null ? void 0 : _e.use_dummy_data) ? {
4494
+ previewSettings
4495
+ } : {}
4494
4496
  }
4495
4497
  ),
4496
4498
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-featured-image-element", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -4514,7 +4516,7 @@ const ProductCard = React__default.memo((props) => {
4514
4516
  }
4515
4517
  }
4516
4518
  ) }),
4517
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: (_e = (_d = product == null ? void 0 : product.images) == null ? void 0 : _d.map) == null ? void 0 : _e.call(_d, (image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
4519
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: (_g = (_f = product == null ? void 0 : product.images) == null ? void 0 : _f.map) == null ? void 0 : _g.call(_f, (image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
4518
4520
  "img",
4519
4521
  {
4520
4522
  decoding: "async",
@@ -4639,7 +4641,7 @@ const ProductCard = React__default.memo((props) => {
4639
4641
  return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: component }, id);
4640
4642
  });
4641
4643
  const ProductGrid = React__default.memo((props) => {
4642
- const { type, className = "", data, setting, sourceApp = null, useSlider = false, isFlyout = false, onAfterAddToCart, onAfterRenderProduct, currentColumnGrid } = props;
4644
+ const { type, className = "", data, setting, sourceApp = null, useSlider = false, isFlyout = false, onAfterAddToCart, onAfterRenderProduct, currentColumnGrid, previewSettings } = props;
4643
4645
  const { redirect_add_to_cart = true } = setting || {};
4644
4646
  const [clickedAddToCartId, setClickedAddToCartId] = React__default.useState(null);
4645
4647
  const [generalDataSettings, setGeneralDataSettings] = React__default.useState({});
@@ -4647,6 +4649,17 @@ const ProductGrid = React__default.memo((props) => {
4647
4649
  var _a;
4648
4650
  const { id, quantity } = data2;
4649
4651
  setClickedAddToCartId(id);
4652
+ if (objectPresent(previewSettings)) {
4653
+ setClickedAddToCartId(null);
4654
+ onAfterAddToCart && onAfterAddToCart("success");
4655
+ window.sledgeToastNotification({
4656
+ title: "Cart added",
4657
+ message: "Successfully added to wishlist",
4658
+ type: "success",
4659
+ icon: /* @__PURE__ */ jsxRuntimeExports.jsx(BagIcon, { width: 40, height: 40, color: "black" })
4660
+ });
4661
+ return;
4662
+ }
4650
4663
  let resShopifyAddToCart = await addToCart([
4651
4664
  {
4652
4665
  id,
@@ -7090,6 +7103,7 @@ const FilterItem = (props) => {
7090
7103
  filter,
7091
7104
  filterSettings,
7092
7105
  indexFilter,
7106
+ filterTitleStyle,
7093
7107
  deviceType,
7094
7108
  clickedOpenFilterHorizontalId,
7095
7109
  setClickedOpenFilterHorizontalId,
@@ -7127,6 +7141,7 @@ const FilterItem = (props) => {
7127
7141
  }
7128
7142
  },
7129
7143
  className: isHorizontalGroup ? "sledge-instant-search__result-filter-trigger-horizontal-group" : `${isLastIndex ? (allowedFilter == null ? void 0 : allowedFilter.length) % 2 ? "sledge-instant-search__result-filter-trigger-odd" : "sledge-instant-search__result-filter-trigger-even" : ""}`,
7144
+ style: filterTitleStyle,
7130
7145
  children: [
7131
7146
  label,
7132
7147
  /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "closed", animate: isOpenFilterHorizontal ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, className: "sort-trigger-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 20, height: 20, color: "#000000" }) })
@@ -7197,6 +7212,7 @@ const FilterHorizontal = (props) => {
7197
7212
  const {
7198
7213
  items = [],
7199
7214
  filterSettings = null,
7215
+ filterTitleStyle = {},
7200
7216
  deviceType = "desktop",
7201
7217
  clickedOpenFilterHorizontalId,
7202
7218
  setClickedOpenFilterHorizontalId,
@@ -7236,6 +7252,7 @@ const FilterHorizontal = (props) => {
7236
7252
  filter,
7237
7253
  filterSettings,
7238
7254
  indexFilter,
7255
+ filterTitleStyle,
7239
7256
  deviceType,
7240
7257
  clickedOpenFilterHorizontalId,
7241
7258
  setClickedOpenFilterHorizontalId,
@@ -10008,6 +10025,9 @@ const ResultProduct = React__default.memo((props) => {
10008
10025
  });
10009
10026
  }
10010
10027
  }, [isReplaceWidgetList, clickedTabIndexId]);
10028
+ useEffectOnChange(() => {
10029
+ setSummaryText(summaryTextGenerator(totalSearchResult));
10030
+ }, [previewSettings]);
10011
10031
  let dataClickedFacets = handleDataClickedFacets();
10012
10032
  let keepCounterFacets = [];
10013
10033
  allowedFilter == null ? void 0 : allowedFilter.map((filter) => {
@@ -10143,6 +10163,7 @@ const ResultProduct = React__default.memo((props) => {
10143
10163
  const defaultProps = {
10144
10164
  items: allowedFilter,
10145
10165
  filterSettings,
10166
+ filterTitleStyle: filter_title_style,
10146
10167
  clickedOpenFilterHorizontalId,
10147
10168
  setClickedOpenFilterHorizontalId,
10148
10169
  clickedOpenFilterHorizontalMobileId,