{"version":3,"file":"popover.mjs","names":[],"sources":["../../../../package/common/popover/popover.tsx"],"sourcesContent":["import { useRef, useEffect, useState, useCallback, type RefObject } from 'react';\nimport cx from 'classnames';\nimport BodyEnd from 'components/common/bodyEnd';\n\nimport styles from './popover.module.pcss';\nimport sheetStyles from '../styles/sheet.module.pcss';\nimport SheetBackdrop from '../sheetBackdrop';\nimport { usePopoverPosition } from './usePopoverPosition';\nimport { useFocusBoundary, tabbablesIn } from '../hooks/useFocusBoundary';\nimport { useSheet } from '../hooks/useSheet';\nimport { useOverlay } from '../hooks/useOverlay';\nimport { useComponentDefaults, usePresentationDefault } from '../configProvider';\nimport { markDismiss } from '../utils/dismissClick';\nimport { Presentation } from '../configProvider/presentation.types';\nimport { PopoverPlacement, PopoverAlign, PopoverTrigger, type PopoverProps } from './popover.types';\n\n/**\n * How long after its click an anchored popover still counts as opened by it: long enough for the\n * render the click causes, short enough that an old keypress does not decide a later open.\n */\nconst ACTIVATION_WINDOW_MS = 1000;\n\nfunction toReference(\n  anchor: HTMLElement | null | undefined,\n  triggerRef: RefObject<HTMLElement | null>,\n): RefObject<HTMLElement | null> {\n  return anchor ? { current: anchor } : triggerRef;\n}\n\nfunction Popover(props: PopoverProps) {\n  const {\n    children = null,\n    anchor,\n    content = null,\n    placement = PopoverPlacement.Bottom,\n    align = PopoverAlign.Center,\n    trigger = PopoverTrigger.Click,\n    isOpen,\n    defaultOpen = false,\n    onOpenChange = () => {},\n    offset = 10,\n    withArrow = true,\n    closeOnOutsideClick = true,\n    closeOnEscape = true,\n    openDelay = 100,\n    closeDelay = 120,\n    disabled = false,\n    focusOnOpen = 'keyboard',\n    closeOnTriggerClick = true,\n    width = 'auto',\n    constrainWidth = true,\n    presentation: presentationProp,\n    className,\n    style,\n    classNames,\n    styles: slotStyles,\n    ...rest\n  } = useComponentDefaults('Popover', props);\n  const triggerRef = useRef<HTMLDivElement>(null);\n  const floatingRef = useRef<HTMLDivElement>(null);\n  const panelRef = useRef<HTMLDivElement>(null);\n  const arrowRef = useRef<HTMLDivElement>(null);\n  const hoverTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n  // Set from a capture handler on the panel, which React fires for its whole\n  // React subtree — including children that portal elsewhere in the DOM, such as\n  // a Dropdown's list inside a DatePicker's calendar. A DOM `contains` check\n  // cannot see those, and without this the panel closes when one is used.\n  const panelInteractedRef = useRef(false);\n  // An outside click is a press that starts and ends outside while the panel is open. One that\n  // starts inside is a drag, such as selecting a field's text, and Chromium and WebKit send its\n  // `mouseup` to wherever it ends. One that started before the panel opened is the gesture that\n  // opened it, such as Calendar's drag to create, which opens an editor on `pointerup`.\n  const pressStartedOutsideRef = useRef(false);\n  // Whether the open that is running came from the keyboard, which is what the\n  // default `focusOnOpen` follows and what `onOpenChange` reports. A click raised\n  // by Enter or Space reports `detail === 0`, where a pointer press counts the\n  // clicks; an open with no trigger event at all, such as a panel that appears\n  // while the user types, leaves this false.\n  const openedByKeyboardRef = useRef(false);\n  // A nested portal sits outside the panel's DOM; this is how focus leaving one counts as leaving.\n  const lastPanelFocusRef = useRef<EventTarget | null>(null);\n  function markPanelInteraction() {\n    panelInteractedRef.current = true;\n  }\n  function markPanelFocus(event: React.FocusEvent) {\n    markPanelInteraction();\n    lastPanelFocusRef.current = event.target;\n  }\n\n  // What the panel is placed against, and where the focus goes back to. A new object exactly when\n  // `anchor` changes, which is what restarts the position tracking for the new element: state, not\n  // a memo, because a memo React chose to drop would restart it for no reason.\n  const [reference, setReference] = useState(() => ({ anchor, ref: toReference(anchor, triggerRef) }));\n  if (reference.anchor !== anchor) setReference({ anchor, ref: toReference(anchor, triggerRef) });\n  const referenceRef = reference.ref;\n\n  // An anchored popover is opened by its consumer through `isOpen`, so none of the key handling\n  // below sees how. The click that caused it does: Enter and Space raise one with `detail === 0`,\n  // the same test the trigger uses. Not `:focus-visible`, which a text field matches after a\n  // mouse click too, and which stays on a keyboard-focused button that is then clicked.\n  const activationRef = useRef<{ target: Node; keyboard: boolean; time: number } | null>(null);\n  const anchored = anchor !== undefined;\n  useEffect(() => {\n    if (!anchored) return;\n    function onClick(event: MouseEvent) {\n      activationRef.current = { target: event.target as Node, keyboard: event.detail === 0, time: performance.now() };\n    }\n    // Capturing, so it is recorded before the consumer's own handler opens the panel.\n    document.addEventListener('click', onClick, true);\n    return () => document.removeEventListener('click', onClick, true);\n  }, [anchored]);\n\n  const isControlled = isOpen !== undefined;\n  const [internalOpen, setInternalOpen] = useState(defaultOpen);\n  const open = isControlled ? isOpen : internalOpen;\n\n  // Keep the outside-click/Escape listeners pointed at the latest setter without re-subscribing.\n  const onOpenChangeRef = useRef(onOpenChange);\n  useEffect(() => {\n    onOpenChangeRef.current = onOpenChange;\n  });\n\n  const setOpen = useCallback(\n    (next: boolean, fromKeyboard = false) => {\n      if (disabled && next) return;\n      if (next) openedByKeyboardRef.current = fromKeyboard;\n      if (!isControlled) setInternalOpen(next);\n      onOpenChangeRef.current(next, { fromKeyboard });\n    },\n    [disabled, isControlled],\n  );\n\n  // Explicit prop → this component's global default → the app-wide one → anchored.\n  const appPresentation = usePresentationDefault();\n  const presentation = presentationProp ?? appPresentation ?? Presentation.Default;\n  const { isSheet: sheetPresentation, sheetStyle } = useSheet(presentation);\n  // Hover and focus are pointer affordances that open something small next to what caused them;\n  // a sheet is a deliberate, screen-owning open. Only a click asks for one.\n  const isSheet = sheetPresentation && trigger === PopoverTrigger.Click;\n\n  // Focus into the panel waits until it shows, since one that waits out a moving ancestor hidden\n  // takes none.\n  const shownRef = useRef(false);\n  const focusPendingRef = useRef(false);\n  function focusPanel() {\n    focusPendingRef.current = false;\n    const focusables = tabbablesIn(panelRef.current);\n    if (focusables.length === 0) return;\n    // Only claim the dialog role when we're actually managing focus for real content.\n    floatingRef.current?.setAttribute('role', 'dialog');\n    focusables[0].focus();\n  }\n\n  // A sheet isn't anchored to anything, so there's nothing to track, flip or clamp.\n  usePopoverPosition({\n    isOpen: !!open && !isSheet,\n    placement,\n    align,\n    offset,\n    triggerRef: referenceRef,\n    floatingRef,\n    panelRef,\n    arrowRef: withArrow ? arrowRef : { current: null },\n    matchTriggerWidth: width === 'trigger',\n    onShown: () => {\n      shownRef.current = true;\n      if (focusPendingRef.current) focusPanel();\n    },\n  });\n\n  // Registered for as long as it's open, not just as a sheet: this is what puts the popover on\n  // the overlay stack, so an enclosing Modal knows something sits above it and neither drags\n  // focus out of this (portaled, so outside the modal's panel) panel nor closes itself on the\n  // Escape meant for this. Focus isn't trapped: a Popover is deliberately non-modal, and it\n  // already moves focus into the panel on open by itself.\n  const { restoreFocusToTrigger, focusAfterTrigger } = useFocusBoundary({\n    triggerRef: referenceRef,\n    contentRef: floatingRef,\n  });\n  const restoreFocusRef = useRef(restoreFocusToTrigger);\n  useEffect(() => {\n    restoreFocusRef.current = restoreFocusToTrigger;\n  });\n\n  // Focus inside the panel returns to the trigger however it closes, as with `hidePopover()`. Read\n  // in a ref cleanup, while the panel is still in the DOM; moved in an effect, because StrictMode\n  // detaches a new panel's refs once more right after it took the focus.\n  const focusLeftWithPanelRef = useRef(false);\n  const floatingCallbackRef = useCallback((node: HTMLDivElement | null) => {\n    floatingRef.current = node;\n    focusLeftWithPanelRef.current = false;\n    if (!node) return;\n    return () => {\n      floatingRef.current = null;\n      const active = document.activeElement;\n      focusLeftWithPanelRef.current = !!active && (node.contains(active) || active === lastPanelFocusRef.current);\n    };\n  }, []);\n  useEffect(() => {\n    if (open || !focusLeftWithPanelRef.current) return;\n    focusLeftWithPanelRef.current = false;\n    const active = document.activeElement;\n    if (!active || active === document.body) restoreFocusRef.current();\n  }, [open]);\n\n  useOverlay({\n    isActive: !!open,\n    containerRef: panelRef,\n    onEscape: closeOnEscape\n      ? () => {\n          // Hand focus back to the trigger when it currently sits inside the panel.\n          if (floatingRef.current?.contains(document.activeElement)) restoreFocusToTrigger();\n          setOpen(false, true);\n        }\n      : undefined,\n    trapFocus: false,\n    lockScroll: isSheet,\n  });\n\n  // The panel is portaled to the end of the DOM, so Tab never flows into it naturally. When we\n  // manage focus (click trigger + focusable content), move focus in on open and, on Tab out of\n  // either end, close and continue focus as if the panel sat right after the trigger.\n  useEffect(() => {\n    if (!open) {\n      openedByKeyboardRef.current = false;\n      shownRef.current = false;\n      focusPendingRef.current = false;\n      return;\n    }\n    const activation = activationRef.current;\n    activationRef.current = null;\n    const anchorKeyed =\n      !!anchor &&\n      !!activation?.keyboard &&\n      anchor.contains(activation.target) &&\n      performance.now() - activation.time < ACTIVATION_WINDOW_MS;\n    const takeFocus =\n      focusOnOpen === true || (focusOnOpen === 'keyboard' && (openedByKeyboardRef.current || anchorKeyed));\n    if (!takeFocus || trigger !== PopoverTrigger.Click) return;\n    if (shownRef.current) focusPanel();\n    else focusPendingRef.current = true;\n  }, [open, trigger, focusOnOpen, anchor]);\n\n  function handleFloatingKeyDown(event: React.KeyboardEvent) {\n    if (event.key !== 'Tab' || trigger !== PopoverTrigger.Click) return;\n    const focusables = tabbablesIn(panelRef.current);\n    if (focusables.length === 0) return;\n    const active = document.activeElement;\n    if (!event.shiftKey && active === focusables[focusables.length - 1]) {\n      event.preventDefault();\n      focusAfterTrigger();\n      setOpen(false, true);\n    } else if (event.shiftKey && active === focusables[0]) {\n      event.preventDefault();\n      restoreFocusToTrigger();\n      setOpen(false, true);\n    }\n  }\n\n  // Outside click. Registered only while open and only for the relevant trigger mode; Escape is\n  // handled by `useOverlay` above, which scopes it to the innermost open layer.\n  useEffect(() => {\n    if (!open) return;\n    // Focus that landed in the panel before these listeners existed (ours on open, or content\n    // that focuses itself on mount) set the flag with nothing to clear it, and the first\n    // click outside was swallowed.\n    panelInteractedRef.current = false;\n    pressStartedOutsideRef.current = false;\n\n    function containsNode(node: Node) {\n      // Both trigger refs: with an anchor, `children` still toggle the panel, and a press on them is theirs.\n      return Boolean(\n        floatingRef.current?.contains(node) ||\n        triggerRef.current?.contains(node) ||\n        referenceRef.current?.contains(node),\n      );\n    }\n    function isInside(event: Event) {\n      // Read and clear: the flag describes this one event, and the panel's React\n      // handler has already run by the time this does.\n      const inPanelSubtree = panelInteractedRef.current;\n      panelInteractedRef.current = false;\n      return inPanelSubtree || containsNode(event.target as Node);\n    }\n    function onMouseDown(event: MouseEvent) {\n      pressStartedOutsideRef.current = !isInside(event);\n    }\n    function onMouseUp(event: MouseEvent) {\n      const pressStartedOutside = pressStartedOutsideRef.current;\n      pressStartedOutsideRef.current = false;\n      if (isInside(event) || !pressStartedOutside) return;\n      markDismiss();\n      setOpen(false);\n    }\n    // Keyboard counterpart to the outside click. Only focus that comes from inside closes it: code\n    // moving focus elsewhere (a Modal restoring it) must not, nor `null`, focus back from another tab.\n    function onFocusIn(event: FocusEvent) {\n      if (isInside(event)) return;\n      const from = event.relatedTarget as Node | null;\n      if (!from || (from !== lastPanelFocusRef.current && !containsNode(from))) return;\n      // A press on an outside field focuses it before its `mouseup`, and that is not the keyboard.\n      // It closes here, before the `mouseup` that would mark its click, so it marks it now.\n      const pressed = pressStartedOutsideRef.current;\n      if (pressed) markDismiss();\n      setOpen(false, !pressed);\n    }\n\n    if (closeOnOutsideClick && trigger !== PopoverTrigger.Hover) {\n      window.addEventListener('mousedown', onMouseDown);\n      window.addEventListener('mouseup', onMouseUp);\n      document.addEventListener('focusin', onFocusIn);\n    }\n    return () => {\n      window.removeEventListener('mousedown', onMouseDown);\n      window.removeEventListener('mouseup', onMouseUp);\n      document.removeEventListener('focusin', onFocusIn);\n    };\n  }, [open, closeOnOutsideClick, trigger, setOpen, referenceRef]);\n\n  useEffect(() => () => clearTimeout(hoverTimer.current), []);\n\n  function scheduleHover(next: boolean) {\n    clearTimeout(hoverTimer.current);\n    hoverTimer.current = setTimeout(() => setOpen(next), next ? openDelay : closeDelay);\n  }\n\n  // Opening from the keyboard without the trigger having to be a button that\n  // happens to toggle on Enter: the arrow keys are what the menu-button pattern\n  // asks for, and what a consumer reaches for first.\n  function handleTriggerKeyDown(event: React.KeyboardEvent) {\n    if (open || (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')) return;\n    event.preventDefault();\n    setOpen(true, true);\n  }\n\n  const triggerHandlers =\n    trigger === PopoverTrigger.Click\n      ? {\n          onClick: (event: React.MouseEvent) => {\n            // A field that opens a picker keeps it open when clicked again, so\n            // that placing the caret in the field does not close the panel.\n            if (open && !closeOnTriggerClick) return;\n            setOpen(!open, event.detail === 0);\n          },\n          onKeyDown: handleTriggerKeyDown,\n        }\n      : trigger === PopoverTrigger.Hover\n        ? { onMouseEnter: () => scheduleHover(true), onMouseLeave: () => scheduleHover(false) }\n        : { onFocus: () => setOpen(true), onBlur: () => setOpen(false) };\n\n  const floatingHoverHandlers =\n    trigger === PopoverTrigger.Hover\n      ? { onMouseEnter: () => scheduleHover(true), onMouseLeave: () => scheduleHover(false) }\n      : {};\n\n  return (\n    <div\n      {...rest}\n      className={cx(styles.popover, className, classNames?.root)}\n      style={{ ...style, ...slotStyles?.root }}\n    >\n      <div\n        ref={triggerRef}\n        className={cx(styles.popoverTrigger, classNames?.trigger)}\n        style={slotStyles?.trigger}\n        {...triggerHandlers}\n      >\n        {children}\n      </div>\n      {open && (\n        <BodyEnd>\n          {isSheet && (\n            <SheetBackdrop\n              onClose={() => {\n                if (closeOnOutsideClick) setOpen(false);\n              }}\n              className={classNames?.backdrop}\n              style={slotStyles?.backdrop}\n            />\n          )}\n          <div\n            ref={floatingCallbackRef}\n            className={cx(isSheet ? sheetStyles.sheet : styles.popoverFloating, classNames?.floating)}\n            style={{ ...(isSheet ? sheetStyle : undefined), ...slotStyles?.floating }}\n            data-placement={placement}\n            onKeyDown={handleFloatingKeyDown}\n            onMouseDownCapture={markPanelInteraction}\n            onMouseUpCapture={markPanelInteraction}\n            onFocusCapture={markPanelFocus}\n            {...floatingHoverHandlers}\n          >\n            <div\n              ref={panelRef}\n              className={cx(\n                styles.popoverPanel,\n                constrainWidth && styles.popoverPanelConstrained,\n                isSheet && sheetStyles.sheetPanel,\n                classNames?.panel,\n              )}\n              style={slotStyles?.panel}\n            >\n              {content}\n            </div>\n            {withArrow && !isSheet && (\n              <div ref={arrowRef} className={cx(styles.popoverArrow, classNames?.arrow)} style={slotStyles?.arrow} />\n            )}\n          </div>\n        </BodyEnd>\n      )}\n    </div>\n  );\n}\n\nexport default Popover;\n"],"mappings":"k8BAoBA,IAAM,GAAuB,IAE7B,SAAS,EACP,EACA,EAC+B,CAC/B,OAAO,EAAS,CAAE,QAAS,CAAO,EAAI,CACxC,CAEA,SAAS,EAAQ,EAAqB,CACpC,GAAM,CACJ,YAAW,KACX,SACA,WAAU,KACV,YAAY,GAAiB,OAC7B,SAAQ,GAAa,OACrB,UAAU,EAAe,MACzB,SACA,eAAc,GACd,mBAAqB,CAAC,EACtB,UAAS,GACT,YAAY,GACZ,sBAAsB,GACtB,iBAAgB,GAChB,aAAY,IACZ,cAAa,IACb,WAAW,GACX,cAAc,WACd,uBAAsB,GACtB,SAAQ,OACR,kBAAiB,GACjB,aAAc,GACd,aACA,SACA,aACA,OAAQ,EACR,GAAG,IACD,EAAqB,UAAW,CAAK,EACnC,EAAa,EAAuB,IAAI,EACxC,EAAc,EAAuB,IAAI,EACzC,EAAW,EAAuB,IAAI,EACtC,EAAW,EAAuB,IAAI,EACtC,EAAa,EAAkD,IAAA,EAAS,EAKxE,EAAqB,EAAO,EAAK,EAKjC,EAAyB,EAAO,EAAK,EAMrC,EAAsB,EAAO,EAAK,EAElC,EAAoB,EAA2B,IAAI,EACzD,SAAS,GAAuB,CAC9B,EAAmB,QAAU,EAC/B,CACA,SAAS,GAAe,EAAyB,CAC/C,EAAqB,EACrB,EAAkB,QAAU,EAAM,MACpC,CAKA,GAAM,CAAC,EAAW,IAAgB,OAAgB,CAAE,SAAQ,IAAK,EAAY,EAAQ,CAAU,CAAE,EAAE,EAC/F,EAAU,SAAW,GAAQ,GAAa,CAAE,SAAQ,IAAK,EAAY,EAAQ,CAAU,CAAE,CAAC,EAC9F,IAAM,EAAe,EAAU,IAMzB,EAAgB,EAAiE,IAAI,EACrF,EAAW,IAAW,IAAA,GAC5B,MAAgB,CACd,GAAI,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