UNPKG

@mskcc/carbon-react

Version:

Carbon react components for the MSKCC DSM

117 lines (116 loc) 4.73 kB
/** * MSKCC DSM 2021, 2024 */ import PropTypes from 'prop-types'; import React from 'react'; import { PopoverAlignment } from '../Popover'; import { type PolymorphicProps } from '../../types/common'; interface TooltipBaseProps { /** * Specify how the trigger should align with the tooltip */ align?: PopoverAlignment; /** * Pass in the child to which the tooltip will be applied */ children?: React.ReactElement; /** * Specify an optional className to be applied to the container node */ className?: string; /** * Determines whether the tooltip should close when inner content is activated (click, Enter or Space) */ closeOnActivation?: boolean; /** * Specify whether the tooltip should be open when it first renders */ defaultOpen?: boolean; /** * Provide the description to be rendered inside of the Tooltip. The * description will use `aria-describedby` and will describe the child node * in addition to the text rendered inside of the child. This means that if you * have text in the child node, that it will be announced alongside the * description to the screen reader. * * Note: if label and description are both provided, label will be used and * description will not be used */ description?: React.ReactNode; /** * Specify the duration in milliseconds to delay before displaying the tooltip */ enterDelayMs?: number; /** * Provide the label to be rendered inside of the Tooltip. The label will use * `aria-labelledby` and will fully describe the child node that is provided. * This means that if you have text in the child node, that it will not be * announced to the screen reader. * * Note: if label and description are both provided, description will not be * used */ label?: React.ReactNode; /** * Specify the duration in milliseconds to delay before hiding the tooltip */ leaveDelayMs?: number; disabled?: boolean; } export type TooltipProps<T extends React.ElementType> = PolymorphicProps<T, TooltipBaseProps>; declare function Tooltip<T extends React.ElementType>({ align, className: customClassName, children, label, description, enterDelayMs, leaveDelayMs, defaultOpen, closeOnActivation, disabled, ...rest }: TooltipProps<T>): JSX.Element; declare namespace Tooltip { var propTypes: { /** * Specify how the trigger should align with the tooltip */ align: PropTypes.Requireable<string>; /** * Pass in the child to which the tooltip will be applied */ children: PropTypes.Requireable<PropTypes.ReactNodeLike>; /** * Specify an optional className to be applied to the container node */ className: PropTypes.Requireable<string>; /** * Determines wether the tooltip should close when inner content is activated (click, Enter or Space) */ closeOnActivation: PropTypes.Requireable<boolean>; /** * Specify whether the tooltip should be open when it first renders */ defaultOpen: PropTypes.Requireable<boolean>; /** * Provide the description to be rendered inside of the Tooltip. The * description will use `aria-describedby` and will describe the child node * in addition to the text rendered inside of the child. This means that if you * have text in the child node, that it will be announced alongside the * description to the screen reader. * * Note: if label and description are both provided, label will be used and * description will not be used */ description: PropTypes.Requireable<PropTypes.ReactNodeLike>; disabled: PropTypes.Requireable<boolean>; /** * Specify the duration in milliseconds to delay before displaying the tooltip */ enterDelayMs: PropTypes.Requireable<number>; /** * Provide the label to be rendered inside of the Tooltip. The label will use * `aria-labelledby` and will fully describe the child node that is provided. * This means that if you have text in the child node, that it will not be * announced to the screen reader. * * Note: if label and description are both provided, description will not be * used */ label: PropTypes.Requireable<PropTypes.ReactNodeLike>; /** * Specify the duration in milliseconds to delay before hiding the tooltip */ leaveDelayMs: PropTypes.Requireable<number>; }; } export { Tooltip };