@depup/react-aria-components 1.21.0-depup.0 → 1.22.0-depup.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 (55) hide show
  1. package/README.md +4 -3
  2. package/Sheet/package.json +5 -0
  3. package/changes.json +6 -2
  4. package/dist/exports/Sheet.cjs +30 -0
  5. package/dist/exports/Sheet.cjs.map +1 -0
  6. package/dist/exports/Sheet.js +21 -0
  7. package/dist/exports/Sheet.js.map +1 -0
  8. package/dist/exports/Sheet.mjs +21 -0
  9. package/dist/exports/Sheet.mjs.map +1 -0
  10. package/dist/exports/TokenField.cjs +1 -0
  11. package/dist/exports/TokenField.cjs.map +1 -1
  12. package/dist/exports/TokenField.js +2 -2
  13. package/dist/exports/TokenField.js.map +1 -1
  14. package/dist/exports/TokenField.mjs +2 -2
  15. package/dist/exports/TokenField.mjs.map +1 -1
  16. package/dist/exports/index.cjs +7 -0
  17. package/dist/exports/index.cjs.map +1 -1
  18. package/dist/exports/index.js +3 -1
  19. package/dist/exports/index.js.map +1 -1
  20. package/dist/exports/index.mjs +3 -1
  21. package/dist/exports/index.mjs.map +1 -1
  22. package/dist/private/Breadcrumbs.cjs +1 -1
  23. package/dist/private/Breadcrumbs.cjs.map +1 -1
  24. package/dist/private/Breadcrumbs.js +1 -1
  25. package/dist/private/Breadcrumbs.js.map +1 -1
  26. package/dist/private/Breadcrumbs.mjs +1 -1
  27. package/dist/private/Breadcrumbs.mjs.map +1 -1
  28. package/dist/private/Modal.cjs +56 -11
  29. package/dist/private/Modal.cjs.map +1 -1
  30. package/dist/private/Modal.js +61 -14
  31. package/dist/private/Modal.js.map +1 -1
  32. package/dist/private/Modal.mjs +58 -14
  33. package/dist/private/Modal.mjs.map +1 -1
  34. package/dist/private/NavigationTree.cjs.map +1 -1
  35. package/dist/private/NavigationTree.js.map +1 -1
  36. package/dist/private/NavigationTree.mjs.map +1 -1
  37. package/dist/private/Popover.cjs +10 -2
  38. package/dist/private/Popover.cjs.map +1 -1
  39. package/dist/private/Popover.js +10 -2
  40. package/dist/private/Popover.js.map +1 -1
  41. package/dist/private/Popover.mjs +10 -2
  42. package/dist/private/Popover.mjs.map +1 -1
  43. package/dist/private/Sheet.cjs +827 -0
  44. package/dist/private/Sheet.cjs.map +1 -0
  45. package/dist/private/Sheet.js +820 -0
  46. package/dist/private/Sheet.js.map +1 -0
  47. package/dist/private/Sheet.mjs +814 -0
  48. package/dist/private/Sheet.mjs.map +1 -0
  49. package/dist/types/exports/Sheet.d.ts +3 -0
  50. package/dist/types/exports/TokenField.d.ts +2 -2
  51. package/dist/types/exports/index.d.ts +2 -0
  52. package/dist/types/src/Modal.d.ts +28 -1
  53. package/dist/types/src/NavigationTree.d.ts +1 -1
  54. package/dist/types/src/Sheet.d.ts +149 -0
  55. package/package.json +13 -8
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAuEM,MAAM,0DAAe,CAAA,GAAA,0BAAY,EAAmD;AAC3F,MAAM,2DAAuB,CAAA,GAAA,0BAAY,EAAoC;AAwBtE,MAAM,4CAAsB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB,SAAS,MACzE,KAAwB,EACxB,GAAiC;IAEjC,IAAI,MAAM,CAAA,GAAA,uBAAS,EAAE;IAErB,IAAI,KAAK;QACP,IACE,QAAQ,GAAG,CAAC,QAAQ,KAAK,gBACxB,CAAA,MAAM,YAAY,IAAI,MAAM,WAAW,KAAK,aAAa,MAAM,MAAM,KAAK,SAAQ,GACnF;YACA,gGAAgG;YAChG,MAAM,aAAa,IAAI,IAAI;gBACzB;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;aACD;YACD,MAAM,eAAe,OAAO,IAAI,CAAC,OAAO,MAAM,CAAC,CAAA,MAAO,WAAW,GAAG,CAAC;YACrE,QAAQ,IAAI,CACV,CAAC,wDAAwD,EAAE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QACL,GAAG,CAAA,GAAA,qCAAS,EAAE,CAAA,GAAA,6CAAa,EAAE,OAAO;YAAC,QAAQ;QAAI,IAAI,WAAW;QAChE,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,YAAY;QAC3B,gBAAc,aAAa;OAC1B,+BAAiB,0DAAC,CAAA,GAAA,qCAAY;QAAE,WAAW,MAAM,KAAK;QACtD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {DismissButton, Overlay} from 'react-aria/Overlay';\nimport {DOMAttributes, forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {isScrollable} from 'react-aria/private/utils/isScrollable';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {\n OverlayTriggerProps,\n OverlayTriggerState,\n useOverlayTriggerState\n} from 'react-stately/useOverlayTriggerState';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo, useRef} from 'react';\nimport {useEnterAnimation, useExitAnimation} from 'react-aria/private/utils/animation';\nimport {useIsSSR} from 'react-aria/SSRProvider';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useViewportSize} from 'react-aria/private/utils/useViewportSize';\n\nexport interface ModalOverlayProps\n extends\n AriaModalOverlayProps,\n OverlayTriggerProps,\n RenderProps<ModalRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalOverlay'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n /**\n * Whether the modal is currently performing an entry animation.\n */\n isEntering?: boolean;\n /**\n * Whether the modal is currently performing an exit animation.\n */\n isExiting?: boolean;\n /**\n * The container element in which the overlay portal will be placed. This may have unknown\n * behavior depending on where it is portalled to.\n *\n * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n * @default document.body\n */\n UNSTABLE_portalContainer?: Element;\n}\n\ninterface InternalModalContextValue {\n modalProps: DOMAttributes;\n modalRef: RefObject<HTMLDivElement | null>;\n isExiting: boolean;\n isDismissable?: boolean;\n}\n\nexport const ModalContext = createContext<ContextValue<ModalOverlayProps, HTMLDivElement>>(null);\nconst InternalModalContext = createContext<InternalModalContextValue | null>(null);\n\nexport interface ModalRenderProps {\n /**\n * Whether the modal is currently entering. Use this to apply animations.\n *\n * @selector [data-entering]\n */\n isEntering: boolean;\n /**\n * Whether the modal is currently exiting. Use this to apply animations.\n *\n * @selector [data-exiting]\n */\n isExiting: boolean;\n /**\n * State of the modal.\n */\n state: OverlayTriggerState;\n}\n\n/**\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport const Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(function Modal(\n props: ModalOverlayProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let ctx = useContext(InternalModalContext);\n\n if (ctx) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n // create a list of props that are passed in but not allowed when using an external ModalOverlay\n const invalidSet = new Set([\n 'isDismissable',\n 'isKeyboardDismissDisabled',\n 'isOpen',\n 'defaultOpen',\n 'onOpenChange',\n 'isEntering',\n 'isExiting',\n 'UNSTABLE_portalContainer',\n 'shouldCloseOnInteractOutside'\n ]);\n const invalidProps = Object.keys(props).filter(key => invalidSet.has(key));\n console.warn(\n `This modal is already wrapped in a ModalOverlay, props [${invalidProps.join(', ')}] should be placed on the ModalOverlay instead.`\n );\n }\n return (\n <ModalContent {...props} modalRef={ref}>\n {props.children}\n </ModalContent>\n );\n }\n\n let {\n isDismissable,\n isKeyboardDismissDisabled,\n isOpen,\n defaultOpen,\n onOpenChange,\n children,\n isEntering,\n isExiting,\n UNSTABLE_portalContainer,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n return (\n <ModalOverlay\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n isEntering={isEntering}\n isExiting={isExiting}\n UNSTABLE_portalContainer={UNSTABLE_portalContainer}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}>\n <ModalContent {...otherProps} modalRef={ref}>\n {children}\n </ModalContent>\n </ModalOverlay>\n );\n});\n\ninterface ModalOverlayInnerProps extends ModalOverlayProps {\n overlayRef: RefObject<HTMLDivElement | null>;\n modalRef: RefObject<HTMLDivElement | null>;\n state: OverlayTriggerState;\n isExiting: boolean;\n}\n\nfunction ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ModalContext);\n let contextState = useContext(OverlayTriggerStateContext);\n let localState = useOverlayTriggerState(props);\n let state =\n props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;\n if (state === contextState) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n console.warn(\n 'This modals state is controlled by a trigger, place onOpenChange on the trigger instead.'\n );\n }\n }\n\n let objectRef = useObjectRef(ref);\n let modalRef = useRef<HTMLDivElement>(null);\n let isOverlayExiting = useExitAnimation(objectRef, state.isOpen);\n let isModalExiting = useExitAnimation(modalRef, state.isOpen);\n let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;\n let isSSR = useIsSSR();\n\n if ((!state.isOpen && !isExiting) || isSSR) {\n return null;\n }\n\n return (\n <ModalOverlayInner\n {...props}\n state={state}\n isExiting={isExiting}\n overlayRef={objectRef}\n modalRef={modalRef}\n />\n );\n}\n\n/**\n * A ModalOverlay is a wrapper for a Modal which allows customizing the backdrop element.\n */\nexport const ModalOverlay = /*#__PURE__*/ (forwardRef as forwardRefType)(\n ModalOverlayWithForwardRef\n);\n\nfunction ModalOverlayInner({UNSTABLE_portalContainer, ...props}: ModalOverlayInnerProps) {\n let modalRef = props.modalRef;\n let {state} = props;\n let {modalProps, underlayProps} = useModalOverlay(props, state, modalRef);\n\n let entering = useEnterAnimation(props.overlayRef) || props.isEntering || false;\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ModalOverlay',\n values: {\n isEntering: entering,\n isExiting: props.isExiting,\n state\n }\n });\n\n let viewport = useViewportSize();\n let pageWidth: number | undefined = undefined;\n let pageHeight: number | undefined = undefined;\n if (typeof document !== 'undefined') {\n let scrollingElement = isScrollable(document.body)\n ? document.body\n : document.scrollingElement || document.documentElement;\n // Prevent Firefox from adding scrollbars when the page has a fractional width/height.\n let fractionalWidthDifference = scrollingElement.getBoundingClientRect().width % 1;\n let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;\n pageWidth = scrollingElement.scrollWidth - fractionalWidthDifference;\n pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;\n }\n\n let style = {\n ...renderProps.style,\n '--visual-viewport-width': viewport.width + 'px',\n '--visual-viewport-height': viewport.height + 'px',\n '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,\n '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined\n };\n\n // oxlint-disable react/react-compiler\n return (\n <Overlay isExiting={props.isExiting} portalContainer={UNSTABLE_portalContainer}>\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), underlayProps)}\n {...renderProps}\n style={style}\n ref={props.overlayRef}\n data-entering={entering || undefined}\n data-exiting={props.isExiting || undefined}>\n <Provider\n values={[\n [\n InternalModalContext,\n {modalProps, modalRef, isExiting: props.isExiting, isDismissable: props.isDismissable}\n ],\n [OverlayTriggerStateContext, state]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n </Overlay>\n );\n // oxlint-enable react/react-compiler\n}\n\ninterface ModalContentProps\n extends RenderProps<ModalRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalContent'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n modalRef: ForwardedRef<HTMLDivElement>;\n}\n\nfunction ModalContent(props: ModalContentProps) {\n let {modalProps, modalRef, isExiting, isDismissable} = useContext(InternalModalContext)!;\n let state = useContext(OverlayTriggerStateContext)!;\n let mergedRefs = useMemo(() => mergeRefs(props.modalRef, modalRef), [props.modalRef, modalRef]);\n\n let ref = useObjectRef(mergedRefs);\n let entering = useEnterAnimation(ref);\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Modal',\n values: {\n isEntering: entering,\n isExiting,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), modalProps)}\n {...renderProps}\n ref={ref}\n data-entering={entering || undefined}\n data-exiting={isExiting || undefined}>\n {isDismissable && <DismissButton onDismiss={state.close} />}\n {renderProps.children}\n </dom.div>\n );\n}\n"],"names":[],"version":3,"file":"Modal.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAmGM,MAAM,0D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,IAAI,aAAa,CAAA,GAAA,oBAAM,EAAE,IAAM,CAAA,GAAA,mCAAQ,EAAE,MAAM,QAAQ,EAAE,WAAW;QAAC,MAAM,QAAQ;QAAE;KAAS;IAE9F,IAAI,MAAM,CAAA,GAAA,yCAAW,EAAE;IACvB,IAAI,WAAW,CAAA,GAAA,uDAAgB,EAAE,KAAK,QAAQ,MAAM,OAAO;IAC3D,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;YACN,YAAY;uBACZ;mBACA;QACF;IACF;IAEA,CAAA,GAAA,2DAAc,EAAE;QACd,IAAI,WACF,UAAU,OAAO,GAAG,MAAM,MAAM;IAEpC;IAEA,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,qCAAS,EAAE,CAAA,GAAA,6CAAa,EAAE,OAAO;YAAC,QAAQ;QAAI,IAAI,WAAW;QAChE,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,YAAY;QAC3B,gBAAc,aAAa;OAC1B,+BAAiB,0DAAC,CAAA,GAAA,qCAAY;QAAE,WAAW,MAAM,KAAK;QACtD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2022 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';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {DialogContext, DialogProps, OverlayTriggerStateContext} from './Dialog';\nimport {DismissButton, Overlay} from 'react-aria/Overlay';\nimport {DOMAttributes, forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {isScrollable} from 'react-aria/private/utils/isScrollable';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {\n OverlayTriggerProps,\n OverlayTriggerState,\n useOverlayTriggerState\n} from 'react-stately/useOverlayTriggerState';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {runAfterKeyboard} from 'react-aria/private/utils/runAfterKeyboard';\nimport {useEnterAnimation, useExitAnimation} from 'react-aria/private/utils/animation';\nimport {useIsSSR} from 'react-aria/SSRProvider';\nimport {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useViewportSize} from 'react-aria/private/utils/useViewportSize';\n\nexport interface ModalOverlayProps\n extends\n AriaModalOverlayProps,\n OverlayTriggerProps,\n RenderProps<ModalRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalOverlay'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n /**\n * Whether the modal is currently performing an entry animation.\n */\n isEntering?: boolean;\n /**\n * Whether the modal is currently performing an exit animation.\n */\n isExiting?: boolean;\n /**\n * Callback when the modal starts entering. Return a promise to indicate when the entry animation\n * has completed.\n */\n onEnter?: (element: HTMLElement) => void | Promise<void>;\n /**\n * Callback when the modal starts exiting. Return a promise to indicate when the exit animation\n * has completed.\n */\n onExit?: (element: HTMLElement) => void | Promise<void>;\n /**\n * The container element in which the overlay portal will be placed. This may have unknown\n * behavior depending on where it is portalled to.\n *\n * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n * @default document.body\n */\n UNSTABLE_portalContainer?: Element;\n /**\n * Whether to wait until the entry animation completes before hiding content outside the modal\n * and moving focus into it.\n *\n * @private\n */\n UNSTABLE_deferUntilEntered?: boolean;\n}\n\ninterface InternalModalContextValue {\n modalProps: DOMAttributes;\n modalRef: RefObject<HTMLDivElement | null>;\n isOpen: boolean;\n isExiting: boolean;\n isDismissable?: boolean;\n onExitRef?: RefObject<ModalOverlayProps['onExit'] | null>;\n}\n\nexport const ModalContext = createContext<ContextValue<ModalOverlayProps, HTMLDivElement>>(null);\nexport const InternalModalContext = createContext<InternalModalContextValue | null>(null);\n\nexport interface ModalRenderProps {\n /**\n * Whether the modal is currently entering. Use this to apply animations.\n *\n * @selector [data-entering]\n */\n isEntering: boolean;\n /**\n * Whether the modal is currently exiting. Use this to apply animations.\n *\n * @selector [data-exiting]\n */\n isExiting: boolean;\n /**\n * State of the modal.\n */\n state: OverlayTriggerState;\n}\n\n/**\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport const Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(function Modal(\n props: ModalOverlayProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let ctx = useContext(InternalModalContext);\n\n if (ctx) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n // create a list of props that are passed in but not allowed when using an external ModalOverlay\n const invalidSet = new Set([\n 'isDismissable',\n 'isKeyboardDismissDisabled',\n 'isOpen',\n 'defaultOpen',\n 'onOpenChange',\n 'isEntering',\n 'isExiting',\n 'UNSTABLE_portalContainer',\n 'shouldCloseOnInteractOutside'\n ]);\n const invalidProps = Object.keys(props).filter(key => invalidSet.has(key));\n console.warn(\n `This modal is already wrapped in a ModalOverlay, props [${invalidProps.join(', ')}] should be placed on the ModalOverlay instead.`\n );\n }\n return (\n <ModalContent {...props} modalRef={ref}>\n {props.children}\n </ModalContent>\n );\n }\n\n let {\n isDismissable,\n isKeyboardDismissDisabled,\n isOpen,\n defaultOpen,\n onOpenChange,\n children,\n isEntering,\n isExiting,\n UNSTABLE_portalContainer,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n return (\n <ModalOverlay\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n isEntering={isEntering}\n isExiting={isExiting}\n UNSTABLE_portalContainer={UNSTABLE_portalContainer}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}>\n <ModalContent {...otherProps} modalRef={ref}>\n {children}\n </ModalContent>\n </ModalOverlay>\n );\n});\n\ninterface ModalOverlayInnerProps extends ModalOverlayProps {\n overlayRef: RefObject<HTMLDivElement | null>;\n modalRef: RefObject<HTMLDivElement | null>;\n state: OverlayTriggerState;\n isExiting: boolean;\n onExitRef?: RefObject<ModalOverlayProps['onExit'] | null>;\n}\n\nfunction ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ModalContext);\n let contextState = useContext(OverlayTriggerStateContext);\n let localState = useOverlayTriggerState(props);\n let state =\n props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;\n if (state === contextState) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n console.warn(\n 'This modals state is controlled by a trigger, place onOpenChange on the trigger instead.'\n );\n }\n }\n\n let objectRef = useObjectRef(ref);\n let modalRef = useRef<HTMLDivElement>(null);\n let isOverlayExiting = useExitAnimation(objectRef, state.isOpen, props.onExit);\n let onExitRef = useRef<ModalOverlayProps['onExit'] | null>(null);\n let isModalExiting = useExitAnimation(modalRef, state.isOpen, element =>\n onExitRef.current?.(element)\n );\n let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;\n let isSSR = useIsSSR();\n\n if ((!state.isOpen && !isExiting) || isSSR) {\n return null;\n }\n\n return (\n <ModalOverlayInner\n {...props}\n state={state}\n isExiting={isExiting}\n overlayRef={objectRef}\n modalRef={modalRef}\n onExitRef={onExitRef}\n />\n );\n}\n\n/**\n * A ModalOverlay is a wrapper for a Modal which allows customizing the backdrop element.\n */\nexport const ModalOverlay = /*#__PURE__*/ (forwardRef as forwardRefType)(\n ModalOverlayWithForwardRef\n);\n\nfunction ModalOverlayInner({\n UNSTABLE_portalContainer,\n UNSTABLE_deferUntilEntered,\n ...props\n}: ModalOverlayInnerProps) {\n let modalRef = props.modalRef;\n let {state} = props;\n\n let [isOpen, setIsOpen] = useState(false);\n let entering =\n useEnterAnimation(props.overlayRef, isOpen, props.onEnter) || props.isEntering || false;\n let isDeferred = !!UNSTABLE_deferUntilEntered && (!isOpen || entering);\n let {modalProps, underlayProps} = useModalOverlay(\n {...props, isEntering: isDeferred},\n state,\n modalRef\n );\n\n // Pass the entering state to the dialog so it waits to move focus until the modal has entered.\n let dialogContext = useContext(DialogContext);\n let mergedDialogContext = UNSTABLE_deferUntilEntered\n ? mergeDialogContext(dialogContext, {isEntering: isDeferred})\n : dialogContext;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ModalOverlay',\n values: {\n isEntering: entering,\n isExiting: props.isExiting,\n state\n }\n });\n\n let viewport = useViewportSize();\n let pageWidth: number | undefined = undefined;\n let pageHeight: number | undefined = undefined;\n if (typeof document !== 'undefined') {\n let scrollingElement = isScrollable(document.body)\n ? document.body\n : document.scrollingElement || document.documentElement;\n // Prevent Firefox from adding scrollbars when the page has a fractional width/height.\n let fractionalWidthDifference = scrollingElement.getBoundingClientRect().width % 1;\n let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;\n pageWidth = scrollingElement.scrollWidth - fractionalWidthDifference;\n pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;\n }\n\n let style = {\n ...renderProps.style,\n '--visual-viewport-width': viewport.width + 'px',\n '--visual-viewport-height': viewport.height + 'px',\n '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,\n '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined\n };\n\n // Since an auto-focused input may open the OSK, we defer the reveal, as a courtesy, to avoid layout shift.\n useLayoutEffect(() => runAfterKeyboard(() => setIsOpen(true)), []);\n\n // oxlint-disable react/react-compiler\n return (\n <Overlay isExiting={props.isExiting} portalContainer={UNSTABLE_portalContainer}>\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), underlayProps)}\n {...renderProps}\n style={style}\n ref={props.overlayRef}\n data-entering={entering || undefined}\n data-exiting={props.isExiting || undefined}>\n <Provider\n values={[\n [\n InternalModalContext,\n {\n modalProps,\n modalRef,\n isExiting: props.isExiting,\n onExitRef: props.onExitRef,\n isOpen,\n isDismissable: props.isDismissable\n }\n ],\n [OverlayTriggerStateContext, state],\n [DialogContext, mergedDialogContext]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n </Overlay>\n );\n // oxlint-enable react/react-compiler\n}\n\nfunction mergeDialogContext(\n context: ContextValue<DialogProps, HTMLElement>,\n props: Partial<DialogProps>\n): ContextValue<DialogProps, HTMLElement> {\n if (context && 'slots' in context && context.slots) {\n let slots = {};\n for (let key in context.slots) {\n slots[key] = {...context.slots[key], ...props};\n }\n return {...context, slots};\n }\n return {...context, ...props};\n}\n\ninterface ModalContentProps\n extends RenderProps<ModalRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalContent'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n modalRef: ForwardedRef<HTMLDivElement>;\n onEnter?: (element: HTMLElement) => void;\n onExit?: (element: HTMLElement) => void;\n}\n\nfunction ModalContent(props: ModalContentProps) {\n let {modalProps, modalRef, isExiting, onExitRef, isDismissable, isOpen} =\n useContext(InternalModalContext)!;\n let state = useContext(OverlayTriggerStateContext)!;\n let mergedRefs = useMemo(() => mergeRefs(props.modalRef, modalRef), [props.modalRef, modalRef]);\n\n let ref = useObjectRef(mergedRefs);\n let entering = useEnterAnimation(ref, isOpen, props.onEnter);\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Modal',\n values: {\n isEntering: entering,\n isExiting,\n state\n }\n });\n\n useLayoutEffect(() => {\n if (onExitRef) {\n onExitRef.current = props.onExit;\n }\n });\n\n return (\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), modalProps)}\n {...renderProps}\n ref={ref}\n data-entering={entering || undefined}\n data-exiting={isExiting || undefined}>\n {isDismissable && <DismissButton onDismiss={state.close} />}\n {renderProps.children}\n </dom.div>\n );\n}\n"],"names":[],"version":3,"file":"Modal.cjs.map"}
@@ -1,5 +1,5 @@
1
1
  import {dom as $b7b7a92703138c9b$export$df3a06d6289f983e, Provider as $b7b7a92703138c9b$export$2881499e37b75b9a, useContextProps as $b7b7a92703138c9b$export$29f1550f4b0d4415, useRenderProps as $b7b7a92703138c9b$export$4d86445c2cf5e3} from "./utils.js";
2
- import {OverlayTriggerStateContext as $acf8e70c2f419f18$export$d2f961adcb0afbe} from "./Dialog.js";
2
+ import {DialogContext as $acf8e70c2f419f18$export$8b93a07348a7730c, OverlayTriggerStateContext as $acf8e70c2f419f18$export$d2f961adcb0afbe} from "./Dialog.js";
3
3
  import {useModalOverlay as $auKl7$useModalOverlay} from "react-aria/useModalOverlay";
4
4
  import {Overlay as $auKl7$Overlay, DismissButton as $auKl7$DismissButton} from "react-aria/Overlay";
5
5
  import {filterDOMProps as $auKl7$filterDOMProps} from "react-aria/filterDOMProps";
@@ -7,9 +7,11 @@ import {isScrollable as $auKl7$isScrollable} from "react-aria/private/utils/isSc
7
7
  import {mergeProps as $auKl7$mergeProps} from "react-aria/mergeProps";
8
8
  import {mergeRefs as $auKl7$mergeRefs} from "react-aria/mergeRefs";
9
9
  import {useOverlayTriggerState as $auKl7$useOverlayTriggerState} from "react-stately/useOverlayTriggerState";
10
- import $auKl7$react, {createContext as $auKl7$createContext, forwardRef as $auKl7$forwardRef, useContext as $auKl7$useContext, useRef as $auKl7$useRef, useMemo as $auKl7$useMemo} from "react";
10
+ import $auKl7$react, {createContext as $auKl7$createContext, forwardRef as $auKl7$forwardRef, useContext as $auKl7$useContext, useRef as $auKl7$useRef, useState as $auKl7$useState, useMemo as $auKl7$useMemo} from "react";
11
+ import {runAfterKeyboard as $auKl7$runAfterKeyboard} from "react-aria/private/utils/runAfterKeyboard";
11
12
  import {useExitAnimation as $auKl7$useExitAnimation, useEnterAnimation as $auKl7$useEnterAnimation} from "react-aria/private/utils/animation";
12
13
  import {useIsSSR as $auKl7$useIsSSR} from "react-aria/SSRProvider";
14
+ import {useLayoutEffect as $auKl7$useLayoutEffect} from "react-aria/private/utils/useLayoutEffect";
13
15
  import {useObjectRef as $auKl7$useObjectRef} from "react-aria/useObjectRef";
14
16
  import {useViewportSize as $auKl7$useViewportSize} from "react-aria/private/utils/useViewportSize";
15
17
 
@@ -37,10 +39,12 @@ import {useViewportSize as $auKl7$useViewportSize} from "react-aria/private/util
37
39
 
38
40
 
39
41
 
42
+
43
+
40
44
  const $46ccb41fa2c44f44$export$ab57792b9b6974a6 = /*#__PURE__*/ (0, $auKl7$createContext)(null);
41
- const $46ccb41fa2c44f44$var$InternalModalContext = /*#__PURE__*/ (0, $auKl7$createContext)(null);
45
+ const $46ccb41fa2c44f44$export$6bc057cefccad9c8 = /*#__PURE__*/ (0, $auKl7$createContext)(null);
42
46
  const $46ccb41fa2c44f44$export$2b77a92f1a5ad772 = /*#__PURE__*/ (0, $auKl7$forwardRef)(function Modal(props, ref) {
43
- let ctx = (0, $auKl7$useContext)($46ccb41fa2c44f44$var$InternalModalContext);
47
+ let ctx = (0, $auKl7$useContext)($46ccb41fa2c44f44$export$6bc057cefccad9c8);
44
48
  if (ctx) {
45
49
  if (process.env.NODE_ENV !== 'production' && (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)) {
46
50
  // create a list of props that are passed in but not allowed when using an external ModalOverlay
@@ -89,8 +93,12 @@ function $46ccb41fa2c44f44$var$ModalOverlayWithForwardRef(props, ref) {
89
93
  }
90
94
  let objectRef = (0, $auKl7$useObjectRef)(ref);
91
95
  let modalRef = (0, $auKl7$useRef)(null);
92
- let isOverlayExiting = (0, $auKl7$useExitAnimation)(objectRef, state.isOpen);
93
- let isModalExiting = (0, $auKl7$useExitAnimation)(modalRef, state.isOpen);
96
+ let isOverlayExiting = (0, $auKl7$useExitAnimation)(objectRef, state.isOpen, props.onExit);
97
+ let onExitRef = (0, $auKl7$useRef)(null);
98
+ let isModalExiting = (0, $auKl7$useExitAnimation)(modalRef, state.isOpen, (element)=>{
99
+ var _onExitRef_current;
100
+ return (_onExitRef_current = onExitRef.current) === null || _onExitRef_current === void 0 ? void 0 : _onExitRef_current.call(onExitRef, element);
101
+ });
94
102
  let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;
95
103
  let isSSR = (0, $auKl7$useIsSSR)();
96
104
  if (!state.isOpen && !isExiting || isSSR) return null;
@@ -99,15 +107,26 @@ function $46ccb41fa2c44f44$var$ModalOverlayWithForwardRef(props, ref) {
99
107
  state: state,
100
108
  isExiting: isExiting,
101
109
  overlayRef: objectRef,
102
- modalRef: modalRef
110
+ modalRef: modalRef,
111
+ onExitRef: onExitRef
103
112
  });
104
113
  }
105
114
  const $46ccb41fa2c44f44$export$8948f78d83984c69 = /*#__PURE__*/ (0, $auKl7$forwardRef)($46ccb41fa2c44f44$var$ModalOverlayWithForwardRef);
106
- function $46ccb41fa2c44f44$var$ModalOverlayInner({ UNSTABLE_portalContainer: UNSTABLE_portalContainer, ...props }) {
115
+ function $46ccb41fa2c44f44$var$ModalOverlayInner({ UNSTABLE_portalContainer: UNSTABLE_portalContainer, UNSTABLE_deferUntilEntered: UNSTABLE_deferUntilEntered, ...props }) {
107
116
  let modalRef = props.modalRef;
108
117
  let { state: state } = props;
109
- let { modalProps: modalProps, underlayProps: underlayProps } = (0, $auKl7$useModalOverlay)(props, state, modalRef);
110
- let entering = (0, $auKl7$useEnterAnimation)(props.overlayRef) || props.isEntering || false;
118
+ let [isOpen, setIsOpen] = (0, $auKl7$useState)(false);
119
+ let entering = (0, $auKl7$useEnterAnimation)(props.overlayRef, isOpen, props.onEnter) || props.isEntering || false;
120
+ let isDeferred = !!UNSTABLE_deferUntilEntered && (!isOpen || entering);
121
+ let { modalProps: modalProps, underlayProps: underlayProps } = (0, $auKl7$useModalOverlay)({
122
+ ...props,
123
+ isEntering: isDeferred
124
+ }, state, modalRef);
125
+ // Pass the entering state to the dialog so it waits to move focus until the modal has entered.
126
+ let dialogContext = (0, $auKl7$useContext)((0, $acf8e70c2f419f18$export$8b93a07348a7730c));
127
+ let mergedDialogContext = UNSTABLE_deferUntilEntered ? $46ccb41fa2c44f44$var$mergeDialogContext(dialogContext, {
128
+ isEntering: isDeferred
129
+ }) : dialogContext;
111
130
  let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
112
131
  ...props,
113
132
  defaultClassName: 'react-aria-ModalOverlay',
@@ -135,6 +154,8 @@ function $46ccb41fa2c44f44$var$ModalOverlayInner({ UNSTABLE_portalContainer: UNS
135
154
  '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,
136
155
  '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined
137
156
  };
157
+ // Since an auto-focused input may open the OSK, we defer the reveal, as a courtesy, to avoid layout shift.
158
+ (0, $auKl7$useLayoutEffect)(()=>(0, $auKl7$runAfterKeyboard)(()=>setIsOpen(true)), []);
138
159
  // oxlint-disable react/react-compiler
139
160
  return /*#__PURE__*/ (0, $auKl7$react).createElement((0, $auKl7$Overlay), {
140
161
  isExiting: props.isExiting,
@@ -151,31 +172,54 @@ function $46ccb41fa2c44f44$var$ModalOverlayInner({ UNSTABLE_portalContainer: UNS
151
172
  }, /*#__PURE__*/ (0, $auKl7$react).createElement((0, $b7b7a92703138c9b$export$2881499e37b75b9a), {
152
173
  values: [
153
174
  [
154
- $46ccb41fa2c44f44$var$InternalModalContext,
175
+ $46ccb41fa2c44f44$export$6bc057cefccad9c8,
155
176
  {
156
177
  modalProps: modalProps,
157
178
  modalRef: modalRef,
158
179
  isExiting: props.isExiting,
180
+ onExitRef: props.onExitRef,
181
+ isOpen: isOpen,
159
182
  isDismissable: props.isDismissable
160
183
  }
161
184
  ],
162
185
  [
163
186
  (0, $acf8e70c2f419f18$export$d2f961adcb0afbe),
164
187
  state
188
+ ],
189
+ [
190
+ (0, $acf8e70c2f419f18$export$8b93a07348a7730c),
191
+ mergedDialogContext
165
192
  ]
166
193
  ]
167
194
  }, renderProps.children)));
168
195
  // oxlint-enable react/react-compiler
169
196
  }
197
+ function $46ccb41fa2c44f44$var$mergeDialogContext(context, props) {
198
+ if (context && 'slots' in context && context.slots) {
199
+ let slots = {};
200
+ for(let key in context.slots)slots[key] = {
201
+ ...context.slots[key],
202
+ ...props
203
+ };
204
+ return {
205
+ ...context,
206
+ slots: slots
207
+ };
208
+ }
209
+ return {
210
+ ...context,
211
+ ...props
212
+ };
213
+ }
170
214
  function $46ccb41fa2c44f44$var$ModalContent(props) {
171
- let { modalProps: modalProps, modalRef: modalRef, isExiting: isExiting, isDismissable: isDismissable } = (0, $auKl7$useContext)($46ccb41fa2c44f44$var$InternalModalContext);
215
+ let { modalProps: modalProps, modalRef: modalRef, isExiting: isExiting, onExitRef: onExitRef, isDismissable: isDismissable, isOpen: isOpen } = (0, $auKl7$useContext)($46ccb41fa2c44f44$export$6bc057cefccad9c8);
172
216
  let state = (0, $auKl7$useContext)((0, $acf8e70c2f419f18$export$d2f961adcb0afbe));
173
217
  let mergedRefs = (0, $auKl7$useMemo)(()=>(0, $auKl7$mergeRefs)(props.modalRef, modalRef), [
174
218
  props.modalRef,
175
219
  modalRef
176
220
  ]);
177
221
  let ref = (0, $auKl7$useObjectRef)(mergedRefs);
178
- let entering = (0, $auKl7$useEnterAnimation)(ref);
222
+ let entering = (0, $auKl7$useEnterAnimation)(ref, isOpen, props.onEnter);
179
223
  let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
180
224
  ...props,
181
225
  defaultClassName: 'react-aria-Modal',
@@ -185,6 +229,9 @@ function $46ccb41fa2c44f44$var$ModalContent(props) {
185
229
  state: state
186
230
  }
187
231
  });
232
+ (0, $auKl7$useLayoutEffect)(()=>{
233
+ if (onExitRef) onExitRef.current = props.onExit;
234
+ });
188
235
  return /*#__PURE__*/ (0, $auKl7$react).createElement((0, $b7b7a92703138c9b$export$df3a06d6289f983e).div, {
189
236
  ...(0, $auKl7$mergeProps)((0, $auKl7$filterDOMProps)(props, {
190
237
  global: true
@@ -199,5 +246,5 @@ function $46ccb41fa2c44f44$var$ModalContent(props) {
199
246
  }
200
247
 
201
248
 
202
- export {$46ccb41fa2c44f44$export$ab57792b9b6974a6 as ModalContext, $46ccb41fa2c44f44$export$2b77a92f1a5ad772 as Modal, $46ccb41fa2c44f44$export$8948f78d83984c69 as ModalOverlay};
249
+ export {$46ccb41fa2c44f44$export$ab57792b9b6974a6 as ModalContext, $46ccb41fa2c44f44$export$6bc057cefccad9c8 as InternalModalContext, $46ccb41fa2c44f44$export$2b77a92f1a5ad772 as Modal, $46ccb41fa2c44f44$export$8948f78d83984c69 as ModalOverlay};
203
250
  //# sourceMappingURL=Modal.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAuEM,MAAM,0DAAe,CAAA,GAAA,oBAAY,EAAmD;AAC3F,MAAM,2DAAuB,CAAA,GAAA,oBAAY,EAAoC;AAwBtE,MAAM,4CAAsB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,MACzE,KAAwB,EACxB,GAAiC;IAEjC,IAAI,MAAM,CAAA,GAAA,iBAAS,EAAE;IAErB,IAAI,KAAK;QACP,I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M,CAAA,GAAA,gBAAQ,EAAE,MAAM,QAAQ,EAAE,WAAW;QAAC,MAAM,QAAQ;QAAE;KAAS;IAE9F,IAAI,MAAM,CAAA,GAAA,mBAAW,EAAE;IACvB,IAAI,WAAW,CAAA,GAAA,wBAAgB,EAAE;IACjC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;YACN,YAAY;uBACZ;mBACA;QACF;IACF;IAEA,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,qBAAa,EAAE,OAAO;YAAC,QAAQ;QAAI,IAAI,WAAW;QAChE,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,YAAY;QAC3B,gBAAc,aAAa;OAC1B,+BAAiB,gCAAC,CAAA,GAAA,oBAAY;QAAE,WAAW,MAAM,KAAK;QACtD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {DismissButton, Overlay} from 'react-aria/Overlay';\nimport {DOMAttributes, forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {isScrollable} from 'react-aria/private/utils/isScrollable';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {\n OverlayTriggerProps,\n OverlayTriggerState,\n useOverlayTriggerState\n} from 'react-stately/useOverlayTriggerState';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo, useRef} from 'react';\nimport {useEnterAnimation, useExitAnimation} from 'react-aria/private/utils/animation';\nimport {useIsSSR} from 'react-aria/SSRProvider';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useViewportSize} from 'react-aria/private/utils/useViewportSize';\n\nexport interface ModalOverlayProps\n extends\n AriaModalOverlayProps,\n OverlayTriggerProps,\n RenderProps<ModalRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalOverlay'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n /**\n * Whether the modal is currently performing an entry animation.\n */\n isEntering?: boolean;\n /**\n * Whether the modal is currently performing an exit animation.\n */\n isExiting?: boolean;\n /**\n * The container element in which the overlay portal will be placed. This may have unknown\n * behavior depending on where it is portalled to.\n *\n * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n * @default document.body\n */\n UNSTABLE_portalContainer?: Element;\n}\n\ninterface InternalModalContextValue {\n modalProps: DOMAttributes;\n modalRef: RefObject<HTMLDivElement | null>;\n isExiting: boolean;\n isDismissable?: boolean;\n}\n\nexport const ModalContext = createContext<ContextValue<ModalOverlayProps, HTMLDivElement>>(null);\nconst InternalModalContext = createContext<InternalModalContextValue | null>(null);\n\nexport interface ModalRenderProps {\n /**\n * Whether the modal is currently entering. Use this to apply animations.\n *\n * @selector [data-entering]\n */\n isEntering: boolean;\n /**\n * Whether the modal is currently exiting. Use this to apply animations.\n *\n * @selector [data-exiting]\n */\n isExiting: boolean;\n /**\n * State of the modal.\n */\n state: OverlayTriggerState;\n}\n\n/**\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport const Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(function Modal(\n props: ModalOverlayProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let ctx = useContext(InternalModalContext);\n\n if (ctx) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n // create a list of props that are passed in but not allowed when using an external ModalOverlay\n const invalidSet = new Set([\n 'isDismissable',\n 'isKeyboardDismissDisabled',\n 'isOpen',\n 'defaultOpen',\n 'onOpenChange',\n 'isEntering',\n 'isExiting',\n 'UNSTABLE_portalContainer',\n 'shouldCloseOnInteractOutside'\n ]);\n const invalidProps = Object.keys(props).filter(key => invalidSet.has(key));\n console.warn(\n `This modal is already wrapped in a ModalOverlay, props [${invalidProps.join(', ')}] should be placed on the ModalOverlay instead.`\n );\n }\n return (\n <ModalContent {...props} modalRef={ref}>\n {props.children}\n </ModalContent>\n );\n }\n\n let {\n isDismissable,\n isKeyboardDismissDisabled,\n isOpen,\n defaultOpen,\n onOpenChange,\n children,\n isEntering,\n isExiting,\n UNSTABLE_portalContainer,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n return (\n <ModalOverlay\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n isEntering={isEntering}\n isExiting={isExiting}\n UNSTABLE_portalContainer={UNSTABLE_portalContainer}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}>\n <ModalContent {...otherProps} modalRef={ref}>\n {children}\n </ModalContent>\n </ModalOverlay>\n );\n});\n\ninterface ModalOverlayInnerProps extends ModalOverlayProps {\n overlayRef: RefObject<HTMLDivElement | null>;\n modalRef: RefObject<HTMLDivElement | null>;\n state: OverlayTriggerState;\n isExiting: boolean;\n}\n\nfunction ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ModalContext);\n let contextState = useContext(OverlayTriggerStateContext);\n let localState = useOverlayTriggerState(props);\n let state =\n props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;\n if (state === contextState) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n console.warn(\n 'This modals state is controlled by a trigger, place onOpenChange on the trigger instead.'\n );\n }\n }\n\n let objectRef = useObjectRef(ref);\n let modalRef = useRef<HTMLDivElement>(null);\n let isOverlayExiting = useExitAnimation(objectRef, state.isOpen);\n let isModalExiting = useExitAnimation(modalRef, state.isOpen);\n let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;\n let isSSR = useIsSSR();\n\n if ((!state.isOpen && !isExiting) || isSSR) {\n return null;\n }\n\n return (\n <ModalOverlayInner\n {...props}\n state={state}\n isExiting={isExiting}\n overlayRef={objectRef}\n modalRef={modalRef}\n />\n );\n}\n\n/**\n * A ModalOverlay is a wrapper for a Modal which allows customizing the backdrop element.\n */\nexport const ModalOverlay = /*#__PURE__*/ (forwardRef as forwardRefType)(\n ModalOverlayWithForwardRef\n);\n\nfunction ModalOverlayInner({UNSTABLE_portalContainer, ...props}: ModalOverlayInnerProps) {\n let modalRef = props.modalRef;\n let {state} = props;\n let {modalProps, underlayProps} = useModalOverlay(props, state, modalRef);\n\n let entering = useEnterAnimation(props.overlayRef) || props.isEntering || false;\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ModalOverlay',\n values: {\n isEntering: entering,\n isExiting: props.isExiting,\n state\n }\n });\n\n let viewport = useViewportSize();\n let pageWidth: number | undefined = undefined;\n let pageHeight: number | undefined = undefined;\n if (typeof document !== 'undefined') {\n let scrollingElement = isScrollable(document.body)\n ? document.body\n : document.scrollingElement || document.documentElement;\n // Prevent Firefox from adding scrollbars when the page has a fractional width/height.\n let fractionalWidthDifference = scrollingElement.getBoundingClientRect().width % 1;\n let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;\n pageWidth = scrollingElement.scrollWidth - fractionalWidthDifference;\n pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;\n }\n\n let style = {\n ...renderProps.style,\n '--visual-viewport-width': viewport.width + 'px',\n '--visual-viewport-height': viewport.height + 'px',\n '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,\n '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined\n };\n\n // oxlint-disable react/react-compiler\n return (\n <Overlay isExiting={props.isExiting} portalContainer={UNSTABLE_portalContainer}>\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), underlayProps)}\n {...renderProps}\n style={style}\n ref={props.overlayRef}\n data-entering={entering || undefined}\n data-exiting={props.isExiting || undefined}>\n <Provider\n values={[\n [\n InternalModalContext,\n {modalProps, modalRef, isExiting: props.isExiting, isDismissable: props.isDismissable}\n ],\n [OverlayTriggerStateContext, state]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n </Overlay>\n );\n // oxlint-enable react/react-compiler\n}\n\ninterface ModalContentProps\n extends RenderProps<ModalRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalContent'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n modalRef: ForwardedRef<HTMLDivElement>;\n}\n\nfunction ModalContent(props: ModalContentProps) {\n let {modalProps, modalRef, isExiting, isDismissable} = useContext(InternalModalContext)!;\n let state = useContext(OverlayTriggerStateContext)!;\n let mergedRefs = useMemo(() => mergeRefs(props.modalRef, modalRef), [props.modalRef, modalRef]);\n\n let ref = useObjectRef(mergedRefs);\n let entering = useEnterAnimation(ref);\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Modal',\n values: {\n isEntering: entering,\n isExiting,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), modalProps)}\n {...renderProps}\n ref={ref}\n data-entering={entering || undefined}\n data-exiting={isExiting || undefined}>\n {isDismissable && <DismissButton onDismiss={state.close} />}\n {renderProps.children}\n </dom.div>\n );\n}\n"],"names":[],"version":3,"file":"Modal.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAmGM,MAAM,0DAAe,CAAA,GAAA,oBAAY,EAAmD;AACpF,MAAM,0DAAuB,CAAA,GAAA,oBAAY,EAAoC;AAwB7E,MAAM,4CAAsB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,MACzE,KAAwB,EACxB,GAAiC;IAEjC,IAAI,MAAM,CAAA,GAAA,iBAAS,EAAE;IAErB,IAAI,KAAK;QACP,IACE,QAAQ,GAAG,CAAC,QAAQ,KAAK,gBACxB,CAAA,MAAM,YAAY,IAAI,MAAM,WAAW,KAAK,aAAa,MAAM,MAAM,KAAK,SAAQ,GACnF;YACA,gGAAgG;YAChG,MAAM,aAAa,IAAI,IAAI;gBACzB;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;aACD;YACD,MAAM,eAAe,OAAO,IAAI,CAAC,OAAO,MAAM,CAAC,CAAA,MAAO,WAAW,GAAG,CAAC;YACrE,QAAQ,IAAI,CACV,CAAC,wDAAwD,EAAE,aAAa,IAAI,CAAC,MAAM,+CAA+C,CAAC;QAEvI;QACA,qBACE,gCAAC;YAAc,GAAG,KAAK;YAAE,UAAU;WAChC,MAAM,QAAQ;IAGrB;IAEA,IAAI,iBACF,aAAa,6BACb,yBAAyB,UACzB,MAAM,eACN,WAAW,gBACX,YAAY,YACZ,QAAQ,cACR,UAAU,aACV,SAAS,4BACT,wBAAwB,gCACxB,4BAA4B,EAC5B,GAAG,YACJ,GAAG;IAEJ,qBACE,gCAA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AAI;YAAE,GAAG,KAAK;QAAA;QAE/C,OAAO;YAAC,GAAG,OAAO;mBAAE;QAAK;IAC3B;IACA,OAAO;QAAC,GAAG,OAAO;QAAE,GAAG,KAAK;IAAA;AAC9B;AAgBA,SAAS,mCAAa,KAAwB;IAC5C,IAAI,cAAC,UAAU,YAAE,QAAQ,aAAE,SAAS,aAAE,SAAS,iBAAE,aAAa,UAAE,MAAM,EAAC,GACrE,CAAA,GAAA,iBAAS,EAAE;IACb,IAAI,QAAQ,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,wCAAyB;IAChD,IAAI,aAAa,CAAA,GAAA,cAAM,EAAE,IAAM,CAAA,GAAA,gBAAQ,EAAE,MAAM,QAAQ,EAAE,WAAW;QAAC,MAAM,QAAQ;QAAE;KAAS;IAE9F,IAAI,MAAM,CAAA,GAAA,mBAAW,EAAE;IACvB,IAAI,WAAW,CAAA,GAAA,wBAAgB,EAAE,KAAK,QAAQ,MAAM,OAAO;IAC3D,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;YACN,YAAY;uBACZ;mBACA;QACF;IACF;IAEA,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,WACF,UAAU,OAAO,GAAG,MAAM,MAAM;IAEpC;IAEA,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,qBAAa,EAAE,OAAO;YAAC,QAAQ;QAAI,IAAI,WAAW;QAChE,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,YAAY;QAC3B,gBAAc,aAAa;OAC1B,+BAAiB,gCAAC,CAAA,GAAA,oBAAY;QAAE,WAAW,MAAM,KAAK;QACtD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2022 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';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {DialogContext, DialogProps, OverlayTriggerStateContext} from './Dialog';\nimport {DismissButton, Overlay} from 'react-aria/Overlay';\nimport {DOMAttributes, forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {isScrollable} from 'react-aria/private/utils/isScrollable';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {\n OverlayTriggerProps,\n OverlayTriggerState,\n useOverlayTriggerState\n} from 'react-stately/useOverlayTriggerState';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {runAfterKeyboard} from 'react-aria/private/utils/runAfterKeyboard';\nimport {useEnterAnimation, useExitAnimation} from 'react-aria/private/utils/animation';\nimport {useIsSSR} from 'react-aria/SSRProvider';\nimport {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useViewportSize} from 'react-aria/private/utils/useViewportSize';\n\nexport interface ModalOverlayProps\n extends\n AriaModalOverlayProps,\n OverlayTriggerProps,\n RenderProps<ModalRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalOverlay'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n /**\n * Whether the modal is currently performing an entry animation.\n */\n isEntering?: boolean;\n /**\n * Whether the modal is currently performing an exit animation.\n */\n isExiting?: boolean;\n /**\n * Callback when the modal starts entering. Return a promise to indicate when the entry animation\n * has completed.\n */\n onEnter?: (element: HTMLElement) => void | Promise<void>;\n /**\n * Callback when the modal starts exiting. Return a promise to indicate when the exit animation\n * has completed.\n */\n onExit?: (element: HTMLElement) => void | Promise<void>;\n /**\n * The container element in which the overlay portal will be placed. This may have unknown\n * behavior depending on where it is portalled to.\n *\n * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n * @default document.body\n */\n UNSTABLE_portalContainer?: Element;\n /**\n * Whether to wait until the entry animation completes before hiding content outside the modal\n * and moving focus into it.\n *\n * @private\n */\n UNSTABLE_deferUntilEntered?: boolean;\n}\n\ninterface InternalModalContextValue {\n modalProps: DOMAttributes;\n modalRef: RefObject<HTMLDivElement | null>;\n isOpen: boolean;\n isExiting: boolean;\n isDismissable?: boolean;\n onExitRef?: RefObject<ModalOverlayProps['onExit'] | null>;\n}\n\nexport const ModalContext = createContext<ContextValue<ModalOverlayProps, HTMLDivElement>>(null);\nexport const InternalModalContext = createContext<InternalModalContextValue | null>(null);\n\nexport interface ModalRenderProps {\n /**\n * Whether the modal is currently entering. Use this to apply animations.\n *\n * @selector [data-entering]\n */\n isEntering: boolean;\n /**\n * Whether the modal is currently exiting. Use this to apply animations.\n *\n * @selector [data-exiting]\n */\n isExiting: boolean;\n /**\n * State of the modal.\n */\n state: OverlayTriggerState;\n}\n\n/**\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport const Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(function Modal(\n props: ModalOverlayProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let ctx = useContext(InternalModalContext);\n\n if (ctx) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n // create a list of props that are passed in but not allowed when using an external ModalOverlay\n const invalidSet = new Set([\n 'isDismissable',\n 'isKeyboardDismissDisabled',\n 'isOpen',\n 'defaultOpen',\n 'onOpenChange',\n 'isEntering',\n 'isExiting',\n 'UNSTABLE_portalContainer',\n 'shouldCloseOnInteractOutside'\n ]);\n const invalidProps = Object.keys(props).filter(key => invalidSet.has(key));\n console.warn(\n `This modal is already wrapped in a ModalOverlay, props [${invalidProps.join(', ')}] should be placed on the ModalOverlay instead.`\n );\n }\n return (\n <ModalContent {...props} modalRef={ref}>\n {props.children}\n </ModalContent>\n );\n }\n\n let {\n isDismissable,\n isKeyboardDismissDisabled,\n isOpen,\n defaultOpen,\n onOpenChange,\n children,\n isEntering,\n isExiting,\n UNSTABLE_portalContainer,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n return (\n <ModalOverlay\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n isEntering={isEntering}\n isExiting={isExiting}\n UNSTABLE_portalContainer={UNSTABLE_portalContainer}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}>\n <ModalContent {...otherProps} modalRef={ref}>\n {children}\n </ModalContent>\n </ModalOverlay>\n );\n});\n\ninterface ModalOverlayInnerProps extends ModalOverlayProps {\n overlayRef: RefObject<HTMLDivElement | null>;\n modalRef: RefObject<HTMLDivElement | null>;\n state: OverlayTriggerState;\n isExiting: boolean;\n onExitRef?: RefObject<ModalOverlayProps['onExit'] | null>;\n}\n\nfunction ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ModalContext);\n let contextState = useContext(OverlayTriggerStateContext);\n let localState = useOverlayTriggerState(props);\n let state =\n props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;\n if (state === contextState) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n console.warn(\n 'This modals state is controlled by a trigger, place onOpenChange on the trigger instead.'\n );\n }\n }\n\n let objectRef = useObjectRef(ref);\n let modalRef = useRef<HTMLDivElement>(null);\n let isOverlayExiting = useExitAnimation(objectRef, state.isOpen, props.onExit);\n let onExitRef = useRef<ModalOverlayProps['onExit'] | null>(null);\n let isModalExiting = useExitAnimation(modalRef, state.isOpen, element =>\n onExitRef.current?.(element)\n );\n let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;\n let isSSR = useIsSSR();\n\n if ((!state.isOpen && !isExiting) || isSSR) {\n return null;\n }\n\n return (\n <ModalOverlayInner\n {...props}\n state={state}\n isExiting={isExiting}\n overlayRef={objectRef}\n modalRef={modalRef}\n onExitRef={onExitRef}\n />\n );\n}\n\n/**\n * A ModalOverlay is a wrapper for a Modal which allows customizing the backdrop element.\n */\nexport const ModalOverlay = /*#__PURE__*/ (forwardRef as forwardRefType)(\n ModalOverlayWithForwardRef\n);\n\nfunction ModalOverlayInner({\n UNSTABLE_portalContainer,\n UNSTABLE_deferUntilEntered,\n ...props\n}: ModalOverlayInnerProps) {\n let modalRef = props.modalRef;\n let {state} = props;\n\n let [isOpen, setIsOpen] = useState(false);\n let entering =\n useEnterAnimation(props.overlayRef, isOpen, props.onEnter) || props.isEntering || false;\n let isDeferred = !!UNSTABLE_deferUntilEntered && (!isOpen || entering);\n let {modalProps, underlayProps} = useModalOverlay(\n {...props, isEntering: isDeferred},\n state,\n modalRef\n );\n\n // Pass the entering state to the dialog so it waits to move focus until the modal has entered.\n let dialogContext = useContext(DialogContext);\n let mergedDialogContext = UNSTABLE_deferUntilEntered\n ? mergeDialogContext(dialogContext, {isEntering: isDeferred})\n : dialogContext;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ModalOverlay',\n values: {\n isEntering: entering,\n isExiting: props.isExiting,\n state\n }\n });\n\n let viewport = useViewportSize();\n let pageWidth: number | undefined = undefined;\n let pageHeight: number | undefined = undefined;\n if (typeof document !== 'undefined') {\n let scrollingElement = isScrollable(document.body)\n ? document.body\n : document.scrollingElement || document.documentElement;\n // Prevent Firefox from adding scrollbars when the page has a fractional width/height.\n let fractionalWidthDifference = scrollingElement.getBoundingClientRect().width % 1;\n let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;\n pageWidth = scrollingElement.scrollWidth - fractionalWidthDifference;\n pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;\n }\n\n let style = {\n ...renderProps.style,\n '--visual-viewport-width': viewport.width + 'px',\n '--visual-viewport-height': viewport.height + 'px',\n '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,\n '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined\n };\n\n // Since an auto-focused input may open the OSK, we defer the reveal, as a courtesy, to avoid layout shift.\n useLayoutEffect(() => runAfterKeyboard(() => setIsOpen(true)), []);\n\n // oxlint-disable react/react-compiler\n return (\n <Overlay isExiting={props.isExiting} portalContainer={UNSTABLE_portalContainer}>\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), underlayProps)}\n {...renderProps}\n style={style}\n ref={props.overlayRef}\n data-entering={entering || undefined}\n data-exiting={props.isExiting || undefined}>\n <Provider\n values={[\n [\n InternalModalContext,\n {\n modalProps,\n modalRef,\n isExiting: props.isExiting,\n onExitRef: props.onExitRef,\n isOpen,\n isDismissable: props.isDismissable\n }\n ],\n [OverlayTriggerStateContext, state],\n [DialogContext, mergedDialogContext]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n </Overlay>\n );\n // oxlint-enable react/react-compiler\n}\n\nfunction mergeDialogContext(\n context: ContextValue<DialogProps, HTMLElement>,\n props: Partial<DialogProps>\n): ContextValue<DialogProps, HTMLElement> {\n if (context && 'slots' in context && context.slots) {\n let slots = {};\n for (let key in context.slots) {\n slots[key] = {...context.slots[key], ...props};\n }\n return {...context, slots};\n }\n return {...context, ...props};\n}\n\ninterface ModalContentProps\n extends RenderProps<ModalRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalContent'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n modalRef: ForwardedRef<HTMLDivElement>;\n onEnter?: (element: HTMLElement) => void;\n onExit?: (element: HTMLElement) => void;\n}\n\nfunction ModalContent(props: ModalContentProps) {\n let {modalProps, modalRef, isExiting, onExitRef, isDismissable, isOpen} =\n useContext(InternalModalContext)!;\n let state = useContext(OverlayTriggerStateContext)!;\n let mergedRefs = useMemo(() => mergeRefs(props.modalRef, modalRef), [props.modalRef, modalRef]);\n\n let ref = useObjectRef(mergedRefs);\n let entering = useEnterAnimation(ref, isOpen, props.onEnter);\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Modal',\n values: {\n isEntering: entering,\n isExiting,\n state\n }\n });\n\n useLayoutEffect(() => {\n if (onExitRef) {\n onExitRef.current = props.onExit;\n }\n });\n\n return (\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), modalProps)}\n {...renderProps}\n ref={ref}\n data-entering={entering || undefined}\n data-exiting={isExiting || undefined}>\n {isDismissable && <DismissButton onDismiss={state.close} />}\n {renderProps.children}\n </dom.div>\n );\n}\n"],"names":[],"version":3,"file":"Modal.js.map"}
@@ -1,5 +1,5 @@
1
1
  import {dom as $7230ffa83bc0c2cf$export$df3a06d6289f983e, Provider as $7230ffa83bc0c2cf$export$2881499e37b75b9a, useContextProps as $7230ffa83bc0c2cf$export$29f1550f4b0d4415, useRenderProps as $7230ffa83bc0c2cf$export$4d86445c2cf5e3} from "./utils.mjs";
2
- import {OverlayTriggerStateContext as $f2ff30fde7b014be$export$d2f961adcb0afbe} from "./Dialog.mjs";
2
+ import {DialogContext as $f2ff30fde7b014be$export$8b93a07348a7730c, OverlayTriggerStateContext as $f2ff30fde7b014be$export$d2f961adcb0afbe} from "./Dialog.mjs";
3
3
  import {useModalOverlay as $gJBoF$useModalOverlay} from "react-aria/useModalOverlay";
4
4
  import {Overlay as $gJBoF$Overlay, DismissButton as $gJBoF$DismissButton} from "react-aria/Overlay";
5
5
  import {filterDOMProps as $gJBoF$filterDOMProps} from "react-aria/filterDOMProps";
@@ -7,9 +7,11 @@ import {isScrollable as $gJBoF$isScrollable} from "react-aria/private/utils/isSc
7
7
  import {mergeProps as $gJBoF$mergeProps} from "react-aria/mergeProps";
8
8
  import {mergeRefs as $gJBoF$mergeRefs} from "react-aria/mergeRefs";
9
9
  import {useOverlayTriggerState as $gJBoF$useOverlayTriggerState} from "react-stately/useOverlayTriggerState";
10
- import $gJBoF$react, {createContext as $gJBoF$createContext, forwardRef as $gJBoF$forwardRef, useContext as $gJBoF$useContext, useRef as $gJBoF$useRef, useMemo as $gJBoF$useMemo} from "react";
10
+ import $gJBoF$react, {createContext as $gJBoF$createContext, forwardRef as $gJBoF$forwardRef, useContext as $gJBoF$useContext, useRef as $gJBoF$useRef, useState as $gJBoF$useState, useMemo as $gJBoF$useMemo} from "react";
11
+ import {runAfterKeyboard as $gJBoF$runAfterKeyboard} from "react-aria/private/utils/runAfterKeyboard";
11
12
  import {useExitAnimation as $gJBoF$useExitAnimation, useEnterAnimation as $gJBoF$useEnterAnimation} from "react-aria/private/utils/animation";
12
13
  import {useIsSSR as $gJBoF$useIsSSR} from "react-aria/SSRProvider";
14
+ import {useLayoutEffect as $gJBoF$useLayoutEffect} from "react-aria/private/utils/useLayoutEffect";
13
15
  import {useObjectRef as $gJBoF$useObjectRef} from "react-aria/useObjectRef";
14
16
  import {useViewportSize as $gJBoF$useViewportSize} from "react-aria/private/utils/useViewportSize";
15
17
 
@@ -37,10 +39,12 @@ import {useViewportSize as $gJBoF$useViewportSize} from "react-aria/private/util
37
39
 
38
40
 
39
41
 
42
+
43
+
40
44
  const $8b8d26808cb8cb53$export$ab57792b9b6974a6 = /*#__PURE__*/ (0, $gJBoF$createContext)(null);
41
- const $8b8d26808cb8cb53$var$InternalModalContext = /*#__PURE__*/ (0, $gJBoF$createContext)(null);
45
+ const $8b8d26808cb8cb53$export$6bc057cefccad9c8 = /*#__PURE__*/ (0, $gJBoF$createContext)(null);
42
46
  const $8b8d26808cb8cb53$export$2b77a92f1a5ad772 = /*#__PURE__*/ (0, $gJBoF$forwardRef)(function Modal(props, ref) {
43
- let ctx = (0, $gJBoF$useContext)($8b8d26808cb8cb53$var$InternalModalContext);
47
+ let ctx = (0, $gJBoF$useContext)($8b8d26808cb8cb53$export$6bc057cefccad9c8);
44
48
  if (ctx) {
45
49
  if (process.env.NODE_ENV !== 'production' && (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)) {
46
50
  // create a list of props that are passed in but not allowed when using an external ModalOverlay
@@ -89,8 +93,9 @@ function $8b8d26808cb8cb53$var$ModalOverlayWithForwardRef(props, ref) {
89
93
  }
90
94
  let objectRef = (0, $gJBoF$useObjectRef)(ref);
91
95
  let modalRef = (0, $gJBoF$useRef)(null);
92
- let isOverlayExiting = (0, $gJBoF$useExitAnimation)(objectRef, state.isOpen);
93
- let isModalExiting = (0, $gJBoF$useExitAnimation)(modalRef, state.isOpen);
96
+ let isOverlayExiting = (0, $gJBoF$useExitAnimation)(objectRef, state.isOpen, props.onExit);
97
+ let onExitRef = (0, $gJBoF$useRef)(null);
98
+ let isModalExiting = (0, $gJBoF$useExitAnimation)(modalRef, state.isOpen, (element)=>onExitRef.current?.(element));
94
99
  let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;
95
100
  let isSSR = (0, $gJBoF$useIsSSR)();
96
101
  if (!state.isOpen && !isExiting || isSSR) return null;
@@ -99,15 +104,26 @@ function $8b8d26808cb8cb53$var$ModalOverlayWithForwardRef(props, ref) {
99
104
  state: state,
100
105
  isExiting: isExiting,
101
106
  overlayRef: objectRef,
102
- modalRef: modalRef
107
+ modalRef: modalRef,
108
+ onExitRef: onExitRef
103
109
  });
104
110
  }
105
111
  const $8b8d26808cb8cb53$export$8948f78d83984c69 = /*#__PURE__*/ (0, $gJBoF$forwardRef)($8b8d26808cb8cb53$var$ModalOverlayWithForwardRef);
106
- function $8b8d26808cb8cb53$var$ModalOverlayInner({ UNSTABLE_portalContainer: UNSTABLE_portalContainer, ...props }) {
112
+ function $8b8d26808cb8cb53$var$ModalOverlayInner({ UNSTABLE_portalContainer: UNSTABLE_portalContainer, UNSTABLE_deferUntilEntered: UNSTABLE_deferUntilEntered, ...props }) {
107
113
  let modalRef = props.modalRef;
108
114
  let { state: state } = props;
109
- let { modalProps: modalProps, underlayProps: underlayProps } = (0, $gJBoF$useModalOverlay)(props, state, modalRef);
110
- let entering = (0, $gJBoF$useEnterAnimation)(props.overlayRef) || props.isEntering || false;
115
+ let [isOpen, setIsOpen] = (0, $gJBoF$useState)(false);
116
+ let entering = (0, $gJBoF$useEnterAnimation)(props.overlayRef, isOpen, props.onEnter) || props.isEntering || false;
117
+ let isDeferred = !!UNSTABLE_deferUntilEntered && (!isOpen || entering);
118
+ let { modalProps: modalProps, underlayProps: underlayProps } = (0, $gJBoF$useModalOverlay)({
119
+ ...props,
120
+ isEntering: isDeferred
121
+ }, state, modalRef);
122
+ // Pass the entering state to the dialog so it waits to move focus until the modal has entered.
123
+ let dialogContext = (0, $gJBoF$useContext)((0, $f2ff30fde7b014be$export$8b93a07348a7730c));
124
+ let mergedDialogContext = UNSTABLE_deferUntilEntered ? $8b8d26808cb8cb53$var$mergeDialogContext(dialogContext, {
125
+ isEntering: isDeferred
126
+ }) : dialogContext;
111
127
  let renderProps = (0, $7230ffa83bc0c2cf$export$4d86445c2cf5e3)({
112
128
  ...props,
113
129
  defaultClassName: 'react-aria-ModalOverlay',
@@ -135,6 +151,8 @@ function $8b8d26808cb8cb53$var$ModalOverlayInner({ UNSTABLE_portalContainer: UNS
135
151
  '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,
136
152
  '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined
137
153
  };
154
+ // Since an auto-focused input may open the OSK, we defer the reveal, as a courtesy, to avoid layout shift.
155
+ (0, $gJBoF$useLayoutEffect)(()=>(0, $gJBoF$runAfterKeyboard)(()=>setIsOpen(true)), []);
138
156
  // oxlint-disable react/react-compiler
139
157
  return /*#__PURE__*/ (0, $gJBoF$react).createElement((0, $gJBoF$Overlay), {
140
158
  isExiting: props.isExiting,
@@ -151,31 +169,54 @@ function $8b8d26808cb8cb53$var$ModalOverlayInner({ UNSTABLE_portalContainer: UNS
151
169
  }, /*#__PURE__*/ (0, $gJBoF$react).createElement((0, $7230ffa83bc0c2cf$export$2881499e37b75b9a), {
152
170
  values: [
153
171
  [
154
- $8b8d26808cb8cb53$var$InternalModalContext,
172
+ $8b8d26808cb8cb53$export$6bc057cefccad9c8,
155
173
  {
156
174
  modalProps: modalProps,
157
175
  modalRef: modalRef,
158
176
  isExiting: props.isExiting,
177
+ onExitRef: props.onExitRef,
178
+ isOpen: isOpen,
159
179
  isDismissable: props.isDismissable
160
180
  }
161
181
  ],
162
182
  [
163
183
  (0, $f2ff30fde7b014be$export$d2f961adcb0afbe),
164
184
  state
185
+ ],
186
+ [
187
+ (0, $f2ff30fde7b014be$export$8b93a07348a7730c),
188
+ mergedDialogContext
165
189
  ]
166
190
  ]
167
191
  }, renderProps.children)));
168
192
  // oxlint-enable react/react-compiler
169
193
  }
194
+ function $8b8d26808cb8cb53$var$mergeDialogContext(context, props) {
195
+ if (context && 'slots' in context && context.slots) {
196
+ let slots = {};
197
+ for(let key in context.slots)slots[key] = {
198
+ ...context.slots[key],
199
+ ...props
200
+ };
201
+ return {
202
+ ...context,
203
+ slots: slots
204
+ };
205
+ }
206
+ return {
207
+ ...context,
208
+ ...props
209
+ };
210
+ }
170
211
  function $8b8d26808cb8cb53$var$ModalContent(props) {
171
- let { modalProps: modalProps, modalRef: modalRef, isExiting: isExiting, isDismissable: isDismissable } = (0, $gJBoF$useContext)($8b8d26808cb8cb53$var$InternalModalContext);
212
+ let { modalProps: modalProps, modalRef: modalRef, isExiting: isExiting, onExitRef: onExitRef, isDismissable: isDismissable, isOpen: isOpen } = (0, $gJBoF$useContext)($8b8d26808cb8cb53$export$6bc057cefccad9c8);
172
213
  let state = (0, $gJBoF$useContext)((0, $f2ff30fde7b014be$export$d2f961adcb0afbe));
173
214
  let mergedRefs = (0, $gJBoF$useMemo)(()=>(0, $gJBoF$mergeRefs)(props.modalRef, modalRef), [
174
215
  props.modalRef,
175
216
  modalRef
176
217
  ]);
177
218
  let ref = (0, $gJBoF$useObjectRef)(mergedRefs);
178
- let entering = (0, $gJBoF$useEnterAnimation)(ref);
219
+ let entering = (0, $gJBoF$useEnterAnimation)(ref, isOpen, props.onEnter);
179
220
  let renderProps = (0, $7230ffa83bc0c2cf$export$4d86445c2cf5e3)({
180
221
  ...props,
181
222
  defaultClassName: 'react-aria-Modal',
@@ -185,6 +226,9 @@ function $8b8d26808cb8cb53$var$ModalContent(props) {
185
226
  state: state
186
227
  }
187
228
  });
229
+ (0, $gJBoF$useLayoutEffect)(()=>{
230
+ if (onExitRef) onExitRef.current = props.onExit;
231
+ });
188
232
  return /*#__PURE__*/ (0, $gJBoF$react).createElement((0, $7230ffa83bc0c2cf$export$df3a06d6289f983e).div, {
189
233
  ...(0, $gJBoF$mergeProps)((0, $gJBoF$filterDOMProps)(props, {
190
234
  global: true
@@ -199,5 +243,5 @@ function $8b8d26808cb8cb53$var$ModalContent(props) {
199
243
  }
200
244
 
201
245
 
202
- export {$8b8d26808cb8cb53$export$ab57792b9b6974a6 as ModalContext, $8b8d26808cb8cb53$export$2b77a92f1a5ad772 as Modal, $8b8d26808cb8cb53$export$8948f78d83984c69 as ModalOverlay};
246
+ export {$8b8d26808cb8cb53$export$ab57792b9b6974a6 as ModalContext, $8b8d26808cb8cb53$export$6bc057cefccad9c8 as InternalModalContext, $8b8d26808cb8cb53$export$2b77a92f1a5ad772 as Modal, $8b8d26808cb8cb53$export$8948f78d83984c69 as ModalOverlay};
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M,SAAS;oBAAE,eAAe,MAAM,aAAa;gBAAA;aACtF;YACD;gBAAC,CAAA,GAAA,wCAAyB;gBAAG;aAAM;SACpC;OACA,YAAY,QAAQ;AAK7B,qCAAqC;AACvC;AAcA,SAAS,mCAAa,KAAwB;IAC5C,IAAI,cAAC,UAAU,YAAE,QAAQ,aAAE,SAAS,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;IAClE,IAAI,QAAQ,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,wCAAyB;IAChD,IAAI,aAAa,CAAA,GAAA,cAAM,EAAE,IAAM,CAAA,GAAA,gBAAQ,EAAE,MAAM,QAAQ,EAAE,WAAW;QAAC,MAAM,QAAQ;QAAE;KAAS;IAE9F,IAAI,MAAM,CAAA,GAAA,mBAAW,EAAE;IACvB,IAAI,WAAW,CAAA,GAAA,wBAAgB,EAAE;IACjC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;YACN,YAAY;uBACZ;mBACA;QACF;IACF;IAEA,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,qBAAa,EAAE,OAAO;YAAC,QAAQ;QAAI,IAAI,WAAW;QAChE,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,YAAY;QAC3B,gBAAc,aAAa;OAC1B,+BAAiB,gCAAC,CAAA,GAAA,oBAAY;QAAE,WAAW,MAAM,KAAK;QACtD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {DismissButton, Overlay} from 'react-aria/Overlay';\nimport {DOMAttributes, forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {isScrollable} from 'react-aria/private/utils/isScrollable';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {\n OverlayTriggerProps,\n OverlayTriggerState,\n useOverlayTriggerState\n} from 'react-stately/useOverlayTriggerState';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport React, {createContext, ForwardedRef, forwardRef, useContext, useMemo, useRef} from 'react';\nimport {useEnterAnimation, useExitAnimation} from 'react-aria/private/utils/animation';\nimport {useIsSSR} from 'react-aria/SSRProvider';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useViewportSize} from 'react-aria/private/utils/useViewportSize';\n\nexport interface ModalOverlayProps\n extends\n AriaModalOverlayProps,\n OverlayTriggerProps,\n RenderProps<ModalRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalOverlay'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n /**\n * Whether the modal is currently performing an entry animation.\n */\n isEntering?: boolean;\n /**\n * Whether the modal is currently performing an exit animation.\n */\n isExiting?: boolean;\n /**\n * The container element in which the overlay portal will be placed. This may have unknown\n * behavior depending on where it is portalled to.\n *\n * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n * @default document.body\n */\n UNSTABLE_portalContainer?: Element;\n}\n\ninterface InternalModalContextValue {\n modalProps: DOMAttributes;\n modalRef: RefObject<HTMLDivElement | null>;\n isExiting: boolean;\n isDismissable?: boolean;\n}\n\nexport const ModalContext = createContext<ContextValue<ModalOverlayProps, HTMLDivElement>>(null);\nconst InternalModalContext = createContext<InternalModalContextValue | null>(null);\n\nexport interface ModalRenderProps {\n /**\n * Whether the modal is currently entering. Use this to apply animations.\n *\n * @selector [data-entering]\n */\n isEntering: boolean;\n /**\n * Whether the modal is currently exiting. Use this to apply animations.\n *\n * @selector [data-exiting]\n */\n isExiting: boolean;\n /**\n * State of the modal.\n */\n state: OverlayTriggerState;\n}\n\n/**\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport const Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(function Modal(\n props: ModalOverlayProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let ctx = useContext(InternalModalContext);\n\n if (ctx) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n // create a list of props that are passed in but not allowed when using an external ModalOverlay\n const invalidSet = new Set([\n 'isDismissable',\n 'isKeyboardDismissDisabled',\n 'isOpen',\n 'defaultOpen',\n 'onOpenChange',\n 'isEntering',\n 'isExiting',\n 'UNSTABLE_portalContainer',\n 'shouldCloseOnInteractOutside'\n ]);\n const invalidProps = Object.keys(props).filter(key => invalidSet.has(key));\n console.warn(\n `This modal is already wrapped in a ModalOverlay, props [${invalidProps.join(', ')}] should be placed on the ModalOverlay instead.`\n );\n }\n return (\n <ModalContent {...props} modalRef={ref}>\n {props.children}\n </ModalContent>\n );\n }\n\n let {\n isDismissable,\n isKeyboardDismissDisabled,\n isOpen,\n defaultOpen,\n onOpenChange,\n children,\n isEntering,\n isExiting,\n UNSTABLE_portalContainer,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n return (\n <ModalOverlay\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n isEntering={isEntering}\n isExiting={isExiting}\n UNSTABLE_portalContainer={UNSTABLE_portalContainer}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}>\n <ModalContent {...otherProps} modalRef={ref}>\n {children}\n </ModalContent>\n </ModalOverlay>\n );\n});\n\ninterface ModalOverlayInnerProps extends ModalOverlayProps {\n overlayRef: RefObject<HTMLDivElement | null>;\n modalRef: RefObject<HTMLDivElement | null>;\n state: OverlayTriggerState;\n isExiting: boolean;\n}\n\nfunction ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ModalContext);\n let contextState = useContext(OverlayTriggerStateContext);\n let localState = useOverlayTriggerState(props);\n let state =\n props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;\n if (state === contextState) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n console.warn(\n 'This modals state is controlled by a trigger, place onOpenChange on the trigger instead.'\n );\n }\n }\n\n let objectRef = useObjectRef(ref);\n let modalRef = useRef<HTMLDivElement>(null);\n let isOverlayExiting = useExitAnimation(objectRef, state.isOpen);\n let isModalExiting = useExitAnimation(modalRef, state.isOpen);\n let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;\n let isSSR = useIsSSR();\n\n if ((!state.isOpen && !isExiting) || isSSR) {\n return null;\n }\n\n return (\n <ModalOverlayInner\n {...props}\n state={state}\n isExiting={isExiting}\n overlayRef={objectRef}\n modalRef={modalRef}\n />\n );\n}\n\n/**\n * A ModalOverlay is a wrapper for a Modal which allows customizing the backdrop element.\n */\nexport const ModalOverlay = /*#__PURE__*/ (forwardRef as forwardRefType)(\n ModalOverlayWithForwardRef\n);\n\nfunction ModalOverlayInner({UNSTABLE_portalContainer, ...props}: ModalOverlayInnerProps) {\n let modalRef = props.modalRef;\n let {state} = props;\n let {modalProps, underlayProps} = useModalOverlay(props, state, modalRef);\n\n let entering = useEnterAnimation(props.overlayRef) || props.isEntering || false;\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ModalOverlay',\n values: {\n isEntering: entering,\n isExiting: props.isExiting,\n state\n }\n });\n\n let viewport = useViewportSize();\n let pageWidth: number | undefined = undefined;\n let pageHeight: number | undefined = undefined;\n if (typeof document !== 'undefined') {\n let scrollingElement = isScrollable(document.body)\n ? document.body\n : document.scrollingElement || document.documentElement;\n // Prevent Firefox from adding scrollbars when the page has a fractional width/height.\n let fractionalWidthDifference = scrollingElement.getBoundingClientRect().width % 1;\n let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;\n pageWidth = scrollingElement.scrollWidth - fractionalWidthDifference;\n pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;\n }\n\n let style = {\n ...renderProps.style,\n '--visual-viewport-width': viewport.width + 'px',\n '--visual-viewport-height': viewport.height + 'px',\n '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,\n '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined\n };\n\n // oxlint-disable react/react-compiler\n return (\n <Overlay isExiting={props.isExiting} portalContainer={UNSTABLE_portalContainer}>\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), underlayProps)}\n {...renderProps}\n style={style}\n ref={props.overlayRef}\n data-entering={entering || undefined}\n data-exiting={props.isExiting || undefined}>\n <Provider\n values={[\n [\n InternalModalContext,\n {modalProps, modalRef, isExiting: props.isExiting, isDismissable: props.isDismissable}\n ],\n [OverlayTriggerStateContext, state]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n </Overlay>\n );\n // oxlint-enable react/react-compiler\n}\n\ninterface ModalContentProps\n extends RenderProps<ModalRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalContent'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n modalRef: ForwardedRef<HTMLDivElement>;\n}\n\nfunction ModalContent(props: ModalContentProps) {\n let {modalProps, modalRef, isExiting, isDismissable} = useContext(InternalModalContext)!;\n let state = useContext(OverlayTriggerStateContext)!;\n let mergedRefs = useMemo(() => mergeRefs(props.modalRef, modalRef), [props.modalRef, modalRef]);\n\n let ref = useObjectRef(mergedRefs);\n let entering = useEnterAnimation(ref);\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Modal',\n values: {\n isEntering: entering,\n isExiting,\n state\n }\n });\n\n return (\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), modalProps)}\n {...renderProps}\n ref={ref}\n data-entering={entering || undefined}\n data-exiting={isExiting || undefined}>\n {isDismissable && <DismissButton onDismiss={state.close} />}\n {renderProps.children}\n </dom.div>\n );\n}\n"],"names":[],"version":3,"file":"Modal.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAmGM,MAAM,0DAAe,CAAA,GAAA,oBAAY,EAAmD;AACpF,MAAM,0DAAuB,CAAA,GAAA,oBAAY,EAAoC;AAwB7E,MAAM,4CAAsB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,MACzE,KAAwB,EACxB,GAAiC;IAEjC,IAAI,MAAM,CAAA,GAAA,iBAAS,EAAE;IAErB,IAAI,KAAK;QACP,IACE,QAAQ,GAAG,CAAC,QAAQ,KAAK,gBACxB,CAAA,MAAM,YAAY,IAAI,MAAM,WAAW,KAAK,aAAa,MAAM,MAAM,KAAK,SAAQ,GACnF;YACA,gGAAgG;YAChG,MAAM,aAAa,IAAI,IAAI;gBACzB;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;gBACA;aACD;YACD,MAAM,eAAe,OAAO,IAAI,CAAC,OAAO,MAAM,CAA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EAAE,CAAA,GAAA,qBAAa,EAAE,OAAO;YAAC,QAAQ;QAAI,IAAI,WAAW;QAChE,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,YAAY;QAC3B,gBAAc,aAAa;OAC1B,+BAAiB,gCAAC,CAAA,GAAA,oBAAY;QAAE,WAAW,MAAM,KAAK;QACtD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Modal.tsx"],"sourcesContent":["/*\n * Copyright 2022 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';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {DialogContext, DialogProps, OverlayTriggerStateContext} from './Dialog';\nimport {DismissButton, Overlay} from 'react-aria/Overlay';\nimport {DOMAttributes, forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {isScrollable} from 'react-aria/private/utils/isScrollable';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport {\n OverlayTriggerProps,\n OverlayTriggerState,\n useOverlayTriggerState\n} from 'react-stately/useOverlayTriggerState';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {runAfterKeyboard} from 'react-aria/private/utils/runAfterKeyboard';\nimport {useEnterAnimation, useExitAnimation} from 'react-aria/private/utils/animation';\nimport {useIsSSR} from 'react-aria/SSRProvider';\nimport {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useViewportSize} from 'react-aria/private/utils/useViewportSize';\n\nexport interface ModalOverlayProps\n extends\n AriaModalOverlayProps,\n OverlayTriggerProps,\n RenderProps<ModalRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalOverlay'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n /**\n * Whether the modal is currently performing an entry animation.\n */\n isEntering?: boolean;\n /**\n * Whether the modal is currently performing an exit animation.\n */\n isExiting?: boolean;\n /**\n * Callback when the modal starts entering. Return a promise to indicate when the entry animation\n * has completed.\n */\n onEnter?: (element: HTMLElement) => void | Promise<void>;\n /**\n * Callback when the modal starts exiting. Return a promise to indicate when the exit animation\n * has completed.\n */\n onExit?: (element: HTMLElement) => void | Promise<void>;\n /**\n * The container element in which the overlay portal will be placed. This may have unknown\n * behavior depending on where it is portalled to.\n *\n * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n * @default document.body\n */\n UNSTABLE_portalContainer?: Element;\n /**\n * Whether to wait until the entry animation completes before hiding content outside the modal\n * and moving focus into it.\n *\n * @private\n */\n UNSTABLE_deferUntilEntered?: boolean;\n}\n\ninterface InternalModalContextValue {\n modalProps: DOMAttributes;\n modalRef: RefObject<HTMLDivElement | null>;\n isOpen: boolean;\n isExiting: boolean;\n isDismissable?: boolean;\n onExitRef?: RefObject<ModalOverlayProps['onExit'] | null>;\n}\n\nexport const ModalContext = createContext<ContextValue<ModalOverlayProps, HTMLDivElement>>(null);\nexport const InternalModalContext = createContext<InternalModalContextValue | null>(null);\n\nexport interface ModalRenderProps {\n /**\n * Whether the modal is currently entering. Use this to apply animations.\n *\n * @selector [data-entering]\n */\n isEntering: boolean;\n /**\n * Whether the modal is currently exiting. Use this to apply animations.\n *\n * @selector [data-exiting]\n */\n isExiting: boolean;\n /**\n * State of the modal.\n */\n state: OverlayTriggerState;\n}\n\n/**\n * A modal is an overlay element which blocks interaction with elements outside it.\n */\nexport const Modal = /*#__PURE__*/ (forwardRef as forwardRefType)(function Modal(\n props: ModalOverlayProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n let ctx = useContext(InternalModalContext);\n\n if (ctx) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n // create a list of props that are passed in but not allowed when using an external ModalOverlay\n const invalidSet = new Set([\n 'isDismissable',\n 'isKeyboardDismissDisabled',\n 'isOpen',\n 'defaultOpen',\n 'onOpenChange',\n 'isEntering',\n 'isExiting',\n 'UNSTABLE_portalContainer',\n 'shouldCloseOnInteractOutside'\n ]);\n const invalidProps = Object.keys(props).filter(key => invalidSet.has(key));\n console.warn(\n `This modal is already wrapped in a ModalOverlay, props [${invalidProps.join(', ')}] should be placed on the ModalOverlay instead.`\n );\n }\n return (\n <ModalContent {...props} modalRef={ref}>\n {props.children}\n </ModalContent>\n );\n }\n\n let {\n isDismissable,\n isKeyboardDismissDisabled,\n isOpen,\n defaultOpen,\n onOpenChange,\n children,\n isEntering,\n isExiting,\n UNSTABLE_portalContainer,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n return (\n <ModalOverlay\n isDismissable={isDismissable}\n isKeyboardDismissDisabled={isKeyboardDismissDisabled}\n isOpen={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n isEntering={isEntering}\n isExiting={isExiting}\n UNSTABLE_portalContainer={UNSTABLE_portalContainer}\n shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}>\n <ModalContent {...otherProps} modalRef={ref}>\n {children}\n </ModalContent>\n </ModalOverlay>\n );\n});\n\ninterface ModalOverlayInnerProps extends ModalOverlayProps {\n overlayRef: RefObject<HTMLDivElement | null>;\n modalRef: RefObject<HTMLDivElement | null>;\n state: OverlayTriggerState;\n isExiting: boolean;\n onExitRef?: RefObject<ModalOverlayProps['onExit'] | null>;\n}\n\nfunction ModalOverlayWithForwardRef(props: ModalOverlayProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ModalContext);\n let contextState = useContext(OverlayTriggerStateContext);\n let localState = useOverlayTriggerState(props);\n let state =\n props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;\n if (state === contextState) {\n if (\n process.env.NODE_ENV !== 'production' &&\n (props.onOpenChange || props.defaultOpen !== undefined || props.isOpen !== undefined)\n ) {\n console.warn(\n 'This modals state is controlled by a trigger, place onOpenChange on the trigger instead.'\n );\n }\n }\n\n let objectRef = useObjectRef(ref);\n let modalRef = useRef<HTMLDivElement>(null);\n let isOverlayExiting = useExitAnimation(objectRef, state.isOpen, props.onExit);\n let onExitRef = useRef<ModalOverlayProps['onExit'] | null>(null);\n let isModalExiting = useExitAnimation(modalRef, state.isOpen, element =>\n onExitRef.current?.(element)\n );\n let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;\n let isSSR = useIsSSR();\n\n if ((!state.isOpen && !isExiting) || isSSR) {\n return null;\n }\n\n return (\n <ModalOverlayInner\n {...props}\n state={state}\n isExiting={isExiting}\n overlayRef={objectRef}\n modalRef={modalRef}\n onExitRef={onExitRef}\n />\n );\n}\n\n/**\n * A ModalOverlay is a wrapper for a Modal which allows customizing the backdrop element.\n */\nexport const ModalOverlay = /*#__PURE__*/ (forwardRef as forwardRefType)(\n ModalOverlayWithForwardRef\n);\n\nfunction ModalOverlayInner({\n UNSTABLE_portalContainer,\n UNSTABLE_deferUntilEntered,\n ...props\n}: ModalOverlayInnerProps) {\n let modalRef = props.modalRef;\n let {state} = props;\n\n let [isOpen, setIsOpen] = useState(false);\n let entering =\n useEnterAnimation(props.overlayRef, isOpen, props.onEnter) || props.isEntering || false;\n let isDeferred = !!UNSTABLE_deferUntilEntered && (!isOpen || entering);\n let {modalProps, underlayProps} = useModalOverlay(\n {...props, isEntering: isDeferred},\n state,\n modalRef\n );\n\n // Pass the entering state to the dialog so it waits to move focus until the modal has entered.\n let dialogContext = useContext(DialogContext);\n let mergedDialogContext = UNSTABLE_deferUntilEntered\n ? mergeDialogContext(dialogContext, {isEntering: isDeferred})\n : dialogContext;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ModalOverlay',\n values: {\n isEntering: entering,\n isExiting: props.isExiting,\n state\n }\n });\n\n let viewport = useViewportSize();\n let pageWidth: number | undefined = undefined;\n let pageHeight: number | undefined = undefined;\n if (typeof document !== 'undefined') {\n let scrollingElement = isScrollable(document.body)\n ? document.body\n : document.scrollingElement || document.documentElement;\n // Prevent Firefox from adding scrollbars when the page has a fractional width/height.\n let fractionalWidthDifference = scrollingElement.getBoundingClientRect().width % 1;\n let fractionalHeightDifference = scrollingElement.getBoundingClientRect().height % 1;\n pageWidth = scrollingElement.scrollWidth - fractionalWidthDifference;\n pageHeight = scrollingElement.scrollHeight - fractionalHeightDifference;\n }\n\n let style = {\n ...renderProps.style,\n '--visual-viewport-width': viewport.width + 'px',\n '--visual-viewport-height': viewport.height + 'px',\n '--page-width': pageWidth !== undefined ? pageWidth + 'px' : undefined,\n '--page-height': pageHeight !== undefined ? pageHeight + 'px' : undefined\n };\n\n // Since an auto-focused input may open the OSK, we defer the reveal, as a courtesy, to avoid layout shift.\n useLayoutEffect(() => runAfterKeyboard(() => setIsOpen(true)), []);\n\n // oxlint-disable react/react-compiler\n return (\n <Overlay isExiting={props.isExiting} portalContainer={UNSTABLE_portalContainer}>\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), underlayProps)}\n {...renderProps}\n style={style}\n ref={props.overlayRef}\n data-entering={entering || undefined}\n data-exiting={props.isExiting || undefined}>\n <Provider\n values={[\n [\n InternalModalContext,\n {\n modalProps,\n modalRef,\n isExiting: props.isExiting,\n onExitRef: props.onExitRef,\n isOpen,\n isDismissable: props.isDismissable\n }\n ],\n [OverlayTriggerStateContext, state],\n [DialogContext, mergedDialogContext]\n ]}>\n {renderProps.children}\n </Provider>\n </dom.div>\n </Overlay>\n );\n // oxlint-enable react/react-compiler\n}\n\nfunction mergeDialogContext(\n context: ContextValue<DialogProps, HTMLElement>,\n props: Partial<DialogProps>\n): ContextValue<DialogProps, HTMLElement> {\n if (context && 'slots' in context && context.slots) {\n let slots = {};\n for (let key in context.slots) {\n slots[key] = {...context.slots[key], ...props};\n }\n return {...context, slots};\n }\n return {...context, ...props};\n}\n\ninterface ModalContentProps\n extends RenderProps<ModalRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ModalContent'\n */\n className?: ClassNameOrFunction<ModalRenderProps>;\n modalRef: ForwardedRef<HTMLDivElement>;\n onEnter?: (element: HTMLElement) => void;\n onExit?: (element: HTMLElement) => void;\n}\n\nfunction ModalContent(props: ModalContentProps) {\n let {modalProps, modalRef, isExiting, onExitRef, isDismissable, isOpen} =\n useContext(InternalModalContext)!;\n let state = useContext(OverlayTriggerStateContext)!;\n let mergedRefs = useMemo(() => mergeRefs(props.modalRef, modalRef), [props.modalRef, modalRef]);\n\n let ref = useObjectRef(mergedRefs);\n let entering = useEnterAnimation(ref, isOpen, props.onEnter);\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Modal',\n values: {\n isEntering: entering,\n isExiting,\n state\n }\n });\n\n useLayoutEffect(() => {\n if (onExitRef) {\n onExitRef.current = props.onExit;\n }\n });\n\n return (\n <dom.div\n {...mergeProps(filterDOMProps(props, {global: true}), modalProps)}\n {...renderProps}\n ref={ref}\n data-entering={entering || undefined}\n data-exiting={isExiting || undefined}>\n {isDismissable && <DismissButton onDismiss={state.close} />}\n {renderProps.children}\n </dom.div>\n );\n}\n"],"names":[],"version":3,"file":"Modal.mjs.map"}