UNPKG

@uex/web-extensions

Version:

## Installation

1,146 lines (1,112 loc) 500 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('lodash'), require('@angular/http'), require('rxjs/add/operator/timeout'), require('@angular/animations'), require('@angular/forms'), require('ngx-pipes'), require('angular2-text-mask'), require('moment'), require('text-mask-addons/dist/createNumberMask.js'), require('text-mask-core/dist/textMaskCore'), require('cropperjs'), require('@angular/platform-browser'), require('@angular/router'), require('rxjs/add/operator/filter'), require('@uex/angular2-qrscanner')) : typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common', 'lodash', '@angular/http', 'rxjs/add/operator/timeout', '@angular/animations', '@angular/forms', 'ngx-pipes', 'angular2-text-mask', 'moment', 'text-mask-addons/dist/createNumberMask.js', 'text-mask-core/dist/textMaskCore', 'cropperjs', '@angular/platform-browser', '@angular/router', 'rxjs/add/operator/filter', '@uex/angular2-qrscanner'], factory) : (factory((global['@uex/web-extensions'] = {}),global.core,global.common,global._,global.http,null,global.animations,global.forms,global.ngxPipes,global.angular2TextMask,global.moment,global.createNumberMask,global.textMaskCore,global.CropperJS,global.platformBrowser,global.router,null,global.angular2Qrscanner)); }(this, (function (exports,core,common,_,http,timeout,animations,forms,ngxPipes,angular2TextMask,moment,createNumberMask,textMaskCore,Cropper,platformBrowser,router,filter,angular2Qrscanner) { 'use strict'; moment = moment && moment.hasOwnProperty('default') ? moment['default'] : moment; createNumberMask = createNumberMask && createNumberMask.hasOwnProperty('default') ? createNumberMask['default'] : createNumberMask; (function (TemplateTheme) { TemplateTheme[TemplateTheme["DARK"] = 1] = "DARK"; TemplateTheme[TemplateTheme["LIGHT"] = 2] = "LIGHT"; TemplateTheme[TemplateTheme["BLUE"] = 3] = "BLUE"; })(exports.TemplateTheme || (exports.TemplateTheme = {})); (function (TemplateSize) { TemplateSize[TemplateSize["RESPONSIVE"] = 1] = "RESPONSIVE"; TemplateSize[TemplateSize["SMALL"] = 2] = "SMALL"; TemplateSize[TemplateSize["MEDIUM"] = 3] = "MEDIUM"; })(exports.TemplateSize || (exports.TemplateSize = {})); var AppConfig = (function () { function AppConfig() { } return AppConfig; }()); var ConfigService = (function () { function ConfigService(config) { this.config = config; this.DEFAULT_CONFIG = { theme: exports.TemplateTheme.LIGHT, header: true, background: { color: '#1C7FBB' } }; this._setDefautValues(); } Object.defineProperty(ConfigService.prototype, "template", { get: function () { return this.config && this.config.template ? this.config.template : {}; }, enumerable: true, configurable: true }); ConfigService.prototype._setDefautValues = function () { var _this = this; _.forEach(this.template, function (config, type) { var default_config = _this.DEFAULT_CONFIG; if (config.background && (config.background.image || config.background.color)) { delete default_config.background.color; } _this.config.template[type] = _.merge({}, default_config, config); }); }; ConfigService.decorators = [ { type: core.Injectable }, ]; ConfigService.ctorParameters = function () { return [ { type: AppConfig, decorators: [{ type: core.Optional },] }, ]; }; return ConfigService; }()); var ButtonComponent = (function () { function ButtonComponent(_element) { this._element = _element; this.color = 'primary'; this.mode = 'raised'; this.size = null; } ButtonComponent.prototype.ngAfterViewInit = function () { componentHandler.upgradeElements(this._element.nativeElement); }; ButtonComponent.decorators = [ { type: core.Component, args: [{ selector: '[uex-button]', template: '<ng-content></ng-content>', styles: ["[uex-button][block] { width: 100%; } [uex-button] .fa { line-height: 32px; } .uex-button + .uex-button:not([block]) { margin-left: 10px; } .uex-button + .uex-button[block] { margin-top: 10px; } .uex-button.mdl-button--mini-raised { padding: 0 10px; line-height: 1; min-width: 58px; height: 30px; font-size: 12px; } .uex-button.mdl-button--mini-icon { line-height: 1.4rem !important; } .uex-button.mdl-button--mini-icon .material-icons, .uex-button.mdl-button--mini-icon .fa { top: 0 !important; left: 0 !important; transform: translate(0, 0) !important; font-size: 1.4rem !important; } .uex-button.mdl-button--mini-icon .fa { line-height: 1; } .mdl-button--facebook { color: #3b5999; } .mdl-button--facebook .mdl-ripple { background: white; } .mdl-button--facebook.mdl-button--raised, .mdl-button--facebook.mdl-button--fab { color: white; background-color: #3b5999; } .mdl-button--facebook.mdl-button--raised:focus:not(:active), .mdl-button--facebook.mdl-button--fab:focus:not(:active) { color: white; background-color: #3b5999; } .mdl-button--facebook:focus:not(:active) .mdl-ripple { background-color: white; } .mdl-button--light { color: white; } .mdl-button--light .mdl-ripple { background: #1C7FBB; } .mdl-button--light.mdl-button--raised, .mdl-button--light.mdl-button--fab { color: #1C7FBB; background-color: white; } .mdl-button--light.mdl-button--raised:focus:not(:active), .mdl-button--light.mdl-button--fab:focus:not(:active) { color: #1C7FBB; background-color: white; } .mdl-button--light:focus:not(:active) .mdl-ripple { background-color: #1C7FBB; } "], host: { 'class': 'uex-button mdl-js-ripple-effect mdl-button mdl-js-button', '[class.mdl-button--raised]': 'mode == "raised"', '[class.mdl-button--icon]': 'mode == "icon"', '[class.mdl-button--fab]': 'mode == "fab"', '[class.mdl-button--mini-raised]': 'mode == "raised" && size == "mini"', '[class.mdl-button--mini-icon]': 'mode == "icon" && size == "mini"', '[class.mdl-button--mini-fab]': 'mode == "fab" && size == "mini"', '[class.mdl-button--colored]': 'color == "colored"', '[class.mdl-button--primary]': 'color == "primary"', '[class.mdl-button--accent]': 'color == "accent"', '[class.mdl-button--dark]': 'color == "dark"', '[class.mdl-button--light]': 'color == "light"', '[class.mdl-button--facebook]': 'color == "facebook"', '[class.mdl-button--green-lightest]': 'color == "green-lightest"', '[class.mdl-button--green-light]': 'color == "green-light"', '[class.mdl-button--green]': 'color == "green"', '[class.mdl-button--green-dark]': 'color == "green-dark"', '[class.mdl-button--green-darkest]': 'color == "green-darkest"', '[class.mdl-button--cyan-lightest]': 'color == "cyan-lightest"', '[class.mdl-button--cyan-light]': 'color == "cyan-light"', '[class.mdl-button--cyan]': 'color == "cyan"', '[class.mdl-button--cyan-dark]': 'color == "cyan-dark"', '[class.mdl-button--cyan-darkest]': 'color == "cyan-darkest"', '[class.mdl-button--blue-lightest]': 'color == "blue-lightest"', '[class.mdl-button--blue-light]': 'color == "blue-light"', '[class.mdl-button--blue]': 'color == "blue"', '[class.mdl-button--blue-dark]': 'color == "blue-dark"', '[class.mdl-button--blue-darkest]': 'color == "blue-darkest"', '[class.mdl-button--red-lightest]': 'color == "red-lightest"', '[class.mdl-button--red-light]': 'color == "red-light"', '[class.mdl-button--red]': 'color == "red"', '[class.mdl-button--red-dark]': 'color == "red-dark"', '[class.mdl-button--red-darkest]': 'color == "red-darkest"', '[class.mdl-button--orange-lightest]': 'color == "orange-lightest"', '[class.mdl-button--orange-light]': 'color == "orange-light"', '[class.mdl-button--orange]': 'color == "orange"', '[class.mdl-button--orange-dark]': 'color == "orange-dark"', '[class.mdl-button--orange-darkest]': 'color == "orange-darkest"', '[class.mdl-button--yellow-lightest]': 'color == "yellow-lightest"', '[class.mdl-button--yellow-light]': 'color == "yellow-light"', '[class.mdl-button--yellow]': 'color == "yellow"', '[class.mdl-button--yellow-dark]': 'color == "yellow-dark"', '[class.mdl-button--yellow-darkest]': 'color == "yellow-darkest"', '[class.mdl-button--purple-lightest]': 'color == "purple-lightest"', '[class.mdl-button--purple-light]': 'color == "purple-light"', '[class.mdl-button--purple]': 'color == "purple"', '[class.mdl-button--purple-dark]': 'color == "purple-dark"', '[class.mdl-button--purple-darkest]': 'color == "purple-darkest"', '[class.mdl-button--pink-lightest]': 'color == "pink-lightest"', '[class.mdl-button--pink-light]': 'color == "pink-light"', '[class.mdl-button--pink]': 'color == "pink"', '[class.mdl-button--pink-dark]': 'color == "pink-dark"', '[class.mdl-button--pink-darkest]': 'color == "pink-darkest"' }, encapsulation: core.ViewEncapsulation.None },] }, ]; ButtonComponent.ctorParameters = function () { return [ { type: core.ElementRef, }, ]; }; ButtonComponent.propDecorators = { 'color': [{ type: core.Input },], 'mode': [{ type: core.Input },], 'size': [{ type: core.Input },], }; return ButtonComponent; }()); var ButtonModule = (function () { function ButtonModule() { } ButtonModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ ButtonComponent ], exports: [ ButtonComponent ], schemas: [core.CUSTOM_ELEMENTS_SCHEMA] },] }, ]; ButtonModule.ctorParameters = function () { return []; }; return ButtonModule; }()); var CameraComponent = (function () { function CameraComponent(_changeDetectorRef) { this._changeDetectorRef = _changeDetectorRef; this.status = { support: true, permission: true, error: false }; this.onReady = new core.EventEmitter(); this._navigator = navigator; } CameraComponent.prototype.ngOnInit = function () { var _this = this; if (this._navigator.mediaDevices && this._navigator.mediaDevices.getUserMedia) { this._navigator.mediaDevices.getUserMedia({ video: true }) .then(function (stream) { return _this._play(stream); }) .catch(function (err) { return _this._onError(err); }); } else if (this._navigator.getUserMedia) { this._navigator.getUserMedia({ video: true }, function (stream) { return _this._play(stream); }, function (err) { return _this._onError(err); }); } else if (this._navigator.webkitGetUserMedia) { this._navigator.webkitGetUserMedia({ video: true }, function (stream) { return _this._play(stream); }, function (err) { return _this._onError(err); }); } else if (this._navigator.mozGetUserMedia) { this._navigator.mozGetUserMedia({ video: true }, function (stream) { return _this._play(stream); }, function (err) { return _this._onError(err); }); } else { this.status.support = false; this._onError(); } }; CameraComponent.prototype.ngOnDestroy = function () { this._pause(); }; CameraComponent.prototype.takePicture = function () { if (!this.cameraWrapper) return null; var canvas = this._getCanvas(this.cameraWrapper.nativeElement); this.picture = canvas.toDataURL('image/jpeg'); return this.picture; }; CameraComponent.prototype._getCanvas = function (wrapper) { var canvas = document.createElement('canvas'); canvas.width = this.cameraWrapper.nativeElement.videoWidth; canvas.height = this.cameraWrapper.nativeElement.videoHeight; canvas.getContext('2d').drawImage(wrapper, 0, 0); return canvas; }; CameraComponent.prototype._play = function (stream) { if (this.cameraWrapper) { this.stream = stream; this.cameraWrapper.nativeElement.src = window.URL.createObjectURL(stream); this.cameraWrapper.nativeElement.play(); var tracks = this.stream.getTracks(); this._onSuccess(); } }; CameraComponent.prototype._pause = function () { if (this.cameraWrapper && this.stream) { var tracks = this.stream.getTracks(); if (tracks) tracks.forEach(function (track) { return track.stop(); }); this.cameraWrapper.nativeElement.pause(); } }; CameraComponent.prototype._onSuccess = function () { this.onReady.emit(this.status); }; CameraComponent.prototype._onError = function (err) { if (err && (err.name == 'PermissionDeniedError' || err.name == 'NotAllowedError')) this.status.permission = false; this.status.error = true; this.onReady.emit(this.status); }; CameraComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-camera', template: "<video #cameraWrapper class=\"uex-camera-wrapper\"></video> ", styles: ["uex-camera { display: table; max-width: 100%; } uex-camera .uex-camera-wrapper { max-width: 100%; } "], encapsulation: core.ViewEncapsulation.None },] }, ]; CameraComponent.ctorParameters = function () { return [ { type: core.ChangeDetectorRef, }, ]; }; CameraComponent.propDecorators = { 'cameraWrapper': [{ type: core.ViewChild, args: ['cameraWrapper',] },], }; return CameraComponent; }()); var CameraModule = (function () { function CameraModule() { } CameraModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ CameraComponent ], imports: [ common.CommonModule ], exports: [ CameraComponent ] },] }, ]; CameraModule.ctorParameters = function () { return []; }; return CameraModule; }()); var CardComponent = (function () { function CardComponent() { } CardComponent.prototype.ngOnInit = function () { }; CardComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-card', template: "<div class=\"mdl-card mdl-shadow--2dp\"> <ng-content></ng-content> </div> ", styles: ["uex-card { display: block; width: 100%; } uex-card .mdl-card { position: static; width: 100%; min-height: 0; } *:not(.uex-grid-item) > uex-card { padding: 5px; } *:not(.uex-grid-item) > uex-card + .uex-grid { margin-top: -5px; } "], host: { class: 'uex-card' }, encapsulation: core.ViewEncapsulation.None },] }, ]; CardComponent.ctorParameters = function () { return []; }; return CardComponent; }()); var CardHeaderComponent = (function () { function CardHeaderComponent() { } CardHeaderComponent.prototype.ngOnInit = function () { }; CardHeaderComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-card-header', template: "<ng-content></ng-content> ", styles: ["uex-card-header.mdl-card__title { flex-wrap: wrap; } "], host: { class: 'mdl-card__title' }, encapsulation: core.ViewEncapsulation.None },] }, ]; CardHeaderComponent.ctorParameters = function () { return []; }; return CardHeaderComponent; }()); var CardMediaComponent = (function () { function CardMediaComponent() { } CardMediaComponent.prototype.ngOnInit = function () { }; CardMediaComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-card-media', template: '<ng-content></ng-content>', styles: ["uex-card-media { display: block; } uex-card-media .mdl-card__media { width: 100%; } "], host: { class: 'mdl-card__media' }, encapsulation: core.ViewEncapsulation.None },] }, ]; CardMediaComponent.ctorParameters = function () { return []; }; return CardMediaComponent; }()); var CardContentComponent = (function () { function CardContentComponent() { } CardContentComponent.prototype.ngOnInit = function () { }; CardContentComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-card-content', template: "<ng-content></ng-content> ", styles: ["uex-card-content { display: block; } uex-card-content.mdl-card__content { width: 100%; padding: 15px; font-size: 1em; overflow: visible; } uex-card-header + uex-card-content.mdl-card__content, uex-card-media + uex-card-content.mdl-card__content { padding-top: 0; } "], host: { class: 'mdl-card__content mdl-card__supporting-text' }, encapsulation: core.ViewEncapsulation.None },] }, ]; CardContentComponent.ctorParameters = function () { return []; }; return CardContentComponent; }()); var CardFooterComponent = (function () { function CardFooterComponent() { } CardFooterComponent.prototype.ngOnInit = function () { }; CardFooterComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-card-footer', template: "<ng-content></ng-content> <div class=\"mdl-card__action-left\"> <ng-content select=\"[left]\"></ng-content> </div> <div class=\"mdl-card__action-right\"> <ng-content select=\"[right]\"></ng-content> </div> ", styles: ["uex-card-footer { display: block; } uex-card-footer.mdl-card__actions { display: table; width: 100%; padding: 15px; } uex-card-footer.mdl-card__actions .mdl-card__action-left { float: left; text-align: left; } uex-card-footer.mdl-card__actions .mdl-card__action-right { float: right; text-align: right; } uex-card-header + uex-card-footer.mdl-card__actions, uex-card-media + uex-card-footer.mdl-card__actions, uex-card-content + uex-card-footer.mdl-card__actions { padding-top: 0; } "], host: { class: 'mdl-card__actions' }, encapsulation: core.ViewEncapsulation.None },] }, ]; CardFooterComponent.ctorParameters = function () { return []; }; return CardFooterComponent; }()); var CardTitleComponent = (function () { function CardTitleComponent() { } CardTitleComponent.prototype.ngOnInit = function () { }; CardTitleComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-card-title', template: '<ng-content></ng-content>', styles: ["uex-card-title.mdl-card__title-text { width: 100%; color: #444444; } "], host: { class: 'mdl-card__title-text' }, encapsulation: core.ViewEncapsulation.None },] }, ]; CardTitleComponent.ctorParameters = function () { return []; }; return CardTitleComponent; }()); var CardSubtitleComponent = (function () { function CardSubtitleComponent() { } CardSubtitleComponent.prototype.ngOnInit = function () { }; CardSubtitleComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-card-subtitle', template: '<ng-content></ng-content>', styles: ["uex-card-subtitle.mdl-card__subtitle-text { width: 100%; color: #777777; } uex-card-title.mdl-card__title-text + uex-card-subtitle.mdl-card__subtitle-text { margin-top: 15px; } "], host: { class: 'mdl-card__subtitle-text' }, encapsulation: core.ViewEncapsulation.None },] }, ]; CardSubtitleComponent.ctorParameters = function () { return []; }; return CardSubtitleComponent; }()); var CardMenuComponent = (function () { function CardMenuComponent() { } CardMenuComponent.prototype.ngOnInit = function () { }; CardMenuComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-card-menu', template: '<ng-content></ng-content>', host: { class: 'mdl-card__menu' }, encapsulation: core.ViewEncapsulation.None },] }, ]; CardMenuComponent.ctorParameters = function () { return []; }; return CardMenuComponent; }()); var CardModule = (function () { function CardModule() { } CardModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ CardComponent, CardHeaderComponent, CardMediaComponent, CardContentComponent, CardFooterComponent, CardTitleComponent, CardSubtitleComponent, CardMenuComponent ], exports: [ CardComponent, CardHeaderComponent, CardMediaComponent, CardContentComponent, CardFooterComponent, CardTitleComponent, CardSubtitleComponent, CardMenuComponent ], schemas: [core.CUSTOM_ELEMENTS_SCHEMA, core.NO_ERRORS_SCHEMA] },] }, ]; CardModule.ctorParameters = function () { return []; }; return CardModule; }()); var ContainerComponent = (function () { function ContainerComponent() { } ContainerComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-container', template: "<div class=\"uex-container\" [class.uex-container-small]=\"size == 'small'\" [class.uex-container-medium]=\"size == 'medium'\" [class.uex-container-large]=\"size == 'large'\" [class.uex-container-xlarge]=\"size == 'xlarge'\" [class.uex-container-responsive]=\"size == 'responsive'\" > <ng-content></ng-content> </div> ", styles: ["uex-container .uex-container { width: 400px; max-width: 100%; margin: 0 auto; } uex-container .uex-container.uex-container-small { width: 300px; } uex-container .uex-container.uex-container-medium { width: 700px; } uex-container .uex-container.uex-container-large { width: 990px; } uex-container .uex-container.uex-container-xlarge { width: 1200px; } uex-container .uex-container.uex-container-responsive { width: 100%; } "], encapsulation: core.ViewEncapsulation.None },] }, ]; ContainerComponent.ctorParameters = function () { return []; }; ContainerComponent.propDecorators = { 'size': [{ type: core.Input, args: ['size',] },], }; return ContainerComponent; }()); var ContainerModule = (function () { function ContainerModule() { } ContainerModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ ContainerComponent ], exports: [ ContainerComponent ], schemas: [core.CUSTOM_ELEMENTS_SCHEMA] },] }, ]; ContainerModule.ctorParameters = function () { return []; }; return ContainerModule; }()); var ToastService = (function () { function ToastService() { this.onOpen = new core.EventEmitter(); this.onClose = new core.EventEmitter(); this.visible = false; this.duration = 5000; this.showAction = false; } ToastService.prototype.open = function (settings) { var _this = this; this._clearTimeout(); this.message = settings.message; this.duration = settings.duration ? settings.duration : 5000; this.actionText = settings.actionText; this.showAction = _.isBoolean(settings.showAction) ? settings.showAction : false; this.visible = true; this.onOpen.emit(); if (this.duration > 0) { this._durationTimeout = setTimeout(function () { _this.close(); }, this.duration); } }; ToastService.prototype.close = function () { this._clearTimeout(); this.visible = false; this.message = null; this.duration = 5000; this.actionText = null; this.showAction = true; this.onClose.emit(); }; ToastService.prototype._clearTimeout = function () { if (this._durationTimeout) clearTimeout(this._durationTimeout); }; ToastService.decorators = [ { type: core.Injectable }, ]; ToastService.ctorParameters = function () { return []; }; return ToastService; }()); var ToastComponent = (function () { function ToastComponent(toastService) { var _this = this; this.toastService = toastService; this.visible = false; toastService.onOpen.subscribe(function () { _this.message = toastService.message; _this.actionText = toastService.actionText; _this.visible = toastService.visible; }); toastService.onClose.subscribe(function () { _this.message = toastService.message; _this.actionText = toastService.actionText; _this.visible = toastService.visible; }); } ToastComponent.prototype.hasAction = function () { return this.toastService.showAction; }; ToastComponent.prototype.onClick = function () { this.toastService.close(); }; ToastComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-toast', template: "<div class=\"mdl-snackbar__text\">{{message}}</div> <button class=\"mdl-snackbar__action\" type=\"button\" (click)=\"onClick()\" *ngIf=\"hasAction()\">{{actionText}}</button> ", styles: ["uex-toast { z-index: 11000 !important; } uex-toast .mdl-snackbar__action { color: #FFFFFF; } "], host: { 'class': 'uex-toast mdl-snackbar', '[class.mdl-snackbar--active]': 'visible' }, encapsulation: core.ViewEncapsulation.None },] }, ]; ToastComponent.ctorParameters = function () { return [ { type: ToastService, }, ]; }; return ToastComponent; }()); var ToastModule = (function () { function ToastModule() { } ToastModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ ToastComponent ], imports: [ common.CommonModule ], exports: [ ToastComponent ], providers: [ ToastService ], schemas: [core.CUSTOM_ELEMENTS_SCHEMA] },] }, ]; ToastModule.ctorParameters = function () { return []; }; return ToastModule; }()); var DisabledDirective = (function () { function DisabledDirective() { } DisabledDirective.decorators = [ { type: core.Directive, args: [{ selector: '[uexDisabled]', host: { '[attr.disabled]': 'disabled ? true : null' } },] }, ]; DisabledDirective.ctorParameters = function () { return []; }; DisabledDirective.propDecorators = { 'disabled': [{ type: core.Input, args: ['uexDisabled',] },], }; return DisabledDirective; }()); var MDLDirective = (function () { function MDLDirective(element) { this.element = element; } MDLDirective.prototype.ngAfterViewInit = function () { componentHandler.upgradeElements(this.element.nativeElement); }; MDLDirective.decorators = [ { type: core.Directive, args: [{ selector: '[mdl]' },] }, ]; MDLDirective.ctorParameters = function () { return [ { type: core.ElementRef, }, ]; }; return MDLDirective; }()); var PortalDirective = (function () { function PortalDirective(viewContainerRef) { this.viewContainerRef = viewContainerRef; } Object.defineProperty(PortalDirective.prototype, "portal", { set: function (template) { if (template) this.viewContainerRef.createEmbeddedView(template); }, enumerable: true, configurable: true }); PortalDirective.decorators = [ { type: core.Directive, args: [{ selector: '[uex-portal]', },] }, ]; PortalDirective.ctorParameters = function () { return [ { type: core.ViewContainerRef, }, ]; }; PortalDirective.propDecorators = { 'portal': [{ type: core.Input, args: ['uex-portal',] },], }; return PortalDirective; }()); var BaseModel = (function () { function BaseModel(http$$1, toastService) { this.http = http$$1; this.toastService = toastService; this.path = ''; this.timeout = 30000; } BaseModel.prototype.buildResource = function (resource_params) { var _this = this; resource_params = this.setResourceParamsDefaults(resource_params); var resource = function (request_params) { if (request_params === void 0) { request_params = {}; } var resource_path = _this.getPath(resource_params); if (resource_params.method != http.RequestMethod.Get) { resource_params.cache = null; } var child_name = _.snakeCase(_this.constructor.name.replace('Model', '')); var schema_name = resource_params.cache ? child_name + "_" + resource_params.cache.name : null; return new Promise(function (resolve, reject) { var request_url = _this.url + _this.path + _this.parseResourcePath(resource_path, request_params); var logout_on_unauthorized = _this.getLogoutOnUnauthorized(resource_params, request_params); var request_options = _this.getOptions(resource_params, request_params); var cache_info = { enabled: resource_params.cache ? true : false, replace: true, name: schema_name, params: request_params }; var timeout$$1 = resource_params.timeout ? resource_params.timeout : _this.timeout; _this.http. request(request_url, request_options). timeout(timeout$$1). subscribe(function (response) { return resolve(_this.handleSuccess(response, cache_info, resource_params.responseInterceptor)); }, function (err) { return reject(_this.handleError(err, cache_info, logout_on_unauthorized, resource_params.responseInterceptor)); }); }); }; return resource; }; BaseModel.prototype.getPath = function (resource_params) { var _path = resource_params.path ? resource_params.path : ''; var _keys = resource_params.path ? resource_params.path.match(/\{([^\{\}]*)\}/g) : []; var resource_path = { template: _path ? _path : '', keys: _keys ? _keys : [] }; resource_path.keys.forEach(function (key, index) { resource_path.template = resource_path.template.replace(key, '{$' + (index + 1) + '}'); resource_path.keys[index] = key.replace(/[\{\}]/g, ''); }); return resource_path; }; BaseModel.prototype.parseResourcePath = function (resource_path, request_params) { var path = resource_path.template; var _this = this; resource_path.keys.forEach(function (key, index) { var is_optional = key[0] == '?' || key[1] == '?'; var ignore_from_payload = key[0] == '!' || key[1] == '!'; var clean_key = (is_optional || ignore_from_payload) ? key.replace(/[\?\!]/g, '') : key; var value = _this.findParamsKey(request_params, clean_key.split('.'), ignore_from_payload); var path_key = (value == '' && is_optional && path.indexOf('/{$' + (index + 1) + '}') > -1) ? '/{$' + (index + 1) + '}' : '{$' + (index + 1) + '}'; path = path.replace(path_key, value); }); return path; }; BaseModel.prototype.headerInterceptor = function (headers, resource_params, request_params) { return headers; }; BaseModel.prototype.clearSession = function () { }; BaseModel.prototype.getOptions = function (resource_params, request_params) { var params; var use_body; if (resource_params.method == http.RequestMethod.Get) { params = new http.URLSearchParams(); this.setParams(params, request_params); use_body = false; } else { params = request_params; use_body = true; } var request_options = new http.RequestOptions({ method: resource_params.method, headers: this.getHeaders(resource_params, request_params), body: use_body ? params : null, search: !use_body ? params : null, withCredentials: resource_params.withCredentials }); if (!_.isEmpty(resource_params.requestInterceptor)) { return resource_params.requestInterceptor(request_options); } return request_options; }; BaseModel.prototype.getHeaders = function (resource_params, request_params) { var headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }; if (_.isFunction(this.headerInterceptor)) { return new http.Headers(this.headerInterceptor(headers, resource_params, request_params)); } return new http.Headers(headers); }; BaseModel.prototype.getLogoutOnUnauthorized = function (resource_params, request_params) { var logout_on_unauthorized = true; if (!_.isEmpty(resource_params) && _.isBoolean(resource_params.logoutOnUnauthorized)) { logout_on_unauthorized = resource_params.logoutOnUnauthorized; } else if (!_.isEmpty(request_params) && _.isBoolean(request_params.logoutOnUnauthorized)) { logout_on_unauthorized = request_params.logoutOnUnauthorized; } return logout_on_unauthorized; }; BaseModel.prototype.setParams = function (params, request_params, prefix) { var count = 0; if (_.isPlainObject(request_params)) { for (var key in request_params) { var item = request_params[key]; if (_.isEmpty(item) && !_.isBoolean(item) && !_.isNumber(item)) continue; var param_prefix = prefix ? prefix + "[" + key + "]" : key; if (_.isPlainObject(item) || _.isArray(item)) { if (this.setParams(params, item, param_prefix)) { count++; } else { continue; } } else { params.set(param_prefix, item); count++; } } } else if (_.isArray(request_params) && prefix) { var index = 0; for (var _i = 0, request_params_1 = request_params; _i < request_params_1.length; _i++) { var item = request_params_1[_i]; if (_.isEmpty(item) && !_.isBoolean(item) && !_.isNumber(item)) continue; var param_prefix = prefix + "[" + index + "]"; if (_.isPlainObject(item) || _.isArray(item)) { if (this.setParams(params, item, param_prefix)) { count++; } else { continue; } } else { params.set(param_prefix, item); count++; } index++; } } return count > 0; }; BaseModel.prototype.findParamsKey = function (params, key_arr, ignore_from_payload) { var value = ''; if (params instanceof Object) { if (key_arr.length > 1) { value = this.findParamsKey(params[key_arr[0]], key_arr.splice(1), ignore_from_payload); } else if (params[key_arr[0]]) { value = params[key_arr[0]]; if (ignore_from_payload) { delete params[key_arr[0]]; } } } return value ? value : ''; }; BaseModel.prototype.setResourceParamsDefaults = function (resource_params) { return Object.assign({ method: http.RequestMethod.Get, path: '', requestInterceptor: null, responseInterceptor: null, withCredentials: false, logoutOnUnauthorized: true }, resource_params); }; BaseModel.prototype.handleSuccess = function (response, cache_info, responseInterceptor) { var response_data; if (!cache_info.enabled || (cache_info.enabled && cache_info.replace)) { var data = _.isFunction(response.json) ? response.json() : response; response_data = { data: data, cached: false, status: response.status, statusText: response.statusText }; } else { response_data = response; response_data.cached = true; } if (_.isFunction(responseInterceptor)) { return responseInterceptor(response_data); } return response_data; }; BaseModel.prototype.handleError = function (err, cache_info, logout_on_unauthorized, responseInterceptor) { var response_data; if (err.status == 401 && logout_on_unauthorized) { this.clearSession(); self.location.reload(); } else if (err.status == 403) { this.toastService.open({ message: 'Você não tem autorização para utilizar esse recurso.' }); } if (!cache_info.enabled || (cache_info.enabled && cache_info.replace)) { if (err.name == "TimeoutError") { err.statusText = "TimeoutError"; err.status = 504; } response_data = { data: (err && _.isFunction(err.json)) ? err.json() : {}, cached: false, status: err.status, statusText: err.statusText }; } else { response_data = { data: {}, cached: true, status: 0, statusText: err.message }; } if (_.isFunction(responseInterceptor)) { return responseInterceptor(response_data); } return response_data; }; return BaseModel; }()); var BaseEnum = (function () { function BaseEnum(enumerators) { this.enumerators = enumerators; for (var enumerator_key in this.enumerators) { this[enumerator_key] = this.enumerators[enumerator_key][0]; this[this.enumerators[enumerator_key][0]] = enumerator_key; } } BaseEnum.prototype.toArray = function (value_key, label_key) { if (value_key === void 0) { value_key = 'value'; } if (label_key === void 0) { label_key = 'label'; } var enum_array = []; _.forEach(this.enumerators, function (enum_data, enum_key) { var data = {}; _.set(data, label_key, enum_data[1]); _.set(data, value_key, enum_data[0]); enum_array.push(data); }); return enum_array; }; BaseEnum.prototype.getKeys = function () { var keys = []; _.forEach(this.enumerators, function (enum_data, enum_key) { keys.push(enum_key); }); return keys; }; BaseEnum.prototype.getValues = function () { var values = []; _.forEach(this.enumerators, function (enum_data, enum_key) { values.push(enum_data[0]); }); return values; }; BaseEnum.prototype.humanize = function (value) { var humanized = ""; _.forEach(this.enumerators, function (enum_data, enum_key) { if (enum_data[0] == value) { humanized = enum_data[1]; } }); return humanized; }; return BaseEnum; }()); var GenericModule = (function () { function GenericModule() { } GenericModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ DisabledDirective, MDLDirective, PortalDirective ], imports: [ common.CommonModule, http.HttpModule, ToastModule ], exports: [ DisabledDirective, MDLDirective, PortalDirective ] },] }, ]; GenericModule.ctorParameters = function () { return []; }; return GenericModule; }()); var IconComponent = (function () { function IconComponent(elementRef) { this.elementRef = elementRef; this.mode = 'md'; } IconComponent.prototype.ngOnInit = function () { this.setClass(); }; IconComponent.prototype.ngOnChanges = function () { this.setClass(); }; IconComponent.prototype.getValue = function () { switch (this.mode) { case 'fa': return null; default: return this.name; } }; IconComponent.prototype.setClass = function () { var pattern = /fa\-[a-z0-9\-]*/; var default_classes = ['fa', 'material-icons', 'uex-icon']; var new_classes = this.elementRef.nativeElement.className.split(' ').filter(function (el_class) { return el_class && !pattern.test(el_class) && (default_classes.indexOf(el_class) == -1); }); new_classes.push('uex-icon'); switch (this.mode) { case 'fa': new_classes.push("fa fa-fw fa-" + this.name); break; default: new_classes.push('material-icons'); } var size_class = this.getSizeClass(); if (size_class) new_classes.push(size_class); this.elementRef.nativeElement.className = new_classes.join(' '); }; IconComponent.prototype.getSizeClass = function () { switch (this.size) { case '2x': return 'size-2x'; case '3x': return 'size-3x'; case '4x': return 'size-4x'; case '5x': return 'size-5x'; default: return null; } }; IconComponent.decorators = [ { type: core.Component, args: [{ selector: 'uex-icon', template: '{{getValue()}}', styles: ["uex-icon { display: inline-block; } uex-icon.size-2x { font-size: 2em; } uex-icon.size-3x { font-size: 3em; } uex-icon.size-4x { font-size: 4em; } uex-icon.size-5x { font-size: 5em; } "], encapsulation: core.ViewEncapsulation.None },] }, ]; IconComponent.ctorParameters = function () { return [ { type: core.ElementRef, }, ]; }; IconComponent.propDecorators = { 'mode': [{ type: core.Input },], 'size': [{ type: core.Input },], 'name': [{ type: core.Input },], }; return IconComponent; }()); var IconModule = (function () { function IconModule() { } IconModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ IconComponent ], imports: [ common.CommonModule ], exports: [ IconComponent ], schemas: [core.CUSTOM_ELEMENTS_SCHEMA] },] }, ]; IconModule.ctorParameters = function () { return []; }; return IconModule; }()); var DialogBase = (function () { function DialogBase(_dialogs, _data, index) { this._dialogs = _dialogs; this._data = _data; this.index = index; this.destroyed = false; this.onOpen = new core.EventEmitter(); this.onDismiss = new core.EventEmitter(); this.onClose = new core.EventEmitter(); this.onDestroy = new core.EventEmitter(); this.onReturnValue = new core.EventEmitter(); _dialogs.push(this); } Object.defineProperty(DialogBase.prototype, "visible", { get: function () { return this.ready ? this.componentInstance.visible : false; }, set: function (visible) { if (this.ready) this.componentInstance.visible = visible; }, enumerable: true, configurable: true }); Object.defineProperty(DialogBase.prototype, "ready", { get: function () { return this.componentInstance ? this.componentInstance.ready : false; }, set: function (ready) { if (this.componentInstance) this.componentInstance.ready = ready; }, enumerable: true, configurable: true }); Object.defineProperty(DialogBase.prototype, "component", { get: function () { return this._data.component; }, enumerable: true, configurable: true }); Object.defineProperty(DialogBase.prototype, "params", { get: function () { var params = new DialogParamsBase(); params.params = this._data.params; return params; }, enumerable: true, configurable: true }); Object.defineProperty(DialogBase.prototype, "settings", { get: function () { var settings = this._data.settings; if (!settings) settings = {}; if (!(settings.backdrop && settings.backdrop.onClick)) { if (!settings.backdrop) settings.backdrop = {}; settings.backdrop.onClick = 'close'; } if (!(settings.keyboard && settings.keyboard.onEscape)) { if (!settings.keyboard) settings.keyboard = {}; settings.keyboard.onEscape = 'none'; } if (!(settings.header && settings.header.closable && settings.header.closeClick)) { if (!settings.header) settings.header = { title: null }; if (settings.header.closable) settings.header.closeClick = 'close'; } return settings; }, enumerable: true, configurable: true }); Object.defineProperty(DialogBase.protot