@react-spectrum/overlays 3.8.0 → 4.1.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/main.css +1 -1
- package/dist/main.js +257 -166
- package/dist/main.js.map +1 -1
- package/dist/module.js +258 -167
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +20 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/Modal.tsx +32 -35
- package/src/OpenTransition.tsx +1 -1
- package/src/Overlay.tsx +17 -17
- package/src/Popover.tsx +58 -73
- package/src/Tray.tsx +38 -43
- package/src/Underlay.tsx +4 -3
package/src/Tray.tsx
CHANGED
|
@@ -10,43 +10,35 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import {AriaModalOverlayProps, DismissButton, useModalOverlay} from '@react-aria/overlays';
|
|
13
14
|
import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';
|
|
14
|
-
import {DOMRef} from '@react-types/shared';
|
|
15
|
-
import {mergeProps, useViewportSize} from '@react-aria/utils';
|
|
15
|
+
import {DOMRef, StyleProps} from '@react-types/shared';
|
|
16
16
|
import {Overlay} from './Overlay';
|
|
17
|
+
import {OverlayProps} from '@react-types/overlays';
|
|
18
|
+
import {OverlayTriggerState} from '@react-stately/overlays';
|
|
17
19
|
import overrideStyles from './overlays.css';
|
|
18
|
-
import React, {forwardRef,
|
|
19
|
-
import {TrayProps} from '@react-types/overlays';
|
|
20
|
+
import React, {forwardRef, ReactNode, RefObject} from 'react';
|
|
20
21
|
import trayStyles from '@adobe/spectrum-css-temp/components/tray/vars.css';
|
|
21
22
|
import {Underlay} from './Underlay';
|
|
22
|
-
import {
|
|
23
|
+
import {useViewportSize} from '@react-aria/utils';
|
|
23
24
|
|
|
24
|
-
interface
|
|
25
|
+
interface TrayProps extends AriaModalOverlayProps, StyleProps, OverlayProps {
|
|
25
26
|
children: ReactNode,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
state: OverlayTriggerState,
|
|
28
|
+
isFixedHeight?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface TrayWrapperProps extends TrayProps {
|
|
32
|
+
isOpen?: boolean
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
function Tray(props: TrayProps, ref: DOMRef<HTMLDivElement>) {
|
|
34
|
-
let {children,
|
|
36
|
+
let {children, state, ...otherProps} = props;
|
|
35
37
|
let domRef = useDOMRef(ref);
|
|
36
|
-
let {styleProps} = useStyleProps(props);
|
|
37
|
-
|
|
38
|
-
let {overlayProps, underlayProps} = useOverlay({...props, isDismissable: true}, domRef);
|
|
39
38
|
|
|
40
39
|
return (
|
|
41
|
-
<Overlay {...otherProps}>
|
|
42
|
-
<
|
|
43
|
-
<TrayWrapper
|
|
44
|
-
{...styleProps}
|
|
45
|
-
onClose={onClose}
|
|
46
|
-
ref={domRef}
|
|
47
|
-
overlayProps={overlayProps}
|
|
48
|
-
isFixedHeight={isFixedHeight}
|
|
49
|
-
isNonModal={isNonModal}>
|
|
40
|
+
<Overlay {...otherProps} isOpen={state.isOpen}>
|
|
41
|
+
<TrayWrapper {...props} ref={domRef}>
|
|
50
42
|
{children}
|
|
51
43
|
</TrayWrapper>
|
|
52
44
|
</Overlay>
|
|
@@ -58,14 +50,14 @@ let TrayWrapper = forwardRef(function (props: TrayWrapperProps, ref: RefObject<H
|
|
|
58
50
|
children,
|
|
59
51
|
isOpen,
|
|
60
52
|
isFixedHeight,
|
|
61
|
-
|
|
62
|
-
overlayProps,
|
|
63
|
-
...otherProps
|
|
53
|
+
state
|
|
64
54
|
} = props;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
let {styleProps} = useStyleProps(props);
|
|
56
|
+
|
|
57
|
+
let {modalProps, underlayProps} = useModalOverlay({
|
|
58
|
+
...props,
|
|
59
|
+
isDismissable: true
|
|
60
|
+
}, state, ref);
|
|
69
61
|
|
|
70
62
|
// We need to measure the window's height in JS rather than using percentages in CSS
|
|
71
63
|
// so that contents (e.g. menu) can inherit the max-height properly. Using percentages
|
|
@@ -96,22 +88,25 @@ let TrayWrapper = forwardRef(function (props: TrayWrapperProps, ref: RefObject<H
|
|
|
96
88
|
'spectrum-Tray',
|
|
97
89
|
'react-spectrum-Tray'
|
|
98
90
|
),
|
|
99
|
-
|
|
91
|
+
styleProps.className
|
|
100
92
|
);
|
|
101
93
|
|
|
102
|
-
let domProps = mergeProps(otherProps, overlayProps);
|
|
103
|
-
|
|
104
94
|
return (
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
<>
|
|
96
|
+
<Underlay {...underlayProps} isOpen={isOpen} />
|
|
97
|
+
<div className={wrapperClassName} style={wrapperStyle}>
|
|
98
|
+
<div
|
|
99
|
+
{...styleProps}
|
|
100
|
+
{...modalProps}
|
|
101
|
+
className={className}
|
|
102
|
+
ref={ref}
|
|
103
|
+
data-testid="tray">
|
|
104
|
+
<DismissButton onDismiss={state.close} />
|
|
105
|
+
{children}
|
|
106
|
+
<DismissButton onDismiss={state.close} />
|
|
107
|
+
</div>
|
|
113
108
|
</div>
|
|
114
|
-
|
|
109
|
+
</>
|
|
115
110
|
);
|
|
116
111
|
});
|
|
117
112
|
|
package/src/Underlay.tsx
CHANGED
|
@@ -15,11 +15,12 @@ import React from 'react';
|
|
|
15
15
|
import underlayStyles from '@adobe/spectrum-css-temp/components/underlay/vars.css';
|
|
16
16
|
|
|
17
17
|
interface UnderlayProps {
|
|
18
|
-
isOpen?: boolean
|
|
18
|
+
isOpen?: boolean,
|
|
19
|
+
isTransparent?: boolean
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export function Underlay({isOpen}: UnderlayProps) {
|
|
22
|
+
export function Underlay({isOpen, isTransparent}: UnderlayProps) {
|
|
22
23
|
return (
|
|
23
|
-
<div className={classNames(underlayStyles, 'spectrum-Underlay', {'is-open': isOpen})} />
|
|
24
|
+
<div className={classNames(underlayStyles, 'spectrum-Underlay', {'is-open': isOpen, 'spectrum-Underlay--transparent': isTransparent})} />
|
|
24
25
|
);
|
|
25
26
|
}
|