Skip to content

Commit 716a201

Browse files
committed
drop component prop
1 parent 01227d4 commit 716a201

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

packages/mui-base/src/Tab/Tab.spec.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,26 @@ const polymorphicComponentTest = () => {
2020
{/* @ts-expect-error */}
2121
<Tab value={0} invalidProp={0} />
2222

23-
<Tab value={0} component="a" href="#" />
23+
<Tab value={0} slots={{ root: 'a' }} href="#" />
2424

25-
<Tab value={0} component={CustomComponent} stringProp="test" numberProp={0} />
25+
<Tab<typeof CustomComponent>
26+
value={0}
27+
slots={{ root: CustomComponent }}
28+
stringProp="test"
29+
numberProp={0}
30+
/>
2631
{/* @ts-expect-error */}
27-
<Tab value={0} component={CustomComponent} />
32+
<Tab value={0} slots={{ root: { CustomComponent } }} />
2833

2934
<Tab
3035
value={0}
31-
component="button"
36+
slots={{ root: 'button' }}
3237
onClick={(e: React.MouseEvent<HTMLButtonElement>) => e.currentTarget.checkValidity()}
3338
/>
3439

3540
<Tab<'button'>
3641
value={0}
37-
component="button"
42+
slots={{ root: 'button' }}
3843
ref={(elem) => {
3944
expectType<HTMLButtonElement | null, typeof elem>(elem);
4045
}}

packages/mui-base/src/Tab/Tab.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ describe('<Tab />', () => {
6565
},
6666
skip: [
6767
'reactTestRenderer', // Need to be wrapped with TabsContext
68+
'componentProp'
6869
],
6970
}));
7071
});

packages/mui-base/src/Tab/Tab.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import * as React from 'react';
22
import PropTypes from 'prop-types';
3-
import { OverridableComponent } from '@mui/types';
43
import { unstable_useForkRef as useForkRef } from '@mui/utils';
54
import composeClasses from '../composeClasses';
65
import { getTabUtilityClass } from './tabClasses';
76
import { TabProps, TabTypeMap, TabRootSlotProps, TabOwnerState } from './Tab.types';
87
import useTab from '../useTab';
9-
import { useSlotProps, WithOptionalOwnerState } from '../utils';
8+
import { PolymorphicComponent, useSlotProps, WithOptionalOwnerState } from '../utils';
109
import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
1110

1211
const useUtilityClasses = (ownerState: TabOwnerState) => {
@@ -40,7 +39,6 @@ const Tab = React.forwardRef(function Tab<RootComponentType extends React.Elemen
4039
onChange,
4140
onClick,
4241
onFocus,
43-
component,
4442
slotProps = {},
4543
slots = {},
4644
...other
@@ -64,7 +62,7 @@ const Tab = React.forwardRef(function Tab<RootComponentType extends React.Elemen
6462

6563
const classes = useUtilityClasses(ownerState);
6664

67-
const TabRoot: React.ElementType = component ?? slots.root ?? 'button';
65+
const TabRoot: React.ElementType =slots.root ?? 'button';
6866
const tabRootProps: WithOptionalOwnerState<TabRootSlotProps> = useSlotProps({
6967
elementType: TabRoot,
7068
getSlotProps: getRootProps,
@@ -78,7 +76,7 @@ const Tab = React.forwardRef(function Tab<RootComponentType extends React.Elemen
7876
});
7977

8078
return <TabRoot {...tabRootProps}>{children}</TabRoot>;
81-
}) as OverridableComponent<TabTypeMap>;
79+
}) as PolymorphicComponent<TabTypeMap>;
8280

8381
Tab.propTypes /* remove-proptypes */ = {
8482
// ----------------------------- Warning --------------------------------

packages/mui-base/src/Tab/Tab.types.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { OverrideProps, Simplify } from '@mui/types';
1+
import { Simplify } from '@mui/types';
22
import * as React from 'react';
33
import { ButtonOwnProps } from '../Button';
44
import { SlotComponentProps } from '../utils';
55
import { UseTabRootSlotProps } from '../useTab';
6+
import { PolymorphicProps } from '../utils/PolymorphicComponent';
67

78
export interface TabRootSlotPropsOverrides {}
89

@@ -39,9 +40,7 @@ export interface TabSlots {
3940
}
4041

4142
export type TabProps<RootComponentType extends React.ElementType = TabTypeMap['defaultComponent']> =
42-
OverrideProps<TabTypeMap<{}, RootComponentType>, RootComponentType> & {
43-
component?: RootComponentType;
44-
};
43+
PolymorphicProps<TabTypeMap<{}, RootComponentType>, RootComponentType>;
4544

4645
export interface TabTypeMap<
4746
AdditionalProps = {},

0 commit comments

Comments
 (0)