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