import React from "react"; import FormHelperText from "@mui/material/FormHelperText"; import Grid from "@mui/material/Grid2"; import Stack from "@mui/material/Stack"; import Switch from "@mui/material/Switch"; import Typography from "@mui/material/Typography"; import { useCardContext } from "../../contexts/CardContext"; import { useI18n } from "../../contexts/I18nContext"; import LabeledValue from "../LabeledValue"; import { CardFieldBaseProps } from "./shared"; export interface CardFieldSwitchProps extends Omit, React.PropsWithChildren { fallback?: never; fallbackPredicate?: never; isEditable?: boolean; off?: string; offValue?: string; on?: string; onValue?: string; type: "switch"; value: boolean; } export const CardFieldSwitch: React.FC> = ({ formName, helperText, isDisabled = false, isEditable = true, isReadable = true, label, offValue, onValue, required = false, size = "grow", value: defaultValue, }) => { const { isCompact, isEditing } = useCardContext(); const { t } = useI18n(); return ( {isEditing && isEditable ? ( {label} {helperText != null && {helperText}} ) : ( isReadable && ( ) )} ); }; export default CardFieldSwitch;