{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "recent-searches",
  "title": "Recent Searches",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/recent-searches/RecentSearches.tsx",
      "content": "import * as React from 'react'\nimport { Keyboard, View, type ViewProps } from 'react-native'\nimport { X } from 'lucide-react-native'\nimport { Button } from '@/components/ui/button'\nimport { IconButton } from '@/components/ui/icon-button'\nimport { List, ListItem, ListItemContent, ListItemTitle, ListSeparator } from '@/components/ui/list'\nimport { SearchBar } from '@/components/ui/search-bar'\nimport { Text } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\n\nconst defaultLabels = {\n  field: 'Search',\n  placeholder: 'Enter a search',\n  submit: 'Search',\n  clearQuery: 'Clear search',\n  history: 'Recent searches',\n  clearHistory: 'Clear history',\n  empty: 'No recent searches.',\n  remove: (query: string) => `Remove “${query}” from recent searches`,\n}\n\nexport interface RecentSearch {\n  id: string\n  query: string\n}\n\nexport interface RecentSearchesProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  /** Caller-owned history, in display order, with stable unique IDs. */\n  history?: readonly RecentSearch[]\n  query?: string\n  defaultQuery?: string\n  onQueryChange?: (query: string) => void\n  /** Called for a submitted search or a separately selected history row. */\n  onSearch: (query: string) => void\n  onRemove?: (id: string) => void\n  onClearHistory?: () => void\n  labels?: Partial<typeof defaultLabels>\n}\n\nexport function RecentSearches({\n  className,\n  history = [],\n  query,\n  defaultQuery = '',\n  onQueryChange,\n  onSearch,\n  onRemove,\n  onClearHistory,\n  labels,\n  ...props\n}: RecentSearchesProps) {\n  const copy = { ...defaultLabels, ...labels }\n  const [localQuery, setLocalQuery] = React.useState(defaultQuery)\n  const value = query ?? localQuery\n  const canSubmit = !!value.trim()\n  const entries = history.filter((entry) => entry.query.trim())\n\n  function change(next: string) {\n    if (query === undefined) setLocalQuery(next)\n    onQueryChange?.(next)\n  }\n\n  function submit(next: string) {\n    const term = next.trim()\n    if (!term) return\n    if (term !== value) change(term)\n    Keyboard.dismiss()\n    onSearch(term)\n  }\n\n  return (\n    <View {...props} className={cn('gap-4', className)}>\n      <View className=\"gap-2\">\n        <SearchBar\n          value={value}\n          accessibilityLabel={copy.field}\n          placeholder={copy.placeholder}\n          clearLabel={copy.clearQuery}\n          onChangeText={change}\n          submitBehavior=\"blurAndSubmit\"\n          onSubmitEditing={(event) => submit(event.nativeEvent.text)}\n        />\n        <Button accessibilityLabel={copy.submit} disabled={!canSubmit} onPress={() => submit(value)}>\n          {copy.submit}\n        </Button>\n      </View>\n      <View className=\"gap-2\">\n        <View className=\"min-h-[48px] flex-row flex-wrap items-center justify-between gap-x-3\">\n          <Text accessibilityRole=\"header\" className=\"font-semibold\">\n            {copy.history}\n          </Text>\n          {entries.length > 0 && onClearHistory ? (\n            <Button variant=\"ghost\" accessibilityLabel={copy.clearHistory} onPress={onClearHistory}>\n              {copy.clearHistory}\n            </Button>\n          ) : null}\n        </View>\n        {entries.length ? (\n          <List>\n            {entries.map((entry, index) => (\n              <React.Fragment key={entry.id}>\n                {index > 0 ? <ListSeparator /> : null}\n                <View className=\"flex-row items-center\">\n                  <ListItem\n                    accessibilityLabel={entry.query}\n                    onPress={() => submit(entry.query)}\n                    className=\"min-w-0 flex-1\"\n                  >\n                    <ListItemContent>\n                      <ListItemTitle>{entry.query}</ListItemTitle>\n                    </ListItemContent>\n                  </ListItem>\n                  {onRemove ? (\n                    <IconButton\n                      icon={X}\n                      accessibilityLabel={copy.remove(entry.query)}\n                      onPress={() => onRemove(entry.id)}\n                      className=\"mr-1\"\n                    />\n                  ) : null}\n                </View>\n              </React.Fragment>\n            ))}\n          </List>\n        ) : (\n          <Text size=\"sm\" variant=\"muted\">\n            {copy.empty}\n          </Text>\n        )}\n      </View>\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/recent-searches/RecentSearches.tsx"
    },
    {
      "path": "packages/registry-native/blocks/recent-searches/index.ts",
      "content": "export { RecentSearches, type RecentSearch, type RecentSearchesProps } from './RecentSearches'\n",
      "type": "registry:block",
      "target": "~/components/blocks/recent-searches/index.ts"
    }
  ],
  "dependencies": [
    "lucide-react-native"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/icon-button.json",
    "https://native.uipkge.dev/r/native/list.json",
    "https://native.uipkge.dev/r/native/search-bar.json",
    "https://native.uipkge.dev/r/native/text.json"
  ],
  "description": "A native search section with reusable history, explicit per-search removal, and a clear history action.",
  "categories": [
    "search"
  ]
}