UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

2 lines 12.5 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/common"),require("ng-zorro-antd/icon"),require("@angular/forms"),require("@angular/cdk/layout"),require("@angular/cdk/platform"),require("ng-zorro-antd/grid"),require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("ng-zorro-antd/core")):"function"==typeof define&&define.amd?define("ng-zorro-antd/form",["exports","@angular/common","ng-zorro-antd/icon","@angular/forms","@angular/cdk/layout","@angular/cdk/platform","ng-zorro-antd/grid","@angular/core","rxjs","rxjs/operators","ng-zorro-antd/core"],e):e((t["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].form={}),t.ng.common,t["ng-zorro-antd"].icon,t.ng.forms,t.ng.cdk.layout,t.ng.cdk.platform,t["ng-zorro-antd"].grid,t.ng.core,t.rxjs,t.rxjs.operators,t["ng-zorro-antd"].core)}(this,function(t,e,n,o,r,a,i,c,s,p,u){"use strict";var l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function d(t,e){function n(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function h(t,e,n,o){var r,a=arguments.length,i=a<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;0<=s;s--)(r=t[s])&&(i=(a<3?r(i):3<a?r(e,n,i):r(e,n))||i);return 3<a&&i&&Object.defineProperty(e,n,i),i}function f(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var m=function(){function t(t,e){this.elementRef=t,this.renderer=e,this.renderer.addClass(this.elementRef.nativeElement,"ant-form-explain")}return t.decorators=[{type:c.Component,args:[{selector:"nz-form-explain",exportAs:"nzFormExplain",preserveWhitespaces:!1,encapsulation:c.ViewEncapsulation.None,changeDetection:c.ChangeDetectionStrategy.OnPush,animations:[u.helpMotion],template:"<div [@helpMotion]>\n <ng-content></ng-content>\n</div>",styles:["\n nz-form-explain {\n display: block;\n }\n "]}]}],t.ctorParameters=function(){return[{type:c.ElementRef},{type:c.Renderer2}]},t}(),y=function(l){function t(t,e,n,o,r,a,i){var s=l.call(this,t,e,n,o,r,a)||this;return s.cdr=i,s.nzFlex=!1,e.addClass(t.nativeElement,"ant-form-item"),s}return d(t,l),t.prototype.ngAfterContentInit=function(){var t=this;this.listOfNzFormExplainComponent&&this.listOfNzFormExplainComponent.changes.pipe(p.takeUntil(this.destroy$)).subscribe(function(){t.cdr.markForCheck()})},t.prototype.ngOnChanges=function(t){(l.prototype.ngOnChanges.call(this,t),t.hasOwnProperty("nzFlex"))&&(t.nzFlex.currentValue?this.renderer.setStyle(this.elementRef.nativeElement,"display","flex"):this.renderer.removeStyle(this.elementRef.nativeElement,"display"))},t.decorators=[{type:c.Component,args:[{selector:"nz-form-item",exportAs:"nzFormItem",preserveWhitespaces:!1,changeDetection:c.ChangeDetectionStrategy.OnPush,encapsulation:c.ViewEncapsulation.None,providers:[u.NzUpdateHostClassService],template:"<ng-content></ng-content>",host:{"[class.ant-form-item-with-help]":"listOfNzFormExplainComponent && (listOfNzFormExplainComponent.length > 0)"},styles:["\n nz-form-item {\n display: block;\n }\n "]}]}],t.ctorParameters=function(){return[{type:c.ElementRef},{type:c.Renderer2},{type:u.NzUpdateHostClassService},{type:r.MediaMatcher},{type:c.NgZone},{type:a.Platform},{type:c.ChangeDetectorRef}]},t.propDecorators={nzFlex:[{type:c.Input}],listOfNzFormExplainComponent:[{type:c.ContentChildren,args:[m,{descendants:!0}]}]},h([u.InputBoolean(),f("design:type",Boolean)],t.prototype,"nzFlex",void 0),t}(i.NzRowDirective),g=function(s){function t(t,e,n,o,r,a){var i=s.call(this,t,e,n||o,a)||this;return i.cdr=r,i._hasFeedback=!1,i.controlClassMap={},a.addClass(e.nativeElement,"ant-form-item-control-wrapper"),i}return d(t,s),Object.defineProperty(t.prototype,"nzHasFeedback",{get:function(){return this._hasFeedback},set:function(t){this._hasFeedback=u.toBoolean(t),this.setControlClassMap()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nzValidateStatus",{set:function(t){t instanceof o.FormControl||t instanceof o.NgModel?(this.validateControl=t,this.validateString=null,this.watchControl()):t instanceof o.FormControlName?(this.validateControl=t.control,this.validateString=null,this.watchControl()):(this.validateString=t,this.validateControl=null,this.setControlClassMap())},enumerable:!0,configurable:!0}),t.prototype.removeSubscribe=function(){this.validateChanges&&(this.validateChanges.unsubscribe(),this.validateChanges=null)},t.prototype.watchControl=function(){var t=this;this.removeSubscribe(),this.validateControl&&this.validateControl.statusChanges&&(this.validateChanges=this.validateControl.statusChanges.pipe(p.startWith(null)).subscribe(function(){t.setControlClassMap(),t.cdr.markForCheck()}))},t.prototype.validateControlStatus=function(t){return!!this.validateControl&&(this.validateControl.dirty||this.validateControl.touched)&&this.validateControl.status===t},t.prototype.setControlClassMap=function(){var t;"warning"===this.validateString?(this.status="warning",this.iconType="exclamation-circle-fill"):"validating"===this.validateString||"pending"===this.validateString||this.validateControlStatus("PENDING")?(this.status="validating",this.iconType="loading"):"error"===this.validateString||this.validateControlStatus("INVALID")?(this.status="error",this.iconType="close-circle-fill"):"success"===this.validateString||this.validateControlStatus("VALID")?(this.status="success",this.iconType="check-circle-fill"):(this.status="init",this.iconType=""),this.controlClassMap=((t={})["has-warning"]="warning"===this.status,t["is-validating"]="validating"===this.status,t["has-error"]="error"===this.status,t["has-success"]="success"===this.status,t["has-feedback"]=this.nzHasFeedback,t)},t.prototype.ngOnInit=function(){s.prototype.ngOnInit.call(this),this.setControlClassMap()},t.prototype.ngOnDestroy=function(){this.removeSubscribe(),s.prototype.ngOnDestroy.call(this)},t.prototype.ngAfterContentInit=function(){!this.defaultValidateControl||this.validateControl||this.validateString||(this.nzValidateStatus=this.defaultValidateControl)},t.prototype.ngAfterViewInit=function(){s.prototype.ngAfterViewInit.call(this)},t.decorators=[{type:c.Component,args:[{selector:"nz-form-control",exportAs:"nzFormControl",preserveWhitespaces:!1,encapsulation:c.ViewEncapsulation.None,changeDetection:c.ChangeDetectionStrategy.OnPush,providers:[u.NzUpdateHostClassService],template:'<div class="ant-form-item-control" [ngClass]="controlClassMap">\n <span class="ant-form-item-children">\n <ng-content></ng-content>\n <span class="ant-form-item-children-icon">\n <i *ngIf="nzHasFeedback && iconType" nz-icon [type]="iconType"></i>\n </span>\n </span>\n <ng-content select="nz-form-explain"></ng-content>\n</div>',styles:["\n nz-form-control {\n display: block;\n }\n "]}]}],t.ctorParameters=function(){return[{type:u.NzUpdateHostClassService},{type:c.ElementRef},{type:y,decorators:[{type:c.Optional},{type:c.Host}]},{type:i.NzRowDirective,decorators:[{type:c.Optional},{type:c.Host}]},{type:c.ChangeDetectorRef},{type:c.Renderer2}]},t.propDecorators={defaultValidateControl:[{type:c.ContentChild,args:[o.NgControl]}],nzHasFeedback:[{type:c.Input}],nzValidateStatus:[{type:c.Input}]},t}(i.NzColDirective),C=function(){function t(t,e){this.elementRef=t,this.renderer=e,this.renderer.addClass(this.elementRef.nativeElement,"ant-form-extra")}return t.decorators=[{type:c.Component,args:[{selector:"nz-form-extra",exportAs:"nzFormExtra",template:"<ng-content></ng-content>",preserveWhitespaces:!1,encapsulation:c.ViewEncapsulation.None,changeDetection:c.ChangeDetectionStrategy.OnPush,styles:["\n nz-form-extra {\n display: block;\n }\n "]}]}],t.ctorParameters=function(){return[{type:c.ElementRef},{type:c.Renderer2}]},t}(),z=function(s){function t(t,e,n,o,r,a){var i=s.call(this,t,e,n||o,r)||this;return i.cdr=a,i.nzRequired=!1,i.defaultNoColon=!1,i.noColon="default",r.addClass(e.nativeElement,"ant-form-item-label"),i}return d(t,s),Object.defineProperty(t.prototype,"nzNoColon",{get:function(){return!!this.noColon},set:function(t){this.noColon=u.toBoolean(t)},enumerable:!0,configurable:!0}),t.prototype.setDefaultNoColon=function(t){this.defaultNoColon=u.toBoolean(t),this.cdr.markForCheck()},t.prototype.ngOnDestroy=function(){s.prototype.ngOnDestroy.call(this)},t.prototype.ngAfterViewInit=function(){s.prototype.ngAfterViewInit.call(this)},t.decorators=[{type:c.Component,args:[{selector:"nz-form-label",exportAs:"nzFormLabel",providers:[u.NzUpdateHostClassService],preserveWhitespaces:!1,encapsulation:c.ViewEncapsulation.None,changeDetection:c.ChangeDetectionStrategy.OnPush,template:'<label [attr.for]="nzFor"\n [class.ant-form-item-no-colon]="noColon === \'default\' ? defaultNoColon : nzNoColon"\n [class.ant-form-item-required]="nzRequired">\n <ng-content></ng-content>\n</label>'}]}],t.ctorParameters=function(){return[{type:u.NzUpdateHostClassService},{type:c.ElementRef},{type:y,decorators:[{type:c.Optional},{type:c.Host}]},{type:i.NzRowDirective,decorators:[{type:c.Optional},{type:c.Host}]},{type:c.Renderer2},{type:c.ChangeDetectorRef}]},t.propDecorators={nzFor:[{type:c.Input}],nzRequired:[{type:c.Input}],nzNoColon:[{type:c.Input}]},h([u.InputBoolean(),f("design:type",Object)],t.prototype,"nzRequired",void 0),t}(i.NzColDirective),v=function(){function t(t,e){this.elementRef=t,this.renderer=e,this.renderer.addClass(this.elementRef.nativeElement,"ant-form-split")}return t.decorators=[{type:c.Component,args:[{selector:"nz-form-split",exportAs:"nzFormSplit",preserveWhitespaces:!1,encapsulation:c.ViewEncapsulation.None,changeDetection:c.ChangeDetectionStrategy.OnPush,template:"<ng-content></ng-content>"}]}],t.ctorParameters=function(){return[{type:c.ElementRef},{type:c.Renderer2}]},t}(),N=function(){function t(t,e){this.elementRef=t,this.renderer=e,this.renderer.addClass(this.elementRef.nativeElement,"ant-form-text")}return t.decorators=[{type:c.Component,args:[{selector:"nz-form-text",exportAs:"nzFormText",preserveWhitespaces:!1,changeDetection:c.ChangeDetectionStrategy.OnPush,encapsulation:c.ViewEncapsulation.None,template:"<ng-content></ng-content>"}]}],t.ctorParameters=function(){return[{type:c.ElementRef},{type:c.Renderer2}]},t}(),b=function(){function t(t,e,n){this.elementRef=t,this.renderer=e,this.nzUpdateHostClassService=n,this.nzLayout="horizontal",this.nzNoColon=!1,this.destroy$=new s.Subject,this.renderer.addClass(t.nativeElement,"ant-form")}return t.prototype.setClassMap=function(){var t;this.nzUpdateHostClassService.updateHostClass(this.elementRef.nativeElement,((t={})["ant-form-"+this.nzLayout]=this.nzLayout,t))},t.prototype.updateItemsDefaultColon=function(){var e=this;this.nzFormLabelComponent&&this.nzFormLabelComponent.forEach(function(t){return t.setDefaultNoColon(e.nzNoColon)})},t.prototype.ngOnInit=function(){this.setClassMap()},t.prototype.ngOnChanges=function(t){this.setClassMap(),t.hasOwnProperty("nzNoColon")&&this.updateItemsDefaultColon()},t.prototype.ngAfterContentInit=function(){var t=this;this.nzFormLabelComponent.changes.pipe(p.startWith(null),p.takeUntil(this.destroy$)).subscribe(function(){t.updateItemsDefaultColon()})},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.decorators=[{type:c.Directive,args:[{selector:"[nz-form]",exportAs:"nzForm",providers:[u.NzUpdateHostClassService]}]}],t.ctorParameters=function(){return[{type:c.ElementRef},{type:c.Renderer2},{type:u.NzUpdateHostClassService}]},t.propDecorators={nzLayout:[{type:c.Input}],nzNoColon:[{type:c.Input}],nzFormLabelComponent:[{type:c.ContentChildren,args:[z,{descendants:!0}]}]},h([u.InputBoolean(),f("design:type",Boolean)],t.prototype,"nzNoColon",void 0),t}(),x=function(){function t(){}return t.decorators=[{type:c.NgModule,args:[{declarations:[C,z,b,y,g,m,N,v],exports:[C,z,b,y,g,m,N,v],imports:[e.CommonModule,i.NzGridModule,n.NzIconModule,r.LayoutModule,a.PlatformModule]}]}],t}();t.NzFormModule=x,t.NzFormDirective=b,t.NzFormControlComponent=g,t.NzFormExplainComponent=m,t.NzFormItemComponent=y,t.NzFormExtraComponent=C,t.NzFormLabelComponent=z,t.NzFormSplitComponent=v,t.NzFormTextComponent=N,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-form.umd.min.js.map