import * as React from "react"; import { StyleType } from "@khanacademy/wonder-blocks-core"; /** * A TextArea is an element used to accept text from the user. * * Make sure to provide a label for the field. This can be done by either: * - (recommended) Using the **LabeledField** component to provide a label, * description, and/or error message for the field * - Using a `label` html tag with the `htmlFor` prop set to the unique id of * the field * - Using an `aria-label` attribute on the field * - Using an `aria-labelledby` attribute on the field */ declare const TextArea: React.ForwardRefExoticComponent & Readonly<{ role?: import("@khanacademy/wonder-blocks-core").AriaRole; }> & { /** * The text area value. */ value: string; /** * Called when the value has changed. */ onChange: (newValue: string) => unknown; /** * An optional unique identifier for the TextArea. * If no id is specified, a unique id will be auto-generated. */ id?: string; /** * Optional test ID for e2e testing. */ testId?: string; /** * Custom styles for the textarea element. */ style?: StyleType; /** * Custom styles for the root node of the component. * If possible, try to use this prop carefully and use the `style` prop * instead. */ rootStyle?: StyleType; /** * Provide hints or examples of what to enter. */ placeholder?: string; /** * Whether the text area should be disabled. * * Internally, the `aria-disabled` attribute will be set so that the * element remains focusable and will be included in the tab order. */ disabled?: boolean; /** * Specifies if the text area is read-only. */ readOnly?: boolean; /** * Specifies if the text area allows autocomplete. */ autoComplete?: "on" | "off"; /** * The name for the text area control. This is submitted along with * the form data. */ name?: string; /** * CSS classes for the textarea element. It is recommended that the style prop is used instead where possible */ className?: string; /** * Whether this textarea should autofocus on page load. */ autoFocus?: boolean; /** * The number of visible lines of text for the textarea. Defaults to 2. * * If `autoResize` is `true`, `rows` is the starting number of rows and more * content increases the number of rows, up until the `maxRows` prop value * is reached. If `autoResize` is `false`, the textarea will be scrollable * with the number of rows set by the `rows` prop. */ rows?: number; /** * Determines if the textarea should be checked for spelling by the browser/OS. * By default, it is enabled. It will be checked for spelling when you try * to edit it (ie. once the textarea is focused). For more details, see the * [spellcheck attribute MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#spellcheck). * **Note**: Consider disabling `spellCheck` for * sensitive information (see [Security and Privacy concerns](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck#security_and_privacy_concerns) for more details) */ spellCheck?: boolean; /** * How the control should wrap the value for form submission. If not provided, * `soft` is the default behaviour. For more details, see the * [wrap attribute MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#wrap) */ wrap?: "hard" | "soft" | "off"; /** * The minimum number of characters allowed in the textarea. */ minLength?: number; /** * The maximum number of characters allowed in the textarea. */ maxLength?: number; /** * Called when the textarea is clicked. * @param event The event from the click */ onClick?: React.MouseEventHandler; /** * Called when a key is pressed. * @param event The keyboard event */ onKeyDown?: React.KeyboardEventHandler; /** * Called when a key is released. * @param event The keyboard event */ onKeyUp?: React.KeyboardEventHandler; /** * Called when the element has been focused. * @param event The focus event */ onFocus?: React.FocusEventHandler; /** * Called when the element has been focused. * @param event The blur event */ onBlur?: React.FocusEventHandler; /** * Called when text is pasted into the element. * @param event The paste event */ onPaste?: React.ClipboardEventHandler; /** * Provide a validation for the textarea value. * Return a string error message or null | void for a valid input. * * Use this for errors that are shown to the user while they are filling out * a form. */ validate?: (value: string) => string | null | void; /** * Called right after the textarea is validated. */ onValidate?: (errorMessage?: string | null | undefined) => unknown; /** * If true, textarea is validated as the user types (onChange). If false, * it is validated when the user's focus moves out of the field (onBlur). * It is preferred that instantValidation is set to `false`, however, it * defaults to `true` for backwards compatibility with existing implementations. */ instantValidation?: boolean; /** * Whether the textarea is in an error state. * * Use this for errors that are triggered by something external to the * component (example: an error after form submission). */ error?: boolean; /** * Whether this textarea is required to continue, or the error message to * render if this textarea is left blank. * * This can be a boolean or a string. * * String: * Please pass in a translated string to use as the error message that will * render if the user leaves this textarea blank. If this textarea is required, * and a string is not passed in, a default untranslated string will render * upon error. * Note: The string will not be used if a `validate` prop is passed in. * * Example message: i18n._("A password is required to log in.") * * Boolean: * True/false indicating whether this textarea is required. Please do not pass * in `true` if possible - pass in the error string instead. * If `true` is passed, and a `validate` prop is not passed, that means * there is no corresponding message and the default untranlsated message * will be used. */ required?: boolean | string; /** * @deprecated This prop is deprecated in favour of the `autoResize` prop. * Specifies the resizing behaviour for the textarea. Defaults to both * behaviour. For more details, see the [CSS resize property values MDN docs](https://developer.mozilla.org/en-US/docs/Web/CSS/resize#values) */ resizeType?: "horizontal" | "vertical" | "both" | "none"; /** * Whether the textarea should automatically resize to fit the content. * If `true`, the textarea will resize to fit the content. If `false`, * the textarea will not change in size and the textarea will be scrollable if * content exceeds the height of the textarea. * * Defaults to `false`. * * See related `maxRows` prop for setting the max height for the textarea. */ autoResize?: boolean; /** * The maximum number of rows to show when `autoResize` is `true` to prevent * the textarea from becoming too tall. The textarea will become scrollable * if content exceeds the max number of rows. * * Defaults to 6. If `rows` > `maxRows`, `rows` will be used for `maxRows`. */ maxRows?: number; } & React.RefAttributes>; export default TextArea;