import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core'; import { CSSResult } from 'lit'; import { FormControlInterface } from '@justeattakeaway/pie-webc-core'; import { GenericConstructor } from '@justeattakeaway/pie-webc-core'; import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement'; import { PIEInputElement } from '@justeattakeaway/pie-webc-core'; import { PropertyValues } from 'lit'; import * as React_2 from 'react'; import { RTLInterface } from '@justeattakeaway/pie-webc-core'; import { TemplateResult } from 'lit-html'; declare type AriaProps = { /** * Provides an accessible label for the textarea. Should be used when no visible label is associated with the textarea. */ label?: string; }; /** * The default values for the `TextareaProps` that are required (i.e. they have a fallback value in the component). */ declare type DefaultProps = ComponentDefaultProps>; /** * Default values for optional properties that have default fallback values in the component. */ export declare const defaultProps: DefaultProps; export declare const PieTextarea: React_2.ForwardRefExoticComponent, "children">> & React_2.RefAttributes & PieTextareaEvents & ReactBaseType>; /** * @tagname pie-textarea * @event {InputEvent} input - when the textarea value is changed. * @event {CustomEvent} change - when the textarea value is changed. */ declare class PieTextarea_2 extends PieTextarea_base implements TextareaProps, PIEInputElement { value: string; defaultValue: TextareaProps['defaultValue']; disabled: boolean; size: "small" | "medium" | "large"; resize: "auto" | "manual" | "none"; readonly: boolean; autoFocus: boolean; required: boolean; status: "default" | "success" | "error"; assistiveText: TextareaProps['assistiveText']; name: TextareaProps['name']; autocomplete: TextareaProps['autocomplete']; placeholder: TextareaProps['placeholder']; maxlength: TextareaProps['maxlength']; rows: TextareaProps['rows']; aria: TextareaProps['aria']; private _textarea; focusTarget: HTMLElement; private _abortController; connectedCallback(): void; disconnectedCallback(): void; protected firstUpdated(): void; protected updated(changedProperties: PropertyValues): void; private _throttledResize; /** * (Read-only) returns a ValidityState with the validity states that this element is in. * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity */ get validity(): ValidityState; /** * Called after the disabled state of the element changes, * either because the disabled attribute of this element was added or removed; * or because the disabled state changed on a
that's an ancestor of this element. * @param disabled - The latest disabled state of the input. */ formDisabledCallback(disabled: boolean): void; /** * Sets the selected text range on the underlying native textarea. */ setSelectionRange(selectionStart: number, selectionEnd: number, selectionDirection?: 'forward' | 'backward' | 'none'): void; /** * Called when the form that owns this component is reset. * Resets the value to the default value. */ formResetCallback(): void; private handleResize; /** * Handles input events and updates the component's value based on the input event or a provided new value. * * @param {InputEvent | null} event - The input event triggered by user interaction. If null, the `newValue` is used. * @param {string} [newValue] - An optional new value to set if the event is not provided. * * @private * @returns {void} */ private handleInput; private handleChange; private handleKeyDown; private renderAssistiveText; render(): TemplateResult<1>; static styles: CSSResult; } declare const PieTextarea_base: GenericConstructor & GenericConstructor & typeof PieElement; declare type PieTextareaEvents = { onInput?: (event: InputEvent) => void; onChange?: (event: CustomEvent) => void; }; declare type ReactBaseType = Omit, 'onChange' | 'onInput'>; export declare const resizeModes: readonly ["auto", "manual", "none"]; export declare const sizes: readonly ["small", "medium", "large"]; export declare const statusTypes: readonly ["default", "success", "error"]; export declare interface TextareaProps { /** * ARIA attributes for the textarea. */ aria?: AriaProps; /** * Same as the HTML disabled attribute - indicates whether the textarea is disabled. */ disabled?: boolean; /** * The size of the textarea field. Can be `small`, `medium` or `large`. Defaults to `medium`. */ size?: typeof sizes[number]; /** * The resize mode of the textarea. Can be `auto`, `manual` or `none`. Defaults to `auto`. * When set to `auto`, the textarea will resize vertically as needed. * When set to `manual`, the textarea will not resize automatically but can be resized by the user. * When set to `none`, the textarea will not resize automatically and cannot be resized by the user. */ resize?: typeof resizeModes[number]; /** * The value of the textarea (used as a key/value pair in HTML forms with `name`). */ value: string; /** * An optional default value to use when the textarea is reset. */ defaultValue?: string; /** * An optional assistive text to display below the textarea element. Must be provided when the status is success or error. */ assistiveText?: string; /** * The status of the textarea component / assistive text. Can be default, success or error. */ status?: typeof statusTypes[number]; /** * The name of the textarea (used as a key/value pair with `value`). This is required in order to work properly with forms. */ name?: string; /** * Allows the user to enable or disable autocomplete functionality on the textarea field. * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) for more information and values. */ autocomplete?: string; /** * If true, the textarea will be focused on the first render. * No more than one element in the document or dialog may have the autofocus attribute. If applied to multiple elements the first one will receive focus. * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus) for more information. */ autoFocus?: boolean; /** * When true, the user cannot edit the control. Not the same as disabled. * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly) for more information. */ readonly?: boolean; /** * If true, the textarea is required to have a value before submitting the form. If there is no value, then the component validity state will be invalid. */ required?: boolean; /** * The placeholder text to display when the textarea is empty. */ placeholder?: string; /** * The maximum number of characters allowed in the textarea. */ maxlength?: number; /** * The number of visible text rows. Defaults to 2 when resize is auto, with a maximum of 6 rows. * Can be set to 1 when resize is manual (no maximum height on desktop). On mobile, manual mode is fixed at 6 rows and cannot be resized. * When resize is none, follows the rows value set by the user, defaulting to 2 rows. */ rows?: number; } export { }