opus-toolkit-components 0.2.7 → 0.2.9
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.
|
@@ -9020,13 +9020,17 @@ function Dropdown(_ref) {
|
|
|
9020
9020
|
onChange,
|
|
9021
9021
|
value
|
|
9022
9022
|
} = _ref;
|
|
9023
|
+
const [selectedItem, setSelectedItem] = (0,external_react_.useState)(value); // Initialize to null
|
|
9024
|
+
|
|
9023
9025
|
const inputClasses = `inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white border px-4 py-3 text-md font-normal text-gray-900 ${isValid ? 'border-slate-500' : 'border-rose-500'}`;
|
|
9024
|
-
const handleSelect =
|
|
9026
|
+
const handleSelect = item => {
|
|
9027
|
+
setSelectedItem(item); // Store the whole item
|
|
9028
|
+
|
|
9025
9029
|
// Create a synthetic event
|
|
9026
9030
|
const event = {
|
|
9027
9031
|
target: {
|
|
9028
9032
|
name: name,
|
|
9029
|
-
value:
|
|
9033
|
+
value: item.value // Use the value of the selected item
|
|
9030
9034
|
}
|
|
9031
9035
|
};
|
|
9032
9036
|
onChange(event); // Pass the synthetic event object
|
|
@@ -9037,7 +9041,7 @@ function Dropdown(_ref) {
|
|
|
9037
9041
|
name: name
|
|
9038
9042
|
}, /*#__PURE__*/external_react_default().createElement("label", null, label), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
|
|
9039
9043
|
className: inputClasses
|
|
9040
|
-
}, placeholder, /*#__PURE__*/external_react_default().createElement(esm_ChevronDownIcon, {
|
|
9044
|
+
}, selectedItem ? selectedItem.label : placeholder, " ", /*#__PURE__*/external_react_default().createElement(esm_ChevronDownIcon, {
|
|
9041
9045
|
"aria-hidden": "true",
|
|
9042
9046
|
className: "-mr-1 h-5 w-5 text-gray-400"
|
|
9043
9047
|
}))), /*#__PURE__*/external_react_default().createElement(gt, {
|
|
@@ -9054,7 +9058,8 @@ function Dropdown(_ref) {
|
|
|
9054
9058
|
return /*#__PURE__*/external_react_default().createElement("button", {
|
|
9055
9059
|
type: "button" // Prevent form submission
|
|
9056
9060
|
,
|
|
9057
|
-
onClick: () => handleSelect(item
|
|
9061
|
+
onClick: () => handleSelect(item) // Pass the whole item to handleSelect
|
|
9062
|
+
,
|
|
9058
9063
|
className: `block w-full px-4 py-2 text-left text-sm text-gray-700 ${active ? 'bg-gray-100 text-gray-900' : ''}`
|
|
9059
9064
|
}, item.label);
|
|
9060
9065
|
})))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
|
|
@@ -9074,4 +9079,4 @@ function Dropdown(_ref) {
|
|
|
9074
9079
|
/******/ })()
|
|
9075
9080
|
;
|
|
9076
9081
|
});
|
|
9077
|
-
//# sourceMappingURL=main.
|
|
9082
|
+
//# sourceMappingURL=main.cbe51cd922acdf7e3218.js.map
|