@react-aria/interactions 3.22.5 → 3.24.0
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/Pressable.main.js +28 -4
- package/dist/Pressable.main.js.map +1 -1
- package/dist/Pressable.mjs +30 -6
- package/dist/Pressable.module.js +30 -6
- package/dist/Pressable.module.js.map +1 -1
- package/dist/createEventHandler.main.js +5 -1
- package/dist/createEventHandler.main.js.map +1 -1
- package/dist/createEventHandler.mjs +5 -1
- package/dist/createEventHandler.module.js +5 -1
- package/dist/createEventHandler.module.js.map +1 -1
- package/dist/focusSafely.main.js +40 -0
- package/dist/focusSafely.main.js.map +1 -0
- package/dist/focusSafely.mjs +35 -0
- package/dist/focusSafely.module.js +35 -0
- package/dist/focusSafely.module.js.map +1 -0
- package/dist/import.mjs +5 -1
- package/dist/main.js +9 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +5 -1
- package/dist/module.js.map +1 -1
- package/dist/textSelection.main.js +5 -3
- package/dist/textSelection.main.js.map +1 -1
- package/dist/textSelection.mjs +5 -3
- package/dist/textSelection.module.js +5 -3
- package/dist/textSelection.module.js.map +1 -1
- package/dist/types.d.ts +59 -25
- package/dist/types.d.ts.map +1 -1
- package/dist/useFocus.main.js +2 -1
- package/dist/useFocus.main.js.map +1 -1
- package/dist/useFocus.mjs +3 -2
- package/dist/useFocus.module.js +3 -2
- package/dist/useFocus.module.js.map +1 -1
- package/dist/useFocusVisible.main.js +9 -3
- package/dist/useFocusVisible.main.js.map +1 -1
- package/dist/useFocusVisible.mjs +9 -3
- package/dist/useFocusVisible.module.js +9 -3
- package/dist/useFocusVisible.module.js.map +1 -1
- package/dist/useFocusWithin.main.js +33 -4
- package/dist/useFocusWithin.main.js.map +1 -1
- package/dist/useFocusWithin.mjs +34 -5
- package/dist/useFocusWithin.module.js +34 -5
- package/dist/useFocusWithin.module.js.map +1 -1
- package/dist/useFocusable.main.js +112 -0
- package/dist/useFocusable.main.js.map +1 -0
- package/dist/useFocusable.mjs +100 -0
- package/dist/useFocusable.module.js +100 -0
- package/dist/useFocusable.module.js.map +1 -0
- package/dist/useHover.main.js +18 -3
- package/dist/useHover.main.js.map +1 -1
- package/dist/useHover.mjs +18 -3
- package/dist/useHover.module.js +18 -3
- package/dist/useHover.module.js.map +1 -1
- package/dist/useInteractOutside.main.js +6 -1
- package/dist/useInteractOutside.main.js.map +1 -1
- package/dist/useInteractOutside.mjs +6 -1
- package/dist/useInteractOutside.module.js +6 -1
- package/dist/useInteractOutside.module.js.map +1 -1
- package/dist/useLongPress.main.js +2 -0
- package/dist/useLongPress.main.js.map +1 -1
- package/dist/useLongPress.mjs +3 -1
- package/dist/useLongPress.module.js +3 -1
- package/dist/useLongPress.module.js.map +1 -1
- package/dist/usePress.main.js +97 -94
- package/dist/usePress.main.js.map +1 -1
- package/dist/usePress.mjs +98 -95
- package/dist/usePress.module.js +98 -95
- package/dist/usePress.module.js.map +1 -1
- package/dist/utils.main.js +57 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +55 -2
- package/dist/utils.module.js +55 -2
- package/dist/utils.module.js.map +1 -1
- package/package.json +7 -5
- package/src/Pressable.tsx +66 -6
- package/src/createEventHandler.ts +8 -1
- package/src/focusSafely.ts +45 -0
- package/src/index.ts +3 -0
- package/src/textSelection.ts +6 -4
- package/src/useFocus.ts +3 -3
- package/src/useFocusVisible.ts +14 -4
- package/src/useFocusWithin.ts +34 -5
- package/src/useFocusable.tsx +183 -0
- package/src/useHover.ts +17 -3
- package/src/useInteractOutside.ts +9 -3
- package/src/useLongPress.ts +8 -2
- package/src/usePress.ts +132 -131
- package/src/utils.ts +80 -1
- package/src/DOMPropsContext.ts +0 -39
- package/src/DOMPropsResponder.tsx +0 -47
- package/src/useDOMPropsResponder.ts +0 -27
package/dist/Pressable.main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var $0294ea432cd92340$exports = require("./usePress.main.js");
|
|
2
|
+
var $15f8fd80892557ff$exports = require("./useFocusable.main.js");
|
|
2
3
|
var $ev4bP$reactariautils = require("@react-aria/utils");
|
|
3
4
|
var $ev4bP$react = require("react");
|
|
4
5
|
|
|
@@ -25,17 +26,40 @@ $parcel$export(module.exports, "Pressable", () => $e1dbec26039c051d$export$27c70
|
|
|
25
26
|
*/
|
|
26
27
|
|
|
27
28
|
|
|
29
|
+
|
|
28
30
|
const $e1dbec26039c051d$export$27c701ed9e449e99 = /*#__PURE__*/ (0, ($parcel$interopDefault($ev4bP$react))).forwardRef(({ children: children, ...props }, ref)=>{
|
|
29
31
|
ref = (0, $ev4bP$reactariautils.useObjectRef)(ref);
|
|
30
32
|
let { pressProps: pressProps } = (0, $0294ea432cd92340$exports.usePress)({
|
|
31
33
|
...props,
|
|
32
34
|
ref: ref
|
|
33
35
|
});
|
|
36
|
+
let { focusableProps: focusableProps } = (0, $15f8fd80892557ff$exports.useFocusable)(props, ref);
|
|
34
37
|
let child = (0, ($parcel$interopDefault($ev4bP$react))).Children.only(children);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
(0, $ev4bP$react.useEffect)(()=>{
|
|
39
|
+
let el = ref.current;
|
|
40
|
+
if (!el || !(el instanceof (0, $ev4bP$reactariautils.getOwnerWindow)(el).Element)) {
|
|
41
|
+
console.error('<Pressable> child must forward its ref to a DOM element.');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!(0, $ev4bP$reactariautils.isFocusable)(el)) {
|
|
45
|
+
console.warn('<Pressable> child must be focusable. Please ensure the tabIndex prop is passed through.');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (el.localName !== 'button' && el.localName !== 'input' && el.localName !== 'select' && el.localName !== 'textarea' && el.localName !== 'a' && el.localName !== 'area' && el.localName !== 'summary') {
|
|
49
|
+
let role = el.getAttribute('role');
|
|
50
|
+
if (!role) console.warn('<Pressable> child must have an interactive ARIA role.');
|
|
51
|
+
else if (// https://w3c.github.io/aria/#widget_roles
|
|
52
|
+
role !== 'application' && role !== 'button' && role !== 'checkbox' && role !== 'combobox' && role !== 'gridcell' && role !== 'link' && role !== 'menuitem' && role !== 'menuitemcheckbox' && role !== 'menuitemradio' && role !== 'option' && role !== 'radio' && role !== 'searchbox' && role !== 'separator' && role !== 'slider' && role !== 'spinbutton' && role !== 'switch' && role !== 'tab' && role !== 'textbox' && role !== 'treeitem') console.warn(`<Pressable> child must have an interactive ARIA role. Got "${role}".`);
|
|
53
|
+
}
|
|
54
|
+
}, [
|
|
55
|
+
ref
|
|
56
|
+
]);
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
let childRef = parseInt((0, ($parcel$interopDefault($ev4bP$react))).version, 10) < 19 ? child.ref : child.props.ref;
|
|
59
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($ev4bP$react))).cloneElement(child, {
|
|
60
|
+
...(0, $ev4bP$reactariautils.mergeProps)(pressProps, focusableProps, child.props),
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
ref: (0, $ev4bP$reactariautils.mergeRefs)(childRef, ref)
|
|
39
63
|
});
|
|
40
64
|
});
|
|
41
65
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAYM,MAAM,0DAAY,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC,CAAC,YAAC,QAAQ,EAAE,GAAG,OAAsB,EAAE;IAC/E,MAAM,CAAA,GAAA,kCAAW,EAAE;IACnB,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,kCAAO,EAAE;QAAC,GAAG,KAAK;aAAE;IAAG;IAC1C,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,sCAAW,EAAE,OAAO;IAC3C,IAAI,QAAQ,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IAEhC,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,KAAK,IAAI,OAAO;QACpB,IAAI,CAAC,MAAM,CAAE,CAAA,cAAc,CAAA,GAAA,oCAAa,EAAE,IAAI,OAAO,AAAD,GAAI;YACtD,QAAQ,KAAK,CAAC;YACd;QACF;QAEA,IAAI,CAAC,CAAA,GAAA,iCAAU,EAAE,KAAK;YACpB,QAAQ,IAAI,CAAC;YACb;QACF;QAEA,IACE,GAAG,SAAS,KAAK,YACjB,GAAG,SAAS,KAAK,WACjB,GAAG,SAAS,KAAK,YACjB,GAAG,SAAS,KAAK,cACjB,GAAG,SAAS,KAAK,OACjB,GAAG,SAAS,KAAK,UACjB,GAAG,SAAS,KAAK,WACjB;YACA,IAAI,OAAO,GAAG,YAAY,CAAC;YAC3B,IAAI,CAAC,MACH,QAAQ,IAAI,CAAC;iBACR,IACL,2CAA2C;YAC3C,SAAS,iBACT,SAAS,YACT,SAAS,cACT,SAAS,cACT,SAAS,cACT,SAAS,UACT,SAAS,cACT,SAAS,sBACT,SAAS,mBACT,SAAS,YACT,SAAS,WACT,SAAS,eACT,SAAS,eACT,SAAS,YACT,SAAS,gBACT,SAAS,YACT,SAAS,SACT,SAAS,aACT,SAAS,YAET,QAAQ,IAAI,CAAC,CAAC,2DAA2D,EAAE,KAAK,EAAE,CAAC;QAEvF;IACF,GAAG;QAAC;KAAI;IAER,aAAa;IACb,IAAI,WAAW,SAAS,CAAA,GAAA,sCAAI,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG;IAE7E,qBAAO,CAAA,GAAA,sCAAI,EAAE,YAAY,CACvB,OACA;QACE,GAAG,CAAA,GAAA,gCAAS,EAAE,YAAY,gBAAgB,MAAM,KAAK,CAAC;QACtD,aAAa;QACb,KAAK,CAAA,GAAA,+BAAQ,EAAE,UAAU;IAC3B;AAEJ","sources":["packages/@react-aria/interactions/src/Pressable.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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getOwnerWindow, isFocusable, mergeProps, mergeRefs, useObjectRef} from '@react-aria/utils';\nimport {PressProps, usePress} from './usePress';\nimport React, {ForwardedRef, ReactElement, useEffect} from 'react';\nimport {useFocusable} from './useFocusable';\n\ninterface PressableProps extends PressProps {\n children: ReactElement<DOMAttributes, string>\n}\n\nexport const Pressable = React.forwardRef(({children, ...props}: PressableProps, ref: ForwardedRef<FocusableElement>) => {\n ref = useObjectRef(ref);\n let {pressProps} = usePress({...props, ref});\n let {focusableProps} = useFocusable(props, ref);\n let child = React.Children.only(children);\n\n useEffect(() => {\n let el = ref.current;\n if (!el || !(el instanceof getOwnerWindow(el).Element)) {\n console.error('<Pressable> child must forward its ref to a DOM element.');\n return;\n }\n\n if (!isFocusable(el)) {\n console.warn('<Pressable> child must be focusable. Please ensure the tabIndex prop is passed through.');\n return;\n }\n\n if (\n el.localName !== 'button' &&\n el.localName !== 'input' &&\n el.localName !== 'select' &&\n el.localName !== 'textarea' &&\n el.localName !== 'a' &&\n el.localName !== 'area' &&\n el.localName !== 'summary'\n ) {\n let role = el.getAttribute('role');\n if (!role) {\n console.warn('<Pressable> child must have an interactive ARIA role.');\n } else if (\n // https://w3c.github.io/aria/#widget_roles\n role !== 'application' &&\n role !== 'button' &&\n role !== 'checkbox' &&\n role !== 'combobox' &&\n role !== 'gridcell' &&\n role !== 'link' &&\n role !== 'menuitem' &&\n role !== 'menuitemcheckbox' &&\n role !== 'menuitemradio' &&\n role !== 'option' &&\n role !== 'radio' &&\n role !== 'searchbox' &&\n role !== 'separator' &&\n role !== 'slider' &&\n role !== 'spinbutton' &&\n role !== 'switch' &&\n role !== 'tab' &&\n role !== 'textbox' &&\n role !== 'treeitem'\n ) {\n console.warn(`<Pressable> child must have an interactive ARIA role. Got \"${role}\".`);\n }\n }\n }, [ref]);\n\n // @ts-ignore\n let childRef = parseInt(React.version, 10) < 19 ? child.ref : child.props.ref;\n\n return React.cloneElement(\n child,\n {\n ...mergeProps(pressProps, focusableProps, child.props),\n // @ts-ignore\n ref: mergeRefs(childRef, ref)\n }\n );\n});\n"],"names":[],"version":3,"file":"Pressable.main.js.map"}
|
package/dist/Pressable.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import $hhDyF$
|
|
2
|
+
import {useFocusable as $f645667febf57a63$export$4c014de7c8940b4c} from "./useFocusable.mjs";
|
|
3
|
+
import {useObjectRef as $hhDyF$useObjectRef, getOwnerWindow as $hhDyF$getOwnerWindow, isFocusable as $hhDyF$isFocusable, mergeProps as $hhDyF$mergeProps, mergeRefs as $hhDyF$mergeRefs} from "@react-aria/utils";
|
|
4
|
+
import $hhDyF$react, {useEffect as $hhDyF$useEffect} from "react";
|
|
4
5
|
|
|
5
6
|
/*
|
|
6
7
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,17 +16,40 @@ import $hhDyF$react from "react";
|
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
|
|
18
20
|
const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ (0, $hhDyF$react).forwardRef(({ children: children, ...props }, ref)=>{
|
|
19
21
|
ref = (0, $hhDyF$useObjectRef)(ref);
|
|
20
22
|
let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
|
|
21
23
|
...props,
|
|
22
24
|
ref: ref
|
|
23
25
|
});
|
|
26
|
+
let { focusableProps: focusableProps } = (0, $f645667febf57a63$export$4c014de7c8940b4c)(props, ref);
|
|
24
27
|
let child = (0, $hhDyF$react).Children.only(children);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
(0, $hhDyF$useEffect)(()=>{
|
|
29
|
+
let el = ref.current;
|
|
30
|
+
if (!el || !(el instanceof (0, $hhDyF$getOwnerWindow)(el).Element)) {
|
|
31
|
+
console.error('<Pressable> child must forward its ref to a DOM element.');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!(0, $hhDyF$isFocusable)(el)) {
|
|
35
|
+
console.warn('<Pressable> child must be focusable. Please ensure the tabIndex prop is passed through.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (el.localName !== 'button' && el.localName !== 'input' && el.localName !== 'select' && el.localName !== 'textarea' && el.localName !== 'a' && el.localName !== 'area' && el.localName !== 'summary') {
|
|
39
|
+
let role = el.getAttribute('role');
|
|
40
|
+
if (!role) console.warn('<Pressable> child must have an interactive ARIA role.');
|
|
41
|
+
else if (// https://w3c.github.io/aria/#widget_roles
|
|
42
|
+
role !== 'application' && role !== 'button' && role !== 'checkbox' && role !== 'combobox' && role !== 'gridcell' && role !== 'link' && role !== 'menuitem' && role !== 'menuitemcheckbox' && role !== 'menuitemradio' && role !== 'option' && role !== 'radio' && role !== 'searchbox' && role !== 'separator' && role !== 'slider' && role !== 'spinbutton' && role !== 'switch' && role !== 'tab' && role !== 'textbox' && role !== 'treeitem') console.warn(`<Pressable> child must have an interactive ARIA role. Got "${role}".`);
|
|
43
|
+
}
|
|
44
|
+
}, [
|
|
45
|
+
ref
|
|
46
|
+
]);
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
let childRef = parseInt((0, $hhDyF$react).version, 10) < 19 ? child.ref : child.props.ref;
|
|
49
|
+
return /*#__PURE__*/ (0, $hhDyF$react).cloneElement(child, {
|
|
50
|
+
...(0, $hhDyF$mergeProps)(pressProps, focusableProps, child.props),
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
ref: (0, $hhDyF$mergeRefs)(childRef, ref)
|
|
29
53
|
});
|
|
30
54
|
});
|
|
31
55
|
|
package/dist/Pressable.module.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.module.js";
|
|
2
|
-
import {
|
|
3
|
-
import $hhDyF$
|
|
2
|
+
import {useFocusable as $f645667febf57a63$export$4c014de7c8940b4c} from "./useFocusable.module.js";
|
|
3
|
+
import {useObjectRef as $hhDyF$useObjectRef, getOwnerWindow as $hhDyF$getOwnerWindow, isFocusable as $hhDyF$isFocusable, mergeProps as $hhDyF$mergeProps, mergeRefs as $hhDyF$mergeRefs} from "@react-aria/utils";
|
|
4
|
+
import $hhDyF$react, {useEffect as $hhDyF$useEffect} from "react";
|
|
4
5
|
|
|
5
6
|
/*
|
|
6
7
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,17 +16,40 @@ import $hhDyF$react from "react";
|
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
|
|
18
20
|
const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ (0, $hhDyF$react).forwardRef(({ children: children, ...props }, ref)=>{
|
|
19
21
|
ref = (0, $hhDyF$useObjectRef)(ref);
|
|
20
22
|
let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
|
|
21
23
|
...props,
|
|
22
24
|
ref: ref
|
|
23
25
|
});
|
|
26
|
+
let { focusableProps: focusableProps } = (0, $f645667febf57a63$export$4c014de7c8940b4c)(props, ref);
|
|
24
27
|
let child = (0, $hhDyF$react).Children.only(children);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
(0, $hhDyF$useEffect)(()=>{
|
|
29
|
+
let el = ref.current;
|
|
30
|
+
if (!el || !(el instanceof (0, $hhDyF$getOwnerWindow)(el).Element)) {
|
|
31
|
+
console.error('<Pressable> child must forward its ref to a DOM element.');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!(0, $hhDyF$isFocusable)(el)) {
|
|
35
|
+
console.warn('<Pressable> child must be focusable. Please ensure the tabIndex prop is passed through.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (el.localName !== 'button' && el.localName !== 'input' && el.localName !== 'select' && el.localName !== 'textarea' && el.localName !== 'a' && el.localName !== 'area' && el.localName !== 'summary') {
|
|
39
|
+
let role = el.getAttribute('role');
|
|
40
|
+
if (!role) console.warn('<Pressable> child must have an interactive ARIA role.');
|
|
41
|
+
else if (// https://w3c.github.io/aria/#widget_roles
|
|
42
|
+
role !== 'application' && role !== 'button' && role !== 'checkbox' && role !== 'combobox' && role !== 'gridcell' && role !== 'link' && role !== 'menuitem' && role !== 'menuitemcheckbox' && role !== 'menuitemradio' && role !== 'option' && role !== 'radio' && role !== 'searchbox' && role !== 'separator' && role !== 'slider' && role !== 'spinbutton' && role !== 'switch' && role !== 'tab' && role !== 'textbox' && role !== 'treeitem') console.warn(`<Pressable> child must have an interactive ARIA role. Got "${role}".`);
|
|
43
|
+
}
|
|
44
|
+
}, [
|
|
45
|
+
ref
|
|
46
|
+
]);
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
let childRef = parseInt((0, $hhDyF$react).version, 10) < 19 ? child.ref : child.props.ref;
|
|
49
|
+
return /*#__PURE__*/ (0, $hhDyF$react).cloneElement(child, {
|
|
50
|
+
...(0, $hhDyF$mergeProps)(pressProps, focusableProps, child.props),
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
ref: (0, $hhDyF$mergeRefs)(childRef, ref)
|
|
29
53
|
});
|
|
30
54
|
});
|
|
31
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAYM,MAAM,0DAAY,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,CAAC,YAAC,QAAQ,EAAE,GAAG,OAAsB,EAAE;IAC/E,MAAM,CAAA,GAAA,mBAAW,EAAE;IACnB,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE;QAAC,GAAG,KAAK;aAAE;IAAG;IAC1C,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,yCAAW,EAAE,OAAO;IAC3C,IAAI,QAAQ,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IAEhC,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,KAAK,IAAI,OAAO;QACpB,IAAI,CAAC,MAAM,CAAE,CAAA,cAAc,CAAA,GAAA,qBAAa,EAAE,IAAI,OAAO,AAAD,GAAI;YACtD,QAAQ,KAAK,CAAC;YACd;QACF;QAEA,IAAI,CAAC,CAAA,GAAA,kBAAU,EAAE,KAAK;YACpB,QAAQ,IAAI,CAAC;YACb;QACF;QAEA,IACE,GAAG,SAAS,KAAK,YACjB,GAAG,SAAS,KAAK,WACjB,GAAG,SAAS,KAAK,YACjB,GAAG,SAAS,KAAK,cACjB,GAAG,SAAS,KAAK,OACjB,GAAG,SAAS,KAAK,UACjB,GAAG,SAAS,KAAK,WACjB;YACA,IAAI,OAAO,GAAG,YAAY,CAAC;YAC3B,IAAI,CAAC,MACH,QAAQ,IAAI,CAAC;iBACR,IACL,2CAA2C;YAC3C,SAAS,iBACT,SAAS,YACT,SAAS,cACT,SAAS,cACT,SAAS,cACT,SAAS,UACT,SAAS,cACT,SAAS,sBACT,SAAS,mBACT,SAAS,YACT,SAAS,WACT,SAAS,eACT,SAAS,eACT,SAAS,YACT,SAAS,gBACT,SAAS,YACT,SAAS,SACT,SAAS,aACT,SAAS,YAET,QAAQ,IAAI,CAAC,CAAC,2DAA2D,EAAE,KAAK,EAAE,CAAC;QAEvF;IACF,GAAG;QAAC;KAAI;IAER,aAAa;IACb,IAAI,WAAW,SAAS,CAAA,GAAA,YAAI,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG;IAE7E,qBAAO,CAAA,GAAA,YAAI,EAAE,YAAY,CACvB,OACA;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,gBAAgB,MAAM,KAAK,CAAC;QACtD,aAAa;QACb,KAAK,CAAA,GAAA,gBAAQ,EAAE,UAAU;IAC3B;AAEJ","sources":["packages/@react-aria/interactions/src/Pressable.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 {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {getOwnerWindow, isFocusable, mergeProps, mergeRefs, useObjectRef} from '@react-aria/utils';\nimport {PressProps, usePress} from './usePress';\nimport React, {ForwardedRef, ReactElement, useEffect} from 'react';\nimport {useFocusable} from './useFocusable';\n\ninterface PressableProps extends PressProps {\n children: ReactElement<DOMAttributes, string>\n}\n\nexport const Pressable = React.forwardRef(({children, ...props}: PressableProps, ref: ForwardedRef<FocusableElement>) => {\n ref = useObjectRef(ref);\n let {pressProps} = usePress({...props, ref});\n let {focusableProps} = useFocusable(props, ref);\n let child = React.Children.only(children);\n\n useEffect(() => {\n let el = ref.current;\n if (!el || !(el instanceof getOwnerWindow(el).Element)) {\n console.error('<Pressable> child must forward its ref to a DOM element.');\n return;\n }\n\n if (!isFocusable(el)) {\n console.warn('<Pressable> child must be focusable. Please ensure the tabIndex prop is passed through.');\n return;\n }\n\n if (\n el.localName !== 'button' &&\n el.localName !== 'input' &&\n el.localName !== 'select' &&\n el.localName !== 'textarea' &&\n el.localName !== 'a' &&\n el.localName !== 'area' &&\n el.localName !== 'summary'\n ) {\n let role = el.getAttribute('role');\n if (!role) {\n console.warn('<Pressable> child must have an interactive ARIA role.');\n } else if (\n // https://w3c.github.io/aria/#widget_roles\n role !== 'application' &&\n role !== 'button' &&\n role !== 'checkbox' &&\n role !== 'combobox' &&\n role !== 'gridcell' &&\n role !== 'link' &&\n role !== 'menuitem' &&\n role !== 'menuitemcheckbox' &&\n role !== 'menuitemradio' &&\n role !== 'option' &&\n role !== 'radio' &&\n role !== 'searchbox' &&\n role !== 'separator' &&\n role !== 'slider' &&\n role !== 'spinbutton' &&\n role !== 'switch' &&\n role !== 'tab' &&\n role !== 'textbox' &&\n role !== 'treeitem'\n ) {\n console.warn(`<Pressable> child must have an interactive ARIA role. Got \"${role}\".`);\n }\n }\n }, [ref]);\n\n // @ts-ignore\n let childRef = parseInt(React.version, 10) < 19 ? child.ref : child.props.ref;\n\n return React.cloneElement(\n child,\n {\n ...mergeProps(pressProps, focusableProps, child.props),\n // @ts-ignore\n ref: mergeRefs(childRef, ref)\n }\n );\n});\n"],"names":[],"version":3,"file":"Pressable.module.js.map"}
|
|
@@ -27,10 +27,14 @@ $parcel$export(module.exports, "createEventHandler", () => $951fbcbbca8db6ce$exp
|
|
|
27
27
|
return e.isDefaultPrevented();
|
|
28
28
|
},
|
|
29
29
|
stopPropagation () {
|
|
30
|
-
console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');
|
|
30
|
+
if (shouldStopPropagation) console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');
|
|
31
|
+
else shouldStopPropagation = true;
|
|
31
32
|
},
|
|
32
33
|
continuePropagation () {
|
|
33
34
|
shouldStopPropagation = false;
|
|
35
|
+
},
|
|
36
|
+
isPropagationStopped () {
|
|
37
|
+
return shouldStopPropagation;
|
|
34
38
|
}
|
|
35
39
|
};
|
|
36
40
|
handler(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAQM,SAAS,0CAA6C,OAAmC;IAC9F,IAAI,CAAC,SACH,OAAO;IAGT,IAAI,wBAAwB;IAC5B,OAAO,CAAC;QACN,IAAI,QAAsB;YACxB,GAAG,CAAC;YACJ;gBACE,EAAE,cAAc;YAClB;YACA;gBACE,OAAO,EAAE,kBAAkB;YAC7B;YACA;gBACE,QAAQ,KAAK,CAAC;
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAQM,SAAS,0CAA6C,OAAmC;IAC9F,IAAI,CAAC,SACH,OAAO;IAGT,IAAI,wBAAwB;IAC5B,OAAO,CAAC;QACN,IAAI,QAAsB;YACxB,GAAG,CAAC;YACJ;gBACE,EAAE,cAAc;YAClB;YACA;gBACE,OAAO,EAAE,kBAAkB;YAC7B;YACA;gBACE,IAAI,uBACF,QAAQ,KAAK,CAAC;qBAEd,wBAAwB;YAE5B;YACA;gBACE,wBAAwB;YAC1B;YACA;gBACE,OAAO;YACT;QACF;QAEA,QAAQ;QAER,IAAI,uBACF,EAAE,eAAe;IAErB;AACF","sources":["packages/@react-aria/interactions/src/createEventHandler.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 {BaseEvent} from '@react-types/shared';\nimport {SyntheticEvent} from 'react';\n\n/**\n * This function wraps a React event handler to make stopPropagation the default, and support continuePropagation instead.\n */\nexport function createEventHandler<T extends SyntheticEvent>(handler?: (e: BaseEvent<T>) => void): ((e: T) => void) | undefined {\n if (!handler) {\n return undefined;\n }\n\n let shouldStopPropagation = true;\n return (e: T) => {\n let event: BaseEvent<T> = {\n ...e,\n preventDefault() {\n e.preventDefault();\n },\n isDefaultPrevented() {\n return e.isDefaultPrevented();\n },\n stopPropagation() {\n if (shouldStopPropagation) {\n console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');\n } else {\n shouldStopPropagation = true;\n }\n },\n continuePropagation() {\n shouldStopPropagation = false;\n },\n isPropagationStopped() {\n return shouldStopPropagation;\n }\n };\n\n handler(event);\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n}\n"],"names":[],"version":3,"file":"createEventHandler.main.js.map"}
|
|
@@ -21,10 +21,14 @@
|
|
|
21
21
|
return e.isDefaultPrevented();
|
|
22
22
|
},
|
|
23
23
|
stopPropagation () {
|
|
24
|
-
console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');
|
|
24
|
+
if (shouldStopPropagation) console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');
|
|
25
|
+
else shouldStopPropagation = true;
|
|
25
26
|
},
|
|
26
27
|
continuePropagation () {
|
|
27
28
|
shouldStopPropagation = false;
|
|
29
|
+
},
|
|
30
|
+
isPropagationStopped () {
|
|
31
|
+
return shouldStopPropagation;
|
|
28
32
|
}
|
|
29
33
|
};
|
|
30
34
|
handler(event);
|
|
@@ -21,10 +21,14 @@
|
|
|
21
21
|
return e.isDefaultPrevented();
|
|
22
22
|
},
|
|
23
23
|
stopPropagation () {
|
|
24
|
-
console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');
|
|
24
|
+
if (shouldStopPropagation) console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');
|
|
25
|
+
else shouldStopPropagation = true;
|
|
25
26
|
},
|
|
26
27
|
continuePropagation () {
|
|
27
28
|
shouldStopPropagation = false;
|
|
29
|
+
},
|
|
30
|
+
isPropagationStopped () {
|
|
31
|
+
return shouldStopPropagation;
|
|
28
32
|
}
|
|
29
33
|
};
|
|
30
34
|
handler(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAQM,SAAS,0CAA6C,OAAmC;IAC9F,IAAI,CAAC,SACH,OAAO;IAGT,IAAI,wBAAwB;IAC5B,OAAO,CAAC;QACN,IAAI,QAAsB;YACxB,GAAG,CAAC;YACJ;gBACE,EAAE,cAAc;YAClB;YACA;gBACE,OAAO,EAAE,kBAAkB;YAC7B;YACA;gBACE,QAAQ,KAAK,CAAC;
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAQM,SAAS,0CAA6C,OAAmC;IAC9F,IAAI,CAAC,SACH,OAAO;IAGT,IAAI,wBAAwB;IAC5B,OAAO,CAAC;QACN,IAAI,QAAsB;YACxB,GAAG,CAAC;YACJ;gBACE,EAAE,cAAc;YAClB;YACA;gBACE,OAAO,EAAE,kBAAkB;YAC7B;YACA;gBACE,IAAI,uBACF,QAAQ,KAAK,CAAC;qBAEd,wBAAwB;YAE5B;YACA;gBACE,wBAAwB;YAC1B;YACA;gBACE,OAAO;YACT;QACF;QAEA,QAAQ;QAER,IAAI,uBACF,EAAE,eAAe;IAErB;AACF","sources":["packages/@react-aria/interactions/src/createEventHandler.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 {BaseEvent} from '@react-types/shared';\nimport {SyntheticEvent} from 'react';\n\n/**\n * This function wraps a React event handler to make stopPropagation the default, and support continuePropagation instead.\n */\nexport function createEventHandler<T extends SyntheticEvent>(handler?: (e: BaseEvent<T>) => void): ((e: T) => void) | undefined {\n if (!handler) {\n return undefined;\n }\n\n let shouldStopPropagation = true;\n return (e: T) => {\n let event: BaseEvent<T> = {\n ...e,\n preventDefault() {\n e.preventDefault();\n },\n isDefaultPrevented() {\n return e.isDefaultPrevented();\n },\n stopPropagation() {\n if (shouldStopPropagation) {\n console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');\n } else {\n shouldStopPropagation = true;\n }\n },\n continuePropagation() {\n shouldStopPropagation = false;\n },\n isPropagationStopped() {\n return shouldStopPropagation;\n }\n };\n\n handler(event);\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n}\n"],"names":[],"version":3,"file":"createEventHandler.module.js.map"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var $e77252a287ef94ab$exports = require("./useFocusVisible.main.js");
|
|
2
|
+
var $fCG8z$reactariautils = require("@react-aria/utils");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "focusSafely", () => $2833058fcd3993f5$export$80f3e147d781571c);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the 'License');
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function $2833058fcd3993f5$export$80f3e147d781571c(element) {
|
|
23
|
+
// If the user is interacting with a virtual cursor, e.g. screen reader, then
|
|
24
|
+
// wait until after any animated transitions that are currently occurring on
|
|
25
|
+
// the page before shifting focus. This avoids issues with VoiceOver on iOS
|
|
26
|
+
// causing the page to scroll when moving focus if the element is transitioning
|
|
27
|
+
// from off the screen.
|
|
28
|
+
const ownerDocument = (0, $fCG8z$reactariautils.getOwnerDocument)(element);
|
|
29
|
+
const activeElement = (0, $fCG8z$reactariautils.getActiveElement)(ownerDocument);
|
|
30
|
+
if ((0, $e77252a287ef94ab$exports.getInteractionModality)() === 'virtual') {
|
|
31
|
+
let lastFocusedElement = activeElement;
|
|
32
|
+
(0, $fCG8z$reactariautils.runAfterTransition)(()=>{
|
|
33
|
+
// If focus did not move and the element is still in the document, focus it.
|
|
34
|
+
if ((0, $fCG8z$reactariautils.getActiveElement)(ownerDocument) === lastFocusedElement && element.isConnected) (0, $fCG8z$reactariautils.focusWithoutScrolling)(element);
|
|
35
|
+
});
|
|
36
|
+
} else (0, $fCG8z$reactariautils.focusWithoutScrolling)(element);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=focusSafely.main.js.map
|
|
@@ -0,0 +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,MAAM,gBAAgB,CAAA,GAAA,sCAAe,EAAE;IACvC,IAAI,CAAA,GAAA,gDAAqB,QAAQ,WAAW;QAC1C,IAAI,qBAAqB;QACzB,CAAA,GAAA,wCAAiB,EAAE;YACjB,4EAA4E;YAC5E,IAAI,CAAA,GAAA,sCAAe,EAAE,mBAAmB,sBAAsB,QAAQ,WAAW,EAC/E,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) {\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 const activeElement = getActiveElement(ownerDocument);\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = activeElement;\n runAfterTransition(() => {\n // If focus did not move and the element is still in the document, focus it.\n if (getActiveElement(ownerDocument) === lastFocusedElement && element.isConnected) {\n focusWithoutScrolling(element);\n }\n });\n } else {\n focusWithoutScrolling(element);\n }\n}\n"],"names":[],"version":3,"file":"focusSafely.main.js.map"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {getInteractionModality as $507fabe10e71c6fb$export$630ff653c5ada6a9} from "./useFocusVisible.mjs";
|
|
2
|
+
import {getOwnerDocument as $k50bp$getOwnerDocument, getActiveElement as $k50bp$getActiveElement, runAfterTransition as $k50bp$runAfterTransition, focusWithoutScrolling as $k50bp$focusWithoutScrolling} from "@react-aria/utils";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the 'License');
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $3ad3f6e1647bc98d$export$80f3e147d781571c(element) {
|
|
17
|
+
// If the user is interacting with a virtual cursor, e.g. screen reader, then
|
|
18
|
+
// wait until after any animated transitions that are currently occurring on
|
|
19
|
+
// the page before shifting focus. This avoids issues with VoiceOver on iOS
|
|
20
|
+
// causing the page to scroll when moving focus if the element is transitioning
|
|
21
|
+
// from off the screen.
|
|
22
|
+
const ownerDocument = (0, $k50bp$getOwnerDocument)(element);
|
|
23
|
+
const activeElement = (0, $k50bp$getActiveElement)(ownerDocument);
|
|
24
|
+
if ((0, $507fabe10e71c6fb$export$630ff653c5ada6a9)() === 'virtual') {
|
|
25
|
+
let lastFocusedElement = activeElement;
|
|
26
|
+
(0, $k50bp$runAfterTransition)(()=>{
|
|
27
|
+
// If focus did not move and the element is still in the document, focus it.
|
|
28
|
+
if ((0, $k50bp$getActiveElement)(ownerDocument) === lastFocusedElement && element.isConnected) (0, $k50bp$focusWithoutScrolling)(element);
|
|
29
|
+
});
|
|
30
|
+
} else (0, $k50bp$focusWithoutScrolling)(element);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export {$3ad3f6e1647bc98d$export$80f3e147d781571c as focusSafely};
|
|
35
|
+
//# sourceMappingURL=focusSafely.module.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {getInteractionModality as $507fabe10e71c6fb$export$630ff653c5ada6a9} from "./useFocusVisible.module.js";
|
|
2
|
+
import {getOwnerDocument as $k50bp$getOwnerDocument, getActiveElement as $k50bp$getActiveElement, runAfterTransition as $k50bp$runAfterTransition, focusWithoutScrolling as $k50bp$focusWithoutScrolling} from "@react-aria/utils";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the 'License');
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $3ad3f6e1647bc98d$export$80f3e147d781571c(element) {
|
|
17
|
+
// If the user is interacting with a virtual cursor, e.g. screen reader, then
|
|
18
|
+
// wait until after any animated transitions that are currently occurring on
|
|
19
|
+
// the page before shifting focus. This avoids issues with VoiceOver on iOS
|
|
20
|
+
// causing the page to scroll when moving focus if the element is transitioning
|
|
21
|
+
// from off the screen.
|
|
22
|
+
const ownerDocument = (0, $k50bp$getOwnerDocument)(element);
|
|
23
|
+
const activeElement = (0, $k50bp$getActiveElement)(ownerDocument);
|
|
24
|
+
if ((0, $507fabe10e71c6fb$export$630ff653c5ada6a9)() === 'virtual') {
|
|
25
|
+
let lastFocusedElement = activeElement;
|
|
26
|
+
(0, $k50bp$runAfterTransition)(()=>{
|
|
27
|
+
// If focus did not move and the element is still in the document, focus it.
|
|
28
|
+
if ((0, $k50bp$getActiveElement)(ownerDocument) === lastFocusedElement && element.isConnected) (0, $k50bp$focusWithoutScrolling)(element);
|
|
29
|
+
});
|
|
30
|
+
} else (0, $k50bp$focusWithoutScrolling)(element);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export {$3ad3f6e1647bc98d$export$80f3e147d781571c as focusSafely};
|
|
35
|
+
//# sourceMappingURL=focusSafely.module.js.map
|
|
@@ -0,0 +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,MAAM,gBAAgB,CAAA,GAAA,uBAAe,EAAE;IACvC,IAAI,CAAA,GAAA,yCAAqB,QAAQ,WAAW;QAC1C,IAAI,qBAAqB;QACzB,CAAA,GAAA,yBAAiB,EAAE;YACjB,4EAA4E;YAC5E,IAAI,CAAA,GAAA,uBAAe,EAAE,mBAAmB,sBAAsB,QAAQ,WAAW,EAC/E,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) {\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 const activeElement = getActiveElement(ownerDocument);\n if (getInteractionModality() === 'virtual') {\n let lastFocusedElement = activeElement;\n runAfterTransition(() => {\n // If focus did not move and the element is still in the document, focus it.\n if (getActiveElement(ownerDocument) === lastFocusedElement && 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/import.mjs
CHANGED
|
@@ -10,6 +10,8 @@ import {useMove as $e8a7022cf87cba2a$export$36da96379f79f245} from "./useMove.mj
|
|
|
10
10
|
import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.mjs";
|
|
11
11
|
import {useScrollWheel as $7d0a636d7a4dcefd$export$2123ff2b87c81ca} from "./useScrollWheel.mjs";
|
|
12
12
|
import {useLongPress as $8a26561d2877236e$export$c24ed0104d07eab9} from "./useLongPress.mjs";
|
|
13
|
+
import {Focusable as $f645667febf57a63$export$35a3bebf7ef2d934, FocusableContext as $f645667febf57a63$export$f9762fab77588ecb, FocusableProvider as $f645667febf57a63$export$13f3202a3e5ddd5, useFocusable as $f645667febf57a63$export$4c014de7c8940b4c} from "./useFocusable.mjs";
|
|
14
|
+
import {focusSafely as $3ad3f6e1647bc98d$export$80f3e147d781571c} from "./focusSafely.mjs";
|
|
13
15
|
|
|
14
16
|
/*
|
|
15
17
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -35,5 +37,7 @@ import {useLongPress as $8a26561d2877236e$export$c24ed0104d07eab9} from "./useLo
|
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export {$3b117e43dc0ca95d$export$27c701ed9e449e99 as Pressable, $f1ab8c75478c6f73$export$3351871ee4b288b8 as PressResponder, $f1ab8c75478c6f73$export$cf75428e0b9ed1ea as ClearPressResponder, $a1ea59d68270f0dd$export$f8168d8dd8fd66e6 as useFocus, $507fabe10e71c6fb$export$b9b3dfddab17db27 as isFocusVisible, $507fabe10e71c6fb$export$630ff653c5ada6a9 as getInteractionModality, $507fabe10e71c6fb$export$8397ddfc504fdb9a as setInteractionModality, $507fabe10e71c6fb$export$2f1888112f558a7d as addWindowFocusTracking, $507fabe10e71c6fb$export$98e20ec92f614cfe as useInteractionModality, $507fabe10e71c6fb$export$ffd9e5021c1fb2d6 as useFocusVisible, $507fabe10e71c6fb$export$ec71b4b83ac08ec3 as useFocusVisibleListener, $9ab94262bd0047c7$export$420e68273165f4ec as useFocusWithin, $6179b936705e76d3$export$ae780daf29e6d456 as useHover, $e0b6e0b68ec7f50f$export$872b660ac5a1ff98 as useInteractOutside, $46d819fcbaf35654$export$8f71654801c2f7cd as useKeyboard, $e8a7022cf87cba2a$export$36da96379f79f245 as useMove, $f6c31cce2adf654f$export$45712eceda6fad21 as usePress, $7d0a636d7a4dcefd$export$2123ff2b87c81ca as useScrollWheel, $8a26561d2877236e$export$c24ed0104d07eab9 as useLongPress, $f645667febf57a63$export$4c014de7c8940b4c as useFocusable, $f645667febf57a63$export$13f3202a3e5ddd5 as FocusableProvider, $f645667febf57a63$export$35a3bebf7ef2d934 as Focusable, $f645667febf57a63$export$f9762fab77588ecb as FocusableContext, $3ad3f6e1647bc98d$export$80f3e147d781571c as focusSafely};
|
|
39
43
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -10,6 +10,8 @@ var $c09386fc48fa427d$exports = require("./useMove.main.js");
|
|
|
10
10
|
var $0294ea432cd92340$exports = require("./usePress.main.js");
|
|
11
11
|
var $a3dbce0aed7087e2$exports = require("./useScrollWheel.main.js");
|
|
12
12
|
var $3cd7b5d0eebf0ca9$exports = require("./useLongPress.main.js");
|
|
13
|
+
var $15f8fd80892557ff$exports = require("./useFocusable.main.js");
|
|
14
|
+
var $2833058fcd3993f5$exports = require("./focusSafely.main.js");
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
function $parcel$export(e, n, v, s) {
|
|
@@ -35,6 +37,11 @@ $parcel$export(module.exports, "useMove", () => $c09386fc48fa427d$exports.useMov
|
|
|
35
37
|
$parcel$export(module.exports, "usePress", () => $0294ea432cd92340$exports.usePress);
|
|
36
38
|
$parcel$export(module.exports, "useScrollWheel", () => $a3dbce0aed7087e2$exports.useScrollWheel);
|
|
37
39
|
$parcel$export(module.exports, "useLongPress", () => $3cd7b5d0eebf0ca9$exports.useLongPress);
|
|
40
|
+
$parcel$export(module.exports, "useFocusable", () => $15f8fd80892557ff$exports.useFocusable);
|
|
41
|
+
$parcel$export(module.exports, "FocusableProvider", () => $15f8fd80892557ff$exports.FocusableProvider);
|
|
42
|
+
$parcel$export(module.exports, "Focusable", () => $15f8fd80892557ff$exports.Focusable);
|
|
43
|
+
$parcel$export(module.exports, "FocusableContext", () => $15f8fd80892557ff$exports.FocusableContext);
|
|
44
|
+
$parcel$export(module.exports, "focusSafely", () => $2833058fcd3993f5$exports.focusSafely);
|
|
38
45
|
/*
|
|
39
46
|
* Copyright 2020 Adobe. All rights reserved.
|
|
40
47
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -59,4 +66,6 @@ $parcel$export(module.exports, "useLongPress", () => $3cd7b5d0eebf0ca9$exports.u
|
|
|
59
66
|
|
|
60
67
|
|
|
61
68
|
|
|
69
|
+
|
|
70
|
+
|
|
62
71
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
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 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"}
|
package/dist/module.js
CHANGED
|
@@ -10,6 +10,8 @@ import {useMove as $e8a7022cf87cba2a$export$36da96379f79f245} from "./useMove.mo
|
|
|
10
10
|
import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.module.js";
|
|
11
11
|
import {useScrollWheel as $7d0a636d7a4dcefd$export$2123ff2b87c81ca} from "./useScrollWheel.module.js";
|
|
12
12
|
import {useLongPress as $8a26561d2877236e$export$c24ed0104d07eab9} from "./useLongPress.module.js";
|
|
13
|
+
import {Focusable as $f645667febf57a63$export$35a3bebf7ef2d934, FocusableContext as $f645667febf57a63$export$f9762fab77588ecb, FocusableProvider as $f645667febf57a63$export$13f3202a3e5ddd5, useFocusable as $f645667febf57a63$export$4c014de7c8940b4c} from "./useFocusable.module.js";
|
|
14
|
+
import {focusSafely as $3ad3f6e1647bc98d$export$80f3e147d781571c} from "./focusSafely.module.js";
|
|
13
15
|
|
|
14
16
|
/*
|
|
15
17
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -35,5 +37,7 @@ import {useLongPress as $8a26561d2877236e$export$c24ed0104d07eab9} from "./useLo
|
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export {$3b117e43dc0ca95d$export$27c701ed9e449e99 as Pressable, $f1ab8c75478c6f73$export$3351871ee4b288b8 as PressResponder, $f1ab8c75478c6f73$export$cf75428e0b9ed1ea as ClearPressResponder, $a1ea59d68270f0dd$export$f8168d8dd8fd66e6 as useFocus, $507fabe10e71c6fb$export$b9b3dfddab17db27 as isFocusVisible, $507fabe10e71c6fb$export$630ff653c5ada6a9 as getInteractionModality, $507fabe10e71c6fb$export$8397ddfc504fdb9a as setInteractionModality, $507fabe10e71c6fb$export$2f1888112f558a7d as addWindowFocusTracking, $507fabe10e71c6fb$export$98e20ec92f614cfe as useInteractionModality, $507fabe10e71c6fb$export$ffd9e5021c1fb2d6 as useFocusVisible, $507fabe10e71c6fb$export$ec71b4b83ac08ec3 as useFocusVisibleListener, $9ab94262bd0047c7$export$420e68273165f4ec as useFocusWithin, $6179b936705e76d3$export$ae780daf29e6d456 as useHover, $e0b6e0b68ec7f50f$export$872b660ac5a1ff98 as useInteractOutside, $46d819fcbaf35654$export$8f71654801c2f7cd as useKeyboard, $e8a7022cf87cba2a$export$36da96379f79f245 as useMove, $f6c31cce2adf654f$export$45712eceda6fad21 as usePress, $7d0a636d7a4dcefd$export$2123ff2b87c81ca as useScrollWheel, $8a26561d2877236e$export$c24ed0104d07eab9 as useLongPress, $f645667febf57a63$export$4c014de7c8940b4c as useFocusable, $f645667febf57a63$export$13f3202a3e5ddd5 as FocusableProvider, $f645667febf57a63$export$35a3bebf7ef2d934 as Focusable, $f645667febf57a63$export$f9762fab77588ecb as FocusableContext, $3ad3f6e1647bc98d$export$80f3e147d781571c as focusSafely};
|
|
39
43
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
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 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"}
|
|
@@ -34,8 +34,9 @@ function $f7e14e656343df57$export$16a4697467175487(target) {
|
|
|
34
34
|
} else if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
35
35
|
// If not iOS, store the target's original user-select and change to user-select: none
|
|
36
36
|
// Ignore state since it doesn't apply for non iOS
|
|
37
|
-
|
|
38
|
-
target.style
|
|
37
|
+
let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
|
|
38
|
+
$f7e14e656343df57$var$modifiedElementMap.set(target, target.style[property]);
|
|
39
|
+
target.style[property] = 'none';
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
function $f7e14e656343df57$export$b0d6fa1ab32e3295(target) {
|
|
@@ -64,7 +65,8 @@ function $f7e14e656343df57$export$b0d6fa1ab32e3295(target) {
|
|
|
64
65
|
{
|
|
65
66
|
if (target && $f7e14e656343df57$var$modifiedElementMap.has(target)) {
|
|
66
67
|
let targetOldUserSelect = $f7e14e656343df57$var$modifiedElementMap.get(target);
|
|
67
|
-
|
|
68
|
+
let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
|
|
69
|
+
if (target.style[property] === 'none') target.style[property] = targetOldUserSelect;
|
|
68
70
|
if (target.getAttribute('style') === '') target.removeAttribute('style');
|
|
69
71
|
$f7e14e656343df57$var$modifiedElementMap.delete(target);
|
|
70
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;AAmBD,0GAA0G;AAC1G,4HAA4H;AAC5H,IAAI,8BAAe;AACnB,IAAI,wCAAkB;AACtB,IAAI,2CAAqB,IAAI;AAEtB,SAAS,0CAAqB,MAAgB;IACnD,IAAI,CAAA,GAAA,2BAAI,KAAK;QACX,IAAI,gCAAU,WAAW;YAEvB,MAAM,iBAAiB,CAAA,GAAA,sCAAe,EAAE;YACxC,wCAAkB,eAAe,eAAe,CAAC,KAAK,CAAC,gBAAgB;YACvE,eAAe,eAAe,CAAC,KAAK,CAAC,gBAAgB,GAAG;QAC1D;QAEA,8BAAQ;IACV,OAAO,IAAI,kBAAkB,eAAe,kBAAkB,YAAY;QACxE,sFAAsF;QACtF,kDAAkD;QAClD,yCAAmB,GAAG,CAAC,QAAQ,OAAO,KAAK,CAAC,
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;AAmBD,0GAA0G;AAC1G,4HAA4H;AAC5H,IAAI,8BAAe;AACnB,IAAI,wCAAkB;AACtB,IAAI,2CAAqB,IAAI;AAEtB,SAAS,0CAAqB,MAAgB;IACnD,IAAI,CAAA,GAAA,2BAAI,KAAK;QACX,IAAI,gCAAU,WAAW;YAEvB,MAAM,iBAAiB,CAAA,GAAA,sCAAe,EAAE;YACxC,wCAAkB,eAAe,eAAe,CAAC,KAAK,CAAC,gBAAgB;YACvE,eAAe,eAAe,CAAC,KAAK,CAAC,gBAAgB,GAAG;QAC1D;QAEA,8BAAQ;IACV,OAAO,IAAI,kBAAkB,eAAe,kBAAkB,YAAY;QACxE,sFAAsF;QACtF,kDAAkD;QAClD,IAAI,WAAW,gBAAgB,OAAO,KAAK,GAAG,eAAe;QAC7D,yCAAmB,GAAG,CAAC,QAAQ,OAAO,KAAK,CAAC,SAAS;QACrD,OAAO,KAAK,CAAC,SAAS,GAAG;IAC3B;AACF;AAEO,SAAS,0CAAqB,MAAgB;IACnD,IAAI,CAAA,GAAA,2BAAI,KAAK;QACX,0DAA0D;QAC1D,sEAAsE;QACtE,IAAI,gCAAU,YACZ;QAGF,8BAAQ;QAER,uEAAuE;QACvE,+DAA+D;QAC/D,WAAW;YACT,uEAAuE;YACvE,oEAAoE;YACpE,CAAA,GAAA,wCAAiB,EAAE;gBACjB,wBAAwB;gBACxB,IAAI,gCAAU,aAAa;oBAEzB,MAAM,iBAAiB,CAAA,GAAA,sCAAe,EAAE;oBACxC,IAAI,eAAe,eAAe,CAAC,KAAK,CAAC,gBAAgB,KAAK,QAC5D,eAAe,eAAe,CAAC,KAAK,CAAC,gBAAgB,GAAG,yCAAmB;oBAG7E,wCAAkB;oBAClB,8BAAQ;gBACV;YACF;QACF,GAAG;IACL,OAAO,IAAI,kBAAkB,eAAe,kBAAkB,YAC5D,+DAA+D;IAC/D,kDAAkD;IAClD;QAAA,IAAI,UAAU,yCAAmB,GAAG,CAAC,SAAS;YAC5C,IAAI,sBAAsB,yCAAmB,GAAG,CAAC;YACjD,IAAI,WAAW,gBAAgB,OAAO,KAAK,GAAG,eAAe;YAE7D,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,QAC7B,OAAO,KAAK,CAAC,SAAS,GAAG;YAG3B,IAAI,OAAO,YAAY,CAAC,aAAa,IACnC,OAAO,eAAe,CAAC;YAEzB,yCAAmB,MAAM,CAAC;QAC5B;IAAA;AAEJ","sources":["packages/@react-aria/interactions/src/textSelection.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 {getOwnerDocument, isIOS, runAfterTransition} from '@react-aria/utils';\n\n// Safari on iOS starts selecting text on long press. The only way to avoid this, it seems,\n// is to add user-select: none to the entire page. Adding it to the pressable element prevents\n// that element from being selected, but nearby elements may still receive selection. We add\n// user-select: none on touch start, and remove it again on touch end to prevent this.\n// This must be implemented using global state to avoid race conditions between multiple elements.\n\n// There are three possible states due to the delay before removing user-select: none after\n// pointer up. The 'default' state always transitions to the 'disabled' state, which transitions\n// to 'restoring'. The 'restoring' state can either transition back to 'disabled' or 'default'.\n\n// For non-iOS devices, we apply user-select: none to the pressed element instead to avoid possible\n// performance issues that arise from applying and removing user-select: none to the entire page\n// (see https://github.com/adobe/react-spectrum/issues/1609).\ntype State = 'default' | 'disabled' | 'restoring';\n\n// Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element\n// rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually\nlet state: State = 'default';\nlet savedUserSelect = '';\nlet modifiedElementMap = new WeakMap<Element, string>();\n\nexport function disableTextSelection(target?: Element) {\n if (isIOS()) {\n if (state === 'default') {\n \n const documentObject = getOwnerDocument(target);\n savedUserSelect = documentObject.documentElement.style.webkitUserSelect;\n documentObject.documentElement.style.webkitUserSelect = 'none';\n }\n\n state = 'disabled';\n } else if (target instanceof HTMLElement || target instanceof SVGElement) {\n // If not iOS, store the target's original user-select and change to user-select: none\n // Ignore state since it doesn't apply for non iOS\n let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';\n modifiedElementMap.set(target, target.style[property]);\n target.style[property] = 'none';\n }\n}\n\nexport function restoreTextSelection(target?: Element) {\n if (isIOS()) {\n // If the state is already default, there's nothing to do.\n // If it is restoring, then there's no need to queue a second restore.\n if (state !== 'disabled') {\n return;\n }\n\n state = 'restoring';\n\n // There appears to be a delay on iOS where selection still might occur\n // after pointer up, so wait a bit before removing user-select.\n setTimeout(() => {\n // Wait for any CSS transitions to complete so we don't recompute style\n // for the whole page in the middle of the animation and cause jank.\n runAfterTransition(() => {\n // Avoid race conditions\n if (state === 'restoring') {\n \n const documentObject = getOwnerDocument(target);\n if (documentObject.documentElement.style.webkitUserSelect === 'none') {\n documentObject.documentElement.style.webkitUserSelect = savedUserSelect || '';\n }\n\n savedUserSelect = '';\n state = 'default';\n }\n });\n }, 300);\n } else if (target instanceof HTMLElement || target instanceof SVGElement) {\n // If not iOS, restore the target's original user-select if any\n // Ignore state since it doesn't apply for non iOS\n if (target && modifiedElementMap.has(target)) {\n let targetOldUserSelect = modifiedElementMap.get(target) as string;\n let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';\n\n if (target.style[property] === 'none') {\n target.style[property] = targetOldUserSelect;\n }\n\n if (target.getAttribute('style') === '') {\n target.removeAttribute('style');\n }\n modifiedElementMap.delete(target);\n }\n }\n}\n"],"names":[],"version":3,"file":"textSelection.main.js.map"}
|