@react-aria/focus 3.9.0 → 3.10.1
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/main.js +188 -152
- package/dist/main.js.map +1 -1
- package/dist/module.js +188 -153
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/FocusScope.tsx +8 -1
- package/src/index.ts +1 -1
package/dist/main.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var $aB6Cp$swchelperslib_define_propertyjs = require("@swc/helpers/lib/_define_property.js");
|
|
1
2
|
var $aB6Cp$react = require("react");
|
|
2
3
|
var $aB6Cp$reactariautils = require("@react-aria/utils");
|
|
3
4
|
var $aB6Cp$reactariainteractions = require("@react-aria/interactions");
|
|
@@ -14,12 +15,44 @@ $parcel$export(module.exports, "FocusScope", () => $a7a032acae3ddda9$export$20e4
|
|
|
14
15
|
$parcel$export(module.exports, "useFocusManager", () => $a7a032acae3ddda9$export$10c5169755ce7bd7);
|
|
15
16
|
$parcel$export(module.exports, "getFocusableTreeWalker", () => $a7a032acae3ddda9$export$2d6ec8fc375ceafa);
|
|
16
17
|
$parcel$export(module.exports, "createFocusManager", () => $a7a032acae3ddda9$export$c5251b9e124bf29);
|
|
18
|
+
$parcel$export(module.exports, "isElementInChildOfActiveScope", () => $a7a032acae3ddda9$export$1258395f99bf9cbf);
|
|
17
19
|
$parcel$export(module.exports, "FocusRing", () => $dfd8c70b928eb1b3$export$1a38b4ad7f578e1d);
|
|
18
20
|
$parcel$export(module.exports, "FocusableProvider", () => $fb504d83237fd6ac$export$13f3202a3e5ddd5);
|
|
19
21
|
$parcel$export(module.exports, "useFocusable", () => $fb504d83237fd6ac$export$4c014de7c8940b4c);
|
|
20
22
|
$parcel$export(module.exports, "useFocusRing", () => $581a96d6eb128c1b$export$4e328f61c538687f);
|
|
21
23
|
$parcel$export(module.exports, "focusSafely", () => $1c7f9157d722357d$export$80f3e147d781571c);
|
|
22
|
-
|
|
24
|
+
/*
|
|
25
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
26
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
27
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
28
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
29
|
+
*
|
|
30
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
31
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
32
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
33
|
+
* governing permissions and limitations under the License.
|
|
34
|
+
*/ /*
|
|
35
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
36
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
37
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
38
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
39
|
+
*
|
|
40
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
41
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
42
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
43
|
+
* governing permissions and limitations under the License.
|
|
44
|
+
*/
|
|
45
|
+
/*
|
|
46
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
47
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the 'License');
|
|
48
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
49
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
50
|
+
*
|
|
51
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
52
|
+
* the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
53
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
54
|
+
* governing permissions and limitations under the License.
|
|
55
|
+
*/
|
|
23
56
|
|
|
24
57
|
function $1c7f9157d722357d$export$80f3e147d781571c(element) {
|
|
25
58
|
// If the user is interacting with a virtual cursor, e.g. screen reader, then
|
|
@@ -27,13 +60,13 @@ function $1c7f9157d722357d$export$80f3e147d781571c(element) {
|
|
|
27
60
|
// the page before shifting focus. This avoids issues with VoiceOver on iOS
|
|
28
61
|
// causing the page to scroll when moving focus if the element is transitioning
|
|
29
62
|
// from off the screen.
|
|
30
|
-
if ($aB6Cp$reactariainteractions.getInteractionModality() ===
|
|
63
|
+
if ((0, $aB6Cp$reactariainteractions.getInteractionModality)() === "virtual") {
|
|
31
64
|
let lastFocusedElement = document.activeElement;
|
|
32
|
-
$aB6Cp$reactariautils.runAfterTransition(()=>{
|
|
65
|
+
(0, $aB6Cp$reactariautils.runAfterTransition)(()=>{
|
|
33
66
|
// If focus did not move and the element is still in the document, focus it.
|
|
34
|
-
if (document.activeElement === lastFocusedElement && document.contains(element)) $aB6Cp$reactariautils.focusWithoutScrolling(element);
|
|
67
|
+
if (document.activeElement === lastFocusedElement && document.contains(element)) (0, $aB6Cp$reactariautils.focusWithoutScrolling)(element);
|
|
35
68
|
});
|
|
36
|
-
} else $aB6Cp$reactariautils.focusWithoutScrolling(element);
|
|
69
|
+
} else (0, $aB6Cp$reactariautils.focusWithoutScrolling)(element);
|
|
37
70
|
}
|
|
38
71
|
|
|
39
72
|
|
|
@@ -50,42 +83,41 @@ function $1c7f9157d722357d$export$80f3e147d781571c(element) {
|
|
|
50
83
|
*/ function $d5156037ad898a4d$var$isStyleVisible(element) {
|
|
51
84
|
if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) return false;
|
|
52
85
|
let { display: display , visibility: visibility } = element.style;
|
|
53
|
-
let isVisible = display !==
|
|
86
|
+
let isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
|
|
54
87
|
if (isVisible) {
|
|
55
88
|
const { getComputedStyle: getComputedStyle } = element.ownerDocument.defaultView;
|
|
56
89
|
let { display: computedDisplay , visibility: computedVisibility } = getComputedStyle(element);
|
|
57
|
-
isVisible = computedDisplay !==
|
|
90
|
+
isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
|
|
58
91
|
}
|
|
59
92
|
return isVisible;
|
|
60
93
|
}
|
|
61
94
|
function $d5156037ad898a4d$var$isAttributeVisible(element, childElement) {
|
|
62
|
-
return !element.hasAttribute(
|
|
95
|
+
return !element.hasAttribute("hidden") && (element.nodeName === "DETAILS" && childElement && childElement.nodeName !== "SUMMARY" ? element.hasAttribute("open") : true);
|
|
63
96
|
}
|
|
64
97
|
function $d5156037ad898a4d$export$e989c0fffaa6b27a(element, childElement) {
|
|
65
|
-
return element.nodeName !==
|
|
98
|
+
return element.nodeName !== "#comment" && $d5156037ad898a4d$var$isStyleVisible(element) && $d5156037ad898a4d$var$isAttributeVisible(element, childElement) && (!element.parentElement || $d5156037ad898a4d$export$e989c0fffaa6b27a(element.parentElement, element));
|
|
66
99
|
}
|
|
67
100
|
|
|
68
101
|
|
|
69
102
|
|
|
70
103
|
|
|
71
|
-
const $a7a032acae3ddda9$var$FocusContext = /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createContext(null);
|
|
104
|
+
const $a7a032acae3ddda9$var$FocusContext = /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).createContext(null);
|
|
72
105
|
let $a7a032acae3ddda9$var$activeScope = null;
|
|
73
106
|
function $a7a032acae3ddda9$export$20e40289641fbbb6(props) {
|
|
74
107
|
let { children: children , contain: contain , restoreFocus: restoreFocus , autoFocus: autoFocus } = props;
|
|
75
|
-
let startRef = $aB6Cp$react.useRef();
|
|
76
|
-
let endRef = $aB6Cp$react.useRef();
|
|
77
|
-
let scopeRef = $aB6Cp$react.useRef([]);
|
|
78
|
-
let ctx = $aB6Cp$react.useContext($a7a032acae3ddda9$var$FocusContext);
|
|
79
|
-
var
|
|
108
|
+
let startRef = (0, $aB6Cp$react.useRef)();
|
|
109
|
+
let endRef = (0, $aB6Cp$react.useRef)();
|
|
110
|
+
let scopeRef = (0, $aB6Cp$react.useRef)([]);
|
|
111
|
+
let ctx = (0, $aB6Cp$react.useContext)($a7a032acae3ddda9$var$FocusContext);
|
|
112
|
+
var _ctx_scopeRef;
|
|
80
113
|
// The parent scope is based on the JSX tree, using context.
|
|
81
114
|
// However, if a new scope mounts outside the active scope (e.g. DialogContainer launched from a menu),
|
|
82
115
|
// we want the parent scope to be the active scope instead.
|
|
83
|
-
let ctxParent = (
|
|
84
|
-
let
|
|
85
|
-
, [
|
|
116
|
+
let ctxParent = (_ctx_scopeRef = ctx === null || ctx === void 0 ? void 0 : ctx.scopeRef) !== null && _ctx_scopeRef !== void 0 ? _ctx_scopeRef : null;
|
|
117
|
+
let parentScope = (0, $aB6Cp$react.useMemo)(()=>$a7a032acae3ddda9$var$activeScope && $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode($a7a032acae3ddda9$var$activeScope) && !$a7a032acae3ddda9$var$isAncestorScope($a7a032acae3ddda9$var$activeScope, ctxParent) ? $a7a032acae3ddda9$var$activeScope : ctxParent, [
|
|
86
118
|
ctxParent
|
|
87
119
|
]);
|
|
88
|
-
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
120
|
+
(0, $aB6Cp$reactariautils.useLayoutEffect)(()=>{
|
|
89
121
|
// Find all rendered nodes between the sentinels and add them to the scope.
|
|
90
122
|
let node = startRef.current.nextSibling;
|
|
91
123
|
let nodes = [];
|
|
@@ -96,19 +128,19 @@ function $a7a032acae3ddda9$export$20e40289641fbbb6(props) {
|
|
|
96
128
|
scopeRef.current = nodes;
|
|
97
129
|
}, [
|
|
98
130
|
children,
|
|
99
|
-
|
|
131
|
+
parentScope
|
|
100
132
|
]);
|
|
101
133
|
// add to the focus scope tree in render order because useEffects/useLayoutEffects run children first whereas render runs parent first
|
|
102
134
|
// which matters when constructing a tree
|
|
103
|
-
if ($a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(
|
|
104
|
-
let
|
|
105
|
-
|
|
135
|
+
if ($a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(parentScope) && !$a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef)) $a7a032acae3ddda9$export$d06fae2ee68b101e.addTreeNode(scopeRef, parentScope);
|
|
136
|
+
let node = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef);
|
|
137
|
+
node.contain = contain;
|
|
106
138
|
$a7a032acae3ddda9$var$useActiveScopeTracker(scopeRef, restoreFocus, contain);
|
|
107
139
|
$a7a032acae3ddda9$var$useFocusContainment(scopeRef, contain);
|
|
108
140
|
$a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain);
|
|
109
141
|
$a7a032acae3ddda9$var$useAutoFocus(scopeRef, autoFocus);
|
|
110
142
|
// this layout effect needs to run last so that focusScopeTree cleanup happens at the last moment possible
|
|
111
|
-
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
143
|
+
(0, $aB6Cp$reactariautils.useLayoutEffect)(()=>{
|
|
112
144
|
if (scopeRef) return ()=>{
|
|
113
145
|
// Scope may have been re-parented.
|
|
114
146
|
let parentScope = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef).parent.scopeRef;
|
|
@@ -120,32 +152,31 @@ function $a7a032acae3ddda9$export$20e40289641fbbb6(props) {
|
|
|
120
152
|
};
|
|
121
153
|
}, [
|
|
122
154
|
scopeRef,
|
|
123
|
-
|
|
155
|
+
parentScope
|
|
124
156
|
]);
|
|
125
157
|
let focusManager = $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef);
|
|
126
|
-
return
|
|
158
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).createElement($a7a032acae3ddda9$var$FocusContext.Provider, {
|
|
127
159
|
value: {
|
|
128
160
|
scopeRef: scopeRef,
|
|
129
161
|
focusManager: focusManager
|
|
130
162
|
}
|
|
131
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createElement("span", {
|
|
163
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).createElement("span", {
|
|
132
164
|
"data-focus-scope-start": true,
|
|
133
165
|
hidden: true,
|
|
134
166
|
ref: startRef
|
|
135
|
-
}), children, /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createElement("span", {
|
|
167
|
+
}), children, /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).createElement("span", {
|
|
136
168
|
"data-focus-scope-end": true,
|
|
137
169
|
hidden: true,
|
|
138
170
|
ref: endRef
|
|
139
|
-
}))
|
|
171
|
+
}));
|
|
140
172
|
}
|
|
141
173
|
function $a7a032acae3ddda9$export$10c5169755ce7bd7() {
|
|
142
|
-
var
|
|
143
|
-
return (
|
|
174
|
+
var _useContext;
|
|
175
|
+
return (_useContext = (0, $aB6Cp$react.useContext)($a7a032acae3ddda9$var$FocusContext)) === null || _useContext === void 0 ? void 0 : _useContext.focusManager;
|
|
144
176
|
}
|
|
145
177
|
function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
146
178
|
return {
|
|
147
|
-
focusNext (opts = {
|
|
148
|
-
}) {
|
|
179
|
+
focusNext (opts = {}) {
|
|
149
180
|
let scope = scopeRef.current;
|
|
150
181
|
let { from: from , tabbable: tabbable , wrap: wrap , accept: accept } = opts;
|
|
151
182
|
let node = from || document.activeElement;
|
|
@@ -163,8 +194,7 @@ function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
|
163
194
|
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
|
|
164
195
|
return nextNode;
|
|
165
196
|
},
|
|
166
|
-
focusPrevious (opts = {
|
|
167
|
-
}) {
|
|
197
|
+
focusPrevious (opts = {}) {
|
|
168
198
|
let scope = scopeRef.current;
|
|
169
199
|
let { from: from , tabbable: tabbable , wrap: wrap , accept: accept } = opts;
|
|
170
200
|
let node = from || document.activeElement;
|
|
@@ -182,8 +212,7 @@ function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
|
182
212
|
if (previousNode) $a7a032acae3ddda9$var$focusElement(previousNode, true);
|
|
183
213
|
return previousNode;
|
|
184
214
|
},
|
|
185
|
-
focusFirst (opts = {
|
|
186
|
-
}) {
|
|
215
|
+
focusFirst (opts = {}) {
|
|
187
216
|
let scope = scopeRef.current;
|
|
188
217
|
let { tabbable: tabbable , accept: accept } = opts;
|
|
189
218
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
@@ -195,8 +224,7 @@ function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
|
195
224
|
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
|
|
196
225
|
return nextNode;
|
|
197
226
|
},
|
|
198
|
-
focusLast (opts = {
|
|
199
|
-
}) {
|
|
227
|
+
focusLast (opts = {}) {
|
|
200
228
|
let scope = scopeRef.current;
|
|
201
229
|
let { tabbable: tabbable , accept: accept } = opts;
|
|
202
230
|
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
@@ -211,21 +239,21 @@ function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
|
211
239
|
};
|
|
212
240
|
}
|
|
213
241
|
const $a7a032acae3ddda9$var$focusableElements = [
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
242
|
+
"input:not([disabled]):not([type=hidden])",
|
|
243
|
+
"select:not([disabled])",
|
|
244
|
+
"textarea:not([disabled])",
|
|
245
|
+
"button:not([disabled])",
|
|
246
|
+
"a[href]",
|
|
247
|
+
"area[href]",
|
|
248
|
+
"summary",
|
|
249
|
+
"iframe",
|
|
250
|
+
"object",
|
|
251
|
+
"embed",
|
|
252
|
+
"audio[controls]",
|
|
253
|
+
"video[controls]",
|
|
254
|
+
"[contenteditable]"
|
|
227
255
|
];
|
|
228
|
-
const $a7a032acae3ddda9$var$FOCUSABLE_ELEMENT_SELECTOR = $a7a032acae3ddda9$var$focusableElements.join(
|
|
256
|
+
const $a7a032acae3ddda9$var$FOCUSABLE_ELEMENT_SELECTOR = $a7a032acae3ddda9$var$focusableElements.join(":not([hidden]),") + ",[tabindex]:not([disabled]):not([hidden])";
|
|
229
257
|
$a7a032acae3ddda9$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
|
|
230
258
|
const $a7a032acae3ddda9$var$TABBABLE_ELEMENT_SELECTOR = $a7a032acae3ddda9$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
|
|
231
259
|
function $a7a032acae3ddda9$var$getScopeRoot(scope) {
|
|
@@ -240,10 +268,10 @@ function $a7a032acae3ddda9$var$shouldContainFocus(scopeRef) {
|
|
|
240
268
|
return true;
|
|
241
269
|
}
|
|
242
270
|
function $a7a032acae3ddda9$var$useFocusContainment(scopeRef, contain) {
|
|
243
|
-
let focusedNode = $aB6Cp$react.useRef();
|
|
244
|
-
let raf = $aB6Cp$react.useRef(null);
|
|
245
|
-
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
246
|
-
let
|
|
271
|
+
let focusedNode = (0, $aB6Cp$react.useRef)();
|
|
272
|
+
let raf = (0, $aB6Cp$react.useRef)(null);
|
|
273
|
+
(0, $aB6Cp$reactariautils.useLayoutEffect)(()=>{
|
|
274
|
+
let scope = scopeRef.current;
|
|
247
275
|
if (!contain) {
|
|
248
276
|
// if contain was changed, then we should cancel any ongoing waits to pull focus back into containment
|
|
249
277
|
if (raf.current) {
|
|
@@ -254,7 +282,7 @@ function $a7a032acae3ddda9$var$useFocusContainment(scopeRef, contain) {
|
|
|
254
282
|
}
|
|
255
283
|
// Handle the Tab key to contain focus within the scope
|
|
256
284
|
let onKeyDown = (e)=>{
|
|
257
|
-
if (e.key !==
|
|
285
|
+
if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey || !$a7a032acae3ddda9$var$shouldContainFocus(scopeRef)) return;
|
|
258
286
|
let focusedElement = document.activeElement;
|
|
259
287
|
let scope = scopeRef.current;
|
|
260
288
|
if (!$a7a032acae3ddda9$var$isElementInScope(focusedElement, scope)) return;
|
|
@@ -296,26 +324,22 @@ function $a7a032acae3ddda9$var$useFocusContainment(scopeRef, contain) {
|
|
|
296
324
|
}
|
|
297
325
|
});
|
|
298
326
|
};
|
|
299
|
-
document.addEventListener(
|
|
300
|
-
document.addEventListener(
|
|
301
|
-
|
|
302
|
-
);
|
|
303
|
-
scope1.forEach((element)=>element.addEventListener('focusout', onBlur, false)
|
|
304
|
-
);
|
|
327
|
+
document.addEventListener("keydown", onKeyDown, false);
|
|
328
|
+
document.addEventListener("focusin", onFocus, false);
|
|
329
|
+
scope.forEach((element)=>element.addEventListener("focusin", onFocus, false));
|
|
330
|
+
scope.forEach((element)=>element.addEventListener("focusout", onBlur, false));
|
|
305
331
|
return ()=>{
|
|
306
|
-
document.removeEventListener(
|
|
307
|
-
document.removeEventListener(
|
|
308
|
-
|
|
309
|
-
);
|
|
310
|
-
scope1.forEach((element)=>element.removeEventListener('focusout', onBlur, false)
|
|
311
|
-
);
|
|
332
|
+
document.removeEventListener("keydown", onKeyDown, false);
|
|
333
|
+
document.removeEventListener("focusin", onFocus, false);
|
|
334
|
+
scope.forEach((element)=>element.removeEventListener("focusin", onFocus, false));
|
|
335
|
+
scope.forEach((element)=>element.removeEventListener("focusout", onBlur, false));
|
|
312
336
|
};
|
|
313
337
|
}, [
|
|
314
338
|
scopeRef,
|
|
315
339
|
contain
|
|
316
340
|
]);
|
|
317
341
|
// eslint-disable-next-line arrow-body-style
|
|
318
|
-
$aB6Cp$react.useEffect(()=>{
|
|
342
|
+
(0, $aB6Cp$react.useEffect)(()=>{
|
|
319
343
|
return ()=>{
|
|
320
344
|
if (raf.current) cancelAnimationFrame(raf.current);
|
|
321
345
|
};
|
|
@@ -327,8 +351,7 @@ function $a7a032acae3ddda9$var$isElementInAnyScope(element) {
|
|
|
327
351
|
return $a7a032acae3ddda9$var$isElementInChildScope(element);
|
|
328
352
|
}
|
|
329
353
|
function $a7a032acae3ddda9$var$isElementInScope(element, scope) {
|
|
330
|
-
return scope.some((node)=>node.contains(element)
|
|
331
|
-
);
|
|
354
|
+
return scope.some((node)=>node.contains(element));
|
|
332
355
|
}
|
|
333
356
|
function $a7a032acae3ddda9$var$isElementInChildScope(element, scope = null) {
|
|
334
357
|
// node.contains in isElementInScope covers child scopes that are also DOM children,
|
|
@@ -338,9 +361,12 @@ function $a7a032acae3ddda9$var$isElementInChildScope(element, scope = null) {
|
|
|
338
361
|
}
|
|
339
362
|
return false;
|
|
340
363
|
}
|
|
364
|
+
function $a7a032acae3ddda9$export$1258395f99bf9cbf(element) {
|
|
365
|
+
return $a7a032acae3ddda9$var$isElementInChildScope(element, $a7a032acae3ddda9$var$activeScope);
|
|
366
|
+
}
|
|
341
367
|
function $a7a032acae3ddda9$var$isAncestorScope(ancestor, scope) {
|
|
342
|
-
var
|
|
343
|
-
let parent = (
|
|
368
|
+
var _focusScopeTree_getTreeNode;
|
|
369
|
+
let parent = (_focusScopeTree_getTreeNode = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scope)) === null || _focusScopeTree_getTreeNode === void 0 ? void 0 : _focusScopeTree_getTreeNode.parent;
|
|
344
370
|
while(parent){
|
|
345
371
|
if (parent.scopeRef === ancestor) return true;
|
|
346
372
|
parent = parent.parent;
|
|
@@ -349,7 +375,7 @@ function $a7a032acae3ddda9$var$isAncestorScope(ancestor, scope) {
|
|
|
349
375
|
}
|
|
350
376
|
function $a7a032acae3ddda9$var$focusElement(element, scroll = false) {
|
|
351
377
|
if (element != null && !scroll) try {
|
|
352
|
-
$1c7f9157d722357d$export$80f3e147d781571c(element);
|
|
378
|
+
(0, $1c7f9157d722357d$export$80f3e147d781571c)(element);
|
|
353
379
|
} catch (err) {
|
|
354
380
|
// ignore
|
|
355
381
|
}
|
|
@@ -377,8 +403,8 @@ function $a7a032acae3ddda9$var$focusFirstInScope(scope, tabbable = true) {
|
|
|
377
403
|
$a7a032acae3ddda9$var$focusElement(nextNode);
|
|
378
404
|
}
|
|
379
405
|
function $a7a032acae3ddda9$var$useAutoFocus(scopeRef, autoFocus) {
|
|
380
|
-
const autoFocusRef = ($parcel$interopDefault($aB6Cp$react)).useRef(autoFocus);
|
|
381
|
-
$aB6Cp$react.useEffect(()=>{
|
|
406
|
+
const autoFocusRef = (0, ($parcel$interopDefault($aB6Cp$react))).useRef(autoFocus);
|
|
407
|
+
(0, $aB6Cp$react.useEffect)(()=>{
|
|
382
408
|
if (autoFocusRef.current) {
|
|
383
409
|
$a7a032acae3ddda9$var$activeScope = scopeRef;
|
|
384
410
|
if (!$a7a032acae3ddda9$var$isElementInScope(document.activeElement, $a7a032acae3ddda9$var$activeScope.current)) $a7a032acae3ddda9$var$focusFirstInScope(scopeRef.current);
|
|
@@ -391,7 +417,7 @@ function $a7a032acae3ddda9$var$useAutoFocus(scopeRef, autoFocus) {
|
|
|
391
417
|
function $a7a032acae3ddda9$var$useActiveScopeTracker(scopeRef, restore, contain) {
|
|
392
418
|
// tracks the active scope, in case restore and contain are both false.
|
|
393
419
|
// if either are true, this is tracked in useRestoreFocus or useFocusContainment.
|
|
394
|
-
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
420
|
+
(0, $aB6Cp$reactariautils.useLayoutEffect)(()=>{
|
|
395
421
|
if (restore || contain) return;
|
|
396
422
|
let scope = scopeRef.current;
|
|
397
423
|
let onFocus = (e)=>{
|
|
@@ -399,13 +425,11 @@ function $a7a032acae3ddda9$var$useActiveScopeTracker(scopeRef, restore, contain)
|
|
|
399
425
|
if ($a7a032acae3ddda9$var$isElementInScope(target, scopeRef.current)) $a7a032acae3ddda9$var$activeScope = scopeRef;
|
|
400
426
|
else if (!$a7a032acae3ddda9$var$isElementInAnyScope(target)) $a7a032acae3ddda9$var$activeScope = null;
|
|
401
427
|
};
|
|
402
|
-
document.addEventListener(
|
|
403
|
-
scope.forEach((element)=>element.addEventListener(
|
|
404
|
-
);
|
|
428
|
+
document.addEventListener("focusin", onFocus, false);
|
|
429
|
+
scope.forEach((element)=>element.addEventListener("focusin", onFocus, false));
|
|
405
430
|
return ()=>{
|
|
406
|
-
document.removeEventListener(
|
|
407
|
-
scope.forEach((element)=>element.removeEventListener(
|
|
408
|
-
);
|
|
431
|
+
document.removeEventListener("focusin", onFocus, false);
|
|
432
|
+
scope.forEach((element)=>element.removeEventListener("focusin", onFocus, false));
|
|
409
433
|
};
|
|
410
434
|
}, [
|
|
411
435
|
scopeRef,
|
|
@@ -419,14 +443,14 @@ function $a7a032acae3ddda9$var$shouldRestoreFocus(scopeRef) {
|
|
|
419
443
|
if (scope.nodeToRestore) return false;
|
|
420
444
|
scope = scope.parent;
|
|
421
445
|
}
|
|
422
|
-
return
|
|
446
|
+
return (scope === null || scope === void 0 ? void 0 : scope.scopeRef) === scopeRef;
|
|
423
447
|
}
|
|
424
448
|
function $a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
|
|
425
449
|
// create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.
|
|
426
|
-
const nodeToRestoreRef = $aB6Cp$react.useRef(typeof document !==
|
|
450
|
+
const nodeToRestoreRef = (0, $aB6Cp$react.useRef)(typeof document !== "undefined" ? document.activeElement : null);
|
|
427
451
|
// restoring scopes should all track if they are active regardless of contain, but contain already tracks it plus logic to contain the focus
|
|
428
452
|
// restoring-non-containing scopes should only care if they become active so they can perform the restore
|
|
429
|
-
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
453
|
+
(0, $aB6Cp$reactariautils.useLayoutEffect)(()=>{
|
|
430
454
|
let scope = scopeRef.current;
|
|
431
455
|
if (!restoreFocus || contain) return;
|
|
432
456
|
let onFocus = ()=>{
|
|
@@ -434,20 +458,19 @@ function $a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain)
|
|
|
434
458
|
// Moving out of the active scope to an ancestor is not allowed.
|
|
435
459
|
if (!$a7a032acae3ddda9$var$activeScope || $a7a032acae3ddda9$var$isAncestorScope($a7a032acae3ddda9$var$activeScope, scopeRef)) $a7a032acae3ddda9$var$activeScope = scopeRef;
|
|
436
460
|
};
|
|
437
|
-
document.addEventListener(
|
|
438
|
-
scope.forEach((element)=>element.addEventListener(
|
|
439
|
-
);
|
|
461
|
+
document.addEventListener("focusin", onFocus, false);
|
|
462
|
+
scope.forEach((element)=>element.addEventListener("focusin", onFocus, false));
|
|
440
463
|
return ()=>{
|
|
441
|
-
document.removeEventListener(
|
|
442
|
-
scope.forEach((element)=>element.removeEventListener(
|
|
443
|
-
);
|
|
464
|
+
document.removeEventListener("focusin", onFocus, false);
|
|
465
|
+
scope.forEach((element)=>element.removeEventListener("focusin", onFocus, false));
|
|
444
466
|
};
|
|
467
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
445
468
|
}, [
|
|
446
469
|
scopeRef,
|
|
447
470
|
contain
|
|
448
471
|
]);
|
|
449
472
|
// useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.
|
|
450
|
-
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
473
|
+
(0, $aB6Cp$reactariautils.useLayoutEffect)(()=>{
|
|
451
474
|
if (!restoreFocus) return;
|
|
452
475
|
$a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef).nodeToRestore = nodeToRestoreRef.current;
|
|
453
476
|
// Handle the Tab key so that tabbing out of the scope goes to the next element
|
|
@@ -455,7 +478,7 @@ function $a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain)
|
|
|
455
478
|
// using portals for overlays, so that focus goes to the expected element when
|
|
456
479
|
// tabbing out of the overlay.
|
|
457
480
|
let onKeyDown = (e)=>{
|
|
458
|
-
if (e.key !==
|
|
481
|
+
if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
459
482
|
let focusedElement = document.activeElement;
|
|
460
483
|
if (!$a7a032acae3ddda9$var$isElementInScope(focusedElement, scopeRef.current)) return;
|
|
461
484
|
let nodeToRestore = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef).nodeToRestore;
|
|
@@ -476,7 +499,7 @@ function $a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain)
|
|
|
476
499
|
walker.currentNode = nodeToRestore;
|
|
477
500
|
// Skip over elements within the scope, in case the scope immediately follows the node to restore.
|
|
478
501
|
do nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
|
|
479
|
-
while ($a7a032acae3ddda9$var$isElementInScope(nextElement, scopeRef.current))
|
|
502
|
+
while ($a7a032acae3ddda9$var$isElementInScope(nextElement, scopeRef.current));
|
|
480
503
|
e.preventDefault();
|
|
481
504
|
e.stopPropagation();
|
|
482
505
|
if (nextElement) $a7a032acae3ddda9$var$focusElement(nextElement, true);
|
|
@@ -487,12 +510,13 @@ function $a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain)
|
|
|
487
510
|
else $a7a032acae3ddda9$var$focusElement(nodeToRestore, true);
|
|
488
511
|
}
|
|
489
512
|
};
|
|
490
|
-
if (!contain) document.addEventListener(
|
|
513
|
+
if (!contain) document.addEventListener("keydown", onKeyDown, true);
|
|
491
514
|
return ()=>{
|
|
492
|
-
if (!contain) document.removeEventListener(
|
|
515
|
+
if (!contain) document.removeEventListener("keydown", onKeyDown, true);
|
|
493
516
|
let nodeToRestore = $a7a032acae3ddda9$export$d06fae2ee68b101e.getTreeNode(scopeRef).nodeToRestore;
|
|
494
517
|
// if we already lost focus to the body and this was the active scope, then we should attempt to restore
|
|
495
|
-
if (restoreFocus && nodeToRestore &&
|
|
518
|
+
if (restoreFocus && nodeToRestore && // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
519
|
+
($a7a032acae3ddda9$var$isElementInScope(document.activeElement, scopeRef.current) || document.activeElement === document.body && $a7a032acae3ddda9$var$shouldRestoreFocus(scopeRef))) {
|
|
496
520
|
// freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it
|
|
497
521
|
let clonedTree = $a7a032acae3ddda9$export$d06fae2ee68b101e.clone();
|
|
498
522
|
requestAnimationFrame(()=>{
|
|
@@ -531,21 +555,19 @@ function $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, opts, scope) {
|
|
|
531
555
|
let selector = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? $a7a032acae3ddda9$var$TABBABLE_ELEMENT_SELECTOR : $a7a032acae3ddda9$var$FOCUSABLE_ELEMENT_SELECTOR;
|
|
532
556
|
let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
|
|
533
557
|
acceptNode (node) {
|
|
534
|
-
var
|
|
558
|
+
var _opts_from;
|
|
535
559
|
// Skip nodes inside the starting node.
|
|
536
|
-
if (opts === null || opts === void 0 ? void 0 : (
|
|
537
|
-
if (node.matches(selector) && $d5156037ad898a4d$export$e989c0fffaa6b27a(node) && (!scope || $a7a032acae3ddda9$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node))) return NodeFilter.FILTER_ACCEPT;
|
|
560
|
+
if (opts === null || opts === void 0 ? void 0 : (_opts_from = opts.from) === null || _opts_from === void 0 ? void 0 : _opts_from.contains(node)) return NodeFilter.FILTER_REJECT;
|
|
561
|
+
if (node.matches(selector) && (0, $d5156037ad898a4d$export$e989c0fffaa6b27a)(node) && (!scope || $a7a032acae3ddda9$var$isElementInScope(node, scope)) && (!(opts === null || opts === void 0 ? void 0 : opts.accept) || opts.accept(node))) return NodeFilter.FILTER_ACCEPT;
|
|
538
562
|
return NodeFilter.FILTER_SKIP;
|
|
539
563
|
}
|
|
540
564
|
});
|
|
541
565
|
if (opts === null || opts === void 0 ? void 0 : opts.from) walker.currentNode = opts.from;
|
|
542
566
|
return walker;
|
|
543
567
|
}
|
|
544
|
-
function $a7a032acae3ddda9$export$c5251b9e124bf29(ref, defaultOptions = {
|
|
545
|
-
}) {
|
|
568
|
+
function $a7a032acae3ddda9$export$c5251b9e124bf29(ref, defaultOptions = {}) {
|
|
546
569
|
return {
|
|
547
|
-
focusNext (opts = {
|
|
548
|
-
}) {
|
|
570
|
+
focusNext (opts = {}) {
|
|
549
571
|
let root = ref.current;
|
|
550
572
|
if (!root) return;
|
|
551
573
|
let { from: from , tabbable: tabbable = defaultOptions.tabbable , wrap: wrap = defaultOptions.wrap , accept: accept = defaultOptions.accept } = opts;
|
|
@@ -618,7 +640,7 @@ function $a7a032acae3ddda9$var$last(walker) {
|
|
|
618
640
|
do {
|
|
619
641
|
last = walker.lastChild();
|
|
620
642
|
if (last) next = last;
|
|
621
|
-
}while (last)
|
|
643
|
+
}while (last);
|
|
622
644
|
return next;
|
|
623
645
|
}
|
|
624
646
|
class $a7a032acae3ddda9$var$Tree {
|
|
@@ -648,8 +670,7 @@ class $a7a032acae3ddda9$var$Tree {
|
|
|
648
670
|
for (let current of this.traverse())if (current !== node && node.nodeToRestore && current.nodeToRestore && node.scopeRef.current && $a7a032acae3ddda9$var$isElementInScope(current.nodeToRestore, node.scopeRef.current)) current.nodeToRestore = node.nodeToRestore;
|
|
649
671
|
let children = node.children;
|
|
650
672
|
parentNode.removeChild(node);
|
|
651
|
-
if (children.length > 0) children.forEach((child)=>parentNode.addChild(child)
|
|
652
|
-
);
|
|
673
|
+
if (children.length > 0) children.forEach((child)=>parentNode.addChild(child));
|
|
653
674
|
this.fastMap.delete(node.scopeRef);
|
|
654
675
|
}
|
|
655
676
|
// Pre Order Depth First
|
|
@@ -663,7 +684,7 @@ class $a7a032acae3ddda9$var$Tree {
|
|
|
663
684
|
return newTree;
|
|
664
685
|
}
|
|
665
686
|
constructor(){
|
|
666
|
-
this
|
|
687
|
+
(0, ($parcel$interopDefault($aB6Cp$swchelperslib_define_propertyjs)))(this, "fastMap", new Map());
|
|
667
688
|
this.root = new $a7a032acae3ddda9$var$TreeNode({
|
|
668
689
|
scopeRef: null
|
|
669
690
|
});
|
|
@@ -680,55 +701,62 @@ class $a7a032acae3ddda9$var$TreeNode {
|
|
|
680
701
|
node.parent = undefined;
|
|
681
702
|
}
|
|
682
703
|
constructor(props){
|
|
683
|
-
this
|
|
684
|
-
this
|
|
704
|
+
(0, ($parcel$interopDefault($aB6Cp$swchelperslib_define_propertyjs)))(this, "children", []);
|
|
705
|
+
(0, ($parcel$interopDefault($aB6Cp$swchelperslib_define_propertyjs)))(this, "contain", false);
|
|
685
706
|
this.scopeRef = props.scopeRef;
|
|
686
707
|
}
|
|
687
708
|
}
|
|
688
709
|
let $a7a032acae3ddda9$export$d06fae2ee68b101e = new $a7a032acae3ddda9$var$Tree();
|
|
689
710
|
|
|
690
711
|
|
|
712
|
+
/*
|
|
713
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
714
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
715
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
716
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
717
|
+
*
|
|
718
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
719
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
720
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
721
|
+
* governing permissions and limitations under the License.
|
|
722
|
+
*/
|
|
691
723
|
|
|
692
724
|
|
|
693
725
|
|
|
694
726
|
|
|
695
727
|
|
|
696
|
-
|
|
697
|
-
function $581a96d6eb128c1b$export$4e328f61c538687f(props = {
|
|
698
|
-
}) {
|
|
728
|
+
function $581a96d6eb128c1b$export$4e328f61c538687f(props = {}) {
|
|
699
729
|
let { autoFocus: autoFocus = false , isTextInput: isTextInput , within: within } = props;
|
|
700
|
-
let state = $aB6Cp$react.useRef({
|
|
730
|
+
let state = (0, $aB6Cp$react.useRef)({
|
|
701
731
|
isFocused: false,
|
|
702
|
-
isFocusVisible: autoFocus || $aB6Cp$reactariainteractions.isFocusVisible()
|
|
732
|
+
isFocusVisible: autoFocus || (0, $aB6Cp$reactariainteractions.isFocusVisible)()
|
|
703
733
|
});
|
|
704
|
-
let [
|
|
705
|
-
let [isFocusVisibleState, setFocusVisible] = $aB6Cp$react.useState(()=>state.current.isFocused && state.current.isFocusVisible
|
|
706
|
-
);
|
|
707
|
-
let
|
|
708
|
-
, []);
|
|
709
|
-
let onFocusChange = $aB6Cp$react.useCallback((isFocused)=>{
|
|
734
|
+
let [isFocused, setFocused] = (0, $aB6Cp$react.useState)(false);
|
|
735
|
+
let [isFocusVisibleState, setFocusVisible] = (0, $aB6Cp$react.useState)(()=>state.current.isFocused && state.current.isFocusVisible);
|
|
736
|
+
let updateState = (0, $aB6Cp$react.useCallback)(()=>setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);
|
|
737
|
+
let onFocusChange = (0, $aB6Cp$react.useCallback)((isFocused)=>{
|
|
710
738
|
state.current.isFocused = isFocused;
|
|
711
739
|
setFocused(isFocused);
|
|
712
740
|
updateState();
|
|
713
741
|
}, [
|
|
714
742
|
updateState
|
|
715
743
|
]);
|
|
716
|
-
$aB6Cp$reactariainteractions.useFocusVisibleListener((isFocusVisible)=>{
|
|
744
|
+
(0, $aB6Cp$reactariainteractions.useFocusVisibleListener)((isFocusVisible)=>{
|
|
717
745
|
state.current.isFocusVisible = isFocusVisible;
|
|
718
746
|
updateState();
|
|
719
747
|
}, [], {
|
|
720
748
|
isTextInput: isTextInput
|
|
721
749
|
});
|
|
722
|
-
let { focusProps: focusProps } = $aB6Cp$reactariainteractions.useFocus({
|
|
750
|
+
let { focusProps: focusProps } = (0, $aB6Cp$reactariainteractions.useFocus)({
|
|
723
751
|
isDisabled: within,
|
|
724
752
|
onFocusChange: onFocusChange
|
|
725
753
|
});
|
|
726
|
-
let { focusWithinProps: focusWithinProps } = $aB6Cp$reactariainteractions.useFocusWithin({
|
|
754
|
+
let { focusWithinProps: focusWithinProps } = (0, $aB6Cp$reactariainteractions.useFocusWithin)({
|
|
727
755
|
isDisabled: !within,
|
|
728
756
|
onFocusWithinChange: onFocusChange
|
|
729
757
|
});
|
|
730
758
|
return {
|
|
731
|
-
isFocused:
|
|
759
|
+
isFocused: isFocused,
|
|
732
760
|
isFocusVisible: state.current.isFocused && isFocusVisibleState,
|
|
733
761
|
focusProps: within ? focusWithinProps : focusProps
|
|
734
762
|
};
|
|
@@ -737,27 +765,36 @@ function $581a96d6eb128c1b$export$4e328f61c538687f(props = {
|
|
|
737
765
|
|
|
738
766
|
function $dfd8c70b928eb1b3$export$1a38b4ad7f578e1d(props) {
|
|
739
767
|
let { children: children , focusClass: focusClass , focusRingClass: focusRingClass } = props;
|
|
740
|
-
let { isFocused: isFocused , isFocusVisible: isFocusVisible , focusProps: focusProps } = $581a96d6eb128c1b$export$4e328f61c538687f(props);
|
|
741
|
-
let child = ($parcel$interopDefault($aB6Cp$react)).Children.only(children);
|
|
742
|
-
return
|
|
768
|
+
let { isFocused: isFocused , isFocusVisible: isFocusVisible , focusProps: focusProps } = (0, $581a96d6eb128c1b$export$4e328f61c538687f)(props);
|
|
769
|
+
let child = (0, ($parcel$interopDefault($aB6Cp$react))).Children.only(children);
|
|
770
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).cloneElement(child, (0, $aB6Cp$reactariautils.mergeProps)(child.props, {
|
|
743
771
|
...focusProps,
|
|
744
|
-
className: ($parcel$interopDefault($aB6Cp$clsx))({
|
|
745
|
-
[focusClass ||
|
|
746
|
-
[focusRingClass ||
|
|
772
|
+
className: (0, ($parcel$interopDefault($aB6Cp$clsx)))({
|
|
773
|
+
[focusClass || ""]: isFocused,
|
|
774
|
+
[focusRingClass || ""]: isFocusVisible
|
|
747
775
|
})
|
|
748
|
-
}))
|
|
776
|
+
}));
|
|
749
777
|
}
|
|
750
778
|
|
|
751
779
|
|
|
780
|
+
/*
|
|
781
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
782
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
783
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
784
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
785
|
+
*
|
|
786
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
787
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
788
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
789
|
+
* governing permissions and limitations under the License.
|
|
790
|
+
*/
|
|
752
791
|
|
|
753
792
|
|
|
754
793
|
|
|
755
|
-
|
|
756
|
-
let $fb504d83237fd6ac$var$FocusableContext = /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createContext(null);
|
|
794
|
+
let $fb504d83237fd6ac$var$FocusableContext = /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).createContext(null);
|
|
757
795
|
function $fb504d83237fd6ac$var$useFocusableContext(ref) {
|
|
758
|
-
let context = $aB6Cp$react.useContext($fb504d83237fd6ac$var$FocusableContext) || {
|
|
759
|
-
|
|
760
|
-
$aB6Cp$reactariautils.useSyncRef(context, ref);
|
|
796
|
+
let context = (0, $aB6Cp$react.useContext)($fb504d83237fd6ac$var$FocusableContext) || {};
|
|
797
|
+
(0, $aB6Cp$reactariautils.useSyncRef)(context, ref);
|
|
761
798
|
// eslint-disable-next-line
|
|
762
799
|
let { ref: _ , ...otherProps } = context;
|
|
763
800
|
return otherProps;
|
|
@@ -770,27 +807,26 @@ function $fb504d83237fd6ac$var$useFocusableContext(ref) {
|
|
|
770
807
|
...otherProps,
|
|
771
808
|
ref: ref
|
|
772
809
|
};
|
|
773
|
-
return
|
|
810
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).createElement($fb504d83237fd6ac$var$FocusableContext.Provider, {
|
|
774
811
|
value: context
|
|
775
|
-
}, children)
|
|
812
|
+
}, children);
|
|
776
813
|
}
|
|
777
|
-
let $fb504d83237fd6ac$export$13f3202a3e5ddd5 = /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).forwardRef($fb504d83237fd6ac$var$FocusableProvider);
|
|
814
|
+
let $fb504d83237fd6ac$export$13f3202a3e5ddd5 = /*#__PURE__*/ (0, ($parcel$interopDefault($aB6Cp$react))).forwardRef($fb504d83237fd6ac$var$FocusableProvider);
|
|
778
815
|
function $fb504d83237fd6ac$export$4c014de7c8940b4c(props, domRef) {
|
|
779
|
-
let { focusProps: focusProps } = $aB6Cp$reactariainteractions.useFocus(props);
|
|
780
|
-
let { keyboardProps: keyboardProps } = $aB6Cp$reactariainteractions.useKeyboard(props);
|
|
781
|
-
let interactions = $aB6Cp$reactariautils.mergeProps(focusProps, keyboardProps);
|
|
816
|
+
let { focusProps: focusProps } = (0, $aB6Cp$reactariainteractions.useFocus)(props);
|
|
817
|
+
let { keyboardProps: keyboardProps } = (0, $aB6Cp$reactariainteractions.useKeyboard)(props);
|
|
818
|
+
let interactions = (0, $aB6Cp$reactariautils.mergeProps)(focusProps, keyboardProps);
|
|
782
819
|
let domProps = $fb504d83237fd6ac$var$useFocusableContext(domRef);
|
|
783
|
-
let interactionProps = props.isDisabled ? {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
if (autoFocusRef.current && domRef.current) $1c7f9157d722357d$export$80f3e147d781571c(domRef.current);
|
|
820
|
+
let interactionProps = props.isDisabled ? {} : domProps;
|
|
821
|
+
let autoFocusRef = (0, $aB6Cp$react.useRef)(props.autoFocus);
|
|
822
|
+
(0, $aB6Cp$react.useEffect)(()=>{
|
|
823
|
+
if (autoFocusRef.current && domRef.current) (0, $1c7f9157d722357d$export$80f3e147d781571c)(domRef.current);
|
|
788
824
|
autoFocusRef.current = false;
|
|
789
825
|
}, [
|
|
790
826
|
domRef
|
|
791
827
|
]);
|
|
792
828
|
return {
|
|
793
|
-
focusableProps: $aB6Cp$reactariautils.mergeProps({
|
|
829
|
+
focusableProps: (0, $aB6Cp$reactariautils.mergeProps)({
|
|
794
830
|
...interactions,
|
|
795
831
|
tabIndex: props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined
|
|
796
832
|
}, interactionProps)
|