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