import React from 'react'; import Button from '../button/button'; import HStack from '../hstack/hstack'; import IconButton from '../icon-button/icon-button'; import Stack from '../stack/stack'; interface IStreamfield { values: any[], onAddItem?: () => void, onRemoveItem?: (i: number) => void, onChange: (values: any[]) => void, component: React.ComponentType<{ onChange: (value: any) => void, value: any }>, maxItems?: number, } /** List of inputs that can be added or removed. */ const Streamfield: React.FC = ({ values, onAddItem, onRemoveItem, onChange, component: Component, maxItems = Infinity, }) => { const handleChange = (i: number) => { return (value: any) => { const newData = [...values]; newData[i] = value; onChange(newData); }; }; return ( {values.map((value, i) => ( {onRemoveItem && ( onRemoveItem(i)} /> )} ))} {onAddItem && ( )} ); }; export default Streamfield;