UNPKG

@hpe/angular-toolkit

Version:

Hewlett-Packard Enterprise : Angular toolkit for rapid project development

2 lines 14.4 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/forms"),require("@hpe/angular-toolkit/lib"),require("@hpe/angular-toolkit/model"),require("@hpe/angular-toolkit/service"),require("@angular/common"),require("@angular/material"),require("primeng/primeng"),require("@hpe/angular-toolkit/gui/panel"),require("@hpe/angular-toolkit/gui/directive")):"function"==typeof define&&define.amd?define("@hpe/angular-toolkit/gui/form",["exports","@angular/core","@angular/forms","@hpe/angular-toolkit/lib","@hpe/angular-toolkit/model","@hpe/angular-toolkit/service","@angular/common","@angular/material","primeng/primeng","@hpe/angular-toolkit/gui/panel","@hpe/angular-toolkit/gui/directive"],t):t((e.hpe=e.hpe||{},e.hpe["angular-toolkit"]=e.hpe["angular-toolkit"]||{},e.hpe["angular-toolkit"].gui=e.hpe["angular-toolkit"].gui||{},e.hpe["angular-toolkit"].gui.form={}),e.ng.core,e.ng.forms,e.hpe["angular-toolkit"].lib,e.hpe["angular-toolkit"].model,e.hpe["angular-toolkit"].service,e.ng.common,e.ng.material,null,e.hpe["angular-toolkit"].gui.panel,e.hpe["angular-toolkit"].gui.directive)}(this,function(e,n,o,r,l,t,i,a,s,p,u){"use strict";var c=function(){function e(){}return e.decorators=[{type:n.Component,args:[{selector:"hpe-form-column",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<div class="formColumn" [style.width]="width">\n <ng-content></ng-content>\n</div>\n',styles:[".formColumn{display:flex;flex-direction:column;align-content:center;justify-content:flex-start;margin:8px}"]}]}],e.propDecorators={width:[{type:n.Input}]},e}(),d=function(){function e(){}return e.decorators=[{type:n.Component,args:[{selector:"hpe-form-label",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<span class="ui-inputgroup-addon label">\n\t<hpe-icon name="{{icon}}"></hpe-icon> {{label}}\n</span>\n',styles:[".label{width:12rem;text-align:start!important}:host ::ng-deep .iconStyle{vertical-align:baseline}"]}]}],e.ctorParameters=function(){return[]},e.propDecorators={icon:[{type:n.Input}],label:[{type:n.Input}]},e}(),h=function(){function e(){}return e.decorators=[{type:n.Component,args:[{selector:"hpe-form-panel",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<div class="formBody">\n\t<ng-content></ng-content>\n</div>\n',styles:[".formBody{display:flex;align-content:center;justify-content:center;flex-wrap:wrap;box-sizing:border-box;width:100%;max-width:100%;padding:1rem;background:#fafafa;color:#000;font-size:1rem}"]}]}],e}(),f=function(){function e(){}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){this.transcoder&&null!=e&&(e=this.transcoder.transcode(e)),this._value=e},enumerable:!0,configurable:!0}),e.decorators=[{type:n.Component,args:[{selector:"hpe-form-text",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<div class="ui-inputgroup spacing">\n\t<hpe-form-label [icon]="icon" [label]="label"></hpe-form-label>\n\t<span class="ui-inputgroup-addon text">{{value}}</span>\n</div>\n',styles:[".spacing{margin-bottom:1rem}.text{background-color:#f5f5f5;width:100%;color:#202020}"]}]}],e.ctorParameters=function(){return[]},e.propDecorators={icon:[{type:n.Input}],label:[{type:n.Input}],transcoder:[{type:n.Input}],value:[{type:n.Input}]},e}(),g=function(e,t){return(g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function m(e,t){function n(){this.constructor=e}g(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var b=function(){function e(){this.enabled=!0,this._required=!1}return e.prototype.registerOnChange=function(e){this.onChange=e},e.prototype.registerOnTouched=function(e){},e.prototype.getComponentClass=function(){var e=["control"];return this.enabled?this.required&&(this.isProvided()?e.push("provided"):e.push("required")):e.push("disabled"),e},Object.defineProperty(e.prototype,"required",{get:function(){return this._required},set:function(e){""==""+e&&(e=!0),this._required=e},enumerable:!0,configurable:!0}),e.propDecorators={icon:[{type:n.Input}],label:[{type:n.Input}],enabled:[{type:n.Input}],required:[{type:n.Input}]},e}(),y=function(e){function t(){return e.call(this)||this}return m(t,e),t.prototype.writeValue=function(e){this._value=e},Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(e){""==e&&(e=null),this._value=e,this.onChange(e)},enumerable:!0,configurable:!0}),t.prototype.isProvided=function(){return r.Lib.str.isProvided(this.value)},t.decorators=[{type:n.Component,args:[{selector:"hpe-input-text",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<div class="ui-inputgroup spacing">\n <hpe-form-label [icon]="icon" [label]="label"></hpe-form-label>\n\t<input pInputText [(ngModel)]="value" [ngClass]="getComponentClass()" [disabled]="!enabled">\n</div>\n\n',styles:[".spacing{margin-bottom:1rem}.control{width:100%}.required,.required:focus{border-right:5px solid #ff8d6d}.provided,.provided:focus{border-right:5px solid #00a982}"],providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:t,multi:!0}]}]}],t.ctorParameters=function(){return[]},t}(b),v=function(e){function t(){return e.call(this)||this}return m(t,e),t.decorators=[{type:n.Component,args:[{selector:"hpe-input-area",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<div class="ui-inputgroup spacing" >\n\t<hpe-form-label [icon]="icon" [label]="label"></hpe-form-label>\n <textarea pInputTextarea [style.height]="height" [(ngModel)]="value" [ngClass]="getComponentClass()" [disabled]="!enabled"></textarea>\n</div>\n',styles:[".spacing{margin-bottom:1rem}.control{width:100%}.required,.required:focus{border-right:5px solid #ff8d6d}.provided,.provided:focus{border-right:5px solid #00a982}"],providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:t,multi:!0}]}]}],t.ctorParameters=function(){return[]},t.propDecorators={height:[{type:n.Input}]},t}(y),x=function(e){function t(){return e.call(this)||this}return m(t,e),t.decorators=[{type:n.Component,args:[{selector:"hpe-input-checkbox",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<div class="ui-inputgroup spacing">\n\t<hpe-form-label [icon]="icon" [label]="label"></hpe-form-label>\n\t<mat-checkbox [(ngModel)]="value" [ngClass]="getComponentClass()" [disabled]="!enabled"></mat-checkbox>\n</div>\n',styles:[".spacing{margin-bottom:1rem}.control{width:100%;margin-top:4px;margin-left:10px}.required{border-right:5px solid #ff8d6d}.provided{border-right:5px solid #00a982}:host ::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background{background-color:#80746e}"],providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:t,multi:!0}]}]}],t.ctorParameters=function(){return[]},t}(y),C=function(e){function t(){return e.call(this)||this}return m(t,e),Object.defineProperty(t.prototype,"dataMap",{get:function(){return this._dataMap},set:function(e){this._dataMap=e,this.key="id",this.value="value";var t=[];for(var n in this.required||t.push({id:null,value:null}),e){var o=Number(n),r=e[n];isNaN(o)&&(o=n),t.push({id:o,value:r})}this.data=t},enumerable:!0,configurable:!0}),t.prototype.writeValue=function(t){var n=this,e=this.data.find(function(e){return e[n.key]==t});null==e&&null!=this.data&&0<this.data.length&&(e=this.data[0]),this._selectedItem=e},Object.defineProperty(t.prototype,"selectedItem",{get:function(){return this._selectedItem},set:function(e){this._selectedItem=e,this.onChange(e[this.key])},enumerable:!0,configurable:!0}),t.prototype.isProvided=function(){return null!=this.selectedItem&&null!=this.selectedItem[this.key]},t.decorators=[{type:n.Component,args:[{selector:"hpe-input-combo",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<div class="ui-inputgroup spacing">\n\t<hpe-form-label [icon]="icon" [label]="label"></hpe-form-label>\n\n\t<p-dropdown [options] = "data"\n\t\t\t\t[dataKey] = "key"\n\t\t\t\t[optionLabel]= "value"\n\t\t\t\t[(ngModel)] = "selectedItem"\n\t\t\t\t[ngClass] = "getComponentClass()"\n\t\t\t\t[style] = "{ \'width\':\'100%\' }"\n\t\t\t\t[disabled] = "!enabled">\n\t</p-dropdown>\n</div>\n',styles:[".spacing{margin-bottom:1rem}.control{width:100%}.required{border-right:5px solid #ff8d6d}.provided{border-right:5px solid #00a982}"],providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:t,multi:!0}]}]}],t.ctorParameters=function(){return[]},t.propDecorators={key:[{type:n.Input}],value:[{type:n.Input}],data:[{type:n.Input}],dataMap:[{type:n.Input}]},t}(b),I=function(a){function e(e,t,n,o,r){var i=a.call(this,e)||this;return i.sessionService=t,i.notificationService=n,i.labelService=o,i.httpService=r,i.cred=new l.Credentials,a.prototype.subscribeToApp.call(i,l.AppEvent.LOGIN_FAILED,function(e){return i.onLoginFailed(e)}),i}return m(e,a),e.prototype.login=function(){if(this.areCredentialsValid())this.sessionService.login(this.cred);else{var e=this.labelService.getLabel("login-panel","missing.info");this.notificationService.showWarn(e.title,e.descr)}},Object.defineProperty(e.prototype,"title",{get:function(){return this.loc("title")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"username",{get:function(){return this.loc("username")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"password",{get:function(){return this.loc("password")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"button",{get:function(){return this.loc("button")},enumerable:!0,configurable:!0}),e.prototype.onLoginFailed=function(e){var t=this.labelService.getLabel("login-panel","login.error");this.notificationService.showError(t.title,t.descr)},e.prototype.areCredentialsValid=function(){return r.Lib.str.isProvided(this.cred.username)&&r.Lib.str.isProvided(this.cred.password)},e.prototype.loc=function(e){return this.labelService.getLabel("login-panel",e)},e.decorators=[{type:n.Component,args:[{selector:"hpe-login",template:'\x3c!--\n=============================================================================\n===\n=== (C) Copyright 2018 Hewlett Packard Enterprise Development LP.\n===\n=== Use of this source code is governed by an MIT-style license that can be\n=== found in the LICENSE file\n=============================================================================\n--\x3e\n\n<hpe-card-panel icon="fa-sign-in" [title]="title" [toggleButton]="false">\n\t<div cpBody>\n\t\t<hpe-form-panel>\n\n\t\t\t<hpe-form-column width="500px">\n\t\t\t\t<hpe-input-text icon="fa-user" [label]="username" [(ngModel)]="cred.username" required></hpe-input-text>\n\t\t\t\t<hpe-input-text icon="fa-key" [label]="password" [(ngModel)]="cred.password" required></hpe-input-text>\n\t\t\t</hpe-form-column>\n\n\t\t</hpe-form-panel>\n\n\t\t<hpe-button-panel>\n\t\t\t<div class="spinner" *ngIf="httpService.loading">\n\t\t\t\t<i class="fa fa-circle-o-notch fa-pulse"></i>\n\t\t\t</div>\n\t\t\t<button mat-button hpeButton (click)="login()">{{button}}</button>\n\t\t</hpe-button-panel>\n\t</div>\n</hpe-card-panel>\n\n\n\n',styles:[".spinner{position:absolute;left:16px;bottom:16px;font-size:32px}"]}]}],e.ctorParameters=function(){return[{type:t.EventBusService},{type:t.SessionService},{type:t.NotificationService},{type:t.LabelService},{type:t.HttpService}]},e}(t.AbstractSubscriber),k=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{imports:[i.CommonModule,o.FormsModule,a.MatCheckboxModule,a.MatButtonModule,s.DropdownModule,s.InputTextModule,p.HpePanelModule,u.HpeDirectiveModule,t.HpeServiceModule],declarations:[c,d,h,f,v,x,C,y,I],exports:[c,d,h,f,v,x,C,y,I],providers:[]}]}],e}();e.HpeFormModule=k,e.FormColumn=c,e.FormLabel=d,e.FormPanel=h,e.FormText=f,e.InputArea=v,e.InputCheckbox=x,e.InputCombo=C,e.InputText=y,e.LoginPanel=I,e.ɵa=b,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=hpe-angular-toolkit-gui-form.umd.min.js.map