{"version":3,"sources":["../src/Typography/Typography.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { cx } from \"cva\";\nimport type { PropsWithChildren, ElementType, ComponentProps, ForwardedRef, JSX } from \"react\";\nimport type { TypographyVariants } from \"@knitto-ui/tokens\";\n\nconst typographyVariants = {\n  button: \"kn-typography-button\",\n  description: \"kn-typography-description\",\n  h1: \"kn-typography-h1\",\n  h2: \"kn-typography-h2\",\n  h3: \"kn-typography-h3\",\n  h4: \"kn-typography-h4\",\n  h5: \"kn-typography-h5\",\n  h6: \"kn-typography-h6\",\n  hint: \"kn-typography-hint\",\n  paragraph: \"kn-typography-paragraph\",\n  paragraphBold: \"kn-typography-paragraph-bold\",\n  reportLabel: \"kn-typography-report-label\",\n  reportLabelBold: \"kn-typography-report-label-bold\",\n  subtitle1: \"kn-typography-subtitle-1\",\n  subtitle2: \"kn-typography-subtitle-2\",\n  subtitle3: \"kn-typography-subtitle-3\",\n} satisfies Record<TypographyVariants, string>;\n\n// Defines the base props for the Typography component\ntype TypographyBaseProps<T extends ElementType> = PropsWithChildren<{\n  as?: T;\n  variant?: TypographyVariants;\n}>;\n\n// Extends the base props with additional component props\nexport type TypographyProps<T extends ElementType> = TypographyBaseProps<T> &\n  Omit<ComponentProps<T>, keyof TypographyBaseProps<T>>;\n\n// Defines the Typography component with generic type support\nconst Typography = <T extends ElementType = \"div\">(\n  { className, as: asProp, variant = \"paragraph\", ...props }: TypographyProps<T>,\n  ref: ForwardedRef<HTMLElement>,\n) => {\n  // Sets the component's element type based on the provided 'as' prop or defaults to 'div'\n  const Component = asProp || (\"div\" as ElementType);\n\n  // Renders the component with the appropriate styles and props\n  return <Component {...props} ref={ref} className={cx(typographyVariants[variant], className)} />;\n};\n\n// Wraps the Typography component with a forwardRef\nconst ForwardedTypography = forwardRef(Typography);\n\n// Sets the display name for the forwardRef-wrapped Typography component\nForwardedTypography.displayName = \"Typography\";\n\n// Defines the exported Typography component type\ntype ExportedTypographyType = <T extends ElementType = \"div\">(\n  props: TypographyProps<T>,\n) => JSX.Element;\n\n// Exports the Typography component as the default export\nexport default ForwardedTypography as ExportedTypographyType;\n"],"mappings":";;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,UAAU;AA0CV;AAtCT,IAAM,qBAAqB;AAAA,EACzB,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAW;AAAA,EACX,eAAe;AAAA,EACf,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AACb;AAaA,IAAM,aAAa,CACjB,IACA,QACG;AAFH,eAAE,aAAW,IAAI,QAAQ,UAAU,YApCrC,IAoCE,IAAmD,kBAAnD,IAAmD,CAAjD,aAAW,MAAY;AAIzB,QAAM,YAAY,UAAW;AAG7B,SAAO,oBAAC,4CAAc,QAAd,EAAqB,KAAU,WAAW,GAAG,mBAAmB,OAAO,GAAG,SAAS,IAAG;AAChG;AAGA,IAAM,sBAAsB,WAAW,UAAU;AAGjD,oBAAoB,cAAc;AAQlC,IAAO,qBAAQ;","names":[]}