import { ChevronDown, Globe, Search } from 'lucide-react'; import * as React from 'react'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { Input } from '@/components/ui/input'; import { cn } from '@/lib/utils.ts'; const LOCAL_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone; const ALL_TIMEZONES: string[] = Intl.supportedValuesOf('timeZone'); interface Props { className?: string; value?: string; onChange?: (value: string) => void; disabled?: boolean; } export function TimezoneSelect({ className, value, onChange, disabled }: Props) { const [search, setSearch] = React.useState(''); const inputRef = React.useRef(null); const filtered = React.useMemo(() => { if (!search.trim()) return ALL_TIMEZONES; const q = search.toLowerCase(); return ALL_TIMEZONES.filter((tz) => tz.toLowerCase().includes(q)); }, [search]); const displayLabel = value || LOCAL_TIMEZONE; return ( { if (open) setSearch(''); }} >
setSearch(e.target.value)} placeholder="Search timezone..." className="h-6 border-0 shadow-none focus-visible:ring-0 text-xs px-0" onKeyDown={(e) => e.stopPropagation()} />
{filtered.length === 0 ? (
No timezone found
) : ( filtered.map((tz) => ( onChange?.(tz)} className="text-xs" > {tz} )) )}
); }