{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "native-nested-list-shadcnui", "type": "registry:component", "title": "Native Nested List", "description": "A nested list component with smooth expand/collapse animations, perfect for file explorers or navigation menus.", "dependencies": [ "framer-motion", "react" ], "files": [ { "path": "@uitripled/react-shadcn/src/components/native/native-nested-list-shadcnui.tsx", "content": "\"use client\";\n\nimport type React from \"react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/utils\";\nimport { AnimatePresence, motion, MotionConfig } from \"framer-motion\";\nimport { ChevronRight } from \"lucide-react\";\nimport { useState } from \"react\";\n\nexport interface ListItem {\n /**\n * Unique identifier for the list item\n */\n id: string;\n /**\n * Display label for the list item\n */\n label: string;\n /**\n * Optional icon component\n */\n icon?: React.ReactNode;\n /**\n * Nested children items\n */\n children?: ListItem[];\n /**\n * Additional metadata\n */\n metadata?: Record;\n /**\n * Optional URL to navigate to\n */\n href?: string;\n /**\n * Optional click handler\n */\n onClick?: (e: React.MouseEvent) => void;\n}\n\nexport interface NativeNestedListProps {\n items: ListItem[];\n activeId?: string;\n onItemClick?: (item: ListItem) => void;\n size?: \"sm\" | \"md\" | \"lg\";\n showExpandIcon?: boolean;\n defaultExpanded?: boolean;\n className?: string;\n indentSize?: number;\n}\n\nconst sizeVariants = {\n sm: \"h-8 text-xs px-2\",\n md: \"h-10 text-sm px-3\",\n lg: \"h-12 text-base px-4\",\n};\n\nconst iconSizeVariants = {\n sm: \"h-3 w-3\",\n md: \"h-4 w-4\",\n lg: \"h-5 w-5\",\n};\n\ninterface NestedItemProps {\n item: ListItem;\n level: number;\n activeId?: string;\n onItemClick?: (item: ListItem) => void;\n size: \"sm\" | \"md\" | \"lg\";\n showExpandIcon: boolean;\n defaultExpanded: boolean;\n indentSize: number;\n}\n\nfunction NestedItem({\n item,\n level,\n activeId,\n onItemClick,\n size,\n showExpandIcon,\n defaultExpanded,\n indentSize,\n}: NestedItemProps) {\n const [isExpanded, setIsExpanded] = useState(defaultExpanded);\n const hasChildren = item.children && item.children.length > 0;\n const isActive = activeId === item.id;\n\n const handleClick = (e: React.MouseEvent) => {\n if (hasChildren) {\n e.preventDefault();\n setIsExpanded(!isExpanded);\n }\n onItemClick?.(item);\n item.onClick?.(e);\n };\n\n const Comp = item.href ? \"a\" : \"span\";\n const props = item.href ? { href: item.href } : {};\n\n return (\n
  • \n \n \n \n \n {showExpandIcon && hasChildren && (\n \n \n \n )}\n {showExpandIcon && !hasChildren && (\n
    \n )}\n {item.icon && (\n
    {item.icon}
    \n )}\n {item.label}\n \n \n \n\n \n {isActive && (\n \n )}\n \n \n\n {/* Nested children */}\n \n {hasChildren && isExpanded && (\n \n
      \n {item.children!.map((child) => (\n \n ))}\n
    \n \n )}\n
    \n
  • \n );\n}\n\nexport function NativeNestedList({\n items,\n activeId,\n onItemClick,\n size = \"md\",\n showExpandIcon = true,\n defaultExpanded = false,\n className,\n indentSize = 16,\n}: NativeNestedListProps) {\n return (\n \n \n \n );\n}\n", "type": "registry:component", "target": "components/uitripled/native-nested-list-shadcnui.tsx" } ] }