-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
cron-expression-input.component.ts
49 lines (42 loc) · 1.4 KB
/
cron-expression-input.component.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
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core';
import { CronChangeType, TimeType } from './typings';
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-cron-expression-input',
exportAs: 'nzCronExpression',
template: `
<div class="ant-cron-expression-input">
<input
nz-input
[(ngModel)]="value"
[name]="label"
(focus)="focusInputEffect($event)"
(blur)="blurInputEffect()"
(ngModelChange)="setValue()"
/>
</div>
`
})
export class NzCronExpressionInputComponent {
@Input() value: string = '0';
@Input() label: TimeType = 'second';
@Output() readonly focusEffect = new EventEmitter<TimeType>();
@Output() readonly blurEffect = new EventEmitter<void>();
@Output() readonly getValue = new EventEmitter<CronChangeType>();
constructor() {}
focusInputEffect(event: FocusEvent): void {
this.focusEffect.emit(this.label);
(event.target as HTMLInputElement).select();
}
blurInputEffect(): void {
this.blurEffect.emit();
}
setValue(): void {
this.getValue.emit({ label: this.label, value: this.value });
}
}