You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
6.1 KiB
133 lines
6.1 KiB
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
|
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
/* eslint react/no-did-mount-set-state: 0, react/prop-types: 0 */
|
|
import React, { cloneElement } from 'react';
|
|
import toArray from "rc-util/es/Children/toArray";
|
|
import classNames from 'classnames';
|
|
import Step from './Step';
|
|
|
|
var Steps = /*#__PURE__*/function (_React$Component) {
|
|
_inherits(Steps, _React$Component);
|
|
|
|
var _super = _createSuper(Steps);
|
|
|
|
function Steps() {
|
|
var _this;
|
|
|
|
_classCallCheck(this, Steps);
|
|
|
|
_this = _super.apply(this, arguments);
|
|
|
|
_this.onStepClick = function (next) {
|
|
var _this$props = _this.props,
|
|
onChange = _this$props.onChange,
|
|
current = _this$props.current;
|
|
|
|
if (onChange && current !== next) {
|
|
onChange(next);
|
|
}
|
|
};
|
|
|
|
return _this;
|
|
}
|
|
|
|
_createClass(Steps, [{
|
|
key: "render",
|
|
value: function render() {
|
|
var _classNames,
|
|
_this2 = this;
|
|
|
|
var _this$props2 = this.props,
|
|
prefixCls = _this$props2.prefixCls,
|
|
_this$props2$style = _this$props2.style,
|
|
style = _this$props2$style === void 0 ? {} : _this$props2$style,
|
|
className = _this$props2.className,
|
|
children = _this$props2.children,
|
|
direction = _this$props2.direction,
|
|
type = _this$props2.type,
|
|
labelPlacement = _this$props2.labelPlacement,
|
|
iconPrefix = _this$props2.iconPrefix,
|
|
status = _this$props2.status,
|
|
size = _this$props2.size,
|
|
current = _this$props2.current,
|
|
progressDot = _this$props2.progressDot,
|
|
stepIcon = _this$props2.stepIcon,
|
|
initial = _this$props2.initial,
|
|
icons = _this$props2.icons,
|
|
onChange = _this$props2.onChange,
|
|
restProps = _objectWithoutProperties(_this$props2, ["prefixCls", "style", "className", "children", "direction", "type", "labelPlacement", "iconPrefix", "status", "size", "current", "progressDot", "stepIcon", "initial", "icons", "onChange"]);
|
|
|
|
var isNav = type === 'navigation';
|
|
var adjustedLabelPlacement = progressDot ? 'vertical' : labelPlacement;
|
|
var classString = classNames(prefixCls, "".concat(prefixCls, "-").concat(direction), className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(size), size), _defineProperty(_classNames, "".concat(prefixCls, "-label-").concat(adjustedLabelPlacement), direction === 'horizontal'), _defineProperty(_classNames, "".concat(prefixCls, "-dot"), !!progressDot), _defineProperty(_classNames, "".concat(prefixCls, "-navigation"), isNav), _classNames));
|
|
return React.createElement("div", Object.assign({
|
|
className: classString,
|
|
style: style
|
|
}, restProps), toArray(children).map(function (child, index) {
|
|
var stepNumber = initial + index;
|
|
|
|
var childProps = _objectSpread({
|
|
stepNumber: "".concat(stepNumber + 1),
|
|
stepIndex: stepNumber,
|
|
key: stepNumber,
|
|
prefixCls: prefixCls,
|
|
iconPrefix: iconPrefix,
|
|
wrapperStyle: style,
|
|
progressDot: progressDot,
|
|
stepIcon: stepIcon,
|
|
icons: icons,
|
|
onStepClick: onChange && _this2.onStepClick
|
|
}, child.props); // fix tail color
|
|
|
|
|
|
if (status === 'error' && index === current - 1) {
|
|
childProps.className = "".concat(prefixCls, "-next-error");
|
|
}
|
|
|
|
if (!child.props.status) {
|
|
if (stepNumber === current) {
|
|
childProps.status = status;
|
|
} else if (stepNumber < current) {
|
|
childProps.status = 'finish';
|
|
} else {
|
|
childProps.status = 'wait';
|
|
}
|
|
}
|
|
|
|
childProps.active = stepNumber === current;
|
|
return cloneElement(child, childProps);
|
|
}));
|
|
}
|
|
}]);
|
|
|
|
return Steps;
|
|
}(React.Component);
|
|
|
|
export { Steps as default };
|
|
Steps.Step = Step;
|
|
Steps.defaultProps = {
|
|
type: 'default',
|
|
prefixCls: 'rc-steps',
|
|
iconPrefix: 'rc',
|
|
direction: 'horizontal',
|
|
labelPlacement: 'horizontal',
|
|
initial: 0,
|
|
current: 0,
|
|
status: 'process',
|
|
size: '',
|
|
progressDot: false
|
|
}; |