hi-tm 0.8.1 → 0.8.3
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.
|
@@ -104,15 +104,37 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
|
|
|
104
104
|
const deriveLabel = (0, react_1.useCallback)((option) => {
|
|
105
105
|
if (getOptionLabel)
|
|
106
106
|
return getOptionLabel(option);
|
|
107
|
+
// Handle primitive types directly
|
|
108
|
+
const optionType = typeof option;
|
|
109
|
+
if (option === null ||
|
|
110
|
+
optionType === 'string' ||
|
|
111
|
+
optionType === 'number' ||
|
|
112
|
+
optionType === 'boolean') {
|
|
113
|
+
return String(option ?? '');
|
|
114
|
+
}
|
|
115
|
+
// Handle objects with common fields
|
|
107
116
|
const anyOption = option;
|
|
108
|
-
const
|
|
109
|
-
|
|
117
|
+
const labelCandidate = anyOption.label ??
|
|
118
|
+
anyOption.content ??
|
|
119
|
+
anyOption.value ??
|
|
120
|
+
anyOption.name ??
|
|
121
|
+
anyOption.title;
|
|
122
|
+
return String(labelCandidate ?? '');
|
|
110
123
|
}, [getOptionLabel]);
|
|
111
124
|
const deriveValue = (0, react_1.useCallback)((option) => {
|
|
112
125
|
if (getOptionValue)
|
|
113
126
|
return getOptionValue(option);
|
|
127
|
+
// Handle primitive types directly
|
|
128
|
+
const optionType = typeof option;
|
|
129
|
+
if (option === null ||
|
|
130
|
+
optionType === 'string' ||
|
|
131
|
+
optionType === 'number' ||
|
|
132
|
+
optionType === 'boolean') {
|
|
133
|
+
return String(option ?? '');
|
|
134
|
+
}
|
|
135
|
+
// Handle objects with common fields
|
|
114
136
|
const anyOption = option;
|
|
115
|
-
const base = anyOption.value ?? anyOption.label ?? anyOption.content;
|
|
137
|
+
const base = anyOption.value ?? anyOption.label ?? anyOption.content ?? anyOption.id ?? anyOption.key;
|
|
116
138
|
return String(base ?? deriveLabel(option));
|
|
117
139
|
}, [getOptionValue, deriveLabel]);
|
|
118
140
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|