1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import { styled } from "../zero-styled/index.js";
|
8 | import memoTheme from "../utils/memoTheme.js";
|
9 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
10 | import Collapse from "../Collapse/index.js";
|
11 | import StepperContext from "../Stepper/StepperContext.js";
|
12 | import StepContext from "../Step/StepContext.js";
|
13 | import { getStepContentUtilityClass } from "./stepContentClasses.js";
|
14 | import { jsx as _jsx } from "react/jsx-runtime";
|
15 | const 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 | };
|
26 | const 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 |
|
40 | paddingLeft: 8 + 12,
|
41 |
|
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 | })));
|
53 | const StepContentTransition = styled(Collapse, {
|
54 | name: 'MuiStepContent',
|
55 | slot: 'Transition',
|
56 | overridesResolver: (props, styles) => styles.transition
|
57 | })({});
|
58 | const StepContent = 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 _jsx(StepContentRoot, {
|
94 | className: clsx(classes.root, className),
|
95 | ref: ref,
|
96 | ownerState: ownerState,
|
97 | ...other,
|
98 | children: _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 | });
|
110 | process.env.NODE_ENV !== "production" ? StepContent.propTypes = {
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | |
116 |
|
117 |
|
118 | children: PropTypes.node,
|
119 | |
120 |
|
121 |
|
122 | classes: PropTypes.object,
|
123 | |
124 |
|
125 |
|
126 | className: PropTypes.string,
|
127 | |
128 |
|
129 |
|
130 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
131 | |
132 |
|
133 |
|
134 |
|
135 |
|
136 | TransitionComponent: PropTypes.elementType,
|
137 | |
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
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 |
|
151 |
|
152 |
|
153 | TransitionProps: PropTypes.object
|
154 | } : void 0;
|
155 | export default StepContent; |
\ | No newline at end of file |