import { IconStringList } from '../Icons/Icon.models'; import { TooltipProps } from '../Tooltip/Tooltip'; import { ButtonConfirmationPopoverProps, ConfirmationItem } from './ButtonComponents/ConfirmationButton'; type ChildrenOrIconProps = { /** Content inside of the Button */ children: React.ReactNode; icon?: never; } | (IconProps & { children?: never; }); type BaseProps = ChildrenOrIconProps & { /** Optional class for the Button */ className?: string; /** Style of the Button */ styleType?: 'primary' | 'secondary' | 'tertiary' | 'primary-red' | 'primary-green' | 'primary-blue' | 'primary-black' | 'text-red' | 'text-blue'; /** Optional prop for disabling button */ disabled?: boolean; tooltip?: Omit; /** Optionally use the red "destructive" variation of the Button */ destructive?: boolean; /** Optional prop to add a test id to the Button for QA testing */ qaTestId?: string; }; export type ButtonAsButton = BaseProps & Omit & { /** Type of Button */ as?: 'button'; confirmation?: never; tippyProps?: never; popoverProps?: never; routerComponent?: never; }; export type ButtonAsUnstyled = Omit & { /** Type of Button */ as: 'unstyled'; styleType?: BaseProps['styleType']; confirmation?: never; tippyProps?: never; popoverProps?: never; routerComponent?: never; }; type RouterProps = Omit & { /** Router component (e.g. Using Link from react-router-dom) */ routerComponent: React.ElementType; /** Allow any props to be passed in */ [key: string]: unknown; }; export type ButtonAsLink = BaseProps & RouterProps & { /** Type of Button */ as: 'link'; confirmation?: never; tippyProps?: never; popoverProps?: never; }; export type ButtonAsExternal = BaseProps & Omit & { /** Type of Button */ as: 'externalLink'; confirmation?: never; tippyProps?: never; popoverProps?: never; routerComponent?: never; }; export type ButtonAsConfirmation = BaseProps & { /** Type of Button */ as: 'confirmation'; confirmation: ConfirmationItem; popoverProps?: ButtonConfirmationPopoverProps; routerComponent?: never; }; type OmitFromTypes = 'className' | 'styleType' | 'as'; export declare function isLinkProps(maybeLinkProps: unknown): maybeLinkProps is Omit; export declare function isButtonProps(maybeButtonProps: unknown): maybeButtonProps is Omit; export declare function isAnchorProps(maybeAnchorProps: unknown): maybeAnchorProps is Omit; export type IconProps = { /** The icon to be shown in the button */ icon: IconStringList; /** This boolean is used to style the icon red if the button is a destructive action. */ destructive?: boolean; }; export type ButtonProps = ButtonAsButton | ButtonAsExternal | ButtonAsLink | ButtonAsUnstyled | ButtonAsConfirmation; export {};