import{j as e,D as g,S as u,o as m}from"./vendor-mui-CBBEb17G.js";import{a as p}from"./vendor-react-BBazpZul.js";import{aP as y,bE as f,I as x}from"./index-DdWwwZXu.js";const I={number:0,string:"",money:0,percent:0},w=C=>{const{onClose:t,onChange:d,value:s,type:o,minValue:h,maxValue:j,label:c}=C,[r,a]=p.useState(s??I[o]),i=()=>{d(r),t()},l=n=>{n.key==="Escape"&&t(),n.key==="Enter"&&i()};return p.useEffect(()=>{s&&a(s)},[s]),e.jsx(g,{onClose:t,open:!0,children:e.jsxs(u,{direction:"row",alignItems:"center",spacing:1,p:1,children:[o==="string"?e.jsx(y,{label:c,autoFocus:!0,onChange:n=>a(n),value:r,onKeyDown:l}):e.jsx(f,{label:c,autoFocus:!0,onChange:n=>a(n),value:+r,isMoney:o==="money",minValue:o==="percent"?0:h,maxValue:o==="percent"?100:j,onKeyDown:l}),e.jsxs(u,{direction:"row",alignItems:"center",children:[e.jsx(m,{color:"success",onClick:()=>i(),children:e.jsx(x.CheckCircleIcon,{})}),e.jsx(m,{color:"error",onClick:()=>t(),children:e.jsx(x.CloseIcon,{})})]})]})})};export{w as C};
