ngx-toastr 14.1.4 → 14.2.0

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.
Files changed (37) hide show
  1. package/{esm2015/ngx-toastr.js → esm2020/ngx-toastr.mjs} +0 -0
  2. package/esm2020/overlay/overlay-container.mjs +46 -0
  3. package/{esm2015/overlay/overlay-ref.js → esm2020/overlay/overlay-ref.mjs} +0 -0
  4. package/{esm2015/overlay/overlay.js → esm2020/overlay/overlay.mjs} +11 -14
  5. package/{esm2015/portal/dom-portal-host.js → esm2020/portal/dom-portal-host.mjs} +0 -0
  6. package/{esm2015/portal/portal.js → esm2020/portal/portal.mjs} +0 -0
  7. package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
  8. package/{esm2015/toastr/toast-injector.js → esm2020/toastr/toast-injector.mjs} +0 -0
  9. package/esm2020/toastr/toast-noanimation.component.mjs +237 -0
  10. package/esm2020/toastr/toast.component.mjs +251 -0
  11. package/esm2020/toastr/toast.directive.mjs +32 -0
  12. package/{esm2015/toastr/toastr-config.js → esm2020/toastr/toastr-config.mjs} +0 -0
  13. package/esm2020/toastr/toastr.module.mjs +63 -0
  14. package/esm2020/toastr/toastr.service.mjs +197 -0
  15. package/fesm2015/{ngx-toastr.js → ngx-toastr.mjs} +338 -262
  16. package/fesm2015/ngx-toastr.mjs.map +1 -0
  17. package/fesm2020/ngx-toastr.mjs +1170 -0
  18. package/fesm2020/ngx-toastr.mjs.map +1 -0
  19. package/ngx-toastr.d.ts +1 -0
  20. package/overlay/overlay-container.d.ts +3 -0
  21. package/overlay/overlay.d.ts +3 -0
  22. package/package.json +20 -8
  23. package/toastr/toast-noanimation.component.d.ts +7 -0
  24. package/toastr/toast.component.d.ts +3 -0
  25. package/toastr/toast.directive.d.ts +6 -0
  26. package/toastr/toastr.module.d.ts +9 -0
  27. package/toastr/toastr.service.d.ts +3 -0
  28. package/bundles/ngx-toastr.umd.js +0 -1508
  29. package/bundles/ngx-toastr.umd.js.map +0 -1
  30. package/esm2015/overlay/overlay-container.js +0 -45
  31. package/esm2015/toastr/toast-noanimation.component.js +0 -204
  32. package/esm2015/toastr/toast.component.js +0 -216
  33. package/esm2015/toastr/toast.directive.js +0 -27
  34. package/esm2015/toastr/toastr.module.js +0 -51
  35. package/esm2015/toastr/toastr.service.js +0 -196
  36. package/fesm2015/ngx-toastr.js.map +0 -1
  37. package/ngx-toastr.metadata.json +0 -1
@@ -1,1508 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/animations'), require('rxjs'), require('@angular/platform-browser'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('ngx-toastr', ['exports', '@angular/core', '@angular/animations', 'rxjs', '@angular/platform-browser', '@angular/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ngx-toastr'] = {}, global.ng.core, global.ng.animations, global.rxjs, global.ng.platformBrowser, global.ng.common));
5
- }(this, (function (exports, i0, animations, rxjs, i3, i1) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
- var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
29
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
30
-
31
- var ToastContainerDirective = /** @class */ (function () {
32
- function ToastContainerDirective(el) {
33
- this.el = el;
34
- }
35
- ToastContainerDirective.prototype.getContainerElement = function () {
36
- return this.el.nativeElement;
37
- };
38
- return ToastContainerDirective;
39
- }());
40
- ToastContainerDirective.decorators = [
41
- { type: i0.Directive, args: [{
42
- selector: '[toastContainer]',
43
- exportAs: 'toastContainer',
44
- },] }
45
- ];
46
- ToastContainerDirective.ctorParameters = function () { return [
47
- { type: i0.ElementRef }
48
- ]; };
49
- var ToastContainerModule = /** @class */ (function () {
50
- function ToastContainerModule() {
51
- }
52
- return ToastContainerModule;
53
- }());
54
- ToastContainerModule.decorators = [
55
- { type: i0.NgModule, args: [{
56
- declarations: [ToastContainerDirective],
57
- exports: [ToastContainerDirective],
58
- },] }
59
- ];
60
-
61
- /**
62
- * Everything a toast needs to launch
63
- */
64
- var ToastPackage = /** @class */ (function () {
65
- function ToastPackage(toastId, config, message, title, toastType, toastRef) {
66
- var _this = this;
67
- this.toastId = toastId;
68
- this.config = config;
69
- this.message = message;
70
- this.title = title;
71
- this.toastType = toastType;
72
- this.toastRef = toastRef;
73
- this._onTap = new rxjs.Subject();
74
- this._onAction = new rxjs.Subject();
75
- this.toastRef.afterClosed().subscribe(function () {
76
- _this._onAction.complete();
77
- _this._onTap.complete();
78
- });
79
- }
80
- /** Fired on click */
81
- ToastPackage.prototype.triggerTap = function () {
82
- this._onTap.next();
83
- if (this.config.tapToDismiss) {
84
- this._onTap.complete();
85
- }
86
- };
87
- ToastPackage.prototype.onTap = function () {
88
- return this._onTap.asObservable();
89
- };
90
- /** available for use in custom toast */
91
- ToastPackage.prototype.triggerAction = function (action) {
92
- this._onAction.next(action);
93
- };
94
- ToastPackage.prototype.onAction = function () {
95
- return this._onAction.asObservable();
96
- };
97
- return ToastPackage;
98
- }());
99
- var DefaultNoComponentGlobalConfig = {
100
- maxOpened: 0,
101
- autoDismiss: false,
102
- newestOnTop: true,
103
- preventDuplicates: false,
104
- countDuplicates: false,
105
- resetTimeoutOnDuplicate: false,
106
- includeTitleDuplicates: false,
107
- iconClasses: {
108
- error: 'toast-error',
109
- info: 'toast-info',
110
- success: 'toast-success',
111
- warning: 'toast-warning',
112
- },
113
- // Individual
114
- closeButton: false,
115
- disableTimeOut: false,
116
- timeOut: 5000,
117
- extendedTimeOut: 1000,
118
- enableHtml: false,
119
- progressBar: false,
120
- toastClass: 'ngx-toastr',
121
- positionClass: 'toast-top-right',
122
- titleClass: 'toast-title',
123
- messageClass: 'toast-message',
124
- easing: 'ease-in',
125
- easeTime: 300,
126
- tapToDismiss: true,
127
- onActivateTick: false,
128
- progressAnimation: 'decreasing',
129
- payload: null
130
- };
131
- var TOAST_CONFIG = new i0.InjectionToken('ToastConfig');
132
-
133
- /*! *****************************************************************************
134
- Copyright (c) Microsoft Corporation.
135
-
136
- Permission to use, copy, modify, and/or distribute this software for any
137
- purpose with or without fee is hereby granted.
138
-
139
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
140
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
141
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
142
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
143
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
144
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
145
- PERFORMANCE OF THIS SOFTWARE.
146
- ***************************************************************************** */
147
- /* global Reflect, Promise */
148
- var extendStatics = function (d, b) {
149
- extendStatics = Object.setPrototypeOf ||
150
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
151
- function (d, b) { for (var p in b)
152
- if (Object.prototype.hasOwnProperty.call(b, p))
153
- d[p] = b[p]; };
154
- return extendStatics(d, b);
155
- };
156
- function __extends(d, b) {
157
- if (typeof b !== "function" && b !== null)
158
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
159
- extendStatics(d, b);
160
- function __() { this.constructor = d; }
161
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
162
- }
163
- var __assign = function () {
164
- __assign = Object.assign || function __assign(t) {
165
- for (var s, i = 1, n = arguments.length; i < n; i++) {
166
- s = arguments[i];
167
- for (var p in s)
168
- if (Object.prototype.hasOwnProperty.call(s, p))
169
- t[p] = s[p];
170
- }
171
- return t;
172
- };
173
- return __assign.apply(this, arguments);
174
- };
175
- function __rest(s, e) {
176
- var t = {};
177
- for (var p in s)
178
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
179
- t[p] = s[p];
180
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
181
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
182
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
183
- t[p[i]] = s[p[i]];
184
- }
185
- return t;
186
- }
187
- function __decorate(decorators, target, key, desc) {
188
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
189
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
190
- r = Reflect.decorate(decorators, target, key, desc);
191
- else
192
- for (var i = decorators.length - 1; i >= 0; i--)
193
- if (d = decorators[i])
194
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
195
- return c > 3 && r && Object.defineProperty(target, key, r), r;
196
- }
197
- function __param(paramIndex, decorator) {
198
- return function (target, key) { decorator(target, key, paramIndex); };
199
- }
200
- function __metadata(metadataKey, metadataValue) {
201
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
202
- return Reflect.metadata(metadataKey, metadataValue);
203
- }
204
- function __awaiter(thisArg, _arguments, P, generator) {
205
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
206
- return new (P || (P = Promise))(function (resolve, reject) {
207
- function fulfilled(value) { try {
208
- step(generator.next(value));
209
- }
210
- catch (e) {
211
- reject(e);
212
- } }
213
- function rejected(value) { try {
214
- step(generator["throw"](value));
215
- }
216
- catch (e) {
217
- reject(e);
218
- } }
219
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
220
- step((generator = generator.apply(thisArg, _arguments || [])).next());
221
- });
222
- }
223
- function __generator(thisArg, body) {
224
- var _ = { label: 0, sent: function () { if (t[0] & 1)
225
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
226
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
227
- function verb(n) { return function (v) { return step([n, v]); }; }
228
- function step(op) {
229
- if (f)
230
- throw new TypeError("Generator is already executing.");
231
- while (_)
232
- try {
233
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
234
- return t;
235
- if (y = 0, t)
236
- op = [op[0] & 2, t.value];
237
- switch (op[0]) {
238
- case 0:
239
- case 1:
240
- t = op;
241
- break;
242
- case 4:
243
- _.label++;
244
- return { value: op[1], done: false };
245
- case 5:
246
- _.label++;
247
- y = op[1];
248
- op = [0];
249
- continue;
250
- case 7:
251
- op = _.ops.pop();
252
- _.trys.pop();
253
- continue;
254
- default:
255
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
256
- _ = 0;
257
- continue;
258
- }
259
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
260
- _.label = op[1];
261
- break;
262
- }
263
- if (op[0] === 6 && _.label < t[1]) {
264
- _.label = t[1];
265
- t = op;
266
- break;
267
- }
268
- if (t && _.label < t[2]) {
269
- _.label = t[2];
270
- _.ops.push(op);
271
- break;
272
- }
273
- if (t[2])
274
- _.ops.pop();
275
- _.trys.pop();
276
- continue;
277
- }
278
- op = body.call(thisArg, _);
279
- }
280
- catch (e) {
281
- op = [6, e];
282
- y = 0;
283
- }
284
- finally {
285
- f = t = 0;
286
- }
287
- if (op[0] & 5)
288
- throw op[1];
289
- return { value: op[0] ? op[1] : void 0, done: true };
290
- }
291
- }
292
- var __createBinding = Object.create ? (function (o, m, k, k2) {
293
- if (k2 === undefined)
294
- k2 = k;
295
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
296
- }) : (function (o, m, k, k2) {
297
- if (k2 === undefined)
298
- k2 = k;
299
- o[k2] = m[k];
300
- });
301
- function __exportStar(m, o) {
302
- for (var p in m)
303
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
304
- __createBinding(o, m, p);
305
- }
306
- function __values(o) {
307
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
308
- if (m)
309
- return m.call(o);
310
- if (o && typeof o.length === "number")
311
- return {
312
- next: function () {
313
- if (o && i >= o.length)
314
- o = void 0;
315
- return { value: o && o[i++], done: !o };
316
- }
317
- };
318
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
319
- }
320
- function __read(o, n) {
321
- var m = typeof Symbol === "function" && o[Symbol.iterator];
322
- if (!m)
323
- return o;
324
- var i = m.call(o), r, ar = [], e;
325
- try {
326
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
327
- ar.push(r.value);
328
- }
329
- catch (error) {
330
- e = { error: error };
331
- }
332
- finally {
333
- try {
334
- if (r && !r.done && (m = i["return"]))
335
- m.call(i);
336
- }
337
- finally {
338
- if (e)
339
- throw e.error;
340
- }
341
- }
342
- return ar;
343
- }
344
- /** @deprecated */
345
- function __spread() {
346
- for (var ar = [], i = 0; i < arguments.length; i++)
347
- ar = ar.concat(__read(arguments[i]));
348
- return ar;
349
- }
350
- /** @deprecated */
351
- function __spreadArrays() {
352
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
353
- s += arguments[i].length;
354
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
355
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
356
- r[k] = a[j];
357
- return r;
358
- }
359
- function __spreadArray(to, from, pack) {
360
- if (pack || arguments.length === 2)
361
- for (var i = 0, l = from.length, ar; i < l; i++) {
362
- if (ar || !(i in from)) {
363
- if (!ar)
364
- ar = Array.prototype.slice.call(from, 0, i);
365
- ar[i] = from[i];
366
- }
367
- }
368
- return to.concat(ar || Array.prototype.slice.call(from));
369
- }
370
- function __await(v) {
371
- return this instanceof __await ? (this.v = v, this) : new __await(v);
372
- }
373
- function __asyncGenerator(thisArg, _arguments, generator) {
374
- if (!Symbol.asyncIterator)
375
- throw new TypeError("Symbol.asyncIterator is not defined.");
376
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
377
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
378
- function verb(n) { if (g[n])
379
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
380
- function resume(n, v) { try {
381
- step(g[n](v));
382
- }
383
- catch (e) {
384
- settle(q[0][3], e);
385
- } }
386
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
387
- function fulfill(value) { resume("next", value); }
388
- function reject(value) { resume("throw", value); }
389
- function settle(f, v) { if (f(v), q.shift(), q.length)
390
- resume(q[0][0], q[0][1]); }
391
- }
392
- function __asyncDelegator(o) {
393
- var i, p;
394
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
395
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
396
- }
397
- function __asyncValues(o) {
398
- if (!Symbol.asyncIterator)
399
- throw new TypeError("Symbol.asyncIterator is not defined.");
400
- var m = o[Symbol.asyncIterator], i;
401
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
402
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
403
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
404
- }
405
- function __makeTemplateObject(cooked, raw) {
406
- if (Object.defineProperty) {
407
- Object.defineProperty(cooked, "raw", { value: raw });
408
- }
409
- else {
410
- cooked.raw = raw;
411
- }
412
- return cooked;
413
- }
414
- ;
415
- var __setModuleDefault = Object.create ? (function (o, v) {
416
- Object.defineProperty(o, "default", { enumerable: true, value: v });
417
- }) : function (o, v) {
418
- o["default"] = v;
419
- };
420
- function __importStar(mod) {
421
- if (mod && mod.__esModule)
422
- return mod;
423
- var result = {};
424
- if (mod != null)
425
- for (var k in mod)
426
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
427
- __createBinding(result, mod, k);
428
- __setModuleDefault(result, mod);
429
- return result;
430
- }
431
- function __importDefault(mod) {
432
- return (mod && mod.__esModule) ? mod : { default: mod };
433
- }
434
- function __classPrivateFieldGet(receiver, state, kind, f) {
435
- if (kind === "a" && !f)
436
- throw new TypeError("Private accessor was defined without a getter");
437
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
438
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
439
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
440
- }
441
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
442
- if (kind === "m")
443
- throw new TypeError("Private method is not writable");
444
- if (kind === "a" && !f)
445
- throw new TypeError("Private accessor was defined without a setter");
446
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
447
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
448
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
449
- }
450
-
451
- /**
452
- * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
453
- */
454
- var ComponentPortal = /** @class */ (function () {
455
- function ComponentPortal(component, injector) {
456
- this.component = component;
457
- this.injector = injector;
458
- }
459
- /** Attach this portal to a host. */
460
- ComponentPortal.prototype.attach = function (host, newestOnTop) {
461
- this._attachedHost = host;
462
- return host.attach(this, newestOnTop);
463
- };
464
- /** Detach this portal from its host */
465
- ComponentPortal.prototype.detach = function () {
466
- var host = this._attachedHost;
467
- if (host) {
468
- this._attachedHost = undefined;
469
- return host.detach();
470
- }
471
- };
472
- Object.defineProperty(ComponentPortal.prototype, "isAttached", {
473
- /** Whether this portal is attached to a host. */
474
- get: function () {
475
- return this._attachedHost != null;
476
- },
477
- enumerable: false,
478
- configurable: true
479
- });
480
- /**
481
- * Sets the PortalHost reference without performing `attach()`. This is used directly by
482
- * the PortalHost when it is performing an `attach()` or `detach()`.
483
- */
484
- ComponentPortal.prototype.setAttachedHost = function (host) {
485
- this._attachedHost = host;
486
- };
487
- return ComponentPortal;
488
- }());
489
- /**
490
- * Partial implementation of PortalHost that only deals with attaching a
491
- * ComponentPortal
492
- */
493
- var BasePortalHost = /** @class */ (function () {
494
- function BasePortalHost() {
495
- }
496
- BasePortalHost.prototype.attach = function (portal, newestOnTop) {
497
- this._attachedPortal = portal;
498
- return this.attachComponentPortal(portal, newestOnTop);
499
- };
500
- BasePortalHost.prototype.detach = function () {
501
- if (this._attachedPortal) {
502
- this._attachedPortal.setAttachedHost();
503
- }
504
- this._attachedPortal = undefined;
505
- if (this._disposeFn) {
506
- this._disposeFn();
507
- this._disposeFn = undefined;
508
- }
509
- };
510
- BasePortalHost.prototype.setDisposeFn = function (fn) {
511
- this._disposeFn = fn;
512
- };
513
- return BasePortalHost;
514
- }());
515
-
516
- /**
517
- * A PortalHost for attaching portals to an arbitrary DOM element outside of the Angular
518
- * application context.
519
- *
520
- * This is the only part of the portal core that directly touches the DOM.
521
- */
522
- var DomPortalHost = /** @class */ (function (_super) {
523
- __extends(DomPortalHost, _super);
524
- function DomPortalHost(_hostDomElement, _componentFactoryResolver, _appRef) {
525
- var _this = _super.call(this) || this;
526
- _this._hostDomElement = _hostDomElement;
527
- _this._componentFactoryResolver = _componentFactoryResolver;
528
- _this._appRef = _appRef;
529
- return _this;
530
- }
531
- /**
532
- * Attach the given ComponentPortal to DOM element using the ComponentFactoryResolver.
533
- * @param portal Portal to be attached
534
- */
535
- DomPortalHost.prototype.attachComponentPortal = function (portal, newestOnTop) {
536
- var _this = this;
537
- var componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
538
- var componentRef;
539
- // If the portal specifies a ViewContainerRef, we will use that as the attachment point
540
- // for the component (in terms of Angular's component tree, not rendering).
541
- // When the ViewContainerRef is missing, we use the factory to create the component directly
542
- // and then manually attach the ChangeDetector for that component to the application (which
543
- // happens automatically when using a ViewContainer).
544
- componentRef = componentFactory.create(portal.injector);
545
- // When creating a component outside of a ViewContainer, we need to manually register
546
- // its ChangeDetector with the application. This API is unfortunately not yet published
547
- // in Angular core. The change detector must also be deregistered when the component
548
- // is destroyed to prevent memory leaks.
549
- this._appRef.attachView(componentRef.hostView);
550
- this.setDisposeFn(function () {
551
- _this._appRef.detachView(componentRef.hostView);
552
- componentRef.destroy();
553
- });
554
- // At this point the component has been instantiated, so we move it to the location in the DOM
555
- // where we want it to be rendered.
556
- if (newestOnTop) {
557
- this._hostDomElement.insertBefore(this._getComponentRootNode(componentRef), this._hostDomElement.firstChild);
558
- }
559
- else {
560
- this._hostDomElement.appendChild(this._getComponentRootNode(componentRef));
561
- }
562
- return componentRef;
563
- };
564
- /** Gets the root HTMLElement for an instantiated component. */
565
- DomPortalHost.prototype._getComponentRootNode = function (componentRef) {
566
- return componentRef.hostView.rootNodes[0];
567
- };
568
- return DomPortalHost;
569
- }(BasePortalHost));
570
-
571
- /** Container inside which all toasts will render. */
572
- var OverlayContainer = /** @class */ (function () {
573
- function OverlayContainer(_document) {
574
- this._document = _document;
575
- }
576
- OverlayContainer.prototype.ngOnDestroy = function () {
577
- if (this._containerElement && this._containerElement.parentNode) {
578
- this._containerElement.parentNode.removeChild(this._containerElement);
579
- }
580
- };
581
- /**
582
- * This method returns the overlay container element. It will lazily
583
- * create the element the first time it is called to facilitate using
584
- * the container in non-browser environments.
585
- * @returns the container element
586
- */
587
- OverlayContainer.prototype.getContainerElement = function () {
588
- if (!this._containerElement) {
589
- this._createContainer();
590
- }
591
- return this._containerElement;
592
- };
593
- /**
594
- * Create the overlay container element, which is simply a div
595
- * with the 'cdk-overlay-container' class on the document body.
596
- */
597
- OverlayContainer.prototype._createContainer = function () {
598
- var container = this._document.createElement('div');
599
- container.classList.add('overlay-container');
600
- this._document.body.appendChild(container);
601
- this._containerElement = container;
602
- };
603
- return OverlayContainer;
604
- }());
605
- OverlayContainer.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function OverlayContainer_Factory() { return new OverlayContainer(i0__namespace.ɵɵinject(i1__namespace.DOCUMENT)); }, token: OverlayContainer, providedIn: "root" });
606
- OverlayContainer.decorators = [
607
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
608
- ];
609
- OverlayContainer.ctorParameters = function () { return [
610
- { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] }
611
- ]; };
612
-
613
- /**
614
- * Reference to an overlay that has been created with the Overlay service.
615
- * Used to manipulate or dispose of said overlay.
616
- */
617
- var OverlayRef = /** @class */ (function () {
618
- function OverlayRef(_portalHost) {
619
- this._portalHost = _portalHost;
620
- }
621
- OverlayRef.prototype.attach = function (portal, newestOnTop) {
622
- if (newestOnTop === void 0) { newestOnTop = true; }
623
- return this._portalHost.attach(portal, newestOnTop);
624
- };
625
- /**
626
- * Detaches an overlay from a portal.
627
- * @returns Resolves when the overlay has been detached.
628
- */
629
- OverlayRef.prototype.detach = function () {
630
- return this._portalHost.detach();
631
- };
632
- return OverlayRef;
633
- }());
634
-
635
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
636
- /**
637
- * Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be
638
- * used as a low-level building building block for other components. Dialogs, tooltips, menus,
639
- * selects, etc. can all be built using overlays. The service should primarily be used by authors
640
- * of re-usable components rather than developers building end-user applications.
641
- *
642
- * An overlay *is* a PortalHost, so any kind of Portal can be loaded into one.
643
- */
644
- var Overlay = /** @class */ (function () {
645
- function Overlay(_overlayContainer, _componentFactoryResolver, _appRef, _document) {
646
- this._overlayContainer = _overlayContainer;
647
- this._componentFactoryResolver = _componentFactoryResolver;
648
- this._appRef = _appRef;
649
- this._document = _document;
650
- // Namespace panes by overlay container
651
- this._paneElements = new Map();
652
- }
653
- /**
654
- * Creates an overlay.
655
- * @returns A reference to the created overlay.
656
- */
657
- Overlay.prototype.create = function (positionClass, overlayContainer) {
658
- // get existing pane if possible
659
- return this._createOverlayRef(this.getPaneElement(positionClass, overlayContainer));
660
- };
661
- Overlay.prototype.getPaneElement = function (positionClass, overlayContainer) {
662
- if (positionClass === void 0) { positionClass = ''; }
663
- if (!this._paneElements.get(overlayContainer)) {
664
- this._paneElements.set(overlayContainer, {});
665
- }
666
- if (!this._paneElements.get(overlayContainer)[positionClass]) {
667
- this._paneElements.get(overlayContainer)[positionClass] = this._createPaneElement(positionClass, overlayContainer);
668
- }
669
- return this._paneElements.get(overlayContainer)[positionClass];
670
- };
671
- /**
672
- * Creates the DOM element for an overlay and appends it to the overlay container.
673
- * @returns Newly-created pane element
674
- */
675
- Overlay.prototype._createPaneElement = function (positionClass, overlayContainer) {
676
- var pane = this._document.createElement('div');
677
- pane.id = 'toast-container';
678
- pane.classList.add(positionClass);
679
- pane.classList.add('toast-container');
680
- if (!overlayContainer) {
681
- this._overlayContainer.getContainerElement().appendChild(pane);
682
- }
683
- else {
684
- overlayContainer.getContainerElement().appendChild(pane);
685
- }
686
- return pane;
687
- };
688
- /**
689
- * Create a DomPortalHost into which the overlay content can be loaded.
690
- * @param pane The DOM element to turn into a portal host.
691
- * @returns A portal host for the given DOM element.
692
- */
693
- Overlay.prototype._createPortalHost = function (pane) {
694
- return new DomPortalHost(pane, this._componentFactoryResolver, this._appRef);
695
- };
696
- /**
697
- * Creates an OverlayRef for an overlay in the given DOM element.
698
- * @param pane DOM element for the overlay
699
- */
700
- Overlay.prototype._createOverlayRef = function (pane) {
701
- return new OverlayRef(this._createPortalHost(pane));
702
- };
703
- return Overlay;
704
- }());
705
- Overlay.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function Overlay_Factory() { return new Overlay(i0__namespace.ɵɵinject(OverlayContainer), i0__namespace.ɵɵinject(i0__namespace.ComponentFactoryResolver), i0__namespace.ɵɵinject(i0__namespace.ApplicationRef), i0__namespace.ɵɵinject(i1__namespace.DOCUMENT)); }, token: Overlay, providedIn: "root" });
706
- Overlay.decorators = [
707
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
708
- ];
709
- Overlay.ctorParameters = function () { return [
710
- { type: OverlayContainer },
711
- { type: i0.ComponentFactoryResolver },
712
- { type: i0.ApplicationRef },
713
- { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] }
714
- ]; };
715
-
716
- /**
717
- * Reference to a toast opened via the Toastr service.
718
- */
719
- var ToastRef = /** @class */ (function () {
720
- function ToastRef(_overlayRef) {
721
- this._overlayRef = _overlayRef;
722
- /** Count of duplicates of this toast */
723
- this.duplicatesCount = 0;
724
- /** Subject for notifying the user that the toast has finished closing. */
725
- this._afterClosed = new rxjs.Subject();
726
- /** triggered when toast is activated */
727
- this._activate = new rxjs.Subject();
728
- /** notifies the toast that it should close before the timeout */
729
- this._manualClose = new rxjs.Subject();
730
- /** notifies the toast that it should reset the timeouts */
731
- this._resetTimeout = new rxjs.Subject();
732
- /** notifies the toast that it should count a duplicate toast */
733
- this._countDuplicate = new rxjs.Subject();
734
- }
735
- ToastRef.prototype.manualClose = function () {
736
- this._manualClose.next();
737
- this._manualClose.complete();
738
- };
739
- ToastRef.prototype.manualClosed = function () {
740
- return this._manualClose.asObservable();
741
- };
742
- ToastRef.prototype.timeoutReset = function () {
743
- return this._resetTimeout.asObservable();
744
- };
745
- ToastRef.prototype.countDuplicate = function () {
746
- return this._countDuplicate.asObservable();
747
- };
748
- /**
749
- * Close the toast.
750
- */
751
- ToastRef.prototype.close = function () {
752
- this._overlayRef.detach();
753
- this._afterClosed.next();
754
- this._manualClose.next();
755
- this._afterClosed.complete();
756
- this._manualClose.complete();
757
- this._activate.complete();
758
- this._resetTimeout.complete();
759
- this._countDuplicate.complete();
760
- };
761
- /** Gets an observable that is notified when the toast is finished closing. */
762
- ToastRef.prototype.afterClosed = function () {
763
- return this._afterClosed.asObservable();
764
- };
765
- ToastRef.prototype.isInactive = function () {
766
- return this._activate.isStopped;
767
- };
768
- ToastRef.prototype.activate = function () {
769
- this._activate.next();
770
- this._activate.complete();
771
- };
772
- /** Gets an observable that is notified when the toast has started opening. */
773
- ToastRef.prototype.afterActivate = function () {
774
- return this._activate.asObservable();
775
- };
776
- /** Reset the toast timouts and count duplicates */
777
- ToastRef.prototype.onDuplicate = function (resetTimeout, countDuplicate) {
778
- if (resetTimeout) {
779
- this._resetTimeout.next();
780
- }
781
- if (countDuplicate) {
782
- this._countDuplicate.next(++this.duplicatesCount);
783
- }
784
- };
785
- return ToastRef;
786
- }());
787
- /** Custom injector type specifically for instantiating components with a toast. */
788
- var ToastInjector = /** @class */ (function () {
789
- function ToastInjector(_toastPackage, _parentInjector) {
790
- this._toastPackage = _toastPackage;
791
- this._parentInjector = _parentInjector;
792
- }
793
- ToastInjector.prototype.get = function (token, notFoundValue, flags) {
794
- if (token === ToastPackage) {
795
- return this._toastPackage;
796
- }
797
- return this._parentInjector.get(token, notFoundValue, flags);
798
- };
799
- return ToastInjector;
800
- }());
801
-
802
- var ToastrService = /** @class */ (function () {
803
- function ToastrService(token, overlay, _injector, sanitizer, ngZone) {
804
- this.overlay = overlay;
805
- this._injector = _injector;
806
- this.sanitizer = sanitizer;
807
- this.ngZone = ngZone;
808
- this.currentlyActive = 0;
809
- this.toasts = [];
810
- this.index = 0;
811
- this.toastrConfig = Object.assign(Object.assign({}, token.default), token.config);
812
- if (token.config.iconClasses) {
813
- this.toastrConfig.iconClasses = Object.assign(Object.assign({}, token.default.iconClasses), token.config.iconClasses);
814
- }
815
- }
816
- /** show toast */
817
- ToastrService.prototype.show = function (message, title, override, type) {
818
- if (override === void 0) { override = {}; }
819
- if (type === void 0) { type = ''; }
820
- return this._preBuildNotification(type, message, title, this.applyConfig(override));
821
- };
822
- /** show successful toast */
823
- ToastrService.prototype.success = function (message, title, override) {
824
- if (override === void 0) { override = {}; }
825
- var type = this.toastrConfig.iconClasses.success || '';
826
- return this._preBuildNotification(type, message, title, this.applyConfig(override));
827
- };
828
- /** show error toast */
829
- ToastrService.prototype.error = function (message, title, override) {
830
- if (override === void 0) { override = {}; }
831
- var type = this.toastrConfig.iconClasses.error || '';
832
- return this._preBuildNotification(type, message, title, this.applyConfig(override));
833
- };
834
- /** show info toast */
835
- ToastrService.prototype.info = function (message, title, override) {
836
- if (override === void 0) { override = {}; }
837
- var type = this.toastrConfig.iconClasses.info || '';
838
- return this._preBuildNotification(type, message, title, this.applyConfig(override));
839
- };
840
- /** show warning toast */
841
- ToastrService.prototype.warning = function (message, title, override) {
842
- if (override === void 0) { override = {}; }
843
- var type = this.toastrConfig.iconClasses.warning || '';
844
- return this._preBuildNotification(type, message, title, this.applyConfig(override));
845
- };
846
- /**
847
- * Remove all or a single toast by id
848
- */
849
- ToastrService.prototype.clear = function (toastId) {
850
- var e_1, _a;
851
- try {
852
- // Call every toastRef manualClose function
853
- for (var _b = __values(this.toasts), _c = _b.next(); !_c.done; _c = _b.next()) {
854
- var toast = _c.value;
855
- if (toastId !== undefined) {
856
- if (toast.toastId === toastId) {
857
- toast.toastRef.manualClose();
858
- return;
859
- }
860
- }
861
- else {
862
- toast.toastRef.manualClose();
863
- }
864
- }
865
- }
866
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
867
- finally {
868
- try {
869
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
870
- }
871
- finally { if (e_1) throw e_1.error; }
872
- }
873
- };
874
- /**
875
- * Remove and destroy a single toast by id
876
- */
877
- ToastrService.prototype.remove = function (toastId) {
878
- var found = this._findToast(toastId);
879
- if (!found) {
880
- return false;
881
- }
882
- found.activeToast.toastRef.close();
883
- this.toasts.splice(found.index, 1);
884
- this.currentlyActive = this.currentlyActive - 1;
885
- if (!this.toastrConfig.maxOpened || !this.toasts.length) {
886
- return false;
887
- }
888
- if (this.currentlyActive < this.toastrConfig.maxOpened && this.toasts[this.currentlyActive]) {
889
- var p = this.toasts[this.currentlyActive].toastRef;
890
- if (!p.isInactive()) {
891
- this.currentlyActive = this.currentlyActive + 1;
892
- p.activate();
893
- }
894
- }
895
- return true;
896
- };
897
- /**
898
- * Determines if toast message is already shown
899
- */
900
- ToastrService.prototype.findDuplicate = function (title, message, resetOnDuplicate, countDuplicates) {
901
- var e_2, _a;
902
- if (title === void 0) { title = ''; }
903
- if (message === void 0) { message = ''; }
904
- var includeTitleDuplicates = this.toastrConfig.includeTitleDuplicates;
905
- try {
906
- for (var _b = __values(this.toasts), _c = _b.next(); !_c.done; _c = _b.next()) {
907
- var toast = _c.value;
908
- var hasDuplicateTitle = includeTitleDuplicates && toast.title === title;
909
- if ((!includeTitleDuplicates || hasDuplicateTitle) && toast.message === message) {
910
- toast.toastRef.onDuplicate(resetOnDuplicate, countDuplicates);
911
- return toast;
912
- }
913
- }
914
- }
915
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
916
- finally {
917
- try {
918
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
919
- }
920
- finally { if (e_2) throw e_2.error; }
921
- }
922
- return null;
923
- };
924
- /** create a clone of global config and apply individual settings */
925
- ToastrService.prototype.applyConfig = function (override) {
926
- if (override === void 0) { override = {}; }
927
- return Object.assign(Object.assign({}, this.toastrConfig), override);
928
- };
929
- /**
930
- * Find toast object by id
931
- */
932
- ToastrService.prototype._findToast = function (toastId) {
933
- for (var i = 0; i < this.toasts.length; i++) {
934
- if (this.toasts[i].toastId === toastId) {
935
- return { index: i, activeToast: this.toasts[i] };
936
- }
937
- }
938
- return null;
939
- };
940
- /**
941
- * Determines the need to run inside angular's zone then builds the toast
942
- */
943
- ToastrService.prototype._preBuildNotification = function (toastType, message, title, config) {
944
- var _this = this;
945
- if (config.onActivateTick) {
946
- return this.ngZone.run(function () { return _this._buildNotification(toastType, message, title, config); });
947
- }
948
- return this._buildNotification(toastType, message, title, config);
949
- };
950
- /**
951
- * Creates and attaches toast data to component
952
- * returns the active toast, or in case preventDuplicates is enabled the original/non-duplicate active toast.
953
- */
954
- ToastrService.prototype._buildNotification = function (toastType, message, title, config) {
955
- if (!config.toastComponent) {
956
- throw new Error('toastComponent required');
957
- }
958
- // max opened and auto dismiss = true
959
- // if timeout = 0 resetting it would result in setting this.hideTime = Date.now(). Hence, we only want to reset timeout if there is
960
- // a timeout at all
961
- var duplicate = this.findDuplicate(title, message, this.toastrConfig.resetTimeoutOnDuplicate && config.timeOut > 0, this.toastrConfig.countDuplicates);
962
- if (((this.toastrConfig.includeTitleDuplicates && title) || message) &&
963
- this.toastrConfig.preventDuplicates &&
964
- duplicate !== null) {
965
- return duplicate;
966
- }
967
- this.previousToastMessage = message;
968
- var keepInactive = false;
969
- if (this.toastrConfig.maxOpened && this.currentlyActive >= this.toastrConfig.maxOpened) {
970
- keepInactive = true;
971
- if (this.toastrConfig.autoDismiss) {
972
- this.clear(this.toasts[0].toastId);
973
- }
974
- }
975
- var overlayRef = this.overlay.create(config.positionClass, this.overlayContainer);
976
- this.index = this.index + 1;
977
- var sanitizedMessage = message;
978
- if (message && config.enableHtml) {
979
- sanitizedMessage = this.sanitizer.sanitize(i0.SecurityContext.HTML, message);
980
- }
981
- var toastRef = new ToastRef(overlayRef);
982
- var toastPackage = new ToastPackage(this.index, config, sanitizedMessage, title, toastType, toastRef);
983
- var toastInjector = new ToastInjector(toastPackage, this._injector);
984
- var component = new ComponentPortal(config.toastComponent, toastInjector);
985
- var portal = overlayRef.attach(component, this.toastrConfig.newestOnTop);
986
- toastRef.componentInstance = portal.instance;
987
- var ins = {
988
- toastId: this.index,
989
- title: title || '',
990
- message: message || '',
991
- toastRef: toastRef,
992
- onShown: toastRef.afterActivate(),
993
- onHidden: toastRef.afterClosed(),
994
- onTap: toastPackage.onTap(),
995
- onAction: toastPackage.onAction(),
996
- portal: portal,
997
- };
998
- if (!keepInactive) {
999
- this.currentlyActive = this.currentlyActive + 1;
1000
- setTimeout(function () {
1001
- ins.toastRef.activate();
1002
- });
1003
- }
1004
- this.toasts.push(ins);
1005
- return ins;
1006
- };
1007
- return ToastrService;
1008
- }());
1009
- ToastrService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ToastrService_Factory() { return new ToastrService(i0__namespace.ɵɵinject(TOAST_CONFIG), i0__namespace.ɵɵinject(Overlay), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(i3__namespace.DomSanitizer), i0__namespace.ɵɵinject(i0__namespace.NgZone)); }, token: ToastrService, providedIn: "root" });
1010
- ToastrService.decorators = [
1011
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
1012
- ];
1013
- ToastrService.ctorParameters = function () { return [
1014
- { type: undefined, decorators: [{ type: i0.Inject, args: [TOAST_CONFIG,] }] },
1015
- { type: Overlay },
1016
- { type: i0.Injector },
1017
- { type: i3.DomSanitizer },
1018
- { type: i0.NgZone }
1019
- ]; };
1020
-
1021
- var Toast = /** @class */ (function () {
1022
- function Toast(toastrService, toastPackage, ngZone) {
1023
- var _this = this;
1024
- this.toastrService = toastrService;
1025
- this.toastPackage = toastPackage;
1026
- this.ngZone = ngZone;
1027
- /** width of progress bar */
1028
- this.width = -1;
1029
- /** a combination of toast type and options.toastClass */
1030
- this.toastClasses = '';
1031
- /** controls animation */
1032
- this.state = {
1033
- value: 'inactive',
1034
- params: {
1035
- easeTime: this.toastPackage.config.easeTime,
1036
- easing: 'ease-in'
1037
- }
1038
- };
1039
- this.message = toastPackage.message;
1040
- this.title = toastPackage.title;
1041
- this.options = toastPackage.config;
1042
- this.originalTimeout = toastPackage.config.timeOut;
1043
- this.toastClasses = toastPackage.toastType + " " + toastPackage.config.toastClass;
1044
- this.sub = toastPackage.toastRef.afterActivate().subscribe(function () {
1045
- _this.activateToast();
1046
- });
1047
- this.sub1 = toastPackage.toastRef.manualClosed().subscribe(function () {
1048
- _this.remove();
1049
- });
1050
- this.sub2 = toastPackage.toastRef.timeoutReset().subscribe(function () {
1051
- _this.resetTimeout();
1052
- });
1053
- this.sub3 = toastPackage.toastRef.countDuplicate().subscribe(function (count) {
1054
- _this.duplicatesCount = count;
1055
- });
1056
- }
1057
- Object.defineProperty(Toast.prototype, "displayStyle", {
1058
- /** hides component when waiting to be displayed */
1059
- get: function () {
1060
- if (this.state.value === 'inactive') {
1061
- return 'none';
1062
- }
1063
- return;
1064
- },
1065
- enumerable: false,
1066
- configurable: true
1067
- });
1068
- Toast.prototype.ngOnDestroy = function () {
1069
- this.sub.unsubscribe();
1070
- this.sub1.unsubscribe();
1071
- this.sub2.unsubscribe();
1072
- this.sub3.unsubscribe();
1073
- clearInterval(this.intervalId);
1074
- clearTimeout(this.timeout);
1075
- };
1076
- /**
1077
- * activates toast and sets timeout
1078
- */
1079
- Toast.prototype.activateToast = function () {
1080
- var _this = this;
1081
- this.state = Object.assign(Object.assign({}, this.state), { value: 'active' });
1082
- if (!(this.options.disableTimeOut === true || this.options.disableTimeOut === 'timeOut') && this.options.timeOut) {
1083
- this.outsideTimeout(function () { return _this.remove(); }, this.options.timeOut);
1084
- this.hideTime = new Date().getTime() + this.options.timeOut;
1085
- if (this.options.progressBar) {
1086
- this.outsideInterval(function () { return _this.updateProgress(); }, 10);
1087
- }
1088
- }
1089
- };
1090
- /**
1091
- * updates progress bar width
1092
- */
1093
- Toast.prototype.updateProgress = function () {
1094
- if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
1095
- return;
1096
- }
1097
- var now = new Date().getTime();
1098
- var remaining = this.hideTime - now;
1099
- this.width = (remaining / this.options.timeOut) * 100;
1100
- if (this.options.progressAnimation === 'increasing') {
1101
- this.width = 100 - this.width;
1102
- }
1103
- if (this.width <= 0) {
1104
- this.width = 0;
1105
- }
1106
- if (this.width >= 100) {
1107
- this.width = 100;
1108
- }
1109
- };
1110
- Toast.prototype.resetTimeout = function () {
1111
- var _this = this;
1112
- clearTimeout(this.timeout);
1113
- clearInterval(this.intervalId);
1114
- this.state = Object.assign(Object.assign({}, this.state), { value: 'active' });
1115
- this.outsideTimeout(function () { return _this.remove(); }, this.originalTimeout);
1116
- this.options.timeOut = this.originalTimeout;
1117
- this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
1118
- this.width = -1;
1119
- if (this.options.progressBar) {
1120
- this.outsideInterval(function () { return _this.updateProgress(); }, 10);
1121
- }
1122
- };
1123
- /**
1124
- * tells toastrService to remove this toast after animation time
1125
- */
1126
- Toast.prototype.remove = function () {
1127
- var _this = this;
1128
- if (this.state.value === 'removed') {
1129
- return;
1130
- }
1131
- clearTimeout(this.timeout);
1132
- this.state = Object.assign(Object.assign({}, this.state), { value: 'removed' });
1133
- this.outsideTimeout(function () { return _this.toastrService.remove(_this.toastPackage.toastId); }, +this.toastPackage.config.easeTime);
1134
- };
1135
- Toast.prototype.tapToast = function () {
1136
- if (this.state.value === 'removed') {
1137
- return;
1138
- }
1139
- this.toastPackage.triggerTap();
1140
- if (this.options.tapToDismiss) {
1141
- this.remove();
1142
- }
1143
- };
1144
- Toast.prototype.stickAround = function () {
1145
- if (this.state.value === 'removed') {
1146
- return;
1147
- }
1148
- clearTimeout(this.timeout);
1149
- this.options.timeOut = 0;
1150
- this.hideTime = 0;
1151
- // disable progressBar
1152
- clearInterval(this.intervalId);
1153
- this.width = 0;
1154
- };
1155
- Toast.prototype.delayedHideToast = function () {
1156
- var _this = this;
1157
- if ((this.options.disableTimeOut === true || this.options.disableTimeOut === 'extendedTimeOut') ||
1158
- this.options.extendedTimeOut === 0 ||
1159
- this.state.value === 'removed') {
1160
- return;
1161
- }
1162
- this.outsideTimeout(function () { return _this.remove(); }, this.options.extendedTimeOut);
1163
- this.options.timeOut = this.options.extendedTimeOut;
1164
- this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
1165
- this.width = -1;
1166
- if (this.options.progressBar) {
1167
- this.outsideInterval(function () { return _this.updateProgress(); }, 10);
1168
- }
1169
- };
1170
- Toast.prototype.outsideTimeout = function (func, timeout) {
1171
- var _this = this;
1172
- if (this.ngZone) {
1173
- this.ngZone.runOutsideAngular(function () { return (_this.timeout = setTimeout(function () { return _this.runInsideAngular(func); }, timeout)); });
1174
- }
1175
- else {
1176
- this.timeout = setTimeout(function () { return func(); }, timeout);
1177
- }
1178
- };
1179
- Toast.prototype.outsideInterval = function (func, timeout) {
1180
- var _this = this;
1181
- if (this.ngZone) {
1182
- this.ngZone.runOutsideAngular(function () { return (_this.intervalId = setInterval(function () { return _this.runInsideAngular(func); }, timeout)); });
1183
- }
1184
- else {
1185
- this.intervalId = setInterval(function () { return func(); }, timeout);
1186
- }
1187
- };
1188
- Toast.prototype.runInsideAngular = function (func) {
1189
- if (this.ngZone) {
1190
- this.ngZone.run(function () { return func(); });
1191
- }
1192
- else {
1193
- func();
1194
- }
1195
- };
1196
- return Toast;
1197
- }());
1198
- Toast.decorators = [
1199
- { type: i0.Component, args: [{
1200
- selector: '[toast-component]',
1201
- template: "\n <button *ngIf=\"options.closeButton\" (click)=\"remove()\" type=\"button\" class=\"toast-close-button\" aria-label=\"Close\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n <div *ngIf=\"title\" [class]=\"options.titleClass\" [attr.aria-label]=\"title\">\n {{ title }} <ng-container *ngIf=\"duplicatesCount\">[{{ duplicatesCount + 1 }}]</ng-container>\n </div>\n <div *ngIf=\"message && options.enableHtml\" role=\"alertdialog\" aria-live=\"polite\"\n [class]=\"options.messageClass\" [innerHTML]=\"message\">\n </div>\n <div *ngIf=\"message && !options.enableHtml\" role=\"alertdialog\" aria-live=\"polite\"\n [class]=\"options.messageClass\" [attr.aria-label]=\"message\">\n {{ message }}\n </div>\n <div *ngIf=\"options.progressBar\">\n <div class=\"toast-progress\" [style.width]=\"width + '%'\"></div>\n </div>\n ",
1202
- animations: [
1203
- animations.trigger('flyInOut', [
1204
- animations.state('inactive', animations.style({ opacity: 0 })),
1205
- animations.state('active', animations.style({ opacity: 1 })),
1206
- animations.state('removed', animations.style({ opacity: 0 })),
1207
- animations.transition('inactive => active', animations.animate('{{ easeTime }}ms {{ easing }}')),
1208
- animations.transition('active => removed', animations.animate('{{ easeTime }}ms {{ easing }}'))
1209
- ])
1210
- ],
1211
- preserveWhitespaces: false
1212
- },] }
1213
- ];
1214
- Toast.ctorParameters = function () { return [
1215
- { type: ToastrService },
1216
- { type: ToastPackage },
1217
- { type: i0.NgZone }
1218
- ]; };
1219
- Toast.propDecorators = {
1220
- toastClasses: [{ type: i0.HostBinding, args: ['class',] }],
1221
- state: [{ type: i0.HostBinding, args: ['@flyInOut',] }],
1222
- displayStyle: [{ type: i0.HostBinding, args: ['style.display',] }],
1223
- tapToast: [{ type: i0.HostListener, args: ['click',] }],
1224
- stickAround: [{ type: i0.HostListener, args: ['mouseenter',] }],
1225
- delayedHideToast: [{ type: i0.HostListener, args: ['mouseleave',] }]
1226
- };
1227
-
1228
- var DefaultGlobalConfig = Object.assign(Object.assign({}, DefaultNoComponentGlobalConfig), { toastComponent: Toast });
1229
- var ToastrModule = /** @class */ (function () {
1230
- function ToastrModule() {
1231
- }
1232
- ToastrModule.forRoot = function (config) {
1233
- if (config === void 0) { config = {}; }
1234
- return {
1235
- ngModule: ToastrModule,
1236
- providers: [
1237
- {
1238
- provide: TOAST_CONFIG,
1239
- useValue: {
1240
- default: DefaultGlobalConfig,
1241
- config: config,
1242
- },
1243
- },
1244
- ],
1245
- };
1246
- };
1247
- return ToastrModule;
1248
- }());
1249
- ToastrModule.decorators = [
1250
- { type: i0.NgModule, args: [{
1251
- imports: [i1.CommonModule],
1252
- declarations: [Toast],
1253
- exports: [Toast],
1254
- entryComponents: [Toast],
1255
- },] }
1256
- ];
1257
- var ToastrComponentlessModule = /** @class */ (function () {
1258
- function ToastrComponentlessModule() {
1259
- }
1260
- ToastrComponentlessModule.forRoot = function (config) {
1261
- if (config === void 0) { config = {}; }
1262
- return {
1263
- ngModule: ToastrModule,
1264
- providers: [
1265
- {
1266
- provide: TOAST_CONFIG,
1267
- useValue: {
1268
- default: DefaultNoComponentGlobalConfig,
1269
- config: config,
1270
- },
1271
- },
1272
- ],
1273
- };
1274
- };
1275
- return ToastrComponentlessModule;
1276
- }());
1277
- ToastrComponentlessModule.decorators = [
1278
- { type: i0.NgModule, args: [{
1279
- imports: [i1.CommonModule],
1280
- },] }
1281
- ];
1282
-
1283
- var ToastNoAnimation = /** @class */ (function () {
1284
- function ToastNoAnimation(toastrService, toastPackage, appRef) {
1285
- var _this = this;
1286
- this.toastrService = toastrService;
1287
- this.toastPackage = toastPackage;
1288
- this.appRef = appRef;
1289
- /** width of progress bar */
1290
- this.width = -1;
1291
- /** a combination of toast type and options.toastClass */
1292
- this.toastClasses = '';
1293
- /** controls animation */
1294
- this.state = 'inactive';
1295
- this.message = toastPackage.message;
1296
- this.title = toastPackage.title;
1297
- this.options = toastPackage.config;
1298
- this.originalTimeout = toastPackage.config.timeOut;
1299
- this.toastClasses = toastPackage.toastType + " " + toastPackage.config.toastClass;
1300
- this.sub = toastPackage.toastRef.afterActivate().subscribe(function () {
1301
- _this.activateToast();
1302
- });
1303
- this.sub1 = toastPackage.toastRef.manualClosed().subscribe(function () {
1304
- _this.remove();
1305
- });
1306
- this.sub2 = toastPackage.toastRef.timeoutReset().subscribe(function () {
1307
- _this.resetTimeout();
1308
- });
1309
- this.sub3 = toastPackage.toastRef.countDuplicate().subscribe(function (count) {
1310
- _this.duplicatesCount = count;
1311
- });
1312
- }
1313
- Object.defineProperty(ToastNoAnimation.prototype, "displayStyle", {
1314
- /** hides component when waiting to be displayed */
1315
- get: function () {
1316
- if (this.state === 'inactive') {
1317
- return 'none';
1318
- }
1319
- },
1320
- enumerable: false,
1321
- configurable: true
1322
- });
1323
- ToastNoAnimation.prototype.ngOnDestroy = function () {
1324
- this.sub.unsubscribe();
1325
- this.sub1.unsubscribe();
1326
- this.sub2.unsubscribe();
1327
- this.sub3.unsubscribe();
1328
- clearInterval(this.intervalId);
1329
- clearTimeout(this.timeout);
1330
- };
1331
- /**
1332
- * activates toast and sets timeout
1333
- */
1334
- ToastNoAnimation.prototype.activateToast = function () {
1335
- var _this = this;
1336
- this.state = 'active';
1337
- if (!(this.options.disableTimeOut === true || this.options.disableTimeOut === 'timeOut') && this.options.timeOut) {
1338
- this.timeout = setTimeout(function () {
1339
- _this.remove();
1340
- }, this.options.timeOut);
1341
- this.hideTime = new Date().getTime() + this.options.timeOut;
1342
- if (this.options.progressBar) {
1343
- this.intervalId = setInterval(function () { return _this.updateProgress(); }, 10);
1344
- }
1345
- }
1346
- if (this.options.onActivateTick) {
1347
- this.appRef.tick();
1348
- }
1349
- };
1350
- /**
1351
- * updates progress bar width
1352
- */
1353
- ToastNoAnimation.prototype.updateProgress = function () {
1354
- if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
1355
- return;
1356
- }
1357
- var now = new Date().getTime();
1358
- var remaining = this.hideTime - now;
1359
- this.width = (remaining / this.options.timeOut) * 100;
1360
- if (this.options.progressAnimation === 'increasing') {
1361
- this.width = 100 - this.width;
1362
- }
1363
- if (this.width <= 0) {
1364
- this.width = 0;
1365
- }
1366
- if (this.width >= 100) {
1367
- this.width = 100;
1368
- }
1369
- };
1370
- ToastNoAnimation.prototype.resetTimeout = function () {
1371
- var _this = this;
1372
- clearTimeout(this.timeout);
1373
- clearInterval(this.intervalId);
1374
- this.state = 'active';
1375
- this.options.timeOut = this.originalTimeout;
1376
- this.timeout = setTimeout(function () { return _this.remove(); }, this.originalTimeout);
1377
- this.hideTime = new Date().getTime() + (this.originalTimeout || 0);
1378
- this.width = -1;
1379
- if (this.options.progressBar) {
1380
- this.intervalId = setInterval(function () { return _this.updateProgress(); }, 10);
1381
- }
1382
- };
1383
- /**
1384
- * tells toastrService to remove this toast after animation time
1385
- */
1386
- ToastNoAnimation.prototype.remove = function () {
1387
- var _this = this;
1388
- if (this.state === 'removed') {
1389
- return;
1390
- }
1391
- clearTimeout(this.timeout);
1392
- this.state = 'removed';
1393
- this.timeout = setTimeout(function () { return _this.toastrService.remove(_this.toastPackage.toastId); });
1394
- };
1395
- ToastNoAnimation.prototype.tapToast = function () {
1396
- if (this.state === 'removed') {
1397
- return;
1398
- }
1399
- this.toastPackage.triggerTap();
1400
- if (this.options.tapToDismiss) {
1401
- this.remove();
1402
- }
1403
- };
1404
- ToastNoAnimation.prototype.stickAround = function () {
1405
- if (this.state === 'removed') {
1406
- return;
1407
- }
1408
- clearTimeout(this.timeout);
1409
- this.options.timeOut = 0;
1410
- this.hideTime = 0;
1411
- // disable progressBar
1412
- clearInterval(this.intervalId);
1413
- this.width = 0;
1414
- };
1415
- ToastNoAnimation.prototype.delayedHideToast = function () {
1416
- var _this = this;
1417
- if ((this.options.disableTimeOut === true || this.options.disableTimeOut === 'extendedTimeOut') ||
1418
- this.options.extendedTimeOut === 0 ||
1419
- this.state === 'removed') {
1420
- return;
1421
- }
1422
- this.timeout = setTimeout(function () { return _this.remove(); }, this.options.extendedTimeOut);
1423
- this.options.timeOut = this.options.extendedTimeOut;
1424
- this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
1425
- this.width = -1;
1426
- if (this.options.progressBar) {
1427
- this.intervalId = setInterval(function () { return _this.updateProgress(); }, 10);
1428
- }
1429
- };
1430
- return ToastNoAnimation;
1431
- }());
1432
- ToastNoAnimation.decorators = [
1433
- { type: i0.Component, args: [{
1434
- selector: '[toast-component]',
1435
- template: "\n <button *ngIf=\"options.closeButton\" (click)=\"remove()\" type=\"button\" class=\"toast-close-button\" aria-label=\"Close\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n <div *ngIf=\"title\" [class]=\"options.titleClass\" [attr.aria-label]=\"title\">\n {{ title }} <ng-container *ngIf=\"duplicatesCount\">[{{ duplicatesCount + 1 }}]</ng-container>\n </div>\n <div *ngIf=\"message && options.enableHtml\" role=\"alert\" aria-live=\"polite\"\n [class]=\"options.messageClass\" [innerHTML]=\"message\">\n </div>\n <div *ngIf=\"message && !options.enableHtml\" role=\"alert\" aria-live=\"polite\"\n [class]=\"options.messageClass\" [attr.aria-label]=\"message\">\n {{ message }}\n </div>\n <div *ngIf=\"options.progressBar\">\n <div class=\"toast-progress\" [style.width]=\"width + '%'\"></div>\n </div>\n "
1436
- },] }
1437
- ];
1438
- ToastNoAnimation.ctorParameters = function () { return [
1439
- { type: ToastrService },
1440
- { type: ToastPackage },
1441
- { type: i0.ApplicationRef }
1442
- ]; };
1443
- ToastNoAnimation.propDecorators = {
1444
- toastClasses: [{ type: i0.HostBinding, args: ['class',] }],
1445
- displayStyle: [{ type: i0.HostBinding, args: ['style.display',] }],
1446
- tapToast: [{ type: i0.HostListener, args: ['click',] }],
1447
- stickAround: [{ type: i0.HostListener, args: ['mouseenter',] }],
1448
- delayedHideToast: [{ type: i0.HostListener, args: ['mouseleave',] }]
1449
- };
1450
- var DefaultNoAnimationsGlobalConfig = Object.assign(Object.assign({}, DefaultNoComponentGlobalConfig), { toastComponent: ToastNoAnimation });
1451
- var ToastNoAnimationModule = /** @class */ (function () {
1452
- function ToastNoAnimationModule() {
1453
- }
1454
- ToastNoAnimationModule.forRoot = function (config) {
1455
- if (config === void 0) { config = {}; }
1456
- return {
1457
- ngModule: ToastNoAnimationModule,
1458
- providers: [
1459
- {
1460
- provide: TOAST_CONFIG,
1461
- useValue: {
1462
- default: DefaultNoAnimationsGlobalConfig,
1463
- config: config,
1464
- },
1465
- },
1466
- ],
1467
- };
1468
- };
1469
- return ToastNoAnimationModule;
1470
- }());
1471
- ToastNoAnimationModule.decorators = [
1472
- { type: i0.NgModule, args: [{
1473
- imports: [i1.CommonModule],
1474
- declarations: [ToastNoAnimation],
1475
- exports: [ToastNoAnimation],
1476
- entryComponents: [ToastNoAnimation],
1477
- },] }
1478
- ];
1479
-
1480
- /**
1481
- * Generated bundle index. Do not edit.
1482
- */
1483
-
1484
- exports.BasePortalHost = BasePortalHost;
1485
- exports.ComponentPortal = ComponentPortal;
1486
- exports.DefaultGlobalConfig = DefaultGlobalConfig;
1487
- exports.DefaultNoAnimationsGlobalConfig = DefaultNoAnimationsGlobalConfig;
1488
- exports.DefaultNoComponentGlobalConfig = DefaultNoComponentGlobalConfig;
1489
- exports.Overlay = Overlay;
1490
- exports.OverlayContainer = OverlayContainer;
1491
- exports.OverlayRef = OverlayRef;
1492
- exports.TOAST_CONFIG = TOAST_CONFIG;
1493
- exports.Toast = Toast;
1494
- exports.ToastContainerDirective = ToastContainerDirective;
1495
- exports.ToastContainerModule = ToastContainerModule;
1496
- exports.ToastInjector = ToastInjector;
1497
- exports.ToastNoAnimation = ToastNoAnimation;
1498
- exports.ToastNoAnimationModule = ToastNoAnimationModule;
1499
- exports.ToastPackage = ToastPackage;
1500
- exports.ToastRef = ToastRef;
1501
- exports.ToastrComponentlessModule = ToastrComponentlessModule;
1502
- exports.ToastrModule = ToastrModule;
1503
- exports.ToastrService = ToastrService;
1504
-
1505
- Object.defineProperty(exports, '__esModule', { value: true });
1506
-
1507
- })));
1508
- //# sourceMappingURL=ngx-toastr.umd.js.map