UNPKG

@aplus-frontend/ui

Version:

2 lines (1 loc) 1.64 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),f=require("@aplus-frontend/antdv");require("../../config-provider/index.js");require("../../hooks/index.js");const h=require("../../config-provider/hooks/use-namespace.js"),g=require("../../hooks/useControllableValue.js"),v=["onClick"],y=e.defineComponent({name:"ApRadioGroup",__name:"ap-radio-group",props:{value:{default:""},delay:{default:0},options:{default:()=>[]},optionStyle:{default:()=>({height:28,gap:8})}},emits:["update:value","change"],setup(i,{emit:s}){const{b:c,e:a}=h.useNamespace("ap-radio-group"),n=i,r=s,{value:u,updateValue:p}=g.useControllableValue(n,r),o=e.ref(u.value),d=t=>e.isVNode(t)?e.h(t):typeof t=="function"?e.h("span",t()):e.h("span",t);e.watch(()=>u.value,t=>{t!==o.value&&(o.value=t)});const m=t=>{o.value=t,setTimeout(()=>{p(t),r("change",t)},n.delay)};return(t,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([e.unref(c)()])},[e.createVNode(e.unref(f.Flex),{gap:t.optionStyle?.gap,wrap:"wrap"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options.filter(l=>l.visible!==!1),l=>(e.openBlock(),e.createElementBlock("div",{key:l.value,class:e.normalizeClass([e.unref(a)("item"),o.value===l.value?e.unref(a)("item--active"):""]),style:e.normalizeStyle({height:t.optionStyle?.height+"px",lineHeight:t.optionStyle?.height+"px",color:t.optionStyle?.color}),onClick:C=>m(l.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d(l.label))))],14,v))),128))]),_:1},8,["gap"])],2))}});exports.default=y;