(props: OverlayContainerProps)
| 134 | * be accessible at once. |
| 135 | */ |
| 136 | export function OverlayContainer(props: OverlayContainerProps): React.ReactPortal | null { |
| 137 | let isSSR = useIsSSR(); |
| 138 | let {portalContainer = isSSR ? null : document.body, ...rest} = props; |
| 139 | let {getContainer} = useUNSAFE_PortalContext(); |
| 140 | if (!props.portalContainer && getContainer) { |
| 141 | portalContainer = getContainer(); |
| 142 | } |
| 143 | |
| 144 | React.useEffect(() => { |
| 145 | if (portalContainer?.closest('[data-overlay-container]')) { |
| 146 | throw new Error( |
| 147 | 'An OverlayContainer must not be inside another container. Please change the portalContainer prop.' |
| 148 | ); |
| 149 | } |
| 150 | }, [portalContainer]); |
| 151 | |
| 152 | if (!portalContainer) { |
| 153 | return null; |
| 154 | } |
| 155 | |
| 156 | let contents = <OverlayProvider {...rest} />; |
| 157 | return ReactDOM.createPortal(contents, portalContainer); |
| 158 | } |
| 159 | |
| 160 | interface ModalAriaProps extends DOMAttributes { |
| 161 | /** Data attribute marks the dom node as a modal for the aria-modal-polyfill. */ |
nothing calls this directly
no test coverage detected