@centreon/ui 24.5.5 → 24.5.6

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.5.5",
3
+ "version": "24.5.6",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -6,12 +6,11 @@ import { equals, isNil, prop } from 'ramda';
6
6
 
7
7
  import { getTime } from '../../../../common/timeSeries';
8
8
  import { TimeValue } from '../../../../common/timeSeries/models';
9
- import { getFillColor } from '../../../common';
10
- import { CurveType } from '../models';
9
+ import { getCurveFactory, getFillColor } from '../../../common';
11
10
 
12
11
  interface Props {
13
12
  areaColor: string;
14
- curve: CurveType;
13
+ curve: 'linear' | 'step' | 'natural';
15
14
  filled: boolean;
16
15
  graphHeight: number;
17
16
  highlight?: boolean;
@@ -40,8 +39,9 @@ const RegularLine = ({
40
39
  graphHeight,
41
40
  curve
42
41
  }: Props): JSX.Element => {
42
+ const curveType = getCurveFactory(curve);
43
43
  const props = {
44
- curve,
44
+ curve: curveType,
45
45
  data: timeSeries,
46
46
  defined: (value): boolean => !isNil(value[metric_id]),
47
47
  opacity: 1,
@@ -74,14 +74,16 @@ export default memo(RegularLine, (prevProps, nextProps) => {
74
74
  graphHeight: prevGraphHeight,
75
75
  highlight: prevHighlight,
76
76
  xScale: prevXScale,
77
- yScale: prevYScale
77
+ yScale: prevYScale,
78
+ curve: prevCurve
78
79
  } = prevProps;
79
80
  const {
80
81
  timeSeries: nextTimeSeries,
81
82
  graphHeight: nextGraphHeight,
82
83
  highlight: nextHighlight,
83
84
  xScale: nextXScale,
84
- yScale: nextYScale
85
+ yScale: nextYScale,
86
+ curve: nextCurve
85
87
  } = nextProps;
86
88
 
87
89
  const prevXScaleRange = prevXScale.range();
@@ -94,6 +96,7 @@ export default memo(RegularLine, (prevProps, nextProps) => {
94
96
  equals(prevGraphHeight, nextGraphHeight) &&
95
97
  equals(prevHighlight, nextHighlight) &&
96
98
  equals(prevXScaleRange, nextXScaleRange) &&
97
- equals(prevYScaleDomain, nextYScaleDomain)
99
+ equals(prevYScaleDomain, nextYScaleDomain) &&
100
+ equals(prevCurve, nextCurve)
98
101
  );
99
102
  });
@@ -4,13 +4,12 @@ import { all, isNil, map, not, nth, path, pipe, prop } from 'ramda';
4
4
 
5
5
  import StackedAnchorPoint from '../../../InteractiveComponents/AnchorPoint/StackedAnchorPoint';
6
6
  import { StackValue } from '../../../InteractiveComponents/AnchorPoint/models';
7
- import { getFillColor } from '../../../common';
7
+ import { getCurveFactory, getFillColor } from '../../../common';
8
8
  import { getTime } from '../../../../common/timeSeries';
9
9
  import { Line, TimeValue } from '../../../../common/timeSeries/models';
10
- import { CurveType } from '../models';
11
10
 
12
11
  interface Props {
13
- curve: CurveType;
12
+ curve: 'linear' | 'step' | 'natural';
14
13
  displayAnchor: boolean;
15
14
  lines: Array<Line>;
16
15
  timeSeries: Array<TimeValue>;
@@ -26,9 +25,11 @@ const StackLines = ({
26
25
  displayAnchor,
27
26
  curve
28
27
  }: Props): JSX.Element => {
28
+ const curveType = getCurveFactory(curve);
29
+
29
30
  return (
30
31
  <Shape.AreaStack
31
- curve={curve}
32
+ curve={curveType}
32
33
  data={timeSeries}
33
34
  defined={(d): boolean => {
34
35
  return pipe(
@@ -1,10 +1,9 @@
1
1
  import { Threshold } from '@visx/threshold';
2
2
 
3
3
  import { TimeValue } from '../../../../common/timeSeries/models';
4
- import { CurveType } from '../models';
5
4
 
6
5
  interface Props {
7
- curve: CurveType;
6
+ curve: 'linear' | 'natural' | 'step';
8
7
  fillAboveArea: string;
9
8
  fillBelowArea: string;
10
9
  fillOpacity?: number;
@@ -5,14 +5,13 @@ import { useTheme } from '@mui/material/styles';
5
5
 
6
6
  import { adjustGraphData } from '../../../helpers/index';
7
7
  import { PatternOrientation } from '../../../models';
8
- import { CurveType } from '../models';
9
8
  import { LineChartData } from '../../../../common/models';
10
9
 
11
10
  import BasicThreshold from './BasicThreshold';
12
11
  import useScaleThreshold from './useScaleThreshold';
13
12
 
14
13
  interface Props {
15
- curve: CurveType;
14
+ curve: 'linear' | 'natural' | 'step';
16
15
  data: LineChartData;
17
16
  graphHeight: number;
18
17
  id: string;
@@ -4,12 +4,11 @@ import { LinePath } from '@visx/shape';
4
4
  import { useTheme } from '@mui/material/styles';
5
5
 
6
6
  import { TimeValue } from '../../../../common/timeSeries/models';
7
- import { CurveType } from '../models';
8
7
 
9
8
  import BasicThreshold from './BasicThreshold';
10
9
 
11
10
  interface Props {
12
- curve: CurveType;
11
+ curve: 'linear' | 'natural' | 'step';
13
12
  getX: (timeValue: TimeValue) => number;
14
13
  getY0Variation: (timeValue: TimeValue) => number;
15
14
  getY1Variation: (timeValue: TimeValue) => number;
@@ -7,7 +7,6 @@ import {
7
7
  VariationThreshold
8
8
  } from '../../../models';
9
9
  import { TimeValue } from '../../../../common/timeSeries/models';
10
- import { CurveType } from '../models';
11
10
 
12
11
  import BasicThreshold from './BasicThreshold';
13
12
  import Circle from './Circle';
@@ -17,7 +16,7 @@ import { WrapperThresholdLinesModel } from './models';
17
16
  import useScaleThreshold from './useScaleThreshold';
18
17
 
19
18
  interface Props extends WrapperThresholdLinesModel {
20
- curve: CurveType;
19
+ curve: 'linear' | 'natural' | 'step';
21
20
  graphHeight: number;
22
21
  timeSeries: Array<TimeValue>;
23
22
  }
@@ -23,10 +23,9 @@ import {
23
23
  canDisplayThreshold,
24
24
  requiredNumberLinesThreshold
25
25
  } from './Threshold/models';
26
- import { CurveType } from './models';
27
26
 
28
27
  interface Props extends GlobalAreaLines {
29
- curve: CurveType;
28
+ curve: 'linear' | 'step' | 'natural';
30
29
  displayAnchor?: DisplayAnchor;
31
30
  displayedLines: Array<Line>;
32
31
  graphSvgRef: MutableRefObject<SVGSVGElement | null>;
@@ -1,5 +1,4 @@
1
1
  import { ScaleLinear } from 'd3-scale';
2
- import { curveBasis } from '@visx/curve';
3
2
 
4
3
  import { Line, TimeValue } from '../../../common/timeSeries/models';
5
4
  import { LineChartData } from '../../../common/models';
@@ -41,5 +40,3 @@ export interface Shape {
41
40
  areaStackedLines: AreaStackedLines;
42
41
  areaThreshold: AreaThreshold;
43
42
  }
44
-
45
- export type CurveType = typeof curveBasis;
@@ -30,7 +30,6 @@ import {
30
30
  LegendModel
31
31
  } from './models';
32
32
  import { useIntersection } from './useLineChartIntersection';
33
- import { CurveType } from './BasicComponents/Lines/models';
34
33
  import Thresholds from './BasicComponents/Thresholds';
35
34
  import { legendWidth } from './Legend/Legend.styles';
36
35
  import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphValueTooltip';
@@ -38,7 +37,7 @@ import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphVa
38
37
  const extraMargin = 10;
39
38
 
40
39
  interface Props extends LineChartProps {
41
- curve: CurveType;
40
+ curve: 'linear' | 'step' | 'natural';
42
41
  graphData: Data;
43
42
  graphInterval: GraphInterval;
44
43
  graphRef: MutableRefObject<HTMLDivElement | null>;
@@ -1,3 +1,6 @@
1
+ import * as Curve from '@visx/curve';
2
+ import { always, cond, equals } from 'ramda';
3
+
1
4
  import { alpha } from '@mui/material';
2
5
 
3
6
  const commonTickLabelProps = {
@@ -24,6 +27,16 @@ const timeFormat = 'LT';
24
27
  const dateTimeFormat = `${dateFormat} ${timeFormat}`;
25
28
  const maxLinesDisplayedLegend = 11;
26
29
 
30
+ const getCurveFactory = (
31
+ curve: 'linear' | 'step' | 'natural'
32
+ ): typeof Curve.curveLinear => {
33
+ return cond([
34
+ [equals('linear'), always(Curve.curveLinear)],
35
+ [equals('step'), always(Curve.curveStep)],
36
+ [equals('natural'), always(Curve.curveCatmullRom)]
37
+ ])(curve);
38
+ };
39
+
27
40
  export {
28
41
  commonTickLabelProps,
29
42
  margin,
@@ -31,5 +44,6 @@ export {
31
44
  dateFormat,
32
45
  timeFormat,
33
46
  dateTimeFormat,
34
- maxLinesDisplayedLegend
47
+ maxLinesDisplayedLegend,
48
+ getCurveFactory
35
49
  };
@@ -1,7 +1,6 @@
1
1
  import { useEffect, useState } from 'react';
2
2
 
3
3
  import { Meta, StoryObj } from '@storybook/react';
4
- import { Curve } from '@visx/visx';
5
4
 
6
5
  import { Button } from '@mui/material';
7
6
  import ButtonGroup from '@mui/material/ButtonGroup';
@@ -342,7 +341,7 @@ export const LineChartWithStepCurve: Story = {
342
341
  argTypes,
343
342
  args: {
344
343
  ...argumentsData,
345
- curve: Curve.curveStep
344
+ curve: 'step'
346
345
  }
347
346
  };
348
347
 
@@ -1,6 +1,5 @@
1
1
  import { MutableRefObject, useRef } from 'react';
2
2
 
3
- import { Curve } from '@visx/visx';
4
3
  import dayjs from 'dayjs';
5
4
  import 'dayjs/locale/en';
6
5
  import 'dayjs/locale/es';
@@ -17,14 +16,13 @@ import LineChart from './LineChart';
17
16
  import LoadingSkeleton from './LoadingSkeleton';
18
17
  import { GlobalAreaLines, LineChartProps, LegendModel } from './models';
19
18
  import useLineChartData from './useLineChartData';
20
- import { CurveType } from './BasicComponents/Lines/models';
21
19
 
22
20
  dayjs.extend(localizedFormat);
23
21
  dayjs.extend(utcPlugin);
24
22
  dayjs.extend(timezonePlugin);
25
23
 
26
24
  interface Props extends Partial<LineChartProps> {
27
- curve?: CurveType;
25
+ curve?: 'linear' | 'step' | 'natural';
28
26
  data?: LineChartData;
29
27
  end: string;
30
28
  legend: LegendModel;
@@ -52,7 +50,7 @@ const WrapperLineChart = ({
52
50
  annotationEvent,
53
51
  legend,
54
52
  header,
55
- curve = Curve.curveLinear,
53
+ curve = 'linear',
56
54
  thresholds,
57
55
  thresholdUnit,
58
56
  limitLegend
@@ -95,9 +95,6 @@ const useStyles = makeStyles<StylesProps>()(
95
95
  caretMore: {
96
96
  transform: 'rotate3d(0,0,1,180deg)'
97
97
  },
98
- fakeCaret: {
99
- marginLeft: theme.spacing(3)
100
- },
101
98
  root: {
102
99
  alignItems: 'center',
103
100
  backgroundColor: getBackgroundColor({
@@ -198,26 +195,23 @@ const Cell = ({
198
195
  props
199
196
  )}
200
197
  >
201
- {displaySubItemsCaret &&
202
- (hasSubItems ? (
203
- <IconButton
204
- ariaLabel={`${isSubItemsExpanded ? labelCollapse : labelExpand} ${
205
- props.row.id
206
- }`}
207
- size="small"
208
- onClick={click}
209
- >
210
- <ExpandMoreIcon
211
- className={cx(
212
- classes.caret,
213
- isSubItemsExpanded ? classes.caretMore : classes.caretLess
214
- )}
215
- fontSize="small"
216
- />
217
- </IconButton>
218
- ) : (
219
- <div className={classes.fakeCaret} />
220
- ))}
198
+ {displaySubItemsCaret && hasSubItems && (
199
+ <IconButton
200
+ ariaLabel={`${isSubItemsExpanded ? labelCollapse : labelExpand} ${
201
+ props.row.id
202
+ }`}
203
+ size="small"
204
+ onClick={click}
205
+ >
206
+ <ExpandMoreIcon
207
+ className={cx(
208
+ classes.caret,
209
+ isSubItemsExpanded ? classes.caretMore : classes.caretLess
210
+ )}
211
+ fontSize="small"
212
+ />
213
+ </IconButton>
214
+ )}
221
215
  {children}
222
216
  </TableCell>
223
217
  );
@@ -68,6 +68,7 @@ const ShareInput = ({ labels, endpoints, roles }: Props): JSX.Element => {
68
68
  data-testid="add"
69
69
  disabled={isNil(selectedContact)}
70
70
  icon={<AddCircleIcon />}
71
+ size="small"
71
72
  onClick={add}
72
73
  />
73
74
  </div>