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) [![npm downloads](https://img.shields.io/npm/dm/primeng.sv

2 lines 4.27 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("primeng/ripple"),require("@angular/forms")):"function"==typeof define&&define.amd?define("primeng/togglebutton",["exports","@angular/core","@angular/common","primeng/ripple","@angular/forms"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).primeng=t.primeng||{},t.primeng.togglebutton={}),t.ng.core,t.ng.common,t.primeng.ripple,t.ng.forms)}(this,(function(t,e,o,n,i){"use strict";var r={provide:i.NG_VALUE_ACCESSOR,useExisting:e.forwardRef((function(){return l})),multi:!0},l=function(){function t(t){this.cd=t,this.iconPos="left",this.onChange=new e.EventEmitter,this.checked=!1,this.onModelChange=function(){},this.onModelTouched=function(){}}return t.prototype.toggle=function(t){this.disabled||(this.checked=!this.checked,this.onModelChange(this.checked),this.onModelTouched(),this.onChange.emit({originalEvent:t,checked:this.checked}),this.cd.markForCheck())},t.prototype.onBlur=function(){this.onModelTouched()},t.prototype.writeValue=function(t){this.checked=t,this.cd.markForCheck()},t.prototype.registerOnChange=function(t){this.onModelChange=t},t.prototype.registerOnTouched=function(t){this.onModelTouched=t},t.prototype.setDisabledState=function(t){this.disabled=t,this.cd.markForCheck()},Object.defineProperty(t.prototype,"hasOnLabel",{get:function(){return this.onLabel&&this.onLabel.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasOffLabel",{get:function(){return this.onLabel&&this.onLabel.length>0},enumerable:!1,configurable:!0}),t}();l.decorators=[{type:e.Component,args:[{selector:"p-toggleButton",template:"\n <div [ngClass]=\"{'p-button p-togglebutton p-component': true, 'p-button-icon-only': (onIcon && offIcon && !hasOnLabel && !hasOffLabel),'p-highlight': checked,'p-disabled':disabled}\" \n [ngStyle]=\"style\" [class]=\"styleClass\" (click)=\"toggle($event)\" (keydown.enter)=\"toggle($event)\"\n [attr.tabindex]=\"disabled ? null : '0'\" role=\"checkbox\" [attr.aria-checked]=\"checked\" pRipple>\n <span *ngIf=\"onIcon||offIcon\" [class]=\"checked ? this.onIcon : this.offIcon\" \n [ngClass]=\"{'p-button-icon': true, 'p-button-icon-left': (iconPos === 'left'), 'p-button-icon-right': (iconPos === 'right')}\"></span>\n <span class=\"p-button-label\">{{checked ? hasOnLabel ? onLabel : '' : hasOffLabel ? offLabel : ''}}</span>\n </div>\n ",providers:[r],changeDetection:e.ChangeDetectionStrategy.OnPush,styles:[".p-button{-ms-user-select:none;-webkit-user-select:none;align-items:center;cursor:pointer;display:inline-flex;margin:0;overflow:hidden;position:relative;text-align:center;user-select:none;vertical-align:bottom}.p-button-label{flex:1 1 auto}.p-button-icon-right{order:1}.p-button:disabled{cursor:default}.p-button-icon-only{justify-content:center}.p-button-icon-only .p-button-label{flex:0 0 auto;visibility:hidden;width:0}.p-button-vertical{flex-direction:column}.p-button-icon-bottom{order:2}.p-buttonset .p-button{margin:0}.p-buttonset .p-button:not(:last-child){border-right:0}.p-buttonset .p-button:not(:first-of-type):not(:last-of-type){border-radius:0}.p-buttonset .p-button:first-of-type{border-bottom-right-radius:0;border-top-right-radius:0}.p-buttonset .p-button:last-of-type{border-bottom-left-radius:0;border-top-left-radius:0}.p-buttonset .p-button:focus{position:relative;z-index:1}.p-button-label{transition:all .2s}"]}]}],l.ctorParameters=function(){return[{type:e.ChangeDetectorRef}]},l.propDecorators={onLabel:[{type:e.Input}],offLabel:[{type:e.Input}],onIcon:[{type:e.Input}],offIcon:[{type:e.Input}],ariaLabelledBy:[{type:e.Input}],disabled:[{type:e.Input}],style:[{type:e.Input}],styleClass:[{type:e.Input}],inputId:[{type:e.Input}],tabindex:[{type:e.Input}],iconPos:[{type:e.Input}],onChange:[{type:e.Output}]};var s=function(){};s.decorators=[{type:e.NgModule,args:[{imports:[o.CommonModule,n.RippleModule],exports:[l],declarations:[l]}]}],t.TOGGLEBUTTON_VALUE_ACCESSOR=r,t.ToggleButton=l,t.ToggleButtonModule=s,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=primeng-togglebutton.umd.min.js.map