import React, { forwardRef, useState } from "react"; import { BodyShort, ErrorMessage, Label } from "../../typography"; import { omit, useId } from "../../utils-external"; import TextareaAutosize from "../../utils/components/textarea-autosize/TextareaAutoSize"; import { cl, composeEventHandlers } from "../../utils/helpers"; import { ReadOnlyIcon } from "../ReadOnlyIcon"; import { FormFieldProps, useFormField } from "./../useFormField"; import Counter from "./TextareaCounter"; export interface TextareaProps extends FormFieldProps, React.TextareaHTMLAttributes { /** * Allowed character-count for content * * This is just a visual indicator! You will still need to handle actual character-limits/validation if needed. */ maxLength?: number; /** * Controlled value */ value?: string; /** * Defaults input-value without needing controlled-state */ defaultValue?: string; /** * Maximum number of character rows to display. */ maxRows?: number; /** * Minimum number of character-rows to display when empty. */ minRows?: number; /** * Textarea label. */ label: React.ReactNode; /** * If enabled shows the label and description for screenreaders only. */ hideLabel?: boolean; /** * Enables resizing of field. */ resize?: boolean | "vertical" | "horizontal"; /** * Textarea will stop growing and get a scrollbar when there's no more room to grow. * Requires `display:flex` on the parent. * Experimental feature that may be removed or get breaking changes in a minor version. */ UNSAFE_autoScrollbar?: boolean; /** * i18n-translations for counter-text * @deprecated Use ``-component */ i18n?: { /** @default tegn igjen */ counterLeft?: string; /** @default tegn for mye */ counterTooMuch?: string; }; } /** * A component that displays a textarea input field with a label. * * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/textarea) * @see 🏷️ {@link TextareaProps} * * @example * ```jsx *