'use client'; import * as React from 'react'; import { classNames } from '@vkontakte/vkjs'; import { useAdaptivityConditionalRender } from '../../hooks/useAdaptivityConditionalRender'; import type { HasDataAttribute, HasOnlyExpectedProps, HasRootRef } from '../../types'; import { CustomSelect, type SelectProps } from '../CustomSelect/CustomSelect'; import { type CustomSelectOptionInterface } from '../CustomSelect/types'; import { type NativeHTMLSelectProps, NativeSelect, type NativeSelectProps, } from '../NativeSelect/NativeSelect'; export type SelectType = 'default' | 'plain' | 'accent'; /** * @see https://vkui.io/components/select */ export const Select = ({ children, className, ...props }: SelectProps): React.ReactNode => { const { options = [], searchable, emptyText, onInputChange, filterFn, popupDirection, renderOption, renderDropdown, fetching, onClose, onOpen, icon, ClearButton, allowClearButton, clearButtonTestId, dropdownOffsetDistance, dropdownAutoWidth, forceDropdownPortal, noMaxHeight, labelTextTestId, nativeSelectTestId, after, mode, pattern, minLength, maxLength, readOnly, getSelectInputRef, overscrollBehavior, beforeAlign, afterAlign, onInputKeyDown, accessible, fetchingCompletedLabel, fetchingInProgressLabel, slotProps, ...restProps } = props; const { deviceType } = useAdaptivityConditionalRender(); const nativeProps: HasOnlyExpectedProps = restProps; return ( {deviceType.desktop && ( )} {deviceType.mobile && ( & HasDataAttribute), ...slotProps?.select, }, root: slotProps?.root, }} {...nativeProps} > {options.map(({ label, value, disabled }) => ( ))} )} ); };