mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
# Description of Changes
- **What was changed**
- Added missing trailing semicolons across React components, utilities,
tests, and build/test configs to ensure consistent formatting.
- Normalized arrow-function assignments to end with semicolons (e.g.,
`const fn = () => { ... };`).
- Harmonized imports/exports and object literals in configuration files
to terminate statements with semicolons.
- Updated test setup files and mocks to consistently use semicolons.
- **Why the change was made**
- Aligns the codebase with ESLint/Prettier conventions to prevent
auto-format churn and avoid ASI (automatic semicolon insertion) edge
cases.
- Improves readability and produces cleaner diffs in future
contributions.
---
## Checklist
### General
- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings
### Documentation
- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)
### UI Changes (if applicable)
- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)
### Testing (if applicable)
- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.
---------
Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com>
164 lines
5.6 KiB
TypeScript
164 lines
5.6 KiB
TypeScript
import { Stack, TextInput, Checkbox, Anchor, Text } from '@mantine/core';
|
|
import LocalIcon from '../../shared/LocalIcon';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { SPLIT_METHODS } from '../../../constants/splitConstants';
|
|
import { SplitParameters } from '../../../hooks/tools/split/useSplitParameters';
|
|
|
|
export interface SplitSettingsProps {
|
|
parameters: SplitParameters;
|
|
onParameterChange: <K extends keyof SplitParameters>(key: K, value: SplitParameters[K]) => void;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
const SplitSettings = ({
|
|
parameters,
|
|
onParameterChange,
|
|
disabled = false
|
|
}: SplitSettingsProps) => {
|
|
const { t } = useTranslation();
|
|
|
|
const renderByPagesForm = () => (
|
|
<TextInput
|
|
label={t("split.splitPages", "Pages")}
|
|
placeholder={t("pageSelectionPrompt", "e.g. 1,3,5-10")}
|
|
value={parameters.pages}
|
|
onChange={(e) => onParameterChange('pages', e.target.value)}
|
|
disabled={disabled}
|
|
/>
|
|
);
|
|
|
|
const renderBySectionsForm = () => (
|
|
<Stack gap="sm">
|
|
<TextInput
|
|
label={t("split-by-sections.horizontal.label", "Horizontal Divisions")}
|
|
type="number"
|
|
min="0"
|
|
max="300"
|
|
value={parameters.hDiv}
|
|
onChange={(e) => onParameterChange('hDiv', e.target.value)}
|
|
placeholder={t("split-by-sections.horizontal.placeholder", "Enter number of horizontal divisions")}
|
|
disabled={disabled}
|
|
/>
|
|
<TextInput
|
|
label={t("split-by-sections.vertical.label", "Vertical Divisions")}
|
|
type="number"
|
|
min="0"
|
|
max="300"
|
|
value={parameters.vDiv}
|
|
onChange={(e) => onParameterChange('vDiv', e.target.value)}
|
|
placeholder={t("split-by-sections.vertical.placeholder", "Enter number of vertical divisions")}
|
|
disabled={disabled}
|
|
/>
|
|
<Checkbox
|
|
label={t("split-by-sections.merge", "Merge sections into one PDF")}
|
|
checked={parameters.merge}
|
|
onChange={(e) => onParameterChange('merge', e.currentTarget.checked)}
|
|
disabled={disabled}
|
|
/>
|
|
</Stack>
|
|
);
|
|
|
|
const renderSplitValueForm = () => {
|
|
let label, placeholder;
|
|
|
|
switch (parameters.method) {
|
|
case SPLIT_METHODS.BY_SIZE:
|
|
label = t("split.value.fileSize.label", "File Size");
|
|
placeholder = t("split.value.fileSize.placeholder", "e.g. 10MB, 500KB");
|
|
break;
|
|
case SPLIT_METHODS.BY_PAGE_COUNT:
|
|
label = t("split.value.pageCount.label", "Pages per File");
|
|
placeholder = t("split.value.pageCount.placeholder", "e.g. 5, 10");
|
|
break;
|
|
case SPLIT_METHODS.BY_DOC_COUNT:
|
|
label = t("split.value.docCount.label", "Number of Files");
|
|
placeholder = t("split.value.docCount.placeholder", "e.g. 3, 5");
|
|
break;
|
|
default:
|
|
label = t("split-by-size-or-count.value.label", "Split Value");
|
|
placeholder = t("split-by-size-or-count.value.placeholder", "e.g. 10MB or 5 pages");
|
|
}
|
|
|
|
return (
|
|
<TextInput
|
|
label={label}
|
|
placeholder={placeholder}
|
|
value={parameters.splitValue}
|
|
onChange={(e) => onParameterChange('splitValue', e.target.value)}
|
|
disabled={disabled}
|
|
/>
|
|
);
|
|
};
|
|
|
|
const renderByChaptersForm = () => (
|
|
<Stack gap="sm">
|
|
<TextInput
|
|
label={t("splitByChapters.bookmarkLevel", "Bookmark Level")}
|
|
type="number"
|
|
value={parameters.bookmarkLevel}
|
|
onChange={(e) => onParameterChange('bookmarkLevel', e.target.value)}
|
|
disabled={disabled}
|
|
/>
|
|
<Checkbox
|
|
label={t("splitByChapters.includeMetadata", "Include Metadata")}
|
|
checked={parameters.includeMetadata}
|
|
onChange={(e) => onParameterChange('includeMetadata', e.currentTarget.checked)}
|
|
disabled={disabled}
|
|
/>
|
|
<Checkbox
|
|
label={t("splitByChapters.allowDuplicates", "Allow Duplicate Bookmarks")}
|
|
checked={parameters.allowDuplicates}
|
|
onChange={(e) => onParameterChange('allowDuplicates', e.currentTarget.checked)}
|
|
disabled={disabled}
|
|
/>
|
|
</Stack>
|
|
);
|
|
|
|
const renderByPageDividerForm = () => (
|
|
<Stack gap="sm">
|
|
<Anchor
|
|
href="https://stirlingpdf.io/files/Auto%20Splitter%20Divider%20(with%20instructions).pdf"
|
|
target="_blank"
|
|
size="sm"
|
|
style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}
|
|
>
|
|
<LocalIcon icon="download-rounded" width="2rem" height="2rem" />
|
|
{t("autoSplitPDF.dividerDownload2", "Download 'Auto Splitter Divider (with instructions).pdf'")}
|
|
</Anchor>
|
|
|
|
<Checkbox
|
|
label={t("autoSplitPDF.duplexMode", "Duplex Mode (Front and back scanning)")}
|
|
checked={parameters.duplexMode}
|
|
onChange={(e) => onParameterChange('duplexMode', e.currentTarget.checked)}
|
|
disabled={disabled}
|
|
/>
|
|
</Stack>
|
|
);
|
|
|
|
// Don't render anything if no method is selected
|
|
if (!parameters.method) {
|
|
return (
|
|
<Stack gap="sm">
|
|
<Text c="dimmed" ta="center">
|
|
{t("split.settings.selectMethodFirst", "Please select a split method first")}
|
|
</Text>
|
|
</Stack>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Stack gap="md">
|
|
{/* Method-Specific Form */}
|
|
{parameters.method === SPLIT_METHODS.BY_PAGES && renderByPagesForm()}
|
|
{parameters.method === SPLIT_METHODS.BY_SECTIONS && renderBySectionsForm()}
|
|
{(parameters.method === SPLIT_METHODS.BY_SIZE ||
|
|
parameters.method === SPLIT_METHODS.BY_PAGE_COUNT ||
|
|
parameters.method === SPLIT_METHODS.BY_DOC_COUNT) && renderSplitValueForm()}
|
|
{parameters.method === SPLIT_METHODS.BY_CHAPTERS && renderByChaptersForm()}
|
|
{parameters.method === SPLIT_METHODS.BY_PAGE_DIVIDER && renderByPageDividerForm()}
|
|
</Stack>
|
|
);
|
|
};
|
|
|
|
export default SplitSettings;
|