Last
Some checks are pending
Deploy Volleyball CMS / deploy (push) Waiting to run

This commit is contained in:
2025-06-02 18:56:22 +02:00
parent 8f62885a45
commit 33181acf83
1443 changed files with 286102 additions and 12 deletions

44
node_modules/@react-aria/focus/dist/FocusRing.main.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
var $581a96d6eb128c1b$exports = require("./useFocusRing.main.js");
var $hE1Ku$clsx = require("clsx");
var $hE1Ku$reactariautils = require("@react-aria/utils");
var $hE1Ku$react = require("react");
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "FocusRing", () => $dfd8c70b928eb1b3$export$1a38b4ad7f578e1d);
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $dfd8c70b928eb1b3$export$1a38b4ad7f578e1d(props) {
let { children: children, focusClass: focusClass, focusRingClass: focusRingClass } = props;
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $581a96d6eb128c1b$exports.useFocusRing)(props);
let child = (0, ($parcel$interopDefault($hE1Ku$react))).Children.only(children);
return /*#__PURE__*/ (0, ($parcel$interopDefault($hE1Ku$react))).cloneElement(child, (0, $hE1Ku$reactariautils.mergeProps)(child.props, {
...focusProps,
className: (0, ($parcel$interopDefault($hE1Ku$clsx)))({
[focusClass || '']: isFocused,
[focusRingClass || '']: isFocusVisible
})
}));
}
//# sourceMappingURL=FocusRing.main.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAgCM,SAAS,0CAAU,KAAqB;IAC7C,IAAI,YAAC,QAAQ,cAAE,UAAU,kBAAE,cAAc,EAAC,GAAG;IAC7C,IAAI,aAAC,SAAS,kBAAE,cAAc,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,sCAAW,EAAE;IAC3D,IAAI,QAAQ,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IAEhC,qBAAO,CAAA,GAAA,sCAAI,EAAE,YAAY,CAAC,OAAO,CAAA,GAAA,gCAAS,EAAE,MAAM,KAAK,EAAS;QAC9D,GAAG,UAAU;QACb,WAAW,CAAA,GAAA,qCAAG,EAAE;YACd,CAAC,cAAc,GAAG,EAAE;YACpB,CAAC,kBAAkB,GAAG,EAAE;QAC1B;IACF;AACF","sources":["packages/@react-aria/focus/src/FocusRing.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport clsx from 'clsx';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {ReactElement} from 'react';\nimport {useFocusRing} from './useFocusRing';\n\nexport interface FocusRingProps {\n /** Child element to apply CSS classes to. */\n children: ReactElement,\n /** CSS class to apply when the element is focused. */\n focusClass?: string,\n /** CSS class to apply when the element has keyboard focus. */\n focusRingClass?: string,\n /**\n * Whether to show the focus ring when something\n * inside the container element has focus (true), or\n * only if the container itself has focus (false).\n * @default false\n */\n within?: boolean,\n /** Whether the element is a text input. */\n isTextInput?: boolean,\n /** Whether the element will be auto focused. */\n autoFocus?: boolean\n}\n\n/**\n * A utility component that applies a CSS class when an element has keyboard focus.\n * Focus rings are visible only when the user is interacting with a keyboard,\n * not with a mouse, touch, or other input methods.\n */\nexport function FocusRing(props: FocusRingProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>> {\n let {children, focusClass, focusRingClass} = props;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing(props);\n let child = React.Children.only(children);\n\n return React.cloneElement(child, mergeProps(child.props as any, {\n ...focusProps,\n className: clsx({\n [focusClass || '']: isFocused,\n [focusRingClass || '']: isFocusVisible\n })\n }));\n}\n"],"names":[],"version":3,"file":"FocusRing.main.js.map"}

35
node_modules/@react-aria/focus/dist/FocusRing.mjs generated vendored Normal file
View File

@@ -0,0 +1,35 @@
import {useFocusRing as $f7dceffc5ad7768b$export$4e328f61c538687f} from "./useFocusRing.mjs";
import $hAmeg$clsx from "clsx";
import {mergeProps as $hAmeg$mergeProps} from "@react-aria/utils";
import $hAmeg$react from "react";
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $907718708eab68af$export$1a38b4ad7f578e1d(props) {
let { children: children, focusClass: focusClass, focusRingClass: focusRingClass } = props;
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $f7dceffc5ad7768b$export$4e328f61c538687f)(props);
let child = (0, $hAmeg$react).Children.only(children);
return /*#__PURE__*/ (0, $hAmeg$react).cloneElement(child, (0, $hAmeg$mergeProps)(child.props, {
...focusProps,
className: (0, $hAmeg$clsx)({
[focusClass || '']: isFocused,
[focusRingClass || '']: isFocusVisible
})
}));
}
export {$907718708eab68af$export$1a38b4ad7f578e1d as FocusRing};
//# sourceMappingURL=FocusRing.module.js.map

View File

@@ -0,0 +1,35 @@
import {useFocusRing as $f7dceffc5ad7768b$export$4e328f61c538687f} from "./useFocusRing.module.js";
import $hAmeg$clsx from "clsx";
import {mergeProps as $hAmeg$mergeProps} from "@react-aria/utils";
import $hAmeg$react from "react";
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $907718708eab68af$export$1a38b4ad7f578e1d(props) {
let { children: children, focusClass: focusClass, focusRingClass: focusRingClass } = props;
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $f7dceffc5ad7768b$export$4e328f61c538687f)(props);
let child = (0, $hAmeg$react).Children.only(children);
return /*#__PURE__*/ (0, $hAmeg$react).cloneElement(child, (0, $hAmeg$mergeProps)(child.props, {
...focusProps,
className: (0, $hAmeg$clsx)({
[focusClass || '']: isFocused,
[focusRingClass || '']: isFocusVisible
})
}));
}
export {$907718708eab68af$export$1a38b4ad7f578e1d as FocusRing};
//# sourceMappingURL=FocusRing.module.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAgCM,SAAS,0CAAU,KAAqB;IAC7C,IAAI,YAAC,QAAQ,cAAE,UAAU,kBAAE,cAAc,EAAC,GAAG;IAC7C,IAAI,aAAC,SAAS,kBAAE,cAAc,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,yCAAW,EAAE;IAC3D,IAAI,QAAQ,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IAEhC,qBAAO,CAAA,GAAA,YAAI,EAAE,YAAY,CAAC,OAAO,CAAA,GAAA,iBAAS,EAAE,MAAM,KAAK,EAAS;QAC9D,GAAG,UAAU;QACb,WAAW,CAAA,GAAA,WAAG,EAAE;YACd,CAAC,cAAc,GAAG,EAAE;YACpB,CAAC,kBAAkB,GAAG,EAAE;QAC1B;IACF;AACF","sources":["packages/@react-aria/focus/src/FocusRing.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport clsx from 'clsx';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {ReactElement} from 'react';\nimport {useFocusRing} from './useFocusRing';\n\nexport interface FocusRingProps {\n /** Child element to apply CSS classes to. */\n children: ReactElement,\n /** CSS class to apply when the element is focused. */\n focusClass?: string,\n /** CSS class to apply when the element has keyboard focus. */\n focusRingClass?: string,\n /**\n * Whether to show the focus ring when something\n * inside the container element has focus (true), or\n * only if the container itself has focus (false).\n * @default false\n */\n within?: boolean,\n /** Whether the element is a text input. */\n isTextInput?: boolean,\n /** Whether the element will be auto focused. */\n autoFocus?: boolean\n}\n\n/**\n * A utility component that applies a CSS class when an element has keyboard focus.\n * Focus rings are visible only when the user is interacting with a keyboard,\n * not with a mouse, touch, or other input methods.\n */\nexport function FocusRing(props: FocusRingProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>> {\n let {children, focusClass, focusRingClass} = props;\n let {isFocused, isFocusVisible, focusProps} = useFocusRing(props);\n let child = React.Children.only(children);\n\n return React.cloneElement(child, mergeProps(child.props as any, {\n ...focusProps,\n className: clsx({\n [focusClass || '']: isFocused,\n [focusRingClass || '']: isFocusVisible\n })\n }));\n}\n"],"names":[],"version":3,"file":"FocusRing.module.js.map"}

739
node_modules/@react-aria/focus/dist/FocusScope.main.js generated vendored Normal file
View File

@@ -0,0 +1,739 @@
var $d5156037ad898a4d$exports = require("./isElementVisible.main.js");
var $euGna$reactariautils = require("@react-aria/utils");
var $euGna$reactariainteractions = require("@react-aria/interactions");
var $euGna$react = require("react");
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "FocusScope", () => $a7a032acae3ddda9$export$20e40289641fbbb6);
$parcel$export(module.exports, "useFocusManager", () => $a7a032acae3ddda9$export$10c5169755ce7bd7);
$parcel$export(module.exports, "getFocusableTreeWalker", () => $a7a032acae3ddda9$export$2d6ec8fc375ceafa);
$parcel$export(module.exports, "isElementInChildOfActiveScope", () => $a7a032acae3ddda9$export$1258395f99bf9cbf);
$parcel$export(module.exports, "createFocusManager", () => $a7a032acae3ddda9$export$c5251b9e124bf29);
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
const $a7a032acae3ddda9$var$FocusContext = /*#__PURE__*/ (0, ($parcel$interopDefault($euGna$react))).createContext(null);
const $a7a032acae3ddda9$var$RESTORE_FOCUS_EVENT = 'react-aria-focus-scope-restore';
let $a7a032acae3ddda9$var$activeScope = null;
function $a7a032acae3ddda9$export$20e40289641fbbb6(props) {
let { children: children, contain: contain, restoreFocus: restoreFocus, autoFocus: autoFocus } = props;
let startRef = (0, $euGna$react.useRef)(null);
let endRef = (0, $euGna$react.useRef)(null);
let scopeRef = (0, $euGna$react.useRef)([]);
let { parentNode: parentNode } = (0, $euGna$react.useContext)($a7a032acae3ddda9$var$FocusContext) || {};
// Create a tree node here so we can add children to it even before it is added to the tree.
let node = (0, $euGna$react.useMemo)(()=>new $a7a032acae3ddda9$var$TreeNode({
scopeRef: scopeRef
}), [
scopeRef
]);
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
// If a new scope mounts outside the active scope, (e.g. DialogContainer launched from a menu),
// use the active scope as the parent instead of the parent from context. Layout effects run bottom
// up, so if the parent is not yet added to the tree, don't do this. Only the outer-most FocusScope
// that is being added should get the activeScope as its parent.
let parent = parentNode || $a7a032acae3ddda9$export$d06fae2ee68b101e.root;
if ($a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(parent.scopeRef) && $a7a032acae3ddda9$var$activeScope && !$a7a032acae3ddda9$var$isAncestorScope($a7a032acae3ddda9$var$activeScope, parent.scopeRef)) {
let activeNode = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode($a7a032acae3ddda9$var$activeScope);
if (activeNode) parent = activeNode;
}
// Add the node to the parent, and to the tree.
parent.addChild(node);
$a7a032acae3ddda9$export$d06fae2ee68b101e.addNode(node);
}, [
node,
parentNode
]);
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
let node = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (node) node.contain = !!contain;
}, [
contain
]);
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
var _startRef_current;
// Find all rendered nodes between the sentinels and add them to the scope.
let node = (_startRef_current = startRef.current) === null || _startRef_current === void 0 ? void 0 : _startRef_current.nextSibling;
let nodes = [];
let stopPropagation = (e)=>e.stopPropagation();
while(node && node !== endRef.current){
nodes.push(node);
// Stop custom restore focus event from propagating to parent focus scopes.
node.addEventListener($a7a032acae3ddda9$var$RESTORE_FOCUS_EVENT, stopPropagation);
node = node.nextSibling;
}
scopeRef.current = nodes;
return ()=>{
for (let node of nodes)node.removeEventListener($a7a032acae3ddda9$var$RESTORE_FOCUS_EVENT, stopPropagation);
};
}, [
children
]);
$a7a032acae3ddda9$var$useActiveScopeTracker(scopeRef, restoreFocus, contain);
$a7a032acae3ddda9$var$useFocusContainment(scopeRef, contain);
$a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain);
$a7a032acae3ddda9$var$useAutoFocus(scopeRef, autoFocus);
// This needs to be an effect so that activeScope is updated after the FocusScope tree is complete.
// It cannot be a useLayoutEffect because the parent of this node hasn't been attached in the tree yet.
(0, $euGna$react.useEffect)(()=>{
const activeElement = (0, $euGna$reactariautils.getActiveElement)((0, $euGna$reactariautils.getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined));
let scope = null;
if ($a7a032acae3ddda9$var$isElementInScope(activeElement, scopeRef.current)) {
// We need to traverse the focusScope tree and find the bottom most scope that
// contains the active element and set that as the activeScope.
for (let node of $a7a032acae3ddda9$export$d06fae2ee68b101e.traverse())if (node.scopeRef && $a7a032acae3ddda9$var$isElementInScope(activeElement, node.scopeRef.current)) scope = node;
if (scope === $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef)) $a7a032acae3ddda9$var$activeScope = scope.scopeRef;
}
}, [
scopeRef
]);
// This layout effect cleanup is so that the tree node is removed synchronously with react before the RAF
// in useRestoreFocus cleanup runs.
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
return ()=>{
var _focusScopeTree_getTreeNode_parent, _focusScopeTree_getTreeNode;
var _focusScopeTree_getTreeNode_parent_scopeRef;
// Scope may have been re-parented.
let parentScope = (_focusScopeTree_getTreeNode_parent_scopeRef = (_focusScopeTree_getTreeNode = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : (_focusScopeTree_getTreeNode_parent = _focusScopeTree_getTreeNode.parent) === null || _focusScopeTree_getTreeNode_parent === void 0 ? void 0 : _focusScopeTree_getTreeNode_parent.scopeRef) !== null && _focusScopeTree_getTreeNode_parent_scopeRef !== void 0 ? _focusScopeTree_getTreeNode_parent_scopeRef : null;
if ((scopeRef === $a7a032acae3ddda9$var$activeScope || $a7a032acae3ddda9$var$isAncestorScope(scopeRef, $a7a032acae3ddda9$var$activeScope)) && (!parentScope || $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(parentScope))) $a7a032acae3ddda9$var$activeScope = parentScope;
$a7a032acae3ddda9$export$d06fae2ee68b101e.removeTreeNode(scopeRef);
};
}, [
scopeRef
]);
let focusManager = (0, $euGna$react.useMemo)(()=>$a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef), []);
let value = (0, $euGna$react.useMemo)(()=>({
focusManager: focusManager,
parentNode: node
}), [
node,
focusManager
]);
return /*#__PURE__*/ (0, ($parcel$interopDefault($euGna$react))).createElement($a7a032acae3ddda9$var$FocusContext.Provider, {
value: value
}, /*#__PURE__*/ (0, ($parcel$interopDefault($euGna$react))).createElement("span", {
"data-focus-scope-start": true,
hidden: true,
ref: startRef
}), children, /*#__PURE__*/ (0, ($parcel$interopDefault($euGna$react))).createElement("span", {
"data-focus-scope-end": true,
hidden: true,
ref: endRef
}));
}
function $a7a032acae3ddda9$export$10c5169755ce7bd7() {
var _useContext;
return (_useContext = (0, $euGna$react.useContext)($a7a032acae3ddda9$var$FocusContext)) === null || _useContext === void 0 ? void 0 : _useContext.focusManager;
}
function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
return {
focusNext (opts = {}) {
let scope = scopeRef.current;
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
var _scope_;
let node = from || (0, $euGna$reactariautils.getActiveElement)((0, $euGna$reactariautils.getOwnerDocument)((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : undefined));
let sentinel = scope[0].previousElementSibling;
let scopeRoot = $a7a032acae3ddda9$var$getScopeRoot(scope);
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = $a7a032acae3ddda9$var$isElementInScope(node, scope) ? node : sentinel;
let nextNode = walker.nextNode();
if (!nextNode && wrap) {
walker.currentNode = sentinel;
nextNode = walker.nextNode();
}
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
return nextNode;
},
focusPrevious (opts = {}) {
let scope = scopeRef.current;
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
var _scope_;
let node = from || (0, $euGna$reactariautils.getActiveElement)((0, $euGna$reactariautils.getOwnerDocument)((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : undefined));
let sentinel = scope[scope.length - 1].nextElementSibling;
let scopeRoot = $a7a032acae3ddda9$var$getScopeRoot(scope);
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = $a7a032acae3ddda9$var$isElementInScope(node, scope) ? node : sentinel;
let previousNode = walker.previousNode();
if (!previousNode && wrap) {
walker.currentNode = sentinel;
previousNode = walker.previousNode();
}
if (previousNode) $a7a032acae3ddda9$var$focusElement(previousNode, true);
return previousNode;
},
focusFirst (opts = {}) {
let scope = scopeRef.current;
let { tabbable: tabbable, accept: accept } = opts;
let scopeRoot = $a7a032acae3ddda9$var$getScopeRoot(scope);
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = scope[0].previousElementSibling;
let nextNode = walker.nextNode();
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
return nextNode;
},
focusLast (opts = {}) {
let scope = scopeRef.current;
let { tabbable: tabbable, accept: accept } = opts;
let scopeRoot = $a7a032acae3ddda9$var$getScopeRoot(scope);
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = scope[scope.length - 1].nextElementSibling;
let previousNode = walker.previousNode();
if (previousNode) $a7a032acae3ddda9$var$focusElement(previousNode, true);
return previousNode;
}
};
}
function $a7a032acae3ddda9$var$getScopeRoot(scope) {
return scope[0].parentElement;
}
function $a7a032acae3ddda9$var$shouldContainFocus(scopeRef) {
let scope = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode($a7a032acae3ddda9$var$activeScope);
while(scope && scope.scopeRef !== scopeRef){
if (scope.contain) return false;
scope = scope.parent;
}
return true;
}
function $a7a032acae3ddda9$var$useFocusContainment(scopeRef, contain) {
let focusedNode = (0, $euGna$react.useRef)(undefined);
let raf = (0, $euGna$react.useRef)(undefined);
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
let scope = scopeRef.current;
if (!contain) {
// if contain was changed, then we should cancel any ongoing waits to pull focus back into containment
if (raf.current) {
cancelAnimationFrame(raf.current);
raf.current = undefined;
}
return;
}
const ownerDocument = (0, $euGna$reactariautils.getOwnerDocument)(scope ? scope[0] : undefined);
// Handle the Tab key to contain focus within the scope
let onKeyDown = (e)=>{
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !$a7a032acae3ddda9$var$shouldContainFocus(scopeRef) || e.isComposing) return;
let focusedElement = (0, $euGna$reactariautils.getActiveElement)(ownerDocument);
let scope = scopeRef.current;
if (!scope || !$a7a032acae3ddda9$var$isElementInScope(focusedElement, scope)) return;
let scopeRoot = $a7a032acae3ddda9$var$getScopeRoot(scope);
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: true
}, scope);
if (!focusedElement) return;
walker.currentNode = focusedElement;
let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
if (!nextElement) {
walker.currentNode = e.shiftKey ? scope[scope.length - 1].nextElementSibling : scope[0].previousElementSibling;
nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
}
e.preventDefault();
if (nextElement) $a7a032acae3ddda9$var$focusElement(nextElement, true);
};
let onFocus = (e)=>{
// If focusing an element in a child scope of the currently active scope, the child becomes active.
// Moving out of the active scope to an ancestor is not allowed.
if ((!$a7a032acae3ddda9$var$activeScope || $a7a032acae3ddda9$var$isAncestorScope($a7a032acae3ddda9$var$activeScope, scopeRef)) && $a7a032acae3ddda9$var$isElementInScope((0, $euGna$reactariautils.getEventTarget)(e), scopeRef.current)) {
$a7a032acae3ddda9$var$activeScope = scopeRef;
focusedNode.current = (0, $euGna$reactariautils.getEventTarget)(e);
} else if ($a7a032acae3ddda9$var$shouldContainFocus(scopeRef) && !$a7a032acae3ddda9$var$isElementInChildScope((0, $euGna$reactariautils.getEventTarget)(e), scopeRef)) {
// If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),
// restore focus to the previously focused node or the first tabbable element in the active scope.
if (focusedNode.current) focusedNode.current.focus();
else if ($a7a032acae3ddda9$var$activeScope && $a7a032acae3ddda9$var$activeScope.current) $a7a032acae3ddda9$var$focusFirstInScope($a7a032acae3ddda9$var$activeScope.current);
} else if ($a7a032acae3ddda9$var$shouldContainFocus(scopeRef)) focusedNode.current = (0, $euGna$reactariautils.getEventTarget)(e);
};
let onBlur = (e)=>{
// Firefox doesn't shift focus back to the Dialog properly without this
if (raf.current) cancelAnimationFrame(raf.current);
raf.current = requestAnimationFrame(()=>{
// Patches infinite focus coersion loop for Android Talkback where the user isn't able to move the virtual cursor
// if within a containing focus scope. Bug filed against Chrome: https://issuetracker.google.com/issues/384844019.
// Note that this means focus can leave focus containing modals due to this, but it is isolated to Chrome Talkback.
let modality = (0, $euGna$reactariainteractions.getInteractionModality)();
let shouldSkipFocusRestore = (modality === 'virtual' || modality === null) && (0, $euGna$reactariautils.isAndroid)() && (0, $euGna$reactariautils.isChrome)();
// Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe
let activeElement = (0, $euGna$reactariautils.getActiveElement)(ownerDocument);
if (!shouldSkipFocusRestore && activeElement && $a7a032acae3ddda9$var$shouldContainFocus(scopeRef) && !$a7a032acae3ddda9$var$isElementInChildScope(activeElement, scopeRef)) {
$a7a032acae3ddda9$var$activeScope = scopeRef;
let target = (0, $euGna$reactariautils.getEventTarget)(e);
if (target && target.isConnected) {
var _focusedNode_current;
focusedNode.current = target;
(_focusedNode_current = focusedNode.current) === null || _focusedNode_current === void 0 ? void 0 : _focusedNode_current.focus();
} else if ($a7a032acae3ddda9$var$activeScope.current) $a7a032acae3ddda9$var$focusFirstInScope($a7a032acae3ddda9$var$activeScope.current);
}
});
};
ownerDocument.addEventListener('keydown', onKeyDown, false);
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusout', onBlur, false));
return ()=>{
ownerDocument.removeEventListener('keydown', onKeyDown, false);
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusout', onBlur, false));
};
}, [
scopeRef,
contain
]);
// This is a useLayoutEffect so it is guaranteed to run before our async synthetic blur
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
return ()=>{
if (raf.current) cancelAnimationFrame(raf.current);
};
}, [
raf
]);
}
function $a7a032acae3ddda9$var$isElementInAnyScope(element) {
return $a7a032acae3ddda9$var$isElementInChildScope(element);
}
function $a7a032acae3ddda9$var$isElementInScope(element, scope) {
if (!element) return false;
if (!scope) return false;
return scope.some((node)=>node.contains(element));
}
function $a7a032acae3ddda9$var$isElementInChildScope(element, scope = null) {
// If the element is within a top layer element (e.g. toasts), always allow moving focus there.
if (element instanceof Element && element.closest('[data-react-aria-top-layer]')) return true;
// node.contains in isElementInScope covers child scopes that are also DOM children,
// but does not cover child scopes in portals.
for (let { scopeRef: s } of $a7a032acae3ddda9$export$d06fae2ee68b101e.traverse($a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scope))){
if (s && $a7a032acae3ddda9$var$isElementInScope(element, s.current)) return true;
}
return false;
}
function $a7a032acae3ddda9$export$1258395f99bf9cbf(element) {
return $a7a032acae3ddda9$var$isElementInChildScope(element, $a7a032acae3ddda9$var$activeScope);
}
function $a7a032acae3ddda9$var$isAncestorScope(ancestor, scope) {
var _focusScopeTree_getTreeNode;
let parent = (_focusScopeTree_getTreeNode = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scope)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : _focusScopeTree_getTreeNode.parent;
while(parent){
if (parent.scopeRef === ancestor) return true;
parent = parent.parent;
}
return false;
}
function $a7a032acae3ddda9$var$focusElement(element, scroll = false) {
if (element != null && !scroll) try {
(0, $euGna$reactariainteractions.focusSafely)(element);
} catch {
// ignore
}
else if (element != null) try {
element.focus();
} catch {
// ignore
}
}
function $a7a032acae3ddda9$var$getFirstInScope(scope, tabbable = true) {
let sentinel = scope[0].previousElementSibling;
let scopeRoot = $a7a032acae3ddda9$var$getScopeRoot(scope);
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable
}, scope);
walker.currentNode = sentinel;
let nextNode = walker.nextNode();
// If the scope does not contain a tabbable element, use the first focusable element.
if (tabbable && !nextNode) {
scopeRoot = $a7a032acae3ddda9$var$getScopeRoot(scope);
walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: false
}, scope);
walker.currentNode = sentinel;
nextNode = walker.nextNode();
}
return nextNode;
}
function $a7a032acae3ddda9$var$focusFirstInScope(scope, tabbable = true) {
$a7a032acae3ddda9$var$focusElement($a7a032acae3ddda9$var$getFirstInScope(scope, tabbable));
}
function $a7a032acae3ddda9$var$useAutoFocus(scopeRef, autoFocus) {
const autoFocusRef = (0, ($parcel$interopDefault($euGna$react))).useRef(autoFocus);
(0, $euGna$react.useEffect)(()=>{
if (autoFocusRef.current) {
$a7a032acae3ddda9$var$activeScope = scopeRef;
const ownerDocument = (0, $euGna$reactariautils.getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!$a7a032acae3ddda9$var$isElementInScope((0, $euGna$reactariautils.getActiveElement)(ownerDocument), $a7a032acae3ddda9$var$activeScope.current) && scopeRef.current) $a7a032acae3ddda9$var$focusFirstInScope(scopeRef.current);
}
autoFocusRef.current = false;
}, [
scopeRef
]);
}
function $a7a032acae3ddda9$var$useActiveScopeTracker(scopeRef, restore, contain) {
// tracks the active scope, in case restore and contain are both false.
// if either are true, this is tracked in useRestoreFocus or useFocusContainment.
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
if (restore || contain) return;
let scope = scopeRef.current;
const ownerDocument = (0, $euGna$reactariautils.getOwnerDocument)(scope ? scope[0] : undefined);
let onFocus = (e)=>{
let target = (0, $euGna$reactariautils.getEventTarget)(e);
if ($a7a032acae3ddda9$var$isElementInScope(target, scopeRef.current)) $a7a032acae3ddda9$var$activeScope = scopeRef;
else if (!$a7a032acae3ddda9$var$isElementInAnyScope(target)) $a7a032acae3ddda9$var$activeScope = null;
};
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
return ()=>{
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
};
}, [
scopeRef,
restore,
contain
]);
}
function $a7a032acae3ddda9$var$shouldRestoreFocus(scopeRef) {
let scope = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode($a7a032acae3ddda9$var$activeScope);
while(scope && scope.scopeRef !== scopeRef){
if (scope.nodeToRestore) return false;
scope = scope.parent;
}
return (scope === null || scope === void 0 ? void 0 : scope.scopeRef) === scopeRef;
}
function $a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
// create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.
// eslint-disable-next-line no-restricted-globals
const nodeToRestoreRef = (0, $euGna$react.useRef)(typeof document !== 'undefined' ? (0, $euGna$reactariautils.getActiveElement)((0, $euGna$reactariautils.getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined)) : null);
// restoring scopes should all track if they are active regardless of contain, but contain already tracks it plus logic to contain the focus
// restoring-non-containing scopes should only care if they become active so they can perform the restore
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
let scope = scopeRef.current;
const ownerDocument = (0, $euGna$reactariautils.getOwnerDocument)(scope ? scope[0] : undefined);
if (!restoreFocus || contain) return;
let onFocus = ()=>{
// If focusing an element in a child scope of the currently active scope, the child becomes active.
// Moving out of the active scope to an ancestor is not allowed.
if ((!$a7a032acae3ddda9$var$activeScope || $a7a032acae3ddda9$var$isAncestorScope($a7a032acae3ddda9$var$activeScope, scopeRef)) && $a7a032acae3ddda9$var$isElementInScope((0, $euGna$reactariautils.getActiveElement)(ownerDocument), scopeRef.current)) $a7a032acae3ddda9$var$activeScope = scopeRef;
};
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
return ()=>{
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
scopeRef,
contain
]);
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
const ownerDocument = (0, $euGna$reactariautils.getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!restoreFocus) return;
// Handle the Tab key so that tabbing out of the scope goes to the next element
// after the node that had focus when the scope mounted. This is important when
// using portals for overlays, so that focus goes to the expected element when
// tabbing out of the overlay.
let onKeyDown = (e)=>{
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !$a7a032acae3ddda9$var$shouldContainFocus(scopeRef) || e.isComposing) return;
let focusedElement = ownerDocument.activeElement;
if (!$a7a032acae3ddda9$var$isElementInChildScope(focusedElement, scopeRef) || !$a7a032acae3ddda9$var$shouldRestoreFocus(scopeRef)) return;
let treeNode = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
let nodeToRestore = treeNode.nodeToRestore;
// Create a DOM tree walker that matches all tabbable elements
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(ownerDocument.body, {
tabbable: true
});
// Find the next tabbable element after the currently focused element
walker.currentNode = focusedElement;
let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
if (!nodeToRestore || !nodeToRestore.isConnected || nodeToRestore === ownerDocument.body) {
nodeToRestore = undefined;
treeNode.nodeToRestore = undefined;
}
// If there is no next element, or it is outside the current scope, move focus to the
// next element after the node to restore to instead.
if ((!nextElement || !$a7a032acae3ddda9$var$isElementInChildScope(nextElement, scopeRef)) && nodeToRestore) {
walker.currentNode = nodeToRestore;
// Skip over elements within the scope, in case the scope immediately follows the node to restore.
do nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
while ($a7a032acae3ddda9$var$isElementInChildScope(nextElement, scopeRef));
e.preventDefault();
e.stopPropagation();
if (nextElement) $a7a032acae3ddda9$var$focusElement(nextElement, true);
else // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)
// then move focus to the body.
// Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)
if (!$a7a032acae3ddda9$var$isElementInAnyScope(nodeToRestore)) focusedElement.blur();
else $a7a032acae3ddda9$var$focusElement(nodeToRestore, true);
}
};
if (!contain) ownerDocument.addEventListener('keydown', onKeyDown, true);
return ()=>{
if (!contain) ownerDocument.removeEventListener('keydown', onKeyDown, true);
};
}, [
scopeRef,
restoreFocus,
contain
]);
// useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.
(0, $euGna$reactariautils.useLayoutEffect)(()=>{
const ownerDocument = (0, $euGna$reactariautils.getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!restoreFocus) return;
let treeNode = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
var _nodeToRestoreRef_current;
treeNode.nodeToRestore = (_nodeToRestoreRef_current = nodeToRestoreRef.current) !== null && _nodeToRestoreRef_current !== void 0 ? _nodeToRestoreRef_current : undefined;
return ()=>{
let treeNode = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
let nodeToRestore = treeNode.nodeToRestore;
// if we already lost focus to the body and this was the active scope, then we should attempt to restore
let activeElement = (0, $euGna$reactariautils.getActiveElement)(ownerDocument);
if (restoreFocus && nodeToRestore && (activeElement && $a7a032acae3ddda9$var$isElementInChildScope(activeElement, scopeRef) || activeElement === ownerDocument.body && $a7a032acae3ddda9$var$shouldRestoreFocus(scopeRef))) {
// freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it
let clonedTree = $a7a032acae3ddda9$export$d06fae2ee68b101e.clone();
requestAnimationFrame(()=>{
// Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere
if (ownerDocument.activeElement === ownerDocument.body) {
// look up the tree starting with our scope to find a nodeToRestore still in the DOM
let treeNode = clonedTree.getTreeNode(scopeRef);
while(treeNode){
if (treeNode.nodeToRestore && treeNode.nodeToRestore.isConnected) {
$a7a032acae3ddda9$var$restoreFocusToElement(treeNode.nodeToRestore);
return;
}
treeNode = treeNode.parent;
}
// If no nodeToRestore was found, focus the first element in the nearest
// ancestor scope that is still in the tree.
treeNode = clonedTree.getTreeNode(scopeRef);
while(treeNode){
if (treeNode.scopeRef && treeNode.scopeRef.current && $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(treeNode.scopeRef)) {
let node = $a7a032acae3ddda9$var$getFirstInScope(treeNode.scopeRef.current, true);
$a7a032acae3ddda9$var$restoreFocusToElement(node);
return;
}
treeNode = treeNode.parent;
}
}
});
}
};
}, [
scopeRef,
restoreFocus
]);
}
function $a7a032acae3ddda9$var$restoreFocusToElement(node) {
// Dispatch a custom event that parent elements can intercept to customize focus restoration.
// For example, virtualized collection components reuse DOM elements, so the original element
// might still exist in the DOM but representing a different item.
if (node.dispatchEvent(new CustomEvent($a7a032acae3ddda9$var$RESTORE_FOCUS_EVENT, {
bubbles: true,
cancelable: true
}))) $a7a032acae3ddda9$var$focusElement(node);
}
function $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, opts, scope) {
let filter = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? (0, $euGna$reactariautils.isTabbable) : (0, $euGna$reactariautils.isFocusable);
// Ensure that root is an Element or fall back appropriately
let rootElement = (root === null || root === void 0 ? void 0 : root.nodeType) === Node.ELEMENT_NODE ? root : null;
// Determine the document to use
let doc = (0, $euGna$reactariautils.getOwnerDocument)(rootElement);
// Create a TreeWalker, ensuring the root is an Element or Document
let walker = (0, $euGna$reactariautils.createShadowTreeWalker)(doc, root || doc, NodeFilter.SHOW_ELEMENT, {
acceptNode (node) {
var _opts_from;
// Skip nodes inside the starting node.
if (opts === null || opts === void 0 ? void 0 : (_opts_from = opts.from) === null || _opts_from === void 0 ? void 0 : _opts_from.contains(node)) return NodeFilter.FILTER_REJECT;
if (filter(node) && (0, $d5156037ad898a4d$exports.isElementVisible)(node) && (!scope || $a7a032acae3ddda9$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node))) return NodeFilter.FILTER_ACCEPT;
return NodeFilter.FILTER_SKIP;
}
});
if (opts === null || opts === void 0 ? void 0 : opts.from) walker.currentNode = opts.from;
return walker;
}
function $a7a032acae3ddda9$export$c5251b9e124bf29(ref, defaultOptions = {}) {
return {
focusNext (opts = {}) {
let root = ref.current;
if (!root) return null;
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
let node = from || (0, $euGna$reactariautils.getActiveElement)((0, $euGna$reactariautils.getOwnerDocument)(root));
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
if (root.contains(node)) walker.currentNode = node;
let nextNode = walker.nextNode();
if (!nextNode && wrap) {
walker.currentNode = root;
nextNode = walker.nextNode();
}
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
return nextNode;
},
focusPrevious (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
let node = from || (0, $euGna$reactariautils.getActiveElement)((0, $euGna$reactariautils.getOwnerDocument)(root));
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
if (root.contains(node)) walker.currentNode = node;
else {
let next = $a7a032acae3ddda9$var$last(walker);
if (next) $a7a032acae3ddda9$var$focusElement(next, true);
return next !== null && next !== void 0 ? next : null;
}
let previousNode = walker.previousNode();
if (!previousNode && wrap) {
walker.currentNode = root;
let lastNode = $a7a032acae3ddda9$var$last(walker);
if (!lastNode) // couldn't wrap
return null;
previousNode = lastNode;
}
if (previousNode) $a7a032acae3ddda9$var$focusElement(previousNode, true);
return previousNode !== null && previousNode !== void 0 ? previousNode : null;
},
focusFirst (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
let nextNode = walker.nextNode();
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
return nextNode;
},
focusLast (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
let next = $a7a032acae3ddda9$var$last(walker);
if (next) $a7a032acae3ddda9$var$focusElement(next, true);
return next !== null && next !== void 0 ? next : null;
}
};
}
function $a7a032acae3ddda9$var$last(walker) {
let next = undefined;
let last;
do {
last = walker.lastChild();
if (last) next = last;
}while (last);
return next;
}
class $a7a032acae3ddda9$var$Tree {
get size() {
return this.fastMap.size;
}
getTreeNode(data) {
return this.fastMap.get(data);
}
addTreeNode(scopeRef, parent, nodeToRestore) {
let parentNode = this.fastMap.get(parent !== null && parent !== void 0 ? parent : null);
if (!parentNode) return;
let node = new $a7a032acae3ddda9$var$TreeNode({
scopeRef: scopeRef
});
parentNode.addChild(node);
node.parent = parentNode;
this.fastMap.set(scopeRef, node);
if (nodeToRestore) node.nodeToRestore = nodeToRestore;
}
addNode(node) {
this.fastMap.set(node.scopeRef, node);
}
removeTreeNode(scopeRef) {
// never remove the root
if (scopeRef === null) return;
let node = this.fastMap.get(scopeRef);
if (!node) return;
let parentNode = node.parent;
// when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing
// if we are, then replace the siblings restore with the restore from the scope we're removing
for (let current of this.traverse())if (current !== node && node.nodeToRestore && current.nodeToRestore && node.scopeRef && node.scopeRef.current && $a7a032acae3ddda9$var$isElementInScope(current.nodeToRestore, node.scopeRef.current)) current.nodeToRestore = node.nodeToRestore;
let children = node.children;
if (parentNode) {
parentNode.removeChild(node);
if (children.size > 0) children.forEach((child)=>parentNode && parentNode.addChild(child));
}
this.fastMap.delete(node.scopeRef);
}
// Pre Order Depth First
*traverse(node = this.root) {
if (node.scopeRef != null) yield node;
if (node.children.size > 0) for (let child of node.children)yield* this.traverse(child);
}
clone() {
var _node_parent;
let newTree = new $a7a032acae3ddda9$var$Tree();
var _node_parent_scopeRef;
for (let node of this.traverse())newTree.addTreeNode(node.scopeRef, (_node_parent_scopeRef = (_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.scopeRef) !== null && _node_parent_scopeRef !== void 0 ? _node_parent_scopeRef : null, node.nodeToRestore);
return newTree;
}
constructor(){
this.fastMap = new Map();
this.root = new $a7a032acae3ddda9$var$TreeNode({
scopeRef: null
});
this.fastMap.set(null, this.root);
}
}
class $a7a032acae3ddda9$var$TreeNode {
addChild(node) {
this.children.add(node);
node.parent = this;
}
removeChild(node) {
this.children.delete(node);
node.parent = undefined;
}
constructor(props){
this.children = new Set();
this.contain = false;
this.scopeRef = props.scopeRef;
}
}
let $a7a032acae3ddda9$export$d06fae2ee68b101e = new $a7a032acae3ddda9$var$Tree();
//# sourceMappingURL=FocusScope.main.js.map

File diff suppressed because one or more lines are too long

726
node_modules/@react-aria/focus/dist/FocusScope.mjs generated vendored Normal file
View File

@@ -0,0 +1,726 @@
import {isElementVisible as $645f2e67b85a24c9$export$e989c0fffaa6b27a} from "./isElementVisible.mjs";
import {useLayoutEffect as $cgawC$useLayoutEffect, getActiveElement as $cgawC$getActiveElement, getOwnerDocument as $cgawC$getOwnerDocument, getEventTarget as $cgawC$getEventTarget, isAndroid as $cgawC$isAndroid, isChrome as $cgawC$isChrome, isTabbable as $cgawC$isTabbable, isFocusable as $cgawC$isFocusable, createShadowTreeWalker as $cgawC$createShadowTreeWalker} from "@react-aria/utils";
import {getInteractionModality as $cgawC$getInteractionModality, focusSafely as $cgawC$focusSafely} from "@react-aria/interactions";
import $cgawC$react, {useRef as $cgawC$useRef, useContext as $cgawC$useContext, useMemo as $cgawC$useMemo, useEffect as $cgawC$useEffect} from "react";
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
const $9bf71ea28793e738$var$FocusContext = /*#__PURE__*/ (0, $cgawC$react).createContext(null);
const $9bf71ea28793e738$var$RESTORE_FOCUS_EVENT = 'react-aria-focus-scope-restore';
let $9bf71ea28793e738$var$activeScope = null;
function $9bf71ea28793e738$export$20e40289641fbbb6(props) {
let { children: children, contain: contain, restoreFocus: restoreFocus, autoFocus: autoFocus } = props;
let startRef = (0, $cgawC$useRef)(null);
let endRef = (0, $cgawC$useRef)(null);
let scopeRef = (0, $cgawC$useRef)([]);
let { parentNode: parentNode } = (0, $cgawC$useContext)($9bf71ea28793e738$var$FocusContext) || {};
// Create a tree node here so we can add children to it even before it is added to the tree.
let node = (0, $cgawC$useMemo)(()=>new $9bf71ea28793e738$var$TreeNode({
scopeRef: scopeRef
}), [
scopeRef
]);
(0, $cgawC$useLayoutEffect)(()=>{
// If a new scope mounts outside the active scope, (e.g. DialogContainer launched from a menu),
// use the active scope as the parent instead of the parent from context. Layout effects run bottom
// up, so if the parent is not yet added to the tree, don't do this. Only the outer-most FocusScope
// that is being added should get the activeScope as its parent.
let parent = parentNode || $9bf71ea28793e738$export$d06fae2ee68b101e.root;
if ($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parent.scopeRef) && $9bf71ea28793e738$var$activeScope && !$9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, parent.scopeRef)) {
let activeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
if (activeNode) parent = activeNode;
}
// Add the node to the parent, and to the tree.
parent.addChild(node);
$9bf71ea28793e738$export$d06fae2ee68b101e.addNode(node);
}, [
node,
parentNode
]);
(0, $cgawC$useLayoutEffect)(()=>{
let node = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (node) node.contain = !!contain;
}, [
contain
]);
(0, $cgawC$useLayoutEffect)(()=>{
var _startRef_current;
// Find all rendered nodes between the sentinels and add them to the scope.
let node = (_startRef_current = startRef.current) === null || _startRef_current === void 0 ? void 0 : _startRef_current.nextSibling;
let nodes = [];
let stopPropagation = (e)=>e.stopPropagation();
while(node && node !== endRef.current){
nodes.push(node);
// Stop custom restore focus event from propagating to parent focus scopes.
node.addEventListener($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, stopPropagation);
node = node.nextSibling;
}
scopeRef.current = nodes;
return ()=>{
for (let node of nodes)node.removeEventListener($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, stopPropagation);
};
}, [
children
]);
$9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restoreFocus, contain);
$9bf71ea28793e738$var$useFocusContainment(scopeRef, contain);
$9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain);
$9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus);
// This needs to be an effect so that activeScope is updated after the FocusScope tree is complete.
// It cannot be a useLayoutEffect because the parent of this node hasn't been attached in the tree yet.
(0, $cgawC$useEffect)(()=>{
const activeElement = (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined));
let scope = null;
if ($9bf71ea28793e738$var$isElementInScope(activeElement, scopeRef.current)) {
// We need to traverse the focusScope tree and find the bottom most scope that
// contains the active element and set that as the activeScope.
for (let node of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse())if (node.scopeRef && $9bf71ea28793e738$var$isElementInScope(activeElement, node.scopeRef.current)) scope = node;
if (scope === $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef)) $9bf71ea28793e738$var$activeScope = scope.scopeRef;
}
}, [
scopeRef
]);
// This layout effect cleanup is so that the tree node is removed synchronously with react before the RAF
// in useRestoreFocus cleanup runs.
(0, $cgawC$useLayoutEffect)(()=>{
return ()=>{
var _focusScopeTree_getTreeNode_parent, _focusScopeTree_getTreeNode;
var _focusScopeTree_getTreeNode_parent_scopeRef;
// Scope may have been re-parented.
let parentScope = (_focusScopeTree_getTreeNode_parent_scopeRef = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : (_focusScopeTree_getTreeNode_parent = _focusScopeTree_getTreeNode.parent) === null || _focusScopeTree_getTreeNode_parent === void 0 ? void 0 : _focusScopeTree_getTreeNode_parent.scopeRef) !== null && _focusScopeTree_getTreeNode_parent_scopeRef !== void 0 ? _focusScopeTree_getTreeNode_parent_scopeRef : null;
if ((scopeRef === $9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope(scopeRef, $9bf71ea28793e738$var$activeScope)) && (!parentScope || $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parentScope))) $9bf71ea28793e738$var$activeScope = parentScope;
$9bf71ea28793e738$export$d06fae2ee68b101e.removeTreeNode(scopeRef);
};
}, [
scopeRef
]);
let focusManager = (0, $cgawC$useMemo)(()=>$9bf71ea28793e738$var$createFocusManagerForScope(scopeRef), []);
let value = (0, $cgawC$useMemo)(()=>({
focusManager: focusManager,
parentNode: node
}), [
node,
focusManager
]);
return /*#__PURE__*/ (0, $cgawC$react).createElement($9bf71ea28793e738$var$FocusContext.Provider, {
value: value
}, /*#__PURE__*/ (0, $cgawC$react).createElement("span", {
"data-focus-scope-start": true,
hidden: true,
ref: startRef
}), children, /*#__PURE__*/ (0, $cgawC$react).createElement("span", {
"data-focus-scope-end": true,
hidden: true,
ref: endRef
}));
}
function $9bf71ea28793e738$export$10c5169755ce7bd7() {
var _useContext;
return (_useContext = (0, $cgawC$useContext)($9bf71ea28793e738$var$FocusContext)) === null || _useContext === void 0 ? void 0 : _useContext.focusManager;
}
function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
return {
focusNext (opts = {}) {
let scope = scopeRef.current;
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
var _scope_;
let node = from || (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : undefined));
let sentinel = scope[0].previousElementSibling;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
let nextNode = walker.nextNode();
if (!nextNode && wrap) {
walker.currentNode = sentinel;
nextNode = walker.nextNode();
}
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
return nextNode;
},
focusPrevious (opts = {}) {
let scope = scopeRef.current;
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
var _scope_;
let node = from || (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : undefined));
let sentinel = scope[scope.length - 1].nextElementSibling;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
let previousNode = walker.previousNode();
if (!previousNode && wrap) {
walker.currentNode = sentinel;
previousNode = walker.previousNode();
}
if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
return previousNode;
},
focusFirst (opts = {}) {
let scope = scopeRef.current;
let { tabbable: tabbable, accept: accept } = opts;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = scope[0].previousElementSibling;
let nextNode = walker.nextNode();
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
return nextNode;
},
focusLast (opts = {}) {
let scope = scopeRef.current;
let { tabbable: tabbable, accept: accept } = opts;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = scope[scope.length - 1].nextElementSibling;
let previousNode = walker.previousNode();
if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
return previousNode;
}
};
}
function $9bf71ea28793e738$var$getScopeRoot(scope) {
return scope[0].parentElement;
}
function $9bf71ea28793e738$var$shouldContainFocus(scopeRef) {
let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
while(scope && scope.scopeRef !== scopeRef){
if (scope.contain) return false;
scope = scope.parent;
}
return true;
}
function $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain) {
let focusedNode = (0, $cgawC$useRef)(undefined);
let raf = (0, $cgawC$useRef)(undefined);
(0, $cgawC$useLayoutEffect)(()=>{
let scope = scopeRef.current;
if (!contain) {
// if contain was changed, then we should cancel any ongoing waits to pull focus back into containment
if (raf.current) {
cancelAnimationFrame(raf.current);
raf.current = undefined;
}
return;
}
const ownerDocument = (0, $cgawC$getOwnerDocument)(scope ? scope[0] : undefined);
// Handle the Tab key to contain focus within the scope
let onKeyDown = (e)=>{
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing) return;
let focusedElement = (0, $cgawC$getActiveElement)(ownerDocument);
let scope = scopeRef.current;
if (!scope || !$9bf71ea28793e738$var$isElementInScope(focusedElement, scope)) return;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: true
}, scope);
if (!focusedElement) return;
walker.currentNode = focusedElement;
let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
if (!nextElement) {
walker.currentNode = e.shiftKey ? scope[scope.length - 1].nextElementSibling : scope[0].previousElementSibling;
nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
}
e.preventDefault();
if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
};
let onFocus = (e)=>{
// If focusing an element in a child scope of the currently active scope, the child becomes active.
// Moving out of the active scope to an ancestor is not allowed.
if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope((0, $cgawC$getEventTarget)(e), scopeRef.current)) {
$9bf71ea28793e738$var$activeScope = scopeRef;
focusedNode.current = (0, $cgawC$getEventTarget)(e);
} else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope((0, $cgawC$getEventTarget)(e), scopeRef)) {
// If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),
// restore focus to the previously focused node or the first tabbable element in the active scope.
if (focusedNode.current) focusedNode.current.focus();
else if ($9bf71ea28793e738$var$activeScope && $9bf71ea28793e738$var$activeScope.current) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
} else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef)) focusedNode.current = (0, $cgawC$getEventTarget)(e);
};
let onBlur = (e)=>{
// Firefox doesn't shift focus back to the Dialog properly without this
if (raf.current) cancelAnimationFrame(raf.current);
raf.current = requestAnimationFrame(()=>{
// Patches infinite focus coersion loop for Android Talkback where the user isn't able to move the virtual cursor
// if within a containing focus scope. Bug filed against Chrome: https://issuetracker.google.com/issues/384844019.
// Note that this means focus can leave focus containing modals due to this, but it is isolated to Chrome Talkback.
let modality = (0, $cgawC$getInteractionModality)();
let shouldSkipFocusRestore = (modality === 'virtual' || modality === null) && (0, $cgawC$isAndroid)() && (0, $cgawC$isChrome)();
// Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe
let activeElement = (0, $cgawC$getActiveElement)(ownerDocument);
if (!shouldSkipFocusRestore && activeElement && $9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope(activeElement, scopeRef)) {
$9bf71ea28793e738$var$activeScope = scopeRef;
let target = (0, $cgawC$getEventTarget)(e);
if (target && target.isConnected) {
var _focusedNode_current;
focusedNode.current = target;
(_focusedNode_current = focusedNode.current) === null || _focusedNode_current === void 0 ? void 0 : _focusedNode_current.focus();
} else if ($9bf71ea28793e738$var$activeScope.current) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
}
});
};
ownerDocument.addEventListener('keydown', onKeyDown, false);
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusout', onBlur, false));
return ()=>{
ownerDocument.removeEventListener('keydown', onKeyDown, false);
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusout', onBlur, false));
};
}, [
scopeRef,
contain
]);
// This is a useLayoutEffect so it is guaranteed to run before our async synthetic blur
(0, $cgawC$useLayoutEffect)(()=>{
return ()=>{
if (raf.current) cancelAnimationFrame(raf.current);
};
}, [
raf
]);
}
function $9bf71ea28793e738$var$isElementInAnyScope(element) {
return $9bf71ea28793e738$var$isElementInChildScope(element);
}
function $9bf71ea28793e738$var$isElementInScope(element, scope) {
if (!element) return false;
if (!scope) return false;
return scope.some((node)=>node.contains(element));
}
function $9bf71ea28793e738$var$isElementInChildScope(element, scope = null) {
// If the element is within a top layer element (e.g. toasts), always allow moving focus there.
if (element instanceof Element && element.closest('[data-react-aria-top-layer]')) return true;
// node.contains in isElementInScope covers child scopes that are also DOM children,
// but does not cover child scopes in portals.
for (let { scopeRef: s } of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope))){
if (s && $9bf71ea28793e738$var$isElementInScope(element, s.current)) return true;
}
return false;
}
function $9bf71ea28793e738$export$1258395f99bf9cbf(element) {
return $9bf71ea28793e738$var$isElementInChildScope(element, $9bf71ea28793e738$var$activeScope);
}
function $9bf71ea28793e738$var$isAncestorScope(ancestor, scope) {
var _focusScopeTree_getTreeNode;
let parent = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : _focusScopeTree_getTreeNode.parent;
while(parent){
if (parent.scopeRef === ancestor) return true;
parent = parent.parent;
}
return false;
}
function $9bf71ea28793e738$var$focusElement(element, scroll = false) {
if (element != null && !scroll) try {
(0, $cgawC$focusSafely)(element);
} catch {
// ignore
}
else if (element != null) try {
element.focus();
} catch {
// ignore
}
}
function $9bf71ea28793e738$var$getFirstInScope(scope, tabbable = true) {
let sentinel = scope[0].previousElementSibling;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable
}, scope);
walker.currentNode = sentinel;
let nextNode = walker.nextNode();
// If the scope does not contain a tabbable element, use the first focusable element.
if (tabbable && !nextNode) {
scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: false
}, scope);
walker.currentNode = sentinel;
nextNode = walker.nextNode();
}
return nextNode;
}
function $9bf71ea28793e738$var$focusFirstInScope(scope, tabbable = true) {
$9bf71ea28793e738$var$focusElement($9bf71ea28793e738$var$getFirstInScope(scope, tabbable));
}
function $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus) {
const autoFocusRef = (0, $cgawC$react).useRef(autoFocus);
(0, $cgawC$useEffect)(()=>{
if (autoFocusRef.current) {
$9bf71ea28793e738$var$activeScope = scopeRef;
const ownerDocument = (0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!$9bf71ea28793e738$var$isElementInScope((0, $cgawC$getActiveElement)(ownerDocument), $9bf71ea28793e738$var$activeScope.current) && scopeRef.current) $9bf71ea28793e738$var$focusFirstInScope(scopeRef.current);
}
autoFocusRef.current = false;
}, [
scopeRef
]);
}
function $9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restore, contain) {
// tracks the active scope, in case restore and contain are both false.
// if either are true, this is tracked in useRestoreFocus or useFocusContainment.
(0, $cgawC$useLayoutEffect)(()=>{
if (restore || contain) return;
let scope = scopeRef.current;
const ownerDocument = (0, $cgawC$getOwnerDocument)(scope ? scope[0] : undefined);
let onFocus = (e)=>{
let target = (0, $cgawC$getEventTarget)(e);
if ($9bf71ea28793e738$var$isElementInScope(target, scopeRef.current)) $9bf71ea28793e738$var$activeScope = scopeRef;
else if (!$9bf71ea28793e738$var$isElementInAnyScope(target)) $9bf71ea28793e738$var$activeScope = null;
};
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
return ()=>{
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
};
}, [
scopeRef,
restore,
contain
]);
}
function $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef) {
let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
while(scope && scope.scopeRef !== scopeRef){
if (scope.nodeToRestore) return false;
scope = scope.parent;
}
return (scope === null || scope === void 0 ? void 0 : scope.scopeRef) === scopeRef;
}
function $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
// create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.
// eslint-disable-next-line no-restricted-globals
const nodeToRestoreRef = (0, $cgawC$useRef)(typeof document !== 'undefined' ? (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined)) : null);
// restoring scopes should all track if they are active regardless of contain, but contain already tracks it plus logic to contain the focus
// restoring-non-containing scopes should only care if they become active so they can perform the restore
(0, $cgawC$useLayoutEffect)(()=>{
let scope = scopeRef.current;
const ownerDocument = (0, $cgawC$getOwnerDocument)(scope ? scope[0] : undefined);
if (!restoreFocus || contain) return;
let onFocus = ()=>{
// If focusing an element in a child scope of the currently active scope, the child becomes active.
// Moving out of the active scope to an ancestor is not allowed.
if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope((0, $cgawC$getActiveElement)(ownerDocument), scopeRef.current)) $9bf71ea28793e738$var$activeScope = scopeRef;
};
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
return ()=>{
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
scopeRef,
contain
]);
(0, $cgawC$useLayoutEffect)(()=>{
const ownerDocument = (0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!restoreFocus) return;
// Handle the Tab key so that tabbing out of the scope goes to the next element
// after the node that had focus when the scope mounted. This is important when
// using portals for overlays, so that focus goes to the expected element when
// tabbing out of the overlay.
let onKeyDown = (e)=>{
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing) return;
let focusedElement = ownerDocument.activeElement;
if (!$9bf71ea28793e738$var$isElementInChildScope(focusedElement, scopeRef) || !$9bf71ea28793e738$var$shouldRestoreFocus(scopeRef)) return;
let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
let nodeToRestore = treeNode.nodeToRestore;
// Create a DOM tree walker that matches all tabbable elements
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ownerDocument.body, {
tabbable: true
});
// Find the next tabbable element after the currently focused element
walker.currentNode = focusedElement;
let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
if (!nodeToRestore || !nodeToRestore.isConnected || nodeToRestore === ownerDocument.body) {
nodeToRestore = undefined;
treeNode.nodeToRestore = undefined;
}
// If there is no next element, or it is outside the current scope, move focus to the
// next element after the node to restore to instead.
if ((!nextElement || !$9bf71ea28793e738$var$isElementInChildScope(nextElement, scopeRef)) && nodeToRestore) {
walker.currentNode = nodeToRestore;
// Skip over elements within the scope, in case the scope immediately follows the node to restore.
do nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
while ($9bf71ea28793e738$var$isElementInChildScope(nextElement, scopeRef));
e.preventDefault();
e.stopPropagation();
if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
else // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)
// then move focus to the body.
// Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)
if (!$9bf71ea28793e738$var$isElementInAnyScope(nodeToRestore)) focusedElement.blur();
else $9bf71ea28793e738$var$focusElement(nodeToRestore, true);
}
};
if (!contain) ownerDocument.addEventListener('keydown', onKeyDown, true);
return ()=>{
if (!contain) ownerDocument.removeEventListener('keydown', onKeyDown, true);
};
}, [
scopeRef,
restoreFocus,
contain
]);
// useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.
(0, $cgawC$useLayoutEffect)(()=>{
const ownerDocument = (0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!restoreFocus) return;
let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
var _nodeToRestoreRef_current;
treeNode.nodeToRestore = (_nodeToRestoreRef_current = nodeToRestoreRef.current) !== null && _nodeToRestoreRef_current !== void 0 ? _nodeToRestoreRef_current : undefined;
return ()=>{
let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
let nodeToRestore = treeNode.nodeToRestore;
// if we already lost focus to the body and this was the active scope, then we should attempt to restore
let activeElement = (0, $cgawC$getActiveElement)(ownerDocument);
if (restoreFocus && nodeToRestore && (activeElement && $9bf71ea28793e738$var$isElementInChildScope(activeElement, scopeRef) || activeElement === ownerDocument.body && $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef))) {
// freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it
let clonedTree = $9bf71ea28793e738$export$d06fae2ee68b101e.clone();
requestAnimationFrame(()=>{
// Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere
if (ownerDocument.activeElement === ownerDocument.body) {
// look up the tree starting with our scope to find a nodeToRestore still in the DOM
let treeNode = clonedTree.getTreeNode(scopeRef);
while(treeNode){
if (treeNode.nodeToRestore && treeNode.nodeToRestore.isConnected) {
$9bf71ea28793e738$var$restoreFocusToElement(treeNode.nodeToRestore);
return;
}
treeNode = treeNode.parent;
}
// If no nodeToRestore was found, focus the first element in the nearest
// ancestor scope that is still in the tree.
treeNode = clonedTree.getTreeNode(scopeRef);
while(treeNode){
if (treeNode.scopeRef && treeNode.scopeRef.current && $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(treeNode.scopeRef)) {
let node = $9bf71ea28793e738$var$getFirstInScope(treeNode.scopeRef.current, true);
$9bf71ea28793e738$var$restoreFocusToElement(node);
return;
}
treeNode = treeNode.parent;
}
}
});
}
};
}, [
scopeRef,
restoreFocus
]);
}
function $9bf71ea28793e738$var$restoreFocusToElement(node) {
// Dispatch a custom event that parent elements can intercept to customize focus restoration.
// For example, virtualized collection components reuse DOM elements, so the original element
// might still exist in the DOM but representing a different item.
if (node.dispatchEvent(new CustomEvent($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, {
bubbles: true,
cancelable: true
}))) $9bf71ea28793e738$var$focusElement(node);
}
function $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, opts, scope) {
let filter = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? (0, $cgawC$isTabbable) : (0, $cgawC$isFocusable);
// Ensure that root is an Element or fall back appropriately
let rootElement = (root === null || root === void 0 ? void 0 : root.nodeType) === Node.ELEMENT_NODE ? root : null;
// Determine the document to use
let doc = (0, $cgawC$getOwnerDocument)(rootElement);
// Create a TreeWalker, ensuring the root is an Element or Document
let walker = (0, $cgawC$createShadowTreeWalker)(doc, root || doc, NodeFilter.SHOW_ELEMENT, {
acceptNode (node) {
var _opts_from;
// Skip nodes inside the starting node.
if (opts === null || opts === void 0 ? void 0 : (_opts_from = opts.from) === null || _opts_from === void 0 ? void 0 : _opts_from.contains(node)) return NodeFilter.FILTER_REJECT;
if (filter(node) && (0, $645f2e67b85a24c9$export$e989c0fffaa6b27a)(node) && (!scope || $9bf71ea28793e738$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node))) return NodeFilter.FILTER_ACCEPT;
return NodeFilter.FILTER_SKIP;
}
});
if (opts === null || opts === void 0 ? void 0 : opts.from) walker.currentNode = opts.from;
return walker;
}
function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
return {
focusNext (opts = {}) {
let root = ref.current;
if (!root) return null;
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
let node = from || (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)(root));
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
if (root.contains(node)) walker.currentNode = node;
let nextNode = walker.nextNode();
if (!nextNode && wrap) {
walker.currentNode = root;
nextNode = walker.nextNode();
}
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
return nextNode;
},
focusPrevious (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
let node = from || (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)(root));
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
if (root.contains(node)) walker.currentNode = node;
else {
let next = $9bf71ea28793e738$var$last(walker);
if (next) $9bf71ea28793e738$var$focusElement(next, true);
return next !== null && next !== void 0 ? next : null;
}
let previousNode = walker.previousNode();
if (!previousNode && wrap) {
walker.currentNode = root;
let lastNode = $9bf71ea28793e738$var$last(walker);
if (!lastNode) // couldn't wrap
return null;
previousNode = lastNode;
}
if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
return previousNode !== null && previousNode !== void 0 ? previousNode : null;
},
focusFirst (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
let nextNode = walker.nextNode();
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
return nextNode;
},
focusLast (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
let next = $9bf71ea28793e738$var$last(walker);
if (next) $9bf71ea28793e738$var$focusElement(next, true);
return next !== null && next !== void 0 ? next : null;
}
};
}
function $9bf71ea28793e738$var$last(walker) {
let next = undefined;
let last;
do {
last = walker.lastChild();
if (last) next = last;
}while (last);
return next;
}
class $9bf71ea28793e738$var$Tree {
get size() {
return this.fastMap.size;
}
getTreeNode(data) {
return this.fastMap.get(data);
}
addTreeNode(scopeRef, parent, nodeToRestore) {
let parentNode = this.fastMap.get(parent !== null && parent !== void 0 ? parent : null);
if (!parentNode) return;
let node = new $9bf71ea28793e738$var$TreeNode({
scopeRef: scopeRef
});
parentNode.addChild(node);
node.parent = parentNode;
this.fastMap.set(scopeRef, node);
if (nodeToRestore) node.nodeToRestore = nodeToRestore;
}
addNode(node) {
this.fastMap.set(node.scopeRef, node);
}
removeTreeNode(scopeRef) {
// never remove the root
if (scopeRef === null) return;
let node = this.fastMap.get(scopeRef);
if (!node) return;
let parentNode = node.parent;
// when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing
// if we are, then replace the siblings restore with the restore from the scope we're removing
for (let current of this.traverse())if (current !== node && node.nodeToRestore && current.nodeToRestore && node.scopeRef && node.scopeRef.current && $9bf71ea28793e738$var$isElementInScope(current.nodeToRestore, node.scopeRef.current)) current.nodeToRestore = node.nodeToRestore;
let children = node.children;
if (parentNode) {
parentNode.removeChild(node);
if (children.size > 0) children.forEach((child)=>parentNode && parentNode.addChild(child));
}
this.fastMap.delete(node.scopeRef);
}
// Pre Order Depth First
*traverse(node = this.root) {
if (node.scopeRef != null) yield node;
if (node.children.size > 0) for (let child of node.children)yield* this.traverse(child);
}
clone() {
var _node_parent;
let newTree = new $9bf71ea28793e738$var$Tree();
var _node_parent_scopeRef;
for (let node of this.traverse())newTree.addTreeNode(node.scopeRef, (_node_parent_scopeRef = (_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.scopeRef) !== null && _node_parent_scopeRef !== void 0 ? _node_parent_scopeRef : null, node.nodeToRestore);
return newTree;
}
constructor(){
this.fastMap = new Map();
this.root = new $9bf71ea28793e738$var$TreeNode({
scopeRef: null
});
this.fastMap.set(null, this.root);
}
}
class $9bf71ea28793e738$var$TreeNode {
addChild(node) {
this.children.add(node);
node.parent = this;
}
removeChild(node) {
this.children.delete(node);
node.parent = undefined;
}
constructor(props){
this.children = new Set();
this.contain = false;
this.scopeRef = props.scopeRef;
}
}
let $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree();
export {$9bf71ea28793e738$export$20e40289641fbbb6 as FocusScope, $9bf71ea28793e738$export$d06fae2ee68b101e as focusScopeTree, $9bf71ea28793e738$export$10c5169755ce7bd7 as useFocusManager, $9bf71ea28793e738$export$2d6ec8fc375ceafa as getFocusableTreeWalker, $9bf71ea28793e738$export$1258395f99bf9cbf as isElementInChildOfActiveScope, $9bf71ea28793e738$export$c5251b9e124bf29 as createFocusManager};
//# sourceMappingURL=FocusScope.module.js.map

View File

@@ -0,0 +1,726 @@
import {isElementVisible as $645f2e67b85a24c9$export$e989c0fffaa6b27a} from "./isElementVisible.module.js";
import {useLayoutEffect as $cgawC$useLayoutEffect, getActiveElement as $cgawC$getActiveElement, getOwnerDocument as $cgawC$getOwnerDocument, getEventTarget as $cgawC$getEventTarget, isAndroid as $cgawC$isAndroid, isChrome as $cgawC$isChrome, isTabbable as $cgawC$isTabbable, isFocusable as $cgawC$isFocusable, createShadowTreeWalker as $cgawC$createShadowTreeWalker} from "@react-aria/utils";
import {getInteractionModality as $cgawC$getInteractionModality, focusSafely as $cgawC$focusSafely} from "@react-aria/interactions";
import $cgawC$react, {useRef as $cgawC$useRef, useContext as $cgawC$useContext, useMemo as $cgawC$useMemo, useEffect as $cgawC$useEffect} from "react";
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
const $9bf71ea28793e738$var$FocusContext = /*#__PURE__*/ (0, $cgawC$react).createContext(null);
const $9bf71ea28793e738$var$RESTORE_FOCUS_EVENT = 'react-aria-focus-scope-restore';
let $9bf71ea28793e738$var$activeScope = null;
function $9bf71ea28793e738$export$20e40289641fbbb6(props) {
let { children: children, contain: contain, restoreFocus: restoreFocus, autoFocus: autoFocus } = props;
let startRef = (0, $cgawC$useRef)(null);
let endRef = (0, $cgawC$useRef)(null);
let scopeRef = (0, $cgawC$useRef)([]);
let { parentNode: parentNode } = (0, $cgawC$useContext)($9bf71ea28793e738$var$FocusContext) || {};
// Create a tree node here so we can add children to it even before it is added to the tree.
let node = (0, $cgawC$useMemo)(()=>new $9bf71ea28793e738$var$TreeNode({
scopeRef: scopeRef
}), [
scopeRef
]);
(0, $cgawC$useLayoutEffect)(()=>{
// If a new scope mounts outside the active scope, (e.g. DialogContainer launched from a menu),
// use the active scope as the parent instead of the parent from context. Layout effects run bottom
// up, so if the parent is not yet added to the tree, don't do this. Only the outer-most FocusScope
// that is being added should get the activeScope as its parent.
let parent = parentNode || $9bf71ea28793e738$export$d06fae2ee68b101e.root;
if ($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parent.scopeRef) && $9bf71ea28793e738$var$activeScope && !$9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, parent.scopeRef)) {
let activeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
if (activeNode) parent = activeNode;
}
// Add the node to the parent, and to the tree.
parent.addChild(node);
$9bf71ea28793e738$export$d06fae2ee68b101e.addNode(node);
}, [
node,
parentNode
]);
(0, $cgawC$useLayoutEffect)(()=>{
let node = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (node) node.contain = !!contain;
}, [
contain
]);
(0, $cgawC$useLayoutEffect)(()=>{
var _startRef_current;
// Find all rendered nodes between the sentinels and add them to the scope.
let node = (_startRef_current = startRef.current) === null || _startRef_current === void 0 ? void 0 : _startRef_current.nextSibling;
let nodes = [];
let stopPropagation = (e)=>e.stopPropagation();
while(node && node !== endRef.current){
nodes.push(node);
// Stop custom restore focus event from propagating to parent focus scopes.
node.addEventListener($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, stopPropagation);
node = node.nextSibling;
}
scopeRef.current = nodes;
return ()=>{
for (let node of nodes)node.removeEventListener($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, stopPropagation);
};
}, [
children
]);
$9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restoreFocus, contain);
$9bf71ea28793e738$var$useFocusContainment(scopeRef, contain);
$9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain);
$9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus);
// This needs to be an effect so that activeScope is updated after the FocusScope tree is complete.
// It cannot be a useLayoutEffect because the parent of this node hasn't been attached in the tree yet.
(0, $cgawC$useEffect)(()=>{
const activeElement = (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined));
let scope = null;
if ($9bf71ea28793e738$var$isElementInScope(activeElement, scopeRef.current)) {
// We need to traverse the focusScope tree and find the bottom most scope that
// contains the active element and set that as the activeScope.
for (let node of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse())if (node.scopeRef && $9bf71ea28793e738$var$isElementInScope(activeElement, node.scopeRef.current)) scope = node;
if (scope === $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef)) $9bf71ea28793e738$var$activeScope = scope.scopeRef;
}
}, [
scopeRef
]);
// This layout effect cleanup is so that the tree node is removed synchronously with react before the RAF
// in useRestoreFocus cleanup runs.
(0, $cgawC$useLayoutEffect)(()=>{
return ()=>{
var _focusScopeTree_getTreeNode_parent, _focusScopeTree_getTreeNode;
var _focusScopeTree_getTreeNode_parent_scopeRef;
// Scope may have been re-parented.
let parentScope = (_focusScopeTree_getTreeNode_parent_scopeRef = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : (_focusScopeTree_getTreeNode_parent = _focusScopeTree_getTreeNode.parent) === null || _focusScopeTree_getTreeNode_parent === void 0 ? void 0 : _focusScopeTree_getTreeNode_parent.scopeRef) !== null && _focusScopeTree_getTreeNode_parent_scopeRef !== void 0 ? _focusScopeTree_getTreeNode_parent_scopeRef : null;
if ((scopeRef === $9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope(scopeRef, $9bf71ea28793e738$var$activeScope)) && (!parentScope || $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(parentScope))) $9bf71ea28793e738$var$activeScope = parentScope;
$9bf71ea28793e738$export$d06fae2ee68b101e.removeTreeNode(scopeRef);
};
}, [
scopeRef
]);
let focusManager = (0, $cgawC$useMemo)(()=>$9bf71ea28793e738$var$createFocusManagerForScope(scopeRef), []);
let value = (0, $cgawC$useMemo)(()=>({
focusManager: focusManager,
parentNode: node
}), [
node,
focusManager
]);
return /*#__PURE__*/ (0, $cgawC$react).createElement($9bf71ea28793e738$var$FocusContext.Provider, {
value: value
}, /*#__PURE__*/ (0, $cgawC$react).createElement("span", {
"data-focus-scope-start": true,
hidden: true,
ref: startRef
}), children, /*#__PURE__*/ (0, $cgawC$react).createElement("span", {
"data-focus-scope-end": true,
hidden: true,
ref: endRef
}));
}
function $9bf71ea28793e738$export$10c5169755ce7bd7() {
var _useContext;
return (_useContext = (0, $cgawC$useContext)($9bf71ea28793e738$var$FocusContext)) === null || _useContext === void 0 ? void 0 : _useContext.focusManager;
}
function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
return {
focusNext (opts = {}) {
let scope = scopeRef.current;
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
var _scope_;
let node = from || (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : undefined));
let sentinel = scope[0].previousElementSibling;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
let nextNode = walker.nextNode();
if (!nextNode && wrap) {
walker.currentNode = sentinel;
nextNode = walker.nextNode();
}
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
return nextNode;
},
focusPrevious (opts = {}) {
let scope = scopeRef.current;
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
var _scope_;
let node = from || (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)((_scope_ = scope[0]) !== null && _scope_ !== void 0 ? _scope_ : undefined));
let sentinel = scope[scope.length - 1].nextElementSibling;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = $9bf71ea28793e738$var$isElementInScope(node, scope) ? node : sentinel;
let previousNode = walker.previousNode();
if (!previousNode && wrap) {
walker.currentNode = sentinel;
previousNode = walker.previousNode();
}
if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
return previousNode;
},
focusFirst (opts = {}) {
let scope = scopeRef.current;
let { tabbable: tabbable, accept: accept } = opts;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = scope[0].previousElementSibling;
let nextNode = walker.nextNode();
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
return nextNode;
},
focusLast (opts = {}) {
let scope = scopeRef.current;
let { tabbable: tabbable, accept: accept } = opts;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable,
accept: accept
}, scope);
walker.currentNode = scope[scope.length - 1].nextElementSibling;
let previousNode = walker.previousNode();
if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
return previousNode;
}
};
}
function $9bf71ea28793e738$var$getScopeRoot(scope) {
return scope[0].parentElement;
}
function $9bf71ea28793e738$var$shouldContainFocus(scopeRef) {
let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
while(scope && scope.scopeRef !== scopeRef){
if (scope.contain) return false;
scope = scope.parent;
}
return true;
}
function $9bf71ea28793e738$var$useFocusContainment(scopeRef, contain) {
let focusedNode = (0, $cgawC$useRef)(undefined);
let raf = (0, $cgawC$useRef)(undefined);
(0, $cgawC$useLayoutEffect)(()=>{
let scope = scopeRef.current;
if (!contain) {
// if contain was changed, then we should cancel any ongoing waits to pull focus back into containment
if (raf.current) {
cancelAnimationFrame(raf.current);
raf.current = undefined;
}
return;
}
const ownerDocument = (0, $cgawC$getOwnerDocument)(scope ? scope[0] : undefined);
// Handle the Tab key to contain focus within the scope
let onKeyDown = (e)=>{
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing) return;
let focusedElement = (0, $cgawC$getActiveElement)(ownerDocument);
let scope = scopeRef.current;
if (!scope || !$9bf71ea28793e738$var$isElementInScope(focusedElement, scope)) return;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: true
}, scope);
if (!focusedElement) return;
walker.currentNode = focusedElement;
let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
if (!nextElement) {
walker.currentNode = e.shiftKey ? scope[scope.length - 1].nextElementSibling : scope[0].previousElementSibling;
nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
}
e.preventDefault();
if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
};
let onFocus = (e)=>{
// If focusing an element in a child scope of the currently active scope, the child becomes active.
// Moving out of the active scope to an ancestor is not allowed.
if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope((0, $cgawC$getEventTarget)(e), scopeRef.current)) {
$9bf71ea28793e738$var$activeScope = scopeRef;
focusedNode.current = (0, $cgawC$getEventTarget)(e);
} else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope((0, $cgawC$getEventTarget)(e), scopeRef)) {
// If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),
// restore focus to the previously focused node or the first tabbable element in the active scope.
if (focusedNode.current) focusedNode.current.focus();
else if ($9bf71ea28793e738$var$activeScope && $9bf71ea28793e738$var$activeScope.current) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
} else if ($9bf71ea28793e738$var$shouldContainFocus(scopeRef)) focusedNode.current = (0, $cgawC$getEventTarget)(e);
};
let onBlur = (e)=>{
// Firefox doesn't shift focus back to the Dialog properly without this
if (raf.current) cancelAnimationFrame(raf.current);
raf.current = requestAnimationFrame(()=>{
// Patches infinite focus coersion loop for Android Talkback where the user isn't able to move the virtual cursor
// if within a containing focus scope. Bug filed against Chrome: https://issuetracker.google.com/issues/384844019.
// Note that this means focus can leave focus containing modals due to this, but it is isolated to Chrome Talkback.
let modality = (0, $cgawC$getInteractionModality)();
let shouldSkipFocusRestore = (modality === 'virtual' || modality === null) && (0, $cgawC$isAndroid)() && (0, $cgawC$isChrome)();
// Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe
let activeElement = (0, $cgawC$getActiveElement)(ownerDocument);
if (!shouldSkipFocusRestore && activeElement && $9bf71ea28793e738$var$shouldContainFocus(scopeRef) && !$9bf71ea28793e738$var$isElementInChildScope(activeElement, scopeRef)) {
$9bf71ea28793e738$var$activeScope = scopeRef;
let target = (0, $cgawC$getEventTarget)(e);
if (target && target.isConnected) {
var _focusedNode_current;
focusedNode.current = target;
(_focusedNode_current = focusedNode.current) === null || _focusedNode_current === void 0 ? void 0 : _focusedNode_current.focus();
} else if ($9bf71ea28793e738$var$activeScope.current) $9bf71ea28793e738$var$focusFirstInScope($9bf71ea28793e738$var$activeScope.current);
}
});
};
ownerDocument.addEventListener('keydown', onKeyDown, false);
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusout', onBlur, false));
return ()=>{
ownerDocument.removeEventListener('keydown', onKeyDown, false);
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusout', onBlur, false));
};
}, [
scopeRef,
contain
]);
// This is a useLayoutEffect so it is guaranteed to run before our async synthetic blur
(0, $cgawC$useLayoutEffect)(()=>{
return ()=>{
if (raf.current) cancelAnimationFrame(raf.current);
};
}, [
raf
]);
}
function $9bf71ea28793e738$var$isElementInAnyScope(element) {
return $9bf71ea28793e738$var$isElementInChildScope(element);
}
function $9bf71ea28793e738$var$isElementInScope(element, scope) {
if (!element) return false;
if (!scope) return false;
return scope.some((node)=>node.contains(element));
}
function $9bf71ea28793e738$var$isElementInChildScope(element, scope = null) {
// If the element is within a top layer element (e.g. toasts), always allow moving focus there.
if (element instanceof Element && element.closest('[data-react-aria-top-layer]')) return true;
// node.contains in isElementInScope covers child scopes that are also DOM children,
// but does not cover child scopes in portals.
for (let { scopeRef: s } of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope))){
if (s && $9bf71ea28793e738$var$isElementInScope(element, s.current)) return true;
}
return false;
}
function $9bf71ea28793e738$export$1258395f99bf9cbf(element) {
return $9bf71ea28793e738$var$isElementInChildScope(element, $9bf71ea28793e738$var$activeScope);
}
function $9bf71ea28793e738$var$isAncestorScope(ancestor, scope) {
var _focusScopeTree_getTreeNode;
let parent = (_focusScopeTree_getTreeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : _focusScopeTree_getTreeNode.parent;
while(parent){
if (parent.scopeRef === ancestor) return true;
parent = parent.parent;
}
return false;
}
function $9bf71ea28793e738$var$focusElement(element, scroll = false) {
if (element != null && !scroll) try {
(0, $cgawC$focusSafely)(element);
} catch {
// ignore
}
else if (element != null) try {
element.focus();
} catch {
// ignore
}
}
function $9bf71ea28793e738$var$getFirstInScope(scope, tabbable = true) {
let sentinel = scope[0].previousElementSibling;
let scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: tabbable
}, scope);
walker.currentNode = sentinel;
let nextNode = walker.nextNode();
// If the scope does not contain a tabbable element, use the first focusable element.
if (tabbable && !nextNode) {
scopeRoot = $9bf71ea28793e738$var$getScopeRoot(scope);
walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(scopeRoot, {
tabbable: false
}, scope);
walker.currentNode = sentinel;
nextNode = walker.nextNode();
}
return nextNode;
}
function $9bf71ea28793e738$var$focusFirstInScope(scope, tabbable = true) {
$9bf71ea28793e738$var$focusElement($9bf71ea28793e738$var$getFirstInScope(scope, tabbable));
}
function $9bf71ea28793e738$var$useAutoFocus(scopeRef, autoFocus) {
const autoFocusRef = (0, $cgawC$react).useRef(autoFocus);
(0, $cgawC$useEffect)(()=>{
if (autoFocusRef.current) {
$9bf71ea28793e738$var$activeScope = scopeRef;
const ownerDocument = (0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!$9bf71ea28793e738$var$isElementInScope((0, $cgawC$getActiveElement)(ownerDocument), $9bf71ea28793e738$var$activeScope.current) && scopeRef.current) $9bf71ea28793e738$var$focusFirstInScope(scopeRef.current);
}
autoFocusRef.current = false;
}, [
scopeRef
]);
}
function $9bf71ea28793e738$var$useActiveScopeTracker(scopeRef, restore, contain) {
// tracks the active scope, in case restore and contain are both false.
// if either are true, this is tracked in useRestoreFocus or useFocusContainment.
(0, $cgawC$useLayoutEffect)(()=>{
if (restore || contain) return;
let scope = scopeRef.current;
const ownerDocument = (0, $cgawC$getOwnerDocument)(scope ? scope[0] : undefined);
let onFocus = (e)=>{
let target = (0, $cgawC$getEventTarget)(e);
if ($9bf71ea28793e738$var$isElementInScope(target, scopeRef.current)) $9bf71ea28793e738$var$activeScope = scopeRef;
else if (!$9bf71ea28793e738$var$isElementInAnyScope(target)) $9bf71ea28793e738$var$activeScope = null;
};
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
return ()=>{
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
};
}, [
scopeRef,
restore,
contain
]);
}
function $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef) {
let scope = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode($9bf71ea28793e738$var$activeScope);
while(scope && scope.scopeRef !== scopeRef){
if (scope.nodeToRestore) return false;
scope = scope.parent;
}
return (scope === null || scope === void 0 ? void 0 : scope.scopeRef) === scopeRef;
}
function $9bf71ea28793e738$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
// create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.
// eslint-disable-next-line no-restricted-globals
const nodeToRestoreRef = (0, $cgawC$useRef)(typeof document !== 'undefined' ? (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined)) : null);
// restoring scopes should all track if they are active regardless of contain, but contain already tracks it plus logic to contain the focus
// restoring-non-containing scopes should only care if they become active so they can perform the restore
(0, $cgawC$useLayoutEffect)(()=>{
let scope = scopeRef.current;
const ownerDocument = (0, $cgawC$getOwnerDocument)(scope ? scope[0] : undefined);
if (!restoreFocus || contain) return;
let onFocus = ()=>{
// If focusing an element in a child scope of the currently active scope, the child becomes active.
// Moving out of the active scope to an ancestor is not allowed.
if ((!$9bf71ea28793e738$var$activeScope || $9bf71ea28793e738$var$isAncestorScope($9bf71ea28793e738$var$activeScope, scopeRef)) && $9bf71ea28793e738$var$isElementInScope((0, $cgawC$getActiveElement)(ownerDocument), scopeRef.current)) $9bf71ea28793e738$var$activeScope = scopeRef;
};
ownerDocument.addEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.addEventListener('focusin', onFocus, false));
return ()=>{
ownerDocument.removeEventListener('focusin', onFocus, false);
scope === null || scope === void 0 ? void 0 : scope.forEach((element)=>element.removeEventListener('focusin', onFocus, false));
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
scopeRef,
contain
]);
(0, $cgawC$useLayoutEffect)(()=>{
const ownerDocument = (0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!restoreFocus) return;
// Handle the Tab key so that tabbing out of the scope goes to the next element
// after the node that had focus when the scope mounted. This is important when
// using portals for overlays, so that focus goes to the expected element when
// tabbing out of the overlay.
let onKeyDown = (e)=>{
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !$9bf71ea28793e738$var$shouldContainFocus(scopeRef) || e.isComposing) return;
let focusedElement = ownerDocument.activeElement;
if (!$9bf71ea28793e738$var$isElementInChildScope(focusedElement, scopeRef) || !$9bf71ea28793e738$var$shouldRestoreFocus(scopeRef)) return;
let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
let nodeToRestore = treeNode.nodeToRestore;
// Create a DOM tree walker that matches all tabbable elements
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ownerDocument.body, {
tabbable: true
});
// Find the next tabbable element after the currently focused element
walker.currentNode = focusedElement;
let nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
if (!nodeToRestore || !nodeToRestore.isConnected || nodeToRestore === ownerDocument.body) {
nodeToRestore = undefined;
treeNode.nodeToRestore = undefined;
}
// If there is no next element, or it is outside the current scope, move focus to the
// next element after the node to restore to instead.
if ((!nextElement || !$9bf71ea28793e738$var$isElementInChildScope(nextElement, scopeRef)) && nodeToRestore) {
walker.currentNode = nodeToRestore;
// Skip over elements within the scope, in case the scope immediately follows the node to restore.
do nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
while ($9bf71ea28793e738$var$isElementInChildScope(nextElement, scopeRef));
e.preventDefault();
e.stopPropagation();
if (nextElement) $9bf71ea28793e738$var$focusElement(nextElement, true);
else // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)
// then move focus to the body.
// Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)
if (!$9bf71ea28793e738$var$isElementInAnyScope(nodeToRestore)) focusedElement.blur();
else $9bf71ea28793e738$var$focusElement(nodeToRestore, true);
}
};
if (!contain) ownerDocument.addEventListener('keydown', onKeyDown, true);
return ()=>{
if (!contain) ownerDocument.removeEventListener('keydown', onKeyDown, true);
};
}, [
scopeRef,
restoreFocus,
contain
]);
// useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.
(0, $cgawC$useLayoutEffect)(()=>{
const ownerDocument = (0, $cgawC$getOwnerDocument)(scopeRef.current ? scopeRef.current[0] : undefined);
if (!restoreFocus) return;
let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
var _nodeToRestoreRef_current;
treeNode.nodeToRestore = (_nodeToRestoreRef_current = nodeToRestoreRef.current) !== null && _nodeToRestoreRef_current !== void 0 ? _nodeToRestoreRef_current : undefined;
return ()=>{
let treeNode = $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scopeRef);
if (!treeNode) return;
let nodeToRestore = treeNode.nodeToRestore;
// if we already lost focus to the body and this was the active scope, then we should attempt to restore
let activeElement = (0, $cgawC$getActiveElement)(ownerDocument);
if (restoreFocus && nodeToRestore && (activeElement && $9bf71ea28793e738$var$isElementInChildScope(activeElement, scopeRef) || activeElement === ownerDocument.body && $9bf71ea28793e738$var$shouldRestoreFocus(scopeRef))) {
// freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it
let clonedTree = $9bf71ea28793e738$export$d06fae2ee68b101e.clone();
requestAnimationFrame(()=>{
// Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere
if (ownerDocument.activeElement === ownerDocument.body) {
// look up the tree starting with our scope to find a nodeToRestore still in the DOM
let treeNode = clonedTree.getTreeNode(scopeRef);
while(treeNode){
if (treeNode.nodeToRestore && treeNode.nodeToRestore.isConnected) {
$9bf71ea28793e738$var$restoreFocusToElement(treeNode.nodeToRestore);
return;
}
treeNode = treeNode.parent;
}
// If no nodeToRestore was found, focus the first element in the nearest
// ancestor scope that is still in the tree.
treeNode = clonedTree.getTreeNode(scopeRef);
while(treeNode){
if (treeNode.scopeRef && treeNode.scopeRef.current && $9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(treeNode.scopeRef)) {
let node = $9bf71ea28793e738$var$getFirstInScope(treeNode.scopeRef.current, true);
$9bf71ea28793e738$var$restoreFocusToElement(node);
return;
}
treeNode = treeNode.parent;
}
}
});
}
};
}, [
scopeRef,
restoreFocus
]);
}
function $9bf71ea28793e738$var$restoreFocusToElement(node) {
// Dispatch a custom event that parent elements can intercept to customize focus restoration.
// For example, virtualized collection components reuse DOM elements, so the original element
// might still exist in the DOM but representing a different item.
if (node.dispatchEvent(new CustomEvent($9bf71ea28793e738$var$RESTORE_FOCUS_EVENT, {
bubbles: true,
cancelable: true
}))) $9bf71ea28793e738$var$focusElement(node);
}
function $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, opts, scope) {
let filter = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? (0, $cgawC$isTabbable) : (0, $cgawC$isFocusable);
// Ensure that root is an Element or fall back appropriately
let rootElement = (root === null || root === void 0 ? void 0 : root.nodeType) === Node.ELEMENT_NODE ? root : null;
// Determine the document to use
let doc = (0, $cgawC$getOwnerDocument)(rootElement);
// Create a TreeWalker, ensuring the root is an Element or Document
let walker = (0, $cgawC$createShadowTreeWalker)(doc, root || doc, NodeFilter.SHOW_ELEMENT, {
acceptNode (node) {
var _opts_from;
// Skip nodes inside the starting node.
if (opts === null || opts === void 0 ? void 0 : (_opts_from = opts.from) === null || _opts_from === void 0 ? void 0 : _opts_from.contains(node)) return NodeFilter.FILTER_REJECT;
if (filter(node) && (0, $645f2e67b85a24c9$export$e989c0fffaa6b27a)(node) && (!scope || $9bf71ea28793e738$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node))) return NodeFilter.FILTER_ACCEPT;
return NodeFilter.FILTER_SKIP;
}
});
if (opts === null || opts === void 0 ? void 0 : opts.from) walker.currentNode = opts.from;
return walker;
}
function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
return {
focusNext (opts = {}) {
let root = ref.current;
if (!root) return null;
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
let node = from || (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)(root));
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
if (root.contains(node)) walker.currentNode = node;
let nextNode = walker.nextNode();
if (!nextNode && wrap) {
walker.currentNode = root;
nextNode = walker.nextNode();
}
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
return nextNode;
},
focusPrevious (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
let node = from || (0, $cgawC$getActiveElement)((0, $cgawC$getOwnerDocument)(root));
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
if (root.contains(node)) walker.currentNode = node;
else {
let next = $9bf71ea28793e738$var$last(walker);
if (next) $9bf71ea28793e738$var$focusElement(next, true);
return next !== null && next !== void 0 ? next : null;
}
let previousNode = walker.previousNode();
if (!previousNode && wrap) {
walker.currentNode = root;
let lastNode = $9bf71ea28793e738$var$last(walker);
if (!lastNode) // couldn't wrap
return null;
previousNode = lastNode;
}
if (previousNode) $9bf71ea28793e738$var$focusElement(previousNode, true);
return previousNode !== null && previousNode !== void 0 ? previousNode : null;
},
focusFirst (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
let nextNode = walker.nextNode();
if (nextNode) $9bf71ea28793e738$var$focusElement(nextNode, true);
return nextNode;
},
focusLast (opts = defaultOptions) {
let root = ref.current;
if (!root) return null;
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
tabbable: tabbable,
accept: accept
});
let next = $9bf71ea28793e738$var$last(walker);
if (next) $9bf71ea28793e738$var$focusElement(next, true);
return next !== null && next !== void 0 ? next : null;
}
};
}
function $9bf71ea28793e738$var$last(walker) {
let next = undefined;
let last;
do {
last = walker.lastChild();
if (last) next = last;
}while (last);
return next;
}
class $9bf71ea28793e738$var$Tree {
get size() {
return this.fastMap.size;
}
getTreeNode(data) {
return this.fastMap.get(data);
}
addTreeNode(scopeRef, parent, nodeToRestore) {
let parentNode = this.fastMap.get(parent !== null && parent !== void 0 ? parent : null);
if (!parentNode) return;
let node = new $9bf71ea28793e738$var$TreeNode({
scopeRef: scopeRef
});
parentNode.addChild(node);
node.parent = parentNode;
this.fastMap.set(scopeRef, node);
if (nodeToRestore) node.nodeToRestore = nodeToRestore;
}
addNode(node) {
this.fastMap.set(node.scopeRef, node);
}
removeTreeNode(scopeRef) {
// never remove the root
if (scopeRef === null) return;
let node = this.fastMap.get(scopeRef);
if (!node) return;
let parentNode = node.parent;
// when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing
// if we are, then replace the siblings restore with the restore from the scope we're removing
for (let current of this.traverse())if (current !== node && node.nodeToRestore && current.nodeToRestore && node.scopeRef && node.scopeRef.current && $9bf71ea28793e738$var$isElementInScope(current.nodeToRestore, node.scopeRef.current)) current.nodeToRestore = node.nodeToRestore;
let children = node.children;
if (parentNode) {
parentNode.removeChild(node);
if (children.size > 0) children.forEach((child)=>parentNode && parentNode.addChild(child));
}
this.fastMap.delete(node.scopeRef);
}
// Pre Order Depth First
*traverse(node = this.root) {
if (node.scopeRef != null) yield node;
if (node.children.size > 0) for (let child of node.children)yield* this.traverse(child);
}
clone() {
var _node_parent;
let newTree = new $9bf71ea28793e738$var$Tree();
var _node_parent_scopeRef;
for (let node of this.traverse())newTree.addTreeNode(node.scopeRef, (_node_parent_scopeRef = (_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.scopeRef) !== null && _node_parent_scopeRef !== void 0 ? _node_parent_scopeRef : null, node.nodeToRestore);
return newTree;
}
constructor(){
this.fastMap = new Map();
this.root = new $9bf71ea28793e738$var$TreeNode({
scopeRef: null
});
this.fastMap.set(null, this.root);
}
}
class $9bf71ea28793e738$var$TreeNode {
addChild(node) {
this.children.add(node);
node.parent = this;
}
removeChild(node) {
this.children.delete(node);
node.parent = undefined;
}
constructor(props){
this.children = new Set();
this.contain = false;
this.scopeRef = props.scopeRef;
}
}
let $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree();
export {$9bf71ea28793e738$export$20e40289641fbbb6 as FocusScope, $9bf71ea28793e738$export$d06fae2ee68b101e as focusScopeTree, $9bf71ea28793e738$export$10c5169755ce7bd7 as useFocusManager, $9bf71ea28793e738$export$2d6ec8fc375ceafa as getFocusableTreeWalker, $9bf71ea28793e738$export$1258395f99bf9cbf as isElementInChildOfActiveScope, $9bf71ea28793e738$export$c5251b9e124bf29 as createFocusManager};
//# sourceMappingURL=FocusScope.module.js.map

File diff suppressed because one or more lines are too long

29
node_modules/@react-aria/focus/dist/import.mjs generated vendored Normal file
View File

@@ -0,0 +1,29 @@
import {createFocusManager as $9bf71ea28793e738$export$c5251b9e124bf29, FocusScope as $9bf71ea28793e738$export$20e40289641fbbb6, getFocusableTreeWalker as $9bf71ea28793e738$export$2d6ec8fc375ceafa, isElementInChildOfActiveScope as $9bf71ea28793e738$export$1258395f99bf9cbf, useFocusManager as $9bf71ea28793e738$export$10c5169755ce7bd7} from "./FocusScope.mjs";
import {FocusRing as $907718708eab68af$export$1a38b4ad7f578e1d} from "./FocusRing.mjs";
import {useFocusRing as $f7dceffc5ad7768b$export$4e328f61c538687f} from "./useFocusRing.mjs";
import {useHasTabbableChild as $83013635b024ae3d$export$eac1895992b9f3d6} from "./useHasTabbableChild.mjs";
import {dispatchVirtualBlur as $55f9b1ae81f22853$export$6c5dc7e81d2cc29a, dispatchVirtualFocus as $55f9b1ae81f22853$export$2b35b76d2e30e129, getVirtuallyFocusedElement as $55f9b1ae81f22853$export$759df0d867455a91, moveVirtualFocus as $55f9b1ae81f22853$export$76e4e37e5339496d} from "./virtualFocus.mjs";
import {isFocusable as $d48f97c9d1a8e323$re_export$isFocusable} from "@react-aria/utils";
import {FocusableProvider as $d48f97c9d1a8e323$re_export$FocusableProvider, Focusable as $d48f97c9d1a8e323$re_export$Focusable, useFocusable as $d48f97c9d1a8e323$re_export$useFocusable, focusSafely as $d48f97c9d1a8e323$re_export$focusSafely} from "@react-aria/interactions";
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
export {$9bf71ea28793e738$export$20e40289641fbbb6 as FocusScope, $9bf71ea28793e738$export$10c5169755ce7bd7 as useFocusManager, $9bf71ea28793e738$export$2d6ec8fc375ceafa as getFocusableTreeWalker, $9bf71ea28793e738$export$c5251b9e124bf29 as createFocusManager, $9bf71ea28793e738$export$1258395f99bf9cbf as isElementInChildOfActiveScope, $907718708eab68af$export$1a38b4ad7f578e1d as FocusRing, $f7dceffc5ad7768b$export$4e328f61c538687f as useFocusRing, $83013635b024ae3d$export$eac1895992b9f3d6 as useHasTabbableChild, $55f9b1ae81f22853$export$76e4e37e5339496d as moveVirtualFocus, $55f9b1ae81f22853$export$6c5dc7e81d2cc29a as dispatchVirtualBlur, $55f9b1ae81f22853$export$2b35b76d2e30e129 as dispatchVirtualFocus, $55f9b1ae81f22853$export$759df0d867455a91 as getVirtuallyFocusedElement, $d48f97c9d1a8e323$re_export$isFocusable as isFocusable, $d48f97c9d1a8e323$re_export$FocusableProvider as FocusableProvider, $d48f97c9d1a8e323$re_export$Focusable as Focusable, $d48f97c9d1a8e323$re_export$useFocusable as useFocusable, $d48f97c9d1a8e323$re_export$focusSafely as focusSafely};
//# sourceMappingURL=module.js.map

View File

@@ -0,0 +1,41 @@
var $fhpU6$reactariautils = require("@react-aria/utils");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "isElementVisible", () => $d5156037ad898a4d$export$e989c0fffaa6b27a);
/*
* Copyright 2021 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $d5156037ad898a4d$var$isStyleVisible(element) {
const windowObject = (0, $fhpU6$reactariautils.getOwnerWindow)(element);
if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) return false;
let { display: display, visibility: visibility } = element.style;
let isVisible = display !== 'none' && visibility !== 'hidden' && visibility !== 'collapse';
if (isVisible) {
const { getComputedStyle: getComputedStyle } = element.ownerDocument.defaultView;
let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
isVisible = computedDisplay !== 'none' && computedVisibility !== 'hidden' && computedVisibility !== 'collapse';
}
return isVisible;
}
function $d5156037ad898a4d$var$isAttributeVisible(element, childElement) {
return !element.hasAttribute('hidden') && // Ignore HiddenSelect when tree walking.
!element.hasAttribute('data-react-aria-prevent-focus') && (element.nodeName === 'DETAILS' && childElement && childElement.nodeName !== 'SUMMARY' ? element.hasAttribute('open') : true);
}
function $d5156037ad898a4d$export$e989c0fffaa6b27a(element, childElement) {
return element.nodeName !== '#comment' && $d5156037ad898a4d$var$isStyleVisible(element) && $d5156037ad898a4d$var$isAttributeVisible(element, childElement) && (!element.parentElement || $d5156037ad898a4d$export$e989c0fffaa6b27a(element.parentElement, element));
}
//# sourceMappingURL=isElementVisible.main.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAID,SAAS,qCAAe,OAAgB;IACtC,MAAM,eAAe,CAAA,GAAA,oCAAa,EAAE;IACpC,IAAI,CAAE,CAAA,mBAAmB,aAAa,WAAW,AAAD,KAAM,CAAE,CAAA,mBAAmB,aAAa,UAAU,AAAD,GAC/F,OAAO;IAGT,IAAI,WAAC,OAAO,cAAE,UAAU,EAAC,GAAG,QAAQ,KAAK;IAEzC,IAAI,YACF,YAAY,UACZ,eAAe,YACf,eAAe;IAGjB,IAAI,WAAW;QACb,MAAM,oBAAC,gBAAgB,EAAC,GAAG,QAAQ,aAAa,CAAC,WAAW;QAC5D,IAAI,EAAC,SAAS,eAAe,EAAE,YAAY,kBAAkB,EAAC,GAAG,iBAAiB;QAElF,YACE,oBAAoB,UACpB,uBAAuB,YACvB,uBAAuB;IAE3B;IAEA,OAAO;AACT;AAEA,SAAS,yCAAmB,OAAgB,EAAE,YAAsB;IAClE,OACE,CAAC,QAAQ,YAAY,CAAC,aACtB,yCAAyC;IACzC,CAAC,QAAQ,YAAY,CAAC,oCACrB,CAAA,QAAQ,QAAQ,KAAK,aACpB,gBACA,aAAa,QAAQ,KAAK,YACxB,QAAQ,YAAY,CAAC,UACrB,IAAG;AAEX;AAQO,SAAS,0CAAiB,OAAgB,EAAE,YAAsB;IACvE,OACE,QAAQ,QAAQ,KAAK,cACrB,qCAAe,YACf,yCAAmB,SAAS,iBAC3B,CAAA,CAAC,QAAQ,aAAa,IAAI,0CAAiB,QAAQ,aAAa,EAAE,QAAO;AAE9E","sources":["packages/@react-aria/focus/src/isElementVisible.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getOwnerWindow} from '@react-aria/utils';\n\nfunction isStyleVisible(element: Element) {\n const windowObject = getOwnerWindow(element);\n if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) {\n return false;\n }\n\n let {display, visibility} = element.style;\n\n let isVisible = (\n display !== 'none' &&\n visibility !== 'hidden' &&\n visibility !== 'collapse'\n );\n\n if (isVisible) {\n const {getComputedStyle} = element.ownerDocument.defaultView as unknown as Window;\n let {display: computedDisplay, visibility: computedVisibility} = getComputedStyle(element);\n\n isVisible = (\n computedDisplay !== 'none' &&\n computedVisibility !== 'hidden' &&\n computedVisibility !== 'collapse'\n );\n }\n\n return isVisible;\n}\n\nfunction isAttributeVisible(element: Element, childElement?: Element) {\n return (\n !element.hasAttribute('hidden') &&\n // Ignore HiddenSelect when tree walking.\n !element.hasAttribute('data-react-aria-prevent-focus') &&\n (element.nodeName === 'DETAILS' &&\n childElement &&\n childElement.nodeName !== 'SUMMARY'\n ? element.hasAttribute('open')\n : true)\n );\n}\n\n/**\n * Adapted from https://github.com/testing-library/jest-dom and\n * https://github.com/vuejs/vue-test-utils-next/.\n * Licensed under the MIT License.\n * @param element - Element to evaluate for display or visibility.\n */\nexport function isElementVisible(element: Element, childElement?: Element): boolean {\n return (\n element.nodeName !== '#comment' &&\n isStyleVisible(element) &&\n isAttributeVisible(element, childElement) &&\n (!element.parentElement || isElementVisible(element.parentElement, element))\n );\n}\n"],"names":[],"version":3,"file":"isElementVisible.main.js.map"}

View File

@@ -0,0 +1,36 @@
import {getOwnerWindow as $djhjW$getOwnerWindow} from "@react-aria/utils";
/*
* Copyright 2021 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $645f2e67b85a24c9$var$isStyleVisible(element) {
const windowObject = (0, $djhjW$getOwnerWindow)(element);
if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) return false;
let { display: display, visibility: visibility } = element.style;
let isVisible = display !== 'none' && visibility !== 'hidden' && visibility !== 'collapse';
if (isVisible) {
const { getComputedStyle: getComputedStyle } = element.ownerDocument.defaultView;
let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
isVisible = computedDisplay !== 'none' && computedVisibility !== 'hidden' && computedVisibility !== 'collapse';
}
return isVisible;
}
function $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) {
return !element.hasAttribute('hidden') && // Ignore HiddenSelect when tree walking.
!element.hasAttribute('data-react-aria-prevent-focus') && (element.nodeName === 'DETAILS' && childElement && childElement.nodeName !== 'SUMMARY' ? element.hasAttribute('open') : true);
}
function $645f2e67b85a24c9$export$e989c0fffaa6b27a(element, childElement) {
return element.nodeName !== '#comment' && $645f2e67b85a24c9$var$isStyleVisible(element) && $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) && (!element.parentElement || $645f2e67b85a24c9$export$e989c0fffaa6b27a(element.parentElement, element));
}
export {$645f2e67b85a24c9$export$e989c0fffaa6b27a as isElementVisible};
//# sourceMappingURL=isElementVisible.module.js.map

View File

@@ -0,0 +1,36 @@
import {getOwnerWindow as $djhjW$getOwnerWindow} from "@react-aria/utils";
/*
* Copyright 2021 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $645f2e67b85a24c9$var$isStyleVisible(element) {
const windowObject = (0, $djhjW$getOwnerWindow)(element);
if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) return false;
let { display: display, visibility: visibility } = element.style;
let isVisible = display !== 'none' && visibility !== 'hidden' && visibility !== 'collapse';
if (isVisible) {
const { getComputedStyle: getComputedStyle } = element.ownerDocument.defaultView;
let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
isVisible = computedDisplay !== 'none' && computedVisibility !== 'hidden' && computedVisibility !== 'collapse';
}
return isVisible;
}
function $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) {
return !element.hasAttribute('hidden') && // Ignore HiddenSelect when tree walking.
!element.hasAttribute('data-react-aria-prevent-focus') && (element.nodeName === 'DETAILS' && childElement && childElement.nodeName !== 'SUMMARY' ? element.hasAttribute('open') : true);
}
function $645f2e67b85a24c9$export$e989c0fffaa6b27a(element, childElement) {
return element.nodeName !== '#comment' && $645f2e67b85a24c9$var$isStyleVisible(element) && $645f2e67b85a24c9$var$isAttributeVisible(element, childElement) && (!element.parentElement || $645f2e67b85a24c9$export$e989c0fffaa6b27a(element.parentElement, element));
}
export {$645f2e67b85a24c9$export$e989c0fffaa6b27a as isElementVisible};
//# sourceMappingURL=isElementVisible.module.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAID,SAAS,qCAAe,OAAgB;IACtC,MAAM,eAAe,CAAA,GAAA,qBAAa,EAAE;IACpC,IAAI,CAAE,CAAA,mBAAmB,aAAa,WAAW,AAAD,KAAM,CAAE,CAAA,mBAAmB,aAAa,UAAU,AAAD,GAC/F,OAAO;IAGT,IAAI,WAAC,OAAO,cAAE,UAAU,EAAC,GAAG,QAAQ,KAAK;IAEzC,IAAI,YACF,YAAY,UACZ,eAAe,YACf,eAAe;IAGjB,IAAI,WAAW;QACb,MAAM,oBAAC,gBAAgB,EAAC,GAAG,QAAQ,aAAa,CAAC,WAAW;QAC5D,IAAI,EAAC,SAAS,eAAe,EAAE,YAAY,kBAAkB,EAAC,GAAG,iBAAiB;QAElF,YACE,oBAAoB,UACpB,uBAAuB,YACvB,uBAAuB;IAE3B;IAEA,OAAO;AACT;AAEA,SAAS,yCAAmB,OAAgB,EAAE,YAAsB;IAClE,OACE,CAAC,QAAQ,YAAY,CAAC,aACtB,yCAAyC;IACzC,CAAC,QAAQ,YAAY,CAAC,oCACrB,CAAA,QAAQ,QAAQ,KAAK,aACpB,gBACA,aAAa,QAAQ,KAAK,YACxB,QAAQ,YAAY,CAAC,UACrB,IAAG;AAEX;AAQO,SAAS,0CAAiB,OAAgB,EAAE,YAAsB;IACvE,OACE,QAAQ,QAAQ,KAAK,cACrB,qCAAe,YACf,yCAAmB,SAAS,iBAC3B,CAAA,CAAC,QAAQ,aAAa,IAAI,0CAAiB,QAAQ,aAAa,EAAE,QAAO;AAE9E","sources":["packages/@react-aria/focus/src/isElementVisible.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getOwnerWindow} from '@react-aria/utils';\n\nfunction isStyleVisible(element: Element) {\n const windowObject = getOwnerWindow(element);\n if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) {\n return false;\n }\n\n let {display, visibility} = element.style;\n\n let isVisible = (\n display !== 'none' &&\n visibility !== 'hidden' &&\n visibility !== 'collapse'\n );\n\n if (isVisible) {\n const {getComputedStyle} = element.ownerDocument.defaultView as unknown as Window;\n let {display: computedDisplay, visibility: computedVisibility} = getComputedStyle(element);\n\n isVisible = (\n computedDisplay !== 'none' &&\n computedVisibility !== 'hidden' &&\n computedVisibility !== 'collapse'\n );\n }\n\n return isVisible;\n}\n\nfunction isAttributeVisible(element: Element, childElement?: Element) {\n return (\n !element.hasAttribute('hidden') &&\n // Ignore HiddenSelect when tree walking.\n !element.hasAttribute('data-react-aria-prevent-focus') &&\n (element.nodeName === 'DETAILS' &&\n childElement &&\n childElement.nodeName !== 'SUMMARY'\n ? element.hasAttribute('open')\n : true)\n );\n}\n\n/**\n * Adapted from https://github.com/testing-library/jest-dom and\n * https://github.com/vuejs/vue-test-utils-next/.\n * Licensed under the MIT License.\n * @param element - Element to evaluate for display or visibility.\n */\nexport function isElementVisible(element: Element, childElement?: Element): boolean {\n return (\n element.nodeName !== '#comment' &&\n isStyleVisible(element) &&\n isAttributeVisible(element, childElement) &&\n (!element.parentElement || isElementVisible(element.parentElement, element))\n );\n}\n"],"names":[],"version":3,"file":"isElementVisible.module.js.map"}

50
node_modules/@react-aria/focus/dist/main.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
var $a7a032acae3ddda9$exports = require("./FocusScope.main.js");
var $dfd8c70b928eb1b3$exports = require("./FocusRing.main.js");
var $581a96d6eb128c1b$exports = require("./useFocusRing.main.js");
var $259c6413a286f2e6$exports = require("./useHasTabbableChild.main.js");
var $a756eb2d3b28d089$exports = require("./virtualFocus.main.js");
var $aB6Cp$reactariautils = require("@react-aria/utils");
var $aB6Cp$reactariainteractions = require("@react-aria/interactions");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "FocusScope", () => $a7a032acae3ddda9$exports.FocusScope);
$parcel$export(module.exports, "useFocusManager", () => $a7a032acae3ddda9$exports.useFocusManager);
$parcel$export(module.exports, "getFocusableTreeWalker", () => $a7a032acae3ddda9$exports.getFocusableTreeWalker);
$parcel$export(module.exports, "createFocusManager", () => $a7a032acae3ddda9$exports.createFocusManager);
$parcel$export(module.exports, "isElementInChildOfActiveScope", () => $a7a032acae3ddda9$exports.isElementInChildOfActiveScope);
$parcel$export(module.exports, "FocusRing", () => $dfd8c70b928eb1b3$exports.FocusRing);
$parcel$export(module.exports, "useFocusRing", () => $581a96d6eb128c1b$exports.useFocusRing);
$parcel$export(module.exports, "useHasTabbableChild", () => $259c6413a286f2e6$exports.useHasTabbableChild);
$parcel$export(module.exports, "moveVirtualFocus", () => $a756eb2d3b28d089$exports.moveVirtualFocus);
$parcel$export(module.exports, "dispatchVirtualBlur", () => $a756eb2d3b28d089$exports.dispatchVirtualBlur);
$parcel$export(module.exports, "dispatchVirtualFocus", () => $a756eb2d3b28d089$exports.dispatchVirtualFocus);
$parcel$export(module.exports, "getVirtuallyFocusedElement", () => $a756eb2d3b28d089$exports.getVirtuallyFocusedElement);
$parcel$export(module.exports, "isFocusable", () => $aB6Cp$reactariautils.isFocusable);
$parcel$export(module.exports, "FocusableProvider", () => $aB6Cp$reactariainteractions.FocusableProvider);
$parcel$export(module.exports, "Focusable", () => $aB6Cp$reactariainteractions.Focusable);
$parcel$export(module.exports, "useFocusable", () => $aB6Cp$reactariainteractions.useFocusable);
$parcel$export(module.exports, "focusSafely", () => $aB6Cp$reactariainteractions.focusSafely);
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
//# sourceMappingURL=main.js.map

1
node_modules/@react-aria/focus/dist/main.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/focus/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {FocusScope, useFocusManager, getFocusableTreeWalker, createFocusManager, isElementInChildOfActiveScope} from './FocusScope';\nexport {FocusRing} from './FocusRing';\nexport {useFocusRing} from './useFocusRing';\nexport {useHasTabbableChild} from './useHasTabbableChild';\nexport {moveVirtualFocus, dispatchVirtualBlur, dispatchVirtualFocus, getVirtuallyFocusedElement} from './virtualFocus';\n// For backward compatibility.\nexport {isFocusable} from '@react-aria/utils';\nexport {FocusableProvider, Focusable, useFocusable, focusSafely} from '@react-aria/interactions';\n\nexport type {FocusScopeProps, FocusManager, FocusManagerOptions} from './FocusScope';\nexport type {FocusRingProps} from './FocusRing';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from '@react-aria/interactions';\nexport type {AriaFocusRingProps, FocusRingAria} from './useFocusRing';\n"],"names":[],"version":3,"file":"main.js.map"}

29
node_modules/@react-aria/focus/dist/module.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
import {createFocusManager as $9bf71ea28793e738$export$c5251b9e124bf29, FocusScope as $9bf71ea28793e738$export$20e40289641fbbb6, getFocusableTreeWalker as $9bf71ea28793e738$export$2d6ec8fc375ceafa, isElementInChildOfActiveScope as $9bf71ea28793e738$export$1258395f99bf9cbf, useFocusManager as $9bf71ea28793e738$export$10c5169755ce7bd7} from "./FocusScope.module.js";
import {FocusRing as $907718708eab68af$export$1a38b4ad7f578e1d} from "./FocusRing.module.js";
import {useFocusRing as $f7dceffc5ad7768b$export$4e328f61c538687f} from "./useFocusRing.module.js";
import {useHasTabbableChild as $83013635b024ae3d$export$eac1895992b9f3d6} from "./useHasTabbableChild.module.js";
import {dispatchVirtualBlur as $55f9b1ae81f22853$export$6c5dc7e81d2cc29a, dispatchVirtualFocus as $55f9b1ae81f22853$export$2b35b76d2e30e129, getVirtuallyFocusedElement as $55f9b1ae81f22853$export$759df0d867455a91, moveVirtualFocus as $55f9b1ae81f22853$export$76e4e37e5339496d} from "./virtualFocus.module.js";
import {isFocusable as $d48f97c9d1a8e323$re_export$isFocusable} from "@react-aria/utils";
import {FocusableProvider as $d48f97c9d1a8e323$re_export$FocusableProvider, Focusable as $d48f97c9d1a8e323$re_export$Focusable, useFocusable as $d48f97c9d1a8e323$re_export$useFocusable, focusSafely as $d48f97c9d1a8e323$re_export$focusSafely} from "@react-aria/interactions";
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
export {$9bf71ea28793e738$export$20e40289641fbbb6 as FocusScope, $9bf71ea28793e738$export$10c5169755ce7bd7 as useFocusManager, $9bf71ea28793e738$export$2d6ec8fc375ceafa as getFocusableTreeWalker, $9bf71ea28793e738$export$c5251b9e124bf29 as createFocusManager, $9bf71ea28793e738$export$1258395f99bf9cbf as isElementInChildOfActiveScope, $907718708eab68af$export$1a38b4ad7f578e1d as FocusRing, $f7dceffc5ad7768b$export$4e328f61c538687f as useFocusRing, $83013635b024ae3d$export$eac1895992b9f3d6 as useHasTabbableChild, $55f9b1ae81f22853$export$76e4e37e5339496d as moveVirtualFocus, $55f9b1ae81f22853$export$6c5dc7e81d2cc29a as dispatchVirtualBlur, $55f9b1ae81f22853$export$2b35b76d2e30e129 as dispatchVirtualFocus, $55f9b1ae81f22853$export$759df0d867455a91 as getVirtuallyFocusedElement, $d48f97c9d1a8e323$re_export$isFocusable as isFocusable, $d48f97c9d1a8e323$re_export$FocusableProvider as FocusableProvider, $d48f97c9d1a8e323$re_export$Focusable as Focusable, $d48f97c9d1a8e323$re_export$useFocusable as useFocusable, $d48f97c9d1a8e323$re_export$focusSafely as focusSafely};
//# sourceMappingURL=module.js.map

1
node_modules/@react-aria/focus/dist/module.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/focus/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {FocusScope, useFocusManager, getFocusableTreeWalker, createFocusManager, isElementInChildOfActiveScope} from './FocusScope';\nexport {FocusRing} from './FocusRing';\nexport {useFocusRing} from './useFocusRing';\nexport {useHasTabbableChild} from './useHasTabbableChild';\nexport {moveVirtualFocus, dispatchVirtualBlur, dispatchVirtualFocus, getVirtuallyFocusedElement} from './virtualFocus';\n// For backward compatibility.\nexport {isFocusable} from '@react-aria/utils';\nexport {FocusableProvider, Focusable, useFocusable, focusSafely} from '@react-aria/interactions';\n\nexport type {FocusScopeProps, FocusManager, FocusManagerOptions} from './FocusScope';\nexport type {FocusRingProps} from './FocusRing';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from '@react-aria/interactions';\nexport type {AriaFocusRingProps, FocusRingAria} from './useFocusRing';\n"],"names":[],"version":3,"file":"module.js.map"}

133
node_modules/@react-aria/focus/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,133 @@
import { ShadowTreeWalker } from "@react-aria/utils";
import { FocusableElement, RefObject, DOMAttributes } from "@react-types/shared";
import React, { JSX, ReactNode, ReactElement } from "react";
export interface FocusScopeProps {
/** The contents of the focus scope. */
children: ReactNode;
/**
* Whether to contain focus inside the scope, so users cannot
* move focus outside, for example in a modal dialog.
*/
contain?: boolean;
/**
* Whether to restore focus back to the element that was focused
* when the focus scope mounted, after the focus scope unmounts.
*/
restoreFocus?: boolean;
/** Whether to auto focus the first focusable element in the focus scope on mount. */
autoFocus?: boolean;
}
export interface FocusManagerOptions {
/** The element to start searching from. The currently focused element by default. */
from?: Element;
/** Whether to only include tabbable elements, or all focusable elements. */
tabbable?: boolean;
/** Whether focus should wrap around when it reaches the end of the scope. */
wrap?: boolean;
/** A callback that determines whether the given element is focused. */
accept?: (node: Element) => boolean;
}
export interface FocusManager {
/** Moves focus to the next focusable or tabbable element in the focus scope. */
focusNext(opts?: FocusManagerOptions): FocusableElement | null;
/** Moves focus to the previous focusable or tabbable element in the focus scope. */
focusPrevious(opts?: FocusManagerOptions): FocusableElement | null;
/** Moves focus to the first focusable or tabbable element in the focus scope. */
focusFirst(opts?: FocusManagerOptions): FocusableElement | null;
/** Moves focus to the last focusable or tabbable element in the focus scope. */
focusLast(opts?: FocusManagerOptions): FocusableElement | null;
}
/**
* A FocusScope manages focus for its descendants. It supports containing focus inside
* the scope, restoring focus to the previously focused element on unmount, and auto
* focusing children on mount. It also acts as a container for a programmatic focus
* management interface that can be used to move focus forward and back in response
* to user events.
*/
export function FocusScope(props: FocusScopeProps): JSX.Element;
/**
* Returns a FocusManager interface for the parent FocusScope.
* A FocusManager can be used to programmatically move focus within
* a FocusScope, e.g. in response to user events like keyboard navigation.
*/
export function useFocusManager(): FocusManager | undefined;
/** @private */
export function isElementInChildOfActiveScope(element: Element): boolean;
/**
* Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}
* that matches all focusable/tabbable elements.
*/
export function getFocusableTreeWalker(root: Element, opts?: FocusManagerOptions, scope?: Element[]): ShadowTreeWalker | TreeWalker;
/**
* Creates a FocusManager object that can be used to move focus within an element.
*/
export function createFocusManager(ref: RefObject<Element | null>, defaultOptions?: FocusManagerOptions): FocusManager;
export interface AriaFocusRingProps {
/**
* Whether to show the focus ring when something
* inside the container element has focus (true), or
* only if the container itself has focus (false).
* @default 'false'
*/
within?: boolean;
/** Whether the element is a text input. */
isTextInput?: boolean;
/** Whether the element will be auto focused. */
autoFocus?: boolean;
}
export interface FocusRingAria {
/** Whether the element is currently focused. */
isFocused: boolean;
/** Whether keyboard focus should be visible. */
isFocusVisible: boolean;
/** Props to apply to the container element with the focus ring. */
focusProps: DOMAttributes;
}
/**
* Determines whether a focus ring should be shown to indicate keyboard focus.
* Focus rings are visible only when the user is interacting with a keyboard,
* not with a mouse, touch, or other input methods.
*/
export function useFocusRing(props?: AriaFocusRingProps): FocusRingAria;
export interface FocusRingProps {
/** Child element to apply CSS classes to. */
children: ReactElement;
/** CSS class to apply when the element is focused. */
focusClass?: string;
/** CSS class to apply when the element has keyboard focus. */
focusRingClass?: string;
/**
* Whether to show the focus ring when something
* inside the container element has focus (true), or
* only if the container itself has focus (false).
* @default false
*/
within?: boolean;
/** Whether the element is a text input. */
isTextInput?: boolean;
/** Whether the element will be auto focused. */
autoFocus?: boolean;
}
/**
* A utility component that applies a CSS class when an element has keyboard focus.
* Focus rings are visible only when the user is interacting with a keyboard,
* not with a mouse, touch, or other input methods.
*/
export function FocusRing(props: FocusRingProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
interface AriaHasTabbableChildOptions {
isDisabled?: boolean;
}
/**
* Returns whether an element has a tabbable child, and updates as children change.
* @private
*/
export function useHasTabbableChild(ref: RefObject<Element | null>, options?: AriaHasTabbableChildOptions): boolean;
export function moveVirtualFocus(to: Element | null): void;
export function dispatchVirtualBlur(from: Element, to: Element | null): void;
export function dispatchVirtualFocus(to: Element, from: Element | null): void;
export function getVirtuallyFocusedElement(document: Document): Element | null;
export { isFocusable } from '@react-aria/utils';
export { FocusableProvider, Focusable, useFocusable, focusSafely } from '@react-aria/interactions';
export type { FocusableAria, FocusableOptions, FocusableProviderProps } from '@react-aria/interactions';
//# sourceMappingURL=types.d.ts.map

1
node_modules/@react-aria/focus/dist/types.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"mappings":";;;AC6BA;IACE,uCAAuC;IACvC,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,qFAAqF;IACrF,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;IACE,qFAAqF;IACrF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uEAAuE;IACvE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAA;CACpC;AAED;IACE,gFAAgF;IAChF,SAAS,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC/D,oFAAoF;IACpF,aAAa,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,IAAI,CAAC;IACnE,iFAAiF;IACjF,UAAU,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAChE,gFAAgF;IAChF,SAAS,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,IAAI,CAAA;CAC/D;AAgBD;;;;;;GAMG;AACH,2BAA2B,KAAK,EAAE,eAAe,GAAG,IAAI,OAAO,CAgH9D;AAED;;;;GAIG;AACH,mCAAmC,YAAY,GAAG,SAAS,CAE1D;AAuOD,eAAe;AACf,8CAA8C,OAAO,EAAE,OAAO,GAAG,OAAO,CAEvE;AA+RD;;;GAGG;AACH,uCAAuC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,mBAAmB,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,gBAAgB,GAAG,UAAU,CAuClI;AAED;;GAEG;AACH,mCAAmC,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,EAAE,cAAc,GAAE,mBAAwB,GAAG,YAAY,CAkFzH;AC51BD;IACE;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;IACE,gDAAgD;IAChD,SAAS,EAAE,OAAO,CAAC;IAEnB,gDAAgD;IAChD,cAAc,EAAE,OAAO,CAAC;IAExB,mEAAmE;IACnE,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED;;;;GAIG;AACH,6BAA6B,KAAK,GAAE,kBAAuB,GAAG,aAAa,CAyC1E;AC5DD;IACE,6CAA6C;IAC7C,QAAQ,EAAE,YAAY,CAAC;IACvB,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,0BAA0B,KAAK,EAAE,cAAc,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAYvH;ACrCD;IACE,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAOD;;;GAGG;AACH,oCAAoC,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,2BAA2B,GAAG,OAAO,CAmClH;AC/DD,iCAAiC,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAUzD;AAED,oCAAoC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAG3E;AAED,qCAAqC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAG5E;AAED,2CAA2C,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAQ7E;ACdD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAIjG,YAAY,EAAC,aAAa,EAAE,gBAAgB,EAAE,sBAAsB,EAAC,MAAM,0BAA0B,CAAC","sources":["packages/@react-aria/focus/src/packages/@react-aria/focus/src/isElementVisible.ts","packages/@react-aria/focus/src/packages/@react-aria/focus/src/FocusScope.tsx","packages/@react-aria/focus/src/packages/@react-aria/focus/src/useFocusRing.ts","packages/@react-aria/focus/src/packages/@react-aria/focus/src/FocusRing.tsx","packages/@react-aria/focus/src/packages/@react-aria/focus/src/useHasTabbableChild.ts","packages/@react-aria/focus/src/packages/@react-aria/focus/src/virtualFocus.ts","packages/@react-aria/focus/src/packages/@react-aria/focus/src/index.ts","packages/@react-aria/focus/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {FocusScope, useFocusManager, getFocusableTreeWalker, createFocusManager, isElementInChildOfActiveScope} from './FocusScope';\nexport {FocusRing} from './FocusRing';\nexport {useFocusRing} from './useFocusRing';\nexport {useHasTabbableChild} from './useHasTabbableChild';\nexport {moveVirtualFocus, dispatchVirtualBlur, dispatchVirtualFocus, getVirtuallyFocusedElement} from './virtualFocus';\n// For backward compatibility.\nexport {isFocusable} from '@react-aria/utils';\nexport {FocusableProvider, Focusable, useFocusable, focusSafely} from '@react-aria/interactions';\n\nexport type {FocusScopeProps, FocusManager, FocusManagerOptions} from './FocusScope';\nexport type {FocusRingProps} from './FocusRing';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from '@react-aria/interactions';\nexport type {AriaFocusRingProps, FocusRingAria} from './useFocusRing';\n"],"names":[],"version":3,"file":"types.d.ts.map"}

View File

@@ -0,0 +1,50 @@
var $7eRoM$reactariainteractions = require("@react-aria/interactions");
var $7eRoM$react = require("react");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "useFocusRing", () => $581a96d6eb128c1b$export$4e328f61c538687f);
function $581a96d6eb128c1b$export$4e328f61c538687f(props = {}) {
let { autoFocus: autoFocus = false, isTextInput: isTextInput, within: within } = props;
let state = (0, $7eRoM$react.useRef)({
isFocused: false,
isFocusVisible: autoFocus || (0, $7eRoM$reactariainteractions.isFocusVisible)()
});
let [isFocused, setFocused] = (0, $7eRoM$react.useState)(false);
let [isFocusVisibleState, setFocusVisible] = (0, $7eRoM$react.useState)(()=>state.current.isFocused && state.current.isFocusVisible);
let updateState = (0, $7eRoM$react.useCallback)(()=>setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);
let onFocusChange = (0, $7eRoM$react.useCallback)((isFocused)=>{
state.current.isFocused = isFocused;
setFocused(isFocused);
updateState();
}, [
updateState
]);
(0, $7eRoM$reactariainteractions.useFocusVisibleListener)((isFocusVisible)=>{
state.current.isFocusVisible = isFocusVisible;
updateState();
}, [], {
isTextInput: isTextInput
});
let { focusProps: focusProps } = (0, $7eRoM$reactariainteractions.useFocus)({
isDisabled: within,
onFocusChange: onFocusChange
});
let { focusWithinProps: focusWithinProps } = (0, $7eRoM$reactariainteractions.useFocusWithin)({
isDisabled: !within,
onFocusWithinChange: onFocusChange
});
return {
isFocused: isFocused,
isFocusVisible: isFocusVisibleState,
focusProps: within ? focusWithinProps : focusProps
};
}
//# sourceMappingURL=useFocusRing.main.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;;;;;;;;AAoCO,SAAS,0CAAa,QAA4B,CAAC,CAAC;IACzD,IAAI,aACF,YAAY,oBACZ,WAAW,UACX,MAAM,EACP,GAAG;IACJ,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAAE;QACjB,WAAW;QACX,gBAAgB,aAAa,CAAA,GAAA,2CAAa;IAC5C;IACA,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA,GAAA,qBAAO,EAAE;IACvC,IAAI,CAAC,qBAAqB,gBAAgB,GAAG,CAAA,GAAA,qBAAO,EAAE,IAAM,MAAM,OAAO,CAAC,SAAS,IAAI,MAAM,OAAO,CAAC,cAAc;IAEnH,IAAI,cAAc,CAAA,GAAA,wBAAU,EAAE,IAAM,gBAAgB,MAAM,OAAO,CAAC,SAAS,IAAI,MAAM,OAAO,CAAC,cAAc,GAAG,EAAE;IAEhH,IAAI,gBAAgB,CAAA,GAAA,wBAAU,EAAE,CAAA;QAC9B,MAAM,OAAO,CAAC,SAAS,GAAG;QAC1B,WAAW;QACX;IACF,GAAG;QAAC;KAAY;IAEhB,CAAA,GAAA,oDAAsB,EAAE,CAAC;QACvB,MAAM,OAAO,CAAC,cAAc,GAAG;QAC/B;IACF,GAAG,EAAE,EAAE;qBAAC;IAAW;IAEnB,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,YAAY;uBACZ;IACF;IAEA,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;QACtC,YAAY,CAAC;QACb,qBAAqB;IACvB;IAEA,OAAO;mBACL;QACA,gBAAgB;QAChB,YAAY,SAAS,mBAAmB;IAC1C;AACF","sources":["packages/@react-aria/focus/src/useFocusRing.ts"],"sourcesContent":["import {DOMAttributes} from '@react-types/shared';\nimport {isFocusVisible, useFocus, useFocusVisibleListener, useFocusWithin} from '@react-aria/interactions';\nimport {useCallback, useRef, useState} from 'react';\n\nexport interface AriaFocusRingProps {\n /**\n * Whether to show the focus ring when something\n * inside the container element has focus (true), or\n * only if the container itself has focus (false).\n * @default 'false'\n */\n within?: boolean,\n\n /** Whether the element is a text input. */\n isTextInput?: boolean,\n\n /** Whether the element will be auto focused. */\n autoFocus?: boolean\n}\n\nexport interface FocusRingAria {\n /** Whether the element is currently focused. */\n isFocused: boolean,\n\n /** Whether keyboard focus should be visible. */\n isFocusVisible: boolean,\n\n /** Props to apply to the container element with the focus ring. */\n focusProps: DOMAttributes\n}\n\n/**\n * Determines whether a focus ring should be shown to indicate keyboard focus.\n * Focus rings are visible only when the user is interacting with a keyboard,\n * not with a mouse, touch, or other input methods.\n */\nexport function useFocusRing(props: AriaFocusRingProps = {}): FocusRingAria {\n let {\n autoFocus = false,\n isTextInput,\n within\n } = props;\n let state = useRef({\n isFocused: false,\n isFocusVisible: autoFocus || isFocusVisible()\n });\n let [isFocused, setFocused] = useState(false);\n let [isFocusVisibleState, setFocusVisible] = useState(() => state.current.isFocused && state.current.isFocusVisible);\n\n let updateState = useCallback(() => setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);\n\n let onFocusChange = useCallback(isFocused => {\n state.current.isFocused = isFocused;\n setFocused(isFocused);\n updateState();\n }, [updateState]);\n\n useFocusVisibleListener((isFocusVisible) => {\n state.current.isFocusVisible = isFocusVisible;\n updateState();\n }, [], {isTextInput});\n\n let {focusProps} = useFocus({\n isDisabled: within,\n onFocusChange\n });\n\n let {focusWithinProps} = useFocusWithin({\n isDisabled: !within,\n onFocusWithinChange: onFocusChange\n });\n\n return {\n isFocused,\n isFocusVisible: isFocusVisibleState,\n focusProps: within ? focusWithinProps : focusProps\n };\n}\n"],"names":[],"version":3,"file":"useFocusRing.main.js.map"}

45
node_modules/@react-aria/focus/dist/useFocusRing.mjs generated vendored Normal file
View File

@@ -0,0 +1,45 @@
import {isFocusVisible as $isWE5$isFocusVisible, useFocusVisibleListener as $isWE5$useFocusVisibleListener, useFocus as $isWE5$useFocus, useFocusWithin as $isWE5$useFocusWithin} from "@react-aria/interactions";
import {useRef as $isWE5$useRef, useState as $isWE5$useState, useCallback as $isWE5$useCallback} from "react";
function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
let { autoFocus: autoFocus = false, isTextInput: isTextInput, within: within } = props;
let state = (0, $isWE5$useRef)({
isFocused: false,
isFocusVisible: autoFocus || (0, $isWE5$isFocusVisible)()
});
let [isFocused, setFocused] = (0, $isWE5$useState)(false);
let [isFocusVisibleState, setFocusVisible] = (0, $isWE5$useState)(()=>state.current.isFocused && state.current.isFocusVisible);
let updateState = (0, $isWE5$useCallback)(()=>setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);
let onFocusChange = (0, $isWE5$useCallback)((isFocused)=>{
state.current.isFocused = isFocused;
setFocused(isFocused);
updateState();
}, [
updateState
]);
(0, $isWE5$useFocusVisibleListener)((isFocusVisible)=>{
state.current.isFocusVisible = isFocusVisible;
updateState();
}, [], {
isTextInput: isTextInput
});
let { focusProps: focusProps } = (0, $isWE5$useFocus)({
isDisabled: within,
onFocusChange: onFocusChange
});
let { focusWithinProps: focusWithinProps } = (0, $isWE5$useFocusWithin)({
isDisabled: !within,
onFocusWithinChange: onFocusChange
});
return {
isFocused: isFocused,
isFocusVisible: isFocusVisibleState,
focusProps: within ? focusWithinProps : focusProps
};
}
export {$f7dceffc5ad7768b$export$4e328f61c538687f as useFocusRing};
//# sourceMappingURL=useFocusRing.module.js.map

View File

@@ -0,0 +1,45 @@
import {isFocusVisible as $isWE5$isFocusVisible, useFocusVisibleListener as $isWE5$useFocusVisibleListener, useFocus as $isWE5$useFocus, useFocusWithin as $isWE5$useFocusWithin} from "@react-aria/interactions";
import {useRef as $isWE5$useRef, useState as $isWE5$useState, useCallback as $isWE5$useCallback} from "react";
function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
let { autoFocus: autoFocus = false, isTextInput: isTextInput, within: within } = props;
let state = (0, $isWE5$useRef)({
isFocused: false,
isFocusVisible: autoFocus || (0, $isWE5$isFocusVisible)()
});
let [isFocused, setFocused] = (0, $isWE5$useState)(false);
let [isFocusVisibleState, setFocusVisible] = (0, $isWE5$useState)(()=>state.current.isFocused && state.current.isFocusVisible);
let updateState = (0, $isWE5$useCallback)(()=>setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);
let onFocusChange = (0, $isWE5$useCallback)((isFocused)=>{
state.current.isFocused = isFocused;
setFocused(isFocused);
updateState();
}, [
updateState
]);
(0, $isWE5$useFocusVisibleListener)((isFocusVisible)=>{
state.current.isFocusVisible = isFocusVisible;
updateState();
}, [], {
isTextInput: isTextInput
});
let { focusProps: focusProps } = (0, $isWE5$useFocus)({
isDisabled: within,
onFocusChange: onFocusChange
});
let { focusWithinProps: focusWithinProps } = (0, $isWE5$useFocusWithin)({
isDisabled: !within,
onFocusWithinChange: onFocusChange
});
return {
isFocused: isFocused,
isFocusVisible: isFocusVisibleState,
focusProps: within ? focusWithinProps : focusProps
};
}
export {$f7dceffc5ad7768b$export$4e328f61c538687f as useFocusRing};
//# sourceMappingURL=useFocusRing.module.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;;AAoCO,SAAS,0CAAa,QAA4B,CAAC,CAAC;IACzD,IAAI,aACF,YAAY,oBACZ,WAAW,UACX,MAAM,EACP,GAAG;IACJ,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;QACjB,WAAW;QACX,gBAAgB,aAAa,CAAA,GAAA,qBAAa;IAC5C;IACA,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA,GAAA,eAAO,EAAE;IACvC,IAAI,CAAC,qBAAqB,gBAAgB,GAAG,CAAA,GAAA,eAAO,EAAE,IAAM,MAAM,OAAO,CAAC,SAAS,IAAI,MAAM,OAAO,CAAC,cAAc;IAEnH,IAAI,cAAc,CAAA,GAAA,kBAAU,EAAE,IAAM,gBAAgB,MAAM,OAAO,CAAC,SAAS,IAAI,MAAM,OAAO,CAAC,cAAc,GAAG,EAAE;IAEhH,IAAI,gBAAgB,CAAA,GAAA,kBAAU,EAAE,CAAA;QAC9B,MAAM,OAAO,CAAC,SAAS,GAAG;QAC1B,WAAW;QACX;IACF,GAAG;QAAC;KAAY;IAEhB,CAAA,GAAA,8BAAsB,EAAE,CAAC;QACvB,MAAM,OAAO,CAAC,cAAc,GAAG;QAC/B;IACF,GAAG,EAAE,EAAE;qBAAC;IAAW;IAEnB,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,YAAY;uBACZ;IACF;IAEA,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,YAAY,CAAC;QACb,qBAAqB;IACvB;IAEA,OAAO;mBACL;QACA,gBAAgB;QAChB,YAAY,SAAS,mBAAmB;IAC1C;AACF","sources":["packages/@react-aria/focus/src/useFocusRing.ts"],"sourcesContent":["import {DOMAttributes} from '@react-types/shared';\nimport {isFocusVisible, useFocus, useFocusVisibleListener, useFocusWithin} from '@react-aria/interactions';\nimport {useCallback, useRef, useState} from 'react';\n\nexport interface AriaFocusRingProps {\n /**\n * Whether to show the focus ring when something\n * inside the container element has focus (true), or\n * only if the container itself has focus (false).\n * @default 'false'\n */\n within?: boolean,\n\n /** Whether the element is a text input. */\n isTextInput?: boolean,\n\n /** Whether the element will be auto focused. */\n autoFocus?: boolean\n}\n\nexport interface FocusRingAria {\n /** Whether the element is currently focused. */\n isFocused: boolean,\n\n /** Whether keyboard focus should be visible. */\n isFocusVisible: boolean,\n\n /** Props to apply to the container element with the focus ring. */\n focusProps: DOMAttributes\n}\n\n/**\n * Determines whether a focus ring should be shown to indicate keyboard focus.\n * Focus rings are visible only when the user is interacting with a keyboard,\n * not with a mouse, touch, or other input methods.\n */\nexport function useFocusRing(props: AriaFocusRingProps = {}): FocusRingAria {\n let {\n autoFocus = false,\n isTextInput,\n within\n } = props;\n let state = useRef({\n isFocused: false,\n isFocusVisible: autoFocus || isFocusVisible()\n });\n let [isFocused, setFocused] = useState(false);\n let [isFocusVisibleState, setFocusVisible] = useState(() => state.current.isFocused && state.current.isFocusVisible);\n\n let updateState = useCallback(() => setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);\n\n let onFocusChange = useCallback(isFocused => {\n state.current.isFocused = isFocused;\n setFocused(isFocused);\n updateState();\n }, [updateState]);\n\n useFocusVisibleListener((isFocusVisible) => {\n state.current.isFocusVisible = isFocusVisible;\n updateState();\n }, [], {isTextInput});\n\n let {focusProps} = useFocus({\n isDisabled: within,\n onFocusChange\n });\n\n let {focusWithinProps} = useFocusWithin({\n isDisabled: !within,\n onFocusWithinChange: onFocusChange\n });\n\n return {\n isFocused,\n isFocusVisible: isFocusVisibleState,\n focusProps: within ? focusWithinProps : focusProps\n };\n}\n"],"names":[],"version":3,"file":"useFocusRing.module.js.map"}

View File

@@ -0,0 +1,62 @@
var $a7a032acae3ddda9$exports = require("./FocusScope.main.js");
var $6RLDH$reactariautils = require("@react-aria/utils");
var $6RLDH$react = require("react");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "useHasTabbableChild", () => $259c6413a286f2e6$export$eac1895992b9f3d6);
/*
* Copyright 2022 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $259c6413a286f2e6$export$eac1895992b9f3d6(ref, options) {
let isDisabled = options === null || options === void 0 ? void 0 : options.isDisabled;
let [hasTabbableChild, setHasTabbableChild] = (0, $6RLDH$react.useState)(false);
(0, $6RLDH$reactariautils.useLayoutEffect)(()=>{
if ((ref === null || ref === void 0 ? void 0 : ref.current) && !isDisabled) {
let update = ()=>{
if (ref.current) {
let walker = (0, $a7a032acae3ddda9$exports.getFocusableTreeWalker)(ref.current, {
tabbable: true
});
setHasTabbableChild(!!walker.nextNode());
}
};
update();
// Update when new elements are inserted, or the tabIndex/disabled attribute updates.
let observer = new MutationObserver(update);
observer.observe(ref.current, {
subtree: true,
childList: true,
attributes: true,
attributeFilter: [
'tabIndex',
'disabled'
]
});
return ()=>{
// Disconnect mutation observer when a React update occurs on the top-level component
// so we update synchronously after re-rendering. Otherwise React will emit act warnings
// in tests since mutation observers fire asynchronously. The mutation observer is necessary
// so we also update if a child component re-renders and adds/removes something tabbable.
observer.disconnect();
};
}
});
return isDisabled ? false : hasTabbableChild;
}
//# sourceMappingURL=useHasTabbableChild.main.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAoBM,SAAS,0CAAoB,GAA8B,EAAE,OAAqC;IACvG,IAAI,aAAa,oBAAA,8BAAA,QAAS,UAAU;IACpC,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEvD,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,CAAA,gBAAA,0BAAA,IAAK,OAAO,KAAI,CAAC,YAAY;YAC/B,IAAI,SAAS;gBACX,IAAI,IAAI,OAAO,EAAE;oBACf,IAAI,SAAS,CAAA,GAAA,gDAAqB,EAAE,IAAI,OAAO,EAAE;wBAAC,UAAU;oBAAI;oBAChE,oBAAoB,CAAC,CAAC,OAAO,QAAQ;gBACvC;YACF;YAEA;YAEA,qFAAqF;YACrF,IAAI,WAAW,IAAI,iBAAiB;YACpC,SAAS,OAAO,CAAC,IAAI,OAAO,EAAE;gBAC5B,SAAS;gBACT,WAAW;gBACX,YAAY;gBACZ,iBAAiB;oBAAC;oBAAY;iBAAW;YAC3C;YAEA,OAAO;gBACL,qFAAqF;gBACrF,wFAAwF;gBACxF,4FAA4F;gBAC5F,yFAAyF;gBACzF,SAAS,UAAU;YACrB;QACF;IACF;IAEA,OAAO,aAAa,QAAQ;AAC9B","sources":["packages/@react-aria/focus/src/useHasTabbableChild.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getFocusableTreeWalker} from './FocusScope';\nimport {RefObject} from '@react-types/shared';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useState} from 'react';\n\ninterface AriaHasTabbableChildOptions {\n isDisabled?: boolean\n}\n\n// This was created for a special empty case of a component that can have child or\n// be empty, like Collection/Virtualizer/Table/ListView/etc. When these components\n// are empty they can have a message with a tabbable element, which is like them\n// being not empty, when it comes to focus and tab order.\n\n/**\n * Returns whether an element has a tabbable child, and updates as children change.\n * @private\n */\nexport function useHasTabbableChild(ref: RefObject<Element | null>, options?: AriaHasTabbableChildOptions): boolean {\n let isDisabled = options?.isDisabled;\n let [hasTabbableChild, setHasTabbableChild] = useState(false);\n\n useLayoutEffect(() => {\n if (ref?.current && !isDisabled) {\n let update = () => {\n if (ref.current) {\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setHasTabbableChild(!!walker.nextNode());\n }\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n // Disconnect mutation observer when a React update occurs on the top-level component\n // so we update synchronously after re-rendering. Otherwise React will emit act warnings\n // in tests since mutation observers fire asynchronously. The mutation observer is necessary\n // so we also update if a child component re-renders and adds/removes something tabbable.\n observer.disconnect();\n };\n }\n });\n\n return isDisabled ? false : hasTabbableChild;\n}\n"],"names":[],"version":3,"file":"useHasTabbableChild.main.js.map"}

View File

@@ -0,0 +1,57 @@
import {getFocusableTreeWalker as $9bf71ea28793e738$export$2d6ec8fc375ceafa} from "./FocusScope.mjs";
import {useLayoutEffect as $hGAaG$useLayoutEffect} from "@react-aria/utils";
import {useState as $hGAaG$useState} from "react";
/*
* Copyright 2022 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $83013635b024ae3d$export$eac1895992b9f3d6(ref, options) {
let isDisabled = options === null || options === void 0 ? void 0 : options.isDisabled;
let [hasTabbableChild, setHasTabbableChild] = (0, $hGAaG$useState)(false);
(0, $hGAaG$useLayoutEffect)(()=>{
if ((ref === null || ref === void 0 ? void 0 : ref.current) && !isDisabled) {
let update = ()=>{
if (ref.current) {
let walker = (0, $9bf71ea28793e738$export$2d6ec8fc375ceafa)(ref.current, {
tabbable: true
});
setHasTabbableChild(!!walker.nextNode());
}
};
update();
// Update when new elements are inserted, or the tabIndex/disabled attribute updates.
let observer = new MutationObserver(update);
observer.observe(ref.current, {
subtree: true,
childList: true,
attributes: true,
attributeFilter: [
'tabIndex',
'disabled'
]
});
return ()=>{
// Disconnect mutation observer when a React update occurs on the top-level component
// so we update synchronously after re-rendering. Otherwise React will emit act warnings
// in tests since mutation observers fire asynchronously. The mutation observer is necessary
// so we also update if a child component re-renders and adds/removes something tabbable.
observer.disconnect();
};
}
});
return isDisabled ? false : hasTabbableChild;
}
export {$83013635b024ae3d$export$eac1895992b9f3d6 as useHasTabbableChild};
//# sourceMappingURL=useHasTabbableChild.module.js.map

View File

@@ -0,0 +1,57 @@
import {getFocusableTreeWalker as $9bf71ea28793e738$export$2d6ec8fc375ceafa} from "./FocusScope.module.js";
import {useLayoutEffect as $hGAaG$useLayoutEffect} from "@react-aria/utils";
import {useState as $hGAaG$useState} from "react";
/*
* Copyright 2022 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $83013635b024ae3d$export$eac1895992b9f3d6(ref, options) {
let isDisabled = options === null || options === void 0 ? void 0 : options.isDisabled;
let [hasTabbableChild, setHasTabbableChild] = (0, $hGAaG$useState)(false);
(0, $hGAaG$useLayoutEffect)(()=>{
if ((ref === null || ref === void 0 ? void 0 : ref.current) && !isDisabled) {
let update = ()=>{
if (ref.current) {
let walker = (0, $9bf71ea28793e738$export$2d6ec8fc375ceafa)(ref.current, {
tabbable: true
});
setHasTabbableChild(!!walker.nextNode());
}
};
update();
// Update when new elements are inserted, or the tabIndex/disabled attribute updates.
let observer = new MutationObserver(update);
observer.observe(ref.current, {
subtree: true,
childList: true,
attributes: true,
attributeFilter: [
'tabIndex',
'disabled'
]
});
return ()=>{
// Disconnect mutation observer when a React update occurs on the top-level component
// so we update synchronously after re-rendering. Otherwise React will emit act warnings
// in tests since mutation observers fire asynchronously. The mutation observer is necessary
// so we also update if a child component re-renders and adds/removes something tabbable.
observer.disconnect();
};
}
});
return isDisabled ? false : hasTabbableChild;
}
export {$83013635b024ae3d$export$eac1895992b9f3d6 as useHasTabbableChild};
//# sourceMappingURL=useHasTabbableChild.module.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAoBM,SAAS,0CAAoB,GAA8B,EAAE,OAAqC;IACvG,IAAI,aAAa,oBAAA,8BAAA,QAAS,UAAU;IACpC,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvD,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,CAAA,gBAAA,0BAAA,IAAK,OAAO,KAAI,CAAC,YAAY;YAC/B,IAAI,SAAS;gBACX,IAAI,IAAI,OAAO,EAAE;oBACf,IAAI,SAAS,CAAA,GAAA,yCAAqB,EAAE,IAAI,OAAO,EAAE;wBAAC,UAAU;oBAAI;oBAChE,oBAAoB,CAAC,CAAC,OAAO,QAAQ;gBACvC;YACF;YAEA;YAEA,qFAAqF;YACrF,IAAI,WAAW,IAAI,iBAAiB;YACpC,SAAS,OAAO,CAAC,IAAI,OAAO,EAAE;gBAC5B,SAAS;gBACT,WAAW;gBACX,YAAY;gBACZ,iBAAiB;oBAAC;oBAAY;iBAAW;YAC3C;YAEA,OAAO;gBACL,qFAAqF;gBACrF,wFAAwF;gBACxF,4FAA4F;gBAC5F,yFAAyF;gBACzF,SAAS,UAAU;YACrB;QACF;IACF;IAEA,OAAO,aAAa,QAAQ;AAC9B","sources":["packages/@react-aria/focus/src/useHasTabbableChild.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getFocusableTreeWalker} from './FocusScope';\nimport {RefObject} from '@react-types/shared';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useState} from 'react';\n\ninterface AriaHasTabbableChildOptions {\n isDisabled?: boolean\n}\n\n// This was created for a special empty case of a component that can have child or\n// be empty, like Collection/Virtualizer/Table/ListView/etc. When these components\n// are empty they can have a message with a tabbable element, which is like them\n// being not empty, when it comes to focus and tab order.\n\n/**\n * Returns whether an element has a tabbable child, and updates as children change.\n * @private\n */\nexport function useHasTabbableChild(ref: RefObject<Element | null>, options?: AriaHasTabbableChildOptions): boolean {\n let isDisabled = options?.isDisabled;\n let [hasTabbableChild, setHasTabbableChild] = useState(false);\n\n useLayoutEffect(() => {\n if (ref?.current && !isDisabled) {\n let update = () => {\n if (ref.current) {\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setHasTabbableChild(!!walker.nextNode());\n }\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n // Disconnect mutation observer when a React update occurs on the top-level component\n // so we update synchronously after re-rendering. Otherwise React will emit act warnings\n // in tests since mutation observers fire asynchronously. The mutation observer is necessary\n // so we also update if a child component re-renders and adds/removes something tabbable.\n observer.disconnect();\n };\n }\n });\n\n return isDisabled ? false : hasTabbableChild;\n}\n"],"names":[],"version":3,"file":"useHasTabbableChild.module.js.map"}

View File

@@ -0,0 +1,46 @@
var $jMsK8$reactariautils = require("@react-aria/utils");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "moveVirtualFocus", () => $a756eb2d3b28d089$export$76e4e37e5339496d);
$parcel$export(module.exports, "getVirtuallyFocusedElement", () => $a756eb2d3b28d089$export$759df0d867455a91);
$parcel$export(module.exports, "dispatchVirtualBlur", () => $a756eb2d3b28d089$export$6c5dc7e81d2cc29a);
$parcel$export(module.exports, "dispatchVirtualFocus", () => $a756eb2d3b28d089$export$2b35b76d2e30e129);
function $a756eb2d3b28d089$export$76e4e37e5339496d(to) {
let from = $a756eb2d3b28d089$export$759df0d867455a91((0, $jMsK8$reactariautils.getOwnerDocument)(to));
if (from !== to) {
if (from) $a756eb2d3b28d089$export$6c5dc7e81d2cc29a(from, to);
if (to) $a756eb2d3b28d089$export$2b35b76d2e30e129(to, from);
}
}
function $a756eb2d3b28d089$export$6c5dc7e81d2cc29a(from, to) {
from.dispatchEvent(new FocusEvent('blur', {
relatedTarget: to
}));
from.dispatchEvent(new FocusEvent('focusout', {
bubbles: true,
relatedTarget: to
}));
}
function $a756eb2d3b28d089$export$2b35b76d2e30e129(to, from) {
to.dispatchEvent(new FocusEvent('focus', {
relatedTarget: from
}));
to.dispatchEvent(new FocusEvent('focusin', {
bubbles: true,
relatedTarget: from
}));
}
function $a756eb2d3b28d089$export$759df0d867455a91(document) {
let activeElement = (0, $jMsK8$reactariautils.getActiveElement)(document);
let activeDescendant = activeElement === null || activeElement === void 0 ? void 0 : activeElement.getAttribute('aria-activedescendant');
if (activeDescendant) return document.getElementById(activeDescendant) || activeElement;
return activeElement;
}
//# sourceMappingURL=virtualFocus.main.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;;;;;;;;;AAEO,SAAS,0CAAiB,EAAkB;IACjD,IAAI,OAAO,0CAA2B,CAAA,GAAA,sCAAe,EAAE;IACvD,IAAI,SAAS,IAAI;QACf,IAAI,MACF,0CAAoB,MAAM;QAE5B,IAAI,IACF,0CAAqB,IAAI;IAE7B;AACF;AAEO,SAAS,0CAAoB,IAAa,EAAE,EAAkB;IACnE,KAAK,aAAa,CAAC,IAAI,WAAW,QAAQ;QAAC,eAAe;IAAE;IAC5D,KAAK,aAAa,CAAC,IAAI,WAAW,YAAY;QAAC,SAAS;QAAM,eAAe;IAAE;AACjF;AAEO,SAAS,0CAAqB,EAAW,EAAE,IAAoB;IACpE,GAAG,aAAa,CAAC,IAAI,WAAW,SAAS;QAAC,eAAe;IAAI;IAC7D,GAAG,aAAa,CAAC,IAAI,WAAW,WAAW;QAAC,SAAS;QAAM,eAAe;IAAI;AAChF;AAEO,SAAS,0CAA2B,QAAkB;IAC3D,IAAI,gBAAgB,CAAA,GAAA,sCAAe,EAAE;IACrC,IAAI,mBAAmB,0BAAA,oCAAA,cAAe,YAAY,CAAC;IACnD,IAAI,kBACF,OAAO,SAAS,cAAc,CAAC,qBAAqB;IAGtD,OAAO;AACT","sources":["packages/@react-aria/focus/src/virtualFocus.ts"],"sourcesContent":["import {getActiveElement, getOwnerDocument} from '@react-aria/utils';\n\nexport function moveVirtualFocus(to: Element | null): void {\n let from = getVirtuallyFocusedElement(getOwnerDocument(to));\n if (from !== to) {\n if (from) {\n dispatchVirtualBlur(from, to);\n }\n if (to) {\n dispatchVirtualFocus(to, from);\n }\n }\n}\n\nexport function dispatchVirtualBlur(from: Element, to: Element | null): void {\n from.dispatchEvent(new FocusEvent('blur', {relatedTarget: to}));\n from.dispatchEvent(new FocusEvent('focusout', {bubbles: true, relatedTarget: to}));\n}\n\nexport function dispatchVirtualFocus(to: Element, from: Element | null): void {\n to.dispatchEvent(new FocusEvent('focus', {relatedTarget: from}));\n to.dispatchEvent(new FocusEvent('focusin', {bubbles: true, relatedTarget: from}));\n}\n\nexport function getVirtuallyFocusedElement(document: Document): Element | null {\n let activeElement = getActiveElement(document);\n let activeDescendant = activeElement?.getAttribute('aria-activedescendant');\n if (activeDescendant) {\n return document.getElementById(activeDescendant) || activeElement;\n }\n\n return activeElement;\n}\n"],"names":[],"version":3,"file":"virtualFocus.main.js.map"}

38
node_modules/@react-aria/focus/dist/virtualFocus.mjs generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import {getOwnerDocument as $hpDQO$getOwnerDocument, getActiveElement as $hpDQO$getActiveElement} from "@react-aria/utils";
function $55f9b1ae81f22853$export$76e4e37e5339496d(to) {
let from = $55f9b1ae81f22853$export$759df0d867455a91((0, $hpDQO$getOwnerDocument)(to));
if (from !== to) {
if (from) $55f9b1ae81f22853$export$6c5dc7e81d2cc29a(from, to);
if (to) $55f9b1ae81f22853$export$2b35b76d2e30e129(to, from);
}
}
function $55f9b1ae81f22853$export$6c5dc7e81d2cc29a(from, to) {
from.dispatchEvent(new FocusEvent('blur', {
relatedTarget: to
}));
from.dispatchEvent(new FocusEvent('focusout', {
bubbles: true,
relatedTarget: to
}));
}
function $55f9b1ae81f22853$export$2b35b76d2e30e129(to, from) {
to.dispatchEvent(new FocusEvent('focus', {
relatedTarget: from
}));
to.dispatchEvent(new FocusEvent('focusin', {
bubbles: true,
relatedTarget: from
}));
}
function $55f9b1ae81f22853$export$759df0d867455a91(document) {
let activeElement = (0, $hpDQO$getActiveElement)(document);
let activeDescendant = activeElement === null || activeElement === void 0 ? void 0 : activeElement.getAttribute('aria-activedescendant');
if (activeDescendant) return document.getElementById(activeDescendant) || activeElement;
return activeElement;
}
export {$55f9b1ae81f22853$export$76e4e37e5339496d as moveVirtualFocus, $55f9b1ae81f22853$export$759df0d867455a91 as getVirtuallyFocusedElement, $55f9b1ae81f22853$export$6c5dc7e81d2cc29a as dispatchVirtualBlur, $55f9b1ae81f22853$export$2b35b76d2e30e129 as dispatchVirtualFocus};
//# sourceMappingURL=virtualFocus.module.js.map

View File

@@ -0,0 +1,38 @@
import {getOwnerDocument as $hpDQO$getOwnerDocument, getActiveElement as $hpDQO$getActiveElement} from "@react-aria/utils";
function $55f9b1ae81f22853$export$76e4e37e5339496d(to) {
let from = $55f9b1ae81f22853$export$759df0d867455a91((0, $hpDQO$getOwnerDocument)(to));
if (from !== to) {
if (from) $55f9b1ae81f22853$export$6c5dc7e81d2cc29a(from, to);
if (to) $55f9b1ae81f22853$export$2b35b76d2e30e129(to, from);
}
}
function $55f9b1ae81f22853$export$6c5dc7e81d2cc29a(from, to) {
from.dispatchEvent(new FocusEvent('blur', {
relatedTarget: to
}));
from.dispatchEvent(new FocusEvent('focusout', {
bubbles: true,
relatedTarget: to
}));
}
function $55f9b1ae81f22853$export$2b35b76d2e30e129(to, from) {
to.dispatchEvent(new FocusEvent('focus', {
relatedTarget: from
}));
to.dispatchEvent(new FocusEvent('focusin', {
bubbles: true,
relatedTarget: from
}));
}
function $55f9b1ae81f22853$export$759df0d867455a91(document) {
let activeElement = (0, $hpDQO$getActiveElement)(document);
let activeDescendant = activeElement === null || activeElement === void 0 ? void 0 : activeElement.getAttribute('aria-activedescendant');
if (activeDescendant) return document.getElementById(activeDescendant) || activeElement;
return activeElement;
}
export {$55f9b1ae81f22853$export$76e4e37e5339496d as moveVirtualFocus, $55f9b1ae81f22853$export$759df0d867455a91 as getVirtuallyFocusedElement, $55f9b1ae81f22853$export$6c5dc7e81d2cc29a as dispatchVirtualBlur, $55f9b1ae81f22853$export$2b35b76d2e30e129 as dispatchVirtualFocus};
//# sourceMappingURL=virtualFocus.module.js.map

View File

@@ -0,0 +1 @@
{"mappings":";;;AAEO,SAAS,0CAAiB,EAAkB;IACjD,IAAI,OAAO,0CAA2B,CAAA,GAAA,uBAAe,EAAE;IACvD,IAAI,SAAS,IAAI;QACf,IAAI,MACF,0CAAoB,MAAM;QAE5B,IAAI,IACF,0CAAqB,IAAI;IAE7B;AACF;AAEO,SAAS,0CAAoB,IAAa,EAAE,EAAkB;IACnE,KAAK,aAAa,CAAC,IAAI,WAAW,QAAQ;QAAC,eAAe;IAAE;IAC5D,KAAK,aAAa,CAAC,IAAI,WAAW,YAAY;QAAC,SAAS;QAAM,eAAe;IAAE;AACjF;AAEO,SAAS,0CAAqB,EAAW,EAAE,IAAoB;IACpE,GAAG,aAAa,CAAC,IAAI,WAAW,SAAS;QAAC,eAAe;IAAI;IAC7D,GAAG,aAAa,CAAC,IAAI,WAAW,WAAW;QAAC,SAAS;QAAM,eAAe;IAAI;AAChF;AAEO,SAAS,0CAA2B,QAAkB;IAC3D,IAAI,gBAAgB,CAAA,GAAA,uBAAe,EAAE;IACrC,IAAI,mBAAmB,0BAAA,oCAAA,cAAe,YAAY,CAAC;IACnD,IAAI,kBACF,OAAO,SAAS,cAAc,CAAC,qBAAqB;IAGtD,OAAO;AACT","sources":["packages/@react-aria/focus/src/virtualFocus.ts"],"sourcesContent":["import {getActiveElement, getOwnerDocument} from '@react-aria/utils';\n\nexport function moveVirtualFocus(to: Element | null): void {\n let from = getVirtuallyFocusedElement(getOwnerDocument(to));\n if (from !== to) {\n if (from) {\n dispatchVirtualBlur(from, to);\n }\n if (to) {\n dispatchVirtualFocus(to, from);\n }\n }\n}\n\nexport function dispatchVirtualBlur(from: Element, to: Element | null): void {\n from.dispatchEvent(new FocusEvent('blur', {relatedTarget: to}));\n from.dispatchEvent(new FocusEvent('focusout', {bubbles: true, relatedTarget: to}));\n}\n\nexport function dispatchVirtualFocus(to: Element, from: Element | null): void {\n to.dispatchEvent(new FocusEvent('focus', {relatedTarget: from}));\n to.dispatchEvent(new FocusEvent('focusin', {bubbles: true, relatedTarget: from}));\n}\n\nexport function getVirtuallyFocusedElement(document: Document): Element | null {\n let activeElement = getActiveElement(document);\n let activeDescendant = activeElement?.getAttribute('aria-activedescendant');\n if (activeDescendant) {\n return document.getElementById(activeDescendant) || activeElement;\n }\n\n return activeElement;\n}\n"],"names":[],"version":3,"file":"virtualFocus.module.js.map"}