Comparing version 3.3.1 to 3.4.0
@@ -18,5 +18,11 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
function Step() { | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, Step); | ||
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _initialiseProps.call(_this), _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
@@ -107,3 +113,6 @@ | ||
icons = _props2.icons, | ||
restProps = _objectWithoutProperties(_props2, ['className', 'prefixCls', 'style', 'itemWidth', 'status', 'iconPrefix', 'icon', 'wrapperStyle', 'adjustMarginRight', 'stepNumber', 'description', 'title', 'progressDot', 'tailContent', 'icons']); | ||
stepIndex = _props2.stepIndex, | ||
onStepClick = _props2.onStepClick, | ||
onClick = _props2.onClick, | ||
restProps = _objectWithoutProperties(_props2, ['className', 'prefixCls', 'style', 'itemWidth', 'status', 'iconPrefix', 'icon', 'wrapperStyle', 'adjustMarginRight', 'stepNumber', 'description', 'title', 'progressDot', 'tailContent', 'icons', 'stepIndex', 'onStepClick', 'onClick']); | ||
@@ -118,5 +127,15 @@ var classString = classNames(prefixCls + '-item', prefixCls + '-item-' + status, className, (_classNames2 = {}, _classNames2[prefixCls + '-item-custom'] = icon, _classNames2)); | ||
} | ||
var accessibilityProps = {}; | ||
if (onStepClick) { | ||
accessibilityProps.role = 'button'; | ||
accessibilityProps.tabIndex = 0; | ||
accessibilityProps.onClick = this.onClick; | ||
} | ||
return React.createElement( | ||
'div', | ||
_extends({}, restProps, { | ||
_extends({ | ||
onClick: onClick | ||
}, accessibilityProps, restProps, { | ||
className: classString, | ||
@@ -166,2 +185,3 @@ style: stepItemStyle | ||
stepNumber: PropTypes.string, | ||
stepIndex: PropTypes.number, | ||
description: PropTypes.any, | ||
@@ -174,4 +194,25 @@ title: PropTypes.any, | ||
error: PropTypes.node | ||
}) | ||
}), | ||
onClick: PropTypes.func, | ||
onStepClick: PropTypes.func | ||
}; | ||
var _initialiseProps = function _initialiseProps() { | ||
var _this2 = this; | ||
this.onClick = function () { | ||
var _props3 = _this2.props, | ||
onClick = _props3.onClick, | ||
onStepClick = _props3.onStepClick, | ||
stepIndex = _props3.stepIndex; | ||
if (onClick) { | ||
onClick.apply(undefined, arguments); | ||
} | ||
onStepClick(stepIndex); | ||
}; | ||
}; | ||
export default Step; |
@@ -22,2 +22,10 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
_this.onStepClick = function (current) { | ||
var onChange = _this.props.onChange; | ||
if (onChange) { | ||
onChange(current); | ||
} | ||
}; | ||
_this.calcStepOffsetWidth = function () { | ||
@@ -76,3 +84,4 @@ if (isFlexSupported()) { | ||
Steps.prototype.render = function render() { | ||
var _classNames; | ||
var _classNames, | ||
_this2 = this; | ||
@@ -94,3 +103,4 @@ var _props = this.props, | ||
icons = _props.icons, | ||
restProps = _objectWithoutProperties(_props, ['prefixCls', 'style', 'className', 'children', 'direction', 'labelPlacement', 'iconPrefix', 'status', 'size', 'current', 'progressDot', 'initial', 'icons']); | ||
onChange = _props.onChange, | ||
restProps = _objectWithoutProperties(_props, ['prefixCls', 'style', 'className', 'children', 'direction', 'labelPlacement', 'iconPrefix', 'status', 'size', 'current', 'progressDot', 'initial', 'icons', 'onChange']); | ||
@@ -118,2 +128,3 @@ var _state = this.state, | ||
stepNumber: '' + (stepNumber + 1), | ||
stepIndex: stepNumber, | ||
prefixCls: prefixCls, | ||
@@ -123,3 +134,4 @@ iconPrefix: iconPrefix, | ||
progressDot: progressDot, | ||
icons: icons | ||
icons: icons, | ||
onStepClick: onChange && _this2.onStepClick | ||
}, child.props); | ||
@@ -167,3 +179,4 @@ if (!flexSupported && direction !== 'vertical' && index !== lastIndex) { | ||
error: PropTypes.node | ||
}) | ||
}), | ||
onChange: PropTypes.func | ||
}; | ||
@@ -170,0 +183,0 @@ Steps.defaultProps = { |
# History | ||
---- | ||
## 3.230 | ||
## 3.4.0 | ||
- Support `onChange` event. | ||
## 3.3.0 | ||
- Add `icons` prop for change preset icon. | ||
@@ -7,0 +11,0 @@ |
@@ -47,4 +47,11 @@ 'use strict'; | ||
function Step() { | ||
var _temp, _this, _ret; | ||
(0, _classCallCheck3['default'])(this, Step); | ||
return (0, _possibleConstructorReturn3['default'])(this, _React$Component.apply(this, arguments)); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3['default'])(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _initialiseProps.call(_this), _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret); | ||
} | ||
@@ -135,3 +142,6 @@ | ||
icons = _props2.icons, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props2, ['className', 'prefixCls', 'style', 'itemWidth', 'status', 'iconPrefix', 'icon', 'wrapperStyle', 'adjustMarginRight', 'stepNumber', 'description', 'title', 'progressDot', 'tailContent', 'icons']); | ||
stepIndex = _props2.stepIndex, | ||
onStepClick = _props2.onStepClick, | ||
onClick = _props2.onClick, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props2, ['className', 'prefixCls', 'style', 'itemWidth', 'status', 'iconPrefix', 'icon', 'wrapperStyle', 'adjustMarginRight', 'stepNumber', 'description', 'title', 'progressDot', 'tailContent', 'icons', 'stepIndex', 'onStepClick', 'onClick']); | ||
@@ -147,5 +157,15 @@ | ||
} | ||
var accessibilityProps = {}; | ||
if (onStepClick) { | ||
accessibilityProps.role = 'button'; | ||
accessibilityProps.tabIndex = 0; | ||
accessibilityProps.onClick = this.onClick; | ||
} | ||
return _react2['default'].createElement( | ||
'div', | ||
(0, _extends3['default'])({}, restProps, { | ||
(0, _extends3['default'])({ | ||
onClick: onClick | ||
}, accessibilityProps, restProps, { | ||
className: classString, | ||
@@ -195,2 +215,3 @@ style: stepItemStyle | ||
stepNumber: _propTypes2['default'].string, | ||
stepIndex: _propTypes2['default'].number, | ||
description: _propTypes2['default'].any, | ||
@@ -203,5 +224,26 @@ title: _propTypes2['default'].any, | ||
error: _propTypes2['default'].node | ||
}) | ||
}), | ||
onClick: _propTypes2['default'].func, | ||
onStepClick: _propTypes2['default'].func | ||
}; | ||
var _initialiseProps = function _initialiseProps() { | ||
var _this2 = this; | ||
this.onClick = function () { | ||
var _props3 = _this2.props, | ||
onClick = _props3.onClick, | ||
onStepClick = _props3.onStepClick, | ||
stepIndex = _props3.stepIndex; | ||
if (onClick) { | ||
onClick.apply(undefined, arguments); | ||
} | ||
onStepClick(stepIndex); | ||
}; | ||
}; | ||
exports['default'] = Step; | ||
module.exports = exports['default']; |
@@ -56,2 +56,10 @@ 'use strict'; | ||
_this.onStepClick = function (current) { | ||
var onChange = _this.props.onChange; | ||
if (onChange) { | ||
onChange(current); | ||
} | ||
}; | ||
_this.calcStepOffsetWidth = function () { | ||
@@ -110,3 +118,4 @@ if ((0, _utils.isFlexSupported)()) { | ||
Steps.prototype.render = function render() { | ||
var _classNames; | ||
var _classNames, | ||
_this2 = this; | ||
@@ -128,3 +137,4 @@ var _props = this.props, | ||
icons = _props.icons, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props, ['prefixCls', 'style', 'className', 'children', 'direction', 'labelPlacement', 'iconPrefix', 'status', 'size', 'current', 'progressDot', 'initial', 'icons']); | ||
onChange = _props.onChange, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props, ['prefixCls', 'style', 'className', 'children', 'direction', 'labelPlacement', 'iconPrefix', 'status', 'size', 'current', 'progressDot', 'initial', 'icons', 'onChange']); | ||
var _state = this.state, | ||
@@ -151,2 +161,3 @@ lastStepOffsetWidth = _state.lastStepOffsetWidth, | ||
stepNumber: '' + (stepNumber + 1), | ||
stepIndex: stepNumber, | ||
prefixCls: prefixCls, | ||
@@ -156,3 +167,4 @@ iconPrefix: iconPrefix, | ||
progressDot: progressDot, | ||
icons: icons | ||
icons: icons, | ||
onStepClick: onChange && _this2.onStepClick | ||
}, child.props); | ||
@@ -200,3 +212,4 @@ if (!flexSupported && direction !== 'vertical' && index !== lastIndex) { | ||
error: _propTypes2['default'].node | ||
}) | ||
}), | ||
onChange: _propTypes2['default'].func | ||
}; | ||
@@ -203,0 +216,0 @@ Steps.defaultProps = { |
{ | ||
"name": "rc-steps", | ||
"version": "3.3.1", | ||
"version": "3.4.0", | ||
"description": "steps ui component for react", | ||
@@ -46,3 +46,4 @@ "keywords": [ | ||
"prepublish": "rc-tools run guard", | ||
"coverage": "jest --coverage && cat ./coverage/lcov.info | coveralls" | ||
"coverage": "jest --coverage && cat ./coverage/lcov.info | coveralls", | ||
"now-build": "npm run build" | ||
}, | ||
@@ -49,0 +50,0 @@ "jest": { |
@@ -95,2 +95,8 @@ # rc-steps | ||
</tr> | ||
<tr> | ||
<td>onChange</td> | ||
<td>(current: number) => void</td> | ||
<td></td> | ||
<td>Trigger when Step changed</td> | ||
</tr> | ||
</tbody> | ||
@@ -97,0 +103,0 @@ </table> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57638
1653
159
1