UNPKG

5.39 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define("primeng/checkbox",["exports","@angular/core","@angular/common","@angular/forms"],t):t(((e=e||self).primeng=e.primeng||{},e.primeng.checkbox={}),e.ng.core,e.ng.common,e.ng.forms)}(this,(function(e,t,o,n){"use strict";var i=this&&this.__decorate||function(e,t,o,n){var i,r=arguments.length,c=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,o,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(c=(r<3?i(c):r>3?i(t,o,c):i(t,o))||c);return r>3&&c&&Object.defineProperty(t,o,c),c},r=this&&this.__read||function(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var n,i,r=o.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=r.next()).done;)c.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(i)throw i.error}}return c},c=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e},l={provide:n.NG_VALUE_ACCESSOR,useExisting:t.forwardRef((function(){return a})),multi:!0},a=function(){function e(e){this.cd=e,this.checkboxIcon="pi pi-check",this.onChange=new t.EventEmitter,this.onModelChange=function(){},this.onModelTouched=function(){},this.focused=!1,this.checked=!1}return e.prototype.onClick=function(e,t,o){e.preventDefault(),this.disabled||this.readonly||(this.checked=!this.checked,this.updateModel(e),o&&t.focus())},e.prototype.updateModel=function(e){this.binary?this.onModelChange(this.checked):(this.checked?this.addValue():this.removeValue(),this.onModelChange(this.model),this.formControl&&this.formControl.setValue(this.model)),this.onChange.emit({checked:this.checked,originalEvent:e})},e.prototype.handleChange=function(e){this.readonly||(this.checked=e.target.checked,this.updateModel(e))},e.prototype.isChecked=function(){return this.binary?this.model:this.model&&this.model.indexOf(this.value)>-1},e.prototype.removeValue=function(){var e=this;this.model=this.model.filter((function(t){return t!==e.value}))},e.prototype.addValue=function(){this.model?this.model=c(this.model,[this.value]):this.model=[this.value]},e.prototype.onFocus=function(){this.focused=!0},e.prototype.onBlur=function(){this.focused=!1,this.onModelTouched()},e.prototype.focus=function(){this.inputViewChild.nativeElement.focus()},e.prototype.writeValue=function(e){this.model=e,this.checked=this.isChecked(),this.cd.markForCheck()},e.prototype.registerOnChange=function(e){this.onModelChange=e},e.prototype.registerOnTouched=function(e){this.onModelTouched=e},e.prototype.setDisabledState=function(e){this.disabled=e},e.ctorParameters=function(){return[{type:t.ChangeDetectorRef}]},i([t.Input()],e.prototype,"value",void 0),i([t.Input()],e.prototype,"name",void 0),i([t.Input()],e.prototype,"disabled",void 0),i([t.Input()],e.prototype,"binary",void 0),i([t.Input()],e.prototype,"label",void 0),i([t.Input()],e.prototype,"ariaLabelledBy",void 0),i([t.Input()],e.prototype,"tabindex",void 0),i([t.Input()],e.prototype,"inputId",void 0),i([t.Input()],e.prototype,"style",void 0),i([t.Input()],e.prototype,"styleClass",void 0),i([t.Input()],e.prototype,"labelStyleClass",void 0),i([t.Input()],e.prototype,"formControl",void 0),i([t.Input()],e.prototype,"checkboxIcon",void 0),i([t.Input()],e.prototype,"readonly",void 0),i([t.Input()],e.prototype,"required",void 0),i([t.ViewChild("cb")],e.prototype,"inputViewChild",void 0),i([t.Output()],e.prototype,"onChange",void 0),e=i([t.Component({selector:"p-checkbox",template:'\n <div [ngStyle]="style" [ngClass]="{\'ui-chkbox ui-widget\': true,\'ui-chkbox-readonly\': readonly}" [class]="styleClass">\n <div class="ui-helper-hidden-accessible">\n <input #cb type="checkbox" [attr.id]="inputId" [attr.name]="name" [readonly]="readonly" [value]="value" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()"\n [ngClass]="{\'ui-state-focus\':focused}" (change)="handleChange($event)" [disabled]="disabled" [attr.tabindex]="tabindex" [attr.aria-labelledby]="ariaLabelledBy" [attr.required]="required">\n </div>\n <div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default" (click)="onClick($event,cb,true)"\n [ngClass]="{\'ui-state-active\':checked,\'ui-state-disabled\':disabled,\'ui-state-focus\':focused}" role="checkbox" [attr.aria-checked]="checked">\n <span class="ui-chkbox-icon ui-clickable" [ngClass]="checked ? checkboxIcon : null"></span>\n </div>\n </div>\n <label (click)="onClick($event,cb,true)" [class]="labelStyleClass"\n [ngClass]="{\'ui-chkbox-label\': true, \'ui-label-active\':checked, \'ui-label-disabled\':disabled, \'ui-label-focus\':focused}"\n *ngIf="label" [attr.for]="inputId">{{label}}</label>\n ',providers:[l],changeDetection:t.ChangeDetectionStrategy.Default})],e)}(),d=function(){function e(){}return e=i([t.NgModule({imports:[o.CommonModule],exports:[a],declarations:[a]})],e)}();e.CHECKBOX_VALUE_ACCESSOR=l,e.Checkbox=a,e.CheckboxModule=d,Object.defineProperty(e,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-checkbox.umd.min.js.map
\No newline at end of file