{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "uniswap-dialog-base",
  "type": "registry:component",
  "title": "Uniswap Dialog (base)",
  "description": "Theme-ready base variant of A Uniswap-style region selector dialog with a searchable country list, flag icons, and smooth open and close animations..",
  "dependencies": [
    "clsx",
    "lucide-react",
    "motion",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/watermelon/uniswap-dialog.tsx",
      "type": "registry:component",
      "content": "import { useMemo, useState } from 'react';\nimport { motion, AnimatePresence } from 'motion/react';\nimport { Search, X, Check, ChevronDown } from 'lucide-react';\nimport { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/* utils */\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\n/* types */\nexport type Country = {\n  name: string;\n  code: string;\n};\n\nexport type UniSwapDialogProps = {\n  value: Country;\n  onChange: (country: Country) => void;\n  countries?: Country[];\n  title?: string;\n};\n\n/* default countries */\nexport const DefaultCountries: Country[] = [\n  { name: 'Afghanistan', code: 'AF' },\n  { name: 'Åland Islands', code: 'AX' },\n  { name: 'Albania', code: 'AL' },\n  { name: 'Algeria', code: 'DZ' },\n  { name: 'American Samoa', code: 'AS' },\n  { name: 'Andorra', code: 'AD' },\n  { name: 'Angola', code: 'AO' },\n  { name: 'Australia', code: 'AU' },\n  { name: 'Austria', code: 'AT' },\n  { name: 'Belarus', code: 'BY' },\n  { name: 'Cyprus', code: 'CY' },\n  { name: 'India', code: 'IN' },\n  { name: 'Mauritius', code: 'MU' },\n  { name: 'Russia', code: 'RU' },\n  { name: 'United States', code: 'US' },\n];\n\n/* flag */\nconst Flag = ({ code }: { code: string }) => (\n  <img\n    src={`https://flagcdn.com/w160/${code.toLowerCase()}.png`}\n    alt={code}\n    className=\"h-6 w-6 shrink-0 rounded-full object-cover\"\n    loading=\"lazy\"\n  />\n);\n\n/* component */\nexport function UniSwapDialog({\n  value,\n  onChange,\n  countries = DefaultCountries,\n  title = 'Select your region',\n}: UniSwapDialogProps) {\n  const [isOpen, setIsOpen] = useState(false);\n  const [search, setSearch] = useState('');\n\n  const filteredCountries = useMemo(() => {\n    return countries.filter((c) =>\n      c.name.toLowerCase().includes(search.toLowerCase()),\n    );\n  }, [countries, search]);\n\n  return (\n    <div className=\"relative w-max theme-injected font-sans\">\n      {/* Trigger */}\n      <button\n        onClick={() => setIsOpen(true)}\n        className=\"flex items-center gap-2 rounded-3xl bg-muted px-2 py-1.5 transition-colors hover:bg-muted/80\"\n      >\n        <div className=\"h-6 w-6 shrink-0 overflow-hidden rounded-full border border-border\">\n          <Flag code={value.code} />\n        </div>\n        <ChevronDown size={16} className=\"text-foreground\" />\n      </button>\n\n      <AnimatePresence>\n        {isOpen && (\n          <>\n            {/* Backdrop */}\n            <motion.div\n              initial={{ opacity: 0 }}\n              animate={{ opacity: 1 }}\n              exit={{ opacity: 0 }}\n              onClick={() => setIsOpen(false)}\n              className=\"fixed inset-0 z-998 bg-background/30 backdrop-blur-sm\"\n            />\n\n            {/* Dialog Container */}\n            <div className=\"fixed inset-0 z-999 flex items-center justify-center p-4 pointer-events-none\">\n              <motion.div\n                initial={{\n                  opacity: 0,\n                  scale: 0.96,\n                  filter: 'blur(4px)',\n                }}\n                animate={{\n                  opacity: 1,\n                  scale: 1,\n                  filter: 'blur(0px)',\n                }}\n                exit={{\n                  opacity: 0,\n                  scale: 0.96,\n                  filter: 'blur(4px)',\n                }}\n                transition={{ type: 'spring', bounce: 0, duration: 0.3 }}\n                className=\"pointer-events-auto flex h-fit max-h-[520px] w-full max-w-[400px] flex-col overflow-hidden rounded-2xl border-2 border-border bg-card shadow-lg sm:h-[520px]\"\n              >\n                {/* Header */}\n                <div className=\"flex items-center justify-between p-4 pb-2\">\n                  <h2 className=\"px-1 text-sm font-medium text-foreground\">\n                    {title}\n                  </h2>\n                  <button\n                    title=\"close\"\n                    onClick={() => setIsOpen(false)}\n                    className=\"p-1 text-muted-foreground transition-colors hover:text-foreground\"\n                  >\n                    <X size={18} />\n                  </button>\n                </div>\n\n                {/* Search */}\n                <div className=\"px-4 pb-3\">\n                  <div className=\"relative flex items-center\">\n                    <Search\n                      size={16}\n                      className=\"absolute left-3.5 text-muted-foreground\"\n                    />\n                    <input\n                      autoFocus\n                      value={search}\n                      onChange={(e) => setSearch(e.target.value)}\n                      placeholder=\"Search by country or region\"\n                      className=\"w-full rounded-lg border-2 border-input bg-muted py-2.5 pr-4 pl-10 text-sm text-foreground placeholder-muted-foreground transition-colors outline-none focus:border-input\"\n                    />\n                  </div>\n                </div>\n\n                {/* List */}\n                <div className=\"custom-scrollbar flex-1 overflow-y-auto pb-4\">\n                  {filteredCountries.length === 0 ? (\n                    <div className=\"flex h-38 items-center justify-center text-sm text-muted-foreground\">\n                      No countries found\n                    </div>\n                  ) : (\n                    filteredCountries.map((country) => (\n                      <button\n                        key={country.code}\n                        onClick={() => {\n                          onChange(country);\n                          setIsOpen(false);\n                          setSearch('');\n                        }}\n                        className={cn(\n                          'group flex w-full items-center justify-between px-4 py-2.5 transition-all',\n                          value.code === country.code\n                            ? 'bg-muted'\n                            : 'hover:bg-muted/50',\n                        )}\n                      >\n                        <div className=\"flex items-center gap-3\">\n                          <div className=\"h-6 w-6 shrink-0 overflow-hidden rounded-full border-2 border-border\">\n                            <Flag code={country.code} />\n                          </div>\n                          <span\n                            className={cn(\n                              'text-sm font-medium transition-colors',\n                              value.code === country.code\n                                ? 'text-foreground'\n                                : 'text-muted-foreground group-hover:text-foreground',\n                            )}\n                          >\n                            {country.name}\n                          </span>\n                        </div>\n\n                        {value.code === country.code && (\n                          <Check\n                            size={16}\n                            className=\"text-foreground\"\n                          />\n                        )}\n                      </button>\n                    ))\n                  )}\n                </div>\n              </motion.div>\n            </div>\n          </>\n        )}\n      </AnimatePresence>\n\n      <style>{`\n        .custom-scrollbar::-webkit-scrollbar {\n          width: 4px;\n        }\n        .custom-scrollbar::-webkit-scrollbar-thumb {\n          background: hsl(var(--border));\n          border-radius: 10px;\n        }\n        .custom-scrollbar::-webkit-scrollbar-track {\n          background: transparent;\n        }\n      `}</style>\n    </div>\n  );\n}\n"
    }
  ]
}
