reakit-utils
Advanced tools
Comparing version 0.6.4 to 0.6.5
@@ -6,2 +6,18 @@ # Change Log | ||
## [0.6.5](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/compare/reakit-utils@0.6.4...reakit-utils@0.6.5) (2019-09-25) | ||
### Bug Fixes | ||
* Replace IE11 incompatible DOM features ([#443](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/issues/443)) ([8837557](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/commit/8837557)), closes [#360](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/issues/360) | ||
### Features | ||
* Show warnings on console whenever it gets called, not only once ([efaa95e](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/commit/efaa95e)) | ||
## [0.6.4](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/compare/reakit-utils@0.6.3...reakit-utils@0.6.4) (2019-09-19) | ||
@@ -8,0 +24,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e=e||self).ReakitUtils={},e.React)}(this,function(e,n){"use strict";function t(e){return"object"==typeof e&&null!=e}function r(e,n){return-1===n?e:[].concat(e.slice(0,n),e.slice(n+1))}var o="input, select, textarea, a[href], button, [tabindex], audio[controls], video[controls], [contenteditable]:not([contenteditable=false])";function u(e){return e instanceof HTMLElement}function i(e){return e.hasAttribute("tabindex")}function a(e){if(!u(e))return!1;if(function e(n){return!(!n.parentElement||!e(n.parentElement))||n.hidden}(e))return!1;if(function(e){return Boolean(e.disabled)}(e))return!1;var n=e.localName;if(["input","select","textarea","button"].indexOf(n)>=0)return!0;var t={a:function(){return e.hasAttribute("href")},audio:function(){return e.hasAttribute("controls")},video:function(){return e.hasAttribute("controls")}};return n in t?t[n]():!!function(e){var n=e.getAttribute("contenteditable");return"false"!==n&&null!=n}(e)||i(e)}function f(e){return u(e)&&a(e)&&!function(e){return i(e)&&e.tabIndex<0}(e)}function c(e){var n=Array.from(e.querySelectorAll(o));return n.unshift(e),n.filter(a)}function l(e,n){var t=Array.from(e.querySelectorAll(o)),r=t.filter(f);return f(e)&&r.unshift(e),!r.length&&n?t:r}function s(e,n){var t=c(e),r=t.indexOf(document.activeElement),o=t.slice(r+1);return o.find(f)||t.find(f)||(n?o[0]:null)}function v(e,n){var t=c(e).reverse(),r=t.indexOf(document.activeElement),o=t.slice(r+1);return o.find(f)||t.find(f)||(n?o[0]:null)}function d(e){return document.activeElement===e}var b="id-",y=n.createContext(function(e){return void 0===e&&(e=b),""+e+Math.random().toString(32).substr(2,6)});e.IdProvider=function(e){var t=e.children,r=e.unstable_prefix,o=void 0===r?"":r,u=n.useRef(0),i=n.useMemo(function(){return function(e){return void 0===e&&(e=b),""+o+e+ ++u.current}},[o]);return n.createElement(y.Provider,{value:i},t)},e.createOnKeyDown=function(e){var n=void 0===e?{}:e,t=n.keyMap,r=n.onKey,o=n.stopPropagation,u=n.onKeyDown,i=n.shouldKeyDown,a=void 0===i?function(){return!0}:i,f=n.preventDefault,c=void 0===f||f;return function(e){if(t){var n="function"==typeof t?t(e):t,i="function"==typeof c?c(e):c,f="function"==typeof o?o(e):o;if(e.key in n){var l=n[e.key];if("function"==typeof l&&a(e))return i&&e.preventDefault(),f&&e.stopPropagation(),r&&r(e),void l(e)}u&&u(e)}}},e.cx=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.filter(Boolean).join(" ")||void 0},e.focusNextTabbableIn=function(e,n){var t=s(e,n);t&&u(t)&&t.focus()},e.focusPreviousTabbableIn=function(e,n){var t=v(e,n);t&&u(t)&&t.focus()},e.forceFocus=function(e,n){var t=void 0===n?{}:n,r=t.isActive,o=void 0===r?d:r,u=t.preventScroll;return o(e)?-1:(e.focus({preventScroll:u}),o(e)?-1:requestAnimationFrame(function(){e.focus({preventScroll:u})}))},e.getAllFocusableIn=c,e.getAllTabbableIn=l,e.getFirstFocusableIn=function(e){var n=c(e);return n.length?n[0]:null},e.getFirstTabbableIn=function(e,n){return l(e,n)[0]||null},e.getLastTabbableIn=function(e,n){var t=l(e,n);return t[t.length-1]||null},e.getNextTabbableIn=s,e.getPreviousTabbableIn=v,e.hasFocusWithin=function(e){return!!document.activeElement&&e.contains(document.activeElement)},e.isEmpty=function(e){return Array.isArray(e)?!e.length:t(e)?!Object.keys(e).length:null==e||""===e},e.isFocusable=a,e.isInteger=function(e){return"number"==typeof e?Math.floor(e)===e:String(Math.floor(Number(e)))===e},e.isObject=t,e.isPromise=function(e){return Boolean(e&&e.then)},e.isTabbable=f,e.mergeRefs=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=n.filter(Boolean);return r.length?0===r.length?r[0]:function(e){var n=r,t=Array.isArray(n),o=0;for(n=t?n:n[Symbol.iterator]();;){var u;if(t){if(o>=n.length)break;u=n[o++]}else{if((o=n.next()).done)break;u=o.value}var i=u;"function"==typeof i?i(e):i&&(i.current=e)}}:null},e.omit=function(e,n){for(var t=Object.keys(e),r={},o=0;o<t.length;o+=1){var u=t[o];-1===n.indexOf(u)&&(r[u]=e[u])}return r},e.pick=function(e,n){for(var t=Object.keys(e),r={},o=0;o<t.length;o+=1){var u=t[o];n.indexOf(u)>=0&&(r[u]=e[u])}return r},e.removeIndexFromArray=r,e.removeItemFromArray=function(e,n){var t=e.indexOf(n);return r(e,t)},e.splitProps=function(e,n){for(var t={},r={},o=0,u=Object.keys(e);o<u.length;o++){var i=u[o];n.indexOf(i)>=0?t[i]=e[i]:r[i]=e[i]}return[t,r]},e.toArray=function(e){return Array.isArray(e)?e:void 0!==e?[e]:[]},e.useAllCallbacks=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.useCallback(function(){var e=t.filter(Boolean),n=e,r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var u;if(r){if(o>=n.length)break;u=n[o++]}else{if((o=n.next()).done)break;u=o.value}var i=u;i.apply(void 0,arguments)}},t)},e.useId=function(e){void 0===e&&(e=b);var t=n.useContext(y);return n.useState(function(){return t(e)})[0]},e.useLiveRef=function(e){var t=n.useRef(e);return n.useEffect(function(){t.current=e}),t},e.usePipe=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.useCallback(function(e){return t.filter(Boolean).reduce(function(e,n){return n(e)},e)},t)},e.useSealedState=function(e){return n.useState(e)[0]},e.useUpdateEffect=function(e,t){var r=n.useRef(!1);n.useEffect(function(){if(r.current)return e();r.current=!0},t)},e.warning=function(e,n){},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e=e||self).ReakitUtils={},e.React)}(this,function(e,n){"use strict";function t(e,n){return"matches"in e?e.matches(n):"msMatchesSelector"in e?e.msMatchesSelector(n):e.webkitMatchesSelector(n)}function r(e){return"object"==typeof e&&null!=e}function o(e,n){return-1===n?e:[].concat(e.slice(0,n),e.slice(n+1))}var u="input, select, textarea, a[href], button, [tabindex], audio[controls], video[controls], [contenteditable]:not([contenteditable=false])";function i(e){return e instanceof HTMLElement}function a(e){return e.hasAttribute("tabindex")}function f(e){if(!i(e))return!1;if(function e(n){return!(!n.parentElement||!e(n.parentElement))||n.hidden}(e))return!1;if(function(e){return Boolean(e.disabled)}(e))return!1;var n=e.localName;if(["input","select","textarea","button"].indexOf(n)>=0)return!0;var t={a:function(){return e.hasAttribute("href")},audio:function(){return e.hasAttribute("controls")},video:function(){return e.hasAttribute("controls")}};return n in t?t[n]():!!function(e){var n=e.getAttribute("contenteditable");return"false"!==n&&null!=n}(e)||a(e)}function c(e){return i(e)&&f(e)&&!function(e){return a(e)&&e.tabIndex<0}(e)}function l(e){var n=Array.from(e.querySelectorAll(u));return n.unshift(e),n.filter(f)}function s(e,n){var t=Array.from(e.querySelectorAll(u)),r=t.filter(c);return c(e)&&r.unshift(e),!r.length&&n?t:r}function v(e,n){var t=l(e),r=t.indexOf(document.activeElement),o=t.slice(r+1);return o.find(c)||t.find(c)||(n?o[0]:null)}function d(e,n){var t=l(e).reverse(),r=t.indexOf(document.activeElement),o=t.slice(r+1);return o.find(c)||t.find(c)||(n?o[0]:null)}function b(e){return document.activeElement===e}var y="id-",m=n.createContext(function(e){return void 0===e&&(e=y),""+e+Math.random().toString(32).substr(2,6)});e.IdProvider=function(e){var t=e.children,r=e.unstable_prefix,o=void 0===r?"":r,u=n.useRef(0),i=n.useMemo(function(){return function(e){return void 0===e&&(e=y),""+o+e+ ++u.current}},[o]);return n.createElement(m.Provider,{value:i},t)},e.closest=function(e,n){if("closest"in e)return e.closest(n);do{if(t(e,n))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null},e.createOnKeyDown=function(e){var n=void 0===e?{}:e,t=n.keyMap,r=n.onKey,o=n.stopPropagation,u=n.onKeyDown,i=n.shouldKeyDown,a=void 0===i?function(){return!0}:i,f=n.preventDefault,c=void 0===f||f;return function(e){if(t){var n="function"==typeof t?t(e):t,i="function"==typeof c?c(e):c,f="function"==typeof o?o(e):o;if(e.key in n){var l=n[e.key];if("function"==typeof l&&a(e))return i&&e.preventDefault(),f&&e.stopPropagation(),r&&r(e),void l(e)}u&&u(e)}}},e.cx=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.filter(Boolean).join(" ")||void 0},e.focusNextTabbableIn=function(e,n){var t=v(e,n);t&&i(t)&&t.focus()},e.focusPreviousTabbableIn=function(e,n){var t=d(e,n);t&&i(t)&&t.focus()},e.forceFocus=function(e,n){var t=void 0===n?{}:n,r=t.isActive,o=void 0===r?b:r,u=t.preventScroll;return o(e)?-1:(e.focus({preventScroll:u}),o(e)?-1:requestAnimationFrame(function(){e.focus({preventScroll:u})}))},e.getAllFocusableIn=l,e.getAllTabbableIn=s,e.getFirstFocusableIn=function(e){var n=l(e);return n.length?n[0]:null},e.getFirstTabbableIn=function(e,n){return s(e,n)[0]||null},e.getLastTabbableIn=function(e,n){var t=s(e,n);return t[t.length-1]||null},e.getNextTabbableIn=v,e.getPreviousTabbableIn=d,e.hasFocusWithin=function(e){return!!document.activeElement&&e.contains(document.activeElement)},e.isEmpty=function(e){return Array.isArray(e)?!e.length:r(e)?!Object.keys(e).length:null==e||""===e},e.isFocusable=f,e.isInteger=function(e){return"number"==typeof e?Math.floor(e)===e:String(Math.floor(Number(e)))===e},e.isObject=r,e.isPromise=function(e){return Boolean(e&&e.then)},e.isTabbable=c,e.mergeRefs=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=n.filter(Boolean);return r.length?0===r.length?r[0]:function(e){var n=r,t=Array.isArray(n),o=0;for(n=t?n:n[Symbol.iterator]();;){var u;if(t){if(o>=n.length)break;u=n[o++]}else{if((o=n.next()).done)break;u=o.value}var i=u;"function"==typeof i?i(e):i&&(i.current=e)}}:null},e.omit=function(e,n){for(var t=Object.keys(e),r={},o=0;o<t.length;o+=1){var u=t[o];-1===n.indexOf(u)&&(r[u]=e[u])}return r},e.pick=function(e,n){for(var t=Object.keys(e),r={},o=0;o<t.length;o+=1){var u=t[o];n.indexOf(u)>=0&&(r[u]=e[u])}return r},e.removeIndexFromArray=o,e.removeItemFromArray=function(e,n){var t=e.indexOf(n);return o(e,t)},e.splitProps=function(e,n){for(var t={},r={},o=0,u=Object.keys(e);o<u.length;o++){var i=u[o];n.indexOf(i)>=0?t[i]=e[i]:r[i]=e[i]}return[t,r]},e.toArray=function(e){return Array.isArray(e)?e:void 0!==e?[e]:[]},e.useAllCallbacks=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.useCallback(function(){var e=t.filter(Boolean),n=e,r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var u;if(r){if(o>=n.length)break;u=n[o++]}else{if((o=n.next()).done)break;u=o.value}var i=u;i.apply(void 0,arguments)}},t)},e.useId=function(e){void 0===e&&(e=y);var t=n.useContext(m);return n.useState(function(){return t(e)})[0]},e.useLiveRef=function(e){var t=n.useRef(e);return n.useEffect(function(){t.current=e}),t},e.usePipe=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.useCallback(function(e){return t.filter(Boolean).reduce(function(e,n){return n(e)},e)},t)},e.useSealedState=function(e){return n.useState(e)[0]},e.useUpdateEffect=function(e,t){var r=n.useRef(!1);n.useEffect(function(){if(r.current)return e();r.current=!0},t)},e.warning=function(e,n){},Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -21,4 +21,5 @@ export { warning } from './warning.js'; | ||
export { isEmpty } from './isEmpty.js'; | ||
export { closest } from './closest.js'; | ||
export { createOnKeyDown } from './createOnKeyDown.js'; | ||
export { cx } from './cx.js'; | ||
export { hasFocusWithin } from './hasFocusWithin.js'; |
var isProduction = process.env.NODE_ENV === "production"; | ||
var warnings = []; | ||
function warning(condition, label) { | ||
@@ -12,13 +11,8 @@ if (!isProduction) { | ||
var text = "" + finalLabel + messages.join("\n\n"); | ||
var text = "" + finalLabel + messages.join("\n\n"); // eslint-disable-next-line no-console | ||
if (warnings.indexOf(text) === -1) { | ||
// eslint-disable-next-line no-console | ||
console.warn(text); | ||
warnings.push(text); | ||
} // Throwing an error and catching it immediately to improve debugging | ||
console.warn(text); // Throwing an error and catching it immediately to improve debugging | ||
// A consumer can use 'pause on caught exceptions' | ||
// https://github.com/facebook/react/issues/4216 | ||
try { | ||
@@ -25,0 +19,0 @@ throw Error(text); |
@@ -25,2 +25,3 @@ 'use strict'; | ||
var isEmpty = require('./isEmpty.js'); | ||
var closest = require('./closest.js'); | ||
var createOnKeyDown = require('./createOnKeyDown.js'); | ||
@@ -63,4 +64,5 @@ var cx = require('./cx.js'); | ||
exports.isEmpty = isEmpty.isEmpty; | ||
exports.closest = closest.closest; | ||
exports.createOnKeyDown = createOnKeyDown.createOnKeyDown; | ||
exports.cx = cx.cx; | ||
exports.hasFocusWithin = hasFocusWithin.hasFocusWithin; |
@@ -6,3 +6,2 @@ 'use strict'; | ||
var isProduction = process.env.NODE_ENV === "production"; | ||
var warnings = []; | ||
function warning(condition, label) { | ||
@@ -17,13 +16,8 @@ if (!isProduction) { | ||
var text = "" + finalLabel + messages.join("\n\n"); | ||
var text = "" + finalLabel + messages.join("\n\n"); // eslint-disable-next-line no-console | ||
if (warnings.indexOf(text) === -1) { | ||
// eslint-disable-next-line no-console | ||
console.warn(text); | ||
warnings.push(text); | ||
} // Throwing an error and catching it immediately to improve debugging | ||
console.warn(text); // Throwing an error and catching it immediately to improve debugging | ||
// A consumer can use 'pause on caught exceptions' | ||
// https://github.com/facebook/react/issues/4216 | ||
try { | ||
@@ -30,0 +24,0 @@ throw Error(text); |
{ | ||
"name": "reakit-utils", | ||
"version": "0.6.4", | ||
"version": "0.6.5", | ||
"description": "Reakit utils", | ||
@@ -36,3 +36,4 @@ "sideEffects": false, | ||
"react-dom": "^16.8.0" | ||
} | ||
}, | ||
"gitHead": "82a1dfc8e21b7394ce8a0a402725011177abc8f7" | ||
} |
@@ -0,1 +1,2 @@ | ||
export * from "./closest"; | ||
export * from "./createOnKeyDown"; | ||
@@ -2,0 +3,0 @@ export * from "./cx"; |
const isProduction = process.env.NODE_ENV === "production"; | ||
const warnings: string[] = []; | ||
export function warning( | ||
@@ -16,7 +14,4 @@ condition: boolean, | ||
if (warnings.indexOf(text) === -1) { | ||
// eslint-disable-next-line no-console | ||
console.warn(text); | ||
warnings.push(text); | ||
} | ||
// eslint-disable-next-line no-console | ||
console.warn(text); | ||
@@ -23,0 +18,0 @@ // Throwing an error and catching it immediately to improve debugging |
@@ -0,1 +1,2 @@ | ||
export * from "./closest"; | ||
export * from "./createOnKeyDown"; | ||
@@ -2,0 +3,0 @@ export * from "./cx"; |
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
271807
166
2002