!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:()=>f});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),c=r(8619),d=r(3294);const m=["name","label","maxLength","required"],b=e=>{var t;let{name:r,label:n,maxLength:l,required:u=!1}=e,s=a()(e,m);const[p,b]=(0,d.useField)(r),f=(null===(t=p.value)||void 0===t?void 0:t.length)||0;let y="";return n&&(y=u?`${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:l}}},s)),l&&i().createElement(c.Typography,{sx:{fontSize:"1.2rem",color:"#00000099",pl:2}},l-f+" characters left"))};b.propTypes={name:p().string.isRequired,label:p().string,maxLength:p().number,required:p().bool};const f=b},3209:(e,t,r)=>{r.d(t,{At:()=>n,eM:()=>o});const n=100,o={AMOUNT:"Amount",RATE:"Rate"}},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 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:()=>P});var o=r(6031),l=r.n(o),a=r(1116),u=r.n(a),i=r(2462),s=r.n(i),p=r(2015),c=r.n(p),d=r(9825),m=r.n(d),b=r(8619),f=r(3294),y=r(9314),v=r(3209);const g=["name","label","discountType","inCents","disabled"];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){u()(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","+","-"],j=e=>{let{name:t,label:r,discountType:n,inCents:o=!1,disabled:a=!1}=e,u=s()(e,g);const[i,d,m]=(0,f.useField)(t),[x,j]=(0,p.useState)(!1),P=null===d.initialValue?null:0,T=n===v.eM.RATE?{endAdornment:c().createElement(b.InputAdornment,{position:"end"},"%")}:{startAdornment:c().createElement(b.InputAdornment,{position:"start"},"$")},q=n===v.eM.RATE?{max:100,inputMode:"numeric",step:1}:{inputMode:"decimal",step:1};return c().createElement(y.default,l()({name:t,label:r,value:(()=>x?"":null==i.value||0===i.value?0===i.value?0:"":o?i.value/v.At:i.value)(),onChange:e=>{const t=e.target.value;if(""===t)return j(!0),void m.setValue(P);j(!1);const r=Number(t),n=o?r*v.At:r;m.setValue(n)},type:"number",disabled:a,slotProps:{input:h({},T),htmlInput:h({min:0},q)},onKeyDown:e=>{O.includes(e.key)&&(e.preventDefault(),e.stopPropagation())}},u))};j.propTypes={name:m().string.isRequired,label:m().string};const P=j;return n})()));
//# sourceMappingURL=discount-field.js.map