import React from 'react'; import PropTypes from 'prop-types'; import { ComponentProps } from '../utils/types'; /** @public */ type TextAreaChangeHandler = (event: React.ChangeEvent, data: { name?: string; value: string; }) => void; /** @public */ type TextAreaBlurHandler = (event: React.FocusEvent, data: { name?: string; value: string; }) => void; /** @public */ type TextAreaFocusHandler = (event: React.FocusEvent, data: { name?: string; value: string; }) => void; interface TextAreaPropsBase { /** Append removes rounded borders and the border from the right side. */ append?: boolean; /** * Control the browser's automatic capitalization functionality. * Note: Doesn't apply to physical keyboard input. * Examples: 'on', 'off', 'sentences', 'words, 'characters'. */ autoCapitalize?: string; /** * Control the browser's autofill functionality. * See [the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute) for details. * Examples: 'on', 'off', 'cc-name', 'shipping street-address'. */ autoComplete?: string; /** Set the input's autocorrect attribute. Only supported by Safari. See also `spellCheck`. */ autoCorrect?: string; /** Specify that the input should request focus when mounted. */ autoFocus?: boolean; children?: React.ReactNode; /** * Set this property instead of value to make value uncontrolled. */ defaultValue?: string; /** * The id of the description. When placed in a ControlGroup, this is automatically set to the * ControlGroup's help component. */ describedBy?: string; /** Determines whether or not the input is editable. */ disabled?: boolean; /** * A React ref which is set to the DOM element when the component mounts, and null when it unmounts. */ elementRef?: React.Ref; /** * Adornment after the input. */ endAdornment?: React.ReactNode; /** * Highlight the field as having an error. The border will turn red. */ error?: boolean; /** When false, display as inline-block with the default width. */ inline?: boolean; /** @private. */ inputClassName?: string; /** * An id for the input, which may be necessary for accessibility, such as for aria * attributes. */ inputId?: string; /** * A React ref which is set to the input element when the component mounts and null when it unmounts. */ inputRef?: React.Ref; /** * The id of the label. When placed in a ControlGroup, this is automatically set to the * ControlGroup's label. */ labelledBy?: string; /** Set the input's maxlength attribute. */ maxLength?: number; /** The name is returned with onChange events, which can be used to identify the * control when multiple controls share an onChange callback. */ name?: string; /** A callback for when the input loses focus. */ onBlur?: TextAreaBlurHandler; /** * This is equivalent to onInput which is called on keydown, paste, and so on. * If value is set, this callback is required. This must set the value prop to retain the * change. */ onChange?: TextAreaChangeHandler; /** A callback for when the input takes focus. */ onFocus?: TextAreaFocusHandler; /** A keydown callback can be used to prevent a certain input by utilizing the event argument. */ onKeyDown?: React.KeyboardEventHandler; /** A callback for when the text selection or cursor position changes. */ onSelect?: React.ReactEventHandler; /** A callback for when the user clicks the textbox. * This will only trigger when the textbox itself is clicked and will not trigger for other parts of the component, * such as nodes added via "startAdornment" or "endAdornment" props. * If you want to handle all click events, pass the "onClick" prop, which will be attached to `TextArea`'s root element. */ onInputClick?: React.MouseEventHandler; /** Prepend removes rounded borders from the left side. */ prepend?: boolean; /** @private. */ required?: boolean; /** Maximum number of rows to display */ rowsMax?: number; /** Minimum number of rows to display */ rowsMin?: number; /** Control the browser's spelling and grammar checking functionality. */ spellCheck?: boolean; /** * Adornment in front of the input. */ startAdornment?: React.ReactNode; tabIndex?: number; /** * The contents of the input. Setting this value makes the property controlled. A callback * is required. */ value?: string; } interface TextAreaPropsBaseControlled extends TextAreaPropsBase { defaultValue?: never; onChange: TextAreaChangeHandler; value?: string; } interface TextAreaPropsBaseUncontrolled extends TextAreaPropsBase { defaultValue?: string; value?: never; } type TextAreaProps = ComponentProps; /** Note: TextArea places role and aria props onto the input. All other props are placed on the wrapper. */ declare function TextArea({ append, autoCapitalize, autoComplete, autoCorrect, autoFocus, children, disabled, describedBy, defaultValue, elementRef, error, endAdornment, inline, inputClassName, inputId, inputRef: inputRefProp, labelledBy, maxLength, name, onBlur, onChange, onFocus, onInputClick, onKeyDown, onSelect, placeholder, // removed as a prop, but supported as the HTML attribute prepend, required, rowsMin, rowsMax, spellCheck, startAdornment, tabIndex, value: valueProp, ...otherProps }: TextAreaProps): React.JSX.Element; declare namespace TextArea { var propTypes: { append: PropTypes.Requireable; autoCapitalize: PropTypes.Requireable; autoComplete: PropTypes.Requireable; autoCorrect: PropTypes.Requireable; autoFocus: PropTypes.Requireable; children: PropTypes.Requireable; defaultValue: PropTypes.Requireable; describedBy: PropTypes.Requireable; disabled: PropTypes.Requireable; elementRef: PropTypes.Requireable; endAdornment: PropTypes.Requireable; error: PropTypes.Requireable; inline: PropTypes.Requireable; /** @private. */ inputClassName: PropTypes.Requireable; inputId: PropTypes.Requireable; inputRef: PropTypes.Requireable; labelledBy: PropTypes.Requireable; maxLength: PropTypes.Requireable; name: PropTypes.Requireable; onBlur: PropTypes.Requireable<(...args: any[]) => any>; onChange: PropTypes.Requireable<(...args: any[]) => any>; onFocus: PropTypes.Requireable<(...args: any[]) => any>; onKeyDown: PropTypes.Requireable<(...args: any[]) => any>; onSelect: PropTypes.Requireable<(...args: any[]) => any>; onInputClick: PropTypes.Requireable<(...args: any[]) => any>; prepend: PropTypes.Requireable; /** @private. */ required: PropTypes.Requireable; rowsMax: PropTypes.Requireable; rowsMin: PropTypes.Requireable; spellCheck: PropTypes.Requireable; tabIndex: PropTypes.Requireable; startAdornment: PropTypes.Requireable; value: PropTypes.Requireable; }; var componentType: string; } export default TextArea; export { TextAreaBlurHandler, TextAreaChangeHandler, TextAreaFocusHandler }; export type { TextAreaPropsBase, TextAreaPropsBaseControlled, TextAreaPropsBaseUncontrolled };