index-legacy-31697f57.js 7.5 KB

1
  1. System.register(["./index-legacy-a314c7dd.js","./index-legacy-dff5e6e7.js"],(function(e,t){"use strict";var a,r,l,n,o,i,s,u,c,d,g,f,p,v,m,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.br,r=e.bs,l=e.bt,n=e.b6,o=e.b4,i=e.c,s=e.n,u=e.m,c=e.b,d=e.ac,g=e.a5,f=e.d,p=e.bu,v=e.x,m=e.r,b=e.ad,h=e.e,y=e.o,x=e.Z,k=e.aA,w=e.bv,S=e.w,C=e.z,M=e.y,V=e._,I=e.a,A=e.bw,B=e.Y,E=e.b3,T=e.bm,z=e.p,P=e.I,L=e.h,W=e.A,$=e.bn,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 H(e,t){const{message:a}=t;return o(a)?a(e,t):a||""}function R({target:e}){e.composing=!0}function D({target:e}){e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}function O(e){return[...e].length}function Z(e,t){return[...e].slice(0,t).join("")}const[K,Y]=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:K,props:G,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}=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,K=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=H(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=H(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 Z(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=Z(t,+l)),c.value&&u.focused){const{selectionEnd:e}=c.value,t=Z(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=Y("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:D,onKeypress:de,onCompositionend:D,onCompositionstart:R};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:Y("right-icon"),onClick:se},[t?t():I(P,{name:e.rightIcon,classPrefix:e.iconPrefix},null)])},ve=()=>{if(e.showWordLimit&&e.maxlength){const t=O(j());return I("div",{class:Y("word-limit")},[I("span",{class:Y("word-num")},[t]),W("/"),e.maxlength])}},me=()=>{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:Y("error-message",a)},[e?e({message:t}):t])}},be=()=>[I("div",{class:Y("body")},[fe(),K.value&&I(P,{ref:d,name:e.clearIcon,class:Y("clear")},null),pe(),i.button&&I("div",{class:Y("button")},[i.button()])]),ve(),me()];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:Y("left-icon"),onClick:ie},[t?t():I(P,{name:e.leftIcon,classPrefix:e.iconPrefix},null)])})();return I(F,{size:e.size,class:Y({error:ue.value,disabled:t,[`label-${a}`]:a}),center:e.center,border:e.border,isLink:e.isLink,clickable:e.clickable,titleStyle:ce.value,valueClass:Y("value"),titleClass:[Y("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))}}}));