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 { useDefaultProps } from '../DefaultPropsProvider';
|
11 | import styled from '../styles/styled';
|
12 | import { getStepperUtilityClass } from './stepperClasses';
|
13 | import StepConnector from '../StepConnector';
|
14 | import StepperContext from './StepperContext';
|
15 | import { jsx as _jsx } from "react/jsx-runtime";
|
16 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
17 | var orientation = ownerState.orientation,
|
18 | nonLinear = ownerState.nonLinear,
|
19 | alternativeLabel = ownerState.alternativeLabel,
|
20 | classes = ownerState.classes;
|
21 | var slots = {
|
22 | root: ['root', orientation, nonLinear && 'nonLinear', alternativeLabel && 'alternativeLabel']
|
23 | };
|
24 | return composeClasses(slots, getStepperUtilityClass, classes);
|
25 | };
|
26 | var StepperRoot = styled('div', {
|
27 | name: 'MuiStepper',
|
28 | slot: 'Root',
|
29 | overridesResolver: function overridesResolver(props, styles) {
|
30 | var ownerState = props.ownerState;
|
31 | return [styles.root, styles[ownerState.orientation], ownerState.alternativeLabel && styles.alternativeLabel, ownerState.nonLinear && styles.nonLinear];
|
32 | }
|
33 | })(function (_ref) {
|
34 | var ownerState = _ref.ownerState;
|
35 | return _extends({
|
36 | display: 'flex'
|
37 | }, ownerState.orientation === 'horizontal' && {
|
38 | flexDirection: 'row',
|
39 | alignItems: 'center'
|
40 | }, ownerState.orientation === 'vertical' && {
|
41 | flexDirection: 'column'
|
42 | }, ownerState.alternativeLabel && {
|
43 | alignItems: 'flex-start'
|
44 | });
|
45 | });
|
46 | var defaultConnector = _jsx(StepConnector, {});
|
47 | var Stepper = React.forwardRef(function Stepper(inProps, ref) {
|
48 | var props = useDefaultProps({
|
49 | props: inProps,
|
50 | name: 'MuiStepper'
|
51 | });
|
52 | var _props$activeStep = props.activeStep,
|
53 | activeStep = _props$activeStep === void 0 ? 0 : _props$activeStep,
|
54 | _props$alternativeLab = props.alternativeLabel,
|
55 | alternativeLabel = _props$alternativeLab === void 0 ? false : _props$alternativeLab,
|
56 | children = props.children,
|
57 | className = props.className,
|
58 | _props$component = props.component,
|
59 | component = _props$component === void 0 ? 'div' : _props$component,
|
60 | _props$connector = props.connector,
|
61 | connector = _props$connector === void 0 ? defaultConnector : _props$connector,
|
62 | _props$nonLinear = props.nonLinear,
|
63 | nonLinear = _props$nonLinear === void 0 ? false : _props$nonLinear,
|
64 | _props$orientation = props.orientation,
|
65 | orientation = _props$orientation === void 0 ? 'horizontal' : _props$orientation,
|
66 | other = _objectWithoutProperties(props, ["activeStep", "alternativeLabel", "children", "className", "component", "connector", "nonLinear", "orientation"]);
|
67 | var ownerState = _extends({}, props, {
|
68 | nonLinear: nonLinear,
|
69 | alternativeLabel: alternativeLabel,
|
70 | orientation: orientation,
|
71 | component: component
|
72 | });
|
73 | var classes = useUtilityClasses(ownerState);
|
74 | var childrenArray = React.Children.toArray(children).filter(Boolean);
|
75 | var steps = childrenArray.map(function (step, index) {
|
76 | return React.cloneElement(step, _extends({
|
77 | index: index,
|
78 | last: index + 1 === childrenArray.length
|
79 | }, step.props));
|
80 | });
|
81 | var contextValue = React.useMemo(function () {
|
82 | return {
|
83 | activeStep: activeStep,
|
84 | alternativeLabel: alternativeLabel,
|
85 | connector: connector,
|
86 | nonLinear: nonLinear,
|
87 | orientation: orientation
|
88 | };
|
89 | }, [activeStep, alternativeLabel, connector, nonLinear, orientation]);
|
90 | return _jsx(StepperContext.Provider, {
|
91 | value: contextValue,
|
92 | children: _jsx(StepperRoot, _extends({
|
93 | as: component,
|
94 | ownerState: ownerState,
|
95 | className: clsx(classes.root, className),
|
96 | ref: ref
|
97 | }, other, {
|
98 | children: steps
|
99 | }))
|
100 | });
|
101 | });
|
102 | process.env.NODE_ENV !== "production" ? Stepper.propTypes = {
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | |
108 |
|
109 |
|
110 |
|
111 |
|
112 | activeStep: integerPropType,
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 | alternativeLabel: PropTypes.bool,
|
119 | |
120 |
|
121 |
|
122 | children: PropTypes.node,
|
123 | |
124 |
|
125 |
|
126 | classes: PropTypes.object,
|
127 | |
128 |
|
129 |
|
130 | className: PropTypes.string,
|
131 | |
132 |
|
133 |
|
134 |
|
135 | component: PropTypes.elementType,
|
136 | |
137 |
|
138 |
|
139 |
|
140 | connector: PropTypes.element,
|
141 | |
142 |
|
143 |
|
144 |
|
145 | nonLinear: PropTypes.bool,
|
146 | |
147 |
|
148 |
|
149 |
|
150 | orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
151 | |
152 |
|
153 |
|
154 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
155 | } : void 0;
|
156 | export default Stepper; |
\ | No newline at end of file |