From ea57ed832f4c1cf3494889c30f1683086c457d88 Mon Sep 17 00:00:00 2001 From: myusername Date: Fri, 18 Jun 2021 19:07:31 +0100 Subject: [PATCH 1/3] Add AlertPropsColorOverrides --- packages/material-ui/src/Alert/Alert.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/material-ui/src/Alert/Alert.d.ts b/packages/material-ui/src/Alert/Alert.d.ts index e54b4319f14deb..d69f4c60ae722f 100644 --- a/packages/material-ui/src/Alert/Alert.d.ts +++ b/packages/material-ui/src/Alert/Alert.d.ts @@ -9,6 +9,8 @@ export type Color = 'success' | 'info' | 'warning' | 'error'; export interface AlertPropsVariantOverrides {} +export interface AlertPropsColorOverrides {} + export interface AlertProps extends StandardProps { /** * The action to display. It renders after the message, at the end of the alert. @@ -28,7 +30,7 @@ export interface AlertProps extends StandardProps { /** * The main color for the alert. Unless provided, the value is taken from the `severity` prop. */ - color?: Color; + color?: OverridableStringUnion; /** * The severity of the alert. This defines the color and icon used. * @default 'success' From 41c09cfcf74ee97db2e73bbaa6d68c2d78d48adf Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sat, 19 Jun 2021 00:11:15 +0200 Subject: [PATCH 2/3] push one step further --- docs/pages/api-docs/alert.json | 4 ++-- packages/material-ui/src/Alert/Alert.d.ts | 3 +-- packages/material-ui/src/Alert/Alert.js | 8 +++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/pages/api-docs/alert.json b/docs/pages/api-docs/alert.json index 4cbe542220066d..dac98c4ef6cbc2 100644 --- a/docs/pages/api-docs/alert.json +++ b/docs/pages/api-docs/alert.json @@ -6,8 +6,8 @@ "closeText": { "type": { "name": "string" }, "default": "'Close'" }, "color": { "type": { - "name": "enum", - "description": "'error'
| 'info'
| 'success'
| 'warning'" + "name": "union", + "description": "'error'
| 'info'
| 'success'
| 'warning'
| string" } }, "icon": { "type": { "name": "node" } }, diff --git a/packages/material-ui/src/Alert/Alert.d.ts b/packages/material-ui/src/Alert/Alert.d.ts index d69f4c60ae722f..ce0139dd00955b 100644 --- a/packages/material-ui/src/Alert/Alert.d.ts +++ b/packages/material-ui/src/Alert/Alert.d.ts @@ -5,7 +5,7 @@ import { InternalStandardProps as StandardProps, Theme } from '..'; import { PaperProps } from '../Paper'; import { AlertClasses } from './alertClasses'; -export type Color = 'success' | 'info' | 'warning' | 'error'; +type Color = 'success' | 'info' | 'warning' | 'error'; export interface AlertPropsVariantOverrides {} @@ -56,7 +56,6 @@ export interface AlertProps extends StandardProps { /** * Callback fired when the component requests to be closed. * When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked. - * * @param {object} event The event source of the callback. */ onClose?: (event: React.SyntheticEvent) => void; diff --git a/packages/material-ui/src/Alert/Alert.js b/packages/material-ui/src/Alert/Alert.js index 796b3e984b6794..f13e17cd535d92 100644 --- a/packages/material-ui/src/Alert/Alert.js +++ b/packages/material-ui/src/Alert/Alert.js @@ -141,9 +141,9 @@ const Alert = React.forwardRef(function Alert(inProps, ref) { const styleProps = { ...props, - variant, color, severity, + variant, }; const classes = useUtilityClasses(styleProps); @@ -215,7 +215,10 @@ Alert.propTypes /* remove-proptypes */ = { /** * The main color for the alert. Unless provided, the value is taken from the `severity` prop. */ - color: PropTypes.oneOf(['error', 'info', 'success', 'warning']), + color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([ + PropTypes.oneOf(['error', 'info', 'success', 'warning']), + PropTypes.string, + ]), /** * Override the icon displayed before the children. * Unless provided, the icon is mapped to the value of the `severity` prop. @@ -236,7 +239,6 @@ Alert.propTypes /* remove-proptypes */ = { /** * Callback fired when the component requests to be closed. * When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked. - * * @param {object} event The event source of the callback. */ onClose: PropTypes.func, From 3c3ab7dbbe6055e1cade1358e7045d62c5402634 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sat, 19 Jun 2021 01:08:53 +0200 Subject: [PATCH 3/3] fix types --- packages/material-ui/src/Alert/Alert.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/material-ui/src/Alert/Alert.d.ts b/packages/material-ui/src/Alert/Alert.d.ts index ce0139dd00955b..c442d20af86369 100644 --- a/packages/material-ui/src/Alert/Alert.d.ts +++ b/packages/material-ui/src/Alert/Alert.d.ts @@ -5,7 +5,7 @@ import { InternalStandardProps as StandardProps, Theme } from '..'; import { PaperProps } from '../Paper'; import { AlertClasses } from './alertClasses'; -type Color = 'success' | 'info' | 'warning' | 'error'; +export type AlertColor = 'success' | 'info' | 'warning' | 'error'; export interface AlertPropsVariantOverrides {} @@ -30,12 +30,12 @@ export interface AlertProps extends StandardProps { /** * The main color for the alert. Unless provided, the value is taken from the `severity` prop. */ - color?: OverridableStringUnion; + color?: OverridableStringUnion; /** * The severity of the alert. This defines the color and icon used. * @default 'success' */ - severity?: Color; + severity?: AlertColor; /** * Override the icon displayed before the children. * Unless provided, the icon is mapped to the value of the `severity` prop. @@ -52,7 +52,7 @@ export interface AlertProps extends StandardProps { * If you wish to change this mapping, you can provide your own. * Alternatively, you can use the `icon` prop to override the icon displayed. */ - iconMapping?: Partial>; + iconMapping?: Partial>; /** * Callback fired when the component requests to be closed. * When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.