!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={9314:(e,t,r)=>{r.d(t,{default:()=>v});var n=r(6031),o=r.n(n),l=r(2462),a=r.n(l),u=r(2015),i=r.n(u),s=r(9825),p=r.n(s),d=r(8619),c=r(3294);const m=["name","label","maxLength","required"],f=e=>{var t;let{name:r,label:n,maxLength:l,required:u=!1}=e,s=a()(e,m);const[p,f]=(0,c.useField)(r),v=(null===(t=p.value)||void 0===t?void 0:t.length)||0;let b="";return n&&(b=u?`${n} *`:n),i().createElement(d.Box,null,i().createElement(d.TextField,o()({name:r,label:b},p,{onBlur:p.onBlur,margin:"normal",error:f.touched&&Boolean(f.error),helperText:f.touched&&f.error,slotProps:{htmlInput:{maxLength:l}}},s)),l&&i().createElement(d.Typography,{sx:{fontSize:"1.2rem",color:"#00000099",pl:2}},l-v+" characters left"))};f.propTypes={name:p().string.isRequired,label:p().string,maxLength:p().number,required:p().bool};const v=f},6031:e=>{e.exports=require("@babel/runtime/helpers/extends")},2462:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},8619:e=>{e.exports=require("@mui/material")},3294:e=>{e.exports=require("formik")},9825:e=>{e.exports=require("prop-types")},2015:e=>{e.exports=require("react")}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var l=t[n]={exports:{}};return e[n](l,l.exports,r),l.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var n={};r.r(n),r.d(n,{default:()=>h});var o=r(6031),l=r.n(o),a=r(2462),u=r.n(a),i=r(2015),s=r.n(i),p=r(9825),d=r.n(p),c=r(8619),m=r(3294),f=r(9314);const v=["name","label","displayUnit","valueUnit"],b=["e","E","+","-",".",","],y={B:0,KB:1,MB:2},x=e=>1024**y[e],g=e=>{let{name:t,label:r,displayUnit:n,valueUnit:o}=e,a=u()(e,v);const[p,d,y]=(0,m.useField)(t),[g,h]=(0,i.useState)(!1),q=null===d.initialValue?null:0,j=x(o)/x(n);return s().createElement(f.default,l()({name:t,label:r,type:"number",value:(()=>g?"":null==p.value||0===p.value?0===p.value?0:"":Math.floor(p.value*j))(),onChange:e=>{const t=e.target.value;if(""===t)return h(!0),void y.setValue(q);h(!1),y.setValue(Number(t)/j)},slotProps:{input:{endAdornment:s().createElement(c.InputAdornment,{position:"end"},n)},htmlInput:{min:0,inputMode:"numeric",step:1}},onKeyDown:e=>{if(b.includes(e.key))return e.preventDefault(),void e.stopPropagation();"0"!==e.key||""!==e.target.value&&"0"!==e.target.value||(e.preventDefault(),e.stopPropagation())}},a))};g.propTypes={name:d().string.isRequired,label:d().string.isRequired,displayUnit:d().oneOf(Object.keys(y)),valueUnit:d().oneOf(Object.keys(y))},g.defaultProps={displayUnit:"MB",valueUnit:"B"};const h=g;return n})()));
//# sourceMappingURL=file-size-field.js.map