import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{__rest as a}from"../../../_virtual/_tslib.js";import r,{forwardRef as s,useMemo as l,useState as n,useCallback as o}from"react";import i from"classnames";import{getTestId as d}from"../../tests/testIds.js";import{ComponentDefaultTestId as m,ComponentVibeId as c}from"../../tests/constants.js";import u from"./TextArea.module.scss.js";import x from"../Text/Text.js";import p from"../HiddenText/HiddenText.js";import f from"../../../components/layout/dist/Flex/Flex.js";var h={small:3,large:4},g=s((function(s,g){var b=s.size,v=void 0===b?"small":b,T=s.rows,E=s.label,y=s.helpText,j=s.success,w=s.error,A=s.className,C=s["data-testid"],N=s.id,_=s.disabled,z=s.readOnly,L=s.required,O=s.maxLength,q=s.allowExceedingMaxLength,F=s.onChange,H=s.value,M=s.resize,P=void 0===M||M,R=s.showCharCount,X=void 0!==R&&R,B=a(s,["size","rows","label","helpText","success","error","className","data-testid","id","disabled","readOnly","required","maxLength","allowExceedingMaxLength","onChange","value","resize","showCharCount"]),I=T||h[v],W=y&&"".concat(N,"-help-text"),k=q&&"".concat(N,"-allow-exceeding-max-length"),D=l((function(){return[W,k].filter((function(e){return!!e})).join(" ")||void 0}),[W,k]),G=n((null==H?void 0:H.length)||0),J=e(G,2),K=J[0],Q=J[1],S=w||"number"==typeof O&&K>O,U=o((function(e){Q(e.target.value.length),null==F||F(e)}),[F]);return r.createElement("div",{className:i(u.textAreaWrapper,t(t(t(t({},u.error,S),u.success,j),u.disabled,_),u.readOnly,z),A),"data-testid":C||d(m.TEXT_AREA,N),"data-vibe":c.TEXT_AREA},E&&r.createElement("label",{className:i(u.label,t({},u.required,L)),htmlFor:N},E),r.createElement("textarea",Object.assign({},B,{id:N,maxLength:"number"!=typeof O||q?void 0:O,ref:g,value:H,disabled:_,readOnly:z,required:L,rows:I,className:i(u.textArea,[u[v]],t({},u.resize,P)),"aria-invalid":S,"aria-describedby":D,onChange:U})),(X||y)&&r.createElement(f,{gap:"xs",justify:"space-between",className:i(u.subTextContainer)},y&&r.createElement(x,{className:i(u.helpText),color:"inherit",id:W},y),X&&r.createElement(r.Fragment,null,r.createElement(x,{className:u.limitText},K,"number"==typeof O&&"/".concat(O)),r.createElement(p,{id:k,text:"".concat(K," out of ").concat(O)}))))}));export{g as default};
//# sourceMappingURL=TextArea.js.map
