From 4421f9fa5cc61130d9d827664a6c25c4a813d361 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 26 Nov 2024 23:53:30 +0100 Subject: [PATCH] [docs][charts] Fix anchorEl API page --- .../src/Heatmap/HeatmapTooltip.tsx | 26 +++---------------- .../src/ChartsTooltip/ChartsTooltip.tsx | 26 +++---------------- .../ChartsTooltip/ChartsTooltipContainer.tsx | 26 +++---------------- 3 files changed, 12 insertions(+), 66 deletions(-) diff --git a/packages/x-charts-pro/src/Heatmap/HeatmapTooltip.tsx b/packages/x-charts-pro/src/Heatmap/HeatmapTooltip.tsx index 2ecefa914ce36..8e46baed39db9 100644 --- a/packages/x-charts-pro/src/Heatmap/HeatmapTooltip.tsx +++ b/packages/x-charts-pro/src/Heatmap/HeatmapTooltip.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; +import HTMLElementType from '@mui/utils/HTMLElementType'; import composeClasses from '@mui/utils/composeClasses'; import { ChartsTooltipPaper, @@ -134,29 +135,10 @@ HeatmapTooltip.propTypes = { * It's used to set the position of the popper. * The return value will passed as the reference object of the Popper instance. */ - anchorEl: PropTypes.oneOfType([ - (props, propName) => { - if (props[propName] == null) { - return new Error(`Prop '${propName}' is required but wasn't specified`); - } - if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { - return new Error(`Expected prop '${propName}' to be of type Element`); - } - return null; - }, + anchorEl: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([ + HTMLElementType, + PropTypes.object, PropTypes.func, - PropTypes.shape({ - contextElement: (props, propName) => { - if (props[propName] == null) { - return null; - } - if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { - return new Error(`Expected prop '${propName}' to be of type Element`); - } - return null; - }, - getBoundingClientRect: PropTypes.func.isRequired, - }), ]), /** * Override or extend the styles applied to the component. diff --git a/packages/x-charts/src/ChartsTooltip/ChartsTooltip.tsx b/packages/x-charts/src/ChartsTooltip/ChartsTooltip.tsx index 6173a3f6bd2f3..894ba438c9d25 100644 --- a/packages/x-charts/src/ChartsTooltip/ChartsTooltip.tsx +++ b/packages/x-charts/src/ChartsTooltip/ChartsTooltip.tsx @@ -1,6 +1,7 @@ 'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; +import HTMLElementType from '@mui/utils/HTMLElementType'; import { ChartsItemTooltipContent } from './ChartsItemTooltipContent'; import { ChartsAxisTooltipContent } from './ChartsAxisTooltipContent'; import { ChartsTooltipContainer, ChartsTooltipContainerProps } from './ChartsTooltipContainer'; @@ -44,29 +45,10 @@ ChartsTooltip.propTypes = { * It's used to set the position of the popper. * The return value will passed as the reference object of the Popper instance. */ - anchorEl: PropTypes.oneOfType([ - (props, propName) => { - if (props[propName] == null) { - return new Error(`Prop '${propName}' is required but wasn't specified`); - } - if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { - return new Error(`Expected prop '${propName}' to be of type Element`); - } - return null; - }, + anchorEl: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([ + HTMLElementType, + PropTypes.object, PropTypes.func, - PropTypes.shape({ - contextElement: (props, propName) => { - if (props[propName] == null) { - return null; - } - if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { - return new Error(`Expected prop '${propName}' to be of type Element`); - } - return null; - }, - getBoundingClientRect: PropTypes.func.isRequired, - }), ]), /** * Override or extend the styles applied to the component. diff --git a/packages/x-charts/src/ChartsTooltip/ChartsTooltipContainer.tsx b/packages/x-charts/src/ChartsTooltip/ChartsTooltipContainer.tsx index 140bfb8f25c77..d48312ba337fe 100644 --- a/packages/x-charts/src/ChartsTooltip/ChartsTooltipContainer.tsx +++ b/packages/x-charts/src/ChartsTooltip/ChartsTooltipContainer.tsx @@ -1,6 +1,7 @@ 'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; +import HTMLElementType from '@mui/utils/HTMLElementType'; import useLazyRef from '@mui/utils/useLazyRef'; import { styled, useThemeProps } from '@mui/material/styles'; import Popper, { PopperProps } from '@mui/material/Popper'; @@ -153,29 +154,10 @@ ChartsTooltipContainer.propTypes = { * It's used to set the position of the popper. * The return value will passed as the reference object of the Popper instance. */ - anchorEl: PropTypes.oneOfType([ - (props, propName) => { - if (props[propName] == null) { - return new Error(`Prop '${propName}' is required but wasn't specified`); - } - if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { - return new Error(`Expected prop '${propName}' to be of type Element`); - } - return null; - }, + anchorEl: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([ + HTMLElementType, + PropTypes.object, PropTypes.func, - PropTypes.shape({ - contextElement: (props, propName) => { - if (props[propName] == null) { - return null; - } - if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { - return new Error(`Expected prop '${propName}' to be of type Element`); - } - return null; - }, - getBoundingClientRect: PropTypes.func.isRequired, - }), ]), /** * Popper render function or node.