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AAK,GAAG;QAC9B,KAAK;QACJ,GAAG,UAAU;qBACd,0DAAC;QACC,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAC9B,GAAG,SAAS,IAAI,CAAC;;AAIzB,EAEA;;;;;;;;;;;CAWC","sources":["packages/@adobe/react-spectrum/src/overlays/Popover.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 {AriaPopoverProps, PopoverAria, usePopover} from 'react-aria/usePopover';\n\nimport {classNames} from '../utils/classNames';\nimport {DismissButton} from 'react-aria/Overlay';\nimport {DOMRef, RefObject, StyleProps} from '@react-types/shared';\nimport {FocusWithinProps, useFocusWithin} from 'react-aria/useFocusWithin';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {Overlay} from './Overlay';\nimport {OverlayTriggerState} from 'react-stately/useOverlayTriggerState';\nimport overrideStyles from './overlays.css';\nimport React, {ForwardedRef, forwardRef, ReactNode, useRef, useState} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/popover/vars.css';\nimport {Underlay} from './Underlay';\nimport {useDOMRef} from '../utils/useDOMRef';\nimport {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useStyleProps} from '../utils/styleProps';\n\ninterface PopoverProps\n  extends Omit<AriaPopoverProps, 'popoverRef' | 'maxHeight'>, FocusWithinProps, StyleProps {\n  children: ReactNode;\n  hideArrow?: boolean;\n  state: OverlayTriggerState;\n  shouldContainFocus?: boolean;\n  onEntering?: () => void;\n  onEnter?: () => void;\n  onEntered?: () => void;\n  onExiting?: () => void;\n  onExited?: () => void;\n  onExit?: () => void;\n  container?: HTMLElement;\n  disableFocusManagement?: boolean;\n  enableBothDismissButtons?: boolean;\n  onDismissButtonPress?: () => void;\n}\n\ninterface PopoverWrapperProps extends PopoverProps, FocusWithinProps {\n  isOpen?: boolean;\n  wrapperRef: RefObject<HTMLDivElement | null>;\n}\n\ninterface ArrowProps {\n  arrowProps: PopoverAria['arrowProps'];\n  isLandscape: boolean;\n  arrowRef?: RefObject<SVGSVGElement | null>;\n  primary: number;\n  secondary: number;\n  borderDiagonal: number;\n}\n\n/**\n * Arrow placement can be done pointing right or down because those paths start at 0, x or y.\n * Because the other two don't, they start at a fractional pixel value, it introduces rounding\n * differences between browsers and between display types (retina with subpixels vs not retina). By\n * flipping them with CSS we can ensure that the path always starts at 0 so that it perfectly\n * overlaps the popover's border. See bottom of file for more explanation.\n */\nlet arrowPlacement = {\n  left: 'right',\n  right: 'right',\n  top: 'bottom',\n  bottom: 'bottom'\n};\n\nexport const Popover = forwardRef(function Popover(\n  props: PopoverProps,\n  ref: DOMRef<HTMLDivElement>\n) {\n  let {children, state, ...otherProps} = props;\n  let domRef = useDOMRef(ref);\n  let wrapperRef = useRef<HTMLDivElement>(null);\n\n  return (\n    <Overlay {...otherProps} isOpen={state.isOpen} nodeRef={wrapperRef}>\n      <PopoverWrapper ref={domRef} {...props} wrapperRef={wrapperRef}>\n        {children}\n      </PopoverWrapper>\n    </Overlay>\n  );\n});\n\nconst PopoverWrapper = forwardRef(\n  (props: PopoverWrapperProps, ref: ForwardedRef<HTMLDivElement | null>) => {\n    let {\n      children,\n      isOpen,\n      hideArrow,\n      isNonModal,\n      enableBothDismissButtons,\n      state,\n      wrapperRef,\n      onDismissButtonPress = () => state.close()\n    } = props;\n    let {styleProps} = useStyleProps(props);\n    let objRef = useObjectRef(ref);\n\n    let {size, borderWidth, arrowRef} = useArrowSize();\n    const borderRadius = usePopoverBorderRadius(objRef);\n    let borderDiagonal = borderWidth * Math.SQRT2;\n    let primary = size + borderDiagonal;\n    let secondary = primary * 2;\n    let {popoverProps, arrowProps, underlayProps, placement} = usePopover(\n      {\n        ...props,\n        popoverRef: objRef,\n        maxHeight: undefined,\n        arrowSize: hideArrow ? 0 : secondary,\n        arrowBoundaryOffset: borderRadius\n      },\n      state\n    );\n    let {focusWithinProps} = useFocusWithin(props);\n\n    // Attach Transition's nodeRef to outermost wrapper for node.reflow: https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L231\n    return (\n      <div ref={wrapperRef}>\n        {!isNonModal && <Underlay isTransparent {...mergeProps(underlayProps)} isOpen={isOpen} />}\n        <div\n          {...styleProps}\n          {...mergeProps(popoverProps, focusWithinProps)}\n          style={{\n            ...styleProps.style,\n            ...popoverProps.style\n          }}\n          ref={objRef}\n          className={classNames(\n            styles,\n            'spectrum-Popover',\n            `spectrum-Popover--${placement}`,\n            {\n              'spectrum-Popover--withTip': !hideArrow,\n              'is-open': isOpen,\n              [`is-open--${placement}`]: isOpen,\n              'is-exiting': !state.isOpen\n            },\n            classNames(overrideStyles, 'spectrum-Popover', 'react-spectrum-Popover'),\n            styleProps.className\n          )}\n          role=\"presentation\"\n          data-testid=\"popover\">\n          {(!isNonModal || enableBothDismissButtons) && (\n            <DismissButton onDismiss={onDismissButtonPress} />\n          )}\n          {children}\n          {hideArrow ? null : (\n            <Arrow\n              arrowProps={arrowProps}\n              isLandscape={placement != null ? arrowPlacement[placement] === 'bottom' : false}\n              arrowRef={arrowRef}\n              primary={primary}\n              secondary={secondary}\n              borderDiagonal={borderDiagonal}\n            />\n          )}\n          <DismissButton onDismiss={onDismissButtonPress} />\n        </div>\n      </div>\n    );\n  }\n);\n\nfunction usePopoverBorderRadius(popoverRef: RefObject<HTMLDivElement | null>) {\n  let [borderRadius, setBorderRadius] = useState(0);\n  useLayoutEffect(() => {\n    if (popoverRef.current) {\n      let spectrumBorderRadius = window.getComputedStyle(popoverRef.current).borderRadius;\n      if (spectrumBorderRadius !== '') {\n        setBorderRadius(parseInt(spectrumBorderRadius, 10));\n      }\n    }\n  }, [popoverRef]);\n  return borderRadius;\n}\n\nfunction useArrowSize() {\n  let [size, setSize] = useState(20);\n  let [borderWidth, setBorderWidth] = useState(1);\n  let arrowRef = useRef<SVGSVGElement>(null);\n  // get the css value for the tip size and divide it by 2 for this arrow implementation\n  useLayoutEffect(() => {\n    if (arrowRef.current) {\n      let spectrumTipWidth = window\n        .getComputedStyle(arrowRef.current)\n        .getPropertyValue('--spectrum-popover-tip-size');\n      if (spectrumTipWidth !== '') {\n        setSize(parseInt(spectrumTipWidth, 10) / 2);\n      }\n\n      let spectrumBorderWidth = window\n        .getComputedStyle(arrowRef.current)\n        .getPropertyValue('--spectrum-popover-tip-borderWidth');\n      if (spectrumBorderWidth !== '') {\n        setBorderWidth(parseInt(spectrumBorderWidth, 10));\n      }\n    }\n  }, []);\n  return {size, borderWidth, arrowRef};\n}\n\nfunction Arrow(props: ArrowProps) {\n  let {primary, secondary, isLandscape, arrowProps, borderDiagonal, arrowRef} = props;\n  let halfBorderDiagonal = borderDiagonal / 2;\n\n  let primaryStart = 0;\n  let primaryEnd = primary - halfBorderDiagonal;\n\n  let secondaryStart = halfBorderDiagonal;\n  let secondaryMiddle = secondary / 2;\n  let secondaryEnd = secondary - halfBorderDiagonal;\n\n  let pathData = isLandscape\n    ? [\n        'M',\n        secondaryStart,\n        primaryStart,\n        'L',\n        secondaryMiddle,\n        primaryEnd,\n        'L',\n        secondaryEnd,\n        primaryStart\n      ]\n    : [\n        'M',\n        primaryStart,\n        secondaryStart,\n        'L',\n        primaryEnd,\n        secondaryMiddle,\n        'L',\n        primaryStart,\n        secondaryEnd\n      ];\n\n  /* use ceil because the svg needs to always accommodate the path inside it */\n  return (\n    <svg\n      xmlns=\"http://www.w3.org/svg/2000\"\n      width={Math.ceil(isLandscape ? secondary : primary)}\n      height={Math.ceil(isLandscape ? primary : secondary)}\n      className={classNames(styles, 'spectrum-Popover-tip')}\n      ref={arrowRef}\n      {...arrowProps}>\n      <path\n        className={classNames(styles, 'spectrum-Popover-tip-triangle')}\n        d={pathData.join(' ')}\n      />\n    </svg>\n  );\n}\n\n/**\n * More explanation on popover tips. - I tried changing the calculation of the popover placement in\n * an effort to get it squarely onto the pixel grid. This did not work because the problem was in\n * the svg partial pixel end of the path in the popover right and popover bottom. - I tried creating\n * an extra 'bandaid' path that matched the background color and would overlap the popover border.\n * This didn't work because the border on the svg triangle didn't extend all the way to match nicely\n * with the popover border. - I tried getting the client bounding box and setting the svg to that\n * partial pixel value This didn't work because again the issue was inside the svg - I didn't try\n * drawing the svg backwards This could still be tried - I tried changing the calculation of the\n * popover placement AND the svg height/width so that they were all rounded This seems to have done\n * the trick.\n */\n"],"names":[],"version":3,"file":"Popover.cjs.map"}