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

@@ -3,18 +3,19 @@ import { StandardProps } from '..';
import { Breakpoint } from '../styles/createBreakpoints';
export interface HiddenProps extends StandardProps<{}, never> {
only?: Breakpoint | Array<Breakpoint>;
xsUp?: boolean;
smUp?: boolean;
mdUp?: boolean;
implementation?: 'js' | 'css';
initialWidth?: Breakpoint;
lgDown?: boolean;
lgUp?: boolean;
mdDown?: boolean;
mdUp?: boolean;
only?: Breakpoint | Array<Breakpoint>;
smDown?: boolean;
smUp?: boolean;
xlDown?: boolean;
xlUp?: boolean;
xsDown?: boolean;
smDown?: boolean;
mdDown?: boolean;
lgDown?: boolean;
xlDown?: boolean;
implementation?: 'js' | 'css';
xsUp?: boolean;
}
declare const Hidden: React.ComponentType<HiddenProps>;

View File

@@ -12,6 +12,10 @@ var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _HiddenJs = require('./HiddenJs');
var _HiddenJs2 = _interopRequireDefault(_HiddenJs);
@@ -22,97 +26,6 @@ var _HiddenCss2 = _interopRequireDefault(_HiddenCss);
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_Breakpoint = require('../styles/createBreakpoints').babelPluginFlowReactPropTypes_proptype_Breakpoint || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node.isRequired ? babelPluginFlowReactPropTypes_proptype_Node.isRequired : babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node).isRequired,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* Hide the given breakpoint(s).
*/
only: require('prop-types').oneOfType([typeof babelPluginFlowReactPropTypes_proptype_Breakpoint === 'function' ? babelPluginFlowReactPropTypes_proptype_Breakpoint : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Breakpoint), require('prop-types').arrayOf(typeof babelPluginFlowReactPropTypes_proptype_Breakpoint === 'function' ? babelPluginFlowReactPropTypes_proptype_Breakpoint : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Breakpoint))]),
/**
* If true, screens this size and up will be hidden.
*/
xsUp: require('prop-types').bool,
/**
* If true, screens this size and up will be hidden.
*/
smUp: require('prop-types').bool,
/**
* If true, screens this size and up will be hidden.
*/
mdUp: require('prop-types').bool,
/**
* If true, screens this size and up will be hidden.
*/
lgUp: require('prop-types').bool,
/**
* If true, screens this size and up will be hidden.
*/
xlUp: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
xsDown: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
smDown: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
mdDown: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
lgDown: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
xlDown: require('prop-types').bool,
/**
* Specify which implementation to use. 'js' is the default, 'css' works better for server
* side rendering.
*/
implementation: require('prop-types').oneOf(['js', 'css']),
/**
* You can use this property when choosing the `js` implementation with server side rendering.
*
* As `window.innerWidth` is unavailable on the server,
* we default to rendering an empty componenent during the first mount.
* In some situation you might want to use an heristic to approximate
* the screen width of the client browser screen width.
*
* For instance, you could be using the user-agent or the client-hints.
* http://caniuse.com/#search=client%20hint
*/
initialWidth: require('prop-types').number
};
/**
* Responsively hides children based on the selected implementation.
*/
@@ -128,19 +41,90 @@ function Hidden(props) {
return _react2.default.createElement(_HiddenCss2.default, other);
}
Hidden.propTypes = process.env.NODE_ENV !== "production" ? babelPluginFlowReactPropTypes_proptype_Props : {};
Hidden.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component.
*/
children: _propTypes2.default.node,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* Specify which implementation to use. 'js' is the default, 'css' works better for server
* side rendering.
*/
implementation: _propTypes2.default.oneOf(['js', 'css']),
/**
* You can use this property when choosing the `js` implementation with server side rendering.
*
* As `window.innerWidth` is unavailable on the server,
* we default to rendering an empty componenent during the first mount.
* In some situation you might want to use an heristic to approximate
* the screen width of the client browser screen width.
*
* For instance, you could be using the user-agent or the client-hints.
* http://caniuse.com/#search=client%20hint
*/
initialWidth: _propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
/**
* If true, screens this size and down will be hidden.
*/
lgDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
lgUp: _propTypes2.default.bool,
/**
* If true, screens this size and down will be hidden.
*/
mdDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
mdUp: _propTypes2.default.bool,
/**
* Hide the given breakpoint(s).
*/
only: _propTypes2.default.oneOfType([_propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), _propTypes2.default.arrayOf(_propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']))]),
/**
* If true, screens this size and down will be hidden.
*/
smDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
smUp: _propTypes2.default.bool,
/**
* If true, screens this size and down will be hidden.
*/
xlDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
xlUp: _propTypes2.default.bool,
/**
* If true, screens this size and down will be hidden.
*/
xsDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
xsUp: _propTypes2.default.bool
} : {};
Hidden.defaultProps = {
implementation: 'js',
xsUp: false,
smUp: false,
mdUp: false,
lgDown: false,
lgUp: false,
mdDown: false,
mdUp: false,
smDown: false,
smUp: false,
xlDown: false,
xlUp: false,
xsDown: false,
smDown: false,
mdDown: false,
lgDown: false,
xlDown: false
xsUp: false
};
exports.default = Hidden;

View File

@@ -1,69 +1,35 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import HiddenJs from './HiddenJs';
import HiddenCss from './HiddenCss';
import type { Breakpoint } from '../styles/createBreakpoints';
export type Props = {
/**
* Responsively hides children based on the selected implementation.
*/
function Hidden(props) {
const { implementation, ...other } = props;
if (implementation === 'js') {
return <HiddenJs {...other} />;
}
return <HiddenCss {...other} />;
}
Hidden.propTypes = {
/**
* The content of the component.
*/
children: Node,
children: PropTypes.node,
/**
* @ignore
*/
className?: string,
/**
* Hide the given breakpoint(s).
*/
only?: Breakpoint | Array<Breakpoint>,
/**
* If true, screens this size and up will be hidden.
*/
xsUp?: boolean,
/**
* If true, screens this size and up will be hidden.
*/
smUp?: boolean,
/**
* If true, screens this size and up will be hidden.
*/
mdUp?: boolean,
/**
* If true, screens this size and up will be hidden.
*/
lgUp?: 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 down will be hidden.
*/
smDown?: boolean,
/**
* If true, screens this size and down will be hidden.
*/
mdDown?: boolean,
/**
* If true, screens this size and down will be hidden.
*/
lgDown?: boolean,
/**
* If true, screens this size and down will be hidden.
*/
xlDown?: boolean,
className: PropTypes.string,
/**
* Specify which implementation to use. 'js' is the default, 'css' works better for server
* side rendering.
*/
implementation?: 'js' | 'css',
implementation: PropTypes.oneOf(['js', 'css']),
/**
* You can use this property when choosing the `js` implementation with server side rendering.
*
@@ -75,34 +41,68 @@ export type Props = {
* For instance, you could be using the user-agent or the client-hints.
* http://caniuse.com/#search=client%20hint
*/
initialWidth?: number,
initialWidth: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
/**
* If true, screens this size and down will be hidden.
*/
lgDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
lgUp: PropTypes.bool,
/**
* If true, screens this size and down will be hidden.
*/
mdDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
mdUp: PropTypes.bool,
/**
* Hide the given breakpoint(s).
*/
only: PropTypes.oneOfType([
PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
PropTypes.arrayOf(PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl'])),
]),
/**
* If true, screens this size and down will be hidden.
*/
smDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
smUp: PropTypes.bool,
/**
* If true, screens this size and down will be hidden.
*/
xlDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
xlUp: PropTypes.bool,
/**
* If true, screens this size and down will be hidden.
*/
xsDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
xsUp: PropTypes.bool,
};
/**
* Responsively hides children based on the selected implementation.
*/
function Hidden(props: Props) {
const { implementation, ...other } = props;
if (implementation === 'js') {
return <HiddenJs {...other} />;
}
return <HiddenCss {...other} />;
}
Hidden.defaultProps = {
implementation: 'js',
xsUp: false,
smUp: false,
mdUp: false,
lgDown: false,
lgUp: false,
mdDown: false,
mdUp: false,
smDown: false,
smUp: false,
xlDown: false,
xlUp: false,
xsDown: false,
smDown: false,
mdDown: false,
lgDown: false,
xlDown: false,
xsUp: false,
};
export default Hidden;

View File

@@ -0,0 +1,20 @@
import * as React from 'react';
import { Breakpoint } from '../styles/createBreakpoints';
export interface HiddenCssProps {
lgDown?: boolean;
lgUp?: boolean;
mdDown?: boolean;
mdUp?: boolean;
only?: Breakpoint | Array<Breakpoint>;
smDown?: boolean;
smUp?: boolean;
xlDown?: boolean;
xlUp?: boolean;
xsDown?: boolean;
xsUp?: boolean;
}
declare const HiddenCss: React.ComponentType<HiddenCssProps>;
export default HiddenCss;

View File

@@ -16,14 +16,14 @@ var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _warning = require('warning');
var _warning2 = _interopRequireDefault(_warning);
@@ -38,39 +38,18 @@ 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; /* eslint-disable flowtype/require-valid-file-annotation */
var babelPluginFlowReactPropTypes_proptype_HiddenProps = require('./types').babelPluginFlowReactPropTypes_proptype_HiddenProps || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_Props = (0, _extends3.default)({}, babelPluginFlowReactPropTypes_proptype_HiddenProps === require('prop-types').any ? {} : babelPluginFlowReactPropTypes_proptype_HiddenProps, {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node.isRequired ? babelPluginFlowReactPropTypes_proptype_Node.isRequired : babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node).isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object.isRequired
});
function generateStyles(theme) {
var styles = function styles(theme) {
var hidden = {
display: 'none'
};
return _createBreakpoints.keys.reduce(function (styles, key) {
styles['only' + (0, _helpers.capitalizeFirstLetter)(key)] = (0, _defineProperty3.default)({}, theme.breakpoints.only(key), hidden);
styles[key + 'Up'] = (0, _defineProperty3.default)({}, theme.breakpoints.up(key), hidden);
styles[key + 'Down'] = (0, _defineProperty3.default)({}, theme.breakpoints.down(key), hidden);
return _createBreakpoints.keys.reduce(function (acc, key) {
acc['only' + (0, _helpers.capitalize)(key)] = (0, _defineProperty3.default)({}, theme.breakpoints.only(key), hidden);
acc[key + 'Up'] = (0, _defineProperty3.default)({}, theme.breakpoints.up(key), hidden);
acc[key + 'Down'] = (0, _defineProperty3.default)({}, theme.breakpoints.down(key), hidden);
return styles;
return acc;
}, {});
}
var styles = function styles(theme) {
return generateStyles(theme);
};
/**
@@ -79,23 +58,28 @@ var styles = function styles(theme) {
function HiddenCss(props) {
var children = props.children,
classes = props.classes,
only = props.only,
xsUp = props.xsUp,
smUp = props.smUp,
mdUp = props.mdUp,
className = props.className,
lgDown = props.lgDown,
lgUp = props.lgUp,
mdDown = props.mdDown,
mdUp = props.mdUp,
only = props.only,
smDown = props.smDown,
smUp = props.smUp,
xlDown = props.xlDown,
xlUp = props.xlUp,
xsDown = props.xsDown,
smDown = props.smDown,
mdDown = props.mdDown,
lgDown = props.lgDown,
xlDown = props.xlDown,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'only', 'xsUp', 'smUp', 'mdUp', 'lgUp', 'xlUp', 'xsDown', 'smDown', 'mdDown', 'lgDown', 'xlDown']);
xsUp = props.xsUp,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'lgDown', 'lgUp', 'mdDown', 'mdUp', 'only', 'smDown', 'smUp', 'xlDown', 'xlUp', 'xsDown', 'xsUp']);
process.env.NODE_ENV !== "production" ? (0, _warning2.default)((0, _keys2.default)(other).length === 0 || (0, _keys2.default)(other).length === 1 && other.hasOwnProperty('ref'), 'Material-UI: unsupported properties received ' + (0, _keys2.default)(other).join(', ') + ' by `<Hidden />`.') : void 0;
var className = [];
var classNames = [];
if (className) {
classNames.push(className);
}
for (var i = 0; i < _createBreakpoints.keys.length; i += 1) {
var breakpoint = _createBreakpoints.keys[i];
@@ -103,23 +87,89 @@ function HiddenCss(props) {
var breakpointDown = props[breakpoint + 'Down'];
if (breakpointUp) {
className.push(classes[breakpoint + 'Up']);
classNames.push(classes[breakpoint + 'Up']);
}
if (breakpointDown) {
className.push(classes[breakpoint + 'Down']);
classNames.push(classes[breakpoint + 'Down']);
}
}
if (only) {
className.push(classes['only' + (0, _helpers.capitalizeFirstLetter)(only)]);
var onlyBreakpoints = Array.isArray(only) ? only : [only];
onlyBreakpoints.forEach(function (breakpoint) {
classNames.push(classes['only' + (0, _helpers.capitalize)(breakpoint)]);
});
}
return _react2.default.createElement(
'span',
{ className: className },
'div',
{ className: classNames.join(' ') },
children
);
}
HiddenCss.propTypes = process.env.NODE_ENV !== "production" ? babelPluginFlowReactPropTypes_proptype_Props : {};
HiddenCss.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,
/**
* Specify which implementation to use. 'js' is the default, 'css' works better for server
* side rendering.
*/
implementation: _propTypes2.default.oneOf(['js', 'css']),
/**
* If true, screens this size and down will be hidden.
*/
lgDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
lgUp: _propTypes2.default.bool,
/**
* If true, screens this size and down will be hidden.
*/
mdDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
mdUp: _propTypes2.default.bool,
/**
* Hide the given breakpoint(s).
*/
only: _propTypes2.default.oneOfType([_propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), _propTypes2.default.arrayOf(_propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']))]),
/**
* If true, screens this size and down will be hidden.
*/
smDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
smUp: _propTypes2.default.bool,
/**
* If true, screens this size and down will be hidden.
*/
xlDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
xlUp: _propTypes2.default.bool,
/**
* If true, screens this size and down will be hidden.
*/
xsDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
xsUp: _propTypes2.default.bool
} : {};
exports.default = (0, _withStyles2.default)(styles, { name: 'MuiHiddenCss' })(HiddenCss);

View File

@@ -1,45 +1,29 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import warning from 'warning';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import { capitalizeFirstLetter } from '../utils/helpers';
import { capitalize } from '../utils/helpers';
import withStyles from '../styles/withStyles';
import type { HiddenProps } from './types';
export type Props = HiddenProps & {
/**
* The content of the component.
*/
children: Node,
/**
* Useful to extend the style applied to components.
*/
classes: Object,
};
function generateStyles(theme) {
const styles = theme => {
const hidden = {
display: 'none',
};
return breakpointKeys.reduce((styles, key) => {
styles[`only${capitalizeFirstLetter(key)}`] = {
return breakpointKeys.reduce((acc, key) => {
acc[`only${capitalize(key)}`] = {
[theme.breakpoints.only(key)]: hidden,
};
styles[`${key}Up`] = {
acc[`${key}Up`] = {
[theme.breakpoints.up(key)]: hidden,
};
styles[`${key}Down`] = {
acc[`${key}Down`] = {
[theme.breakpoints.down(key)]: hidden,
};
return styles;
return acc;
}, {});
}
const styles = (theme: Object) => generateStyles(theme);
};
/**
* @ignore - internal component.
@@ -48,17 +32,18 @@ function HiddenCss(props: Props) {
const {
children,
classes,
only,
xsUp,
smUp,
mdUp,
className,
lgDown,
lgUp,
mdDown,
mdUp,
only,
smDown,
smUp,
xlDown,
xlUp,
xsDown,
smDown,
mdDown,
lgDown,
xlDown,
xsUp,
...other
} = props;
@@ -70,7 +55,11 @@ function HiddenCss(props: Props) {
)} by \`<Hidden />\`.`,
);
const className = [];
const classNames = [];
if (className) {
classNames.push(className);
}
for (let i = 0; i < breakpointKeys.length; i += 1) {
const breakpoint = breakpointKeys[i];
@@ -78,18 +67,88 @@ function HiddenCss(props: Props) {
const breakpointDown = props[`${breakpoint}Down`];
if (breakpointUp) {
className.push(classes[`${breakpoint}Up`]);
classNames.push(classes[`${breakpoint}Up`]);
}
if (breakpointDown) {
className.push(classes[`${breakpoint}Down`]);
classNames.push(classes[`${breakpoint}Down`]);
}
}
if (only) {
className.push(classes[`only${capitalizeFirstLetter(only)}`]);
const onlyBreakpoints = Array.isArray(only) ? only : [only];
onlyBreakpoints.forEach(breakpoint => {
classNames.push(classes[`only${capitalize(breakpoint)}`]);
});
}
return <span className={className}>{children}</span>;
return <div className={classNames.join(' ')}>{children}</div>;
}
HiddenCss.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,
/**
* Specify which implementation to use. 'js' is the default, 'css' works better for server
* side rendering.
*/
implementation: PropTypes.oneOf(['js', 'css']),
/**
* If true, screens this size and down will be hidden.
*/
lgDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
lgUp: PropTypes.bool,
/**
* If true, screens this size and down will be hidden.
*/
mdDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
mdUp: PropTypes.bool,
/**
* Hide the given breakpoint(s).
*/
only: PropTypes.oneOfType([
PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
PropTypes.arrayOf(PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl'])),
]),
/**
* If true, screens this size and down will be hidden.
*/
smDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
smUp: PropTypes.bool,
/**
* If true, screens this size and down will be hidden.
*/
xlDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
xlUp: PropTypes.bool,
/**
* If true, screens this size and down will be hidden.
*/
xsDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
xsUp: PropTypes.bool,
};
export default withStyles(styles, { name: 'MuiHiddenCss' })(HiddenCss);

View File

@@ -2,17 +2,18 @@ import * as React from 'react';
import { Breakpoint } from '../styles/createBreakpoints';
export interface HiddenJsProps {
only?: Breakpoint | Array<Breakpoint>;
xsUp?: boolean;
smUp?: boolean;
mdUp?: boolean;
initialWidth?: Breakpoint;
lgDown?: boolean;
lgUp?: boolean;
mdDown?: boolean;
mdUp?: boolean;
only?: Breakpoint | Array<Breakpoint>;
smDown?: boolean;
smUp?: boolean;
xlDown?: boolean;
xlUp?: boolean;
xsDown?: boolean;
smDown?: boolean;
mdDown?: boolean;
lgDown?: boolean;
xlDown?: boolean;
xsUp?: boolean;
}
declare const HiddenJs: React.ComponentType<HiddenJsProps>;

View File

@@ -4,25 +4,9 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
var _stringify = require('babel-runtime/core-js/json/stringify');
var _propTypes = require('prop-types');
var _stringify2 = _interopRequireDefault(_stringify);
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _warning = require('warning');
var _warning2 = _interopRequireDefault(_warning);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _createBreakpoints = require('../styles/createBreakpoints');
@@ -30,48 +14,21 @@ var _withWidth = require('../utils/withWidth');
var _withWidth2 = _interopRequireDefault(_withWidth);
var _exactProp = require('../utils/exactProp');
var _exactProp2 = _interopRequireDefault(_exactProp);
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_HiddenProps = require('./types').babelPluginFlowReactPropTypes_proptype_HiddenProps || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_Props = (0, _extends3.default)({}, babelPluginFlowReactPropTypes_proptype_HiddenProps === require('prop-types').any ? {} : babelPluginFlowReactPropTypes_proptype_HiddenProps, {
/**
* The content of the component.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node.isRequired ? babelPluginFlowReactPropTypes_proptype_Node.isRequired : babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node).isRequired,
/**
* @ignore
* width prop provided by withWidth decorator
*/
width: require('prop-types').string.isRequired
});
/**
* @ignore - internal component.
*/
function HiddenJs(props) {
var children = props.children,
only = props.only,
xsUp = props.xsUp,
smUp = props.smUp,
mdUp = props.mdUp,
lgUp = props.lgUp,
xlUp = props.xlUp,
xsDown = props.xsDown,
smDown = props.smDown,
mdDown = props.mdDown,
lgDown = props.lgDown,
xlDown = props.xlDown,
width = props.width,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'only', 'xsUp', 'smUp', 'mdUp', 'lgUp', 'xlUp', 'xsDown', 'smDown', 'mdDown', 'lgDown', 'xlDown', 'width']);
width = props.width;
process.env.NODE_ENV !== "production" ? (0, _warning2.default)((0, _keys2.default)(other).length === 0, 'Material-UI: unsupported properties received ' + (0, _stringify2.default)(other) + ' by `<Hidden />`.') : void 0;
var visible = true;
// `only` check is faster to get out sooner if used.
@@ -110,4 +67,83 @@ function HiddenJs(props) {
return children;
}
HiddenJs.propTypes = {
/**
* The content of the component.
*/
children: _propTypes2.default.node,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* Specify which implementation to use. 'js' is the default, 'css' works better for server
* side rendering.
*/
implementation: _propTypes2.default.oneOf(['js', 'css']),
/**
* You can use this property when choosing the `js` implementation with server side rendering.
*
* As `window.innerWidth` is unavailable on the server,
* we default to rendering an empty componenent during the first mount.
* In some situation you might want to use an heristic to approximate
* the screen width of the client browser screen width.
*
* For instance, you could be using the user-agent or the client-hints.
* http://caniuse.com/#search=client%20hint
*/
initialWidth: _propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
/**
* If true, screens this size and down will be hidden.
*/
lgDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
lgUp: _propTypes2.default.bool,
/**
* If true, screens this size and down will be hidden.
*/
mdDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
mdUp: _propTypes2.default.bool,
/**
* Hide the given breakpoint(s).
*/
only: _propTypes2.default.oneOfType([_propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']), _propTypes2.default.arrayOf(_propTypes2.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']))]),
/**
* If true, screens this size and down will be hidden.
*/
smDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
smUp: _propTypes2.default.bool,
/**
* @ignore
* width prop provided by withWidth decorator.
*/
width: _propTypes2.default.string.isRequired,
/**
* If true, screens this size and down will be hidden.
*/
xlDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
xlUp: _propTypes2.default.bool,
/**
* If true, screens this size and down will be hidden.
*/
xsDown: _propTypes2.default.bool,
/**
* If true, screens this size and up will be hidden.
*/
xsUp: _propTypes2.default.bool
};
HiddenJs.propTypes = (0, _exactProp2.default)(HiddenJs.propTypes, 'HiddenJs');
exports.default = (0, _withWidth2.default)()(HiddenJs);

View File

@@ -1,48 +1,13 @@
// @flow
import type { Node } from 'react';
import warning from 'warning';
import PropTypes from 'prop-types';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import withWidth, { isWidthDown, isWidthUp } from '../utils/withWidth';
import type { HiddenProps } from './types';
export type Props = HiddenProps & {
/**
* The content of the component.
*/
children: Node,
/**
* @ignore
* width prop provided by withWidth decorator
*/
width: string,
};
import exactProp from '../utils/exactProp';
/**
* @ignore - internal component.
*/
function HiddenJs(props: Props) {
const {
children,
only,
xsUp,
smUp,
mdUp,
lgUp,
xlUp,
xsDown,
smDown,
mdDown,
lgDown,
xlDown,
width,
...other
} = props;
warning(
Object.keys(other).length === 0,
`Material-UI: unsupported properties received ${JSON.stringify(other)} by \`<Hidden />\`.`,
);
function HiddenJs(props) {
const { children, only, width } = props;
let visible = true;
@@ -85,4 +50,86 @@ function HiddenJs(props: Props) {
return children;
}
HiddenJs.propTypes = {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* @ignore
*/
className: PropTypes.string,
/**
* Specify which implementation to use. 'js' is the default, 'css' works better for server
* side rendering.
*/
implementation: PropTypes.oneOf(['js', 'css']),
/**
* You can use this property when choosing the `js` implementation with server side rendering.
*
* As `window.innerWidth` is unavailable on the server,
* we default to rendering an empty componenent during the first mount.
* In some situation you might want to use an heristic to approximate
* the screen width of the client browser screen width.
*
* For instance, you could be using the user-agent or the client-hints.
* http://caniuse.com/#search=client%20hint
*/
initialWidth: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
/**
* If true, screens this size and down will be hidden.
*/
lgDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
lgUp: PropTypes.bool,
/**
* If true, screens this size and down will be hidden.
*/
mdDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
mdUp: PropTypes.bool,
/**
* Hide the given breakpoint(s).
*/
only: PropTypes.oneOfType([
PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
PropTypes.arrayOf(PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl'])),
]),
/**
* If true, screens this size and down will be hidden.
*/
smDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
smUp: PropTypes.bool,
/**
* @ignore
* width prop provided by withWidth decorator.
*/
width: PropTypes.string.isRequired,
/**
* If true, screens this size and down will be hidden.
*/
xlDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
xlUp: PropTypes.bool,
/**
* If true, screens this size and down will be hidden.
*/
xsDown: PropTypes.bool,
/**
* If true, screens this size and up will be hidden.
*/
xsUp: PropTypes.bool,
};
HiddenJs.propTypes = exactProp(HiddenJs.propTypes, 'HiddenJs');
export default withWidth()(HiddenJs);

View File

@@ -1,4 +1,2 @@
export { default } from './Hidden';
export * from './Hidden';
export { default as HiddenJs } from './HiddenJs';
export * from './HiddenJs';

View File

@@ -13,13 +13,4 @@ Object.defineProperty(exports, 'default', {
}
});
var _HiddenJs = require('./HiddenJs');
Object.defineProperty(exports, 'HiddenJs', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_HiddenJs).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

View File

@@ -1,4 +1 @@
// @flow
export { default } from './Hidden';
export { default as HiddenJs } from './HiddenJs';

View File

@@ -1,67 +0,0 @@
'use strict';
// IMPORTANT: this must be identical to Hidden.js Props.
// This is here because docgen can't yet import type definitions across files.
var babelPluginFlowReactPropTypes_proptype_Breakpoint = require('../styles/createBreakpoints').babelPluginFlowReactPropTypes_proptype_Breakpoint || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_HiddenProps = {
/**
* @ignore
*/
className: require('prop-types').string,
/**
* Hide the given breakpoint(s).
*/
only: require('prop-types').oneOfType([typeof babelPluginFlowReactPropTypes_proptype_Breakpoint === 'function' ? babelPluginFlowReactPropTypes_proptype_Breakpoint : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Breakpoint), require('prop-types').arrayOf(typeof babelPluginFlowReactPropTypes_proptype_Breakpoint === 'function' ? babelPluginFlowReactPropTypes_proptype_Breakpoint : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Breakpoint))]),
/**
* If true, screens this size and up will be hidden.
*/
xsUp: require('prop-types').bool,
/**
* If true, screens this size and up will be hidden.
*/
smUp: require('prop-types').bool,
/**
* If true, screens this size and up will be hidden.
*/
mdUp: require('prop-types').bool,
/**
* If true, screens this size and up will be hidden.
*/
lgUp: require('prop-types').bool,
/**
* If true, screens this size and up will be hidden.
*/
xlUp: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
xsDown: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
smDown: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
mdDown: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
lgDown: require('prop-types').bool,
/**
* If true, screens this size and down will be hidden.
*/
xlDown: require('prop-types').bool
};

View File

@@ -1,56 +0,0 @@
// @flow
import type { Breakpoint } from '../styles/createBreakpoints';
// IMPORTANT: this must be identical to Hidden.js Props.
// This is here because docgen can't yet import type definitions across files.
export type HiddenProps = {
/**
* @ignore
*/
className?: string,
/**
* Hide the given breakpoint(s).
*/
only?: Breakpoint | Array<Breakpoint>,
/**
* If true, screens this size and up will be hidden.
*/
xsUp?: boolean,
/**
* If true, screens this size and up will be hidden.
*/
smUp?: boolean,
/**
* If true, screens this size and up will be hidden.
*/
mdUp?: boolean,
/**
* If true, screens this size and up will be hidden.
*/
lgUp?: 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 down will be hidden.
*/
smDown?: boolean,
/**
* If true, screens this size and down will be hidden.
*/
mdDown?: boolean,
/**
* If true, screens this size and down will be hidden.
*/
lgDown?: boolean,
/**
* If true, screens this size and down will be hidden.
*/
xlDown?: boolean,
};