/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import React, { startTransition, useId, unstable_ViewTransition as ViewTransition, unstable_addTransitionType as addTransitionType, } from 'react'; import clsx from 'clsx'; import {TOGGLE_TAB_TRANSITION} from '../lib/transitionTypes'; export default function TabbedWindow({ tabs, activeTab, onTabChange, }: { tabs: Map; activeTab: string; onTabChange: (tab: string) => void; }): React.ReactElement { const id = useId(); const transitionName = `tab-highlight-${id}`; const handleTabChange = (tab: string): void => { startTransition(() => { addTransitionType(TOGGLE_TAB_TRANSITION); onTabChange(tab); }); }; return (
{Array.from(tabs.keys()).map(tab => { const isActive = activeTab === tab; return ( ); })}
{tabs.get(activeTab)}
); }