@khanacademy/wonder-blocks-clickable
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -99,7 +99,12 @@ // @flow | ||
getCorrectTag = (clickableState: ClickableState, commonProps: mixed) => { | ||
getCorrectTag = ( | ||
clickableState: ClickableState, | ||
commonProps: {[string]: any, ...}, | ||
) => { | ||
const activeHref = this.props.href && !this.props.disabled; | ||
const useClient = this.context.router && !this.props.skipClientNav; | ||
if (activeHref && useClient) { | ||
// NOTE: checking this.props.href here is redundant, but flow | ||
// needs it to refine this.props.href to a string. | ||
if (activeHref && useClient && this.props.href) { | ||
return ( | ||
@@ -106,0 +111,0 @@ <StyledLink |
@@ -127,2 +127,15 @@ import { createElement, Component } from 'react'; | ||
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; | ||
} | ||
} | ||
function _assertThisInitialized(self) { | ||
@@ -144,2 +157,21 @@ if (self === void 0) { | ||
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); | ||
}; | ||
} | ||
var StyledAnchor = addStyle("a"); | ||
@@ -176,5 +208,5 @@ var StyledButton = addStyle("button"); | ||
var _super = _createSuper(Clickable); | ||
function Clickable() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
@@ -188,10 +220,11 @@ | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Clickable)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this), "getCorrectTag", function (clickableState, commonProps) { | ||
var activeHref = _this.props.href && !_this.props.disabled; | ||
var useClient = _this.context.router && !_this.props.skipClientNav; | ||
var useClient = _this.context.router && !_this.props.skipClientNav; // NOTE: checking this.props.href here is redundant, but flow | ||
// needs it to refine this.props.href to a string. | ||
if (activeHref && useClient) { | ||
return createElement(StyledLink, _extends({}, commonProps, { | ||
if (activeHref && useClient && _this.props.href) { | ||
return /*#__PURE__*/createElement(StyledLink, _extends({}, commonProps, { | ||
to: _this.props.href, | ||
@@ -202,3 +235,3 @@ role: _this.props.role, | ||
} else if (activeHref && !useClient) { | ||
return createElement(StyledAnchor, _extends({}, commonProps, { | ||
return /*#__PURE__*/createElement(StyledAnchor, _extends({}, commonProps, { | ||
href: _this.props.href, | ||
@@ -209,3 +242,3 @@ role: _this.props.role, | ||
} else { | ||
return createElement(StyledButton, _extends({}, commonProps, { | ||
return /*#__PURE__*/createElement(StyledButton, _extends({}, commonProps, { | ||
type: "button", | ||
@@ -230,3 +263,3 @@ disabled: _this.props.disabled | ||
var ClickableBehavior = getClickableBehavior(href, skipClientNav, this.context.router); | ||
return createElement(ClickableBehavior, { | ||
return /*#__PURE__*/createElement(ClickableBehavior, { | ||
href: href, | ||
@@ -233,0 +266,0 @@ onClick: onClick |
@@ -1364,11 +1364,15 @@ module.exports = | ||
function clickable_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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 clickable_possibleConstructorReturn(this, result); }; } | ||
function clickable_possibleConstructorReturn(self, call) { if (call && (clickable_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function clickable_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
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; } } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
@@ -1413,5 +1417,5 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _super = _createSuper(Clickable); | ||
function Clickable() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
@@ -1425,10 +1429,11 @@ | ||
_this = clickable_possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Clickable)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this), "getCorrectTag", function (clickableState, commonProps) { | ||
var activeHref = _this.props.href && !_this.props.disabled; | ||
var useClient = _this.context.router && !_this.props.skipClientNav; | ||
var useClient = _this.context.router && !_this.props.skipClientNav; // NOTE: checking this.props.href here is redundant, but flow | ||
// needs it to refine this.props.href to a string. | ||
if (activeHref && useClient) { | ||
return external_react_["createElement"](StyledLink, clickable_extends({}, commonProps, { | ||
if (activeHref && useClient && _this.props.href) { | ||
return /*#__PURE__*/external_react_["createElement"](StyledLink, clickable_extends({}, commonProps, { | ||
to: _this.props.href, | ||
@@ -1439,3 +1444,3 @@ role: _this.props.role, | ||
} else if (activeHref && !useClient) { | ||
return external_react_["createElement"](StyledAnchor, clickable_extends({}, commonProps, { | ||
return /*#__PURE__*/external_react_["createElement"](StyledAnchor, clickable_extends({}, commonProps, { | ||
href: _this.props.href, | ||
@@ -1446,3 +1451,3 @@ role: _this.props.role, | ||
} else { | ||
return external_react_["createElement"](StyledButton, clickable_extends({}, commonProps, { | ||
return /*#__PURE__*/external_react_["createElement"](StyledButton, clickable_extends({}, commonProps, { | ||
type: "button", | ||
@@ -1467,3 +1472,3 @@ disabled: _this.props.disabled | ||
var ClickableBehavior = Object(wonder_blocks_core_["getClickableBehavior"])(href, skipClientNav, this.context.router); | ||
return external_react_["createElement"](ClickableBehavior, { | ||
return /*#__PURE__*/external_react_["createElement"](ClickableBehavior, { | ||
href: href, | ||
@@ -1470,0 +1475,0 @@ onClick: onClick |
{ | ||
"name": "@khanacademy/wonder-blocks-clickable", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"design": "v1", | ||
@@ -18,3 +18,3 @@ "description": "Clickable component for Wonder-Blocks.", | ||
"dependencies": { | ||
"@khanacademy/wonder-blocks-core": "^2.5.1" | ||
"@khanacademy/wonder-blocks-core": "^2.5.2" | ||
}, | ||
@@ -33,3 +33,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "3c6c92225a4eba049ead8d78e2d3eb648e5b16ab" | ||
"gitHead": "a2b5548f5d7db108c39961071d081ec5d96fa88f" | ||
} |
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
89831
2010