focus-trap
Advanced tools
Comparing version 6.5.0 to 6.5.1
# Changelog | ||
## 6.5.1 | ||
### Patch Changes | ||
- c38bf3f: onPostDeactivate should always be called even if returnFocus/OnDeactivate is disabled. | ||
## 6.5.0 | ||
@@ -4,0 +10,0 @@ |
/*! | ||
* focus-trap 6.5.0 | ||
* focus-trap 6.5.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
@@ -562,11 +562,11 @@ */ | ||
var finishDeactivation = function finishDeactivation() { | ||
if (returnFocus) { | ||
delay(function () { | ||
delay(function () { | ||
if (returnFocus) { | ||
tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)); | ||
} | ||
if (onPostDeactivate) { | ||
onPostDeactivate(); | ||
} | ||
}); | ||
} | ||
if (onPostDeactivate) { | ||
onPostDeactivate(); | ||
} | ||
}); | ||
}; | ||
@@ -573,0 +573,0 @@ |
/*! | ||
* focus-trap 6.5.0 | ||
* focus-trap 6.5.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
*/ | ||
import{tabbable as e,isFocusable as t}from"tabbable";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}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 a,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,r){return!t(e)||(n=r,!1)})),n},s=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return"function"==typeof e?e.apply(void 0,n):e},l=function(o,l){var f,b=document,v=function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?n(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):n(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},l),p={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},d=function(e,t,n){return e&&void 0!==e[t]?e[t]:v[n||t]},h=function(e){return p.containers.some((function(t){return t.contains(e)}))},m=function(e){var t=v[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=b.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},g=function(){var e;if(null!==m("initialFocus"))e=m("initialFocus");else if(h(b.activeElement))e=b.activeElement;else{var t=p.tabbableGroups[0];e=t&&t.firstTabbableNode||m("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},y=function(){if(p.tabbableGroups=p.containers.map((function(t){var n=e(t);if(n.length>0)return{container:t,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),p.tabbableGroups.length<=0&&!m("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},O=function e(t){t!==b.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!v.preventScroll}),p.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(g()))},w=function(e){var t=m("setReturnFocus");return t||e},E=function(e){h(e.target)||(s(v.clickOutsideDeactivates,e)?f.deactivate({returnFocus:v.returnFocusOnDeactivate&&!t(e.target)}):s(v.allowOutsideClick,e)||e.preventDefault())},F=function(e){var t=h(e.target);t||e.target instanceof Document?t&&(p.mostRecentlyFocusedNode=e.target):(e.stopImmediatePropagation(),O(p.mostRecentlyFocusedNode||g()))},k=function(e){if(!1!==v.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void f.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){y();var t=null;if(p.tabbableGroups.length>0){var n=u(p.tabbableGroups,(function(t){return t.container.contains(e.target)}));if(n<0)t=e.shiftKey?p.tabbableGroups[p.tabbableGroups.length-1].lastTabbableNode:p.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var r=u(p.tabbableGroups,(function(t){var n=t.firstTabbableNode;return e.target===n}));if(r<0&&p.tabbableGroups[n].container===e.target&&(r=n),r>=0){var a=0===r?p.tabbableGroups.length-1:r-1;t=p.tabbableGroups[a].lastTabbableNode}}else{var o=u(p.tabbableGroups,(function(t){var n=t.lastTabbableNode;return e.target===n}));if(o<0&&p.tabbableGroups[n].container===e.target&&(o=n),o>=0){var i=o===p.tabbableGroups.length-1?0:o+1;t=p.tabbableGroups[i].firstTabbableNode}}}else t=m("fallbackFocus");t&&(e.preventDefault(),O(t))}(e)},D=function(e){s(v.clickOutsideDeactivates,e)||h(e.target)||s(v.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},G=function(){if(p.active)return i.activateTrap(f),a=v.delayInitialFocus?c((function(){O(g())})):O(g()),b.addEventListener("focusin",F,!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}),f},T=function(){if(p.active)return b.removeEventListener("focusin",F,!0),b.removeEventListener("mousedown",E,!0),b.removeEventListener("touchstart",E,!0),b.removeEventListener("click",D,!0),b.removeEventListener("keydown",k,!0),f};return(f={activate:function(e){if(p.active)return this;var t=d(e,"onActivate"),n=d(e,"onPostActivate"),r=d(e,"checkCanFocusTrap");r||y(),p.active=!0,p.paused=!1,p.nodeFocusedBeforeActivation=b.activeElement,t&&t();var a=function(){r&&y(),G(),n&&n()};return r?(r(p.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(e){if(!p.active)return this;clearTimeout(a),T(),p.active=!1,p.paused=!1,i.deactivateTrap(f);var t=d(e,"onDeactivate"),n=d(e,"onPostDeactivate"),r=d(e,"checkCanReturnFocus");t&&t();var o=d(e,"returnFocus","returnFocusOnDeactivate"),u=function(){o&&c((function(){O(w(p.nodeFocusedBeforeActivation)),n&&n()}))};return o&&r?(r(w(p.nodeFocusedBeforeActivation)).then(u,u),this):(u(),this)},pause:function(){return p.paused||!p.active||(p.paused=!0,T()),this},unpause:function(){return p.paused&&p.active?(p.paused=!1,y(),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&&y(),this}}).updateContainerElements(o),f};export{l as createFocusTrap}; | ||
import{tabbable as e,isFocusable as t}from"tabbable";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}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 a,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,r){return!t(e)||(n=r,!1)})),n},s=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return"function"==typeof e?e.apply(void 0,n):e},l=function(o,l){var f,b=document,v=function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?n(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):n(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},l),p={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},d=function(e,t,n){return e&&void 0!==e[t]?e[t]:v[n||t]},h=function(e){return p.containers.some((function(t){return t.contains(e)}))},m=function(e){var t=v[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=b.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},g=function(){var e;if(null!==m("initialFocus"))e=m("initialFocus");else if(h(b.activeElement))e=b.activeElement;else{var t=p.tabbableGroups[0];e=t&&t.firstTabbableNode||m("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},y=function(){if(p.tabbableGroups=p.containers.map((function(t){var n=e(t);if(n.length>0)return{container:t,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),p.tabbableGroups.length<=0&&!m("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},O=function e(t){t!==b.activeElement&&(t&&t.focus?(t.focus({preventScroll:!!v.preventScroll}),p.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(g()))},w=function(e){var t=m("setReturnFocus");return t||e},E=function(e){h(e.target)||(s(v.clickOutsideDeactivates,e)?f.deactivate({returnFocus:v.returnFocusOnDeactivate&&!t(e.target)}):s(v.allowOutsideClick,e)||e.preventDefault())},F=function(e){var t=h(e.target);t||e.target instanceof Document?t&&(p.mostRecentlyFocusedNode=e.target):(e.stopImmediatePropagation(),O(p.mostRecentlyFocusedNode||g()))},k=function(e){if(!1!==v.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void f.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){y();var t=null;if(p.tabbableGroups.length>0){var n=u(p.tabbableGroups,(function(t){return t.container.contains(e.target)}));if(n<0)t=e.shiftKey?p.tabbableGroups[p.tabbableGroups.length-1].lastTabbableNode:p.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var r=u(p.tabbableGroups,(function(t){var n=t.firstTabbableNode;return e.target===n}));if(r<0&&p.tabbableGroups[n].container===e.target&&(r=n),r>=0){var a=0===r?p.tabbableGroups.length-1:r-1;t=p.tabbableGroups[a].lastTabbableNode}}else{var o=u(p.tabbableGroups,(function(t){var n=t.lastTabbableNode;return e.target===n}));if(o<0&&p.tabbableGroups[n].container===e.target&&(o=n),o>=0){var i=o===p.tabbableGroups.length-1?0:o+1;t=p.tabbableGroups[i].firstTabbableNode}}}else t=m("fallbackFocus");t&&(e.preventDefault(),O(t))}(e)},D=function(e){s(v.clickOutsideDeactivates,e)||h(e.target)||s(v.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},G=function(){if(p.active)return i.activateTrap(f),a=v.delayInitialFocus?c((function(){O(g())})):O(g()),b.addEventListener("focusin",F,!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}),f},T=function(){if(p.active)return b.removeEventListener("focusin",F,!0),b.removeEventListener("mousedown",E,!0),b.removeEventListener("touchstart",E,!0),b.removeEventListener("click",D,!0),b.removeEventListener("keydown",k,!0),f};return(f={activate:function(e){if(p.active)return this;var t=d(e,"onActivate"),n=d(e,"onPostActivate"),r=d(e,"checkCanFocusTrap");r||y(),p.active=!0,p.paused=!1,p.nodeFocusedBeforeActivation=b.activeElement,t&&t();var a=function(){r&&y(),G(),n&&n()};return r?(r(p.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(e){if(!p.active)return this;clearTimeout(a),T(),p.active=!1,p.paused=!1,i.deactivateTrap(f);var t=d(e,"onDeactivate"),n=d(e,"onPostDeactivate"),r=d(e,"checkCanReturnFocus");t&&t();var o=d(e,"returnFocus","returnFocusOnDeactivate"),u=function(){c((function(){o&&O(w(p.nodeFocusedBeforeActivation)),n&&n()}))};return o&&r?(r(w(p.nodeFocusedBeforeActivation)).then(u,u),this):(u(),this)},pause:function(){return p.paused||!p.active||(p.paused=!0,T()),this},unpause:function(){return p.paused&&p.active?(p.paused=!1,y(),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&&y(),this}}).updateContainerElements(o),f};export{l as createFocusTrap}; | ||
//# sourceMappingURL=focus-trap.esm.min.js.map |
/*! | ||
* focus-trap 6.5.0 | ||
* focus-trap 6.5.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
@@ -566,11 +566,11 @@ */ | ||
var finishDeactivation = function finishDeactivation() { | ||
if (returnFocus) { | ||
delay(function () { | ||
delay(function () { | ||
if (returnFocus) { | ||
tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)); | ||
} | ||
if (onPostDeactivate) { | ||
onPostDeactivate(); | ||
} | ||
}); | ||
} | ||
if (onPostDeactivate) { | ||
onPostDeactivate(); | ||
} | ||
}); | ||
}; | ||
@@ -577,0 +577,0 @@ |
/*! | ||
* focus-trap 6.5.0 | ||
* focus-trap 6.5.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tabbable");function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}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 a,o=(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()}}),i=function(e){return setTimeout(e,0)},c=function(e,t){var n=-1;return e.every((function(e,r){return!t(e)||(n=r,!1)})),n},u=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return"function"==typeof e?e.apply(void 0,n):e};exports.createFocusTrap=function(a,s){var l,f=document,b=function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?n(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):n(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},s),v={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},p=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},d=function(e){return v.containers.some((function(t){return t.contains(e)}))},h=function(e){var t=b[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=f.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},y=function(){var e;if(null!==h("initialFocus"))e=h("initialFocus");else if(d(f.activeElement))e=f.activeElement;else{var t=v.tabbableGroups[0];e=t&&t.firstTabbableNode||h("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},g=function(){if(v.tabbableGroups=v.containers.map((function(e){var n=t.tabbable(e);if(n.length>0)return{container:e,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),v.tabbableGroups.length<=0&&!h("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},m=function e(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()))},O=function(e){var t=h("setReturnFocus");return t||e},w=function(e){d(e.target)||(u(b.clickOutsideDeactivates,e)?l.deactivate({returnFocus:b.returnFocusOnDeactivate&&!t.isFocusable(e.target)}):u(b.allowOutsideClick,e)||e.preventDefault())},F=function(e){var t=d(e.target);t||e.target instanceof Document?t&&(v.mostRecentlyFocusedNode=e.target):(e.stopImmediatePropagation(),m(v.mostRecentlyFocusedNode||y()))},E=function(e){if(!1!==b.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void l.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){g();var t=null;if(v.tabbableGroups.length>0){var n=c(v.tabbableGroups,(function(t){return t.container.contains(e.target)}));if(n<0)t=e.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var r=c(v.tabbableGroups,(function(t){var n=t.firstTabbableNode;return e.target===n}));if(r<0&&v.tabbableGroups[n].container===e.target&&(r=n),r>=0){var a=0===r?v.tabbableGroups.length-1:r-1;t=v.tabbableGroups[a].lastTabbableNode}}else{var o=c(v.tabbableGroups,(function(t){var n=t.lastTabbableNode;return e.target===n}));if(o<0&&v.tabbableGroups[n].container===e.target&&(o=n),o>=0){var i=o===v.tabbableGroups.length-1?0:o+1;t=v.tabbableGroups[i].firstTabbableNode}}}else t=h("fallbackFocus");t&&(e.preventDefault(),m(t))}(e)},k=function(e){u(b.clickOutsideDeactivates,e)||d(e.target)||u(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},D=function(){if(v.active)return o.activateTrap(l),e=b.delayInitialFocus?i((function(){m(y())})):m(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",k,{capture:!0,passive:!1}),f.addEventListener("keydown",E,{capture:!0,passive:!1}),l},T=function(){if(v.active)return f.removeEventListener("focusin",F,!0),f.removeEventListener("mousedown",w,!0),f.removeEventListener("touchstart",w,!0),f.removeEventListener("click",k,!0),f.removeEventListener("keydown",E,!0),l};return(l={activate:function(e){if(v.active)return this;var t=p(e,"onActivate"),n=p(e,"onPostActivate"),r=p(e,"checkCanFocusTrap");r||g(),v.active=!0,v.paused=!1,v.nodeFocusedBeforeActivation=f.activeElement,t&&t();var a=function(){r&&g(),D(),n&&n()};return r?(r(v.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(t){if(!v.active)return this;clearTimeout(e),T(),v.active=!1,v.paused=!1,o.deactivateTrap(l);var n=p(t,"onDeactivate"),r=p(t,"onPostDeactivate"),a=p(t,"checkCanReturnFocus");n&&n();var c=p(t,"returnFocus","returnFocusOnDeactivate"),u=function(){c&&i((function(){m(O(v.nodeFocusedBeforeActivation)),r&&r()}))};return c&&a?(a(O(v.nodeFocusedBeforeActivation)).then(u,u),this):(u(),this)},pause:function(){return v.paused||!v.active||(v.paused=!0,T()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,g(),D(),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&&g(),this}}).updateContainerElements(a),l}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tabbable");function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}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 a,o=(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()}}),i=function(e){return setTimeout(e,0)},c=function(e,t){var n=-1;return e.every((function(e,r){return!t(e)||(n=r,!1)})),n},u=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return"function"==typeof e?e.apply(void 0,n):e};exports.createFocusTrap=function(a,s){var l,f=document,b=function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?n(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):n(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},s),v={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},p=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},d=function(e){return v.containers.some((function(t){return t.contains(e)}))},h=function(e){var t=b[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=f.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},y=function(){var e;if(null!==h("initialFocus"))e=h("initialFocus");else if(d(f.activeElement))e=f.activeElement;else{var t=v.tabbableGroups[0];e=t&&t.firstTabbableNode||h("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},g=function(){if(v.tabbableGroups=v.containers.map((function(e){var n=t.tabbable(e);if(n.length>0)return{container:e,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),v.tabbableGroups.length<=0&&!h("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},m=function e(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()))},O=function(e){var t=h("setReturnFocus");return t||e},w=function(e){d(e.target)||(u(b.clickOutsideDeactivates,e)?l.deactivate({returnFocus:b.returnFocusOnDeactivate&&!t.isFocusable(e.target)}):u(b.allowOutsideClick,e)||e.preventDefault())},F=function(e){var t=d(e.target);t||e.target instanceof Document?t&&(v.mostRecentlyFocusedNode=e.target):(e.stopImmediatePropagation(),m(v.mostRecentlyFocusedNode||y()))},E=function(e){if(!1!==b.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void l.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){g();var t=null;if(v.tabbableGroups.length>0){var n=c(v.tabbableGroups,(function(t){return t.container.contains(e.target)}));if(n<0)t=e.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var r=c(v.tabbableGroups,(function(t){var n=t.firstTabbableNode;return e.target===n}));if(r<0&&v.tabbableGroups[n].container===e.target&&(r=n),r>=0){var a=0===r?v.tabbableGroups.length-1:r-1;t=v.tabbableGroups[a].lastTabbableNode}}else{var o=c(v.tabbableGroups,(function(t){var n=t.lastTabbableNode;return e.target===n}));if(o<0&&v.tabbableGroups[n].container===e.target&&(o=n),o>=0){var i=o===v.tabbableGroups.length-1?0:o+1;t=v.tabbableGroups[i].firstTabbableNode}}}else t=h("fallbackFocus");t&&(e.preventDefault(),m(t))}(e)},k=function(e){u(b.clickOutsideDeactivates,e)||d(e.target)||u(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},D=function(){if(v.active)return o.activateTrap(l),e=b.delayInitialFocus?i((function(){m(y())})):m(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",k,{capture:!0,passive:!1}),f.addEventListener("keydown",E,{capture:!0,passive:!1}),l},T=function(){if(v.active)return f.removeEventListener("focusin",F,!0),f.removeEventListener("mousedown",w,!0),f.removeEventListener("touchstart",w,!0),f.removeEventListener("click",k,!0),f.removeEventListener("keydown",E,!0),l};return(l={activate:function(e){if(v.active)return this;var t=p(e,"onActivate"),n=p(e,"onPostActivate"),r=p(e,"checkCanFocusTrap");r||g(),v.active=!0,v.paused=!1,v.nodeFocusedBeforeActivation=f.activeElement,t&&t();var a=function(){r&&g(),D(),n&&n()};return r?(r(v.containers.concat()).then(a,a),this):(a(),this)},deactivate:function(t){if(!v.active)return this;clearTimeout(e),T(),v.active=!1,v.paused=!1,o.deactivateTrap(l);var n=p(t,"onDeactivate"),r=p(t,"onPostDeactivate"),a=p(t,"checkCanReturnFocus");n&&n();var c=p(t,"returnFocus","returnFocusOnDeactivate"),u=function(){i((function(){c&&m(O(v.nodeFocusedBeforeActivation)),r&&r()}))};return c&&a?(a(O(v.nodeFocusedBeforeActivation)).then(u,u),this):(u(),this)},pause:function(){return v.paused||!v.active||(v.paused=!0,T()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,g(),D(),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&&g(),this}}).updateContainerElements(a),l}; | ||
//# sourceMappingURL=focus-trap.min.js.map |
/*! | ||
* focus-trap 6.5.0 | ||
* focus-trap 6.5.1 | ||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE | ||
@@ -571,11 +571,11 @@ */ | ||
var finishDeactivation = function finishDeactivation() { | ||
if (returnFocus) { | ||
delay(function () { | ||
delay(function () { | ||
if (returnFocus) { | ||
tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)); | ||
} | ||
if (onPostDeactivate) { | ||
onPostDeactivate(); | ||
} | ||
}); | ||
} | ||
if (onPostDeactivate) { | ||
onPostDeactivate(); | ||
} | ||
}); | ||
}; | ||
@@ -582,0 +582,0 @@ |
/*! | ||
* focus-trap 6.5.0 | ||
* focus-trap 6.5.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 r,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};e.createFocusTrap=function(e,o){var l,f=document,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},o),v={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},p=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},d=function(e){return v.containers.some((function(t){return t.contains(e)}))},h=function(e){var t=b[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=f.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},y=function(){var e;if(null!==h("initialFocus"))e=h("initialFocus");else if(d(f.activeElement))e=f.activeElement;else{var t=v.tabbableGroups[0];e=t&&t.firstTabbableNode||h("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},g=function(){if(v.tabbableGroups=v.containers.map((function(e){var n=t.tabbable(e);if(n.length>0)return{container:e,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),v.tabbableGroups.length<=0&&!h("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},m=function e(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()))},O=function(e){var t=h("setReturnFocus");return t||e},w=function(e){d(e.target)||(s(b.clickOutsideDeactivates,e)?l.deactivate({returnFocus:b.returnFocusOnDeactivate&&!t.isFocusable(e.target)}):s(b.allowOutsideClick,e)||e.preventDefault())},F=function(e){var t=d(e.target);t||e.target instanceof Document?t&&(v.mostRecentlyFocusedNode=e.target):(e.stopImmediatePropagation(),m(v.mostRecentlyFocusedNode||y()))},E=function(e){if(!1!==b.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void l.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){g();var t=null;if(v.tabbableGroups.length>0){var n=u(v.tabbableGroups,(function(t){return t.container.contains(e.target)}));if(n<0)t=e.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var a=u(v.tabbableGroups,(function(t){var n=t.firstTabbableNode;return e.target===n}));if(a<0&&v.tabbableGroups[n].container===e.target&&(a=n),a>=0){var r=0===a?v.tabbableGroups.length-1:a-1;t=v.tabbableGroups[r].lastTabbableNode}}else{var o=u(v.tabbableGroups,(function(t){var n=t.lastTabbableNode;return e.target===n}));if(o<0&&v.tabbableGroups[n].container===e.target&&(o=n),o>=0){var i=o===v.tabbableGroups.length-1?0:o+1;t=v.tabbableGroups[i].firstTabbableNode}}}else t=h("fallbackFocus");t&&(e.preventDefault(),m(t))}(e)},T=function(e){s(b.clickOutsideDeactivates,e)||d(e.target)||s(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},k=function(){if(v.active)return i.activateTrap(l),r=b.delayInitialFocus?c((function(){m(y())})):m(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",T,{capture:!0,passive:!1}),f.addEventListener("keydown",E,{capture:!0,passive:!1}),l},D=function(){if(v.active)return f.removeEventListener("focusin",F,!0),f.removeEventListener("mousedown",w,!0),f.removeEventListener("touchstart",w,!0),f.removeEventListener("click",T,!0),f.removeEventListener("keydown",E,!0),l};return(l={activate:function(e){if(v.active)return this;var t=p(e,"onActivate"),n=p(e,"onPostActivate"),a=p(e,"checkCanFocusTrap");a||g(),v.active=!0,v.paused=!1,v.nodeFocusedBeforeActivation=f.activeElement,t&&t();var r=function(){a&&g(),k(),n&&n()};return a?(a(v.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!v.active)return this;clearTimeout(r),D(),v.active=!1,v.paused=!1,i.deactivateTrap(l);var t=p(e,"onDeactivate"),n=p(e,"onPostDeactivate"),a=p(e,"checkCanReturnFocus");t&&t();var o=p(e,"returnFocus","returnFocusOnDeactivate"),u=function(){o&&c((function(){m(O(v.nodeFocusedBeforeActivation)),n&&n()}))};return o&&a?(a(O(v.nodeFocusedBeforeActivation)).then(u,u),this):(u(),this)},pause:function(){return v.paused||!v.active||(v.paused=!0,D()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,g(),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&&g(),this}}).updateContainerElements(e),l},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tabbable")):"function"==typeof define&&define.amd?define(["exports","tabbable"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.focusTrap,a=e.focusTrap={};t(a,e.tabbable),a.noConflict=function(){return e.focusTrap=n,a}}())}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r,o,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};e.createFocusTrap=function(e,o){var l,f=document,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0},o),v={containers:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1},p=function(e,t,n){return e&&void 0!==e[t]?e[t]:b[n||t]},d=function(e){return v.containers.some((function(t){return t.contains(e)}))},h=function(e){var t=b[e];if(!t)return null;var n=t;if("string"==typeof t&&!(n=f.querySelector(t)))throw new Error("`".concat(e,"` refers to no known node"));if("function"==typeof t&&!(n=t()))throw new Error("`".concat(e,"` did not return a node"));return n},y=function(){var e;if(null!==h("initialFocus"))e=h("initialFocus");else if(d(f.activeElement))e=f.activeElement;else{var t=v.tabbableGroups[0];e=t&&t.firstTabbableNode||h("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},g=function(){if(v.tabbableGroups=v.containers.map((function(e){var n=t.tabbable(e);if(n.length>0)return{container:e,firstTabbableNode:n[0],lastTabbableNode:n[n.length-1]}})).filter((function(e){return!!e})),v.tabbableGroups.length<=0&&!h("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times")},m=function e(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()))},O=function(e){var t=h("setReturnFocus");return t||e},w=function(e){d(e.target)||(s(b.clickOutsideDeactivates,e)?l.deactivate({returnFocus:b.returnFocusOnDeactivate&&!t.isFocusable(e.target)}):s(b.allowOutsideClick,e)||e.preventDefault())},F=function(e){var t=d(e.target);t||e.target instanceof Document?t&&(v.mostRecentlyFocusedNode=e.target):(e.stopImmediatePropagation(),m(v.mostRecentlyFocusedNode||y()))},E=function(e){if(!1!==b.escapeDeactivates&&function(e){return"Escape"===e.key||"Esc"===e.key||27===e.keyCode}(e))return e.preventDefault(),void l.deactivate();(function(e){return"Tab"===e.key||9===e.keyCode})(e)&&function(e){g();var t=null;if(v.tabbableGroups.length>0){var n=u(v.tabbableGroups,(function(t){return t.container.contains(e.target)}));if(n<0)t=e.shiftKey?v.tabbableGroups[v.tabbableGroups.length-1].lastTabbableNode:v.tabbableGroups[0].firstTabbableNode;else if(e.shiftKey){var a=u(v.tabbableGroups,(function(t){var n=t.firstTabbableNode;return e.target===n}));if(a<0&&v.tabbableGroups[n].container===e.target&&(a=n),a>=0){var r=0===a?v.tabbableGroups.length-1:a-1;t=v.tabbableGroups[r].lastTabbableNode}}else{var o=u(v.tabbableGroups,(function(t){var n=t.lastTabbableNode;return e.target===n}));if(o<0&&v.tabbableGroups[n].container===e.target&&(o=n),o>=0){var i=o===v.tabbableGroups.length-1?0:o+1;t=v.tabbableGroups[i].firstTabbableNode}}}else t=h("fallbackFocus");t&&(e.preventDefault(),m(t))}(e)},T=function(e){s(b.clickOutsideDeactivates,e)||d(e.target)||s(b.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},k=function(){if(v.active)return i.activateTrap(l),r=b.delayInitialFocus?c((function(){m(y())})):m(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",T,{capture:!0,passive:!1}),f.addEventListener("keydown",E,{capture:!0,passive:!1}),l},D=function(){if(v.active)return f.removeEventListener("focusin",F,!0),f.removeEventListener("mousedown",w,!0),f.removeEventListener("touchstart",w,!0),f.removeEventListener("click",T,!0),f.removeEventListener("keydown",E,!0),l};return(l={activate:function(e){if(v.active)return this;var t=p(e,"onActivate"),n=p(e,"onPostActivate"),a=p(e,"checkCanFocusTrap");a||g(),v.active=!0,v.paused=!1,v.nodeFocusedBeforeActivation=f.activeElement,t&&t();var r=function(){a&&g(),k(),n&&n()};return a?(a(v.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!v.active)return this;clearTimeout(r),D(),v.active=!1,v.paused=!1,i.deactivateTrap(l);var t=p(e,"onDeactivate"),n=p(e,"onPostDeactivate"),a=p(e,"checkCanReturnFocus");t&&t();var o=p(e,"returnFocus","returnFocusOnDeactivate"),u=function(){c((function(){o&&m(O(v.nodeFocusedBeforeActivation)),n&&n()}))};return o&&a?(a(O(v.nodeFocusedBeforeActivation)).then(u,u),this):(u(),this)},pause:function(){return v.paused||!v.active||(v.paused=!0,D()),this},unpause:function(){return v.paused&&v.active?(v.paused=!1,g(),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&&g(),this}}).updateContainerElements(e),l},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=focus-trap.umd.min.js.map |
@@ -44,4 +44,5 @@ declare module 'focus-trap' { | ||
/** | ||
* A function that will be called **after** focus has been sent to the | ||
* trigger element upon deactivation. | ||
* A function that will be called after the trap is deactivated, after `onDeactivate`. | ||
* If `returnFocus` was set, it will be called **after** focus has been sent to the trigger | ||
* element upon deactivation; otherwise, it will be called after deactivation completes. | ||
*/ | ||
@@ -48,0 +49,0 @@ onPostDeactivate?: () => void |
14
index.js
@@ -549,10 +549,10 @@ import { tabbable, isFocusable } from 'tabbable'; | ||
const finishDeactivation = () => { | ||
if (returnFocus) { | ||
delay(() => { | ||
delay(() => { | ||
if (returnFocus) { | ||
tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)); | ||
if (onPostDeactivate) { | ||
onPostDeactivate(); | ||
} | ||
}); | ||
} | ||
} | ||
if (onPostDeactivate) { | ||
onPostDeactivate(); | ||
} | ||
}); | ||
}; | ||
@@ -559,0 +559,0 @@ |
{ | ||
"name": "focus-trap", | ||
"version": "6.5.0", | ||
"version": "6.5.1", | ||
"description": "Trap focus within a DOM node.", | ||
@@ -20,7 +20,7 @@ "main": "dist/focus-trap.js", | ||
"scripts": { | ||
"demo-bundle": "browserify demo/js/index.js -o demo/demo-bundle.js", | ||
"format": "prettier --write \"{*,src/**/*,test/**/*,demo/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\"", | ||
"format:check": "prettier --check \"{*,src/**/*,test/**/*,demo/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\"", | ||
"format:watch": "onchange \"{*,src/**/*,test/**/*,demo/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\" -- prettier --write {{changed}}", | ||
"lint": "eslint \"*.js\" \"demo/**/*.js\" \"cypress/**/*.js\"", | ||
"demo-bundle": "browserify docs/js/index.js -o docs/demo-bundle.js", | ||
"format": "prettier --write \"{*,src/**/*,test/**/*,docs/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\"", | ||
"format:check": "prettier --check \"{*,src/**/*,test/**/*,docs/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\"", | ||
"format:watch": "onchange \"{*,src/**/*,test/**/*,docs/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\" -- prettier --write {{changed}}", | ||
"lint": "eslint \"*.js\" \"docs/js/**/*.js\" \"cypress/**/*.js\"", | ||
"clean": "rm -rf ./dist", | ||
@@ -32,3 +32,3 @@ "compile:esm": "cross-env BUILD_ENV=esm BABEL_ENV=esm rollup -c", | ||
"build": "yarn clean && yarn compile", | ||
"start": "yarn compile:cjs && budo demo/js/index.js:demo-bundle.js --dir demo --live -- -t babelify", | ||
"start": "yarn compile:cjs && budo docs/js/index.js:demo-bundle.js --dir docs --live -- -t babelify", | ||
"test:types": "tsc index.d.ts", | ||
@@ -68,5 +68,5 @@ "test:unit": "echo \"No unit tests to run!\"", | ||
"devDependencies": { | ||
"@babel/cli": "^7.14.3", | ||
"@babel/core": "^7.14.3", | ||
"@babel/preset-env": "^7.14.4", | ||
"@babel/cli": "^7.14.5", | ||
"@babel/core": "^7.14.6", | ||
"@babel/preset-env": "^7.14.5", | ||
"@changesets/cli": "^2.16.0", | ||
@@ -85,15 +85,15 @@ "@rollup/plugin-babel": "^5.3.0", | ||
"cross-env": "^7.0.3", | ||
"cypress": "^7.4.0", | ||
"cypress": "^7.5.0", | ||
"cypress-plugin-tab": "^1.0.5", | ||
"eslint": "^7.27.0", | ||
"eslint": "^7.28.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-cypress": "^2.11.3", | ||
"onchange": "^7.1.0", | ||
"prettier": "^2.3.0", | ||
"rollup": "^2.50.5", | ||
"prettier": "^2.3.1", | ||
"rollup": "^2.51.2", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.1", | ||
"start-server-and-test": "^1.12.3", | ||
"start-server-and-test": "^1.12.5", | ||
"typescript": "^4.3.2" | ||
} | ||
} |
@@ -31,3 +31,3 @@ # 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) | ||
[Check out the demos.](http://focus-trap.github.io/focus-trap/demo/) | ||
[Check out the demos.](http://focus-trap.github.io/focus-trap/) | ||
@@ -90,3 +90,3 @@ For more advanced usage (e.g. focus traps within focus traps), you can also pause a focus trap's behavior without deactivating it entirely, then unpause at will. | ||
- **onDeactivate** `{() => void}`: A function that will be called **before** returning focus to the node that had focus prior to activation (or configured with the `setReturnFocus` option) upon deactivation. | ||
- **onPostDeactivate** `{() => void}`: A function that will be called **after** returning focus to the node that had focus prior to activation (or configured with the `setReturnFocus` option) upon deactivation. | ||
- **onPostDeactivate** `{() => void}`: A function that will be called after the trap is deactivated, after `onDeactivate`. If the `returnFocus` deactivation option was set, it will be called **after** returning focus to the node that had focus prior to activation (or configured with the `setReturnFocus` option) upon deactivation; otherwise, it will be called after deactivation completes. | ||
- **checkCanReturnFocus** `{(trigger: HTMLElement | SVGElement) => Promise<void>}`: An animated trigger button will have a small delay between when `onDeactivate` is called and when the focus is able to be sent back to the trigger. `checkCanReturnFocus` expects a promise to be returned. When that promise settles (resolves or rejects), focus will be sent to to the node that had focus prior to the activation of the trap (or the node configured in the `setReturnFocus` option). Due to the lack of Promise support, `checkCanReturnFocus` is not supported in IE unless you provide a Promise polyfill. | ||
@@ -176,3 +176,3 @@ - **initialFocus** `{HTMLElement | SVGElement | string | () => HTMLElement | SVGElement}`: By default, when a focus trap is activated the first element in the focus trap's tab order will receive focus. With this option you can specify a different element to receive that initial focus. Can be a DOM node, or a selector string (which will be passed to `document.querySelector()` to find the DOM node), or a function that returns a DOM node. | ||
Read code in `demo/` and [see how it works](http://focus-trap.github.io/focus-trap/demo/). | ||
Read code in `docs/` and [see how it works](http://focus-trap.github.io/focus-trap/). | ||
@@ -179,0 +179,0 @@ Here's what happens in `default.js` (the "default behavior" demo): |
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
321067
2278