model-form
Version:
Dynamic Form Builder for Anuglar 5 and the WAR Framework
1 lines • 5.05 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common","@angular/forms"],e):e((t.ng=t.ng||{},t.ng.modelForm=t.ng.modelForm||{}),t.ng.core,t.ng.common,t.ng.forms)}(this,function(t,e,n,o){"use strict";var r=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"model-input",template:'\n <div class="dynamic-field form-input form-group" [formGroup]="group">\n <label>{{map.name}}</label>\n <input type="text" [formControlName]="map.name" />\n </div>\n ',styles:[]}]}],t.ctorParameters=function(){return[]},t}(),m=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"model-email",template:'\n <div class="dynamic-field form-input form-group" [formGroup]="group">\n <label>{{map.name}}</label>\n <input type="text" [formControlName]="map.name" />\n </div>\n ',styles:[]}]}],t.ctorParameters=function(){return[]},t}(),a=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"model-number",template:'\n <div class="dynamic-field form-input form-group" [formGroup]="group">\n <label>{{map.name}}</label>\n <input type="text" [formControlName]="map.name" />\n </div>\n ',styles:[]}]}],t.ctorParameters=function(){return[]},t}(),i=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"model-switch",template:'\n <div class="dynamic-field form-input form-group" [formGroup]="group">\n <label>{{map.name}}</label>\n <input type="text" [formControlName]="map.name" />\n </div>\n ',styles:[]}]}],t.ctorParameters=function(){return[]},t}(),p=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"model-text",template:'\n <div class="dynamic-field form-input form-group" [formGroup]="group">\n <label>{{map.name}}</label>\n <input type="text" [formControlName]="map.name" />\n </div>\n ',styles:[]}]}],t.ctorParameters=function(){return[]},t}(),u={string:r,text:p,integer:a,date:r,array:r,bool:i,email:m,json:p},s=function(){function t(t,e){this.resolver=t,this.container=e}return t.prototype.ngOnInit=function(){var t=u[this.map.type],e=this.resolver.resolveComponentFactory(t);this.component=this.container.createComponent(e),this.component.instance.map=this.map,this.component.instance.model=this.model,this.component.instance.group=this.group},t.decorators=[{type:e.Directive,args:[{selector:"[modelField]"}]}],t.ctorParameters=function(){return[{type:e.ComponentFactoryResolver},{type:e.ViewContainerRef}]},t.propDecorators={map:[{type:e.Input}],model:[{type:e.Input}],group:[{type:e.Input}]},t}(),l=function(){function t(t){this.fb=t,this.map=[],this.submitted=new e.EventEmitter}return t.prototype.ngOnInit=function(){this.form=this.createGroup()},t.prototype.createGroup=function(){var t=this,e=this.fb.group({});return this.map.forEach(function(n){return e.addControl(n.name,t.fb.control(""))}),e},t.decorators=[{type:e.Component,args:[{selector:"model-form",template:'\n\t\t<form class="model-form compact" [formGroup]="form" (ngSubmit)="submitted.emit(form.value)">\n\t\t\t<section class="form-block">\n\t\t\t\t<ng-container modelField></ng-container>\n\t\t\t</section>\n\t\t</form>\n\t',styles:[]}]}],t.ctorParameters=function(){return[{type:o.FormBuilder}]},t.propDecorators={map:[{type:e.Input}],model:[{type:e.Input}],submitted:[{type:e.Output}]},t}(),c=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"model-radio",template:'\n <div class="dynamic-field form-input form-group" [formGroup]="group">\n <label>{{map.name}}</label>\n <input type="text" [formControlName]="map.name" />\n </div>\n ',styles:[]}]}],t.ctorParameters=function(){return[]},t}(),f=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"model-select",template:'\n <div class="dynamic-field form-input form-group" [formGroup]="group">\n <label>{{map.name}}</label>\n <input type="text" [formControlName]="map.name" />\n </div>\n ',styles:[]}]}],t.ctorParameters=function(){return[]},t}(),d=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"model-submit",template:'\n <div class="dynamic-field form-button" [formGroup]="group">\n <button class="btn btn-primary" type="submit">{{map.name}}</button>\n </div>\n ',styles:[]}]}],t.ctorParameters=function(){return[]},t}(),y=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[n.CommonModule,o.ReactiveFormsModule],exports:[l],declarations:[l,s,r,m,a,c,f,d,i,p],entryComponents:[r,m,a,c,f,d,i,p]}]}],t.ctorParameters=function(){return[]},t}();t.ModelFormModule=y,t.ModelFieldDirective=s,t.ModelFormComponent=l,t.InputComponent=r,t.EmailComponent=m,t.NumberComponent=a,t.RadioComponent=c,t.SelectComponent=f,t.SubmitComponent=d,t.SwitchComponent=i,t.TextComponent=p,Object.defineProperty(t,"__esModule",{value:!0})});