UNPKG

7.01 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _clsx = _interopRequireDefault(require("clsx"));
21
22var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
23
24var _Typography = _interopRequireDefault(require("../Typography"));
25
26var _StepIcon = _interopRequireDefault(require("../StepIcon"));
27
28var styles = function styles(theme) {
29 return {
30 /* Styles applied to the root element. */
31 root: {
32 display: 'flex',
33 alignItems: 'center',
34 '&$alternativeLabel': {
35 flexDirection: 'column'
36 },
37 '&$disabled': {
38 cursor: 'default'
39 }
40 },
41
42 /* Styles applied to the root element if `orientation="horizontal"`. */
43 horizontal: {},
44
45 /* Styles applied to the root element if `orientation="vertical"`. */
46 vertical: {},
47
48 /* Styles applied to the `Typography` component which wraps `children`. */
49 label: {
50 color: theme.palette.text.secondary,
51 '&$active': {
52 color: theme.palette.text.primary,
53 fontWeight: 500
54 },
55 '&$completed': {
56 color: theme.palette.text.primary,
57 fontWeight: 500
58 },
59 '&$alternativeLabel': {
60 textAlign: 'center',
61 marginTop: 16
62 },
63 '&$error': {
64 color: theme.palette.error.main
65 }
66 },
67
68 /* Pseudo-class applied to the `Typography` component if `active={true}`. */
69 active: {},
70
71 /* Pseudo-class applied to the `Typography` component if `completed={true}`. */
72 completed: {},
73
74 /* Pseudo-class applied to the root element and `Typography` component if `error={true}`. */
75 error: {},
76
77 /* Pseudo-class applied to the root element and `Typography` component if `disabled={true}`. */
78 disabled: {},
79
80 /* Styles applied to the `icon` container element. */
81 iconContainer: {
82 flexShrink: 0,
83 // Fix IE 11 issue
84 display: 'flex',
85 paddingRight: 8,
86 '&$alternativeLabel': {
87 paddingRight: 0
88 }
89 },
90
91 /* Pseudo-class applied to the root and icon container and `Typography` if `alternativeLabel={true}`. */
92 alternativeLabel: {},
93
94 /* Styles applied to the container element which wraps `Typography` and `optional`. */
95 labelContainer: {
96 width: '100%'
97 }
98 };
99};
100
101exports.styles = styles;
102var StepLabel = /*#__PURE__*/React.forwardRef(function StepLabel(props, ref) {
103 var _props$active = props.active,
104 active = _props$active === void 0 ? false : _props$active,
105 _props$alternativeLab = props.alternativeLabel,
106 alternativeLabel = _props$alternativeLab === void 0 ? false : _props$alternativeLab,
107 children = props.children,
108 classes = props.classes,
109 className = props.className,
110 _props$completed = props.completed,
111 completed = _props$completed === void 0 ? false : _props$completed,
112 _props$disabled = props.disabled,
113 disabled = _props$disabled === void 0 ? false : _props$disabled,
114 _props$error = props.error,
115 error = _props$error === void 0 ? false : _props$error,
116 expanded = props.expanded,
117 icon = props.icon,
118 last = props.last,
119 optional = props.optional,
120 _props$orientation = props.orientation,
121 orientation = _props$orientation === void 0 ? 'horizontal' : _props$orientation,
122 StepIconComponentProp = props.StepIconComponent,
123 StepIconProps = props.StepIconProps,
124 other = (0, _objectWithoutProperties2.default)(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "disabled", "error", "expanded", "icon", "last", "optional", "orientation", "StepIconComponent", "StepIconProps"]);
125 var StepIconComponent = StepIconComponentProp;
126
127 if (icon && !StepIconComponent) {
128 StepIconComponent = _StepIcon.default;
129 }
130
131 return /*#__PURE__*/React.createElement("span", (0, _extends2.default)({
132 className: (0, _clsx.default)(classes.root, classes[orientation], className, disabled && classes.disabled, alternativeLabel && classes.alternativeLabel, error && classes.error),
133 ref: ref
134 }, other), icon || StepIconComponent ? /*#__PURE__*/React.createElement("span", {
135 className: (0, _clsx.default)(classes.iconContainer, alternativeLabel && classes.alternativeLabel)
136 }, /*#__PURE__*/React.createElement(StepIconComponent, (0, _extends2.default)({
137 completed: completed,
138 active: active,
139 error: error,
140 icon: icon
141 }, StepIconProps))) : null, /*#__PURE__*/React.createElement("span", {
142 className: classes.labelContainer
143 }, children ? /*#__PURE__*/React.createElement(_Typography.default, {
144 variant: "body2",
145 component: "span",
146 display: "block",
147 className: (0, _clsx.default)(classes.label, alternativeLabel && classes.alternativeLabel, completed && classes.completed, active && classes.active, error && classes.error)
148 }, children) : null, optional));
149});
150process.env.NODE_ENV !== "production" ? StepLabel.propTypes = {
151 // ----------------------------- Warning --------------------------------
152 // | These PropTypes are generated from the TypeScript type definitions |
153 // | To update them edit the d.ts file and run "yarn proptypes" |
154 // ----------------------------------------------------------------------
155
156 /**
157 * In most cases will simply be a string containing a title for the label.
158 */
159 children: _propTypes.default.node,
160
161 /**
162 * Override or extend the styles applied to the component.
163 * See [CSS API](#css) below for more details.
164 */
165 classes: _propTypes.default.object,
166
167 /**
168 * @ignore
169 */
170 className: _propTypes.default.string,
171
172 /**
173 * Mark the step as disabled, will also disable the button if
174 * `StepLabelButton` is a child of `StepLabel`. Is passed to child components.
175 */
176 disabled: _propTypes.default.bool,
177
178 /**
179 * Mark the step as failed.
180 */
181 error: _propTypes.default.bool,
182
183 /**
184 * Override the default label of the step icon.
185 */
186 icon: _propTypes.default.node,
187
188 /**
189 * The optional node to display.
190 */
191 optional: _propTypes.default.node,
192
193 /**
194 * The component to render in place of the [`StepIcon`](/api/step-icon/).
195 */
196 StepIconComponent: _propTypes.default.elementType,
197
198 /**
199 * Props applied to the [`StepIcon`](/api/step-icon/) element.
200 */
201 StepIconProps: _propTypes.default.object
202} : void 0;
203StepLabel.muiName = 'StepLabel';
204
205var _default = (0, _withStyles.default)(styles, {
206 name: 'MuiStepLabel'
207})(StepLabel);
208
209exports.default = _default;
\No newline at end of file