ng-zorro-antd-notification.mjs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. import { NgTemplateOutlet } from '@angular/common';
  2. import * as i0 from '@angular/core';
  3. import { EventEmitter, Output, Input, ViewEncapsulation, Component, ChangeDetectionStrategy, NgModule, Injectable } from '@angular/core';
  4. import { notificationMotion } from 'ng-zorro-antd/core/animation';
  5. import * as i2 from 'ng-zorro-antd/core/outlet';
  6. import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
  7. import * as i1 from 'ng-zorro-antd/icon';
  8. import { NzIconModule } from 'ng-zorro-antd/icon';
  9. import { NzMNComponent, NzMNContainerComponent, NzMNService } from 'ng-zorro-antd/message';
  10. import { Subject } from 'rxjs';
  11. import { takeUntil } from 'rxjs/operators';
  12. import { toCssPixel } from 'ng-zorro-antd/core/util';
  13. import * as i1$1 from '@angular/cdk/overlay';
  14. /**
  15. * Use of this source code is governed by an MIT-style license that can be
  16. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  17. */
  18. class NzNotificationComponent extends NzMNComponent {
  19. instance;
  20. index;
  21. placement;
  22. destroyed = new EventEmitter();
  23. ngOnDestroy() {
  24. super.ngOnDestroy();
  25. this.instance.onClick.complete();
  26. }
  27. onClick(event) {
  28. this.instance.onClick.next(event);
  29. }
  30. close() {
  31. this.destroy(true);
  32. }
  33. get state() {
  34. if (this.instance.state === 'enter') {
  35. switch (this.placement) {
  36. case 'topLeft':
  37. case 'bottomLeft':
  38. return 'enterLeft';
  39. case 'topRight':
  40. case 'bottomRight':
  41. return 'enterRight';
  42. case 'top':
  43. return 'enterTop';
  44. case 'bottom':
  45. return 'enterBottom';
  46. default:
  47. return 'enterRight';
  48. }
  49. }
  50. else {
  51. return this.instance.state;
  52. }
  53. }
  54. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
  55. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzNotificationComponent, isStandalone: true, selector: "nz-notification", inputs: { instance: "instance", index: "index", placement: "placement" }, outputs: { destroyed: "destroyed" }, exportAs: ["nzNotification"], usesInheritance: true, ngImport: i0, template: `
  56. <div
  57. class="ant-notification-notice ant-notification-notice-closable"
  58. [style]="instance.options?.nzStyle || null"
  59. [class]="instance.options?.nzClass || ''"
  60. [@notificationMotion]="state"
  61. (@notificationMotion.done)="animationStateChanged.next($event)"
  62. (click)="onClick($event)"
  63. (mouseenter)="onEnter()"
  64. (mouseleave)="onLeave()"
  65. >
  66. @if (instance.template) {
  67. <ng-template
  68. [ngTemplateOutlet]="instance.template!"
  69. [ngTemplateOutletContext]="{ $implicit: this, data: instance.options?.nzData }"
  70. />
  71. } @else {
  72. <div class="ant-notification-notice-content">
  73. <div class="ant-notification-notice-content">
  74. <div [class.ant-notification-notice-with-icon]="instance.type !== 'blank'">
  75. @switch (instance.type) {
  76. @case ('success') {
  77. <nz-icon
  78. nzType="check-circle"
  79. class="ant-notification-notice-icon ant-notification-notice-icon-success"
  80. />
  81. }
  82. @case ('info') {
  83. <nz-icon
  84. nzType="info-circle"
  85. class="ant-notification-notice-icon ant-notification-notice-icon-info"
  86. />
  87. }
  88. @case ('warning') {
  89. <nz-icon
  90. nzType="exclamation-circle"
  91. class="ant-notification-notice-icon ant-notification-notice-icon-warning"
  92. />
  93. }
  94. @case ('error') {
  95. <nz-icon
  96. nzType="close-circle"
  97. class="ant-notification-notice-icon ant-notification-notice-icon-error"
  98. />
  99. }
  100. }
  101. <div class="ant-notification-notice-message">
  102. <ng-container *nzStringTemplateOutlet="instance.title">
  103. <div [innerHTML]="instance.title"></div>
  104. </ng-container>
  105. </div>
  106. <div class="ant-notification-notice-description">
  107. <ng-container
  108. *nzStringTemplateOutlet="
  109. instance.content;
  110. context: { $implicit: this, data: instance.options?.nzData }
  111. "
  112. >
  113. <div [innerHTML]="instance.content"></div>
  114. </ng-container>
  115. </div>
  116. @if (instance.options?.nzButton; as btn) {
  117. <span class="ant-notification-notice-btn">
  118. <ng-template [ngTemplateOutlet]="btn" [ngTemplateOutletContext]="{ $implicit: this }" />
  119. </span>
  120. }
  121. </div>
  122. </div>
  123. </div>
  124. }
  125. <a tabindex="0" class="ant-notification-notice-close" (click)="close()">
  126. <span class="ant-notification-notice-close-x">
  127. @if (instance.options?.nzCloseIcon) {
  128. <ng-container *nzStringTemplateOutlet="instance.options?.nzCloseIcon; let closeIcon">
  129. <nz-icon [nzType]="closeIcon" />
  130. </ng-container>
  131. } @else {
  132. <nz-icon nzType="close" class="ant-notification-close-icon" />
  133. }
  134. </span>
  135. </a>
  136. </div>
  137. `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i2.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], animations: [notificationMotion], encapsulation: i0.ViewEncapsulation.None });
  138. }
  139. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationComponent, decorators: [{
  140. type: Component,
  141. args: [{
  142. encapsulation: ViewEncapsulation.None,
  143. selector: 'nz-notification',
  144. exportAs: 'nzNotification',
  145. preserveWhitespaces: false,
  146. animations: [notificationMotion],
  147. template: `
  148. <div
  149. class="ant-notification-notice ant-notification-notice-closable"
  150. [style]="instance.options?.nzStyle || null"
  151. [class]="instance.options?.nzClass || ''"
  152. [@notificationMotion]="state"
  153. (@notificationMotion.done)="animationStateChanged.next($event)"
  154. (click)="onClick($event)"
  155. (mouseenter)="onEnter()"
  156. (mouseleave)="onLeave()"
  157. >
  158. @if (instance.template) {
  159. <ng-template
  160. [ngTemplateOutlet]="instance.template!"
  161. [ngTemplateOutletContext]="{ $implicit: this, data: instance.options?.nzData }"
  162. />
  163. } @else {
  164. <div class="ant-notification-notice-content">
  165. <div class="ant-notification-notice-content">
  166. <div [class.ant-notification-notice-with-icon]="instance.type !== 'blank'">
  167. @switch (instance.type) {
  168. @case ('success') {
  169. <nz-icon
  170. nzType="check-circle"
  171. class="ant-notification-notice-icon ant-notification-notice-icon-success"
  172. />
  173. }
  174. @case ('info') {
  175. <nz-icon
  176. nzType="info-circle"
  177. class="ant-notification-notice-icon ant-notification-notice-icon-info"
  178. />
  179. }
  180. @case ('warning') {
  181. <nz-icon
  182. nzType="exclamation-circle"
  183. class="ant-notification-notice-icon ant-notification-notice-icon-warning"
  184. />
  185. }
  186. @case ('error') {
  187. <nz-icon
  188. nzType="close-circle"
  189. class="ant-notification-notice-icon ant-notification-notice-icon-error"
  190. />
  191. }
  192. }
  193. <div class="ant-notification-notice-message">
  194. <ng-container *nzStringTemplateOutlet="instance.title">
  195. <div [innerHTML]="instance.title"></div>
  196. </ng-container>
  197. </div>
  198. <div class="ant-notification-notice-description">
  199. <ng-container
  200. *nzStringTemplateOutlet="
  201. instance.content;
  202. context: { $implicit: this, data: instance.options?.nzData }
  203. "
  204. >
  205. <div [innerHTML]="instance.content"></div>
  206. </ng-container>
  207. </div>
  208. @if (instance.options?.nzButton; as btn) {
  209. <span class="ant-notification-notice-btn">
  210. <ng-template [ngTemplateOutlet]="btn" [ngTemplateOutletContext]="{ $implicit: this }" />
  211. </span>
  212. }
  213. </div>
  214. </div>
  215. </div>
  216. }
  217. <a tabindex="0" class="ant-notification-notice-close" (click)="close()">
  218. <span class="ant-notification-notice-close-x">
  219. @if (instance.options?.nzCloseIcon) {
  220. <ng-container *nzStringTemplateOutlet="instance.options?.nzCloseIcon; let closeIcon">
  221. <nz-icon [nzType]="closeIcon" />
  222. </ng-container>
  223. } @else {
  224. <nz-icon nzType="close" class="ant-notification-close-icon" />
  225. }
  226. </span>
  227. </a>
  228. </div>
  229. `,
  230. imports: [NzIconModule, NzOutletModule, NgTemplateOutlet]
  231. }]
  232. }], propDecorators: { instance: [{
  233. type: Input
  234. }], index: [{
  235. type: Input
  236. }], placement: [{
  237. type: Input
  238. }], destroyed: [{
  239. type: Output
  240. }] } });
  241. const NZ_CONFIG_MODULE_NAME = 'notification';
  242. const NZ_NOTIFICATION_DEFAULT_CONFIG = {
  243. nzTop: '24px',
  244. nzBottom: '24px',
  245. nzPlacement: 'topRight',
  246. nzDuration: 4500,
  247. nzMaxStack: 8,
  248. nzPauseOnHover: true,
  249. nzAnimate: true,
  250. nzDirection: 'ltr'
  251. };
  252. class NzNotificationContainerComponent extends NzMNContainerComponent {
  253. dir = this.nzConfigService.getConfigForComponent(NZ_CONFIG_MODULE_NAME)?.nzDirection || 'ltr';
  254. bottom;
  255. top;
  256. topLeftInstances = [];
  257. topRightInstances = [];
  258. bottomLeftInstances = [];
  259. bottomRightInstances = [];
  260. topInstances = [];
  261. bottomInstances = [];
  262. constructor() {
  263. super();
  264. this.updateConfig();
  265. }
  266. create(notification) {
  267. const instance = this.onCreate(notification);
  268. const key = instance.options.nzKey;
  269. const notificationWithSameKey = this.instances.find(msg => msg.options.nzKey === notification.options.nzKey);
  270. if (key && notificationWithSameKey) {
  271. this.replaceNotification(notificationWithSameKey, instance);
  272. }
  273. else {
  274. if (this.instances.length >= this.config.nzMaxStack) {
  275. this.instances = this.instances.slice(1);
  276. }
  277. this.instances = [...this.instances, instance];
  278. }
  279. this.readyInstances();
  280. return instance;
  281. }
  282. onCreate(instance) {
  283. instance.options = this.mergeOptions(instance.options);
  284. instance.onClose = new Subject();
  285. instance.onClick = new Subject();
  286. return instance;
  287. }
  288. subscribeConfigChange() {
  289. this.nzConfigService
  290. .getConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME)
  291. .pipe(takeUntil(this.destroy$))
  292. .subscribe(() => {
  293. this.updateConfig();
  294. this.dir = this.nzConfigService.getConfigForComponent(NZ_CONFIG_MODULE_NAME)?.nzDirection || this.dir;
  295. });
  296. }
  297. updateConfig() {
  298. this.config = {
  299. ...NZ_NOTIFICATION_DEFAULT_CONFIG,
  300. ...this.config,
  301. ...this.nzConfigService.getConfigForComponent(NZ_CONFIG_MODULE_NAME)
  302. };
  303. this.top = toCssPixel(this.config.nzTop);
  304. this.bottom = toCssPixel(this.config.nzBottom);
  305. this.cdr.markForCheck();
  306. }
  307. replaceNotification(old, _new) {
  308. old.title = _new.title;
  309. old.content = _new.content;
  310. old.template = _new.template;
  311. old.type = _new.type;
  312. old.options = _new.options;
  313. }
  314. readyInstances() {
  315. const instancesMap = {
  316. topLeft: [],
  317. topRight: [],
  318. bottomLeft: [],
  319. bottomRight: [],
  320. top: [],
  321. bottom: []
  322. };
  323. this.instances.forEach(m => {
  324. const placement = m.options.nzPlacement;
  325. switch (placement) {
  326. case 'topLeft':
  327. instancesMap.topLeft.unshift(m);
  328. break;
  329. case 'topRight':
  330. instancesMap.topRight.unshift(m);
  331. break;
  332. case 'bottomLeft':
  333. instancesMap.bottomLeft.unshift(m);
  334. break;
  335. case 'bottomRight':
  336. instancesMap.bottomRight.unshift(m);
  337. break;
  338. case 'top':
  339. instancesMap.top.unshift(m);
  340. break;
  341. case 'bottom':
  342. instancesMap.bottom.unshift(m);
  343. break;
  344. default:
  345. instancesMap.topRight.unshift(m);
  346. }
  347. });
  348. this.topLeftInstances = instancesMap.topLeft;
  349. this.topRightInstances = instancesMap.topRight;
  350. this.bottomLeftInstances = instancesMap.bottomLeft;
  351. this.bottomRightInstances = instancesMap.bottomRight;
  352. this.topInstances = instancesMap.top;
  353. this.bottomInstances = instancesMap.bottom;
  354. this.cdr.detectChanges();
  355. }
  356. mergeOptions(options) {
  357. const { nzDuration, nzAnimate, nzPauseOnHover, nzPlacement } = this.config;
  358. return { nzDuration, nzAnimate, nzPauseOnHover, nzPlacement, ...options };
  359. }
  360. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
  361. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzNotificationContainerComponent, isStandalone: true, selector: "nz-notification-container", exportAs: ["nzNotificationContainer"], usesInheritance: true, ngImport: i0, template: `
  362. <div
  363. class="ant-notification ant-notification-topLeft"
  364. [class.ant-notification-rtl]="dir === 'rtl'"
  365. [style.top]="top"
  366. [style.left]="'0px'"
  367. >
  368. @for (instance of topLeftInstances; track instance) {
  369. <nz-notification
  370. [instance]="instance"
  371. [placement]="'topLeft'"
  372. (destroyed)="remove($event.id, $event.userAction)"
  373. />
  374. }
  375. </div>
  376. <div
  377. class="ant-notification ant-notification-topRight"
  378. [class.ant-notification-rtl]="dir === 'rtl'"
  379. [style.top]="top"
  380. [style.right]="'0px'"
  381. >
  382. @for (instance of topRightInstances; track instance) {
  383. <nz-notification
  384. [instance]="instance"
  385. [placement]="'topRight'"
  386. (destroyed)="remove($event.id, $event.userAction)"
  387. />
  388. }
  389. </div>
  390. <div
  391. class="ant-notification ant-notification-bottomLeft"
  392. [class.ant-notification-rtl]="dir === 'rtl'"
  393. [style.bottom]="bottom"
  394. [style.left]="'0px'"
  395. >
  396. @for (instance of bottomLeftInstances; track instance) {
  397. <nz-notification
  398. [instance]="instance"
  399. [placement]="'bottomLeft'"
  400. (destroyed)="remove($event.id, $event.userAction)"
  401. />
  402. }
  403. </div>
  404. <div
  405. class="ant-notification ant-notification-bottomRight"
  406. [class.ant-notification-rtl]="dir === 'rtl'"
  407. [style.bottom]="bottom"
  408. [style.right]="'0px'"
  409. >
  410. @for (instance of bottomRightInstances; track instance) {
  411. <nz-notification
  412. [instance]="instance"
  413. [placement]="'bottomRight'"
  414. (destroyed)="remove($event.id, $event.userAction)"
  415. />
  416. }
  417. </div>
  418. <div
  419. class="ant-notification ant-notification-top"
  420. [class.ant-notification-rtl]="dir === 'rtl'"
  421. [style.top]="top"
  422. [style.left]="'50%'"
  423. [style.transform]="'translateX(-50%)'"
  424. >
  425. @for (instance of topInstances; track instance) {
  426. <nz-notification [instance]="instance" [placement]="'top'" (destroyed)="remove($event.id, $event.userAction)" />
  427. }
  428. </div>
  429. <div
  430. class="ant-notification ant-notification-bottom"
  431. [class.ant-notification-rtl]="dir === 'rtl'"
  432. [style.bottom]="bottom"
  433. [style.left]="'50%'"
  434. [style.transform]="'translateX(-50%)'"
  435. >
  436. @for (instance of bottomInstances; track instance) {
  437. <nz-notification
  438. [instance]="instance"
  439. [placement]="'bottom'"
  440. (destroyed)="remove($event.id, $event.userAction)"
  441. />
  442. }
  443. </div>
  444. `, isInline: true, dependencies: [{ kind: "component", type: NzNotificationComponent, selector: "nz-notification", inputs: ["instance", "index", "placement"], outputs: ["destroyed"], exportAs: ["nzNotification"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
  445. }
  446. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationContainerComponent, decorators: [{
  447. type: Component,
  448. args: [{
  449. changeDetection: ChangeDetectionStrategy.OnPush,
  450. encapsulation: ViewEncapsulation.None,
  451. selector: 'nz-notification-container',
  452. exportAs: 'nzNotificationContainer',
  453. preserveWhitespaces: false,
  454. template: `
  455. <div
  456. class="ant-notification ant-notification-topLeft"
  457. [class.ant-notification-rtl]="dir === 'rtl'"
  458. [style.top]="top"
  459. [style.left]="'0px'"
  460. >
  461. @for (instance of topLeftInstances; track instance) {
  462. <nz-notification
  463. [instance]="instance"
  464. [placement]="'topLeft'"
  465. (destroyed)="remove($event.id, $event.userAction)"
  466. />
  467. }
  468. </div>
  469. <div
  470. class="ant-notification ant-notification-topRight"
  471. [class.ant-notification-rtl]="dir === 'rtl'"
  472. [style.top]="top"
  473. [style.right]="'0px'"
  474. >
  475. @for (instance of topRightInstances; track instance) {
  476. <nz-notification
  477. [instance]="instance"
  478. [placement]="'topRight'"
  479. (destroyed)="remove($event.id, $event.userAction)"
  480. />
  481. }
  482. </div>
  483. <div
  484. class="ant-notification ant-notification-bottomLeft"
  485. [class.ant-notification-rtl]="dir === 'rtl'"
  486. [style.bottom]="bottom"
  487. [style.left]="'0px'"
  488. >
  489. @for (instance of bottomLeftInstances; track instance) {
  490. <nz-notification
  491. [instance]="instance"
  492. [placement]="'bottomLeft'"
  493. (destroyed)="remove($event.id, $event.userAction)"
  494. />
  495. }
  496. </div>
  497. <div
  498. class="ant-notification ant-notification-bottomRight"
  499. [class.ant-notification-rtl]="dir === 'rtl'"
  500. [style.bottom]="bottom"
  501. [style.right]="'0px'"
  502. >
  503. @for (instance of bottomRightInstances; track instance) {
  504. <nz-notification
  505. [instance]="instance"
  506. [placement]="'bottomRight'"
  507. (destroyed)="remove($event.id, $event.userAction)"
  508. />
  509. }
  510. </div>
  511. <div
  512. class="ant-notification ant-notification-top"
  513. [class.ant-notification-rtl]="dir === 'rtl'"
  514. [style.top]="top"
  515. [style.left]="'50%'"
  516. [style.transform]="'translateX(-50%)'"
  517. >
  518. @for (instance of topInstances; track instance) {
  519. <nz-notification [instance]="instance" [placement]="'top'" (destroyed)="remove($event.id, $event.userAction)" />
  520. }
  521. </div>
  522. <div
  523. class="ant-notification ant-notification-bottom"
  524. [class.ant-notification-rtl]="dir === 'rtl'"
  525. [style.bottom]="bottom"
  526. [style.left]="'50%'"
  527. [style.transform]="'translateX(-50%)'"
  528. >
  529. @for (instance of bottomInstances; track instance) {
  530. <nz-notification
  531. [instance]="instance"
  532. [placement]="'bottom'"
  533. (destroyed)="remove($event.id, $event.userAction)"
  534. />
  535. }
  536. </div>
  537. `,
  538. imports: [NzNotificationComponent]
  539. }]
  540. }], ctorParameters: () => [] });
  541. /**
  542. * Use of this source code is governed by an MIT-style license that can be
  543. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  544. */
  545. /**
  546. * @deprecated This module is no longer needed, will be removed in v20, please remove its import.
  547. */
  548. class NzNotificationModule {
  549. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  550. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationModule, imports: [NzNotificationComponent, NzNotificationContainerComponent] });
  551. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationModule, imports: [NzNotificationComponent, NzNotificationContainerComponent] });
  552. }
  553. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationModule, decorators: [{
  554. type: NgModule,
  555. args: [{
  556. imports: [NzNotificationComponent, NzNotificationContainerComponent]
  557. }]
  558. }] });
  559. /**
  560. * Use of this source code is governed by an MIT-style license that can be
  561. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  562. */
  563. let notificationId = 0;
  564. class NzNotificationService extends NzMNService {
  565. componentPrefix = 'notification-';
  566. constructor(overlay, injector) {
  567. super(overlay, injector);
  568. }
  569. success(title, content, options) {
  570. return this.create('success', title, content, options);
  571. }
  572. error(title, content, options) {
  573. return this.create('error', title, content, options);
  574. }
  575. info(title, content, options) {
  576. return this.create('info', title, content, options);
  577. }
  578. warning(title, content, options) {
  579. return this.create('warning', title, content, options);
  580. }
  581. blank(title, content, options) {
  582. return this.create('blank', title, content, options);
  583. }
  584. create(type, title, content, options) {
  585. return this.createInstance({ type, title, content }, options);
  586. }
  587. template(template, options) {
  588. return this.createInstance({ template }, options);
  589. }
  590. generateMessageId() {
  591. return `${this.componentPrefix}-${notificationId++}`;
  592. }
  593. createInstance(message, options) {
  594. this.container = this.withContainer(NzNotificationContainerComponent);
  595. return this.container.create({
  596. ...message,
  597. ...{
  598. createdAt: new Date(),
  599. messageId: options?.nzKey || this.generateMessageId(),
  600. options
  601. }
  602. });
  603. }
  604. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationService, deps: [{ token: i1$1.Overlay }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
  605. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationService, providedIn: 'root' });
  606. }
  607. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationService, decorators: [{
  608. type: Injectable,
  609. args: [{
  610. providedIn: 'root'
  611. }]
  612. }], ctorParameters: () => [{ type: i1$1.Overlay }, { type: i0.Injector }] });
  613. /**
  614. * Use of this source code is governed by an MIT-style license that can be
  615. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  616. */
  617. /**
  618. * @deprecated This module is no longer needed, will be removed in v20, please remove its import.
  619. */
  620. class NzNotificationServiceModule {
  621. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  622. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationServiceModule });
  623. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationServiceModule });
  624. }
  625. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzNotificationServiceModule, decorators: [{
  626. type: NgModule
  627. }] });
  628. /**
  629. * Use of this source code is governed by an MIT-style license that can be
  630. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  631. */
  632. /**
  633. * Generated bundle index. Do not edit.
  634. */
  635. export { NzNotificationComponent, NzNotificationContainerComponent, NzNotificationModule, NzNotificationService, NzNotificationServiceModule };
  636. //# sourceMappingURL=ng-zorro-antd-notification.mjs.map