!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:()=>m});var n=r(6031),o=r.n(n),u=r(2462),l=r.n(u),a=r(2015),i=r.n(a),s=r(9825),p=r.n(s),c=r(8619),d=r(3294);const f=["name","label","maxLength","required"],b=e=>{var t;let{name:r,label:n,maxLength:u,required:a=!1}=e,s=l()(e,f);const[p,b]=(0,d.useField)(r),m=(null===(t=p.value)||void 0===t?void 0:t.length)||0;let y="";return n&&(y=a?`${n} *`:n),i().createElement(c.Box,null,i().createElement(c.TextField,o()({name:r,label:y},p,{onBlur:p.onBlur,margin:"normal",error:b.touched&&Boolean(b.error),helperText:b.touched&&b.error,slotProps:{htmlInput:{maxLength:u}}},s)),u&&i().createElement(c.Typography,{sx:{fontSize:"1.2rem",color:"#00000099",pl:2}},u-m+" characters left"))};b.propTypes={name:p().string.isRequired,label:p().string,maxLength:p().number,required:p().bool};const m=b},3209:(e,t,r)=>{r.d(t,{At:()=>n,tv:()=>o});const n=100,o=2},1116:e=>{e.exports=require("@babel/runtime/helpers/defineProperty")},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 u=t[n]={exports:{}};return e[n](u,u.exports,r),u.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:()=>j});var o=r(6031),u=r.n(o),l=r(1116),a=r.n(l),i=r(2462),s=r.n(i),p=r(2015),c=r.n(p),d=r(9825),f=r.n(d),b=r(8619),m=r(3294),y=r(9314),v=r(3209);const g=["name","label","inCents","inputProps"];function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const O=["e","E","+","-"],P=e=>{let{name:t,label:r,inCents:n=!1,inputProps:o={step:.01}}=e,l=s()(e,g);const[a,i,d]=(0,m.useField)(t),[f,x]=(0,p.useState)(!1),[P,j]=(0,p.useState)(!1),[q,S]=(0,p.useState)(""),w=()=>{if(f||null==a.value)return"";if(0===a.value)return"0";const e=n?a.value/v.At:a.value;return String(Number(e.toFixed(v.tv)))};return c().createElement(y.default,u()({name:t,label:r,type:"number",value:(()=>{if(P)return q;if(f)return"";if(null==a.value||0===a.value)return 0===a.value?0:"";const e=w(),t=e.indexOf(".");return-1===t?`${e}.00`:e.length-t-1==1?`${e}0`:e})(),onChange:e=>{const t=e.target.value;if(S(t),""===t)return x(!0),void d.setValue(0);x(!1);const r=Number(t),o=n?Math.round(r*v.At):r;d.setValue(o)},onFocus:()=>{j(!0),S(w())},onBlur:e=>{j(!1),l.onBlur&&l.onBlur(e)},slotProps:{input:{startAdornment:c().createElement(b.InputAdornment,{position:"start"},"$")}},inputProps:h({min:0,inputMode:"decimal"},o),onKeyDown:e=>{O.includes(e.key)&&(e.preventDefault(),e.stopPropagation())}},l))};P.propTypes={name:f().string.isRequired,label:f().string};const j=P;return n})()));
//# sourceMappingURL=price-field.js.map