import React, { type FC, useRef } from 'react'; import mergeRefs from 'react-merge-refs'; import cn from 'classnames'; import { type FieldProps } from '@alfalab/core-components-select/shared'; import { useFocus } from '@alfalab/hooks'; import WorldMagnifierMIcon from '@alfalab/icons-glyph/WorldMagnifierMIcon'; import { FlagIcon } from '../flag-icon'; import styles from './index.module.css'; export const EMPTY_COUNTRY_SELECT_FIELD = { value: 'EMPTY_COUNTRY_SELECT_VALUE', key: 'EMPTY_COUNTRY_SELECT_KEY', }; export const SelectField: FC = ({ selected, Arrow, size, disabled, innerProps = {}, }) => { const wrapperRef = useRef(null); const [focusVisible] = useFocus(wrapperRef, 'keyboard'); const ref = innerProps.ref ? mergeRefs([innerProps.ref, wrapperRef]) : wrapperRef; return (
{!selected || selected === EMPTY_COUNTRY_SELECT_FIELD ? ( ) : ( )} {Arrow}
); };