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

focus-trap

Package Overview
Dependencies
Maintainers
3
Versions
83
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 6.7.1 to 6.7.2

6

CHANGELOG.md
# Changelog
## 6.7.2
### Patch Changes
- c932330: Fixed bug where tabbing forward from an element with negative tabindex that is last in the trap would result in focus remaining on that element ([565](https://github.com/focus-trap/focus-trap/issues/565))
## 6.7.1

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

50

dist/focus-trap.esm.js
/*!
* focus-trap 6.7.1
* focus-trap 6.7.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
import { tabbable, isFocusable } from 'tabbable';
import { tabbable, isFocusable, isTabbable } from 'tabbable';

@@ -12,10 +12,5 @@ function ownKeys(object, enumerableOnly) {

var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}

@@ -28,15 +23,8 @@

for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}

@@ -157,2 +145,4 @@

var createFocusTrap = function createFocusTrap(elements, userOptions) {
// SSR: a live trap shouldn't be created in this type of environment so this
// should be safe code to execute if the `document` option isn't specified
var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;

@@ -391,3 +381,3 @@

// make sure the target is actually contained in a group
// NOTE: the target may also be the container itself if it's tabbable
// NOTE: the target may also be the container itself if it's focusable
// with tabIndex='-1' and was given initial focus

@@ -417,4 +407,6 @@ var containerIndex = findIndex(state.tabbableGroups, function (_ref) {

if (startOfGroupIndex < 0 && state.tabbableGroups[containerIndex].container === target) {
// an exception case where the target is the container itself, in which
if (startOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || isFocusable(target) && !isTabbable(target))) {
// an exception case where the target is either the container itself, or
// a non-tabbable node that was given focus (i.e. tabindex is negative
// and user clicked on it or node was programmatically given focus), in which
// case, we should handle shift+tab as if focus were on the container's

@@ -441,4 +433,6 @@ // first tabbable node, and go to the last tabbable node of the LAST group

if (lastOfGroupIndex < 0 && state.tabbableGroups[containerIndex].container === target) {
// an exception case where the target is the container itself, in which
if (lastOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || isFocusable(target) && !isTabbable(target))) {
// an exception case where the target is the container itself, or
// a non-tabbable node that was given focus (i.e. tabindex is negative
// and user clicked on it or node was programmatically given focus), in which
// case, we should handle tab as if focus were on the container's

@@ -445,0 +439,0 @@ // last tabbable node, and go to the first tabbable node of the FIRST group

/*!
* focus-trap 6.7.1
* focus-trap 6.7.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
*/
import{tabbable as e,isFocusable as t}from"tabbable";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r,o=(r=[],{activateTrap:function(e){if(r.length>0){var t=r[r.length-1];t!==e&&t.pause()}var n=r.indexOf(e);-1===n||r.splice(n,1),r.push(e)},deactivateTrap:function(e){var t=r.indexOf(e);-1!==t&&r.splice(t,1),r.length>0&&r[r.length-1].unpause()}}),i=function(e){return setTimeout(e,0)},c=function(e,t){var n=-1;return e.every((function(e,a){return!t(e)||(n=a,!1)})),n},u=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return"function"==typeof e?e.apply(void 0,n):e},s=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},l=function(r,l){var f,v=(null==l?void 0:l.document)||document,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},l),p={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},d=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},h=function(e){return!(!e||!p.containers.some((function(t){return t.contains(e)})))},m=function(e){var t=b[e];if("function"==typeof t){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];t=t.apply(void 0,a)}if(!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 o=t;if("string"==typeof t&&!(o=v.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return o},y=function(){var e=m("initialFocus");if(!1===e)return!1;if(void 0===e)if(h(v.activeElement))e=v.activeElement;else{var t=p.tabbableGroups[0];e=t&&t.firstTabbableNode||m("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},g=function(){if(p.tabbableGroups=p.containers.map((function(t){var n=e(t);if(n.length>0)return{container:t,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),p.tabbableGroups.length<=0&&!m("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},w=function e(t){!1!==t&&t!==v.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!b.preventScroll}),p.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(y()))},O=function(e){var t=m("setReturnFocus",e);return t||!1!==t&&e},F=function(e){var n=s(e);h(n)||(u(b.clickOutsideDeactivates,e)?f.deactivate({returnFocus:b.returnFocusOnDeactivate&&!t(n)}):u(b.allowOutsideClick,e)||e.preventDefault())},E=function(e){var t=s(e),n=h(t);n||t instanceof Document?n&&(p.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),w(p.mostRecentlyFocusedNode||y()))},T=function(e){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e)&&!1!==u(b.escapeDeactivates,e))return e.preventDefault(),void f.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){var t=s(e);g();var n=null;if(p.tabbableGroups.length>0){var a=c(p.tabbableGroups,(function(e){return e.container.contains(t)}));if(a<0)n=e.shiftKey?p.tabbableGroups[p.tabbableGroups.length-1].lastTabbableNode:p.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var r=c(p.tabbableGroups,(function(e){var n=e.firstTabbableNode;return t===n}));if(r<0&&p.tabbableGroups[a].container===t&&(r=a),r>=0){var o=0===r?p.tabbableGroups.length-1:r-1;n=p.tabbableGroups[o].lastTabbableNode}}else{var i=c(p.tabbableGroups,(function(e){var n=e.lastTabbableNode;return t===n}));if(i<0&&p.tabbableGroups[a].container===t&&(i=a),i>=0){var u=i===p.tabbableGroups.length-1?0:i+1;n=p.tabbableGroups[u].firstTabbableNode}}}else n=m("fallbackFocus");n&&(e.preventDefault(),w(n))}(e)},k=function(e){if(!u(b.clickOutsideDeactivates,e)){var t=s(e);h(t)||u(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},D=function(){if(p.active)return o.activateTrap(f),p.delayInitialFocusTimer=b.delayInitialFocus?i((function(){w(y())})):w(y()),v.addEventListener("focusin",E,!0),v.addEventListener("mousedown",F,{capture:!0,passive:!1}),v.addEventListener("touchstart",F,{capture:!0,passive:!1}),v.addEventListener("click",k,{capture:!0,passive:!1}),v.addEventListener("keydown",T,{capture:!0,passive:!1}),f},G=function(){if(p.active)return v.removeEventListener("focusin",E,!0),v.removeEventListener("mousedown",F,!0),v.removeEventListener("touchstart",F,!0),v.removeEventListener("click",k,!0),v.removeEventListener("keydown",T,!0),f};return(f={activate:function(e){if(p.active)return this;var t=d(e,"onActivate"),n=d(e,"onPostActivate"),a=d(e,"checkCanFocusTrap");a||g(),p.active=!0,p.paused=!1,p.nodeFocusedBeforeActivation=v.activeElement,t&&t();var r=function(){a&&g(),D(),n&&n()};return a?(a(p.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!p.active)return this;clearTimeout(p.delayInitialFocusTimer),p.delayInitialFocusTimer=void 0,G(),p.active=!1,p.paused=!1,o.deactivateTrap(f);var t=d(e,"onDeactivate"),n=d(e,"onPostDeactivate"),a=d(e,"checkCanReturnFocus");t&&t();var r=d(e,"returnFocus","returnFocusOnDeactivate"),c=function(){i((function(){r&&w(O(p.nodeFocusedBeforeActivation)),n&&n()}))};return r&&a?(a(O(p.nodeFocusedBeforeActivation)).then(c,c),this):(c(),this)},pause:function(){return p.paused||!p.active||(p.paused=!0,G()),this},unpause:function(){return p.paused&&p.active?(p.paused=!1,g(),D(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return p.containers=t.map((function(e){return"string"==typeof e?v.querySelector(e):e})),p.active&&g(),this}}).updateContainerElements(r),f};export{l as createFocusTrap};
import{tabbable as e,isFocusable as t,isTabbable as n}from"tabbable";function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o,i=(o=[],{activateTrap:function(e){if(o.length>0){var t=o[o.length-1];t!==e&&t.pause()}var n=o.indexOf(e);-1===n||o.splice(n,1),o.push(e)},deactivateTrap:function(e){var t=o.indexOf(e);-1!==t&&o.splice(t,1),o.length>0&&o[o.length-1].unpause()}}),c=function(e){return setTimeout(e,0)},u=function(e,t){var n=-1;return e.every((function(e,a){return!t(e)||(n=a,!1)})),n},s=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return"function"==typeof e?e.apply(void 0,n):e},l=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},f=function(o,f){var v,b=(null==f?void 0:f.document)||document,p=function(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){r(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}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},f),d={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},h=function(e,t,n){return e&&void 0!==e[t]?e[t]:p[n||t]},m=function(e){return!(!e||!d.containers.some((function(t){return t.contains(e)})))},y=function(e){var t=p[e];if("function"==typeof t){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];t=t.apply(void 0,a)}if(!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 o=t;if("string"==typeof t&&!(o=b.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return o},g=function(){var e=y("initialFocus");if(!1===e)return!1;if(void 0===e)if(m(b.activeElement))e=b.activeElement;else{var t=d.tabbableGroups[0];e=t&&t.firstTabbableNode||y("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},w=function(){if(d.tabbableGroups=d.containers.map((function(t){var n=e(t);if(n.length>0)return{container:t,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),d.tabbableGroups.length<=0&&!y("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},O=function e(t){!1!==t&&t!==b.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!p.preventScroll}),d.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(g()))},F=function(e){var t=y("setReturnFocus",e);return t||!1!==t&&e},E=function(e){var n=l(e);m(n)||(s(p.clickOutsideDeactivates,e)?v.deactivate({returnFocus:p.returnFocusOnDeactivate&&!t(n)}):s(p.allowOutsideClick,e)||e.preventDefault())},T=function(e){var t=l(e),n=m(t);n||t instanceof Document?n&&(d.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),O(d.mostRecentlyFocusedNode||g()))},k=function(e){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e)&&!1!==s(p.escapeDeactivates,e))return e.preventDefault(),void v.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){var a=l(e);w();var r=null;if(d.tabbableGroups.length>0){var o=u(d.tabbableGroups,(function(e){return e.container.contains(a)}));if(o<0)r=e.shiftKey?d.tabbableGroups[d.tabbableGroups.length-1].lastTabbableNode:d.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var i=u(d.tabbableGroups,(function(e){var t=e.firstTabbableNode;return a===t}));if(i<0&&(d.tabbableGroups[o].container===a||t(a)&&!n(a))&&(i=o),i>=0){var c=0===i?d.tabbableGroups.length-1:i-1;r=d.tabbableGroups[c].lastTabbableNode}}else{var s=u(d.tabbableGroups,(function(e){var t=e.lastTabbableNode;return a===t}));if(s<0&&(d.tabbableGroups[o].container===a||t(a)&&!n(a))&&(s=o),s>=0){var f=s===d.tabbableGroups.length-1?0:s+1;r=d.tabbableGroups[f].firstTabbableNode}}}else r=y("fallbackFocus");r&&(e.preventDefault(),O(r))}(e)},D=function(e){if(!s(p.clickOutsideDeactivates,e)){var t=l(e);m(t)||s(p.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},G=function(){if(d.active)return i.activateTrap(v),d.delayInitialFocusTimer=p.delayInitialFocus?c((function(){O(g())})):O(g()),b.addEventListener("focusin",T,!0),b.addEventListener("mousedown",E,{capture:!0,passive:!1}),b.addEventListener("touchstart",E,{capture:!0,passive:!1}),b.addEventListener("click",D,{capture:!0,passive:!1}),b.addEventListener("keydown",k,{capture:!0,passive:!1}),v},N=function(){if(d.active)return b.removeEventListener("focusin",T,!0),b.removeEventListener("mousedown",E,!0),b.removeEventListener("touchstart",E,!0),b.removeEventListener("click",D,!0),b.removeEventListener("keydown",k,!0),v};return(v={activate:function(e){if(d.active)return this;var t=h(e,"onActivate"),n=h(e,"onPostActivate"),a=h(e,"checkCanFocusTrap");a||w(),d.active=!0,d.paused=!1,d.nodeFocusedBeforeActivation=b.activeElement,t&&t();var r=function(){a&&w(),G(),n&&n()};return a?(a(d.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!d.active)return this;clearTimeout(d.delayInitialFocusTimer),d.delayInitialFocusTimer=void 0,N(),d.active=!1,d.paused=!1,i.deactivateTrap(v);var t=h(e,"onDeactivate"),n=h(e,"onPostDeactivate"),a=h(e,"checkCanReturnFocus");t&&t();var r=h(e,"returnFocus","returnFocusOnDeactivate"),o=function(){c((function(){r&&O(F(d.nodeFocusedBeforeActivation)),n&&n()}))};return r&&a?(a(F(d.nodeFocusedBeforeActivation)).then(o,o),this):(o(),this)},pause:function(){return d.paused||!d.active||(d.paused=!0,N()),this},unpause:function(){return d.paused&&d.active?(d.paused=!1,w(),G(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return d.containers=t.map((function(e){return"string"==typeof e?b.querySelector(e):e})),d.active&&w(),this}}).updateContainerElements(o),v};export{f as createFocusTrap};
//# sourceMappingURL=focus-trap.esm.min.js.map
/*!
* focus-trap 6.7.1
* focus-trap 6.7.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -16,10 +16,5 @@ */

var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}

@@ -32,15 +27,8 @@

for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}

@@ -161,2 +149,4 @@

var createFocusTrap = function createFocusTrap(elements, userOptions) {
// SSR: a live trap shouldn't be created in this type of environment so this
// should be safe code to execute if the `document` option isn't specified
var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;

@@ -395,3 +385,3 @@

// make sure the target is actually contained in a group
// NOTE: the target may also be the container itself if it's tabbable
// NOTE: the target may also be the container itself if it's focusable
// with tabIndex='-1' and was given initial focus

@@ -421,4 +411,6 @@ var containerIndex = findIndex(state.tabbableGroups, function (_ref) {

if (startOfGroupIndex < 0 && state.tabbableGroups[containerIndex].container === target) {
// an exception case where the target is the container itself, in which
if (startOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target))) {
// an exception case where the target is either the container itself, or
// a non-tabbable node that was given focus (i.e. tabindex is negative
// and user clicked on it or node was programmatically given focus), in which
// case, we should handle shift+tab as if focus were on the container's

@@ -445,4 +437,6 @@ // first tabbable node, and go to the last tabbable node of the LAST group

if (lastOfGroupIndex < 0 && state.tabbableGroups[containerIndex].container === target) {
// an exception case where the target is the container itself, in which
if (lastOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target))) {
// an exception case where the target is the container itself, or
// a non-tabbable node that was given focus (i.e. tabindex is negative
// and user clicked on it or node was programmatically given focus), in which
// case, we should handle tab as if focus were on the container's

@@ -449,0 +443,0 @@ // last tabbable node, and go to the first tabbable node of the FIRST group

/*!
* focus-trap 6.7.1
* focus-trap 6.7.2
* @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 a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a,r=(a=[],{activateTrap:function(e){if(a.length>0){var t=a[a.length-1];t!==e&&t.pause()}var n=a.indexOf(e);-1===n||a.splice(n,1),a.push(e)},deactivateTrap:function(e){var t=a.indexOf(e);-1!==t&&a.splice(t,1),a.length>0&&a[a.length-1].unpause()}}),o=function(e){return setTimeout(e,0)},i=function(e,t){var n=-1;return e.every((function(e,a){return!t(e)||(n=a,!1)})),n},c=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return"function"==typeof e?e.apply(void 0,n):e},u=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target};exports.createFocusTrap=function(a,s){var l,f=(null==s?void 0:s.document)||document,b=function(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?t(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},s),v={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},p=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},d=function(e){return!(!e||!v.containers.some((function(t){return t.contains(e)})))},h=function(e){var t=b[e];if("function"==typeof t){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];t=t.apply(void 0,a)}if(!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 o=t;if("string"==typeof t&&!(o=f.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return o},y=function(){var e=h("initialFocus");if(!1===e)return!1;if(void 0===e)if(d(f.activeElement))e=f.activeElement;else{var t=v.tabbableGroups[0];e=t&&t.firstTabbableNode||h("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},m=function(){if(v.tabbableGroups=v.containers.map((function(t){var n=e.tabbable(t);if(n.length>0)return{container:t,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),v.tabbableGroups.length<=0&&!h("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},g=function e(t){!1!==t&&t!==f.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!b.preventScroll}),v.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(y()))},w=function(e){var t=h("setReturnFocus",e);return t||!1!==t&&e},F=function(t){var n=u(t);d(n)||(c(b.clickOutsideDeactivates,t)?l.deactivate({returnFocus:b.returnFocusOnDeactivate&&!e.isFocusable(n)}):c(b.allowOutsideClick,t)||t.preventDefault())},O=function(e){var t=u(e),n=d(t);n||t instanceof Document?n&&(v.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),g(v.mostRecentlyFocusedNode||y()))},E=function(e){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e)&&!1!==c(b.escapeDeactivates,e))return e.preventDefault(),void l.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){var t=u(e);m();var n=null;if(v.tabbableGroups.length>0){var a=i(v.tabbableGroups,(function(e){return e.container.contains(t)}));if(a<0)n=e.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var r=i(v.tabbableGroups,(function(e){var n=e.firstTabbableNode;return t===n}));if(r<0&&v.tabbableGroups[a].container===t&&(r=a),r>=0){var o=0===r?v.tabbableGroups.length-1:r-1;n=v.tabbableGroups[o].lastTabbableNode}}else{var c=i(v.tabbableGroups,(function(e){var n=e.lastTabbableNode;return t===n}));if(c<0&&v.tabbableGroups[a].container===t&&(c=a),c>=0){var s=c===v.tabbableGroups.length-1?0:c+1;n=v.tabbableGroups[s].firstTabbableNode}}}else n=h("fallbackFocus");n&&(e.preventDefault(),g(n))}(e)},T=function(e){if(!c(b.clickOutsideDeactivates,e)){var t=u(e);d(t)||c(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},k=function(){if(v.active)return r.activateTrap(l),v.delayInitialFocusTimer=b.delayInitialFocus?o((function(){g(y())})):g(y()),f.addEventListener("focusin",O,!0),f.addEventListener("mousedown",F,{capture:!0,passive:!1}),f.addEventListener("touchstart",F,{capture:!0,passive:!1}),f.addEventListener("click",T,{capture:!0,passive:!1}),f.addEventListener("keydown",E,{capture:!0,passive:!1}),l},D=function(){if(v.active)return f.removeEventListener("focusin",O,!0),f.removeEventListener("mousedown",F,!0),f.removeEventListener("touchstart",F,!0),f.removeEventListener("click",T,!0),f.removeEventListener("keydown",E,!0),l};return(l={activate:function(e){if(v.active)return this;var t=p(e,"onActivate"),n=p(e,"onPostActivate"),a=p(e,"checkCanFocusTrap");a||m(),v.active=!0,v.paused=!1,v.nodeFocusedBeforeActivation=f.activeElement,t&&t();var r=function(){a&&m(),k(),n&&n()};return a?(a(v.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!v.active)return this;clearTimeout(v.delayInitialFocusTimer),v.delayInitialFocusTimer=void 0,D(),v.active=!1,v.paused=!1,r.deactivateTrap(l);var t=p(e,"onDeactivate"),n=p(e,"onPostDeactivate"),a=p(e,"checkCanReturnFocus");t&&t();var i=p(e,"returnFocus","returnFocusOnDeactivate"),c=function(){o((function(){i&&g(w(v.nodeFocusedBeforeActivation)),n&&n()}))};return i&&a?(a(w(v.nodeFocusedBeforeActivation)).then(c,c),this):(c(),this)},pause:function(){return v.paused||!v.active||(v.paused=!0,D()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,m(),k(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return v.containers=t.map((function(e){return"string"==typeof e?f.querySelector(e):e})),v.active&&m(),this}}).updateContainerElements(a),l};
"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 a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a,r=(a=[],{activateTrap:function(e){if(a.length>0){var t=a[a.length-1];t!==e&&t.pause()}var n=a.indexOf(e);-1===n||a.splice(n,1),a.push(e)},deactivateTrap:function(e){var t=a.indexOf(e);-1!==t&&a.splice(t,1),a.length>0&&a[a.length-1].unpause()}}),o=function(e){return setTimeout(e,0)},i=function(e,t){var n=-1;return e.every((function(e,a){return!t(e)||(n=a,!1)})),n},c=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return"function"==typeof e?e.apply(void 0,n):e},u=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target};exports.createFocusTrap=function(a,s){var l,f=(null==s?void 0:s.document)||document,b=function(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?t(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},s),v={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},p=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},d=function(e){return!(!e||!v.containers.some((function(t){return t.contains(e)})))},h=function(e){var t=b[e];if("function"==typeof t){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];t=t.apply(void 0,a)}if(!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 o=t;if("string"==typeof t&&!(o=f.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return o},y=function(){var e=h("initialFocus");if(!1===e)return!1;if(void 0===e)if(d(f.activeElement))e=f.activeElement;else{var t=v.tabbableGroups[0];e=t&&t.firstTabbableNode||h("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},m=function(){if(v.tabbableGroups=v.containers.map((function(t){var n=e.tabbable(t);if(n.length>0)return{container:t,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),v.tabbableGroups.length<=0&&!h("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},F=function e(t){!1!==t&&t!==f.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!b.preventScroll}),v.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(y()))},g=function(e){var t=h("setReturnFocus",e);return t||!1!==t&&e},w=function(t){var n=u(t);d(n)||(c(b.clickOutsideDeactivates,t)?l.deactivate({returnFocus:b.returnFocusOnDeactivate&&!e.isFocusable(n)}):c(b.allowOutsideClick,t)||t.preventDefault())},O=function(e){var t=u(e),n=d(t);n||t instanceof Document?n&&(v.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),F(v.mostRecentlyFocusedNode||y()))},E=function(t){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(t)&&!1!==c(b.escapeDeactivates,t))return t.preventDefault(),void l.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(t)&&function(t){var n=u(t);m();var a=null;if(v.tabbableGroups.length>0){var r=i(v.tabbableGroups,(function(e){return e.container.contains(n)}));if(r<0)a=t.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(t.shiftKey){var o=i(v.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(o<0&&(v.tabbableGroups[r].container===n||e.isFocusable(n)&&!e.isTabbable(n))&&(o=r),o>=0){var c=0===o?v.tabbableGroups.length-1:o-1;a=v.tabbableGroups[c].lastTabbableNode}}else{var s=i(v.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(s<0&&(v.tabbableGroups[r].container===n||e.isFocusable(n)&&!e.isTabbable(n))&&(s=r),s>=0){var l=s===v.tabbableGroups.length-1?0:s+1;a=v.tabbableGroups[l].firstTabbableNode}}}else a=h("fallbackFocus");a&&(t.preventDefault(),F(a))}(t)},T=function(e){if(!c(b.clickOutsideDeactivates,e)){var t=u(e);d(t)||c(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},k=function(){if(v.active)return r.activateTrap(l),v.delayInitialFocusTimer=b.delayInitialFocus?o((function(){F(y())})):F(y()),f.addEventListener("focusin",O,!0),f.addEventListener("mousedown",w,{capture:!0,passive:!1}),f.addEventListener("touchstart",w,{capture:!0,passive:!1}),f.addEventListener("click",T,{capture:!0,passive:!1}),f.addEventListener("keydown",E,{capture:!0,passive:!1}),l},D=function(){if(v.active)return f.removeEventListener("focusin",O,!0),f.removeEventListener("mousedown",w,!0),f.removeEventListener("touchstart",w,!0),f.removeEventListener("click",T,!0),f.removeEventListener("keydown",E,!0),l};return(l={activate:function(e){if(v.active)return this;var t=p(e,"onActivate"),n=p(e,"onPostActivate"),a=p(e,"checkCanFocusTrap");a||m(),v.active=!0,v.paused=!1,v.nodeFocusedBeforeActivation=f.activeElement,t&&t();var r=function(){a&&m(),k(),n&&n()};return a?(a(v.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!v.active)return this;clearTimeout(v.delayInitialFocusTimer),v.delayInitialFocusTimer=void 0,D(),v.active=!1,v.paused=!1,r.deactivateTrap(l);var t=p(e,"onDeactivate"),n=p(e,"onPostDeactivate"),a=p(e,"checkCanReturnFocus");t&&t();var i=p(e,"returnFocus","returnFocusOnDeactivate"),c=function(){o((function(){i&&F(g(v.nodeFocusedBeforeActivation)),n&&n()}))};return i&&a?(a(g(v.nodeFocusedBeforeActivation)).then(c,c),this):(c(),this)},pause:function(){return v.paused||!v.active||(v.paused=!0,D()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,m(),k(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return v.containers=t.map((function(e){return"string"==typeof e?f.querySelector(e):e})),v.active&&m(),this}}).updateContainerElements(a),l};
//# sourceMappingURL=focus-trap.min.js.map
/*!
* focus-trap 6.7.1
* focus-trap 6.7.2
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -21,10 +21,5 @@ */

var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}

@@ -37,15 +32,8 @@

for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}

@@ -166,2 +154,4 @@

var createFocusTrap = function createFocusTrap(elements, userOptions) {
// SSR: a live trap shouldn't be created in this type of environment so this
// should be safe code to execute if the `document` option isn't specified
var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;

@@ -400,3 +390,3 @@

// make sure the target is actually contained in a group
// NOTE: the target may also be the container itself if it's tabbable
// NOTE: the target may also be the container itself if it's focusable
// with tabIndex='-1' and was given initial focus

@@ -426,4 +416,6 @@ var containerIndex = findIndex(state.tabbableGroups, function (_ref) {

if (startOfGroupIndex < 0 && state.tabbableGroups[containerIndex].container === target) {
// an exception case where the target is the container itself, in which
if (startOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target))) {
// an exception case where the target is either the container itself, or
// a non-tabbable node that was given focus (i.e. tabindex is negative
// and user clicked on it or node was programmatically given focus), in which
// case, we should handle shift+tab as if focus were on the container's

@@ -450,4 +442,6 @@ // first tabbable node, and go to the last tabbable node of the LAST group

if (lastOfGroupIndex < 0 && state.tabbableGroups[containerIndex].container === target) {
// an exception case where the target is the container itself, in which
if (lastOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target))) {
// an exception case where the target is the container itself, or
// a non-tabbable node that was given focus (i.e. tabindex is negative
// and user clicked on it or node was programmatically given focus), in which
// case, we should handle tab as if focus were on the container's

@@ -454,0 +448,0 @@ // last tabbable node, and go to the first tabbable node of the FIRST group

/*!
* focus-trap 6.7.1
* focus-trap 6.7.2
* @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,a=e.focusTrap={};t(a,e.tabbable),a.noConflict=function(){return e.focusTrap=n,a}}())}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r,o=(r=[],{activateTrap:function(e){if(r.length>0){var t=r[r.length-1];t!==e&&t.pause()}var n=r.indexOf(e);-1===n||r.splice(n,1),r.push(e)},deactivateTrap:function(e){var t=r.indexOf(e);-1!==t&&r.splice(t,1),r.length>0&&r[r.length-1].unpause()}}),i=function(e){return setTimeout(e,0)},c=function(e,t){var n=-1;return e.every((function(e,a){return!t(e)||(n=a,!1)})),n},u=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return"function"==typeof e?e.apply(void 0,n):e},s=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target};e.createFocusTrap=function(e,r){var l,f=(null==r?void 0:r.document)||document,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},r),v={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},d=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},p=function(e){return!(!e||!v.containers.some((function(t){return t.contains(e)})))},h=function(e){var t=b[e];if("function"==typeof t){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];t=t.apply(void 0,a)}if(!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 o=t;if("string"==typeof t&&!(o=f.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return o},y=function(){var e=h("initialFocus");if(!1===e)return!1;if(void 0===e)if(p(f.activeElement))e=f.activeElement;else{var t=v.tabbableGroups[0];e=t&&t.firstTabbableNode||h("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},m=function(){if(v.tabbableGroups=v.containers.map((function(e){var n=t.tabbable(e);if(n.length>0)return{container:e,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),v.tabbableGroups.length<=0&&!h("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},g=function e(t){!1!==t&&t!==f.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!b.preventScroll}),v.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(y()))},w=function(e){var t=h("setReturnFocus",e);return t||!1!==t&&e},F=function(e){var n=s(e);p(n)||(u(b.clickOutsideDeactivates,e)?l.deactivate({returnFocus:b.returnFocusOnDeactivate&&!t.isFocusable(n)}):u(b.allowOutsideClick,e)||e.preventDefault())},O=function(e){var t=s(e),n=p(t);n||t instanceof Document?n&&(v.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),g(v.mostRecentlyFocusedNode||y()))},T=function(e){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e)&&!1!==u(b.escapeDeactivates,e))return e.preventDefault(),void l.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){var t=s(e);m();var n=null;if(v.tabbableGroups.length>0){var a=c(v.tabbableGroups,(function(e){return e.container.contains(t)}));if(a<0)n=e.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var r=c(v.tabbableGroups,(function(e){var n=e.firstTabbableNode;return t===n}));if(r<0&&v.tabbableGroups[a].container===t&&(r=a),r>=0){var o=0===r?v.tabbableGroups.length-1:r-1;n=v.tabbableGroups[o].lastTabbableNode}}else{var i=c(v.tabbableGroups,(function(e){var n=e.lastTabbableNode;return t===n}));if(i<0&&v.tabbableGroups[a].container===t&&(i=a),i>=0){var u=i===v.tabbableGroups.length-1?0:i+1;n=v.tabbableGroups[u].firstTabbableNode}}}else n=h("fallbackFocus");n&&(e.preventDefault(),g(n))}(e)},E=function(e){if(!u(b.clickOutsideDeactivates,e)){var t=s(e);p(t)||u(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},k=function(){if(v.active)return o.activateTrap(l),v.delayInitialFocusTimer=b.delayInitialFocus?i((function(){g(y())})):g(y()),f.addEventListener("focusin",O,!0),f.addEventListener("mousedown",F,{capture:!0,passive:!1}),f.addEventListener("touchstart",F,{capture:!0,passive:!1}),f.addEventListener("click",E,{capture:!0,passive:!1}),f.addEventListener("keydown",T,{capture:!0,passive:!1}),l},D=function(){if(v.active)return f.removeEventListener("focusin",O,!0),f.removeEventListener("mousedown",F,!0),f.removeEventListener("touchstart",F,!0),f.removeEventListener("click",E,!0),f.removeEventListener("keydown",T,!0),l};return(l={activate:function(e){if(v.active)return this;var t=d(e,"onActivate"),n=d(e,"onPostActivate"),a=d(e,"checkCanFocusTrap");a||m(),v.active=!0,v.paused=!1,v.nodeFocusedBeforeActivation=f.activeElement,t&&t();var r=function(){a&&m(),k(),n&&n()};return a?(a(v.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!v.active)return this;clearTimeout(v.delayInitialFocusTimer),v.delayInitialFocusTimer=void 0,D(),v.active=!1,v.paused=!1,o.deactivateTrap(l);var t=d(e,"onDeactivate"),n=d(e,"onPostDeactivate"),a=d(e,"checkCanReturnFocus");t&&t();var r=d(e,"returnFocus","returnFocusOnDeactivate"),c=function(){i((function(){r&&g(w(v.nodeFocusedBeforeActivation)),n&&n()}))};return r&&a?(a(w(v.nodeFocusedBeforeActivation)).then(c,c),this):(c(),this)},pause:function(){return v.paused||!v.active||(v.paused=!0,D()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,m(),k(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return v.containers=t.map((function(e){return"string"==typeof e?f.querySelector(e):e})),v.active&&m(),this}}).updateContainerElements(e),l},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,a=e.focusTrap={};t(a,e.tabbable),a.noConflict=function(){return e.focusTrap=n,a}}())}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r,o=(r=[],{activateTrap:function(e){if(r.length>0){var t=r[r.length-1];t!==e&&t.pause()}var n=r.indexOf(e);-1===n||r.splice(n,1),r.push(e)},deactivateTrap:function(e){var t=r.indexOf(e);-1!==t&&r.splice(t,1),r.length>0&&r[r.length-1].unpause()}}),i=function(e){return setTimeout(e,0)},c=function(e,t){var n=-1;return e.every((function(e,a){return!t(e)||(n=a,!1)})),n},u=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return"function"==typeof e?e.apply(void 0,n):e},s=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target};e.createFocusTrap=function(e,r){var l,f=(null==r?void 0:r.document)||document,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},r),v={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},d=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},p=function(e){return!(!e||!v.containers.some((function(t){return t.contains(e)})))},h=function(e){var t=b[e];if("function"==typeof t){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];t=t.apply(void 0,a)}if(!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 o=t;if("string"==typeof t&&!(o=f.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return o},y=function(){var e=h("initialFocus");if(!1===e)return!1;if(void 0===e)if(p(f.activeElement))e=f.activeElement;else{var t=v.tabbableGroups[0];e=t&&t.firstTabbableNode||h("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},m=function(){if(v.tabbableGroups=v.containers.map((function(e){var n=t.tabbable(e);if(n.length>0)return{container:e,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),v.tabbableGroups.length<=0&&!h("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},g=function e(t){!1!==t&&t!==f.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!b.preventScroll}),v.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(y()))},F=function(e){var t=h("setReturnFocus",e);return t||!1!==t&&e},w=function(e){var n=s(e);p(n)||(u(b.clickOutsideDeactivates,e)?l.deactivate({returnFocus:b.returnFocusOnDeactivate&&!t.isFocusable(n)}):u(b.allowOutsideClick,e)||e.preventDefault())},T=function(e){var t=s(e),n=p(t);n||t instanceof Document?n&&(v.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),g(v.mostRecentlyFocusedNode||y()))},O=function(e){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e)&&!1!==u(b.escapeDeactivates,e))return e.preventDefault(),void l.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){var n=s(e);m();var a=null;if(v.tabbableGroups.length>0){var r=c(v.tabbableGroups,(function(e){return e.container.contains(n)}));if(r<0)a=e.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var o=c(v.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(o<0&&(v.tabbableGroups[r].container===n||t.isFocusable(n)&&!t.isTabbable(n))&&(o=r),o>=0){var i=0===o?v.tabbableGroups.length-1:o-1;a=v.tabbableGroups[i].lastTabbableNode}}else{var u=c(v.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(u<0&&(v.tabbableGroups[r].container===n||t.isFocusable(n)&&!t.isTabbable(n))&&(u=r),u>=0){var l=u===v.tabbableGroups.length-1?0:u+1;a=v.tabbableGroups[l].firstTabbableNode}}}else a=h("fallbackFocus");a&&(e.preventDefault(),g(a))}(e)},E=function(e){if(!u(b.clickOutsideDeactivates,e)){var t=s(e);p(t)||u(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},k=function(){if(v.active)return o.activateTrap(l),v.delayInitialFocusTimer=b.delayInitialFocus?i((function(){g(y())})):g(y()),f.addEventListener("focusin",T,!0),f.addEventListener("mousedown",w,{capture:!0,passive:!1}),f.addEventListener("touchstart",w,{capture:!0,passive:!1}),f.addEventListener("click",E,{capture:!0,passive:!1}),f.addEventListener("keydown",O,{capture:!0,passive:!1}),l},D=function(){if(v.active)return f.removeEventListener("focusin",T,!0),f.removeEventListener("mousedown",w,!0),f.removeEventListener("touchstart",w,!0),f.removeEventListener("click",E,!0),f.removeEventListener("keydown",O,!0),l};return(l={activate:function(e){if(v.active)return this;var t=d(e,"onActivate"),n=d(e,"onPostActivate"),a=d(e,"checkCanFocusTrap");a||m(),v.active=!0,v.paused=!1,v.nodeFocusedBeforeActivation=f.activeElement,t&&t();var r=function(){a&&m(),k(),n&&n()};return a?(a(v.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!v.active)return this;clearTimeout(v.delayInitialFocusTimer),v.delayInitialFocusTimer=void 0,D(),v.active=!1,v.paused=!1,o.deactivateTrap(l);var t=d(e,"onDeactivate"),n=d(e,"onPostDeactivate"),a=d(e,"checkCanReturnFocus");t&&t();var r=d(e,"returnFocus","returnFocusOnDeactivate"),c=function(){i((function(){r&&g(F(v.nodeFocusedBeforeActivation)),n&&n()}))};return r&&a?(a(F(v.nodeFocusedBeforeActivation)).then(c,c),this):(c(),this)},pause:function(){return v.paused||!v.active||(v.paused=!0,D()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,m(),k(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return v.containers=t.map((function(e){return"string"==typeof e?f.querySelector(e):e})),v.active&&m(),this}}).updateContainerElements(e),l},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=focus-trap.umd.min.js.map

@@ -1,2 +0,2 @@

import { tabbable, isFocusable } from 'tabbable';
import { tabbable, isFocusable, isTabbable } from 'tabbable';

@@ -99,2 +99,4 @@ const activeFocusTraps = (function () {

const createFocusTrap = function (elements, userOptions) {
// SSR: a live trap shouldn't be created in this type of environment so this
// should be safe code to execute if the `document` option isn't specified
const doc = userOptions?.document || document;

@@ -349,3 +351,3 @@

// make sure the target is actually contained in a group
// NOTE: the target may also be the container itself if it's tabbable
// NOTE: the target may also be the container itself if it's focusable
// with tabIndex='-1' and was given initial focus

@@ -379,5 +381,8 @@ const containerIndex = findIndex(state.tabbableGroups, ({ container }) =>

startOfGroupIndex < 0 &&
state.tabbableGroups[containerIndex].container === target
(state.tabbableGroups[containerIndex].container === target ||
(isFocusable(target) && !isTabbable(target)))
) {
// an exception case where the target is the container itself, in which
// an exception case where the target is either the container itself, or
// a non-tabbable node that was given focus (i.e. tabindex is negative
// and user clicked on it or node was programmatically given focus), in which
// case, we should handle shift+tab as if focus were on the container's

@@ -411,5 +416,8 @@ // first tabbable node, and go to the last tabbable node of the LAST group

lastOfGroupIndex < 0 &&
state.tabbableGroups[containerIndex].container === target
(state.tabbableGroups[containerIndex].container === target ||
(isFocusable(target) && !isTabbable(target)))
) {
// an exception case where the target is the container itself, in which
// an exception case where the target is the container itself, or
// a non-tabbable node that was given focus (i.e. tabindex is negative
// and user clicked on it or node was programmatically given focus), in which
// case, we should handle tab as if focus were on the container's

@@ -416,0 +424,0 @@ // last tabbable node, and go to the first tabbable node of the FIRST group

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

@@ -68,23 +68,23 @@ "main": "dist/focus-trap.js",

"devDependencies": {
"@babel/cli": "^7.15.7",
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@changesets/cli": "^2.17.0",
"@babel/cli": "^7.16.8",
"@babel/core": "^7.16.7",
"@babel/eslint-parser": "^7.16.5",
"@babel/preset-env": "^7.16.8",
"@changesets/cli": "^2.19.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@testing-library/cypress": "^8.0.1",
"@types/jquery": "^3.5.6",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"@testing-library/cypress": "^8.0.2",
"@types/jquery": "^3.5.13",
"all-contributors-cli": "^6.20.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"babel-loader": "^8.2.3",
"cross-env": "^7.0.3",
"cypress": "^8.4.1",
"cypress": "^9.2.1",
"cypress-plugin-tab": "^1.0.5",
"eslint": "^7.32.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-cypress": "^2.12.1",
"onchange": "^7.1.0",
"prettier": "^2.4.1",
"rollup": "^2.57.0",
"prettier": "^2.5.1",
"rollup": "^2.63.0",
"rollup-plugin-inject-process-env": "^1.3.1",

@@ -96,4 +96,4 @@ "rollup-plugin-livereload": "^2.0.5",

"start-server-and-test": "^1.14.0",
"typescript": "^4.4.3"
"typescript": "^4.5.4"
}
}

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