@sledge-app/react-instant-search 0.0.116 → 0.0.117

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,6 +1,7 @@
1
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 client, F as $a093c7e1ec25a057$export$2881499e37b75b9a, G as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, H as $a093c7e1ec25a057$export$41fb9f06171c75f4, I as $a093c7e1ec25a057$export$602eac185826482c, J as $a093c7e1ec25a057$export$7c6e2c02157bb7d2, K as $a093c7e1ec25a057$export$21b07c8f274aebd5, L as $57acba87d6e25586$export$be92b6f5f03c0fe9, M as $57acba87d6e25586$export$d5c6c08dc2d3ca7, N as $57acba87d6e25586$export$9a4e88b92edfce6b, O as $57acba87d6e25586$export$6521433ed15a34db, 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-efe38901.js";
2
2
  import React__default, { createElement } from "react";
3
3
  import { SledgeContext } from "@sledge-app/core";
4
+ import { useLocation } from "react-router-dom";
4
5
  import "react-dom";
5
6
  const ProductFilterWidget = (props) => {
6
7
  return /* @__PURE__ */ jsxRuntimeExports.jsx(SearchResultWidget, { layoutType: "product-filter", ...props });
@@ -3241,7 +3242,7 @@ const SearchIconWidgetPopup = () => {
3241
3242
  ] }) });
3242
3243
  };
3243
3244
  const SearchResultWidget = (props) => {
3244
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
3245
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3245
3246
  const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
3246
3247
  const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
3247
3248
  const {
@@ -3282,7 +3283,9 @@ const SearchResultWidget = (props) => {
3282
3283
  articleCardsComponent = articleCard;
3283
3284
  }
3284
3285
  });
3285
- const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
3286
+ const { search: search2 } = useLocation();
3287
+ const searchParams = new URLSearchParams(search2);
3288
+ const keywordParam = searchParams == null ? void 0 : searchParams.get(queryKeyword);
3286
3289
  const [settings] = React__default.useState(typeof localStorage !== "undefined" ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}") : {});
3287
3290
  const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
3288
3291
  const [isLoading, setIsLoading] = React__default.useState(!propsData);
@@ -3291,17 +3294,17 @@ const SearchResultWidget = (props) => {
3291
3294
  const [clickedTabIndexName, setClickedTabIndexName] = React__default.useState();
3292
3295
  const [resultComponent, setResultComponent] = React__default.useState(/* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}));
3293
3296
  const [isLoadingSetting, setIsLoadingSetting] = React__default.useState(!propsData);
3294
- const [allowedSorts, setAllowedSorts] = React__default.useState(((_b = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _b.allowed_sorts) || []);
3295
- const [allowedFilters, setAllowedFilters] = React__default.useState(((_c = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c.filters) || []);
3297
+ const [allowedSorts, setAllowedSorts] = React__default.useState(((_a = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _a.allowed_sorts) || []);
3298
+ const [allowedFilters, setAllowedFilters] = React__default.useState(((_b = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _b.filters) || []);
3296
3299
  const [allowedTabs, setAllowedTabs] = React__default.useState([]);
3297
3300
  const [facets, setFacets] = React__default.useState([]);
3298
- const [indexProduct, setIndexProduct] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.index_product) || "");
3301
+ const [indexProduct, setIndexProduct] = React__default.useState(((_c = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _c.index_product) || "");
3299
3302
  const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
3300
- const [hiddenTags, setHiddenTags] = React__default.useState(((_e = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _e.hidden_tags) || []);
3301
- const [displaySettings, setDisplaySettings] = React__default.useState(((_f = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _f.display) || {});
3302
- const [colorSwatches, setColorSwatches] = React__default.useState(((_g = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _g.colors) || []);
3303
- const [defaultSort, setDefaultSort] = React__default.useState(((_h = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _h.default_sort) || "");
3304
- const [showOutOfStock, setShowOutOfStock] = React__default.useState((_i = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _i.show_out_of_stock);
3303
+ const [hiddenTags, setHiddenTags] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.hidden_tags) || []);
3304
+ const [displaySettings, setDisplaySettings] = React__default.useState(((_e = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _e.display) || {});
3305
+ const [colorSwatches, setColorSwatches] = React__default.useState(((_f = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _f.colors) || []);
3306
+ const [defaultSort, setDefaultSort] = React__default.useState(((_g = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _g.default_sort) || "");
3307
+ const [showOutOfStock, setShowOutOfStock] = React__default.useState((_h = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _h.show_out_of_stock);
3305
3308
  const [initStatesFirstTime, setInitStatesFirstTime] = React__default.useState(true);
3306
3309
  const searchResultContainerRef = React__default.useRef(null);
3307
3310
  const previousState = usePrevious({ keyword });
@@ -3436,11 +3439,10 @@ const SearchResultWidget = (props) => {
3436
3439
  React__default.useEffect(() => {
3437
3440
  if (!isRenderAppInstantSearch)
3438
3441
  return;
3439
- console.log("isRenderAppInstantSearch");
3440
- const searchParams2 = new URLSearchParams(document.location.search);
3441
- setKeyword((searchParams2 == null ? void 0 : searchParams2.get(queryKeyword)) || "");
3442
+ console.log("isRenderAppInstantSearch", searchParams, keywordParam);
3443
+ setKeyword(keywordParam || "");
3442
3444
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
3443
- }, [isRenderAppInstantSearch]);
3445
+ }, [isRenderAppInstantSearch, keywordParam]);
3444
3446
  React__default.useEffect(() => {
3445
3447
  if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword) && layoutType === "default") {
3446
3448
  const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
@@ -3452,8 +3454,8 @@ const SearchResultWidget = (props) => {
3452
3454
  }
3453
3455
  }, [keyword]);
3454
3456
  const tabSkeleton = layoutType === "default" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-tab-list sledge-instant-search__result-tab-list-skeleton", children: [1, 2, 3, 4, 5].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "122px", height: "28px", rounded: "md", color: "lighten" }, index)) }) : null;
3455
- const filterHorizontalSkeleton = ((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.enable_on_search) && ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-skeleton", children: [1, 2, 3, 4, 5, 6, 7].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "106px", height: "42px", rounded: "md", color: "lighten" }, index)) }) : null;
3456
- const filterVerticalSkeleton = ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.enable_on_search) && ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3457
+ const filterHorizontalSkeleton = ((_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.enable_on_search) && ((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-skeleton", children: [1, 2, 3, 4, 5, 6, 7].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "106px", height: "42px", rounded: "md", color: "lighten" }, index)) }) : null;
3458
+ const filterVerticalSkeleton = ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.enable_on_search) && ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3457
3459
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
3458
3460
  "div",
3459
3461
  {
@@ -3669,7 +3671,7 @@ const SearchResultWidget = (props) => {
3669
3671
  )
3670
3672
  ] }) : null;
3671
3673
  const productGridSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3672
- ((_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.show_total_products) && ((_o = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _o.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
3674
+ ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.show_total_products) && ((_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
3673
3675
  SkeletonLoading.Item,
3674
3676
  {
3675
3677
  width: "117px",
@@ -3684,7 +3686,7 @@ const SearchResultWidget = (props) => {
3684
3686
  /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 12, type: "large" })
3685
3687
  ] });
3686
3688
  const searchAndSelectOptionSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
3687
- ((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.show_total_products) && ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "lighten", rounded: "md" }) }) : null,
3689
+ ((_o = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _o.show_total_products) && ((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.layout) === "horizontal" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "lighten", rounded: "md" }) }) : null,
3688
3690
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-keyword-form", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3689
3691
  SkeletonLoading.Item,
3690
3692
  {
@@ -3715,7 +3717,7 @@ const SearchResultWidget = (props) => {
3715
3717
  tabSkeleton,
3716
3718
  filterHorizontalSkeleton,
3717
3719
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-wrapper sledge-instant-search__result-wrapper-skeleton", children: [
3718
- ((_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.enable_on_search) && ((_s = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _s.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : null,
3720
+ ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.enable_on_search) && ((_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter", children: filterVerticalSkeleton }) : null,
3719
3721
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
3720
3722
  searchAndSelectOptionSkeleton,
3721
3723
  productGridSkeleton