import{ej as V,d as R,r as s,ay as x,aw as U,j as a,aB as j,c8 as q,aa as O,c9 as P,l as f,dZ as N,c as h,o as D,w as c,W as F,i as k,G,B as S,p as B,ei as W,X as $}from"./index-9PRMimni.js";import{_ as z}from"./RadioButton-oqN0Zkh5.js";const A={...V,request:{type:Function,default:null},options:{type:Array,default:()=>[]},isButton:{type:Boolean,default:!1}};function L(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!N(n)}const b=R({name:"ProRadio",props:A,emits:["complete","update:value","onUpdate:value"],setup(n,{emit:p,expose:m}){const r=s(!0),o=s(),u=s([]);x(()=>n.value,t=>{o.value=t},{immediate:!0});function d(){r.value=!1,p("complete",u.value)}async function g(){const{request:t,options:e}=n;if(!t&&!e){r.value=!1;return}if(e&&e.length){u.value=e,d();return}try{const l=await t();u.value=l||[],d()}catch(l){r.value=!1,console.error(l)}}function _(t){!t||!f(t).length||(u.value=f(t))}function i(t,e){t.preventDefault(),o.value===e?o.value="":o.value=e,p("update:value",o.value),p("onUpdate:value",o.value)}return m({setOptions:_}),U(()=>{g()}),()=>{let t;return a("div",{class:"inline-block"},[a(j,{show:r.value,size:"small"},{default:()=>[a(q,O(n,{value:o.value,"onUpdate:value":e=>o.value=e}),L(t=u.value.map(e=>n.isButton?a(z,{value:e.value,label:e.label,onClick:l=>i(l,e.value)},null):a(P,{value:e.value,label:e.label,onClick:l=>i(l,e.value)},null)))?t:{default:()=>[t]})]})])}}}),M={class:"flex pl-3 mt-6"},T={class:"flex pl-3 mt-6"},E=R({__name:"proRadio",setup(n){const p=s(2),m=s(3),r=s(7),o=s(),u=s([{label:"已完成",value:6},{label:"已售后",value:7},{label:"已服务",value:8}]);async function d(){return await W()}function g(){o.value.setOptions(u.value)}function _(t){console.log(t)}function i(t){console.log("请求完成",t)}return(t,e)=>{const l=G,C=S,y=F,w=$;return D(),h(w,{title:"远程Radio",content:"基于 Radio 组件扩展，很多时候这些数据或许是从 api 获取的，再次点击还可以取消选中哦",showFooter:""},{default:c(()=>[a(y,{bordered:!1,class:"mt-3 proCard",title:"基本使用","content-style":"padding-top: 0;"},{default:c(()=>[a(f(b),{ref_key:"proRadioRef",ref:o,request:d,value:p.value,"onUpdate:value":[e[0]||(e[0]=v=>p.value=v),_],onComplete:i,class:"p-3"},null,8,["value"]),a(l),k("div",M,[a(C,{type:"primary",onClick:g},{default:c(()=>e[3]||(e[3]=[B("改变数据")])),_:1})])]),_:1}),a(y,{bordered:!1,class:"mt-3 proCard",title:"按钮组","content-style":"padding-top: 0;"},{default:c(()=>[a(f(b),{ref_key:"proRadioRef",ref:o,request:d,value:m.value,"onUpdate:value":[e[1]||(e[1]=v=>m.value=v),_],onComplete:i,class:"p-3",isButton:""},null,8,["value"]),a(l),k("div",T,[a(C,{type:"primary",onClick:g},{default:c(()=>e[4]||(e[4]=[B("改变数据")])),_:1})])]),_:1}),a(y,{bordered:!1,class:"mt-3 proCard",title:"静态数据","content-style":"padding-top: 0;"},{default:c(()=>[a(f(b),{options:u.value,value:r.value,"onUpdate:value":[e[2]||(e[2]=v=>r.value=v),_],onComplete:i,class:"p-3"},null,8,["options","value"])]),_:1})]),_:1})}}});export{E as default};
