adb-shared 2.0.31 → 2.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/components/adb-toast/adb-toast.mjs +15 -9
- package/esm2020/lib/components/adb-toast/adb-toast.service.mjs +34 -20
- package/fesm2015/adb-shared.mjs +48 -29
- package/fesm2015/adb-shared.mjs.map +1 -1
- package/fesm2020/adb-shared.mjs +47 -29
- package/fesm2020/adb-shared.mjs.map +1 -1
- package/lib/components/adb-toast/adb-toast.d.ts +7 -11
- package/lib/components/adb-toast/adb-toast.service.d.ts +20 -3
- package/package.json +1 -1
package/fesm2020/adb-shared.mjs
CHANGED
|
@@ -4,13 +4,14 @@ import * as i0 from '@angular/core';
|
|
|
4
4
|
import { Injectable, Inject, EventEmitter, Component, Output, Input, Directive, HostListener, NgModule, HostBinding, Pipe, forwardRef } from '@angular/core';
|
|
5
5
|
import * as i1$1 from '@ngx-translate/core';
|
|
6
6
|
import { TranslateModule } from '@ngx-translate/core';
|
|
7
|
-
import { Subscription, Subject } from 'rxjs';
|
|
7
|
+
import { Subscription, Subject, of } from 'rxjs';
|
|
8
8
|
import * as i1 from '@angular/common/http';
|
|
9
9
|
import { HttpClientModule } from '@angular/common/http';
|
|
10
10
|
import * as i1$2 from '@angular/router';
|
|
11
11
|
import { RouterModule } from '@angular/router';
|
|
12
12
|
import { isValid, parseISO, startOfDay, subYears, endOfDay, addYears, getMonth, subMonths, addMonths, isSameYear, startOfMonth, endOfMonth, eachWeekOfInterval, getISOWeek, addDays, eachDayOfInterval, getHours, getMinutes, isSameDay, isSameMonth, isWithinInterval } from 'date-fns';
|
|
13
13
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
14
|
+
import { delay } from 'rxjs/operators';
|
|
14
15
|
|
|
15
16
|
class EnvironmentService {
|
|
16
17
|
constructor(environment) {
|
|
@@ -996,53 +997,70 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
996
997
|
class AdbToastService {
|
|
997
998
|
constructor(componentFactoryResolver, rendererFactory, appRef, injector) {
|
|
998
999
|
this.componentFactoryResolver = componentFactoryResolver;
|
|
1000
|
+
this.rendererFactory = rendererFactory;
|
|
999
1001
|
this.appRef = appRef;
|
|
1000
1002
|
this.injector = injector;
|
|
1001
|
-
this.
|
|
1003
|
+
this.toasts = new Array();
|
|
1004
|
+
this.toastsSubject = new Subject();
|
|
1005
|
+
this.$toasts = this.toastsSubject.asObservable();
|
|
1006
|
+
}
|
|
1007
|
+
add(toastMessage, time = 4000) {
|
|
1008
|
+
this.addContainer();
|
|
1009
|
+
toastMessage.type = toastMessage.type ? toastMessage.type : ToastType.Success;
|
|
1010
|
+
toastMessage.index = this.toasts.length;
|
|
1011
|
+
toastMessage.delay = of(toastMessage).pipe(delay(time)).subscribe(toast => {
|
|
1012
|
+
this.remove(toast);
|
|
1013
|
+
});
|
|
1014
|
+
this.toasts.push(toastMessage);
|
|
1015
|
+
this.toastsSubject.next(this.toasts);
|
|
1016
|
+
}
|
|
1017
|
+
remove(toast) {
|
|
1018
|
+
this.toasts = this.toasts?.filter(x => x.index !== toast.index);
|
|
1019
|
+
this.toastsSubject.next(this.toasts);
|
|
1002
1020
|
}
|
|
1003
|
-
|
|
1021
|
+
addContainer() {
|
|
1004
1022
|
if (!this.container) {
|
|
1023
|
+
this.renderer = this.rendererFactory.createRenderer(null, null);
|
|
1024
|
+
//create container i top
|
|
1005
1025
|
this.container = this.renderer.createElement('div');
|
|
1006
|
-
this.container.setAttribute('adb-toast-container', '');
|
|
1007
|
-
this.container.classList.add('position-absolute', 'bottom-0', 'end-0');
|
|
1008
1026
|
this.renderer.appendChild(document.body, this.container);
|
|
1027
|
+
let componentRef = this.componentFactoryResolver.resolveComponentFactory(AdbToast).create(this.injector);
|
|
1028
|
+
this.appRef.attachView(componentRef.hostView);
|
|
1029
|
+
const element = componentRef.hostView.rootNodes[0];
|
|
1030
|
+
this.container.prepend(element);
|
|
1009
1031
|
}
|
|
1010
|
-
this.createToast(model);
|
|
1011
|
-
}
|
|
1012
|
-
createToast(model) {
|
|
1013
|
-
if (!model.state)
|
|
1014
|
-
model.state = 'info';
|
|
1015
|
-
if (!model.timeInMs)
|
|
1016
|
-
model.timeInMs = 4000;
|
|
1017
|
-
let componentRef = this.componentFactoryResolver.resolveComponentFactory(AdbToast).create(this.injector);
|
|
1018
|
-
componentRef.instance.model = model;
|
|
1019
|
-
this.appRef.attachView(componentRef.hostView);
|
|
1020
|
-
const element = componentRef.hostView.rootNodes[0];
|
|
1021
|
-
this.container.prepend(element);
|
|
1022
|
-
setTimeout(() => {
|
|
1023
|
-
// element.remove();
|
|
1024
|
-
}, model.timeInMs);
|
|
1025
1032
|
}
|
|
1026
1033
|
}
|
|
1027
1034
|
/** @nocollapse */ AdbToastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbToastService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.RendererFactory2 }, { token: i0.ApplicationRef }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1028
1035
|
/** @nocollapse */ AdbToastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbToastService });
|
|
1029
1036
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbToastService, decorators: [{
|
|
1030
1037
|
type: Injectable
|
|
1031
|
-
}], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.RendererFactory2 }, { type: i0.ApplicationRef }, { type: i0.Injector }]; } });
|
|
1038
|
+
}], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.RendererFactory2 }, { type: i0.ApplicationRef }, { type: i0.Injector }]; } });
|
|
1039
|
+
var ToastType;
|
|
1040
|
+
(function (ToastType) {
|
|
1041
|
+
ToastType[ToastType["Info"] = 1] = "Info";
|
|
1042
|
+
ToastType[ToastType["Success"] = 2] = "Success";
|
|
1043
|
+
ToastType[ToastType["Warn"] = 3] = "Warn";
|
|
1044
|
+
})(ToastType || (ToastType = {}));
|
|
1032
1045
|
|
|
1033
1046
|
class AdbToast {
|
|
1034
|
-
constructor(
|
|
1035
|
-
this.
|
|
1047
|
+
constructor(toastService) {
|
|
1048
|
+
this.toastService = toastService;
|
|
1049
|
+
this.toastType = ToastType;
|
|
1050
|
+
this.toastService.$toasts.subscribe(toasts => {
|
|
1051
|
+
this.toasts = toasts;
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
onRemoveToast(toast) {
|
|
1055
|
+
this.toastService.remove(toast);
|
|
1036
1056
|
}
|
|
1037
1057
|
}
|
|
1038
1058
|
/** @nocollapse */ AdbToast.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbToast, deps: [{ token: AdbToastService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1039
|
-
/** @nocollapse */ AdbToast.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: AdbToast, selector: "ng-component",
|
|
1059
|
+
/** @nocollapse */ AdbToast.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: AdbToast, selector: "ng-component", ngImport: i0, template: "<div class=\"position-fixed bottom-0 end-0\" style=\"z-index: 50000;min-width: 15rem;\">\r\n <div class=\"text-white px-3 pb-3 pt-2 mb-2\" *ngFor=\"let toast of toasts\"\r\n [class.bg-success]=\"toast.type===toastType.Success\" [class.bg-info]=\"toast.type===toastType.Info\" [class.bg-danger]=\"toast.type===toastType.Warn\">\r\n <div class=\"d-flex align-items-center justify-content-between pb-1\" *ngIf=\"toast.header\">\r\n <div class=\"fw-bold pb-1\">{{toast.header|translate}}</div>\r\n <button class=\"btn top-0 end-0 btn p-0 ms-2 text-white\" (click)=\"onRemoveToast(toast)\"><i class=\"fas fa-times\"></i></button>\r\n </div>\r\n <div class=\"d-flex align-items-center justify-content-between mt-1\">\r\n <div>{{toast.message|translate}}</div>\r\n <button *ngIf=\"!toast.header\" class=\"btn p-0 ms-2 text-white\" (click)=\"onRemoveToast(toast)\"><i class=\"fas fa-times\"></i></button>\r\n </div>\r\n </div>\r\n</div>", directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "translate": i1$1.TranslatePipe } });
|
|
1040
1060
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AdbToast, decorators: [{
|
|
1041
1061
|
type: Component,
|
|
1042
|
-
args: [{ template: "
|
|
1043
|
-
}], ctorParameters: function () { return [{ type: AdbToastService }]; }
|
|
1044
|
-
type: Input
|
|
1045
|
-
}] } });
|
|
1062
|
+
args: [{ template: "<div class=\"position-fixed bottom-0 end-0\" style=\"z-index: 50000;min-width: 15rem;\">\r\n <div class=\"text-white px-3 pb-3 pt-2 mb-2\" *ngFor=\"let toast of toasts\"\r\n [class.bg-success]=\"toast.type===toastType.Success\" [class.bg-info]=\"toast.type===toastType.Info\" [class.bg-danger]=\"toast.type===toastType.Warn\">\r\n <div class=\"d-flex align-items-center justify-content-between pb-1\" *ngIf=\"toast.header\">\r\n <div class=\"fw-bold pb-1\">{{toast.header|translate}}</div>\r\n <button class=\"btn top-0 end-0 btn p-0 ms-2 text-white\" (click)=\"onRemoveToast(toast)\"><i class=\"fas fa-times\"></i></button>\r\n </div>\r\n <div class=\"d-flex align-items-center justify-content-between mt-1\">\r\n <div>{{toast.message|translate}}</div>\r\n <button *ngIf=\"!toast.header\" class=\"btn p-0 ms-2 text-white\" (click)=\"onRemoveToast(toast)\"><i class=\"fas fa-times\"></i></button>\r\n </div>\r\n </div>\r\n</div>" }]
|
|
1063
|
+
}], ctorParameters: function () { return [{ type: AdbToastService }]; } });
|
|
1046
1064
|
|
|
1047
1065
|
class AdbToastModule {
|
|
1048
1066
|
}
|
|
@@ -1067,5 +1085,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
1067
1085
|
* Generated bundle index. Do not edit.
|
|
1068
1086
|
*/
|
|
1069
1087
|
|
|
1070
|
-
export { ADBHeaderComponent, ADBHeaderModule, AdbConfirmModal, AdbDatePickerComponent, AdbDatePickerDirective, AdbDatePickerModule, AdbDirectivesModule, AdbDropdownDirective, AdbDropdownModule, AdbModalModule, AdbModalService, AdbPagersModule, AdbPipesModule, AdbToast, AdbToastModule, AdbToastService, ClickOutsideDirective, FileUploadDirective, FocusDirective, HighlightPipe, InfiniteScrollComponent, LocaleDatePipe, NumberSpacingPipe, PagerComponent };
|
|
1088
|
+
export { ADBHeaderComponent, ADBHeaderModule, AdbConfirmModal, AdbDatePickerComponent, AdbDatePickerDirective, AdbDatePickerModule, AdbDirectivesModule, AdbDropdownDirective, AdbDropdownModule, AdbModalModule, AdbModalService, AdbPagersModule, AdbPipesModule, AdbToast, AdbToastModule, AdbToastService, ClickOutsideDirective, FileUploadDirective, FocusDirective, HighlightPipe, InfiniteScrollComponent, LocaleDatePipe, NumberSpacingPipe, PagerComponent, ToastType };
|
|
1071
1089
|
//# sourceMappingURL=adb-shared.mjs.map
|