primeng
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primeng) [{"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define("primeng/togglebutton",["exports","@angular/core","@angular/common","@angular/forms"],t):t(((e=e||self).primeng=e.primeng||{},e.primeng.togglebutton={}),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,c=arguments.length,s=c<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,n);else for(var u=e.length-1;u>=0;u--)(i=e[u])&&(s=(c<3?i(s):c>3?i(t,o,s):i(t,o))||s);return c>3&&s&&Object.defineProperty(t,o,s),s},c={provide:n.NG_VALUE_ACCESSOR,useExisting:t.forwardRef((function(){return s})),multi:!0},s=function(){function e(){this.onLabel="Yes",this.offLabel="No",this.iconPos="left",this.onChange=new t.EventEmitter,this.checked=!1,this.focus=!1,this.onModelChange=function(){},this.onModelTouched=function(){}}return e.prototype.ngAfterViewInit=function(){this.checkboxViewChild&&(this.checkbox=this.checkboxViewChild.nativeElement)},e.prototype.toggle=function(e){this.disabled||(this.checked=!this.checked,this.onModelChange(this.checked),this.onModelTouched(),this.onChange.emit({originalEvent:e,checked:this.checked}),this.checkbox&&this.checkbox.focus())},e.prototype.onFocus=function(){this.focus=!0},e.prototype.onBlur=function(){this.focus=!1,this.onModelTouched()},e.prototype.writeValue=function(e){this.checked=e},e.prototype.registerOnChange=function(e){this.onModelChange=e},e.prototype.registerOnTouched=function(e){this.onModelTouched=e},e.prototype.setDisabledState=function(e){this.disabled=e},Object.defineProperty(e.prototype,"hasOnLabel",{get:function(){return this.onLabel&&this.onLabel.length>0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasOffLabel",{get:function(){return this.onLabel&&this.onLabel.length>0},enumerable:!0,configurable:!0}),i([t.Input()],e.prototype,"onLabel",void 0),i([t.Input()],e.prototype,"offLabel",void 0),i([t.Input()],e.prototype,"onIcon",void 0),i([t.Input()],e.prototype,"offIcon",void 0),i([t.Input()],e.prototype,"ariaLabelledBy",void 0),i([t.Input()],e.prototype,"disabled",void 0),i([t.Input()],e.prototype,"style",void 0),i([t.Input()],e.prototype,"styleClass",void 0),i([t.Input()],e.prototype,"inputId",void 0),i([t.Input()],e.prototype,"tabindex",void 0),i([t.Input()],e.prototype,"iconPos",void 0),i([t.Output()],e.prototype,"onChange",void 0),i([t.ViewChild("checkbox")],e.prototype,"checkboxViewChild",void 0),e=i([t.Component({selector:"p-toggleButton",template:'\n <div [ngClass]="{\'ui-button ui-togglebutton ui-widget ui-state-default ui-corner-all\': true, \'ui-button-text-only\': (!onIcon && !offIcon), \n \'ui-button-text-icon-left\': (onIcon && offIcon && hasOnLabel && hasOffLabel && iconPos === \'left\'), \n \'ui-button-text-icon-right\': (onIcon && offIcon && hasOnLabel && hasOffLabel && iconPos === \'right\'),\'ui-button-icon-only\': (onIcon && offIcon && !hasOnLabel && !hasOffLabel),\n \'ui-state-active\': checked,\'ui-state-focus\':focus,\'ui-state-disabled\':disabled}" [ngStyle]="style" [class]="styleClass" \n (click)="toggle($event)" (keydown.enter)="toggle($event)">\n <div class="ui-helper-hidden-accessible">\n <input #checkbox type="checkbox" [attr.id]="inputId" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [attr.tabindex]="tabindex"\n role="button" [attr.aria-pressed]="checked" [attr.aria-labelledby]="ariaLabelledBy">\n </div>\n <span *ngIf="onIcon||offIcon" class="ui-button-icon-left" [class]="checked ? this.onIcon : this.offIcon" [ngClass]="{\'ui-button-icon-left\': (iconPos === \'left\'), \n \'ui-button-icon-right\': (iconPos === \'right\')}"></span>\n <span class="ui-button-text ui-unselectable-text">{{checked ? hasOnLabel ? onLabel : \'ui-btn\' : hasOffLabel ? offLabel : \'ui-btn\'}}</span>\n </div>\n ',providers:[c],changeDetection:t.ChangeDetectionStrategy.Default})],e)}(),u=function(){function e(){}return e=i([t.NgModule({imports:[o.CommonModule],exports:[s],declarations:[s]})],e)}();e.TOGGLEBUTTON_VALUE_ACCESSOR=c,e.ToggleButton=s,e.ToggleButtonModule=u,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=primeng-togglebutton.umd.min.js.map