Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:cron-expression): adjust the layout
- Loading branch information
1 parent
9abeb86
commit 3271d4a
Showing
17 changed files
with
455 additions
and
525 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
components/cron-expression/cron-expression-input.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 }); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
components/cron-expression/cron-expression-label.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* 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, OnInit } from '@angular/core'; | ||
|
||
import { NzCronExpressionLabelI18n } from 'ng-zorro-antd/i18n'; | ||
|
||
import { TimeType, TimeTypeError } from './typings'; | ||
|
||
@Component({ | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None, | ||
selector: 'nz-cron-expression-label', | ||
exportAs: 'nzCronExpression', | ||
template: ` | ||
<div | ||
class="ant-cron-expression-label" | ||
[class.ant-cron-expression-label-foucs]="labelFocus === type" | ||
[class.ant-cron-expression-error]="!valid" | ||
> | ||
<label nz-tooltip [nzTooltipTitle]="error" [nzTooltipVisible]="!valid" nzTooltipPlacement="bottom"> | ||
{{ locale[type] }} | ||
</label> | ||
</div> | ||
<ng-template #error> | ||
<div class="ant-cron-expression-hint" [innerHTML]="locale[labelError]"></div> | ||
</ng-template> | ||
` | ||
}) | ||
export class NzCronExpressionLabelComponent implements OnInit { | ||
@Input() type: TimeType = 'second'; | ||
@Input() valid: boolean = true; | ||
@Input() locale!: NzCronExpressionLabelI18n; | ||
@Input() labelFocus: string | null = null; | ||
labelError: TimeTypeError = 'secondError'; | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void { | ||
this.labelError = `${this.type}Error`; | ||
} | ||
} |
Oops, something went wrong.