2024-06-07 16:46:40 +00:00
|
|
|
import{u as re,b as qe,c as h,d as We,i as Ie,_ as Me}from"./useConfig.7e9a03f4.js";import{d as Ee,c as y,aI as C,i as He,f as P,t as Oe,r as Te,o as Ke,b as Ue,w as ke,p as we,n as ze}from"./arco.446db797.js";import{G as Ge,A as je,z as Ne,B as Fe,H as Je,J as Ce,K as Xe,M as ie,F as Ze}from"./index.25cd9d44.js";import{u as Qe,i as _e}from"./index.79f252de.js";import{u as Re,F as Be,i as Pe,V as q,_ as R,a as Ye,C as er,r as b,s as $e,v as rr}from"./form-model.0db7876d.js";import{g as de,r as tr}from"./index.80de110f.js";import{a as ar,C as nr,E as lr}from"./dialog.604d372a.js";/**
|
2024-05-24 14:39:15 +00:00
|
|
|
* tdesign v1.9.4
|
|
|
|
* (c) 2024 tdesign
|
|
|
|
* @license MIT
|
|
|
|
*/var ur={content:{type:[String,Function]},default:{type:[String,Function]},disabled:{type:Boolean,default:void 0},download:{type:[String,Boolean]},hover:{type:String,default:"underline",validator:function(e){return e?["color","underline"].includes(e):!0}},href:{type:String,default:""},prefixIcon:{type:Function},size:{type:String,default:"medium",validator:function(e){return e?["small","medium","large"].includes(e):!0}},suffixIcon:{type:Function},target:{type:String,default:""},theme:{type:String,default:"default",validator:function(e){return e?["default","primary","danger","warning","success"].includes(e):!0}},underline:Boolean,onClick:Function};/**
|
|
|
|
* tdesign v1.9.4
|
|
|
|
* (c) 2024 tdesign
|
|
|
|
* @license MIT
|
2024-06-07 16:46:40 +00:00
|
|
|
*/function Le(l,e){var o=Object.keys(l);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(l);e&&(s=s.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),o.push.apply(o,s)}return o}function ir(l){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?Le(Object(o),!0).forEach(function(s){h(l,s,o[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):Le(Object(o)).forEach(function(s){Object.defineProperty(l,s,Object.getOwnPropertyDescriptor(o,s))})}return l}var sr=Ee({name:"TLink",props:ir({},ur),emits:["click"],setup:function(e,o){var s=o.emit,S=Ge(),p=je(),V=re("link"),$=qe(),I=$.STATUS,_=$.SIZE,te=Ne("classPrefix"),ae=te.classPrefix,r=Qe(),U=y(function(){return["".concat(V.value),"".concat(V.value,"--theme-").concat(e.theme),h(h(h(h({},_.value[e.size],e.size!=="medium"),I.value.disabled,r.value),"".concat(ae.value,"-is-underline"),e.underline),"".concat(V.value,"--hover-").concat(e.hover),!r.value)]}),z=function(A){r.value||s("click",A)};return function(){var G=S("default","content"),A=p("prefixIcon"),J=p("suffixIcon");return C("a",{class:We(U.value),href:r.value||!e.href?void 0:e.href,target:e.target?e.target:void 0,download:e.download?e.download:void 0,onClick:z},[A?C("span",{class:"".concat(V.value,"__prefix-icon")},[A]):null,G,J?C("span",{class:"".concat(V.value,"__suffix-icon")},[J]):null])}}});/**
|
2024-05-24 14:39:15 +00:00
|
|
|
* tdesign v1.9.4
|
|
|
|
* (c) 2024 tdesign
|
|
|
|
* @license MIT
|
2024-06-07 16:46:40 +00:00
|
|
|
*/var Cr=Fe(sr);/**
|
2024-05-24 14:39:15 +00:00
|
|
|
* tdesign v1.9.4
|
|
|
|
* (c) 2024 tdesign
|
|
|
|
* @license MIT
|
|
|
|
*/var or={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 cr(l,e){return l.replace(/\${(.*?)}/g,function(o,s){return e[s.trim()]||""})}/**
|
|
|
|
* tdesign v1.9.4
|
|
|
|
* (c) 2024 tdesign
|
|
|
|
* @license MIT
|
2024-06-07 16:46:40 +00:00
|
|
|
*/function Ve(l,e){var o=Object.keys(l);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(l);e&&(s=s.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),o.push.apply(o,s)}return o}function Se(l){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?Ve(Object(o),!0).forEach(function(s){h(l,s,o[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):Ve(Object(o)).forEach(function(s){Object.defineProperty(l,s,Object.getOwnPropertyDescriptor(o,s))})}return l}function De(l,e){return e?"".concat(l,"__").concat(e).replace(/(\[|\]\.)/g,"_"):""}var vr=Ee({name:"TFormItem",props:Se({},or),setup:function(e,o){var s=o.slots,S=je(),p=Re(),V=Ne("form"),$=V.globalConfig,I=ar({CheckCircleFilledIcon:nr,CloseCircleFilledIcon:er,ErrorCircleFilledIcon:lr}),_=I.CheckCircleFilledIcon,te=I.CloseCircleFilledIcon,ae=I.ErrorCircleFilledIcon,r=He(Be,void 0),U=re(),z=re("form-item"),G=y(function(){var a,n,t=(a=(n=e.requiredMark)!==null&&n!==void 0?n:r==null?void 0:r.requiredMark)!==null&&a!==void 0?a:$.value.requiredMark,d=g.value.filter(function(f){return f.required}).length>0;return t!=null?t:d}),A=y(function(){return s.label||e.label}),J=y(function(){return!!(r!=null&&r.colon&&A.value)}),W=re("form__label"),H=y(function(){return Pe(e.labelAlign)?r==null?void 0:r.labelAlign:e.labelAlign}),E=y(function(){return Pe(e.labelWidth)?r==null?void 0:r.labelWidth:e.labelWidth}),me=y(function(){return[p.value.label,h(h(h(h(h({},"".concat(W.value,"--required"),G.value),"".concat(W.value,"--colon"),J.value),"".concat(W.value,"--top"),A.value&&(H.value==="top"||!E.value)),"".concat(W.value,"--left"),H.value==="left"&&E.value),"".concat(W.value,"--right"),H.value==="right"&&E.value)]}),ge=function(){if(Number(E.value)!==0){var n={};return E.value&&H.value!=="top"&&(Ie(E.value)?n={width:"".concat(E.value,"px")}:n={width:E.value}),C("div",{class:me.value,style:n},[C("label",{for:e.for||null},[S("label")])])}},ne=function(){var n=function(O){return C("span",{class:p.value.status},[C(O,null,null)])},t=L.value;if(D.value===q.SUCCESS)return n(_);if(t!=null&&t[0]){var d=t[0].type||"error",f={error:te,warning:ae}[d]||_;return n(f)}return null},pe=function(){var n=e.statusIcon;if(n!==!1){var t=S("statusIcon",{defaultNode:ne()});if(t)return C("span",{class:p.value.status},[t]);if(t!==!1&&(t=r==null?void 0:r.renderContent("statusIcon",{defaultNode:ne(),params:e}),t))return t}},X=y(function(){if(!k.value)return"";if(D.value===q.SUCCESS)return e.successBorder?[p.value.success,p.value.successBorder].join(" "):p.value.success;if(!!L.value.length){var a=L.value[0].type||"error";return a==="error"?p.value.error:p.value.warning}}),se=y(function(){return[p.value.controls,X.value]}),oe=y(function(){var a={};return E.value&&H.value!=="top"&&(Ie(E.value)?a={marginLeft:"".concat(E.value,"px")}:a={marginLeft:E.value}),a}),L=P([]),B=P([]),D=P(q.TO_BE_VALIDATED),le=P(!1),x=P(!1),ue=function(){x.value=!1,L.value=[],B.value=[],D.value=q.TO_BE_VALIDATED},ye=function(){var n=Object.prototype.toString.call(de(r==null?void 0:r.data,e.name)),t;return n==="[object String]"&&(t=""),n==="[object Array]"&&(t=[]),n==="[object Object]"&&(t={}),t},be=function(){var a=R(b.mark(function n(){var t,d=arguments;return b.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(t=d.length>0&&d[0]!==void 0?d[0]:r==null?void 0:r.resetType,e.name){j.next=3;break}return j.abrupt("return");case 3:return t==="empty"?$e(r==null?void 0:r.data,e.name,ye()):t==="initial"&&$e(r==null?void 0:r.data,e.name,M.value),j.next=6,ze();case 6:le.value?x.value=!0:ue();case 7:case"end":return j.stop()}},n)}));return function(){return a.apply(this,arguments)}}(),ce=y(function(){var a;return(a=r==null?void 0:r.errorMessage)!==null&&a!==void 0?a:$.value.errorMessage}),g=y(function(){var a;if((a=e.rules)!==null&&a!==void 0&&a.length)return e.rules;if(!e.name)return[];var n="".concat(e.name).lastIndexOf(".")||-1,t="".concat(e.name).slice(n+1);return de(r==null?void 0:r.rules,e.name)||de(r==null?void 0:r.rules,t)||[]})
|
2024-05-24 14:39:15 +00:00
|
|
|
* tdesign v1.9.4
|
|
|
|
* (c) 2024 tdesign
|
|
|
|
* @license MIT
|
|
|
|
*/var fr={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
|
2024-06-07 16:46:40 +00:00
|
|
|
*/function Ae(l,e){var o=Object.keys(l);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(l);e&&(s=s.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),o.push.apply(o,s)}return o}function dr(l){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?Ae(Object(o),!0).forEach(function(s){h(l,s,o[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):Ae(Object(o)).forEach(function(s){Object.defineProperty(l,s,Object.getOwnPropertyDescriptor(o,s))})}return l}var mr=Ee({name:"TForm",props:dr({},fr),setup:function(e,o){var s=o.expose,S=je(),p=Oe(e),V=p.disabled;we("formDisabled",{disabled:V});var $=P(null),I=P([]),_=Oe(e),te=_.showErrorMessage,ae=_.labelWidth,r=_.labelAlign,U=_.data,z=_.colon,G=_.requiredMark,A=_.rules,J=_.errorMessage,W=_.resetType;we(Be,Te({showErrorMessage:te,labelWidth:ae,labelAlign:r,data:U,colon:z,requiredMark:G,rules:A,errorMessage:J,resetType:W,children:I,renderContent:S}));var H=re("form"),E=Re(),me=y(function(){return[E.value.form,h({},"".concat(H.value,"-inline"),e.layout==="inline")]}),ge=re("form-item"),ne=function(u){if(_e(u))return"";var i=Object.keys(u),v=Me(i,1),c=v[0];if(e.scrollToFirstError){var w=De(ge.value,c);pe(w)}var M=u[c];return Ce(M)?M.filter(function(T){return!T.result})[0].message:""},pe=function(u){var i=$.value.getElementsByClassName(u),v=Me(i,1),c=v[0],w=e.scrollToFirstError;w&&c&&c.scrollIntoView({behavior:w})},X=function(u,i){return!i||!Ce(i)?!0:i.indexOf("".concat(u))!==-1},se=function(u){var i=u.reduce(function(v,c){return Object.assign(v||{},c)},{});return Object.keys(i).forEach(function(v){i[v]===!0&&delete i[v]}),Ze(i)?!0:i},oe=function(){var g=R(b.mark(function u(i){var v,c,w,M,T,K,Z,F,k,ve;return b.wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return c=i||{},w=c.fields,M=c.trigger,T=M===void 0?"all":M,K=c.showErrorMessage,Z=I.value.filter(function(Q){return ie(Q.validate)&&X(String(Q.name),w)}).map(function(Q){return Q.validate(T,K)}),N.next=4,Promise.all(Z);case 4:return F=N.sent,k=se(F),ve=ne(k),(v=e.onValidate)===null||v===void 0||v.call(e,{validateResult:k,firstError:ve}),N.abrupt("return",k);case 9:case"end":return N.stop()}},u)}));return function(i){return g.apply(this,arguments)}}(),L=function(){var g=R(b.mark(function u(i){var v,c,w,M,T,K;return b.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return v=i||{},c=v.fields,w=v.trigger,M=w===void 0?"all":w,T=I.value.filter(function(k){return ie(k.validateOnly)&&X(String(k.name),c)}).map(function(k){return k.validateOnly(M)}),F.next=4,Promise.all(T);case 4:return K=F.sent,F.abrupt("return",se(K));case 6:case"end":return F.stop()}},u)}));return function(i){return g.apply(this,arguments)}}(),B=P(),D=function(u){e.preventSubmitDefault&&u&&(u.preventDefault(),u.stopPropagation()),oe(B.value).then(function(i){var v;(v=e.onSubmit)===null||v===void 0||v.call(e,{validateResult:i,firstError:ne(i),e:u})}),B.value=void 0},le=function(){var g=R(b.mark(function u(i){return b.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:B.value=i,tr($.value);case 2:case"end":return c.stop()}},u)}));return function(i){return g.apply(this,arguments)}}(),x=P(),ue=function(u){var i;e.preventSubmitDefault&&u&&(u.preventDefault(),u.stopPropagation()),I.value.filter(function(v){var c;return ie(v.resetField)&&X(String(v.name),(c=x.value)===null||c===void 0?void 0:c.fields)}).forEach(function(v){var c;return v.resetField((c=x.value)===null||c===void 0?void 0:c.type)}),x.value=void 0,(i=e.onReset)===null||i===void 0||i.call(e,{e:u})},ye=function(u){x.value=u,$.value.reset()},be=function(u){I.value.forEach(function(i){ie(i.resetHandler)&&X(String(i.name),u)&&i.resetHandler()})},ce=function(u){var i=Object.keys(u);if(!!i.length){var v=I.value.filter(function(c){return ie(c.setValidateMessage)&&i.includes("".concat(c.name))}).map(function(c){return c.setValidateMessage(u[c.name])});Promise.all(v)}};return s({validate:oe,submit:le,reset:ye,clearValidate:be,setValidateMessage:ce,validateOnly:L}),function(){return C("form",{ref
|
2024-05-24 14:39:15 +00:00
|
|
|
* tdesign v1.9.4
|
|
|
|
* (c) 2024 tdesign
|
|
|
|
* @license MIT
|
2024-06-07 16:46:40 +00:00
|
|
|
*/var _r=Fe(mr),Er=Fe(vr);export{Er as F,Cr as L,_r as a};
|