ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 14.6 kB
JavaScript
!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/core/outlet"),require("ng-zorro-antd/grid"),require("ng-zorro-antd/icon"),require("@angular/forms"),require("ng-zorro-antd/core/animation"),require("ng-zorro-antd/core/util"),require("ng-zorro-antd/i18n"),require("rxjs"),require("rxjs/operators"),require("ng-zorro-antd/core/config"),require("ng-zorro-antd/core/logger")):"function"==typeof define&&define.amd?define("ng-zorro-antd/form",["exports","@angular/cdk/layout","@angular/cdk/platform","@angular/common","@angular/core","ng-zorro-antd/core/outlet","ng-zorro-antd/grid","ng-zorro-antd/icon","@angular/forms","ng-zorro-antd/core/animation","ng-zorro-antd/core/util","ng-zorro-antd/i18n","rxjs","rxjs/operators","ng-zorro-antd/core/config","ng-zorro-antd/core/logger"],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"].core.outlet,t["ng-zorro-antd"].grid,t["ng-zorro-antd"].icon,t.ng.forms,t["ng-zorro-antd"].core.animation,t["ng-zorro-antd"].core.util,t["ng-zorro-antd"].i18n,t.rxjs,t.rxjs.operators,t["ng-zorro-antd"].core.config,t["ng-zorro-antd"].core.logger)}(this,(function(t,e,n,o,r,i,a,s,l,u,c,p,d,h,f,g){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function m(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 z(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var y=function(){function t(t,e,n){this.nzConfigService=t,this.renderer=n,this.nzLayout="horizontal",this.nzDisableAutoTips=!1,this.destroy$=new d.Subject,this.inputChanges$=new d.Subject,this.renderer.addClass(e.nativeElement,"ant-form")}return t.prototype.getInputObservable=function(t){return this.inputChanges$.pipe(h.filter((function(e){return t in e})),h.map((function(e){return e[t]})))},t.prototype.ngOnChanges=function(t){this.inputChanges$.next(t)},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.decorators=[{type:r.Directive,args:[{selector:"[nz-form]",exportAs:"nzForm",host:{"[class.ant-form-horizontal]":"nzLayout === 'horizontal'","[class.ant-form-vertical]":"nzLayout === 'vertical'","[class.ant-form-inline]":"nzLayout === 'inline'"}}]}],t.ctorParameters=function(){return[{type:f.NzConfigService},{type:r.ElementRef},{type:r.Renderer2}]},t.propDecorators={nzLayout:[{type:r.Input}],nzNoColon:[{type:r.Input}],nzAutoTips:[{type:r.Input}],nzDisableAutoTips:[{type:r.Input}]},m([f.WithConfig("form",!1),c.InputBoolean(),z("design:type",Boolean)],t.prototype,"nzNoColon",void 0),m([f.WithConfig("form",{}),z("design:type",Object)],t.prototype,"nzAutoTips",void 0),m([c.InputBoolean(),z("design:type",Object)],t.prototype,"nzDisableAutoTips",void 0),t}();var v=function(){function t(t,e,n){this.cdr=n,this.status=null,this.hasFeedback=!1,this.withHelpClass=!1,this.destroy$=new d.Subject,e.addClass(t.nativeElement,"ant-form-item")}return Object.defineProperty(t.prototype,"nzFlex",{set:function(t){g.warnDeprecation("'nzFlex' is deprecated and going to be removed in 10.0.0.")},enumerable:!0,configurable:!0}),t.prototype.setWithHelpViaTips=function(t){this.withHelpClass=t,this.cdr.markForCheck()},t.prototype.setStatus=function(t){this.status=t,this.cdr.markForCheck()},t.prototype.setHasFeedback=function(t){this.hasFeedback=t,this.cdr.markForCheck()},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.decorators=[{type:r.Component,args:[{selector:"nz-form-item",exportAs:"nzFormItem",preserveWhitespaces:!1,changeDetection:r.ChangeDetectionStrategy.OnPush,encapsulation:r.ViewEncapsulation.None,host:{"[class.ant-form-item-has-success]":'status === "success"',"[class.ant-form-item-has-warning]":'status === "warning"',"[class.ant-form-item-has-error]":'status === "error"',"[class.ant-form-item-is-validating]":'status === "validating"',"[class.ant-form-item-has-feedback]":"hasFeedback && status","[class.ant-form-item-with-help]":"withHelpClass"},template:"\n <ng-content></ng-content>\n "}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:r.Renderer2},{type:r.ChangeDetectorRef}]},t.propDecorators={nzFlex:[{type:r.Input}]},t}();var C={error:"close-circle-fill",validating:"loading",success:"check-circle-fill",warning:"exclamation-circle-fill"},b=function(){function t(t,e,n,o,r,i){var a,s,l=this;this.nzFormItemComponent=e,this.cdr=n,this.nzFormDirective=i,this._hasFeedback=!1,this.validateChanges=d.Subscription.EMPTY,this.validateString=null,this.status=null,this.destroyed$=new d.Subject,this.validateControl=null,this.iconType=null,this.innerTip=null,this.nzAutoTips={},this.nzDisableAutoTips="default",o.addClass(t.nativeElement,"ant-form-item-control"),this.subscribeAutoTips(r.localeChange.pipe(h.tap((function(t){return l.localeId=t.locale})))),this.subscribeAutoTips(null===(a=this.nzFormDirective)||void 0===a?void 0:a.getInputObservable("nzAutoTips")),this.subscribeAutoTips(null===(s=this.nzFormDirective)||void 0===s?void 0:s.getInputObservable("nzDisableAutoTips").pipe(h.filter((function(){return"default"===l.nzDisableAutoTips}))))}return Object.defineProperty(t.prototype,"disableAutoTips",{get:function(){var t;return"default"!==this.nzDisableAutoTips?c.toBoolean(this.nzDisableAutoTips):null===(t=this.nzFormDirective)||void 0===t?void 0:t.nzDisableAutoTips},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nzHasFeedback",{get:function(){return this._hasFeedback},set:function(t){this._hasFeedback=c.toBoolean(t),this.nzFormItemComponent&&this.nzFormItemComponent.setHasFeedback(this._hasFeedback)},enumerable:!0,configurable:!0}),Object.defineProperty(t.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.setStatus())},enumerable:!0,configurable:!0}),t.prototype.watchControl=function(){var t=this;this.validateChanges.unsubscribe(),this.validateControl&&this.validateControl.statusChanges&&(this.validateChanges=this.validateControl.statusChanges.pipe(h.startWith(null),h.takeUntil(this.destroyed$)).subscribe((function(e){t.disableAutoTips||t.updateAutoErrorTip(),t.setStatus(),t.cdr.markForCheck()})))},t.prototype.setStatus=function(){this.status=this.getControlStatus(this.validateString),this.iconType=this.status?C[this.status]:null,this.innerTip=this.getInnerTip(this.status),this.nzFormItemComponent&&(this.nzFormItemComponent.setWithHelpViaTips(!!this.innerTip),this.nzFormItemComponent.setStatus(this.status))},t.prototype.getControlStatus=function(t){return"warning"===t||this.validateControlStatus("INVALID","warning")?"warning":"error"===t||this.validateControlStatus("INVALID")?"error":"validating"===t||"pending"===t||this.validateControlStatus("PENDING")?"validating":"success"===t||this.validateControlStatus("VALID")?"success":null},t.prototype.validateControlStatus=function(t,e){if(this.validateControl){var n=this.validateControl,o=n.dirty,r=n.touched,i=n.status;return(!!o||!!r)&&(e?this.validateControl.hasError(e):i===t)}return!1},t.prototype.getInnerTip=function(t){switch(t){case"error":return!this.disableAutoTips&&this.autoErrorTip||this.nzErrorTip;case"validating":return this.nzValidatingTip;case"success":return this.nzSuccessTip;case"warning":return this.nzWarningTip;default:return null}},t.prototype.updateAutoErrorTip=function(){var t,e,n,o,r,i,a;if(this.validateControl){var s=this.validateControl.errors||{},l="";for(var u in s)if(s.hasOwnProperty(u)&&(l=null!==(o=null!==(t=s[u][this.localeId])&&void 0!==t?t:null===(n=null===(e=this.nzAutoTips)||void 0===e?void 0:e[this.localeId])||void 0===n?void 0:n[u])&&void 0!==o?o:null===(a=null===(i=null===(r=this.nzFormDirective)||void 0===r?void 0:r.nzAutoTips)||void 0===i?void 0:i[this.localeId])||void 0===a?void 0:a[u]),l)break;this.autoErrorTip=l}},t.prototype.subscribeAutoTips=function(t){var e=this;null==t||t.pipe(h.takeUntil(this.destroyed$)).subscribe((function(){e.disableAutoTips||(e.updateAutoErrorTip(),e.setStatus(),e.cdr.markForCheck())}))},t.prototype.ngOnChanges=function(t){var e=t.nzDisableAutoTips,n=t.nzAutoTips,o=t.nzSuccessTip,r=t.nzWarningTip,i=t.nzErrorTip,a=t.nzValidatingTip;e||n?(this.updateAutoErrorTip(),this.setStatus()):(o||r||i||a)&&this.setStatus()},t.prototype.ngOnInit=function(){this.setStatus()},t.prototype.ngOnDestroy=function(){this.destroyed$.next(),this.destroyed$.complete()},t.prototype.ngAfterContentInit=function(){this.validateControl||this.validateString||(this.defaultValidateControl instanceof l.FormControlDirective?this.nzValidateStatus=this.defaultValidateControl.control:this.nzValidateStatus=this.defaultValidateControl)},t.decorators=[{type:r.Component,args:[{selector:"nz-form-control",exportAs:"nzFormControl",preserveWhitespaces:!1,animations:[u.helpMotion],encapsulation:r.ViewEncapsulation.None,changeDetection:r.ChangeDetectionStrategy.OnPush,template:'\n <div class="ant-form-item-control-input">\n <div class="ant-form-item-control-input-content">\n <ng-content></ng-content>\n </div>\n <span class="ant-form-item-children-icon">\n <i *ngIf="nzHasFeedback && iconType" nz-icon [nzType]="iconType"></i>\n </span>\n </div>\n <div class="ant-form-item-explain" *ngIf="innerTip">\n <div @helpMotion>\n <ng-container *nzStringTemplateOutlet="innerTip; context: { $implicit: validateControl }">{{ innerTip }}</ng-container>\n </div>\n </div>\n <div class="ant-form-item-extra" *ngIf="nzExtra">\n <ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>\n </div>\n '}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:v,decorators:[{type:r.Optional},{type:r.Host}]},{type:r.ChangeDetectorRef},{type:r.Renderer2},{type:p.NzI18nService},{type:y,decorators:[{type:r.Optional},{type:r.Host}]}]},t.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}],nzAutoTips:[{type:r.Input}],nzDisableAutoTips:[{type:r.Input}],nzExtra:[{type:r.Input}],nzHasFeedback:[{type:r.Input}],nzValidateStatus:[{type:r.Input}]},t}();var T=function(){function t(t,e,n,o){var r=this;this.cdr=n,this.nzFormDirective=o,this.nzRequired=!1,this.noColon="default",this.destroy$=new d.Subject,e.addClass(t.nativeElement,"ant-form-item-label"),this.nzFormDirective&&this.nzFormDirective.getInputObservable("nzNoColon").pipe(h.filter((function(){return"default"===r.noColon})),h.takeUntil(this.destroy$)).subscribe((function(){return r.cdr.markForCheck()}))}return Object.defineProperty(t.prototype,"nzNoColon",{get:function(){var t;return"default"!==this.noColon?this.noColon:null===(t=this.nzFormDirective)||void 0===t?void 0:t.nzNoColon},set:function(t){this.noColon=c.toBoolean(t)},enumerable:!0,configurable:!0}),t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.decorators=[{type:r.Component,args:[{selector:"nz-form-label",exportAs:"nzFormLabel",preserveWhitespaces:!1,encapsulation:r.ViewEncapsulation.None,changeDetection:r.ChangeDetectionStrategy.OnPush,template:'\n <label [attr.for]="nzFor" [class.ant-form-item-no-colon]="nzNoColon" [class.ant-form-item-required]="nzRequired">\n <ng-content></ng-content>\n </label>\n '}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:r.Renderer2},{type:r.ChangeDetectorRef},{type:y,decorators:[{type:r.Optional},{type:r.SkipSelf}]}]},t.propDecorators={nzFor:[{type:r.Input}],nzRequired:[{type:r.Input}],nzNoColon:[{type:r.Input}]},m([c.InputBoolean(),z("design:type",Object)],t.prototype,"nzRequired",void 0),t}();var F=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:"\n <ng-content></ng-content>\n "}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:r.Renderer2}]},t}();var I=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:"\n <ng-content></ng-content>\n "}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:r.Renderer2}]},t}();var D=function(){function t(){}return t.decorators=[{type:r.NgModule,args:[{declarations:[y,v,T,b,I,F],exports:[a.NzGridModule,y,v,T,b,I,F],imports:[o.CommonModule,a.NzGridModule,s.NzIconModule,e.LayoutModule,n.PlatformModule,i.NzOutletModule]}]}],t}();t.NzFormControlComponent=b,t.NzFormDirective=y,t.NzFormItemComponent=v,t.NzFormLabelComponent=T,t.NzFormModule=D,t.NzFormSplitComponent=F,t.NzFormTextComponent=I,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-form.umd.min.js.map