import{r as s,aO as U,z as k,cr as x,C as A,j as l,bq as L,bG as P,br as B,b8 as D,bs as j}from"./index.BEHais2d.js";import{u as O}from"./uniqueId.C03hvAF0.js";import{u as _,a as q,b as w}from"./useOnInputChange.DqPkFylT.js";import{I as G}from"./InputInstructions.Dh8ccyYH.js";import{a as K}from"./useBasicWidgetState.DxtD7xs-.js";import{T as $}from"./textarea.FHoad42C.js";import"./inputUtils.CQWz5UKz.js";import"./FormClearHelper.CpsBciie.js";import"./base-input.C3m059Ja.js";const T=(a,t)=>a.getStringValue(t)??t.default??null,N=a=>a.default??null,J=a=>a.value??null,Q=(a,t,o,u)=>{t.setStringValue(a,o.value,{fromUi:o.fromUi},u)},X=({disabled:a,element:t,widgetMgr:o,fragmentId:u})=>{var g;const p=s.useRef(O("text_area_")).current,[W,S]=U(),[r,n]=s.useState(!1),[C,b]=s.useState(!1),[i,d]=s.useState(()=>T(o,t)??null),I=s.useCallback(()=>{d(t.default??null),n(!0)},[t]),[V,c]=K({getStateFromWidgetMgr:T,getDefaultStateFromProto:N,getCurrStateFromProto:J,updateWidgetMgrState:Q,element:t,widgetMgr:o,fragmentId:u,onFormCleared:I});_(V,i,d,r);const e=k(),m=s.useCallback(()=>{n(!1),c({value:i,fromUi:!0})},[i,c]),y=s.useCallback(()=>{r&&m(),b(!1)},[r,m]),F=s.useCallback(()=>{b(!0)},[]),v=q({formId:t.formId,maxChars:t.maxChars,setDirty:n,setUiValue:d,setValueWithSource:c}),E=w(t.formId,m,r,o,u,!0),{height:f,placeholder:z,formId:h}=t,R=x({formId:h})?o.allowFormEnterToSubmit(h):r,H=C&&W>e.breakpoints.hideWidgetDetails;return A("div",{className:"stTextArea","data-testid":"stTextArea",ref:S,children:[l(j,{label:t.label,disabled:a,labelVisibility:L((g=t.labelVisibility)==null?void 0:g.value),htmlFor:p,children:t.help&&l(P,{children:l(B,{content:t.help,placement:D.TOP_RIGHT})})}),l($,{value:i??"",placeholder:z,onBlur:y,onFocus:F,onChange:v,onKeyDown:E,"aria-label":t.label,disabled:a,id:p,overrides:{Input:{style:{lineHeight:e.lineHeights.inputWidget,height:f?`${f}px`:"",minHeight:e.sizes.largestElementHeight,resize:"vertical",paddingRight:e.spacing.md,paddingLeft:e.spacing.md,paddingBottom:e.spacing.md,paddingTop:e.spacing.md,"::placeholder":{color:e.colors.fadedText60}}},Root:{props:{"data-testid":"stTextAreaRootElement"},style:{borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth}}}}),H&&l(G,{dirty:r,value:i??"",maxLength:t.maxChars,type:"multiline",inForm:x({formId:h}),allowEnterToSubmit:R})]})},it=s.memo(X);export{it as default};
