Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vueform/toggle

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueform/toggle - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## v2.1.0
> `2022-07-11`
### 🎉 Features
- Vue `2.7` compatibility.
## v2.0.2

@@ -2,0 +9,0 @@

2

dist/toggle.global.js

@@ -1,1 +0,1 @@

var VueformToggle=function(e,l){"use strict";function a(e,l,a){return l in e?Object.defineProperty(e,l,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[l]=a,e}function t(e,l){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);l&&(t=t.filter((function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable}))),a.push.apply(a,t)}return a}function n(l,n,u){var r=e.toRefs(l),c=r.disabled,d=u.checked,o=e.computed((function(){return function(e){for(var l=1;l<arguments.length;l++){var n=null!=arguments[l]?arguments[l]:{};l%2?t(Object(n),!0).forEach((function(l){a(e,l,n[l])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(n,l))}))}return e}({container:"toggle-container",toggle:"toggle",toggleOn:"toggle-on",toggleOff:"toggle-off",toggleOnDisabled:"toggle-on-disabled",toggleOffDisabled:"toggle-off-disabled",handle:"toggle-handle",handleOn:"toggle-handle-on",handleOff:"toggle-handle-off",handleOnDisabled:"toggle-handle-on-disabled",handleOffDisabled:"toggle-handle-off-disabled",label:"toggle-label"},r.classes.value)}));return{classList:e.computed((function(){return{container:o.value.container,toggle:[o.value.toggle,c.value?d.value?o.value.toggleOnDisabled:o.value.toggleOffDisabled:d.value?o.value.toggleOn:o.value.toggleOff],handle:[o.value.handle,c.value?d.value?o.value.handleOnDisabled:o.value.handleOffDisabled:d.value?o.value.handleOn:o.value.handleOff],label:o.value.label}}))}}var u={name:"Toggle",emits:["input","update:modelValue","change"],props:{...{value:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1},modelValue:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1}},id:{type:[String,Number],required:!1,default:"toggle"},name:{type:[String,Number],required:!1,default:"toggle"},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1},falseValue:{type:[String,Number,Boolean],required:!1,default:!1},trueValue:{type:[String,Number,Boolean],required:!1,default:!0},onLabel:{type:[String,Object],required:!1,default:""},offLabel:{type:[String,Object],required:!1,default:""},classes:{type:Object,required:!1,default:()=>({})},labelledby:{type:String,required:!1},describedby:{type:String,required:!1}},setup(l,a){const t=function(l,a,t){var n=e.toRefs(l),u=n.value,r=n.modelValue,c=n.falseValue,d=n.trueValue,o=n.disabled,i=void 0!==a.expose?r:u,s=e.computed((function(){return i.value===d.value})),f=function(e){a.emit("input",e),a.emit("update:modelValue",e),a.emit("change",e)},b=function(){f(d.value)},g=function(){f(c.value)};return-1!==[null,void 0,!1,0,"0","off"].indexOf(i.value)&&-1===[c.value,d.value].indexOf(i.value)&&g(),-1!==[!0,1,"1","on"].indexOf(i.value)&&-1===[c.value,d.value].indexOf(i.value)&&b(),{externalValue:i,checked:s,update:f,check:b,uncheck:g,handleInput:function(e){f(e.target.checked?d.value:c.value)},handleClick:function(){o.value||(s.value?g():b())}}}(l,a),u=function(l,a,t){var n=e.toRefs(l),u=n.trueValue,r=n.falseValue,c=n.onLabel,d=n.offLabel,o=t.checked,i=t.update;return{label:e.computed((function(){var e=o.value?c.value:d.value;return e||(e="&nbsp;"),e})),toggle:function(){i(o.value?r.value:u.value)},on:function(){i(u.value)},off:function(){i(r.value)}}}(l,0,{checked:t.checked,update:t.update}),r=n(l,0,{checked:t.checked}),c=function(l,a,t){var n=e.toRefs(l).disabled,u=t.check,r=t.uncheck,c=t.checked;return{handleSpace:function(){n.value||(c.value?r():u())}}}(l,0,{check:t.check,uncheck:t.uncheck,checked:t.checked});return{...t,...r,...u,...c}}};return u.render=function(e,a,t,n,u,r){return l.openBlock(),l.createBlock("div",{class:e.classList.container,tabindex:t.disabled?void 0:0,"aria-checked":e.checked,"aria-describedby":t.describedby,"aria-labelledby":t.labelledby,role:"switch",onKeyup:a[2]||(a[2]=l.withKeys(((...l)=>e.handleSpace&&e.handleSpace(...l)),["space"]))},[l.withDirectives(l.createVNode("input",{type:"checkbox",id:t.id,name:t.name,value:t.trueValue,checked:e.checked,disabled:t.disabled},null,8,["id","name","value","checked","disabled"]),[[l.vShow,!1]]),l.createVNode("div",{class:e.classList.toggle,onClick:a[1]||(a[1]=(...l)=>e.handleClick&&e.handleClick(...l))},[l.createVNode("span",{class:e.classList.handle},null,2),l.renderSlot(e.$slots,"label",{checked:e.checked,classList:e.classList},(()=>[l.createVNode("span",{class:e.classList.label,innerHTML:e.label},null,10,["innerHTML"])])),t.required?(l.openBlock(),l.createBlock("input",{key:0,type:"checkbox",style:{appearance:"none",height:"1px",margin:"0",padding:"0",fontSize:"0",background:"transparent",position:"absolute",width:"100%",bottom:"0",outline:"none"},checked:e.checked,"aria-hidden":"true",tabindex:"-1",required:""},null,8,["checked"])):l.createCommentVNode("v-if",!0)],2)],42,["tabindex","aria-checked","aria-describedby","aria-labelledby"])},u.__file="src/Toggle.vue",u}(Vue,Vue);
var VueformToggle=function(e,l){"use strict";function a(e,l,a){return l in e?Object.defineProperty(e,l,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[l]=a,e}function t(e,l){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);l&&(t=t.filter((function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable}))),a.push.apply(a,t)}return a}function n(l,n,u){var r=e.toRefs(l),c=r.disabled,d=u.checked,o=e.computed((function(){return function(e){for(var l=1;l<arguments.length;l++){var n=null!=arguments[l]?arguments[l]:{};l%2?t(Object(n),!0).forEach((function(l){a(e,l,n[l])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(n,l))}))}return e}({container:"toggle-container",toggle:"toggle",toggleOn:"toggle-on",toggleOff:"toggle-off",toggleOnDisabled:"toggle-on-disabled",toggleOffDisabled:"toggle-off-disabled",handle:"toggle-handle",handleOn:"toggle-handle-on",handleOff:"toggle-handle-off",handleOnDisabled:"toggle-handle-on-disabled",handleOffDisabled:"toggle-handle-off-disabled",label:"toggle-label"},r.classes.value)}));return{classList:e.computed((function(){return{container:o.value.container,toggle:[o.value.toggle,c.value?d.value?o.value.toggleOnDisabled:o.value.toggleOffDisabled:d.value?o.value.toggleOn:o.value.toggleOff],handle:[o.value.handle,c.value?d.value?o.value.handleOnDisabled:o.value.handleOffDisabled:d.value?o.value.handleOn:o.value.handleOff],label:o.value.label}}))}}var u={name:"Toggle",emits:["input","update:modelValue","change"],props:{...{value:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1},modelValue:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1}},id:{type:[String,Number],required:!1,default:"toggle"},name:{type:[String,Number],required:!1,default:"toggle"},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1},falseValue:{type:[String,Number,Boolean],required:!1,default:!1},trueValue:{type:[String,Number,Boolean],required:!1,default:!0},onLabel:{type:[String,Object],required:!1,default:""},offLabel:{type:[String,Object],required:!1,default:""},classes:{type:Object,required:!1,default:()=>({})},labelledby:{type:String,required:!1},describedby:{type:String,required:!1}},setup(l,a){const t=function(l,a,t){var n=e.toRefs(l),u=n.value,r=n.modelValue,c=n.falseValue,d=n.trueValue,o=n.disabled,i=r&&void 0!==r.value?r:u,s=e.computed((function(){return i.value===d.value})),f=function(e){a.emit("input",e),a.emit("update:modelValue",e),a.emit("change",e)},b=function(){f(d.value)},g=function(){f(c.value)};return-1!==[null,void 0,!1,0,"0","off"].indexOf(i.value)&&-1===[c.value,d.value].indexOf(i.value)&&g(),-1!==[!0,1,"1","on"].indexOf(i.value)&&-1===[c.value,d.value].indexOf(i.value)&&b(),{externalValue:i,checked:s,update:f,check:b,uncheck:g,handleInput:function(e){f(e.target.checked?d.value:c.value)},handleClick:function(){o.value||(s.value?g():b())}}}(l,a),u=function(l,a,t){var n=e.toRefs(l),u=n.trueValue,r=n.falseValue,c=n.onLabel,d=n.offLabel,o=t.checked,i=t.update;return{label:e.computed((function(){var e=o.value?c.value:d.value;return e||(e="&nbsp;"),e})),toggle:function(){i(o.value?r.value:u.value)},on:function(){i(u.value)},off:function(){i(r.value)}}}(l,0,{checked:t.checked,update:t.update}),r=n(l,0,{checked:t.checked}),c=function(l,a,t){var n=e.toRefs(l).disabled,u=t.check,r=t.uncheck,c=t.checked;return{handleSpace:function(){n.value||(c.value?r():u())}}}(l,0,{check:t.check,uncheck:t.uncheck,checked:t.checked});return{...t,...r,...u,...c}}};return u.render=function(e,a,t,n,u,r){return l.openBlock(),l.createBlock("div",{class:e.classList.container,tabindex:t.disabled?void 0:0,"aria-checked":e.checked,"aria-describedby":t.describedby,"aria-labelledby":t.labelledby,role:"switch",onKeyup:a[2]||(a[2]=l.withKeys(((...l)=>e.handleSpace&&e.handleSpace(...l)),["space"]))},[l.withDirectives(l.createVNode("input",{type:"checkbox",id:t.id,name:t.name,value:t.trueValue,checked:e.checked,disabled:t.disabled},null,8,["id","name","value","checked","disabled"]),[[l.vShow,!1]]),l.createVNode("div",{class:e.classList.toggle,onClick:a[1]||(a[1]=(...l)=>e.handleClick&&e.handleClick(...l))},[l.createVNode("span",{class:e.classList.handle},null,2),l.renderSlot(e.$slots,"label",{checked:e.checked,classList:e.classList},(()=>[l.createVNode("span",{class:e.classList.label,innerHTML:e.label},null,10,["innerHTML"])])),t.required?(l.openBlock(),l.createBlock("input",{key:0,type:"checkbox",style:{appearance:"none",height:"1px",margin:"0",padding:"0",fontSize:"0",background:"transparent",position:"absolute",width:"100%",bottom:"0",outline:"none"},checked:e.checked,"aria-hidden":"true",tabindex:"-1",required:""},null,8,["checked"])):l.createCommentVNode("v-if",!0)],2)],42,["tabindex","aria-checked","aria-describedby","aria-labelledby"])},u.__file="src/Toggle.vue",u}(Vue,Vue);

@@ -1,1 +0,1 @@

import{toRefs as e,computed as l,openBlock as a,createBlock as n,withKeys as t,withDirectives as u,createVNode as r,vShow as d,renderSlot as i,createCommentVNode as c}from"vue";function o(e,l){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);l&&(n=n.filter((function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable}))),a.push.apply(a,n)}return a}function f(e,l,a){return l in e?Object.defineProperty(e,l,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[l]=a,e}function s(a,n,t){var u=e(a),r=u.disabled,d=t.checked,i=l((function(){return function(e){for(var l=1;l<arguments.length;l++){var a=null!=arguments[l]?arguments[l]:{};l%2?o(Object(a),!0).forEach((function(l){f(e,l,a[l])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach((function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(a,l))}))}return e}({container:"toggle-container",toggle:"toggle",toggleOn:"toggle-on",toggleOff:"toggle-off",toggleOnDisabled:"toggle-on-disabled",toggleOffDisabled:"toggle-off-disabled",handle:"toggle-handle",handleOn:"toggle-handle-on",handleOff:"toggle-handle-off",handleOnDisabled:"toggle-handle-on-disabled",handleOffDisabled:"toggle-handle-off-disabled",label:"toggle-label"},u.classes.value)}));return{classList:l((function(){return{container:i.value.container,toggle:[i.value.toggle,r.value?d.value?i.value.toggleOnDisabled:i.value.toggleOffDisabled:d.value?i.value.toggleOn:i.value.toggleOff],handle:[i.value.handle,r.value?d.value?i.value.handleOnDisabled:i.value.handleOffDisabled:d.value?i.value.handleOn:i.value.handleOff],label:i.value.label}}))}}var b={name:"Toggle",emits:["input","update:modelValue","change"],props:{...{value:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1},modelValue:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1}},id:{type:[String,Number],required:!1,default:"toggle"},name:{type:[String,Number],required:!1,default:"toggle"},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1},falseValue:{type:[String,Number,Boolean],required:!1,default:!1},trueValue:{type:[String,Number,Boolean],required:!1,default:!0},onLabel:{type:[String,Object],required:!1,default:""},offLabel:{type:[String,Object],required:!1,default:""},classes:{type:Object,required:!1,default:()=>({})},labelledby:{type:String,required:!1},describedby:{type:String,required:!1}},setup(a,n){const t=function(a,n,t){var u=e(a),r=u.value,d=u.modelValue,i=u.falseValue,c=u.trueValue,o=u.disabled,f=void 0!==n.expose?d:r,s=l((function(){return f.value===c.value})),b=function(e){n.emit("input",e),n.emit("update:modelValue",e),n.emit("change",e)},g=function(){b(c.value)},v=function(){b(i.value)};return-1!==[null,void 0,!1,0,"0","off"].indexOf(f.value)&&-1===[i.value,c.value].indexOf(f.value)&&v(),-1!==[!0,1,"1","on"].indexOf(f.value)&&-1===[i.value,c.value].indexOf(f.value)&&g(),{externalValue:f,checked:s,update:b,check:g,uncheck:v,handleInput:function(e){b(e.target.checked?c.value:i.value)},handleClick:function(){o.value||(s.value?v():g())}}}(a,n),u=function(a,n,t){var u=e(a),r=u.trueValue,d=u.falseValue,i=u.onLabel,c=u.offLabel,o=t.checked,f=t.update;return{label:l((function(){var e=o.value?i.value:c.value;return e||(e="&nbsp;"),e})),toggle:function(){f(o.value?d.value:r.value)},on:function(){f(r.value)},off:function(){f(d.value)}}}(a,0,{checked:t.checked,update:t.update}),r=s(a,0,{checked:t.checked}),d=function(l,a,n){var t=e(l).disabled,u=n.check,r=n.uncheck,d=n.checked;return{handleSpace:function(){t.value||(d.value?r():u())}}}(a,0,{check:t.check,uncheck:t.uncheck,checked:t.checked});return{...t,...r,...u,...d}}};b.render=function(e,l,o,f,s,b){return a(),n("div",{class:e.classList.container,tabindex:o.disabled?void 0:0,"aria-checked":e.checked,"aria-describedby":o.describedby,"aria-labelledby":o.labelledby,role:"switch",onKeyup:l[2]||(l[2]=t(((...l)=>e.handleSpace&&e.handleSpace(...l)),["space"]))},[u(r("input",{type:"checkbox",id:o.id,name:o.name,value:o.trueValue,checked:e.checked,disabled:o.disabled},null,8,["id","name","value","checked","disabled"]),[[d,!1]]),r("div",{class:e.classList.toggle,onClick:l[1]||(l[1]=(...l)=>e.handleClick&&e.handleClick(...l))},[r("span",{class:e.classList.handle},null,2),i(e.$slots,"label",{checked:e.checked,classList:e.classList},(()=>[r("span",{class:e.classList.label,innerHTML:e.label},null,10,["innerHTML"])])),o.required?(a(),n("input",{key:0,type:"checkbox",style:{appearance:"none",height:"1px",margin:"0",padding:"0",fontSize:"0",background:"transparent",position:"absolute",width:"100%",bottom:"0",outline:"none"},checked:e.checked,"aria-hidden":"true",tabindex:"-1",required:""},null,8,["checked"])):c("v-if",!0)],2)],42,["tabindex","aria-checked","aria-describedby","aria-labelledby"])},b.__file="src/Toggle.vue";export default b;
import{toRefs as e,computed as l,openBlock as a,createBlock as n,withKeys as t,withDirectives as u,createVNode as r,vShow as d,renderSlot as i,createCommentVNode as c}from"vue";function o(e,l){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);l&&(n=n.filter((function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable}))),a.push.apply(a,n)}return a}function f(e,l,a){return l in e?Object.defineProperty(e,l,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[l]=a,e}function s(a,n,t){var u=e(a),r=u.disabled,d=t.checked,i=l((function(){return function(e){for(var l=1;l<arguments.length;l++){var a=null!=arguments[l]?arguments[l]:{};l%2?o(Object(a),!0).forEach((function(l){f(e,l,a[l])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach((function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(a,l))}))}return e}({container:"toggle-container",toggle:"toggle",toggleOn:"toggle-on",toggleOff:"toggle-off",toggleOnDisabled:"toggle-on-disabled",toggleOffDisabled:"toggle-off-disabled",handle:"toggle-handle",handleOn:"toggle-handle-on",handleOff:"toggle-handle-off",handleOnDisabled:"toggle-handle-on-disabled",handleOffDisabled:"toggle-handle-off-disabled",label:"toggle-label"},u.classes.value)}));return{classList:l((function(){return{container:i.value.container,toggle:[i.value.toggle,r.value?d.value?i.value.toggleOnDisabled:i.value.toggleOffDisabled:d.value?i.value.toggleOn:i.value.toggleOff],handle:[i.value.handle,r.value?d.value?i.value.handleOnDisabled:i.value.handleOffDisabled:d.value?i.value.handleOn:i.value.handleOff],label:i.value.label}}))}}var b={name:"Toggle",emits:["input","update:modelValue","change"],props:{...{value:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1},modelValue:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1}},id:{type:[String,Number],required:!1,default:"toggle"},name:{type:[String,Number],required:!1,default:"toggle"},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1},falseValue:{type:[String,Number,Boolean],required:!1,default:!1},trueValue:{type:[String,Number,Boolean],required:!1,default:!0},onLabel:{type:[String,Object],required:!1,default:""},offLabel:{type:[String,Object],required:!1,default:""},classes:{type:Object,required:!1,default:()=>({})},labelledby:{type:String,required:!1},describedby:{type:String,required:!1}},setup(a,n){const t=function(a,n,t){var u=e(a),r=u.value,d=u.modelValue,i=u.falseValue,c=u.trueValue,o=u.disabled,f=d&&void 0!==d.value?d:r,s=l((function(){return f.value===c.value})),b=function(e){n.emit("input",e),n.emit("update:modelValue",e),n.emit("change",e)},g=function(){b(c.value)},v=function(){b(i.value)};return-1!==[null,void 0,!1,0,"0","off"].indexOf(f.value)&&-1===[i.value,c.value].indexOf(f.value)&&v(),-1!==[!0,1,"1","on"].indexOf(f.value)&&-1===[i.value,c.value].indexOf(f.value)&&g(),{externalValue:f,checked:s,update:b,check:g,uncheck:v,handleInput:function(e){b(e.target.checked?c.value:i.value)},handleClick:function(){o.value||(s.value?v():g())}}}(a,n),u=function(a,n,t){var u=e(a),r=u.trueValue,d=u.falseValue,i=u.onLabel,c=u.offLabel,o=t.checked,f=t.update;return{label:l((function(){var e=o.value?i.value:c.value;return e||(e="&nbsp;"),e})),toggle:function(){f(o.value?d.value:r.value)},on:function(){f(r.value)},off:function(){f(d.value)}}}(a,0,{checked:t.checked,update:t.update}),r=s(a,0,{checked:t.checked}),d=function(l,a,n){var t=e(l).disabled,u=n.check,r=n.uncheck,d=n.checked;return{handleSpace:function(){t.value||(d.value?r():u())}}}(a,0,{check:t.check,uncheck:t.uncheck,checked:t.checked});return{...t,...r,...u,...d}}};b.render=function(e,l,o,f,s,b){return a(),n("div",{class:e.classList.container,tabindex:o.disabled?void 0:0,"aria-checked":e.checked,"aria-describedby":o.describedby,"aria-labelledby":o.labelledby,role:"switch",onKeyup:l[2]||(l[2]=t(((...l)=>e.handleSpace&&e.handleSpace(...l)),["space"]))},[u(r("input",{type:"checkbox",id:o.id,name:o.name,value:o.trueValue,checked:e.checked,disabled:o.disabled},null,8,["id","name","value","checked","disabled"]),[[d,!1]]),r("div",{class:e.classList.toggle,onClick:l[1]||(l[1]=(...l)=>e.handleClick&&e.handleClick(...l))},[r("span",{class:e.classList.handle},null,2),i(e.$slots,"label",{checked:e.checked,classList:e.classList},(()=>[r("span",{class:e.classList.label,innerHTML:e.label},null,10,["innerHTML"])])),o.required?(a(),n("input",{key:0,type:"checkbox",style:{appearance:"none",height:"1px",margin:"0",padding:"0",fontSize:"0",background:"transparent",position:"absolute",width:"100%",bottom:"0",outline:"none"},checked:e.checked,"aria-hidden":"true",tabindex:"-1",required:""},null,8,["checked"])):c("v-if",!0)],2)],42,["tabindex","aria-checked","aria-describedby","aria-labelledby"])},b.__file="src/Toggle.vue";export default b;

@@ -1,1 +0,1 @@

var VueformToggle=function(e){"use strict";function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function a(a,l,r){var o=e.toRefs(a),u=o.disabled,i=r.checked,d=e.computed((function(){return function(e){for(var a=1;a<arguments.length;a++){var l=null!=arguments[a]?arguments[a]:{};a%2?n(Object(l),!0).forEach((function(n){t(e,n,l[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):n(Object(l)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))}))}return e}({container:"toggle-container",toggle:"toggle",toggleOn:"toggle-on",toggleOff:"toggle-off",toggleOnDisabled:"toggle-on-disabled",toggleOffDisabled:"toggle-off-disabled",handle:"toggle-handle",handleOn:"toggle-handle-on",handleOff:"toggle-handle-off",handleOnDisabled:"toggle-handle-on-disabled",handleOffDisabled:"toggle-handle-off-disabled",label:"toggle-label"},o.classes.value)}));return{classList:e.computed((function(){return{container:d.value.container,toggle:[d.value.toggle,u.value?i.value?d.value.toggleOnDisabled:d.value.toggleOffDisabled:i.value?d.value.toggleOn:d.value.toggleOff],handle:[d.value.handle,u.value?i.value?d.value.handleOnDisabled:d.value.handleOffDisabled:i.value?d.value.handleOn:d.value.handleOff],label:d.value.label}}))}}function l(e,t,n,a,l,r,o,u,i,d){"boolean"!=typeof o&&(i=u,u=o,o=!1);var c,s="function"==typeof n?n.options:n;if(e&&e.render&&(s.render=e.render,s.staticRenderFns=e.staticRenderFns,s._compiled=!0,l&&(s.functional=!0)),a&&(s._scopeId=a),r?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,i(e)),e&&e._registeredComponents&&e._registeredComponents.add(r)},s._ssrRegister=c):t&&(c=o?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,u(e))}),c)if(s.functional){var f=s.render;s.render=function(e,t){return c.call(t),f(e,t)}}else{var g=s.beforeCreate;s.beforeCreate=g?[].concat(g,c):[c]}return n}const r={name:"Toggle",emits:["input","update:modelValue","change"],props:{...{value:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1},modelValue:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1}},id:{type:[String,Number],required:!1,default:"toggle"},name:{type:[String,Number],required:!1,default:"toggle"},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1},falseValue:{type:[String,Number,Boolean],required:!1,default:!1},trueValue:{type:[String,Number,Boolean],required:!1,default:!0},onLabel:{type:[String,Object],required:!1,default:""},offLabel:{type:[String,Object],required:!1,default:""},classes:{type:Object,required:!1,default:()=>({})},labelledby:{type:String,required:!1},describedby:{type:String,required:!1}},setup(t,n){const l=function(t,n,a){var l=e.toRefs(t),r=l.value,o=l.modelValue,u=l.falseValue,i=l.trueValue,d=l.disabled,c=void 0!==n.expose?o:r,s=e.computed((function(){return c.value===i.value})),f=function(e){n.emit("input",e),n.emit("update:modelValue",e),n.emit("change",e)},g=function(){f(i.value)},b=function(){f(u.value)};return-1!==[null,void 0,!1,0,"0","off"].indexOf(c.value)&&-1===[u.value,i.value].indexOf(c.value)&&b(),-1!==[!0,1,"1","on"].indexOf(c.value)&&-1===[u.value,i.value].indexOf(c.value)&&g(),{externalValue:c,checked:s,update:f,check:g,uncheck:b,handleInput:function(e){f(e.target.checked?i.value:u.value)},handleClick:function(){d.value||(s.value?b():g())}}}(t,n),r=function(t,n,a){var l=e.toRefs(t),r=l.trueValue,o=l.falseValue,u=l.onLabel,i=l.offLabel,d=a.checked,c=a.update;return{label:e.computed((function(){var e=d.value?u.value:i.value;return e||(e="&nbsp;"),e})),toggle:function(){c(d.value?o.value:r.value)},on:function(){c(r.value)},off:function(){c(o.value)}}}(t,0,{checked:l.checked,update:l.update}),o=a(t,0,{checked:l.checked}),u=function(t,n,a){var l=e.toRefs(t).disabled,r=a.check,o=a.uncheck,u=a.checked;return{handleSpace:function(){l.value||(u.value?o():r())}}}(t,0,{check:l.check,uncheck:l.uncheck,checked:l.checked});return{...l,...o,...r,...u}}};var o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:e.classList.container,attrs:{tabindex:e.disabled?void 0:0,"aria-checked":e.checked,"aria-describedby":e.describedby,"aria-labelledby":e.labelledby,role:"switch"},on:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"space",32,t.key,[" ","Spacebar"])?null:e.handleSpace(t)}}},[n("input",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],attrs:{type:"checkbox",id:e.id,name:e.name,disabled:e.disabled},domProps:{value:e.trueValue,checked:e.checked}}),e._v(" "),n("div",{class:e.classList.toggle,on:{click:e.handleClick}},[n("span",{class:e.classList.handle}),e._v(" "),e._t("label",[n("span",{class:e.classList.label,domProps:{innerHTML:e._s(e.label)}})],{checked:e.checked,classList:e.classList}),e._v(" "),e.required?n("input",{style:{appearance:"none",height:"1px",margin:"0",padding:"0",fontSize:"0",background:"transparent",position:"absolute",width:"100%",bottom:"0",outline:"none"},attrs:{type:"checkbox","aria-hidden":"true",tabindex:"-1",required:""},domProps:{checked:e.checked}}):e._e()],2)])};o._withStripped=!0;return l({render:o,staticRenderFns:[]},undefined,r,undefined,false,undefined,!1,void 0,void 0,void 0)}(VueCompositionAPI);
var VueformToggle=function(e){"use strict";function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function a(a,l,r){var o=e.toRefs(a),u=o.disabled,i=r.checked,d=e.computed((function(){return function(e){for(var a=1;a<arguments.length;a++){var l=null!=arguments[a]?arguments[a]:{};a%2?n(Object(l),!0).forEach((function(n){t(e,n,l[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):n(Object(l)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))}))}return e}({container:"toggle-container",toggle:"toggle",toggleOn:"toggle-on",toggleOff:"toggle-off",toggleOnDisabled:"toggle-on-disabled",toggleOffDisabled:"toggle-off-disabled",handle:"toggle-handle",handleOn:"toggle-handle-on",handleOff:"toggle-handle-off",handleOnDisabled:"toggle-handle-on-disabled",handleOffDisabled:"toggle-handle-off-disabled",label:"toggle-label"},o.classes.value)}));return{classList:e.computed((function(){return{container:d.value.container,toggle:[d.value.toggle,u.value?i.value?d.value.toggleOnDisabled:d.value.toggleOffDisabled:i.value?d.value.toggleOn:d.value.toggleOff],handle:[d.value.handle,u.value?i.value?d.value.handleOnDisabled:d.value.handleOffDisabled:i.value?d.value.handleOn:d.value.handleOff],label:d.value.label}}))}}function l(e,t,n,a,l,r,o,u,i,d){"boolean"!=typeof o&&(i=u,u=o,o=!1);var c,s="function"==typeof n?n.options:n;if(e&&e.render&&(s.render=e.render,s.staticRenderFns=e.staticRenderFns,s._compiled=!0,l&&(s.functional=!0)),a&&(s._scopeId=a),r?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,i(e)),e&&e._registeredComponents&&e._registeredComponents.add(r)},s._ssrRegister=c):t&&(c=o?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,u(e))}),c)if(s.functional){var f=s.render;s.render=function(e,t){return c.call(t),f(e,t)}}else{var g=s.beforeCreate;s.beforeCreate=g?[].concat(g,c):[c]}return n}const r={name:"Toggle",emits:["input","update:modelValue","change"],props:{...{value:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1},modelValue:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1}},id:{type:[String,Number],required:!1,default:"toggle"},name:{type:[String,Number],required:!1,default:"toggle"},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1},falseValue:{type:[String,Number,Boolean],required:!1,default:!1},trueValue:{type:[String,Number,Boolean],required:!1,default:!0},onLabel:{type:[String,Object],required:!1,default:""},offLabel:{type:[String,Object],required:!1,default:""},classes:{type:Object,required:!1,default:()=>({})},labelledby:{type:String,required:!1},describedby:{type:String,required:!1}},setup(t,n){const l=function(t,n,a){var l=e.toRefs(t),r=l.value,o=l.modelValue,u=l.falseValue,i=l.trueValue,d=l.disabled,c=o&&void 0!==o.value?o:r,s=e.computed((function(){return c.value===i.value})),f=function(e){n.emit("input",e),n.emit("update:modelValue",e),n.emit("change",e)},g=function(){f(i.value)},v=function(){f(u.value)};return-1!==[null,void 0,!1,0,"0","off"].indexOf(c.value)&&-1===[u.value,i.value].indexOf(c.value)&&v(),-1!==[!0,1,"1","on"].indexOf(c.value)&&-1===[u.value,i.value].indexOf(c.value)&&g(),{externalValue:c,checked:s,update:f,check:g,uncheck:v,handleInput:function(e){f(e.target.checked?i.value:u.value)},handleClick:function(){d.value||(s.value?v():g())}}}(t,n),r=function(t,n,a){var l=e.toRefs(t),r=l.trueValue,o=l.falseValue,u=l.onLabel,i=l.offLabel,d=a.checked,c=a.update;return{label:e.computed((function(){var e=d.value?u.value:i.value;return e||(e="&nbsp;"),e})),toggle:function(){c(d.value?o.value:r.value)},on:function(){c(r.value)},off:function(){c(o.value)}}}(t,0,{checked:l.checked,update:l.update}),o=a(t,0,{checked:l.checked}),u=function(t,n,a){var l=e.toRefs(t).disabled,r=a.check,o=a.uncheck,u=a.checked;return{handleSpace:function(){l.value||(u.value?o():r())}}}(t,0,{check:l.check,uncheck:l.uncheck,checked:l.checked});return{...l,...o,...r,...u}}};var o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:e.classList.container,attrs:{tabindex:e.disabled?void 0:0,"aria-checked":e.checked,"aria-describedby":e.describedby,"aria-labelledby":e.labelledby,role:"switch"},on:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"space",32,t.key,[" ","Spacebar"])?null:e.handleSpace(t)}}},[n("input",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],attrs:{type:"checkbox",id:e.id,name:e.name,disabled:e.disabled},domProps:{value:e.trueValue,checked:e.checked}}),e._v(" "),n("div",{class:e.classList.toggle,on:{click:e.handleClick}},[n("span",{class:e.classList.handle}),e._v(" "),e._t("label",[n("span",{class:e.classList.label,domProps:{innerHTML:e._s(e.label)}})],{checked:e.checked,classList:e.classList}),e._v(" "),e.required?n("input",{style:{appearance:"none",height:"1px",margin:"0",padding:"0",fontSize:"0",background:"transparent",position:"absolute",width:"100%",bottom:"0",outline:"none"},attrs:{type:"checkbox","aria-hidden":"true",tabindex:"-1",required:""},domProps:{checked:e.checked}}):e._e()],2)])};o._withStripped=!0;return l({render:o,staticRenderFns:[]},undefined,r,undefined,false,undefined,!1,void 0,void 0,void 0)}(Vue);

@@ -1,1 +0,1 @@

import{toRefs as e,computed as n}from"@vue/composition-api";function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function l(l,r,o){var i=e(l),u=i.disabled,d=o.checked,c=n((function(){return function(e){for(var n=1;n<arguments.length;n++){var l=null!=arguments[n]?arguments[n]:{};n%2?t(Object(l),!0).forEach((function(n){a(e,n,l[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):t(Object(l)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(l,n))}))}return e}({container:"toggle-container",toggle:"toggle",toggleOn:"toggle-on",toggleOff:"toggle-off",toggleOnDisabled:"toggle-on-disabled",toggleOffDisabled:"toggle-off-disabled",handle:"toggle-handle",handleOn:"toggle-handle-on",handleOff:"toggle-handle-off",handleOnDisabled:"toggle-handle-on-disabled",handleOffDisabled:"toggle-handle-off-disabled",label:"toggle-label"},i.classes.value)}));return{classList:n((function(){return{container:c.value.container,toggle:[c.value.toggle,u.value?d.value?c.value.toggleOnDisabled:c.value.toggleOffDisabled:d.value?c.value.toggleOn:c.value.toggleOff],handle:[c.value.handle,u.value?d.value?c.value.handleOnDisabled:c.value.handleOffDisabled:d.value?c.value.handleOn:c.value.handleOff],label:c.value.label}}))}}function r(e,n,t,a,l,r,o,i,u,d){"boolean"!=typeof o&&(u=i,i=o,o=!1);var c,s="function"==typeof t?t.options:t;if(e&&e.render&&(s.render=e.render,s.staticRenderFns=e.staticRenderFns,s._compiled=!0,l&&(s.functional=!0)),a&&(s._scopeId=a),r?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,u(e)),e&&e._registeredComponents&&e._registeredComponents.add(r)},s._ssrRegister=c):n&&(c=o?function(e){n.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){n.call(this,i(e))}),c)if(s.functional){var f=s.render;s.render=function(e,n){return c.call(n),f(e,n)}}else{var b=s.beforeCreate;s.beforeCreate=b?[].concat(b,c):[c]}return t}const o={name:"Toggle",emits:["input","update:modelValue","change"],props:{...{value:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1},modelValue:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1}},id:{type:[String,Number],required:!1,default:"toggle"},name:{type:[String,Number],required:!1,default:"toggle"},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1},falseValue:{type:[String,Number,Boolean],required:!1,default:!1},trueValue:{type:[String,Number,Boolean],required:!1,default:!0},onLabel:{type:[String,Object],required:!1,default:""},offLabel:{type:[String,Object],required:!1,default:""},classes:{type:Object,required:!1,default:()=>({})},labelledby:{type:String,required:!1},describedby:{type:String,required:!1}},setup(t,a){const r=function(t,a,l){var r=e(t),o=r.value,i=r.modelValue,u=r.falseValue,d=r.trueValue,c=r.disabled,s=void 0!==a.expose?i:o,f=n((function(){return s.value===d.value})),b=function(e){a.emit("input",e),a.emit("update:modelValue",e),a.emit("change",e)},g=function(){b(d.value)},v=function(){b(u.value)};return-1!==[null,void 0,!1,0,"0","off"].indexOf(s.value)&&-1===[u.value,d.value].indexOf(s.value)&&v(),-1!==[!0,1,"1","on"].indexOf(s.value)&&-1===[u.value,d.value].indexOf(s.value)&&g(),{externalValue:s,checked:f,update:b,check:g,uncheck:v,handleInput:function(e){b(e.target.checked?d.value:u.value)},handleClick:function(){c.value||(f.value?v():g())}}}(t,a),o=function(t,a,l){var r=e(t),o=r.trueValue,i=r.falseValue,u=r.onLabel,d=r.offLabel,c=l.checked,s=l.update;return{label:n((function(){var e=c.value?u.value:d.value;return e||(e="&nbsp;"),e})),toggle:function(){s(c.value?i.value:o.value)},on:function(){s(o.value)},off:function(){s(i.value)}}}(t,0,{checked:r.checked,update:r.update}),i=l(t,0,{checked:r.checked}),u=function(n,t,a){var l=e(n).disabled,r=a.check,o=a.uncheck,i=a.checked;return{handleSpace:function(){l.value||(i.value?o():r())}}}(t,0,{check:r.check,uncheck:r.uncheck,checked:r.checked});return{...r,...i,...o,...u}}};var i=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{class:e.classList.container,attrs:{tabindex:e.disabled?void 0:0,"aria-checked":e.checked,"aria-describedby":e.describedby,"aria-labelledby":e.labelledby,role:"switch"},on:{keyup:function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"space",32,n.key,[" ","Spacebar"])?null:e.handleSpace(n)}}},[t("input",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],attrs:{type:"checkbox",id:e.id,name:e.name,disabled:e.disabled},domProps:{value:e.trueValue,checked:e.checked}}),e._v(" "),t("div",{class:e.classList.toggle,on:{click:e.handleClick}},[t("span",{class:e.classList.handle}),e._v(" "),e._t("label",[t("span",{class:e.classList.label,domProps:{innerHTML:e._s(e.label)}})],{checked:e.checked,classList:e.classList}),e._v(" "),e.required?t("input",{style:{appearance:"none",height:"1px",margin:"0",padding:"0",fontSize:"0",background:"transparent",position:"absolute",width:"100%",bottom:"0",outline:"none"},attrs:{type:"checkbox","aria-hidden":"true",tabindex:"-1",required:""},domProps:{checked:e.checked}}):e._e()],2)])};i._withStripped=!0;const u=r({render:i,staticRenderFns:[]},undefined,o,undefined,false,undefined,!1,void 0,void 0,void 0);export default u;
import{toRefs as e,computed as n}from"vue";function t(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function l(l,r,o){var u=e(l),i=u.disabled,d=o.checked,c=n((function(){return function(e){for(var n=1;n<arguments.length;n++){var l=null!=arguments[n]?arguments[n]:{};n%2?t(Object(l),!0).forEach((function(n){a(e,n,l[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):t(Object(l)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(l,n))}))}return e}({container:"toggle-container",toggle:"toggle",toggleOn:"toggle-on",toggleOff:"toggle-off",toggleOnDisabled:"toggle-on-disabled",toggleOffDisabled:"toggle-off-disabled",handle:"toggle-handle",handleOn:"toggle-handle-on",handleOff:"toggle-handle-off",handleOnDisabled:"toggle-handle-on-disabled",handleOffDisabled:"toggle-handle-off-disabled",label:"toggle-label"},u.classes.value)}));return{classList:n((function(){return{container:c.value.container,toggle:[c.value.toggle,i.value?d.value?c.value.toggleOnDisabled:c.value.toggleOffDisabled:d.value?c.value.toggleOn:c.value.toggleOff],handle:[c.value.handle,i.value?d.value?c.value.handleOnDisabled:c.value.handleOffDisabled:d.value?c.value.handleOn:c.value.handleOff],label:c.value.label}}))}}function r(e,n,t,a,l,r,o,u,i,d){"boolean"!=typeof o&&(i=u,u=o,o=!1);var c,s="function"==typeof t?t.options:t;if(e&&e.render&&(s.render=e.render,s.staticRenderFns=e.staticRenderFns,s._compiled=!0,l&&(s.functional=!0)),a&&(s._scopeId=a),r?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,i(e)),e&&e._registeredComponents&&e._registeredComponents.add(r)},s._ssrRegister=c):n&&(c=o?function(e){n.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){n.call(this,u(e))}),c)if(s.functional){var f=s.render;s.render=function(e,n){return c.call(n),f(e,n)}}else{var v=s.beforeCreate;s.beforeCreate=v?[].concat(v,c):[c]}return t}const o={name:"Toggle",emits:["input","update:modelValue","change"],props:{...{value:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1},modelValue:{validator:function(e){return e=>-1!==["number","string","boolean"].indexOf(typeof e)||null==e},required:!1}},id:{type:[String,Number],required:!1,default:"toggle"},name:{type:[String,Number],required:!1,default:"toggle"},disabled:{type:Boolean,required:!1,default:!1},required:{type:Boolean,required:!1,default:!1},falseValue:{type:[String,Number,Boolean],required:!1,default:!1},trueValue:{type:[String,Number,Boolean],required:!1,default:!0},onLabel:{type:[String,Object],required:!1,default:""},offLabel:{type:[String,Object],required:!1,default:""},classes:{type:Object,required:!1,default:()=>({})},labelledby:{type:String,required:!1},describedby:{type:String,required:!1}},setup(t,a){const r=function(t,a,l){var r=e(t),o=r.value,u=r.modelValue,i=r.falseValue,d=r.trueValue,c=r.disabled,s=u&&void 0!==u.value?u:o,f=n((function(){return s.value===d.value})),v=function(e){a.emit("input",e),a.emit("update:modelValue",e),a.emit("change",e)},b=function(){v(d.value)},g=function(){v(i.value)};return-1!==[null,void 0,!1,0,"0","off"].indexOf(s.value)&&-1===[i.value,d.value].indexOf(s.value)&&g(),-1!==[!0,1,"1","on"].indexOf(s.value)&&-1===[i.value,d.value].indexOf(s.value)&&b(),{externalValue:s,checked:f,update:v,check:b,uncheck:g,handleInput:function(e){v(e.target.checked?d.value:i.value)},handleClick:function(){c.value||(f.value?g():b())}}}(t,a),o=function(t,a,l){var r=e(t),o=r.trueValue,u=r.falseValue,i=r.onLabel,d=r.offLabel,c=l.checked,s=l.update;return{label:n((function(){var e=c.value?i.value:d.value;return e||(e="&nbsp;"),e})),toggle:function(){s(c.value?u.value:o.value)},on:function(){s(o.value)},off:function(){s(u.value)}}}(t,0,{checked:r.checked,update:r.update}),u=l(t,0,{checked:r.checked}),i=function(n,t,a){var l=e(n).disabled,r=a.check,o=a.uncheck,u=a.checked;return{handleSpace:function(){l.value||(u.value?o():r())}}}(t,0,{check:r.check,uncheck:r.uncheck,checked:r.checked});return{...r,...u,...o,...i}}};var u=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{class:e.classList.container,attrs:{tabindex:e.disabled?void 0:0,"aria-checked":e.checked,"aria-describedby":e.describedby,"aria-labelledby":e.labelledby,role:"switch"},on:{keyup:function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"space",32,n.key,[" ","Spacebar"])?null:e.handleSpace(n)}}},[t("input",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],attrs:{type:"checkbox",id:e.id,name:e.name,disabled:e.disabled},domProps:{value:e.trueValue,checked:e.checked}}),e._v(" "),t("div",{class:e.classList.toggle,on:{click:e.handleClick}},[t("span",{class:e.classList.handle}),e._v(" "),e._t("label",[t("span",{class:e.classList.label,domProps:{innerHTML:e._s(e.label)}})],{checked:e.checked,classList:e.classList}),e._v(" "),e.required?t("input",{style:{appearance:"none",height:"1px",margin:"0",padding:"0",fontSize:"0",background:"transparent",position:"absolute",width:"100%",bottom:"0",outline:"none"},attrs:{type:"checkbox","aria-hidden":"true",tabindex:"-1",required:""},domProps:{checked:e.checked}}):e._e()],2)])};u._withStripped=!0;const i=r({render:u,staticRenderFns:[]},undefined,o,undefined,false,undefined,!1,void 0,void 0,void 0);export default i;
{
"name": "@vueform/toggle",
"version": "2.0.2",
"version": "2.1.0",
"private": false,

@@ -5,0 +5,0 @@ "description": "Vue 3 toggle component with labels, custom slots and styling options.",

@@ -129,49 +129,31 @@ <div align="center">

When using Vue 2 install [@vue/composition-api](https://github.com/vuejs/composition-api#npm) via npm/yarn first:
``` vue
<template>
<div>
<Toggle v-model="value" />
</div>
</template>
``` bash
npm i @vue/composition-api --save-dev
```
<script>
import Toggle from '@vueform/toggle/toggle.vue2.js'
Then install the plugin for Vue:
export default {
components: {
Toggle,
},
data() {
return {
value: true
}
}
}
</script>
``` js
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)
<style src="@vueform/toggle/themes/default.css"></style>
```
After that make sure to change the imported Toggle module to:
#### Using with < Vue 2.7
``` js
import Toggle from '@vueform/toggle/dist/toggle.vue2.js'
```
Switch to [`<= 2.0.2`](https://github.com/vueform/toggle/tree/2.0.2) to use the Toggle with Vue.js `< 2.7`.
## Using with Nuxt.js
First you need install [@nuxtjs/composition-api](https://composition-api.nuxtjs.org/getting-started/setup):
``` bash
npm i @nuxtjs/composition-api --save
```
Then you need to enable it as a module in `nuxt.config.js`:
``` js
{
buildModules: [
'@nuxtjs/composition-api/module'
]
}
```
After that make sure to change the imported module to Vue 2 version of Toggle:
``` js
import Toggle from '@vueform/toggle/dist/toggle.vue2'
```
For more information on using `@nuxtjs/composition-api` read [their documentation](https://composition-api.nuxtjs.org/).
## Support

@@ -178,0 +160,0 @@

@@ -8,3 +8,3 @@ import { toRefs, computed } from 'composition-api'

/* istanbul ignore next */
const externalValue = context.expose !== undefined ? modelValue : value
const externalValue = modelValue && modelValue.value !== undefined ? modelValue : value

@@ -11,0 +11,0 @@ // ============== COMPUTED ==============

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc