import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; import type { CameraDevice } from "@/hooks/useCameras"; import { Loader2, RefreshCw, Video } from "lucide-react"; type Props = { cameras: CameraDevice[]; loading: boolean; error: string | null; onRefresh: () => void; value: number; onChange: (index: number) => void; id?: string; label?: string; /** When false, only show a single-line summary if one camera (no dropdown). */ showDropdownOnlyIfMultiple?: boolean; }; export function CameraSelect({ cameras, loading, error, onRefresh, value, onChange, id = "camera-select", label = "Camera", showDropdownOnlyIfMultiple = true, }: Props) { const multiple = cameras.length > 1; const single = cameras.length === 1 ? cameras[0] : null; const showDropdown = multiple || !showDropdownOnlyIfMultiple; return (
{error}
} {loading && cameras.length === 0 && (Scanning for cameras…
)} {!loading && cameras.length === 0 && (No cameras detected. Check drivers and privacy settings.
)} {showDropdown && cameras.length > 0 && ( )} {showDropdownOnlyIfMultiple && !multiple && single && (Using: {single.label}
)} {multiple && (Multiple cameras found — choose which device to use for capture.
)}