UNPKG

primevue

Version:

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

2 lines (1 loc) 1.62 kB
var togglebutton=function(t,e){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n={emits:["update:modelValue","change"],props:{modelValue:Boolean,onIcon:String,offIcon:String,onLabel:String,offLabel:String,iconPos:{type:String,default:"left"}},methods:{onClick(t){this.$attrs.disabled||(this.$emit("update:modelValue",!this.modelValue),this.$emit("change",t))}},computed:{buttonClass(){return{"p-button p-togglebutton p-component":!0,"p-button-icon-only":this.hasIcon&&!this.hasLabel,"p-disabled":this.$attrs.disabled,"p-highlight":!0===this.modelValue}},iconClass(){return[this.modelValue?this.onIcon:this.offIcon,"p-button-icon",{"p-button-icon-left":"left"===this.iconPos&&this.label,"p-button-icon-right":"right"===this.iconPos&&this.label}]},hasLabel(){return this.onLabel&&this.onLabel.length>0&&this.offLabel&&this.offLabel.length>0},hasIcon(){return this.onIcon&&this.onIcon.length>0&&this.offIcon&&this.offIcon.length>0},label(){return this.hasLabel?this.modelValue?this.onLabel:this.offLabel:" "}},directives:{ripple:o(t).default}};const l={class:"p-button-label"};return n.render=function(t,o,n,i,s,a){const c=e.resolveDirective("ripple");return e.withDirectives((e.openBlock(),e.createBlock("div",{class:a.buttonClass,onClick:o[1]||(o[1]=t=>a.onClick(t)),role:"checkbox","aria-checked":n.modelValue,tabindex:t.$attrs.disabled?null:"0"},[a.hasIcon?(e.openBlock(),e.createBlock("span",{key:0,class:a.iconClass},null,2)):e.createCommentVNode("",!0),e.createVNode("span",l,e.toDisplayString(a.label),1)],10,["aria-checked","tabindex"])),[[c]])},n}(primevue.ripple,Vue);