import React from "react"; import { Stack, Text, Select, NumberInput, Group, Divider, UnstyledButton, useMantineTheme, useMantineColorScheme } from "@mantine/core"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; import { useTranslation } from "react-i18next"; import GroupedFormatDropdown from "./GroupedFormatDropdown"; import { ConvertParameters } from "../../../hooks/tools/convert/useConvertParameters"; import { FROM_FORMAT_OPTIONS, TO_FORMAT_OPTIONS, COLOR_TYPES, OUTPUT_OPTIONS, } from "../../../constants/convertConstants"; interface ConvertSettingsProps { parameters: ConvertParameters; onParameterChange: (key: keyof ConvertParameters, value: any) => void; getAvailableToExtensions: (fromExtension: string) => Array<{value: string, label: string, group: string}>; disabled?: boolean; } const ConvertSettings = ({ parameters, onParameterChange, getAvailableToExtensions, disabled = false }: ConvertSettingsProps) => { const { t } = useTranslation(); const theme = useMantineTheme(); const { colorScheme } = useMantineColorScheme(); const handleFromExtensionChange = (value: string | null) => { if (value) { onParameterChange('fromExtension', value); // Reset to extension when from extension changes onParameterChange('toExtension', ''); // Reset format-specific options onParameterChange('imageOptions', { colorType: COLOR_TYPES.COLOR, dpi: 300, singleOrMultiple: OUTPUT_OPTIONS.MULTIPLE, }); } }; const handleToExtensionChange = (value: string) => { onParameterChange('toExtension', value); // Reset format-specific options when target extension changes onParameterChange('imageOptions', { colorType: COLOR_TYPES.COLOR, dpi: 300, singleOrMultiple: OUTPUT_OPTIONS.MULTIPLE, }); }; return ( {/* Format Selection */} {t("convert.convertFrom", "Convert from")}: val && onParameterChange('imageOptions', { ...parameters.imageOptions, colorType: val as typeof COLOR_TYPES[keyof typeof COLOR_TYPES] })} data={[ { value: COLOR_TYPES.COLOR, label: t("convert.color", "Color") }, { value: COLOR_TYPES.GREYSCALE, label: t("convert.greyscale", "Greyscale") }, { value: COLOR_TYPES.BLACK_WHITE, label: t("convert.blackwhite", "Black & White") }, ]} disabled={disabled} /> typeof val === 'number' && onParameterChange('imageOptions', { ...parameters.imageOptions, dpi: val })} min={72} max={600} step={1} disabled={disabled} /> val && onParameterChange('imageOptions', { ...parameters.imageOptions, colorType: val as typeof COLOR_TYPES[keyof typeof COLOR_TYPES] })} data={[ { value: COLOR_TYPES.COLOR, label: t("convert.color", "Color") }, { value: COLOR_TYPES.GREYSCALE, label: t("convert.greyscale", "Greyscale") }, { value: COLOR_TYPES.BLACK_WHITE, label: t("convert.blackwhite", "Black & White") }, ]} disabled={disabled} /> )} ); }; export default ConvertSettings;