umami/src/components/input/CurrencySelect.tsx
Mike Cao 28c9c7d3ec Fix Select component usage by removing items prop and render functions.
Replace render function children with mapped ListItem elements and remove
the unsupported items prop across all Select instances.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 02:46:38 -08:00

33 lines
888 B
TypeScript

import { ListItem, Select } from '@umami/react-zen';
import { useState } from 'react';
import { useMessages } from '@/components/hooks';
import { CURRENCIES } from '@/lib/constants';
export function CurrencySelect({ value, onChange }) {
const { formatMessage, labels } = useMessages();
const [search, setSearch] = useState('');
return (
<Select
label={formatMessage(labels.currency)}
value={value}
defaultValue={value}
onChange={onChange}
listProps={{ style: { maxHeight: 300 } }}
onSearch={setSearch}
allowSearch
>
{CURRENCIES.map(({ id, name }) => {
if (search && !`${id}${name}`.toLowerCase().includes(search)) {
return null;
}
return (
<ListItem key={id} id={id}>
{id} &mdash; {name}
</ListItem>
);
}).filter(n => n)}
</Select>
);
}