@sledge-app/react-instant-search 2.0.6 → 2.0.7

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.
@@ -4272,7 +4272,8 @@ const ProductCard = React__default.memo((props) => {
4272
4272
  dataWishlists,
4273
4273
  generalDataSettings,
4274
4274
  previewSettings,
4275
- isFlyout
4275
+ isFlyout,
4276
+ additionalCardProps
4276
4277
  } = props;
4277
4278
  const {
4278
4279
  show_vendor = true,
@@ -4317,6 +4318,7 @@ const ProductCard = React__default.memo((props) => {
4317
4318
  let isOutOfStock = showOptionOutOfStock ? !Boolean(selectedVariantStock > 0 || selectedVariantInventoryManagement === null || selectedVariantInventoryPolicy === "continue") : false;
4318
4319
  let isOnSale = parseFloat(String(compare_at_price)) ? parseFloat(String(compare_at_price)) > parseFloat(String(price)) : false;
4319
4320
  const { money_format } = generalDataSettings || {};
4321
+ const { forLoopIndex, forLoopIndexWithPage } = additionalCardProps || {};
4320
4322
  let component = null;
4321
4323
  if (CardsComponent) {
4322
4324
  const CardsProps = {
@@ -4342,11 +4344,13 @@ const ProductCard = React__default.memo((props) => {
4342
4344
  },
4343
4345
  showPopupComponent,
4344
4346
  setShowPopupComponent,
4345
- sourceApp
4347
+ sourceApp,
4348
+ forLoopIndex,
4349
+ forLoopIndexWithPage
4346
4350
  };
4347
- component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: CardsComponent({ ...CardsProps }) } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CardsComponent, { ...CardsProps }) });
4351
+ component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-for-loop-index": forLoopIndex, "data-for-loop-index-with-page": forLoopIndexWithPage, dangerouslySetInnerHTML: { __html: CardsComponent({ ...CardsProps }) } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CardsComponent, { ...CardsProps }) });
4348
4352
  } else {
4349
- component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFlyout ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-flyout", children: [
4353
+ component = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFlyout ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-flyout", "data-for-loop-index": forLoopIndex, "data-for-loop-index-with-page": forLoopIndexWithPage, children: [
4350
4354
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-flyout-wishlist-trigger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4351
4355
  Trigger,
4352
4356
  {
@@ -4437,7 +4441,7 @@ const ProductCard = React__default.memo((props) => {
4437
4441
  )
4438
4442
  ] }) : null
4439
4443
  ] })
4440
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", children: [
4444
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card", "data-for-loop-index": forLoopIndex, "data-for-loop-index-with-page": forLoopIndexWithPage, children: [
4441
4445
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-content", children: [
4442
4446
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__product-grid-card-image", children: [
4443
4447
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -4629,7 +4633,21 @@ const ProductCard = React__default.memo((props) => {
4629
4633
  return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: component }, id);
4630
4634
  });
4631
4635
  const ProductGrid = React__default.memo((props) => {
4632
- const { type, className = "", data, setting, sourceApp = null, useSlider = false, isFlyout = false, onAfterAddToCart, onAfterRenderProduct, currentColumnGrid, previewSettings } = props;
4636
+ const {
4637
+ type,
4638
+ className = "",
4639
+ data,
4640
+ setting,
4641
+ sourceApp = null,
4642
+ useSlider = false,
4643
+ isFlyout = false,
4644
+ onAfterAddToCart,
4645
+ onAfterRenderProduct,
4646
+ currentColumnGrid,
4647
+ previewSettings,
4648
+ hitsPerPage,
4649
+ currentPage
4650
+ } = props;
4633
4651
  const { redirect_add_to_cart = true } = setting || {};
4634
4652
  const [clickedAddToCartId, setClickedAddToCartId] = React__default.useState(null);
4635
4653
  const [generalDataSettings, setGeneralDataSettings] = React__default.useState({});
@@ -4731,6 +4749,10 @@ const ProductGrid = React__default.memo((props) => {
4731
4749
  handleAddToCart,
4732
4750
  clickedAddToCartId,
4733
4751
  generalDataSettings,
4752
+ additionalCardProps: {
4753
+ forLoopIndex: index,
4754
+ forLoopIndexWithPage: Number(currentPage) && Number(hitsPerPage) ? index + (Number(currentPage) - 1) * Number(hitsPerPage) : index
4755
+ },
4734
4756
  ...props
4735
4757
  },
4736
4758
  `sledge-product-card_${index}`
@@ -9477,7 +9499,7 @@ const SearchResultWidget = (props) => {
9477
9499
  ] });
9478
9500
  };
9479
9501
  const ResultProduct = React__default.memo((props) => {
9480
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
9502
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
9481
9503
  const {
9482
9504
  layoutType,
9483
9505
  keyword,
@@ -9573,10 +9595,11 @@ const ResultProduct = React__default.memo((props) => {
9573
9595
  );
9574
9596
  const [triggerClickedFacets, setTriggerClickedFacets] = React__default.useState(false);
9575
9597
  const [searchResult, setSearchResult] = React__default.useState(((_d = (_c = (_b = propsData == null ? void 0 : propsData.result) == null ? void 0 : _b.results) == null ? void 0 : _c[0]) == null ? void 0 : _d.hits) || []);
9598
+ const [hitsPerPageResult, setHitsPerPageResult] = React__default.useState(((_g = (_f = (_e = propsData == null ? void 0 : propsData.result) == null ? void 0 : _e.results) == null ? void 0 : _f[0]) == null ? void 0 : _g.hitsPerPage) || 0);
9576
9599
  const [searchProcessingTimeMs, setSearchProcessingTimeMs] = React__default.useState(0);
9577
9600
  const [currentPage, setCurrentPage] = React__default.useState(Number(searchParams == null ? void 0 : searchParams.get(queryPage)) && !isLoadMore ? Number(searchParams == null ? void 0 : searchParams.get(queryPage)) : 1);
9578
9601
  const [totalPage, setTotalPage] = React__default.useState(0);
9579
- const [totalSearchResult, setTotalSearchResult] = React__default.useState(((_g = (_f = (_e = propsData == null ? void 0 : propsData.result) == null ? void 0 : _e.results) == null ? void 0 : _f[0]) == null ? void 0 : _g.totalHits) || 0);
9602
+ const [totalSearchResult, setTotalSearchResult] = React__default.useState(((_j = (_i = (_h = propsData == null ? void 0 : propsData.result) == null ? void 0 : _h.results) == null ? void 0 : _i[0]) == null ? void 0 : _j.totalHits) || 0);
9580
9603
  const [handleSearchResultFirstTime, setHandleSearchResultFirstTime] = React__default.useState(true);
9581
9604
  const [searchFacetDistribution, setSearchFacetDistribution] = React__default.useState({});
9582
9605
  const [isLoadingButtonLoadMore, setIsLoadingButtonLoadMore] = React__default.useState(false);
@@ -9628,13 +9651,13 @@ const ResultProduct = React__default.memo((props) => {
9628
9651
  };
9629
9652
  const [summaryText, setSummaryText] = React__default.useState(propsData ? summaryTextGenerator(totalSearchResult) : null);
9630
9653
  const previousState = usePrevious({ clickedLimitId, clickedSortId, clickedFacets, clickedTabIndexId });
9631
- const { color: filter_title_color, font_size: filter_title_font_size, font_weight: filter_title_font_weight, text_transform: filter_title_text_transform } = ((_h = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _h.title) || {};
9654
+ const { color: filter_title_color, font_size: filter_title_font_size, font_weight: filter_title_font_weight, text_transform: filter_title_text_transform } = ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.title) || {};
9632
9655
  const {
9633
9656
  color: filter_option_color,
9634
9657
  font_size: filter_option_font_size,
9635
9658
  font_weight: filter_option_font_weight,
9636
9659
  text_transform: filter_option_text_transform
9637
- } = ((_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.option) || {};
9660
+ } = ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.option) || {};
9638
9661
  const {
9639
9662
  text_color: filter_button_text_color,
9640
9663
  border_color: filter_button_border_color,
@@ -9647,7 +9670,7 @@ const ResultProduct = React__default.memo((props) => {
9647
9670
  font_size: filter_button_font_size,
9648
9671
  font_weight: filter_button_font_weight,
9649
9672
  text_transform: filter_button_text_transform
9650
- } = ((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.button) || {};
9673
+ } = ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.button) || {};
9651
9674
  const filter_title_style = {
9652
9675
  ...filter_title_color && { color: filter_title_color },
9653
9676
  ...filter_title_font_size && { fontSize: filter_title_font_size },
@@ -9834,7 +9857,7 @@ const ResultProduct = React__default.memo((props) => {
9834
9857
  const result = layoutType === "default" && isFirstTimeOrOnSearch ? (_b2 = resultData == null ? void 0 : resultData.find) == null ? void 0 : _b2.call(resultData, ({ indexUid }) => indexUid.includes(index_product)) : resultData;
9835
9858
  if (!result)
9836
9859
  return;
9837
- const { hits, processingTimeMs, totalHits, totalPages, facetDistribution } = result;
9860
+ const { hits, hitsPerPage, processingTimeMs, totalHits, totalPages, facetDistribution } = result;
9838
9861
  const updateTabs = () => {
9839
9862
  const valueAllowedTabs = objectPresent(previewSettings) ? tabs : allowedTabs;
9840
9863
  if (valueAllowedTabs == null ? void 0 : valueAllowedTabs.length) {
@@ -9891,6 +9914,7 @@ const ResultProduct = React__default.memo((props) => {
9891
9914
  setIsLoadingButtonLoadMore(false);
9892
9915
  setIsReplaceWidgetList == null ? void 0 : setIsReplaceWidgetList(false);
9893
9916
  setSearchResult(!(hits == null ? void 0 : hits.length) ? [] : (prevState) => (searchResult == null ? void 0 : searchResult.length) && isLoadMore2 ? [...prevState, ...hits] : hits);
9917
+ setHitsPerPageResult(hitsPerPage);
9894
9918
  setSearchProcessingTimeMs(processingTimeMs || 0);
9895
9919
  setTotalPage(totalPages);
9896
9920
  setTotalSearchResult(totalHits || 0);
@@ -10201,7 +10225,7 @@ const ResultProduct = React__default.memo((props) => {
10201
10225
  const paginationComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(
10202
10226
  PaginationOrLoadMore,
10203
10227
  {
10204
- type: (_k = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _k.pagination_type,
10228
+ type: (_n = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _n.pagination_type,
10205
10229
  isLoadMore,
10206
10230
  isLoadingButtonLoadMore,
10207
10231
  handleLoadMore: () => {
@@ -10210,7 +10234,7 @@ const ResultProduct = React__default.memo((props) => {
10210
10234
  setIsReplaceWidgetList == null ? void 0 : setIsReplaceWidgetList(true);
10211
10235
  },
10212
10236
  buttonLoadMoreText: isLoadingButtonLoadMore ? button_loading || "Loading..." : button_load_more || "Load More",
10213
- isInfiniteScroll: ((_l = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _l.pagination_type) === "infinite_scroll",
10237
+ isInfiniteScroll: ((_o = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _o.pagination_type) === "infinite_scroll",
10214
10238
  currentPage,
10215
10239
  totalPage,
10216
10240
  totalResult: totalSearchResult,
@@ -10219,7 +10243,7 @@ const ResultProduct = React__default.memo((props) => {
10219
10243
  handlePageChange
10220
10244
  }
10221
10245
  );
10222
- const summaryTextComponent = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-item", children: ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.show_total_products) ? summaryText : null });
10246
+ const summaryTextComponent = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-item", children: ((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.show_total_products) ? summaryText : null });
10223
10247
  const searchFieldComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Search, { placeholder: language_search_form_placeholder == null ? void 0 : language_search_form_placeholder.product, value: keyword, handleChangeSearch: handleChangeKeyword });
10224
10248
  /* @__PURE__ */ jsxRuntimeExports.jsx(Search, { placeholder: language_search_form_placeholder == null ? void 0 : language_search_form_placeholder.product, value: keyword, handleChangeSearch: handleChangeKeyword });
10225
10249
  const sortComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -10232,7 +10256,7 @@ const ResultProduct = React__default.memo((props) => {
10232
10256
  overridePlaceholderOnMobile: !mobileShowSelectedSort ? mobile_sort_placeholder || "Sort" : null
10233
10257
  }
10234
10258
  );
10235
- const limitComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Limit, { label: language_limit, options: (_n = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _n.allowed_limit, clickedOption: clickedLimitId, handleChangeOption: handleChangeLimit });
10259
+ const limitComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Limit, { label: language_limit, options: (_q = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _q.allowed_limit, clickedOption: clickedLimitId, handleChangeOption: handleChangeLimit });
10236
10260
  const productGridComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(
10237
10261
  ProductGrid,
10238
10262
  {
@@ -10246,9 +10270,9 @@ const ResultProduct = React__default.memo((props) => {
10246
10270
  };
10247
10271
  }),
10248
10272
  setting: {
10249
- show_vendor: (_o = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _o.show_vendor,
10250
- show_sku: (_p = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _p.show_sku,
10251
- show_price: (_q = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _q.show_price,
10273
+ show_vendor: (_r = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _r.show_vendor,
10274
+ show_sku: (_s = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _s.show_sku,
10275
+ show_price: (_t = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _t.show_price,
10252
10276
  language_button_add_to_cart: language_add_to_cart,
10253
10277
  language_button_out_of_stock: languageSettings && languageSettings["out of stock"] ? languageSettings["out of stock"] : ""
10254
10278
  },
@@ -10262,7 +10286,9 @@ const ResultProduct = React__default.memo((props) => {
10262
10286
  dataWishlists: propsData == null ? void 0 : propsData.wishlists,
10263
10287
  dataReviews: propsData == null ? void 0 : propsData.reviews,
10264
10288
  currentColumnGrid,
10265
- previewSettings
10289
+ previewSettings,
10290
+ hitsPerPage: hitsPerPageResult,
10291
+ currentPage
10266
10292
  }
10267
10293
  );
10268
10294
  const resultEmptyComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(ResultEmpty, { ...props });