{"version":3,"file":"SentimentSurface.mjs","sources":["../../src/sentimentSurface/SentimentSurface.tsx"],"sourcesContent":["import { forwardRef, ElementType, ForwardedRef } from 'react';\nimport { clsx } from 'clsx';\n\nimport {\n  SentimentSurfaceComponentProps,\n  SentimentSurfaceComponent,\n} from './SentimentSurface.types';\nimport { useTheme } from '@wise/components-theming';\n\n/**\n * SentimentSurface is a polymorphic container component that exposes and, optionally, applies\n * contextual colour tokens as CSS custom properties, based on sentiment types (`negative`,\n * `warning`, `neutral`, `success`, `proposition`).\n *\n * @param {ElementType} [as='div'] - Optional prop to override the HTML element rendered.\n * @param {Sentiment} sentiment - Required prop to set the sentiment type (negative, warning, neutral, success, proposition).\n * @param {Emphasis} [emphasis='base'] - Optional prop to specify the emphasis level (base or elevated).\n * @param {boolean} [hasBaseStyles=true] - If true, sets the `background-color` and `color` on the container. Otherwise, only exposes the tokens as CSS custom properties without rendering.\n * @param {ReactNode} [children] - Content to render inside the surface.\n * @param {string} [className] - Additional CSS classes to apply.\n * @param {CSSProperties} [style] - Inline styles to apply.\n * @param {string} [id] - Unique identifier for the component.\n * @param {string} [data-testid] - A unique string that appears as data attribute `data-testid` in the rendered code.\n *\n * @component\n * @example\n * ```tsx\n * // Basic usage with negative sentiment\n * <SentimentSurface sentiment=\"negative\">\n *   Your payment has failed\n * </SentimentSurface>\n * ```\n *\n * @see {@link SentimentSurface} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/sentiment-surface--docs|Storybook Wise Design}\n */\n// @ts-expect-error - Generic forwardRef limitation. See: https://fettblog.eu/typescript-react-generic-forward-refs/\nconst SentimentSurface: SentimentSurfaceComponent = forwardRef(function SentimentSurface<\n  T extends ElementType = 'div',\n>(\n  {\n    as,\n    sentiment,\n    emphasis = 'base',\n    hasBaseStyles = true,\n    style,\n    className,\n    children,\n    id,\n    'data-testid': dataTestId,\n    ...props\n  }: SentimentSurfaceComponentProps<T>,\n  ref: ForwardedRef<HTMLElement>,\n) {\n  const Element = as ?? 'div';\n  const BASE_CLASS = 'wds-sentiment-surface';\n  const { className: closestBrandTheme } = useTheme();\n  const classNames = clsx(\n    closestBrandTheme,\n    BASE_CLASS,\n    `${BASE_CLASS}-${sentiment}-${emphasis}`,\n    hasBaseStyles && `${BASE_CLASS}--hasBaseStyles`,\n    className,\n  );\n  const sentimentProps = {\n    ref,\n    id,\n    'data-testid': dataTestId,\n    className: classNames,\n    style,\n    ...props,\n  };\n\n  return (\n    // @ts-expect-error - Generic forwardRef limitation. See: https://fettblog.eu/typescript-react-generic-forward-refs/\n    <Element {...sentimentProps}>{children}</Element>\n  );\n});\n\nSentimentSurface.displayName = 'SentimentSurface';\n\nexport default SentimentSurface;\n"],"names":["SentimentSurface","forwardRef","as","sentiment","emphasis","hasBaseStyles","style","className","children","id","dataTestId","props","ref","Element","BASE_CLASS","closestBrandTheme","useTheme","classNames","clsx","sentimentProps","_jsx","displayName"],"mappings":";;;;;AAqCA,MAAMA,gBAAgB,gBAA8BC,UAAU,CAAC,SAASD,gBAAgBA,CAGtF;EACEE,EAAE;EACFC,SAAS;AACTC,EAAAA,QAAQ,GAAG,MAAM;AACjBC,EAAAA,aAAa,GAAG,IAAI;EACpBC,KAAK;EACLC,SAAS;EACTC,QAAQ;EACRC,EAAE;AACF,EAAA,aAAa,EAAEC,UAAU;EACzB,GAAGC;AAAK,CAC0B,EACpCC,GAA8B,EAAA;AAE9B,EAAA,MAAMC,OAAO,GAAGX,EAAE,IAAI,KAAK;EAC3B,MAAMY,UAAU,GAAG,uBAAuB;EAC1C,MAAM;AAAEP,IAAAA,SAAS,EAAEQ;GAAmB,GAAGC,QAAQ,EAAE;EACnD,MAAMC,UAAU,GAAGC,IAAI,CACrBH,iBAAiB,EACjBD,UAAU,EACV,CAAA,EAAGA,UAAU,CAAA,CAAA,EAAIX,SAAS,CAAA,CAAA,EAAIC,QAAQ,CAAA,CAAE,EACxCC,aAAa,IAAI,GAAGS,UAAU,CAAA,eAAA,CAAiB,EAC/CP,SAAS,CACV;AACD,EAAA,MAAMY,cAAc,GAAG;IACrBP,GAAG;IACHH,EAAE;AACF,IAAA,aAAa,EAAEC,UAAU;AACzBH,IAAAA,SAAS,EAAEU,UAAU;IACrBX,KAAK;IACL,GAAGK;GACJ;AAED,EAAA;AAAA;AACE;AACAS,IAAAA,GAAA,CAACP,OAAO,EAAA;AAAA,MAAA,GAAKM,cAAc;AAAAX,MAAAA,QAAA,EAAGA;KAAkB;AAAC;AAErD,CAAC;AAEDR,gBAAgB,CAACqB,WAAW,GAAG,kBAAkB;;;;"}