Comparing version 3.0.0 to 3.0.1
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports.Step = undefined; | ||
@@ -7,0 +5,0 @@ |
187
lib/Step.js
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
@@ -15,6 +13,2 @@ var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _defineProperty2 = require('babel-runtime/helpers/defineProperty'); | ||
var _defineProperty3 = _interopRequireDefault(_defineProperty2); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
@@ -24,6 +18,2 @@ | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
@@ -60,46 +50,29 @@ | ||
(0, _classCallCheck3['default'])(this, Step); | ||
return (0, _possibleConstructorReturn3['default'])(this, (Step.__proto__ || Object.getPrototypeOf(Step)).apply(this, arguments)); | ||
return (0, _possibleConstructorReturn3['default'])(this, _React$Component.apply(this, arguments)); | ||
} | ||
(0, _createClass3['default'])(Step, [{ | ||
key: 'renderIconNode', | ||
value: function renderIconNode() { | ||
var _classNames; | ||
Step.prototype.renderIconNode = function renderIconNode() { | ||
var _classNames; | ||
var _props = this.props, | ||
prefixCls = _props.prefixCls, | ||
progressDot = _props.progressDot, | ||
stepNumber = _props.stepNumber, | ||
status = _props.status, | ||
title = _props.title, | ||
description = _props.description, | ||
icon = _props.icon, | ||
iconPrefix = _props.iconPrefix; | ||
var _props = this.props, | ||
prefixCls = _props.prefixCls, | ||
progressDot = _props.progressDot, | ||
stepNumber = _props.stepNumber, | ||
status = _props.status, | ||
title = _props.title, | ||
description = _props.description, | ||
icon = _props.icon, | ||
iconPrefix = _props.iconPrefix; | ||
var iconNode = void 0; | ||
var iconClassName = (0, _classnames2['default'])(prefixCls + '-icon', iconPrefix + 'icon', (_classNames = {}, (0, _defineProperty3['default'])(_classNames, iconPrefix + 'icon-' + icon, icon && isString(icon)), (0, _defineProperty3['default'])(_classNames, iconPrefix + 'icon-check', !icon && status === 'finish'), (0, _defineProperty3['default'])(_classNames, iconPrefix + 'icon-cross', !icon && status === 'error'), _classNames)); | ||
var iconDot = _react2['default'].createElement('span', { className: prefixCls + '-icon-dot' }); | ||
// `progressDot` enjoy the highest priority | ||
if (progressDot) { | ||
if (typeof progressDot === 'function') { | ||
iconNode = _react2['default'].createElement( | ||
'span', | ||
{ className: prefixCls + '-icon' }, | ||
progressDot(iconDot, { index: stepNumber - 1, status: status, title: title, description: description }) | ||
); | ||
} else { | ||
iconNode = _react2['default'].createElement( | ||
'span', | ||
{ className: prefixCls + '-icon' }, | ||
iconDot | ||
); | ||
} | ||
} else if (icon && !isString(icon)) { | ||
var iconNode = void 0; | ||
var iconClassName = (0, _classnames2['default'])(prefixCls + '-icon', iconPrefix + 'icon', (_classNames = {}, _classNames[iconPrefix + 'icon-' + icon] = icon && isString(icon), _classNames[iconPrefix + 'icon-check'] = !icon && status === 'finish', _classNames[iconPrefix + 'icon-cross'] = !icon && status === 'error', _classNames)); | ||
var iconDot = _react2['default'].createElement('span', { className: prefixCls + '-icon-dot' }); | ||
// `progressDot` enjoy the highest priority | ||
if (progressDot) { | ||
if (typeof progressDot === 'function') { | ||
iconNode = _react2['default'].createElement( | ||
'span', | ||
{ className: prefixCls + '-icon' }, | ||
icon | ||
progressDot(iconDot, { index: stepNumber - 1, status: status, title: title, description: description }) | ||
); | ||
} else if (icon || status === 'finish' || status === 'error') { | ||
iconNode = _react2['default'].createElement('span', { className: iconClassName }); | ||
} else { | ||
@@ -109,65 +82,81 @@ iconNode = _react2['default'].createElement( | ||
{ className: prefixCls + '-icon' }, | ||
stepNumber | ||
iconDot | ||
); | ||
} | ||
return iconNode; | ||
} else if (icon && !isString(icon)) { | ||
iconNode = _react2['default'].createElement( | ||
'span', | ||
{ className: prefixCls + '-icon' }, | ||
icon | ||
); | ||
} else if (icon || status === 'finish' || status === 'error') { | ||
iconNode = _react2['default'].createElement('span', { className: iconClassName }); | ||
} else { | ||
iconNode = _react2['default'].createElement( | ||
'span', | ||
{ className: prefixCls + '-icon' }, | ||
stepNumber | ||
); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _props2 = this.props, | ||
className = _props2.className, | ||
prefixCls = _props2.prefixCls, | ||
style = _props2.style, | ||
itemWidth = _props2.itemWidth, | ||
_props2$status = _props2.status, | ||
status = _props2$status === undefined ? 'wait' : _props2$status, | ||
iconPrefix = _props2.iconPrefix, | ||
icon = _props2.icon, | ||
wrapperStyle = _props2.wrapperStyle, | ||
adjustMarginRight = _props2.adjustMarginRight, | ||
stepNumber = _props2.stepNumber, | ||
description = _props2.description, | ||
title = _props2.title, | ||
progressDot = _props2.progressDot, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props2, ['className', 'prefixCls', 'style', 'itemWidth', 'status', 'iconPrefix', 'icon', 'wrapperStyle', 'adjustMarginRight', 'stepNumber', 'description', 'title', 'progressDot']); | ||
return iconNode; | ||
}; | ||
Step.prototype.render = function render() { | ||
var _classNames2; | ||
var classString = (0, _classnames2['default'])(prefixCls + '-item', prefixCls + '-item-' + status, className, (0, _defineProperty3['default'])({}, prefixCls + '-item-custom', icon)); | ||
var stepItemStyle = (0, _extends3['default'])({}, style); | ||
if (itemWidth) { | ||
stepItemStyle.width = itemWidth; | ||
} | ||
if (adjustMarginRight) { | ||
stepItemStyle.marginRight = adjustMarginRight; | ||
} | ||
return _react2['default'].createElement( | ||
var _props2 = this.props, | ||
className = _props2.className, | ||
prefixCls = _props2.prefixCls, | ||
style = _props2.style, | ||
itemWidth = _props2.itemWidth, | ||
_props2$status = _props2.status, | ||
status = _props2$status === undefined ? 'wait' : _props2$status, | ||
iconPrefix = _props2.iconPrefix, | ||
icon = _props2.icon, | ||
wrapperStyle = _props2.wrapperStyle, | ||
adjustMarginRight = _props2.adjustMarginRight, | ||
stepNumber = _props2.stepNumber, | ||
description = _props2.description, | ||
title = _props2.title, | ||
progressDot = _props2.progressDot, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props2, ['className', 'prefixCls', 'style', 'itemWidth', 'status', 'iconPrefix', 'icon', 'wrapperStyle', 'adjustMarginRight', 'stepNumber', 'description', 'title', 'progressDot']); | ||
var classString = (0, _classnames2['default'])(prefixCls + '-item', prefixCls + '-item-' + status, className, (_classNames2 = {}, _classNames2[prefixCls + '-item-custom'] = icon, _classNames2)); | ||
var stepItemStyle = (0, _extends3['default'])({}, style); | ||
if (itemWidth) { | ||
stepItemStyle.width = itemWidth; | ||
} | ||
if (adjustMarginRight) { | ||
stepItemStyle.marginRight = adjustMarginRight; | ||
} | ||
return _react2['default'].createElement( | ||
'div', | ||
(0, _extends3['default'])({}, restProps, { | ||
className: classString, | ||
style: stepItemStyle | ||
}), | ||
_react2['default'].createElement('div', { className: prefixCls + '-item-tail' }), | ||
_react2['default'].createElement( | ||
'div', | ||
(0, _extends3['default'])({}, restProps, { | ||
className: classString, | ||
style: stepItemStyle | ||
}), | ||
_react2['default'].createElement('div', { className: prefixCls + '-item-tail' }), | ||
{ className: prefixCls + '-item-icon' }, | ||
this.renderIconNode() | ||
), | ||
_react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-item-content' }, | ||
_react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-item-icon' }, | ||
this.renderIconNode() | ||
{ className: prefixCls + '-item-title' }, | ||
title | ||
), | ||
_react2['default'].createElement( | ||
description && _react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-item-content' }, | ||
_react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-item-title' }, | ||
title | ||
), | ||
description && _react2['default'].createElement( | ||
'div', | ||
{ className: prefixCls + '-item-description' }, | ||
description | ||
) | ||
{ className: prefixCls + '-item-description' }, | ||
description | ||
) | ||
); | ||
} | ||
}]); | ||
) | ||
); | ||
}; | ||
return Step; | ||
@@ -174,0 +163,0 @@ }(_react2['default'].Component); |
177
lib/Steps.js
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
@@ -11,6 +9,2 @@ var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _defineProperty2 = require('babel-runtime/helpers/defineProperty'); | ||
var _defineProperty3 = _interopRequireDefault(_defineProperty2); | ||
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties'); | ||
@@ -24,6 +18,2 @@ | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
@@ -66,3 +56,3 @@ | ||
var _this = (0, _possibleConstructorReturn3['default'])(this, (Steps.__proto__ || Object.getPrototypeOf(Steps)).call(this, props)); | ||
var _this = (0, _possibleConstructorReturn3['default'])(this, _Component.call(this, props)); | ||
@@ -99,93 +89,88 @@ _this.calcStepOffsetWidth = function () { | ||
(0, _createClass3['default'])(Steps, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.calcStepOffsetWidth(); | ||
if (!(0, _utils.isFlexSupported)()) { | ||
this.setState({ | ||
flexSupported: false | ||
}); | ||
} | ||
Steps.prototype.componentDidMount = function componentDidMount() { | ||
this.calcStepOffsetWidth(); | ||
if (!(0, _utils.isFlexSupported)()) { | ||
this.setState({ | ||
flexSupported: false | ||
}); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
this.calcStepOffsetWidth(); | ||
}; | ||
Steps.prototype.componentDidUpdate = function componentDidUpdate() { | ||
this.calcStepOffsetWidth(); | ||
}; | ||
Steps.prototype.componentWillUnmount = function componentWillUnmount() { | ||
if (this.calcTimeout) { | ||
clearTimeout(this.calcTimeout); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (this.calcTimeout) { | ||
clearTimeout(this.calcTimeout); | ||
} | ||
if (this.calcStepOffsetWidth && this.calcStepOffsetWidth.cancel) { | ||
this.calcStepOffsetWidth.cancel(); | ||
} | ||
if (this.calcStepOffsetWidth && this.calcStepOffsetWidth.cancel) { | ||
this.calcStepOffsetWidth.cancel(); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _classNames; | ||
}; | ||
var _props = this.props, | ||
prefixCls = _props.prefixCls, | ||
_props$style = _props.style, | ||
style = _props$style === undefined ? {} : _props$style, | ||
className = _props.className, | ||
children = _props.children, | ||
direction = _props.direction, | ||
labelPlacement = _props.labelPlacement, | ||
iconPrefix = _props.iconPrefix, | ||
status = _props.status, | ||
size = _props.size, | ||
current = _props.current, | ||
progressDot = _props.progressDot, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props, ['prefixCls', 'style', 'className', 'children', 'direction', 'labelPlacement', 'iconPrefix', 'status', 'size', 'current', 'progressDot']); | ||
var _state = this.state, | ||
lastStepOffsetWidth = _state.lastStepOffsetWidth, | ||
flexSupported = _state.flexSupported; | ||
Steps.prototype.render = function render() { | ||
var _classNames; | ||
var filteredChildren = _react2['default'].Children.toArray(children).filter(function (c) { | ||
return !!c; | ||
}); | ||
var lastIndex = filteredChildren.length - 1; | ||
var adjustedlabelPlacement = !!progressDot ? 'vertical' : labelPlacement; | ||
var classString = (0, _classnames2['default'])(prefixCls, prefixCls + '-' + direction, className, (_classNames = {}, (0, _defineProperty3['default'])(_classNames, prefixCls + '-' + size, size), (0, _defineProperty3['default'])(_classNames, prefixCls + '-label-' + adjustedlabelPlacement, direction === 'horizontal'), (0, _defineProperty3['default'])(_classNames, prefixCls + '-dot', !!progressDot), _classNames)); | ||
var _props = this.props, | ||
prefixCls = _props.prefixCls, | ||
_props$style = _props.style, | ||
style = _props$style === undefined ? {} : _props$style, | ||
className = _props.className, | ||
children = _props.children, | ||
direction = _props.direction, | ||
labelPlacement = _props.labelPlacement, | ||
iconPrefix = _props.iconPrefix, | ||
status = _props.status, | ||
size = _props.size, | ||
current = _props.current, | ||
progressDot = _props.progressDot, | ||
restProps = (0, _objectWithoutProperties3['default'])(_props, ['prefixCls', 'style', 'className', 'children', 'direction', 'labelPlacement', 'iconPrefix', 'status', 'size', 'current', 'progressDot']); | ||
var _state = this.state, | ||
lastStepOffsetWidth = _state.lastStepOffsetWidth, | ||
flexSupported = _state.flexSupported; | ||
return _react2['default'].createElement( | ||
'div', | ||
(0, _extends3['default'])({ className: classString, style: style }, restProps), | ||
_react.Children.map(filteredChildren, function (child, index) { | ||
if (!child) { | ||
return null; | ||
var filteredChildren = _react2['default'].Children.toArray(children).filter(function (c) { | ||
return !!c; | ||
}); | ||
var lastIndex = filteredChildren.length - 1; | ||
var adjustedlabelPlacement = !!progressDot ? 'vertical' : labelPlacement; | ||
var classString = (0, _classnames2['default'])(prefixCls, prefixCls + '-' + direction, className, (_classNames = {}, _classNames[prefixCls + '-' + size] = size, _classNames[prefixCls + '-label-' + adjustedlabelPlacement] = direction === 'horizontal', _classNames[prefixCls + '-dot'] = !!progressDot, _classNames)); | ||
return _react2['default'].createElement( | ||
'div', | ||
(0, _extends3['default'])({ className: classString, style: style }, restProps), | ||
_react.Children.map(filteredChildren, function (child, index) { | ||
if (!child) { | ||
return null; | ||
} | ||
var childProps = (0, _extends3['default'])({ | ||
stepNumber: '' + (index + 1), | ||
prefixCls: prefixCls, | ||
iconPrefix: iconPrefix, | ||
wrapperStyle: style, | ||
progressDot: progressDot | ||
}, child.props); | ||
if (!flexSupported && direction !== 'vertical' && index !== lastIndex) { | ||
childProps.itemWidth = 100 / lastIndex + '%'; | ||
childProps.adjustMarginRight = -Math.round(lastStepOffsetWidth / lastIndex + 1); | ||
} | ||
// fix tail color | ||
if (status === 'error' && index === current - 1) { | ||
childProps.className = prefixCls + '-next-error'; | ||
} | ||
if (!child.props.status) { | ||
if (index === current) { | ||
childProps.status = status; | ||
} else if (index < current) { | ||
childProps.status = 'finish'; | ||
} else { | ||
childProps.status = 'wait'; | ||
} | ||
var childProps = (0, _extends3['default'])({ | ||
stepNumber: '' + (index + 1), | ||
prefixCls: prefixCls, | ||
iconPrefix: iconPrefix, | ||
wrapperStyle: style, | ||
progressDot: progressDot | ||
}, child.props); | ||
if (!flexSupported && direction !== 'vertical' && index !== lastIndex) { | ||
childProps.itemWidth = 100 / lastIndex + '%'; | ||
childProps.adjustMarginRight = -Math.round(lastStepOffsetWidth / lastIndex + 1); | ||
} | ||
// fix tail color | ||
if (status === 'error' && index === current - 1) { | ||
childProps.className = prefixCls + '-next-error'; | ||
} | ||
if (!child.props.status) { | ||
if (index === current) { | ||
childProps.status = status; | ||
} else if (index < current) { | ||
childProps.status = 'finish'; | ||
} else { | ||
childProps.status = 'wait'; | ||
} | ||
} | ||
return (0, _react.cloneElement)(child, childProps); | ||
}) | ||
); | ||
} | ||
}]); | ||
} | ||
return (0, _react.cloneElement)(child, childProps); | ||
}) | ||
); | ||
}; | ||
return Steps; | ||
@@ -192,0 +177,0 @@ }(_react.Component); |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports.isFlexSupported = isFlexSupported; | ||
@@ -7,0 +5,0 @@ function isFlexSupported() { |
{ | ||
"name": "rc-steps", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "steps ui component for react", | ||
@@ -14,2 +14,3 @@ "keywords": [ | ||
"lib", | ||
"es", | ||
"assets/iconfont.css", | ||
@@ -49,2 +50,5 @@ "assets/index.css" | ||
"jest": { | ||
"setupFiles": [ | ||
"./tests/setup.js" | ||
], | ||
"collectCoverageFrom": [ | ||
@@ -62,4 +66,5 @@ "src/**/*" | ||
"coveralls": "^2.11.15", | ||
"enzyme": "^2.6.0", | ||
"enzyme-to-json": "^1.5.0", | ||
"enzyme": "^3.0.0", | ||
"enzyme-adapter-react-16": "^1.0.1", | ||
"enzyme-to-json": "^3.0.0", | ||
"jest": "^20.0.4", | ||
@@ -69,6 +74,6 @@ "pre-commit": "1.x", | ||
"rc-dialog": "6.x", | ||
"rc-tools": "6.x", | ||
"react": "15.x", | ||
"react-dom": "15.x", | ||
"react-test-renderer": "^15.3.2" | ||
"rc-tools": "7.x", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"react-test-renderer": "^16.0.0" | ||
}, | ||
@@ -75,0 +80,0 @@ "pre-commit": [ |
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
51612
14
1498
12
1