Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

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

View File

@@ -0,0 +1,37 @@
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import React from 'react';
import HiddenJs from './HiddenJs';
import HiddenCss from './HiddenCss';
/**
* Responsively hides children based on the selected implementation.
*/
function Hidden(props) {
const { implementation } = props,
other = _objectWithoutProperties(props, ['implementation']);
if (implementation === 'js') {
return React.createElement(HiddenJs, other);
}
return React.createElement(HiddenCss, other);
}
Hidden.defaultProps = {
implementation: 'js',
xsUp: false,
smUp: false,
mdUp: false,
lgUp: false,
xlUp: false,
xsDown: false,
smDown: false,
mdDown: false,
lgDown: false,
xlDown: false
};
export default Hidden;

View File

@@ -0,0 +1,84 @@
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
/* eslint-disable flowtype/require-valid-file-annotation */
import React from 'react';
import warning from 'warning';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import { capitalizeFirstLetter } from '../utils/helpers';
import withStyles from '../styles/withStyles';
function generateStyles(theme) {
const hidden = {
display: 'none'
};
return breakpointKeys.reduce((styles, key) => {
styles[`only${capitalizeFirstLetter(key)}`] = {
[theme.breakpoints.only(key)]: hidden
};
styles[`${key}Up`] = {
[theme.breakpoints.up(key)]: hidden
};
styles[`${key}Down`] = {
[theme.breakpoints.down(key)]: hidden
};
return styles;
}, {});
}
const styles = theme => generateStyles(theme);
/**
* @ignore - internal component.
*/
function HiddenCss(props) {
const {
children,
classes,
only,
xsUp,
smUp,
mdUp,
lgUp,
xlUp,
xsDown,
smDown,
mdDown,
lgDown,
xlDown
} = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'only', 'xsUp', 'smUp', 'mdUp', 'lgUp', 'xlUp', 'xsDown', 'smDown', 'mdDown', 'lgDown', 'xlDown']);
warning(Object.keys(other).length === 0 || Object.keys(other).length === 1 && other.hasOwnProperty('ref'), `Material-UI: unsupported properties received ${Object.keys(other).join(', ')} by \`<Hidden />\`.`);
const className = [];
for (let i = 0; i < breakpointKeys.length; i += 1) {
const breakpoint = breakpointKeys[i];
const breakpointUp = props[`${breakpoint}Up`];
const breakpointDown = props[`${breakpoint}Down`];
if (breakpointUp) {
className.push(classes[`${breakpoint}Up`]);
}
if (breakpointDown) {
className.push(classes[`${breakpoint}Down`]);
}
}
if (only) {
className.push(classes[`only${capitalizeFirstLetter(only)}`]);
}
return React.createElement(
'span',
{ className: className },
children
);
}
export default withStyles(styles, { name: 'MuiHiddenCss' })(HiddenCss);

View File

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

View File

@@ -0,0 +1,70 @@
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import warning from 'warning';
import { keys as breakpointKeys } from '../styles/createBreakpoints';
import withWidth, { isWidthDown, isWidthUp } from '../utils/withWidth';
/**
* @ignore - internal component.
*/
function HiddenJs(props) {
const {
children,
only,
xsUp,
smUp,
mdUp,
lgUp,
xlUp,
xsDown,
smDown,
mdDown,
lgDown,
xlDown,
width
} = props,
other = _objectWithoutProperties(props, ['children', 'only', 'xsUp', 'smUp', 'mdUp', 'lgUp', 'xlUp', 'xsDown', 'smDown', 'mdDown', 'lgDown', 'xlDown', 'width']);
warning(Object.keys(other).length === 0, `Material-UI: unsupported properties received ${JSON.stringify(other)} by \`<Hidden />\`.`);
let visible = true;
// `only` check is faster to get out sooner if used.
if (only) {
if (Array.isArray(only)) {
for (let i = 0; i < only.length; i += 1) {
const breakpoint = only[i];
if (width === breakpoint) {
visible = false;
break;
}
}
} else if (only && width === only) {
visible = false;
}
}
// Allow `only` to be combined with other props. If already hidden, no need to check others.
if (visible) {
// determine visibility based on the smallest size up
for (let i = 0; i < breakpointKeys.length; i += 1) {
const breakpoint = breakpointKeys[i];
const breakpointUp = props[`${breakpoint}Up`];
const breakpointDown = props[`${breakpoint}Down`];
if (breakpointUp && isWidthUp(breakpoint, width) || breakpointDown && isWidthDown(breakpoint, width)) {
visible = false;
break;
}
}
}
if (!visible) {
return null;
}
return children;
}
export default withWidth()(HiddenJs);

View File

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

View File

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

View File