import { JSXNode, PropsWithChildren } from "../types"; import { JSX } from "preact"; import { ForwardedRef, forwardRef } from "preact/compat"; type AllowedTags = "a" | "button" | "span" | "div"; type AllowedElements = ( Tag extends "a" ? HTMLAnchorElement : Tag extends "div" ? HTMLDivElement : Tag extends "span" ? HTMLSpanElement : HTMLButtonElement ); type ButtonProps = PropsWithChildren< { tag?: Tag; class?: string; leftIcon?: JSXNode; rightIcon?: JSXNode; // For when the user is _actually_ focused on another element, like react-aria radio buttons isFocusVisible?: boolean; variant?: | "primary-emphasized" | "secondary-emphasized" | "primary" | "secondary"; } & JSX.HTMLAttributes> >; const ButtonWrapper = forwardRef | null, ButtonProps>( ( { tag = "a" as never, class: className, children, variant = "primary", leftIcon, rightIcon, isFocusVisible, ...props }, ref, ) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const Wrapper: any = tag; return ( !!c) .join(" ")} ref={ref} > {leftIcon && ( )} {children} {rightIcon && ( )} ); }, ); export const Button = forwardRef | null, ButtonProps>( ( { class: className = "", ...props }, ref, ) => { return ( ); }, ); export const LargeButton = forwardRef | null, ButtonProps>( ( { class: className = "", ...props }, ref, ) => { return ( ); }, ); type IconOnlyButtonProps = Omit< ButtonProps, "leftIcon" | "rightIcon" >; export const IconOnlyButton = forwardRef | null, IconOnlyButtonProps>( ( { class: className = "", children, ...props }, ref, ) => { return ( ); }, ); export const LargeIconOnlyButton = forwardRef | null, IconOnlyButtonProps>( ( { class: className = "", children, ...props }, ref, ) => { return ( ); }, );