@material-ui/lab
Version:
Laboratory for new Material-UI modules.
125 lines (114 loc) • 4.14 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { styled, useThemeProps } from '@material-ui/core/styles';
import { capitalize } from '@material-ui/core/utils';
import { unstable_composeClasses as composeClasses } from '@material-ui/unstyled';
import { getTimelineDotUtilityClass } from './timelineDotClasses';
import { jsx as _jsx } from "react/jsx-runtime";
var useUtilityClasses = function useUtilityClasses(styleProps) {
var color = styleProps.color,
variant = styleProps.variant,
classes = styleProps.classes;
var slots = {
root: ['root', variant, color !== 'inherit' && "".concat(variant).concat(capitalize(color))]
};
return composeClasses(slots, getTimelineDotUtilityClass, classes);
};
var TimelineDotRoot = styled('span', {
name: 'MuiTimelineDot',
slot: 'Root',
overridesResolver: function overridesResolver(props, styles) {
var styleProps = props.styleProps;
return [styles.root, styles[styleProps.color !== 'inherit' && "".concat(styleProps.variant).concat(capitalize(styleProps.color))], styles[styleProps.variant]];
}
})(function (_ref) {
var styleProps = _ref.styleProps,
theme = _ref.theme;
return _extends({
display: 'flex',
alignSelf: 'baseline',
borderStyle: 'solid',
borderWidth: 2,
padding: 4,
borderRadius: '50%',
boxShadow: theme.shadows[1],
margin: '11.5px 0'
}, styleProps.variant === 'filled' && _extends({
borderColor: 'transparent'
}, styleProps.color === 'grey' ? {
color: theme.palette.grey[50],
backgroundColor: theme.palette.grey[400]
} : {
color: theme.palette[styleProps.color].contrastText,
backgroundColor: theme.palette[styleProps.color].main
}), styleProps.variant === 'outlined' && _extends({
boxShadow: 'none',
backgroundColor: 'transparent'
}, styleProps.color === 'grey' ? {
borderColor: theme.palette.grey[400]
} : {
borderColor: theme.palette[styleProps.color].main
}));
});
var TimelineDot = /*#__PURE__*/React.forwardRef(function TimelineDot(inProps, ref) {
var props = useThemeProps({
props: inProps,
name: 'MuiTimelineDot'
});
var className = props.className,
_props$color = props.color,
color = _props$color === void 0 ? 'grey' : _props$color,
_props$variant = props.variant,
variant = _props$variant === void 0 ? 'filled' : _props$variant,
other = _objectWithoutProperties(props, ["className", "color", "variant"]);
var styleProps = _extends({}, props, {
color: color,
variant: variant
});
var classes = useUtilityClasses(styleProps);
return /*#__PURE__*/_jsx(TimelineDotRoot, _extends({
className: clsx(classes.root, className),
styleProps: styleProps,
ref: ref
}, other));
});
process.env.NODE_ENV !== "production" ? TimelineDot.propTypes
/* remove-proptypes */
= {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the d.ts file and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The dot can have a different colors.
* @default 'grey'
*/
color: PropTypes.oneOf(['error', 'grey', 'info', 'inherit', 'primary', 'secondary', 'success', 'warning']),
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.object,
/**
* The dot can appear filled or outlined.
* @default 'filled'
*/
variant: PropTypes
/* @typescript-to-proptypes-ignore */
.oneOfType([PropTypes.oneOf(['filled', 'outlined']), PropTypes.string])
} : void 0;
export default TimelineDot;