{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "comp-477",
  "type": "registry:component",
  "title": "Comp 477",
  "description": "Comp 477",
  "files": [
    {
      "path": "registry/ui-basic/comp-477.tsx",
      "content": "\"use client\";\r\n\r\nimport { useEffect, useState } from \"react\";\r\n\r\nimport { Badge } from \"@/components/ui/badge\";\r\nimport { Checkbox } from \"@/components/ui/checkbox\";\r\nimport {\r\n\tTable,\r\n\tTableBody,\r\n\tTableCell,\r\n\tTableFooter,\r\n\tTableHead,\r\n\tTableHeader,\r\n\tTableRow,\r\n} from \"@/components/ui/table\";\r\nimport {\r\n\tColumnDef,\r\n\tflexRender,\r\n\tgetCoreRowModel,\r\n\tuseReactTable,\r\n} from \"@tanstack/react-table\";\r\n\r\nimport { cn } from \"../utilities/cn\";\r\n\r\ntype Item = {\r\n\tid: string;\r\n\tname: string;\r\n\temail: string;\r\n\tlocation: string;\r\n\tflag: string;\r\n\tstatus: \"Active\" | \"Inactive\" | \"Pending\";\r\n\tbalance: number;\r\n};\r\n\r\nconst columns: ColumnDef<Item>[] = [\r\n\t{\r\n\t\tid: \"select\",\r\n\t\theader: ({ table }) => (\r\n\t\t\t<Checkbox\r\n\t\t\t\tchecked={\r\n\t\t\t\t\ttable.getIsAllPageRowsSelected() ||\r\n\t\t\t\t\t(table.getIsSomePageRowsSelected() && \"indeterminate\")\r\n\t\t\t\t}\r\n\t\t\t\tonCheckedChange={(value) =>\r\n\t\t\t\t\ttable.toggleAllPageRowsSelected(!!value)\r\n\t\t\t\t}\r\n\t\t\t\taria-label=\"Select all\"\r\n\t\t\t/>\r\n\t\t),\r\n\t\tcell: ({ row }) => (\r\n\t\t\t<Checkbox\r\n\t\t\t\tchecked={row.getIsSelected()}\r\n\t\t\t\tonCheckedChange={(value) => row.toggleSelected(!!value)}\r\n\t\t\t\taria-label=\"Select row\"\r\n\t\t\t/>\r\n\t\t),\r\n\t},\r\n\t{\r\n\t\theader: \"Name\",\r\n\t\taccessorKey: \"name\",\r\n\t\tcell: ({ row }) => (\r\n\t\t\t<div className=\"font-medium\">{row.getValue(\"name\")}</div>\r\n\t\t),\r\n\t},\r\n\t{\r\n\t\theader: \"Email\",\r\n\t\taccessorKey: \"email\",\r\n\t},\r\n\t{\r\n\t\theader: \"Location\",\r\n\t\taccessorKey: \"location\",\r\n\t\tcell: ({ row }) => (\r\n\t\t\t<div>\r\n\t\t\t\t<span className=\"text-lg leading-none\">{row.original.flag}</span>{\" \"}\r\n\t\t\t\t{row.getValue(\"location\")}\r\n\t\t\t</div>\r\n\t\t),\r\n\t},\r\n\t{\r\n\t\theader: \"Status\",\r\n\t\taccessorKey: \"status\",\r\n\t\tcell: ({ row }) => (\r\n\t\t\t<Badge\r\n\t\t\t\tclassName={cn(\r\n\t\t\t\t\trow.getValue(\"status\") === \"Inactive\" &&\r\n\t\t\t\t\t\t\"bg-muted-foreground/60 text-primary-foreground\"\r\n\t\t\t\t)}\r\n\t\t\t>\r\n\t\t\t\t{row.getValue(\"status\")}\r\n\t\t\t</Badge>\r\n\t\t),\r\n\t},\r\n\t{\r\n\t\theader: () => <div className=\"text-right\">Balance</div>,\r\n\t\taccessorKey: \"balance\",\r\n\t\tcell: ({ row }) => {\r\n\t\t\tconst amount = parseFloat(row.getValue(\"balance\"));\r\n\t\t\tconst formatted = new Intl.NumberFormat(\"en-US\", {\r\n\t\t\t\tstyle: \"currency\",\r\n\t\t\t\tcurrency: \"USD\",\r\n\t\t\t}).format(amount);\r\n\t\t\treturn <div className=\"text-right\">{formatted}</div>;\r\n\t\t},\r\n\t},\r\n];\r\n\r\nexport default function Component() {\r\n\tconst [data, setData] = useState<Item[]>([]);\r\n\r\n\tuseEffect(() => {\r\n\t\tasync function fetchPosts() {\r\n\t\t\tconst res = await fetch(\r\n\t\t\t\t\"https://raw.githubusercontent.com/origin-space/origin-images/refs/heads/main/users-01_fertyx.json\"\r\n\t\t\t);\r\n\t\t\tconst data = await res.json();\r\n\t\t\tsetData(data.slice(0, 5)); // Limit to 5 items\r\n\t\t}\r\n\t\tfetchPosts();\r\n\t}, []);\r\n\r\n\tconst table = useReactTable({\r\n\t\tdata,\r\n\t\tcolumns,\r\n\t\tgetCoreRowModel: getCoreRowModel(),\r\n\t});\r\n\r\n\treturn (\r\n\t\t<div>\r\n\t\t\t<Table>\r\n\t\t\t\t<TableHeader>\r\n\t\t\t\t\t{table.getHeaderGroups().map((headerGroup) => (\r\n\t\t\t\t\t\t<TableRow\r\n\t\t\t\t\t\t\tkey={headerGroup.id}\r\n\t\t\t\t\t\t\tclassName=\"hover:bg-transparent\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t{headerGroup.headers.map((header) => {\r\n\t\t\t\t\t\t\t\treturn (\r\n\t\t\t\t\t\t\t\t\t<TableHead key={header.id}>\r\n\t\t\t\t\t\t\t\t\t\t{header.isPlaceholder\r\n\t\t\t\t\t\t\t\t\t\t\t? null\r\n\t\t\t\t\t\t\t\t\t\t\t: flexRender(\r\n\t\t\t\t\t\t\t\t\t\t\t\t\theader.column.columnDef.header,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\theader.getContext()\r\n\t\t\t\t\t\t\t\t\t\t\t\t)}\r\n\t\t\t\t\t\t\t\t\t</TableHead>\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t})}\r\n\t\t\t\t\t\t</TableRow>\r\n\t\t\t\t\t))}\r\n\t\t\t\t</TableHeader>\r\n\t\t\t\t<TableBody>\r\n\t\t\t\t\t{table.getRowModel().rows?.length ? (\r\n\t\t\t\t\t\ttable.getRowModel().rows.map((row) => (\r\n\t\t\t\t\t\t\t<TableRow\r\n\t\t\t\t\t\t\t\tkey={row.id}\r\n\t\t\t\t\t\t\t\tdata-state={row.getIsSelected() && \"selected\"}\r\n\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t\t{row.getVisibleCells().map((cell) => (\r\n\t\t\t\t\t\t\t\t\t<TableCell key={cell.id}>\r\n\t\t\t\t\t\t\t\t\t\t{flexRender(\r\n\t\t\t\t\t\t\t\t\t\t\tcell.column.columnDef.cell,\r\n\t\t\t\t\t\t\t\t\t\t\tcell.getContext()\r\n\t\t\t\t\t\t\t\t\t\t)}\r\n\t\t\t\t\t\t\t\t\t</TableCell>\r\n\t\t\t\t\t\t\t\t))}\r\n\t\t\t\t\t\t\t</TableRow>\r\n\t\t\t\t\t\t))\r\n\t\t\t\t\t) : (\r\n\t\t\t\t\t\t<TableRow>\r\n\t\t\t\t\t\t\t<TableCell\r\n\t\t\t\t\t\t\t\tcolSpan={columns.length}\r\n\t\t\t\t\t\t\t\tclassName=\"h-24 text-center\"\r\n\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t\tNo results.\r\n\t\t\t\t\t\t\t</TableCell>\r\n\t\t\t\t\t\t</TableRow>\r\n\t\t\t\t\t)}\r\n\t\t\t\t</TableBody>\r\n\t\t\t\t<TableFooter className=\"bg-transparent\">\r\n\t\t\t\t\t<TableRow className=\"hover:bg-transparent\">\r\n\t\t\t\t\t\t<TableCell colSpan={5}>Total</TableCell>\r\n\t\t\t\t\t\t<TableCell className=\"text-right\">\r\n\t\t\t\t\t\t\t{new Intl.NumberFormat(\"en-US\", {\r\n\t\t\t\t\t\t\t\tstyle: \"currency\",\r\n\t\t\t\t\t\t\t\tcurrency: \"USD\",\r\n\t\t\t\t\t\t\t}).format(\r\n\t\t\t\t\t\t\t\tdata.reduce((total, item) => total + item.balance, 0)\r\n\t\t\t\t\t\t\t)}\r\n\t\t\t\t\t\t</TableCell>\r\n\t\t\t\t\t</TableRow>\r\n\t\t\t\t</TableFooter>\r\n\t\t\t</Table>\r\n\t\t\t<p className=\"text-muted-foreground mt-4 text-center text-sm\">\r\n\t\t\t\tBasic data table made with{\" \"}\r\n\t\t\t\t<a\r\n\t\t\t\t\tclassName=\"hover:text-foreground underline\"\r\n\t\t\t\t\thref=\"https://tanstack.com/table\"\r\n\t\t\t\t\ttarget=\"_blank\"\r\n\t\t\t\t\trel=\"noopener noreferrer\"\r\n\t\t\t\t>\r\n\t\t\t\t\tTanStack Table\r\n\t\t\t\t</a>\r\n\t\t\t</p>\r\n\t\t</div>\r\n\t);\r\n}\r\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/badge.tsx",
      "content": "import React from \"react\";\r\n\r\nimport { cn } from \"@/registry/utilities/cn\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\n\r\nconst badgeVariants = cva(\r\n\t\"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2\",\r\n\t{\r\n\t\tvariants: {\r\n\t\t\tvariant: {\r\n\t\t\t\tdefault:\r\n\t\t\t\t\t\"border-transparent bg-primary text-primary-foreground hover:bg-primary/80\",\r\n\t\t\t\tsecondary:\r\n\t\t\t\t\t\"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80\",\r\n\t\t\t\tdestructive:\r\n\t\t\t\t\t\"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80\",\r\n\t\t\t\toutline: \"text-foreground\",\r\n\t\t\t},\r\n\t\t},\r\n\t\tdefaultVariants: {\r\n\t\t\tvariant: \"default\",\r\n\t\t},\r\n\t}\r\n);\r\n\r\nexport interface BadgeProps\r\n\textends React.HTMLAttributes<HTMLDivElement>,\r\n\t\tVariantProps<typeof badgeVariants> {}\r\n\r\nfunction Badge({ className, variant, ...props }: BadgeProps) {\r\n\treturn (\r\n\t\t<div className={cn(badgeVariants({ variant }), className)} {...props} />\r\n\t);\r\n}\r\n\r\nexport { Badge, badgeVariants };\r\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/utilities/cn.ts",
      "content": "import { ClassValue, clsx } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n\treturn twMerge(clsx(inputs));\r\n}\r\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/checkbox.tsx",
      "content": "\"use client\";\r\n\r\nimport React from \"react\";\r\n\r\nimport { cn } from \"@/registry/utilities/cn\";\r\nimport * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\r\nimport { Check } from \"lucide-react\";\r\n\r\nconst Checkbox = React.forwardRef<\r\n\tReact.ElementRef<typeof CheckboxPrimitive.Root>,\r\n\tReact.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>\r\n>(({ className, ...props }, ref) => (\r\n\t<CheckboxPrimitive.Root\r\n\t\tref={ref}\r\n\t\tclassName={cn(\r\n\t\t\t\"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground\",\r\n\t\t\tclassName\r\n\t\t)}\r\n\t\t{...props}\r\n\t>\r\n\t\t<CheckboxPrimitive.Indicator\r\n\t\t\tclassName={cn(\"flex items-center justify-center text-current\")}\r\n\t\t>\r\n\t\t\t<Check className=\"h-4 w-4\" />\r\n\t\t</CheckboxPrimitive.Indicator>\r\n\t</CheckboxPrimitive.Root>\r\n));\r\nCheckbox.displayName = CheckboxPrimitive.Root.displayName;\r\n\r\nexport { Checkbox };\r\n",
      "type": "registry:ui"
    }
  ]
}