UNPKG

@stratio/egeo

Version:

Stratio egeo library of components in Angular 2

1,149 lines (1,140 loc) 272 kB
/** * Copyright (C) 2016 Stratio (http://stratio.com) * * 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 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('rxjs/BehaviorSubject'), require('rxjs/Subject'), require('lodash/index'), require('rxjs/Observable'), require('rxjs/add/operator/map'), require('@angular/forms'), require('@angular/router'), require('angular2-virtual-scroll'), require('rxjs/add/operator/debounceTime')) : typeof define === 'function' && define.amd ? define(['exports', '@angular/common', '@angular/core', 'rxjs/BehaviorSubject', 'rxjs/Subject', 'lodash/index', 'rxjs/Observable', 'rxjs/add/operator/map', '@angular/forms', '@angular/router', 'angular2-virtual-scroll', 'rxjs/add/operator/debounceTime'], factory) : (factory((global.egeo = global.egeo || {}),global.ng.common,global.ng.core,global.Rx,global.Rx,global.lodash,global.Rx,global.Rx.Observable.prototype,global.ng.forms,global.ng.router,global['angular2-virtual-scroll'])); }(this, (function (exports,_angular_common,_angular_core,rxjs_BehaviorSubject,rxjs_Subject,lodash_index,rxjs_Observable,rxjs_add_operator_map,_angular_forms,_angular_router,angular2VirtualScroll) { 'use strict'; /* global Reflect, Promise */ var 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]; }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } 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; } /** * Copyright (C) 2016 Stratio (http://stratio.com) * * 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 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var STALERT_SEVERITY = {}; STALERT_SEVERITY.SUCCESS = 0; STALERT_SEVERITY.WARNING = 1; STALERT_SEVERITY.ERROR = 2; STALERT_SEVERITY[STALERT_SEVERITY.SUCCESS] = "SUCCESS"; STALERT_SEVERITY[STALERT_SEVERITY.WARNING] = "WARNING"; STALERT_SEVERITY[STALERT_SEVERITY.ERROR] = "ERROR"; var StAlertLink = (function () { function StAlertLink() { } return StAlertLink; }()); var StAlert = (function () { function StAlert(id, title, message, severity, timeout, extendedTimeout, link) { this.id = id; this.title = title; this.message = message; this.severity = severity; this.timeout = timeout; this.extendedTimeout = extendedTimeout; this.link = link; this._readed = false; this._opacity = 0; this._opacityState = new rxjs_Subject.Subject(); this._removeEvent = new rxjs_Subject.Subject(); } Object.defineProperty(StAlert.prototype, "opacity", { get: function () { return this._opacityState.asObservable(); }, enumerable: true, configurable: true }); Object.defineProperty(StAlert.prototype, "removeAlertEvent", { get: function () { return this._removeEvent.asObservable(); }, enumerable: true, configurable: true }); StAlert.prototype.notify = function () { this.setVisible(true); }; StAlert.prototype.pauseNotify = function () { this._opacity = 1; this._readed = true; this.clearAnimation(); this.stopLife(); this._opacityState.next(this._opacity); }; StAlert.prototype.continueNotify = function () { this.startLife(); }; StAlert.prototype.cancel = function () { this.setVisible(false); }; StAlert.prototype.setVisible = function (increase) { var _this = this; this.clearAnimation(); this._changeVisibilityInterval = window.setInterval(function () { return _this.modifyVisibility(increase); }, 50); }; StAlert.prototype.modifyVisibility = function (increase) { this._opacity += increase ? 0.1 : -0.1; if (this._opacity >= 1 || this._opacity <= 0) { this.clearAnimation(); if (increase) { this.startLife(); } else { this.notifyForRemove(); } } this._opacityState.next(this._opacity); }; StAlert.prototype.notifyForRemove = function () { this._opacityState.complete(); this._removeEvent.next(this); this._removeEvent.complete(); }; StAlert.prototype.clearAnimation = function () { window.clearInterval(this._changeVisibilityInterval); }; StAlert.prototype.stopLife = function () { window.clearTimeout(this._lifeTimeout); }; StAlert.prototype.startLife = function () { var _this = this; var timeout = this._readed ? this.extendedTimeout : this.timeout; this._lifeTimeout = window.setTimeout(function () { return _this.setVisible(false); }, timeout); }; return StAlert; }()); var StAlertsService = (function () { function StAlertsService() { this._alertsList = []; this._nextId = 0; this._alertsStream = new rxjs_BehaviorSubject.BehaviorSubject([]); } Object.defineProperty(StAlertsService.prototype, "alertList", { get: function () { return this._alertsStream.asObservable(); }, enumerable: true, configurable: true }); StAlertsService.prototype.notifyAlert = function (title, message, severity, link, timeout, extendedTimeout) { var _this = this; timeout = timeout !== undefined ? timeout : 5000; extendedTimeout = extendedTimeout !== undefined ? extendedTimeout : 4000; var alert = new StAlert(this._nextId, title, message, severity, timeout, extendedTimeout, link); alert.removeAlertEvent.subscribe(function (alertToRemove) { return _this.onNotifyRemove(alertToRemove); }); this.insertAlert(alert); this._nextId++; }; StAlertsService.prototype.insertAlert = function (alert) { this._alertsList.push(alert); this._alertsStream.next(this._alertsList); }; StAlertsService.prototype.onNotifyRemove = function (alert) { var pos = this._alertsList.findIndex(function (internalAlert) { return internalAlert.id === alert.id; }); this._alertsList.splice(pos, 1); this._alertsStream.next(this._alertsList); }; return StAlertsService; }()); StAlertsService.decorators = [ { type: _angular_core.Injectable }, ]; StAlertsService.ctorParameters = function () { return []; }; var EgeoUtils = (function () { function EgeoUtils() { } EgeoUtils.isDefined = function (value) { return value !== undefined && value !== null; }; EgeoUtils.validateInputs = function (scope, inputs, component) { var _this = this; inputs.forEach(function (input) { if (!_this.isDefined(scope[input])) { throw new Error(_this.toDash(component) + ": field " + input + " is a required field"); } }); }; EgeoUtils.toDash = function (value) { try { return value.replace(/([A-Z])/g, function ($1) { return '-' + $1.toLowerCase(); }).substring(1); } catch (err) { return value; } }; return EgeoUtils; }()); var EGEO_METADATA = Symbol('EgeoLibraryMetadata'); function StRequired(condition) { return function (target, name) { var meta = Reflect.getOwnMetadata(EGEO_METADATA, target.constructor) || {}; meta[name] = meta.hasOwnProperty(name) && meta[name] || { type: 0 }; meta[name].required = true; if (condition !== undefined) { meta[name].requireCondition = condition; } Reflect.defineMetadata(EGEO_METADATA, meta, target.constructor); }; } function StDeprecated(initialValue) { return function (target, name) { var meta = Reflect.getOwnMetadata(EGEO_METADATA, target.constructor) || {}; meta[name] = meta.hasOwnProperty(name) && meta[name] || { type: 0 }; meta[name].deprecated = true; if (initialValue !== undefined) { meta[name].initialValue = initialValue; } Reflect.defineMetadata(EGEO_METADATA, meta, target.constructor); }; } function StEgeo(params) { return function (target) { var _onInit = target.prototype.ngOnInit; if (_onInit !== undefined) { target.prototype.ngOnInit = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } checkDeprecated(target, this); checkRequired(target, this); _onInit.apply(this, args); }; } else { target.prototype.ngOnInit = function () { checkDeprecated(target, this); checkRequired(target, this); }; } }; } function checkDeprecated(target, scope) { var meta = Reflect.getOwnMetadata(EGEO_METADATA, target); if (meta !== undefined) { Object.keys(meta).forEach(function (key) { if (meta[key].deprecated) { if (scope[key] !== undefined) { console.warn(EgeoUtils.toDash(target.name) + ": field " + key + " is a deprecated field"); } else if (meta[key].initialValue) { scope[key] = meta[key].initialValue; } } }); } } function checkRequired(target, scope) { var meta = Reflect.getOwnMetadata(EGEO_METADATA, target); if (meta !== undefined) { var inputs = getKeys(Object.keys(meta), meta, scope); EgeoUtils.validateInputs(scope, inputs, target.name); } } function getKeys(inputs, metadata, scope) { return inputs.reduce(function (prev, curr) { if (metadata[curr].requireCondition !== undefined) { if (checkConditionMetadata(scope, metadata[curr].requireCondition)) { prev.push(curr); } } else if (metadata[curr].required) { prev.push(curr); } return prev; }, []); } function checkConditionMetadata(scope, key) { if (typeof scope[key] === 'function') { return scope[key].apply(scope); } else { return scope[key]; } } var StModalType = {}; StModalType.INFO = 0; StModalType.WARNING = 1; StModalType.NEUTRAL = 2; StModalType[StModalType.INFO] = "INFO"; StModalType[StModalType.WARNING] = "WARNING"; StModalType[StModalType.NEUTRAL] = "NEUTRAL"; var StModalWidth = {}; StModalWidth.COMPACT = 0; StModalWidth.REGULAR = 1; StModalWidth.LARGE = 2; StModalWidth[StModalWidth.COMPACT] = "COMPACT"; StModalWidth[StModalWidth.REGULAR] = "REGULAR"; StModalWidth[StModalWidth.LARGE] = "LARGE"; var StModalMainTextSize = {}; StModalMainTextSize.BIG = 0; StModalMainTextSize.MEDIUM = 1; StModalMainTextSize[StModalMainTextSize.BIG] = "BIG"; StModalMainTextSize[StModalMainTextSize.MEDIUM] = "MEDIUM"; var StModalResponse = {}; StModalResponse.YES = 0; StModalResponse.NO = 1; StModalResponse.CLOSE = 2; StModalResponse[StModalResponse.YES] = "YES"; StModalResponse[StModalResponse.NO] = "NO"; StModalResponse[StModalResponse.CLOSE] = "CLOSE"; exports.ɵbm = (function () { function StModal(cfr) { this.cfr = cfr; this.close = new _angular_core.EventEmitter(); this.click = new _angular_core.EventEmitter(); } StModal.prototype.getModalSize = function () { switch (this.modalConfig.modalWidth) { case StModalWidth.COMPACT: return { 'min-width': '700px', 'max-width': '700px', 'max-heigth': '500px' }; case StModalWidth.REGULAR: return { 'min-width': '950px', 'max-width': '950px', 'max-heigth': '500px' }; case StModalWidth.LARGE: return { 'min-width': '1240px', 'max-width': '1240px', 'min-heigth': '600px', 'max-heigth': '600px' }; default: return { 'min-width': '700px', 'max-width': '700px', 'max-heigth': '500px' }; } }; StModal.prototype.getTitleClass = function () { switch (this.modalConfig.modalType) { case StModalType.NEUTRAL: return 'st-modal-neutral'; case StModalType.INFO: return 'st-modal-info'; case StModalType.WARNING: return 'st-modal-warning'; default: return 'st-modal-neutral'; } }; StModal.prototype.hasContextualTitle = function () { return this.modalConfig.contextualTitle !== undefined && this.modalConfig.contextualTitle.length > 0; }; Object.defineProperty(StModal.prototype, "contextualTitle", { get: function () { return this.modalConfig.contextualTitle; }, enumerable: true, configurable: true }); StModal.prototype.getHeaderHeight = function () { return this.hasContextualTitle() ? '90px' : '80px'; }; StModal.prototype.hasIcon = function () { return this.modalConfig.modalType !== StModalType.NEUTRAL; }; StModal.prototype.getIcon = function () { if (this.modalConfig.modalType === StModalType.INFO) { return 'icon-info1'; } else if (this.modalConfig.modalType === StModalType.WARNING) { return 'icon-alert'; } return ''; }; StModal.prototype.getTitle = function () { return this.modalConfig.modalTitle; }; StModal.prototype.hasButtons = function () { return this.modalConfig.buttons && this.modalConfig.buttons.length > 0; }; StModal.prototype.getButtonIcon = function (left, button) { if (button && button.icon) { if (button.iconLeft && left) { return button.icon; } else if (!button.iconLeft && !left) { return button.icon; } } return ''; }; StModal.prototype.getButtonSubtype = function (button) { return button && button.primary ? 'subtype1' : 'subtype2'; }; StModal.prototype.getButtons = function () { return lodash_index.cloneDeep(this.modalConfig.buttons || []).reverse(); }; StModal.prototype.isMessageModal = function () { return this.modalConfig.message && this.modalConfig.message.length > 0; }; StModal.prototype.isComplexMessageModal = function () { return this.modalConfig.html && this.modalConfig.html.length > 0; }; StModal.prototype.getHTML = function () { return this.modalConfig.html; }; Object.defineProperty(StModal.prototype, "message", { get: function () { return this.modalConfig.message; }, enumerable: true, configurable: true }); Object.defineProperty(StModal.prototype, "mainTextSize", { get: function () { switch (this.modalConfig.mainText) { case StModalMainTextSize.BIG: return 'sth-modal-message-big'; case StModalMainTextSize.MEDIUM: return 'sth-modal-message-medium'; default: return ''; } }, enumerable: true, configurable: true }); Object.defineProperty(StModal.prototype, "qaTag", { get: function () { if (this.modalConfig && this.modalConfig.qaTag) { return this.modalConfig.qaTag; } else { throw new Error('[ERROR]: StModal => qa tag is a required field'); } }, enumerable: true, configurable: true }); StModal.prototype.clickButton = function (index, button) { this.click.emit(button.response); }; StModal.prototype.closeModal = function (event) { this.close.emit(event); }; StModal.prototype.ngOnInit = function () { if (this.component && !(this.modalConfig.html || this.modalConfig.message)) { this.loadBody(); } }; StModal.prototype.ngOnDestroy = function () { if (this.componentRef) { this.componentRef.destroy(); } }; StModal.prototype.loadBody = function () { if (!this.componentRef) { this.target.clear(); var compFactory = this.cfr.resolveComponentFactory(this.component); this.componentRef = this.target.createComponent(compFactory); this.bindModalInputs(); } }; StModal.prototype.bindModalInputs = function () { for (var key in this.modalConfig.inputs) { if (this.modalConfig.inputs.hasOwnProperty(key)) { this.componentRef.instance[key] = ((this.modalConfig.inputs))[key]; } } for (var key in this.modalConfig.outputs) { if (this.modalConfig.outputs.hasOwnProperty(key)) { this.componentRef.instance[key].subscribe(((this.modalConfig.outputs))[key]); } } this.componentRef.changeDetectorRef.detectChanges(); }; return StModal; }()); exports.ɵbm.decorators = [ { type: _angular_core.Component, args: [{ selector: 'st-modal', template: "<div class=\"st-modal sth-modal\"><div class=\"st-modal-content sth-modal-content\" [ngStyle]=\"getModalSize()\"><div class=\"sth-modal-header st-modal-header\" [ngClass]=\"getTitleClass()\" [ngStyle]=\"{height: getHeaderHeight()}\"><div class=\"st-modal-contextual sth-modal-contextual\" *ngIf=\"hasContextualTitle()\">{{contextualTitle}}</div><div class=\"st-modal-title sth-modal-title\"><i *ngIf=\"hasIcon()\" [ngClass]=\"getIcon()\"></i><p id=\"st-modal-title\">{{getTitle()}}</p></div><div (click)=\"closeModal($event)\" class=\"st-modal-close-button sth-modal-close-button\" id=\"st-modal-close-button\"><i class=\"icon-circle-cross\"></i></div></div><div class=\"st-modal-body sth-modal-body\" [ngClass]=\"mainTextSize\"><div *ngIf=\"isMessageModal()\" class=\"message\"><p id=\"st-modal-message-plain\">{{message}}</p></div><div *ngIf=\"isComplexMessageModal()\" [innerHTML]=\"getHTML()\" id=\"st-modal-message-html\"></div><div #stModalBody id=\"st-modal-message-component\"></div><div *ngIf=\"hasButtons()\" class=\"st-modal-buttons\"><st-button *ngFor=\"let button of getButtons(); let idx = index\" [text]=\"button.label\" [leftIcon]=\"getButtonIcon(true, button)\" [rightIcon]=\"getButtonIcon(false, button)\" [qaTag]=\"'st-modal-button-' + idx\" [subtypeClass]=\"getButtonSubtype(button)\" [inputType]=\"button\" (onClick)=\"clickButton(idx, button)\"></st-button></div></div></div></div>", styles: [".st-modal{height:100vh;left:0;top:0;position:fixed;width:100%;z-index:999999;display:-webkit-box;display:-ms-flexbox;display:flex}.st-modal-content{-ms-flex-item-align:center;align-self:center;-webkit-animation-duration:.5s;animation-duration:.5s;-webkit-animation-name:fadeIn;animation-name:fadeIn;margin:auto;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.st-modal-header{width:100%;position:relative;display:-webkit-box;display:-ms-flexbox;display:flex}.st-modal-close-button{position:absolute;right:15px;top:15px}.st-modal-title{-ms-flex-item-align:end;align-self:flex-end;margin:0 0 7px 30px;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overflow:hidden;text-overflow:ellipsis;max-width:87%}.st-modal-title i{margin-right:10px}.st-modal-title p{text-transform:uppercase;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.st-modal-body{padding:30px 30px 50px 30px}.st-modal-buttons{margin-top:50px;margin-left:auto;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}.st-modal-buttons st-button{margin-left:10px}.st-modal-contextual{height:35px;padding:10px 14px;position:absolute;top:0;left:30px}"], changeDetection: _angular_core.ChangeDetectionStrategy.OnPush },] }, ]; exports.ɵbm.ctorParameters = function () { return [ { type: _angular_core.ComponentFactoryResolver, }, ]; }; exports.ɵbm.propDecorators = { 'modalConfig': [{ type: _angular_core.Input },], 'close': [{ type: _angular_core.Output },], 'click': [{ type: _angular_core.Output },], 'component': [{ type: _angular_core.Input },], 'target': [{ type: _angular_core.ViewChild, args: ['stModalBody', { read: _angular_core.ViewContainerRef },] },], }; __decorate([ StRequired() ], exports.ɵbm.prototype, "modalConfig", void 0); exports.ɵbm = __decorate([ StEgeo() ], exports.ɵbm); var StModalService = (function () { function StModalService(_cfr) { this._cfr = _cfr; this._containerRef = undefined; this.dynamicModal = undefined; } Object.defineProperty(StModalService.prototype, "container", { set: function (container) { this._containerRef = container; }, enumerable: true, configurable: true }); StModalService.prototype.show = function (config, component) { var errors = this.canCreateModal(config, component); if (errors && errors.length > 0) { throw new Error(errors.join(' ')); } this.notifyButtonInteraction = new rxjs_Subject.Subject(); this.createModal(this.createConfig(config), component); return this.notifyButtonInteraction.asObservable(); }; StModalService.prototype.showDeleteConfirmation = function (message, modalTitle, okButton, cancelButton, qaTag, modalType) { var buttons = [ { icon: 'icon-trash', iconLeft: true, label: okButton, primary: true, response: StModalResponse.YES }, { icon: 'icon-circle-cross', iconLeft: true, label: cancelButton, primary: false, response: StModalResponse.NO } ]; return this.show({ qaTag: qaTag ? qaTag : 'delete-confirmation', modalType: modalType ? modalType : StModalType.WARNING, modalWidth: StModalWidth.COMPACT, mainText: StModalMainTextSize.BIG, message: message, modalTitle: modalTitle, buttons: buttons }); }; StModalService.prototype.close = function () { this.destroy(); }; StModalService.prototype.createModal = function (modalConfig, component) { var stModalFactory = this._cfr.resolveComponentFactory(exports.ɵbm); if (stModalFactory) { this._containerRef.clear(); this.dynamicModal = this._containerRef.createComponent(stModalFactory); this.bindVars(modalConfig, component); } }; StModalService.prototype.destroy = function () { if (this.dynamicModal) { this.dynamicModal.destroy(); this.dynamicModal = undefined; this.notifyButtonInteraction.next(StModalResponse.CLOSE); this.notifyButtonInteraction.complete(); } }; StModalService.prototype.bindVars = function (modalConfig, component) { var _this = this; this.dynamicModal.instance.component = component; this.dynamicModal.instance.close.subscribe(function (event) { return _this.onClose(event); }); this.dynamicModal.instance.click.subscribe(function (response) { return _this.notify(response, modalConfig.closeOnAccept); }); this.dynamicModal.instance.modalConfig = modalConfig; this.dynamicModal.changeDetectorRef.detectChanges(); }; StModalService.prototype.onClose = function (event) { this.close(); }; StModalService.prototype.notify = function (response, closeOnAccept) { this.notifyButtonInteraction.next(response); if (closeOnAccept && response === StModalResponse.YES) { this.close(); } }; StModalService.prototype.canCreateModal = function (config, component) { var errors = []; if (!this._containerRef) { errors.push("[ERROR]: StModalService => Cant find container, are you sure you declarate in MAIN APP component in html and typescript?"); } if (this.dynamicModal !== undefined) { errors.push("[ERROR]: StModalService => Can't create modal beacause already exists one. Are you sure that you call close method?)"); } if (!component && !config.message && !config.html) { errors.push("[ERROR]: StModalService => Can't find message, html or component to show in modal"); } return errors; }; StModalService.prototype.createConfig = function (config) { if (config.qaTag === undefined || config.qaTag.length === 0) { throw new Error("[ERROR]: StModalService => qaTag is a required field"); } return { inputs: config.inputs !== undefined ? config.inputs : {}, outputs: config.outputs !== undefined ? config.outputs : {}, modalTitle: config.modalTitle !== undefined && config.modalTitle.length > 0 ? config.modalTitle : 'DEFAULT TITLE', modalType: config.modalType !== undefined ? config.modalType : StModalType.NEUTRAL, modalWidth: config.modalWidth !== undefined ? config.modalWidth : StModalWidth.COMPACT, buttons: config.buttons !== undefined ? config.buttons : [], closeOnAccept: config.closeOnAccept !== undefined ? config.closeOnAccept : true, mainText: config.mainText !== undefined ? config.mainText : StModalMainTextSize.MEDIUM, message: config.message, html: config.html, contextualTitle: config.contextualTitle, qaTag: config.qaTag }; }; return StModalService; }()); StModalService.decorators = [ { type: _angular_core.Injectable }, ]; StModalService.ctorParameters = function () { return [ { type: _angular_core.ComponentFactoryResolver, }, ]; }; var StPaginationService = (function () { function StPaginationService() { } StPaginationService.prototype.newPage = function (items, currentPage, perPage) { if (currentPage === 1) { this.initItem = 0; } else { this.initItem = perPage * (currentPage - 1); } if (perPage >= items.length) { return Object.assign([], items); } if (this.initItem >= items.length) { this.initItem = items.length - (perPage + 1); return Object.assign([], lodash_index.takeRight(items, perPage)); } this.lastItem = (this.initItem + perPage); return Object.assign([], items.slice(this.initItem, this.lastItem)); }; return StPaginationService; }()); StPaginationService.decorators = [ { type: _angular_core.Injectable }, ]; StPaginationService.ctorParameters = function () { return []; }; var EgeoResolveService = (function () { function EgeoResolveService() { } EgeoResolveService.prototype.getKeys = function (object, key, searchedValue) { return this.searchInDeep(object, key, searchedValue); }; EgeoResolveService.prototype.setKeys = function (object, resolved) { resolved.forEach(function (element) { return lodash_index.set(object, element.path, element.resolved); }); }; EgeoResolveService.prototype.translate = function (object, translateService) { var _this = this; var keys$$1 = this.getKeys(object, 'translate'); if (keys$$1 && keys$$1.length > 0) { var toTranslate = this.extractTranslationKeys(keys$$1); return translateService.get(toTranslate) .map(function (translation) { return _this.remapObjectWithTranslations(translation, keys$$1, object); }); } else { return rxjs_Observable.Observable.create(function (observer) { observer.next(object); observer.complete(); }); } }; EgeoResolveService.prototype.translateArrayOfKeys = function (keys$$1, translateService) { var _this = this; return translateService.get(keys$$1) .map(function (translation) { return _this.remapArrayWithTranslations(translation, keys$$1); }); }; EgeoResolveService.prototype.remapArrayWithTranslations = function (translations, originalArray) { return originalArray.map(function (key) { return translations[key] ? translations[key] : key; }); }; EgeoResolveService.prototype.remapObjectWithTranslations = function (translations, resolverKeys, object) { var _this = this; var newObj = lodash_index.cloneDeep(object); if (translations || lodash_index.keys(translations).length > 0) { lodash_index.forEach(resolverKeys, function (resolvKey, key) { lodash_index.set(newObj, resolvKey.path, _this.getTranslationFromTranslatedKey(translations, resolvKey)); }); } return newObj; }; EgeoResolveService.prototype.getTranslationFromTranslatedKey = function (translations, resolverKey) { var translationElementKey = resolverKey && resolverKey.toResolve && resolverKey.toResolve.key ? resolverKey.toResolve.key : ''; return translations[translationElementKey] ? translations[translationElementKey] : translationElementKey; }; EgeoResolveService.prototype.extractTranslationKeys = function (list) { return list.map(function (element) { return (lodash_index.values(lodash_index.omit(element.toResolve, 'translate'))[0]); }); }; EgeoResolveService.prototype.searchInDeep = function (object, key, searchedValue, path) { var _this = this; if (path === void 0) { path = ''; } var result = []; if (lodash_index.has(object, key)) { if (searchedValue !== undefined) { if (object[key] === searchedValue) { result.push({ path: path, toResolve: object }); } } else { result.push({ path: path, toResolve: object }); } } var i = 0; lodash_index.forEach(object, function (value, objKey) { if (typeof value === 'object') { result = result.concat(_this.searchInDeep(value, key, searchedValue, _this.getPath(path, object, i, objKey))); } i++; }); return result; }; EgeoResolveService.prototype.getPath = function (actualPath, obj, pos, key) { if (this.isArray(obj)) { actualPath = actualPath + "[" + pos + "]"; } else { actualPath = actualPath === '' ? key : actualPath + "." + key; } return actualPath; }; EgeoResolveService.prototype.isArray = function (value) { return Object.prototype.toString.call(value) === '[object Array]'; }; return EgeoResolveService; }()); EgeoResolveService.decorators = [ { type: _angular_core.Injectable }, ]; EgeoResolveService.ctorParameters = function () { return []; }; var SelectOneDispatcher = (function () { function SelectOneDispatcher() { this.listeners = []; } SelectOneDispatcher.prototype.notify = function (id, name) { for (var _i = 0, _a = this.listeners; _i < _a.length; _i++) { var listener = _a[_i]; listener(id, name); } }; SelectOneDispatcher.prototype.listen = function (listener) { this.listeners.push(listener); }; return SelectOneDispatcher; }()); SelectOneDispatcher.decorators = [ { type: _angular_core.Injectable }, ]; SelectOneDispatcher.ctorParameters = function () { return []; }; var StFilterList = (function () { function StFilterList() { } StFilterList.prototype.transform = function (list, field, search) { var _this = this; this.checkParams(field); if (list && list.length > 0) { return list.filter(function (element) { return _this.contains(element, field, search); }); } else { return []; } }; StFilterList.prototype.contains = function (element, field, search) { if (this.isDefined(element) && this.isString(field) && this.isString(search) && this.isString(element[field])) { return element[field].toUpperCase().search(search.toUpperCase()) > -1; } return false; }; StFilterList.prototype.isDefined = function (value) { return value !== undefined && value !== null; }; StFilterList.prototype.isString = function (value) { return this.isDefined(value) && typeof value === 'string'; }; StFilterList.prototype.checkParams = function (field) { if (!this.isString(field)) { throw new Error('PIPE: stFilterList: "field" is a required and string parameter'); } }; return StFilterList; }()); StFilterList.decorators = [ { type: _angular_core.Pipe, args: [{ name: 'stFilterList' },] }, ]; StFilterList.ctorParameters = function () { return []; }; var StObjectToArrayPipe = (function () { function StObjectToArrayPipe() { } StObjectToArrayPipe.prototype.transform = function (obj) { return obj ? Object.keys(obj).map(function (key) { return ({ key: key, value: obj[key] }); }) : []; }; return StObjectToArrayPipe; }()); StObjectToArrayPipe.decorators = [ { type: _angular_core.Pipe, args: [{ 'name': 'stObjectToArray' },] }, ]; StObjectToArrayPipe.ctorParameters = function () { return []; }; var PipesModule = (function () { function PipesModule() { } return PipesModule; }()); PipesModule.decorators = [ { type: _angular_core.NgModule, args: [{ imports: [_angular_common.CommonModule], declarations: [StFilterList, StObjectToArrayPipe], exports: [StFilterList, StObjectToArrayPipe] },] }, ]; PipesModule.ctorParameters = function () { return []; }; var StAlertBoxComponent = (function () { function StAlertBoxComponent(_cd) { this._cd = _cd; this.showInConsole = false; this.opacity = 0; } StAlertBoxComponent.prototype.ngOnInit = function () { var _this = this; this.alert.opacity.subscribe(function (opacity) { return _this.changeOpacity(opacity); }); this.alert.notify(); if (this.showInConsole) { this.notifyConsole(); } }; StAlertBoxComponent.prototype.enter = function () { this.alert.pauseNotify(); }; StAlertBoxComponent.prototype.leave = function () { this.alert.continueNotify(); }; StAlertBoxComponent.prototype.closeAlert = function () { this.alert.cancel(); }; StAlertBoxComponent.prototype.getIcon = function () { switch (this.alert.severity) { case STALERT_SEVERITY.ERROR: return 'icon-ban'; case STALERT_SEVERITY.WARNING: return 'icon-alert'; case STALERT_SEVERITY.SUCCESS: return 'icon-circle-check'; default: return ''; } }; StAlertBoxComponent.prototype.getSeverityColor = function () { switch (this.alert.severity) { case STALERT_SEVERITY.ERROR: return 'sth-alert-box-error'; case STALERT_SEVERITY.WARNING: return 'sth-alert-box-warning'; case STALERT_SEVERITY.SUCCESS: return 'sth-alert-box-success'; default: return ''; } }; StAlertBoxComponent.prototype.goTo = function () { window.open(this.alert.link.link); }; StAlertBoxComponent.prototype.changeOpacity = function (opacity) { this.opacity = opacity; this._cd.markForCheck(); }; StAlertBoxComponent.prototype.notifyConsole = function () { switch (this.alert.severity) { case STALERT_SEVERITY.ERROR: console.error("ERROR-" + this.alert.title + ": " + this.alert.message); break; case STALERT_SEVERITY.WARNING: console.warn("WARNING-" + this.alert.title + ": " + this.alert.message); break; case STALERT_SEVERITY.SUCCESS: console.log("SUCCESS-" + this.alert.title + ": " + this.alert.message); break; default: console.error("ERROR: severity not found for " + this.alert.title + ": " + this.alert.message); break; } }; return StAlertBoxComponent; }()); StAlertBoxComponent.decorators = [ { type: _angular_core.Component, args: [{ selector: 'st-alert-box', template: "<div class=\"sth-alert-box\" [ngClass]=\"getSeverityColor()\" (mouseenter)=\"enter()\" (mouseleave)=\"leave()\" [ngStyle]=\"{opacity: opacity}\"><span class=\"sth-alert-box-close-button\" (click)=\"closeAlert()\"><i class=\"icon-circle-cross\"></i></span><div class=\"sth-alert-box-ico-type\"><i [ngClass]=\"getIcon()\"></i></div><div class=\"sth-alert-box-message\"><header class=\"sth-alert-box-message-header\"><p class=\"sth-alert-box-message-header-title\">{{alert.title}}</p></header><div class=\"sth-alert-box-message-body\"><p>{{alert.message}}</p><footer *ngIf=\"alert.link\" class=\"sth-alert-box-message-footer\"><a (click)=\"goTo()\">{{alert.link.title}}</a></footer></div></div></div>", changeDetection: _angular_core.ChangeDetectionStrategy.OnPush },] }, ]; StAlertBoxComponent.ctorParameters = function () { return [ { type: _angular_core.ChangeDetectorRef, }, ]; }; StAlertBoxComponent.propDecorators = { 'alert': [{ type: _angular_core.Input },], 'showInConsole': [{ type: _angular_core.Input },], }; var StAlertsComponent = (function () { function StAlertsComponent(_cd, alertService) { this._cd = _cd; this.alertService = alertService; this.showInConsole = false; this.qaTag = 'st-alert-manager'; } return StAlertsComponent; }()); StAlertsComponent.decorators = [ { type: _angular_core.Component, args: [{ selector: 'st-alerts', template: "<div [attr.id]=\"qaTag\" class=\"st-alerts\"><st-alert-box class=\"st-alert-box\" *ngFor=\"let alert of (alertService.alertList | async)\" [alert]=\"alert\" [showInConsole]=\"showInConsole\"></st-alert-box></div>", styles: [".st-alert-box{margin-top:15px;display:block}.st-alerts{width:288px;position:fixed;right:15px;top:0;z-index:99999}"], changeDetection: _angular_core.ChangeDetectionStrategy.OnPush },] }, ]; StAlertsComponent.ctorParameters = function () { return [ { type: _angular_core.ChangeDetectorRef, }, { type: StAlertsService, }, ]; }; StAlertsComponent.propDecorators = { 'showInConsole': [{ type: _angular_core.Input },], 'qaTag': [{ type: _angular_core.Input },], }; var StAlertsModule = (function () { function StAlertsModule() { } return StAlertsModule; }()); StAlertsModule.decorators = [ { type: _angular_core.NgModule, args: [{ imports: [_angular_common.CommonModule], declarations: [StAlertsComponent, StAlertBoxComponent], exports: [StAlertsComponent] },] }, ]; StAlertsModule.ctorParameters = function () { return []; }; var StBreadCrumbsComponent = (function () { function StBreadCrumbsComponent() { this.options = []; this.select = new _angular_core.EventEmitter(); } StBreadCrumbsComponent.prototype.generateCrumbs = function () { if (this.options.length <= 6) { return this.options.slice(); } else { return this.options .slice(0, 1) .concat(['...']) .concat(this.options.slice(-4)); } }; StBreadCrumbsComponent.prototype.onSelect = function (index) { if (index + 1 < this.options.length) { if (this.options.length <= 6 || index === 0) { this.select.emit(index); } else { var calculatedIndex = void 0; calculatedIndex = this.options.length - (6 - index); this.select.emit(index); } } }; return StBreadCrumbsComponent; }()); StBreadCrumbsComponent.decorators = [ { type: _angular_core.Component, args: [{ selector: 'st-breadcrumbs', template: "<ul class=\"st-breadcrumbs\"><ng-content select=\"st-breadcrumbs-item\"></ng-content><div *ngIf=\"options.length\"><st-breadcrumbs-item *ngFor=\"let item of generateCrumbs(); let last=last; let i = index\" (click)=\"onSelect(i)\" [active]=\"last\" [qaTag]=\"qaTag + '-' + i\">{{item}}</st-breadcrumbs-item></div></ul>", styles: ["ul{list-style:none;margin:0;padding:0}"] },] }, ]; StBreadCrumbsComponent.ctorParameters = function () { return []; }; StBreadCrumbsComponent.propDecorators = { 'options': [{ type: _angular_core.Input },], 'qaTag': [{ type: _angular_core.Input },], 'select': [{ type: _angular_core.Output },], }; var StBreadcrumbItemComponent = (function () { function StBreadcrumbItemComponent() { } return StBreadcrumbItemComponent; }()); StBreadcrumbItemComponent.decorators = [ { type: _angular_core.Component, args: [{ selector: 'st-breadcrumbs-item', template: "<li class=\"st-breadcrumbs__item sth-breadcrumbs__item\" [ngClass]=\"{'last': active}\"><span class=\"st-breadcrumbs__item--text sth-breadcrumbs__item--text\" [attr.id]=\"qaTag\"><ng-content></ng-content></span><span class=\"st-breadcrumbs__item--arrow sth-breadcrumbs__item--arrow\" *ngIf=\"!active\">></span></li>", styles: [".st-breadcrumbs__item{display:inline}.st-breadcrumbs__item--text{cursor:pointer}.last .st-breadcrumbs__item--text{cursor:default;background-color:transparent}.last .st-breadcrumbs__item--arrow{display:none}"] },] }, ]; StBreadcrumbItemComponent.ctorParameters = function () { return []; }; StBreadcrumbItemComponent.propDecorators = { 'qaTag': [{ type: _angular_core.Input },], 'active': [{ type: _angular_core.Input },], }; var StBreadcrumbsModule = (function () { function StBreadcrumbsModule() { } return StBreadcrumbsModule; }()); StBreadcrumbsModule.decorators = [ { type: _angular_core.NgModule, args: [{ imports: [_angular_common.CommonModule], exports: [StBreadCrumbsComponent, StBreadcrumbItemComponent], declarations: [StBreadCrumbsComponent, StBreadcrumbItemComponent] },] }, ]; StBreadcrumbsModule.ctorParameters = function () { return []; }; var StButtonComponent = (function () { function StButtonComponent() { this.inputType = 'button'; this.isDisabled = false; this.subtypeClass = 'default'; this.text = 'Click Me'; this.typeClass = 'btnMain'; this.onClick = new _angular_core.EventEmitter(); this.internalText = ''; } StButtonComponent.prototype.ngOnInit = function () { if (this.typeClass !== 'btnTool') { this.internalText = this.text; } }; StButtonComponent.prototype.getButtonTypeClass = function () { if (this.typeClass === 'btnMain') { switch (this.subtypeClass) { case 'subtype1': return "button-sq1"; case 'subtype2': return "button-sq2"; case 'subtype3': return "button-sq3"; case 'subtype4': return "button-sq4"; default: return "button-sq1"; } } else if (this.typeClass === 'btnLink') { if (this.themeClass === 'themeB') { switch (this.subtypeClass) { case 'subtype1': return "button-lk3"; case 'subtype2': return "button-lk4"; default: return "button-lk3"; } } else { switch (this.subtypeClass) { case 'subtype1': return "button-lk1"; case 'subtype2': return "button-lk2"; default: return "button-lk1"; } } } else if (this.typeClass === 'btnTool') { if (this.themeClass === 'themeB') { switch (this.subtypeClass) { case 'subtype1': return "button-rd4"; case 'subtype2': return "button-rd5"; case 'subtype3': return "button-rd6"; default: return "button-rd4"; } } else { switch (this.subtypeClass) { case 'subtype1': return "button-rd1"; case 'subtype2': return "button-rd2"; case 'subtype3': return "button-rd3"; case 'subtype4': return "button-rd7"; default: return "button-rd1"; } } } return 'button-sq1'; }; StButtonComponent.prototype.onClickEvent = function (event) { this.onClick.emit(event); }; return StButtonComponent; }()); StButtonComponent.decorators = [ { type: _angular_core.Component, args: [{ selector: 'st-button', template: "<button [attr.type]=\"inputType\" class=\"button\" [attr.id]=\"qaTag\" [attr.disabled]=\"isDisabled ? true : null\" [ngClass]=\"getButtonTypeClass()\" (click)=\"onClickEvent($event)\" [title]=\"text\"><i [ngClass]=\"leftIcon\" *ngIf=\"leftIcon\"></i> <span class=\"st-button__text\">{{internalText}}</span> <i [ngClass]=\"rightIcon\" *ngIf=\"rightIcon\"></i></button>" },] }, ]; StButtonComponent.ctorParameters = function () { return []; }; StButtonComponent.propDecorators = { 'inputType': [{ type: _angular_core.Input },], 'isDisabled': [{ type: _angular_core.Input },], 'leftIcon': [{ type: _angular_core.Input },], 'qaTag': [{ type: _angular_core.Input },], 'rightIcon': [{ type: _angular_core.Input },], 'subtypeClass': [{ type: _angular_core.Input },], 'text': [{ type: _angular_core.Input },], 'themeClass': [{ type: _angular_core.Input },], 'typeClass': [{ type: _angular_core.Input },], 'onClick': [{ type: _angular_core.Output },], }; var StButtonModule = (function () { function StButtonModule() { } return StButtonModule; }()); StButtonModule.decorators = [ { type: _angular_core.NgModule, args: [{ imports: [_angular_common.CommonModule], declarations: [StButtonComponent], exports: [StButtonComponent] },] }, ]; StButtonModule.ctorParameters = function () { return []; }; var CHECKBOX_CONTROL_ACCESSOR = { provide: _angular_forms.NG_VALUE_ACCESSOR, useExisting: _angular_core.forwardRef(function () { return StCheckboxComponent; }), multi: true }; var StCheckboxComponent = (function () { function StCheckboxComponent(_changeDetectorRef) { this._changeDetectorRef = _changeDetectorRef; this.change = new _angular_core.EventEmitter(); this._checked = false; this._controlValueAccessorChangeFn = function (value) { }; this.onTouched = function () { }; } Object.defineProperty(StCheckboxComponent.prototype, "checked", { get: function () { return this._checked; }, set: function (checked) { if (checked !== this.checked) { this._checked = checked; this._changeDetectorRef.markForCheck(); } }, enumerable: true, configurable: true }); StCheckboxComponent.prototype.handleClick = function () { if (!this.readonly) { if (!this.disabled) { this._checked = !this._checked; this._contro