UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

1,159 lines (1,127 loc) 113 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/core'), require('ng-zorro-antd/core/logger'), require('ng-zorro-antd/core/util'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/a11y'), require('@angular/common'), require('@angular/platform-browser/animations'), require('ng-zorro-antd/i18n'), require('@angular/animations'), require('@angular/cdk/keycodes'), require('ng-zorro-antd/core/config'), require('ng-zorro-antd/button'), require('ng-zorro-antd/core/no-animation'), require('ng-zorro-antd/core/outlet'), require('ng-zorro-antd/core/pipe'), require('ng-zorro-antd/icon')) : typeof define === 'function' && define.amd ? define('ng-zorro-antd/modal', ['exports', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/core', 'ng-zorro-antd/core/logger', 'ng-zorro-antd/core/util', 'rxjs', 'rxjs/operators', '@angular/cdk/a11y', '@angular/common', '@angular/platform-browser/animations', 'ng-zorro-antd/i18n', '@angular/animations', '@angular/cdk/keycodes', 'ng-zorro-antd/core/config', 'ng-zorro-antd/button', 'ng-zorro-antd/core/no-animation', 'ng-zorro-antd/core/outlet', 'ng-zorro-antd/core/pipe', 'ng-zorro-antd/icon'], factory) : (global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].modal = {}), global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.core, global['ng-zorro-antd'].core.logger, global['ng-zorro-antd'].core.util, global.rxjs, global.rxjs.operators, global.ng.cdk.a11y, global.ng.common, global.ng.platformBrowser.animations, global['ng-zorro-antd'].i18n, global.ng.animations, global.ng.cdk.keycodes, global['ng-zorro-antd'].core.config, global['ng-zorro-antd'].button, global['ng-zorro-antd'].core['no-animation'], global['ng-zorro-antd'].core.outlet, global['ng-zorro-antd'].core.pipe, global['ng-zorro-antd'].icon)); }(this, (function (exports, overlay, portal, core, logger, util, rxjs, operators, a11y, common, animations, i18n, animations$1, keycodes, config, button, noAnimation, outlet, pipe, icon) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __exportStar(m, exports) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result.default = mod; return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); } function __classPrivateFieldSet(receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; } /** * @fileoverview added by tsickle * Generated from: modal-types.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ /** * @record */ function StyleObjectLike() { } /** @type {?} */ var noopFun = (/** * @return {?} */ function () { return void 0; }); var ɵ0 = noopFun; /** * @template T, R */ var /** * @template T, R */ ModalOptions = /** @class */ (function () { function ModalOptions() { this.nzClosable = true; this.nzOkLoading = false; this.nzOkDisabled = false; this.nzCancelDisabled = false; this.nzCancelLoading = false; this.nzNoAnimation = false; this.nzAutofocus = 'auto'; this.nzMask = true; this.nzMaskClosable = true; this.nzKeyboard = true; this.nzZIndex = 1000; this.nzWidth = 520; this.nzCloseIcon = 'close'; this.nzOkType = 'primary'; this.nzModalType = 'default'; this.nzOnCancel = noopFun; this.nzOnOk = noopFun; this.nzCloseOnNavigation = true; // Confirm this.nzIconType = 'question-circle'; } return ModalOptions; }()); if (false) { /** @type {?} */ ModalOptions.prototype.nzClosable; /** @type {?} */ ModalOptions.prototype.nzOkLoading; /** @type {?} */ ModalOptions.prototype.nzOkDisabled; /** @type {?} */ ModalOptions.prototype.nzCancelDisabled; /** @type {?} */ ModalOptions.prototype.nzCancelLoading; /** @type {?} */ ModalOptions.prototype.nzNoAnimation; /** @type {?} */ ModalOptions.prototype.nzAutofocus; /** @type {?} */ ModalOptions.prototype.nzMask; /** @type {?} */ ModalOptions.prototype.nzMaskClosable; /** @type {?} */ ModalOptions.prototype.nzKeyboard; /** @type {?} */ ModalOptions.prototype.nzZIndex; /** @type {?} */ ModalOptions.prototype.nzWidth; /** @type {?} */ ModalOptions.prototype.nzCloseIcon; /** @type {?} */ ModalOptions.prototype.nzOkType; /** @type {?} */ ModalOptions.prototype.nzModalType; /** @type {?} */ ModalOptions.prototype.nzOnCancel; /** @type {?} */ ModalOptions.prototype.nzOnOk; /** @type {?} */ ModalOptions.prototype.nzComponentParams; /** @type {?} */ ModalOptions.prototype.nzMaskStyle; /** @type {?} */ ModalOptions.prototype.nzBodyStyle; /** @type {?} */ ModalOptions.prototype.nzWrapClassName; /** @type {?} */ ModalOptions.prototype.nzClassName; /** @type {?} */ ModalOptions.prototype.nzStyle; /** @type {?} */ ModalOptions.prototype.nzTitle; /** @type {?} */ ModalOptions.prototype.nzFooter; /** @type {?} */ ModalOptions.prototype.nzCancelText; /** @type {?} */ ModalOptions.prototype.nzOkText; /** @type {?} */ ModalOptions.prototype.nzContent; /** @type {?} */ ModalOptions.prototype.nzCloseOnNavigation; /** @type {?} */ ModalOptions.prototype.nzViewContainerRef; /** * Reset the container element. * @deprecated Not supported. * \@breaking-change 10.0.0 * @type {?} */ ModalOptions.prototype.nzGetContainer; /** @type {?} */ ModalOptions.prototype.nzAfterOpen; /** @type {?} */ ModalOptions.prototype.nzAfterClose; /** @type {?} */ ModalOptions.prototype.nzIconType; } /** * @record * @template T */ function ModalButtonOptions() { } if (false) { /** @type {?} */ ModalButtonOptions.prototype.label; /** @type {?|undefined} */ ModalButtonOptions.prototype.type; /** @type {?|undefined} */ ModalButtonOptions.prototype.shape; /** @type {?|undefined} */ ModalButtonOptions.prototype.ghost; /** @type {?|undefined} */ ModalButtonOptions.prototype.size; /** @type {?|undefined} */ ModalButtonOptions.prototype.autoLoading; /** @type {?|undefined} */ ModalButtonOptions.prototype.show; /** @type {?|undefined} */ ModalButtonOptions.prototype.loading; /** @type {?|undefined} */ ModalButtonOptions.prototype.disabled; /* Skipping unhandled member: [key: string]: NzSafeAny;*/ /** * @this {?} * @param {?=} contentComponentInstance * @return {?} */ ModalButtonOptions.prototype.onClick = function (contentComponentInstance) { }; } /** * @fileoverview added by tsickle * Generated from: modal-config.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function NzModalConfig() { } if (false) { /** @type {?|undefined} */ NzModalConfig.prototype.nzMask; /** @type {?|undefined} */ NzModalConfig.prototype.nzMaskClosable; } /** @type {?} */ var NZ_MODAL_CONFIG = new core.InjectionToken('NZ_MODAL_CONFIG'); /** @type {?} */ var ZOOM_CLASS_NAME_MAP = { enter: 'zoom-enter', enterActive: 'zoom-enter-active', leave: 'zoom-leave', leaveActive: 'zoom-leave-active' }; /** @type {?} */ var FADE_CLASS_NAME_MAP = { enter: 'fade-enter', enterActive: 'fade-enter-active', leave: 'fade-leave', leaveActive: 'fade-leave-active' }; /** @type {?} */ var MODAL_MASK_CLASS_NAME = 'ant-modal-mask'; /** * @fileoverview added by tsickle * Generated from: modal-animations.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var nzModalAnimations = { modalContainer: animations$1.trigger('modalContainer', [ animations$1.state('void, exit', animations$1.style({})), animations$1.state('enter', animations$1.style({})), animations$1.transition('* => enter', animations$1.animate('.24s', animations$1.style({}))), animations$1.transition('* => void, * => exit', animations$1.animate('.2s', animations$1.style({}))) ]) }; /** * @fileoverview added by tsickle * Generated from: modal-container.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @return {?} */ function throwNzModalContentAlreadyAttachedError() { throw Error('Attempting to attach modal content after content is already attached'); } var BaseModalContainer = /** @class */ (function (_super) { __extends(BaseModalContainer, _super); function BaseModalContainer(elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, document, animationType) { var _this = _super.call(this) || this; _this.elementRef = elementRef; _this.focusTrapFactory = focusTrapFactory; _this.cdr = cdr; _this.render = render; _this.zone = zone; _this.overlayRef = overlayRef; _this.config = config; _this.animationType = animationType; _this.animationStateChanged = new core.EventEmitter(); _this.containerClick = new core.EventEmitter(); _this.cancelTriggered = new core.EventEmitter(); _this.okTriggered = new core.EventEmitter(); _this.state = 'enter'; _this.isStringContent = false; _this.elementFocusedBeforeModalWasOpened = null; _this.latestMousedownTarget = null; _this.oldMaskStyle = null; _this.document = document; _this.isStringContent = typeof config.nzContent === 'string'; _this.setContainer(); return _this; } /** * @param {?} e * @return {?} */ BaseModalContainer.prototype.onMousedown = /** * @param {?} e * @return {?} */ function (e) { this.latestMousedownTarget = ((/** @type {?} */ (e.target))) || null; }; /** * @param {?} e * @return {?} */ BaseModalContainer.prototype.onMouseup = /** * @param {?} e * @return {?} */ function (e) { if (e.target === this.latestMousedownTarget && e.target === this.elementRef.nativeElement) { this.containerClick.emit(); } this.latestMousedownTarget = null; }; /** * @return {?} */ BaseModalContainer.prototype.onCloseClick = /** * @return {?} */ function () { this.cancelTriggered.emit(); }; /** * @return {?} */ BaseModalContainer.prototype.onOkClick = /** * @return {?} */ function () { this.okTriggered.emit(); }; /** * @template T * @param {?} portal * @return {?} */ BaseModalContainer.prototype.attachComponentPortal = /** * @template T * @param {?} portal * @return {?} */ function (portal) { if (this.portalOutlet.hasAttached()) { throwNzModalContentAlreadyAttachedError(); } this.savePreviouslyFocusedElement(); this.setModalTransformOrigin(); return this.portalOutlet.attachComponentPortal(portal); }; /** * @template C * @param {?} portal * @return {?} */ BaseModalContainer.prototype.attachTemplatePortal = /** * @template C * @param {?} portal * @return {?} */ function (portal) { if (this.portalOutlet.hasAttached()) { throwNzModalContentAlreadyAttachedError(); } this.savePreviouslyFocusedElement(); return this.portalOutlet.attachTemplatePortal(portal); }; /** * @return {?} */ BaseModalContainer.prototype.getNativeElement = /** * @return {?} */ function () { return this.elementRef.nativeElement; }; /** * @private * @return {?} */ BaseModalContainer.prototype.animationDisabled = /** * @private * @return {?} */ function () { return this.config.nzNoAnimation || this.animationType === 'NoopAnimations'; }; /** * @private * @return {?} */ BaseModalContainer.prototype.setModalTransformOrigin = /** * @private * @return {?} */ function () { /** @type {?} */ var modalElement = this.modalElementRef.nativeElement; if ((/** @type {?} */ (this.elementFocusedBeforeModalWasOpened))) { /** @type {?} */ var previouslyDOMRect = (/** @type {?} */ (this.elementFocusedBeforeModalWasOpened)).getBoundingClientRect(); /** @type {?} */ var lastPosition = util.getElementOffset((/** @type {?} */ (this.elementFocusedBeforeModalWasOpened))); /** @type {?} */ var x = lastPosition.left + previouslyDOMRect.width / 2; /** @type {?} */ var y = lastPosition.top + previouslyDOMRect.height / 2; /** @type {?} */ var transformOrigin = x - modalElement.offsetLeft + "px " + (y - modalElement.offsetTop) + "px 0px"; this.render.setStyle(modalElement, 'transform-origin', transformOrigin); } }; /** * @private * @return {?} */ BaseModalContainer.prototype.savePreviouslyFocusedElement = /** * @private * @return {?} */ function () { var _this = this; if (this.document) { this.elementFocusedBeforeModalWasOpened = (/** @type {?} */ (this.document.activeElement)); if (this.elementRef.nativeElement.focus) { Promise.resolve().then((/** * @return {?} */ function () { return _this.elementRef.nativeElement.focus(); })); } } }; /** * @private * @return {?} */ BaseModalContainer.prototype.trapFocus = /** * @private * @return {?} */ function () { /** @type {?} */ var element = this.elementRef.nativeElement; if (!this.focusTrap) { this.focusTrap = this.focusTrapFactory.create(element); } if (this.config.nzAutofocus) { this.focusTrap.focusInitialElementWhenReady().then(); } else { /** @type {?} */ var activeElement = this.document.activeElement; if (activeElement !== element && !element.contains(activeElement)) { element.focus(); } } }; /** * @private * @return {?} */ BaseModalContainer.prototype.restoreFocus = /** * @private * @return {?} */ function () { /** @type {?} */ var toFocus = (/** @type {?} */ (this.elementFocusedBeforeModalWasOpened)); // We need the extra check, because IE can set the `activeElement` to null in some cases. if (toFocus && typeof toFocus.focus === 'function') { /** @type {?} */ var activeElement = (/** @type {?} */ (this.document.activeElement)); /** @type {?} */ var element = this.elementRef.nativeElement; if (!activeElement || activeElement === this.document.body || activeElement === element || element.contains(activeElement)) { toFocus.focus(); } } if (this.focusTrap) { this.focusTrap.destroy(); } }; /** * @private * @return {?} */ BaseModalContainer.prototype.setEnterAnimationClass = /** * @private * @return {?} */ function () { var _this = this; if (this.animationDisabled()) { return; } this.zone.runOutsideAngular((/** * @return {?} */ function () { // Make sure to set the `TransformOrigin` style before set the modelElement's class names _this.setModalTransformOrigin(); /** @type {?} */ var modalElement = _this.modalElementRef.nativeElement; /** @type {?} */ var backdropElement = _this.overlayRef.backdropElement; _this.render.addClass(modalElement, ZOOM_CLASS_NAME_MAP.enter); _this.render.addClass(modalElement, ZOOM_CLASS_NAME_MAP.enterActive); _this.render.addClass(backdropElement, FADE_CLASS_NAME_MAP.enter); _this.render.addClass(backdropElement, FADE_CLASS_NAME_MAP.enterActive); })); }; /** * @private * @return {?} */ BaseModalContainer.prototype.setExitAnimationClass = /** * @private * @return {?} */ function () { var _this = this; this.zone.runOutsideAngular((/** * @return {?} */ function () { /** @type {?} */ var modalElement = _this.modalElementRef.nativeElement; /** @type {?} */ var backdropElement = _this.overlayRef.backdropElement; if (_this.animationDisabled()) { // https://github.com/angular/components/issues/18645 _this.render.removeClass(backdropElement, MODAL_MASK_CLASS_NAME); return; } _this.render.addClass(modalElement, ZOOM_CLASS_NAME_MAP.leave); _this.render.addClass(modalElement, ZOOM_CLASS_NAME_MAP.leaveActive); _this.render.addClass(backdropElement, FADE_CLASS_NAME_MAP.leave); _this.render.addClass(backdropElement, FADE_CLASS_NAME_MAP.leaveActive); })); }; /** * @private * @return {?} */ BaseModalContainer.prototype.cleanAnimationClass = /** * @private * @return {?} */ function () { var _this = this; if (this.animationDisabled()) { return; } this.zone.runOutsideAngular((/** * @return {?} */ function () { /** @type {?} */ var backdropElement = _this.overlayRef.backdropElement; /** @type {?} */ var modalElement = _this.modalElementRef.nativeElement; _this.render.removeClass(modalElement, ZOOM_CLASS_NAME_MAP.enter); _this.render.removeClass(modalElement, ZOOM_CLASS_NAME_MAP.enterActive); _this.render.removeClass(modalElement, ZOOM_CLASS_NAME_MAP.leave); _this.render.removeClass(modalElement, ZOOM_CLASS_NAME_MAP.leaveActive); _this.render.removeClass(backdropElement, FADE_CLASS_NAME_MAP.enter); _this.render.removeClass(backdropElement, FADE_CLASS_NAME_MAP.enterActive); })); }; /** * @private * @return {?} */ BaseModalContainer.prototype.bindBackdropStyle = /** * @private * @return {?} */ function () { var _this = this; this.zone.runOutsideAngular((/** * @return {?} */ function () { if (_this.oldMaskStyle) { /** @type {?} */ var backdropElement_1 = _this.overlayRef.backdropElement; /** @type {?} */ var styles = (/** @type {?} */ (_this.oldMaskStyle)); Object.keys(styles).forEach((/** * @param {?} key * @return {?} */ function (key) { _this.render.removeStyle(backdropElement_1, key); })); _this.oldMaskStyle = null; } if (typeof _this.config.nzMaskStyle === 'object' && Object.keys(_this.config.nzMaskStyle).length) { /** @type {?} */ var backdropElement_2 = _this.overlayRef.backdropElement; /** @type {?} */ var styles_1 = __assign({}, _this.config.nzMaskStyle); Object.keys(styles_1).forEach((/** * @param {?} key * @return {?} */ function (key) { _this.render.setStyle(backdropElement_2, key, styles_1[key]); })); _this.oldMaskStyle = styles_1; } })); }; /** * Set the container element. * @deprecated Not supported. * @breaking-change 10.0.0 */ /** * Set the container element. * @deprecated Not supported. * \@breaking-change 10.0.0 * @private * @return {?} */ BaseModalContainer.prototype.setContainer = /** * Set the container element. * @deprecated Not supported. * \@breaking-change 10.0.0 * @private * @return {?} */ function () { /** @type {?} */ var container = this.getContainer(); if (container) { this.render.appendChild(container, this.elementRef.nativeElement); } }; /** * Reset the container element. * @deprecated Not supported. * @breaking-change 10.0.0 */ /** * Reset the container element. * @deprecated Not supported. * \@breaking-change 10.0.0 * @private * @return {?} */ BaseModalContainer.prototype.resetContainer = /** * Reset the container element. * @deprecated Not supported. * \@breaking-change 10.0.0 * @private * @return {?} */ function () { /** @type {?} */ var container = this.getContainer(); if (container) { this.render.appendChild(this.overlayRef.overlayElement, this.elementRef.nativeElement); } }; /** * @private * @return {?} */ BaseModalContainer.prototype.getContainer = /** * @private * @return {?} */ function () { var nzGetContainer = this.config.nzGetContainer; /** @type {?} */ var container = typeof nzGetContainer === 'function' ? nzGetContainer() : nzGetContainer; return container instanceof HTMLElement ? container : null; }; /** * @param {?} event * @return {?} */ BaseModalContainer.prototype.onAnimationDone = /** * @param {?} event * @return {?} */ function (event) { if (event.toState === 'void') { return; } if (event.toState === 'enter') { this.setContainer(); this.trapFocus(); } else if (event.toState === 'exit') { this.restoreFocus(); } this.cleanAnimationClass(); this.animationStateChanged.emit(event); }; /** * @param {?} event * @return {?} */ BaseModalContainer.prototype.onAnimationStart = /** * @param {?} event * @return {?} */ function (event) { if (event.toState === 'enter') { this.setEnterAnimationClass(); this.bindBackdropStyle(); } else if (event.toState === 'exit') { this.resetContainer(); this.setExitAnimationClass(); } this.animationStateChanged.emit(event); }; /** * @return {?} */ BaseModalContainer.prototype.startExitAnimation = /** * @return {?} */ function () { this.state = 'exit'; this.cdr.markForCheck(); }; return BaseModalContainer; }(portal.BasePortalOutlet)); if (false) { /** @type {?} */ BaseModalContainer.prototype.portalOutlet; /** @type {?} */ BaseModalContainer.prototype.modalElementRef; /** @type {?} */ BaseModalContainer.prototype.animationStateChanged; /** @type {?} */ BaseModalContainer.prototype.containerClick; /** @type {?} */ BaseModalContainer.prototype.cancelTriggered; /** @type {?} */ BaseModalContainer.prototype.okTriggered; /** @type {?} */ BaseModalContainer.prototype.state; /** @type {?} */ BaseModalContainer.prototype.document; /** @type {?} */ BaseModalContainer.prototype.modalRef; /** @type {?} */ BaseModalContainer.prototype.isStringContent; /** * @type {?} * @private */ BaseModalContainer.prototype.elementFocusedBeforeModalWasOpened; /** * @type {?} * @private */ BaseModalContainer.prototype.focusTrap; /** * @type {?} * @private */ BaseModalContainer.prototype.latestMousedownTarget; /** * @type {?} * @private */ BaseModalContainer.prototype.oldMaskStyle; /** * @type {?} * @protected */ BaseModalContainer.prototype.elementRef; /** * @type {?} * @protected */ BaseModalContainer.prototype.focusTrapFactory; /** @type {?} */ BaseModalContainer.prototype.cdr; /** * @type {?} * @protected */ BaseModalContainer.prototype.render; /** * @type {?} * @protected */ BaseModalContainer.prototype.zone; /** * @type {?} * @protected */ BaseModalContainer.prototype.overlayRef; /** @type {?} */ BaseModalContainer.prototype.config; /** * @type {?} * @protected */ BaseModalContainer.prototype.animationType; } /** * @fileoverview added by tsickle * Generated from: modal-confirm-container.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzModalConfirmContainerComponent = /** @class */ (function (_super) { __extends(NzModalConfirmContainerComponent, _super); function NzModalConfirmContainerComponent(i18n, elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, document, animationType) { var _this = _super.call(this, elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, document, animationType) || this; _this.i18n = i18n; _this.config = config; _this.cancelTriggered = new core.EventEmitter(); _this.okTriggered = new core.EventEmitter(); _this.locale = {}; _this.destroy$ = new rxjs.Subject(); _this.i18n.localeChange.pipe(operators.takeUntil(_this.destroy$)).subscribe((/** * @return {?} */ function () { _this.locale = _this.i18n.getLocaleData('Modal'); })); return _this; } /** * @return {?} */ NzModalConfirmContainerComponent.prototype.onCancel = /** * @return {?} */ function () { this.cancelTriggered.emit(); }; /** * @return {?} */ NzModalConfirmContainerComponent.prototype.onOk = /** * @return {?} */ function () { this.okTriggered.emit(); }; /** * @template T * @param {?} _portal * @return {?} */ NzModalConfirmContainerComponent.prototype.attachComponentPortal = /** * @template T * @param {?} _portal * @return {?} */ function (_portal) { throw new Error('The confirm mode does not support using component as content'); }; /** * @return {?} */ NzModalConfirmContainerComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.destroy$.next(); this.destroy$.complete(); }; NzModalConfirmContainerComponent.decorators = [ { type: core.Component, args: [{ selector: 'nz-modal-confirm-container', exportAs: 'nzModalConfirmContainer', template: "\n <div\n #modalElement\n role=\"document\"\n class=\"ant-modal\"\n [ngClass]=\"config.nzClassName\"\n [ngStyle]=\"config.nzStyle\"\n [style.width]=\"config?.nzWidth | nzToCssUnit\"\n >\n <div class=\"ant-modal-content\">\n <button *ngIf=\"config.nzClosable\" nz-modal-close (click)=\"onCloseClick()\"></button>\n <div class=\"ant-modal-body\" [ngStyle]=\"config.nzBodyStyle\">\n <div class=\"ant-modal-confirm-body-wrapper\">\n <div class=\"ant-modal-confirm-body\">\n <i nz-icon [nzType]=\"config.nzIconType\"></i>\n <span class=\"ant-modal-confirm-title\">\n <ng-container *nzStringTemplateOutlet=\"config.nzTitle\">\n <span [innerHTML]=\"config.nzTitle\"></span>\n </ng-container>\n </span>\n <div class=\"ant-modal-confirm-content\">\n <ng-template cdkPortalOutlet></ng-template>\n <div *ngIf=\"isStringContent\" [innerHTML]=\"config.nzContent\"></div>\n </div>\n </div>\n <div class=\"ant-modal-confirm-btns\">\n <button\n *ngIf=\"config.nzCancelText !== null\"\n [attr.cdkFocusInitial]=\"config.nzAutofocus === 'cancel'\"\n nz-button\n (click)=\"onCancel()\"\n [nzLoading]=\"config.nzCancelLoading\"\n [disabled]=\"config.nzCancelDisabled\"\n >\n {{ config.nzCancelText || locale.cancelText }}\n </button>\n <button\n *ngIf=\"config.nzOkText !== null\"\n [attr.cdkFocusInitial]=\"config.nzAutofocus === 'ok'\"\n nz-button\n [nzType]=\"config.nzOkType\"\n (click)=\"onOk()\"\n [nzLoading]=\"config.nzOkLoading\"\n [disabled]=\"config.nzOkDisabled\"\n >\n {{ config.nzOkText || locale.okText }}\n </button>\n </div>\n </div>\n </div>\n </div>\n </div>\n ", animations: [nzModalAnimations.modalContainer], // Using OnPush for modal caused footer can not to detect changes. we can fix it when 8.x. changeDetection: core.ChangeDetectionStrategy.Default, host: { tabindex: '-1', role: 'dialog', '[class]': 'config.nzWrapClassName ? "ant-modal-wrap " + config.nzWrapClassName : "ant-modal-wrap"', '[style.zIndex]': 'config.nzZIndex', '[@.disabled]': 'config.nzNoAnimation', '[@modalContainer]': 'state', '(@modalContainer.start)': 'onAnimationStart($event)', '(@modalContainer.done)': 'onAnimationDone($event)', '(mousedown)': 'onMousedown($event)', '(mouseup)': 'onMouseup($event)' } }] } ]; /** @nocollapse */ NzModalConfirmContainerComponent.ctorParameters = function () { return [ { type: i18n.NzI18nService }, { type: core.ElementRef }, { type: a11y.FocusTrapFactory }, { type: core.ChangeDetectorRef }, { type: core.Renderer2 }, { type: core.NgZone }, { type: overlay.OverlayRef }, { type: ModalOptions }, { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [common.DOCUMENT,] }] }, { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [animations.ANIMATION_MODULE_TYPE,] }] } ]; }; NzModalConfirmContainerComponent.propDecorators = { portalOutlet: [{ type: core.ViewChild, args: [portal.CdkPortalOutlet, { static: true },] }], modalElementRef: [{ type: core.ViewChild, args: ['modalElement', { static: true },] }], cancelTriggered: [{ type: core.Output }], okTriggered: [{ type: core.Output }] }; return NzModalConfirmContainerComponent; }(BaseModalContainer)); if (false) { /** @type {?} */ NzModalConfirmContainerComponent.prototype.portalOutlet; /** @type {?} */ NzModalConfirmContainerComponent.prototype.modalElementRef; /** @type {?} */ NzModalConfirmContainerComponent.prototype.cancelTriggered; /** @type {?} */ NzModalConfirmContainerComponent.prototype.okTriggered; /** @type {?} */ NzModalConfirmContainerComponent.prototype.locale; /** * @type {?} * @private */ NzModalConfirmContainerComponent.prototype.destroy$; /** * @type {?} * @private */ NzModalConfirmContainerComponent.prototype.i18n; /** @type {?} */ NzModalConfirmContainerComponent.prototype.config; } /** * @fileoverview added by tsickle * Generated from: modal-container.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzModalContainerComponent = /** @class */ (function (_super) { __extends(NzModalContainerComponent, _super); function NzModalContainerComponent(elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, document, animationType) { var _this = _super.call(this, elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, document, animationType) || this; _this.config = config; return _this; } NzModalContainerComponent.decorators = [ { type: core.Component, args: [{ selector: 'nz-modal-container', exportAs: 'nzModalContainer', template: "\n <div\n #modalElement\n role=\"document\"\n class=\"ant-modal\"\n [ngClass]=\"config.nzClassName\"\n [ngStyle]=\"config.nzStyle\"\n [style.width]=\"config?.nzWidth | nzToCssUnit\"\n >\n <div class=\"ant-modal-content\">\n <button *ngIf=\"config.nzClosable\" nz-modal-close (click)=\"onCloseClick()\"></button>\n <div *ngIf=\"config.nzTitle\" nz-modal-title></div>\n <div class=\"ant-modal-body\" [ngStyle]=\"config.nzBodyStyle\">\n <ng-template cdkPortalOutlet></ng-template>\n <div *ngIf=\"isStringContent\" [innerHTML]=\"config.nzContent\"></div>\n </div>\n <div\n *ngIf=\"config.nzFooter !== null\"\n nz-modal-footer\n [modalRef]=\"modalRef\"\n (cancelTriggered)=\"onCloseClick()\"\n (okTriggered)=\"onOkClick()\"\n ></div>\n </div>\n </div>\n ", animations: [nzModalAnimations.modalContainer], // Using OnPush for modal caused footer can not to detect changes. we can fix it when 8.x. changeDetection: core.ChangeDetectionStrategy.Default, host: { tabindex: '-1', role: 'dialog', '[class]': 'config.nzWrapClassName ? "ant-modal-wrap " + config.nzWrapClassName : "ant-modal-wrap"', '[style.zIndex]': 'config.nzZIndex', '[@.disabled]': 'config.nzNoAnimation', '[@modalContainer]': 'state', '(@modalContainer.start)': 'onAnimationStart($event)', '(@modalContainer.done)': 'onAnimationDone($event)', '(mousedown)': 'onMousedown($event)', '(mouseup)': 'onMouseup($event)' } }] } ]; /** @nocollapse */ NzModalContainerComponent.ctorParameters = function () { return [ { type: core.ElementRef }, { type: a11y.FocusTrapFactory }, { type: core.ChangeDetectorRef }, { t