import React, { MouseEvent, useCallback } from 'react'; import { Dropdown, Button } from '../../index'; import cls from 'classnames'; import { cssClasses } from '@douyinfe/semi-foundation/aiChatInput/constants'; import { Locale } from '../../locale/interface'; import LocaleConsumer from '../../locale/localeConsumer'; import { DropdownProps } from '../../dropdown'; export interface McpOption { value: string; label: string; icon?: React.ReactNode; [key: string]: any } export interface McpProps extends DropdownProps { options: McpOption[]; num?: number; onConfigureButtonClick: () => void } // because there may be grouping or nested dropdown forms. const Mcp = React.memo((props: McpProps) => { const { className, style, options = [], num = 0, children, onConfigureButtonClick, ...rest } = props; const onClick = useCallback((e: MouseEvent) => { // Prevent accidental closing of dropdown when clicking Button e.stopPropagation(); }, []); return ( {(locale: Locale['AIChatInput']) => (<>
{locale.selected.replace('${count}', String(options.length ?? num))}
{children ? children : <> {options.map((item: any) => ( {item.label} ))} } )} } >
); }); export default Mcp;