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