1 |
- System.register(["./index-legacy-67665670.js","./index-legacy-07687ee8.js"],(function(e,t){"use strict";var a,l,r,n,o,i,s,u,c,d,g,f,p,v,m,h,b,y,k,x,S,w,C,V,M,I,B,A,z,E,T,j,P,W,q,L,$,F;return{setters:[e=>{a=e.bj,l=e.ak,r=e.bk,n=e.bl,o=e.b2,i=e.x,s=e.z,u=e.C,c=e.D,d=e.a6,g=e.aq,f=e.d,p=e.ae,v=e.r,m=e.H,h=e.ar,b=e.c,y=e.y,k=e.ad,x=e.au,S=e.j,w=e.K,C=e.o,V=e.W,M=e.a,I=e.bm,B=e.ai,A=e.bn,z=e.bo,E=e.aF,T=e.V,j=e.bp,P=e.G,W=e.n,q=e.bq,L=e.w},e=>{$=e.c,F=e.C}],execute:function(){function t(e){return Array.isArray(e)?!e.length:0!==e&&!e}function H(e,t){const{message:a}=t;return o(a)?a(e,t):a||""}function D({target:e}){e.composing=!0}function R({target:e}){e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}function K(e){return[...e].length}function O(e,t){return[...e].slice(0,t).join("")}const[G,J]=i("field"),N=e("f",{id:String,name:String,leftIcon:String,rightIcon:String,autofocus:Boolean,clearable:Boolean,maxlength:s,formatter:Function,clearIcon:u("clear"),modelValue:c(""),inputAlign:String,placeholder:String,autocomplete:String,autocapitalize:String,autocorrect:String,errorMessage:String,enterkeyhint:String,clearTrigger:u("focus"),formatTrigger:u("onChange"),spellcheck:{type:Boolean,"default":null},error:{type:Boolean,"default":null},disabled:{type:Boolean,"default":null},readonly:{type:Boolean,"default":null}}),Q=d({},$,N,{rows:s,type:u("text"),rules:Array,autosize:[Boolean,Object],labelWidth:s,labelClass:g,labelAlign:String,showWordLimit:Boolean,errorMessageAlign:String,colon:{type:Boolean,"default":null}});var U=f({name:G,props:Q,emits:["blur","focus","clear","keypress","clickInput","endValidate","startValidate","clickLeftIcon","clickRightIcon","update:modelValue"],setup(e,{emit:o,slots:i}){const s=p(),u=v({status:"unvalidated",focused:!1,validateMessage:""}),c=m(),d=m(),g=m(),{parent:f}=h(I),L=()=>{var t;return String(null!=(t=e.modelValue)?t:"")},$=t=>B(e[t])?e[t]:f&&B(f.props[t])?f.props[t]:void 0,G=b((()=>{const t=$("readonly");if(e.clearable&&!t){const t=""!==L(),a="always"===e.clearTrigger||"focus"===e.clearTrigger&&u.focused;return t&&a}return!1})),N=b((()=>g.value&&i.input?g.value():e.modelValue)),Q=b((()=>{var t;const a=$("required");return"auto"===a?null==(t=e.rules)?void 0:t.some((e=>e.required)):a})),U=e=>e.reduce(((e,a)=>e.then((()=>{if("failed"===u.status)return;let{value:e}=N;if(a.formatter&&(e=a.formatter(e,a)),!function(e,a){if(t(e)){if(a.required)return!1;if(!1===a.validateEmpty)return!0}return!(a.pattern&&!a.pattern.test(String(e)))}(e,a))return u.status="failed",void(u.validateMessage=H(e,a));if(a.validator){if(t(e)&&!1===a.validateEmpty)return;return function(e,t){return new Promise((a=>{const l=t.validator(e,t);n(l)?l.then(a):a(l)}))}(e,a).then((t=>{t&&"string"==typeof t?(u.status="failed",u.validateMessage=t):!1===t&&(u.status="failed",u.validateMessage=H(e,a))}))}}))),Promise.resolve()),X=()=>{u.status="unvalidated",u.validateMessage=""},Y=()=>o("endValidate",{status:u.status,message:u.validateMessage}),Z=(t=e.rules)=>new Promise((a=>{X(),t?(o("startValidate"),U(t).then((()=>{"failed"===u.status?(a({name:e.name,message:u.validateMessage}),Y()):(u.status="passed",a(),Y())}))):a()})),_=t=>{if(f&&e.rules){const{validateTrigger:a}=f.props,l=A(a).includes(t),r=e.rules.filter((e=>e.trigger?A(e.trigger).includes(t):l));r.length&&Z(r)}},ee=(t,a="onChange")=>{const l=t;t=(t=>{var a;const{maxlength:l}=e;if(B(l)&&K(t)>+l){const e=L();if(e&&K(e)===+l)return e;const r=null==(a=c.value)?void 0:a.selectionEnd;if(u.focused&&r){const e=[...t],a=e.length-+l;return e.splice(r-a,a),e.join("")}return O(t,+l)}return t})(t);const r=K(l)-K(t);if("number"===e.type||"digit"===e.type){const a="number"===e.type;t=z(t,a,a)}let n=0;if(e.formatter&&a===e.formatTrigger){const{formatter:a,maxlength:r}=e;if(t=a(t),B(r)&&K(t)>+r&&(t=O(t,+r)),c.value&&u.focused){const{selectionEnd:e}=c.value,t=O(l,e);n=K(a(t))-K(t)}}if(c.value&&c.value.value!==t)if(u.focused){let{selectionStart:e,selectionEnd:a}=c.value;if(c.value.value=t,B(e)&&B(a)){const l=K(t);r?(e-=r,a-=r):n&&(e+=n,a+=n),c.value.setSelectionRange(Math.min(e,l),Math.min(a,l))}}else c.value.value=t;t!==e.modelValue&&o("update:modelValue",t)},te=e=>{e.target.composing||ee(e.target.value)},ae=()=>{var e;return null==(e=c.value)?void 0:e.blur()},le=()=>{var e;return null==(e=c.value)?void 0:e.focus()},re=()=>{const t=c.value;"textarea"===e.type&&e.autosize&&t&&function(e,t){const n=a();e.style.height="auto";let o=e.scrollHeight;if(r(t)){const{maxHeight:e,minHeight:a}=t;void 0!==e&&(o=Math.min(o,e)),void 0!==a&&(o=Math.max(o,a))}o&&(e.style.height=`${o}px`,l(n))}(t,e.autosize)},ne=e=>{u.focused=!0,o("focus",e),w(re),$("readonly")&&ae()},oe=e=>{u.focused=!1,ee(L(),"onBlur"),o("blur",e),$("readonly")||(_("onBlur"),w(re),q())},ie=e=>o("clickInput",e),se=e=>o("clickLeftIcon",e),ue=e=>o("clickRightIcon",e),ce=b((()=>"boolean"==typeof e.error?e.error:!(!f||!f.props.showError||"failed"!==u.status)||void 0)),de=b((()=>{const e=$("labelWidth"),t=$("labelAlign");if(e&&"top"!==t)return{width:y(e)}})),ge=t=>{13===t.keyCode&&(f&&f.props.submitOnEnter||"textarea"===e.type||E(t),"search"===e.type&&ae()),o("keypress",t)},fe=()=>e.id||`${s}-input`,pe=()=>{const t=J("control",[$("inputAlign"),{error:ce.value,custom:!!i.input,"min-height":"textarea"===e.type&&!e.autosize}]);if(i.input)return M("div",{"class":t,onClick:ie},[i.input()]);const a={id:fe(),ref:c,name:e.name,rows:void 0!==e.rows?+e.rows:void 0,"class":t,disabled:$("disabled"),readonly:$("readonly"),autofocus:e.autofocus,placeholder:e.placeholder,autocomplete:e.autocomplete,autocapitalize:e.autocapitalize,autocorrect:e.autocorrect,enterkeyhint:e.enterkeyhint,spellcheck:e.spellcheck,"aria-labelledby":e.label?`${s}-label`:void 0,onBlur:oe,onFocus:ne,onInput:te,onClick:ie,onChange:R,onKeypress:ge,onCompositionend:R,onCompositionstart:D};return"textarea"===e.type?M("textarea",a,null):M("input",P("number"===(l=e.type)?{type:"text",inputmode:"decimal"}:"digit"===l?{type:"tel",inputmode:"numeric"}:{type:l},a),null);var l},ve=()=>{const t=i["right-icon"];if(e.rightIcon||t)return M("div",{"class":J("right-icon"),onClick:ue},[t?t():M(T,{name:e.rightIcon,classPrefix:e.iconPrefix},null)])},me=()=>{if(e.showWordLimit&&e.maxlength){const t=K(L());return M("div",{"class":J("word-limit")},[M("span",{"class":J("word-num")},[t]),W("/"),e.maxlength])}},he=()=>{if(f&&!1===f.props.showErrorMessage)return;const t=e.errorMessage||u.validateMessage;if(t){const e=i["error-message"],a=$("errorMessageAlign");return M("div",{"class":J("error-message",a)},[e?e({message:t}):t])}},be=()=>[M("div",{"class":J("body")},[pe(),G.value&&M(T,{ref:d,name:e.clearIcon,"class":J("clear")},null),ve(),i.button&&M("div",{"class":J("button")},[i.button()])]),me(),he()];return k({blur:ae,focus:le,validate:Z,formValue:N,resetValidation:X,getValidationStatus:()=>u.status}),x(j,{customValue:g,resetValidation:X,validateWithTrigger:_}),S((()=>e.modelValue),(()=>{ee(L()),X(),_("onChange"),w(re)})),C((()=>{ee(L(),e.formatTrigger),w(re)})),V("touchstart",(e=>{E(e),o("update:modelValue",""),o("clear",e)}),{target:b((()=>{var e;return null==(e=d.value)?void 0:e.$el}))}),()=>{const t=$("disabled"),a=$("labelAlign"),l=(()=>{const t=i["left-icon"];if(e.leftIcon||t)return M("div",{"class":J("left-icon"),onClick:se},[t?t():M(T,{name:e.leftIcon,classPrefix:e.iconPrefix},null)])})();return M(F,{size:e.size,"class":J({error:ce.value,disabled:t,[`label-${a}`]:a}),center:e.center,border:e.border,isLink:e.isLink,clickable:e.clickable,titleStyle:de.value,valueClass:J("value"),titleClass:[J("label",[a,{required:Q.value}]),e.labelClass],arrowDirection:e.arrowDirection},{icon:l&&"top"!==a?()=>l:null,title:()=>{const t=(()=>{const t=$("labelWidth"),a=$("labelAlign"),l=$("colon")?":":"";return i.label?[i.label(),l]:e.label?M("label",{id:`${s}-label`,"for":i.input?void 0:fe(),onClick:e=>{E(e),le()},style:"top"===a&&t?{width:y(t)}:void 0},[e.label+l]):void 0})();return"top"===a?[l,t].filter(Boolean):t||[]},value:be,extra:i.extra})}}});e("F",L(U))}}}));
|