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