import type {
  HTMLAttributes,
  ReactElement,
  ReactNode,
  ComponentType,
} from "react";
import type { ButtonProps as MUIButtonProps } from "@mui/material";
import type { TooltipProps } from "../tooltip/Tooltip";
import type { IconProps } from "../icon/Icon";

export type ButtonVariant =
  | "primary"
  | "secondary"
  | "tertiary"
  | "outlined"
  | "danger";

type NavTo = string | { pathname: string; state?: unknown };
export type ButtonSize = "tiny" | "small" | "default" | "large";

export interface ButtonProps
  extends Omit<MUIButtonProps, "size" | "variant" | "color" | "className">,
    Omit<HTMLAttributes<HTMLButtonElement>, "style" | "className" | "color"> {
  children?: ReactNode;
  disabled?: boolean;
  fullWidth?: boolean;
  variant?: ButtonVariant;
  type?: "submit" | "reset" | "button";
  size?: ButtonSize;
  icon?: IconProps["name"];
  iconPosition?: "start" | "end";
  iconWeight?: IconProps["weight"];
  to?: NavTo;
  linkComponent?: ComponentType<unknown>;
  tooltip?: string | ReactElement;
  tooltipProps?: Partial<TooltipProps>;
  ESCAPE_className?: string;
}

export type MUIButtonPropWithLink = MUIButtonProps & {
  component?: ComponentType<unknown>;
  to?: NavTo;
};

export type StyleProps = {
  hasLabel: boolean;
  variant: ButtonVariant;
  size: ButtonSize;
};
