@chakra-ui/dom-utils
Advanced tools
Comparing version 2.0.6 to 2.1.0
export { FocusableElement, hasDisplayNone, hasFocusWithin, hasNegativeTabIndex, hasTabIndex, isActiveElement, isContentEditable, isDisabled, isFocusable, isHidden, isInputElement, isTabbable } from './tabbable.js'; | ||
export { contains, getActiveElement, getEventWindow, getOwnerDocument, getOwnerWindow, isBrowser, isElement, isHTMLElement } from './dom.js'; | ||
export { getScrollParent } from './scroll.js'; | ||
@@ -4,0 +5,0 @@ declare function getAllFocusable<T extends HTMLElement>(container: T): T[]; |
@@ -35,2 +35,3 @@ "use strict"; | ||
getPreviousTabbable: () => getPreviousTabbable, | ||
getScrollParent: () => getScrollParent, | ||
hasDisplayNone: () => hasDisplayNone, | ||
@@ -141,2 +142,23 @@ hasFocusWithin: () => hasFocusWithin, | ||
// src/scroll.ts | ||
function isScrollParent(el) { | ||
const win = el.ownerDocument.defaultView || window; | ||
const { overflow, overflowX, overflowY } = win.getComputedStyle(el); | ||
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); | ||
} | ||
function getParent(el) { | ||
if (el.localName === "html") | ||
return el; | ||
return el.assignedSlot || el.parentElement || el.ownerDocument.documentElement; | ||
} | ||
function getScrollParent(el) { | ||
if (["html", "body", "#document"].includes(el.localName)) { | ||
return el.ownerDocument.body; | ||
} | ||
if (isHTMLElement(el) && isScrollParent(el)) { | ||
return el; | ||
} | ||
return getScrollParent(getParent(el)); | ||
} | ||
// src/index.ts | ||
@@ -219,2 +241,3 @@ var focusableElList = [ | ||
getPreviousTabbable, | ||
getScrollParent, | ||
hasDisplayNone, | ||
@@ -221,0 +244,0 @@ hasFocusWithin, |
{ | ||
"name": "@chakra-ui/dom-utils", | ||
"version": "2.0.6", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"clean-package": "2.1.1" | ||
"clean-package": "2.2.0" | ||
}, | ||
@@ -31,0 +31,0 @@ "clean-package": "../../../clean-package.config.json", |
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
30708
18
845