@sledge-app/react-instant-search 1.0.125 → 1.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.
- 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 +38 -10
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -6532,7 +6532,7 @@ const SearchResultWidget = (props) => {
|
|
|
6532
6532
|
data: propsData,
|
|
6533
6533
|
sledgeSettings
|
|
6534
6534
|
} = props;
|
|
6535
|
-
|
|
6535
|
+
useIsFirstRender();
|
|
6536
6536
|
const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
|
|
6537
6537
|
const querySortBy = (query == null ? void 0 : query.sortBy) ? query.sortBy : DEFAULT_QUERY_PARAM.SORT_BY;
|
|
6538
6538
|
const { collectionId } = params || {};
|
|
@@ -6873,12 +6873,30 @@ const SearchResultWidget = (props) => {
|
|
|
6873
6873
|
setKeyword(value);
|
|
6874
6874
|
window.history.pushState(null, "", `${document.location.pathname}?${searchParams2.toString()}`);
|
|
6875
6875
|
};
|
|
6876
|
+
const initStates = () => {
|
|
6877
|
+
const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
|
|
6878
|
+
if (INSTANT_SEARCH_SETTING)
|
|
6879
|
+
handleInitStates(INSTANT_SEARCH_SETTING);
|
|
6880
|
+
};
|
|
6876
6881
|
useEffectCallback(() => {
|
|
6882
|
+
var _a2, _b2, _c2, _d2;
|
|
6877
6883
|
if (!isRenderAppInstantSearch)
|
|
6878
6884
|
return;
|
|
6879
|
-
|
|
6880
|
-
setKeyword((searchParams2 == null ? void 0 : searchParams2.get(queryKeyword)) || "");
|
|
6885
|
+
initStates();
|
|
6881
6886
|
handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
|
|
6887
|
+
if (typeof window !== "undefined") {
|
|
6888
|
+
if (layoutType === "default") {
|
|
6889
|
+
if ((_b2 = (_a2 = window == null ? void 0 : window.sledge) == null ? void 0 : _a2.instantSearch) == null ? void 0 : _b2.searchResult)
|
|
6890
|
+
window.sledge.instantSearch.searchResult.search = (keyword2 = "") => {
|
|
6891
|
+
handleChangeKeyword == null ? void 0 : handleChangeKeyword(keyword2);
|
|
6892
|
+
};
|
|
6893
|
+
} else {
|
|
6894
|
+
if ((_d2 = (_c2 = window == null ? void 0 : window.sledge) == null ? void 0 : _c2.instantSearch) == null ? void 0 : _d2.productFilter)
|
|
6895
|
+
window.sledge.instantSearch.productFilter.search = (keyword2 = "") => {
|
|
6896
|
+
handleChangeKeyword == null ? void 0 : handleChangeKeyword(keyword2);
|
|
6897
|
+
};
|
|
6898
|
+
}
|
|
6899
|
+
}
|
|
6882
6900
|
}, [isRenderAppInstantSearch]);
|
|
6883
6901
|
useEffectCallback(() => {
|
|
6884
6902
|
if (!valueRenderInstantSearchResult)
|
|
@@ -6887,13 +6905,9 @@ const SearchResultWidget = (props) => {
|
|
|
6887
6905
|
triggerRenderInstantSearchResult("");
|
|
6888
6906
|
setKeyword(valueRenderInstantSearchResult);
|
|
6889
6907
|
}, [valueRenderInstantSearchResult]);
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
|
|
6894
|
-
if (INSTANT_SEARCH_SETTING)
|
|
6895
|
-
handleInitStates(INSTANT_SEARCH_SETTING);
|
|
6896
|
-
}, [debouncedKeyword, isFirstRender, isLoadingSetting]);
|
|
6908
|
+
useEffectOnChange(() => {
|
|
6909
|
+
initStates();
|
|
6910
|
+
}, [debouncedKeyword]);
|
|
6897
6911
|
const filterHorizontalSkeletonComponent = /* @__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)) });
|
|
6898
6912
|
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;
|
|
6899
6913
|
const filterHorizontalSkeleton = ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.enable_on_search) && ((_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.layout) === "horizontal" && !hideFilterWhenOneValue ? filterHorizontalSkeletonComponent : null;
|
|
@@ -7660,6 +7674,20 @@ const ResultProduct = (props) => {
|
|
|
7660
7674
|
setIsReplaceWidgetList == null ? void 0 : setIsReplaceWidgetList(true);
|
|
7661
7675
|
};
|
|
7662
7676
|
React__default.useEffect(() => {
|
|
7677
|
+
var _a2, _b2, _c2, _d2;
|
|
7678
|
+
if (typeof window !== "undefined") {
|
|
7679
|
+
if (layoutType === "default") {
|
|
7680
|
+
if ((_b2 = (_a2 = window == null ? void 0 : window.sledge) == null ? void 0 : _a2.instantSearch) == null ? void 0 : _b2.searchResult)
|
|
7681
|
+
window.sledge.instantSearch.searchResult.filter = () => {
|
|
7682
|
+
setTriggerClickedFacets(!triggerClickedFacets);
|
|
7683
|
+
};
|
|
7684
|
+
} else {
|
|
7685
|
+
if ((_d2 = (_c2 = window == null ? void 0 : window.sledge) == null ? void 0 : _c2.instantSearch) == null ? void 0 : _d2.productFilter)
|
|
7686
|
+
window.sledge.instantSearch.productFilter.filter = () => {
|
|
7687
|
+
setTriggerClickedFacets(!triggerClickedFacets);
|
|
7688
|
+
};
|
|
7689
|
+
}
|
|
7690
|
+
}
|
|
7663
7691
|
let isKeywordChanged = Boolean(parentPreviousState && parentPreviousState.keyword !== keyword);
|
|
7664
7692
|
let isReplaceData = Boolean(
|
|
7665
7693
|
previousState && ((previousState == null ? void 0 : previousState.clickedLimitId) !== clickedLimitId || (previousState == null ? void 0 : previousState.clickedSortId) !== clickedSortId || (previousState == null ? void 0 : previousState.clickedFacets) !== clickedFacets) || isKeywordChanged
|