import Paper from '@mui/material/Paper'; import Popper from '@mui/material/Popper'; import Tab from '@mui/material/Tab'; import * as React from 'react'; import type { IFieldDropdownOption } from '@automatisch/types'; import Suggestions from 'components/PowerInput/Suggestions'; import TabPanel from 'components/TabPanel'; import Options from './Options'; import { Tabs } from './style'; interface CustomOptionsProps { open: boolean; anchorEl: any; data: any; options: readonly IFieldDropdownOption[]; onSuggestionClick: any; onOptionClick: (event: React.MouseEvent, option: any) => void; onTabChange: (tabIndex: 0 | 1) => void; label?: string; initialTabIndex?: 0 | 1; }; const CustomOptions = (props: CustomOptionsProps) => { const { open, anchorEl, data, options = [], onSuggestionClick, onOptionClick, onTabChange, label, initialTabIndex, } = props; const [activeTabIndex, setActiveTabIndex] = React.useState(undefined); React.useEffect(function applyInitialActiveTabIndex() { setActiveTabIndex((currentActiveTabIndex) => { if (currentActiveTabIndex === undefined) { return initialTabIndex; } return currentActiveTabIndex; }); }, [initialTabIndex]); return ( { onTabChange(tabIndex); setActiveTabIndex(tabIndex); }} > ); }; export default CustomOptions;