{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transaction-activity",
  "title": "Transaction Activity",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/transaction-activity/TransactionActivity.tsx",
      "content": "import * as React from 'react'\nimport { Platform, SectionList, View, useWindowDimensions, type ViewProps } from 'react-native'\nimport { ArrowDownLeft, ArrowUpRight, Minus } from 'lucide-react-native'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { Icon } from '@/components/ui/icon'\nimport { ListItem, ListItemContent, ListItemDescription, ListItemTitle, ListSeparator } from '@/components/ui/list'\nimport { SearchBar } from '@/components/ui/search-bar'\nimport { SegmentedControl, SegmentedControlItem } from '@/components/ui/segmented-control'\nimport { Text } from '@/components/ui/text'\nimport { useAnnouncement } from '@/lib/accessibility'\nimport { cn } from '@/lib/utils'\n\nexport interface TransactionActivityEntry {\n  id: string\n  name: string\n  description?: string\n  /** Signed amount in major currency units. Positive values are credits. */\n  amount: number\n  /** Three-letter currency code, such as USD or EUR. */\n  currency: string\n  /** Unix timestamp in milliseconds. Sections use the device's calendar day. */\n  occurredAt: number\n  status?: 'posted' | 'pending' | 'reversed'\n}\n\nconst labels = {\n  search: 'Search transactions',\n  all: 'All',\n  incoming: 'Money in',\n  outgoing: 'Money out',\n  pending: 'Pending',\n  reversed: 'Reversed',\n  empty: 'No transactions yet',\n  noMatches: 'No matching transactions',\n  clearFilters: 'Clear filters',\n  resultCount: (count: number) => `${count} ${count === 1 ? 'transaction' : 'transactions'}`,\n}\n\nexport interface TransactionActivityProps extends ViewProps {\n  className?: string\n  /** Omit to show sample activity. Pass an empty array for a real empty state. */\n  entries?: readonly TransactionActivityEntry[]\n  /** Adds content above the search field inside the list's scroll area. */\n  header?: React.ReactNode\n  locale?: string\n  labels?: Partial<typeof labels>\n  /** Makes each transaction an action. Detail presentation is owned by the caller. */\n  onEntryPress?: (entry: TransactionActivityEntry) => void\n}\n\nconst sampleEntries: readonly TransactionActivityEntry[] = [\n  {\n    id: 'sample-1',\n    name: 'Cedar Market',\n    description: 'Groceries',\n    amount: -28.45,\n    currency: 'USD',\n    occurredAt: Date.UTC(2026, 10, 24, 15),\n  },\n  {\n    id: 'sample-2',\n    name: 'Oliver Bennett',\n    description: 'Transfer received',\n    amount: 75,\n    currency: 'USD',\n    occurredAt: Date.UTC(2026, 10, 23, 18),\n  },\n]\n\ntype Direction = 'all' | 'incoming' | 'outgoing'\n\nfunction activitySections(\n  entries: readonly TransactionActivityEntry[],\n  query: string,\n  direction: Direction,\n  dateFormat: Intl.DateTimeFormat,\n  locale: string | undefined,\n) {\n  const search = query.trim().toLocaleLowerCase(locale)\n  const sorted = entries\n    .filter((entry) => {\n      if (!Number.isFinite(entry.amount) || Number.isNaN(new Date(entry.occurredAt).getTime())) return false\n      if (direction === 'incoming' && entry.amount <= 0) return false\n      if (direction === 'outgoing' && entry.amount >= 0) return false\n      return (\n        !search ||\n        [entry.name, entry.description, entry.currency].some((value) =>\n          value?.toLocaleLowerCase(locale).includes(search),\n        )\n      )\n    })\n    .sort((a, b) => b.occurredAt - a.occurredAt)\n\n  const sections = new Map<string, { key: string; title: string; data: TransactionActivityEntry[] }>()\n  for (const entry of sorted) {\n    const date = new Date(entry.occurredAt)\n    const key = `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`\n    const section = sections.get(key)\n    if (section) section.data.push(entry)\n    else sections.set(key, { key, title: dateFormat.format(date), data: [entry] })\n  }\n  return { sections: [...sections.values()], count: sorted.length }\n}\n\nfunction formatAmount(entry: TransactionActivityEntry, locale: string | undefined) {\n  const currency = entry.currency.trim().toUpperCase()\n  const amount = entry.amount === 0 ? 0 : entry.amount\n  if (!/^[A-Z]{3}$/.test(currency)) {\n    return [new Intl.NumberFormat(locale, { signDisplay: 'exceptZero' }).format(amount), currency]\n      .filter(Boolean)\n      .join(' ')\n  }\n  return new Intl.NumberFormat(locale, { style: 'currency', currency, signDisplay: 'exceptZero' }).format(amount)\n}\n\nexport function TransactionActivity({\n  className,\n  entries = sampleEntries,\n  header,\n  locale,\n  labels: overrides,\n  onEntryPress,\n  ...props\n}: TransactionActivityProps) {\n  const copy = { ...labels, ...overrides }\n  const [query, setQuery] = React.useState('')\n  const [settledQuery, setSettledQuery] = React.useState(query)\n  const [direction, setDirection] = React.useState<Direction>('all')\n  const { width, fontScale } = useWindowDimensions()\n  const stackDetails = width < 360 || fontScale >= 1.4\n  const dateFormat = React.useMemo(\n    () => new Intl.DateTimeFormat(locale, { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric' }),\n    [locale],\n  )\n  const { sections, count } = React.useMemo(\n    () => activitySections(entries, query, direction, dateFormat, locale),\n    [entries, query, direction, dateFormat, locale],\n  )\n  const hasFilters = !!query.trim() || direction !== 'all'\n  const resultCount = copy.resultCount(count)\n  React.useEffect(() => {\n    if (query === settledQuery) return\n    const timer = setTimeout(() => setSettledQuery(query), 300)\n    return () => clearTimeout(timer)\n  }, [query, settledQuery])\n  useAnnouncement(hasFilters && query === settledQuery ? resultCount : undefined)\n\n  return (\n    <View {...props} className={cn('min-h-0 flex-1 bg-background', className)}>\n      <SectionList\n        sections={sections}\n        keyExtractor={(entry) => entry.id}\n        stickySectionHeadersEnabled={false}\n        keyboardDismissMode=\"on-drag\"\n        keyboardShouldPersistTaps=\"handled\"\n        automaticallyAdjustKeyboardInsets={Platform.OS === 'ios'}\n        contentContainerStyle={{ paddingBottom: 16 }}\n        ListHeaderComponent={\n          <View className=\"gap-3 pb-4\">\n            {header}\n            <SearchBar\n              accessibilityLabel={copy.search}\n              placeholder={copy.search}\n              value={query}\n              onChangeText={setQuery}\n            />\n            <SegmentedControl\n              value={direction}\n              onValueChange={(value) => {\n                if (value === 'all' || value === 'incoming' || value === 'outgoing') setDirection(value)\n              }}\n            >\n              <SegmentedControlItem value=\"all\">{copy.all}</SegmentedControlItem>\n              <SegmentedControlItem value=\"incoming\">{copy.incoming}</SegmentedControlItem>\n              <SegmentedControlItem value=\"outgoing\">{copy.outgoing}</SegmentedControlItem>\n            </SegmentedControl>\n            <Text size=\"xs\" variant=\"muted\">\n              {resultCount}\n            </Text>\n          </View>\n        }\n        ListEmptyComponent={\n          <View className=\"items-center gap-3 rounded-xl border border-border px-4 py-8\">\n            <Text className=\"text-center font-semibold\">{hasFilters ? copy.noMatches : copy.empty}</Text>\n            {hasFilters ? (\n              <Button\n                variant=\"outline\"\n                accessibilityLabel={copy.clearFilters}\n                onPress={() => {\n                  setQuery('')\n                  setDirection('all')\n                }}\n              >\n                {copy.clearFilters}\n              </Button>\n            ) : null}\n          </View>\n        }\n        renderSectionHeader={({ section }) => (\n          <Text size=\"sm\" accessibilityRole=\"header\" className=\"border-b border-border pb-2 pt-4 font-semibold\">\n            {section.title}\n          </Text>\n        )}\n        ItemSeparatorComponent={ListSeparator}\n        renderItem={({ item }) => {\n          const amount = formatAmount(item, locale)\n          const status =\n            item.status === 'pending' ? copy.pending : item.status === 'reversed' ? copy.reversed : undefined\n          const Glyph = item.amount > 0 ? ArrowDownLeft : item.amount < 0 ? ArrowUpRight : Minus\n          return (\n            <ListItem\n              accessible\n              accessibilityLabel={[item.name, item.description, amount, status].filter(Boolean).join(', ')}\n              onPress={onEntryPress ? () => onEntryPress(item) : undefined}\n              className=\"items-start px-0\"\n            >\n              <View className=\"size-10 shrink-0 items-center justify-center rounded-lg bg-muted\">\n                <Icon icon={Glyph} size={18} className={item.amount > 0 ? 'text-success' : 'text-muted-foreground'} />\n              </View>\n              <ListItemContent className={cn('gap-2', !stackDetails && 'flex-row justify-between')}>\n                <View className={cn('min-w-0 gap-1', !stackDetails && 'flex-1')}>\n                  <ListItemTitle>{item.name}</ListItemTitle>\n                  {item.description ? <ListItemDescription>{item.description}</ListItemDescription> : null}\n                </View>\n                <View className={cn('items-start gap-1', !stackDetails && 'max-w-[46%] items-end')}>\n                  <Text\n                    size=\"sm\"\n                    className={cn('font-medium', !stackDetails && 'text-right', item.amount > 0 && 'text-success')}\n                    style={{ fontVariant: ['tabular-nums'] }}\n                  >\n                    {amount}\n                  </Text>\n                  {status ? (\n                    <Badge variant={item.status === 'pending' ? 'outline' : 'secondary'} text={status} />\n                  ) : null}\n                </View>\n              </ListItemContent>\n            </ListItem>\n          )\n        }}\n      />\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/transaction-activity/TransactionActivity.tsx"
    },
    {
      "path": "packages/registry-native/blocks/transaction-activity/index.ts",
      "content": "export {\n  TransactionActivity,\n  type TransactionActivityEntry,\n  type TransactionActivityProps,\n} from './TransactionActivity'\n",
      "type": "registry:block",
      "target": "~/components/blocks/transaction-activity/index.ts"
    }
  ],
  "dependencies": [
    "lucide-react-native"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/accessibility.json",
    "https://native.uipkge.dev/r/native/badge.json",
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/icon.json",
    "https://native.uipkge.dev/r/native/list.json",
    "https://native.uipkge.dev/r/native/search-bar.json",
    "https://native.uipkge.dev/r/native/segmented-control.json",
    "https://native.uipkge.dev/r/native/text.json"
  ],
  "description": "A searchable, date-grouped native ledger with money-in and money-out filters, signed localized amounts, transaction status, and optional detail actions.",
  "categories": [
    "finance"
  ]
}