UNPKG

4.92 kBJavaScriptView Raw
1'use client';
2
3var _circle;
4import * as React from 'react';
5import PropTypes from 'prop-types';
6import clsx from 'clsx';
7import composeClasses from '@mui/utils/composeClasses';
8import { styled } from "../zero-styled/index.js";
9import memoTheme from "../utils/memoTheme.js";
10import { useDefaultProps } from "../DefaultPropsProvider/index.js";
11import CheckCircle from "../internal/svg-icons/CheckCircle.js";
12import Warning from "../internal/svg-icons/Warning.js";
13import SvgIcon from "../SvgIcon/index.js";
14import stepIconClasses, { getStepIconUtilityClass } from "./stepIconClasses.js";
15import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16const 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};
29const 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})));
51const 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})));
62const StepIcon = /*#__PURE__*/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 /*#__PURE__*/_jsx(StepIconRoot, {
86 as: Warning,
87 className: className,
88 ref: ref,
89 ownerState: ownerState,
90 ...other
91 });
92 }
93 if (completed) {
94 return /*#__PURE__*/_jsx(StepIconRoot, {
95 as: CheckCircle,
96 className: className,
97 ref: ref,
98 ownerState: ownerState,
99 ...other
100 });
101 }
102 return /*#__PURE__*/_jsxs(StepIconRoot, {
103 className: className,
104 ref: ref,
105 ownerState: ownerState,
106 ...other,
107 children: [_circle || (_circle = /*#__PURE__*/_jsx("circle", {
108 cx: "12",
109 cy: "12",
110 r: "12"
111 })), /*#__PURE__*/_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});
124process.env.NODE_ENV !== "production" ? StepIcon.propTypes /* remove-proptypes */ = {
125 // ┌────────────────────────────── Warning ──────────────────────────────┐
126 // │ These PropTypes are generated from the TypeScript type definitions. │
127 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
128 // └─────────────────────────────────────────────────────────────────────┘
129 /**
130 * Whether this step is active.
131 * @default false
132 */
133 active: PropTypes.bool,
134 /**
135 * Override or extend the styles applied to the component.
136 */
137 classes: PropTypes.object,
138 /**
139 * @ignore
140 */
141 className: PropTypes.string,
142 /**
143 * Mark the step as completed. Is passed to child components.
144 * @default false
145 */
146 completed: PropTypes.bool,
147 /**
148 * If `true`, the step is marked as failed.
149 * @default false
150 */
151 error: PropTypes.bool,
152 /**
153 * The label displayed in the step icon.
154 */
155 icon: PropTypes.node,
156 /**
157 * The system prop that allows defining system overrides as well as additional CSS styles.
158 */
159 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
160} : void 0;
161export default StepIcon;
\No newline at end of file