import{eg as g,d as _,r as f,a4 as y,j as a,a7 as S,aa as d,a8 as B,H as F,B as c}from"./index-9PRMimni.js";const b={...g,drawerContent:{type:Object},positiveButtonProps:{type:Object},negativeButtonProps:{type:Object},positiveText:{type:String,default:"确认"},negativeText:{type:String,default:"取消"},form:{type:Object,required:!0},showAction:{type:Boolean,default:!0},isHideForm:{type:Boolean,default:!1},isShowHeader:{type:Boolean,default:!1},isShowFooter:{type:Boolean,default:!1}},P=_({name:"DrawerForm",props:b,emits:["submit","register","update:isShowHeader","update:isHideForm","update:isShowFooter","update:showAction"],setup(e,{emit:n,slots:t,expose:m}){const r=f(!1),i=f(!1),p=y(()=>e.form);function s(){i.value=!1,r.value=!1,n("update:isShowHeader",!0),n("update:isHideForm",!1),n("update:isShowFooter",!1),n("update:showAction",!0)}function w(){r.value=!0}function u(o){i.value=o}function h(){return{footer:()=>t.action?t.action():e.showAction&&a(F,null,{default:()=>[a(c,d(e.negativeButtonProps,{onClick:s}),{default:()=>[e.negativeText]}),a(c,d({type:"primary"},e.positiveButtonProps,{loading:i.value,onClick:l}),{default:()=>[e.positiveText]})]})}}async function l(){i.value=!0;const o=await p?.value?.submit();if(!o){setTimeout(()=>{u(!1)},200);return}n("submit",o,v=>{v===!0?(u(!1),s()):u(!1)})}return m({showDrawer:w,hideDrawer:s,setLoading:u,submit:l}),()=>a(S,d(e,{show:r.value,"onUpdate:show":o=>r.value=o}),{default:()=>[a(B,e.drawerContent,{default:()=>[e.isShowHeader&&t.header&&a("div",{class:"form-dialog-header"},[t.header()]),!e.isHideForm&&t.default&&a("div",{class:"form-dialog-form"},[t.default()]),e.isShowFooter&&t.footer&&a("div",{class:"form-dialog-head"},[t.footer()])],...h()})]})}});export{P as _};
