{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "shopping-cart", "title": "Shopping cart", "description": "Cart with line items, totals, and empty state for React Native and Uniwind.", "dependencies": [], "registryDependencies": [], "files": [ { "path": "src/blocks/shopping-cart/shopping-cart-block.tsx", "content": "import { useState } from 'react'\nimport { Image, View } from 'uniwind/components'\nimport { cn } from '../../../reusables/lib/utils'\nimport { Button, Separator, UIText } from '../../reusables'\nimport type { ShoppingCartBlockProps, ShoppingCartItem } from './types'\n\nconst DEFAULT_SHOPPING_CART_ITEMS: ShoppingCartItem[] = [\n {\n id: '1',\n name: 'Minimalist Beige Sneakers',\n image: 'https://deifkwefumgah.cloudfront.net/shadcnblocks/block/ecommerce/clothes/Minimalist-Beige-Sneakers-2.png',\n price: 120.0,\n quantity: 1,\n },\n {\n id: '2',\n name: 'Embroidered Blue Top',\n image: 'https://deifkwefumgah.cloudfront.net/shadcnblocks/block/ecommerce/clothes/Woman-in-Embroidered-Blue-Top-2.png',\n price: 140.0,\n quantity: 1,\n },\n {\n id: '3',\n name: 'Classic Fedora Hat',\n image: 'https://deifkwefumgah.cloudfront.net/shadcnblocks/block/ecommerce/accessories/Classic-Fedora-Hat-2.png',\n price: 84.0,\n quantity: 1,\n },\n]\n\nfunction formatUsd(price: number) {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: 'USD',\n }).format(price)\n}\n\nfunction ShoppingCartBlock({\n checkoutLabel = 'Checkout',\n className,\n continueShoppingLabel = 'Continue Shopping',\n emptyDescription = \"Looks like you haven't added anything yet.\",\n emptyTitle = 'Your cart is empty',\n initialItems = DEFAULT_SHOPPING_CART_ITEMS,\n onCheckout,\n onContinueShopping,\n title = 'Shopping Cart',\n totalLabel = 'Total',\n}: ShoppingCartBlockProps) {\n const [items, setItems] = useState(initialItems)\n\n const removeItem = (id: string) => {\n setItems(prev => prev.filter(item => item.id !== id))\n }\n\n const subtotal = items.reduce((sum, item) => sum + item.price * item.quantity, 0)\n\n if (items.length === 0) {\n return (\n \n \n \n {emptyTitle}\n {emptyDescription}\n \n \n \n \n )\n }\n\n return (\n \n \n {title}\n\n \n {items.map(item => (\n \n \n \n \n\n \n {item.name}\n Qty: {item.quantity}\n \n\n \n {formatUsd(item.price * item.quantity)}\n \n\n removeItem(item.id)}\n >\n ×\n \n \n ))}\n \n\n \n\n \n \n {totalLabel}\n {formatUsd(subtotal)}\n \n\n \n \n \n \n )\n}\n\nconst ShoppingCart1 = ShoppingCartBlock\n\nexport { ShoppingCart1, ShoppingCartBlock }\n", "type": "registry:component" }, { "path": "src/blocks/shopping-cart/types.ts", "content": "import type { ReactNode } from 'react'\n\nexport interface ShoppingCartItem {\n id: string\n name: string\n image: string\n price: number\n quantity: number\n}\n\nexport interface ShoppingCartBlockProps {\n className?: string\n initialItems?: ShoppingCartItem[]\n emptyTitle?: ReactNode\n emptyDescription?: ReactNode\n title?: ReactNode\n totalLabel?: ReactNode\n continueShoppingLabel?: ReactNode\n checkoutLabel?: ReactNode\n onContinueShopping?: () => void\n onCheckout?: () => void\n}\n", "type": "registry:lib" }, { "path": "src/blocks/shopping-cart/index.ts", "content": "export { ShoppingCart1, ShoppingCartBlock } from './shopping-cart-block'\nexport type { ShoppingCartBlockProps, ShoppingCartItem } from './types'\n", "type": "registry:lib" } ], "docs": "Depends on local `reusables` (Button, Separator, UIText), `reusables/lib/utils` (cn), and `uniwind`. Align import paths with your app aliases after install.", "categories": [ "blocks", "ecommerce" ], "type": "registry:block" }