mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-22 04:09:22 +00:00

# Description of Changes Implementation of Sanitize UI for V2. Also removes parameter validation from standard tool hooks because the logic would have to be duplicated between parameter handling and operation hooks, and the nicer workflow is for the tools to reject using the Go button if the validation fails, rather than the operation hook checking it, since that can't appear in the UI. Co-authored-by: James <james@crosscourtanalytics.com> Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Co-authored-by: ConnorYoh <40631091+ConnorYoh@users.noreply.github.com>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { Stack, Text, Checkbox } from "@mantine/core";
|
|
import { useTranslation } from "react-i18next";
|
|
import { SanitizeParameters, defaultParameters } from "../../../hooks/tools/sanitize/useSanitizeParameters";
|
|
|
|
interface SanitizeSettingsProps {
|
|
parameters: SanitizeParameters;
|
|
onParameterChange: (key: keyof SanitizeParameters, value: boolean) => void;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
const SanitizeSettings = ({ parameters, onParameterChange, disabled = false }: SanitizeSettingsProps) => {
|
|
const { t } = useTranslation();
|
|
|
|
const options = (Object.keys(defaultParameters) as Array<keyof SanitizeParameters>).map((key) => ({
|
|
key: key,
|
|
label: t(`sanitize.options.${key}`, key),
|
|
description: t(`sanitize.options.${key}.desc`, `${key} from the PDF`),
|
|
default: defaultParameters[key],
|
|
}));
|
|
|
|
return (
|
|
<Stack gap="md">
|
|
<Text size="sm" fw={500}>
|
|
{t('sanitize.options.title', 'Sanitization Options')}
|
|
</Text>
|
|
|
|
<Stack gap="sm">
|
|
{options.map((option) => (
|
|
<Checkbox
|
|
key={option.key}
|
|
checked={parameters[option.key]}
|
|
onChange={(event) => onParameterChange(option.key, event.currentTarget.checked)}
|
|
disabled={disabled}
|
|
label={
|
|
<div>
|
|
<Text size="sm">{option.label}</Text>
|
|
<Text size="xs" c="dimmed">{option.description}</Text>
|
|
</div>
|
|
}
|
|
/>
|
|
))}
|
|
</Stack>
|
|
|
|
<Text size="xs" c="dimmed">
|
|
{t('sanitize.options.note', 'Select the elements you want to remove from the PDF. At least one option must be selected.')}
|
|
</Text>
|
|
</Stack>
|
|
);
|
|
};
|
|
|
|
export default SanitizeSettings;
|