@storybook/components
Advanced tools
Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2
@@ -51,12 +51,6 @@ 'use strict'; | ||
var wrapOnClick = function wrapOnClick(fn) { | ||
return function (e) { | ||
return isPlainLeftClick(e) ? e.preventDefault() || fn(e) : false; | ||
}; | ||
}; | ||
var RoutedLink = function (_React$Component) { | ||
(0, _inherits3.default)(RoutedLink, _React$Component); | ||
function RoutedLink(props) { | ||
function RoutedLink() { | ||
var _ref; | ||
@@ -66,11 +60,9 @@ | ||
for (var _len = arguments.length, rest = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
rest[_key - 1] = arguments[_key]; | ||
for (var _len = arguments.length, attrs = Array(_len), _key = 0; _key < _len; _key++) { | ||
attrs[_key] = arguments[_key]; | ||
} | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (_ref = RoutedLink.__proto__ || (0, _getPrototypeOf2.default)(RoutedLink)).call.apply(_ref, [this].concat([props].concat(rest)))); | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (_ref = RoutedLink.__proto__ || (0, _getPrototypeOf2.default)(RoutedLink)).call.apply(_ref, [this].concat(attrs))); | ||
var onClick = props.onClick; | ||
_this.onClick = onClick ? wrapOnClick(onClick) : undefined; | ||
_this.onClick = _this.onClick.bind(_this); | ||
return _this; | ||
@@ -80,7 +72,8 @@ } | ||
(0, _createClass3.default)(RoutedLink, [{ | ||
key: 'componentWillUpdate', | ||
value: function componentWillUpdate(_ref2) { | ||
var onClick = _ref2.onClick; | ||
this.onClick = wrapOnClick(onClick); | ||
key: 'onClick', | ||
value: function onClick(e) { | ||
if (isPlainLeftClick(e)) { | ||
e.preventDefault(); | ||
this.props.onClick(e); | ||
} | ||
} | ||
@@ -90,9 +83,9 @@ }, { | ||
value: function render() { | ||
var onClick = this.onClick; | ||
var _props = this.props, | ||
href = _props.href, | ||
children = _props.children, | ||
rest = (0, _objectWithoutProperties3.default)(_props, ['href', 'children']); | ||
onClick = _props.onClick, | ||
rest = (0, _objectWithoutProperties3.default)(_props, ['href', 'children', 'onClick']); | ||
var props = (0, _extends3.default)({ href: href }, rest, { onClick: onClick }); | ||
var props = onClick ? (0, _extends3.default)({ href: href }, rest, { onClick: this.onClick }) : (0, _extends3.default)({ href: href }, rest); | ||
return _react2.default.createElement( | ||
@@ -99,0 +92,0 @@ 'a', |
{ | ||
"name": "@storybook/components", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.2", | ||
"description": "Core Storybook Components", | ||
@@ -27,6 +27,6 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@storybook/addon-actions": "4.0.0-alpha.1", | ||
"@storybook/addon-knobs": "4.0.0-alpha.1", | ||
"@storybook/react": "4.0.0-alpha.1" | ||
"@storybook/addon-actions": "4.0.0-alpha.2", | ||
"@storybook/addon-knobs": "4.0.0-alpha.2", | ||
"@storybook/react": "4.0.0-alpha.2" | ||
} | ||
} |
@@ -9,20 +9,19 @@ import PropTypes from 'prop-types'; | ||
const wrapOnClick = fn => e => (isPlainLeftClick(e) ? e.preventDefault() || fn(e) : false); | ||
export default class RoutedLink extends React.Component { | ||
constructor(props, ...rest) { | ||
super(...[props, ...rest]); | ||
constructor(...attrs) { | ||
super(...attrs); | ||
const { onClick } = props; | ||
this.onClick = onClick ? wrapOnClick(onClick) : undefined; | ||
this.onClick = this.onClick.bind(this); | ||
} | ||
componentWillUpdate({ onClick }) { | ||
this.onClick = wrapOnClick(onClick); | ||
onClick(e) { | ||
if (isPlainLeftClick(e)) { | ||
e.preventDefault(); | ||
this.props.onClick(e); | ||
} | ||
} | ||
render() { | ||
const { onClick } = this; | ||
const { href, children, ...rest } = this.props; | ||
const props = { href, ...rest, onClick }; | ||
const { href, children, onClick, ...rest } = this.props; | ||
const props = onClick ? { href, ...rest, onClick: this.onClick } : { href, ...rest }; | ||
return <a {...props}>{children}</a>; | ||
@@ -29,0 +28,0 @@ } |
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
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
23931
582