hi-tm 0.9.0 → 0.9.1
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.
|
@@ -41,7 +41,7 @@ const defaultStyles = {
|
|
|
41
41
|
trigger: 'flex items-center border rounded-md px-3 py-2 bg-white cursor-pointer',
|
|
42
42
|
input: 'w-full outline-none',
|
|
43
43
|
dropdown: 'absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-60 overflow-y-auto',
|
|
44
|
-
option: 'py-2 px-3 cursor-pointer flex items-center',
|
|
44
|
+
option: 'py-2 px-3 cursor-pointer flex items-center gap-2', // Added gap-2 for spacing
|
|
45
45
|
selectedOption: 'font-medium',
|
|
46
46
|
highlightedOption: 'bg-blue-100',
|
|
47
47
|
createOption: 'flex items-center gap-2 py-2 px-3 cursor-pointer hover:bg-blue-50',
|
|
@@ -51,20 +51,33 @@ const defaultStyles = {
|
|
|
51
51
|
clearButton: 'p-1 rounded-full hover:bg-gray-100',
|
|
52
52
|
icon: 'w-4 h-4 text-gray-400',
|
|
53
53
|
separator: 'h-4 border-l mx-2',
|
|
54
|
-
selectedOptionIcon: 'w-4 h-4 mr-2 text-blue-500', // Added style for selected option icon
|
|
54
|
+
selectedOptionIcon: 'w-4 h-4 mr-2 text-blue-500 flex-shrink-0', // Added style for selected option icon
|
|
55
55
|
};
|
|
56
56
|
// Helper function to render different icon types
|
|
57
57
|
const renderIcon = (icon, className = '') => {
|
|
58
|
+
if (react_1.default.isValidElement(icon)) {
|
|
59
|
+
// Check if the element can accept className
|
|
60
|
+
if ('props' in icon && typeof icon.props === 'object' && icon.props !== null) {
|
|
61
|
+
// Create a new object with existing props plus className
|
|
62
|
+
const props = {
|
|
63
|
+
...icon.props,
|
|
64
|
+
className: `${icon.props.className || ''} ${className}`.trim(),
|
|
65
|
+
};
|
|
66
|
+
// Return a new element with the updated props
|
|
67
|
+
return react_1.default.cloneElement(icon, props);
|
|
68
|
+
}
|
|
69
|
+
// If we can't add className, just return the element as-is
|
|
70
|
+
return icon;
|
|
71
|
+
}
|
|
58
72
|
if (typeof icon === 'string') {
|
|
59
|
-
return react_1.default.createElement("
|
|
73
|
+
return react_1.default.createElement("span", { className: className }, icon);
|
|
60
74
|
}
|
|
61
|
-
|
|
75
|
+
if (typeof icon === 'object' && icon && 'src' in icon) {
|
|
62
76
|
const img = icon;
|
|
63
77
|
return react_1.default.createElement("img", { src: img.src || '/placeholder.svg', alt: img.alt || '', className: className });
|
|
64
78
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
79
|
+
// For any other case (like JSX.Element or null/undefined)
|
|
80
|
+
return icon;
|
|
68
81
|
};
|
|
69
82
|
// Helper function to render the no results message
|
|
70
83
|
const renderNoResults = (noResults, className, searchIcon) => {
|
|
@@ -390,10 +403,12 @@ function CreatableSelect({ options = [], value, onChange, onClick, onValueChange
|
|
|
390
403
|
isOpen && (react_1.default.createElement("div", { className: styles.dropdown }, showLoading ? (react_1.default.createElement("div", { className: styles.loadingState },
|
|
391
404
|
renderIcon(iconSrc.loading, `animate-spin mr-2 ${styles.icon}`),
|
|
392
405
|
loadingMessage)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
393
|
-
filteredOptions.length > 0 && (react_1.default.createElement(react_1.default.Fragment, null, filteredOptions.map((option, index) =>
|
|
394
|
-
isOptionSelected(option)
|
|
395
|
-
|
|
396
|
-
|
|
406
|
+
filteredOptions.length > 0 && (react_1.default.createElement(react_1.default.Fragment, null, filteredOptions.map((option, index) => {
|
|
407
|
+
const isSelected = isOptionSelected(option);
|
|
408
|
+
return (react_1.default.createElement("div", { key: deriveValue(option), className: `${styles.option} ${index === highlightedIndex ? styles.highlightedOption : 'hover:bg-gray-50'}`, onClick: () => selectOption(option), onMouseEnter: () => setHighlightedIndex(index) },
|
|
409
|
+
isSelected && (react_1.default.createElement("span", { className: styles.selectedOptionIcon }, renderIcon(icons.checkmark, styles.selectedOptionIcon))),
|
|
410
|
+
react_1.default.createElement("span", { className: isSelected ? styles.selectedOption : '' }, deriveLabel(option) || deriveValue(option))));
|
|
411
|
+
}))),
|
|
397
412
|
filteredOptions.length === 0 && !inputValue && (react_1.default.createElement("div", { className: styles.noOptions }, noOptionsMessage)),
|
|
398
413
|
filteredOptions.length === 0 &&
|
|
399
414
|
inputValue &&
|