Socket
Socket
Sign inDemoInstall

focus-trap

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

focus-trap - npm Package Compare versions

Comparing version 7.5.3 to 7.5.4

6

CHANGELOG.md
# Changelog
## 7.5.4
### Patch Changes
- 680f6e8: Fix issue with not being able to cycle back to the start from the last element if there is a focusable web component inside the focus-trap ((#1068)[https://github.com/focus-trap/focus-trap/issues/1068])
## 7.5.3

@@ -4,0 +10,0 @@

23

dist/focus-trap.esm.js
/*!
* focus-trap 7.5.3
* focus-trap 7.5.4
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -403,2 +403,21 @@ */

};
/**
* Gets the current activeElement. If it's a web-component and has open shadow-root
* it will recursively search inside shadow roots for the "true" activeElement.
*
* @param {Document | ShadowRoot} el
*
* @returns {HTMLElement} The element that currently has the focus
**/
var getActiveElement = function getActiveElement(el) {
var activeElement = el.activeElement;
if (!activeElement) {
return;
}
if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
return getActiveElement(activeElement.shadowRoot);
}
return activeElement;
};
var tryFocus = function tryFocus(node) {

@@ -408,3 +427,3 @@ if (node === false) {

}
if (node === doc.activeElement) {
if (node === getActiveElement(document)) {
return;

@@ -411,0 +430,0 @@ }

4

dist/focus-trap.esm.min.js
/*!
* focus-trap 7.5.3
* focus-trap 7.5.4
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
import{isFocusable as e,tabbable as t,focusable as n,isTabbable as o,getTabIndex as r}from"tabbable";function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},s=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},l=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},d=function(e){return l(e)&&!e.shiftKey},f=function(e){return l(e)&&e.shiftKey},b=function(e){return setTimeout(e,0)},v=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},p=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},m=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},y=[],h=function(a,u){var h,w=(null==u?void 0:u.document)||document,g=(null==u?void 0:u.trapStack)||y,N=i({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:d,isKeyBackward:f},u),F={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},O=function(e,t,n){return e&&void 0!==e[t]?e[t]:N[n||t]},E=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return F.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},k=function(e){var t=N[e];if("function"==typeof t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];t=t.apply(void 0,o)}if(!0===t&&(t=void 0),!t){if(void 0===t||!1===t)return t;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var a=t;if("string"==typeof t&&!(a=w.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return a},T=function(){var t=k("initialFocus");if(!1===t)return!1;if(void 0===t||!e(t,N.tabbableOptions))if(E(w.activeElement)>=0)t=w.activeElement;else{var n=F.tabbableGroups[0];t=n&&n.firstTabbableNode||k("fallbackFocus")}if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},D=function(){if(F.containerGroups=F.containers.map((function(e){var a=t(e,N.tabbableOptions),i=n(e,N.tabbableOptions),u=a.length>0?a[0]:void 0,c=a.length>0?a[a.length-1]:void 0,s=i.find((function(e){return o(e)})),l=i.slice().reverse().find((function(e){return o(e)})),d=!!a.find((function(e){return r(e)>0}));return{container:e,tabbableNodes:a,focusableNodes:i,posTabIndexesFound:d,firstTabbableNode:u,lastTabbableNode:c,firstDomTabbableNode:s,lastDomTabbableNode:l,nextTabbableNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=a.indexOf(e);return n<0?t?i.slice(i.indexOf(e)+1).find((function(e){return o(e)})):i.slice(0,i.indexOf(e)).reverse().find((function(e){return o(e)})):a[n+(t?1:-1)]}}})),F.tabbableGroups=F.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),F.tabbableGroups.length<=0&&!k("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(F.containerGroups.find((function(e){return e.posTabIndexesFound}))&&F.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},P=function e(t){!1!==t&&t!==w.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!N.preventScroll}),F.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(T()))},G=function(e){var t=k("setReturnFocus",e);return t||!1!==t&&e},x=function(t){var n=t.target,a=t.event,i=t.isBackward,u=void 0!==i&&i;n=n||m(a),D();var c=null;if(F.tabbableGroups.length>0){var s=E(n,a),d=s>=0?F.containerGroups[s]:void 0;if(s<0)c=u?F.tabbableGroups[F.tabbableGroups.length-1].lastTabbableNode:F.tabbableGroups[0].firstTabbableNode;else if(u){var f=v(F.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(f<0&&(d.container===n||e(n,N.tabbableOptions)&&!o(n,N.tabbableOptions)&&!d.nextTabbableNode(n,!1))&&(f=s),f>=0){var b=0===f?F.tabbableGroups.length-1:f-1,p=F.tabbableGroups[b];c=r(n)>=0?p.lastTabbableNode:p.lastDomTabbableNode}else l(a)||(c=d.nextTabbableNode(n,!1))}else{var y=v(F.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(y<0&&(d.container===n||e(n,N.tabbableOptions)&&!o(n,N.tabbableOptions)&&!d.nextTabbableNode(n))&&(y=s),y>=0){var h=y===F.tabbableGroups.length-1?0:y+1,w=F.tabbableGroups[h];c=r(n)>=0?w.firstTabbableNode:w.firstDomTabbableNode}else l(a)||(c=d.nextTabbableNode(n))}}else c=k("fallbackFocus");return c},R=function(e){var t=m(e);E(t,e)>=0||(p(N.clickOutsideDeactivates,e)?h.deactivate({returnFocus:N.returnFocusOnDeactivate}):p(N.allowOutsideClick,e)||e.preventDefault())},j=function(e){var t=m(e),n=E(t,e)>=0;if(n||t instanceof Document)n&&(F.mostRecentlyFocusedNode=t);else{var o;e.stopImmediatePropagation();var a=!0;if(F.mostRecentlyFocusedNode)if(r(F.mostRecentlyFocusedNode)>0){var i=E(F.mostRecentlyFocusedNode),u=F.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===F.mostRecentlyFocusedNode}));c>=0&&(N.isKeyForward(F.recentNavEvent)?c+1<u.length&&(o=u[c+1],a=!1):c-1>=0&&(o=u[c-1],a=!1))}}else F.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return r(e)>0}))}))||(a=!1);else a=!1;a&&(o=x({target:F.mostRecentlyFocusedNode,isBackward:N.isKeyBackward(F.recentNavEvent)})),P(o||(F.mostRecentlyFocusedNode||T()))}F.recentNavEvent=void 0},B=function(e){if(!(t=e,"Escape"!==(null==t?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===p(N.escapeDeactivates,e)))return e.preventDefault(),void h.deactivate();var t;(N.isKeyForward(e)||N.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];F.recentNavEvent=e;var n=x({event:e,isBackward:t});n&&(l(e)&&e.preventDefault(),P(n))}(e,N.isKeyBackward(e))},I=function(e){var t=m(e);E(t,e)>=0||p(N.clickOutsideDeactivates,e)||p(N.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},L=function(){if(F.active)return c(g,h),F.delayInitialFocusTimer=N.delayInitialFocus?b((function(){P(T())})):P(T()),w.addEventListener("focusin",j,!0),w.addEventListener("mousedown",R,{capture:!0,passive:!1}),w.addEventListener("touchstart",R,{capture:!0,passive:!1}),w.addEventListener("click",I,{capture:!0,passive:!1}),w.addEventListener("keydown",B,{capture:!0,passive:!1}),h},C=function(){if(F.active)return w.removeEventListener("focusin",j,!0),w.removeEventListener("mousedown",R,!0),w.removeEventListener("touchstart",R,!0),w.removeEventListener("click",I,!0),w.removeEventListener("keydown",B,!0),h},A="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===F.mostRecentlyFocusedNode}))}))&&P(T())})):void 0,S=function(){A&&(A.disconnect(),F.active&&!F.paused&&F.containers.map((function(e){A.observe(e,{subtree:!0,childList:!0})})))};return(h={get active(){return F.active},get paused(){return F.paused},activate:function(e){if(F.active)return this;var t=O(e,"onActivate"),n=O(e,"onPostActivate"),o=O(e,"checkCanFocusTrap");o||D(),F.active=!0,F.paused=!1,F.nodeFocusedBeforeActivation=w.activeElement,null==t||t();var r=function(){o&&D(),L(),S(),null==n||n()};return o?(o(F.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!F.active)return this;var t=i({onDeactivate:N.onDeactivate,onPostDeactivate:N.onPostDeactivate,checkCanReturnFocus:N.checkCanReturnFocus},e);clearTimeout(F.delayInitialFocusTimer),F.delayInitialFocusTimer=void 0,C(),F.active=!1,F.paused=!1,S(),s(g,h);var n=O(t,"onDeactivate"),o=O(t,"onPostDeactivate"),r=O(t,"checkCanReturnFocus"),a=O(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var u=function(){b((function(){a&&P(G(F.nodeFocusedBeforeActivation)),null==o||o()}))};return a&&r?(r(G(F.nodeFocusedBeforeActivation)).then(u,u),this):(u(),this)},pause:function(e){if(F.paused||!F.active)return this;var t=O(e,"onPause"),n=O(e,"onPostPause");return F.paused=!0,null==t||t(),C(),S(),null==n||n(),this},unpause:function(e){if(!F.paused||!F.active)return this;var t=O(e,"onUnpause"),n=O(e,"onPostUnpause");return F.paused=!1,null==t||t(),D(),L(),S(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return F.containers=t.map((function(e){return"string"==typeof e?w.querySelector(e):e})),F.active&&D(),S(),this}}).updateContainerElements(a),h};export{h as createFocusTrap};
import{isFocusable as e,tabbable as t,focusable as n,isTabbable as o,getTabIndex as r}from"tabbable";function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},s=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},l=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},d=function(e){return l(e)&&!e.shiftKey},f=function(e){return l(e)&&e.shiftKey},b=function(e){return setTimeout(e,0)},v=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},p=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},m=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},y=[],h=function(a,u){var h,w=(null==u?void 0:u.document)||document,g=(null==u?void 0:u.trapStack)||y,N=i({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:d,isKeyBackward:f},u),F={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},O=function(e,t,n){return e&&void 0!==e[t]?e[t]:N[n||t]},E=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return F.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},k=function(e){var t=N[e];if("function"==typeof t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];t=t.apply(void 0,o)}if(!0===t&&(t=void 0),!t){if(void 0===t||!1===t)return t;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var a=t;if("string"==typeof t&&!(a=w.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return a},T=function(){var t=k("initialFocus");if(!1===t)return!1;if(void 0===t||!e(t,N.tabbableOptions))if(E(w.activeElement)>=0)t=w.activeElement;else{var n=F.tabbableGroups[0];t=n&&n.firstTabbableNode||k("fallbackFocus")}if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},D=function(){if(F.containerGroups=F.containers.map((function(e){var a=t(e,N.tabbableOptions),i=n(e,N.tabbableOptions),u=a.length>0?a[0]:void 0,c=a.length>0?a[a.length-1]:void 0,s=i.find((function(e){return o(e)})),l=i.slice().reverse().find((function(e){return o(e)})),d=!!a.find((function(e){return r(e)>0}));return{container:e,tabbableNodes:a,focusableNodes:i,posTabIndexesFound:d,firstTabbableNode:u,lastTabbableNode:c,firstDomTabbableNode:s,lastDomTabbableNode:l,nextTabbableNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=a.indexOf(e);return n<0?t?i.slice(i.indexOf(e)+1).find((function(e){return o(e)})):i.slice(0,i.indexOf(e)).reverse().find((function(e){return o(e)})):a[n+(t?1:-1)]}}})),F.tabbableGroups=F.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),F.tabbableGroups.length<=0&&!k("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(F.containerGroups.find((function(e){return e.posTabIndexesFound}))&&F.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},P=function e(t){var n=t.activeElement;if(n)return n.shadowRoot&&null!==n.shadowRoot.activeElement?e(n.shadowRoot):n},G=function e(t){!1!==t&&t!==P(document)&&(t&&t.focus?(t.focus({preventScroll:!!N.preventScroll}),F.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(T()))},R=function(e){var t=k("setReturnFocus",e);return t||!1!==t&&e},x=function(t){var n=t.target,a=t.event,i=t.isBackward,u=void 0!==i&&i;n=n||m(a),D();var c=null;if(F.tabbableGroups.length>0){var s=E(n,a),d=s>=0?F.containerGroups[s]:void 0;if(s<0)c=u?F.tabbableGroups[F.tabbableGroups.length-1].lastTabbableNode:F.tabbableGroups[0].firstTabbableNode;else if(u){var f=v(F.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(f<0&&(d.container===n||e(n,N.tabbableOptions)&&!o(n,N.tabbableOptions)&&!d.nextTabbableNode(n,!1))&&(f=s),f>=0){var b=0===f?F.tabbableGroups.length-1:f-1,p=F.tabbableGroups[b];c=r(n)>=0?p.lastTabbableNode:p.lastDomTabbableNode}else l(a)||(c=d.nextTabbableNode(n,!1))}else{var y=v(F.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(y<0&&(d.container===n||e(n,N.tabbableOptions)&&!o(n,N.tabbableOptions)&&!d.nextTabbableNode(n))&&(y=s),y>=0){var h=y===F.tabbableGroups.length-1?0:y+1,w=F.tabbableGroups[h];c=r(n)>=0?w.firstTabbableNode:w.firstDomTabbableNode}else l(a)||(c=d.nextTabbableNode(n))}}else c=k("fallbackFocus");return c},j=function(e){var t=m(e);E(t,e)>=0||(p(N.clickOutsideDeactivates,e)?h.deactivate({returnFocus:N.returnFocusOnDeactivate}):p(N.allowOutsideClick,e)||e.preventDefault())},B=function(e){var t=m(e),n=E(t,e)>=0;if(n||t instanceof Document)n&&(F.mostRecentlyFocusedNode=t);else{var o;e.stopImmediatePropagation();var a=!0;if(F.mostRecentlyFocusedNode)if(r(F.mostRecentlyFocusedNode)>0){var i=E(F.mostRecentlyFocusedNode),u=F.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===F.mostRecentlyFocusedNode}));c>=0&&(N.isKeyForward(F.recentNavEvent)?c+1<u.length&&(o=u[c+1],a=!1):c-1>=0&&(o=u[c-1],a=!1))}}else F.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return r(e)>0}))}))||(a=!1);else a=!1;a&&(o=x({target:F.mostRecentlyFocusedNode,isBackward:N.isKeyBackward(F.recentNavEvent)})),G(o||(F.mostRecentlyFocusedNode||T()))}F.recentNavEvent=void 0},I=function(e){if(!(t=e,"Escape"!==(null==t?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===p(N.escapeDeactivates,e)))return e.preventDefault(),void h.deactivate();var t;(N.isKeyForward(e)||N.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];F.recentNavEvent=e;var n=x({event:e,isBackward:t});n&&(l(e)&&e.preventDefault(),G(n))}(e,N.isKeyBackward(e))},L=function(e){var t=m(e);E(t,e)>=0||p(N.clickOutsideDeactivates,e)||p(N.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},C=function(){if(F.active)return c(g,h),F.delayInitialFocusTimer=N.delayInitialFocus?b((function(){G(T())})):G(T()),w.addEventListener("focusin",B,!0),w.addEventListener("mousedown",j,{capture:!0,passive:!1}),w.addEventListener("touchstart",j,{capture:!0,passive:!1}),w.addEventListener("click",L,{capture:!0,passive:!1}),w.addEventListener("keydown",I,{capture:!0,passive:!1}),h},A=function(){if(F.active)return w.removeEventListener("focusin",B,!0),w.removeEventListener("mousedown",j,!0),w.removeEventListener("touchstart",j,!0),w.removeEventListener("click",L,!0),w.removeEventListener("keydown",I,!0),h},S="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===F.mostRecentlyFocusedNode}))}))&&G(T())})):void 0,K=function(){S&&(S.disconnect(),F.active&&!F.paused&&F.containers.map((function(e){S.observe(e,{subtree:!0,childList:!0})})))};return(h={get active(){return F.active},get paused(){return F.paused},activate:function(e){if(F.active)return this;var t=O(e,"onActivate"),n=O(e,"onPostActivate"),o=O(e,"checkCanFocusTrap");o||D(),F.active=!0,F.paused=!1,F.nodeFocusedBeforeActivation=w.activeElement,null==t||t();var r=function(){o&&D(),C(),K(),null==n||n()};return o?(o(F.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!F.active)return this;var t=i({onDeactivate:N.onDeactivate,onPostDeactivate:N.onPostDeactivate,checkCanReturnFocus:N.checkCanReturnFocus},e);clearTimeout(F.delayInitialFocusTimer),F.delayInitialFocusTimer=void 0,A(),F.active=!1,F.paused=!1,K(),s(g,h);var n=O(t,"onDeactivate"),o=O(t,"onPostDeactivate"),r=O(t,"checkCanReturnFocus"),a=O(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var u=function(){b((function(){a&&G(R(F.nodeFocusedBeforeActivation)),null==o||o()}))};return a&&r?(r(R(F.nodeFocusedBeforeActivation)).then(u,u),this):(u(),this)},pause:function(e){if(F.paused||!F.active)return this;var t=O(e,"onPause"),n=O(e,"onPostPause");return F.paused=!0,null==t||t(),A(),K(),null==n||n(),this},unpause:function(e){if(!F.paused||!F.active)return this;var t=O(e,"onUnpause"),n=O(e,"onPostUnpause");return F.paused=!1,null==t||t(),D(),C(),K(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return F.containers=t.map((function(e){return"string"==typeof e?w.querySelector(e):e})),F.active&&D(),K(),this}}).updateContainerElements(a),h};export{h as createFocusTrap};
//# sourceMappingURL=focus-trap.esm.min.js.map
/*!
* focus-trap 7.5.3
* focus-trap 7.5.4
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -407,2 +407,21 @@ */

};
/**
* Gets the current activeElement. If it's a web-component and has open shadow-root
* it will recursively search inside shadow roots for the "true" activeElement.
*
* @param {Document | ShadowRoot} el
*
* @returns {HTMLElement} The element that currently has the focus
**/
var getActiveElement = function getActiveElement(el) {
var activeElement = el.activeElement;
if (!activeElement) {
return;
}
if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
return getActiveElement(activeElement.shadowRoot);
}
return activeElement;
};
var tryFocus = function tryFocus(node) {

@@ -412,3 +431,3 @@ if (node === false) {

}
if (node === doc.activeElement) {
if (node === getActiveElement(document)) {
return;

@@ -415,0 +434,0 @@ }

/*!
* focus-trap 7.5.3
* focus-trap 7.5.4
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tabbable");function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function n(e){for(var n=1;n<arguments.length;n++){var a=null!=arguments[n]?arguments[n]:{};n%2?t(Object(a),!0).forEach((function(t){o(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):t(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},r=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},i=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},u=function(e){return i(e)&&!e.shiftKey},s=function(e){return i(e)&&e.shiftKey},c=function(e){return setTimeout(e,0)},l=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},b=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},d=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},f=[];exports.createFocusTrap=function(t,o){var v,p=(null==o?void 0:o.document)||document,m=(null==o?void 0:o.trapStack)||f,y=n({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:u,isKeyBackward:s},o),h={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},g=function(e,t,n){return e&&void 0!==e[t]?e[t]:y[n||t]},w=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return h.containerGroups.findIndex((function(t){var o=t.container,a=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||a.find((function(t){return t===e}))}))},F=function(e){var t=y[e];if("function"==typeof t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];t=t.apply(void 0,o)}if(!0===t&&(t=void 0),!t){if(void 0===t||!1===t)return t;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var r=t;if("string"==typeof t&&!(r=p.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return r},N=function(){var t=F("initialFocus");if(!1===t)return!1;if(void 0===t||!e.isFocusable(t,y.tabbableOptions))if(w(p.activeElement)>=0)t=p.activeElement;else{var n=h.tabbableGroups[0];t=n&&n.firstTabbableNode||F("fallbackFocus")}if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},T=function(){if(h.containerGroups=h.containers.map((function(t){var n=e.tabbable(t,y.tabbableOptions),o=e.focusable(t,y.tabbableOptions),a=n.length>0?n[0]:void 0,r=n.length>0?n[n.length-1]:void 0,i=o.find((function(t){return e.isTabbable(t)})),u=o.slice().reverse().find((function(t){return e.isTabbable(t)})),s=!!n.find((function(t){return e.getTabIndex(t)>0}));return{container:t,tabbableNodes:n,focusableNodes:o,posTabIndexesFound:s,firstTabbableNode:a,lastTabbableNode:r,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(t){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=n.indexOf(t);return r<0?a?o.slice(o.indexOf(t)+1).find((function(t){return e.isTabbable(t)})):o.slice(0,o.indexOf(t)).reverse().find((function(t){return e.isTabbable(t)})):n[r+(a?1:-1)]}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),h.tabbableGroups.length<=0&&!F("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(h.containerGroups.find((function(e){return e.posTabIndexesFound}))&&h.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},O=function e(t){!1!==t&&t!==p.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!y.preventScroll}),h.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(N()))},E=function(e){var t=F("setReturnFocus",e);return t||!1!==t&&e},k=function(t){var n=t.target,o=t.event,a=t.isBackward,r=void 0!==a&&a;n=n||d(o),T();var u=null;if(h.tabbableGroups.length>0){var s=w(n,o),c=s>=0?h.containerGroups[s]:void 0;if(s<0)u=r?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(r){var b=l(h.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(b<0&&(c.container===n||e.isFocusable(n,y.tabbableOptions)&&!e.isTabbable(n,y.tabbableOptions)&&!c.nextTabbableNode(n,!1))&&(b=s),b>=0){var f=0===b?h.tabbableGroups.length-1:b-1,v=h.tabbableGroups[f];u=e.getTabIndex(n)>=0?v.lastTabbableNode:v.lastDomTabbableNode}else i(o)||(u=c.nextTabbableNode(n,!1))}else{var p=l(h.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(p<0&&(c.container===n||e.isFocusable(n,y.tabbableOptions)&&!e.isTabbable(n,y.tabbableOptions)&&!c.nextTabbableNode(n))&&(p=s),p>=0){var m=p===h.tabbableGroups.length-1?0:p+1,g=h.tabbableGroups[m];u=e.getTabIndex(n)>=0?g.firstTabbableNode:g.firstDomTabbableNode}else i(o)||(u=c.nextTabbableNode(n))}}else u=F("fallbackFocus");return u},P=function(e){var t=d(e);w(t,e)>=0||(b(y.clickOutsideDeactivates,e)?v.deactivate({returnFocus:y.returnFocusOnDeactivate}):b(y.allowOutsideClick,e)||e.preventDefault())},D=function(t){var n=d(t),o=w(n,t)>=0;if(o||n instanceof Document)o&&(h.mostRecentlyFocusedNode=n);else{var a;t.stopImmediatePropagation();var r=!0;if(h.mostRecentlyFocusedNode)if(e.getTabIndex(h.mostRecentlyFocusedNode)>0){var i=w(h.mostRecentlyFocusedNode),u=h.containerGroups[i].tabbableNodes;if(u.length>0){var s=u.findIndex((function(e){return e===h.mostRecentlyFocusedNode}));s>=0&&(y.isKeyForward(h.recentNavEvent)?s+1<u.length&&(a=u[s+1],r=!1):s-1>=0&&(a=u[s-1],r=!1))}}else h.containerGroups.some((function(t){return t.tabbableNodes.some((function(t){return e.getTabIndex(t)>0}))}))||(r=!1);else r=!1;r&&(a=k({target:h.mostRecentlyFocusedNode,isBackward:y.isKeyBackward(h.recentNavEvent)})),O(a||(h.mostRecentlyFocusedNode||N()))}h.recentNavEvent=void 0},x=function(e){if(!(t=e,"Escape"!==(null==t?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===b(y.escapeDeactivates,e)))return e.preventDefault(),void v.deactivate();var t;(y.isKeyForward(e)||y.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];h.recentNavEvent=e;var n=k({event:e,isBackward:t});n&&(i(e)&&e.preventDefault(),O(n))}(e,y.isKeyBackward(e))},G=function(e){var t=d(e);w(t,e)>=0||b(y.clickOutsideDeactivates,e)||b(y.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},I=function(){if(h.active)return a(m,v),h.delayInitialFocusTimer=y.delayInitialFocus?c((function(){O(N())})):O(N()),p.addEventListener("focusin",D,!0),p.addEventListener("mousedown",P,{capture:!0,passive:!1}),p.addEventListener("touchstart",P,{capture:!0,passive:!1}),p.addEventListener("click",G,{capture:!0,passive:!1}),p.addEventListener("keydown",x,{capture:!0,passive:!1}),v},j=function(){if(h.active)return p.removeEventListener("focusin",D,!0),p.removeEventListener("mousedown",P,!0),p.removeEventListener("touchstart",P,!0),p.removeEventListener("click",G,!0),p.removeEventListener("keydown",x,!0),v},R="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===h.mostRecentlyFocusedNode}))}))&&O(N())})):void 0,B=function(){R&&(R.disconnect(),h.active&&!h.paused&&h.containers.map((function(e){R.observe(e,{subtree:!0,childList:!0})})))};return(v={get active(){return h.active},get paused(){return h.paused},activate:function(e){if(h.active)return this;var t=g(e,"onActivate"),n=g(e,"onPostActivate"),o=g(e,"checkCanFocusTrap");o||T(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=p.activeElement,null==t||t();var a=function(){o&&T(),I(),B(),null==n||n()};return o?(o(h.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(e){if(!h.active)return this;var t=n({onDeactivate:y.onDeactivate,onPostDeactivate:y.onPostDeactivate,checkCanReturnFocus:y.checkCanReturnFocus},e);clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,j(),h.active=!1,h.paused=!1,B(),r(m,v);var o=g(t,"onDeactivate"),a=g(t,"onPostDeactivate"),i=g(t,"checkCanReturnFocus"),u=g(t,"returnFocus","returnFocusOnDeactivate");null==o||o();var s=function(){c((function(){u&&O(E(h.nodeFocusedBeforeActivation)),null==a||a()}))};return u&&i?(i(E(h.nodeFocusedBeforeActivation)).then(s,s),this):(s(),this)},pause:function(e){if(h.paused||!h.active)return this;var t=g(e,"onPause"),n=g(e,"onPostPause");return h.paused=!0,null==t||t(),j(),B(),null==n||n(),this},unpause:function(e){if(!h.paused||!h.active)return this;var t=g(e,"onUnpause"),n=g(e,"onPostUnpause");return h.paused=!1,null==t||t(),T(),I(),B(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?p.querySelector(e):e})),h.active&&T(),B(),this}}).updateContainerElements(t),v};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tabbable");function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function n(e){for(var n=1;n<arguments.length;n++){var a=null!=arguments[n]?arguments[n]:{};n%2?t(Object(a),!0).forEach((function(t){o(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):t(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},r=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},i=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},u=function(e){return i(e)&&!e.shiftKey},s=function(e){return i(e)&&e.shiftKey},c=function(e){return setTimeout(e,0)},l=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},b=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},d=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},f=[];exports.createFocusTrap=function(t,o){var v,p=(null==o?void 0:o.document)||document,m=(null==o?void 0:o.trapStack)||f,y=n({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:u,isKeyBackward:s},o),h={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},w=function(e,t,n){return e&&void 0!==e[t]?e[t]:y[n||t]},g=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return h.containerGroups.findIndex((function(t){var o=t.container,a=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||a.find((function(t){return t===e}))}))},F=function(e){var t=y[e];if("function"==typeof t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];t=t.apply(void 0,o)}if(!0===t&&(t=void 0),!t){if(void 0===t||!1===t)return t;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var r=t;if("string"==typeof t&&!(r=p.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return r},N=function(){var t=F("initialFocus");if(!1===t)return!1;if(void 0===t||!e.isFocusable(t,y.tabbableOptions))if(g(p.activeElement)>=0)t=p.activeElement;else{var n=h.tabbableGroups[0];t=n&&n.firstTabbableNode||F("fallbackFocus")}if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},T=function(){if(h.containerGroups=h.containers.map((function(t){var n=e.tabbable(t,y.tabbableOptions),o=e.focusable(t,y.tabbableOptions),a=n.length>0?n[0]:void 0,r=n.length>0?n[n.length-1]:void 0,i=o.find((function(t){return e.isTabbable(t)})),u=o.slice().reverse().find((function(t){return e.isTabbable(t)})),s=!!n.find((function(t){return e.getTabIndex(t)>0}));return{container:t,tabbableNodes:n,focusableNodes:o,posTabIndexesFound:s,firstTabbableNode:a,lastTabbableNode:r,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(t){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=n.indexOf(t);return r<0?a?o.slice(o.indexOf(t)+1).find((function(t){return e.isTabbable(t)})):o.slice(0,o.indexOf(t)).reverse().find((function(t){return e.isTabbable(t)})):n[r+(a?1:-1)]}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),h.tabbableGroups.length<=0&&!F("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(h.containerGroups.find((function(e){return e.posTabIndexesFound}))&&h.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},O=function e(t){var n=t.activeElement;if(n)return n.shadowRoot&&null!==n.shadowRoot.activeElement?e(n.shadowRoot):n},E=function e(t){!1!==t&&t!==O(document)&&(t&&t.focus?(t.focus({preventScroll:!!y.preventScroll}),h.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(N()))},k=function(e){var t=F("setReturnFocus",e);return t||!1!==t&&e},P=function(t){var n=t.target,o=t.event,a=t.isBackward,r=void 0!==a&&a;n=n||d(o),T();var u=null;if(h.tabbableGroups.length>0){var s=g(n,o),c=s>=0?h.containerGroups[s]:void 0;if(s<0)u=r?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(r){var b=l(h.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(b<0&&(c.container===n||e.isFocusable(n,y.tabbableOptions)&&!e.isTabbable(n,y.tabbableOptions)&&!c.nextTabbableNode(n,!1))&&(b=s),b>=0){var f=0===b?h.tabbableGroups.length-1:b-1,v=h.tabbableGroups[f];u=e.getTabIndex(n)>=0?v.lastTabbableNode:v.lastDomTabbableNode}else i(o)||(u=c.nextTabbableNode(n,!1))}else{var p=l(h.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(p<0&&(c.container===n||e.isFocusable(n,y.tabbableOptions)&&!e.isTabbable(n,y.tabbableOptions)&&!c.nextTabbableNode(n))&&(p=s),p>=0){var m=p===h.tabbableGroups.length-1?0:p+1,w=h.tabbableGroups[m];u=e.getTabIndex(n)>=0?w.firstTabbableNode:w.firstDomTabbableNode}else i(o)||(u=c.nextTabbableNode(n))}}else u=F("fallbackFocus");return u},D=function(e){var t=d(e);g(t,e)>=0||(b(y.clickOutsideDeactivates,e)?v.deactivate({returnFocus:y.returnFocusOnDeactivate}):b(y.allowOutsideClick,e)||e.preventDefault())},x=function(t){var n=d(t),o=g(n,t)>=0;if(o||n instanceof Document)o&&(h.mostRecentlyFocusedNode=n);else{var a;t.stopImmediatePropagation();var r=!0;if(h.mostRecentlyFocusedNode)if(e.getTabIndex(h.mostRecentlyFocusedNode)>0){var i=g(h.mostRecentlyFocusedNode),u=h.containerGroups[i].tabbableNodes;if(u.length>0){var s=u.findIndex((function(e){return e===h.mostRecentlyFocusedNode}));s>=0&&(y.isKeyForward(h.recentNavEvent)?s+1<u.length&&(a=u[s+1],r=!1):s-1>=0&&(a=u[s-1],r=!1))}}else h.containerGroups.some((function(t){return t.tabbableNodes.some((function(t){return e.getTabIndex(t)>0}))}))||(r=!1);else r=!1;r&&(a=P({target:h.mostRecentlyFocusedNode,isBackward:y.isKeyBackward(h.recentNavEvent)})),E(a||(h.mostRecentlyFocusedNode||N()))}h.recentNavEvent=void 0},G=function(e){if(!(t=e,"Escape"!==(null==t?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===b(y.escapeDeactivates,e)))return e.preventDefault(),void v.deactivate();var t;(y.isKeyForward(e)||y.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];h.recentNavEvent=e;var n=P({event:e,isBackward:t});n&&(i(e)&&e.preventDefault(),E(n))}(e,y.isKeyBackward(e))},R=function(e){var t=d(e);g(t,e)>=0||b(y.clickOutsideDeactivates,e)||b(y.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},I=function(){if(h.active)return a(m,v),h.delayInitialFocusTimer=y.delayInitialFocus?c((function(){E(N())})):E(N()),p.addEventListener("focusin",x,!0),p.addEventListener("mousedown",D,{capture:!0,passive:!1}),p.addEventListener("touchstart",D,{capture:!0,passive:!1}),p.addEventListener("click",R,{capture:!0,passive:!1}),p.addEventListener("keydown",G,{capture:!0,passive:!1}),v},j=function(){if(h.active)return p.removeEventListener("focusin",x,!0),p.removeEventListener("mousedown",D,!0),p.removeEventListener("touchstart",D,!0),p.removeEventListener("click",R,!0),p.removeEventListener("keydown",G,!0),v},B="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===h.mostRecentlyFocusedNode}))}))&&E(N())})):void 0,L=function(){B&&(B.disconnect(),h.active&&!h.paused&&h.containers.map((function(e){B.observe(e,{subtree:!0,childList:!0})})))};return(v={get active(){return h.active},get paused(){return h.paused},activate:function(e){if(h.active)return this;var t=w(e,"onActivate"),n=w(e,"onPostActivate"),o=w(e,"checkCanFocusTrap");o||T(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=p.activeElement,null==t||t();var a=function(){o&&T(),I(),L(),null==n||n()};return o?(o(h.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(e){if(!h.active)return this;var t=n({onDeactivate:y.onDeactivate,onPostDeactivate:y.onPostDeactivate,checkCanReturnFocus:y.checkCanReturnFocus},e);clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,j(),h.active=!1,h.paused=!1,L(),r(m,v);var o=w(t,"onDeactivate"),a=w(t,"onPostDeactivate"),i=w(t,"checkCanReturnFocus"),u=w(t,"returnFocus","returnFocusOnDeactivate");null==o||o();var s=function(){c((function(){u&&E(k(h.nodeFocusedBeforeActivation)),null==a||a()}))};return u&&i?(i(k(h.nodeFocusedBeforeActivation)).then(s,s),this):(s(),this)},pause:function(e){if(h.paused||!h.active)return this;var t=w(e,"onPause"),n=w(e,"onPostPause");return h.paused=!0,null==t||t(),j(),L(),null==n||n(),this},unpause:function(e){if(!h.paused||!h.active)return this;var t=w(e,"onUnpause"),n=w(e,"onPostUnpause");return h.paused=!1,null==t||t(),T(),I(),L(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?p.querySelector(e):e})),h.active&&T(),L(),this}}).updateContainerElements(t),v};
//# sourceMappingURL=focus-trap.min.js.map
/*!
* focus-trap 7.5.3
* focus-trap 7.5.4
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -412,2 +412,21 @@ */

};
/**
* Gets the current activeElement. If it's a web-component and has open shadow-root
* it will recursively search inside shadow roots for the "true" activeElement.
*
* @param {Document | ShadowRoot} el
*
* @returns {HTMLElement} The element that currently has the focus
**/
var getActiveElement = function getActiveElement(el) {
var activeElement = el.activeElement;
if (!activeElement) {
return;
}
if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
return getActiveElement(activeElement.shadowRoot);
}
return activeElement;
};
var tryFocus = function tryFocus(node) {

@@ -417,3 +436,3 @@ if (node === false) {

}
if (node === doc.activeElement) {
if (node === getActiveElement(document)) {
return;

@@ -420,0 +439,0 @@ }

/*!
* focus-trap 7.5.3
* focus-trap 7.5.4
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tabbable")):"function"==typeof define&&define.amd?define(["exports","tabbable"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.focusTrap,o=e.focusTrap={};t(o,e.tabbable),o.noConflict=function(){return e.focusTrap=n,o}}())}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){a(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function a(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},i=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},u=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},c=function(e){return u(e)&&!e.shiftKey},s=function(e){return u(e)&&e.shiftKey},l=function(e){return setTimeout(e,0)},b=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},f=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},v=[];e.createFocusTrap=function(e,n){var a,p=(null==n?void 0:n.document)||document,y=(null==n?void 0:n.trapStack)||v,m=o({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:c,isKeyBackward:s},n),h={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},g=function(e,t,n){return e&&void 0!==e[t]?e[t]:m[n||t]},w=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return h.containerGroups.findIndex((function(t){var o=t.container,a=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||a.find((function(t){return t===e}))}))},T=function(e){var t=m[e];if("function"==typeof t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];t=t.apply(void 0,o)}if(!0===t&&(t=void 0),!t){if(void 0===t||!1===t)return t;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var r=t;if("string"==typeof t&&!(r=p.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return r},F=function(){var e=T("initialFocus");if(!1===e)return!1;if(void 0===e||!t.isFocusable(e,m.tabbableOptions))if(w(p.activeElement)>=0)e=p.activeElement;else{var n=h.tabbableGroups[0];e=n&&n.firstTabbableNode||T("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},N=function(){if(h.containerGroups=h.containers.map((function(e){var n=t.tabbable(e,m.tabbableOptions),o=t.focusable(e,m.tabbableOptions),a=n.length>0?n[0]:void 0,r=n.length>0?n[n.length-1]:void 0,i=o.find((function(e){return t.isTabbable(e)})),u=o.slice().reverse().find((function(e){return t.isTabbable(e)})),c=!!n.find((function(e){return t.getTabIndex(e)>0}));return{container:e,tabbableNodes:n,focusableNodes:o,posTabIndexesFound:c,firstTabbableNode:a,lastTabbableNode:r,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(e){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=n.indexOf(e);return r<0?a?o.slice(o.indexOf(e)+1).find((function(e){return t.isTabbable(e)})):o.slice(0,o.indexOf(e)).reverse().find((function(e){return t.isTabbable(e)})):n[r+(a?1:-1)]}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),h.tabbableGroups.length<=0&&!T("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(h.containerGroups.find((function(e){return e.posTabIndexesFound}))&&h.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},O=function e(t){!1!==t&&t!==p.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!m.preventScroll}),h.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(F()))},E=function(e){var t=T("setReturnFocus",e);return t||!1!==t&&e},k=function(e){var n=e.target,o=e.event,a=e.isBackward,r=void 0!==a&&a;n=n||f(o),N();var i=null;if(h.tabbableGroups.length>0){var c=w(n,o),s=c>=0?h.containerGroups[c]:void 0;if(c<0)i=r?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(r){var l=b(h.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(l<0&&(s.container===n||t.isFocusable(n,m.tabbableOptions)&&!t.isTabbable(n,m.tabbableOptions)&&!s.nextTabbableNode(n,!1))&&(l=c),l>=0){var d=0===l?h.tabbableGroups.length-1:l-1,v=h.tabbableGroups[d];i=t.getTabIndex(n)>=0?v.lastTabbableNode:v.lastDomTabbableNode}else u(o)||(i=s.nextTabbableNode(n,!1))}else{var p=b(h.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(p<0&&(s.container===n||t.isFocusable(n,m.tabbableOptions)&&!t.isTabbable(n,m.tabbableOptions)&&!s.nextTabbableNode(n))&&(p=c),p>=0){var y=p===h.tabbableGroups.length-1?0:p+1,g=h.tabbableGroups[y];i=t.getTabIndex(n)>=0?g.firstTabbableNode:g.firstDomTabbableNode}else u(o)||(i=s.nextTabbableNode(n))}}else i=T("fallbackFocus");return i},P=function(e){var t=f(e);w(t,e)>=0||(d(m.clickOutsideDeactivates,e)?a.deactivate({returnFocus:m.returnFocusOnDeactivate}):d(m.allowOutsideClick,e)||e.preventDefault())},D=function(e){var n=f(e),o=w(n,e)>=0;if(o||n instanceof Document)o&&(h.mostRecentlyFocusedNode=n);else{var a;e.stopImmediatePropagation();var r=!0;if(h.mostRecentlyFocusedNode)if(t.getTabIndex(h.mostRecentlyFocusedNode)>0){var i=w(h.mostRecentlyFocusedNode),u=h.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===h.mostRecentlyFocusedNode}));c>=0&&(m.isKeyForward(h.recentNavEvent)?c+1<u.length&&(a=u[c+1],r=!1):c-1>=0&&(a=u[c-1],r=!1))}}else h.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return t.getTabIndex(e)>0}))}))||(r=!1);else r=!1;r&&(a=k({target:h.mostRecentlyFocusedNode,isBackward:m.isKeyBackward(h.recentNavEvent)})),O(a||(h.mostRecentlyFocusedNode||F()))}h.recentNavEvent=void 0},x=function(e){if(!(t=e,"Escape"!==(null==t?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===d(m.escapeDeactivates,e)))return e.preventDefault(),void a.deactivate();var t;(m.isKeyForward(e)||m.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];h.recentNavEvent=e;var n=k({event:e,isBackward:t});n&&(u(e)&&e.preventDefault(),O(n))}(e,m.isKeyBackward(e))},G=function(e){var t=f(e);w(t,e)>=0||d(m.clickOutsideDeactivates,e)||d(m.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},I=function(){if(h.active)return r(y,a),h.delayInitialFocusTimer=m.delayInitialFocus?l((function(){O(F())})):O(F()),p.addEventListener("focusin",D,!0),p.addEventListener("mousedown",P,{capture:!0,passive:!1}),p.addEventListener("touchstart",P,{capture:!0,passive:!1}),p.addEventListener("click",G,{capture:!0,passive:!1}),p.addEventListener("keydown",x,{capture:!0,passive:!1}),a},j=function(){if(h.active)return p.removeEventListener("focusin",D,!0),p.removeEventListener("mousedown",P,!0),p.removeEventListener("touchstart",P,!0),p.removeEventListener("click",G,!0),p.removeEventListener("keydown",x,!0),a},R="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===h.mostRecentlyFocusedNode}))}))&&O(F())})):void 0,B=function(){R&&(R.disconnect(),h.active&&!h.paused&&h.containers.map((function(e){R.observe(e,{subtree:!0,childList:!0})})))};return(a={get active(){return h.active},get paused(){return h.paused},activate:function(e){if(h.active)return this;var t=g(e,"onActivate"),n=g(e,"onPostActivate"),o=g(e,"checkCanFocusTrap");o||N(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=p.activeElement,null==t||t();var a=function(){o&&N(),I(),B(),null==n||n()};return o?(o(h.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(e){if(!h.active)return this;var t=o({onDeactivate:m.onDeactivate,onPostDeactivate:m.onPostDeactivate,checkCanReturnFocus:m.checkCanReturnFocus},e);clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,j(),h.active=!1,h.paused=!1,B(),i(y,a);var n=g(t,"onDeactivate"),r=g(t,"onPostDeactivate"),u=g(t,"checkCanReturnFocus"),c=g(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var s=function(){l((function(){c&&O(E(h.nodeFocusedBeforeActivation)),null==r||r()}))};return c&&u?(u(E(h.nodeFocusedBeforeActivation)).then(s,s),this):(s(),this)},pause:function(e){if(h.paused||!h.active)return this;var t=g(e,"onPause"),n=g(e,"onPostPause");return h.paused=!0,null==t||t(),j(),B(),null==n||n(),this},unpause:function(e){if(!h.paused||!h.active)return this;var t=g(e,"onUnpause"),n=g(e,"onPostUnpause");return h.paused=!1,null==t||t(),N(),I(),B(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?p.querySelector(e):e})),h.active&&N(),B(),this}}).updateContainerElements(e),a},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tabbable")):"function"==typeof define&&define.amd?define(["exports","tabbable"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.focusTrap,o=e.focusTrap={};t(o,e.tabbable),o.noConflict=function(){return e.focusTrap=n,o}}())}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){a(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function a(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},i=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()},u=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},c=function(e){return u(e)&&!e.shiftKey},s=function(e){return u(e)&&e.shiftKey},l=function(e){return setTimeout(e,0)},b=function(e,t){var n=-1;return e.every((function(e,o){return!t(e)||(n=o,!1)})),n},d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},f=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},v=[];e.createFocusTrap=function(e,n){var a,p=(null==n?void 0:n.document)||document,m=(null==n?void 0:n.trapStack)||v,y=o({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:c,isKeyBackward:s},n),h={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},w=function(e,t,n){return e&&void 0!==e[t]?e[t]:y[n||t]},g=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return h.containerGroups.findIndex((function(t){var o=t.container,a=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||a.find((function(t){return t===e}))}))},T=function(e){var t=y[e];if("function"==typeof t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];t=t.apply(void 0,o)}if(!0===t&&(t=void 0),!t){if(void 0===t||!1===t)return t;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var r=t;if("string"==typeof t&&!(r=p.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return r},F=function(){var e=T("initialFocus");if(!1===e)return!1;if(void 0===e||!t.isFocusable(e,y.tabbableOptions))if(g(p.activeElement)>=0)e=p.activeElement;else{var n=h.tabbableGroups[0];e=n&&n.firstTabbableNode||T("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},N=function(){if(h.containerGroups=h.containers.map((function(e){var n=t.tabbable(e,y.tabbableOptions),o=t.focusable(e,y.tabbableOptions),a=n.length>0?n[0]:void 0,r=n.length>0?n[n.length-1]:void 0,i=o.find((function(e){return t.isTabbable(e)})),u=o.slice().reverse().find((function(e){return t.isTabbable(e)})),c=!!n.find((function(e){return t.getTabIndex(e)>0}));return{container:e,tabbableNodes:n,focusableNodes:o,posTabIndexesFound:c,firstTabbableNode:a,lastTabbableNode:r,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(e){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=n.indexOf(e);return r<0?a?o.slice(o.indexOf(e)+1).find((function(e){return t.isTabbable(e)})):o.slice(0,o.indexOf(e)).reverse().find((function(e){return t.isTabbable(e)})):n[r+(a?1:-1)]}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),h.tabbableGroups.length<=0&&!T("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(h.containerGroups.find((function(e){return e.posTabIndexesFound}))&&h.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},O=function e(t){var n=t.activeElement;if(n)return n.shadowRoot&&null!==n.shadowRoot.activeElement?e(n.shadowRoot):n},E=function e(t){!1!==t&&t!==O(document)&&(t&&t.focus?(t.focus({preventScroll:!!y.preventScroll}),h.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(F()))},k=function(e){var t=T("setReturnFocus",e);return t||!1!==t&&e},P=function(e){var n=e.target,o=e.event,a=e.isBackward,r=void 0!==a&&a;n=n||f(o),N();var i=null;if(h.tabbableGroups.length>0){var c=g(n,o),s=c>=0?h.containerGroups[c]:void 0;if(c<0)i=r?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(r){var l=b(h.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(l<0&&(s.container===n||t.isFocusable(n,y.tabbableOptions)&&!t.isTabbable(n,y.tabbableOptions)&&!s.nextTabbableNode(n,!1))&&(l=c),l>=0){var d=0===l?h.tabbableGroups.length-1:l-1,v=h.tabbableGroups[d];i=t.getTabIndex(n)>=0?v.lastTabbableNode:v.lastDomTabbableNode}else u(o)||(i=s.nextTabbableNode(n,!1))}else{var p=b(h.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(p<0&&(s.container===n||t.isFocusable(n,y.tabbableOptions)&&!t.isTabbable(n,y.tabbableOptions)&&!s.nextTabbableNode(n))&&(p=c),p>=0){var m=p===h.tabbableGroups.length-1?0:p+1,w=h.tabbableGroups[m];i=t.getTabIndex(n)>=0?w.firstTabbableNode:w.firstDomTabbableNode}else u(o)||(i=s.nextTabbableNode(n))}}else i=T("fallbackFocus");return i},D=function(e){var t=f(e);g(t,e)>=0||(d(y.clickOutsideDeactivates,e)?a.deactivate({returnFocus:y.returnFocusOnDeactivate}):d(y.allowOutsideClick,e)||e.preventDefault())},x=function(e){var n=f(e),o=g(n,e)>=0;if(o||n instanceof Document)o&&(h.mostRecentlyFocusedNode=n);else{var a;e.stopImmediatePropagation();var r=!0;if(h.mostRecentlyFocusedNode)if(t.getTabIndex(h.mostRecentlyFocusedNode)>0){var i=g(h.mostRecentlyFocusedNode),u=h.containerGroups[i].tabbableNodes;if(u.length>0){var c=u.findIndex((function(e){return e===h.mostRecentlyFocusedNode}));c>=0&&(y.isKeyForward(h.recentNavEvent)?c+1<u.length&&(a=u[c+1],r=!1):c-1>=0&&(a=u[c-1],r=!1))}}else h.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return t.getTabIndex(e)>0}))}))||(r=!1);else r=!1;r&&(a=P({target:h.mostRecentlyFocusedNode,isBackward:y.isKeyBackward(h.recentNavEvent)})),E(a||(h.mostRecentlyFocusedNode||F()))}h.recentNavEvent=void 0},G=function(e){if(!(t=e,"Escape"!==(null==t?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===d(y.escapeDeactivates,e)))return e.preventDefault(),void a.deactivate();var t;(y.isKeyForward(e)||y.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];h.recentNavEvent=e;var n=P({event:e,isBackward:t});n&&(u(e)&&e.preventDefault(),E(n))}(e,y.isKeyBackward(e))},R=function(e){var t=f(e);g(t,e)>=0||d(y.clickOutsideDeactivates,e)||d(y.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},I=function(){if(h.active)return r(m,a),h.delayInitialFocusTimer=y.delayInitialFocus?l((function(){E(F())})):E(F()),p.addEventListener("focusin",x,!0),p.addEventListener("mousedown",D,{capture:!0,passive:!1}),p.addEventListener("touchstart",D,{capture:!0,passive:!1}),p.addEventListener("click",R,{capture:!0,passive:!1}),p.addEventListener("keydown",G,{capture:!0,passive:!1}),a},j=function(){if(h.active)return p.removeEventListener("focusin",x,!0),p.removeEventListener("mousedown",D,!0),p.removeEventListener("touchstart",D,!0),p.removeEventListener("click",R,!0),p.removeEventListener("keydown",G,!0),a},B="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===h.mostRecentlyFocusedNode}))}))&&E(F())})):void 0,C=function(){B&&(B.disconnect(),h.active&&!h.paused&&h.containers.map((function(e){B.observe(e,{subtree:!0,childList:!0})})))};return(a={get active(){return h.active},get paused(){return h.paused},activate:function(e){if(h.active)return this;var t=w(e,"onActivate"),n=w(e,"onPostActivate"),o=w(e,"checkCanFocusTrap");o||N(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=p.activeElement,null==t||t();var a=function(){o&&N(),I(),C(),null==n||n()};return o?(o(h.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(e){if(!h.active)return this;var t=o({onDeactivate:y.onDeactivate,onPostDeactivate:y.onPostDeactivate,checkCanReturnFocus:y.checkCanReturnFocus},e);clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,j(),h.active=!1,h.paused=!1,C(),i(m,a);var n=w(t,"onDeactivate"),r=w(t,"onPostDeactivate"),u=w(t,"checkCanReturnFocus"),c=w(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var s=function(){l((function(){c&&E(k(h.nodeFocusedBeforeActivation)),null==r||r()}))};return c&&u?(u(k(h.nodeFocusedBeforeActivation)).then(s,s),this):(s(),this)},pause:function(e){if(h.paused||!h.active)return this;var t=w(e,"onPause"),n=w(e,"onPostPause");return h.paused=!0,null==t||t(),j(),C(),null==n||n(),this},unpause:function(e){if(!h.paused||!h.active)return this;var t=w(e,"onUnpause"),n=w(e,"onPostUnpause");return h.paused=!1,null==t||t(),N(),I(),C(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?p.querySelector(e):e})),h.active&&N(),C(),this}}).updateContainerElements(e),a},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=focus-trap.umd.min.js.map

@@ -418,2 +418,27 @@ import {

/**
* Gets the current activeElement. If it's a web-component and has open shadow-root
* it will recursively search inside shadow roots for the "true" activeElement.
*
* @param {Document | ShadowRoot} el
*
* @returns {HTMLElement} The element that currently has the focus
**/
const getActiveElement = function (el) {
const activeElement = el.activeElement;
if (!activeElement) {
return;
}
if (
activeElement.shadowRoot &&
activeElement.shadowRoot.activeElement !== null
) {
return getActiveElement(activeElement.shadowRoot);
}
return activeElement;
};
const tryFocus = function (node) {

@@ -424,3 +449,3 @@ if (node === false) {

if (node === doc.activeElement) {
if (node === getActiveElement(document)) {
return;

@@ -427,0 +452,0 @@ }

{
"name": "focus-trap",
"version": "7.5.3",
"version": "7.5.4",
"description": "Trap focus within a DOM node.",

@@ -42,3 +42,4 @@ "main": "dist/focus-trap.js",

"prepublishOnly": "npm run test && npm run build",
"release": "npm run build && changeset publish"
"release": "npm run build && changeset publish",
"all-contributors": "all-contributors"
},

@@ -70,22 +71,22 @@ "repository": {

"devDependencies": {
"@babel/cli": "^7.22.15",
"@babel/core": "^7.22.20",
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.0",
"@babel/eslint-parser": "^7.22.15",
"@babel/preset-env": "^7.22.20",
"@changesets/cli": "^2.26.2",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.5",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@testing-library/cypress": "^10.0.1",
"@types/jquery": "^3.5.19",
"@types/jquery": "^3.5.22",
"all-contributors-cli": "^6.26.1",
"babel-loader": "^9.1.3",
"cross-env": "^7.0.3",
"cypress": "^13.2.0",
"cypress": "^13.3.0",
"cypress-plugin-tab": "^1.0.5",
"eslint": "^8.49.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-jest": "^27.4.0",
"eslint-plugin-jest": "^27.4.2",
"onchange": "^7.1.0",

@@ -98,5 +99,5 @@ "prettier": "^3.0.3",

"rollup-plugin-sourcemaps": "^0.6.3",
"start-server-and-test": "^2.0.0",
"start-server-and-test": "^2.0.1",
"typescript": "^5.2.2"
}
}
# focus-trap [![CI](https://github.com/focus-trap/focus-trap/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/focus-trap/focus-trap/actions?query=workflow:CI+branch:master) [![license](https://badgen.now.sh/badge/license/MIT)](./LICENSE)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-29-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-30-orange.svg?style=flat-square)](#contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

@@ -402,2 +402,3 @@

<td align="center" valign="top" width="14.28%"><a href="https://github.com/jpveooys"><img src="https://avatars.githubusercontent.com/u/66470099?v=4?s=100" width="100px;" alt="jpveooys"/><br /><sub><b>jpveooys</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Ajpveooys" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/simonxabris"><img src="https://avatars.githubusercontent.com/u/27497229?v=4?s=100" width="100px;" alt="Ábris Simon"/><br /><sub><b>Ábris Simon</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=simonxabris" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Asimonxabris" title="Bug reports">🐛</a></td>
</tr>

@@ -404,0 +405,0 @@ </tbody>

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

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

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