Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fix propTypes in components where OverridableStringUnion is used #30682

Merged
merged 5 commits into from
Feb 2, 2022
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
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 @@ -171,7 +171,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([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 @@ -185,12 +188,18 @@ 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,
]),
/**
* 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