2 lines
5.0 KiB
JavaScript
2 lines
5.0 KiB
JavaScript
"use strict";var e=Object.defineProperty,a=Object.defineProperties,l=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,n=(a,l,o)=>l in a?e(a,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[l]=o;const u=require("../../../../common/vendor.js");if(!Array){u.resolveComponent("wd-icon")()}Math;const i=u.defineComponent((s=((e,a)=>{for(var l in a||(a={}))t.call(a,l)&&n(e,l,a[l]);if(o)for(var l of o(a))r.call(a,l)&&n(e,l,a[l]);return e})({},{name:"wd-input",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),c={props:u.inputProps,emits:["update:modelValue","clear","change","blur","focus","input","keyboardheightchange","confirm","linechange","clicksuffixicon","clickprefixicon","click"],setup(e,{emit:a}){const l=e,o=a,{translate:t}=u.useTranslate("input"),r=u.ref(!1),n=u.ref(!1),i=u.ref(!1),s=u.ref(!1),c=u.ref(!1),p=u.ref(""),d=u.useCell();u.watch((()=>l.focus),(e=>{c.value=e}),{immediate:!0,deep:!0}),u.watch((()=>l.modelValue),(e=>{const{disabled:a,readonly:o,clearable:t}=l;void 0===e&&(e=""),p.value=e,r.value=Boolean(t&&!a&&!o&&e)}),{immediate:!0,deep:!0});const{parent:f}=u.useParent(u.FORM_KEY),v=u.computed((()=>f&&l.prop&&f.errorMessages&&f.errorMessages[l.prop]?f.errorMessages[l.prop]:"")),m=u.computed((()=>{let e=!1;if(f&&f.props.rules){const a=f.props.rules;for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&o===l.prop&&Array.isArray(a[o])&&(e=a[o].some((e=>e.required)))}return l.required||l.rules.some((e=>e.required))||e})),b=u.computed((()=>`wd-input ${l.label||l.useLabelSlot?"is-cell":""} ${l.center?"is-center":""} ${d.border.value?"is-border":""} ${l.size?"is-"+l.size:""} ${l.error?"is-error":""} ${l.disabled?"is-disabled":""} ${p.value&&String(p.value).length>0?"is-not-empty":""} ${l.noBorder?"is-no-border":""} ${l.customClass}`)),h=u.computed((()=>`wd-input__label ${l.customLabelClass} ${m.value?"is-required":""}`)),g=u.computed((()=>`wd-input__placeholder ${l.placeholderClass}`)),w=u.computed((()=>l.labelWidth?u.objToStyle({"min-width":l.labelWidth,"max-width":l.labelWidth}):""));function x(){i.value=!i.value}function y(){p.value="",u.requestAnimationFrame().then((()=>u.requestAnimationFrame())).then((()=>u.requestAnimationFrame())).then((()=>{c.value=!0,o("change",{value:""}),o("update:modelValue",p.value),o("clear")}))}function S(){c.value=!1,o("change",{value:p.value}),o("update:modelValue",p.value),o("blur",{value:p.value})}function _({detail:e}){s.value?s.value=!1:(c.value=!0,o("focus",e))}function I(){o("update:modelValue",p.value),o("input",p.value)}function P(e){o("keyboardheightchange",e.detail)}function O({detail:e}){o("confirm",e)}function j(){o("clicksuffixicon")}function $(){o("clickprefixicon")}function C(e){o("click",e)}return u.onBeforeMount((()=>{!function(){const{disabled:e,readonly:a,clearable:t,maxlength:u,showWordLimit:i}=l;let s="";i&&u&&p.value.toString().length>u&&(s=p.value.toString().substring(0,u)),r.value=Boolean(!e&&!a&&t&&p.value),n.value=Boolean(!e&&!a&&u&&i),p.value=s||p.value,o("update:modelValue",p.value)}()})),(e,a)=>u.e({a:e.label||e.useLabelSlot},e.label||e.useLabelSlot?u.e({b:e.prefixIcon||e.usePrefixSlot},e.prefixIcon||e.usePrefixSlot?u.e({c:e.prefixIcon&&!e.usePrefixSlot},e.prefixIcon&&!e.usePrefixSlot?{d:u.o($),e:u.p({"custom-class":"wd-input__icon",name:e.prefixIcon})}:{}):{},{f:e.label},e.label?{g:u.t(e.label)}:{},{h:u.n(h.value),i:u.s(w.value)}):{},{j:(e.prefixIcon||e.usePrefixSlot)&&!e.label},!e.prefixIcon&&!e.usePrefixSlot||e.label?{}:u.e({k:e.prefixIcon},e.prefixIcon?{l:u.o($),m:u.p({"custom-class":"wd-input__icon",name:e.prefixIcon})}:{}),{n:u.n(e.prefixIcon?"wd-input__inner--prefix":""),o:u.n(n.value?"wd-input__inner--count":""),p:u.n(e.alignRight?"is-align-right":""),q:u.n(e.customInputClass),r:e.type,s:e.showPassword&&!i.value,t:e.placeholder||u.unref(t)("placeholder"),v:e.disabled,w:e.maxlength,x:c.value,y:e.confirmType,z:e.confirmHold,A:e.cursor,B:e.cursorSpacing,C:e.placeholderStyle,D:e.selectionStart,E:e.selectionEnd,F:e.adjustPosition,G:e.holdKeyboard,H:e.alwaysEmbed,I:g.value,J:u.o([e=>p.value=e.detail.value,I]),K:u.o(_),L:u.o(S),M:u.o(O),N:u.o(P),O:p.value,P:e.readonly},(e.readonly,{}),{Q:r.value||e.showPassword||e.suffixIcon||n.value||e.useSuffixSlot},r.value||e.showPassword||e.suffixIcon||n.value||e.useSuffixSlot?u.e({R:r.value},r.value?{S:u.o(y),T:u.p({"custom-class":"wd-input__clear",name:"error-fill"})}:{},{U:e.showPassword},e.showPassword?{V:u.o(x),W:u.p({"custom-class":"wd-input__icon",name:i.value?"view":"eye-close"})}:{},{X:n.value},n.value?{Y:u.t(String(p.value).length),Z:u.n(p.value&&String(p.value).length>0?"wd-input__count-current":""),aa:u.n(String(p.value).length>e.maxlength?"is-error":""),ab:u.t(e.maxlength)}:{},{ac:e.suffixIcon},e.suffixIcon?{ad:u.o(j),ae:u.p({"custom-class":"wd-input__icon",name:e.suffixIcon})}:{}):{},{af:v.value},v.value?{ag:u.t(v.value)}:{},{ah:u.n(b.value),ai:u.s(e.customStyle),aj:u.o(C)})}},a(s,l(c))));var s,c;const p=u._export_sfc(i,[["__scopeId","data-v-c3a16a86"]]);wx.createComponent(p);
|