Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -1,24 +1,18 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ModalProps, ModalClassKey } from '../internal/Modal';
import { TransitionDuration } from '../internal/transition';
import { PaperProps } from '../Paper';
import { ModalProps, ModalClassKey } from '../Modal';
import { TransitionHandlerProps, TransitionProps } from '../transitions/transition';
export interface DialogProps extends StandardProps<
ModalProps,
DialogClassKey,
'onBackdropClick' | 'onEscapeKeyUp'
> {
export interface DialogProps
extends StandardProps<ModalProps & Partial<TransitionHandlerProps>, DialogClassKey, 'children'> {
children?: React.ReactNode;
fullScreen?: boolean;
ignoreBackdropClick?: boolean;
ignoreEscapeKeyUp?: boolean;
transitionDuration?: TransitionDuration;
maxWidth?: 'xs' | 'sm' | 'md';
fullWidth?: boolean;
onBackdropClick?: Function;
onEscapeKeyUp?: Function;
onRequestClose?: React.EventHandler<any>;
open?: boolean;
maxWidth?: 'xs' | 'sm' | 'md' | false;
PaperProps?: Partial<PaperProps>;
transition?: React.ReactType;
transitionDuration?: TransitionProps['timeout'];
}
export type DialogClassKey =
@@ -29,8 +23,7 @@ export type DialogClassKey =
| 'paperWidthSm'
| 'paperWidthMd'
| 'fullWidth'
| 'fullScreen'
;
| 'fullScreen';
declare const Dialog: React.ComponentType<DialogProps>;

View File

@@ -17,12 +17,14 @@ var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProp
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -33,7 +35,7 @@ var _withStyles2 = _interopRequireDefault(_withStyles);
var _helpers = require('../utils/helpers');
var _Modal = require('../internal/Modal');
var _Modal = require('../Modal');
var _Modal2 = _interopRequireDefault(_Modal);
@@ -49,14 +51,6 @@ var _Paper2 = _interopRequireDefault(_Paper);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_ComponentType = require('prop-types').func;
var babelPluginFlowReactPropTypes_proptype_TransitionCallback = require('../internal/transition').babelPluginFlowReactPropTypes_proptype_TransitionCallback || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_TransitionDuration = require('../internal/transition').babelPluginFlowReactPropTypes_proptype_TransitionDuration || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
@@ -76,7 +70,7 @@ var styles = exports.styles = function styles(theme) {
}
},
paperWidthXs: {
maxWidth: theme.breakpoints.values.xs
maxWidth: Math.max(theme.breakpoints.values.xs, 360)
},
paperWidthSm: {
maxWidth: theme.breakpoints.values.sm
@@ -98,118 +92,11 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* Dialog children, usually the included sub-components.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* If `true`, it will be full-screen
*/
fullScreen: require('prop-types').bool,
/**
* If `true`, clicking the backdrop will not fire the `onRequestClose` callback.
*/
ignoreBackdropClick: require('prop-types').bool,
/**
* If `true`, hitting escape will not fire the `onRequestClose` callback.
*/
ignoreEscapeKeyUp: require('prop-types').bool,
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*/
transitionDuration: typeof babelPluginFlowReactPropTypes_proptype_TransitionDuration === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionDuration : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionDuration),
/**
* Determine the max width of the dialog.
* The dialog width grows with the size of the screen, this property is useful
* on the desktop where you might need some coherent different width size across your
* application.
*/
maxWidth: require('prop-types').oneOf(['xs', 'sm', 'md']),
/**
* If specified, stretches dialog to max width.
*/
fullWidth: require('prop-types').bool,
/**
* Callback fired when the backdrop is clicked.
*/
onBackdropClick: require('prop-types').func,
/**
* Callback fired before the dialog enters.
*/
onEnter: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the dialog is entering.
*/
onEntering: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the dialog has entered.
*/
onEntered: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fires when the escape key is released and the modal is in focus.
*/
onEscapeKeyUp: require('prop-types').func,
/**
* Callback fired before the dialog exits.
*/
onExit: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the dialog is exiting.
*/
onExiting: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the dialog has exited.
*/
onExited: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback
*/
onRequestClose: require('prop-types').func,
/**
* If `true`, the Dialog is open.
*/
open: require('prop-types').bool,
/**
* Transition component.
*/
transition: typeof babelPluginFlowReactPropTypes_proptype_ComponentType === 'function' ? babelPluginFlowReactPropTypes_proptype_ComponentType : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_ComponentType)
};
/**
* Dialogs are overlaid modal paper based components with a backdrop.
*/
// @inheritedComponent Modal
function Dialog(props) {
var _classNames;
@@ -217,36 +104,40 @@ function Dialog(props) {
classes = props.classes,
className = props.className,
fullScreen = props.fullScreen,
ignoreBackdropClick = props.ignoreBackdropClick,
ignoreEscapeKeyUp = props.ignoreEscapeKeyUp,
transitionDuration = props.transitionDuration,
maxWidth = props.maxWidth,
fullWidth = props.fullWidth,
open = props.open,
disableBackdropClick = props.disableBackdropClick,
disableEscapeKeyDown = props.disableEscapeKeyDown,
maxWidth = props.maxWidth,
onBackdropClick = props.onBackdropClick,
onEscapeKeyUp = props.onEscapeKeyUp,
onClose = props.onClose,
onEnter = props.onEnter,
onEntering = props.onEntering,
onEntered = props.onEntered,
onEntering = props.onEntering,
onEscapeKeyDown = props.onEscapeKeyDown,
onExit = props.onExit,
onExiting = props.onExiting,
onExited = props.onExited,
onRequestClose = props.onRequestClose,
onExiting = props.onExiting,
open = props.open,
PaperProps = props.PaperProps,
TransitionProp = props.transition,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'fullScreen', 'ignoreBackdropClick', 'ignoreEscapeKeyUp', 'transitionDuration', 'maxWidth', 'fullWidth', 'open', 'onBackdropClick', 'onEscapeKeyUp', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'onRequestClose', 'transition']);
transitionDuration = props.transitionDuration,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'fullScreen', 'fullWidth', 'disableBackdropClick', 'disableEscapeKeyDown', 'maxWidth', 'onBackdropClick', 'onClose', 'onEnter', 'onEntered', 'onEntering', 'onEscapeKeyDown', 'onExit', 'onExited', 'onExiting', 'open', 'PaperProps', 'transition', 'transitionDuration']);
return _react2.default.createElement(
_Modal2.default,
(0, _extends3.default)({
className: (0, _classnames2.default)(classes.root, className),
BackdropTransitionDuration: transitionDuration,
ignoreBackdropClick: ignoreBackdropClick,
ignoreEscapeKeyUp: ignoreEscapeKeyUp,
BackdropProps: {
transitionDuration: transitionDuration
},
disableBackdropClick: disableBackdropClick,
disableEscapeKeyDown: disableEscapeKeyDown,
onBackdropClick: onBackdropClick,
onEscapeKeyUp: onEscapeKeyUp,
onRequestClose: onRequestClose,
show: open
onEscapeKeyDown: onEscapeKeyDown,
onClose: onClose,
open: open,
role: 'dialog'
}, other),
_react2.default.createElement(
TransitionProp,
@@ -263,33 +154,118 @@ function Dialog(props) {
},
_react2.default.createElement(
_Paper2.default,
{
(0, _extends3.default)({
elevation: 24,
className: (0, _classnames2.default)(classes.paper, classes['paperWidth' + (0, _helpers.capitalizeFirstLetter)(maxWidth)], (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.fullScreen, fullScreen), (0, _defineProperty3.default)(_classNames, classes.fullWidth, fullWidth), _classNames))
},
className: (0, _classnames2.default)(classes.paper, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes['paperWidth' + (maxWidth ? (0, _helpers.capitalize)(maxWidth) : '')], maxWidth), (0, _defineProperty3.default)(_classNames, classes.fullScreen, fullScreen), (0, _defineProperty3.default)(_classNames, classes.fullWidth, fullWidth), _classNames))
}, PaperProps),
children
)
)
);
}
Dialog.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
transition: typeof babelPluginFlowReactPropTypes_proptype_ComponentType === 'function' ? babelPluginFlowReactPropTypes_proptype_ComponentType.isRequired ? babelPluginFlowReactPropTypes_proptype_ComponentType.isRequired : babelPluginFlowReactPropTypes_proptype_ComponentType : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_ComponentType).isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'fullScreen', require('prop-types').bool), (0, _defineProperty3.default)(_ref, 'ignoreBackdropClick', require('prop-types').bool), (0, _defineProperty3.default)(_ref, 'ignoreEscapeKeyUp', require('prop-types').bool), (0, _defineProperty3.default)(_ref, 'transitionDuration', typeof babelPluginFlowReactPropTypes_proptype_TransitionDuration === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionDuration : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionDuration)), (0, _defineProperty3.default)(_ref, 'maxWidth', require('prop-types').oneOf(['xs', 'sm', 'md'])), (0, _defineProperty3.default)(_ref, 'fullWidth', require('prop-types').bool), (0, _defineProperty3.default)(_ref, 'onBackdropClick', require('prop-types').func), (0, _defineProperty3.default)(_ref, 'onEnter', typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback)), (0, _defineProperty3.default)(_ref, 'onEntering', typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback)), (0, _defineProperty3.default)(_ref, 'onEntered', typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback)), (0, _defineProperty3.default)(_ref, 'onEscapeKeyUp', require('prop-types').func), (0, _defineProperty3.default)(_ref, 'onExit', typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback)), (0, _defineProperty3.default)(_ref, 'onExiting', typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback)), (0, _defineProperty3.default)(_ref, 'onExited', typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback)), (0, _defineProperty3.default)(_ref, 'onRequestClose', require('prop-types').func), (0, _defineProperty3.default)(_ref, 'open', require('prop-types').bool), (0, _defineProperty3.default)(_ref, 'transition', typeof babelPluginFlowReactPropTypes_proptype_ComponentType === 'function' ? babelPluginFlowReactPropTypes_proptype_ComponentType : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_ComponentType)), _ref) : {};
Dialog.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* Dialog children, usually the included sub-components.
*/
children: _propTypes2.default.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* If `true`, clicking the backdrop will not fire the `onClose` callback.
*/
disableBackdropClick: _propTypes2.default.bool,
/**
* If `true`, hitting escape will not fire the `onClose` callback.
*/
disableEscapeKeyDown: _propTypes2.default.bool,
/**
* If `true`, the dialog will be full-screen
*/
fullScreen: _propTypes2.default.bool,
/**
* If `true`, the dialog stretches to `maxWidth`.
*/
fullWidth: _propTypes2.default.bool,
/**
* Determine the max width of the dialog.
* The dialog width grows with the size of the screen, this property is useful
* on the desktop where you might need some coherent different width size across your
* application. Set to `false` to disable `maxWidth`.
*/
maxWidth: _propTypes2.default.oneOf(['xs', 'sm', 'md', false]),
/**
* Callback fired when the backdrop is clicked.
*/
onBackdropClick: _propTypes2.default.func,
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback
*/
onClose: _propTypes2.default.func,
/**
* Callback fired before the dialog enters.
*/
onEnter: _propTypes2.default.func,
/**
* Callback fired when the dialog has entered.
*/
onEntered: _propTypes2.default.func,
/**
* Callback fired when the dialog is entering.
*/
onEntering: _propTypes2.default.func,
/**
* Callback fired when the escape key is pressed,
* `disableKeyboard` is false and the modal is in focus.
*/
onEscapeKeyDown: _propTypes2.default.func,
/**
* Callback fired before the dialog exits.
*/
onExit: _propTypes2.default.func,
/**
* Callback fired when the dialog has exited.
*/
onExited: _propTypes2.default.func,
/**
* Callback fired when the dialog is exiting.
*/
onExiting: _propTypes2.default.func,
/**
* If `true`, the Dialog is open.
*/
open: _propTypes2.default.bool.isRequired,
/**
* Properties applied to the `Paper` element.
*/
PaperProps: _propTypes2.default.object,
/**
* Transition component.
*/
transition: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]),
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*/
transitionDuration: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.shape({ enter: _propTypes2.default.number, exit: _propTypes2.default.number })])
} : {};
Dialog.defaultProps = {
fullScreen: false,
ignoreBackdropClick: false,
ignoreEscapeKeyUp: false,
transitionDuration: {
enter: _transitions.duration.enteringScreen,
exit: _transitions.duration.leavingScreen
},
maxWidth: 'sm',
fullWidth: false,
open: false,
transition: _Fade2.default
disableBackdropClick: false,
disableEscapeKeyDown: false,
maxWidth: 'sm',
transition: _Fade2.default,
transitionDuration: { enter: _transitions.duration.enteringScreen, exit: _transitions.duration.leavingScreen }
};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiDialog' })(Dialog);

View File

@@ -1,17 +1,16 @@
// @flow
// @inheritedComponent Modal
import React from 'react';
import type { ComponentType, Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { capitalizeFirstLetter } from '../utils/helpers';
import Modal from '../internal/Modal';
import { capitalize } from '../utils/helpers';
import Modal from '../Modal';
import Fade from '../transitions/Fade';
import { duration } from '../styles/transitions';
import Paper from '../Paper';
import type { TransitionDuration, TransitionCallback } from '../internal/transition';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
justifyContent: 'center',
alignItems: 'center',
@@ -29,7 +28,7 @@ export const styles = (theme: Object) => ({
},
},
paperWidthXs: {
maxWidth: theme.breakpoints.values.xs,
maxWidth: Math.max(theme.breakpoints.values.xs, 360),
},
paperWidthSm: {
maxWidth: theme.breakpoints.values.sm,
@@ -50,138 +49,48 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
transition: ComponentType<*>,
};
export type Props = {
/**
* Dialog children, usually the included sub-components.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* If `true`, it will be full-screen
*/
fullScreen?: boolean,
/**
* If `true`, clicking the backdrop will not fire the `onRequestClose` callback.
*/
ignoreBackdropClick?: boolean,
/**
* If `true`, hitting escape will not fire the `onRequestClose` callback.
*/
ignoreEscapeKeyUp?: boolean,
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*/
transitionDuration?: TransitionDuration,
/**
* Determine the max width of the dialog.
* The dialog width grows with the size of the screen, this property is useful
* on the desktop where you might need some coherent different width size across your
* application.
*/
maxWidth?: 'xs' | 'sm' | 'md',
/**
* If specified, stretches dialog to max width.
*/
fullWidth?: boolean,
/**
* Callback fired when the backdrop is clicked.
*/
onBackdropClick?: Function,
/**
* Callback fired before the dialog enters.
*/
onEnter?: TransitionCallback,
/**
* Callback fired when the dialog is entering.
*/
onEntering?: TransitionCallback,
/**
* Callback fired when the dialog has entered.
*/
onEntered?: TransitionCallback,
/**
* Callback fires when the escape key is released and the modal is in focus.
*/
onEscapeKeyUp?: Function,
/**
* Callback fired before the dialog exits.
*/
onExit?: TransitionCallback,
/**
* Callback fired when the dialog is exiting.
*/
onExiting?: TransitionCallback,
/**
* Callback fired when the dialog has exited.
*/
onExited?: TransitionCallback,
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback
*/
onRequestClose?: Function,
/**
* If `true`, the Dialog is open.
*/
open?: boolean,
/**
* Transition component.
*/
transition?: ComponentType<*>,
};
/**
* Dialogs are overlaid modal paper based components with a backdrop.
*/
function Dialog(props: ProvidedProps & Props) {
function Dialog(props) {
const {
children,
classes,
className,
fullScreen,
ignoreBackdropClick,
ignoreEscapeKeyUp,
transitionDuration,
maxWidth,
fullWidth,
open,
disableBackdropClick,
disableEscapeKeyDown,
maxWidth,
onBackdropClick,
onEscapeKeyUp,
onClose,
onEnter,
onEntering,
onEntered,
onEntering,
onEscapeKeyDown,
onExit,
onExiting,
onExited,
onRequestClose,
onExiting,
open,
PaperProps,
transition: TransitionProp,
transitionDuration,
...other
} = props;
return (
<Modal
className={classNames(classes.root, className)}
BackdropTransitionDuration={transitionDuration}
ignoreBackdropClick={ignoreBackdropClick}
ignoreEscapeKeyUp={ignoreEscapeKeyUp}
BackdropProps={{
transitionDuration,
}}
disableBackdropClick={disableBackdropClick}
disableEscapeKeyDown={disableEscapeKeyDown}
onBackdropClick={onBackdropClick}
onEscapeKeyUp={onEscapeKeyUp}
onRequestClose={onRequestClose}
show={open}
onEscapeKeyDown={onEscapeKeyDown}
onClose={onClose}
open={open}
role="dialog"
{...other}
>
<TransitionProp
@@ -198,14 +107,12 @@ function Dialog(props: ProvidedProps & Props) {
<Paper
data-mui-test="Dialog"
elevation={24}
className={classNames(
classes.paper,
classes[`paperWidth${capitalizeFirstLetter(maxWidth)}`],
{
[classes.fullScreen]: fullScreen,
[classes.fullWidth]: fullWidth,
},
)}
className={classNames(classes.paper, {
[classes[`paperWidth${maxWidth ? capitalize(maxWidth) : ''}`]]: maxWidth,
[classes.fullScreen]: fullScreen,
[classes.fullWidth]: fullWidth,
})}
{...PaperProps}
>
{children}
</Paper>
@@ -214,18 +121,111 @@ function Dialog(props: ProvidedProps & Props) {
);
}
Dialog.propTypes = {
/**
* Dialog children, usually the included sub-components.
*/
children: PropTypes.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, clicking the backdrop will not fire the `onClose` callback.
*/
disableBackdropClick: PropTypes.bool,
/**
* If `true`, hitting escape will not fire the `onClose` callback.
*/
disableEscapeKeyDown: PropTypes.bool,
/**
* If `true`, the dialog will be full-screen
*/
fullScreen: PropTypes.bool,
/**
* If `true`, the dialog stretches to `maxWidth`.
*/
fullWidth: PropTypes.bool,
/**
* Determine the max width of the dialog.
* The dialog width grows with the size of the screen, this property is useful
* on the desktop where you might need some coherent different width size across your
* application. Set to `false` to disable `maxWidth`.
*/
maxWidth: PropTypes.oneOf(['xs', 'sm', 'md', false]),
/**
* Callback fired when the backdrop is clicked.
*/
onBackdropClick: PropTypes.func,
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback
*/
onClose: PropTypes.func,
/**
* Callback fired before the dialog enters.
*/
onEnter: PropTypes.func,
/**
* Callback fired when the dialog has entered.
*/
onEntered: PropTypes.func,
/**
* Callback fired when the dialog is entering.
*/
onEntering: PropTypes.func,
/**
* Callback fired when the escape key is pressed,
* `disableKeyboard` is false and the modal is in focus.
*/
onEscapeKeyDown: PropTypes.func,
/**
* Callback fired before the dialog exits.
*/
onExit: PropTypes.func,
/**
* Callback fired when the dialog has exited.
*/
onExited: PropTypes.func,
/**
* Callback fired when the dialog is exiting.
*/
onExiting: PropTypes.func,
/**
* If `true`, the Dialog is open.
*/
open: PropTypes.bool.isRequired,
/**
* Properties applied to the `Paper` element.
*/
PaperProps: PropTypes.object,
/**
* Transition component.
*/
transition: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*/
transitionDuration: PropTypes.oneOfType([
PropTypes.number,
PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number }),
]),
};
Dialog.defaultProps = {
fullScreen: false,
ignoreBackdropClick: false,
ignoreEscapeKeyUp: false,
transitionDuration: {
enter: duration.enteringScreen,
exit: duration.leavingScreen,
},
maxWidth: 'sm',
fullWidth: false,
open: false,
disableBackdropClick: false,
disableEscapeKeyDown: false,
maxWidth: 'sm',
transition: Fade,
transitionDuration: { enter: duration.enteringScreen, exit: duration.leavingScreen },
};
export default withStyles(styles, { name: 'MuiDialog' })(Dialog);

View File

@@ -1,16 +1,10 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DialogActionsProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
DialogActionsClassKey
> {}
export interface DialogActionsProps
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, DialogActionsClassKey> {}
export type DialogActionsClassKey =
| 'root'
| 'action'
| 'button'
;
export type DialogActionsClassKey = 'root' | 'action' | 'button';
declare const DialogActions: React.ComponentType<DialogActionsProps>;

View File

@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
});
exports.styles = undefined;
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
@@ -17,12 +13,14 @@ var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProp
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -35,8 +33,6 @@ require('../Button');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
// So we don't have any override priority issue.
var styles = exports.styles = function styles(theme) {
@@ -57,24 +53,6 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string
};
function DialogActions(props) {
var children = props.children,
classes = props.classes,
@@ -85,20 +63,35 @@ function DialogActions(props) {
return _react2.default.createElement(
'div',
(0, _extends3.default)({ className: (0, _classnames2.default)(classes.root, className) }, other),
_react2.default.Children.map(children, function (button) {
return _react2.default.isValidElement(button) && _react2.default.createElement(
_react2.default.Children.map(children, function (child) {
if (!_react2.default.isValidElement(child)) {
return null;
}
return _react2.default.createElement(
'div',
{ className: classes.action },
_react2.default.cloneElement(button, {
className: (0, _classnames2.default)(classes.button, button.props.className)
_react2.default.cloneElement(child, {
className: (0, _classnames2.default)(classes.button, child.props.className)
})
);
})
);
}
DialogActions.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), _ref) : {};
DialogActions.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string
} : {};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiDialogActions' })(DialogActions);

View File

@@ -1,12 +1,10 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import '../Button'; // So we don't have any override priority issue.
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
display: 'flex',
justifyContent: 'flex-end',
@@ -22,43 +20,41 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* The content of the component.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
};
function DialogActions(props: ProvidedProps & Props) {
function DialogActions(props) {
const { children, classes, className, ...other } = props;
return (
<div data-mui-test="DialogActions" className={classNames(classes.root, className)} {...other}>
{React.Children.map(
children,
button =>
React.isValidElement(button) && (
<div className={classes.action}>
{React.cloneElement(button, {
className: classNames(classes.button, button.props.className),
})}
</div>
),
)}
<div className={classNames(classes.root, className)} {...other}>
{React.Children.map(children, child => {
if (!React.isValidElement(child)) {
return null;
}
return (
<div className={classes.action}>
{React.cloneElement(child, {
className: classNames(classes.button, child.props.className),
})}
</div>
);
})}
</div>
);
}
DialogActions.propTypes = {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
};
export default withStyles(styles, { name: 'MuiDialogActions' })(DialogActions);

View File

@@ -1,14 +1,10 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DialogContentProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
DialogContentClassKey
> {}
export interface DialogContentProps
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, DialogContentClassKey> {}
export type DialogContentClassKey =
| 'root'
;
export type DialogContentClassKey = 'root';
declare const DialogContent: React.ComponentType<DialogContentProps>;

View File

@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
});
exports.styles = undefined;
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
@@ -17,12 +13,14 @@ var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProp
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -33,8 +31,6 @@ var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
var spacing = theme.spacing.unit * 3;
return {
@@ -49,24 +45,6 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string
};
function DialogContent(props) {
var classes = props.classes,
children = props.children,
@@ -81,8 +59,19 @@ function DialogContent(props) {
);
}
DialogContent.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), _ref) : {};
DialogContent.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string
} : {};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiDialogContent' })(DialogContent);

View File

@@ -1,11 +1,9 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => {
export const styles = theme => {
const spacing = theme.spacing.unit * 3;
return {
root: {
@@ -19,26 +17,7 @@ export const styles = (theme: Object) => {
};
};
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* The content of the component.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
};
function DialogContent(props: ProvidedProps & Props) {
function DialogContent(props) {
const { classes, children, className, ...other } = props;
return (
@@ -48,4 +27,19 @@ function DialogContent(props: ProvidedProps & Props) {
);
}
DialogContent.propTypes = {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
};
export default withStyles(styles, { name: 'MuiDialogContent' })(DialogContent);

View File

@@ -1,14 +1,10 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DialogContentTextProps extends StandardProps<
React.HTMLAttributes<HTMLParagraphElement>,
DialogContentTextClassKey
> {}
export interface DialogContentTextProps
extends StandardProps<React.HTMLAttributes<HTMLParagraphElement>, DialogContentTextClassKey> {}
export type DialogContentTextClassKey =
| 'root'
;
export type DialogContentTextClassKey = 'root';
declare const DialogContentText: React.ComponentType<DialogContentTextProps>;

View File

@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
});
exports.styles = undefined;
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
@@ -17,12 +13,14 @@ var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _ref;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -33,8 +31,6 @@ var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: (0, _extends3.default)({}, theme.typography.subheading, {
@@ -44,24 +40,6 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string
};
function DialogContentText(props) {
var children = props.children,
classes = props.classes,
@@ -76,8 +54,19 @@ function DialogContentText(props) {
);
}
DialogContentText.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), _ref) : {};
DialogContentText.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string
} : {};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiDialogContentText' })(DialogContentText);

View File

@@ -1,11 +1,9 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
...theme.typography.subheading,
color: theme.palette.text.secondary,
@@ -13,26 +11,7 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* The content of the component.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
};
function DialogContentText(props: ProvidedProps & Props) {
function DialogContentText(props) {
const { children, classes, className, ...other } = props;
return (
@@ -42,4 +21,19 @@ function DialogContentText(props: ProvidedProps & Props) {
);
}
DialogContentText.propTypes = {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
};
export default withStyles(styles, { name: 'MuiDialogContentText' })(DialogContentText);

View File

@@ -1,16 +1,12 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface DialogTitleProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
DialogTitleClassKey
> {
export interface DialogTitleProps
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, DialogTitleClassKey> {
disableTypography?: boolean;
}
export type DialogTitleClassKey =
| 'root'
;
export type DialogTitleClassKey = 'root';
declare const DialogTitle: React.ComponentType<DialogTitleProps>;

View File

@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
});
exports.styles = undefined;
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
@@ -17,12 +13,14 @@ var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProp
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -37,8 +35,6 @@ var _Typography2 = _interopRequireDefault(_Typography);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
@@ -49,30 +45,6 @@ var styles = exports.styles = function styles(theme) {
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* If `true`, the children won't be wrapped by a typography component.
* For instance, that can be useful to can render an h4 instead of a
*/
disableTypography: require('prop-types').bool
};
function DialogTitle(props) {
var children = props.children,
classes = props.classes,
@@ -86,16 +58,32 @@ function DialogTitle(props) {
(0, _extends3.default)({ className: (0, _classnames2.default)(classes.root, className) }, other),
disableTypography ? children : _react2.default.createElement(
_Typography2.default,
{ type: 'title' },
{ variant: 'title' },
children
)
);
}
DialogTitle.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'disableTypography', require('prop-types').bool), _ref) : {};
DialogTitle.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: _propTypes2.default.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* 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: _propTypes2.default.bool
} : {};
DialogTitle.defaultProps = {
disableTypography: false
};

View File

@@ -1,12 +1,10 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import Typography from '../Typography';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
margin: 0,
padding: `${theme.spacing.unit * 3}px ${theme.spacing.unit * 3}px \
@@ -15,40 +13,36 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
};
export type Props = {
/**
* The content of the component.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* If `true`, the children won't be wrapped by a typography component.
* For instance, that can be useful to can render an h4 instead of a
*/
disableTypography?: boolean,
};
function DialogTitle(props: ProvidedProps & Props) {
function DialogTitle(props) {
const { children, classes, className, disableTypography, ...other } = props;
return (
<div data-mui-test="DialogTitle" className={classNames(classes.root, className)} {...other}>
{disableTypography ? children : <Typography type="title">{children}</Typography>}
{disableTypography ? children : <Typography variant="title">{children}</Typography>}
</div>
);
}
DialogTitle.propTypes = {
/**
* The content of the component.
*/
children: PropTypes.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* 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: PropTypes.bool,
};
DialogTitle.defaultProps = {
disableTypography: false,
};

View File

@@ -8,7 +8,5 @@ export { default as DialogContent } from './DialogContent';
export * from './DialogContent';
export { default as DialogContentText } from './DialogContentText';
export * from './DialogContentText';
export {
default as withMobileDialog,
} from './withMobileDialog';
export { default as withMobileDialog } from './withMobileDialog';
export * from './withMobileDialog';

View File

@@ -1,5 +1,3 @@
// @flow
export { default } from './Dialog';
export { default as DialogActions } from './DialogActions';
export { default as DialogTitle } from './DialogTitle';

View File

@@ -5,8 +5,12 @@ export interface WithMobileDialogOptions {
breakpoint: Breakpoint;
}
export interface InjectedProps {
fullScreen?: boolean;
}
export default function withMobileDialog<P = {}>(
options: WithMobileDialogOptions
options?: WithMobileDialogOptions,
): (
component: React.ComponentType<P & Partial<WithWidthProps>>
) => React.ComponentClass<P & Partial<WithWidthProps>>;
component: React.ComponentType<P & InjectedProps & Partial<WithWidthProps>>,
) => React.ComponentType<P & Partial<WithWidthProps>>;

View File

@@ -12,9 +12,9 @@ var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _wrapDisplayName = require('recompose/wrapDisplayName');
var _propTypes = require('prop-types');
var _wrapDisplayName2 = _interopRequireDefault(_wrapDisplayName);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _withWidth = require('../utils/withWidth');
@@ -22,27 +22,16 @@ var _withWidth2 = _interopRequireDefault(_withWidth);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_HigherOrderComponent = require('react-flow-types').babelPluginFlowReactPropTypes_proptype_HigherOrderComponent || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_Breakpoint = require('../styles/createBreakpoints').babelPluginFlowReactPropTypes_proptype_Breakpoint || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_InjectedProps = {
/**
* If isWidthDown(options.breakpoint), return true.
*/
fullScreen: require('prop-types').bool.isRequired
};
/**
* Dialog will responsively be full screen *at or below* the given breakpoint
* (defaults to 'sm' for mobile devices).
* Notice that this Higher-order Component is incompatible with server side rendering.
*/
var withMobileDialog = function withMobileDialog() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { breakpoint: 'sm' };
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return function (Component) {
var breakpoint = options.breakpoint;
var _options$breakpoint = options.breakpoint,
breakpoint = _options$breakpoint === undefined ? 'sm' : _options$breakpoint;
function WithMobileDialog(props) {
@@ -50,11 +39,8 @@ var withMobileDialog = function withMobileDialog() {
}
WithMobileDialog.propTypes = process.env.NODE_ENV !== "production" ? {
width: require('prop-types').string.isRequired
width: _propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']).isRequired
} : {};
if (process.env.NODE_ENV !== 'production') {
WithMobileDialog.displayName = (0, _wrapDisplayName2.default)(Component, 'withMobileDialog');
}
return (0, _withWidth2.default)()(WithMobileDialog);
};

View File

@@ -1,37 +1,22 @@
// @flow
import React from 'react';
import type { HigherOrderComponent } from 'react-flow-types';
import wrapDisplayName from 'recompose/wrapDisplayName';
import PropTypes from 'prop-types';
import withWidth, { isWidthDown } from '../utils/withWidth';
import type { Breakpoint } from '../styles/createBreakpoints';
type Options = { breakpoint: Breakpoint };
export type InjectedProps = {
/**
* If isWidthDown(options.breakpoint), return true.
*/
fullScreen: boolean,
};
/**
* Dialog will responsively be full screen *at or below* the given breakpoint
* (defaults to 'sm' for mobile devices).
* Notice that this Higher-order Component is incompatible with server side rendering.
*/
const withMobileDialog = (
options: Options = { breakpoint: 'sm' },
): HigherOrderComponent<{}, InjectedProps> => (Component: any): any => {
const { breakpoint } = options;
const withMobileDialog = (options = {}) => Component => {
const { breakpoint = 'sm' } = options;
function WithMobileDialog(props: { width: string }) {
function WithMobileDialog(props) {
return <Component fullScreen={isWidthDown(breakpoint, props.width)} {...props} />;
}
if (process.env.NODE_ENV !== 'production') {
WithMobileDialog.displayName = wrapDisplayName(Component, 'withMobileDialog');
}
WithMobileDialog.propTypes = {
width: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']).isRequired,
};
return withWidth()(WithMobileDialog);
};