2024-01-02 15:36:59 +01:00
|
|
|
"use client";
|
|
|
|
|
|
2024-04-25 22:06:15 +02:00
|
|
|
import { Switch } from "@mantine/core";
|
2024-01-02 15:36:59 +01:00
|
|
|
|
|
|
|
|
import type { CommonWidgetInputProps } from "./common";
|
|
|
|
|
import { useWidgetInputTranslation } from "./common";
|
|
|
|
|
import { useFormContext } from "./form";
|
|
|
|
|
|
2024-05-19 22:38:39 +02:00
|
|
|
export const WidgetSwitchInput = ({ property, kind, options }: CommonWidgetInputProps<"switch">) => {
|
2024-02-03 22:26:12 +01:00
|
|
|
const t = useWidgetInputTranslation(kind, property);
|
2024-01-02 15:36:59 +01:00
|
|
|
const form = useFormContext();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Switch
|
|
|
|
|
label={t("label")}
|
|
|
|
|
description={options.withDescription ? t("description") : undefined}
|
2024-02-03 10:24:39 +01:00
|
|
|
{...form.getInputProps(`options.${property}`, { type: "checkbox" })}
|
2024-01-02 15:36:59 +01:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|