Socket
Socket
Sign inDemoInstall

focus-trap

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

focus-trap - npm Package Compare versions

Comparing version 7.5.2 to 7.5.3

6

CHANGELOG.md
# Changelog
## 7.5.3
### Patch Changes
- 203b322: Fix missing typings for initialFocus option ([#1060](https://github.com/focus-trap/focus-trap/issues/1060))
## 7.5.2

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

48

dist/focus-trap.esm.js
/*!
* focus-trap 7.5.2
* focus-trap 7.5.3
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -7,22 +7,22 @@ */

function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return keys;
return t;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return target;
return e;
}

@@ -822,3 +822,3 @@ function _defineProperty(obj, key, value) {

state.nodeFocusedBeforeActivation = doc.activeElement;
onActivate === null || onActivate === void 0 ? void 0 : onActivate();
onActivate === null || onActivate === void 0 || onActivate();
var finishActivation = function finishActivation() {

@@ -830,3 +830,3 @@ if (checkCanFocusTrap) {

updateObservedNodes();
onPostActivate === null || onPostActivate === void 0 ? void 0 : onPostActivate();
onPostActivate === null || onPostActivate === void 0 || onPostActivate();
};

@@ -860,3 +860,3 @@ if (checkCanFocusTrap) {

var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
onDeactivate === null || onDeactivate === void 0 ? void 0 : onDeactivate();
onDeactivate === null || onDeactivate === void 0 || onDeactivate();
var finishDeactivation = function finishDeactivation() {

@@ -867,3 +867,3 @@ delay(function () {

}
onPostDeactivate === null || onPostDeactivate === void 0 ? void 0 : onPostDeactivate();
onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
});

@@ -885,6 +885,6 @@ };

state.paused = true;
onPause === null || onPause === void 0 ? void 0 : onPause();
onPause === null || onPause === void 0 || onPause();
removeListeners();
updateObservedNodes();
onPostPause === null || onPostPause === void 0 ? void 0 : onPostPause();
onPostPause === null || onPostPause === void 0 || onPostPause();
return this;

@@ -899,7 +899,7 @@ },

state.paused = false;
onUnpause === null || onUnpause === void 0 ? void 0 : onUnpause();
onUnpause === null || onUnpause === void 0 || onUnpause();
updateTabbableNodes();
addListeners();
updateObservedNodes();
onPostUnpause === null || onPostUnpause === void 0 ? void 0 : onPostUnpause();
onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
return this;

@@ -906,0 +906,0 @@ },

/*!
* focus-trap 7.5.2
* focus-trap 7.5.3
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -4,0 +4,0 @@ */

/*!
* focus-trap 7.5.2
* focus-trap 7.5.3
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -11,22 +11,22 @@ */

function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return keys;
return t;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return target;
return e;
}

@@ -826,3 +826,3 @@ function _defineProperty(obj, key, value) {

state.nodeFocusedBeforeActivation = doc.activeElement;
onActivate === null || onActivate === void 0 ? void 0 : onActivate();
onActivate === null || onActivate === void 0 || onActivate();
var finishActivation = function finishActivation() {

@@ -834,3 +834,3 @@ if (checkCanFocusTrap) {

updateObservedNodes();
onPostActivate === null || onPostActivate === void 0 ? void 0 : onPostActivate();
onPostActivate === null || onPostActivate === void 0 || onPostActivate();
};

@@ -864,3 +864,3 @@ if (checkCanFocusTrap) {

var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
onDeactivate === null || onDeactivate === void 0 ? void 0 : onDeactivate();
onDeactivate === null || onDeactivate === void 0 || onDeactivate();
var finishDeactivation = function finishDeactivation() {

@@ -871,3 +871,3 @@ delay(function () {

}
onPostDeactivate === null || onPostDeactivate === void 0 ? void 0 : onPostDeactivate();
onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
});

@@ -889,6 +889,6 @@ };

state.paused = true;
onPause === null || onPause === void 0 ? void 0 : onPause();
onPause === null || onPause === void 0 || onPause();
removeListeners();
updateObservedNodes();
onPostPause === null || onPostPause === void 0 ? void 0 : onPostPause();
onPostPause === null || onPostPause === void 0 || onPostPause();
return this;

@@ -903,7 +903,7 @@ },

state.paused = false;
onUnpause === null || onUnpause === void 0 ? void 0 : onUnpause();
onUnpause === null || onUnpause === void 0 || onUnpause();
updateTabbableNodes();
addListeners();
updateObservedNodes();
onPostUnpause === null || onPostUnpause === void 0 ? void 0 : onPostUnpause();
onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
return this;

@@ -910,0 +910,0 @@ },

/*!
* focus-trap 7.5.2
* focus-trap 7.5.3
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -4,0 +4,0 @@ */

/*!
* focus-trap 7.5.2
* focus-trap 7.5.3
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -16,22 +16,22 @@ */

function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return keys;
return t;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return target;
return e;
}

@@ -831,3 +831,3 @@ function _defineProperty(obj, key, value) {

state.nodeFocusedBeforeActivation = doc.activeElement;
onActivate === null || onActivate === void 0 ? void 0 : onActivate();
onActivate === null || onActivate === void 0 || onActivate();
var finishActivation = function finishActivation() {

@@ -839,3 +839,3 @@ if (checkCanFocusTrap) {

updateObservedNodes();
onPostActivate === null || onPostActivate === void 0 ? void 0 : onPostActivate();
onPostActivate === null || onPostActivate === void 0 || onPostActivate();
};

@@ -869,3 +869,3 @@ if (checkCanFocusTrap) {

var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
onDeactivate === null || onDeactivate === void 0 ? void 0 : onDeactivate();
onDeactivate === null || onDeactivate === void 0 || onDeactivate();
var finishDeactivation = function finishDeactivation() {

@@ -876,3 +876,3 @@ delay(function () {

}
onPostDeactivate === null || onPostDeactivate === void 0 ? void 0 : onPostDeactivate();
onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
});

@@ -894,6 +894,6 @@ };

state.paused = true;
onPause === null || onPause === void 0 ? void 0 : onPause();
onPause === null || onPause === void 0 || onPause();
removeListeners();
updateObservedNodes();
onPostPause === null || onPostPause === void 0 ? void 0 : onPostPause();
onPostPause === null || onPostPause === void 0 || onPostPause();
return this;

@@ -908,7 +908,7 @@ },

state.paused = false;
onUnpause === null || onUnpause === void 0 ? void 0 : onUnpause();
onUnpause === null || onUnpause === void 0 || onUnpause();
updateTabbableNodes();
addListeners();
updateObservedNodes();
onPostUnpause === null || onPostUnpause === void 0 ? void 0 : onPostUnpause();
onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
return this;

@@ -915,0 +915,0 @@ },

/*!
* focus-trap 7.5.2
* focus-trap 7.5.3
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE

@@ -4,0 +4,0 @@ */

@@ -117,4 +117,7 @@ import { CheckOptions as TabbableCheckOptions } from 'tabbable';

* will prevent the `fallbackFocus` option from being used.
*
* Setting this option to `undefined` (or a function that returns `undefined`)
* will result in the default behavior.
*/
initialFocus?: FocusTargetOrFalse;
initialFocus?: FocusTargetOrFalse | undefined | (() => void);
/**

@@ -121,0 +124,0 @@ * By default, an error will be thrown if the focus trap contains no

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

@@ -69,24 +69,24 @@ "main": "dist/focus-trap.js",

"devDependencies": {
"@babel/cli": "^7.22.5",
"@babel/core": "^7.22.5",
"@babel/eslint-parser": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/cli": "^7.22.15",
"@babel/core": "^7.22.20",
"@babel/eslint-parser": "^7.22.15",
"@babel/preset-env": "^7.22.20",
"@changesets/cli": "^2.26.2",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-terser": "^0.4.3",
"@testing-library/cypress": "^9.0.0",
"@types/jquery": "^3.5.16",
"all-contributors-cli": "^6.26.0",
"babel-loader": "^9.1.2",
"@testing-library/cypress": "^10.0.1",
"@types/jquery": "^3.5.19",
"all-contributors-cli": "^6.26.1",
"babel-loader": "^9.1.3",
"cross-env": "^7.0.3",
"cypress": "^12.16.0",
"cypress": "^13.2.0",
"cypress-plugin-tab": "^1.0.5",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-cypress": "^2.13.3",
"eslint-plugin-jest": "^27.2.2",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-jest": "^27.4.0",
"onchange": "^7.1.0",
"prettier": "^2.8.8",
"prettier": "^3.0.3",
"rollup": "^2.79.1",

@@ -98,4 +98,4 @@ "rollup-plugin-inject-process-env": "^1.3.1",

"start-server-and-test": "^2.0.0",
"typescript": "^5.1.5"
"typescript": "^5.2.2"
}
}

@@ -104,4 +104,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)

- **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).
- **initialFocus** `{HTMLElement | SVGElement | string | false | (() => HTMLElement | SVGElement | string | false)}`: 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 any of these. You can also set this option to `false` (or to a function that returns `false`) to prevent any initial focus at all when the trap activates.
- **initialFocus** `{HTMLElement | SVGElement | string | false | undefined | (() => HTMLElement | SVGElement | string | false | undefined)}`: 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 any of these. You can also set this option to `false` (or to a function that returns `false`) to prevent any initial focus at all when the trap activates.
- ๐Ÿ’ฌ Setting this option to `false` (or a function that returns `false`) will prevent the `fallbackFocus` option from being used.
- Returning `undefined` from a function will result in the default behavior.
- โš ๏ธ See warning below about **Shadow DOM** and selector strings.

@@ -108,0 +109,0 @@ - **fallbackFocus** `{HTMLElement | SVGElement | string | () => HTMLElement | SVGElement | string}`: By default, an error will be thrown if the focus trap contains no elements in its tab order. With this option you can specify a fallback element to programmatically receive focus if no other tabbable elements are found. For example, you may want a popover's `<div>` to receive focus if the popover's content includes no tabbable elements. *Make sure the fallback element has a negative `tabindex` so it can be programmatically focused.* The option value can be a DOM node, a selector string (which will be passed to `document.querySelector()` to find the DOM node), or a function that returns any of these.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc