reakit-utils
Advanced tools
Comparing version 0.14.3 to 0.14.4
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.14.4](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/compare/reakit-utils@0.14.3...reakit-utils@0.14.4) (2020-09-22) | ||
### Bug Fixes | ||
* **reakit-utils:** Fix `getActiveElement` returning an empty object on IE 11 ([b7516c0](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/commit/b7516c01cc923d8e179743a07eba74a083132229)) | ||
## [0.14.3](https://github.com/reakit/reakit/tree/master/packages/reakit-utils/compare/reakit-utils@0.14.2...reakit-utils@0.14.3) (2020-08-24) | ||
@@ -8,0 +19,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReakitUtils={},e.React)}(this,(function(e,t){"use strict";function n(e){return e?e.ownerDocument||e:document}var r;try{r=window}catch(e){}function o(e){return e&&n(e).defaultView||r}var u=function(){var e=o();return Boolean(void 0!==e&&e.document&&e.document.createElement)}();function i(e,t){return"matches"in e?e.matches(t):"msMatchesSelector"in e?e.msMatchesSelector(t):e.webkitMatchesSelector(t)}function c(e,t){if("closest"in e)return e.closest(t);do{if(i(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null}function a(e,t){return e===t||e.contains(t)}function f(e,t,r){if("function"==typeof Event)return new Event(t,r);var o=n(e).createEvent("Event");return o.initEvent(t,null==r?void 0:r.bubbles,null==r?void 0:r.cancelable),o}function l(e){return n(e).activeElement}function s(e){var t=l(e);if(!t)return!1;if(t===e)return!0;var n=t.getAttribute("aria-activedescendant");return!!n&&n===e.id}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){v(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function p(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;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(n=e[Symbol.iterator]()).next.bind(n)}function g(e,t,n){return void 0===n&&(n={}),"function"==typeof FocusEvent?new FocusEvent(t,n):f(e,t,n)}var m=u&&"msCrypto"in window;var h=["button","color","file","image","reset","submit"];function O(e){return"object"==typeof e&&null!=e}function E(e,t){return-1===t?e:[].concat(e.slice(0,t),e.slice(t+1))}var j="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";function A(e){return i(e,j)&&function(e){var t=e;return t.offsetWidth>0||t.offsetHeight>0||e.getClientRects().length>0}(e)}function w(e){return A(e)&&!function(e){return parseInt(e.getAttribute("tabindex")||"0",10)<0}(e)}function S(e){var t=Array.from(e.querySelectorAll(j));return t.unshift(e),t.filter(A)}function T(e,t){var n=Array.from(e.querySelectorAll(j)),r=n.filter(w);return w(e)&&r.unshift(e),!r.length&&t?n:r}function P(e,t){void 0===t&&(t=null),e&&("function"==typeof e?e(t):e.current=t)}var x=u?t.useLayoutEffect:t.useEffect;e.applyState=function(e,t){return function(e){return"function"==typeof e}(e)?e(t):e},e.canUseDOM=u,e.closest=c,e.contains=a,e.createEvent=f,e.createOnKeyDown=function(e){var t=void 0===e?{}:e,n=t.keyMap,r=t.onKey,o=t.stopPropagation,u=t.onKeyDown,i=t.shouldKeyDown,c=void 0===i?function(){return!0}:i,a=t.preventDefault,f=void 0===a||a;return function(e){if(n){var t,i="function"==typeof n?n(e):n,a="function"==typeof f?f(e):f,l="function"==typeof o?o(e):o;if(e.key in i){var s=i[e.key];if("function"==typeof s&&c(e))return a&&e.preventDefault(),l&&e.stopPropagation(),r&&r(e),void s(e)}if(u&&"current"in u)null===(t=u.current)||void 0===t||t.call(u,e);else null==u||u(e)}}},e.ensureFocus=function(e,t){var n=void 0===t?{}:t,r=n.preventScroll,o=n.isActive,u=void 0===o?s:o;return u(e)?-1:(e.focus({preventScroll:r}),u(e)?-1:requestAnimationFrame((function(){e.focus({preventScroll:r})})))},e.fireBlurEvent=function(e,t){var n=g(e,"blur",t),r=e.dispatchEvent(n),o=d(d({},t),{},{bubbles:!0});return e.dispatchEvent(g(e,"focusout",o)),r},e.fireEvent=function(e,t,n){return e.dispatchEvent(f(e,t,n))},e.fireKeyboardEvent=function(e,t,r){return e.dispatchEvent(function(e,t,r){if(void 0===r&&(r={}),"function"==typeof KeyboardEvent)return new KeyboardEvent(t,r);var u=n(e).createEvent("KeyboardEvent");return u.initKeyboardEvent(t,r.bubbles,r.cancelable,o(e),r.key,r.location,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey),u}(e,t,r))},e.flatten=function e(t){for(var n,r=[],o=p(t);!(n=o()).done;){var u=n.value;Array.isArray(u)?r.push.apply(r,e(u)):r.push(u)}return r},e.getActiveElement=l,e.getAllFocusableIn=S,e.getAllTabbableIn=T,e.getClosestFocusable=function(e){for(;e&&!A(e);)e=c(e,j);return e},e.getDocument=n,e.getFirstFocusableIn=function(e){return S(e)[0]||null},e.getFirstTabbableIn=function(e,t){return T(e,t)[0]||null},e.getLastTabbableIn=function(e,t){var n=T(e,t);return n[n.length-1]||null},e.getNextActiveElementOnBlur=function(e){return m?l(e.currentTarget):e.relatedTarget},e.getNextTabbableIn=function(e,t){var n=l(e),r=S(e),o=r.indexOf(n),u=r.slice(o+1);return u.find(w)||r.find(w)||(t?u[0]:null)},e.getPreviousTabbableIn=function(e,t){var n=l(e),r=S(e).reverse(),o=r.indexOf(n),u=r.slice(o+1);return u.find(w)||r.find(w)||(t?u[0]:null)},e.getWindow=o,e.hasFocus=s,e.hasFocusWithin=function(e){var t=l(e);if(!t)return!1;if(a(e,t))return!0;var n=t.getAttribute("aria-activedescendant");return!!n&&(n===e.id||!!e.querySelector("#"+n))},e.isButton=function(e){if("BUTTON"===e.tagName)return!0;if("INPUT"===e.tagName){var t=e;return-1!==h.indexOf(t.type)}return!1},e.isEmpty=function(e){return Array.isArray(e)?!e.length:O(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=O,e.isPlainObject=function(e){var t;if(!O(e))return!1;var n=Object.getPrototypeOf(e);return null==n||(null===(t=n.constructor)||void 0===t?void 0:t.toString())===Object.toString()},e.isPortalEvent=function(e){return!a(e.currentTarget,e.target)},e.isPromise=function(e){return Boolean(e&&"then"in e&&e.then)},e.isSelfTarget=function(e){return e.target===e.currentTarget},e.isTabbable=w,e.isTextField=function(e){try{var t=e instanceof HTMLInputElement&&null!==e.selectionStart,n="TEXTAREA"===e.tagName,r="true"===e.contentEditable;return t||n||r||!1}catch(e){return!1}},e.matches=i,e.omit=function(e,t){for(var n=Object.keys(e),r={},o=0;o<n.length;o+=1){var u=n[o];-1===t.indexOf(u)&&(r[u]=e[u])}return r},e.pick=function(e,t){for(var n=Object.keys(e),r={},o=0;o<n.length;o+=1){var u=n[o];t.indexOf(u)>=0&&(r[u]=e[u])}return r},e.removeIndexFromArray=E,e.removeItemFromArray=function(e,t){var n=e.indexOf(t);return E(e,n)},e.shallowEqual=function(e,t){if(e===t)return!0;if(!e)return!1;if(!t)return!1;if("object"!=typeof e)return!1;if("object"!=typeof t)return!1;var n=Object.keys(e),r=Object.keys(t),o=n.length;if(r.length!==o)return!1;for(var u=0,i=n;u<i.length;u++){var c=i[u];if(e[c]!==t[c])return!1}return!0},e.splitProps=function(e,t){for(var n={},r={},o=0,u=Object.keys(e);o<u.length;o++){var i=u[o];t.indexOf(i)>=0?n[i]=e[i]:r[i]=e[i]}return[n,r]},e.toArray=function(e){return Array.isArray(e)?e:void 0!==e?[e]:[]},e.useForkRef=function(e,n){return t.useMemo((function(){return null==e&&null==n?null:function(t){P(e,t),P(n,t)}}),[e,n])},e.useLiveRef=function(e){var n=t.useRef(e);return x((function(){n.current=e})),n},e.useSealedState=function(e){return t.useState(e)[0]},e.useUpdateEffect=function(e,n){var r=t.useRef(!1);t.useEffect((function(){if(r.current)return e();r.current=!0}),n)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReakitUtils={},e.React)}(this,(function(e,t){"use strict";function n(e){return e?e.ownerDocument||e:document}var r;try{r=window}catch(e){}function o(e){return e&&n(e).defaultView||r}var u=function(){var e=o();return Boolean(void 0!==e&&e.document&&e.document.createElement)}();function i(e,t){return"matches"in e?e.matches(t):"msMatchesSelector"in e?e.msMatchesSelector(t):e.webkitMatchesSelector(t)}function c(e,t){if("closest"in e)return e.closest(t);do{if(i(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null}function a(e,t){return e===t||e.contains(t)}function f(e,t,r){if("function"==typeof Event)return new Event(t,r);var o=n(e).createEvent("Event");return o.initEvent(t,null==r?void 0:r.bubbles,null==r?void 0:r.cancelable),o}function l(e){var t=n(e).activeElement;return(null==t?void 0:t.nodeName)?t:null}function s(e){var t=l(e);if(!t)return!1;if(t===e)return!0;var n=t.getAttribute("aria-activedescendant");return!!n&&n===e.id}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){v(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function p(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;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(n=e[Symbol.iterator]()).next.bind(n)}function g(e,t,n){return void 0===n&&(n={}),"function"==typeof FocusEvent?new FocusEvent(t,n):f(e,t,n)}var m=u&&"msCrypto"in window;var h=["button","color","file","image","reset","submit"];function O(e){return"object"==typeof e&&null!=e}function E(e,t){return-1===t?e:[].concat(e.slice(0,t),e.slice(t+1))}var j="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";function A(e){return i(e,j)&&function(e){var t=e;return t.offsetWidth>0||t.offsetHeight>0||e.getClientRects().length>0}(e)}function w(e){return A(e)&&!function(e){return parseInt(e.getAttribute("tabindex")||"0",10)<0}(e)}function S(e){var t=Array.from(e.querySelectorAll(j));return t.unshift(e),t.filter(A)}function T(e,t){var n=Array.from(e.querySelectorAll(j)),r=n.filter(w);return w(e)&&r.unshift(e),!r.length&&t?n:r}function P(e,t){void 0===t&&(t=null),e&&("function"==typeof e?e(t):e.current=t)}var x=u?t.useLayoutEffect:t.useEffect;e.applyState=function(e,t){return function(e){return"function"==typeof e}(e)?e(t):e},e.canUseDOM=u,e.closest=c,e.contains=a,e.createEvent=f,e.createOnKeyDown=function(e){var t=void 0===e?{}:e,n=t.keyMap,r=t.onKey,o=t.stopPropagation,u=t.onKeyDown,i=t.shouldKeyDown,c=void 0===i?function(){return!0}:i,a=t.preventDefault,f=void 0===a||a;return function(e){if(n){var t,i="function"==typeof n?n(e):n,a="function"==typeof f?f(e):f,l="function"==typeof o?o(e):o;if(e.key in i){var s=i[e.key];if("function"==typeof s&&c(e))return a&&e.preventDefault(),l&&e.stopPropagation(),r&&r(e),void s(e)}if(u&&"current"in u)null===(t=u.current)||void 0===t||t.call(u,e);else null==u||u(e)}}},e.ensureFocus=function(e,t){var n=void 0===t?{}:t,r=n.preventScroll,o=n.isActive,u=void 0===o?s:o;return u(e)?-1:(e.focus({preventScroll:r}),u(e)?-1:requestAnimationFrame((function(){e.focus({preventScroll:r})})))},e.fireBlurEvent=function(e,t){var n=g(e,"blur",t),r=e.dispatchEvent(n),o=d(d({},t),{},{bubbles:!0});return e.dispatchEvent(g(e,"focusout",o)),r},e.fireEvent=function(e,t,n){return e.dispatchEvent(f(e,t,n))},e.fireKeyboardEvent=function(e,t,r){return e.dispatchEvent(function(e,t,r){if(void 0===r&&(r={}),"function"==typeof KeyboardEvent)return new KeyboardEvent(t,r);var u=n(e).createEvent("KeyboardEvent");return u.initKeyboardEvent(t,r.bubbles,r.cancelable,o(e),r.key,r.location,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey),u}(e,t,r))},e.flatten=function e(t){for(var n,r=[],o=p(t);!(n=o()).done;){var u=n.value;Array.isArray(u)?r.push.apply(r,e(u)):r.push(u)}return r},e.getActiveElement=l,e.getAllFocusableIn=S,e.getAllTabbableIn=T,e.getClosestFocusable=function(e){for(;e&&!A(e);)e=c(e,j);return e},e.getDocument=n,e.getFirstFocusableIn=function(e){return S(e)[0]||null},e.getFirstTabbableIn=function(e,t){return T(e,t)[0]||null},e.getLastTabbableIn=function(e,t){var n=T(e,t);return n[n.length-1]||null},e.getNextActiveElementOnBlur=function(e){return m?l(e.currentTarget):e.relatedTarget},e.getNextTabbableIn=function(e,t){var n=l(e),r=S(e),o=r.indexOf(n),u=r.slice(o+1);return u.find(w)||r.find(w)||(t?u[0]:null)},e.getPreviousTabbableIn=function(e,t){var n=l(e),r=S(e).reverse(),o=r.indexOf(n),u=r.slice(o+1);return u.find(w)||r.find(w)||(t?u[0]:null)},e.getWindow=o,e.hasFocus=s,e.hasFocusWithin=function(e){var t=l(e);if(!t)return!1;if(a(e,t))return!0;var n=t.getAttribute("aria-activedescendant");return!!n&&(n===e.id||!!e.querySelector("#"+n))},e.isButton=function(e){if("BUTTON"===e.tagName)return!0;if("INPUT"===e.tagName){var t=e;return-1!==h.indexOf(t.type)}return!1},e.isEmpty=function(e){return Array.isArray(e)?!e.length:O(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=O,e.isPlainObject=function(e){var t;if(!O(e))return!1;var n=Object.getPrototypeOf(e);return null==n||(null===(t=n.constructor)||void 0===t?void 0:t.toString())===Object.toString()},e.isPortalEvent=function(e){return!a(e.currentTarget,e.target)},e.isPromise=function(e){return Boolean(e&&"then"in e&&e.then)},e.isSelfTarget=function(e){return e.target===e.currentTarget},e.isTabbable=w,e.isTextField=function(e){try{var t=e instanceof HTMLInputElement&&null!==e.selectionStart,n="TEXTAREA"===e.tagName,r="true"===e.contentEditable;return t||n||r||!1}catch(e){return!1}},e.matches=i,e.omit=function(e,t){for(var n=Object.keys(e),r={},o=0;o<n.length;o+=1){var u=n[o];-1===t.indexOf(u)&&(r[u]=e[u])}return r},e.pick=function(e,t){for(var n=Object.keys(e),r={},o=0;o<n.length;o+=1){var u=n[o];t.indexOf(u)>=0&&(r[u]=e[u])}return r},e.removeIndexFromArray=E,e.removeItemFromArray=function(e,t){var n=e.indexOf(t);return E(e,n)},e.shallowEqual=function(e,t){if(e===t)return!0;if(!e)return!1;if(!t)return!1;if("object"!=typeof e)return!1;if("object"!=typeof t)return!1;var n=Object.keys(e),r=Object.keys(t),o=n.length;if(r.length!==o)return!1;for(var u=0,i=n;u<i.length;u++){var c=i[u];if(e[c]!==t[c])return!1}return!0},e.splitProps=function(e,t){for(var n={},r={},o=0,u=Object.keys(e);o<u.length;o++){var i=u[o];t.indexOf(i)>=0?n[i]=e[i]:r[i]=e[i]}return[n,r]},e.toArray=function(e){return Array.isArray(e)?e:void 0!==e?[e]:[]},e.useForkRef=function(e,n){return t.useMemo((function(){return null==e&&null==n?null:function(t){P(e,t),P(n,t)}}),[e,n])},e.useLiveRef=function(e){var n=t.useRef(e);return x((function(){n.current=e})),n},e.useSealedState=function(e){return t.useState(e)[0]},e.useUpdateEffect=function(e,n){var r=t.useRef(!1);t.useEffect((function(){if(r.current)return e();r.current=!0}),n)},Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -8,5 +8,14 @@ import { getDocument } from './getDocument.js'; | ||
function getActiveElement(element) { | ||
return getDocument(element).activeElement; | ||
var _getDocument = getDocument(element), | ||
activeElement = _getDocument.activeElement; | ||
if (!(activeElement === null || activeElement === void 0 ? void 0 : activeElement.nodeName)) { | ||
// In IE11, activeElement might be an empty object if we're interacting | ||
// with elements inside of an iframe. | ||
return null; | ||
} | ||
return activeElement; | ||
} | ||
export { getActiveElement }; |
@@ -12,5 +12,14 @@ 'use strict'; | ||
function getActiveElement(element) { | ||
return getDocument.getDocument(element).activeElement; | ||
var _getDocument = getDocument.getDocument(element), | ||
activeElement = _getDocument.activeElement; | ||
if (!(activeElement === null || activeElement === void 0 ? void 0 : activeElement.nodeName)) { | ||
// In IE11, activeElement might be an empty object if we're interacting | ||
// with elements inside of an iframe. | ||
return null; | ||
} | ||
return activeElement; | ||
} | ||
exports.getActiveElement = getActiveElement; |
{ | ||
"name": "reakit-utils", | ||
"version": "0.14.3", | ||
"version": "0.14.4", | ||
"description": "Reakit utils", | ||
@@ -37,3 +37,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "2b9a11c7d44c6159662e4e8261d8852211d66c30" | ||
"gitHead": "b6e5ec820dd5fb1f347c2349866e3d0de638b7f4" | ||
} |
@@ -7,3 +7,9 @@ import { getDocument } from "./getDocument"; | ||
export function getActiveElement(element?: Element | Document | null) { | ||
return getDocument(element).activeElement; | ||
const { activeElement } = getDocument(element); | ||
if (!activeElement?.nodeName) { | ||
// In IE11, activeElement might be an empty object if we're interacting | ||
// with elements inside of an iframe. | ||
return null; | ||
} | ||
return activeElement; | ||
} |
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
198968
4499