import * as React from 'react'; import { SxProps } from '@mui/system'; import { OverridableStringUnion } from '@mui/types'; import { Theme } from '../styles'; import { InternalStandardProps as StandardProps } from '..'; import { InputBaseClasses } from './inputBaseClasses'; export interface InputBasePropsSizeOverrides {} export interface InputBasePropsColorOverrides {} export interface InputBaseComponentsPropsOverrides {} export interface InputBaseProps extends StandardProps< React.HTMLAttributes, /* * `onBlur`, `onChange`, `onFocus`, `onInvalid`, `onKeyDown`, `onKeyUp` are applied to the inner `InputComponent`, * which by default is an input or textarea. Since these handlers differ from the * ones inherited by `React.HTMLAttributes` we need to omit them. */ | 'children' | 'defaultValue' | 'onBlur' | 'onChange' | 'onFocus' | 'onInvalid' | 'onKeyDown' | 'onKeyUp' > { 'aria-describedby'?: string; /** * This prop helps users to fill forms faster, especially on mobile devices. * The name can be confusing, as it's more like an autofill. * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill). */ autoComplete?: string; /** * If `true`, the `input` element is focused during the first mount. */ autoFocus?: boolean; /** * Override or extend the styles applied to the component. */ classes?: Partial; /** * The color of the component. * It supports both default and custom theme colors, which can be added as shown in the * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors). * The prop defaults to the value (`'primary'`) inherited from the parent FormControl component. */ color?: OverridableStringUnion< 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning', InputBasePropsColorOverrides >; /** * The components used for each slot inside. * * This prop is an alias for the `slots` prop. * It's recommended to use the `slots` prop instead. * * @default {} */ components?: { Root?: React.ElementType; Input?: React.ElementType; }; /** * The extra props for the slot components. * You can override the existing props or add new ones. * * This prop is an alias for the `slotProps` prop. * It's recommended to use the `slotProps` prop instead, as `componentsProps` will be deprecated in the future. * * @default {} */ componentsProps?: { root?: React.HTMLAttributes & InputBaseComponentsPropsOverrides; input?: React.InputHTMLAttributes & InputBaseComponentsPropsOverrides; }; /** * The default value. Use when the component is not controlled. */ defaultValue?: unknown; /** * If `true`, the component is disabled. * The prop defaults to the value (`false`) inherited from the parent FormControl component. */ disabled?: boolean; /** * If `true`, GlobalStyles for the auto-fill keyframes will not be injected/removed on mount/unmount. Make sure to inject them at the top of your application. * This option is intended to help with boosting the initial rendering performance if you are loading a big amount of Input components at once. * @default false */ disableInjectingGlobalStyles?: boolean; /** * End `InputAdornment` for this component. */ endAdornment?: React.ReactNode; /** * If `true`, the `input` will indicate an error. * The prop defaults to the value (`false`) inherited from the parent FormControl component. */ error?: boolean; /** * If `true`, the `input` will take up the full width of its container. * @default false */ fullWidth?: boolean; /** * The id of the `input` element. */ id?: string; /** * The component used for the `input` element. * Either a string to use a HTML element or a component. * @default 'input' */ inputComponent?: React.ElementType; /** * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element. * @default {} */ inputProps?: InputBaseComponentProps; /** * Pass a ref to the `input` element. */ inputRef?: React.Ref; /** * If `dense`, will adjust vertical spacing. This is normally obtained via context from * FormControl. * The prop defaults to the value (`'none'`) inherited from the parent FormControl component. */ margin?: 'dense' | 'none'; /** * If `true`, a [TextareaAutosize](/material-ui/react-textarea-autosize/) element is rendered. * @default false */ multiline?: boolean; /** * Name attribute of the `input` element. */ name?: string; /** * Callback fired when the `input` is blurred. * * Notice that the first argument (event) might be undefined. */ onBlur?: React.FocusEventHandler; /** * Callback fired when the value is changed. * * @param {React.ChangeEvent} event The event source of the callback. * You can pull out the new value by accessing `event.target.value` (string). */ onChange?: React.ChangeEventHandler; onFocus?: React.FocusEventHandler; onKeyDown?: React.KeyboardEventHandler; onKeyUp?: React.KeyboardEventHandler; /** * Callback fired when the `input` doesn't satisfy its constraints. */ onInvalid?: React.FormEventHandler; /** * The short hint displayed in the `input` before the user enters a value. */ placeholder?: string; /** * It prevents the user from changing the value of the field * (not from interacting with the field). */ readOnly?: boolean; /** * If `true`, the `input` element is required. * The prop defaults to the value (`false`) inherited from the parent FormControl component. */ required?: boolean; renderSuffix?: (state: { disabled?: boolean; error?: boolean; filled?: boolean; focused?: boolean; margin?: 'dense' | 'none' | 'normal'; required?: boolean; startAdornment?: React.ReactNode; }) => React.ReactNode; /** * Number of rows to display when multiline option is set to true. */ rows?: string | number; /** * Maximum number of rows to display when multiline option is set to true. */ maxRows?: string | number; /** * Minimum number of rows to display when multiline option is set to true. */ minRows?: string | number; /** * The size of the component. */ size?: OverridableStringUnion<'small' | 'medium', InputBasePropsSizeOverrides>; /** * The extra props for the slot components. * You can override the existing props or add new ones. * * This prop is an alias for the `componentsProps` prop, which will be deprecated in the future. * * @default {} */ slotProps?: { root?: React.HTMLAttributes & InputBaseComponentsPropsOverrides & { sx?: SxProps }; input?: React.InputHTMLAttributes & InputBaseComponentsPropsOverrides & { sx?: SxProps }; }; /** * The components used for each slot inside. * * This prop is an alias for the `components` prop, which will be deprecated in the future. * * @default {} */ slots?: { root?: React.ElementType; input?: React.ElementType; }; /** * Start `InputAdornment` for this component. */ startAdornment?: React.ReactNode; /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx?: SxProps; /** * Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types). * @default 'text' */ type?: string; /** * The