@x-plat/design-system 0.14.11 → 0.14.13
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.
- package/dist/components/Dropdown/index.cjs +32 -14
- package/dist/components/Dropdown/index.js +32 -14
- package/dist/components/PopOver/index.cjs +31 -14
- package/dist/components/PopOver/index.js +31 -14
- package/dist/components/Select/index.cjs +32 -14
- package/dist/components/Select/index.css +6 -4
- package/dist/components/Select/index.js +32 -14
- package/dist/components/TimePicker/index.cjs +30 -12
- package/dist/components/TimePicker/index.js +30 -12
- package/dist/components/index.cjs +35 -18
- package/dist/components/index.css +6 -4
- package/dist/components/index.js +35 -18
- package/dist/index.cjs +35 -18
- package/dist/index.css +6 -4
- package/dist/index.js +35 -18
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
24
24
|
const roomAbove = triggerRect.top - clip.top;
|
|
25
25
|
let direction;
|
|
26
26
|
let top;
|
|
27
|
+
let maxHeight = null;
|
|
27
28
|
if (popH <= roomBelow) {
|
|
28
29
|
direction = "bottom";
|
|
29
30
|
top = triggerRect.bottom;
|
|
@@ -31,38 +32,48 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
31
32
|
direction = "top";
|
|
32
33
|
top = triggerRect.top - popH;
|
|
33
34
|
} else {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
36
|
+
if (roomBelow >= roomAbove) {
|
|
37
|
+
direction = "bottom";
|
|
38
|
+
top = triggerRect.bottom;
|
|
39
|
+
} else {
|
|
40
|
+
direction = "top";
|
|
41
|
+
top = triggerRect.top - room;
|
|
42
|
+
}
|
|
43
|
+
maxHeight = room;
|
|
38
44
|
}
|
|
39
45
|
let left = triggerRect.left;
|
|
40
46
|
if (left + popW > clip.right - 8) {
|
|
41
47
|
left = triggerRect.right - popW;
|
|
42
48
|
}
|
|
43
49
|
if (left < clip.left + 8) left = clip.left + 8;
|
|
50
|
+
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
44
51
|
return {
|
|
45
52
|
direction,
|
|
46
53
|
top,
|
|
47
54
|
left,
|
|
55
|
+
maxHeight,
|
|
48
56
|
over: {
|
|
49
57
|
top: Math.max(0, clip.top - top),
|
|
50
58
|
right: Math.max(0, left + popW - clip.right),
|
|
51
|
-
bottom: Math.max(0, top +
|
|
59
|
+
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
52
60
|
left: Math.max(0, clip.left - left)
|
|
53
61
|
}
|
|
54
62
|
};
|
|
55
63
|
};
|
|
56
64
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
57
|
-
const [direction, setDirection] = React.useState("bottom");
|
|
58
65
|
const directionRef = React.useRef("bottom");
|
|
59
66
|
const sizeRef = React.useRef(null);
|
|
60
67
|
const scrollParentRef = React.useRef(null);
|
|
68
|
+
const placedRef = React.useRef(false);
|
|
61
69
|
const calculatePosition = React.useCallback((remeasure = false) => {
|
|
62
70
|
const pop = popRef.current;
|
|
63
71
|
if (!triggerRef.current || !pop) return;
|
|
64
72
|
if (remeasure || !sizeRef.current) {
|
|
65
|
-
sizeRef.current = {
|
|
73
|
+
sizeRef.current = {
|
|
74
|
+
w: pop.offsetWidth,
|
|
75
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
76
|
+
};
|
|
66
77
|
}
|
|
67
78
|
const { w: popW, h: popH } = sizeRef.current;
|
|
68
79
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
@@ -77,7 +88,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
77
88
|
left: Math.max(parentRect?.left ?? 0, 0),
|
|
78
89
|
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
79
90
|
};
|
|
80
|
-
const
|
|
91
|
+
const first = !placedRef.current;
|
|
92
|
+
if (first) pop.style.transition = "none";
|
|
93
|
+
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
81
94
|
triggerRect,
|
|
82
95
|
popW,
|
|
83
96
|
popH,
|
|
@@ -85,16 +98,22 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
85
98
|
);
|
|
86
99
|
pop.style.top = `${top + window.scrollY}px`;
|
|
87
100
|
pop.style.left = `${left + window.scrollX}px`;
|
|
101
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
88
102
|
pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
directionRef.current = next;
|
|
104
|
+
pop.classList.toggle("top", next === "top");
|
|
105
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
106
|
+
if (first) {
|
|
107
|
+
void pop.offsetHeight;
|
|
108
|
+
pop.style.transition = "";
|
|
109
|
+
placedRef.current = true;
|
|
92
110
|
}
|
|
93
111
|
}, [triggerRef, popRef]);
|
|
94
112
|
React.useLayoutEffect(() => {
|
|
95
113
|
if (!enabled) {
|
|
96
114
|
sizeRef.current = null;
|
|
97
115
|
scrollParentRef.current = null;
|
|
116
|
+
placedRef.current = false;
|
|
98
117
|
return;
|
|
99
118
|
}
|
|
100
119
|
if (triggerRef.current) {
|
|
@@ -123,7 +142,6 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
123
142
|
window.removeEventListener("scroll", onScroll, true);
|
|
124
143
|
};
|
|
125
144
|
}, [calculatePosition, enabled]);
|
|
126
|
-
return { direction };
|
|
127
145
|
};
|
|
128
146
|
var useAutoPosition_default = useAutoPosition;
|
|
129
147
|
|
|
@@ -1353,7 +1371,7 @@ var SelectRoot = (props) => {
|
|
|
1353
1371
|
close();
|
|
1354
1372
|
triggerRef.current?.focus({ preventScroll: true });
|
|
1355
1373
|
});
|
|
1356
|
-
|
|
1374
|
+
useAutoPosition_default(triggerRef, contentRef, mounted);
|
|
1357
1375
|
const setSelected = React6.useCallback(
|
|
1358
1376
|
(label2, itemValue) => {
|
|
1359
1377
|
if (!isControlled) {
|
|
@@ -1446,7 +1464,7 @@ var SelectRoot = (props) => {
|
|
|
1446
1464
|
mounted && /* @__PURE__ */ jsx297(Portal_default, { children: /* @__PURE__ */ jsxs190(
|
|
1447
1465
|
"div",
|
|
1448
1466
|
{
|
|
1449
|
-
className: clsx_default("lib-xplat-select-content", size,
|
|
1467
|
+
className: clsx_default("lib-xplat-select-content", size, stateClass),
|
|
1450
1468
|
ref: contentRef,
|
|
1451
1469
|
style: { width: triggerRef.current?.offsetWidth },
|
|
1452
1470
|
role: "listbox",
|
|
@@ -60,6 +60,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
60
60
|
const roomAbove = triggerRect.top - clip.top;
|
|
61
61
|
let direction;
|
|
62
62
|
let top;
|
|
63
|
+
let maxHeight = null;
|
|
63
64
|
if (popH <= roomBelow) {
|
|
64
65
|
direction = "bottom";
|
|
65
66
|
top = triggerRect.bottom;
|
|
@@ -67,38 +68,48 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
67
68
|
direction = "top";
|
|
68
69
|
top = triggerRect.top - popH;
|
|
69
70
|
} else {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
72
|
+
if (roomBelow >= roomAbove) {
|
|
73
|
+
direction = "bottom";
|
|
74
|
+
top = triggerRect.bottom;
|
|
75
|
+
} else {
|
|
76
|
+
direction = "top";
|
|
77
|
+
top = triggerRect.top - room;
|
|
78
|
+
}
|
|
79
|
+
maxHeight = room;
|
|
74
80
|
}
|
|
75
81
|
let left = triggerRect.left;
|
|
76
82
|
if (left + popW > clip.right - 8) {
|
|
77
83
|
left = triggerRect.right - popW;
|
|
78
84
|
}
|
|
79
85
|
if (left < clip.left + 8) left = clip.left + 8;
|
|
86
|
+
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
80
87
|
return {
|
|
81
88
|
direction,
|
|
82
89
|
top,
|
|
83
90
|
left,
|
|
91
|
+
maxHeight,
|
|
84
92
|
over: {
|
|
85
93
|
top: Math.max(0, clip.top - top),
|
|
86
94
|
right: Math.max(0, left + popW - clip.right),
|
|
87
|
-
bottom: Math.max(0, top +
|
|
95
|
+
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
88
96
|
left: Math.max(0, clip.left - left)
|
|
89
97
|
}
|
|
90
98
|
};
|
|
91
99
|
};
|
|
92
100
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
93
|
-
const [direction, setDirection] = import_react.default.useState("bottom");
|
|
94
101
|
const directionRef = import_react.default.useRef("bottom");
|
|
95
102
|
const sizeRef = import_react.default.useRef(null);
|
|
96
103
|
const scrollParentRef = import_react.default.useRef(null);
|
|
104
|
+
const placedRef = import_react.default.useRef(false);
|
|
97
105
|
const calculatePosition = import_react.default.useCallback((remeasure = false) => {
|
|
98
106
|
const pop = popRef.current;
|
|
99
107
|
if (!triggerRef.current || !pop) return;
|
|
100
108
|
if (remeasure || !sizeRef.current) {
|
|
101
|
-
sizeRef.current = {
|
|
109
|
+
sizeRef.current = {
|
|
110
|
+
w: pop.offsetWidth,
|
|
111
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
112
|
+
};
|
|
102
113
|
}
|
|
103
114
|
const { w: popW, h: popH } = sizeRef.current;
|
|
104
115
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
@@ -113,7 +124,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
113
124
|
left: Math.max(parentRect?.left ?? 0, 0),
|
|
114
125
|
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
115
126
|
};
|
|
116
|
-
const
|
|
127
|
+
const first = !placedRef.current;
|
|
128
|
+
if (first) pop.style.transition = "none";
|
|
129
|
+
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
117
130
|
triggerRect,
|
|
118
131
|
popW,
|
|
119
132
|
popH,
|
|
@@ -121,16 +134,22 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
121
134
|
);
|
|
122
135
|
pop.style.top = `${top + window.scrollY}px`;
|
|
123
136
|
pop.style.left = `${left + window.scrollX}px`;
|
|
137
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
124
138
|
pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
139
|
+
directionRef.current = next;
|
|
140
|
+
pop.classList.toggle("top", next === "top");
|
|
141
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
142
|
+
if (first) {
|
|
143
|
+
void pop.offsetHeight;
|
|
144
|
+
pop.style.transition = "";
|
|
145
|
+
placedRef.current = true;
|
|
128
146
|
}
|
|
129
147
|
}, [triggerRef, popRef]);
|
|
130
148
|
import_react.default.useLayoutEffect(() => {
|
|
131
149
|
if (!enabled) {
|
|
132
150
|
sizeRef.current = null;
|
|
133
151
|
scrollParentRef.current = null;
|
|
152
|
+
placedRef.current = false;
|
|
134
153
|
return;
|
|
135
154
|
}
|
|
136
155
|
if (triggerRef.current) {
|
|
@@ -159,7 +178,6 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
159
178
|
window.removeEventListener("scroll", onScroll, true);
|
|
160
179
|
};
|
|
161
180
|
}, [calculatePosition, enabled]);
|
|
162
|
-
return { direction };
|
|
163
181
|
};
|
|
164
182
|
var useAutoPosition_default = useAutoPosition;
|
|
165
183
|
|
|
@@ -24,6 +24,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
24
24
|
const roomAbove = triggerRect.top - clip.top;
|
|
25
25
|
let direction;
|
|
26
26
|
let top;
|
|
27
|
+
let maxHeight = null;
|
|
27
28
|
if (popH <= roomBelow) {
|
|
28
29
|
direction = "bottom";
|
|
29
30
|
top = triggerRect.bottom;
|
|
@@ -31,38 +32,48 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
31
32
|
direction = "top";
|
|
32
33
|
top = triggerRect.top - popH;
|
|
33
34
|
} else {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
36
|
+
if (roomBelow >= roomAbove) {
|
|
37
|
+
direction = "bottom";
|
|
38
|
+
top = triggerRect.bottom;
|
|
39
|
+
} else {
|
|
40
|
+
direction = "top";
|
|
41
|
+
top = triggerRect.top - room;
|
|
42
|
+
}
|
|
43
|
+
maxHeight = room;
|
|
38
44
|
}
|
|
39
45
|
let left = triggerRect.left;
|
|
40
46
|
if (left + popW > clip.right - 8) {
|
|
41
47
|
left = triggerRect.right - popW;
|
|
42
48
|
}
|
|
43
49
|
if (left < clip.left + 8) left = clip.left + 8;
|
|
50
|
+
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
44
51
|
return {
|
|
45
52
|
direction,
|
|
46
53
|
top,
|
|
47
54
|
left,
|
|
55
|
+
maxHeight,
|
|
48
56
|
over: {
|
|
49
57
|
top: Math.max(0, clip.top - top),
|
|
50
58
|
right: Math.max(0, left + popW - clip.right),
|
|
51
|
-
bottom: Math.max(0, top +
|
|
59
|
+
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
52
60
|
left: Math.max(0, clip.left - left)
|
|
53
61
|
}
|
|
54
62
|
};
|
|
55
63
|
};
|
|
56
64
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
57
|
-
const [direction, setDirection] = React.useState("bottom");
|
|
58
65
|
const directionRef = React.useRef("bottom");
|
|
59
66
|
const sizeRef = React.useRef(null);
|
|
60
67
|
const scrollParentRef = React.useRef(null);
|
|
68
|
+
const placedRef = React.useRef(false);
|
|
61
69
|
const calculatePosition = React.useCallback((remeasure = false) => {
|
|
62
70
|
const pop = popRef.current;
|
|
63
71
|
if (!triggerRef.current || !pop) return;
|
|
64
72
|
if (remeasure || !sizeRef.current) {
|
|
65
|
-
sizeRef.current = {
|
|
73
|
+
sizeRef.current = {
|
|
74
|
+
w: pop.offsetWidth,
|
|
75
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
76
|
+
};
|
|
66
77
|
}
|
|
67
78
|
const { w: popW, h: popH } = sizeRef.current;
|
|
68
79
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
@@ -77,7 +88,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
77
88
|
left: Math.max(parentRect?.left ?? 0, 0),
|
|
78
89
|
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
79
90
|
};
|
|
80
|
-
const
|
|
91
|
+
const first = !placedRef.current;
|
|
92
|
+
if (first) pop.style.transition = "none";
|
|
93
|
+
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
81
94
|
triggerRect,
|
|
82
95
|
popW,
|
|
83
96
|
popH,
|
|
@@ -85,16 +98,22 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
85
98
|
);
|
|
86
99
|
pop.style.top = `${top + window.scrollY}px`;
|
|
87
100
|
pop.style.left = `${left + window.scrollX}px`;
|
|
101
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
88
102
|
pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
directionRef.current = next;
|
|
104
|
+
pop.classList.toggle("top", next === "top");
|
|
105
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
106
|
+
if (first) {
|
|
107
|
+
void pop.offsetHeight;
|
|
108
|
+
pop.style.transition = "";
|
|
109
|
+
placedRef.current = true;
|
|
92
110
|
}
|
|
93
111
|
}, [triggerRef, popRef]);
|
|
94
112
|
React.useLayoutEffect(() => {
|
|
95
113
|
if (!enabled) {
|
|
96
114
|
sizeRef.current = null;
|
|
97
115
|
scrollParentRef.current = null;
|
|
116
|
+
placedRef.current = false;
|
|
98
117
|
return;
|
|
99
118
|
}
|
|
100
119
|
if (triggerRef.current) {
|
|
@@ -123,7 +142,6 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
123
142
|
window.removeEventListener("scroll", onScroll, true);
|
|
124
143
|
};
|
|
125
144
|
}, [calculatePosition, enabled]);
|
|
126
|
-
return { direction };
|
|
127
145
|
};
|
|
128
146
|
var useAutoPosition_default = useAutoPosition;
|
|
129
147
|
|
|
@@ -4004,6 +4004,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
4004
4004
|
const roomAbove = triggerRect.top - clip.top;
|
|
4005
4005
|
let direction;
|
|
4006
4006
|
let top;
|
|
4007
|
+
let maxHeight = null;
|
|
4007
4008
|
if (popH <= roomBelow) {
|
|
4008
4009
|
direction = "bottom";
|
|
4009
4010
|
top = triggerRect.bottom;
|
|
@@ -4011,38 +4012,48 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
4011
4012
|
direction = "top";
|
|
4012
4013
|
top = triggerRect.top - popH;
|
|
4013
4014
|
} else {
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4015
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
4016
|
+
if (roomBelow >= roomAbove) {
|
|
4017
|
+
direction = "bottom";
|
|
4018
|
+
top = triggerRect.bottom;
|
|
4019
|
+
} else {
|
|
4020
|
+
direction = "top";
|
|
4021
|
+
top = triggerRect.top - room;
|
|
4022
|
+
}
|
|
4023
|
+
maxHeight = room;
|
|
4018
4024
|
}
|
|
4019
4025
|
let left = triggerRect.left;
|
|
4020
4026
|
if (left + popW > clip.right - 8) {
|
|
4021
4027
|
left = triggerRect.right - popW;
|
|
4022
4028
|
}
|
|
4023
4029
|
if (left < clip.left + 8) left = clip.left + 8;
|
|
4030
|
+
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
4024
4031
|
return {
|
|
4025
4032
|
direction,
|
|
4026
4033
|
top,
|
|
4027
4034
|
left,
|
|
4035
|
+
maxHeight,
|
|
4028
4036
|
over: {
|
|
4029
4037
|
top: Math.max(0, clip.top - top),
|
|
4030
4038
|
right: Math.max(0, left + popW - clip.right),
|
|
4031
|
-
bottom: Math.max(0, top +
|
|
4039
|
+
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
4032
4040
|
left: Math.max(0, clip.left - left)
|
|
4033
4041
|
}
|
|
4034
4042
|
};
|
|
4035
4043
|
};
|
|
4036
4044
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
4037
|
-
const [direction, setDirection] = import_react19.default.useState("bottom");
|
|
4038
4045
|
const directionRef = import_react19.default.useRef("bottom");
|
|
4039
4046
|
const sizeRef = import_react19.default.useRef(null);
|
|
4040
4047
|
const scrollParentRef = import_react19.default.useRef(null);
|
|
4048
|
+
const placedRef = import_react19.default.useRef(false);
|
|
4041
4049
|
const calculatePosition = import_react19.default.useCallback((remeasure = false) => {
|
|
4042
4050
|
const pop = popRef.current;
|
|
4043
4051
|
if (!triggerRef.current || !pop) return;
|
|
4044
4052
|
if (remeasure || !sizeRef.current) {
|
|
4045
|
-
sizeRef.current = {
|
|
4053
|
+
sizeRef.current = {
|
|
4054
|
+
w: pop.offsetWidth,
|
|
4055
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
4056
|
+
};
|
|
4046
4057
|
}
|
|
4047
4058
|
const { w: popW, h: popH } = sizeRef.current;
|
|
4048
4059
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
@@ -4057,7 +4068,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
4057
4068
|
left: Math.max(parentRect?.left ?? 0, 0),
|
|
4058
4069
|
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
4059
4070
|
};
|
|
4060
|
-
const
|
|
4071
|
+
const first = !placedRef.current;
|
|
4072
|
+
if (first) pop.style.transition = "none";
|
|
4073
|
+
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
4061
4074
|
triggerRect,
|
|
4062
4075
|
popW,
|
|
4063
4076
|
popH,
|
|
@@ -4065,16 +4078,22 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
4065
4078
|
);
|
|
4066
4079
|
pop.style.top = `${top + window.scrollY}px`;
|
|
4067
4080
|
pop.style.left = `${left + window.scrollX}px`;
|
|
4081
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
4068
4082
|
pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4083
|
+
directionRef.current = next;
|
|
4084
|
+
pop.classList.toggle("top", next === "top");
|
|
4085
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
4086
|
+
if (first) {
|
|
4087
|
+
void pop.offsetHeight;
|
|
4088
|
+
pop.style.transition = "";
|
|
4089
|
+
placedRef.current = true;
|
|
4072
4090
|
}
|
|
4073
4091
|
}, [triggerRef, popRef]);
|
|
4074
4092
|
import_react19.default.useLayoutEffect(() => {
|
|
4075
4093
|
if (!enabled) {
|
|
4076
4094
|
sizeRef.current = null;
|
|
4077
4095
|
scrollParentRef.current = null;
|
|
4096
|
+
placedRef.current = false;
|
|
4078
4097
|
return;
|
|
4079
4098
|
}
|
|
4080
4099
|
if (triggerRef.current) {
|
|
@@ -4103,7 +4122,6 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
4103
4122
|
window.removeEventListener("scroll", onScroll, true);
|
|
4104
4123
|
};
|
|
4105
4124
|
}, [calculatePosition, enabled]);
|
|
4106
|
-
return { direction };
|
|
4107
4125
|
};
|
|
4108
4126
|
var useAutoPosition_default = useAutoPosition;
|
|
4109
4127
|
|
|
@@ -4141,7 +4159,7 @@ var Dropdown = (props) => {
|
|
|
4141
4159
|
const [visible, setVisible] = import_react21.default.useState(false);
|
|
4142
4160
|
const triggerRef = import_react21.default.useRef(null);
|
|
4143
4161
|
const menuRef = import_react21.default.useRef(null);
|
|
4144
|
-
|
|
4162
|
+
useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
4145
4163
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
4146
4164
|
useCloseOnContainerScroll(isOpen, menuRef, () => setIsOpen(false));
|
|
4147
4165
|
useEscapeKey(isOpen, () => {
|
|
@@ -4177,7 +4195,7 @@ var Dropdown = (props) => {
|
|
|
4177
4195
|
"div",
|
|
4178
4196
|
{
|
|
4179
4197
|
ref: menuRef,
|
|
4180
|
-
className: clsx_default("lib-xplat-dropdown-menu",
|
|
4198
|
+
className: clsx_default("lib-xplat-dropdown-menu", { visible }),
|
|
4181
4199
|
role: "menu",
|
|
4182
4200
|
children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
|
|
4183
4201
|
"button",
|
|
@@ -6079,7 +6097,7 @@ var PopOver = (props) => {
|
|
|
6079
6097
|
onClose();
|
|
6080
6098
|
triggerRef.current?.focus({ preventScroll: true });
|
|
6081
6099
|
});
|
|
6082
|
-
|
|
6100
|
+
useAutoPosition_default(triggerRef, popRef, localOpen);
|
|
6083
6101
|
import_react27.default.useEffect(() => {
|
|
6084
6102
|
if (isOpen) {
|
|
6085
6103
|
setLocalOpen(isOpen);
|
|
@@ -6108,7 +6126,6 @@ var PopOver = (props) => {
|
|
|
6108
6126
|
{
|
|
6109
6127
|
className: clsx_default(
|
|
6110
6128
|
"lib-xplat-pop-over-content",
|
|
6111
|
-
position.direction,
|
|
6112
6129
|
eventTrigger && "visible"
|
|
6113
6130
|
),
|
|
6114
6131
|
ref: popRef,
|
|
@@ -6360,7 +6377,7 @@ var SelectRoot = (props) => {
|
|
|
6360
6377
|
close();
|
|
6361
6378
|
triggerRef.current?.focus({ preventScroll: true });
|
|
6362
6379
|
});
|
|
6363
|
-
|
|
6380
|
+
useAutoPosition_default(triggerRef, contentRef, mounted);
|
|
6364
6381
|
const setSelected = import_react31.default.useCallback(
|
|
6365
6382
|
(label2, itemValue) => {
|
|
6366
6383
|
if (!isControlled) {
|
|
@@ -6453,7 +6470,7 @@ var SelectRoot = (props) => {
|
|
|
6453
6470
|
mounted && /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime337.jsxs)(
|
|
6454
6471
|
"div",
|
|
6455
6472
|
{
|
|
6456
|
-
className: clsx_default("lib-xplat-select-content", size,
|
|
6473
|
+
className: clsx_default("lib-xplat-select-content", size, stateClass),
|
|
6457
6474
|
ref: contentRef,
|
|
6458
6475
|
style: { width: triggerRef.current?.offsetWidth },
|
|
6459
6476
|
role: "listbox",
|
|
@@ -4513,7 +4513,7 @@
|
|
|
4513
4513
|
transition: transform 0.2s ease, opacity 0.2s ease;
|
|
4514
4514
|
}
|
|
4515
4515
|
.lib-xplat-select-content.bottom {
|
|
4516
|
-
transform: translateY(
|
|
4516
|
+
transform: translateY(8px);
|
|
4517
4517
|
}
|
|
4518
4518
|
.lib-xplat-select-content.bottom.visible {
|
|
4519
4519
|
opacity: 1;
|
|
@@ -4521,10 +4521,12 @@
|
|
|
4521
4521
|
}
|
|
4522
4522
|
.lib-xplat-select-content.bottom.exit {
|
|
4523
4523
|
opacity: 0;
|
|
4524
|
-
transform: translateY(
|
|
4524
|
+
transform: translateY(8px);
|
|
4525
|
+
}
|
|
4526
|
+
.lib-xplat-select-content {
|
|
4525
4527
|
}
|
|
4526
4528
|
.lib-xplat-select-content.top {
|
|
4527
|
-
transform: translateY(8px);
|
|
4529
|
+
transform: translateY(-8px);
|
|
4528
4530
|
}
|
|
4529
4531
|
.lib-xplat-select-content.top.visible {
|
|
4530
4532
|
opacity: 1;
|
|
@@ -4532,7 +4534,7 @@
|
|
|
4532
4534
|
}
|
|
4533
4535
|
.lib-xplat-select-content.top.exit {
|
|
4534
4536
|
opacity: 0;
|
|
4535
|
-
transform: translateY(8px);
|
|
4537
|
+
transform: translateY(-8px);
|
|
4536
4538
|
}
|
|
4537
4539
|
.lib-xplat-select-content.sm .select-item {
|
|
4538
4540
|
padding: var(--spacing-space-2) var(--spacing-space-2);
|