UNPKG

ng-zorro-antd

Version:

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

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