@homecode/ui 4.18.62 → 4.18.63
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.
|
@@ -61,10 +61,13 @@ class Select extends Component {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
componentDidUpdate(prevProps) {
|
|
64
|
-
const { options, value } = this.props;
|
|
64
|
+
const { options, value, searchValue } = this.props;
|
|
65
65
|
if (!compare(value, prevProps.value)) {
|
|
66
66
|
this.store.selected = this.getDefaultSelected();
|
|
67
67
|
}
|
|
68
|
+
if (!compare(searchValue, prevProps.searchValue)) {
|
|
69
|
+
this.setSearchVal(searchValue);
|
|
70
|
+
}
|
|
68
71
|
if (!compare(options, prevProps.options)) {
|
|
69
72
|
this.onOptionsChange();
|
|
70
73
|
}
|
|
@@ -193,7 +196,6 @@ class Select extends Component {
|
|
|
193
196
|
unDocumentClick = () => document.removeEventListener('click', this.onDocumentClick);
|
|
194
197
|
onFocus = e => {
|
|
195
198
|
const { onFocus } = this.props;
|
|
196
|
-
this.setSearchVal('');
|
|
197
199
|
this.store.isFocused = true;
|
|
198
200
|
onFocus?.(e);
|
|
199
201
|
};
|
|
@@ -374,9 +376,10 @@ class Select extends Component {
|
|
|
374
376
|
return null;
|
|
375
377
|
}
|
|
376
378
|
getInputVal() {
|
|
377
|
-
const { isFocused,
|
|
378
|
-
|
|
379
|
-
|
|
379
|
+
const { isFocused, selected } = this.store;
|
|
380
|
+
const searchValue = this.props.searchValue ?? this.store.searchVal;
|
|
381
|
+
if (isFocused && searchValue)
|
|
382
|
+
return searchValue;
|
|
380
383
|
const selectedPlain = Object.entries(selected).reduce((acc, entry) => {
|
|
381
384
|
const parentId = this.coerceType(entry[0]);
|
|
382
385
|
const val = entry[1];
|
|
@@ -390,6 +393,8 @@ class Select extends Component {
|
|
|
390
393
|
}
|
|
391
394
|
return acc;
|
|
392
395
|
}, []);
|
|
396
|
+
if (selectedPlain.length === 0)
|
|
397
|
+
return searchValue;
|
|
393
398
|
return selectedPlain.map(id => this.getItem(id)?.label).join(', ');
|
|
394
399
|
}
|
|
395
400
|
getLabel(id) {
|
|
@@ -44,6 +44,7 @@ export type Props = FormControl<Value> & InheritedInputProps & {
|
|
|
44
44
|
clearButton?: boolean;
|
|
45
45
|
selectAllButton?: boolean;
|
|
46
46
|
value?: Value;
|
|
47
|
+
searchValue?: string;
|
|
47
48
|
expandSelected?: boolean;
|
|
48
49
|
onChange: (value: Value) => void;
|
|
49
50
|
onSeachChange?: (value: string) => void;
|