@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.
Files changed (82) hide show
  1. package/dist/import.mjs +6 -6
  2. package/dist/main.js +10 -10
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +6 -6
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +6 -0
  7. package/package.json +13 -33
  8. package/src/index.ts +7 -5
  9. package/dist/Modal.main.js +0 -93
  10. package/dist/Modal.main.js.map +0 -1
  11. package/dist/Modal.mjs +0 -88
  12. package/dist/Modal.module.js +0 -88
  13. package/dist/Modal.module.js.map +0 -1
  14. package/dist/OpenTransition.main.js +0 -44
  15. package/dist/OpenTransition.main.js.map +0 -1
  16. package/dist/OpenTransition.mjs +0 -35
  17. package/dist/OpenTransition.module.js +0 -35
  18. package/dist/OpenTransition.module.js.map +0 -1
  19. package/dist/Overlay.main.js +0 -75
  20. package/dist/Overlay.main.js.map +0 -1
  21. package/dist/Overlay.mjs +0 -66
  22. package/dist/Overlay.module.js +0 -66
  23. package/dist/Overlay.module.js.map +0 -1
  24. package/dist/Popover.main.js +0 -206
  25. package/dist/Popover.main.js.map +0 -1
  26. package/dist/Popover.mjs +0 -201
  27. package/dist/Popover.module.js +0 -201
  28. package/dist/Popover.module.js.map +0 -1
  29. package/dist/Tray.main.js +0 -105
  30. package/dist/Tray.main.js.map +0 -1
  31. package/dist/Tray.mjs +0 -100
  32. package/dist/Tray.module.js +0 -100
  33. package/dist/Tray.module.js.map +0 -1
  34. package/dist/Underlay.main.js +0 -54
  35. package/dist/Underlay.main.js.map +0 -1
  36. package/dist/Underlay.mjs +0 -49
  37. package/dist/Underlay.module.js +0 -49
  38. package/dist/Underlay.module.js.map +0 -1
  39. package/dist/modal_vars_css.main.js +0 -59
  40. package/dist/modal_vars_css.main.js.map +0 -1
  41. package/dist/modal_vars_css.mjs +0 -61
  42. package/dist/modal_vars_css.module.js +0 -61
  43. package/dist/modal_vars_css.module.js.map +0 -1
  44. package/dist/overlays.c765f49e.css +0 -131
  45. package/dist/overlays.c765f49e.css.map +0 -1
  46. package/dist/overlays.ec5cd7e2.css +0 -210
  47. package/dist/overlays.ec5cd7e2.css.map +0 -1
  48. package/dist/overlays.ef39a1b9.css +0 -197
  49. package/dist/overlays.ef39a1b9.css.map +0 -1
  50. package/dist/overlays.f1e5a60e.css +0 -184
  51. package/dist/overlays.f1e5a60e.css.map +0 -1
  52. package/dist/overlays.f8d97b78.css +0 -12
  53. package/dist/overlays.f8d97b78.css.map +0 -1
  54. package/dist/overlays_css.main.js +0 -35
  55. package/dist/overlays_css.main.js.map +0 -1
  56. package/dist/overlays_css.mjs +0 -37
  57. package/dist/overlays_css.module.js +0 -37
  58. package/dist/overlays_css.module.js.map +0 -1
  59. package/dist/popover_vars_css.main.js +0 -83
  60. package/dist/popover_vars_css.main.js.map +0 -1
  61. package/dist/popover_vars_css.mjs +0 -85
  62. package/dist/popover_vars_css.module.js +0 -85
  63. package/dist/popover_vars_css.module.js.map +0 -1
  64. package/dist/tray_vars_css.main.js +0 -53
  65. package/dist/tray_vars_css.main.js.map +0 -1
  66. package/dist/tray_vars_css.mjs +0 -55
  67. package/dist/tray_vars_css.module.js +0 -55
  68. package/dist/tray_vars_css.module.js.map +0 -1
  69. package/dist/types.d.ts +0 -51
  70. package/dist/types.d.ts.map +0 -1
  71. package/dist/underlay_vars_css.main.js +0 -50
  72. package/dist/underlay_vars_css.main.js.map +0 -1
  73. package/dist/underlay_vars_css.mjs +0 -52
  74. package/dist/underlay_vars_css.module.js +0 -52
  75. package/dist/underlay_vars_css.module.js.map +0 -1
  76. package/src/Modal.tsx +0 -109
  77. package/src/OpenTransition.tsx +0 -47
  78. package/src/Overlay.tsx +0 -77
  79. package/src/Popover.tsx +0 -253
  80. package/src/Tray.tsx +0 -120
  81. package/src/Underlay.tsx +0 -43
  82. 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
- }