next-helios-fe 1.4.33 → 1.4.35
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/package.json
CHANGED
@@ -30,12 +30,14 @@ export const Modal: React.FC<ModalProps> = ({
|
|
30
30
|
}) => {
|
31
31
|
useEffect(() => {
|
32
32
|
if (!options?.disableClose) {
|
33
|
-
|
34
|
-
|
35
|
-
e.
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
if (open) {
|
34
|
+
document.addEventListener("keydown", (e) => {
|
35
|
+
if (e.key === "Escape") {
|
36
|
+
e.preventDefault();
|
37
|
+
onClose && onClose();
|
38
|
+
}
|
39
|
+
});
|
40
|
+
}
|
39
41
|
}
|
40
42
|
}, []);
|
41
43
|
|
@@ -26,6 +26,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
26
26
|
...rest
|
27
27
|
}) => {
|
28
28
|
const [tempValue, setTempValue] = useState("");
|
29
|
+
const [tempFilter, setTempFilter] = useState("");
|
29
30
|
const [openDropdown, setOpenDropdown] = useState(false);
|
30
31
|
const [position, setPosition] = useState<{
|
31
32
|
top: number;
|
@@ -89,10 +90,10 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
89
90
|
}, [openDropdown, tempValue]);
|
90
91
|
|
91
92
|
useEffect(() => {
|
92
|
-
if (rest.value) {
|
93
|
+
if (rest.value || rest.value === "") {
|
93
94
|
setTempValue(rest.value as string);
|
94
95
|
return;
|
95
|
-
} else if (rest.defaultValue) {
|
96
|
+
} else if (rest.defaultValue || rest.defaultValue === "") {
|
96
97
|
setTempValue(rest.defaultValue as string);
|
97
98
|
return;
|
98
99
|
}
|
@@ -129,17 +130,14 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
129
130
|
placeholder={placeholder}
|
130
131
|
required={rest.required}
|
131
132
|
disabled={rest.disabled}
|
132
|
-
value={
|
133
|
-
menus.find((item) => item.value === tempValue)
|
134
|
-
? menus.find((item) => item.value === tempValue)?.label
|
135
|
-
: tempValue
|
136
|
-
}
|
133
|
+
value={tempFilter}
|
137
134
|
onChange={(e) => {
|
138
|
-
|
135
|
+
setTempFilter(e.target.value);
|
139
136
|
}}
|
140
137
|
onClick={() => {
|
141
138
|
setOpenDropdown(true);
|
142
139
|
setTempValue("");
|
140
|
+
setTempFilter("");
|
143
141
|
}}
|
144
142
|
/>
|
145
143
|
<div className="absolute right-4 text-xl text-slate-400 pointer-events-none">
|
@@ -159,7 +157,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
159
157
|
}}
|
160
158
|
>
|
161
159
|
{menus.filter((item) =>
|
162
|
-
item.label.toLowerCase().includes(
|
160
|
+
item.label.toLowerCase().includes(tempFilter.toLowerCase())
|
163
161
|
).length === 0 ? (
|
164
162
|
<div className="flex justify-center">
|
165
163
|
<span className="px-4 py-1">No data found</span>
|
@@ -167,7 +165,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
167
165
|
) : (
|
168
166
|
menus
|
169
167
|
.filter((item) =>
|
170
|
-
item.label.toLowerCase().includes(
|
168
|
+
item.label.toLowerCase().includes(tempFilter.toLowerCase())
|
171
169
|
)
|
172
170
|
.map((item, index) => (
|
173
171
|
<button
|
@@ -177,6 +175,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
177
175
|
disabled={tempValue === item.value}
|
178
176
|
onMouseDown={() => {
|
179
177
|
setTempValue(item.value);
|
178
|
+
setTempFilter(item.label);
|
180
179
|
setOpenDropdown(false);
|
181
180
|
}}
|
182
181
|
>
|
@@ -89,10 +89,10 @@ export const Select: React.FC<SelectProps> = ({
|
|
89
89
|
}, [openDropdown]);
|
90
90
|
|
91
91
|
useEffect(() => {
|
92
|
-
if (rest.value) {
|
92
|
+
if (rest.value || rest.value === "") {
|
93
93
|
setTempValue(rest.value as string);
|
94
94
|
return;
|
95
|
-
} else if (rest.defaultValue) {
|
95
|
+
} else if (rest.defaultValue || rest.defaultValue === "") {
|
96
96
|
setTempValue(rest.defaultValue as string);
|
97
97
|
return;
|
98
98
|
}
|
@@ -129,7 +129,11 @@ export const Select: React.FC<SelectProps> = ({
|
|
129
129
|
placeholder={placeholder}
|
130
130
|
required={rest.required}
|
131
131
|
disabled={rest.disabled}
|
132
|
-
value={
|
132
|
+
value={
|
133
|
+
tempValue
|
134
|
+
? menus.find((item) => item.value === tempValue)?.label
|
135
|
+
: ""
|
136
|
+
}
|
133
137
|
onClick={() => setOpenDropdown(true)}
|
134
138
|
/>
|
135
139
|
<div className="absolute right-4 text-xl text-slate-400 pointer-events-none">
|