@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,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.9.1",
3
+ "version": "24.9.3",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -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<{ reverse: boolean; svgSize: number }>()(
5
- (theme, { reverse, svgSize }) => ({
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: reverse ? 'column-reverse' : 'column',
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
- isSmall ||
115
- (equals(variant, 'donut') && equals(titlePosition, 'bottom'))) &&
116
- title &&
117
- displayTitle && (
118
- <div className={classes.title} data-testid="Title" ref={titleRef}>
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
- !isSmall &&
237
- title &&
238
- displayTitle &&
239
- !equals(titlePosition, 'bottom') && (
240
- <>
241
- <Text
242
- className={classes.title}
243
- dy={lt(svgSize, 150) ? -10 : -15}
244
- fill={theme.palette.text.primary}
245
- textAnchor="middle"
246
- >
247
- {numeral(total).format('0a').toUpperCase()}
248
- </Text>
249
- <Text
250
- className={classes.title}
251
- data-testid="Title"
252
- dy={lt(svgSize, 150) ? 10 : 15}
253
- fill={theme.palette.text.primary}
254
- textAnchor="middle"
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]);