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.
6 lines
2.4 KiB
6 lines
2.4 KiB
import{c as w,d as M,b as P,u as S,f as _}from"./light-Cua7cqmF.js";import{c as j}from"./context-KbjOeZY_.js";import{f as k}from"./light-CUlEsFk3.js";import{k as I}from"./keysOf-HiGXOwLp.js";import{d as O,s as B,P as x,G as L}from"./index-bVOhw2NF.js";const R=w("form",[M("inline",`
|
|
width: 100%;
|
|
display: inline-flex;
|
|
align-items: flex-start;
|
|
align-content: space-around;
|
|
`,[w("form-item",{width:"auto",marginRight:"18px"},[P("&:last-child",{marginRight:0})])])]),F=j("n-form"),V=j("n-form-item-insts");var E=function(t,m,o,i){function h(r){return r instanceof o?r:new o(function(f){f(r)})}return new(o||(o=Promise))(function(r,f){function y(n){try{e(i.next(n))}catch(d){f(d)}}function a(n){try{e(i.throw(n))}catch(d){f(d)}}function e(n){n.done?r(n.value):h(n.value).then(y,a)}e((i=i.apply(t,m||[])).next())})};const K=Object.assign(Object.assign({},_.props),{inline:Boolean,labelWidth:[Number,String],labelAlign:String,labelPlacement:{type:String,default:"top"},model:{type:Object,default:()=>{}},rules:Object,disabled:Boolean,size:String,showRequireMark:{type:Boolean,default:void 0},requireMarkPlacement:String,showFeedback:{type:Boolean,default:!0},onSubmit:{type:Function,default:t=>{t.preventDefault()}},showLabel:{type:Boolean,default:void 0},validateMessages:Object}),D=O({name:"Form",props:K,setup(t){const{mergedClsPrefixRef:m}=S(t);_("Form","-form",R,k,t,m);const o={},i=B(void 0),h=a=>{const e=i.value;(e===void 0||a>=e)&&(i.value=a)};function r(a){return E(this,arguments,void 0,function*(e,n=()=>!0){return yield new Promise((d,C)=>{const v=[];for(const u of I(o)){const p=o[u];for(const s of p)s.path&&v.push(s.internalValidate(null,n))}Promise.all(v).then(u=>{const p=u.some(l=>!l.valid),s=[],c=[];u.forEach(l=>{var g,b;!((g=l.errors)===null||g===void 0)&&g.length&&s.push(l.errors),!((b=l.warnings)===null||b===void 0)&&b.length&&c.push(l.warnings)}),e&&e(s.length?s:void 0,{warnings:c.length?c:void 0}),p?C(s.length?s:void 0):d({warnings:c.length?c:void 0})})})})}function f(){for(const a of I(o)){const e=o[a];for(const n of e)n.restoreValidation()}}return x(F,{props:t,maxChildLabelWidthRef:i,deriveMaxChildLabelWidth:h}),x(V,{formItems:o}),Object.assign({validate:r,restoreValidation:f},{mergedClsPrefix:m})},render(){const{mergedClsPrefix:t}=this;return L("form",{class:[`${t}-form`,this.inline&&`${t}-form--inline`],onSubmit:this.onSubmit},this.$slots)}});export{D as _,V as a,F as f};
|