UNPKG

5.16 kBJavaScriptView Raw
1import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2import _extends from "@babel/runtime/helpers/esm/extends";
3const _excluded = ["children", "className", "TransitionComponent", "transitionDuration", "TransitionProps"];
4import * as React from 'react';
5import PropTypes from 'prop-types';
6import clsx from 'clsx';
7import { unstable_composeClasses as composeClasses } from '@mui/base';
8import styled from '../styles/styled';
9import useThemeProps from '../styles/useThemeProps';
10import Collapse from '../Collapse';
11import StepperContext from '../Stepper/StepperContext';
12import StepContext from '../Step/StepContext';
13import { getStepContentUtilityClass } from './stepContentClasses';
14import { jsx as _jsx } from "react/jsx-runtime";
15
16const useUtilityClasses = ownerState => {
17 const {
18 classes,
19 last
20 } = ownerState;
21 const slots = {
22 root: ['root', last && 'last'],
23 transition: ['transition']
24 };
25 return composeClasses(slots, getStepContentUtilityClass, classes);
26};
27
28const StepContentRoot = styled('div', {
29 name: 'MuiStepContent',
30 slot: 'Root',
31 overridesResolver: (props, styles) => {
32 const {
33 ownerState
34 } = props;
35 return [styles.root, ownerState.last && styles.last];
36 }
37})(({
38 ownerState,
39 theme
40}) => _extends({
41 marginLeft: 12,
42 // half icon
43 paddingLeft: 8 + 12,
44 // margin + half icon
45 paddingRight: 8,
46 borderLeft: theme.vars ? `1px solid ${theme.vars.palette.StepContent.border}` : `1px solid ${theme.palette.mode === 'light' ? theme.palette.grey[400] : theme.palette.grey[600]}`
47}, ownerState.last && {
48 borderLeft: 'none'
49}));
50const StepContentTransition = styled(Collapse, {
51 name: 'MuiStepContent',
52 slot: 'Transition',
53 overridesResolver: (props, styles) => styles.transition
54})({});
55const StepContent = /*#__PURE__*/React.forwardRef(function StepContent(inProps, ref) {
56 const props = useThemeProps({
57 props: inProps,
58 name: 'MuiStepContent'
59 });
60
61 const {
62 children,
63 className,
64 TransitionComponent = Collapse,
65 transitionDuration: transitionDurationProp = 'auto',
66 TransitionProps
67 } = props,
68 other = _objectWithoutPropertiesLoose(props, _excluded);
69
70 const {
71 orientation
72 } = React.useContext(StepperContext);
73 const {
74 active,
75 last,
76 expanded
77 } = React.useContext(StepContext);
78
79 const ownerState = _extends({}, props, {
80 last
81 });
82
83 const classes = useUtilityClasses(ownerState);
84
85 if (process.env.NODE_ENV !== 'production') {
86 if (orientation !== 'vertical') {
87 console.error('MUI: <StepContent /> is only designed for use with the vertical stepper.');
88 }
89 }
90
91 let transitionDuration = transitionDurationProp;
92
93 if (transitionDurationProp === 'auto' && !TransitionComponent.muiSupportAuto) {
94 transitionDuration = undefined;
95 }
96
97 return /*#__PURE__*/_jsx(StepContentRoot, _extends({
98 className: clsx(classes.root, className),
99 ref: ref,
100 ownerState: ownerState
101 }, other, {
102 children: /*#__PURE__*/_jsx(StepContentTransition, _extends({
103 as: TransitionComponent,
104 in: active || expanded,
105 className: classes.transition,
106 ownerState: ownerState,
107 timeout: transitionDuration,
108 unmountOnExit: true
109 }, TransitionProps, {
110 children: children
111 }))
112 }));
113});
114process.env.NODE_ENV !== "production" ? StepContent.propTypes
115/* remove-proptypes */
116= {
117 // ----------------------------- Warning --------------------------------
118 // | These PropTypes are generated from the TypeScript type definitions |
119 // | To update them edit the d.ts file and run "yarn proptypes" |
120 // ----------------------------------------------------------------------
121
122 /**
123 * The content of the component.
124 */
125 children: PropTypes.node,
126
127 /**
128 * Override or extend the styles applied to the component.
129 */
130 classes: PropTypes.object,
131
132 /**
133 * @ignore
134 */
135 className: PropTypes.string,
136
137 /**
138 * The system prop that allows defining system overrides as well as additional CSS styles.
139 */
140 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
141
142 /**
143 * The component used for the transition.
144 * [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
145 * @default Collapse
146 */
147 TransitionComponent: PropTypes.elementType,
148
149 /**
150 * Adjust the duration of the content expand transition.
151 * Passed as a prop to the transition component.
152 *
153 * Set to 'auto' to automatically calculate transition time based on height.
154 * @default 'auto'
155 */
156 transitionDuration: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.shape({
157 appear: PropTypes.number,
158 enter: PropTypes.number,
159 exit: PropTypes.number
160 })]),
161
162 /**
163 * Props applied to the transition element.
164 * By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition/) component.
165 */
166 TransitionProps: PropTypes.object
167} : void 0;
168export default StepContent;
\No newline at end of file