diff --git a/docs/pages/api-docs/collapse.md b/docs/pages/api-docs/collapse.md index 87a983dde7e51c..4b7eaf8e07dc16 100644 --- a/docs/pages/api-docs/collapse.md +++ b/docs/pages/api-docs/collapse.md @@ -28,10 +28,10 @@ It uses [react-transition-group](https://github.com/reactjs/react-transition-gro |:-----|:-----|:--------|:------------| | children | node | | The content node to be collapsed. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | -| collapsedHeight | string
| number
| '0px' | The height of the container when collapsed. | +| collapsedHeight | number
| string
| '0px' | The height of the container when collapsed. | | component | elementType | 'div' | The component used for the root node. Either a string to use a DOM element or a component. | | in | bool | | If `true`, the component will transition in. | -| timeout | number
| { enter?: number, exit?: number }
| 'auto'
| duration.standard | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.
Set to 'auto' to automatically calculate transition time based on height. | +| timeout | 'auto'
| number
| { appear?: number, enter?: number, exit?: number }
| duration.standard | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.
Set to 'auto' to automatically calculate transition time based on height. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/dialog-title.md b/docs/pages/api-docs/dialog-title.md index d539bf04e51d22..1b088ca2355dbc 100644 --- a/docs/pages/api-docs/dialog-title.md +++ b/docs/pages/api-docs/dialog-title.md @@ -24,7 +24,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| -| children * | node | | The content of the component. | +| children | node | | The content of the component. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | disableTypography | bool | false | If `true`, the children won't be wrapped by a typography component. For instance, this can be useful to render an h4 instead of the default h2. | diff --git a/docs/pages/api-docs/drawer.md b/docs/pages/api-docs/drawer.md index 1990635c0f441d..4cd0ba37d5f311 100644 --- a/docs/pages/api-docs/drawer.md +++ b/docs/pages/api-docs/drawer.md @@ -25,7 +25,7 @@ when `variant="temporary"` is set. | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| -| anchor | 'left'
| 'top'
| 'right'
| 'bottom'
| 'left' | Side from which the drawer will appear. | +| anchor | 'bottom'
| 'left'
| 'right'
| 'top'
| 'left' | Side from which the drawer will appear. | | children | node | | The contents of the drawer. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | elevation | number | 16 | The elevation of the drawer. | @@ -34,7 +34,7 @@ when `variant="temporary"` is set. | open | bool | false | If `true`, the drawer is open. | | PaperProps | object | {} | Props applied to the [`Paper`](/api/paper/) element. | | SlideProps | object | | Props applied to the [`Slide`](/api/slide/) element. | -| transitionDuration | number
| { enter?: number, exit?: number }
| { enter: duration.enteringScreen, exit: duration.leavingScreen } | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object. | +| transitionDuration | number
| { appear?: number, enter?: number, exit?: number }
| { enter: duration.enteringScreen, exit: duration.leavingScreen } | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object. | | variant | 'permanent'
| 'persistent'
| 'temporary'
| 'temporary' | The variant to use. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/expansion-panel-actions.md b/docs/pages/api-docs/expansion-panel-actions.md index 98332c1600d962..1e6448c023f3c2 100644 --- a/docs/pages/api-docs/expansion-panel-actions.md +++ b/docs/pages/api-docs/expansion-panel-actions.md @@ -24,7 +24,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| -| children * | node | | The content of the component. | +| children | node | | The content of the component. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | disableSpacing | bool | false | If `true`, the actions do not have additional margin. | diff --git a/docs/pages/api-docs/expansion-panel-details.md b/docs/pages/api-docs/expansion-panel-details.md index d5fd6c28a6dc01..2bdb266a2860e3 100644 --- a/docs/pages/api-docs/expansion-panel-details.md +++ b/docs/pages/api-docs/expansion-panel-details.md @@ -24,7 +24,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| -| children * | node | | The content of the expansion panel details. | +| children | node | | The content of the expansion panel details. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/fade.md b/docs/pages/api-docs/fade.md index 0032e4d0847cfa..958648b27fa10c 100644 --- a/docs/pages/api-docs/fade.md +++ b/docs/pages/api-docs/fade.md @@ -27,7 +27,7 @@ It uses [react-transition-group](https://github.com/reactjs/react-transition-gro |:-----|:-----|:--------|:------------| | children | element | | A single child content element. | | in | bool | | If `true`, the component will transition in. | -| timeout | number
| { enter?: number, exit?: number }
| { enter: duration.enteringScreen, exit: duration.leavingScreen,} | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object. | +| timeout | number
| { appear?: number, enter?: number, exit?: number }
| { enter: duration.enteringScreen, exit: duration.leavingScreen,} | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/grid-list-tile-bar.md b/docs/pages/api-docs/grid-list-tile-bar.md index 8b8c24395e9334..9194cb0a411be5 100644 --- a/docs/pages/api-docs/grid-list-tile-bar.md +++ b/docs/pages/api-docs/grid-list-tile-bar.md @@ -29,7 +29,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | subtitle | node | | String or element serving as subtitle (support text). | | title | node | | Title to be displayed on tile. | -| titlePosition | 'top'
| 'bottom'
| 'bottom' | Position of the title bar. | +| titlePosition | 'bottom'
| 'top'
| 'bottom' | Position of the title bar. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/grow.md b/docs/pages/api-docs/grow.md index 6be835581d90b6..ec9b1a21b75d80 100644 --- a/docs/pages/api-docs/grow.md +++ b/docs/pages/api-docs/grow.md @@ -28,7 +28,7 @@ It uses [react-transition-group](https://github.com/reactjs/react-transition-gro |:-----|:-----|:--------|:------------| | children | element | | A single child content element. | | in | bool | | If `true`, show the component; triggers the enter or exit animation. | -| timeout | number
| { enter?: number, exit?: number }
| 'auto'
| 'auto' | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.
Set to 'auto' to automatically calculate transition time based on height. | +| timeout | 'auto'
| number
| { appear?: number, enter?: number, exit?: number }
| 'auto' | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.
Set to 'auto' to automatically calculate transition time based on height. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/linear-progress.md b/docs/pages/api-docs/linear-progress.md index a45999a6133292..c2aa4275694edf 100644 --- a/docs/pages/api-docs/linear-progress.md +++ b/docs/pages/api-docs/linear-progress.md @@ -32,7 +32,7 @@ attribute to `true` on that region until it has finished loading. | color | 'primary'
| 'secondary'
| 'primary' | The color of the component. It supports those theme colors that make sense for this component. | | value | number | | The value of the progress indicator for the determinate and buffer variants. Value between 0 and 100. | | valueBuffer | number | | The value for the buffer variant. Value between 0 and 100. | -| variant | 'determinate'
| 'indeterminate'
| 'buffer'
| 'query'
| 'indeterminate' | The variant to use. Use indeterminate or query when there is no progress value. | +| variant | 'buffer'
| 'determinate'
| 'indeterminate'
| 'query'
| 'indeterminate' | The variant to use. Use indeterminate or query when there is no progress value. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/menu-list.md b/docs/pages/api-docs/menu-list.md index 39a7b425f0ed54..be4b6d4cfdb414 100644 --- a/docs/pages/api-docs/menu-list.md +++ b/docs/pages/api-docs/menu-list.md @@ -27,8 +27,8 @@ the focus is placed inside the component it is fully keyboard accessible. | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| -| autoFocus | bool | false | If `true`, will focus the `[role="menu"]` container and move into tab order | -| autoFocusItem | bool | false | If `true`, will focus the first menuitem if `variant="menu"` or selected item if `variant="selectedMenu"` | +| autoFocus | bool | false | If `true`, will focus the `[role="menu"]` container and move into tab order. | +| autoFocusItem | bool | false | If `true`, will focus the first menuitem if `variant="menu"` or selected item if `variant="selectedMenu"`. | | children | node | | MenuList contents, normally `MenuItem`s. | | disableListWrap | bool | false | If `true`, the menu items will not wrap focus. | | variant | 'menu'
| 'selectedMenu'
| 'selectedMenu' | The variant to use. Use `menu` to prevent selected items from impacting the initial focus and the vertical alignment relative to the anchor element. | diff --git a/docs/pages/api-docs/menu.md b/docs/pages/api-docs/menu.md index 5abae1f0a9ce7c..33b469cc05f0a7 100644 --- a/docs/pages/api-docs/menu.md +++ b/docs/pages/api-docs/menu.md @@ -24,7 +24,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| -| anchorEl | object
| func
| | The DOM element used to set the position of the menu. | +| anchorEl | func
| Element
| | The DOM element used to set the position of the menu. | | autoFocus | bool | true | If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled children are not focusable. If you set this prop to `false` focus will be placed on the parent modal container. This has severe accessibility implications and should only be considered if you manage focus otherwise. | | children | node | | Menu contents, normally `MenuItem`s. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | @@ -39,7 +39,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | onExiting | func | | Callback fired when the Menu is exiting. | | open * | bool | | If `true`, the menu is visible. | | PopoverClasses | object | | `classes` prop applied to the [`Popover`](/api/popover/) element. | -| transitionDuration | number
| { enter?: number, exit?: number }
| 'auto'
| 'auto' | The length of the transition in `ms`, or 'auto' | +| transitionDuration | 'auto'
| number
| { appear?: number, enter?: number, exit?: number }
| 'auto' | The length of the transition in `ms`, or 'auto' | | variant | 'menu'
| 'selectedMenu'
| 'selectedMenu' | The variant to use. Use `menu` to prevent selected items from impacting the initial focus and the vertical alignment relative to the anchor element. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/mobile-stepper.md b/docs/pages/api-docs/mobile-stepper.md index 20289217e97884..33f57ddc40901f 100644 --- a/docs/pages/api-docs/mobile-stepper.md +++ b/docs/pages/api-docs/mobile-stepper.md @@ -29,9 +29,9 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | LinearProgressProps | object | | Props applied to the `LinearProgress` element. | | nextButton | node | | A next button element. For instance, it can be a `Button` or an `IconButton`. | -| position | 'bottom'
| 'top'
| 'static'
| 'bottom' | Set the positioning type. | +| position | 'bottom'
| 'static'
| 'top'
| 'bottom' | Set the positioning type. | | steps * | number | | The total steps. | -| variant | 'text'
| 'dots'
| 'progress'
| 'dots' | The variant to use. | +| variant | 'dots'
| 'progress'
| 'text'
| 'dots' | The variant to use. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/radio-group.md b/docs/pages/api-docs/radio-group.md index 4fe300e1e5d0ba..9190a69909414a 100644 --- a/docs/pages/api-docs/radio-group.md +++ b/docs/pages/api-docs/radio-group.md @@ -25,7 +25,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| | children | node | | The content of the component. | -| defaultValue | any | | The default `input` element value. Use when the component is not controlled. | +| defaultValue | Array<string>
| number
| string
| | The default `input` element value. Use when the component is not controlled. | | name | string | | The name used to reference the value of the control. If you don't provide this prop, it falls back to a randomly generated name. | | onChange | func | | Callback fired when a radio button is selected.

**Signature:**
`function(event: object) => void`
*event:* The event source of the callback. You can pull out the new value by accessing `event.target.value` (string). | | value | any | | Value of the selected radio button. The DOM API casts this to a string. | diff --git a/docs/pages/api-docs/snackbar.md b/docs/pages/api-docs/snackbar.md index 144faf806a0505..5bc80a34616c5c 100644 --- a/docs/pages/api-docs/snackbar.md +++ b/docs/pages/api-docs/snackbar.md @@ -25,7 +25,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | Name | Type | Default | Description | |:-----|:-----|:--------|:------------| | action | node | | The action to display. It renders after the message, at the end of the snackbar. | -| anchorOrigin | { horizontal: 'left'
| 'center'
| 'right', vertical: 'top'
| 'bottom' }
| { vertical: 'bottom', horizontal: 'center' } | The anchor of the `Snackbar`. | +| anchorOrigin | { horizontal: 'center'
| 'left'
| 'right', vertical: 'bottom'
| 'top' }
| { vertical: 'bottom', horizontal: 'center' } | The anchor of the `Snackbar`. | | autoHideDuration | number | null | The number of milliseconds to wait before automatically calling the `onClose` function. `onClose` should then set the state of the `open` prop to hide the Snackbar. This behavior is disabled by default with the `null` value. | | children | element | | Replace the `SnackbarContent` component. | | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | @@ -44,7 +44,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | open | bool | | If `true`, `Snackbar` is open. | | resumeHideDuration | number | | The number of milliseconds to wait before dismissing after user interaction. If `autoHideDuration` prop isn't specified, it does nothing. If `autoHideDuration` prop is specified but `resumeHideDuration` isn't, we default to `autoHideDuration / 2` ms. | | TransitionComponent | elementType | Grow | The component used for the transition. [Follow this guide](/components/transitions/#transitioncomponent-prop) to learn more about the requirements for this component. | -| transitionDuration | number
| { enter?: number, exit?: number }
| { enter: duration.enteringScreen, exit: duration.leavingScreen,} | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object. | +| transitionDuration | number
| { appear?: number, enter?: number, exit?: number }
| { enter: duration.enteringScreen, exit: duration.leavingScreen,} | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object. | | TransitionProps | object | | Props applied to the [`Transition`](http://reactcommunity.org/react-transition-group/transition#Transition-props) element. | The `ref` is forwarded to the root element. diff --git a/docs/src/modules/utils/defaultPropsHandler.js b/docs/src/modules/utils/defaultPropsHandler.js index 961a1524b2d4a0..9f456176855b18 100644 --- a/docs/src/modules/utils/defaultPropsHandler.js +++ b/docs/src/modules/utils/defaultPropsHandler.js @@ -61,6 +61,13 @@ function getDefaultValuesFromProps(properties, documentation) { if (!propName) return; const propDescriptor = documentation.getPropDescriptor(propName); + if (propDescriptor.description === undefined) { + // private props have no propsType validator and therefore + // not description. + // They are either not subject to eslint react/prop-types + // or are and then we catch these issues during linting. + return; + } const jsdocDefaultValue = getJsdocDefaultValue( parseDoctrine(propDescriptor.description, { diff --git a/docs/src/pages/components/snackbars/TransitionsSnackbar.tsx b/docs/src/pages/components/snackbars/TransitionsSnackbar.tsx index 3826a3b6bc7216..7a44e0377a6806 100644 --- a/docs/src/pages/components/snackbars/TransitionsSnackbar.tsx +++ b/docs/src/pages/components/snackbars/TransitionsSnackbar.tsx @@ -15,7 +15,10 @@ function GrowTransition(props: TransitionProps) { } export default function TransitionsSnackbar() { - const [state, setState] = React.useState({ + const [state, setState] = React.useState<{ + open: boolean; + Transition: React.ComponentType; + }>({ open: false, Transition: Fade, }); diff --git a/packages/material-ui/src/Backdrop/Backdrop.d.ts b/packages/material-ui/src/Backdrop/Backdrop.d.ts index 0deddf3c1e2d9a..9f309a944b82d8 100644 --- a/packages/material-ui/src/Backdrop/Backdrop.d.ts +++ b/packages/material-ui/src/Backdrop/Backdrop.d.ts @@ -5,7 +5,7 @@ import { TransitionProps } from '../transitions/transition'; export interface BackdropProps extends StandardProps< - React.HTMLAttributes & Partial, + React.HTMLAttributes & Partial>, BackdropClassKey > { /** diff --git a/packages/material-ui/src/Card/Card.d.ts b/packages/material-ui/src/Card/Card.d.ts index 113111f40474d1..684339eab7cda0 100644 --- a/packages/material-ui/src/Card/Card.d.ts +++ b/packages/material-ui/src/Card/Card.d.ts @@ -3,6 +3,9 @@ import { StandardProps } from '..'; import { PaperProps } from '../Paper'; export interface CardProps extends StandardProps { + /** + * If `true`, the card will use raised styling. + */ raised?: boolean; } @@ -19,6 +22,4 @@ export type CardClassKey = 'root'; * - [Card API](https://material-ui.com/api/card/) * - inherits [Paper API](https://material-ui.com/api/paper/) */ -declare const Card: React.ComponentType; - -export default Card; +export default function Card(props: CardProps): JSX.Element; diff --git a/packages/material-ui/src/Card/Card.js b/packages/material-ui/src/Card/Card.js index 42df3f421d6ba7..71c7d9ce7e31b3 100644 --- a/packages/material-ui/src/Card/Card.js +++ b/packages/material-ui/src/Card/Card.js @@ -25,6 +25,10 @@ const Card = React.forwardRef(function Card(props, ref) { }); Card.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ @@ -33,7 +37,7 @@ Card.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/CardActions/CardActions.d.ts b/packages/material-ui/src/CardActions/CardActions.d.ts index c7b138a5ecbeb2..0b24a5b78df3da 100644 --- a/packages/material-ui/src/CardActions/CardActions.d.ts +++ b/packages/material-ui/src/CardActions/CardActions.d.ts @@ -3,6 +3,9 @@ import { StandardProps } from '..'; export interface CardActionsProps extends StandardProps, CardActionsClassKey> { + /** + * If `true`, the actions do not have additional margin. + */ disableSpacing?: boolean; } @@ -18,6 +21,4 @@ export type CardActionsClassKey = 'root' | 'spacing'; * * - [CardActions API](https://material-ui.com/api/card-actions/) */ -declare const CardActions: React.ComponentType; - -export default CardActions; +export default function CardActions(props: CardActionsProps): JSX.Element; diff --git a/packages/material-ui/src/CardActions/CardActions.js b/packages/material-ui/src/CardActions/CardActions.js index 86aa4e8d22d0a1..e2499ce6e3996e 100644 --- a/packages/material-ui/src/CardActions/CardActions.js +++ b/packages/material-ui/src/CardActions/CardActions.js @@ -31,6 +31,10 @@ const CardActions = React.forwardRef(function CardActions(props, ref) { }); CardActions.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ @@ -39,7 +43,7 @@ CardActions.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/Collapse/Collapse.d.ts b/packages/material-ui/src/Collapse/Collapse.d.ts index c49623260e2986..356285615cd0b0 100644 --- a/packages/material-ui/src/Collapse/Collapse.d.ts +++ b/packages/material-ui/src/Collapse/Collapse.d.ts @@ -4,10 +4,44 @@ import { Theme } from '../styles/createMuiTheme'; import { TransitionProps } from '../transitions/transition'; export interface CollapseProps extends StandardProps { + /** + * The content node to be collapsed. + */ children?: React.ReactNode; + /** + * The height of the container when collapsed. + */ collapsedHeight?: string | number; + /** + * The component used for the root node. + * Either a string to use a DOM element or a component. + */ component?: React.ElementType; - theme?: Theme; + /** + * If `true`, the component will transition in. + */ + in?: boolean; + /** + */ + onEnter?: TransitionProps['onEnter']; + /** + */ + onEntered?: TransitionProps['onEntered']; + /** + */ + onEntering?: TransitionProps['onEntering']; + /** + */ + onExit?: TransitionProps['onExit']; + /** + */ + onExiting?: TransitionProps['onExiting']; + /** + * The duration for the transition, in milliseconds. + * You may specify a single timeout for all transitions, or individually with an object. + * + * Set to 'auto' to automatically calculate transition time based on height. + */ timeout?: TransitionProps['timeout'] | 'auto'; } @@ -28,6 +62,5 @@ export type CollapseClassKey = 'container' | 'entered' | 'hidden' | 'wrapper' | * - [Collapse API](https://material-ui.com/api/collapse/) * - inherits [Transition API](https://reactcommunity.org/react-transition-group/transition#Transition-props) */ -declare const Collapse: React.ComponentType; -export default Collapse; +export default function Collapse(props: CollapseProps): JSX.Element; diff --git a/packages/material-ui/src/Collapse/Collapse.js b/packages/material-ui/src/Collapse/Collapse.js index 80389e4a955fd7..88c812840d259e 100644 --- a/packages/material-ui/src/Collapse/Collapse.js +++ b/packages/material-ui/src/Collapse/Collapse.js @@ -191,6 +191,10 @@ const Collapse = React.forwardRef(function Collapse(props, ref) { }); Collapse.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content node to be collapsed. */ @@ -199,7 +203,7 @@ Collapse.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ @@ -207,7 +211,7 @@ Collapse.propTypes = { /** * The height of the container when collapsed. */ - collapsedHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + collapsedHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** * The component used for the root node. * Either a string to use a DOM element or a component. @@ -248,9 +252,13 @@ Collapse.propTypes = { * Set to 'auto' to automatically calculate transition time based on height. */ timeout: PropTypes.oneOfType([ - PropTypes.number, - PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number }), PropTypes.oneOf(['auto']), + PropTypes.number, + PropTypes.shape({ + appear: PropTypes.number, + enter: PropTypes.number, + exit: PropTypes.number, + }), ]), }; diff --git a/packages/material-ui/src/DialogActions/DialogActions.d.ts b/packages/material-ui/src/DialogActions/DialogActions.d.ts index 02f0932a507e91..9355f3fe27de21 100644 --- a/packages/material-ui/src/DialogActions/DialogActions.d.ts +++ b/packages/material-ui/src/DialogActions/DialogActions.d.ts @@ -3,6 +3,9 @@ import { StandardProps } from '..'; export interface DialogActionsProps extends StandardProps, DialogActionsClassKey> { + /** + * If `true`, the actions do not have additional margin. + */ disableSpacing?: boolean; } @@ -18,6 +21,4 @@ export type DialogActionsClassKey = 'root' | 'spacing'; * * - [DialogActions API](https://material-ui.com/api/dialog-actions/) */ -declare const DialogActions: React.ComponentType; - -export default DialogActions; +export default function DialogActions(props: DialogActionsProps): JSX.Element; diff --git a/packages/material-ui/src/DialogActions/DialogActions.js b/packages/material-ui/src/DialogActions/DialogActions.js index 3d900c05697f3e..ba1553a2ab495f 100644 --- a/packages/material-ui/src/DialogActions/DialogActions.js +++ b/packages/material-ui/src/DialogActions/DialogActions.js @@ -33,6 +33,10 @@ const DialogActions = React.forwardRef(function DialogActions(props, ref) { }); DialogActions.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ @@ -41,7 +45,7 @@ DialogActions.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/DialogContent/DialogContent.d.ts b/packages/material-ui/src/DialogContent/DialogContent.d.ts index de79eae7ccc2fa..3d86c2cca47657 100644 --- a/packages/material-ui/src/DialogContent/DialogContent.d.ts +++ b/packages/material-ui/src/DialogContent/DialogContent.d.ts @@ -3,6 +3,9 @@ import { StandardProps } from '..'; export interface DialogContentProps extends StandardProps, DialogContentClassKey> { + /** + * Display the top and bottom dividers. + */ dividers?: boolean; } @@ -18,6 +21,4 @@ export type DialogContentClassKey = 'root' | 'dividers'; * * - [DialogContent API](https://material-ui.com/api/dialog-content/) */ -declare const DialogContent: React.ComponentType; - -export default DialogContent; +export default function DialogContent(props: DialogContentProps): JSX.Element; diff --git a/packages/material-ui/src/DialogContent/DialogContent.js b/packages/material-ui/src/DialogContent/DialogContent.js index 804b64f38e3f2d..bfbbda63f5504a 100644 --- a/packages/material-ui/src/DialogContent/DialogContent.js +++ b/packages/material-ui/src/DialogContent/DialogContent.js @@ -42,6 +42,10 @@ const DialogContent = React.forwardRef(function DialogContent(props, ref) { }); DialogContent.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ @@ -50,7 +54,7 @@ DialogContent.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/DialogTitle/DialogTitle.d.ts b/packages/material-ui/src/DialogTitle/DialogTitle.d.ts index 189e3215990bca..5be489e42a9b38 100644 --- a/packages/material-ui/src/DialogTitle/DialogTitle.d.ts +++ b/packages/material-ui/src/DialogTitle/DialogTitle.d.ts @@ -3,6 +3,10 @@ import { StandardProps } from '..'; export interface DialogTitleProps extends StandardProps, DialogTitleClassKey> { + /** + * If `true`, the children won't be wrapped by a typography component. + * For instance, this can be useful to render an h4 instead of the default h2. + */ disableTypography?: boolean; } @@ -18,6 +22,4 @@ export type DialogTitleClassKey = 'root'; * * - [DialogTitle API](https://material-ui.com/api/dialog-title/) */ -declare const DialogTitle: React.ComponentType; - -export default DialogTitle; +export default function DialogTitle(props: DialogTitleProps): JSX.Element; diff --git a/packages/material-ui/src/DialogTitle/DialogTitle.js b/packages/material-ui/src/DialogTitle/DialogTitle.js index 7c35c854515f90..cdfbacbd736dbd 100644 --- a/packages/material-ui/src/DialogTitle/DialogTitle.js +++ b/packages/material-ui/src/DialogTitle/DialogTitle.js @@ -30,15 +30,19 @@ const DialogTitle = React.forwardRef(function DialogTitle(props, ref) { }); DialogTitle.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ - children: PropTypes.node.isRequired, + children: PropTypes.node, /** * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/Drawer/Drawer.d.ts b/packages/material-ui/src/Drawer/Drawer.d.ts index 28d4154432a353..e647049b5f42a4 100644 --- a/packages/material-ui/src/Drawer/Drawer.d.ts +++ b/packages/material-ui/src/Drawer/Drawer.d.ts @@ -12,15 +12,48 @@ export interface DrawerProps DrawerClassKey, 'open' | 'children' > { + /** + * Side from which the drawer will appear. + */ anchor?: 'left' | 'top' | 'right' | 'bottom'; + /** + * The contents of the drawer. + */ children?: React.ReactNode; + /** + * The elevation of the drawer. + */ elevation?: number; + /** + * Props applied to the [`Modal`](/api/modal/) element. + */ ModalProps?: Partial; + /** + * Callback fired when the component requests to be closed. + * + * @param {object} event The event source of the callback. + */ + onClose?: ModalProps['onClose']; + /** + * If `true`, the drawer is open. + */ open?: boolean; + /** + * Props applied to the [`Paper`](/api/paper/) element. + */ PaperProps?: Partial; + /** + * Props applied to the [`Slide`](/api/slide/) element. + */ SlideProps?: Partial; - theme?: Theme; + /** + * The duration for the transition, in milliseconds. + * You may specify a single timeout for all transitions, or individually with an object. + */ transitionDuration?: TransitionProps['timeout']; + /** + * The variant to use. + */ variant?: 'permanent' | 'persistent' | 'temporary'; } @@ -49,6 +82,4 @@ export type DrawerClassKey = * * - [Drawer API](https://material-ui.com/api/drawer/) */ -declare const Drawer: React.ComponentType; - -export default Drawer; +export default function Drawer(props: DrawerProps): JSX.Element; diff --git a/packages/material-ui/src/Drawer/Drawer.js b/packages/material-ui/src/Drawer/Drawer.js index a4a2df2dc741da..f60ddc8dad855b 100644 --- a/packages/material-ui/src/Drawer/Drawer.js +++ b/packages/material-ui/src/Drawer/Drawer.js @@ -198,10 +198,14 @@ const Drawer = React.forwardRef(function Drawer(props, ref) { }); Drawer.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * Side from which the drawer will appear. */ - anchor: PropTypes.oneOf(['left', 'top', 'right', 'bottom']), + anchor: PropTypes.oneOf(['bottom', 'left', 'right', 'top']), /** * @ignore */ @@ -214,7 +218,7 @@ Drawer.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ @@ -251,7 +255,11 @@ Drawer.propTypes = { */ transitionDuration: PropTypes.oneOfType([ PropTypes.number, - PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number }), + PropTypes.shape({ + appear: PropTypes.number, + enter: PropTypes.number, + exit: PropTypes.number, + }), ]), /** * The variant to use. diff --git a/packages/material-ui/src/ExpansionPanelActions/ExpansionPanelActions.d.ts b/packages/material-ui/src/ExpansionPanelActions/ExpansionPanelActions.d.ts index 921edbec443295..679eb1ddabe821 100644 --- a/packages/material-ui/src/ExpansionPanelActions/ExpansionPanelActions.d.ts +++ b/packages/material-ui/src/ExpansionPanelActions/ExpansionPanelActions.d.ts @@ -2,7 +2,12 @@ import * as React from 'react'; import { StandardProps } from '..'; export interface ExpansionPanelActionsProps - extends StandardProps, ExpansionPanelActionsClassKey> {} + extends StandardProps, ExpansionPanelActionsClassKey> { + /** + * If `true`, the actions do not have additional margin. + */ + disableSpacing?: boolean; +} export type ExpansionPanelActionsClassKey = 'root' | 'spacing'; @@ -16,6 +21,4 @@ export type ExpansionPanelActionsClassKey = 'root' | 'spacing'; * * - [ExpansionPanelActions API](https://material-ui.com/api/expansion-panel-actions/) */ -declare const ExpansionPanelActions: React.ComponentType; - -export default ExpansionPanelActions; +export default function ExpansionPanelActions(props: ExpansionPanelActionsProps): JSX.Element; diff --git a/packages/material-ui/src/ExpansionPanelActions/ExpansionPanelActions.js b/packages/material-ui/src/ExpansionPanelActions/ExpansionPanelActions.js index 2b054e07780084..647be17fa32f2e 100644 --- a/packages/material-ui/src/ExpansionPanelActions/ExpansionPanelActions.js +++ b/packages/material-ui/src/ExpansionPanelActions/ExpansionPanelActions.js @@ -32,15 +32,19 @@ const ExpansionPanelActions = React.forwardRef(function ExpansionPanelActions(pr }); ExpansionPanelActions.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ - children: PropTypes.node.isRequired, + children: PropTypes.node, /** * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/ExpansionPanelDetails/ExpansionPanelDetails.d.ts b/packages/material-ui/src/ExpansionPanelDetails/ExpansionPanelDetails.d.ts index 224e472b44144e..2678f5e6c9ee57 100644 --- a/packages/material-ui/src/ExpansionPanelDetails/ExpansionPanelDetails.d.ts +++ b/packages/material-ui/src/ExpansionPanelDetails/ExpansionPanelDetails.d.ts @@ -2,7 +2,12 @@ import * as React from 'react'; import { StandardProps } from '..'; export interface ExpansionPanelDetailsProps - extends StandardProps, ExpansionPanelDetailsClassKey> {} + extends StandardProps, ExpansionPanelDetailsClassKey> { + /** + * The content of the expansion panel details. + */ + children?: React.ReactNode; +} export type ExpansionPanelDetailsClassKey = 'root'; @@ -16,6 +21,4 @@ export type ExpansionPanelDetailsClassKey = 'root'; * * - [ExpansionPanelDetails API](https://material-ui.com/api/expansion-panel-details/) */ -declare const ExpansionPanelDetails: React.ComponentType; - -export default ExpansionPanelDetails; +export default function ExpansionPanelDetails(props: ExpansionPanelDetailsProps): JSX.Element; diff --git a/packages/material-ui/src/ExpansionPanelDetails/ExpansionPanelDetails.js b/packages/material-ui/src/ExpansionPanelDetails/ExpansionPanelDetails.js index 487e1fb383ab2c..5d13dd37a19a84 100644 --- a/packages/material-ui/src/ExpansionPanelDetails/ExpansionPanelDetails.js +++ b/packages/material-ui/src/ExpansionPanelDetails/ExpansionPanelDetails.js @@ -18,15 +18,19 @@ const ExpansionPanelDetails = React.forwardRef(function ExpansionPanelDetails(pr }); ExpansionPanelDetails.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the expansion panel details. */ - children: PropTypes.node.isRequired, + children: PropTypes.node, /** * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/Fade/Fade.d.ts b/packages/material-ui/src/Fade/Fade.d.ts index ca2f44435d21c9..6b13062a191407 100644 --- a/packages/material-ui/src/Fade/Fade.d.ts +++ b/packages/material-ui/src/Fade/Fade.d.ts @@ -1,10 +1,27 @@ import * as React from 'react'; -import { Theme } from '../styles/createMuiTheme'; import { TransitionProps } from '../transitions/transition'; -export interface FadeProps extends TransitionProps { +export interface FadeProps extends Omit { + /** + * A single child content element. + */ + children?: React.ReactElement; + /** + * If `true`, the component will transition in. + */ + in?: boolean; + /** + */ + onEnter?: TransitionProps['onEnter']; + /** + */ + onExit?: TransitionProps['onExit']; ref?: React.Ref; - theme?: Theme; + /** + * The duration for the transition, in milliseconds. + * You may specify a single timeout for all transitions, or individually with an object. + */ + timeout?: TransitionProps['timeout']; } /** @@ -19,6 +36,4 @@ export interface FadeProps extends TransitionProps { * - [Fade API](https://material-ui.com/api/fade/) * - inherits [Transition API](https://reactcommunity.org/react-transition-group/transition#Transition-props) */ -declare const Fade: React.ComponentType; - -export default Fade; +export default function Fade(props: FadeProps): JSX.Element; diff --git a/packages/material-ui/src/Fade/Fade.js b/packages/material-ui/src/Fade/Fade.js index a09d439ffb8888..a1076108e737dd 100644 --- a/packages/material-ui/src/Fade/Fade.js +++ b/packages/material-ui/src/Fade/Fade.js @@ -46,6 +46,7 @@ const Fade = React.forwardRef(function Fade(props, ref) { mode: 'enter', }, ); + node.style.webkitTransition = theme.transitions.create('opacity', transitionProps); node.style.transition = theme.transitions.create('opacity', transitionProps); @@ -61,6 +62,7 @@ const Fade = React.forwardRef(function Fade(props, ref) { mode: 'exit', }, ); + node.style.webkitTransition = theme.transitions.create('opacity', transitionProps); node.style.transition = theme.transitions.create('opacity', transitionProps); @@ -96,6 +98,10 @@ const Fade = React.forwardRef(function Fade(props, ref) { }); Fade.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * A single child content element. */ @@ -122,7 +128,11 @@ Fade.propTypes = { */ timeout: PropTypes.oneOfType([ PropTypes.number, - PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number }), + PropTypes.shape({ + appear: PropTypes.number, + enter: PropTypes.number, + exit: PropTypes.number, + }), ]), }; diff --git a/packages/material-ui/src/FormGroup/FormGroup.d.ts b/packages/material-ui/src/FormGroup/FormGroup.d.ts index 11a421a3c644c7..5accd812d7477a 100644 --- a/packages/material-ui/src/FormGroup/FormGroup.d.ts +++ b/packages/material-ui/src/FormGroup/FormGroup.d.ts @@ -3,6 +3,9 @@ import { StandardProps } from '..'; export interface FormGroupProps extends StandardProps, FormGroupClassKey> { + /** + * Display group of elements in a compact row. + */ row?: boolean; } @@ -21,6 +24,4 @@ export type FormGroupClassKey = 'root' | 'row'; * * - [FormGroup API](https://material-ui.com/api/form-group/) */ -declare const FormGroup: React.ComponentType; - -export default FormGroup; +export default function FormGroup(props: FormGroupProps): JSX.Element; diff --git a/packages/material-ui/src/FormGroup/FormGroup.js b/packages/material-ui/src/FormGroup/FormGroup.js index 53a85805d15b61..1f9d9177c4d2b2 100644 --- a/packages/material-ui/src/FormGroup/FormGroup.js +++ b/packages/material-ui/src/FormGroup/FormGroup.js @@ -40,6 +40,10 @@ const FormGroup = React.forwardRef(function FormGroup(props, ref) { }); FormGroup.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ @@ -48,7 +52,7 @@ FormGroup.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/GridListTileBar/GridListTileBar.d.ts b/packages/material-ui/src/GridListTileBar/GridListTileBar.d.ts index e364c078bb672a..f35075dacbb55e 100644 --- a/packages/material-ui/src/GridListTileBar/GridListTileBar.d.ts +++ b/packages/material-ui/src/GridListTileBar/GridListTileBar.d.ts @@ -2,10 +2,26 @@ import * as React from 'react'; import { StandardProps } from '..'; export interface GridListTileBarProps extends StandardProps<{}, GridListTileBarClassKey> { + /** + * An IconButton element to be used as secondary action target + * (primary action target is the tile itself). + */ actionIcon?: React.ReactNode; + /** + * Position of secondary action IconButton. + */ actionPosition?: 'left' | 'right'; + /** + * String or element serving as subtitle (support text). + */ subtitle?: React.ReactNode; + /** + * Title to be displayed on tile. + */ title?: React.ReactNode; + /** + * Position of the title bar. + */ titlePosition?: 'top' | 'bottom'; } @@ -32,6 +48,4 @@ export type GridListTileBarClassKey = * * - [GridListTileBar API](https://material-ui.com/api/grid-list-tile-bar/) */ -declare const GridListTileBar: React.ComponentType; - -export default GridListTileBar; +export default function GridListTileBar(props: GridListTileBarProps): JSX.Element; diff --git a/packages/material-ui/src/GridListTileBar/GridListTileBar.js b/packages/material-ui/src/GridListTileBar/GridListTileBar.js index 78a3b030d10161..528a58a78f7ca2 100644 --- a/packages/material-ui/src/GridListTileBar/GridListTileBar.js +++ b/packages/material-ui/src/GridListTileBar/GridListTileBar.js @@ -118,6 +118,10 @@ const GridListTileBar = React.forwardRef(function GridListTileBar(props, ref) { }); GridListTileBar.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * An IconButton element to be used as secondary action target * (primary action target is the tile itself). @@ -131,7 +135,7 @@ GridListTileBar.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ @@ -147,7 +151,7 @@ GridListTileBar.propTypes = { /** * Position of the title bar. */ - titlePosition: PropTypes.oneOf(['top', 'bottom']), + titlePosition: PropTypes.oneOf(['bottom', 'top']), }; export default withStyles(styles, { name: 'MuiGridListTileBar' })(GridListTileBar); diff --git a/packages/material-ui/src/Grow/Grow.d.ts b/packages/material-ui/src/Grow/Grow.d.ts index f7e183836bbed5..7fa41cde3802de 100644 --- a/packages/material-ui/src/Grow/Grow.d.ts +++ b/packages/material-ui/src/Grow/Grow.d.ts @@ -4,8 +4,27 @@ import { Theme } from '../styles/createMuiTheme'; import { TransitionProps } from '../transitions/transition'; export interface GrowProps extends Omit { + /** + * A single child content element. + */ + children?: React.ReactElement; + /** + * If `true`, show the component; triggers the enter or exit animation. + */ + in?: boolean; + /** + */ + onEnter?: TransitionProps['onEnter']; + /** + */ + onExit?: TransitionProps['onExit']; ref?: React.Ref; - theme?: Theme; + /** + * The duration for the transition, in milliseconds. + * You may specify a single timeout for all transitions, or individually with an object. + * + * Set to 'auto' to automatically calculate transition time based on height. + */ timeout?: TransitionProps['timeout'] | 'auto'; } @@ -23,6 +42,4 @@ export interface GrowProps extends Omit { * - [Grow API](https://material-ui.com/api/grow/) * - inherits [Transition API](https://reactcommunity.org/react-transition-group/transition#Transition-props) */ -declare const Grow: React.ComponentType; - -export default Grow; +export default function Grow(props: GrowProps): JSX.Element; diff --git a/packages/material-ui/src/Grow/Grow.js b/packages/material-ui/src/Grow/Grow.js index ef6fbba1f4bc5f..51857f9d390695 100644 --- a/packages/material-ui/src/Grow/Grow.js +++ b/packages/material-ui/src/Grow/Grow.js @@ -142,6 +142,10 @@ const Grow = React.forwardRef(function Grow(props, ref) { }); Grow.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * A single child content element. */ @@ -169,9 +173,13 @@ Grow.propTypes = { * Set to 'auto' to automatically calculate transition time based on height. */ timeout: PropTypes.oneOfType([ - PropTypes.number, - PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number }), PropTypes.oneOf(['auto']), + PropTypes.number, + PropTypes.shape({ + appear: PropTypes.number, + enter: PropTypes.number, + exit: PropTypes.number, + }), ]), }; diff --git a/packages/material-ui/src/Hidden/Hidden.d.ts b/packages/material-ui/src/Hidden/Hidden.d.ts index 663f218fc1a634..a99230636d1ff5 100644 --- a/packages/material-ui/src/Hidden/Hidden.d.ts +++ b/packages/material-ui/src/Hidden/Hidden.d.ts @@ -2,18 +2,66 @@ import * as React from 'react'; import { Breakpoint } from '../styles/createBreakpoints'; export interface HiddenProps { + /** + * Specify which implementation to use. 'js' is the default, 'css' works better for + * server-side rendering. + */ implementation?: 'js' | 'css'; + /** + * You can use this prop when choosing the `js` implementation with server-side rendering. + * + * As `window.innerWidth` is unavailable on the server, + * we default to rendering an empty component during the first mount. + * You might want to use an heuristic to approximate + * the screen width of the client browser screen width. + * + * For instance, you could be using the user-agent or the client-hints. + * https://caniuse.com/#search=client%20hint + */ initialWidth?: Breakpoint; + /** + * If `true`, screens this size and down will be hidden. + */ lgDown?: boolean; + /** + * If `true`, screens this size and up will be hidden. + */ lgUp?: boolean; + /** + * If `true`, screens this size and down will be hidden. + */ mdDown?: boolean; + /** + * If `true`, screens this size and up will be hidden. + */ mdUp?: boolean; + /** + * Hide the given breakpoint(s). + */ only?: Breakpoint | Breakpoint[]; + /** + * If `true`, screens this size and down will be hidden. + */ smDown?: boolean; + /** + * If `true`, screens this size and up will be hidden. + */ smUp?: boolean; + /** + * If `true`, screens this size and down will be hidden. + */ xlDown?: boolean; + /** + * If `true`, screens this size and up will be hidden. + */ xlUp?: boolean; + /** + * If `true`, screens this size and down will be hidden. + */ xsDown?: boolean; + /** + * If `true`, screens this size and up will be hidden. + */ xsUp?: boolean; } diff --git a/packages/material-ui/src/LinearProgress/LinearProgress.d.ts b/packages/material-ui/src/LinearProgress/LinearProgress.d.ts index e47e8e59b8c24c..9021d228f74d6f 100644 --- a/packages/material-ui/src/LinearProgress/LinearProgress.d.ts +++ b/packages/material-ui/src/LinearProgress/LinearProgress.d.ts @@ -2,10 +2,25 @@ import * as React from 'react'; import { StandardProps } from '..'; export interface LinearProgressProps - extends StandardProps, LinearProgressClassKey> { + extends StandardProps, LinearProgressClassKey, 'children'> { + /** + * The color of the component. It supports those theme colors that make sense for this component. + */ color?: 'primary' | 'secondary'; + /** + * The value of the progress indicator for the determinate and buffer variants. + * Value between 0 and 100. + */ value?: number; + /** + * The value for the buffer variant. + * Value between 0 and 100. + */ valueBuffer?: number; + /** + * The variant to use. + * Use indeterminate or query when there is no progress value. + */ variant?: 'determinate' | 'indeterminate' | 'buffer' | 'query'; } @@ -43,6 +58,4 @@ export type LinearProgressClassKey = * * - [LinearProgress API](https://material-ui.com/api/linear-progress/) */ -declare const LinearProgress: React.ComponentType; - -export default LinearProgress; +export default function LinearProgress(props: LinearProgressProps): JSX.Element; diff --git a/packages/material-ui/src/LinearProgress/LinearProgress.js b/packages/material-ui/src/LinearProgress/LinearProgress.js index 6f9139bb6609c3..130423d787cf7e 100644 --- a/packages/material-ui/src/LinearProgress/LinearProgress.js +++ b/packages/material-ui/src/LinearProgress/LinearProgress.js @@ -253,11 +253,15 @@ const LinearProgress = React.forwardRef(function LinearProgress(props, ref) { }); LinearProgress.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ @@ -280,7 +284,7 @@ LinearProgress.propTypes = { * The variant to use. * Use indeterminate or query when there is no progress value. */ - variant: PropTypes.oneOf(['determinate', 'indeterminate', 'buffer', 'query']), + variant: PropTypes.oneOf(['buffer', 'determinate', 'indeterminate', 'query']), }; export default withStyles(styles, { name: 'MuiLinearProgress' })(LinearProgress); diff --git a/packages/material-ui/src/ListItemAvatar/ListItemAvatar.d.ts b/packages/material-ui/src/ListItemAvatar/ListItemAvatar.d.ts index 21463c0d2392a6..29261a4b86e632 100644 --- a/packages/material-ui/src/ListItemAvatar/ListItemAvatar.d.ts +++ b/packages/material-ui/src/ListItemAvatar/ListItemAvatar.d.ts @@ -1,6 +1,9 @@ import { StandardProps } from '..'; export interface ListItemAvatarProps extends StandardProps<{}, ListItemAvatarClassKey> { + /** + * The content of the component – normally `Avatar`. + */ children: React.ReactElement; } @@ -16,6 +19,4 @@ export type ListItemAvatarClassKey = 'root' | 'icon'; * * - [ListItemAvatar API](https://material-ui.com/api/list-item-avatar/) */ -declare const ListItemAvatar: React.ComponentType; - -export default ListItemAvatar; +export default function ListItemAvatar(props: ListItemAvatarProps): JSX.Element; diff --git a/packages/material-ui/src/ListItemAvatar/ListItemAvatar.js b/packages/material-ui/src/ListItemAvatar/ListItemAvatar.js index 45d2a545568283..28347b111ffc11 100644 --- a/packages/material-ui/src/ListItemAvatar/ListItemAvatar.js +++ b/packages/material-ui/src/ListItemAvatar/ListItemAvatar.js @@ -39,6 +39,10 @@ const ListItemAvatar = React.forwardRef(function ListItemAvatar(props, ref) { }); ListItemAvatar.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component – normally `Avatar`. */ @@ -47,7 +51,7 @@ ListItemAvatar.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/ListItemIcon/ListItemIcon.d.ts b/packages/material-ui/src/ListItemIcon/ListItemIcon.d.ts index 24ceab7eee575b..029ca35a368760 100644 --- a/packages/material-ui/src/ListItemIcon/ListItemIcon.d.ts +++ b/packages/material-ui/src/ListItemIcon/ListItemIcon.d.ts @@ -2,6 +2,10 @@ import { StandardProps } from '..'; export interface ListItemIconProps extends StandardProps, ListItemIconClassKey> { + /** + * The content of the component, normally `Icon`, `SvgIcon`, + * or a `@material-ui/icons` SVG icon element. + */ children: React.ReactElement; } @@ -17,6 +21,4 @@ export type ListItemIconClassKey = 'root'; * * - [ListItemIcon API](https://material-ui.com/api/list-item-icon/) */ -declare const ListItemIcon: React.ComponentType; - -export default ListItemIcon; +export default function ListItemIcon(props: ListItemIconProps): JSX.Element; diff --git a/packages/material-ui/src/ListItemIcon/ListItemIcon.js b/packages/material-ui/src/ListItemIcon/ListItemIcon.js index 59fac363403f57..69447bd9d5858f 100644 --- a/packages/material-ui/src/ListItemIcon/ListItemIcon.js +++ b/packages/material-ui/src/ListItemIcon/ListItemIcon.js @@ -41,6 +41,10 @@ const ListItemIcon = React.forwardRef(function ListItemIcon(props, ref) { }); ListItemIcon.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component, normally `Icon`, `SvgIcon`, * or a `@material-ui/icons` SVG icon element. @@ -50,7 +54,7 @@ ListItemIcon.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/Menu/Menu.d.ts b/packages/material-ui/src/Menu/Menu.d.ts index b417acdbbdb8e7..6af9c66a18665e 100644 --- a/packages/material-ui/src/Menu/Menu.d.ts +++ b/packages/material-ui/src/Menu/Menu.d.ts @@ -7,12 +7,89 @@ import { TransitionHandlerProps, TransitionProps } from '../transitions/transiti export interface MenuProps extends StandardProps, MenuClassKey> { + /** + * The DOM element used to set the position of the menu. + * @document + */ + anchorEl?: PopoverProps['anchorEl']; + /** + * If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled + * children are not focusable. If you set this prop to `false` focus will be placed + * on the parent modal container. This has severe accessibility implications + * and should only be considered if you manage focus otherwise. + */ autoFocus?: boolean; + /** + * Menu contents, normally `MenuItem`s. + */ + children?: React.ReactNode; + /** + * When opening the menu will not focus the active item but the `[role="menu"]` + * unless `autoFocus` is also set to `false`. Not using the default means not + * following WAI-ARIA authoring practices. Please be considerate about possible + * accessibility implications. + */ disableAutoFocusItem?: boolean; + /** + * Props applied to the [`MenuList`](/api/menu-list/) element. + */ MenuListProps?: Partial; + /** + * Callback fired when the component requests to be closed. + * + * @param {object} event The event source of the callback. + * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`, `"tabKeyDown"`. + */ + onClose?: PopoverProps['onClose']; + /** + * Callback fired before the Menu enters. + * @document + */ + onEnter?: PopoverProps['onEnter']; + /** + * Callback fired when the Menu has entered. + * @document + */ + onEntered?: PopoverProps['onEntered']; + /** + * Callback fired when the Menu is entering. + * @document + */ + onEntering?: PopoverProps['onEntering']; + /** + * Callback fired before the Menu exits. + * @document + */ + onExit?: PopoverProps['onExit']; + /** + * Callback fired when the Menu has exited. + * @document + */ + onExited?: PopoverProps['onExited']; + /** + * Callback fired when the Menu is exiting. + * @document + */ + onExiting?: PopoverProps['onExiting']; + /** + * If `true`, the menu is visible. + */ + open: boolean; + /** + */ PaperProps?: Partial; + /** + * `classes` prop applied to the [`Popover`](/api/popover/) element. + */ PopoverClasses?: PopoverProps['classes']; + /** + * The length of the transition in `ms`, or 'auto' + */ transitionDuration?: TransitionProps['timeout'] | 'auto'; + /** + * The variant to use. Use `menu` to prevent selected items from impacting the initial focus + * and the vertical alignment relative to the anchor element. + */ variant?: 'menu' | 'selectedMenu'; } @@ -30,6 +107,4 @@ export type MenuClassKey = 'paper' | 'list'; * - [Menu API](https://material-ui.com/api/menu/) * - inherits [Popover API](https://material-ui.com/api/popover/) */ -declare const Menu: React.ComponentType; - -export default Menu; +export default function Menu(props: MenuProps): JSX.Element; diff --git a/packages/material-ui/src/Menu/Menu.js b/packages/material-ui/src/Menu/Menu.js index 1dc0e1bf45ed02..2a96e5d3735e9b 100644 --- a/packages/material-ui/src/Menu/Menu.js +++ b/packages/material-ui/src/Menu/Menu.js @@ -166,10 +166,17 @@ const Menu = React.forwardRef(function Menu(props, ref) { }); Menu.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The DOM element used to set the position of the menu. */ - anchorEl: PropTypes.oneOfType([PropTypes.object, PropTypes.func]), + anchorEl: PropTypes.oneOfType([ + PropTypes.func, + PropTypes.instanceOf(typeof Element === 'undefined' ? Object : Element), + ]), /** * If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled * children are not focusable. If you set this prop to `false` focus will be placed @@ -185,7 +192,7 @@ Menu.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * When opening the menu will not focus the active item but the `[role="menu"]` * unless `autoFocus` is also set to `false`. Not using the default means not @@ -244,9 +251,13 @@ Menu.propTypes = { * The length of the transition in `ms`, or 'auto' */ transitionDuration: PropTypes.oneOfType([ - PropTypes.number, - PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number }), PropTypes.oneOf(['auto']), + PropTypes.number, + PropTypes.shape({ + appear: PropTypes.number, + enter: PropTypes.number, + exit: PropTypes.number, + }), ]), /** * The variant to use. Use `menu` to prevent selected items from impacting the initial focus diff --git a/packages/material-ui/src/MenuList/MenuList.d.ts b/packages/material-ui/src/MenuList/MenuList.d.ts index 43e753e40b53f6..8d91ab6ed7643e 100644 --- a/packages/material-ui/src/MenuList/MenuList.d.ts +++ b/packages/material-ui/src/MenuList/MenuList.d.ts @@ -3,9 +3,27 @@ import { StandardProps } from '..'; import { ListProps, ListClassKey } from '../List'; export interface MenuListProps extends StandardProps { + /** + * If `true`, will focus the `[role="menu"]` container and move into tab order. + */ autoFocus?: boolean; + /** + * If `true`, will focus the first menuitem if `variant="menu"` or selected item + * if `variant="selectedMenu"`. + */ autoFocusItem?: boolean; + /** + * MenuList contents, normally `MenuItem`s. + */ + children?: React.ReactNode; + /** + * If `true`, the menu items will not wrap focus. + */ disableListWrap?: boolean; + /** + * The variant to use. Use `menu` to prevent selected items from impacting the initial focus + * and the vertical alignment relative to the anchor element. + */ variant?: 'menu' | 'selectedMenu'; } @@ -25,6 +43,4 @@ export type MenuListClassKey = ListClassKey; * - [MenuList API](https://material-ui.com/api/menu-list/) * - inherits [List API](https://material-ui.com/api/list/) */ -declare const MenuList: React.ComponentType; - -export default MenuList; +export default function MenuList(props: MenuListProps): JSX.Element; diff --git a/packages/material-ui/src/MenuList/MenuList.js b/packages/material-ui/src/MenuList/MenuList.js index 049b44c97dc1e4..aa25a97cb84325 100644 --- a/packages/material-ui/src/MenuList/MenuList.js +++ b/packages/material-ui/src/MenuList/MenuList.js @@ -85,6 +85,8 @@ const useEnhancedEffect = typeof window === 'undefined' ? React.useEffect : Reac */ const MenuList = React.forwardRef(function MenuList(props, ref) { const { + // private + // eslint-disable-next-line react/prop-types actions, autoFocus = false, autoFocusItem = false, @@ -259,17 +261,17 @@ const MenuList = React.forwardRef(function MenuList(props, ref) { }); MenuList.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** - * @ignore - */ - actions: PropTypes.shape({ current: PropTypes.object }), - /** - * If `true`, will focus the `[role="menu"]` container and move into tab order + * If `true`, will focus the `[role="menu"]` container and move into tab order. */ autoFocus: PropTypes.bool, /** * If `true`, will focus the first menuitem if `variant="menu"` or selected item - * if `variant="selectedMenu"` + * if `variant="selectedMenu"`. */ autoFocusItem: PropTypes.bool, /** diff --git a/packages/material-ui/src/MobileStepper/MobileStepper.d.ts b/packages/material-ui/src/MobileStepper/MobileStepper.d.ts index 807b8d1d44c0e3..9371eebea85d3d 100644 --- a/packages/material-ui/src/MobileStepper/MobileStepper.d.ts +++ b/packages/material-ui/src/MobileStepper/MobileStepper.d.ts @@ -4,13 +4,35 @@ import { PaperProps } from '../Paper'; import { LinearProgressProps } from '../LinearProgress'; export interface MobileStepperProps - extends StandardProps { + extends StandardProps { + /** + * Set the active step (zero based index). + * Defines which dot is highlighted when the variant is 'dots'. + */ activeStep?: number; + /** + * A back button element. For instance, it can be a `Button` or an `IconButton`. + */ backButton: React.ReactNode; + /** + * Props applied to the `LinearProgress` element. + */ LinearProgressProps?: Partial; + /** + * A next button element. For instance, it can be a `Button` or an `IconButton`. + */ nextButton: React.ReactNode; + /** + * Set the positioning type. + */ position?: 'bottom' | 'top' | 'static'; + /** + * The total steps. + */ steps: number; + /** + * The variant to use. + */ variant?: 'text' | 'dots' | 'progress'; } @@ -35,6 +57,4 @@ export type MobileStepperClassKey = * - [MobileStepper API](https://material-ui.com/api/mobile-stepper/) * - inherits [Paper API](https://material-ui.com/api/paper/) */ -declare const MobileStepper: React.ComponentType; - -export default MobileStepper; +export default function MobileStepper(props: MobileStepperProps): JSX.Element; diff --git a/packages/material-ui/src/MobileStepper/MobileStepper.js b/packages/material-ui/src/MobileStepper/MobileStepper.js index 7199e087d685e0..b9a8f7a5b28cd1 100644 --- a/packages/material-ui/src/MobileStepper/MobileStepper.js +++ b/packages/material-ui/src/MobileStepper/MobileStepper.js @@ -85,6 +85,7 @@ const MobileStepper = React.forwardRef(function MobileStepper(props, ref) { {activeStep + 1} / {steps} )} + {variant === 'dots' && (
{[...new Array(steps)].map((_, index) => ( @@ -97,6 +98,7 @@ const MobileStepper = React.forwardRef(function MobileStepper(props, ref) { ))}
)} + {variant === 'progress' && ( )} + {nextButton} ); }); MobileStepper.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * Set the active step (zero based index). * Defines which dot is highlighted when the variant is 'dots'. @@ -124,7 +131,7 @@ MobileStepper.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ @@ -140,7 +147,7 @@ MobileStepper.propTypes = { /** * Set the positioning type. */ - position: PropTypes.oneOf(['bottom', 'top', 'static']), + position: PropTypes.oneOf(['bottom', 'static', 'top']), /** * The total steps. */ @@ -148,7 +155,7 @@ MobileStepper.propTypes = { /** * The variant to use. */ - variant: PropTypes.oneOf(['text', 'dots', 'progress']), + variant: PropTypes.oneOf(['dots', 'progress', 'text']), }; export default withStyles(styles, { name: 'MuiMobileStepper' })(MobileStepper); diff --git a/packages/material-ui/src/NoSsr/NoSsr.d.ts b/packages/material-ui/src/NoSsr/NoSsr.d.ts index 4284742f0de637..2ff0253df098b1 100644 --- a/packages/material-ui/src/NoSsr/NoSsr.d.ts +++ b/packages/material-ui/src/NoSsr/NoSsr.d.ts @@ -1,8 +1,18 @@ import * as React from 'react'; export interface NoSsrProps { + /** + * You can wrap a node. + */ children?: React.ReactNode; + /** + * If `true`, the component will not only prevent server-side rendering. + * It will also defer the rendering of the children into a different screen frame. + */ defer?: boolean; + /** + * The fallback content to display. + */ fallback?: React.ReactNode; } @@ -23,6 +33,4 @@ export interface NoSsrProps { * * - [NoSsr API](https://material-ui.com/api/no-ssr/) */ -declare const NoSsr: React.ComponentType; - -export default NoSsr; +export default function NoSsr(props: NoSsrProps): JSX.Element; diff --git a/packages/material-ui/src/NoSsr/NoSsr.js b/packages/material-ui/src/NoSsr/NoSsr.js index 1c9c44fcd148f9..f90da8e1dbb858 100644 --- a/packages/material-ui/src/NoSsr/NoSsr.js +++ b/packages/material-ui/src/NoSsr/NoSsr.js @@ -37,6 +37,10 @@ function NoSsr(props) { } NoSsr.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * You can wrap a node. */ diff --git a/packages/material-ui/src/Paper/Paper.d.ts b/packages/material-ui/src/Paper/Paper.d.ts index 72d892ef0d555f..6cdc933f2dc611 100644 --- a/packages/material-ui/src/Paper/Paper.d.ts +++ b/packages/material-ui/src/Paper/Paper.d.ts @@ -3,9 +3,23 @@ import { StandardProps } from '..'; export interface PaperProps extends StandardProps, PaperClassKey> { + /** + * The component used for the root node. + * Either a string to use a DOM element or a component. + */ component?: React.ElementType>; + /** + * Shadow depth, corresponds to `dp` in the spec. + * It accepts values between 0 and 24 inclusive. + */ elevation?: number; + /** + * If `true`, rounded corners are disabled. + */ square?: boolean; + /** + * The variant to use. + */ variant?: 'elevation' | 'outlined'; } @@ -50,6 +64,4 @@ export type PaperClassKey = * * - [Paper API](https://material-ui.com/api/paper/) */ -declare const Paper: React.ComponentType; - -export default Paper; +export default function Paper(props: PaperProps): JSX.Element; diff --git a/packages/material-ui/src/Paper/Paper.js b/packages/material-ui/src/Paper/Paper.js index 0fd9310bb6e6dd..99b78c1bbb792d 100644 --- a/packages/material-ui/src/Paper/Paper.js +++ b/packages/material-ui/src/Paper/Paper.js @@ -65,6 +65,10 @@ const Paper = React.forwardRef(function Paper(props, ref) { }); Paper.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ @@ -73,7 +77,7 @@ Paper.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ diff --git a/packages/material-ui/src/RadioGroup/RadioGroup.d.ts b/packages/material-ui/src/RadioGroup/RadioGroup.d.ts index bea3676b0e6e00..020a6b139cbeed 100644 --- a/packages/material-ui/src/RadioGroup/RadioGroup.d.ts +++ b/packages/material-ui/src/RadioGroup/RadioGroup.d.ts @@ -4,8 +4,25 @@ import { FormGroupProps, FormGroupClassKey } from '../FormGroup'; export interface RadioGroupProps extends StandardProps { + /** + * The default `input` element value. Use when the component is not controlled. + */ + defaultValue?: FormGroupProps['defaultValue']; + /** + * The name used to reference the value of the control. + * If you don't provide this prop, it falls back to a randomly generated name. + */ name?: string; + /** + * Callback fired when a radio button is selected. + * + * @param {object} event The event source of the callback. + * You can pull out the new value by accessing `event.target.value` (string). + */ onChange?: (event: React.ChangeEvent, value: string) => void; + /** + * Value of the selected radio button. The DOM API casts this to a string. + */ value?: any; } @@ -22,6 +39,4 @@ export type RadioGroupClassKey = FormGroupClassKey; * - [RadioGroup API](https://material-ui.com/api/radio-group/) * - inherits [FormGroup API](https://material-ui.com/api/form-group/) */ -declare const RadioGroup: React.ComponentType; - -export default RadioGroup; +export default function RadioGroup(props: RadioGroupProps): JSX.Element; diff --git a/packages/material-ui/src/RadioGroup/RadioGroup.js b/packages/material-ui/src/RadioGroup/RadioGroup.js index 48c62bcfdc1395..29ddee6a9a63b6 100644 --- a/packages/material-ui/src/RadioGroup/RadioGroup.js +++ b/packages/material-ui/src/RadioGroup/RadioGroup.js @@ -6,7 +6,16 @@ import useControlled from '../utils/useControlled'; import RadioGroupContext from './RadioGroupContext'; const RadioGroup = React.forwardRef(function RadioGroup(props, ref) { - const { actions, children, name: nameProp, value: valueProp, onChange, ...other } = props; + const { + // private + // eslint-disable-next-line react/prop-types + actions, + children, + name: nameProp, + value: valueProp, + onChange, + ...other + } = props; const rootRef = React.useRef(null); const [value, setValue] = useControlled({ @@ -62,10 +71,10 @@ const RadioGroup = React.forwardRef(function RadioGroup(props, ref) { }); RadioGroup.propTypes = { - /** - * @ignore - */ - actions: PropTypes.shape({ current: PropTypes.object }), + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The content of the component. */ @@ -73,16 +82,16 @@ RadioGroup.propTypes = { /** * The default `input` element value. Use when the component is not controlled. */ - defaultValue: PropTypes.any, + defaultValue: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.string), + PropTypes.number, + PropTypes.string, + ]), /** * The name used to reference the value of the control. * If you don't provide this prop, it falls back to a randomly generated name. */ name: PropTypes.string, - /** - * @ignore - */ - onBlur: PropTypes.func, /** * Callback fired when a radio button is selected. * @@ -90,10 +99,6 @@ RadioGroup.propTypes = { * You can pull out the new value by accessing `event.target.value` (string). */ onChange: PropTypes.func, - /** - * @ignore - */ - onKeyDown: PropTypes.func, /** * Value of the selected radio button. The DOM API casts this to a string. */ diff --git a/packages/material-ui/src/Snackbar/Snackbar.d.ts b/packages/material-ui/src/Snackbar/Snackbar.d.ts index 73607d5a33219c..adc600d0895856 100644 --- a/packages/material-ui/src/Snackbar/Snackbar.d.ts +++ b/packages/material-ui/src/Snackbar/Snackbar.d.ts @@ -16,20 +16,110 @@ export interface SnackbarProps React.HTMLAttributes & Partial, SnackbarClassKey > { + /** + * The action to display. It renders after the message, at the end of the snackbar. + */ action?: SnackbarContentProps['action']; + /** + * The anchor of the `Snackbar`. + */ anchorOrigin?: SnackbarOrigin; + /** + * The number of milliseconds to wait before automatically calling the + * `onClose` function. `onClose` should then set the state of the `open` + * prop to hide the Snackbar. This behavior is disabled by default with + * the `null` value. + */ autoHideDuration?: number | null; + /** + * Replace the `SnackbarContent` component. + */ + children?: React.ReactElement; + /** + * Props applied to the `ClickAwayListener` element. + */ ClickAwayListenerProps?: Partial; + /** + * Props applied to the [`SnackbarContent`](/api/snackbar-content/) element. + */ ContentProps?: Partial; + /** + * If `true`, the `autoHideDuration` timer will expire even if the window is not focused. + */ disableWindowBlurListener?: boolean; + /** + * When displaying multiple consecutive Snackbars from a parent rendering a single + * , add the key prop to ensure independent treatment of each message. + * e.g. , otherwise, the message may update-in-place and + * features such as autoHideDuration may be canceled. + * @document + */ + key?: any; + /** + * The message to display. + */ message?: SnackbarContentProps['message']; + /** + * Callback fired when the component requests to be closed. + * Typically `onClose` is used to set state in the parent component, + * which is used to control the `Snackbar` `open` prop. + * The `reason` parameter can optionally be used to control the response to `onClose`, + * for example ignoring `clickaway`. + * + * @param {object} event The event source of the callback. + * @param {string} reason Can be: `"timeout"` (`autoHideDuration` expired), `"clickaway"`. + */ onClose?: (event: React.SyntheticEvent, reason: SnackbarCloseReason) => void; + /** + * Callback fired before the transition is entering. + */ + onEnter?: TransitionHandlerProps['onEnter']; + /** + * Callback fired when the transition has entered. + */ + onEntered?: TransitionHandlerProps['onEntered']; + /** + * Callback fired when the transition is entering. + */ + onEntering?: TransitionHandlerProps['onEntering']; + /** + * Callback fired before the transition is exiting. + */ + onExit?: TransitionHandlerProps['onExit']; + /** + * Callback fired when the transition has exited. + */ + onExited?: TransitionHandlerProps['onExited']; + /** + * Callback fired when the transition is exiting. + */ + onExiting?: TransitionHandlerProps['onExiting']; onMouseEnter?: React.MouseEventHandler; onMouseLeave?: React.MouseEventHandler; - open: boolean; + /** + * If `true`, `Snackbar` is open. + */ + open?: boolean; + /** + * The number of milliseconds to wait before dismissing after user interaction. + * If `autoHideDuration` prop isn't specified, it does nothing. + * If `autoHideDuration` prop is specified but `resumeHideDuration` isn't, + * we default to `autoHideDuration / 2` ms. + */ resumeHideDuration?: number; + /** + * The component used for the transition. + * [Follow this guide](/components/transitions/#transitioncomponent-prop) to learn more about the requirements for this component. + */ TransitionComponent?: React.ComponentType; + /** + * The duration for the transition, in milliseconds. + * You may specify a single timeout for all transitions, or individually with an object. + */ transitionDuration?: TransitionProps['timeout']; + /** + * Props applied to the [`Transition`](http://reactcommunity.org/react-transition-group/transition#Transition-props) element. + */ TransitionProps?: TransitionProps; } @@ -52,6 +142,4 @@ export type SnackbarClassKey = * * - [Snackbar API](https://material-ui.com/api/snackbar/) */ -declare const Snackbar: React.ComponentType; - -export default Snackbar; +export default function Snackbar(props: SnackbarProps): JSX.Element; diff --git a/packages/material-ui/src/Snackbar/Snackbar.js b/packages/material-ui/src/Snackbar/Snackbar.js index 94f2d1c7e11ec7..51e93c0e5ad30f 100644 --- a/packages/material-ui/src/Snackbar/Snackbar.js +++ b/packages/material-ui/src/Snackbar/Snackbar.js @@ -252,6 +252,10 @@ const Snackbar = React.forwardRef(function Snackbar(props, ref) { }); Snackbar.propTypes = { + // ----------------------------- Warning -------------------------------- + // | These PropTypes are generated from the TypeScript type definitions | + // | To update them edit the d.ts file and run "yarn proptypes" | + // ---------------------------------------------------------------------- /** * The action to display. It renders after the message, at the end of the snackbar. */ @@ -260,8 +264,8 @@ Snackbar.propTypes = { * The anchor of the `Snackbar`. */ anchorOrigin: PropTypes.shape({ - horizontal: PropTypes.oneOf(['left', 'center', 'right']).isRequired, - vertical: PropTypes.oneOf(['top', 'bottom']).isRequired, + horizontal: PropTypes.oneOf(['center', 'left', 'right']).isRequired, + vertical: PropTypes.oneOf(['bottom', 'top']).isRequired, }), /** * The number of milliseconds to wait before automatically calling the @@ -278,7 +282,7 @@ Snackbar.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object.isRequired, + classes: PropTypes.object, /** * @ignore */ @@ -371,7 +375,11 @@ Snackbar.propTypes = { */ transitionDuration: PropTypes.oneOfType([ PropTypes.number, - PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number }), + PropTypes.shape({ + appear: PropTypes.number, + enter: PropTypes.number, + exit: PropTypes.number, + }), ]), /** * Props applied to the [`Transition`](http://reactcommunity.org/react-transition-group/transition#Transition-props) element. diff --git a/scripts/generateProptypes.ts b/scripts/generateProptypes.ts index 7926bafad120c8..92c494eaabb280 100644 --- a/scripts/generateProptypes.ts +++ b/scripts/generateProptypes.ts @@ -5,13 +5,11 @@ import * as prettier from 'prettier'; import * as globCallback from 'glob'; import { promisify } from 'util'; import * as _ from 'lodash'; +import * as yargs from 'yargs'; import { fixBabelGeneratorIssues, fixLineEndings } from '../docs/scripts/helpers'; const glob = promisify(globCallback); -const ignoreCache = process.argv.includes('--disable-cache'); -const verbose = process.argv.includes('--verbose'); - enum GenerateResult { Success, Skipped, @@ -92,7 +90,19 @@ async function generateProptypes( return GenerateResult.Success; } -async function run() { +interface HandlerArgv { + 'disable-cache': boolean; + pattern: string; + verbose: boolean; +} +async function run(argv: HandlerArgv) { + const { 'disable-cache': ignoreCache, pattern, verbose } = argv; + + const filePattern = new RegExp(pattern); + if (pattern.length > 0) { + console.log(`Only considering declaration files matching ${filePattern}`); + } + // Matches files where the folder and file both start with uppercase letters // Example: AppBar/AppBar.d.ts @@ -116,8 +126,10 @@ async function run() { const fileName = path.basename(filePath, '.d.ts'); return fileName === folderName; + }) + .filter((filePath) => { + return filePattern.test(filePath); }); - const program = ttp.createProgram(files, tsconfig); const promises = files.map>(async (tsFile) => { @@ -149,7 +161,31 @@ async function run() { console.log('Total: %d', results.length); } -run().catch((error) => { - console.error(error); - process.exit(1); -}); +yargs + .command({ + command: '$0', + describe: 'Generates Component.propTypes from TypeScript declarations', + builder: (command) => { + return command + .option('disable-cache', { + default: false, + describe: 'Considers all files on every run', + type: 'boolean', + }) + .option('verbose', { + default: false, + describe: 'Logs result for each file', + type: 'boolean', + }) + .option('pattern', { + default: '', + describe: 'Only considers declaration files matching this pattern.', + type: 'string', + }); + }, + handler: run, + }) + .help() + .strict(true) + .version(false) + .parse();