ngx-modialog-7
Version:
Modal / Dialog for Angular
1,090 lines (1,053 loc) • 42.9 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('@angular/core'), require('ngx-modialog-7'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('ngxModialog.plugins.vex', ['exports', 'rxjs', '@angular/core', 'ngx-modialog-7', '@angular/common'], factory) :
(global = global || self, factory((global.ngxModialog = global.ngxModialog || {}, global.ngxModialog.plugins = global.ngxModialog.plugins || {}, global.ngxModialog.plugins.vex = {}), global.rxjs, global.ng.core, global.ngxModialog, global.ng.common));
}(this, (function (exports, rxjs, core, ngxModialog7, common) { '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: lib/dialog-form-modal.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function VEXButtonHandler() { }
/**
* Interface for button definition
* @record
*/
function VEXButtonConfig() { }
if (false) {
/** @type {?} */
VEXButtonConfig.prototype.cssClass;
/** @type {?} */
VEXButtonConfig.prototype.caption;
/** @type {?} */
VEXButtonConfig.prototype.onClick;
}
/**
* @record
*/
function VEXButtonClickEvent() { }
if (false) {
/** @type {?} */
VEXButtonClickEvent.prototype.btn;
/** @type {?} */
VEXButtonClickEvent.prototype.$event;
}
/**
* A Dialog is a
*/
var VEXDialogButtons = /** @class */ (function () {
function VEXDialogButtons() {
/**
* Emitted when a button was clicked
*/
this.onButtonClick = new core.EventEmitter();
}
/**
* @param {?} btn
* @param {?} $event
* @return {?}
*/
VEXDialogButtons.prototype.onClick = /**
* @param {?} btn
* @param {?} $event
* @return {?}
*/
function (btn, $event) {
$event.stopPropagation();
this.onButtonClick.emit({ btn: btn, $event: $event });
};
VEXDialogButtons.decorators = [
{ type: core.Component, args: [{
selector: 'vex-dialog-buttons',
encapsulation: core.ViewEncapsulation.None,
template: "<div class=\"vex-dialog-buttons\">\n <button type=\"button\"\n *ngFor=\"let btn of buttons;\"\n [class]=\"btn.cssClass\"\n (click)=\"onClick(btn, $event)\">{{btn.caption}}</button>\n</div>"
}] }
];
VEXDialogButtons.propDecorators = {
buttons: [{ type: core.Input }],
onButtonClick: [{ type: core.Output }]
};
return VEXDialogButtons;
}());
if (false) {
/**
* A collection of button configurations, each configuration is a button to display.
* @type {?}
*/
VEXDialogButtons.prototype.buttons;
/**
* Emitted when a button was clicked
* @type {?}
*/
VEXDialogButtons.prototype.onButtonClick;
}
/**
* A Dialog with customized buttons wrapped in a form.
*
*/
var DialogFormModal = /** @class */ (function () {
function DialogFormModal(dialog) {
this.dialog = dialog;
this.context = dialog.context;
}
/**
* @param {?} $event
* @return {?}
*/
DialogFormModal.prototype.onButtonClick = /**
* @param {?} $event
* @return {?}
*/
function ($event) {
$event.btn.onClick(this, $event.$event);
};
DialogFormModal.decorators = [
{ type: core.Component, args: [{
selector: 'modal-dialog',
encapsulation: core.ViewEncapsulation.None,
template: "<form class=\"vex-dialog-form\">\n <ng-container *ngComponentOutlet=\"context.content\"></ng-container>\n <vex-dialog-buttons [buttons]=\"context.buttons\"\n (onButtonClick)=\"onButtonClick($event)\"></vex-dialog-buttons>\n</form>"
}] }
];
/** @nocollapse */
DialogFormModal.ctorParameters = function () { return [
{ type: ngxModialog7.DialogRef }
]; };
return DialogFormModal;
}());
if (false) {
/** @type {?} */
DialogFormModal.prototype.context;
/** @type {?} */
DialogFormModal.prototype.dialog;
}
var FormDropIn = /** @class */ (function () {
function FormDropIn(dialog) {
this.dialog = dialog;
this.context = dialog.context;
}
FormDropIn.decorators = [
{ type: core.Component, args: [{
selector: 'drop-in-dialog',
encapsulation: core.ViewEncapsulation.None,
template: "<div class=\"vex-dialog-message\">{{context.message}}</div>\n <div *ngIf=\"context.showInput\" class=\"vex-dialog-input\">\n <input #input\n autofocus\n name=\"vex\"\n type=\"text\"\n class=\"vex-dialog-prompt-input\"\n (change)=\"context.defaultResult = input.value\"\n placeholder=\"{{context.placeholder}}\">\n </div>\n <div *ngIf=\"context.showCloseButton\"\n [class]=\"context.closeClassName\"\n (click)=\"dialog.dismiss()\"></div>"
}] }
];
/** @nocollapse */
FormDropIn.ctorParameters = function () { return [
{ type: ngxModialog7.DialogRef }
]; };
return FormDropIn;
}());
if (false) {
/** @type {?} */
FormDropIn.prototype.context;
/** @type {?} */
FormDropIn.prototype.dialog;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/modal-context.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var DEFAULT_VALUES = {
className: (/** @type {?} */ ('default')),
overlayClassName: 'vex-overlay',
contentClassName: 'vex-content',
closeClassName: 'vex-close'
};
/** @type {?} */
var DEFAULT_SETTERS = [
'className',
'overlayClassName',
'contentClassName',
'closeClassName',
'showCloseButton'
];
var VEXModalContext = /** @class */ (function (_super) {
__extends(VEXModalContext, _super);
function VEXModalContext() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @return {?}
*/
VEXModalContext.prototype.normalize = /**
* @return {?}
*/
function () {
if (!this.className) {
this.className = DEFAULT_VALUES.className;
}
if (!this.overlayClassName) {
this.overlayClassName = DEFAULT_VALUES.overlayClassName;
}
if (!this.contentClassName) {
this.contentClassName = DEFAULT_VALUES.contentClassName;
}
if (!this.closeClassName) {
this.closeClassName = DEFAULT_VALUES.closeClassName;
}
_super.prototype.normalize.call(this);
};
return VEXModalContext;
}(ngxModialog7.ModalOpenContext));
if (false) {
/**
* Set the built in schema to use.
* @type {?}
*/
VEXModalContext.prototype.className;
/** @type {?} */
VEXModalContext.prototype.overlayClassName;
/** @type {?} */
VEXModalContext.prototype.contentClassName;
/** @type {?} */
VEXModalContext.prototype.closeClassName;
/** @type {?} */
VEXModalContext.prototype.showCloseButton;
}
/**
* @template T
*/
var /**
* @template T
*/
VEXModalContextBuilder = /** @class */ (function (_super) {
__extends(VEXModalContextBuilder, _super);
function VEXModalContextBuilder(defaultValues, initialSetters, baseType) {
if (defaultValues === void 0) { defaultValues = undefined; }
if (initialSetters === void 0) { initialSetters = undefined; }
if (baseType === void 0) { baseType = undefined; }
return _super.call(this, ngxModialog7.extend(DEFAULT_VALUES, defaultValues || {}), ngxModialog7.arrayUnion(DEFAULT_SETTERS, initialSetters || []), baseType || (/** @type {?} */ (VEXModalContext)) // https://github.com/Microsoft/TypeScript/issues/7234
) || this;
}
/**
*
* @aliasFor isBlocking
*/
/**
*
* \@aliasFor isBlocking
* @template THIS
* @this {THIS}
* @param {?} value
* @return {THIS}
*/
VEXModalContextBuilder.prototype.overlayClosesOnClick = /**
*
* \@aliasFor isBlocking
* @template THIS
* @this {THIS}
* @param {?} value
* @return {THIS}
*/
function (value) {
(/** @type {?} */ (this))[ngxModialog7.privateKey('isBlocking')] = !value;
return (/** @type {?} */ (this));
};
return VEXModalContextBuilder;
}(ngxModialog7.ModalOpenContextBuilder));
if (false) {
/**
* Set the built in schema to use.
* @type {?}
*/
VEXModalContextBuilder.prototype.className;
/** @type {?} */
VEXModalContextBuilder.prototype.overlayClassName;
/** @type {?} */
VEXModalContextBuilder.prototype.contentClassName;
/** @type {?} */
VEXModalContextBuilder.prototype.closeClassName;
/** @type {?} */
VEXModalContextBuilder.prototype.showCloseButton;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/presets/dialog-preset.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var DEFAULT_SETTERS$1 = [
'content'
];
/**
* Data definition
*/
var /**
* Data definition
*/
DialogPreset = /** @class */ (function (_super) {
__extends(DialogPreset, _super);
function DialogPreset() {
return _super !== null && _super.apply(this, arguments) || this;
}
return DialogPreset;
}(VEXModalContext));
if (false) {
/** @type {?} */
DialogPreset.prototype.defaultResult;
/** @type {?} */
DialogPreset.prototype.content;
/** @type {?} */
DialogPreset.prototype.buttons;
/** @type {?} */
DialogPreset.prototype.showInput;
}
/**
* A Preset representing the configuration needed to open MessageModal.
* This is an abstract implementation with no concrete behaviour.
* Use derived implementation.
* @template T
*/
var /**
* A Preset representing the configuration needed to open MessageModal.
* This is an abstract implementation with no concrete behaviour.
* Use derived implementation.
* @template T
*/
DialogPresetBuilder = /** @class */ (function (_super) {
__extends(DialogPresetBuilder, _super);
function DialogPresetBuilder(modal, defaultValues, initialSetters, baseType) {
if (defaultValues === void 0) { defaultValues = undefined; }
if (initialSetters === void 0) { initialSetters = undefined; }
if (baseType === void 0) { baseType = undefined; }
return _super.call(this, ngxModialog7.extend({ modal: modal, component: DialogFormModal, buttons: [], defaultResult: true }, defaultValues || {}), ngxModialog7.arrayUnion(DEFAULT_SETTERS$1, initialSetters || []), baseType || (/** @type {?} */ (DialogPreset)) // https://github.com/Microsoft/TypeScript/issues/7234
) || this;
}
/**
* @template THIS
* @this {THIS}
* @param {?} css
* @param {?} caption
* @param {?} onClick
* @return {THIS}
*/
DialogPresetBuilder.prototype.addButton = /**
* @template THIS
* @this {THIS}
* @param {?} css
* @param {?} caption
* @param {?} onClick
* @return {THIS}
*/
function (css, caption, onClick) {
/** @type {?} */
var btn = {
cssClass: css,
caption: caption,
onClick: onClick
};
/** @type {?} */
var key = ngxModialog7.privateKey('buttons');
((/** @type {?} */ ((/** @type {?} */ (this))[key]))).push(btn);
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?=} text
* @return {THIS}
*/
DialogPresetBuilder.prototype.addOkButton = /**
* @template THIS
* @this {THIS}
* @param {?=} text
* @return {THIS}
*/
function (text) {
if (text === void 0) { text = 'OK'; }
(/** @type {?} */ (this)).addButton('vex-dialog-button-primary vex-dialog-button vex-first', text, (/**
* @param {?} cmp
* @param {?} $event
* @return {?}
*/
function (cmp, $event) { return cmp.dialog.close(cmp.dialog.context.defaultResult); }));
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?=} text
* @return {THIS}
*/
DialogPresetBuilder.prototype.addCancelButton = /**
* @template THIS
* @this {THIS}
* @param {?=} text
* @return {THIS}
*/
function (text) {
if (text === void 0) { text = 'CANCEL'; }
(/** @type {?} */ (this)).addButton('vex-dialog-button-secondary vex-dialog-button vex-last', text, (/**
* @param {?} cmp
* @param {?} $event
* @return {?}
*/
function (cmp, $event) { return cmp.dialog.dismiss(); }));
return (/** @type {?} */ (this));
};
return DialogPresetBuilder;
}(VEXModalContextBuilder));
if (false) {
/**
* the message to display on the modal.
* @type {?}
*/
DialogPresetBuilder.prototype.content;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/presets/dropin-preset.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var DEFAULT_VALUES$1 = {
component: DialogFormModal,
content: FormDropIn,
okBtn: 'OK',
cancelBtn: 'Cancel'
};
/** @type {?} */
var DEFAULT_SETTERS$2 = [
'okBtn',
'cancelBtn',
'placeholder'
];
/**
* Data definition
*/
var /**
* Data definition
*/
DropInPreset = /** @class */ (function (_super) {
__extends(DropInPreset, _super);
function DropInPreset() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(DropInPreset.prototype, "showInput", {
get: /**
* @return {?}
*/
function () {
return this.dropInType === ngxModialog7.DROP_IN_TYPE.prompt;
},
enumerable: true,
configurable: true
});
return DropInPreset;
}(DialogPreset));
if (false) {
/**
* the message to display on the modal.
* @type {?}
*/
DropInPreset.prototype.message;
/**
* OK button caption.
* Default: OK
* Set to false ('', undefined, null, false) to remove button.
* @type {?}
*/
DropInPreset.prototype.okBtn;
/**
* Cancel button caption.
* Default: Cancel
* Set to false ('', undefined, null, false) to remove button.
* @type {?}
*/
DropInPreset.prototype.cancelBtn;
/**
* A placeholder for the input element.
* Valid only for prompt modal.
* @type {?}
*/
DropInPreset.prototype.placeholder;
/** @type {?} */
DropInPreset.prototype.dropInType;
}
/**
* A Preset representing all 3 drop ins (alert, prompt, confirm)
*/
var /**
* A Preset representing all 3 drop ins (alert, prompt, confirm)
*/
DropInPresetBuilder = /** @class */ (function (_super) {
__extends(DropInPresetBuilder, _super);
function DropInPresetBuilder(modal, dropInType, defaultValues) {
if (defaultValues === void 0) { defaultValues = undefined; }
return _super.call(this, modal, ngxModialog7.extend(ngxModialog7.extend({ modal: modal, dropInType: dropInType }, DEFAULT_VALUES$1), defaultValues || {}), DEFAULT_SETTERS$2, DropInPreset) || this;
}
/**
* @param {?} config
* @return {?}
*/
DropInPresetBuilder.prototype.$$beforeOpen = /**
* @param {?} config
* @return {?}
*/
function (config) {
_super.prototype.$$beforeOpen.call(this, config);
if (config.okBtn) {
this.addOkButton(config.okBtn);
}
switch (config.dropInType) {
case ngxModialog7.DROP_IN_TYPE.prompt:
config.defaultResult = undefined;
break;
case ngxModialog7.DROP_IN_TYPE.confirm:
if (config.cancelBtn) {
this.addCancelButton(config.cancelBtn);
}
break;
}
};
return DropInPresetBuilder;
}(DialogPresetBuilder));
if (false) {
/**
* the message to display on the modal.
* @type {?}
*/
DropInPresetBuilder.prototype.message;
/**
* The default Ok button caption.
* @type {?}
*/
DropInPresetBuilder.prototype.okBtn;
/**
* The default Cancel button caption.
* @type {?}
*/
DropInPresetBuilder.prototype.cancelBtn;
/**
* A placeholder for the input element.
* Valid only for prompt modal.
* @type {?}
*/
DropInPresetBuilder.prototype.placeholder;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/vex-css-dialog-container.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A component that acts as a top level container for an open modal window.
*/
var VexCSSDialogContainer = /** @class */ (function (_super) {
__extends(VexCSSDialogContainer, _super);
function VexCSSDialogContainer() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} overlay
* @return {?}
*/
VexCSSDialogContainer.prototype.apply = /**
* @param {?} overlay
* @return {?}
*/
function (overlay) {
overlay.setClickBoundary(this.vexContentContainer.nativeElement);
if (this.dialog.inElement) {
this.setStyle('padding', '20px 0 0 0');
if (this.dialog.context.className === 'bottom-right-corner') {
this.setStyle('overflow-y', 'hidden');
this.renderer.setStyle(this.vexContentContainer.nativeElement, 'position', 'absolute');
}
}
};
VexCSSDialogContainer.decorators = [
{ type: core.Component, args: [{
selector: 'css-dialog-container',
host: {
'tabindex': '-1',
'role': 'dialog'
},
encapsulation: core.ViewEncapsulation.None,
template: "<div #clickBoundary class=\"{{dialog.context.contentClassName}}\"><ng-content></ng-content></div>"
}] }
];
VexCSSDialogContainer.propDecorators = {
vexContentContainer: [{ type: core.ViewChild, args: ['clickBoundary', { read: core.ElementRef, static: true },] }]
};
return VexCSSDialogContainer;
}(ngxModialog7.CSSDialogContainer));
if (false) {
/**
* The div that wraps the content of the modal, by default use the class `vex-content`
* @type {?}
*/
VexCSSDialogContainer.prototype.vexContentContainer;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/modal.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// TODO: use DI factory for this.
// TODO: consolidate dup code
/** @type {?} */
var isDoc = !(typeof document === 'undefined' || !document);
/** @type {?} */
var vexV3 = false;
/**
* Execute this method to flag that you are working with VEX version 3.
* @return {?}
*/
function vexV3Mode() {
vexV3 = true;
}
var Modal = /** @class */ (function (_super) {
__extends(Modal, _super);
function Modal(overlay) {
return _super.call(this, overlay) || this;
}
/**
* @return {?}
*/
Modal.prototype.alert = /**
* @return {?}
*/
function () {
return new DropInPresetBuilder(this, ngxModialog7.DROP_IN_TYPE.alert, (/** @type {?} */ ({ isBlocking: false })));
};
/**
* @return {?}
*/
Modal.prototype.prompt = /**
* @return {?}
*/
function () {
return new DropInPresetBuilder(this, ngxModialog7.DROP_IN_TYPE.prompt, (/** @type {?} */ ({
isBlocking: true,
keyboard: null
})));
};
/**
* @return {?}
*/
Modal.prototype.confirm = /**
* @return {?}
*/
function () {
return new DropInPresetBuilder(this, ngxModialog7.DROP_IN_TYPE.confirm, (/** @type {?} */ ({
isBlocking: true,
keyboard: null
})));
};
/**
* @protected
* @param {?} dialogRef
* @param {?} content
* @return {?}
*/
Modal.prototype.create = /**
* @protected
* @param {?} dialogRef
* @param {?} content
* @return {?}
*/
function (dialogRef, content) {
var _this = this;
if (vexV3 === true) {
return this.createV3(dialogRef, content);
}
/** @type {?} */
var backdropRef = this.createBackdrop(dialogRef, ngxModialog7.CSSBackdrop);
/** @type {?} */
var containerRef = this.createContainer(dialogRef, VexCSSDialogContainer, content);
/** @type {?} */
var overlay = dialogRef.overlayRef.instance;
/** @type {?} */
var backdrop = backdropRef.instance;
/** @type {?} */
var container = containerRef.instance;
if (dialogRef.inElement) {
overlay.insideElement();
overlay.setContainerStyle('position', 'relative')
.setContainerStyle('height', '100%')
.setContainerStyle('width', '100%');
backdrop.setStyle('position', 'absolute')
.setStyle('display', 'block')
.setStyle('height', '100%')
.setStyle('width', '100%');
container.setStyle('position', 'relative')
.setStyle('display', 'block')
.setStyle('height', '100%')
.setStyle('width', '100%');
}
else {
overlay.fullscreen();
}
// add body class if this is the only dialog in the stack
if (isDoc && !document.body.classList.contains('vex-open')) {
document.body.classList.add('vex-open');
}
backdrop.addClass('vex-overlay');
container.addClass("vex vex-theme-" + dialogRef.context.className);
container.setStyle('display', 'block');
if (containerRef.location.nativeElement) {
containerRef.location.nativeElement.focus();
}
overlay.beforeDestroy((/**
* @return {?}
*/
function () {
backdrop.addClass('vex-closing');
container.addClass('vex-closing');
/** @type {?} */
var completer = new ngxModialog7.PromiseCompleter();
/** @type {?} */
var animationEnd$ = backdrop.myAnimationEnd$();
// TODO: the child element inside the container (vex-content) is the one with animation
// need to also wait for it to end, but this requires a reference to to it.
// the container itself is its parent, won't do.
// animationEnd$ = combineLatest.call(animationEnd$, container.myAnimationEnd$(), (s1, s2) => [s1,s2] );
animationEnd$.subscribe((/**
* @param {?} sources
* @return {?}
*/
function (sources) {
isDoc && _this.overlay.groupStackLength(dialogRef) === 1 && document.body.classList.remove('vex-open');
completer.resolve();
}));
return completer.promise;
}));
container.apply(overlay);
return dialogRef;
};
/**
* @private
* @param {?} dialogRef
* @param {?} content
* @return {?}
*/
Modal.prototype.createV3 = /**
* @private
* @param {?} dialogRef
* @param {?} content
* @return {?}
*/
function (dialogRef, content) {
var _this = this;
/** @type {?} */
var backdropRef = this.createBackdrop(dialogRef, ngxModialog7.CSSBackdrop);
/** @type {?} */
var containerRef = this.createContainer(dialogRef, ngxModialog7.CSSDialogContainer, content);
/** @type {?} */
var overlay = dialogRef.overlayRef.instance;
/** @type {?} */
var backdrop = backdropRef.instance;
/** @type {?} */
var container = containerRef.instance;
dialogRef.inElement ? overlay.insideElement() : overlay.fullscreen();
// add body class if this is the only dialog in the stack
if (isDoc && !document.body.classList.contains('vex-open')) {
document.body.classList.add('vex-open');
}
overlay.addClass("vex vex-theme-" + dialogRef.context.className);
backdrop.addClass('vex-overlay');
container.addClass(dialogRef.context.contentClassName);
container.setStyle('display', 'block');
if (dialogRef.inElement) {
overlay.setStyle('padding', '0');
container.setStyle('margin-top', '20px');
}
if (containerRef.location.nativeElement) {
containerRef.location.nativeElement.focus();
}
if (dialogRef.context.className === 'bottom-right-corner') {
overlay.setStyle('overflow-y', 'hidden');
container.setStyle('position', 'absolute');
}
overlay.beforeDestroy((/**
* @return {?}
*/
function () {
overlay.addClass('vex-closing');
/** @type {?} */
var completer = new ngxModialog7.PromiseCompleter();
/** @type {?} */
var animationEnd$ = container.myAnimationEnd$();
if (dialogRef.context.className !== 'bottom-right-corner') {
animationEnd$ = rxjs.combineLatest.call(animationEnd$, backdrop.myAnimationEnd$(), (/**
* @param {?} s1
* @param {?} s2
* @return {?}
*/
function (s1, s2) { return [s1, s2]; }));
}
animationEnd$.subscribe((/**
* @param {?} sources
* @return {?}
*/
function (sources) {
isDoc && _this.overlay.groupStackLength(dialogRef) === 1 && document.body.classList.remove('vex-open');
completer.resolve();
}));
return completer.promise;
}));
overlay.setClickBoundary(containerRef.location.nativeElement);
return dialogRef;
};
Modal.decorators = [
{ type: core.Injectable }
];
/** @nocollapse */
Modal.ctorParameters = function () { return [
{ type: ngxModialog7.Overlay }
]; };
return Modal;
}(ngxModialog7.Modal));
/**
* @fileoverview added by tsickle
* Generated from: lib/vex.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var providers = [
{ provide: ngxModialog7.Modal, useClass: Modal },
{ provide: Modal, useClass: Modal }
];
var VexModalModule = /** @class */ (function () {
function VexModalModule() {
}
/**
* @return {?}
*/
VexModalModule.getProviders = /**
* @return {?}
*/
function () {
return providers;
};
VexModalModule.decorators = [
{ type: core.NgModule, args: [{
imports: [ngxModialog7.ModalModule, common.CommonModule],
declarations: [
VexCSSDialogContainer,
VEXDialogButtons,
FormDropIn,
DialogFormModal
],
providers: providers,
entryComponents: [
VexCSSDialogContainer,
DialogFormModal,
FormDropIn
]
},] }
];
return VexModalModule;
}());
exports.DialogFormModal = DialogFormModal;
exports.DialogPreset = DialogPreset;
exports.DialogPresetBuilder = DialogPresetBuilder;
exports.DropInPreset = DropInPreset;
exports.DropInPresetBuilder = DropInPresetBuilder;
exports.FormDropIn = FormDropIn;
exports.Modal = Modal;
exports.VEXDialogButtons = VEXDialogButtons;
exports.VEXModalContext = VEXModalContext;
exports.VEXModalContextBuilder = VEXModalContextBuilder;
exports.VexModalModule = VexModalModule;
exports.providers = providers;
exports.vexV3Mode = vexV3Mode;
exports.ɵa = VexCSSDialogContainer;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=ngx-modialog-7-plugins-vex.umd.js.map