{"version":3,"file":"Text-CDVWihJo.cjs","sources":["../src/components/Text/Text.tsx"],"sourcesContent":["'use client';\nimport { forwardRef, createElement } from 'react';\nimport type {\n  ComponentPropsWithoutRef,\n  ElementType,\n  ForwardedRef,\n  ReactElement,\n} from 'react';\nimport { withSx } from '../../utils/withSx';\nimport type { SxProp } from '../Layout/sx';\n\nexport type TextVariant =\n  | 'display'\n  | 'h1'\n  | 'h2'\n  | 'h3'\n  | 'h4'\n  | 'h5'\n  | 'h6'\n  | 'lead'\n  | 'body'\n  | 'small'\n  | 'caption'\n  | 'code'\n  | 'kbd';\n\nexport type TextWeight = 'regular' | 'medium' | 'semibold' | 'bold';\nexport type TextAlign = 'left' | 'center' | 'right' | 'justify';\n\nexport type TextColor =\n  | 'primary'\n  | 'secondary'\n  | 'muted'\n  | 'accent'\n  | 'danger'\n  | 'warning'\n  | 'success'\n  | 'info';\n\n/** Default semantic element per variant. */\nconst VARIANT_ELEMENT: Record<TextVariant, ElementType> = {\n  display: 'h1',\n  h1: 'h1',\n  h2: 'h2',\n  h3: 'h3',\n  h4: 'h4',\n  h5: 'h5',\n  h6: 'h6',\n  lead: 'p',\n  body: 'p',\n  small: 'small',\n  caption: 'span',\n  code: 'code',\n  kbd: 'kbd',\n};\n\nexport type TextProps<E extends ElementType = ElementType> = Omit<\n  ComponentPropsWithoutRef<E>,\n  'color'\n> & {\n  as?: E;\n  variant?: TextVariant;\n  weight?: TextWeight;\n  align?: TextAlign;\n  color?: TextColor;\n  truncate?: boolean;\n  /**\n   * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a\n   * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx\n   * merges into inline style; responsive sx injects a scoped class.\n   */\n  sx?: SxProp;\n};\n\n/**\n * Text — typography primitive. `variant` picks the semantic element and the\n * type scale in one prop. Override the rendered tag with `as` while keeping\n * the style (e.g. `<Text variant=\"h1\" as=\"div\">`).\n *\n * @example\n * <Text variant=\"h1\">Page title</Text>\n * <Text variant=\"body\" color=\"muted\">Subtle paragraph</Text>\n * <Text variant=\"caption\" truncate>Long caption…</Text>\n */\nexport const Text = forwardRef(function Text<E extends ElementType = ElementType>(\n  {\n    as,\n    variant = 'body',\n    weight,\n    align,\n    color,\n    truncate = false,\n    className,\n    style,\n    sx,\n    children,\n    ...rest\n  }: TextProps<E>,\n  ref: ForwardedRef<Element>,\n): ReactElement {\n  const Tag = (as ?? VARIANT_ELEMENT[variant]) as ElementType;\n  const { className: classes, style: mergedStyle, styleTag } = withSx(\n    sx,\n    style,\n    'cny-text',\n    `cny-text-${variant}`,\n    weight && `cny-weight-${weight}`,\n    align && `cny-text-${align}`,\n    color && `text-${color}`,\n    truncate && 'truncate',\n    className,\n  );\n  return createElement(\n    Tag,\n    { ref, className: classes, style: mergedStyle, ...rest },\n    styleTag,\n    children,\n  );\n}) as <E extends ElementType = ElementType>(\n  props: TextProps<E> & { ref?: ForwardedRef<Element> },\n) => ReactElement;\n"],"names":["VARIANT_ELEMENT","Text","forwardRef","as","variant","weight","align","color","truncate","className","style","sx","children","rest","ref","Tag","classes","mergedStyle","styleTag","withSx","createElement"],"mappings":"sFAwCMA,EAAoD,CACxD,QAAS,KACT,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,KAAM,IACN,KAAM,IACN,MAAO,QACP,QAAS,OACT,KAAM,OACN,IAAK,KACP,EA8BaC,EAAOC,EAAAA,WAAW,SAC7B,CACE,GAAAC,EACA,QAAAC,EAAU,OACV,OAAAC,EACA,MAAAC,EACA,MAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EACA,MAAAC,EACA,GAAAC,EACA,SAAAC,EACA,GAAGC,CACL,EACAC,EACc,CACd,MAAMC,EAAOZ,GAAMH,EAAgBI,CAAO,EACpC,CAAE,UAAWY,EAAS,MAAOC,EAAa,SAAAC,GAAaC,EAAAA,OAC3DR,EACAD,EACA,WACA,YAAYN,CAAO,GACnBC,GAAU,cAAcA,CAAM,GAC9BC,GAAS,YAAYA,CAAK,GAC1BC,GAAS,QAAQA,CAAK,GACtBC,GAAY,WACZC,CAAA,EAEF,OAAOW,EAAAA,cACLL,EACA,CAAE,IAAAD,EAAK,UAAWE,EAAS,MAAOC,EAAa,GAAGJ,CAAA,EAClDK,EACAN,CAAA,CAEJ,CAAC"}