@sledge-app/react-instant-search 0.0.125 → 0.0.127

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.
@@ -3320,6 +3320,7 @@ const SearchResultWidget = (props) => {
3320
3320
  const [keyword, setKeyword] = React__default.useState(searchParams == null ? void 0 : searchParams.get(queryKeyword));
3321
3321
  const [clickedTabIndexId, setClickedTabIndexId] = React__default.useState(null);
3322
3322
  const [clickedTabIndexName, setClickedTabIndexName] = React__default.useState();
3323
+ const [clickedTabIndexType, setClickedTabIndexType] = React__default.useState();
3323
3324
  const [resultComponent, setResultComponent] = React__default.useState(/* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}));
3324
3325
  const [isLoadingSetting, setIsLoadingSetting] = React__default.useState(!propsData);
3325
3326
  const [allowedSorts, setAllowedSorts] = React__default.useState(((_c = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c.allowed_sorts) || []);
@@ -3336,9 +3337,11 @@ const SearchResultWidget = (props) => {
3336
3337
  const [initStatesFirstTime, setInitStatesFirstTime] = React__default.useState(true);
3337
3338
  const searchResultContainerRef = React__default.useRef(null);
3338
3339
  const previousState = usePrevious({ keyword });
3339
- const handleChangeTabIndex = (id, name, e) => {
3340
+ const handleChangeTabIndex = (params2) => {
3341
+ const { id, name, type } = params2;
3340
3342
  setClickedTabIndexId(id);
3341
3343
  setClickedTabIndexName(name);
3344
+ setClickedTabIndexType(type);
3342
3345
  setResultComponent(id.includes(indexProduct) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultCategory, {}));
3343
3346
  };
3344
3347
  const handleInitStates = async (data, type) => {
@@ -3459,6 +3462,7 @@ const SearchResultWidget = (props) => {
3459
3462
  if (Object.keys(getFirstIndex).length) {
3460
3463
  setClickedTabIndexId(getFirstIndex.index);
3461
3464
  setClickedTabIndexName(getFirstIndex.name);
3465
+ setClickedTabIndexType(getFirstIndex.type);
3462
3466
  }
3463
3467
  await handleInitStates(response, "default");
3464
3468
  if (layoutType === "default")
@@ -3741,12 +3745,24 @@ const SearchResultWidget = (props) => {
3741
3745
  ] });
3742
3746
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-container", ref: searchResultContainerRef, children: [
3743
3747
  isFirstLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${layoutType === "default" && (allowedTabs == null ? void 0 : allowedTabs.length) ? "sledge-instant-search__result-tab" : "sledge-instant-search__result-tab-no-index"}`, children: layoutType === "default" && (allowedTabs == null ? void 0 : allowedTabs.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__result-tab-list", children: allowedTabs.map((item) => {
3744
- const { name, index, total } = item;
3748
+ const { name, index, type, total } = item;
3745
3749
  let isActive = clickedTabIndexId === index;
3746
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { onClick: (e) => handleChangeTabIndex(index, name), className: `${isActive ? "sledge-instant-search__result-tab-list-item-active" : ""}`, children: [
3747
- name,
3748
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-tab-total", children: total || 0 })
3749
- ] }, index);
3750
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
3751
+ "li",
3752
+ {
3753
+ onClick: (e) => handleChangeTabIndex({
3754
+ id: index,
3755
+ name,
3756
+ type
3757
+ }),
3758
+ className: `${isActive ? "sledge-instant-search__result-tab-list-item-active" : ""}`,
3759
+ children: [
3760
+ name,
3761
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-tab-total", children: total || 0 })
3762
+ ]
3763
+ },
3764
+ index
3765
+ );
3750
3766
  }) }) : null }),
3751
3767
  isFirstLoading && (layoutType == null ? void 0 : layoutType.length) && !propsData ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3752
3768
  tabSkeleton,
@@ -3763,6 +3779,7 @@ const SearchResultWidget = (props) => {
3763
3779
  keyword,
3764
3780
  clickedTabIndexId,
3765
3781
  clickedTabIndexName,
3782
+ clickedTabIndexType,
3766
3783
  isLoadingSetting,
3767
3784
  allowedSorts,
3768
3785
  allowedFilters,
@@ -4479,11 +4496,11 @@ const ResultProduct = (props) => {
4479
4496
  ] });
4480
4497
  };
4481
4498
  const ResultCategory = (props) => {
4482
- var _a, _b, _c, _d;
4483
4499
  const {
4484
4500
  keyword,
4485
4501
  clickedTabIndexId,
4486
4502
  clickedTabIndexName,
4503
+ clickedTabIndexType,
4487
4504
  isJsVersion,
4488
4505
  collectionCardsComponent,
4489
4506
  pageCardsComponent,
@@ -4579,7 +4596,7 @@ const ResultCategory = (props) => {
4579
4596
  }
4580
4597
  ) });
4581
4598
  const summaryTextSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "lighten", rounded: "md" }) });
4582
- const skeletonLoadingComponent = ((_a = String(clickedTabIndexId)) == null ? void 0 : _a.includes("collection")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.CollectionGrid, { count: 6 }) : ((_b = String(clickedTabIndexId)) == null ? void 0 : _b.includes("page")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.PageGrid, { count: 6 }) : ((_c = String(clickedTabIndexId)) == null ? void 0 : _c.includes("blog")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.BlogGrid, { count: 12 }) : ((_d = String(clickedTabIndexId)) == null ? void 0 : _d.includes("article")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ArticleGrid, { count: 12 }) : null;
4599
+ const skeletonLoadingComponent = clickedTabIndexType === "collection" ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.CollectionGrid, { count: 6 }) : clickedTabIndexType === "page" ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.PageGrid, { count: 6 }) : clickedTabIndexType === "blog" ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.BlogGrid, { count: 12 }) : clickedTabIndexType === "article" ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ArticleGrid, { count: 12 }) : null;
4583
4600
  const ProvideElementFirstLoading = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-category-wrapper", children: [
4584
4601
  searchKeywordComponent,
4585
4602
  summaryTextSkeleton,
@@ -4590,10 +4607,7 @@ const ResultCategory = (props) => {
4590
4607
  summaryTextSkeleton,
4591
4608
  skeletonLoadingComponent
4592
4609
  ] });
4593
- const ProvideElement = (elementProps) => {
4594
- var _a2, _b2, _c2, _d2;
4595
- return ((_a2 = String(clickedTabIndexId)) == null ? void 0 : _a2.includes("collection")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(CollectionGrid, { cards: collectionCardsComponent, onAfterRenderCollection, ...elementProps }) : ((_b2 = String(clickedTabIndexId)) == null ? void 0 : _b2.includes("page")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(PageGrid, { cards: pageCardsComponent, onAfterRenderPage, ...elementProps }) : ((_c2 = String(clickedTabIndexId)) == null ? void 0 : _c2.includes("blog")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlogGrid, { cards: blogCardsComponent, onAfterRenderBlog, ...elementProps }) : ((_d2 = String(clickedTabIndexId)) == null ? void 0 : _d2.includes("article")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ArticleGrid, { cards: articleCardsComponent, onAfterRenderArticle, ...elementProps }) : null;
4596
- };
4610
+ const ProvideElement = (elementProps) => clickedTabIndexType === "collection" ? /* @__PURE__ */ jsxRuntimeExports.jsx(CollectionGrid, { cards: collectionCardsComponent, onAfterRenderCollection, ...elementProps }) : clickedTabIndexType === "page" ? /* @__PURE__ */ jsxRuntimeExports.jsx(PageGrid, { cards: pageCardsComponent, onAfterRenderPage, ...elementProps }) : clickedTabIndexType === "blog" ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlogGrid, { cards: blogCardsComponent, onAfterRenderBlog, ...elementProps }) : clickedTabIndexType === "article" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ArticleGrid, { cards: articleCardsComponent, onAfterRenderArticle, ...elementProps }) : null;
4597
4611
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", children: isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(ProvideElementFirstLoading, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-category-wrapper", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(ProvideElementLoading, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4598
4612
  searchKeywordComponent,
4599
4613
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary", children: summaryText }),