karsten-design-system 1.1.78 → 1.1.79
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/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4160,17 +4160,21 @@ function Select(props) {
|
|
|
4160
4160
|
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
4161
4161
|
const containerRef = useRef(null);
|
|
4162
4162
|
const inputRef = useRef(null);
|
|
4163
|
+
const hasOnInputChange = props?.onInputChange !== undefined;
|
|
4163
4164
|
const normalize = (str) => str
|
|
4164
4165
|
.normalize('NFD')
|
|
4165
4166
|
.replace(/[\u0300-\u036f]/g, '')
|
|
4166
4167
|
.toLowerCase();
|
|
4167
4168
|
const filteredOptions = (() => {
|
|
4168
|
-
if (
|
|
4169
|
-
return options
|
|
4169
|
+
if (hasOnInputChange && searchText.length > 0) {
|
|
4170
|
+
return options;
|
|
4170
4171
|
}
|
|
4171
|
-
if (isOpen && props.value) {
|
|
4172
|
+
if (hasOnInputChange && isOpen && !searchText.length && props.value) {
|
|
4172
4173
|
return [props.value];
|
|
4173
4174
|
}
|
|
4175
|
+
if (!hasOnInputChange) {
|
|
4176
|
+
return options.filter((option) => normalize(option.label).includes(normalize(searchText)));
|
|
4177
|
+
}
|
|
4174
4178
|
return [];
|
|
4175
4179
|
})();
|
|
4176
4180
|
const toggleDropdown = () => {
|
|
@@ -4182,6 +4186,7 @@ function Select(props) {
|
|
|
4182
4186
|
setTimeout(() => {
|
|
4183
4187
|
inputRef.current?.focus();
|
|
4184
4188
|
}, 0);
|
|
4189
|
+
setSearchText('');
|
|
4185
4190
|
}
|
|
4186
4191
|
else {
|
|
4187
4192
|
setSearchText(props.value?.label ?? '');
|
|
@@ -4195,7 +4200,7 @@ function Select(props) {
|
|
|
4195
4200
|
}
|
|
4196
4201
|
else {
|
|
4197
4202
|
props.onChange(option);
|
|
4198
|
-
if (!
|
|
4203
|
+
if (!hasOnInputChange) {
|
|
4199
4204
|
setSearchText(option.label);
|
|
4200
4205
|
}
|
|
4201
4206
|
}
|