UNPKG

web-ui-pack

Version:
82 lines (80 loc) 3.25 kB
import WUPTextControl from "./text"; declare const tagName = "wup-textarea"; declare global { namespace WUP.Textarea { interface EventMap extends WUP.Text.EventMap { } interface ValidityMap extends WUP.Text.ValidityMap { } interface Options<T = string, VM = ValidityMap> extends Omit<WUP.Text.Options<T, VM>, "mask" | "maskholder" | "prefix" | "postfix"> { } interface JSXProps<C = WUPTextareaControl> extends Omit<WUP.Text.JSXProps<C>, "mask" | "maskholder" | "prefix" | "postfix"> { } } interface HTMLElementTagNameMap { [tagName]: WUPTextareaControl; } } declare module "react" { namespace JSX { interface IntrinsicElements { /** Form-control with multiline text-input * @see {@link WUPTextareaControl} */ [tagName]: WUP.Base.ReactHTML<WUPTextareaControl> & WUP.Textarea.JSXProps; } } } declare module "preact/jsx-runtime" { namespace JSX { interface HTMLAttributes<RefType> { } interface IntrinsicElements { /** Form-control with multiline text-input * @see {@link WUPTextareaControl} */ [tagName]: HTMLAttributes<WUPTextareaControl> & WUP.Textarea.JSXProps; } } } /** Form-control with multiline text-input * @see demo {@link https://yegorich555.github.io/web-ui-pack/control/textarea} * @example const el = document.createElement("wup-textarea"); el.$options.name = "textarea"; el.$options.validations = { required: true, max: 250 }; const form = document.body.appendChild(document.createElement("wup-form")); form.appendChild(el); // or HTML <wup-form> <wup-textarea w-name="textarea" w-validations="myValidations"/> </wup-form>; * @tutorial innerHTML @example * <label> * <span> // extra span requires to use with icons via label:before, label:after without adjustments * <span contenteditable="true" /> * <strong>{$options.label}</strong> * </span> * <button clear/> * </label> * @tutorial Troubleshooting * * known issue: NVDA doesn't read multiline text https://github.com/nvaccess/nvda/issues/13369 * to resolve it set WUPTextareaControl.$defaults.selectOnFocus = true */ export default class WUPTextareaControl<ValueType = string, TOptions extends WUP.Textarea.Options = WUP.Textarea.Options, EventMap extends WUP.Textarea.EventMap = WUP.Textarea.EventMap> extends WUPTextControl<ValueType, TOptions, EventMap> { /** Returns this.constructor // watch-fix: https://github.com/Microsoft/TypeScript/issues/3841#issuecomment-337560146 */ static get $style(): string; /** Default options - applied to every element. Change it to configure default behavior */ static $defaults: WUP.Textarea.Options; $refInput: HTMLInputElement; protected renderControl(): void; protected gotChanges(propsChanged: Array<keyof WUP.Textarea.Options> | null): void; protected renderPrefix(): void; protected renderPostfix(): void; protected gotKeyDown(e: KeyboardEvent & { submitPrevented?: boolean; }): void; protected gotBeforeInput(e: WUP.Text.GotInputEvent): void; protected gotFocusLost(): void; } export {};