UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

2 lines (1 loc) 3.15 kB
"use strict";var e=require("primevue/ripple"),t=require("primevue/utils"),l=require("primevue/basecomponent"),n=require("primevue/togglebutton/style"),a=require("vue");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(e),r={name:"ToggleButton",extends:{name:"BaseToggleButton",extends:o(l).default,props:{modelValue:Boolean,onIcon:String,offIcon:String,onLabel:{type:String,default:"Yes"},offLabel:{type:String,default:"No"},iconPos:{type:String,default:"left"},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},tabindex:{type:Number,default:null},inputId:{type:String,default:null},inputClass:{type:[String,Object],default:null},inputStyle:{type:Object,default:null},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null}},style:o(n).default,provide:function(){return{$parentInstance:this}}},emits:["update:modelValue","change","focus","blur"],methods:{getPTOptions:function(e){return this.ptm(e,{context:{active:this.active,disabled:this.disabled}})},onChange:function(e){this.disabled||this.readonly||(this.$emit("update:modelValue",!this.modelValue),this.$emit("change",e))},onFocus:function(e){this.$emit("focus",e)},onBlur:function(e){this.$emit("blur",e)}},computed:{active:function(){return!0===this.modelValue},hasLabel:function(){return t.ObjectUtils.isNotEmpty(this.onLabel)&&t.ObjectUtils.isNotEmpty(this.offLabel)},hasIcon:function(){return this.$slots.icon||this.onIcon&&this.offIcon},label:function(){return this.hasLabel?this.modelValue?this.onLabel:this.offLabel:" "}},directives:{ripple:i.default}},u=["data-p-highlight","data-p-disabled"],s=["id","value","checked","tabindex","disabled","readonly","aria-labelledby","aria-label"];r.render=function(e,t,l,n,o,i){var r=a.resolveDirective("ripple");return a.openBlock(),a.createElementBlock("div",a.mergeProps({class:e.cx("root")},i.getPTOptions("root"),{"data-pc-name":"togglebutton","data-p-highlight":i.active,"data-p-disabled":e.disabled}),[a.createElementVNode("input",a.mergeProps({id:e.inputId,type:"checkbox",role:"switch",class:[e.cx("input"),e.inputClass],style:e.inputStyle,value:e.modelValue,checked:i.active,tabindex:e.tabindex,disabled:e.disabled,readonly:e.readonly,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onFocus:t[0]||(t[0]=function(){return i.onFocus&&i.onFocus.apply(i,arguments)}),onBlur:t[1]||(t[1]=function(){return i.onBlur&&i.onBlur.apply(i,arguments)}),onChange:t[2]||(t[2]=function(){return i.onChange&&i.onChange.apply(i,arguments)})},i.getPTOptions("input")),null,16,s),a.withDirectives((a.openBlock(),a.createElementBlock("div",a.mergeProps({class:e.cx("box")},i.getPTOptions("box")),[a.renderSlot(e.$slots,"icon",{value:e.modelValue,class:a.normalizeClass(e.cx("icon"))},(function(){return[e.onIcon||e.offIcon?(a.openBlock(),a.createElementBlock("span",a.mergeProps({key:0,class:[e.cx("icon"),e.modelValue?e.onIcon:e.offIcon]},i.getPTOptions("icon")),null,16)):a.createCommentVNode("",!0)]})),a.createElementVNode("span",a.mergeProps({class:e.cx("label")},i.getPTOptions("label")),a.toDisplayString(i.label),17)],16)),[[r]])],16,u)},module.exports=r;