opus-toolkit-components 1.1.2 → 1.1.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.
|
@@ -12701,7 +12701,7 @@ const esm_ChevronDownIcon_ForwardRef = /*#__PURE__*/ external_react_.forwardRef(
|
|
|
12701
12701
|
|
|
12702
12702
|
function Dropdown(_ref) {
|
|
12703
12703
|
let {
|
|
12704
|
-
items,
|
|
12704
|
+
items = [],
|
|
12705
12705
|
label = 'Test Label',
|
|
12706
12706
|
isValid = true,
|
|
12707
12707
|
required = false,
|
|
@@ -12712,21 +12712,17 @@ function Dropdown(_ref) {
|
|
|
12712
12712
|
tabIndex = '',
|
|
12713
12713
|
onChange,
|
|
12714
12714
|
value,
|
|
12715
|
+
// Controlled from parent
|
|
12715
12716
|
Icon,
|
|
12716
12717
|
errorMessage = 'This field is required',
|
|
12717
12718
|
disabled = false,
|
|
12718
|
-
dataCy
|
|
12719
|
+
dataCy
|
|
12719
12720
|
} = _ref;
|
|
12720
|
-
const [selectedItem, setSelectedItem] = (0,external_react_.useState)(null);
|
|
12721
12721
|
const [isOpen, setIsOpen] = (0,external_react_.useState)(false);
|
|
12722
|
-
|
|
12723
|
-
const newSelectedItem = items.find(item => item.value === value) || null;
|
|
12724
|
-
setSelectedItem(newSelectedItem);
|
|
12725
|
-
}, [value, items]);
|
|
12722
|
+
const selectedItem = items.find(item => item.value === value) || null;
|
|
12726
12723
|
const inputClasses = "inline-flex w-full justify-between items-center rounded-md bg-[--color-input-bg] text-md font-normal border p-2 text-[--color-text-weak] ".concat(isValid ? 'border-[--color-stroke]' : 'border-utilRed1000', " ").concat(disabled ? 'opacity-50 cursor-not-allowed' : '', " ").concat(className);
|
|
12727
12724
|
const handleSelect = item => {
|
|
12728
|
-
if (disabled) return;
|
|
12729
|
-
setSelectedItem(item);
|
|
12725
|
+
if (disabled || item.value === value) return; // prevent repeat calls
|
|
12730
12726
|
const event = {
|
|
12731
12727
|
target: {
|
|
12732
12728
|
name,
|
|
@@ -12776,7 +12772,7 @@ function Dropdown(_ref) {
|
|
|
12776
12772
|
return /*#__PURE__*/external_react_default().createElement("button", {
|
|
12777
12773
|
type: "button",
|
|
12778
12774
|
onClick: () => handleSelect(item),
|
|
12779
|
-
className: "block w-full px-4 py-2 text-left text-sm text-[--color-text-weak] ".concat(active ? 'bg-[--color-input-bg]
|
|
12775
|
+
className: "block w-full px-4 py-2 text-left text-sm text-[--color-text-weak] ".concat(active ? 'bg-[--color-input-bg]' : '', " hover:bg-[--color-input-bg]")
|
|
12780
12776
|
}, item.label);
|
|
12781
12777
|
})))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
|
|
12782
12778
|
className: "text-utilRed1000 text-sm"
|
|
@@ -13003,4 +12999,4 @@ const CookieBanner = _ref => {
|
|
|
13003
12999
|
/******/ })()
|
|
13004
13000
|
;
|
|
13005
13001
|
});
|
|
13006
|
-
//# sourceMappingURL=main.
|
|
13002
|
+
//# sourceMappingURL=main.e0a995fbb7814fd5f6d3.js.map
|