[WEB-4660] chore: replace jsx element with react node (#7567)
* chore: replace jsx element with react node * fix: review comments * fix: tooltip types update * fix: propel pacakge fix
This commit is contained in:
parent
1ef30746a2
commit
a085c0ec62
43 changed files with 102 additions and 57 deletions
|
|
@ -158,7 +158,7 @@ const CustomBarLollipop = React.memo((props: TBarProps) => {
|
|||
*/
|
||||
const createShapeVariant =
|
||||
(Component: React.ComponentType<TBarProps>, factoryProps?: Partial<TBarProps>) =>
|
||||
(shapeProps: TShapeProps, bar: TBarItem<string>, stackKeys: string[]): JSX.Element => {
|
||||
(shapeProps: TShapeProps, bar: TBarItem<string>, stackKeys: string[]): React.ReactNode => {
|
||||
const showTopBorderRadius = bar.showTopBorderRadius?.(shapeProps.dataKey, shapeProps.payload);
|
||||
const showBottomBorderRadius = bar.showBottomBorderRadius?.(shapeProps.dataKey, shapeProps.payload);
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ const createShapeVariant =
|
|||
|
||||
export const barShapeVariants: Record<
|
||||
TBarChartShapeVariant,
|
||||
(props: TShapeProps, bar: TBarItem<string>, stackKeys: string[]) => JSX.Element
|
||||
(props: TShapeProps, bar: TBarItem<string>, stackKeys: string[]) => React.ReactNode
|
||||
> = {
|
||||
bar: createShapeVariant(CustomBar), // Standard bar with rounded corners
|
||||
lollipop: createShapeVariant(CustomBarLollipop), // Line with circle at top
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ export const BarChart = React.memo(<K extends string, T extends string>(props: T
|
|||
opacity={!!activeLegend && activeLegend !== bar.key ? 0.1 : 1}
|
||||
shape={(shapeProps: any) => {
|
||||
const shapeVariant = barShapeVariants[bar.shapeVariant ?? "bar"];
|
||||
return shapeVariant(shapeProps, bar, stackKeys);
|
||||
const node = shapeVariant(shapeProps, bar, stackKeys);
|
||||
return React.isValidElement(node) ? node : <>{node}</>;
|
||||
}}
|
||||
className="[&_path]:transition-opacity [&_path]:duration-200"
|
||||
onMouseEnter={() => setActiveBar(bar.key)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue