import * as React from 'react'; import { TextControl, tailwind } from '@tesseract-design/web-base'; import { useFallbackId } from '@modal-sh/react-utils'; const { tw } = tailwind; const MultilineTextInputDerivedElementComponent = 'textarea' as const; /** * Derived HTML element of the {@link MultilineTextInput} component. */ export type MultilineTextInputDerivedElement = HTMLElementTagNameMap[ typeof MultilineTextInputDerivedElementComponent ]; /** * Props of the {@link MultilineTextInput} component. */ export interface MultilineTextInputProps extends Omit, 'size' | 'label' | 'inputMode' | 'pattern'> { /** * Short textual description indicating the nature of the component's value. */ label?: React.ReactNode, /** * Short textual description as guidelines for valid input values. */ hint?: React.ReactNode, /** * Size of the component. */ size?: TextControl.Size, /** * Additional description, usually graphical, indicating the nature of the component's value. */ indicator?: React.ReactNode, /** * Should the component display a border? */ border?: boolean, /** * Should the component occupy the whole width of its parent? */ block?: boolean, /** * Style of the component. */ variant?: TextControl.Variant, /** * Is the label hidden? */ hiddenLabel?: boolean, } /** * Component for inputting textual values. * * This component supports multiline input and adjusts its layout accordingly. */ export const MultilineTextInput = React.forwardRef< MultilineTextInputDerivedElement, MultilineTextInputProps >(( { label, hint, indicator, size = 'medium' as const, border = false, block = false, variant = 'default' as const, hiddenLabel = false, className, style, id: idProp, ...etcProps }: MultilineTextInputProps, forwardedRef, ) => { const labelId = React.useId(); const id = useFallbackId(idProp); return (
{label && ( <> {' '} )} {hint && (
{hint}
)} {indicator && (
{indicator}
)} {border && ( )}
); }); MultilineTextInput.displayName = 'MultilineTextInput'; MultilineTextInput.defaultProps = { label: undefined, hint: undefined, size: 'medium', indicator: undefined, border: false, block: false, variant: 'default', hiddenLabel: false, };