Skip to content

Commit

Permalink
[charts] Fix TS bottle neck (mui#13137)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette authored and Arthur Balduini committed May 23, 2024
1 parent c6f52ac commit d7c5e45
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/x-charts/src/BarChart/BarElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
import { styled } from '@mui/material/styles';
import { color as d3Color } from 'd3-color';
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
import { animated } from '@react-spring/web';
import { AnimatedProps, animated } from '@react-spring/web';
import {
getIsFaded,
getIsHighlighted,
Expand Down Expand Up @@ -62,9 +62,18 @@ export const BarElementPath = styled(animated.rect, {
opacity: (ownerState.isFaded && 0.3) || 1,
}));

interface BarProps extends Omit<React.ComponentPropsWithoutRef<'path'>, 'id' | 'color'> {
interface BarProps
extends Omit<
React.SVGProps<SVGRectElement>,
'id' | 'color' | 'ref' | 'x' | 'y' | 'height' | 'width'
>,
AnimatedProps<{
x?: string | number | undefined;
y?: string | number | undefined;
height?: string | number | undefined;
width?: string | number | undefined;
}> {
highlightScope?: Partial<HighlightScope>;
onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>) => void;
ownerState: BarElementOwnerState;
}

Expand All @@ -73,7 +82,7 @@ export interface BarElementSlots {
* The component that renders the bar.
* @default BarElementPath
*/
bar?: React.JSXElementConstructor<BarProps>;
bar?: React.ElementType<BarProps>;
}

export interface BarElementSlotProps {
Expand Down Expand Up @@ -130,7 +139,7 @@ function BarElement(props: BarElementProps) {
};
const classes = useUtilityClasses(ownerState);

const Bar = slots?.bar ?? BarElementPath;
const Bar = slots?.bar ?? (BarElementPath as React.ElementType<BarProps>);

const barProps = useSlotProps({
elementType: Bar,
Expand Down

0 comments on commit d7c5e45

Please sign in to comment.