@react-aria/interactions 3.27.1 → 3.28.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.
Files changed (118) hide show
  1. package/dist/import.mjs +21 -15
  2. package/dist/main.js +45 -39
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +21 -15
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +31 -0
  7. package/package.json +16 -15
  8. package/src/index.ts +30 -34
  9. package/dist/PressResponder.main.js +0 -61
  10. package/dist/PressResponder.main.js.map +0 -1
  11. package/dist/PressResponder.mjs +0 -51
  12. package/dist/PressResponder.module.js +0 -51
  13. package/dist/PressResponder.module.js.map +0 -1
  14. package/dist/Pressable.main.js +0 -69
  15. package/dist/Pressable.main.js.map +0 -1
  16. package/dist/Pressable.mjs +0 -60
  17. package/dist/Pressable.module.js +0 -60
  18. package/dist/Pressable.module.js.map +0 -1
  19. package/dist/context.main.js +0 -30
  20. package/dist/context.main.js.map +0 -1
  21. package/dist/context.mjs +0 -21
  22. package/dist/context.module.js +0 -21
  23. package/dist/context.module.js.map +0 -1
  24. package/dist/createEventHandler.main.js +0 -46
  25. package/dist/createEventHandler.main.js.map +0 -1
  26. package/dist/createEventHandler.mjs +0 -41
  27. package/dist/createEventHandler.module.js +0 -41
  28. package/dist/createEventHandler.module.js.map +0 -1
  29. package/dist/focusSafely.main.js +0 -41
  30. package/dist/focusSafely.main.js.map +0 -1
  31. package/dist/focusSafely.mjs +0 -36
  32. package/dist/focusSafely.module.js +0 -36
  33. package/dist/focusSafely.module.js.map +0 -1
  34. package/dist/textSelection.main.js +0 -77
  35. package/dist/textSelection.main.js.map +0 -1
  36. package/dist/textSelection.mjs +0 -71
  37. package/dist/textSelection.module.js +0 -71
  38. package/dist/textSelection.module.js.map +0 -1
  39. package/dist/types.d.ts +0 -255
  40. package/dist/types.d.ts.map +0 -1
  41. package/dist/useFocus.main.js +0 -66
  42. package/dist/useFocus.main.js.map +0 -1
  43. package/dist/useFocus.mjs +0 -61
  44. package/dist/useFocus.module.js +0 -61
  45. package/dist/useFocus.module.js.map +0 -1
  46. package/dist/useFocusVisible.main.js +0 -267
  47. package/dist/useFocusVisible.main.js.map +0 -1
  48. package/dist/useFocusVisible.mjs +0 -255
  49. package/dist/useFocusVisible.module.js +0 -255
  50. package/dist/useFocusVisible.module.js.map +0 -1
  51. package/dist/useFocusWithin.main.js +0 -107
  52. package/dist/useFocusWithin.main.js.map +0 -1
  53. package/dist/useFocusWithin.mjs +0 -102
  54. package/dist/useFocusWithin.module.js +0 -102
  55. package/dist/useFocusWithin.module.js.map +0 -1
  56. package/dist/useFocusable.main.js +0 -113
  57. package/dist/useFocusable.main.js.map +0 -1
  58. package/dist/useFocusable.mjs +0 -101
  59. package/dist/useFocusable.module.js +0 -101
  60. package/dist/useFocusable.module.js.map +0 -1
  61. package/dist/useHover.main.js +0 -159
  62. package/dist/useHover.main.js.map +0 -1
  63. package/dist/useHover.mjs +0 -154
  64. package/dist/useHover.module.js +0 -154
  65. package/dist/useHover.module.js.map +0 -1
  66. package/dist/useInteractOutside.main.js +0 -107
  67. package/dist/useInteractOutside.main.js.map +0 -1
  68. package/dist/useInteractOutside.mjs +0 -102
  69. package/dist/useInteractOutside.module.js +0 -102
  70. package/dist/useInteractOutside.module.js.map +0 -1
  71. package/dist/useKeyboard.main.js +0 -30
  72. package/dist/useKeyboard.main.js.map +0 -1
  73. package/dist/useKeyboard.mjs +0 -25
  74. package/dist/useKeyboard.module.js +0 -25
  75. package/dist/useKeyboard.module.js.map +0 -1
  76. package/dist/useLongPress.main.js +0 -86
  77. package/dist/useLongPress.main.js.map +0 -1
  78. package/dist/useLongPress.mjs +0 -81
  79. package/dist/useLongPress.module.js +0 -81
  80. package/dist/useLongPress.module.js.map +0 -1
  81. package/dist/useMove.main.js +0 -272
  82. package/dist/useMove.main.js.map +0 -1
  83. package/dist/useMove.mjs +0 -267
  84. package/dist/useMove.module.js +0 -267
  85. package/dist/useMove.module.js.map +0 -1
  86. package/dist/usePress.main.js +0 -763
  87. package/dist/usePress.main.js.map +0 -1
  88. package/dist/usePress.mjs +0 -758
  89. package/dist/usePress.module.js +0 -758
  90. package/dist/usePress.module.js.map +0 -1
  91. package/dist/useScrollWheel.main.js +0 -41
  92. package/dist/useScrollWheel.main.js.map +0 -1
  93. package/dist/useScrollWheel.mjs +0 -36
  94. package/dist/useScrollWheel.module.js +0 -36
  95. package/dist/useScrollWheel.module.js.map +0 -1
  96. package/dist/utils.main.js +0 -164
  97. package/dist/utils.main.js.map +0 -1
  98. package/dist/utils.mjs +0 -155
  99. package/dist/utils.module.js +0 -155
  100. package/dist/utils.module.js.map +0 -1
  101. package/src/PressResponder.tsx +0 -67
  102. package/src/Pressable.tsx +0 -97
  103. package/src/context.ts +0 -23
  104. package/src/createEventHandler.ts +0 -55
  105. package/src/focusSafely.ts +0 -49
  106. package/src/textSelection.ts +0 -101
  107. package/src/useFocus.ts +0 -88
  108. package/src/useFocusVisible.ts +0 -359
  109. package/src/useFocusWithin.ts +0 -134
  110. package/src/useFocusable.tsx +0 -191
  111. package/src/useHover.ts +0 -222
  112. package/src/useInteractOutside.ts +0 -143
  113. package/src/useKeyboard.ts +0 -36
  114. package/src/useLongPress.ts +0 -135
  115. package/src/useMove.ts +0 -259
  116. package/src/usePress.ts +0 -1095
  117. package/src/useScrollWheel.ts +0 -41
  118. package/src/utils.ts +0 -175
@@ -1,77 +0,0 @@
1
- var $20aJV$reactariautils = require("@react-aria/utils");
2
-
3
-
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
-
8
- $parcel$export(module.exports, "disableTextSelection", () => $f7e14e656343df57$export$16a4697467175487);
9
- $parcel$export(module.exports, "restoreTextSelection", () => $f7e14e656343df57$export$b0d6fa1ab32e3295);
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
- // Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
22
- // rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
23
- let $f7e14e656343df57$var$state = 'default';
24
- let $f7e14e656343df57$var$savedUserSelect = '';
25
- let $f7e14e656343df57$var$modifiedElementMap = new WeakMap();
26
- function $f7e14e656343df57$export$16a4697467175487(target) {
27
- if ((0, $20aJV$reactariautils.isIOS)()) {
28
- if ($f7e14e656343df57$var$state === 'default') {
29
- const documentObject = (0, $20aJV$reactariautils.getOwnerDocument)(target);
30
- $f7e14e656343df57$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
31
- documentObject.documentElement.style.webkitUserSelect = 'none';
32
- }
33
- $f7e14e656343df57$var$state = 'disabled';
34
- } else if (target instanceof HTMLElement || target instanceof SVGElement) {
35
- // If not iOS, store the target's original user-select and change to user-select: none
36
- // Ignore state since it doesn't apply for non iOS
37
- let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
38
- $f7e14e656343df57$var$modifiedElementMap.set(target, target.style[property]);
39
- target.style[property] = 'none';
40
- }
41
- }
42
- function $f7e14e656343df57$export$b0d6fa1ab32e3295(target) {
43
- if ((0, $20aJV$reactariautils.isIOS)()) {
44
- // If the state is already default, there's nothing to do.
45
- // If it is restoring, then there's no need to queue a second restore.
46
- if ($f7e14e656343df57$var$state !== 'disabled') return;
47
- $f7e14e656343df57$var$state = 'restoring';
48
- // There appears to be a delay on iOS where selection still might occur
49
- // after pointer up, so wait a bit before removing user-select.
50
- setTimeout(()=>{
51
- // Wait for any CSS transitions to complete so we don't recompute style
52
- // for the whole page in the middle of the animation and cause jank.
53
- (0, $20aJV$reactariautils.runAfterTransition)(()=>{
54
- // Avoid race conditions
55
- if ($f7e14e656343df57$var$state === 'restoring') {
56
- const documentObject = (0, $20aJV$reactariautils.getOwnerDocument)(target);
57
- if (documentObject.documentElement.style.webkitUserSelect === 'none') documentObject.documentElement.style.webkitUserSelect = $f7e14e656343df57$var$savedUserSelect || '';
58
- $f7e14e656343df57$var$savedUserSelect = '';
59
- $f7e14e656343df57$var$state = 'default';
60
- }
61
- });
62
- }, 300);
63
- } else if (target instanceof HTMLElement || target instanceof SVGElement) // If not iOS, restore the target's original user-select if any
64
- // Ignore state since it doesn't apply for non iOS
65
- {
66
- if (target && $f7e14e656343df57$var$modifiedElementMap.has(target)) {
67
- let targetOldUserSelect = $f7e14e656343df57$var$modifiedElementMap.get(target);
68
- let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
69
- if (target.style[property] === 'none') target.style[property] = targetOldUserSelect;
70
- if (target.getAttribute('style') === '') target.removeAttribute('style');
71
- $f7e14e656343df57$var$modifiedElementMap.delete(target);
72
- }
73
- }
74
- }
75
-
76
-
77
- //# sourceMappingURL=textSelection.main.js.map
@@ -1 +0,0 @@
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): void {\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): void {\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"}
@@ -1,71 +0,0 @@
1
- import {isIOS as $7R18e$isIOS, getOwnerDocument as $7R18e$getOwnerDocument, runAfterTransition as $7R18e$runAfterTransition} from "@react-aria/utils";
2
-
3
- /*
4
- * Copyright 2020 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- // Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
15
- // rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
16
- let $14c0b72509d70225$var$state = 'default';
17
- let $14c0b72509d70225$var$savedUserSelect = '';
18
- let $14c0b72509d70225$var$modifiedElementMap = new WeakMap();
19
- function $14c0b72509d70225$export$16a4697467175487(target) {
20
- if ((0, $7R18e$isIOS)()) {
21
- if ($14c0b72509d70225$var$state === 'default') {
22
- const documentObject = (0, $7R18e$getOwnerDocument)(target);
23
- $14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
24
- documentObject.documentElement.style.webkitUserSelect = 'none';
25
- }
26
- $14c0b72509d70225$var$state = 'disabled';
27
- } else if (target instanceof HTMLElement || target instanceof SVGElement) {
28
- // If not iOS, store the target's original user-select and change to user-select: none
29
- // Ignore state since it doesn't apply for non iOS
30
- let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
31
- $14c0b72509d70225$var$modifiedElementMap.set(target, target.style[property]);
32
- target.style[property] = 'none';
33
- }
34
- }
35
- function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
36
- if ((0, $7R18e$isIOS)()) {
37
- // If the state is already default, there's nothing to do.
38
- // If it is restoring, then there's no need to queue a second restore.
39
- if ($14c0b72509d70225$var$state !== 'disabled') return;
40
- $14c0b72509d70225$var$state = 'restoring';
41
- // There appears to be a delay on iOS where selection still might occur
42
- // after pointer up, so wait a bit before removing user-select.
43
- setTimeout(()=>{
44
- // Wait for any CSS transitions to complete so we don't recompute style
45
- // for the whole page in the middle of the animation and cause jank.
46
- (0, $7R18e$runAfterTransition)(()=>{
47
- // Avoid race conditions
48
- if ($14c0b72509d70225$var$state === 'restoring') {
49
- const documentObject = (0, $7R18e$getOwnerDocument)(target);
50
- if (documentObject.documentElement.style.webkitUserSelect === 'none') documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || '';
51
- $14c0b72509d70225$var$savedUserSelect = '';
52
- $14c0b72509d70225$var$state = 'default';
53
- }
54
- });
55
- }, 300);
56
- } else if (target instanceof HTMLElement || target instanceof SVGElement) // If not iOS, restore the target's original user-select if any
57
- // Ignore state since it doesn't apply for non iOS
58
- {
59
- if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
60
- let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
61
- let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
62
- if (target.style[property] === 'none') target.style[property] = targetOldUserSelect;
63
- if (target.getAttribute('style') === '') target.removeAttribute('style');
64
- $14c0b72509d70225$var$modifiedElementMap.delete(target);
65
- }
66
- }
67
- }
68
-
69
-
70
- export {$14c0b72509d70225$export$16a4697467175487 as disableTextSelection, $14c0b72509d70225$export$b0d6fa1ab32e3295 as restoreTextSelection};
71
- //# sourceMappingURL=textSelection.module.js.map
@@ -1,71 +0,0 @@
1
- import {isIOS as $7R18e$isIOS, getOwnerDocument as $7R18e$getOwnerDocument, runAfterTransition as $7R18e$runAfterTransition} from "@react-aria/utils";
2
-
3
- /*
4
- * Copyright 2020 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- // Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
15
- // rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
16
- let $14c0b72509d70225$var$state = 'default';
17
- let $14c0b72509d70225$var$savedUserSelect = '';
18
- let $14c0b72509d70225$var$modifiedElementMap = new WeakMap();
19
- function $14c0b72509d70225$export$16a4697467175487(target) {
20
- if ((0, $7R18e$isIOS)()) {
21
- if ($14c0b72509d70225$var$state === 'default') {
22
- const documentObject = (0, $7R18e$getOwnerDocument)(target);
23
- $14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
24
- documentObject.documentElement.style.webkitUserSelect = 'none';
25
- }
26
- $14c0b72509d70225$var$state = 'disabled';
27
- } else if (target instanceof HTMLElement || target instanceof SVGElement) {
28
- // If not iOS, store the target's original user-select and change to user-select: none
29
- // Ignore state since it doesn't apply for non iOS
30
- let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
31
- $14c0b72509d70225$var$modifiedElementMap.set(target, target.style[property]);
32
- target.style[property] = 'none';
33
- }
34
- }
35
- function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
36
- if ((0, $7R18e$isIOS)()) {
37
- // If the state is already default, there's nothing to do.
38
- // If it is restoring, then there's no need to queue a second restore.
39
- if ($14c0b72509d70225$var$state !== 'disabled') return;
40
- $14c0b72509d70225$var$state = 'restoring';
41
- // There appears to be a delay on iOS where selection still might occur
42
- // after pointer up, so wait a bit before removing user-select.
43
- setTimeout(()=>{
44
- // Wait for any CSS transitions to complete so we don't recompute style
45
- // for the whole page in the middle of the animation and cause jank.
46
- (0, $7R18e$runAfterTransition)(()=>{
47
- // Avoid race conditions
48
- if ($14c0b72509d70225$var$state === 'restoring') {
49
- const documentObject = (0, $7R18e$getOwnerDocument)(target);
50
- if (documentObject.documentElement.style.webkitUserSelect === 'none') documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || '';
51
- $14c0b72509d70225$var$savedUserSelect = '';
52
- $14c0b72509d70225$var$state = 'default';
53
- }
54
- });
55
- }, 300);
56
- } else if (target instanceof HTMLElement || target instanceof SVGElement) // If not iOS, restore the target's original user-select if any
57
- // Ignore state since it doesn't apply for non iOS
58
- {
59
- if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
60
- let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
61
- let property = 'userSelect' in target.style ? 'userSelect' : 'webkitUserSelect';
62
- if (target.style[property] === 'none') target.style[property] = targetOldUserSelect;
63
- if (target.getAttribute('style') === '') target.removeAttribute('style');
64
- $14c0b72509d70225$var$modifiedElementMap.delete(target);
65
- }
66
- }
67
- }
68
-
69
-
70
- export {$14c0b72509d70225$export$16a4697467175487 as disableTextSelection, $14c0b72509d70225$export$b0d6fa1ab32e3295 as restoreTextSelection};
71
- //# sourceMappingURL=textSelection.module.js.map
@@ -1 +0,0 @@
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,YAAI,KAAK;QACX,IAAI,gCAAU,WAAW;YAEvB,MAAM,iBAAiB,CAAA,GAAA,uBAAe,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,YAAI,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,yBAAiB,EAAE;gBACjB,wBAAwB;gBACxB,IAAI,gCAAU,aAAa;oBAEzB,MAAM,iBAAiB,CAAA,GAAA,uBAAe,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): void {\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): void {\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.module.js.map"}
package/dist/types.d.ts DELETED
@@ -1,255 +0,0 @@
1
- import { DOMAttributes, PressEvents, RefObject, FocusableElement, FocusEvents, KeyboardEvents, FocusableDOMProps, FocusableProps, PointerType, HoverEvents, MoveEvents, ScrollEvents, LongPressEvent } from "@react-types/shared";
2
- import React, { MutableRefObject, ReactElement, ReactNode, JSX, FocusEvent } from "react";
3
- export interface PressProps extends PressEvents {
4
- /** Whether the target is in a controlled press state (e.g. an overlay it triggers is open). */
5
- isPressed?: boolean;
6
- /** Whether the press events should be disabled. */
7
- isDisabled?: boolean;
8
- /** Whether the target should not receive focus on press. */
9
- preventFocusOnPress?: boolean;
10
- /**
11
- * Whether press events should be canceled when the pointer leaves the target while pressed.
12
- * By default, this is `false`, which means if the pointer returns back over the target while
13
- * still pressed, onPressStart will be fired again. If set to `true`, the press is canceled
14
- * when the pointer leaves the target and onPressStart will not be fired if the pointer returns.
15
- */
16
- shouldCancelOnPointerExit?: boolean;
17
- /** Whether text selection should be enabled on the pressable element. */
18
- allowTextSelectionOnPress?: boolean;
19
- }
20
- export interface PressHookProps extends PressProps {
21
- /** A ref to the target element. */
22
- ref?: RefObject<Element | null>;
23
- }
24
- export interface PressResult {
25
- /** Whether the target is currently pressed. */
26
- isPressed: boolean;
27
- /** Props to spread on the target element. */
28
- pressProps: DOMAttributes;
29
- }
30
- /**
31
- * Handles press interactions across mouse, touch, keyboard, and screen readers.
32
- * It normalizes behavior across browsers and platforms, and handles many nuances
33
- * of dealing with pointer and keyboard events.
34
- */
35
- export function usePress(props: PressHookProps): PressResult;
36
- export interface FocusProps<Target = FocusableElement> extends FocusEvents<Target> {
37
- /** Whether the focus events should be disabled. */
38
- isDisabled?: boolean;
39
- }
40
- export interface FocusResult<Target = FocusableElement> {
41
- /** Props to spread onto the target element. */
42
- focusProps: DOMAttributes<Target>;
43
- }
44
- /**
45
- * Handles focus events for the immediate target.
46
- * Focus events on child elements will be ignored.
47
- */
48
- export function useFocus<Target extends FocusableElement = FocusableElement>(props: FocusProps<Target>): FocusResult<Target>;
49
- export interface KeyboardProps extends KeyboardEvents {
50
- /** Whether the keyboard events should be disabled. */
51
- isDisabled?: boolean;
52
- }
53
- export interface KeyboardResult {
54
- /** Props to spread onto the target element. */
55
- keyboardProps: DOMAttributes;
56
- }
57
- /**
58
- * Handles keyboard interactions for a focusable element.
59
- */
60
- export function useKeyboard(props: KeyboardProps): KeyboardResult;
61
- export interface FocusableOptions<T = FocusableElement> extends FocusableProps<T>, FocusableDOMProps {
62
- /** Whether focus should be disabled. */
63
- isDisabled?: boolean;
64
- }
65
- export interface FocusableProviderProps extends DOMAttributes {
66
- /** The child element to provide DOM props to. */
67
- children?: ReactNode;
68
- }
69
- interface FocusableContextValue extends FocusableProviderProps {
70
- ref?: MutableRefObject<FocusableElement | null>;
71
- }
72
- /** @private */
73
- export let FocusableContext: React.Context<FocusableContextValue | null>;
74
- /**
75
- * Provides DOM props to the nearest focusable child.
76
- */
77
- export const FocusableProvider: React.ForwardRefExoticComponent<FocusableProviderProps & React.RefAttributes<FocusableElement>>;
78
- export interface FocusableAria {
79
- /** Props for the focusable element. */
80
- focusableProps: DOMAttributes;
81
- }
82
- /**
83
- * Used to make an element focusable and capable of auto focus.
84
- */
85
- export function useFocusable<T extends FocusableElement = FocusableElement>(props: FocusableOptions<T>, domRef: RefObject<FocusableElement | null>): FocusableAria;
86
- interface FocusableComponentProps extends FocusableOptions {
87
- children: ReactElement<DOMAttributes, string>;
88
- }
89
- export const Focusable: React.ForwardRefExoticComponent<FocusableComponentProps & React.RefAttributes<FocusableElement>>;
90
- interface PressableProps extends PressProps {
91
- children: ReactElement<DOMAttributes, string>;
92
- }
93
- export const Pressable: React.ForwardRefExoticComponent<PressableProps & React.RefAttributes<FocusableElement>>;
94
- interface PressResponderProps extends PressProps {
95
- children: ReactNode;
96
- }
97
- export const PressResponder: React.ForwardRefExoticComponent<PressResponderProps & React.RefAttributes<FocusableElement>>;
98
- export function ClearPressResponder({ children }: {
99
- children: ReactNode;
100
- }): JSX.Element;
101
- export type Modality = 'keyboard' | 'pointer' | 'virtual';
102
- export type FocusVisibleHandler = (isFocusVisible: boolean) => void;
103
- export interface FocusVisibleProps {
104
- /** Whether the element is a text input. */
105
- isTextInput?: boolean;
106
- /** Whether the element will be auto focused. */
107
- autoFocus?: boolean;
108
- }
109
- export interface FocusVisibleResult {
110
- /** Whether keyboard focus is visible globally. */
111
- isFocusVisible: boolean;
112
- }
113
- /**
114
- * EXPERIMENTAL
115
- * Adds a window (i.e. iframe) to the list of windows that are being tracked for focus visible.
116
- *
117
- * Sometimes apps render portions of their tree into an iframe. In this case, we cannot accurately track if the focus
118
- * is visible because we cannot see interactions inside the iframe. If you have this in your application's architecture,
119
- * then this function will attach event listeners inside the iframe. You should call `addWindowFocusTracking` with an
120
- * element from inside the window you wish to add. We'll retrieve the relevant elements based on that.
121
- * Note, you do not need to call this for the default window, as we call it for you.
122
- *
123
- * When you are ready to stop listening, but you do not wish to unmount the iframe, you may call the cleanup function
124
- * returned by `addWindowFocusTracking`. Otherwise, when you unmount the iframe, all listeners and state will be cleaned
125
- * up automatically for you.
126
- *
127
- * @param element @default document.body - The element provided will be used to get the window to add.
128
- * @returns A function to remove the event listeners and cleanup the state.
129
- */
130
- export function addWindowFocusTracking(element?: HTMLElement | null): () => void;
131
- /**
132
- * If true, keyboard focus is visible.
133
- */
134
- export function isFocusVisible(): boolean;
135
- export function getInteractionModality(): Modality | null;
136
- export function setInteractionModality(modality: Modality): void;
137
- /** @private */
138
- export function getPointerType(): PointerType;
139
- /**
140
- * Keeps state of the current modality.
141
- */
142
- export function useInteractionModality(): Modality | null;
143
- /**
144
- * Manages focus visible state for the page, and subscribes individual components for updates.
145
- */
146
- export function useFocusVisible(props?: FocusVisibleProps): FocusVisibleResult;
147
- /**
148
- * Listens for trigger change and reports if focus is visible (i.e., modality is not pointer).
149
- */
150
- export function useFocusVisibleListener(fn: FocusVisibleHandler, deps: ReadonlyArray<any>, opts?: {
151
- enabled?: boolean;
152
- isTextInput?: boolean;
153
- }): void;
154
- export interface FocusWithinProps {
155
- /** Whether the focus within events should be disabled. */
156
- isDisabled?: boolean;
157
- /** Handler that is called when the target element or a descendant receives focus. */
158
- onFocusWithin?: (e: FocusEvent) => void;
159
- /** Handler that is called when the target element and all descendants lose focus. */
160
- onBlurWithin?: (e: FocusEvent) => void;
161
- /** Handler that is called when the the focus within state changes. */
162
- onFocusWithinChange?: (isFocusWithin: boolean) => void;
163
- }
164
- export interface FocusWithinResult {
165
- /** Props to spread onto the target element. */
166
- focusWithinProps: DOMAttributes;
167
- }
168
- /**
169
- * Handles focus events for the target and its descendants.
170
- */
171
- export function useFocusWithin(props: FocusWithinProps): FocusWithinResult;
172
- export interface HoverProps extends HoverEvents {
173
- /** Whether the hover events should be disabled. */
174
- isDisabled?: boolean;
175
- }
176
- export interface HoverResult {
177
- /** Props to spread on the target element. */
178
- hoverProps: DOMAttributes;
179
- isHovered: boolean;
180
- }
181
- /**
182
- * Handles pointer hover interactions for an element. Normalizes behavior
183
- * across browsers and platforms, and ignores emulated mouse events on touch devices.
184
- */
185
- export function useHover(props: HoverProps): HoverResult;
186
- export interface InteractOutsideProps {
187
- ref: RefObject<Element | null>;
188
- onInteractOutside?: (e: PointerEvent) => void;
189
- onInteractOutsideStart?: (e: PointerEvent) => void;
190
- /** Whether the interact outside events should be disabled. */
191
- isDisabled?: boolean;
192
- }
193
- /**
194
- * Example, used in components like Dialogs and Popovers so they can close
195
- * when a user clicks outside them.
196
- */
197
- export function useInteractOutside(props: InteractOutsideProps): void;
198
- export interface MoveResult {
199
- /** Props to spread on the target element. */
200
- moveProps: DOMAttributes;
201
- }
202
- /**
203
- * Handles move interactions across mouse, touch, and keyboard, including dragging with
204
- * the mouse or touch, and using the arrow keys. Normalizes behavior across browsers and
205
- * platforms, and ignores emulated mouse events on touch devices.
206
- */
207
- export function useMove(props: MoveEvents): MoveResult;
208
- export interface ScrollWheelProps extends ScrollEvents {
209
- /** Whether the scroll listener should be disabled. */
210
- isDisabled?: boolean;
211
- }
212
- export function useScrollWheel(props: ScrollWheelProps, ref: RefObject<HTMLElement | null>): void;
213
- export interface LongPressProps {
214
- /** Whether long press events should be disabled. */
215
- isDisabled?: boolean;
216
- /** Handler that is called when a long press interaction starts. */
217
- onLongPressStart?: (e: LongPressEvent) => void;
218
- /**
219
- * Handler that is called when a long press interaction ends, either
220
- * over the target or when the pointer leaves the target.
221
- */
222
- onLongPressEnd?: (e: LongPressEvent) => void;
223
- /**
224
- * Handler that is called when the threshold time is met while
225
- * the press is over the target.
226
- */
227
- onLongPress?: (e: LongPressEvent) => void;
228
- /**
229
- * The amount of time in milliseconds to wait before triggering a long press.
230
- * @default 500ms
231
- */
232
- threshold?: number;
233
- /**
234
- * A description for assistive techology users indicating that a long press
235
- * action is available, e.g. "Long press to open menu".
236
- */
237
- accessibilityDescription?: string;
238
- }
239
- export interface LongPressResult {
240
- /** Props to spread on the target element. */
241
- longPressProps: DOMAttributes;
242
- }
243
- /**
244
- * Handles long press interactions across mouse and touch devices. Supports a customizable time threshold,
245
- * accessibility description, and normalizes behavior across browsers and devices.
246
- */
247
- export function useLongPress(props: LongPressProps): LongPressResult;
248
- /**
249
- * A utility function that focuses an element while avoiding undesired side effects such
250
- * as page scrolling and screen reader issues with CSS transitions.
251
- */
252
- export function focusSafely(element: FocusableElement): void;
253
- export type { PressEvent, PressEvents, LongPressEvent, MoveStartEvent, MoveMoveEvent, MoveEndEvent, MoveEvent, MoveEvents, HoverEvent, HoverEvents, FocusEvents, KeyboardEvents } from '@react-types/shared';
254
-
255
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":";;AGyCA,2BAA4B,SAAQ,WAAW;IAC7C,+FAA+F;IAC/F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,UAAU,CAAC,EAAE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C1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,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"}
@@ -1,66 +0,0 @@
1
- var $625cf83917e112ad$exports = require("./utils.main.js");
2
- var $hrHul$react = require("react");
3
- var $hrHul$reactariautils = require("@react-aria/utils");
4
-
5
-
6
- function $parcel$export(e, n, v, s) {
7
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
- }
9
-
10
- $parcel$export(module.exports, "useFocus", () => $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6);
11
- /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */ // Portions of the code in this file are based on code from react.
22
- // Original licensing for the following can be found in the
23
- // NOTICE file in the root directory of this source tree.
24
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
25
-
26
-
27
-
28
- function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
29
- let { isDisabled: isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange: onFocusChange } = props;
30
- const onBlur = (0, $hrHul$react.useCallback)((e)=>{
31
- if ((0, $hrHul$reactariautils.getEventTarget)(e) === e.currentTarget) {
32
- if (onBlurProp) onBlurProp(e);
33
- if (onFocusChange) onFocusChange(false);
34
- return true;
35
- }
36
- }, [
37
- onBlurProp,
38
- onFocusChange
39
- ]);
40
- const onSyntheticFocus = (0, $625cf83917e112ad$exports.useSyntheticBlurEvent)(onBlur);
41
- const onFocus = (0, $hrHul$react.useCallback)((e)=>{
42
- // Double check that document.activeElement actually matches e.target in case a previously chained
43
- // focus handler already moved focus somewhere else.
44
- let eventTarget = (0, $hrHul$reactariautils.getEventTarget)(e);
45
- const ownerDocument = (0, $hrHul$reactariautils.getOwnerDocument)(eventTarget);
46
- const activeElement = ownerDocument ? (0, $hrHul$reactariautils.getActiveElement)(ownerDocument) : (0, $hrHul$reactariautils.getActiveElement)();
47
- if (eventTarget === e.currentTarget && eventTarget === activeElement) {
48
- if (onFocusProp) onFocusProp(e);
49
- if (onFocusChange) onFocusChange(true);
50
- onSyntheticFocus(e);
51
- }
52
- }, [
53
- onFocusChange,
54
- onFocusProp,
55
- onSyntheticFocus
56
- ]);
57
- return {
58
- focusProps: {
59
- onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
60
- onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
61
- }
62
- };
63
- }
64
-
65
-
66
- //# sourceMappingURL=useFocus.main.js.map
@@ -1 +0,0 @@
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,wBAAU,EAAE,CAAC;QACxD,IAAI,CAAA,GAAA,oCAAa,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,+CAAoB,EAAU;IAEvD,MAAM,UAAyC,CAAA,GAAA,wBAAU,EAAE,CAAC;QAC1D,kGAAkG;QAClG,oDAAoD;QAEpD,IAAI,cAAc,CAAA,GAAA,oCAAa,EAAE;QACjC,MAAM,gBAAgB,CAAA,GAAA,sCAAe,EAAE;QACvC,MAAM,gBAAgB,gBAAgB,CAAA,GAAA,sCAAe,EAAE,iBAAiB,CAAA,GAAA,sCAAe;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.main.js.map"}