All files / src/components/ui EmptyState.tsx

0% Statements 0/139
0% Branches 0/1
0% Functions 0/1
0% Lines 0/139

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202                                                                                                                                                                                                                                                                                                                                                                                                                   
import { cn } from '../../lib/utils';
import { MessageSquare, Inbox, Search, FileX, Wifi, Bot } from 'lucide-react';
 
interface EmptyStateProps {
  icon: React.ReactNode;
  title: string;
  description: string;
  action?: React.ReactNode;
  className?: string;
  /** Size variant */
  size?: 'sm' | 'md' | 'lg';
}
 
export function EmptyState({
  icon,
  title,
  description,
  action,
  className,
  size = 'md'
}: EmptyStateProps) {
  const sizeClasses = {
    sm: {
      container: 'py-4',
      iconWrapper: 'w-12 h-12',
      icon: 'w-5 h-5',
      title: 'text-sm',
      description: 'text-xs',
    },
    md: {
      container: 'p-6',
      iconWrapper: 'w-16 h-16',
      icon: 'w-8 h-8',
      title: 'text-base',
      description: 'text-sm',
    },
    lg: {
      container: 'p-8',
      iconWrapper: 'w-20 h-20',
      icon: 'w-10 h-10',
      title: 'text-lg',
      description: 'text-base',
    },
  };
 
  const sizes = sizeClasses[size];
 
  return (
    <div className={cn('h-full flex items-center justify-center', sizes.container, className)}>
      <div className="text-center max-w-sm">
        <div
          className={cn(
            'rounded-full flex items-center justify-center mx-auto mb-4 text-gray-400',
            sizes.iconWrapper,
            'bg-gray-100 dark:bg-gray-800'
          )}
        >
          {icon}
        </div>
        <h3 className={cn('font-semibold text-gray-700 dark:text-gray-300 mb-2', sizes.title)}>
          {title}
        </h3>
        <p className={cn('text-gray-500 dark:text-gray-400 mb-4', sizes.description)}>
          {description}
        </p>
        {action}
      </div>
    </div>
  );
}
 
// === Pre-built Empty State Variants ===
 
interface PrebuiltEmptyStateProps {
  action?: React.ReactNode;
  className?: string;
  size?: 'sm' | 'md' | 'lg';
}
 
/**
 * Empty state for no messages in chat.
 */
export function EmptyMessages({ action, className, size }: PrebuiltEmptyStateProps) {
  return (
    <EmptyState
      icon={<MessageSquare className="w-8 h-8" />}
      title="No messages yet"
      description="Start the conversation by sending a message below."
      action={action}
      className={className}
      size={size}
    />
  );
}
 
/**
 * Empty state for no conversations.
 */
export function EmptyConversations({ action, className, size }: PrebuiltEmptyStateProps) {
  return (
    <EmptyState
      icon={<Inbox className="w-8 h-8" />}
      title="No conversations"
      description="Your conversation history will appear here."
      action={action}
      className={className}
      size={size}
    />
  );
}
 
/**
 * Empty state for search with no results.
 */
export function EmptySearchResults({ query, action, className, size }: PrebuiltEmptyStateProps & { query?: string }) {
  return (
    <EmptyState
      icon={<Search className="w-8 h-8" />}
      title="No results found"
      description={query ? `No messages matching "${query}"` : 'Try adjusting your search terms.'}
      action={action}
      className={className}
      size={size}
    />
  );
}
 
/**
 * Empty state for no files or attachments.
 */
export function EmptyFiles({ action, className, size }: PrebuiltEmptyStateProps) {
  return (
    <EmptyState
      icon={<FileX className="w-8 h-8" />}
      title="No files"
      description="No files or attachments here yet."
      action={action}
      className={className}
      size={size}
    />
  );
}
 
/**
 * Empty state for offline/disconnected state.
 */
export function EmptyOffline({ action, className, size }: PrebuiltEmptyStateProps) {
  return (
    <EmptyState
      icon={<Wifi className="w-8 h-8 text-orange-400" />}
      title="Offline"
      description="Please check your connection and try again."
      action={action}
      className={className}
      size={size}
    />
  );
}
 
/**
 * Empty state for no agents/clones available.
 */
export function EmptyAgents({ action, className, size }: PrebuiltEmptyStateProps) {
  return (
    <EmptyState
      icon={<Bot className="w-8 h-8" />}
      title="No agents"
      description="Create an agent to get started with personalized conversations."
      action={action}
      className={className}
      size={size}
    />
  );
}
 
/**
 * Empty state for welcome screen.
 */
export function WelcomeEmptyState({
  title = "Welcome to ZCLAW",
  description = "Send a message to start the conversation.",
  connected = true,
  action,
  className,
  size,
}: PrebuiltEmptyStateProps & {
  title?: string;
  description?: string;
  connected?: boolean;
}) {
  return (
    <EmptyState
      icon={<MessageSquare className="w-8 h-8" />}
      title={title}
      description={connected ? description : 'Please connect to Gateway first.'}
      action={action}
      className={className}
      size={size}
    />
  );
}