Comparing version 0.4.9 to 0.5.0
@@ -70,2 +70,6 @@ 'use strict'; | ||
function identity(x) { | ||
x; | ||
} | ||
/** | ||
@@ -100,3 +104,2 @@ * @summary A derivable class for creating React components that can transparently | ||
var ReactiveComponent = function (_React$Component2) { | ||
@@ -123,2 +126,3 @@ _inherits(ReactiveComponent, _React$Component2); | ||
var bonds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var propTransforms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -131,2 +135,3 @@ _classCallCheck(this, ReactiveComponent); | ||
_this2.bonds = bonds; | ||
_this2.propTransforms = propTransforms; | ||
_this2.allBondKeys = [].concat(reactiveProps).concat(Object.keys(bonds)); | ||
@@ -212,2 +217,4 @@ return _this2; | ||
value: function manageProps(props, nextProps) { | ||
var _this3 = this; | ||
var that = this; | ||
@@ -219,3 +226,3 @@ if (this._consolidatedBonds) { | ||
this._consolidatedBonds = new ReactiveBond(this.reactiveProps.map(function (f) { | ||
return nextProps[f]; | ||
return (_this3.reactiveProps[f] || identity)(nextProps[f]); | ||
}), [], function (a) { | ||
@@ -240,6 +247,6 @@ var s = that.state || {}; | ||
value: function ready() { | ||
var _this3 = this; | ||
var _this4 = this; | ||
return this.allBondKeys.every(function (k) { | ||
return _this3.state[k] !== undefined; | ||
return _this4.state[k] !== undefined; | ||
}); | ||
@@ -289,2 +296,37 @@ } | ||
/** | ||
* Simple coditional to output one item over another dependent on some condition. | ||
* | ||
* @example | ||
* class Clock extends React.Component { | ||
* constructor (someBond) { this._someBond = someBond } | ||
* render () { | ||
* return <If condition={this.someBond.ready()} | ||
* then={<Rspan>{this.someBond}</Rspan>} | ||
* else='Not ready' | ||
* /> | ||
* } | ||
* } | ||
*/ | ||
var If = function (_ReactiveComponent) { | ||
_inherits(If, _ReactiveComponent); | ||
function If() { | ||
_classCallCheck(this, If); | ||
return _possibleConstructorReturn(this, (If.__proto__ || Object.getPrototypeOf(If)).call(this, ['condition'])); | ||
} | ||
_createClass(If, [{ | ||
key: 'render', | ||
value: function render() { | ||
return this.state.condition ? this.props.then : this.props.else || React.createElement('span', null); | ||
} | ||
}]); | ||
return If; | ||
}(ReactiveComponent); | ||
/** | ||
* {@link Bond}-aware, variant of `span` component. | ||
@@ -302,4 +344,4 @@ * | ||
var Rspan = function (_ReactiveComponent) { | ||
_inherits(Rspan, _ReactiveComponent); | ||
var Rspan = function (_ReactiveComponent2) { | ||
_inherits(Rspan, _ReactiveComponent2); | ||
@@ -343,4 +385,4 @@ function Rspan() { | ||
var Rdiv = function (_ReactiveComponent2) { | ||
_inherits(Rdiv, _ReactiveComponent2); | ||
var Rdiv = function (_ReactiveComponent3) { | ||
_inherits(Rdiv, _ReactiveComponent3); | ||
@@ -379,4 +421,4 @@ function Rdiv() { | ||
var Ra = function (_ReactiveComponent3) { | ||
_inherits(Ra, _ReactiveComponent3); | ||
var Ra = function (_ReactiveComponent4) { | ||
_inherits(Ra, _ReactiveComponent4); | ||
@@ -417,4 +459,4 @@ function Ra() { | ||
var Rimg = function (_ReactiveComponent4) { | ||
_inherits(Rimg, _ReactiveComponent4); | ||
var Rimg = function (_ReactiveComponent5) { | ||
_inherits(Rimg, _ReactiveComponent5); | ||
@@ -451,4 +493,4 @@ function Rimg() { | ||
var Hash = function (_ReactiveComponent5) { | ||
_inherits(Hash, _ReactiveComponent5); | ||
var Hash = function (_ReactiveComponent6) { | ||
_inherits(Hash, _ReactiveComponent6); | ||
@@ -487,3 +529,3 @@ function Hash() { | ||
module.exports = { | ||
ReactiveComponent: ReactiveComponent, Rspan: Rspan, Rdiv: Rdiv, Ra: Ra, Rimg: Rimg, Hash: Hash, InjectedCacheWaiter: InjectedCacheWaiter | ||
ReactiveComponent: ReactiveComponent, Rspan: Rspan, Rdiv: Rdiv, Ra: Ra, Rimg: Rimg, Hash: Hash, InjectedCacheWaiter: InjectedCacheWaiter, If: If | ||
}; |
{ | ||
"name": "oo7-react", | ||
"version": "0.4.9", | ||
"version": "0.5.0", | ||
"description": "The Reactive Bond API", | ||
@@ -41,4 +41,4 @@ "main": "lib/index.js", | ||
"chai": "^3.5.0", | ||
"mocha": "^3.2.0" | ||
"mocha": "^5.2.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
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
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
29545
434