@react-aria/tooltip
Advanced tools
Comparing version 3.0.0-nightly.836 to 3.0.0-nightly.849
@@ -10,11 +10,11 @@ var { | ||
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends")); | ||
var { | ||
useHover, | ||
getInteractionModality, | ||
isFocusVisible, | ||
usePress, | ||
useHover | ||
usePress | ||
} = require("@react-aria/interactions"); | ||
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends")); | ||
var { | ||
@@ -33,8 +33,14 @@ filterDOMProps, | ||
*/ | ||
function useTooltip(props) { | ||
function useTooltip(props, state) { | ||
let domProps = filterDOMProps(props, { | ||
labelable: true | ||
}); | ||
let { | ||
hoverProps | ||
} = useHover({ | ||
onHoverStart: () => state == null ? void 0 : state.open(true), | ||
onHoverEnd: () => state == null ? void 0 : state.close() | ||
}); | ||
return { | ||
tooltipProps: mergeProps(domProps, { | ||
tooltipProps: mergeProps(domProps, hoverProps, { | ||
role: 'tooltip' | ||
@@ -66,5 +72,5 @@ }) | ||
let handleHide = () => { | ||
let handleHide = immediate => { | ||
if (!isHovered.current && !isFocused.current) { | ||
state.close(); | ||
state.close(immediate); | ||
} | ||
@@ -79,3 +85,3 @@ }; | ||
if (e.key === 'Escape') { | ||
state.close(); | ||
state.close(true); | ||
} | ||
@@ -126,3 +132,3 @@ } | ||
isHovered.current = false; | ||
handleHide(); | ||
handleHide(true); | ||
}; | ||
@@ -142,3 +148,3 @@ | ||
isHovered.current = false; | ||
handleHide(); | ||
handleHide(true); | ||
}; | ||
@@ -145,0 +151,0 @@ |
import { useFocusable } from "@react-aria/focus"; | ||
import { useEffect, useRef } from "react"; | ||
import { getInteractionModality, isFocusVisible, usePress, useHover } from "@react-aria/interactions"; | ||
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends"; | ||
import { useHover, getInteractionModality, isFocusVisible, usePress } from "@react-aria/interactions"; | ||
import { filterDOMProps, mergeProps, useId } from "@react-aria/utils"; | ||
@@ -10,8 +10,14 @@ | ||
*/ | ||
export function useTooltip(props) { | ||
export function useTooltip(props, state) { | ||
let domProps = filterDOMProps(props, { | ||
labelable: true | ||
}); | ||
let { | ||
hoverProps | ||
} = useHover({ | ||
onHoverStart: () => state == null ? void 0 : state.open(true), | ||
onHoverEnd: () => state == null ? void 0 : state.close() | ||
}); | ||
return { | ||
tooltipProps: mergeProps(domProps, { | ||
tooltipProps: mergeProps(domProps, hoverProps, { | ||
role: 'tooltip' | ||
@@ -41,5 +47,5 @@ }) | ||
let handleHide = () => { | ||
let handleHide = immediate => { | ||
if (!isHovered.current && !isFocused.current) { | ||
state.close(); | ||
state.close(immediate); | ||
} | ||
@@ -54,3 +60,3 @@ }; | ||
if (e.key === 'Escape') { | ||
state.close(); | ||
state.close(true); | ||
} | ||
@@ -101,3 +107,3 @@ } | ||
isHovered.current = false; | ||
handleHide(); | ||
handleHide(true); | ||
}; | ||
@@ -117,3 +123,3 @@ | ||
isHovered.current = false; | ||
handleHide(); | ||
handleHide(true); | ||
}; | ||
@@ -120,0 +126,0 @@ |
import { AriaTooltipProps, TooltipTriggerProps } from "@react-types/tooltip"; | ||
import { HTMLAttributes, RefObject } from "react"; | ||
import { TooltipTriggerState } from "@react-stately/tooltip"; | ||
import { FocusEvents } from "@react-types/shared"; | ||
import { HoverProps, PressProps } from "@react-aria/interactions"; | ||
import { TooltipTriggerState } from "@react-stately/tooltip"; | ||
interface TooltipAria { | ||
@@ -15,3 +15,3 @@ /** | ||
*/ | ||
export function useTooltip(props: AriaTooltipProps): TooltipAria; | ||
export function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria; | ||
interface TooltipTriggerAria { | ||
@@ -18,0 +18,0 @@ /** |
{ | ||
"name": "@react-aria/tooltip", | ||
"version": "3.0.0-nightly.836+f5678f9c", | ||
"version": "3.0.0-nightly.849+e08af810", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,9 +21,9 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/focus": "3.0.0-nightly.836+f5678f9c", | ||
"@react-aria/interactions": "3.0.0-nightly.836+f5678f9c", | ||
"@react-aria/overlays": "3.0.0-nightly.836+f5678f9c", | ||
"@react-aria/utils": "3.0.0-nightly.836+f5678f9c", | ||
"@react-stately/tooltip": "3.0.2-nightly.2514+f5678f9c", | ||
"@react-types/shared": "3.0.0-nightly.836+f5678f9c", | ||
"@react-types/tooltip": "3.1.1-nightly.2514+f5678f9c" | ||
"@react-aria/focus": "3.0.0-nightly.849+e08af810", | ||
"@react-aria/interactions": "3.0.0-nightly.849+e08af810", | ||
"@react-aria/overlays": "3.0.0-nightly.849+e08af810", | ||
"@react-aria/utils": "3.0.0-nightly.849+e08af810", | ||
"@react-stately/tooltip": "3.0.2-nightly.2527+e08af810", | ||
"@react-types/shared": "3.0.0-nightly.849+e08af810", | ||
"@react-types/tooltip": "3.1.1-nightly.2527+e08af810" | ||
}, | ||
@@ -36,3 +36,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "f5678f9c0a8a02422a16eda4e9be11d2b88ed08b" | ||
"gitHead": "e08af810954896b95e444b5b02ab782cd1e4b759" | ||
} |
@@ -16,2 +16,4 @@ /* | ||
import {HTMLAttributes} from 'react'; | ||
import {TooltipTriggerState} from '@react-stately/tooltip'; | ||
import {useHover} from '@react-aria/interactions'; | ||
@@ -28,7 +30,12 @@ interface TooltipAria { | ||
*/ | ||
export function useTooltip(props: AriaTooltipProps): TooltipAria { | ||
export function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria { | ||
let domProps = filterDOMProps(props, {labelable: true}); | ||
let {hoverProps} = useHover({ | ||
onHoverStart: () => state?.open(true), | ||
onHoverEnd: () => state?.close() | ||
}); | ||
return { | ||
tooltipProps: mergeProps(domProps, { | ||
tooltipProps: mergeProps(domProps, hoverProps, { | ||
role: 'tooltip' | ||
@@ -35,0 +42,0 @@ }) |
@@ -55,5 +55,5 @@ /* | ||
let handleHide = () => { | ||
let handleHide = (immediate?: boolean) => { | ||
if (!isHovered.current && !isFocused.current) { | ||
state.close(); | ||
state.close(immediate); | ||
} | ||
@@ -68,3 +68,3 @@ }; | ||
if (e.key === 'Escape') { | ||
state.close(); | ||
state.close(true); | ||
} | ||
@@ -111,3 +111,3 @@ } | ||
isHovered.current = false; | ||
handleHide(); | ||
handleHide(true); | ||
}; | ||
@@ -126,3 +126,3 @@ | ||
isHovered.current = false; | ||
handleHide(); | ||
handleHide(true); | ||
}; | ||
@@ -129,0 +129,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
49160
495