{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ecommerce-product-list-table-list","type":"registry:block","title":"Table List","files":[{"path":"components/blocks/ecommerce/product-list/table-list.tsx","content":"import { Button } from '@/components/ui/button';\nimport { Checkbox } from '@/components/ui/checkbox';\nimport { ArrowUpDown, Heart, Star } from 'lucide-react';\nimport { useState } from 'react';\n\ninterface Product {\n  id: number;\n  name: string;\n  category: string;\n  price: number;\n  originalPrice: number;\n  rating: number;\n  reviews: number;\n  stock: number;\n}\n\nexport default function TableList() {\n  const [sortBy, setSortBy] = useState<keyof Product>('price');\n  const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>('desc');\n  const [selectedItems, setSelectedItems] = useState<number[]>([]);\n\n  const products: Product[] = [\n    {\n      id: 1,\n      name: 'Classic Leather Watch',\n      category: 'Accessories',\n      price: 299,\n      originalPrice: 399,\n      rating: 4.9,\n      reviews: 128,\n      stock: 45,\n    },\n    {\n      id: 2,\n      name: 'Premium Steel Watch',\n      category: 'Accessories',\n      price: 499,\n      originalPrice: 599,\n      rating: 4.8,\n      reviews: 96,\n      stock: 32,\n    },\n    {\n      id: 3,\n      name: 'Smart Watch Pro',\n      category: 'Electronics',\n      price: 399,\n      originalPrice: 449,\n      rating: 4.7,\n      reviews: 256,\n      stock: 18,\n    },\n    {\n      id: 4,\n      name: 'Minimalist Watch',\n      category: 'Accessories',\n      price: 199,\n      originalPrice: 249,\n      rating: 4.6,\n      reviews: 64,\n      stock: 56,\n    },\n    {\n      id: 5,\n      name: 'Sport Watch Elite',\n      category: 'Sports',\n      price: 349,\n      originalPrice: 399,\n      rating: 4.8,\n      reviews: 192,\n      stock: 27,\n    },\n  ];\n\n  const sortedProducts = [...products].sort((a, b) => {\n    const aValue = a[sortBy];\n    const bValue = b[sortBy];\n    return sortOrder === 'asc'\n      ? aValue > bValue\n        ? 1\n        : -1\n      : aValue < bValue\n        ? 1\n        : -1;\n  });\n\n  const handleSort = (key: keyof Product) => {\n    if (sortBy === key) {\n      setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc');\n    } else {\n      setSortBy(key);\n      setSortOrder('desc');\n    }\n  };\n\n  const handleSelectAll = () => {\n    if (selectedItems.length === products.length) {\n      setSelectedItems([]);\n    } else {\n      setSelectedItems(products.map((p) => p.id));\n    }\n  };\n\n  const handleSelect = (id: number) => {\n    if (selectedItems.includes(id)) {\n      setSelectedItems(selectedItems.filter((i) => i !== id));\n    } else {\n      setSelectedItems([...selectedItems, id]);\n    }\n  };\n\n  return (\n    <div className=\"mx-auto w-full max-w-7xl p-6\">\n      <div className=\"bg-card rounded-xl border shadow-sm\">\n        <div className=\"overflow-x-auto\">\n          <table className=\"w-full\">\n            <thead>\n              <tr className=\"bg-muted/50 border-b\">\n                <th className=\"w-12 p-4\">\n                  <Checkbox\n                    checked={selectedItems.length === products.length}\n                    onCheckedChange={handleSelectAll}\n                    aria-label=\"Select all\"\n                  />\n                </th>\n                <th className=\"p-4 text-left\">Product</th>\n                <th className=\"p-4\">\n                  <Button\n                    variant=\"ghost\"\n                    onClick={() => handleSort('category')}\n                    className=\"flex h-8 items-center gap-1 font-medium\"\n                  >\n                    Category\n                    <ArrowUpDown className=\"h-4 w-4\" />\n                  </Button>\n                </th>\n                <th className=\"p-4\">\n                  <Button\n                    variant=\"ghost\"\n                    onClick={() => handleSort('price')}\n                    className=\"flex h-8 items-center gap-1 font-medium\"\n                  >\n                    Price\n                    <ArrowUpDown className=\"h-4 w-4\" />\n                  </Button>\n                </th>\n                <th className=\"p-4\">\n                  <Button\n                    variant=\"ghost\"\n                    onClick={() => handleSort('rating')}\n                    className=\"flex h-8 items-center gap-1 font-medium\"\n                  >\n                    Rating\n                    <ArrowUpDown className=\"h-4 w-4\" />\n                  </Button>\n                </th>\n                <th className=\"p-4\">\n                  <Button\n                    variant=\"ghost\"\n                    onClick={() => handleSort('stock')}\n                    className=\"flex h-8 items-center gap-1 font-medium\"\n                  >\n                    Stock\n                    <ArrowUpDown className=\"h-4 w-4\" />\n                  </Button>\n                </th>\n                <th className=\"w-24 p-4\"></th>\n              </tr>\n            </thead>\n            <tbody>\n              {sortedProducts.map((product) => (\n                <tr key={product.id} className=\"border-b\">\n                  <td className=\"p-4\">\n                    <Checkbox\n                      checked={selectedItems.includes(product.id)}\n                      onCheckedChange={() => handleSelect(product.id)}\n                      aria-label={`Select ${product.name}`}\n                    />\n                  </td>\n                  <td className=\"p-4\">\n                    <div className=\"flex items-center gap-3\">\n                      <div className=\"bg-muted relative h-12 w-12 overflow-hidden rounded-lg\">\n                        <img\n                          src=\"https://images.unsplash.com/photo-1523275335684-37898b6baf30\"\n                          alt={product.name}\n                          className=\"object-cover\"\n                          sizes=\"48px\"\n                        />\n                      </div>\n                      <div>\n                        <div className=\"font-medium\">{product.name}</div>\n                        <div className=\"text-muted-foreground text-sm\">\n                          SKU: {product.id.toString().padStart(4, '0')}\n                        </div>\n                      </div>\n                    </div>\n                  </td>\n                  <td className=\"p-4 text-center\">\n                    <span className=\"bg-secondary text-secondary-foreground inline-block rounded-md px-2 py-1 text-xs font-medium\">\n                      {product.category}\n                    </span>\n                  </td>\n                  <td className=\"p-4 text-center\">\n                    <div className=\"font-medium\">${product.price}</div>\n                    <div className=\"text-muted-foreground text-sm line-through\">\n                      ${product.originalPrice}\n                    </div>\n                  </td>\n                  <td className=\"p-4\">\n                    <div className=\"flex items-center justify-center gap-1\">\n                      <Star className=\"fill-primary text-primary h-4 w-4\" />\n                      <span>{product.rating}</span>\n                      <span className=\"text-muted-foreground\">\n                        ({product.reviews})\n                      </span>\n                    </div>\n                  </td>\n                  <td className=\"p-4 text-center\">\n                    <span\n                      className={`text-sm font-medium ${\n                        product.stock < 20\n                          ? 'text-destructive'\n                          : product.stock < 50\n                            ? 'text-orange-500'\n                            : 'text-green-500'\n                      }`}\n                    >\n                      {product.stock} units\n                    </span>\n                  </td>\n                  <td className=\"p-4\">\n                    <div className=\"flex items-center gap-2\">\n                      <Button size=\"sm\" className=\"w-full\">\n                        Buy\n                      </Button>\n                      <Button size=\"icon\" variant=\"ghost\" className=\"h-8 w-8\">\n                        <Heart className=\"h-4 w-4\" />\n                      </Button>\n                    </div>\n                  </td>\n                </tr>\n              ))}\n            </tbody>\n          </table>\n        </div>\n      </div>\n    </div>\n  );\n}\n","type":"registry:component","target":"components/blocks/ecommerce/product-list/table-list.tsx"},{"path":"components/ui/button.tsx","content":"import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Slot } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst buttonVariants = cva(\n  \"group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-primary text-primary-foreground hover:bg-primary/80\",\n        outline:\n          \"border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50\",\n        secondary:\n          \"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground\",\n        ghost:\n          \"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50\",\n        destructive:\n          \"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40\",\n        link: \"text-primary underline-offset-4 hover:underline\",\n      },\n      size: {\n        default:\n          \"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2\",\n        xs: \"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3\",\n        sm: \"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5\",\n        lg: \"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2\",\n        icon: \"size-9\",\n        \"icon-xs\":\n          \"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3\",\n        \"icon-sm\":\n          \"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md\",\n        \"icon-lg\": \"size-10\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n      size: \"default\",\n    },\n  }\n)\n\nfunction Button({\n  className,\n  variant = \"default\",\n  size = \"default\",\n  asChild = false,\n  ...props\n}: React.ComponentProps<\"button\"> &\n  VariantProps<typeof buttonVariants> & {\n    asChild?: boolean\n  }) {\n  const Comp = asChild ? Slot.Root : \"button\"\n\n  return (\n    <Comp\n      data-slot=\"button\"\n      data-variant={variant}\n      data-size={size}\n      className={cn(buttonVariants({ variant, size, className }))}\n      {...props}\n    />\n  )\n}\n\nexport { Button, buttonVariants }\n","type":"registry:ui","target":"components/ui/button.tsx"},{"path":"components/ui/checkbox.tsx","content":"\"use client\"\n\nimport * as React from \"react\"\nimport { Checkbox as CheckboxPrimitive } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\nimport { CheckIcon } from \"lucide-react\"\n\nfunction Checkbox({\n  className,\n  ...props\n}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {\n  return (\n    <CheckboxPrimitive.Root\n      data-slot=\"checkbox\"\n      className={cn(\n        \"peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary\",\n        className\n      )}\n      {...props}\n    >\n      <CheckboxPrimitive.Indicator\n        data-slot=\"checkbox-indicator\"\n        className=\"grid place-content-center text-current transition-none [&>svg]:size-3.5\"\n      >\n        <CheckIcon\n        />\n      </CheckboxPrimitive.Indicator>\n    </CheckboxPrimitive.Root>\n  )\n}\n\nexport { Checkbox }\n","type":"registry:ui","target":"components/ui/checkbox.tsx"}],"description":"A table listing products in rows with columns for image, name, stock, and price. Ideal for dashboards, admin catalogs, and bulk inventory views.","dependencies":["class-variance-authority","lucide-react","radix-ui"]}