{"version":3,"file":"Body.mjs","sources":["../../src/body/Body.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, HTMLAttributes } from 'react';\n\nimport { Typography, BodyTypes } from '../common/propsValues/typography';\n\nconst DEFAULT_TYPE = Typography.BODY_DEFAULT;\n\nconst bodyTypes = new Set<BodyTypes>([\n  Typography.BODY_DEFAULT,\n  Typography.BODY_DEFAULT_BOLD,\n  Typography.BODY_LARGE,\n  Typography.BODY_LARGE_BOLD,\n]);\n\ntype Props = HTMLAttributes<HTMLSpanElement | HTMLParagraphElement> & {\n  /** @default 'body-default' */\n  type?: BodyTypes;\n  /** @default 'div' */\n  as?: 'span' | 'p' | 'div';\n  /**\n   * When true, preserves newline characters in the text\n   * @default false\n   */\n  preserveNewlines?: boolean;\n};\n\nconst Body = forwardRef(function Body(\n  { as: Element = 'div', type = DEFAULT_TYPE, className, preserveNewlines, ...props }: Props,\n  reference: React.ForwardedRef<\n    | {\n        [key in typeof Element]: React.ElementRef<key>;\n      }[typeof Element]\n    | null\n  >,\n) {\n  const isTypeSupported = bodyTypes.has(type);\n  return (\n    <Element\n      {...props}\n      // @ts-expect-error TODO: Remove when component could be rewritten with generics\n      // See: https://fettblog.eu/typescript-react-generic-forward-refs/\n      ref={reference}\n      className={clsx(\n        `np-text-${isTypeSupported ? type : DEFAULT_TYPE}`,\n        preserveNewlines && 'np-text--pre-line',\n        className,\n      )}\n    />\n  );\n});\n\nexport default Body;\n"],"names":["DEFAULT_TYPE","Typography","BODY_DEFAULT","bodyTypes","Set","BODY_DEFAULT_BOLD","BODY_LARGE","BODY_LARGE_BOLD","Body","forwardRef","as","Element","type","className","preserveNewlines","props","reference","isTypeSupported","has","_jsx","ref","clsx"],"mappings":";;;;;AAKA,MAAMA,YAAY,GAAGC,UAAU,CAACC,YAAY;AAE5C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAY,CACnCH,UAAU,CAACC,YAAY,EACvBD,UAAU,CAACI,iBAAiB,EAC5BJ,UAAU,CAACK,UAAU,EACrBL,UAAU,CAACM,eAAe,CAC3B,CAAC;AAcF,MAAMC,IAAI,gBAAGC,UAAU,CAAC,SAASD,IAAIA,CACnC;EAAEE,EAAE,EAAEC,OAAO,GAAG,KAAK;AAAEC,EAAAA,IAAI,GAAGZ,YAAY;EAAEa,SAAS;EAAEC,gBAAgB;EAAE,GAAGC;AAAK,CAAS,EAC1FC,SAKC,EAAA;AAED,EAAA,MAAMC,eAAe,GAAGd,SAAS,CAACe,GAAG,CAACN,IAAI,CAAC;EAC3C,oBACEO,GAAA,CAACR,OAAO,EAAA;AAAA,IAAA,GACFI,KAAK;AACT;AACA;AACAK,IAAAA,GAAG,EAAEJ,SAAU;AACfH,IAAAA,SAAS,EAAEQ,IAAI,CACb,CAAA,QAAA,EAAWJ,eAAe,GAAGL,IAAI,GAAGZ,YAAY,EAAE,EAClDc,gBAAgB,IAAI,mBAAmB,EACvCD,SAAS;AACT,GAAA,CACF;AAEN,CAAC;;;;"}