import * as React from 'react'; import { InternalStandardProps as StandardProps } from '..'; export interface InputBaseProps extends StandardProps< React.HTMLAttributes, /* * `onChange`, `onKeyUp`, `onKeyDown`, `onBlur`, `onFocus` 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' | 'onChange' | 'onKeyUp' | 'onKeyDown' | 'onBlur' | 'onFocus' | 'defaultValue' > { '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 will be focused during the first mount. */ autoFocus?: boolean; /** * Override or extend the styles applied to the component. */ classes?: { /** Styles applied to the root element. */ root?: string; /** Styles applied to the root element if the component is a descendant of `FormControl`. */ formControl?: string; /** Styles applied to the root element if the component is focused. */ focused?: string; /** Styles applied to the root element if `disabled={true}`. */ disabled?: string; /** Styles applied to the root element if `startAdornment` is provided. */ adornedStart?: string; /** Styles applied to the root element if `endAdornment` is provided. */ adornedEnd?: string; /** Pseudo-class applied to the root element if `error={true}`. */ error?: string; /** Styles applied to the `input` element if `margin="dense"`. */ marginDense?: string; /** Styles applied to the root element if `multiline={true}`. */ multiline?: string; /** Styles applied to the root element if the color is secondary. */ colorSecondary?: string; /** Styles applied to the root element if `fullWidth={true}`. */ fullWidth?: string; /** Styles applied to the root element if `hiddenLabel={true}`. */ hiddenLabel?: string; /** Styles applied to the `input` element. */ input?: string; /** Styles applied to the `input` element if `margin="dense"`. */ inputMarginDense?: string; /** Styles applied to the `input` element if `multiline={true}`. */ inputMultiline?: string; /** Styles applied to the `input` element if `type="search"`. */ inputTypeSearch?: string; /** Styles applied to the `input` element if `startAdornment` is provided. */ inputAdornedStart?: string; /** Styles applied to the `input` element if `endAdornment` is provided. */ inputAdornedEnd?: string; /** Styles applied to the `input` element if `hiddenLabel={true}`. */ inputHiddenLabel?: string; }; /** * The color of the component. It supports those theme colors that make sense for this component. * The prop defaults to the value (`'primary'`) inherited from the parent FormControl component. */ color?: 'primary' | 'secondary'; /** * The default `input` element value. Use when the component is not controlled. */ defaultValue?: unknown; /** * If `true`, the `input` element will be disabled. * The prop defaults to the value (`false`) inherited from the parent FormControl component. */ disabled?: 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 textarea element will be 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 {object} 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; /** * 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 will be 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; /** * Start `InputAdornment` for this component. */ startAdornment?: React.ReactNode; /** * 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 value of the `input` element, required for a controlled component. */ value?: unknown; } export interface InputBaseComponentProps extends React.HTMLAttributes { // Accommodate arbitrary additional props coming from the `inputProps` prop [arbitrary: string]: any; } export type InputBaseClassKey = keyof NonNullable; /** * `InputBase` contains as few styles as possible. * It aims to be a simple building block for creating an input. * It contains a load of style reset and some state logic. * Demos: * * - [Text Fields](https://material-ui.com/components/text-fields/) * * API: * * - [InputBase API](https://material-ui.com/api/input-base/) */ export default function InputBase(props: InputBaseProps): JSX.Element;