import PropTypes from 'prop-types' import { Button, Flex, Input, InputNumber } from 'antd' const ArrayInput = ({ value = [], onChange, disabled = false, numeric = false, min, max, step, placeholder }) => { const values = Array.isArray(value) ? value : [] const updateValue = (index, nextValue) => { const nextValues = [...values] nextValues[index] = nextValue onChange?.(nextValues) } const removeValue = (index) => { onChange?.(values.filter((_, valueIndex) => valueIndex !== index)) } return ( {values.map((item, index) => ( {numeric ? ( updateValue(index, nextValue)} min={min} max={max} step={step} placeholder={placeholder} disabled={disabled} style={{ flex: 1 }} /> ) : ( updateValue(index, event.target.value)} placeholder={placeholder} disabled={disabled} style={{ flex: 1 }} /> )} ))} ) } ArrayInput.propTypes = { value: PropTypes.array, onChange: PropTypes.func, disabled: PropTypes.bool, numeric: PropTypes.bool, min: PropTypes.number, max: PropTypes.number, step: PropTypes.number, placeholder: PropTypes.string } export default ArrayInput