@react-aria/overlays 3.22.0 → 3.22.1
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/DismissButton.main.js +2 -2
- package/dist/DismissButton.mjs +3 -3
- package/dist/DismissButton.module.js +2 -2
- package/dist/Overlay.mjs +1 -1
- package/dist/PortalProvider.mjs +1 -1
- package/dist/ar-AE.mjs +1 -1
- package/dist/ariaHideOutside.main.js +7 -7
- package/dist/ariaHideOutside.mjs +8 -8
- package/dist/ariaHideOutside.module.js +7 -7
- package/dist/bg-BG.mjs +1 -1
- package/dist/calculatePosition.main.js +40 -40
- package/dist/calculatePosition.main.js.map +1 -1
- package/dist/calculatePosition.mjs +41 -41
- package/dist/calculatePosition.module.js +40 -40
- package/dist/calculatePosition.module.js.map +1 -1
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/intlStrings.mjs +1 -1
- package/dist/it-IT.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useCloseOnScroll.main.js +2 -2
- package/dist/useCloseOnScroll.mjs +3 -3
- package/dist/useCloseOnScroll.module.js +2 -2
- package/dist/useModal.main.js +4 -4
- package/dist/useModal.mjs +5 -5
- package/dist/useModal.module.js +4 -4
- package/dist/useModalOverlay.mjs +1 -1
- package/dist/useOverlay.main.js +1 -1
- package/dist/useOverlay.mjs +2 -2
- package/dist/useOverlay.module.js +1 -1
- package/dist/useOverlayPosition.main.js +25 -16
- package/dist/useOverlayPosition.main.js.map +1 -1
- package/dist/useOverlayPosition.mjs +26 -17
- package/dist/useOverlayPosition.module.js +25 -16
- package/dist/useOverlayPosition.module.js.map +1 -1
- package/dist/useOverlayTrigger.main.js +5 -5
- package/dist/useOverlayTrigger.mjs +6 -6
- package/dist/useOverlayTrigger.module.js +5 -5
- package/dist/usePopover.mjs +1 -1
- package/dist/usePreventScroll.main.js +22 -22
- package/dist/usePreventScroll.mjs +23 -23
- package/dist/usePreventScroll.module.js +22 -22
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +12 -12
- package/src/calculatePosition.ts +3 -3
- package/src/useOverlayPosition.ts +8 -3
|
@@ -12,18 +12,18 @@ import {useLayoutEffect as $7mMvr$useLayoutEffect, isIOS as $7mMvr$isIOS, chain
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
// @ts-ignore
|
|
15
|
-
const $49c51c25361d4cd2$var$visualViewport = typeof document !==
|
|
15
|
+
const $49c51c25361d4cd2$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
16
16
|
// HTML input types that do not cause the software keyboard to appear.
|
|
17
17
|
const $49c51c25361d4cd2$var$nonTextInputTypes = new Set([
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
'checkbox',
|
|
19
|
+
'radio',
|
|
20
|
+
'range',
|
|
21
|
+
'color',
|
|
22
|
+
'file',
|
|
23
|
+
'image',
|
|
24
|
+
'button',
|
|
25
|
+
'submit',
|
|
26
|
+
'reset'
|
|
27
27
|
]);
|
|
28
28
|
// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
|
|
29
29
|
let $49c51c25361d4cd2$var$preventScrollCount = 0;
|
|
@@ -48,7 +48,7 @@ function $49c51c25361d4cd2$export$ee0f7cc6afcd1c18(options = {}) {
|
|
|
48
48
|
// For most browsers, all we need to do is set `overflow: hidden` on the root element, and
|
|
49
49
|
// add some padding to prevent the page from shifting when the scrollbar is hidden.
|
|
50
50
|
function $49c51c25361d4cd2$var$preventScrollStandard() {
|
|
51
|
-
return (0, $7mMvr$chain)($49c51c25361d4cd2$var$setStyle(document.documentElement,
|
|
51
|
+
return (0, $7mMvr$chain)($49c51c25361d4cd2$var$setStyle(document.documentElement, 'paddingRight', `${window.innerWidth - document.documentElement.clientWidth}px`), $49c51c25361d4cd2$var$setStyle(document.documentElement, 'overflow', 'hidden'));
|
|
52
52
|
}
|
|
53
53
|
// Mobile Safari is a whole different beast. Even with overflow: hidden,
|
|
54
54
|
// it still scrolls the page in many situations:
|
|
@@ -87,7 +87,7 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
87
87
|
// Prevent scrolling up when at the top and scrolling down when at the bottom
|
|
88
88
|
// of a nested scrollable area, otherwise mobile Safari will start scrolling
|
|
89
89
|
// the window instead.
|
|
90
|
-
if (scrollable instanceof HTMLElement && window.getComputedStyle(scrollable).overscrollBehavior ===
|
|
90
|
+
if (scrollable instanceof HTMLElement && window.getComputedStyle(scrollable).overscrollBehavior === 'auto') restoreScrollableStyles = $49c51c25361d4cd2$var$setStyle(scrollable, 'overscrollBehavior', 'contain');
|
|
91
91
|
};
|
|
92
92
|
let onTouchMove = (e)=>{
|
|
93
93
|
// Prevent scrolling the window.
|
|
@@ -112,10 +112,10 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
112
112
|
// Apply a transform to trick Safari into thinking the input is at the top of the page
|
|
113
113
|
// so it doesn't try to scroll it into view. When tapping on an input, this needs to
|
|
114
114
|
// be done before the "focus" event, so we have to focus the element ourselves.
|
|
115
|
-
target.style.transform =
|
|
115
|
+
target.style.transform = 'translateY(-2000px)';
|
|
116
116
|
target.focus();
|
|
117
117
|
requestAnimationFrame(()=>{
|
|
118
|
-
target.style.transform =
|
|
118
|
+
target.style.transform = '';
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
if (restoreScrollableStyles) restoreScrollableStyles();
|
|
@@ -128,9 +128,9 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
128
128
|
// other than tapping on an input directly, e.g. the next/previous buttons in the
|
|
129
129
|
// software keyboard. In these cases, it seems applying the transform in the focus event
|
|
130
130
|
// is good enough, whereas when tapping an input, it must be done before the focus event. 🤷♂️
|
|
131
|
-
target.style.transform =
|
|
131
|
+
target.style.transform = 'translateY(-2000px)';
|
|
132
132
|
requestAnimationFrame(()=>{
|
|
133
|
-
target.style.transform =
|
|
133
|
+
target.style.transform = '';
|
|
134
134
|
// This will have prevented the browser from scrolling the focused element into view,
|
|
135
135
|
// so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
|
|
136
136
|
if ($49c51c25361d4cd2$var$visualViewport) {
|
|
@@ -141,7 +141,7 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
141
141
|
});
|
|
142
142
|
else // Otherwise, wait for the visual viewport to resize before scrolling so we can
|
|
143
143
|
// measure the correct position to scroll to.
|
|
144
|
-
$49c51c25361d4cd2$var$visualViewport.addEventListener(
|
|
144
|
+
$49c51c25361d4cd2$var$visualViewport.addEventListener('resize', ()=>$49c51c25361d4cd2$var$scrollIntoView(target), {
|
|
145
145
|
once: true
|
|
146
146
|
});
|
|
147
147
|
}
|
|
@@ -161,22 +161,22 @@ function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
|
161
161
|
// enable us to scroll the window to the top, which is required for the rest of this to work.
|
|
162
162
|
let scrollX = window.pageXOffset;
|
|
163
163
|
let scrollY = window.pageYOffset;
|
|
164
|
-
restoreStyles = (0, $7mMvr$chain)($49c51c25361d4cd2$var$addEvent(window,
|
|
164
|
+
restoreStyles = (0, $7mMvr$chain)($49c51c25361d4cd2$var$addEvent(window, 'scroll', onWindowScroll), $49c51c25361d4cd2$var$setStyle(document.documentElement, 'paddingRight', `${window.innerWidth - document.documentElement.clientWidth}px`), $49c51c25361d4cd2$var$setStyle(document.documentElement, 'overflow', 'hidden'), $49c51c25361d4cd2$var$setStyle(document.body, 'marginTop', `-${scrollY}px`), ()=>{
|
|
165
165
|
window.scrollTo(scrollX, scrollY);
|
|
166
166
|
});
|
|
167
167
|
// Scroll to the top. The negative margin on the body will make this appear the same.
|
|
168
168
|
window.scrollTo(0, 0);
|
|
169
169
|
};
|
|
170
|
-
let removeEvents = (0, $7mMvr$chain)($49c51c25361d4cd2$var$addEvent(document,
|
|
170
|
+
let removeEvents = (0, $7mMvr$chain)($49c51c25361d4cd2$var$addEvent(document, 'touchstart', onTouchStart, {
|
|
171
171
|
passive: false,
|
|
172
172
|
capture: true
|
|
173
|
-
}), $49c51c25361d4cd2$var$addEvent(document,
|
|
173
|
+
}), $49c51c25361d4cd2$var$addEvent(document, 'touchmove', onTouchMove, {
|
|
174
174
|
passive: false,
|
|
175
175
|
capture: true
|
|
176
|
-
}), $49c51c25361d4cd2$var$addEvent(document,
|
|
176
|
+
}), $49c51c25361d4cd2$var$addEvent(document, 'touchend', onTouchEnd, {
|
|
177
177
|
passive: false,
|
|
178
178
|
capture: true
|
|
179
|
-
}), $49c51c25361d4cd2$var$addEvent(document,
|
|
179
|
+
}), $49c51c25361d4cd2$var$addEvent(document, 'focus', onFocus, true));
|
|
180
180
|
return ()=>{
|
|
181
181
|
// Restore styles and scroll the page back to where it was.
|
|
182
182
|
restoreScrollableStyles === null || restoreScrollableStyles === void 0 ? void 0 : restoreScrollableStyles();
|
package/dist/zh-CN.mjs
CHANGED
package/dist/zh-TW.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/overlays",
|
|
3
|
-
"version": "3.22.
|
|
3
|
+
"version": "3.22.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/focus": "^3.17.
|
|
26
|
-
"@react-aria/i18n": "^3.11.
|
|
27
|
-
"@react-aria/interactions": "^3.21.
|
|
28
|
-
"@react-aria/ssr": "^3.9.
|
|
29
|
-
"@react-aria/utils": "^3.24.
|
|
30
|
-
"@react-aria/visually-hidden": "^3.8.
|
|
31
|
-
"@react-stately/overlays": "^3.6.
|
|
32
|
-
"@react-types/button": "^3.9.
|
|
33
|
-
"@react-types/overlays": "^3.8.
|
|
34
|
-
"@react-types/shared": "^3.23.
|
|
25
|
+
"@react-aria/focus": "^3.17.1",
|
|
26
|
+
"@react-aria/i18n": "^3.11.1",
|
|
27
|
+
"@react-aria/interactions": "^3.21.3",
|
|
28
|
+
"@react-aria/ssr": "^3.9.4",
|
|
29
|
+
"@react-aria/utils": "^3.24.1",
|
|
30
|
+
"@react-aria/visually-hidden": "^3.8.12",
|
|
31
|
+
"@react-stately/overlays": "^3.6.7",
|
|
32
|
+
"@react-types/button": "^3.9.4",
|
|
33
|
+
"@react-types/overlays": "^3.8.7",
|
|
34
|
+
"@react-types/shared": "^3.23.1",
|
|
35
35
|
"@swc/helpers": "^0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
|
|
45
45
|
}
|
package/src/calculatePosition.ts
CHANGED
|
@@ -417,15 +417,15 @@ export function calculatePositionInternal(
|
|
|
417
417
|
|
|
418
418
|
// All values are transformed so that 0 is at the top/left of the overlay depending on the orientation
|
|
419
419
|
// Prefer the arrow being in the center of the trigger/overlay anchor element
|
|
420
|
-
let preferredArrowPosition = childOffset[crossAxis] + .5 * childOffset[crossSize] -
|
|
420
|
+
let preferredArrowPosition = childOffset[crossAxis] + .5 * childOffset[crossSize] - position[crossAxis];
|
|
421
421
|
|
|
422
422
|
// Min/Max position limits for the arrow with respect to the overlay
|
|
423
423
|
const arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;
|
|
424
424
|
const arrowMaxPosition = overlaySize[crossSize] - (arrowSize / 2) - arrowBoundaryOffset;
|
|
425
425
|
|
|
426
426
|
// Min/Max position limits for the arrow with respect to the trigger/overlay anchor element
|
|
427
|
-
const arrowOverlappingChildMinEdge = childOffset[crossAxis] -
|
|
428
|
-
const arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] -
|
|
427
|
+
const arrowOverlappingChildMinEdge = childOffset[crossAxis] - position[crossAxis] + (arrowSize / 2);
|
|
428
|
+
const arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] - position[crossAxis] - (arrowSize / 2);
|
|
429
429
|
|
|
430
430
|
// Clamp the arrow positioning so that it always is within the bounds of the anchor and the overlay
|
|
431
431
|
const arrowPositionOverlappingChild = clamp(preferredArrowPosition, arrowOverlappingChildMinEdge, arrowOverlappingChildMaxEdge);
|
|
@@ -145,8 +145,11 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
|
|
|
145
145
|
|
|
146
146
|
// Always reset the overlay's previous max height if not defined by the user so that we can compensate for
|
|
147
147
|
// RAC collections populating after a second render and properly set a correct max height + positioning when it populates.
|
|
148
|
+
let overlay = (overlayRef.current as HTMLElement);
|
|
148
149
|
if (!maxHeight && overlayRef.current) {
|
|
149
|
-
|
|
150
|
+
overlay.style.top = '0px';
|
|
151
|
+
overlay.style.bottom = '';
|
|
152
|
+
overlay.style.maxHeight = (window.visualViewport?.height ?? window.innerHeight) + 'px';
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
let position = calculatePosition({
|
|
@@ -166,8 +169,10 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
|
|
|
166
169
|
|
|
167
170
|
// Modify overlay styles directly so positioning happens immediately without the need of a second render
|
|
168
171
|
// This is so we don't have to delay autoFocus scrolling or delay applying preventScroll for popovers
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
overlay.style.top = '';
|
|
173
|
+
overlay.style.bottom = '';
|
|
174
|
+
Object.keys(position.position).forEach(key => overlay.style[key] = position.position[key] + 'px');
|
|
175
|
+
overlay.style.maxHeight = position.maxHeight != null ? position.maxHeight + 'px' : undefined;
|
|
171
176
|
|
|
172
177
|
// Trigger a set state for a second render anyway for arrow positioning
|
|
173
178
|
setPosition(position);
|