Improve typing for Dialog

This commit is contained in:
Florian Rival
2019-08-22 21:55:33 +02:00
parent 6016790f03
commit 4fd7698907
2 changed files with 37 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import React from 'react';
// @flow
import * as React from 'react';
import Dialog from 'material-ui/Dialog';
const styles = {
@@ -16,11 +17,44 @@ const styles = {
},
};
// We support a subset of the props supported by Material-UI v0.x Dialog
// They should be self descriptive - refer to Material UI docs otherwise.
type Props = {|
open?: boolean,
noMargin?: boolean,
title?: React.Node,
actions?: React.Node,
secondaryActions?: React.Node,
onRequestClose?: () => void,
modal?: boolean, // Force the user to use one of the actions in the Dialog. Clicking outside the Dialog will not trigger the onRequestClose.
children: React.Node, // The content of the dialog
// Style:
contentStyle?: {|
maxWidth?: string | number,
width?: string,
|},
titleStyle?: {| padding?: 0 |},
bodyStyle?: {|
padding?: 0,
display?: 'flex',
flexDirection?: 'row',
overflowX?: 'hidden',
|},
// Positioning:
autoScrollBodyContent?: boolean,
repositionOnUpdate?: boolean,
|};
/**
* A enhanced material-ui Dialog that can have optional secondary actions
* and no margins if required.
*/
export default props => {
export default (props: Props) => {
const { secondaryActions, actions, noMargin, title, ...otherProps } = props;
const dialogActions = secondaryActions
? [

View File

@@ -51,7 +51,7 @@ export class ListItem extends React.Component<ListItemProps, {||}> {
// into ListItem props and assumes nestedItems is always an array.
static defaultProps = {
nestedItems: [],
}
};
render() {
return <MUIListItem {...this.props} />;