1234567891011 |
- import{ao as R,w as se,o as ee,i as te,d as V,b as g,b9 as ve,ar as de,aO as ce,u as fe,e as H,c as $}from"./index-421a14fe.js";import{d as ae,k as w,x as ge,w as ne,q as Z,o as me,g as re,f as j,t as he,e as J,s as xe}from"./vue-18ee037d.js";import{t as ie,f as be,C as ze,g as Se,r as U}from"./index-15629871.js";var pe=`
- min-height:0 !important;
- max-height:none !important;
- height:0 !important;
- visibility:hidden !important;
- overflow:hidden !important;
- position:absolute !important;
- z-index:-1000 !important;
- top:0 !important;
- right:0 !important
- `,ye=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],K={},z;function we(d){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=d.getAttribute("id")||d.getAttribute("data-reactid")||d.getAttribute("name");if(e&&K[r])return K[r];var n=window.getComputedStyle(d),m=n.getPropertyValue("box-sizing")||n.getPropertyValue("-moz-box-sizing")||n.getPropertyValue("-webkit-box-sizing"),c=parseFloat(n.getPropertyValue("padding-bottom"))+parseFloat(n.getPropertyValue("padding-top")),b=parseFloat(n.getPropertyValue("border-bottom-width"))+parseFloat(n.getPropertyValue("border-top-width")),v=ye.map(function(u){return"".concat(u,":").concat(n.getPropertyValue(u))}).join(";"),i={sizingStyle:v,paddingSize:c,borderSize:b,boxSizing:m};return e&&r&&(K[r]=i),i}function Ce(d){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;z||(z=document.createElement("textarea"),z.setAttribute("tab-index","-1"),z.setAttribute("aria-hidden","true"),document.body.appendChild(z)),d.getAttribute("wrap")?z.setAttribute("wrap",d.getAttribute("wrap")):z.removeAttribute("wrap");var m=we(d,e),c=m.paddingSize,b=m.borderSize,v=m.boxSizing,i=m.sizingStyle;z.setAttribute("style","".concat(i,";").concat(pe)),z.value=d.value||d.placeholder||"";var u=Number.MIN_SAFE_INTEGER,f=Number.MAX_SAFE_INTEGER,s=z.scrollHeight,S;if(v==="border-box"?s+=b:v==="content-box"&&(s-=c),r!==null||n!==null){z.value=" ";var E=z.scrollHeight-c;r!==null&&(u=E*r,v==="border-box"&&(u=u+c+b),s=Math.max(u,s)),n!==null&&(f=E*n,v==="border-box"&&(f=f+c+b),S=s>f?"":"hidden",s=Math.min(f,s))}return{height:"".concat(s,"px"),minHeight:"".concat(u,"px"),maxHeight:"".concat(f,"px"),overflowY:S,resize:"none"}}var L=0,Q=1,Ae=2,Ee=ae({compatConfig:{MODE:3},name:"ResizableTextArea",inheritAttrs:!1,props:ie(),setup:function(e,r){var n=r.attrs,m=r.emit,c=r.expose,b,v,i=w(),u=w({}),f=w(L);ge(function(){R.cancel(b),R.cancel(v)});var s=function(){try{if(document.activeElement===i.value){var h=i.value.selectionStart,p=i.value.selectionEnd;i.value.setSelectionRange(h,p)}}catch{}},S=function(){var h=e.autoSize||e.autosize;if(!(!h||!i.value)){var p=h.minRows,P=h.maxRows;u.value=Ce(i.value,!1,p,P),f.value=Q,R.cancel(v),v=R(function(){f.value=Ae,v=R(function(){f.value=L,s()})})}},E=function(){R.cancel(b),b=R(S)},C=function(h){if(f.value===L){m("resize",h);var p=e.autoSize||e.autosize;p&&E()}};se(e.autosize===void 0,"Input.TextArea","autosize is deprecated, please use autoSize instead.");var F=function(){var h=e.prefixCls,p=e.autoSize,P=e.autosize,k=e.disabled,D=ee(e,["prefixCls","onPressEnter","autoSize","autosize","defaultValue","allowClear","type","lazy","maxlength","valueModifiers"]),Y=te(h,n.class,V({},"".concat(h,"-disabled"),k)),_=[n.style,u.value,f.value===Q?{overflowX:"hidden",overflowY:"hidden"}:null],I=g(g(g({},D),n),{},{style:_,class:Y});return I.autofocus||delete I.autofocus,I.rows===0&&delete I.rows,j(de,{onResize:C,disabled:!(p||P)},{default:function(){return[he(j("textarea",g(g({},I),{},{ref:i}),null),[[ve]])]}})};ne(function(){return e.value},function(){Z(function(){S()})}),me(function(){Z(function(){S()})});var T=re();return c({resizeTextarea:S,textArea:i,instance:T}),function(){return F()}}});const Te=Ee;function le(d,e){return H(d||"").slice(0,e).join("")}function W(d,e,r,n){var m=r;return d?m=le(r,n):H(e||"").length<r.length&&H(r||"").length>n&&(m=e),m}const Pe=ae({compatConfig:{MODE:3},name:"ATextarea",inheritAttrs:!1,props:ie(),setup:function(e,r){var n=r.attrs,m=r.expose,c=r.emit,b=ce(),v=w(e.value===void 0?e.defaultValue:e.value),i=w(),u=w(""),f=fe("input",e),s=f.prefixCls,S=f.size,E=f.direction,C=J(function(){return e.showCount===""||e.showCount||!1}),F=J(function(){return Number(e.maxlength)>0}),T=w(!1),A=w(),h=w(0),p=function(t){T.value=!0,A.value=u.value,h.value=t.currentTarget.selectionStart,c("compositionstart",t)},P=function(t){T.value=!1;var a=t.currentTarget.value;if(F.value){var o,x=h.value>=e.maxlength+1||h.value===((o=A.value)===null||o===void 0?void 0:o.length);a=W(x,A.value,a,e.maxlength)}a!==u.value&&(_(a),U(t.currentTarget,t,G,a)),c("compositionend",t)},k=re();ne(function(){return e.value},function(){"value"in k.vnode.props;var l;v.value=(l=e.value)!==null&&l!==void 0?l:""});var D=function(t){var a;Se((a=i.value)===null||a===void 0?void 0:a.textArea,t)},Y=function(){var t,a;(t=i.value)===null||t===void 0||(a=t.textArea)===null||a===void 0||a.blur()},_=function(t,a){v.value!==t&&(e.value===void 0?v.value=t:Z(function(){if(i.value.textArea.value!==u.value){var o,x,y;(o=i.value)===null||o===void 0||(x=(y=o.instance).update)===null||x===void 0||x.call(y)}}),Z(function(){a&&a()}))},I=function(t){t.keyCode===13&&c("pressEnter",t),c("keydown",t)},X=function(t){var a=e.onBlur;a==null||a(t),b.onFieldBlur()},G=function(t){c("update:value",t.target.value),c("change",t),c("input",t),b.onFieldChange()},oe=function(t){U(i.value.textArea,t,G),_("",function(){D()})},q=function(t){var a=t.target.composing,o=t.target.value;if(T.value=!!(t.isComposing||a),!(T.value&&e.lazy||v.value===o)){if(F.value){var x=t.target,y=x.selectionStart>=e.maxlength+1||x.selectionStart===o.length||!x.selectionStart;o=W(y,u.value,o,e.maxlength)}U(t.currentTarget,t,G,o),_(o)}},ue=function(){var t,a,o,x=n.style,y=n.class,O=e.bordered,M=O===void 0?!0:O,N=g(g(g({},ee(e,["allowClear"])),n),{},{style:C.value?{}:x,class:(t={},V(t,"".concat(s.value,"-borderless"),!M),V(t,"".concat(y),y&&!C.value),V(t,"".concat(s.value,"-sm"),S.value==="small"),V(t,"".concat(s.value,"-lg"),S.value==="large"),t),showCount:null,prefixCls:s.value,onInput:q,onChange:q,onBlur:X,onKeydown:I,onCompositionstart:p,onCompositionend:P});return(a=e.valueModifiers)!==null&&a!==void 0&&a.lazy&&delete N.onInput,j(Te,g(g({},N),{},{id:(o=N.id)!==null&&o!==void 0?o:b.id.value,ref:i,maxlength:e.maxlength}),null)};return m({focus:D,blur:Y,resizableTextArea:i}),xe(function(){var l=be(v.value);!T.value&&F.value&&(e.value===null||e.value===void 0)&&(l=le(l,e.maxlength)),u.value=l}),function(){var l=e.maxlength,t=e.bordered,a=t===void 0?!0:t,o=e.hidden,x=n.style,y=n.class,O=g(g(g({},e),n),{},{prefixCls:s.value,inputType:"text",handleReset:oe,direction:E.value,bordered:a,style:C.value?void 0:x}),M=j(ze,g(g({},O),{},{value:u.value}),{element:ue});if(C.value){var N=H(u.value).length,B="";$(C.value)==="object"?B=C.value.formatter({count:N,maxlength:l}):B="".concat(N).concat(F.value?" / ".concat(l):""),M=j("div",{hidden:o,class:te("".concat(s.value,"-textarea"),V({},"".concat(s.value,"-textarea-rtl"),E.value==="rtl"),"".concat(s.value,"-textarea-show-count"),y),style:x,"data-count":$(B)!=="object"?B:void 0},[M])}return M}}});export{Pe as T};
|