Skip to content

Commit

Permalink
feat(TabList): separate the binding relationship between TabContext a…
Browse files Browse the repository at this point in the history
…nd RcTabList
  • Loading branch information
HaoZhouInRC authored and 233mawile-rc committed Dec 4, 2024
1 parent 4f44c5e commit ee40215
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import MuiTabContext, {
getPanelId,
getTabId,
useTabContext,
TabContextValue,
} from '@material-ui/lab/TabContext';

const RcTabContext = MuiTabContext as FunctionComponent<
Expand All @@ -12,4 +13,4 @@ const RcTabContext = MuiTabContext as FunctionComponent<

RcTabContext.displayName = 'RcTabContext';

export { getPanelId, getTabId, RcTabContext, useTabContext };
export { getPanelId, getTabId, RcTabContext, useTabContext, TabContextValue };
25 changes: 18 additions & 7 deletions packages/juno-core/src/components/Tabs/TabList/TabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,37 @@ import {
useThemeProps,
} from '../../../foundation';
import { RcTabProps } from '../Tab/Tab';
import { getPanelId, getTabId, useTabContext } from '../TabContext';
import {
getPanelId,
getTabId,
useTabContext,
TabContextValue,
} from '../TabContext';
import { RcTabs, RcTabsProps } from '../Tabs';
import { TabListStyle } from './styles';
import { RcTabListClasses } from './utils';

type RcTabListProps = {} & RcBaseProps<RcTabsProps>;
type RcTabListProps = Partial<TabContextValue> & RcBaseProps<RcTabsProps>;

const _RcTabList = forwardRef<any, RcTabListProps>(
(inProps: RcTabListProps, ref) => {
const props = useThemeProps({ props: inProps, name: 'RcTabList' });
const { classes: classesProp, children: childrenProp, ...rest } = props;
const {
classes: classesProp,
children: childrenProp,
idPrefix = '',
value,
...rest
} = props;
const classes = useMemo(
() => combineClasses(RcTabListClasses, classesProp),
[classesProp],
);

const context = useTabContext();
if (context === null) {
throw new TypeError('[RcTabList] No TabContext provided');
}
const context = useTabContext() || {
value,
idPrefix,
};

const children = useMemo(
() =>
Expand Down
2 changes: 1 addition & 1 deletion sync-github.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"latestCommitSHA": "d1f0e11c4041f850796e36ebc2e67def862b0b48"
"latestCommitSHA": "acd05954c6ebe53a00888d50324f5f0d94a5c44d"
}

0 comments on commit ee40215

Please sign in to comment.