ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 8.08 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/a11y"),require("@angular/core"),require("@angular/forms"),require("ng-zorro-antd/core"),require("@angular/cdk/observers"),require("@angular/common")):"function"==typeof define&&define.amd?define("ng-zorro-antd/checkbox",["exports","@angular/cdk/a11y","@angular/core","@angular/forms","ng-zorro-antd/core","@angular/cdk/observers","@angular/common"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].checkbox={}),e.ng.cdk.a11y,e.ng.core,e.ng.forms,e["ng-zorro-antd"].core,e.ng.cdk.observers,e.ng.common)}(this,function(e,t,n,o,r,i,c){"use strict";function s(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);return i>3&&c&&Object.defineProperty(t,n,c),c}function a(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var p=function(){function e(e,t){this.nzOnChange=new n.EventEmitter,this.checkboxList=[],e.addClass(t.nativeElement,"ant-checkbox-group")}return e.prototype.addCheckbox=function(e){this.checkboxList.push(e)},e.prototype.removeCheckbox=function(e){this.checkboxList.splice(this.checkboxList.indexOf(e),1)},e.prototype.outputValue=function(){return this.checkboxList.filter(function(e){return e.nzChecked}).map(function(e){return e.nzValue})},e.prototype.onChange=function(){this.nzOnChange.emit(this.outputValue())},e.decorators=[{type:n.Component,args:[{selector:"nz-checkbox-wrapper",exportAs:"nzCheckboxWrapper",preserveWhitespaces:!1,changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None,template:"<ng-content></ng-content>"}]}],e.ctorParameters=function(){return[{type:n.Renderer2},{type:n.ElementRef}]},e.propDecorators={nzOnChange:[{type:n.Output}]},e}();var u=function(){function e(e,t,o,r,i){this.elementRef=e,this.renderer=t,this.nzCheckboxWrapperComponent=o,this.cdr=r,this.focusMonitor=i,this.onChange=function(){return null},this.onTouched=function(){return null},this.nzCheckedChange=new n.EventEmitter,this.nzAutoFocus=!1,this.nzDisabled=!1,this.nzIndeterminate=!1,this.nzChecked=!1,t.addClass(e.nativeElement,"ant-checkbox-wrapper")}return e.prototype.hostClick=function(e){e.preventDefault(),this.focus(),this.innerCheckedChange(!this.nzChecked)},e.prototype.innerCheckedChange=function(e){this.nzDisabled||(this.nzChecked=e,this.onChange(this.nzChecked),this.nzCheckedChange.emit(this.nzChecked),this.nzCheckboxWrapperComponent&&this.nzCheckboxWrapperComponent.onChange())},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.writeValue=function(e){this.nzChecked=e,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.prototype.focus=function(){this.focusMonitor.focusVia(this.inputElement,"keyboard")},e.prototype.blur=function(){this.inputElement.nativeElement.blur()},e.prototype.checkContent=function(){r.isEmpty(this.contentElement.nativeElement)?this.renderer.setStyle(this.contentElement.nativeElement,"display","none"):this.renderer.removeStyle(this.contentElement.nativeElement,"display")},e.prototype.ngOnInit=function(){var e=this;this.focusMonitor.monitor(this.elementRef,!0).subscribe(function(t){t||Promise.resolve().then(function(){return e.onTouched()})}),this.nzCheckboxWrapperComponent&&this.nzCheckboxWrapperComponent.addCheckbox(this)},e.prototype.ngOnChanges=function(e){e.nzAutoFocus&&this.updateAutoFocus()},e.prototype.ngAfterViewInit=function(){this.updateAutoFocus(),this.checkContent()},e.prototype.ngOnDestroy=function(){this.focusMonitor.stopMonitoring(this.elementRef),this.nzCheckboxWrapperComponent&&this.nzCheckboxWrapperComponent.removeCheckbox(this)},e.decorators=[{type:n.Component,args:[{selector:"[nz-checkbox]",exportAs:"nzCheckbox",preserveWhitespaces:!1,changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None,template:'<span class="ant-checkbox"\n [class.ant-checkbox-checked]="nzChecked && !nzIndeterminate"\n [class.ant-checkbox-disabled]="nzDisabled"\n [class.ant-checkbox-indeterminate]="nzIndeterminate">\n <input #inputElement [checked]="nzChecked" [ngModel]="nzChecked" [disabled]="nzDisabled" (ngModelChange)="innerCheckedChange($event)" (click)="$event.stopPropagation();" type="checkbox" class="ant-checkbox-input">\n <span class="ant-checkbox-inner"></span>\n</span>\n<span #contentElement (cdkObserveContent)="checkContent()"><ng-content></ng-content></span>',providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:n.forwardRef(function(){return e}),multi:!0}],host:{"(click)":"hostClick($event)"}}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:n.Renderer2},{type:p,decorators:[{type:n.Optional}]},{type:n.ChangeDetectorRef},{type:t.FocusMonitor}]},e.propDecorators={inputElement:[{type:n.ViewChild,args:["inputElement",{static:!0}]}],contentElement:[{type:n.ViewChild,args:["contentElement",{static:!1}]}],nzCheckedChange:[{type:n.Output}],nzValue:[{type:n.Input}],nzAutoFocus:[{type:n.Input}],nzDisabled:[{type:n.Input}],nzIndeterminate:[{type:n.Input}],nzChecked:[{type:n.Input}]},s([r.InputBoolean(),a("design:type",Object)],e.prototype,"nzAutoFocus",void 0),s([r.InputBoolean(),a("design:type",Object)],e.prototype,"nzDisabled",void 0),s([r.InputBoolean(),a("design:type",Object)],e.prototype,"nzIndeterminate",void 0),s([r.InputBoolean(),a("design:type",Object)],e.prototype,"nzChecked",void 0),e}();var h=function(){function e(e,t,n,o){this.elementRef=e,this.focusMonitor=t,this.cdr=n,this.onChange=function(){return null},this.onTouched=function(){return null},this.options=[],this.nzDisabled=!1,o.addClass(e.nativeElement,"ant-checkbox-group")}return e.prototype.onOptionChange=function(){this.onChange(this.options)},e.prototype.trackByOption=function(e,t){return t.value},e.prototype.ngOnInit=function(){var e=this;this.focusMonitor.monitor(this.elementRef,!0).subscribe(function(t){t||Promise.resolve().then(function(){return e.onTouched()})})},e.prototype.ngOnDestroy=function(){this.focusMonitor.stopMonitoring(this.elementRef)},e.prototype.writeValue=function(e){this.options=e,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:n.Component,args:[{selector:"nz-checkbox-group",exportAs:"nzCheckboxGroup",preserveWhitespaces:!1,encapsulation:n.ViewEncapsulation.None,template:'<label nz-checkbox\n class="ant-checkbox-group-item"\n *ngFor="let option of options; trackBy:trackByOption"\n [nzDisabled]="option.disabled || nzDisabled"\n [(nzChecked)]="option.checked"\n (nzCheckedChange)="onOptionChange()">\n <span>{{ option.label }}</span>\n</label>',providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:n.forwardRef(function(){return e}),multi:!0}]}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:t.FocusMonitor},{type:n.ChangeDetectorRef},{type:n.Renderer2}]},e.propDecorators={nzDisabled:[{type:n.Input}]},s([r.InputBoolean(),a("design:type",Object)],e.prototype,"nzDisabled",void 0),e}();var l=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{imports:[c.CommonModule,o.FormsModule,i.ObserversModule],declarations:[u,h,p],exports:[u,h,p]}]}],e}();e.NzCheckboxComponent=u,e.NzCheckboxGroupComponent=h,e.NzCheckboxModule=l,e.NzCheckboxWrapperComponent=p,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-checkbox.umd.min.js.map