@radix-ui/react-focus-scope
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -22,5 +22,5 @@ import * as React from "react"; | ||
}; | ||
export function FocusScope(props: FocusScopeProps): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>; | ||
export function FocusScope(props: FocusScopeProps): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>; | ||
export const Root: typeof FocusScope; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
var e,t,n=require("@radix-ui/react-utils").useCallbackRef,u=require("@radix-ui/utils").arrayRemove,r=(e={},t=require("react"),Object.keys(t).forEach((function(n){"default"!==n&&"__esModule"!==n&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),e);function o(e){var t=document.activeElement;function n(t){if(!r.paused){var n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||c(e,n)}}var u,r={paused:!1,pause:function(){return r.paused=!0},resume:function(){return r.paused=!1},trap:function(){document.addEventListener("focusout",n,{capture:!0}),document.addEventListener("focusin",n,{capture:!0})},untrap:function(){document.removeEventListener("focusout",n,{capture:!0}),document.removeEventListener("focusin",n,{capture:!0})},destroy:function(){var n;!function(e){e.removeAttribute("tabIndex")}(e),r.untrap(),n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0}),e.dispatchEvent(n),n.defaultPrevented||a(t),s.remove(r)}};return s.add(r),function(e){if(e.tabIndex>-1)return;e.tabIndex=-1}(e),u=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0}),e.dispatchEvent(u),u.defaultPrevented||c(e,null),r}function c(e,t){var n,u=function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}})}(e),r=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;if(r&Node.DOCUMENT_POSITION_PRECEDING)a(null!==(n=u.firstChild())&&void 0!==n?n:e);else if(r&Node.DOCUMENT_POSITION_FOLLOWING){var o;a(null!==(o=u.lastChild())&&void 0!==o?o:e)}}function a(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}var i,s=(i=[],{add:function(e){var t=i[0];e!==t&&(null==t||t.pause()),(i=u(i,e)).unshift(e)},remove:function(e){var t;null===(t=(i=u(i,e))[0])||void 0===t||t.resume()},size:function(){return i.length}});function d(e){var t=e.children,u=e.trapped,c=void 0!==u&&u,a=r.useRef(null),i=r.useRef(),s=n(e.onMountAutoFocus),d=n(e.onUnmountAutoFocus);return r.useEffect((function(){var e=a.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",s),e.addEventListener("focusScope.autoFocusOnDestroy",d),i.current=o(e),function(){e.removeEventListener("focusScope.autoFocusOnCreate",s),setTimeout((function(){var t;null===(t=i.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",d)}),0)}}),[a,s,d]),r.useEffect((function(){var e;if(c)return null===(e=i.current)||void 0===e||e.trap(),function(){var e;return null===(e=i.current)||void 0===e?void 0:e.untrap()}}),[c]),t({ref:a})}exports.FocusScope=d;var f=d;exports.Root=f; | ||
var e,t,n=require("@radix-ui/react-use-callback-ref").useCallbackRef,r=(e={},t=require("react"),Object.keys(t).forEach((function(n){"default"!==n&&"__esModule"!==n&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),e);function u(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(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 c(e){var t=document.activeElement;function n(t){if(!u.paused){var n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||a(e,n)}}var r,u={paused:!1,pause:function(){return u.paused=!0},resume:function(){return u.paused=!1},trap:function(){document.addEventListener("focusout",n,{capture:!0}),document.addEventListener("focusin",n,{capture:!0})},untrap:function(){document.removeEventListener("focusout",n,{capture:!0}),document.removeEventListener("focusin",n,{capture:!0})},destroy:function(){var n;!function(e){e.removeAttribute("tabIndex")}(e),u.untrap(),n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0}),e.dispatchEvent(n),n.defaultPrevented||i(t),s.remove(u)}};return s.add(u),function(e){if(e.tabIndex>-1)return;e.tabIndex=-1}(e),r=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0}),e.dispatchEvent(r),r.defaultPrevented||a(e,null),u}function a(e,t){var n,r=function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}})}(e),u=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;if(u&Node.DOCUMENT_POSITION_PRECEDING)i(null!==(n=r.firstChild())&&void 0!==n?n:e);else if(u&Node.DOCUMENT_POSITION_FOLLOWING){var o;i(null!==(o=r.lastChild())&&void 0!==o?o:e)}}function i(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}var f,s=(f=[],{add:function(e){var t=f[0];e!==t&&(null==t||t.pause()),(f=d(f,e)).unshift(e)},remove:function(e){var t;null===(t=(f=d(f,e))[0])||void 0===t||t.resume()},size:function(){return f.length}});function d(e,t){var n=u(e),r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}function l(e){var t=e.children,u=e.trapped,o=void 0!==u&&u,a=r.useRef(null),i=r.useRef(),f=n(e.onMountAutoFocus),s=n(e.onUnmountAutoFocus);return r.useEffect((function(){var e=a.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",f),e.addEventListener("focusScope.autoFocusOnDestroy",s),i.current=c(e),function(){e.removeEventListener("focusScope.autoFocusOnCreate",f),setTimeout((function(){var t;null===(t=i.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",s)}),0)}}),[a,f,s]),r.useEffect((function(){var e;if(o)return null===(e=i.current)||void 0===e||e.trap(),function(){var e;return null===(e=i.current)||void 0===e?void 0:e.untrap()}}),[o]),t({ref:a})}exports.FocusScope=l;var v=l;exports.Root=v; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{useCallbackRef as e}from"@radix-ui/react-utils";import{arrayRemove as t}from"@radix-ui/utils";import*as n from"react";function o(e){const t=document.activeElement;function n(t){if(o.paused)return;const n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||u(e,n)}const o={paused:!1,pause:()=>o.paused=!0,resume:()=>o.paused=!1,trap:function(){document.addEventListener("focusout",n,{capture:!0}),document.addEventListener("focusin",n,{capture:!0})},untrap:function(){document.removeEventListener("focusout",n,{capture:!0}),document.removeEventListener("focusin",n,{capture:!0})},destroy:()=>{!function(e){e.removeAttribute("tabIndex")}(e),o.untrap(),function(){const n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0});e.dispatchEvent(n),n.defaultPrevented||r(t)}(),c.remove(o)}};return c.add(o),function(e){if(e.tabIndex>-1)return;e.tabIndex=-1}(e),function(){const t=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0});e.dispatchEvent(t),t.defaultPrevented||u(e,null)}(),o}function u(e,t){const n=function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})}(e),o=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;var u;if(o&Node.DOCUMENT_POSITION_PRECEDING)r(null!==(u=n.firstChild())&&void 0!==u?u:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var c;r(null!==(c=n.lastChild())&&void 0!==c?c:e)}}function r(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}const c=function(){let e=[];return{add(n){const o=e[0];n!==o&&(null==o||o.pause()),e=t(e,n),e.unshift(n)},remove(n){var o;e=t(e,n),null===(o=e[0])||void 0===o||o.resume()},size:()=>e.length}}();export function FocusScope(t){const{children:u,trapped:r=!1}=t,c=n.useRef(null),s=n.useRef(),a=e(t.onMountAutoFocus),i=e(t.onUnmountAutoFocus);return n.useEffect((()=>{const e=c.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",a),e.addEventListener("focusScope.autoFocusOnDestroy",i),s.current=o(e),()=>{e.removeEventListener("focusScope.autoFocusOnCreate",a),setTimeout((()=>{var t;null===(t=s.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",i)}),0)}}),[c,a,i]),n.useEffect((()=>{var e;if(r)return null===(e=s.current)||void 0===e||e.trap(),()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.untrap()}}),[r]),u({ref:c})}export const Root=FocusScope; | ||
import{useCallbackRef as e}from"@radix-ui/react-use-callback-ref";import*as t from"react";function n(e){const t=document.activeElement;function n(t){if(c.paused)return;const n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||o(e,n)}const c={paused:!1,pause:()=>c.paused=!0,resume:()=>c.paused=!1,trap:function(){document.addEventListener("focusout",n,{capture:!0}),document.addEventListener("focusin",n,{capture:!0})},untrap:function(){document.removeEventListener("focusout",n,{capture:!0}),document.removeEventListener("focusin",n,{capture:!0})},destroy:()=>{!function(e){e.removeAttribute("tabIndex")}(e),c.untrap(),function(){const n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0});e.dispatchEvent(n),n.defaultPrevented||u(t)}(),r.remove(c)}};return r.add(c),function(e){if(e.tabIndex>-1)return;e.tabIndex=-1}(e),function(){const t=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0});e.dispatchEvent(t),t.defaultPrevented||o(e,null)}(),c}function o(e,t){const n=function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})}(e),o=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;var r;if(o&Node.DOCUMENT_POSITION_PRECEDING)u(null!==(r=n.firstChild())&&void 0!==r?r:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var c;u(null!==(c=n.lastChild())&&void 0!==c?c:e)}}function u(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}const r=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null==n||n.pause()),e=c(e,t),e.unshift(t)},remove(t){var n;e=c(e,t),null===(n=e[0])||void 0===n||n.resume()},size:()=>e.length}}();function c(e,t){const n=[...e],o=n.indexOf(t);return-1!==o&&n.splice(o,1),n}export function FocusScope(o){const{children:u,trapped:r=!1}=o,c=t.useRef(null),s=t.useRef(),a=e(o.onMountAutoFocus),i=e(o.onUnmountAutoFocus);return t.useEffect((()=>{const e=c.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",a),e.addEventListener("focusScope.autoFocusOnDestroy",i),s.current=n(e),()=>{e.removeEventListener("focusScope.autoFocusOnCreate",a),setTimeout((()=>{var t;null===(t=s.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",i)}),0)}}),[c,a,i]),t.useEffect((()=>{var e;if(r)return null===(e=s.current)||void 0===e||e.trap(),()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.untrap()}}),[r]),u({ref:c})}export const Root=FocusScope; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-focus-scope", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"license": "MIT", | ||
@@ -19,4 +19,3 @@ "source": "src/index.ts", | ||
"dependencies": { | ||
"@radix-ui/react-utils": "0.0.5", | ||
"@radix-ui/utils": "0.0.3" | ||
"@radix-ui/react-use-callback-ref": "0.0.1" | ||
}, | ||
@@ -23,0 +22,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37115
2
50
+ Added@radix-ui/react-use-callback-ref@0.0.1(transitive)
- Removed@radix-ui/react-utils@0.0.5
- Removed@radix-ui/utils@0.0.3
- Removed@radix-ui/react-polymorphic@0.0.5(transitive)
- Removed@radix-ui/react-utils@0.0.5(transitive)
- Removed@radix-ui/utils@0.0.3(transitive)