UNPKG

lamb-web-lib

Version:

LambWebLib. Es un proyecto angular de tipo Librería. que contiene una Suit de componentes reutilizables para el proyecto [Lamb Financial](https://lamb.upeu.edu.pe).

1,231 lines (1,203 loc) 395 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/router'), require('@angular/common'), require('rxjs/operators'), require('rxjs'), require('@angular/animations'), require('@angular/platform-browser'), require('@angular/forms')) : typeof define === 'function' && define.amd ? define('lamb-web-lib', ['exports', '@angular/core', '@angular/router', '@angular/common', 'rxjs/operators', 'rxjs', '@angular/animations', '@angular/platform-browser', '@angular/forms'], factory) : (factory((global['lamb-web-lib'] = {}),global.ng.core,global.ng.router,global.ng.common,global.rxjs.operators,global.rxjs,global.ng.animations,global.ng.platformBrowser,global.ng.forms)); }(this, (function (exports,i0,router,common,operators,rxjs,animations,platformBrowser,forms) { 'use strict'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambWebLibService = (function () { function LambWebLibService() { } LambWebLibService.decorators = [ { type: i0.Injectable, args: [{ providedIn: 'root' },] }, ]; LambWebLibService.ctorParameters = function () { return []; }; /** @nocollapse */ LambWebLibService.ngInjectableDef = i0.defineInjectable({ factory: function LambWebLibService_Factory() { return new LambWebLibService(); }, token: LambWebLibService, providedIn: "root" }); return LambWebLibService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambWebLibComponent = (function () { function LambWebLibComponent() { } /** * @return {?} */ LambWebLibComponent.prototype.ngOnInit = /** * @return {?} */ function () { }; LambWebLibComponent.decorators = [ { type: i0.Component, args: [{ selector: 'lamb-lamb-web-lib', template: "\n <p>\n lamb-web-lib works!\n </p>\n ", styles: [] },] }, ]; LambWebLibComponent.ctorParameters = function () { return []; }; return LambWebLibComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambWebLibModule = (function () { function LambWebLibModule() { } LambWebLibModule.decorators = [ { type: i0.NgModule, args: [{ imports: [], declarations: [LambWebLibComponent], exports: [LambWebLibComponent] },] }, ]; return LambWebLibModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambButtonBackComponent = (function () { // private pathBack: string; function LambButtonBackComponent(route, router$$1, location) { this.route = route; this.router = router$$1; this.location = location; this.flag = true; } /** * @return {?} */ LambButtonBackComponent.prototype.ngOnInit = /** * @return {?} */ function () { /** Estos dos metodos son para el flag. */ this.initShowOrHideFlag(); this.eventFlagSubscribe(); }; /** * @return {?} */ LambButtonBackComponent.prototype.initShowOrHideFlag = /** * @return {?} */ function () { /** @type {?} */ var pathEnd = this.pathEnd(this.location.path()); this.condition(pathEnd); }; /** * @return {?} */ LambButtonBackComponent.prototype.eventFlagSubscribe = /** * @return {?} */ function () { var _this = this; this.router.events.pipe(operators.filter(function (path) { return path instanceof router.NavigationEnd; })) .subscribe(function (path) { /** @type {?} */ var pathEnd = _this.pathEnd(path.url); _this.condition(pathEnd); }); }; /** * @param {?} path * @return {?} */ LambButtonBackComponent.prototype.pathEnd = /** * @param {?} path * @return {?} */ function (path) { /** @type {?} */ var paths = path.split('/') .filter(function (path2) { return path2 !== ''; }); return paths[paths.length - 1]; }; /** * @param {?} pathEnd * @return {?} */ LambButtonBackComponent.prototype.condition = /** * @param {?} pathEnd * @return {?} */ function (pathEnd) { /** @type {?} */ var url = this.route.snapshot.url; if (((url[0] && url[0].path) === pathEnd)) { this.flag = true; } else if (url[0] == null) { /** @type {?} */ var urlParent = this.route.parent.snapshot.url; if (((urlParent[urlParent.length - 1] && urlParent[urlParent.length - 1].path) === pathEnd)) { this.flag = true; } else { this.flag = false; } } else { this.flag = false; } }; /** * @return {?} */ LambButtonBackComponent.prototype.onBack = /** * @return {?} */ function () { /** @type {?} */ var url = this.route.snapshot.url; /** @type {?} */ var link = (url[0] && url[0].path) || ''; /** @type {?} */ var relativeUrl = link ? "../" + link : "./" + link; this.router.navigate([relativeUrl], { relativeTo: this.route }); }; LambButtonBackComponent.decorators = [ { type: i0.Component, args: [{ selector: 'lamb-button-back', template: "\n <a class=\"btn btn-light lamb-button\" [ngClass]=\"{'lamb-flag': flag}\" (click)=\"onBack()\">\n <span class=\"fa fa-reply\" > </span>\n </a>\n ", styles: [ "\n .lamb-flag {\n visibility: hidden;\n }\n .lamb-button {\n /* padding: 0.3rem 0.6rem; */\n padding: 0.1rem 0.3rem;\n cursor: pointer !important;\n border-radius: 50%;\n -webkit-transition: -webkit-transform .4s ease-in-out;\n transition: transform .4s ease-in-out;\n }\n .lamb-button:hover {\n -webkit-transform: rotate(-360deg);\n transform: rotate(-360deg)\n }\n ", ], },] }, ]; LambButtonBackComponent.ctorParameters = function () { return [ { type: router.ActivatedRoute }, { type: router.Router }, { type: common.Location } ]; }; return LambButtonBackComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambButtonBackModule = (function () { function LambButtonBackModule() { } LambButtonBackModule.decorators = [ { type: i0.NgModule, args: [{ imports: [ common.CommonModule, ], exports: [ LambButtonBackComponent, ], declarations: [ LambButtonBackComponent, ], providers: [], },] }, ]; return LambButtonBackModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambButtonIconComponent = (function () { function LambButtonIconComponent() { this.colorClass = 'btn-light'; this.icon = 'fa fa-plus-circle'; this.label = 'New'; this.size = 'lg'; } /** * @return {?} */ LambButtonIconComponent.prototype.ngOnInit = /** * @return {?} */ function () { }; LambButtonIconComponent.decorators = [ { type: i0.Component, args: [{ selector: 'lamb-button-icon', template: "<!-- <button class=\"btn lamb-btn-block btn-sm\" [title]=\"title || ''\" [routerLink]=\"routerLink\" [disabled]=\"isDisabled\"> -->\n<button class=\"btn lamb-btn-block btn-{{ size }} {{ colorClass }}\" [title]=\"title || ''\" [disabled]=\"isDisabled\">\n <span class=\"{{ icon }}\" [ngClass]=\"{'lamb-icon': !onlyIcon, 'lamb-text-black': (colorClass === 'btn-light') }\"></span>\n <span *ngIf=\"!onlyIcon\" [ngClass]=\"{'lamb-text-black': (colorClass === 'btn-light')}\"> {{ label }}</span>\n</button>", styles: [".lamb-icon{margin-right:3px}@media (max-width:550px){.lamb-btn-block{display:block;width:100%}}:host{display:flex;flex-direction:column;position:relative;height:100%}"] },] }, ]; LambButtonIconComponent.ctorParameters = function () { return []; }; LambButtonIconComponent.propDecorators = { colorClass: [{ type: i0.Input }], label: [{ type: i0.Input }], isDisabled: [{ type: i0.Input }], onlyIcon: [{ type: i0.Input }], icon: [{ type: i0.Input }], title: [{ type: i0.Input }], size: [{ type: i0.Input }] }; return LambButtonIconComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambButtonIconModule = (function () { function LambButtonIconModule() { } LambButtonIconModule.decorators = [ { type: i0.NgModule, args: [{ imports: [ common.CommonModule, ], declarations: [LambButtonIconComponent], exports: [LambButtonIconComponent], },] }, ]; return LambButtonIconModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambModalBackdropComponent = (function () { function LambModalBackdropComponent() { } Object.defineProperty(LambModalBackdropComponent.prototype, "modalClass", { get: /** * @return {?} */ function () { return 'modal-backdrop fade show'; }, enumerable: true, configurable: true }); LambModalBackdropComponent.decorators = [ { type: i0.Component, args: [{ selector: 'lamb-modal-backdrop', template: '', // host: { 'class': 'modal-backdrop fade show' }, styles: [], },] }, ]; LambModalBackdropComponent.ctorParameters = function () { return []; }; LambModalBackdropComponent.propDecorators = { modalClass: [{ type: i0.HostBinding, args: ['class',] }] }; return LambModalBackdropComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** @enum {number} */ var ModalDismissReasons = { BACKDROP_CLICK: 0, ESC: 1, }; ModalDismissReasons[ModalDismissReasons.BACKDROP_CLICK] = 'BACKDROP_CLICK'; ModalDismissReasons[ModalDismissReasons.ESC] = 'ESC'; /*! ***************************************************************************** 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. ***************************************************************************** */ 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 __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; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** @enum {number} */ var Key = { Tab: 9, Enter: 13, Escape: 27, Space: 32, PageUp: 33, PageDown: 34, End: 35, Home: 36, ArrowLeft: 37, ArrowUp: 38, ArrowRight: 39, ArrowDown: 40, }; Key[Key.Tab] = 'Tab'; Key[Key.Enter] = 'Enter'; Key[Key.Escape] = 'Escape'; Key[Key.Space] = 'Space'; Key[Key.PageUp] = 'PageUp'; Key[Key.PageDown] = 'PageDown'; Key[Key.End] = 'End'; Key[Key.Home] = 'Home'; Key[Key.ArrowLeft] = 'ArrowLeft'; Key[Key.ArrowUp] = 'ArrowUp'; Key[Key.ArrowRight] = 'ArrowRight'; Key[Key.ArrowDown] = 'ArrowDown'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** @type {?} */ var FOCUSABLE_ELEMENTS_SELECTOR = [ 'a[href]', 'button:not([disabled])', 'input:not([disabled]):not([type="hidden"])', 'select:not([disabled])', 'textarea:not([disabled])', '[contenteditable]', '[tabindex]:not([tabindex="-1"])' ].join(', '); /** * Returns first and last focusable elements inside of a given element based on specific CSS selector * @param {?} element * @return {?} */ function getFocusableBoundaryElements(element) { /** @type {?} */ var list = element.querySelectorAll(FOCUSABLE_ELEMENTS_SELECTOR); return [list[0], list[list.length - 1]]; } /** * Function that enforces browser focus to be trapped inside a DOM element. * * Works only for clicks inside the element and navigation with 'Tab', ignoring clicks outside of the element * * \@param element The element around which focus will be trapped inside * \@param stopFocusTrap$ The observable stream. When completed the focus trap will clean up listeners * and free internal resources * @type {?} */ var lambFocusTrap = function (element, stopFocusTrap$) { // last focused element /** @type {?} */ var lastFocusedElement$ = rxjs.fromEvent(element, 'focusin').pipe(operators.takeUntil(stopFocusTrap$), operators.map(function (e) { return e.target; })); // 'tab' / 'shift+tab' stream rxjs.fromEvent(element, 'keydown') .pipe(operators.takeUntil(stopFocusTrap$), operators.filter(function (e) { return e.which === Key.Tab; }), operators.withLatestFrom(lastFocusedElement$)) .subscribe(function (_a) { var _b = __read(_a, 2), tabEvent = _b[0], focusedElement = _b[1]; var _c = __read(getFocusableBoundaryElements(element), 2), first = _c[0], last = _c[1]; if (focusedElement === first && tabEvent.shiftKey) { last.focus(); tabEvent.preventDefault(); } if (focusedElement === last && !tabEvent.shiftKey) { first.focus(); tabEvent.preventDefault(); } }); // inside click rxjs.fromEvent(element, 'click') .pipe(operators.takeUntil(stopFocusTrap$), operators.withLatestFrom(lastFocusedElement$), operators.map(function (arr) { return ((arr[1])); })) .subscribe(function (lastFocusedElement) { return lastFocusedElement.focus(); }); }; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambModalWindowComponent = (function () { // @HostBinding('attr.role') // public role = 'dialog'; // @HostBinding('attr.tabindex') // public tabindex = '-1'; // @HostBinding('attr.style') // public style = 'display: block;'; function LambModalWindowComponent(document, _elRef, _renderer) { this._elRef = _elRef; this._renderer = _renderer; this.backdrop = true; this.keyboard = true; this.dismissEvent = new i0.EventEmitter(); this._document = document; lambFocusTrap(this._elRef.nativeElement, this.dismissEvent); } Object.defineProperty(LambModalWindowComponent.prototype, "modalClass", { get: /** * @return {?} */ function () { return 'modal fade show d-block' + (this.windowClass ? ' ' + this.windowClass : ''); }, enumerable: true, configurable: true }); /** * @param {?} $event * @return {?} */ LambModalWindowComponent.prototype.backdropClick = /** * @param {?} $event * @return {?} */ function ($event) { if (this.backdrop === true && this._elRef.nativeElement === $event.target) { this.dismiss(ModalDismissReasons.BACKDROP_CLICK); } }; /** * @param {?} $event * @return {?} */ LambModalWindowComponent.prototype.escKey = /** * @param {?} $event * @return {?} */ function ($event) { if (this.keyboard && !$event.defaultPrevented) { this.dismiss(ModalDismissReasons.ESC); } }; /** * @param {?} reason * @return {?} */ LambModalWindowComponent.prototype.dismiss = /** * @param {?} reason * @return {?} */ function (reason) { this.dismissEvent.emit(reason); }; /** * @return {?} */ LambModalWindowComponent.prototype.ngOnInit = /** * @return {?} */ function () { this._elWithFocus = this._document.activeElement; this._renderer.addClass(this._document.body, 'modal-open'); }; /** * @return {?} */ LambModalWindowComponent.prototype.ngAfterViewInit = /** * @return {?} */ function () { if (!this._elRef.nativeElement.contains(document.activeElement)) { this._elRef.nativeElement['focus'].apply(this._elRef.nativeElement, []); } }; /** * @return {?} */ LambModalWindowComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { /** @type {?} */ var body = this._document.body; /** @type {?} */ var elWithFocus = this._elWithFocus; /** @type {?} */ var elementToFocus; if (elWithFocus && elWithFocus['focus'] && body.contains(elWithFocus)) { elementToFocus = elWithFocus; } else { elementToFocus = body; } elementToFocus['focus'].apply(elementToFocus, []); this._elWithFocus = null; this._renderer.removeClass(body, 'modal-open'); }; LambModalWindowComponent.decorators = [ { type: i0.Component, args: [{ selector: 'lamb-modal-window', template: "\n <div\n [class]=\"'modal-dialog' + (size ? ' modal-' + size : '') + (centered ? ' modal-dialog-centered' : '')\"\n role=\"document\">\n <div class=\"modal-content\"><ng-content></ng-content></div>\n </div>\n ", host: { // '[class]': '"modal fade show" + (windowClass ? " " + windowClass : "")', 'role': 'dialog', 'tabindex': '-1', 'style': 'display: block;', }, },] }, ]; LambModalWindowComponent.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] }, { type: i0.ElementRef }, { type: i0.Renderer2 } ]; }; LambModalWindowComponent.propDecorators = { backdrop: [{ type: i0.Input }], keyboard: [{ type: i0.Input }], size: [{ type: i0.Input }], centered: [{ type: i0.Input }], windowClass: [{ type: i0.Input }], dismissEvent: [{ type: i0.Output }], modalClass: [{ type: i0.HostBinding, args: ['class',] }], backdropClick: [{ type: i0.HostListener, args: ['click', ['$event'],] }], escKey: [{ type: i0.HostListener, args: ['keyup.esc', ['$event'],] }] }; return LambModalWindowComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** * Una referencia a un modal activo (actualmente abierto). Instancias de esta clase * puede ser inyectado en componentes pasados ​​como contenido modal. */ var /** * Una referencia a un modal activo (actualmente abierto). Instancias de esta clase * puede ser inyectado en componentes pasados ​​como contenido modal. */ LambActiveModal = (function () { /** * Una referencia a un modal activo (actualmente abierto). Instancias de esta clase * puede ser inyectado en componentes pasados ​​como contenido modal. */ function LambActiveModal() { } /** * Se puede usar para cerrar un modal, pasando un resultado opcional. * @param reason rasultado. */ /** * Se puede usar para cerrar un modal, pasando un resultado opcional. * @param {?=} result * @return {?} */ LambActiveModal.prototype.close = /** * Se puede usar para cerrar un modal, pasando un resultado opcional. * @param {?=} result * @return {?} */ function (result) { }; /** * Se puede usar para descartar un modal, pasando un motivo opcional. * @param reason razon por que se descarto. */ /** * Se puede usar para descartar un modal, pasando un motivo opcional. * @param {?=} reason razon por que se descarto. * @return {?} */ LambActiveModal.prototype.dismiss = /** * Se puede usar para descartar un modal, pasando un motivo opcional. * @param {?=} reason razon por que se descarto. * @return {?} */ function (reason) { }; return LambActiveModal; }()); /** * Una referencia a un modal recientemente abierto. */ var /** * Una referencia a un modal recientemente abierto. */ LambModalRef = (function () { function LambModalRef(windowComponentRef, contentRef, backdropComponentRef, beforeDismiss) { var _this = this; this.windowComponentRef = windowComponentRef; this.contentRef = contentRef; this.backdropComponentRef = backdropComponentRef; this.beforeDismiss = beforeDismiss; windowComponentRef.instance.dismissEvent.subscribe(function (reason) { _this.dismiss(reason); }); this.result = new Promise(function (resolve, reject) { _this.resolve = resolve; _this.reject = reject; }); this.result.then(null, function () { }); } Object.defineProperty(LambModalRef.prototype, "componentInstance", { /** * La instancia de componente utilizada como contenido modal. * Indefinido cuando se utiliza un TemplateRef como contenido modal. */ get: /** * La instancia de componente utilizada como contenido modal. * Indefinido cuando se utiliza un TemplateRef como contenido modal. * @return {?} */ function () { if (this.contentRef.componentRef) { return this.contentRef.componentRef.instance; } }, // solo es necesario para mantener la compatibilidad con TS1.8 set: // solo es necesario para mantener la compatibilidad con TS1.8 /** * @param {?} instance * @return {?} */ function (instance) { }, enumerable: true, configurable: true }); /** * Se puede usar para cerrar un modal, pasando un resultado opcional. * @param result */ /** * Se puede usar para cerrar un modal, pasando un resultado opcional. * @param {?=} result * @return {?} */ LambModalRef.prototype.close = /** * Se puede usar para cerrar un modal, pasando un resultado opcional. * @param {?=} result * @return {?} */ function (result) { if (this.windowComponentRef) { this.resolve(result); this.removeModalElements(); } }; /** * Se puede usar para descartar un modal, pasando un motivo opcional. * @param reason */ /** * Se puede usar para descartar un modal, pasando un motivo opcional. * @param {?=} reason * @return {?} */ LambModalRef.prototype.dismiss = /** * Se puede usar para descartar un modal, pasando un motivo opcional. * @param {?=} reason * @return {?} */ function (reason) { // console.log('reason'); // console.log(reason); if (this.windowComponentRef) { if (!this.beforeDismiss || this.beforeDismiss() !== false) { this.reject(reason); this.removeModalElements(); } } }; /** * @return {?} */ LambModalRef.prototype.removeModalElements = /** * @return {?} */ function () { /** @type {?} */ var windowNativeEl = this.windowComponentRef.location.nativeElement; windowNativeEl.parentNode.removeChild(windowNativeEl); this.windowComponentRef.destroy(); if (this.backdropComponentRef) { /** @type {?} */ var backdropNativeEl = this.backdropComponentRef.location.nativeElement; backdropNativeEl.parentNode.removeChild(backdropNativeEl); this.backdropComponentRef.destroy(); } if (this.contentRef && this.contentRef.viewRef) { this.contentRef.viewRef.destroy(); } this.windowComponentRef = null; this.backdropComponentRef = null; this.contentRef = null; }; return LambModalRef; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** * @param {?} value * @return {?} */ function isDefined(value) { return value !== undefined && value !== null; } /** * @param {?} value * @return {?} */ function isString(value) { return typeof value === 'string'; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var ContentRef = (function () { function ContentRef(nodes, viewRef, componentRef) { this.nodes = nodes; this.viewRef = viewRef; this.componentRef = componentRef; } return ContentRef; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambModalStackService = (function () { function LambModalStackService(applicationRef, injector, componentFactoryResolver, document) { this.applicationRef = applicationRef; this.injector = injector; this.componentFactoryResolver = componentFactoryResolver; this._windowAttributes = ['backdrop', 'keyboard', 'centered', 'size', 'windowClass']; this._document = document; } /** * @param {?} moduleCFR * @param {?} contentInjector * @param {?} content * @param {?} options * @return {?} */ LambModalStackService.prototype.open = /** * @param {?} moduleCFR * @param {?} contentInjector * @param {?} content * @param {?} options * @return {?} */ function (moduleCFR, contentInjector, content, options) { /** @type {?} */ var containerEl = isDefined(options.container) ? this._document.querySelector(options.container) : this._document.body; if (!containerEl) { throw new Error("El contenedor modal especificado \"" + (options.container || 'body') + "\" no fue encontrado en el DOM"); } /** @type {?} */ var activeModal = new LambActiveModal(); /** @type {?} */ var contentRef = this.getContentRef(moduleCFR, options.injector || contentInjector, content, activeModal); /** @type {?} */ var backdropCmptRef = options.backdrop !== false ? this.attachBackdrop(containerEl) : null; /** @type {?} */ var windowCmptRef = this.attachWindowComponent(containerEl, contentRef); /** @type {?} */ var lambModalRef = new LambModalRef(windowCmptRef, contentRef, backdropCmptRef, options.beforeDismiss); activeModal.close = function (result) { lambModalRef.close(result); }; activeModal.dismiss = function (reason) { lambModalRef.dismiss(reason); }; this.applyWindowOptions(windowCmptRef.instance, options); return lambModalRef; }; /** * @param {?} containerEl * @return {?} */ LambModalStackService.prototype.attachBackdrop = /** * @param {?} containerEl * @return {?} */ function (containerEl) { /** @type {?} */ var backdropFactory = this.componentFactoryResolver.resolveComponentFactory(LambModalBackdropComponent); /** @type {?} */ var backdropCmptRef = backdropFactory.create(this.injector); this.applicationRef.attachView(backdropCmptRef.hostView); containerEl.appendChild(backdropCmptRef.location.nativeElement); return backdropCmptRef; }; /** * @param {?} containerEl * @param {?} contentRef * @return {?} */ LambModalStackService.prototype.attachWindowComponent = /** * @param {?} containerEl * @param {?} contentRef * @return {?} */ function (containerEl, contentRef) { /** @type {?} */ var windowFactory = this.componentFactoryResolver.resolveComponentFactory(LambModalWindowComponent); /** @type {?} */ var windowCmptRef = windowFactory.create(this.injector, contentRef.nodes); this.applicationRef.attachView(windowCmptRef.hostView); containerEl.appendChild(windowCmptRef.location.nativeElement); return windowCmptRef; }; /** * @param {?} windowInstance * @param {?} options * @return {?} */ LambModalStackService.prototype.applyWindowOptions = /** * @param {?} windowInstance * @param {?} options * @return {?} */ function (windowInstance, options) { this._windowAttributes.forEach(function (optionName) { if (isDefined(options[optionName])) { windowInstance[optionName] = options[optionName]; } }); }; /** * @param {?} moduleCFR * @param {?} contentInjector * @param {?} content * @param {?} context * @return {?} */ LambModalStackService.prototype.getContentRef = /** * @param {?} moduleCFR * @param {?} contentInjector * @param {?} content * @param {?} context * @return {?} */ function (moduleCFR, contentInjector, content, context) { if (!content) { return new ContentRef([]); } else if (content instanceof i0.TemplateRef) { return this.createFromTemplateRef(content, context); } else if (isString(content)) { return this.createFromString(content); } else { return this.createFromComponent(moduleCFR, contentInjector, content, context); } }; /** * @param {?} content * @param {?} context * @return {?} */ LambModalStackService.prototype.createFromTemplateRef = /** * @param {?} content * @param {?} context * @return {?} */ function (content, context) { /** @type {?} */ var viewRef = content.createEmbeddedView(context); this.applicationRef.attachView(viewRef); return new ContentRef([viewRef.rootNodes], viewRef); }; /** * @param {?} content * @return {?} */ LambModalStackService.prototype.createFromString = /** * @param {?} content * @return {?} */ function (content) { /** @type {?} */ var component = this._document.createTextNode("" + content); return new ContentRef([[component]]); }; /** * @param {?} moduleCFR * @param {?} contentInjector * @param {?} content * @param {?} context * @return {?} */ LambModalStackService.prototype.createFromComponent = /** * @param {?} moduleCFR * @param {?} contentInjector * @param {?} content * @param {?} context * @return {?} */ function (moduleCFR, contentInjector, content, context) { /** @type {?} */ var contentComponentFactory = moduleCFR.resolveComponentFactory(content); /** @type {?} */ var modalContentInjector = i0.ReflectiveInjector.resolveAndCreate([{ provide: LambActiveModal, useValue: context }], contentInjector); /** @type {?} */ var componentRef = contentComponentFactory.create(modalContentInjector); this.applicationRef.attachView(componentRef.hostView); return new ContentRef([[componentRef.location.nativeElement]], componentRef.hostView, componentRef); }; LambModalStackService.decorators = [ { type: i0.Injectable }, ]; LambModalStackService.ctorParameters = function () { return [ { type: i0.ApplicationRef }, { type: i0.Injector }, { type: i0.ComponentFactoryResolver }, { type: undefined, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] } ]; }; return LambModalStackService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** * Un servicio para abrir ventanas modales * Crear un modal es sencillo: crear una plantilla y pasarla como argumento para * el método "abierto"! */ var LambModalService = (function () { function LambModalService(moduleCFR, injector, lambModalStackService) { this.moduleCFR = moduleCFR; this.injector = injector; this.lambModalStackService = lambModalStackService; } /** * Abre una nueva ventana modal con el contenido especificado y usando las opciones provistas. * El contenido puede ser proporcionado * como un TemplateRef o un tipo de componente. * Si pasa un tipo de componente como contenido que las instancias de aquellos * los componentes se pueden inyectar con una instancia de la clase NgbActiveModal. * Puedes usar métodos en * Clase LambActiveModal para close / dismiss modales del "inside" de un componente. * @param content * @param options */ /** * Abre una nueva ventana modal con el contenido especificado y usando las opciones provistas. * El contenido puede ser proporcionado * como un TemplateRef o un tipo de componente. * Si pasa un tipo de componente como contenido que las instancias de aquellos * los componentes se pueden inyectar con una instancia de la clase NgbActiveModal. * Puedes usar métodos en * Clase LambActiveModal para close / dismiss modales del "inside" de un componente. * @param {?} content * @param {?=} options * @return {?} */ LambModalService.prototype.open = /** * Abre una nueva ventana modal con el contenido especificado y usando las opciones provistas. * El contenido puede ser proporcionado * como un TemplateRef o un tipo de componente. * Si pasa un tipo de componente como contenido que las instancias de aquellos * los componentes se pueden inyectar con una instancia de la clase NgbActiveModal. * Puedes usar métodos en * Clase LambActiveModal para close / dismiss modales del "inside" de un componente. * @param {?} content * @param {?=} options * @return {?} */ function (content, options) { if (options === void 0) { options = {}; } return this.lambModalStackService.open(this.moduleCFR, this.injector, content, options); }; LambModalService.decorators = [ { type: i0.Injectable }, ]; LambModalService.ctorParameters = function () { return [ { type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: LambModalStackService } ]; }; return LambModalService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambModalModule = (function () { function LambModalModule() { } LambModalModule.decorators = [ { type: i0.NgModule, args: [{ imports: [], declarations: [ LambModalBackdropComponent, LambModalWindowComponent, ], entryComponents: [ LambModalBackdropComponent, LambModalWindowComponent, ], providers: [ LambModalService, LambModalStackService, ], },] }, ]; return LambModalModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambConfirmDialogComponent = (function () { function LambConfirmDialogComponent(activeModal) { this.activeModal = activeModal; } /** * @return {?} */ LambConfirmDialogComponent.prototype.ngOnInit = /** * @return {?} */ function () { }; /** * @return {?} */ LambConfirmDialogComponent.prototype.cancel = /** * @return {?} */ function () { // this.activeModal.close(false); this.activeModal.dismiss(false); }; /** * @return {?} */ LambConfirmDialogComponent.prototype.ok = /** * @return {?} */ function () { this.activeModal.close({ data: 'Hi' }); }; /** * @return {?} */ LambConfirmDialogComponent.prototype.dismiss = /** * @return {?} */ function () { // this.activeModal.close(true); this.activeModal.dismiss(false); }; LambConfirmDialogComponent.decorators = [ { type: i0.Component, args: [{ selector: 'lamb-confirm-dialog', template: "<div class=\"modal-header\">\n <h6 class=\"modal-title\">{{ title }}</h6>\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"dismiss()\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n</div>\n<div class=\"modal-body\">\n {{ message }}\n</div>\n<div class=\"modal-footer\">\n <button type=\"submit\" class=\"btn btn-light btn-sm\" (click)=\"cancel()\" autofocus>{{ btnCancelText }}</button>\n <button type=\"button\" class=\"btn btn-primary btn-sm\" (click)=\"ok()\" >{{ btnOkText }}</button>\n</div>", styles: [".btn.btn-light,.btn.btn-light:active,.btn.btn-light:hover{color:#2a2a2a}"], },] }, ]; LambConfirmDialogComponent.ctorParameters = function () { return [ { type: LambActiveModal } ]; }; LambConfirmDialogComponent.propDecorators = { title: [{ type: i0.Input }], message: [{ type: i0.Input }], btnOkText: [{ type: i0.Input }], btnCancelText: [{ type: i0.Input }] }; return LambConfirmDialogComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ /** @type {?} */ var message = { confirmDelete: '¿Estas seguro de Eliminar este registro?', confirmUpdate: '¿Estas seguro de Actualizar este registro?', confirmSave: '¿Estas seguro de Guardar?', confirmDefault: '¿Estas seguro de realizar la Acción?', }; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc */ var LambConfirmDialogService = (function () { function LambConfirmDialogService(lambModalService) { this.lambModalService = lambModalService; } /** * Confirm * @param options optional JSON Options * @param action X = XXX; D = Delete; U = Update; S = Save */ /** * Confirm * @param {?=} options optional JSON Options * @param {?=} action X = XXX; D = Delete; U = Update; S = Save * @return {?} */ LambConfirmDialogService.prototype.confirm = /** * Confirm * @param {?=} options optional JSON Options * @param {?=} action X = XXX; D = Delete; U = Update; S = Save * @return {?} */ function (options, action) { if (options === void 0) { options = {}; } /** @type {?} */ var modalRef = this.lambModalService.open(LambConfirmDialogComponent, { centered: true }); // const modalRef = this.lambModalService.open(LambConfirmDialogComponent); // const modalRef = // this.lambModalService.open(ConfirmDialogComponent, // { size: (options.dialogSize ? options.dialogSize : this.config.dialogSize) }); modalRef.componentInstance.title = options.title ? options.title : this.config.title; modalRef.componentInstance.message = options.message ? options.message : this.getMessage(action); modalRef.componentInstance.btnOkText = options.btnOkText ? options.btnOkText : this.config.btnOkText;