import React, { useState } from "react"; import styles from "./TabView.module.scss"; import { utils } from "../../main"; import TextBlock from "../text/TextBlock"; interface Props { tabs: { label: string; content: JSX.Element; }[]; } export interface RefInstance { } const TabView = React.forwardRef((props, ref) => { const [ tabIndex, setTabIndex ] = useState(0); props = utils.mergeObject({ tabs: [] }, props); if (props.tabs.length == 0) { props.tabs.push({ label: "Label", content: ( <> Body ) }) } return (
{ props.tabs.map((tab, index) => { return ( ); }) }
{ props.tabs.map((tab, index) => { if (index == tabIndex) { return (
{ tab.content }
); } }) }
); }); export default TabView;