Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reakit-system

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reakit-system - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

es/_rollupPluginBabelHelpers-5ba0a876.js

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [0.11.0](https://github.com/reakit/reakit/tree/master/packages/reakit-system/compare/reakit-system@0.10.0...reakit-system@0.11.0) (2020-04-20)
### Bug Fixes
* Fix `Composite` on IE11 ([#609](https://github.com/reakit/reakit/tree/master/packages/reakit-system/issues/609)) ([555b931](https://github.com/reakit/reakit/tree/master/packages/reakit-system/commit/555b931de003a81a635ed1d980d67f9c62fb91e0))
# [0.10.0](https://github.com/reakit/reakit/tree/master/packages/reakit-system/compare/reakit-system@0.9.0...reakit-system@0.10.0) (2020-03-30)

@@ -8,0 +19,0 @@

2

dist/reakit-system.min.js

@@ -1,1 +0,1 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],r):r((e=e||self).ReakitSystem={},e.React)}(this,(function(e,r){"use strict";function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(r){t(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e}function u(e,r){if(null==e)return{};var t,n,o={},u=Object.keys(e);for(n=0;n<u.length;n++)t=u[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}function i(e,r){for(var t={},n={},o=0,u=Object.keys(e);o<u.length;o++){var i=u[o];r.indexOf(i)>=0?t[i]=e[i]:n[i]=e[i]}return[t,n]}var a=r.createContext({}),s=function(e,t,n){void 0===n&&(n=t.children);var o=r.useContext(a);if(o.useCreateElement)return o.useCreateElement(e,t,n);if(function(e){return"function"==typeof e}(n)){t.children;return n(u(t,["children"]))}return r.createElement(e,t,n)};function c(e){return"object"==typeof e&&null!=e}function f(e,t){r.useDebugValue(e);var n=r.useContext(a);return null!=n[e]?n[e]:t}function l(e,t,n){void 0===t&&(t={}),void 0===n&&(n={});var u="use"+e+"Options";r.useDebugValue(u);var i=f(u);return i?o({},t,{},i(t,n)):t}function p(e,t,n){void 0===t&&(t={}),void 0===n&&(n={});var o="use"+e+"Props";r.useDebugValue(o);var u=f(o);return u?u(t,n):n}function v(e,r){var t={},n=e,o=Array.isArray(n),u=0;for(n=o?n:n[Symbol.iterator]();;){var i;if(o){if(u>=n.length)break;i=n[u++]}else{if((u=n.next()).done)break;i=u.value}for(var a=i,s=0,c=Object.keys(a);s<c.length;s++){var f=c[s];if(!r||r(a[f],f)){var l=t[f]||[];t[f]=[].concat(l,[a[f]])}}}return t}function y(e){for(var r=v(e,(function(e){return"function"==typeof e})),t={},n=0,o=Object.keys(r);n<o.length;n++){var u=o[n],i=r[u];t[u]=1===i.length?i[0]:i.reduce((function(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return r.apply(void 0,n.slice(0,-1).concat([e.apply(void 0,n)]))}}))}return t}function d(e){for(var r=v(e,c),t={},n=0,o=Object.keys(r);n<o.length;n++){var u=o[n],i=r[u];t[u]=Object.assign.apply(Object,[{}].concat(i))}return t}e.SystemContext=a,e.SystemProvider=function(e){var t=e.children,n=e.unstable_system;return r.createElement(a.Provider,{value:n},t)},e.createComponent=function(e){var t,n=e.as,a=e.useHook,c=e.keys,f=void 0===c?a&&a.__keys||[]:c,l=e.propsAreEqual,p=void 0===l?a&&a.__propsAreEqual:l,v=e.useCreateElement,y=void 0===v?s:v,d=function(e,r){var t=e.as,s=void 0===t?n:t,c=u(e,["as"]);if(a){var l=i(c,f),p=l[0],v=l[1],d=a(p,o({ref:r},v)),b=d.wrapElement,O=u(d,["wrapElement"]),m=s.render?s.render.__keys:s.__keys,_=m?i(c,m)[0]:{},g=y(s,o({},O,{},_));return b?b(g):g}return y(s,c)};return d.__keys=f,function(e,t){return r.memo(e,t)}((t=d,r.forwardRef(t)),p)},e.createHook=function(e){var r,t=(r=e.compose,Array.isArray(r)?r:void 0!==r?[r]:[]),n=function(r,n){return e.useOptions&&(r=e.useOptions(r,n)),e.name&&(r=l(e.name,r,n)),e.compose&&t.forEach((function(e){r=e.__useOptions(r,n)})),r},o=function(r,o,u){return void 0===r&&(r={}),void 0===o&&(o={}),void 0===u&&(u=!1),u||(r=n(r,o)),e.useProps&&(o=e.useProps(r,o)),e.name&&(o=p(e.name,r,o)),e.compose&&(e.useComposeOptions&&(r=e.useComposeOptions(r,o)),e.useComposeProps?o=e.useComposeProps(r,o):t.forEach((function(e){o=e(r,o,!0)}))),o};return o.__useOptions=n,o.__keys=[].concat(t.reduce((function(e,r){return e.push.apply(e,r.__keys||[]),e}),[]),e.useState?e.useState.__keys:[],e.keys||[]),Boolean(e.propsAreEqual||t.find((function(e){return Boolean(e.__propsAreEqual)})))&&(o.__propsAreEqual=function(r,n){var o=e.propsAreEqual&&e.propsAreEqual(r,n);if(null!=o)return o;var u=t,i=Array.isArray(u),a=0;for(u=i?u:u[Symbol.iterator]();;){var s;if(i){if(a>=u.length)break;s=u[a++]}else{if((a=u.next()).done)break;s=a.value}var f=s.__propsAreEqual,l=f&&f(r,n);if(null!=l)return l}return r.children===n.children&&function e(r,t,n){if(void 0===n&&(n=1),r===t)return!0;if(!r||!t)return!1;var o=Object.keys(r),u=Object.keys(t),i=o.length;if(u.length!==i)return!1;for(var a=0,s=o;a<s.length;a++){var f=s[a];if(r[f]!==t[f]&&!(n&&c(r[f])&&c(t[f])&&e(r[f],t[f],n-1)))return!1}return!0}(r,n)}),o},e.mergeSystem=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return Object.assign.apply(Object,[{}].concat(r,[d(r),y(r)]))},e.useCreateElement=s,e.useOptions=l,e.useProps=p,e.useToken=f,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],r):r((e=e||self).ReakitSystem={},e.React)}(this,(function(e,r){"use strict";function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(r){t(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e}function u(e,r){if(null==e)return{};var t,n,o={},u=Object.keys(e);for(n=0;n<u.length;n++)t=u[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e){var r=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return i(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}}(e)))return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function c(e,r){for(var t={},n={},o=0,u=Object.keys(e);o<u.length;o++){var i=u[o];r.indexOf(i)>=0?t[i]=e[i]:n[i]=e[i]}return[t,n]}function s(e){return r.forwardRef(e)}var f=r.createContext({}),l=function(e,t,n){void 0===n&&(n=t.children);var o=r.useContext(f);if(o.useCreateElement)return o.useCreateElement(e,t,n);if(function(e){return"function"==typeof e}(n)){t.children;return n(u(t,["children"]))}return r.createElement(e,t,n)};function p(e,t){r.useDebugValue(e);var n=r.useContext(f);return null!=n[e]?n[e]:t}function v(e,t,n){void 0===t&&(t={}),void 0===n&&(n={});var u="use"+e+"Options";r.useDebugValue(u);var i=p(u);return i?o({},t,{},i(t,n)):t}function y(e,t,n){void 0===t&&(t={}),void 0===n&&(n={});var o="use"+e+"Props";r.useDebugValue(o);var u=p(o);return u?u(t,n):n}function d(e){return"object"==typeof e&&null!=e}function m(e,r){for(var t,n={},o=a(e);!(t=o()).done;)for(var u=t.value,i=0,c=Object.keys(u);i<c.length;i++){var s=c[i];if(!r||r(u[s],s)){var f=n[s]||[];n[s]=[].concat(f,[u[s]])}}return n}function b(e){for(var r=m(e,(function(e){return"function"==typeof e})),t={},n=0,o=Object.keys(r);n<o.length;n++){var u=o[n],i=r[u];t[u]=1===i.length?i[0]:i.reduce((function(e,r){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return r.apply(void 0,n.slice(0,-1).concat([e.apply(void 0,n)]))}}))}return t}function O(e){for(var r=m(e,d),t={},n=0,o=Object.keys(r);n<o.length;n++){var u=o[n],i=r[u];t[u]=Object.assign.apply(Object,[{}].concat(i))}return t}e.SystemContext=f,e.SystemProvider=function(e){var t=e.children,n=e.unstable_system;return r.createElement(f.Provider,{value:n},t)},e.createComponent=function(e){var t,n,i=e.as,a=e.useHook,f=e.keys,p=void 0===f?(null==a?void 0:a.__keys)||[]:f,v=e.useCreateElement,y=void 0===v?l:v,d=e.memo,m=function(e,r){var t=e.as,n=void 0===t?i:t,s=u(e,["as"]);if(a){var f,l=c(s,p),v=l[0],d=l[1],m=a(v,o({ref:r},d)),b=m.wrapElement,O=u(m,["wrapElement"]),g=(null===(f=n.render)||void 0===f?void 0:f.__keys)||n.__keys,j=g&&c(s,g)[0],h=j?o({},O,{},j):O,_=y(n,h);return b?b(_):_}return y(n,s)};return m.__keys=p,d?(t=s(m),r.memo(t,n)):s(m)},e.createHook=function(e){var r,t,n=(t=e.compose,Array.isArray(t)?t:void 0!==t?[t]:[]),o=function(r,t){if(e.useOptions&&(r=e.useOptions(r,t)),e.name&&(r=v(e.name,r,t)),e.compose)for(var o,u=a(n);!(o=u()).done;){r=o.value.__useOptions(r,t)}return r},u=function(r,t,u){if(void 0===r&&(r={}),void 0===t&&(t={}),void 0===u&&(u=!1),u||(r=o(r,t)),e.useProps&&(t=e.useProps(r,t)),e.name&&(t=y(e.name,r,t)),e.compose)if(e.useComposeOptions&&(r=e.useComposeOptions(r,t)),e.useComposeProps)t=e.useComposeProps(r,t);else for(var i,c=a(n);!(i=c()).done;){t=(0,i.value)(r,t,!0)}return t||{}};u.__useOptions=o;var i=n.reduce((function(e,r){return e.push.apply(e,r.__keys||[]),e}),[]);return u.__keys=[].concat(i,(null===(r=e.useState)||void 0===r?void 0:r.__keys)||[],e.keys||[]),u},e.mergeSystem=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return Object.assign.apply(Object,[{}].concat(r,[O(r),b(r)]))},e.useCreateElement=l,e.useOptions=v,e.useProps=y,e.useToken=p,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,7 +0,11 @@

import { memo as memo$1, forwardRef as forwardRef$1 } from 'react';
import { forwardRef as forwardRef$1, memo as memo$1 } from 'react';
import './SystemContext.js';
import { a as _objectWithoutPropertiesLoose, _ as _objectSpread2 } from './_rollupPluginBabelHelpers-ce04ac6e.js';
import { a as _objectWithoutPropertiesLoose, _ as _objectSpread2 } from './_rollupPluginBabelHelpers-5ba0a876.js';
import { useCreateElement } from './useCreateElement.js';
import { splitProps } from 'reakit-utils/splitProps';
function forwardRef(component) {
return forwardRef$1(component);
}
function memo(component, propsAreEqual) {

@@ -11,6 +15,2 @@ return memo$1(component, propsAreEqual);

function forwardRef(component) {
return forwardRef$1(component);
}
/**

@@ -30,7 +30,6 @@ * Creates a React component.

_ref$keys = _ref.keys,
keys = _ref$keys === void 0 ? useHook && useHook.__keys || [] : _ref$keys,
_ref$propsAreEqual = _ref.propsAreEqual,
propsAreEqual = _ref$propsAreEqual === void 0 ? useHook && useHook.__propsAreEqual : _ref$propsAreEqual,
keys = _ref$keys === void 0 ? (useHook === null || useHook === void 0 ? void 0 : useHook.__keys) || [] : _ref$keys,
_ref$useCreateElement = _ref.useCreateElement,
useCreateElement$1 = _ref$useCreateElement === void 0 ? useCreateElement : _ref$useCreateElement;
useCreateElement$1 = _ref$useCreateElement === void 0 ? useCreateElement : _ref$useCreateElement,
shouldMemo = _ref.memo;

@@ -43,2 +42,4 @@ var Comp = function Comp(_ref2, ref) {

if (useHook) {
var _as$render;
var _splitProps = splitProps(props, keys),

@@ -55,6 +56,7 @@ _options = _splitProps[0],

var asKeys = as.render ? as.render.__keys : as.__keys;
var asOptions = asKeys ? splitProps(props, asKeys)[0] : {};
var asKeys = ((_as$render = as.render) === null || _as$render === void 0 ? void 0 : _as$render.__keys) || as.__keys;
var asOptions = asKeys && splitProps(props, asKeys)[0];
var allProps = asOptions ? _objectSpread2({}, elementProps, {}, asOptions) : elementProps;
var _element = useCreateElement$1(as, _objectSpread2({}, elementProps, {}, asOptions));
var _element = useCreateElement$1(as, allProps);

@@ -77,5 +79,9 @@ if (wrapElement) {

return memo(forwardRef(Comp), propsAreEqual);
if (shouldMemo) {
return memo(forwardRef(Comp));
}
return forwardRef(Comp);
}
export { createComponent };

@@ -5,32 +5,6 @@ import 'react';

import { useProps } from './useProps.js';
import './_rollupPluginBabelHelpers-ce04ac6e.js';
import { b as _createForOfIteratorHelperLoose } from './_rollupPluginBabelHelpers-5ba0a876.js';
import { useOptions } from './useOptions.js';
import { isObject } from 'reakit-utils/isObject';
import { toArray } from 'reakit-utils/toArray';
function deepEqual(objA, objB, depth) {
if (depth === void 0) {
depth = 1;
}
if (objA === objB) return true;
if (!objA || !objB) return false;
var aKeys = Object.keys(objA);
var bKeys = Object.keys(objB);
var length = aKeys.length;
if (bKeys.length !== length) return false;
for (var _i = 0, _aKeys = aKeys; _i < _aKeys.length; _i++) {
var key = _aKeys[_i];
if (objA[key] !== objB[key]) {
if (!depth || !isObject(objA[key]) || !isObject(objB[key]) || !deepEqual(objA[key], objB[key], depth - 1)) {
return false;
}
}
}
return true;
}
/**

@@ -48,5 +22,5 @@ * Creates a React custom hook that will return component props.

* ...htmlProps,
* href: options.url
* href: options.url,
* };
* }
* },
* });

@@ -62,2 +36,4 @@ *

function createHook(options) {
var _options$useState;
var composedHooks = toArray(options.compose);

@@ -78,5 +54,6 @@

if (options.compose) {
composedHooks.forEach(function (hook) {
for (var _iterator = _createForOfIteratorHelperLoose(composedHooks), _step; !(_step = _iterator()).done;) {
var hook = _step.value;
hookOptions = hook.__useOptions(hookOptions, htmlProps);
});
}
}

@@ -123,11 +100,20 @@

} else {
composedHooks.forEach(function (hook) {
for (var _iterator2 = _createForOfIteratorHelperLoose(composedHooks), _step2; !(_step2 = _iterator2()).done;) {
var hook = _step2.value;
htmlProps = hook(hookOptions, htmlProps, true);
});
}
}
}
return htmlProps;
return htmlProps || {};
};
useHook.__useOptions = __useOptions;
var composedKeys = composedHooks.reduce(function (keys, hook) {
keys.push.apply(keys, hook.__keys || []);
return keys;
}, []); // It's used by createComponent to split option props (keys) and html props
useHook.__keys = [].concat(composedKeys, ((_options$useState = options.useState) === null || _options$useState === void 0 ? void 0 : _options$useState.__keys) || [], options.keys || []);
if (process.env.NODE_ENV !== "production" && options.name) {

@@ -139,50 +125,2 @@ Object.defineProperty(useHook, "name", {

useHook.__useOptions = __useOptions; // It's used by createComponent to split option props (keys) and html props
useHook.__keys = [].concat(composedHooks.reduce(function (allKeys, hook) {
allKeys.push.apply(allKeys, hook.__keys || []);
return allKeys;
}, []), options.useState ? options.useState.__keys : [], options.keys || []);
var hasPropsAreEqual = Boolean(options.propsAreEqual || composedHooks.find(function (hook) {
return Boolean(hook.__propsAreEqual);
}));
if (hasPropsAreEqual) {
useHook.__propsAreEqual = function (prev, next) {
var result = options.propsAreEqual && options.propsAreEqual(prev, next);
if (result != null) {
return result;
}
for (var _iterator = composedHooks, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var hook = _ref;
var propsAreEqual = hook.__propsAreEqual;
var hookResult = propsAreEqual && propsAreEqual(prev, next);
if (hookResult != null) {
return hookResult;
}
} // @ts-ignore
if (prev.children !== next.children) {
return false;
}
return deepEqual(prev, next);
};
}
return useHook;

@@ -189,0 +127,0 @@ }

@@ -5,3 +5,3 @@ import 'react';

export { useProps } from './useProps.js';
import './_rollupPluginBabelHelpers-ce04ac6e.js';
import './_rollupPluginBabelHelpers-5ba0a876.js';
export { useOptions } from './useOptions.js';

@@ -8,0 +8,0 @@ export { useCreateElement } from './useCreateElement.js';

@@ -0,1 +1,2 @@

import { b as _createForOfIteratorHelperLoose } from './_rollupPluginBabelHelpers-5ba0a876.js';
import { isObject } from 'reakit-utils/isObject';

@@ -9,19 +10,8 @@

for (var _iterator = objects, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var object = _ref;
for (var _iterator = _createForOfIteratorHelperLoose(objects), _step; !(_step = _iterator()).done;) {
var object = _step.value;
var keys = Object.keys(object);
for (var _i2 = 0, _keys = keys; _i2 < _keys.length; _i2++) {
var _key = _keys[_i2];
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
var _key = _keys[_i];
// eslint-disable-next-line no-continue

@@ -85,3 +75,3 @@ if (filter && !filter(object[_key], _key)) continue;

* const mySystem = {
* useButtonProps() {}
* useButtonProps() {},
* };

@@ -88,0 +78,0 @@ *

@@ -28,3 +28,3 @@ import { createElement } from 'react';

system = _ref.unstable_system;
return createElement(SystemContext.Provider, {
return /*#__PURE__*/createElement(SystemContext.Provider, {
value: system

@@ -31,0 +31,0 @@ }, children);

import { useContext, createElement } from 'react';
import { SystemContext } from './SystemContext.js';
import { a as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ce04ac6e.js';
import { a as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-5ba0a876.js';

@@ -25,3 +25,3 @@ function isRenderProp(children) {

* return React.createElement(type, props, children);
* }
* },
* };

@@ -28,0 +28,0 @@ *

import { useDebugValue } from 'react';
import './SystemContext.js';
import { useToken } from './useToken.js';
import { _ as _objectSpread2 } from './_rollupPluginBabelHelpers-ce04ac6e.js';
import { _ as _objectSpread2 } from './_rollupPluginBabelHelpers-5ba0a876.js';

@@ -18,5 +18,5 @@ /**

* ...options,
* url: htmlProps.href
* url: htmlProps.href,
* };
* }
* },
* };

@@ -23,0 +23,0 @@ *

@@ -16,5 +16,5 @@ import { useDebugValue } from 'react';

* ...htmlProps,
* href: options.url
* href: options.url,
* };
* }
* },
* };

@@ -21,0 +21,0 @@ *

@@ -13,3 +13,3 @@ import { useDebugValue, useContext } from 'react';

* const system = {
* token: "value"
* token: "value",
* };

@@ -16,0 +16,0 @@ *

@@ -7,6 +7,10 @@ 'use strict';

require('./SystemContext.js');
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-baac11a7.js');
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-770e06b1.js');
var useCreateElement = require('./useCreateElement.js');
var splitProps = require('reakit-utils/splitProps');
function forwardRef(component) {
return React.forwardRef(component);
}
function memo(component, propsAreEqual) {

@@ -16,6 +20,2 @@ return React.memo(component, propsAreEqual);

function forwardRef(component) {
return React.forwardRef(component);
}
/**

@@ -35,7 +35,6 @@ * Creates a React component.

_ref$keys = _ref.keys,
keys = _ref$keys === void 0 ? useHook && useHook.__keys || [] : _ref$keys,
_ref$propsAreEqual = _ref.propsAreEqual,
propsAreEqual = _ref$propsAreEqual === void 0 ? useHook && useHook.__propsAreEqual : _ref$propsAreEqual,
keys = _ref$keys === void 0 ? (useHook === null || useHook === void 0 ? void 0 : useHook.__keys) || [] : _ref$keys,
_ref$useCreateElement = _ref.useCreateElement,
useCreateElement$1 = _ref$useCreateElement === void 0 ? useCreateElement.useCreateElement : _ref$useCreateElement;
useCreateElement$1 = _ref$useCreateElement === void 0 ? useCreateElement.useCreateElement : _ref$useCreateElement,
shouldMemo = _ref.memo;

@@ -48,2 +47,4 @@ var Comp = function Comp(_ref2, ref) {

if (useHook) {
var _as$render;
var _splitProps = splitProps.splitProps(props, keys),

@@ -60,6 +61,7 @@ _options = _splitProps[0],

var asKeys = as.render ? as.render.__keys : as.__keys;
var asOptions = asKeys ? splitProps.splitProps(props, asKeys)[0] : {};
var asKeys = ((_as$render = as.render) === null || _as$render === void 0 ? void 0 : _as$render.__keys) || as.__keys;
var asOptions = asKeys && splitProps.splitProps(props, asKeys)[0];
var allProps = asOptions ? _rollupPluginBabelHelpers._objectSpread2({}, elementProps, {}, asOptions) : elementProps;
var _element = useCreateElement$1(as, _rollupPluginBabelHelpers._objectSpread2({}, elementProps, {}, asOptions));
var _element = useCreateElement$1(as, allProps);

@@ -82,5 +84,9 @@ if (wrapElement) {

return memo(forwardRef(Comp), propsAreEqual);
if (shouldMemo) {
return memo(forwardRef(Comp));
}
return forwardRef(Comp);
}
exports.createComponent = createComponent;

@@ -9,32 +9,6 @@ 'use strict';

var useProps = require('./useProps.js');
require('./_rollupPluginBabelHelpers-baac11a7.js');
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-770e06b1.js');
var useOptions = require('./useOptions.js');
var isObject = require('reakit-utils/isObject');
var toArray = require('reakit-utils/toArray');
function deepEqual(objA, objB, depth) {
if (depth === void 0) {
depth = 1;
}
if (objA === objB) return true;
if (!objA || !objB) return false;
var aKeys = Object.keys(objA);
var bKeys = Object.keys(objB);
var length = aKeys.length;
if (bKeys.length !== length) return false;
for (var _i = 0, _aKeys = aKeys; _i < _aKeys.length; _i++) {
var key = _aKeys[_i];
if (objA[key] !== objB[key]) {
if (!depth || !isObject.isObject(objA[key]) || !isObject.isObject(objB[key]) || !deepEqual(objA[key], objB[key], depth - 1)) {
return false;
}
}
}
return true;
}
/**

@@ -52,5 +26,5 @@ * Creates a React custom hook that will return component props.

* ...htmlProps,
* href: options.url
* href: options.url,
* };
* }
* },
* });

@@ -66,2 +40,4 @@ *

function createHook(options) {
var _options$useState;
var composedHooks = toArray.toArray(options.compose);

@@ -82,5 +58,6 @@

if (options.compose) {
composedHooks.forEach(function (hook) {
for (var _iterator = _rollupPluginBabelHelpers._createForOfIteratorHelperLoose(composedHooks), _step; !(_step = _iterator()).done;) {
var hook = _step.value;
hookOptions = hook.__useOptions(hookOptions, htmlProps);
});
}
}

@@ -127,11 +104,20 @@

} else {
composedHooks.forEach(function (hook) {
for (var _iterator2 = _rollupPluginBabelHelpers._createForOfIteratorHelperLoose(composedHooks), _step2; !(_step2 = _iterator2()).done;) {
var hook = _step2.value;
htmlProps = hook(hookOptions, htmlProps, true);
});
}
}
}
return htmlProps;
return htmlProps || {};
};
useHook.__useOptions = __useOptions;
var composedKeys = composedHooks.reduce(function (keys, hook) {
keys.push.apply(keys, hook.__keys || []);
return keys;
}, []); // It's used by createComponent to split option props (keys) and html props
useHook.__keys = [].concat(composedKeys, ((_options$useState = options.useState) === null || _options$useState === void 0 ? void 0 : _options$useState.__keys) || [], options.keys || []);
if (process.env.NODE_ENV !== "production" && options.name) {

@@ -143,50 +129,2 @@ Object.defineProperty(useHook, "name", {

useHook.__useOptions = __useOptions; // It's used by createComponent to split option props (keys) and html props
useHook.__keys = [].concat(composedHooks.reduce(function (allKeys, hook) {
allKeys.push.apply(allKeys, hook.__keys || []);
return allKeys;
}, []), options.useState ? options.useState.__keys : [], options.keys || []);
var hasPropsAreEqual = Boolean(options.propsAreEqual || composedHooks.find(function (hook) {
return Boolean(hook.__propsAreEqual);
}));
if (hasPropsAreEqual) {
useHook.__propsAreEqual = function (prev, next) {
var result = options.propsAreEqual && options.propsAreEqual(prev, next);
if (result != null) {
return result;
}
for (var _iterator = composedHooks, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var hook = _ref;
var propsAreEqual = hook.__propsAreEqual;
var hookResult = propsAreEqual && propsAreEqual(prev, next);
if (hookResult != null) {
return hookResult;
}
} // @ts-ignore
if (prev.children !== next.children) {
return false;
}
return deepEqual(prev, next);
};
}
return useHook;

@@ -193,0 +131,0 @@ }

@@ -9,3 +9,3 @@ 'use strict';

var useProps = require('./useProps.js');
require('./_rollupPluginBabelHelpers-baac11a7.js');
require('./_rollupPluginBabelHelpers-770e06b1.js');
var useOptions = require('./useOptions.js');

@@ -12,0 +12,0 @@ var useCreateElement = require('./useCreateElement.js');

@@ -5,2 +5,3 @@ 'use strict';

var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-770e06b1.js');
var isObject = require('reakit-utils/isObject');

@@ -14,19 +15,8 @@

for (var _iterator = objects, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var object = _ref;
for (var _iterator = _rollupPluginBabelHelpers._createForOfIteratorHelperLoose(objects), _step; !(_step = _iterator()).done;) {
var object = _step.value;
var keys = Object.keys(object);
for (var _i2 = 0, _keys = keys; _i2 < _keys.length; _i2++) {
var _key = _keys[_i2];
for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
var _key = _keys[_i];
// eslint-disable-next-line no-continue

@@ -90,3 +80,3 @@ if (filter && !filter(object[_key], _key)) continue;

* const mySystem = {
* useButtonProps() {}
* useButtonProps() {},
* };

@@ -93,0 +83,0 @@ *

@@ -32,3 +32,3 @@ 'use strict';

system = _ref.unstable_system;
return React.createElement(SystemContext.SystemContext.Provider, {
return /*#__PURE__*/React.createElement(SystemContext.SystemContext.Provider, {
value: system

@@ -35,0 +35,0 @@ }, children);

@@ -7,3 +7,3 @@ 'use strict';

var SystemContext = require('./SystemContext.js');
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-baac11a7.js');
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-770e06b1.js');

@@ -30,3 +30,3 @@ function isRenderProp(children) {

* return React.createElement(type, props, children);
* }
* },
* };

@@ -33,0 +33,0 @@ *

@@ -8,3 +8,3 @@ 'use strict';

var useToken = require('./useToken.js');
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-baac11a7.js');
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-770e06b1.js');

@@ -23,5 +23,5 @@ /**

* ...options,
* url: htmlProps.href
* url: htmlProps.href,
* };
* }
* },
* };

@@ -28,0 +28,0 @@ *

@@ -20,5 +20,5 @@ 'use strict';

* ...htmlProps,
* href: options.url
* href: options.url,
* };
* }
* },
* };

@@ -25,0 +25,0 @@ *

@@ -17,3 +17,3 @@ 'use strict';

* const system = {
* token: "value"
* token: "value",
* };

@@ -20,0 +20,0 @@ *

{
"name": "reakit-system",
"version": "0.10.0",
"version": "0.11.0",
"description": "Reakit System utils",

@@ -34,3 +34,3 @@ "sideEffects": false,

"dependencies": {
"reakit-utils": "^0.10.0"
"reakit-utils": "^0.11.0"
},

@@ -41,3 +41,3 @@ "peerDependencies": {

},
"gitHead": "49db6c007ea82fddf959448328b5f5d572defa40"
"gitHead": "7289c202a077e3651e69bf392e1a51ee26622c90"
}

@@ -54,5 +54,5 @@ # reakit-system

- `options.useHook`
- `options.keys` (optional, default `useHook&&useHook.__keys||[]`)
- `options.propsAreEqual` (optional, default `useHook&&useHook.__propsAreEqual`)
- `options.keys` (optional, default `useHook?.__keys||[]`)
- `options.useCreateElement` (optional, default `defaultUseCreateElement`)
- `options.memo`

@@ -86,5 +86,5 @@ #### Examples

...htmlProps,
href: options.url
href: options.url,
};
}
},
});

@@ -114,3 +114,3 @@

const mySystem = {
useButtonProps() {}
useButtonProps() {},
};

@@ -183,3 +183,3 @@

return React.createElement(type, props, children);
}
},
};

@@ -223,5 +223,5 @@

...options,
url: htmlProps.href
url: htmlProps.href,
};
}
},
};

@@ -267,5 +267,5 @@

...htmlProps,
href: options.url
href: options.url,
};
}
},
};

@@ -306,3 +306,3 @@

const system = {
token: "value"
token: "value",
};

@@ -309,0 +309,0 @@

@@ -11,4 +11,4 @@ import { reduceObjects } from "../reduceObjects";

).toEqual({
a: ["a"]
a: ["a"],
});
});

@@ -1,8 +0,7 @@

// TODO: Refactor
import * as React from "react";
import { As, PropsWithAs } from "reakit-utils/types";
import { splitProps } from "reakit-utils/splitProps";
import { memo } from "./__utils/memo";
import { forwardRef } from "./__utils/forwardRef";
import { useCreateElement as defaultUseCreateElement } from "./useCreateElement";
import { memo } from "./__utils/memo";

@@ -17,3 +16,2 @@ type BoxHTMLProps = React.HTMLAttributes<any> &

__keys?: ReadonlyArray<any>;
__propsAreEqual?: (prev: O, next: O) => boolean;
};

@@ -25,3 +23,3 @@

keys?: ReadonlyArray<any>;
propsAreEqual?: (prev: O, next: O) => boolean;
memo?: boolean;
useCreateElement?: typeof defaultUseCreateElement;

@@ -54,9 +52,9 @@ };

useHook,
keys = (useHook && useHook.__keys) || [],
propsAreEqual = useHook && useHook.__propsAreEqual,
useCreateElement = defaultUseCreateElement
keys = useHook?.__keys || [],
useCreateElement = defaultUseCreateElement,
memo: shouldMemo,
}: Options<T, O>) {
const Comp = (
{ as = type, ...props }: PropsWithAs<O, T>,
ref: React.Ref<any>
ref: React.Ref<T>
) => {

@@ -67,8 +65,11 @@ if (useHook) {

ref,
...htmlProps
...htmlProps,
});
// @ts-ignore
const asKeys = as.render ? as.render.__keys : as.__keys;
const asOptions = asKeys ? splitProps(props, asKeys)[0] : {};
const element = useCreateElement(as, { ...elementProps, ...asOptions });
const asKeys = as.render?.__keys || as.__keys;
const asOptions = asKeys && splitProps(props, asKeys)[0];
const allProps = asOptions
? { ...elementProps, ...asOptions }
: elementProps;
const element = useCreateElement(as, allProps);
if (wrapElement) {

@@ -88,3 +89,7 @@ return wrapElement(element);

return memo(forwardRef(Comp as Component<T, O>), propsAreEqual);
if (shouldMemo) {
return memo(forwardRef(Comp as Component<T, O>));
}
return forwardRef(Comp as Component<T, O>);
}
import { toArray } from "reakit-utils/toArray";
import { deepEqual } from "./__utils/deepEqual";
import { useOptions } from "./useOptions";

@@ -10,3 +9,2 @@ import { useProps } from "./useProps";

__useOptions: (options: O, htmlProps: P) => O;
__propsAreEqual?: (prev: O & P, next: O & P) => boolean;
};

@@ -22,3 +20,2 @@

useComposeProps?: (options: O, htmlProps: P) => P;
propsAreEqual?: (prev: O & P, next: O & P) => boolean | undefined | null;
keys?: ReadonlyArray<keyof O>;

@@ -39,5 +36,5 @@ };

* ...htmlProps,
* href: options.url
* href: options.url,
* };
* }
* },
* });

@@ -66,7 +63,6 @@ *

if (options.compose) {
composedHooks.forEach(hook => {
for (const hook of composedHooks) {
hookOptions = hook.__useOptions(hookOptions, htmlProps);
});
}
}
return hookOptions;

@@ -99,55 +95,28 @@ };

} else {
composedHooks.forEach(hook => {
for (const hook of composedHooks) {
htmlProps = hook(hookOptions, htmlProps, true);
});
}
}
}
return htmlProps;
return htmlProps || ({} as P);
};
if (process.env.NODE_ENV !== "production" && options.name) {
Object.defineProperty(useHook, "name", {
value: `use${options.name}`
});
}
useHook.__useOptions = __useOptions;
const composedKeys = composedHooks.reduce((keys, hook) => {
keys.push(...(hook.__keys || []));
return keys;
}, [] as string[]);
// It's used by createComponent to split option props (keys) and html props
useHook.__keys = [
...composedHooks.reduce((allKeys, hook) => {
allKeys.push(...(hook.__keys || []));
return allKeys;
}, [] as string[]),
...(options.useState ? options.useState.__keys : []),
...(options.keys || [])
...composedKeys,
...(options.useState?.__keys || []),
...(options.keys || []),
];
const hasPropsAreEqual = Boolean(
options.propsAreEqual ||
composedHooks.find(hook => Boolean(hook.__propsAreEqual))
);
if (hasPropsAreEqual) {
useHook.__propsAreEqual = (prev, next) => {
const result = options.propsAreEqual && options.propsAreEqual(prev, next);
if (result != null) {
return result;
}
for (const hook of composedHooks) {
const propsAreEqual = hook.__propsAreEqual;
const hookResult = propsAreEqual && propsAreEqual(prev, next);
if (hookResult != null) {
return hookResult;
}
}
// @ts-ignore
if (prev.children !== next.children) {
return false;
}
return deepEqual(prev, next);
};
if (process.env.NODE_ENV !== "production" && options.name) {
Object.defineProperty(useHook, "name", {
value: `use${options.name}`,
});
}

@@ -154,0 +123,0 @@

@@ -7,3 +7,3 @@ import { isObject } from "reakit-utils/isObject";

function mergeFunctionsInObjects(objects: Array<Record<string, any>>) {
const object = reduceObjects(objects, value => typeof value === "function");
const object = reduceObjects(objects, (value) => typeof value === "function");
const keys = Object.keys(object);

@@ -47,3 +47,3 @@ const result: Record<string, any> = {};

* const mySystem = {
* useButtonProps() {}
* useButtonProps() {},
* };

@@ -50,0 +50,0 @@ *

@@ -22,3 +22,3 @@ import * as React from "react";

* return React.createElement(type, props, children);
* }
* },
* };

@@ -25,0 +25,0 @@ *

@@ -16,5 +16,5 @@ import * as React from "react";

* ...options,
* url: htmlProps.href
* url: htmlProps.href,
* };
* }
* },
* };

@@ -21,0 +21,0 @@ *

@@ -15,5 +15,5 @@ import * as React from "react";

* ...htmlProps,
* href: options.url
* href: options.url,
* };
* }
* },
* };

@@ -20,0 +20,0 @@ *

@@ -13,3 +13,3 @@ import * as React from "react";

* const system = {
* token: "value"
* token: "value",
* };

@@ -16,0 +16,0 @@ *

@@ -10,3 +10,2 @@ import * as React from "react";

__keys?: ReadonlyArray<any>;
__propsAreEqual?: (prev: O, next: O) => boolean;
};

@@ -17,3 +16,3 @@ declare type Options<T extends As, O> = {

keys?: ReadonlyArray<any>;
propsAreEqual?: (prev: O, next: O) => boolean;
memo?: boolean;
useCreateElement?: typeof defaultUseCreateElement;

@@ -37,3 +36,3 @@ };

*/
export declare function createComponent<T extends As, O>({ as: type, useHook, keys, propsAreEqual, useCreateElement }: Options<T, O>): Component<T, O>;
export declare function createComponent<T extends As, O>({ as: type, useHook, keys, useCreateElement, memo: shouldMemo, }: Options<T, O>): Component<T, O>;
export {};

@@ -5,3 +5,2 @@ declare type Hook<O = any, P = any> = {

__useOptions: (options: O, htmlProps: P) => O;
__propsAreEqual?: (prev: O & P, next: O & P) => boolean;
};

@@ -19,3 +18,2 @@ declare type CreateHookOptions<O, P> = {

useComposeProps?: (options: O, htmlProps: P) => P;
propsAreEqual?: (prev: O & P, next: O & P) => boolean | undefined | null;
keys?: ReadonlyArray<keyof O>;

@@ -35,5 +33,5 @@ };

* ...htmlProps,
* href: options.url
* href: options.url,
* };
* }
* },
* });

@@ -40,0 +38,0 @@ *

@@ -12,3 +12,3 @@ import { UnionToIntersection } from "reakit-utils/types";

* const mySystem = {
* useButtonProps() {}
* useButtonProps() {},
* };

@@ -15,0 +15,0 @@ *

@@ -28,2 +28,2 @@ import * as React from "react";

*/
export declare function SystemProvider({ children, unstable_system: system }: SystemProviderProps): JSX.Element;
export declare function SystemProvider({ children, unstable_system: system, }: SystemProviderProps): JSX.Element;

@@ -18,3 +18,3 @@ import * as React from "react";

* return React.createElement(type, props, children);
* }
* },
* };

@@ -21,0 +21,0 @@ *

@@ -14,5 +14,5 @@ import * as React from "react";

* ...options,
* url: htmlProps.href
* url: htmlProps.href,
* };
* }
* },
* };

@@ -19,0 +19,0 @@ *

@@ -13,5 +13,5 @@ import * as React from "react";

* ...htmlProps,
* href: options.url
* href: options.url,
* };
* }
* },
* };

@@ -18,0 +18,0 @@ *

@@ -10,3 +10,3 @@ /**

* const system = {
* token: "value"
* token: "value",
* };

@@ -13,0 +13,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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc