"use client"; import { type CSSProperties, type HTMLAttributes, type ReactElement, type Ref, type TextareaHTMLAttributes, } from "react"; import { type PropsWithRef } from "../types.js"; import { useEnsuredId } from "../useEnsuredId.js"; import { useEnsuredRef } from "../useEnsuredRef.js"; import { FormMessageContainer } from "./FormMessageContainer.js"; import { Label } from "./Label.js"; import { ResizingTextAreaWrapper } from "./ResizingTextAreaWrapper.js"; import { TextFieldContainer } from "./TextFieldContainer.js"; import { getFormConfig } from "./formConfig.js"; import { textArea, textAreaContainer } from "./textAreaStyles.js"; import { type FormFieldOptions } from "./types.js"; import { type TextAreaResize, useResizingTextArea, } from "./useResizingTextArea.js"; // NOTE: The augmentation appears in this file since no type definitions are // ever imported from the `textAreaStylesStyles` file. declare module "react" { interface CSSProperties { "--rmd-text-area-height"?: string | number; "--rmd-text-area-padding"?: string | number; } } /** * @since 6.0.0 Added `containerProps`. */ export interface TextAreaProps extends FormFieldOptions, TextareaHTMLAttributes { ref?: Ref; /** @defaultValue `"text-area-" + useId()` */ id?: string; /** * Optional placeholder text to display in the text field. * * @defaultValue `label ? " " : ""` */ placeholder?: string; /** * Set this to `true` if the auto resizing textarea should not animate for new * height changes. * * @defaultValue `false` */ disableTransition?: boolean; /** * An optional style to apply to the textarea element. The base `style` prop * is applied to the surrounding `div` instead. */ areaStyle?: CSSProperties; /** * An optional className to apply to the textarea element. The base `style` * prop is applied to the surrounding `div` instead. */ areaClassName?: string; /** * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-rows * @defaultValue `2` */ rows?: number; /** * The maximum number of rows a textarea can expand to before showing a * scrollbar. When this is set to `-1`, there will be no limit. * * @defaultValue `-1` */ maxRows?: number; /** * @see {@link TextAreaResize} * @defaultValue `"auto"` */ resize?: TextAreaResize; /** * When the {@link resize} prop is set to `"auto"`, an additional `
` is * added along with a hidden `