Skip to content

Commit

Permalink
[core] Fix propTypes in components where OverridableStringUnion is us…
Browse files Browse the repository at this point in the history
…ed (mui#30682)
  • Loading branch information
paales authored and wladimirguerra committed Feb 2, 2022
1 parent 353aafd commit b1ca57a
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/pages/api-docs/image-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"variant": {
"type": {
"name": "enum",
"description": "'masonry'<br>&#124;&nbsp;'quilted'<br>&#124;&nbsp;'standard'<br>&#124;&nbsp;'woven'"
"name": "union",
"description": "'masonry'<br>&#124;&nbsp;'quilted'<br>&#124;&nbsp;'standard'<br>&#124;&nbsp;'woven'<br>&#124;&nbsp;string"
},
"default": "'standard'"
}
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/api-docs/loading-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
"variant": {
"type": {
"name": "enum",
"description": "'contained'<br>&#124;&nbsp;'outlined'<br>&#124;&nbsp;'text'"
"name": "union",
"description": "'contained'<br>&#124;&nbsp;'outlined'<br>&#124;&nbsp;'text'<br>&#124;&nbsp;string"
},
"default": "'text'"
}
Expand Down
5 changes: 4 additions & 1 deletion docs/pages/api-docs/slider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
},
"scale": { "type": { "name": "func" }, "default": "(x) => x" },
"size": {
"type": { "name": "enum", "description": "'small'<br>&#124;&nbsp;'medium'" },
"type": {
"name": "union",
"description": "'small'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
"step": { "type": { "name": "number" }, "default": "1" },
Expand Down
7 changes: 0 additions & 7 deletions framer/Material-UI.framerfx/code/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ interface Props {
max?: number;
min?: number;
orientation?: 'horizontal' | 'vertical';
size: 'small' | 'medium';
step?: number;
tabIndex?: number;
track?: 'inverted' | 'normal' | false;
Expand All @@ -23,7 +22,6 @@ export function Slider(props: Props): JSX.Element {
}

Slider.defaultProps = {
size: 'medium' as 'medium',
width: 160,
height: 24,
};
Expand All @@ -50,11 +48,6 @@ addPropertyControls(Slider, {
title: 'Orientation',
options: ['horizontal', 'vertical'],
},
size: {
type: ControlType.Enum,
title: 'Size',
options: ['small', 'medium'],
},
step: {
type: ControlType.Number,
title: 'Step',
Expand Down
1 change: 1 addition & 0 deletions framer/scripts/framerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export const componentSettings = {
'sx',
// FIXME: `Union`
'color',
'size',
],
propValues: {
width: 160,
Expand Down
15 changes: 12 additions & 3 deletions packages/mui-joy/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ Button.propTypes /* remove-proptypes */ = {
* The color of the component. It supports those theme colors that make sense for this component.
* @default 'primary'
*/
color: PropTypes.oneOf(['context', 'danger', 'info', 'neutral', 'primary', 'success', 'warning']),
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['context', 'danger', 'info', 'neutral', 'primary', 'success', 'warning']),
PropTypes.string,
]),
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
Expand All @@ -237,7 +240,10 @@ Button.propTypes /* remove-proptypes */ = {
/**
* The size of the component.
*/
size: PropTypes.oneOf(['sm', 'md', 'lg']),
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['sm', 'md', 'lg']),
PropTypes.string,
]),
/**
* Element placed before the children.
*/
Expand All @@ -246,7 +252,10 @@ Button.propTypes /* remove-proptypes */ = {
* The variant to use.
* @default 'contained'
*/
variant: PropTypes.oneOf(['contained', 'light', 'outlined', 'text']),
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['contained', 'light', 'outlined', 'text']),
PropTypes.string,
]),
} as any;

export default Button;
10 changes: 8 additions & 2 deletions packages/mui-joy/src/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ Switch.propTypes /* remove-proptypes */ = {
* The color of the component. It supports those theme colors that make sense for this component.
* @default 'primary'
*/
color: PropTypes.oneOf(['danger', 'info', 'primary', 'success', 'warning']),
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['danger', 'info', 'primary', 'success', 'warning']),
PropTypes.string,
]),
/**
* The component used for the Root slot.
* Either a string to use a HTML element or a component.
Expand Down Expand Up @@ -278,7 +281,10 @@ Switch.propTypes /* remove-proptypes */ = {
* The size of the component.
* @default 'md'
*/
size: PropTypes.oneOf(['sm', 'md', 'lg']),
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['sm', 'md', 'lg']),
PropTypes.string,
]),
} as any;

export default Switch;
5 changes: 4 additions & 1 deletion packages/mui-lab/src/LoadingButton/LoadingButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ LoadingButton.propTypes /* remove-proptypes */ = {
* The variant to use.
* @default 'text'
*/
variant: PropTypes.oneOf(['contained', 'outlined', 'text']),
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['contained', 'outlined', 'text']),
PropTypes.string,
]),
};

export default LoadingButton;
5 changes: 4 additions & 1 deletion packages/mui-material/src/ImageList/ImageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ ImageList.propTypes /* remove-proptypes */ = {
* The variant to use.
* @default 'standard'
*/
variant: PropTypes.oneOf(['masonry', 'quilted', 'standard', 'woven']),
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['masonry', 'quilted', 'standard', 'woven']),
PropTypes.string,
]),
};

export default ImageList;
5 changes: 4 additions & 1 deletion packages/mui-material/src/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ Slider.propTypes /* remove-proptypes */ = {
* The size of the slider.
* @default 'medium'
*/
size: PropTypes.oneOf(['small', 'medium']),
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['small', 'medium']),
PropTypes.string,
]),
/**
* The granularity with which the slider can step through values. (A "discrete" slider.)
* The `min` prop serves as the origin for the valid values.
Expand Down

0 comments on commit b1ca57a

Please sign in to comment.