index-legacy.3a3e070a.js 7.7 KB

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