UNPKG

4.04 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var React = _interopRequireWildcard(require("react"));
13
14var _propTypes = _interopRequireDefault(require("prop-types"));
15
16var _clsx = _interopRequireDefault(require("clsx"));
17
18var _CheckCircle = _interopRequireDefault(require("../internal/svg-icons/CheckCircle"));
19
20var _Warning = _interopRequireDefault(require("../internal/svg-icons/Warning"));
21
22var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
23
24var _SvgIcon = _interopRequireDefault(require("../SvgIcon"));
25
26var styles = function styles(theme) {
27 return {
28 /* Styles applied to the root element. */
29 root: {
30 display: 'block',
31 color: theme.palette.text.disabled,
32 '&$completed': {
33 color: theme.palette.primary.main
34 },
35 '&$active': {
36 color: theme.palette.primary.main
37 },
38 '&$error': {
39 color: theme.palette.error.main
40 }
41 },
42
43 /* Styles applied to the SVG text element. */
44 text: {
45 fill: theme.palette.primary.contrastText,
46 fontSize: theme.typography.caption.fontSize,
47 fontFamily: theme.typography.fontFamily
48 },
49
50 /* Pseudo-class applied to the root element if `active={true}`. */
51 active: {},
52
53 /* Pseudo-class applied to the root element if `completed={true}`. */
54 completed: {},
55
56 /* Pseudo-class applied to the root element if `error={true}`. */
57 error: {}
58 };
59};
60
61exports.styles = styles;
62
63var _ref = /*#__PURE__*/React.createElement("circle", {
64 cx: "12",
65 cy: "12",
66 r: "12"
67});
68
69var StepIcon = /*#__PURE__*/React.forwardRef(function StepIcon(props, ref) {
70 var _props$completed = props.completed,
71 completed = _props$completed === void 0 ? false : _props$completed,
72 icon = props.icon,
73 _props$active = props.active,
74 active = _props$active === void 0 ? false : _props$active,
75 _props$error = props.error,
76 error = _props$error === void 0 ? false : _props$error,
77 classes = props.classes;
78
79 if (typeof icon === 'number' || typeof icon === 'string') {
80 var className = (0, _clsx.default)(classes.root, active && classes.active, error && classes.error, completed && classes.completed);
81
82 if (error) {
83 return /*#__PURE__*/React.createElement(_Warning.default, {
84 className: className,
85 ref: ref
86 });
87 }
88
89 if (completed) {
90 return /*#__PURE__*/React.createElement(_CheckCircle.default, {
91 className: className,
92 ref: ref
93 });
94 }
95
96 return /*#__PURE__*/React.createElement(_SvgIcon.default, {
97 className: className,
98 ref: ref
99 }, _ref, /*#__PURE__*/React.createElement("text", {
100 className: classes.text,
101 x: "12",
102 y: "16",
103 textAnchor: "middle"
104 }, icon));
105 }
106
107 return icon;
108});
109process.env.NODE_ENV !== "production" ? StepIcon.propTypes = {
110 // ----------------------------- Warning --------------------------------
111 // | These PropTypes are generated from the TypeScript type definitions |
112 // | To update them edit the d.ts file and run "yarn proptypes" |
113 // ----------------------------------------------------------------------
114
115 /**
116 * Whether this step is active.
117 */
118 active: _propTypes.default.bool,
119
120 /**
121 * Override or extend the styles applied to the component.
122 * See [CSS API](#css) below for more details.
123 */
124 classes: _propTypes.default.object,
125
126 /**
127 * Mark the step as completed. Is passed to child components.
128 */
129 completed: _propTypes.default.bool,
130
131 /**
132 * Mark the step as failed.
133 */
134 error: _propTypes.default.bool,
135
136 /**
137 * The label displayed in the step icon.
138 */
139 icon: _propTypes.default.node
140} : void 0;
141
142var _default = (0, _withStyles.default)(styles, {
143 name: 'MuiStepIcon'
144})(StepIcon);
145
146exports.default = _default;
\No newline at end of file