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

reakit-utils

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reakit-utils - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

11

CHANGELOG.md

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

## [0.7.2](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/compare/reakit-utils@0.7.1...reakit-utils@0.7.2) (2019-11-22)
### Bug Fixes
* **reakit-utils:** Support iframes ([b6b3340](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/commit/b6b3340))
## [0.7.1](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/compare/reakit-utils@0.7.0...reakit-utils@0.7.1) (2019-11-14)

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

2

dist/reakit-utils.min.js

@@ -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,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.ensureFocus=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.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.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?1===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){},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 c(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 f(e){return i(e)&&c(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(c)}function s(e,n){var t=Array.from(e.querySelectorAll(u)),r=t.filter(f);return f(e)&&r.unshift(e),!r.length&&n?t:r}function v(e,n){var t=(e.ownerDocument||document).activeElement,r=l(e),o=r.indexOf(t),u=r.slice(o+1);return u.find(f)||r.find(f)||(n?u[0]:null)}function d(e,n){var t=(e.ownerDocument||document).activeElement,r=l(e).reverse(),o=r.indexOf(t),u=r.slice(o+1);return u.find(f)||r.find(f)||(n?u[0]:null)}function b(e){return(e.ownerDocument||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,c=n.preventDefault,f=void 0===c||c;return function(e){if(t){var n="function"==typeof t?t(e):t,i="function"==typeof f?f(e):f,c="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(),c&&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.ensureFocus=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.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.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){var n=e.ownerDocument||document;return!!n.activeElement&&e.contains(n.activeElement)},e.isEmpty=function(e){return Array.isArray(e)?!e.length:r(e)?!Object.keys(e).length:null==e||""===e},e.isFocusable=c,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=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?1===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){},Object.defineProperty(e,"__esModule",{value:!0})});
function hasFocusWithin(element) {
if (!document.activeElement) return false;
return element.contains(document.activeElement);
var doc = element.ownerDocument || document;
if (!doc.activeElement) return false;
return element.contains(doc.activeElement);
}
export { hasFocusWithin };

@@ -92,4 +92,7 @@ var selector = "input, select, textarea, a[href], button, [tabindex], audio[controls], video[controls], [contenteditable]:not([contenteditable=false])";

function getNextTabbableIn(container, fallbackToFocusable) {
var _ref = container.ownerDocument || document,
activeElement = _ref.activeElement;
var allFocusable = getAllFocusableIn(container);
var index = allFocusable.indexOf(document.activeElement);
var index = allFocusable.indexOf(activeElement);
var slice = allFocusable.slice(index + 1);

@@ -99,4 +102,7 @@ return slice.find(isTabbable) || allFocusable.find(isTabbable) || (fallbackToFocusable ? slice[0] : null);

function getPreviousTabbableIn(container, fallbackToFocusable) {
var _ref2 = container.ownerDocument || document,
activeElement = _ref2.activeElement;
var allFocusable = getAllFocusableIn(container).reverse();
var index = allFocusable.indexOf(document.activeElement);
var index = allFocusable.indexOf(activeElement);
var slice = allFocusable.slice(index + 1);

@@ -121,10 +127,13 @@ return slice.find(isTabbable) || allFocusable.find(isTabbable) || (fallbackToFocusable ? slice[0] : null);

function defaultIsActive(element) {
return document.activeElement === element;
var _ref3 = element.ownerDocument || document,
activeElement = _ref3.activeElement;
return activeElement === element;
}
function ensureFocus(element, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$isActive = _ref.isActive,
isActive = _ref$isActive === void 0 ? defaultIsActive : _ref$isActive,
preventScroll = _ref.preventScroll;
var _ref4 = _temp === void 0 ? {} : _temp,
_ref4$isActive = _ref4.isActive,
isActive = _ref4$isActive === void 0 ? defaultIsActive : _ref4$isActive,
preventScroll = _ref4.preventScroll;

@@ -131,0 +140,0 @@ if (isActive(element)) return -1;

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

function hasFocusWithin(element) {
if (!document.activeElement) return false;
return element.contains(document.activeElement);
var doc = element.ownerDocument || document;
if (!doc.activeElement) return false;
return element.contains(doc.activeElement);
}
exports.hasFocusWithin = hasFocusWithin;

@@ -96,4 +96,7 @@ 'use strict';

function getNextTabbableIn(container, fallbackToFocusable) {
var _ref = container.ownerDocument || document,
activeElement = _ref.activeElement;
var allFocusable = getAllFocusableIn(container);
var index = allFocusable.indexOf(document.activeElement);
var index = allFocusable.indexOf(activeElement);
var slice = allFocusable.slice(index + 1);

@@ -103,4 +106,7 @@ return slice.find(isTabbable) || allFocusable.find(isTabbable) || (fallbackToFocusable ? slice[0] : null);

function getPreviousTabbableIn(container, fallbackToFocusable) {
var _ref2 = container.ownerDocument || document,
activeElement = _ref2.activeElement;
var allFocusable = getAllFocusableIn(container).reverse();
var index = allFocusable.indexOf(document.activeElement);
var index = allFocusable.indexOf(activeElement);
var slice = allFocusable.slice(index + 1);

@@ -125,10 +131,13 @@ return slice.find(isTabbable) || allFocusable.find(isTabbable) || (fallbackToFocusable ? slice[0] : null);

function defaultIsActive(element) {
return document.activeElement === element;
var _ref3 = element.ownerDocument || document,
activeElement = _ref3.activeElement;
return activeElement === element;
}
function ensureFocus(element, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$isActive = _ref.isActive,
isActive = _ref$isActive === void 0 ? defaultIsActive : _ref$isActive,
preventScroll = _ref.preventScroll;
var _ref4 = _temp === void 0 ? {} : _temp,
_ref4$isActive = _ref4.isActive,
isActive = _ref4$isActive === void 0 ? defaultIsActive : _ref4$isActive,
preventScroll = _ref4.preventScroll;

@@ -135,0 +144,0 @@ if (isActive(element)) return -1;

{
"name": "reakit-utils",
"version": "0.7.1",
"version": "0.7.2",
"description": "Reakit utils",

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

},
"gitHead": "a05b07b10dc045401c49ed56e7de0440be252c55"
"gitHead": "4931fef3070e0b56e454ae6c888b5dcf6043916c"
}

@@ -10,3 +10,3 @@ describe("warning", () => {

it('logs to console.warn when NODE_ENV is not "production"', () => {
test('log to console.warn when NODE_ENV is not "production"', () => {
process.env.NODE_ENV = "development";

@@ -21,3 +21,4 @@

});
it('does not log to console.warn if NODE_ENV is "production"', () => {
test('do not log to console.warn if NODE_ENV is "production"', () => {
process.env.NODE_ENV = "production";

@@ -24,0 +25,0 @@

export function hasFocusWithin(element: Element) {
if (!document.activeElement) return false;
return element.contains(document.activeElement);
const doc = element.ownerDocument || document;
if (!doc.activeElement) return false;
return element.contains(doc.activeElement);
}

@@ -111,4 +111,5 @@ const selector =

): T | null {
const { activeElement } = container.ownerDocument || document;
const allFocusable = getAllFocusableIn(container);
const index = allFocusable.indexOf(document.activeElement as T);
const index = allFocusable.indexOf(activeElement as T);
const slice = allFocusable.slice(index + 1);

@@ -126,4 +127,5 @@ return (

): T | null {
const { activeElement } = container.ownerDocument || document;
const allFocusable = getAllFocusableIn(container).reverse();
const index = allFocusable.indexOf(document.activeElement as T);
const index = allFocusable.indexOf(activeElement as T);
const slice = allFocusable.slice(index + 1);

@@ -161,3 +163,4 @@ return (

function defaultIsActive(element: Element) {
return document.activeElement === element;
const { activeElement } = element.ownerDocument || document;
return activeElement === element;
}

@@ -164,0 +167,0 @@

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