Files
Nexus/web/app/assets/VTextarea-Dde5kxXN.js
T
2026-06-08 07:30:31 +08:00

1 line
5.1 KiB
JavaScript

import{An as e,Cn as t,Cr as n,En as r,Fn as i,Fr as a,G as o,Lr as s,Pr as c,Sr as l,Tr as u,Ur as d,Wr as ee,Yn as f,Zr as p,a as te,cn as m,d as h,dn as g,f as _,g as v,gr as y,i as b,kn as ne,lr as x,mn as re,o as S,p as C,r as w,rr as T,s as E,sr as D,ur as O,xr as k,y as A,yn as j}from"./index-DC1GUjcg.js";var M=t({autoGrow:Boolean,autofocus:Boolean,counter:[Boolean,Number,String],counterValue:Function,prefix:String,placeholder:String,persistentPlaceholder:Boolean,persistentCounter:Boolean,noResize:Boolean,rows:{type:[Number,String],default:5,validator:e=>!isNaN(parseFloat(e))},maxHeight:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},maxRows:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},suffix:String,modelModifiers:Object,...b(),...f(E(),[`direction`]),..._()},`VTextarea`),N=j()({name:`VTextarea`,directives:{vIntersect:o},inheritAttrs:!1,props:M(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0,"update:rows":e=>!0},setup(t,{attrs:f,emit:_,slots:b}){let E=g(t,`modelValue`),{isFocused:j,focus:M,blur:N}=C(t),{onIntersect:P}=w(t),F=x(()=>typeof t.counterValue==`function`?t.counterValue(E.value):(E.value||``).toString().length),I=x(()=>{if(f.maxlength)return f.maxlength;if(!(!t.counter||typeof t.counter!=`number`&&typeof t.counter!=`string`))return t.counter}),L=d(),R=d(),z=ee(``),B=d(),V=d(0),{platform:H}=m(),U=te(t),W=x(()=>t.persistentPlaceholder||j.value||t.active);function G(){U.isSuppressing.value&&U.update(),B.value!==document.activeElement&&B.value?.focus(),j.value||M()}function K(e){G(),_(`click:control`,e)}function q(e){_(`mousedown:control`,e)}function J(e){e.stopPropagation(),G(),l(()=>{E.value=``,r(t[`onClick:clear`],e)})}function ie(e){let n=e.target;if(!t.modelModifiers?.trim){E.value=n.value;return}let r=n.value,i=n.selectionStart,a=n.selectionEnd;E.value=r,l(()=>{let e=0;r.trimStart().length===n.value.length&&(e=r.length-n.value.length),i!=null&&(n.selectionStart=i-e),a!=null&&(n.selectionEnd=a-e)})}let Y=d(),X=d(Number(t.rows)),Z=x(()=>[`plain`,`underlined`].includes(t.variant));a(()=>{t.autoGrow||(X.value=Number(t.rows))});function Q(){l(()=>{if(!B.value)return;if(H.value.firefox){V.value=12;return}let{offsetWidth:e,clientWidth:t}=B.value;V.value=Math.max(0,e-t)}),t.autoGrow&&l(()=>{if(!Y.value||!R.value)return;let n=getComputedStyle(Y.value),r=getComputedStyle(R.value.$el),i=parseFloat(n.getPropertyValue(`--v-field-padding-top`))+parseFloat(n.getPropertyValue(`--v-input-padding-top`))+parseFloat(n.getPropertyValue(`--v-field-padding-bottom`)),a=Y.value.scrollHeight,o=parseFloat(n.lineHeight),s=Math.max(parseFloat(t.rows)*o+i,parseFloat(r.getPropertyValue(`--v-input-control-height`))),c=t.maxHeight?parseFloat(t.maxHeight):parseFloat(t.maxRows)*o+i||1/0,l=ne(a??0,s,c);X.value=Math.floor((l-i)/o),z.value=e(l)})}u(Q),c(E,Q),c(()=>t.rows,Q),c(()=>t.maxHeight,Q),c(()=>t.maxRows,Q),c(()=>t.density,Q),c(X,e=>{_(`update:rows`,e)});let $;return c(Y,e=>{e?($=new ResizeObserver(Q),$.observe(Y.value)):$?.disconnect()}),n(()=>{$?.disconnect()}),re(()=>{let n=!!(b.counter||t.counter||t.counterValue),r=!!(n||b.details),[a,c]=i(f),{modelValue:l,...u}=S.filterProps(t),d={...h.filterProps(t),"onClick:clear":J};return y(S,k({ref:L,modelValue:E.value,"onUpdate:modelValue":e=>E.value=e,class:[`v-textarea v-text-field`,{"v-textarea--prefixed":t.prefix,"v-textarea--suffixed":t.suffix,"v-text-field--prefixed":t.prefix,"v-text-field--suffixed":t.suffix,"v-textarea--auto-grow":t.autoGrow,"v-textarea--no-resize":t.noResize||t.autoGrow,"v-input--plain-underlined":Z.value},t.class],style:[{"--v-textarea-max-height":t.maxHeight?e(t.maxHeight):void 0,"--v-textarea-scroll-bar-width":e(V.value)},t.style]},a,u,{centerAffix:X.value===1&&!Z.value,focused:j.value,indentDetails:t.indentDetails??!Z.value}),{...b,default:({id:e,isDisabled:n,isDirty:r,isReadonly:i,isValid:a,hasDetails:l})=>y(h,k({ref:R,style:{"--v-textarea-control-height":z.value},onClick:K,onMousedown:q,"onClick:prependInner":t[`onClick:prependInner`],"onClick:appendInner":t[`onClick:appendInner`]},d,{id:e.value,active:W.value||r.value,labelId:`${e.value}-label`,centerAffix:X.value===1&&!Z.value,dirty:r.value||t.dirty,disabled:n.value,focused:j.value,details:l.value,error:a.value===!1}),{...b,default:({props:{class:r,...a},controlRef:l})=>O(D,null,[t.prefix&&O(`span`,{class:`v-text-field__prefix`},[t.prefix]),s(O(`textarea`,k({ref:e=>B.value=l.value=e,class:r,value:E.value,onInput:ie,autofocus:t.autofocus,readonly:i.value,disabled:n.value,placeholder:t.placeholder,rows:t.rows,name:U.fieldName.value,autocomplete:U.fieldAutocomplete.value,onFocus:G,onBlur:N,"aria-labelledby":`${e.value}-label`},a,c),null),[[o,{handler:P},null,{once:!0}]]),t.autoGrow&&s(O(`textarea`,{class:p([r,`v-textarea__sizer`]),id:`${a.id}-sizer`,"onUpdate:modelValue":e=>E.value=e,ref:Y,readonly:!0,"aria-hidden":`true`},null),[[T,E.value]]),t.suffix&&O(`span`,{class:`v-text-field__suffix`},[t.suffix])])}),details:r?e=>O(D,null,[b.details?.(e),n&&O(D,null,[O(`span`,null,null),y(v,{active:t.persistentCounter||j.value,value:F.value,max:I.value,disabled:t.disabled},b.counter)])]):void 0})}),A({},L,R,B)}});export{N as t};