import React, { useEffect, useState } from "react"; import { nanoid } from "nanoid"; import { theme, css, styled } from "../theme"; import type * as WPDS from "../theme"; import { sharedInputStyles, sharedInputVariants, useFloating, globalInputAutoFillTriggerAnimations, FloatingLabelStyles, } from "../input-shared"; import { InputLabel } from "../input-label"; import { ErrorMessage } from "../error-message"; import { HelperText } from "../helper-text"; const NAME = "InputTextarea"; const InputTextareaCSS = css({ ...sharedInputStyles, display: "block", minHeight: "$500", padding: "$125 $050 $050 $050", width: "100%", variants: { ...sharedInputVariants, /** * Enable to allow for the text area to be resized by the user. */ canResize: { false: { resize: "none", }, }, }, }); const TextAreaLabel = styled(InputLabel, { insetBlockStart: "$050", insetInlineStart: "$050", pointerEvents: "none", position: "absolute", transition: theme.transitions.allFast, "@reducedMotion": { transition: "none", }, variants: { isFloating: { true: { fontSize: FloatingLabelStyles.fontSize, lineHeight: FloatingLabelStyles.lineHeight, transform: `translateY(0)`, }, }, }, }); const ControlCSS = css({ display: "flex", flexDirection: "column", position: "relative", }); export interface InputTextareaProps extends Omit< WPDS.VariantProps, "isInvalid" | "isDisabled" > { /** children */ children?: React.ReactNode; /** Override CSS */ css?: WPDS.CSS; /** The initial input element value for uncontrolled components */ defaultValue?: string; /** The underlying textarea element disabled attribute */ disabled?: boolean; /** if the element has an error */ error?: boolean; /** Text displayed below the input to describe the cause of the error */ errorMessage?: React.ReactNode; /** Text displayed below the input to provide additional context */ helperText?: React.ReactNode; /** Label (use instead of Placeholder) */ label: string; /** An id attribute to allow the to be associated with a