import * as React from "react"; import { Button as KumoButton, LinkButton as KumoLinkButton, type ButtonProps as KumoButtonProps, type LinkButtonProps as KumoLinkButtonProps, } from "@cloudflare/kumo/components/button"; import { cn } from "@/lib/utils"; type ButtonVariant = "default" | "secondary" | "outline" | "ghost" | "destructive"; type ButtonSize = "default" | "sm" | "lg" | "icon"; const variantMap: Record = { default: "primary", secondary: "secondary", outline: "outline", ghost: "ghost", destructive: "destructive", }; const sizeMap: Record = { default: "base", sm: "sm", lg: "lg", icon: "base", }; type BaseButtonProps = Omit & { variant?: ButtonVariant; }; type TextButtonProps = BaseButtonProps & { size?: Exclude; }; type IconButtonProps = BaseButtonProps & { "aria-label": string; size: "icon"; }; export type ButtonProps = TextButtonProps | IconButtonProps; export type LinkButtonProps = Omit & { variant?: ButtonVariant; size?: Exclude; }; export const Button = React.forwardRef(function Button( { className, variant = "default", size = "default", ...props }, ref, ): React.ReactElement { if (size === "icon") { const iconAriaLabel = props["aria-label"]; if (!iconAriaLabel) { throw new Error("Icon buttons require an aria-label."); } return ( ); } return ( ); }); export const LinkButton = React.forwardRef(function LinkButton( { className, variant = "default", size = "default", ...props }, ref, ): React.ReactElement { return ( ); });