Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@elvia/elvis-toolbox

Package Overview
Dependencies
Maintainers
7
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elvia/elvis-toolbox - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

12

CHANGELOG.json

@@ -6,2 +6,14 @@ {

"date": "28.09.22",
"version": "4.0.1",
"changelog": [
{
"type": "bug_fix",
"changes": [
"Fixed a bug that caused the <span class=\"code-text\">useFocusTrap</span> hook to not work properly when a custom element was passed as content in the <span class=\"code-text\">elvia-modal</span> component."
]
}
]
},
{
"date": "28.09.22",
"version": "4.0.0",

@@ -8,0 +20,0 @@ "changelog": [

73

dist/hooks/useFocusTrap.js

@@ -5,44 +5,47 @@ "use strict";

const useFocusTrap = (focusTrapContainer, removeEventListener) => {
if (!focusTrapContainer.current) {
return;
}
const focusableItems = Array.from(focusTrapContainer.current.querySelectorAll('a[href], button, textarea, input, select, details, [tabindex]:not([tabindex="-1"]')).filter((element) => {
return (!element.hasAttribute('disabled') &&
!element.hasAttribute('aria-hidden') &&
element.getAttribute('tabindex') !== '-1');
});
const firstItem = focusableItems[0];
const lastItem = focusableItems[focusableItems.length - 1];
const handleFirstItemTab = (e) => {
if (e.key === 'Tab' && e.shiftKey) {
if (lastItem) {
lastItem.focus();
}
e.preventDefault();
setTimeout(() => {
if (!focusTrapContainer.current) {
return;
}
};
const handleLastItemTab = (e) => {
if (e.key === 'Tab' && !e.shiftKey) {
if (firstItem) {
firstItem.focus();
const focusableItems = Array.from(focusTrapContainer.current.querySelectorAll('a[href], button, textarea, input, select, details, [tabindex]:not([tabindex="-1"]')).filter((element) => {
var _a;
return (!element.hasAttribute('disabled') &&
element.getAttribute('aria-hidden') !== 'true' &&
parseInt((_a = element.getAttribute('tabindex')) !== null && _a !== void 0 ? _a : '0') >= 0);
});
const firstItem = focusableItems[0];
const lastItem = focusableItems[focusableItems.length - 1];
const handleFirstItemTab = (e) => {
if (e.key === 'Tab' && e.shiftKey) {
if (lastItem) {
lastItem.focus();
}
e.preventDefault();
}
e.preventDefault();
}
};
if (firstItem) {
firstItem.focus();
firstItem.addEventListener('keydown', handleFirstItemTab);
}
if (lastItem) {
lastItem.addEventListener('keydown', handleLastItemTab);
}
if (removeEventListener) {
};
const handleLastItemTab = (e) => {
if (e.key === 'Tab' && !e.shiftKey) {
if (firstItem) {
firstItem.focus();
}
e.preventDefault();
}
};
if (firstItem) {
firstItem.removeEventListener('keydown', handleFirstItemTab);
firstItem.focus();
firstItem.addEventListener('keydown', handleFirstItemTab);
}
if (lastItem) {
lastItem.removeEventListener('keydown', handleLastItemTab);
lastItem.addEventListener('keydown', handleLastItemTab);
}
}
if (removeEventListener) {
if (firstItem) {
firstItem.removeEventListener('keydown', handleFirstItemTab);
}
if (lastItem) {
lastItem.removeEventListener('keydown', handleLastItemTab);
}
}
});
};
exports.useFocusTrap = useFocusTrap;
{
"name": "@elvia/elvis-toolbox",
"version": "4.0.0",
"version": "4.0.1",
"description": "",

@@ -5,0 +5,0 @@ "license": "MIT",

# Toolbox

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

@@ -0,0 +0,0 @@ import { Dispatch, RefObject, SetStateAction, useEffect, useState } from 'react';

@@ -7,52 +7,54 @@ import { RefObject } from 'react';

): void => {
if (!focusTrapContainer.current) {
return;
}
const focusableItems = Array.from(
focusTrapContainer.current.querySelectorAll(
'a[href], button, textarea, input, select, details, [tabindex]:not([tabindex="-1"]',
),
).filter((element) => {
return (
!element.hasAttribute('disabled') &&
!element.hasAttribute('aria-hidden') &&
element.getAttribute('tabindex') !== '-1'
);
});
setTimeout(() => {
if (!focusTrapContainer.current) {
return;
}
const focusableItems = Array.from(
focusTrapContainer.current.querySelectorAll(
'a[href], button, textarea, input, select, details, [tabindex]:not([tabindex="-1"]',
),
).filter((element) => {
return (
!element.hasAttribute('disabled') &&
element.getAttribute('aria-hidden') !== 'true' &&
parseInt(element.getAttribute('tabindex') ?? '0') >= 0
);
});
const firstItem = focusableItems[0];
const lastItem = focusableItems[focusableItems.length - 1];
const firstItem = focusableItems[0];
const lastItem = focusableItems[focusableItems.length - 1];
const handleFirstItemTab = (e: KeyboardEvent) => {
if (e.key === 'Tab' && e.shiftKey) {
if (lastItem) {
(lastItem as HTMLElement).focus();
const handleFirstItemTab = (e: KeyboardEvent) => {
if (e.key === 'Tab' && e.shiftKey) {
if (lastItem) {
(lastItem as HTMLElement).focus();
}
e.preventDefault();
}
e.preventDefault();
}
};
const handleLastItemTab = (e: KeyboardEvent) => {
if (e.key === 'Tab' && !e.shiftKey) {
if (firstItem) {
(firstItem as HTMLElement).focus();
};
const handleLastItemTab = (e: KeyboardEvent) => {
if (e.key === 'Tab' && !e.shiftKey) {
if (firstItem) {
(firstItem as HTMLElement).focus();
}
e.preventDefault();
}
e.preventDefault();
}
};
if (firstItem) {
(firstItem as HTMLElement).focus();
firstItem.addEventListener('keydown', handleFirstItemTab);
}
if (lastItem) {
lastItem.addEventListener('keydown', handleLastItemTab);
}
if (removeEventListener) {
};
if (firstItem) {
firstItem.removeEventListener('keydown', handleFirstItemTab);
(firstItem as HTMLElement).focus();
firstItem.addEventListener('keydown', handleFirstItemTab);
}
if (lastItem) {
lastItem.removeEventListener('keydown', handleLastItemTab);
lastItem.addEventListener('keydown', handleLastItemTab);
}
}
if (removeEventListener) {
if (firstItem) {
firstItem.removeEventListener('keydown', handleFirstItemTab);
}
if (lastItem) {
lastItem.removeEventListener('keydown', handleLastItemTab);
}
}
});
};

@@ -0,0 +0,0 @@ import { RefObject, useEffect, useState } from 'react';

@@ -0,0 +0,0 @@ export * from './elvis-toolbox';

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