register-oLnhNHen.js 3.2 KB

1
  1. var v=(p,u,o)=>new Promise((r,t)=>{var l=n=>{try{c(o.next(n))}catch(m){t(m)}},i=n=>{try{c(o.throw(n))}catch(m){t(m)}},c=n=>n.done?r(n.value):Promise.resolve(n.value).then(l,i);c((o=o.apply(p,u)).next())});import{b7 as V,b0 as $,a$ as e,b1 as y,b8 as g,bg as B}from"./bootstrap-Dk-V8kQL.js";import{T as x}from"./auth-title-DEa0D3bh.js";import{a4 as S,T as N,J as _,av as A,ab as k,x as b,aB as P,ac as w,a8 as T,ai as h,aj as d,a7 as s,aV as F,P as R,k as C,aa as I}from"../jse/index-index-CjpzFec5.js";const L={class:"mt-4 text-center text-sm"},q=S({name:"RegisterForm",__name:"register",props:{formSchema:{default:()=>[]},loading:{type:Boolean,default:!1},loginPath:{default:"/auth/login"},title:{default:""},subTitle:{default:""},submitButtonText:{default:""}},emits:["submit"],setup(p,{expose:u,emit:o}){const r=p,t=o,[l,i]=V(N({commonConfig:{hideLabel:!0,hideRequiredMark:!0},schema:_(()=>r.formSchema),showDefaultActions:!1})),c=$();function n(){return v(this,null,function*(){const{valid:a}=yield i.validate(),f=yield i.getValues();a&&t("submit",f)})}function m(){c.push(r.loginPath)}return u({getFormApi:()=>i}),(a,f)=>(k(),A("div",null,[b(x,null,{desc:w(()=>[T(a.$slots,"subTitle",{},()=>[h(d(a.subTitle||s(e)("authentication.signUpSubtitle")),1)])]),default:w(()=>[T(a.$slots,"title",{},()=>[h(d(a.title||s(e)("authentication.createAnAccount"))+" 🚀 ",1)])]),_:3}),b(s(l)),b(s(y),{class:F([{"cursor-wait":a.loading},"mt-2 w-full"]),loading:a.loading,"aria-label":"register",onClick:n},{default:w(()=>[T(a.$slots,"submitButtonText",{},()=>[h(d(a.submitButtonText||s(e)("authentication.signUp")),1)])]),_:3},8,["class","loading"]),P("div",L,[h(d(s(e)("authentication.alreadyHaveAccount"))+" ",1),P("span",{class:"vben-link text-sm font-normal",onClick:f[0]||(f[0]=D=>m())},d(s(e)("authentication.goToLogin")),1)])]))}}),H=S({name:"Register",__name:"register",setup(p){const u=R(!1),o=_(()=>[{component:"VbenInput",componentProps:{placeholder:e("authentication.usernameTip")},fieldName:"username",label:e("authentication.username"),rules:g().min(1,{message:e("authentication.usernameTip")})},{component:"VbenInputPassword",componentProps:{passwordStrength:!0,placeholder:e("authentication.password")},fieldName:"password",label:e("authentication.password"),renderComponentContent(){return{strengthText:()=>e("authentication.passwordStrength")}},rules:g().min(1,{message:e("authentication.passwordTip")})},{component:"VbenInputPassword",componentProps:{placeholder:e("authentication.confirmPassword")},dependencies:{rules(t){const{password:l}=t;return g({required_error:e("authentication.passwordTip")}).min(1,{message:e("authentication.passwordTip")}).refine(i=>i===l,{message:e("authentication.confirmPasswordTip")})},triggerFields:["password"]},fieldName:"confirmPassword",label:e("authentication.confirmPassword")},{component:"VbenCheckbox",fieldName:"agreePolicy",renderComponentContent:()=>({default:()=>C("span",[e("authentication.agree"),C("a",{class:"vben-link ml-1 ",href:""},`${e("authentication.privacyPolicy")} & ${e("authentication.terms")}`)])}),rules:B().refine(t=>!!t,{message:e("authentication.agreeTip")})}]);function r(t){console.log("register submit:",t)}return(t,l)=>(k(),I(s(q),{"form-schema":o.value,loading:u.value,onSubmit:r},null,8,["form-schema","loading"]))}});export{H as default};