Files
filecodebox/fcb-fronted/dist/assets/el-form-item-950b4c25.js
T
2024-07-28 18:40:46 +08:00

13 lines
26 KiB
Python

import{c as $e,g as it,j as we,k as ue,t as at,u as st}from"./el-input-3673f448.js";import{b5 as ot,b as Fe,bj as Be,j as de,aq as ft,G as ce,ae as Te,s as $,c as A,d as K,u as qe,O as te,p as Ce,t as De,x as ze,o as pe,V as Ue,r as H,e as G,f as O,_ as Ge,a3 as ke,k as re,P as Ze,Q as Je,aR as lt,a_ as ut,B as ne,a8 as dt,n as Ke,au as ct,bv as pt,aC as Ee,bs as oe,w as fe,a as vt,h as mt,g as Ae,Z as gt,X as Pe,W as Se,S as je,ap as ht,i as yt,ag as bt}from"./index-e9ecd6a3.js";import{b as wt}from"./_baseClone-15d6718a.js";function ve(){if(!arguments.length)return[];var i=arguments[0];return ot(i)?i:[i]}var Ft=4;function Re(i){return wt(i,Ft)}const qt=Fe({size:{type:String,values:Be},disabled:Boolean}),xt=Fe({...qt,model:Object,rules:{type:de(Object)},labelPosition:{type:String,values:["left","right","top"],default:"right"},requireAsteriskPosition:{type:String,values:["left","right"],default:"left"},labelWidth:{type:[String,Number],default:""},labelSuffix:{type:String,default:""},inline:Boolean,inlineMessage:Boolean,statusIcon:Boolean,showMessage:{type:Boolean,default:!0},validateOnRuleChange:{type:Boolean,default:!0},hideRequiredAsterisk:Boolean,scrollToError:Boolean,scrollIntoViewOptions:{type:[Object,Boolean]}}),Ot={validate:(i,e,t)=>(ft(i)||ce(i))&&Te(e)&&ce(t)};function _t(){const i=$([]),e=A(()=>{if(!i.value.length)return"0";const s=Math.max(...i.value);return s?`${s}px`:""});function t(s){const a=i.value.indexOf(s);return a===-1&&e.value,a}function n(s,a){if(s&&a){const o=t(a);i.value.splice(o,1,s)}else s&&i.value.push(s)}function r(s){const a=t(s);a>-1&&i.value.splice(a,1)}return{autoLabelWidth:e,registerLabelWidth:n,deregisterLabelWidth:r}}const Q=(i,e)=>{const t=ve(e);return t.length>0?i.filter(n=>n.prop&&t.includes(n.prop)):i},Et="ElForm",At=K({name:Et}),Pt=K({...At,props:xt,emits:Ot,setup(i,{expose:e,emit:t}){const n=i,r=[],s=$e(),a=qe("form"),o=A(()=>{const{labelPosition:v,inline:f}=n;return[a.b(),a.m(s.value||"default"),{[a.m(`label-${v}`)]:v,[a.m("inline")]:f}]}),u=v=>{r.push(v)},b=v=>{v.prop&&r.splice(r.indexOf(v),1)},p=(v=[])=>{n.model&&Q(r,v).forEach(f=>f.resetField())},h=(v=[])=>{Q(r,v).forEach(f=>f.clearValidate())},w=A(()=>!!n.model),_=v=>{if(r.length===0)return[];const f=Q(r,v);return f.length?f:[]},E=async v=>y(void 0,v),d=async(v=[])=>{if(!w.value)return!1;const f=_(v);if(f.length===0)return!0;let g={};for(const q of f)try{await q.validate("")}catch(x){g={...g,...x}}return Object.keys(g).length===0?!0:Promise.reject(g)},y=async(v=[],f)=>{const g=!ke(f);try{const q=await d(v);return q===!0&&(f==null||f(q)),q}catch(q){if(q instanceof Error)throw q;const x=q;return n.scrollToError&&l(Object.keys(x)[0]),f==null||f(!1,x),g&&Promise.reject(x)}},l=v=>{var f;const g=Q(r,v)[0];g&&((f=g.$el)==null||f.scrollIntoView(n.scrollIntoViewOptions))};return te(()=>n.rules,()=>{n.validateOnRuleChange&&E().catch(v=>it())},{deep:!0}),Ce(we,De({...ze(n),emit:t,resetFields:p,clearValidate:h,validateField:y,addField:u,removeField:b,..._t()})),e({validate:E,validateField:y,resetFields:p,clearValidate:h,scrollToField:l}),(v,f)=>(pe(),Ue("form",{class:G(O(o))},[H(v.$slots,"default")],2))}});var St=Ge(Pt,[["__file","/home/runner/work/element-plus/element-plus/packages/components/form/src/form.vue"]]);function B(){return B=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},B.apply(this,arguments)}function jt(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,J(i,e)}function me(i){return me=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},me(i)}function J(i,e){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},J(i,e)}function Rt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ee(i,e,t){return Rt()?ee=Reflect.construct.bind():ee=function(r,s,a){var o=[null];o.push.apply(o,s);var u=Function.bind.apply(r,o),b=new u;return a&&J(b,a.prototype),b},ee.apply(null,arguments)}function Nt(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function ge(i){var e=typeof Map=="function"?new Map:void 0;return ge=function(n){if(n===null||!Nt(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(n))return e.get(n);e.set(n,r)}function r(){return ee(n,arguments,me(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),J(r,n)},ge(i)}var Vt=/%[sdj%]/g,Wt=function(){};typeof process<"u"&&process.env;function he(i){if(!i||!i.length)return null;var e={};return i.forEach(function(t){var n=t.field;e[n]=e[n]||[],e[n].push(t)}),e}function N(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];var r=0,s=t.length;if(typeof i=="function")return i.apply(null,t);if(typeof i=="string"){var a=i.replace(Vt,function(o){if(o==="%%")return"%";if(r>=s)return o;switch(o){case"%s":return String(t[r++]);case"%d":return Number(t[r++]);case"%j":try{return JSON.stringify(t[r++])}catch{return"[Circular]"}break;default:return o}});return a}return i}function Mt(i){return i==="string"||i==="url"||i==="hex"||i==="email"||i==="date"||i==="pattern"}function P(i,e){return!!(i==null||e==="array"&&Array.isArray(i)&&!i.length||Mt(e)&&typeof i=="string"&&!i)}function It(i,e,t){var n=[],r=0,s=i.length;function a(o){n.push.apply(n,o||[]),r++,r===s&&t(n)}i.forEach(function(o){e(o,a)})}function Ne(i,e,t){var n=0,r=i.length;function s(a){if(a&&a.length){t(a);return}var o=n;n=n+1,o<r?e(i[o],s):t([])}s([])}function Lt(i){var e=[];return Object.keys(i).forEach(function(t){e.push.apply(e,i[t]||[])}),e}var Ve=function(i){jt(e,i);function e(t,n){var r;return r=i.call(this,"Async Validation Error")||this,r.errors=t,r.fields=n,r}return e}(ge(Error));function $t(i,e,t,n,r){if(e.first){var s=new Promise(function(w,_){var E=function(l){return n(l),l.length?_(new Ve(l,he(l))):w(r)},d=Lt(i);Ne(d,t,E)});return s.catch(function(w){return w}),s}var a=e.firstFields===!0?Object.keys(i):e.firstFields||[],o=Object.keys(i),u=o.length,b=0,p=[],h=new Promise(function(w,_){var E=function(y){if(p.push.apply(p,y),b++,b===u)return n(p),p.length?_(new Ve(p,he(p))):w(r)};o.length||(n(p),w(r)),o.forEach(function(d){var y=i[d];a.indexOf(d)!==-1?Ne(y,t,E):It(y,t,E)})});return h.catch(function(w){return w}),h}function Bt(i){return!!(i&&i.message!==void 0)}function Tt(i,e){for(var t=i,n=0;n<e.length;n++){if(t==null)return t;t=t[e[n]]}return t}function We(i,e){return function(t){var n;return i.fullFields?n=Tt(e,i.fullFields):n=e[t.field||i.fullField],Bt(t)?(t.field=t.field||i.fullField,t.fieldValue=n,t):{message:typeof t=="function"?t():t,fieldValue:n,field:t.field||i.fullField}}}function Me(i,e){if(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];typeof n=="object"&&typeof i[t]=="object"?i[t]=B({},i[t],n):i[t]=n}}return i}var Ye=function(e,t,n,r,s,a){e.required&&(!n.hasOwnProperty(e.field)||P(t,a||e.type))&&r.push(N(s.messages.required,e.fullField))},Ct=function(e,t,n,r,s){(/^\s+$/.test(t)||t==="")&&r.push(N(s.messages.whitespace,e.fullField))},X,Dt=function(){if(X)return X;var i="[a-fA-F\\d:]",e=function(g){return g&&g.includeBoundaries?"(?:(?<=\\s|^)(?="+i+")|(?<="+i+")(?=\\s|$))":""},t="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",n="[a-fA-F\\d]{1,4}",r=(`
(?:
(?:`+n+":){7}(?:"+n+`|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:`+n+":){6}(?:"+t+"|:"+n+`|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
(?:`+n+":){5}(?::"+t+"|(?::"+n+`){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
(?:`+n+":){4}(?:(?::"+n+"){0,1}:"+t+"|(?::"+n+`){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
(?:`+n+":){3}(?:(?::"+n+"){0,2}:"+t+"|(?::"+n+`){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
(?:`+n+":){2}(?:(?::"+n+"){0,3}:"+t+"|(?::"+n+`){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:`+n+":){1}(?:(?::"+n+"){0,4}:"+t+"|(?::"+n+`){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::`+n+"){0,5}:"+t+"|(?::"+n+`){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
`).replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),s=new RegExp("(?:^"+t+"$)|(?:^"+r+"$)"),a=new RegExp("^"+t+"$"),o=new RegExp("^"+r+"$"),u=function(g){return g&&g.exact?s:new RegExp("(?:"+e(g)+t+e(g)+")|(?:"+e(g)+r+e(g)+")","g")};u.v4=function(f){return f&&f.exact?a:new RegExp(""+e(f)+t+e(f),"g")},u.v6=function(f){return f&&f.exact?o:new RegExp(""+e(f)+r+e(f),"g")};var b="(?:(?:[a-z]+:)?//)",p="(?:\\S+(?::\\S*)?@)?",h=u.v4().source,w=u.v6().source,_="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",E="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",d="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",y="(?::\\d{2,5})?",l='(?:[/?#][^\\s"]*)?',v="(?:"+b+"|www\\.)"+p+"(?:localhost|"+h+"|"+w+"|"+_+E+d+")"+y+l;return X=new RegExp("(?:^"+v+"$)","i"),X},Ie={email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},k={integer:function(e){return k.number(e)&&parseInt(e,10)===e},float:function(e){return k.number(e)&&!k.integer(e)},array:function(e){return Array.isArray(e)},regexp:function(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch{return!1}},date:function(e){return typeof e.getTime=="function"&&typeof e.getMonth=="function"&&typeof e.getYear=="function"&&!isNaN(e.getTime())},number:function(e){return isNaN(e)?!1:typeof e=="number"},object:function(e){return typeof e=="object"&&!k.array(e)},method:function(e){return typeof e=="function"},email:function(e){return typeof e=="string"&&e.length<=320&&!!e.match(Ie.email)},url:function(e){return typeof e=="string"&&e.length<=2048&&!!e.match(Dt())},hex:function(e){return typeof e=="string"&&!!e.match(Ie.hex)}},zt=function(e,t,n,r,s){if(e.required&&t===void 0){Ye(e,t,n,r,s);return}var a=["integer","float","array","regexp","object","method","email","number","date","url","hex"],o=e.type;a.indexOf(o)>-1?k[o](t)||r.push(N(s.messages.types[o],e.fullField,e.type)):o&&typeof t!==e.type&&r.push(N(s.messages.types[o],e.fullField,e.type))},Ut=function(e,t,n,r,s){var a=typeof e.len=="number",o=typeof e.min=="number",u=typeof e.max=="number",b=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,p=t,h=null,w=typeof t=="number",_=typeof t=="string",E=Array.isArray(t);if(w?h="number":_?h="string":E&&(h="array"),!h)return!1;E&&(p=t.length),_&&(p=t.replace(b,"_").length),a?p!==e.len&&r.push(N(s.messages[h].len,e.fullField,e.len)):o&&!u&&p<e.min?r.push(N(s.messages[h].min,e.fullField,e.min)):u&&!o&&p>e.max?r.push(N(s.messages[h].max,e.fullField,e.max)):o&&u&&(p<e.min||p>e.max)&&r.push(N(s.messages[h].range,e.fullField,e.min,e.max))},z="enum",Gt=function(e,t,n,r,s){e[z]=Array.isArray(e[z])?e[z]:[],e[z].indexOf(t)===-1&&r.push(N(s.messages[z],e.fullField,e[z].join(", ")))},kt=function(e,t,n,r,s){if(e.pattern){if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(t)||r.push(N(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if(typeof e.pattern=="string"){var a=new RegExp(e.pattern);a.test(t)||r.push(N(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}},m={required:Ye,whitespace:Ct,type:zt,range:Ut,enum:Gt,pattern:kt},Zt=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t,"string")&&!e.required)return n();m.required(e,t,r,a,s,"string"),P(t,"string")||(m.type(e,t,r,a,s),m.range(e,t,r,a,s),m.pattern(e,t,r,a,s),e.whitespace===!0&&m.whitespace(e,t,r,a,s))}n(a)},Jt=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return n();m.required(e,t,r,a,s),t!==void 0&&m.type(e,t,r,a,s)}n(a)},Kt=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(t===""&&(t=void 0),P(t)&&!e.required)return n();m.required(e,t,r,a,s),t!==void 0&&(m.type(e,t,r,a,s),m.range(e,t,r,a,s))}n(a)},Yt=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return n();m.required(e,t,r,a,s),t!==void 0&&m.type(e,t,r,a,s)}n(a)},Qt=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return n();m.required(e,t,r,a,s),P(t)||m.type(e,t,r,a,s)}n(a)},Xt=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return n();m.required(e,t,r,a,s),t!==void 0&&(m.type(e,t,r,a,s),m.range(e,t,r,a,s))}n(a)},Ht=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return n();m.required(e,t,r,a,s),t!==void 0&&(m.type(e,t,r,a,s),m.range(e,t,r,a,s))}n(a)},er=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(t==null&&!e.required)return n();m.required(e,t,r,a,s,"array"),t!=null&&(m.type(e,t,r,a,s),m.range(e,t,r,a,s))}n(a)},tr=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return n();m.required(e,t,r,a,s),t!==void 0&&m.type(e,t,r,a,s)}n(a)},rr="enum",nr=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return n();m.required(e,t,r,a,s),t!==void 0&&m[rr](e,t,r,a,s)}n(a)},ir=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t,"string")&&!e.required)return n();m.required(e,t,r,a,s),P(t,"string")||m.pattern(e,t,r,a,s)}n(a)},ar=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t,"date")&&!e.required)return n();if(m.required(e,t,r,a,s),!P(t,"date")){var u;t instanceof Date?u=t:u=new Date(t),m.type(e,u,r,a,s),u&&m.range(e,u.getTime(),r,a,s)}}n(a)},sr=function(e,t,n,r,s){var a=[],o=Array.isArray(t)?"array":typeof t;m.required(e,t,r,a,s,o),n(a)},le=function(e,t,n,r,s){var a=e.type,o=[],u=e.required||!e.required&&r.hasOwnProperty(e.field);if(u){if(P(t,a)&&!e.required)return n();m.required(e,t,r,o,s,a),P(t,a)||m.type(e,t,r,o,s)}n(o)},or=function(e,t,n,r,s){var a=[],o=e.required||!e.required&&r.hasOwnProperty(e.field);if(o){if(P(t)&&!e.required)return n();m.required(e,t,r,a,s)}n(a)},Z={string:Zt,method:Jt,number:Kt,boolean:Yt,regexp:Qt,integer:Xt,float:Ht,array:er,object:tr,enum:nr,pattern:ir,date:ar,url:le,hex:le,email:le,required:sr,any:or};function ye(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone:function(){var e=JSON.parse(JSON.stringify(this));return e.clone=this.clone,e}}}var be=ye(),Y=function(){function i(t){this.rules=null,this._messages=be,this.define(t)}var e=i.prototype;return e.define=function(n){var r=this;if(!n)throw new Error("Cannot configure a schema with no rules");if(typeof n!="object"||Array.isArray(n))throw new Error("Rules must be an object");this.rules={},Object.keys(n).forEach(function(s){var a=n[s];r.rules[s]=Array.isArray(a)?a:[a]})},e.messages=function(n){return n&&(this._messages=Me(ye(),n)),this._messages},e.validate=function(n,r,s){var a=this;r===void 0&&(r={}),s===void 0&&(s=function(){});var o=n,u=r,b=s;if(typeof u=="function"&&(b=u,u={}),!this.rules||Object.keys(this.rules).length===0)return b&&b(null,o),Promise.resolve(o);function p(d){var y=[],l={};function v(g){if(Array.isArray(g)){var q;y=(q=y).concat.apply(q,g)}else y.push(g)}for(var f=0;f<d.length;f++)v(d[f]);y.length?(l=he(y),b(y,l)):b(null,o)}if(u.messages){var h=this.messages();h===be&&(h=ye()),Me(h,u.messages),u.messages=h}else u.messages=this.messages();var w={},_=u.keys||Object.keys(this.rules);_.forEach(function(d){var y=a.rules[d],l=o[d];y.forEach(function(v){var f=v;typeof f.transform=="function"&&(o===n&&(o=B({},o)),l=o[d]=f.transform(l)),typeof f=="function"?f={validator:f}:f=B({},f),f.validator=a.getValidationMethod(f),f.validator&&(f.field=d,f.fullField=f.fullField||d,f.type=a.getType(f),w[d]=w[d]||[],w[d].push({rule:f,value:l,source:o,field:d}))})});var E={};return $t(w,u,function(d,y){var l=d.rule,v=(l.type==="object"||l.type==="array")&&(typeof l.fields=="object"||typeof l.defaultField=="object");v=v&&(l.required||!l.required&&d.value),l.field=d.field;function f(x,W){return B({},W,{fullField:l.fullField+"."+x,fullFields:l.fullFields?[].concat(l.fullFields,[x]):[x]})}function g(x){x===void 0&&(x=[]);var W=Array.isArray(x)?x:[x];!u.suppressWarning&&W.length&&i.warning("async-validator:",W),W.length&&l.message!==void 0&&(W=[].concat(l.message));var R=W.map(We(l,o));if(u.first&&R.length)return E[l.field]=1,y(R);if(!v)y(R);else{if(l.required&&!d.value)return l.message!==void 0?R=[].concat(l.message).map(We(l,o)):u.error&&(R=[u.error(l,N(u.messages.required,l.field))]),y(R);var L={};l.defaultField&&Object.keys(d.value).map(function(M){L[M]=l.defaultField}),L=B({},L,d.rule.fields);var U={};Object.keys(L).forEach(function(M){var V=L[M],ie=Array.isArray(V)?V:[V];U[M]=ie.map(f.bind(null,M))});var T=new i(U);T.messages(u.messages),d.rule.options&&(d.rule.options.messages=u.messages,d.rule.options.error=u.error),T.validate(d.value,d.rule.options||u,function(M){var V=[];R&&R.length&&V.push.apply(V,R),M&&M.length&&V.push.apply(V,M),y(V.length?V:null)})}}var q;if(l.asyncValidator)q=l.asyncValidator(l,d.value,g,d.source,u);else if(l.validator){try{q=l.validator(l,d.value,g,d.source,u)}catch(x){console.error==null||console.error(x),u.suppressValidatorError||setTimeout(function(){throw x},0),g(x.message)}q===!0?g():q===!1?g(typeof l.message=="function"?l.message(l.fullField||l.field):l.message||(l.fullField||l.field)+" fails"):q instanceof Array?g(q):q instanceof Error&&g(q.message)}q&&q.then&&q.then(function(){return g()},function(x){return g(x)})},function(d){p(d)},o)},e.getType=function(n){if(n.type===void 0&&n.pattern instanceof RegExp&&(n.type="pattern"),typeof n.validator!="function"&&n.type&&!Z.hasOwnProperty(n.type))throw new Error(N("Unknown rule type %s",n.type));return n.type||"string"},e.getValidationMethod=function(n){if(typeof n.validator=="function")return n.validator;var r=Object.keys(n),s=r.indexOf("message");return s!==-1&&r.splice(s,1),r.length===1&&r[0]==="required"?Z.required:Z[this.getType(n)]||void 0},i}();Y.register=function(e,t){if(typeof t!="function")throw new Error("Cannot register a validator by type, validator is not a function");Z[e]=t};Y.warning=Wt;Y.messages=be;Y.validators=Z;const fr=["","error","validating","success"],lr=Fe({label:String,labelWidth:{type:[String,Number],default:""},prop:{type:de([String,Array])},required:{type:Boolean,default:void 0},rules:{type:de([Object,Array])},error:String,validateStatus:{type:String,values:fr},for:String,inlineMessage:{type:[String,Boolean],default:""},showMessage:{type:Boolean,default:!0},size:{type:String,values:Be}}),Le="ElLabelWrap";var ur=K({name:Le,props:{isAutoWidth:Boolean,updateAll:Boolean},setup(i,{slots:e}){const t=re(we,void 0),n=re(ue);n||at(Le,"usage: <el-form-item><label-wrap /></el-form-item>");const r=qe("form"),s=$(),a=$(0),o=()=>{var p;if((p=s.value)!=null&&p.firstElementChild){const h=window.getComputedStyle(s.value.firstElementChild).width;return Math.ceil(Number.parseFloat(h))}else return 0},u=(p="update")=>{Ke(()=>{e.default&&i.isAutoWidth&&(p==="update"?a.value=o():p==="remove"&&(t==null||t.deregisterLabelWidth(a.value)))})},b=()=>u("update");return Ze(()=>{b()}),Je(()=>{u("remove")}),lt(()=>b()),te(a,(p,h)=>{i.updateAll&&(t==null||t.registerLabelWidth(p,h))}),ut(A(()=>{var p,h;return(h=(p=s.value)==null?void 0:p.firstElementChild)!=null?h:null}),b),()=>{var p,h;if(!e)return null;const{isAutoWidth:w}=i;if(w){const _=t==null?void 0:t.autoLabelWidth,E=n==null?void 0:n.hasLabel,d={};if(E&&_&&_!=="auto"){const y=Math.max(0,Number.parseInt(_,10)-a.value),l=t.labelPosition==="left"?"marginRight":"marginLeft";y&&(d[l]=`${y}px`)}return ne("div",{ref:s,class:[r.be("item","label-wrap")],style:d},[(p=e.default)==null?void 0:p.call(e)])}else return ne(dt,{ref:s},[(h=e.default)==null?void 0:h.call(e)])}}});const dr=["role","aria-labelledby"],cr=K({name:"ElFormItem"}),pr=K({...cr,props:lr,setup(i,{expose:e}){const t=i,n=ct(),r=re(we,void 0),s=re(ue,void 0),a=$e(void 0,{formItem:!1}),o=qe("form-item"),u=st().value,b=$([]),p=$(""),h=pt(p,100),w=$(""),_=$();let E,d=!1;const y=A(()=>{if((r==null?void 0:r.labelPosition)==="top")return{};const c=Ee(t.labelWidth||(r==null?void 0:r.labelWidth)||"");return c?{width:c}:{}}),l=A(()=>{if((r==null?void 0:r.labelPosition)==="top"||r!=null&&r.inline)return{};if(!t.label&&!t.labelWidth&&L)return{};const c=Ee(t.labelWidth||(r==null?void 0:r.labelWidth)||"");return!t.label&&!n.label?{marginLeft:c}:{}}),v=A(()=>[o.b(),o.m(a.value),o.is("error",p.value==="error"),o.is("validating",p.value==="validating"),o.is("success",p.value==="success"),o.is("required",ie.value||t.required),o.is("no-asterisk",r==null?void 0:r.hideRequiredAsterisk),(r==null?void 0:r.requireAsteriskPosition)==="right"?"asterisk-right":"asterisk-left",{[o.m("feedback")]:r==null?void 0:r.statusIcon}]),f=A(()=>Te(t.inlineMessage)?t.inlineMessage:(r==null?void 0:r.inlineMessage)||!1),g=A(()=>[o.e("error"),{[o.em("error","inline")]:f.value}]),q=A(()=>t.prop?ce(t.prop)?t.prop:t.prop.join("."):""),x=A(()=>!!(t.label||n.label)),W=A(()=>t.for||b.value.length===1?b.value[0]:void 0),R=A(()=>!W.value&&x.value),L=!!s,U=A(()=>{const c=r==null?void 0:r.model;if(!(!c||!t.prop))return oe(c,t.prop).value}),T=A(()=>{const{required:c}=t,F=[];t.rules&&F.push(...ve(t.rules));const j=r==null?void 0:r.rules;if(j&&t.prop){const S=oe(j,t.prop).value;S&&F.push(...ve(S))}if(c!==void 0){const S=F.map((I,D)=>[I,D]).filter(([I])=>Object.keys(I).includes("required"));if(S.length>0)for(const[I,D]of S)I.required!==c&&(F[D]={...I,required:c});else F.push({required:c})}return F}),M=A(()=>T.value.length>0),V=c=>T.value.filter(j=>!j.trigger||!c?!0:Array.isArray(j.trigger)?j.trigger.includes(c):j.trigger===c).map(({trigger:j,...S})=>S),ie=A(()=>T.value.some(c=>c.required)),Xe=A(()=>{var c;return h.value==="error"&&t.showMessage&&((c=r==null?void 0:r.showMessage)!=null?c:!0)}),xe=A(()=>`${t.label||""}${(r==null?void 0:r.labelSuffix)||""}`),C=c=>{p.value=c},He=c=>{var F,j;const{errors:S,fields:I}=c;(!S||!I)&&console.error(c),C("error"),w.value=S?(j=(F=S==null?void 0:S[0])==null?void 0:F.message)!=null?j:`${t.prop} is required`:"",r==null||r.emit("validate",t.prop,!1,w.value)},et=()=>{C("success"),r==null||r.emit("validate",t.prop,!0,"")},tt=async c=>{const F=q.value;return new Y({[F]:c}).validate({[F]:U.value},{firstFields:!0}).then(()=>(et(),!0)).catch(S=>(He(S),Promise.reject(S)))},Oe=async(c,F)=>{if(d||!t.prop)return!1;const j=ke(F);if(!M.value)return F==null||F(!1),!1;const S=V(c);return S.length===0?(F==null||F(!0),!0):(C("validating"),tt(S).then(()=>(F==null||F(!0),!0)).catch(I=>{const{fields:D}=I;return F==null||F(!1,D),j?!1:Promise.reject(D)}))},ae=()=>{C(""),w.value="",d=!1},_e=async()=>{const c=r==null?void 0:r.model;if(!c||!t.prop)return;const F=oe(c,t.prop);d=!0,F.value=Re(E),await Ke(),ae(),d=!1},rt=c=>{b.value.includes(c)||b.value.push(c)},nt=c=>{b.value=b.value.filter(F=>F!==c)};te(()=>t.error,c=>{w.value=c||"",C(c?"error":"")},{immediate:!0}),te(()=>t.validateStatus,c=>C(c||""));const se=De({...ze(t),$el:_,size:a,validateState:p,labelId:u,inputIds:b,isGroup:R,hasLabel:x,addInputId:rt,removeInputId:nt,resetField:_e,clearValidate:ae,validate:Oe});return Ce(ue,se),Ze(()=>{t.prop&&(r==null||r.addField(se),E=Re(U.value))}),Je(()=>{r==null||r.removeField(se)}),e({size:a,validateMessage:w,validateState:p,validate:Oe,clearValidate:ae,resetField:_e}),(c,F)=>{var j;return pe(),Ue("div",{ref_key:"formItemRef",ref:_,class:G(O(v)),role:O(R)?"group":void 0,"aria-labelledby":O(R)?O(u):void 0},[ne(O(ur),{"is-auto-width":O(y).width==="auto","update-all":((j=O(r))==null?void 0:j.labelWidth)==="auto"},{default:fe(()=>[O(x)?(pe(),vt(mt(O(W)?"label":"div"),{key:0,id:O(u),for:O(W),class:G(O(o).e("label")),style:Ae(O(y))},{default:fe(()=>[H(c.$slots,"label",{label:O(xe)},()=>[gt(Pe(O(xe)),1)])]),_:3},8,["id","for","class","style"])):Se("v-if",!0)]),_:3},8,["is-auto-width","update-all"]),je("div",{class:G(O(o).e("content")),style:Ae(O(l))},[H(c.$slots,"default"),ne(ht,{name:`${O(o).namespace.value}-zoom-in-top`},{default:fe(()=>[O(Xe)?H(c.$slots,"error",{key:0,error:w.value},()=>[je("div",{class:G(O(g))},Pe(w.value),3)]):Se("v-if",!0)]),_:3},8,["name"])],6)],10,dr)}}});var Qe=Ge(pr,[["__file","/home/runner/work/element-plus/element-plus/packages/components/form/src/form-item.vue"]]);const hr=yt(St,{FormItem:Qe}),yr=bt(Qe);export{hr as E,yr as a};