import { SlotComponentProps } from '@mui/utils'; import { ReactNode } from 'react'; import { OverridableComponent, OverridableTypeMap, OverrideProps, Simplify } from '@mui/types'; import { UseButtonParameters, UseButtonRootSlotProps } from '../internal/hooks/useButton'; import { SlotCommonProps } from '../types/slot'; export interface ButtonActions { focusVisible(): void; } export interface ButtonRootSlotPropsOverrides { } export interface ButtonBaseOwnProps extends Omit, Pick { /** * A ref for imperative actions. It currently only supports `focusVisible()` action. */ action?: React.Ref; children?: React.ReactNode; className?: string; /** * The props used for each slot inside the Button. * @default {} */ slotProps?: { root?: SlotComponentProps<'button', ButtonRootSlotPropsOverrides, ButtonOwnerState>; }; /** * The components used for each slot inside the Button. * Either a string to use a HTML element or a component. * @default {} */ slots?: ButtonSlots; /** * The overall size of the button. * @default 'medium' */ size?: 'small' | 'medium' | 'large'; /** * An optional icon to show at the start of the button */ startIcon?: ReactNode; /** * An optional icon to show at the end of the button */ endIcon?: ReactNode; /** * If `true`, the button will take up the full width of its container. * @default false */ fullWidth?: boolean; } export interface ButtonSlots { /** * The component that renders the root. * @default props.href || props.to ? 'a' : 'button' */ root?: React.ElementType; } export type ButtonBaseProps = OverrideProps, RootComponent> & { component?: React.ElementType; }; export interface ButtonBaseTypeMap { props: AdditionalProps & ButtonBaseOwnProps; defaultComponent: RootComponent; } /** * utility to create component types that inherit props from ButtonBase. * This component has an additional overload if the `href` prop is set which * can make extension quite tricky */ export interface ExtendButtonBaseTypeMap { props: TypeMap['props'] & Omit; defaultComponent: TypeMap['defaultComponent']; } export type ExtendButtonBase = ((props: { href: string; } & OverrideProps, 'a'>) => React.JSX.Element) & OverridableComponent>; export type ButtonOwnerState = Simplify; export type ButtonRootSlotProps = Simplify;