index-cc5952e0.js 2.2 KB

1
  1. import{b6 as v,d as m,b7 as I,w as _,b8 as p,h as i,b9 as f,ba as b,bb as C,bc as w,bd as y,be as B,bf as D,l as G,e as u,I as $,bg as x,bh as j,bi as F,bj as N}from"./index-03e4b0d9.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),h=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)},k=()=>{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(),k()]:[k(),g()];return i("div",{role:e.role,class:e.bem([{disabled:a.value,"label-disabled":e.labelDisabled},h.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};