{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "order-history",
  "title": "Order History",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/order-history/OrderHistory.tsx",
      "content": "import { Fragment, useState } from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport { FilterChip, FilterChipGroup, FilterChipReset } from '@/components/ui/filter-chip-group'\nimport {\n  List,\n  ListItem,\n  ListItemContent,\n  ListItemDescription,\n  ListItemTitle,\n  ListSeparator,\n} from '@/components/ui/list'\nimport { Text } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\n\nexport type OrderHistoryStatus = 'in-progress' | 'delivered' | 'cancelled'\n\nexport interface OrderHistoryOrder {\n  id: string\n  title: string\n  reference?: string\n  status: OrderHistoryStatus\n  /** Locale-formatted amount as shown in the order system. */\n  total?: string\n}\n\nexport interface OrderHistoryGroup {\n  id: string\n  /** Caller-localized date or month heading. */\n  label: string\n  orders: readonly OrderHistoryOrder[]\n}\n\ntype OrderHistoryLabels = Partial<Record<OrderHistoryStatus | 'details' | 'clear' | 'empty' | 'noMatches', string>>\n\nexport interface OrderHistoryProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  title?: string\n  /** A bounded set of date groups in the order that they should appear. */\n  groups?: readonly OrderHistoryGroup[]\n  showFilters?: boolean\n  labels?: OrderHistoryLabels\n  onOpen: (orderId: string) => void\n}\n\nconst statuses = {\n  'in-progress': 'In progress',\n  delivered: 'Delivered',\n  cancelled: 'Canceled',\n} satisfies Record<OrderHistoryStatus, string>\nconst statusKeys = Object.keys(statuses) as OrderHistoryStatus[]\n\nexport function OrderHistory({\n  className,\n  title = 'Order history',\n  groups = [],\n  showFilters = false,\n  labels,\n  onOpen,\n  ...props\n}: OrderHistoryProps) {\n  const [filters, setFilters] = useState<string[]>([])\n  const active = showFilters && filters.length > 0\n  const visible = groups\n    .map((group) => ({\n      ...group,\n      orders: active ? group.orders.filter(({ status }) => filters.includes(status)) : group.orders,\n    }))\n    .filter(({ orders }) => orders.length > 0)\n  const details = labels?.details ?? 'Details'\n\n  return (\n    <View {...props} className={cn('gap-[16px]', className)}>\n      <Text size=\"title\" accessibilityRole=\"header\">\n        {title}\n      </Text>\n      {showFilters && groups.some(({ orders }) => orders.length > 0) ? (\n        <FilterChipGroup value={filters} onValueChange={setFilters}>\n          {statusKeys.map((status) => (\n            <FilterChip key={status} value={status} label={labels?.[status] ?? statuses[status]} />\n          ))}\n          {filters.length > 0 ? (\n            <FilterChipReset accessibilityLabel={labels?.clear ?? 'Clear filters'}>\n              {labels?.clear ?? 'Clear filters'}\n            </FilterChipReset>\n          ) : null}\n        </FilterChipGroup>\n      ) : null}\n      {visible.length > 0 ? (\n        visible.map(({ id, label, orders }) => (\n          <View key={id} className=\"gap-[8px]\">\n            <Text size=\"sm\" accessibilityRole=\"header\" className=\"font-semibold\">\n              {label}\n            </Text>\n            <List>\n              {orders.map((order, index) => {\n                const status = labels?.[order.status] ?? statuses[order.status]\n                return (\n                  <Fragment key={order.id}>\n                    {index > 0 ? <ListSeparator /> : null}\n                    <ListItem\n                      className=\"flex-wrap focus:bg-muted\"\n                      accessibilityLabel={[order.title, order.reference, status, order.total, details]\n                        .filter(Boolean)\n                        .join(', ')}\n                      onPress={() => onOpen(order.id)}\n                    >\n                      <ListItemContent>\n                        <ListItemTitle>{order.title}</ListItemTitle>\n                        <ListItemDescription>\n                          {[order.reference, status].filter(Boolean).join(' · ')}\n                        </ListItemDescription>\n                        {order.total ? <Text size=\"sm\">{order.total}</Text> : null}\n                      </ListItemContent>\n                      <Text size=\"sm\" className=\"max-w-[35%] shrink font-semibold\">\n                        {details}\n                      </Text>\n                    </ListItem>\n                  </Fragment>\n                )\n              })}\n            </List>\n          </View>\n        ))\n      ) : (\n        <Text variant=\"muted\">\n          {active ? (labels?.noMatches ?? 'No orders match these filters.') : (labels?.empty ?? 'No orders yet.')}\n        </Text>\n      )}\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/order-history/OrderHistory.tsx"
    },
    {
      "path": "packages/registry-native/blocks/order-history/index.ts",
      "content": "export {\n  OrderHistory,\n  type OrderHistoryGroup,\n  type OrderHistoryOrder,\n  type OrderHistoryProps,\n  type OrderHistoryStatus,\n} from './OrderHistory'\n",
      "type": "registry:block",
      "target": "~/components/blocks/order-history/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/filter-chip-group.json",
    "https://native.uipkge.dev/r/native/list.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Date-grouped order statuses, optional status filters and one open-details action per order.",
  "categories": [
    "commerce"
  ]
}