1 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3 | import _extends from "@babel/runtime/helpers/esm/extends";
|
4 | import * as React from 'react';
|
5 | import PropTypes from 'prop-types';
|
6 | import clsx from 'clsx';
|
7 | import { unstable_composeClasses as composeClasses } from '@mui/base';
|
8 | import styled from '../styles/styled';
|
9 | import useThemeProps from '../styles/useThemeProps';
|
10 | import StepIcon from '../StepIcon';
|
11 | import StepperContext from '../Stepper/StepperContext';
|
12 | import StepContext from '../Step/StepContext';
|
13 | import stepLabelClasses, { getStepLabelUtilityClass } from './stepLabelClasses';
|
14 | import { jsx as _jsx } from "react/jsx-runtime";
|
15 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
16 |
|
17 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
18 | var classes = ownerState.classes,
|
19 | orientation = ownerState.orientation,
|
20 | active = ownerState.active,
|
21 | completed = ownerState.completed,
|
22 | error = ownerState.error,
|
23 | disabled = ownerState.disabled,
|
24 | alternativeLabel = ownerState.alternativeLabel;
|
25 | var slots = {
|
26 | root: ['root', orientation, error && 'error', disabled && 'disabled', alternativeLabel && 'alternativeLabel'],
|
27 | label: ['label', active && 'active', completed && 'completed', error && 'error', disabled && 'disabled', alternativeLabel && 'alternativeLabel'],
|
28 | iconContainer: ['iconContainer', active && 'active', completed && 'completed', error && 'error', disabled && 'disabled', alternativeLabel && 'alternativeLabel'],
|
29 | labelContainer: ['labelContainer']
|
30 | };
|
31 | return composeClasses(slots, getStepLabelUtilityClass, classes);
|
32 | };
|
33 |
|
34 | var StepLabelRoot = styled('span', {
|
35 | name: 'MuiStepLabel',
|
36 | slot: 'Root',
|
37 | overridesResolver: function overridesResolver(props, styles) {
|
38 | var ownerState = props.ownerState;
|
39 | return [styles.root, styles[ownerState.orientation]];
|
40 | }
|
41 | })(function (_ref) {
|
42 | var _extends2;
|
43 |
|
44 | var ownerState = _ref.ownerState;
|
45 | return _extends((_extends2 = {
|
46 | display: 'flex',
|
47 | alignItems: 'center'
|
48 | }, _defineProperty(_extends2, "&.".concat(stepLabelClasses.alternativeLabel), {
|
49 | flexDirection: 'column'
|
50 | }), _defineProperty(_extends2, "&.".concat(stepLabelClasses.disabled), {
|
51 | cursor: 'default'
|
52 | }), _extends2), ownerState.orientation === 'vertical' && {
|
53 | textAlign: 'left',
|
54 | padding: '8px 0'
|
55 | });
|
56 | });
|
57 | var StepLabelLabel = styled('span', {
|
58 | name: 'MuiStepLabel',
|
59 | slot: 'Label',
|
60 | overridesResolver: function overridesResolver(props, styles) {
|
61 | return styles.label;
|
62 | }
|
63 | })(function (_ref2) {
|
64 | var _extends3;
|
65 |
|
66 | var theme = _ref2.theme;
|
67 | return _extends({}, theme.typography.body2, (_extends3 = {
|
68 | display: 'block',
|
69 | transition: theme.transitions.create('color', {
|
70 | duration: theme.transitions.duration.shortest
|
71 | })
|
72 | }, _defineProperty(_extends3, "&.".concat(stepLabelClasses.active), {
|
73 | color: (theme.vars || theme).palette.text.primary,
|
74 | fontWeight: 500
|
75 | }), _defineProperty(_extends3, "&.".concat(stepLabelClasses.completed), {
|
76 | color: (theme.vars || theme).palette.text.primary,
|
77 | fontWeight: 500
|
78 | }), _defineProperty(_extends3, "&.".concat(stepLabelClasses.alternativeLabel), {
|
79 | textAlign: 'center',
|
80 | marginTop: 16
|
81 | }), _defineProperty(_extends3, "&.".concat(stepLabelClasses.error), {
|
82 | color: (theme.vars || theme).palette.error.main
|
83 | }), _extends3));
|
84 | });
|
85 | var StepLabelIconContainer = styled('span', {
|
86 | name: 'MuiStepLabel',
|
87 | slot: 'IconContainer',
|
88 | overridesResolver: function overridesResolver(props, styles) {
|
89 | return styles.iconContainer;
|
90 | }
|
91 | })(function () {
|
92 | return _defineProperty({
|
93 | flexShrink: 0,
|
94 |
|
95 | display: 'flex',
|
96 | paddingRight: 8
|
97 | }, "&.".concat(stepLabelClasses.alternativeLabel), {
|
98 | paddingRight: 0
|
99 | });
|
100 | });
|
101 | var StepLabelLabelContainer = styled('span', {
|
102 | name: 'MuiStepLabel',
|
103 | slot: 'LabelContainer',
|
104 | overridesResolver: function overridesResolver(props, styles) {
|
105 | return styles.labelContainer;
|
106 | }
|
107 | })(function (_ref4) {
|
108 | var theme = _ref4.theme;
|
109 | return {
|
110 | width: '100%',
|
111 | color: (theme.vars || theme).palette.text.secondary
|
112 | };
|
113 | });
|
114 | var StepLabel = React.forwardRef(function StepLabel(inProps, ref) {
|
115 | var props = useThemeProps({
|
116 | props: inProps,
|
117 | name: 'MuiStepLabel'
|
118 | });
|
119 |
|
120 | var children = props.children,
|
121 | className = props.className,
|
122 | _props$componentsProp = props.componentsProps,
|
123 | componentsProps = _props$componentsProp === void 0 ? {} : _props$componentsProp,
|
124 | _props$error = props.error,
|
125 | error = _props$error === void 0 ? false : _props$error,
|
126 | iconProp = props.icon,
|
127 | optional = props.optional,
|
128 | StepIconComponentProp = props.StepIconComponent,
|
129 | StepIconProps = props.StepIconProps,
|
130 | other = _objectWithoutProperties(props, ["children", "className", "componentsProps", "error", "icon", "optional", "StepIconComponent", "StepIconProps"]);
|
131 |
|
132 | var _React$useContext = React.useContext(StepperContext),
|
133 | alternativeLabel = _React$useContext.alternativeLabel,
|
134 | orientation = _React$useContext.orientation;
|
135 |
|
136 | var _React$useContext2 = React.useContext(StepContext),
|
137 | active = _React$useContext2.active,
|
138 | disabled = _React$useContext2.disabled,
|
139 | completed = _React$useContext2.completed,
|
140 | iconContext = _React$useContext2.icon;
|
141 |
|
142 | var icon = iconProp || iconContext;
|
143 | var StepIconComponent = StepIconComponentProp;
|
144 |
|
145 | if (icon && !StepIconComponent) {
|
146 | StepIconComponent = StepIcon;
|
147 | }
|
148 |
|
149 | var ownerState = _extends({}, props, {
|
150 | active: active,
|
151 | alternativeLabel: alternativeLabel,
|
152 | completed: completed,
|
153 | disabled: disabled,
|
154 | error: error,
|
155 | orientation: orientation
|
156 | });
|
157 |
|
158 | var classes = useUtilityClasses(ownerState);
|
159 | return _jsxs(StepLabelRoot, _extends({
|
160 | className: clsx(classes.root, className),
|
161 | ref: ref,
|
162 | ownerState: ownerState
|
163 | }, other, {
|
164 | children: [icon || StepIconComponent ? _jsx(StepLabelIconContainer, {
|
165 | className: classes.iconContainer,
|
166 | ownerState: ownerState,
|
167 | children: _jsx(StepIconComponent, _extends({
|
168 | completed: completed,
|
169 | active: active,
|
170 | error: error,
|
171 | icon: icon
|
172 | }, StepIconProps))
|
173 | }) : null, _jsxs(StepLabelLabelContainer, {
|
174 | className: classes.labelContainer,
|
175 | ownerState: ownerState,
|
176 | children: [children ? _jsx(StepLabelLabel, _extends({
|
177 | className: classes.label,
|
178 | ownerState: ownerState
|
179 | }, componentsProps.label, {
|
180 | children: children
|
181 | })) : null, optional]
|
182 | })]
|
183 | }));
|
184 | });
|
185 | process.env.NODE_ENV !== "production" ? StepLabel.propTypes
|
186 |
|
187 | = {
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 | |
194 |
|
195 |
|
196 | children: PropTypes.node,
|
197 |
|
198 | |
199 |
|
200 |
|
201 | classes: PropTypes.object,
|
202 |
|
203 | |
204 |
|
205 |
|
206 | className: PropTypes.string,
|
207 |
|
208 | |
209 |
|
210 |
|
211 |
|
212 | componentsProps: PropTypes.shape({
|
213 | label: PropTypes.object
|
214 | }),
|
215 |
|
216 | |
217 |
|
218 |
|
219 |
|
220 | error: PropTypes.bool,
|
221 |
|
222 | |
223 |
|
224 |
|
225 | icon: PropTypes.node,
|
226 |
|
227 | |
228 |
|
229 |
|
230 | optional: PropTypes.node,
|
231 |
|
232 | |
233 |
|
234 |
|
235 | StepIconComponent: PropTypes.elementType,
|
236 |
|
237 | |
238 |
|
239 |
|
240 | StepIconProps: PropTypes.object,
|
241 |
|
242 | |
243 |
|
244 |
|
245 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
246 | } : void 0;
|
247 | StepLabel.muiName = 'StepLabel';
|
248 | export default StepLabel; |
\ | No newline at end of file |