import * as React from 'react'; import type { AriaListBoxOptions } from 'react-aria'; import { useListBox, useObjectRef } from 'react-aria'; import { forwardRef } from '../../../../utils/forwardRef'; import { DataList } from '../../../DataList/DataList'; import type { CommonInputProps } from '../../types'; import type { MultiSelectState } from '../hooks/useMultiSelectState'; import { MultiSelectOption } from './MultiSelectOption'; import { MultiSelectSection } from './MultiSelectSection'; interface MultiSelectListProps extends AriaListBoxOptions, Pick { state: MultiSelectState; mode?: 'content' | 'dropdown'; isDisabled?: boolean; emptyListLabel: string; 'aria-label'?: string; } export const MultiSelectList = forwardRef(function MultiSelectList( { state, isDisabled, error, warning, mode, emptyListLabel, 'aria-label': ariaLabel, ...props }: MultiSelectListProps, forwardedRef: React.ForwardedRef ) { const ref = useObjectRef(forwardedRef); const { listBoxProps } = useListBox( { ...props, 'aria-label': ariaLabel, disallowEmptySelection: true, }, state, ref ); return ( {state.collection.size === 0 && {emptyListLabel}} {[...state.collection].map(item => item.type === 'section' ? ( ) : ( ) )} ); });