UNPKG

@react-spectrum/s2

Version:
1 lines 5.2 kB
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmBD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;AAuBC,MAAM,0DAAQ,CAAA,GAAA,iBAAS,EAAE,SAAS,MAAM,MAAiB,EAAE,GAA2B;IAC3F,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,cAAc,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAiB;IAC9C,IAAI,UAAC,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAElC,0DAA0D;IAC1D,IAAI,WAAW,CAAA,GAAA,kBAAU,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,gBAAC,CAAA,GAAA,mBAAW;QACT,GAAG,MAAK;QACT,WAAW,CAAA,cAAe,yCAAmB;gBAAC,GAAG,WAAW;6BAAE;YAAW;kBACzE,cAAA,gBAAC,CAAA,GAAA,YAAO;YACL,GAAG,MAAK;YACT,KAAK;YACL,WAAW,CAAA,cAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgEvB;oBAAC,GAAG,WAAW;oBAAE,MAAM,OAAM,IAAI;gBAAA;;;AAG5C","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} 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 ModalOverlayProps {\n /**\n * The size of the Modal.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'fullscreen' | 'fullscreenTakeover'\n}\n\nconst modalOverlayStyles = style({\n ...colorScheme(),\n position: 'fixed',\n inset: 0,\n isolation: 'isolate',\n backgroundColor: 'transparent-black-500',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n opacity: {\n isEntering: 0,\n isExiting: 0\n },\n transition: 'opacity',\n transitionDuration: {\n default: 250,\n isExiting: 130\n }\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 <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 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: '90vh',\n size: {\n fullscreen: 'none',\n fullscreenTakeover: 'none'\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 </ModalOverlay>\n );\n});\n"],"names":[],"version":3,"file":"Modal.mjs.map"}