ng-zorro-antd-modal.mjs 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774
  1. import * as i1 from '@angular/cdk/overlay';
  2. import { OverlayRef, CdkScrollable, OverlayConfig } from '@angular/cdk/overlay';
  3. import * as i5 from '@angular/cdk/portal';
  4. import { BasePortalOutlet, PortalModule, CdkPortalOutlet, ComponentPortal, TemplatePortal } from '@angular/cdk/portal';
  5. import * as i0 from '@angular/core';
  6. import { InjectionToken, ChangeDetectionStrategy, Component, EventEmitter, inject, ChangeDetectorRef, NgZone, ElementRef, Renderer2, ANIMATION_MODULE_TYPE, Directive, Output, ViewChild, Input, Injector, TemplateRef, Injectable, booleanAttribute, numberAttribute, ContentChild, NgModule } from '@angular/core';
  7. import { Subject, defer } from 'rxjs';
  8. import { takeUntil, filter, take, startWith } from 'rxjs/operators';
  9. import { warn } from 'ng-zorro-antd/core/logger';
  10. import { overlayZIndexSetter } from 'ng-zorro-antd/core/overlay';
  11. import { getElementOffset, isNotNil, fromEventOutsideAngular, isPromise } from 'ng-zorro-antd/core/util';
  12. import * as i6 from 'ng-zorro-antd/button';
  13. import { NzButtonModule } from 'ng-zorro-antd/button';
  14. import * as i3 from 'ng-zorro-antd/core/outlet';
  15. import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
  16. import * as i1$1 from 'ng-zorro-antd/i18n';
  17. import { NzI18nService } from 'ng-zorro-antd/i18n';
  18. import * as i2 from 'ng-zorro-antd/icon';
  19. import { NzIconModule } from 'ng-zorro-antd/icon';
  20. import * as i2$1 from 'ng-zorro-antd/pipes';
  21. import { NzPipesModule } from 'ng-zorro-antd/pipes';
  22. import { trigger, state, transition, style, animate } from '@angular/animations';
  23. import { FocusTrapFactory } from '@angular/cdk/a11y';
  24. import { DOCUMENT } from '@angular/common';
  25. import * as i2$2 from 'ng-zorro-antd/core/config';
  26. import { NzConfigService } from 'ng-zorro-antd/core/config';
  27. import { reqAnimFrame } from 'ng-zorro-antd/core/polyfill';
  28. import * as i7 from 'ng-zorro-antd/core/transition-patch';
  29. import * as i8 from 'ng-zorro-antd/core/wave';
  30. import { CdkDrag, CdkDragHandle } from '@angular/cdk/drag-drop';
  31. import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
  32. import * as i3$1 from '@angular/cdk/bidi';
  33. /**
  34. * Use of this source code is governed by an MIT-style license that can be
  35. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  36. */
  37. const noopFun = () => void 0;
  38. class ModalOptions {
  39. nzCentered = false;
  40. nzClosable = true;
  41. nzOkLoading = false;
  42. nzOkDisabled = false;
  43. nzCancelDisabled = false;
  44. nzCancelLoading = false;
  45. nzDraggable = false;
  46. nzNoAnimation = false;
  47. nzAutofocus = 'auto';
  48. nzMask;
  49. nzMaskClosable;
  50. nzKeyboard = true;
  51. nzZIndex = 1000;
  52. nzWidth = 520;
  53. nzCloseIcon = 'close';
  54. nzOkType = 'primary';
  55. nzOkDanger = false;
  56. nzModalType = 'default';
  57. nzOnCancel = noopFun;
  58. nzOnOk = noopFun;
  59. nzData;
  60. nzMaskStyle;
  61. nzBodyStyle;
  62. nzWrapClassName;
  63. nzClassName;
  64. nzStyle;
  65. nzTitle;
  66. nzFooter; // Default Modal ONLY
  67. nzCancelText;
  68. nzOkText;
  69. nzContent;
  70. nzCloseOnNavigation;
  71. nzViewContainerRef;
  72. // Template use only
  73. nzAfterOpen;
  74. nzAfterClose;
  75. // Confirm
  76. nzIconType = 'question-circle';
  77. nzDirection;
  78. }
  79. /**
  80. * Use of this source code is governed by an MIT-style license that can be
  81. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  82. */
  83. const ZOOM_CLASS_NAME_MAP = {
  84. enter: 'ant-zoom-enter',
  85. enterActive: 'ant-zoom-enter-active',
  86. leave: 'ant-zoom-leave',
  87. leaveActive: 'ant-zoom-leave-active'
  88. };
  89. const FADE_CLASS_NAME_MAP = {
  90. enter: 'ant-fade-enter',
  91. enterActive: 'ant-fade-enter-active',
  92. leave: 'ant-fade-leave',
  93. leaveActive: 'ant-fade-leave-active'
  94. };
  95. const MODAL_MASK_CLASS_NAME = 'ant-modal-mask';
  96. const NZ_CONFIG_MODULE_NAME = 'modal';
  97. const NZ_MODAL_DATA = new InjectionToken('NZ_MODAL_DATA');
  98. /**
  99. * Use of this source code is governed by an MIT-style license that can be
  100. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  101. */
  102. const nzModalAnimations = {
  103. modalContainer: trigger('modalContainer', [
  104. state('void, exit', style({})),
  105. state('enter', style({})),
  106. transition('* => enter', animate('.24s', style({}))),
  107. transition('* => void, * => exit', animate('.2s', style({})))
  108. ])
  109. };
  110. /**
  111. * Use of this source code is governed by an MIT-style license that can be
  112. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  113. */
  114. class NzModalCloseComponent {
  115. config;
  116. constructor(config) {
  117. this.config = config;
  118. }
  119. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalCloseComponent, deps: [{ token: ModalOptions }], target: i0.ɵɵFactoryTarget.Component });
  120. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzModalCloseComponent, isStandalone: true, selector: "button[nz-modal-close]", host: { attributes: { "aria-label": "Close" }, classAttribute: "ant-modal-close" }, exportAs: ["NzModalCloseBuiltin"], ngImport: i0, template: `
  121. <span class="ant-modal-close-x">
  122. <ng-container *nzStringTemplateOutlet="config.nzCloseIcon; let closeIcon">
  123. <nz-icon [nzType]="closeIcon" class="ant-modal-close-icon" />
  124. </ng-container>
  125. </span>
  126. `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
  127. }
  128. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalCloseComponent, decorators: [{
  129. type: Component,
  130. args: [{
  131. selector: 'button[nz-modal-close]',
  132. exportAs: 'NzModalCloseBuiltin',
  133. template: `
  134. <span class="ant-modal-close-x">
  135. <ng-container *nzStringTemplateOutlet="config.nzCloseIcon; let closeIcon">
  136. <nz-icon [nzType]="closeIcon" class="ant-modal-close-icon" />
  137. </ng-container>
  138. </span>
  139. `,
  140. host: {
  141. class: 'ant-modal-close',
  142. 'aria-label': 'Close'
  143. },
  144. changeDetection: ChangeDetectionStrategy.OnPush,
  145. imports: [NzIconModule, NzOutletModule]
  146. }]
  147. }], ctorParameters: () => [{ type: ModalOptions }] });
  148. /**
  149. * Use of this source code is governed by an MIT-style license that can be
  150. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  151. */
  152. function applyConfigDefaults(config, defaultOptions) {
  153. return { ...defaultOptions, ...config };
  154. }
  155. function getValueWithConfig(userValue, configValue, defaultValue) {
  156. return typeof userValue === 'undefined'
  157. ? typeof configValue === 'undefined'
  158. ? defaultValue
  159. : configValue
  160. : userValue;
  161. }
  162. function getConfigFromComponent(component) {
  163. const { nzCentered, nzMask, nzMaskClosable, nzClosable, nzOkLoading, nzOkDisabled, nzCancelDisabled, nzCancelLoading, nzKeyboard, nzNoAnimation, nzDraggable, nzContent, nzFooter, nzZIndex, nzWidth, nzWrapClassName, nzClassName, nzStyle, nzTitle, nzCloseIcon, nzMaskStyle, nzBodyStyle, nzOkText, nzCancelText, nzOkType, nzOkDanger, nzIconType, nzModalType, nzOnOk, nzOnCancel, nzAfterOpen, nzAfterClose, nzCloseOnNavigation, nzAutofocus } = component;
  164. return {
  165. nzCentered,
  166. nzMask,
  167. nzMaskClosable,
  168. nzDraggable,
  169. nzClosable,
  170. nzOkLoading,
  171. nzOkDisabled,
  172. nzCancelDisabled,
  173. nzCancelLoading,
  174. nzKeyboard,
  175. nzNoAnimation,
  176. nzContent,
  177. nzFooter,
  178. nzZIndex,
  179. nzWidth,
  180. nzWrapClassName,
  181. nzClassName,
  182. nzStyle,
  183. nzTitle,
  184. nzCloseIcon,
  185. nzMaskStyle,
  186. nzBodyStyle,
  187. nzOkText,
  188. nzCancelText,
  189. nzOkType,
  190. nzOkDanger,
  191. nzIconType,
  192. nzModalType,
  193. nzOnOk,
  194. nzOnCancel,
  195. nzAfterOpen,
  196. nzAfterClose,
  197. nzCloseOnNavigation,
  198. nzAutofocus
  199. };
  200. }
  201. function throwNzModalContentAlreadyAttachedError() {
  202. throw Error('Attempting to attach modal content after content is already attached');
  203. }
  204. class BaseModalContainerComponent extends BasePortalOutlet {
  205. portalOutlet;
  206. modalElementRef;
  207. animationStateChanged = new EventEmitter();
  208. containerClick = new EventEmitter();
  209. cancelTriggered = new EventEmitter();
  210. okTriggered = new EventEmitter();
  211. state = 'enter';
  212. document = inject(DOCUMENT);
  213. modalRef;
  214. isStringContent = false;
  215. dir = 'ltr';
  216. elementFocusedBeforeModalWasOpened = null;
  217. focusTrap;
  218. mouseDown = false;
  219. oldMaskStyle = null;
  220. cdr = inject(ChangeDetectorRef);
  221. config = inject(ModalOptions);
  222. destroy$ = new Subject();
  223. ngZone = inject(NgZone);
  224. host = inject(ElementRef);
  225. focusTrapFactory = inject(FocusTrapFactory);
  226. render = inject(Renderer2);
  227. overlayRef = inject(OverlayRef);
  228. nzConfigService = inject(NzConfigService);
  229. animationType = inject(ANIMATION_MODULE_TYPE, { optional: true });
  230. get showMask() {
  231. const defaultConfig = this.nzConfigService.getConfigForComponent(NZ_CONFIG_MODULE_NAME) || {};
  232. return !!getValueWithConfig(this.config.nzMask, defaultConfig.nzMask, true);
  233. }
  234. get maskClosable() {
  235. const defaultConfig = this.nzConfigService.getConfigForComponent(NZ_CONFIG_MODULE_NAME) || {};
  236. return !!getValueWithConfig(this.config.nzMaskClosable, defaultConfig.nzMaskClosable, true);
  237. }
  238. constructor() {
  239. super();
  240. this.dir = this.overlayRef.getDirection();
  241. this.isStringContent = typeof this.config.nzContent === 'string';
  242. this.nzConfigService
  243. .getConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME)
  244. .pipe(takeUntil(this.destroy$))
  245. .subscribe(() => {
  246. this.updateMaskClassname();
  247. });
  248. }
  249. onContainerClick(e) {
  250. if (e.target === e.currentTarget && !this.mouseDown && this.showMask && this.maskClosable) {
  251. this.containerClick.emit();
  252. }
  253. }
  254. onCloseClick() {
  255. this.cancelTriggered.emit();
  256. }
  257. onOkClick() {
  258. this.okTriggered.emit();
  259. }
  260. attachComponentPortal(portal) {
  261. if (this.portalOutlet.hasAttached()) {
  262. throwNzModalContentAlreadyAttachedError();
  263. }
  264. this.savePreviouslyFocusedElement();
  265. this.setZIndexForBackdrop();
  266. return this.portalOutlet.attachComponentPortal(portal);
  267. }
  268. attachTemplatePortal(portal) {
  269. if (this.portalOutlet.hasAttached()) {
  270. throwNzModalContentAlreadyAttachedError();
  271. }
  272. this.savePreviouslyFocusedElement();
  273. this.setZIndexForBackdrop();
  274. return this.portalOutlet.attachTemplatePortal(portal);
  275. }
  276. attachStringContent() {
  277. this.savePreviouslyFocusedElement();
  278. this.setZIndexForBackdrop();
  279. }
  280. getNativeElement() {
  281. return this.host.nativeElement;
  282. }
  283. animationDisabled() {
  284. return this.config.nzNoAnimation || this.animationType === 'NoopAnimations';
  285. }
  286. setModalTransformOrigin() {
  287. const modalElement = this.modalElementRef.nativeElement;
  288. if (this.elementFocusedBeforeModalWasOpened) {
  289. const previouslyDOMRect = this.elementFocusedBeforeModalWasOpened.getBoundingClientRect();
  290. const lastPosition = getElementOffset(this.elementFocusedBeforeModalWasOpened);
  291. const x = lastPosition.left + previouslyDOMRect.width / 2;
  292. const y = lastPosition.top + previouslyDOMRect.height / 2;
  293. const transformOrigin = `${x - modalElement.offsetLeft}px ${y - modalElement.offsetTop}px 0px`;
  294. this.render.setStyle(modalElement, 'transform-origin', transformOrigin);
  295. }
  296. }
  297. savePreviouslyFocusedElement() {
  298. if (!this.focusTrap) {
  299. this.focusTrap = this.focusTrapFactory.create(this.host.nativeElement);
  300. }
  301. if (this.document) {
  302. this.elementFocusedBeforeModalWasOpened = this.document.activeElement;
  303. if (this.host.nativeElement.focus) {
  304. this.ngZone.runOutsideAngular(() => reqAnimFrame(() => this.host.nativeElement.focus()));
  305. }
  306. }
  307. }
  308. trapFocus() {
  309. const element = this.host.nativeElement;
  310. if (this.config.nzAutofocus) {
  311. this.focusTrap.focusInitialElementWhenReady();
  312. }
  313. else {
  314. const activeElement = this.document.activeElement;
  315. if (activeElement !== element && !element.contains(activeElement)) {
  316. element.focus();
  317. }
  318. }
  319. }
  320. restoreFocus() {
  321. const toFocus = this.elementFocusedBeforeModalWasOpened;
  322. // We need the extra check, because IE can set the `activeElement` to null in some cases.
  323. if (toFocus && typeof toFocus.focus === 'function') {
  324. const activeElement = this.document.activeElement;
  325. const element = this.host.nativeElement;
  326. if (!activeElement ||
  327. activeElement === this.document.body ||
  328. activeElement === element ||
  329. element.contains(activeElement)) {
  330. toFocus.focus();
  331. }
  332. }
  333. if (this.focusTrap) {
  334. this.focusTrap.destroy();
  335. }
  336. }
  337. setEnterAnimationClass() {
  338. if (this.animationDisabled()) {
  339. return;
  340. }
  341. // Make sure to set the `TransformOrigin` style before set the modelElement's class names
  342. this.setModalTransformOrigin();
  343. const modalElement = this.modalElementRef.nativeElement;
  344. const backdropElement = this.overlayRef.backdropElement;
  345. modalElement.classList.add(ZOOM_CLASS_NAME_MAP.enter);
  346. modalElement.classList.add(ZOOM_CLASS_NAME_MAP.enterActive);
  347. if (backdropElement) {
  348. backdropElement.classList.add(FADE_CLASS_NAME_MAP.enter);
  349. backdropElement.classList.add(FADE_CLASS_NAME_MAP.enterActive);
  350. }
  351. }
  352. setExitAnimationClass() {
  353. const modalElement = this.modalElementRef.nativeElement;
  354. modalElement.classList.add(ZOOM_CLASS_NAME_MAP.leave);
  355. modalElement.classList.add(ZOOM_CLASS_NAME_MAP.leaveActive);
  356. this.setMaskExitAnimationClass();
  357. }
  358. setMaskExitAnimationClass(force = false) {
  359. const backdropElement = this.overlayRef.backdropElement;
  360. if (backdropElement) {
  361. if (this.animationDisabled() || force) {
  362. // https://github.com/angular/components/issues/18645
  363. backdropElement.classList.remove(MODAL_MASK_CLASS_NAME);
  364. return;
  365. }
  366. backdropElement.classList.add(FADE_CLASS_NAME_MAP.leave);
  367. backdropElement.classList.add(FADE_CLASS_NAME_MAP.leaveActive);
  368. }
  369. }
  370. cleanAnimationClass() {
  371. if (this.animationDisabled()) {
  372. return;
  373. }
  374. const backdropElement = this.overlayRef.backdropElement;
  375. const modalElement = this.modalElementRef.nativeElement;
  376. if (backdropElement) {
  377. backdropElement.classList.remove(FADE_CLASS_NAME_MAP.enter);
  378. backdropElement.classList.remove(FADE_CLASS_NAME_MAP.enterActive);
  379. }
  380. modalElement.classList.remove(ZOOM_CLASS_NAME_MAP.enter);
  381. modalElement.classList.remove(ZOOM_CLASS_NAME_MAP.enterActive);
  382. modalElement.classList.remove(ZOOM_CLASS_NAME_MAP.leave);
  383. modalElement.classList.remove(ZOOM_CLASS_NAME_MAP.leaveActive);
  384. }
  385. setZIndexForBackdrop() {
  386. const backdropElement = this.overlayRef.backdropElement;
  387. if (backdropElement) {
  388. if (isNotNil(this.config.nzZIndex)) {
  389. this.render.setStyle(backdropElement, 'z-index', this.config.nzZIndex);
  390. }
  391. }
  392. }
  393. bindBackdropStyle() {
  394. const backdropElement = this.overlayRef.backdropElement;
  395. if (backdropElement) {
  396. if (this.oldMaskStyle) {
  397. const styles = this.oldMaskStyle;
  398. Object.keys(styles).forEach(key => {
  399. this.render.removeStyle(backdropElement, key);
  400. });
  401. this.oldMaskStyle = null;
  402. }
  403. this.setZIndexForBackdrop();
  404. if (typeof this.config.nzMaskStyle === 'object' && Object.keys(this.config.nzMaskStyle).length) {
  405. const styles = { ...this.config.nzMaskStyle };
  406. Object.keys(styles).forEach(key => {
  407. this.render.setStyle(backdropElement, key, styles[key]);
  408. });
  409. this.oldMaskStyle = styles;
  410. }
  411. }
  412. }
  413. updateMaskClassname() {
  414. const backdropElement = this.overlayRef.backdropElement;
  415. if (backdropElement) {
  416. if (this.showMask) {
  417. backdropElement.classList.add(MODAL_MASK_CLASS_NAME);
  418. }
  419. else {
  420. backdropElement.classList.remove(MODAL_MASK_CLASS_NAME);
  421. }
  422. }
  423. }
  424. onAnimationDone(event) {
  425. if (event.toState === 'enter') {
  426. this.trapFocus();
  427. }
  428. else if (event.toState === 'exit') {
  429. this.restoreFocus();
  430. }
  431. this.cleanAnimationClass();
  432. this.animationStateChanged.emit(event);
  433. }
  434. onAnimationStart(event) {
  435. if (event.toState === 'enter') {
  436. this.setEnterAnimationClass();
  437. this.bindBackdropStyle();
  438. }
  439. else if (event.toState === 'exit') {
  440. this.setExitAnimationClass();
  441. }
  442. this.animationStateChanged.emit(event);
  443. }
  444. startExitAnimation() {
  445. this.state = 'exit';
  446. this.cdr.markForCheck();
  447. }
  448. ngOnDestroy() {
  449. this.setMaskExitAnimationClass(true);
  450. this.destroy$.next(true);
  451. this.destroy$.complete();
  452. }
  453. setupMouseListeners(modalContainer) {
  454. fromEventOutsideAngular(this.host.nativeElement, 'mouseup')
  455. .pipe(takeUntil(this.destroy$))
  456. .subscribe(() => {
  457. if (this.mouseDown) {
  458. setTimeout(() => {
  459. this.mouseDown = false;
  460. });
  461. }
  462. });
  463. fromEventOutsideAngular(modalContainer.nativeElement, 'mousedown')
  464. .pipe(takeUntil(this.destroy$))
  465. .subscribe(() => {
  466. this.mouseDown = true;
  467. });
  468. }
  469. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: BaseModalContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  470. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: BaseModalContainerComponent, isStandalone: true, usesInheritance: true, ngImport: i0 });
  471. }
  472. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: BaseModalContainerComponent, decorators: [{
  473. type: Directive
  474. }], ctorParameters: () => [] });
  475. /**
  476. * Use of this source code is governed by an MIT-style license that can be
  477. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  478. */
  479. class NzModalConfirmContainerComponent extends BaseModalContainerComponent {
  480. set _portalOutlet(portalOutlet) {
  481. this.portalOutlet = portalOutlet;
  482. }
  483. set _modalElementRef(elementRef) {
  484. this.modalElementRef = elementRef;
  485. }
  486. cancelTriggered = new EventEmitter();
  487. okTriggered = new EventEmitter();
  488. locale;
  489. i18n = inject(NzI18nService);
  490. constructor() {
  491. super();
  492. this.i18n.localeChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
  493. this.locale = this.i18n.getLocaleData('Modal');
  494. });
  495. }
  496. ngOnInit() {
  497. this.setupMouseListeners(this.modalElementRef);
  498. }
  499. onCancel() {
  500. this.cancelTriggered.emit();
  501. }
  502. onOk() {
  503. this.okTriggered.emit();
  504. }
  505. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalConfirmContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
  506. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzModalConfirmContainerComponent, isStandalone: true, selector: "nz-modal-confirm-container", outputs: { cancelTriggered: "cancelTriggered", okTriggered: "okTriggered" }, host: { attributes: { "tabindex": "-1", "role": "dialog" }, listeners: { "@modalContainer.start": "onAnimationStart($event)", "@modalContainer.done": "onAnimationDone($event)", "click": "onContainerClick($event)" }, properties: { "class": "config.nzWrapClassName ? \"ant-modal-wrap \" + config.nzWrapClassName : \"ant-modal-wrap\"", "class.ant-modal-wrap-rtl": "dir === 'rtl'", "class.ant-modal-centered": "config.nzCentered", "style.zIndex": "config.nzZIndex", "@.disabled": "config.nzNoAnimation", "@modalContainer": "state" } }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }, { propertyName: "_modalElementRef", first: true, predicate: ["modalElement"], descendants: true, static: true }], exportAs: ["nzModalConfirmContainer"], usesInheritance: true, hostDirectives: [{ directive: i1.CdkScrollable }], ngImport: i0, template: `
  507. <div
  508. #modalElement
  509. role="document"
  510. class="ant-modal"
  511. [class]="config.nzClassName!"
  512. [style]="config.nzStyle!"
  513. [style.width]="config?.nzWidth! | nzToCssUnit"
  514. >
  515. <div class="ant-modal-content">
  516. @if (config.nzClosable) {
  517. <button nz-modal-close (click)="onCloseClick()"></button>
  518. }
  519. <div class="ant-modal-body" [style]="config.nzBodyStyle!">
  520. <div class="ant-modal-confirm-body-wrapper">
  521. <div class="ant-modal-confirm-body">
  522. <nz-icon [nzType]="config.nzIconType!" />
  523. <span class="ant-modal-confirm-title">
  524. <ng-container *nzStringTemplateOutlet="config.nzTitle">
  525. <span [innerHTML]="config.nzTitle"></span>
  526. </ng-container>
  527. </span>
  528. <div class="ant-modal-confirm-content">
  529. <ng-template cdkPortalOutlet></ng-template>
  530. @if (isStringContent) {
  531. <div [innerHTML]="config.nzContent"></div>
  532. }
  533. </div>
  534. </div>
  535. <div class="ant-modal-confirm-btns">
  536. @if (config.nzCancelText !== null) {
  537. <button
  538. [attr.cdkFocusInitial]="config.nzAutofocus === 'cancel' || null"
  539. nz-button
  540. (click)="onCancel()"
  541. [nzLoading]="config.nzCancelLoading"
  542. [disabled]="config.nzCancelDisabled"
  543. >
  544. {{ config.nzCancelText || locale.cancelText }}
  545. </button>
  546. }
  547. @if (config.nzOkText !== null) {
  548. <button
  549. [attr.cdkFocusInitial]="config.nzAutofocus === 'ok' || null"
  550. nz-button
  551. [nzType]="config.nzOkType!"
  552. (click)="onOk()"
  553. [nzLoading]="config.nzOkLoading"
  554. [disabled]="config.nzOkDisabled"
  555. [nzDanger]="config.nzOkDanger"
  556. >
  557. {{ config.nzOkText || locale.okText }}
  558. </button>
  559. }
  560. </div>
  561. </div>
  562. </div>
  563. </div>
  564. </div>
  565. `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzPipesModule }, { kind: "pipe", type: i2$1.NzToCssUnitPipe, name: "nzToCssUnit" }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "component", type: NzModalCloseComponent, selector: "button[nz-modal-close]", exportAs: ["NzModalCloseBuiltin"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i5.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "ngmodule", type: NzButtonModule }, { kind: "component", type: i6.NzButtonComponent, selector: "button[nz-button], a[nz-button]", inputs: ["nzBlock", "nzGhost", "nzSearch", "nzLoading", "nzDanger", "disabled", "tabIndex", "nzType", "nzShape", "nzSize"], exportAs: ["nzButton"] }, { kind: "directive", type: i7.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { kind: "directive", type: i8.NzWaveDirective, selector: "[nz-wave],button[nz-button]:not([nzType=\"link\"]):not([nzType=\"text\"])", inputs: ["nzWaveExtraNode"], exportAs: ["nzWave"] }], animations: [nzModalAnimations.modalContainer], changeDetection: i0.ChangeDetectionStrategy.Default });
  566. }
  567. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalConfirmContainerComponent, decorators: [{
  568. type: Component,
  569. args: [{
  570. selector: 'nz-modal-confirm-container',
  571. exportAs: 'nzModalConfirmContainer',
  572. template: `
  573. <div
  574. #modalElement
  575. role="document"
  576. class="ant-modal"
  577. [class]="config.nzClassName!"
  578. [style]="config.nzStyle!"
  579. [style.width]="config?.nzWidth! | nzToCssUnit"
  580. >
  581. <div class="ant-modal-content">
  582. @if (config.nzClosable) {
  583. <button nz-modal-close (click)="onCloseClick()"></button>
  584. }
  585. <div class="ant-modal-body" [style]="config.nzBodyStyle!">
  586. <div class="ant-modal-confirm-body-wrapper">
  587. <div class="ant-modal-confirm-body">
  588. <nz-icon [nzType]="config.nzIconType!" />
  589. <span class="ant-modal-confirm-title">
  590. <ng-container *nzStringTemplateOutlet="config.nzTitle">
  591. <span [innerHTML]="config.nzTitle"></span>
  592. </ng-container>
  593. </span>
  594. <div class="ant-modal-confirm-content">
  595. <ng-template cdkPortalOutlet></ng-template>
  596. @if (isStringContent) {
  597. <div [innerHTML]="config.nzContent"></div>
  598. }
  599. </div>
  600. </div>
  601. <div class="ant-modal-confirm-btns">
  602. @if (config.nzCancelText !== null) {
  603. <button
  604. [attr.cdkFocusInitial]="config.nzAutofocus === 'cancel' || null"
  605. nz-button
  606. (click)="onCancel()"
  607. [nzLoading]="config.nzCancelLoading"
  608. [disabled]="config.nzCancelDisabled"
  609. >
  610. {{ config.nzCancelText || locale.cancelText }}
  611. </button>
  612. }
  613. @if (config.nzOkText !== null) {
  614. <button
  615. [attr.cdkFocusInitial]="config.nzAutofocus === 'ok' || null"
  616. nz-button
  617. [nzType]="config.nzOkType!"
  618. (click)="onOk()"
  619. [nzLoading]="config.nzOkLoading"
  620. [disabled]="config.nzOkDisabled"
  621. [nzDanger]="config.nzOkDanger"
  622. >
  623. {{ config.nzOkText || locale.okText }}
  624. </button>
  625. }
  626. </div>
  627. </div>
  628. </div>
  629. </div>
  630. </div>
  631. `,
  632. hostDirectives: [CdkScrollable],
  633. animations: [nzModalAnimations.modalContainer],
  634. // Using OnPush for modal caused footer can not to detect changes. we can fix it when 8.x.
  635. changeDetection: ChangeDetectionStrategy.Default,
  636. host: {
  637. tabindex: '-1',
  638. role: 'dialog',
  639. '[class]': 'config.nzWrapClassName ? "ant-modal-wrap " + config.nzWrapClassName : "ant-modal-wrap"',
  640. '[class.ant-modal-wrap-rtl]': `dir === 'rtl'`,
  641. '[class.ant-modal-centered]': 'config.nzCentered',
  642. '[style.zIndex]': 'config.nzZIndex',
  643. '[@.disabled]': 'config.nzNoAnimation',
  644. '[@modalContainer]': 'state',
  645. '(@modalContainer.start)': 'onAnimationStart($event)',
  646. '(@modalContainer.done)': 'onAnimationDone($event)',
  647. '(click)': 'onContainerClick($event)'
  648. },
  649. imports: [NzPipesModule, NzIconModule, NzModalCloseComponent, NzOutletModule, PortalModule, NzButtonModule]
  650. }]
  651. }], ctorParameters: () => [], propDecorators: { _portalOutlet: [{
  652. type: ViewChild,
  653. args: [CdkPortalOutlet, { static: true }]
  654. }], _modalElementRef: [{
  655. type: ViewChild,
  656. args: ['modalElement', { static: true }]
  657. }], cancelTriggered: [{
  658. type: Output
  659. }], okTriggered: [{
  660. type: Output
  661. }] } });
  662. /**
  663. * Use of this source code is governed by an MIT-style license that can be
  664. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  665. */
  666. class NzModalFooterComponent {
  667. i18n;
  668. config;
  669. buttonsFooter = false;
  670. buttons = [];
  671. locale;
  672. cancelTriggered = new EventEmitter();
  673. okTriggered = new EventEmitter();
  674. modalRef;
  675. destroy$ = new Subject();
  676. constructor(i18n, config) {
  677. this.i18n = i18n;
  678. this.config = config;
  679. if (Array.isArray(config.nzFooter)) {
  680. this.buttonsFooter = true;
  681. this.buttons = config.nzFooter.map(mergeDefaultOption);
  682. }
  683. this.i18n.localeChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
  684. this.locale = this.i18n.getLocaleData('Modal');
  685. });
  686. }
  687. onCancel() {
  688. this.cancelTriggered.emit();
  689. }
  690. onOk() {
  691. this.okTriggered.emit();
  692. }
  693. /**
  694. * Returns the value of the specified key.
  695. * If it is a function, run and return the return value of the function.
  696. */
  697. getButtonCallableProp(options, prop) {
  698. const value = options[prop];
  699. const componentInstance = this.modalRef.getContentComponent();
  700. return typeof value === 'function' ? value.apply(options, componentInstance && [componentInstance]) : value;
  701. }
  702. /**
  703. * Run function based on the type and set its `loading` prop if needed.
  704. */
  705. onButtonClick(options) {
  706. const loading = this.getButtonCallableProp(options, 'loading');
  707. if (!loading) {
  708. const result = this.getButtonCallableProp(options, 'onClick');
  709. if (options.autoLoading && isPromise(result)) {
  710. options.loading = true;
  711. result
  712. .then(() => (options.loading = false))
  713. .catch(e => {
  714. options.loading = false;
  715. throw e;
  716. });
  717. }
  718. }
  719. }
  720. ngOnDestroy() {
  721. this.destroy$.next();
  722. this.destroy$.complete();
  723. }
  724. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalFooterComponent, deps: [{ token: i1$1.NzI18nService }, { token: ModalOptions }], target: i0.ɵɵFactoryTarget.Component });
  725. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzModalFooterComponent, isStandalone: true, selector: "div[nz-modal-footer]", inputs: { modalRef: "modalRef" }, outputs: { cancelTriggered: "cancelTriggered", okTriggered: "okTriggered" }, host: { classAttribute: "ant-modal-footer" }, exportAs: ["NzModalFooterBuiltin"], ngImport: i0, template: `
  726. @if (config.nzFooter) {
  727. <ng-container
  728. *nzStringTemplateOutlet="config.nzFooter; context: { $implicit: config.nzData, modalRef: modalRef }"
  729. >
  730. @if (buttonsFooter) {
  731. @for (button of buttons; track button) {
  732. <button
  733. nz-button
  734. (click)="onButtonClick(button)"
  735. [hidden]="!getButtonCallableProp(button, 'show')"
  736. [nzLoading]="getButtonCallableProp(button, 'loading')"
  737. [disabled]="getButtonCallableProp(button, 'disabled')"
  738. [nzType]="button.type!"
  739. [nzDanger]="button.danger"
  740. [nzShape]="button.shape!"
  741. [nzSize]="button.size!"
  742. [nzGhost]="button.ghost!"
  743. >
  744. {{ button.label }}
  745. </button>
  746. }
  747. } @else {
  748. <div [innerHTML]="config.nzFooter"></div>
  749. }
  750. </ng-container>
  751. } @else {
  752. @if (config.nzCancelText !== null) {
  753. <button
  754. [attr.cdkFocusInitial]="config.nzAutofocus === 'cancel' || null"
  755. nz-button
  756. (click)="onCancel()"
  757. [nzLoading]="config.nzCancelLoading"
  758. [disabled]="config.nzCancelDisabled"
  759. >
  760. {{ config.nzCancelText || locale.cancelText }}
  761. </button>
  762. }
  763. @if (config.nzOkText !== null) {
  764. <button
  765. [attr.cdkFocusInitial]="config.nzAutofocus === 'ok' || null"
  766. nz-button
  767. [nzType]="config.nzOkType!"
  768. [nzDanger]="config.nzOkDanger"
  769. (click)="onOk()"
  770. [nzLoading]="config.nzOkLoading"
  771. [disabled]="config.nzOkDisabled"
  772. >
  773. {{ config.nzOkText || locale.okText }}
  774. </button>
  775. }
  776. }
  777. `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "ngmodule", type: NzButtonModule }, { kind: "component", type: i6.NzButtonComponent, selector: "button[nz-button], a[nz-button]", inputs: ["nzBlock", "nzGhost", "nzSearch", "nzLoading", "nzDanger", "disabled", "tabIndex", "nzType", "nzShape", "nzSize"], exportAs: ["nzButton"] }, { kind: "directive", type: i7.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { kind: "directive", type: i8.NzWaveDirective, selector: "[nz-wave],button[nz-button]:not([nzType=\"link\"]):not([nzType=\"text\"])", inputs: ["nzWaveExtraNode"], exportAs: ["nzWave"] }], changeDetection: i0.ChangeDetectionStrategy.Default });
  778. }
  779. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalFooterComponent, decorators: [{
  780. type: Component,
  781. args: [{
  782. selector: 'div[nz-modal-footer]',
  783. exportAs: 'NzModalFooterBuiltin',
  784. template: `
  785. @if (config.nzFooter) {
  786. <ng-container
  787. *nzStringTemplateOutlet="config.nzFooter; context: { $implicit: config.nzData, modalRef: modalRef }"
  788. >
  789. @if (buttonsFooter) {
  790. @for (button of buttons; track button) {
  791. <button
  792. nz-button
  793. (click)="onButtonClick(button)"
  794. [hidden]="!getButtonCallableProp(button, 'show')"
  795. [nzLoading]="getButtonCallableProp(button, 'loading')"
  796. [disabled]="getButtonCallableProp(button, 'disabled')"
  797. [nzType]="button.type!"
  798. [nzDanger]="button.danger"
  799. [nzShape]="button.shape!"
  800. [nzSize]="button.size!"
  801. [nzGhost]="button.ghost!"
  802. >
  803. {{ button.label }}
  804. </button>
  805. }
  806. } @else {
  807. <div [innerHTML]="config.nzFooter"></div>
  808. }
  809. </ng-container>
  810. } @else {
  811. @if (config.nzCancelText !== null) {
  812. <button
  813. [attr.cdkFocusInitial]="config.nzAutofocus === 'cancel' || null"
  814. nz-button
  815. (click)="onCancel()"
  816. [nzLoading]="config.nzCancelLoading"
  817. [disabled]="config.nzCancelDisabled"
  818. >
  819. {{ config.nzCancelText || locale.cancelText }}
  820. </button>
  821. }
  822. @if (config.nzOkText !== null) {
  823. <button
  824. [attr.cdkFocusInitial]="config.nzAutofocus === 'ok' || null"
  825. nz-button
  826. [nzType]="config.nzOkType!"
  827. [nzDanger]="config.nzOkDanger"
  828. (click)="onOk()"
  829. [nzLoading]="config.nzOkLoading"
  830. [disabled]="config.nzOkDisabled"
  831. >
  832. {{ config.nzOkText || locale.okText }}
  833. </button>
  834. }
  835. }
  836. `,
  837. host: {
  838. class: 'ant-modal-footer'
  839. },
  840. changeDetection: ChangeDetectionStrategy.Default,
  841. imports: [NzOutletModule, NzButtonModule]
  842. }]
  843. }], ctorParameters: () => [{ type: i1$1.NzI18nService }, { type: ModalOptions }], propDecorators: { cancelTriggered: [{
  844. type: Output
  845. }], okTriggered: [{
  846. type: Output
  847. }], modalRef: [{
  848. type: Input
  849. }] } });
  850. function mergeDefaultOption(options) {
  851. return {
  852. type: null,
  853. size: 'default',
  854. autoLoading: true,
  855. show: true,
  856. loading: false,
  857. disabled: false,
  858. ...options
  859. };
  860. }
  861. /**
  862. * Use of this source code is governed by an MIT-style license that can be
  863. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  864. */
  865. class NzModalTitleComponent {
  866. config;
  867. constructor(config) {
  868. this.config = config;
  869. }
  870. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalTitleComponent, deps: [{ token: ModalOptions }], target: i0.ɵɵFactoryTarget.Component });
  871. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.2", type: NzModalTitleComponent, isStandalone: true, selector: "div[nz-modal-title]", host: { classAttribute: "ant-modal-header" }, exportAs: ["NzModalTitleBuiltin"], ngImport: i0, template: `
  872. <div class="ant-modal-title">
  873. <ng-container *nzStringTemplateOutlet="config.nzTitle">
  874. <div [innerHTML]="config.nzTitle"></div>
  875. </ng-container>
  876. </div>
  877. `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
  878. }
  879. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalTitleComponent, decorators: [{
  880. type: Component,
  881. args: [{
  882. selector: 'div[nz-modal-title]',
  883. exportAs: 'NzModalTitleBuiltin',
  884. template: `
  885. <div class="ant-modal-title">
  886. <ng-container *nzStringTemplateOutlet="config.nzTitle">
  887. <div [innerHTML]="config.nzTitle"></div>
  888. </ng-container>
  889. </div>
  890. `,
  891. host: {
  892. class: 'ant-modal-header'
  893. },
  894. changeDetection: ChangeDetectionStrategy.OnPush,
  895. imports: [NzOutletModule]
  896. }]
  897. }], ctorParameters: () => [{ type: ModalOptions }] });
  898. /**
  899. * Use of this source code is governed by an MIT-style license that can be
  900. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  901. */
  902. class NzModalContainerComponent extends BaseModalContainerComponent {
  903. set _portalOutlet(portalOutlet) {
  904. this.portalOutlet = portalOutlet;
  905. }
  906. set _modalElementRef(elementRef) {
  907. this.modalElementRef = elementRef;
  908. }
  909. ngOnInit() {
  910. this.setupMouseListeners(this.modalElementRef);
  911. }
  912. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalContainerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
  913. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzModalContainerComponent, isStandalone: true, selector: "nz-modal-container", host: { attributes: { "tabindex": "-1", "role": "dialog" }, listeners: { "@modalContainer.start": "onAnimationStart($event)", "@modalContainer.done": "onAnimationDone($event)", "click": "onContainerClick($event)" }, properties: { "class": "config.nzWrapClassName ? \"ant-modal-wrap \" + config.nzWrapClassName : \"ant-modal-wrap\"", "class.ant-modal-wrap-rtl": "dir === 'rtl'", "class.ant-modal-centered": "config.nzCentered", "style.zIndex": "config.nzZIndex", "@.disabled": "config.nzNoAnimation", "@modalContainer": "state" } }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }, { propertyName: "_modalElementRef", first: true, predicate: ["modalElement"], descendants: true, static: true }], exportAs: ["nzModalContainer"], usesInheritance: true, hostDirectives: [{ directive: i1.CdkScrollable }], ngImport: i0, template: `
  914. <div
  915. #modalElement
  916. cdkDrag
  917. cdkDragBoundary=".cdk-overlay-container"
  918. [cdkDragDisabled]="!config.nzDraggable"
  919. role="document"
  920. class="ant-modal"
  921. [class]="config.nzClassName!"
  922. [style]="config.nzStyle!"
  923. [style.width]="config?.nzWidth! | nzToCssUnit"
  924. >
  925. <div class="ant-modal-content">
  926. @if (config.nzClosable) {
  927. <button nz-modal-close (click)="onCloseClick()"></button>
  928. }
  929. @if (config.nzTitle) {
  930. <div nz-modal-title cdkDragHandle [style.cursor]="config.nzDraggable ? 'move' : 'auto'"></div>
  931. }
  932. <div class="ant-modal-body" [style]="config.nzBodyStyle!">
  933. <ng-template cdkPortalOutlet />
  934. @if (isStringContent) {
  935. <div [innerHTML]="config.nzContent"></div>
  936. }
  937. </div>
  938. @if (config.nzFooter !== null) {
  939. <div
  940. nz-modal-footer
  941. [modalRef]="modalRef"
  942. (cancelTriggered)="onCloseClick()"
  943. (okTriggered)="onOkClick()"
  944. ></div>
  945. }
  946. </div>
  947. </div>
  948. `, isInline: true, dependencies: [{ kind: "component", type: NzModalCloseComponent, selector: "button[nz-modal-close]", exportAs: ["NzModalCloseBuiltin"] }, { kind: "component", type: NzModalTitleComponent, selector: "div[nz-modal-title]", exportAs: ["NzModalTitleBuiltin"] }, { kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i5.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "component", type: NzModalFooterComponent, selector: "div[nz-modal-footer]", inputs: ["modalRef"], outputs: ["cancelTriggered", "okTriggered"], exportAs: ["NzModalFooterBuiltin"] }, { kind: "ngmodule", type: NzPipesModule }, { kind: "pipe", type: i2$1.NzToCssUnitPipe, name: "nzToCssUnit" }, { kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }], animations: [nzModalAnimations.modalContainer], changeDetection: i0.ChangeDetectionStrategy.Default });
  949. }
  950. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalContainerComponent, decorators: [{
  951. type: Component,
  952. args: [{
  953. selector: 'nz-modal-container',
  954. exportAs: 'nzModalContainer',
  955. hostDirectives: [CdkScrollable],
  956. template: `
  957. <div
  958. #modalElement
  959. cdkDrag
  960. cdkDragBoundary=".cdk-overlay-container"
  961. [cdkDragDisabled]="!config.nzDraggable"
  962. role="document"
  963. class="ant-modal"
  964. [class]="config.nzClassName!"
  965. [style]="config.nzStyle!"
  966. [style.width]="config?.nzWidth! | nzToCssUnit"
  967. >
  968. <div class="ant-modal-content">
  969. @if (config.nzClosable) {
  970. <button nz-modal-close (click)="onCloseClick()"></button>
  971. }
  972. @if (config.nzTitle) {
  973. <div nz-modal-title cdkDragHandle [style.cursor]="config.nzDraggable ? 'move' : 'auto'"></div>
  974. }
  975. <div class="ant-modal-body" [style]="config.nzBodyStyle!">
  976. <ng-template cdkPortalOutlet />
  977. @if (isStringContent) {
  978. <div [innerHTML]="config.nzContent"></div>
  979. }
  980. </div>
  981. @if (config.nzFooter !== null) {
  982. <div
  983. nz-modal-footer
  984. [modalRef]="modalRef"
  985. (cancelTriggered)="onCloseClick()"
  986. (okTriggered)="onOkClick()"
  987. ></div>
  988. }
  989. </div>
  990. </div>
  991. `,
  992. animations: [nzModalAnimations.modalContainer],
  993. // Using OnPush for modal caused footer can not to detect changes. we can fix it when 8.x.
  994. changeDetection: ChangeDetectionStrategy.Default,
  995. host: {
  996. tabindex: '-1',
  997. role: 'dialog',
  998. '[class]': 'config.nzWrapClassName ? "ant-modal-wrap " + config.nzWrapClassName : "ant-modal-wrap"',
  999. '[class.ant-modal-wrap-rtl]': `dir === 'rtl'`,
  1000. '[class.ant-modal-centered]': 'config.nzCentered',
  1001. '[style.zIndex]': 'config.nzZIndex',
  1002. '[@.disabled]': 'config.nzNoAnimation',
  1003. '[@modalContainer]': 'state',
  1004. '(@modalContainer.start)': 'onAnimationStart($event)',
  1005. '(@modalContainer.done)': 'onAnimationDone($event)',
  1006. '(click)': 'onContainerClick($event)'
  1007. },
  1008. imports: [
  1009. NzModalCloseComponent,
  1010. NzModalTitleComponent,
  1011. PortalModule,
  1012. NzModalFooterComponent,
  1013. NzPipesModule,
  1014. CdkDrag,
  1015. CdkDragHandle
  1016. ]
  1017. }]
  1018. }], propDecorators: { _portalOutlet: [{
  1019. type: ViewChild,
  1020. args: [CdkPortalOutlet, { static: true }]
  1021. }], _modalElementRef: [{
  1022. type: ViewChild,
  1023. args: ['modalElement', { static: true }]
  1024. }] } });
  1025. /**
  1026. * Use of this source code is governed by an MIT-style license that can be
  1027. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1028. */
  1029. class NzModalRef {
  1030. overlayRef;
  1031. config;
  1032. containerInstance;
  1033. componentInstance = null;
  1034. componentRef = null;
  1035. result;
  1036. state = 0 /* NzModalState.OPEN */;
  1037. afterClose = new Subject();
  1038. afterOpen = new Subject();
  1039. closeTimeout;
  1040. destroy$ = new Subject();
  1041. constructor(overlayRef, config, containerInstance) {
  1042. this.overlayRef = overlayRef;
  1043. this.config = config;
  1044. this.containerInstance = containerInstance;
  1045. containerInstance.animationStateChanged
  1046. .pipe(filter(event => event.phaseName === 'done' && event.toState === 'enter'), take(1))
  1047. .subscribe(() => {
  1048. this.afterOpen.next();
  1049. this.afterOpen.complete();
  1050. if (config.nzAfterOpen instanceof EventEmitter) {
  1051. config.nzAfterOpen.emit();
  1052. }
  1053. });
  1054. containerInstance.animationStateChanged
  1055. .pipe(filter(event => event.phaseName === 'done' && event.toState === 'exit'), take(1))
  1056. .subscribe(() => {
  1057. clearTimeout(this.closeTimeout);
  1058. this._finishDialogClose();
  1059. });
  1060. containerInstance.containerClick.pipe(takeUntil(this.destroy$)).subscribe(() => {
  1061. const cancelable = !this.config.nzCancelLoading && !this.config.nzOkLoading;
  1062. if (cancelable) {
  1063. this.trigger("cancel" /* NzTriggerAction.CANCEL */);
  1064. }
  1065. });
  1066. overlayRef
  1067. .keydownEvents()
  1068. .pipe(filter(event => this.config.nzKeyboard &&
  1069. !this.config.nzCancelLoading &&
  1070. !this.config.nzOkLoading &&
  1071. event.keyCode === ESCAPE &&
  1072. !hasModifierKey(event)))
  1073. .subscribe(event => {
  1074. event.preventDefault();
  1075. this.trigger("cancel" /* NzTriggerAction.CANCEL */);
  1076. });
  1077. containerInstance.cancelTriggered
  1078. .pipe(takeUntil(this.destroy$))
  1079. .subscribe(() => this.trigger("cancel" /* NzTriggerAction.CANCEL */));
  1080. containerInstance.okTriggered.pipe(takeUntil(this.destroy$)).subscribe(() => this.trigger("ok" /* NzTriggerAction.OK */));
  1081. overlayRef.detachments().subscribe(() => {
  1082. this.afterClose.next(this.result);
  1083. this.afterClose.complete();
  1084. if (config.nzAfterClose instanceof EventEmitter) {
  1085. config.nzAfterClose.emit(this.result);
  1086. }
  1087. this.componentInstance = null;
  1088. this.componentRef = null;
  1089. this.overlayRef.dispose();
  1090. });
  1091. }
  1092. getContentComponent() {
  1093. return this.componentInstance;
  1094. }
  1095. getContentComponentRef() {
  1096. return this.componentRef;
  1097. }
  1098. getElement() {
  1099. return this.containerInstance.getNativeElement();
  1100. }
  1101. destroy(result) {
  1102. this.close(result);
  1103. }
  1104. triggerOk() {
  1105. return this.trigger("ok" /* NzTriggerAction.OK */);
  1106. }
  1107. triggerCancel() {
  1108. return this.trigger("cancel" /* NzTriggerAction.CANCEL */);
  1109. }
  1110. close(result) {
  1111. if (this.state !== 0 /* NzModalState.OPEN */) {
  1112. return;
  1113. }
  1114. this.result = result;
  1115. this.containerInstance.animationStateChanged
  1116. .pipe(filter(event => event.phaseName === 'start'), take(1))
  1117. .subscribe(event => {
  1118. this.overlayRef.detachBackdrop();
  1119. this.closeTimeout = setTimeout(() => {
  1120. this._finishDialogClose();
  1121. }, event.totalTime + 100);
  1122. });
  1123. this.containerInstance.startExitAnimation();
  1124. this.state = 1 /* NzModalState.CLOSING */;
  1125. }
  1126. updateConfig(config) {
  1127. Object.assign(this.config, config);
  1128. this.containerInstance.bindBackdropStyle();
  1129. this.containerInstance.cdr.markForCheck();
  1130. }
  1131. getState() {
  1132. return this.state;
  1133. }
  1134. getConfig() {
  1135. return this.config;
  1136. }
  1137. getBackdropElement() {
  1138. return this.overlayRef.backdropElement;
  1139. }
  1140. async trigger(action) {
  1141. if (this.state === 1 /* NzModalState.CLOSING */) {
  1142. return;
  1143. }
  1144. const trigger = { ok: this.config.nzOnOk, cancel: this.config.nzOnCancel }[action];
  1145. const loadingKey = { ok: 'nzOkLoading', cancel: 'nzCancelLoading' }[action];
  1146. const loading = this.config[loadingKey];
  1147. if (loading) {
  1148. return;
  1149. }
  1150. if (trigger instanceof EventEmitter) {
  1151. trigger.emit(this.getContentComponent());
  1152. }
  1153. else if (typeof trigger === 'function') {
  1154. const result = trigger(this.getContentComponent());
  1155. if (isPromise(result)) {
  1156. this.config[loadingKey] = true;
  1157. let doClose = false;
  1158. try {
  1159. doClose = (await result);
  1160. }
  1161. finally {
  1162. this.config[loadingKey] = false;
  1163. this.closeWhitResult(doClose);
  1164. }
  1165. }
  1166. else {
  1167. this.closeWhitResult(result);
  1168. }
  1169. }
  1170. }
  1171. closeWhitResult(result) {
  1172. if (result !== false) {
  1173. this.close(result);
  1174. }
  1175. }
  1176. _finishDialogClose() {
  1177. this.state = 2 /* NzModalState.CLOSED */;
  1178. this.overlayRef.dispose();
  1179. this.destroy$.next();
  1180. }
  1181. }
  1182. class NzModalService {
  1183. overlay;
  1184. injector;
  1185. nzConfigService;
  1186. directionality;
  1187. openModalsAtThisLevel = [];
  1188. afterAllClosedAtThisLevel = new Subject();
  1189. get openModals() {
  1190. return this.parentModal ? this.parentModal.openModals : this.openModalsAtThisLevel;
  1191. }
  1192. get _afterAllClosed() {
  1193. const parent = this.parentModal;
  1194. return parent ? parent._afterAllClosed : this.afterAllClosedAtThisLevel;
  1195. }
  1196. afterAllClose = defer(() => this.openModals.length ? this._afterAllClosed : this._afterAllClosed.pipe(startWith(undefined)));
  1197. parentModal = inject(NzModalService, { skipSelf: true, optional: true });
  1198. constructor(overlay, injector, nzConfigService, directionality) {
  1199. this.overlay = overlay;
  1200. this.injector = injector;
  1201. this.nzConfigService = nzConfigService;
  1202. this.directionality = directionality;
  1203. }
  1204. create(config) {
  1205. return this.open(config.nzContent, config);
  1206. }
  1207. closeAll() {
  1208. this.closeModals(this.openModals);
  1209. }
  1210. confirm(options = {}, confirmType = 'confirm') {
  1211. if ('nzFooter' in options) {
  1212. warn(`The Confirm-Modal doesn't support "nzFooter", this property will be ignored.`);
  1213. }
  1214. if (!('nzWidth' in options)) {
  1215. options.nzWidth = 416;
  1216. }
  1217. if (!('nzMaskClosable' in options)) {
  1218. options.nzMaskClosable = false;
  1219. }
  1220. options.nzModalType = 'confirm';
  1221. options.nzClassName = `ant-modal-confirm ant-modal-confirm-${confirmType} ${options.nzClassName || ''}`;
  1222. return this.create(options);
  1223. }
  1224. info(options = {}) {
  1225. return this.confirmFactory(options, 'info');
  1226. }
  1227. success(options = {}) {
  1228. return this.confirmFactory(options, 'success');
  1229. }
  1230. error(options = {}) {
  1231. return this.confirmFactory(options, 'error');
  1232. }
  1233. warning(options = {}) {
  1234. return this.confirmFactory(options, 'warning');
  1235. }
  1236. open(componentOrTemplateRef, config) {
  1237. const configMerged = applyConfigDefaults(config || {}, new ModalOptions());
  1238. const overlayRef = this.createOverlay(configMerged);
  1239. const modalContainer = this.attachModalContainer(overlayRef, configMerged);
  1240. const modalRef = this.attachModalContent(componentOrTemplateRef, modalContainer, overlayRef, configMerged);
  1241. modalContainer.modalRef = modalRef;
  1242. overlayZIndexSetter(overlayRef, config?.nzZIndex);
  1243. this.openModals.push(modalRef);
  1244. modalRef.afterClose.subscribe(() => this.removeOpenModal(modalRef));
  1245. return modalRef;
  1246. }
  1247. removeOpenModal(modalRef) {
  1248. const index = this.openModals.indexOf(modalRef);
  1249. if (index > -1) {
  1250. this.openModals.splice(index, 1);
  1251. if (!this.openModals.length) {
  1252. this._afterAllClosed.next();
  1253. }
  1254. }
  1255. }
  1256. closeModals(dialogs) {
  1257. let i = dialogs.length;
  1258. while (i--) {
  1259. dialogs[i].close();
  1260. if (!this.openModals.length) {
  1261. this._afterAllClosed.next();
  1262. }
  1263. }
  1264. }
  1265. createOverlay(config) {
  1266. const globalConfig = this.nzConfigService.getConfigForComponent(NZ_CONFIG_MODULE_NAME) || {};
  1267. const overlayConfig = new OverlayConfig({
  1268. hasBackdrop: true,
  1269. scrollStrategy: this.overlay.scrollStrategies.block(),
  1270. backdropClass: getValueWithConfig(config.nzMask, globalConfig.nzMask, true) ? MODAL_MASK_CLASS_NAME : '',
  1271. positionStrategy: this.overlay.position().global(),
  1272. disposeOnNavigation: getValueWithConfig(config.nzCloseOnNavigation, globalConfig.nzCloseOnNavigation, true),
  1273. direction: getValueWithConfig(config.nzDirection, globalConfig.nzDirection, this.directionality.value)
  1274. });
  1275. return this.overlay.create(overlayConfig);
  1276. }
  1277. attachModalContainer(overlayRef, config) {
  1278. const userInjector = config && config.nzViewContainerRef && config.nzViewContainerRef.injector;
  1279. const injector = Injector.create({
  1280. parent: userInjector || this.injector,
  1281. providers: [
  1282. { provide: OverlayRef, useValue: overlayRef },
  1283. { provide: ModalOptions, useValue: config }
  1284. ]
  1285. });
  1286. const ContainerComponent = config.nzModalType === 'confirm'
  1287. ? // If the mode is `confirm`, use `NzModalConfirmContainerComponent`
  1288. NzModalConfirmContainerComponent
  1289. : // If the mode is not `confirm`, use `NzModalContainerComponent`
  1290. NzModalContainerComponent;
  1291. const containerPortal = new ComponentPortal(ContainerComponent, config.nzViewContainerRef, injector);
  1292. const containerRef = overlayRef.attach(containerPortal);
  1293. return containerRef.instance;
  1294. }
  1295. attachModalContent(componentOrTemplateRef, modalContainer, overlayRef, config) {
  1296. const modalRef = new NzModalRef(overlayRef, config, modalContainer);
  1297. if (componentOrTemplateRef instanceof TemplateRef) {
  1298. modalContainer.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null, {
  1299. $implicit: config.nzData,
  1300. modalRef
  1301. }));
  1302. }
  1303. else if (isNotNil(componentOrTemplateRef) && typeof componentOrTemplateRef !== 'string') {
  1304. const injector = this.createInjector(modalRef, config);
  1305. const contentRef = modalContainer.attachComponentPortal(new ComponentPortal(componentOrTemplateRef, config.nzViewContainerRef, injector));
  1306. modalRef.componentRef = contentRef;
  1307. modalRef.componentInstance = contentRef.instance;
  1308. }
  1309. else {
  1310. modalContainer.attachStringContent();
  1311. }
  1312. return modalRef;
  1313. }
  1314. createInjector(modalRef, config) {
  1315. const userInjector = config && config.nzViewContainerRef && config.nzViewContainerRef.injector;
  1316. return Injector.create({
  1317. parent: userInjector || this.injector,
  1318. providers: [
  1319. { provide: NzModalRef, useValue: modalRef },
  1320. { provide: NZ_MODAL_DATA, useValue: config.nzData }
  1321. ]
  1322. });
  1323. }
  1324. confirmFactory(options = {}, confirmType) {
  1325. const iconMap = {
  1326. info: 'info-circle',
  1327. success: 'check-circle',
  1328. error: 'close-circle',
  1329. warning: 'exclamation-circle'
  1330. };
  1331. if (!('nzIconType' in options)) {
  1332. options.nzIconType = iconMap[confirmType];
  1333. }
  1334. if (!('nzCancelText' in options)) {
  1335. // Remove the Cancel button if the user not specify a Cancel button
  1336. options.nzCancelText = null;
  1337. }
  1338. return this.confirm(options, confirmType);
  1339. }
  1340. ngOnDestroy() {
  1341. this.closeModals(this.openModalsAtThisLevel);
  1342. this.afterAllClosedAtThisLevel.complete();
  1343. }
  1344. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalService, deps: [{ token: i1.Overlay }, { token: i0.Injector }, { token: i2$2.NzConfigService }, { token: i3$1.Directionality }], target: i0.ɵɵFactoryTarget.Injectable });
  1345. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalService });
  1346. }
  1347. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalService, decorators: [{
  1348. type: Injectable
  1349. }], ctorParameters: () => [{ type: i1.Overlay }, { type: i0.Injector }, { type: i2$2.NzConfigService }, { type: i3$1.Directionality }] });
  1350. /**
  1351. * Use of this source code is governed by an MIT-style license that can be
  1352. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1353. */
  1354. class NzModalContentDirective {
  1355. templateRef;
  1356. constructor(templateRef) {
  1357. this.templateRef = templateRef;
  1358. }
  1359. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalContentDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
  1360. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: NzModalContentDirective, isStandalone: true, selector: "[nzModalContent]", exportAs: ["nzModalContent"], ngImport: i0 });
  1361. }
  1362. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalContentDirective, decorators: [{
  1363. type: Directive,
  1364. args: [{
  1365. selector: '[nzModalContent]',
  1366. exportAs: 'nzModalContent'
  1367. }]
  1368. }], ctorParameters: () => [{ type: i0.TemplateRef }] });
  1369. /**
  1370. * Use of this source code is governed by an MIT-style license that can be
  1371. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1372. */
  1373. class NzModalFooterDirective {
  1374. templateRef;
  1375. nzModalRef = inject(NzModalRef, { optional: true });
  1376. constructor(templateRef) {
  1377. this.templateRef = templateRef;
  1378. if (this.nzModalRef) {
  1379. this.nzModalRef.updateConfig({
  1380. nzFooter: this.templateRef
  1381. });
  1382. }
  1383. }
  1384. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalFooterDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
  1385. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: NzModalFooterDirective, isStandalone: true, selector: "[nzModalFooter]", exportAs: ["nzModalFooter"], ngImport: i0 });
  1386. }
  1387. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalFooterDirective, decorators: [{
  1388. type: Directive,
  1389. args: [{
  1390. selector: '[nzModalFooter]',
  1391. exportAs: 'nzModalFooter'
  1392. }]
  1393. }], ctorParameters: () => [{ type: i0.TemplateRef }] });
  1394. /**
  1395. * Use of this source code is governed by an MIT-style license that can be
  1396. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1397. */
  1398. class NzModalTitleDirective {
  1399. templateRef;
  1400. nzModalRef = inject(NzModalRef, { optional: true });
  1401. constructor(templateRef) {
  1402. this.templateRef = templateRef;
  1403. if (this.nzModalRef) {
  1404. this.nzModalRef.updateConfig({
  1405. nzTitle: this.templateRef
  1406. });
  1407. }
  1408. }
  1409. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalTitleDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
  1410. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.2", type: NzModalTitleDirective, isStandalone: true, selector: "[nzModalTitle]", exportAs: ["nzModalTitle"], ngImport: i0 });
  1411. }
  1412. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalTitleDirective, decorators: [{
  1413. type: Directive,
  1414. args: [{
  1415. selector: '[nzModalTitle]',
  1416. exportAs: 'nzModalTitle'
  1417. }]
  1418. }], ctorParameters: () => [{ type: i0.TemplateRef }] });
  1419. /**
  1420. * Use of this source code is governed by an MIT-style license that can be
  1421. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1422. */
  1423. class NzModalComponent {
  1424. cdr;
  1425. modal;
  1426. viewContainerRef;
  1427. nzMask;
  1428. nzMaskClosable;
  1429. nzCloseOnNavigation;
  1430. nzVisible = false;
  1431. nzClosable = true;
  1432. nzOkLoading = false;
  1433. nzOkDisabled = false;
  1434. nzCancelDisabled = false;
  1435. nzCancelLoading = false;
  1436. nzKeyboard = true;
  1437. nzNoAnimation = false;
  1438. nzCentered = false;
  1439. nzDraggable = false;
  1440. nzContent;
  1441. nzFooter;
  1442. nzZIndex = 1000;
  1443. nzWidth = 520;
  1444. nzWrapClassName;
  1445. nzClassName;
  1446. nzStyle;
  1447. nzTitle;
  1448. nzCloseIcon = 'close';
  1449. nzMaskStyle;
  1450. nzBodyStyle;
  1451. nzOkText;
  1452. nzCancelText;
  1453. nzOkType = 'primary';
  1454. nzOkDanger = false;
  1455. nzIconType = 'question-circle'; // Confirm Modal ONLY
  1456. nzModalType = 'default';
  1457. nzAutofocus = 'auto';
  1458. // TODO(@hsuanxyz) Input will not be supported
  1459. nzOnOk = new EventEmitter();
  1460. // TODO(@hsuanxyz) Input will not be supported
  1461. nzOnCancel = new EventEmitter();
  1462. nzAfterOpen = new EventEmitter();
  1463. nzAfterClose = new EventEmitter();
  1464. nzVisibleChange = new EventEmitter();
  1465. set modalTitle(value) {
  1466. if (value) {
  1467. this.setTitleWithTemplate(value);
  1468. }
  1469. }
  1470. contentFromContentChild;
  1471. set modalFooter(value) {
  1472. if (value) {
  1473. this.setFooterWithTemplate(value);
  1474. }
  1475. }
  1476. modalRef = null;
  1477. destroy$ = new Subject();
  1478. get afterOpen() {
  1479. // Observable alias for nzAfterOpen
  1480. return this.nzAfterOpen.asObservable();
  1481. }
  1482. get afterClose() {
  1483. // Observable alias for nzAfterClose
  1484. return this.nzAfterClose.asObservable();
  1485. }
  1486. constructor(cdr, modal, viewContainerRef) {
  1487. this.cdr = cdr;
  1488. this.modal = modal;
  1489. this.viewContainerRef = viewContainerRef;
  1490. }
  1491. open() {
  1492. if (!this.nzVisible) {
  1493. this.nzVisible = true;
  1494. this.nzVisibleChange.emit(true);
  1495. }
  1496. if (!this.modalRef) {
  1497. const config = this.getConfig();
  1498. this.modalRef = this.modal.create(config);
  1499. // When the modal is implicitly closed (e.g. closeAll) the nzVisible needs to be set to the correct value and emit.
  1500. this.modalRef.afterClose
  1501. .asObservable()
  1502. .pipe(takeUntil(this.destroy$))
  1503. .subscribe(() => {
  1504. this.close();
  1505. });
  1506. }
  1507. }
  1508. close(result) {
  1509. if (this.nzVisible) {
  1510. this.nzVisible = false;
  1511. this.nzVisibleChange.emit(false);
  1512. }
  1513. if (this.modalRef) {
  1514. this.modalRef.close(result);
  1515. this.modalRef = null;
  1516. }
  1517. }
  1518. destroy(result) {
  1519. this.close(result);
  1520. }
  1521. triggerOk() {
  1522. this.modalRef?.triggerOk();
  1523. }
  1524. triggerCancel() {
  1525. this.modalRef?.triggerCancel();
  1526. }
  1527. getContentComponent() {
  1528. return this.modalRef?.getContentComponent();
  1529. }
  1530. getElement() {
  1531. return this.modalRef?.getElement();
  1532. }
  1533. getModalRef() {
  1534. return this.modalRef;
  1535. }
  1536. setTitleWithTemplate(templateRef) {
  1537. this.nzTitle = templateRef;
  1538. if (this.modalRef) {
  1539. // If modalRef already created, set the title in next tick
  1540. Promise.resolve().then(() => {
  1541. this.modalRef.updateConfig({
  1542. nzTitle: this.nzTitle
  1543. });
  1544. });
  1545. }
  1546. }
  1547. setFooterWithTemplate(templateRef) {
  1548. this.nzFooter = templateRef;
  1549. if (this.modalRef) {
  1550. // If modalRef already created, set the footer in next tick
  1551. Promise.resolve().then(() => {
  1552. this.modalRef.updateConfig({
  1553. nzFooter: this.nzFooter
  1554. });
  1555. });
  1556. }
  1557. this.cdr.markForCheck();
  1558. }
  1559. getConfig() {
  1560. const componentConfig = getConfigFromComponent(this);
  1561. componentConfig.nzViewContainerRef = this.viewContainerRef;
  1562. componentConfig.nzContent = this.nzContent || this.contentFromContentChild;
  1563. return componentConfig;
  1564. }
  1565. ngOnChanges(changes) {
  1566. const { nzVisible, ...otherChanges } = changes;
  1567. if (Object.keys(otherChanges).length && this.modalRef) {
  1568. this.modalRef.updateConfig(getConfigFromComponent(this));
  1569. }
  1570. if (nzVisible) {
  1571. if (this.nzVisible) {
  1572. this.open();
  1573. }
  1574. else {
  1575. this.close();
  1576. }
  1577. }
  1578. }
  1579. ngOnDestroy() {
  1580. this.modalRef?._finishDialogClose();
  1581. this.destroy$.next();
  1582. this.destroy$.complete();
  1583. }
  1584. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: NzModalService }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
  1585. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.2", type: NzModalComponent, isStandalone: true, selector: "nz-modal", inputs: { nzMask: ["nzMask", "nzMask", booleanAttribute], nzMaskClosable: ["nzMaskClosable", "nzMaskClosable", booleanAttribute], nzCloseOnNavigation: ["nzCloseOnNavigation", "nzCloseOnNavigation", booleanAttribute], nzVisible: ["nzVisible", "nzVisible", booleanAttribute], nzClosable: ["nzClosable", "nzClosable", booleanAttribute], nzOkLoading: ["nzOkLoading", "nzOkLoading", booleanAttribute], nzOkDisabled: ["nzOkDisabled", "nzOkDisabled", booleanAttribute], nzCancelDisabled: ["nzCancelDisabled", "nzCancelDisabled", booleanAttribute], nzCancelLoading: ["nzCancelLoading", "nzCancelLoading", booleanAttribute], nzKeyboard: ["nzKeyboard", "nzKeyboard", booleanAttribute], nzNoAnimation: ["nzNoAnimation", "nzNoAnimation", booleanAttribute], nzCentered: ["nzCentered", "nzCentered", booleanAttribute], nzDraggable: ["nzDraggable", "nzDraggable", booleanAttribute], nzContent: "nzContent", nzFooter: "nzFooter", nzZIndex: ["nzZIndex", "nzZIndex", numberAttribute], nzWidth: "nzWidth", nzWrapClassName: "nzWrapClassName", nzClassName: "nzClassName", nzStyle: "nzStyle", nzTitle: "nzTitle", nzCloseIcon: "nzCloseIcon", nzMaskStyle: "nzMaskStyle", nzBodyStyle: "nzBodyStyle", nzOkText: "nzOkText", nzCancelText: "nzCancelText", nzOkType: "nzOkType", nzOkDanger: ["nzOkDanger", "nzOkDanger", booleanAttribute], nzIconType: "nzIconType", nzModalType: "nzModalType", nzAutofocus: "nzAutofocus", nzOnOk: "nzOnOk", nzOnCancel: "nzOnCancel" }, outputs: { nzOnOk: "nzOnOk", nzOnCancel: "nzOnCancel", nzAfterOpen: "nzAfterOpen", nzAfterClose: "nzAfterClose", nzVisibleChange: "nzVisibleChange" }, queries: [{ propertyName: "modalTitle", first: true, predicate: NzModalTitleDirective, descendants: true, read: TemplateRef, static: true }, { propertyName: "contentFromContentChild", first: true, predicate: NzModalContentDirective, descendants: true, read: TemplateRef, static: true }, { propertyName: "modalFooter", first: true, predicate: NzModalFooterDirective, descendants: true, read: TemplateRef, static: true }], exportAs: ["nzModal"], usesOnChanges: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
  1586. }
  1587. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalComponent, decorators: [{
  1588. type: Component,
  1589. args: [{
  1590. selector: 'nz-modal',
  1591. exportAs: 'nzModal',
  1592. template: ``,
  1593. changeDetection: ChangeDetectionStrategy.OnPush
  1594. }]
  1595. }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: NzModalService }, { type: i0.ViewContainerRef }], propDecorators: { nzMask: [{
  1596. type: Input,
  1597. args: [{ transform: booleanAttribute }]
  1598. }], nzMaskClosable: [{
  1599. type: Input,
  1600. args: [{ transform: booleanAttribute }]
  1601. }], nzCloseOnNavigation: [{
  1602. type: Input,
  1603. args: [{ transform: booleanAttribute }]
  1604. }], nzVisible: [{
  1605. type: Input,
  1606. args: [{ transform: booleanAttribute }]
  1607. }], nzClosable: [{
  1608. type: Input,
  1609. args: [{ transform: booleanAttribute }]
  1610. }], nzOkLoading: [{
  1611. type: Input,
  1612. args: [{ transform: booleanAttribute }]
  1613. }], nzOkDisabled: [{
  1614. type: Input,
  1615. args: [{ transform: booleanAttribute }]
  1616. }], nzCancelDisabled: [{
  1617. type: Input,
  1618. args: [{ transform: booleanAttribute }]
  1619. }], nzCancelLoading: [{
  1620. type: Input,
  1621. args: [{ transform: booleanAttribute }]
  1622. }], nzKeyboard: [{
  1623. type: Input,
  1624. args: [{ transform: booleanAttribute }]
  1625. }], nzNoAnimation: [{
  1626. type: Input,
  1627. args: [{ transform: booleanAttribute }]
  1628. }], nzCentered: [{
  1629. type: Input,
  1630. args: [{ transform: booleanAttribute }]
  1631. }], nzDraggable: [{
  1632. type: Input,
  1633. args: [{ transform: booleanAttribute }]
  1634. }], nzContent: [{
  1635. type: Input
  1636. }], nzFooter: [{
  1637. type: Input
  1638. }], nzZIndex: [{
  1639. type: Input,
  1640. args: [{ transform: numberAttribute }]
  1641. }], nzWidth: [{
  1642. type: Input
  1643. }], nzWrapClassName: [{
  1644. type: Input
  1645. }], nzClassName: [{
  1646. type: Input
  1647. }], nzStyle: [{
  1648. type: Input
  1649. }], nzTitle: [{
  1650. type: Input
  1651. }], nzCloseIcon: [{
  1652. type: Input
  1653. }], nzMaskStyle: [{
  1654. type: Input
  1655. }], nzBodyStyle: [{
  1656. type: Input
  1657. }], nzOkText: [{
  1658. type: Input
  1659. }], nzCancelText: [{
  1660. type: Input
  1661. }], nzOkType: [{
  1662. type: Input
  1663. }], nzOkDanger: [{
  1664. type: Input,
  1665. args: [{ transform: booleanAttribute }]
  1666. }], nzIconType: [{
  1667. type: Input
  1668. }], nzModalType: [{
  1669. type: Input
  1670. }], nzAutofocus: [{
  1671. type: Input
  1672. }], nzOnOk: [{
  1673. type: Input
  1674. }, {
  1675. type: Output
  1676. }], nzOnCancel: [{
  1677. type: Input
  1678. }, {
  1679. type: Output
  1680. }], nzAfterOpen: [{
  1681. type: Output
  1682. }], nzAfterClose: [{
  1683. type: Output
  1684. }], nzVisibleChange: [{
  1685. type: Output
  1686. }], modalTitle: [{
  1687. type: ContentChild,
  1688. args: [NzModalTitleDirective, { static: true, read: TemplateRef }]
  1689. }], contentFromContentChild: [{
  1690. type: ContentChild,
  1691. args: [NzModalContentDirective, { static: true, read: TemplateRef }]
  1692. }], modalFooter: [{
  1693. type: ContentChild,
  1694. args: [NzModalFooterDirective, { static: true, read: TemplateRef }]
  1695. }] } });
  1696. /**
  1697. * Use of this source code is governed by an MIT-style license that can be
  1698. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1699. */
  1700. class NzModalModule {
  1701. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  1702. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzModalModule, imports: [NzModalComponent,
  1703. NzModalFooterDirective,
  1704. NzModalContentDirective,
  1705. NzModalCloseComponent,
  1706. NzModalFooterComponent,
  1707. NzModalTitleComponent,
  1708. NzModalTitleDirective,
  1709. NzModalContainerComponent,
  1710. NzModalConfirmContainerComponent], exports: [NzModalComponent, NzModalFooterDirective, NzModalContentDirective, NzModalTitleDirective] });
  1711. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalModule, providers: [NzModalService], imports: [NzModalCloseComponent,
  1712. NzModalFooterComponent,
  1713. NzModalTitleComponent,
  1714. NzModalContainerComponent,
  1715. NzModalConfirmContainerComponent] });
  1716. }
  1717. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzModalModule, decorators: [{
  1718. type: NgModule,
  1719. args: [{
  1720. imports: [
  1721. NzModalComponent,
  1722. NzModalFooterDirective,
  1723. NzModalContentDirective,
  1724. NzModalCloseComponent,
  1725. NzModalFooterComponent,
  1726. NzModalTitleComponent,
  1727. NzModalTitleDirective,
  1728. NzModalContainerComponent,
  1729. NzModalConfirmContainerComponent
  1730. ],
  1731. exports: [NzModalComponent, NzModalFooterDirective, NzModalContentDirective, NzModalTitleDirective],
  1732. providers: [NzModalService]
  1733. }]
  1734. }] });
  1735. /**
  1736. * Use of this source code is governed by an MIT-style license that can be
  1737. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1738. */
  1739. class NzModalLegacyAPI {
  1740. }
  1741. /**
  1742. * Use of this source code is governed by an MIT-style license that can be
  1743. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1744. */
  1745. /**
  1746. * Generated bundle index. Do not edit.
  1747. */
  1748. export { BaseModalContainerComponent, FADE_CLASS_NAME_MAP, MODAL_MASK_CLASS_NAME, ModalOptions, NZ_CONFIG_MODULE_NAME, NZ_MODAL_DATA, NzModalCloseComponent, NzModalComponent, NzModalConfirmContainerComponent, NzModalContainerComponent, NzModalContentDirective, NzModalFooterComponent, NzModalFooterDirective, NzModalLegacyAPI, NzModalModule, NzModalRef, NzModalService, NzModalTitleComponent, NzModalTitleDirective, ZOOM_CLASS_NAME_MAP, applyConfigDefaults, getConfigFromComponent, getValueWithConfig, nzModalAnimations, throwNzModalContentAlreadyAttachedError };
  1749. //# sourceMappingURL=ng-zorro-antd-modal.mjs.map