focus-trap
Advanced tools
Comparing version 6.8.0-beta.0 to 6.8.0-beta.1
# Changelog | ||
## 6.8.0-beta.1 | ||
- Rebased onto `v6.7.3`. | ||
## 6.8.0-beta.0 | ||
@@ -7,2 +11,8 @@ | ||
## 6.7.3 | ||
### Patch Changes | ||
- ab20d3d: Fix issue with focusing negative tabindex node and then tabbing away when this node is _not_ the last node in the trap's container ((#611)[https://github.com/focus-trap/focus-trap/issues/611]) | ||
## 6.7.2 | ||
@@ -9,0 +19,0 @@ |
/*! | ||
* focus-trap 6.8.0-beta.0 | ||
* focus-trap 6.8.0-beta.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
*/ | ||
import { tabbable, isFocusable, isTabbable } from 'tabbable'; | ||
import { tabbable, focusable, isTabbable, isFocusable } from 'tabbable'; | ||
@@ -162,3 +162,8 @@ function ownKeys(object, enumerableOnly) { | ||
// result in an error being thrown) | ||
// @type {Array<{ container: HTMLElement, firstTabbableNode: HTMLElement|null, lastTabbableNode: HTMLElement|null }>} | ||
// @type {Array<{ | ||
// container: HTMLElement, | ||
// firstTabbableNode: HTMLElement|null, | ||
// lastTabbableNode: HTMLElement|null, | ||
// nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined | ||
// }>} | ||
tabbableGroups: [], | ||
@@ -273,4 +278,7 @@ nodeFocusedBeforeActivation: null, | ||
getShadowRoot: (_config$tabbableOptio = config.tabbableOptions) === null || _config$tabbableOptio === void 0 ? void 0 : _config$tabbableOptio.getShadowRoot | ||
}); | ||
}); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes | ||
// are a superset of tabbable nodes | ||
var focusableNodes = focusable(container); | ||
if (tabbableNodes.length > 0) { | ||
@@ -280,3 +288,38 @@ return { | ||
firstTabbableNode: tabbableNodes[0], | ||
lastTabbableNode: tabbableNodes[tabbableNodes.length - 1] | ||
lastTabbableNode: tabbableNodes[tabbableNodes.length - 1], | ||
/** | ||
* Finds the __tabbable__ node that follows the given node in the specified direction, | ||
* in this container, if any. | ||
* @param {HTMLElement} node | ||
* @param {boolean} [forward] True if going in forward tab order; false if going | ||
* in reverse. | ||
* @returns {HTMLElement|undefined} The next tabbable node, if any. | ||
*/ | ||
nextTabbableNode: function nextTabbableNode(node) { | ||
var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
// NOTE: If tabindex is positive (in order to manipulate the tab order separate | ||
// from the DOM order), this __will not work__ because the list of focusableNodes, | ||
// while it contains tabbable nodes, does not sort its nodes in any order other | ||
// than DOM order, because it can't: Where would you place focusable (but not | ||
// tabbable) nodes in that order? They have no order, because they aren't tabbale... | ||
// Support for positive tabindex is already broken and hard to manage (possibly | ||
// not supportable, TBD), so this isn't going to make things worse than they | ||
// already are, and at least makes things better for the majority of cases where | ||
// tabindex is either 0/unset or negative. | ||
// FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375 | ||
var nodeIdx = focusableNodes.findIndex(function (n) { | ||
return n === node; | ||
}); | ||
if (forward) { | ||
return focusableNodes.slice(nodeIdx + 1).find(function (n) { | ||
return isTabbable(n); | ||
}); | ||
} | ||
return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) { | ||
return isTabbable(n); | ||
}); | ||
} | ||
}; | ||
@@ -400,2 +443,3 @@ } | ||
}); | ||
var containerGroup = containerIndex >= 0 ? state.tabbableGroups[containerIndex] : undefined; | ||
@@ -420,6 +464,7 @@ if (containerIndex < 0) { | ||
if (startOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || isFocusable(target) && !isTabbable(target))) { | ||
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target) && !isTabbable(target) && !containerGroup.nextTabbableNode(target, false))) { | ||
// 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 | ||
// and user clicked on it or node was programmatically given focus) | ||
// and is not followed by any other tabbable node, in which | ||
// case, we should handle shift+tab as if focus were on the container's | ||
@@ -446,6 +491,7 @@ // first tabbable node, and go to the last tabbable node of the LAST group | ||
if (lastOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || isFocusable(target) && !isTabbable(target))) { | ||
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target) && !isTabbable(target) && !containerGroup.nextTabbableNode(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 | ||
// and user clicked on it or node was programmatically given focus) | ||
// and is not followed by any other tabbable node, in which | ||
// case, we should handle tab as if focus were on the container's | ||
@@ -452,0 +498,0 @@ // last tabbable node, and go to the first tabbable node of the FIRST group |
/*! | ||
* focus-trap 6.8.0-beta.0 | ||
* focus-trap 6.8.0-beta.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
*/ | ||
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,d=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),p={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]:d[n||t]},m=function(e){return!(!e||!p.containers.some((function(t){return t.contains(e)})))},y=function(e){var t=d[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=p.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(p.tabbableGroups=p.containers.map((function(t){var n,a=e(t,{getShadowRoot:null===(n=d.tabbableOptions)||void 0===n?void 0:n.getShadowRoot});if(a.length>0)return{container:t,firstTabbableNode:a[0],lastTabbableNode:a[a.length-1]}})).filter((function(e){return!!e})),p.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:!!d.preventScroll}),p.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(d.clickOutsideDeactivates,e)?v.deactivate({returnFocus:d.returnFocusOnDeactivate&&!t(n)}):s(d.allowOutsideClick,e)||e.preventDefault())},T=function(e){var t=l(e),n=m(t);n||t instanceof Document?n&&(p.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),O(p.mostRecentlyFocusedNode||g()))},k=function(e){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e)&&!1!==s(d.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(p.tabbableGroups.length>0){var o=u(p.tabbableGroups,(function(e){return e.container.contains(a)}));if(o<0)r=e.shiftKey?p.tabbableGroups[p.tabbableGroups.length-1].lastTabbableNode:p.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var i=u(p.tabbableGroups,(function(e){var t=e.firstTabbableNode;return a===t}));if(i<0&&(p.tabbableGroups[o].container===a||t(a)&&!n(a))&&(i=o),i>=0){var c=0===i?p.tabbableGroups.length-1:i-1;r=p.tabbableGroups[c].lastTabbableNode}}else{var s=u(p.tabbableGroups,(function(e){var t=e.lastTabbableNode;return a===t}));if(s<0&&(p.tabbableGroups[o].container===a||t(a)&&!n(a))&&(s=o),s>=0){var f=s===p.tabbableGroups.length-1?0:s+1;r=p.tabbableGroups[f].firstTabbableNode}}}else r=y("fallbackFocus");r&&(e.preventDefault(),O(r))}(e)},D=function(e){if(!s(d.clickOutsideDeactivates,e)){var t=l(e);m(t)||s(d.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},G=function(){if(p.active)return i.activateTrap(v),p.delayInitialFocusTimer=d.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(p.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(p.active)return this;var t=h(e,"onActivate"),n=h(e,"onPostActivate"),a=h(e,"checkCanFocusTrap");a||w(),p.active=!0,p.paused=!1,p.nodeFocusedBeforeActivation=b.activeElement,t&&t();var r=function(){a&&w(),G(),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,N(),p.active=!1,p.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(p.nodeFocusedBeforeActivation)),n&&n()}))};return r&&a?(a(F(p.nodeFocusedBeforeActivation)).then(o,o),this):(o(),this)},pause:function(){return p.paused||!p.active||(p.paused=!0,N()),this},unpause:function(){return p.paused&&p.active?(p.paused=!1,w(),G(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return p.containers=t.map((function(e){return"string"==typeof e?b.querySelector(e):e})),p.active&&w(),this}}).updateContainerElements(o),v};export{f as createFocusTrap}; | ||
import{tabbable as e,focusable as t,isTabbable as n,isFocusable as a}from"tabbable";function r(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 o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i,c=(i=[],{activateTrap:function(e){if(i.length>0){var t=i[i.length-1];t!==e&&t.pause()}var n=i.indexOf(e);-1===n||i.splice(n,1),i.push(e)},deactivateTrap:function(e){var t=i.indexOf(e);-1!==t&&i.splice(t,1),i.length>0&&i[i.length-1].unpause()}}),u=function(e){return setTimeout(e,0)},s=function(e,t){var n=-1;return e.every((function(e,a){return!t(e)||(n=a,!1)})),n},l=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},f=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},b=function(i,b){var v,d=(null==b?void 0:b.document)||document,p=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},b),h={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},m=function(e,t,n){return e&&void 0!==e[t]?e[t]:p[n||t]},y=function(e){return!(!e||!h.containers.some((function(t){return t.contains(e)})))},g=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=d.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return o},w=function(){var e=g("initialFocus");if(!1===e)return!1;if(void 0===e)if(y(d.activeElement))e=d.activeElement;else{var t=h.tabbableGroups[0];e=t&&t.firstTabbableNode||g("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},O=function(){if(h.tabbableGroups=h.containers.map((function(a){var r,o=e(a,{getShadowRoot:null===(r=p.tabbableOptions)||void 0===r?void 0:r.getShadowRoot}),i=t(a);if(o.length>0)return{container:a,firstTabbableNode:o[0],lastTabbableNode:o[o.length-1],nextTabbableNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=i.findIndex((function(t){return t===e}));return t?i.slice(a+1).find((function(e){return n(e)})):i.slice(0,a).reverse().find((function(e){return n(e)}))}}})).filter((function(e){return!!e})),h.tabbableGroups.length<=0&&!g("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!==d.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!p.preventScroll}),h.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(w()))},E=function(e){var t=g("setReturnFocus",e);return t||!1!==t&&e},T=function(e){var t=f(e);y(t)||(l(p.clickOutsideDeactivates,e)?v.deactivate({returnFocus:p.returnFocusOnDeactivate&&!a(t)}):l(p.allowOutsideClick,e)||e.preventDefault())},k=function(e){var t=f(e),n=y(t);n||t instanceof Document?n&&(h.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),F(h.mostRecentlyFocusedNode||w()))},D=function(e){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e)&&!1!==l(p.escapeDeactivates,e))return e.preventDefault(),void v.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){var t=f(e);O();var r=null;if(h.tabbableGroups.length>0){var o=s(h.tabbableGroups,(function(e){return e.container.contains(t)})),i=o>=0?h.tabbableGroups[o]:void 0;if(o<0)r=e.shiftKey?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var c=s(h.tabbableGroups,(function(e){var n=e.firstTabbableNode;return t===n}));if(c<0&&(i.container===t||a(t)&&!n(t)&&!i.nextTabbableNode(t,!1))&&(c=o),c>=0){var u=0===c?h.tabbableGroups.length-1:c-1;r=h.tabbableGroups[u].lastTabbableNode}}else{var l=s(h.tabbableGroups,(function(e){var n=e.lastTabbableNode;return t===n}));if(l<0&&(i.container===t||a(t)&&!n(t)&&!i.nextTabbableNode(t))&&(l=o),l>=0){var b=l===h.tabbableGroups.length-1?0:l+1;r=h.tabbableGroups[b].firstTabbableNode}}}else r=g("fallbackFocus");r&&(e.preventDefault(),F(r))}(e)},N=function(e){if(!l(p.clickOutsideDeactivates,e)){var t=f(e);y(t)||l(p.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},G=function(){if(h.active)return c.activateTrap(v),h.delayInitialFocusTimer=p.delayInitialFocus?u((function(){F(w())})):F(w()),d.addEventListener("focusin",k,!0),d.addEventListener("mousedown",T,{capture:!0,passive:!1}),d.addEventListener("touchstart",T,{capture:!0,passive:!1}),d.addEventListener("click",N,{capture:!0,passive:!1}),d.addEventListener("keydown",D,{capture:!0,passive:!1}),v},P=function(){if(h.active)return d.removeEventListener("focusin",k,!0),d.removeEventListener("mousedown",T,!0),d.removeEventListener("touchstart",T,!0),d.removeEventListener("click",N,!0),d.removeEventListener("keydown",D,!0),v};return(v={activate:function(e){if(h.active)return this;var t=m(e,"onActivate"),n=m(e,"onPostActivate"),a=m(e,"checkCanFocusTrap");a||O(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=d.activeElement,t&&t();var r=function(){a&&O(),G(),n&&n()};return a?(a(h.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!h.active)return this;clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,P(),h.active=!1,h.paused=!1,c.deactivateTrap(v);var t=m(e,"onDeactivate"),n=m(e,"onPostDeactivate"),a=m(e,"checkCanReturnFocus");t&&t();var r=m(e,"returnFocus","returnFocusOnDeactivate"),o=function(){u((function(){r&&F(E(h.nodeFocusedBeforeActivation)),n&&n()}))};return r&&a?(a(E(h.nodeFocusedBeforeActivation)).then(o,o),this):(o(),this)},pause:function(){return h.paused||!h.active||(h.paused=!0,P()),this},unpause:function(){return h.paused&&h.active?(h.paused=!1,O(),G(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?d.querySelector(e):e})),h.active&&O(),this}}).updateContainerElements(i),v};export{b as createFocusTrap}; | ||
//# sourceMappingURL=focus-trap.esm.min.js.map |
/*! | ||
* focus-trap 6.8.0-beta.0 | ||
* focus-trap 6.8.0-beta.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
@@ -166,3 +166,8 @@ */ | ||
// result in an error being thrown) | ||
// @type {Array<{ container: HTMLElement, firstTabbableNode: HTMLElement|null, lastTabbableNode: HTMLElement|null }>} | ||
// @type {Array<{ | ||
// container: HTMLElement, | ||
// firstTabbableNode: HTMLElement|null, | ||
// lastTabbableNode: HTMLElement|null, | ||
// nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined | ||
// }>} | ||
tabbableGroups: [], | ||
@@ -277,4 +282,7 @@ nodeFocusedBeforeActivation: null, | ||
getShadowRoot: (_config$tabbableOptio = config.tabbableOptions) === null || _config$tabbableOptio === void 0 ? void 0 : _config$tabbableOptio.getShadowRoot | ||
}); | ||
}); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes | ||
// are a superset of tabbable nodes | ||
var focusableNodes = tabbable.focusable(container); | ||
if (tabbableNodes.length > 0) { | ||
@@ -284,3 +292,38 @@ return { | ||
firstTabbableNode: tabbableNodes[0], | ||
lastTabbableNode: tabbableNodes[tabbableNodes.length - 1] | ||
lastTabbableNode: tabbableNodes[tabbableNodes.length - 1], | ||
/** | ||
* Finds the __tabbable__ node that follows the given node in the specified direction, | ||
* in this container, if any. | ||
* @param {HTMLElement} node | ||
* @param {boolean} [forward] True if going in forward tab order; false if going | ||
* in reverse. | ||
* @returns {HTMLElement|undefined} The next tabbable node, if any. | ||
*/ | ||
nextTabbableNode: function nextTabbableNode(node) { | ||
var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
// NOTE: If tabindex is positive (in order to manipulate the tab order separate | ||
// from the DOM order), this __will not work__ because the list of focusableNodes, | ||
// while it contains tabbable nodes, does not sort its nodes in any order other | ||
// than DOM order, because it can't: Where would you place focusable (but not | ||
// tabbable) nodes in that order? They have no order, because they aren't tabbale... | ||
// Support for positive tabindex is already broken and hard to manage (possibly | ||
// not supportable, TBD), so this isn't going to make things worse than they | ||
// already are, and at least makes things better for the majority of cases where | ||
// tabindex is either 0/unset or negative. | ||
// FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375 | ||
var nodeIdx = focusableNodes.findIndex(function (n) { | ||
return n === node; | ||
}); | ||
if (forward) { | ||
return focusableNodes.slice(nodeIdx + 1).find(function (n) { | ||
return tabbable.isTabbable(n); | ||
}); | ||
} | ||
return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) { | ||
return tabbable.isTabbable(n); | ||
}); | ||
} | ||
}; | ||
@@ -404,2 +447,3 @@ } | ||
}); | ||
var containerGroup = containerIndex >= 0 ? state.tabbableGroups[containerIndex] : undefined; | ||
@@ -424,6 +468,7 @@ if (containerIndex < 0) { | ||
if (startOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target))) { | ||
if (startOfGroupIndex < 0 && (containerGroup.container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target) && !containerGroup.nextTabbableNode(target, false))) { | ||
// 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 | ||
// and user clicked on it or node was programmatically given focus) | ||
// and is not followed by any other tabbable node, in which | ||
// case, we should handle shift+tab as if focus were on the container's | ||
@@ -450,6 +495,7 @@ // first tabbable node, and go to the last tabbable node of the LAST group | ||
if (lastOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target))) { | ||
if (lastOfGroupIndex < 0 && (containerGroup.container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target) && !containerGroup.nextTabbableNode(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 | ||
// and user clicked on it or node was programmatically given focus) | ||
// and is not followed by any other tabbable node, in which | ||
// case, we should handle tab as if focus were on the container's | ||
@@ -456,0 +502,0 @@ // last tabbable node, and go to the first tabbable node of the FIRST group |
/*! | ||
* focus-trap 6.8.0-beta.0 | ||
* focus-trap 6.8.0-beta.1 | ||
* @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,b=(null==s?void 0:s.document)||document,f=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},d=function(e,t,n){return e&&void 0!==e[t]?e[t]:f[n||t]},p=function(e){return!(!e||!v.containers.some((function(t){return t.contains(e)})))},h=function(e){var t=f[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},y=function(){var e=h("initialFocus");if(!1===e)return!1;if(void 0===e)if(p(b.activeElement))e=b.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,a=e.tabbable(t,{getShadowRoot:null===(n=f.tabbableOptions)||void 0===n?void 0:n.getShadowRoot});if(a.length>0)return{container:t,firstTabbableNode:a[0],lastTabbableNode:a[a.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!==b.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!f.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);p(n)||(c(f.clickOutsideDeactivates,t)?l.deactivate({returnFocus:f.returnFocusOnDeactivate&&!e.isFocusable(n)}):c(f.allowOutsideClick,t)||t.preventDefault())},O=function(e){var t=u(e),n=p(t);n||t instanceof Document?n&&(v.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),g(v.mostRecentlyFocusedNode||y()))},E=function(t){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(t)&&!1!==c(f.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(),g(a))}(t)},T=function(e){if(!c(f.clickOutsideDeactivates,e)){var t=u(e);p(t)||c(f.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},k=function(){if(v.active)return r.activateTrap(l),v.delayInitialFocusTimer=f.delayInitialFocus?o((function(){g(y())})):g(y()),b.addEventListener("focusin",O,!0),b.addEventListener("mousedown",F,{capture:!0,passive:!1}),b.addEventListener("touchstart",F,{capture:!0,passive:!1}),b.addEventListener("click",T,{capture:!0,passive:!1}),b.addEventListener("keydown",E,{capture:!0,passive:!1}),l},D=function(){if(v.active)return b.removeEventListener("focusin",O,!0),b.removeEventListener("mousedown",F,!0),b.removeEventListener("touchstart",F,!0),b.removeEventListener("click",T,!0),b.removeEventListener("keydown",E,!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=b.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=d(e,"onDeactivate"),n=d(e,"onPostDeactivate"),a=d(e,"checkCanReturnFocus");t&&t();var i=d(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?b.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,b=(null==s?void 0:s.document)||document,f=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},d=function(e,t,n){return e&&void 0!==e[t]?e[t]:f[n||t]},p=function(e){return!(!e||!v.containers.some((function(t){return t.contains(e)})))},h=function(e){var t=f[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},y=function(){var e=h("initialFocus");if(!1===e)return!1;if(void 0===e)if(p(b.activeElement))e=b.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,a=e.tabbable(t,{getShadowRoot:null===(n=f.tabbableOptions)||void 0===n?void 0:n.getShadowRoot}),r=e.focusable(t);if(a.length>0)return{container:t,firstTabbableNode:a[0],lastTabbableNode:a[a.length-1],nextTabbableNode:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=r.findIndex((function(e){return e===t}));return n?r.slice(a+1).find((function(t){return e.isTabbable(t)})):r.slice(0,a).reverse().find((function(t){return e.isTabbable(t)}))}}})).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!==b.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!f.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);p(n)||(c(f.clickOutsideDeactivates,t)?l.deactivate({returnFocus:f.returnFocusOnDeactivate&&!e.isFocusable(n)}):c(f.allowOutsideClick,t)||t.preventDefault())},O=function(e){var t=u(e),n=p(t);n||t instanceof Document?n&&(v.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),g(v.mostRecentlyFocusedNode||y()))},T=function(t){if(function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(t)&&!1!==c(f.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)})),o=r>=0?v.tabbableGroups[r]:void 0;if(r<0)a=t.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(t.shiftKey){var c=i(v.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(c<0&&(o.container===n||e.isFocusable(n)&&!e.isTabbable(n)&&!o.nextTabbableNode(n,!1))&&(c=r),c>=0){var s=0===c?v.tabbableGroups.length-1:c-1;a=v.tabbableGroups[s].lastTabbableNode}}else{var l=i(v.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(l<0&&(o.container===n||e.isFocusable(n)&&!e.isTabbable(n)&&!o.nextTabbableNode(n))&&(l=r),l>=0){var b=l===v.tabbableGroups.length-1?0:l+1;a=v.tabbableGroups[b].firstTabbableNode}}}else a=h("fallbackFocus");a&&(t.preventDefault(),g(a))}(t)},E=function(e){if(!c(f.clickOutsideDeactivates,e)){var t=u(e);p(t)||c(f.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},k=function(){if(v.active)return r.activateTrap(l),v.delayInitialFocusTimer=f.delayInitialFocus?o((function(){g(y())})):g(y()),b.addEventListener("focusin",O,!0),b.addEventListener("mousedown",F,{capture:!0,passive:!1}),b.addEventListener("touchstart",F,{capture:!0,passive:!1}),b.addEventListener("click",E,{capture:!0,passive:!1}),b.addEventListener("keydown",T,{capture:!0,passive:!1}),l},D=function(){if(v.active)return b.removeEventListener("focusin",O,!0),b.removeEventListener("mousedown",F,!0),b.removeEventListener("touchstart",F,!0),b.removeEventListener("click",E,!0),b.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=b.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=d(e,"onDeactivate"),n=d(e,"onPostDeactivate"),a=d(e,"checkCanReturnFocus");t&&t();var i=d(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?b.querySelector(e):e})),v.active&&m(),this}}).updateContainerElements(a),l}; | ||
//# sourceMappingURL=focus-trap.min.js.map |
/*! | ||
* focus-trap 6.8.0-beta.0 | ||
* focus-trap 6.8.0-beta.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
@@ -171,3 +171,8 @@ */ | ||
// result in an error being thrown) | ||
// @type {Array<{ container: HTMLElement, firstTabbableNode: HTMLElement|null, lastTabbableNode: HTMLElement|null }>} | ||
// @type {Array<{ | ||
// container: HTMLElement, | ||
// firstTabbableNode: HTMLElement|null, | ||
// lastTabbableNode: HTMLElement|null, | ||
// nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined | ||
// }>} | ||
tabbableGroups: [], | ||
@@ -282,4 +287,7 @@ nodeFocusedBeforeActivation: null, | ||
getShadowRoot: (_config$tabbableOptio = config.tabbableOptions) === null || _config$tabbableOptio === void 0 ? void 0 : _config$tabbableOptio.getShadowRoot | ||
}); | ||
}); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes | ||
// are a superset of tabbable nodes | ||
var focusableNodes = tabbable.focusable(container); | ||
if (tabbableNodes.length > 0) { | ||
@@ -289,3 +297,38 @@ return { | ||
firstTabbableNode: tabbableNodes[0], | ||
lastTabbableNode: tabbableNodes[tabbableNodes.length - 1] | ||
lastTabbableNode: tabbableNodes[tabbableNodes.length - 1], | ||
/** | ||
* Finds the __tabbable__ node that follows the given node in the specified direction, | ||
* in this container, if any. | ||
* @param {HTMLElement} node | ||
* @param {boolean} [forward] True if going in forward tab order; false if going | ||
* in reverse. | ||
* @returns {HTMLElement|undefined} The next tabbable node, if any. | ||
*/ | ||
nextTabbableNode: function nextTabbableNode(node) { | ||
var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
// NOTE: If tabindex is positive (in order to manipulate the tab order separate | ||
// from the DOM order), this __will not work__ because the list of focusableNodes, | ||
// while it contains tabbable nodes, does not sort its nodes in any order other | ||
// than DOM order, because it can't: Where would you place focusable (but not | ||
// tabbable) nodes in that order? They have no order, because they aren't tabbale... | ||
// Support for positive tabindex is already broken and hard to manage (possibly | ||
// not supportable, TBD), so this isn't going to make things worse than they | ||
// already are, and at least makes things better for the majority of cases where | ||
// tabindex is either 0/unset or negative. | ||
// FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375 | ||
var nodeIdx = focusableNodes.findIndex(function (n) { | ||
return n === node; | ||
}); | ||
if (forward) { | ||
return focusableNodes.slice(nodeIdx + 1).find(function (n) { | ||
return tabbable.isTabbable(n); | ||
}); | ||
} | ||
return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) { | ||
return tabbable.isTabbable(n); | ||
}); | ||
} | ||
}; | ||
@@ -409,2 +452,3 @@ } | ||
}); | ||
var containerGroup = containerIndex >= 0 ? state.tabbableGroups[containerIndex] : undefined; | ||
@@ -429,6 +473,7 @@ if (containerIndex < 0) { | ||
if (startOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target))) { | ||
if (startOfGroupIndex < 0 && (containerGroup.container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target) && !containerGroup.nextTabbableNode(target, false))) { | ||
// 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 | ||
// and user clicked on it or node was programmatically given focus) | ||
// and is not followed by any other tabbable node, in which | ||
// case, we should handle shift+tab as if focus were on the container's | ||
@@ -455,6 +500,7 @@ // first tabbable node, and go to the last tabbable node of the LAST group | ||
if (lastOfGroupIndex < 0 && (state.tabbableGroups[containerIndex].container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target))) { | ||
if (lastOfGroupIndex < 0 && (containerGroup.container === target || tabbable.isFocusable(target) && !tabbable.isTabbable(target) && !containerGroup.nextTabbableNode(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 | ||
// and user clicked on it or node was programmatically given focus) | ||
// and is not followed by any other tabbable node, in which | ||
// case, we should handle tab as if focus were on the container's | ||
@@ -461,0 +507,0 @@ // last tabbable node, and go to the first tabbable node of the FIRST group |
/*! | ||
* focus-trap 6.8.0-beta.0 | ||
* focus-trap 6.8.0-beta.1 | ||
* @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 o,r=(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()}}),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,o){var l,f=(null==o?void 0:o.document)||document,b=function(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}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},o),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),o=1;o<n;o++)a[o-1]=arguments[o];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 r=t;if("string"==typeof t&&!(r=f.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return r},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,a=t.tabbable(e,{getShadowRoot:null===(n=b.tabbableOptions)||void 0===n?void 0:n.getShadowRoot});if(a.length>0)return{container:e,firstTabbableNode:a[0],lastTabbableNode:a[a.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 n=s(e);m();var a=null;if(v.tabbableGroups.length>0){var o=c(v.tabbableGroups,(function(e){return e.container.contains(n)}));if(o<0)a=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 t=e.firstTabbableNode;return n===t}));if(r<0&&(v.tabbableGroups[o].container===n||t.isFocusable(n)&&!t.isTabbable(n))&&(r=o),r>=0){var i=0===r?v.tabbableGroups.length-1:r-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[o].container===n||t.isFocusable(n)&&!t.isTabbable(n))&&(u=o),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 r.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 o=function(){a&&m(),k(),n&&n()};return a?(a(v.containers.concat()).then(o,o),this):(o(),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=d(e,"onDeactivate"),n=d(e,"onPostDeactivate"),a=d(e,"checkCanReturnFocus");t&&t();var o=d(e,"returnFocus","returnFocusOnDeactivate"),c=function(){i((function(){o&&g(w(v.nodeFocusedBeforeActivation)),n&&n()}))};return o&&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 o,r=(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()}}),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,o){var l,f=(null==o?void 0:o.document)||document,b=function(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}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},o),d={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0},v=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},p=function(e){return!(!e||!d.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),o=1;o<n;o++)a[o-1]=arguments[o];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 r=t;if("string"==typeof t&&!(r=f.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return r},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=d.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(d.tabbableGroups=d.containers.map((function(e){var n,a=t.tabbable(e,{getShadowRoot:null===(n=b.tabbableOptions)||void 0===n?void 0:n.getShadowRoot}),o=t.focusable(e);if(a.length>0)return{container:e,firstTabbableNode:a[0],lastTabbableNode:a[a.length-1],nextTabbableNode:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=o.findIndex((function(t){return t===e}));return n?o.slice(a+1).find((function(e){return t.isTabbable(e)})):o.slice(0,a).reverse().find((function(e){return t.isTabbable(e)}))}}})).filter((function(e){return!!e})),d.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}),d.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(y()))},T=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())},F=function(e){var t=s(e),n=p(t);n||t instanceof Document?n&&(d.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),g(d.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(d.tabbableGroups.length>0){var o=c(d.tabbableGroups,(function(e){return e.container.contains(n)})),r=o>=0?d.tabbableGroups[o]:void 0;if(o<0)a=e.shiftKey?d.tabbableGroups[d.tabbableGroups.length-1].lastTabbableNode:d.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var i=c(d.tabbableGroups,(function(e){var t=e.firstTabbableNode;return n===t}));if(i<0&&(r.container===n||t.isFocusable(n)&&!t.isTabbable(n)&&!r.nextTabbableNode(n,!1))&&(i=o),i>=0){var u=0===i?d.tabbableGroups.length-1:i-1;a=d.tabbableGroups[u].lastTabbableNode}}else{var l=c(d.tabbableGroups,(function(e){var t=e.lastTabbableNode;return n===t}));if(l<0&&(r.container===n||t.isFocusable(n)&&!t.isTabbable(n)&&!r.nextTabbableNode(n))&&(l=o),l>=0){var f=l===d.tabbableGroups.length-1?0:l+1;a=d.tabbableGroups[f].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(d.active)return r.activateTrap(l),d.delayInitialFocusTimer=b.delayInitialFocus?i((function(){g(y())})):g(y()),f.addEventListener("focusin",F,!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(d.active)return f.removeEventListener("focusin",F,!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(d.active)return this;var t=v(e,"onActivate"),n=v(e,"onPostActivate"),a=v(e,"checkCanFocusTrap");a||m(),d.active=!0,d.paused=!1,d.nodeFocusedBeforeActivation=f.activeElement,t&&t();var o=function(){a&&m(),k(),n&&n()};return a?(a(d.containers.concat()).then(o,o),this):(o(),this)},deactivate:function(e){if(!d.active)return this;clearTimeout(d.delayInitialFocusTimer),d.delayInitialFocusTimer=void 0,D(),d.active=!1,d.paused=!1,r.deactivateTrap(l);var t=v(e,"onDeactivate"),n=v(e,"onPostDeactivate"),a=v(e,"checkCanReturnFocus");t&&t();var o=v(e,"returnFocus","returnFocusOnDeactivate"),c=function(){i((function(){o&&g(T(d.nodeFocusedBeforeActivation)),n&&n()}))};return o&&a?(a(T(d.nodeFocusedBeforeActivation)).then(c,c),this):(c(),this)},pause:function(){return d.paused||!d.active||(d.paused=!0,D()),this},unpause:function(){return d.paused&&d.active?(d.paused=!1,m(),k(),this):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return d.containers=t.map((function(e){return"string"==typeof e?f.querySelector(e):e})),d.active&&m(),this}}).updateContainerElements(e),l},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=focus-trap.umd.min.js.map |
64
index.js
@@ -1,2 +0,2 @@ | ||
import { tabbable, isFocusable, isTabbable } from 'tabbable'; | ||
import { tabbable, focusable, isFocusable, isTabbable } from 'tabbable'; | ||
@@ -120,3 +120,8 @@ const activeFocusTraps = (function () { | ||
// result in an error being thrown) | ||
// @type {Array<{ container: HTMLElement, firstTabbableNode: HTMLElement|null, lastTabbableNode: HTMLElement|null }>} | ||
// @type {Array<{ | ||
// container: HTMLElement, | ||
// firstTabbableNode: HTMLElement|null, | ||
// lastTabbableNode: HTMLElement|null, | ||
// nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined | ||
// }>} | ||
tabbableGroups: [], | ||
@@ -241,2 +246,6 @@ | ||
// NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes | ||
// are a superset of tabbable nodes | ||
const focusableNodes = focusable(container); | ||
if (tabbableNodes.length > 0) { | ||
@@ -247,2 +256,33 @@ return { | ||
lastTabbableNode: tabbableNodes[tabbableNodes.length - 1], | ||
/** | ||
* Finds the __tabbable__ node that follows the given node in the specified direction, | ||
* in this container, if any. | ||
* @param {HTMLElement} node | ||
* @param {boolean} [forward] True if going in forward tab order; false if going | ||
* in reverse. | ||
* @returns {HTMLElement|undefined} The next tabbable node, if any. | ||
*/ | ||
nextTabbableNode(node, forward = true) { | ||
// NOTE: If tabindex is positive (in order to manipulate the tab order separate | ||
// from the DOM order), this __will not work__ because the list of focusableNodes, | ||
// while it contains tabbable nodes, does not sort its nodes in any order other | ||
// than DOM order, because it can't: Where would you place focusable (but not | ||
// tabbable) nodes in that order? They have no order, because they aren't tabbale... | ||
// Support for positive tabindex is already broken and hard to manage (possibly | ||
// not supportable, TBD), so this isn't going to make things worse than they | ||
// already are, and at least makes things better for the majority of cases where | ||
// tabindex is either 0/unset or negative. | ||
// FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375 | ||
const nodeIdx = focusableNodes.findIndex((n) => n === node); | ||
if (forward) { | ||
return focusableNodes | ||
.slice(nodeIdx + 1) | ||
.find((n) => isTabbable(n)); | ||
} | ||
return focusableNodes | ||
.slice(0, nodeIdx) | ||
.reverse() | ||
.find((n) => isTabbable(n)); | ||
}, | ||
}; | ||
@@ -368,2 +408,4 @@ } | ||
); | ||
const containerGroup = | ||
containerIndex >= 0 ? state.tabbableGroups[containerIndex] : undefined; | ||
@@ -393,8 +435,11 @@ if (containerIndex < 0) { | ||
startOfGroupIndex < 0 && | ||
(state.tabbableGroups[containerIndex].container === target || | ||
(isFocusable(target) && !isTabbable(target))) | ||
(containerGroup.container === target || | ||
(isFocusable(target) && | ||
!isTabbable(target) && | ||
!containerGroup.nextTabbableNode(target, false))) | ||
) { | ||
// 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 | ||
// and user clicked on it or node was programmatically given focus) | ||
// and is not followed by any other tabbable node, in which | ||
// case, we should handle shift+tab as if focus were on the container's | ||
@@ -428,8 +473,11 @@ // first tabbable node, and go to the last tabbable node of the LAST group | ||
lastOfGroupIndex < 0 && | ||
(state.tabbableGroups[containerIndex].container === target || | ||
(isFocusable(target) && !isTabbable(target))) | ||
(containerGroup.container === target || | ||
(isFocusable(target) && | ||
!isTabbable(target) && | ||
!containerGroup.nextTabbableNode(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 | ||
// and user clicked on it or node was programmatically given focus) | ||
// and is not followed by any other tabbable node, in which | ||
// case, we should handle tab as if focus were on the container's | ||
@@ -436,0 +484,0 @@ // last tabbable node, and go to the first tabbable node of the FIRST group |
{ | ||
"name": "focus-trap", | ||
"version": "6.8.0-beta.0", | ||
"version": "6.8.0-beta.1", | ||
"description": "Trap focus within a DOM node.", | ||
@@ -68,5 +68,5 @@ "main": "dist/focus-trap.js", | ||
"devDependencies": { | ||
"@babel/cli": "^7.16.8", | ||
"@babel/core": "^7.16.12", | ||
"@babel/eslint-parser": "^7.16.5", | ||
"@babel/cli": "^7.17.0", | ||
"@babel/core": "^7.17.2", | ||
"@babel/eslint-parser": "^7.17.0", | ||
"@babel/preset-env": "^7.16.11", | ||
@@ -82,5 +82,5 @@ "@changesets/cli": "^2.20.0", | ||
"cross-env": "^7.0.3", | ||
"cypress": "^9.3.1", | ||
"cypress": "^9.4.1", | ||
"cypress-plugin-tab": "^1.0.5", | ||
"eslint": "^8.7.0", | ||
"eslint": "^8.8.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
@@ -90,3 +90,3 @@ "eslint-plugin-cypress": "^2.12.1", | ||
"prettier": "^2.5.1", | ||
"rollup": "^2.66.1", | ||
"rollup": "^2.67.1", | ||
"rollup-plugin-inject-process-env": "^1.3.1", | ||
@@ -93,0 +93,0 @@ "rollup-plugin-livereload": "^2.0.5", |
# 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-20-orange.svg?style=flat-square)](#contributors) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-21-orange.svg?style=flat-square)](#contributors) | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
@@ -272,5 +272,6 @@ | ||
<td align="center"><a href="https://seanmcp.com/"><img src="https://avatars1.githubusercontent.com/u/6360367?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sean McPherson</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=SeanMcP" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=SeanMcP" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://recollectr.io"><img src="https://avatars2.githubusercontent.com/u/6835891?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Slapbox</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3ASlapbox" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/skriems"><img src="https://avatars.githubusercontent.com/u/15573317?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sebastian Kriems</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Askriems" title="Bug reports">🐛</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="https://recollectr.io"><img src="https://avatars2.githubusercontent.com/u/6835891?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Slapbox</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3ASlapbox" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://stefancameron.com/"><img src="https://avatars3.githubusercontent.com/u/2855350?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefan Cameron</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=stefcameron" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Astefcameron" title="Bug reports">🐛</a> <a href="#infra-stefcameron" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=stefcameron" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=stefcameron" title="Documentation">📖</a> <a href="#maintenance-stefcameron" title="Maintenance">🚧</a></td> | ||
@@ -277,0 +278,0 @@ <td align="center"><a href="http://tylerhawkins.info/201R/"><img src="https://avatars0.githubusercontent.com/u/13806458?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler Hawkins</b></sub></a><br /><a href="#tool-thawkin3" title="Tools">🔧</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=thawkin3" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=thawkin3" title="Documentation">📖</a></td> |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
408175
2711
289