Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,5 +469,25 @@ If you render a `TextField` from `Autocomplete`, the `params` shape also changed
}}
/>
)}
```

#### Alert deprecated props removed

Use the [alert-props codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#alert-props) below to migrate the code as described in the following section:

```bash
npx @mui/codemod@latest deprecations/alert-props <path>
```

The deprecated `Alert` props have been removed.
Use the `slots` and `slotProps` props instead:

```diff
<Alert
onClose={handleClose}
- components={{ CloseIcon: MyCloseIcon, CloseButton: MyCloseButton }}
- componentsProps={{ closeButton: { size: 'large' }, closeIcon: { fontSize: 'small' } }}
+ slots={{ closeIcon: MyCloseIcon, closeButton: MyCloseButton }}
+ slotProps={{ closeButton: { size: 'large' }, closeIcon: { fontSize: 'small' } }}
/>
```
15 changes: 0 additions & 15 deletions docs/pages/material-ui/api/alert.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@
"description": "'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
}
},
"components": {
"type": {
"name": "shape",
"description": "{ CloseButton?: elementType, CloseIcon?: elementType }"
},
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slots</code> prop instead. This prop will be removed in a future major release. See <a href=\"https://mui.com/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
},
"componentsProps": {
"type": { "name": "shape", "description": "{ closeButton?: object, closeIcon?: object }" },
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slotProps</code> prop instead. This prop will be removed in a future major release. See <a href=\"https://mui.com/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
},
"icon": { "type": { "name": "node" } },
"iconMapping": {
"type": {
Expand Down
4 changes: 0 additions & 4 deletions docs/translations/api-docs/alert/alert.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"color": {
"description": "The color of the component. Unless provided, the value is taken from the <code>severity</code> prop. It supports both default and custom theme colors, which can be added as shown in the <a href=\"https://mui.com/material-ui/customization/palette/#custom-colors\">palette customization guide</a>."
},
"components": { "description": "The components used for each slot inside." },
"componentsProps": {
"description": "The extra props for the slot components. You can override the existing props or add new ones."
},
"icon": {
"description": "Override the icon displayed before the children. Unless provided, the icon is mapped to the value of the <code>severity</code> prop. Set to <code>false</code> to remove the <code>icon</code>."
},
Expand Down
27 changes: 0 additions & 27 deletions packages/mui-material/src/Alert/Alert.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,33 +124,6 @@ export interface AlertProps extends StandardProps<PaperProps, 'variant'>, AlertS
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
*/
color?: OverridableStringUnion<AlertColor, AlertPropsColorOverrides> | undefined;
/**
* The components used for each slot inside.
*
* @deprecated use the `slots` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*
* @default {}
*/
components?:
| {
CloseButton?: React.ElementType | undefined;
CloseIcon?: React.ElementType | undefined;
}
| undefined;
/**
* The extra props for the slot components.
* You can override the existing props or add new ones.
*
* @deprecated use the `slotProps` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*
* @default {}
*/
componentsProps?:
| {
closeButton?: IconButtonProps | undefined;
closeIcon?: SvgIconProps | undefined;
}
| undefined;
/**
* The severity of the alert. This defines the color and icon used.
* @default 'success'
Expand Down
36 changes: 2 additions & 34 deletions packages/mui-material/src/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ const Alert = React.forwardRef(function Alert(inProps, ref) {
className,
closeText = 'Close',
color,
components = {},
componentsProps = {},
icon,
iconMapping = defaultIconMapping,
onClose,
Expand All @@ -187,15 +185,8 @@ const Alert = React.forwardRef(function Alert(inProps, ref) {
const classes = useUtilityClasses(ownerState);

const externalForwardedProps = {
slots: {
closeButton: components.CloseButton,
closeIcon: components.CloseIcon,
...slots,
},
slotProps: {
...componentsProps,
...slotProps,
},
slots,
slotProps,
};

const [RootSlot, rootSlotProps] = useSlot('root', {
Expand Down Expand Up @@ -311,29 +302,6 @@ Alert.propTypes /* remove-proptypes */ = {
PropTypes.oneOf(['error', 'info', 'success', 'warning']),
PropTypes.string,
]),
/**
* The components used for each slot inside.
*
* @deprecated use the `slots` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*
* @default {}
*/
components: PropTypes.shape({
CloseButton: PropTypes.elementType,
CloseIcon: PropTypes.elementType,
}),
/**
* The extra props for the slot components.
* You can override the existing props or add new ones.
*
* @deprecated use the `slotProps` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
*
* @default {}
*/
componentsProps: PropTypes.shape({
closeButton: PropTypes.object,
closeIcon: PropTypes.object,
}),
/**
* Override the icon displayed before the children.
* Unless provided, the icon is mapped to the value of the `severity` prop.
Expand Down
13 changes: 6 additions & 7 deletions packages/mui-material/src/Alert/Alert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('<Alert />', () => {
muiName: 'MuiAlert',
testVariantProps: { variant: 'standard', color: 'success' },
testDeepOverrides: { slotName: 'message', slotClassName: classes.message },
testLegacyComponentsProp: ['closeButton', 'closeIcon'],
slots: {
root: {
expectedClassName: classes.root,
Expand Down Expand Up @@ -96,14 +95,14 @@ describe('<Alert />', () => {
});
});

describe('prop: components', () => {
describe('slots.closeButton and slots.closeIcon', () => {
it('should override the default icon used in the close action', () => {
function MyCloseIcon() {
return <div data-testid="closeIcon">X</div>;
}

render(
<Alert onClose={() => {}} components={{ CloseIcon: MyCloseIcon }}>
<Alert onClose={() => {}} slots={{ closeIcon: MyCloseIcon }}>
Hello World
</Alert>,
);
Expand All @@ -117,7 +116,7 @@ describe('<Alert />', () => {
}

render(
<Alert onClose={() => {}} components={{ CloseButton: MyCloseButton }}>
<Alert onClose={() => {}} slots={{ closeButton: MyCloseButton }}>
Hello World
</Alert>,
);
Expand All @@ -126,12 +125,12 @@ describe('<Alert />', () => {
});
});

describe('prop: componentsProps', () => {
describe('slotProps.closeButton and slotProps.closeIcon', () => {
it('should apply the props on the close IconButton component', () => {
render(
<Alert
onClose={() => {}}
componentsProps={{
slotProps={{
closeButton: {
'data-testid': 'closeButton',
size: 'large',
Expand All @@ -152,7 +151,7 @@ describe('<Alert />', () => {
render(
<Alert
onClose={() => {}}
componentsProps={{
slotProps={{
closeIcon: {
'data-testid': 'closeIcon',
fontSize: 'large',
Expand Down
Loading