11'use client' ;
22
3- import { enrichEventWithDetails , ThemingParameters } from '@ui5/webcomponents-react-base' ;
3+ import { enrichEventWithDetails , ThemingParameters , useStylesheet } from '@ui5/webcomponents-react-base' ;
44import { clsx } from 'clsx' ;
55import type { CSSProperties } from 'react' ;
66import React , { createElement , forwardRef , useCallback , useMemo } from 'react' ;
7- import { createUseStyles } from 'react-jss' ;
87import { getValueByDataKey } from 'recharts/lib/util/ChartUtils.js' ;
98import type { IChartBaseProps } from '../../interfaces/IChartBaseProps.js' ;
109import type { IChartDimension } from '../../interfaces/IChartDimension.js' ;
1110import type { IChartMeasure } from '../../interfaces/IChartMeasure.js' ;
1211import { ChartContainer } from '../../internal/ChartContainer.js' ;
1312import { defaultFormatter } from '../../internal/defaults.js' ;
1413import { BarChartPlaceholder } from '../BarChart/Placeholder.js' ;
14+ import { classNames , styleData } from './MicroBarChart.module.css.js' ;
1515
1616interface MeasureConfig extends Omit < IChartMeasure , 'color' > {
1717 /**
@@ -86,65 +86,13 @@ const resolveColor = (index: number, color = null) => {
8686 return ThemingParameters [ `sapChart_Sequence_${ ( index % 11 ) + 1 } ` ] ;
8787} ;
8888
89- const MicroBarChartStyles = {
90- container : {
91- display : 'flex' ,
92- flexDirection : 'column' ,
93- overflow : 'hidden' ,
94- fontFamily : ThemingParameters . sapFontFamily ,
95- fontWeight : 'normal' ,
96- width : '100%' ,
97- height : '100%' ,
98- justifyContent : 'space-around'
99- } ,
100- barContainer : {
101- cursor : 'auto'
102- } ,
103- barContainerActive : {
104- '&:active' : { opacity : '0.3 !important' } ,
105- cursor : 'pointer'
106- } ,
107- labelContainer : {
108- display : 'flex' ,
109- justifyContent : 'space-between'
110- } ,
111- valueContainer : {
112- display : 'flex' ,
113- backgroundColor : ThemingParameters . sapContent_Placeholderloading_Background
114- } ,
115- valueBar : { height : '100%' } ,
116- label : {
117- color : ThemingParameters . sapContent_LabelColor ,
118- display : 'block' ,
119- overflow : 'hidden' ,
120- whiteSpace : 'nowrap' ,
121- textOverflow : 'ellipsis' ,
122- fontSize : ThemingParameters . sapFontSmallSize ,
123- maxWidth : '70%'
124- } ,
125- text : {
126- paddingLeft : '6px' ,
127- display : 'inline-block' ,
128- overflow : 'hidden' ,
129- fontSize : ThemingParameters . sapFontSmallSize ,
130- boxSizing : 'border-box' ,
131-
132- whiteSpace : 'nowrap' ,
133- textOverflow : 'ellipsis' ,
134- color : ThemingParameters . sapTextColor ,
135- textAlign : 'right'
136- }
137- } ;
138-
139- const useStyles = createUseStyles ( MicroBarChartStyles , { name : 'MicroBarChart' } ) ;
140-
14189/**
14290 * The `MicroBarChart` compares different values of the same category to each other by displaying them in a compact way.
14391 */
14492const MicroBarChart = forwardRef < HTMLDivElement , MicroBarChartProps > ( ( props , ref ) => {
14593 const { loading, dataset, onDataPointClick, style, className, slot, ChartPlaceholder, ...rest } = props ;
14694
147- const classes = useStyles ( ) ;
95+ useStylesheet ( styleData , MicroBarChart . displayName ) ;
14896
14997 const dimension = useMemo < IChartDimension > (
15098 ( ) => ( {
@@ -186,7 +134,7 @@ const MicroBarChart = forwardRef<HTMLDivElement, MicroBarChartProps>((props, ref
186134 } ,
187135 [ measure . accessor , onDataPointClick ]
188136 ) ;
189- const barContainerClasses = clsx ( classes . barContainer , onDataPointClick && classes . barContainerActive ) ;
137+ const barContainerClasses = clsx ( classNames . barContainer , onDataPointClick && classNames . barContainerActive ) ;
190138 const { maxValue : _0 , dimension : _1 , measure : _2 , ...propsWithoutOmitted } = rest ;
191139 return (
192140 < ChartContainer
@@ -200,7 +148,7 @@ const MicroBarChart = forwardRef<HTMLDivElement, MicroBarChartProps>((props, ref
200148 resizeDebounce = { 250 }
201149 { ...propsWithoutOmitted }
202150 >
203- < div className = { classes . container } >
151+ < div className = { classNames . container } >
204152 { dataset ?. map ( ( item , index ) => {
205153 const dimensionValue = getValueByDataKey ( item , dimension . accessor ) ;
206154 const measureValue = getValueByDataKey ( item , measure . accessor ) ;
@@ -219,23 +167,24 @@ const MicroBarChart = forwardRef<HTMLDivElement, MicroBarChartProps>((props, ref
219167 }
220168 return (
221169 < div key = { dimensionValue } className = { barContainerClasses } onClick = { onBarClick ( item , index ) } >
222- < div className = { classes . labelContainer } >
223- < span className = { classes . label } title = { formattedDimension } >
170+ < div className = { classNames . labelContainer } >
171+ < span className = { classNames . label } title = { formattedDimension } >
224172 { formattedDimension }
225173 </ span >
226- < span className = { classes . text } title = { formattedMeasure } >
174+ < span className = { classNames . text } title = { formattedMeasure } >
227175 { measure . hideDataLabel ? '' : formattedMeasure }
228176 </ span >
229177 </ div >
230178 < div
231- className = { classes . valueContainer }
179+ className = { classNames . valueContainer }
232180 style = { {
233181 opacity : measure ?. opacity ?? 1 ,
234182 height : barHeight
235183 } }
236184 >
237185 < div
238- className = { classes . valueBar }
186+ className = { classNames . valueBar }
187+ data-component-name = "MicroBarChartValueBar"
239188 style = { {
240189 width : `${ ( measureValue / maxValue ) * 100 } %` ,
241190 backgroundColor : resolveColor ( index , measure ?. colors ?. [ index ] )
0 commit comments