// Copyright 2025 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import classNames from 'classnames'; import React, { type ReactNode, useMemo } from 'react'; import { v4 as uuid } from 'uuid'; import { noop } from 'lodash'; import { CircleCheckbox, Variant as CircleCheckboxVariant, } from './CircleCheckbox'; export function SettingsRow({ children, title, className, }: { children: ReactNode; title?: string; className?: string; }): JSX.Element { return (
{title && {title}} {children}
); } export function SettingsControl({ icon, left, onClick, right, }: { /** A className or `true` to leave room for icon */ icon?: string | true; left: ReactNode; onClick?: () => unknown; right: ReactNode; }): JSX.Element { const content = ( <> {icon && (
)}
{left}
{right}
); if (onClick) { return ( ); } return
{content}
; } type SettingsRadioOptionType = Readonly<{ text: string; value: Enum; readOnly?: boolean; onClick?: () => void; }>; export function SettingsRadio({ value, options, onChange, }: { value: Enum; options: ReadonlyArray>; onChange: (value: Enum) => void; }): JSX.Element { const htmlIds = useMemo(() => { return Array.from({ length: options.length }, () => uuid()); }, [options.length]); return (
{options.map(({ text, value: optionValue, readOnly, onClick }, i) => { const htmlId = htmlIds[i]; return ( ); })}
); }