opus-toolkit-components 0.2.3 → 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.
|
@@ -722,7 +722,8 @@ function Input(_ref) {
|
|
|
722
722
|
name,
|
|
723
723
|
isValid = true,
|
|
724
724
|
errorMessage = `${label} is required`,
|
|
725
|
-
onChange
|
|
725
|
+
onChange,
|
|
726
|
+
value
|
|
726
727
|
} = _ref;
|
|
727
728
|
const inputClasses = `rounded-md bg-white border px-4 py-3 text-md font-normal text-gray-900 ${isValid ? 'border-slate-500' : 'border-rose-500'}`;
|
|
728
729
|
return /*#__PURE__*/external_react_default().createElement("div", {
|
|
@@ -732,7 +733,8 @@ function Input(_ref) {
|
|
|
732
733
|
type: type,
|
|
733
734
|
name: name,
|
|
734
735
|
placeholder: placeholder,
|
|
735
|
-
onChange: onChange
|
|
736
|
+
onChange: onChange,
|
|
737
|
+
value: value
|
|
736
738
|
}), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
|
|
737
739
|
className: "text-rose-500 text-sm"
|
|
738
740
|
}, errorMessage));
|
|
@@ -8995,15 +8997,15 @@ const ForwardRef = /*#__PURE__*/ external_react_.forwardRef(ChevronDownIcon);
|
|
|
8995
8997
|
|
|
8996
8998
|
/*
|
|
8997
8999
|
|
|
8998
|
-
Usage:
|
|
9000
|
+
Usage Example:
|
|
8999
9001
|
|
|
9000
9002
|
import Dropdown from './Dropdown';
|
|
9001
9003
|
|
|
9002
9004
|
const menuItems = [
|
|
9003
|
-
{ label: 'Account settings',
|
|
9004
|
-
{ label: 'Support',
|
|
9005
|
-
{ label: 'License',
|
|
9006
|
-
{ 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!') },
|
|
9007
9009
|
];
|
|
9008
9010
|
|
|
9009
9011
|
function App() {
|
|
@@ -9012,7 +9014,6 @@ const ForwardRef = /*#__PURE__*/ external_react_.forwardRef(ChevronDownIcon);
|
|
|
9012
9014
|
|
|
9013
9015
|
export default App;
|
|
9014
9016
|
|
|
9015
|
-
|
|
9016
9017
|
*/
|
|
9017
9018
|
|
|
9018
9019
|
function Dropdown(_ref) {
|
|
@@ -9022,21 +9023,33 @@ function Dropdown(_ref) {
|
|
|
9022
9023
|
isValid = true,
|
|
9023
9024
|
placeholder = "Example Placeholder",
|
|
9024
9025
|
name,
|
|
9026
|
+
value,
|
|
9027
|
+
// Added value prop for controlled usage
|
|
9025
9028
|
onChange
|
|
9026
9029
|
} = _ref;
|
|
9027
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
|
+
};
|
|
9028
9041
|
return /*#__PURE__*/external_react_default().createElement(rn, {
|
|
9029
9042
|
as: "div",
|
|
9030
9043
|
className: "relative inline-block text-left",
|
|
9031
9044
|
name: name
|
|
9032
9045
|
}, /*#__PURE__*/external_react_default().createElement("label", null, label), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
|
|
9033
9046
|
className: inputClasses
|
|
9034
|
-
}, placeholder, /*#__PURE__*/external_react_default().createElement(esm_ChevronDownIcon, {
|
|
9047
|
+
}, value || placeholder, " ", /*#__PURE__*/external_react_default().createElement(esm_ChevronDownIcon, {
|
|
9035
9048
|
"aria-hidden": "true",
|
|
9036
9049
|
className: "-mr-1 h-5 w-5 text-gray-400"
|
|
9037
9050
|
}))), /*#__PURE__*/external_react_default().createElement(gt, {
|
|
9038
9051
|
transition: true,
|
|
9039
|
-
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"
|
|
9040
9053
|
}, /*#__PURE__*/external_react_default().createElement("div", {
|
|
9041
9054
|
className: "py-1"
|
|
9042
9055
|
}, items.map((item, index) => /*#__PURE__*/external_react_default().createElement(Et, {
|
|
@@ -9045,16 +9058,14 @@ function Dropdown(_ref) {
|
|
|
9045
9058
|
let {
|
|
9046
9059
|
active
|
|
9047
9060
|
} = _ref2;
|
|
9048
|
-
return
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
}, item.label) : /*#__PURE__*/external_react_default().createElement("button", {
|
|
9052
|
-
onClick: item.onClick,
|
|
9061
|
+
return /*#__PURE__*/external_react_default().createElement("button", {
|
|
9062
|
+
onClick: () => handleItemClick(item) // Handle item click
|
|
9063
|
+
,
|
|
9053
9064
|
className: `block w-full px-4 py-2 text-left text-sm text-gray-700 ${active ? 'bg-gray-100 text-gray-900' : ''}`
|
|
9054
9065
|
}, item.label);
|
|
9055
9066
|
})))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
|
|
9056
9067
|
className: "text-rose-500 text-sm"
|
|
9057
|
-
}));
|
|
9068
|
+
}, "Invalid selection!"));
|
|
9058
9069
|
}
|
|
9059
9070
|
;// ./src/index.js
|
|
9060
9071
|
|
|
@@ -9069,4 +9080,4 @@ function Dropdown(_ref) {
|
|
|
9069
9080
|
/******/ })()
|
|
9070
9081
|
;
|
|
9071
9082
|
});
|
|
9072
|
-
//# sourceMappingURL=main.
|
|
9083
|
+
//# sourceMappingURL=main.44c465f9808a1ad16ef3.js.map
|