ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 8.8 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/a11y"),require("rxjs"),require("rxjs/operators"),require("ng-zorro-antd/core"),require("@angular/common"),require("@angular/core"),require("@angular/forms")):"function"==typeof define&&define.amd?define("ng-zorro-antd/radio",["exports","@angular/cdk/a11y","rxjs","rxjs/operators","ng-zorro-antd/core","@angular/common","@angular/core","@angular/forms"],t):t((e["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].radio={}),e.ng.cdk.a11y,e.rxjs,e.rxjs.operators,e["ng-zorro-antd"].core,e.ng.common,e.ng.core,e.ng.forms)}(this,function(e,t,r,n,o,i,a,s){"use strict";var c=function(e,t){return(c=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 u(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;0<=s;s--)(r=e[s])&&(a=(i<3?r(a):3<i?r(t,n,a):r(t,n))||a);return 3<i&&a&&Object.defineProperty(t,n,a),a}function p(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),a=[];try{for(;(void 0===t||0<t--)&&!(o=i.next()).done;)a.push(o.value)}catch(s){r={error:s}}finally{try{o&&!o.done&&(n=i["return"])&&n.call(i)}finally{if(r)throw r.error}}return a}function l(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(d(arguments[t]));return e}var h=(f.prototype.updateAutoFocus=function(){this.inputElement&&(this.nzAutoFocus?this.renderer.setAttribute(this.inputElement.nativeElement,"autofocus","autofocus"):this.renderer.removeAttribute(this.inputElement.nativeElement,"autofocus"))},f.prototype.onClick=function(e){e.stopPropagation(),e.preventDefault(),this.nzDisabled||this.checked||(this.select$.next(this),this.isNgModel&&(this.checked=!0,this.onChange(!0)))},f.prototype.focus=function(){this.focusMonitor.focusVia(this.inputElement,"keyboard")},f.prototype.blur=function(){this.inputElement.nativeElement.blur()},f.prototype.markForCheck=function(){this.cdr.markForCheck()},f.prototype.setDisabledState=function(e){this.nzDisabled=e,this.cdr.markForCheck()},f.prototype.writeValue=function(e){this.checked=e,this.cdr.markForCheck()},f.prototype.registerOnChange=function(e){this.isNgModel=!0,this.onChange=e},f.prototype.registerOnTouched=function(e){this.onTouched=e},f.prototype.ngAfterViewInit=function(){var t=this;this.focusMonitor.monitor(this.elementRef,!0).subscribe(function(e){e||(Promise.resolve().then(function(){return t.onTouched()}),t.touched$.next())}),this.updateAutoFocus()},f.prototype.ngOnChanges=function(e){e.nzAutoFocus&&this.updateAutoFocus()},f.prototype.ngOnDestroy=function(){this.focusMonitor.stopMonitoring(this.elementRef)},f.decorators=[{type:a.Component,args:[{selector:"[nz-radio]",exportAs:"nzRadio",preserveWhitespaces:!1,template:'<span class="ant-radio" [class.ant-radio-checked]="checked" [class.ant-radio-disabled]="nzDisabled">\n <input #inputElement type="radio" class="ant-radio-input" [disabled]="nzDisabled" [checked]="checked" [attr.name]="name">\n <span class="ant-radio-inner"></span>\n</span>\n<span><ng-content></ng-content></span>',encapsulation:a.ViewEncapsulation.None,changeDetection:a.ChangeDetectionStrategy.OnPush,providers:[{provide:s.NG_VALUE_ACCESSOR,useExisting:a.forwardRef(function(){return f}),multi:!0}],host:{"[class.ant-radio-wrapper-checked]":"checked","[class.ant-radio-wrapper-disabled]":"nzDisabled"}}]}],f.ctorParameters=function(){return[{type:a.ElementRef},{type:a.Renderer2},{type:a.ChangeDetectorRef},{type:t.FocusMonitor}]},f.propDecorators={inputElement:[{type:a.ViewChild,args:["inputElement"]}],nzValue:[{type:a.Input}],nzDisabled:[{type:a.Input}],nzAutoFocus:[{type:a.Input}],onClick:[{type:a.HostListener,args:["click",["$event"]]}]},u([o.InputBoolean(),p("design:type",Object)],f.prototype,"nzDisabled",void 0),u([o.InputBoolean(),p("design:type",Object)],f.prototype,"nzAutoFocus",void 0),f);function f(e,t,n,o){this.elementRef=e,this.renderer=t,this.cdr=n,this.focusMonitor=o,this.select$=new r.Subject,this.touched$=new r.Subject,this.checked=!1,this.isNgModel=!1,this.onChange=function(){return null},this.onTouched=function(){return null},this.nzDisabled=!1,this.nzAutoFocus=!1,this.renderer.addClass(e.nativeElement,"ant-radio-wrapper")}var y,g=(function k(e,t){function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(m,y=h),m.decorators=[{type:a.Component,args:[{selector:"[nz-radio-button]",exportAs:"nzRadioButton",providers:[{provide:s.NG_VALUE_ACCESSOR,useExisting:a.forwardRef(function(){return h}),multi:!0},{provide:h,useExisting:a.forwardRef(function(){return m})}],encapsulation:a.ViewEncapsulation.None,changeDetection:a.ChangeDetectionStrategy.OnPush,preserveWhitespaces:!1,template:'<span class="ant-radio-button" [class.ant-radio-button-checked]="checked" [class.ant-radio-button-disabled]="nzDisabled">\n <input type="radio" #inputElement class="ant-radio-button-input" [disabled]="nzDisabled" [checked]="checked" [attr.name]="name">\n <span class="ant-radio-button-inner"></span>\n</span>\n<span><ng-content></ng-content></span>',host:{"[class.ant-radio-button-wrapper-checked]":"checked","[class.ant-radio-button-wrapper-disabled]":"nzDisabled"}}]}],m.ctorParameters=function(){return[{type:a.ElementRef},{type:a.Renderer2},{type:a.ChangeDetectorRef},{type:t.FocusMonitor}]},m);function m(e,t,n,o){var r=y.call(this,e,t,n,o)||this;return t.removeClass(e.nativeElement,"ant-radio-wrapper"),t.addClass(e.nativeElement,"ant-radio-button-wrapper"),r}var b=(z.prototype.updateChildrenStatus=function(){var t=this;this.radios&&Promise.resolve().then(function(){t.radios.forEach(function(e){e.checked=e.nzValue===t.value,o.isNotNil(t.nzDisabled)&&(e.nzDisabled=t.nzDisabled),t.nzName&&(e.name=t.nzName),e.markForCheck()})})},z.prototype.ngAfterContentInit=function(){var t=this;this.radios.changes.pipe(n.startWith(null),n.takeUntil(this.destroy$)).subscribe(function(){t.updateChildrenStatus(),t.selectSubscription&&t.selectSubscription.unsubscribe(),t.selectSubscription=r.merge.apply(void 0,l(t.radios.map(function(e){return e.select$}))).pipe(n.takeUntil(t.destroy$)).subscribe(function(e){t.value!==e.nzValue&&(t.value=e.nzValue,t.updateChildrenStatus(),t.onChange(t.value))}),t.touchedSubscription&&t.touchedSubscription.unsubscribe(),t.touchedSubscription=r.merge.apply(void 0,l(t.radios.map(function(e){return e.touched$}))).pipe(n.takeUntil(t.destroy$)).subscribe(function(){Promise.resolve().then(function(){return t.onTouched()})})})},z.prototype.ngOnChanges=function(e){(e.nzDisabled||e.nzName)&&this.updateChildrenStatus()},z.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},z.prototype.writeValue=function(e){this.value=e,this.updateChildrenStatus(),this.cdr.markForCheck()},z.prototype.registerOnChange=function(e){this.onChange=e},z.prototype.registerOnTouched=function(e){this.onTouched=e},z.prototype.setDisabledState=function(e){this.nzDisabled=e,this.cdr.markForCheck()},z.decorators=[{type:a.Component,args:[{selector:"nz-radio-group",exportAs:"nzRadioGroup",preserveWhitespaces:!1,template:"<ng-content></ng-content>",encapsulation:a.ViewEncapsulation.None,changeDetection:a.ChangeDetectionStrategy.OnPush,providers:[{provide:s.NG_VALUE_ACCESSOR,useExisting:a.forwardRef(function(){return z}),multi:!0}],host:{"[class.ant-radio-group-large]":"nzSize === 'large'","[class.ant-radio-group-small]":"nzSize === 'small'","[class.ant-radio-group-solid]":"nzButtonStyle === 'solid'"}}]}],z.ctorParameters=function(){return[{type:a.ChangeDetectorRef},{type:a.Renderer2},{type:a.ElementRef}]},z.propDecorators={radios:[{type:a.ContentChildren,args:[a.forwardRef(function(){return h}),{descendants:!0}]}],nzDisabled:[{type:a.Input}],nzButtonStyle:[{type:a.Input}],nzSize:[{type:a.Input}],nzName:[{type:a.Input}]},u([o.InputBoolean(),p("design:type",Boolean)],z.prototype,"nzDisabled",void 0),z);function z(e,t,n){this.cdr=e,this.destroy$=new r.Subject,this.onChange=function(){return null},this.onTouched=function(){return null},this.nzButtonStyle="outline",this.nzSize="default",t.addClass(n.nativeElement,"ant-radio-group")}var v=(C.decorators=[{type:a.NgModule,args:[{imports:[i.CommonModule,s.FormsModule],exports:[h,g,b],declarations:[h,g,b]}]}],C);function C(){}e.NzRadioButtonComponent=g,e.NzRadioGroupComponent=b,e.NzRadioComponent=h,e.NzRadioModule=v,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-radio.umd.min.js.map