UNPKG

@infinityfx/fluid

Version:

React UI library, using zero-runtime CSS-in-JS.

3 lines (2 loc) 525 B
import{useRef as e,useEffect as t}from"react";import{getFocusable as r}from"../core/utils.js";function n(n){const o=e(null);return t((()=>{if(o.current&&n)return o.current.addEventListener("keydown",e),()=>o.current?.removeEventListener("keydown",e);function e(e){if("Tab"===e.key&&o.current){e.preventDefault();let t=r(o.current),n=0;t.forEach(((t,r)=>{t===document.activeElement&&(n=r+(e.shiftKey?-1:1))})),t[(n<0?t.length+n:n)%t.length]?.focus()}}}),[n]),o}export{n as default}; //# sourceMappingURL=use-focus-trap.js.map