UNPKG

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