/* * Copyright (c) 2021 - 2025, Ludvig Lundgren and the autobrr contributors. * SPDX-License-Identifier: GPL-2.0-or-later */ import type { FieldProps } from "formik"; import { Field as FormikField } from "formik"; import { Field, Label, Description } from "@headlessui/react"; import { classNames } from "@utils"; import { DocsTooltip } from "@components/tooltips/DocsTooltip"; import { Checkbox } from "@components/Checkbox"; interface SwitchGroupProps { name: string; label?: string; description?: string | React.ReactNode; heading?: boolean; tooltip?: JSX.Element; disabled?: boolean; className?: string; } const SwitchGroup = ({ name, label, description, tooltip, heading, disabled, className }: SwitchGroupProps) => ( {label && {tooltip ? ( {tooltip} ) : label} {description && ( {description} )} } {({ field, form: { setFieldValue } }: FieldProps) => ( { setFieldValue(field?.name ?? "", value); }} disabled={disabled} /> )} ); interface SwitchButtonProps { name: string; defaultValue?: boolean; className?: string; } const SwitchButton = ({ name, defaultValue }: SwitchButtonProps) => ( {({ field, form: { setFieldValue } }: FieldProps) => ( { setFieldValue(field?.name ?? "", value); }} /> )} ); export { SwitchGroup, SwitchButton };