import type { FC } from 'react' import { memo, useState, } from 'react' import { groupBy } from 'lodash-es' import BlockIcon from '../block-icon' import type { BlockEnum } from '../types' import { BLOCK_CLASSIFICATIONS } from './constants' import { useBlocks, useTabs, } from './hooks' import type { ToolDefaultValue } from './types' import { TabsEnum } from './types' import Tools from './tools' export type TabsProps = { onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void } const Tabs: FC = ({ onSelect, }) => { const blocks = useBlocks() const tabs = useTabs() const [activeTab, setActiveTab] = useState(tabs[0].key) return (
e.stopPropagation()}>
{ tabs.map(tab => (
setActiveTab(tab.key)} > {tab.name}
)) }
{ activeTab === TabsEnum.Blocks && (
{ BLOCK_CLASSIFICATIONS.map(classification => (
{ classification !== '-' && (
{classification}
) } { groupBy(blocks, 'classification')[classification].map(block => (
onSelect(block.type)} >
{block.title}
)) }
)) }
) } { activeTab === TabsEnum.BuiltInTool && ( ) } { activeTab === TabsEnum.CustomTool && ( ) }
) } export default memo(Tabs)