import { Button as MantineButton, type ButtonProps as MantineButtonCoreProps, } from "@mantine/core"; import React from "react"; import { cn } from "./utils"; // Define the props for our custom Button component // We want to allow all MantineButtonProps and also our custom variant and className. // Native HTML button attributes are generally passed through MantineButtonProps. interface ButtonProps extends MantineButtonCoreProps { variant?: | "default" | "destructive" | "outline" | "secondary" | "ghost" | "link"; className?: string; // Explicitly add common HTML button attributes if they are causing issues type?: React.ButtonHTMLAttributes["type"]; onClick?: React.MouseEventHandler; } const Button = React.forwardRef( ({ children, className, variant, type, onClick, ...props }, ref) => { // Destructure type and onClick let mantineVariant: MantineButtonCoreProps["variant"]; let mantineColor: MantineButtonCoreProps["color"]; switch (variant) { case "destructive": mantineVariant = "filled"; mantineColor = "red"; break; case "outline": mantineVariant = "outline"; break; case "secondary": mantineVariant = "default"; break; case "ghost": mantineVariant = "subtle"; break; case "link": mantineVariant = "transparent"; mantineColor = "blue"; // Assuming primary maps to blue in Mantine for now break; default: mantineVariant = "filled"; mantineColor = "blue"; // Assuming primary maps to blue in Mantine for now break; } return ( {children} ); }, ); Button.displayName = "Button"; export { Button };