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) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 1.9 kB
"use strict";var e=require("vue"),t={name:"InputSwitch",inheritAttrs:!1,emits:["update:modelValue","click","change"],props:{modelValue:Boolean,class:null,style:null},data:()=>({focused:!1}),methods:{onClick(e){this.$attrs.disabled||(this.$emit("click",e),this.$emit("update:modelValue",!this.modelValue),this.$emit("change",e),this.$refs.input.focus()),e.preventDefault()},onFocus(){this.focused=!0},onBlur(){this.focused=!1}},computed:{containerClass(){return["p-inputswitch p-component",this.class,{"p-inputswitch-checked":this.modelValue,"p-disabled":this.$attrs.disabled,"p-focus":this.focused}]}}};const n={class:"p-hidden-accessible"},s=e.createVNode("span",{class:"p-inputswitch-slider"},null,-1);!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&s.firstChild?s.insertBefore(i,s.firstChild):s.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}('\n.p-inputswitch {\n position: relative;\n display: inline-block;\n}\n.p-inputswitch-slider {\n position: absolute;\n cursor: pointer;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n}\n.p-inputswitch-slider:before {\n position: absolute;\n content: "";\n top: 50%;\n}\n'),t.render=function(t,i,o,c,l,d){return e.openBlock(),e.createBlock("div",{class:d.containerClass,onClick:i[4]||(i[4]=e=>d.onClick(e)),style:o.style},[e.createVNode("div",n,[e.createVNode("input",e.mergeProps({ref:"input",type:"checkbox",checked:o.modelValue},t.$attrs,{onFocus:i[1]||(i[1]=e=>d.onFocus(e)),onBlur:i[2]||(i[2]=e=>d.onBlur(e)),onKeydown:i[3]||(i[3]=e.withKeys(e.withModifiers((e=>d.onClick(e)),["prevent"]),["enter"])),role:"switch","aria-checked":o.modelValue}),null,16,["checked","aria-checked"])]),s],6)},module.exports=t;