Icard/angular-clarity-master(work.../node_modules/ngx-toastr/esm2022/toastr/toast.component.mjs

273 lines
31 KiB
JavaScript

import { animate, state, style, transition, trigger } from '@angular/animations';
import { Component, HostBinding, HostListener, } from '@angular/core';
import { NgIf } from '@angular/common';
import * as i0 from "@angular/core";
import * as i1 from "./toastr.service";
import * as i2 from "./toastr-config";
class Toast {
toastrService;
toastPackage;
ngZone;
message;
title;
options;
duplicatesCount;
originalTimeout;
/** width of progress bar */
width = -1;
/** a combination of toast type and options.toastClass */
toastClasses = '';
/** controls animation */
state;
/** hides component when waiting to be displayed */
get displayStyle() {
if (this.state.value === 'inactive') {
return 'none';
}
return;
}
timeout;
intervalId;
hideTime;
sub;
sub1;
sub2;
sub3;
constructor(toastrService, toastPackage, ngZone) {
this.toastrService = toastrService;
this.toastPackage = toastPackage;
this.ngZone = ngZone;
this.message = toastPackage.message;
this.title = toastPackage.title;
this.options = toastPackage.config;
this.originalTimeout = toastPackage.config.timeOut;
this.toastClasses = `${toastPackage.toastType} ${toastPackage.config.toastClass}`;
this.sub = toastPackage.toastRef.afterActivate().subscribe(() => {
this.activateToast();
});
this.sub1 = toastPackage.toastRef.manualClosed().subscribe(() => {
this.remove();
});
this.sub2 = toastPackage.toastRef.timeoutReset().subscribe(() => {
this.resetTimeout();
});
this.sub3 = toastPackage.toastRef.countDuplicate().subscribe(count => {
this.duplicatesCount = count;
});
this.state = {
value: 'inactive',
params: {
easeTime: this.toastPackage.config.easeTime,
easing: 'ease-in',
},
};
}
ngOnDestroy() {
this.sub.unsubscribe();
this.sub1.unsubscribe();
this.sub2.unsubscribe();
this.sub3.unsubscribe();
clearInterval(this.intervalId);
clearTimeout(this.timeout);
}
/**
* activates toast and sets timeout
*/
activateToast() {
this.state = { ...this.state, value: 'active' };
if (!(this.options.disableTimeOut === true || this.options.disableTimeOut === 'timeOut') &&
this.options.timeOut) {
this.outsideTimeout(() => this.remove(), this.options.timeOut);
this.hideTime = new Date().getTime() + this.options.timeOut;
if (this.options.progressBar) {
this.outsideInterval(() => this.updateProgress(), 10);
}
}
}
/**
* updates progress bar width
*/
updateProgress() {
if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
return;
}
const now = new Date().getTime();
const remaining = this.hideTime - now;
this.width = (remaining / this.options.timeOut) * 100;
if (this.options.progressAnimation === 'increasing') {
this.width = 100 - this.width;
}
if (this.width <= 0) {
this.width = 0;
}
if (this.width >= 100) {
this.width = 100;
}
}
resetTimeout() {
clearTimeout(this.timeout);
clearInterval(this.intervalId);
this.state = { ...this.state, value: 'active' };
this.outsideTimeout(() => this.remove(), this.originalTimeout);
this.options.timeOut = this.originalTimeout;
this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
this.width = -1;
if (this.options.progressBar) {
this.outsideInterval(() => this.updateProgress(), 10);
}
}
/**
* tells toastrService to remove this toast after animation time
*/
remove() {
if (this.state.value === 'removed') {
return;
}
clearTimeout(this.timeout);
this.state = { ...this.state, value: 'removed' };
this.outsideTimeout(() => this.toastrService.remove(this.toastPackage.toastId), +this.toastPackage.config.easeTime);
}
tapToast() {
if (this.state.value === 'removed') {
return;
}
this.toastPackage.triggerTap();
if (this.options.tapToDismiss) {
this.remove();
}
}
stickAround() {
if (this.state.value === 'removed') {
return;
}
if (this.options.disableTimeOut !== 'extendedTimeOut') {
clearTimeout(this.timeout);
this.options.timeOut = 0;
this.hideTime = 0;
// disable progressBar
clearInterval(this.intervalId);
this.width = 0;
}
}
delayedHideToast() {
if ((this.options.disableTimeOut === true || this.options.disableTimeOut === 'extendedTimeOut') ||
this.options.extendedTimeOut === 0 ||
this.state.value === 'removed') {
return;
}
this.outsideTimeout(() => this.remove(), this.options.extendedTimeOut);
this.options.timeOut = this.options.extendedTimeOut;
this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
this.width = -1;
if (this.options.progressBar) {
this.outsideInterval(() => this.updateProgress(), 10);
}
}
outsideTimeout(func, timeout) {
if (this.ngZone) {
this.ngZone.runOutsideAngular(() => (this.timeout = setTimeout(() => this.runInsideAngular(func), timeout)));
}
else {
this.timeout = setTimeout(() => func(), timeout);
}
}
outsideInterval(func, timeout) {
if (this.ngZone) {
this.ngZone.runOutsideAngular(() => (this.intervalId = setInterval(() => this.runInsideAngular(func), timeout)));
}
else {
this.intervalId = setInterval(() => func(), timeout);
}
}
runInsideAngular(func) {
if (this.ngZone) {
this.ngZone.run(() => func());
}
else {
func();
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: Toast, deps: [{ token: i1.ToastrService }, { token: i2.ToastPackage }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.1", type: Toast, isStandalone: true, selector: "[toast-component]", host: { listeners: { "click": "tapToast()", "mouseenter": "stickAround()", "mouseleave": "delayedHideToast()" }, properties: { "class": "this.toastClasses", "@flyInOut": "this.state", "style.display": "this.displayStyle" } }, ngImport: i0, template: `
<button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<div *ngIf="title" [class]="options.titleClass" [attr.aria-label]="title">
{{ title }} <ng-container *ngIf="duplicatesCount">[{{ duplicatesCount + 1 }}]</ng-container>
</div>
<div *ngIf="message && options.enableHtml" role="alert"
[class]="options.messageClass" [innerHTML]="message">
</div>
<div *ngIf="message && !options.enableHtml" role="alert"
[class]="options.messageClass" [attr.aria-label]="message">
{{ message }}
</div>
<div *ngIf="options.progressBar">
<div class="toast-progress" [style.width]="width + '%'"></div>
</div>
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], animations: [
trigger('flyInOut', [
state('inactive', style({ opacity: 0 })),
state('active', style({ opacity: 1 })),
state('removed', style({ opacity: 0 })),
transition('inactive => active', animate('{{ easeTime }}ms {{ easing }}')),
transition('active => removed', animate('{{ easeTime }}ms {{ easing }}')),
]),
] });
}
export { Toast };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.1", ngImport: i0, type: Toast, decorators: [{
type: Component,
args: [{
selector: '[toast-component]',
template: `
<button *ngIf="options.closeButton" (click)="remove()" type="button" class="toast-close-button" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<div *ngIf="title" [class]="options.titleClass" [attr.aria-label]="title">
{{ title }} <ng-container *ngIf="duplicatesCount">[{{ duplicatesCount + 1 }}]</ng-container>
</div>
<div *ngIf="message && options.enableHtml" role="alert"
[class]="options.messageClass" [innerHTML]="message">
</div>
<div *ngIf="message && !options.enableHtml" role="alert"
[class]="options.messageClass" [attr.aria-label]="message">
{{ message }}
</div>
<div *ngIf="options.progressBar">
<div class="toast-progress" [style.width]="width + '%'"></div>
</div>
`,
animations: [
trigger('flyInOut', [
state('inactive', style({ opacity: 0 })),
state('active', style({ opacity: 1 })),
state('removed', style({ opacity: 0 })),
transition('inactive => active', animate('{{ easeTime }}ms {{ easing }}')),
transition('active => removed', animate('{{ easeTime }}ms {{ easing }}')),
]),
],
preserveWhitespaces: false,
standalone: true,
imports: [NgIf],
}]
}], ctorParameters: function () { return [{ type: i1.ToastrService }, { type: i2.ToastPackage }, { type: i0.NgZone }]; }, propDecorators: { toastClasses: [{
type: HostBinding,
args: ['class']
}], state: [{
type: HostBinding,
args: ['@flyInOut']
}], displayStyle: [{
type: HostBinding,
args: ['style.display']
}], tapToast: [{
type: HostListener,
args: ['click']
}], stickAround: [{
type: HostListener,
args: ['mouseenter']
}], delayedHideToast: [{
type: HostListener,
args: ['mouseleave']
}] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9hc3QuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi90b2FzdHIvdG9hc3QuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3M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