import { Text, XStack, YStack } from '@hanzo/gui'; import * as React from 'react'; // Inline constants const apos = '’'; // right single quotation mark (typographic apostrophe) function upperFirst(str: string): string { return str.charAt(0).toUpperCase() + str.slice(1); } export type EmptyStateType = 'query' | 'stats' | 'coming_soon'; // Empty state icons are intentionally omitted in the shared package. // Consumers can pass a custom `icon` prop instead. const ICONS: Partial> = {}; export interface EmptyStateProps extends React.HTMLAttributes { title?: string; description?: React.ReactNode; term?: string; type?: EmptyStateType; icon?: React.ReactNode; } const MUTED = 'var(--color-text-secondary)' as never; export const EmptyState = React.forwardRef( function EmptyState(props, ref) { const { title, description, term, type = 'query', icon, children, className, ...rest } = props; const titleContent = (() => { if (title) { return title; } if (type === 'stats') { return 'Collecting data'; } if (type === 'coming_soon') { return 'Coming soon'; } return 'No results'; })(); const descriptionContent = (() => { if (description) { return description; } if (term && type === 'query') { return `Couldn${ apos }t find any ${ term } that matches your query.`; } if (type === 'stats') { return term ? `${ upperFirst(term) } stats will be added soon` : 'Charts and statistics will be available soon'; } if (type === 'coming_soon') { return 'The information will be available soon. Stay tuned!'; } })(); const iconContent = (() => { const Icon = ICONS[type]; if (Icon) { return ; } return icon; })(); return ( { iconContent && ( { iconContent } ) } { descriptionContent ? ( { titleContent } { descriptionContent } ) : ( { titleContent } ) } { children } ); }, );