@react-aria/focus 3.14.1 → 3.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +23 -23
- package/dist/main.js +23 -23
- package/dist/main.js.map +1 -1
- package/dist/module.js +23 -23
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
package/dist/import.mjs
CHANGED
|
@@ -63,11 +63,11 @@ function $6a99195332edec8b$export$80f3e147d781571c(element) {
|
|
|
63
63
|
* governing permissions and limitations under the License.
|
|
64
64
|
*/ function $645f2e67b85a24c9$var$isStyleVisible(element) {
|
|
65
65
|
if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) return false;
|
|
66
|
-
let { display: display
|
|
66
|
+
let { display: display, visibility: visibility } = element.style;
|
|
67
67
|
let isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
|
|
68
68
|
if (isVisible) {
|
|
69
|
-
const { getComputedStyle: getComputedStyle
|
|
70
|
-
let { display: computedDisplay
|
|
69
|
+
const { getComputedStyle: getComputedStyle } = element.ownerDocument.defaultView;
|
|
70
|
+
let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
|
|
71
71
|
isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
|
|
72
72
|
}
|
|
73
73
|
return isVisible;
|
|
@@ -85,11 +85,11 @@ function $645f2e67b85a24c9$export$e989c0fffaa6b27a(element, childElement) {
|
|
|
85
85
|
const $9bf71ea28793e738$var$FocusContext = /*#__PURE__*/ (0, $6nfFC$react).createContext(null);
|
|
86
86
|
let $9bf71ea28793e738$var$activeScope = null;
|
|
87
87
|
function $9bf71ea28793e738$export$20e40289641fbbb6(props) {
|
|
88
|
-
let { children: children
|
|
88
|
+
let { children: children, contain: contain, restoreFocus: restoreFocus, autoFocus: autoFocus } = props;
|
|
89
89
|
let startRef = (0, $6nfFC$useRef)();
|
|
90
90
|
let endRef = (0, $6nfFC$useRef)();
|
|
91
91
|
let scopeRef = (0, $6nfFC$useRef)([]);
|
|
92
|
-
let { parentNode: parentNode
|
|
92
|
+
let { parentNode: parentNode } = (0, $6nfFC$useContext)($9bf71ea28793e738$var$FocusContext) || {};
|
|
93
93
|
// Create a tree node here so we can add children to it even before it is added to the tree.
|
|
94
94
|
let node = (0, $6nfFC$useMemo)(()=>new $9bf71ea28793e738$var$TreeNode({
|
|
95
95
|
scopeRef: scopeRef
|
|
@@ -189,7 +189,7 @@ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
|
|
189
189
|
return {
|
|
190
190
|
focusNext (opts = {}) {
|
|
191
191
|
let scope = scopeRef.current;
|
|
192
|
-
let { from: from
|
|
192
|
+
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
|
|
193
193
|
let node = from || document.activeElement;
|
|
194
194
|
let sentinel = scope[0].previousElementSibling;
|
|
195
195
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
|
|
@@ -207,7 +207,7 @@ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
|
|
207
207
|
},
|
|
208
208
|
focusPrevious (opts = {}) {
|
|
209
209
|
let scope = scopeRef.current;
|
|
210
|
-
let { from: from
|
|
210
|
+
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
|
|
211
211
|
let node = from || document.activeElement;
|
|
212
212
|
let sentinel = scope[scope.length - 1].nextElementSibling;
|
|
213
213
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
|
|
@@ -225,7 +225,7 @@ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
|
|
225
225
|
},
|
|
226
226
|
focusFirst (opts = {}) {
|
|
227
227
|
let scope = scopeRef.current;
|
|
228
|
-
let { tabbable: tabbable
|
|
228
|
+
let { tabbable: tabbable, accept: accept } = opts;
|
|
229
229
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
|
|
230
230
|
tabbable: tabbable,
|
|
231
231
|
accept: accept
|
|
@@ -237,7 +237,7 @@ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
|
|
237
237
|
},
|
|
238
238
|
focusLast (opts = {}) {
|
|
239
239
|
let scope = scopeRef.current;
|
|
240
|
-
let { tabbable: tabbable
|
|
240
|
+
let { tabbable: tabbable, accept: accept } = opts;
|
|
241
241
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
|
|
242
242
|
tabbable: tabbable,
|
|
243
243
|
accept: accept
|
|
@@ -371,7 +371,7 @@ function $9bf71ea28793e738$var$isElementInChildScope(element, scope = null) {
|
|
|
371
371
|
if (element instanceof Element && element.closest("[data-react-aria-top-layer]")) return true;
|
|
372
372
|
// node.contains in isElementInScope covers child scopes that are also DOM children,
|
|
373
373
|
// but does not cover child scopes in portals.
|
|
374
|
-
for (let { scopeRef: s
|
|
374
|
+
for (let { scopeRef: s } of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope))){
|
|
375
375
|
if ($9bf71ea28793e738$var$isElementInScope(element, s.current)) return true;
|
|
376
376
|
}
|
|
377
377
|
return false;
|
|
@@ -593,7 +593,7 @@ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
593
593
|
focusNext (opts = {}) {
|
|
594
594
|
let root = ref.current;
|
|
595
595
|
if (!root) return;
|
|
596
|
-
let { from: from
|
|
596
|
+
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
|
|
597
597
|
let node = from || document.activeElement;
|
|
598
598
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
|
|
599
599
|
tabbable: tabbable,
|
|
@@ -611,7 +611,7 @@ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
611
611
|
focusPrevious (opts = defaultOptions) {
|
|
612
612
|
let root = ref.current;
|
|
613
613
|
if (!root) return;
|
|
614
|
-
let { from: from
|
|
614
|
+
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
|
|
615
615
|
let node = from || document.activeElement;
|
|
616
616
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
|
|
617
617
|
tabbable: tabbable,
|
|
@@ -634,7 +634,7 @@ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
634
634
|
focusFirst (opts = defaultOptions) {
|
|
635
635
|
let root = ref.current;
|
|
636
636
|
if (!root) return;
|
|
637
|
-
let { tabbable: tabbable = defaultOptions.tabbable
|
|
637
|
+
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
|
|
638
638
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
|
|
639
639
|
tabbable: tabbable,
|
|
640
640
|
accept: accept
|
|
@@ -646,7 +646,7 @@ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
646
646
|
focusLast (opts = defaultOptions) {
|
|
647
647
|
let root = ref.current;
|
|
648
648
|
if (!root) return;
|
|
649
|
-
let { tabbable: tabbable = defaultOptions.tabbable
|
|
649
|
+
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
|
|
650
650
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
|
|
651
651
|
tabbable: tabbable,
|
|
652
652
|
accept: accept
|
|
@@ -751,7 +751,7 @@ let $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree()
|
|
|
751
751
|
|
|
752
752
|
|
|
753
753
|
function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
|
|
754
|
-
let { autoFocus: autoFocus = false
|
|
754
|
+
let { autoFocus: autoFocus = false, isTextInput: isTextInput, within: within } = props;
|
|
755
755
|
let state = (0, $6nfFC$useRef)({
|
|
756
756
|
isFocused: false,
|
|
757
757
|
isFocusVisible: autoFocus || (0, $6nfFC$isFocusVisible)()
|
|
@@ -772,11 +772,11 @@ function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
|
|
|
772
772
|
}, [], {
|
|
773
773
|
isTextInput: isTextInput
|
|
774
774
|
});
|
|
775
|
-
let { focusProps: focusProps
|
|
775
|
+
let { focusProps: focusProps } = (0, $6nfFC$useFocus)({
|
|
776
776
|
isDisabled: within,
|
|
777
777
|
onFocusChange: onFocusChange
|
|
778
778
|
});
|
|
779
|
-
let { focusWithinProps: focusWithinProps
|
|
779
|
+
let { focusWithinProps: focusWithinProps } = (0, $6nfFC$useFocusWithin)({
|
|
780
780
|
isDisabled: !within,
|
|
781
781
|
onFocusWithinChange: onFocusChange
|
|
782
782
|
});
|
|
@@ -789,8 +789,8 @@ function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
|
|
|
789
789
|
|
|
790
790
|
|
|
791
791
|
function $907718708eab68af$export$1a38b4ad7f578e1d(props) {
|
|
792
|
-
let { children: children
|
|
793
|
-
let { isFocused: isFocused
|
|
792
|
+
let { children: children, focusClass: focusClass, focusRingClass: focusRingClass } = props;
|
|
793
|
+
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $f7dceffc5ad7768b$export$4e328f61c538687f)(props);
|
|
794
794
|
let child = (0, $6nfFC$react).Children.only(children);
|
|
795
795
|
return /*#__PURE__*/ (0, $6nfFC$react).cloneElement(child, (0, $6nfFC$mergeProps)(child.props, {
|
|
796
796
|
...focusProps,
|
|
@@ -821,13 +821,13 @@ function $e6afbd83fe6ebbd2$var$useFocusableContext(ref) {
|
|
|
821
821
|
let context = (0, $6nfFC$useContext)($e6afbd83fe6ebbd2$var$FocusableContext) || {};
|
|
822
822
|
(0, $6nfFC$useSyncRef)(context, ref);
|
|
823
823
|
// eslint-disable-next-line
|
|
824
|
-
let { ref: _
|
|
824
|
+
let { ref: _, ...otherProps } = context;
|
|
825
825
|
return otherProps;
|
|
826
826
|
}
|
|
827
827
|
/**
|
|
828
828
|
* Provides DOM props to the nearest focusable child.
|
|
829
829
|
*/ function $e6afbd83fe6ebbd2$var$FocusableProvider(props, ref) {
|
|
830
|
-
let { children: children
|
|
830
|
+
let { children: children, ...otherProps } = props;
|
|
831
831
|
let context = {
|
|
832
832
|
...otherProps,
|
|
833
833
|
ref: ref
|
|
@@ -838,8 +838,8 @@ function $e6afbd83fe6ebbd2$var$useFocusableContext(ref) {
|
|
|
838
838
|
}
|
|
839
839
|
let $e6afbd83fe6ebbd2$export$13f3202a3e5ddd5 = /*#__PURE__*/ (0, $6nfFC$react).forwardRef($e6afbd83fe6ebbd2$var$FocusableProvider);
|
|
840
840
|
function $e6afbd83fe6ebbd2$export$4c014de7c8940b4c(props, domRef) {
|
|
841
|
-
let { focusProps: focusProps
|
|
842
|
-
let { keyboardProps: keyboardProps
|
|
841
|
+
let { focusProps: focusProps } = (0, $6nfFC$useFocus)(props);
|
|
842
|
+
let { keyboardProps: keyboardProps } = (0, $6nfFC$useKeyboard)(props);
|
|
843
843
|
let interactions = (0, $6nfFC$mergeProps)(focusProps, keyboardProps);
|
|
844
844
|
let domProps = $e6afbd83fe6ebbd2$var$useFocusableContext(domRef);
|
|
845
845
|
let interactionProps = props.isDisabled ? {} : domProps;
|
package/dist/main.js
CHANGED
|
@@ -81,11 +81,11 @@ function $1c7f9157d722357d$export$80f3e147d781571c(element) {
|
|
|
81
81
|
* governing permissions and limitations under the License.
|
|
82
82
|
*/ function $d5156037ad898a4d$var$isStyleVisible(element) {
|
|
83
83
|
if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) return false;
|
|
84
|
-
let { display: display
|
|
84
|
+
let { display: display, visibility: visibility } = element.style;
|
|
85
85
|
let isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
|
|
86
86
|
if (isVisible) {
|
|
87
|
-
const { getComputedStyle: getComputedStyle
|
|
88
|
-
let { display: computedDisplay
|
|
87
|
+
const { getComputedStyle: getComputedStyle } = element.ownerDocument.defaultView;
|
|
88
|
+
let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
|
|
89
89
|
isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
|
|
90
90
|
}
|
|
91
91
|
return isVisible;
|
|
@@ -103,11 +103,11 @@ function $d5156037ad898a4d$export$e989c0fffaa6b27a(element, childElement) {
|
|
|
103
103
|
const $a7a032acae3ddda9$var$FocusContext = /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).createContext(null);
|
|
104
104
|
let $a7a032acae3ddda9$var$activeScope = null;
|
|
105
105
|
function $a7a032acae3ddda9$export$20e40289641fbbb6(props) {
|
|
106
|
-
let { children: children
|
|
106
|
+
let { children: children, contain: contain, restoreFocus: restoreFocus, autoFocus: autoFocus } = props;
|
|
107
107
|
let startRef = (0, $aB6Cp$react.useRef)();
|
|
108
108
|
let endRef = (0, $aB6Cp$react.useRef)();
|
|
109
109
|
let scopeRef = (0, $aB6Cp$react.useRef)([]);
|
|
110
|
-
let { parentNode: parentNode
|
|
110
|
+
let { parentNode: parentNode } = (0, $aB6Cp$react.useContext)($a7a032acae3ddda9$var$FocusContext) || {};
|
|
111
111
|
// Create a tree node here so we can add children to it even before it is added to the tree.
|
|
112
112
|
let node = (0, $aB6Cp$react.useMemo)(()=>new $a7a032acae3ddda9$var$TreeNode({
|
|
113
113
|
scopeRef: scopeRef
|
|
@@ -207,7 +207,7 @@ function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
|
207
207
|
return {
|
|
208
208
|
focusNext (opts = {}) {
|
|
209
209
|
let scope = scopeRef.current;
|
|
210
|
-
let { from: from
|
|
210
|
+
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
|
|
211
211
|
let node = from || document.activeElement;
|
|
212
212
|
let sentinel = scope[0].previousElementSibling;
|
|
213
213
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
@@ -225,7 +225,7 @@ function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
|
225
225
|
},
|
|
226
226
|
focusPrevious (opts = {}) {
|
|
227
227
|
let scope = scopeRef.current;
|
|
228
|
-
let { from: from
|
|
228
|
+
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
|
|
229
229
|
let node = from || document.activeElement;
|
|
230
230
|
let sentinel = scope[scope.length - 1].nextElementSibling;
|
|
231
231
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
@@ -243,7 +243,7 @@ function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
|
243
243
|
},
|
|
244
244
|
focusFirst (opts = {}) {
|
|
245
245
|
let scope = scopeRef.current;
|
|
246
|
-
let { tabbable: tabbable
|
|
246
|
+
let { tabbable: tabbable, accept: accept } = opts;
|
|
247
247
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
248
248
|
tabbable: tabbable,
|
|
249
249
|
accept: accept
|
|
@@ -255,7 +255,7 @@ function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
|
255
255
|
},
|
|
256
256
|
focusLast (opts = {}) {
|
|
257
257
|
let scope = scopeRef.current;
|
|
258
|
-
let { tabbable: tabbable
|
|
258
|
+
let { tabbable: tabbable, accept: accept } = opts;
|
|
259
259
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
260
260
|
tabbable: tabbable,
|
|
261
261
|
accept: accept
|
|
@@ -389,7 +389,7 @@ function $a7a032acae3ddda9$var$isElementInChildScope(element, scope = null) {
|
|
|
389
389
|
if (element instanceof Element && element.closest("[data-react-aria-top-layer]")) return true;
|
|
390
390
|
// node.contains in isElementInScope covers child scopes that are also DOM children,
|
|
391
391
|
// but does not cover child scopes in portals.
|
|
392
|
-
for (let { scopeRef: s
|
|
392
|
+
for (let { scopeRef: s } of $a7a032acae3ddda9$export$d06fae2ee68b101e.traverse($a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scope))){
|
|
393
393
|
if ($a7a032acae3ddda9$var$isElementInScope(element, s.current)) return true;
|
|
394
394
|
}
|
|
395
395
|
return false;
|
|
@@ -611,7 +611,7 @@ function $a7a032acae3ddda9$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
611
611
|
focusNext (opts = {}) {
|
|
612
612
|
let root = ref.current;
|
|
613
613
|
if (!root) return;
|
|
614
|
-
let { from: from
|
|
614
|
+
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
|
|
615
615
|
let node = from || document.activeElement;
|
|
616
616
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
|
|
617
617
|
tabbable: tabbable,
|
|
@@ -629,7 +629,7 @@ function $a7a032acae3ddda9$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
629
629
|
focusPrevious (opts = defaultOptions) {
|
|
630
630
|
let root = ref.current;
|
|
631
631
|
if (!root) return;
|
|
632
|
-
let { from: from
|
|
632
|
+
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
|
|
633
633
|
let node = from || document.activeElement;
|
|
634
634
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
|
|
635
635
|
tabbable: tabbable,
|
|
@@ -652,7 +652,7 @@ function $a7a032acae3ddda9$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
652
652
|
focusFirst (opts = defaultOptions) {
|
|
653
653
|
let root = ref.current;
|
|
654
654
|
if (!root) return;
|
|
655
|
-
let { tabbable: tabbable = defaultOptions.tabbable
|
|
655
|
+
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
|
|
656
656
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
|
|
657
657
|
tabbable: tabbable,
|
|
658
658
|
accept: accept
|
|
@@ -664,7 +664,7 @@ function $a7a032acae3ddda9$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
664
664
|
focusLast (opts = defaultOptions) {
|
|
665
665
|
let root = ref.current;
|
|
666
666
|
if (!root) return;
|
|
667
|
-
let { tabbable: tabbable = defaultOptions.tabbable
|
|
667
|
+
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
|
|
668
668
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
|
|
669
669
|
tabbable: tabbable,
|
|
670
670
|
accept: accept
|
|
@@ -769,7 +769,7 @@ let $a7a032acae3ddda9$export$d06fae2ee68b101e = new $a7a032acae3ddda9$var$Tree()
|
|
|
769
769
|
|
|
770
770
|
|
|
771
771
|
function $581a96d6eb128c1b$export$4e328f61c538687f(props = {}) {
|
|
772
|
-
let { autoFocus: autoFocus = false
|
|
772
|
+
let { autoFocus: autoFocus = false, isTextInput: isTextInput, within: within } = props;
|
|
773
773
|
let state = (0, $aB6Cp$react.useRef)({
|
|
774
774
|
isFocused: false,
|
|
775
775
|
isFocusVisible: autoFocus || (0, $aB6Cp$reactariainteractions.isFocusVisible)()
|
|
@@ -790,11 +790,11 @@ function $581a96d6eb128c1b$export$4e328f61c538687f(props = {}) {
|
|
|
790
790
|
}, [], {
|
|
791
791
|
isTextInput: isTextInput
|
|
792
792
|
});
|
|
793
|
-
let { focusProps: focusProps
|
|
793
|
+
let { focusProps: focusProps } = (0, $aB6Cp$reactariainteractions.useFocus)({
|
|
794
794
|
isDisabled: within,
|
|
795
795
|
onFocusChange: onFocusChange
|
|
796
796
|
});
|
|
797
|
-
let { focusWithinProps: focusWithinProps
|
|
797
|
+
let { focusWithinProps: focusWithinProps } = (0, $aB6Cp$reactariainteractions.useFocusWithin)({
|
|
798
798
|
isDisabled: !within,
|
|
799
799
|
onFocusWithinChange: onFocusChange
|
|
800
800
|
});
|
|
@@ -807,8 +807,8 @@ function $581a96d6eb128c1b$export$4e328f61c538687f(props = {}) {
|
|
|
807
807
|
|
|
808
808
|
|
|
809
809
|
function $dfd8c70b928eb1b3$export$1a38b4ad7f578e1d(props) {
|
|
810
|
-
let { children: children
|
|
811
|
-
let { isFocused: isFocused
|
|
810
|
+
let { children: children, focusClass: focusClass, focusRingClass: focusRingClass } = props;
|
|
811
|
+
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $581a96d6eb128c1b$export$4e328f61c538687f)(props);
|
|
812
812
|
let child = (0, ($parcel$interopDefault($aB6Cp$react))).Children.only(children);
|
|
813
813
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).cloneElement(child, (0, $aB6Cp$reactariautils.mergeProps)(child.props, {
|
|
814
814
|
...focusProps,
|
|
@@ -839,13 +839,13 @@ function $fb504d83237fd6ac$var$useFocusableContext(ref) {
|
|
|
839
839
|
let context = (0, $aB6Cp$react.useContext)($fb504d83237fd6ac$var$FocusableContext) || {};
|
|
840
840
|
(0, $aB6Cp$reactariautils.useSyncRef)(context, ref);
|
|
841
841
|
// eslint-disable-next-line
|
|
842
|
-
let { ref: _
|
|
842
|
+
let { ref: _, ...otherProps } = context;
|
|
843
843
|
return otherProps;
|
|
844
844
|
}
|
|
845
845
|
/**
|
|
846
846
|
* Provides DOM props to the nearest focusable child.
|
|
847
847
|
*/ function $fb504d83237fd6ac$var$FocusableProvider(props, ref) {
|
|
848
|
-
let { children: children
|
|
848
|
+
let { children: children, ...otherProps } = props;
|
|
849
849
|
let context = {
|
|
850
850
|
...otherProps,
|
|
851
851
|
ref: ref
|
|
@@ -856,8 +856,8 @@ function $fb504d83237fd6ac$var$useFocusableContext(ref) {
|
|
|
856
856
|
}
|
|
857
857
|
let $fb504d83237fd6ac$export$13f3202a3e5ddd5 = /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).forwardRef($fb504d83237fd6ac$var$FocusableProvider);
|
|
858
858
|
function $fb504d83237fd6ac$export$4c014de7c8940b4c(props, domRef) {
|
|
859
|
-
let { focusProps: focusProps
|
|
860
|
-
let { keyboardProps: keyboardProps
|
|
859
|
+
let { focusProps: focusProps } = (0, $aB6Cp$reactariainteractions.useFocus)(props);
|
|
860
|
+
let { keyboardProps: keyboardProps } = (0, $aB6Cp$reactariainteractions.useKeyboard)(props);
|
|
861
861
|
let interactions = (0, $aB6Cp$reactariautils.mergeProps)(focusProps, keyboardProps);
|
|
862
862
|
let domProps = $fb504d83237fd6ac$var$useFocusableContext(domRef);
|
|
863
863
|
let interactionProps = props.isDisabled ? {} : domProps;
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;AAUM,SAAS,0CAAY,OAAyB;IACnD,6EAA6E;IAC7E,4EAA4E;IAC5E,2EAA2E;IAC3E,+EAA+E;IAC/E,uBAAuB;IACvB,IAAI,CAAA,GAAA,mDAAqB,QAAQ,WAAW;QAC1C,IAAI,qBAAqB,SAAS;QAClC,CAAA,GAAA,wCAAiB,EAAE;YACjB,4EAA4E;YAC5E,IAAI,SAAS,kBAAkB,sBAAsB,SAAS,SAAS,UACrE,CAAA,GAAA,2CAAoB,EAAE;QAE1B;IACF,OACE,CAAA,GAAA,2CAAoB,EAAE;AAE1B;;CD3BC;AEVD;;;;;;;;;;CAUC,GAED,SAAS,qCAAe,OAAgB;IACtC,IAAI,CAAE,CAAA,mBAAmB,WAAU,KAAM,CAAE,CAAA,mBAAmB,UA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YAC3C;YAEA,OAAO;gBACL,qFAAqF;gBACrF,wFAAwF;gBACxF,4FAA4F;gBAC5F,yFAAyF;gBACzF,SAAS;YACX;QACF;IACF;IAEA,OAAO,aAAa,QAAQ;AAC9B;;","sources":["packages/@react-aria/focus/src/index.ts","packages/@react-aria/focus/src/FocusScope.tsx","packages/@react-aria/focus/src/focusSafely.ts","packages/@react-aria/focus/src/isElementVisible.ts","packages/@react-aria/focus/src/FocusRing.tsx","packages/@react-aria/focus/src/useFocusRing.ts","packages/@react-aria/focus/src/useFocusable.tsx","packages/@react-aria/focus/src/useHasTabbableChild.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 {FocusableProvider, useFocusable} from './useFocusable';\nexport {useFocusRing} from './useFocusRing';\nexport {focusSafely} from './focusSafely';\nexport {useHasTabbableChild} from './useHasTabbableChild';\n\nexport type {FocusScopeProps, FocusManager, FocusManagerOptions} from './FocusScope';\nexport type {FocusRingProps} from './FocusRing';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\nexport type {AriaFocusRingProps, FocusRingAria} from './useFocusRing';\n","/*\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 {FocusableElement} from '@react-types/shared';\nimport {focusSafely} from './focusSafely';\nimport {isElementVisible} from './isElementVisible';\nimport React, {ReactNode, RefObject, useContext, useEffect, useMemo, useRef} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\n\nexport interface FocusScopeProps {\n /** The contents of the focus scope. */\n children: ReactNode,\n\n /**\n * Whether to contain focus inside the scope, so users cannot\n * move focus outside, for example in a modal dialog.\n */\n contain?: boolean,\n\n /**\n * Whether to restore focus back to the element that was focused\n * when the focus scope mounted, after the focus scope unmounts.\n */\n restoreFocus?: boolean,\n\n /** Whether to auto focus the first focusable element in the focus scope on mount. */\n autoFocus?: boolean\n}\n\nexport interface FocusManagerOptions {\n /** The element to start searching from. The currently focused element by default. */\n from?: Element,\n /** Whether to only include tabbable elements, or all focusable elements. */\n tabbable?: boolean,\n /** Whether focus should wrap around when it reaches the end of the scope. */\n wrap?: boolean,\n /** A callback that determines whether the given element is focused. */\n accept?: (node: Element) => boolean\n}\n\nexport interface FocusManager {\n /** Moves focus to the next focusable or tabbable element in the focus scope. */\n focusNext(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the previous focusable or tabbable element in the focus scope. */\n focusPrevious(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the first focusable or tabbable element in the focus scope. */\n focusFirst(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the last focusable or tabbable element in the focus scope. */\n focusLast(opts?: FocusManagerOptions): FocusableElement\n}\n\ntype ScopeRef = RefObject<Element[]>;\ninterface IFocusContext {\n focusManager: FocusManager,\n parentNode: TreeNode | null\n}\n\nconst FocusContext = React.createContext<IFocusContext>(null);\n\nlet activeScope: ScopeRef = null;\n\n// This is a hacky DOM-based implementation of a FocusScope until this RFC lands in React:\n// https://github.com/reactjs/rfcs/pull/109\n\n/**\n * A FocusScope manages focus for its descendants. It supports containing focus inside\n * the scope, restoring focus to the previously focused element on unmount, and auto\n * focusing children on mount. It also acts as a container for a programmatic focus\n * management interface that can be used to move focus forward and back in response\n * to user events.\n */\nexport function FocusScope(props: FocusScopeProps) {\n let {children, contain, restoreFocus, autoFocus} = props;\n let startRef = useRef<HTMLSpanElement>();\n let endRef = useRef<HTMLSpanElement>();\n let scopeRef = useRef<Element[]>([]);\n let {parentNode} = useContext(FocusContext) || {};\n\n // Create a tree node here so we can add children to it even before it is added to the tree.\n let node = useMemo(() => new TreeNode({scopeRef}), [scopeRef]);\n\n useLayoutEffect(() => {\n // If a new scope mounts outside the active scope, (e.g. DialogContainer launched from a menu),\n // use the active scope as the parent instead of the parent from context. Layout effects run bottom\n // up, so if the parent is not yet added to the tree, don't do this. Only the outer-most FocusScope\n // that is being added should get the activeScope as its parent.\n let parent = parentNode || focusScopeTree.root;\n if (focusScopeTree.getTreeNode(parent.scopeRef) && activeScope && !isAncestorScope(activeScope, parent.scopeRef)) {\n let activeNode = focusScopeTree.getTreeNode(activeScope);\n if (activeNode) {\n parent = activeNode;\n }\n }\n\n // Add the node to the parent, and to the tree.\n parent.addChild(node);\n focusScopeTree.addNode(node);\n }, [node, parentNode]);\n\n useLayoutEffect(() => {\n let node = focusScopeTree.getTreeNode(scopeRef);\n node.contain = contain;\n }, [contain]);\n\n useLayoutEffect(() => {\n // Find all rendered nodes between the sentinels and add them to the scope.\n let node = startRef.current.nextSibling;\n let nodes = [];\n while (node && node !== endRef.current) {\n nodes.push(node);\n node = node.nextSibling;\n }\n\n scopeRef.current = nodes;\n }, [children]);\n\n useActiveScopeTracker(scopeRef, restoreFocus, contain);\n useFocusContainment(scopeRef, contain);\n useRestoreFocus(scopeRef, restoreFocus, contain);\n useAutoFocus(scopeRef, autoFocus);\n\n // this layout effect needs to run last so that focusScopeTree cleanup happens at the last moment possible\n useEffect(() => {\n if (scopeRef) {\n let activeElement = document.activeElement;\n let scope = null;\n // In strict mode, active scope is incorrectly updated since cleanup will run even though scope hasn't unmounted.\n // To fix this, we need to update the actual activeScope here\n if (isElementInScope(activeElement, scopeRef.current)) {\n // Since useLayoutEffect runs for children first, we need to traverse the focusScope tree and find the bottom most scope that\n // contains the active element and set that as the activeScope\n for (let node of focusScopeTree.traverse()) {\n if (isElementInScope(activeElement, node.scopeRef.current)) {\n scope = node;\n }\n }\n\n if (scope === focusScopeTree.getTreeNode(scopeRef)) {\n activeScope = scope.scopeRef;\n }\n }\n\n return () => {\n // Scope may have been re-parented.\n let parentScope = focusScopeTree.getTreeNode(scopeRef).parent.scopeRef;\n\n // Restore the active scope on unmount if this scope or a descendant scope is active.\n // Parent effect cleanups run before children, so we need to check if the\n // parent scope actually still exists before restoring the active scope to it.\n if (\n (scopeRef === activeScope || isAncestorScope(scopeRef, activeScope)) &&\n (!parentScope || focusScopeTree.getTreeNode(parentScope))\n ) {\n activeScope = parentScope;\n }\n focusScopeTree.removeTreeNode(scopeRef);\n };\n }\n }, [scopeRef]);\n\n let focusManager = useMemo(() => createFocusManagerForScope(scopeRef), []);\n let value = useMemo(() => ({\n focusManager,\n parentNode: node\n }), [node, focusManager]);\n\n return (\n <FocusContext.Provider value={value}>\n <span data-focus-scope-start hidden ref={startRef} />\n {children}\n <span data-focus-scope-end hidden ref={endRef} />\n </FocusContext.Provider>\n );\n}\n\n/**\n * Returns a FocusManager interface for the parent FocusScope.\n * A FocusManager can be used to programmatically move focus within\n * a FocusScope, e.g. in response to user events like keyboard navigation.\n */\nexport function useFocusManager(): FocusManager {\n return useContext(FocusContext)?.focusManager;\n}\n\nfunction createFocusManagerForScope(scopeRef: React.RefObject<Element[]>): FocusManager {\n return {\n focusNext(opts: FocusManagerOptions = {}) {\n let scope = scopeRef.current;\n let {from, tabbable, wrap, accept} = opts;\n let node = from || document.activeElement;\n let sentinel = scope[0].previousElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let nextNode = walker.nextNode() as FocusableElement;\n if (!nextNode && wrap) {\n walker.currentNode = sentinel;\n nextNode = walker.nextNode() as FocusableElement;\n }\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = {}) {\n let scope = scopeRef.current;\n let {from, tabbable, wrap, accept} = opts;\n let node = from || document.activeElement;\n let sentinel = scope[scope.length - 1].nextElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let previousNode = walker.previousNode() as FocusableElement;\n if (!previousNode && wrap) {\n walker.currentNode = sentinel;\n previousNode = walker.previousNode() as FocusableElement;\n }\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n },\n focusFirst(opts = {}) {\n let scope = scopeRef.current;\n let {tabbable, accept} = opts;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = scope[0].previousElementSibling;\n let nextNode = walker.nextNode() as FocusableElement;\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusLast(opts = {}) {\n let scope = scopeRef.current;\n let {tabbable, accept} = opts;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = scope[scope.length - 1].nextElementSibling;\n let previousNode = walker.previousNode() as FocusableElement;\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n }\n };\n}\n\nconst focusableElements = [\n 'input:not([disabled]):not([type=hidden])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'button:not([disabled])',\n 'a[href]',\n 'area[href]',\n 'summary',\n 'iframe',\n 'object',\n 'embed',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]'\n];\n\nconst FOCUSABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';\n\nfocusableElements.push('[tabindex]:not([tabindex=\"-1\"]):not([disabled])');\nconst TABBABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]):not([tabindex=\"-1\"]),');\n\nfunction getScopeRoot(scope: Element[]) {\n return scope[0].parentElement;\n}\n\nfunction shouldContainFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.contain) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return true;\n}\n\nfunction useFocusContainment(scopeRef: RefObject<Element[]>, contain: boolean) {\n let focusedNode = useRef<FocusableElement>();\n\n let raf = useRef(null);\n useLayoutEffect(() => {\n let scope = scopeRef.current;\n if (!contain) {\n // if contain was changed, then we should cancel any ongoing waits to pull focus back into containment\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n raf.current = null;\n }\n return;\n }\n\n // Handle the Tab key to contain focus within the scope\n let onKeyDown = (e) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !shouldContainFocus(scopeRef)) {\n return;\n }\n\n let focusedElement = document.activeElement;\n let scope = scopeRef.current;\n if (!isElementInScope(focusedElement, scope)) {\n return;\n }\n\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable: true}, scope);\n walker.currentNode = focusedElement;\n let nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n if (!nextElement) {\n walker.currentNode = e.shiftKey ? scope[scope.length - 1].nextElementSibling : scope[0].previousElementSibling;\n nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n }\n\n e.preventDefault();\n if (nextElement) {\n focusElement(nextElement, true);\n }\n };\n\n let onFocus = (e) => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if ((!activeScope || isAncestorScope(activeScope, scopeRef)) && isElementInScope(e.target, scopeRef.current)) {\n activeScope = scopeRef;\n focusedNode.current = e.target;\n } else if (shouldContainFocus(scopeRef) && !isElementInChildScope(e.target, scopeRef)) {\n // If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),\n // restore focus to the previously focused node or the first tabbable element in the active scope.\n if (focusedNode.current) {\n focusedNode.current.focus();\n } else if (activeScope) {\n focusFirstInScope(activeScope.current);\n }\n } else if (shouldContainFocus(scopeRef)) {\n focusedNode.current = e.target;\n }\n };\n\n let onBlur = (e) => {\n // Firefox doesn't shift focus back to the Dialog properly without this\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n raf.current = requestAnimationFrame(() => {\n // Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe\n if (shouldContainFocus(scopeRef) && !isElementInChildScope(document.activeElement, scopeRef)) {\n activeScope = scopeRef;\n if (document.body.contains(e.target)) {\n focusedNode.current = e.target;\n focusedNode.current.focus();\n } else if (activeScope) {\n focusFirstInScope(activeScope.current);\n }\n }\n });\n };\n\n document.addEventListener('keydown', onKeyDown, false);\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n scope.forEach(element => element.addEventListener('focusout', onBlur, false));\n return () => {\n document.removeEventListener('keydown', onKeyDown, false);\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n scope.forEach(element => element.removeEventListener('focusout', onBlur, false));\n };\n }, [scopeRef, contain]);\n\n // This is a useLayoutEffect so it is guaranteed to run before our async synthetic blur\n // eslint-disable-next-line arrow-body-style\n useLayoutEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, [raf]);\n}\n\nfunction isElementInAnyScope(element: Element) {\n return isElementInChildScope(element);\n}\n\nfunction isElementInScope(element: Element, scope: Element[]) {\n return scope.some(node => node.contains(element));\n}\n\nfunction isElementInChildScope(element: Element, scope: ScopeRef = null) {\n // If the element is within a top layer element (e.g. toasts), always allow moving focus there.\n if (element instanceof Element && element.closest('[data-react-aria-top-layer]')) {\n return true;\n }\n\n // node.contains in isElementInScope covers child scopes that are also DOM children,\n // but does not cover child scopes in portals.\n for (let {scopeRef: s} of focusScopeTree.traverse(focusScopeTree.getTreeNode(scope))) {\n if (isElementInScope(element, s.current)) {\n return true;\n }\n }\n\n return false;\n}\n\n/** @private */\nexport function isElementInChildOfActiveScope(element: Element) {\n return isElementInChildScope(element, activeScope);\n}\n\nfunction isAncestorScope(ancestor: ScopeRef, scope: ScopeRef) {\n let parent = focusScopeTree.getTreeNode(scope)?.parent;\n while (parent) {\n if (parent.scopeRef === ancestor) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n}\n\nfunction focusElement(element: FocusableElement | null, scroll = false) {\n if (element != null && !scroll) {\n try {\n focusSafely(element);\n } catch (err) {\n // ignore\n }\n } else if (element != null) {\n try {\n element.focus();\n } catch (err) {\n // ignore\n }\n }\n}\n\nfunction focusFirstInScope(scope: Element[], tabbable:boolean = true) {\n let sentinel = scope[0].previousElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable}, scope);\n walker.currentNode = sentinel;\n let nextNode = walker.nextNode();\n\n // If the scope does not contain a tabbable element, use the first focusable element.\n if (tabbable && !nextNode) {\n walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable: false}, scope);\n walker.currentNode = sentinel;\n nextNode = walker.nextNode();\n }\n\n focusElement(nextNode as FocusableElement);\n}\n\nfunction useAutoFocus(scopeRef: RefObject<Element[]>, autoFocus: boolean) {\n const autoFocusRef = React.useRef(autoFocus);\n useEffect(() => {\n if (autoFocusRef.current) {\n activeScope = scopeRef;\n if (!isElementInScope(document.activeElement, activeScope.current)) {\n focusFirstInScope(scopeRef.current);\n }\n }\n autoFocusRef.current = false;\n }, [scopeRef]);\n}\n\nfunction useActiveScopeTracker(scopeRef: RefObject<Element[]>, restore: boolean, contain: boolean) {\n // tracks the active scope, in case restore and contain are both false.\n // if either are true, this is tracked in useRestoreFocus or useFocusContainment.\n useLayoutEffect(() => {\n if (restore || contain) {\n return;\n }\n\n let scope = scopeRef.current;\n\n let onFocus = (e: FocusEvent) => {\n let target = e.target as Element;\n if (isElementInScope(target, scopeRef.current)) {\n activeScope = scopeRef;\n } else if (!isElementInAnyScope(target)) {\n activeScope = null;\n }\n };\n\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n return () => {\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n };\n }, [scopeRef, restore, contain]);\n}\n\nfunction shouldRestoreFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.nodeToRestore) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return scope?.scopeRef === scopeRef;\n}\n\nfunction useRestoreFocus(scopeRef: RefObject<Element[]>, restoreFocus: boolean, contain: boolean) {\n // create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.\n const nodeToRestoreRef = useRef(typeof document !== 'undefined' ? document.activeElement as FocusableElement : null);\n\n // restoring scopes should all track if they are active regardless of contain, but contain already tracks it plus logic to contain the focus\n // restoring-non-containing scopes should only care if they become active so they can perform the restore\n useLayoutEffect(() => {\n let scope = scopeRef.current;\n if (!restoreFocus || contain) {\n return;\n }\n\n let onFocus = () => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if ((!activeScope || isAncestorScope(activeScope, scopeRef)) &&\n isElementInScope(document.activeElement, scopeRef.current)\n ) {\n activeScope = scopeRef;\n }\n };\n\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n return () => {\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [scopeRef, contain]);\n\n useLayoutEffect(() => {\n if (!restoreFocus) {\n return;\n }\n\n // Handle the Tab key so that tabbing out of the scope goes to the next element\n // after the node that had focus when the scope mounted. This is important when\n // using portals for overlays, so that focus goes to the expected element when\n // tabbing out of the overlay.\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !shouldContainFocus(scopeRef)) {\n return;\n }\n\n let focusedElement = document.activeElement as FocusableElement;\n if (!isElementInScope(focusedElement, scopeRef.current)) {\n return;\n }\n let nodeToRestore = focusScopeTree.getTreeNode(scopeRef).nodeToRestore;\n\n // Create a DOM tree walker that matches all tabbable elements\n let walker = getFocusableTreeWalker(document.body, {tabbable: true});\n\n // Find the next tabbable element after the currently focused element\n walker.currentNode = focusedElement;\n let nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n\n if (!document.body.contains(nodeToRestore) || nodeToRestore === document.body) {\n nodeToRestore = null;\n focusScopeTree.getTreeNode(scopeRef).nodeToRestore = null;\n }\n\n // If there is no next element, or it is outside the current scope, move focus to the\n // next element after the node to restore to instead.\n if ((!nextElement || !isElementInScope(nextElement, scopeRef.current)) && nodeToRestore) {\n walker.currentNode = nodeToRestore;\n\n // Skip over elements within the scope, in case the scope immediately follows the node to restore.\n do {\n nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n } while (isElementInScope(nextElement, scopeRef.current));\n\n e.preventDefault();\n e.stopPropagation();\n if (nextElement) {\n focusElement(nextElement, true);\n } else {\n // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)\n // then move focus to the body.\n // Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)\n if (!isElementInAnyScope(nodeToRestore)) {\n focusedElement.blur();\n } else {\n focusElement(nodeToRestore, true);\n }\n }\n }\n };\n\n if (!contain) {\n document.addEventListener('keydown', onKeyDown, true);\n }\n\n return () => {\n if (!contain) {\n document.removeEventListener('keydown', onKeyDown, true);\n }\n };\n }, [scopeRef, restoreFocus, contain]);\n\n // useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.\n useLayoutEffect(() => {\n if (!restoreFocus) {\n return;\n }\n\n focusScopeTree.getTreeNode(scopeRef).nodeToRestore = nodeToRestoreRef.current;\n\n return () => {\n let nodeToRestore = focusScopeTree.getTreeNode(scopeRef).nodeToRestore;\n\n // if we already lost focus to the body and this was the active scope, then we should attempt to restore\n if (\n restoreFocus\n && nodeToRestore\n && (\n // eslint-disable-next-line react-hooks/exhaustive-deps\n isElementInScope(document.activeElement, scopeRef.current)\n || (document.activeElement === document.body && shouldRestoreFocus(scopeRef))\n )\n ) {\n // freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it\n let clonedTree = focusScopeTree.clone();\n requestAnimationFrame(() => {\n // Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere\n if (document.activeElement === document.body) {\n // look up the tree starting with our scope to find a nodeToRestore still in the DOM\n let treeNode = clonedTree.getTreeNode(scopeRef);\n while (treeNode) {\n if (treeNode.nodeToRestore && document.body.contains(treeNode.nodeToRestore)) {\n focusElement(treeNode.nodeToRestore);\n return;\n }\n treeNode = treeNode.parent;\n }\n\n // If no nodeToRestore was found, focus the first element in the nearest\n // ancestor scope that is still in the tree.\n treeNode = clonedTree.getTreeNode(scopeRef);\n while (treeNode) {\n if (treeNode.scopeRef && focusScopeTree.getTreeNode(treeNode.scopeRef)) {\n focusFirstInScope(treeNode.scopeRef.current, true);\n return;\n }\n treeNode = treeNode.parent;\n }\n }\n });\n }\n };\n }, [scopeRef, restoreFocus]);\n}\n\n/**\n * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}\n * that matches all focusable/tabbable elements.\n */\nexport function getFocusableTreeWalker(root: Element, opts?: FocusManagerOptions, scope?: Element[]) {\n let selector = opts?.tabbable ? TABBABLE_ELEMENT_SELECTOR : FOCUSABLE_ELEMENT_SELECTOR;\n let walker = document.createTreeWalker(\n root,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode(node) {\n // Skip nodes inside the starting node.\n if (opts?.from?.contains(node)) {\n return NodeFilter.FILTER_REJECT;\n }\n\n if ((node as Element).matches(selector)\n && isElementVisible(node as Element)\n && (!scope || isElementInScope(node as Element, scope))\n && (!opts?.accept || opts.accept(node as Element))\n ) {\n return NodeFilter.FILTER_ACCEPT;\n }\n\n return NodeFilter.FILTER_SKIP;\n }\n }\n );\n\n if (opts?.from) {\n walker.currentNode = opts.from;\n }\n\n return walker;\n}\n\n/**\n * Creates a FocusManager object that can be used to move focus within an element.\n */\nexport function createFocusManager(ref: RefObject<Element>, defaultOptions: FocusManagerOptions = {}): FocusManager {\n return {\n focusNext(opts: FocusManagerOptions = {}) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept} = opts;\n let node = from || document.activeElement;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n if (root.contains(node)) {\n walker.currentNode = node;\n }\n let nextNode = walker.nextNode() as FocusableElement;\n if (!nextNode && wrap) {\n walker.currentNode = root;\n nextNode = walker.nextNode() as FocusableElement;\n }\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept} = opts;\n let node = from || document.activeElement;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n if (root.contains(node)) {\n walker.currentNode = node;\n } else {\n let next = last(walker);\n if (next) {\n focusElement(next, true);\n }\n return next;\n }\n let previousNode = walker.previousNode() as FocusableElement;\n if (!previousNode && wrap) {\n walker.currentNode = root;\n previousNode = last(walker);\n }\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n },\n focusFirst(opts = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {tabbable = defaultOptions.tabbable, accept = defaultOptions.accept} = opts;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n let nextNode = walker.nextNode() as FocusableElement;\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusLast(opts = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {tabbable = defaultOptions.tabbable, accept = defaultOptions.accept} = opts;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n let next = last(walker);\n if (next) {\n focusElement(next, true);\n }\n return next;\n }\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\n\nclass Tree {\n root: TreeNode;\n private fastMap = new Map<ScopeRef, TreeNode>();\n\n constructor() {\n this.root = new TreeNode({scopeRef: null});\n this.fastMap.set(null, this.root);\n }\n\n get size() {\n return this.fastMap.size;\n }\n\n getTreeNode(data: ScopeRef) {\n return this.fastMap.get(data);\n }\n\n addTreeNode(scopeRef: ScopeRef, parent: ScopeRef, nodeToRestore?: FocusableElement) {\n let parentNode = this.fastMap.get(parent ?? null);\n let node = new TreeNode({scopeRef});\n parentNode.addChild(node);\n node.parent = parentNode;\n this.fastMap.set(scopeRef, node);\n if (nodeToRestore) {\n node.nodeToRestore = nodeToRestore;\n }\n }\n\n addNode(node: TreeNode) {\n this.fastMap.set(node.scopeRef, node);\n }\n\n removeTreeNode(scopeRef: ScopeRef) {\n // never remove the root\n if (scopeRef === null) {\n return;\n }\n let node = this.fastMap.get(scopeRef);\n let parentNode = node.parent;\n // when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing\n // if we are, then replace the siblings restore with the restore from the scope we're removing\n for (let current of this.traverse()) {\n if (\n current !== node &&\n node.nodeToRestore &&\n current.nodeToRestore &&\n node.scopeRef.current &&\n isElementInScope(current.nodeToRestore, node.scopeRef.current)\n ) {\n current.nodeToRestore = node.nodeToRestore;\n }\n }\n let children = node.children;\n parentNode.removeChild(node);\n if (children.size > 0) {\n children.forEach(child => parentNode.addChild(child));\n }\n\n this.fastMap.delete(node.scopeRef);\n }\n\n // Pre Order Depth First\n *traverse(node: TreeNode = this.root): Generator<TreeNode> {\n if (node.scopeRef != null) {\n yield node;\n }\n if (node.children.size > 0) {\n for (let child of node.children) {\n yield* this.traverse(child);\n }\n }\n }\n\n clone(): Tree {\n let newTree = new Tree();\n for (let node of this.traverse()) {\n newTree.addTreeNode(node.scopeRef, node.parent.scopeRef, node.nodeToRestore);\n }\n return newTree;\n }\n}\n\nclass TreeNode {\n public scopeRef: ScopeRef;\n public nodeToRestore: FocusableElement;\n public parent: TreeNode;\n public children: Set<TreeNode> = new Set();\n public contain = false;\n\n constructor(props: {scopeRef: ScopeRef}) {\n this.scopeRef = props.scopeRef;\n }\n addChild(node: TreeNode) {\n this.children.add(node);\n node.parent = this;\n }\n removeChild(node: TreeNode) {\n this.children.delete(node);\n node.parent = undefined;\n }\n}\n\nexport let focusScopeTree = new Tree();\n","/*\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 {FocusableElement} from '@react-types/shared';\nimport {focusWithoutScrolling, runAfterTransition} from '@react-aria/utils';\nimport {getInteractionModality} from '@react-aria/interactions';\n\n/**\n * A utility function that focuses an element while avoiding undesired side effects such\n * as page scrolling and screen reader issues with CSS transitions.\n */\nexport function focusSafely(element: FocusableElement) {\n // If the user is interacting with a virtual cursor, e.g. screen reader, then\n // wait until after any animated transitions that are currently occurring on\n // the page before shifting focus. This avoids issues with VoiceOver on iOS\n // causing the page to scroll when moving focus if the element is transitioning\n // from off the screen.\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = document.activeElement;\n runAfterTransition(() => {\n // If focus did not move and the element is still in the document, focus it.\n if (document.activeElement === lastFocusedElement && document.contains(element)) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n","/*\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\nfunction isStyleVisible(element: Element) {\n if (!(element instanceof HTMLElement) && !(element instanceof 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;\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 (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) {\n return (\n element.nodeName !== '#comment' &&\n isStyleVisible(element) &&\n isAttributeVisible(element, childElement) &&\n (!element.parentElement || isElementVisible(element.parentElement, element))\n );\n}\n","/*\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) {\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, {\n ...focusProps,\n className: clsx({\n [focusClass || '']: isFocused,\n [focusRingClass || '']: isFocusVisible\n })\n }));\n}\n","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","/*\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 {DOMAttributes, FocusableDOMProps, FocusableElement, FocusableProps} from '@react-types/shared';\nimport {focusSafely} from './';\nimport {mergeProps, useSyncRef} from '@react-aria/utils';\nimport React, {MutableRefObject, ReactNode, RefObject, useContext, useEffect, useRef} from 'react';\nimport {useFocus, useKeyboard} from '@react-aria/interactions';\n\nexport interface FocusableOptions extends FocusableProps, FocusableDOMProps {\n /** Whether focus should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface FocusableProviderProps extends DOMAttributes {\n /** The child element to provide DOM props to. */\n children?: ReactNode\n}\n\ninterface FocusableContextValue extends FocusableProviderProps {\n ref?: MutableRefObject<FocusableElement>\n}\n\nlet FocusableContext = React.createContext<FocusableContextValue>(null);\n\nfunction useFocusableContext(ref: RefObject<FocusableElement>): FocusableContextValue {\n let context = useContext(FocusableContext) || {};\n useSyncRef(context, ref);\n\n // eslint-disable-next-line\n let {ref: _, ...otherProps} = context;\n return otherProps;\n}\n\n/**\n * Provides DOM props to the nearest focusable child.\n */\nfunction FocusableProvider(props: FocusableProviderProps, ref: RefObject<FocusableElement>) {\n let {children, ...otherProps} = props;\n let context = {\n ...otherProps,\n ref\n };\n\n return (\n <FocusableContext.Provider value={context}>\n {children}\n </FocusableContext.Provider>\n );\n}\n\nlet _FocusableProvider = React.forwardRef(FocusableProvider);\nexport {_FocusableProvider as FocusableProvider};\n\nexport interface FocusableAria {\n /** Props for the focusable element. */\n focusableProps: DOMAttributes\n}\n\n/**\n * Used to make an element focusable and capable of auto focus.\n */\nexport function useFocusable(props: FocusableOptions, domRef: RefObject<FocusableElement>): FocusableAria {\n let {focusProps} = useFocus(props);\n let {keyboardProps} = useKeyboard(props);\n let interactions = mergeProps(focusProps, keyboardProps);\n let domProps = useFocusableContext(domRef);\n let interactionProps = props.isDisabled ? {} : domProps;\n let autoFocusRef = useRef(props.autoFocus);\n\n useEffect(() => {\n if (autoFocusRef.current && domRef.current) {\n focusSafely(domRef.current);\n }\n autoFocusRef.current = false;\n }, [domRef]);\n\n return {\n focusableProps: mergeProps(\n {\n ...interactions,\n tabIndex: props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined\n },\n interactionProps\n )\n };\n}\n","/*\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, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\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>, 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":"main.js.map"}
|
|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CAAoB,GAAuB,EAAE,OAAqC;IAChG,IAAI,aAAa,oBAAA,qBAAA,KAAA,IAAA,QAAS;IAC1B,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEvD,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,CAAA,gBAAA,iBAAA,KAAA,IAAA,IAAK,OAAM,KAAK,CAAC,YAAY;YAC/B,IAAI,SAAS;gBACX,IAAI,IAAI,SAAS;oBACf,IAAI,SAAS,CAAA,GAAA,yCAAqB,EAAE,IAAI,SAAS;wBAAC,UAAU;oBAAI;oBAChE,oBAAoB,CAAC,CAAC,OAAO;gBAC/B;YACF;YAEA;YAEA,qFAAqF;YACrF,IAAI,WAAW,IAAI,iBAAiB;YACpC,SAAS,QAAQ,IAAI,SAAS;gBAC5B,SAAS;gBACT,WAAW;gBACX,YAAY;gBACZ,iBAAiB;oBAAC;oBAAY;iBAAW;YAC3C;YAEA,OAAO;gBACL,qFAAqF;gBACrF,wFAAwF;gBACxF,4FAA4F;gBAC5F,yFAAyF;gBACzF,SAAS;YACX;QACF;IACF;IAEA,OAAO,aAAa,QAAQ;AAC9B;;","sources":["packages/@react-aria/focus/src/index.ts","packages/@react-aria/focus/src/FocusScope.tsx","packages/@react-aria/focus/src/focusSafely.ts","packages/@react-aria/focus/src/isElementVisible.ts","packages/@react-aria/focus/src/FocusRing.tsx","packages/@react-aria/focus/src/useFocusRing.ts","packages/@react-aria/focus/src/useFocusable.tsx","packages/@react-aria/focus/src/useHasTabbableChild.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 {FocusableProvider, useFocusable} from './useFocusable';\nexport {useFocusRing} from './useFocusRing';\nexport {focusSafely} from './focusSafely';\nexport {useHasTabbableChild} from './useHasTabbableChild';\n\nexport type {FocusScopeProps, FocusManager, FocusManagerOptions} from './FocusScope';\nexport type {FocusRingProps} from './FocusRing';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\nexport type {AriaFocusRingProps, FocusRingAria} from './useFocusRing';\n","/*\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 {FocusableElement} from '@react-types/shared';\nimport {focusSafely} from './focusSafely';\nimport {isElementVisible} from './isElementVisible';\nimport React, {ReactNode, RefObject, useContext, useEffect, useMemo, useRef} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\n\nexport interface FocusScopeProps {\n /** The contents of the focus scope. */\n children: ReactNode,\n\n /**\n * Whether to contain focus inside the scope, so users cannot\n * move focus outside, for example in a modal dialog.\n */\n contain?: boolean,\n\n /**\n * Whether to restore focus back to the element that was focused\n * when the focus scope mounted, after the focus scope unmounts.\n */\n restoreFocus?: boolean,\n\n /** Whether to auto focus the first focusable element in the focus scope on mount. */\n autoFocus?: boolean\n}\n\nexport interface FocusManagerOptions {\n /** The element to start searching from. The currently focused element by default. */\n from?: Element,\n /** Whether to only include tabbable elements, or all focusable elements. */\n tabbable?: boolean,\n /** Whether focus should wrap around when it reaches the end of the scope. */\n wrap?: boolean,\n /** A callback that determines whether the given element is focused. */\n accept?: (node: Element) => boolean\n}\n\nexport interface FocusManager {\n /** Moves focus to the next focusable or tabbable element in the focus scope. */\n focusNext(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the previous focusable or tabbable element in the focus scope. */\n focusPrevious(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the first focusable or tabbable element in the focus scope. */\n focusFirst(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the last focusable or tabbable element in the focus scope. */\n focusLast(opts?: FocusManagerOptions): FocusableElement\n}\n\ntype ScopeRef = RefObject<Element[]>;\ninterface IFocusContext {\n focusManager: FocusManager,\n parentNode: TreeNode | null\n}\n\nconst FocusContext = React.createContext<IFocusContext>(null);\n\nlet activeScope: ScopeRef = null;\n\n// This is a hacky DOM-based implementation of a FocusScope until this RFC lands in React:\n// https://github.com/reactjs/rfcs/pull/109\n\n/**\n * A FocusScope manages focus for its descendants. It supports containing focus inside\n * the scope, restoring focus to the previously focused element on unmount, and auto\n * focusing children on mount. It also acts as a container for a programmatic focus\n * management interface that can be used to move focus forward and back in response\n * to user events.\n */\nexport function FocusScope(props: FocusScopeProps) {\n let {children, contain, restoreFocus, autoFocus} = props;\n let startRef = useRef<HTMLSpanElement>();\n let endRef = useRef<HTMLSpanElement>();\n let scopeRef = useRef<Element[]>([]);\n let {parentNode} = useContext(FocusContext) || {};\n\n // Create a tree node here so we can add children to it even before it is added to the tree.\n let node = useMemo(() => new TreeNode({scopeRef}), [scopeRef]);\n\n useLayoutEffect(() => {\n // If a new scope mounts outside the active scope, (e.g. DialogContainer launched from a menu),\n // use the active scope as the parent instead of the parent from context. Layout effects run bottom\n // up, so if the parent is not yet added to the tree, don't do this. Only the outer-most FocusScope\n // that is being added should get the activeScope as its parent.\n let parent = parentNode || focusScopeTree.root;\n if (focusScopeTree.getTreeNode(parent.scopeRef) && activeScope && !isAncestorScope(activeScope, parent.scopeRef)) {\n let activeNode = focusScopeTree.getTreeNode(activeScope);\n if (activeNode) {\n parent = activeNode;\n }\n }\n\n // Add the node to the parent, and to the tree.\n parent.addChild(node);\n focusScopeTree.addNode(node);\n }, [node, parentNode]);\n\n useLayoutEffect(() => {\n let node = focusScopeTree.getTreeNode(scopeRef);\n node.contain = contain;\n }, [contain]);\n\n useLayoutEffect(() => {\n // Find all rendered nodes between the sentinels and add them to the scope.\n let node = startRef.current.nextSibling;\n let nodes = [];\n while (node && node !== endRef.current) {\n nodes.push(node);\n node = node.nextSibling;\n }\n\n scopeRef.current = nodes;\n }, [children]);\n\n useActiveScopeTracker(scopeRef, restoreFocus, contain);\n useFocusContainment(scopeRef, contain);\n useRestoreFocus(scopeRef, restoreFocus, contain);\n useAutoFocus(scopeRef, autoFocus);\n\n // this layout effect needs to run last so that focusScopeTree cleanup happens at the last moment possible\n useEffect(() => {\n if (scopeRef) {\n let activeElement = document.activeElement;\n let scope = null;\n // In strict mode, active scope is incorrectly updated since cleanup will run even though scope hasn't unmounted.\n // To fix this, we need to update the actual activeScope here\n if (isElementInScope(activeElement, scopeRef.current)) {\n // Since useLayoutEffect runs for children first, we need to traverse the focusScope tree and find the bottom most scope that\n // contains the active element and set that as the activeScope\n for (let node of focusScopeTree.traverse()) {\n if (isElementInScope(activeElement, node.scopeRef.current)) {\n scope = node;\n }\n }\n\n if (scope === focusScopeTree.getTreeNode(scopeRef)) {\n activeScope = scope.scopeRef;\n }\n }\n\n return () => {\n // Scope may have been re-parented.\n let parentScope = focusScopeTree.getTreeNode(scopeRef).parent.scopeRef;\n\n // Restore the active scope on unmount if this scope or a descendant scope is active.\n // Parent effect cleanups run before children, so we need to check if the\n // parent scope actually still exists before restoring the active scope to it.\n if (\n (scopeRef === activeScope || isAncestorScope(scopeRef, activeScope)) &&\n (!parentScope || focusScopeTree.getTreeNode(parentScope))\n ) {\n activeScope = parentScope;\n }\n focusScopeTree.removeTreeNode(scopeRef);\n };\n }\n }, [scopeRef]);\n\n let focusManager = useMemo(() => createFocusManagerForScope(scopeRef), []);\n let value = useMemo(() => ({\n focusManager,\n parentNode: node\n }), [node, focusManager]);\n\n return (\n <FocusContext.Provider value={value}>\n <span data-focus-scope-start hidden ref={startRef} />\n {children}\n <span data-focus-scope-end hidden ref={endRef} />\n </FocusContext.Provider>\n );\n}\n\n/**\n * Returns a FocusManager interface for the parent FocusScope.\n * A FocusManager can be used to programmatically move focus within\n * a FocusScope, e.g. in response to user events like keyboard navigation.\n */\nexport function useFocusManager(): FocusManager {\n return useContext(FocusContext)?.focusManager;\n}\n\nfunction createFocusManagerForScope(scopeRef: React.RefObject<Element[]>): FocusManager {\n return {\n focusNext(opts: FocusManagerOptions = {}) {\n let scope = scopeRef.current;\n let {from, tabbable, wrap, accept} = opts;\n let node = from || document.activeElement;\n let sentinel = scope[0].previousElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let nextNode = walker.nextNode() as FocusableElement;\n if (!nextNode && wrap) {\n walker.currentNode = sentinel;\n nextNode = walker.nextNode() as FocusableElement;\n }\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = {}) {\n let scope = scopeRef.current;\n let {from, tabbable, wrap, accept} = opts;\n let node = from || document.activeElement;\n let sentinel = scope[scope.length - 1].nextElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let previousNode = walker.previousNode() as FocusableElement;\n if (!previousNode && wrap) {\n walker.currentNode = sentinel;\n previousNode = walker.previousNode() as FocusableElement;\n }\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n },\n focusFirst(opts = {}) {\n let scope = scopeRef.current;\n let {tabbable, accept} = opts;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = scope[0].previousElementSibling;\n let nextNode = walker.nextNode() as FocusableElement;\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusLast(opts = {}) {\n let scope = scopeRef.current;\n let {tabbable, accept} = opts;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = scope[scope.length - 1].nextElementSibling;\n let previousNode = walker.previousNode() as FocusableElement;\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n }\n };\n}\n\nconst focusableElements = [\n 'input:not([disabled]):not([type=hidden])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'button:not([disabled])',\n 'a[href]',\n 'area[href]',\n 'summary',\n 'iframe',\n 'object',\n 'embed',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]'\n];\n\nconst FOCUSABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';\n\nfocusableElements.push('[tabindex]:not([tabindex=\"-1\"]):not([disabled])');\nconst TABBABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]):not([tabindex=\"-1\"]),');\n\nfunction getScopeRoot(scope: Element[]) {\n return scope[0].parentElement;\n}\n\nfunction shouldContainFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.contain) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return true;\n}\n\nfunction useFocusContainment(scopeRef: RefObject<Element[]>, contain: boolean) {\n let focusedNode = useRef<FocusableElement>();\n\n let raf = useRef(null);\n useLayoutEffect(() => {\n let scope = scopeRef.current;\n if (!contain) {\n // if contain was changed, then we should cancel any ongoing waits to pull focus back into containment\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n raf.current = null;\n }\n return;\n }\n\n // Handle the Tab key to contain focus within the scope\n let onKeyDown = (e) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !shouldContainFocus(scopeRef)) {\n return;\n }\n\n let focusedElement = document.activeElement;\n let scope = scopeRef.current;\n if (!isElementInScope(focusedElement, scope)) {\n return;\n }\n\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable: true}, scope);\n walker.currentNode = focusedElement;\n let nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n if (!nextElement) {\n walker.currentNode = e.shiftKey ? scope[scope.length - 1].nextElementSibling : scope[0].previousElementSibling;\n nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n }\n\n e.preventDefault();\n if (nextElement) {\n focusElement(nextElement, true);\n }\n };\n\n let onFocus = (e) => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if ((!activeScope || isAncestorScope(activeScope, scopeRef)) && isElementInScope(e.target, scopeRef.current)) {\n activeScope = scopeRef;\n focusedNode.current = e.target;\n } else if (shouldContainFocus(scopeRef) && !isElementInChildScope(e.target, scopeRef)) {\n // If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),\n // restore focus to the previously focused node or the first tabbable element in the active scope.\n if (focusedNode.current) {\n focusedNode.current.focus();\n } else if (activeScope) {\n focusFirstInScope(activeScope.current);\n }\n } else if (shouldContainFocus(scopeRef)) {\n focusedNode.current = e.target;\n }\n };\n\n let onBlur = (e) => {\n // Firefox doesn't shift focus back to the Dialog properly without this\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n raf.current = requestAnimationFrame(() => {\n // Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe\n if (shouldContainFocus(scopeRef) && !isElementInChildScope(document.activeElement, scopeRef)) {\n activeScope = scopeRef;\n if (document.body.contains(e.target)) {\n focusedNode.current = e.target;\n focusedNode.current.focus();\n } else if (activeScope) {\n focusFirstInScope(activeScope.current);\n }\n }\n });\n };\n\n document.addEventListener('keydown', onKeyDown, false);\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n scope.forEach(element => element.addEventListener('focusout', onBlur, false));\n return () => {\n document.removeEventListener('keydown', onKeyDown, false);\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n scope.forEach(element => element.removeEventListener('focusout', onBlur, false));\n };\n }, [scopeRef, contain]);\n\n // This is a useLayoutEffect so it is guaranteed to run before our async synthetic blur\n // eslint-disable-next-line arrow-body-style\n useLayoutEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, [raf]);\n}\n\nfunction isElementInAnyScope(element: Element) {\n return isElementInChildScope(element);\n}\n\nfunction isElementInScope(element: Element, scope: Element[]) {\n return scope.some(node => node.contains(element));\n}\n\nfunction isElementInChildScope(element: Element, scope: ScopeRef = null) {\n // If the element is within a top layer element (e.g. toasts), always allow moving focus there.\n if (element instanceof Element && element.closest('[data-react-aria-top-layer]')) {\n return true;\n }\n\n // node.contains in isElementInScope covers child scopes that are also DOM children,\n // but does not cover child scopes in portals.\n for (let {scopeRef: s} of focusScopeTree.traverse(focusScopeTree.getTreeNode(scope))) {\n if (isElementInScope(element, s.current)) {\n return true;\n }\n }\n\n return false;\n}\n\n/** @private */\nexport function isElementInChildOfActiveScope(element: Element) {\n return isElementInChildScope(element, activeScope);\n}\n\nfunction isAncestorScope(ancestor: ScopeRef, scope: ScopeRef) {\n let parent = focusScopeTree.getTreeNode(scope)?.parent;\n while (parent) {\n if (parent.scopeRef === ancestor) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n}\n\nfunction focusElement(element: FocusableElement | null, scroll = false) {\n if (element != null && !scroll) {\n try {\n focusSafely(element);\n } catch (err) {\n // ignore\n }\n } else if (element != null) {\n try {\n element.focus();\n } catch (err) {\n // ignore\n }\n }\n}\n\nfunction focusFirstInScope(scope: Element[], tabbable:boolean = true) {\n let sentinel = scope[0].previousElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable}, scope);\n walker.currentNode = sentinel;\n let nextNode = walker.nextNode();\n\n // If the scope does not contain a tabbable element, use the first focusable element.\n if (tabbable && !nextNode) {\n walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable: false}, scope);\n walker.currentNode = sentinel;\n nextNode = walker.nextNode();\n }\n\n focusElement(nextNode as FocusableElement);\n}\n\nfunction useAutoFocus(scopeRef: RefObject<Element[]>, autoFocus: boolean) {\n const autoFocusRef = React.useRef(autoFocus);\n useEffect(() => {\n if (autoFocusRef.current) {\n activeScope = scopeRef;\n if (!isElementInScope(document.activeElement, activeScope.current)) {\n focusFirstInScope(scopeRef.current);\n }\n }\n autoFocusRef.current = false;\n }, [scopeRef]);\n}\n\nfunction useActiveScopeTracker(scopeRef: RefObject<Element[]>, restore: boolean, contain: boolean) {\n // tracks the active scope, in case restore and contain are both false.\n // if either are true, this is tracked in useRestoreFocus or useFocusContainment.\n useLayoutEffect(() => {\n if (restore || contain) {\n return;\n }\n\n let scope = scopeRef.current;\n\n let onFocus = (e: FocusEvent) => {\n let target = e.target as Element;\n if (isElementInScope(target, scopeRef.current)) {\n activeScope = scopeRef;\n } else if (!isElementInAnyScope(target)) {\n activeScope = null;\n }\n };\n\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n return () => {\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n };\n }, [scopeRef, restore, contain]);\n}\n\nfunction shouldRestoreFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.nodeToRestore) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return scope?.scopeRef === scopeRef;\n}\n\nfunction useRestoreFocus(scopeRef: RefObject<Element[]>, restoreFocus: boolean, contain: boolean) {\n // create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.\n const nodeToRestoreRef = useRef(typeof document !== 'undefined' ? document.activeElement as FocusableElement : null);\n\n // restoring scopes should all track if they are active regardless of contain, but contain already tracks it plus logic to contain the focus\n // restoring-non-containing scopes should only care if they become active so they can perform the restore\n useLayoutEffect(() => {\n let scope = scopeRef.current;\n if (!restoreFocus || contain) {\n return;\n }\n\n let onFocus = () => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if ((!activeScope || isAncestorScope(activeScope, scopeRef)) &&\n isElementInScope(document.activeElement, scopeRef.current)\n ) {\n activeScope = scopeRef;\n }\n };\n\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n return () => {\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [scopeRef, contain]);\n\n useLayoutEffect(() => {\n if (!restoreFocus) {\n return;\n }\n\n // Handle the Tab key so that tabbing out of the scope goes to the next element\n // after the node that had focus when the scope mounted. This is important when\n // using portals for overlays, so that focus goes to the expected element when\n // tabbing out of the overlay.\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !shouldContainFocus(scopeRef)) {\n return;\n }\n\n let focusedElement = document.activeElement as FocusableElement;\n if (!isElementInScope(focusedElement, scopeRef.current)) {\n return;\n }\n let nodeToRestore = focusScopeTree.getTreeNode(scopeRef).nodeToRestore;\n\n // Create a DOM tree walker that matches all tabbable elements\n let walker = getFocusableTreeWalker(document.body, {tabbable: true});\n\n // Find the next tabbable element after the currently focused element\n walker.currentNode = focusedElement;\n let nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n\n if (!document.body.contains(nodeToRestore) || nodeToRestore === document.body) {\n nodeToRestore = null;\n focusScopeTree.getTreeNode(scopeRef).nodeToRestore = null;\n }\n\n // If there is no next element, or it is outside the current scope, move focus to the\n // next element after the node to restore to instead.\n if ((!nextElement || !isElementInScope(nextElement, scopeRef.current)) && nodeToRestore) {\n walker.currentNode = nodeToRestore;\n\n // Skip over elements within the scope, in case the scope immediately follows the node to restore.\n do {\n nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n } while (isElementInScope(nextElement, scopeRef.current));\n\n e.preventDefault();\n e.stopPropagation();\n if (nextElement) {\n focusElement(nextElement, true);\n } else {\n // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)\n // then move focus to the body.\n // Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)\n if (!isElementInAnyScope(nodeToRestore)) {\n focusedElement.blur();\n } else {\n focusElement(nodeToRestore, true);\n }\n }\n }\n };\n\n if (!contain) {\n document.addEventListener('keydown', onKeyDown, true);\n }\n\n return () => {\n if (!contain) {\n document.removeEventListener('keydown', onKeyDown, true);\n }\n };\n }, [scopeRef, restoreFocus, contain]);\n\n // useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.\n useLayoutEffect(() => {\n if (!restoreFocus) {\n return;\n }\n\n focusScopeTree.getTreeNode(scopeRef).nodeToRestore = nodeToRestoreRef.current;\n\n return () => {\n let nodeToRestore = focusScopeTree.getTreeNode(scopeRef).nodeToRestore;\n\n // if we already lost focus to the body and this was the active scope, then we should attempt to restore\n if (\n restoreFocus\n && nodeToRestore\n && (\n // eslint-disable-next-line react-hooks/exhaustive-deps\n isElementInScope(document.activeElement, scopeRef.current)\n || (document.activeElement === document.body && shouldRestoreFocus(scopeRef))\n )\n ) {\n // freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it\n let clonedTree = focusScopeTree.clone();\n requestAnimationFrame(() => {\n // Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere\n if (document.activeElement === document.body) {\n // look up the tree starting with our scope to find a nodeToRestore still in the DOM\n let treeNode = clonedTree.getTreeNode(scopeRef);\n while (treeNode) {\n if (treeNode.nodeToRestore && document.body.contains(treeNode.nodeToRestore)) {\n focusElement(treeNode.nodeToRestore);\n return;\n }\n treeNode = treeNode.parent;\n }\n\n // If no nodeToRestore was found, focus the first element in the nearest\n // ancestor scope that is still in the tree.\n treeNode = clonedTree.getTreeNode(scopeRef);\n while (treeNode) {\n if (treeNode.scopeRef && focusScopeTree.getTreeNode(treeNode.scopeRef)) {\n focusFirstInScope(treeNode.scopeRef.current, true);\n return;\n }\n treeNode = treeNode.parent;\n }\n }\n });\n }\n };\n }, [scopeRef, restoreFocus]);\n}\n\n/**\n * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}\n * that matches all focusable/tabbable elements.\n */\nexport function getFocusableTreeWalker(root: Element, opts?: FocusManagerOptions, scope?: Element[]) {\n let selector = opts?.tabbable ? TABBABLE_ELEMENT_SELECTOR : FOCUSABLE_ELEMENT_SELECTOR;\n let walker = document.createTreeWalker(\n root,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode(node) {\n // Skip nodes inside the starting node.\n if (opts?.from?.contains(node)) {\n return NodeFilter.FILTER_REJECT;\n }\n\n if ((node as Element).matches(selector)\n && isElementVisible(node as Element)\n && (!scope || isElementInScope(node as Element, scope))\n && (!opts?.accept || opts.accept(node as Element))\n ) {\n return NodeFilter.FILTER_ACCEPT;\n }\n\n return NodeFilter.FILTER_SKIP;\n }\n }\n );\n\n if (opts?.from) {\n walker.currentNode = opts.from;\n }\n\n return walker;\n}\n\n/**\n * Creates a FocusManager object that can be used to move focus within an element.\n */\nexport function createFocusManager(ref: RefObject<Element>, defaultOptions: FocusManagerOptions = {}): FocusManager {\n return {\n focusNext(opts: FocusManagerOptions = {}) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept} = opts;\n let node = from || document.activeElement;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n if (root.contains(node)) {\n walker.currentNode = node;\n }\n let nextNode = walker.nextNode() as FocusableElement;\n if (!nextNode && wrap) {\n walker.currentNode = root;\n nextNode = walker.nextNode() as FocusableElement;\n }\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept} = opts;\n let node = from || document.activeElement;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n if (root.contains(node)) {\n walker.currentNode = node;\n } else {\n let next = last(walker);\n if (next) {\n focusElement(next, true);\n }\n return next;\n }\n let previousNode = walker.previousNode() as FocusableElement;\n if (!previousNode && wrap) {\n walker.currentNode = root;\n previousNode = last(walker);\n }\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n },\n focusFirst(opts = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {tabbable = defaultOptions.tabbable, accept = defaultOptions.accept} = opts;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n let nextNode = walker.nextNode() as FocusableElement;\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusLast(opts = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {tabbable = defaultOptions.tabbable, accept = defaultOptions.accept} = opts;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n let next = last(walker);\n if (next) {\n focusElement(next, true);\n }\n return next;\n }\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\n\nclass Tree {\n root: TreeNode;\n private fastMap = new Map<ScopeRef, TreeNode>();\n\n constructor() {\n this.root = new TreeNode({scopeRef: null});\n this.fastMap.set(null, this.root);\n }\n\n get size() {\n return this.fastMap.size;\n }\n\n getTreeNode(data: ScopeRef) {\n return this.fastMap.get(data);\n }\n\n addTreeNode(scopeRef: ScopeRef, parent: ScopeRef, nodeToRestore?: FocusableElement) {\n let parentNode = this.fastMap.get(parent ?? null);\n let node = new TreeNode({scopeRef});\n parentNode.addChild(node);\n node.parent = parentNode;\n this.fastMap.set(scopeRef, node);\n if (nodeToRestore) {\n node.nodeToRestore = nodeToRestore;\n }\n }\n\n addNode(node: TreeNode) {\n this.fastMap.set(node.scopeRef, node);\n }\n\n removeTreeNode(scopeRef: ScopeRef) {\n // never remove the root\n if (scopeRef === null) {\n return;\n }\n let node = this.fastMap.get(scopeRef);\n let parentNode = node.parent;\n // when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing\n // if we are, then replace the siblings restore with the restore from the scope we're removing\n for (let current of this.traverse()) {\n if (\n current !== node &&\n node.nodeToRestore &&\n current.nodeToRestore &&\n node.scopeRef.current &&\n isElementInScope(current.nodeToRestore, node.scopeRef.current)\n ) {\n current.nodeToRestore = node.nodeToRestore;\n }\n }\n let children = node.children;\n parentNode.removeChild(node);\n if (children.size > 0) {\n children.forEach(child => parentNode.addChild(child));\n }\n\n this.fastMap.delete(node.scopeRef);\n }\n\n // Pre Order Depth First\n *traverse(node: TreeNode = this.root): Generator<TreeNode> {\n if (node.scopeRef != null) {\n yield node;\n }\n if (node.children.size > 0) {\n for (let child of node.children) {\n yield* this.traverse(child);\n }\n }\n }\n\n clone(): Tree {\n let newTree = new Tree();\n for (let node of this.traverse()) {\n newTree.addTreeNode(node.scopeRef, node.parent.scopeRef, node.nodeToRestore);\n }\n return newTree;\n }\n}\n\nclass TreeNode {\n public scopeRef: ScopeRef;\n public nodeToRestore: FocusableElement;\n public parent: TreeNode;\n public children: Set<TreeNode> = new Set();\n public contain = false;\n\n constructor(props: {scopeRef: ScopeRef}) {\n this.scopeRef = props.scopeRef;\n }\n addChild(node: TreeNode) {\n this.children.add(node);\n node.parent = this;\n }\n removeChild(node: TreeNode) {\n this.children.delete(node);\n node.parent = undefined;\n }\n}\n\nexport let focusScopeTree = new Tree();\n","/*\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 {FocusableElement} from '@react-types/shared';\nimport {focusWithoutScrolling, runAfterTransition} from '@react-aria/utils';\nimport {getInteractionModality} from '@react-aria/interactions';\n\n/**\n * A utility function that focuses an element while avoiding undesired side effects such\n * as page scrolling and screen reader issues with CSS transitions.\n */\nexport function focusSafely(element: FocusableElement) {\n // If the user is interacting with a virtual cursor, e.g. screen reader, then\n // wait until after any animated transitions that are currently occurring on\n // the page before shifting focus. This avoids issues with VoiceOver on iOS\n // causing the page to scroll when moving focus if the element is transitioning\n // from off the screen.\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = document.activeElement;\n runAfterTransition(() => {\n // If focus did not move and the element is still in the document, focus it.\n if (document.activeElement === lastFocusedElement && document.contains(element)) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n","/*\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\nfunction isStyleVisible(element: Element) {\n if (!(element instanceof HTMLElement) && !(element instanceof 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;\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 (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) {\n return (\n element.nodeName !== '#comment' &&\n isStyleVisible(element) &&\n isAttributeVisible(element, childElement) &&\n (!element.parentElement || isElementVisible(element.parentElement, element))\n );\n}\n","/*\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) {\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, {\n ...focusProps,\n className: clsx({\n [focusClass || '']: isFocused,\n [focusRingClass || '']: isFocusVisible\n })\n }));\n}\n","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","/*\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 {DOMAttributes, FocusableDOMProps, FocusableElement, FocusableProps} from '@react-types/shared';\nimport {focusSafely} from './';\nimport {mergeProps, useSyncRef} from '@react-aria/utils';\nimport React, {MutableRefObject, ReactNode, RefObject, useContext, useEffect, useRef} from 'react';\nimport {useFocus, useKeyboard} from '@react-aria/interactions';\n\nexport interface FocusableOptions extends FocusableProps, FocusableDOMProps {\n /** Whether focus should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface FocusableProviderProps extends DOMAttributes {\n /** The child element to provide DOM props to. */\n children?: ReactNode\n}\n\ninterface FocusableContextValue extends FocusableProviderProps {\n ref?: MutableRefObject<FocusableElement>\n}\n\nlet FocusableContext = React.createContext<FocusableContextValue>(null);\n\nfunction useFocusableContext(ref: RefObject<FocusableElement>): FocusableContextValue {\n let context = useContext(FocusableContext) || {};\n useSyncRef(context, ref);\n\n // eslint-disable-next-line\n let {ref: _, ...otherProps} = context;\n return otherProps;\n}\n\n/**\n * Provides DOM props to the nearest focusable child.\n */\nfunction FocusableProvider(props: FocusableProviderProps, ref: RefObject<FocusableElement>) {\n let {children, ...otherProps} = props;\n let context = {\n ...otherProps,\n ref\n };\n\n return (\n <FocusableContext.Provider value={context}>\n {children}\n </FocusableContext.Provider>\n );\n}\n\nlet _FocusableProvider = React.forwardRef(FocusableProvider);\nexport {_FocusableProvider as FocusableProvider};\n\nexport interface FocusableAria {\n /** Props for the focusable element. */\n focusableProps: DOMAttributes\n}\n\n/**\n * Used to make an element focusable and capable of auto focus.\n */\nexport function useFocusable(props: FocusableOptions, domRef: RefObject<FocusableElement>): FocusableAria {\n let {focusProps} = useFocus(props);\n let {keyboardProps} = useKeyboard(props);\n let interactions = mergeProps(focusProps, keyboardProps);\n let domProps = useFocusableContext(domRef);\n let interactionProps = props.isDisabled ? {} : domProps;\n let autoFocusRef = useRef(props.autoFocus);\n\n useEffect(() => {\n if (autoFocusRef.current && domRef.current) {\n focusSafely(domRef.current);\n }\n autoFocusRef.current = false;\n }, [domRef]);\n\n return {\n focusableProps: mergeProps(\n {\n ...interactions,\n tabIndex: props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined\n },\n interactionProps\n )\n };\n}\n","/*\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, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\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>, 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":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -63,11 +63,11 @@ function $6a99195332edec8b$export$80f3e147d781571c(element) {
|
|
|
63
63
|
* governing permissions and limitations under the License.
|
|
64
64
|
*/ function $645f2e67b85a24c9$var$isStyleVisible(element) {
|
|
65
65
|
if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) return false;
|
|
66
|
-
let { display: display
|
|
66
|
+
let { display: display, visibility: visibility } = element.style;
|
|
67
67
|
let isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
|
|
68
68
|
if (isVisible) {
|
|
69
|
-
const { getComputedStyle: getComputedStyle
|
|
70
|
-
let { display: computedDisplay
|
|
69
|
+
const { getComputedStyle: getComputedStyle } = element.ownerDocument.defaultView;
|
|
70
|
+
let { display: computedDisplay, visibility: computedVisibility } = getComputedStyle(element);
|
|
71
71
|
isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
|
|
72
72
|
}
|
|
73
73
|
return isVisible;
|
|
@@ -85,11 +85,11 @@ function $645f2e67b85a24c9$export$e989c0fffaa6b27a(element, childElement) {
|
|
|
85
85
|
const $9bf71ea28793e738$var$FocusContext = /*#__PURE__*/ (0, $6nfFC$react).createContext(null);
|
|
86
86
|
let $9bf71ea28793e738$var$activeScope = null;
|
|
87
87
|
function $9bf71ea28793e738$export$20e40289641fbbb6(props) {
|
|
88
|
-
let { children: children
|
|
88
|
+
let { children: children, contain: contain, restoreFocus: restoreFocus, autoFocus: autoFocus } = props;
|
|
89
89
|
let startRef = (0, $6nfFC$useRef)();
|
|
90
90
|
let endRef = (0, $6nfFC$useRef)();
|
|
91
91
|
let scopeRef = (0, $6nfFC$useRef)([]);
|
|
92
|
-
let { parentNode: parentNode
|
|
92
|
+
let { parentNode: parentNode } = (0, $6nfFC$useContext)($9bf71ea28793e738$var$FocusContext) || {};
|
|
93
93
|
// Create a tree node here so we can add children to it even before it is added to the tree.
|
|
94
94
|
let node = (0, $6nfFC$useMemo)(()=>new $9bf71ea28793e738$var$TreeNode({
|
|
95
95
|
scopeRef: scopeRef
|
|
@@ -189,7 +189,7 @@ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
|
|
189
189
|
return {
|
|
190
190
|
focusNext (opts = {}) {
|
|
191
191
|
let scope = scopeRef.current;
|
|
192
|
-
let { from: from
|
|
192
|
+
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
|
|
193
193
|
let node = from || document.activeElement;
|
|
194
194
|
let sentinel = scope[0].previousElementSibling;
|
|
195
195
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
|
|
@@ -207,7 +207,7 @@ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
|
|
207
207
|
},
|
|
208
208
|
focusPrevious (opts = {}) {
|
|
209
209
|
let scope = scopeRef.current;
|
|
210
|
-
let { from: from
|
|
210
|
+
let { from: from, tabbable: tabbable, wrap: wrap, accept: accept } = opts;
|
|
211
211
|
let node = from || document.activeElement;
|
|
212
212
|
let sentinel = scope[scope.length - 1].nextElementSibling;
|
|
213
213
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
|
|
@@ -225,7 +225,7 @@ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
|
|
225
225
|
},
|
|
226
226
|
focusFirst (opts = {}) {
|
|
227
227
|
let scope = scopeRef.current;
|
|
228
|
-
let { tabbable: tabbable
|
|
228
|
+
let { tabbable: tabbable, accept: accept } = opts;
|
|
229
229
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
|
|
230
230
|
tabbable: tabbable,
|
|
231
231
|
accept: accept
|
|
@@ -237,7 +237,7 @@ function $9bf71ea28793e738$var$createFocusManagerForScope(scopeRef) {
|
|
|
237
237
|
},
|
|
238
238
|
focusLast (opts = {}) {
|
|
239
239
|
let scope = scopeRef.current;
|
|
240
|
-
let { tabbable: tabbable
|
|
240
|
+
let { tabbable: tabbable, accept: accept } = opts;
|
|
241
241
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa($9bf71ea28793e738$var$getScopeRoot(scope), {
|
|
242
242
|
tabbable: tabbable,
|
|
243
243
|
accept: accept
|
|
@@ -371,7 +371,7 @@ function $9bf71ea28793e738$var$isElementInChildScope(element, scope = null) {
|
|
|
371
371
|
if (element instanceof Element && element.closest("[data-react-aria-top-layer]")) return true;
|
|
372
372
|
// node.contains in isElementInScope covers child scopes that are also DOM children,
|
|
373
373
|
// but does not cover child scopes in portals.
|
|
374
|
-
for (let { scopeRef: s
|
|
374
|
+
for (let { scopeRef: s } of $9bf71ea28793e738$export$d06fae2ee68b101e.traverse($9bf71ea28793e738$export$d06fae2ee68b101e.getTreeNode(scope))){
|
|
375
375
|
if ($9bf71ea28793e738$var$isElementInScope(element, s.current)) return true;
|
|
376
376
|
}
|
|
377
377
|
return false;
|
|
@@ -593,7 +593,7 @@ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
593
593
|
focusNext (opts = {}) {
|
|
594
594
|
let root = ref.current;
|
|
595
595
|
if (!root) return;
|
|
596
|
-
let { from: from
|
|
596
|
+
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
|
|
597
597
|
let node = from || document.activeElement;
|
|
598
598
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
|
|
599
599
|
tabbable: tabbable,
|
|
@@ -611,7 +611,7 @@ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
611
611
|
focusPrevious (opts = defaultOptions) {
|
|
612
612
|
let root = ref.current;
|
|
613
613
|
if (!root) return;
|
|
614
|
-
let { from: from
|
|
614
|
+
let { from: from, tabbable: tabbable = defaultOptions.tabbable, wrap: wrap = defaultOptions.wrap, accept: accept = defaultOptions.accept } = opts;
|
|
615
615
|
let node = from || document.activeElement;
|
|
616
616
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
|
|
617
617
|
tabbable: tabbable,
|
|
@@ -634,7 +634,7 @@ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
634
634
|
focusFirst (opts = defaultOptions) {
|
|
635
635
|
let root = ref.current;
|
|
636
636
|
if (!root) return;
|
|
637
|
-
let { tabbable: tabbable = defaultOptions.tabbable
|
|
637
|
+
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
|
|
638
638
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
|
|
639
639
|
tabbable: tabbable,
|
|
640
640
|
accept: accept
|
|
@@ -646,7 +646,7 @@ function $9bf71ea28793e738$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
|
646
646
|
focusLast (opts = defaultOptions) {
|
|
647
647
|
let root = ref.current;
|
|
648
648
|
if (!root) return;
|
|
649
|
-
let { tabbable: tabbable = defaultOptions.tabbable
|
|
649
|
+
let { tabbable: tabbable = defaultOptions.tabbable, accept: accept = defaultOptions.accept } = opts;
|
|
650
650
|
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(root, {
|
|
651
651
|
tabbable: tabbable,
|
|
652
652
|
accept: accept
|
|
@@ -751,7 +751,7 @@ let $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree()
|
|
|
751
751
|
|
|
752
752
|
|
|
753
753
|
function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
|
|
754
|
-
let { autoFocus: autoFocus = false
|
|
754
|
+
let { autoFocus: autoFocus = false, isTextInput: isTextInput, within: within } = props;
|
|
755
755
|
let state = (0, $6nfFC$useRef)({
|
|
756
756
|
isFocused: false,
|
|
757
757
|
isFocusVisible: autoFocus || (0, $6nfFC$isFocusVisible)()
|
|
@@ -772,11 +772,11 @@ function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
|
|
|
772
772
|
}, [], {
|
|
773
773
|
isTextInput: isTextInput
|
|
774
774
|
});
|
|
775
|
-
let { focusProps: focusProps
|
|
775
|
+
let { focusProps: focusProps } = (0, $6nfFC$useFocus)({
|
|
776
776
|
isDisabled: within,
|
|
777
777
|
onFocusChange: onFocusChange
|
|
778
778
|
});
|
|
779
|
-
let { focusWithinProps: focusWithinProps
|
|
779
|
+
let { focusWithinProps: focusWithinProps } = (0, $6nfFC$useFocusWithin)({
|
|
780
780
|
isDisabled: !within,
|
|
781
781
|
onFocusWithinChange: onFocusChange
|
|
782
782
|
});
|
|
@@ -789,8 +789,8 @@ function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
|
|
|
789
789
|
|
|
790
790
|
|
|
791
791
|
function $907718708eab68af$export$1a38b4ad7f578e1d(props) {
|
|
792
|
-
let { children: children
|
|
793
|
-
let { isFocused: isFocused
|
|
792
|
+
let { children: children, focusClass: focusClass, focusRingClass: focusRingClass } = props;
|
|
793
|
+
let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $f7dceffc5ad7768b$export$4e328f61c538687f)(props);
|
|
794
794
|
let child = (0, $6nfFC$react).Children.only(children);
|
|
795
795
|
return /*#__PURE__*/ (0, $6nfFC$react).cloneElement(child, (0, $6nfFC$mergeProps)(child.props, {
|
|
796
796
|
...focusProps,
|
|
@@ -821,13 +821,13 @@ function $e6afbd83fe6ebbd2$var$useFocusableContext(ref) {
|
|
|
821
821
|
let context = (0, $6nfFC$useContext)($e6afbd83fe6ebbd2$var$FocusableContext) || {};
|
|
822
822
|
(0, $6nfFC$useSyncRef)(context, ref);
|
|
823
823
|
// eslint-disable-next-line
|
|
824
|
-
let { ref: _
|
|
824
|
+
let { ref: _, ...otherProps } = context;
|
|
825
825
|
return otherProps;
|
|
826
826
|
}
|
|
827
827
|
/**
|
|
828
828
|
* Provides DOM props to the nearest focusable child.
|
|
829
829
|
*/ function $e6afbd83fe6ebbd2$var$FocusableProvider(props, ref) {
|
|
830
|
-
let { children: children
|
|
830
|
+
let { children: children, ...otherProps } = props;
|
|
831
831
|
let context = {
|
|
832
832
|
...otherProps,
|
|
833
833
|
ref: ref
|
|
@@ -838,8 +838,8 @@ function $e6afbd83fe6ebbd2$var$useFocusableContext(ref) {
|
|
|
838
838
|
}
|
|
839
839
|
let $e6afbd83fe6ebbd2$export$13f3202a3e5ddd5 = /*#__PURE__*/ (0, $6nfFC$react).forwardRef($e6afbd83fe6ebbd2$var$FocusableProvider);
|
|
840
840
|
function $e6afbd83fe6ebbd2$export$4c014de7c8940b4c(props, domRef) {
|
|
841
|
-
let { focusProps: focusProps
|
|
842
|
-
let { keyboardProps: keyboardProps
|
|
841
|
+
let { focusProps: focusProps } = (0, $6nfFC$useFocus)(props);
|
|
842
|
+
let { keyboardProps: keyboardProps } = (0, $6nfFC$useKeyboard)(props);
|
|
843
843
|
let interactions = (0, $6nfFC$mergeProps)(focusProps, keyboardProps);
|
|
844
844
|
let domProps = $e6afbd83fe6ebb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ACA;IAEJ;AACF;;;;;AC/FA;;;;;;;;;;CAUC;;;AAmBM,SAAS,0CAAoB,GAAuB,EAAE,OAAqC;IAChG,IAAI,aAAa,oBAAA,qBAAA,KAAA,IAAA,QAAS;IAC1B,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvD,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,CAAA,gBAAA,iBAAA,KAAA,IAAA,IAAK,OAAM,KAAK,CAAC,YAAY;YAC/B,IAAI,SAAS;gBACX,IAAI,IAAI,SAAS;oBACf,IAAI,SAAS,CAAA,GAAA,yCAAqB,EAAE,IAAI,SAAS;wBAAC,UAAU;oBAAI;oBAChE,oBAAoB,CAAC,CAAC,OAAO;gBAC/B;YACF;YAEA;YAEA,qFAAqF;YACrF,IAAI,WAAW,IAAI,iBAAiB;YACpC,SAAS,QAAQ,IAAI,SAAS;gBAC5B,SAAS;gBACT,WAAW;gBACX,YAAY;gBACZ,iBAAiB;oBAAC;oBAAY;iBAAW;YAC3C;YAEA,OAAO;gBACL,qFAAqF;gBACrF,wFAAwF;gBACxF,4FAA4F;gBAC5F,yFAAyF;gBACzF,SAAS;YACX;QACF;IACF;IAEA,OAAO,aAAa,QAAQ;AAC9B;;","sources":["packages/@react-aria/focus/src/index.ts","packages/@react-aria/focus/src/FocusScope.tsx","packages/@react-aria/focus/src/focusSafely.ts","packages/@react-aria/focus/src/isElementVisible.ts","packages/@react-aria/focus/src/FocusRing.tsx","packages/@react-aria/focus/src/useFocusRing.ts","packages/@react-aria/focus/src/useFocusable.tsx","packages/@react-aria/focus/src/useHasTabbableChild.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 {FocusableProvider, useFocusable} from './useFocusable';\nexport {useFocusRing} from './useFocusRing';\nexport {focusSafely} from './focusSafely';\nexport {useHasTabbableChild} from './useHasTabbableChild';\n\nexport type {FocusScopeProps, FocusManager, FocusManagerOptions} from './FocusScope';\nexport type {FocusRingProps} from './FocusRing';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\nexport type {AriaFocusRingProps, FocusRingAria} from './useFocusRing';\n","/*\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 {FocusableElement} from '@react-types/shared';\nimport {focusSafely} from './focusSafely';\nimport {isElementVisible} from './isElementVisible';\nimport React, {ReactNode, RefObject, useContext, useEffect, useMemo, useRef} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\n\nexport interface FocusScopeProps {\n /** The contents of the focus scope. */\n children: ReactNode,\n\n /**\n * Whether to contain focus inside the scope, so users cannot\n * move focus outside, for example in a modal dialog.\n */\n contain?: boolean,\n\n /**\n * Whether to restore focus back to the element that was focused\n * when the focus scope mounted, after the focus scope unmounts.\n */\n restoreFocus?: boolean,\n\n /** Whether to auto focus the first focusable element in the focus scope on mount. */\n autoFocus?: boolean\n}\n\nexport interface FocusManagerOptions {\n /** The element to start searching from. The currently focused element by default. */\n from?: Element,\n /** Whether to only include tabbable elements, or all focusable elements. */\n tabbable?: boolean,\n /** Whether focus should wrap around when it reaches the end of the scope. */\n wrap?: boolean,\n /** A callback that determines whether the given element is focused. */\n accept?: (node: Element) => boolean\n}\n\nexport interface FocusManager {\n /** Moves focus to the next focusable or tabbable element in the focus scope. */\n focusNext(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the previous focusable or tabbable element in the focus scope. */\n focusPrevious(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the first focusable or tabbable element in the focus scope. */\n focusFirst(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the last focusable or tabbable element in the focus scope. */\n focusLast(opts?: FocusManagerOptions): FocusableElement\n}\n\ntype ScopeRef = RefObject<Element[]>;\ninterface IFocusContext {\n focusManager: FocusManager,\n parentNode: TreeNode | null\n}\n\nconst FocusContext = React.createContext<IFocusContext>(null);\n\nlet activeScope: ScopeRef = null;\n\n// This is a hacky DOM-based implementation of a FocusScope until this RFC lands in React:\n// https://github.com/reactjs/rfcs/pull/109\n\n/**\n * A FocusScope manages focus for its descendants. It supports containing focus inside\n * the scope, restoring focus to the previously focused element on unmount, and auto\n * focusing children on mount. It also acts as a container for a programmatic focus\n * management interface that can be used to move focus forward and back in response\n * to user events.\n */\nexport function FocusScope(props: FocusScopeProps) {\n let {children, contain, restoreFocus, autoFocus} = props;\n let startRef = useRef<HTMLSpanElement>();\n let endRef = useRef<HTMLSpanElement>();\n let scopeRef = useRef<Element[]>([]);\n let {parentNode} = useContext(FocusContext) || {};\n\n // Create a tree node here so we can add children to it even before it is added to the tree.\n let node = useMemo(() => new TreeNode({scopeRef}), [scopeRef]);\n\n useLayoutEffect(() => {\n // If a new scope mounts outside the active scope, (e.g. DialogContainer launched from a menu),\n // use the active scope as the parent instead of the parent from context. Layout effects run bottom\n // up, so if the parent is not yet added to the tree, don't do this. Only the outer-most FocusScope\n // that is being added should get the activeScope as its parent.\n let parent = parentNode || focusScopeTree.root;\n if (focusScopeTree.getTreeNode(parent.scopeRef) && activeScope && !isAncestorScope(activeScope, parent.scopeRef)) {\n let activeNode = focusScopeTree.getTreeNode(activeScope);\n if (activeNode) {\n parent = activeNode;\n }\n }\n\n // Add the node to the parent, and to the tree.\n parent.addChild(node);\n focusScopeTree.addNode(node);\n }, [node, parentNode]);\n\n useLayoutEffect(() => {\n let node = focusScopeTree.getTreeNode(scopeRef);\n node.contain = contain;\n }, [contain]);\n\n useLayoutEffect(() => {\n // Find all rendered nodes between the sentinels and add them to the scope.\n let node = startRef.current.nextSibling;\n let nodes = [];\n while (node && node !== endRef.current) {\n nodes.push(node);\n node = node.nextSibling;\n }\n\n scopeRef.current = nodes;\n }, [children]);\n\n useActiveScopeTracker(scopeRef, restoreFocus, contain);\n useFocusContainment(scopeRef, contain);\n useRestoreFocus(scopeRef, restoreFocus, contain);\n useAutoFocus(scopeRef, autoFocus);\n\n // this layout effect needs to run last so that focusScopeTree cleanup happens at the last moment possible\n useEffect(() => {\n if (scopeRef) {\n let activeElement = document.activeElement;\n let scope = null;\n // In strict mode, active scope is incorrectly updated since cleanup will run even though scope hasn't unmounted.\n // To fix this, we need to update the actual activeScope here\n if (isElementInScope(activeElement, scopeRef.current)) {\n // Since useLayoutEffect runs for children first, we need to traverse the focusScope tree and find the bottom most scope that\n // contains the active element and set that as the activeScope\n for (let node of focusScopeTree.traverse()) {\n if (isElementInScope(activeElement, node.scopeRef.current)) {\n scope = node;\n }\n }\n\n if (scope === focusScopeTree.getTreeNode(scopeRef)) {\n activeScope = scope.scopeRef;\n }\n }\n\n return () => {\n // Scope may have been re-parented.\n let parentScope = focusScopeTree.getTreeNode(scopeRef).parent.scopeRef;\n\n // Restore the active scope on unmount if this scope or a descendant scope is active.\n // Parent effect cleanups run before children, so we need to check if the\n // parent scope actually still exists before restoring the active scope to it.\n if (\n (scopeRef === activeScope || isAncestorScope(scopeRef, activeScope)) &&\n (!parentScope || focusScopeTree.getTreeNode(parentScope))\n ) {\n activeScope = parentScope;\n }\n focusScopeTree.removeTreeNode(scopeRef);\n };\n }\n }, [scopeRef]);\n\n let focusManager = useMemo(() => createFocusManagerForScope(scopeRef), []);\n let value = useMemo(() => ({\n focusManager,\n parentNode: node\n }), [node, focusManager]);\n\n return (\n <FocusContext.Provider value={value}>\n <span data-focus-scope-start hidden ref={startRef} />\n {children}\n <span data-focus-scope-end hidden ref={endRef} />\n </FocusContext.Provider>\n );\n}\n\n/**\n * Returns a FocusManager interface for the parent FocusScope.\n * A FocusManager can be used to programmatically move focus within\n * a FocusScope, e.g. in response to user events like keyboard navigation.\n */\nexport function useFocusManager(): FocusManager {\n return useContext(FocusContext)?.focusManager;\n}\n\nfunction createFocusManagerForScope(scopeRef: React.RefObject<Element[]>): FocusManager {\n return {\n focusNext(opts: FocusManagerOptions = {}) {\n let scope = scopeRef.current;\n let {from, tabbable, wrap, accept} = opts;\n let node = from || document.activeElement;\n let sentinel = scope[0].previousElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let nextNode = walker.nextNode() as FocusableElement;\n if (!nextNode && wrap) {\n walker.currentNode = sentinel;\n nextNode = walker.nextNode() as FocusableElement;\n }\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = {}) {\n let scope = scopeRef.current;\n let {from, tabbable, wrap, accept} = opts;\n let node = from || document.activeElement;\n let sentinel = scope[scope.length - 1].nextElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let previousNode = walker.previousNode() as FocusableElement;\n if (!previousNode && wrap) {\n walker.currentNode = sentinel;\n previousNode = walker.previousNode() as FocusableElement;\n }\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n },\n focusFirst(opts = {}) {\n let scope = scopeRef.current;\n let {tabbable, accept} = opts;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = scope[0].previousElementSibling;\n let nextNode = walker.nextNode() as FocusableElement;\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusLast(opts = {}) {\n let scope = scopeRef.current;\n let {tabbable, accept} = opts;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = scope[scope.length - 1].nextElementSibling;\n let previousNode = walker.previousNode() as FocusableElement;\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n }\n };\n}\n\nconst focusableElements = [\n 'input:not([disabled]):not([type=hidden])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'button:not([disabled])',\n 'a[href]',\n 'area[href]',\n 'summary',\n 'iframe',\n 'object',\n 'embed',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]'\n];\n\nconst FOCUSABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';\n\nfocusableElements.push('[tabindex]:not([tabindex=\"-1\"]):not([disabled])');\nconst TABBABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]):not([tabindex=\"-1\"]),');\n\nfunction getScopeRoot(scope: Element[]) {\n return scope[0].parentElement;\n}\n\nfunction shouldContainFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.contain) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return true;\n}\n\nfunction useFocusContainment(scopeRef: RefObject<Element[]>, contain: boolean) {\n let focusedNode = useRef<FocusableElement>();\n\n let raf = useRef(null);\n useLayoutEffect(() => {\n let scope = scopeRef.current;\n if (!contain) {\n // if contain was changed, then we should cancel any ongoing waits to pull focus back into containment\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n raf.current = null;\n }\n return;\n }\n\n // Handle the Tab key to contain focus within the scope\n let onKeyDown = (e) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !shouldContainFocus(scopeRef)) {\n return;\n }\n\n let focusedElement = document.activeElement;\n let scope = scopeRef.current;\n if (!isElementInScope(focusedElement, scope)) {\n return;\n }\n\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable: true}, scope);\n walker.currentNode = focusedElement;\n let nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n if (!nextElement) {\n walker.currentNode = e.shiftKey ? scope[scope.length - 1].nextElementSibling : scope[0].previousElementSibling;\n nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n }\n\n e.preventDefault();\n if (nextElement) {\n focusElement(nextElement, true);\n }\n };\n\n let onFocus = (e) => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if ((!activeScope || isAncestorScope(activeScope, scopeRef)) && isElementInScope(e.target, scopeRef.current)) {\n activeScope = scopeRef;\n focusedNode.current = e.target;\n } else if (shouldContainFocus(scopeRef) && !isElementInChildScope(e.target, scopeRef)) {\n // If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),\n // restore focus to the previously focused node or the first tabbable element in the active scope.\n if (focusedNode.current) {\n focusedNode.current.focus();\n } else if (activeScope) {\n focusFirstInScope(activeScope.current);\n }\n } else if (shouldContainFocus(scopeRef)) {\n focusedNode.current = e.target;\n }\n };\n\n let onBlur = (e) => {\n // Firefox doesn't shift focus back to the Dialog properly without this\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n raf.current = requestAnimationFrame(() => {\n // Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe\n if (shouldContainFocus(scopeRef) && !isElementInChildScope(document.activeElement, scopeRef)) {\n activeScope = scopeRef;\n if (document.body.contains(e.target)) {\n focusedNode.current = e.target;\n focusedNode.current.focus();\n } else if (activeScope) {\n focusFirstInScope(activeScope.current);\n }\n }\n });\n };\n\n document.addEventListener('keydown', onKeyDown, false);\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n scope.forEach(element => element.addEventListener('focusout', onBlur, false));\n return () => {\n document.removeEventListener('keydown', onKeyDown, false);\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n scope.forEach(element => element.removeEventListener('focusout', onBlur, false));\n };\n }, [scopeRef, contain]);\n\n // This is a useLayoutEffect so it is guaranteed to run before our async synthetic blur\n // eslint-disable-next-line arrow-body-style\n useLayoutEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, [raf]);\n}\n\nfunction isElementInAnyScope(element: Element) {\n return isElementInChildScope(element);\n}\n\nfunction isElementInScope(element: Element, scope: Element[]) {\n return scope.some(node => node.contains(element));\n}\n\nfunction isElementInChildScope(element: Element, scope: ScopeRef = null) {\n // If the element is within a top layer element (e.g. toasts), always allow moving focus there.\n if (element instanceof Element && element.closest('[data-react-aria-top-layer]')) {\n return true;\n }\n\n // node.contains in isElementInScope covers child scopes that are also DOM children,\n // but does not cover child scopes in portals.\n for (let {scopeRef: s} of focusScopeTree.traverse(focusScopeTree.getTreeNode(scope))) {\n if (isElementInScope(element, s.current)) {\n return true;\n }\n }\n\n return false;\n}\n\n/** @private */\nexport function isElementInChildOfActiveScope(element: Element) {\n return isElementInChildScope(element, activeScope);\n}\n\nfunction isAncestorScope(ancestor: ScopeRef, scope: ScopeRef) {\n let parent = focusScopeTree.getTreeNode(scope)?.parent;\n while (parent) {\n if (parent.scopeRef === ancestor) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n}\n\nfunction focusElement(element: FocusableElement | null, scroll = false) {\n if (element != null && !scroll) {\n try {\n focusSafely(element);\n } catch (err) {\n // ignore\n }\n } else if (element != null) {\n try {\n element.focus();\n } catch (err) {\n // ignore\n }\n }\n}\n\nfunction focusFirstInScope(scope: Element[], tabbable:boolean = true) {\n let sentinel = scope[0].previousElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable}, scope);\n walker.currentNode = sentinel;\n let nextNode = walker.nextNode();\n\n // If the scope does not contain a tabbable element, use the first focusable element.\n if (tabbable && !nextNode) {\n walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable: false}, scope);\n walker.currentNode = sentinel;\n nextNode = walker.nextNode();\n }\n\n focusElement(nextNode as FocusableElement);\n}\n\nfunction useAutoFocus(scopeRef: RefObject<Element[]>, autoFocus: boolean) {\n const autoFocusRef = React.useRef(autoFocus);\n useEffect(() => {\n if (autoFocusRef.current) {\n activeScope = scopeRef;\n if (!isElementInScope(document.activeElement, activeScope.current)) {\n focusFirstInScope(scopeRef.current);\n }\n }\n autoFocusRef.current = false;\n }, [scopeRef]);\n}\n\nfunction useActiveScopeTracker(scopeRef: RefObject<Element[]>, restore: boolean, contain: boolean) {\n // tracks the active scope, in case restore and contain are both false.\n // if either are true, this is tracked in useRestoreFocus or useFocusContainment.\n useLayoutEffect(() => {\n if (restore || contain) {\n return;\n }\n\n let scope = scopeRef.current;\n\n let onFocus = (e: FocusEvent) => {\n let target = e.target as Element;\n if (isElementInScope(target, scopeRef.current)) {\n activeScope = scopeRef;\n } else if (!isElementInAnyScope(target)) {\n activeScope = null;\n }\n };\n\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n return () => {\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n };\n }, [scopeRef, restore, contain]);\n}\n\nfunction shouldRestoreFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.nodeToRestore) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return scope?.scopeRef === scopeRef;\n}\n\nfunction useRestoreFocus(scopeRef: RefObject<Element[]>, restoreFocus: boolean, contain: boolean) {\n // create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.\n const nodeToRestoreRef = useRef(typeof document !== 'undefined' ? document.activeElement as FocusableElement : null);\n\n // restoring scopes should all track if they are active regardless of contain, but contain already tracks it plus logic to contain the focus\n // restoring-non-containing scopes should only care if they become active so they can perform the restore\n useLayoutEffect(() => {\n let scope = scopeRef.current;\n if (!restoreFocus || contain) {\n return;\n }\n\n let onFocus = () => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if ((!activeScope || isAncestorScope(activeScope, scopeRef)) &&\n isElementInScope(document.activeElement, scopeRef.current)\n ) {\n activeScope = scopeRef;\n }\n };\n\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n return () => {\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [scopeRef, contain]);\n\n useLayoutEffect(() => {\n if (!restoreFocus) {\n return;\n }\n\n // Handle the Tab key so that tabbing out of the scope goes to the next element\n // after the node that had focus when the scope mounted. This is important when\n // using portals for overlays, so that focus goes to the expected element when\n // tabbing out of the overlay.\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !shouldContainFocus(scopeRef)) {\n return;\n }\n\n let focusedElement = document.activeElement as FocusableElement;\n if (!isElementInScope(focusedElement, scopeRef.current)) {\n return;\n }\n let nodeToRestore = focusScopeTree.getTreeNode(scopeRef).nodeToRestore;\n\n // Create a DOM tree walker that matches all tabbable elements\n let walker = getFocusableTreeWalker(document.body, {tabbable: true});\n\n // Find the next tabbable element after the currently focused element\n walker.currentNode = focusedElement;\n let nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n\n if (!document.body.contains(nodeToRestore) || nodeToRestore === document.body) {\n nodeToRestore = null;\n focusScopeTree.getTreeNode(scopeRef).nodeToRestore = null;\n }\n\n // If there is no next element, or it is outside the current scope, move focus to the\n // next element after the node to restore to instead.\n if ((!nextElement || !isElementInScope(nextElement, scopeRef.current)) && nodeToRestore) {\n walker.currentNode = nodeToRestore;\n\n // Skip over elements within the scope, in case the scope immediately follows the node to restore.\n do {\n nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n } while (isElementInScope(nextElement, scopeRef.current));\n\n e.preventDefault();\n e.stopPropagation();\n if (nextElement) {\n focusElement(nextElement, true);\n } else {\n // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)\n // then move focus to the body.\n // Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)\n if (!isElementInAnyScope(nodeToRestore)) {\n focusedElement.blur();\n } else {\n focusElement(nodeToRestore, true);\n }\n }\n }\n };\n\n if (!contain) {\n document.addEventListener('keydown', onKeyDown, true);\n }\n\n return () => {\n if (!contain) {\n document.removeEventListener('keydown', onKeyDown, true);\n }\n };\n }, [scopeRef, restoreFocus, contain]);\n\n // useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.\n useLayoutEffect(() => {\n if (!restoreFocus) {\n return;\n }\n\n focusScopeTree.getTreeNode(scopeRef).nodeToRestore = nodeToRestoreRef.current;\n\n return () => {\n let nodeToRestore = focusScopeTree.getTreeNode(scopeRef).nodeToRestore;\n\n // if we already lost focus to the body and this was the active scope, then we should attempt to restore\n if (\n restoreFocus\n && nodeToRestore\n && (\n // eslint-disable-next-line react-hooks/exhaustive-deps\n isElementInScope(document.activeElement, scopeRef.current)\n || (document.activeElement === document.body && shouldRestoreFocus(scopeRef))\n )\n ) {\n // freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it\n let clonedTree = focusScopeTree.clone();\n requestAnimationFrame(() => {\n // Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere\n if (document.activeElement === document.body) {\n // look up the tree starting with our scope to find a nodeToRestore still in the DOM\n let treeNode = clonedTree.getTreeNode(scopeRef);\n while (treeNode) {\n if (treeNode.nodeToRestore && document.body.contains(treeNode.nodeToRestore)) {\n focusElement(treeNode.nodeToRestore);\n return;\n }\n treeNode = treeNode.parent;\n }\n\n // If no nodeToRestore was found, focus the first element in the nearest\n // ancestor scope that is still in the tree.\n treeNode = clonedTree.getTreeNode(scopeRef);\n while (treeNode) {\n if (treeNode.scopeRef && focusScopeTree.getTreeNode(treeNode.scopeRef)) {\n focusFirstInScope(treeNode.scopeRef.current, true);\n return;\n }\n treeNode = treeNode.parent;\n }\n }\n });\n }\n };\n }, [scopeRef, restoreFocus]);\n}\n\n/**\n * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}\n * that matches all focusable/tabbable elements.\n */\nexport function getFocusableTreeWalker(root: Element, opts?: FocusManagerOptions, scope?: Element[]) {\n let selector = opts?.tabbable ? TABBABLE_ELEMENT_SELECTOR : FOCUSABLE_ELEMENT_SELECTOR;\n let walker = document.createTreeWalker(\n root,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode(node) {\n // Skip nodes inside the starting node.\n if (opts?.from?.contains(node)) {\n return NodeFilter.FILTER_REJECT;\n }\n\n if ((node as Element).matches(selector)\n && isElementVisible(node as Element)\n && (!scope || isElementInScope(node as Element, scope))\n && (!opts?.accept || opts.accept(node as Element))\n ) {\n return NodeFilter.FILTER_ACCEPT;\n }\n\n return NodeFilter.FILTER_SKIP;\n }\n }\n );\n\n if (opts?.from) {\n walker.currentNode = opts.from;\n }\n\n return walker;\n}\n\n/**\n * Creates a FocusManager object that can be used to move focus within an element.\n */\nexport function createFocusManager(ref: RefObject<Element>, defaultOptions: FocusManagerOptions = {}): FocusManager {\n return {\n focusNext(opts: FocusManagerOptions = {}) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept} = opts;\n let node = from || document.activeElement;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n if (root.contains(node)) {\n walker.currentNode = node;\n }\n let nextNode = walker.nextNode() as FocusableElement;\n if (!nextNode && wrap) {\n walker.currentNode = root;\n nextNode = walker.nextNode() as FocusableElement;\n }\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept} = opts;\n let node = from || document.activeElement;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n if (root.contains(node)) {\n walker.currentNode = node;\n } else {\n let next = last(walker);\n if (next) {\n focusElement(next, true);\n }\n return next;\n }\n let previousNode = walker.previousNode() as FocusableElement;\n if (!previousNode && wrap) {\n walker.currentNode = root;\n previousNode = last(walker);\n }\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n },\n focusFirst(opts = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {tabbable = defaultOptions.tabbable, accept = defaultOptions.accept} = opts;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n let nextNode = walker.nextNode() as FocusableElement;\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusLast(opts = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {tabbable = defaultOptions.tabbable, accept = defaultOptions.accept} = opts;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n let next = last(walker);\n if (next) {\n focusElement(next, true);\n }\n return next;\n }\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\n\nclass Tree {\n root: TreeNode;\n private fastMap = new Map<ScopeRef, TreeNode>();\n\n constructor() {\n this.root = new TreeNode({scopeRef: null});\n this.fastMap.set(null, this.root);\n }\n\n get size() {\n return this.fastMap.size;\n }\n\n getTreeNode(data: ScopeRef) {\n return this.fastMap.get(data);\n }\n\n addTreeNode(scopeRef: ScopeRef, parent: ScopeRef, nodeToRestore?: FocusableElement) {\n let parentNode = this.fastMap.get(parent ?? null);\n let node = new TreeNode({scopeRef});\n parentNode.addChild(node);\n node.parent = parentNode;\n this.fastMap.set(scopeRef, node);\n if (nodeToRestore) {\n node.nodeToRestore = nodeToRestore;\n }\n }\n\n addNode(node: TreeNode) {\n this.fastMap.set(node.scopeRef, node);\n }\n\n removeTreeNode(scopeRef: ScopeRef) {\n // never remove the root\n if (scopeRef === null) {\n return;\n }\n let node = this.fastMap.get(scopeRef);\n let parentNode = node.parent;\n // when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing\n // if we are, then replace the siblings restore with the restore from the scope we're removing\n for (let current of this.traverse()) {\n if (\n current !== node &&\n node.nodeToRestore &&\n current.nodeToRestore &&\n node.scopeRef.current &&\n isElementInScope(current.nodeToRestore, node.scopeRef.current)\n ) {\n current.nodeToRestore = node.nodeToRestore;\n }\n }\n let children = node.children;\n parentNode.removeChild(node);\n if (children.size > 0) {\n children.forEach(child => parentNode.addChild(child));\n }\n\n this.fastMap.delete(node.scopeRef);\n }\n\n // Pre Order Depth First\n *traverse(node: TreeNode = this.root): Generator<TreeNode> {\n if (node.scopeRef != null) {\n yield node;\n }\n if (node.children.size > 0) {\n for (let child of node.children) {\n yield* this.traverse(child);\n }\n }\n }\n\n clone(): Tree {\n let newTree = new Tree();\n for (let node of this.traverse()) {\n newTree.addTreeNode(node.scopeRef, node.parent.scopeRef, node.nodeToRestore);\n }\n return newTree;\n }\n}\n\nclass TreeNode {\n public scopeRef: ScopeRef;\n public nodeToRestore: FocusableElement;\n public parent: TreeNode;\n public children: Set<TreeNode> = new Set();\n public contain = false;\n\n constructor(props: {scopeRef: ScopeRef}) {\n this.scopeRef = props.scopeRef;\n }\n addChild(node: TreeNode) {\n this.children.add(node);\n node.parent = this;\n }\n removeChild(node: TreeNode) {\n this.children.delete(node);\n node.parent = undefined;\n }\n}\n\nexport let focusScopeTree = new Tree();\n","/*\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 {FocusableElement} from '@react-types/shared';\nimport {focusWithoutScrolling, runAfterTransition} from '@react-aria/utils';\nimport {getInteractionModality} from '@react-aria/interactions';\n\n/**\n * A utility function that focuses an element while avoiding undesired side effects such\n * as page scrolling and screen reader issues with CSS transitions.\n */\nexport function focusSafely(element: FocusableElement) {\n // If the user is interacting with a virtual cursor, e.g. screen reader, then\n // wait until after any animated transitions that are currently occurring on\n // the page before shifting focus. This avoids issues with VoiceOver on iOS\n // causing the page to scroll when moving focus if the element is transitioning\n // from off the screen.\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = document.activeElement;\n runAfterTransition(() => {\n // If focus did not move and the element is still in the document, focus it.\n if (document.activeElement === lastFocusedElement && document.contains(element)) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n","/*\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\nfunction isStyleVisible(element: Element) {\n if (!(element instanceof HTMLElement) && !(element instanceof 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;\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 (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) {\n return (\n element.nodeName !== '#comment' &&\n isStyleVisible(element) &&\n isAttributeVisible(element, childElement) &&\n (!element.parentElement || isElementVisible(element.parentElement, element))\n );\n}\n","/*\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) {\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, {\n ...focusProps,\n className: clsx({\n [focusClass || '']: isFocused,\n [focusRingClass || '']: isFocusVisible\n })\n }));\n}\n","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","/*\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 {DOMAttributes, FocusableDOMProps, FocusableElement, FocusableProps} from '@react-types/shared';\nimport {focusSafely} from './';\nimport {mergeProps, useSyncRef} from '@react-aria/utils';\nimport React, {MutableRefObject, ReactNode, RefObject, useContext, useEffect, useRef} from 'react';\nimport {useFocus, useKeyboard} from '@react-aria/interactions';\n\nexport interface FocusableOptions extends FocusableProps, FocusableDOMProps {\n /** Whether focus should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface FocusableProviderProps extends DOMAttributes {\n /** The child element to provide DOM props to. */\n children?: ReactNode\n}\n\ninterface FocusableContextValue extends FocusableProviderProps {\n ref?: MutableRefObject<FocusableElement>\n}\n\nlet FocusableContext = React.createContext<FocusableContextValue>(null);\n\nfunction useFocusableContext(ref: RefObject<FocusableElement>): FocusableContextValue {\n let context = useContext(FocusableContext) || {};\n useSyncRef(context, ref);\n\n // eslint-disable-next-line\n let {ref: _, ...otherProps} = context;\n return otherProps;\n}\n\n/**\n * Provides DOM props to the nearest focusable child.\n */\nfunction FocusableProvider(props: FocusableProviderProps, ref: RefObject<FocusableElement>) {\n let {children, ...otherProps} = props;\n let context = {\n ...otherProps,\n ref\n };\n\n return (\n <FocusableContext.Provider value={context}>\n {children}\n </FocusableContext.Provider>\n );\n}\n\nlet _FocusableProvider = React.forwardRef(FocusableProvider);\nexport {_FocusableProvider as FocusableProvider};\n\nexport interface FocusableAria {\n /** Props for the focusable element. */\n focusableProps: DOMAttributes\n}\n\n/**\n * Used to make an element focusable and capable of auto focus.\n */\nexport function useFocusable(props: FocusableOptions, domRef: RefObject<FocusableElement>): FocusableAria {\n let {focusProps} = useFocus(props);\n let {keyboardProps} = useKeyboard(props);\n let interactions = mergeProps(focusProps, keyboardProps);\n let domProps = useFocusableContext(domRef);\n let interactionProps = props.isDisabled ? {} : domProps;\n let autoFocusRef = useRef(props.autoFocus);\n\n useEffect(() => {\n if (autoFocusRef.current && domRef.current) {\n focusSafely(domRef.current);\n }\n autoFocusRef.current = false;\n }, [domRef]);\n\n return {\n focusableProps: mergeProps(\n {\n ...interactions,\n tabIndex: props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined\n },\n interactionProps\n )\n };\n}\n","/*\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, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\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>, 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":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;AAUM,SAAS,0CAAY,OAAyB;IACnD,6EAA6E;IAC7E,4EAA4E;IAC5E,2EAA2E;IAC3E,+EAA+E;IAC/E,uBAAuB;IACvB,IAAI,CAAA,GAAA,6BAAqB,QAAQ,WAAW;QAC1C,IAAI,qBAAqB,SAAS;QAClC,CAAA,GAAA,yBAAiB,EAAE;YACjB,4EAA4E;YAC5E,IAAI,SAAS,kBAAkB,sBAAsB,SAAS,SAAS,UACrE,CAAA,GAAA,4BAAoB,EAAE;QAE1B;IACF,OACE,CAAA,GAAA,4BAAoB,EAAE;AAE1B;;CD3BC;AEVD;;;;;;;;;;CAUC,GAED,SAAS,qCAAe,OAAgB;IACtC,IAAI,CAAE,CAAA,mBAAmB,WAAU,KAAM,CAAE,CAAA,mBAAmB,UAAS,GACrE,OAAO;IAGT,IAAI,WAAC,O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;gBAC5F,yFAAyF;gBACzF,SAAS;YACX;QACF;IACF;IAEA,OAAO,aAAa,QAAQ;AAC9B;;","sources":["packages/@react-aria/focus/src/index.ts","packages/@react-aria/focus/src/FocusScope.tsx","packages/@react-aria/focus/src/focusSafely.ts","packages/@react-aria/focus/src/isElementVisible.ts","packages/@react-aria/focus/src/FocusRing.tsx","packages/@react-aria/focus/src/useFocusRing.ts","packages/@react-aria/focus/src/useFocusable.tsx","packages/@react-aria/focus/src/useHasTabbableChild.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 {FocusableProvider, useFocusable} from './useFocusable';\nexport {useFocusRing} from './useFocusRing';\nexport {focusSafely} from './focusSafely';\nexport {useHasTabbableChild} from './useHasTabbableChild';\n\nexport type {FocusScopeProps, FocusManager, FocusManagerOptions} from './FocusScope';\nexport type {FocusRingProps} from './FocusRing';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\nexport type {AriaFocusRingProps, FocusRingAria} from './useFocusRing';\n","/*\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 {FocusableElement} from '@react-types/shared';\nimport {focusSafely} from './focusSafely';\nimport {isElementVisible} from './isElementVisible';\nimport React, {ReactNode, RefObject, useContext, useEffect, useMemo, useRef} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\n\nexport interface FocusScopeProps {\n /** The contents of the focus scope. */\n children: ReactNode,\n\n /**\n * Whether to contain focus inside the scope, so users cannot\n * move focus outside, for example in a modal dialog.\n */\n contain?: boolean,\n\n /**\n * Whether to restore focus back to the element that was focused\n * when the focus scope mounted, after the focus scope unmounts.\n */\n restoreFocus?: boolean,\n\n /** Whether to auto focus the first focusable element in the focus scope on mount. */\n autoFocus?: boolean\n}\n\nexport interface FocusManagerOptions {\n /** The element to start searching from. The currently focused element by default. */\n from?: Element,\n /** Whether to only include tabbable elements, or all focusable elements. */\n tabbable?: boolean,\n /** Whether focus should wrap around when it reaches the end of the scope. */\n wrap?: boolean,\n /** A callback that determines whether the given element is focused. */\n accept?: (node: Element) => boolean\n}\n\nexport interface FocusManager {\n /** Moves focus to the next focusable or tabbable element in the focus scope. */\n focusNext(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the previous focusable or tabbable element in the focus scope. */\n focusPrevious(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the first focusable or tabbable element in the focus scope. */\n focusFirst(opts?: FocusManagerOptions): FocusableElement,\n /** Moves focus to the last focusable or tabbable element in the focus scope. */\n focusLast(opts?: FocusManagerOptions): FocusableElement\n}\n\ntype ScopeRef = RefObject<Element[]>;\ninterface IFocusContext {\n focusManager: FocusManager,\n parentNode: TreeNode | null\n}\n\nconst FocusContext = React.createContext<IFocusContext>(null);\n\nlet activeScope: ScopeRef = null;\n\n// This is a hacky DOM-based implementation of a FocusScope until this RFC lands in React:\n// https://github.com/reactjs/rfcs/pull/109\n\n/**\n * A FocusScope manages focus for its descendants. It supports containing focus inside\n * the scope, restoring focus to the previously focused element on unmount, and auto\n * focusing children on mount. It also acts as a container for a programmatic focus\n * management interface that can be used to move focus forward and back in response\n * to user events.\n */\nexport function FocusScope(props: FocusScopeProps) {\n let {children, contain, restoreFocus, autoFocus} = props;\n let startRef = useRef<HTMLSpanElement>();\n let endRef = useRef<HTMLSpanElement>();\n let scopeRef = useRef<Element[]>([]);\n let {parentNode} = useContext(FocusContext) || {};\n\n // Create a tree node here so we can add children to it even before it is added to the tree.\n let node = useMemo(() => new TreeNode({scopeRef}), [scopeRef]);\n\n useLayoutEffect(() => {\n // If a new scope mounts outside the active scope, (e.g. DialogContainer launched from a menu),\n // use the active scope as the parent instead of the parent from context. Layout effects run bottom\n // up, so if the parent is not yet added to the tree, don't do this. Only the outer-most FocusScope\n // that is being added should get the activeScope as its parent.\n let parent = parentNode || focusScopeTree.root;\n if (focusScopeTree.getTreeNode(parent.scopeRef) && activeScope && !isAncestorScope(activeScope, parent.scopeRef)) {\n let activeNode = focusScopeTree.getTreeNode(activeScope);\n if (activeNode) {\n parent = activeNode;\n }\n }\n\n // Add the node to the parent, and to the tree.\n parent.addChild(node);\n focusScopeTree.addNode(node);\n }, [node, parentNode]);\n\n useLayoutEffect(() => {\n let node = focusScopeTree.getTreeNode(scopeRef);\n node.contain = contain;\n }, [contain]);\n\n useLayoutEffect(() => {\n // Find all rendered nodes between the sentinels and add them to the scope.\n let node = startRef.current.nextSibling;\n let nodes = [];\n while (node && node !== endRef.current) {\n nodes.push(node);\n node = node.nextSibling;\n }\n\n scopeRef.current = nodes;\n }, [children]);\n\n useActiveScopeTracker(scopeRef, restoreFocus, contain);\n useFocusContainment(scopeRef, contain);\n useRestoreFocus(scopeRef, restoreFocus, contain);\n useAutoFocus(scopeRef, autoFocus);\n\n // this layout effect needs to run last so that focusScopeTree cleanup happens at the last moment possible\n useEffect(() => {\n if (scopeRef) {\n let activeElement = document.activeElement;\n let scope = null;\n // In strict mode, active scope is incorrectly updated since cleanup will run even though scope hasn't unmounted.\n // To fix this, we need to update the actual activeScope here\n if (isElementInScope(activeElement, scopeRef.current)) {\n // Since useLayoutEffect runs for children first, we need to traverse the focusScope tree and find the bottom most scope that\n // contains the active element and set that as the activeScope\n for (let node of focusScopeTree.traverse()) {\n if (isElementInScope(activeElement, node.scopeRef.current)) {\n scope = node;\n }\n }\n\n if (scope === focusScopeTree.getTreeNode(scopeRef)) {\n activeScope = scope.scopeRef;\n }\n }\n\n return () => {\n // Scope may have been re-parented.\n let parentScope = focusScopeTree.getTreeNode(scopeRef).parent.scopeRef;\n\n // Restore the active scope on unmount if this scope or a descendant scope is active.\n // Parent effect cleanups run before children, so we need to check if the\n // parent scope actually still exists before restoring the active scope to it.\n if (\n (scopeRef === activeScope || isAncestorScope(scopeRef, activeScope)) &&\n (!parentScope || focusScopeTree.getTreeNode(parentScope))\n ) {\n activeScope = parentScope;\n }\n focusScopeTree.removeTreeNode(scopeRef);\n };\n }\n }, [scopeRef]);\n\n let focusManager = useMemo(() => createFocusManagerForScope(scopeRef), []);\n let value = useMemo(() => ({\n focusManager,\n parentNode: node\n }), [node, focusManager]);\n\n return (\n <FocusContext.Provider value={value}>\n <span data-focus-scope-start hidden ref={startRef} />\n {children}\n <span data-focus-scope-end hidden ref={endRef} />\n </FocusContext.Provider>\n );\n}\n\n/**\n * Returns a FocusManager interface for the parent FocusScope.\n * A FocusManager can be used to programmatically move focus within\n * a FocusScope, e.g. in response to user events like keyboard navigation.\n */\nexport function useFocusManager(): FocusManager {\n return useContext(FocusContext)?.focusManager;\n}\n\nfunction createFocusManagerForScope(scopeRef: React.RefObject<Element[]>): FocusManager {\n return {\n focusNext(opts: FocusManagerOptions = {}) {\n let scope = scopeRef.current;\n let {from, tabbable, wrap, accept} = opts;\n let node = from || document.activeElement;\n let sentinel = scope[0].previousElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let nextNode = walker.nextNode() as FocusableElement;\n if (!nextNode && wrap) {\n walker.currentNode = sentinel;\n nextNode = walker.nextNode() as FocusableElement;\n }\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = {}) {\n let scope = scopeRef.current;\n let {from, tabbable, wrap, accept} = opts;\n let node = from || document.activeElement;\n let sentinel = scope[scope.length - 1].nextElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let previousNode = walker.previousNode() as FocusableElement;\n if (!previousNode && wrap) {\n walker.currentNode = sentinel;\n previousNode = walker.previousNode() as FocusableElement;\n }\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n },\n focusFirst(opts = {}) {\n let scope = scopeRef.current;\n let {tabbable, accept} = opts;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = scope[0].previousElementSibling;\n let nextNode = walker.nextNode() as FocusableElement;\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusLast(opts = {}) {\n let scope = scopeRef.current;\n let {tabbable, accept} = opts;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable, accept}, scope);\n walker.currentNode = scope[scope.length - 1].nextElementSibling;\n let previousNode = walker.previousNode() as FocusableElement;\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n }\n };\n}\n\nconst focusableElements = [\n 'input:not([disabled]):not([type=hidden])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n 'button:not([disabled])',\n 'a[href]',\n 'area[href]',\n 'summary',\n 'iframe',\n 'object',\n 'embed',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]'\n];\n\nconst FOCUSABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';\n\nfocusableElements.push('[tabindex]:not([tabindex=\"-1\"]):not([disabled])');\nconst TABBABLE_ELEMENT_SELECTOR = focusableElements.join(':not([hidden]):not([tabindex=\"-1\"]),');\n\nfunction getScopeRoot(scope: Element[]) {\n return scope[0].parentElement;\n}\n\nfunction shouldContainFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.contain) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return true;\n}\n\nfunction useFocusContainment(scopeRef: RefObject<Element[]>, contain: boolean) {\n let focusedNode = useRef<FocusableElement>();\n\n let raf = useRef(null);\n useLayoutEffect(() => {\n let scope = scopeRef.current;\n if (!contain) {\n // if contain was changed, then we should cancel any ongoing waits to pull focus back into containment\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n raf.current = null;\n }\n return;\n }\n\n // Handle the Tab key to contain focus within the scope\n let onKeyDown = (e) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !shouldContainFocus(scopeRef)) {\n return;\n }\n\n let focusedElement = document.activeElement;\n let scope = scopeRef.current;\n if (!isElementInScope(focusedElement, scope)) {\n return;\n }\n\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable: true}, scope);\n walker.currentNode = focusedElement;\n let nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n if (!nextElement) {\n walker.currentNode = e.shiftKey ? scope[scope.length - 1].nextElementSibling : scope[0].previousElementSibling;\n nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n }\n\n e.preventDefault();\n if (nextElement) {\n focusElement(nextElement, true);\n }\n };\n\n let onFocus = (e) => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if ((!activeScope || isAncestorScope(activeScope, scopeRef)) && isElementInScope(e.target, scopeRef.current)) {\n activeScope = scopeRef;\n focusedNode.current = e.target;\n } else if (shouldContainFocus(scopeRef) && !isElementInChildScope(e.target, scopeRef)) {\n // If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),\n // restore focus to the previously focused node or the first tabbable element in the active scope.\n if (focusedNode.current) {\n focusedNode.current.focus();\n } else if (activeScope) {\n focusFirstInScope(activeScope.current);\n }\n } else if (shouldContainFocus(scopeRef)) {\n focusedNode.current = e.target;\n }\n };\n\n let onBlur = (e) => {\n // Firefox doesn't shift focus back to the Dialog properly without this\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n raf.current = requestAnimationFrame(() => {\n // Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe\n if (shouldContainFocus(scopeRef) && !isElementInChildScope(document.activeElement, scopeRef)) {\n activeScope = scopeRef;\n if (document.body.contains(e.target)) {\n focusedNode.current = e.target;\n focusedNode.current.focus();\n } else if (activeScope) {\n focusFirstInScope(activeScope.current);\n }\n }\n });\n };\n\n document.addEventListener('keydown', onKeyDown, false);\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n scope.forEach(element => element.addEventListener('focusout', onBlur, false));\n return () => {\n document.removeEventListener('keydown', onKeyDown, false);\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n scope.forEach(element => element.removeEventListener('focusout', onBlur, false));\n };\n }, [scopeRef, contain]);\n\n // This is a useLayoutEffect so it is guaranteed to run before our async synthetic blur\n // eslint-disable-next-line arrow-body-style\n useLayoutEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, [raf]);\n}\n\nfunction isElementInAnyScope(element: Element) {\n return isElementInChildScope(element);\n}\n\nfunction isElementInScope(element: Element, scope: Element[]) {\n return scope.some(node => node.contains(element));\n}\n\nfunction isElementInChildScope(element: Element, scope: ScopeRef = null) {\n // If the element is within a top layer element (e.g. toasts), always allow moving focus there.\n if (element instanceof Element && element.closest('[data-react-aria-top-layer]')) {\n return true;\n }\n\n // node.contains in isElementInScope covers child scopes that are also DOM children,\n // but does not cover child scopes in portals.\n for (let {scopeRef: s} of focusScopeTree.traverse(focusScopeTree.getTreeNode(scope))) {\n if (isElementInScope(element, s.current)) {\n return true;\n }\n }\n\n return false;\n}\n\n/** @private */\nexport function isElementInChildOfActiveScope(element: Element) {\n return isElementInChildScope(element, activeScope);\n}\n\nfunction isAncestorScope(ancestor: ScopeRef, scope: ScopeRef) {\n let parent = focusScopeTree.getTreeNode(scope)?.parent;\n while (parent) {\n if (parent.scopeRef === ancestor) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n}\n\nfunction focusElement(element: FocusableElement | null, scroll = false) {\n if (element != null && !scroll) {\n try {\n focusSafely(element);\n } catch (err) {\n // ignore\n }\n } else if (element != null) {\n try {\n element.focus();\n } catch (err) {\n // ignore\n }\n }\n}\n\nfunction focusFirstInScope(scope: Element[], tabbable:boolean = true) {\n let sentinel = scope[0].previousElementSibling;\n let walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable}, scope);\n walker.currentNode = sentinel;\n let nextNode = walker.nextNode();\n\n // If the scope does not contain a tabbable element, use the first focusable element.\n if (tabbable && !nextNode) {\n walker = getFocusableTreeWalker(getScopeRoot(scope), {tabbable: false}, scope);\n walker.currentNode = sentinel;\n nextNode = walker.nextNode();\n }\n\n focusElement(nextNode as FocusableElement);\n}\n\nfunction useAutoFocus(scopeRef: RefObject<Element[]>, autoFocus: boolean) {\n const autoFocusRef = React.useRef(autoFocus);\n useEffect(() => {\n if (autoFocusRef.current) {\n activeScope = scopeRef;\n if (!isElementInScope(document.activeElement, activeScope.current)) {\n focusFirstInScope(scopeRef.current);\n }\n }\n autoFocusRef.current = false;\n }, [scopeRef]);\n}\n\nfunction useActiveScopeTracker(scopeRef: RefObject<Element[]>, restore: boolean, contain: boolean) {\n // tracks the active scope, in case restore and contain are both false.\n // if either are true, this is tracked in useRestoreFocus or useFocusContainment.\n useLayoutEffect(() => {\n if (restore || contain) {\n return;\n }\n\n let scope = scopeRef.current;\n\n let onFocus = (e: FocusEvent) => {\n let target = e.target as Element;\n if (isElementInScope(target, scopeRef.current)) {\n activeScope = scopeRef;\n } else if (!isElementInAnyScope(target)) {\n activeScope = null;\n }\n };\n\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n return () => {\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n };\n }, [scopeRef, restore, contain]);\n}\n\nfunction shouldRestoreFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.nodeToRestore) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return scope?.scopeRef === scopeRef;\n}\n\nfunction useRestoreFocus(scopeRef: RefObject<Element[]>, restoreFocus: boolean, contain: boolean) {\n // create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.\n const nodeToRestoreRef = useRef(typeof document !== 'undefined' ? document.activeElement as FocusableElement : null);\n\n // restoring scopes should all track if they are active regardless of contain, but contain already tracks it plus logic to contain the focus\n // restoring-non-containing scopes should only care if they become active so they can perform the restore\n useLayoutEffect(() => {\n let scope = scopeRef.current;\n if (!restoreFocus || contain) {\n return;\n }\n\n let onFocus = () => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if ((!activeScope || isAncestorScope(activeScope, scopeRef)) &&\n isElementInScope(document.activeElement, scopeRef.current)\n ) {\n activeScope = scopeRef;\n }\n };\n\n document.addEventListener('focusin', onFocus, false);\n scope.forEach(element => element.addEventListener('focusin', onFocus, false));\n return () => {\n document.removeEventListener('focusin', onFocus, false);\n scope.forEach(element => element.removeEventListener('focusin', onFocus, false));\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [scopeRef, contain]);\n\n useLayoutEffect(() => {\n if (!restoreFocus) {\n return;\n }\n\n // Handle the Tab key so that tabbing out of the scope goes to the next element\n // after the node that had focus when the scope mounted. This is important when\n // using portals for overlays, so that focus goes to the expected element when\n // tabbing out of the overlay.\n let onKeyDown = (e: KeyboardEvent) => {\n if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || !shouldContainFocus(scopeRef)) {\n return;\n }\n\n let focusedElement = document.activeElement as FocusableElement;\n if (!isElementInScope(focusedElement, scopeRef.current)) {\n return;\n }\n let nodeToRestore = focusScopeTree.getTreeNode(scopeRef).nodeToRestore;\n\n // Create a DOM tree walker that matches all tabbable elements\n let walker = getFocusableTreeWalker(document.body, {tabbable: true});\n\n // Find the next tabbable element after the currently focused element\n walker.currentNode = focusedElement;\n let nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n\n if (!document.body.contains(nodeToRestore) || nodeToRestore === document.body) {\n nodeToRestore = null;\n focusScopeTree.getTreeNode(scopeRef).nodeToRestore = null;\n }\n\n // If there is no next element, or it is outside the current scope, move focus to the\n // next element after the node to restore to instead.\n if ((!nextElement || !isElementInScope(nextElement, scopeRef.current)) && nodeToRestore) {\n walker.currentNode = nodeToRestore;\n\n // Skip over elements within the scope, in case the scope immediately follows the node to restore.\n do {\n nextElement = (e.shiftKey ? walker.previousNode() : walker.nextNode()) as FocusableElement;\n } while (isElementInScope(nextElement, scopeRef.current));\n\n e.preventDefault();\n e.stopPropagation();\n if (nextElement) {\n focusElement(nextElement, true);\n } else {\n // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)\n // then move focus to the body.\n // Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)\n if (!isElementInAnyScope(nodeToRestore)) {\n focusedElement.blur();\n } else {\n focusElement(nodeToRestore, true);\n }\n }\n }\n };\n\n if (!contain) {\n document.addEventListener('keydown', onKeyDown, true);\n }\n\n return () => {\n if (!contain) {\n document.removeEventListener('keydown', onKeyDown, true);\n }\n };\n }, [scopeRef, restoreFocus, contain]);\n\n // useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.\n useLayoutEffect(() => {\n if (!restoreFocus) {\n return;\n }\n\n focusScopeTree.getTreeNode(scopeRef).nodeToRestore = nodeToRestoreRef.current;\n\n return () => {\n let nodeToRestore = focusScopeTree.getTreeNode(scopeRef).nodeToRestore;\n\n // if we already lost focus to the body and this was the active scope, then we should attempt to restore\n if (\n restoreFocus\n && nodeToRestore\n && (\n // eslint-disable-next-line react-hooks/exhaustive-deps\n isElementInScope(document.activeElement, scopeRef.current)\n || (document.activeElement === document.body && shouldRestoreFocus(scopeRef))\n )\n ) {\n // freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it\n let clonedTree = focusScopeTree.clone();\n requestAnimationFrame(() => {\n // Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere\n if (document.activeElement === document.body) {\n // look up the tree starting with our scope to find a nodeToRestore still in the DOM\n let treeNode = clonedTree.getTreeNode(scopeRef);\n while (treeNode) {\n if (treeNode.nodeToRestore && document.body.contains(treeNode.nodeToRestore)) {\n focusElement(treeNode.nodeToRestore);\n return;\n }\n treeNode = treeNode.parent;\n }\n\n // If no nodeToRestore was found, focus the first element in the nearest\n // ancestor scope that is still in the tree.\n treeNode = clonedTree.getTreeNode(scopeRef);\n while (treeNode) {\n if (treeNode.scopeRef && focusScopeTree.getTreeNode(treeNode.scopeRef)) {\n focusFirstInScope(treeNode.scopeRef.current, true);\n return;\n }\n treeNode = treeNode.parent;\n }\n }\n });\n }\n };\n }, [scopeRef, restoreFocus]);\n}\n\n/**\n * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}\n * that matches all focusable/tabbable elements.\n */\nexport function getFocusableTreeWalker(root: Element, opts?: FocusManagerOptions, scope?: Element[]) {\n let selector = opts?.tabbable ? TABBABLE_ELEMENT_SELECTOR : FOCUSABLE_ELEMENT_SELECTOR;\n let walker = document.createTreeWalker(\n root,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode(node) {\n // Skip nodes inside the starting node.\n if (opts?.from?.contains(node)) {\n return NodeFilter.FILTER_REJECT;\n }\n\n if ((node as Element).matches(selector)\n && isElementVisible(node as Element)\n && (!scope || isElementInScope(node as Element, scope))\n && (!opts?.accept || opts.accept(node as Element))\n ) {\n return NodeFilter.FILTER_ACCEPT;\n }\n\n return NodeFilter.FILTER_SKIP;\n }\n }\n );\n\n if (opts?.from) {\n walker.currentNode = opts.from;\n }\n\n return walker;\n}\n\n/**\n * Creates a FocusManager object that can be used to move focus within an element.\n */\nexport function createFocusManager(ref: RefObject<Element>, defaultOptions: FocusManagerOptions = {}): FocusManager {\n return {\n focusNext(opts: FocusManagerOptions = {}) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept} = opts;\n let node = from || document.activeElement;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n if (root.contains(node)) {\n walker.currentNode = node;\n }\n let nextNode = walker.nextNode() as FocusableElement;\n if (!nextNode && wrap) {\n walker.currentNode = root;\n nextNode = walker.nextNode() as FocusableElement;\n }\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {from, tabbable = defaultOptions.tabbable, wrap = defaultOptions.wrap, accept = defaultOptions.accept} = opts;\n let node = from || document.activeElement;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n if (root.contains(node)) {\n walker.currentNode = node;\n } else {\n let next = last(walker);\n if (next) {\n focusElement(next, true);\n }\n return next;\n }\n let previousNode = walker.previousNode() as FocusableElement;\n if (!previousNode && wrap) {\n walker.currentNode = root;\n previousNode = last(walker);\n }\n if (previousNode) {\n focusElement(previousNode, true);\n }\n return previousNode;\n },\n focusFirst(opts = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {tabbable = defaultOptions.tabbable, accept = defaultOptions.accept} = opts;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n let nextNode = walker.nextNode() as FocusableElement;\n if (nextNode) {\n focusElement(nextNode, true);\n }\n return nextNode;\n },\n focusLast(opts = defaultOptions) {\n let root = ref.current;\n if (!root) {\n return;\n }\n let {tabbable = defaultOptions.tabbable, accept = defaultOptions.accept} = opts;\n let walker = getFocusableTreeWalker(root, {tabbable, accept});\n let next = last(walker);\n if (next) {\n focusElement(next, true);\n }\n return next;\n }\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n\n\nclass Tree {\n root: TreeNode;\n private fastMap = new Map<ScopeRef, TreeNode>();\n\n constructor() {\n this.root = new TreeNode({scopeRef: null});\n this.fastMap.set(null, this.root);\n }\n\n get size() {\n return this.fastMap.size;\n }\n\n getTreeNode(data: ScopeRef) {\n return this.fastMap.get(data);\n }\n\n addTreeNode(scopeRef: ScopeRef, parent: ScopeRef, nodeToRestore?: FocusableElement) {\n let parentNode = this.fastMap.get(parent ?? null);\n let node = new TreeNode({scopeRef});\n parentNode.addChild(node);\n node.parent = parentNode;\n this.fastMap.set(scopeRef, node);\n if (nodeToRestore) {\n node.nodeToRestore = nodeToRestore;\n }\n }\n\n addNode(node: TreeNode) {\n this.fastMap.set(node.scopeRef, node);\n }\n\n removeTreeNode(scopeRef: ScopeRef) {\n // never remove the root\n if (scopeRef === null) {\n return;\n }\n let node = this.fastMap.get(scopeRef);\n let parentNode = node.parent;\n // when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing\n // if we are, then replace the siblings restore with the restore from the scope we're removing\n for (let current of this.traverse()) {\n if (\n current !== node &&\n node.nodeToRestore &&\n current.nodeToRestore &&\n node.scopeRef.current &&\n isElementInScope(current.nodeToRestore, node.scopeRef.current)\n ) {\n current.nodeToRestore = node.nodeToRestore;\n }\n }\n let children = node.children;\n parentNode.removeChild(node);\n if (children.size > 0) {\n children.forEach(child => parentNode.addChild(child));\n }\n\n this.fastMap.delete(node.scopeRef);\n }\n\n // Pre Order Depth First\n *traverse(node: TreeNode = this.root): Generator<TreeNode> {\n if (node.scopeRef != null) {\n yield node;\n }\n if (node.children.size > 0) {\n for (let child of node.children) {\n yield* this.traverse(child);\n }\n }\n }\n\n clone(): Tree {\n let newTree = new Tree();\n for (let node of this.traverse()) {\n newTree.addTreeNode(node.scopeRef, node.parent.scopeRef, node.nodeToRestore);\n }\n return newTree;\n }\n}\n\nclass TreeNode {\n public scopeRef: ScopeRef;\n public nodeToRestore: FocusableElement;\n public parent: TreeNode;\n public children: Set<TreeNode> = new Set();\n public contain = false;\n\n constructor(props: {scopeRef: ScopeRef}) {\n this.scopeRef = props.scopeRef;\n }\n addChild(node: TreeNode) {\n this.children.add(node);\n node.parent = this;\n }\n removeChild(node: TreeNode) {\n this.children.delete(node);\n node.parent = undefined;\n }\n}\n\nexport let focusScopeTree = new Tree();\n","/*\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 {FocusableElement} from '@react-types/shared';\nimport {focusWithoutScrolling, runAfterTransition} from '@react-aria/utils';\nimport {getInteractionModality} from '@react-aria/interactions';\n\n/**\n * A utility function that focuses an element while avoiding undesired side effects such\n * as page scrolling and screen reader issues with CSS transitions.\n */\nexport function focusSafely(element: FocusableElement) {\n // If the user is interacting with a virtual cursor, e.g. screen reader, then\n // wait until after any animated transitions that are currently occurring on\n // the page before shifting focus. This avoids issues with VoiceOver on iOS\n // causing the page to scroll when moving focus if the element is transitioning\n // from off the screen.\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = document.activeElement;\n runAfterTransition(() => {\n // If focus did not move and the element is still in the document, focus it.\n if (document.activeElement === lastFocusedElement && document.contains(element)) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n","/*\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\nfunction isStyleVisible(element: Element) {\n if (!(element instanceof HTMLElement) && !(element instanceof 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;\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 (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) {\n return (\n element.nodeName !== '#comment' &&\n isStyleVisible(element) &&\n isAttributeVisible(element, childElement) &&\n (!element.parentElement || isElementVisible(element.parentElement, element))\n );\n}\n","/*\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) {\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, {\n ...focusProps,\n className: clsx({\n [focusClass || '']: isFocused,\n [focusRingClass || '']: isFocusVisible\n })\n }));\n}\n","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","/*\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 {DOMAttributes, FocusableDOMProps, FocusableElement, FocusableProps} from '@react-types/shared';\nimport {focusSafely} from './';\nimport {mergeProps, useSyncRef} from '@react-aria/utils';\nimport React, {MutableRefObject, ReactNode, RefObject, useContext, useEffect, useRef} from 'react';\nimport {useFocus, useKeyboard} from '@react-aria/interactions';\n\nexport interface FocusableOptions extends FocusableProps, FocusableDOMProps {\n /** Whether focus should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface FocusableProviderProps extends DOMAttributes {\n /** The child element to provide DOM props to. */\n children?: ReactNode\n}\n\ninterface FocusableContextValue extends FocusableProviderProps {\n ref?: MutableRefObject<FocusableElement>\n}\n\nlet FocusableContext = React.createContext<FocusableContextValue>(null);\n\nfunction useFocusableContext(ref: RefObject<FocusableElement>): FocusableContextValue {\n let context = useContext(FocusableContext) || {};\n useSyncRef(context, ref);\n\n // eslint-disable-next-line\n let {ref: _, ...otherProps} = context;\n return otherProps;\n}\n\n/**\n * Provides DOM props to the nearest focusable child.\n */\nfunction FocusableProvider(props: FocusableProviderProps, ref: RefObject<FocusableElement>) {\n let {children, ...otherProps} = props;\n let context = {\n ...otherProps,\n ref\n };\n\n return (\n <FocusableContext.Provider value={context}>\n {children}\n </FocusableContext.Provider>\n );\n}\n\nlet _FocusableProvider = React.forwardRef(FocusableProvider);\nexport {_FocusableProvider as FocusableProvider};\n\nexport interface FocusableAria {\n /** Props for the focusable element. */\n focusableProps: DOMAttributes\n}\n\n/**\n * Used to make an element focusable and capable of auto focus.\n */\nexport function useFocusable(props: FocusableOptions, domRef: RefObject<FocusableElement>): FocusableAria {\n let {focusProps} = useFocus(props);\n let {keyboardProps} = useKeyboard(props);\n let interactions = mergeProps(focusProps, keyboardProps);\n let domProps = useFocusableContext(domRef);\n let interactionProps = props.isDisabled ? {} : domProps;\n let autoFocusRef = useRef(props.autoFocus);\n\n useEffect(() => {\n if (autoFocusRef.current && domRef.current) {\n focusSafely(domRef.current);\n }\n autoFocusRef.current = false;\n }, [domRef]);\n\n return {\n focusableProps: mergeProps(\n {\n ...interactions,\n tabIndex: props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined\n },\n interactionProps\n )\n };\n}\n","/*\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, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\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>, 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":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/focus",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.2",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/interactions": "^3.
|
|
26
|
-
"@react-aria/utils": "^3.
|
|
27
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-aria/interactions": "^3.19.0",
|
|
26
|
+
"@react-aria/utils": "^3.21.0",
|
|
27
|
+
"@react-types/shared": "^3.21.0",
|
|
28
28
|
"@swc/helpers": "^0.5.0",
|
|
29
29
|
"clsx": "^1.1.1"
|
|
30
30
|
},
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "4122e44d1991c90507d630d35ed297f89db435d3"
|
|
38
38
|
}
|