karsten-design-system 1.1.77 → 1.1.78
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 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4164,11 +4164,8 @@ function Select(props) {
|
|
|
4164
4164
|
.normalize('NFD')
|
|
4165
4165
|
.replace(/[\u0300-\u036f]/g, '')
|
|
4166
4166
|
.toLowerCase();
|
|
4167
|
-
// const filteredOptions = options.filter((option) =>
|
|
4168
|
-
// normalize(option.label).includes(normalize(searchText))
|
|
4169
|
-
// )
|
|
4170
4167
|
const filteredOptions = (() => {
|
|
4171
|
-
if (isOpen && searchText.length > 0) {
|
|
4168
|
+
if (isReadOnly || (isOpen && searchText.length > 0)) {
|
|
4172
4169
|
return options.filter((option) => normalize(option.label).includes(normalize(searchText)));
|
|
4173
4170
|
}
|
|
4174
4171
|
if (isOpen && props.value) {
|
|
@@ -4180,23 +4177,28 @@ function Select(props) {
|
|
|
4180
4177
|
if (!disabled && !isLoading) {
|
|
4181
4178
|
const newState = !isOpen;
|
|
4182
4179
|
setIsOpen(newState);
|
|
4183
|
-
setSearchText('');
|
|
4184
4180
|
setHighlightedIndex(-1);
|
|
4185
4181
|
if (newState) {
|
|
4186
4182
|
setTimeout(() => {
|
|
4187
4183
|
inputRef.current?.focus();
|
|
4188
4184
|
}, 0);
|
|
4189
4185
|
}
|
|
4186
|
+
else {
|
|
4187
|
+
setSearchText(props.value?.label ?? '');
|
|
4188
|
+
}
|
|
4190
4189
|
}
|
|
4191
4190
|
};
|
|
4192
4191
|
const handleSelect = (option) => {
|
|
4193
4192
|
if (props.value?.value === option.value) {
|
|
4194
4193
|
props.onChange(null);
|
|
4194
|
+
setSearchText('');
|
|
4195
4195
|
}
|
|
4196
4196
|
else {
|
|
4197
4197
|
props.onChange(option);
|
|
4198
|
+
if (!isReadOnly) {
|
|
4199
|
+
setSearchText(option.label);
|
|
4200
|
+
}
|
|
4198
4201
|
}
|
|
4199
|
-
setSearchText('');
|
|
4200
4202
|
setIsOpen(false);
|
|
4201
4203
|
setHighlightedIndex(-1);
|
|
4202
4204
|
};
|
|
@@ -4212,7 +4214,7 @@ function Select(props) {
|
|
|
4212
4214
|
if (containerRef.current &&
|
|
4213
4215
|
!containerRef.current.contains(event.target)) {
|
|
4214
4216
|
setIsOpen(false);
|
|
4215
|
-
setSearchText('');
|
|
4217
|
+
setSearchText(props.value?.label ?? '');
|
|
4216
4218
|
setHighlightedIndex(-1);
|
|
4217
4219
|
}
|
|
4218
4220
|
};
|