From 43ef1a18706ed76d00597dc9bdc922bb8af4d92d Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Thu, 9 Jan 2025 10:03:57 +0700 Subject: [PATCH] fix slotProps types --- docs/pages/material-ui/api/alert.json | 2 +- packages/mui-material/src/Alert/Alert.d.ts | 12 ++++++++-- packages/mui-material/src/Alert/Alert.js | 28 ++-------------------- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/docs/pages/material-ui/api/alert.json b/docs/pages/material-ui/api/alert.json index 51d9a243bef167..0a5490bb494611 100644 --- a/docs/pages/material-ui/api/alert.json +++ b/docs/pages/material-ui/api/alert.json @@ -50,7 +50,7 @@ "slotProps": { "type": { "name": "shape", - "description": "{ action?: func
| { component?: elementType, sx?: Array<func
| object
| bool>
| func
| object }, closeButton?: func
| object, closeIcon?: func
| object, icon?: func
| object, message?: func
| { component?: elementType, sx?: Array<func
| object
| bool>
| func
| object }, root?: func
| object }" + "description": "{ action?: func
| object, closeButton?: func
| object, closeIcon?: func
| object, icon?: func
| object, message?: func
| object, root?: func
| object }" }, "default": "{}" }, diff --git a/packages/mui-material/src/Alert/Alert.d.ts b/packages/mui-material/src/Alert/Alert.d.ts index 9998cdc738da4b..24b8f2e53655af 100644 --- a/packages/mui-material/src/Alert/Alert.d.ts +++ b/packages/mui-material/src/Alert/Alert.d.ts @@ -76,12 +76,20 @@ export type AlertSlotsAndSlotProps = CreateSlotsAndSlotProps< * Props forwarded to the message slot. * By default, the avaible props are based on a div element. */ - message: SlotProps; + message: SlotProps< + React.ElementType>, + AlertMessageSlotPropsOverrides, + AlertOwnerState + >; /** * Props forwarded to the action slot. * By default, the avaible props are based on a div element. */ - action: SlotProps; + action: SlotProps< + React.ElementType>, + AlertActionSlotPropsOverrides, + AlertOwnerState + >; /** * Props forwarded to the closeButton slot. * By default, the avaible props are based on the [IconButton](https://mui.com/material-ui/api/icon-button/#props) component. diff --git a/packages/mui-material/src/Alert/Alert.js b/packages/mui-material/src/Alert/Alert.js index 9f1757e08ebbf9..b15421e10a8cf3 100644 --- a/packages/mui-material/src/Alert/Alert.js +++ b/packages/mui-material/src/Alert/Alert.js @@ -373,35 +373,11 @@ Alert.propTypes /* remove-proptypes */ = { * @default {} */ slotProps: PropTypes.shape({ - action: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ - component: PropTypes.elementType, - sx: PropTypes.oneOfType([ - PropTypes.arrayOf( - PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool]), - ), - PropTypes.func, - PropTypes.object, - ]), - }), - ]), + action: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), closeButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), closeIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), - message: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ - component: PropTypes.elementType, - sx: PropTypes.oneOfType([ - PropTypes.arrayOf( - PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool]), - ), - PropTypes.func, - PropTypes.object, - ]), - }), - ]), + message: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), }), /**