@uiw/react-steps
Version:
Steps component
89 lines (88 loc) • 3.98 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = Step;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _reactIcon = _interopRequireDefault(require("@uiw/react-icon"));
var _jsxRuntime = require("react/jsx-runtime");
var _excluded = ["prefixCls", "className", "style", "status", "itemWidth", "icon", "adjustMarginRight", "stepNumber", "title", "description", "progressDot"];
function Step(props) {
var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'w-steps' : _props$prefixCls,
className = props.className,
style = props.style,
status = props.status,
itemWidth = props.itemWidth,
icon = props.icon,
adjustMarginRight = props.adjustMarginRight,
stepNumber = props.stepNumber,
title = props.title,
description = props.description,
progressDot = props.progressDot,
restProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
var classString = ["".concat(prefixCls, "-item"), "".concat(prefixCls, "-item-").concat(status), className, icon ? "".concat(prefixCls, "-custom") : null].filter(Boolean).join(' ').trim();
var stepItemStyle = (0, _objectSpread2["default"])({}, style);
var stepItemDotStyle = {};
if (itemWidth) {
stepItemStyle.width = itemWidth;
}
if (adjustMarginRight) {
stepItemStyle.marginRight = adjustMarginRight;
if (progressDot) {
stepItemDotStyle.paddingRight = Math.abs(adjustMarginRight);
}
}
var iconNode = null;
if (progressDot && !icon) {
iconNode = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
className: "".concat(prefixCls, "-dot")
});
} else if (icon && typeof icon !== 'string') {
iconNode = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
className: "".concat(prefixCls, "-icon"),
children: icon
});
} else if (icon && typeof icon === 'string' || status === 'finish' || status === 'error') {
iconNode = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIcon["default"], {
type: [icon && typeof icon === 'string' ? "".concat(icon) : null, !icon && status === 'finish' ? 'check' : null, !icon && status === 'error' ? 'close' : null].filter(Boolean).join(' ').trim()
});
} else {
iconNode = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
className: "".concat(prefixCls, "-icon"),
children: stepNumber
});
}
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, restProps), {}, {
className: classString,
style: stepItemStyle,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: "".concat(prefixCls, "-item-tail"),
style: stepItemDotStyle,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
style: {
paddingRight: '100%'
}
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: "".concat(prefixCls, "-item-head"),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: ["".concat(prefixCls, "-item-inner"), !!icon && 'is-icon'].filter(Boolean).join(' ').trim(),
children: iconNode
})
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
className: ["".concat(prefixCls, "-item-main"), !!icon && 'is-icon-main'].filter(Boolean).join(' ').trim(),
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: "".concat(prefixCls, "-item-title"),
children: title
}), description && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: "".concat(prefixCls, "-item-description"),
children: description
})]
})]
}));
}
module.exports = exports.default;