UNPKG

@material-ui/lab

Version:
94 lines (84 loc) 3.17 kB
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 Typography from '@material-ui/core/Typography'; import TimelineContext from '../Timeline/TimelineContext'; import { getTimelineOppositeContentUtilityClass } from './timelineOppositeContentClasses'; import { jsx as _jsx } from "react/jsx-runtime"; var useUtilityClasses = function useUtilityClasses(styleProps) { var position = styleProps.position, classes = styleProps.classes; var slots = { root: ['root', "position".concat(capitalize(position))] }; return composeClasses(slots, getTimelineOppositeContentUtilityClass, classes); }; var TimelineOppositeContentRoot = styled(Typography, { name: 'MuiTimelineOppositeContent', slot: 'Root', overridesResolver: function overridesResolver(props, styles) { var styleProps = props.styleProps; return [styles.root, styles["position".concat(capitalize(styleProps.position))]]; } })(function (_ref) { var styleProps = _ref.styleProps; return _extends({ padding: '6px 16px', marginRight: 'auto', textAlign: 'right', flex: 1 }, styleProps.position === 'left' && { textAlign: 'left' }); }); var TimelineOppositeContent = /*#__PURE__*/React.forwardRef(function TimelineOppositeContent(inProps, ref) { var props = useThemeProps({ props: inProps, name: 'MuiTimelineOppositeContent' }); var className = props.className, other = _objectWithoutProperties(props, ["className"]); var _React$useContext = React.useContext(TimelineContext), positionContext = _React$useContext.position; var styleProps = _extends({}, props, { position: positionContext || 'left' }); var classes = useUtilityClasses(styleProps); return /*#__PURE__*/_jsx(TimelineOppositeContentRoot, _extends({ component: "div", className: clsx(classes.root, className), styleProps: styleProps, ref: ref }, other)); }); process.env.NODE_ENV !== "production" ? TimelineOppositeContent.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 system prop that allows defining system overrides as well as additional CSS styles. */ sx: PropTypes.object } : void 0; TimelineOppositeContent.muiName = 'TimelineOppositeContent'; export default TimelineOppositeContent;