@hsds/utils-focus
Advanced tools
Comparing version 5.2.1 to 7.0.0
@@ -5,4 +5,26 @@ # Changelog | ||
### [5.2.1](https://github.com/helpscout/hsds/compare/utils-focus-5.2.0...utils-focus-5.2.1) (2022-08-25) | ||
# [7.0.0](https://github.com/helpscout/hsds/compare/v6.0.0...v7.0.0) (2023-01-12) | ||
# [6.0.0](https://github.com/helpscout/hsds/compare/v5.0.0...v6.0.0) (2023-01-12) | ||
# [5.0.0](https://github.com/helpscout/hsds/compare/v4.0.0...v5.0.0) (2023-01-12) | ||
### Bug Fixes | ||
* **workspace:** remove esm module from projects ([829cc37](https://github.com/helpscout/hsds/commit/829cc3795f54a8bcfbc0c45b5bc36bd17463bf54)) | ||
### Features | ||
* **workspace:** improves versioning packages ([b836826](https://github.com/helpscout/hsds/commit/b836826d549aeb7295498f1091c783136079f134)) | ||
### [5.2.1](https://github.com/helpscout/hsds/compare/utils-focus-5.2.0...utils-focus-5.2.1) (2022-08-29) | ||
### Dependency Updates | ||
@@ -9,0 +31,0 @@ |
26
focus.js
@@ -7,8 +7,5 @@ "use strict"; | ||
exports.manageTrappedFocus = manageTrappedFocus; | ||
var _utilsDom = require("@hsds/utils-dom"); | ||
const FOCUSABLE_SELECTOR = 'a[href],frame,iframe,input:not([type=hidden]):not([disabled]),select,textarea,button:not([disabled]):not([tabindex="-1"]),*[tabindex]:not([tabindex="-1"])'; | ||
exports.FOCUSABLE_SELECTOR = FOCUSABLE_SELECTOR; | ||
const findFocusableNodes = nodeScope => { | ||
@@ -18,5 +15,3 @@ const scope = (0, _utilsDom.getNodeScope)(nodeScope); | ||
}; | ||
exports.findFocusableNodes = findFocusableNodes; | ||
const findFirstFocusableNode = nodeScope => { | ||
@@ -26,5 +21,3 @@ const focusableNodes = findFocusableNodes(nodeScope); | ||
}; | ||
exports.findFirstFocusableNode = findFirstFocusableNode; | ||
const findLastFocusableNode = nodeScope => { | ||
@@ -34,5 +27,3 @@ const focusableNodes = findFocusableNodes(nodeScope); | ||
}; | ||
exports.findLastFocusableNode = findLastFocusableNode; | ||
const findCurrentFocusedNodeIndex = (currentNode, nodeScope) => { | ||
@@ -44,5 +35,3 @@ if (!(0, _utilsDom.isNodeElement)(currentNode)) return; | ||
}; | ||
exports.findCurrentFocusedNodeIndex = findCurrentFocusedNodeIndex; | ||
const findNextFocusableNode = (currentNode, nodeScope) => { | ||
@@ -56,5 +45,3 @@ if (!(0, _utilsDom.isNodeElement)(currentNode)) return; | ||
}; | ||
exports.findNextFocusableNode = findNextFocusableNode; | ||
const findPreviousFocusableNode = (currentNode, nodeScope) => { | ||
@@ -68,5 +55,3 @@ if (!(0, _utilsDom.isNodeElement)(currentNode)) return; | ||
}; | ||
exports.findPreviousFocusableNode = findPreviousFocusableNode; | ||
const focusNextFocusableNode = (currentNode, nodeScope) => { | ||
@@ -78,5 +63,3 @@ const scope = (0, _utilsDom.getNodeScope)(nodeScope); | ||
}; | ||
exports.focusNextFocusableNode = focusNextFocusableNode; | ||
const focusPreviousFocusableNode = (currentNode, nodeScope) => { | ||
@@ -88,2 +71,3 @@ const scope = (0, _utilsDom.getNodeScope)(nodeScope); | ||
}; | ||
/** | ||
@@ -94,9 +78,7 @@ * Method that will find the closest parent that can is focusable | ||
*/ | ||
exports.focusPreviousFocusableNode = focusPreviousFocusableNode; | ||
function getClosestFocusableParent(element) { | ||
return element.closest(FOCUSABLE_SELECTOR) || document.body; | ||
} | ||
/** | ||
@@ -107,4 +89,2 @@ * Method that will ensure tabbing will cycle between focusable nodes inside a given container | ||
*/ | ||
function manageTrappedFocus(container, e) { | ||
@@ -114,3 +94,2 @@ const focusedNode = e.target; | ||
const focusableNodes = findFocusableNodes(container); | ||
if (focusableNodes != null) { | ||
@@ -120,3 +99,2 @@ const focusedNodeIndex = Array.prototype.indexOf.call(focusableNodes, focusedNode); | ||
const isLastNode = focusedNodeIndex === focusableNodes.length - 1; | ||
if (!e.shiftKey && isLastNode) { | ||
@@ -123,0 +101,0 @@ e.preventDefault(); |
{ | ||
"name": "@hsds/utils-focus", | ||
"version": "5.2.1", | ||
"main": "./index.cjs.js", | ||
"module": "./index.esm.js", | ||
"typings": "./index.d.ts", | ||
"version": "7.0.0", | ||
"main": "./index.cjs", | ||
"type": "commonjs", | ||
"types": "./index.d.ts", | ||
"dependencies": { | ||
"@hsds/utils-dom": "5.2.1" | ||
"@hsds/utils-dom": "7.0.0" | ||
}, | ||
"peerDependencies": {} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12024
0
+ Added@hsds/utils-dom@7.0.0(transitive)
- Removed@hsds/utils-dom@5.2.1(transitive)
Updated@hsds/utils-dom@7.0.0