import { useCallback, useMemo } from "react"; import { InputDateRange, InputDateSingle, InputMultiSelect, InputMultiSelectProps, InputText, TagsSelector } from "Components/Inputs"; import { useTypemapSettings } from "Components/UserSettings"; import { InputEnum, InputValuesMap } from "../types"; type ItemTypeProps = Omit; function ItemType({ value, setValue }: ItemTypeProps){ const [typemap] = useTypemapSettings(); const typeOptions = useMemo(() => Object.keys(typemap).map(k => ({ value: k, label: typemap[k] })), [typemap]); return ; } type ItemTagsProps = { setValue: (value: string[]) => void, value: string[] }; function ItemTags({ value, setValue }: ItemTagsProps){ const onSelect = useCallback((tag) => setValue([...value, tag]), [setValue, value]); const onRemove = useCallback((tag) => setValue(value.filter(val => val != tag)), [setValue, value]); return ; } type InputComponentProps = { setValue: T extends InputEnum ? ((value: InputValuesMap[T]) => void) : () => void, value: T extends InputEnum ? InputValuesMap[T] : null }; function InputComponent({ inputType, ...props }: { inputType: T } & InputComponentProps){ switch (inputType) { case InputEnum.ITEM_TYPE: return } />; case InputEnum.ITEM_TAGS: return } />; case InputEnum.DATE: return } />; case InputEnum.DATE_RANGE: return } />; case InputEnum.TEXT: return } />; case null: default: return null; } } export default InputComponent;