import React, { Fragment } from 'react'; import { Tab } from '@headlessui/react'; import { Info } from 'lucide-react'; import { SearchableSelect } from '../SearchableSelect'; import { DateSplitter } from './splitters/DateSplitter'; import { RandomSplitter } from './splitters/RandomSplitter'; import { PredefinedSplitter } from './splitters/PredefinedSplitter'; import { StratifiedSplitter } from './splitters/StratifiedSplitter'; import { KFoldSplitter } from './splitters/KFoldSplitter'; import { LeavePOutSplitter } from './splitters/LeavePOutSplitter'; import { SPLITTER_OPTIONS, DEFAULT_CONFIGS } from './splitters/constants'; import type { SplitterType, SplitConfig, ColumnConfig } from './splitters/types'; interface SplitConfiguratorProps { type: SplitterType; splitter_attributes: SplitConfig; columns: ColumnConfig[]; available_files: string[]; onChange: (type: SplitterType, attributes: SplitConfig) => void; } export function SplitConfigurator({ type, splitter_attributes, columns, available_files, onSplitterChange, onChange }: SplitConfiguratorProps) { const dateColumns = columns.filter(col => col.type === 'datetime').map(col => col.name); const handleTypeChange = (newType: SplitterType) => { onChange(newType, DEFAULT_CONFIGS[newType]); }; const handleSplitterChange = (type: SplitterType, newAttributes: SplitConfig) => { onChange(type, newAttributes); }; const renderSplitter = () => { switch (type) { case 'date': return ( handleSplitterChange(type, attrs)} /> ); case 'random': return ( handleSplitterChange(type, attrs)} /> ); case 'predefined': return ( handleSplitterChange(type, attrs)} /> ); case 'stratified': return ( handleSplitterChange(type, attrs)} /> ); case 'stratified_kfold': case 'group_kfold': return ( handleSplitterChange(type, attrs)} /> ); case 'group_shuffle': return ( handleSplitterChange(type, { groupColumn: attrs.targetColumn, testSize: attrs.testSize, validSize: attrs.validSize })} /> ); case 'leave_p_out': return ( handleSplitterChange(type, attrs)} /> ); default: return null; } }; return (
handleTypeChange(value as SplitterType)} />
{renderSplitter()}
); } export type { SplitterType }; export type { ColumnConfig };