@octopusdeploy/design-system-components
Version:
The design systems component library.
122 lines (121 loc) • 4.58 kB
TypeScript
import type { ReactElement, ReactNode } from "react";
import type { PopoverBasicHelpProps } from "../../Popover";
import type { ValidationState } from "../Primitives/InputValidationMessage";
import type { DescriptionContent } from "../utils/descriptionWithLinks";
export interface TextareaProps {
/**
* The label for the textarea field
*/
label: string;
/**
* The current value of the textarea
*/
value?: string;
/**
* The placeholder text to display when textarea is empty
*/
placeholder?: string;
/**
* The description text to display below the textarea
*/
description?: string | DescriptionContent;
/**
* Validation message to display.
*
* Will default to displaying as an error unless changed with the `validationState` prop.
*/
validationMessage?: string;
/**
* The validation state, used to style the validation message and textarea border.
* Only applied when a `validationMessage` is provided; defaults to `"error"` in that case.
*/
validationState?: ValidationState;
/**
* Whether the field is disabled
*/
disabled?: boolean;
/**
* Whether the field is required
*/
hasRequiredMarker?: boolean;
/**
* Whether to show optional marker
*/
hasOptionalMarker?: boolean;
/**
* Uses a monospace font for textarea
*/
monospace?: boolean;
/**
* PopoverBasicHelp component to display additional help information
*/
popover?: ReactElement<PopoverBasicHelpProps>;
/**
* Whether to autofocus the textarea
*/
autoFocus?: boolean;
/**
* Whether the textarea is readonly
*/
readOnly?: boolean;
/**
* The name attribute for the textarea
*/
name?: string;
/**
* The number of visible text lines for the textarea (Default is 4)
*/
rows?: number;
/**
* The maximum number of characters allowed
*/
maxLength?: number;
/**
* The minimum number of characters required
*/
minLength?: number;
/**
* Whether the textarea should automatically resize
*/
autoResize?: boolean;
/**
* Content rendered inside the field's border, above the textarea input (e.g. a formatting toolbar).
* When provided, the field container draws the border and focus ring around both the toolbar and the input.
*/
toolbar?: ReactNode;
/**
* The action to perform when the form control field is changed.
*/
onChange: (newValue: string) => void;
}
/**
* Textarea component used for multi-line text input
*
* @remarks Only use in pre-approved areas, as in #project-form-uplift if unsure before using.
* /
/**
* @param props - TextareaProps
* @param props.label - The label for the textarea field
* @param props.value - The current value of the textarea
* @param props.placeholder - The placeholder text to display when textarea is empty
* @param props.description - The description text to display below the textarea
* @param props.validationMessage - Validation message to display
* @param props.validationState - The validation state ('error' | 'success'). Only applied when a `validationMessage` is provided; defaults to 'error' in that case.
* @param props.disabled - Whether the field is disabled
* @param props.hasRequiredMarker - Whether the field is required
* @param props.hasOptionalMarker - Whether to show optional marker
* @param props.monospace - Whether to use a monospace font for the textarea
* @param props.popover - PopoverBasicHelp component to display additional help information
* @param props.autoFocus - Whether to autofocus the textarea
* @param props.readOnly - Whether the textarea is readonly
* @param props.name - The name attribute for the textarea
* @param props.rows - The number of visible text lines for the textarea (Default is 4)
* @param props.maxLength - The maximum number of characters allowed
* @param props.minLength - The minimum number of characters required
* @param props.autoResize - Whether the textarea should automatically resize
* @param props.toolbar - Content rendered inside the field's border, above the textarea input (e.g. a formatting toolbar)
* @param props.onChange - The action to perform when the form control field is changed.
* @param ref - Forwarded to the underlying textarea element
*/
export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
export default Textarea;