ngx-toastr.umd.js 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  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 = global || self, factory(global['ngx-toastr'] = {}, global.ng.core, global.ng.animations, global.rxjs, global.ng.platformBrowser, global.ng.common));
  5. }(this, function (exports, core, animations, rxjs, platformBrowser, common) { 'use strict';
  6. /*! *****************************************************************************
  7. Copyright (c) Microsoft Corporation. All rights reserved.
  8. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  9. this file except in compliance with the License. You may obtain a copy of the
  10. License at http://www.apache.org/licenses/LICENSE-2.0
  11. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  12. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  13. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  14. MERCHANTABLITY OR NON-INFRINGEMENT.
  15. See the Apache Version 2.0 License for specific language governing permissions
  16. and limitations under the License.
  17. ***************************************************************************** */
  18. /* global Reflect, Promise */
  19. var extendStatics = function(d, b) {
  20. extendStatics = Object.setPrototypeOf ||
  21. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  22. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23. return extendStatics(d, b);
  24. };
  25. function __extends(d, b) {
  26. extendStatics(d, b);
  27. function __() { this.constructor = d; }
  28. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  29. }
  30. var __assign = function() {
  31. __assign = Object.assign || function __assign(t) {
  32. for (var s, i = 1, n = arguments.length; i < n; i++) {
  33. s = arguments[i];
  34. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  35. }
  36. return t;
  37. };
  38. return __assign.apply(this, arguments);
  39. };
  40. function __decorate(decorators, target, key, desc) {
  41. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  42. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  43. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  44. return c > 3 && r && Object.defineProperty(target, key, r), r;
  45. }
  46. function __param(paramIndex, decorator) {
  47. return function (target, key) { decorator(target, key, paramIndex); }
  48. }
  49. function __metadata(metadataKey, metadataValue) {
  50. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  51. }
  52. function __values(o) {
  53. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  54. if (m) return m.call(o);
  55. return {
  56. next: function () {
  57. if (o && i >= o.length) o = void 0;
  58. return { value: o && o[i++], done: !o };
  59. }
  60. };
  61. }
  62. var ToastContainerDirective = /** @class */ (function () {
  63. function ToastContainerDirective(el) {
  64. this.el = el;
  65. }
  66. ToastContainerDirective.prototype.getContainerElement = function () {
  67. return this.el.nativeElement;
  68. };
  69. ToastContainerDirective = __decorate([
  70. core.Directive({
  71. selector: '[toastContainer]',
  72. exportAs: 'toastContainer',
  73. }),
  74. __metadata("design:paramtypes", [core.ElementRef])
  75. ], ToastContainerDirective);
  76. return ToastContainerDirective;
  77. }());
  78. var ToastContainerModule = /** @class */ (function () {
  79. function ToastContainerModule() {
  80. }
  81. ToastContainerModule = __decorate([
  82. core.NgModule({
  83. declarations: [ToastContainerDirective],
  84. exports: [ToastContainerDirective],
  85. })
  86. ], ToastContainerModule);
  87. return ToastContainerModule;
  88. }());
  89. /**
  90. * Everything a toast needs to launch
  91. */
  92. var ToastPackage = /** @class */ (function () {
  93. function ToastPackage(toastId, config, message, title, toastType, toastRef) {
  94. var _this = this;
  95. this.toastId = toastId;
  96. this.config = config;
  97. this.message = message;
  98. this.title = title;
  99. this.toastType = toastType;
  100. this.toastRef = toastRef;
  101. this._onTap = new rxjs.Subject();
  102. this._onAction = new rxjs.Subject();
  103. this.toastRef.afterClosed().subscribe(function () {
  104. _this._onAction.complete();
  105. _this._onTap.complete();
  106. });
  107. }
  108. /** Fired on click */
  109. ToastPackage.prototype.triggerTap = function () {
  110. this._onTap.next();
  111. if (this.config.tapToDismiss) {
  112. this._onTap.complete();
  113. }
  114. };
  115. ToastPackage.prototype.onTap = function () {
  116. return this._onTap.asObservable();
  117. };
  118. /** available for use in custom toast */
  119. ToastPackage.prototype.triggerAction = function (action) {
  120. this._onAction.next(action);
  121. };
  122. ToastPackage.prototype.onAction = function () {
  123. return this._onAction.asObservable();
  124. };
  125. return ToastPackage;
  126. }());
  127. var DefaultNoComponentGlobalConfig = {
  128. maxOpened: 0,
  129. autoDismiss: false,
  130. newestOnTop: true,
  131. preventDuplicates: false,
  132. countDuplicates: false,
  133. resetTimeoutOnDuplicate: false,
  134. iconClasses: {
  135. error: 'toast-error',
  136. info: 'toast-info',
  137. success: 'toast-success',
  138. warning: 'toast-warning',
  139. },
  140. // Individual
  141. closeButton: false,
  142. disableTimeOut: false,
  143. timeOut: 5000,
  144. extendedTimeOut: 1000,
  145. enableHtml: false,
  146. progressBar: false,
  147. toastClass: 'ngx-toastr',
  148. positionClass: 'toast-top-right',
  149. titleClass: 'toast-title',
  150. messageClass: 'toast-message',
  151. easing: 'ease-in',
  152. easeTime: 300,
  153. tapToDismiss: true,
  154. onActivateTick: false,
  155. progressAnimation: 'decreasing',
  156. };
  157. var TOAST_CONFIG = new core.InjectionToken('ToastConfig');
  158. /**
  159. * A `ComponentPortal` is a portal that instantiates some Component upon attachment.
  160. */
  161. var ComponentPortal = /** @class */ (function () {
  162. function ComponentPortal(component, injector) {
  163. this.component = component;
  164. this.injector = injector;
  165. }
  166. /** Attach this portal to a host. */
  167. ComponentPortal.prototype.attach = function (host, newestOnTop) {
  168. this._attachedHost = host;
  169. return host.attach(this, newestOnTop);
  170. };
  171. /** Detach this portal from its host */
  172. ComponentPortal.prototype.detach = function () {
  173. var host = this._attachedHost;
  174. if (host) {
  175. this._attachedHost = undefined;
  176. return host.detach();
  177. }
  178. };
  179. Object.defineProperty(ComponentPortal.prototype, "isAttached", {
  180. /** Whether this portal is attached to a host. */
  181. get: function () {
  182. return this._attachedHost != null;
  183. },
  184. enumerable: true,
  185. configurable: true
  186. });
  187. /**
  188. * Sets the PortalHost reference without performing `attach()`. This is used directly by
  189. * the PortalHost when it is performing an `attach()` or `detach()`.
  190. */
  191. ComponentPortal.prototype.setAttachedHost = function (host) {
  192. this._attachedHost = host;
  193. };
  194. return ComponentPortal;
  195. }());
  196. /**
  197. * Partial implementation of PortalHost that only deals with attaching a
  198. * ComponentPortal
  199. */
  200. var BasePortalHost = /** @class */ (function () {
  201. function BasePortalHost() {
  202. }
  203. BasePortalHost.prototype.attach = function (portal, newestOnTop) {
  204. this._attachedPortal = portal;
  205. return this.attachComponentPortal(portal, newestOnTop);
  206. };
  207. BasePortalHost.prototype.detach = function () {
  208. if (this._attachedPortal) {
  209. this._attachedPortal.setAttachedHost();
  210. }
  211. this._attachedPortal = undefined;
  212. if (this._disposeFn) {
  213. this._disposeFn();
  214. this._disposeFn = undefined;
  215. }
  216. };
  217. BasePortalHost.prototype.setDisposeFn = function (fn) {
  218. this._disposeFn = fn;
  219. };
  220. return BasePortalHost;
  221. }());
  222. /**
  223. * A PortalHost for attaching portals to an arbitrary DOM element outside of the Angular
  224. * application context.
  225. *
  226. * This is the only part of the portal core that directly touches the DOM.
  227. */
  228. var DomPortalHost = /** @class */ (function (_super) {
  229. __extends(DomPortalHost, _super);
  230. function DomPortalHost(_hostDomElement, _componentFactoryResolver, _appRef) {
  231. var _this = _super.call(this) || this;
  232. _this._hostDomElement = _hostDomElement;
  233. _this._componentFactoryResolver = _componentFactoryResolver;
  234. _this._appRef = _appRef;
  235. return _this;
  236. }
  237. /**
  238. * Attach the given ComponentPortal to DOM element using the ComponentFactoryResolver.
  239. * @param portal Portal to be attached
  240. */
  241. DomPortalHost.prototype.attachComponentPortal = function (portal, newestOnTop) {
  242. var _this = this;
  243. var componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
  244. var componentRef;
  245. // If the portal specifies a ViewContainerRef, we will use that as the attachment point
  246. // for the component (in terms of Angular's component tree, not rendering).
  247. // When the ViewContainerRef is missing, we use the factory to create the component directly
  248. // and then manually attach the ChangeDetector for that component to the application (which
  249. // happens automatically when using a ViewContainer).
  250. componentRef = componentFactory.create(portal.injector);
  251. // When creating a component outside of a ViewContainer, we need to manually register
  252. // its ChangeDetector with the application. This API is unfortunately not yet published
  253. // in Angular core. The change detector must also be deregistered when the component
  254. // is destroyed to prevent memory leaks.
  255. this._appRef.attachView(componentRef.hostView);
  256. this.setDisposeFn(function () {
  257. _this._appRef.detachView(componentRef.hostView);
  258. componentRef.destroy();
  259. });
  260. // At this point the component has been instantiated, so we move it to the location in the DOM
  261. // where we want it to be rendered.
  262. if (newestOnTop) {
  263. this._hostDomElement.insertBefore(this._getComponentRootNode(componentRef), this._hostDomElement.firstChild);
  264. }
  265. else {
  266. this._hostDomElement.appendChild(this._getComponentRootNode(componentRef));
  267. }
  268. return componentRef;
  269. };
  270. /** Gets the root HTMLElement for an instantiated component. */
  271. DomPortalHost.prototype._getComponentRootNode = function (componentRef) {
  272. return componentRef.hostView.rootNodes[0];
  273. };
  274. return DomPortalHost;
  275. }(BasePortalHost));
  276. /** Container inside which all toasts will render. */
  277. var OverlayContainer = /** @class */ (function () {
  278. function OverlayContainer(_document) {
  279. this._document = _document;
  280. }
  281. OverlayContainer.prototype.ngOnDestroy = function () {
  282. if (this._containerElement && this._containerElement.parentNode) {
  283. this._containerElement.parentNode.removeChild(this._containerElement);
  284. }
  285. };
  286. /**
  287. * This method returns the overlay container element. It will lazily
  288. * create the element the first time it is called to facilitate using
  289. * the container in non-browser environments.
  290. * @returns the container element
  291. */
  292. OverlayContainer.prototype.getContainerElement = function () {
  293. if (!this._containerElement) {
  294. this._createContainer();
  295. }
  296. return this._containerElement;
  297. };
  298. /**
  299. * Create the overlay container element, which is simply a div
  300. * with the 'cdk-overlay-container' class on the document body.
  301. */
  302. OverlayContainer.prototype._createContainer = function () {
  303. var container = this._document.createElement('div');
  304. container.classList.add('overlay-container');
  305. this._document.body.appendChild(container);
  306. this._containerElement = container;
  307. };
  308. OverlayContainer.ngInjectableDef = core.defineInjectable({ factory: function OverlayContainer_Factory() { return new OverlayContainer(core.inject(common.DOCUMENT)); }, token: OverlayContainer, providedIn: "root" });
  309. OverlayContainer = __decorate([
  310. core.Injectable({ providedIn: 'root' }),
  311. __param(0, core.Inject(common.DOCUMENT)),
  312. __metadata("design:paramtypes", [Object])
  313. ], OverlayContainer);
  314. return OverlayContainer;
  315. }());
  316. /**
  317. * Reference to an overlay that has been created with the Overlay service.
  318. * Used to manipulate or dispose of said overlay.
  319. */
  320. var OverlayRef = /** @class */ (function () {
  321. function OverlayRef(_portalHost) {
  322. this._portalHost = _portalHost;
  323. }
  324. OverlayRef.prototype.attach = function (portal, newestOnTop) {
  325. if (newestOnTop === void 0) { newestOnTop = true; }
  326. return this._portalHost.attach(portal, newestOnTop);
  327. };
  328. /**
  329. * Detaches an overlay from a portal.
  330. * @returns Resolves when the overlay has been detached.
  331. */
  332. OverlayRef.prototype.detach = function () {
  333. return this._portalHost.detach();
  334. };
  335. return OverlayRef;
  336. }());
  337. /**
  338. * Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be
  339. * used as a low-level building building block for other components. Dialogs, tooltips, menus,
  340. * selects, etc. can all be built using overlays. The service should primarily be used by authors
  341. * of re-usable components rather than developers building end-user applications.
  342. *
  343. * An overlay *is* a PortalHost, so any kind of Portal can be loaded into one.
  344. */
  345. var Overlay = /** @class */ (function () {
  346. function Overlay(_overlayContainer, _componentFactoryResolver, _appRef, _document) {
  347. this._overlayContainer = _overlayContainer;
  348. this._componentFactoryResolver = _componentFactoryResolver;
  349. this._appRef = _appRef;
  350. this._document = _document;
  351. // Namespace panes by overlay container
  352. this._paneElements = new Map();
  353. }
  354. /**
  355. * Creates an overlay.
  356. * @returns A reference to the created overlay.
  357. */
  358. Overlay.prototype.create = function (positionClass, overlayContainer) {
  359. // get existing pane if possible
  360. return this._createOverlayRef(this.getPaneElement(positionClass, overlayContainer));
  361. };
  362. Overlay.prototype.getPaneElement = function (positionClass, overlayContainer) {
  363. if (positionClass === void 0) { positionClass = ''; }
  364. if (!this._paneElements.get(overlayContainer)) {
  365. this._paneElements.set(overlayContainer, {});
  366. }
  367. if (!this._paneElements.get(overlayContainer)[positionClass]) {
  368. this._paneElements.get(overlayContainer)[positionClass] = this._createPaneElement(positionClass, overlayContainer);
  369. }
  370. return this._paneElements.get(overlayContainer)[positionClass];
  371. };
  372. /**
  373. * Creates the DOM element for an overlay and appends it to the overlay container.
  374. * @returns Newly-created pane element
  375. */
  376. Overlay.prototype._createPaneElement = function (positionClass, overlayContainer) {
  377. var pane = this._document.createElement('div');
  378. pane.id = 'toast-container';
  379. pane.classList.add(positionClass);
  380. pane.classList.add('toast-container');
  381. if (!overlayContainer) {
  382. this._overlayContainer.getContainerElement().appendChild(pane);
  383. }
  384. else {
  385. overlayContainer.getContainerElement().appendChild(pane);
  386. }
  387. return pane;
  388. };
  389. /**
  390. * Create a DomPortalHost into which the overlay content can be loaded.
  391. * @param pane The DOM element to turn into a portal host.
  392. * @returns A portal host for the given DOM element.
  393. */
  394. Overlay.prototype._createPortalHost = function (pane) {
  395. return new DomPortalHost(pane, this._componentFactoryResolver, this._appRef);
  396. };
  397. /**
  398. * Creates an OverlayRef for an overlay in the given DOM element.
  399. * @param pane DOM element for the overlay
  400. */
  401. Overlay.prototype._createOverlayRef = function (pane) {
  402. return new OverlayRef(this._createPortalHost(pane));
  403. };
  404. Overlay.ngInjectableDef = core.defineInjectable({ factory: function Overlay_Factory() { return new Overlay(core.inject(OverlayContainer), core.inject(core.ComponentFactoryResolver), core.inject(core.ApplicationRef), core.inject(common.DOCUMENT)); }, token: Overlay, providedIn: "root" });
  405. Overlay = __decorate([
  406. core.Injectable({ providedIn: 'root' }),
  407. __param(3, core.Inject(common.DOCUMENT)),
  408. __metadata("design:paramtypes", [OverlayContainer,
  409. core.ComponentFactoryResolver,
  410. core.ApplicationRef, Object])
  411. ], Overlay);
  412. return Overlay;
  413. }());
  414. /**
  415. * Reference to a toast opened via the Toastr service.
  416. */
  417. var ToastRef = /** @class */ (function () {
  418. function ToastRef(_overlayRef) {
  419. this._overlayRef = _overlayRef;
  420. /** Count of duplicates of this toast */
  421. this.duplicatesCount = 0;
  422. /** Subject for notifying the user that the toast has finished closing. */
  423. this._afterClosed = new rxjs.Subject();
  424. /** triggered when toast is activated */
  425. this._activate = new rxjs.Subject();
  426. /** notifies the toast that it should close before the timeout */
  427. this._manualClose = new rxjs.Subject();
  428. /** notifies the toast that it should reset the timeouts */
  429. this._resetTimeout = new rxjs.Subject();
  430. /** notifies the toast that it should count a duplicate toast */
  431. this._countDuplicate = new rxjs.Subject();
  432. }
  433. ToastRef.prototype.manualClose = function () {
  434. this._manualClose.next();
  435. this._manualClose.complete();
  436. };
  437. ToastRef.prototype.manualClosed = function () {
  438. return this._manualClose.asObservable();
  439. };
  440. ToastRef.prototype.timeoutReset = function () {
  441. return this._resetTimeout.asObservable();
  442. };
  443. ToastRef.prototype.countDuplicate = function () {
  444. return this._countDuplicate.asObservable();
  445. };
  446. /**
  447. * Close the toast.
  448. */
  449. ToastRef.prototype.close = function () {
  450. this._overlayRef.detach();
  451. this._afterClosed.next();
  452. this._manualClose.next();
  453. this._afterClosed.complete();
  454. this._manualClose.complete();
  455. this._activate.complete();
  456. this._resetTimeout.complete();
  457. this._countDuplicate.complete();
  458. };
  459. /** Gets an observable that is notified when the toast is finished closing. */
  460. ToastRef.prototype.afterClosed = function () {
  461. return this._afterClosed.asObservable();
  462. };
  463. ToastRef.prototype.isInactive = function () {
  464. return this._activate.isStopped;
  465. };
  466. ToastRef.prototype.activate = function () {
  467. this._activate.next();
  468. this._activate.complete();
  469. };
  470. /** Gets an observable that is notified when the toast has started opening. */
  471. ToastRef.prototype.afterActivate = function () {
  472. return this._activate.asObservable();
  473. };
  474. /** Reset the toast timouts and count duplicates */
  475. ToastRef.prototype.onDuplicate = function (resetTimeout, countDuplicate) {
  476. if (resetTimeout) {
  477. this._resetTimeout.next();
  478. }
  479. if (countDuplicate) {
  480. this._countDuplicate.next(++this.duplicatesCount);
  481. }
  482. };
  483. return ToastRef;
  484. }());
  485. /** Custom injector type specifically for instantiating components with a toast. */
  486. var ToastInjector = /** @class */ (function () {
  487. function ToastInjector(_toastPackage, _parentInjector) {
  488. this._toastPackage = _toastPackage;
  489. this._parentInjector = _parentInjector;
  490. }
  491. ToastInjector.prototype.get = function (token, notFoundValue, flags) {
  492. if (token === ToastPackage) {
  493. return this._toastPackage;
  494. }
  495. return this._parentInjector.get(token, notFoundValue, flags);
  496. };
  497. return ToastInjector;
  498. }());
  499. var ToastrService = /** @class */ (function () {
  500. function ToastrService(token, overlay, _injector, sanitizer, ngZone) {
  501. this.overlay = overlay;
  502. this._injector = _injector;
  503. this.sanitizer = sanitizer;
  504. this.ngZone = ngZone;
  505. this.currentlyActive = 0;
  506. this.toasts = [];
  507. this.index = 0;
  508. this.toastrConfig = __assign({}, token.default, token.config);
  509. if (token.config.iconClasses) {
  510. this.toastrConfig.iconClasses = __assign({}, token.default.iconClasses, token.config.iconClasses);
  511. }
  512. }
  513. /** show toast */
  514. ToastrService.prototype.show = function (message, title, override, type) {
  515. if (override === void 0) { override = {}; }
  516. if (type === void 0) { type = ''; }
  517. return this._preBuildNotification(type, message, title, this.applyConfig(override));
  518. };
  519. /** show successful toast */
  520. ToastrService.prototype.success = function (message, title, override) {
  521. if (override === void 0) { override = {}; }
  522. var type = this.toastrConfig.iconClasses.success || '';
  523. return this._preBuildNotification(type, message, title, this.applyConfig(override));
  524. };
  525. /** show error toast */
  526. ToastrService.prototype.error = function (message, title, override) {
  527. if (override === void 0) { override = {}; }
  528. var type = this.toastrConfig.iconClasses.error || '';
  529. return this._preBuildNotification(type, message, title, this.applyConfig(override));
  530. };
  531. /** show info toast */
  532. ToastrService.prototype.info = function (message, title, override) {
  533. if (override === void 0) { override = {}; }
  534. var type = this.toastrConfig.iconClasses.info || '';
  535. return this._preBuildNotification(type, message, title, this.applyConfig(override));
  536. };
  537. /** show warning toast */
  538. ToastrService.prototype.warning = function (message, title, override) {
  539. if (override === void 0) { override = {}; }
  540. var type = this.toastrConfig.iconClasses.warning || '';
  541. return this._preBuildNotification(type, message, title, this.applyConfig(override));
  542. };
  543. /**
  544. * Remove all or a single toast by id
  545. */
  546. ToastrService.prototype.clear = function (toastId) {
  547. var e_1, _a;
  548. try {
  549. // Call every toastRef manualClose function
  550. for (var _b = __values(this.toasts), _c = _b.next(); !_c.done; _c = _b.next()) {
  551. var toast = _c.value;
  552. if (toastId !== undefined) {
  553. if (toast.toastId === toastId) {
  554. toast.toastRef.manualClose();
  555. return;
  556. }
  557. }
  558. else {
  559. toast.toastRef.manualClose();
  560. }
  561. }
  562. }
  563. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  564. finally {
  565. try {
  566. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  567. }
  568. finally { if (e_1) throw e_1.error; }
  569. }
  570. };
  571. /**
  572. * Remove and destroy a single toast by id
  573. */
  574. ToastrService.prototype.remove = function (toastId) {
  575. var found = this._findToast(toastId);
  576. if (!found) {
  577. return false;
  578. }
  579. found.activeToast.toastRef.close();
  580. this.toasts.splice(found.index, 1);
  581. this.currentlyActive = this.currentlyActive - 1;
  582. if (!this.toastrConfig.maxOpened || !this.toasts.length) {
  583. return false;
  584. }
  585. if (this.currentlyActive < this.toastrConfig.maxOpened &&
  586. this.toasts[this.currentlyActive]) {
  587. var p = this.toasts[this.currentlyActive].toastRef;
  588. if (!p.isInactive()) {
  589. this.currentlyActive = this.currentlyActive + 1;
  590. p.activate();
  591. }
  592. }
  593. return true;
  594. };
  595. /**
  596. * Determines if toast message is already shown
  597. */
  598. ToastrService.prototype.findDuplicate = function (message, resetOnDuplicate, countDuplicates) {
  599. for (var i = 0; i < this.toasts.length; i++) {
  600. var toast = this.toasts[i];
  601. if (toast.message === message) {
  602. toast.toastRef.onDuplicate(resetOnDuplicate, countDuplicates);
  603. return toast;
  604. }
  605. }
  606. return null;
  607. };
  608. /** create a clone of global config and apply individual settings */
  609. ToastrService.prototype.applyConfig = function (override) {
  610. if (override === void 0) { override = {}; }
  611. return __assign({}, this.toastrConfig, override);
  612. };
  613. /**
  614. * Find toast object by id
  615. */
  616. ToastrService.prototype._findToast = function (toastId) {
  617. for (var i = 0; i < this.toasts.length; i++) {
  618. if (this.toasts[i].toastId === toastId) {
  619. return { index: i, activeToast: this.toasts[i] };
  620. }
  621. }
  622. return null;
  623. };
  624. /**
  625. * Determines the need to run inside angular's zone then builds the toast
  626. */
  627. ToastrService.prototype._preBuildNotification = function (toastType, message, title, config) {
  628. var _this = this;
  629. if (config.onActivateTick) {
  630. return this.ngZone.run(function () {
  631. return _this._buildNotification(toastType, message, title, config);
  632. });
  633. }
  634. return this._buildNotification(toastType, message, title, config);
  635. };
  636. /**
  637. * Creates and attaches toast data to component
  638. * returns the active toast, or in case preventDuplicates is enabled the original/non-duplicate active toast.
  639. */
  640. ToastrService.prototype._buildNotification = function (toastType, message, title, config) {
  641. var _this = this;
  642. if (!config.toastComponent) {
  643. throw new Error('toastComponent required');
  644. }
  645. // max opened and auto dismiss = true
  646. // if timeout = 0 resetting it would result in setting this.hideTime = Date.now(). Hence, we only want to reset timeout if there is
  647. // a timeout at all
  648. var duplicate = this.findDuplicate(message, this.toastrConfig.resetTimeoutOnDuplicate && config.timeOut > 0, this.toastrConfig.countDuplicates);
  649. if (message && this.toastrConfig.preventDuplicates && duplicate !== null) {
  650. return duplicate;
  651. }
  652. this.previousToastMessage = message;
  653. var keepInactive = false;
  654. if (this.toastrConfig.maxOpened &&
  655. this.currentlyActive >= this.toastrConfig.maxOpened) {
  656. keepInactive = true;
  657. if (this.toastrConfig.autoDismiss) {
  658. this.clear(this.toasts[0].toastId);
  659. }
  660. }
  661. var overlayRef = this.overlay.create(config.positionClass, this.overlayContainer);
  662. this.index = this.index + 1;
  663. var sanitizedMessage = message;
  664. if (message && config.enableHtml) {
  665. sanitizedMessage = this.sanitizer.sanitize(core.SecurityContext.HTML, message);
  666. }
  667. var toastRef = new ToastRef(overlayRef);
  668. var toastPackage = new ToastPackage(this.index, config, sanitizedMessage, title, toastType, toastRef);
  669. var toastInjector = new ToastInjector(toastPackage, this._injector);
  670. var component = new ComponentPortal(config.toastComponent, toastInjector);
  671. var portal = overlayRef.attach(component, this.toastrConfig.newestOnTop);
  672. toastRef.componentInstance = portal._component;
  673. var ins = {
  674. toastId: this.index,
  675. message: message || '',
  676. toastRef: toastRef,
  677. onShown: toastRef.afterActivate(),
  678. onHidden: toastRef.afterClosed(),
  679. onTap: toastPackage.onTap(),
  680. onAction: toastPackage.onAction(),
  681. portal: portal
  682. };
  683. if (!keepInactive) {
  684. setTimeout(function () {
  685. ins.toastRef.activate();
  686. _this.currentlyActive = _this.currentlyActive + 1;
  687. });
  688. }
  689. this.toasts.push(ins);
  690. return ins;
  691. };
  692. ToastrService.ngInjectableDef = core.defineInjectable({ factory: function ToastrService_Factory() { return new ToastrService(core.inject(TOAST_CONFIG), core.inject(Overlay), core.inject(core.INJECTOR), core.inject(platformBrowser.DomSanitizer), core.inject(core.NgZone)); }, token: ToastrService, providedIn: "root" });
  693. ToastrService = __decorate([
  694. core.Injectable({ providedIn: 'root' }),
  695. __param(0, core.Inject(TOAST_CONFIG)),
  696. __metadata("design:paramtypes", [Object, Overlay,
  697. core.Injector,
  698. platformBrowser.DomSanitizer,
  699. core.NgZone])
  700. ], ToastrService);
  701. return ToastrService;
  702. }());
  703. var Toast = /** @class */ (function () {
  704. function Toast(toastrService, toastPackage, ngZone) {
  705. var _this = this;
  706. this.toastrService = toastrService;
  707. this.toastPackage = toastPackage;
  708. this.ngZone = ngZone;
  709. /** width of progress bar */
  710. this.width = -1;
  711. /** a combination of toast type and options.toastClass */
  712. this.toastClasses = '';
  713. /** controls animation */
  714. this.state = {
  715. value: 'inactive',
  716. params: {
  717. easeTime: this.toastPackage.config.easeTime,
  718. easing: 'ease-in'
  719. }
  720. };
  721. this.message = toastPackage.message;
  722. this.title = toastPackage.title;
  723. this.options = toastPackage.config;
  724. this.originalTimeout = toastPackage.config.timeOut;
  725. this.toastClasses = toastPackage.toastType + " " + toastPackage.config.toastClass;
  726. this.sub = toastPackage.toastRef.afterActivate().subscribe(function () {
  727. _this.activateToast();
  728. });
  729. this.sub1 = toastPackage.toastRef.manualClosed().subscribe(function () {
  730. _this.remove();
  731. });
  732. this.sub2 = toastPackage.toastRef.timeoutReset().subscribe(function () {
  733. _this.resetTimeout();
  734. });
  735. this.sub3 = toastPackage.toastRef.countDuplicate().subscribe(function (count) {
  736. _this.duplicatesCount = count;
  737. });
  738. }
  739. Object.defineProperty(Toast.prototype, "displayStyle", {
  740. /** hides component when waiting to be displayed */
  741. get: function () {
  742. if (this.state.value === 'inactive') {
  743. return 'none';
  744. }
  745. },
  746. enumerable: true,
  747. configurable: true
  748. });
  749. Toast.prototype.ngOnDestroy = function () {
  750. this.sub.unsubscribe();
  751. this.sub1.unsubscribe();
  752. this.sub2.unsubscribe();
  753. this.sub3.unsubscribe();
  754. clearInterval(this.intervalId);
  755. clearTimeout(this.timeout);
  756. };
  757. /**
  758. * activates toast and sets timeout
  759. */
  760. Toast.prototype.activateToast = function () {
  761. var _this = this;
  762. this.state = __assign({}, this.state, { value: 'active' });
  763. if (!this.options.disableTimeOut && this.options.timeOut) {
  764. this.outsideTimeout(function () { return _this.remove(); }, this.options.timeOut);
  765. this.hideTime = new Date().getTime() + this.options.timeOut;
  766. if (this.options.progressBar) {
  767. this.outsideInterval(function () { return _this.updateProgress(); }, 10);
  768. }
  769. }
  770. };
  771. /**
  772. * updates progress bar width
  773. */
  774. Toast.prototype.updateProgress = function () {
  775. if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
  776. return;
  777. }
  778. var now = new Date().getTime();
  779. var remaining = this.hideTime - now;
  780. this.width = (remaining / this.options.timeOut) * 100;
  781. if (this.options.progressAnimation === 'increasing') {
  782. this.width = 100 - this.width;
  783. }
  784. if (this.width <= 0) {
  785. this.width = 0;
  786. }
  787. if (this.width >= 100) {
  788. this.width = 100;
  789. }
  790. };
  791. Toast.prototype.resetTimeout = function () {
  792. var _this = this;
  793. clearTimeout(this.timeout);
  794. clearInterval(this.intervalId);
  795. this.state = __assign({}, this.state, { value: 'active' });
  796. this.outsideTimeout(function () { return _this.remove(); }, this.originalTimeout);
  797. this.options.timeOut = this.originalTimeout;
  798. this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
  799. this.width = -1;
  800. if (this.options.progressBar) {
  801. this.outsideInterval(function () { return _this.updateProgress(); }, 10);
  802. }
  803. };
  804. /**
  805. * tells toastrService to remove this toast after animation time
  806. */
  807. Toast.prototype.remove = function () {
  808. var _this = this;
  809. if (this.state.value === 'removed') {
  810. return;
  811. }
  812. clearTimeout(this.timeout);
  813. this.state = __assign({}, this.state, { value: 'removed' });
  814. this.outsideTimeout(function () { return _this.toastrService.remove(_this.toastPackage.toastId); }, +this.toastPackage.config.easeTime);
  815. };
  816. Toast.prototype.tapToast = function () {
  817. if (this.state.value === 'removed') {
  818. return;
  819. }
  820. this.toastPackage.triggerTap();
  821. if (this.options.tapToDismiss) {
  822. this.remove();
  823. }
  824. };
  825. Toast.prototype.stickAround = function () {
  826. if (this.state.value === 'removed') {
  827. return;
  828. }
  829. clearTimeout(this.timeout);
  830. this.options.timeOut = 0;
  831. this.hideTime = 0;
  832. // disable progressBar
  833. clearInterval(this.intervalId);
  834. this.width = 0;
  835. };
  836. Toast.prototype.delayedHideToast = function () {
  837. var _this = this;
  838. if (this.options.disableTimeOut ||
  839. this.options.extendedTimeOut === 0 ||
  840. this.state.value === 'removed') {
  841. return;
  842. }
  843. this.outsideTimeout(function () { return _this.remove(); }, this.options.extendedTimeOut);
  844. this.options.timeOut = this.options.extendedTimeOut;
  845. this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
  846. this.width = -1;
  847. if (this.options.progressBar) {
  848. this.outsideInterval(function () { return _this.updateProgress(); }, 10);
  849. }
  850. };
  851. Toast.prototype.outsideTimeout = function (func, timeout) {
  852. var _this = this;
  853. if (this.ngZone) {
  854. this.ngZone.runOutsideAngular(function () {
  855. return (_this.timeout = setTimeout(function () { return _this.runInsideAngular(func); }, timeout));
  856. });
  857. }
  858. else {
  859. this.timeout = setTimeout(function () { return func(); }, timeout);
  860. }
  861. };
  862. Toast.prototype.outsideInterval = function (func, timeout) {
  863. var _this = this;
  864. if (this.ngZone) {
  865. this.ngZone.runOutsideAngular(function () {
  866. return (_this.intervalId = setInterval(function () { return _this.runInsideAngular(func); }, timeout));
  867. });
  868. }
  869. else {
  870. this.intervalId = setInterval(function () { return func(); }, timeout);
  871. }
  872. };
  873. Toast.prototype.runInsideAngular = function (func) {
  874. if (this.ngZone) {
  875. this.ngZone.run(function () { return func(); });
  876. }
  877. else {
  878. func();
  879. }
  880. };
  881. __decorate([
  882. core.HostBinding('class'),
  883. __metadata("design:type", Object)
  884. ], Toast.prototype, "toastClasses", void 0);
  885. __decorate([
  886. core.HostBinding('@flyInOut'),
  887. __metadata("design:type", Object)
  888. ], Toast.prototype, "state", void 0);
  889. __decorate([
  890. core.HostBinding('style.display'),
  891. __metadata("design:type", Object),
  892. __metadata("design:paramtypes", [])
  893. ], Toast.prototype, "displayStyle", null);
  894. __decorate([
  895. core.HostListener('click'),
  896. __metadata("design:type", Function),
  897. __metadata("design:paramtypes", []),
  898. __metadata("design:returntype", void 0)
  899. ], Toast.prototype, "tapToast", null);
  900. __decorate([
  901. core.HostListener('mouseenter'),
  902. __metadata("design:type", Function),
  903. __metadata("design:paramtypes", []),
  904. __metadata("design:returntype", void 0)
  905. ], Toast.prototype, "stickAround", null);
  906. __decorate([
  907. core.HostListener('mouseleave'),
  908. __metadata("design:type", Function),
  909. __metadata("design:paramtypes", []),
  910. __metadata("design:returntype", void 0)
  911. ], Toast.prototype, "delayedHideToast", null);
  912. Toast = __decorate([
  913. core.Component({
  914. selector: '[toast-component]',
  915. template: "\n <button *ngIf=\"options.closeButton\" (click)=\"remove()\" 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 ",
  916. animations: [
  917. animations.trigger('flyInOut', [
  918. animations.state('inactive', animations.style({ opacity: 0 })),
  919. animations.state('active', animations.style({ opacity: 1 })),
  920. animations.state('removed', animations.style({ opacity: 0 })),
  921. animations.transition('inactive => active', animations.animate('{{ easeTime }}ms {{ easing }}')),
  922. animations.transition('active => removed', animations.animate('{{ easeTime }}ms {{ easing }}'))
  923. ])
  924. ],
  925. preserveWhitespaces: false
  926. }),
  927. __metadata("design:paramtypes", [ToastrService,
  928. ToastPackage,
  929. core.NgZone])
  930. ], Toast);
  931. return Toast;
  932. }());
  933. var DefaultGlobalConfig = __assign({}, DefaultNoComponentGlobalConfig, { toastComponent: Toast });
  934. var ToastrModule = /** @class */ (function () {
  935. function ToastrModule() {
  936. }
  937. ToastrModule_1 = ToastrModule;
  938. ToastrModule.forRoot = function (config) {
  939. if (config === void 0) { config = {}; }
  940. return {
  941. ngModule: ToastrModule_1,
  942. providers: [
  943. {
  944. provide: TOAST_CONFIG,
  945. useValue: {
  946. default: DefaultGlobalConfig,
  947. config: config,
  948. },
  949. },
  950. ],
  951. };
  952. };
  953. var ToastrModule_1;
  954. ToastrModule = ToastrModule_1 = __decorate([
  955. core.NgModule({
  956. imports: [common.CommonModule],
  957. declarations: [Toast],
  958. exports: [Toast],
  959. entryComponents: [Toast],
  960. })
  961. ], ToastrModule);
  962. return ToastrModule;
  963. }());
  964. var ToastrComponentlessModule = /** @class */ (function () {
  965. function ToastrComponentlessModule() {
  966. }
  967. ToastrComponentlessModule.forRoot = function (config) {
  968. if (config === void 0) { config = {}; }
  969. return {
  970. ngModule: ToastrModule,
  971. providers: [
  972. {
  973. provide: TOAST_CONFIG,
  974. useValue: {
  975. default: DefaultNoComponentGlobalConfig,
  976. config: config,
  977. },
  978. },
  979. ],
  980. };
  981. };
  982. ToastrComponentlessModule = __decorate([
  983. core.NgModule({
  984. imports: [common.CommonModule],
  985. })
  986. ], ToastrComponentlessModule);
  987. return ToastrComponentlessModule;
  988. }());
  989. var ToastNoAnimation = /** @class */ (function () {
  990. function ToastNoAnimation(toastrService, toastPackage, appRef) {
  991. var _this = this;
  992. this.toastrService = toastrService;
  993. this.toastPackage = toastPackage;
  994. this.appRef = appRef;
  995. /** width of progress bar */
  996. this.width = -1;
  997. /** a combination of toast type and options.toastClass */
  998. this.toastClasses = '';
  999. /** controls animation */
  1000. this.state = 'inactive';
  1001. this.message = toastPackage.message;
  1002. this.title = toastPackage.title;
  1003. this.options = toastPackage.config;
  1004. this.originalTimeout = toastPackage.config.timeOut;
  1005. this.toastClasses = toastPackage.toastType + " " + toastPackage.config.toastClass;
  1006. this.sub = toastPackage.toastRef.afterActivate().subscribe(function () {
  1007. _this.activateToast();
  1008. });
  1009. this.sub1 = toastPackage.toastRef.manualClosed().subscribe(function () {
  1010. _this.remove();
  1011. });
  1012. this.sub2 = toastPackage.toastRef.timeoutReset().subscribe(function () {
  1013. _this.resetTimeout();
  1014. });
  1015. this.sub3 = toastPackage.toastRef.countDuplicate().subscribe(function (count) {
  1016. _this.duplicatesCount = count;
  1017. });
  1018. }
  1019. Object.defineProperty(ToastNoAnimation.prototype, "displayStyle", {
  1020. /** hides component when waiting to be displayed */
  1021. get: function () {
  1022. if (this.state === 'inactive') {
  1023. return 'none';
  1024. }
  1025. },
  1026. enumerable: true,
  1027. configurable: true
  1028. });
  1029. ToastNoAnimation.prototype.ngOnDestroy = function () {
  1030. this.sub.unsubscribe();
  1031. this.sub1.unsubscribe();
  1032. this.sub2.unsubscribe();
  1033. this.sub3.unsubscribe();
  1034. clearInterval(this.intervalId);
  1035. clearTimeout(this.timeout);
  1036. };
  1037. /**
  1038. * activates toast and sets timeout
  1039. */
  1040. ToastNoAnimation.prototype.activateToast = function () {
  1041. var _this = this;
  1042. this.state = 'active';
  1043. if (!this.options.disableTimeOut && this.options.timeOut) {
  1044. this.timeout = setTimeout(function () {
  1045. _this.remove();
  1046. }, this.options.timeOut);
  1047. this.hideTime = new Date().getTime() + this.options.timeOut;
  1048. if (this.options.progressBar) {
  1049. this.intervalId = setInterval(function () { return _this.updateProgress(); }, 10);
  1050. }
  1051. }
  1052. if (this.options.onActivateTick) {
  1053. this.appRef.tick();
  1054. }
  1055. };
  1056. /**
  1057. * updates progress bar width
  1058. */
  1059. ToastNoAnimation.prototype.updateProgress = function () {
  1060. if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
  1061. return;
  1062. }
  1063. var now = new Date().getTime();
  1064. var remaining = this.hideTime - now;
  1065. this.width = (remaining / this.options.timeOut) * 100;
  1066. if (this.options.progressAnimation === 'increasing') {
  1067. this.width = 100 - this.width;
  1068. }
  1069. if (this.width <= 0) {
  1070. this.width = 0;
  1071. }
  1072. if (this.width >= 100) {
  1073. this.width = 100;
  1074. }
  1075. };
  1076. ToastNoAnimation.prototype.resetTimeout = function () {
  1077. var _this = this;
  1078. clearTimeout(this.timeout);
  1079. clearInterval(this.intervalId);
  1080. this.state = 'active';
  1081. this.options.timeOut = this.originalTimeout;
  1082. this.timeout = setTimeout(function () { return _this.remove(); }, this.originalTimeout);
  1083. this.hideTime = new Date().getTime() + (this.originalTimeout || 0);
  1084. this.width = -1;
  1085. if (this.options.progressBar) {
  1086. this.intervalId = setInterval(function () { return _this.updateProgress(); }, 10);
  1087. }
  1088. };
  1089. /**
  1090. * tells toastrService to remove this toast after animation time
  1091. */
  1092. ToastNoAnimation.prototype.remove = function () {
  1093. var _this = this;
  1094. if (this.state === 'removed') {
  1095. return;
  1096. }
  1097. clearTimeout(this.timeout);
  1098. this.state = 'removed';
  1099. this.timeout = setTimeout(function () {
  1100. return _this.toastrService.remove(_this.toastPackage.toastId);
  1101. });
  1102. };
  1103. ToastNoAnimation.prototype.tapToast = function () {
  1104. if (this.state === 'removed') {
  1105. return;
  1106. }
  1107. this.toastPackage.triggerTap();
  1108. if (this.options.tapToDismiss) {
  1109. this.remove();
  1110. }
  1111. };
  1112. ToastNoAnimation.prototype.stickAround = function () {
  1113. if (this.state === 'removed') {
  1114. return;
  1115. }
  1116. clearTimeout(this.timeout);
  1117. this.options.timeOut = 0;
  1118. this.hideTime = 0;
  1119. // disable progressBar
  1120. clearInterval(this.intervalId);
  1121. this.width = 0;
  1122. };
  1123. ToastNoAnimation.prototype.delayedHideToast = function () {
  1124. var _this = this;
  1125. if (this.options.disableTimeOut ||
  1126. this.options.extendedTimeOut === 0 ||
  1127. this.state === 'removed') {
  1128. return;
  1129. }
  1130. this.timeout = setTimeout(function () { return _this.remove(); }, this.options.extendedTimeOut);
  1131. this.options.timeOut = this.options.extendedTimeOut;
  1132. this.hideTime = new Date().getTime() + (this.options.timeOut || 0);
  1133. this.width = -1;
  1134. if (this.options.progressBar) {
  1135. this.intervalId = setInterval(function () { return _this.updateProgress(); }, 10);
  1136. }
  1137. };
  1138. __decorate([
  1139. core.HostBinding('class'),
  1140. __metadata("design:type", Object)
  1141. ], ToastNoAnimation.prototype, "toastClasses", void 0);
  1142. __decorate([
  1143. core.HostBinding('style.display'),
  1144. __metadata("design:type", Object),
  1145. __metadata("design:paramtypes", [])
  1146. ], ToastNoAnimation.prototype, "displayStyle", null);
  1147. __decorate([
  1148. core.HostListener('click'),
  1149. __metadata("design:type", Function),
  1150. __metadata("design:paramtypes", []),
  1151. __metadata("design:returntype", void 0)
  1152. ], ToastNoAnimation.prototype, "tapToast", null);
  1153. __decorate([
  1154. core.HostListener('mouseenter'),
  1155. __metadata("design:type", Function),
  1156. __metadata("design:paramtypes", []),
  1157. __metadata("design:returntype", void 0)
  1158. ], ToastNoAnimation.prototype, "stickAround", null);
  1159. __decorate([
  1160. core.HostListener('mouseleave'),
  1161. __metadata("design:type", Function),
  1162. __metadata("design:paramtypes", []),
  1163. __metadata("design:returntype", void 0)
  1164. ], ToastNoAnimation.prototype, "delayedHideToast", null);
  1165. ToastNoAnimation = __decorate([
  1166. core.Component({
  1167. selector: '[toast-component]',
  1168. template: "\n <button *ngIf=\"options.closeButton\" (click)=\"remove()\" 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 "
  1169. }),
  1170. __metadata("design:paramtypes", [ToastrService,
  1171. ToastPackage,
  1172. core.ApplicationRef])
  1173. ], ToastNoAnimation);
  1174. return ToastNoAnimation;
  1175. }());
  1176. var DefaultNoAnimationsGlobalConfig = __assign({}, DefaultNoComponentGlobalConfig, { toastComponent: ToastNoAnimation });
  1177. var ToastNoAnimationModule = /** @class */ (function () {
  1178. function ToastNoAnimationModule() {
  1179. }
  1180. ToastNoAnimationModule_1 = ToastNoAnimationModule;
  1181. ToastNoAnimationModule.forRoot = function (config) {
  1182. if (config === void 0) { config = {}; }
  1183. return {
  1184. ngModule: ToastNoAnimationModule_1,
  1185. providers: [
  1186. {
  1187. provide: TOAST_CONFIG,
  1188. useValue: {
  1189. default: DefaultNoAnimationsGlobalConfig,
  1190. config: config,
  1191. },
  1192. },
  1193. ],
  1194. };
  1195. };
  1196. var ToastNoAnimationModule_1;
  1197. ToastNoAnimationModule = ToastNoAnimationModule_1 = __decorate([
  1198. core.NgModule({
  1199. imports: [common.CommonModule],
  1200. declarations: [ToastNoAnimation],
  1201. exports: [ToastNoAnimation],
  1202. entryComponents: [ToastNoAnimation],
  1203. })
  1204. ], ToastNoAnimationModule);
  1205. return ToastNoAnimationModule;
  1206. }());
  1207. exports.BasePortalHost = BasePortalHost;
  1208. exports.ComponentPortal = ComponentPortal;
  1209. exports.DefaultGlobalConfig = DefaultGlobalConfig;
  1210. exports.DefaultNoAnimationsGlobalConfig = DefaultNoAnimationsGlobalConfig;
  1211. exports.DefaultNoComponentGlobalConfig = DefaultNoComponentGlobalConfig;
  1212. exports.Overlay = Overlay;
  1213. exports.OverlayContainer = OverlayContainer;
  1214. exports.OverlayRef = OverlayRef;
  1215. exports.TOAST_CONFIG = TOAST_CONFIG;
  1216. exports.Toast = Toast;
  1217. exports.ToastContainerDirective = ToastContainerDirective;
  1218. exports.ToastContainerModule = ToastContainerModule;
  1219. exports.ToastInjector = ToastInjector;
  1220. exports.ToastNoAnimation = ToastNoAnimation;
  1221. exports.ToastNoAnimationModule = ToastNoAnimationModule;
  1222. exports.ToastPackage = ToastPackage;
  1223. exports.ToastRef = ToastRef;
  1224. exports.ToastrComponentlessModule = ToastrComponentlessModule;
  1225. exports.ToastrModule = ToastrModule;
  1226. exports.ToastrService = ToastrService;
  1227. Object.defineProperty(exports, '__esModule', { value: true });
  1228. }));
  1229. //# sourceMappingURL=ngx-toastr.umd.js.map