// @flow strict import * as React from 'react'; import {classify} from '../../utils/classify'; import type {IconType} from '../Icon/Icon'; import {MenuOptionButton} from './MenuOptionButton'; import css from './Menu.module.css'; type ClassNames = $ReadOnly<{ wrapper?: string, option?: string, groupTitle?: string, optionTextContainer?: string, optionTextLabel?: string, }>; export type MenuOption = { key: string, label?: string, secondaryLabel?: string, customComponent?: React.Node, iconLeft?: string, iconLeftType?: IconType, iconRight?: string, iconRightType?: IconType, disabled?: boolean, optionSize?: MenuSizeTypes, optionVariant?: MenuOptionsVariant, }; // Render first available option set export type BaseMenuProps = { onSelect?: (option: MenuOption) => mixed, selectedOption?: ?MenuOption, optionsVariant?: MenuOptionsVariant, selectedKeys?: Array, classNames?: ClassNames, size?: MenuSizeTypes, width?: string, menuDisabled?: boolean, isFluid?: boolean, }; export type MenuOptionTypes = { options?: Array, composeOptions?: Array>, groupTitleOptions?: Array, }; export type MenuSizeTypes = 'medium' | 'small'; export type MenuOptionsVariant = 'checkbox' | 'radio' | 'normal'; export type MenuGroupTitleOption = { groupTitle?: React.Node, options?: Array, showLineDivider?: boolean, }; export type MenuProps = { ...BaseMenuProps, ...MenuOptionTypes, }; const RenderOption = ({ options, composeOptions, groupTitleOptions, classNames, ...restProps }: MenuProps): React.Node => { if (options && Array.isArray(options) && options.length) { return ( <> {options.map((option) => ( ))} ); } if ( composeOptions && Array.isArray(composeOptions) && composeOptions.length ) { return ( <> {composeOptions.map((composeMenuOptions, index) => ( // eslint-disable-next-line react/no-array-index-key {composeMenuOptions.map((option) => ( ))} ))} ); } if ( groupTitleOptions && Array.isArray(groupTitleOptions) && groupTitleOptions.length ) { return ( <> {groupTitleOptions.map((optionsGroup, index) => ( // eslint-disable-next-line react/no-array-index-key {!!optionsGroup.groupTitle && (
{optionsGroup.groupTitle}
)} {optionsGroup.options?.map((option) => ( ))}
))} ); } return <>; }; export const Menu: React$AbstractComponent = React.forwardRef( (props: MenuProps, ref): React.Node => { const {classNames, size = 'medium', width, isFluid = true} = props; return (
); }, );