react-adopt
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -1,2 +0,2 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=_interopDefault(require("react")),extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};function __extends(e,t){function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var __assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};function __rest(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);n.length>o;o++)0>t.indexOf(n[o])&&(r[n[o]]=e[n[o]])}return r}var values=Object.values,keys=Object.keys,assign=Object.assign;function omit(e,t){return keys(t).filter(function(t){return-1===e.indexOf(t)}).reduce(function(e,r){return __assign({},e,((n={})[r]=t[r],n));var n},{})}function prop(e,t){return t[e]}var isFn=function(e){return!!e&&"function"==typeof e},isValidRenderProp=function(e){return React.isValidElement(e)||isFn(e)};function adopt(e,t){if(!values(e).some(isValidRenderProp))throw Error("The render props object mapper just accept valid elements as value");var r=keys(e);return r.reduce(function(n,o,i){return function(a){var s=a.children,c=__rest(a,["children"]);return React.createElement(n,__assign({},c),function(n){var a=prop(o,e),u=omit(keys(c),n),p=i===r.length-1,f=function(e){var r,n=assign({},u,((r={})[o]=e,r));return isFn(s)?s(t&&isFn(t)&&p?t(n):n):null};return isFn(a)?React.createElement(a,assign({},c,n,{render:f})):React.cloneElement(a,{},f)})}},function(e){var t=e.children,r=__rest(e,["children"]);return isFn(t)&&t(r)})}var Adopt=function(e){function t(t){var r=e.call(this,t)||this;return r.Composed=adopt(t.mapper,r.props.mapProps),r}return __extends(t,e),t.prototype.render=function(){var e=this.props,t=__rest(e,["mapper"]);return React.createElement(this.Composed,__assign({},t))},t}(React.Component);exports.adopt=adopt,exports.Adopt=Adopt; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=_interopDefault(require("react")),extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};function __extends(e,t){function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var __assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};function __rest(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);n.length>o;o++)0>t.indexOf(n[o])&&(r[n[o]]=e[n[o]])}return r}var values=Object.values,keys=Object.keys,assign=Object.assign;function omit(e,t){return keys(t).filter(function(t){return-1===e.indexOf(t)}).reduce(function(e,r){return __assign({},e,((n={})[r]=t[r],n));var n},{})}function prop(e,t){return t[e]}var isFn=function(e){return!!e&&"function"==typeof e},isValidRenderProp=function(e){return React.isValidElement(e)||isFn(e)};function adopt(e,t){if(!values(e).some(isValidRenderProp))throw Error("The render props object mapper just accept valid elements as value");var r=keys(e);return r.reduce(function(n,o,i){return function(a){var s=a.children,c=__rest(a,["children"]);return React.createElement(n,__assign({},c),function(n){var a=prop(o,e),p=omit(keys(c),n),u=i===r.length-1,f=function(e){var r,n=assign({},p,((r={})[o]=e,r));return isFn(s)?s(t&&isFn(t)&&u?t(n):n):null};return isFn(a)?React.createElement(a,assign({},c,n,{render:f})):React.cloneElement(a,{},f)})}},function(e){var t=e.children,r=__rest(e,["children"]);return isFn(t)&&t(r)})}var Adopt=function(e){function t(t){var r=e.call(this,t)||this;return r.Composed=adopt(t.mapper,r.props.mapProps),r}return __extends(t,e),t.prototype.render=function(){var e=this.props,t=__rest(e,["mapper","mapProps"]);return React.createElement(this.Composed,__assign({},t))},t}(React.Component);exports.adopt=adopt,exports.Adopt=Adopt; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import React from"react";var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};function __extends(e,t){function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var __assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};function __rest(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);n.length>o;o++)0>t.indexOf(n[o])&&(r[n[o]]=e[n[o]])}return r}var values=Object.values,keys=Object.keys,assign=Object.assign;function omit(e,t){return keys(t).filter(function(t){return-1===e.indexOf(t)}).reduce(function(e,r){return __assign({},e,((n={})[r]=t[r],n));var n},{})}function prop(e,t){return t[e]}var isFn=function(e){return!!e&&"function"==typeof e},isValidRenderProp=function(e){return React.isValidElement(e)||isFn(e)};function adopt(e,t){if(!values(e).some(isValidRenderProp))throw Error("The render props object mapper just accept valid elements as value");var r=keys(e);return r.reduce(function(n,o,i){return function(a){var s=a.children,c=__rest(a,["children"]);return React.createElement(n,__assign({},c),function(n){var a=prop(o,e),p=omit(keys(c),n),u=i===r.length-1,f=function(e){var r,n=assign({},p,((r={})[o]=e,r));return isFn(s)?s(t&&isFn(t)&&u?t(n):n):null};return isFn(a)?React.createElement(a,assign({},c,n,{render:f})):React.cloneElement(a,{},f)})}},function(e){var t=e.children,r=__rest(e,["children"]);return isFn(t)&&t(r)})}var Adopt=function(e){function t(t){var r=e.call(this,t)||this;return r.Composed=adopt(t.mapper,r.props.mapProps),r}return __extends(t,e),t.prototype.render=function(){var e=this.props,t=__rest(e,["mapper"]);return React.createElement(this.Composed,__assign({},t))},t}(React.Component);export{adopt,Adopt}; | ||
import React from"react";var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};function __extends(e,t){function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var __assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};function __rest(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);n.length>o;o++)0>t.indexOf(n[o])&&(r[n[o]]=e[n[o]])}return r}var values=Object.values,keys=Object.keys,assign=Object.assign;function omit(e,t){return keys(t).filter(function(t){return-1===e.indexOf(t)}).reduce(function(e,r){return __assign({},e,((n={})[r]=t[r],n));var n},{})}function prop(e,t){return t[e]}var isFn=function(e){return!!e&&"function"==typeof e},isValidRenderProp=function(e){return React.isValidElement(e)||isFn(e)};function adopt(e,t){if(!values(e).some(isValidRenderProp))throw Error("The render props object mapper just accept valid elements as value");var r=keys(e);return r.reduce(function(n,o,i){return function(a){var s=a.children,c=__rest(a,["children"]);return React.createElement(n,__assign({},c),function(n){var a=prop(o,e),p=omit(keys(c),n),u=i===r.length-1,f=function(e){var r,n=assign({},p,((r={})[o]=e,r));return isFn(s)?s(t&&isFn(t)&&u?t(n):n):null};return isFn(a)?React.createElement(a,assign({},c,n,{render:f})):React.cloneElement(a,{},f)})}},function(e){var t=e.children,r=__rest(e,["children"]);return isFn(t)&&t(r)})}var Adopt=function(e){function t(t){var r=e.call(this,t)||this;return r.Composed=adopt(t.mapper,r.props.mapProps),r}return __extends(t,e),t.prototype.render=function(){var e=this.props,t=__rest(e,["mapper","mapProps"]);return React.createElement(this.Composed,__assign({},t))},t}(React.Component);export{adopt,Adopt}; | ||
//# sourceMappingURL=index.m.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=_interopDefault(require("react")),extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};function __extends(e,t){function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var __assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};function __rest(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);n.length>o;o++)0>t.indexOf(n[o])&&(r[n[o]]=e[n[o]])}return r}var values=Object.values,keys=Object.keys,assign=Object.assign;function omit(e,t){return keys(t).filter(function(t){return-1===e.indexOf(t)}).reduce(function(e,r){return __assign({},e,((n={})[r]=t[r],n));var n},{})}function prop(e,t){return t[e]}var isFn=function(e){return!!e&&"function"==typeof e},isValidRenderProp=function(e){return React.isValidElement(e)||isFn(e)};function adopt(e,t){if(!values(e).some(isValidRenderProp))throw Error("The render props object mapper just accept valid elements as value");var r=keys(e);return r.reduce(function(n,o,i){return function(a){var s=a.children,c=__rest(a,["children"]);return React.createElement(n,__assign({},c),function(n){var a=prop(o,e),u=omit(keys(c),n),p=i===r.length-1,f=function(e){var r,n=assign({},u,((r={})[o]=e,r));return isFn(s)?s(t&&isFn(t)&&p?t(n):n):null};return isFn(a)?React.createElement(a,assign({},c,n,{render:f})):React.cloneElement(a,{},f)})}},function(e){var t=e.children,r=__rest(e,["children"]);return isFn(t)&&t(r)})}var Adopt=function(e){function t(t){var r=e.call(this,t)||this;return r.Composed=adopt(t.mapper,r.props.mapProps),r}return __extends(t,e),t.prototype.render=function(){var e=this.props,t=__rest(e,["mapper"]);return React.createElement(this.Composed,__assign({},t))},t}(React.Component);exports.adopt=adopt,exports.Adopt=Adopt; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=_interopDefault(require("react")),extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};function __extends(e,t){function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var __assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e};function __rest(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);n.length>o;o++)0>t.indexOf(n[o])&&(r[n[o]]=e[n[o]])}return r}var values=Object.values,keys=Object.keys,assign=Object.assign;function omit(e,t){return keys(t).filter(function(t){return-1===e.indexOf(t)}).reduce(function(e,r){return __assign({},e,((n={})[r]=t[r],n));var n},{})}function prop(e,t){return t[e]}var isFn=function(e){return!!e&&"function"==typeof e},isValidRenderProp=function(e){return React.isValidElement(e)||isFn(e)};function adopt(e,t){if(!values(e).some(isValidRenderProp))throw Error("The render props object mapper just accept valid elements as value");var r=keys(e);return r.reduce(function(n,o,i){return function(a){var s=a.children,c=__rest(a,["children"]);return React.createElement(n,__assign({},c),function(n){var a=prop(o,e),p=omit(keys(c),n),u=i===r.length-1,f=function(e){var r,n=assign({},p,((r={})[o]=e,r));return isFn(s)?s(t&&isFn(t)&&u?t(n):n):null};return isFn(a)?React.createElement(a,assign({},c,n,{render:f})):React.cloneElement(a,{},f)})}},function(e){var t=e.children,r=__rest(e,["children"]);return isFn(t)&&t(r)})}var Adopt=function(e){function t(t){var r=e.call(this,t)||this;return r.Composed=adopt(t.mapper,r.props.mapProps),r}return __extends(t,e),t.prototype.render=function(){var e=this.props,t=__rest(e,["mapper","mapProps"]);return React.createElement(this.Composed,__assign({},t))},t}(React.Component);exports.adopt=adopt,exports.Adopt=Adopt; | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "react-adopt", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "umd:main": "dist/index.umd.js", |
@@ -17,3 +17,3 @@ :sunglasses: _**React Adopt -**_ Compose render props components like a pro | ||
- [Custom render and retrieving props from composed](#custom-render-and-retrieving-props-from-composed) | ||
- [Mapping props from mappers](#mapping-props-from-mappers) | ||
- [Mapping props from mapper](#mapping-props-from-mapper) | ||
- [Leading with multiple params](#leading-with-multiple-params) | ||
@@ -138,3 +138,3 @@ - [Typescript support](#typescript-support) | ||
### Mapping props from mappers | ||
### Mapping props from mapper | ||
@@ -165,2 +165,24 @@ Sometimes get properties from your mappers can be kind a boring depending how nest is the result from each mapper. To easily avoid deep nested objects or combine your results, you can map the final results into a single object using de `mapProps` function as second parameter. | ||
You can do that using the `<Adopt />` component as well: | ||
```js | ||
import { Adopt } from 'react-adopt' | ||
import { Value } from 'react-powerplug' | ||
const mapper = { | ||
greet: <Value initial="Hi" />, | ||
name: <Value initial="John" />, | ||
} | ||
const mapProps = ({ greet, name }) => ({ | ||
message: `${greet.value} ${name.value}`, | ||
}) | ||
const App = () => ( | ||
<Adopt mapper={mapper} mapProps={mapProps}> | ||
{({ message }) => /* ... */} | ||
</Adopt> | ||
) | ||
``` | ||
### Leading with multiple params | ||
@@ -167,0 +189,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
22416
272