import type { ElementRef, TeactNode } from '../../lib/teact/teact'; import { memo, useRef } from '../../lib/teact/teact'; import type { ApiMessageEntityCustomEmoji } from '../../api/types'; import type { IconName } from '../../types/icons'; import type { MenuItemContextAction } from './ListItem'; import buildClassName from '../../util/buildClassName'; import useHorizontalScroll from '../../hooks/useHorizontalScroll'; import useLang from '../../hooks/useLang'; import usePreviousDeprecated from '../../hooks/usePreviousDeprecated'; import useScrollToActiveTab from '../../hooks/useScrollToActiveTab'; import Tab from './Tab'; import './SquareTabList.scss'; export type TabWithProperties = { id?: number; title: TeactNode; icon?: IconName; badgeCount?: number; isBlocked?: boolean; isBadgeActive?: boolean; contextActions?: MenuItemContextAction[]; emoticon?: string | ApiMessageEntityCustomEmoji; customEmojiDocumentId?: string; noTitleAnimations?: boolean; }; type OwnProps = { tabs: readonly TabWithProperties[]; activeTab: number; className?: string; tabClassName?: string; contextRootElementSelector?: string; ref?: ElementRef; onSwitchTab: (index: number) => void; }; const SquareTabList = ({ tabs, activeTab, className, tabClassName, contextRootElementSelector, ref, onSwitchTab, }: OwnProps) => { const internalRef = useRef(); const containerRef = ref || internalRef; const previousActiveTab = usePreviousDeprecated(activeTab); const lang = useLang(); useHorizontalScroll(containerRef, undefined, true); useScrollToActiveTab(containerRef, activeTab); return (
{tabs.map((tab, i) => ( ))}
); }; export default memo(SquareTabList);