{"version":3,"file":"PrimitivePrompt.mjs","sources":["../../../src/Prompt/PrimitivePrompt/PrimitivePrompt.tsx"],"sourcesContent":["import { Cross } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport SentimentSurface, { Emphasis, Sentiment } from '../../SentimentSurface';\nimport IconButton, { type IconButtonProps } from '../../IconButton';\nimport { useIntl } from 'react-intl';\nimport closeBtnMessages from '../../common/CloseButton/CloseButton.messages';\nimport { forwardRef, HTMLAttributes, ReactNode } from 'react';\n\nexport type PrimitivePromptProps = HTMLAttributes<HTMLDivElement> & {\n  /**\n   * The sentiment determines the colour scheme.\n   * @default success\n   */\n  sentiment?: Sentiment;\n  /**\n   * The emphasis level affecting background and text contrast.\n   * @default 'base'\n   */\n  emphasis?: Emphasis;\n  /**\n   * Media to be displayed on the prompt (icon/image/etc).\n   */\n  media: ReactNode;\n  /**\n   * Any actions to be displayed on the prompt.\n   */\n  actions?: ReactNode;\n  /**\n   * Handler called when the close button is clicked. If not provided, then the close button is hidden.\n   */\n  onDismiss?: () => void;\n  /**\n   * The priority of the dismiss IconButton.\n   * @default 'secondary'\n   */\n  dismissButtonPriority?: IconButtonProps['priority'];\n  /**\n   * Test ID for testing tools\n   */\n  'data-testid'?: string;\n};\n\n/**\n * PrimitivePrompt is a low-level component that provides the structure, sentiment support and styling for various prompts.\n * Uses several css variables to handle styling from within the consuming component, e.g. --Prompt-padding-x. */\nexport const PrimitivePrompt = forwardRef<HTMLDivElement, PrimitivePromptProps>(\n  (\n    {\n      sentiment = 'success',\n      emphasis = 'base',\n      media,\n      actions,\n      onDismiss,\n      dismissButtonPriority = 'secondary',\n      className,\n      children,\n      ...restProps\n    },\n    ref,\n  ) => {\n    const intl = useIntl();\n\n    return (\n      <SentimentSurface\n        // @ts-expect-error - SentimentSurface forwardRef types don't expose ref in props\n        ref={ref}\n        sentiment={sentiment}\n        emphasis={emphasis}\n        className={clsx('wds-prompt', `wds-prompt--${sentiment}`, className)}\n        {...restProps}\n      >\n        <div\n          className={clsx('wds-prompt__content-wrapper', {\n            'wds-prompt__content-wrapper--with-dismiss': !!onDismiss,\n          })}\n        >\n          <div className={clsx('wds-prompt__media-wrapper')}>{media}</div>\n          {children}\n          {onDismiss && (\n            <IconButton\n              size={24}\n              priority={dismissButtonPriority}\n              aria-label={intl.formatMessage(closeBtnMessages.ariaLabel)}\n              className=\"wds-prompt__dismiss\"\n              onClick={onDismiss}\n            >\n              <Cross />\n            </IconButton>\n          )}\n          {actions && <div className=\"wds-prompt__actions-wrapper\">{actions}</div>}\n        </div>\n      </SentimentSurface>\n    );\n  },\n);\n\nPrimitivePrompt.displayName = 'PrimitivePrompt';\n"],"names":["PrimitivePrompt","forwardRef","sentiment","emphasis","media","actions","onDismiss","dismissButtonPriority","className","children","restProps","ref","intl","useIntl","_jsx","SentimentSurface","clsx","_jsxs","IconButton","size","priority","formatMessage","closeBtnMessages","ariaLabel","onClick","Cross","displayName"],"mappings":";;;;;;;;;AA6CO,MAAMA,eAAe,gBAAGC,UAAU,CACvC,CACE;AACEC,EAAAA,SAAS,GAAG,SAAS;AACrBC,EAAAA,QAAQ,GAAG,MAAM;EACjBC,KAAK;EACLC,OAAO;EACPC,SAAS;AACTC,EAAAA,qBAAqB,GAAG,WAAW;EACnCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AAAS,CACb,EACDC,GAAG,KACD;AACF,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE;AAEtB,EAAA,oBACEC,GAAA,CAACC;AACC;AAAA,IAAA;AACAJ,IAAAA,GAAG,EAAEA,GAAI;AACTT,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,QAAQ,EAAEA,QAAS;IACnBK,SAAS,EAAEQ,IAAI,CAAC,YAAY,EAAE,eAAed,SAAS,CAAA,CAAE,EAAEM,SAAS,CAAE;AAAA,IAAA,GACjEE,SAAS;AAAAD,IAAAA,QAAA,eAEbQ,IAAA,CAAA,KAAA,EAAA;AACET,MAAAA,SAAS,EAAEQ,IAAI,CAA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