@ucloud-fe/react-components 1.11.1 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,7 +31,7 @@ var _StepIcon = _interopRequireDefault(require("./StepIcon"));
31
31
 
32
32
  var _style = require("./style");
33
33
 
34
- var _excluded = ["status", "step", "remark", "title"];
34
+ var _excluded = ["status", "step", "remark", "title", "isLast", "showTitle"];
35
35
 
36
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
37
 
@@ -59,13 +59,21 @@ var Step = /*#__PURE__*/function (_PureComponent) {
59
59
  step = _this$props.step,
60
60
  remark = _this$props.remark,
61
61
  title = _this$props.title,
62
+ isLast = _this$props.isLast,
63
+ showTitle = _this$props.showTitle,
62
64
  rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
63
65
  return /*#__PURE__*/_react.default.createElement(_style.StepWrapper, (0, _extends2.default)({
64
- status: status
65
- }, rest), /*#__PURE__*/_react.default.createElement(_StepIcon.default, {
66
+ status: status,
67
+ isLast: isLast,
68
+ showTitle: showTitle
69
+ }, rest, {
70
+ className: "".concat(_style.stepWrapperCls, " ").concat(rest.className ? rest.className : '')
71
+ }), /*#__PURE__*/_react.default.createElement("div", {
72
+ className: _style.itemTailCls
73
+ }), /*#__PURE__*/_react.default.createElement(_StepIcon.default, {
66
74
  status: status,
67
75
  step: step || 0
68
- }), (title || remark) && /*#__PURE__*/_react.default.createElement(_style.ContentWrapper, null, /*#__PURE__*/_react.default.createElement(_style.TitleWrapper, null, title), remark && /*#__PURE__*/_react.default.createElement(_style.RemarkWrapper, null, remark)));
76
+ }), /*#__PURE__*/_react.default.createElement(_style.ContentWrapper, null, /*#__PURE__*/_react.default.createElement(_style.TitleWrapper, null, title), remark && /*#__PURE__*/_react.default.createElement(_style.RemarkWrapper, null, remark)));
69
77
  }
70
78
  }]);
71
79
  return Step;
@@ -76,5 +84,8 @@ Step.propTypes = {
76
84
  status: _propTypes.default.string,
77
85
  step: _propTypes.default.node,
78
86
  remark: _propTypes.default.node,
79
- title: _propTypes.default.node
87
+ title: _propTypes.default.node,
88
+ isLast: _propTypes.default.bool,
89
+ disabled: _propTypes.default.bool,
90
+ showTitle: _propTypes.default.bool
80
91
  };
@@ -99,7 +99,9 @@ var StepIcon = /*#__PURE__*/function (_PureComponent) {
99
99
  rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
100
100
  return /*#__PURE__*/_react.default.createElement(_style.IconWrapper, (0, _extends2.default)({
101
101
  status: status
102
- }, rest), this.renderContent(status, step));
102
+ }, rest, {
103
+ className: "".concat(_style.iconCls, " ").concat(rest.className ? rest.className : '')
104
+ }), this.renderContent(status, step));
103
105
  }
104
106
  }]);
105
107
  return StepIcon;
@@ -33,10 +33,8 @@ var _style = require("./style");
33
33
 
34
34
  var _Step = _interopRequireDefault(require("./Step"));
35
35
 
36
- var _Link = _interopRequireDefault(require("./Link"));
37
-
38
- var _excluded = ["key", "step"],
39
- _excluded2 = ["steps", "current", "status"];
36
+ var _excluded = ["key", "step", "status"],
37
+ _excluded2 = ["steps", "current", "status", "onChange", "direction", "nowrap"];
40
38
 
41
39
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
42
40
 
@@ -66,18 +64,27 @@ var Steps = /*#__PURE__*/function (_Component) {
66
64
 
67
65
  _this = _super.call.apply(_super, [this].concat(args));
68
66
 
69
- _this.renderSteps = function (steps, current, status) {
67
+ _this.renderSteps = function (_ref) {
70
68
  var _this3 = this;
71
69
 
72
70
  (0, _newArrowCheck2.default)(this, _this2);
71
+ var steps = _ref.steps,
72
+ current = _ref.current,
73
+ status = _ref.status,
74
+ direction = _ref.direction,
75
+ onChange = _ref.onChange,
76
+ nowrap = _ref.nowrap;
73
77
  var pos = 'before';
74
78
  var l = steps.length;
75
79
  return steps.map(function (step, i) {
80
+ var _this4 = this;
81
+
76
82
  (0, _newArrowCheck2.default)(this, _this3);
77
83
  var _step$key = step.key,
78
84
  key = _step$key === void 0 ? i : _step$key,
79
85
  _step$step = step.step,
80
86
  stepContent = _step$step === void 0 ? i + 1 : _step$step,
87
+ singleStatus = step.status,
81
88
  rest = (0, _objectWithoutProperties2.default)(step, _excluded);
82
89
  var isCurrent = current === key;
83
90
  var finalStatus;
@@ -86,17 +93,48 @@ var Steps = /*#__PURE__*/function (_Component) {
86
93
  pos = 'after';
87
94
  finalStatus = status;
88
95
  } else {
96
+ switch (singleStatus) {
97
+ case 'error':
98
+ pos = 'error';
99
+ break;
100
+
101
+ case 'success':
102
+ pos = 'before';
103
+ break;
104
+
105
+ case 'normal':
106
+ pos = 'after';
107
+ break;
108
+
109
+ default:
110
+ }
111
+
89
112
  finalStatus = pos;
90
113
  }
91
114
 
92
- return [/*#__PURE__*/_react.default.createElement(_Step.default, (0, _extends2.default)({}, rest, {
115
+ var canHover = typeof onChange === 'function' && singleStatus !== 'disabled' ? true : false;
116
+ var showTitle = rest.title ? true : false;
117
+ return /*#__PURE__*/_react.default.createElement(_style.StepsItemWrapper, {
93
118
  key: key,
119
+ direction: direction,
94
120
  status: finalStatus,
95
- step: stepContent
96
- })), i < l - 1 && /*#__PURE__*/_react.default.createElement(_Link.default, {
97
- key: "link-".concat(key),
98
- status: pos
99
- })];
121
+ canHover: canHover,
122
+ showTitle: showTitle,
123
+ nowrap: nowrap,
124
+ onClick: function () {
125
+ (0, _newArrowCheck2.default)(this, _this4);
126
+
127
+ if (canHover) {
128
+ onChange(key, finalStatus);
129
+ }
130
+ }.bind(this)
131
+ }, /*#__PURE__*/_react.default.createElement(_Step.default, (0, _extends2.default)({}, rest, {
132
+ key: "step-".concat(key),
133
+ status: finalStatus,
134
+ step: stepContent,
135
+ showTitle: showTitle,
136
+ isLast: i === l - 1 ? true : false
137
+ })));
100
138
  }.bind(this));
101
139
  }.bind(this);
102
140
 
@@ -110,8 +148,21 @@ var Steps = /*#__PURE__*/function (_Component) {
110
148
  steps = _this$props.steps,
111
149
  current = _this$props.current,
112
150
  status = _this$props.status,
151
+ onChange = _this$props.onChange,
152
+ direction = _this$props.direction,
153
+ nowrap = _this$props.nowrap,
113
154
  rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded2);
114
- return /*#__PURE__*/_react.default.createElement(_style.StepsWrapper, rest, this.renderSteps(steps, current, status));
155
+ return /*#__PURE__*/_react.default.createElement(_style.StepsWrapper, (0, _extends2.default)({
156
+ direction: direction,
157
+ nowrap: nowrap
158
+ }, rest), this.renderSteps({
159
+ steps: steps,
160
+ current: current,
161
+ status: status,
162
+ direction: direction,
163
+ onChange: onChange,
164
+ nowrap: nowrap
165
+ }));
115
166
  }
116
167
  }]);
117
168
  return Steps;
@@ -130,17 +181,38 @@ Steps.propTypes = {
130
181
  title: _propTypes.default.node,
131
182
 
132
183
  /** 步骤的备注 */
133
- remark: _propTypes.default.node
184
+ remark: _propTypes.default.node,
185
+
186
+ /** 步骤的状态 */
187
+ status: _propTypes.default.oneOf(['disabled', 'error', 'success', 'normal'])
134
188
  })).isRequired,
135
189
 
136
190
  /** 当前步骤的 key,不传或传 null 时为全部完成 */
137
191
  current: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
138
192
 
139
193
  /** 当前步骤的状态 */
140
- status: _propTypes.default.oneOf(Status)
194
+ status: _propTypes.default.oneOf(Status),
195
+
196
+ /**
197
+ * 步骤状态改变时的回调函数
198
+ * @param {number} current 当前步骤的key
199
+ */
200
+ onChange: _propTypes.default.func,
201
+
202
+ /**
203
+ * 指定步骤条方向 , 默认是horizontal
204
+ */
205
+ direction: _propTypes.default.oneOf(['horizontal', 'vertical']),
206
+
207
+ /**
208
+ * 横向场景,不换行, 默认是false
209
+ */
210
+ nowrap: _propTypes.default.bool
141
211
  };
142
212
  Steps.defaultProps = {
143
- status: 'current'
213
+ status: 'current',
214
+ direction: 'horizontal',
215
+ nowrap: false
144
216
  };
145
217
  var _default = Steps;
146
218
  exports.default = _default;