next-helios-fe 1.4.32 → 1.4.34
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
@@ -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;
|
@@ -127,18 +128,16 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
127
128
|
type="text"
|
128
129
|
className={`w-full px-4 border-default border rounded-md bg-secondary-bg placeholder:duration-300 placeholder:translate-x-0 focus:placeholder:translate-x-1 placeholder:text-slate-300 focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:text-slate-400 ${height}`}
|
129
130
|
placeholder={placeholder}
|
131
|
+
required={rest.required}
|
130
132
|
disabled={rest.disabled}
|
131
|
-
value={
|
132
|
-
menus.find((item) => item.value === tempValue)
|
133
|
-
? menus.find((item) => item.value === tempValue)?.label
|
134
|
-
: tempValue
|
135
|
-
}
|
133
|
+
value={tempFilter}
|
136
134
|
onChange={(e) => {
|
137
|
-
|
135
|
+
setTempFilter(e.target.value);
|
138
136
|
}}
|
139
137
|
onClick={() => {
|
140
138
|
setOpenDropdown(true);
|
141
139
|
setTempValue("");
|
140
|
+
setTempFilter("");
|
142
141
|
}}
|
143
142
|
/>
|
144
143
|
<div className="absolute right-4 text-xl text-slate-400 pointer-events-none">
|
@@ -158,7 +157,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
158
157
|
}}
|
159
158
|
>
|
160
159
|
{menus.filter((item) =>
|
161
|
-
item.label.toLowerCase().includes(
|
160
|
+
item.label.toLowerCase().includes(tempFilter.toLowerCase())
|
162
161
|
).length === 0 ? (
|
163
162
|
<div className="flex justify-center">
|
164
163
|
<span className="px-4 py-1">No data found</span>
|
@@ -166,7 +165,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
166
165
|
) : (
|
167
166
|
menus
|
168
167
|
.filter((item) =>
|
169
|
-
item.label.toLowerCase().includes(
|
168
|
+
item.label.toLowerCase().includes(tempFilter.toLowerCase())
|
170
169
|
)
|
171
170
|
.map((item, index) => (
|
172
171
|
<button
|
@@ -176,6 +175,7 @@ export const Autocomplete: React.FC<AutocompleteProps> = ({
|
|
176
175
|
disabled={tempValue === item.value}
|
177
176
|
onMouseDown={() => {
|
178
177
|
setTempValue(item.value);
|
178
|
+
setTempFilter(item.label);
|
179
179
|
setOpenDropdown(false);
|
180
180
|
}}
|
181
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
|
}
|
@@ -127,8 +127,13 @@ export const Select: React.FC<SelectProps> = ({
|
|
127
127
|
type="text"
|
128
128
|
className={`w-full px-4 border-default border rounded-md bg-secondary-bg cursor-pointer caret-transparent placeholder:duration-300 placeholder:translate-x-0 focus:placeholder:translate-x-1 placeholder:text-slate-300 focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:text-slate-400 disabled:cursor-default ${height}`}
|
129
129
|
placeholder={placeholder}
|
130
|
+
required={rest.required}
|
130
131
|
disabled={rest.disabled}
|
131
|
-
value={
|
132
|
+
value={
|
133
|
+
tempValue
|
134
|
+
? menus.find((item) => item.value === tempValue)?.label
|
135
|
+
: ""
|
136
|
+
}
|
132
137
|
onClick={() => setOpenDropdown(true)}
|
133
138
|
/>
|
134
139
|
<div className="absolute right-4 text-xl text-slate-400 pointer-events-none">
|