{"version":3,"sources":["../src/Button/Button.tsx","../src/Button/Button.types.ts"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { type VariantProps, cva, cx } from \"cva\";\nimport type { ComponentPropsWithRef, ElementType, FunctionComponent, ReactNode, JSX } from \"react\";\nimport type { ButtonColor, ButtonSize, ButtonVariant } from \"./Button.types.ts\";\nimport type { NonFunctionProperties } from \"../utils.ts\";\nimport Typography from \"../Typography\";\n\nconst buttonRecipe = cva({\n  base: \"kn-btn\",\n  variants: {\n    color: {\n      primary: \"kn-btn-primary\",\n      secondary: \"kn-btn-secondary\",\n      tertiary: \"kn-btn-tertiary\",\n    } satisfies Record<ButtonColor, string>,\n    size: {\n      small: \"kn-btn-small\",\n      large: \"kn-btn-large\",\n    } satisfies Record<ButtonSize, string>,\n    variant: {\n      contained: \"kn-btn-contained\",\n      outlined: \"kn-btn-outlined\",\n      text: \"kn-btn-text\",\n    } satisfies Record<ButtonVariant, string>,\n  },\n  defaultVariants: {\n    color: \"primary\",\n    size: \"large\",\n    variant: \"contained\",\n  },\n});\n\nconst buttonIconContainerRecipe = cva({\n  base: \"kn-btn-icon-container\",\n  variants: {\n    position: {\n      left: \"kn-btn-icon-container-left\",\n      right: \"kn-btn-icon-container-right\",\n    },\n    size: {\n      large: \"kn-btn-icon-container-large\",\n      small: \"kn-btn-icon-container-small\",\n    } satisfies Record<ButtonSize, string>,\n  },\n  defaultVariants: {\n    size: \"large\",\n  },\n});\n\nconst buttonIconStyles = {\n  large: \"kn-btn-icon-large\",\n  small: \"kn-btn-icon-small\",\n} satisfies Record<ButtonSize, string>;\n\ntype ButtonRecipeVariants = VariantProps<typeof buttonRecipe>;\n\n// Define the type for the base button props\ntype BaseButtonProps = ButtonRecipeVariants & {\n  left?: ReactNode;\n  leftClassName?: string;\n  right?: ReactNode;\n  rightClassName?: string;\n  innerClassName?: string;\n\n  /**\n   * @deprecated Use `innerClassName` instead\n   */\n  textClassName?: string;\n};\n\n// Define the type for the button props\nexport type ButtonProps<T extends ElementType = \"button\"> = BaseButtonProps &\n  Omit<ComponentPropsWithRef<T>, keyof BaseButtonProps | \"as\"> & {\n    as?: T;\n  };\n\n// Define the type for the button icon props\nexport type ButtonIconProps<T extends ElementType = \"button\"> = Omit<\n  ComponentPropsWithRef<T>,\n  keyof ButtonRecipeVariants | \"as\"\n> &\n  ButtonRecipeVariants & {\n    as?: T;\n    innerClassName?: string;\n  };\n\n// Define the button component with forwardRef\ntype ButtonComponent<T extends ElementType = \"button\"> = NonFunctionProperties<\n  FunctionComponent<ButtonProps<T>>\n> & {\n  <T extends ElementType = \"button\">(props: ButtonProps<T>): JSX.Element;\n  Icon: ButtonIconComponent;\n};\n\ntype ButtonIconComponent<T extends ElementType = \"button\"> = NonFunctionProperties<\n  FunctionComponent<ButtonIconProps<T>>\n> & {\n  <T extends ElementType = \"button\">(props: ButtonIconProps<T>): JSX.Element;\n};\n\n// Create the Button component\nconst Button = forwardRef((props, ref) => {\n  const {\n    as = \"button\" as ElementType,\n    children,\n    className,\n    color = \"primary\",\n    size = \"large\",\n    variant = \"contained\",\n    left,\n    leftClassName,\n    right,\n    rightClassName,\n    innerClassName,\n    textClassName,\n    type = \"button\",\n    ...rest\n  } = props;\n  return (\n    <Typography\n      as={as}\n      variant=\"button\"\n      {...rest}\n      ref={ref}\n      className={cx(buttonRecipe({ color, size, variant }), className)}\n      type={as === \"button\" ? type : undefined}\n    >\n      {/* Render the left icon container */}\n      {left ? (\n        <div className={cx(buttonIconContainerRecipe({ position: \"left\", size }), leftClassName)}>\n          {left}\n        </div>\n      ) : null}\n\n      {/* Render the text */}\n      <div className={innerClassName || textClassName}>{children}</div>\n\n      {/* Render the right icon container */}\n      {right ? (\n        <div className={cx(buttonIconContainerRecipe({ position: \"right\", size }), rightClassName)}>\n          {right}\n        </div>\n      ) : null}\n    </Typography>\n  );\n}) satisfies Omit<ButtonComponent, \"Icon\"> as unknown as ButtonComponent;\n\nButton.displayName = \"Button\";\n\n// Create the Button.Icon component\nButton.Icon = forwardRef((props, ref) => {\n  const { children, className, size = \"large\", type = \"button\", ...rest } = props;\n  return (\n    <Button\n      {...rest}\n      ref={ref}\n      className={cx(size && buttonIconStyles[size], className)}\n      size={size}\n      type={type}\n    >\n      {children}\n    </Button>\n  );\n}) satisfies Omit<ButtonIconComponent, \"Icon\"> as unknown as ButtonIconComponent;\n\nButton.Icon.displayName = \"Button.Icon\";\n\nexport default Button;\n","export const buttonColors = [\"primary\", \"secondary\", \"tertiary\"] as const;\n\nexport const buttonVariants = [\"contained\", \"outlined\", \"text\"] as const;\n\nexport const buttonSizes = [\"small\", \"large\"] as const;\n\nexport type ButtonColor = (typeof buttonColors)[number];\n\nexport type ButtonVariant = (typeof buttonVariants)[number];\n\nexport type ButtonSize = (typeof buttonSizes)[number];\n"],"mappings":";;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAA4B,KAAK,UAAU;AAsHvC,SAUI,KAVJ;AAhHJ,IAAM,eAAe,IAAI;AAAA,EACvB,MAAM;AAAA,EACN,UAAU;AAAA,IACR,OAAO;AAAA,MACL,SAAS;AAAA,MACT,WAAW;AAAA,MACX,UAAU;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,MACJ,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,IACA,SAAS;AAAA,MACP,WAAW;AAAA,MACX,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AACF,CAAC;AAED,IAAM,4BAA4B,IAAI;AAAA,EACpC,MAAM;AAAA,EACN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,IACA,MAAM;AAAA,MACJ,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAED,IAAM,mBAAmB;AAAA,E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