@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
|
@@ -63,28 +63,37 @@ const SearchInput = props => {
|
|
|
63
63
|
nextIcon,
|
|
64
64
|
clearIcon,
|
|
65
65
|
width,
|
|
66
|
-
searchIcon
|
|
66
|
+
searchIcon,
|
|
67
|
+
current: externalCurrent
|
|
67
68
|
} = _a,
|
|
68
|
-
restProps = __objRest(_a, ["onChange", "debounceWait", "total", "onSearchNext", "onSearchPrev", "prefixHoverIcon", "nextHoverIcon", "clearHoverIcon", "prefixIcon", "nextIcon", "clearIcon", "width", "searchIcon"]);
|
|
69
|
-
const [
|
|
69
|
+
restProps = __objRest(_a, ["onChange", "debounceWait", "total", "onSearchNext", "onSearchPrev", "prefixHoverIcon", "nextHoverIcon", "clearHoverIcon", "prefixIcon", "nextIcon", "clearIcon", "width", "searchIcon", "current"]);
|
|
70
|
+
const [internalCurrent, setInternalCurrent] = React.useState(0);
|
|
70
71
|
const [value, setValue] = React.useState(props.value || "");
|
|
71
72
|
const {
|
|
72
73
|
t
|
|
73
74
|
} = useParrotTranslation();
|
|
74
75
|
const onSearch = ___default.default.debounce(onChange, debounceWait);
|
|
75
76
|
const isNoMatch = total === 0;
|
|
77
|
+
const current = externalCurrent !== void 0 ? externalCurrent : internalCurrent;
|
|
78
|
+
const setCurrent = React.useCallback(newCurrent => {
|
|
79
|
+
if (externalCurrent === void 0) {
|
|
80
|
+
setInternalCurrent(newCurrent);
|
|
81
|
+
}
|
|
82
|
+
}, [externalCurrent]);
|
|
76
83
|
const next = React.useCallback(() => {
|
|
77
84
|
if (total) {
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
const nextCurrent = current + 1 > total ? 1 : current + 1;
|
|
86
|
+
onSearchNext == null ? void 0 : onSearchNext(value, nextCurrent);
|
|
87
|
+
setCurrent(nextCurrent);
|
|
80
88
|
}
|
|
81
|
-
}, [onSearchNext, current, total, value]);
|
|
89
|
+
}, [onSearchNext, current, total, value, setCurrent]);
|
|
82
90
|
const prev = React.useCallback(() => {
|
|
83
91
|
if (total) {
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
const prevCurrent = current - 1 < 1 ? total : current - 1;
|
|
93
|
+
onSearchPrev == null ? void 0 : onSearchPrev(value, prevCurrent);
|
|
94
|
+
setCurrent(prevCurrent);
|
|
86
95
|
}
|
|
87
|
-
}, [onSearchPrev, current, total, value]);
|
|
96
|
+
}, [onSearchPrev, current, total, value, setCurrent]);
|
|
88
97
|
const suffix = onSearchNext && onSearchPrev && value ? /* @__PURE__ */React__default.default.createElement(React__default.default.Fragment, null, typeof total === "number" ? /* @__PURE__ */React__default.default.createElement("span", {
|
|
89
98
|
className: core.cx(index.Typo.Label.l4_regular, "counter-text", CountTextStyle)
|
|
90
99
|
}, current, "/", total) : null, /* @__PURE__ */React__default.default.createElement("span", {
|
|
@@ -127,8 +136,10 @@ const SearchInput = props => {
|
|
|
127
136
|
setValue(props.value || "");
|
|
128
137
|
}, [props.value]);
|
|
129
138
|
React.useEffect(() => {
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
if (externalCurrent === void 0) {
|
|
140
|
+
setCurrent(total ? 1 : 0);
|
|
141
|
+
}
|
|
142
|
+
}, [value, total, externalCurrent, setCurrent]);
|
|
132
143
|
return /* @__PURE__ */React__default.default.createElement(index$3, __spreadProps(__spreadValues({
|
|
133
144
|
style: {
|
|
134
145
|
width: width != null ? width : 276
|