import React, { Children, useMemo, useState } from 'react';
import { Tab, Tabs } from '@mui/material';
import { TabContext, TabPanel } from '@mui/lab';
import makeStyles from '@mui/styles/makeStyles';
import { buildView } from '@pega/react-sdk-components/lib/components/helpers/field-group-utils';
import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
const useStyles = makeStyles(() => ({
tab: {
minWidth: '72px'
}
}));
interface DynamicTabsProps extends PConnProps {
// If any, enter additional props that only exist on this component
showLabel: boolean;
label: string;
referenceList?: any[];
}
function DynamicTabs(props: DynamicTabsProps) {
const classes = useStyles();
const { referenceList, showLabel, label, getPConnect } = props;
const pConnect = getPConnect();
// Get the inherited props from the parent to determine label settings
const propsToUse = { label, showLabel, ...pConnect.getInheritedProps() };
const defaultTabIndex = 0;
const { tablabel } = pConnect.getComponentConfig();
const tablabelProp = PCore.getAnnotationUtils().getPropertyName(tablabel);
const referenceListData: any = pConnect.getValue(`${referenceList}.pxResults`, ''); // 2nd arg empty string until typedefs properly allow optional
const memoisedTabViews = useMemo(() => {
pConnect.setInheritedProp('displayMode', 'DISPLAY_ONLY');
pConnect.setInheritedProp('readOnly', true);
return (
referenceListData &&
Children.toArray(
referenceListData.map((item, index) => {
return