-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirm-dialog.ts
More file actions
63 lines (56 loc) · 1.78 KB
/
Copy pathconfirm-dialog.ts
File metadata and controls
63 lines (56 loc) · 1.78 KB
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
import { Component, ChangeDetectionStrategy, input, output } from '@angular/core';
import { AppIconComponent } from '../icon/app-icon';
import { ButtonComponent } from '../button/button';
@Component({
selector: 'app-confirm-dialog',
standalone: true,
imports: [AppIconComponent, ButtonComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './confirm-dialog.html',
styleUrl: './confirm-dialog.css',
})
export class ConfirmDialogComponent {
readonly isOpen = input.required<boolean>();
readonly title = input<string>('Confirmar Ação');
readonly message = input<string>('Tem certeza de que deseja realizar esta operação?');
readonly type = input<'danger' | 'warning' | 'info'>('danger');
readonly confirmText = input<string>('Confirmar');
readonly cancelText = input<string>('Cancelar');
readonly confirmAction = output<void>();
readonly cancelAction = output<void>();
onConfirm(): void {
this.confirmAction.emit();
}
onCancel(): void {
this.cancelAction.emit();
}
get confirmVariant(): () => 'danger' | 'primary' {
return () => (this.type() === 'danger' ? 'danger' : 'primary');
}
get typeIcon(): () => string {
return () => {
switch (this.type()) {
case 'danger':
return 'trash-2';
case 'warning':
return 'alert-circle';
case 'info':
default:
return 'info';
}
};
}
get iconBgClass(): () => string {
return () => {
switch (this.type()) {
case 'danger':
return 'bg-rose-50 dark:bg-rose-950/40 text-[#D66A6A]';
case 'warning':
return 'bg-amber-50 dark:bg-amber-950/40 text-[#E9B949]';
case 'info':
default:
return 'bg-blue-50 dark:bg-blue-950/40 text-[#5A8DEE]';
}
};
}
}