opus-toolkit-components 0.2.4 → 0.2.5
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.
|
@@ -8997,15 +8997,15 @@ const ForwardRef = /*#__PURE__*/ external_react_.forwardRef(ChevronDownIcon);
|
|
|
8997
8997
|
|
|
8998
8998
|
/*
|
|
8999
8999
|
|
|
9000
|
-
Usage:
|
|
9000
|
+
Usage Example:
|
|
9001
9001
|
|
|
9002
9002
|
import Dropdown from './Dropdown';
|
|
9003
9003
|
|
|
9004
9004
|
const menuItems = [
|
|
9005
|
-
{ label: 'Account settings',
|
|
9006
|
-
{ label: 'Support',
|
|
9007
|
-
{ label: 'License',
|
|
9008
|
-
{ label: 'Sign out', onClick: () => alert('Signed out!') },
|
|
9005
|
+
{ label: 'Account settings', value: 'settings' },
|
|
9006
|
+
{ label: 'Support', value: 'support' },
|
|
9007
|
+
{ label: 'License', value: 'license' },
|
|
9008
|
+
{ label: 'Sign out', value: 'signOut', onClick: () => alert('Signed out!') },
|
|
9009
9009
|
];
|
|
9010
9010
|
|
|
9011
9011
|
function App() {
|
|
@@ -9014,7 +9014,6 @@ const ForwardRef = /*#__PURE__*/ external_react_.forwardRef(ChevronDownIcon);
|
|
|
9014
9014
|
|
|
9015
9015
|
export default App;
|
|
9016
9016
|
|
|
9017
|
-
|
|
9018
9017
|
*/
|
|
9019
9018
|
|
|
9020
9019
|
function Dropdown(_ref) {
|
|
@@ -9024,21 +9023,33 @@ function Dropdown(_ref) {
|
|
|
9024
9023
|
isValid = true,
|
|
9025
9024
|
placeholder = "Example Placeholder",
|
|
9026
9025
|
name,
|
|
9026
|
+
value,
|
|
9027
|
+
// Added value prop for controlled usage
|
|
9027
9028
|
onChange
|
|
9028
9029
|
} = _ref;
|
|
9029
9030
|
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'}`;
|
|
9031
|
+
const handleItemClick = item => {
|
|
9032
|
+
// Call the onChange function if provided
|
|
9033
|
+
if (onChange) {
|
|
9034
|
+
onChange(item.value); // Pass the value of the item
|
|
9035
|
+
}
|
|
9036
|
+
// If there's an onClick function for the item, call it
|
|
9037
|
+
if (item.onClick) {
|
|
9038
|
+
item.onClick();
|
|
9039
|
+
}
|
|
9040
|
+
};
|
|
9030
9041
|
return /*#__PURE__*/external_react_default().createElement(rn, {
|
|
9031
9042
|
as: "div",
|
|
9032
9043
|
className: "relative inline-block text-left",
|
|
9033
9044
|
name: name
|
|
9034
9045
|
}, /*#__PURE__*/external_react_default().createElement("label", null, label), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
|
|
9035
9046
|
className: inputClasses
|
|
9036
|
-
}, placeholder, /*#__PURE__*/external_react_default().createElement(esm_ChevronDownIcon, {
|
|
9047
|
+
}, value || placeholder, " ", /*#__PURE__*/external_react_default().createElement(esm_ChevronDownIcon, {
|
|
9037
9048
|
"aria-hidden": "true",
|
|
9038
9049
|
className: "-mr-1 h-5 w-5 text-gray-400"
|
|
9039
9050
|
}))), /*#__PURE__*/external_react_default().createElement(gt, {
|
|
9040
9051
|
transition: true,
|
|
9041
|
-
className: "absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 transition focus:outline-none
|
|
9052
|
+
className: "absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 transition focus:outline-none"
|
|
9042
9053
|
}, /*#__PURE__*/external_react_default().createElement("div", {
|
|
9043
9054
|
className: "py-1"
|
|
9044
9055
|
}, items.map((item, index) => /*#__PURE__*/external_react_default().createElement(Et, {
|
|
@@ -9047,16 +9058,14 @@ function Dropdown(_ref) {
|
|
|
9047
9058
|
let {
|
|
9048
9059
|
active
|
|
9049
9060
|
} = _ref2;
|
|
9050
|
-
return
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
}, item.label) : /*#__PURE__*/external_react_default().createElement("button", {
|
|
9054
|
-
onClick: item.onClick,
|
|
9061
|
+
return /*#__PURE__*/external_react_default().createElement("button", {
|
|
9062
|
+
onClick: () => handleItemClick(item) // Handle item click
|
|
9063
|
+
,
|
|
9055
9064
|
className: `block w-full px-4 py-2 text-left text-sm text-gray-700 ${active ? 'bg-gray-100 text-gray-900' : ''}`
|
|
9056
9065
|
}, item.label);
|
|
9057
9066
|
})))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
|
|
9058
9067
|
className: "text-rose-500 text-sm"
|
|
9059
|
-
}));
|
|
9068
|
+
}, "Invalid selection!"));
|
|
9060
9069
|
}
|
|
9061
9070
|
;// ./src/index.js
|
|
9062
9071
|
|
|
@@ -9071,4 +9080,4 @@ function Dropdown(_ref) {
|
|
|
9071
9080
|
/******/ })()
|
|
9072
9081
|
;
|
|
9073
9082
|
});
|
|
9074
|
-
//# sourceMappingURL=main.
|
|
9083
|
+
//# sourceMappingURL=main.44c465f9808a1ad16ef3.js.map
|