@arkyn/components 1.3.61 → 1.3.63

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,7 +34,6 @@ function Select(props: SelectProps) {
34
34
  onBlur,
35
35
  Spinner,
36
36
  name,
37
- // isSearchable,
38
37
  placeholder,
39
38
  onSelect,
40
39
  options,
@@ -44,7 +43,6 @@ function Select(props: SelectProps) {
44
43
  } = getConfig({ ...props, id, isError }, isFocused);
45
44
 
46
45
  const [selectedValue, setSelectedValue] = useState(defaultValue);
47
- const [searchValue, setSearchValue] = useState("");
48
46
 
49
47
  function handleSectionClick() {
50
48
  if (disabled || !ref?.current) return;
@@ -53,16 +51,14 @@ function Select(props: SelectProps) {
53
51
  }
54
52
 
55
53
  function handleFocus(e: FocusEvent<HTMLInputElement>) {
54
+ if (isFocused) return;
56
55
  setIsFocused(true);
57
56
  if (onFocus) onFocus(e);
58
57
  }
59
58
 
60
59
  function handleBlur() {
61
60
  setIsFocused(false);
62
-
63
- if (onBlur && ref.current) {
64
- ref.current.blur();
65
- }
61
+ if (onBlur && ref.current) ref.current.blur();
66
62
  }
67
63
 
68
64
  function handleChangeValue(option: { label: string; value: string }) {
@@ -72,11 +68,7 @@ function Select(props: SelectProps) {
72
68
  else setSelectedValue("");
73
69
 
74
70
  if (onSelect) onSelect({ label, value });
75
- if (closeOnSelect) {
76
- ref.current.blur();
77
- setIsFocused(false);
78
- console.log("fecha");
79
- }
71
+ if (closeOnSelect) handleBlur();
80
72
  }
81
73
 
82
74
  const currentValue =
@@ -86,28 +78,12 @@ function Select(props: SelectProps) {
86
78
  options.find((option) => option.value === currentValue)?.label || "";
87
79
 
88
80
  const placeholderDark = () => {
89
- // if (isSearchable) {
90
- // if (!isFocused && !!currentLabel) return true;
91
- // if (!isFocused && !currentLabel) return false;
92
- // if (isFocused) return false;
93
- // }
94
-
95
- // if (!isSearchable) {
96
81
  if (!isFocused && !!currentLabel) return true;
97
82
  if (!isFocused && !currentLabel) return false;
98
83
  if (isFocused && !!currentLabel) return true;
99
84
  if (isFocused && !currentLabel) return false;
100
- // }
101
85
  };
102
86
 
103
- const filteredOptions = options.filter((option) => {
104
- // if (isSearchable) {
105
- // return option.label.toLowerCase().includes(searchValue.toLowerCase());
106
- // } else {
107
- return true;
108
- // }
109
- });
110
-
111
87
  return (
112
88
  <>
113
89
  <section
@@ -121,14 +97,10 @@ function Select(props: SelectProps) {
121
97
 
122
98
  <input
123
99
  disabled={disabled || isLoading}
124
- // readOnly={!isSearchable}
125
100
  readOnly
126
- value={searchValue || ""}
127
101
  placeholder={currentLabel || placeholder}
128
102
  onFocus={handleFocus}
129
- onBlur={() => setSearchValue("")}
130
103
  {...rest}
131
- // onChange={(e) => setSearchValue(e.target.value)}
132
104
  />
133
105
 
134
106
  <input
@@ -144,7 +116,7 @@ function Select(props: SelectProps) {
144
116
  className="arkyn_select_content"
145
117
  style={{ overflow: "auto", maxHeight: optionMaxHeight }}
146
118
  >
147
- {filteredOptions.map(({ label, value }) => (
119
+ {options.map(({ label, value }) => (
148
120
  <div
149
121
  key={value}
150
122
  onClick={() => handleChangeValue({ label, value })}
@@ -158,7 +130,7 @@ function Select(props: SelectProps) {
158
130
  </div>
159
131
  ))}
160
132
 
161
- {filteredOptions.length <= 0 && <p>Sem opções disponíveis</p>}
133
+ {options.length <= 0 && <p>Sem opções disponíveis</p>}
162
134
  </div>
163
135
  )}
164
136