UNPKG

@payfit/unity-components

Version:

58 lines (57 loc) 2.1 kB
import { ReactNode } from 'react'; import { PopoverProps as AriaPopoverProps } from 'react-aria-components/Popover'; import { DialogTrigger } from 'react-aria-components/Dialog'; interface PopoverBaseProps extends Omit<AriaPopoverProps, 'className' | 'style'> { /** * The content to be displayed inside the popover. */ children: ReactNode; /** * Title text to be displayed in the header and used as the Popover's label. */ title: string; } interface PopoverPropsWithVisibleTitle extends PopoverBaseProps { /** * If true, the title will not be shown on the screen but will still be accessible to screen readers * @default false */ isTitleSrOnly?: false; /** * Whether the popover can be dismissed with a close button. * If true, a close button will be added to the popover header. * @default false */ displayCloseButton?: boolean; } interface PopoverPropsWithHiddenTitle extends PopoverBaseProps { /** * If true, the title will not be shown on the screen but will still be accessible to screen readers * @default false */ isTitleSrOnly: true; /** * Whether the popover can be dismissed with a close button. * If true, a close button will be added to the popover header. * @default false */ displayCloseButton?: false; } type PopoverProps = PopoverPropsWithVisibleTitle | PopoverPropsWithHiddenTitle; /** * The `Popover` component renders a floating container that appears when a user interacts with a trigger element. * Use it to display additional information or actions without navigating away from the current context. * @example * ```tsx * import { Popover, PopoverTrigger, Button } from '@payfit/unity-components' * * <PopoverTrigger> * <Button>Open Popover</Button> * <Popover> * <p>Popover content goes here</p> * </Popover> * </PopoverTrigger> * ``` */ declare const Popover: import('react').ForwardRefExoticComponent<PopoverProps & import('react').RefAttributes<HTMLDivElement>>; export { Popover, DialogTrigger as PopoverTrigger };