UNPKG

6.19 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2019 Google LLC
4 * SPDX-License-Identifier: Apache-2.0
5 */
6import '@material/mwc-notched-outline/mwc-notched-outline.js';
7import { MDCFloatingLabelFoundation } from '@material/floating-label/foundation.js';
8import { MDCLineRippleFoundation } from '@material/line-ripple/foundation.js';
9import { FormElement } from '@material/mwc-base/form-element.js';
10import { FloatingLabel } from '@material/mwc-floating-label/mwc-floating-label-directive.js';
11import { LineRipple } from '@material/mwc-line-ripple/mwc-line-ripple-directive.js';
12import { NotchedOutline } from '@material/mwc-notched-outline/mwc-notched-outline.js';
13import { MDCTextFieldAdapter, MDCTextFieldInputAdapter, MDCTextFieldLabelAdapter, MDCTextFieldLineRippleAdapter, MDCTextFieldOutlineAdapter, MDCTextFieldRootAdapter } from '@material/textfield/adapter.js';
14import MDCTextFieldFoundation from '@material/textfield/foundation.js';
15import { PropertyValues, TemplateResult } from 'lit';
16declare global {
17 interface HTMLElement {
18 floatingLabelFoundation?: MDCFloatingLabelFoundation;
19 lineRippleFoundation?: MDCLineRippleFoundation;
20 }
21 interface Element {
22 floatingLabelFoundation?: MDCFloatingLabelFoundation;
23 lineRippleFoundation?: MDCLineRippleFoundation;
24 }
25}
26/**
27 * This is the enumerated typeof HTMLInputElement.type as declared by
28 * lit-analyzer.
29 */
30export declare type TextFieldType = 'text' | 'search' | 'tel' | 'url' | 'email' | 'password' | 'date' | 'month' | 'week' | 'time' | 'datetime-local' | 'number' | 'color';
31/**
32 * This is the enumerated typeof HTMLInputElement.inputMode as declared by
33 * lit-analyzer.
34 */
35export declare type TextFieldInputMode = 'verbatim' | 'latin' | 'latin-name' | 'latin-prose' | 'full-width-latin' | 'kana' | 'kana-name' | 'katakana' | 'numeric' | 'tel' | 'email' | 'url';
36export declare type TextAreaCharCounter = 'external' | 'internal';
37/** @soyCompatible */
38export declare abstract class TextFieldBase extends FormElement {
39 protected mdcFoundation: MDCTextFieldFoundation;
40 protected readonly mdcFoundationClass: typeof MDCTextFieldFoundation;
41 protected mdcRoot: HTMLElement;
42 protected formElement: HTMLInputElement;
43 protected labelElement: FloatingLabel | null;
44 protected lineRippleElement: LineRipple | null;
45 protected outlineElement: NotchedOutline | null;
46 protected notchElement: HTMLElement;
47 value: string;
48 type: TextFieldType;
49 placeholder: string;
50 label: string;
51 icon: string;
52 iconTrailing: string;
53 disabled: boolean;
54 required: boolean;
55 minLength: number;
56 maxLength: number;
57 outlined: boolean;
58 helper: string;
59 validateOnInitialRender: boolean;
60 validationMessage: string;
61 autoValidate: boolean;
62 pattern: string;
63 min: number | string;
64 max: number | string;
65 /**
66 * step can be a number or the keyword "any".
67 *
68 * Use `String` typing to pass down the value as a string and let the native
69 * input cast internally as needed.
70 */
71 step: number | 'any' | null;
72 size: number | null;
73 helperPersistent: boolean;
74 charCounter: boolean | TextAreaCharCounter;
75 endAligned: boolean;
76 prefix: string;
77 suffix: string;
78 name: string;
79 inputMode: TextFieldInputMode;
80 readOnly: boolean;
81 autocapitalize: string;
82 protected outlineOpen: boolean;
83 protected outlineWidth: number;
84 protected isUiValid: boolean;
85 protected focused: boolean;
86 protected _validity: ValidityState;
87 get validity(): ValidityState;
88 get willValidate(): boolean;
89 get selectionStart(): number | null;
90 get selectionEnd(): number | null;
91 validityTransform: ((value: string, nativeValidity: ValidityState) => Partial<ValidityState>) | null;
92 focus(): void;
93 blur(): void;
94 select(): void;
95 setSelectionRange(selectionStart: number, selectionEnd: number, selectionDirection?: 'forward' | 'backward' | 'none'): void;
96 update(changedProperties: PropertyValues): void;
97 protected setFormData(formData: FormData): void;
98 /** @soyTemplate */
99 render(): TemplateResult;
100 updated(changedProperties: PropertyValues): void;
101 /** @soyTemplate */
102 protected renderRipple(): TemplateResult | string;
103 /** @soyTemplate */
104 protected renderOutline(): TemplateResult | string;
105 /** @soyTemplate */
106 protected renderLabel(): TemplateResult | string;
107 /** @soyTemplate */
108 protected renderLeadingIcon(): TemplateResult | string;
109 /** @soyTemplate */
110 protected renderTrailingIcon(): TemplateResult | string;
111 /** @soyTemplate */
112 protected renderIcon(icon: string, isTrailingIcon?: boolean): TemplateResult;
113 /** @soyTemplate */
114 protected renderPrefix(): TemplateResult | string;
115 /** @soyTemplate */
116 protected renderSuffix(): TemplateResult | string;
117 /** @soyTemplate */
118 protected renderAffix(content: string, isSuffix?: boolean): TemplateResult | string;
119 /** @soyTemplate */
120 protected renderInput(shouldRenderHelperText: boolean): TemplateResult;
121 /** @soyTemplate */
122 protected renderLineRipple(): TemplateResult | string;
123 /** @soyTemplate */
124 protected renderHelperText(shouldRenderHelperText: boolean, shouldRenderCharCounter: boolean): TemplateResult | string;
125 /** @soyTemplate */
126 protected renderCharCounter(shouldRenderCharCounter: boolean): TemplateResult | string;
127 protected onInputFocus(): void;
128 protected onInputBlur(): void;
129 checkValidity(): boolean;
130 reportValidity(): boolean;
131 protected _checkValidity(value: string): boolean;
132 setCustomValidity(message: string): void;
133 protected handleInputChange(): void;
134 protected createAdapter(): MDCTextFieldAdapter;
135 protected getRootAdapterMethods(): MDCTextFieldRootAdapter;
136 protected getInputAdapterMethods(): MDCTextFieldInputAdapter;
137 protected getLabelAdapterMethods(): MDCTextFieldLabelAdapter;
138 protected getLineRippleAdapterMethods(): MDCTextFieldLineRippleAdapter;
139 protected getUpdateComplete(): Promise<boolean>;
140 firstUpdated(): void;
141 protected getOutlineAdapterMethods(): MDCTextFieldOutlineAdapter;
142 layout(): Promise<void>;
143}
144
\No newline at end of file