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;QAAG,GAAG,KAAK;QAAE,oBAAoB;QAAU,WAAW;QAAW,iBAAiB;OACtF,CAAC,MAAM,UAAU,IAAI,MAAM,MAAM,kBAAI,0DAAC;QAAI,eAAY;QAAY,GAAG,aAAa;QAAE,OAAO;YAAC,UAAU;YAAS,OAAO;QAAC;sBACxH,0DAAC;QAAI,KAAK;QAAc,OAAO;YAAC,SAAS;QAAU;qBACjD,0DAAC,0CAAoB,QAAQ;QAAC,OAAO;OAClC;IAOX,qEAAqE;IACrE,qBACE,0DAAC,CAAA,GAAA,+BAAM;QAAG,GAAG,KAAK;QAAE,oBAAoB;QAAU,WAAW;QAAW,iBAAiB,4BAA4B,UAAU,WAAW;OACvI;AAGP","sources":["packages/react-aria-components/src/Popover.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 {AriaLabelingProps, forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {AriaPopoverProps, usePopover} from 'react-aria/usePopover';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps\n} from './utils';\nimport {DismissButton, Overlay} from 'react-aria/Overlay';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {focusSafely} from 'react-aria/private/interactions/focusSafely';\nimport {getInteractionModality} from 'react-aria/private/interactions/useFocusVisible';\nimport {isFocusWithin} from 'react-aria/private/utils/shadowdom/DOMFunctions';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayArrowContext} from './OverlayArrow';\nimport {OverlayTriggerProps, OverlayTriggerState, useOverlayTriggerState} from 'react-stately/useOverlayTriggerState';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PlacementAxis, PositionProps} from 'react-aria/useOverlayPosition';\nimport React, {Context, createContext, ForwardedRef, forwardRef, useContext, useEffect, useMemo, useRef, useState} from 'react';\nimport {useEnterAnimation, useExitAnimation} from 'react-aria/private/utils/animation';\nimport {useIsHidden} from 'react-aria/private/collections/Hidden';\nimport {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\nimport {useLocale} from 'react-aria/I18nProvider';\n\nexport interface PopoverProps extends Omit<PositionProps, 'isOpen'>, Omit<AriaPopoverProps, 'popoverRef' | 'triggerRef' | 'groupRef' | 'offset' | 'arrowSize'>, OverlayTriggerProps, RenderProps<PopoverRenderProps>, SlotProps, AriaLabelingProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-Popover'\n   */\n  className?: ClassNameOrFunction<PopoverRenderProps>,\n  /**\n   * The name of the component that triggered the popover. This is reflected on the element\n   * as the `data-trigger` attribute, and can be used to provide specific\n   * styles for the popover depending on which element triggered it.\n   */\n  trigger?: string,\n  /**\n   * The ref for the element which the popover positions itself with respect to.\n   *\n   * When used within a trigger component such as DialogTrigger, MenuTrigger, Select, etc.,\n   * this is set automatically. It is only required when used standalone.\n   */\n  triggerRef?: RefObject<Element | null>,\n  /**\n   * Whether the popover is currently performing an entry animation.\n   */\n  isEntering?: boolean,\n  /**\n   * Whether the popover 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 behavior depending on where it is portalled to.\n   * @default document.body\n   * @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.\n   */\n  UNSTABLE_portalContainer?: Element,\n  /**\n   * The additional offset applied along the main axis between the element and its\n   * anchor element.\n   * @default 8\n   */\n  offset?: number\n}\n\nexport interface PopoverRenderProps {\n  /**\n   * The name of the component that triggered the popover, e.g. \"DialogTrigger\" or \"ComboBox\".\n   * @selector [data-trigger=\"...\"]\n   */\n  trigger: string | null,\n  /**\n   * The placement of the popover relative to the trigger.\n   * @selector [data-placement=\"left | right | top | bottom\"]\n   */\n  placement: PlacementAxis | null,\n  /**\n   * Whether the popover is currently entering. Use this to apply animations.\n   * @selector [data-entering]\n   */\n  isEntering: boolean,\n  /**\n   * Whether the popover is currently exiting. Use this to apply animations.\n   * @selector [data-exiting]\n   */\n  isExiting: boolean\n}\n\ninterface PopoverContextValue extends PopoverProps {\n  /** Contexts to clear. */\n  clearContexts?: Context<any>[]\n}\n\nexport const PopoverContext = createContext<ContextValue<PopoverContextValue, HTMLElement>>(null);\n\n// Stores a ref for the portal container for a group of popovers (e.g. submenus).\nconst PopoverGroupContext = createContext<RefObject<Element | null> | null>(null);\n\n/**\n * A popover is an overlay element positioned relative to a trigger.\n */\nexport const Popover = /*#__PURE__*/ (forwardRef as forwardRefType)(function Popover(props: PopoverProps, ref: ForwardedRef<HTMLElement>) {\n  [props, ref] = useContextProps(props, ref, PopoverContext);\n  let contextState = useContext(OverlayTriggerStateContext);\n  let localState = useOverlayTriggerState(props);\n  let state = props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;\n  let isExiting = useExitAnimation(ref, state.isOpen) || props.isExiting || false;\n  let isHidden = useIsHidden();\n  let {direction} = useLocale();\n\n  // If we are in a hidden tree, we still need to preserve our children.\n  if (isHidden) {\n    let children = props.children;\n    if (typeof children === 'function') {\n      children = children({\n        trigger: props.trigger || null,\n        placement: 'bottom',\n        isEntering: false,\n        isExiting: false,\n        defaultChildren: null\n      });\n    }\n\n    return <>{children}</>;\n  }\n\n  if (state && !state.isOpen && !isExiting) {\n    return null;\n  }\n\n  return (\n    <PopoverInner\n      {...props}\n      triggerRef={props.triggerRef!}\n      state={state}\n      popoverRef={ref}\n      isExiting={isExiting}\n      dir={direction} />\n  );\n});\n\ninterface PopoverInnerProps extends AriaPopoverProps, RenderProps<PopoverRenderProps>, SlotProps {\n  state: OverlayTriggerState,\n  isEntering?: boolean,\n  isExiting: boolean,\n  UNSTABLE_portalContainer?: Element,\n  trigger?: string,\n  dir?: 'ltr' | 'rtl',\n  clearContexts?: Context<any>[]\n}\n\nfunction PopoverInner({state, isExiting, UNSTABLE_portalContainer, clearContexts, ...props}: PopoverInnerProps) {\n  // Calculate the arrow size internally (and remove props.arrowSize from PopoverProps)\n  // Referenced from: packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx\n  let arrowRef = useRef<HTMLDivElement>(null);\n  let containerRef = useRef<HTMLDivElement | null>(null);\n  let groupCtx = useContext(PopoverGroupContext);\n  let isSubPopover = groupCtx && props.trigger === 'SubmenuTrigger';\n\n  let {popoverProps, underlayProps, arrowProps, placement, triggerAnchorPoint} = usePopover({\n    ...props,\n    offset: props.offset ?? 8,\n    arrowRef,\n    // If this is a submenu/subdialog, use the root popover's container\n    // to detect outside interaction and add aria-hidden.\n    groupRef: isSubPopover ? groupCtx! : containerRef\n  }, state);\n\n  let ref = props.popoverRef as RefObject<HTMLDivElement | null>;\n  let isEntering = useEnterAnimation(ref, !!placement) || props.isEntering || false;\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-Popover',\n    values: {\n      trigger: props.trigger || null,\n      placement,\n      isEntering,\n      isExiting\n    }\n  });\n\n  // Automatically render Popover with role=dialog except when isNonModal is true,\n  // or a dialog is already nested inside the popover.\n  let shouldBeDialog = !props.isNonModal || props.trigger === 'SubmenuTrigger';\n  let [isDialog, setDialog] = useState(false);\n  useLayoutEffect(() => {\n    if (ref.current) {\n      setDialog(shouldBeDialog && !ref.current.querySelector('[role=dialog]'));\n    }\n  }, [ref, shouldBeDialog]);\n\n  // Focus the popover itself on mount, unless a child element is already focused.\n  // Skip this for submenus since hovering a submenutrigger should keep focus on the trigger\n  useEffect(() => {\n    if (isDialog && (props.trigger !== 'SubmenuTrigger' || getInteractionModality() !== 'pointer') && ref.current && !isFocusWithin(ref.current)) {\n      focusSafely(ref.current);\n    }\n  }, [isDialog, ref, props.trigger]);\n\n  let children = useMemo(() => {\n    let children = renderProps.children;\n    if (clearContexts) {\n      for (let Context of clearContexts) {\n        children = <Context.Provider value={null}>{children}</Context.Provider>;\n      }\n    }\n    return children;\n  }, [renderProps.children, clearContexts]);\n\n  let style = {\n    ...popoverProps.style,\n    '--trigger-anchor-point': triggerAnchorPoint ? `${triggerAnchorPoint.x}px ${triggerAnchorPoint.y}px` : undefined,\n    ...renderProps.style\n  };\n\n  let overlay = (\n    <dom.div\n      {...mergeProps(filterDOMProps(props, {global: true}), popoverProps)}\n      {...renderProps}\n      role={isDialog ? 'dialog' : undefined}\n      tabIndex={isDialog ? -1 : undefined}\n      aria-label={props['aria-label']}\n      aria-labelledby={props['aria-labelledby']}\n      ref={ref}\n      slot={props.slot || undefined}\n      style={style}\n      dir={props.dir}\n      data-trigger={props.trigger}\n      data-placement={placement}\n      data-entering={isEntering || undefined}\n      data-exiting={isExiting || undefined}>\n      {!props.isNonModal && <DismissButton onDismiss={state.close} />}\n      <OverlayArrowContext.Provider value={{...arrowProps, placement, ref: arrowRef}}>\n        {children}\n      </OverlayArrowContext.Provider>\n      <DismissButton onDismiss={state.close} />\n    </dom.div>\n  );\n\n  // If this is a root popover, render an extra div to act as the portal container for submenus/subdialogs.\n  if (!isSubPopover) {\n    return (\n      <Overlay {...props} shouldContainFocus={isDialog} isExiting={isExiting} portalContainer={UNSTABLE_portalContainer}>\n        {!props.isNonModal && state.isOpen && <div data-testid=\"underlay\" {...underlayProps} style={{position: 'fixed', inset: 0}} />}\n        <div ref={containerRef} style={{display: 'contents'}}>\n          <PopoverGroupContext.Provider value={containerRef}>\n            {overlay}\n          </PopoverGroupContext.Provider>\n        </div>\n      </Overlay>\n    );\n  }\n\n  // Submenus/subdialogs are mounted into the root popover's container.\n  return (\n    <Overlay {...props} shouldContainFocus={isDialog} isExiting={isExiting} portalContainer={UNSTABLE_portalContainer ?? groupCtx?.current ?? undefined}>\n      {overlay}\n    </Overlay>\n  );\n}\n"],"names":[],"version":3,"file":"Popover.cjs.map"}