1 | 'use client';
|
2 |
|
3 | var _circle;
|
4 | import * as React from 'react';
|
5 | import PropTypes from 'prop-types';
|
6 | import clsx from 'clsx';
|
7 | import composeClasses from '@mui/utils/composeClasses';
|
8 | import { styled } from "../zero-styled/index.js";
|
9 | import memoTheme from "../utils/memoTheme.js";
|
10 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
11 | import CheckCircle from "../internal/svg-icons/CheckCircle.js";
|
12 | import Warning from "../internal/svg-icons/Warning.js";
|
13 | import SvgIcon from "../SvgIcon/index.js";
|
14 | import stepIconClasses, { getStepIconUtilityClass } from "./stepIconClasses.js";
|
15 | import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
16 | const useUtilityClasses = ownerState => {
|
17 | const {
|
18 | classes,
|
19 | active,
|
20 | completed,
|
21 | error
|
22 | } = ownerState;
|
23 | const slots = {
|
24 | root: ['root', active && 'active', completed && 'completed', error && 'error'],
|
25 | text: ['text']
|
26 | };
|
27 | return composeClasses(slots, getStepIconUtilityClass, classes);
|
28 | };
|
29 | const StepIconRoot = styled(SvgIcon, {
|
30 | name: 'MuiStepIcon',
|
31 | slot: 'Root',
|
32 | overridesResolver: (props, styles) => styles.root
|
33 | })(memoTheme(({
|
34 | theme
|
35 | }) => ({
|
36 | display: 'block',
|
37 | transition: theme.transitions.create('color', {
|
38 | duration: theme.transitions.duration.shortest
|
39 | }),
|
40 | color: (theme.vars || theme).palette.text.disabled,
|
41 | [`&.${stepIconClasses.completed}`]: {
|
42 | color: (theme.vars || theme).palette.primary.main
|
43 | },
|
44 | [`&.${stepIconClasses.active}`]: {
|
45 | color: (theme.vars || theme).palette.primary.main
|
46 | },
|
47 | [`&.${stepIconClasses.error}`]: {
|
48 | color: (theme.vars || theme).palette.error.main
|
49 | }
|
50 | })));
|
51 | const StepIconText = styled('text', {
|
52 | name: 'MuiStepIcon',
|
53 | slot: 'Text',
|
54 | overridesResolver: (props, styles) => styles.text
|
55 | })(memoTheme(({
|
56 | theme
|
57 | }) => ({
|
58 | fill: (theme.vars || theme).palette.primary.contrastText,
|
59 | fontSize: theme.typography.caption.fontSize,
|
60 | fontFamily: theme.typography.fontFamily
|
61 | })));
|
62 | const StepIcon = React.forwardRef(function StepIcon(inProps, ref) {
|
63 | const props = useDefaultProps({
|
64 | props: inProps,
|
65 | name: 'MuiStepIcon'
|
66 | });
|
67 | const {
|
68 | active = false,
|
69 | className: classNameProp,
|
70 | completed = false,
|
71 | error = false,
|
72 | icon,
|
73 | ...other
|
74 | } = props;
|
75 | const ownerState = {
|
76 | ...props,
|
77 | active,
|
78 | completed,
|
79 | error
|
80 | };
|
81 | const classes = useUtilityClasses(ownerState);
|
82 | if (typeof icon === 'number' || typeof icon === 'string') {
|
83 | const className = clsx(classNameProp, classes.root);
|
84 | if (error) {
|
85 | return _jsx(StepIconRoot, {
|
86 | as: Warning,
|
87 | className: className,
|
88 | ref: ref,
|
89 | ownerState: ownerState,
|
90 | ...other
|
91 | });
|
92 | }
|
93 | if (completed) {
|
94 | return _jsx(StepIconRoot, {
|
95 | as: CheckCircle,
|
96 | className: className,
|
97 | ref: ref,
|
98 | ownerState: ownerState,
|
99 | ...other
|
100 | });
|
101 | }
|
102 | return _jsxs(StepIconRoot, {
|
103 | className: className,
|
104 | ref: ref,
|
105 | ownerState: ownerState,
|
106 | ...other,
|
107 | children: [_circle || (_circle = _jsx("circle", {
|
108 | cx: "12",
|
109 | cy: "12",
|
110 | r: "12"
|
111 | })), _jsx(StepIconText, {
|
112 | className: classes.text,
|
113 | x: "12",
|
114 | y: "12",
|
115 | textAnchor: "middle",
|
116 | dominantBaseline: "central",
|
117 | ownerState: ownerState,
|
118 | children: icon
|
119 | })]
|
120 | });
|
121 | }
|
122 | return icon;
|
123 | });
|
124 | process.env.NODE_ENV !== "production" ? StepIcon.propTypes = {
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | |
130 |
|
131 |
|
132 |
|
133 | active: PropTypes.bool,
|
134 | |
135 |
|
136 |
|
137 | classes: PropTypes.object,
|
138 | |
139 |
|
140 |
|
141 | className: PropTypes.string,
|
142 | |
143 |
|
144 |
|
145 |
|
146 | completed: PropTypes.bool,
|
147 | |
148 |
|
149 |
|
150 |
|
151 | error: PropTypes.bool,
|
152 | |
153 |
|
154 |
|
155 | icon: PropTypes.node,
|
156 | |
157 |
|
158 |
|
159 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
160 | } : void 0;
|
161 | export default StepIcon; |
\ | No newline at end of file |