import { MouseEventHandler, ReactElement, ReactNode } from 'react'; import { EllipsizedText, MenuItem, MenuItemProps, Sticker, SxProps, Tooltip, } from '@biom3/react'; import { EIP6963ProviderInfo } from '@imtbl/checkout-sdk'; const disabledStyles = { cursor: 'not-allowed', bg: 'base.color.translucent.inverse.800', }; export type ChainInfo = { name: string; iconUrl: string; }; export interface SelectedWalletProps { children?: ReactNode; label: string; caption?: string; providerInfo?: Partial; chainInfo?: ChainInfo; onClick: MouseEventHandler; disabled?: boolean; sx?: SxProps; } export function SelectedWallet({ label, caption, children, onClick, providerInfo, chainInfo, disabled, sx, }: SelectedWalletProps) { const selected = !!children && providerInfo?.rdns; const size: MenuItemProps['size'] = selected ? 'xSmall' : 'small'; const getMenuItemImage = () => { const menuItemImage = !providerInfo?.icon ? ( ) : ( (( } /> ) as ReactElement) ); if (chainInfo && providerInfo?.rdns) { return ( } size="xSmall" sx={{ bottom: 'base.spacing.x2', right: 'base.spacing.x2' }} /> {chainInfo.name} {menuItemImage} ); } return menuItemImage; }; return ( {getMenuItemImage()} {label} {providerInfo?.name ? ( {providerInfo?.name} {' • '} ) : ( {caption} )} {children} ); }