@react-aria/focus 3.5.2 → 3.5.3
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 +163 -163
- package/dist/main.js.map +1 -1
- package/dist/module.js +159 -159
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +5 -5
- package/src/FocusScope.tsx +1 -1
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
1
|
+
var $aB6Cp$react = require("react");
|
|
2
|
+
var $aB6Cp$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $aB6Cp$reactariainteractions = require("@react-aria/interactions");
|
|
4
|
+
var $aB6Cp$clsx = require("clsx");
|
|
5
5
|
|
|
6
6
|
function $parcel$exportWildcard(dest, source) {
|
|
7
7
|
Object.keys(source).forEach(function(key) {
|
|
@@ -25,30 +25,30 @@ function $parcel$interopDefault(a) {
|
|
|
25
25
|
function $parcel$export(e, n, v, s) {
|
|
26
26
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
27
27
|
}
|
|
28
|
-
var $
|
|
28
|
+
var $a7a032acae3ddda9$exports = {};
|
|
29
29
|
|
|
30
|
-
$parcel$export($
|
|
31
|
-
$parcel$export($
|
|
32
|
-
$parcel$export($
|
|
33
|
-
$parcel$export($
|
|
34
|
-
var $
|
|
30
|
+
$parcel$export($a7a032acae3ddda9$exports, "FocusScope", () => $a7a032acae3ddda9$export$20e40289641fbbb6);
|
|
31
|
+
$parcel$export($a7a032acae3ddda9$exports, "useFocusManager", () => $a7a032acae3ddda9$export$10c5169755ce7bd7);
|
|
32
|
+
$parcel$export($a7a032acae3ddda9$exports, "getFocusableTreeWalker", () => $a7a032acae3ddda9$export$2d6ec8fc375ceafa);
|
|
33
|
+
$parcel$export($a7a032acae3ddda9$exports, "createFocusManager", () => $a7a032acae3ddda9$export$c5251b9e124bf29);
|
|
34
|
+
var $1c7f9157d722357d$exports = {};
|
|
35
35
|
|
|
36
|
-
$parcel$export($
|
|
36
|
+
$parcel$export($1c7f9157d722357d$exports, "focusSafely", () => $1c7f9157d722357d$export$80f3e147d781571c);
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
function $
|
|
39
|
+
function $1c7f9157d722357d$export$80f3e147d781571c(element) {
|
|
40
40
|
// If the user is interacting with a virtual cursor, e.g. screen reader, then
|
|
41
41
|
// wait until after any animated transitions that are currently occurring on
|
|
42
42
|
// the page before shifting focus. This avoids issues with VoiceOver on iOS
|
|
43
43
|
// causing the page to scroll when moving focus if the element is transitioning
|
|
44
44
|
// from off the screen.
|
|
45
|
-
if ($
|
|
45
|
+
if ($aB6Cp$reactariainteractions.getInteractionModality() === 'virtual') {
|
|
46
46
|
let lastFocusedElement = document.activeElement;
|
|
47
|
-
$
|
|
47
|
+
$aB6Cp$reactariautils.runAfterTransition(()=>{
|
|
48
48
|
// If focus did not move and the element is still in the document, focus it.
|
|
49
|
-
if (document.activeElement === lastFocusedElement && document.contains(element)) $
|
|
49
|
+
if (document.activeElement === lastFocusedElement && document.contains(element)) $aB6Cp$reactariautils.focusWithoutScrolling(element);
|
|
50
50
|
});
|
|
51
|
-
} else $
|
|
51
|
+
} else $aB6Cp$reactariautils.focusWithoutScrolling(element);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
|
|
@@ -62,7 +62,7 @@ function $5d2399de34f67875$export$80f3e147d781571c(element) {
|
|
|
62
62
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
63
63
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
64
64
|
* governing permissions and limitations under the License.
|
|
65
|
-
*/ function $
|
|
65
|
+
*/ function $d5156037ad898a4d$var$isStyleVisible(element) {
|
|
66
66
|
if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) return false;
|
|
67
67
|
let { display: display , visibility: visibility } = element.style;
|
|
68
68
|
let isVisible = display !== 'none' && visibility !== 'hidden' && visibility !== 'collapse';
|
|
@@ -73,27 +73,27 @@ function $5d2399de34f67875$export$80f3e147d781571c(element) {
|
|
|
73
73
|
}
|
|
74
74
|
return isVisible;
|
|
75
75
|
}
|
|
76
|
-
function $
|
|
76
|
+
function $d5156037ad898a4d$var$isAttributeVisible(element, childElement) {
|
|
77
77
|
return !element.hasAttribute('hidden') && (element.nodeName === 'DETAILS' && childElement && childElement.nodeName !== 'SUMMARY' ? element.hasAttribute('open') : true);
|
|
78
78
|
}
|
|
79
|
-
function $
|
|
80
|
-
return element.nodeName !== '#comment' && $
|
|
79
|
+
function $d5156037ad898a4d$export$e989c0fffaa6b27a(element, childElement) {
|
|
80
|
+
return element.nodeName !== '#comment' && $d5156037ad898a4d$var$isStyleVisible(element) && $d5156037ad898a4d$var$isAttributeVisible(element, childElement) && (!element.parentElement || $d5156037ad898a4d$export$e989c0fffaa6b27a(element.parentElement, element));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
const $
|
|
87
|
-
let $
|
|
88
|
-
let $
|
|
89
|
-
function $
|
|
86
|
+
const $a7a032acae3ddda9$var$FocusContext = /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createContext(null);
|
|
87
|
+
let $a7a032acae3ddda9$var$activeScope = null;
|
|
88
|
+
let $a7a032acae3ddda9$var$scopes = new Map();
|
|
89
|
+
function $a7a032acae3ddda9$export$20e40289641fbbb6(props) {
|
|
90
90
|
let { children: children , contain: contain , restoreFocus: restoreFocus , autoFocus: autoFocus } = props;
|
|
91
|
-
let startRef = $
|
|
92
|
-
let endRef = $
|
|
93
|
-
let scopeRef = $
|
|
94
|
-
let ctx = $
|
|
91
|
+
let startRef = $aB6Cp$react.useRef();
|
|
92
|
+
let endRef = $aB6Cp$react.useRef();
|
|
93
|
+
let scopeRef = $aB6Cp$react.useRef([]);
|
|
94
|
+
let ctx = $aB6Cp$react.useContext($a7a032acae3ddda9$var$FocusContext);
|
|
95
95
|
let parentScope = ctx === null || ctx === void 0 ? void 0 : ctx.scopeRef;
|
|
96
|
-
$
|
|
96
|
+
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
97
97
|
// Find all rendered nodes between the sentinels and add them to the scope.
|
|
98
98
|
let node = startRef.current.nextSibling;
|
|
99
99
|
let nodes = [];
|
|
@@ -106,43 +106,43 @@ function $81f01af19760c2bc$export$20e40289641fbbb6(props) {
|
|
|
106
106
|
children,
|
|
107
107
|
parentScope
|
|
108
108
|
]);
|
|
109
|
-
$
|
|
110
|
-
$
|
|
109
|
+
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
110
|
+
$a7a032acae3ddda9$var$scopes.set(scopeRef, parentScope);
|
|
111
111
|
return ()=>{
|
|
112
112
|
// Restore the active scope on unmount if this scope or a descendant scope is active.
|
|
113
113
|
// Parent effect cleanups run before children, so we need to check if the
|
|
114
114
|
// parent scope actually still exists before restoring the active scope to it.
|
|
115
|
-
if ((scopeRef === $
|
|
116
|
-
$
|
|
115
|
+
if ((scopeRef === $a7a032acae3ddda9$var$activeScope || $a7a032acae3ddda9$var$isAncestorScope(scopeRef, $a7a032acae3ddda9$var$activeScope)) && (!parentScope || $a7a032acae3ddda9$var$scopes.has(parentScope))) $a7a032acae3ddda9$var$activeScope = parentScope;
|
|
116
|
+
$a7a032acae3ddda9$var$scopes.delete(scopeRef);
|
|
117
117
|
};
|
|
118
118
|
}, [
|
|
119
119
|
scopeRef,
|
|
120
120
|
parentScope
|
|
121
121
|
]);
|
|
122
|
-
$
|
|
123
|
-
$
|
|
124
|
-
$
|
|
125
|
-
let focusManager = $
|
|
126
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
122
|
+
$a7a032acae3ddda9$var$useFocusContainment(scopeRef, contain);
|
|
123
|
+
$a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain);
|
|
124
|
+
$a7a032acae3ddda9$var$useAutoFocus(scopeRef, autoFocus);
|
|
125
|
+
let focusManager = $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef);
|
|
126
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createElement($a7a032acae3ddda9$var$FocusContext.Provider, {
|
|
127
127
|
value: {
|
|
128
128
|
scopeRef: scopeRef,
|
|
129
129
|
focusManager: focusManager
|
|
130
130
|
}
|
|
131
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($
|
|
131
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createElement("span", {
|
|
132
132
|
"data-focus-scope-start": true,
|
|
133
133
|
hidden: true,
|
|
134
134
|
ref: startRef
|
|
135
|
-
}), children, /*#__PURE__*/ ($parcel$interopDefault($
|
|
135
|
+
}), children, /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createElement("span", {
|
|
136
136
|
"data-focus-scope-end": true,
|
|
137
137
|
hidden: true,
|
|
138
138
|
ref: endRef
|
|
139
139
|
})));
|
|
140
140
|
}
|
|
141
|
-
function $
|
|
141
|
+
function $a7a032acae3ddda9$export$10c5169755ce7bd7() {
|
|
142
142
|
var ref;
|
|
143
|
-
return (ref = $
|
|
143
|
+
return (ref = $aB6Cp$react.useContext($a7a032acae3ddda9$var$FocusContext)) === null || ref === void 0 ? void 0 : ref.focusManager;
|
|
144
144
|
}
|
|
145
|
-
function $
|
|
145
|
+
function $a7a032acae3ddda9$var$createFocusManagerForScope(scopeRef) {
|
|
146
146
|
return {
|
|
147
147
|
focusNext (opts = {
|
|
148
148
|
}) {
|
|
@@ -150,16 +150,16 @@ function $81f01af19760c2bc$var$createFocusManagerForScope(scopeRef) {
|
|
|
150
150
|
let { from: from , tabbable: tabbable , wrap: wrap } = opts;
|
|
151
151
|
let node = from || document.activeElement;
|
|
152
152
|
let sentinel = scope[0].previousElementSibling;
|
|
153
|
-
let walker = $
|
|
153
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
154
154
|
tabbable: tabbable
|
|
155
155
|
}, scope);
|
|
156
|
-
walker.currentNode = $
|
|
156
|
+
walker.currentNode = $a7a032acae3ddda9$var$isElementInScope(node, scope) ? node : sentinel;
|
|
157
157
|
let nextNode = walker.nextNode();
|
|
158
158
|
if (!nextNode && wrap) {
|
|
159
159
|
walker.currentNode = sentinel;
|
|
160
160
|
nextNode = walker.nextNode();
|
|
161
161
|
}
|
|
162
|
-
if (nextNode) $
|
|
162
|
+
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
|
|
163
163
|
return nextNode;
|
|
164
164
|
},
|
|
165
165
|
focusPrevious (opts = {
|
|
@@ -168,45 +168,45 @@ function $81f01af19760c2bc$var$createFocusManagerForScope(scopeRef) {
|
|
|
168
168
|
let { from: from , tabbable: tabbable , wrap: wrap } = opts;
|
|
169
169
|
let node = from || document.activeElement;
|
|
170
170
|
let sentinel = scope[scope.length - 1].nextElementSibling;
|
|
171
|
-
let walker = $
|
|
171
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
172
172
|
tabbable: tabbable
|
|
173
173
|
}, scope);
|
|
174
|
-
walker.currentNode = $
|
|
174
|
+
walker.currentNode = $a7a032acae3ddda9$var$isElementInScope(node, scope) ? node : sentinel;
|
|
175
175
|
let previousNode = walker.previousNode();
|
|
176
176
|
if (!previousNode && wrap) {
|
|
177
177
|
walker.currentNode = sentinel;
|
|
178
178
|
previousNode = walker.previousNode();
|
|
179
179
|
}
|
|
180
|
-
if (previousNode) $
|
|
180
|
+
if (previousNode) $a7a032acae3ddda9$var$focusElement(previousNode, true);
|
|
181
181
|
return previousNode;
|
|
182
182
|
},
|
|
183
183
|
focusFirst (opts = {
|
|
184
184
|
}) {
|
|
185
185
|
let scope = scopeRef.current;
|
|
186
186
|
let { tabbable: tabbable } = opts;
|
|
187
|
-
let walker = $
|
|
187
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
188
188
|
tabbable: tabbable
|
|
189
189
|
}, scope);
|
|
190
190
|
walker.currentNode = scope[0].previousElementSibling;
|
|
191
191
|
let nextNode = walker.nextNode();
|
|
192
|
-
if (nextNode) $
|
|
192
|
+
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
|
|
193
193
|
return nextNode;
|
|
194
194
|
},
|
|
195
195
|
focusLast (opts = {
|
|
196
196
|
}) {
|
|
197
197
|
let scope = scopeRef.current;
|
|
198
198
|
let { tabbable: tabbable } = opts;
|
|
199
|
-
let walker = $
|
|
199
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
200
200
|
tabbable: tabbable
|
|
201
201
|
}, scope);
|
|
202
202
|
walker.currentNode = scope[scope.length - 1].nextElementSibling;
|
|
203
203
|
let previousNode = walker.previousNode();
|
|
204
|
-
if (previousNode) $
|
|
204
|
+
if (previousNode) $a7a032acae3ddda9$var$focusElement(previousNode, true);
|
|
205
205
|
return previousNode;
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
const $
|
|
209
|
+
const $a7a032acae3ddda9$var$focusableElements = [
|
|
210
210
|
'input:not([disabled]):not([type=hidden])',
|
|
211
211
|
'select:not([disabled])',
|
|
212
212
|
'textarea:not([disabled])',
|
|
@@ -221,25 +221,25 @@ const $81f01af19760c2bc$var$focusableElements = [
|
|
|
221
221
|
'video[controls]',
|
|
222
222
|
'[contenteditable]'
|
|
223
223
|
];
|
|
224
|
-
const $
|
|
225
|
-
$
|
|
226
|
-
const $
|
|
227
|
-
function $
|
|
224
|
+
const $a7a032acae3ddda9$var$FOCUSABLE_ELEMENT_SELECTOR = $a7a032acae3ddda9$var$focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';
|
|
225
|
+
$a7a032acae3ddda9$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
|
|
226
|
+
const $a7a032acae3ddda9$var$TABBABLE_ELEMENT_SELECTOR = $a7a032acae3ddda9$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
|
|
227
|
+
function $a7a032acae3ddda9$var$getScopeRoot(scope) {
|
|
228
228
|
return scope[0].parentElement;
|
|
229
229
|
}
|
|
230
|
-
function $
|
|
231
|
-
let focusedNode = $
|
|
232
|
-
let raf = $
|
|
233
|
-
$
|
|
230
|
+
function $a7a032acae3ddda9$var$useFocusContainment(scopeRef, contain) {
|
|
231
|
+
let focusedNode = $aB6Cp$react.useRef();
|
|
232
|
+
let raf = $aB6Cp$react.useRef(null);
|
|
233
|
+
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
234
234
|
let scope1 = scopeRef.current;
|
|
235
235
|
if (!contain) return;
|
|
236
236
|
// Handle the Tab key to contain focus within the scope
|
|
237
237
|
let onKeyDown = (e)=>{
|
|
238
|
-
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || scopeRef !== $
|
|
238
|
+
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey || scopeRef !== $a7a032acae3ddda9$var$activeScope) return;
|
|
239
239
|
let focusedElement = document.activeElement;
|
|
240
240
|
let scope = scopeRef.current;
|
|
241
|
-
if (!$
|
|
242
|
-
let walker = $
|
|
241
|
+
if (!$a7a032acae3ddda9$var$isElementInScope(focusedElement, scope)) return;
|
|
242
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
243
243
|
tabbable: true
|
|
244
244
|
}, scope);
|
|
245
245
|
walker.currentNode = focusedElement;
|
|
@@ -249,27 +249,27 @@ function $81f01af19760c2bc$var$useFocusContainment(scopeRef, contain) {
|
|
|
249
249
|
nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
|
|
250
250
|
}
|
|
251
251
|
e.preventDefault();
|
|
252
|
-
if (nextElement) $
|
|
252
|
+
if (nextElement) $a7a032acae3ddda9$var$focusElement(nextElement, true);
|
|
253
253
|
};
|
|
254
254
|
let onFocus = (e)=>{
|
|
255
255
|
// If focusing an element in a child scope of the currently active scope, the child becomes active.
|
|
256
256
|
// Moving out of the active scope to an ancestor is not allowed.
|
|
257
|
-
if (!$
|
|
258
|
-
$
|
|
257
|
+
if (!$a7a032acae3ddda9$var$activeScope || $a7a032acae3ddda9$var$isAncestorScope($a7a032acae3ddda9$var$activeScope, scopeRef)) {
|
|
258
|
+
$a7a032acae3ddda9$var$activeScope = scopeRef;
|
|
259
259
|
focusedNode.current = e.target;
|
|
260
|
-
} else if (scopeRef === $
|
|
260
|
+
} else if (scopeRef === $a7a032acae3ddda9$var$activeScope && !$a7a032acae3ddda9$var$isElementInChildScope(e.target, scopeRef)) {
|
|
261
261
|
// If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),
|
|
262
262
|
// restore focus to the previously focused node or the first tabbable element in the active scope.
|
|
263
263
|
if (focusedNode.current) focusedNode.current.focus();
|
|
264
|
-
else if ($
|
|
265
|
-
} else if (scopeRef === $
|
|
264
|
+
else if ($a7a032acae3ddda9$var$activeScope) $a7a032acae3ddda9$var$focusFirstInScope($a7a032acae3ddda9$var$activeScope.current);
|
|
265
|
+
} else if (scopeRef === $a7a032acae3ddda9$var$activeScope) focusedNode.current = e.target;
|
|
266
266
|
};
|
|
267
267
|
let onBlur = (e)=>{
|
|
268
268
|
// Firefox doesn't shift focus back to the Dialog properly without this
|
|
269
269
|
raf.current = requestAnimationFrame(()=>{
|
|
270
270
|
// Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe
|
|
271
|
-
if (scopeRef === $
|
|
272
|
-
$
|
|
271
|
+
if (scopeRef === $a7a032acae3ddda9$var$activeScope && !$a7a032acae3ddda9$var$isElementInChildScope(document.activeElement, scopeRef)) {
|
|
272
|
+
$a7a032acae3ddda9$var$activeScope = scopeRef;
|
|
273
273
|
focusedNode.current = e.target;
|
|
274
274
|
focusedNode.current.focus();
|
|
275
275
|
}
|
|
@@ -294,40 +294,40 @@ function $81f01af19760c2bc$var$useFocusContainment(scopeRef, contain) {
|
|
|
294
294
|
contain
|
|
295
295
|
]);
|
|
296
296
|
// eslint-disable-next-line arrow-body-style
|
|
297
|
-
$
|
|
297
|
+
$aB6Cp$react.useEffect(()=>{
|
|
298
298
|
return ()=>cancelAnimationFrame(raf.current)
|
|
299
299
|
;
|
|
300
300
|
}, [
|
|
301
301
|
raf
|
|
302
302
|
]);
|
|
303
303
|
}
|
|
304
|
-
function $
|
|
305
|
-
for (let scope of $
|
|
306
|
-
if ($
|
|
304
|
+
function $a7a032acae3ddda9$var$isElementInAnyScope(element) {
|
|
305
|
+
for (let scope of $a7a032acae3ddda9$var$scopes.keys()){
|
|
306
|
+
if ($a7a032acae3ddda9$var$isElementInScope(element, scope.current)) return true;
|
|
307
307
|
}
|
|
308
308
|
return false;
|
|
309
309
|
}
|
|
310
|
-
function $
|
|
310
|
+
function $a7a032acae3ddda9$var$isElementInScope(element, scope) {
|
|
311
311
|
return scope.some((node)=>node.contains(element)
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
|
-
function $
|
|
314
|
+
function $a7a032acae3ddda9$var$isElementInChildScope(element, scope) {
|
|
315
315
|
// node.contains in isElementInScope covers child scopes that are also DOM children,
|
|
316
316
|
// but does not cover child scopes in portals.
|
|
317
|
-
for (let s of $
|
|
318
|
-
if ((s === scope || $
|
|
317
|
+
for (let s of $a7a032acae3ddda9$var$scopes.keys()){
|
|
318
|
+
if ((s === scope || $a7a032acae3ddda9$var$isAncestorScope(scope, s)) && $a7a032acae3ddda9$var$isElementInScope(element, s.current)) return true;
|
|
319
319
|
}
|
|
320
320
|
return false;
|
|
321
321
|
}
|
|
322
|
-
function $
|
|
323
|
-
let parent = $
|
|
322
|
+
function $a7a032acae3ddda9$var$isAncestorScope(ancestor, scope) {
|
|
323
|
+
let parent = $a7a032acae3ddda9$var$scopes.get(scope);
|
|
324
324
|
if (!parent) return false;
|
|
325
325
|
if (parent === ancestor) return true;
|
|
326
|
-
return $
|
|
326
|
+
return $a7a032acae3ddda9$var$isAncestorScope(ancestor, parent);
|
|
327
327
|
}
|
|
328
|
-
function $
|
|
328
|
+
function $a7a032acae3ddda9$var$focusElement(element, scroll = false) {
|
|
329
329
|
if (element != null && !scroll) try {
|
|
330
|
-
$
|
|
330
|
+
$1c7f9157d722357d$export$80f3e147d781571c(element);
|
|
331
331
|
} catch (err) {
|
|
332
332
|
// ignore
|
|
333
333
|
}
|
|
@@ -337,29 +337,29 @@ function $81f01af19760c2bc$var$focusElement(element, scroll = false) {
|
|
|
337
337
|
// ignore
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
function $
|
|
340
|
+
function $a7a032acae3ddda9$var$focusFirstInScope(scope) {
|
|
341
341
|
let sentinel = scope[0].previousElementSibling;
|
|
342
|
-
let walker = $
|
|
342
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa($a7a032acae3ddda9$var$getScopeRoot(scope), {
|
|
343
343
|
tabbable: true
|
|
344
344
|
}, scope);
|
|
345
345
|
walker.currentNode = sentinel;
|
|
346
|
-
$
|
|
346
|
+
$a7a032acae3ddda9$var$focusElement(walker.nextNode());
|
|
347
347
|
}
|
|
348
|
-
function $
|
|
349
|
-
const autoFocusRef = ($parcel$interopDefault($
|
|
350
|
-
$
|
|
348
|
+
function $a7a032acae3ddda9$var$useAutoFocus(scopeRef, autoFocus) {
|
|
349
|
+
const autoFocusRef = ($parcel$interopDefault($aB6Cp$react)).useRef(autoFocus);
|
|
350
|
+
$aB6Cp$react.useEffect(()=>{
|
|
351
351
|
if (autoFocusRef.current) {
|
|
352
|
-
$
|
|
353
|
-
if (!$
|
|
352
|
+
$a7a032acae3ddda9$var$activeScope = scopeRef;
|
|
353
|
+
if (!$a7a032acae3ddda9$var$isElementInScope(document.activeElement, $a7a032acae3ddda9$var$activeScope.current)) $a7a032acae3ddda9$var$focusFirstInScope(scopeRef.current);
|
|
354
354
|
}
|
|
355
355
|
autoFocusRef.current = false;
|
|
356
356
|
}, []);
|
|
357
357
|
}
|
|
358
|
-
function $
|
|
358
|
+
function $a7a032acae3ddda9$var$useRestoreFocus(scopeRef, restoreFocus, contain) {
|
|
359
359
|
// create a ref during render instead of useLayoutEffect so the active element is saved before a child with autoFocus=true mounts.
|
|
360
|
-
const nodeToRestoreRef = $
|
|
360
|
+
const nodeToRestoreRef = $aB6Cp$react.useRef(typeof document !== 'undefined' ? document.activeElement : null);
|
|
361
361
|
// useLayoutEffect instead of useEffect so the active element is saved synchronously instead of asynchronously.
|
|
362
|
-
$
|
|
362
|
+
$aB6Cp$reactariautils.useLayoutEffect(()=>{
|
|
363
363
|
let nodeToRestore = nodeToRestoreRef.current;
|
|
364
364
|
if (!restoreFocus) return;
|
|
365
365
|
// Handle the Tab key so that tabbing out of the scope goes to the next element
|
|
@@ -369,9 +369,9 @@ function $81f01af19760c2bc$var$useRestoreFocus(scopeRef, restoreFocus, contain)
|
|
|
369
369
|
let onKeyDown = (e)=>{
|
|
370
370
|
if (e.key !== 'Tab' || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
371
371
|
let focusedElement = document.activeElement;
|
|
372
|
-
if (!$
|
|
372
|
+
if (!$a7a032acae3ddda9$var$isElementInScope(focusedElement, scopeRef.current)) return;
|
|
373
373
|
// Create a DOM tree walker that matches all tabbable elements
|
|
374
|
-
let walker = $
|
|
374
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(document.body, {
|
|
375
375
|
tabbable: true
|
|
376
376
|
});
|
|
377
377
|
// Find the next tabbable element after the currently focused element
|
|
@@ -380,26 +380,26 @@ function $81f01af19760c2bc$var$useRestoreFocus(scopeRef, restoreFocus, contain)
|
|
|
380
380
|
if (!document.body.contains(nodeToRestore) || nodeToRestore === document.body) nodeToRestore = null;
|
|
381
381
|
// If there is no next element, or it is outside the current scope, move focus to the
|
|
382
382
|
// next element after the node to restore to instead.
|
|
383
|
-
if ((!nextElement || !$
|
|
383
|
+
if ((!nextElement || !$a7a032acae3ddda9$var$isElementInScope(nextElement, scopeRef.current)) && nodeToRestore) {
|
|
384
384
|
walker.currentNode = nodeToRestore;
|
|
385
385
|
// Skip over elements within the scope, in case the scope immediately follows the node to restore.
|
|
386
386
|
do nextElement = e.shiftKey ? walker.previousNode() : walker.nextNode();
|
|
387
|
-
while ($
|
|
387
|
+
while ($a7a032acae3ddda9$var$isElementInScope(nextElement, scopeRef.current))
|
|
388
388
|
e.preventDefault();
|
|
389
389
|
e.stopPropagation();
|
|
390
|
-
if (nextElement) $
|
|
390
|
+
if (nextElement) $a7a032acae3ddda9$var$focusElement(nextElement, true);
|
|
391
391
|
else // If there is no next element and the nodeToRestore isn't within a FocusScope (i.e. we are leaving the top level focus scope)
|
|
392
392
|
// then move focus to the body.
|
|
393
393
|
// Otherwise restore focus to the nodeToRestore (e.g menu within a popover -> tabbing to close the menu should move focus to menu trigger)
|
|
394
|
-
if (!$
|
|
395
|
-
else $
|
|
394
|
+
if (!$a7a032acae3ddda9$var$isElementInAnyScope(nodeToRestore)) focusedElement.blur();
|
|
395
|
+
else $a7a032acae3ddda9$var$focusElement(nodeToRestore, true);
|
|
396
396
|
}
|
|
397
397
|
};
|
|
398
398
|
if (!contain) document.addEventListener('keydown', onKeyDown, true);
|
|
399
399
|
return ()=>{
|
|
400
400
|
if (!contain) document.removeEventListener('keydown', onKeyDown, true);
|
|
401
|
-
if (restoreFocus && nodeToRestore && $
|
|
402
|
-
if (document.body.contains(nodeToRestore)) $
|
|
401
|
+
if (restoreFocus && nodeToRestore && $a7a032acae3ddda9$var$isElementInScope(document.activeElement, scopeRef.current)) requestAnimationFrame(()=>{
|
|
402
|
+
if (document.body.contains(nodeToRestore)) $a7a032acae3ddda9$var$focusElement(nodeToRestore);
|
|
403
403
|
});
|
|
404
404
|
};
|
|
405
405
|
}, [
|
|
@@ -408,28 +408,28 @@ function $81f01af19760c2bc$var$useRestoreFocus(scopeRef, restoreFocus, contain)
|
|
|
408
408
|
contain
|
|
409
409
|
]);
|
|
410
410
|
}
|
|
411
|
-
function $
|
|
412
|
-
let selector = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? $
|
|
411
|
+
function $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, opts, scope) {
|
|
412
|
+
let selector = (opts === null || opts === void 0 ? void 0 : opts.tabbable) ? $a7a032acae3ddda9$var$TABBABLE_ELEMENT_SELECTOR : $a7a032acae3ddda9$var$FOCUSABLE_ELEMENT_SELECTOR;
|
|
413
413
|
let walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, {
|
|
414
414
|
acceptNode (node) {
|
|
415
415
|
var ref;
|
|
416
416
|
// Skip nodes inside the starting node.
|
|
417
417
|
if (opts === null || opts === void 0 ? void 0 : (ref = opts.from) === null || ref === void 0 ? void 0 : ref.contains(node)) return NodeFilter.FILTER_REJECT;
|
|
418
|
-
if (node.matches(selector) && $
|
|
418
|
+
if (node.matches(selector) && $d5156037ad898a4d$export$e989c0fffaa6b27a(node) && (!scope || $a7a032acae3ddda9$var$isElementInScope(node, scope))) return NodeFilter.FILTER_ACCEPT;
|
|
419
419
|
return NodeFilter.FILTER_SKIP;
|
|
420
420
|
}
|
|
421
421
|
});
|
|
422
422
|
if (opts === null || opts === void 0 ? void 0 : opts.from) walker.currentNode = opts.from;
|
|
423
423
|
return walker;
|
|
424
424
|
}
|
|
425
|
-
function $
|
|
425
|
+
function $a7a032acae3ddda9$export$c5251b9e124bf29(ref) {
|
|
426
426
|
return {
|
|
427
427
|
focusNext (opts = {
|
|
428
428
|
}) {
|
|
429
429
|
let root = ref.current;
|
|
430
430
|
let { from: from , tabbable: tabbable , wrap: wrap } = opts;
|
|
431
431
|
let node = from || document.activeElement;
|
|
432
|
-
let walker = $
|
|
432
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
|
|
433
433
|
tabbable: tabbable
|
|
434
434
|
});
|
|
435
435
|
if (root.contains(node)) walker.currentNode = node;
|
|
@@ -438,7 +438,7 @@ function $81f01af19760c2bc$export$c5251b9e124bf29(ref) {
|
|
|
438
438
|
walker.currentNode = root;
|
|
439
439
|
nextNode = walker.nextNode();
|
|
440
440
|
}
|
|
441
|
-
if (nextNode) $
|
|
441
|
+
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
|
|
442
442
|
return nextNode;
|
|
443
443
|
},
|
|
444
444
|
focusPrevious (opts = {
|
|
@@ -446,48 +446,48 @@ function $81f01af19760c2bc$export$c5251b9e124bf29(ref) {
|
|
|
446
446
|
let root = ref.current;
|
|
447
447
|
let { from: from , tabbable: tabbable , wrap: wrap } = opts;
|
|
448
448
|
let node = from || document.activeElement;
|
|
449
|
-
let walker = $
|
|
449
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
|
|
450
450
|
tabbable: tabbable
|
|
451
451
|
});
|
|
452
452
|
if (root.contains(node)) walker.currentNode = node;
|
|
453
453
|
else {
|
|
454
|
-
let next = $
|
|
455
|
-
if (next) $
|
|
454
|
+
let next = $a7a032acae3ddda9$var$last(walker);
|
|
455
|
+
if (next) $a7a032acae3ddda9$var$focusElement(next, true);
|
|
456
456
|
return next;
|
|
457
457
|
}
|
|
458
458
|
let previousNode = walker.previousNode();
|
|
459
459
|
if (!previousNode && wrap) {
|
|
460
460
|
walker.currentNode = root;
|
|
461
|
-
previousNode = $
|
|
461
|
+
previousNode = $a7a032acae3ddda9$var$last(walker);
|
|
462
462
|
}
|
|
463
|
-
if (previousNode) $
|
|
463
|
+
if (previousNode) $a7a032acae3ddda9$var$focusElement(previousNode, true);
|
|
464
464
|
return previousNode;
|
|
465
465
|
},
|
|
466
466
|
focusFirst (opts = {
|
|
467
467
|
}) {
|
|
468
468
|
let root = ref.current;
|
|
469
469
|
let { tabbable: tabbable } = opts;
|
|
470
|
-
let walker = $
|
|
470
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
|
|
471
471
|
tabbable: tabbable
|
|
472
472
|
});
|
|
473
473
|
let nextNode = walker.nextNode();
|
|
474
|
-
if (nextNode) $
|
|
474
|
+
if (nextNode) $a7a032acae3ddda9$var$focusElement(nextNode, true);
|
|
475
475
|
return nextNode;
|
|
476
476
|
},
|
|
477
477
|
focusLast (opts = {
|
|
478
478
|
}) {
|
|
479
479
|
let root = ref.current;
|
|
480
480
|
let { tabbable: tabbable } = opts;
|
|
481
|
-
let walker = $
|
|
481
|
+
let walker = $a7a032acae3ddda9$export$2d6ec8fc375ceafa(root, {
|
|
482
482
|
tabbable: tabbable
|
|
483
483
|
});
|
|
484
|
-
let next = $
|
|
485
|
-
if (next) $
|
|
484
|
+
let next = $a7a032acae3ddda9$var$last(walker);
|
|
485
|
+
if (next) $a7a032acae3ddda9$var$focusElement(next, true);
|
|
486
486
|
return next;
|
|
487
487
|
}
|
|
488
488
|
};
|
|
489
489
|
}
|
|
490
|
-
function $
|
|
490
|
+
function $a7a032acae3ddda9$var$last(walker) {
|
|
491
491
|
let next;
|
|
492
492
|
let last;
|
|
493
493
|
do {
|
|
@@ -498,27 +498,27 @@ function $81f01af19760c2bc$var$last(walker) {
|
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
|
|
501
|
-
var $
|
|
501
|
+
var $dfd8c70b928eb1b3$exports = {};
|
|
502
502
|
|
|
503
|
-
$parcel$export($
|
|
503
|
+
$parcel$export($dfd8c70b928eb1b3$exports, "FocusRing", () => $dfd8c70b928eb1b3$export$1a38b4ad7f578e1d);
|
|
504
504
|
|
|
505
505
|
|
|
506
506
|
|
|
507
|
-
var $
|
|
507
|
+
var $581a96d6eb128c1b$exports = {};
|
|
508
508
|
|
|
509
|
-
$parcel$export($
|
|
509
|
+
$parcel$export($581a96d6eb128c1b$exports, "useFocusRing", () => $581a96d6eb128c1b$export$4e328f61c538687f);
|
|
510
510
|
|
|
511
511
|
|
|
512
512
|
|
|
513
|
-
function $
|
|
513
|
+
function $581a96d6eb128c1b$export$4e328f61c538687f(props = {
|
|
514
514
|
}) {
|
|
515
515
|
let { autoFocus: autoFocus = false , isTextInput: isTextInput , within: within } = props;
|
|
516
|
-
let state = $
|
|
516
|
+
let state = $aB6Cp$react.useRef({
|
|
517
517
|
isFocused: false,
|
|
518
|
-
isFocusVisible: autoFocus || $
|
|
518
|
+
isFocusVisible: autoFocus || $aB6Cp$reactariainteractions.isFocusVisible()
|
|
519
519
|
}).current;
|
|
520
|
-
let [isFocused1, setFocused] = $
|
|
521
|
-
let [isFocusVisibleState, setFocusVisible] = $
|
|
520
|
+
let [isFocused1, setFocused] = $aB6Cp$react.useState(false);
|
|
521
|
+
let [isFocusVisibleState, setFocusVisible] = $aB6Cp$react.useState(()=>state.isFocused && state.isFocusVisible
|
|
522
522
|
);
|
|
523
523
|
let updateState = ()=>setFocusVisible(state.isFocused && state.isFocusVisible)
|
|
524
524
|
;
|
|
@@ -527,17 +527,17 @@ function $0c85563baefded4a$export$4e328f61c538687f(props = {
|
|
|
527
527
|
setFocused(isFocused);
|
|
528
528
|
updateState();
|
|
529
529
|
};
|
|
530
|
-
$
|
|
530
|
+
$aB6Cp$reactariainteractions.useFocusVisibleListener((isFocusVisible)=>{
|
|
531
531
|
state.isFocusVisible = isFocusVisible;
|
|
532
532
|
updateState();
|
|
533
533
|
}, [], {
|
|
534
534
|
isTextInput: isTextInput
|
|
535
535
|
});
|
|
536
|
-
let { focusProps: focusProps } = $
|
|
536
|
+
let { focusProps: focusProps } = $aB6Cp$reactariainteractions.useFocus({
|
|
537
537
|
isDisabled: within,
|
|
538
538
|
onFocusChange: onFocusChange
|
|
539
539
|
});
|
|
540
|
-
let { focusWithinProps: focusWithinProps } = $
|
|
540
|
+
let { focusWithinProps: focusWithinProps } = $aB6Cp$reactariainteractions.useFocusWithin({
|
|
541
541
|
isDisabled: !within,
|
|
542
542
|
onFocusWithinChange: onFocusChange
|
|
543
543
|
});
|
|
@@ -549,13 +549,13 @@ function $0c85563baefded4a$export$4e328f61c538687f(props = {
|
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
|
|
552
|
-
function $
|
|
552
|
+
function $dfd8c70b928eb1b3$export$1a38b4ad7f578e1d(props) {
|
|
553
553
|
let { children: children , focusClass: focusClass , focusRingClass: focusRingClass } = props;
|
|
554
|
-
let { isFocused: isFocused , isFocusVisible: isFocusVisible , focusProps: focusProps } = $
|
|
555
|
-
let child = ($parcel$interopDefault($
|
|
556
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
554
|
+
let { isFocused: isFocused , isFocusVisible: isFocusVisible , focusProps: focusProps } = $581a96d6eb128c1b$export$4e328f61c538687f(props);
|
|
555
|
+
let child = ($parcel$interopDefault($aB6Cp$react)).Children.only(children);
|
|
556
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).cloneElement(child, $aB6Cp$reactariautils.mergeProps(child.props, {
|
|
557
557
|
...focusProps,
|
|
558
|
-
className: ($parcel$interopDefault($
|
|
558
|
+
className: ($parcel$interopDefault($aB6Cp$clsx))({
|
|
559
559
|
[focusClass || '']: isFocused,
|
|
560
560
|
[focusRingClass || '']: isFocusVisible
|
|
561
561
|
})
|
|
@@ -563,49 +563,49 @@ function $b69c3d2bb4e1879d$export$1a38b4ad7f578e1d(props) {
|
|
|
563
563
|
}
|
|
564
564
|
|
|
565
565
|
|
|
566
|
-
var $
|
|
566
|
+
var $fb504d83237fd6ac$exports = {};
|
|
567
567
|
|
|
568
|
-
$parcel$export($
|
|
569
|
-
$parcel$export($
|
|
568
|
+
$parcel$export($fb504d83237fd6ac$exports, "FocusableProvider", () => $fb504d83237fd6ac$export$13f3202a3e5ddd5);
|
|
569
|
+
$parcel$export($fb504d83237fd6ac$exports, "useFocusable", () => $fb504d83237fd6ac$export$4c014de7c8940b4c);
|
|
570
570
|
|
|
571
571
|
|
|
572
572
|
|
|
573
|
-
let $
|
|
574
|
-
function $
|
|
575
|
-
let context = $
|
|
573
|
+
let $fb504d83237fd6ac$var$FocusableContext = /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createContext(null);
|
|
574
|
+
function $fb504d83237fd6ac$var$useFocusableContext(ref) {
|
|
575
|
+
let context = $aB6Cp$react.useContext($fb504d83237fd6ac$var$FocusableContext) || {
|
|
576
576
|
};
|
|
577
|
-
$
|
|
577
|
+
$aB6Cp$reactariautils.useSyncRef(context, ref);
|
|
578
578
|
// eslint-disable-next-line
|
|
579
579
|
let { ref: _ , ...otherProps } = context;
|
|
580
580
|
return otherProps;
|
|
581
581
|
}
|
|
582
582
|
/**
|
|
583
583
|
* Provides DOM props to the nearest focusable child.
|
|
584
|
-
*/ function $
|
|
584
|
+
*/ function $fb504d83237fd6ac$var$FocusableProvider(props, ref) {
|
|
585
585
|
let { children: children , ...otherProps } = props;
|
|
586
586
|
let context = {
|
|
587
587
|
...otherProps,
|
|
588
588
|
ref: ref
|
|
589
589
|
};
|
|
590
|
-
return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
590
|
+
return(/*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).createElement($fb504d83237fd6ac$var$FocusableContext.Provider, {
|
|
591
591
|
value: context
|
|
592
592
|
}, children));
|
|
593
593
|
}
|
|
594
|
-
let $
|
|
595
|
-
function $
|
|
596
|
-
let { focusProps: focusProps } = $
|
|
597
|
-
let { keyboardProps: keyboardProps } = $
|
|
598
|
-
let interactions = $
|
|
599
|
-
let domProps = $
|
|
594
|
+
let $fb504d83237fd6ac$export$13f3202a3e5ddd5 = /*#__PURE__*/ ($parcel$interopDefault($aB6Cp$react)).forwardRef($fb504d83237fd6ac$var$FocusableProvider);
|
|
595
|
+
function $fb504d83237fd6ac$export$4c014de7c8940b4c(props, domRef) {
|
|
596
|
+
let { focusProps: focusProps } = $aB6Cp$reactariainteractions.useFocus(props);
|
|
597
|
+
let { keyboardProps: keyboardProps } = $aB6Cp$reactariainteractions.useKeyboard(props);
|
|
598
|
+
let interactions = $aB6Cp$reactariautils.mergeProps(focusProps, keyboardProps);
|
|
599
|
+
let domProps = $fb504d83237fd6ac$var$useFocusableContext(domRef);
|
|
600
600
|
let interactionProps = props.isDisabled ? {
|
|
601
601
|
} : domProps;
|
|
602
|
-
let autoFocusRef = $
|
|
603
|
-
$
|
|
602
|
+
let autoFocusRef = $aB6Cp$react.useRef(props.autoFocus);
|
|
603
|
+
$aB6Cp$react.useEffect(()=>{
|
|
604
604
|
if (autoFocusRef.current && domRef.current) domRef.current.focus();
|
|
605
605
|
autoFocusRef.current = false;
|
|
606
606
|
}, []);
|
|
607
607
|
return {
|
|
608
|
-
focusableProps: $
|
|
608
|
+
focusableProps: $aB6Cp$reactariautils.mergeProps({
|
|
609
609
|
...interactions,
|
|
610
610
|
tabIndex: props.excludeFromTabOrder && !props.isDisabled ? -1 : undefined
|
|
611
611
|
}, interactionProps)
|
|
@@ -615,11 +615,11 @@ function $a6d2890e204970f2$export$4c014de7c8940b4c(props, domRef) {
|
|
|
615
615
|
|
|
616
616
|
|
|
617
617
|
|
|
618
|
-
$parcel$exportWildcard(module.exports, $
|
|
619
|
-
$parcel$exportWildcard(module.exports, $
|
|
620
|
-
$parcel$exportWildcard(module.exports, $
|
|
621
|
-
$parcel$exportWildcard(module.exports, $
|
|
622
|
-
$parcel$exportWildcard(module.exports, $
|
|
618
|
+
$parcel$exportWildcard(module.exports, $a7a032acae3ddda9$exports);
|
|
619
|
+
$parcel$exportWildcard(module.exports, $dfd8c70b928eb1b3$exports);
|
|
620
|
+
$parcel$exportWildcard(module.exports, $fb504d83237fd6ac$exports);
|
|
621
|
+
$parcel$exportWildcard(module.exports, $581a96d6eb128c1b$exports);
|
|
622
|
+
$parcel$exportWildcard(module.exports, $1c7f9157d722357d$exports);
|
|
623
623
|
|
|
624
624
|
|
|
625
625
|
//# sourceMappingURL=main.js.map
|