index-legacy-2358b05b.js 1.8 KB

1
  1. System.register(["./index-legacy-a314c7dd.js"],(function(e,t){"use strict";var r,n,a,l,o,i,s,u,d,c;return{setters:[e=>{r=e.c,n=e.d,a=e.aa,l=e.Z,o=e.a,i=e.n,s=e.t,u=e.p,d=e.bw,c=e.k}],execute:function(){const[t,m]=r("form"),g={colon:Boolean,disabled:Boolean,readonly:Boolean,showError:Boolean,labelWidth:i,labelAlign:String,inputAlign:String,scrollToError:Boolean,validateFirst:Boolean,submitOnEnter:s,showErrorMessage:s,errorMessageAlign:String,validateTrigger:{type:[String,Array],default:"onBlur"}};var h=n({name:t,props:g,emits:["submit","failed"],setup(e,{emit:t,slots:r}){const{children:n,linkChildren:i}=a(d),s=e=>e?n.filter((t=>e.includes(t.name))):n,c=t=>{return"string"==typeof t?(e=>{const t=n.find((t=>t.name===e));return t?new Promise(((e,r)=>{t.validate().then((t=>{t?r(t):e()}))})):Promise.reject()})(t):e.validateFirst?(r=t,new Promise(((e,t)=>{const n=[];s(r).reduce(((e,t)=>e.then((()=>{if(!n.length)return t.validate().then((e=>{e&&n.push(e)}))}))),Promise.resolve()).then((()=>{n.length?t(n):e()}))}))):(e=>new Promise(((t,r)=>{const n=s(e);Promise.all(n.map((e=>e.validate()))).then((e=>{(e=e.filter(Boolean)).length?r(e):t()}))})))(t);var r},g=(e,t)=>{n.some((r=>r.name===e&&(r.$el.scrollIntoView(t),!0)))},h=()=>n.reduce(((e,t)=>(void 0!==t.name&&(e[t.name]=t.formValue.value),e)),{}),f=()=>{const r=h();c().then((()=>t("submit",r))).catch((n=>{t("failed",{values:r,errors:n}),e.scrollToError&&n[0].name&&g(n[0].name)}))},v=e=>{u(e),f()};return i({props:e}),l({submit:f,validate:c,getValues:h,scrollToField:g,resetValidation:e=>{"string"==typeof e&&(e=[e]),s(e).forEach((e=>{e.resetValidation()}))},getValidationStatus:()=>n.reduce(((e,t)=>(e[t.name]=t.getValidationStatus(),e)),{})}),()=>{var e;return o("form",{class:m(),onSubmit:v},[null==(e=r.default)?void 0:e.call(r)])}}});e("F",c(h))}}}));