{"version":3,"file":"HoverCard.cjs","names":["useProps","useHoverCard","HoverCardContext","Popover","HoverCardTarget","HoverCardDropdown","HoverCardGroup"],"sources":["../../../src/components/HoverCard/HoverCard.tsx"],"sourcesContent":["import { ExtendComponent, Factory, useProps } from '../../core';\nimport { Popover, PopoverProps, PopoverStylesNames } from '../Popover';\nimport { PopoverCssVariables } from '../Popover/Popover';\nimport { HoverCardContext, HoverCardContextValue } from './HoverCard.context';\nimport { HoverCardDropdown, HoverCardDropdownProps } from './HoverCardDropdown/HoverCardDropdown';\nimport {\n  HoverCardGroup,\n  HoverCardGroupContextValue,\n  HoverCardGroupProps,\n} from './HoverCardGroup/HoverCardGroup';\nimport { HoverCardTarget, HoverCardTargetProps } from './HoverCardTarget/HoverCardTarget';\nimport { useHoverCard } from './use-hover-card';\n\nexport interface HoverCardEvents {\n  /** Determines whether the dropdown should be opened when the target is hovered @default true */\n  hover?: boolean;\n\n  /** Determines whether the dropdown should be opened when the target is focused with the keyboard @default true */\n  focus?: boolean;\n\n  /** Determines whether the dropdown should be opened when the target is tapped on touch devices. Requires `hover` to be enabled @default false */\n  touch?: boolean;\n}\n\nexport interface HoverCardProps extends Omit<PopoverProps, 'opened' | 'onChange'> {\n  /** Initial opened state */\n  initiallyOpened?: boolean;\n\n  /** Called when the dropdown is opened */\n  onOpen?: () => void;\n\n  /** Called when the dropdown is closed */\n  onClose?: () => void;\n\n  /**\n   * Delay in ms before the dropdown opens after mouse enters the target.\n   * Overridden by HoverCard.Group delay if used within a group.\n   * @default 0\n   */\n  openDelay?: number;\n\n  /**\n   * Delay in ms before the dropdown closes after mouse leaves the target or dropdown.\n   * Overridden by HoverCard.Group delay if used within a group.\n   * @default 150\n   */\n  closeDelay?: number;\n\n  /**\n   * Determines which events open the dropdown. Fields that are not specified keep their default values.\n   * @default { hover: true, focus: true, touch: false }\n   */\n  events?: HoverCardEvents;\n\n  /**\n   * If set, the dropdown stays open while the pointer travels from the target to the dropdown\n   * and remains over it. Set it if the dropdown contains interactive content.\n   * @default false\n   */\n  interactive?: boolean;\n\n  /**\n   * Accessible relation between the target and the dropdown. `dialog` sets `aria-haspopup`,\n   * `aria-expanded` and `aria-controls` on the target, `tooltip` sets `aria-describedby` instead\n   * and should be used if the dropdown contains only descriptive content.\n   * @default 'dialog'\n   */\n  role?: 'dialog' | 'tooltip';\n\n  /** Determines whether the dropdown should be closed when the user presses outside of the target and the dropdown @default true */\n  closeOnClickOutside?: boolean;\n\n  /** Not supported by `HoverCard`: outside press is always detected with the `pointerdown` event. Use `closeOnClickOutside` to disable it. */\n  clickOutsideEvents?: string[];\n\n  /**\n   * Determines whether focus should be returned to the target when the dropdown closes.\n   * Ignored when focus activation is enabled (`events.focus`, the default), otherwise moving\n   * focus away from the target would return it and reopen the dropdown.\n   * `Escape` pressed inside the dropdown always returns focus to the target.\n   * @default false\n   */\n  returnFocus?: boolean;\n\n  /** Called when the dropdown is closed with `Escape` key or with a press outside of the target and the dropdown */\n  onDismiss?: () => void;\n}\n\nexport type HoverCardFactory = Factory<{\n  props: HoverCardProps;\n  stylesNames: PopoverStylesNames;\n  vars: PopoverCssVariables;\n}>;\n\nconst DEFAULT_EVENTS = { hover: true, focus: true, touch: false };\n\nconst defaultProps = {\n  openDelay: 0,\n  closeDelay: 150,\n  initiallyOpened: false,\n  interactive: false,\n  closeOnEscape: true,\n  closeOnClickOutside: true,\n  role: 'dialog',\n} satisfies Partial<HoverCardProps>;\n\nexport function HoverCard(props: HoverCardProps) {\n  const {\n    children,\n    onOpen,\n    onClose,\n    openDelay,\n    closeDelay,\n    initiallyOpened,\n    events,\n    interactive,\n    closeOnEscape,\n    closeOnClickOutside,\n    returnFocus,\n    onDismiss,\n    id,\n    role,\n    withRoles,\n    ...others\n  } = useProps('HoverCard', defaultProps, props);\n\n  const resolvedEvents = { ...DEFAULT_EVENTS, ...events };\n  const rolesEnabled = withRoles !== false;\n\n  const hoverCard = useHoverCard({\n    openDelay,\n    closeDelay,\n    defaultOpened: initiallyOpened,\n    onOpen,\n    onClose,\n    events: resolvedEvents,\n    interactive,\n    closeOnEscape,\n    closeOnClickOutside,\n    onDismiss,\n    id,\n  });\n\n  return (\n    <HoverCardContext\n      value={{\n        openDropdown: hoverCard.openDropdown,\n        closeDropdown: hoverCard.closeDropdown,\n        assignTarget: hoverCard.assignTarget,\n        getReferenceProps: hoverCard.getReferenceProps,\n        getFloatingProps: hoverCard.getFloatingProps,\n        reference: hoverCard.reference,\n        floating: hoverCard.floating,\n        opened: hoverCard.opened!,\n        dropdownId: hoverCard.dropdownId,\n        role,\n        withRoles: rolesEnabled,\n      }}\n    >\n      <Popover\n        {...others}\n        id={id}\n        closeOnEscape={closeOnEscape}\n        closeOnClickOutside={closeOnClickOutside}\n        returnFocus={resolvedEvents.focus ? false : returnFocus}\n        withRoles={role === 'tooltip' ? false : withRoles}\n        opened={hoverCard.opened}\n        __staticSelector=\"HoverCard\"\n      >\n        {children}\n      </Popover>\n    </HoverCardContext>\n  );\n}\n\nHoverCard.displayName = '@mantine/core/HoverCard';\nHoverCard.Target = HoverCardTarget;\nHoverCard.Dropdown = HoverCardDropdown;\nHoverCard.Group = HoverCardGroup;\nHoverCard.extend = (input: ExtendComponent<HoverCardFactory>) => input;\n\nexport namespace HoverCard {\n  export type Props = HoverCardProps;\n  export type Events = HoverCardEvents;\n  export type DropdownProps = HoverCardDropdownProps;\n  export type TargetProps = HoverCardTargetProps;\n  export type GroupProps = HoverCardGroupProps;\n  export type ContextValue = HoverCardContextValue;\n\n  export namespace Group {\n    export type Props = HoverCardGroupProps;\n    export type ContextValue = HoverCardGroupContextValue;\n  }\n}\n"],"mappings":";;;;;;;;;;AA8FA,MAAM,iBAAiB;CAAE,OAAO;CAAM,OAAO;CAAM,OAAO;AAAM;AAEhE,MAAM,eAAe;CACnB,WAAW;CACX,YAAY;CACZ,iBAAiB;CACjB,aAAa;CACb,eAAe;CACf,qBAAqB;CACrB,MAAM;AACR;AAEA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,EACJ,UACA,QACA,SACA,WACA,YACA,iBACA,QACA,aACA,eACA,qBACA,aACA,WACA,IACA,MACA,WACA,GAAG,WACDA,kBAAAA,SAAS,aAAa,cAAc,KAAK;CAE7C,MAAM,iBAAiB;EAAE,GAAG;EAAgB,GAAG;CAAO;CACtD,MAAM,eAAe,cAAc;CAEnC,MAAM,YAAYC,uBAAAA,aAAa;EAC7B;EACA;EACA,eAAe;EACf;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,0BAAAA,kBAAD;EACE,OAAO;GACL,cAAc,UAAU;GACxB,eAAe,UAAU;GACzB,cAAc,UAAU;GACxB,mBAAmB,UAAU;GAC7B,kBAAkB,UAAU;GAC5B,WAAW,UAAU;GACrB,UAAU,UAAU;GACpB,QAAQ,UAAU;GAClB,YAAY,UAAU;GACtB;GACA,WAAW;EACb;EAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,gBAAAA,SAAD;GACE,GAAI;GACA;GACW;GACM;GACrB,aAAa,eAAe,QAAQ,QAAQ;GAC5C,WAAW,SAAS,YAAY,QAAQ;GACxC,QAAQ,UAAU;GAClB,kBAAiB;GAEhB;EACM,CAAA;CACO,CAAA;AAEtB;AAEA,UAAU,cAAc;AACxB,UAAU,SAASC,wBAAAA;AACnB,UAAU,WAAWC,0BAAAA;AACrB,UAAU,QAAQC,uBAAAA;AAClB,UAAU,UAAU,UAA6C"}