-
Notifications
You must be signed in to change notification settings - Fork 0
/
kb-input.js
71 lines (62 loc) · 1.79 KB
/
kb-input.js
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
import {html, css, LitElement} from 'https://cdn.jsdelivr.net/gh/lit/dist@2/all/lit-all.min.js';
export class KBInput extends LitElement {
static formAssociated = false;
static properties = {
type: {type: String, reflect: true},
placeholder: {type: String, reflect: true},
name: {type: String, reflect: true},
expand: {type: Boolean, reflect: true},
};
constructor() {
super();
this.type = {};
this.placeholder = {};
this.name = {};
this.expand = false;
this.internals = this.attachInternals();
}
static get styles() {
return [
css`
input {
border: none;
height: 72px;
padding: 20px 12px;
background-clip: padding-box;
background-color: #fff;
border-radius: 2px;
color: #495057;
display: block;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
:host([expand]),
:host([expand]) input{
width: 100%;
}
:focus-visible {
outline: 0;
}
`];
}
render() {
return html`
<div>
<input type="${this.type}" name="${this.name}" placeholder="${this.placeholder}" @input="${this._onInput}">
</div>
`;
}
_onInput(event) {
this.value = event.target.value;
this.internals.setFormValue(this.value);
}
/** LitElement lifecycle method */
// firstUpdated(...args) {
// super.firstUpdated(...args);
// /** This ensures our element always participates in the form */
// this.internals.setFormValue(this.value);
// }
}
customElements.define('kb-input', KBInput);