import styled from '@emotion/styled'; import { type DraggableProvided, type DraggableRubric, type DraggableStateSnapshot, Droppable, } from '@hello-pangea/dnd'; import { TabButton } from 'twenty-ui/input'; import { TAB_LIST_GAP } from '@/ui/layout/tab-list/constants/TabListGap'; import { type SingleTabProps } from '@/ui/layout/tab-list/types/SingleTabProps'; import { PAGE_LAYOUT_TAB_LIST_DROPPABLE_IDS } from '@/page-layout/components/PageLayoutTabListDroppableIds'; import { PageLayoutTabListReorderableTab } from '@/page-layout/components/PageLayoutTabListReorderableTab'; import { PageLayoutTabRenderClone } from '@/page-layout/components/PageLayoutTabRenderClone'; type PageLayoutTabListVisibleTabsProps = { visibleTabs: SingleTabProps[]; visibleTabCount: number; activeTabId: string | null; behaveAsLinks: boolean; loading?: boolean; onChangeTab?: (tabId: string) => void; onSelectTab: (tabId: string) => void; canReorder: boolean; }; const StyledTabContainer = styled.div` display: flex; position: relative; overflow: hidden; max-width: 100%; > *:not(:last-child) { margin-right: ${TAB_LIST_GAP}px; } `; export const PageLayoutTabListVisibleTabs = ({ visibleTabs, visibleTabCount, activeTabId, behaveAsLinks, loading, onChangeTab, onSelectTab, canReorder, }: PageLayoutTabListVisibleTabsProps) => { if (canReorder) { return ( { const tab = visibleTabs[rubric.source.index]; return ( ); }} > {(provided) => ( {visibleTabs.slice(0, visibleTabCount).map((tab, index) => ( onSelectTab(tab.id)} /> ))} {provided.placeholder} )} ); } return ( {visibleTabs.slice(0, visibleTabCount).map((tab) => ( onChangeTab?.(tab.id) : () => onSelectTab(tab.id) } /> ))} ); };