hi-tm 0.5.9 → 0.6.0
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.
|
@@ -114,9 +114,26 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
|
|
|
114
114
|
const [highlightedIndex, setHighlightedIndex] = (0, react_1.useState)(0);
|
|
115
115
|
const [internalLoading, setInternalLoading] = (0, react_1.useState)(false);
|
|
116
116
|
const [hasSearched, setHasSearched] = (0, react_1.useState)(false);
|
|
117
|
-
const [selectedValues, setSelectedValues] = (0, react_1.useState)(
|
|
117
|
+
const [selectedValues, setSelectedValues] = (0, react_1.useState)([]);
|
|
118
118
|
const containerRef = (0, react_1.useRef)(null);
|
|
119
119
|
const inputRef = (0, react_1.useRef)(null);
|
|
120
|
+
// Sync external value prop with internal selectedValues state
|
|
121
|
+
(0, react_1.useEffect)(() => {
|
|
122
|
+
if (value === null || value === undefined) {
|
|
123
|
+
setSelectedValues([]);
|
|
124
|
+
}
|
|
125
|
+
else if (Array.isArray(value)) {
|
|
126
|
+
if (isMultiSelect) {
|
|
127
|
+
setSelectedValues(value);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
setSelectedValues(value.length > 0 ? [value[0]] : []);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
setSelectedValues([value]);
|
|
135
|
+
}
|
|
136
|
+
}, [value, isMultiSelect]);
|
|
120
137
|
// Sync options into filtered list when not searching
|
|
121
138
|
(0, react_1.useEffect)(() => {
|
|
122
139
|
if (!hasSearched) {
|