Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!color.contrastText) {
color.contrastText = getContrastText(color.main);
}
return color;
}
const types = { dark, light };
if (process.env.NODE_ENV !== 'production') {
if (!types[type]) {
console.error(`Material-UI: the palette type \`${type}\` is not supported.`);
}
}
const paletteOutput = deepmerge(
{
// A collection of common colors.
common,
// The palette type, can be light or dark.
type,
// The colors used to represent primary interface elements for a user.
primary: augmentColor(primary),
// The colors used to represent secondary interface elements for a user.
secondary: augmentColor(secondary, 'A400', 'A200', 'A700'),
// The colors used to represent interface elements that the user should be made aware of.
error: augmentColor(error),
// The colors used to represent potentially dangerous actions or important messages.
warning: augmentColor(warning),
// The colors used to present information to the user that is neutral and not necessarily important.
info: augmentColor(info),
// The colors used to indicate the successful completion of an action that user triggered.
alignItems: PropTypes.oneOf(['flex-start', 'center']),
/**
* If `true`, the list item will be focused during the first mount.
* Focus will also be triggered if the value changes from false to true.
*/
autoFocus: PropTypes.bool,
/**
* If `true`, the list item will be a button (using `ButtonBase`). Props intended
* for `ButtonBase` can then be applied to `ListItem`.
*/
button: PropTypes.bool,
/**
* The content of the component. If a `ListItemSecondaryAction` is used it must
* be the last child.
*/
children: chainPropTypes(PropTypes.node, props => {
const children = React.Children.toArray(props.children);
// React.Children.toArray(props.children).findLastIndex(isListItemSecondaryAction)
let secondaryActionIndex = -1;
for (let i = children.length - 1; i >= 0; i -= 1) {
const child = children[i];
if (isMuiElement(child, ['ListItemSecondaryAction'])) {
secondaryActionIndex = i;
break;
}
}
// is ListItemSecondaryAction the last child of ListItem
if (secondaryActionIndex !== -1 && secondaryActionIndex !== children.length - 1) {
return new Error(
'Material-UI: you used an element after ListItemSecondaryAction. ' +
export default function withForwardedRef(Component) {
const ForwardRefComponent = React.forwardRef((props, ref) => (
// We expect this component to be wrapped in `withStyles` in which `innerRef`
// is already intercepted and therefore won't appear in `props` here.
));
if (process.env.NODE_ENV !== 'production') {
ForwardRefComponent.displayName = `ForwardRef(${getDisplayName(Component)})`;
}
return hoistNonReactStatics(ForwardRefComponent, Component);
}
return null;
// return new Error(
// 'Material-UI: the `innerRef` prop is deprecated and will be removed in v5. ' +
// 'Refs are now automatically forwarded to the inner component.',
// );
}),
};
// The wrapper receives only user supplied props, which could be a subset of
// the actual props Component might receive due to merging with defaultProps.
// So copying it here would give us the same result in the wrapper as well.
WithStyles.defaultProps = Component.defaultProps;
if (process.env.NODE_ENV !== 'production') {
WithStyles.displayName = `WithStyles(${getDisplayName(Component)})`;
}
hoistNonReactStatics(WithStyles, Component);
if (process.env.NODE_ENV !== 'production') {
// Exposed for test purposes.
WithStyles.Naked = Component;
WithStyles.options = options;
WithStyles.useStyles = useStyles;
}
return WithStyles;
};
if (process.env.NODE_ENV !== 'production' && Component === undefined) {
throw new Error(
[
'You are calling styled(Component)(style) with an undefined component.',
'You may have forgotten to import it.',
].join('\n'),
);
}
let classNamePrefix = name;
if (process.env.NODE_ENV !== 'production') {
if (!name) {
// Provide a better DX outside production.
const displayName = getDisplayName(Component);
if (displayName !== undefined) {
classNamePrefix = displayName;
}
}
}
const stylesOrCreator =
typeof style === 'function'
? theme => ({ root: props => style({ theme, ...props }) })
: { root: style };
const useStyles = makeStyles(stylesOrCreator, {
Component,
name: name || Component.displayName,
classNamePrefix,
...stylesOptions,
if (Component === undefined) {
throw new Error(
[
'You are calling withStyles(styles)(Component) with an undefined component.',
'You may have forgotten to import it.',
].join('\n'),
);
}
}
let classNamePrefix = name;
if (process.env.NODE_ENV !== 'production') {
if (!name) {
// Provide a better DX outside production.
const displayName = getDisplayName(Component);
if (displayName !== undefined) {
classNamePrefix = displayName;
}
}
}
const useStyles = makeStyles(stylesOrCreator, {
defaultTheme,
Component,
name: name || Component.displayName,
classNamePrefix,
...stylesOptions,
});
const WithStyles = React.forwardRef(function WithStyles(props, ref) {
const { classes: classesProp, innerRef, ...other } = props;
*/
children: PropTypes.node.isRequired,
/**
* If `true`, the component will not only prevent server-side rendering.
* It will also defer the rendering of the children into a different screen frame.
*/
defer: PropTypes.bool,
/**
* The fallback content to display.
*/
fallback: PropTypes.node,
};
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line
NoSsr['propTypes' + ''] = exactProp(NoSsr.propTypes);
}
export default NoSsr;
/**
* Disable the portal behavior.
* The children stay within it's parent DOM hierarchy.
*/
disablePortal: PropTypes.bool,
/**
* Callback fired once the children has been mounted into the `container`.
*
* This prop will be deprecated and removed in v5, the ref can be used instead.
*/
onRendered: PropTypes.func,
};
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line
Portal['propTypes' + ''] = exactProp(Portal.propTypes);
}
export default Portal;
function CssBaseline(props) {
const { children = null } = props;
useStyles();
return {children};
}
CssBaseline.propTypes = {
/**
* You can wrap a node.
*/
children: PropTypes.node,
};
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line
CssBaseline['propTypes' + ''] = exactProp(CssBaseline.propTypes);
}
export default CssBaseline;
* The mouse event to listen to. You can disable the listener by providing `false`.
*/
mouseEvent: PropTypes.oneOf(['onClick', 'onMouseDown', 'onMouseUp', false]),
/**
* Callback fired when a "click away" event is detected.
*/
onClickAway: PropTypes.func.isRequired,
/**
* The touch event to listen to. You can disable the listener by providing `false`.
*/
touchEvent: PropTypes.oneOf(['onTouchStart', 'onTouchEnd', false]),
};
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line
ClickAwayListener['propTypes' + ''] = exactProp(ClickAwayListener.propTypes);
}
export default ClickAwayListener;