import { Cross } from '@transferwise/icons'; import { clsx } from 'clsx'; import SentimentSurface, { Emphasis, Sentiment } from '../../SentimentSurface'; import IconButton, { type IconButtonProps } from '../../IconButton'; import { useIntl } from 'react-intl'; import closeBtnMessages from '../../common/CloseButton/CloseButton.messages'; import { forwardRef, HTMLAttributes, ReactNode } from 'react'; export type PrimitivePromptProps = HTMLAttributes & { /** * The sentiment determines the colour scheme. * @default success */ sentiment?: Sentiment; /** * The emphasis level affecting background and text contrast. * @default 'base' */ emphasis?: Emphasis; /** * Media to be displayed on the prompt (icon/image/etc). */ media: ReactNode; /** * Any actions to be displayed on the prompt. */ actions?: ReactNode; /** * Handler called when the close button is clicked. If not provided, then the close button is hidden. */ onDismiss?: () => void; /** * The priority of the dismiss IconButton. * @default 'secondary' */ dismissButtonPriority?: IconButtonProps['priority']; /** * Test ID for testing tools */ 'data-testid'?: string; }; /** * PrimitivePrompt is a low-level component that provides the structure, sentiment support and styling for various prompts. * Uses several css variables to handle styling from within the consuming component, e.g. --Prompt-padding-x. */ export const PrimitivePrompt = forwardRef( ( { sentiment = 'success', emphasis = 'base', media, actions, onDismiss, dismissButtonPriority = 'secondary', className, children, ...restProps }, ref, ) => { const intl = useIntl(); return (
{media}
{children} {onDismiss && ( )} {actions &&
{actions}
}
); }, ); PrimitivePrompt.displayName = 'PrimitivePrompt';