@centreon/ui 24.9.1 → 24.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { lt } from 'ramda';
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
|
|
4
|
-
export const usePieStyles = makeStyles<{
|
|
5
|
-
(theme, {
|
|
4
|
+
export const usePieStyles = makeStyles<{ svgSize: number }>()(
|
|
5
|
+
(theme, { svgSize }) => ({
|
|
6
6
|
container: {
|
|
7
7
|
alignItems: 'center',
|
|
8
8
|
display: 'flex',
|
|
@@ -25,7 +25,7 @@ export const usePieStyles = makeStyles<{ reverse: boolean; svgSize: number }>()(
|
|
|
25
25
|
svgWrapper: {
|
|
26
26
|
alignItems: 'center',
|
|
27
27
|
display: 'flex',
|
|
28
|
-
flexDirection:
|
|
28
|
+
flexDirection: 'column',
|
|
29
29
|
gap: theme.spacing(1),
|
|
30
30
|
justifyContent: 'center'
|
|
31
31
|
},
|
|
@@ -42,8 +42,6 @@ const getTooltipPlacement = ({ radianX, radianY }): Placement => {
|
|
|
42
42
|
|
|
43
43
|
const ResponsivePie = ({
|
|
44
44
|
title,
|
|
45
|
-
titlePosition,
|
|
46
|
-
displayTitle = true,
|
|
47
45
|
variant = 'pie',
|
|
48
46
|
width,
|
|
49
47
|
height,
|
|
@@ -92,10 +90,7 @@ const ResponsivePie = ({
|
|
|
92
90
|
const isSmall = lt(width, 130);
|
|
93
91
|
const mustDisplayLegend = isTooSmallForLegend ? false : displayLegend;
|
|
94
92
|
|
|
95
|
-
const { classes } = usePieStyles({
|
|
96
|
-
reverse: equals(titlePosition, 'bottom'),
|
|
97
|
-
svgSize
|
|
98
|
-
});
|
|
93
|
+
const { classes } = usePieStyles({ svgSize });
|
|
99
94
|
|
|
100
95
|
return (
|
|
101
96
|
<div
|
|
@@ -110,16 +105,12 @@ const ResponsivePie = ({
|
|
|
110
105
|
minHeight: equals(variant, 'donut') && isSmall ? 'auto' : height
|
|
111
106
|
}}
|
|
112
107
|
>
|
|
113
|
-
{(equals(variant, 'pie') ||
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{`${displayTotal ? numeral(total).format('0a').toUpperCase() : ''} `}
|
|
120
|
-
{t(title)}
|
|
121
|
-
</div>
|
|
122
|
-
)}
|
|
108
|
+
{(equals(variant, 'pie') || isSmall) && title && (
|
|
109
|
+
<div className={classes.title} data-testid="Title" ref={titleRef}>
|
|
110
|
+
{`${displayTotal ? numeral(total).format('0a').toUpperCase() : ''} `}
|
|
111
|
+
{t(title)}
|
|
112
|
+
</div>
|
|
113
|
+
)}
|
|
123
114
|
<div
|
|
124
115
|
className={classes.svgContainer}
|
|
125
116
|
data-testid="pieChart"
|
|
@@ -232,31 +223,27 @@ const ResponsivePie = ({
|
|
|
232
223
|
});
|
|
233
224
|
}}
|
|
234
225
|
</Pie>
|
|
235
|
-
{equals(variant, 'donut') &&
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
{t(title)}
|
|
257
|
-
</Text>
|
|
258
|
-
</>
|
|
259
|
-
)}
|
|
226
|
+
{equals(variant, 'donut') && !isSmall && title && (
|
|
227
|
+
<>
|
|
228
|
+
<Text
|
|
229
|
+
className={classes.title}
|
|
230
|
+
dy={lt(svgSize, 150) ? -10 : -15}
|
|
231
|
+
fill={theme.palette.text.primary}
|
|
232
|
+
textAnchor="middle"
|
|
233
|
+
>
|
|
234
|
+
{numeral(total).format('0a').toUpperCase()}
|
|
235
|
+
</Text>
|
|
236
|
+
<Text
|
|
237
|
+
className={classes.title}
|
|
238
|
+
data-testid="Title"
|
|
239
|
+
dy={lt(svgSize, 150) ? 10 : 15}
|
|
240
|
+
fill={theme.palette.text.primary}
|
|
241
|
+
textAnchor="middle"
|
|
242
|
+
>
|
|
243
|
+
{t(title)}
|
|
244
|
+
</Text>
|
|
245
|
+
</>
|
|
246
|
+
)}
|
|
260
247
|
</Group>
|
|
261
248
|
</svg>
|
|
262
249
|
</div>
|
|
@@ -9,7 +9,6 @@ export interface PieProps {
|
|
|
9
9
|
TooltipContent?: (arcData) => JSX.Element | boolean | null;
|
|
10
10
|
data: Array<ArcType>;
|
|
11
11
|
displayLegend?: boolean;
|
|
12
|
-
displayTitle?: boolean;
|
|
13
12
|
displayTotal?: boolean;
|
|
14
13
|
displayValues?: boolean;
|
|
15
14
|
innerRadius?: number;
|
|
@@ -19,7 +18,6 @@ export interface PieProps {
|
|
|
19
18
|
opacity: number;
|
|
20
19
|
padAngle?: number;
|
|
21
20
|
title?: string;
|
|
22
|
-
titlePosition?: 'default' | 'bottom';
|
|
23
21
|
tooltipProps?: object;
|
|
24
22
|
unit?: 'percentage' | 'number';
|
|
25
23
|
variant?: 'pie' | 'donut';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
|
1
|
+
import { type Dispatch, type SetStateAction, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { makeStyles } from 'tss-react/mui';
|
|
4
4
|
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
ClickAwayListener,
|
|
7
7
|
Paper,
|
|
8
8
|
Popper,
|
|
9
|
-
PopperPlacementType
|
|
9
|
+
type PopperPlacementType
|
|
10
10
|
} from '@mui/material';
|
|
11
|
-
import { PopperProps } from '@mui/material/Popper';
|
|
11
|
+
import type { PopperProps } from '@mui/material/Popper';
|
|
12
12
|
|
|
13
13
|
import { IconButton } from '..';
|
|
14
14
|
|
|
@@ -80,7 +80,7 @@ const PopoverMenu = ({
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
useEffect(() => {
|
|
83
|
-
if (!canOpen) {
|
|
83
|
+
if (!canOpen && isOpen) {
|
|
84
84
|
close();
|
|
85
85
|
}
|
|
86
86
|
}, [canOpen]);
|