UNPKG

ng-zorro-antd

Version:

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

2 lines 8.99 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/cdk/bidi"),require("@angular/forms"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/a11y"),require("@angular/common")):"function"==typeof define&&define.amd?define("ng-zorro-antd/radio",["exports","@angular/core","@angular/cdk/bidi","@angular/forms","ng-zorro-antd/core/util","rxjs","rxjs/operators","@angular/cdk/a11y","@angular/common"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].radio={}),t.ng.core,t.ng.cdk.bidi,t.ng.forms,t["ng-zorro-antd"].core.util,t.rxjs,t.rxjs.operators,t.ng.cdk.a11y,t.ng.common)}(this,(function(t,e,n,i,o,r,s,a,c){"use strict";var d=function(){};d.decorators=[{type:e.Directive,args:[{selector:"[nz-radio-button]"}]}];function u(t,e,n,i){var o,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}function l(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}Object.create;Object.create;var p=function(){function t(){this.selected$=new r.ReplaySubject(1),this.touched$=new r.Subject,this.disabled$=new r.ReplaySubject(1),this.name$=new r.ReplaySubject(1)}return t.prototype.touch=function(){this.touched$.next()},t.prototype.select=function(t){this.selected$.next(t)},t.prototype.setDisabled=function(t){this.disabled$.next(t)},t.prototype.setName=function(t){this.name$.next(t)},t}();p.decorators=[{type:e.Injectable}];var h=function(){function t(t,e,n,i){this.cdr=t,this.nzRadioService=e,this.elementRef=n,this.directionality=i,this.value=null,this.destroy$=new r.Subject,this.onChange=function(){},this.onTouched=function(){},this.nzDisabled=!1,this.nzButtonStyle="outline",this.nzSize="default",this.nzName=null,this.dir="ltr",this.elementRef.nativeElement.classList.add("ant-radio-group")}return t.prototype.ngOnInit=function(){var t,e=this;this.nzRadioService.selected$.pipe(s.takeUntil(this.destroy$)).subscribe((function(t){e.value!==t&&(e.value=t,e.onChange(e.value))})),this.nzRadioService.touched$.pipe(s.takeUntil(this.destroy$)).subscribe((function(){Promise.resolve().then((function(){return e.onTouched()}))})),null===(t=this.directionality.change)||void 0===t||t.pipe(s.takeUntil(this.destroy$)).subscribe((function(t){e.dir=t,e.cdr.detectChanges()})),this.dir=this.directionality.value},t.prototype.ngOnChanges=function(t){var e=t.nzDisabled,n=t.nzName;e&&this.nzRadioService.setDisabled(this.nzDisabled),n&&this.nzRadioService.setName(this.nzName)},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.prototype.writeValue=function(t){this.value=t,this.nzRadioService.select(t),this.cdr.markForCheck()},t.prototype.registerOnChange=function(t){this.onChange=t},t.prototype.registerOnTouched=function(t){this.onTouched=t},t.prototype.setDisabledState=function(t){this.nzDisabled=t,this.nzRadioService.setDisabled(t),this.cdr.markForCheck()},t}();h.decorators=[{type:e.Component,args:[{selector:"nz-radio-group",exportAs:"nzRadioGroup",preserveWhitespaces:!1,template:"\n <ng-content></ng-content>\n ",encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush,providers:[p,{provide:i.NG_VALUE_ACCESSOR,useExisting:e.forwardRef((function(){return h})),multi:!0}],host:{"[class.ant-radio-group-large]":"nzSize === 'large'","[class.ant-radio-group-small]":"nzSize === 'small'","[class.ant-radio-group-solid]":"nzButtonStyle === 'solid'","[class.ant-radio-group-rtl]":"dir === 'rtl'"}}]}],h.ctorParameters=function(){return[{type:e.ChangeDetectorRef},{type:p},{type:e.ElementRef},{type:n.Directionality,decorators:[{type:e.Optional}]}]},h.propDecorators={nzDisabled:[{type:e.Input}],nzButtonStyle:[{type:e.Input}],nzSize:[{type:e.Input}],nzName:[{type:e.Input}]},u([o.InputBoolean(),l("design:type",Object)],h.prototype,"nzDisabled",void 0);var f=function(){function t(t,e,n,i,o,s){this.elementRef=t,this.cdr=e,this.focusMonitor=n,this.directionality=i,this.nzRadioService=o,this.nzRadioButtonDirective=s,this.isNgModel=!1,this.destroy$=new r.Subject,this.isChecked=!1,this.name=null,this.isRadioButton=!!this.nzRadioButtonDirective,this.onChange=function(){},this.onTouched=function(){},this.nzValue=null,this.nzDisabled=!1,this.nzAutoFocus=!1,this.dir="ltr"}return t.prototype.onHostClick=function(t){t.stopPropagation(),t.preventDefault(),this.nzDisabled||this.isChecked||(this.nzRadioService&&this.nzRadioService.select(this.nzValue),this.isNgModel&&(this.isChecked=!0,this.onChange(!0)))},t.prototype.focus=function(){this.focusMonitor.focusVia(this.inputElement,"keyboard")},t.prototype.blur=function(){this.inputElement.nativeElement.blur()},t.prototype.setDisabledState=function(t){this.nzDisabled=t,this.cdr.markForCheck()},t.prototype.writeValue=function(t){this.isChecked=t,this.cdr.markForCheck()},t.prototype.registerOnChange=function(t){this.isNgModel=!0,this.onChange=t},t.prototype.registerOnTouched=function(t){this.onTouched=t},t.prototype.ngOnInit=function(){var t,e=this;this.nzRadioService&&(this.nzRadioService.name$.pipe(s.takeUntil(this.destroy$)).subscribe((function(t){e.name=t,e.cdr.markForCheck()})),this.nzRadioService.disabled$.pipe(s.takeUntil(this.destroy$)).subscribe((function(t){e.nzDisabled=t,e.cdr.markForCheck()})),this.nzRadioService.selected$.pipe(s.takeUntil(this.destroy$)).subscribe((function(t){e.isChecked=e.nzValue===t,e.cdr.markForCheck()}))),this.focusMonitor.monitor(this.elementRef,!0).subscribe((function(t){t||(Promise.resolve().then((function(){return e.onTouched()})),e.nzRadioService&&e.nzRadioService.touch())})),null===(t=this.directionality.change)||void 0===t||t.pipe(s.takeUntil(this.destroy$)).subscribe((function(t){e.dir=t,e.cdr.detectChanges()})),this.dir=this.directionality.value},t.prototype.ngAfterViewInit=function(){this.nzAutoFocus&&this.focus()},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete(),this.focusMonitor.stopMonitoring(this.elementRef)},t}();f.decorators=[{type:e.Component,args:[{selector:"[nz-radio],[nz-radio-button]",exportAs:"nzRadio",preserveWhitespaces:!1,template:'\n <span\n [class.ant-radio]="!isRadioButton"\n [class.ant-radio-checked]="isChecked && !isRadioButton"\n [class.ant-radio-disabled]="nzDisabled && !isRadioButton"\n [class.ant-radio-button]="isRadioButton"\n [class.ant-radio-button-checked]="isChecked && isRadioButton"\n [class.ant-radio-button-disabled]="nzDisabled && isRadioButton"\n >\n <input\n #inputElement\n type="radio"\n [attr.autofocus]="nzAutoFocus ? \'autofocus\' : null"\n [class.ant-radio-input]="!isRadioButton"\n [class.ant-radio-button-input]="isRadioButton"\n [disabled]="nzDisabled"\n [checked]="isChecked"\n [attr.name]="name"\n />\n <span [class.ant-radio-inner]="!isRadioButton" [class.ant-radio-button-inner]="isRadioButton"></span>\n </span>\n <span><ng-content></ng-content></span>\n ',encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush,providers:[{provide:i.NG_VALUE_ACCESSOR,useExisting:e.forwardRef((function(){return f})),multi:!0}],host:{"[class.ant-radio-wrapper]":"!isRadioButton","[class.ant-radio-button-wrapper]":"isRadioButton","[class.ant-radio-wrapper-checked]":"isChecked && !isRadioButton","[class.ant-radio-button-wrapper-checked]":"isChecked && isRadioButton","[class.ant-radio-wrapper-disabled]":"nzDisabled && !isRadioButton","[class.ant-radio-button-wrapper-disabled]":"nzDisabled && isRadioButton","[class.ant-radio-wrapper-rtl]":"!isRadioButton && dir === 'rtl'","[class.ant-radio-button-wrapper-rtl]":"isRadioButton && dir === 'rtl'","(click)":"onHostClick($event)"}}]}],f.ctorParameters=function(){return[{type:e.ElementRef},{type:e.ChangeDetectorRef},{type:a.FocusMonitor},{type:n.Directionality,decorators:[{type:e.Optional}]},{type:p,decorators:[{type:e.Optional}]},{type:d,decorators:[{type:e.Optional}]}]},f.propDecorators={inputElement:[{type:e.ViewChild,args:["inputElement",{static:!1}]}],nzValue:[{type:e.Input}],nzDisabled:[{type:e.Input}],nzAutoFocus:[{type:e.Input}]},u([o.InputBoolean(),l("design:type",Object)],f.prototype,"nzDisabled",void 0),u([o.InputBoolean(),l("design:type",Object)],f.prototype,"nzAutoFocus",void 0);var y=function(){};y.decorators=[{type:e.NgModule,args:[{imports:[n.BidiModule,c.CommonModule,i.FormsModule],exports:[f,d,h],declarations:[f,d,h]}]}],t.NzRadioButtonDirective=d,t.NzRadioComponent=f,t.NzRadioGroupComponent=h,t.NzRadioModule=y,t.NzRadioService=p,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-radio.umd.min.js.map