import { cn, getFileExt } from "@/lib/utils"; import React, { useMemo, useState } from "react"; export type Tab = { title: string; icon?: React.ReactNode; render?: () => React.ReactNode; }; type Props = { tabs: Tab[]; current?: number; onChange?: (idx: number) => void; }; const Tabs = ({ tabs, current = 0, onChange }: Props) => { const tabView = useMemo(() => { const tab = tabs[current]; const element = tab?.render ? tab.render() : null; return element; }, [tabs, current]); return (
{tabs.length > 0 ? ( ) : null}
{tabView}
); }; type TabItemProps = { title: string; icon?: React.ReactNode; isActive?: boolean; onSelect: () => void; onClose: () => void; }; const TabItem = ({ title, icon, isActive, onSelect, onClose, }: TabItemProps) => { const lastDotFile = title.lastIndexOf("."); const ext = title.substring(lastDotFile); const filename = title.substring(0, lastDotFile); return ( ); }; export default Tabs;