import { ArrowRightOutlined, DeleteOutlined } from '@ant-design/icons'; import { Button, Col, Row } from 'antd'; import React, { useState } from 'react'; import { StringInput } from './StringInput'; import { TypeInput, TypeInputProps } from './TypeInput'; const mapToObj = (map: Map) => { const obj = new Object(); map.forEach((val: [string, any]) => { obj[val[0] as keyof typeof obj] = val[1]; }); return obj; }; export const DictionaryInput = ({ set, isPrimary, property }: TypeInputProps) => { const [contents, setContents] = useState( new Map() ); const [totalSize, setTotalSize] = useState(0); return ( {Array.from(contents.entries()).map( (val: [number, [string, unknown]]) => { const value = val[1]; return ( { const realValue = contents.get(val[0]); if (realValue === undefined) { return; } contents.set(val[0], [val, realValue[1]]); setContents(contents); set(mapToObj(contents)); }} property={{ type: 'string', optional: false, }} key={val[0]} > { const stringKey = contents.get(val[0]); if (!stringKey) { return; } contents.set(val[0], [stringKey[0], value]); // setContents(contents); set(mapToObj(contents)); }} > ); } )} ); };