@material-ui/core
Version:
React components that implement Google's Material Design.
233 lines (190 loc) • 7.24 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.styles = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
var _Typography = _interopRequireDefault(require("../Typography"));
var _StepIcon = _interopRequireDefault(require("../StepIcon"));
var styles = function styles(theme) {
return {
/* Styles applied to the root element. */
root: {
display: 'flex',
alignItems: 'center',
'&$alternativeLabel': {
flexDirection: 'column'
},
'&$disabled': {
cursor: 'default'
}
},
/* Styles applied to the root element if `orientation="horiizontal". */
horizontal: {},
/* Styles applied to the root element if `orientation="vertical". */
vertical: {},
/* Styles applied to the `Typography` component which wraps `children`. */
label: {
color: theme.palette.text.secondary,
'&$active': {
color: theme.palette.text.primary,
fontWeight: 500
},
'&$completed': {
color: theme.palette.text.primary,
fontWeight: 500
},
'&$alternativeLabel': {
textAlign: 'center',
marginTop: 16
},
'&$error': {
color: theme.palette.error.main
}
},
/* Styles applied to the `Typography` component if `active={true}`. */
active: {},
/* Styles applied to the `Typography` component if `completed={true}`. */
completed: {},
/* Styles applied to the root element and `Typography` component if `error={true}`. */
error: {},
/* Styles applied to the root element and `Typography` component if `disabled={true}`. */
disabled: {},
/* Styles applied to the `icon` container element. */
iconContainer: {
display: 'flex',
paddingRight: 8,
'&$alternativeLabel': {
paddingRight: 0
}
},
/* Styles applied to the root & icon container and `Typography` if `alternativeLabel={true}`. */
alternativeLabel: {},
/* Styles applied to the container element which wraps `Typography` and `optional`. */
labelContainer: {
width: '100%'
}
};
};
exports.styles = styles;
function StepLabel(props) {
var _classNames, _classNames3;
var active = props.active,
alternativeLabel = props.alternativeLabel,
children = props.children,
classes = props.classes,
classNameProp = props.className,
completed = props.completed,
disabled = props.disabled,
error = props.error,
icon = props.icon,
last = props.last,
optional = props.optional,
orientation = props.orientation,
StepIconComponentProp = props.StepIconComponent,
StepIconProps = props.StepIconProps,
other = (0, _objectWithoutProperties2.default)(props, ["active", "alternativeLabel", "children", "classes", "className", "completed", "disabled", "error", "icon", "last", "optional", "orientation", "StepIconComponent", "StepIconProps"]);
var StepIconComponent = StepIconComponentProp;
if (icon && !StepIconComponent) {
StepIconComponent = _StepIcon.default;
}
return _react.default.createElement("span", (0, _extends2.default)({
className: (0, _classnames.default)(classes.root, classes[orientation], (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.disabled, disabled), (0, _defineProperty2.default)(_classNames, classes.alternativeLabel, alternativeLabel), (0, _defineProperty2.default)(_classNames, classes.error, error), _classNames), classNameProp)
}, other), icon || StepIconComponent ? _react.default.createElement("span", {
className: (0, _classnames.default)(classes.iconContainer, (0, _defineProperty2.default)({}, classes.alternativeLabel, alternativeLabel))
}, _react.default.createElement(StepIconComponent, (0, _extends2.default)({
completed: completed,
active: active,
error: error,
icon: icon
}, StepIconProps))) : null, _react.default.createElement("span", {
className: classes.labelContainer
}, _react.default.createElement(_Typography.default, {
component: "span",
className: (0, _classnames.default)(classes.label, (_classNames3 = {}, (0, _defineProperty2.default)(_classNames3, classes.alternativeLabel, alternativeLabel), (0, _defineProperty2.default)(_classNames3, classes.completed, completed), (0, _defineProperty2.default)(_classNames3, classes.active, active), (0, _defineProperty2.default)(_classNames3, classes.error, error), _classNames3))
}, children), optional));
}
StepLabel.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* @ignore
* Sets the step as active. Is passed to child components.
*/
active: _propTypes.default.bool,
/**
* @ignore
* Set internally by Stepper when it's supplied with the alternativeLabel property.
*/
alternativeLabel: _propTypes.default.bool,
/**
* In most cases will simply be a string containing a title for the label.
*/
children: _propTypes.default.node,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css-api) below for more details.
*/
classes: _propTypes.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes.default.string,
/**
* @ignore
* Mark the step as completed. Is passed to child components.
*/
completed: _propTypes.default.bool,
/**
* Mark the step as disabled, will also disable the button if
* `StepLabelButton` is a child of `StepLabel`. Is passed to child components.
*/
disabled: _propTypes.default.bool,
/**
* Mark the step as failed.
*/
error: _propTypes.default.bool,
/**
* Override the default icon.
*/
icon: _propTypes.default.node,
/**
* @ignore
*/
last: _propTypes.default.bool,
/**
* The optional node to display.
*/
optional: _propTypes.default.node,
/**
* @ignore
*/
orientation: _propTypes.default.oneOf(['horizontal', 'vertical']),
/**
* The component to render in place of the [`StepIcon`](/api/step-icon/).
*/
StepIconComponent: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func, _propTypes.default.object]),
/**
* Properties applied to the [`StepIcon`](/api/step-icon/) element.
*/
StepIconProps: _propTypes.default.object
} : {};
StepLabel.defaultProps = {
active: false,
alternativeLabel: false,
completed: false,
disabled: false,
error: false,
last: false,
orientation: 'horizontal'
};
StepLabel.muiName = 'StepLabel';
var _default = (0, _withStyles.default)(styles, {
name: 'MuiStepLabel'
})(StepLabel);
exports.default = _default;