UNPKG

@aplus-frontend/ui

Version:

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