UNPKG

916 BJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import * as React from 'react';
3import PropTypes from 'prop-types';
4import withWidth, { isWidthDown } from '../withWidth';
5/**
6 * Dialog will responsively be full screen *at or below* the given breakpoint
7 * (defaults to 'sm' for mobile devices).
8 * Notice that this Higher-order Component is incompatible with server-side rendering.
9 */
10
11const withMobileDialog = (options = {}) => Component => {
12 const {
13 breakpoint = 'sm'
14 } = options;
15
16 function WithMobileDialog(props) {
17 return /*#__PURE__*/React.createElement(Component, _extends({
18 fullScreen: isWidthDown(breakpoint, props.width)
19 }, props));
20 }
21
22 process.env.NODE_ENV !== "production" ? WithMobileDialog.propTypes = {
23 width: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']).isRequired
24 } : void 0;
25 return withWidth()(WithMobileDialog);
26};
27
28export default withMobileDialog;
\No newline at end of file