import { Stack, TextInput, Select, Checkbox } from '@mantine/core'; import { useTranslation } from 'react-i18next'; import { SPLIT_MODES, SPLIT_TYPES, type SplitMode, type SplitType } from '../../../constants/splitConstants'; export interface SplitParameters { pages: string; hDiv: string; vDiv: string; merge: boolean; splitType: SplitType | ''; splitValue: string; bookmarkLevel: string; includeMetadata: boolean; allowDuplicates: boolean; } export interface SplitSettingsProps { mode: SplitMode | ''; onModeChange: (mode: SplitMode | '') => void; parameters: SplitParameters; onParameterChange: (parameter: keyof SplitParameters, value: string | boolean) => void; disabled?: boolean; } const SplitSettings = ({ mode, onModeChange, parameters, onParameterChange, disabled = false }: SplitSettingsProps) => { const { t } = useTranslation(); const renderByPagesForm = () => ( onParameterChange('pages', e.target.value)} disabled={disabled} /> ); const renderBySectionsForm = () => ( onParameterChange('hDiv', e.target.value)} placeholder={t("split-by-sections.horizontal.placeholder", "Enter number of horizontal divisions")} disabled={disabled} /> onParameterChange('vDiv', e.target.value)} placeholder={t("split-by-sections.vertical.placeholder", "Enter number of vertical divisions")} disabled={disabled} /> onParameterChange('merge', e.currentTarget.checked)} disabled={disabled} /> ); const renderBySizeOrCountForm = () => ( v && onModeChange(v)} disabled={disabled} data={[ { value: SPLIT_MODES.BY_PAGES, label: t("split.header", "Split by Pages") + " (e.g. 1,3,5-10)" }, { value: SPLIT_MODES.BY_SECTIONS, label: t("split-by-sections.title", "Split by Grid Sections") }, { value: SPLIT_MODES.BY_SIZE_OR_COUNT, label: t("split-by-size-or-count.title", "Split by Size or Count") }, { value: SPLIT_MODES.BY_CHAPTERS, label: t("splitByChapters.title", "Split by Chapters") }, ]} /> {/* Parameter Form */} {mode === SPLIT_MODES.BY_PAGES && renderByPagesForm()} {mode === SPLIT_MODES.BY_SECTIONS && renderBySectionsForm()} {mode === SPLIT_MODES.BY_SIZE_OR_COUNT && renderBySizeOrCountForm()} {mode === SPLIT_MODES.BY_CHAPTERS && renderByChaptersForm()} ); } export default SplitSettings;