ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,301 lines (1,271 loc) • 89.8 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/a11y'), require('@angular/cdk/keycodes'), require('@angular/cdk/overlay'), require('@angular/common'), require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('ng-zorro-antd/core'), require('ng-zorro-antd/i18n'), require('ng-zorro-antd/button'), require('ng-zorro-antd/icon'), require('@angular/cdk/portal')) :
typeof define === 'function' && define.amd ? define('ng-zorro-antd/modal', ['exports', '@angular/cdk/a11y', '@angular/cdk/keycodes', '@angular/cdk/overlay', '@angular/common', '@angular/core', 'rxjs', 'rxjs/operators', 'ng-zorro-antd/core', 'ng-zorro-antd/i18n', 'ng-zorro-antd/button', 'ng-zorro-antd/icon', '@angular/cdk/portal'], factory) :
(global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].modal = {}), global.ng.cdk.a11y, global.ng.cdk.keycodes, global.ng.cdk.overlay, global.ng.common, global.ng.core, global.rxjs, global.rxjs.operators, global['ng-zorro-antd'].core, global['ng-zorro-antd'].i18n, global['ng-zorro-antd'].button, global['ng-zorro-antd'].icon, global.ng.cdk.portal));
}(this, function (exports, a11y, keycodes, overlay, common, core, rxjs, operators, core$1, i18n, button, icon, portal) { '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) {
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) : new P(function (resolve) { resolve(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 m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
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 };
}
/**
* @fileoverview added by tsickle
* @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');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzModalControlServiceModule = /** @class */ (function () {
function NzModalControlServiceModule() {
}
NzModalControlServiceModule.decorators = [
{ type: core.NgModule }
];
return NzModalControlServiceModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function RegisteredMeta() { }
if (false) {
/** @type {?} */
RegisteredMeta.prototype.modalRef;
/** @type {?} */
RegisteredMeta.prototype.afterOpenSubscription;
/** @type {?} */
RegisteredMeta.prototype.afterCloseSubscription;
}
var NzModalControlService = /** @class */ (function () {
function NzModalControlService(parentService) {
this.parentService = parentService;
this.rootOpenModals = this.parentService ? null : [];
this.rootAfterAllClose = this.parentService ? null : new rxjs.Subject();
this.rootRegisteredMetaMap = this.parentService ? null : new Map();
}
Object.defineProperty(NzModalControlService.prototype, "afterAllClose", {
// Track singleton afterAllClose through over the injection tree
get:
// Track singleton afterAllClose through over the injection tree
/**
* @return {?}
*/
function () {
return this.parentService ? this.parentService.afterAllClose : (/** @type {?} */ (this.rootAfterAllClose));
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalControlService.prototype, "openModals", {
// Track singleton openModals array through over the injection tree
get:
// Track singleton openModals array through over the injection tree
/**
* @return {?}
*/
function () {
return this.parentService ? this.parentService.openModals : (/** @type {?} */ (this.rootOpenModals));
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalControlService.prototype, "registeredMetaMap", {
get: /**
* @private
* @return {?}
*/
function () {
// Registered modal for later usage
return this.parentService ? this.parentService.registeredMetaMap : (/** @type {?} */ (this.rootRegisteredMetaMap));
},
enumerable: true,
configurable: true
});
// Register a modal to listen its open/close
// Register a modal to listen its open/close
/**
* @param {?} modalRef
* @return {?}
*/
NzModalControlService.prototype.registerModal =
// Register a modal to listen its open/close
/**
* @param {?} modalRef
* @return {?}
*/
function (modalRef) {
var _this = this;
if (!this.hasRegistered(modalRef)) {
/** @type {?} */
var afterOpenSubscription = modalRef.afterOpen.subscribe((/**
* @return {?}
*/
function () { return _this.openModals.push(modalRef); }));
/** @type {?} */
var afterCloseSubscription = modalRef.afterClose.subscribe((/**
* @return {?}
*/
function () { return _this.removeOpenModal(modalRef); }));
this.registeredMetaMap.set(modalRef, { modalRef: modalRef, afterOpenSubscription: afterOpenSubscription, afterCloseSubscription: afterCloseSubscription });
}
};
// deregister modals
// deregister modals
/**
* @param {?} modalRef
* @return {?}
*/
NzModalControlService.prototype.deregisterModal =
// deregister modals
/**
* @param {?} modalRef
* @return {?}
*/
function (modalRef) {
/** @type {?} */
var registeredMeta = this.registeredMetaMap.get(modalRef);
if (registeredMeta) {
// Remove this modal if it is still in the opened modal list (NOTE: it may trigger "afterAllClose")
this.removeOpenModal(registeredMeta.modalRef);
registeredMeta.afterOpenSubscription.unsubscribe();
registeredMeta.afterCloseSubscription.unsubscribe();
this.registeredMetaMap.delete(modalRef);
}
};
/**
* @param {?} modalRef
* @return {?}
*/
NzModalControlService.prototype.hasRegistered = /**
* @param {?} modalRef
* @return {?}
*/
function (modalRef) {
return this.registeredMetaMap.has(modalRef);
};
// Close all registered opened modals
// Close all registered opened modals
/**
* @return {?}
*/
NzModalControlService.prototype.closeAll =
// Close all registered opened modals
/**
* @return {?}
*/
function () {
/** @type {?} */
var i = this.openModals.length;
while (i--) {
this.openModals[i].close();
}
};
/**
* @private
* @param {?} modalRef
* @return {?}
*/
NzModalControlService.prototype.removeOpenModal = /**
* @private
* @param {?} modalRef
* @return {?}
*/
function (modalRef) {
/** @type {?} */
var index = this.openModals.indexOf(modalRef);
if (index > -1) {
this.openModals.splice(index, 1);
if (!this.openModals.length) {
this.afterAllClose.next();
}
}
};
NzModalControlService.decorators = [
{ type: core.Injectable, args: [{
providedIn: NzModalControlServiceModule
},] }
];
/** @nocollapse */
NzModalControlService.ctorParameters = function () { return [
{ type: NzModalControlService, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] }
]; };
/** @nocollapse */ NzModalControlService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NzModalControlService_Factory() { return new NzModalControlService(core.ɵɵinject(NzModalControlService, 12)); }, token: NzModalControlService, providedIn: NzModalControlServiceModule });
return NzModalControlService;
}());
if (false) {
/**
* @type {?}
* @private
*/
NzModalControlService.prototype.rootOpenModals;
/**
* @type {?}
* @private
*/
NzModalControlService.prototype.rootAfterAllClose;
/**
* @type {?}
* @private
*/
NzModalControlService.prototype.rootRegisteredMetaMap;
/**
* @type {?}
* @private
*/
NzModalControlService.prototype.parentService;
}
/**
* @fileoverview added by tsickle
* @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
*/
/**
* API class that public to users to handle the modal instance.
* NzModalRef is aim to avoid accessing to the modal instance directly by users.
* @abstract
* @template T, R
*/
// tslint:disable-next-line:no-any
var /**
* API class that public to users to handle the modal instance.
* NzModalRef is aim to avoid accessing to the modal instance directly by users.
* @abstract
* @template T, R
*/
// tslint:disable-next-line:no-any
NzModalRef = /** @class */ (function () {
function NzModalRef() {
}
return NzModalRef;
}());
if (false) {
/** @type {?} */
NzModalRef.prototype.afterOpen;
/** @type {?} */
NzModalRef.prototype.afterClose;
/**
* @abstract
* @return {?}
*/
NzModalRef.prototype.open = function () { };
/**
* @abstract
* @param {?=} result
* @return {?}
*/
NzModalRef.prototype.close = function (result) { };
/**
* @abstract
* @param {?=} result
* @return {?}
*/
NzModalRef.prototype.destroy = function (result) { };
/**
* Trigger the nzOnOk/nzOnCancel by manual
* @abstract
* @return {?}
*/
NzModalRef.prototype.triggerOk = function () { };
/**
* @abstract
* @return {?}
*/
NzModalRef.prototype.triggerCancel = function () { };
/**
* Return the component instance of nzContent when specify nzContent as a Component
* Note: this method may return undefined if the Component has not ready yet. (it only available after Modal's ngOnInit)
* @abstract
* @return {?}
*/
NzModalRef.prototype.getContentComponent = function () { };
/**
* Get the dom element of this Modal
* @abstract
* @return {?}
*/
NzModalRef.prototype.getElement = function () { };
/**
* Get the instance of the Modal itself
* @abstract
* @return {?}
*/
NzModalRef.prototype.getInstance = function () { };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzModalFooterDirective = /** @class */ (function () {
function NzModalFooterDirective(nzModalRef, templateRef) {
this.nzModalRef = nzModalRef;
this.templateRef = templateRef;
if (this.nzModalRef) {
this.nzModalRef.getInstance().setFooterWithTemplate(this.templateRef);
}
}
NzModalFooterDirective.decorators = [
{ type: core.Directive, args: [{
selector: '[nzModalFooter]',
exportAs: 'nzModalFooter'
},] }
];
/** @nocollapse */
NzModalFooterDirective.ctorParameters = function () { return [
{ type: NzModalRef, decorators: [{ type: core.Optional }] },
{ type: core.TemplateRef }
]; };
return NzModalFooterDirective;
}());
if (false) {
/**
* @type {?}
* @private
*/
NzModalFooterDirective.prototype.nzModalRef;
/** @type {?} */
NzModalFooterDirective.prototype.templateRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var MODAL_ANIMATE_DURATION = 200;
/** @type {?} */
var WRAP_CLASS_NAME = 'ant-modal-wrap';
/**
* @template T, R
*/
var NzModalComponent = /** @class */ (function (_super) {
__extends(NzModalComponent, _super);
function NzModalComponent(nzConfigService, overlay, overlayKeyboardDispatcher, i18n, cfr, elementRef, viewContainer, modalControl, focusTrapFactory, cdr, nzModalGlobalConfig, document // tslint:disable-line:no-any
) {
var _this = _super.call(this) || this;
_this.nzConfigService = nzConfigService;
_this.overlay = overlay;
_this.overlayKeyboardDispatcher = overlayKeyboardDispatcher;
_this.i18n = i18n;
_this.cfr = cfr;
_this.elementRef = elementRef;
_this.viewContainer = viewContainer;
_this.modalControl = modalControl;
_this.focusTrapFactory = focusTrapFactory;
_this.cdr = cdr;
_this.nzModalGlobalConfig = nzModalGlobalConfig;
_this.document = document;
_this.nzVisible = false;
_this.nzClosable = true;
_this.nzOkLoading = false;
_this.nzOkDisabled = false;
_this.nzCancelDisabled = false;
_this.nzCancelLoading = false;
_this.nzKeyboard = true;
_this.nzNoAnimation = false;
// [STATIC] Default Modal ONLY
_this.nzGetContainer = (/**
* @return {?}
*/
function () { return _this.overlay.create(); }); // [STATIC]
// [STATIC]
_this.nzZIndex = 1000;
_this.nzWidth = 520;
_this.nzCloseIcon = 'close';
_this.nzOkType = 'primary';
_this.nzIconType = 'question-circle'; // Confirm Modal ONLY
// Confirm Modal ONLY
_this.nzModalType = 'default';
_this.nzOnOk = new core.EventEmitter();
_this.nzOnCancel = new core.EventEmitter();
_this.nzAfterOpen = new core.EventEmitter(); // Trigger when modal open(visible) after animations
// Trigger when modal open(visible) after animations
_this.nzAfterClose = new core.EventEmitter(); // Trigger when modal leave-animation over
// Trigger when modal leave-animation over
_this.nzVisibleChange = new core.EventEmitter();
_this.locale = {};
_this.transformOrigin = '0px 0px 0px'; // The origin point that animation based on
_this.unsubscribe$ = new rxjs.Subject();
_this.dialogMouseDown = false;
_this.scrollStrategy = _this.overlay.scrollStrategies.block();
if (_this.nzModalGlobalConfig) {
core$1.warnDeprecation('`NZ_MODAL_CONFIG` has been deprecated and will be removed in 9.0.0. Please use global config instead.');
}
return _this;
}
Object.defineProperty(NzModalComponent.prototype, "modalFooter", {
set:
// Only aim to focus the ok button that needs to be auto focused
/**
* @param {?} value
* @return {?}
*/
function (value) {
if (value && value.templateRef) {
this.setFooterWithTemplate(value.templateRef);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalComponent.prototype, "afterOpen", {
get: /**
* @return {?}
*/
function () {
// Observable alias for nzAfterOpen
return this.nzAfterOpen.asObservable();
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalComponent.prototype, "afterClose", {
get: /**
* @return {?}
*/
function () {
// Observable alias for nzAfterClose
return this.nzAfterClose.asObservable();
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalComponent.prototype, "cancelText", {
get: /**
* @return {?}
*/
function () {
return this.nzCancelText || (/** @type {?} */ (this.locale.cancelText));
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalComponent.prototype, "okText", {
get: /**
* @return {?}
*/
function () {
return this.nzOkText || (/** @type {?} */ (this.locale.okText));
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalComponent.prototype, "hidden", {
get: /**
* @return {?}
*/
function () {
return !this.nzVisible && !this.animationState;
} // Indicate whether this dialog should hidden
,
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalComponent.prototype, "mask", {
/**
* @description
* The calculated highest weight of mask value
*
* Weight of different mask input:
* component default value < global configuration < component input value
*/
get:
// Indicate whether this dialog should hidden
/**
* \@description
* The calculated highest weight of mask value
*
* Weight of different mask input:
* component default value < global configuration < component input value
* @return {?}
*/
function () {
if (this.nzMask != null) {
return this.nzMask;
}
else if (this.nzModalGlobalConfig && this.nzModalGlobalConfig.nzMask != null) {
return this.nzModalGlobalConfig.nzMask;
}
else {
return true;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzModalComponent.prototype, "maskClosable", {
/**
* @description
* The calculated highest weight of maskClosable value
*
* Weight of different maskClosable input:
* component default value < global configuration < component input value
*/
get: /**
* \@description
* The calculated highest weight of maskClosable value
*
* Weight of different maskClosable input:
* component default value < global configuration < component input value
* @return {?}
*/
function () {
if (this.nzMaskClosable != null) {
return this.nzMaskClosable;
}
else if (this.nzModalGlobalConfig && this.nzModalGlobalConfig.nzMaskClosable != null) {
return this.nzModalGlobalConfig.nzMaskClosable;
}
else {
return true;
}
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NzModalComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.i18n.localeChange.pipe(operators.takeUntil(this.unsubscribe$)).subscribe((/**
* @return {?}
*/
function () {
_this.locale = _this.i18n.getLocaleData('Modal');
}));
if (this.isComponent(this.nzContent)) {
this.createDynamicComponent((/** @type {?} */ (this.nzContent))); // Create component along without View
}
if (this.isModalButtons(this.nzFooter)) {
// Setup default button options
this.nzFooter = this.formatModalButtons((/** @type {?} */ (this.nzFooter)));
}
// Place the modal dom to elsewhere
this.container = typeof this.nzGetContainer === 'function' ? this.nzGetContainer() : this.nzGetContainer;
if (this.container instanceof HTMLElement) {
this.container.appendChild(this.elementRef.nativeElement);
rxjs.fromEvent(this.document.body, 'keydown')
.pipe(operators.takeUntil(this.unsubscribe$))
.subscribe((/**
* @param {?} e
* @return {?}
*/
function (e) { return _this.keydownListener(e); }));
}
else if (this.container instanceof overlay.OverlayRef) {
// NOTE: only attach the dom to overlay, the view container is not changed actually
this.setOverlayRef(this.container);
this.container.overlayElement.appendChild(this.elementRef.nativeElement);
}
if (this.overlayRef) {
this.overlayRef
.keydownEvents()
.pipe(operators.takeUntil(this.unsubscribe$))
.subscribe((/**
* @param {?} e
* @return {?}
*/
function (e) { return _this.keydownListener(e); }));
}
// Register modal when afterOpen/afterClose is stable
this.modalControl.registerModal(this);
};
// [NOTE] NOT available when using by service!
// Because ngOnChanges never be called when using by service,
// here we can't support "nzContent"(Component) etc. as inputs that initialized dynamically.
// BUT: User also can change "nzContent" dynamically to trigger UI changes (provided you don't use Component that needs initializations)
// [NOTE] NOT available when using by service!
// Because ngOnChanges never be called when using by service,
// here we can't support "nzContent"(Component) etc. as inputs that initialized dynamically.
// BUT: User also can change "nzContent" dynamically to trigger UI changes (provided you don't use Component that needs initializations)
/**
* @param {?} changes
* @return {?}
*/
NzModalComponent.prototype.ngOnChanges =
// [NOTE] NOT available when using by service!
// Because ngOnChanges never be called when using by service,
// here we can't support "nzContent"(Component) etc. as inputs that initialized dynamically.
// BUT: User also can change "nzContent" dynamically to trigger UI changes (provided you don't use Component that needs initializations)
/**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.nzVisible) {
this.handleVisibleStateChange(this.nzVisible, !changes.nzVisible.firstChange); // Do not trigger animation while initializing
}
};
/**
* @return {?}
*/
NzModalComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
// If using Component, it is the time to attach View while bodyContainer is ready
if (this.contentComponentRef) {
this.bodyContainer.insert(this.contentComponentRef.hostView);
}
if (this.autoFocusButtonOk) {
((/** @type {?} */ (this.autoFocusButtonOk.nativeElement))).focus();
}
};
/**
* @return {?}
*/
NzModalComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
var _this = this;
// Close self before destructing
this.changeVisibleFromInside(false).then((/**
* @return {?}
*/
function () {
_this.modalControl.deregisterModal(_this);
if (_this.container instanceof overlay.OverlayRef) {
_this.container.dispose();
}
_this.unsubscribe$.next();
_this.unsubscribe$.complete();
}));
clearTimeout(this.timeoutId);
};
/**
* @param {?} templateRef
* @return {?}
*/
NzModalComponent.prototype.setFooterWithTemplate = /**
* @param {?} templateRef
* @return {?}
*/
function (templateRef) {
this.nzFooter = templateRef;
this.cdr.markForCheck();
};
/**
* @param {?} overlayRef
* @return {?}
*/
NzModalComponent.prototype.setOverlayRef = /**
* @param {?} overlayRef
* @return {?}
*/
function (overlayRef) {
this.overlayRef = overlayRef;
};
/**
* @param {?} event
* @return {?}
*/
NzModalComponent.prototype.keydownListener = /**
* @param {?} event
* @return {?}
*/
function (event) {
if (event.keyCode === keycodes.ESCAPE && this.nzKeyboard) {
this.onClickOkCancel('cancel');
}
};
/**
* @return {?}
*/
NzModalComponent.prototype.open = /**
* @return {?}
*/
function () {
this.changeVisibleFromInside(true);
};
/**
* @param {?=} result
* @return {?}
*/
NzModalComponent.prototype.close = /**
* @param {?=} result
* @return {?}
*/
function (result) {
this.changeVisibleFromInside(false, result);
};
/**
* @param {?=} result
* @return {?}
*/
NzModalComponent.prototype.destroy = /**
* @param {?=} result
* @return {?}
*/
function (result) {
// Destroy equals Close
this.close(result);
};
/**
* @return {?}
*/
NzModalComponent.prototype.triggerOk = /**
* @return {?}
*/
function () {
this.onClickOkCancel('ok');
};
/**
* @return {?}
*/
NzModalComponent.prototype.triggerCancel = /**
* @return {?}
*/
function () {
this.onClickOkCancel('cancel');
};
/**
* @return {?}
*/
NzModalComponent.prototype.getInstance = /**
* @return {?}
*/
function () {
return this;
};
/**
* @return {?}
*/
NzModalComponent.prototype.getContentComponentRef = /**
* @return {?}
*/
function () {
return this.contentComponentRef;
};
/**
* @return {?}
*/
NzModalComponent.prototype.getContentComponent = /**
* @return {?}
*/
function () {
return this.contentComponentRef && this.contentComponentRef.instance;
};
/**
* @return {?}
*/
NzModalComponent.prototype.getElement = /**
* @return {?}
*/
function () {
return this.elementRef && this.elementRef.nativeElement;
};
/**
* @return {?}
*/
NzModalComponent.prototype.onMaskDialogDown = /**
* @return {?}
*/
function () {
this.dialogMouseDown = true;
};
/**
* @return {?}
*/
NzModalComponent.prototype.onDialogUp = /**
* @return {?}
*/
function () {
var _this = this;
if (this.dialogMouseDown) {
this.timeoutId = setTimeout((/**
* @return {?}
*/
function () {
_this.dialogMouseDown = false;
}), 0);
}
};
/**
* @param {?} $event
* @return {?}
*/
NzModalComponent.prototype.onClickMask = /**
* @param {?} $event
* @return {?}
*/
function ($event) {
if (this.mask &&
this.maskClosable &&
((/** @type {?} */ ($event.target))).classList.contains(WRAP_CLASS_NAME) &&
this.nzVisible &&
!this.dialogMouseDown) {
this.onClickOkCancel('cancel');
}
};
/**
* @param {?} type
* @return {?}
*/
NzModalComponent.prototype.isModalType = /**
* @param {?} type
* @return {?}
*/
function (type) {
return this.nzModalType === type;
};
/**
* @return {?}
*/
NzModalComponent.prototype.onClickCloseBtn = /**
* @return {?}
*/
function () {
if (this.nzVisible) {
this.onClickOkCancel('cancel');
}
};
/**
* @param {?} type
* @return {?}
*/
NzModalComponent.prototype.onClickOkCancel = /**
* @param {?} type
* @return {?}
*/
function (type) {
var _this = this;
/** @type {?} */
var trigger = { ok: this.nzOnOk, cancel: this.nzOnCancel }[type];
/** @type {?} */
var loadingKey = { ok: 'nzOkLoading', cancel: 'nzCancelLoading' }[type];
if (trigger instanceof core.EventEmitter) {
trigger.emit(this.getContentComponent());
}
else if (typeof trigger === 'function') {
/** @type {?} */
var result = trigger(this.getContentComponent());
/** @type {?} */
var caseClose_1 = (/**
* @param {?} doClose
* @return {?}
*/
function (doClose) { return doClose !== false && _this.close((/** @type {?} */ (doClose))); });
if (core$1.isPromise(result)) {
this[loadingKey] = true;
/** @type {?} */
var handleThen = (/**
* @param {?} doClose
* @return {?}
*/
function (doClose) {
_this[loadingKey] = false;
caseClose_1(doClose);
});
((/** @type {?} */ (result))).then(handleThen).catch(handleThen);
}
else {
caseClose_1(result);
}
}
};
/**
* @param {?} value
* @return {?}
*/
NzModalComponent.prototype.isNonEmptyString = /**
* @param {?} value
* @return {?}
*/
function (value) {
return typeof value === 'string' && value !== '';
};
/**
* @param {?} value
* @return {?}
*/
NzModalComponent.prototype.isTemplateRef = /**
* @param {?} value
* @return {?}
*/
function (value) {
return value instanceof core.TemplateRef;
};
/**
* @param {?} value
* @return {?}
*/
NzModalComponent.prototype.isComponent = /**
* @param {?} value
* @return {?}
*/
function (value) {
return value instanceof core.Type;
};
/**
* @param {?} value
* @return {?}
*/
NzModalComponent.prototype.isModalButtons = /**
* @param {?} value
* @return {?}
*/
function (value) {
return Array.isArray(value) && value.length > 0;
};
// Do rest things when visible state changed
// Do rest things when visible state changed
/**
* @private
* @param {?} visible
* @param {?=} animation
* @param {?=} closeResult
* @return {?}
*/
NzModalComponent.prototype.handleVisibleStateChange =
// Do rest things when visible state changed
/**
* @private
* @param {?} visible
* @param {?=} animation
* @param {?=} closeResult
* @return {?}
*/
function (visible, animation, closeResult) {
var _this = this;
if (animation === void 0) { animation = true; }
if (visible) {
// Hide scrollbar at the first time when shown up
this.scrollStrategy.enable();
this.savePreviouslyFocusedElement();
this.trapFocus();
if (this.container instanceof overlay.OverlayRef) {
this.overlayKeyboardDispatcher.add(this.overlayRef);
}
}
else {
if (this.container instanceof overlay.OverlayRef) {
this.overlayKeyboardDispatcher.remove(this.overlayRef);
}
}
return Promise.resolve(animation ? this.animateTo(visible) : undefined).then((/**
* @return {?}
*/
function () {
// Emit open/close event after animations over
if (visible) {
_this.nzAfterOpen.emit();
}
else {
_this.nzAfterClose.emit(closeResult);
_this.restoreFocus();
_this.scrollStrategy.disable();
// Mark the for check so it can react if the view container is using OnPush change detection.
_this.cdr.markForCheck();
}
}));
};
// Lookup a button's property, if the prop is a function, call & then return the result, otherwise, return itself.
// Lookup a button's property, if the prop is a function, call & then return the result, otherwise, return itself.
/**
* @param {?} options
* @param {?} prop
* @return {?}
*/
NzModalComponent.prototype.getButtonCallableProp =
// Lookup a button's property, if the prop is a function, call & then return the result, otherwise, return itself.
/**
* @param {?} options
* @param {?} prop
* @return {?}
*/
function (options, prop) {
/** @type {?} */
var value = options[prop];
/** @type {?} */
var args = [];
if (this.contentComponentRef) {
args.push(this.contentComponentRef.instance);
}
return typeof value === 'function' ? value.apply(options, args) : value;
};
// On nzFooter's modal button click
// On nzFooter's modal button click
/**
* @param {?} button
* @return {?}
*/
NzModalComponent.prototype.onButtonClick =
// On nzFooter's modal button click
/**
* @param {?} button
* @return {?}
*/
function (button) {
/** @type {?} */
var result = this.getButtonCallableProp(button, 'onClick');
if (core$1.isPromise(result)) {
button.loading = true;
((/** @type {?} */ (result))).then((/**
* @return {?}
*/
function () { return (button.loading = false); })).catch((/**
* @return {?}
*/
function () { return (button.loading = false); }));
}
};
// Change nzVisible from inside
// Change nzVisible from inside
/**
* @private
* @param {?} visible
* @param {?=} closeResult
* @return {?}
*/
NzModalComponent.prototype.changeVisibleFromInside =
// Change nzVisible from inside
/**
* @private
* @param {?} visible
* @param {?=} closeResult
* @return {?}
*/
function (visible, closeResult) {
if (this.nzVisible !== visible) {
// Change nzVisible value immediately
this.nzVisible = visible;
this.nzVisibleChange.emit(visible);
return this.handleVisibleStateChange(visible, true, closeResult);
}
return Promise.resolve();
};
/**
* @private
* @param {?} state
* @return {?}
*/
NzModalComponent.prototype.changeAnimationState = /**
* @private
* @param {?} state
* @return {?}
*/
function (state) {
var _a, _b;
this.animationState = state;
if (state) {
this.maskAnimationClassMap = (_a = {},
_a["fade-" + state] = true,
_a["fade-" + state + "-active"] = true,
_a);
this.modalAnimationClassMap = (_b = {},
_b["zoom-" + state] = true,
_b["zoom-" + state + "-active"] = true,
_b);
}
else {
this.maskAnimationClassMap = this.modalAnimationClassMap = null;
}
};
/**
* @private
* @param {?} isVisible
* @return {?}
*/
NzModalComponent.prototype.animateTo = /**
* @private
* @param {?} isVisible
* @return {?}
*/
function (isVisible) {
var _this = this;
if (isVisible) {
// Figure out the lastest click position when shows up
s