@volverjs/ui-vue
Version:
@volverjs/ui-vue is a lightweight Vue 3 component library to accompany @volverjs/style.
2 lines (1 loc) • 2.22 kB
JavaScript
import{provide as e,computed as t,defineComponent as l,toRefs as o,watchEffect as a,createElementBlock as r,openBlock as u,normalizeClass as n,unref as s,createCommentVNode as i,renderSlot as d,createTextVNode as m,toDisplayString as p}from"vue";var b=/* @__PURE__ */(e=>(e.local="local",e.session="session",e))(b||{}),f=/* @__PURE__ */(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(f||{}),g=/* @__PURE__ */(e=>(e.before="before",e.after="after",e))(g||{}),y=/* @__PURE__ */(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(y||{}),c=/* @__PURE__ */(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(c||{});const v=Symbol.for("buttonGroup"),V={disabled:{type:Boolean,default:!1}},A={modifiers:{type:[String,Array],default:void 0}};g.before;const B={unselectable:{type:Boolean,default:!0}};f.bottom,y.button,c.button,b.local;const k={...A,...V,...B,legendLabel:{type:String},itemModifiers:{type:[String,Array],default:""},toggle:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},modelValue:{type:[String,Number,Boolean,Array],default:void 0}};const L={key:0,class:"vv-button-group__legend"},S=/* @__PURE__ */l({name:"VvButtonGroup",props:k,emits:["update:modelValue"],setup(l,{emit:b}){const f=l,g=b,{disabled:y,toggle:c,modifiers:V,multiple:A,unselectable:B,itemModifiers:k}=o(f);a(()=>{"string"==typeof f.modelValue&&A.value&&console.warn("[VvButtonGroup]: modelValue is a string but multiple is true.")});const S=t({get:()=>A.value?f.modelValue:Array.isArray(f.modelValue)?f.modelValue[0]:f.modelValue,set:e=>void 0===e||!Array.isArray(f.modelValue)&&!A.value||Array.isArray(e)?g("update:modelValue",e):g("update:modelValue",[e])});e(v,{modelValue:S,disabled:y,toggle:c,multiple:A,unselectable:B,modifiers:k});const $=function(e,l){return t(()=>{const t={[e]:!0},o="string"==typeof l?.value?l.value.split(" "):l?.value;return o&&Array.isArray(o)&&o.forEach(l=>{l&&(t[`${e}--${l}`]=!0)}),t})}("vv-button-group",V);return(e,t)=>(u(),r("fieldset",{class:n(s($)),role:"group"},[e.$slots.legend||e.legendLabel?(u(),r("legend",L,[d(e.$slots,"legend",{},()=>[m(p(e.legendLabel),1)])])):i("v-if",!0),d(e.$slots,"default")],2))}});export{S as default};