@sledge-app/react-instant-search 0.0.117 → 0.0.118
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.
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts.map +1 -1
- package/dist/sledge-react-instant-search.cjs +1 -1
- package/dist/sledge-react-instant-search.cjs.map +1 -1
- package/dist/sledge-react-instant-search.js +18 -21
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +2 -3
|
@@ -1,7 +1,6 @@
|
|
|
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";
|
|
5
4
|
import "react-dom";
|
|
6
5
|
const ProductFilterWidget = (props) => {
|
|
7
6
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(SearchResultWidget, { layoutType: "product-filter", ...props });
|
|
@@ -3242,7 +3241,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
3242
3241
|
] }) });
|
|
3243
3242
|
};
|
|
3244
3243
|
const SearchResultWidget = (props) => {
|
|
3245
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3244
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
3246
3245
|
const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
|
|
3247
3246
|
const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
|
|
3248
3247
|
const {
|
|
@@ -3283,9 +3282,7 @@ const SearchResultWidget = (props) => {
|
|
|
3283
3282
|
articleCardsComponent = articleCard;
|
|
3284
3283
|
}
|
|
3285
3284
|
});
|
|
3286
|
-
const
|
|
3287
|
-
const searchParams = new URLSearchParams(search2);
|
|
3288
|
-
const keywordParam = searchParams == null ? void 0 : searchParams.get(queryKeyword);
|
|
3285
|
+
const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
|
|
3289
3286
|
const [settings] = React__default.useState(typeof localStorage !== "undefined" ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}") : {});
|
|
3290
3287
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
|
|
3291
3288
|
const [isLoading, setIsLoading] = React__default.useState(!propsData);
|
|
@@ -3294,17 +3291,17 @@ const SearchResultWidget = (props) => {
|
|
|
3294
3291
|
const [clickedTabIndexName, setClickedTabIndexName] = React__default.useState();
|
|
3295
3292
|
const [resultComponent, setResultComponent] = React__default.useState(/* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}));
|
|
3296
3293
|
const [isLoadingSetting, setIsLoadingSetting] = React__default.useState(!propsData);
|
|
3297
|
-
const [allowedSorts, setAllowedSorts] = React__default.useState(((
|
|
3298
|
-
const [allowedFilters, setAllowedFilters] = React__default.useState(((
|
|
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) || []);
|
|
3299
3296
|
const [allowedTabs, setAllowedTabs] = React__default.useState([]);
|
|
3300
3297
|
const [facets, setFacets] = React__default.useState([]);
|
|
3301
|
-
const [indexProduct, setIndexProduct] = React__default.useState(((
|
|
3298
|
+
const [indexProduct, setIndexProduct] = React__default.useState(((_d = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _d.index_product) || "");
|
|
3302
3299
|
const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
|
|
3303
|
-
const [hiddenTags, setHiddenTags] = React__default.useState(((
|
|
3304
|
-
const [displaySettings, setDisplaySettings] = React__default.useState(((
|
|
3305
|
-
const [colorSwatches, setColorSwatches] = React__default.useState(((
|
|
3306
|
-
const [defaultSort, setDefaultSort] = React__default.useState(((
|
|
3307
|
-
const [showOutOfStock, setShowOutOfStock] = 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);
|
|
3308
3305
|
const [initStatesFirstTime, setInitStatesFirstTime] = React__default.useState(true);
|
|
3309
3306
|
const searchResultContainerRef = React__default.useRef(null);
|
|
3310
3307
|
const previousState = usePrevious({ keyword });
|
|
@@ -3439,10 +3436,10 @@ const SearchResultWidget = (props) => {
|
|
|
3439
3436
|
React__default.useEffect(() => {
|
|
3440
3437
|
if (!isRenderAppInstantSearch)
|
|
3441
3438
|
return;
|
|
3442
|
-
|
|
3443
|
-
setKeyword(
|
|
3439
|
+
const searchParams2 = new URLSearchParams(document.location.search);
|
|
3440
|
+
setKeyword((searchParams2 == null ? void 0 : searchParams2.get(queryKeyword)) || "");
|
|
3444
3441
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
|
|
3445
|
-
}, [isRenderAppInstantSearch
|
|
3442
|
+
}, [isRenderAppInstantSearch]);
|
|
3446
3443
|
React__default.useEffect(() => {
|
|
3447
3444
|
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword) && layoutType === "default") {
|
|
3448
3445
|
const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
@@ -3454,8 +3451,8 @@ const SearchResultWidget = (props) => {
|
|
|
3454
3451
|
}
|
|
3455
3452
|
}, [keyword]);
|
|
3456
3453
|
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;
|
|
3457
|
-
const filterHorizontalSkeleton = ((
|
|
3458
|
-
const filterVerticalSkeleton = ((
|
|
3454
|
+
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;
|
|
3455
|
+
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: [
|
|
3459
3456
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3460
3457
|
"div",
|
|
3461
3458
|
{
|
|
@@ -3671,7 +3668,7 @@ const SearchResultWidget = (props) => {
|
|
|
3671
3668
|
)
|
|
3672
3669
|
] }) : null;
|
|
3673
3670
|
const productGridSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
3674
|
-
((
|
|
3671
|
+
((_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(
|
|
3675
3672
|
SkeletonLoading.Item,
|
|
3676
3673
|
{
|
|
3677
3674
|
width: "117px",
|
|
@@ -3686,7 +3683,7 @@ const SearchResultWidget = (props) => {
|
|
|
3686
3683
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 12, type: "large" })
|
|
3687
3684
|
] });
|
|
3688
3685
|
const searchAndSelectOptionSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
3689
|
-
((
|
|
3686
|
+
((_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,
|
|
3690
3687
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-keyword-form", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3691
3688
|
SkeletonLoading.Item,
|
|
3692
3689
|
{
|
|
@@ -3717,7 +3714,7 @@ const SearchResultWidget = (props) => {
|
|
|
3717
3714
|
tabSkeleton,
|
|
3718
3715
|
filterHorizontalSkeleton,
|
|
3719
3716
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-wrapper sledge-instant-search__result-wrapper-skeleton", children: [
|
|
3720
|
-
((
|
|
3717
|
+
((_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,
|
|
3721
3718
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
|
|
3722
3719
|
searchAndSelectOptionSkeleton,
|
|
3723
3720
|
productGridSkeleton
|