k5web/assets/index.190f67fb.js
2024-07-24 11:01:29 +08:00

26 lines
14 KiB
JavaScript

import{i as Ce,_ as A,r as b,s as Fe,v as De}from"./form-model.0a7b7414.js";import{d as qe,X as We,Y as xe,Z as He,b as Q,f as j,l as Ie,$ as se,a0 as Ke,a1 as we,i as Le,k as Oe,m as Ue,a2 as z,n as Me,a3 as Ge,a4 as Xe,w as ke}from"./index.1c489121.js";import{d as Pe,i as Je,c as p,f as V,t as Ee,r as Ae,o as Ye,b as Ze,w as je,aI as M,p as _e,n as ze}from"./arco.c29bba08.js";import{u as Re,C as Qe,F as Ne,V as B,a as er}from"./index.2541b16e.js";/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var rr={for:{type:String,default:""},help:{type:[String,Function]},label:{type:[String,Function],default:""},labelAlign:{type:String,validator:function(e){return e?["left","right","top"].includes(e):!0}},labelWidth:{type:[String,Number]},name:{type:String,default:""},requiredMark:{type:Boolean,default:void 0},rules:{type:Array},showErrorMessage:{type:Boolean,default:void 0},status:{type:String,default:""},statusIcon:{type:[Boolean,Function],default:void 0},successBorder:Boolean,tips:{type:[String,Function]}};/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function ar(c,e){return c.replace(/\${(.*?)}/g,function(f,v){return e[v.trim()]||""})}/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function Ve(c,e){var f=Object.keys(c);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(c);e&&(v=v.filter(function(_){return Object.getOwnPropertyDescriptor(c,_).enumerable})),f.push.apply(f,v)}return f}function Se(c){for(var e=1;e<arguments.length;e++){var f=arguments[e]!=null?arguments[e]:{};e%2?Ve(Object(f),!0).forEach(function(v){j(c,v,f[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(f)):Ve(Object(f)).forEach(function(v){Object.defineProperty(c,v,Object.getOwnPropertyDescriptor(f,v))})}return c}function Te(c,e){return e?"".concat(c,"__").concat(e).replace(/(\[|\]\.)/g,"_"):""}var tr=Pe({name:"TFormItem",props:Se({},rr),setup:function(e,f){var v=f.slots,_=Le(),y=Re(),oe=qe("form"),D=oe.globalConfig,$=We({CheckCircleFilledIcon:xe,CloseCircleFilledIcon:Qe,ErrorCircleFilledIcon:He}),C=$.CheckCircleFilledIcon,ce=$.CloseCircleFilledIcon,ve=$.ErrorCircleFilledIcon,r=Je(Ne,void 0),ee=Q(),re=Q("form-item"),fe=p(function(){var t,n,a=(t=(n=e.requiredMark)!==null&&n!==void 0?n:r==null?void 0:r.requiredMark)!==null&&t!==void 0?t:D.value.requiredMark,d=g.value.filter(function(o){return o.required}).length>0;return a!=null?a:d}),ae=p(function(){return v.label||e.label}),de=p(function(){return!!(r!=null&&r.colon&&ae.value)}),q=Q("form__label"),W=p(function(){return Ce(e.labelAlign)?r==null?void 0:r.labelAlign:e.labelAlign}),w=p(function(){return Ce(e.labelWidth)?r==null?void 0:r.labelWidth:e.labelWidth}),me=p(function(){return[y.value.label,j(j(j(j(j({},"".concat(q.value,"--required"),fe.value),"".concat(q.value,"--colon"),de.value),"".concat(q.value,"--top"),ae.value&&(W.value==="top"||!w.value)),"".concat(q.value,"--left"),W.value==="left"&&w.value),"".concat(q.value,"--right"),W.value==="right"&&w.value)]}),ge=function(){if(Number(w.value)!==0){var n={};return w.value&&W.value!=="top"&&(Ie(w.value)?n={width:"".concat(w.value,"px")}:n={width:w.value}),M("div",{class:me.value,style:n},[M("label",{for:e.for||null},[_("label")])])}},J=function(){var n=function(h){return M("span",{class:y.value.status},[M(h,null,null)])},a=L.value;if(N.value===B.SUCCESS)return n(C);if(a!=null&&a[0]){var d=a[0].type||"error",o={error:ce,warning:ve}[d]||C;return n(o)}return null},pe=function(){var n=e.statusIcon;if(n!==!1){var a=_("statusIcon",{defaultNode:J()});if(a)return M("span",{class:y.value.status},[a]);if(a!==!1&&(a=r==null?void 0:r.renderContent("statusIcon",{defaultNode:J(),params:e}),a))return a}},H=p(function(){if(!I.value)return"";if(N.value===B.SUCCESS)return e.successBorder?[y.value.success,y.value.successBorder].join(" "):y.value.success;if(!!L.value.length){var t=L.value[0].type||"error";return t==="error"?y.value.error:y.value.warning}}),te=p(function(){return[y.value.controls,H.value]}),ne=p(function(){var t={};return w.value&&W.value!=="top"&&(Ie(w.value)?t={marginLeft:"".concat(w.value,"px")}:t={marginLeft:w.value}),t}),L=V([]),R=V([]),N=V(B.TO_BE_VALIDATED),Y=V(!1),T=V(!1),Z=function(){T.value=!1,L.value=[],R.value=[],N.value=B.TO_BE_VALIDATED},be=function(){var n=Object.prototype.toString.call(se(r==null?void 0:r.data,e.name)),a;return n==="[object String]"&&(a=""),n==="[object Array]"&&(a=[]),n==="[object Object]"&&(a={}),a},ye=function(){var t=A(b.mark(function n(){var a,d=arguments;return b.wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(a=d.length>0&&d[0]!==void 0?d[0]:r==null?void 0:r.resetType,e.name){O.next=3;break}return O.abrupt("return");case 3:return a==="empty"?Fe(r==null?void 0:r.data,e.name,be()):a==="initial"&&Fe(r==null?void 0:r.data,e.name,F.value),O.next=6,ze();case 6:Y.value?T.value=!0:Z();case 7:case"end":return O.stop()}},n)}));return function(){return t.apply(this,arguments)}}(),le=p(function(){var t;return(t=r==null?void 0:r.errorMessage)!==null&&t!==void 0?t:D.value.errorMessage}),g=p(function(){var t;if((t=e.rules)!==null&&t!==void 0&&t.length)return e.rules;if(!e.name)return[];var n="".concat(e.name).lastIndexOf(".")||-1,a="".concat(e.name).slice(n+1);return se(r==null?void 0:r.rules,e.name)||se(r==null?void 0:r.rules,a)||[]}),l=function(){var t=A(b.mark(function n(a){var d,o;return b.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(o={successList:[],errorList:[],rules:[],resultList:[],allowSetValue:!1},o.rules=a==="all"?g.value:g.value.filter(function(m){return(m.trigger||"change")===a}),!(g.value.length&&!((d=o.rules)!==null&&d!==void 0&&d.length))){h.next=4;break}return h.abrupt("return",o);case 4:return o.allowSetValue=!0,h.next=7,De(S.value,o.rules);case 7:return o.resultList=h.sent,o.errorList=o.resultList.filter(function(m){return m.result!==!0}).map(function(m){return Object.keys(m).forEach(function(G){if(!m.message&&le.value[G]){var ie=Ue(e.label)?e.label:e.name;m.message=ar(le.value[G],{name:ie,validate:m[G]})}}),m}),o.successList=o.resultList.filter(function(m){return m.result===!0&&m.message&&m.type==="success"}),h.abrupt("return",o);case 11:case"end":return h.stop()}},n)}));return function(a){return t.apply(this,arguments)}}(),u=function(){var t=A(b.mark(function n(a,d){var o,O,h,m,G,ie;return b.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return Y.value=!0,E.value=d,X.next=4,l(a);case 4:return o=X.sent,O=o.successList,h=o.errorList,m=o.rules,G=o.resultList,ie=o.allowSetValue,ie&&(R.value=O,L.value=h),m.length&&(N.value=h.length?B.FAIL:B.SUCCESS),T.value&&Z(),Y.value=!1,X.abrupt("return",j({},e.name,h.length===0?!0:G));case 15:case"end":return X.stop()}},n)}));return function(a,d){return t.apply(this,arguments)}}(),s=function(){var t=A(b.mark(function n(a){var d,o,O;return b.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,l(a);case 2:return d=m.sent,o=d.errorList,O=d.resultList,m.abrupt("return",j({},e.name,o.length===0?!0:O));case 6:case"end":return m.stop()}},n)}));return function(a){return t.apply(this,arguments)}}(),i=function(n){!n&&!Oe(n)||(n.length===0&&(L.value=[],N.value=B.SUCCESS),L.value=n.map(function(a){return Se(Se({},a),{},{result:!1})}),N.value=B.FAIL)},S=p(function(){return(r==null?void 0:r.data)&&se(r==null?void 0:r.data,e.name)}),F=V(void 0),k=Ee(e),x=k.name,K=Ae({name:x,resetHandler:Z,resetField:ye,validate:u,validateOnly:s,setValidateMessage:i});Ye(function(){F.value=Ke(S.value),r==null||r.children.push(K)}),Ze(function(){r&&(r.children=r==null?void 0:r.children.filter(function(t){return t!==K}))}),je(S,A(b.mark(function t(){return b.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,u("change");case 2:case"end":return a.stop()}},t)})),{deep:!0}),je(function(){return[e.name,JSON.stringify(e.rules)].join(",")},function(){u("change")});var E=V(void 0),I=p(function(){return we(E.value)?E.value:we(e.showErrorMessage)?e.showErrorMessage:r==null?void 0:r.showErrorMessage}),ue=p(function(){return[y.value.formItem,Te(re.value,e.name),j(j({},y.value.formItemWithHelp,he.value),y.value.formItemWithExtra,P.value)]}),he=p(function(){var t=_("help");return t?M("div",{class:y.value.help},[t]):null}),P=p(function(){var t,n=function(o){return M("div",{class:y.value.extra,title:o},[o])},a=L.value;return I.value&&a!==null&&a!==void 0&&(t=a[0])!==null&&t!==void 0&&t.message?n(a[0].message):R.value.length?n(R.value[0].message):null}),U=p(function(){var t=_("tips");if(!t)return null;var n=["".concat(re.value,"-tips"),"".concat(ee.value,"-tips"),"".concat(ee.value,"-is-").concat(e.status||"default")];return M("div",{class:n},[t])}),Be=function(){var t=A(b.mark(function n(){return b.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,u("blur");case 2:case"end":return d.stop()}},n)}));return function(){return t.apply(this,arguments)}}();return _e(er,{handleBlur:Be}),function(){return M("div",{class:ue.value},[ge(),M("div",{class:te.value,style:ne.value},[M("div",{class:y.value.controlsContent},[_("default"),pe()]),he.value,U.value,P.value])])}}});/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var nr={colon:Boolean,data:{type:Object,default:function(){return{}}},disabled:{type:Boolean,default:void 0},errorMessage:{type:Object},formControlledComponents:{type:Array},labelAlign:{type:String,default:"right",validator:function(e){return e?["left","right","top"].includes(e):!0}},labelWidth:{type:[String,Number],default:"100px"},layout:{type:String,default:"vertical",validator:function(e){return e?["vertical","inline"].includes(e):!0}},preventSubmitDefault:{type:Boolean,default:!0},requiredMark:{type:Boolean,default:void 0},resetType:{type:String,default:"empty",validator:function(e){return e?["empty","initial"].includes(e):!0}},rules:{type:Object},scrollToFirstError:{type:String,validator:function(e){return e?["","smooth","auto"].includes(e):!0}},showErrorMessage:{type:Boolean,default:!0},statusIcon:{type:[Boolean,Function],default:void 0},submitWithWarningMessage:Boolean,onReset:Function,onSubmit:Function,onValidate:Function};/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function $e(c,e){var f=Object.keys(c);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(c);e&&(v=v.filter(function(_){return Object.getOwnPropertyDescriptor(c,_).enumerable})),f.push.apply(f,v)}return f}function lr(c){for(var e=1;e<arguments.length;e++){var f=arguments[e]!=null?arguments[e]:{};e%2?$e(Object(f),!0).forEach(function(v){j(c,v,f[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(f)):$e(Object(f)).forEach(function(v){Object.defineProperty(c,v,Object.getOwnPropertyDescriptor(f,v))})}return c}var ur=Pe({name:"TForm",props:lr({},nr),setup:function(e,f){var v=f.expose,_=Le(),y=Ee(e),oe=y.disabled;_e("formDisabled",{disabled:oe});var D=V(null),$=V([]),C=Ee(e),ce=C.showErrorMessage,ve=C.labelWidth,r=C.labelAlign,ee=C.data,re=C.colon,fe=C.requiredMark,ae=C.rules,de=C.errorMessage,q=C.resetType;_e(Ne,Ae({showErrorMessage:ce,labelWidth:ve,labelAlign:r,data:ee,colon:re,requiredMark:fe,rules:ae,errorMessage:de,resetType:q,children:$,renderContent:_}));var W=Q("form"),w=Re(),me=p(function(){return[w.value.form,j({},"".concat(W.value,"-inline"),e.layout==="inline")]}),ge=Q("form-item"),J=function(l){if(we(l))return"";var u=Object.keys(l),s=Me(u,1),i=s[0];if(e.scrollToFirstError){var S=Te(ge.value,i);pe(S)}var F=l[i];return Oe(F)?F.filter(function(k){return!k.result})[0].message:""},pe=function(l){var u=D.value.getElementsByClassName(l),s=Me(u,1),i=s[0],S=e.scrollToFirstError;S&&i&&i.scrollIntoView({behavior:S})},H=function(l,u){return!u||!Oe(u)?!0:u.indexOf("".concat(l))!==-1},te=function(l){var u=l.reduce(function(s,i){return Object.assign(s||{},i)},{});return Object.keys(u).forEach(function(s){u[s]===!0&&delete u[s]}),Xe(u)?!0:u},ne=function(){var g=A(b.mark(function l(u){var s,i,S,F,k,x,K,E,I,ue;return b.wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return i=u||{},S=i.fields,F=i.trigger,k=F===void 0?"all":F,x=i.showErrorMessage,K=$.value.filter(function(U){return z(U.validate)&&H(String(U.name),S)}).map(function(U){return U.validate(k,x)}),P.next=4,Promise.all(K);case 4:return E=P.sent,I=te(E),ue=J(I),(s=e.onValidate)===null||s===void 0||s.call(e,{validateResult:I,firstError:ue}),P.abrupt("return",I);case 9:case"end":return P.stop()}},l)}));return function(u){return g.apply(this,arguments)}}(),L=function(){var g=A(b.mark(function l(u){var s,i,S,F,k,x;return b.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return s=u||{},i=s.fields,S=s.trigger,F=S===void 0?"all":S,k=$.value.filter(function(I){return z(I.validateOnly)&&H(String(I.name),i)}).map(function(I){return I.validateOnly(F)}),E.next=4,Promise.all(k);case 4:return x=E.sent,E.abrupt("return",te(x));case 6:case"end":return E.stop()}},l)}));return function(u){return g.apply(this,arguments)}}(),R=V(),N=function(l){e.preventSubmitDefault&&l&&(l.preventDefault(),l.stopPropagation()),ne(R.value).then(function(u){var s;(s=e.onSubmit)===null||s===void 0||s.call(e,{validateResult:u,firstError:J(u),e:l})}),R.value=void 0},Y=function(){var g=A(b.mark(function l(u){return b.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:R.value=u,Ge(D.value);case 2:case"end":return i.stop()}},l)}));return function(u){return g.apply(this,arguments)}}(),T=V(),Z=function(l){var u;e.preventSubmitDefault&&l&&(l.preventDefault(),l.stopPropagation()),$.value.filter(function(s){var i;return z(s.resetField)&&H(String(s.name),(i=T.value)===null||i===void 0?void 0:i.fields)}).forEach(function(s){var i;return s.resetField((i=T.value)===null||i===void 0?void 0:i.type)}),T.value=void 0,(u=e.onReset)===null||u===void 0||u.call(e,{e:l})},be=function(l){T.value=l,D.value.reset()},ye=function(l){$.value.forEach(function(u){z(u.resetHandler)&&H(String(u.name),l)&&u.resetHandler()})},le=function(l){var u=Object.keys(l);if(!!u.length){var s=$.value.filter(function(i){return z(i.setValidateMessage)&&u.includes("".concat(i.name))}).map(function(i){return i.setValidateMessage(l[i.name])});Promise.all(s)}};return v({validate:ne,submit:Y,reset:be,clearValidate:ye,setValidateMessage:le,validateOnly:L}),function(){return M("form",{ref:D,class:me.value,onSubmit:function(l){return N(l)},onReset:function(l){return Z(l)}},[_("default")])}}});/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var fr=ke(ur),dr=ke(tr);export{dr as F,fr as a};