{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "detailed-usage-table", "title": "Detailed Usage Table", "description": "A detailed usage table component with resource consumption breakdown", "registryDependencies": [ "table", "card", "badge", "utils" ], "files": [ { "path": "src/registry/billingsdk/detailed-usage-table.tsx", "content": "\"use client\";\n\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\nimport {\n Table,\n TableBody,\n TableCaption,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"@/components/ui/table\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface UsageResource {\n name: string;\n used: number;\n limit: number;\n percentage?: number;\n unit?: string;\n}\n\nexport interface DetailedUsageTableProps {\n className?: string;\n title?: string;\n description?: string;\n resources: UsageResource[];\n}\n\nexport function DetailedUsageTable({\n className,\n title = \"Detailed Usage\",\n description,\n resources,\n}: DetailedUsageTableProps) {\n const formatNumber = (num: number) => {\n return new Intl.NumberFormat().format(num);\n };\n\n const getPercentageBar = (percentage: number) => {\n let bgColor = \"bg-emerald-500\";\n if (percentage >= 90) bgColor = \"bg-destructive\";\n else if (percentage >= 75) bgColor = \"bg-orange-500\";\n\n return (\n
\n
\n \n
\n \n {Math.round(percentage)}%\n \n
\n );\n };\n\n return (\n \n \n {title}\n {description && {description}}\n \n \n
\n \n \n Detailed usage of resources\n \n \n \n Resource\n Used\n Limit\n \n Usage\n \n \n \n \n {resources.length === 0 ? (\n \n \n No resources found\n \n \n ) : (\n resources.map((resource, index) => {\n const percentage =\n resource.percentage ??\n (resource.limit > 0\n ? (resource.used / resource.limit) * 100\n : 0);\n\n const unit = resource.unit ? ` ${resource.unit}` : \"\";\n\n return (\n \n \n {resource.name}\n \n \n {formatNumber(resource.used)}\n {unit}\n \n \n {formatNumber(resource.limit)}\n {unit}\n \n \n {getPercentageBar(percentage)}\n \n \n );\n })\n )}\n \n
\n
\n
\n
\n );\n}\n", "type": "registry:component", "target": "components/billingsdk/detailed-usage-table.tsx" }, { "path": "src/registry/billingsdk/demo/detailed-usage-table-demo.tsx", "content": "\"use client\";\n\nimport { DetailedUsageTable } from \"@/registry/billingsdk/detailed-usage-table\";\n\nexport function DetailedUsageTableDemo() {\n return (\n \n );\n}\n", "type": "registry:component", "target": "components/detailed-usage-table-demo.tsx" } ], "type": "registry:block" }