import{r as s,bh as U,y as k,cr as x,B as A,j as l,br as B,bF as L,bs as P,ba as D,bt as j}from"./index.D1HZENZx.js";import{u as w}from"./uniqueId.D2FMWUEI.js";import{u as O,a as _,b as K}from"./useOnInputChange.BOKIIdJ1.js";import{I as $}from"./InputInstructions.DB3QGNJP.js";import{a as q}from"./useBasicWidgetState.urnZLANY.js";import{T as G}from"./textarea.Cb_uJt5U.js";import"./inputUtils.CQWz5UKz.js";import"./FormClearHelper.Ct2rwLXo.js";import"./base-input.CQBQT24M.js";const T=(a,t)=>a.getStringValue(t)??t.default??null,N=a=>a.default??null,J=a=>a.value??null,M=(a,t,o,u)=>{t.setStringValue(a,o.value,{fromUi:o.fromUi},u)},Q=({disabled:a,element:t,widgetMgr:o,fragmentId:u})=>{var f;const p=s.useRef(w("text_area_")).current,{values:[W],elementRef:S}=U(s.useMemo(()=>["width"],[])),[r,n]=s.useState(!1),[y,b]=s.useState(!1),[i,d]=s.useState(T(o,t)??null),I=s.useCallback(()=>{d(t.default??null),n(!0)},[t]),[F,c]=q({getStateFromWidgetMgr:T,getDefaultStateFromProto:N,getCurrStateFromProto:J,updateWidgetMgrState:M,element:t,widgetMgr:o,fragmentId:u,onFormCleared:I});O(F,i,d,r);const e=k(),m=s.useCallback(()=>{n(!1),c({value:i,fromUi:!0})},[i,c]),V=s.useCallback(()=>{r&&m(),b(!1)},[r,m]),v=s.useCallback(()=>{b(!0)},[]),C=_({formId:t.formId,maxChars:t.maxChars,setDirty:n,setUiValue:d,setValueWithSource:c}),R=K(t.formId,m,r,o,u,!0),{height:g,placeholder:z,formId:h}=t,E=x({formId:h})?o.allowFormEnterToSubmit(h):r,H=y&&W>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:z,onBlur:V,onFocus:v,onChange:C,onKeyDown:R,"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:x({formId:h}),allowEnterToSubmit:E})]})},it=s.memo(Q);export{it as default};
