@sledge-app/react-instant-search 1.0.16 → 1.0.18
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/SearchWidget/SearchWidget.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 +16 -1
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -4879,7 +4879,9 @@ const SearchWidget = (props) => {
|
|
|
4879
4879
|
const [displaySettings, setDisplaySettings] = React__default.useState({});
|
|
4880
4880
|
const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
|
|
4881
4881
|
const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
|
|
4882
|
+
const [showSearchResult, setShowSearchResult] = React__default.useState(false);
|
|
4882
4883
|
const previousState = usePrevious({ keyword });
|
|
4884
|
+
const searchFieldRef = React__default.useRef(null);
|
|
4883
4885
|
const handleMultiSearch = async (data, onSearch = false) => {
|
|
4884
4886
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
|
|
4885
4887
|
if (!keyword.length)
|
|
@@ -4957,30 +4959,43 @@ const SearchWidget = (props) => {
|
|
|
4957
4959
|
React__default.useEffect(() => {
|
|
4958
4960
|
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
4959
4961
|
const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
4962
|
+
if (!keyword)
|
|
4963
|
+
setShowSearchResult(false);
|
|
4960
4964
|
const delayDebounceFn = setTimeout(() => {
|
|
4965
|
+
if (keyword)
|
|
4966
|
+
setShowSearchResult(true);
|
|
4961
4967
|
if (INSTANT_SEARCH_SETTING)
|
|
4962
4968
|
handleMultiSearch(INSTANT_SEARCH_SETTING, true);
|
|
4963
4969
|
}, 500);
|
|
4964
4970
|
return () => clearTimeout(delayDebounceFn);
|
|
4965
4971
|
}
|
|
4966
4972
|
}, [keyword]);
|
|
4973
|
+
React__default.useEffect(() => {
|
|
4974
|
+
showSearchResult ? document.body.classList.add("sledge__open-element-inset") : document.body.classList.remove("sledge__open-element-inset");
|
|
4975
|
+
}, [showSearchResult]);
|
|
4967
4976
|
const wrapperStyle = {
|
|
4968
4977
|
maxWidth: width
|
|
4969
4978
|
};
|
|
4970
4979
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-wrapper", style: wrapperStyle, children: [
|
|
4980
|
+
showSearchResult ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__inset-full", onClick: () => setShowSearchResult(false) }) : null,
|
|
4971
4981
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4972
4982
|
SearchInputField,
|
|
4973
4983
|
{
|
|
4974
4984
|
type: "text",
|
|
4985
|
+
fieldRef: searchFieldRef,
|
|
4975
4986
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
4976
4987
|
placeholder: "Search anything",
|
|
4977
4988
|
value: keyword,
|
|
4978
4989
|
onChange: ({ value }) => setKeyword(value),
|
|
4979
4990
|
onResetField: () => setKeyword(""),
|
|
4991
|
+
onFocus: () => {
|
|
4992
|
+
if (keyword)
|
|
4993
|
+
setShowSearchResult(true);
|
|
4994
|
+
},
|
|
4980
4995
|
withClearField: true
|
|
4981
4996
|
}
|
|
4982
4997
|
),
|
|
4983
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "hidden", animate:
|
|
4998
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "hidden", animate: showSearchResult ? "visible" : "hidden", variants: VISIBLE_ANIMATION, className: "sledge-instant-search__widget-search-form-result", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex", children: [
|
|
4984
4999
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-other sledge-instant-search__widget-search-form-result-flex-item-other-skeleton", children: [0, 1, 2].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(React__default.Fragment, { children: [
|
|
4985
5000
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4986
5001
|
SkeletonLoading.Item,
|