import clsx from 'clsx'; import uuid from 'uuid'; import { ComponentProps, PropsWithChildren, ReactNode } from 'react'; import { FeatureId } from '@/react/portainer/feature-flags/enums'; import { Tooltip } from '@@/Tip/Tooltip'; import styles from './SwitchField.module.css'; import { Switch } from './Switch'; export interface Props { label: string; checked: boolean; onChange(value: boolean, index?: number): void; index?: number; name?: string; tooltip?: ComponentProps['message']; setTooltipHtmlMessage?: ComponentProps['setHtmlMessage']; labelClass?: string; switchClass?: string; fieldClass?: string; dataCy?: string; disabled?: boolean; featureId?: FeatureId; valueExplanation?: ReactNode; } export function SwitchField({ tooltip, checked, label, index, name = uuid(), labelClass, fieldClass, dataCy, disabled, onChange, featureId, switchClass, setTooltipHtmlMessage, valueExplanation, }: PropsWithChildren) { const toggleName = name ? `toggle_${name}` : ''; return (
{valueExplanation && {valueExplanation}}
); }