@react-spectrum/s2
Version:
Spectrum 2 UI components in React
1 lines • 6.17 kB
Source Map (JSON)
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmBD,MAAM;;;;;;;;;;;;;;;;;;;;;AAoBN,MAAM;;;;;;;;;;;;;AAmBC,MAAM,0DAAQ,CAAA,GAAA,uBAAS,EAAE,SAAS,MAAM,MAAiB,EAAE,GAA2B;IAC3F,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,cAAc,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,4CAAiB;IAC9C,IAAI,UAAC,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,oCAAQ;IAElC,0DAA0D;IAC1D,IAAI,WAAW,CAAA,GAAA,wBAAU,EAAE,CAAC;QACzB,OAA4C,OAAO,GAAG;QACvD,IAAI,IAAI;YACN,GAAG,IAAI,GAAG;YACV,GAAG,GAAG,GAAG;QACX;IACF,GAAG;QAAC;QAAQ;QAAW;KAAO;IAE9B,qBACE,gCAAC,CAAA,GAAA,uCAAW;QACT,GAAG,MAAK;QACT,WAAW,CAAA,cAAe,yCAAmB;gBAAC,GAAG,WAAW;6BAAE;YAAW;kBACzE,cAAA,gCAAC;YAAI,WAAW,mCAAa;gBAAC,MAAM,OAAM,IAAI;YAAA;YAAI,OAAO;gBAAC,eAAe;YAAM;sBAC7E,cAAA,gCAAC,CAAA,GAAA,gCAAO;gBACL,GAAG,MAAK;gBACT,KAAK;gBACL,WAAW,CAAA,cAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAuEvB;wBAAC,GAAG,WAAW;wBAAE,MAAM,OAAM,IAAI;oBAAA;;;;AAI9C","sources":["packages/@react-spectrum/s2/src/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {colorScheme} from './style-utils' with {type: 'macro'};\nimport {ColorSchemeContext} from './Provider';\nimport {DOMRef, GlobalDOMAttributes} from '@react-types/shared';\nimport {forwardRef, MutableRefObject, useCallback, useContext} from 'react';\nimport {ModalOverlay, ModalOverlayProps, Modal as RACModal, useLocale} from 'react-aria-components';\nimport {style} from '../style' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\n\ninterface ModalProps extends Omit<ModalOverlayProps, 'className' | 'style' | keyof GlobalDOMAttributes> {\n /**\n * The size of the Modal.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL' | 'fullscreen' | 'fullscreenTakeover'\n}\n\nconst modalOverlayStyles = style({\n ...colorScheme(),\n position: 'absolute',\n top: 0,\n left: 0,\n width: 'full',\n height: '--page-height',\n isolation: 'isolate',\n backgroundColor: 'transparent-black-500',\n opacity: {\n isEntering: 0,\n isExiting: 0\n },\n transition: 'opacity',\n transitionDuration: {\n default: 250,\n isExiting: 130\n }\n});\n\nconst modalWrapper = style({\n position: 'sticky',\n top: 0,\n left: 0,\n width: 'full',\n height: '--visual-viewport-height',\n display: 'flex',\n alignItems: {\n default: 'center',\n size: {\n fullscreenTakeover: 'start'\n }\n },\n justifyContent: 'center'\n});\n\n/**\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport const Modal = forwardRef(function Modal(props: ModalProps, ref: DOMRef<HTMLDivElement>) {\n let domRef = useDOMRef(ref);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n\n // TODO: should we pass through lang and dir props in RAC?\n let modalRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n }\n }, [locale, direction, domRef]);\n\n return (\n <ModalOverlay\n {...props}\n className={renderProps => modalOverlayStyles({...renderProps, colorScheme})}>\n <div className={modalWrapper({size: props.size})} style={{containerType: 'size'} as any}>\n <RACModal\n {...props}\n ref={modalRef}\n className={renderProps => style({\n display: 'flex',\n flexDirection: 'column',\n borderRadius: {\n default: 'xl',\n size: {\n fullscreenTakeover: 'none'\n }\n },\n width: {\n size: {\n // Copied from designs, not sure if correct.\n S: 400,\n M: 480,\n L: 640,\n XL: 960,\n fullscreen: 'calc(100% - 40px)',\n fullscreenTakeover: 'full'\n }\n },\n height: {\n size: {\n fullscreen: 'calc(100% - 40px)',\n fullscreenTakeover: 'full'\n }\n },\n maxWidth: {\n default: '90vw',\n size: {\n fullscreen: 'none',\n fullscreenTakeover: 'none'\n }\n },\n maxHeight: {\n default: '90%',\n size: {\n fullscreen: 'none',\n fullscreenTakeover: 'none'\n }\n },\n paddingBottom: {\n size: {\n // Extend background behind the iOS Safari toolbar and keyboard.\n fullscreenTakeover: '[100vh]'\n }\n },\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: 'layer-2'\n },\n backgroundColor: '--s2-container-bg',\n opacity: {\n isEntering: 0,\n isExiting: 0\n },\n translateY: {\n isEntering: 20\n },\n transition: '[opacity, translate]',\n transitionDuration: {\n default: 250,\n isExiting: 130\n },\n transitionDelay: {\n default: 160,\n isExiting: 0\n },\n // Transparent outline for WHCM.\n outlineStyle: 'solid',\n outlineWidth: 1,\n outlineColor: 'transparent'\n })({...renderProps, size: props.size})} />\n </div>\n </ModalOverlay>\n );\n});\n"],"names":[],"version":3,"file":"Modal.cjs.map"}