-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtextfield.ts
81 lines (73 loc) · 1.96 KB
/
textfield.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { customElement, html, property, TemplateResult } from "lit-element";
import { ifDefined } from "lit-html/directives/if-defined";
import { TextfieldType } from "./textfield-type";
import { ITextfieldBehaviorProperties, TextfieldBehavior } from "../behavior/textfield/textfield-behavior";
import { cssResult } from "../util/css";
import styles from "./textfield.scss";
/**
* Properties of the textfield.
*/
export interface ITextfieldProperties extends ITextfieldBehaviorProperties {
list?: string;
min?: number;
max?: number;
type: TextfieldType;
}
/**
* Singleline text fields.
*/
@customElement("wl-textfield")
export class Textfield extends TextfieldBehavior implements ITextfieldProperties {
static styles = [...TextfieldBehavior.styles, cssResult(styles)];
/**
* Datalist id.
* @attr
*/
@property({ type: String }) list?: string;
/**
* Type of the input.
* @attr
*/
@property({ type: String, reflect: true }) type: TextfieldType = "text";
/**
* Min number value.
* @attr
*/
@property({ type: Number }) min?: number;
/**
* Max number value.
* @attr
*/
@property({ type: Number }) max?: number;
/**
* Renders the form element
*/
protected renderFormElement(): TemplateResult {
return html`
<input
id="${this.formElementId}"
.value="${this.value}"
value="${ifDefined(this.initialValue)}"
?required="${this.required}"
?disabled="${this.disabled}"
?readonly="${this.readonly}"
aria-label="${ifDefined(this.label)}"
type="${ifDefined(this.type)}"
name="${ifDefined(this.name)}"
list="${ifDefined(this.list)}"
pattern="${ifDefined(this.pattern)}"
autocomplete="${ifDefined(this.autocomplete)}"
minlength="${ifDefined(this.minLength)}"
maxlength="${ifDefined(this.maxLength)}"
min="${ifDefined(this.min)}"
max="${ifDefined(this.max)}"
tabindex="${this.disabled ? -1 : 0}"
/>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"wl-textfield": Textfield;
}
}