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I,IAAI;QACpB,OAAO;QACP,KAAK,MAAM,GAAG;QACd,gBAAc,MAAM,OAAO;QAC3B,kBAAgB;QAChB,iBAAe,cAAc;QAC7B,gBAAc,aAAa;OAC1B,CAAC,MAAM,UAAU,kBAAI,gCAAC,CAAA,GAAA,oBAAY;QAAE,WAAW,MAAM,KAAK;sBAC3D,gCAAC,CAAA,GAAA,yCAAkB,EAAE,QAAQ;QAAC,OAAO;YAAC,GAAG,UAAU;uBAAE;YAAW,KAAK;QAAQ;OAC1E,yBAEH,gCAAC,CAAA,GAAA,oBAAY;QAAE,WAAW,MAAM,KAAK;;IAIzC,yGAAyG;IACzG,IAAI,CAAC,cACH,qBACE,gCAAC,CAAA,GAAA,cAAM;QACJ,GAAG,KAAK;QACT,oBAAoB;QACpB,WAAW;QACX,iBAAiB;OAChB,CAAC,MAAM,UAAU,IAAI,MAAM,MAAM,kBAChC,gCAAC;QAAI,eAAY;QAAY,GAAG,aAAa;QAAE,OAAO;YAAC,UAAU;YAAS,OAAO;QAAC;sBAEpF,gCAAC;QAAI,KAAK;QAAc,OAAO;YAAC,SAAS;QAAU;qBACjD,gCAAC,0CAAoB,QAAQ;QAAC,OAAO;OAClC;IAOX,qEAAqE;IACrE,qBACE,gCAAC,CAAA,GAAA,cAAM;QACJ,GAAG,KAAK;QACT,oBAAoB;QACpB,WAAW;QACX,iBAAiB,4BAA4B,UAAU,WAAW;OACjE;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 {\n  AriaLabelingProps,\n  forwardRefType,\n  GlobalDOMAttributes,\n  RefObject\n} 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 {\n  OverlayTriggerProps,\n  OverlayTriggerState,\n  useOverlayTriggerState\n} from 'react-stately/useOverlayTriggerState';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PlacementAxis, PositionProps} from 'react-aria/useOverlayPosition';\nimport React, {\n  Context,\n  createContext,\n  ForwardedRef,\n  forwardRef,\n  useCallback,\n  useContext,\n  useEffect,\n  useMemo,\n  useRef,\n  useState\n} 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';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\nexport interface PopoverProps\n  extends\n    Omit<PositionProps, 'isOpen'>,\n    Omit<AriaPopoverProps, 'popoverRef' | 'triggerRef' | 'groupRef' | 'offset' | 'arrowSize'>,\n    OverlayTriggerProps,\n    RenderProps<PopoverRenderProps>,\n    SlotProps,\n    AriaLabelingProps,\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-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\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   * The additional offset applied along the main axis between the element and its\n   * anchor element.\n   *\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   *\n   * @selector [data-trigger=\"...\"]\n   */\n  trigger: string | null;\n  /**\n   * The placement of the popover relative to the trigger.\n   *\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   *\n   * @selector [data-entering]\n   */\n  isEntering: boolean;\n  /**\n   * Whether the popover is currently exiting. Use this to apply animations.\n   *\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(\n  props: PopoverProps,\n  ref: ForwardedRef<HTMLElement>\n) {\n  [props, ref] = useContextProps(props, ref, PopoverContext);\n  let contextState = useContext(OverlayTriggerStateContext);\n  let localState = useOverlayTriggerState(props);\n  let state =\n    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});\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({\n  state,\n  isExiting,\n  UNSTABLE_portalContainer,\n  clearContexts,\n  ...props\n}: 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    {\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    },\n    state\n  );\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 (\n      isDialog &&\n      (props.trigger !== 'SubmenuTrigger' || getInteractionModality() !== 'pointer') &&\n      ref.current &&\n      !isFocusWithin(ref.current)\n    ) {\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 [triggerWidth, setTriggerWidth] = useState<string | null>(null);\n  let onResize = useCallback(() => {\n    if (props.triggerRef.current) {\n      setTriggerWidth(props.triggerRef.current.getBoundingClientRect().width + 'px');\n    }\n  }, [props.triggerRef]);\n\n  useLayoutEffect(onResize, [onResize]);\n  useResizeObserver({\n    ref: renderProps.style?.['--trigger-width'] ? undefined : props.triggerRef,\n    onResize: onResize\n  });\n\n  let style = {\n    ...popoverProps.style,\n    '--trigger-anchor-point': triggerAnchorPoint\n      ? `${triggerAnchorPoint.x}px ${triggerAnchorPoint.y}px`\n      : undefined,\n    ...renderProps.style,\n    '--trigger-width': renderProps.style?.['--trigger-width'] || triggerWidth\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\n        {...props}\n        shouldContainFocus={isDialog}\n        isExiting={isExiting}\n        portalContainer={UNSTABLE_portalContainer}>\n        {!props.isNonModal && state.isOpen && (\n          <div data-testid=\"underlay\" {...underlayProps} style={{position: 'fixed', inset: 0}} />\n        )}\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\n      {...props}\n      shouldContainFocus={isDialog}\n      isExiting={isExiting}\n      portalContainer={UNSTABLE_portalContainer ?? groupCtx?.current ?? undefined}>\n      {overlay}\n    </Overlay>\n  );\n}\n"],"names":[],"version":3,"file":"Popover.mjs.map"}