karsten-design-system 1.1.78 → 1.1.80

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 CHANGED
@@ -4160,18 +4160,34 @@ 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();
4168
+ // const filteredOptions = (() => {
4169
+ // if (!hasOnInputChange || (isOpen && searchText.length > 0)) {
4170
+ // return options.filter((option) =>
4171
+ // normalize(option.label).includes(normalize(searchText))
4172
+ // )
4173
+ // }
4174
+ // if (isOpen && props.value) {
4175
+ // return [props.value]
4176
+ // }
4177
+ // return []
4178
+ // })()
4167
4179
  const filteredOptions = (() => {
4168
- if (isReadOnly || (isOpen && searchText.length > 0)) {
4169
- return options.filter((option) => normalize(option.label).includes(normalize(searchText)));
4170
- }
4171
- if (isOpen && props.value) {
4172
- return [props.value];
4180
+ const hasSearch = searchText.length > 0;
4181
+ if (hasOnInputChange) {
4182
+ if (isOpen) {
4183
+ if (hasSearch) {
4184
+ return options.filter((option) => normalize(option.label).includes(normalize(searchText)));
4185
+ }
4186
+ return props.value ? [props.value] : [];
4187
+ }
4188
+ return [];
4173
4189
  }
4174
- return [];
4190
+ return options.filter((option) => normalize(option.label).includes(normalize(searchText)));
4175
4191
  })();
4176
4192
  const toggleDropdown = () => {
4177
4193
  if (!disabled && !isLoading) {
@@ -4195,7 +4211,7 @@ function Select(props) {
4195
4211
  }
4196
4212
  else {
4197
4213
  props.onChange(option);
4198
- if (!isReadOnly) {
4214
+ if (!hasOnInputChange) {
4199
4215
  setSearchText(option.label);
4200
4216
  }
4201
4217
  }