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