UNPKG

28.3 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import useTimeout, { Timeout } from '@mui/utils/useTimeout';
7import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
8import composeClasses from '@mui/utils/composeClasses';
9import { alpha } from '@mui/system/colorManipulator';
10import { useRtl } from '@mui/system/RtlProvider';
11import isFocusVisible from '@mui/utils/isFocusVisible';
12import appendOwnerState from '@mui/utils/appendOwnerState';
13import getReactElementRef from '@mui/utils/getReactElementRef';
14import { styled, useTheme } from "../zero-styled/index.js";
15import memoTheme from "../utils/memoTheme.js";
16import { useDefaultProps } from "../DefaultPropsProvider/index.js";
17import capitalize from "../utils/capitalize.js";
18import Grow from "../Grow/index.js";
19import Popper from "../Popper/index.js";
20import useEventCallback from "../utils/useEventCallback.js";
21import useForkRef from "../utils/useForkRef.js";
22import useId from "../utils/useId.js";
23import useControlled from "../utils/useControlled.js";
24import tooltipClasses, { getTooltipUtilityClass } from "./tooltipClasses.js";
25import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
26function round(value) {
27 return Math.round(value * 1e5) / 1e5;
28}
29const useUtilityClasses = ownerState => {
30 const {
31 classes,
32 disableInteractive,
33 arrow,
34 touch,
35 placement
36 } = ownerState;
37 const slots = {
38 popper: ['popper', !disableInteractive && 'popperInteractive', arrow && 'popperArrow'],
39 tooltip: ['tooltip', arrow && 'tooltipArrow', touch && 'touch', `tooltipPlacement${capitalize(placement.split('-')[0])}`],
40 arrow: ['arrow']
41 };
42 return composeClasses(slots, getTooltipUtilityClass, classes);
43};
44const TooltipPopper = styled(Popper, {
45 name: 'MuiTooltip',
46 slot: 'Popper',
47 overridesResolver: (props, styles) => {
48 const {
49 ownerState
50 } = props;
51 return [styles.popper, !ownerState.disableInteractive && styles.popperInteractive, ownerState.arrow && styles.popperArrow, !ownerState.open && styles.popperClose];
52 }
53})(memoTheme(({
54 theme
55}) => ({
56 zIndex: (theme.vars || theme).zIndex.tooltip,
57 pointerEvents: 'none',
58 variants: [{
59 props: ({
60 ownerState
61 }) => !ownerState.disableInteractive,
62 style: {
63 pointerEvents: 'auto'
64 }
65 }, {
66 props: ({
67 open
68 }) => !open,
69 style: {
70 pointerEvents: 'none'
71 }
72 }, {
73 props: ({
74 ownerState
75 }) => ownerState.arrow,
76 style: {
77 [`&[data-popper-placement*="bottom"] .${tooltipClasses.arrow}`]: {
78 top: 0,
79 marginTop: '-0.71em',
80 '&::before': {
81 transformOrigin: '0 100%'
82 }
83 },
84 [`&[data-popper-placement*="top"] .${tooltipClasses.arrow}`]: {
85 bottom: 0,
86 marginBottom: '-0.71em',
87 '&::before': {
88 transformOrigin: '100% 0'
89 }
90 },
91 [`&[data-popper-placement*="right"] .${tooltipClasses.arrow}`]: {
92 height: '1em',
93 width: '0.71em',
94 '&::before': {
95 transformOrigin: '100% 100%'
96 }
97 },
98 [`&[data-popper-placement*="left"] .${tooltipClasses.arrow}`]: {
99 height: '1em',
100 width: '0.71em',
101 '&::before': {
102 transformOrigin: '0 0'
103 }
104 }
105 }
106 }, {
107 props: ({
108 ownerState
109 }) => ownerState.arrow && !ownerState.isRtl,
110 style: {
111 [`&[data-popper-placement*="right"] .${tooltipClasses.arrow}`]: {
112 left: 0,
113 marginLeft: '-0.71em'
114 }
115 }
116 }, {
117 props: ({
118 ownerState
119 }) => ownerState.arrow && !!ownerState.isRtl,
120 style: {
121 [`&[data-popper-placement*="right"] .${tooltipClasses.arrow}`]: {
122 right: 0,
123 marginRight: '-0.71em'
124 }
125 }
126 }, {
127 props: ({
128 ownerState
129 }) => ownerState.arrow && !ownerState.isRtl,
130 style: {
131 [`&[data-popper-placement*="left"] .${tooltipClasses.arrow}`]: {
132 right: 0,
133 marginRight: '-0.71em'
134 }
135 }
136 }, {
137 props: ({
138 ownerState
139 }) => ownerState.arrow && !!ownerState.isRtl,
140 style: {
141 [`&[data-popper-placement*="left"] .${tooltipClasses.arrow}`]: {
142 left: 0,
143 marginLeft: '-0.71em'
144 }
145 }
146 }]
147})));
148const TooltipTooltip = styled('div', {
149 name: 'MuiTooltip',
150 slot: 'Tooltip',
151 overridesResolver: (props, styles) => {
152 const {
153 ownerState
154 } = props;
155 return [styles.tooltip, ownerState.touch && styles.touch, ownerState.arrow && styles.tooltipArrow, styles[`tooltipPlacement${capitalize(ownerState.placement.split('-')[0])}`]];
156 }
157})(memoTheme(({
158 theme
159}) => ({
160 backgroundColor: theme.vars ? theme.vars.palette.Tooltip.bg : alpha(theme.palette.grey[700], 0.92),
161 borderRadius: (theme.vars || theme).shape.borderRadius,
162 color: (theme.vars || theme).palette.common.white,
163 fontFamily: theme.typography.fontFamily,
164 padding: '4px 8px',
165 fontSize: theme.typography.pxToRem(11),
166 maxWidth: 300,
167 margin: 2,
168 wordWrap: 'break-word',
169 fontWeight: theme.typography.fontWeightMedium,
170 [`.${tooltipClasses.popper}[data-popper-placement*="left"] &`]: {
171 transformOrigin: 'right center'
172 },
173 [`.${tooltipClasses.popper}[data-popper-placement*="right"] &`]: {
174 transformOrigin: 'left center'
175 },
176 [`.${tooltipClasses.popper}[data-popper-placement*="top"] &`]: {
177 transformOrigin: 'center bottom',
178 marginBottom: '14px'
179 },
180 [`.${tooltipClasses.popper}[data-popper-placement*="bottom"] &`]: {
181 transformOrigin: 'center top',
182 marginTop: '14px'
183 },
184 variants: [{
185 props: ({
186 ownerState
187 }) => ownerState.arrow,
188 style: {
189 position: 'relative',
190 margin: 0
191 }
192 }, {
193 props: ({
194 ownerState
195 }) => ownerState.touch,
196 style: {
197 padding: '8px 16px',
198 fontSize: theme.typography.pxToRem(14),
199 lineHeight: `${round(16 / 14)}em`,
200 fontWeight: theme.typography.fontWeightRegular
201 }
202 }, {
203 props: ({
204 ownerState
205 }) => !ownerState.isRtl,
206 style: {
207 [`.${tooltipClasses.popper}[data-popper-placement*="left"] &`]: {
208 marginRight: '14px'
209 },
210 [`.${tooltipClasses.popper}[data-popper-placement*="right"] &`]: {
211 marginLeft: '14px'
212 }
213 }
214 }, {
215 props: ({
216 ownerState
217 }) => !ownerState.isRtl && ownerState.touch,
218 style: {
219 [`.${tooltipClasses.popper}[data-popper-placement*="left"] &`]: {
220 marginRight: '24px'
221 },
222 [`.${tooltipClasses.popper}[data-popper-placement*="right"] &`]: {
223 marginLeft: '24px'
224 }
225 }
226 }, {
227 props: ({
228 ownerState
229 }) => !!ownerState.isRtl,
230 style: {
231 [`.${tooltipClasses.popper}[data-popper-placement*="left"] &`]: {
232 marginLeft: '14px'
233 },
234 [`.${tooltipClasses.popper}[data-popper-placement*="right"] &`]: {
235 marginRight: '14px'
236 }
237 }
238 }, {
239 props: ({
240 ownerState
241 }) => !!ownerState.isRtl && ownerState.touch,
242 style: {
243 [`.${tooltipClasses.popper}[data-popper-placement*="left"] &`]: {
244 marginLeft: '24px'
245 },
246 [`.${tooltipClasses.popper}[data-popper-placement*="right"] &`]: {
247 marginRight: '24px'
248 }
249 }
250 }, {
251 props: ({
252 ownerState
253 }) => ownerState.touch,
254 style: {
255 [`.${tooltipClasses.popper}[data-popper-placement*="top"] &`]: {
256 marginBottom: '24px'
257 }
258 }
259 }, {
260 props: ({
261 ownerState
262 }) => ownerState.touch,
263 style: {
264 [`.${tooltipClasses.popper}[data-popper-placement*="bottom"] &`]: {
265 marginTop: '24px'
266 }
267 }
268 }]
269})));
270const TooltipArrow = styled('span', {
271 name: 'MuiTooltip',
272 slot: 'Arrow',
273 overridesResolver: (props, styles) => styles.arrow
274})(memoTheme(({
275 theme
276}) => ({
277 overflow: 'hidden',
278 position: 'absolute',
279 width: '1em',
280 height: '0.71em' /* = width / sqrt(2) = (length of the hypotenuse) */,
281 boxSizing: 'border-box',
282 color: theme.vars ? theme.vars.palette.Tooltip.bg : alpha(theme.palette.grey[700], 0.9),
283 '&::before': {
284 content: '""',
285 margin: 'auto',
286 display: 'block',
287 width: '100%',
288 height: '100%',
289 backgroundColor: 'currentColor',
290 transform: 'rotate(45deg)'
291 }
292})));
293let hystersisOpen = false;
294const hystersisTimer = new Timeout();
295let cursorPosition = {
296 x: 0,
297 y: 0
298};
299export function testReset() {
300 hystersisOpen = false;
301 hystersisTimer.clear();
302}
303function composeEventHandler(handler, eventHandler) {
304 return (event, ...params) => {
305 if (eventHandler) {
306 eventHandler(event, ...params);
307 }
308 handler(event, ...params);
309 };
310}
311
312// TODO v6: Remove PopperComponent, PopperProps, TransitionComponent and TransitionProps.
313const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(inProps, ref) {
314 const props = useDefaultProps({
315 props: inProps,
316 name: 'MuiTooltip'
317 });
318 const {
319 arrow = false,
320 children: childrenProp,
321 classes: classesProp,
322 components = {},
323 componentsProps = {},
324 describeChild = false,
325 disableFocusListener = false,
326 disableHoverListener = false,
327 disableInteractive: disableInteractiveProp = false,
328 disableTouchListener = false,
329 enterDelay = 100,
330 enterNextDelay = 0,
331 enterTouchDelay = 700,
332 followCursor = false,
333 id: idProp,
334 leaveDelay = 0,
335 leaveTouchDelay = 1500,
336 onClose,
337 onOpen,
338 open: openProp,
339 placement = 'bottom',
340 PopperComponent: PopperComponentProp,
341 PopperProps = {},
342 slotProps = {},
343 slots = {},
344 title,
345 TransitionComponent: TransitionComponentProp = Grow,
346 TransitionProps,
347 ...other
348 } = props;
349
350 // to prevent runtime errors, developers will need to provide a child as a React element anyway.
351 const children = /*#__PURE__*/React.isValidElement(childrenProp) ? childrenProp : /*#__PURE__*/_jsx("span", {
352 children: childrenProp
353 });
354 const theme = useTheme();
355 const isRtl = useRtl();
356 const [childNode, setChildNode] = React.useState();
357 const [arrowRef, setArrowRef] = React.useState(null);
358 const ignoreNonTouchEvents = React.useRef(false);
359 const disableInteractive = disableInteractiveProp || followCursor;
360 const closeTimer = useTimeout();
361 const enterTimer = useTimeout();
362 const leaveTimer = useTimeout();
363 const touchTimer = useTimeout();
364 const [openState, setOpenState] = useControlled({
365 controlled: openProp,
366 default: false,
367 name: 'Tooltip',
368 state: 'open'
369 });
370 let open = openState;
371 if (process.env.NODE_ENV !== 'production') {
372 // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
373 // eslint-disable-next-line react-hooks/rules-of-hooks -- process.env never changes
374 const {
375 current: isControlled
376 } = React.useRef(openProp !== undefined);
377
378 // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
379 // eslint-disable-next-line react-hooks/rules-of-hooks -- process.env never changes
380 React.useEffect(() => {
381 if (childNode && childNode.disabled && !isControlled && title !== '' && childNode.tagName.toLowerCase() === 'button') {
382 console.error(['MUI: You are providing a disabled `button` child to the Tooltip component.', 'A disabled element does not fire events.', "Tooltip needs to listen to the child element's events to display the title.", '', 'Add a simple wrapper element, such as a `span`.'].join('\n'));
383 }
384 }, [title, childNode, isControlled]);
385 }
386 const id = useId(idProp);
387 const prevUserSelect = React.useRef();
388 const stopTouchInteraction = useEventCallback(() => {
389 if (prevUserSelect.current !== undefined) {
390 document.body.style.WebkitUserSelect = prevUserSelect.current;
391 prevUserSelect.current = undefined;
392 }
393 touchTimer.clear();
394 });
395 React.useEffect(() => stopTouchInteraction, [stopTouchInteraction]);
396 const handleOpen = event => {
397 hystersisTimer.clear();
398 hystersisOpen = true;
399
400 // The mouseover event will trigger for every nested element in the tooltip.
401 // We can skip rerendering when the tooltip is already open.
402 // We are using the mouseover event instead of the mouseenter event to fix a hide/show issue.
403 setOpenState(true);
404 if (onOpen && !open) {
405 onOpen(event);
406 }
407 };
408 const handleClose = useEventCallback(
409 /**
410 * @param {React.SyntheticEvent | Event} event
411 */
412 event => {
413 hystersisTimer.start(800 + leaveDelay, () => {
414 hystersisOpen = false;
415 });
416 setOpenState(false);
417 if (onClose && open) {
418 onClose(event);
419 }
420 closeTimer.start(theme.transitions.duration.shortest, () => {
421 ignoreNonTouchEvents.current = false;
422 });
423 });
424 const handleMouseOver = event => {
425 if (ignoreNonTouchEvents.current && event.type !== 'touchstart') {
426 return;
427 }
428
429 // Remove the title ahead of time.
430 // We don't want to wait for the next render commit.
431 // We would risk displaying two tooltips at the same time (native + this one).
432 if (childNode) {
433 childNode.removeAttribute('title');
434 }
435 enterTimer.clear();
436 leaveTimer.clear();
437 if (enterDelay || hystersisOpen && enterNextDelay) {
438 enterTimer.start(hystersisOpen ? enterNextDelay : enterDelay, () => {
439 handleOpen(event);
440 });
441 } else {
442 handleOpen(event);
443 }
444 };
445 const handleMouseLeave = event => {
446 enterTimer.clear();
447 leaveTimer.start(leaveDelay, () => {
448 handleClose(event);
449 });
450 };
451 const [, setChildIsFocusVisible] = React.useState(false);
452 const handleBlur = event => {
453 if (!isFocusVisible(event.target)) {
454 setChildIsFocusVisible(false);
455 handleMouseLeave(event);
456 }
457 };
458 const handleFocus = event => {
459 // Workaround for https://github.com/facebook/react/issues/7769
460 // The autoFocus of React might trigger the event before the componentDidMount.
461 // We need to account for this eventuality.
462 if (!childNode) {
463 setChildNode(event.currentTarget);
464 }
465 if (isFocusVisible(event.target)) {
466 setChildIsFocusVisible(true);
467 handleMouseOver(event);
468 }
469 };
470 const detectTouchStart = event => {
471 ignoreNonTouchEvents.current = true;
472 const childrenProps = children.props;
473 if (childrenProps.onTouchStart) {
474 childrenProps.onTouchStart(event);
475 }
476 };
477 const handleTouchStart = event => {
478 detectTouchStart(event);
479 leaveTimer.clear();
480 closeTimer.clear();
481 stopTouchInteraction();
482 prevUserSelect.current = document.body.style.WebkitUserSelect;
483 // Prevent iOS text selection on long-tap.
484 document.body.style.WebkitUserSelect = 'none';
485 touchTimer.start(enterTouchDelay, () => {
486 document.body.style.WebkitUserSelect = prevUserSelect.current;
487 handleMouseOver(event);
488 });
489 };
490 const handleTouchEnd = event => {
491 if (children.props.onTouchEnd) {
492 children.props.onTouchEnd(event);
493 }
494 stopTouchInteraction();
495 leaveTimer.start(leaveTouchDelay, () => {
496 handleClose(event);
497 });
498 };
499 React.useEffect(() => {
500 if (!open) {
501 return undefined;
502 }
503
504 /**
505 * @param {KeyboardEvent} nativeEvent
506 */
507 function handleKeyDown(nativeEvent) {
508 if (nativeEvent.key === 'Escape') {
509 handleClose(nativeEvent);
510 }
511 }
512 document.addEventListener('keydown', handleKeyDown);
513 return () => {
514 document.removeEventListener('keydown', handleKeyDown);
515 };
516 }, [handleClose, open]);
517 const handleRef = useForkRef(getReactElementRef(children), setChildNode, ref);
518
519 // There is no point in displaying an empty tooltip.
520 // So we exclude all falsy values, except 0, which is valid.
521 if (!title && title !== 0) {
522 open = false;
523 }
524 const popperRef = React.useRef();
525 const handleMouseMove = event => {
526 const childrenProps = children.props;
527 if (childrenProps.onMouseMove) {
528 childrenProps.onMouseMove(event);
529 }
530 cursorPosition = {
531 x: event.clientX,
532 y: event.clientY
533 };
534 if (popperRef.current) {
535 popperRef.current.update();
536 }
537 };
538 const nameOrDescProps = {};
539 const titleIsString = typeof title === 'string';
540 if (describeChild) {
541 nameOrDescProps.title = !open && titleIsString && !disableHoverListener ? title : null;
542 nameOrDescProps['aria-describedby'] = open ? id : null;
543 } else {
544 nameOrDescProps['aria-label'] = titleIsString ? title : null;
545 nameOrDescProps['aria-labelledby'] = open && !titleIsString ? id : null;
546 }
547 const childrenProps = {
548 ...nameOrDescProps,
549 ...other,
550 ...children.props,
551 className: clsx(other.className, children.props.className),
552 onTouchStart: detectTouchStart,
553 ref: handleRef,
554 ...(followCursor ? {
555 onMouseMove: handleMouseMove
556 } : {})
557 };
558 if (process.env.NODE_ENV !== 'production') {
559 childrenProps['data-mui-internal-clone-element'] = true;
560
561 // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
562 // eslint-disable-next-line react-hooks/rules-of-hooks -- process.env never changes
563 React.useEffect(() => {
564 if (childNode && !childNode.getAttribute('data-mui-internal-clone-element')) {
565 console.error(['MUI: The `children` component of the Tooltip is not forwarding its props correctly.', 'Please make sure that props are spread on the same element that the ref is applied to.'].join('\n'));
566 }
567 }, [childNode]);
568 }
569 const interactiveWrapperListeners = {};
570 if (!disableTouchListener) {
571 childrenProps.onTouchStart = handleTouchStart;
572 childrenProps.onTouchEnd = handleTouchEnd;
573 }
574 if (!disableHoverListener) {
575 childrenProps.onMouseOver = composeEventHandler(handleMouseOver, childrenProps.onMouseOver);
576 childrenProps.onMouseLeave = composeEventHandler(handleMouseLeave, childrenProps.onMouseLeave);
577 if (!disableInteractive) {
578 interactiveWrapperListeners.onMouseOver = handleMouseOver;
579 interactiveWrapperListeners.onMouseLeave = handleMouseLeave;
580 }
581 }
582 if (!disableFocusListener) {
583 childrenProps.onFocus = composeEventHandler(handleFocus, childrenProps.onFocus);
584 childrenProps.onBlur = composeEventHandler(handleBlur, childrenProps.onBlur);
585 if (!disableInteractive) {
586 interactiveWrapperListeners.onFocus = handleFocus;
587 interactiveWrapperListeners.onBlur = handleBlur;
588 }
589 }
590 if (process.env.NODE_ENV !== 'production') {
591 if (children.props.title) {
592 console.error(['MUI: You have provided a `title` prop to the child of <Tooltip />.', `Remove this title prop \`${children.props.title}\` or the Tooltip component.`].join('\n'));
593 }
594 }
595 const popperOptions = React.useMemo(() => {
596 let tooltipModifiers = [{
597 name: 'arrow',
598 enabled: Boolean(arrowRef),
599 options: {
600 element: arrowRef,
601 padding: 4
602 }
603 }];
604 if (PopperProps.popperOptions?.modifiers) {
605 tooltipModifiers = tooltipModifiers.concat(PopperProps.popperOptions.modifiers);
606 }
607 return {
608 ...PopperProps.popperOptions,
609 modifiers: tooltipModifiers
610 };
611 }, [arrowRef, PopperProps]);
612 const ownerState = {
613 ...props,
614 isRtl,
615 arrow,
616 disableInteractive,
617 placement,
618 PopperComponentProp,
619 touch: ignoreNonTouchEvents.current
620 };
621 const classes = useUtilityClasses(ownerState);
622 const PopperComponent = slots.popper ?? components.Popper ?? TooltipPopper;
623 const TransitionComponent = slots.transition ?? components.Transition ?? TransitionComponentProp ?? Grow;
624 const TooltipComponent = slots.tooltip ?? components.Tooltip ?? TooltipTooltip;
625 const ArrowComponent = slots.arrow ?? components.Arrow ?? TooltipArrow;
626 const popperProps = appendOwnerState(PopperComponent, {
627 ...PopperProps,
628 ...(slotProps.popper ?? componentsProps.popper),
629 className: clsx(classes.popper, PopperProps?.className, (slotProps.popper ?? componentsProps.popper)?.className)
630 }, ownerState);
631 const transitionProps = appendOwnerState(TransitionComponent, {
632 ...TransitionProps,
633 ...(slotProps.transition ?? componentsProps.transition)
634 }, ownerState);
635 const tooltipProps = appendOwnerState(TooltipComponent, {
636 ...(slotProps.tooltip ?? componentsProps.tooltip),
637 className: clsx(classes.tooltip, (slotProps.tooltip ?? componentsProps.tooltip)?.className)
638 }, ownerState);
639 const tooltipArrowProps = appendOwnerState(ArrowComponent, {
640 ...(slotProps.arrow ?? componentsProps.arrow),
641 className: clsx(classes.arrow, (slotProps.arrow ?? componentsProps.arrow)?.className)
642 }, ownerState);
643 return /*#__PURE__*/_jsxs(React.Fragment, {
644 children: [/*#__PURE__*/React.cloneElement(children, childrenProps), /*#__PURE__*/_jsx(PopperComponent, {
645 as: PopperComponentProp ?? Popper,
646 placement: placement,
647 anchorEl: followCursor ? {
648 getBoundingClientRect: () => ({
649 top: cursorPosition.y,
650 left: cursorPosition.x,
651 right: cursorPosition.x,
652 bottom: cursorPosition.y,
653 width: 0,
654 height: 0
655 })
656 } : childNode,
657 popperRef: popperRef,
658 open: childNode ? open : false,
659 id: id,
660 transition: true,
661 ...interactiveWrapperListeners,
662 ...popperProps,
663 popperOptions: popperOptions,
664 children: ({
665 TransitionProps: TransitionPropsInner
666 }) => /*#__PURE__*/_jsx(TransitionComponent, {
667 timeout: theme.transitions.duration.shorter,
668 ...TransitionPropsInner,
669 ...transitionProps,
670 children: /*#__PURE__*/_jsxs(TooltipComponent, {
671 ...tooltipProps,
672 children: [title, arrow ? /*#__PURE__*/_jsx(ArrowComponent, {
673 ...tooltipArrowProps,
674 ref: setArrowRef
675 }) : null]
676 })
677 })
678 })]
679 });
680});
681process.env.NODE_ENV !== "production" ? Tooltip.propTypes /* remove-proptypes */ = {
682 // ┌────────────────────────────── Warning ──────────────────────────────┐
683 // │ These PropTypes are generated from the TypeScript type definitions. │
684 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
685 // └─────────────────────────────────────────────────────────────────────┘
686 /**
687 * If `true`, adds an arrow to the tooltip.
688 * @default false
689 */
690 arrow: PropTypes.bool,
691 /**
692 * Tooltip reference element.
693 */
694 children: elementAcceptingRef.isRequired,
695 /**
696 * Override or extend the styles applied to the component.
697 */
698 classes: PropTypes.object,
699 /**
700 * @ignore
701 */
702 className: PropTypes.string,
703 /**
704 * The components used for each slot inside.
705 *
706 * @deprecated use the `slots` prop instead. This prop will be removed in v7. [How to migrate](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/).
707 *
708 * @default {}
709 */
710 components: PropTypes.shape({
711 Arrow: PropTypes.elementType,
712 Popper: PropTypes.elementType,
713 Tooltip: PropTypes.elementType,
714 Transition: PropTypes.elementType
715 }),
716 /**
717 * The extra props for the slot components.
718 * You can override the existing props or add new ones.
719 *
720 * @deprecated use the `slotProps` prop instead. This prop will be removed in v7. [How to migrate](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/).
721 *
722 * @default {}
723 */
724 componentsProps: PropTypes.shape({
725 arrow: PropTypes.object,
726 popper: PropTypes.object,
727 tooltip: PropTypes.object,
728 transition: PropTypes.object
729 }),
730 /**
731 * Set to `true` if the `title` acts as an accessible description.
732 * By default the `title` acts as an accessible label for the child.
733 * @default false
734 */
735 describeChild: PropTypes.bool,
736 /**
737 * Do not respond to focus-visible events.
738 * @default false
739 */
740 disableFocusListener: PropTypes.bool,
741 /**
742 * Do not respond to hover events.
743 * @default false
744 */
745 disableHoverListener: PropTypes.bool,
746 /**
747 * Makes a tooltip not interactive, i.e. it will close when the user
748 * hovers over the tooltip before the `leaveDelay` is expired.
749 * @default false
750 */
751 disableInteractive: PropTypes.bool,
752 /**
753 * Do not respond to long press touch events.
754 * @default false
755 */
756 disableTouchListener: PropTypes.bool,
757 /**
758 * The number of milliseconds to wait before showing the tooltip.
759 * This prop won't impact the enter touch delay (`enterTouchDelay`).
760 * @default 100
761 */
762 enterDelay: PropTypes.number,
763 /**
764 * The number of milliseconds to wait before showing the tooltip when one was already recently opened.
765 * @default 0
766 */
767 enterNextDelay: PropTypes.number,
768 /**
769 * The number of milliseconds a user must touch the element before showing the tooltip.
770 * @default 700
771 */
772 enterTouchDelay: PropTypes.number,
773 /**
774 * If `true`, the tooltip follow the cursor over the wrapped element.
775 * @default false
776 */
777 followCursor: PropTypes.bool,
778 /**
779 * This prop is used to help implement the accessibility logic.
780 * If you don't provide this prop. It falls back to a randomly generated id.
781 */
782 id: PropTypes.string,
783 /**
784 * The number of milliseconds to wait before hiding the tooltip.
785 * This prop won't impact the leave touch delay (`leaveTouchDelay`).
786 * @default 0
787 */
788 leaveDelay: PropTypes.number,
789 /**
790 * The number of milliseconds after the user stops touching an element before hiding the tooltip.
791 * @default 1500
792 */
793 leaveTouchDelay: PropTypes.number,
794 /**
795 * Callback fired when the component requests to be closed.
796 *
797 * @param {React.SyntheticEvent} event The event source of the callback.
798 */
799 onClose: PropTypes.func,
800 /**
801 * Callback fired when the component requests to be open.
802 *
803 * @param {React.SyntheticEvent} event The event source of the callback.
804 */
805 onOpen: PropTypes.func,
806 /**
807 * If `true`, the component is shown.
808 */
809 open: PropTypes.bool,
810 /**
811 * Tooltip placement.
812 * @default 'bottom'
813 */
814 placement: PropTypes.oneOf(['bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
815 /**
816 * The component used for the popper.
817 * @default Popper
818 */
819 PopperComponent: PropTypes.elementType,
820 /**
821 * Props applied to the [`Popper`](https://mui.com/material-ui/api/popper/) element.
822 * @default {}
823 */
824 PopperProps: PropTypes.object,
825 /**
826 * The extra props for the slot components.
827 * You can override the existing props or add new ones.
828 *
829 * This prop is an alias for the `componentsProps` prop, which will be deprecated in the future.
830 *
831 * @default {}
832 */
833 slotProps: PropTypes.shape({
834 arrow: PropTypes.object,
835 popper: PropTypes.object,
836 tooltip: PropTypes.object,
837 transition: PropTypes.object
838 }),
839 /**
840 * The components used for each slot inside.
841 *
842 * This prop is an alias for the `components` prop, which will be deprecated in the future.
843 *
844 * @default {}
845 */
846 slots: PropTypes.shape({
847 arrow: PropTypes.elementType,
848 popper: PropTypes.elementType,
849 tooltip: PropTypes.elementType,
850 transition: PropTypes.elementType
851 }),
852 /**
853 * The system prop that allows defining system overrides as well as additional CSS styles.
854 */
855 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
856 /**
857 * Tooltip title. Zero-length titles string, undefined, null and false are never displayed.
858 */
859 title: PropTypes.node,
860 /**
861 * The component used for the transition.
862 * [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
863 * @default Grow
864 */
865 TransitionComponent: PropTypes.elementType,
866 /**
867 * Props applied to the transition element.
868 * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
869 */
870 TransitionProps: PropTypes.object
871} : void 0;
872export default Tooltip;
\No newline at end of file