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/src/Dialog.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 */\nimport {AriaDialogProps, useDialog} from 'react-aria/useDialog';\n\nimport {ButtonContext} from './Button';\nimport {\n  ContextValue,\n  DEFAULT_SLOT,\n  dom,\n  DOMRenderProps,\n  Provider,\n  SlotProps,\n  StyleProps,\n  useContextProps,\n  useRenderProps\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes} from '@react-types/shared';\nimport {HeadingContext} from './Heading';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerProps, OverlayTriggerState} from 'react-stately/useOverlayTriggerState';\nimport {PopoverContext} from './Popover';\nimport {PressResponder} from 'react-aria/private/interactions/PressResponder';\nimport React, {\n  createContext,\n  ForwardedRef,\n  forwardRef,\n  JSX,\n  ReactNode,\n  useContext,\n  useRef\n} from 'react';\nimport {RootMenuTriggerStateContext} from './Menu';\nimport {useId} from 'react-aria/useId';\nimport {useMenuTriggerState} from 'react-stately/useMenuTriggerState';\nimport {useOverlayTrigger} from 'react-aria/useOverlayTrigger';\n\nexport interface DialogTriggerProps extends OverlayTriggerProps {\n  children: ReactNode;\n}\n\nexport interface DialogRenderProps {\n  close: () => void;\n}\n\nexport interface DialogProps\n  extends\n    AriaDialogProps,\n    StyleProps,\n    SlotProps,\n    DOMRenderProps<'section', undefined>,\n    GlobalDOMAttributes<HTMLElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element.\n   *\n   * @default 'react-aria-Dialog'\n   */\n  className?: string;\n  /** Children of the dialog. A function may be provided to access a function to close the dialog. */\n  children?: ReactNode | ((opts: DialogRenderProps) => ReactNode);\n}\n\nexport const DialogContext = createContext<ContextValue<DialogProps, HTMLElement>>(null);\nexport const OverlayTriggerStateContext = createContext<OverlayTriggerState | null>(null);\n\n/**\n * A DialogTrigger opens a dialog when a trigger element is pressed.\n */\nexport function DialogTrigger(props: DialogTriggerProps): JSX.Element {\n  // Use useMenuTriggerState instead of useOverlayTriggerState in case a menu is embedded in the dialog.\n  // This is needed to handle submenus.\n  let state = useMenuTriggerState(props);\n\n  let buttonRef = useRef<HTMLButtonElement>(null);\n  let {triggerProps, overlayProps} = useOverlayTrigger({type: 'dialog'}, state, buttonRef);\n\n  // Label dialog by the trigger as a fallback if there is no title slot.\n  // This is done in RAC instead of hooks because otherwise we cannot distinguish\n  // between context and props. Normally aria-labelledby overrides the title\n  // but when sent by context we want the title to win.\n  triggerProps.id = useId();\n  overlayProps['aria-labelledby'] = triggerProps.id;\n\n  return (\n    <Provider\n      values={[\n        [OverlayTriggerStateContext, state],\n        [RootMenuTriggerStateContext, state],\n        [DialogContext, overlayProps],\n        [\n          PopoverContext,\n          {\n            trigger: 'DialogTrigger',\n            triggerRef: buttonRef,\n            'aria-labelledby': overlayProps['aria-labelledby']\n          }\n        ]\n      ]}>\n      <PressResponder {...triggerProps} ref={buttonRef} isPressed={state.isOpen}>\n        {props.children}\n      </PressResponder>\n    </Provider>\n  );\n}\n\n/**\n * A dialog is an overlay shown above other content in an application.\n */\nexport const Dialog = /*#__PURE__*/ (forwardRef as forwardRefType)(function Dialog(\n  props: DialogProps,\n  ref: ForwardedRef<HTMLElement>\n) {\n  let originalAriaLabelledby = props['aria-labelledby'];\n  [props, ref] = useContextProps(props, ref, DialogContext);\n  let {dialogProps, titleProps} = useDialog(\n    {\n      ...props,\n      // Only pass aria-labelledby from props, not context.\n      // Context is used as a fallback below.\n      'aria-labelledby': originalAriaLabelledby\n    },\n    ref\n  );\n  let state = useContext(OverlayTriggerStateContext);\n\n  if (!dialogProps['aria-label'] && !dialogProps['aria-labelledby']) {\n    // If aria-labelledby exists on props, we know it came from context.\n    // Use that as a fallback in case there is no title slot.\n    if (props['aria-labelledby']) {\n      dialogProps['aria-labelledby'] = props['aria-labelledby'];\n    } else if (process.env.NODE_ENV !== 'production') {\n      console.warn(\n        'If a Dialog does not contain a <Heading slot=\"title\">, it must have an aria-label or aria-labelledby attribute for accessibility.'\n      );\n    }\n  }\n\n  let renderProps = useRenderProps({\n    defaultClassName: 'react-aria-Dialog',\n    className: props.className,\n    style: props.style,\n    children: props.children,\n    values: {\n      close: state?.close || (() => {})\n    }\n  });\n\n  let DOMProps = filterDOMProps(props, {global: true});\n\n  return (\n    <dom.section\n      {...mergeProps(DOMProps, renderProps, dialogProps)}\n      render={props.render}\n      ref={ref}\n      slot={props.slot || undefined}>\n      <Provider\n        values={[\n          [\n            HeadingContext,\n            {\n              slots: {\n                [DEFAULT_SLOT]: {},\n                title: {...titleProps, level: 2}\n              }\n            }\n          ],\n          [\n            ButtonContext,\n            {\n              slots: {\n                [DEFAULT_SLOT]: {},\n                close: {\n                  onPress: () => state?.close()\n                }\n              }\n            }\n          ]\n        ]}>\n        {renderProps.children}\n      </Provider>\n    </dom.section>\n  );\n});\n"],"names":[],"version":3,"file":"Dialog.mjs.map"}