UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primeng.svg)](https://badge.fury.io/js/primeng) [![Discord](https://img.shields.io/discord/557940238991753

2 lines 3.36 kB
!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/inputswitch",["exports","@angular/core","@angular/common","@angular/forms"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).primeng=e.primeng||{},e.primeng.inputswitch={}),e.ng.core,e.ng.common,e.ng.forms)}(this,(function(e,t,n,o){"use strict";var i={provide:o.NG_VALUE_ACCESSOR,useExisting:t.forwardRef((function(){return s})),multi:!0},s=function(){function e(e){this.cd=e,this.onChange=new t.EventEmitter,this.checked=!1,this.focused=!1,this.onModelChange=function(){},this.onModelTouched=function(){}}return e.prototype.onClick=function(e,t){this.disabled||this.readonly||(e.preventDefault(),this.toggle(e),t.focus())},e.prototype.onInputChange=function(e){if(!this.readonly){var t=e.target.checked;this.updateModel(e,t)}},e.prototype.toggle=function(e){this.updateModel(e,!this.checked)},e.prototype.updateModel=function(e,t){this.checked=t,this.onModelChange(this.checked),this.onChange.emit({originalEvent:e,checked:this.checked})},e.prototype.onFocus=function(e){this.focused=!0},e.prototype.onBlur=function(e){this.focused=!1,this.onModelTouched()},e.prototype.writeValue=function(e){this.checked=e,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,this.cd.markForCheck()},e}();s.decorators=[{type:t.Component,args:[{selector:"p-inputSwitch",template:'\n <div [ngClass]="{\'p-inputswitch p-component\': true, \'p-inputswitch-checked\': checked, \'p-disabled\': disabled, \'p-focus\': focused}" \n [ngStyle]="style" [class]="styleClass" (click)="onClick($event, cb)">\n <div class="p-hidden-accessible">\n <input #cb type="checkbox" [attr.id]="inputId" [attr.name]="name" [attr.tabindex]="tabindex" [checked]="checked" (change)="onInputChange($event)"\n (focus)="onFocus($event)" (blur)="onBlur($event)" [disabled]="disabled" role="switch" [attr.aria-checked]="checked" [attr.aria-labelledby]="ariaLabelledBy"/>\n </div>\n <span class="p-inputswitch-slider"></span>\n </div>\n ',providers:[i],changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None,styles:['.p-inputswitch{-ms-user-select:none;-webkit-user-select:none;display:inline-block;position:relative;user-select:none}.p-inputswitch-slider{bottom:0;cursor:pointer;left:0;position:absolute;right:0;top:0}.p-inputswitch-slider:before{content:"";position:absolute;top:50%}']}]}],s.ctorParameters=function(){return[{type:t.ChangeDetectorRef}]},s.propDecorators={style:[{type:t.Input}],styleClass:[{type:t.Input}],tabindex:[{type:t.Input}],inputId:[{type:t.Input}],name:[{type:t.Input}],disabled:[{type:t.Input}],readonly:[{type:t.Input}],ariaLabelledBy:[{type:t.Input}],onChange:[{type:t.Output}]};var c=function(){};c.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule],exports:[s],declarations:[s]}]}],e.INPUTSWITCH_VALUE_ACCESSOR=i,e.InputSwitch=s,e.InputSwitchModule=c,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=primeng-inputswitch.umd.min.js.map