focus-trap 8.0.0 → 8.0.1

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
+ ## 8.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7d5010e: Loosen checkCanFocusTrap Promise resolution type to `unknown` to make it easier to use `Promise.all()` or `Promise.allSettled()` as the returned Promise (`Promise<void>` was causing issues because those Promise APIs do not resolve with a `void` value).
8
+
3
9
  ## 8.0.0
4
10
 
5
11
  ### Major Changes
package/README.md CHANGED
@@ -144,11 +144,13 @@ Note that if [delayInitialFocus](#delayinitialfocus) is true, this handler will
144
144
  ##### checkCanFocusTrap
145
145
 
146
146
  ```typescript
147
- (containers: Array<HTMLElement | SVGElement>) => Promise<void>
147
+ (containers: Array<HTMLElement | SVGElement>) => Promise<unknown>
148
148
  ```
149
149
 
150
150
  Animated dialogs have a small delay between when `onActivate` is called and when the focus trap is focusable. `checkCanFocusTrap` expects a promise to be returned. When that promise settles (resolves or rejects), focus will be sent to the first tabbable node (in tab order) in the focus trap (or the node configured in the `initialFocus` option).
151
151
 
152
+ 🔺 It does not matter whether the Promise resolves or rejects, only that it settles. A rejected Promise will not result in cancellation of trap activation.
153
+
152
154
  ##### onDeactivate
153
155
 
154
156
  ```typescript
@@ -389,7 +391,7 @@ These options are used to override the focus trap's default behavior for this pa
389
391
 
390
392
  - **onActivate** `{() => void}`: Default: whatever you chose for `createOptions.onActivate`. `null` or `false` are the equivalent of a `noop`.
391
393
  - **onPostActivate** `{() => void}`: Default: whatever you chose for `createOptions.onPostActivate`. `null` or `false` are the equivalent of a `noop`.
392
- - **checkCanFocusTrap** `{(containers: Array<HTMLElement | SVGElement>) => Promise<void>}`: Default: whatever you chose for `createOptions.checkCanFocusTrap`.
394
+ - **checkCanFocusTrap** `{(containers: Array<HTMLElement | SVGElement>) => Promise<unknown>}`: Default: whatever you chose for `createOptions.checkCanFocusTrap`.
393
395
 
394
396
  ### trap.deactivate()
395
397
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 8.0.0
2
+ * focus-trap 8.0.1
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  import { isFocusable, tabbable, focusable, isTabbable, getTabIndex } from 'tabbable';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 8.0.0
2
+ * focus-trap 8.0.1
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  import{isFocusable as e,tabbable as t,focusable as n,isTabbable as r,getTabIndex as o}from"tabbable";function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function i(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,c,"next",e)}function c(e){i(a,r,o,u,c,"throw",e)}u(void 0)}))}}function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=p(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw a}}}}function s(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(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 d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function f(){
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 8.0.0
2
+ * focus-trap 8.0.1
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 8.0.0
2
+ * focus-trap 8.0.1
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
5
  "use strict";var e=require("tabbable");function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function r(e){return function(){var t=this,r=arguments;return new Promise((function(o,a){var i=e.apply(t,r);function u(e){n(i,o,a,u,c,"next",e)}function c(e){n(i,o,a,u,c,"throw",e)}u(void 0)}))}}function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=d(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw a}}}}function a(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(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 u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(){
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * focus-trap 8.0.0
2
+ * focus-trap 8.0.1
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 8.0.0
2
+ * focus-trap 8.0.1
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,r=e.focusTrap={};t(r,e.tabbable),r.noConflict=function(){return e.focusTrap=n,r}}())}(this,(function(e,t){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function r(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,a){var i=e.apply(t,n);function u(e){r(i,o,a,u,c,"next",e)}function c(e){r(i,o,a,u,c,"throw",e)}u(void 0)}))}}function a(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=f(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw a}}}}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(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 c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(){
package/index.d.ts CHANGED
@@ -71,13 +71,16 @@ declare module 'focus-trap' {
71
71
  * It should return a promise that only resolves once all the listed `containers`
72
72
  * are able to receive focus.
73
73
  *
74
- * The purpose of this is to prevent early focus-trap activation on animated
74
+ * This option exists to prevent early focus-trap activation on animated
75
75
  * dialogs that fade in and out. When a dialog fades in, there is a brief delay
76
76
  * between the activation of the trap and the trap element being focusable.
77
+ *
78
+ * 🔺 It does not matter whether the Promise resolves or rejects, only that it
79
+ * settles. A rejected Promise will not result in cancellation of trap activation.
77
80
  */
78
81
  checkCanFocusTrap?: (
79
82
  containers: Array<HTMLElement | SVGElement>
80
- ) => Promise<void>;
83
+ ) => Promise<unknown>;
81
84
 
82
85
  /**
83
86
  * A function that will be called **before** sending focus to the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "focus-trap",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Trap focus within a DOM node.",
5
5
  "main": "dist/focus-trap.js",
6
6
  "module": "dist/focus-trap.esm.js",
@@ -69,51 +69,51 @@
69
69
  },
70
70
  "devDependencies": {
71
71
  "@babel/cli": "^7.28.6",
72
- "@babel/core": "^7.28.6",
72
+ "@babel/core": "^7.29.0",
73
73
  "@babel/eslint-parser": "^7.28.6",
74
74
  "@babel/eslint-plugin": "^7.27.1",
75
- "@babel/preset-env": "^7.28.6",
76
- "@changesets/cli": "^2.29.8",
75
+ "@babel/preset-env": "^7.29.2",
76
+ "@changesets/cli": "^2.30.0",
77
77
  "@eslint/js": "^9.39.2",
78
- "@rollup/plugin-babel": "^6.1.0",
79
- "@rollup/plugin-commonjs": "^29.0.0",
78
+ "@rollup/plugin-babel": "^7.0.0",
79
+ "@rollup/plugin-commonjs": "^29.0.2",
80
80
  "@rollup/plugin-node-resolve": "^16.0.3",
81
81
  "@rollup/plugin-replace": "^6.0.3",
82
- "@rollup/plugin-terser": "^0.4.4",
82
+ "@rollup/plugin-terser": "^1.0.0",
83
83
  "@testing-library/cypress": "^10.1.0",
84
84
  "@testing-library/dom": "^10.4.1",
85
85
  "@testing-library/jest-dom": "^6.9.1",
86
86
  "@testing-library/user-event": "^14.6.1",
87
87
  "@types/jest": "^30.0.0",
88
- "@types/jquery": "^3.5.33",
89
- "@types/node": "^25.0.10",
90
- "@typescript-eslint/eslint-plugin": "^8.54.0",
91
- "@typescript-eslint/parser": "^8.53.1",
88
+ "@types/jquery": "^4.0.0",
89
+ "@types/node": "^25.5.0",
90
+ "@typescript-eslint/eslint-plugin": "^8.57.1",
91
+ "@typescript-eslint/parser": "^8.57.0",
92
92
  "all-contributors-cli": "^6.26.1",
93
- "babel-jest": "^30.1.2",
94
- "babel-loader": "^10.0.0",
93
+ "babel-jest": "^30.3.0",
94
+ "babel-loader": "^10.1.1",
95
95
  "cross-env": "^10.1.0",
96
- "cypress": "^15.9.0",
96
+ "cypress": "^15.12.0",
97
97
  "cypress-plugin-tab": "^1.0.5",
98
98
  "eslint": "^9.39.2",
99
99
  "eslint-config-prettier": "^10.1.8",
100
100
  "eslint-import-resolver-node": "^0.3.9",
101
101
  "eslint-import-resolver-typescript": "^4.4.4",
102
- "eslint-plugin-cypress": "^5.2.1",
102
+ "eslint-plugin-cypress": "^6.2.0",
103
103
  "eslint-plugin-import": "^2.32.0",
104
- "eslint-plugin-jest": "^29.12.1",
104
+ "eslint-plugin-jest": "^29.15.0",
105
105
  "eslint-plugin-jest-dom": "^5.5.0",
106
- "eslint-plugin-testing-library": "^7.15.4",
107
- "globals": "^17.2.0",
108
- "jest": "^30.2.0",
109
- "jest-environment-jsdom": "^30.2.0",
106
+ "eslint-plugin-testing-library": "^7.16.0",
107
+ "globals": "^17.4.0",
108
+ "jest": "^30.3.0",
109
+ "jest-environment-jsdom": "^30.3.0",
110
110
  "jest-watch-typeahead": "^3.0.1",
111
111
  "onchange": "^7.1.0",
112
112
  "prettier": "^3.8.1",
113
- "rollup": "^4.57.0",
113
+ "rollup": "^4.59.0",
114
114
  "rollup-plugin-livereload": "^2.0.5",
115
115
  "rollup-plugin-serve": "^3.0.0",
116
- "start-server-and-test": "^2.1.3",
116
+ "start-server-and-test": "^2.1.5",
117
117
  "typescript": "^5.9.3"
118
118
  }
119
119
  }