1 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import { integerPropType } from '@mui/utils';
|
7 | import { unstable_composeClasses as composeClasses } from '@mui/base';
|
8 | import StepperContext from '../Stepper/StepperContext';
|
9 | import StepContext from './StepContext';
|
10 | import useThemeProps from '../styles/useThemeProps';
|
11 | import styled from '../styles/styled';
|
12 | import { getStepUtilityClass } from './stepClasses';
|
13 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
14 | import { jsx as _jsx } from "react/jsx-runtime";
|
15 |
|
16 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
17 | var classes = ownerState.classes,
|
18 | orientation = ownerState.orientation,
|
19 | alternativeLabel = ownerState.alternativeLabel,
|
20 | completed = ownerState.completed;
|
21 | var slots = {
|
22 | root: ['root', orientation, alternativeLabel && 'alternativeLabel', completed && 'completed']
|
23 | };
|
24 | return composeClasses(slots, getStepUtilityClass, classes);
|
25 | };
|
26 |
|
27 | var StepRoot = styled('div', {
|
28 | name: 'MuiStep',
|
29 | slot: 'Root',
|
30 | overridesResolver: function overridesResolver(props, styles) {
|
31 | var ownerState = props.ownerState;
|
32 | return [styles.root, styles[ownerState.orientation], ownerState.alternativeLabel && styles.alternativeLabel, ownerState.completed && styles.completed];
|
33 | }
|
34 | })(function (_ref) {
|
35 | var ownerState = _ref.ownerState;
|
36 | return _extends({}, ownerState.orientation === 'horizontal' && {
|
37 | paddingLeft: 8,
|
38 | paddingRight: 8
|
39 | }, ownerState.alternativeLabel && {
|
40 | flex: 1,
|
41 | position: 'relative'
|
42 | });
|
43 | });
|
44 | var Step = React.forwardRef(function Step(inProps, ref) {
|
45 | var props = useThemeProps({
|
46 | props: inProps,
|
47 | name: 'MuiStep'
|
48 | });
|
49 |
|
50 | var activeProp = props.active,
|
51 | children = props.children,
|
52 | className = props.className,
|
53 | completedProp = props.completed,
|
54 | disabledProp = props.disabled,
|
55 | _props$expanded = props.expanded,
|
56 | expanded = _props$expanded === void 0 ? false : _props$expanded,
|
57 | index = props.index,
|
58 | last = props.last,
|
59 | other = _objectWithoutProperties(props, ["active", "children", "className", "completed", "disabled", "expanded", "index", "last"]);
|
60 |
|
61 | var _React$useContext = React.useContext(StepperContext),
|
62 | activeStep = _React$useContext.activeStep,
|
63 | connector = _React$useContext.connector,
|
64 | alternativeLabel = _React$useContext.alternativeLabel,
|
65 | orientation = _React$useContext.orientation,
|
66 | nonLinear = _React$useContext.nonLinear;
|
67 |
|
68 | var _activeProp = activeProp,
|
69 | active = _activeProp === void 0 ? false : _activeProp,
|
70 | _completedProp = completedProp,
|
71 | completed = _completedProp === void 0 ? false : _completedProp,
|
72 | _disabledProp = disabledProp,
|
73 | disabled = _disabledProp === void 0 ? false : _disabledProp;
|
74 |
|
75 | if (activeStep === index) {
|
76 | active = activeProp !== undefined ? activeProp : true;
|
77 | } else if (!nonLinear && activeStep > index) {
|
78 | completed = completedProp !== undefined ? completedProp : true;
|
79 | } else if (!nonLinear && activeStep < index) {
|
80 | disabled = disabledProp !== undefined ? disabledProp : true;
|
81 | }
|
82 |
|
83 | var contextValue = React.useMemo(function () {
|
84 | return {
|
85 | index: index,
|
86 | last: last,
|
87 | expanded: expanded,
|
88 | icon: index + 1,
|
89 | active: active,
|
90 | completed: completed,
|
91 | disabled: disabled
|
92 | };
|
93 | }, [index, last, expanded, active, completed, disabled]);
|
94 |
|
95 | var ownerState = _extends({}, props, {
|
96 | active: active,
|
97 | orientation: orientation,
|
98 | alternativeLabel: alternativeLabel,
|
99 | completed: completed,
|
100 | disabled: disabled,
|
101 | expanded: expanded
|
102 | });
|
103 |
|
104 | var classes = useUtilityClasses(ownerState);
|
105 |
|
106 | var newChildren = _jsxs(StepRoot, _extends({
|
107 | className: clsx(classes.root, className),
|
108 | ref: ref,
|
109 | ownerState: ownerState
|
110 | }, other, {
|
111 | children: [connector && alternativeLabel && index !== 0 ? connector : null, children]
|
112 | }));
|
113 |
|
114 | return _jsx(StepContext.Provider, {
|
115 | value: contextValue,
|
116 | children: connector && !alternativeLabel && index !== 0 ? _jsxs(React.Fragment, {
|
117 | children: [connector, newChildren]
|
118 | }) : newChildren
|
119 | });
|
120 | });
|
121 | process.env.NODE_ENV !== "production" ? Step.propTypes
|
122 |
|
123 | = {
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | |
130 |
|
131 |
|
132 | active: PropTypes.bool,
|
133 |
|
134 | |
135 |
|
136 |
|
137 | children: PropTypes.node,
|
138 |
|
139 | |
140 |
|
141 |
|
142 | classes: PropTypes.object,
|
143 |
|
144 | |
145 |
|
146 |
|
147 | className: PropTypes.string,
|
148 |
|
149 | |
150 |
|
151 |
|
152 | completed: PropTypes.bool,
|
153 |
|
154 | |
155 |
|
156 |
|
157 |
|
158 | disabled: PropTypes.bool,
|
159 |
|
160 | |
161 |
|
162 |
|
163 |
|
164 | expanded: PropTypes.bool,
|
165 |
|
166 | |
167 |
|
168 |
|
169 |
|
170 | index: integerPropType,
|
171 |
|
172 | |
173 |
|
174 |
|
175 |
|
176 | last: PropTypes.bool,
|
177 |
|
178 | |
179 |
|
180 |
|
181 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
182 | } : void 0;
|
183 | export default Step; |
\ | No newline at end of file |