@sanity/ui 4.4.1 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","names":["(nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }","useCallback((nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }, [])","() => {\n return () => {\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n }\n }\n }","[]","[state, onStateChange]","_c","getTransformOrigin(originX, originY)","{\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }","animate ? 'transform' : undefined","useMemo(\n () => ({\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, style],\n )","{\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }","arrowX !== null ? arrowX : undefined","arrowY !== null ? arrowY : undefined","useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )","clsx(tooltipCard, className)","arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )","<MotionCard\n className={clsx(tooltipCard, className)}\n data-ui=\"Tooltip__card\"\n {...restProps}\n data-placement={placement}\n padding={padding}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n style={rootStyle}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n {children}\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )}\n </MotionCard>","animate ? POPOVER_MOTION_PROPS : undefined","_c","_animate = false","arrowProp = false","placementProp = 'bottom'","padding = 2","radius = 2","shadow = 2","_getArrayProp(fallbackPlacementsProp)","() => ref.current","resolvePortalElement(portal, portalName)","{\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n portalElement,\n rootBoundary,\n }","{reference: referenceElement}","{\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: {reference: referenceElement},\n }","() => update()","() => {\n if (boundaryElement || portalElement) reposition()\n }","[boundaryElement, portalElement]","delayGroupContext || {}","(open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n }","useCallback(\n (open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n },\n [\n isInsideGroup,\n openDelay,\n setIsGroupActive,\n setOpenTooltipId,\n tooltipId,\n closeDelay,\n setIsOpen,\n ],\n )","(e: FocusEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onBlur?.(e)\n }","props","useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onBlur?.(e)\n },\n [childProp?.props, handleIsOpenChange, suppressed],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n }","e","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n }","useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onMouseLeave?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onMouseLeave?.(e)\n },\n [childProp?.props, handleIsOpenChange, suppressed],\n )","{handleIsOpenChange, referenceElement, showTooltip, isInsideGroup}","() => handleIsOpenChange(false, true)","() => {\n // If the user clicks on escape key, close the tooltip.\n if (!showTooltip) return\n\n function handleWindowKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n onWindowEscape()\n }\n }\n\n window.addEventListener('keydown', handleWindowKeyDown)\n\n // oxlint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('keydown', handleWindowKeyDown)\n }\n }","[showTooltip]","(arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n }","useCallback(\n (arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n },\n [update],\n )","(node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n }","useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n },\n [refs],\n )","useMemo(() => {\n if (!childProp) return null\n\n return cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })\n }, [\n childProp,\n handleBlur,\n handleClick,\n handleContextMenu,\n handleFocus,\n handleMouseEnter,\n handleMouseLeave,\n ])","cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })","childProp ? getElementRef(childProp) : null","() => referenceElement","[\n referenceElement,\n ]","<></>","<TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>","<Layer\n data-ui=\"Tooltip\"\n {...restProps}\n className={clsx(tooltipLayer, restProps.className)}\n ref={setFloating}\n style={floatingStyles}\n zOffset={zOffset}\n >\n <TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>\n </Layer>","Layer","clsx(tooltipLayer, restProps.className)","\"Tooltip\"","portalProp ? <Portal __unstable_name={portalName}>{tooltip}</Portal> : tooltip","animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )","<>\n {/* the tooltip */}\n {disabled ? null : tooltipActivity}\n\n {/* the referred element */}\n {child}\n </>","disabled ? null : tooltipActivity","() => {\n ref.current = value\n }","[value]","{\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n portalElement,\n rootBoundary,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n boundaryElement: HTMLElement | null\n fallbackPlacements: Placement[]\n portalElement: HTMLElement | null\n rootBoundary: RootBoundary\n}","flip(\n withBoundary(boundaryRef, {\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n )","offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE})","shift(withBoundary(boundaryRef, {rootBoundary, padding: DEFAULT_TOOLTIP_PADDING}))","sizeMiddleware({boundaryRef, portalRef, rootBoundary})","arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING})","useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n ret.push(\n flip(\n withBoundary(boundaryRef, {\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n ),\n )\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))\n\n // Shift the tooltip so its sits with the boundary element\n ret.push(shift(withBoundary(boundaryRef, {rootBoundary, padding: DEFAULT_TOOLTIP_PADDING})))\n\n // Cap the tooltip width to the boundary, viewport and portal\n ret.push(sizeMiddleware({boundaryRef, portalRef, rootBoundary}))\n\n // Place arrow\n if (arrowProp) {\n ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))\n }\n\n // Determine the origin to scale from.\n // Must be placed after `size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n return ret\n }, [animate, arrowProp, arrowRef, boundaryRef, fallbackPlacements, portalRef, rootBoundary])","{\n handleIsOpenChange,\n referenceElement,\n showTooltip,\n isInsideGroup,\n}: {\n handleIsOpenChange: (open: boolean, immediate?: boolean) => void\n referenceElement: HTMLElement | null\n showTooltip: boolean\n isInsideGroup: boolean\n}","(target: EventTarget | null, teardown: () => void) => {\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === target || (target instanceof Node && referenceElement.contains(target))\n\n if (!isHoveringReference) {\n handleIsOpenChange(false)\n // Allow removing the event listener eagerly, to avoid race conditions\n teardown()\n }\n }","() => {\n if (!showTooltip || isInsideGroup) return\n\n const handleMouseMove = (event: MouseEvent) => {\n onMouseMove(event.target, () => window.removeEventListener('mousemove', handleMouseMove))\n }\n\n window.addEventListener('mousemove', handleMouseMove)\n\n // oxlint-disable-next-line consistent-return\n return () => window.removeEventListener('mousemove', handleMouseMove)\n }","[isInsideGroup, showTooltip]","_c","_Fragment","tooltipActivity","{\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }","isGroupActive ? 1 : openDelay","useMemo(\n () => ({\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }),\n [closeDelay, isGroupActive, openDelay, openTooltipId, setIsGroupActive, setOpenTooltipId],\n )","<TooltipDelayGroupContext.Provider value={value}>{children}</TooltipDelayGroupContext.Provider>","TooltipDelayGroupContext.Provider","_c","\"top\"","\"bottom\"","\"left\"","\"right\""],"sources":["../src/core/hooks/useDelayedState.ts","../src/core/primitives/tooltip/constants.ts","../src/core/primitives/tooltip/tooltip.css.ts","../src/core/primitives/tooltip/tooltipCard.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts","../src/core/primitives/tooltip/tooltip.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx"],"sourcesContent":["import {SetStateAction, useCallback, useEffect, useRef, useState} from 'react'\n\n/**\n * @beta\n */\nexport function useDelayedState<S>(\n initialState: S | (() => S),\n): [S, (nextState: SetStateAction<S>, delay?: number) => void] {\n const [state, setState] = useState(initialState)\n const delayedAction = useRef<NodeJS.Timeout | undefined>(undefined)\n\n const onStateChange = useCallback((nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }, [])\n\n useEffect(() => {\n return () => {\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n }\n }\n }, [])\n\n return [state, onStateChange]\n}\n","import {Placement} from '@floating-ui/react-dom'\n\nexport const DEFAULT_TOOLTIP_ARROW_WIDTH = 15\nexport const DEFAULT_TOOLTIP_ARROW_HEIGHT = 6\nexport const DEFAULT_TOOLTIP_ARROW_RADIUS = 2\n\nexport const DEFAULT_TOOLTIP_DISTANCE = 4\nexport const DEFAULT_TOOLTIP_PADDING = 4\n\nexport const DEFAULT_FALLBACK_PLACEMENTS: Record<Placement, Placement[]> = {\n 'top': ['top-end', 'top-start', 'bottom', 'left', 'right'],\n 'top-start': ['top', 'top-end', 'bottom-start', 'left-start', 'right-start'],\n 'top-end': ['top', 'top-start', 'bottom-end', 'left-end', 'right-end'],\n 'bottom': ['bottom-end', 'bottom-start', 'top', 'left', 'right'],\n 'bottom-start': ['bottom', 'bottom-end', 'top-start', 'left-start', 'right-start'],\n 'bottom-end': ['bottom', 'bottom-start', 'top-end', 'left-end', 'right-end'],\n 'left': ['left-end', 'left-start', 'right', 'top', 'bottom'],\n 'left-start': ['left', 'left-end', 'right-start', 'top-start', 'bottom-start'],\n 'left-end': ['left', 'left-start', 'right-end', 'top-end', 'bottom-end'],\n 'right': ['right-end', 'right-start', 'left', 'top', 'bottom'],\n 'right-start': ['right', 'right-end', 'left-start', 'top-start', 'bottom-start'],\n 'right-end': ['right', 'right-start', 'left-end', 'top-end', 'bottom-end'],\n}\n","import {style} from '@vanilla-extract/css'\n\nexport const tooltipLayer = style({\n pointerEvents: 'none',\n})\n\nexport const tooltipCard = style({\n willChange: 'transform',\n})\n","import {clsx} from 'clsx/lite'\nimport {motion} from 'motion/react'\nimport React, {CSSProperties, useMemo} from 'react'\n\nimport {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {POPOVER_MOTION_PROPS} from '../../constants'\nimport {getTransformOrigin} from '../../middleware/origin'\nimport {Placement} from '../../types/placement'\nimport {Radius} from '../../types/radius'\nimport {Arrow} from '../../utils/arrow/arrow'\nimport {Card} from '../card/card'\nimport {\n DEFAULT_TOOLTIP_ARROW_HEIGHT,\n DEFAULT_TOOLTIP_ARROW_RADIUS,\n DEFAULT_TOOLTIP_ARROW_WIDTH,\n} from './constants'\n\nimport {tooltipCard} from './tooltip.css'\n\nconst MotionCard = motion.create(Card)\n\n/**\n * @internal\n */\nexport function TooltipCard(\n props: {\n animate?: boolean\n arrow: boolean\n arrowRef: React.Ref<HTMLDivElement>\n arrowX?: number\n arrowY?: number\n originX?: number\n originY?: number\n padding?: number | number[]\n placement?: Placement\n radius?: Radius | Radius[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n } & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,\n) {\n const {\n animate,\n arrow,\n arrowRef,\n arrowX,\n arrowY,\n children,\n className,\n originX,\n originY,\n padding,\n placement,\n radius,\n ref,\n scheme,\n shadow,\n style,\n ...restProps\n } = props\n\n const rootStyle: CSSProperties = useMemo(\n () => ({\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, style],\n )\n\n const arrowStyle: CSSProperties = useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )\n\n return (\n <MotionCard\n className={clsx(tooltipCard, className)}\n data-ui=\"Tooltip__card\"\n {...restProps}\n data-placement={placement}\n padding={padding}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n style={rootStyle}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n {children}\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )}\n </MotionCard>\n )\n}\n","import {createGlobalScopedContext} from '../../../lib/createGlobalScopedContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @beta\n */\nexport const TooltipDelayGroupContext =\n createGlobalScopedContext<TooltipDelayGroupContextValue | null>(\n '@sanity/ui/context/tooltipDelayGroup',\n null,\n )\n","import {useContext} from 'react'\n\nimport {TooltipDelayGroupContext} from './tooltipDelayGroupContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @beta\n */\nexport function useTooltipDelayGroup(): TooltipDelayGroupContextValue | null {\n const value = useContext(TooltipDelayGroupContext)\n\n return value\n}\n","import {\n arrow,\n autoUpdate,\n detectOverflow,\n flip,\n type Middleware,\n offset,\n type RootBoundary,\n shift,\n size,\n useFloating,\n} from '@floating-ui/react-dom'\nimport {clsx} from 'clsx/lite'\nimport {\n Activity,\n cloneElement,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useInsertionEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once\n// https://github.com/facebook/react/issues/34818 is fixed in the lowest React\n// version we support: on React 19.2 the native hook never sees values past\n// the first render when the calling component is wrapped in `forwardRef` or\n// `memo`, and consumers may wrap `Tooltip` in `memo`.\nimport {useEffectEvent} from 'use-effect-event'\n\nimport type {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {useDelayedState} from '../../hooks/useDelayedState'\nimport {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'\nimport {origin} from '../../middleware/origin'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {useTheme_v2} from '../../theme/useTheme'\nimport type {Placement} from '../../types/placement'\nimport {AnimateActivity} from '../../utils/animateActivity'\nimport {useBoundaryElement} from '../../utils/boundaryElement/useBoundaryElement'\nimport {getElementRef} from '../../utils/getElementRef'\nimport {Layer, type LayerProps} from '../../utils/layer/layer'\nimport {Portal} from '../../utils/portal/portal'\nimport {resolvePortalElement} from '../../utils/portal/resolvePortalElement'\nimport {usePortal} from '../../utils/portal/usePortal'\nimport type {Delay} from '../types'\nimport {\n DEFAULT_FALLBACK_PLACEMENTS,\n DEFAULT_TOOLTIP_DISTANCE,\n DEFAULT_TOOLTIP_PADDING,\n} from './constants'\nimport {TooltipCard} from './tooltipCard'\nimport {useTooltipDelayGroup} from './tooltipDelayGroup/useTooltipDelayGroup'\n\nimport {tooltipLayer} from './tooltip.css'\n\n/**\n * @public\n */\nexport interface TooltipProps extends Omit<LayerProps, 'as'> {\n /** @deprecated Use `fallbackPlacements` instead. */\n allowedAutoPlacements?: never\n arrow?: boolean\n boundaryElement?: HTMLElement | null\n children?: React.JSX.Element\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n padding?: number | number[]\n placement?: Placement\n /** Whether or not to render the tooltip in a portal element. */\n portal?: boolean | string\n radius?: number | number[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n /**\n * Adds a delay to open or close the tooltip.\n *\n * If only a `number` is passed, it will be used for both opening and closing.\n *\n * If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.\n *\n * @public\n * @defaultValue 0\n */\n delay?: Delay\n /**\n * Whether the tooltip should animate in and out.\n *\n * @beta\n * @defaultValue false\n */\n animate?: boolean\n}\n\n/**\n * Tooltips display information when hovering, focusing or tapping.\n *\n * @public\n */\nexport function Tooltip(\n props: TooltipProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content'>,\n) {\n const boundaryElementContext = useBoundaryElement()\n const {layer} = useTheme_v2()\n const {\n animate: _animate = false,\n arrow: arrowProp = false,\n boundaryElement: _boundaryElement,\n children: childProp,\n content,\n disabled,\n fallbackPlacements: _fallbackPlacementsProp,\n padding = 2,\n placement: placementProp = 'bottom',\n portal: portalProp,\n radius = 2,\n ref: forwardedRef,\n scheme,\n shadow = 2,\n zOffset: _zOffset,\n delay,\n ...restProps\n } = props\n const boundaryElement = _boundaryElement ?? boundaryElementContext?.element\n const fallbackPlacementsProp =\n _fallbackPlacementsProp ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom']\n const zOffset = _zOffset ?? layer.tooltip.zOffset\n const prefersReducedMotion = usePrefersReducedMotion()\n const animate = prefersReducedMotion ? false : _animate\n const fallbackPlacements = _getArrayProp(fallbackPlacementsProp)\n const ref = useRef<HTMLDivElement | null>(null)\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)\n const arrowRef = useRef<HTMLDivElement | null>(null)\n const rootBoundary: RootBoundary = 'viewport'\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)\n\n const portal = usePortal()\n const portalName = typeof portalProp === 'string' ? portalProp : undefined\n // Resolved the way `Portal` resolves it (a missing named portal falls back to the default one),\n // so the width cap applies to the element the tooltip actually renders into\n const portalElement = resolvePortalElement(portal, portalName)\n\n const middleware = useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n portalElement,\n rootBoundary,\n })\n\n const {floatingStyles, placement, middlewareData, refs, update} = useFloating({\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: {reference: referenceElement},\n })\n\n // The middleware reads the boundary and portal elements through refs (see `useMiddleware`), so\n // a change of either does not reach Floating UI by itself: reposition a shown tooltip against\n // the new element here, without tearing `autoUpdate` down. `update` is a no-op while the tooltip\n // is closed, as there is no floating element then. The body references the elements so that\n // the dependencies the React Compiler and the linter infer from it are the authored ones; with\n // neither element there is no tooltip DOM to reposition (`Portal` renders nothing).\n const reposition = useEffectEvent(() => update())\n\n useLayoutEffect(() => {\n if (boundaryElement || portalElement) reposition()\n }, [boundaryElement, portalElement])\n\n const arrowX = middlewareData.arrow?.x\n const arrowY = middlewareData.arrow?.y\n\n const originX = middlewareData['@sanity/ui/origin']?.originX\n const originY = middlewareData['@sanity/ui/origin']?.originY\n\n const tooltipId = useId()\n const [isOpen, setIsOpen] = useDelayedState(false)\n const delayGroupContext = useTooltipDelayGroup()\n const {setIsGroupActive, setOpenTooltipId} = delayGroupContext || {}\n // Derived, not synced: `disabled` and an empty `content` suppress the tooltip in the same render\n // that changes them, instead of an effect closing it one commit later. The hover state\n // (`isOpen`, or the group pointing at this tooltip) is kept as it is, so a tooltip that is\n // re-enabled or given content while its child is still hovered shows right away.\n const suppressed = disabled || !content\n const showTooltip = !suppressed && (isOpen || delayGroupContext?.openTooltipId === tooltipId)\n\n const isInsideGroup = delayGroupContext !== null\n const openDelayProp = typeof delay === 'number' ? delay : delay?.open || 0\n const closeDelayProp = typeof delay === 'number' ? delay : delay?.close || 0\n\n const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp\n const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp\n\n const handleIsOpenChange = useCallback(\n (open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n },\n [\n isInsideGroup,\n openDelay,\n setIsGroupActive,\n setOpenTooltipId,\n tooltipId,\n closeDelay,\n setIsOpen,\n ],\n )\n\n // `isOpen` is delayed visibility, not the current hover state: after the pointer or focus\n // leaves, it stays true for the close delay. While the tooltip is suppressed it must not linger\n // like that, or re-enabling it (or giving it content) before the delay has elapsed would show it\n // under a pointer that has already left. Leaving a suppressed tooltip closes it immediately.\n const handleBlur = useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onBlur?.(e)\n },\n [childProp?.props, handleIsOpenChange, suppressed],\n )\n const handleClick = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleContextMenu = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleFocus = useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleMouseEnter = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleMouseLeave = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onMouseLeave?.(e)\n },\n [childProp?.props, handleIsOpenChange, suppressed],\n )\n\n // Handle closing the tooltip when the mouse leaves the referenceElement\n useCloseOnMouseLeave({handleIsOpenChange, referenceElement, showTooltip, isInsideGroup})\n\n const onWindowEscape = useEffectEvent(() => handleIsOpenChange(false, true))\n\n useEffect(() => {\n // If the user clicks on escape key, close the tooltip.\n if (!showTooltip) return\n\n function handleWindowKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n onWindowEscape()\n }\n }\n\n window.addEventListener('keydown', handleWindowKeyDown)\n\n // oxlint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('keydown', handleWindowKeyDown)\n }\n }, [showTooltip])\n\n const setArrow = useCallback(\n (arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n },\n [update],\n )\n\n const setFloating = useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n },\n [refs],\n )\n\n const child = useMemo(() => {\n if (!childProp) return null\n\n return cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })\n }, [\n childProp,\n handleBlur,\n handleClick,\n handleContextMenu,\n handleFocus,\n handleMouseEnter,\n handleMouseLeave,\n ])\n\n // If there's a child then we need to set the reference element to the cloned child ref\n // and if child changes we make sure to update or remove the reference element.\n useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [\n referenceElement,\n ])\n\n if (!child) return <></>\n\n const tooltip = (\n <Layer\n data-ui=\"Tooltip\"\n {...restProps}\n className={clsx(tooltipLayer, restProps.className)}\n ref={setFloating}\n style={floatingStyles}\n zOffset={zOffset}\n >\n <TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>\n </Layer>\n )\n\n const tooltipNode = portalProp ? <Portal __unstable_name={portalName}>{tooltip}</Portal> : tooltip\n\n const tooltipActivity = animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )\n\n // The fragment has the same shape whether or not the tooltip is disabled, so the referred\n // element keeps its fiber (DOM node, state, focus) when `disabled` toggles. Returning the bare\n // child while disabled would change the tree shape and remount it. While disabled the tooltip\n // slot is left empty: no hidden tooltip DOM is rendered.\n return (\n <>\n {/* the tooltip */}\n {disabled ? null : tooltipActivity}\n\n {/* the referred element */}\n {child}\n </>\n )\n}\n\n/**\n * A ref that always holds the latest `value`, updated before any layout effect of the same commit\n * runs (the same mechanism `use-effect-event` uses), for callbacks that run outside render.\n */\nfunction useLatestRef<T>(value: T): React.RefObject<T> {\n const ref = useRef(value)\n\n useInsertionEffect(() => {\n ref.current = value\n }, [value])\n\n return ref\n}\n\ntype ElementRef = React.RefObject<HTMLElement | null>\n\n/**\n * Derivable middleware options that read the boundary element from a ref. Floating UI evaluates\n * them inside `computePosition`, which is when the ref is read — never during render.\n *\n * Built at module scope, like `sizeMiddleware` below: a `ref.current` read inside a callback\n * created during render makes the React Compiler skip the calling function, since it cannot tell\n * when the callback runs.\n */\nfunction withBoundary<Options extends object>(\n boundaryRef: ElementRef,\n options: Options,\n): () => Options & {boundary: HTMLElement | undefined} {\n return () => ({...options, boundary: boundaryRef.current || undefined})\n}\n\n/**\n * Caps the tooltip width to the room it is positioned in: the boundary element (or the clipping\n * ancestors when there is none), always within the viewport, and the portal element's width.\n * Floating UI measures inside its own positioning pass — only while the tooltip is shown, never\n * during render or on mount — and the width is written straight to the element, so no state or\n * layout effect is involved. Placed after `shift` so `availableWidth` is the full clipping width\n * for top and bottom placements; for left and right placements it is the room on that side.\n */\nfunction sizeMiddleware({\n boundaryRef,\n portalRef,\n rootBoundary,\n}: {\n boundaryRef: ElementRef\n portalRef: ElementRef\n rootBoundary: RootBoundary\n}): Middleware {\n return size(() => ({\n boundary: boundaryRef.current || undefined,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n async apply(state) {\n const {availableWidth, elements} = state\n const portalElement = portalRef.current\n let maxWidth = availableWidth\n\n // A tooltip rendered in a portal is capped to the portal's width as well, which may be\n // narrower than the boundary (see the CustomPortal story). The portal is measured on its\n // own rather than as part of `boundary`: an element array is the intersection of the rects,\n // and the portal need not overlap the boundary at all. A portal without a width — an empty\n // mount point — imposes no cap, as before.\n if (portalElement) {\n const overflow = await detectOverflow(state, {\n boundary: portalElement,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n })\n // The portal's clipping width minus the padding on both sides, wherever the tooltip is\n const portalWidth = state.rects.floating.width - overflow.left - overflow.right\n\n if (portalWidth > 0) maxWidth = Math.min(maxWidth, portalWidth)\n }\n\n // No room on the chosen side gives a negative width: the cap is clamped to zero rather than\n // removed, so the tooltip never grows across the boundary.\n elements.floating.style.maxWidth = `${Math.max(0, maxWidth)}px`\n },\n }))\n}\n\nfunction useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n portalElement,\n rootBoundary,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n boundaryElement: HTMLElement | null\n fallbackPlacements: Placement[]\n portalElement: HTMLElement | null\n rootBoundary: RootBoundary\n}) {\n // The elements are read through refs when Floating UI runs the middleware — inside\n // `computePosition`, never during render — so the middleware array keeps its identity when an\n // element changes, and with it Floating UI's `update` callback and `autoUpdate` subscription.\n // Passing the elements as option values would make `useFloating` deep-compare them on every\n // render (it has no DOM element case: two elements are equal unless their own enumerable\n // properties differ, which for React-rendered elements means walking their fibers), and an\n // element captured by a closure such as `apply` would never be noticed at all, since functions\n // are compared by source. The component repositions a shown tooltip itself when an element\n // changes (see `useLayoutEffect` in `Tooltip`).\n const boundaryRef = useLatestRef(boundaryElement)\n const portalRef = useLatestRef(portalElement)\n\n return useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n ret.push(\n flip(\n withBoundary(boundaryRef, {\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n ),\n )\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))\n\n // Shift the tooltip so its sits with the boundary element\n ret.push(shift(withBoundary(boundaryRef, {rootBoundary, padding: DEFAULT_TOOLTIP_PADDING})))\n\n // Cap the tooltip width to the boundary, viewport and portal\n ret.push(sizeMiddleware({boundaryRef, portalRef, rootBoundary}))\n\n // Place arrow\n if (arrowProp) {\n ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))\n }\n\n // Determine the origin to scale from.\n // Must be placed after `size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n return ret\n }, [animate, arrowProp, arrowRef, boundaryRef, fallbackPlacements, portalRef, rootBoundary])\n}\n\n/**\n * As `useEffectEvent` should never be passed to other components or hooks, this custom hook groups together the `useEffectEvent` and the `useEffect` hook using it.\n * @see https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events:~:text=Never%20pass%20them%20to%20other%20components%20or%20Hooks\n */\nfunction useCloseOnMouseLeave({\n handleIsOpenChange,\n referenceElement,\n showTooltip,\n isInsideGroup,\n}: {\n handleIsOpenChange: (open: boolean, immediate?: boolean) => void\n referenceElement: HTMLElement | null\n showTooltip: boolean\n isInsideGroup: boolean\n}) {\n // Since we don't want the `mouseevent` events to be attached and removed if the `referenceElement` is changed\n // we use a \"effect event\" (https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events)\n // in order to always see the latest `referenceElement` value inside the event handler itself.\n const onMouseMove = useEffectEvent((target: EventTarget | null, teardown: () => void) => {\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === target || (target instanceof Node && referenceElement.contains(target))\n\n if (!isHoveringReference) {\n handleIsOpenChange(false)\n // Allow removing the event listener eagerly, to avoid race conditions\n teardown()\n }\n })\n\n // Detect whether the mouse is moving outside of the reference element. This is sometimes\n // necessary, because the tooltip might not always close as it should (e.g. when clicking\n // the reference element triggers a CPU-heavy operation.)\n useEffect(() => {\n if (!showTooltip || isInsideGroup) return\n\n const handleMouseMove = (event: MouseEvent) => {\n onMouseMove(event.target, () => window.removeEventListener('mousemove', handleMouseMove))\n }\n\n window.addEventListener('mousemove', handleMouseMove)\n\n // oxlint-disable-next-line consistent-return\n return () => window.removeEventListener('mousemove', handleMouseMove)\n }, [isInsideGroup, showTooltip])\n}\n","import {useMemo} from 'react'\n\nimport {useDelayedState} from '../../../hooks/useDelayedState'\nimport {Delay} from '../../types'\nimport {TooltipDelayGroupContext} from './tooltipDelayGroupContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @public\n * */\nexport interface TooltipDelayGroupProviderProps {\n children?: React.ReactNode\n /**\n * Handles the delays to open or close a tooltip inside a group\n *\n * If only a `number` is passed, it will be used for both opening and closing.\n *\n * If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.\n *\n * @public\n */\n delay: Delay\n}\n\n/**\n * @public\n * Provides context for a group of tooltip elements that should share a delay\n * which temporarily becomes 1 ms after the first floating element of the group opens.\n */\nexport function TooltipDelayGroupProvider(\n props: TooltipDelayGroupProviderProps,\n): React.JSX.Element {\n const {children, delay} = props\n const [isGroupActive, setIsGroupActive] = useDelayedState(false)\n const [openTooltipId, setOpenTooltipId] = useDelayedState<string | null>(null)\n\n const openDelay = typeof delay === 'number' ? delay : delay?.open || 0\n const closeDelay = typeof delay === 'number' ? delay : delay?.close || 0\n\n const value: TooltipDelayGroupContextValue = useMemo(\n () => ({\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }),\n [closeDelay, isGroupActive, openDelay, openTooltipId, setIsGroupActive, setOpenTooltipId],\n )\n\n return (\n <TooltipDelayGroupContext.Provider value={value}>{children}</TooltipDelayGroupContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAgB,gBACd,cAC6D;eACvD,CAAC,OAAO,YAAY,SAAS,YAAY,GACzC,gBAAgB,OAAmC,KAAA,CAAS,GAEhCA;qDAAC,MAAA,WAA8B,UAAmB;EAClF,IAAM,eAAe;GACnB,SAAS,SAAS;EACpB;EAQA,IALA,AAEE,cAAc,aADd,aAAa,cAAc,OAAO,GACV,KAAA,IAGtB,CAAC,OAAO,OAAO,OAAO;EAC1B,cAAc,UAAU,WAAW,QAAQ,KAAK;CAClD;C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EAAA,OADG,oBAAA,EAAA,OAEA,oBAAA,EAAA,OAEPC,MALN,KAAA;EACa;EACH;EACG;EAElB,WAAWA;EACC;CACd,GADc,EAAA,KAAA,YAJG,EAAA,KAAA,eADG,EAAA,KAAA,kBAEA,EAAA,KAAA,kBAEPA,EAAAA,KAAAA;CANf,IAAM,QAAuCC,IAa3CC;CADF,OACoD,EAAA,OAAA,YAAA,EAAA,OAAR,SAA1C,KAAA,oBAACC,yBAAAA,UAAD;EAA0C;EAAQ;CAA4C,CAAA,GAA5C,EAAA,KAAA,UAAR,EAAA,KAAA,+BAA1CD;AAEJ"}
1
+ {"version":3,"file":"tooltip.js","names":["(nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }","useCallback((nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }, [])","() => {\n return () => {\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n }\n }\n }","[]","[state, onStateChange]","_c","getTransformOrigin(originX, originY)","{\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }","animate ? 'transform' : undefined","useMemo(\n () => ({\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, style],\n )","{\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }","arrowX !== null ? arrowX : undefined","arrowY !== null ? arrowY : undefined","useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )","clsx(tooltipCard, className)","arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )","<MotionCard\n className={clsx(tooltipCard, className)}\n data-ui=\"Tooltip__card\"\n {...restProps}\n data-placement={placement}\n padding={padding}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n style={rootStyle}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n {children}\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )}\n </MotionCard>","animate ? POPOVER_MOTION_PROPS : undefined","_c","_animate = false","arrowProp = false","placementProp = 'bottom'","padding = 2","radius = 2","shadow = 2","_getArrayProp(fallbackPlacementsProp)","() => ref.current","resolvePortalElement(portal, portalName)","{\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n portalElement,\n rootBoundary,\n }","{\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n }","childProp ? getElementRef<HTMLElement>(childProp) : undefined","() => update()","() => {\n if (boundaryElement || portalElement) reposition()\n }","[boundaryElement, portalElement]","delayGroupContext || {}","(open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n }","useCallback(\n (open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n },\n [\n isInsideGroup,\n openDelay,\n setIsGroupActive,\n setOpenTooltipId,\n tooltipId,\n closeDelay,\n setIsOpen,\n ],\n )","(e: FocusEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onBlur?.(e)\n }","props","useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onBlur?.(e)\n },\n [childProp?.props, handleIsOpenChange, suppressed],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n }","e","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n }","useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onMouseLeave?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onMouseLeave?.(e)\n },\n [childProp?.props, handleIsOpenChange, suppressed],\n )","{handleIsOpenChange, referenceRef, showTooltip, isInsideGroup}","() => handleIsOpenChange(false, true)","() => {\n // If the user clicks on escape key, close the tooltip.\n if (!showTooltip) return\n\n function handleWindowKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n onWindowEscape()\n }\n }\n\n window.addEventListener('keydown', handleWindowKeyDown)\n\n // oxlint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('keydown', handleWindowKeyDown)\n }\n }","[showTooltip]","(arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n }","useCallback(\n (arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n },\n [update],\n )","(node: HTMLDivElement | null) => {\n ref.current = node\n if (node) handOverReference()\n refs.setFloating(node)\n }","useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n if (node) handOverReference()\n refs.setFloating(node)\n },\n [handOverReference, refs],\n )","useMemo(() => {\n if (!childProp) return null\n\n return cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReference,\n })\n }, [\n childProp,\n handleBlur,\n handleClick,\n handleContextMenu,\n handleFocus,\n handleMouseEnter,\n handleMouseLeave,\n setReference,\n ])","cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReference,\n })","<></>","<TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>","<Layer\n data-ui=\"Tooltip\"\n {...restProps}\n className={clsx(tooltipLayer, restProps.className)}\n ref={setFloating}\n style={floatingStyles}\n zOffset={zOffset}\n >\n <TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>\n </Layer>","Layer","clsx(tooltipLayer, restProps.className)","\"Tooltip\"","portalProp ? <Portal __unstable_name={portalName}>{tooltip}</Portal> : tooltip","animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )","<>\n {/* the tooltip */}\n {disabled ? null : tooltipActivity}\n\n {/* the referred element */}\n {child}\n </>","disabled ? null : tooltipActivity","{\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n portalElement,\n rootBoundary,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n boundaryElement: HTMLElement | null\n fallbackPlacements: Placement[]\n portalElement: HTMLElement | null\n rootBoundary: RootBoundary\n}","flip(\n withBoundary(boundaryRef, {\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n )","offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE})","shift(withBoundary(boundaryRef, {rootBoundary, padding: DEFAULT_TOOLTIP_PADDING}))","sizeMiddleware({boundaryRef, portalRef, rootBoundary})","arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING})","useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n ret.push(\n flip(\n withBoundary(boundaryRef, {\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n ),\n )\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))\n\n // Shift the tooltip so its sits with the boundary element\n ret.push(shift(withBoundary(boundaryRef, {rootBoundary, padding: DEFAULT_TOOLTIP_PADDING})))\n\n // Cap the tooltip width to the boundary, viewport and portal\n ret.push(sizeMiddleware({boundaryRef, portalRef, rootBoundary}))\n\n // Place arrow\n if (arrowProp) {\n ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))\n }\n\n // Determine the origin to scale from.\n // Must be placed after `size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n return ret\n }, [animate, arrowProp, arrowRef, boundaryRef, fallbackPlacements, portalRef, rootBoundary])","{\n handleIsOpenChange,\n referenceRef,\n showTooltip,\n isInsideGroup,\n}: {\n handleIsOpenChange: (open: boolean, immediate?: boolean) => void\n referenceRef: ElementRef\n showTooltip: boolean\n isInsideGroup: boolean\n}","(target: EventTarget | null, teardown: () => void) => {\n const referenceElement = referenceRef.current\n\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === target || (target instanceof Node && referenceElement.contains(target))\n\n if (!isHoveringReference) {\n handleIsOpenChange(false)\n // Allow removing the event listener eagerly, to avoid race conditions\n teardown()\n }\n }","referenceRef.current","() => {\n if (!showTooltip || isInsideGroup) return\n\n const handleMouseMove = (event: MouseEvent) => {\n onMouseMove(event.target, () => window.removeEventListener('mousemove', handleMouseMove))\n }\n\n window.addEventListener('mousemove', handleMouseMove)\n\n // oxlint-disable-next-line consistent-return\n return () => window.removeEventListener('mousemove', handleMouseMove)\n }","[isInsideGroup, showTooltip]","_c","childRef","_Fragment","tooltipActivity","{\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }","isGroupActive ? 1 : openDelay","useMemo(\n () => ({\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }),\n [closeDelay, isGroupActive, openDelay, openTooltipId, setIsGroupActive, setOpenTooltipId],\n )","<TooltipDelayGroupContext.Provider value={value}>{children}</TooltipDelayGroupContext.Provider>","TooltipDelayGroupContext.Provider","_c","\"top\"","\"bottom\"","\"left\"","\"right\""],"sources":["../src/core/hooks/useDelayedState.ts","../src/core/primitives/tooltip/constants.ts","../src/core/primitives/tooltip/tooltip.css.ts","../src/core/primitives/tooltip/tooltipCard.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts","../src/core/primitives/tooltip/tooltip.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx"],"sourcesContent":["import {SetStateAction, useCallback, useEffect, useRef, useState} from 'react'\n\n/**\n * @beta\n */\nexport function useDelayedState<S>(\n initialState: S | (() => S),\n): [S, (nextState: SetStateAction<S>, delay?: number) => void] {\n const [state, setState] = useState(initialState)\n const delayedAction = useRef<NodeJS.Timeout | undefined>(undefined)\n\n const onStateChange = useCallback((nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }, [])\n\n useEffect(() => {\n return () => {\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n }\n }\n }, [])\n\n return [state, onStateChange]\n}\n","import {Placement} from '@floating-ui/react-dom'\n\nexport const DEFAULT_TOOLTIP_ARROW_WIDTH = 15\nexport const DEFAULT_TOOLTIP_ARROW_HEIGHT = 6\nexport const DEFAULT_TOOLTIP_ARROW_RADIUS = 2\n\nexport const DEFAULT_TOOLTIP_DISTANCE = 4\nexport const DEFAULT_TOOLTIP_PADDING = 4\n\nexport const DEFAULT_FALLBACK_PLACEMENTS: Record<Placement, Placement[]> = {\n 'top': ['top-end', 'top-start', 'bottom', 'left', 'right'],\n 'top-start': ['top', 'top-end', 'bottom-start', 'left-start', 'right-start'],\n 'top-end': ['top', 'top-start', 'bottom-end', 'left-end', 'right-end'],\n 'bottom': ['bottom-end', 'bottom-start', 'top', 'left', 'right'],\n 'bottom-start': ['bottom', 'bottom-end', 'top-start', 'left-start', 'right-start'],\n 'bottom-end': ['bottom', 'bottom-start', 'top-end', 'left-end', 'right-end'],\n 'left': ['left-end', 'left-start', 'right', 'top', 'bottom'],\n 'left-start': ['left', 'left-end', 'right-start', 'top-start', 'bottom-start'],\n 'left-end': ['left', 'left-start', 'right-end', 'top-end', 'bottom-end'],\n 'right': ['right-end', 'right-start', 'left', 'top', 'bottom'],\n 'right-start': ['right', 'right-end', 'left-start', 'top-start', 'bottom-start'],\n 'right-end': ['right', 'right-start', 'left-end', 'top-end', 'bottom-end'],\n}\n","import {style} from '@vanilla-extract/css'\n\nexport const tooltipLayer = style({\n pointerEvents: 'none',\n})\n\nexport const tooltipCard = style({\n willChange: 'transform',\n})\n","import {clsx} from 'clsx/lite'\nimport {motion} from 'motion/react'\nimport React, {CSSProperties, useMemo} from 'react'\n\nimport {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {POPOVER_MOTION_PROPS} from '../../constants'\nimport {getTransformOrigin} from '../../middleware/origin'\nimport {Placement} from '../../types/placement'\nimport {Radius} from '../../types/radius'\nimport {Arrow} from '../../utils/arrow/arrow'\nimport {Card} from '../card/card'\nimport {\n DEFAULT_TOOLTIP_ARROW_HEIGHT,\n DEFAULT_TOOLTIP_ARROW_RADIUS,\n DEFAULT_TOOLTIP_ARROW_WIDTH,\n} from './constants'\n\nimport {tooltipCard} from './tooltip.css'\n\nconst MotionCard = motion.create(Card)\n\n/**\n * @internal\n */\nexport function TooltipCard(\n props: {\n animate?: boolean\n arrow: boolean\n arrowRef: React.Ref<HTMLDivElement>\n arrowX?: number\n arrowY?: number\n originX?: number\n originY?: number\n padding?: number | number[]\n placement?: Placement\n radius?: Radius | Radius[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n } & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,\n) {\n const {\n animate,\n arrow,\n arrowRef,\n arrowX,\n arrowY,\n children,\n className,\n originX,\n originY,\n padding,\n placement,\n radius,\n ref,\n scheme,\n shadow,\n style,\n ...restProps\n } = props\n\n const rootStyle: CSSProperties = useMemo(\n () => ({\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, style],\n )\n\n const arrowStyle: CSSProperties = useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )\n\n return (\n <MotionCard\n className={clsx(tooltipCard, className)}\n data-ui=\"Tooltip__card\"\n {...restProps}\n data-placement={placement}\n padding={padding}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n style={rootStyle}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n {children}\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )}\n </MotionCard>\n )\n}\n","import {createGlobalScopedContext} from '../../../lib/createGlobalScopedContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @beta\n */\nexport const TooltipDelayGroupContext =\n createGlobalScopedContext<TooltipDelayGroupContextValue | null>(\n '@sanity/ui/context/tooltipDelayGroup',\n null,\n )\n","import {useContext} from 'react'\n\nimport {TooltipDelayGroupContext} from './tooltipDelayGroupContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @beta\n */\nexport function useTooltipDelayGroup(): TooltipDelayGroupContextValue | null {\n const value = useContext(TooltipDelayGroupContext)\n\n return value\n}\n","import {\n arrow,\n autoUpdate,\n detectOverflow,\n flip,\n type Middleware,\n offset,\n type RootBoundary,\n shift,\n size,\n useFloating,\n} from '@floating-ui/react-dom'\nimport {clsx} from 'clsx/lite'\nimport {\n Activity,\n cloneElement,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once\n// https://github.com/facebook/react/issues/34818 is fixed in the lowest React\n// version we support: on React 19.2 the native hook never sees values past\n// the first render when the calling component is wrapped in `forwardRef` or\n// `memo`, and consumers may wrap `Tooltip` in `memo`.\nimport {useEffectEvent} from 'use-effect-event'\n\nimport type {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {useDelayedState} from '../../hooks/useDelayedState'\nimport {useLatestRef} from '../../hooks/useLatestRef'\nimport {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'\nimport {useReferenceElement} from '../../hooks/useReferenceElement'\nimport {origin} from '../../middleware/origin'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {useTheme_v2} from '../../theme/useTheme'\nimport type {Placement} from '../../types/placement'\nimport {AnimateActivity} from '../../utils/animateActivity'\nimport {useBoundaryElement} from '../../utils/boundaryElement/useBoundaryElement'\nimport {getElementRef} from '../../utils/getElementRef'\nimport {Layer, type LayerProps} from '../../utils/layer/layer'\nimport {Portal} from '../../utils/portal/portal'\nimport {resolvePortalElement} from '../../utils/portal/resolvePortalElement'\nimport {usePortal} from '../../utils/portal/usePortal'\nimport type {Delay} from '../types'\nimport {\n DEFAULT_FALLBACK_PLACEMENTS,\n DEFAULT_TOOLTIP_DISTANCE,\n DEFAULT_TOOLTIP_PADDING,\n} from './constants'\nimport {TooltipCard} from './tooltipCard'\nimport {useTooltipDelayGroup} from './tooltipDelayGroup/useTooltipDelayGroup'\n\nimport {tooltipLayer} from './tooltip.css'\n\n/**\n * @public\n */\nexport interface TooltipProps extends Omit<LayerProps, 'as'> {\n /** @deprecated Use `fallbackPlacements` instead. */\n allowedAutoPlacements?: never\n arrow?: boolean\n boundaryElement?: HTMLElement | null\n children?: React.JSX.Element\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n padding?: number | number[]\n placement?: Placement\n /** Whether or not to render the tooltip in a portal element. */\n portal?: boolean | string\n radius?: number | number[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n /**\n * Adds a delay to open or close the tooltip.\n *\n * If only a `number` is passed, it will be used for both opening and closing.\n *\n * If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.\n *\n * @public\n * @defaultValue 0\n */\n delay?: Delay\n /**\n * Whether the tooltip should animate in and out.\n *\n * @beta\n * @defaultValue false\n */\n animate?: boolean\n}\n\n/**\n * Tooltips display information when hovering, focusing or tapping.\n *\n * @public\n */\nexport function Tooltip(\n props: TooltipProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content'>,\n) {\n const boundaryElementContext = useBoundaryElement()\n const {layer} = useTheme_v2()\n const {\n animate: _animate = false,\n arrow: arrowProp = false,\n boundaryElement: _boundaryElement,\n children: childProp,\n content,\n disabled,\n fallbackPlacements: _fallbackPlacementsProp,\n padding = 2,\n placement: placementProp = 'bottom',\n portal: portalProp,\n radius = 2,\n ref: forwardedRef,\n scheme,\n shadow = 2,\n zOffset: _zOffset,\n delay,\n ...restProps\n } = props\n const boundaryElement = _boundaryElement ?? boundaryElementContext?.element\n const fallbackPlacementsProp =\n _fallbackPlacementsProp ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom']\n const zOffset = _zOffset ?? layer.tooltip.zOffset\n const prefersReducedMotion = usePrefersReducedMotion()\n const animate = prefersReducedMotion ? false : _animate\n const fallbackPlacements = _getArrayProp(fallbackPlacementsProp)\n const ref = useRef<HTMLDivElement | null>(null)\n const arrowRef = useRef<HTMLDivElement | null>(null)\n const rootBoundary: RootBoundary = 'viewport'\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)\n\n const portal = usePortal()\n const portalName = typeof portalProp === 'string' ? portalProp : undefined\n // Resolved the way `Portal` resolves it (a missing named portal falls back to the default one),\n // so the width cap applies to the element the tooltip actually renders into\n const portalElement = resolvePortalElement(portal, portalName)\n\n const middleware = useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n portalElement,\n rootBoundary,\n })\n\n const {floatingStyles, placement, middlewareData, refs, update} = useFloating({\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n })\n\n const childRef = childProp ? getElementRef<HTMLElement>(childProp) : undefined\n const {handOverReference, referenceRef, setReference} = useReferenceElement(refs, childRef)\n\n // The middleware reads the boundary and portal elements through refs (see `useMiddleware`), so\n // a change of either does not reach Floating UI by itself: reposition a shown tooltip against\n // the new element here, without tearing `autoUpdate` down. `update` is a no-op while the tooltip\n // is closed, as there is no floating element then. The body references the elements so that\n // the dependencies the React Compiler and the linter infer from it are the authored ones; with\n // neither element there is no tooltip DOM to reposition (`Portal` renders nothing).\n const reposition = useEffectEvent(() => update())\n\n useLayoutEffect(() => {\n if (boundaryElement || portalElement) reposition()\n }, [boundaryElement, portalElement])\n\n const arrowX = middlewareData.arrow?.x\n const arrowY = middlewareData.arrow?.y\n\n const originX = middlewareData['@sanity/ui/origin']?.originX\n const originY = middlewareData['@sanity/ui/origin']?.originY\n\n const tooltipId = useId()\n const [isOpen, setIsOpen] = useDelayedState(false)\n const delayGroupContext = useTooltipDelayGroup()\n const {setIsGroupActive, setOpenTooltipId} = delayGroupContext || {}\n // Derived, not synced: `disabled` and an empty `content` suppress the tooltip in the same render\n // that changes them, instead of an effect closing it one commit later. The hover state\n // (`isOpen`, or the group pointing at this tooltip) is kept as it is, so a tooltip that is\n // re-enabled or given content while its child is still hovered shows right away.\n const suppressed = disabled || !content\n const showTooltip = !suppressed && (isOpen || delayGroupContext?.openTooltipId === tooltipId)\n\n const isInsideGroup = delayGroupContext !== null\n const openDelayProp = typeof delay === 'number' ? delay : delay?.open || 0\n const closeDelayProp = typeof delay === 'number' ? delay : delay?.close || 0\n\n const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp\n const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp\n\n const handleIsOpenChange = useCallback(\n (open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n },\n [\n isInsideGroup,\n openDelay,\n setIsGroupActive,\n setOpenTooltipId,\n tooltipId,\n closeDelay,\n setIsOpen,\n ],\n )\n\n // `isOpen` is delayed visibility, not the current hover state: after the pointer or focus\n // leaves, it stays true for the close delay. While the tooltip is suppressed it must not linger\n // like that, or re-enabling it (or giving it content) before the delay has elapsed would show it\n // under a pointer that has already left. Leaving a suppressed tooltip closes it immediately.\n const handleBlur = useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onBlur?.(e)\n },\n [childProp?.props, handleIsOpenChange, suppressed],\n )\n const handleClick = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleContextMenu = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleFocus = useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleMouseEnter = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleMouseLeave = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, suppressed)\n childProp?.props?.onMouseLeave?.(e)\n },\n [childProp?.props, handleIsOpenChange, suppressed],\n )\n\n // Handle closing the tooltip when the mouse leaves the referenceElement\n useCloseOnMouseLeave({handleIsOpenChange, referenceRef, showTooltip, isInsideGroup})\n\n const onWindowEscape = useEffectEvent(() => handleIsOpenChange(false, true))\n\n useEffect(() => {\n // If the user clicks on escape key, close the tooltip.\n if (!showTooltip) return\n\n function handleWindowKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n onWindowEscape()\n }\n }\n\n window.addEventListener('keydown', handleWindowKeyDown)\n\n // oxlint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('keydown', handleWindowKeyDown)\n }\n }, [showTooltip])\n\n const setArrow = useCallback(\n (arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n },\n [update],\n )\n\n const setFloating = useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n if (node) handOverReference()\n refs.setFloating(node)\n },\n [handOverReference, refs],\n )\n\n const child = useMemo(() => {\n if (!childProp) return null\n\n return cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReference,\n })\n }, [\n childProp,\n handleBlur,\n handleClick,\n handleContextMenu,\n handleFocus,\n handleMouseEnter,\n handleMouseLeave,\n setReference,\n ])\n\n if (!child) return <></>\n\n const tooltip = (\n <Layer\n data-ui=\"Tooltip\"\n {...restProps}\n className={clsx(tooltipLayer, restProps.className)}\n ref={setFloating}\n style={floatingStyles}\n zOffset={zOffset}\n >\n <TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>\n </Layer>\n )\n\n const tooltipNode = portalProp ? <Portal __unstable_name={portalName}>{tooltip}</Portal> : tooltip\n\n const tooltipActivity = animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )\n\n // The fragment has the same shape whether or not the tooltip is disabled, so the referred\n // element keeps its fiber (DOM node, state, focus) when `disabled` toggles. Returning the bare\n // child while disabled would change the tree shape and remount it. While disabled the tooltip\n // slot is left empty: no hidden tooltip DOM is rendered.\n return (\n <>\n {/* the tooltip */}\n {disabled ? null : tooltipActivity}\n\n {/* the referred element */}\n {child}\n </>\n )\n}\n\ntype ElementRef = React.RefObject<HTMLElement | null>\n\n/**\n * Derivable middleware options that read the boundary element from a ref. Floating UI evaluates\n * them inside `computePosition`, which is when the ref is read — never during render.\n *\n * Built at module scope, like `sizeMiddleware` below: a `ref.current` read inside a callback\n * created during render makes the React Compiler skip the calling function, since it cannot tell\n * when the callback runs.\n */\nfunction withBoundary<Options extends object>(\n boundaryRef: ElementRef,\n options: Options,\n): () => Options & {boundary: HTMLElement | undefined} {\n return () => ({...options, boundary: boundaryRef.current || undefined})\n}\n\n/**\n * Caps the tooltip width to the room it is positioned in: the boundary element (or the clipping\n * ancestors when there is none), always within the viewport, and the portal element's width.\n * Floating UI measures inside its own positioning pass — only while the tooltip is shown, never\n * during render or on mount — and the width is written straight to the element, so no state or\n * layout effect is involved. Placed after `shift` so `availableWidth` is the full clipping width\n * for top and bottom placements; for left and right placements it is the room on that side.\n */\nfunction sizeMiddleware({\n boundaryRef,\n portalRef,\n rootBoundary,\n}: {\n boundaryRef: ElementRef\n portalRef: ElementRef\n rootBoundary: RootBoundary\n}): Middleware {\n return size(() => ({\n boundary: boundaryRef.current || undefined,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n async apply(state) {\n const {availableWidth, elements} = state\n const portalElement = portalRef.current\n let maxWidth = availableWidth\n\n // A tooltip rendered in a portal is capped to the portal's width as well, which may be\n // narrower than the boundary (see the CustomPortal story). The portal is measured on its\n // own rather than as part of `boundary`: an element array is the intersection of the rects,\n // and the portal need not overlap the boundary at all. A portal without a width — an empty\n // mount point — imposes no cap, as before.\n if (portalElement) {\n const overflow = await detectOverflow(state, {\n boundary: portalElement,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n })\n // The portal's clipping width minus the padding on both sides, wherever the tooltip is\n const portalWidth = state.rects.floating.width - overflow.left - overflow.right\n\n if (portalWidth > 0) maxWidth = Math.min(maxWidth, portalWidth)\n }\n\n // No room on the chosen side gives a negative width: the cap is clamped to zero rather than\n // removed, so the tooltip never grows across the boundary.\n elements.floating.style.maxWidth = `${Math.max(0, maxWidth)}px`\n },\n }))\n}\n\nfunction useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n portalElement,\n rootBoundary,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n boundaryElement: HTMLElement | null\n fallbackPlacements: Placement[]\n portalElement: HTMLElement | null\n rootBoundary: RootBoundary\n}) {\n // The elements are read through refs when Floating UI runs the middleware — inside\n // `computePosition`, never during render — so the middleware array keeps its identity when an\n // element changes, and with it Floating UI's `update` callback and `autoUpdate` subscription.\n // Passing the elements as option values would make `useFloating` deep-compare them on every\n // render (it has no DOM element case: two elements are equal unless their own enumerable\n // properties differ, which for React-rendered elements means walking their fibers), and an\n // element captured by a closure such as `apply` would never be noticed at all, since functions\n // are compared by source. The component repositions a shown tooltip itself when an element\n // changes (see `useLayoutEffect` in `Tooltip`).\n const boundaryRef = useLatestRef(boundaryElement)\n const portalRef = useLatestRef(portalElement)\n\n return useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n ret.push(\n flip(\n withBoundary(boundaryRef, {\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n ),\n )\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))\n\n // Shift the tooltip so its sits with the boundary element\n ret.push(shift(withBoundary(boundaryRef, {rootBoundary, padding: DEFAULT_TOOLTIP_PADDING})))\n\n // Cap the tooltip width to the boundary, viewport and portal\n ret.push(sizeMiddleware({boundaryRef, portalRef, rootBoundary}))\n\n // Place arrow\n if (arrowProp) {\n ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))\n }\n\n // Determine the origin to scale from.\n // Must be placed after `size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n return ret\n }, [animate, arrowProp, arrowRef, boundaryRef, fallbackPlacements, portalRef, rootBoundary])\n}\n\n/**\n * As `useEffectEvent` should never be passed to other components or hooks, this custom hook groups together the `useEffectEvent` and the `useEffect` hook using it.\n * @see https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events:~:text=Never%20pass%20them%20to%20other%20components%20or%20Hooks\n */\nfunction useCloseOnMouseLeave({\n handleIsOpenChange,\n referenceRef,\n showTooltip,\n isInsideGroup,\n}: {\n handleIsOpenChange: (open: boolean, immediate?: boolean) => void\n referenceRef: ElementRef\n showTooltip: boolean\n isInsideGroup: boolean\n}) {\n // An \"effect event\" (https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events),\n // so that the `mousemove` listener below is not detached and attached again whenever\n // `handleIsOpenChange` changes; the referred element is read from its ref when the pointer moves.\n const onMouseMove = useEffectEvent((target: EventTarget | null, teardown: () => void) => {\n const referenceElement = referenceRef.current\n\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === target || (target instanceof Node && referenceElement.contains(target))\n\n if (!isHoveringReference) {\n handleIsOpenChange(false)\n // Allow removing the event listener eagerly, to avoid race conditions\n teardown()\n }\n })\n\n // Detect whether the mouse is moving outside of the reference element. This is sometimes\n // necessary, because the tooltip might not always close as it should (e.g. when clicking\n // the reference element triggers a CPU-heavy operation.)\n useEffect(() => {\n if (!showTooltip || isInsideGroup) return\n\n const handleMouseMove = (event: MouseEvent) => {\n onMouseMove(event.target, () => window.removeEventListener('mousemove', handleMouseMove))\n }\n\n window.addEventListener('mousemove', handleMouseMove)\n\n // oxlint-disable-next-line consistent-return\n return () => window.removeEventListener('mousemove', handleMouseMove)\n }, [isInsideGroup, showTooltip])\n}\n","import {useMemo} from 'react'\n\nimport {useDelayedState} from '../../../hooks/useDelayedState'\nimport {Delay} from '../../types'\nimport {TooltipDelayGroupContext} from './tooltipDelayGroupContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @public\n * */\nexport interface TooltipDelayGroupProviderProps {\n children?: React.ReactNode\n /**\n * Handles the delays to open or close a tooltip inside a group\n *\n * If only a `number` is passed, it will be used for both opening and closing.\n *\n * If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.\n *\n * @public\n */\n delay: Delay\n}\n\n/**\n * @public\n * Provides context for a group of tooltip elements that should share a delay\n * which temporarily becomes 1 ms after the first floating element of the group opens.\n */\nexport function TooltipDelayGroupProvider(\n props: TooltipDelayGroupProviderProps,\n): React.JSX.Element {\n const {children, delay} = props\n const [isGroupActive, setIsGroupActive] = useDelayedState(false)\n const [openTooltipId, setOpenTooltipId] = useDelayedState<string | null>(null)\n\n const openDelay = typeof delay === 'number' ? delay : delay?.open || 0\n const closeDelay = typeof delay === 'number' ? delay : delay?.close || 0\n\n const value: TooltipDelayGroupContextValue = useMemo(\n () => ({\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }),\n [closeDelay, isGroupActive, openDelay, openTooltipId, setIsGroupActive, setOpenTooltipId],\n )\n\n return (\n <TooltipDelayGroupContext.Provider value={value}>{children}</TooltipDelayGroupContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAgB,gBACd,cAC6D;eACvD,CAAC,OAAO,YAAY,SAAS,YAAY,GACzC,gBAAgB,OAAmC,KAAA,CAAS,GAEhCA;qDAAC,MAAA,WAA8B,UAAmB;EAClF,IAAM,eAAe;GACnB,SAAS,SAAS;EACpB;EAQA,IALA,AAEE,cAAc,aADd,aAAa,cAAc,OAAO,GACV,KAAA,IAGtB,CAAC,OAA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AD;EAA0C;EAAQ;CAA4C,CAAA,GAA5C,EAAA,KAAA,UAAR,EAAA,KAAA,+BAA1CD;AAEJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "4.4.1",
3
+ "version": "4.4.2",
4
4
  "keywords": [
5
5
  "components",
6
6
  "design-system",
@@ -1 +0,0 @@
1
- {"version":3,"file":"getElementRef-Jw7gY0eV.js","names":["{mode: modeFromProps, layoutMode, children}: AnimateActivityProps","() => setMode('hidden')","<PresenceChild\n isPresent={isPresent}\n onExitComplete={!isPresent ? onExitComplete : undefined}\n presenceAffectsLayout={false}\n mode={layoutMode === 'pop' ? 'popLayout' : 'sync'}\n >\n {/* oxlint-disable-next-line no-unsafe-type-assertion -- PresenceChild expects a single ReactElement */}\n {children as any}\n </PresenceChild>","!isPresent ? onExitComplete : undefined","layoutMode === 'pop' ? 'popLayout' : 'sync'","children as any","<Activity mode={mode}>\n <PresenceChild\n isPresent={isPresent}\n onExitComplete={!isPresent ? onExitComplete : undefined}\n presenceAffectsLayout={false}\n mode={layoutMode === 'pop' ? 'popLayout' : 'sync'}\n >\n {/* oxlint-disable-next-line no-unsafe-type-assertion -- PresenceChild expects a single ReactElement */}\n {children as any}\n </PresenceChild>\n </Activity>","_c"],"sources":["../src/core/middleware/origin.ts","../src/core/utils/animateActivity.tsx","../src/core/utils/getElementRef.ts"],"sourcesContent":["import {Middleware} from '@floating-ui/react-dom'\n\n/**\n * Custom floating-ui middleware which calculates transform-origin X + Y offsets\n * based on the current floating rect's dimensions and shift offset.\n *\n * Scaling popovers with these transform-origin offsets will give the effect of\n * popvers slightly 'growing' from the origin/reference element.\n *\n * This middleware must be applied after both `@sanity/ui/size` and `shift` middlewares.\n */\nexport const origin: Middleware = {\n name: '@sanity/ui/origin',\n fn({middlewareData, placement, rects}) {\n const [side] = placement.split('-')\n\n const floatingWidth = rects.floating.width\n const floatingHeight = rects.floating.height\n\n const shiftX = middlewareData.shift?.x || 0\n const shiftY = middlewareData.shift?.y || 0\n\n if (floatingWidth <= 0 || floatingHeight <= 0) {\n return {}\n }\n\n const isVerticalPlacement = ['bottom', 'top'].includes(side)\n\n const {originX, originY}: {originX: number; originY: number} = isVerticalPlacement\n ? {\n originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),\n originY: side === 'bottom' ? 0 : 1,\n }\n : {\n originX: side === 'left' ? 1 : 0,\n originY: clamp(0.5 - shiftY / floatingHeight, 0, 1),\n }\n\n return {\n data: {originX, originY},\n }\n },\n}\n\n/**\n * Converts the `origin` middleware data into a plain `transform-origin` CSS value.\n *\n * The value is intentionally applied as a regular CSS property rather than motion's\n * `originX`/`originY` style keys: motion turns those into motion values that it resets to\n * their initial (unpositioned, `undefined`) state whenever the element re-mounts, which is\n * what happens every time an `Activity`-hidden popover or tooltip is shown again.\n */\nexport function getTransformOrigin(originX?: number, originY?: number): string | undefined {\n if (originX === undefined || originY === undefined) return undefined\n\n return `${originX * 100}% ${originY * 100}%`\n}\n\nfunction clamp(num: number, min: number, max: number) {\n return Math.min(Math.max(num, min), max)\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2024 Motion One\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {invariant, PresenceChild} from 'motion/react'\nimport {Activity, useState} from 'react'\n\ninterface AnimateActivityProps {\n mode: 'visible' | 'hidden'\n layoutMode: 'default' | 'pop'\n children: React.ReactNode\n}\n\n/**\n * Animated version of React's `Activity` that defers `mode=\"hidden\"` until\n * child exit animations have finished.\n *\n * @internal\n */\nexport function AnimateActivity({mode: modeFromProps, layoutMode, children}: AnimateActivityProps) {\n /**\n * This is the mode that we'll render.\n */\n const [mode, setMode] = useState(modeFromProps)\n\n /**\n * This is the goal state as defined by props.\n */\n const isPresent = modeFromProps === 'visible'\n\n /**\n * Immediately switch to mode=\"visible\" when the user\n * changes the mode prop.\n */\n if (isPresent && mode !== 'visible') {\n setMode('visible')\n return null\n }\n\n /**\n * Set mode to \"hidden\" only when the exit animation is complete.\n */\n const onExitComplete = () => setMode('hidden')\n\n invariant(Boolean(Activity), 'Activity component not found - upgrade to React 19.2.0 or higher')\n\n return (\n <Activity mode={mode}>\n <PresenceChild\n isPresent={isPresent}\n onExitComplete={!isPresent ? onExitComplete : undefined}\n presenceAffectsLayout={false}\n mode={layoutMode === 'pop' ? 'popLayout' : 'sync'}\n >\n {/* oxlint-disable-next-line no-unsafe-type-assertion -- PresenceChild expects a single ReactElement */}\n {children as any}\n </PresenceChild>\n </Activity>\n )\n}\n","// Based on https://github.com/radix-ui/primitives/blob/0bade6a704e5821b90a6da0f3d8cfa8a7711127d/packages/react/slot/src/Slot.tsx#L128-L150\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nexport function getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n // oxlint-disable-next-line unbound-method\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning\n\n if (mayWarn) {\n // oxlint-disable-next-line no-unsafe-type-assertion\n return (element as any).ref\n }\n\n // React 19 in DEV\n // oxlint-disable-next-line unbound-method\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning\n\n if (mayWarn) {\n // oxlint-disable-next-line no-unsafe-type-assertion\n return (element.props as {ref?: React.Ref<unknown>}).ref\n }\n\n // Not DEV\n // oxlint-disable-next-line no-unsafe-type-assertion\n return (element.props as {ref?: React.Ref<unknown>}).ref || (element as any).ref\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,SAAqB;CAChC,MAAM;CACN,GAAG,EAAC,gBAAgB,WAAW,SAAQ;EACrC,IAAM,CAAC,QAAQ,UAAU,MAAM,GAAG,GAE5B,gBAAgB,MAAM,SAAS,OAC/B,iBAAiB,MAAM,SAAS,QAEhC,SAAS,eAAe,OAAO,KAAK,GACpC,SAAS,eAAe,OAAO,KAAK;EAE1C,IAAI,iBAAiB,KAAK,kBAAkB,GAC1C,OAAO,CAAC;EAKV,IAAM,EAAC,SAAS,YAFY,CAAC,UAAU,KAAK,CAAC,CAAC,SAAS,IAEQ,IAC3D;GACE,SAAS,MAAM,KAAM,SAAS,eAAe,GAAG,CAAC;GACjD,SAAS,SAAS,WAAW,IAAI;EACnC,IACA;GACE,SAAS,WAAS;GAClB,SAAS,MAAM,KAAM,SAAS,gBAAgB,GAAG,CAAC;EACpD;EAEJ,OAAO,EACL,MAAM;GAAC;GAAS;EAAO,EACzB;CACF;AACF;;;;;;;;;AAUA,SAAgB,mBAAmB,SAAkB,SAAsC;CACzF,IAAI,YAAY,KAAA,KAAa,YAAY,KAAA,GAEzC,OAAO,GAAG,UAAU,IAAI,IAAI,UAAU,IAAI;AAC5C;AAEA,SAAS,MAAM,KAAa,KAAa,KAAa;CACpD,OAAO,KAAK,IAAI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3,"file":"popover-B0kvwaep.js","names":["size","getTransformOrigin(originX, originY)","{\n left: x,\n position: strategy,\n top: y,\n transformOrigin: getTransformOrigin(originX, originY),\n width,\n zIndex,\n willChange: animate ? 'transform' : undefined,\n ...style,\n }","animate ? 'transform' : undefined","useMemo(\n () => ({\n left: x,\n position: strategy,\n top: y,\n transformOrigin: getTransformOrigin(originX, originY),\n width,\n zIndex,\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, strategy, style, width, x, y, zIndex],\n )","{\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }","arrowX !== null ? arrowX : undefined","arrowY !== null ? arrowY : undefined","useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )","<Flex direction=\"column\" flex={1} padding={padding}>\n {children}\n </Flex>","<Flex data-ui=\"Popover__wrapper\" direction=\"column\" flex={1} overflow={overflow}>\n <Flex direction=\"column\" flex={1} padding={padding}>\n {children}\n </Flex>\n </Flex>","arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_POPOVER_ARROW_WIDTH}\n height={DEFAULT_POPOVER_ARROW_HEIGHT}\n radius={DEFAULT_POPOVER_ARROW_RADIUS}\n />\n )","<MotionCard\n data-ui=\"Popover\"\n {...restProps}\n data-placement={placement}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n sizing=\"border\"\n style={rootStyle}\n tone={tone}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n <Flex data-ui=\"Popover__wrapper\" direction=\"column\" flex={1} overflow={overflow}>\n <Flex direction=\"column\" flex={1} padding={padding}>\n {children}\n </Flex>\n </Flex>\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_POPOVER_ARROW_WIDTH}\n height={DEFAULT_POPOVER_ARROW_HEIGHT}\n radius={DEFAULT_POPOVER_ARROW_RADIUS}\n />\n )}\n </MotionCard>","animate ? POPOVER_MOTION_PROPS : undefined","_c","<div\n data-ui=\"PopoverOverlay\"\n style={{height: '100vh', inset: 0, position: 'fixed', width: '100vw', zIndex}}\n />","margins = DEFAULT_POPOVER_MARGINS","_animate = false","tone = 'inherit'","widthProp = 'auto'","arrowProp = false","constrainSize = false","overflow = 'hidden'","placementProp = 'bottom'","placementStrategy = 'flip'","preventOverflow = true","radiusProp = 3","shadowProp = 3","childProp","_fallbackPlacements","_floatingBoundary","paddingProp","forwardedRef","_referenceBoundary","_zOffsetProp","...restProps","_getArrayProp(paddingProp)","_getArrayProp(radiusProp)","_getArrayProp(shadowProp)","_getArrayProp(zOffsetProp)","() => ref.current","() => {\n widthRef.current = width\n }","[width]","calcMaxWidth({boundaryWidth, currentWidth: width})","() => {\n maxWidthRef.current = maxWidth\n }","[maxWidth]","() => {\n const floatingElement = ref.current\n\n if (!open || !floatingElement) return\n\n const referenceWidth = referenceWidthRef.current\n\n if (matchReferenceWidth) {\n if (referenceWidth !== undefined) {\n floatingElement.style.width = `${referenceWidth}px`\n }\n } else if (width !== undefined) {\n floatingElement.style.width = `${width}px`\n }\n\n if (typeof maxWidth === 'number') {\n floatingElement.style.maxWidth = `${maxWidth}px`\n }\n }","[width, matchReferenceWidth, maxWidth, open]","referenceWidth","{\n animate,\n arrowProp,\n arrowRef,\n constrainSize,\n fallbackPlacements,\n floatingBoundary,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n placementProp,\n placementStrategy,\n preventOverflow,\n referenceBoundary,\n referenceWidthRef,\n rootBoundary,\n setReferenceWidth,\n widthRef,\n }","referenceElement\n ? {\n reference: referenceElement,\n }\n : undefined","{\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: referenceElement\n ? {\n reference: referenceElement,\n }\n : undefined,\n }","() => {\n if (!intentReference) return undefined\n\n const controller = new AbortController()\n const {signal} = controller\n // In a transition, so that it never holds up an open that follows right away (a click), and\n // so that React pre-renders the hidden popover in the background\n const handleIntent = () => startTransition(() => setHasRendered(true))\n\n // `focusin` rather than `focus` so that focus landing inside the reference element counts too.\n // `pointerdown` is a fallback for a pointer that was already over the element when it\n // rendered, which fires no `pointerenter`.\n for (const type of INTENT_EVENT_TYPES) {\n intentReference.addEventListener(type, handleIntent, {signal})\n }\n\n // Focus that landed before the listeners did (an `autoFocus` reference, a `referenceElement`\n // that was focused already) fired its `focusin` unheard, so count it now\n const {activeElement} = intentReference.ownerDocument\n\n if (activeElement && intentReference.contains(activeElement)) handleIntent()\n\n return () => controller.abort()\n }","[intentReference]","(arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n }","useCallback((arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n }, [])","(node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n }","useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n },\n [refs],\n )","childProp ? getElementRef(childProp) : null","() => refs.reference.current","current","useMemo(() => {\n // If a reference element is defined, we don't need to clone the child\n if (referenceElement) return childProp\n\n if (!childProp) return null\n\n return cloneElement(childProp, {ref: refs.setReference})\n }, [childProp, referenceElement, refs.setReference])","cloneElement(childProp, {ref: refs.setReference})","setReference","() => update","[update]","childProp || <></>","modal && <ViewportOverlay />","<PopoverCard\n {...restProps}\n __unstable_margins={margins}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n hidden={referenceHidden}\n overflow={overflow}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n originX={originX}\n originY={originY}\n strategy={strategy}\n tone={tone}\n width={matchReferenceWidth ? referenceWidth : width}\n x={x}\n y={y}\n >\n {content}\n </PopoverCard>","matchReferenceWidth ? referenceWidth : width","<LayerProvider zOffset={zOffset}>\n {/* Optional transparent blocking overlay at the top-most z-index layer. Must be positioned before the below popover card. */}\n {modal && <ViewportOverlay />}\n\n <PopoverCard\n {...restProps}\n __unstable_margins={margins}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n hidden={referenceHidden}\n overflow={overflow}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n originX={originX}\n originY={originY}\n strategy={strategy}\n tone={tone}\n width={matchReferenceWidth ? referenceWidth : width}\n x={x}\n y={y}\n >\n {content}\n </PopoverCard>\n </LayerProvider>","portal ? (\n <Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>{popover}</Portal>\n ) : (\n popover\n )","animate ? (\n <AnimateActivity layoutMode=\"default\" mode={open ? 'visible' : 'hidden'}>\n {shouldRender ? popoverNode : null}\n </AnimateActivity>\n ) : (\n <Activity mode={open ? 'visible' : 'hidden'}>{shouldRender ? popoverNode : null}</Activity>\n )","<>\n {/* the popover (not rendered until it opens or is about to, see `hasRendered`) */}\n {animate ? (\n <AnimateActivity layoutMode=\"default\" mode={open ? 'visible' : 'hidden'}>\n {shouldRender ? popoverNode : null}\n </AnimateActivity>\n ) : (\n <Activity mode={open ? 'visible' : 'hidden'}>{shouldRender ? popoverNode : null}</Activity>\n )}\n\n {/* the referred element */}\n {child}\n </>","() => {\n if (!open || !element) return undefined\n\n // Measuring the boundary is what this effect is for: the DOM is only measurable after the\n // commit, and the result has to be in the next paint\n // oxlint-disable-next-line react/set-state-in-effect\n setSize((prev) => sameSize(prev, measureBorderBox(element)))\n\n return _elementSizeObserver.subscribe(element, ({border}) =>\n setSize((prev) =>\n sameSize(prev, {width: Math.round(border.width), height: Math.round(border.height)}),\n ),\n )\n }","[element, open]","{border}","prev","{\n animate,\n arrowProp,\n arrowRef,\n constrainSize,\n fallbackPlacements,\n floatingBoundary,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n placementProp,\n placementStrategy,\n preventOverflow,\n referenceBoundary,\n referenceWidthRef,\n rootBoundary,\n setReferenceWidth,\n widthRef,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n constrainSize: boolean\n fallbackPlacements: Placement[]\n floatingBoundary: HTMLElement | null\n margins: PopoverMargins\n matchReferenceWidth: boolean | undefined\n maxWidthRef: React.RefObject<number | undefined>\n placementProp: Placement\n placementStrategy: 'flip' | 'autoPlacement'\n preventOverflow: boolean\n referenceBoundary: HTMLElement | null\n referenceWidthRef: React.RefObject<number | undefined>\n rootBoundary: RootBoundary\n setReferenceWidth: (referenceWidth: number) => void\n widthRef: React.RefObject<number | undefined>\n}","autoPlacement({\n allowedPlacements: [placementProp].concat(fallbackPlacements),\n })","flip({\n boundary: floatingBoundary || undefined,\n fallbackPlacements,\n padding: DEFAULT_POPOVER_PADDING,\n rootBoundary,\n })","floatingBoundary || undefined","offset({mainAxis: DEFAULT_POPOVER_DISTANCE})","size({\n boundaryElement: floatingBoundary || undefined,\n constrainSize,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n padding: DEFAULT_POPOVER_PADDING,\n referenceWidthRef,\n setReferenceWidth,\n widthRef,\n })","shift({\n boundary: floatingBoundary || undefined,\n rootBoundary,\n padding: DEFAULT_POPOVER_PADDING,\n })","arrow({\n element: arrowRef,\n padding: DEFAULT_POPOVER_PADDING,\n })","hide({\n boundary: referenceBoundary || undefined,\n padding: DEFAULT_POPOVER_PADDING,\n strategy: 'referenceHidden',\n })","referenceBoundary || undefined","useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n if (constrainSize || preventOverflow) {\n if (placementStrategy === 'autoPlacement') {\n ret.push(\n autoPlacement({\n allowedPlacements: [placementProp].concat(fallbackPlacements),\n }),\n )\n } else {\n ret.push(\n flip({\n boundary: floatingBoundary || undefined,\n fallbackPlacements,\n padding: DEFAULT_POPOVER_PADDING,\n rootBoundary,\n }),\n )\n }\n }\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_POPOVER_DISTANCE}))\n\n // Track sizes\n if (constrainSize || matchReferenceWidth) {\n ret.push(\n size({\n boundaryElement: floatingBoundary || undefined,\n constrainSize,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n padding: DEFAULT_POPOVER_PADDING,\n referenceWidthRef,\n setReferenceWidth,\n widthRef,\n }),\n )\n }\n\n // Shift the popover so its sits within the boundary element\n if (preventOverflow) {\n ret.push(\n shift({\n boundary: floatingBoundary || undefined,\n rootBoundary,\n padding: DEFAULT_POPOVER_PADDING,\n }),\n )\n }\n\n // Place arrow\n if (arrowProp) {\n ret.push(\n arrow({\n element: arrowRef,\n padding: DEFAULT_POPOVER_PADDING,\n }),\n )\n }\n\n // Determine the origin to scale from.\n // Must be placed after `@sanity/ui/size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n ret.push(\n hide({\n boundary: referenceBoundary || undefined,\n padding: DEFAULT_POPOVER_PADDING,\n strategy: 'referenceHidden',\n }),\n )\n\n return ret\n }, [\n animate,\n arrowProp,\n arrowRef,\n constrainSize,\n fallbackPlacements,\n floatingBoundary,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n placementProp,\n placementStrategy,\n preventOverflow,\n referenceBoundary,\n referenceWidthRef,\n rootBoundary,\n setReferenceWidth,\n widthRef,\n ])","_c","_Fragment","size","\"top\"","\"bottom\"","\"left\"","\"right\""],"sources":["../src/core/primitives/popover/constants.ts","../src/core/primitives/popover/floating-ui/size.ts","../src/core/primitives/popover/helpers.ts","../src/core/primitives/popover/popoverCard.tsx","../src/core/primitives/popover/popover.tsx"],"sourcesContent":["import {Placement} from '../../types/placement'\nimport {PopoverMargins} from '../../types/popover'\n\nexport const DEFAULT_POPOVER_DISTANCE = 4\nexport const DEFAULT_POPOVER_PADDING = 4\nexport const DEFAULT_POPOVER_ARROW_WIDTH = 19\nexport const DEFAULT_POPOVER_ARROW_HEIGHT = 8\nexport const DEFAULT_POPOVER_ARROW_RADIUS = 2\nexport const DEFAULT_POPOVER_MARGINS: PopoverMargins = [0, 0, 0, 0]\nexport const DEFAULT_FALLBACK_PLACEMENTS: Record<Placement, Placement[]> = {\n 'top': ['bottom', 'left', 'right'],\n 'top-start': ['bottom-start', 'left-start', 'right-start'],\n 'top-end': ['bottom-end', 'left-end', 'right-end'],\n 'bottom': ['top', 'left', 'right'],\n 'bottom-start': ['top-start', 'left-start', 'right-start'],\n 'bottom-end': ['top-end', 'left-end', 'right-end'],\n 'left': ['right', 'top', 'bottom'],\n 'left-start': ['right-start', 'top-start', 'bottom-start'],\n 'left-end': ['right-end', 'top-end', 'bottom-end'],\n 'right': ['left', 'top', 'bottom'],\n 'right-start': ['left-start', 'top-start', 'bottom-start'],\n 'right-end': ['left-end', 'top-end', 'bottom-end'],\n}\n","import {detectOverflow, Middleware} from '@floating-ui/react-dom'\n\nimport {PopoverMargins} from '../../../types/popover'\n\nexport function size(options: {\n boundaryElement?: HTMLElement | null\n constrainSize: boolean\n margins: PopoverMargins\n matchReferenceWidth?: boolean\n maxWidthRef: React.RefObject<number | undefined>\n padding?: number\n referenceWidthRef: React.RefObject<number | undefined>\n setReferenceWidth: (referenceWidth: number) => void\n widthRef: React.RefObject<number | undefined>\n}): Middleware {\n const {\n constrainSize,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n padding = 0,\n referenceWidthRef,\n setReferenceWidth,\n widthRef,\n } = options\n\n return {\n name: '@sanity/ui/size',\n async fn(args) {\n const {elements, placement, platform, rects} = args\n const {floating, reference} = rects\n\n const overflow = await detectOverflow(args, {\n altBoundary: true,\n boundary: options.boundaryElement || undefined,\n elementContext: 'floating',\n padding,\n rootBoundary: 'viewport',\n })\n\n let maxWidth = Infinity\n let maxHeight = Infinity\n\n const floatingW = floating.width\n const floatingH = floating.height\n\n if (placement.includes('top')) {\n maxWidth = floatingW - (overflow.left + overflow.right)\n maxHeight = floatingH - overflow.top\n }\n\n if (placement.includes('right')) {\n maxWidth = floatingW - overflow.right\n maxHeight = floatingH - (overflow.top + overflow.bottom)\n }\n\n if (placement.includes('bottom')) {\n maxWidth = floatingW - (overflow.left + overflow.right)\n maxHeight = floatingH - overflow.bottom\n }\n\n if (placement.includes('left')) {\n maxWidth = floatingW - overflow.left\n maxHeight = floatingH - (overflow.top + overflow.bottom)\n }\n\n // IMPORTANT – APPLY ELEMENT STYLES HERE\n // Elements need to be resized BEFORE the `platform.getDimensions` call below\n const availableWidth = maxWidth - margins[1] - margins[3]\n const availableHeight = maxHeight - margins[0] - margins[2]\n const referenceWidth = reference.width - margins[1] - margins[3]\n referenceWidthRef.current = referenceWidth\n setReferenceWidth(referenceWidth)\n\n if (matchReferenceWidth) {\n elements.floating.style.width = `${referenceWidth}px`\n } else if (widthRef.current !== undefined) {\n elements.floating.style.width = `${widthRef.current}px`\n }\n\n if (constrainSize) {\n elements.floating.style.maxWidth = `${Math.min(availableWidth, maxWidthRef.current ?? Infinity)}px`\n\n elements.floating.style.maxHeight = `${availableHeight}px`\n }\n\n const nextDimensions = await platform.getDimensions(elements.floating)\n\n const targetH = nextDimensions.height\n const targetW = nextDimensions.width\n\n if (floatingW !== targetW || floatingH !== targetH) {\n return {reset: {rects: true}}\n }\n\n return {}\n },\n }\n}\n","import {DEFAULT_POPOVER_PADDING} from './constants'\nimport {PopoverWidth} from './types'\n\nexport function calcCurrentWidth(params: {\n mediaIndex: number\n container: number[]\n width: PopoverWidth[]\n}): number | undefined {\n const {container, mediaIndex, width} = params\n\n const w = width[mediaIndex]\n const currentWidth: PopoverWidth | undefined = w === undefined ? width[width.length - 1] : w\n\n return typeof currentWidth === 'number' ? container[currentWidth] : undefined\n}\n\nexport function calcMaxWidth(params: {\n boundaryWidth: number | undefined\n currentWidth: number | undefined\n}): number | undefined {\n const {boundaryWidth, currentWidth} = params\n\n if (currentWidth === undefined && boundaryWidth === undefined) {\n return undefined\n }\n\n return Math.min(\n currentWidth ?? Infinity,\n (boundaryWidth || Infinity) - DEFAULT_POPOVER_PADDING * 2,\n )\n}\n","import {Strategy} from '@floating-ui/react-dom'\nimport {motion} from 'motion/react'\nimport React, {CSSProperties, useMemo} from 'react'\nimport {styled} from 'styled-components'\n\nimport {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {POPOVER_MOTION_PROPS} from '../../constants'\nimport {getTransformOrigin} from '../../middleware/origin'\nimport {BoxOverflow} from '../../types/box'\nimport {CardTone} from '../../types/card'\nimport {Placement} from '../../types/placement'\nimport {PopoverMargins} from '../../types/popover'\nimport {Radius} from '../../types/radius'\nimport {Arrow} from '../../utils/arrow/arrow'\nimport {useLayer} from '../../utils/layer/useLayer'\nimport {Card} from '../card/card'\nimport {Flex} from '../flex/flex'\nimport {\n DEFAULT_POPOVER_ARROW_HEIGHT,\n DEFAULT_POPOVER_ARROW_RADIUS,\n DEFAULT_POPOVER_ARROW_WIDTH,\n DEFAULT_POPOVER_MARGINS,\n} from './constants'\n\nconst MotionCard = styled(motion.create(Card))`\n &:not([hidden]) {\n display: flex;\n }\n flex-direction: column;\n width: max-content;\n min-width: min-content;\n will-change: transform;\n`\n\n/**\n * @internal\n */\nexport function PopoverCard(\n props: {\n /** @beta*/\n __unstable_margins?: PopoverMargins\n animate?: boolean\n arrow: boolean\n arrowRef: React.Ref<HTMLDivElement>\n arrowX?: number\n arrowY?: number\n originX?: number\n originY?: number\n overflow?: BoxOverflow\n padding?: number | number[]\n placement: Placement\n radius?: Radius | Radius[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n strategy: Strategy\n tone: CardTone\n width: number | undefined\n x: number | null\n y: number | null\n } & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,\n) {\n const {\n __unstable_margins: marginsProp,\n animate,\n arrow,\n arrowRef,\n arrowX,\n arrowY,\n children,\n padding,\n placement,\n originX,\n originY,\n overflow,\n radius,\n ref,\n scheme,\n shadow,\n strategy,\n style,\n tone,\n width,\n x: xProp,\n y: yProp,\n ...restProps\n } = props\n\n const {zIndex} = useLayer()\n\n // Get margins: [top, right, bottom, left]\n const margins: PopoverMargins = useMemo(\n () => marginsProp || DEFAULT_POPOVER_MARGINS,\n [marginsProp],\n )\n\n // Translate according to margins\n const x = (xProp ?? 0) + margins[3]\n const y = (yProp ?? 0) + margins[0]\n\n const rootStyle: CSSProperties = useMemo(\n () => ({\n left: x,\n position: strategy,\n top: y,\n transformOrigin: getTransformOrigin(originX, originY),\n width,\n zIndex,\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, strategy, style, width, x, y, zIndex],\n )\n\n const arrowStyle: CSSProperties = useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )\n\n return (\n <MotionCard\n data-ui=\"Popover\"\n {...restProps}\n data-placement={placement}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n sizing=\"border\"\n style={rootStyle}\n tone={tone}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n <Flex data-ui=\"Popover__wrapper\" direction=\"column\" flex={1} overflow={overflow}>\n <Flex direction=\"column\" flex={1} padding={padding}>\n {children}\n </Flex>\n </Flex>\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_POPOVER_ARROW_WIDTH}\n height={DEFAULT_POPOVER_ARROW_HEIGHT}\n radius={DEFAULT_POPOVER_ARROW_RADIUS}\n />\n )}\n </MotionCard>\n )\n}\n","import {\n arrow,\n autoPlacement,\n autoUpdate,\n flip,\n hide,\n Middleware,\n offset,\n RootBoundary,\n shift,\n useFloating,\n} from '@floating-ui/react-dom'\nimport {\n Activity,\n cloneElement,\n type Ref,\n startTransition,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {useMediaIndex} from '../../hooks/useMediaIndex/useMediaIndex'\nimport {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'\nimport {origin} from '../../middleware/origin'\nimport {_elementSizeObserver, ElementRectValue} from '../../observers/elementSizeObserver'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {useTheme_v2} from '../../theme/useTheme'\nimport {BoxOverflow} from '../../types/box'\nimport {CardTone} from '../../types/card'\nimport {Placement} from '../../types/placement'\nimport {PopoverMargins} from '../../types/popover'\nimport {AnimateActivity} from '../../utils/animateActivity'\nimport {useBoundaryElement} from '../../utils/boundaryElement/useBoundaryElement'\nimport {getElementRef} from '../../utils/getElementRef'\nimport {LayerProps} from '../../utils/layer/layer'\nimport {LayerProvider} from '../../utils/layer/layerProvider'\nimport {useLayer} from '../../utils/layer/useLayer'\nimport {Portal} from '../../utils/portal/portal'\nimport {ResponsiveRadiusProps, ResponsiveShadowProps} from '../types'\nimport {\n DEFAULT_FALLBACK_PLACEMENTS,\n DEFAULT_POPOVER_DISTANCE,\n DEFAULT_POPOVER_MARGINS,\n DEFAULT_POPOVER_PADDING,\n} from './constants'\nimport {size} from './floating-ui/size'\nimport {calcCurrentWidth, calcMaxWidth} from './helpers'\nimport {PopoverCard} from './popoverCard'\nimport {PopoverUpdateCallback, PopoverWidth} from './types'\n\n/** @public */\nexport interface PopoverProps\n extends Omit<LayerProps, 'as'>, ResponsiveRadiusProps, ResponsiveShadowProps {\n /** @beta */\n __unstable_margins?: PopoverMargins\n /**\n * Whether the popover should animate in and out.\n *\n * @beta\n * @defaultValue false\n */\n animate?: boolean\n arrow?: boolean\n /** @deprecated Use `floatingBoundary` and/or `referenceBoundary` instead */\n boundaryElement?: never\n children?: React.JSX.Element\n /**\n * When `true`, prevent overflow within the current boundary:\n * - by flipping on its side axis\n * - by resizing\n /*\n * Note that:\n * - setting `preventOverflow` to `true` also prevents overflow on its side axis\n * - setting `matchReferenceWidth` to `true` also causes the popover to resize\n *\n * @defaultValue false\n */\n constrainSize?: boolean\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n floatingBoundary?: HTMLElement | null\n /**\n * When `true`, set the maximum width to match the reference element, and also prevent overflow within\n * the current boundary by resizing.\n *\n * Note that setting `constrainSize` to `true` also causes the popover to resize\n *\n * @defaultValue false\n */\n matchReferenceWidth?: boolean\n /**\n * When true, blocks all pointer interaction with elements beneath the popover until closed.\n *\n * @beta\n * @defaultValue false\n */\n modal?: boolean\n /**\n * Whether the popover is open.\n *\n * Set it inside `startTransition`. A closed popover pre-renders its content hidden, in a\n * transition, once the reference element shows intent to open it (focus, a pointer entering or\n * pressing it). Opening in a transition too lets React keep rendering that content in the\n * background when the open comes before it is done, instead of rendering it synchronously in the\n * click. Content that was pre-rendered already shows in the first frame after the click either\n * way.\n *\n * ```tsx\n * const [open, setOpen] = useState(false)\n *\n * <Popover content={content} open={open}>\n * <Button onClick={() => startTransition(() => setOpen((isOpen) => !isOpen))} text=\"Toggle\" />\n * </Popover>\n * ```\n *\n * Wrap the state update itself: a `startTransition` around code that schedules the update for\n * later (a timeout) does not reach it.\n */\n open?: boolean\n overflow?: BoxOverflow\n padding?: number | number[]\n placement?: Placement\n /**\n * When 'flip' (default), the placement is determined from the initial placement and the\n * fallback placements in order. Whichever fits in the viewport first.\n *\n * When 'autoPlacement', the initial placement and all fallback placements are evaluated\n * and the placement with the most viewport space available.\n *\n * Option is only relevant if either `constrainSize` or `preventOverflow` is `true`\n */\n placementStrategy?: 'flip' | 'autoPlacement'\n /** Whether or not to render the popover in a portal element. */\n portal?: boolean | string\n preventOverflow?: boolean\n referenceBoundary?: HTMLElement | null\n /**\n * When defined, the popover will be positioned relative to this element.\n * The children of the popover won't be rendered.\n */\n referenceElement?: HTMLElement | null\n scheme?: ThemeColorSchemeKey\n tone?: CardTone\n /** @beta */\n updateRef?: Ref<PopoverUpdateCallback | undefined>\n width?: PopoverWidth | PopoverWidth[]\n}\n\n/**\n * The events on the reference element that count as intent to open the popover. Each precedes the\n * interaction that usually opens a popover: focus before a key press, the pointer entering before\n * a click or a tap.\n */\nconst INTENT_EVENT_TYPES = ['focusin', 'pointerenter', 'pointerdown'] as const\n\nconst ViewportOverlay = () => {\n const {zIndex} = useLayer()\n\n return (\n <div\n data-ui=\"PopoverOverlay\"\n style={{height: '100vh', inset: 0, position: 'fixed', width: '100vw', zIndex}}\n />\n )\n}\n\n/**\n * The `Popover` component is used to display some content on top of another.\n *\n * @public\n */\nexport function Popover(\n props: PopoverProps &\n Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'width'>,\n): React.JSX.Element {\n const {container, layer} = useTheme_v2()\n const boundaryElementContext = useBoundaryElement()\n\n const {\n __unstable_margins: margins = DEFAULT_POPOVER_MARGINS,\n animate: _animate = false,\n arrow: arrowProp = false,\n children: childProp,\n constrainSize = false,\n content,\n disabled,\n fallbackPlacements: _fallbackPlacements,\n matchReferenceWidth,\n floatingBoundary: _floatingBoundary,\n modal,\n // oxlint-disable-next-line no-unused-vars\n onActivate,\n open,\n overflow = 'hidden',\n padding: paddingProp,\n placement: placementProp = 'bottom',\n placementStrategy = 'flip',\n portal,\n preventOverflow = true,\n radius: radiusProp = 3,\n ref: forwardedRef,\n referenceBoundary: _referenceBoundary,\n referenceElement,\n scheme,\n shadow: shadowProp = 3,\n tone = 'inherit',\n width: widthProp = 'auto',\n zOffset: _zOffsetProp,\n updateRef,\n ...restProps\n } = props\n const fallbackPlacements =\n _fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom']\n const floatingBoundary = _floatingBoundary ?? boundaryElementContext.element\n const referenceBoundary = _referenceBoundary ?? boundaryElementContext.element\n // Max-width uses BoundaryElementProvider when present; otherwise the floating\n // boundary (same element the old `boundaryElement` prop used for both).\n const boundaryElement = boundaryElementContext.element ?? floatingBoundary\n const zOffsetProp = _zOffsetProp ?? layer.popover.zOffset\n const prefersReducedMotion = usePrefersReducedMotion()\n const animate = prefersReducedMotion ? false : _animate\n\n // Opening renders the popover whether or not any intent preceded it. A `disabled` popover\n // renders only its child, so neither `open` nor intent counts while it is disabled: otherwise\n // enabling it later would render it hidden without it ever having opened or been about to.\n const isOpen = Boolean(open) && !disabled\n\n const boundarySize = useBoundarySize(boundaryElement, isOpen)\n const padding = _getArrayProp(paddingProp)\n const radius = _getArrayProp(radiusProp)\n const shadow = _getArrayProp(shadowProp)\n const widthArrayProp = _getArrayProp(widthProp)\n const zOffset = _getArrayProp(zOffsetProp)\n const ref = useRef<HTMLDivElement | null>(null)\n const arrowRef = useRef<HTMLDivElement | null>(null)\n const rootBoundary: RootBoundary = 'viewport'\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)\n\n const mediaIndex = useMediaIndex()\n const boundaryWidth = constrainSize || preventOverflow ? boundarySize?.width : undefined\n\n // Update width when\n // - media index changes\n // - `width` property changes\n const width = calcCurrentWidth({\n container,\n mediaIndex,\n width: widthArrayProp,\n })\n const widthRef = useRef(width)\n\n useEffect(() => {\n widthRef.current = width\n }, [width])\n\n // Update max width when\n // - boundary width changes\n // - `width` property changes\n const maxWidth = calcMaxWidth({boundaryWidth, currentWidth: width})\n const maxWidthRef = useRef(maxWidth)\n\n useEffect(() => {\n maxWidthRef.current = maxWidth\n }, [maxWidth])\n\n // Keep track of reference element width (see `size` middleware below)\n const referenceWidthRef = useRef<number>(undefined)\n\n // Force apply width & max width to floating element\n useEffect(() => {\n const floatingElement = ref.current\n\n if (!open || !floatingElement) return\n\n const referenceWidth = referenceWidthRef.current\n\n if (matchReferenceWidth) {\n if (referenceWidth !== undefined) {\n floatingElement.style.width = `${referenceWidth}px`\n }\n } else if (width !== undefined) {\n floatingElement.style.width = `${width}px`\n }\n\n if (typeof maxWidth === 'number') {\n floatingElement.style.maxWidth = `${maxWidth}px`\n }\n }, [width, matchReferenceWidth, maxWidth, open])\n\n const [referenceWidth, setReferenceWidth] = useState<number | undefined>(undefined)\n const middleware = useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n constrainSize,\n fallbackPlacements,\n floatingBoundary,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n placementProp,\n placementStrategy,\n preventOverflow,\n referenceBoundary,\n referenceWidthRef,\n rootBoundary,\n setReferenceWidth,\n widthRef,\n })\n\n const {x, y, elements, middlewareData, placement, refs, strategy, update} =\n useFloating<HTMLElement>({\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: referenceElement\n ? {\n reference: referenceElement,\n }\n : undefined,\n })\n\n // Whether the popover (card, portal and `content`) has been rendered yet. Closed popovers\n // render inside a hidden `<Activity>`, so whatever is rendered while closed is pre-rendered DOM\n // that only pays off if the popover opens. Nothing is rendered until the popover opens or the\n // reference element shows intent to open it (see `INTENT_EVENT_TYPES`), and from then on it\n // stays rendered so the state of its `content` survives reopening. Consumers that do not want\n // a popover pre-rendered on intent can leave `content` empty until it opens.\n const [hasRendered, setHasRendered] = useState(false)\n\n if (isOpen && !hasRendered) setHasRendered(true)\n\n const shouldRender = isOpen || hasRendered\n // The element to listen to for intent to open the popover: none once the popover has rendered,\n // since there is nothing left to pre-render, and none while disabled, which also drops the\n // listeners of a popover that was enabled before\n const intentReference = shouldRender || disabled ? null : elements.reference\n\n useEffect(() => {\n if (!intentReference) return undefined\n\n const controller = new AbortController()\n const {signal} = controller\n // In a transition, so that it never holds up an open that follows right away (a click), and\n // so that React pre-renders the hidden popover in the background\n const handleIntent = () => startTransition(() => setHasRendered(true))\n\n // `focusin` rather than `focus` so that focus landing inside the reference element counts too.\n // `pointerdown` is a fallback for a pointer that was already over the element when it\n // rendered, which fires no `pointerenter`.\n for (const type of INTENT_EVENT_TYPES) {\n intentReference.addEventListener(type, handleIntent, {signal})\n }\n\n // Focus that landed before the listeners did (an `autoFocus` reference, a `referenceElement`\n // that was focused already) fired its `focusin` unheard, so count it now\n const {activeElement} = intentReference.ownerDocument\n\n if (activeElement && intentReference.contains(activeElement)) handleIntent()\n\n return () => controller.abort()\n }, [intentReference])\n\n const referenceHidden = middlewareData.hide?.referenceHidden\n\n const arrowX = middlewareData.arrow?.x\n const arrowY = middlewareData.arrow?.y\n\n const originX = middlewareData['@sanity/ui/origin']?.originX\n const originY = middlewareData['@sanity/ui/origin']?.originY\n\n const setArrow = useCallback((arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n }, [])\n\n const setFloating = useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n },\n [refs],\n )\n\n // If there's a child then we need to set the reference element to the cloned child ref\n // and if child changes we make sure to update or remove the reference element.\n useImperativeHandle(childProp ? getElementRef(childProp) : null, () => refs.reference.current)\n\n const child = useMemo(() => {\n // If a reference element is defined, we don't need to clone the child\n if (referenceElement) return childProp\n\n if (!childProp) return null\n\n return cloneElement(childProp, {ref: refs.setReference})\n }, [childProp, referenceElement, refs.setReference])\n\n useImperativeHandle(updateRef, () => update, [update])\n\n if (disabled) {\n return childProp || <></>\n }\n\n const popover = (\n <LayerProvider zOffset={zOffset}>\n {/* Optional transparent blocking overlay at the top-most z-index layer. Must be positioned before the below popover card. */}\n {modal && <ViewportOverlay />}\n\n <PopoverCard\n {...restProps}\n __unstable_margins={margins}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n hidden={referenceHidden}\n overflow={overflow}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n originX={originX}\n originY={originY}\n strategy={strategy}\n tone={tone}\n width={matchReferenceWidth ? referenceWidth : width}\n x={x}\n y={y}\n >\n {content}\n </PopoverCard>\n </LayerProvider>\n )\n\n const popoverNode = portal ? (\n <Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>{popover}</Portal>\n ) : (\n popover\n )\n\n return (\n <>\n {/* the popover (not rendered until it opens or is about to, see `hasRendered`) */}\n {animate ? (\n <AnimateActivity layoutMode=\"default\" mode={open ? 'visible' : 'hidden'}>\n {shouldRender ? popoverNode : null}\n </AnimateActivity>\n ) : (\n <Activity mode={open ? 'visible' : 'hidden'}>{shouldRender ? popoverNode : null}</Activity>\n )}\n\n {/* the referred element */}\n {child}\n </>\n )\n}\n\n/**\n * The border-box size of the boundary element in whole pixels, tracked only while the popover is\n * open.\n *\n * Closed popovers have nothing to size, so they hold no `ResizeObserver` subscription and do not\n * re-render when the boundary resizes (one subscription per popover, every closed popover\n * re-rendering on every boundary resize, is what this replaces). The boundary is measured\n * synchronously in a layout effect when the popover opens, so the max width is right in the first\n * painted frame instead of one `ResizeObserver` callback later; the shared observer takes over\n * from there. The last size is kept while closed.\n *\n * Both measurements are rounded to whole pixels so that they agree: the observer's first delivery\n * must not change the size the opening commit measured, or the max width would be corrected a\n * frame later after all. See `measureBorderBox`.\n */\nfunction useBoundarySize(element: HTMLElement | null, open: boolean): ElementRectValue | undefined {\n const [size, setSize] = useState<ElementRectValue | undefined>(undefined)\n\n useLayoutEffect(() => {\n if (!open || !element) return undefined\n\n // Measuring the boundary is what this effect is for: the DOM is only measurable after the\n // commit, and the result has to be in the next paint\n // oxlint-disable-next-line react/set-state-in-effect\n setSize((prev) => sameSize(prev, measureBorderBox(element)))\n\n return _elementSizeObserver.subscribe(element, ({border}) =>\n setSize((prev) =>\n sameSize(prev, {width: Math.round(border.width), height: Math.round(border.height)}),\n ),\n )\n }, [element, open])\n\n return size\n}\n\n/**\n * The border-box size of an element in whole pixels, the way `_elementSizeObserver` reports it:\n * from `ResizeObserverEntry.borderBoxSize`, which is the layout size with no CSS transform or\n * `zoom` applied, in the element's writing mode (`inlineSize` as `width`, `blockSize` as\n * `height`), rounded by `useBoundarySize`. `offsetWidth`/`offsetHeight` are that same untransformed\n * border box rounded to whole pixels. `getBoundingClientRect` would include transforms (a boundary\n * mid scale animation) and `zoom`, and `getComputedStyle` serializes lengths with limited\n * precision, so neither agrees with the observer for every element.\n *\n * Kept at module scope on purpose: reading the offset size forces a synchronous layout, and the\n * React Compiler (which the package build runs) lifts a member expression on an element captured\n * by a component callback into a memo dependency evaluated during render. A plain function call\n * on the element gives it nothing to lift.\n */\nfunction measureBorderBox(element: HTMLElement): ElementRectValue {\n const {offsetWidth, offsetHeight} = element\n\n if (getComputedStyle(element).writingMode.startsWith('horizontal')) {\n return {width: offsetWidth, height: offsetHeight}\n }\n\n // In a vertical writing mode the inline size is the physical height\n return {width: offsetHeight, height: offsetWidth}\n}\n\n/** Keeps the previous object when the size has not changed, so `setState` bails out */\nfunction sameSize(prev: ElementRectValue | undefined, next: ElementRectValue): ElementRectValue {\n return prev && prev.width === next.width && prev.height === next.height ? prev : next\n}\n\nfunction useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n constrainSize,\n fallbackPlacements,\n floatingBoundary,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n placementProp,\n placementStrategy,\n preventOverflow,\n referenceBoundary,\n referenceWidthRef,\n rootBoundary,\n setReferenceWidth,\n widthRef,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n constrainSize: boolean\n fallbackPlacements: Placement[]\n floatingBoundary: HTMLElement | null\n margins: PopoverMargins\n matchReferenceWidth: boolean | undefined\n maxWidthRef: React.RefObject<number | undefined>\n placementProp: Placement\n placementStrategy: 'flip' | 'autoPlacement'\n preventOverflow: boolean\n referenceBoundary: HTMLElement | null\n referenceWidthRef: React.RefObject<number | undefined>\n rootBoundary: RootBoundary\n setReferenceWidth: (referenceWidth: number) => void\n widthRef: React.RefObject<number | undefined>\n}) {\n return useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n if (constrainSize || preventOverflow) {\n if (placementStrategy === 'autoPlacement') {\n ret.push(\n autoPlacement({\n allowedPlacements: [placementProp].concat(fallbackPlacements),\n }),\n )\n } else {\n ret.push(\n flip({\n boundary: floatingBoundary || undefined,\n fallbackPlacements,\n padding: DEFAULT_POPOVER_PADDING,\n rootBoundary,\n }),\n )\n }\n }\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_POPOVER_DISTANCE}))\n\n // Track sizes\n if (constrainSize || matchReferenceWidth) {\n ret.push(\n size({\n boundaryElement: floatingBoundary || undefined,\n constrainSize,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n padding: DEFAULT_POPOVER_PADDING,\n referenceWidthRef,\n setReferenceWidth,\n widthRef,\n }),\n )\n }\n\n // Shift the popover so its sits within the boundary element\n if (preventOverflow) {\n ret.push(\n shift({\n boundary: floatingBoundary || undefined,\n rootBoundary,\n padding: DEFAULT_POPOVER_PADDING,\n }),\n )\n }\n\n // Place arrow\n if (arrowProp) {\n ret.push(\n arrow({\n element: arrowRef,\n padding: DEFAULT_POPOVER_PADDING,\n }),\n )\n }\n\n // Determine the origin to scale from.\n // Must be placed after `@sanity/ui/size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n ret.push(\n hide({\n boundary: referenceBoundary || undefined,\n padding: DEFAULT_POPOVER_PADDING,\n strategy: 'referenceHidden',\n }),\n )\n\n return ret\n }, [\n animate,\n arrowProp,\n arrowRef,\n constrainSize,\n fallbackPlacements,\n floatingBoundary,\n margins,\n matchReferenceWidth,\n maxWidthRef,\n placementProp,\n placementStrategy,\n preventOverflow,\n referenceBoundary,\n referenceWidthRef,\n rootBoundary,\n setReferenceWidth,\n widthRef,\n ])\n}\n"],"mappings":";;;;;;;;;;;;AAQA,MAAa,0BAA0C;CAAC;CAAG;CAAG;CAAG;AAAC,GACrD,8BAA8D;CACzE4F,KAAO;EAAC;EAAU;EAAQ;CAAO;CACjC,aAAa;EAAC;EAAgB;EAAc;CAAa;CACzD,WAAW;EAAC;EAAc;EAAY;CAAW;CACjDC,QAAU;EAAC;EAAO;EAAQ;CAAO;CACjC,gBAAgB;EAAC;EAAa;EAAc;CAAa;CACzD,cAAc;EAAC;EAAW;EAAY;CAAW;CACjDC,MAAQ;EAAC;EAAS;EAAO;CAAQ;CACjC,cAAc;EAAC;EAAe;EAAa;CAAc;CACzD,YAAY;EAAC;EAAa;EAAW;CAAY;CACjDC,OAAS;EAAC;EAAQ;EAAO;CAAQ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