ngx-bootstrap-confirm
Version:
Bootstrap confirm provider for Angular 11+
89 lines (80 loc) • 3.9 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-bootstrap/modal'), require('rxjs')) :
typeof define === 'function' && define.amd ? define('ngx-bootstrap-confirm', ['exports', '@angular/core', 'ngx-bootstrap/modal', 'rxjs'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ngx-bootstrap-confirm'] = {}, global.ng.core, global.modal, global.rxjs));
}(this, (function (exports, core, modal, rxjs) { 'use strict';
var NgxBootstrapConfirmComponent = /** @class */ (function () {
function NgxBootstrapConfirmComponent(bsModalRef) {
this.bsModalRef = bsModalRef;
}
NgxBootstrapConfirmComponent.prototype.ngOnInit = function () {
this.onClose = new rxjs.Subject();
};
NgxBootstrapConfirmComponent.prototype.confirm = function () {
this.onClose.next(true);
this.bsModalRef.hide();
};
NgxBootstrapConfirmComponent.prototype.decline = function () {
this.onClose.next(false);
this.bsModalRef.hide();
};
return NgxBootstrapConfirmComponent;
}());
NgxBootstrapConfirmComponent.decorators = [
{ type: core.Component, args: [{
selector: 'lib-ngx-bootstrap-confirm',
template: "\n <div class=\"confirm modal-body\">\n <div class=\"content\" [innerHTML]=\"title\"></div>\n <div class=\"buttons\">\n <button type=\"button\" class=\"btn btn-success\" (click)=\"confirm()\" [innerHTML]=\"confirmLabel\"></button>\n <button type=\"button\" class=\"btn btn-danger\" (click)=\"decline()\" [innerHTML]=\"declineLabel\"></button>\n </div>\n </div>\n "
},] }
];
NgxBootstrapConfirmComponent.ctorParameters = function () { return [
{ type: modal.BsModalRef }
]; };
var NgxBootstrapConfirmService = /** @class */ (function () {
function NgxBootstrapConfirmService(modalService) {
this.modalService = modalService;
}
NgxBootstrapConfirmService.prototype.confirm = function (options) {
var _this = this;
return new Promise(function (resolve, reject) {
_this.modalRef = _this.modalService.show(NgxBootstrapConfirmComponent);
_this.modalRef.content.title = options.title;
_this.modalRef.content.confirmLabel = options.confirmLabel;
_this.modalRef.content.declineLabel = options.declineLabel;
_this.modalRef.content.onClose.subscribe(function (result) {
resolve(result);
});
});
};
return NgxBootstrapConfirmService;
}());
NgxBootstrapConfirmService.decorators = [
{ type: core.Injectable }
];
NgxBootstrapConfirmService.ctorParameters = function () { return [
{ type: modal.BsModalService }
]; };
var NgxBootstrapConfirmModule = /** @class */ (function () {
function NgxBootstrapConfirmModule() {
}
return NgxBootstrapConfirmModule;
}());
NgxBootstrapConfirmModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [NgxBootstrapConfirmComponent],
imports: [modal.ModalModule.forRoot()],
exports: [NgxBootstrapConfirmComponent],
providers: [NgxBootstrapConfirmService],
},] }
];
/*
* Public API Surface of ngx-bootstrap-confirm
*/
/**
* Generated bundle index. Do not edit.
*/
exports.NgxBootstrapConfirmComponent = NgxBootstrapConfirmComponent;
exports.NgxBootstrapConfirmModule = NgxBootstrapConfirmModule;
exports.NgxBootstrapConfirmService = NgxBootstrapConfirmService;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=ngx-bootstrap-confirm.umd.js.map