import React from "react"; import { hardwareOptions } from "../config"; import type { HardwareOption } from "../config"; import styles from "../styles.module.css"; interface Props { deviceId: string; hardwareEnabled: Record; onToggle: (hwId: string) => void; isDisabled: (hwId: string) => boolean; } function renderDescription(text: string): React.ReactNode { const parts = text.split(/(\[[^\]]+\]\([^)]+\))/g); return parts.map((part, i) => { const match = part.match(/^\[([^\]]+)\]\(([^)]+)\)$/); if (match) { return {match[1]}; } return {part}; }); } function HardwareCheckbox({ hw, disabled, checked, onToggle, }: { hw: HardwareOption; disabled: boolean; checked: boolean; onToggle: () => void; }) { return (
{checked && hw.description && (
{renderDescription(hw.description)}
)}
); } export default function HardwareOptions({ deviceId, hardwareEnabled, onToggle, isDisabled }: Props) { return (

Generic Hardware Devices

{deviceId !== "stable" && (

Some options have been auto-configured based on your device type.

)}
{hardwareOptions.map((hw) => { const disabled = isDisabled(hw.id); const checked = disabled ? false : !!hardwareEnabled[hw.id]; return ( onToggle(hw.id)} /> ); })}
); }