@centreon/ui 24.4.1-MON-34407-implement-the-status-chart-widget.21 → 24.4.1-MON-24235-Filter-App-token.41

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.4.1-MON-34407-implement-the-status-chart-widget.21",
3
+ "version": "24.4.1-MON-24235-Filter-App-token.41",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -58,6 +58,11 @@ export const WithoutTitle: Story = {
58
58
  render: Template
59
59
  };
60
60
 
61
+ export const WithPencentage: Story = {
62
+ args: { data, title: 'hosts', unit: 'percentage' },
63
+ render: Template
64
+ };
65
+
61
66
  export const WithoutLegend: Story = {
62
67
  args: { data, displayLegend: false, title: 'hosts' },
63
68
 
@@ -69,11 +74,6 @@ export const withDisplayedValues: Story = {
69
74
  render: Template
70
75
  };
71
76
 
72
- export const WithPencentage: Story = {
73
- args: { data, displayValues: true, title: 'hosts', unit: 'percentage' },
74
- render: Template
75
- };
76
-
77
77
  export const WithTooltip: Story = {
78
78
  args: { TooltipContent, data, title: 'hosts' },
79
79
  render: Template
@@ -16,7 +16,7 @@ export const useBarStackStyles = makeStyles()((theme) => ({
16
16
  svgContainer: {
17
17
  alignItems: 'center',
18
18
  backgroundColor: theme.palette.background.panelGroups,
19
- borderRadius: theme.spacing(1.25),
19
+ borderRadius: theme.shape.borderRadius,
20
20
  display: 'flex',
21
21
  justifyContent: 'center'
22
22
  },
@@ -5,7 +5,6 @@ import { Group } from '@visx/group';
5
5
  import numeral from 'numeral';
6
6
  import { Text } from '@visx/text';
7
7
  import { useTranslation } from 'react-i18next';
8
- import { equals } from 'ramda';
9
8
 
10
9
  import { Typography } from '@mui/material';
11
10
 
@@ -13,7 +12,7 @@ import { Tooltip } from '../../components';
13
12
  import { LegendProps } from '../Legend/models';
14
13
  import { Legend as LegendComponent } from '../Legend';
15
14
  import { getValueByUnit } from '../common/utils';
16
- import { labelNoDataFound as defaultlabelNoDataFound } from '../translatedLabels';
15
+ import { labelNoDataFound } from '../translatedLabels';
17
16
 
18
17
  import { BarStackProps } from './models';
19
18
  import { useBarStackStyles } from './BarStack.styles';
@@ -36,8 +35,7 @@ const BarStack = ({
36
35
  unit = 'number',
37
36
  displayValues,
38
37
  variant = 'vertical',
39
- legendDirection = 'column',
40
- labelNoDataFound = defaultlabelNoDataFound
38
+ legendDirection = 'column'
41
39
  }: BarStackProps & { height: number; width: number }): JSX.Element => {
42
40
  const { t } = useTranslation();
43
41
  const { classes } = useBarStackStyles();
@@ -92,7 +90,7 @@ const BarStack = ({
92
90
  >
93
91
  {title && (
94
92
  <div className={classes.title} data-testid="Title" ref={titleRef}>
95
- {`${numeral(total).format('0a').toUpperCase()} `} {t(title)}
93
+ {`${numeral(total).format('0a').toUpperCase()} `} {title}
96
94
  </div>
97
95
  )}
98
96
  <div
@@ -119,20 +117,6 @@ const BarStack = ({
119
117
  {(barStacks) =>
120
118
  barStacks.map((barStack) =>
121
119
  barStack.bars.map((bar) => {
122
- const shouldDisplayValues = (): boolean => {
123
- if (bar.height < 10) {
124
- return false;
125
- }
126
-
127
- return (
128
- (equals(unit, 'number') && bar.width > 10) ||
129
- (equals(unit, 'percentage') && bar.width > 25)
130
- );
131
- };
132
-
133
- const TextX = bar.x + bar.width / 2;
134
- const TextY = bar.y + bar.height / 2;
135
-
136
120
  const onClick = (): void => {
137
121
  onSingleBarClick?.(bar);
138
122
  };
@@ -160,38 +144,40 @@ const BarStack = ({
160
144
  isVerticalBar ? 'right-start' : 'bottom-start'
161
145
  }
162
146
  >
163
- <g data-testid={bar.key} onClick={onClick}>
147
+ <g data-testid={bar.key}>
164
148
  <rect
165
- cursor="pointer"
166
149
  fill={bar.color}
167
150
  height={
168
151
  isVerticalBar ? bar.height - 1 : bar.height
169
152
  }
170
153
  key={`bar-stack-${barStack.index}-${bar.index}`}
171
- ry={10}
154
+ ry={5}
172
155
  width={isVerticalBar ? bar.width : bar.width - 1}
173
156
  x={bar.x}
174
157
  y={bar.y}
158
+ onClick={onClick}
175
159
  />
176
- {displayValues && shouldDisplayValues() && (
177
- <Text
178
- cursor="pointer"
179
- data-testid="value"
180
- fill="#000"
181
- fontSize={12}
182
- fontWeight={600}
183
- textAnchor="middle"
184
- verticalAnchor="middle"
185
- x={TextX}
186
- y={TextY}
187
- >
188
- {getValueByUnit({
189
- total,
190
- unit,
191
- value: barStack.bars[0].bar.data[barStack.key]
192
- })}
193
- </Text>
194
- )}
160
+ {displayValues &&
161
+ bar.height > 10 &&
162
+ bar.width > 10 && (
163
+ <Text
164
+ cursor="pointer"
165
+ data-testid="value"
166
+ fill="#000"
167
+ fontSize={12}
168
+ textAnchor="middle"
169
+ verticalAnchor="middle"
170
+ x={bar.x + bar.width / 2}
171
+ y={bar.y + bar.height / 2}
172
+ >
173
+ {getValueByUnit({
174
+ total,
175
+ unit,
176
+ value:
177
+ barStack.bars[0].bar.data[barStack.key]
178
+ })}
179
+ </Text>
180
+ )}
195
181
  </g>
196
182
  </Tooltip>
197
183
  );
@@ -10,7 +10,6 @@ export type BarStackProps = {
10
10
  data: Array<BarType>;
11
11
  displayLegend?: boolean;
12
12
  displayValues?: boolean;
13
- labelNoDataFound?: string;
14
13
  legendDirection?: 'row' | 'column';
15
14
  onSingleBarClick?: (barData) => void;
16
15
  size?: number;
@@ -72,7 +72,8 @@ const useResponsiveBarStack = ({
72
72
 
73
73
  const yScale = isVerticalBar
74
74
  ? scaleLinear({
75
- domain: [0, total]
75
+ domain: [0, total],
76
+ nice: true
76
77
  })
77
78
  : scaleBand({
78
79
  domain: [0, 0],
@@ -85,7 +86,8 @@ const useResponsiveBarStack = ({
85
86
  padding: 0
86
87
  })
87
88
  : scaleLinear({
88
- domain: [0, total]
89
+ domain: [0, total],
90
+ nice: true
89
91
  });
90
92
 
91
93
  const keys = pluck('label', data);
@@ -13,7 +13,7 @@ import { Tooltip } from '../../components';
13
13
  import { Legend as LegendComponent } from '../Legend';
14
14
  import { LegendProps } from '../Legend/models';
15
15
  import { getValueByUnit } from '../common/utils';
16
- import { labelNoDataFound as defaultlabelNoDataFound } from '../translatedLabels';
16
+ import { labelNoDataFound } from '../translatedLabels';
17
17
 
18
18
  import { PieProps } from './models';
19
19
  import { usePieStyles } from './PieChart.styles';
@@ -54,8 +54,7 @@ const ResponsivePie = ({
54
54
  onArcClick,
55
55
  displayValues,
56
56
  TooltipContent,
57
- legendDirection = 'column',
58
- labelNoDataFound = defaultlabelNoDataFound
57
+ legendDirection = 'column'
59
58
  }: PieProps & { height: number; width: number }): JSX.Element => {
60
59
  const { t } = useTranslation();
61
60
  const theme = useTheme();
@@ -110,7 +109,7 @@ const ResponsivePie = ({
110
109
  >
111
110
  {equals(variant, 'pie') && title && (
112
111
  <div className={classes.title} data-testid="Title" ref={titleRef}>
113
- {`${numeral(total).format('0a').toUpperCase()} `} {t(title)}
112
+ {`${numeral(total).format('0a').toUpperCase()} `} {title}
114
113
  </div>
115
114
  )}
116
115
  <div
@@ -179,7 +178,6 @@ const ResponsivePie = ({
179
178
  >
180
179
  <g data-testid={arc.data.label} onClick={onClick}>
181
180
  <path
182
- cursor="pointer"
183
181
  d={pie.path(arc) as string}
184
182
  fill={arc.data.color}
185
183
  />
@@ -191,7 +189,6 @@ const ResponsivePie = ({
191
189
  dy=".33em"
192
190
  fill="#000"
193
191
  fontSize={12}
194
- fontWeight={600}
195
192
  pointerEvents="none"
196
193
  textAnchor="middle"
197
194
  x={x}
@@ -227,7 +224,7 @@ const ResponsivePie = ({
227
224
  fill={theme.palette.text.primary}
228
225
  textAnchor="middle"
229
226
  >
230
- {t(title)}
227
+ {title}
231
228
  </Text>
232
229
  </>
233
230
  )}
@@ -11,7 +11,6 @@ export interface PieProps {
11
11
  displayLegend?: boolean;
12
12
  displayValues?: boolean;
13
13
  innerRadius?: number;
14
- labelNoDataFound?: string;
15
14
  legendDirection?: 'row' | 'column';
16
15
  onArcClick?: (ardata) => void;
17
16
  title?: string;
@@ -41,11 +41,12 @@ export const useResponsivePie = ({
41
41
  const horizontalGap = widthOfLegend > 0 ? 16 : 0;
42
42
  const verticalGap = heightOfTitle > 0 ? 8 : 0;
43
43
 
44
+ const svgWrapperWidth = width - widthOfLegend - horizontalGap;
45
+
44
46
  const svgContainerSize = Math.min(
45
47
  height - heightOfTitle - verticalGap,
46
48
  width - widthOfLegend - horizontalGap
47
49
  );
48
- const svgWrapperWidth = svgContainerSize;
49
50
 
50
51
  const outerRadius = Math.min(32, svgContainerSize / 6);
51
52
 
@@ -1,4 +1,4 @@
1
- import { includes, map, prop, reject } from 'ramda';
1
+ import { includes, map, prop, reject, sortBy, toLower, compose } from 'ramda';
2
2
  import { makeStyles } from 'tss-react/mui';
3
3
 
4
4
  import { Chip, ChipProps, Tooltip } from '@mui/material';
@@ -85,9 +85,11 @@ const MultiAutocompleteField = ({
85
85
  return includes(id, valueIds);
86
86
  };
87
87
 
88
+ const sortByName = sortBy(compose(toLower, prop(optionProperty)));
89
+
88
90
  const autocompleteOptions = disableSortedOptions
89
91
  ? options
90
- : [...values, ...reject(isOptionSelected, options)];
92
+ : sortByName([...values, ...reject(isOptionSelected, options)]);
91
93
 
92
94
  return (
93
95
  <Autocomplete
@@ -222,7 +222,8 @@ const AutocompleteField = React.forwardRef(
222
222
  ...params.inputProps,
223
223
  'aria-label': label,
224
224
  'data-testid': dataTestId || label,
225
- id: getNormalizedId(label || '')
225
+ id: getNormalizedId(label || ''),
226
+ ...autocompleteProps?.inputProps
226
227
  }}
227
228
  label={label}
228
229
  placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
@@ -6,14 +6,16 @@ import {
6
6
  ClickAwayListener,
7
7
  Paper,
8
8
  Popper,
9
- PopperPlacementType,
10
- useTheme
9
+ PopperPlacementType
11
10
  } from '@mui/material';
12
11
  import { PopperProps } from '@mui/material/Popper';
13
12
 
14
13
  import { IconButton } from '..';
15
14
 
16
- const useStyles = makeStyles()(() => ({
15
+ const useStyles = makeStyles()((theme) => ({
16
+ popover: {
17
+ zIndex: theme.zIndex.tooltip
18
+ },
17
19
  popoverIconButton: {
18
20
  padding: 0,
19
21
  width: '100%'
@@ -52,7 +54,6 @@ const PopoverMenu = ({
52
54
  getPopoverData,
53
55
  popperProps
54
56
  }: Props): JSX.Element => {
55
- const theme = useTheme();
56
57
  const { classes, cx } = useStyles();
57
58
  const [anchorEl, setAnchorEl] = useState<HTMLElement | undefined>();
58
59
  const isOpen = Boolean(anchorEl);
@@ -105,9 +106,9 @@ const PopoverMenu = ({
105
106
  <Popper
106
107
  open
107
108
  anchorEl={anchorEl}
109
+ className={classes.popover}
108
110
  nonce={undefined}
109
111
  placement={popperPlacement}
110
- style={{ zIndex: theme.zIndex.tooltip }}
111
112
  onResize={(): undefined => undefined}
112
113
  onResizeCapture={(): undefined => undefined}
113
114
  {...popperProps}
@@ -1,10 +1,10 @@
1
1
  import { ForwardedRef, forwardRef, ReactElement, ReactNode } from 'react';
2
2
 
3
- import { ListItem as MuiListItem } from '@mui/material';
3
+ import { ListItemProps, ListItem as MuiListItem } from '@mui/material';
4
4
 
5
5
  import { useStyles } from './ListItem.styles';
6
6
 
7
- type ListItemProps = {
7
+ type Props = {
8
8
  action?: ReactElement;
9
9
  children: ReactNode | Array<ReactNode>;
10
10
  className?: string;
@@ -12,7 +12,7 @@ type ListItemProps = {
12
12
 
13
13
  export const ListItem = forwardRef(
14
14
  (
15
- { action, children, className, ...attr }: ListItemProps,
15
+ { action, children, className, ...attr }: Props & ListItemProps,
16
16
  ref?: ForwardedRef<HTMLLIElement>
17
17
  ) => {
18
18
  const { classes, cx } = useStyles();