bazarr/frontend/src/components/forms/FrameRateForm.tsx
dependabot[bot] 9c6aff40c8
no log: Bump the mantine group in /frontend with 6 updates (#2851)
* [bot]: Bump the mantine group in /frontend with 6 updates

Bumps the mantine group in /frontend with 6 updates:

| Package | From | To |
| --- | --- | --- |
| [@mantine/core](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/core) | `7.16.3` | `7.17.0` |
| [@mantine/dropzone](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/dropzone) | `7.16.3` | `7.17.0` |
| [@mantine/form](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/form) | `7.16.3` | `7.17.0` |
| [@mantine/hooks](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/hooks) | `7.16.3` | `7.17.0` |
| [@mantine/modals](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/modals) | `7.16.3` | `7.17.0` |
| [@mantine/notifications](https://github.com/mantinedev/mantine/tree/HEAD/packages/@mantine/notifications) | `7.16.3` | `7.17.0` |


Updates `@mantine/core` from 7.16.3 to 7.17.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/7.17.0/packages/@mantine/core)

Updates `@mantine/dropzone` from 7.16.3 to 7.17.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/7.17.0/packages/@mantine/dropzone)

Updates `@mantine/form` from 7.16.3 to 7.17.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/7.17.0/packages/@mantine/form)

Updates `@mantine/hooks` from 7.16.3 to 7.17.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/7.17.0/packages/@mantine/hooks)

Updates `@mantine/modals` from 7.16.3 to 7.17.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/7.17.0/packages/@mantine/modals)

Updates `@mantine/notifications` from 7.16.3 to 7.17.0
- [Release notes](https://github.com/mantinedev/mantine/releases)
- [Changelog](https://github.com/mantinedev/mantine/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mantinedev/mantine/commits/7.17.0/packages/@mantine/notifications)

---
updated-dependencies:
- dependency-name: "@mantine/core"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: mantine
- dependency-name: "@mantine/dropzone"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: mantine
- dependency-name: "@mantine/form"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: mantine
- dependency-name: "@mantine/hooks"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: mantine
- dependency-name: "@mantine/modals"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: mantine
- dependency-name: "@mantine/notifications"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: mantine
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: apply breaking change types

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Anderson Shindy Oki <anderson.vs.oki@gmail.com>
2025-02-24 22:08:18 +09:00

83 lines
2.1 KiB
TypeScript

import { FunctionComponent } from "react";
import { Button, Divider, Group, NumberInput, Stack } from "@mantine/core";
import { useForm } from "@mantine/form";
import { useSubtitleAction } from "@/apis/hooks";
import { useModals, withModal } from "@/modules/modals";
import { task } from "@/modules/task";
import FormUtils from "@/utilities/form";
const TaskName = "Changing Frame Rate";
function convertToAction(from: number, to: number) {
return `change_FPS(from=${from},to=${to})`;
}
interface Props {
selections: FormType.ModifySubtitle[];
onSubmit?: VoidFunction;
}
const FrameRateForm: FunctionComponent<Props> = ({ selections, onSubmit }) => {
const { mutateAsync } = useSubtitleAction();
const modals = useModals();
const form = useForm({
initialValues: {
from: 0,
to: 0,
},
validate: {
from: FormUtils.validation(
(value: number) => value > 0,
"The From value must be larger than 0",
),
to: FormUtils.validation(
(value: number) => value > 0,
"The To value must be larger than 0",
),
},
});
return (
<form
onSubmit={form.onSubmit(({ from, to }) => {
const action = convertToAction(from, to);
selections.forEach((s) =>
task.create(s.path, TaskName, mutateAsync, {
action,
form: s,
}),
);
onSubmit?.();
modals.closeSelf();
})}
>
<Stack>
<Group gap="xs" grow>
<NumberInput
placeholder="From"
decimalScale={2}
fixedDecimalScale
{...form.getInputProps("from")}
></NumberInput>
<NumberInput
placeholder="To"
decimalScale={2}
fixedDecimalScale
{...form.getInputProps("to")}
></NumberInput>
</Group>
<Divider></Divider>
<Button type="submit">Start</Button>
</Stack>
</form>
);
};
export const FrameRateModal = withModal(FrameRateForm, "frame-rate-tool", {
title: "Change Frame Rate",
});
export default FrameRateForm;