import { createContext, Fragment, useContext, type ReactNode } from 'react' import { MoreHorizontal, Loader2, AlertCircle } from 'lucide-react' import { Button } from '@/components/ui/button' import { DESKTOP_MEDIA_QUERY, useMediaQuery } from '@/hooks/useMediaQuery' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { cn } from '@/lib/utils' export const RowActionsMenuContext = createContext(false) export interface SettingsListRowAction { label: string onClick: () => void icon?: ReactNode destructive?: boolean disabled?: boolean separatorBefore?: boolean } interface SettingsListProps { isLoading?: boolean error?: Error | null isEmpty: boolean emptyTitle?: string emptyHint?: string loadingLabel?: string errorTitle?: string maxHeightClassName?: string children: ReactNode } interface SettingsListRowProps { title: ReactNode titleClassName?: string description?: ReactNode badges?: ReactNode belowDescription?: ReactNode trailing?: ReactNode primaryAction?: { label: string; onClick: () => void } actions?: SettingsListRowAction[] actionsLabel?: string onClick?: () => void className?: string } export function SettingsList({ isLoading, error, isEmpty, emptyTitle, emptyHint, loadingLabel, errorTitle, maxHeightClassName, children, }: SettingsListProps) { if (isLoading) { return (
{errorTitle ?? 'Failed to load'}
{error.message}
{emptyTitle}
{emptyHint}
{title}
{badges}