'use client'; import { useCallback, useMemo } from 'react'; import AutoSizer from 'react-virtualized-auto-sizer'; import { FixedSizeList, ListChildComponentProps } from 'react-window'; import { FiFolder } from 'react-icons/fi'; import { Box, Checkbox, Code } from '@chakra-ui/react'; import { TestCard } from '#components/Backtest/TestCard'; import { EmptyState } from '#ui'; import type { Items } from '#app/types/ui'; interface ListProps { tests: Items; loadding: boolean; fulFilled: boolean; noData: boolean; selectedTestNames: string[]; onToggleSelection: (testName: string, checked: boolean) => void; overscan?: number; } const ITEM_HEIGHT = 548; export const TestList = ({ tests, loadding, fulFilled, noData, selectedTestNames, onToggleSelection, overscan = 2, }: ListProps) => { const selectedTestSet = useMemo( () => new Set(selectedTestNames), [selectedTestNames], ); const itemKey = useCallback( (index: number) => tests[index]?.value ?? String(index), [tests], ); const Row = useCallback( ({ index, style }: ListChildComponentProps) => { const item = tests[index]; return ( onToggleSelection(item.value, details.checked === true) } > } > ); }, [onToggleSelection, selectedTestSet, tests], ); if (!fulFilled && loadding) { return ( <> ); } if (fulFilled && !loadding && noData) { return ( Please run yarn backtest --help } /> ); } return ( <> {({ height: h, width }) => ( {Row} )} ); };