1 | import { Directive, ElementRef, Optional, HostListener, NgModule } from '@angular/core';
|
2 | import { NgModel } from '@angular/forms';
|
3 | import { CommonModule } from '@angular/common';
|
4 |
|
5 | class InputText {
|
6 | constructor(el, ngModel) {
|
7 | this.el = el;
|
8 | this.ngModel = ngModel;
|
9 | }
|
10 | ngDoCheck() {
|
11 | this.updateFilledState();
|
12 | }
|
13 | onInput(e) {
|
14 | this.updateFilledState();
|
15 | }
|
16 | updateFilledState() {
|
17 | this.filled = (this.el.nativeElement.value && this.el.nativeElement.value.length) ||
|
18 | (this.ngModel && this.ngModel.model);
|
19 | }
|
20 | }
|
21 | InputText.decorators = [
|
22 | { type: Directive, args: [{
|
23 | selector: '[pInputText]',
|
24 | host: {
|
25 | '[class.p-inputtext]': 'true',
|
26 | '[class.p-component]': 'true',
|
27 | '[class.p-filled]': 'filled'
|
28 | }
|
29 | },] }
|
30 | ];
|
31 | InputText.ctorParameters = () => [
|
32 | { type: ElementRef },
|
33 | { type: NgModel, decorators: [{ type: Optional }] }
|
34 | ];
|
35 | InputText.propDecorators = {
|
36 | onInput: [{ type: HostListener, args: ['input', ['$event'],] }]
|
37 | };
|
38 | class InputTextModule {
|
39 | }
|
40 | InputTextModule.decorators = [
|
41 | { type: NgModule, args: [{
|
42 | imports: [CommonModule],
|
43 | exports: [InputText],
|
44 | declarations: [InputText]
|
45 | },] }
|
46 | ];
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | export { InputText, InputTextModule };
|
53 |
|