allaw-ui 1.0.88 → 1.0.90
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.
|
@@ -45,12 +45,8 @@
|
|
|
45
45
|
|
|
46
46
|
.select-list {
|
|
47
47
|
position: absolute;
|
|
48
|
-
top: 100%;
|
|
49
|
-
left: 0;
|
|
50
|
-
right: 0;
|
|
51
48
|
display: flex;
|
|
52
49
|
flex-direction: column;
|
|
53
|
-
/* background: var(--secondary-light-grey, #f4f7fb); */
|
|
54
50
|
background: #fff;
|
|
55
51
|
border-radius: 8px;
|
|
56
52
|
padding: 8px 0;
|
|
@@ -66,9 +62,16 @@
|
|
|
66
62
|
border: 1px solid var(--grey-venom, #e6edf5);
|
|
67
63
|
box-shadow: 0px 4px 8px 0px rgba(9, 30, 66, 0.15);
|
|
68
64
|
scroll-behavior: auto;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.select-list.bottom {
|
|
69
68
|
margin-top: 4px;
|
|
70
69
|
}
|
|
71
70
|
|
|
71
|
+
.select-list.top {
|
|
72
|
+
margin-bottom: 4px;
|
|
73
|
+
}
|
|
74
|
+
|
|
72
75
|
.select-item {
|
|
73
76
|
display: flex;
|
|
74
77
|
align-items: center;
|
|
@@ -25,6 +25,7 @@ function Select(_a, ref) {
|
|
|
25
25
|
left: 0,
|
|
26
26
|
width: 0,
|
|
27
27
|
}), listPosition = _l[0], setListPosition = _l[1];
|
|
28
|
+
var _m = useState("bottom"), placement = _m[0], setPlacement = _m[1];
|
|
28
29
|
useEffect(function () {
|
|
29
30
|
setSelected((multiple ? selectedItem || [] : selectedItem || ""));
|
|
30
31
|
}, [selectedItem, multiple]);
|
|
@@ -66,9 +67,14 @@ function Select(_a, ref) {
|
|
|
66
67
|
var updateListPosition = function () {
|
|
67
68
|
if (selectRef.current) {
|
|
68
69
|
var rect = selectRef.current.getBoundingClientRect();
|
|
70
|
+
var windowHeight = window.innerHeight;
|
|
71
|
+
var listHeight = 300;
|
|
72
|
+
var spaceBelow = windowHeight - rect.bottom;
|
|
73
|
+
var shouldShowBelow = spaceBelow >= listHeight;
|
|
74
|
+
setPlacement(shouldShowBelow ? "bottom" : "top");
|
|
69
75
|
setListPosition({
|
|
70
|
-
top: rect.bottom +
|
|
71
|
-
left: rect.left
|
|
76
|
+
top: shouldShowBelow ? rect.bottom : rect.top - listHeight + 65, // 65px de marge au-dessus
|
|
77
|
+
left: rect.left,
|
|
72
78
|
width: rect.width,
|
|
73
79
|
});
|
|
74
80
|
}
|
|
@@ -98,7 +104,20 @@ function Select(_a, ref) {
|
|
|
98
104
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
99
105
|
};
|
|
100
106
|
}, [isOpen]);
|
|
101
|
-
|
|
107
|
+
useEffect(function () {
|
|
108
|
+
if (isOpen) {
|
|
109
|
+
var handleScroll_1 = function () {
|
|
110
|
+
updateListPosition();
|
|
111
|
+
};
|
|
112
|
+
window.addEventListener("scroll", handleScroll_1, true);
|
|
113
|
+
return function () {
|
|
114
|
+
window.removeEventListener("scroll", handleScroll_1, true);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return function () { };
|
|
118
|
+
}, [isOpen]);
|
|
119
|
+
var renderList = function () { return (React.createElement("div", { ref: listRef, className: "select-list ".concat(isOpen ? "visible" : "", " ").concat(placement), style: {
|
|
120
|
+
position: "fixed",
|
|
102
121
|
top: "".concat(listPosition.top, "px"),
|
|
103
122
|
left: "".concat(listPosition.left, "px"),
|
|
104
123
|
width: "".concat(listPosition.width, "px"),
|