This commit is contained in:
25
src/components/NumberInput.jsx
Normal file
25
src/components/NumberInput.jsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { InputNumber } from 'antd';
|
||||
|
||||
export default function NumberInput({ label, value, onChange, unit, min = 0, step = 1 }) {
|
||||
const handleChange = (newValue) => {
|
||||
const numValue = Math.max(min, newValue || 0);
|
||||
onChange(numValue);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="form-row">
|
||||
<label className="form-label">{label}</label>
|
||||
<InputNumber
|
||||
value={value}
|
||||
onChange={handleChange}
|
||||
min={min}
|
||||
step={step}
|
||||
placeholder="0"
|
||||
addonAfter={unit}
|
||||
size="large"
|
||||
style={{ width: '100%' }}
|
||||
controls={false}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user