11import { type CommonProps , Label , Loader } from '@ui5/webcomponents-react' ;
2- import { ThemingParameters } from '@ui5/webcomponents-react-base' ;
2+ import { useStylesheet } from '@ui5/webcomponents-react-base' ;
33import { clsx } from 'clsx' ;
44import type { ComponentType , CSSProperties , ReactElement , ReactNode } from 'react' ;
55import React , { Component , forwardRef } from 'react' ;
6- import { createUseStyles } from 'react-jss' ;
76import { ResponsiveContainer } from 'recharts' ;
7+ import { classNames , styleData } from './ChartContainer.module.css.js' ;
88
99export interface ContainerProps extends CommonProps {
1010 children : ReactElement ;
@@ -14,41 +14,13 @@ export interface ContainerProps extends CommonProps {
1414 resizeDebounce : number ;
1515}
1616
17- // eslint-disable-next-line no-underscore-dangle
18- const __testingProps__ : any = { } ;
19-
20- if ( process . env . NODE_ENV === 'test' ) {
21- __testingProps__ . width = 400 ;
22- __testingProps__ . height = 400 ;
23- }
24-
2517const loaderStyles : CSSProperties = {
2618 position : 'absolute' ,
2719 top : 0 ,
2820 left : 0 ,
2921 right : 0
3022} ;
3123
32- const chartContainerStyles = {
33- container : {
34- fontSize : ThemingParameters . sapFontSmallSize ,
35- color : ThemingParameters . sapTextColor ,
36- fontFamily : ThemingParameters . sapFontFamily ,
37- width : '100%' ,
38- height : '400px' ,
39- position : 'relative'
40- } ,
41- '@global' : {
42- '.has-click-handler' : {
43- '& .recharts-pie-sector, .recharts-bar-rectangles, .recharts-active-dot, .recharts-area-dot' : {
44- cursor : 'pointer'
45- }
46- }
47- }
48- } ;
49-
50- const useStyles = createUseStyles ( chartContainerStyles , { name : 'ChartContainer' } ) ;
51-
5224class ErrorBoundary extends Component < { children : ReactNode } , { errorCount : number } > {
5325 state = {
5426 errorCount : 0
@@ -70,17 +42,16 @@ class ErrorBoundary extends Component<{ children: ReactNode }, { errorCount: num
7042
7143const ChartContainer = forwardRef < HTMLDivElement , ContainerProps > ( ( props , ref ) => {
7244 const { Placeholder, loading = false , dataset, className, slot, children, resizeDebounce, ...rest } = props ;
73- const classes = useStyles ( ) ;
45+
46+ useStylesheet ( styleData , ChartContainer . displayName ) ;
7447
7548 return (
76- < div ref = { ref } className = { clsx ( classes . container , className ) } slot = { slot } { ...rest } >
49+ < div ref = { ref } className = { clsx ( classNames . container , className ) } slot = { slot } { ...rest } >
7750 { dataset ?. length > 0 ? (
7851 < >
7952 { loading && < Loader style = { loaderStyles } /> }
8053 < ErrorBoundary >
81- < ResponsiveContainer debounce = { resizeDebounce } { ...__testingProps__ } >
82- { children }
83- </ ResponsiveContainer >
54+ < ResponsiveContainer debounce = { resizeDebounce } > { children } </ ResponsiveContainer >
8455 </ ErrorBoundary >
8556 </ >
8657 ) : (
0 commit comments