You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
1.7 KiB
2 lines
1.7 KiB
import{j as T,k as F,n as M,aZ as j,s as k,b as x,H as O,G as f,M as C,O as I,__tla as D}from"./index.3b792103.js";let p,G=Promise.all([(()=>{try{return D}catch{}})()]).then(async()=>{const[v,b]=T("form");var B=F({name:v,props:{colon:Boolean,disabled:Boolean,readonly:Boolean,showError:Boolean,labelWidth:O,labelAlign:String,inputAlign:String,scrollToError:Boolean,validateFirst:Boolean,submitOnEnter:f,showErrorMessage:f,errorMessageAlign:String,validateTrigger:{type:[String,Array],default:"onBlur"}},emits:["submit","failed"],setup(n,{emit:i,slots:m}){const{children:o,linkChildren:y}=M(j),s=e=>e?o.filter(a=>e.includes(a.name)):o,P=e=>new Promise((a,r)=>{const l=[];s(e).reduce((t,A)=>t.then(()=>{if(!l.length)return A.validate().then(h=>{h&&l.push(h)})}),Promise.resolve()).then(()=>{l.length?r(l):a()})}),S=e=>new Promise((a,r)=>{const l=s(e);Promise.all(l.map(t=>t.validate())).then(t=>{t=t.filter(Boolean),t.length?r(t):a()})}),_=e=>{const a=o.find(r=>r.name===e);return a?new Promise((r,l)=>{a.validate().then(t=>{t?l(t):r()})}):Promise.reject()},d=e=>typeof e=="string"?_(e):n.validateFirst?P(e):S(e),w=e=>{typeof e=="string"&&(e=[e]),s(e).forEach(a=>{a.resetValidation()})},E=()=>o.reduce((e,a)=>(e[a.name]=a.getValidationStatus(),e),{}),c=(e,a)=>{o.some(r=>r.name===e?(r.$el.scrollIntoView(a),!0):!1)},u=()=>o.reduce((e,a)=>(e[a.name]=a.formValue.value,e),{}),g=()=>{const e=u();d().then(()=>i("submit",e)).catch(a=>{i("failed",{values:e,errors:a}),n.scrollToError&&a[0].name&&c(a[0].name)})},V=e=>{C(e),g()};return y({props:n}),k({submit:g,validate:d,getValues:u,scrollToField:c,resetValidation:w,getValidationStatus:E}),()=>{var e;return x("form",{class:b(),onSubmit:V},[(e=m.default)==null?void 0:e.call(m)])}}});p=I(B)});export{p as F,G as __tla};
|