'use client'; import { Check, ChevronDown, Search } from 'lucide-react'; import { useEffect, useMemo, useRef, useState } from 'react'; export interface Country { code: string; // ISO-3166 alpha-2 name: string; dial: string; // E.164 dial prefix incl. leading '+' } /** Compute the regional-indicator-symbol flag emoji from an ISO-3166 alpha-2 * code. 🇨🇭 from "CH", 🇺🇸 from "US" etc. — no asset files needed. */ function flagFor(code: string): string { if (code.length !== 2) return ''; const A = 0x1f1e6 - 65; return String.fromCodePoint( ...code .toUpperCase() .split('') .map((c) => A + c.charCodeAt(0)), ); } /** * Custom country picker — opens DOWNWARD always (native setQuery(e.target.value)} placeholder="Search country or code…" className="h-9 w-full bg-transparent text-[13px] text-[--color-fg] placeholder:text-[--color-fg-subtle] focus:outline-none" onKeyDown={(e) => { if (e.key === 'Enter' && filtered.length > 0) { e.preventDefault(); select(filtered[0]!.code); } }} /> )} ); }