1 |
- import{m as y,b2 as z,ae as E,b4 as $,b5 as h,b6 as w,ai as H,f as B,W as J,k as v,s as O,by as x,d as R,t as k,v as G,x as I,y as g,a0 as N,bE as C,B as e,ba as P,A as c,z as _,a as F,a2 as A,G as D,_ as V,n as T,J as Q,bF as X,bG as Y,b3 as Z,o as ee,p as ae,r as oe,$ as se,w as le,a9 as ne,L as te,av as K}from"./index.0b5aa2a0.js";const L=Symbol("radioGroupKey"),M=y({size:z,disabled:Boolean,label:{type:[String,Number,Boolean],default:""}}),re=y({...M,modelValue:{type:[String,Number,Boolean],default:""},name:{type:String,default:""},border:Boolean}),U={[E]:l=>$(l)||h(l)||w(l),[H]:l=>$(l)||h(l)||w(l)},W=(l,b)=>{const n=B(),o=J(L,void 0),d=v(()=>!!o),m=v({get(){return d.value?o.modelValue:l.modelValue},set(i){d.value?o.changeEvent(i):b&&b(E,i),n.value.checked=l.modelValue===l.label}}),r=O(v(()=>o==null?void 0:o.size)),u=x(v(()=>o==null?void 0:o.disabled)),s=B(!1),p=v(()=>u.value||d.value&&m.value!==l.label?-1:0);return{radioRef:n,isGroup:d,radioGroup:o,focus:s,size:r,disabled:u,tabIndex:p,modelValue:m}},ie=["value","name","disabled"],de={name:"ElRadio"},ue=R({...de,props:re,emits:U,setup(l,{emit:b}){const n=l,o=k("radio"),{radioRef:d,radioGroup:m,focus:r,size:u,disabled:s,modelValue:p}=W(n,b);function i(){T(()=>b("change",p.value))}return(a,t)=>{var f;return G(),I("label",{class:c([e(o).b(),e(o).is("disabled",e(s)),e(o).is("focus",e(r)),e(o).is("bordered",a.border),e(o).is("checked",e(p)===a.label),e(o).m(e(u))])},[g("span",{class:c([e(o).e("input"),e(o).is("disabled",e(s)),e(o).is("checked",e(p)===a.label)])},[N(g("input",{ref_key:"radioRef",ref:d,"onUpdate:modelValue":t[0]||(t[0]=S=>P(p)?p.value=S:null),class:c(e(o).e("original")),value:a.label,name:a.name||((f=e(m))==null?void 0:f.name),disabled:e(s),type:"radio",onFocus:t[1]||(t[1]=S=>r.value=!0),onBlur:t[2]||(t[2]=S=>r.value=!1),onChange:i},null,42,ie),[[C,e(p)]]),g("span",{class:c(e(o).e("inner"))},null,2)],2),g("span",{class:c(e(o).e("label")),onKeydown:t[3]||(t[3]=D(()=>{},["stop"]))},[_(a.$slots,"default",{},()=>[F(A(a.label),1)])],34)],2)}}});var pe=V(ue,[["__file","/home/runner/work/element-plus/element-plus/packages/components/radio/src/radio.vue"]]);const be=y({...M,name:{type:String,default:""}}),me=["value","name","disabled"],ce={name:"ElRadioButton"},fe=R({...ce,props:be,setup(l){const b=l,n=k("radio"),{radioRef:o,focus:d,size:m,disabled:r,modelValue:u,radioGroup:s}=W(b),p=v(()=>({backgroundColor:(s==null?void 0:s.fill)||"",borderColor:(s==null?void 0:s.fill)||"",boxShadow:s!=null&&s.fill?`-1px 0 0 0 ${s.fill}`:"",color:(s==null?void 0:s.textColor)||""}));return(i,a)=>{var t;return G(),I("label",{class:c([e(n).b("button"),e(n).is("active",e(u)===i.label),e(n).is("disabled",e(r)),e(n).is("focus",e(d)),e(n).bm("button",e(m))])},[N(g("input",{ref_key:"radioRef",ref:o,"onUpdate:modelValue":a[0]||(a[0]=f=>P(u)?u.value=f:null),class:c(e(n).be("button","original-radio")),value:i.label,type:"radio",name:i.name||((t=e(s))==null?void 0:t.name),disabled:e(r),onFocus:a[1]||(a[1]=f=>d.value=!0),onBlur:a[2]||(a[2]=f=>d.value=!1)},null,42,me),[[C,e(u)]]),g("span",{class:c(e(n).be("button","inner")),style:Q(e(u)===i.label?e(p):{}),onKeydown:a[3]||(a[3]=D(()=>{},["stop"]))},[_(i.$slots,"default",{},()=>[F(A(i.label),1)])],38)],2)}}});var j=V(fe,[["__file","/home/runner/work/element-plus/element-plus/packages/components/radio/src/radio-button.vue"]]);const ve=y({id:{type:String,default:void 0},size:z,disabled:Boolean,modelValue:{type:[String,Number,Boolean],default:""},fill:{type:String,default:""},label:{type:String,default:void 0},textColor:{type:String,default:""},name:{type:String,default:void 0}}),ge=U,ye=["id","aria-label","aria-labelledby"],Se={name:"ElRadioGroup"},Be=R({...Se,props:ve,emits:ge,setup(l,{emit:b}){const n=l,o=k("radio"),d=X(),m=B(),{formItem:r}=Y(),{inputId:u,isLabeledByFormItem:s}=Z(n,{formItemContext:r}),p=a=>{b(E,a),T(()=>b("change",a))};ee(()=>{const a=m.value.querySelectorAll("[type=radio]"),t=a[0];!Array.from(a).some(f=>f.checked)&&t&&(t.tabIndex=0)});const i=v(()=>n.name||d.value);return ae(L,oe({...se(n),changeEvent:p,name:i})),le(()=>n.modelValue,()=>r==null?void 0:r.validate("change").catch(a=>ne())),(a,t)=>(G(),I("div",{id:e(u),ref_key:"radioGroupRef",ref:m,class:c(e(o).b("group")),role:"radiogroup","aria-label":e(s)?void 0:a.label||"radio-group","aria-labelledby":e(s)?e(r).labelId:void 0},[_(a.$slots,"default")],10,ye))}});var q=V(Be,[["__file","/home/runner/work/element-plus/element-plus/packages/components/radio/src/radio-group.vue"]]);te(pe,{RadioButton:j,RadioGroup:q});const Re=K(q),ke=K(j);export{Re as E,ke as a};
|