@cloudtower/eagle 0.32.52 → 0.32.53
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/cjs/core/SearchInput/index.js +22 -11
- package/dist/cjs/stats1.html +1 -1
- package/dist/components.css +2725 -2725
- package/dist/esm/core/SearchInput/index.js +22 -11
- package/dist/esm/stats1.html +1 -1
- package/dist/linaria.merged.scss +3872 -3872
- package/dist/src/core/SearchInput/searchInput.type.d.ts +5 -0
- package/dist/stories/docs/core/SearchInput.stories.d.ts +28 -1
- package/dist/style.css +2567 -2567
- package/package.json +4 -4
|
@@ -56,28 +56,37 @@ const SearchInput = props => {
|
|
|
56
56
|
nextIcon,
|
|
57
57
|
clearIcon,
|
|
58
58
|
width,
|
|
59
|
-
searchIcon
|
|
59
|
+
searchIcon,
|
|
60
|
+
current: externalCurrent
|
|
60
61
|
} = _a,
|
|
61
|
-
restProps = __objRest(_a, ["onChange", "debounceWait", "total", "onSearchNext", "onSearchPrev", "prefixHoverIcon", "nextHoverIcon", "clearHoverIcon", "prefixIcon", "nextIcon", "clearIcon", "width", "searchIcon"]);
|
|
62
|
-
const [
|
|
62
|
+
restProps = __objRest(_a, ["onChange", "debounceWait", "total", "onSearchNext", "onSearchPrev", "prefixHoverIcon", "nextHoverIcon", "clearHoverIcon", "prefixIcon", "nextIcon", "clearIcon", "width", "searchIcon", "current"]);
|
|
63
|
+
const [internalCurrent, setInternalCurrent] = useState(0);
|
|
63
64
|
const [value, setValue] = useState(props.value || "");
|
|
64
65
|
const {
|
|
65
66
|
t
|
|
66
67
|
} = useParrotTranslation();
|
|
67
68
|
const onSearch = _.debounce(onChange, debounceWait);
|
|
68
69
|
const isNoMatch = total === 0;
|
|
70
|
+
const current = externalCurrent !== void 0 ? externalCurrent : internalCurrent;
|
|
71
|
+
const setCurrent = useCallback(newCurrent => {
|
|
72
|
+
if (externalCurrent === void 0) {
|
|
73
|
+
setInternalCurrent(newCurrent);
|
|
74
|
+
}
|
|
75
|
+
}, [externalCurrent]);
|
|
69
76
|
const next = useCallback(() => {
|
|
70
77
|
if (total) {
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
const nextCurrent = current + 1 > total ? 1 : current + 1;
|
|
79
|
+
onSearchNext == null ? void 0 : onSearchNext(value, nextCurrent);
|
|
80
|
+
setCurrent(nextCurrent);
|
|
73
81
|
}
|
|
74
|
-
}, [onSearchNext, current, total, value]);
|
|
82
|
+
}, [onSearchNext, current, total, value, setCurrent]);
|
|
75
83
|
const prev = useCallback(() => {
|
|
76
84
|
if (total) {
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
const prevCurrent = current - 1 < 1 ? total : current - 1;
|
|
86
|
+
onSearchPrev == null ? void 0 : onSearchPrev(value, prevCurrent);
|
|
87
|
+
setCurrent(prevCurrent);
|
|
79
88
|
}
|
|
80
|
-
}, [onSearchPrev, current, total, value]);
|
|
89
|
+
}, [onSearchPrev, current, total, value, setCurrent]);
|
|
81
90
|
const suffix = onSearchNext && onSearchPrev && value ? /* @__PURE__ */React__default.createElement(React__default.Fragment, null, typeof total === "number" ? /* @__PURE__ */React__default.createElement("span", {
|
|
82
91
|
className: cx(Typo.Label.l4_regular, "counter-text", CountTextStyle)
|
|
83
92
|
}, current, "/", total) : null, /* @__PURE__ */React__default.createElement("span", {
|
|
@@ -120,8 +129,10 @@ const SearchInput = props => {
|
|
|
120
129
|
setValue(props.value || "");
|
|
121
130
|
}, [props.value]);
|
|
122
131
|
useEffect(() => {
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
if (externalCurrent === void 0) {
|
|
133
|
+
setCurrent(total ? 1 : 0);
|
|
134
|
+
}
|
|
135
|
+
}, [value, total, externalCurrent, setCurrent]);
|
|
125
136
|
return /* @__PURE__ */React__default.createElement(Input, __spreadProps(__spreadValues({
|
|
126
137
|
style: {
|
|
127
138
|
width: width != null ? width : 276
|