- Updated all component headers and documentation
- Changed navbar and footer branding
- Updated homepage hero badge
- Modified page title in index.html
- Simplified footer text to 'Built with ❤️'
- Consistent V2 capitalization across all references
72 lines
3.1 KiB
JavaScript
72 lines
3.1 KiB
JavaScript
import { FOCUS_NO_AUTOFOCUS } from '../constants';
|
|
var isElementHidden = function (node) {
|
|
// we can measure only "elements"
|
|
// consider others as "visible"
|
|
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
return false;
|
|
}
|
|
var computedStyle = window.getComputedStyle(node, null);
|
|
if (!computedStyle || !computedStyle.getPropertyValue) {
|
|
return false;
|
|
}
|
|
return (computedStyle.getPropertyValue('display') === 'none' || computedStyle.getPropertyValue('visibility') === 'hidden');
|
|
};
|
|
var getParentNode = function (node) {
|
|
// DOCUMENT_FRAGMENT_NODE can also point on ShadowRoot. In this case .host will point on the next node
|
|
return node.parentNode && node.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE
|
|
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
node.parentNode.host
|
|
: node.parentNode;
|
|
};
|
|
var isTopNode = function (node) {
|
|
// @ts-ignore
|
|
return node === document || (node && node.nodeType === Node.DOCUMENT_NODE);
|
|
};
|
|
var isInert = function (node) { return node.hasAttribute('inert'); };
|
|
/**
|
|
* @see https://github.com/testing-library/jest-dom/blob/main/src/to-be-visible.js
|
|
*/
|
|
var isVisibleUncached = function (node, checkParent) {
|
|
return !node || isTopNode(node) || (!isElementHidden(node) && !isInert(node) && checkParent(getParentNode(node)));
|
|
};
|
|
export var isVisibleCached = function (visibilityCache, node) {
|
|
var cached = visibilityCache.get(node);
|
|
if (cached !== undefined) {
|
|
return cached;
|
|
}
|
|
var result = isVisibleUncached(node, isVisibleCached.bind(undefined, visibilityCache));
|
|
visibilityCache.set(node, result);
|
|
return result;
|
|
};
|
|
var isAutoFocusAllowedUncached = function (node, checkParent) {
|
|
return node && !isTopNode(node) ? (isAutoFocusAllowed(node) ? checkParent(getParentNode(node)) : false) : true;
|
|
};
|
|
export var isAutoFocusAllowedCached = function (cache, node) {
|
|
var cached = cache.get(node);
|
|
if (cached !== undefined) {
|
|
return cached;
|
|
}
|
|
var result = isAutoFocusAllowedUncached(node, isAutoFocusAllowedCached.bind(undefined, cache));
|
|
cache.set(node, result);
|
|
return result;
|
|
};
|
|
export var getDataset = function (node) {
|
|
// @ts-ignore
|
|
return node.dataset;
|
|
};
|
|
export var isHTMLButtonElement = function (node) { return node.tagName === 'BUTTON'; };
|
|
export var isHTMLInputElement = function (node) { return node.tagName === 'INPUT'; };
|
|
export var isRadioElement = function (node) {
|
|
return isHTMLInputElement(node) && node.type === 'radio';
|
|
};
|
|
export var notHiddenInput = function (node) {
|
|
return !((isHTMLInputElement(node) || isHTMLButtonElement(node)) && (node.type === 'hidden' || node.disabled));
|
|
};
|
|
export var isAutoFocusAllowed = function (node) {
|
|
var attribute = node.getAttribute(FOCUS_NO_AUTOFOCUS);
|
|
return ![true, 'true', ''].includes(attribute);
|
|
};
|
|
export var isGuard = function (node) { var _a; return Boolean(node && ((_a = getDataset(node)) === null || _a === void 0 ? void 0 : _a.focusGuard)); };
|
|
export var isNotAGuard = function (node) { return !isGuard(node); };
|
|
export var isDefined = function (x) { return Boolean(x); };
|