| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { TabPanel, TabsContext } from 'react-aria-components'; |
| 3 |
import { Tab as TabType } from '../types'; |
| 4 |
import ErrorBoundary from '../ErrorBoundary'; |
| 5 |
import styles from '../AdminDetailsPage.module.scss'; |
| 6 |
import { useContext } from 'react'; |
| 7 |
|
| 8 |
/** |
| 9 |
* @since 4.4.0 |
| 10 |
*/ |
| 11 |
export default function TabPanels({ tabDefinitions }: { tabDefinitions: TabType[] }) { |
| 12 |
// @ts-ignore |
| 13 |
const {selectedKey} = useContext(TabsContext); |
| 14 |
const activeTab = tabDefinitions.find((tab) => tab.id === selectedKey); |
| 15 |
const isFullWidth = activeTab?.fullwidth; |
| 16 |
|
| 17 |
return ( |
| 18 |
<div className={`${styles.pageContent} ${isFullWidth ? styles.fullWidth : ''}`}> |
| 19 |
<ErrorBoundary> |
| 20 |
{tabDefinitions.map((tab) => ( |
| 21 |
<TabPanel key={tab.id} id={tab.id}> |
| 22 |
<tab.content /> |
| 23 |
</TabPanel> |
| 24 |
))} |
| 25 |
</ErrorBoundary> |
| 26 |
</div> |
| 27 |
); |
| 28 |
} |
| 29 |
|