Comparing version 0.16.0 to 0.17.0
@@ -29,47 +29,49 @@ 'use strict'; | ||
var branch = function branch(test, left, right, BaseComponent) { | ||
return function (_React$Component) { | ||
_inherits(_class2, _React$Component); | ||
var branch = function branch(test, left, right) { | ||
return function (BaseComponent) { | ||
return function (_React$Component) { | ||
_inherits(_class2, _React$Component); | ||
function _class2(props, context) { | ||
_classCallCheck(this, _class2); | ||
function _class2(props, context) { | ||
_classCallCheck(this, _class2); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(_class2).call(this, props, context)); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(_class2).call(this, props, context)); | ||
_this.LeftComponent = null; | ||
_this.RightComponent = null; | ||
_this.LeftComponent = null; | ||
_this.RightComponent = null; | ||
_this.computeChildComponent(_this.props); | ||
return _this; | ||
} | ||
_this.computeChildComponent(_this.props); | ||
return _this; | ||
} | ||
_createClass(_class2, [{ | ||
key: 'computeChildComponent', | ||
value: function computeChildComponent(props) { | ||
if (test(props)) { | ||
this.LeftComponent = this.LeftComponent || left(BaseComponent); | ||
this.Component = this.LeftComponent; | ||
} else { | ||
this.RightComponent = this.RightComponent || right(BaseComponent); | ||
this.Component = this.RightComponent; | ||
_createClass(_class2, [{ | ||
key: 'computeChildComponent', | ||
value: function computeChildComponent(props) { | ||
if (test(props)) { | ||
this.LeftComponent = this.LeftComponent || left(BaseComponent); | ||
this.Component = this.LeftComponent; | ||
} else { | ||
this.RightComponent = this.RightComponent || right(BaseComponent); | ||
this.Component = this.RightComponent; | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
this.computeChildComponent(nextProps); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var Component = this.Component; | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
this.computeChildComponent(nextProps); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var Component = this.Component; | ||
return (0, _createElement2.default)(Component, this.props); | ||
} | ||
}]); | ||
return (0, _createElement2.default)(Component, this.props); | ||
} | ||
}]); | ||
return _class2; | ||
}(_react2.default.Component); | ||
return _class2; | ||
}(_react2.default.Component); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(branch, 'branch'); |
@@ -11,6 +11,2 @@ 'use strict'; | ||
var _createHelper = require('./createHelper'); | ||
var _createHelper2 = _interopRequireDefault(_createHelper); | ||
var _createElement = require('./createElement'); | ||
@@ -23,7 +19,9 @@ | ||
var componentFromProp = function componentFromProp(propName) { | ||
return function (props) { | ||
var Component = function Component(props) { | ||
return (0, _createElement2.default)(props[propName], (0, _omit2.default)(props, propName)); | ||
}; | ||
Component.displayName = 'componentFromProp(' + propName + ')'; | ||
return Component; | ||
}; | ||
exports.default = (0, _createHelper2.default)(componentFromProp, 'componentFromProp'); | ||
exports.default = componentFromProp; |
@@ -13,54 +13,2 @@ 'use strict'; | ||
// In production, use lodash's flowRight | ||
var compose = _flowRight2.default; | ||
// In development, print warnings when composing higher-order component helpers | ||
// that have been applied with too few parameters | ||
if (process.env.NODE_ENV !== 'production') { | ||
(function () { | ||
var getDisplayName = require('./getDisplayName').default; | ||
compose = function compose() { | ||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
var needsParameters = []; | ||
var doesntNeedParameters = []; | ||
funcs.forEach(function (func) { | ||
var missingHelperParameters = func.__missingHelperParameters; | ||
if (missingHelperParameters === 0) { | ||
doesntNeedParameters.push(func); | ||
} else if (missingHelperParameters > 0) { | ||
needsParameters.push(func); | ||
} | ||
}); | ||
// Warn if a helper that needs parameters is composed with another helper | ||
// that doesn't need parameters. Checking for the second condition allows | ||
// partially-applied helpers to be composed before they become | ||
// higher-order components. | ||
if (needsParameters.length && doesntNeedParameters.length) { | ||
return function (BaseComponent) { | ||
var displayName = getDisplayName(BaseComponent); | ||
needsParameters.forEach(function (func) { | ||
var helperName = func.__helperName; | ||
var amountMissing = func.__missingHelperParameters; | ||
/* eslint-disable */ | ||
console.error( | ||
/* eslint-enable */ | ||
'Attempted to compose `' + helperName + '()` with other ' + 'higher-order component helpers, but it has been applied with ' + (amountMissing + ' too few parameters. Check the implementation ') + ('of <' + displayName + '>.')); | ||
}); | ||
return _flowRight2.default.apply(undefined, funcs)(BaseComponent); | ||
}; | ||
} | ||
return _flowRight2.default.apply(undefined, funcs); | ||
}; | ||
})(); | ||
} | ||
exports.default = compose; | ||
exports.default = _flowRight2.default; |
@@ -9,62 +9,42 @@ 'use strict'; | ||
var _curry = require('lodash/curry'); | ||
var createHelper = function createHelper(func, helperName) { | ||
var setDisplayName = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; | ||
var noArgs = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; | ||
var _curry2 = _interopRequireDefault(_curry); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var createHelper = function createHelper(func, helperName, _helperLength) { | ||
var setDisplayName = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3]; | ||
var helperLength = _helperLength || func.length; | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (process.env.NODE_ENV !== 'production' && setDisplayName) { | ||
var _ret = function () { | ||
// In development, use custom implementation of curry that keeps track of | ||
// whether enough parameters have been applied. Also adds a `displayName` | ||
// to the base commponent. | ||
var wrapDisplayName = require('./wrapDisplayName').default; | ||
var apply = function apply(previousArgs, nextArgs) { | ||
var args = previousArgs.concat(nextArgs); | ||
var argsLength = args.length; | ||
if (argsLength < helperLength) { | ||
var partialFunc = function partialFunc() { | ||
for (var _len = arguments.length, partialArgs = Array(_len), _key = 0; _key < _len; _key++) { | ||
partialArgs[_key] = arguments[_key]; | ||
} | ||
if (noArgs) { | ||
return { | ||
v: function v(BaseComponent) { | ||
var Component = func(BaseComponent); | ||
Component.displayName = wrapDisplayName(BaseComponent, helperName); | ||
return Component; | ||
} | ||
}; | ||
} | ||
return apply(args, partialArgs); | ||
}; | ||
return { | ||
v: function v() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
// The development version of `compose` will use these properties to | ||
// print warnings | ||
partialFunc.__missingHelperParameters = helperLength - argsLength - 1; | ||
partialFunc.__helperName = helperName; | ||
if (process.env.NODE_ENV !== 'production' && args.length > func.length) { | ||
/* eslint-disable */ | ||
console.error( | ||
/* eslint-enable */ | ||
'Too many arguments passed to ' + helperName + '(). It should called ' + ('like so: ' + helperName + '(...args)(BaseComponent).')); | ||
} | ||
return partialFunc; | ||
} | ||
return function (BaseComponent) { | ||
var Component = noArgs ? func(BaseComponent) : func.apply(undefined, args)(BaseComponent); | ||
var BaseComponent = args[helperLength - 1]; | ||
Component.displayName = wrapDisplayName(BaseComponent, helperName); | ||
var Component = func.apply(undefined, _toConsumableArray(args)); | ||
if (BaseComponent && helperName && setDisplayName) { | ||
Component.displayName = wrapDisplayName(BaseComponent, helperName); | ||
return Component; | ||
}; | ||
} | ||
return Component; | ||
}; | ||
return { | ||
v: function v() { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
return apply([], args); | ||
} | ||
}; | ||
}(); | ||
@@ -75,6 +55,5 @@ | ||
// In production, use lodash's curry | ||
return (0, _curry2.default)(func, helperLength); | ||
return func; | ||
}; | ||
exports.default = createHelper; |
@@ -19,11 +19,11 @@ 'use strict'; | ||
return function (_Component) { | ||
_inherits(_class, _Component); | ||
_inherits(Sink, _Component); | ||
function _class() { | ||
_classCallCheck(this, _class); | ||
function Sink() { | ||
_classCallCheck(this, Sink); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Sink).apply(this, arguments)); | ||
} | ||
_createClass(_class, [{ | ||
_createClass(Sink, [{ | ||
key: 'componentWillMount', | ||
@@ -45,3 +45,3 @@ value: function componentWillMount() { | ||
return _class; | ||
return Sink; | ||
}(_react.Component); | ||
@@ -48,0 +48,0 @@ }; |
@@ -15,5 +15,5 @@ 'use strict'; | ||
var _createHelper = require('./createHelper'); | ||
var _wrapDisplayName = require('./wrapDisplayName'); | ||
var _createHelper2 = _interopRequireDefault(_createHelper); | ||
var _wrapDisplayName2 = _interopRequireDefault(_wrapDisplayName); | ||
@@ -65,10 +65,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var spy = (0, _createHelper2.default)(function (BaseComponent) { | ||
return function (_React$Component) { | ||
_inherits(_class2, _React$Component); | ||
var spy = function spy(BaseComponent) { | ||
var Spy = function (_React$Component) { | ||
_inherits(Spy, _React$Component); | ||
function _class2(props, context) { | ||
_classCallCheck(this, _class2); | ||
function Spy(props, context) { | ||
_classCallCheck(this, Spy); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(_class2).call(this, props, context)); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Spy).call(this, props, context)); | ||
@@ -84,3 +84,3 @@ _this.refCallback = function (ref) { | ||
_createClass(_class2, [{ | ||
_createClass(Spy, [{ | ||
key: 'componentWillReceiveProps', | ||
@@ -102,6 +102,10 @@ value: function componentWillReceiveProps(nextProps) { | ||
return _class2; | ||
return Spy; | ||
}(_react2.default.Component); | ||
}, 'spy'); | ||
Spy.displayName = (0, _wrapDisplayName2.default)(BaseComponent, 'spy'); | ||
return Spy; | ||
}; | ||
spy.getInfo = function () { | ||
@@ -108,0 +112,0 @@ return spyInfo; |
@@ -17,10 +17,12 @@ 'use strict'; | ||
var defaultProps = function defaultProps(props, BaseComponent) { | ||
var DefaultProps = function DefaultProps(ownerProps) { | ||
return (0, _createElement2.default)(BaseComponent, ownerProps); | ||
var defaultProps = function defaultProps(props) { | ||
return function (BaseComponent) { | ||
var DefaultProps = function DefaultProps(ownerProps) { | ||
return (0, _createElement2.default)(BaseComponent, ownerProps); | ||
}; | ||
DefaultProps.defaultProps = props; | ||
return DefaultProps; | ||
}; | ||
DefaultProps.defaultProps = props; | ||
return DefaultProps; | ||
}; | ||
exports.default = (0, _createHelper2.default)(defaultProps, 'defaultProps'); |
@@ -27,33 +27,35 @@ 'use strict'; | ||
var doOnReceiveProps = function doOnReceiveProps(callback, BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class, _Component); | ||
var doOnReceiveProps = function doOnReceiveProps(callback) { | ||
return function (BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class, _Component); | ||
function _class() { | ||
_classCallCheck(this, _class); | ||
function _class() { | ||
_classCallCheck(this, _class); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments)); | ||
} | ||
_createClass(_class, [{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
callback(this.props); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments)); | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
callback(nextProps); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, this.props); | ||
} | ||
}]); | ||
return _class; | ||
}(_react.Component); | ||
_createClass(_class, [{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
callback(this.props); | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
callback(nextProps); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, this.props); | ||
} | ||
}]); | ||
return _class; | ||
}(_react.Component); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(doOnReceiveProps, 'doOnReceiveProps'); |
@@ -23,5 +23,7 @@ 'use strict'; | ||
var flattenProp = function flattenProp(propName, BaseComponent) { | ||
return function (props) { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, (0, _omit2.default)(props, propName), props[propName])); | ||
var flattenProp = function flattenProp(propName) { | ||
return function (BaseComponent) { | ||
return function (props) { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, (0, _omit2.default)(props, propName), props[propName])); | ||
}; | ||
}; | ||
@@ -28,0 +30,0 @@ }; |
@@ -19,12 +19,14 @@ 'use strict'; | ||
var getContext = function getContext(contextTypes, BaseComponent) { | ||
var GetContext = function GetContext(ownerProps, context) { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, ownerProps, context)); | ||
}; | ||
var getContext = function getContext(contextTypes) { | ||
return function (BaseComponent) { | ||
var GetContext = function GetContext(ownerProps, context) { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, ownerProps, context)); | ||
}; | ||
GetContext.contextTypes = contextTypes; | ||
GetContext.contextTypes = contextTypes; | ||
return GetContext; | ||
return GetContext; | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(getContext, 'getContext'); |
@@ -10,2 +10,7 @@ 'use strict'; | ||
} | ||
if (!Component) { | ||
return undefined; | ||
} | ||
return Component.displayName || Component.name || 'Component'; | ||
@@ -12,0 +17,0 @@ }; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.hoistStatics = exports.nest = exports.componentFromProp = exports.createSink = exports.isClassComponent = exports.shallowEqual = exports.wrapDisplayName = exports.getDisplayName = exports.compose = exports.setDisplayName = exports.setPropTypes = exports.setStatic = exports.toClass = exports.lifecycle = exports.doOnReceiveProps = exports.getContext = exports.withContext = exports.onlyUpdateForPropTypes = exports.onlyUpdateForKeys = exports.pure = exports.shouldUpdate = exports.renderNothing = exports.renderComponent = exports.branch = exports.withReducer = exports.withState = exports.flattenProp = exports.renameProps = exports.renameProp = exports.defaultProps = exports.withAttachedProps = exports.withProps = exports.mapPropsOnChange = exports.mapProps = undefined; | ||
exports.hoistStatics = exports.nest = exports.componentFromProp = exports.createSink = exports.isClassComponent = exports.shallowEqual = exports.wrapDisplayName = exports.getDisplayName = exports.compose = exports.setDisplayName = exports.setPropTypes = exports.setStatic = exports.toClass = exports.lifecycle = exports.doOnReceiveProps = exports.getContext = exports.withContext = exports.onlyUpdateForPropTypes = exports.onlyUpdateForKeys = exports.pure = exports.shouldUpdate = exports.renderNothing = exports.renderComponent = exports.branch = exports.withReducer = exports.withState = exports.flattenProp = exports.renameProps = exports.renameProp = exports.defaultProps = exports.withHandlers = exports.withProps = exports.mapPropsOnChange = exports.mapProps = undefined; | ||
@@ -21,5 +21,5 @@ var _mapProps2 = require('./mapProps'); | ||
var _withAttachedProps2 = require('./withAttachedProps'); | ||
var _withHandlers2 = require('./withHandlers'); | ||
var _withAttachedProps3 = _interopRequireDefault(_withAttachedProps2); | ||
var _withHandlers3 = _interopRequireDefault(_withHandlers2); | ||
@@ -152,3 +152,3 @@ var _defaultProps2 = require('./defaultProps'); | ||
exports.withProps = _withProps3.default; | ||
exports.withAttachedProps = _withAttachedProps3.default; | ||
exports.withHandlers = _withHandlers3.default; | ||
exports.defaultProps = _defaultProps3.default; | ||
@@ -155,0 +155,0 @@ exports.renameProp = _renameProp3.default; |
@@ -31,35 +31,37 @@ 'use strict'; | ||
var lifecycle = function lifecycle(setup, teardown, BaseComponent) { | ||
return function (_React$Component) { | ||
_inherits(Lifecycle, _React$Component); | ||
var lifecycle = function lifecycle(setup, teardown) { | ||
return function (BaseComponent) { | ||
return function (_React$Component) { | ||
_inherits(Lifecycle, _React$Component); | ||
function Lifecycle(props, context) { | ||
_classCallCheck(this, Lifecycle); | ||
function Lifecycle(props, context) { | ||
_classCallCheck(this, Lifecycle); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Lifecycle).call(this, props, context)); | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Lifecycle).call(this, props, context)); | ||
if (setup) { | ||
setup(_this); | ||
if (setup) { | ||
setup(_this); | ||
} | ||
return _this; | ||
} | ||
return _this; | ||
} | ||
_createClass(Lifecycle, [{ | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (teardown) { | ||
teardown(this); | ||
_createClass(Lifecycle, [{ | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (teardown) { | ||
teardown(this); | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, this.state)); | ||
} | ||
}]); | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, this.state)); | ||
} | ||
}]); | ||
return Lifecycle; | ||
}(_react2.default.Component); | ||
return Lifecycle; | ||
}(_react2.default.Component); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(lifecycle, 'lifecycle'); |
@@ -17,5 +17,7 @@ 'use strict'; | ||
var mapProps = function mapProps(propsMapper, BaseComponent) { | ||
return function (props) { | ||
return (0, _createElement2.default)(BaseComponent, propsMapper(props)); | ||
var mapProps = function mapProps(propsMapper) { | ||
return function (BaseComponent) { | ||
return function (props) { | ||
return (0, _createElement2.default)(BaseComponent, propsMapper(props)); | ||
}; | ||
}; | ||
@@ -22,0 +24,0 @@ }; |
@@ -41,42 +41,44 @@ 'use strict'; | ||
var mapPropsOnChange = function mapPropsOnChange(depdendentPropKeys, propsMapper, BaseComponent) { | ||
var pickDependentProps = function pickDependentProps(props) { | ||
return (0, _pick2.default)(props, depdendentPropKeys); | ||
}; | ||
var mapPropsOnChange = function mapPropsOnChange(depdendentPropKeys, propsMapper) { | ||
return function (BaseComponent) { | ||
var pickDependentProps = function pickDependentProps(props) { | ||
return (0, _pick2.default)(props, depdendentPropKeys); | ||
}; | ||
return function (_Component) { | ||
_inherits(_class2, _Component); | ||
return function (_Component) { | ||
_inherits(_class2, _Component); | ||
function _class2() { | ||
var _Object$getPrototypeO; | ||
function _class2() { | ||
var _Object$getPrototypeO; | ||
var _temp, _this, _ret; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, _class2); | ||
_classCallCheck(this, _class2); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.computedProps = propsMapper(_this.props), _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.computedProps = propsMapper(_this.props), _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
_createClass(_class2, [{ | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (!(0, _shallowEqual2.default)(pickDependentProps(this.props), pickDependentProps(nextProps))) { | ||
this.computedProps = propsMapper(nextProps); | ||
_createClass(_class2, [{ | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (!(0, _shallowEqual2.default)(pickDependentProps(this.props), pickDependentProps(nextProps))) { | ||
this.computedProps = propsMapper(nextProps); | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, (0, _omit2.default)(this.props, depdendentPropKeys), this.computedProps)); | ||
} | ||
}]); | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, (0, _omit2.default)(this.props, depdendentPropKeys), this.computedProps)); | ||
} | ||
}]); | ||
return _class2; | ||
}(_react.Component); | ||
return _class2; | ||
}(_react.Component); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(mapPropsOnChange, 'mapPropsOnChange'); |
@@ -25,8 +25,10 @@ 'use strict'; | ||
var onlyUpdateForKeys = function onlyUpdateForKeys(propKeys, BaseComponent) { | ||
return (0, _shouldUpdate2.default)(function (props, nextProps) { | ||
return !(0, _shallowEqual2.default)((0, _pick2.default)(nextProps, propKeys), (0, _pick2.default)(props, propKeys)); | ||
}, BaseComponent); | ||
var onlyUpdateForKeys = function onlyUpdateForKeys(propKeys) { | ||
return function (BaseComponent) { | ||
return (0, _shouldUpdate2.default)(function (props, nextProps) { | ||
return !(0, _shallowEqual2.default)((0, _pick2.default)(nextProps, propKeys), (0, _pick2.default)(props, propKeys)); | ||
})(BaseComponent); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(onlyUpdateForKeys, 'onlyUpdateForKeys'); |
@@ -30,3 +30,3 @@ 'use strict'; | ||
var propKeys = Object.keys(propTypes || {}); | ||
var OnlyUpdateForPropTypes = (0, _onlyUpdateForKeys2.default)(propKeys, BaseComponent); | ||
var OnlyUpdateForPropTypes = (0, _onlyUpdateForKeys2.default)(propKeys)(BaseComponent); | ||
@@ -36,2 +36,2 @@ return OnlyUpdateForPropTypes; | ||
exports.default = (0, _createHelper2.default)(onlyUpdateForPropTypes, 'onlyUpdateForPropTypes'); | ||
exports.default = (0, _createHelper2.default)(onlyUpdateForPropTypes, 'onlyUpdateForPropTypes', true, true); |
{ | ||
"name": "recompose", | ||
"version": "0.16.0", | ||
"version": "0.17.0", | ||
"author": "Andrew Clark <acdlite@me.com>", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -25,2 +25,2 @@ 'use strict'; | ||
exports.default = (0, _createHelper2.default)(pure, 'pure', 1); | ||
exports.default = (0, _createHelper2.default)(pure, 'pure', true, true); |
@@ -25,8 +25,8 @@ 'use strict'; | ||
var renameProp = function renameProp(oldName, newName, BaseComponent) { | ||
var renameProp = function renameProp(oldName, newName) { | ||
return (0, _mapProps2.default)(function (props) { | ||
return _extends({}, (0, _omit2.default)(props, oldName), _defineProperty({}, newName, props[oldName])); | ||
}, BaseComponent); | ||
}); | ||
}; | ||
exports.default = (0, _createHelper2.default)(renameProp, 'renameProp'); |
@@ -34,3 +34,3 @@ 'use strict'; | ||
var renameProps = function renameProps(nameMap, BaseComponent) { | ||
var renameProps = function renameProps(nameMap) { | ||
return (0, _mapProps2.default)(function (props) { | ||
@@ -40,5 +40,5 @@ return _extends({}, (0, _omit2.default)(props, keys(nameMap)), (0, _mapKeys2.default)((0, _pick2.default)(props, keys(nameMap)), function (_, oldName) { | ||
})); | ||
}, BaseComponent); | ||
}); | ||
}; | ||
exports.default = (0, _createHelper2.default)(renameProps, 'renameProps'); |
@@ -17,8 +17,15 @@ 'use strict'; | ||
var renderComponent = function renderComponent(Component, _) { | ||
return function (props) { | ||
return (0, _createElement2.default)(Component, props); | ||
var renderComponent = function renderComponent(Component) { | ||
return function (_) { | ||
var RenderComponent = function RenderComponent(props) { | ||
return (0, _createElement2.default)(Component, props); | ||
}; | ||
if (process.env.NODE_ENV !== 'production') { | ||
var wrapDisplayName = require('./wrapDisplayName').default; | ||
RenderComponent.displayName = wrapDisplayName(Component, 'renderComponent'); | ||
} | ||
return RenderComponent; | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(renderComponent, 'renderComponent'); | ||
exports.default = (0, _createHelper2.default)(renderComponent, 'renderComponent', false); |
@@ -21,2 +21,2 @@ 'use strict'; | ||
exports.default = (0, _createHelper2.default)(renderNothing, 'renderNothing', 1, false); | ||
exports.default = (0, _createHelper2.default)(renderNothing, 'renderNothing', false, true); |
@@ -17,4 +17,6 @@ 'use strict'; | ||
var setDisplayName = (0, _setStatic2.default)('displayName'); | ||
var setDisplayName = function setDisplayName(displayName) { | ||
return (0, _setStatic2.default)('displayName', displayName); | ||
}; | ||
exports.default = (0, _createHelper2.default)(setDisplayName, 'setDisplayName', 2, false); | ||
exports.default = (0, _createHelper2.default)(setDisplayName, 'setDisplayName', false); |
@@ -17,4 +17,6 @@ 'use strict'; | ||
var setPropTypes = (0, _setStatic2.default)('propTypes'); | ||
var setPropTypes = function setPropTypes(propTypes) { | ||
return (0, _setStatic2.default)('propTypes', propTypes); | ||
}; | ||
exports.default = (0, _createHelper2.default)(setPropTypes, 'setPropTypes', 2, false); | ||
exports.default = (0, _createHelper2.default)(setPropTypes, 'setPropTypes', false); |
@@ -13,7 +13,9 @@ 'use strict'; | ||
var setStatic = function setStatic(key, value, BaseComponent) { | ||
BaseComponent[key] = value; | ||
return BaseComponent; | ||
var setStatic = function setStatic(key, value) { | ||
return function (BaseComponent) { | ||
BaseComponent[key] = value; | ||
return BaseComponent; | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(setStatic, 'setStatic', 3, false); | ||
exports.default = (0, _createHelper2.default)(setStatic, 'setStatic', false); |
@@ -27,28 +27,30 @@ 'use strict'; | ||
var shouldUpdate = function shouldUpdate(test, BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class, _Component); | ||
var shouldUpdate = function shouldUpdate(test) { | ||
return function (BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class, _Component); | ||
function _class() { | ||
_classCallCheck(this, _class); | ||
function _class() { | ||
_classCallCheck(this, _class); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments)); | ||
} | ||
_createClass(_class, [{ | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
return test(this.props, nextProps); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments)); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, this.props); | ||
} | ||
}]); | ||
return _class; | ||
}(_react.Component); | ||
_createClass(_class, [{ | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
return test(this.props, nextProps); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, this.props); | ||
} | ||
}]); | ||
return _class; | ||
}(_react.Component); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(shouldUpdate, 'shouldUpdate'); |
@@ -29,33 +29,35 @@ 'use strict'; | ||
var withAttachedProps = function withAttachedProps(createProps, BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class2, _Component); | ||
var withAttachedProps = function withAttachedProps(createProps) { | ||
return function (BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class2, _Component); | ||
function _class2() { | ||
var _Object$getPrototypeO; | ||
function _class2() { | ||
var _Object$getPrototypeO; | ||
var _temp, _this, _ret; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, _class2); | ||
_classCallCheck(this, _class2); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.attachedProps = createProps(function () { | ||
return _this.props; | ||
}), _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.attachedProps = createProps(function () { | ||
return _this.props; | ||
}), _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
_createClass(_class2, [{ | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, this.attachedProps)); | ||
} | ||
}]); | ||
_createClass(_class2, [{ | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, this.attachedProps)); | ||
} | ||
}]); | ||
return _class2; | ||
}(_react.Component); | ||
return _class2; | ||
}(_react.Component); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(withAttachedProps, 'withAttachedProps'); |
@@ -27,37 +27,39 @@ 'use strict'; | ||
var withContext = function withContext(childContextTypes, getChildContext, BaseComponent) { | ||
var WithContext = function (_Component) { | ||
_inherits(WithContext, _Component); | ||
var withContext = function withContext(childContextTypes, getChildContext) { | ||
return function (BaseComponent) { | ||
var WithContext = function (_Component) { | ||
_inherits(WithContext, _Component); | ||
function WithContext() { | ||
var _Object$getPrototypeO; | ||
function WithContext() { | ||
var _Object$getPrototypeO; | ||
var _temp, _this, _ret; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, WithContext); | ||
_classCallCheck(this, WithContext); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(WithContext)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.getChildContext = function () { | ||
return getChildContext(_this.props); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(WithContext)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.getChildContext = function () { | ||
return getChildContext(_this.props); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
_createClass(WithContext, [{ | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, this.props); | ||
} | ||
}]); | ||
_createClass(WithContext, [{ | ||
key: 'render', | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, this.props); | ||
} | ||
}]); | ||
return WithContext; | ||
}(_react.Component); | ||
WithContext.childContextTypes = childContextTypes; | ||
return WithContext; | ||
}(_react.Component); | ||
WithContext.childContextTypes = childContextTypes; | ||
return WithContext; | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(withContext, 'withContext'); |
@@ -23,11 +23,13 @@ 'use strict'; | ||
var withProps = function withProps(input, BaseComponent) { | ||
var getProps = void 0; | ||
var props = (0, _isFunction2.default)(input) ? input(getProps) : input; | ||
var withProps = function withProps(input) { | ||
return function (BaseComponent) { | ||
var getProps = void 0; | ||
var props = (0, _isFunction2.default)(input) ? input(getProps) : input; | ||
return function (ownerProps) { | ||
getProps = function getProps() { | ||
return ownerProps; | ||
return function (ownerProps) { | ||
getProps = function getProps() { | ||
return ownerProps; | ||
}; | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, ownerProps, props)); | ||
}; | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, ownerProps, props)); | ||
}; | ||
@@ -34,0 +36,0 @@ }; |
@@ -35,42 +35,44 @@ 'use strict'; | ||
var withReducer = function withReducer(stateName, dispatchName, reducer, initialState, BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class2, _Component); | ||
var withReducer = function withReducer(stateName, dispatchName, reducer, initialState) { | ||
return function (BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class2, _Component); | ||
function _class2() { | ||
var _Object$getPrototypeO; | ||
function _class2() { | ||
var _Object$getPrototypeO; | ||
var _temp, _this, _ret; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, _class2); | ||
_classCallCheck(this, _class2); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { | ||
stateValue: (0, _isFunction2.default)(initialState) ? initialState(_this.props) : initialState | ||
}, _this.dispatch = function (action) { | ||
return _this.setState(function (_ref) { | ||
var stateValue = _ref.stateValue; | ||
return { | ||
stateValue: reducer(stateValue, action) | ||
}; | ||
}); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { | ||
stateValue: (0, _isFunction2.default)(initialState) ? initialState(_this.props) : initialState | ||
}, _this.dispatch = function (action) { | ||
return _this.setState(function (_ref) { | ||
var stateValue = _ref.stateValue; | ||
return { | ||
stateValue: reducer(stateValue, action) | ||
}; | ||
}); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
_createClass(_class2, [{ | ||
key: 'render', | ||
value: function render() { | ||
var _extends2; | ||
_createClass(_class2, [{ | ||
key: 'render', | ||
value: function render() { | ||
var _extends2; | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, (_extends2 = {}, _defineProperty(_extends2, stateName, this.state.stateValue), _defineProperty(_extends2, dispatchName, this.dispatch), _extends2))); | ||
} | ||
}]); | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, (_extends2 = {}, _defineProperty(_extends2, stateName, this.state.stateValue), _defineProperty(_extends2, dispatchName, this.dispatch), _extends2))); | ||
} | ||
}]); | ||
return _class2; | ||
}(_react.Component); | ||
return _class2; | ||
}(_react.Component); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(withReducer, 'withReducer'); |
@@ -35,42 +35,44 @@ 'use strict'; | ||
var withState = function withState(stateName, stateUpdaterName, initialState, BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class2, _Component); | ||
var withState = function withState(stateName, stateUpdaterName, initialState) { | ||
return function (BaseComponent) { | ||
return function (_Component) { | ||
_inherits(_class2, _Component); | ||
function _class2() { | ||
var _Object$getPrototypeO; | ||
function _class2() { | ||
var _Object$getPrototypeO; | ||
var _temp, _this, _ret; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, _class2); | ||
_classCallCheck(this, _class2); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { | ||
stateValue: (0, _isFunction2.default)(initialState) ? initialState(_this.props) : initialState | ||
}, _this.updateStateValue = function (updateFn, callback) { | ||
return _this.setState(function (_ref) { | ||
var stateValue = _ref.stateValue; | ||
return { | ||
stateValue: (0, _isFunction2.default)(updateFn) ? updateFn(stateValue) : updateFn | ||
}; | ||
}, callback); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { | ||
stateValue: (0, _isFunction2.default)(initialState) ? initialState(_this.props) : initialState | ||
}, _this.updateStateValue = function (updateFn, callback) { | ||
return _this.setState(function (_ref) { | ||
var stateValue = _ref.stateValue; | ||
return { | ||
stateValue: (0, _isFunction2.default)(updateFn) ? updateFn(stateValue) : updateFn | ||
}; | ||
}, callback); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
_createClass(_class2, [{ | ||
key: 'render', | ||
value: function render() { | ||
var _extends2; | ||
_createClass(_class2, [{ | ||
key: 'render', | ||
value: function render() { | ||
var _extends2; | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, (_extends2 = {}, _defineProperty(_extends2, stateName, this.state.stateValue), _defineProperty(_extends2, stateUpdaterName, this.updateStateValue), _extends2))); | ||
} | ||
}]); | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, (_extends2 = {}, _defineProperty(_extends2, stateName, this.state.stateValue), _defineProperty(_extends2, stateUpdaterName, this.updateStateValue), _extends2))); | ||
} | ||
}]); | ||
return _class2; | ||
}(_react.Component); | ||
return _class2; | ||
}(_react.Component); | ||
}; | ||
}; | ||
exports.default = (0, _createHelper2.default)(withState, 'withState'); |
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
75273
43
1249
6