1 |
- System.register(["./index-legacy-835c2a22.js","./index-legacy-552d02c1.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,E,z,T,L,P,j,W,$,q,D;return{setters:[e=>{a=e.bg,l=e.am,r=e.bh,n=e.bi,o=e.b1,i=e.t,s=e.w,u=e.N,c=e.x,d=e.D,g=e.aq,f=e.d,p=e.ah,v=e.r,m=e.Q,h=e.G,b=e.c,y=e.z,k=e.ag,x=e.at,S=e.S,w=e.V,C=e.o,V=e.k,M=e.a,I=e.bj,B=e.ak,A=e.bk,E=e.bl,z=e.aE,T=e.L,L=e.bm,P=e.J,j=e.m,W=e.bn,$=e.C},e=>{q=e.c,D=e.C}],execute:function(){function t(e){return Array.isArray(e)?!e.length:0!==e&&!e}function F(e,t){const{message:a}=t;return o(a)?a(e,t):a||""}function H({target:e}){e.composing=!0}function R({target:e}){e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}function O(e){return[...e].length}function G(e,t){return[...e].slice(0,t).join("")}const[J,K]=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({},q,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:J,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),$=()=>{var t;return String(null!=(t=e.modelValue)?t:"")},q=t=>B(e[t])?e[t]:f&&B(f.props[t])?f.props[t]:void 0,J=b((()=>{const t=q("readonly");if(e.clearable&&!t){const t=""!==$(),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=q("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=F(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=F(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)&&O(t)>+l){const e=$();if(e&&O(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 G(t,+l)}return t})(t);const r=O(l)-O(t);if("number"===e.type||"digit"===e.type){const a="number"===e.type;t=E(t,a,a)}let n=0;if(e.formatter&&a===e.formatTrigger){const{formatter:a,maxlength:r}=e;if(t=a(t),B(r)&&O(t)>+r&&(t=G(t,+r)),c.value&&u.focused){const{selectionEnd:e}=c.value,t=G(l,e);n=O(a(t))-O(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=O(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),q("readonly")&&ae()},oe=e=>{u.focused=!1,ee($(),"onBlur"),o("blur",e),q("readonly")||(_("onBlur"),w(re),W())},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=q("labelWidth"),t=q("labelAlign");if(e&&"top"!==t)return{width:y(e)}})),ge=t=>{13===t.keyCode&&(f&&f.props.submitOnEnter||"textarea"===e.type||z(t),"search"===e.type&&ae()),o("keypress",t)},fe=()=>e.id||`${s}-input`,pe=()=>{const t=K("control",[q("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:q("disabled"),readonly:q("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:H};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":K("right-icon"),onClick:ue},[t?t():M(T,{name:e.rightIcon,classPrefix:e.iconPrefix},null)])},me=()=>{if(e.showWordLimit&&e.maxlength){const t=O($());return M("div",{"class":K("word-limit")},[M("span",{"class":K("word-num")},[t]),j("/"),e.maxlength])}},he=()=>{if(f&&!1===f.props.showErrorMessage)return;const t=e.errorMessage||u.validateMessage;if(t){const e=i["error-message"],a=q("errorMessageAlign");return M("div",{"class":K("error-message",a)},[e?e({message:t}):t])}},be=()=>[M("div",{"class":K("body")},[pe(),J.value&&M(T,{ref:d,name:e.clearIcon,"class":K("clear")},null),ve(),i.button&&M("div",{"class":K("button")},[i.button()])]),me(),he()];return k({blur:ae,focus:le,validate:Z,formValue:N,resetValidation:X,getValidationStatus:()=>u.status}),x(L,{customValue:g,resetValidation:X,validateWithTrigger:_}),S((()=>e.modelValue),(()=>{ee($()),X(),_("onChange"),w(re)})),C((()=>{ee($(),e.formatTrigger),w(re)})),V("touchstart",(e=>{z(e),o("update:modelValue",""),o("clear",e)}),{target:b((()=>{var e;return null==(e=d.value)?void 0:e.$el}))}),()=>{const t=q("disabled"),a=q("labelAlign"),l=(()=>{const t=i["left-icon"];if(e.leftIcon||t)return M("div",{"class":K("left-icon"),onClick:se},[t?t():M(T,{name:e.leftIcon,classPrefix:e.iconPrefix},null)])})();return M(D,{size:e.size,"class":K({error:ce.value,disabled:t,[`label-${a}`]:a}),center:e.center,border:e.border,isLink:e.isLink,clickable:e.clickable,titleStyle:de.value,valueClass:K("value"),titleClass:[K("label",[a,{required:Q.value}]),e.labelClass],arrowDirection:e.arrowDirection},{icon:l&&"top"!==a?()=>l:null,title:()=>{const t=(()=>{const t=q("labelWidth"),a=q("labelAlign"),l=q("colon")?":":"";return i.label?[i.label(),l]:e.label?M("label",{id:`${s}-label`,"for":i.input?void 0:fe(),onClick:e=>{z(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",$(U))}}}));
|