import { memo, useState } from 'react'; import { Box, TextField, Popover, Stack, Typography, ListSubheader, InputAdornment, PopoverProps, MenuList, MenuItem, IconButton, } from '@mui/material'; import SearchIcon from '@mui/icons-material/Search'; import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline'; import { TIMEZONE_LABELS, TIMEZONE_OFFSETS, TIMEZONE_GROUPS_FOR_LISTING, fuzzySearchByLabel, TIMEZONE_LABEL_TO_VALUE, } from './constants'; export default function TimezonePopover( props: Omit & { onChange: (value: string) => void; } ) { const { onChange, anchorEl, ...rest } = props; return ( ); } function TimezoneSelector({ onChange }: { onChange: (value: string) => void }) { const [search, setSearch] = useState(''); return ( setSearch('')} /> ); } const TimezoneMenu = memo( ({ search, onChange }: { search: string; onChange: (value: string) => void }) => ( {!!search && fuzzySearchByLabel(search).map((timezoneLabel) => { const timezone = TIMEZONE_LABEL_TO_VALUE[timezoneLabel]; return ; })} {!search && TIMEZONE_GROUPS_FOR_LISTING.map((item) => { if (item.type === 'timezone') { return ; } return {item.label}; })} ) ); function TimezoneSearch({ value, onChange, onClear, }: { value: string; onChange: (value: string) => void; onClear: () => void; }) { const hasValue = !!value; return ( onChange(e.target.value)} fullWidth placeholder="Search..." InputProps={{ startAdornment: ( ), endAdornment: hasValue ? ( ) : null, }} /> ); } function TimezoneMenuItem({ timezone, onClick, }: { timezone: string; onClick: (value: string) => void; }) { return ( onClick(timezone)} sx={{ borderRadius: 1, }} > ({TIMEZONE_OFFSETS[timezone]}) {TIMEZONE_LABELS[timezone]} ); }