import type { DeviceModel, ManufacturerAnnotation, } from '@seamapi/types/devicedb' import classNames from 'classnames' import { ChevronRightIcon } from 'lib/icons/ChevronRight.js' import { InfoBlueIcon } from 'lib/icons/InfoBlue.js' import { HiddenDevicesOverlay } from 'lib/seam/components/SupportedDeviceTable/HiddenDevicesOverlay.js' import { ShowAllDevicesButton } from 'lib/seam/components/SupportedDeviceTable/ShowAllDevicesButton.js' import { SupportedDeviceRow } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceRow.js' import { useManufacturer } from 'lib/seam/components/SupportedDeviceTable/use-manufacturer.js' import { useToggle } from 'lib/ui/use-toggle.js' /** * How many device models required before collapsing the list, * and requiring the user to click to view all. */ const maxDevicesBeforeCollapsing = 3 interface SupportedDeviceManufacturerSectionProps { manufacturerId: string deviceModels: DeviceModel[] } export function SupportedDeviceManufacturerSection({ manufacturerId, deviceModels, }: SupportedDeviceManufacturerSectionProps): JSX.Element | null { const { manufacturer } = useManufacturer({ manufacturer_id: manufacturerId }) const [expanded, toggleExpand] = useToggle() const canExpand = deviceModels.length > maxDevicesBeforeCollapsing const visibleDevices = !canExpand || expanded ? deviceModels : deviceModels.filter( (_deviceModel, index) => index < maxDevicesBeforeCollapsing ) const handleHeaderClick = (): void => { if (!canExpand) { return } toggleExpand() } return (
{annotation.message}