'use client' import type React from 'react' import { useCallback, useState } from 'react' import { useIsMobile } from '../../hooks' import { cn } from '../../utils' import { Command, CommandEmpty, CommandGroup, CommandInput, CommandList, } from '../Command' import { inputVariants } from '../Input' import { LegacyCombobox, LegacyComboboxContent, LegacyComboboxTrigger, LegacyComboboxValue, LegacyComboboxIcon, OptionRow, type LegacyComboboxProps, } from '../LegacyCombobox' import { MobileMenuSheetContent } from '../PageHeader/MobileMenuSheetContent' import { Sheet, SheetTrigger, SheetClose } from '../Sheet/sheet' import { typographyVariants } from '../Typography' type WalletNetworkOption = { value: string label: string iconUrl?: string Icon?: React.ReactElement } export interface WalletNetworkSelectorProps extends Pick< LegacyComboboxProps, 'size' | 'placeholder' | 'defaultOpen' | 'value' | 'onValueChange' > { className?: string options: WalletNetworkOption[] disabled?: boolean } export function WalletNetworkSelector({ options, value, onValueChange, placeholder = 'Select network', className, defaultOpen, size = 'default', disabled = false, ...props }: WalletNetworkSelectorProps) { const isMobile = useIsMobile() const [mobileOpen, setMobileOpen] = useState(false) const handleValueChange = useCallback( (newValue: string) => { onValueChange?.(newValue) if (isMobile) { setMobileOpen(false) } }, [isMobile, onValueChange], ) return ( {isMobile ? ( No results found. {options.map(({ value, label, iconUrl, Icon }) => ( {Icon ?? (iconUrl && ( {label ))} {label} ))} ) : ( <> {options.map(({ value, label, iconUrl, Icon }) => ( {Icon ?? (iconUrl && ( {label ))} {label} ))} )} ) } WalletNetworkSelector.displayName = 'WalletNetworkSelector'