/** * Copyright (c) Facebook, Inc. and its 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, {cloneElement} from 'react'; import clsx from 'clsx'; import { useScrollPositionBlocker, useTabs, sanitizeTabsChildren, } from '@docusaurus/theme-common/internal'; import useIsBrowser from '@docusaurus/useIsBrowser'; import styles from './styles.module.css'; function TabList({className, block, selectedValue, selectValue, tabValues}) { const tabRefs = []; const {blockElementScrollPositionUntilNextRender} = useScrollPositionBlocker(); const handleTabChange = (event) => { const newTab = event.currentTarget; const newTabIndex = tabRefs.indexOf(newTab); const newTabValue = tabValues[newTabIndex].value; if (newTabValue !== selectedValue) { blockElementScrollPositionUntilNextRender(newTab); selectValue(newTabValue); } }; const handleKeydown = (event) => { let focusElement = null; switch (event.key) { case 'Enter': { handleTabChange(event); break; } case 'ArrowRight': { const nextTab = tabRefs.indexOf(event.currentTarget) + 1; focusElement = tabRefs[nextTab] ?? tabRefs[0]; break; } case 'ArrowLeft': { const prevTab = tabRefs.indexOf(event.currentTarget) - 1; focusElement = tabRefs[prevTab] ?? tabRefs[tabRefs.length - 1]; break; } default: break; } focusElement?.focus(); }; return (