import type { FC } from 'react' import { memo, useState, } from 'react' import BlockIcon from '../block-icon' import type { BlockEnum } from '../types' import { BLOCK_CLASSIFICATIONS, BLOCK_GROUP_BY_CLASSIFICATION, TABS, } from './constants' export type TabsProps = { onSelect: (type: BlockEnum) => void } const Tabs: FC = ({ onSelect, }) => { const [activeTab, setActiveTab] = useState(TABS[0].key) return (
{ TABS.map(tab => (
setActiveTab(tab.key)} > {tab.name}
)) }
{ BLOCK_CLASSIFICATIONS.map(classification => (
{ classification !== '-' && (
{classification}
) } { BLOCK_GROUP_BY_CLASSIFICATION[classification].map(block => (
{ e.stopPropagation() onSelect(block.type) }} >
{block.title}
)) }
)) }
) } export default memo(Tabs)