mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
1 line
4.4 KiB
JavaScript
1 line
4.4 KiB
JavaScript
import{p as Z,ae as p,bg as ee,n as te,bh as ae,u as ne,ag as le,o as y,O as x,aq as oe,b4 as ue,bd as ie,aR as m,bi as re,ac as se,ai as ce,aj as z,bj as de,D as o,bk as fe,J as R,a2 as I,ar as A,as as ve,bl as xe,bm as me,b3 as ge,ax as S,bn as he,ad as we,az as Ve}from"./index.86ff0207.js";const ye=Z({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))},maxRows:{type:[Number,String],validator:e=>!isNaN(parseFloat(e))},suffix:String,modelModifiers:Object,...p(),...ee()},"VTextarea"),Fe=te()({name:"VTextarea",directives:{Intersect:ae},inheritAttrs:!1,props:ye(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,_){let{attrs:b,emit:M,slots:i}=_;const u=ne(e,"modelValue"),{isFocused:f,focus:D,blur:G}=le(e),E=y(()=>typeof e.counterValue=="function"?e.counterValue(u.value):(u.value||"").toString().length),U=y(()=>{if(b.maxlength)return b.maxlength;if(!(!e.counter||typeof e.counter!="number"&&typeof e.counter!="string"))return e.counter});function O(t,n){var a,l;!e.autofocus||!t||(l=(a=n[0].target)==null?void 0:a.focus)==null||l.call(a)}const B=x(),g=x(),H=oe(""),h=x(),j=y(()=>e.persistentPlaceholder||f.value||e.active);function F(){var t;h.value!==document.activeElement&&((t=h.value)==null||t.focus()),f.value||D()}function $(t){F(),M("click:control",t)}function q(t){M("mousedown:control",t)}function J(t){t.stopPropagation(),F(),S(()=>{u.value="",he(e["onClick:clear"],t)})}function K(t){var a;const n=t.target;if(u.value=n.value,(a=e.modelModifiers)!=null&&a.trim){const l=[n.selectionStart,n.selectionEnd];S(()=>{n.selectionStart=l[0],n.selectionEnd=l[1]})}}const c=x(),w=x(+e.rows),C=y(()=>["plain","underlined"].includes(e.variant));ue(()=>{e.autoGrow||(w.value=+e.rows)});function d(){!e.autoGrow||S(()=>{if(!c.value||!g.value)return;const t=getComputedStyle(c.value),n=getComputedStyle(g.value.$el),a=parseFloat(t.getPropertyValue("--v-field-padding-top"))+parseFloat(t.getPropertyValue("--v-input-padding-top"))+parseFloat(t.getPropertyValue("--v-field-padding-bottom")),l=c.value.scrollHeight,V=parseFloat(t.lineHeight),P=Math.max(parseFloat(e.rows)*V+a,parseFloat(n.getPropertyValue("--v-input-control-height"))),k=parseFloat(e.maxRows)*V+a||1/0,s=Ve(l!=null?l:0,P,k);w.value=Math.floor((s-a)/V),H.value=we(s)})}ie(d),m(u,d),m(()=>e.rows,d),m(()=>e.maxRows,d),m(()=>e.density,d);let r;return m(c,t=>{t?(r=new ResizeObserver(d),r.observe(c.value)):r==null||r.disconnect()}),re(()=>{r==null||r.disconnect()}),se(()=>{const t=!!(i.counter||e.counter||e.counterValue),n=!!(t||i.details),[a,l]=ce(b),[{modelValue:V,...P}]=z.filterProps(e),[k]=de(e);return o(z,R({ref:B,modelValue:u.value,"onUpdate:modelValue":s=>u.value=s,class:["v-textarea v-text-field",{"v-textarea--prefixed":e.prefix,"v-textarea--suffixed":e.suffix,"v-text-field--prefixed":e.prefix,"v-text-field--suffixed":e.suffix,"v-textarea--auto-grow":e.autoGrow,"v-textarea--no-resize":e.noResize||e.autoGrow,"v-text-field--plain-underlined":C.value},e.class],style:e.style},a,P,{centerAffix:w.value===1&&!C.value,focused:f.value}),{...i,default:s=>{let{isDisabled:v,isDirty:N,isReadonly:L,isValid:Q}=s;return o(fe,R({ref:g,style:{"--v-textarea-control-height":H.value},onClick:$,onMousedown:q,"onClick:clear":J,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},k,{active:j.value||N.value,centerAffix:w.value===1&&!C.value,dirty:N.value||e.dirty,disabled:v.value,focused:f.value,error:Q.value===!1}),{...i,default:W=>{let{props:{class:T,...X}}=W;return o(I,null,[e.prefix&&o("span",{class:"v-text-field__prefix"},[e.prefix]),A(o("textarea",R({ref:h,class:T,value:u.value,onInput:K,autofocus:e.autofocus,readonly:L.value,disabled:v.value,placeholder:e.placeholder,rows:e.rows,name:e.name,onFocus:F,onBlur:G},X,l),null),[[ve("intersect"),{handler:O},null,{once:!0}]]),e.autoGrow&&A(o("textarea",{class:[T,"v-textarea__sizer"],"onUpdate:modelValue":Y=>u.value=Y,ref:c,readonly:!0,"aria-hidden":"true"},null),[[xe,u.value]]),e.suffix&&o("span",{class:"v-text-field__suffix"},[e.suffix])])}})},details:n?s=>{var v;return o(I,null,[(v=i.details)==null?void 0:v.call(i,s),t&&o(I,null,[o("span",null,null),o(me,{active:e.persistentCounter||f.value,value:E.value,max:U.value},i.counter)])])}:void 0})}),ge({},B,g,h)}});export{Fe as V};
|