Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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. ' +
);
}
}
const WithTheme = React.forwardRef(function WithTheme(props, ref) {
const { innerRef, ...other } = props;
const theme = useTheme() || defaultTheme;
return ;
});
WithTheme.propTypes = {
/**
* Use that prop to pass a ref to the decorated component.
* @deprecated
*/
innerRef: chainPropTypes(PropTypes.oneOfType([PropTypes.func, PropTypes.object]), props => {
if (props.innerRef == null) {
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.',
);
}),
};
if (process.env.NODE_ENV !== 'production') {
WithTheme.displayName = `WithTheme(${getDisplayName(Component)})`;
}
hoistNonReactStatics(WithTheme, Component);
StyledComponent.propTypes = {
/**
* A render function or node.
*/
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the component will recycle it's children DOM element.
* It's using `React.cloneElement` internally.
*
* This prop will be deprecated and removed in v5
*/
clone: chainPropTypes(PropTypes.bool, props => {
if (props.clone && props.component) {
return new Error('You can not use the clone and component prop at the same time.');
}
return null;
}),
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.elementType,
...propTypes,
};
if (process.env.NODE_ENV !== 'production') {
StyledComponent.displayName = `Styled(${classNamePrefix})`;
}
{summary}
<div role="region" id="{summary.props['aria-controls']}" aria-labelledby="{summary.props.id}">
{children}
</div>
);
});
ExpansionPanel.propTypes = {
/**
* The content of the expansion panel.
*/
children: chainPropTypes(PropTypes.node.isRequired, props => {
const summary = React.Children.toArray(props.children)[0];
if (isFragment(summary)) {
return new Error(
"Material-UI: the ExpansionPanel doesn't accept a Fragment as a child. " +
'Consider providing an array instead.',
);
}
if (!React.isValidElement(summary)) {
return new Error(
'Material-UI: expected the first child of ExpansionPanel to be a valid element.',
);
}
return null;
}),
)}
ref={ref}
style={composedStyle}
src={isMediaComponent ? image || src : undefined}
{...other}
>
{children}
);
});
CardMedia.propTypes = {
/**
* The content of the component.
*/
children: chainPropTypes(PropTypes.node, props => {
if (!props.children && !props.image && !props.src) {
return new Error('Material-UI: either `children`, `image` or `src` prop must be specified.');
}
return null;
}),
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* Component for rendering image.
onBlur={handleBlur}
onMouseOver={handleMouseOver}
onMouseLeave={handleMouseLeave}
/>
);
})}
);
});
Slider.propTypes = {
/**
* The label of the slider.
*/
'aria-label': chainPropTypes(PropTypes.string, props => {
const range = Array.isArray(props.value || props.defaultValue);
if (range && props['aria-label'] != null) {
return new Error(
'Material-UI: you need to use the `getAriaLabel` prop instead of `aria-label` when using a range slider.',
);
}
return null;
}),
/**
* The id of the element containing a label for the slider.
*/
'aria-labelledby': PropTypes.string,
/**
* A string value that provides a user-friendly name for the current value of the slider.
if (range && props['aria-label'] != null) {
return new Error(
'Material-UI: you need to use the `getAriaLabel` prop instead of `aria-label` when using a range slider.',
);
}
return null;
}),
/**
* The id of the element containing a label for the slider.
*/
'aria-labelledby': PropTypes.string,
/**
* A string value that provides a user-friendly name for the current value of the slider.
*/
'aria-valuetext': chainPropTypes(PropTypes.string, props => {
const range = Array.isArray(props.value || props.defaultValue);
if (range && props['aria-valuetext'] != null) {
return new Error(
'Material-UI: you need to use the `getAriaValueText` prop instead of `aria-valuetext` when using a range slider.',
);
}
return null;
}),
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: PropTypes.object.isRequired,
/**
*/
icon: PropTypes.node,
/**
* The component containing the icon.
*/
IconContainerComponent: PropTypes.elementType,
/**
* Maximum rating.
*/
max: PropTypes.number,
/**
* The name attribute of the radio `input` elements.
* If `readOnly` is false, the prop is required,
* this input name`should be unique within the parent form.
*/
name: chainPropTypes(PropTypes.string, props => {
if (!props.readOnly && !props.name) {
return new Error(
[
'Material-UI: the prop `name` is required (when `readOnly` is false).',
'Additionally, the input name should be unique within the parent form.',
].join('\n'),
);
}
return null;
}),
/**
* Callback fired when the value changes.
*
* @param {object} event The event source of the callback.
* @param {number} value The new value.
*/
);
});
Popper.propTypes = {
/**
* This is the reference element, or a function that returns the reference element,
* that may be used to set the position of the popover.
* The return value will passed as the reference object of the Popper
* instance.
*
* The reference element should be an HTML Element instance or a referenceObject:
* https://popper.js.org/popper-documentation.html#referenceObject.
*/
anchorEl: chainPropTypes(PropTypes.oneOfType([PropTypes.object, PropTypes.func]), props => {
if (props.open) {
const resolvedAnchorEl = getAnchorEl(props.anchorEl);
const containerWindow = ownerWindow(resolvedAnchorEl);
if (resolvedAnchorEl instanceof containerWindow.Element) {
const box = resolvedAnchorEl.getBoundingClientRect();
if (
process.env.NODE_ENV !== 'test' &&
box.top === 0 &&
box.left === 0 &&
box.right === 0 &&
box.bottom === 0
) {
return new Error(
[
* Callback fired when the page is changed.
*
* @param {object} event The event source of the callback.
* @param {number} page The page selected.
*/
onChangePage: PropTypes.func.isRequired,
/**
* Callback fired when the number of rows per page is changed.
*
* @param {object} event The event source of the callback.
*/
onChangeRowsPerPage: PropTypes.func,
/**
* The zero-based index of the current page.
*/
page: chainPropTypes(PropTypes.number.isRequired, props => {
const { count, page, rowsPerPage } = props;
const newLastPage = Math.max(0, Math.ceil(count / rowsPerPage) - 1);
if (page < 0 || page > newLastPage) {
return new Error(
'Material-UI: the page prop of a TablePagination is out of range ' +
`(0 to ${newLastPage}, but page is ${page}).`,
);
}
return null;
}),
/**
* The number of rows per page.
*/
rowsPerPage: PropTypes.number.isRequired,
/**
* Customizes the options of the rows per page select field. If less than two options are