focus-trap 6.8.0-beta.2 → 6.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 21458c9: Bumps tabbable to v5.3.0 and includes all changes from the past v6.8.0 beta releases. The big new feature is opt-in Shadow DOM support in tabbable, and a new `getShadowRoot` tabbable option exposed in a new `tabbableOptions` focus-trap config option.
8
+
3
9
  ## 6.8.0-beta.2
4
10
 
5
11
  - When updating tabbable nodes, make sure that `getShadowRoot` tabbable option is also passed to `focusable()`.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 6.8.0-beta.2
2
+ * focus-trap 6.8.0
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  import { tabbable, focusable, isTabbable, isFocusable } from 'tabbable';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 6.8.0-beta.2
2
+ * focus-trap 6.8.0
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  import{tabbable as e,focusable as t,isTabbable as n,isFocusable as a}from"tabbable";function o(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 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?o(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},b),h={containers:[],containerGroups:[],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 h.containerGroups.findIndex((function(t){var n=t.container,a=t.tabbableNodes;return n.contains(e)||a.find((function(t){return t===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),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=d.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return r},w=function(){var e=g("initialFocus");if(!1===e)return!1;if(void 0===e)if(y(d.activeElement)>=0)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.containerGroups=h.containers.map((function(a){var o,r,i=e(a,{getShadowRoot:null===(o=p.tabbableOptions)||void 0===o?void 0:o.getShadowRoot}),c=t(a,{getShadowRoot:null===(r=p.tabbableOptions)||void 0===r?void 0:r.getShadowRoot});return{container:a,tabbableNodes:i,focusableNodes:c,firstTabbableNode:i.length>0?i[0]:null,lastTabbableNode:i.length>0?i[i.length-1]:null,nextTabbableNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=c.findIndex((function(t){return t===e}));if(!(a<0))return t?c.slice(a+1).find((function(e){return n(e)})):c.slice(0,a).reverse().find((function(e){return n(e)}))}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),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)>=0||(l(p.clickOutsideDeactivates,e)?v.deactivate({returnFocus:p.returnFocusOnDeactivate&&!a(t)}):l(p.allowOutsideClick,e)||e.preventDefault())},N=function(e){var t=f(e),n=y(t)>=0;n||t instanceof Document?n&&(h.mostRecentlyFocusedNode=t):(e.stopImmediatePropagation(),F(h.mostRecentlyFocusedNode||w()))},k=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 o=null;if(h.tabbableGroups.length>0){var r=y(t),i=r>=0?h.containerGroups[r]:void 0;if(r<0)o=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=r),c>=0){var u=0===c?h.tabbableGroups.length-1:c-1;o=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=r),l>=0){var b=l===h.tabbableGroups.length-1?0:l+1;o=h.tabbableGroups[b].firstTabbableNode}}}else o=g("fallbackFocus");o&&(e.preventDefault(),F(o))}(e)},G=function(e){if(!l(p.clickOutsideDeactivates,e)){var t=f(e);y(t)>=0||l(p.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},D=function(){if(h.active)return c.activateTrap(v),h.delayInitialFocusTimer=p.delayInitialFocus?u((function(){F(w())})):F(w()),d.addEventListener("focusin",N,!0),d.addEventListener("mousedown",T,{capture:!0,passive:!1}),d.addEventListener("touchstart",T,{capture:!0,passive:!1}),d.addEventListener("click",G,{capture:!0,passive:!1}),d.addEventListener("keydown",k,{capture:!0,passive:!1}),v},P=function(){if(h.active)return d.removeEventListener("focusin",N,!0),d.removeEventListener("mousedown",T,!0),d.removeEventListener("touchstart",T,!0),d.removeEventListener("click",G,!0),d.removeEventListener("keydown",k,!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 o=function(){a&&O(),D(),n&&n()};return a?(a(h.containers.concat()).then(o,o),this):(o(),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 o=m(e,"returnFocus","returnFocusOnDeactivate"),r=function(){u((function(){o&&F(E(h.nodeFocusedBeforeActivation)),n&&n()}))};return o&&a?(a(E(h.nodeFocusedBeforeActivation)).then(r,r),this):(r(),this)},pause:function(){return h.paused||!h.active||(h.paused=!0,P()),this},unpause:function(){return h.paused&&h.active?(h.paused=!1,O(),D(),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};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 6.8.0-beta.2
2
+ * focus-trap 6.8.0
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  'use strict';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 6.8.0-beta.2
2
+ * focus-trap 6.8.0
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  "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:[],containerGroups:[],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 v.containerGroups.findIndex((function(t){var n=t.container,a=t.tabbableNodes;return n.contains(e)||a.find((function(t){return t===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)>=0)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.containerGroups=v.containers.map((function(t){var n,a,r=e.tabbable(t,{getShadowRoot:null===(n=f.tabbableOptions)||void 0===n?void 0:n.getShadowRoot}),o=e.focusable(t,{getShadowRoot:null===(a=f.tabbableOptions)||void 0===a?void 0:a.getShadowRoot});return{container:t,tabbableNodes:r,focusableNodes:o,firstTabbableNode:r.length>0?r[0]:null,lastTabbableNode:r.length>0?r[r.length-1]:null,nextTabbableNode:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=o.findIndex((function(e){return e===t}));if(!(a<0))return n?o.slice(a+1).find((function(t){return e.isTabbable(t)})):o.slice(0,a).reverse().find((function(t){return e.isTabbable(t)}))}}})),v.tabbableGroups=v.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),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)>=0||(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)>=0;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=p(n),o=r>=0?v.containerGroups[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)>=0||c(f.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},N=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},k=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(),N(),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,k(),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,k()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,m(),N(),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};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 6.8.0-beta.2
2
+ * focus-trap 6.8.0
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  (function (global, factory) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 6.8.0-beta.2
2
+ * focus-trap 6.8.0
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  !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,b=(null==o?void 0:o.document)||document,f=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:[],containerGroups:[],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]:f[n||t]},p=function(e){return d.containerGroups.findIndex((function(t){var n=t.container,a=t.tabbableNodes;return n.contains(e)||a.find((function(t){return t===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),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=b.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(b.activeElement)>=0)e=b.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.containerGroups=d.containers.map((function(e){var n,a,o=t.tabbable(e,{getShadowRoot:null===(n=f.tabbableOptions)||void 0===n?void 0:n.getShadowRoot}),r=t.focusable(e,{getShadowRoot:null===(a=f.tabbableOptions)||void 0===a?void 0:a.getShadowRoot});return{container:e,tabbableNodes:o,focusableNodes:r,firstTabbableNode:o.length>0?o[0]:null,lastTabbableNode:o.length>0?o[o.length-1]:null,nextTabbableNode:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=r.findIndex((function(t){return t===e}));if(!(a<0))return n?r.slice(a+1).find((function(e){return t.isTabbable(e)})):r.slice(0,a).reverse().find((function(e){return t.isTabbable(e)}))}}})),d.tabbableGroups=d.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),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!==b.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!f.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)>=0||(u(f.clickOutsideDeactivates,e)?l.deactivate({returnFocus:f.returnFocusOnDeactivate&&!t.isFocusable(n)}):u(f.allowOutsideClick,e)||e.preventDefault())},F=function(e){var t=s(e),n=p(t)>=0;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(f.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=p(n),r=o>=0?d.containerGroups[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 b=l===d.tabbableGroups.length-1?0:l+1;a=d.tabbableGroups[b].firstTabbableNode}}}else a=h("fallbackFocus");a&&(e.preventDefault(),g(a))}(e)},E=function(e){if(!u(f.clickOutsideDeactivates,e)){var t=s(e);p(t)>=0||u(f.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())}},N=function(){if(d.active)return r.activateTrap(l),d.delayInitialFocusTimer=f.delayInitialFocus?i((function(){g(y())})):g(y()),b.addEventListener("focusin",F,!0),b.addEventListener("mousedown",w,{capture:!0,passive:!1}),b.addEventListener("touchstart",w,{capture:!0,passive:!1}),b.addEventListener("click",E,{capture:!0,passive:!1}),b.addEventListener("keydown",O,{capture:!0,passive:!1}),l},k=function(){if(d.active)return b.removeEventListener("focusin",F,!0),b.removeEventListener("mousedown",w,!0),b.removeEventListener("touchstart",w,!0),b.removeEventListener("click",E,!0),b.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=b.activeElement,t&&t();var o=function(){a&&m(),N(),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,k(),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,k()),this},unpause:function(){return d.paused&&d.active?(d.paused=!1,m(),N(),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&&m(),this}}).updateContainerElements(e),l},Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "focus-trap",
3
- "version": "6.8.0-beta.2",
3
+ "version": "6.8.0",
4
4
  "description": "Trap focus within a DOM node.",
5
5
  "main": "dist/focus-trap.js",
6
6
  "module": "dist/focus-trap.esm.js",
@@ -63,36 +63,36 @@
63
63
  },
64
64
  "homepage": "https://github.com/focus-trap/focus-trap#readme",
65
65
  "dependencies": {
66
- "tabbable": "5.3.0-beta.1"
66
+ "tabbable": "5.3.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@babel/cli": "^7.17.6",
70
- "@babel/core": "^7.17.5",
70
+ "@babel/core": "^7.17.9",
71
71
  "@babel/eslint-parser": "^7.17.0",
72
72
  "@babel/preset-env": "^7.16.11",
73
- "@changesets/cli": "^2.21.1",
73
+ "@changesets/cli": "^2.22.0",
74
74
  "@rollup/plugin-babel": "^5.3.1",
75
- "@rollup/plugin-commonjs": "^21.0.2",
76
- "@rollup/plugin-node-resolve": "^13.1.3",
75
+ "@rollup/plugin-commonjs": "^21.1.0",
76
+ "@rollup/plugin-node-resolve": "^13.2.1",
77
77
  "@testing-library/cypress": "^8.0.2",
78
78
  "@types/jquery": "^3.5.14",
79
79
  "all-contributors-cli": "^6.20.0",
80
- "babel-loader": "^8.2.3",
80
+ "babel-loader": "^8.2.5",
81
81
  "cross-env": "^7.0.3",
82
- "cypress": "^9.5.1",
82
+ "cypress": "^9.5.4",
83
83
  "cypress-plugin-tab": "^1.0.5",
84
- "eslint": "^8.10.0",
84
+ "eslint": "^8.13.0",
85
85
  "eslint-config-prettier": "^8.5.0",
86
86
  "eslint-plugin-cypress": "^2.12.1",
87
87
  "onchange": "^7.1.0",
88
- "prettier": "^2.5.1",
89
- "rollup": "^2.70.0",
88
+ "prettier": "^2.6.2",
89
+ "rollup": "^2.70.2",
90
90
  "rollup-plugin-inject-process-env": "^1.3.1",
91
91
  "rollup-plugin-livereload": "^2.0.5",
92
92
  "rollup-plugin-serve": "^1.1.0",
93
93
  "rollup-plugin-sourcemaps": "^0.6.3",
94
94
  "rollup-plugin-terser": "^7.0.1",
95
95
  "start-server-and-test": "^1.14.0",
96
- "typescript": "^4.6.2"
96
+ "typescript": "^4.6.3"
97
97
  }
98
98
  }