-
Notifications
You must be signed in to change notification settings - Fork 237
/
textarea.ts
40 lines (36 loc) · 1.15 KB
/
textarea.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
// @ts-ignore
import autosize from "autosize/src/autosize";
import { element, html, property } from "./base";
import { BaseInput } from "./base-input";
@element("pl-textarea")
export class Textarea extends BaseInput {
@property()
autosize: boolean = false;
updated() {
if (this.autosize) {
setTimeout(() => autosize(this._inputElement));
}
}
_renderInput() {
const { placeholder, readonly, noTab, disabled, autocapitalize, required } = this;
return html`
<textarea
class="input-element"
.placeholder=${placeholder}
.tabIndex=${noTab ? "-1" : ""}
?readonly=${readonly}
?disabled=${disabled}
?required=${required}
autocapitalize=${autocapitalize}
autocomplete="off"
spellcheck="false"
autocorrect="off"
rows="1"
@focus=${this._focused}
@blur=${this._blurred}
@change=${this._changeHandler}
@touchend=${this._touchend}
></textarea>
`;
}
}