import { __ } from '@wordpress/i18n'; import { AsyncPaginate } from 'react-select-async-paginate'; import { AdminSectionField } from '@givewp/components/AdminDetailsPage/AdminSection'; import { SelectOption } from '@givewp/admin/types'; import styles from './styles.module.scss'; /** * @since 4.11.0 */ export default function AsyncSelectOption({ name, label, description = '', selectedOption, loadOptions, mapOptionsForMenu, handleChange, isLoadingError, errorMessage, searchPlaceholder, loadingMessage, loadingError, ariaLabel, noOptionsMessage, children }: AsyncSelectOptionProps) { return ( {description &&

{description}

} {isLoadingError ? (
{loadingError}
) : ( loadingMessage} noOptionsMessage={() => noOptionsMessage} aria-label={ariaLabel} /> )} {children}
); } interface AsyncSelectOptionProps { name: string; label: string; description?: string; handleChange: (selectedOption: SelectOption) => void; selectedOption: SelectOption | null; loadOptions: (searchInput: string) => Promise<{ options: SelectOption[]; hasMore: boolean; }>; mapOptionsForMenu: (options: SelectOption[]) => SelectOption[]; isLoadingError: Error | null; errorMessage: string; searchPlaceholder: string; loadingMessage: string; loadingError: string, noOptionsMessage: string; ariaLabel: string; children?: JSX.Element | JSX.Element[]; }