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