26 lines
822 B
TypeScript
26 lines
822 B
TypeScript
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
import { Toast } from 'ngx-toastr';
|
|
import { ToasterActions, ToasterOptions } from '../../services';
|
|
import { MatIconModule } from '@angular/material/icon';
|
|
import { NgForOf, NgIf } from '@angular/common';
|
|
import { StopPropagationDirective } from '../../directives';
|
|
|
|
@Component({
|
|
templateUrl: './toast.component.html',
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
standalone: true,
|
|
imports: [MatIconModule, NgIf, StopPropagationDirective, NgForOf],
|
|
})
|
|
export class ToastComponent extends Toast {
|
|
get actions(): ToasterActions[] {
|
|
return (this.options as ToasterOptions)?.actions || [];
|
|
}
|
|
|
|
callAction(action: () => void): void {
|
|
if (action) {
|
|
action();
|
|
}
|
|
this.remove();
|
|
}
|
|
}
|