import React from 'react' import Block from '../Primitives/Block/Block' import type { MultiSelectV2TokensType } from './multiSelectV2.tokens' import type { MultiSelectV2GroupType } from './multiSelectV2.types' import MultiSelectV2MenuSearch from './MultiSelectV2MenuSearch' import MultiSelectV2SelectAllItem from './MultiSelectV2SelectAllItem' export type MultiSelectV2MenuHeaderProps = { tokens: MultiSelectV2TokensType showSearch: boolean showSearchWhenEmpty?: boolean itemsCount: number searchValue: string searchPlaceholder?: string searchInputRef: React.RefObject onSearchChange: (e: React.ChangeEvent) => void onSearchArrowKeyToFirst: () => void showSelectAll: boolean selected: string[] availableValues: string[] filteredItems: MultiSelectV2GroupType[] onSelectAll?: ( selectAll: boolean, filteredItems: MultiSelectV2GroupType[] ) => void selectAllText?: string disabled?: boolean } const MultiSelectV2MenuHeader = ({ tokens, showSearch, showSearchWhenEmpty, itemsCount, searchValue, searchPlaceholder, searchInputRef, onSearchChange, onSearchArrowKeyToFirst, showSelectAll, selected, availableValues, filteredItems, onSelectAll, selectAllText, disabled, }: MultiSelectV2MenuHeaderProps) => { const header = tokens.menu?.header return ( {showSearch && (showSearchWhenEmpty || itemsCount > 0) && ( )} {showSelectAll && onSelectAll && availableValues.length > 0 && ( onSelectAll?.(selectAll, filteredItems) } selectAllText={selectAllText ?? 'Select All'} disabled={disabled} /> )} ) } MultiSelectV2MenuHeader.displayName = 'MultiSelectV2MenuHeader' export default MultiSelectV2MenuHeader