"use strict";const e=require("../../../../common/vendor.js"),a=require("../common/util.js"),l=require("../composables/useCell.js"),r=require("../wd-form/types.js"),o=require("../composables/useParent.js"),t=require("../composables/useTranslate.js"),s=require("./types.js");Math||u();const u=()=>"../wd-icon/wd-icon.js",i=e.defineComponent({name:"wd-textarea",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"},props:s.textareaProps,emits:["update:modelValue","clear","blur","focus","input","keyboardheightchange","confirm","linechange","clickprefixicon","click"],setup(s,{emit:u}){const{translate:i}=t.useTranslate("textarea"),n=s,c=u,d=e.useSlots(),p=e.computed((()=>a.isDef(n.placeholder)?n.placeholder:i("placeholder"))),m=e.ref(!1),v=e.ref(!1),f=e.ref(!1),b=e.ref(""),h=l.useCell();e.watch((()=>n.focus),(e=>{v.value=e}),{immediate:!0,deep:!0}),e.watch((()=>n.modelValue),(e=>{b.value=a.isDef(e)?String(e):""}),{immediate:!0,deep:!0});const{parent:x}=o.useParent(r.FORM_KEY),g=e.computed((()=>{const{disabled:e,readonly:a,clearable:l,clearTrigger:r}=n;return!(!l||a||e||!b.value||!("always"===r||"focus"===n.clearTrigger&&f.value))})),$=e.computed((()=>{const{disabled:e,readonly:l,maxlength:r,showWordLimit:o}=n;return Boolean(!e&&!l&&a.isDef(r)&&r>-1&&o)})),w=e.computed((()=>x&&n.prop&&x.errorMessages&&x.errorMessages[n.prop]?x.errorMessages[n.prop]:"")),y=e.computed((()=>{let e=!1;if(x&&x.props.rules){const a=x.props.rules;for(const l in a)Object.prototype.hasOwnProperty.call(a,l)&&l===n.prop&&Array.isArray(a[l])&&(e=a[l].some((e=>e.required)))}return n.required||n.rules.some((e=>e.required))||e})),_=e.computed((()=>Array.from(String(k(n.modelValue))).length)),C=e.computed((()=>`wd-textarea   ${n.label||d.label?"is-cell":""} ${n.center?"is-center":""} ${h.border.value?"is-border":""} ${n.size?"is-"+n.size:""} ${n.error?"is-error":""} ${n.disabled?"is-disabled":""} ${n.autoHeight?"is-auto-height":""} ${_.value>0?"is-not-empty":""}  ${n.noBorder?"is-no-border":""} ${n.customClass}`));e.computed((()=>`wd-textarea__label ${n.customLabelClass}`));const S=e.computed((()=>`wd-textarea__placeholder  ${n.placeholderClass}`)),j=e.computed((()=>`${_.value>0?"wd-textarea__count-current":""} ${_.value>n.maxlength?"is-error":""}`)),q=e.computed((()=>n.labelWidth?a.objToStyle({"min-width":n.labelWidth,"max-width":n.labelWidth}):""));function k(e){if(null==e)return"";const{maxlength:a,showWordLimit:l}=n;return l&&-1!==a&&String(e).length>a?e.toString().substring(0,a):`${e}`}async function T(){f.value=!1,b.value="",n.focusWhenClear&&(m.value=!0,v.value=!1),await a.pause(),n.focusWhenClear&&(v.value=!0,f.value=!0),c("update:modelValue",b.value),c("clear")}async function I({detail:e}){await a.pause(150),m.value?m.value=!1:(f.value=!1,c("blur",{value:b.value,cursor:e.cursor?e.cursor:null}))}function W({detail:e}){f.value=!0,c("focus",e)}function M({detail:e}){b.value=k(b.value),c("update:modelValue",b.value),c("input",e)}function P({detail:e}){c("keyboardheightchange",e)}function V({detail:e}){c("confirm",e)}function B({detail:e}){c("linechange",e)}function D(){c("clickprefixicon")}return e.onBeforeMount((()=>{b.value=k(b.value),c("update:modelValue",b.value)})),(a,l)=>e.e({a:a.label||a.$slots.label},a.label||a.$slots.label?e.e({b:y.value&&"before"===a.markerSide},(y.value&&a.markerSide,{}),{c:a.prefixIcon||a.$slots.prefix},a.prefixIcon||a.$slots.prefix?e.e({d:a.prefixIcon&&!a.$slots.prefix},a.prefixIcon&&!a.$slots.prefix?{e:e.o(D),f:e.p({"custom-class":"wd-textarea__icon",name:a.prefixIcon})}:{}):{},{g:a.label&&!a.$slots.label},a.label&&!a.$slots.label?{h:e.t(a.label)}:(a.$slots.label,{}),{i:a.$slots.label,j:y.value&&"after"===a.markerSide},(y.value&&a.markerSide,{}),{k:e.s(q.value)}):{},{l:e.n(`wd-textarea__inner ${a.customTextareaClass}`),m:p.value,n:a.disabled||a.readonly,o:a.maxlength,p:v.value,q:a.autoFocus,r:a.placeholderStyle,s:S.value,t:a.autoHeight,v:a.cursorSpacing,w:a.fixed,x:a.cursor,y:a.showConfirmBar,z:a.selectionStart,A:a.selectionEnd,B:a.adjustPosition,C:a.holdKeyboard,D:a.confirmType,E:a.confirmHold,F:a.disableDefaultPadding,G:a.ignoreCompositionEvent,H:a.inputmode,I:e.o([e=>b.value=e.detail.value,M]),J:e.o(W),K:e.o(I),L:e.o(V),M:e.o(B),N:e.o(P),O:b.value,P:w.value},w.value?{Q:e.t(w.value)}:{},{R:n.readonly},(n.readonly,{}),{S:g.value},g.value?{T:e.o(T),U:e.p({"custom-class":"wd-textarea__clear",name:"error-fill"})}:{},{V:$.value},$.value?{W:e.t(_.value),X:e.n(j.value),Y:e.t(a.maxlength)}:{},{Z:e.n(`wd-textarea__value ${g.value?"is-suffix":""} ${a.customTextareaContainerClass} ${$.value?"is-show-limit":""}`),aa:e.n(C.value),ab:e.s(a.customStyle)})}}),n=e._export_sfc(i,[["__scopeId","data-v-ebeccb4f"]]);wx.createComponent(n);
