ngx-bootstrap-alert.umd.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-bootstrap/utils'), require('@angular/common')) :
  3. typeof define === 'function' && define.amd ? define('ngx-bootstrap/alert', ['exports', '@angular/core', 'ngx-bootstrap/utils', '@angular/common'], factory) :
  4. (global = global || self, factory((global['ngx-bootstrap'] = global['ngx-bootstrap'] || {}, global['ngx-bootstrap'].alert = {}), global.ng.core, global.utils, global.ng.common));
  5. }(this, function (exports, core, utils, common) { 'use strict';
  6. /*! *****************************************************************************
  7. Copyright (c) Microsoft Corporation. All rights reserved.
  8. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  9. this file except in compliance with the License. You may obtain a copy of the
  10. License at http://www.apache.org/licenses/LICENSE-2.0
  11. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  12. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  13. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  14. MERCHANTABLITY OR NON-INFRINGEMENT.
  15. See the Apache Version 2.0 License for specific language governing permissions
  16. and limitations under the License.
  17. ***************************************************************************** */
  18. function __decorate(decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. 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;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. }
  24. function __metadata(metadataKey, metadataValue) {
  25. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  26. }
  27. /**
  28. * @fileoverview added by tsickle
  29. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  30. */
  31. var AlertConfig = /** @class */ (function () {
  32. function AlertConfig() {
  33. /**
  34. * default alert type
  35. */
  36. this.type = 'warning';
  37. /**
  38. * is alerts are dismissible by default
  39. */
  40. this.dismissible = false;
  41. /**
  42. * default time before alert will dismiss
  43. */
  44. this.dismissOnTimeout = undefined;
  45. }
  46. AlertConfig.decorators = [
  47. { type: core.Injectable }
  48. ];
  49. return AlertConfig;
  50. }());
  51. /**
  52. * @fileoverview added by tsickle
  53. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  54. */
  55. var AlertComponent = /** @class */ (function () {
  56. function AlertComponent(_config, changeDetection) {
  57. var _this = this;
  58. this.changeDetection = changeDetection;
  59. /**
  60. * Alert type.
  61. * Provides one of four bootstrap supported contextual classes:
  62. * `success`, `info`, `warning` and `danger`
  63. */
  64. this.type = 'warning';
  65. /**
  66. * If set, displays an inline "Close" button
  67. */
  68. this.dismissible = false;
  69. /**
  70. * Is alert visible
  71. */
  72. this.isOpen = true;
  73. /**
  74. * This event fires immediately after close instance method is called,
  75. * $event is an instance of Alert component.
  76. */
  77. this.onClose = new core.EventEmitter();
  78. /**
  79. * This event fires when alert closed, $event is an instance of Alert component
  80. */
  81. this.onClosed = new core.EventEmitter();
  82. this.classes = '';
  83. this.dismissibleChange = new core.EventEmitter();
  84. Object.assign(this, _config);
  85. this.dismissibleChange.subscribe((/**
  86. * @param {?} dismissible
  87. * @return {?}
  88. */
  89. function (dismissible) {
  90. _this.classes = _this.dismissible ? 'alert-dismissible' : '';
  91. _this.changeDetection.markForCheck();
  92. }));
  93. }
  94. /**
  95. * @return {?}
  96. */
  97. AlertComponent.prototype.ngOnInit = /**
  98. * @return {?}
  99. */
  100. function () {
  101. var _this = this;
  102. if (this.dismissOnTimeout) {
  103. // if dismissOnTimeout used as attr without binding, it will be a string
  104. setTimeout((/**
  105. * @return {?}
  106. */
  107. function () { return _this.close(); }), parseInt((/** @type {?} */ (this.dismissOnTimeout)), 10));
  108. }
  109. };
  110. // todo: animation ` If the .fade and .in classes are present on the element,
  111. // the alert will fade out before it is removed`
  112. /**
  113. * Closes an alert by removing it from the DOM.
  114. */
  115. // todo: animation ` If the .fade and .in classes are present on the element,
  116. // the alert will fade out before it is removed`
  117. /**
  118. * Closes an alert by removing it from the DOM.
  119. * @return {?}
  120. */
  121. AlertComponent.prototype.close =
  122. // todo: animation ` If the .fade and .in classes are present on the element,
  123. // the alert will fade out before it is removed`
  124. /**
  125. * Closes an alert by removing it from the DOM.
  126. * @return {?}
  127. */
  128. function () {
  129. if (!this.isOpen) {
  130. return;
  131. }
  132. this.onClose.emit(this);
  133. this.isOpen = false;
  134. this.changeDetection.markForCheck();
  135. this.onClosed.emit(this);
  136. };
  137. AlertComponent.decorators = [
  138. { type: core.Component, args: [{
  139. selector: 'alert,bs-alert',
  140. 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\">&times;</span>\n <span class=\"sr-only\">Close</span>\n </button>\n </ng-template>\n <ng-content></ng-content>\n </div>\n</ng-template>\n",
  141. changeDetection: core.ChangeDetectionStrategy.OnPush
  142. }] }
  143. ];
  144. /** @nocollapse */
  145. AlertComponent.ctorParameters = function () { return [
  146. { type: AlertConfig },
  147. { type: core.ChangeDetectorRef }
  148. ]; };
  149. AlertComponent.propDecorators = {
  150. type: [{ type: core.Input }],
  151. dismissible: [{ type: core.Input }],
  152. dismissOnTimeout: [{ type: core.Input }],
  153. isOpen: [{ type: core.Input }],
  154. onClose: [{ type: core.Output }],
  155. onClosed: [{ type: core.Output }]
  156. };
  157. __decorate([
  158. utils.OnChange(),
  159. __metadata("design:type", Object)
  160. ], AlertComponent.prototype, "dismissible", void 0);
  161. return AlertComponent;
  162. }());
  163. /**
  164. * @fileoverview added by tsickle
  165. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  166. */
  167. var AlertModule = /** @class */ (function () {
  168. function AlertModule() {
  169. }
  170. /**
  171. * @return {?}
  172. */
  173. AlertModule.forRoot = /**
  174. * @return {?}
  175. */
  176. function () {
  177. return { ngModule: AlertModule, providers: [AlertConfig] };
  178. };
  179. AlertModule.decorators = [
  180. { type: core.NgModule, args: [{
  181. imports: [common.CommonModule],
  182. declarations: [AlertComponent],
  183. exports: [AlertComponent],
  184. entryComponents: [AlertComponent]
  185. },] }
  186. ];
  187. return AlertModule;
  188. }());
  189. exports.AlertComponent = AlertComponent;
  190. exports.AlertConfig = AlertConfig;
  191. exports.AlertModule = AlertModule;
  192. Object.defineProperty(exports, '__esModule', { value: true });
  193. }));
  194. //# sourceMappingURL=ngx-bootstrap-alert.umd.js.map