index-60ea108e.js 2.2 KB

1
  1. import{b7 as v,d as m,b8 as I,w as _,b9 as p,h as i,ba as f,bb as b,bc as C,bd as w,be as y,bf as B,bg as D,l as G,e as u,I as $,bh as x,bi as j,bj as F,bk as N}from"./index-efe400a0.js";const[P,O]=v("radio-group"),q={disabled:Boolean,iconSize:f,direction:String,modelValue:b,checkedColor:String},S=Symbol(P);var A=m({name:P,props:q,emits:["change","update:modelValue"],setup(e,{emit:c,slots:o}){const{linkChildren:l}=I(S),t=a=>c("update:modelValue",a);return _(()=>e.modelValue,a=>c("change",a)),l({props:e,updateValue:t}),p(()=>e.modelValue),()=>{var a;return i("div",{class:O([e.direction]),role:"radiogroup"},[(a=o.default)==null?void 0:a.call(o)])}}});const Y=C(A),V={name:b,shape:w("round"),disabled:Boolean,iconSize:f,modelValue:b,checkedColor:String,labelPosition:String,labelDisabled:Boolean};var E=m({props:y({},V,{bem:B(Function),role:String,parent:Object,checked:Boolean,bindGroup:D}),emits:["click","toggle"],setup(e,{emit:c,slots:o}){const l=G(),t=n=>{if(e.parent&&e.bindGroup)return e.parent.props[n]},a=u(()=>t("disabled")||e.disabled),k=u(()=>t("direction")),z=u(()=>{const n=e.checkedColor||t("checkedColor");if(n&&e.checked&&!a.value)return{borderColor:n,backgroundColor:n}}),R=n=>{const{target:r}=n,d=l.value,s=d===r||(d==null?void 0:d.contains(r));!a.value&&(s||!e.labelDisabled)&&c("toggle"),c("click",n)},h=()=>{const{bem:n,shape:r,checked:d}=e,s=e.iconSize||t("iconSize");return i("div",{ref:l,class:n("icon",[r,{disabled:a.value,checked:d}]),style:{fontSize:x(s)}},[o.icon?o.icon({checked:d,disabled:a.value}):i($,{name:"success",style:z.value},null)])},g=()=>{if(o.default)return i("span",{class:e.bem("label",[e.labelPosition,{disabled:a.value}])},[o.default()])};return()=>{const n=e.labelPosition==="left"?[g(),h()]:[h(),g()];return i("div",{role:e.role,class:e.bem([{disabled:a.value,"label-disabled":e.labelDisabled},k.value]),tabindex:a.value?void 0:0,"aria-checked":e.checked,onClick:R},[n])}}});const[K,L]=v("radio");var T=m({name:K,props:V,emits:["update:modelValue"],setup(e,{emit:c,slots:o}){const{parent:l}=j(S),t=()=>(l?l.props.modelValue:e.modelValue)===e.name,a=()=>{l?l.updateValue(e.name):c("update:modelValue",e.name)};return()=>i(E,N({bem:L,role:"radio",parent:l,checked:t(),onToggle:a},e),F(o,["default","icon"]))}});const H=C(T);export{Y as R,H as a};