@x-plat/design-system 0.14.6 → 0.14.8
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 +41 -13
- package/dist/components/Dropdown/index.js +41 -13
- package/dist/components/PopOver/index.cjs +41 -13
- package/dist/components/PopOver/index.js +41 -13
- package/dist/components/Select/index.cjs +41 -13
- package/dist/components/Select/index.css +1 -0
- package/dist/components/Select/index.js +41 -13
- package/dist/components/TimePicker/index.cjs +41 -13
- package/dist/components/TimePicker/index.css +1 -0
- package/dist/components/TimePicker/index.js +41 -13
- package/dist/components/index.cjs +44 -13
- package/dist/components/index.css +2 -0
- package/dist/components/index.js +44 -13
- package/dist/index.cjs +44 -13
- package/dist/index.css +2 -0
- package/dist/index.js +44 -13
- package/guidelines/MIGRATION.md +37 -0
- package/package.json +1 -1
|
@@ -51,15 +51,21 @@ var import_react = __toESM(require("react"), 1);
|
|
|
51
51
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
52
52
|
const [direction, setDirection] = import_react.default.useState("bottom");
|
|
53
53
|
const directionRef = import_react.default.useRef("bottom");
|
|
54
|
-
const
|
|
54
|
+
const sizeRef = import_react.default.useRef(null);
|
|
55
|
+
const calculatePosition = import_react.default.useCallback((remeasure = false) => {
|
|
55
56
|
const pop = popRef.current;
|
|
56
57
|
if (!triggerRef.current || !pop) return;
|
|
58
|
+
if (remeasure || !sizeRef.current) {
|
|
59
|
+
sizeRef.current = { w: pop.offsetWidth, h: pop.offsetHeight };
|
|
60
|
+
}
|
|
61
|
+
const { w: popW, h: popH } = sizeRef.current;
|
|
57
62
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
58
|
-
const popW = pop.offsetWidth;
|
|
59
|
-
const popH = pop.offsetHeight;
|
|
60
63
|
const viewportHeight = window.innerHeight;
|
|
61
64
|
const viewportWidth = window.innerWidth;
|
|
62
|
-
if (popH === 0 || popW === 0)
|
|
65
|
+
if (popH === 0 || popW === 0) {
|
|
66
|
+
sizeRef.current = null;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
63
69
|
let next = "bottom";
|
|
64
70
|
let top;
|
|
65
71
|
let left;
|
|
@@ -82,27 +88,31 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
82
88
|
}
|
|
83
89
|
}, [triggerRef, popRef]);
|
|
84
90
|
import_react.default.useLayoutEffect(() => {
|
|
85
|
-
if (!enabled)
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
if (!enabled) {
|
|
92
|
+
sizeRef.current = null;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
calculatePosition(true);
|
|
96
|
+
const raf = requestAnimationFrame(() => calculatePosition(true));
|
|
88
97
|
return () => cancelAnimationFrame(raf);
|
|
89
98
|
}, [calculatePosition, enabled]);
|
|
90
99
|
import_react.default.useEffect(() => {
|
|
91
100
|
if (!enabled || !popRef.current) return;
|
|
92
101
|
const observer = new ResizeObserver(() => {
|
|
93
|
-
calculatePosition();
|
|
102
|
+
calculatePosition(true);
|
|
94
103
|
});
|
|
95
104
|
observer.observe(popRef.current);
|
|
96
105
|
return () => observer.disconnect();
|
|
97
106
|
}, [calculatePosition, enabled, popRef]);
|
|
98
107
|
import_react.default.useEffect(() => {
|
|
99
108
|
if (!enabled) return;
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
window.addEventListener("
|
|
109
|
+
const onScroll = () => calculatePosition();
|
|
110
|
+
const onResize = () => calculatePosition(true);
|
|
111
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
112
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
103
113
|
return () => {
|
|
104
|
-
window.removeEventListener("resize",
|
|
105
|
-
window.removeEventListener("scroll",
|
|
114
|
+
window.removeEventListener("resize", onResize);
|
|
115
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
106
116
|
};
|
|
107
117
|
}, [calculatePosition, enabled]);
|
|
108
118
|
return { direction };
|
|
@@ -157,6 +167,23 @@ var useEscapeKey = (enabled, onEscape) => {
|
|
|
157
167
|
return () => document.removeEventListener("keydown", onKey);
|
|
158
168
|
}, [enabled, onEscape]);
|
|
159
169
|
};
|
|
170
|
+
var useCloseOnContainerScroll = (enabled, popRef, onClose) => {
|
|
171
|
+
const onCloseRef = import_react3.default.useRef(onClose);
|
|
172
|
+
onCloseRef.current = onClose;
|
|
173
|
+
import_react3.default.useEffect(() => {
|
|
174
|
+
if (!enabled) return;
|
|
175
|
+
const onScroll = (e) => {
|
|
176
|
+
const target = e.target;
|
|
177
|
+
if (target === document || target === document.documentElement || target === document.body) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (target instanceof Node && popRef.current?.contains(target)) return;
|
|
181
|
+
onCloseRef.current();
|
|
182
|
+
};
|
|
183
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
184
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
185
|
+
}, [enabled, popRef]);
|
|
186
|
+
};
|
|
160
187
|
|
|
161
188
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
162
189
|
function r(e) {
|
|
@@ -366,6 +393,7 @@ var TimePicker = (props) => {
|
|
|
366
393
|
}, [step, min, max]);
|
|
367
394
|
const close = import_react4.default.useCallback(() => setOpen(false), []);
|
|
368
395
|
useClickOutside_default([triggerRef, contentRef], close, isOpen);
|
|
396
|
+
useCloseOnContainerScroll(isOpen, contentRef, close);
|
|
369
397
|
useEscapeKey(isOpen, () => {
|
|
370
398
|
close();
|
|
371
399
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -15,15 +15,21 @@ import React from "react";
|
|
|
15
15
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
16
16
|
const [direction, setDirection] = React.useState("bottom");
|
|
17
17
|
const directionRef = React.useRef("bottom");
|
|
18
|
-
const
|
|
18
|
+
const sizeRef = React.useRef(null);
|
|
19
|
+
const calculatePosition = React.useCallback((remeasure = false) => {
|
|
19
20
|
const pop = popRef.current;
|
|
20
21
|
if (!triggerRef.current || !pop) return;
|
|
22
|
+
if (remeasure || !sizeRef.current) {
|
|
23
|
+
sizeRef.current = { w: pop.offsetWidth, h: pop.offsetHeight };
|
|
24
|
+
}
|
|
25
|
+
const { w: popW, h: popH } = sizeRef.current;
|
|
21
26
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
22
|
-
const popW = pop.offsetWidth;
|
|
23
|
-
const popH = pop.offsetHeight;
|
|
24
27
|
const viewportHeight = window.innerHeight;
|
|
25
28
|
const viewportWidth = window.innerWidth;
|
|
26
|
-
if (popH === 0 || popW === 0)
|
|
29
|
+
if (popH === 0 || popW === 0) {
|
|
30
|
+
sizeRef.current = null;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
27
33
|
let next = "bottom";
|
|
28
34
|
let top;
|
|
29
35
|
let left;
|
|
@@ -46,27 +52,31 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
46
52
|
}
|
|
47
53
|
}, [triggerRef, popRef]);
|
|
48
54
|
React.useLayoutEffect(() => {
|
|
49
|
-
if (!enabled)
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
if (!enabled) {
|
|
56
|
+
sizeRef.current = null;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
calculatePosition(true);
|
|
60
|
+
const raf = requestAnimationFrame(() => calculatePosition(true));
|
|
52
61
|
return () => cancelAnimationFrame(raf);
|
|
53
62
|
}, [calculatePosition, enabled]);
|
|
54
63
|
React.useEffect(() => {
|
|
55
64
|
if (!enabled || !popRef.current) return;
|
|
56
65
|
const observer = new ResizeObserver(() => {
|
|
57
|
-
calculatePosition();
|
|
66
|
+
calculatePosition(true);
|
|
58
67
|
});
|
|
59
68
|
observer.observe(popRef.current);
|
|
60
69
|
return () => observer.disconnect();
|
|
61
70
|
}, [calculatePosition, enabled, popRef]);
|
|
62
71
|
React.useEffect(() => {
|
|
63
72
|
if (!enabled) return;
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
window.addEventListener("
|
|
73
|
+
const onScroll = () => calculatePosition();
|
|
74
|
+
const onResize = () => calculatePosition(true);
|
|
75
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
76
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
67
77
|
return () => {
|
|
68
|
-
window.removeEventListener("resize",
|
|
69
|
-
window.removeEventListener("scroll",
|
|
78
|
+
window.removeEventListener("resize", onResize);
|
|
79
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
70
80
|
};
|
|
71
81
|
}, [calculatePosition, enabled]);
|
|
72
82
|
return { direction };
|
|
@@ -121,6 +131,23 @@ var useEscapeKey = (enabled, onEscape) => {
|
|
|
121
131
|
return () => document.removeEventListener("keydown", onKey);
|
|
122
132
|
}, [enabled, onEscape]);
|
|
123
133
|
};
|
|
134
|
+
var useCloseOnContainerScroll = (enabled, popRef, onClose) => {
|
|
135
|
+
const onCloseRef = React3.useRef(onClose);
|
|
136
|
+
onCloseRef.current = onClose;
|
|
137
|
+
React3.useEffect(() => {
|
|
138
|
+
if (!enabled) return;
|
|
139
|
+
const onScroll = (e) => {
|
|
140
|
+
const target = e.target;
|
|
141
|
+
if (target === document || target === document.documentElement || target === document.body) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (target instanceof Node && popRef.current?.contains(target)) return;
|
|
145
|
+
onCloseRef.current();
|
|
146
|
+
};
|
|
147
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
148
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
149
|
+
}, [enabled, popRef]);
|
|
150
|
+
};
|
|
124
151
|
|
|
125
152
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
126
153
|
function r(e) {
|
|
@@ -330,6 +357,7 @@ var TimePicker = (props) => {
|
|
|
330
357
|
}, [step, min, max]);
|
|
331
358
|
const close = React4.useCallback(() => setOpen(false), []);
|
|
332
359
|
useClickOutside_default([triggerRef, contentRef], close, isOpen);
|
|
360
|
+
useCloseOnContainerScroll(isOpen, contentRef, close);
|
|
333
361
|
useEscapeKey(isOpen, () => {
|
|
334
362
|
close();
|
|
335
363
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -3303,6 +3303,23 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
3303
3303
|
return () => document.removeEventListener("keydown", onKey);
|
|
3304
3304
|
}, [enabled, trap, containerRef]);
|
|
3305
3305
|
};
|
|
3306
|
+
var useCloseOnContainerScroll = (enabled, popRef, onClose) => {
|
|
3307
|
+
const onCloseRef = import_react10.default.useRef(onClose);
|
|
3308
|
+
onCloseRef.current = onClose;
|
|
3309
|
+
import_react10.default.useEffect(() => {
|
|
3310
|
+
if (!enabled) return;
|
|
3311
|
+
const onScroll = (e) => {
|
|
3312
|
+
const target = e.target;
|
|
3313
|
+
if (target === document || target === document.documentElement || target === document.body) {
|
|
3314
|
+
return;
|
|
3315
|
+
}
|
|
3316
|
+
if (target instanceof Node && popRef.current?.contains(target)) return;
|
|
3317
|
+
onCloseRef.current();
|
|
3318
|
+
};
|
|
3319
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
3320
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
3321
|
+
}, [enabled, popRef]);
|
|
3322
|
+
};
|
|
3306
3323
|
|
|
3307
3324
|
// src/components/Modal/Modal.tsx
|
|
3308
3325
|
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
@@ -3978,15 +3995,21 @@ var import_react19 = __toESM(require("react"), 1);
|
|
|
3978
3995
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
3979
3996
|
const [direction, setDirection] = import_react19.default.useState("bottom");
|
|
3980
3997
|
const directionRef = import_react19.default.useRef("bottom");
|
|
3981
|
-
const
|
|
3998
|
+
const sizeRef = import_react19.default.useRef(null);
|
|
3999
|
+
const calculatePosition = import_react19.default.useCallback((remeasure = false) => {
|
|
3982
4000
|
const pop = popRef.current;
|
|
3983
4001
|
if (!triggerRef.current || !pop) return;
|
|
4002
|
+
if (remeasure || !sizeRef.current) {
|
|
4003
|
+
sizeRef.current = { w: pop.offsetWidth, h: pop.offsetHeight };
|
|
4004
|
+
}
|
|
4005
|
+
const { w: popW, h: popH } = sizeRef.current;
|
|
3984
4006
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
3985
|
-
const popW = pop.offsetWidth;
|
|
3986
|
-
const popH = pop.offsetHeight;
|
|
3987
4007
|
const viewportHeight = window.innerHeight;
|
|
3988
4008
|
const viewportWidth = window.innerWidth;
|
|
3989
|
-
if (popH === 0 || popW === 0)
|
|
4009
|
+
if (popH === 0 || popW === 0) {
|
|
4010
|
+
sizeRef.current = null;
|
|
4011
|
+
return;
|
|
4012
|
+
}
|
|
3990
4013
|
let next = "bottom";
|
|
3991
4014
|
let top;
|
|
3992
4015
|
let left;
|
|
@@ -4009,27 +4032,31 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
4009
4032
|
}
|
|
4010
4033
|
}, [triggerRef, popRef]);
|
|
4011
4034
|
import_react19.default.useLayoutEffect(() => {
|
|
4012
|
-
if (!enabled)
|
|
4013
|
-
|
|
4014
|
-
|
|
4035
|
+
if (!enabled) {
|
|
4036
|
+
sizeRef.current = null;
|
|
4037
|
+
return;
|
|
4038
|
+
}
|
|
4039
|
+
calculatePosition(true);
|
|
4040
|
+
const raf = requestAnimationFrame(() => calculatePosition(true));
|
|
4015
4041
|
return () => cancelAnimationFrame(raf);
|
|
4016
4042
|
}, [calculatePosition, enabled]);
|
|
4017
4043
|
import_react19.default.useEffect(() => {
|
|
4018
4044
|
if (!enabled || !popRef.current) return;
|
|
4019
4045
|
const observer = new ResizeObserver(() => {
|
|
4020
|
-
calculatePosition();
|
|
4046
|
+
calculatePosition(true);
|
|
4021
4047
|
});
|
|
4022
4048
|
observer.observe(popRef.current);
|
|
4023
4049
|
return () => observer.disconnect();
|
|
4024
4050
|
}, [calculatePosition, enabled, popRef]);
|
|
4025
4051
|
import_react19.default.useEffect(() => {
|
|
4026
4052
|
if (!enabled) return;
|
|
4027
|
-
const
|
|
4028
|
-
|
|
4029
|
-
window.addEventListener("
|
|
4053
|
+
const onScroll = () => calculatePosition();
|
|
4054
|
+
const onResize = () => calculatePosition(true);
|
|
4055
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
4056
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
4030
4057
|
return () => {
|
|
4031
|
-
window.removeEventListener("resize",
|
|
4032
|
-
window.removeEventListener("scroll",
|
|
4058
|
+
window.removeEventListener("resize", onResize);
|
|
4059
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
4033
4060
|
};
|
|
4034
4061
|
}, [calculatePosition, enabled]);
|
|
4035
4062
|
return { direction };
|
|
@@ -4072,6 +4099,7 @@ var Dropdown = (props) => {
|
|
|
4072
4099
|
const menuRef = import_react21.default.useRef(null);
|
|
4073
4100
|
const { direction } = useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
4074
4101
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
4102
|
+
useCloseOnContainerScroll(isOpen, menuRef, () => setIsOpen(false));
|
|
4075
4103
|
useEscapeKey(isOpen, () => {
|
|
4076
4104
|
setIsOpen(false);
|
|
4077
4105
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -6002,6 +6030,7 @@ var PopOver = (props) => {
|
|
|
6002
6030
|
const [localOpen, setLocalOpen] = import_react27.default.useState(false);
|
|
6003
6031
|
const [eventTrigger, setEventTrigger] = import_react27.default.useState(false);
|
|
6004
6032
|
useClickOutside_default([popRef, triggerRef], onClose, isOpen);
|
|
6033
|
+
useCloseOnContainerScroll(isOpen, popRef, onClose);
|
|
6005
6034
|
useEscapeKey(isOpen, () => {
|
|
6006
6035
|
onClose();
|
|
6007
6036
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -6282,6 +6311,7 @@ var SelectRoot = (props) => {
|
|
|
6282
6311
|
}, []);
|
|
6283
6312
|
const toggle = import_react31.default.useCallback(() => setOpen((prev) => !prev), []);
|
|
6284
6313
|
useClickOutside_default([contentRef, triggerRef], close, isOpen);
|
|
6314
|
+
useCloseOnContainerScroll(isOpen, contentRef, close);
|
|
6285
6315
|
useEscapeKey(isOpen, () => {
|
|
6286
6316
|
close();
|
|
6287
6317
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -7222,6 +7252,7 @@ var TimePicker = (props) => {
|
|
|
7222
7252
|
}, [step, min, max]);
|
|
7223
7253
|
const close = import_react40.default.useCallback(() => setOpen(false), []);
|
|
7224
7254
|
useClickOutside_default([triggerRef, contentRef], close, isOpen);
|
|
7255
|
+
useCloseOnContainerScroll(isOpen, contentRef, close);
|
|
7225
7256
|
useEscapeKey(isOpen, () => {
|
|
7226
7257
|
close();
|
|
7227
7258
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -4552,6 +4552,7 @@
|
|
|
4552
4552
|
}
|
|
4553
4553
|
.lib-xplat-select-content .select-item {
|
|
4554
4554
|
padding: var(--spacing-space-2) var(--spacing-space-3);
|
|
4555
|
+
overflow-wrap: anywhere;
|
|
4555
4556
|
font-family: var(--semantic-typo-label-2-m-font);
|
|
4556
4557
|
font-size: var(--semantic-typo-label-2-m-size);
|
|
4557
4558
|
line-height: var(--semantic-typo-label-2-m-lh);
|
|
@@ -5639,6 +5640,7 @@
|
|
|
5639
5640
|
}
|
|
5640
5641
|
.lib-xplat-time-picker-content .time-picker-item {
|
|
5641
5642
|
padding: var(--spacing-space-2) var(--spacing-space-3);
|
|
5643
|
+
overflow-wrap: anywhere;
|
|
5642
5644
|
cursor: pointer;
|
|
5643
5645
|
outline: none;
|
|
5644
5646
|
color: var(--semantic-text-primary);
|
package/dist/components/index.js
CHANGED
|
@@ -3201,6 +3201,23 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
3201
3201
|
return () => document.removeEventListener("keydown", onKey);
|
|
3202
3202
|
}, [enabled, trap, containerRef]);
|
|
3203
3203
|
};
|
|
3204
|
+
var useCloseOnContainerScroll = (enabled, popRef, onClose) => {
|
|
3205
|
+
const onCloseRef = React10.useRef(onClose);
|
|
3206
|
+
onCloseRef.current = onClose;
|
|
3207
|
+
React10.useEffect(() => {
|
|
3208
|
+
if (!enabled) return;
|
|
3209
|
+
const onScroll = (e) => {
|
|
3210
|
+
const target = e.target;
|
|
3211
|
+
if (target === document || target === document.documentElement || target === document.body) {
|
|
3212
|
+
return;
|
|
3213
|
+
}
|
|
3214
|
+
if (target instanceof Node && popRef.current?.contains(target)) return;
|
|
3215
|
+
onCloseRef.current();
|
|
3216
|
+
};
|
|
3217
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
3218
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
3219
|
+
}, [enabled, popRef]);
|
|
3220
|
+
};
|
|
3204
3221
|
|
|
3205
3222
|
// src/components/Modal/Modal.tsx
|
|
3206
3223
|
import { jsx as jsx313 } from "react/jsx-runtime";
|
|
@@ -3876,15 +3893,21 @@ import React19 from "react";
|
|
|
3876
3893
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
3877
3894
|
const [direction, setDirection] = React19.useState("bottom");
|
|
3878
3895
|
const directionRef = React19.useRef("bottom");
|
|
3879
|
-
const
|
|
3896
|
+
const sizeRef = React19.useRef(null);
|
|
3897
|
+
const calculatePosition = React19.useCallback((remeasure = false) => {
|
|
3880
3898
|
const pop = popRef.current;
|
|
3881
3899
|
if (!triggerRef.current || !pop) return;
|
|
3900
|
+
if (remeasure || !sizeRef.current) {
|
|
3901
|
+
sizeRef.current = { w: pop.offsetWidth, h: pop.offsetHeight };
|
|
3902
|
+
}
|
|
3903
|
+
const { w: popW, h: popH } = sizeRef.current;
|
|
3882
3904
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
3883
|
-
const popW = pop.offsetWidth;
|
|
3884
|
-
const popH = pop.offsetHeight;
|
|
3885
3905
|
const viewportHeight = window.innerHeight;
|
|
3886
3906
|
const viewportWidth = window.innerWidth;
|
|
3887
|
-
if (popH === 0 || popW === 0)
|
|
3907
|
+
if (popH === 0 || popW === 0) {
|
|
3908
|
+
sizeRef.current = null;
|
|
3909
|
+
return;
|
|
3910
|
+
}
|
|
3888
3911
|
let next = "bottom";
|
|
3889
3912
|
let top;
|
|
3890
3913
|
let left;
|
|
@@ -3907,27 +3930,31 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
3907
3930
|
}
|
|
3908
3931
|
}, [triggerRef, popRef]);
|
|
3909
3932
|
React19.useLayoutEffect(() => {
|
|
3910
|
-
if (!enabled)
|
|
3911
|
-
|
|
3912
|
-
|
|
3933
|
+
if (!enabled) {
|
|
3934
|
+
sizeRef.current = null;
|
|
3935
|
+
return;
|
|
3936
|
+
}
|
|
3937
|
+
calculatePosition(true);
|
|
3938
|
+
const raf = requestAnimationFrame(() => calculatePosition(true));
|
|
3913
3939
|
return () => cancelAnimationFrame(raf);
|
|
3914
3940
|
}, [calculatePosition, enabled]);
|
|
3915
3941
|
React19.useEffect(() => {
|
|
3916
3942
|
if (!enabled || !popRef.current) return;
|
|
3917
3943
|
const observer = new ResizeObserver(() => {
|
|
3918
|
-
calculatePosition();
|
|
3944
|
+
calculatePosition(true);
|
|
3919
3945
|
});
|
|
3920
3946
|
observer.observe(popRef.current);
|
|
3921
3947
|
return () => observer.disconnect();
|
|
3922
3948
|
}, [calculatePosition, enabled, popRef]);
|
|
3923
3949
|
React19.useEffect(() => {
|
|
3924
3950
|
if (!enabled) return;
|
|
3925
|
-
const
|
|
3926
|
-
|
|
3927
|
-
window.addEventListener("
|
|
3951
|
+
const onScroll = () => calculatePosition();
|
|
3952
|
+
const onResize = () => calculatePosition(true);
|
|
3953
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
3954
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
3928
3955
|
return () => {
|
|
3929
|
-
window.removeEventListener("resize",
|
|
3930
|
-
window.removeEventListener("scroll",
|
|
3956
|
+
window.removeEventListener("resize", onResize);
|
|
3957
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
3931
3958
|
};
|
|
3932
3959
|
}, [calculatePosition, enabled]);
|
|
3933
3960
|
return { direction };
|
|
@@ -3970,6 +3997,7 @@ var Dropdown = (props) => {
|
|
|
3970
3997
|
const menuRef = React21.useRef(null);
|
|
3971
3998
|
const { direction } = useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
3972
3999
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
4000
|
+
useCloseOnContainerScroll(isOpen, menuRef, () => setIsOpen(false));
|
|
3973
4001
|
useEscapeKey(isOpen, () => {
|
|
3974
4002
|
setIsOpen(false);
|
|
3975
4003
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -5900,6 +5928,7 @@ var PopOver = (props) => {
|
|
|
5900
5928
|
const [localOpen, setLocalOpen] = React27.useState(false);
|
|
5901
5929
|
const [eventTrigger, setEventTrigger] = React27.useState(false);
|
|
5902
5930
|
useClickOutside_default([popRef, triggerRef], onClose, isOpen);
|
|
5931
|
+
useCloseOnContainerScroll(isOpen, popRef, onClose);
|
|
5903
5932
|
useEscapeKey(isOpen, () => {
|
|
5904
5933
|
onClose();
|
|
5905
5934
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -6180,6 +6209,7 @@ var SelectRoot = (props) => {
|
|
|
6180
6209
|
}, []);
|
|
6181
6210
|
const toggle = React31.useCallback(() => setOpen((prev) => !prev), []);
|
|
6182
6211
|
useClickOutside_default([contentRef, triggerRef], close, isOpen);
|
|
6212
|
+
useCloseOnContainerScroll(isOpen, contentRef, close);
|
|
6183
6213
|
useEscapeKey(isOpen, () => {
|
|
6184
6214
|
close();
|
|
6185
6215
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -7120,6 +7150,7 @@ var TimePicker = (props) => {
|
|
|
7120
7150
|
}, [step, min, max]);
|
|
7121
7151
|
const close = React40.useCallback(() => setOpen(false), []);
|
|
7122
7152
|
useClickOutside_default([triggerRef, contentRef], close, isOpen);
|
|
7153
|
+
useCloseOnContainerScroll(isOpen, contentRef, close);
|
|
7123
7154
|
useEscapeKey(isOpen, () => {
|
|
7124
7155
|
close();
|
|
7125
7156
|
triggerRef.current?.focus({ preventScroll: true });
|
package/dist/index.cjs
CHANGED
|
@@ -7715,6 +7715,23 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
7715
7715
|
return () => document.removeEventListener("keydown", onKey);
|
|
7716
7716
|
}, [enabled, trap, containerRef]);
|
|
7717
7717
|
};
|
|
7718
|
+
var useCloseOnContainerScroll = (enabled, popRef, onClose) => {
|
|
7719
|
+
const onCloseRef = import_react10.default.useRef(onClose);
|
|
7720
|
+
onCloseRef.current = onClose;
|
|
7721
|
+
import_react10.default.useEffect(() => {
|
|
7722
|
+
if (!enabled) return;
|
|
7723
|
+
const onScroll = (e) => {
|
|
7724
|
+
const target = e.target;
|
|
7725
|
+
if (target === document || target === document.documentElement || target === document.body) {
|
|
7726
|
+
return;
|
|
7727
|
+
}
|
|
7728
|
+
if (target instanceof Node && popRef.current?.contains(target)) return;
|
|
7729
|
+
onCloseRef.current();
|
|
7730
|
+
};
|
|
7731
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
7732
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
7733
|
+
}, [enabled, popRef]);
|
|
7734
|
+
};
|
|
7718
7735
|
|
|
7719
7736
|
// src/components/Modal/Modal.tsx
|
|
7720
7737
|
var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
@@ -8390,15 +8407,21 @@ var import_react19 = __toESM(require("react"), 1);
|
|
|
8390
8407
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
8391
8408
|
const [direction, setDirection] = import_react19.default.useState("bottom");
|
|
8392
8409
|
const directionRef = import_react19.default.useRef("bottom");
|
|
8393
|
-
const
|
|
8410
|
+
const sizeRef = import_react19.default.useRef(null);
|
|
8411
|
+
const calculatePosition = import_react19.default.useCallback((remeasure = false) => {
|
|
8394
8412
|
const pop = popRef.current;
|
|
8395
8413
|
if (!triggerRef.current || !pop) return;
|
|
8414
|
+
if (remeasure || !sizeRef.current) {
|
|
8415
|
+
sizeRef.current = { w: pop.offsetWidth, h: pop.offsetHeight };
|
|
8416
|
+
}
|
|
8417
|
+
const { w: popW, h: popH } = sizeRef.current;
|
|
8396
8418
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
8397
|
-
const popW = pop.offsetWidth;
|
|
8398
|
-
const popH = pop.offsetHeight;
|
|
8399
8419
|
const viewportHeight = window.innerHeight;
|
|
8400
8420
|
const viewportWidth = window.innerWidth;
|
|
8401
|
-
if (popH === 0 || popW === 0)
|
|
8421
|
+
if (popH === 0 || popW === 0) {
|
|
8422
|
+
sizeRef.current = null;
|
|
8423
|
+
return;
|
|
8424
|
+
}
|
|
8402
8425
|
let next = "bottom";
|
|
8403
8426
|
let top;
|
|
8404
8427
|
let left;
|
|
@@ -8421,27 +8444,31 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
8421
8444
|
}
|
|
8422
8445
|
}, [triggerRef, popRef]);
|
|
8423
8446
|
import_react19.default.useLayoutEffect(() => {
|
|
8424
|
-
if (!enabled)
|
|
8425
|
-
|
|
8426
|
-
|
|
8447
|
+
if (!enabled) {
|
|
8448
|
+
sizeRef.current = null;
|
|
8449
|
+
return;
|
|
8450
|
+
}
|
|
8451
|
+
calculatePosition(true);
|
|
8452
|
+
const raf = requestAnimationFrame(() => calculatePosition(true));
|
|
8427
8453
|
return () => cancelAnimationFrame(raf);
|
|
8428
8454
|
}, [calculatePosition, enabled]);
|
|
8429
8455
|
import_react19.default.useEffect(() => {
|
|
8430
8456
|
if (!enabled || !popRef.current) return;
|
|
8431
8457
|
const observer = new ResizeObserver(() => {
|
|
8432
|
-
calculatePosition();
|
|
8458
|
+
calculatePosition(true);
|
|
8433
8459
|
});
|
|
8434
8460
|
observer.observe(popRef.current);
|
|
8435
8461
|
return () => observer.disconnect();
|
|
8436
8462
|
}, [calculatePosition, enabled, popRef]);
|
|
8437
8463
|
import_react19.default.useEffect(() => {
|
|
8438
8464
|
if (!enabled) return;
|
|
8439
|
-
const
|
|
8440
|
-
|
|
8441
|
-
window.addEventListener("
|
|
8465
|
+
const onScroll = () => calculatePosition();
|
|
8466
|
+
const onResize = () => calculatePosition(true);
|
|
8467
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
8468
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
8442
8469
|
return () => {
|
|
8443
|
-
window.removeEventListener("resize",
|
|
8444
|
-
window.removeEventListener("scroll",
|
|
8470
|
+
window.removeEventListener("resize", onResize);
|
|
8471
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
8445
8472
|
};
|
|
8446
8473
|
}, [calculatePosition, enabled]);
|
|
8447
8474
|
return { direction };
|
|
@@ -8484,6 +8511,7 @@ var Dropdown = (props) => {
|
|
|
8484
8511
|
const menuRef = import_react21.default.useRef(null);
|
|
8485
8512
|
const { direction } = useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
8486
8513
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
8514
|
+
useCloseOnContainerScroll(isOpen, menuRef, () => setIsOpen(false));
|
|
8487
8515
|
useEscapeKey(isOpen, () => {
|
|
8488
8516
|
setIsOpen(false);
|
|
8489
8517
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -10414,6 +10442,7 @@ var PopOver = (props) => {
|
|
|
10414
10442
|
const [localOpen, setLocalOpen] = import_react27.default.useState(false);
|
|
10415
10443
|
const [eventTrigger, setEventTrigger] = import_react27.default.useState(false);
|
|
10416
10444
|
useClickOutside_default([popRef, triggerRef], onClose, isOpen);
|
|
10445
|
+
useCloseOnContainerScroll(isOpen, popRef, onClose);
|
|
10417
10446
|
useEscapeKey(isOpen, () => {
|
|
10418
10447
|
onClose();
|
|
10419
10448
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -10694,6 +10723,7 @@ var SelectRoot = (props) => {
|
|
|
10694
10723
|
}, []);
|
|
10695
10724
|
const toggle = import_react31.default.useCallback(() => setOpen((prev) => !prev), []);
|
|
10696
10725
|
useClickOutside_default([contentRef, triggerRef], close, isOpen);
|
|
10726
|
+
useCloseOnContainerScroll(isOpen, contentRef, close);
|
|
10697
10727
|
useEscapeKey(isOpen, () => {
|
|
10698
10728
|
close();
|
|
10699
10729
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -11634,6 +11664,7 @@ var TimePicker = (props) => {
|
|
|
11634
11664
|
}, [step, min, max]);
|
|
11635
11665
|
const close = import_react40.default.useCallback(() => setOpen(false), []);
|
|
11636
11666
|
useClickOutside_default([triggerRef, contentRef], close, isOpen);
|
|
11667
|
+
useCloseOnContainerScroll(isOpen, contentRef, close);
|
|
11637
11668
|
useEscapeKey(isOpen, () => {
|
|
11638
11669
|
close();
|
|
11639
11670
|
triggerRef.current?.focus({ preventScroll: true });
|
package/dist/index.css
CHANGED
|
@@ -4552,6 +4552,7 @@
|
|
|
4552
4552
|
}
|
|
4553
4553
|
.lib-xplat-select-content .select-item {
|
|
4554
4554
|
padding: var(--spacing-space-2) var(--spacing-space-3);
|
|
4555
|
+
overflow-wrap: anywhere;
|
|
4555
4556
|
font-family: var(--semantic-typo-label-2-m-font);
|
|
4556
4557
|
font-size: var(--semantic-typo-label-2-m-size);
|
|
4557
4558
|
line-height: var(--semantic-typo-label-2-m-lh);
|
|
@@ -5639,6 +5640,7 @@
|
|
|
5639
5640
|
}
|
|
5640
5641
|
.lib-xplat-time-picker-content .time-picker-item {
|
|
5641
5642
|
padding: var(--spacing-space-2) var(--spacing-space-3);
|
|
5643
|
+
overflow-wrap: anywhere;
|
|
5642
5644
|
cursor: pointer;
|
|
5643
5645
|
outline: none;
|
|
5644
5646
|
color: var(--semantic-text-primary);
|