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gBAAgB,EAAE,aAAa,CAAC,EAAE;IAAW,GAChD,WAAW,SAAS;IAGtB,IAAI,WAAW,CAAA,GAAA,2DAAc;IAC7B,IAAI,QAAa;QACf,qCAAqC,SAAS,MAAM,GAAG;IACzD;IAEA,4LAA4L;IAC5L,qBACE,0DAAC;QAAI,KAAK;qBACR,0DAAC,CAAA,GAAA,kCAAO;QAAG,GAAG,aAAa;QAAE,QAAQ;sBACrC,0DAAC;QAAI,WAAW;QAAkB,OAAO;qBACvC,0DAAC;QACE,GAAG,UAAU;QACb,GAAG,UAAU;QACd,KAAK;QACL,WAAW;QACX,eAAY;OACX;AAKX","sources":["packages/@adobe/react-spectrum/src/overlays/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaModalOverlayProps, useModalOverlay} from 'react-aria/useModalOverlay';\n\nimport {classNames} from '../utils/classNames';\nimport {DOMRef, RefObject, StyleProps} from '@react-types/shared';\nimport modalStyles from '@adobe/spectrum-css-temp/components/modal/vars.css';\nimport {Overlay, OverlayProps} from './Overlay';\nimport {OverlayTriggerState} from 'react-stately/useOverlayTriggerState';\nimport overrideStyles from './overlays.css';\nimport React, {ForwardedRef, forwardRef, ReactNode, useRef} from 'react';\nimport {Underlay} from './Underlay';\nimport {useDOMRef} from '../utils/useDOMRef';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useStyleProps} from '../utils/styleProps';\nimport {useViewportSize} from 'react-aria/private/utils/useViewportSize';\n\ninterface ModalProps extends AriaModalOverlayProps, StyleProps, Omit<OverlayProps, 'nodeRef' | 'shouldContainFocus'> {\n  children: ReactNode,\n  state: OverlayTriggerState,\n  type?: 'modal' | 'fullscreen' | 'fullscreenTakeover'\n}\n\ninterface ModalWrapperProps extends ModalProps {\n  isOpen?: boolean,\n  wrapperRef: RefObject<HTMLDivElement | null>,\n  children: ReactNode\n}\n\nexport const Modal = forwardRef(function Modal(props: ModalProps, ref: DOMRef<HTMLDivElement>) {\n  let {children, state, ...otherProps} = props;\n  let domRef = useDOMRef(ref);\n  let wrapperRef = useRef<HTMLDivElement>(null);\n\n  return (\n    <Overlay {...otherProps} isOpen={state.isOpen} nodeRef={wrapperRef}>\n      <ModalWrapper {...props} wrapperRef={wrapperRef} ref={domRef}>\n        {children}\n      </ModalWrapper>\n    </Overlay>\n  );\n});\n\nlet typeMap = {\n  fullscreen: 'fullscreen',\n  fullscreenTakeover: 'fullscreenTakeover'\n};\n\nlet ModalWrapper = forwardRef(function (props: ModalWrapperProps, ref: ForwardedRef<HTMLDivElement | null>) {\n  let {type, children, state, isOpen, wrapperRef} = props;\n  let typeVariant = type != null ? typeMap[type] : undefined;\n  let {styleProps} = useStyleProps(props);\n  let objRef = useObjectRef(ref);\n  let {modalProps, underlayProps} = useModalOverlay(props, state, objRef);\n\n  let wrapperClassName = classNames(\n    modalStyles,\n    'spectrum-Modal-wrapper',\n    classNames(\n      overrideStyles,\n      'spectrum-Modal-wrapper',\n      'react-spectrum-Modal-wrapper'\n    )\n  );\n\n  let modalClassName = classNames(\n    modalStyles,\n    'spectrum-Modal',\n    {\n      'is-open': isOpen\n    },\n    classNames(\n      overrideStyles,\n      'spectrum-Modal',\n      'react-spectrum-Modal'\n    ),\n    {[`spectrum-Modal--${typeVariant}`]: typeVariant},\n    styleProps.className\n  );\n\n  let viewport = useViewportSize();\n  let style: any = {\n    '--spectrum-visual-viewport-height': viewport.height + 'px'\n  };\n\n  // Attach Transition's nodeRef to outer most wrapper for node.reflow: https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L231\n  return (\n    <div ref={wrapperRef}>\n      <Underlay {...underlayProps} isOpen={isOpen} />\n      <div className={wrapperClassName} style={style}>\n        <div\n          {...styleProps}\n          {...modalProps}\n          ref={objRef}\n          className={modalClassName}\n          data-testid=\"modal\">\n          {children}\n        </div>\n      </div>\n    </div>\n  );\n});\n"],"names":[],"version":3,"file":"Modal.cjs.map"}