UNPKG

ng-zorro-antd

Version:

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

16 lines (14 loc) 8.88 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/forms"),require("ng-zorro-antd/core/util"),require("rxjs"),require("@angular/cdk/a11y"),require("rxjs/operators"),require("@angular/common")):"function"==typeof define&&define.amd?define("ng-zorro-antd/radio",["exports","@angular/core","@angular/forms","ng-zorro-antd/core/util","rxjs","@angular/cdk/a11y","rxjs/operators","@angular/common"],e):e(((t=t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].radio={}),t.ng.core,t.ng.forms,t["ng-zorro-antd"].core.util,t.rxjs,t.ng.cdk.a11y,t.rxjs.operators,t.ng.common)}(this,(function(t,e,n,o,i,s,r,a){"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 c(t,e,n,o){var i,s=arguments.length,r=s<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(s<3?i(r):s>3?i(e,n,r):i(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r}function u(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var d=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"[nz-radio-button]"}]}],t}(),p=function(){function t(){this.selected$=new i.ReplaySubject(1),this.touched$=new i.Subject,this.disabled$=new i.ReplaySubject(1),this.name$=new i.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.decorators=[{type:e.Injectable}],t}();var l=function(){function t(t,e){this.cdr=t,this.nzRadioService=e,this.value=null,this.destroy$=new i.Subject,this.onChange=function(){},this.onTouched=function(){},this.nzDisabled=!1,this.nzButtonStyle="outline",this.nzSize="default",this.nzName=null}return t.prototype.ngOnInit=function(){var t=this;this.nzRadioService.selected$.subscribe((function(e){t.value!==e&&(t.value=e,t.onChange(t.value))})),this.nzRadioService.touched$.subscribe((function(){Promise.resolve().then((function(){return t.onTouched()}))}))},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.decorators=[{type:e.Component,args:[{selector:"nz-radio-group",exportAs:"nzRadioGroup",preserveWhitespaces:!1,template:" <ng-content></ng-content> ",encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush,providers:[p,{provide:n.NG_VALUE_ACCESSOR,useExisting:e.forwardRef((function(){return t})),multi:!0}],host:{"[class.ant-radio-group]":"true","[class.ant-radio-group-large]":"nzSize === 'large'","[class.ant-radio-group-small]":"nzSize === 'small'","[class.ant-radio-group-solid]":"nzButtonStyle === 'solid'"}}]}],t.ctorParameters=function(){return[{type:e.ChangeDetectorRef},{type:p}]},t.propDecorators={nzDisabled:[{type:e.Input}],nzButtonStyle:[{type:e.Input}],nzSize:[{type:e.Input}],nzName:[{type:e.Input}]},c([o.InputBoolean(),u("design:type",Object)],t.prototype,"nzDisabled",void 0),t}();var h=function(){function t(t,e,n,o,s){this.elementRef=t,this.cdr=e,this.focusMonitor=n,this.nzRadioService=o,this.nzRadioButtonDirective=s,this.isNgModel=!1,this.destroy$=new i.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}return t.prototype.onHostClick=function(t){t.stopPropagation(),t.preventDefault(),this.focus(),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=this;this.nzRadioService&&(this.nzRadioService.name$.pipe(r.takeUntil(this.destroy$)).subscribe((function(e){t.name=e,t.cdr.markForCheck()})),this.nzRadioService.disabled$.pipe(r.takeUntil(this.destroy$)).subscribe((function(e){t.nzDisabled=e,t.cdr.markForCheck()})),this.nzRadioService.selected$.pipe(r.takeUntil(this.destroy$)).subscribe((function(e){t.isChecked=t.nzValue===e,t.cdr.markForCheck()}))),this.focusMonitor.monitor(this.elementRef,!0).subscribe((function(e){e||(Promise.resolve().then((function(){return t.onTouched()})),t.nzRadioService&&t.nzRadioService.touch())}))},t.prototype.ngAfterViewInit=function(){this.nzAutoFocus&&this.focus()},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete(),this.focusMonitor.stopMonitoring(this.elementRef)},t.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:n.NG_VALUE_ACCESSOR,useExisting:e.forwardRef((function(){return t})),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","(click)":"onHostClick($event)"}}]}],t.ctorParameters=function(){return[{type:e.ElementRef},{type:e.ChangeDetectorRef},{type:s.FocusMonitor},{type:p,decorators:[{type:e.Optional}]},{type:d,decorators:[{type:e.Optional}]}]},t.propDecorators={inputElement:[{type:e.ViewChild,args:["inputElement",{static:!1}]}],nzValue:[{type:e.Input}],nzDisabled:[{type:e.Input}],nzAutoFocus:[{type:e.Input}]},c([o.InputBoolean(),u("design:type",Object)],t.prototype,"nzDisabled",void 0),c([o.InputBoolean(),u("design:type",Object)],t.prototype,"nzAutoFocus",void 0),t}();var f=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[a.CommonModule,n.FormsModule],exports:[h,d,l],declarations:[h,d,l]}]}],t}();t.NzRadioButtonDirective=d,t.NzRadioComponent=h,t.NzRadioGroupComponent=l,t.NzRadioModule=f,t.NzRadioService=p,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-radio.umd.min.js.map