import React, { forwardRef } from 'react'; import type { ImageStyle, ViewStyle } from 'react-native'; import { Image, Pressable, StyleSheet, View } from 'react-native'; import { BORDER_WIDTH, COLORS, PADDING, SHAPE } from '../../constants'; import { Arrow } from '../arrow'; import { ClearOption } from '../clear-option'; import { MultiSelectedSeparatedOptions } from '../multi-selected-separated-options/multi-selected-separated-options'; import { SelectFieldType } from '../select-field-type'; import { useSelectControl } from './select-control.hooks'; export const SelectControl = forwardRef((_, ref) => { const { accessibilityHint, accessibilityLabel, onPressSelectControl, aboveSelectControl, selectLeftIconImageProps, selectRightIconsProps, selectLeftIconsProps, hideArrow, selectContainerProps, isOpened, disabled, showClearOptionA11y, showClearOption, buttonsStyles, leftIconStyles, containerStyles, disabledStyles, multiple, separatedMultiple, widthThreshold, } = useSelectControl(); const clearOption = ; return ( {!!selectLeftIconImageProps?.source && ( )} {showClearOption && clearOption} {!hideArrow && } {showClearOptionA11y && {clearOption}} {separatedMultiple && multiple && ( )} ); }); type Styles = { buttonsContainer: ViewStyle; leftIconWrapper: ViewStyle; leftIcon: ImageStyle; a11IconWrapper: ViewStyle; rootView: ViewStyle; container: ViewStyle; disabled: ViewStyle; openedAbove: ViewStyle; opened: ViewStyle; multiSelect: ViewStyle; singleSelect: ViewStyle; }; const styles = StyleSheet.create({ buttonsContainer: { position: 'absolute', right: 8, top: 0, alignItems: 'center', justifyContent: 'center', flexDirection: 'row', height: '100%', }, leftIconWrapper: { height: '100%', justifyContent: 'center', }, leftIcon: { marginRight: 8, }, a11IconWrapper: { position: 'absolute', right: -20, borderWidth: 1, height: '100%', }, rootView: { position: 'relative', width: '100%', }, container: { width: '100%', height: 40, flexDirection: 'row', borderRadius: SHAPE, borderWidth: BORDER_WIDTH, backgroundColor: COLORS.WHITE, paddingHorizontal: PADDING, }, disabled: { backgroundColor: COLORS.DISABLED, }, openedAbove: { borderTopLeftRadius: 0, borderTopRightRadius: 0, }, opened: { borderBottomLeftRadius: 0, borderBottomRightRadius: 0, }, multiSelect: { paddingRight: 40, }, singleSelect: { paddingRight: 55, }, }); SelectControl.displayName = 'SelectControl';