| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- import { __decorate, __metadata } from 'tslib';
- import { Injectable, Component, ChangeDetectionStrategy, ChangeDetectorRef, Input, Output, EventEmitter, NgModule } from '@angular/core';
- import { OnChange } from 'ngx-bootstrap/utils';
- import { CommonModule } from '@angular/common';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var AlertConfig = /** @class */ (function () {
- function AlertConfig() {
- /**
- * default alert type
- */
- this.type = 'warning';
- /**
- * is alerts are dismissible by default
- */
- this.dismissible = false;
- /**
- * default time before alert will dismiss
- */
- this.dismissOnTimeout = undefined;
- }
- AlertConfig.decorators = [
- { type: Injectable }
- ];
- return AlertConfig;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var AlertComponent = /** @class */ (function () {
- function AlertComponent(_config, changeDetection) {
- var _this = this;
- this.changeDetection = changeDetection;
- /**
- * Alert type.
- * Provides one of four bootstrap supported contextual classes:
- * `success`, `info`, `warning` and `danger`
- */
- this.type = 'warning';
- /**
- * If set, displays an inline "Close" button
- */
- this.dismissible = false;
- /**
- * Is alert visible
- */
- this.isOpen = true;
- /**
- * This event fires immediately after close instance method is called,
- * $event is an instance of Alert component.
- */
- this.onClose = new EventEmitter();
- /**
- * This event fires when alert closed, $event is an instance of Alert component
- */
- this.onClosed = new EventEmitter();
- this.classes = '';
- this.dismissibleChange = new EventEmitter();
- Object.assign(this, _config);
- this.dismissibleChange.subscribe((/**
- * @param {?} dismissible
- * @return {?}
- */
- function (dismissible) {
- _this.classes = _this.dismissible ? 'alert-dismissible' : '';
- _this.changeDetection.markForCheck();
- }));
- }
- /**
- * @return {?}
- */
- AlertComponent.prototype.ngOnInit = /**
- * @return {?}
- */
- function () {
- var _this = this;
- if (this.dismissOnTimeout) {
- // if dismissOnTimeout used as attr without binding, it will be a string
- setTimeout((/**
- * @return {?}
- */
- function () { return _this.close(); }), parseInt((/** @type {?} */ (this.dismissOnTimeout)), 10));
- }
- };
- // todo: animation ` If the .fade and .in classes are present on the element,
- // the alert will fade out before it is removed`
- /**
- * Closes an alert by removing it from the DOM.
- */
- // todo: animation ` If the .fade and .in classes are present on the element,
- // the alert will fade out before it is removed`
- /**
- * Closes an alert by removing it from the DOM.
- * @return {?}
- */
- AlertComponent.prototype.close =
- // todo: animation ` If the .fade and .in classes are present on the element,
- // the alert will fade out before it is removed`
- /**
- * Closes an alert by removing it from the DOM.
- * @return {?}
- */
- function () {
- if (!this.isOpen) {
- return;
- }
- this.onClose.emit(this);
- this.isOpen = false;
- this.changeDetection.markForCheck();
- this.onClosed.emit(this);
- };
- AlertComponent.decorators = [
- { type: Component, args: [{
- selector: 'alert,bs-alert',
- template: "<ng-template [ngIf]=\"isOpen\">\n <div [class]=\"'alert alert-' + type\" role=\"alert\" [ngClass]=\"classes\">\n <ng-template [ngIf]=\"dismissible\">\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"close()\">\n <span aria-hidden=\"true\">×</span>\n <span class=\"sr-only\">Close</span>\n </button>\n </ng-template>\n <ng-content></ng-content>\n </div>\n</ng-template>\n",
- changeDetection: ChangeDetectionStrategy.OnPush
- }] }
- ];
- /** @nocollapse */
- AlertComponent.ctorParameters = function () { return [
- { type: AlertConfig },
- { type: ChangeDetectorRef }
- ]; };
- AlertComponent.propDecorators = {
- type: [{ type: Input }],
- dismissible: [{ type: Input }],
- dismissOnTimeout: [{ type: Input }],
- isOpen: [{ type: Input }],
- onClose: [{ type: Output }],
- onClosed: [{ type: Output }]
- };
- __decorate([
- OnChange(),
- __metadata("design:type", Object)
- ], AlertComponent.prototype, "dismissible", void 0);
- return AlertComponent;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var AlertModule = /** @class */ (function () {
- function AlertModule() {
- }
- /**
- * @return {?}
- */
- AlertModule.forRoot = /**
- * @return {?}
- */
- function () {
- return { ngModule: AlertModule, providers: [AlertConfig] };
- };
- AlertModule.decorators = [
- { type: NgModule, args: [{
- imports: [CommonModule],
- declarations: [AlertComponent],
- exports: [AlertComponent],
- entryComponents: [AlertComponent]
- },] }
- ];
- return AlertModule;
- }());
- export { AlertComponent, AlertConfig, AlertModule };
- //# sourceMappingURL=ngx-bootstrap-alert.js.map
|