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
import{openBlock as e,createBlock as t,createVNode as n,mergeProps as s,withKeys as i,withModifiers as o}from"vue";var l={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 c={class:"p-hidden-accessible"},d=n("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'),l.render=function(l,a,u,r,p,h){return e(),t("div",{class:h.containerClass,onClick:a[4]||(a[4]=e=>h.onClick(e)),style:u.style},[n("div",c,[n("input",s({ref:"input",type:"checkbox",checked:u.modelValue},l.$attrs,{onFocus:a[1]||(a[1]=e=>h.onFocus(e)),onBlur:a[2]||(a[2]=e=>h.onBlur(e)),onKeydown:a[3]||(a[3]=i(o((e=>h.onClick(e)),["prevent"]),["enter"])),role:"switch","aria-checked":u.modelValue}),null,16,["checked","aria-checked"])]),d],6)};export default l;