@react-aria/interactions 3.25.6 → 3.27.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 (63) hide show
  1. package/dist/PressResponder.main.js +2 -3
  2. package/dist/PressResponder.main.js.map +1 -1
  3. package/dist/PressResponder.mjs +3 -4
  4. package/dist/PressResponder.module.js +3 -4
  5. package/dist/PressResponder.module.js.map +1 -1
  6. package/dist/focusSafely.main.js +4 -4
  7. package/dist/focusSafely.main.js.map +1 -1
  8. package/dist/focusSafely.mjs +4 -4
  9. package/dist/focusSafely.module.js +4 -4
  10. package/dist/focusSafely.module.js.map +1 -1
  11. package/dist/import.mjs +2 -2
  12. package/dist/main.js +1 -0
  13. package/dist/main.js.map +1 -1
  14. package/dist/module.js +2 -2
  15. package/dist/module.js.map +1 -1
  16. package/dist/types.d.ts +4 -1
  17. package/dist/types.d.ts.map +1 -1
  18. package/dist/useFocusVisible.main.js +19 -8
  19. package/dist/useFocusVisible.main.js.map +1 -1
  20. package/dist/useFocusVisible.mjs +20 -10
  21. package/dist/useFocusVisible.module.js +20 -10
  22. package/dist/useFocusVisible.module.js.map +1 -1
  23. package/dist/useFocusWithin.main.js +3 -3
  24. package/dist/useFocusWithin.main.js.map +1 -1
  25. package/dist/useFocusWithin.mjs +4 -4
  26. package/dist/useFocusWithin.module.js +4 -4
  27. package/dist/useFocusWithin.module.js.map +1 -1
  28. package/dist/useHover.main.js +3 -3
  29. package/dist/useHover.main.js.map +1 -1
  30. package/dist/useHover.mjs +4 -4
  31. package/dist/useHover.module.js +4 -4
  32. package/dist/useHover.module.js.map +1 -1
  33. package/dist/useInteractOutside.main.js +2 -4
  34. package/dist/useInteractOutside.main.js.map +1 -1
  35. package/dist/useInteractOutside.mjs +3 -5
  36. package/dist/useInteractOutside.module.js +3 -5
  37. package/dist/useInteractOutside.module.js.map +1 -1
  38. package/dist/useMove.main.js +110 -74
  39. package/dist/useMove.main.js.map +1 -1
  40. package/dist/useMove.mjs +112 -76
  41. package/dist/useMove.module.js +112 -76
  42. package/dist/useMove.module.js.map +1 -1
  43. package/dist/usePress.main.js +197 -117
  44. package/dist/usePress.main.js.map +1 -1
  45. package/dist/usePress.mjs +199 -119
  46. package/dist/usePress.module.js +199 -119
  47. package/dist/usePress.module.js.map +1 -1
  48. package/dist/utils.main.js +2 -5
  49. package/dist/utils.main.js.map +1 -1
  50. package/dist/utils.mjs +3 -6
  51. package/dist/utils.module.js +3 -6
  52. package/dist/utils.module.js.map +1 -1
  53. package/package.json +4 -4
  54. package/src/PressResponder.tsx +3 -4
  55. package/src/focusSafely.ts +4 -4
  56. package/src/index.ts +1 -0
  57. package/src/useFocusVisible.ts +21 -5
  58. package/src/useFocusWithin.ts +3 -3
  59. package/src/useHover.ts +3 -3
  60. package/src/useInteractOutside.ts +3 -3
  61. package/src/useMove.ts +85 -57
  62. package/src/usePress.ts +199 -151
  63. package/src/utils.ts +3 -7
@@ -1,4 +1,4 @@
1
- import {useGlobalListeners as $AWxnT$useGlobalListeners, getOwnerDocument as $AWxnT$getOwnerDocument, nodeContains as $AWxnT$nodeContains} from "@react-aria/utils";
1
+ import {useGlobalListeners as $AWxnT$useGlobalListeners, nodeContains as $AWxnT$nodeContains, getOwnerDocument as $AWxnT$getOwnerDocument} from "@react-aria/utils";
2
2
  import {useState as $AWxnT$useState, useRef as $AWxnT$useRef, useEffect as $AWxnT$useEffect, useMemo as $AWxnT$useMemo} from "react";
3
3
 
4
4
  /*
@@ -63,7 +63,7 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
63
63
  let { hoverProps: hoverProps, triggerHoverEnd: triggerHoverEnd } = (0, $AWxnT$useMemo)(()=>{
64
64
  let triggerHoverStart = (event, pointerType)=>{
65
65
  state.pointerType = pointerType;
66
- if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) return;
66
+ if (isDisabled || pointerType === 'touch' || state.isHovered || !(0, $AWxnT$nodeContains)(event.currentTarget, event.target)) return;
67
67
  state.isHovered = true;
68
68
  let target = event.currentTarget;
69
69
  state.target = target;
@@ -106,7 +106,7 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
106
106
  triggerHoverStart(e, e.pointerType);
107
107
  };
108
108
  hoverProps.onPointerLeave = (e)=>{
109
- if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, e.pointerType);
109
+ if (!isDisabled && (0, $AWxnT$nodeContains)(e.currentTarget, e.target)) triggerHoverEnd(e, e.pointerType);
110
110
  };
111
111
  } else if (process.env.NODE_ENV === 'test') {
112
112
  hoverProps.onTouchStart = ()=>{
@@ -117,7 +117,7 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
117
117
  state.ignoreEmulatedMouseEvents = false;
118
118
  };
119
119
  hoverProps.onMouseLeave = (e)=>{
120
- if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, 'mouse');
120
+ if (!isDisabled && (0, $AWxnT$nodeContains)(e.currentTarget, e.target)) triggerHoverEnd(e, 'mouse');
121
121
  };
122
122
  }
123
123
  return {
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;AAiBlH,oGAAoG;AACpG,iFAAiF;AACjF,sDAAsD;AACtD,IAAI,wDAAkC;AACtC,IAAI,mCAAa;AAEjB,SAAS;IACP,wDAAkC;IAElC,wFAAwF;IACxF,sFAAsF;IACtF,wFAAwF;IACxF,oEAAoE;IACpE,WAAW;QACT,wDAAkC;IACpC,GAAG;AACL;AAEA,SAAS,+CAAyB,CAAe;IAC/C,IAAI,EAAE,WAAW,KAAK,SACpB;AAEJ;AAEA,SAAS;IACP,IAAI,OAAO,aAAa,aACtB;IAGF,IAAI,qCAAe,GAAG;QACpB,IAAI,OAAO,iBAAiB,aAC1B,SAAS,gBAAgB,CAAC,aAAa;aAClC,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,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EAAiE;QACjE,qFAAqF;QACrF,IAAI,YACF,gBAAgB;YAAC,eAAe,MAAM,MAAM;QAAA,GAAG,MAAM,WAAW;IAEpE,uDAAuD;IACvD,GAAG;QAAC;KAAW;IAEf,OAAO;oBACL;mBACA;IACF;AACF","sources":["packages/@react-aria/interactions/src/useHover.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, HoverEvents} from '@react-types/shared';\nimport {getOwnerDocument, nodeContains, useGlobalListeners} from '@react-aria/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\n\nexport interface HoverProps extends HoverEvents {\n /** Whether the hover events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface HoverResult {\n /** Props to spread on the target element. */\n hoverProps: DOMAttributes,\n isHovered: boolean\n}\n\n// iOS fires onPointerEnter twice: once with pointerType=\"touch\" and again with pointerType=\"mouse\".\n// We want to ignore these emulated events so they do not trigger hover behavior.\n// See https://bugs.webkit.org/show_bug.cgi?id=214609.\nlet globalIgnoreEmulatedMouseEvents = false;\nlet hoverCount = 0;\n\nfunction setGlobalIgnoreEmulatedMouseEvents() {\n globalIgnoreEmulatedMouseEvents = true;\n\n // Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter\n // with pointerType=\"mouse\" immediately after onPointerUp and before onFocus. On other\n // devices that don't have this quirk, we don't want to ignore a mouse hover sometime in\n // the distant future because a user previously touched the element.\n setTimeout(() => {\n globalIgnoreEmulatedMouseEvents = false;\n }, 50);\n}\n\nfunction handleGlobalPointerEvent(e: PointerEvent) {\n if (e.pointerType === 'touch') {\n setGlobalIgnoreEmulatedMouseEvents();\n }\n}\n\nfunction setupGlobalTouchEvents() {\n if (typeof document === 'undefined') {\n return;\n }\n\n if (hoverCount === 0) {\n if (typeof PointerEvent !== 'undefined') {\n document.addEventListener('pointerup', handleGlobalPointerEvent);\n } else if (process.env.NODE_ENV === 'test') {\n document.addEventListener('touchend', setGlobalIgnoreEmulatedMouseEvents);\n }\n }\n\n hoverCount++;\n return () => {\n hoverCount--;\n if (hoverCount > 0) {\n return;\n }\n\n if (typeof PointerEvent !== 'undefined') {\n document.removeEventListener('pointerup', handleGlobalPointerEvent);\n } else if (process.env.NODE_ENV === 'test') {\n document.removeEventListener('touchend', setGlobalIgnoreEmulatedMouseEvents);\n }\n };\n}\n\n/**\n * Handles pointer hover interactions for an element. Normalizes behavior\n * across browsers and platforms, and ignores emulated mouse events on touch devices.\n */\nexport function useHover(props: HoverProps): HoverResult {\n let {\n onHoverStart,\n onHoverChange,\n onHoverEnd,\n isDisabled\n } = props;\n\n let [isHovered, setHovered] = useState(false);\n let state = useRef({\n isHovered: false,\n ignoreEmulatedMouseEvents: false,\n pointerType: '',\n target: null\n }).current;\n\n useEffect(setupGlobalTouchEvents, []);\n let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();\n\n let {hoverProps, triggerHoverEnd} = useMemo(() => {\n let triggerHoverStart = (event, pointerType) => {\n state.pointerType = pointerType;\n if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) {\n return;\n }\n\n state.isHovered = true;\n let target = event.currentTarget;\n state.target = target;\n\n // When an element that is hovered over is removed, no pointerleave event is fired by the browser,\n // even though the originally hovered target may have shrunk in size so it is no longer hovered.\n // However, a pointerover event will be fired on the new target the mouse is over.\n // In Chrome this happens immediately. In Safari and Firefox, it happens upon moving the mouse one pixel.\n addGlobalListener(getOwnerDocument(event.target), 'pointerover', e => {\n if (state.isHovered && state.target && !nodeContains(state.target, e.target as Element)) {\n triggerHoverEnd(e, e.pointerType);\n }\n }, {capture: true});\n\n if (onHoverStart) {\n onHoverStart({\n type: 'hoverstart',\n target,\n pointerType\n });\n }\n\n if (onHoverChange) {\n onHoverChange(true);\n }\n\n setHovered(true);\n };\n\n let triggerHoverEnd = (event, pointerType) => {\n let target = state.target;\n state.pointerType = '';\n state.target = null;\n\n if (pointerType === 'touch' || !state.isHovered || !target) {\n return;\n }\n\n state.isHovered = false;\n removeAllGlobalListeners();\n\n if (onHoverEnd) {\n onHoverEnd({\n type: 'hoverend',\n target,\n pointerType\n });\n }\n\n if (onHoverChange) {\n onHoverChange(false);\n }\n\n setHovered(false);\n };\n\n let hoverProps: DOMAttributes = {};\n\n if (typeof PointerEvent !== 'undefined') {\n hoverProps.onPointerEnter = (e) => {\n if (globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') {\n return;\n }\n\n triggerHoverStart(e, e.pointerType);\n };\n\n hoverProps.onPointerLeave = (e) => {\n if (!isDisabled && e.currentTarget.contains(e.target as Element)) {\n triggerHoverEnd(e, e.pointerType);\n }\n };\n } else if (process.env.NODE_ENV === 'test') {\n hoverProps.onTouchStart = () => {\n state.ignoreEmulatedMouseEvents = true;\n };\n\n hoverProps.onMouseEnter = (e) => {\n if (!state.ignoreEmulatedMouseEvents && !globalIgnoreEmulatedMouseEvents) {\n triggerHoverStart(e, 'mouse');\n }\n\n state.ignoreEmulatedMouseEvents = false;\n };\n\n hoverProps.onMouseLeave = (e) => {\n if (!isDisabled && e.currentTarget.contains(e.target as Element)) {\n triggerHoverEnd(e, 'mouse');\n }\n };\n }\n return {hoverProps, triggerHoverEnd};\n }, [onHoverStart, onHoverChange, onHoverEnd, isDisabled, state, addGlobalListener, removeAllGlobalListeners]);\n\n useEffect(() => {\n // Call the triggerHoverEnd as soon as isDisabled changes to true\n // Safe to call triggerHoverEnd, it will early return if we aren't currently hovering\n if (isDisabled) {\n triggerHoverEnd({currentTarget: state.target}, state.pointerType);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isDisabled]);\n\n return {\n hoverProps,\n isHovered\n };\n}\n"],"names":[],"version":3,"file":"useHover.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;AAiBlH,oGAAoG;AACpG,iFAAiF;AACjF,sDAAsD;AACtD,IAAI,wDAAkC;AACtC,IAAI,mCAAa;AAEjB,SAAS;IACP,wDAAkC;IAElC,wFAAwF;IACxF,sFAAsF;IACtF,wFAAwF;IACxF,oEAAoE;IACpE,WAAW;QACT,wDAAkC;IACpC,GAAG;AACL;AAEA,SAAS,+CAAyB,CAAe;IAC/C,IAAI,EAAE,WAAW,KAAK,SACpB;AAEJ;AAEA,SAAS;IACP,IAAI,OAAO,aAAa,aACtB;IAGF,IAAI,qCAAe,GAAG;QACpB,IAAI,OAAO,iBAAiB,aAC1B,SAAS,gBAAgB,CAAC,aAAa;aAClC,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,QAClC,SAAS,gBAAgB,CAAC,YAAY;IAE1C;IAEA;IACA,OAAO;QACL;QACA,IAAI,mCAAa,GACf;QAGF,IAAI,OAAO,iBAAiB,aAC1B,SAAS,mBAAmB,CAAC,aAAa;aACrC,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,QAClC,SAAS,mBAAmB,CAAC,YAAY;IAE7C;AACF;AAMO,SAAS,0CAAS,KAAiB;IACxC,IAAI,gBACF,YAAY,iBACZ,aAAa,cACb,UAAU,cACV,UAAU,EACX,GAAG;IAEJ,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA,GAAA,eAAO,EAAE;IACvC,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;QACjB,WAAW;QACX,2BAA2B;Q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,iBAAiB,aAAa;YACvC,WAAW,cAAc,GAAG,CAAC;gBAC3B,IAAI,yDAAmC,EAAE,WAAW,KAAK,SACvD;gBAGF,kBAAkB,GAAG,EAAE,WAAW;YACpC;YAEA,WAAW,cAAc,GAAG,CAAC;gBAC3B,IAAI,CAAC,cAAc,CAAA,GAAA,mBAAW,EAAE,EAAE,aAAa,EAAE,EAAE,MAAM,GACvD,gBAAgB,GAAG,EAAE,WAAW;YAEpC;QACF,OAAO,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,QAAQ;YAC1C,WAAW,YAAY,GAAG;gBACxB,MAAM,yBAAyB,GAAG;YACpC;YAEA,WAAW,YAAY,GAAG,CAAC;gBACzB,IAAI,CAAC,MAAM,yBAAyB,IAAI,CAAC,uDACvC,kBAAkB,GAAG;gBAGvB,MAAM,yBAAyB,GAAG;YACpC;YAEA,WAAW,YAAY,GAAG,CAAC;gBACzB,IAAI,CAAC,cAAc,CAAA,GAAA,mBAAW,EAAE,EAAE,aAAa,EAAE,EAAE,MAAM,GACvD,gBAAgB,GAAG;YAEvB;QACF;QACA,OAAO;wBAAC;6BAAY;QAAe;IACrC,GAAG;QAAC;QAAc;QAAe;QAAY;QAAY;QAAO;QAAmB;KAAyB;IAE5G,CAAA,GAAA,gBAAQ,EAAE;QACR,iEAAiE;QACjE,qFAAqF;QACrF,IAAI,YACF,gBAAgB;YAAC,eAAe,MAAM,MAAM;QAAA,GAAG,MAAM,WAAW;IAEpE,uDAAuD;IACvD,GAAG;QAAC;KAAW;IAEf,OAAO;oBACL;mBACA;IACF;AACF","sources":["packages/@react-aria/interactions/src/useHover.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, HoverEvents} from '@react-types/shared';\nimport {getOwnerDocument, nodeContains, useGlobalListeners} from '@react-aria/utils';\nimport {useEffect, useMemo, useRef, useState} from 'react';\n\nexport interface HoverProps extends HoverEvents {\n /** Whether the hover events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface HoverResult {\n /** Props to spread on the target element. */\n hoverProps: DOMAttributes,\n isHovered: boolean\n}\n\n// iOS fires onPointerEnter twice: once with pointerType=\"touch\" and again with pointerType=\"mouse\".\n// We want to ignore these emulated events so they do not trigger hover behavior.\n// See https://bugs.webkit.org/show_bug.cgi?id=214609.\nlet globalIgnoreEmulatedMouseEvents = false;\nlet hoverCount = 0;\n\nfunction setGlobalIgnoreEmulatedMouseEvents() {\n globalIgnoreEmulatedMouseEvents = true;\n\n // Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter\n // with pointerType=\"mouse\" immediately after onPointerUp and before onFocus. On other\n // devices that don't have this quirk, we don't want to ignore a mouse hover sometime in\n // the distant future because a user previously touched the element.\n setTimeout(() => {\n globalIgnoreEmulatedMouseEvents = false;\n }, 50);\n}\n\nfunction handleGlobalPointerEvent(e: PointerEvent) {\n if (e.pointerType === 'touch') {\n setGlobalIgnoreEmulatedMouseEvents();\n }\n}\n\nfunction setupGlobalTouchEvents() {\n if (typeof document === 'undefined') {\n return;\n }\n\n if (hoverCount === 0) {\n if (typeof PointerEvent !== 'undefined') {\n document.addEventListener('pointerup', handleGlobalPointerEvent);\n } else if (process.env.NODE_ENV === 'test') {\n document.addEventListener('touchend', setGlobalIgnoreEmulatedMouseEvents);\n }\n }\n\n hoverCount++;\n return () => {\n hoverCount--;\n if (hoverCount > 0) {\n return;\n }\n\n if (typeof PointerEvent !== 'undefined') {\n document.removeEventListener('pointerup', handleGlobalPointerEvent);\n } else if (process.env.NODE_ENV === 'test') {\n document.removeEventListener('touchend', setGlobalIgnoreEmulatedMouseEvents);\n }\n };\n}\n\n/**\n * Handles pointer hover interactions for an element. Normalizes behavior\n * across browsers and platforms, and ignores emulated mouse events on touch devices.\n */\nexport function useHover(props: HoverProps): HoverResult {\n let {\n onHoverStart,\n onHoverChange,\n onHoverEnd,\n isDisabled\n } = props;\n\n let [isHovered, setHovered] = useState(false);\n let state = useRef({\n isHovered: false,\n ignoreEmulatedMouseEvents: false,\n pointerType: '',\n target: null\n }).current;\n\n useEffect(setupGlobalTouchEvents, []);\n let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();\n\n let {hoverProps, triggerHoverEnd} = useMemo(() => {\n let triggerHoverStart = (event, pointerType) => {\n state.pointerType = pointerType;\n if (isDisabled || pointerType === 'touch' || state.isHovered || !nodeContains(event.currentTarget, event.target)) {\n return;\n }\n\n state.isHovered = true;\n let target = event.currentTarget;\n state.target = target;\n\n // When an element that is hovered over is removed, no pointerleave event is fired by the browser,\n // even though the originally hovered target may have shrunk in size so it is no longer hovered.\n // However, a pointerover event will be fired on the new target the mouse is over.\n // In Chrome this happens immediately. In Safari and Firefox, it happens upon moving the mouse one pixel.\n addGlobalListener(getOwnerDocument(event.target), 'pointerover', e => {\n if (state.isHovered && state.target && !nodeContains(state.target, e.target as Element)) {\n triggerHoverEnd(e, e.pointerType);\n }\n }, {capture: true});\n\n if (onHoverStart) {\n onHoverStart({\n type: 'hoverstart',\n target,\n pointerType\n });\n }\n\n if (onHoverChange) {\n onHoverChange(true);\n }\n\n setHovered(true);\n };\n\n let triggerHoverEnd = (event, pointerType) => {\n let target = state.target;\n state.pointerType = '';\n state.target = null;\n\n if (pointerType === 'touch' || !state.isHovered || !target) {\n return;\n }\n\n state.isHovered = false;\n removeAllGlobalListeners();\n\n if (onHoverEnd) {\n onHoverEnd({\n type: 'hoverend',\n target,\n pointerType\n });\n }\n\n if (onHoverChange) {\n onHoverChange(false);\n }\n\n setHovered(false);\n };\n\n let hoverProps: DOMAttributes = {};\n\n if (typeof PointerEvent !== 'undefined') {\n hoverProps.onPointerEnter = (e) => {\n if (globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') {\n return;\n }\n\n triggerHoverStart(e, e.pointerType);\n };\n\n hoverProps.onPointerLeave = (e) => {\n if (!isDisabled && nodeContains(e.currentTarget, e.target as Element)) {\n triggerHoverEnd(e, e.pointerType);\n }\n };\n } else if (process.env.NODE_ENV === 'test') {\n hoverProps.onTouchStart = () => {\n state.ignoreEmulatedMouseEvents = true;\n };\n\n hoverProps.onMouseEnter = (e) => {\n if (!state.ignoreEmulatedMouseEvents && !globalIgnoreEmulatedMouseEvents) {\n triggerHoverStart(e, 'mouse');\n }\n\n state.ignoreEmulatedMouseEvents = false;\n };\n\n hoverProps.onMouseLeave = (e) => {\n if (!isDisabled && nodeContains(e.currentTarget, e.target as Element)) {\n triggerHoverEnd(e, 'mouse');\n }\n };\n }\n return {hoverProps, triggerHoverEnd};\n }, [onHoverStart, onHoverChange, onHoverEnd, isDisabled, state, addGlobalListener, removeAllGlobalListeners]);\n\n useEffect(() => {\n // Call the triggerHoverEnd as soon as isDisabled changes to true\n // Safe to call triggerHoverEnd, it will early return if we aren't currently hovering\n if (isDisabled) {\n triggerHoverEnd({currentTarget: state.target}, state.pointerType);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isDisabled]);\n\n return {\n hoverProps,\n isHovered\n };\n}\n"],"names":[],"version":3,"file":"useHover.module.js.map"}
@@ -82,9 +82,7 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
82
82
  }
83
83
  }, [
84
84
  ref,
85
- isDisabled,
86
- onPointerDown,
87
- triggerInteractOutside
85
+ isDisabled
88
86
  ]);
89
87
  }
90
88
  function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
@@ -92,7 +90,7 @@ function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
92
90
  if (event.target) {
93
91
  // if the event target is no longer in the document, ignore
94
92
  const ownerDocument = event.target.ownerDocument;
95
- if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
93
+ if (!ownerDocument || !(0, $9Icr4$reactariautils.nodeContains)(ownerDocument.documentElement, event.target)) return false;
96
94
  // If the target is within a top layer element (e.g. toasts), ignore.
97
95
  if (event.target.closest('[data-react-aria-top-layer]')) return false;
98
96
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;AAkB3G,SAAS,0CAAmB,KAA2B;IAC5D,IAAI,OAAC,GAAG,qBAAE,iBAAiB,cAAE,UAAU,0BAAE,sBAAsB,EAAC,GAAG;IACnE,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAE;QACpB,eAAe;QACf,2BAA2B;IAC7B;IAEA,IAAI,gBAAgB,CAAA,GAAA,oCAAa,EAAE,CAAC;QAClC,IAAI,qBAAqB,mCAAa,GAAG,MAAM;YAC7C,IAAI,wBACF,uBAAuB;YAEzB,SAAS,OAAO,CAAC,aAAa,GAAG;QACnC;IACF;IAEA,IAAI,yBAAyB,CAAA,GAAA,oCAAa,EAAE,CAAC;QAC3C,IAAI,mBACF,kBAAkB;IAEtB;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,QAAQ,SAAS,OAAO;QAC5B,IAAI,YACF;QAGF,MAAM,UAAU,IAAI,OAAO;QAC3B,MAAM,iBAAiB,CAAA,GAAA,sCAAe,EAAE;QAExC,mFAAmF;QACnF,IAAI,OAAO,iBAAiB,aAAa;YACvC,IAAI,UAAU,CAAC;gBACb,IAAI,MAAM,aAAa,IAAI,mCAAa,GAAG,MACzC,uBAAuB;gBAEzB,MAAM,aAAa,GAAG;YACxB;YAEA,iDAAiD;YAC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;QACrE,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,gCACvB,OAAO;IAEX;IAEA,IAAI,CAAC,IAAI,OAAO,EACd,OAAO;IAGT,sFAAsF;IACtF,+FAA+F;IAC/F,yFAAyF;IACzF,sEAAsE;IACtE,OAAO,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,OAAO;AACnD","sources":["packages/@react-aria/interactions/src/useInteractOutside.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 {getOwnerDocument, useEffectEvent} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useEffect, useRef} from 'react';\n\nexport interface InteractOutsideProps {\n ref: RefObject<Element | null>,\n onInteractOutside?: (e: PointerEvent) => void,\n onInteractOutsideStart?: (e: PointerEvent) => void,\n /** Whether the interact outside events should be disabled. */\n isDisabled?: boolean\n}\n\n/**\n * Example, used in components like Dialogs and Popovers so they can close\n * when a user clicks outside them.\n */\nexport function useInteractOutside(props: InteractOutsideProps): void {\n let {ref, onInteractOutside, isDisabled, onInteractOutsideStart} = props;\n let stateRef = useRef({\n isPointerDown: false,\n ignoreEmulatedMouseEvents: false\n });\n\n let onPointerDown = useEffectEvent((e) => {\n if (onInteractOutside && isValidEvent(e, ref)) {\n if (onInteractOutsideStart) {\n onInteractOutsideStart(e);\n }\n stateRef.current.isPointerDown = true;\n }\n });\n\n let triggerInteractOutside = useEffectEvent((e: PointerEvent) => {\n if (onInteractOutside) {\n onInteractOutside(e);\n }\n });\n\n useEffect(() => {\n let state = stateRef.current;\n if (isDisabled) {\n return;\n }\n\n const element = ref.current;\n const documentObject = getOwnerDocument(element);\n\n // Use pointer events if available. Otherwise, fall back to mouse and touch events.\n if (typeof PointerEvent !== 'undefined') {\n let onClick = (e) => {\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n // changing these to capture phase fixed combobox\n // Use click instead of pointerup to avoid Android Chrome issue\n // https://issues.chromium.org/issues/40732224\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('click', onClick, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('click', onClick, true);\n };\n } else if (process.env.NODE_ENV === 'test') {\n let onMouseUp = (e) => {\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n } else if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n let onTouchEnd = (e) => {\n state.ignoreEmulatedMouseEvents = true;\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n documentObject.addEventListener('mousedown', onPointerDown, true);\n documentObject.addEventListener('mouseup', onMouseUp, true);\n documentObject.addEventListener('touchstart', onPointerDown, true);\n documentObject.addEventListener('touchend', onTouchEnd, true);\n\n return () => {\n documentObject.removeEventListener('mousedown', onPointerDown, true);\n documentObject.removeEventListener('mouseup', onMouseUp, true);\n documentObject.removeEventListener('touchstart', onPointerDown, true);\n documentObject.removeEventListener('touchend', onTouchEnd, true);\n };\n }\n }, [ref, isDisabled, onPointerDown, triggerInteractOutside]);\n}\n\nfunction isValidEvent(event, ref) {\n if (event.button > 0) {\n return false;\n }\n if (event.target) {\n // if the event target is no longer in the document, ignore\n const ownerDocument = event.target.ownerDocument;\n if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) {\n return false;\n }\n // If the target is within a top layer element (e.g. toasts), ignore.\n if (event.target.closest('[data-react-aria-top-layer]')) {\n return false;\n }\n }\n\n if (!ref.current) {\n return false;\n }\n\n // When the event source is inside a Shadow DOM, event.target is just the shadow root.\n // Using event.composedPath instead means we can get the actual element inside the shadow root.\n // This only works if the shadow root is open, there is no way to detect if it is closed.\n // If the event composed path contains the ref, interaction is inside.\n return !event.composedPath().includes(ref.current);\n}\n"],"names":[],"version":3,"file":"useInteractOutside.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;AAkB3G,SAAS,0CAAmB,KAA2B;IAC5D,IAAI,OAAC,GAAG,qBAAE,iBAAiB,cAAE,UAAU,0BAAE,sBAAsB,EAAC,GAAG;IACnE,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAE;QACpB,eAAe;QACf,2BAA2B;IAC7B;IAEA,IAAI,gBAAgB,CAAA,GAAA,oCAAa,EAAE,CAAC;QAClC,IAAI,qBAAqB,mCAAa,GAAG,MAAM;YAC7C,IAAI,wBACF,uBAAuB;YAEzB,SAAS,OAAO,CAAC,aAAa,GAAG;QACnC;IACF;IAEA,IAAI,yBAAyB,CAAA,GAAA,oCAAa,EAAE,CAAC;QAC3C,IAAI,mBACF,kBAAkB;IAEtB;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,QAAQ,SAAS,OAAO;QAC5B,IAAI,YACF;QAGF,MAAM,UAAU,IAAI,OAAO;QAC3B,MAAM,iBAAiB,CAAA,GAAA,sCAAe,EAAE;QAExC,mFAAmF;QACnF,IAAI,OAAO,iBAAiB,aAAa;YACvC,IAAI,UAAU,CAAC;gBACb,IAAI,MAAM,aAAa,IAAI,mCAAa,GAAG,MACzC,uBAAuB;gBAEzB,M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,MAAM,MAAM,GAC7E,OAAO;QAET,qEAAqE;QACrE,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,gCACvB,OAAO;IAEX;IAEA,IAAI,CAAC,IAAI,OAAO,EACd,OAAO;IAGT,sFAAsF;IACtF,+FAA+F;IAC/F,yFAAyF;IACzF,sEAAsE;IACtE,OAAO,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,OAAO;AACnD","sources":["packages/@react-aria/interactions/src/useInteractOutside.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 {getOwnerDocument, nodeContains, useEffectEvent} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useEffect, useRef} from 'react';\n\nexport interface InteractOutsideProps {\n ref: RefObject<Element | null>,\n onInteractOutside?: (e: PointerEvent) => void,\n onInteractOutsideStart?: (e: PointerEvent) => void,\n /** Whether the interact outside events should be disabled. */\n isDisabled?: boolean\n}\n\n/**\n * Example, used in components like Dialogs and Popovers so they can close\n * when a user clicks outside them.\n */\nexport function useInteractOutside(props: InteractOutsideProps): void {\n let {ref, onInteractOutside, isDisabled, onInteractOutsideStart} = props;\n let stateRef = useRef({\n isPointerDown: false,\n ignoreEmulatedMouseEvents: false\n });\n\n let onPointerDown = useEffectEvent((e) => {\n if (onInteractOutside && isValidEvent(e, ref)) {\n if (onInteractOutsideStart) {\n onInteractOutsideStart(e);\n }\n stateRef.current.isPointerDown = true;\n }\n });\n\n let triggerInteractOutside = useEffectEvent((e: PointerEvent) => {\n if (onInteractOutside) {\n onInteractOutside(e);\n }\n });\n\n useEffect(() => {\n let state = stateRef.current;\n if (isDisabled) {\n return;\n }\n\n const element = ref.current;\n const documentObject = getOwnerDocument(element);\n\n // Use pointer events if available. Otherwise, fall back to mouse and touch events.\n if (typeof PointerEvent !== 'undefined') {\n let onClick = (e) => {\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n // changing these to capture phase fixed combobox\n // Use click instead of pointerup to avoid Android Chrome issue\n // https://issues.chromium.org/issues/40732224\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('click', onClick, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('click', onClick, true);\n };\n } else if (process.env.NODE_ENV === 'test') {\n let onMouseUp = (e) => {\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n } else if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n let onTouchEnd = (e) => {\n state.ignoreEmulatedMouseEvents = true;\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n documentObject.addEventListener('mousedown', onPointerDown, true);\n documentObject.addEventListener('mouseup', onMouseUp, true);\n documentObject.addEventListener('touchstart', onPointerDown, true);\n documentObject.addEventListener('touchend', onTouchEnd, true);\n\n return () => {\n documentObject.removeEventListener('mousedown', onPointerDown, true);\n documentObject.removeEventListener('mouseup', onMouseUp, true);\n documentObject.removeEventListener('touchstart', onPointerDown, true);\n documentObject.removeEventListener('touchend', onTouchEnd, true);\n };\n }\n }, [ref, isDisabled]);\n}\n\nfunction isValidEvent(event, ref) {\n if (event.button > 0) {\n return false;\n }\n if (event.target) {\n // if the event target is no longer in the document, ignore\n const ownerDocument = event.target.ownerDocument;\n if (!ownerDocument || !nodeContains(ownerDocument.documentElement, event.target)) {\n return false;\n }\n // If the target is within a top layer element (e.g. toasts), ignore.\n if (event.target.closest('[data-react-aria-top-layer]')) {\n return false;\n }\n }\n\n if (!ref.current) {\n return false;\n }\n\n // When the event source is inside a Shadow DOM, event.target is just the shadow root.\n // Using event.composedPath instead means we can get the actual element inside the shadow root.\n // This only works if the shadow root is open, there is no way to detect if it is closed.\n // If the event composed path contains the ref, interaction is inside.\n return !event.composedPath().includes(ref.current);\n}\n"],"names":[],"version":3,"file":"useInteractOutside.main.js.map"}
@@ -1,4 +1,4 @@
1
- import {useEffectEvent as $ispOf$useEffectEvent, getOwnerDocument as $ispOf$getOwnerDocument} from "@react-aria/utils";
1
+ import {useEffectEvent as $ispOf$useEffectEvent, getOwnerDocument as $ispOf$getOwnerDocument, nodeContains as $ispOf$nodeContains} from "@react-aria/utils";
2
2
  import {useRef as $ispOf$useRef, useEffect as $ispOf$useEffect} from "react";
3
3
 
4
4
  /*
@@ -76,9 +76,7 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
76
76
  }
77
77
  }, [
78
78
  ref,
79
- isDisabled,
80
- onPointerDown,
81
- triggerInteractOutside
79
+ isDisabled
82
80
  ]);
83
81
  }
84
82
  function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
@@ -86,7 +84,7 @@ function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
86
84
  if (event.target) {
87
85
  // if the event target is no longer in the document, ignore
88
86
  const ownerDocument = event.target.ownerDocument;
89
- if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
87
+ if (!ownerDocument || !(0, $ispOf$nodeContains)(ownerDocument.documentElement, event.target)) return false;
90
88
  // If the target is within a top layer element (e.g. toasts), ignore.
91
89
  if (event.target.closest('[data-react-aria-top-layer]')) return false;
92
90
  }
@@ -1,4 +1,4 @@
1
- import {useEffectEvent as $ispOf$useEffectEvent, getOwnerDocument as $ispOf$getOwnerDocument} from "@react-aria/utils";
1
+ import {useEffectEvent as $ispOf$useEffectEvent, getOwnerDocument as $ispOf$getOwnerDocument, nodeContains as $ispOf$nodeContains} from "@react-aria/utils";
2
2
  import {useRef as $ispOf$useRef, useEffect as $ispOf$useEffect} from "react";
3
3
 
4
4
  /*
@@ -76,9 +76,7 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
76
76
  }
77
77
  }, [
78
78
  ref,
79
- isDisabled,
80
- onPointerDown,
81
- triggerInteractOutside
79
+ isDisabled
82
80
  ]);
83
81
  }
84
82
  function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
@@ -86,7 +84,7 @@ function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
86
84
  if (event.target) {
87
85
  // if the event target is no longer in the document, ignore
88
86
  const ownerDocument = event.target.ownerDocument;
89
- if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
87
+ if (!ownerDocument || !(0, $ispOf$nodeContains)(ownerDocument.documentElement, event.target)) return false;
90
88
  // If the target is within a top layer element (e.g. toasts), ignore.
91
89
  if (event.target.closest('[data-react-aria-top-layer]')) return false;
92
90
  }
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;AAkB3G,SAAS,0CAAmB,KAA2B;IAC5D,IAAI,OAAC,GAAG,qBAAE,iBAAiB,cAAE,UAAU,0BAAE,sBAAsB,EAAC,GAAG;IACnE,IAAI,WAAW,CAAA,GAAA,aAAK,EAAE;QACpB,eAAe;QACf,2BAA2B;IAC7B;IAEA,IAAI,gBAAgB,CAAA,GAAA,qBAAa,EAAE,CAAC;QAClC,IAAI,qBAAqB,mCAAa,GAAG,MAAM;YAC7C,IAAI,wBACF,uBAAuB;YAEzB,SAAS,OAAO,CAAC,aAAa,GAAG;QACn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,CAAC,WAAW,WAAW;gBACzD,eAAe,mBAAmB,CAAC,cAAc,eAAe;gBAChE,eAAe,mBAAmB,CAAC,YAAY,YAAY;YAC7D;QACF;IACF,GAAG;QAAC;QAAK;QAAY;QAAe;KAAuB;AAC7D;AAEA,SAAS,mCAAa,KAAK,EAAE,GAAG;IAC9B,IAAI,MAAM,MAAM,GAAG,GACjB,OAAO;IAET,IAAI,MAAM,MAAM,EAAE;QAChB,2DAA2D;QAC3D,MAAM,gBAAgB,MAAM,MAAM,CAAC,aAAa;QAChD,IAAI,CAAC,iBAAiB,CAAC,cAAc,eAAe,CAAC,QAAQ,CAAC,MAAM,MAAM,GACxE,OAAO;QAET,qEAAqE;QACrE,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,gCACvB,OAAO;IAEX;IAEA,IAAI,CAAC,IAAI,OAAO,EACd,OAAO;IAGT,sFAAsF;IACtF,+FAA+F;IAC/F,yFAAyF;IACzF,sEAAsE;IACtE,OAAO,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,OAAO;AACnD","sources":["packages/@react-aria/interactions/src/useInteractOutside.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 {getOwnerDocument, useEffectEvent} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useEffect, useRef} from 'react';\n\nexport interface InteractOutsideProps {\n ref: RefObject<Element | null>,\n onInteractOutside?: (e: PointerEvent) => void,\n onInteractOutsideStart?: (e: PointerEvent) => void,\n /** Whether the interact outside events should be disabled. */\n isDisabled?: boolean\n}\n\n/**\n * Example, used in components like Dialogs and Popovers so they can close\n * when a user clicks outside them.\n */\nexport function useInteractOutside(props: InteractOutsideProps): void {\n let {ref, onInteractOutside, isDisabled, onInteractOutsideStart} = props;\n let stateRef = useRef({\n isPointerDown: false,\n ignoreEmulatedMouseEvents: false\n });\n\n let onPointerDown = useEffectEvent((e) => {\n if (onInteractOutside && isValidEvent(e, ref)) {\n if (onInteractOutsideStart) {\n onInteractOutsideStart(e);\n }\n stateRef.current.isPointerDown = true;\n }\n });\n\n let triggerInteractOutside = useEffectEvent((e: PointerEvent) => {\n if (onInteractOutside) {\n onInteractOutside(e);\n }\n });\n\n useEffect(() => {\n let state = stateRef.current;\n if (isDisabled) {\n return;\n }\n\n const element = ref.current;\n const documentObject = getOwnerDocument(element);\n\n // Use pointer events if available. Otherwise, fall back to mouse and touch events.\n if (typeof PointerEvent !== 'undefined') {\n let onClick = (e) => {\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n // changing these to capture phase fixed combobox\n // Use click instead of pointerup to avoid Android Chrome issue\n // https://issues.chromium.org/issues/40732224\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('click', onClick, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('click', onClick, true);\n };\n } else if (process.env.NODE_ENV === 'test') {\n let onMouseUp = (e) => {\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n } else if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n let onTouchEnd = (e) => {\n state.ignoreEmulatedMouseEvents = true;\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n documentObject.addEventListener('mousedown', onPointerDown, true);\n documentObject.addEventListener('mouseup', onMouseUp, true);\n documentObject.addEventListener('touchstart', onPointerDown, true);\n documentObject.addEventListener('touchend', onTouchEnd, true);\n\n return () => {\n documentObject.removeEventListener('mousedown', onPointerDown, true);\n documentObject.removeEventListener('mouseup', onMouseUp, true);\n documentObject.removeEventListener('touchstart', onPointerDown, true);\n documentObject.removeEventListener('touchend', onTouchEnd, true);\n };\n }\n }, [ref, isDisabled, onPointerDown, triggerInteractOutside]);\n}\n\nfunction isValidEvent(event, ref) {\n if (event.button > 0) {\n return false;\n }\n if (event.target) {\n // if the event target is no longer in the document, ignore\n const ownerDocument = event.target.ownerDocument;\n if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) {\n return false;\n }\n // If the target is within a top layer element (e.g. toasts), ignore.\n if (event.target.closest('[data-react-aria-top-layer]')) {\n return false;\n }\n }\n\n if (!ref.current) {\n return false;\n }\n\n // When the event source is inside a Shadow DOM, event.target is just the shadow root.\n // Using event.composedPath instead means we can get the actual element inside the shadow root.\n // This only works if the shadow root is open, there is no way to detect if it is closed.\n // If the event composed path contains the ref, interaction is inside.\n return !event.composedPath().includes(ref.current);\n}\n"],"names":[],"version":3,"file":"useInteractOutside.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;AAkB3G,SAAS,0CAAmB,KAA2B;IAC5D,IAAI,OAAC,GAAG,qBAAE,iBAAiB,cAAE,UAAU,0BAAE,sBAAsB,EAAC,GAAG;IACnE,IAAI,WAAW,CAAA,GAAA,aAAK,EAAE;QACpB,eAAe;QACf,2BAA2B;IAC7B;IAEA,IAAI,gBAAgB,CAAA,GAAA,qBAAa,EAAE,CAAC;QAClC,IAAI,qBAAqB,mCAAa,GAAG,MAAM;YAC7C,IAAI,wBACF,uBAAuB;YAEzB,SA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Aa,eAAe;gBAC/D,eAAe,mBAAmB,CAAC,WAAW,WAAW;gBACzD,eAAe,mBAAmB,CAAC,cAAc,eAAe;gBAChE,eAAe,mBAAmB,CAAC,YAAY,YAAY;YAC7D;QACF;IACF,GAAG;QAAC;QAAK;KAAW;AACtB;AAEA,SAAS,mCAAa,KAAK,EAAE,GAAG;IAC9B,IAAI,MAAM,MAAM,GAAG,GACjB,OAAO;IAET,IAAI,MAAM,MAAM,EAAE;QAChB,2DAA2D;QAC3D,MAAM,gBAAgB,MAAM,MAAM,CAAC,aAAa;QAChD,IAAI,CAAC,iBAAiB,CAAC,CAAA,GAAA,mBAAW,EAAE,cAAc,eAAe,EAAE,MAAM,MAAM,GAC7E,OAAO;QAET,qEAAqE;QACrE,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,gCACvB,OAAO;IAEX;IAEA,IAAI,CAAC,IAAI,OAAO,EACd,OAAO;IAGT,sFAAsF;IACtF,+FAA+F;IAC/F,yFAAyF;IACzF,sEAAsE;IACtE,OAAO,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,OAAO;AACnD","sources":["packages/@react-aria/interactions/src/useInteractOutside.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 {getOwnerDocument, nodeContains, useEffectEvent} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useEffect, useRef} from 'react';\n\nexport interface InteractOutsideProps {\n ref: RefObject<Element | null>,\n onInteractOutside?: (e: PointerEvent) => void,\n onInteractOutsideStart?: (e: PointerEvent) => void,\n /** Whether the interact outside events should be disabled. */\n isDisabled?: boolean\n}\n\n/**\n * Example, used in components like Dialogs and Popovers so they can close\n * when a user clicks outside them.\n */\nexport function useInteractOutside(props: InteractOutsideProps): void {\n let {ref, onInteractOutside, isDisabled, onInteractOutsideStart} = props;\n let stateRef = useRef({\n isPointerDown: false,\n ignoreEmulatedMouseEvents: false\n });\n\n let onPointerDown = useEffectEvent((e) => {\n if (onInteractOutside && isValidEvent(e, ref)) {\n if (onInteractOutsideStart) {\n onInteractOutsideStart(e);\n }\n stateRef.current.isPointerDown = true;\n }\n });\n\n let triggerInteractOutside = useEffectEvent((e: PointerEvent) => {\n if (onInteractOutside) {\n onInteractOutside(e);\n }\n });\n\n useEffect(() => {\n let state = stateRef.current;\n if (isDisabled) {\n return;\n }\n\n const element = ref.current;\n const documentObject = getOwnerDocument(element);\n\n // Use pointer events if available. Otherwise, fall back to mouse and touch events.\n if (typeof PointerEvent !== 'undefined') {\n let onClick = (e) => {\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n // changing these to capture phase fixed combobox\n // Use click instead of pointerup to avoid Android Chrome issue\n // https://issues.chromium.org/issues/40732224\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('click', onClick, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('click', onClick, true);\n };\n } else if (process.env.NODE_ENV === 'test') {\n let onMouseUp = (e) => {\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n } else if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n let onTouchEnd = (e) => {\n state.ignoreEmulatedMouseEvents = true;\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n documentObject.addEventListener('mousedown', onPointerDown, true);\n documentObject.addEventListener('mouseup', onMouseUp, true);\n documentObject.addEventListener('touchstart', onPointerDown, true);\n documentObject.addEventListener('touchend', onTouchEnd, true);\n\n return () => {\n documentObject.removeEventListener('mousedown', onPointerDown, true);\n documentObject.removeEventListener('mouseup', onMouseUp, true);\n documentObject.removeEventListener('touchstart', onPointerDown, true);\n documentObject.removeEventListener('touchend', onTouchEnd, true);\n };\n }\n }, [ref, isDisabled]);\n}\n\nfunction isValidEvent(event, ref) {\n if (event.button > 0) {\n return false;\n }\n if (event.target) {\n // if the event target is no longer in the document, ignore\n const ownerDocument = event.target.ownerDocument;\n if (!ownerDocument || !nodeContains(ownerDocument.documentElement, event.target)) {\n return false;\n }\n // If the target is within a top layer element (e.g. toasts), ignore.\n if (event.target.closest('[data-react-aria-top-layer]')) {\n return false;\n }\n }\n\n if (!ref.current) {\n return false;\n }\n\n // When the event source is inside a Shadow DOM, event.target is just the shadow root.\n // Using event.composedPath instead means we can get the actual element inside the shadow root.\n // This only works if the shadow root is open, there is no way to detect if it is closed.\n // If the event composed path contains the ref, interaction is inside.\n return !event.composedPath().includes(ref.current);\n}\n"],"names":[],"version":3,"file":"useInteractOutside.module.js.map"}
@@ -29,7 +29,7 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
29
29
  id: null
30
30
  });
31
31
  let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $cvDGj$reactariautils.useGlobalListeners)();
32
- let move = (0, $cvDGj$reactariautils.useEffectEvent)((originalEvent, pointerType, deltaX, deltaY)=>{
32
+ let move = (0, $cvDGj$react.useCallback)((originalEvent, pointerType, deltaX, deltaY)=>{
33
33
  if (deltaX === 0 && deltaY === 0) return;
34
34
  if (!state.current.didMove) {
35
35
  state.current.didMove = true;
@@ -52,8 +52,13 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
52
52
  ctrlKey: originalEvent.ctrlKey,
53
53
  altKey: originalEvent.altKey
54
54
  });
55
- });
56
- let end = (0, $cvDGj$reactariautils.useEffectEvent)((originalEvent, pointerType)=>{
55
+ }, [
56
+ onMoveStart,
57
+ onMove,
58
+ state
59
+ ]);
60
+ let moveEvent = (0, $cvDGj$reactariautils.useEffectEvent)(move);
61
+ let end = (0, $cvDGj$react.useCallback)((originalEvent, pointerType)=>{
57
62
  (0, $f7e14e656343df57$exports.restoreTextSelection)();
58
63
  if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
59
64
  type: 'moveend',
@@ -63,45 +68,75 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
63
68
  ctrlKey: originalEvent.ctrlKey,
64
69
  altKey: originalEvent.altKey
65
70
  });
66
- });
67
- let moveProps = (0, $cvDGj$react.useMemo)(()=>{
68
- let moveProps = {};
69
- let start = ()=>{
70
- (0, $f7e14e656343df57$exports.disableTextSelection)();
71
- state.current.didMove = false;
72
- };
73
- if (typeof PointerEvent === 'undefined' && process.env.NODE_ENV === 'test') {
74
- let onMouseMove = (e)=>{
75
- if (e.button === 0) {
71
+ }, [
72
+ onMoveEnd,
73
+ state
74
+ ]);
75
+ let endEvent = (0, $cvDGj$reactariautils.useEffectEvent)(end);
76
+ let [pointerDown, setPointerDown] = (0, $cvDGj$react.useState)(null);
77
+ (0, $cvDGj$reactariautils.useLayoutEffect)(()=>{
78
+ if (pointerDown === 'pointer') {
79
+ let onPointerMove = (e)=>{
80
+ if (e.pointerId === state.current.id) {
76
81
  var _state_current_lastPosition, _state_current_lastPosition1;
82
+ let pointerType = e.pointerType || 'mouse';
77
83
  var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
78
- move(e, 'mouse', e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
84
+ // Problems with PointerEvent#movementX/movementY:
85
+ // 1. it is always 0 on macOS Safari.
86
+ // 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS
87
+ moveEvent(e, pointerType, e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
79
88
  state.current.lastPosition = {
80
89
  pageX: e.pageX,
81
90
  pageY: e.pageY
82
91
  };
83
92
  }
84
93
  };
85
- let onMouseUp = (e)=>{
86
- if (e.button === 0) {
87
- end(e, 'mouse');
88
- removeGlobalListener(window, 'mousemove', onMouseMove, false);
89
- removeGlobalListener(window, 'mouseup', onMouseUp, false);
94
+ let onPointerUp = (e)=>{
95
+ if (e.pointerId === state.current.id) {
96
+ let pointerType = e.pointerType || 'mouse';
97
+ endEvent(e, pointerType);
98
+ state.current.id = null;
99
+ removeGlobalListener(window, 'pointermove', onPointerMove, false);
100
+ removeGlobalListener(window, 'pointerup', onPointerUp, false);
101
+ removeGlobalListener(window, 'pointercancel', onPointerUp, false);
102
+ setPointerDown(null);
90
103
  }
91
104
  };
92
- moveProps.onMouseDown = (e)=>{
105
+ addGlobalListener(window, 'pointermove', onPointerMove, false);
106
+ addGlobalListener(window, 'pointerup', onPointerUp, false);
107
+ addGlobalListener(window, 'pointercancel', onPointerUp, false);
108
+ return ()=>{
109
+ removeGlobalListener(window, 'pointermove', onPointerMove, false);
110
+ removeGlobalListener(window, 'pointerup', onPointerUp, false);
111
+ removeGlobalListener(window, 'pointercancel', onPointerUp, false);
112
+ };
113
+ } else if (pointerDown === 'mouse' && process.env.NODE_ENV === 'test') {
114
+ let onMouseMove = (e)=>{
93
115
  if (e.button === 0) {
94
- start();
95
- e.stopPropagation();
96
- e.preventDefault();
116
+ var _state_current_lastPosition, _state_current_lastPosition1;
117
+ var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
118
+ moveEvent(e, 'mouse', e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
97
119
  state.current.lastPosition = {
98
120
  pageX: e.pageX,
99
121
  pageY: e.pageY
100
122
  };
101
- addGlobalListener(window, 'mousemove', onMouseMove, false);
102
- addGlobalListener(window, 'mouseup', onMouseUp, false);
103
123
  }
104
124
  };
125
+ let onMouseUp = (e)=>{
126
+ if (e.button === 0) {
127
+ endEvent(e, 'mouse');
128
+ removeGlobalListener(window, 'mousemove', onMouseMove, false);
129
+ removeGlobalListener(window, 'mouseup', onMouseUp, false);
130
+ setPointerDown(null);
131
+ }
132
+ };
133
+ addGlobalListener(window, 'mousemove', onMouseMove, false);
134
+ addGlobalListener(window, 'mouseup', onMouseUp, false);
135
+ return ()=>{
136
+ removeGlobalListener(window, 'mousemove', onMouseMove, false);
137
+ removeGlobalListener(window, 'mouseup', onMouseUp, false);
138
+ };
139
+ } else if (pointerDown === 'touch' && process.env.NODE_ENV === 'test') {
105
140
  let onTouchMove = (e)=>{
106
141
  let touch = [
107
142
  ...e.changedTouches
@@ -110,7 +145,7 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
110
145
  var _state_current_lastPosition, _state_current_lastPosition1;
111
146
  let { pageX: pageX, pageY: pageY } = e.changedTouches[touch];
112
147
  var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
113
- move(e, 'touch', pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
148
+ moveEvent(e, 'touch', pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
114
149
  state.current.lastPosition = {
115
150
  pageX: pageX,
116
151
  pageY: pageY
@@ -122,11 +157,45 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
122
157
  ...e.changedTouches
123
158
  ].findIndex(({ identifier: identifier })=>identifier === state.current.id);
124
159
  if (touch >= 0) {
125
- end(e, 'touch');
160
+ endEvent(e, 'touch');
126
161
  state.current.id = null;
127
162
  removeGlobalListener(window, 'touchmove', onTouchMove);
128
163
  removeGlobalListener(window, 'touchend', onTouchEnd);
129
164
  removeGlobalListener(window, 'touchcancel', onTouchEnd);
165
+ setPointerDown(null);
166
+ }
167
+ };
168
+ addGlobalListener(window, 'touchmove', onTouchMove, false);
169
+ addGlobalListener(window, 'touchend', onTouchEnd, false);
170
+ addGlobalListener(window, 'touchcancel', onTouchEnd, false);
171
+ return ()=>{
172
+ removeGlobalListener(window, 'touchmove', onTouchMove, false);
173
+ removeGlobalListener(window, 'touchend', onTouchEnd, false);
174
+ removeGlobalListener(window, 'touchcancel', onTouchEnd, false);
175
+ };
176
+ }
177
+ }, [
178
+ pointerDown,
179
+ addGlobalListener,
180
+ removeGlobalListener
181
+ ]);
182
+ let moveProps = (0, $cvDGj$react.useMemo)(()=>{
183
+ let moveProps = {};
184
+ let start = ()=>{
185
+ (0, $f7e14e656343df57$exports.disableTextSelection)();
186
+ state.current.didMove = false;
187
+ };
188
+ if (typeof PointerEvent === 'undefined' && process.env.NODE_ENV === 'test') {
189
+ moveProps.onMouseDown = (e)=>{
190
+ if (e.button === 0) {
191
+ start();
192
+ e.stopPropagation();
193
+ e.preventDefault();
194
+ state.current.lastPosition = {
195
+ pageX: e.pageX,
196
+ pageY: e.pageY
197
+ };
198
+ setPointerDown('mouse');
130
199
  }
131
200
  };
132
201
  moveProps.onTouchStart = (e)=>{
@@ -140,52 +209,21 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
140
209
  pageY: pageY
141
210
  };
142
211
  state.current.id = identifier;
143
- addGlobalListener(window, 'touchmove', onTouchMove, false);
144
- addGlobalListener(window, 'touchend', onTouchEnd, false);
145
- addGlobalListener(window, 'touchcancel', onTouchEnd, false);
146
- };
147
- } else {
148
- let onPointerMove = (e)=>{
149
- if (e.pointerId === state.current.id) {
150
- var _state_current_lastPosition, _state_current_lastPosition1;
151
- let pointerType = e.pointerType || 'mouse';
152
- var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
153
- // Problems with PointerEvent#movementX/movementY:
154
- // 1. it is always 0 on macOS Safari.
155
- // 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS
156
- move(e, pointerType, e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
157
- state.current.lastPosition = {
158
- pageX: e.pageX,
159
- pageY: e.pageY
160
- };
161
- }
212
+ setPointerDown('touch');
162
213
  };
163
- let onPointerUp = (e)=>{
164
- if (e.pointerId === state.current.id) {
165
- let pointerType = e.pointerType || 'mouse';
166
- end(e, pointerType);
167
- state.current.id = null;
168
- removeGlobalListener(window, 'pointermove', onPointerMove, false);
169
- removeGlobalListener(window, 'pointerup', onPointerUp, false);
170
- removeGlobalListener(window, 'pointercancel', onPointerUp, false);
171
- }
172
- };
173
- moveProps.onPointerDown = (e)=>{
174
- if (e.button === 0 && state.current.id == null) {
175
- start();
176
- e.stopPropagation();
177
- e.preventDefault();
178
- state.current.lastPosition = {
179
- pageX: e.pageX,
180
- pageY: e.pageY
181
- };
182
- state.current.id = e.pointerId;
183
- addGlobalListener(window, 'pointermove', onPointerMove, false);
184
- addGlobalListener(window, 'pointerup', onPointerUp, false);
185
- addGlobalListener(window, 'pointercancel', onPointerUp, false);
186
- }
187
- };
188
- }
214
+ } else moveProps.onPointerDown = (e)=>{
215
+ if (e.button === 0 && state.current.id == null) {
216
+ start();
217
+ e.stopPropagation();
218
+ e.preventDefault();
219
+ state.current.lastPosition = {
220
+ pageX: e.pageX,
221
+ pageY: e.pageY
222
+ };
223
+ state.current.id = e.pointerId;
224
+ setPointerDown('pointer');
225
+ }
226
+ };
189
227
  let triggerKeyboardMove = (e, deltaX, deltaY)=>{
190
228
  start();
191
229
  move(e, 'keyboard', deltaX, deltaY);
@@ -222,8 +260,6 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
222
260
  return moveProps;
223
261
  }, [
224
262
  state,
225
- addGlobalListener,
226
- removeGlobalListener,
227
263
  move,
228
264
  end
229
265
  ]);
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAwBM,SAAS,0CAAQ,KAAiB;IACvC,IAAI,eAAC,WAAW,UAAE,MAAM,aAAE,SAAS,EAAC,GAAG;IAEvC,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAId;QAAC,SAAS;QAAO,cAAc;QAAM,IAAI;IAAI;IAEhD,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IAEjE,IAAI,OAAO,CAAA,GAAA,oCAAa,EAAE,CAAC,eAA0B,aAA0B,QAAgB;QAC7F,IAAI,WAAW,KAAK,WAAW,GAC7B;QAGF,IAAI,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE;YAC1B,MAAM,OAAO,CAAC,OAAO,GAAG;YACxB,wBAAA,kCAAA,YAAc;gBACZ,MAAM;6BACN;gBACA,UAAU,cAAc,QAAQ;gBAChC,SAAS,cAAc,OAAO;gBAC9B,SAAS,cAAc,OAAO;gBAC9B,QAAQ,cAAc,MAAM;YAC9B;QACF;QACA,mBAAA,6BAAA,OAAS;YACP,MAAM;yBACN;YACA,QAAQ;YACR,QAAQ;YACR,UAAU,cAAc,QAAQ;YAChC,SAAS,cAAc,OAAO;YAC9B,SAAS,cAAc,OAAO;YAC9B,QAAQ,cAAc,MAAM;QAC9B;IACF;IAEA,IAAI,MAAM,CAAA,GAAA,oCAAa,EAAE,CAAC,eAA0B;QAClD,CAAA,GAAA,8CAAmB;QACnB,IAAI,MAAM,OAAO,CAAC,OAAO,EACvB,sBAAA,gCAAA,UAAY;YACV,MAAM;yBACN;YACA,UAAU,cAAc,QAAQ;Y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AAE,cAAc;oBAChB,MAAM,OAAO,CAAC,YAAY,GAAG;wBAAC,OAAO,EAAE,KAAK;wBAAE,OAAO,EAAE,KAAK;oBAAA;oBAC5D,MAAM,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS;oBAC9B,kBAAkB,QAAQ,eAAe,eAAe;oBACxD,kBAAkB,QAAQ,aAAa,aAAa;oBACpD,kBAAkB,QAAQ,iBAAiB,aAAa;gBAC1D;YACF;QACF;QAEA,IAAI,sBAAsB,CAAC,GAAc,QAAgB;YACvD;YACA,KAAK,GAAG,YAAY,QAAQ;YAC5B,IAAI,GAAG;QACT;QAEA,UAAU,SAAS,GAAG,CAAC;YACrB,OAAQ,EAAE,GAAG;gBACX,KAAK;gBACL,KAAK;oBACH,EAAE,cAAc;oBAChB,EAAE,eAAe;oBACjB,oBAAoB,GAAG,IAAI;oBAC3B;gBACF,KAAK;gBACL,KAAK;oBACH,EAAE,cAAc;oBAChB,EAAE,eAAe;oBACjB,oBAAoB,GAAG,GAAG;oBAC1B;gBACF,KAAK;gBACL,KAAK;oBACH,EAAE,cAAc;oBAChB,EAAE,eAAe;oBACjB,oBAAoB,GAAG,GAAG;oBAC1B;gBACF,KAAK;gBACL,KAAK;oBACH,EAAE,cAAc;oBAChB,EAAE,eAAe;oBACjB,oBAAoB,GAAG,GAAG;oBAC1B;YACJ;QACF;QAEA,OAAO;IACT,GAAG;QAAC;QAAO;QAAmB;QAAsB;QAAM;KAAI;IAE9D,OAAO;mBAAC;IAAS;AACnB","sources":["packages/@react-aria/interactions/src/useMove.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 {disableTextSelection, restoreTextSelection} from './textSelection';\nimport {DOMAttributes, MoveEvents, PointerType} from '@react-types/shared';\nimport React, {useMemo, useRef} from 'react';\nimport {useEffectEvent, useGlobalListeners} from '@react-aria/utils';\n\nexport interface MoveResult {\n /** Props to spread on the target element. */\n moveProps: DOMAttributes\n}\n\ninterface EventBase {\n shiftKey: boolean,\n ctrlKey: boolean,\n metaKey: boolean,\n altKey: boolean\n}\n\n/**\n * Handles move interactions across mouse, touch, and keyboard, including dragging with\n * the mouse or touch, and using the arrow keys. Normalizes behavior across browsers and\n * platforms, and ignores emulated mouse events on touch devices.\n */\nexport function useMove(props: MoveEvents): MoveResult {\n let {onMoveStart, onMove, onMoveEnd} = props;\n\n let state = useRef<{\n didMove: boolean,\n lastPosition: {pageX: number, pageY: number} | null,\n id: number | null\n }>({didMove: false, lastPosition: null, id: null});\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let move = useEffectEvent((originalEvent: EventBase, pointerType: PointerType, deltaX: number, deltaY: number) => {\n if (deltaX === 0 && deltaY === 0) {\n return;\n }\n\n if (!state.current.didMove) {\n state.current.didMove = true;\n onMoveStart?.({\n type: 'movestart',\n pointerType,\n shiftKey: originalEvent.shiftKey,\n metaKey: originalEvent.metaKey,\n ctrlKey: originalEvent.ctrlKey,\n altKey: originalEvent.altKey\n });\n }\n onMove?.({\n type: 'move',\n pointerType,\n deltaX: deltaX,\n deltaY: deltaY,\n shiftKey: originalEvent.shiftKey,\n metaKey: originalEvent.metaKey,\n ctrlKey: originalEvent.ctrlKey,\n altKey: originalEvent.altKey\n });\n });\n\n let end = useEffectEvent((originalEvent: EventBase, pointerType: PointerType) => {\n restoreTextSelection();\n if (state.current.didMove) {\n onMoveEnd?.({\n type: 'moveend',\n pointerType,\n shiftKey: originalEvent.shiftKey,\n metaKey: originalEvent.metaKey,\n ctrlKey: originalEvent.ctrlKey,\n altKey: originalEvent.altKey\n });\n }\n });\n\n let moveProps = useMemo(() => {\n let moveProps: DOMAttributes = {};\n\n let start = () => {\n disableTextSelection();\n state.current.didMove = false;\n };\n\n if (typeof PointerEvent === 'undefined' && process.env.NODE_ENV === 'test') {\n let onMouseMove = (e: MouseEvent) => {\n if (e.button === 0) {\n move(e, 'mouse', e.pageX - (state.current.lastPosition?.pageX ?? 0), e.pageY - (state.current.lastPosition?.pageY ?? 0));\n state.current.lastPosition = {pageX: e.pageX, pageY: e.pageY};\n }\n };\n let onMouseUp = (e: MouseEvent) => {\n if (e.button === 0) {\n end(e, 'mouse');\n removeGlobalListener(window, 'mousemove', onMouseMove, false);\n removeGlobalListener(window, 'mouseup', onMouseUp, false);\n }\n };\n moveProps.onMouseDown = (e: React.MouseEvent) => {\n if (e.button === 0) {\n start();\n e.stopPropagation();\n e.preventDefault();\n state.current.lastPosition = {pageX: e.pageX, pageY: e.pageY};\n addGlobalListener(window, 'mousemove', onMouseMove, false);\n addGlobalListener(window, 'mouseup', onMouseUp, false);\n }\n };\n\n let onTouchMove = (e: TouchEvent) => {\n let touch = [...e.changedTouches].findIndex(({identifier}) => identifier === state.current.id);\n if (touch >= 0) {\n let {pageX, pageY} = e.changedTouches[touch];\n move(e, 'touch', pageX - (state.current.lastPosition?.pageX ?? 0), pageY - (state.current.lastPosition?.pageY ?? 0));\n state.current.lastPosition = {pageX, pageY};\n }\n };\n let onTouchEnd = (e: TouchEvent) => {\n let touch = [...e.changedTouches].findIndex(({identifier}) => identifier === state.current.id);\n if (touch >= 0) {\n end(e, 'touch');\n state.current.id = null;\n removeGlobalListener(window, 'touchmove', onTouchMove);\n removeGlobalListener(window, 'touchend', onTouchEnd);\n removeGlobalListener(window, 'touchcancel', onTouchEnd);\n }\n };\n moveProps.onTouchStart = (e: React.TouchEvent) => {\n if (e.changedTouches.length === 0 || state.current.id != null) {\n return;\n }\n\n let {pageX, pageY, identifier} = e.changedTouches[0];\n start();\n e.stopPropagation();\n e.preventDefault();\n state.current.lastPosition = {pageX, pageY};\n state.current.id = identifier;\n addGlobalListener(window, 'touchmove', onTouchMove, false);\n addGlobalListener(window, 'touchend', onTouchEnd, false);\n addGlobalListener(window, 'touchcancel', onTouchEnd, false);\n };\n } else {\n let onPointerMove = (e: PointerEvent) => {\n if (e.pointerId === state.current.id) {\n let pointerType = (e.pointerType || 'mouse') as PointerType;\n\n // Problems with PointerEvent#movementX/movementY:\n // 1. it is always 0 on macOS Safari.\n // 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS\n move(e, pointerType, e.pageX - (state.current.lastPosition?.pageX ?? 0), e.pageY - (state.current.lastPosition?.pageY ?? 0));\n state.current.lastPosition = {pageX: e.pageX, pageY: e.pageY};\n }\n };\n\n let onPointerUp = (e: PointerEvent) => {\n if (e.pointerId === state.current.id) {\n let pointerType = (e.pointerType || 'mouse') as PointerType;\n end(e, pointerType);\n state.current.id = null;\n removeGlobalListener(window, 'pointermove', onPointerMove, false);\n removeGlobalListener(window, 'pointerup', onPointerUp, false);\n removeGlobalListener(window, 'pointercancel', onPointerUp, false);\n }\n };\n\n moveProps.onPointerDown = (e: React.PointerEvent) => {\n if (e.button === 0 && state.current.id == null) {\n start();\n e.stopPropagation();\n e.preventDefault();\n state.current.lastPosition = {pageX: e.pageX, pageY: e.pageY};\n state.current.id = e.pointerId;\n addGlobalListener(window, 'pointermove', onPointerMove, false);\n addGlobalListener(window, 'pointerup', onPointerUp, false);\n addGlobalListener(window, 'pointercancel', onPointerUp, false);\n }\n };\n }\n\n let triggerKeyboardMove = (e: EventBase, deltaX: number, deltaY: number) => {\n start();\n move(e, 'keyboard', deltaX, deltaY);\n end(e, 'keyboard');\n };\n\n moveProps.onKeyDown = (e) => {\n switch (e.key) {\n case 'Left':\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n triggerKeyboardMove(e, -1, 0);\n break;\n case 'Right':\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n triggerKeyboardMove(e, 1, 0);\n break;\n case 'Up':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n triggerKeyboardMove(e, 0, -1);\n break;\n case 'Down':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n triggerKeyboardMove(e, 0, 1);\n break;\n }\n };\n\n return moveProps;\n }, [state, addGlobalListener, removeGlobalListener, move, end]);\n\n return {moveProps};\n}\n"],"names":[],"version":3,"file":"useMove.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAwBM,SAAS,0CAAQ,KAAiB;IACvC,IAAI,eAAC,WAAW,UAAE,MAAM,aAAE,SAAS,EAAC,GAAG;IAEvC,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAId;QAAC,SAAS;QAAO,cAAc;QAAM,IAAI;IAAI;IAEhD,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IAEjE,IAAI,OAAO,CAAA,GAAA,wBAAU,EAAE,CAAC,eAA0B,aAA0B,QAAgB;QAC1F,IAAI,WAAW,KAAK,WAAW,GAC7B;QAGF,IAAI,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE;YAC1B,MAAM,OAAO,CAAC,OAAO,GAAG;YACxB,wBAAA,kCAAA,YAAc;gBACZ,MAAM;6BACN;gBACA,UAAU,cAAc,QAAQ;gBAChC,SAAS,cAAc,OAAO;gBAC9B,SAAS,cAAc,OAAO;gBAC9B,QAAQ,cAAc,MAAM;YAC9B;QACF;QACA,mBAAA,6BAAA,OAAS;YACP,MAAM;yBACN;YACA,QAAQ;YACR,QAAQ;YACR,UAAU,cAAc,QAAQ;YAChC,SAAS,cAAc,OAAO;YAC9B,SAAS,cAAc,OAAO;YAC9B,QAAQ,cAAc,MAAM;QAC9B;IACF,GAAG;QAAC;QAAa;QAAQ;KAAM;IAC/B,IAAI,YAAY,CAAA,GAAA,oCAAa,EAAE;IAE/B,IAAI,MAAM,CAAA,GAAA,wBAAU,EAAE,CAAC,eAA0B;QAC/C,C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,YAAY,QAAQ;YAC5B,IAAI,GAAG;QACT;QAEA,UAAU,SAAS,GAAG,CAAC;YACrB,OAAQ,EAAE,GAAG;gBACX,KAAK;gBACL,KAAK;oBACH,EAAE,cAAc;oBAChB,EAAE,eAAe;oBACjB,oBAAoB,GAAG,IAAI;oBAC3B;gBACF,KAAK;gBACL,KAAK;oBACH,EAAE,cAAc;oBAChB,EAAE,eAAe;oBACjB,oBAAoB,GAAG,GAAG;oBAC1B;gBACF,KAAK;gBACL,KAAK;oBACH,EAAE,cAAc;oBAChB,EAAE,eAAe;oBACjB,oBAAoB,GAAG,GAAG;oBAC1B;gBACF,KAAK;gBACL,KAAK;oBACH,EAAE,cAAc;oBAChB,EAAE,eAAe;oBACjB,oBAAoB,GAAG,GAAG;oBAC1B;YACJ;QACF;QAEA,OAAO;IACT,GAAG;QAAC;QAAO;QAAM;KAAI;IAErB,OAAO;mBAAC;IAAS;AACnB","sources":["packages/@react-aria/interactions/src/useMove.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 {disableTextSelection, restoreTextSelection} from './textSelection';\nimport {DOMAttributes, MoveEvents, PointerType} from '@react-types/shared';\nimport React, {useCallback, useMemo, useRef, useState} from 'react';\nimport {useEffectEvent, useGlobalListeners, useLayoutEffect} from '@react-aria/utils';\n\nexport interface MoveResult {\n /** Props to spread on the target element. */\n moveProps: DOMAttributes\n}\n\ninterface EventBase {\n shiftKey: boolean,\n ctrlKey: boolean,\n metaKey: boolean,\n altKey: boolean\n}\n\n/**\n * Handles move interactions across mouse, touch, and keyboard, including dragging with\n * the mouse or touch, and using the arrow keys. Normalizes behavior across browsers and\n * platforms, and ignores emulated mouse events on touch devices.\n */\nexport function useMove(props: MoveEvents): MoveResult {\n let {onMoveStart, onMove, onMoveEnd} = props;\n\n let state = useRef<{\n didMove: boolean,\n lastPosition: {pageX: number, pageY: number} | null,\n id: number | null\n }>({didMove: false, lastPosition: null, id: null});\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let move = useCallback((originalEvent: EventBase, pointerType: PointerType, deltaX: number, deltaY: number) => {\n if (deltaX === 0 && deltaY === 0) {\n return;\n }\n\n if (!state.current.didMove) {\n state.current.didMove = true;\n onMoveStart?.({\n type: 'movestart',\n pointerType,\n shiftKey: originalEvent.shiftKey,\n metaKey: originalEvent.metaKey,\n ctrlKey: originalEvent.ctrlKey,\n altKey: originalEvent.altKey\n });\n }\n onMove?.({\n type: 'move',\n pointerType,\n deltaX: deltaX,\n deltaY: deltaY,\n shiftKey: originalEvent.shiftKey,\n metaKey: originalEvent.metaKey,\n ctrlKey: originalEvent.ctrlKey,\n altKey: originalEvent.altKey\n });\n }, [onMoveStart, onMove, state]);\n let moveEvent = useEffectEvent(move);\n\n let end = useCallback((originalEvent: EventBase, pointerType: PointerType) => {\n restoreTextSelection();\n if (state.current.didMove) {\n onMoveEnd?.({\n type: 'moveend',\n pointerType,\n shiftKey: originalEvent.shiftKey,\n metaKey: originalEvent.metaKey,\n ctrlKey: originalEvent.ctrlKey,\n altKey: originalEvent.altKey\n });\n }\n }, [onMoveEnd, state]);\n let endEvent = useEffectEvent(end);\n\n let [pointerDown, setPointerDown] = useState<'pointer' | 'mouse' | 'touch' | null>(null);\n useLayoutEffect(() => {\n if (pointerDown === 'pointer') {\n let onPointerMove = (e: PointerEvent) => {\n if (e.pointerId === state.current.id) {\n let pointerType = (e.pointerType || 'mouse') as PointerType;\n\n // Problems with PointerEvent#movementX/movementY:\n // 1. it is always 0 on macOS Safari.\n // 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS\n moveEvent(e, pointerType, e.pageX - (state.current.lastPosition?.pageX ?? 0), e.pageY - (state.current.lastPosition?.pageY ?? 0));\n state.current.lastPosition = {pageX: e.pageX, pageY: e.pageY};\n }\n };\n\n let onPointerUp = (e: PointerEvent) => {\n if (e.pointerId === state.current.id) {\n let pointerType = (e.pointerType || 'mouse') as PointerType;\n endEvent(e, pointerType);\n state.current.id = null;\n removeGlobalListener(window, 'pointermove', onPointerMove, false);\n removeGlobalListener(window, 'pointerup', onPointerUp, false);\n removeGlobalListener(window, 'pointercancel', onPointerUp, false);\n setPointerDown(null);\n }\n };\n addGlobalListener(window, 'pointermove', onPointerMove, false);\n addGlobalListener(window, 'pointerup', onPointerUp, false);\n addGlobalListener(window, 'pointercancel', onPointerUp, false);\n return () => {\n removeGlobalListener(window, 'pointermove', onPointerMove, false);\n removeGlobalListener(window, 'pointerup', onPointerUp, false);\n removeGlobalListener(window, 'pointercancel', onPointerUp, false);\n };\n } else if (pointerDown === 'mouse' && process.env.NODE_ENV === 'test') {\n let onMouseMove = (e: MouseEvent) => {\n if (e.button === 0) {\n moveEvent(e, 'mouse', e.pageX - (state.current.lastPosition?.pageX ?? 0), e.pageY - (state.current.lastPosition?.pageY ?? 0));\n state.current.lastPosition = {pageX: e.pageX, pageY: e.pageY};\n }\n };\n let onMouseUp = (e: MouseEvent) => {\n if (e.button === 0) {\n endEvent(e, 'mouse');\n removeGlobalListener(window, 'mousemove', onMouseMove, false);\n removeGlobalListener(window, 'mouseup', onMouseUp, false);\n setPointerDown(null);\n }\n };\n addGlobalListener(window, 'mousemove', onMouseMove, false);\n addGlobalListener(window, 'mouseup', onMouseUp, false);\n return () => {\n removeGlobalListener(window, 'mousemove', onMouseMove, false);\n removeGlobalListener(window, 'mouseup', onMouseUp, false);\n };\n } else if (pointerDown === 'touch' && process.env.NODE_ENV === 'test') {\n let onTouchMove = (e: TouchEvent) => {\n let touch = [...e.changedTouches].findIndex(({identifier}) => identifier === state.current.id);\n if (touch >= 0) {\n let {pageX, pageY} = e.changedTouches[touch];\n moveEvent(e, 'touch', pageX - (state.current.lastPosition?.pageX ?? 0), pageY - (state.current.lastPosition?.pageY ?? 0));\n state.current.lastPosition = {pageX, pageY};\n }\n };\n let onTouchEnd = (e: TouchEvent) => {\n let touch = [...e.changedTouches].findIndex(({identifier}) => identifier === state.current.id);\n if (touch >= 0) {\n endEvent(e, 'touch');\n state.current.id = null;\n removeGlobalListener(window, 'touchmove', onTouchMove);\n removeGlobalListener(window, 'touchend', onTouchEnd);\n removeGlobalListener(window, 'touchcancel', onTouchEnd);\n setPointerDown(null);\n }\n };\n addGlobalListener(window, 'touchmove', onTouchMove, false);\n addGlobalListener(window, 'touchend', onTouchEnd, false);\n addGlobalListener(window, 'touchcancel', onTouchEnd, false);\n return () => {\n removeGlobalListener(window, 'touchmove', onTouchMove, false);\n removeGlobalListener(window, 'touchend', onTouchEnd, false);\n removeGlobalListener(window, 'touchcancel', onTouchEnd, false);\n };\n }\n }, [pointerDown, addGlobalListener, removeGlobalListener]);\n\n let moveProps = useMemo(() => {\n let moveProps: DOMAttributes = {};\n\n let start = () => {\n disableTextSelection();\n state.current.didMove = false;\n };\n\n if (typeof PointerEvent === 'undefined' && process.env.NODE_ENV === 'test') {\n moveProps.onMouseDown = (e: React.MouseEvent) => {\n if (e.button === 0) {\n start();\n e.stopPropagation();\n e.preventDefault();\n state.current.lastPosition = {pageX: e.pageX, pageY: e.pageY};\n setPointerDown('mouse');\n }\n };\n moveProps.onTouchStart = (e: React.TouchEvent) => {\n if (e.changedTouches.length === 0 || state.current.id != null) {\n return;\n }\n\n let {pageX, pageY, identifier} = e.changedTouches[0];\n start();\n e.stopPropagation();\n e.preventDefault();\n state.current.lastPosition = {pageX, pageY};\n state.current.id = identifier;\n setPointerDown('touch');\n };\n } else {\n moveProps.onPointerDown = (e: React.PointerEvent) => {\n if (e.button === 0 && state.current.id == null) {\n start();\n e.stopPropagation();\n e.preventDefault();\n state.current.lastPosition = {pageX: e.pageX, pageY: e.pageY};\n state.current.id = e.pointerId;\n setPointerDown('pointer');\n }\n };\n }\n\n let triggerKeyboardMove = (e: EventBase, deltaX: number, deltaY: number) => {\n start();\n move(e, 'keyboard', deltaX, deltaY);\n end(e, 'keyboard');\n };\n\n moveProps.onKeyDown = (e) => {\n switch (e.key) {\n case 'Left':\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n triggerKeyboardMove(e, -1, 0);\n break;\n case 'Right':\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n triggerKeyboardMove(e, 1, 0);\n break;\n case 'Up':\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n triggerKeyboardMove(e, 0, -1);\n break;\n case 'Down':\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n triggerKeyboardMove(e, 0, 1);\n break;\n }\n };\n\n return moveProps;\n }, [state, move, end]);\n\n return {moveProps};\n}\n"],"names":[],"version":3,"file":"useMove.main.js.map"}