import { InboxIcon, type LucideIcon } from 'lucide-react' import { IconStack } from '@/components/reui/icon-stack' import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from '@cfdm/ui/components/empty' import { cn } from '@cfdm/ui/lib/utils' import type { ReactNode } from 'react' interface EmptyStateProps { /** Lucide icon component or pre-rendered node (legacy). */ icon?: LucideIcon | ReactNode title: string description?: string action?: ReactNode className?: string /** Use IconStack media (empty-state-12). Default true. */ stackedIcon?: boolean } function isLucideIcon(icon: LucideIcon | ReactNode): icon is LucideIcon { if (typeof icon === 'function') return true // lucide-react icons are forwardRef objects ({ $$typeof, render, displayName }) if (icon != null && typeof icon === 'object' && '$$typeof' in icon) { // React elements have `props` — those are pre-rendered nodes, not components if ('props' in icon) return false return true } return false } /** Empty state — ReUI empty-state-12. Preview: https://reui.io/preview/base/empty-state-12 */ export function EmptyState({ icon, title, description, action, className, stackedIcon = true, }: EmptyStateProps) { const Icon = isLucideIcon(icon) ? icon : InboxIcon const customIcon = icon && !isLucideIcon(icon) ? icon : null return ( {customIcon ? (
{customIcon}
) : stackedIcon ? ( ) : ( )}
{title} {description ? ( {description} ) : null}
{action ? {action} : null}
) }