"use client" import * as React from "react" import { IconCheck } from "@tabler/icons-react" import { cn } from "@/lib/utils" type DevicePickerProps = { readonly devices: MediaDeviceInfo[] readonly selectedDeviceId: string | undefined readonly onSelectDevice: (deviceId: string) => void readonly label: string } function cleanDeviceLabel(label: string): string { return label.replace(/\(([\da-fA-F]{4}:[\da-fA-F]{4})\)$/, "").trim() } export function DevicePicker({ devices, selectedDeviceId, onSelectDevice, label, }: DevicePickerProps): React.ReactElement { return (
{label}
{devices.length === 0 ? (
No devices found
) : (
{devices.map((device) => { const isSelected = device.deviceId === selectedDeviceId return ( ) })}
)}
) }