@react-spectrum/overlays 5.9.2 → 5.10.0
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/import.mjs +6 -6
- package/dist/main.js +10 -10
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -6
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +6 -0
- package/package.json +13 -33
- package/src/index.ts +7 -5
- package/dist/Modal.main.js +0 -93
- package/dist/Modal.main.js.map +0 -1
- package/dist/Modal.mjs +0 -88
- package/dist/Modal.module.js +0 -88
- package/dist/Modal.module.js.map +0 -1
- package/dist/OpenTransition.main.js +0 -44
- package/dist/OpenTransition.main.js.map +0 -1
- package/dist/OpenTransition.mjs +0 -35
- package/dist/OpenTransition.module.js +0 -35
- package/dist/OpenTransition.module.js.map +0 -1
- package/dist/Overlay.main.js +0 -75
- package/dist/Overlay.main.js.map +0 -1
- package/dist/Overlay.mjs +0 -66
- package/dist/Overlay.module.js +0 -66
- package/dist/Overlay.module.js.map +0 -1
- package/dist/Popover.main.js +0 -206
- package/dist/Popover.main.js.map +0 -1
- package/dist/Popover.mjs +0 -201
- package/dist/Popover.module.js +0 -201
- package/dist/Popover.module.js.map +0 -1
- package/dist/Tray.main.js +0 -105
- package/dist/Tray.main.js.map +0 -1
- package/dist/Tray.mjs +0 -100
- package/dist/Tray.module.js +0 -100
- package/dist/Tray.module.js.map +0 -1
- package/dist/Underlay.main.js +0 -54
- package/dist/Underlay.main.js.map +0 -1
- package/dist/Underlay.mjs +0 -49
- package/dist/Underlay.module.js +0 -49
- package/dist/Underlay.module.js.map +0 -1
- package/dist/modal_vars_css.main.js +0 -59
- package/dist/modal_vars_css.main.js.map +0 -1
- package/dist/modal_vars_css.mjs +0 -61
- package/dist/modal_vars_css.module.js +0 -61
- package/dist/modal_vars_css.module.js.map +0 -1
- package/dist/overlays.c765f49e.css +0 -131
- package/dist/overlays.c765f49e.css.map +0 -1
- package/dist/overlays.ec5cd7e2.css +0 -210
- package/dist/overlays.ec5cd7e2.css.map +0 -1
- package/dist/overlays.ef39a1b9.css +0 -197
- package/dist/overlays.ef39a1b9.css.map +0 -1
- package/dist/overlays.f1e5a60e.css +0 -184
- package/dist/overlays.f1e5a60e.css.map +0 -1
- package/dist/overlays.f8d97b78.css +0 -12
- package/dist/overlays.f8d97b78.css.map +0 -1
- package/dist/overlays_css.main.js +0 -35
- package/dist/overlays_css.main.js.map +0 -1
- package/dist/overlays_css.mjs +0 -37
- package/dist/overlays_css.module.js +0 -37
- package/dist/overlays_css.module.js.map +0 -1
- package/dist/popover_vars_css.main.js +0 -83
- package/dist/popover_vars_css.main.js.map +0 -1
- package/dist/popover_vars_css.mjs +0 -85
- package/dist/popover_vars_css.module.js +0 -85
- package/dist/popover_vars_css.module.js.map +0 -1
- package/dist/tray_vars_css.main.js +0 -53
- package/dist/tray_vars_css.main.js.map +0 -1
- package/dist/tray_vars_css.mjs +0 -55
- package/dist/tray_vars_css.module.js +0 -55
- package/dist/tray_vars_css.module.js.map +0 -1
- package/dist/types.d.ts +0 -51
- package/dist/types.d.ts.map +0 -1
- package/dist/underlay_vars_css.main.js +0 -50
- package/dist/underlay_vars_css.main.js.map +0 -1
- package/dist/underlay_vars_css.mjs +0 -52
- package/dist/underlay_vars_css.module.js +0 -52
- package/dist/underlay_vars_css.module.js.map +0 -1
- package/src/Modal.tsx +0 -109
- package/src/OpenTransition.tsx +0 -47
- package/src/Overlay.tsx +0 -77
- package/src/Popover.tsx +0 -253
- package/src/Tray.tsx +0 -120
- package/src/Underlay.tsx +0 -43
- package/src/overlays.css +0 -32
package/src/Tray.tsx
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {AriaModalOverlayProps, DismissButton, useModalOverlay} from '@react-aria/overlays';
|
|
14
|
-
import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';
|
|
15
|
-
import {DOMRef, RefObject, StyleProps} from '@react-types/shared';
|
|
16
|
-
import {Overlay} from './Overlay';
|
|
17
|
-
import {OverlayProps} from '@react-types/overlays';
|
|
18
|
-
import {OverlayTriggerState} from '@react-stately/overlays';
|
|
19
|
-
import overrideStyles from './overlays.css';
|
|
20
|
-
import React, {ForwardedRef, forwardRef, ReactNode, useRef} from 'react';
|
|
21
|
-
import trayStyles from '@adobe/spectrum-css-temp/components/tray/vars.css';
|
|
22
|
-
import {Underlay} from './Underlay';
|
|
23
|
-
import {useObjectRef, useViewportSize} from '@react-aria/utils';
|
|
24
|
-
|
|
25
|
-
interface TrayProps extends AriaModalOverlayProps, StyleProps, Omit<OverlayProps, 'nodeRef' | 'shouldContainFocus'> {
|
|
26
|
-
children: ReactNode,
|
|
27
|
-
state: OverlayTriggerState,
|
|
28
|
-
isFixedHeight?: boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface TrayWrapperProps extends TrayProps {
|
|
32
|
-
isOpen?: boolean,
|
|
33
|
-
wrapperRef: RefObject<HTMLDivElement | null>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const Tray = forwardRef(function Tray(props: TrayProps, ref: DOMRef<HTMLDivElement>) {
|
|
37
|
-
let {children, state, ...otherProps} = props;
|
|
38
|
-
let domRef = useDOMRef(ref);
|
|
39
|
-
let wrapperRef = useRef<HTMLDivElement>(null);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Overlay {...otherProps} isOpen={state.isOpen} nodeRef={wrapperRef}>
|
|
43
|
-
<TrayWrapper {...props} wrapperRef={wrapperRef} ref={domRef}>
|
|
44
|
-
{children}
|
|
45
|
-
</TrayWrapper>
|
|
46
|
-
</Overlay>
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
let TrayWrapper = forwardRef(function (props: TrayWrapperProps, ref: ForwardedRef<HTMLDivElement | null>) {
|
|
51
|
-
let {
|
|
52
|
-
children,
|
|
53
|
-
isOpen,
|
|
54
|
-
isFixedHeight,
|
|
55
|
-
state,
|
|
56
|
-
wrapperRef
|
|
57
|
-
} = props;
|
|
58
|
-
let {styleProps} = useStyleProps(props);
|
|
59
|
-
let objRef = useObjectRef(ref);
|
|
60
|
-
|
|
61
|
-
let {modalProps, underlayProps} = useModalOverlay({
|
|
62
|
-
...props,
|
|
63
|
-
isDismissable: true
|
|
64
|
-
}, state, objRef);
|
|
65
|
-
|
|
66
|
-
// We need to measure the window's height in JS rather than using percentages in CSS
|
|
67
|
-
// so that contents (e.g. menu) can inherit the max-height properly. Using percentages
|
|
68
|
-
// does not work properly because there is nothing to base the percentage on.
|
|
69
|
-
// We cannot use vh units because mobile browsers adjust the window height dynamically
|
|
70
|
-
// when the address bar/bottom toolbars show and hide on scroll and vh units are fixed.
|
|
71
|
-
// Also, the visual viewport is smaller than the layout viewport when the virtual keyboard
|
|
72
|
-
// is up, so use the VisualViewport API to ensure the tray is displayed above the keyboard.
|
|
73
|
-
let viewport = useViewportSize();
|
|
74
|
-
let wrapperStyle: any = {
|
|
75
|
-
'--spectrum-visual-viewport-height': viewport.height + 'px',
|
|
76
|
-
// position: fixed elements are clipped by Safari on iOS 26, so we use
|
|
77
|
-
// position: absolute and manually set the top to the scrollY.
|
|
78
|
-
// The page can't scroll while the tray is open so this doesn't need to update.
|
|
79
|
-
top: typeof window !== 'undefined' ? window.scrollY : 0
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
let wrapperClassName = classNames(
|
|
83
|
-
trayStyles,
|
|
84
|
-
'spectrum-Tray-wrapper'
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
let className = classNames(
|
|
88
|
-
trayStyles,
|
|
89
|
-
'spectrum-Tray',
|
|
90
|
-
{
|
|
91
|
-
'is-open': isOpen,
|
|
92
|
-
'spectrum-Tray--fixedHeight': isFixedHeight
|
|
93
|
-
},
|
|
94
|
-
classNames(
|
|
95
|
-
overrideStyles,
|
|
96
|
-
'spectrum-Tray',
|
|
97
|
-
'react-spectrum-Tray'
|
|
98
|
-
),
|
|
99
|
-
styleProps.className
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
// Attach Transition's nodeRef to outer most wrapper for node.reflow: https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L231
|
|
103
|
-
return (
|
|
104
|
-
<div ref={wrapperRef}>
|
|
105
|
-
<Underlay {...underlayProps} isOpen={isOpen} />
|
|
106
|
-
<div className={wrapperClassName} style={wrapperStyle}>
|
|
107
|
-
<div
|
|
108
|
-
{...styleProps}
|
|
109
|
-
{...modalProps}
|
|
110
|
-
className={className}
|
|
111
|
-
ref={objRef}
|
|
112
|
-
data-testid="tray">
|
|
113
|
-
<DismissButton onDismiss={state.close} />
|
|
114
|
-
{children}
|
|
115
|
-
<DismissButton onDismiss={state.close} />
|
|
116
|
-
</div>
|
|
117
|
-
</div>
|
|
118
|
-
</div>
|
|
119
|
-
);
|
|
120
|
-
});
|
package/src/Underlay.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {classNames} from '@react-spectrum/utils';
|
|
14
|
-
import {isScrollable} from '@react-aria/utils';
|
|
15
|
-
import React, {JSX} from 'react';
|
|
16
|
-
import underlayStyles from '@adobe/spectrum-css-temp/components/underlay/vars.css';
|
|
17
|
-
|
|
18
|
-
interface UnderlayProps {
|
|
19
|
-
isOpen?: boolean,
|
|
20
|
-
isTransparent?: boolean
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function Underlay({isOpen, isTransparent, ...otherProps}: UnderlayProps): JSX.Element {
|
|
24
|
-
let pageHeight: number | undefined = undefined;
|
|
25
|
-
if (typeof document !== 'undefined') {
|
|
26
|
-
let scrollingElement = isScrollable(document.body) ? document.body : document.scrollingElement || document.documentElement;
|
|
27
|
-
// Prevent Firefox from adding scrollbars when the page has a fractional height.
|
|
28
|
-
let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;
|
|
29
|
-
pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div
|
|
34
|
-
data-testid="underlay"
|
|
35
|
-
{...otherProps}
|
|
36
|
-
// Cover the entire document so iOS 26 Safari doesn't clip the underlay to the inner viewport.
|
|
37
|
-
style={{height: pageHeight}}
|
|
38
|
-
className={classNames(underlayStyles, 'spectrum-Underlay', {
|
|
39
|
-
'is-open': isOpen,
|
|
40
|
-
'spectrum-Underlay--transparent': isTransparent
|
|
41
|
-
})} />
|
|
42
|
-
);
|
|
43
|
-
}
|
package/src/overlays.css
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
.spectrum-Popover {
|
|
14
|
-
/* This makes the contents of popovers focusable immediately, without waiting
|
|
15
|
-
a frame for animations to start. */
|
|
16
|
-
&.react-spectrum-Popover {
|
|
17
|
-
visibility: visible;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.spectrum-Dialog-content {
|
|
21
|
-
max-height: initial;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.spectrum-Modal-wrapper.react-spectrum-Modal-wrapper,
|
|
26
|
-
.spectrum-Modal.react-spectrum-Modal {
|
|
27
|
-
visibility: visible;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.spectrum-Tray.react-spectrum-Tray {
|
|
31
|
-
visibility: visible;
|
|
32
|
-
}
|