import React, { memo, type CSSProperties } from "react"; import { assert } from "tsafe/assert"; import type { Equals } from "tsafe"; import { cx } from "./tools/cx"; import { fr } from "./fr"; import { ToggleSwitch } from "./ToggleSwitch"; import type { ToggleSwitchProps } from "./ToggleSwitch"; import { useAnalyticsId } from "./tools/useAnalyticsId"; export type ToggleSwitchGroupProps = { id?: string; className?: string; /** Default: true */ showCheckedHint?: ToggleSwitchProps["showCheckedHint"]; /** Default: right */ labelPosition?: ToggleSwitchProps["labelPosition"]; classes?: Partial>; /** Needs at least one ToggleSwitch */ toggles: [ToggleSwitchPropsWithoutSharedProps, ...ToggleSwitchPropsWithoutSharedProps[]]; style?: CSSProperties; }; /** @see */ export const ToggleSwitchGroup = memo(props => { const { id: id_props, className, toggles, showCheckedHint = true, labelPosition = "right", classes = {}, style, ...rest } = props; assert>(); const id = useAnalyticsId({ "defaultIdPrefix": "fr-toggle", "explicitlyProvidedId": id_props }); return (
    {toggles.map((toggleSwitchProps, i) => (
  • ))}
); }); export default ToggleSwitchGroup; type ToggleSwitchPropsWithoutSharedProps = | ToggleSwitchPropsWithoutSharedProps.Controlled | ToggleSwitchPropsWithoutSharedProps.Uncontrolled; namespace ToggleSwitchPropsWithoutSharedProps { export type Common = Omit; export type Uncontrolled = Common & Omit; export type Controlled = Common & Omit; }