@react-aria/interactions 3.26.0 → 3.27.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/PressResponder.main.js +2 -3
- package/dist/PressResponder.main.js.map +1 -1
- package/dist/PressResponder.mjs +3 -4
- package/dist/PressResponder.module.js +3 -4
- package/dist/PressResponder.module.js.map +1 -1
- package/dist/focusSafely.main.js +1 -0
- package/dist/focusSafely.main.js.map +1 -1
- package/dist/focusSafely.mjs +1 -0
- package/dist/focusSafely.module.js +1 -0
- package/dist/focusSafely.module.js.map +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useFocus.main.js +4 -3
- package/dist/useFocus.main.js.map +1 -1
- package/dist/useFocus.mjs +5 -4
- package/dist/useFocus.module.js +5 -4
- package/dist/useFocus.module.js.map +1 -1
- package/dist/useFocusVisible.main.js +16 -13
- package/dist/useFocusVisible.main.js.map +1 -1
- package/dist/useFocusVisible.mjs +18 -15
- package/dist/useFocusVisible.module.js +18 -15
- package/dist/useFocusVisible.module.js.map +1 -1
- package/dist/useFocusWithin.main.js +9 -7
- package/dist/useFocusWithin.main.js.map +1 -1
- package/dist/useFocusWithin.mjs +10 -8
- package/dist/useFocusWithin.module.js +10 -8
- package/dist/useFocusWithin.module.js.map +1 -1
- package/dist/useHover.main.js +5 -5
- package/dist/useHover.main.js.map +1 -1
- package/dist/useHover.mjs +6 -6
- package/dist/useHover.module.js +6 -6
- package/dist/useHover.module.js.map +1 -1
- package/dist/useInteractOutside.main.js +5 -4
- package/dist/useInteractOutside.main.js.map +1 -1
- package/dist/useInteractOutside.mjs +6 -5
- package/dist/useInteractOutside.module.js +6 -5
- package/dist/useInteractOutside.module.js.map +1 -1
- package/dist/usePress.main.js +31 -23
- package/dist/usePress.main.js.map +1 -1
- package/dist/usePress.mjs +31 -23
- package/dist/usePress.module.js +31 -23
- package/dist/usePress.module.js.map +1 -1
- package/dist/utils.main.js +8 -7
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +9 -8
- package/dist/utils.module.js +9 -8
- package/dist/utils.module.js.map +1 -1
- package/package.json +4 -4
- package/src/PressResponder.tsx +3 -4
- package/src/focusSafely.ts +4 -0
- package/src/index.ts +1 -1
- package/src/useFocus.ts +4 -3
- package/src/useFocusVisible.ts +18 -12
- package/src/useFocusWithin.ts +9 -7
- package/src/useHover.ts +6 -6
- package/src/useInteractOutside.ts +6 -5
- package/src/usePress.ts +46 -32
- package/src/utils.ts +12 -11
|
@@ -29,16 +29,15 @@ $parcel$export(module.exports, "ClearPressResponder", () => $3596bae48579386f$ex
|
|
|
29
29
|
const $3596bae48579386f$export$3351871ee4b288b8 = /*#__PURE__*/ (0, ($parcel$interopDefault($3maub$react))).forwardRef(({ children: children, ...props }, ref)=>{
|
|
30
30
|
let isRegistered = (0, $3maub$react.useRef)(false);
|
|
31
31
|
let prevContext = (0, $3maub$react.useContext)((0, $01d3f539e91688c8$exports.PressResponderContext));
|
|
32
|
-
ref = (0, $3maub$reactariautils.useObjectRef)(ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref));
|
|
33
32
|
let context = (0, $3maub$reactariautils.mergeProps)(prevContext || {}, {
|
|
34
33
|
...props,
|
|
35
|
-
ref: ref,
|
|
36
34
|
register () {
|
|
37
35
|
isRegistered.current = true;
|
|
38
36
|
if (prevContext) prevContext.register();
|
|
39
37
|
}
|
|
40
38
|
});
|
|
41
|
-
(0, $3maub$reactariautils.
|
|
39
|
+
context.ref = (0, $3maub$reactariautils.useObjectRef)(ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref));
|
|
40
|
+
(0, $3maub$reactariautils.useSyncRef)(prevContext, context.ref);
|
|
42
41
|
(0, $3maub$react.useEffect)(()=>{
|
|
43
42
|
if (!isRegistered.current) {
|
|
44
43
|
if (process.env.NODE_ENV !== 'production') console.warn("A PressResponder was rendered without a pressable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,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;YAAC,UAAU,KAAO;QAAC,CAAA,GAAI,EAAE;IACtD,qBACE,0DAAC,CAAA,GAAA,+CAAoB,EAAE,QAAQ;QAAC,OAAO;OACpC;AAGP","sources":["packages/@react-aria/interactions/src/PressResponder.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {mergeProps, useObjectRef, useSyncRef} from '@react-aria/utils';\nimport {PressProps} from './usePress';\nimport {PressResponderContext} from './context';\nimport React, {ForwardedRef, JSX, ReactNode, useContext, useEffect, useMemo, useRef} from 'react';\n\ninterface PressResponderProps extends PressProps {\n children: ReactNode\n}\n\nexport const PressResponder:\n React.ForwardRefExoticComponent<PressResponderProps & React.RefAttributes<FocusableElement>> =\nReact.forwardRef(({children, ...props}: PressResponderProps, ref: ForwardedRef<FocusableElement>) => {\n let isRegistered = useRef(false);\n let prevContext = useContext(PressResponderContext);\n let context: any = mergeProps(prevContext || {}, {\n ...props,\n register() {\n isRegistered.current = true;\n if (prevContext) {\n prevContext.register();\n }\n }\n });\n\n context.ref = useObjectRef(ref || prevContext?.ref);\n useSyncRef(prevContext, context.ref);\n\n useEffect(() => {\n if (!isRegistered.current) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n 'A PressResponder was rendered without a pressable child. ' +\n 'Either call the usePress hook, or wrap your DOM node with <Pressable> component.'\n );\n }\n isRegistered.current = true; // only warn once in strict mode.\n }\n }, []);\n\n return (\n <PressResponderContext.Provider value={context}>\n {children}\n </PressResponderContext.Provider>\n );\n});\n\nexport function ClearPressResponder({children}: {children: ReactNode}): JSX.Element {\n let context = useMemo(() => ({register: () => {}}), []);\n return (\n <PressResponderContext.Provider value={context}>\n {children}\n </PressResponderContext.Provider>\n );\n}\n"],"names":[],"version":3,"file":"PressResponder.main.js.map"}
|
package/dist/PressResponder.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {PressResponderContext as $ae1eeba8b9eafd08$export$5165eccb35aaadb5} from "./context.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import {mergeProps as $87RPk$mergeProps, useObjectRef as $87RPk$useObjectRef, useSyncRef as $87RPk$useSyncRef} from "@react-aria/utils";
|
|
3
3
|
import $87RPk$react, {useRef as $87RPk$useRef, useContext as $87RPk$useContext, useEffect as $87RPk$useEffect, useMemo as $87RPk$useMemo} from "react";
|
|
4
4
|
|
|
5
5
|
/*
|
|
@@ -18,16 +18,15 @@ import $87RPk$react, {useRef as $87RPk$useRef, useContext as $87RPk$useContext,
|
|
|
18
18
|
const $f1ab8c75478c6f73$export$3351871ee4b288b8 = /*#__PURE__*/ (0, $87RPk$react).forwardRef(({ children: children, ...props }, ref)=>{
|
|
19
19
|
let isRegistered = (0, $87RPk$useRef)(false);
|
|
20
20
|
let prevContext = (0, $87RPk$useContext)((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5));
|
|
21
|
-
ref = (0, $87RPk$useObjectRef)(ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref));
|
|
22
21
|
let context = (0, $87RPk$mergeProps)(prevContext || {}, {
|
|
23
22
|
...props,
|
|
24
|
-
ref: ref,
|
|
25
23
|
register () {
|
|
26
24
|
isRegistered.current = true;
|
|
27
25
|
if (prevContext) prevContext.register();
|
|
28
26
|
}
|
|
29
27
|
});
|
|
30
|
-
(0, $87RPk$
|
|
28
|
+
context.ref = (0, $87RPk$useObjectRef)(ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref));
|
|
29
|
+
(0, $87RPk$useSyncRef)(prevContext, context.ref);
|
|
31
30
|
(0, $87RPk$useEffect)(()=>{
|
|
32
31
|
if (!isRegistered.current) {
|
|
33
32
|
if (process.env.NODE_ENV !== 'production') console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component.");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {PressResponderContext as $ae1eeba8b9eafd08$export$5165eccb35aaadb5} from "./context.module.js";
|
|
2
|
-
import {
|
|
2
|
+
import {mergeProps as $87RPk$mergeProps, useObjectRef as $87RPk$useObjectRef, useSyncRef as $87RPk$useSyncRef} from "@react-aria/utils";
|
|
3
3
|
import $87RPk$react, {useRef as $87RPk$useRef, useContext as $87RPk$useContext, useEffect as $87RPk$useEffect, useMemo as $87RPk$useMemo} from "react";
|
|
4
4
|
|
|
5
5
|
/*
|
|
@@ -18,16 +18,15 @@ import $87RPk$react, {useRef as $87RPk$useRef, useContext as $87RPk$useContext,
|
|
|
18
18
|
const $f1ab8c75478c6f73$export$3351871ee4b288b8 = /*#__PURE__*/ (0, $87RPk$react).forwardRef(({ children: children, ...props }, ref)=>{
|
|
19
19
|
let isRegistered = (0, $87RPk$useRef)(false);
|
|
20
20
|
let prevContext = (0, $87RPk$useContext)((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5));
|
|
21
|
-
ref = (0, $87RPk$useObjectRef)(ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref));
|
|
22
21
|
let context = (0, $87RPk$mergeProps)(prevContext || {}, {
|
|
23
22
|
...props,
|
|
24
|
-
ref: ref,
|
|
25
23
|
register () {
|
|
26
24
|
isRegistered.current = true;
|
|
27
25
|
if (prevContext) prevContext.register();
|
|
28
26
|
}
|
|
29
27
|
});
|
|
30
|
-
(0, $87RPk$
|
|
28
|
+
context.ref = (0, $87RPk$useObjectRef)(ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref));
|
|
29
|
+
(0, $87RPk$useSyncRef)(prevContext, context.ref);
|
|
31
30
|
(0, $87RPk$useEffect)(()=>{
|
|
32
31
|
if (!isRegistered.current) {
|
|
33
32
|
if (process.env.NODE_ENV !== 'production') console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAYM,MAAM,0DAEb,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,CAAC,YAAC,QAAQ,EAAE,GAAG,OAA2B,EAAE;IAC3D,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAC1B,IAAI,cAAc,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAoB;IACjD,
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAYM,MAAM,0DAEb,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,CAAC,YAAC,QAAQ,EAAE,GAAG,OAA2B,EAAE;IAC3D,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAC1B,IAAI,cAAc,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAoB;IACjD,IAAI,UAAe,CAAA,GAAA,iBAAS,EAAE,eAAe,CAAC,GAAG;QAC/C,GAAG,KAAK;QACR;YACE,aAAa,OAAO,GAAG;YACvB,IAAI,aACF,YAAY,QAAQ;QAExB;IACF;IAEA,QAAQ,GAAG,GAAG,CAAA,GAAA,mBAAW,EAAE,QAAO,wBAAA,kCAAA,YAAa,GAAG;IAClD,CAAA,GAAA,iBAAS,EAAE,aAAa,QAAQ,GAAG;IAEnC,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,CAAC,aAAa,OAAO,EAAE;YACzB,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAC3B,QAAQ,IAAI,CACV;YAIJ,aAAa,OAAO,GAAG,MAAM,iCAAiC;QAChE;IACF,GAAG,EAAE;IAEL,qBACE,gCAAC,CAAA,GAAA,yCAAoB,EAAE,QAAQ;QAAC,OAAO;OACpC;AAGP;AAEO,SAAS,0CAAoB,YAAC,QAAQ,EAAwB;IACnE,IAAI,UAAU,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;YAAC,UAAU,KAAO;QAAC,CAAA,GAAI,EAAE;IACtD,qBACE,gCAAC,CAAA,GAAA,yCAAoB,EAAE,QAAQ;QAAC,OAAO;OACpC;AAGP","sources":["packages/@react-aria/interactions/src/PressResponder.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {mergeProps, useObjectRef, useSyncRef} from '@react-aria/utils';\nimport {PressProps} from './usePress';\nimport {PressResponderContext} from './context';\nimport React, {ForwardedRef, JSX, ReactNode, useContext, useEffect, useMemo, useRef} from 'react';\n\ninterface PressResponderProps extends PressProps {\n children: ReactNode\n}\n\nexport const PressResponder:\n React.ForwardRefExoticComponent<PressResponderProps & React.RefAttributes<FocusableElement>> =\nReact.forwardRef(({children, ...props}: PressResponderProps, ref: ForwardedRef<FocusableElement>) => {\n let isRegistered = useRef(false);\n let prevContext = useContext(PressResponderContext);\n let context: any = mergeProps(prevContext || {}, {\n ...props,\n register() {\n isRegistered.current = true;\n if (prevContext) {\n prevContext.register();\n }\n }\n });\n\n context.ref = useObjectRef(ref || prevContext?.ref);\n useSyncRef(prevContext, context.ref);\n\n useEffect(() => {\n if (!isRegistered.current) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n 'A PressResponder was rendered without a pressable child. ' +\n 'Either call the usePress hook, or wrap your DOM node with <Pressable> component.'\n );\n }\n isRegistered.current = true; // only warn once in strict mode.\n }\n }, []);\n\n return (\n <PressResponderContext.Provider value={context}>\n {children}\n </PressResponderContext.Provider>\n );\n});\n\nexport function ClearPressResponder({children}: {children: ReactNode}): JSX.Element {\n let context = useMemo(() => ({register: () => {}}), []);\n return (\n <PressResponderContext.Provider value={context}>\n {children}\n </PressResponderContext.Provider>\n );\n}\n"],"names":[],"version":3,"file":"PressResponder.module.js.map"}
|
package/dist/focusSafely.main.js
CHANGED
|
@@ -20,6 +20,7 @@ $parcel$export(module.exports, "focusSafely", () => $2833058fcd3993f5$export$80f
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
function $2833058fcd3993f5$export$80f3e147d781571c(element) {
|
|
23
|
+
if (!element.isConnected) return;
|
|
23
24
|
// If the user is interacting with a virtual cursor, e.g. screen reader, then
|
|
24
25
|
// wait until after any animated transitions that are currently occurring on
|
|
25
26
|
// the page before shifting focus. This avoids issues with VoiceOver on iOS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAeM,SAAS,0CAAY,OAAyB;IACnD,6EAA6E;IAC7E,4EAA4E;IAC5E,2EAA2E;IAC3E,+EAA+E;IAC/E,uBAAuB;IACvB,MAAM,gBAAgB,CAAA,GAAA,sCAAe,EAAE;IACvC,IAAI,CAAA,GAAA,gDAAqB,QAAQ,WAAW;QAC1C,IAAI,qBAAqB,CAAA,GAAA,sCAAe,EAAE;QAC1C,CAAA,GAAA,wCAAiB,EAAE;YACjB,MAAM,gBAAgB,CAAA,GAAA,sCAAe,EAAE;YACvC,2GAA2G;YAC3G,IAAI,AAAC,CAAA,kBAAkB,sBAAsB,kBAAkB,cAAc,IAAI,AAAD,KAAM,QAAQ,WAAW,EACvG,CAAA,GAAA,2CAAoB,EAAE;QAE1B;IACF,OACE,CAAA,GAAA,2CAAoB,EAAE;AAE1B","sources":["packages/@react-aria/interactions/src/focusSafely.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the 'License');\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {\n focusWithoutScrolling,\n getActiveElement,\n getOwnerDocument,\n runAfterTransition\n} from '@react-aria/utils';\nimport {getInteractionModality} from './useFocusVisible';\n\n/**\n * A utility function that focuses an element while avoiding undesired side effects such\n * as page scrolling and screen reader issues with CSS transitions.\n */\nexport function focusSafely(element: FocusableElement): void {\n // If the user is interacting with a virtual cursor, e.g. screen reader, then\n // wait until after any animated transitions that are currently occurring on\n // the page before shifting focus. This avoids issues with VoiceOver on iOS\n // causing the page to scroll when moving focus if the element is transitioning\n // from off the screen.\n const ownerDocument = getOwnerDocument(element);\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = getActiveElement(ownerDocument);\n runAfterTransition(() => {\n const activeElement = getActiveElement(ownerDocument);\n // If focus did not move or focus was lost to the body, and the element is still in the document, focus it.\n if ((activeElement === lastFocusedElement || activeElement === ownerDocument.body) && element.isConnected) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n"],"names":[],"version":3,"file":"focusSafely.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAeM,SAAS,0CAAY,OAAyB;IACnD,IAAI,CAAC,QAAQ,WAAW,EACtB;IAGF,6EAA6E;IAC7E,4EAA4E;IAC5E,2EAA2E;IAC3E,+EAA+E;IAC/E,uBAAuB;IACvB,MAAM,gBAAgB,CAAA,GAAA,sCAAe,EAAE;IACvC,IAAI,CAAA,GAAA,gDAAqB,QAAQ,WAAW;QAC1C,IAAI,qBAAqB,CAAA,GAAA,sCAAe,EAAE;QAC1C,CAAA,GAAA,wCAAiB,EAAE;YACjB,MAAM,gBAAgB,CAAA,GAAA,sCAAe,EAAE;YACvC,2GAA2G;YAC3G,IAAI,AAAC,CAAA,kBAAkB,sBAAsB,kBAAkB,cAAc,IAAI,AAAD,KAAM,QAAQ,WAAW,EACvG,CAAA,GAAA,2CAAoB,EAAE;QAE1B;IACF,OACE,CAAA,GAAA,2CAAoB,EAAE;AAE1B","sources":["packages/@react-aria/interactions/src/focusSafely.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the 'License');\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {\n focusWithoutScrolling,\n getActiveElement,\n getOwnerDocument,\n runAfterTransition\n} from '@react-aria/utils';\nimport {getInteractionModality} from './useFocusVisible';\n\n/**\n * A utility function that focuses an element while avoiding undesired side effects such\n * as page scrolling and screen reader issues with CSS transitions.\n */\nexport function focusSafely(element: FocusableElement): void {\n if (!element.isConnected) {\n return;\n }\n\n // If the user is interacting with a virtual cursor, e.g. screen reader, then\n // wait until after any animated transitions that are currently occurring on\n // the page before shifting focus. This avoids issues with VoiceOver on iOS\n // causing the page to scroll when moving focus if the element is transitioning\n // from off the screen.\n const ownerDocument = getOwnerDocument(element);\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = getActiveElement(ownerDocument);\n runAfterTransition(() => {\n const activeElement = getActiveElement(ownerDocument);\n // If focus did not move or focus was lost to the body, and the element is still in the document, focus it.\n if ((activeElement === lastFocusedElement || activeElement === ownerDocument.body) && element.isConnected) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n"],"names":[],"version":3,"file":"focusSafely.main.js.map"}
|
package/dist/focusSafely.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import {getOwnerDocument as $k50bp$getOwnerDocument, getActiveElement as $k50bp$
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
function $3ad3f6e1647bc98d$export$80f3e147d781571c(element) {
|
|
17
|
+
if (!element.isConnected) return;
|
|
17
18
|
// If the user is interacting with a virtual cursor, e.g. screen reader, then
|
|
18
19
|
// wait until after any animated transitions that are currently occurring on
|
|
19
20
|
// the page before shifting focus. This avoids issues with VoiceOver on iOS
|
|
@@ -14,6 +14,7 @@ import {getOwnerDocument as $k50bp$getOwnerDocument, getActiveElement as $k50bp$
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
function $3ad3f6e1647bc98d$export$80f3e147d781571c(element) {
|
|
17
|
+
if (!element.isConnected) return;
|
|
17
18
|
// If the user is interacting with a virtual cursor, e.g. screen reader, then
|
|
18
19
|
// wait until after any animated transitions that are currently occurring on
|
|
19
20
|
// the page before shifting focus. This avoids issues with VoiceOver on iOS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAeM,SAAS,0CAAY,OAAyB;IACnD,6EAA6E;IAC7E,4EAA4E;IAC5E,2EAA2E;IAC3E,+EAA+E;IAC/E,uBAAuB;IACvB,MAAM,gBAAgB,CAAA,GAAA,uBAAe,EAAE;IACvC,IAAI,CAAA,GAAA,yCAAqB,QAAQ,WAAW;QAC1C,IAAI,qBAAqB,CAAA,GAAA,uBAAe,EAAE;QAC1C,CAAA,GAAA,yBAAiB,EAAE;YACjB,MAAM,gBAAgB,CAAA,GAAA,uBAAe,EAAE;YACvC,2GAA2G;YAC3G,IAAI,AAAC,CAAA,kBAAkB,sBAAsB,kBAAkB,cAAc,IAAI,AAAD,KAAM,QAAQ,WAAW,EACvG,CAAA,GAAA,4BAAoB,EAAE;QAE1B;IACF,OACE,CAAA,GAAA,4BAAoB,EAAE;AAE1B","sources":["packages/@react-aria/interactions/src/focusSafely.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the 'License');\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {\n focusWithoutScrolling,\n getActiveElement,\n getOwnerDocument,\n runAfterTransition\n} from '@react-aria/utils';\nimport {getInteractionModality} from './useFocusVisible';\n\n/**\n * A utility function that focuses an element while avoiding undesired side effects such\n * as page scrolling and screen reader issues with CSS transitions.\n */\nexport function focusSafely(element: FocusableElement): void {\n // If the user is interacting with a virtual cursor, e.g. screen reader, then\n // wait until after any animated transitions that are currently occurring on\n // the page before shifting focus. This avoids issues with VoiceOver on iOS\n // causing the page to scroll when moving focus if the element is transitioning\n // from off the screen.\n const ownerDocument = getOwnerDocument(element);\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = getActiveElement(ownerDocument);\n runAfterTransition(() => {\n const activeElement = getActiveElement(ownerDocument);\n // If focus did not move or focus was lost to the body, and the element is still in the document, focus it.\n if ((activeElement === lastFocusedElement || activeElement === ownerDocument.body) && element.isConnected) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n"],"names":[],"version":3,"file":"focusSafely.module.js.map"}
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAeM,SAAS,0CAAY,OAAyB;IACnD,IAAI,CAAC,QAAQ,WAAW,EACtB;IAGF,6EAA6E;IAC7E,4EAA4E;IAC5E,2EAA2E;IAC3E,+EAA+E;IAC/E,uBAAuB;IACvB,MAAM,gBAAgB,CAAA,GAAA,uBAAe,EAAE;IACvC,IAAI,CAAA,GAAA,yCAAqB,QAAQ,WAAW;QAC1C,IAAI,qBAAqB,CAAA,GAAA,uBAAe,EAAE;QAC1C,CAAA,GAAA,yBAAiB,EAAE;YACjB,MAAM,gBAAgB,CAAA,GAAA,uBAAe,EAAE;YACvC,2GAA2G;YAC3G,IAAI,AAAC,CAAA,kBAAkB,sBAAsB,kBAAkB,cAAc,IAAI,AAAD,KAAM,QAAQ,WAAW,EACvG,CAAA,GAAA,4BAAoB,EAAE;QAE1B;IACF,OACE,CAAA,GAAA,4BAAoB,EAAE;AAE1B","sources":["packages/@react-aria/interactions/src/focusSafely.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the 'License');\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {\n focusWithoutScrolling,\n getActiveElement,\n getOwnerDocument,\n runAfterTransition\n} from '@react-aria/utils';\nimport {getInteractionModality} from './useFocusVisible';\n\n/**\n * A utility function that focuses an element while avoiding undesired side effects such\n * as page scrolling and screen reader issues with CSS transitions.\n */\nexport function focusSafely(element: FocusableElement): void {\n if (!element.isConnected) {\n return;\n }\n\n // If the user is interacting with a virtual cursor, e.g. screen reader, then\n // wait until after any animated transitions that are currently occurring on\n // the page before shifting focus. This avoids issues with VoiceOver on iOS\n // causing the page to scroll when moving focus if the element is transitioning\n // from off the screen.\n const ownerDocument = getOwnerDocument(element);\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = getActiveElement(ownerDocument);\n runAfterTransition(() => {\n const activeElement = getActiveElement(ownerDocument);\n // If focus did not move or focus was lost to the body, and the element is still in the document, focus it.\n if ((activeElement === lastFocusedElement || activeElement === ownerDocument.body) && element.isConnected) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n"],"names":[],"version":3,"file":"focusSafely.module.js.map"}
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/interactions/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {Pressable} from './Pressable';\nexport {PressResponder, ClearPressResponder} from './PressResponder';\nexport {useFocus} from './useFocus';\nexport {\n isFocusVisible,\n getInteractionModality,\n setInteractionModality,\n getPointerType,\n addWindowFocusTracking,\n useInteractionModality,\n useFocusVisible,\n useFocusVisibleListener\n} from './useFocusVisible';\nexport {useFocusWithin} from './useFocusWithin';\nexport {useHover} from './useHover';\nexport {useInteractOutside} from './useInteractOutside';\nexport {useKeyboard} from './useKeyboard';\nexport {useMove} from './useMove';\nexport {usePress} from './usePress';\nexport {useScrollWheel} from './useScrollWheel';\nexport {useLongPress} from './useLongPress';\nexport {useFocusable, FocusableProvider, Focusable, FocusableContext} from './useFocusable';\nexport {focusSafely} from './focusSafely';\n\nexport type {FocusProps, FocusResult} from './useFocus';\nexport type {FocusVisibleHandler, FocusVisibleProps, FocusVisibleResult, Modality} from './useFocusVisible';\nexport type {FocusWithinProps, FocusWithinResult} from './useFocusWithin';\nexport type {HoverProps, HoverResult} from './useHover';\nexport type {InteractOutsideProps} from './useInteractOutside';\nexport type {KeyboardProps, KeyboardResult} from './useKeyboard';\nexport type {PressProps, PressHookProps, PressResult} from './usePress';\nexport type {PressEvent, PressEvents, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents} from '@react-types/shared';\nexport type {MoveResult} from './useMove';\nexport type {LongPressProps, LongPressResult} from './useLongPress';\nexport type {ScrollWheelProps} from './useScrollWheel';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/interactions/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {Pressable} from './Pressable';\nexport {PressResponder, ClearPressResponder} from './PressResponder';\nexport {useFocus} from './useFocus';\nexport {\n isFocusVisible,\n getInteractionModality,\n setInteractionModality,\n getPointerType,\n addWindowFocusTracking,\n useInteractionModality,\n useFocusVisible,\n useFocusVisibleListener\n} from './useFocusVisible';\nexport {useFocusWithin} from './useFocusWithin';\nexport {useHover} from './useHover';\nexport {useInteractOutside} from './useInteractOutside';\nexport {useKeyboard} from './useKeyboard';\nexport {useMove} from './useMove';\nexport {usePress} from './usePress';\nexport {useScrollWheel} from './useScrollWheel';\nexport {useLongPress} from './useLongPress';\nexport {useFocusable, FocusableProvider, Focusable, FocusableContext} from './useFocusable';\nexport {focusSafely} from './focusSafely';\n\nexport type {FocusProps, FocusResult} from './useFocus';\nexport type {FocusVisibleHandler, FocusVisibleProps, FocusVisibleResult, Modality} from './useFocusVisible';\nexport type {FocusWithinProps, FocusWithinResult} from './useFocusWithin';\nexport type {HoverProps, HoverResult} from './useHover';\nexport type {InteractOutsideProps} from './useInteractOutside';\nexport type {KeyboardProps, KeyboardResult} from './useKeyboard';\nexport type {PressProps, PressHookProps, PressResult} from './usePress';\nexport type {PressEvent, PressEvents, LongPressEvent, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents} from '@react-types/shared';\nexport type {MoveResult} from './useMove';\nexport type {LongPressProps, LongPressResult} from './useLongPress';\nexport type {ScrollWheelProps} from './useScrollWheel';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/interactions/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {Pressable} from './Pressable';\nexport {PressResponder, ClearPressResponder} from './PressResponder';\nexport {useFocus} from './useFocus';\nexport {\n isFocusVisible,\n getInteractionModality,\n setInteractionModality,\n getPointerType,\n addWindowFocusTracking,\n useInteractionModality,\n useFocusVisible,\n useFocusVisibleListener\n} from './useFocusVisible';\nexport {useFocusWithin} from './useFocusWithin';\nexport {useHover} from './useHover';\nexport {useInteractOutside} from './useInteractOutside';\nexport {useKeyboard} from './useKeyboard';\nexport {useMove} from './useMove';\nexport {usePress} from './usePress';\nexport {useScrollWheel} from './useScrollWheel';\nexport {useLongPress} from './useLongPress';\nexport {useFocusable, FocusableProvider, Focusable, FocusableContext} from './useFocusable';\nexport {focusSafely} from './focusSafely';\n\nexport type {FocusProps, FocusResult} from './useFocus';\nexport type {FocusVisibleHandler, FocusVisibleProps, FocusVisibleResult, Modality} from './useFocusVisible';\nexport type {FocusWithinProps, FocusWithinResult} from './useFocusWithin';\nexport type {HoverProps, HoverResult} from './useHover';\nexport type {InteractOutsideProps} from './useInteractOutside';\nexport type {KeyboardProps, KeyboardResult} from './useKeyboard';\nexport type {PressProps, PressHookProps, PressResult} from './usePress';\nexport type {PressEvent, PressEvents, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents} from '@react-types/shared';\nexport type {MoveResult} from './useMove';\nexport type {LongPressProps, LongPressResult} from './useLongPress';\nexport type {ScrollWheelProps} from './useScrollWheel';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/interactions/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {Pressable} from './Pressable';\nexport {PressResponder, ClearPressResponder} from './PressResponder';\nexport {useFocus} from './useFocus';\nexport {\n isFocusVisible,\n getInteractionModality,\n setInteractionModality,\n getPointerType,\n addWindowFocusTracking,\n useInteractionModality,\n useFocusVisible,\n useFocusVisibleListener\n} from './useFocusVisible';\nexport {useFocusWithin} from './useFocusWithin';\nexport {useHover} from './useHover';\nexport {useInteractOutside} from './useInteractOutside';\nexport {useKeyboard} from './useKeyboard';\nexport {useMove} from './useMove';\nexport {usePress} from './usePress';\nexport {useScrollWheel} from './useScrollWheel';\nexport {useLongPress} from './useLongPress';\nexport {useFocusable, FocusableProvider, Focusable, FocusableContext} from './useFocusable';\nexport {focusSafely} from './focusSafely';\n\nexport type {FocusProps, FocusResult} from './useFocus';\nexport type {FocusVisibleHandler, FocusVisibleProps, FocusVisibleResult, Modality} from './useFocusVisible';\nexport type {FocusWithinProps, FocusWithinResult} from './useFocusWithin';\nexport type {HoverProps, HoverResult} from './useHover';\nexport type {InteractOutsideProps} from './useInteractOutside';\nexport type {KeyboardProps, KeyboardResult} from './useKeyboard';\nexport type {PressProps, PressHookProps, PressResult} from './usePress';\nexport type {PressEvent, PressEvents, LongPressEvent, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents} from '@react-types/shared';\nexport type {MoveResult} from './useMove';\nexport type {LongPressProps, LongPressResult} from './useLongPress';\nexport type {ScrollWheelProps} from './useScrollWheel';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -148,6 +148,7 @@ export function useFocusVisible(props?: FocusVisibleProps): FocusVisibleResult;
|
|
|
148
148
|
* Listens for trigger change and reports if focus is visible (i.e., modality is not pointer).
|
|
149
149
|
*/
|
|
150
150
|
export function useFocusVisibleListener(fn: FocusVisibleHandler, deps: ReadonlyArray<any>, opts?: {
|
|
151
|
+
enabled?: boolean;
|
|
151
152
|
isTextInput?: boolean;
|
|
152
153
|
}): void;
|
|
153
154
|
export interface FocusWithinProps {
|
|
@@ -249,6 +250,6 @@ export function useLongPress(props: LongPressProps): LongPressResult;
|
|
|
249
250
|
* as page scrolling and screen reader issues with CSS transitions.
|
|
250
251
|
*/
|
|
251
252
|
export function focusSafely(element: FocusableElement): void;
|
|
252
|
-
export type { PressEvent, PressEvents, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents } from '@react-types/shared';
|
|
253
|
+
export type { PressEvent, PressEvents, LongPressEvent, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents } from '@react-types/shared';
|
|
253
254
|
|
|
254
255
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AGyCA,2BAA4B,SAAQ,WAAW;IAC7C,+FAA+F;IAC/F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,yEAAyE;IACzE,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC;AAED,+BAAgC,SAAQ,UAAU;IAChD,mCAAmC;IACnC,GAAG,CAAC,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,CAAA;CAChC;
|
|
1
|
+
{"mappings":";;AGyCA,2BAA4B,SAAQ,WAAW;IAC7C,+FAA+F;IAC/F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,mBAAmB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CAAC;IACnB;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC;AAED;IACE,6CAA6C;IAC7C,cAAc,EAAE,aAAa,CAAA;CAC9B;AAID;;;GAGG;AACH,6BAA6B,KAAK,EAAE,cAAc,GAAG,eAAe,CA+EnE;ACjHD;;;GAGG;AACH,4BAA4B,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAuB3D;ACLD,YAAY,EAAC,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/utils.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/textSelection.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/context.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/usePress.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useFocus.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/createEventHandler.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useKeyboard.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useFocusable.tsx","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/Pressable.tsx","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/PressResponder.tsx","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useFocusVisible.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useFocusWithin.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useHover.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useInteractOutside.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useMove.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useScrollWheel.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/useLongPress.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/focusSafely.ts","packages/@react-aria/interactions/src/packages/@react-aria/interactions/src/index.ts","packages/@react-aria/interactions/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {Pressable} from './Pressable';\nexport {PressResponder, ClearPressResponder} from './PressResponder';\nexport {useFocus} from './useFocus';\nexport {\n isFocusVisible,\n getInteractionModality,\n setInteractionModality,\n getPointerType,\n addWindowFocusTracking,\n useInteractionModality,\n useFocusVisible,\n useFocusVisibleListener\n} from './useFocusVisible';\nexport {useFocusWithin} from './useFocusWithin';\nexport {useHover} from './useHover';\nexport {useInteractOutside} from './useInteractOutside';\nexport {useKeyboard} from './useKeyboard';\nexport {useMove} from './useMove';\nexport {usePress} from './usePress';\nexport {useScrollWheel} from './useScrollWheel';\nexport {useLongPress} from './useLongPress';\nexport {useFocusable, FocusableProvider, Focusable, FocusableContext} from './useFocusable';\nexport {focusSafely} from './focusSafely';\n\nexport type {FocusProps, FocusResult} from './useFocus';\nexport type {FocusVisibleHandler, FocusVisibleProps, FocusVisibleResult, Modality} from './useFocusVisible';\nexport type {FocusWithinProps, FocusWithinResult} from './useFocusWithin';\nexport type {HoverProps, HoverResult} from './useHover';\nexport type {InteractOutsideProps} from './useInteractOutside';\nexport type {KeyboardProps, KeyboardResult} from './useKeyboard';\nexport type {PressProps, PressHookProps, PressResult} from './usePress';\nexport type {PressEvent, PressEvents, LongPressEvent, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents} from '@react-types/shared';\nexport type {MoveResult} from './useMove';\nexport type {LongPressProps, LongPressResult} from './useLongPress';\nexport type {ScrollWheelProps} from './useScrollWheel';\nexport type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/dist/useFocus.main.js
CHANGED
|
@@ -28,7 +28,7 @@ $parcel$export(module.exports, "useFocus", () => $5cb73d0ce355b0dc$export$f8168d
|
|
|
28
28
|
function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
29
29
|
let { isDisabled: isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange: onFocusChange } = props;
|
|
30
30
|
const onBlur = (0, $hrHul$react.useCallback)((e)=>{
|
|
31
|
-
if (e
|
|
31
|
+
if ((0, $hrHul$reactariautils.getEventTarget)(e) === e.currentTarget) {
|
|
32
32
|
if (onBlurProp) onBlurProp(e);
|
|
33
33
|
if (onFocusChange) onFocusChange(false);
|
|
34
34
|
return true;
|
|
@@ -41,9 +41,10 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
|
41
41
|
const onFocus = (0, $hrHul$react.useCallback)((e)=>{
|
|
42
42
|
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
43
43
|
// focus handler already moved focus somewhere else.
|
|
44
|
-
|
|
44
|
+
let eventTarget = (0, $hrHul$reactariautils.getEventTarget)(e);
|
|
45
|
+
const ownerDocument = (0, $hrHul$reactariautils.getOwnerDocument)(eventTarget);
|
|
45
46
|
const activeElement = ownerDocument ? (0, $hrHul$reactariautils.getActiveElement)(ownerDocument) : (0, $hrHul$reactariautils.getActiveElement)();
|
|
46
|
-
if (
|
|
47
|
+
if (eventTarget === e.currentTarget && eventTarget === activeElement) {
|
|
47
48
|
if (onFocusProp) onFocusProp(e);
|
|
48
49
|
if (onFocusChange) onFocusChange(true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AAiB;IAEjD,OAAO;QACL,YAAY;YACV,SAAS,AAAC,CAAC,cAAe,CAAA,eAAe,iBAAiB,UAAS,IAAM,UAAU;YACnF,QAAQ,AAAC,CAAC,cAAe,CAAA,cAAc,aAAY,IAAM,SAAS;QACpE;IACF;AACF","sources":["packages/@react-aria/interactions/src/useFocus.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from react.\n// Original licensing for the following can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions\n\nimport {DOMAttributes, FocusableElement, FocusEvents} from '@react-types/shared';\nimport {FocusEvent, useCallback} from 'react';\nimport {getActiveElement, getEventTarget, getOwnerDocument} from '@react-aria/utils';\nimport {useSyntheticBlurEvent} from './utils';\n\nexport interface FocusProps<Target = FocusableElement> extends FocusEvents<Target> {\n /** Whether the focus events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface FocusResult<Target = FocusableElement> {\n /** Props to spread onto the target element. */\n focusProps: DOMAttributes<Target>\n}\n\n/**\n * Handles focus events for the immediate target.\n * Focus events on child elements will be ignored.\n */\nexport function useFocus<Target extends FocusableElement = FocusableElement>(props: FocusProps<Target>): FocusResult<Target> {\n let {\n isDisabled,\n onFocus: onFocusProp,\n onBlur: onBlurProp,\n onFocusChange\n } = props;\n\n const onBlur: FocusProps<Target>['onBlur'] = useCallback((e: FocusEvent<Target>) => {\n if (getEventTarget(e) === e.currentTarget) {\n if (onBlurProp) {\n onBlurProp(e);\n }\n\n if (onFocusChange) {\n onFocusChange(false);\n }\n\n return true;\n }\n }, [onBlurProp, onFocusChange]);\n\n\n const onSyntheticFocus = useSyntheticBlurEvent<Target>(onBlur);\n\n const onFocus: FocusProps<Target>['onFocus'] = useCallback((e: FocusEvent<Target>) => {\n // Double check that document.activeElement actually matches e.target in case a previously chained\n // focus handler already moved focus somewhere else.\n\n let eventTarget = getEventTarget(e);\n const ownerDocument = getOwnerDocument(eventTarget);\n const activeElement = ownerDocument ? getActiveElement(ownerDocument) : getActiveElement();\n if (eventTarget === e.currentTarget && eventTarget === activeElement) {\n if (onFocusProp) {\n onFocusProp(e);\n }\n\n if (onFocusChange) {\n onFocusChange(true);\n }\n\n onSyntheticFocus(e);\n }\n }, [onFocusChange, onFocusProp, onSyntheticFocus]);\n\n return {\n focusProps: {\n onFocus: (!isDisabled && (onFocusProp || onFocusChange || onBlurProp)) ? onFocus : undefined,\n onBlur: (!isDisabled && (onBlurProp || onFocusChange)) ? onBlur : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useFocus.main.js.map"}
|
package/dist/useFocus.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {useSyntheticBlurEvent as $8a9cb279dc87e130$export$715c682d09d639cc} from "./utils.mjs";
|
|
2
2
|
import {useCallback as $hf0lj$useCallback} from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {getEventTarget as $hf0lj$getEventTarget, getOwnerDocument as $hf0lj$getOwnerDocument, getActiveElement as $hf0lj$getActiveElement} from "@react-aria/utils";
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -22,7 +22,7 @@ import {getOwnerDocument as $hf0lj$getOwnerDocument, getActiveElement as $hf0lj$
|
|
|
22
22
|
function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
23
23
|
let { isDisabled: isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange: onFocusChange } = props;
|
|
24
24
|
const onBlur = (0, $hf0lj$useCallback)((e)=>{
|
|
25
|
-
if (e
|
|
25
|
+
if ((0, $hf0lj$getEventTarget)(e) === e.currentTarget) {
|
|
26
26
|
if (onBlurProp) onBlurProp(e);
|
|
27
27
|
if (onFocusChange) onFocusChange(false);
|
|
28
28
|
return true;
|
|
@@ -35,9 +35,10 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
35
35
|
const onFocus = (0, $hf0lj$useCallback)((e)=>{
|
|
36
36
|
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
37
37
|
// focus handler already moved focus somewhere else.
|
|
38
|
-
|
|
38
|
+
let eventTarget = (0, $hf0lj$getEventTarget)(e);
|
|
39
|
+
const ownerDocument = (0, $hf0lj$getOwnerDocument)(eventTarget);
|
|
39
40
|
const activeElement = ownerDocument ? (0, $hf0lj$getActiveElement)(ownerDocument) : (0, $hf0lj$getActiveElement)();
|
|
40
|
-
if (
|
|
41
|
+
if (eventTarget === e.currentTarget && eventTarget === activeElement) {
|
|
41
42
|
if (onFocusProp) onFocusProp(e);
|
|
42
43
|
if (onFocusChange) onFocusChange(true);
|
|
43
44
|
onSyntheticFocus(e);
|
package/dist/useFocus.module.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {useSyntheticBlurEvent as $8a9cb279dc87e130$export$715c682d09d639cc} from "./utils.module.js";
|
|
2
2
|
import {useCallback as $hf0lj$useCallback} from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {getEventTarget as $hf0lj$getEventTarget, getOwnerDocument as $hf0lj$getOwnerDocument, getActiveElement as $hf0lj$getActiveElement} from "@react-aria/utils";
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -22,7 +22,7 @@ import {getOwnerDocument as $hf0lj$getOwnerDocument, getActiveElement as $hf0lj$
|
|
|
22
22
|
function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
23
23
|
let { isDisabled: isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange: onFocusChange } = props;
|
|
24
24
|
const onBlur = (0, $hf0lj$useCallback)((e)=>{
|
|
25
|
-
if (e
|
|
25
|
+
if ((0, $hf0lj$getEventTarget)(e) === e.currentTarget) {
|
|
26
26
|
if (onBlurProp) onBlurProp(e);
|
|
27
27
|
if (onFocusChange) onFocusChange(false);
|
|
28
28
|
return true;
|
|
@@ -35,9 +35,10 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
35
35
|
const onFocus = (0, $hf0lj$useCallback)((e)=>{
|
|
36
36
|
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
37
37
|
// focus handler already moved focus somewhere else.
|
|
38
|
-
|
|
38
|
+
let eventTarget = (0, $hf0lj$getEventTarget)(e);
|
|
39
|
+
const ownerDocument = (0, $hf0lj$getOwnerDocument)(eventTarget);
|
|
39
40
|
const activeElement = ownerDocument ? (0, $hf0lj$getActiveElement)(ownerDocument) : (0, $hf0lj$getActiveElement)();
|
|
40
|
-
if (
|
|
41
|
+
if (eventTarget === e.currentTarget && eventTarget === activeElement) {
|
|
41
42
|
if (onFocusProp) onFocusProp(e);
|
|
42
43
|
if (onFocusChange) onFocusChange(true);
|
|
43
44
|
onSyntheticFocus(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;;AAqB3G,SAAS,0CAA6D,KAAyB;IACpG,IAAI,cACF,UAAU,EACV,SAAS,WAAW,EACpB,QAAQ,UAAU,iBAClB,aAAa,EACd,GAAG;IAEJ,MAAM,SAAuC,CAAA,GAAA,kBAAU,EAAE,CAAC;QACxD,IAAI,
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;;AAqB3G,SAAS,0CAA6D,KAAyB;IACpG,IAAI,cACF,UAAU,EACV,SAAS,WAAW,EACpB,QAAQ,UAAU,iBAClB,aAAa,EACd,GAAG;IAEJ,MAAM,SAAuC,CAAA,GAAA,kBAAU,EAAE,CAAC;QACxD,IAAI,CAAA,GAAA,qBAAa,EAAE,OAAO,EAAE,aAAa,EAAE;YACzC,IAAI,YACF,WAAW;YAGb,IAAI,eACF,cAAc;YAGhB,OAAO;QACT;IACF,GAAG;QAAC;QAAY;KAAc;IAG9B,MAAM,mBAAmB,CAAA,GAAA,yCAAoB,EAAU;IAEvD,MAAM,UAAyC,CAAA,GAAA,kBAAU,EAAE,CAAC;QAC1D,kGAAkG;QAClG,oDAAoD;QAEpD,IAAI,cAAc,CAAA,GAAA,qBAAa,EAAE;QACjC,MAAM,gBAAgB,CAAA,GAAA,uBAAe,EAAE;QACvC,MAAM,gBAAgB,gBAAgB,CAAA,GAAA,uBAAe,EAAE,iBAAiB,CAAA,GAAA,uBAAe;QACvF,IAAI,gBAAgB,EAAE,aAAa,IAAI,gBAAgB,eAAe;YACpE,IAAI,aACF,YAAY;YAGd,IAAI,eACF,cAAc;YAGhB,iBAAiB;QACnB;IACF,GAAG;QAAC;QAAe;QAAa;KAAiB;IAEjD,OAAO;QACL,YAAY;YACV,SAAS,AAAC,CAAC,cAAe,CAAA,eAAe,iBAAiB,UAAS,IAAM,UAAU;YACnF,QAAQ,AAAC,CAAC,cAAe,CAAA,cAAc,aAAY,IAAM,SAAS;QACpE;IACF;AACF","sources":["packages/@react-aria/interactions/src/useFocus.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from react.\n// Original licensing for the following can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions\n\nimport {DOMAttributes, FocusableElement, FocusEvents} from '@react-types/shared';\nimport {FocusEvent, useCallback} from 'react';\nimport {getActiveElement, getEventTarget, getOwnerDocument} from '@react-aria/utils';\nimport {useSyntheticBlurEvent} from './utils';\n\nexport interface FocusProps<Target = FocusableElement> extends FocusEvents<Target> {\n /** Whether the focus events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface FocusResult<Target = FocusableElement> {\n /** Props to spread onto the target element. */\n focusProps: DOMAttributes<Target>\n}\n\n/**\n * Handles focus events for the immediate target.\n * Focus events on child elements will be ignored.\n */\nexport function useFocus<Target extends FocusableElement = FocusableElement>(props: FocusProps<Target>): FocusResult<Target> {\n let {\n isDisabled,\n onFocus: onFocusProp,\n onBlur: onBlurProp,\n onFocusChange\n } = props;\n\n const onBlur: FocusProps<Target>['onBlur'] = useCallback((e: FocusEvent<Target>) => {\n if (getEventTarget(e) === e.currentTarget) {\n if (onBlurProp) {\n onBlurProp(e);\n }\n\n if (onFocusChange) {\n onFocusChange(false);\n }\n\n return true;\n }\n }, [onBlurProp, onFocusChange]);\n\n\n const onSyntheticFocus = useSyntheticBlurEvent<Target>(onBlur);\n\n const onFocus: FocusProps<Target>['onFocus'] = useCallback((e: FocusEvent<Target>) => {\n // Double check that document.activeElement actually matches e.target in case a previously chained\n // focus handler already moved focus somewhere else.\n\n let eventTarget = getEventTarget(e);\n const ownerDocument = getOwnerDocument(eventTarget);\n const activeElement = ownerDocument ? getActiveElement(ownerDocument) : getActiveElement();\n if (eventTarget === e.currentTarget && eventTarget === activeElement) {\n if (onFocusProp) {\n onFocusProp(e);\n }\n\n if (onFocusChange) {\n onFocusChange(true);\n }\n\n onSyntheticFocus(e);\n }\n }, [onFocusChange, onFocusProp, onSyntheticFocus]);\n\n return {\n focusProps: {\n onFocus: (!isDisabled && (onFocusProp || onFocusChange || onBlurProp)) ? onFocus : undefined,\n onBlur: (!isDisabled && (onBlurProp || onFocusChange)) ? onBlur : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useFocus.module.js.map"}
|
|
@@ -36,7 +36,7 @@ $parcel$export(module.exports, "useFocusVisibleListener", () => $e77252a287ef94a
|
|
|
36
36
|
|
|
37
37
|
let $e77252a287ef94ab$var$currentModality = null;
|
|
38
38
|
let $e77252a287ef94ab$var$currentPointerType = 'keyboard';
|
|
39
|
-
|
|
39
|
+
const $e77252a287ef94ab$export$901e90a13c50a14e = new Set();
|
|
40
40
|
let $e77252a287ef94ab$export$d90243b58daecda7 = new Map(); // We use a map here to support setting event listeners across multiple document objects.
|
|
41
41
|
let $e77252a287ef94ab$var$hasEventBeforeFocus = false;
|
|
42
42
|
let $e77252a287ef94ab$var$hasBlurredWindowRecently = false;
|
|
@@ -46,7 +46,7 @@ const $e77252a287ef94ab$var$FOCUS_VISIBLE_INPUT_KEYS = {
|
|
|
46
46
|
Escape: true
|
|
47
47
|
};
|
|
48
48
|
function $e77252a287ef94ab$var$triggerChangeHandlers(modality, e) {
|
|
49
|
-
for (let handler of $e77252a287ef94ab$
|
|
49
|
+
for (let handler of $e77252a287ef94ab$export$901e90a13c50a14e)handler(modality, e);
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
@@ -81,7 +81,7 @@ function $e77252a287ef94ab$var$handleFocusEvent(e) {
|
|
|
81
81
|
// Firefox fires two extra focus events when the user first clicks into an iframe:
|
|
82
82
|
// first on the window, then on the document. We ignore these events so they don't
|
|
83
83
|
// cause keyboard focus rings to appear.
|
|
84
|
-
if (e
|
|
84
|
+
if ((0, $cR3F8$reactariautils.getEventTarget)(e) === window || (0, $cR3F8$reactariautils.getEventTarget)(e) === document || (0, $625cf83917e112ad$exports.ignoreFocusEvent) || !e.isTrusted) return;
|
|
85
85
|
// If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
|
|
86
86
|
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
87
87
|
if (!$e77252a287ef94ab$var$hasEventBeforeFocus && !$e77252a287ef94ab$var$hasBlurredWindowRecently) {
|
|
@@ -198,9 +198,9 @@ function $e77252a287ef94ab$export$98e20ec92f614cfe() {
|
|
|
198
198
|
let handler = ()=>{
|
|
199
199
|
setModality($e77252a287ef94ab$var$currentModality);
|
|
200
200
|
};
|
|
201
|
-
$e77252a287ef94ab$
|
|
201
|
+
$e77252a287ef94ab$export$901e90a13c50a14e.add(handler);
|
|
202
202
|
return ()=>{
|
|
203
|
-
$e77252a287ef94ab$
|
|
203
|
+
$e77252a287ef94ab$export$901e90a13c50a14e.delete(handler);
|
|
204
204
|
};
|
|
205
205
|
}, []);
|
|
206
206
|
return (0, $cR3F8$reactariassr.useIsSSR)() ? null : modality;
|
|
@@ -220,14 +220,16 @@ const $e77252a287ef94ab$var$nonTextInputTypes = new Set([
|
|
|
220
220
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
221
221
|
* focus visible style can be properly set.
|
|
222
222
|
*/ function $e77252a287ef94ab$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
|
223
|
-
let document1 = (0, $cR3F8$reactariautils.getOwnerDocument)(e
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
const
|
|
223
|
+
let document1 = (0, $cR3F8$reactariautils.getOwnerDocument)(e ? (0, $cR3F8$reactariautils.getEventTarget)(e) : undefined);
|
|
224
|
+
let eventTarget = e ? (0, $cR3F8$reactariautils.getEventTarget)(e) : undefined;
|
|
225
|
+
const IHTMLInputElement = typeof window !== 'undefined' ? (0, $cR3F8$reactariautils.getOwnerWindow)(eventTarget).HTMLInputElement : HTMLInputElement;
|
|
226
|
+
const IHTMLTextAreaElement = typeof window !== 'undefined' ? (0, $cR3F8$reactariautils.getOwnerWindow)(eventTarget).HTMLTextAreaElement : HTMLTextAreaElement;
|
|
227
|
+
const IHTMLElement = typeof window !== 'undefined' ? (0, $cR3F8$reactariautils.getOwnerWindow)(eventTarget).HTMLElement : HTMLElement;
|
|
228
|
+
const IKeyboardEvent = typeof window !== 'undefined' ? (0, $cR3F8$reactariautils.getOwnerWindow)(eventTarget).KeyboardEvent : KeyboardEvent;
|
|
228
229
|
// For keyboard events that occur on a non-input element that will move focus into input element (aka ArrowLeft going from Datepicker button to the main input group)
|
|
229
230
|
// we need to rely on the user passing isTextInput into here. This way we can skip toggling focus visiblity for said input element
|
|
230
|
-
|
|
231
|
+
let activeElement = (0, $cR3F8$reactariautils.getActiveElement)(document1);
|
|
232
|
+
isTextInput = isTextInput || activeElement instanceof IHTMLInputElement && !$e77252a287ef94ab$var$nonTextInputTypes.has(activeElement.type) || activeElement instanceof IHTMLTextAreaElement || activeElement instanceof IHTMLElement && activeElement.isContentEditable;
|
|
231
233
|
return !(isTextInput && modality === 'keyboard' && e instanceof IKeyboardEvent && !$e77252a287ef94ab$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
|
232
234
|
}
|
|
233
235
|
function $e77252a287ef94ab$export$ffd9e5021c1fb2d6(props = {}) {
|
|
@@ -247,14 +249,15 @@ function $e77252a287ef94ab$export$ffd9e5021c1fb2d6(props = {}) {
|
|
|
247
249
|
function $e77252a287ef94ab$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
248
250
|
$e77252a287ef94ab$var$setupGlobalFocusEvents();
|
|
249
251
|
(0, $cR3F8$react.useEffect)(()=>{
|
|
252
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) return;
|
|
250
253
|
let handler = (modality, e)=>{
|
|
251
254
|
// We want to early return for any keyboard events that occur inside text inputs EXCEPT for Tab and Escape
|
|
252
255
|
if (!$e77252a287ef94ab$var$isKeyboardFocusEvent(!!(opts === null || opts === void 0 ? void 0 : opts.isTextInput), modality, e)) return;
|
|
253
256
|
fn($e77252a287ef94ab$export$b9b3dfddab17db27());
|
|
254
257
|
};
|
|
255
|
-
$e77252a287ef94ab$
|
|
258
|
+
$e77252a287ef94ab$export$901e90a13c50a14e.add(handler);
|
|
256
259
|
return ()=>{
|
|
257
|
-
$e77252a287ef94ab$
|
|
260
|
+
$e77252a287ef94ab$export$901e90a13c50a14e.delete(handler);
|
|
258
261
|
};
|
|
259
262
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
260
263
|
}, deps);
|