import type { FC } from 'react' import { memo } from 'react' import type { BlockEnum } from '../types' import { useTabs } from './hooks' import type { ToolDefaultValue } from './types' import { TabsEnum } from './types' import Blocks from './blocks' import AllTools from './all-tools' import cn from '@/utils/classnames' export type TabsProps = { activeTab: TabsEnum onActiveTabChange: (activeTab: TabsEnum) => void searchText: string onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void availableBlocksTypes?: BlockEnum[] noBlocks?: boolean } const Tabs: FC = ({ activeTab, onActiveTabChange, searchText, onSelect, availableBlocksTypes, noBlocks, }) => { const tabs = useTabs() return (
e.stopPropagation()}> { !noBlocks && (
{ tabs.map(tab => (
onActiveTabChange(tab.key)} > {tab.name}
)) }
) } { activeTab === TabsEnum.Blocks && !noBlocks && ( ) } { activeTab === TabsEnum.Tools && ( ) }
) } export default memo(Tabs)