@react-aria/interactions 3.24.1 → 3.25.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 (75) hide show
  1. package/dist/PressResponder.main.js +1 -1
  2. package/dist/PressResponder.main.js.map +1 -1
  3. package/dist/PressResponder.mjs +1 -1
  4. package/dist/PressResponder.module.js +1 -1
  5. package/dist/PressResponder.module.js.map +1 -1
  6. package/dist/Pressable.main.js +1 -0
  7. package/dist/Pressable.main.js.map +1 -1
  8. package/dist/Pressable.mjs +1 -0
  9. package/dist/Pressable.module.js +1 -0
  10. package/dist/Pressable.module.js.map +1 -1
  11. package/dist/createEventHandler.main.js +1 -1
  12. package/dist/createEventHandler.main.js.map +1 -1
  13. package/dist/createEventHandler.mjs +1 -1
  14. package/dist/createEventHandler.module.js +1 -1
  15. package/dist/createEventHandler.module.js.map +1 -1
  16. package/dist/focusSafely.main.js.map +1 -1
  17. package/dist/focusSafely.module.js.map +1 -1
  18. package/dist/textSelection.main.js.map +1 -1
  19. package/dist/textSelection.module.js.map +1 -1
  20. package/dist/types.d.ts +1 -1
  21. package/dist/types.d.ts.map +1 -1
  22. package/dist/useFocusVisible.main.js +2 -2
  23. package/dist/useFocusVisible.main.js.map +1 -1
  24. package/dist/useFocusVisible.mjs +2 -2
  25. package/dist/useFocusVisible.module.js +2 -2
  26. package/dist/useFocusVisible.module.js.map +1 -1
  27. package/dist/useFocusWithin.main.js +4 -4
  28. package/dist/useFocusWithin.main.js.map +1 -1
  29. package/dist/useFocusWithin.mjs +5 -5
  30. package/dist/useFocusWithin.module.js +5 -5
  31. package/dist/useFocusWithin.module.js.map +1 -1
  32. package/dist/useFocusable.main.js +1 -0
  33. package/dist/useFocusable.main.js.map +1 -1
  34. package/dist/useFocusable.mjs +1 -0
  35. package/dist/useFocusable.module.js +1 -0
  36. package/dist/useFocusable.module.js.map +1 -1
  37. package/dist/useHover.main.js +3 -3
  38. package/dist/useHover.main.js.map +1 -1
  39. package/dist/useHover.mjs +3 -3
  40. package/dist/useHover.module.js +3 -3
  41. package/dist/useHover.module.js.map +1 -1
  42. package/dist/useInteractOutside.main.js +1 -1
  43. package/dist/useInteractOutside.main.js.map +1 -1
  44. package/dist/useInteractOutside.mjs +1 -1
  45. package/dist/useInteractOutside.module.js +1 -1
  46. package/dist/useInteractOutside.module.js.map +1 -1
  47. package/dist/useMove.main.js +1 -1
  48. package/dist/useMove.main.js.map +1 -1
  49. package/dist/useMove.mjs +1 -1
  50. package/dist/useMove.module.js +1 -1
  51. package/dist/useMove.module.js.map +1 -1
  52. package/dist/usePress.main.js +42 -7
  53. package/dist/usePress.main.js.map +1 -1
  54. package/dist/usePress.mjs +42 -7
  55. package/dist/usePress.module.js +42 -7
  56. package/dist/usePress.module.js.map +1 -1
  57. package/dist/utils.main.js +23 -32
  58. package/dist/utils.main.js.map +1 -1
  59. package/dist/utils.mjs +22 -32
  60. package/dist/utils.module.js +22 -32
  61. package/dist/utils.module.js.map +1 -1
  62. package/package.json +6 -6
  63. package/src/PressResponder.tsx +7 -5
  64. package/src/Pressable.tsx +4 -0
  65. package/src/createEventHandler.ts +1 -1
  66. package/src/focusSafely.ts +1 -1
  67. package/src/textSelection.ts +4 -4
  68. package/src/useFocusVisible.ts +3 -3
  69. package/src/useFocusWithin.ts +4 -4
  70. package/src/useFocusable.tsx +4 -0
  71. package/src/useHover.ts +3 -3
  72. package/src/useInteractOutside.ts +2 -2
  73. package/src/useMove.ts +1 -1
  74. package/src/usePress.ts +49 -10
  75. package/src/utils.ts +23 -54
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;;;;;;;;AAgFlH,SAAS,+CAAyB,KAAqB;IACrD,8DAA8D;IAC9D,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAoB;IAC7C,IAAI,SAAS;QACX,IAAI,Y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IAAI;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,SAAS,sCAAgB,MAAwB,EAAE,GAAW;IAC5D,6DAA6D;IAC7D,OAAO,OAAO,IAAI,KAAK,cAAc,OAAO,IAAI,KAAK,UACjD,QAAQ,MACR,wCAAkB,GAAG,CAAC,OAAO,IAAI;AACvC","sources":["packages/@react-aria/interactions/src/usePress.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 {\n chain,\n focusWithoutScrolling,\n getEventTarget,\n getOwnerDocument,\n getOwnerWindow,\n isMac,\n isVirtualClick,\n isVirtualPointerEvent,\n mergeProps,\n nodeContains,\n openLink,\n useEffectEvent,\n useGlobalListeners,\n useSyncRef\n} from '@react-aria/utils';\nimport {disableTextSelection, restoreTextSelection} from './textSelection';\nimport {DOMAttributes, FocusableElement, PressEvent as IPressEvent, PointerType, PressEvents, RefObject} from '@react-types/shared';\nimport {flushSync} from 'react-dom';\nimport {PressResponderContext} from './context';\nimport {preventFocus} from './utils';\nimport {TouchEvent as RTouchEvent, useContext, useEffect, useMemo, useRef, useState} from 'react';\n\nexport interface PressProps extends PressEvents {\n /** Whether the target is in a controlled press state (e.g. an overlay it triggers is open). */\n isPressed?: boolean,\n /** Whether the press events should be disabled. */\n isDisabled?: boolean,\n /** Whether the target should not receive focus on press. */\n preventFocusOnPress?: boolean,\n /**\n * Whether press events should be canceled when the pointer leaves the target while pressed.\n * By default, this is `false`, which means if the pointer returns back over the target while\n * still pressed, onPressStart will be fired again. If set to `true`, the press is canceled\n * when the pointer leaves the target and onPressStart will not be fired if the pointer returns.\n */\n shouldCancelOnPointerExit?: boolean,\n /** Whether text selection should be enabled on the pressable element. */\n allowTextSelectionOnPress?: boolean\n}\n\nexport interface PressHookProps extends PressProps {\n /** A ref to the target element. */\n ref?: RefObject<Element | null>\n}\n\ninterface PressState {\n isPressed: boolean,\n ignoreEmulatedMouseEvents: boolean,\n didFirePressStart: boolean,\n isTriggeringEvent: boolean,\n activePointerId: any,\n target: FocusableElement | null,\n isOverTarget: boolean,\n pointerType: PointerType | null,\n userSelect?: string,\n metaKeyEvents?: Map<string, KeyboardEvent>,\n disposables: Array<() => void>\n}\n\ninterface EventBase {\n currentTarget: EventTarget | null,\n shiftKey: boolean,\n ctrlKey: boolean,\n metaKey: boolean,\n altKey: boolean,\n clientX?: number,\n clientY?: number,\n targetTouches?: Array<{clientX?: number, clientY?: number}>\n}\n\nexport interface PressResult {\n /** Whether the target is currently pressed. */\n isPressed: boolean,\n /** Props to spread on the target element. */\n pressProps: DOMAttributes\n}\n\nfunction usePressResponderContext(props: PressHookProps): PressHookProps {\n // Consume context from <PressResponder> and merge with props.\n let context = useContext(PressResponderContext);\n if (context) {\n let {register, ...contextProps} = context;\n props = mergeProps(contextProps, props) as PressHookProps;\n register();\n }\n useSyncRef(context, props.ref);\n\n return props;\n}\n\nclass PressEvent implements IPressEvent {\n type: IPressEvent['type'];\n pointerType: PointerType;\n target: Element;\n shiftKey: boolean;\n ctrlKey: boolean;\n metaKey: boolean;\n altKey: boolean;\n x: number;\n y: number;\n #shouldStopPropagation = true;\n\n constructor(type: IPressEvent['type'], pointerType: PointerType, originalEvent: EventBase, state?: PressState) {\n let currentTarget = state?.target ?? originalEvent.currentTarget;\n const rect: DOMRect | undefined = (currentTarget as Element)?.getBoundingClientRect();\n let x, y = 0;\n let clientX, clientY: number | null = null;\n if (originalEvent.clientX != null && originalEvent.clientY != null) {\n clientX = originalEvent.clientX;\n clientY = originalEvent.clientY;\n }\n if (rect) {\n if (clientX != null && clientY != null) {\n x = clientX - rect.left;\n y = clientY - rect.top;\n } else {\n x = rect.width / 2;\n y = rect.height / 2;\n }\n }\n this.type = type;\n this.pointerType = pointerType;\n this.target = originalEvent.currentTarget as Element;\n this.shiftKey = originalEvent.shiftKey;\n this.metaKey = originalEvent.metaKey;\n this.ctrlKey = originalEvent.ctrlKey;\n this.altKey = originalEvent.altKey;\n this.x = x;\n this.y = y;\n }\n\n continuePropagation() {\n this.#shouldStopPropagation = false;\n }\n\n get shouldStopPropagation() {\n return this.#shouldStopPropagation;\n }\n}\n\nconst LINK_CLICKED = Symbol('linkClicked');\n\n/**\n * Handles press interactions across mouse, touch, keyboard, and screen readers.\n * It normalizes behavior across browsers and platforms, and handles many nuances\n * of dealing with pointer and keyboard events.\n */\nexport function usePress(props: PressHookProps): PressResult {\n let {\n onPress,\n onPressChange,\n onPressStart,\n onPressEnd,\n onPressUp,\n isDisabled,\n isPressed: isPressedProp,\n preventFocusOnPress,\n shouldCancelOnPointerExit,\n allowTextSelectionOnPress,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ref: _, // Removing `ref` from `domProps` because TypeScript is dumb\n ...domProps\n } = usePressResponderContext(props);\n\n let [isPressed, setPressed] = useState(false);\n let ref = useRef<PressState>({\n isPressed: false,\n ignoreEmulatedMouseEvents: false,\n didFirePressStart: false,\n isTriggeringEvent: false,\n activePointerId: null,\n target: null,\n isOverTarget: false,\n pointerType: null,\n disposables: []\n });\n\n let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();\n\n let triggerPressStart = useEffectEvent((originalEvent: EventBase, pointerType: PointerType) => {\n let state = ref.current;\n if (isDisabled || state.didFirePressStart) {\n return false;\n }\n\n let shouldStopPropagation = true;\n state.isTriggeringEvent = true;\n if (onPressStart) {\n let event = new PressEvent('pressstart', pointerType, originalEvent);\n onPressStart(event);\n shouldStopPropagation = event.shouldStopPropagation;\n }\n\n if (onPressChange) {\n onPressChange(true);\n }\n\n state.isTriggeringEvent = false;\n state.didFirePressStart = true;\n setPressed(true);\n return shouldStopPropagation;\n });\n\n let triggerPressEnd = useEffectEvent((originalEvent: EventBase, pointerType: PointerType, wasPressed = true) => {\n let state = ref.current;\n if (!state.didFirePressStart) {\n return false;\n }\n\n state.didFirePressStart = false;\n state.isTriggeringEvent = true;\n\n let shouldStopPropagation = true;\n if (onPressEnd) {\n let event = new PressEvent('pressend', pointerType, originalEvent);\n onPressEnd(event);\n shouldStopPropagation = event.shouldStopPropagation;\n }\n\n if (onPressChange) {\n onPressChange(false);\n }\n\n setPressed(false);\n\n if (onPress && wasPressed && !isDisabled) {\n let event = new PressEvent('press', pointerType, originalEvent);\n onPress(event);\n shouldStopPropagation &&= event.shouldStopPropagation;\n }\n\n state.isTriggeringEvent = false;\n return shouldStopPropagation;\n });\n\n let triggerPressUp = useEffectEvent((originalEvent: EventBase, pointerType: PointerType) => {\n let state = ref.current;\n if (isDisabled) {\n return false;\n }\n\n if (onPressUp) {\n state.isTriggeringEvent = true;\n let event = new PressEvent('pressup', pointerType, originalEvent);\n onPressUp(event);\n state.isTriggeringEvent = false;\n return event.shouldStopPropagation;\n }\n\n return true;\n });\n\n let cancel = useEffectEvent((e: EventBase) => {\n let state = ref.current;\n if (state.isPressed && state.target) {\n if (state.didFirePressStart && state.pointerType != null) {\n triggerPressEnd(createEvent(state.target, e), state.pointerType, false);\n }\n state.isPressed = false;\n state.isOverTarget = false;\n state.activePointerId = null;\n state.pointerType = null;\n removeAllGlobalListeners();\n if (!allowTextSelectionOnPress) {\n restoreTextSelection(state.target);\n }\n for (let dispose of state.disposables) {\n dispose();\n }\n state.disposables = [];\n }\n });\n\n let cancelOnPointerExit = useEffectEvent((e: EventBase) => {\n if (shouldCancelOnPointerExit) {\n cancel(e);\n }\n });\n\n let pressProps = useMemo(() => {\n let state = ref.current;\n let pressProps: DOMAttributes = {\n onKeyDown(e) {\n if (isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n if (shouldPreventDefaultKeyboard(getEventTarget(e.nativeEvent), e.key)) {\n e.preventDefault();\n }\n\n // If the event is repeating, it may have started on a different element\n // after which focus moved to the current element. Ignore these events and\n // only handle the first key down event.\n let shouldStopPropagation = true;\n if (!state.isPressed && !e.repeat) {\n state.target = e.currentTarget;\n state.isPressed = true;\n state.pointerType = 'keyboard';\n shouldStopPropagation = triggerPressStart(e, 'keyboard');\n\n // Focus may move before the key up event, so register the event on the document\n // instead of the same element where the key down event occurred. Make it capturing so that it will trigger\n // before stopPropagation from useKeyboard on a child element may happen and thus we can still call triggerPress for the parent element.\n let originalTarget = e.currentTarget;\n let pressUp = (e) => {\n if (isValidKeyboardEvent(e, originalTarget) && !e.repeat && nodeContains(originalTarget, getEventTarget(e)) && state.target) {\n triggerPressUp(createEvent(state.target, e), 'keyboard');\n }\n };\n\n addGlobalListener(getOwnerDocument(e.currentTarget), 'keyup', chain(pressUp, onKeyUp), true);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n // Keep track of the keydown events that occur while the Meta (e.g. Command) key is held.\n // macOS has a bug where keyup events are not fired while the Meta key is down.\n // When the Meta key itself is released we will get an event for that, and we'll act as if\n // all of these other keys were released as well.\n // https://bugs.chromium.org/p/chromium/issues/detail?id=1393524\n // https://bugs.webkit.org/show_bug.cgi?id=55291\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1299553\n if (e.metaKey && isMac()) {\n state.metaKeyEvents?.set(e.key, e.nativeEvent);\n }\n } else if (e.key === 'Meta') {\n state.metaKeyEvents = new Map();\n }\n },\n onClick(e) {\n if (e && !nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (e && e.button === 0 && !state.isTriggeringEvent && !(openLink as any).isOpening) {\n let shouldStopPropagation = true;\n if (isDisabled) {\n e.preventDefault();\n }\n \n // If triggered from a screen reader or by using element.click(),\n // trigger as if it were a keyboard click.\n if (!state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType === 'virtual' || isVirtualClick(e.nativeEvent))) {\n let stopPressStart = triggerPressStart(e, 'virtual');\n let stopPressUp = triggerPressUp(e, 'virtual');\n let stopPressEnd = triggerPressEnd(e, 'virtual');\n shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;\n } else if (state.isPressed && state.pointerType !== 'keyboard') {\n let pointerType = state.pointerType || (e.nativeEvent as PointerEvent).pointerType as PointerType || 'virtual';\n shouldStopPropagation = triggerPressEnd(createEvent(e.currentTarget, e), pointerType, true);\n state.isOverTarget = false;\n cancel(e);\n }\n\n state.ignoreEmulatedMouseEvents = false;\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n }\n }\n };\n\n let onKeyUp = (e: KeyboardEvent) => {\n if (state.isPressed && state.target && isValidKeyboardEvent(e, state.target)) {\n if (shouldPreventDefaultKeyboard(getEventTarget(e), e.key)) {\n e.preventDefault();\n }\n\n let target = getEventTarget(e);\n triggerPressEnd(createEvent(state.target, e), 'keyboard', nodeContains(state.target, getEventTarget(e)));\n removeAllGlobalListeners();\n\n // If a link was triggered with a key other than Enter, open the URL ourselves.\n // This means the link has a role override, and the default browser behavior\n // only applies when using the Enter key.\n if (e.key !== 'Enter' && isHTMLAnchorLink(state.target) && nodeContains(state.target, target) && !e[LINK_CLICKED]) {\n // Store a hidden property on the event so we only trigger link click once,\n // even if there are multiple usePress instances attached to the element.\n e[LINK_CLICKED] = true;\n openLink(state.target, e, false);\n }\n\n state.isPressed = false;\n state.metaKeyEvents?.delete(e.key);\n } else if (e.key === 'Meta' && state.metaKeyEvents?.size) {\n // If we recorded keydown events that occurred while the Meta key was pressed,\n // and those haven't received keyup events already, fire keyup events ourselves.\n // See comment above for more info about the macOS bug causing this.\n let events = state.metaKeyEvents;\n state.metaKeyEvents = undefined;\n for (let event of events.values()) {\n state.target?.dispatchEvent(new KeyboardEvent('keyup', event));\n }\n }\n };\n\n if (typeof PointerEvent !== 'undefined') {\n pressProps.onPointerDown = (e) => {\n // Only handle left clicks, and ignore events that bubbled through portals.\n if (e.button !== 0 || !nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n // iOS safari fires pointer events from VoiceOver with incorrect coordinates/target.\n // Ignore and let the onClick handler take care of it instead.\n // https://bugs.webkit.org/show_bug.cgi?id=222627\n // https://bugs.webkit.org/show_bug.cgi?id=223202\n if (isVirtualPointerEvent(e.nativeEvent)) {\n state.pointerType = 'virtual';\n return;\n }\n\n state.pointerType = e.pointerType;\n\n let shouldStopPropagation = true;\n if (!state.isPressed) {\n state.isPressed = true;\n state.isOverTarget = true;\n state.activePointerId = e.pointerId;\n state.target = e.currentTarget as FocusableElement;\n\n if (!allowTextSelectionOnPress) {\n disableTextSelection(state.target);\n }\n\n shouldStopPropagation = triggerPressStart(e, state.pointerType);\n\n // Release pointer capture so that touch interactions can leave the original target.\n // This enables onPointerLeave and onPointerEnter to fire.\n let target = getEventTarget(e.nativeEvent);\n if ('releasePointerCapture' in target) {\n target.releasePointerCapture(e.pointerId);\n }\n\n addGlobalListener(getOwnerDocument(e.currentTarget), 'pointerup', onPointerUp, false);\n addGlobalListener(getOwnerDocument(e.currentTarget), 'pointercancel', onPointerCancel, false);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n\n pressProps.onMouseDown = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (e.button === 0) {\n if (preventFocusOnPress) {\n let dispose = preventFocus(e.target as FocusableElement);\n if (dispose) {\n state.disposables.push(dispose);\n }\n }\n\n e.stopPropagation();\n }\n };\n\n pressProps.onPointerUp = (e) => {\n // iOS fires pointerup with zero width and height, so check the pointerType recorded during pointerdown.\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent)) || state.pointerType === 'virtual') {\n return;\n }\n\n // Only handle left clicks\n if (e.button === 0) {\n triggerPressUp(e, state.pointerType || e.pointerType);\n }\n };\n\n pressProps.onPointerEnter = (e) => {\n if (e.pointerId === state.activePointerId && state.target && !state.isOverTarget && state.pointerType != null) {\n state.isOverTarget = true;\n triggerPressStart(createEvent(state.target, e), state.pointerType);\n }\n };\n\n pressProps.onPointerLeave = (e) => {\n if (e.pointerId === state.activePointerId && state.target && state.isOverTarget && state.pointerType != null) {\n state.isOverTarget = false;\n triggerPressEnd(createEvent(state.target, e), state.pointerType, false);\n cancelOnPointerExit(e);\n }\n };\n\n let onPointerUp = (e: PointerEvent) => {\n if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0 && state.target) {\n if (nodeContains(state.target, getEventTarget(e)) && state.pointerType != null) {\n // Wait for onClick to fire onPress. This avoids browser issues when the DOM\n // is mutated between onPointerUp and onClick, and is more compatible with third party libraries.\n // https://github.com/adobe/react-spectrum/issues/1513\n // https://issues.chromium.org/issues/40732224\n // However, iOS and Android do not focus or fire onClick after a long press.\n // We work around this by triggering a click ourselves after a timeout.\n // This timeout is canceled during the click event in case the real one fires first.\n // The timeout must be at least 32ms, because Safari on iOS delays the click event on\n // non-form elements without certain ARIA roles (for hover emulation).\n // https://github.com/WebKit/WebKit/blob/dccfae42bb29bd4bdef052e469f604a9387241c0/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L875-L892\n let clicked = false;\n let timeout = setTimeout(() => {\n if (state.isPressed && state.target instanceof HTMLElement) {\n if (clicked) {\n cancel(e);\n } else {\n focusWithoutScrolling(state.target);\n state.target.click();\n }\n }\n }, 80);\n // Use a capturing listener to track if a click occurred.\n // If stopPropagation is called it may never reach our handler.\n addGlobalListener(e.currentTarget as Document, 'click', () => clicked = true, true);\n state.disposables.push(() => clearTimeout(timeout));\n } else {\n cancel(e);\n }\n\n // Ignore subsequent onPointerLeave event before onClick on touch devices.\n state.isOverTarget = false;\n }\n };\n\n let onPointerCancel = (e: PointerEvent) => {\n cancel(e);\n };\n\n pressProps.onDragStart = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n // Safari does not call onPointerCancel when a drag starts, whereas Chrome and Firefox do.\n cancel(e);\n };\n } else {\n // NOTE: this fallback branch is almost entirely used by unit tests.\n // All browsers now support pointer events, but JSDOM still does not.\n\n pressProps.onMouseDown = (e) => {\n // Only handle left clicks\n if (e.button !== 0 || !nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (state.ignoreEmulatedMouseEvents) {\n e.stopPropagation();\n return;\n }\n\n state.isPressed = true;\n state.isOverTarget = true;\n state.target = e.currentTarget;\n state.pointerType = isVirtualClick(e.nativeEvent) ? 'virtual' : 'mouse';\n\n // Flush sync so that focus moved during react re-renders occurs before we yield back to the browser.\n let shouldStopPropagation = flushSync(() => triggerPressStart(e, state.pointerType!));\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n if (preventFocusOnPress) {\n let dispose = preventFocus(e.target as FocusableElement);\n if (dispose) {\n state.disposables.push(dispose);\n }\n }\n\n addGlobalListener(getOwnerDocument(e.currentTarget), 'mouseup', onMouseUp, false);\n };\n\n pressProps.onMouseEnter = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n let shouldStopPropagation = true;\n if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {\n state.isOverTarget = true;\n shouldStopPropagation = triggerPressStart(e, state.pointerType);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n\n pressProps.onMouseLeave = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n let shouldStopPropagation = true;\n if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {\n state.isOverTarget = false;\n shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);\n cancelOnPointerExit(e);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n\n pressProps.onMouseUp = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (!state.ignoreEmulatedMouseEvents && e.button === 0) {\n triggerPressUp(e, state.pointerType || 'mouse');\n }\n };\n\n let onMouseUp = (e: MouseEvent) => {\n // Only handle left clicks\n if (e.button !== 0) {\n return;\n }\n\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n return;\n }\n\n if (state.target && state.target.contains(e.target as Element) && state.pointerType != null) {\n // Wait for onClick to fire onPress. This avoids browser issues when the DOM\n // is mutated between onMouseUp and onClick, and is more compatible with third party libraries.\n } else {\n cancel(e);\n }\n\n state.isOverTarget = false;\n };\n\n pressProps.onTouchStart = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n let touch = getTouchFromEvent(e.nativeEvent);\n if (!touch) {\n return;\n }\n state.activePointerId = touch.identifier;\n state.ignoreEmulatedMouseEvents = true;\n state.isOverTarget = true;\n state.isPressed = true;\n state.target = e.currentTarget;\n state.pointerType = 'touch';\n\n if (!allowTextSelectionOnPress) {\n disableTextSelection(state.target);\n }\n\n let shouldStopPropagation = triggerPressStart(createTouchEvent(state.target, e), state.pointerType);\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n addGlobalListener(getOwnerWindow(e.currentTarget), 'scroll', onScroll, true);\n };\n\n pressProps.onTouchMove = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (!state.isPressed) {\n e.stopPropagation();\n return;\n }\n\n let touch = getTouchById(e.nativeEvent, state.activePointerId);\n let shouldStopPropagation = true;\n if (touch && isOverTarget(touch, e.currentTarget)) {\n if (!state.isOverTarget && state.pointerType != null) {\n state.isOverTarget = true;\n shouldStopPropagation = triggerPressStart(createTouchEvent(state.target!, e), state.pointerType);\n }\n } else if (state.isOverTarget && state.pointerType != null) {\n state.isOverTarget = false;\n shouldStopPropagation = triggerPressEnd(createTouchEvent(state.target!, e), state.pointerType, false);\n cancelOnPointerExit(createTouchEvent(state.target!, e));\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n\n pressProps.onTouchEnd = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (!state.isPressed) {\n e.stopPropagation();\n return;\n }\n\n let touch = getTouchById(e.nativeEvent, state.activePointerId);\n let shouldStopPropagation = true;\n if (touch && isOverTarget(touch, e.currentTarget) && state.pointerType != null) {\n triggerPressUp(createTouchEvent(state.target!, e), state.pointerType);\n shouldStopPropagation = triggerPressEnd(createTouchEvent(state.target!, e), state.pointerType);\n } else if (state.isOverTarget && state.pointerType != null) {\n shouldStopPropagation = triggerPressEnd(createTouchEvent(state.target!, e), state.pointerType, false);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n state.isPressed = false;\n state.activePointerId = null;\n state.isOverTarget = false;\n state.ignoreEmulatedMouseEvents = true;\n if (state.target && !allowTextSelectionOnPress) {\n restoreTextSelection(state.target);\n }\n removeAllGlobalListeners();\n };\n\n pressProps.onTouchCancel = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n e.stopPropagation();\n if (state.isPressed) {\n cancel(createTouchEvent(state.target!, e));\n }\n };\n\n let onScroll = (e: Event) => {\n if (state.isPressed && nodeContains(getEventTarget(e), state.target)) {\n cancel({\n currentTarget: state.target,\n shiftKey: false,\n ctrlKey: false,\n metaKey: false,\n altKey: false\n });\n }\n };\n\n pressProps.onDragStart = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n cancel(e);\n };\n }\n\n return pressProps;\n }, [\n addGlobalListener,\n isDisabled,\n preventFocusOnPress,\n removeAllGlobalListeners,\n allowTextSelectionOnPress,\n cancel,\n cancelOnPointerExit,\n triggerPressEnd,\n triggerPressStart,\n triggerPressUp\n ]);\n\n // Remove user-select: none in case component unmounts immediately after pressStart\n\n useEffect(() => {\n let state = ref.current;\n return () => {\n if (!allowTextSelectionOnPress) {\n \n restoreTextSelection(state.target ?? undefined);\n }\n for (let dispose of state.disposables) {\n dispose();\n }\n state.disposables = [];\n };\n }, [allowTextSelectionOnPress]);\n\n return {\n isPressed: isPressedProp || isPressed,\n pressProps: mergeProps(domProps, pressProps)\n };\n}\n\nfunction isHTMLAnchorLink(target: Element): target is HTMLAnchorElement {\n return target.tagName === 'A' && target.hasAttribute('href');\n}\n\nfunction isValidKeyboardEvent(event: KeyboardEvent, currentTarget: Element): boolean {\n const {key, code} = event;\n const element = currentTarget as HTMLElement;\n const role = element.getAttribute('role');\n // Accessibility for keyboards. Space and Enter only.\n // \"Spacebar\" is for IE 11\n return (\n (key === 'Enter' || key === ' ' || key === 'Spacebar' || code === 'Space') &&\n !((element instanceof getOwnerWindow(element).HTMLInputElement && !isValidInputKey(element, key)) ||\n element instanceof getOwnerWindow(element).HTMLTextAreaElement ||\n element.isContentEditable) &&\n // Links should only trigger with Enter key\n !((role === 'link' || (!role && isHTMLAnchorLink(element))) && key !== 'Enter')\n );\n}\n\nfunction getTouchFromEvent(event: TouchEvent): Touch | null {\n const {targetTouches} = event;\n if (targetTouches.length > 0) {\n return targetTouches[0];\n }\n return null;\n}\n\nfunction getTouchById(\n event: TouchEvent,\n pointerId: null | number\n): null | Touch {\n const changedTouches = event.changedTouches;\n for (let i = 0; i < changedTouches.length; i++) {\n const touch = changedTouches[i];\n if (touch.identifier === pointerId) {\n return touch;\n }\n }\n return null;\n}\n\nfunction createTouchEvent(target: FocusableElement, e: RTouchEvent<FocusableElement>): EventBase {\n let clientX = 0;\n let clientY = 0;\n if (e.targetTouches && e.targetTouches.length === 1) {\n clientX = e.targetTouches[0].clientX;\n clientY = e.targetTouches[0].clientY;\n }\n return {\n currentTarget: target,\n shiftKey: e.shiftKey,\n ctrlKey: e.ctrlKey,\n metaKey: e.metaKey,\n altKey: e.altKey,\n clientX,\n clientY\n };\n}\n\nfunction createEvent(target: FocusableElement, e: EventBase): EventBase {\n let clientX = e.clientX;\n let clientY = e.clientY;\n return {\n currentTarget: target,\n shiftKey: e.shiftKey,\n ctrlKey: e.ctrlKey,\n metaKey: e.metaKey,\n altKey: e.altKey,\n clientX,\n clientY\n };\n}\n\ninterface Rect {\n top: number,\n right: number,\n bottom: number,\n left: number\n}\n\ninterface EventPoint {\n clientX: number,\n clientY: number,\n width?: number,\n height?: number,\n radiusX?: number,\n radiusY?: number\n}\n\nfunction getPointClientRect(point: EventPoint): Rect {\n let offsetX = 0;\n let offsetY = 0;\n if (point.width !== undefined) {\n offsetX = (point.width / 2);\n } else if (point.radiusX !== undefined) {\n offsetX = point.radiusX;\n }\n if (point.height !== undefined) {\n offsetY = (point.height / 2);\n } else if (point.radiusY !== undefined) {\n offsetY = point.radiusY;\n }\n\n return {\n top: point.clientY - offsetY,\n right: point.clientX + offsetX,\n bottom: point.clientY + offsetY,\n left: point.clientX - offsetX\n };\n}\n\nfunction areRectanglesOverlapping(a: Rect, b: Rect) {\n // check if they cannot overlap on x axis\n if (a.left > b.right || b.left > a.right) {\n return false;\n }\n // check if they cannot overlap on y axis\n if (a.top > b.bottom || b.top > a.bottom) {\n return false;\n }\n return true;\n}\n\nfunction isOverTarget(point: EventPoint, target: Element) {\n let rect = target.getBoundingClientRect();\n let pointRect = getPointClientRect(point);\n return areRectanglesOverlapping(rect, pointRect);\n}\n\nfunction shouldPreventDefaultUp(target: Element) {\n if (target instanceof HTMLInputElement) {\n return false;\n }\n\n if (target instanceof HTMLButtonElement) {\n return target.type !== 'submit' && target.type !== 'reset';\n }\n\n if (isHTMLAnchorLink(target)) {\n return false;\n }\n\n return true;\n}\n\nfunction shouldPreventDefaultKeyboard(target: Element, key: string) {\n if (target instanceof HTMLInputElement) {\n return !isValidInputKey(target, key);\n }\n\n return shouldPreventDefaultUp(target);\n}\n\nconst nonTextInputTypes = new Set([\n 'checkbox',\n 'radio',\n 'range',\n 'color',\n 'file',\n 'image',\n 'button',\n 'submit',\n 'reset'\n]);\n\nfunction isValidInputKey(target: HTMLInputElement, key: string) {\n // Only space should toggle checkboxes and radios, not enter.\n return target.type === 'checkbox' || target.type === 'radio'\n ? key === ' '\n : nonTextInputTypes.has(target.type);\n}\n"],"names":[],"version":3,"file":"usePress.module.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;;;;;;;;AAgFlH,SAAS,+CAAyB,KAAqB;IACrD,8DAA8D;IAC9D,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAoB;IAC7C,IAAI,SAAS;QACX,IAAI,YAAC,QAAQ,EAAE,GAAG,cAAa,GAAG;QAClC,QAAQ,CAAA,GAAA,iBAAS,EAAE,cAAc;QACjC;IACF;IACA,CAAA,GAAA,iBAAS,EAAE,SAAS,MAAM,GAAG;IAE7B,OAAO;AACT;IAYE;AAVF,MAAM;IAyCJ,sBAAsB;6BACf,8CAAyB;IAChC;IAEA,IAAI,wBAAwB;QAC1B,qBAAO,IAAI,EAAC;IACd;IAnCA,YAAY,IAAyB,EAAE,WAAwB,EAAE,aAAwB,EAAE,KAAkB,CAAE;QAF/G,qBAAA;;mBAAA,KAAA;;6BAAA,8CAAyB;YAGH;QAApB,IAAI,gBAAgB,CAAA,gBAAA,kBAAA,4BAAA,MAAO,MAAM,cAAb,2BAAA,gBAAiB,cAAc,aAAa;QAChE,MAAM,OAA6B,0BAAA,oCAAD,AAAC,cAA2B,qBAAqB;QACnF,IAAI,GAAG,IAAI;QACX,IAAI,SAAS,UAAyB;QACtC,IAAI,cAAc,OAAO,IAAI,QAAQ,cAAc,OAAO,IAAI,MAAM;YAClE,UAAU,cAAc,OAAO;YAC/B,UAAU,cAAc,OAAO;QACjC;QACA,IAAI;YACF,IAAI,WAAW,QAAQ,WAAW,MAAM;gBACtC,IAAI,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AAiB,SACnB,OAAO;IAGT,OAAO;AACT;AAEA,SAAS,mDAA6B,MAAe,EAAE,GAAW;IAChE,IAAI,kBAAkB,kBACpB,OAAO,CAAC,sCAAgB,QAAQ;IAGlC,OAAO,6CAAuB;AAChC;AAEA,MAAM,0CAAoB,IAAI,IAAI;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,SAAS,sCAAgB,MAAwB,EAAE,GAAW;IAC5D,6DAA6D;IAC7D,OAAO,OAAO,IAAI,KAAK,cAAc,OAAO,IAAI,KAAK,UACjD,QAAQ,MACR,wCAAkB,GAAG,CAAC,OAAO,IAAI;AACvC","sources":["packages/@react-aria/interactions/src/usePress.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 {\n chain,\n focusWithoutScrolling,\n getEventTarget,\n getOwnerDocument,\n getOwnerWindow,\n isMac,\n isVirtualClick,\n isVirtualPointerEvent,\n mergeProps,\n nodeContains,\n openLink,\n useEffectEvent,\n useGlobalListeners,\n useSyncRef\n} from '@react-aria/utils';\nimport {createSyntheticEvent, preventFocus, setEventTarget} from './utils';\nimport {disableTextSelection, restoreTextSelection} from './textSelection';\nimport {DOMAttributes, FocusableElement, PressEvent as IPressEvent, PointerType, PressEvents, RefObject} from '@react-types/shared';\nimport {flushSync} from 'react-dom';\nimport {PressResponderContext} from './context';\nimport {MouseEvent as RMouseEvent, TouchEvent as RTouchEvent, useContext, useEffect, useMemo, useRef, useState} from 'react';\n\nexport interface PressProps extends PressEvents {\n /** Whether the target is in a controlled press state (e.g. an overlay it triggers is open). */\n isPressed?: boolean,\n /** Whether the press events should be disabled. */\n isDisabled?: boolean,\n /** Whether the target should not receive focus on press. */\n preventFocusOnPress?: boolean,\n /**\n * Whether press events should be canceled when the pointer leaves the target while pressed.\n * By default, this is `false`, which means if the pointer returns back over the target while\n * still pressed, onPressStart will be fired again. If set to `true`, the press is canceled\n * when the pointer leaves the target and onPressStart will not be fired if the pointer returns.\n */\n shouldCancelOnPointerExit?: boolean,\n /** Whether text selection should be enabled on the pressable element. */\n allowTextSelectionOnPress?: boolean\n}\n\nexport interface PressHookProps extends PressProps {\n /** A ref to the target element. */\n ref?: RefObject<Element | null>\n}\n\ninterface PressState {\n isPressed: boolean,\n ignoreEmulatedMouseEvents: boolean,\n didFirePressStart: boolean,\n isTriggeringEvent: boolean,\n activePointerId: any,\n target: FocusableElement | null,\n isOverTarget: boolean,\n pointerType: PointerType | null,\n userSelect?: string,\n metaKeyEvents?: Map<string, KeyboardEvent>,\n disposables: Array<() => void>\n}\n\ninterface EventBase {\n currentTarget: EventTarget | null,\n shiftKey: boolean,\n ctrlKey: boolean,\n metaKey: boolean,\n altKey: boolean,\n clientX?: number,\n clientY?: number,\n targetTouches?: Array<{clientX?: number, clientY?: number}>\n}\n\nexport interface PressResult {\n /** Whether the target is currently pressed. */\n isPressed: boolean,\n /** Props to spread on the target element. */\n pressProps: DOMAttributes\n}\n\nfunction usePressResponderContext(props: PressHookProps): PressHookProps {\n // Consume context from <PressResponder> and merge with props.\n let context = useContext(PressResponderContext);\n if (context) {\n let {register, ...contextProps} = context;\n props = mergeProps(contextProps, props) as PressHookProps;\n register();\n }\n useSyncRef(context, props.ref);\n\n return props;\n}\n\nclass PressEvent implements IPressEvent {\n type: IPressEvent['type'];\n pointerType: PointerType;\n target: Element;\n shiftKey: boolean;\n ctrlKey: boolean;\n metaKey: boolean;\n altKey: boolean;\n x: number;\n y: number;\n #shouldStopPropagation = true;\n\n constructor(type: IPressEvent['type'], pointerType: PointerType, originalEvent: EventBase, state?: PressState) {\n let currentTarget = state?.target ?? originalEvent.currentTarget;\n const rect: DOMRect | undefined = (currentTarget as Element)?.getBoundingClientRect();\n let x, y = 0;\n let clientX, clientY: number | null = null;\n if (originalEvent.clientX != null && originalEvent.clientY != null) {\n clientX = originalEvent.clientX;\n clientY = originalEvent.clientY;\n }\n if (rect) {\n if (clientX != null && clientY != null) {\n x = clientX - rect.left;\n y = clientY - rect.top;\n } else {\n x = rect.width / 2;\n y = rect.height / 2;\n }\n }\n this.type = type;\n this.pointerType = pointerType;\n this.target = originalEvent.currentTarget as Element;\n this.shiftKey = originalEvent.shiftKey;\n this.metaKey = originalEvent.metaKey;\n this.ctrlKey = originalEvent.ctrlKey;\n this.altKey = originalEvent.altKey;\n this.x = x;\n this.y = y;\n }\n\n continuePropagation() {\n this.#shouldStopPropagation = false;\n }\n\n get shouldStopPropagation() {\n return this.#shouldStopPropagation;\n }\n}\n\nconst LINK_CLICKED = Symbol('linkClicked');\n\n/**\n * Handles press interactions across mouse, touch, keyboard, and screen readers.\n * It normalizes behavior across browsers and platforms, and handles many nuances\n * of dealing with pointer and keyboard events.\n */\nexport function usePress(props: PressHookProps): PressResult {\n let {\n onPress,\n onPressChange,\n onPressStart,\n onPressEnd,\n onPressUp,\n onClick,\n isDisabled,\n isPressed: isPressedProp,\n preventFocusOnPress,\n shouldCancelOnPointerExit,\n allowTextSelectionOnPress,\n ref: domRef,\n ...domProps\n } = usePressResponderContext(props);\n\n let [isPressed, setPressed] = useState(false);\n let ref = useRef<PressState>({\n isPressed: false,\n ignoreEmulatedMouseEvents: false,\n didFirePressStart: false,\n isTriggeringEvent: false,\n activePointerId: null,\n target: null,\n isOverTarget: false,\n pointerType: null,\n disposables: []\n });\n\n let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();\n\n let triggerPressStart = useEffectEvent((originalEvent: EventBase, pointerType: PointerType) => {\n let state = ref.current;\n if (isDisabled || state.didFirePressStart) {\n return false;\n }\n\n let shouldStopPropagation = true;\n state.isTriggeringEvent = true;\n if (onPressStart) {\n let event = new PressEvent('pressstart', pointerType, originalEvent);\n onPressStart(event);\n shouldStopPropagation = event.shouldStopPropagation;\n }\n\n if (onPressChange) {\n onPressChange(true);\n }\n\n state.isTriggeringEvent = false;\n state.didFirePressStart = true;\n setPressed(true);\n return shouldStopPropagation;\n });\n\n let triggerPressEnd = useEffectEvent((originalEvent: EventBase, pointerType: PointerType, wasPressed = true) => {\n let state = ref.current;\n if (!state.didFirePressStart) {\n return false;\n }\n\n state.didFirePressStart = false;\n state.isTriggeringEvent = true;\n\n let shouldStopPropagation = true;\n if (onPressEnd) {\n let event = new PressEvent('pressend', pointerType, originalEvent);\n onPressEnd(event);\n shouldStopPropagation = event.shouldStopPropagation;\n }\n\n if (onPressChange) {\n onPressChange(false);\n }\n\n setPressed(false);\n\n if (onPress && wasPressed && !isDisabled) {\n let event = new PressEvent('press', pointerType, originalEvent);\n onPress(event);\n shouldStopPropagation &&= event.shouldStopPropagation;\n }\n\n state.isTriggeringEvent = false;\n return shouldStopPropagation;\n });\n\n let triggerPressUp = useEffectEvent((originalEvent: EventBase, pointerType: PointerType) => {\n let state = ref.current;\n if (isDisabled) {\n return false;\n }\n\n if (onPressUp) {\n state.isTriggeringEvent = true;\n let event = new PressEvent('pressup', pointerType, originalEvent);\n onPressUp(event);\n state.isTriggeringEvent = false;\n return event.shouldStopPropagation;\n }\n\n return true;\n });\n\n let cancel = useEffectEvent((e: EventBase) => {\n let state = ref.current;\n if (state.isPressed && state.target) {\n if (state.didFirePressStart && state.pointerType != null) {\n triggerPressEnd(createEvent(state.target, e), state.pointerType, false);\n }\n state.isPressed = false;\n state.isOverTarget = false;\n state.activePointerId = null;\n state.pointerType = null;\n removeAllGlobalListeners();\n if (!allowTextSelectionOnPress) {\n restoreTextSelection(state.target);\n }\n for (let dispose of state.disposables) {\n dispose();\n }\n state.disposables = [];\n }\n });\n\n let cancelOnPointerExit = useEffectEvent((e: EventBase) => {\n if (shouldCancelOnPointerExit) {\n cancel(e);\n }\n });\n\n let triggerClick = useEffectEvent((e: RMouseEvent<FocusableElement>) => {\n onClick?.(e);\n });\n\n let triggerSyntheticClick = useEffectEvent((e: KeyboardEvent | TouchEvent, target: FocusableElement) => {\n // Some third-party libraries pass in onClick instead of onPress.\n // Create a fake mouse event and trigger onClick as well.\n // This matches the browser's native activation behavior for certain elements (e.g. button).\n // https://html.spec.whatwg.org/#activation\n // https://html.spec.whatwg.org/#fire-a-synthetic-pointer-event\n if (onClick) {\n let event = new MouseEvent('click', e);\n setEventTarget(event, target);\n onClick(createSyntheticEvent(event));\n }\n });\n\n let pressProps = useMemo(() => {\n let state = ref.current;\n let pressProps: DOMAttributes = {\n onKeyDown(e) {\n if (isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n if (shouldPreventDefaultKeyboard(getEventTarget(e.nativeEvent), e.key)) {\n e.preventDefault();\n }\n\n // If the event is repeating, it may have started on a different element\n // after which focus moved to the current element. Ignore these events and\n // only handle the first key down event.\n let shouldStopPropagation = true;\n if (!state.isPressed && !e.repeat) {\n state.target = e.currentTarget;\n state.isPressed = true;\n state.pointerType = 'keyboard';\n shouldStopPropagation = triggerPressStart(e, 'keyboard');\n\n // Focus may move before the key up event, so register the event on the document\n // instead of the same element where the key down event occurred. Make it capturing so that it will trigger\n // before stopPropagation from useKeyboard on a child element may happen and thus we can still call triggerPress for the parent element.\n let originalTarget = e.currentTarget;\n let pressUp = (e) => {\n if (isValidKeyboardEvent(e, originalTarget) && !e.repeat && nodeContains(originalTarget, getEventTarget(e)) && state.target) {\n triggerPressUp(createEvent(state.target, e), 'keyboard');\n }\n };\n\n addGlobalListener(getOwnerDocument(e.currentTarget), 'keyup', chain(pressUp, onKeyUp), true);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n // Keep track of the keydown events that occur while the Meta (e.g. Command) key is held.\n // macOS has a bug where keyup events are not fired while the Meta key is down.\n // When the Meta key itself is released we will get an event for that, and we'll act as if\n // all of these other keys were released as well.\n // https://bugs.chromium.org/p/chromium/issues/detail?id=1393524\n // https://bugs.webkit.org/show_bug.cgi?id=55291\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1299553\n if (e.metaKey && isMac()) {\n state.metaKeyEvents?.set(e.key, e.nativeEvent);\n }\n } else if (e.key === 'Meta') {\n state.metaKeyEvents = new Map();\n }\n },\n onClick(e) {\n if (e && !nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (e && e.button === 0 && !state.isTriggeringEvent && !(openLink as any).isOpening) {\n let shouldStopPropagation = true;\n if (isDisabled) {\n e.preventDefault();\n }\n \n // If triggered from a screen reader or by using element.click(),\n // trigger as if it were a keyboard click.\n if (!state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType === 'virtual' || isVirtualClick(e.nativeEvent))) {\n let stopPressStart = triggerPressStart(e, 'virtual');\n let stopPressUp = triggerPressUp(e, 'virtual');\n let stopPressEnd = triggerPressEnd(e, 'virtual');\n triggerClick(e);\n shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;\n } else if (state.isPressed && state.pointerType !== 'keyboard') {\n let pointerType = state.pointerType || (e.nativeEvent as PointerEvent).pointerType as PointerType || 'virtual';\n shouldStopPropagation = triggerPressEnd(createEvent(e.currentTarget, e), pointerType, true);\n state.isOverTarget = false;\n triggerClick(e);\n cancel(e);\n }\n\n state.ignoreEmulatedMouseEvents = false;\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n }\n }\n };\n\n let onKeyUp = (e: KeyboardEvent) => {\n if (state.isPressed && state.target && isValidKeyboardEvent(e, state.target)) {\n if (shouldPreventDefaultKeyboard(getEventTarget(e), e.key)) {\n e.preventDefault();\n }\n\n let target = getEventTarget(e);\n let wasPressed = nodeContains(state.target, getEventTarget(e));\n triggerPressEnd(createEvent(state.target, e), 'keyboard', wasPressed);\n if (wasPressed) {\n triggerSyntheticClick(e, state.target);\n }\n removeAllGlobalListeners();\n\n // If a link was triggered with a key other than Enter, open the URL ourselves.\n // This means the link has a role override, and the default browser behavior\n // only applies when using the Enter key.\n if (e.key !== 'Enter' && isHTMLAnchorLink(state.target) && nodeContains(state.target, target) && !e[LINK_CLICKED]) {\n // Store a hidden property on the event so we only trigger link click once,\n // even if there are multiple usePress instances attached to the element.\n e[LINK_CLICKED] = true;\n openLink(state.target, e, false);\n }\n\n state.isPressed = false;\n state.metaKeyEvents?.delete(e.key);\n } else if (e.key === 'Meta' && state.metaKeyEvents?.size) {\n // If we recorded keydown events that occurred while the Meta key was pressed,\n // and those haven't received keyup events already, fire keyup events ourselves.\n // See comment above for more info about the macOS bug causing this.\n let events = state.metaKeyEvents;\n state.metaKeyEvents = undefined;\n for (let event of events.values()) {\n state.target?.dispatchEvent(new KeyboardEvent('keyup', event));\n }\n }\n };\n\n if (typeof PointerEvent !== 'undefined') {\n pressProps.onPointerDown = (e) => {\n // Only handle left clicks, and ignore events that bubbled through portals.\n if (e.button !== 0 || !nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n // iOS safari fires pointer events from VoiceOver with incorrect coordinates/target.\n // Ignore and let the onClick handler take care of it instead.\n // https://bugs.webkit.org/show_bug.cgi?id=222627\n // https://bugs.webkit.org/show_bug.cgi?id=223202\n if (isVirtualPointerEvent(e.nativeEvent)) {\n state.pointerType = 'virtual';\n return;\n }\n\n state.pointerType = e.pointerType;\n\n let shouldStopPropagation = true;\n if (!state.isPressed) {\n state.isPressed = true;\n state.isOverTarget = true;\n state.activePointerId = e.pointerId;\n state.target = e.currentTarget as FocusableElement;\n\n if (!allowTextSelectionOnPress) {\n disableTextSelection(state.target);\n }\n\n shouldStopPropagation = triggerPressStart(e, state.pointerType);\n\n // Release pointer capture so that touch interactions can leave the original target.\n // This enables onPointerLeave and onPointerEnter to fire.\n let target = getEventTarget(e.nativeEvent);\n if ('releasePointerCapture' in target) {\n target.releasePointerCapture(e.pointerId);\n }\n\n addGlobalListener(getOwnerDocument(e.currentTarget), 'pointerup', onPointerUp, false);\n addGlobalListener(getOwnerDocument(e.currentTarget), 'pointercancel', onPointerCancel, false);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n\n pressProps.onMouseDown = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (e.button === 0) {\n if (preventFocusOnPress) {\n let dispose = preventFocus(e.target as FocusableElement);\n if (dispose) {\n state.disposables.push(dispose);\n }\n }\n\n e.stopPropagation();\n }\n };\n\n pressProps.onPointerUp = (e) => {\n // iOS fires pointerup with zero width and height, so check the pointerType recorded during pointerdown.\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent)) || state.pointerType === 'virtual') {\n return;\n }\n\n // Only handle left clicks\n if (e.button === 0) {\n triggerPressUp(e, state.pointerType || e.pointerType);\n }\n };\n\n pressProps.onPointerEnter = (e) => {\n if (e.pointerId === state.activePointerId && state.target && !state.isOverTarget && state.pointerType != null) {\n state.isOverTarget = true;\n triggerPressStart(createEvent(state.target, e), state.pointerType);\n }\n };\n\n pressProps.onPointerLeave = (e) => {\n if (e.pointerId === state.activePointerId && state.target && state.isOverTarget && state.pointerType != null) {\n state.isOverTarget = false;\n triggerPressEnd(createEvent(state.target, e), state.pointerType, false);\n cancelOnPointerExit(e);\n }\n };\n\n let onPointerUp = (e: PointerEvent) => {\n if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0 && state.target) {\n if (nodeContains(state.target, getEventTarget(e)) && state.pointerType != null) {\n // Wait for onClick to fire onPress. This avoids browser issues when the DOM\n // is mutated between onPointerUp and onClick, and is more compatible with third party libraries.\n // https://github.com/adobe/react-spectrum/issues/1513\n // https://issues.chromium.org/issues/40732224\n // However, iOS and Android do not focus or fire onClick after a long press.\n // We work around this by triggering a click ourselves after a timeout.\n // This timeout is canceled during the click event in case the real one fires first.\n // The timeout must be at least 32ms, because Safari on iOS delays the click event on\n // non-form elements without certain ARIA roles (for hover emulation).\n // https://github.com/WebKit/WebKit/blob/dccfae42bb29bd4bdef052e469f604a9387241c0/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L875-L892\n let clicked = false;\n let timeout = setTimeout(() => {\n if (state.isPressed && state.target instanceof HTMLElement) {\n if (clicked) {\n cancel(e);\n } else {\n focusWithoutScrolling(state.target);\n state.target.click();\n }\n }\n }, 80);\n // Use a capturing listener to track if a click occurred.\n // If stopPropagation is called it may never reach our handler.\n addGlobalListener(e.currentTarget as Document, 'click', () => clicked = true, true);\n state.disposables.push(() => clearTimeout(timeout));\n } else {\n cancel(e);\n }\n\n // Ignore subsequent onPointerLeave event before onClick on touch devices.\n state.isOverTarget = false;\n }\n };\n\n let onPointerCancel = (e: PointerEvent) => {\n cancel(e);\n };\n\n pressProps.onDragStart = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n // Safari does not call onPointerCancel when a drag starts, whereas Chrome and Firefox do.\n cancel(e);\n };\n } else if (process.env.NODE_ENV === 'test') {\n // NOTE: this fallback branch is entirely used by unit tests.\n // All browsers now support pointer events, but JSDOM still does not.\n\n pressProps.onMouseDown = (e) => {\n // Only handle left clicks\n if (e.button !== 0 || !nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (state.ignoreEmulatedMouseEvents) {\n e.stopPropagation();\n return;\n }\n\n state.isPressed = true;\n state.isOverTarget = true;\n state.target = e.currentTarget;\n state.pointerType = isVirtualClick(e.nativeEvent) ? 'virtual' : 'mouse';\n\n // Flush sync so that focus moved during react re-renders occurs before we yield back to the browser.\n let shouldStopPropagation = flushSync(() => triggerPressStart(e, state.pointerType!));\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n if (preventFocusOnPress) {\n let dispose = preventFocus(e.target as FocusableElement);\n if (dispose) {\n state.disposables.push(dispose);\n }\n }\n\n addGlobalListener(getOwnerDocument(e.currentTarget), 'mouseup', onMouseUp, false);\n };\n\n pressProps.onMouseEnter = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n let shouldStopPropagation = true;\n if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {\n state.isOverTarget = true;\n shouldStopPropagation = triggerPressStart(e, state.pointerType);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n\n pressProps.onMouseLeave = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n let shouldStopPropagation = true;\n if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {\n state.isOverTarget = false;\n shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);\n cancelOnPointerExit(e);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n\n pressProps.onMouseUp = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (!state.ignoreEmulatedMouseEvents && e.button === 0) {\n triggerPressUp(e, state.pointerType || 'mouse');\n }\n };\n\n let onMouseUp = (e: MouseEvent) => {\n // Only handle left clicks\n if (e.button !== 0) {\n return;\n }\n\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n return;\n }\n\n if (state.target && state.target.contains(e.target as Element) && state.pointerType != null) {\n // Wait for onClick to fire onPress. This avoids browser issues when the DOM\n // is mutated between onMouseUp and onClick, and is more compatible with third party libraries.\n } else {\n cancel(e);\n }\n\n state.isOverTarget = false;\n };\n\n pressProps.onTouchStart = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n let touch = getTouchFromEvent(e.nativeEvent);\n if (!touch) {\n return;\n }\n state.activePointerId = touch.identifier;\n state.ignoreEmulatedMouseEvents = true;\n state.isOverTarget = true;\n state.isPressed = true;\n state.target = e.currentTarget;\n state.pointerType = 'touch';\n\n if (!allowTextSelectionOnPress) {\n disableTextSelection(state.target);\n }\n\n let shouldStopPropagation = triggerPressStart(createTouchEvent(state.target, e), state.pointerType);\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n addGlobalListener(getOwnerWindow(e.currentTarget), 'scroll', onScroll, true);\n };\n\n pressProps.onTouchMove = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (!state.isPressed) {\n e.stopPropagation();\n return;\n }\n\n let touch = getTouchById(e.nativeEvent, state.activePointerId);\n let shouldStopPropagation = true;\n if (touch && isOverTarget(touch, e.currentTarget)) {\n if (!state.isOverTarget && state.pointerType != null) {\n state.isOverTarget = true;\n shouldStopPropagation = triggerPressStart(createTouchEvent(state.target!, e), state.pointerType);\n }\n } else if (state.isOverTarget && state.pointerType != null) {\n state.isOverTarget = false;\n shouldStopPropagation = triggerPressEnd(createTouchEvent(state.target!, e), state.pointerType, false);\n cancelOnPointerExit(createTouchEvent(state.target!, e));\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n\n pressProps.onTouchEnd = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n if (!state.isPressed) {\n e.stopPropagation();\n return;\n }\n\n let touch = getTouchById(e.nativeEvent, state.activePointerId);\n let shouldStopPropagation = true;\n if (touch && isOverTarget(touch, e.currentTarget) && state.pointerType != null) {\n triggerPressUp(createTouchEvent(state.target!, e), state.pointerType);\n shouldStopPropagation = triggerPressEnd(createTouchEvent(state.target!, e), state.pointerType);\n triggerSyntheticClick(e.nativeEvent, state.target!);\n } else if (state.isOverTarget && state.pointerType != null) {\n shouldStopPropagation = triggerPressEnd(createTouchEvent(state.target!, e), state.pointerType, false);\n }\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n\n state.isPressed = false;\n state.activePointerId = null;\n state.isOverTarget = false;\n state.ignoreEmulatedMouseEvents = true;\n if (state.target && !allowTextSelectionOnPress) {\n restoreTextSelection(state.target);\n }\n removeAllGlobalListeners();\n };\n\n pressProps.onTouchCancel = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n e.stopPropagation();\n if (state.isPressed) {\n cancel(createTouchEvent(state.target!, e));\n }\n };\n\n let onScroll = (e: Event) => {\n if (state.isPressed && nodeContains(getEventTarget(e), state.target)) {\n cancel({\n currentTarget: state.target,\n shiftKey: false,\n ctrlKey: false,\n metaKey: false,\n altKey: false\n });\n }\n };\n\n pressProps.onDragStart = (e) => {\n if (!nodeContains(e.currentTarget, getEventTarget(e.nativeEvent))) {\n return;\n }\n\n cancel(e);\n };\n }\n\n return pressProps;\n }, [\n addGlobalListener,\n isDisabled,\n preventFocusOnPress,\n removeAllGlobalListeners,\n allowTextSelectionOnPress,\n cancel,\n cancelOnPointerExit,\n triggerPressEnd,\n triggerPressStart,\n triggerPressUp,\n triggerClick,\n triggerSyntheticClick\n ]);\n\n // Avoid onClick delay for double tap to zoom by default.\n useEffect(() => {\n let element = domRef?.current;\n if (element && (element instanceof getOwnerWindow(element).Element)) {\n // Only apply touch-action if not already set by another CSS rule.\n let style = getOwnerWindow(element).getComputedStyle(element);\n if (style.touchAction === 'auto') {\n // touchAction: 'manipulation' is supposed to be equivalent, but in \n // Safari it causes onPointerCancel not to fire on scroll.\n // https://bugs.webkit.org/show_bug.cgi?id=240917\n (element as HTMLElement).style.touchAction = 'pan-x pan-y pinch-zoom';\n }\n }\n }, [domRef]);\n\n // Remove user-select: none in case component unmounts immediately after pressStart\n useEffect(() => {\n let state = ref.current;\n return () => {\n if (!allowTextSelectionOnPress) {\n restoreTextSelection(state.target ?? undefined);\n }\n for (let dispose of state.disposables) {\n dispose();\n }\n state.disposables = [];\n };\n }, [allowTextSelectionOnPress]);\n\n return {\n isPressed: isPressedProp || isPressed,\n pressProps: mergeProps(domProps, pressProps)\n };\n}\n\nfunction isHTMLAnchorLink(target: Element): target is HTMLAnchorElement {\n return target.tagName === 'A' && target.hasAttribute('href');\n}\n\nfunction isValidKeyboardEvent(event: KeyboardEvent, currentTarget: Element): boolean {\n const {key, code} = event;\n const element = currentTarget as HTMLElement;\n const role = element.getAttribute('role');\n // Accessibility for keyboards. Space and Enter only.\n // \"Spacebar\" is for IE 11\n return (\n (key === 'Enter' || key === ' ' || key === 'Spacebar' || code === 'Space') &&\n !((element instanceof getOwnerWindow(element).HTMLInputElement && !isValidInputKey(element, key)) ||\n element instanceof getOwnerWindow(element).HTMLTextAreaElement ||\n element.isContentEditable) &&\n // Links should only trigger with Enter key\n !((role === 'link' || (!role && isHTMLAnchorLink(element))) && key !== 'Enter')\n );\n}\n\nfunction getTouchFromEvent(event: TouchEvent): Touch | null {\n const {targetTouches} = event;\n if (targetTouches.length > 0) {\n return targetTouches[0];\n }\n return null;\n}\n\nfunction getTouchById(\n event: TouchEvent,\n pointerId: null | number\n): null | Touch {\n const changedTouches = event.changedTouches;\n for (let i = 0; i < changedTouches.length; i++) {\n const touch = changedTouches[i];\n if (touch.identifier === pointerId) {\n return touch;\n }\n }\n return null;\n}\n\nfunction createTouchEvent(target: FocusableElement, e: RTouchEvent<FocusableElement>): EventBase {\n let clientX = 0;\n let clientY = 0;\n if (e.targetTouches && e.targetTouches.length === 1) {\n clientX = e.targetTouches[0].clientX;\n clientY = e.targetTouches[0].clientY;\n }\n return {\n currentTarget: target,\n shiftKey: e.shiftKey,\n ctrlKey: e.ctrlKey,\n metaKey: e.metaKey,\n altKey: e.altKey,\n clientX,\n clientY\n };\n}\n\nfunction createEvent(target: FocusableElement, e: EventBase): EventBase {\n let clientX = e.clientX;\n let clientY = e.clientY;\n return {\n currentTarget: target,\n shiftKey: e.shiftKey,\n ctrlKey: e.ctrlKey,\n metaKey: e.metaKey,\n altKey: e.altKey,\n clientX,\n clientY\n };\n}\n\ninterface Rect {\n top: number,\n right: number,\n bottom: number,\n left: number\n}\n\ninterface EventPoint {\n clientX: number,\n clientY: number,\n width?: number,\n height?: number,\n radiusX?: number,\n radiusY?: number\n}\n\nfunction getPointClientRect(point: EventPoint): Rect {\n let offsetX = 0;\n let offsetY = 0;\n if (point.width !== undefined) {\n offsetX = (point.width / 2);\n } else if (point.radiusX !== undefined) {\n offsetX = point.radiusX;\n }\n if (point.height !== undefined) {\n offsetY = (point.height / 2);\n } else if (point.radiusY !== undefined) {\n offsetY = point.radiusY;\n }\n\n return {\n top: point.clientY - offsetY,\n right: point.clientX + offsetX,\n bottom: point.clientY + offsetY,\n left: point.clientX - offsetX\n };\n}\n\nfunction areRectanglesOverlapping(a: Rect, b: Rect) {\n // check if they cannot overlap on x axis\n if (a.left > b.right || b.left > a.right) {\n return false;\n }\n // check if they cannot overlap on y axis\n if (a.top > b.bottom || b.top > a.bottom) {\n return false;\n }\n return true;\n}\n\nfunction isOverTarget(point: EventPoint, target: Element) {\n let rect = target.getBoundingClientRect();\n let pointRect = getPointClientRect(point);\n return areRectanglesOverlapping(rect, pointRect);\n}\n\nfunction shouldPreventDefaultUp(target: Element) {\n if (target instanceof HTMLInputElement) {\n return false;\n }\n\n if (target instanceof HTMLButtonElement) {\n return target.type !== 'submit' && target.type !== 'reset';\n }\n\n if (isHTMLAnchorLink(target)) {\n return false;\n }\n\n return true;\n}\n\nfunction shouldPreventDefaultKeyboard(target: Element, key: string) {\n if (target instanceof HTMLInputElement) {\n return !isValidInputKey(target, key);\n }\n\n return shouldPreventDefaultUp(target);\n}\n\nconst nonTextInputTypes = new Set([\n 'checkbox',\n 'radio',\n 'range',\n 'color',\n 'file',\n 'image',\n 'button',\n 'submit',\n 'reset'\n]);\n\nfunction isValidInputKey(target: HTMLInputElement, key: string) {\n // Only space should toggle checkboxes and radios, not enter.\n return target.type === 'checkbox' || target.type === 'radio'\n ? key === ' '\n : nonTextInputTypes.has(target.type);\n}\n"],"names":[],"version":3,"file":"usePress.module.js.map"}
@@ -6,7 +6,8 @@ function $parcel$export(e, n, v, s) {
6
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
7
  }
8
8
 
9
- $parcel$export(module.exports, "SyntheticFocusEvent", () => $625cf83917e112ad$export$905e7fc544a71f36);
9
+ $parcel$export(module.exports, "createSyntheticEvent", () => $625cf83917e112ad$export$525bc4921d56d4a);
10
+ $parcel$export(module.exports, "setEventTarget", () => $625cf83917e112ad$export$c2b7abe5d61ec696);
10
11
  $parcel$export(module.exports, "useSyntheticBlurEvent", () => $625cf83917e112ad$export$715c682d09d639cc);
11
12
  $parcel$export(module.exports, "ignoreFocusEvent", () => $625cf83917e112ad$export$fda7da73ab5d4c48);
12
13
  $parcel$export(module.exports, "preventFocus", () => $625cf83917e112ad$export$cabe61c495ee3649);
@@ -22,35 +23,22 @@ $parcel$export(module.exports, "preventFocus", () => $625cf83917e112ad$export$ca
22
23
  * governing permissions and limitations under the License.
23
24
  */
24
25
 
25
- class $625cf83917e112ad$export$905e7fc544a71f36 {
26
- isDefaultPrevented() {
27
- return this.nativeEvent.defaultPrevented;
28
- }
29
- preventDefault() {
30
- this.defaultPrevented = true;
31
- this.nativeEvent.preventDefault();
32
- }
33
- stopPropagation() {
34
- this.nativeEvent.stopPropagation();
35
- this.isPropagationStopped = ()=>true;
36
- }
37
- isPropagationStopped() {
38
- return false;
39
- }
40
- persist() {}
41
- constructor(type, nativeEvent){
42
- this.nativeEvent = nativeEvent;
43
- this.target = nativeEvent.target;
44
- this.currentTarget = nativeEvent.currentTarget;
45
- this.relatedTarget = nativeEvent.relatedTarget;
46
- this.bubbles = nativeEvent.bubbles;
47
- this.cancelable = nativeEvent.cancelable;
48
- this.defaultPrevented = nativeEvent.defaultPrevented;
49
- this.eventPhase = nativeEvent.eventPhase;
50
- this.isTrusted = nativeEvent.isTrusted;
51
- this.timeStamp = nativeEvent.timeStamp;
52
- this.type = type;
53
- }
26
+ function $625cf83917e112ad$export$525bc4921d56d4a(nativeEvent) {
27
+ let event = nativeEvent;
28
+ event.nativeEvent = nativeEvent;
29
+ event.isDefaultPrevented = ()=>event.defaultPrevented;
30
+ // cancelBubble is technically deprecated in the spec, but still supported in all browsers.
31
+ event.isPropagationStopped = ()=>event.cancelBubble;
32
+ event.persist = ()=>{};
33
+ return event;
34
+ }
35
+ function $625cf83917e112ad$export$c2b7abe5d61ec696(event, target) {
36
+ Object.defineProperty(event, 'target', {
37
+ value: target
38
+ });
39
+ Object.defineProperty(event, 'currentTarget', {
40
+ value: target
41
+ });
54
42
  }
55
43
  function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
56
44
  let stateRef = (0, $iJhOP$react.useRef)({
@@ -81,8 +69,11 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
81
69
  let target = e.target;
82
70
  let onBlurHandler = (e)=>{
83
71
  stateRef.current.isFocused = false;
84
- if (target.disabled) // For backward compatibility, dispatch a (fake) React synthetic event.
85
- dispatchBlur(new $625cf83917e112ad$export$905e7fc544a71f36('blur', e));
72
+ if (target.disabled) {
73
+ // For backward compatibility, dispatch a (fake) React synthetic event.
74
+ let event = $625cf83917e112ad$export$525bc4921d56d4a(e);
75
+ dispatchBlur(event);
76
+ }
86
77
  // We no longer need the MutationObserver once the target is blurred.
87
78
  if (stateRef.current.observer) {
88
79
  stateRef.current.observer.disconnect();
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,MAAM;IA2BX,qBAA8B;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,gBAAgB;IAC1C;IAEA,iBAAuB;QACrB,IAAI,CAAC,gBAAgB,GAAG;QACxB,IAAI,CAAC,WAAW,CAAC,cAAc;IACjC;IAEA,kBAAwB;QACtB,IAAI,CAAC,WAAW,CAAC,eAAe;QAChC,IAAI,CAAC,oBAAoB,GAAG,IAAM;IACpC;IAEA,uBAAgC;QAC9B,OAAO;IACT;IAEA,UAAU,CAAC;IAhCX,YAAY,IAAY,EAAE,WA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AAI,aAAa,CAAC;QAChB,IAAI,EAAE,MAAM,KAAK,iBAAiB,cAAc;YAC9C,EAAE,wBAAwB;YAE1B,qEAAqE;YACrE,6CAA6C;YAC7C,IAAI,CAAC,UAAU,CAAC,cAAc;gBAC5B,eAAe;gBACf,CAAA,GAAA,2CAAoB,EAAE;gBACtB;YACF;QACF;IACF;IAEA,IAAI,UAAU,CAAC;QACb,IAAI,EAAE,MAAM,KAAK,UAAU,cACzB,EAAE,wBAAwB;IAE9B;IAEA,IAAI,YAAY,CAAC;QACf,IAAI,EAAE,MAAM,KAAK,UAAU,cAAc;YACvC,EAAE,wBAAwB;YAE1B,IAAI,CAAC,cAAc;gBACjB,eAAe;gBACf,CAAA,GAAA,2CAAoB,EAAE;gBACtB;YACF;QACF;IACF;IAEA,OAAO,gBAAgB,CAAC,QAAQ,QAAQ;IACxC,OAAO,gBAAgB,CAAC,YAAY,YAAY;IAChD,OAAO,gBAAgB,CAAC,WAAW,WAAW;IAC9C,OAAO,gBAAgB,CAAC,SAAS,SAAS;IAE1C,IAAI,UAAU;QACZ,qBAAqB;QACrB,OAAO,mBAAmB,CAAC,QAAQ,QAAQ;QAC3C,OAAO,mBAAmB,CAAC,YAAY,YAAY;QACnD,OAAO,mBAAmB,CAAC,WAAW,WAAW;QACjD,OAAO,mBAAmB,CAAC,SAAS,SAAS;QAC7C,4CAAmB;QACnB,eAAe;IACjB;IAEA,IAAI,MAAM,sBAAsB;IAChC,OAAO;AACT","sources":["packages/@react-aria/interactions/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {focusWithoutScrolling, getOwnerWindow, isFocusable, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {FocusEvent as ReactFocusEvent, useCallback, useRef} from 'react';\n\nexport class SyntheticFocusEvent<Target = Element> implements ReactFocusEvent<Target> {\n nativeEvent: FocusEvent;\n target: EventTarget & Target;\n currentTarget: EventTarget & Target;\n relatedTarget: Element;\n bubbles: boolean;\n cancelable: boolean;\n defaultPrevented: boolean;\n eventPhase: number;\n isTrusted: boolean;\n timeStamp: number;\n type: string;\n\n constructor(type: string, nativeEvent: FocusEvent) {\n this.nativeEvent = nativeEvent;\n this.target = nativeEvent.target as EventTarget & Target;\n this.currentTarget = nativeEvent.currentTarget as EventTarget & Target;\n this.relatedTarget = nativeEvent.relatedTarget as Element;\n this.bubbles = nativeEvent.bubbles;\n this.cancelable = nativeEvent.cancelable;\n this.defaultPrevented = nativeEvent.defaultPrevented;\n this.eventPhase = nativeEvent.eventPhase;\n this.isTrusted = nativeEvent.isTrusted;\n this.timeStamp = nativeEvent.timeStamp;\n this.type = type;\n }\n\n isDefaultPrevented(): boolean {\n return this.nativeEvent.defaultPrevented;\n }\n\n preventDefault(): void {\n this.defaultPrevented = true;\n this.nativeEvent.preventDefault();\n }\n\n stopPropagation(): void {\n this.nativeEvent.stopPropagation();\n this.isPropagationStopped = () => true;\n }\n\n isPropagationStopped(): boolean {\n return false;\n }\n\n persist() {}\n}\n\nexport function useSyntheticBlurEvent<Target = Element>(onBlur: (e: ReactFocusEvent<Target>) => void) {\n let stateRef = useRef({\n isFocused: false,\n observer: null as MutationObserver | null\n });\n\n // Clean up MutationObserver on unmount. See below.\n \n useLayoutEffect(() => {\n const state = stateRef.current;\n return () => {\n if (state.observer) {\n state.observer.disconnect();\n state.observer = null;\n }\n };\n }, []);\n\n let dispatchBlur = useEffectEvent((e: SyntheticFocusEvent<Target>) => {\n onBlur?.(e);\n });\n\n // This function is called during a React onFocus event.\n return useCallback((e: ReactFocusEvent<Target>) => {\n // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142\n // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a\n // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.\n // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.\n if (\n e.target instanceof HTMLButtonElement ||\n e.target instanceof HTMLInputElement ||\n e.target instanceof HTMLTextAreaElement ||\n e.target instanceof HTMLSelectElement\n ) {\n stateRef.current.isFocused = true;\n\n let target = e.target;\n let onBlurHandler: EventListenerOrEventListenerObject | null = (e) => {\n stateRef.current.isFocused = false;\n\n if (target.disabled) {\n // For backward compatibility, dispatch a (fake) React synthetic event.\n dispatchBlur(new SyntheticFocusEvent('blur', e as FocusEvent));\n }\n\n // We no longer need the MutationObserver once the target is blurred.\n if (stateRef.current.observer) {\n stateRef.current.observer.disconnect();\n stateRef.current.observer = null;\n }\n };\n\n target.addEventListener('focusout', onBlurHandler, {once: true});\n\n stateRef.current.observer = new MutationObserver(() => {\n if (stateRef.current.isFocused && target.disabled) {\n stateRef.current.observer?.disconnect();\n let relatedTargetEl = target === document.activeElement ? null : document.activeElement;\n target.dispatchEvent(new FocusEvent('blur', {relatedTarget: relatedTargetEl}));\n target.dispatchEvent(new FocusEvent('focusout', {bubbles: true, relatedTarget: relatedTargetEl}));\n }\n });\n\n stateRef.current.observer.observe(target, {attributes: true, attributeFilter: ['disabled']});\n }\n }, [dispatchBlur]);\n}\n\nexport let ignoreFocusEvent = false;\n\n/**\n * This function prevents the next focus event fired on `target`, without using `event.preventDefault()`.\n * It works by waiting for the series of focus events to occur, and reverts focus back to where it was before.\n * It also makes these events mostly non-observable by using a capturing listener on the window and stopping propagation.\n */\nexport function preventFocus(target: FocusableElement | null) {\n // The browser will focus the nearest focusable ancestor of our target.\n while (target && !isFocusable(target)) {\n target = target.parentElement;\n }\n\n let window = getOwnerWindow(target);\n let activeElement = window.document.activeElement as FocusableElement | null;\n if (!activeElement || activeElement === target) {\n return;\n }\n \n ignoreFocusEvent = true;\n let isRefocusing = false;\n let onBlur = (e: FocusEvent) => {\n if (e.target === activeElement || isRefocusing) {\n e.stopImmediatePropagation();\n }\n };\n\n let onFocusOut = (e: FocusEvent) => {\n if (e.target === activeElement || isRefocusing) {\n e.stopImmediatePropagation();\n\n // If there was no focusable ancestor, we don't expect a focus event.\n // Re-focus the original active element here.\n if (!target && !isRefocusing) {\n isRefocusing = true;\n focusWithoutScrolling(activeElement);\n cleanup();\n }\n }\n };\n \n let onFocus = (e: FocusEvent) => {\n if (e.target === target || isRefocusing) {\n e.stopImmediatePropagation();\n }\n };\n\n let onFocusIn = (e: FocusEvent) => {\n if (e.target === target || isRefocusing) {\n e.stopImmediatePropagation();\n\n if (!isRefocusing) {\n isRefocusing = true;\n focusWithoutScrolling(activeElement);\n cleanup();\n }\n }\n };\n\n window.addEventListener('blur', onBlur, true);\n window.addEventListener('focusout', onFocusOut, true);\n window.addEventListener('focusin', onFocusIn, true);\n window.addEventListener('focus', onFocus, true);\n\n let cleanup = () => {\n cancelAnimationFrame(raf);\n window.removeEventListener('blur', onBlur, true);\n window.removeEventListener('focusout', onFocusOut, true);\n window.removeEventListener('focusin', onFocusIn, true);\n window.removeEventListener('focus', onFocus, true);\n ignoreFocusEvent = false;\n isRefocusing = false;\n };\n\n let raf = requestAnimationFrame(cleanup);\n return cleanup;\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAOM,SAAS,yCAA+C,WAAkB;IAC/E,IAAI,QAAQ;IACZ,MAAM,WAAW,GAAG;IACpB,MAAM,kBAAkB,GAAG,IAAM,MAAM,gBAAgB;IACvD,2FAA2F;IAC3F,MAAM,oBAAoB,GAAG,IAAM,AAAC,MAAc,YAAY;IAC9D,MAAM,OAAO,GAAG,KAAO;IACvB,OAAO;AACT;AAEO,SAAS,0CAAe,KAAY,EAAE,MAAe;IAC1D,OAAO,cAA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MAAM,KAAK,UAAU,cAAc;YACvC,EAAE,wBAAwB;YAE1B,IAAI,CAAC,cAAc;gBACjB,eAAe;gBACf,CAAA,GAAA,2CAAoB,EAAE;gBACtB;YACF;QACF;IACF;IAEA,OAAO,gBAAgB,CAAC,QAAQ,QAAQ;IACxC,OAAO,gBAAgB,CAAC,YAAY,YAAY;IAChD,OAAO,gBAAgB,CAAC,WAAW,WAAW;IAC9C,OAAO,gBAAgB,CAAC,SAAS,SAAS;IAE1C,IAAI,UAAU;QACZ,qBAAqB;QACrB,OAAO,mBAAmB,CAAC,QAAQ,QAAQ;QAC3C,OAAO,mBAAmB,CAAC,YAAY,YAAY;QACnD,OAAO,mBAAmB,CAAC,WAAW,WAAW;QACjD,OAAO,mBAAmB,CAAC,SAAS,SAAS;QAC7C,4CAAmB;QACnB,eAAe;IACjB;IAEA,IAAI,MAAM,sBAAsB;IAChC,OAAO;AACT","sources":["packages/@react-aria/interactions/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {focusWithoutScrolling, getOwnerWindow, isFocusable, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {FocusEvent as ReactFocusEvent, SyntheticEvent, useCallback, useRef} from 'react';\n\n// Turn a native event into a React synthetic event.\nexport function createSyntheticEvent<E extends SyntheticEvent>(nativeEvent: Event): E {\n let event = nativeEvent as any as E;\n event.nativeEvent = nativeEvent;\n event.isDefaultPrevented = () => event.defaultPrevented;\n // cancelBubble is technically deprecated in the spec, but still supported in all browsers.\n event.isPropagationStopped = () => (event as any).cancelBubble;\n event.persist = () => {};\n return event;\n}\n\nexport function setEventTarget(event: Event, target: Element): void {\n Object.defineProperty(event, 'target', {value: target});\n Object.defineProperty(event, 'currentTarget', {value: target});\n}\n\nexport function useSyntheticBlurEvent<Target extends Element = Element>(onBlur: (e: ReactFocusEvent<Target>) => void): (e: ReactFocusEvent<Target>) => void {\n let stateRef = useRef({\n isFocused: false,\n observer: null as MutationObserver | null\n });\n\n // Clean up MutationObserver on unmount. See below.\n\n useLayoutEffect(() => {\n const state = stateRef.current;\n return () => {\n if (state.observer) {\n state.observer.disconnect();\n state.observer = null;\n }\n };\n }, []);\n\n let dispatchBlur = useEffectEvent((e: ReactFocusEvent<Target>) => {\n onBlur?.(e);\n });\n\n // This function is called during a React onFocus event.\n return useCallback((e: ReactFocusEvent<Target>) => {\n // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142\n // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a\n // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.\n // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.\n if (\n e.target instanceof HTMLButtonElement ||\n e.target instanceof HTMLInputElement ||\n e.target instanceof HTMLTextAreaElement ||\n e.target instanceof HTMLSelectElement\n ) {\n stateRef.current.isFocused = true;\n\n let target = e.target;\n let onBlurHandler: EventListenerOrEventListenerObject | null = (e) => {\n stateRef.current.isFocused = false;\n\n if (target.disabled) {\n // For backward compatibility, dispatch a (fake) React synthetic event.\n let event = createSyntheticEvent<ReactFocusEvent<Target>>(e);\n dispatchBlur(event);\n }\n\n // We no longer need the MutationObserver once the target is blurred.\n if (stateRef.current.observer) {\n stateRef.current.observer.disconnect();\n stateRef.current.observer = null;\n }\n };\n\n target.addEventListener('focusout', onBlurHandler, {once: true});\n\n stateRef.current.observer = new MutationObserver(() => {\n if (stateRef.current.isFocused && target.disabled) {\n stateRef.current.observer?.disconnect();\n let relatedTargetEl = target === document.activeElement ? null : document.activeElement;\n target.dispatchEvent(new FocusEvent('blur', {relatedTarget: relatedTargetEl}));\n target.dispatchEvent(new FocusEvent('focusout', {bubbles: true, relatedTarget: relatedTargetEl}));\n }\n });\n\n stateRef.current.observer.observe(target, {attributes: true, attributeFilter: ['disabled']});\n }\n }, [dispatchBlur]);\n}\n\nexport let ignoreFocusEvent = false;\n\n/**\n * This function prevents the next focus event fired on `target`, without using `event.preventDefault()`.\n * It works by waiting for the series of focus events to occur, and reverts focus back to where it was before.\n * It also makes these events mostly non-observable by using a capturing listener on the window and stopping propagation.\n */\nexport function preventFocus(target: FocusableElement | null): (() => void) | undefined {\n // The browser will focus the nearest focusable ancestor of our target.\n while (target && !isFocusable(target)) {\n target = target.parentElement;\n }\n\n let window = getOwnerWindow(target);\n let activeElement = window.document.activeElement as FocusableElement | null;\n if (!activeElement || activeElement === target) {\n return;\n }\n\n ignoreFocusEvent = true;\n let isRefocusing = false;\n let onBlur = (e: FocusEvent) => {\n if (e.target === activeElement || isRefocusing) {\n e.stopImmediatePropagation();\n }\n };\n\n let onFocusOut = (e: FocusEvent) => {\n if (e.target === activeElement || isRefocusing) {\n e.stopImmediatePropagation();\n\n // If there was no focusable ancestor, we don't expect a focus event.\n // Re-focus the original active element here.\n if (!target && !isRefocusing) {\n isRefocusing = true;\n focusWithoutScrolling(activeElement);\n cleanup();\n }\n }\n };\n\n let onFocus = (e: FocusEvent) => {\n if (e.target === target || isRefocusing) {\n e.stopImmediatePropagation();\n }\n };\n\n let onFocusIn = (e: FocusEvent) => {\n if (e.target === target || isRefocusing) {\n e.stopImmediatePropagation();\n\n if (!isRefocusing) {\n isRefocusing = true;\n focusWithoutScrolling(activeElement);\n cleanup();\n }\n }\n };\n\n window.addEventListener('blur', onBlur, true);\n window.addEventListener('focusout', onFocusOut, true);\n window.addEventListener('focusin', onFocusIn, true);\n window.addEventListener('focus', onFocus, true);\n\n let cleanup = () => {\n cancelAnimationFrame(raf);\n window.removeEventListener('blur', onBlur, true);\n window.removeEventListener('focusout', onFocusOut, true);\n window.removeEventListener('focusin', onFocusIn, true);\n window.removeEventListener('focus', onFocus, true);\n ignoreFocusEvent = false;\n isRefocusing = false;\n };\n\n let raf = requestAnimationFrame(cleanup);\n return cleanup;\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
package/dist/utils.mjs CHANGED
@@ -13,35 +13,22 @@ import {useRef as $6dfIe$useRef, useCallback as $6dfIe$useCallback} from "react"
13
13
  * governing permissions and limitations under the License.
14
14
  */
15
15
 
16
- class $8a9cb279dc87e130$export$905e7fc544a71f36 {
17
- isDefaultPrevented() {
18
- return this.nativeEvent.defaultPrevented;
19
- }
20
- preventDefault() {
21
- this.defaultPrevented = true;
22
- this.nativeEvent.preventDefault();
23
- }
24
- stopPropagation() {
25
- this.nativeEvent.stopPropagation();
26
- this.isPropagationStopped = ()=>true;
27
- }
28
- isPropagationStopped() {
29
- return false;
30
- }
31
- persist() {}
32
- constructor(type, nativeEvent){
33
- this.nativeEvent = nativeEvent;
34
- this.target = nativeEvent.target;
35
- this.currentTarget = nativeEvent.currentTarget;
36
- this.relatedTarget = nativeEvent.relatedTarget;
37
- this.bubbles = nativeEvent.bubbles;
38
- this.cancelable = nativeEvent.cancelable;
39
- this.defaultPrevented = nativeEvent.defaultPrevented;
40
- this.eventPhase = nativeEvent.eventPhase;
41
- this.isTrusted = nativeEvent.isTrusted;
42
- this.timeStamp = nativeEvent.timeStamp;
43
- this.type = type;
44
- }
16
+ function $8a9cb279dc87e130$export$525bc4921d56d4a(nativeEvent) {
17
+ let event = nativeEvent;
18
+ event.nativeEvent = nativeEvent;
19
+ event.isDefaultPrevented = ()=>event.defaultPrevented;
20
+ // cancelBubble is technically deprecated in the spec, but still supported in all browsers.
21
+ event.isPropagationStopped = ()=>event.cancelBubble;
22
+ event.persist = ()=>{};
23
+ return event;
24
+ }
25
+ function $8a9cb279dc87e130$export$c2b7abe5d61ec696(event, target) {
26
+ Object.defineProperty(event, 'target', {
27
+ value: target
28
+ });
29
+ Object.defineProperty(event, 'currentTarget', {
30
+ value: target
31
+ });
45
32
  }
46
33
  function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
47
34
  let stateRef = (0, $6dfIe$useRef)({
@@ -72,8 +59,11 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
72
59
  let target = e.target;
73
60
  let onBlurHandler = (e)=>{
74
61
  stateRef.current.isFocused = false;
75
- if (target.disabled) // For backward compatibility, dispatch a (fake) React synthetic event.
76
- dispatchBlur(new $8a9cb279dc87e130$export$905e7fc544a71f36('blur', e));
62
+ if (target.disabled) {
63
+ // For backward compatibility, dispatch a (fake) React synthetic event.
64
+ let event = $8a9cb279dc87e130$export$525bc4921d56d4a(e);
65
+ dispatchBlur(event);
66
+ }
77
67
  // We no longer need the MutationObserver once the target is blurred.
78
68
  if (stateRef.current.observer) {
79
69
  stateRef.current.observer.disconnect();
@@ -163,5 +153,5 @@ function $8a9cb279dc87e130$export$cabe61c495ee3649(target) {
163
153
  }
164
154
 
165
155
 
166
- export {$8a9cb279dc87e130$export$905e7fc544a71f36 as SyntheticFocusEvent, $8a9cb279dc87e130$export$715c682d09d639cc as useSyntheticBlurEvent, $8a9cb279dc87e130$export$fda7da73ab5d4c48 as ignoreFocusEvent, $8a9cb279dc87e130$export$cabe61c495ee3649 as preventFocus};
156
+ export {$8a9cb279dc87e130$export$525bc4921d56d4a as createSyntheticEvent, $8a9cb279dc87e130$export$c2b7abe5d61ec696 as setEventTarget, $8a9cb279dc87e130$export$715c682d09d639cc as useSyntheticBlurEvent, $8a9cb279dc87e130$export$fda7da73ab5d4c48 as ignoreFocusEvent, $8a9cb279dc87e130$export$cabe61c495ee3649 as preventFocus};
167
157
  //# sourceMappingURL=utils.module.js.map
@@ -13,35 +13,22 @@ import {useRef as $6dfIe$useRef, useCallback as $6dfIe$useCallback} from "react"
13
13
  * governing permissions and limitations under the License.
14
14
  */
15
15
 
16
- class $8a9cb279dc87e130$export$905e7fc544a71f36 {
17
- isDefaultPrevented() {
18
- return this.nativeEvent.defaultPrevented;
19
- }
20
- preventDefault() {
21
- this.defaultPrevented = true;
22
- this.nativeEvent.preventDefault();
23
- }
24
- stopPropagation() {
25
- this.nativeEvent.stopPropagation();
26
- this.isPropagationStopped = ()=>true;
27
- }
28
- isPropagationStopped() {
29
- return false;
30
- }
31
- persist() {}
32
- constructor(type, nativeEvent){
33
- this.nativeEvent = nativeEvent;
34
- this.target = nativeEvent.target;
35
- this.currentTarget = nativeEvent.currentTarget;
36
- this.relatedTarget = nativeEvent.relatedTarget;
37
- this.bubbles = nativeEvent.bubbles;
38
- this.cancelable = nativeEvent.cancelable;
39
- this.defaultPrevented = nativeEvent.defaultPrevented;
40
- this.eventPhase = nativeEvent.eventPhase;
41
- this.isTrusted = nativeEvent.isTrusted;
42
- this.timeStamp = nativeEvent.timeStamp;
43
- this.type = type;
44
- }
16
+ function $8a9cb279dc87e130$export$525bc4921d56d4a(nativeEvent) {
17
+ let event = nativeEvent;
18
+ event.nativeEvent = nativeEvent;
19
+ event.isDefaultPrevented = ()=>event.defaultPrevented;
20
+ // cancelBubble is technically deprecated in the spec, but still supported in all browsers.
21
+ event.isPropagationStopped = ()=>event.cancelBubble;
22
+ event.persist = ()=>{};
23
+ return event;
24
+ }
25
+ function $8a9cb279dc87e130$export$c2b7abe5d61ec696(event, target) {
26
+ Object.defineProperty(event, 'target', {
27
+ value: target
28
+ });
29
+ Object.defineProperty(event, 'currentTarget', {
30
+ value: target
31
+ });
45
32
  }
46
33
  function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
47
34
  let stateRef = (0, $6dfIe$useRef)({
@@ -72,8 +59,11 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
72
59
  let target = e.target;
73
60
  let onBlurHandler = (e)=>{
74
61
  stateRef.current.isFocused = false;
75
- if (target.disabled) // For backward compatibility, dispatch a (fake) React synthetic event.
76
- dispatchBlur(new $8a9cb279dc87e130$export$905e7fc544a71f36('blur', e));
62
+ if (target.disabled) {
63
+ // For backward compatibility, dispatch a (fake) React synthetic event.
64
+ let event = $8a9cb279dc87e130$export$525bc4921d56d4a(e);
65
+ dispatchBlur(event);
66
+ }
77
67
  // We no longer need the MutationObserver once the target is blurred.
78
68
  if (stateRef.current.observer) {
79
69
  stateRef.current.observer.disconnect();
@@ -163,5 +153,5 @@ function $8a9cb279dc87e130$export$cabe61c495ee3649(target) {
163
153
  }
164
154
 
165
155
 
166
- export {$8a9cb279dc87e130$export$905e7fc544a71f36 as SyntheticFocusEvent, $8a9cb279dc87e130$export$715c682d09d639cc as useSyntheticBlurEvent, $8a9cb279dc87e130$export$fda7da73ab5d4c48 as ignoreFocusEvent, $8a9cb279dc87e130$export$cabe61c495ee3649 as preventFocus};
156
+ export {$8a9cb279dc87e130$export$525bc4921d56d4a as createSyntheticEvent, $8a9cb279dc87e130$export$c2b7abe5d61ec696 as setEventTarget, $8a9cb279dc87e130$export$715c682d09d639cc as useSyntheticBlurEvent, $8a9cb279dc87e130$export$fda7da73ab5d4c48 as ignoreFocusEvent, $8a9cb279dc87e130$export$cabe61c495ee3649 as preventFocus};
167
157
  //# sourceMappingURL=utils.module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,MAAM;IA2BX,qBAA8B;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,gBAAgB;IAC1C;IAEA,iBAAuB;QACrB,IAAI,CAAC,gBAAgB,GAAG;QACxB,IAAI,CAAC,WAAW,CAAC,cAAc;IACjC;IAEA,kBAAwB;QACtB,IAAI,CAAC,WAAW,CAAC,eAAe;QAChC,IAAI,CAAC,oBAAoB,GAAG,IAAM;IACpC;IAEA,uBAAgC;QAC9B,OAAO;IACT;IAEA,UAAU,CAAC;IAhCX,YAAY,IAAY,EAAE,WAAuB,CAAE;QACjD,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,MAAM,GAAG,YAAY,MAAM;QAChC,IAAI,CAAC,aAAa,GAAG,YAAY,aAA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I,CAAC,UAAU,CAAC,cAAc;gBAC5B,eAAe;gBACf,CAAA,GAAA,4BAAoB,EAAE;gBACtB;YACF;QACF;IACF;IAEA,IAAI,UAAU,CAAC;QACb,IAAI,EAAE,MAAM,KAAK,UAAU,cACzB,EAAE,wBAAwB;IAE9B;IAEA,IAAI,YAAY,CAAC;QACf,IAAI,EAAE,MAAM,KAAK,UAAU,cAAc;YACvC,EAAE,wBAAwB;YAE1B,IAAI,CAAC,cAAc;gBACjB,eAAe;gBACf,CAAA,GAAA,4BAAoB,EAAE;gBACtB;YACF;QACF;IACF;IAEA,OAAO,gBAAgB,CAAC,QAAQ,QAAQ;IACxC,OAAO,gBAAgB,CAAC,YAAY,YAAY;IAChD,OAAO,gBAAgB,CAAC,WAAW,WAAW;IAC9C,OAAO,gBAAgB,CAAC,SAAS,SAAS;IAE1C,IAAI,UAAU;QACZ,qBAAqB;QACrB,OAAO,mBAAmB,CAAC,QAAQ,QAAQ;QAC3C,OAAO,mBAAmB,CAAC,YAAY,YAAY;QACnD,OAAO,mBAAmB,CAAC,WAAW,WAAW;QACjD,OAAO,mBAAmB,CAAC,SAAS,SAAS;QAC7C,4CAAmB;QACnB,eAAe;IACjB;IAEA,IAAI,MAAM,sBAAsB;IAChC,OAAO;AACT","sources":["packages/@react-aria/interactions/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {focusWithoutScrolling, getOwnerWindow, isFocusable, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {FocusEvent as ReactFocusEvent, useCallback, useRef} from 'react';\n\nexport class SyntheticFocusEvent<Target = Element> implements ReactFocusEvent<Target> {\n nativeEvent: FocusEvent;\n target: EventTarget & Target;\n currentTarget: EventTarget & Target;\n relatedTarget: Element;\n bubbles: boolean;\n cancelable: boolean;\n defaultPrevented: boolean;\n eventPhase: number;\n isTrusted: boolean;\n timeStamp: number;\n type: string;\n\n constructor(type: string, nativeEvent: FocusEvent) {\n this.nativeEvent = nativeEvent;\n this.target = nativeEvent.target as EventTarget & Target;\n this.currentTarget = nativeEvent.currentTarget as EventTarget & Target;\n this.relatedTarget = nativeEvent.relatedTarget as Element;\n this.bubbles = nativeEvent.bubbles;\n this.cancelable = nativeEvent.cancelable;\n this.defaultPrevented = nativeEvent.defaultPrevented;\n this.eventPhase = nativeEvent.eventPhase;\n this.isTrusted = nativeEvent.isTrusted;\n this.timeStamp = nativeEvent.timeStamp;\n this.type = type;\n }\n\n isDefaultPrevented(): boolean {\n return this.nativeEvent.defaultPrevented;\n }\n\n preventDefault(): void {\n this.defaultPrevented = true;\n this.nativeEvent.preventDefault();\n }\n\n stopPropagation(): void {\n this.nativeEvent.stopPropagation();\n this.isPropagationStopped = () => true;\n }\n\n isPropagationStopped(): boolean {\n return false;\n }\n\n persist() {}\n}\n\nexport function useSyntheticBlurEvent<Target = Element>(onBlur: (e: ReactFocusEvent<Target>) => void) {\n let stateRef = useRef({\n isFocused: false,\n observer: null as MutationObserver | null\n });\n\n // Clean up MutationObserver on unmount. See below.\n \n useLayoutEffect(() => {\n const state = stateRef.current;\n return () => {\n if (state.observer) {\n state.observer.disconnect();\n state.observer = null;\n }\n };\n }, []);\n\n let dispatchBlur = useEffectEvent((e: SyntheticFocusEvent<Target>) => {\n onBlur?.(e);\n });\n\n // This function is called during a React onFocus event.\n return useCallback((e: ReactFocusEvent<Target>) => {\n // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142\n // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a\n // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.\n // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.\n if (\n e.target instanceof HTMLButtonElement ||\n e.target instanceof HTMLInputElement ||\n e.target instanceof HTMLTextAreaElement ||\n e.target instanceof HTMLSelectElement\n ) {\n stateRef.current.isFocused = true;\n\n let target = e.target;\n let onBlurHandler: EventListenerOrEventListenerObject | null = (e) => {\n stateRef.current.isFocused = false;\n\n if (target.disabled) {\n // For backward compatibility, dispatch a (fake) React synthetic event.\n dispatchBlur(new SyntheticFocusEvent('blur', e as FocusEvent));\n }\n\n // We no longer need the MutationObserver once the target is blurred.\n if (stateRef.current.observer) {\n stateRef.current.observer.disconnect();\n stateRef.current.observer = null;\n }\n };\n\n target.addEventListener('focusout', onBlurHandler, {once: true});\n\n stateRef.current.observer = new MutationObserver(() => {\n if (stateRef.current.isFocused && target.disabled) {\n stateRef.current.observer?.disconnect();\n let relatedTargetEl = target === document.activeElement ? null : document.activeElement;\n target.dispatchEvent(new FocusEvent('blur', {relatedTarget: relatedTargetEl}));\n target.dispatchEvent(new FocusEvent('focusout', {bubbles: true, relatedTarget: relatedTargetEl}));\n }\n });\n\n stateRef.current.observer.observe(target, {attributes: true, attributeFilter: ['disabled']});\n }\n }, [dispatchBlur]);\n}\n\nexport let ignoreFocusEvent = false;\n\n/**\n * This function prevents the next focus event fired on `target`, without using `event.preventDefault()`.\n * It works by waiting for the series of focus events to occur, and reverts focus back to where it was before.\n * It also makes these events mostly non-observable by using a capturing listener on the window and stopping propagation.\n */\nexport function preventFocus(target: FocusableElement | null) {\n // The browser will focus the nearest focusable ancestor of our target.\n while (target && !isFocusable(target)) {\n target = target.parentElement;\n }\n\n let window = getOwnerWindow(target);\n let activeElement = window.document.activeElement as FocusableElement | null;\n if (!activeElement || activeElement === target) {\n return;\n }\n \n ignoreFocusEvent = true;\n let isRefocusing = false;\n let onBlur = (e: FocusEvent) => {\n if (e.target === activeElement || isRefocusing) {\n e.stopImmediatePropagation();\n }\n };\n\n let onFocusOut = (e: FocusEvent) => {\n if (e.target === activeElement || isRefocusing) {\n e.stopImmediatePropagation();\n\n // If there was no focusable ancestor, we don't expect a focus event.\n // Re-focus the original active element here.\n if (!target && !isRefocusing) {\n isRefocusing = true;\n focusWithoutScrolling(activeElement);\n cleanup();\n }\n }\n };\n \n let onFocus = (e: FocusEvent) => {\n if (e.target === target || isRefocusing) {\n e.stopImmediatePropagation();\n }\n };\n\n let onFocusIn = (e: FocusEvent) => {\n if (e.target === target || isRefocusing) {\n e.stopImmediatePropagation();\n\n if (!isRefocusing) {\n isRefocusing = true;\n focusWithoutScrolling(activeElement);\n cleanup();\n }\n }\n };\n\n window.addEventListener('blur', onBlur, true);\n window.addEventListener('focusout', onFocusOut, true);\n window.addEventListener('focusin', onFocusIn, true);\n window.addEventListener('focus', onFocus, true);\n\n let cleanup = () => {\n cancelAnimationFrame(raf);\n window.removeEventListener('blur', onBlur, true);\n window.removeEventListener('focusout', onFocusOut, true);\n window.removeEventListener('focusin', onFocusIn, true);\n window.removeEventListener('focus', onFocus, true);\n ignoreFocusEvent = false;\n isRefocusing = false;\n };\n\n let raf = requestAnimationFrame(cleanup);\n return cleanup;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAOM,SAAS,yCAA+C,WAAkB;IAC/E,IAAI,QAAQ;IACZ,MAAM,WAAW,GAAG;IACpB,MAAM,kBAAkB,GAAG,IAAM,MAAM,gBAAgB;IACvD,2FAA2F;IAC3F,MAAM,oBAAoB,GAAG,IAAM,AAAC,MAAc,YAAY;IAC9D,MAAM,OAAO,GAAG,KAAO;IACvB,OAAO;AACT;AAEO,SAAS,0CAAe,KAAY,EAAE,MAAe;IAC1D,OAAO,cAAc,CAAC,OAAO,UAAU;QAAC,OAAO;IAAM;IACrD,OAAO,cAAc,CAAC,OAAO,iBAAiB;QAAC,OAAO;IAAM;AAC9D;AAEO,SAAS,0CAAwD,MAA4C;IAClH,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IAEA,OAAO,gBAAgB,CAAC,QAAQ,QAAQ;IACxC,OAAO,gBAAgB,CAAC,YAAY,YAAY;IAChD,OAAO,gBAAgB,CAAC,WAAW,WAAW;IAC9C,OAAO,gBAAgB,CAAC,SAAS,SAAS;IAE1C,IAAI,UAAU;QACZ,qBAAqB;QACrB,OAAO,mBAAmB,CAAC,QAAQ,QAAQ;QAC3C,OAAO,mBAAmB,CAAC,YAAY,YAAY;QACnD,OAAO,mBAAmB,CAAC,WAAW,WAAW;QACjD,OAAO,mBAAmB,CAAC,SAAS,SAAS;QAC7C,4CAAmB;QACnB,eAAe;IACjB;IAEA,IAAI,MAAM,sBAAsB;IAChC,OAAO;AACT","sources":["packages/@react-aria/interactions/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement} from '@react-types/shared';\nimport {focusWithoutScrolling, getOwnerWindow, isFocusable, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {FocusEvent as ReactFocusEvent, SyntheticEvent, useCallback, useRef} from 'react';\n\n// Turn a native event into a React synthetic event.\nexport function createSyntheticEvent<E extends SyntheticEvent>(nativeEvent: Event): E {\n let event = nativeEvent as any as E;\n event.nativeEvent = nativeEvent;\n event.isDefaultPrevented = () => event.defaultPrevented;\n // cancelBubble is technically deprecated in the spec, but still supported in all browsers.\n event.isPropagationStopped = () => (event as any).cancelBubble;\n event.persist = () => {};\n return event;\n}\n\nexport function setEventTarget(event: Event, target: Element): void {\n Object.defineProperty(event, 'target', {value: target});\n Object.defineProperty(event, 'currentTarget', {value: target});\n}\n\nexport function useSyntheticBlurEvent<Target extends Element = Element>(onBlur: (e: ReactFocusEvent<Target>) => void): (e: ReactFocusEvent<Target>) => void {\n let stateRef = useRef({\n isFocused: false,\n observer: null as MutationObserver | null\n });\n\n // Clean up MutationObserver on unmount. See below.\n\n useLayoutEffect(() => {\n const state = stateRef.current;\n return () => {\n if (state.observer) {\n state.observer.disconnect();\n state.observer = null;\n }\n };\n }, []);\n\n let dispatchBlur = useEffectEvent((e: ReactFocusEvent<Target>) => {\n onBlur?.(e);\n });\n\n // This function is called during a React onFocus event.\n return useCallback((e: ReactFocusEvent<Target>) => {\n // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142\n // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a\n // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.\n // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.\n if (\n e.target instanceof HTMLButtonElement ||\n e.target instanceof HTMLInputElement ||\n e.target instanceof HTMLTextAreaElement ||\n e.target instanceof HTMLSelectElement\n ) {\n stateRef.current.isFocused = true;\n\n let target = e.target;\n let onBlurHandler: EventListenerOrEventListenerObject | null = (e) => {\n stateRef.current.isFocused = false;\n\n if (target.disabled) {\n // For backward compatibility, dispatch a (fake) React synthetic event.\n let event = createSyntheticEvent<ReactFocusEvent<Target>>(e);\n dispatchBlur(event);\n }\n\n // We no longer need the MutationObserver once the target is blurred.\n if (stateRef.current.observer) {\n stateRef.current.observer.disconnect();\n stateRef.current.observer = null;\n }\n };\n\n target.addEventListener('focusout', onBlurHandler, {once: true});\n\n stateRef.current.observer = new MutationObserver(() => {\n if (stateRef.current.isFocused && target.disabled) {\n stateRef.current.observer?.disconnect();\n let relatedTargetEl = target === document.activeElement ? null : document.activeElement;\n target.dispatchEvent(new FocusEvent('blur', {relatedTarget: relatedTargetEl}));\n target.dispatchEvent(new FocusEvent('focusout', {bubbles: true, relatedTarget: relatedTargetEl}));\n }\n });\n\n stateRef.current.observer.observe(target, {attributes: true, attributeFilter: ['disabled']});\n }\n }, [dispatchBlur]);\n}\n\nexport let ignoreFocusEvent = false;\n\n/**\n * This function prevents the next focus event fired on `target`, without using `event.preventDefault()`.\n * It works by waiting for the series of focus events to occur, and reverts focus back to where it was before.\n * It also makes these events mostly non-observable by using a capturing listener on the window and stopping propagation.\n */\nexport function preventFocus(target: FocusableElement | null): (() => void) | undefined {\n // The browser will focus the nearest focusable ancestor of our target.\n while (target && !isFocusable(target)) {\n target = target.parentElement;\n }\n\n let window = getOwnerWindow(target);\n let activeElement = window.document.activeElement as FocusableElement | null;\n if (!activeElement || activeElement === target) {\n return;\n }\n\n ignoreFocusEvent = true;\n let isRefocusing = false;\n let onBlur = (e: FocusEvent) => {\n if (e.target === activeElement || isRefocusing) {\n e.stopImmediatePropagation();\n }\n };\n\n let onFocusOut = (e: FocusEvent) => {\n if (e.target === activeElement || isRefocusing) {\n e.stopImmediatePropagation();\n\n // If there was no focusable ancestor, we don't expect a focus event.\n // Re-focus the original active element here.\n if (!target && !isRefocusing) {\n isRefocusing = true;\n focusWithoutScrolling(activeElement);\n cleanup();\n }\n }\n };\n\n let onFocus = (e: FocusEvent) => {\n if (e.target === target || isRefocusing) {\n e.stopImmediatePropagation();\n }\n };\n\n let onFocusIn = (e: FocusEvent) => {\n if (e.target === target || isRefocusing) {\n e.stopImmediatePropagation();\n\n if (!isRefocusing) {\n isRefocusing = true;\n focusWithoutScrolling(activeElement);\n cleanup();\n }\n }\n };\n\n window.addEventListener('blur', onBlur, true);\n window.addEventListener('focusout', onFocusOut, true);\n window.addEventListener('focusin', onFocusIn, true);\n window.addEventListener('focus', onFocus, true);\n\n let cleanup = () => {\n cancelAnimationFrame(raf);\n window.removeEventListener('blur', onBlur, true);\n window.removeEventListener('focusout', onFocusOut, true);\n window.removeEventListener('focusin', onFocusIn, true);\n window.removeEventListener('focus', onFocus, true);\n ignoreFocusEvent = false;\n isRefocusing = false;\n };\n\n let raf = requestAnimationFrame(cleanup);\n return cleanup;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/interactions",
3
- "version": "3.24.1",
3
+ "version": "3.25.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,10 +22,10 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/ssr": "^3.9.7",
26
- "@react-aria/utils": "^3.28.1",
27
- "@react-stately/flags": "^3.1.0",
28
- "@react-types/shared": "^3.28.0",
25
+ "@react-aria/ssr": "^3.9.8",
26
+ "@react-aria/utils": "^3.28.2",
27
+ "@react-stately/flags": "^3.1.1",
28
+ "@react-types/shared": "^3.29.0",
29
29
  "@swc/helpers": "^0.5.0"
30
30
  },
31
31
  "peerDependencies": {
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "9c4ebbc0c1972cc880febc29de995ca58caa3ba4"
38
+ "gitHead": "9b66d270572f482948afee95622a85cdf68ed408"
39
39
  }