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