ml-ui-lib 1.0.44 → 1.0.45
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.
|
@@ -81,3 +81,14 @@
|
|
|
81
81
|
.has-error .dropdown-trigger {
|
|
82
82
|
border-color: #ff4d4d;
|
|
83
83
|
}
|
|
84
|
+
|
|
85
|
+
.dropdown-trigger.disabled {
|
|
86
|
+
background: #f5f5f5;
|
|
87
|
+
color: #aaa;
|
|
88
|
+
cursor: not-allowed;
|
|
89
|
+
pointer-events: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.dropdown-wrapper.has-error .dropdown-trigger.disabled {
|
|
93
|
+
border-color: #ccc;
|
|
94
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useRef, useEffect } from "react";
|
|
3
3
|
import "./Dropdown.css";
|
|
4
|
-
export const Dropdown = ({ label, value, options, onChange, placeholder = "Select", className = "", error, }) => {
|
|
4
|
+
export const Dropdown = ({ label, value, options, onChange, placeholder = "Select", className = "", error, disabled }) => {
|
|
5
5
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
6
6
|
const dropdownRef = useRef(null);
|
|
7
7
|
useEffect(() => {
|
|
@@ -13,7 +13,17 @@ export const Dropdown = ({ label, value, options, onChange, placeholder = "Selec
|
|
|
13
13
|
document.addEventListener("mousedown", handleClickOutside);
|
|
14
14
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
15
15
|
}, []);
|
|
16
|
-
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (disabled)
|
|
18
|
+
setDropdownOpen(false);
|
|
19
|
+
}, [disabled]);
|
|
20
|
+
return (_jsxs("div", { className: `dropdown-wrapper ${className} ${error ? "has-error" : ""}`, ref: dropdownRef, children: [label && _jsx("label", { className: "dropdown-label", children: label }), _jsxs("div", { className: `dropdown-trigger ${disabled ? "disabled" : ""}`, onClick: () => {
|
|
21
|
+
if (disabled)
|
|
22
|
+
return;
|
|
23
|
+
setDropdownOpen(!dropdownOpen);
|
|
24
|
+
}, children: [_jsx("span", { className: "dropdown-value", children: value === "" ? placeholder : value }), _jsx("span", { className: "dropdown-caret", children: "\u25BC" })] }), dropdownOpen && (_jsx("div", { className: "dropdown-list scrollbar", children: options.length > 0 ? (options.map((option, i) => (_jsx("div", { className: `dropdown-option ${value === option ? "selected" : ""}`, onClick: () => {
|
|
25
|
+
if (disabled)
|
|
26
|
+
return;
|
|
17
27
|
onChange(option);
|
|
18
28
|
setDropdownOpen(false);
|
|
19
29
|
}, children: option }, i)))) : (_jsx("div", { className: "dropdown-empty", children: "No options" })) })), error && _jsx("span", { className: "dropdown-error", children: error })] }));
|
|
@@ -92,11 +92,12 @@
|
|
|
92
92
|
flex-direction: row;
|
|
93
93
|
background-color: #f5f5f5;
|
|
94
94
|
box-shadow: 0 1px 10px #00000017;
|
|
95
|
+
border: .7px solid #ececec;
|
|
95
96
|
border-radius: 20px;
|
|
96
97
|
padding: 15px;
|
|
97
98
|
gap: 15px 40px;
|
|
98
99
|
align-items: center;
|
|
99
|
-
width:
|
|
100
|
+
width: 352px;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
.navbar-services-item {
|