import type { PopoverContentProps } from "@radix-ui/react-popover"; import type { HTMLAttributes, ReactElement, ReactNode } from "react"; export type PopoverLocale = { dismissText?: string; }; interface PopoverPropsBase extends Omit, "title" | "content" | "aria-label"> { /** * Defines the trigger element of the `Popover`. * It should be a button element. */ children: ReactElement; /** * Defines the subtitle of the `Popover`. */ subtitle?: ReactNode; /** * Defines the content of the `Popover`. */ content: ReactNode; /** * Defines the footer of the `Popover`. */ footer?: ReactNode; /** * Defines whether the `Popover` should be opened or not. */ open?: boolean; /** * Defines the event handler called when the `Popover` is dismissed. */ onDismiss?: () => void; /** * Defines the side of the trigger element where the `Popover` should be displayed. * Will be reversed when collisions occur and `avoidCollisions` is enabled. * @default "top" */ side?: PopoverContentProps["side"]; /** * Defines the offset in pixels of the `Popover` from the trigger element. */ sideOffset?: PopoverContentProps["sideOffset"]; /** * Defines the preferred alignment of the `Popover` against the trigger element. * May change when collisions occur. */ align?: PopoverContentProps["align"]; /** * Defines the offset in pixels of the `Popover` along the trigger element. * It only works when the `align` option is set to "start" or "end". */ alignOffset?: PopoverContentProps["alignOffset"]; /** * Defines whether the `Popover` arrow should be hidden. */ noArrow?: boolean; /** * Defines whether the `Popover` close button should be hidden. */ noCloseButton?: boolean; /** * Defines whether the `Popover` should avoid collisions with the viewport. */ avoidCollisions?: boolean; /** * The element that should receive focus once the `Popover` is opened. * If unspecified, the first focusable element will be focused. * If an element is passed, it will be focused. * If `false`, no element will be focused automatically for you. You should manage focus yourself. * If 'skipContent' is passed, the close button will be focused. */ autoFocusOnOpenElement?: HTMLElement | null | false | "skipContent"; /** * Defines the locale of the `Popover`. */ locale?: PopoverLocale; /** * Used to force mounting when more control is needed. */ forceMount?: true | undefined; } type PopoverPropsWithTitle = { /** * Defines the title of the `Popover`. */ title: ReactNode; /** * Defines the aria-label of the `Popover`. */ "aria-label"?: string; } & PopoverPropsBase; type PopoverPropsWithAriaLabel = { /** * Defines the title of the `Popover`. */ title?: undefined; /** * Defines the aria-label of the `Popover`. */ "aria-label": string; } & PopoverPropsBase; export type PopoverProps = PopoverPropsWithTitle | PopoverPropsWithAriaLabel; export {};