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