import{__assign as r}from'./../../ext-esm/tslib/tslib.es6.js';import{jsx as e,jsxs as o}from"react/jsx-runtime";import{InputAdornment as a,TextField as n}from"@material-ui/core";import{useCallback as t,useMemo as s,isValidElement as l,cloneElement as i}from"react";import d from"classnames";import{TextTruncated as m}from"../TextTruncated/TextTruncated.js";import{LoaderCircular as u}from"../LoaderCircular/LoaderCircular.js";import{useShrink as c}from"./useShrink.js";import p from"./TextInput.scss.js";var f=function(r){return l(r)?i(r,{size:16}):r?e("p",{children:r}):null},h={error:p.error,loading:""},x={normal:p.normal,dense:p.dense},g=function(l){var i=l.type,g=l.className,v=l.testId,b=l.prefix,T=l.suffix,N=l.onFocus,j=l.onBlur,y=l.value,C=void 0===y?"":y,A=l.message,I=l.spacing,z=void 0===I?"normal":I,B=l.onChange,F=l.status,L=l.placeholder,O=l.disabled,k=l.label,P=t((function(r){return null==B?void 0:B(r.target.value,r)}),[B]),S=s((function(){return{startAdornment:b&&e(a,{position:"start",className:p.adornment,disableTypography:!0,children:f(b)}),endAdornment:(T||"loading"===F)&&o(a,{position:"end",className:p.adornment,disableTypography:!0,children:["loading"===F&&e(u,{size:"xs",className:p.loader}),f(T)]})}}),[b,T,F]),W=c({propOnFocus:N,propOnBlur:j,value:C,prefix:b,suffix:T,status:F});return e("label",{className:d(p.root,F&&h[F],x[z],g),"data-testid":v,children:e(n,r({value:C,onChange:P,label:e(m,{children:k}),InputProps:S,type:i,fullWidth:!0,margin:z,helperText:A,error:"error"===F,disabled:O,placeholder:L},W))})};g.Affix=function(r){var o=r.children,a=r.className;return e("p",{className:a,children:o})};export{g as TextInput};
