UNPKG

ng-zorro-antd

Version:

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

2 lines 16.1 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/layout"),require("@angular/cdk/platform"),require("@angular/common"),require("@angular/core"),require("ng-zorro-antd/grid"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/core"),require("@angular/forms"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ng-zorro-antd/form",["exports","@angular/cdk/layout","@angular/cdk/platform","@angular/common","@angular/core","ng-zorro-antd/grid","ng-zorro-antd/icon","ng-zorro-antd/core","@angular/forms","rxjs","rxjs/operators"],e):e(((t=t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].form={}),t.ng.cdk.layout,t.ng.cdk.platform,t.ng.common,t.ng.core,t["ng-zorro-antd"].grid,t["ng-zorro-antd"].icon,t["ng-zorro-antd"].core,t.ng.forms,t.rxjs,t.rxjs.operators)}(this,function(t,e,n,o,r,i,a,s,l,p,c){"use strict";var u=function(t,e){return(u=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}u(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function h(t,e,n,o){var r,i=arguments.length,a=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(a=(i<3?r(a):i>3?r(e,n,a):r(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function f(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var g=function(){function t(t,e){this.elementRef=t,this.renderer=e,this.renderer.addClass(this.elementRef.nativeElement,"ant-form-explain"),s.warnDeprecation("'nz-form-explain' is going to be removed in 9.0.0. Use [nzSuccessTip] | [nzWarningTip] | [nzErrorTip] | [nzValidatingTip] in nz-form-control instead. Read https://ng.ant.design/components/form/en")}return t.decorators=[{type:r.Component,args:[{selector:"nz-form-explain",exportAs:"nzFormExplain",preserveWhitespaces:!1,encapsulation:r.ViewEncapsulation.None,changeDetection:r.ChangeDetectionStrategy.OnPush,animations:[s.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:r.ElementRef},{type:r.Renderer2}]},t}();var m=function(t){function o(e,n,o,r,i,a,s,l){var p=t.call(this,e,n,o,r,i,a,s)||this;return p.cdr=l,p.nzFlex=!1,p.withHelpClass=!1,p.tipsMode=!1,n.addClass(e.nativeElement,"ant-form-item"),p}return d(o,t),o.prototype.updateFlexStyle=function(){this.nzFlex?this.renderer.setStyle(this.elementRef.nativeElement,"display","flex"):this.renderer.removeStyle(this.elementRef.nativeElement,"display")},o.prototype.setWithHelpViaTips=function(t){this.tipsMode=!0,this.withHelpClass=t,this.cdr.markForCheck()},o.prototype.ngAfterContentInit=function(){var t=this;this.tipsMode||this.listOfNzFormExplainComponent.changes.pipe(c.startWith(!0),c.takeUntil(this.destroy$)).subscribe(function(){t.withHelpClass=t.listOfNzFormExplainComponent&&t.listOfNzFormExplainComponent.length>0,t.cdr.markForCheck()})},o.prototype.ngOnInit=function(){t.prototype.ngOnInit.call(this),this.updateFlexStyle()},o.prototype.ngOnDestroy=function(){t.prototype.ngOnDestroy.call(this)},o.prototype.ngOnChanges=function(e){t.prototype.ngOnChanges.call(this,e),e.hasOwnProperty("nzFlex")&&this.updateFlexStyle()},o.decorators=[{type:r.Component,args:[{selector:"nz-form-item",exportAs:"nzFormItem",preserveWhitespaces:!1,changeDetection:r.ChangeDetectionStrategy.OnPush,encapsulation:r.ViewEncapsulation.None,providers:[s.NzUpdateHostClassService],template:"<ng-content></ng-content>",host:{"[class.ant-form-item-with-help]":"withHelpClass"},styles:["\n nz-form-item {\n display: block;\n }\n "]}]}],o.ctorParameters=function(){return[{type:r.ElementRef},{type:r.Renderer2},{type:s.NzUpdateHostClassService},{type:e.MediaMatcher},{type:r.NgZone},{type:n.Platform},{type:s.NzDomEventService},{type:r.ChangeDetectorRef}]},o.propDecorators={nzFlex:[{type:r.Input}],listOfNzFormExplainComponent:[{type:r.ContentChildren,args:[g,{descendants:!0}]}]},h([s.InputBoolean(),f("design:type",Boolean)],o.prototype,"nzFlex",void 0),o}(i.NzRowDirective);var y=function(t){function e(e,n,o,r,i,a){var s=t.call(this,e,n,o||r,a)||this;return s.nzFormItemComponent=o,s.cdr=i,s._hasFeedback=!1,s.validateChanges=p.Subscription.EMPTY,s.status=null,s.controlClassMap={},a.addClass(n.nativeElement,"ant-form-item-control-wrapper"),s}return d(e,t),Object.defineProperty(e.prototype,"nzHasFeedback",{get:function(){return this._hasFeedback},set:function(t){this._hasFeedback=s.toBoolean(t),this.setControlClassMap()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzValidateStatus",{set:function(t){t instanceof l.FormControl||t instanceof l.NgModel?(this.validateControl=t,this.validateString=null,this.watchControl()):t instanceof l.FormControlName?(this.validateControl=t.control,this.validateString=null,this.watchControl()):(this.validateString=t,this.validateControl=null,this.setControlClassMap())},enumerable:!0,configurable:!0}),e.prototype.removeSubscribe=function(){this.validateChanges.unsubscribe()},e.prototype.watchControl=function(){var t=this;this.removeSubscribe(),this.validateControl&&this.validateControl.statusChanges&&(this.validateChanges=this.validateControl.statusChanges.pipe(c.startWith(null)).subscribe(function(){t.setControlClassMap(),t.cdr.markForCheck()}))},e.prototype.validateControlStatus=function(t){return!!this.validateControl&&(this.validateControl.dirty||this.validateControl.touched)&&this.validateControl.status===t},e.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=null,this.iconType=""),this.hasTips&&this.nzFormItemComponent.setWithHelpViaTips(this.showErrorTip),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&&this.status,t)},Object.defineProperty(e.prototype,"hasTips",{get:function(){return!!(this.nzSuccessTip||this.nzWarningTip||this.nzErrorTip||this.nzValidatingTip)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showSuccessTip",{get:function(){return"success"===this.status&&!!this.nzSuccessTip},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showWarningTip",{get:function(){return"warning"===this.status&&!!this.nzWarningTip},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showErrorTip",{get:function(){return"error"===this.status&&!!this.nzErrorTip},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showValidatingTip",{get:function(){return"validating"===this.status&&!!this.nzValidatingTip},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showInnerTip",{get:function(){return this.showSuccessTip||this.showWarningTip||this.showErrorTip||this.showValidatingTip},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){t.prototype.ngOnInit.call(this),this.setControlClassMap()},e.prototype.ngOnDestroy=function(){this.removeSubscribe(),t.prototype.ngOnDestroy.call(this)},e.prototype.ngAfterContentInit=function(){this.validateControl||this.validateString||(this.defaultValidateControl instanceof l.FormControlDirective?this.nzValidateStatus=this.defaultValidateControl.control:this.nzValidateStatus=this.defaultValidateControl)},e.prototype.ngAfterViewInit=function(){t.prototype.ngAfterViewInit.call(this)},e.decorators=[{type:r.Component,args:[{selector:"nz-form-control",exportAs:"nzFormControl",preserveWhitespaces:!1,animations:[s.helpMotion],encapsulation:r.ViewEncapsulation.None,changeDetection:r.ChangeDetectionStrategy.OnPush,providers:[s.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 [nzType]="iconType"></i>\n </span>\n </span>\n <div class="ant-form-explain" *ngIf="showSuccessTip || showWarningTip || showErrorTip || showValidatingTip">\n <div @helpMotion>\n <ng-container *ngIf="showSuccessTip">\n <ng-container *nzStringTemplateOutlet="nzSuccessTip;context:{$implicit:validateControl};">{{ nzSuccessTip }}</ng-container>\n </ng-container>\n <ng-container *ngIf="showWarningTip">\n <ng-container *nzStringTemplateOutlet="nzWarningTip;context:{$implicit:validateControl};">{{ nzWarningTip }}</ng-container>\n </ng-container>\n <ng-container *ngIf="showErrorTip">\n <ng-container *nzStringTemplateOutlet="nzErrorTip;context:{$implicit:validateControl};">{{ nzErrorTip }}</ng-container>\n </ng-container>\n <ng-container *ngIf="showValidatingTip">\n <ng-container *nzStringTemplateOutlet="nzValidatingTip;context:{$implicit:validateControl};">{{ nzValidatingTip }}</ng-container>\n </ng-container>\n </div>\n </div>\n <ng-content *ngIf="!hasTips" select="nz-form-explain"></ng-content>\n <ng-content *ngIf="!nzExtra" select="nz-form-extra"></ng-content>\n <div class="ant-form-extra" *ngIf="nzExtra">\n <ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>\n </div>\n</div>',styles:["\n nz-form-control {\n display: block;\n }\n form .has-feedback .ant-input-suffix i {\n margin-right: 18px;\n }\n "]}]}],e.ctorParameters=function(){return[{type:s.NzUpdateHostClassService},{type:r.ElementRef},{type:m,decorators:[{type:r.Optional},{type:r.Host}]},{type:i.NzRowDirective,decorators:[{type:r.Optional},{type:r.Host}]},{type:r.ChangeDetectorRef},{type:r.Renderer2}]},e.propDecorators={defaultValidateControl:[{type:r.ContentChild,args:[l.NgControl,{static:!1}]}],nzSuccessTip:[{type:r.Input}],nzWarningTip:[{type:r.Input}],nzErrorTip:[{type:r.Input}],nzValidatingTip:[{type:r.Input}],nzExtra:[{type:r.Input}],nzHasFeedback:[{type:r.Input}],nzValidateStatus:[{type:r.Input}]},e}(i.NzColDirective);var C=function(){function t(t,e){this.elementRef=t,this.renderer=e,this.renderer.addClass(this.elementRef.nativeElement,"ant-form-extra"),s.warnDeprecation("'nz-form-extra' is going to be removed in 9.0.0. Use [nzExtra] in nz-form-control instead. Read https://ng.ant.design/components/form/en")}return t.decorators=[{type:r.Component,args:[{selector:"nz-form-extra",exportAs:"nzFormExtra",template:"<ng-content></ng-content>",preserveWhitespaces:!1,encapsulation:r.ViewEncapsulation.None,changeDetection:r.ChangeDetectionStrategy.OnPush,styles:["\n nz-form-extra {\n display: block;\n }\n "]}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:r.Renderer2}]},t}();var z=function(t){function e(e,n,o,r,i,a){var s=t.call(this,e,n,o||r,i)||this;return s.cdr=a,s.nzRequired=!1,s.defaultNoColon=!1,s.noColon="default",i.addClass(n.nativeElement,"ant-form-item-label"),s}return d(e,t),Object.defineProperty(e.prototype,"nzNoColon",{get:function(){return!!this.noColon},set:function(t){this.noColon=s.toBoolean(t)},enumerable:!0,configurable:!0}),e.prototype.setDefaultNoColon=function(t){this.defaultNoColon=s.toBoolean(t),this.cdr.markForCheck()},e.prototype.ngOnDestroy=function(){t.prototype.ngOnDestroy.call(this)},e.prototype.ngAfterViewInit=function(){t.prototype.ngAfterViewInit.call(this)},e.decorators=[{type:r.Component,args:[{selector:"nz-form-label",exportAs:"nzFormLabel",providers:[s.NzUpdateHostClassService],preserveWhitespaces:!1,encapsulation:r.ViewEncapsulation.None,changeDetection:r.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>'}]}],e.ctorParameters=function(){return[{type:s.NzUpdateHostClassService},{type:r.ElementRef},{type:m,decorators:[{type:r.Optional},{type:r.Host}]},{type:i.NzRowDirective,decorators:[{type:r.Optional},{type:r.Host}]},{type:r.Renderer2},{type:r.ChangeDetectorRef}]},e.propDecorators={nzFor:[{type:r.Input}],nzRequired:[{type:r.Input}],nzNoColon:[{type:r.Input}]},h([s.InputBoolean(),f("design:type",Object)],e.prototype,"nzRequired",void 0),e}(i.NzColDirective);var 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:r.Component,args:[{selector:"nz-form-split",exportAs:"nzFormSplit",preserveWhitespaces:!1,encapsulation:r.ViewEncapsulation.None,changeDetection:r.ChangeDetectionStrategy.OnPush,template:"<ng-content></ng-content>"}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:r.Renderer2}]},t}();var b=function(){function t(t,e){this.elementRef=t,this.renderer=e,this.renderer.addClass(this.elementRef.nativeElement,"ant-form-text")}return t.decorators=[{type:r.Component,args:[{selector:"nz-form-text",exportAs:"nzFormText",preserveWhitespaces:!1,changeDetection:r.ChangeDetectionStrategy.OnPush,encapsulation:r.ViewEncapsulation.None,template:"<ng-content></ng-content>"}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:r.Renderer2}]},t}();var x=function(){function t(t,e,n,o){this.nzConfigService=t,this.elementRef=e,this.renderer=n,this.nzUpdateHostClassService=o,this.nzLayout="horizontal",this.destroy$=new p.Subject,this.renderer.addClass(e.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 t=this;this.nzFormLabelComponent&&this.nzFormLabelComponent.forEach(function(e){return e.setDefaultNoColon(t.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(c.startWith(null),c.takeUntil(this.destroy$)).subscribe(function(){t.updateItemsDefaultColon()})},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.decorators=[{type:r.Directive,args:[{selector:"[nz-form]",exportAs:"nzForm",providers:[s.NzUpdateHostClassService]}]}],t.ctorParameters=function(){return[{type:s.NzConfigService},{type:r.ElementRef},{type:r.Renderer2},{type:s.NzUpdateHostClassService}]},t.propDecorators={nzLayout:[{type:r.Input}],nzNoColon:[{type:r.Input}],nzFormLabelComponent:[{type:r.ContentChildren,args:[z,{descendants:!0}]}]},h([s.WithConfig(!1),s.InputBoolean(),f("design:type",Boolean)],t.prototype,"nzNoColon",void 0),t}();var S=function(){function t(){}return t.decorators=[{type:r.NgModule,args:[{declarations:[C,z,x,m,y,g,b,v],exports:[C,z,x,m,y,g,b,v],imports:[o.CommonModule,i.NzGridModule,a.NzIconModule,e.LayoutModule,n.PlatformModule,s.NzAddOnModule]}]}],t}();t.NzFormControlComponent=y,t.NzFormDirective=x,t.NzFormExplainComponent=g,t.NzFormExtraComponent=C,t.NzFormItemComponent=m,t.NzFormLabelComponent=z,t.NzFormModule=S,t.NzFormSplitComponent=v,t.NzFormTextComponent=b,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-form.umd.min.js.map