@centreon/ui 26.5.14 → 26.5.15

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.
Files changed (170) hide show
  1. package/package.json +6 -1
  2. package/src/ActionsList/ActionsList.styles.ts +2 -1
  3. package/src/ActionsList/index.tsx +1 -1
  4. package/src/Button/Icon/index.tsx +1 -1
  5. package/src/Button/Save/useSave.tsx +2 -1
  6. package/src/Checkbox/Checkbox.tsx +14 -9
  7. package/src/Checkbox/CheckboxGroup/index.tsx +1 -1
  8. package/src/Colors/index.tsx +12 -2
  9. package/src/Dashboard/Item.tsx +1 -1
  10. package/src/Dialog/Duplicate/index.tsx +5 -3
  11. package/src/Dialog/index.tsx +4 -1
  12. package/src/Form/Inputs/Autocomplete.tsx +30 -19
  13. package/src/Form/Inputs/ConnectedAutocomplete.tsx +27 -9
  14. package/src/Form/Inputs/FieldsTable/FieldsTable.tsx +24 -13
  15. package/src/Form/Inputs/FieldsTable/Row.tsx +7 -1
  16. package/src/Form/Inputs/List/Content.tsx +2 -2
  17. package/src/Form/Inputs/List/List.tsx +2 -1
  18. package/src/Form/Inputs/List/useList.ts +1 -1
  19. package/src/Form/Inputs/Radio.tsx +4 -1
  20. package/src/Form/Inputs/models.ts +42 -8
  21. package/src/Form/Section/PanelTabs.tsx +1 -1
  22. package/src/Form/storiesData.tsx +2 -2
  23. package/src/Graph/BarChart/Bar.tsx +39 -5
  24. package/src/Graph/BarChart/BarGroup.tsx +9 -5
  25. package/src/Graph/BarChart/BarStack.tsx +17 -4
  26. package/src/Graph/BarChart/useBarStack.ts +16 -8
  27. package/src/Graph/BarStack/Graph.tsx +21 -5
  28. package/src/Graph/BarStack/GraphAndLegend.tsx +2 -1
  29. package/src/Graph/BarStack/models.ts +23 -3
  30. package/src/Graph/BarStack/useGraphAndLegend.ts +10 -6
  31. package/src/Graph/BarStack/useResponsiveBarStack.ts +2 -1
  32. package/src/Graph/Chart/BasicComponents/Lines/Point.tsx +2 -1
  33. package/src/Graph/Chart/BasicComponents/Lines/RegularLines/index.tsx +4 -3
  34. package/src/Graph/Chart/BasicComponents/Lines/RegularLines/useRegularLines.ts +1 -1
  35. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +4 -5
  36. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +10 -1
  37. package/src/Graph/Chart/BasicComponents/Lines/Threshold/index.tsx +13 -4
  38. package/src/Graph/Chart/BasicComponents/Lines/Threshold/models.ts +2 -2
  39. package/src/Graph/Chart/BasicComponents/Lines/index.tsx +2 -10
  40. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +7 -3
  41. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/models.ts +2 -2
  42. package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +4 -4
  43. package/src/Graph/Chart/InteractiveComponents/Annotations/Annotation/Area.tsx +9 -1
  44. package/src/Graph/Chart/InteractiveComponents/Annotations/Annotation/Line.tsx +9 -1
  45. package/src/Graph/Chart/InteractiveComponents/Annotations/EventAnnotations.tsx +9 -1
  46. package/src/Graph/Chart/InteractiveComponents/Annotations/useAnnotation.ts +1 -5
  47. package/src/Graph/Chart/InteractiveComponents/Tooltip/useGraphTooltip.ts +2 -2
  48. package/src/Graph/Chart/InteractiveComponents/index.tsx +8 -8
  49. package/src/Graph/Chart/Legend/LegendHeader.tsx +6 -1
  50. package/src/Graph/Chart/Legend/index.tsx +4 -1
  51. package/src/Graph/Chart/Legend/useLegend.ts +2 -2
  52. package/src/Graph/Chart/helpers/doc.ts +11 -1
  53. package/src/Graph/Chart/models.ts +2 -2
  54. package/src/Graph/Chart/useChartData.ts +4 -3
  55. package/src/Graph/Chart/useChartIntersection.ts +5 -1
  56. package/src/Graph/Gauge/AnimatedPie.tsx +7 -2
  57. package/src/Graph/Gauge/models.ts +7 -1
  58. package/src/Graph/PieChart/ResponsivePie.tsx +7 -1
  59. package/src/Graph/PieChart/models.ts +22 -3
  60. package/src/Graph/PieChart/useResponsivePie.ts +3 -2
  61. package/src/Graph/SingleBar/ThresholdLine.tsx +5 -1
  62. package/src/Graph/SingleBar/Thresholds.tsx +5 -1
  63. package/src/Graph/Timeline/ResponsiveTimeline.tsx +2 -2
  64. package/src/Graph/Timeline/useTimeline.ts +2 -1
  65. package/src/Graph/Tree/DescendantNodes.tsx +4 -3
  66. package/src/Graph/Tree/Tree.tsx +7 -1
  67. package/src/Graph/Tree/models.ts +2 -2
  68. package/src/Graph/common/Axes/UnitLabel.tsx +1 -1
  69. package/src/Graph/common/Axes/index.tsx +15 -6
  70. package/src/Graph/common/Axes/useAxisY.ts +3 -3
  71. package/src/Graph/common/BaseChart/AdditionalLine.tsx +2 -1
  72. package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +7 -3
  73. package/src/Graph/common/Grids/index.tsx +9 -3
  74. package/src/Graph/common/Thresholds/ThresholdLine.tsx +7 -1
  75. package/src/Graph/common/Thresholds/Thresholds.tsx +7 -1
  76. package/src/Graph/common/models.ts +9 -1
  77. package/src/Graph/common/timeSeries/index.test.ts +1 -1
  78. package/src/Graph/common/timeSeries/index.ts +72 -26
  79. package/src/Graph/common/timeSeries/models.ts +1 -1
  80. package/src/Graph/common/utils.ts +3 -1
  81. package/src/Image/useLoadImage.ts +6 -1
  82. package/src/InputField/Search/RegexpHelpTooltip.tsx +3 -1
  83. package/src/InputField/Select/Autocomplete/Connected/Multi/utils/index.ts +4 -1
  84. package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +7 -2
  85. package/src/InputField/Select/Autocomplete/Connected/index.tsx +70 -26
  86. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +2 -2
  87. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +6 -4
  88. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +35 -10
  89. package/src/InputField/Select/Autocomplete/Multi/Listbox.tsx +12 -2
  90. package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +15 -8
  91. package/src/InputField/Select/Autocomplete/Popover/index.tsx +5 -2
  92. package/src/InputField/Select/Autocomplete/index.tsx +23 -10
  93. package/src/InputField/Select/IconPopover/index.tsx +8 -5
  94. package/src/InputField/Select/index.tsx +4 -3
  95. package/src/InputField/Text/index.tsx +1 -1
  96. package/src/InputField/Text/useAutoSize.ts +0 -2
  97. package/src/Listing/ActionBar/ColumnMultiSelect.tsx +2 -2
  98. package/src/Listing/ActionBar/Pagination.tsx +4 -2
  99. package/src/Listing/ActionBar/PaginationActions.tsx +12 -4
  100. package/src/Listing/ActionBar/index.tsx +19 -7
  101. package/src/Listing/Cell/DataCell.tsx +3 -3
  102. package/src/Listing/Cell/index.tsx +26 -13
  103. package/src/Listing/Header/Cell/ListingHeaderCell.tsx +2 -2
  104. package/src/Listing/Header/Cell/SelectActionListingHeaderCell.tsx +6 -4
  105. package/src/Listing/Header/ListingHeader.tsx +2 -2
  106. package/src/Listing/Header/_internals/PredefinedSelectionList.tsx +3 -1
  107. package/src/Listing/Row/Row.tsx +3 -3
  108. package/src/Listing/index.tsx +48 -28
  109. package/src/Listing/models.ts +11 -9
  110. package/src/MultiSelectEntries/index.tsx +3 -3
  111. package/src/Pagination/Pagination.tsx +3 -1
  112. package/src/Panel/index.tsx +2 -2
  113. package/src/PopoverMenu/index.tsx +3 -3
  114. package/src/RichTextEditor/ContentEditable.tsx +2 -1
  115. package/src/RichTextEditor/RichTextEditor.tsx +1 -1
  116. package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +16 -14
  117. package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +3 -3
  118. package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +1 -1
  119. package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +1 -1
  120. package/src/Snackbar/SnackbarProvider.tsx +1 -1
  121. package/src/Snackbar/index.tsx +4 -2
  122. package/src/Snackbar/useSnackbar.tsx +14 -4
  123. package/src/SortableItems/index.tsx +4 -4
  124. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx +1 -1
  125. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +1 -1
  126. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/usePickersStartEndDate.ts +9 -3
  127. package/src/TimePeriods/CustomTimePeriod/index.tsx +7 -2
  128. package/src/TimePeriods/helpers/index.ts +7 -2
  129. package/src/TimePeriods/models.ts +4 -1
  130. package/src/TimePeriods/useTimePeriod.ts +0 -2
  131. package/src/Wizard/ActionsBar.tsx +1 -1
  132. package/src/Wizard/index.test.tsx +0 -66
  133. package/src/Wizard/index.tsx +10 -5
  134. package/src/Wizard/models.ts +1 -1
  135. package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +2 -1
  136. package/src/api/buildListingEndpoint/index.ts +7 -1
  137. package/src/api/customFetch.ts +3 -3
  138. package/src/api/useBulkResponse.ts +31 -9
  139. package/src/api/useFetchQuery/index.ts +28 -6
  140. package/src/api/useGraphQuery/index.ts +1 -1
  141. package/src/api/useRequest/index.ts +7 -7
  142. package/src/components/Button/Button.tsx +1 -1
  143. package/src/components/Button/Icon/IconButton.tsx +1 -1
  144. package/src/components/CrudPage/Listing.tsx +3 -3
  145. package/src/components/CrudPage/utils.ts +1 -1
  146. package/src/components/Form/AccessRights/AccessRights.tsx +4 -1
  147. package/src/components/Form/AccessRights/Actions/Actions.tsx +4 -1
  148. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +1 -1
  149. package/src/components/Form/AccessRights/ShareInput/useShareInput.tsx +35 -13
  150. package/src/components/Form/AccessRights/common/RoleSelectField.tsx +1 -1
  151. package/src/components/Form/AccessRights/storiesData.ts +2 -2
  152. package/src/components/ItemComposition/ItemComposition.tsx +1 -1
  153. package/src/components/Menu/Button/MenuButton.tsx +1 -1
  154. package/src/components/Menu/useMenu.tsx +3 -1
  155. package/src/components/Tabs/Tabs.tsx +1 -1
  156. package/src/components/Tooltip/ConfirmationTooltip/models.ts +5 -1
  157. package/src/components/Zoom/useMinimap.ts +16 -10
  158. package/src/components/Zoom/useZoom.ts +12 -6
  159. package/src/components/Zoom/utils.ts +3 -1
  160. package/src/queryParameters/index.ts +8 -2
  161. package/src/utils/resourcesStatusURL.ts +20 -3
  162. package/src/utils/translatedLabel.ts +4 -2
  163. package/src/utils/useDebounce.ts +10 -9
  164. package/src/utils/useInfiniteScrollListing.ts +2 -2
  165. package/src/utils/useIntersectionObserver.ts +2 -2
  166. package/src/utils/useLicenseExpirationWarning.test.tsx +4 -2
  167. package/src/utils/useLoadImage.tsx +7 -2
  168. package/src/utils/useLocaleDateTimeFormat/index.test.tsx +2 -3
  169. package/src/utils/useLocaleDateTimeFormat/localeFallback.test.tsx +2 -3
  170. package/test/testRenderer.tsx +9 -5
@@ -18,8 +18,16 @@ import Annotation, {
18
18
  yMargin
19
19
  } from '.';
20
20
 
21
+ interface IconProps {
22
+ 'aria-label'?: string;
23
+ className?: string;
24
+ height?: number | string;
25
+ width?: number | string;
26
+ style?: React.CSSProperties;
27
+ }
28
+
21
29
  type Props = {
22
- Icon: (props) => JSX.Element | null;
30
+ Icon: (props: IconProps) => JSX.Element | null;
23
31
  ariaLabel: string;
24
32
  color: string;
25
33
  endDate: string;
@@ -18,8 +18,16 @@ import Annotation, {
18
18
  yMargin
19
19
  } from '.';
20
20
 
21
+ interface IconProps {
22
+ 'aria-label'?: string;
23
+ className?: string;
24
+ height?: number | string;
25
+ width?: number | string;
26
+ style?: React.CSSProperties;
27
+ }
28
+
21
29
  type Props = {
22
- Icon: (props) => JSX.Element | null;
30
+ Icon: (props: IconProps) => JSX.Element | null;
23
31
  ariaLabel: string;
24
32
  color: string;
25
33
  date: string;
@@ -5,8 +5,16 @@ import AreaAnnotation from './Annotation/Area';
5
5
  import LineAnnotation from './Annotation/Line';
6
6
  import type { TimelineEvent } from './models';
7
7
 
8
+ interface IconProps {
9
+ 'aria-label'?: string;
10
+ className?: string;
11
+ height?: number | string;
12
+ width?: number | string;
13
+ style?: React.CSSProperties;
14
+ }
15
+
8
16
  interface Props {
9
- Icon: (props) => JSX.Element | null;
17
+ Icon: (props: IconProps) => JSX.Element | null;
10
18
  annotationHoveredId: number;
11
19
  ariaLabel: string;
12
20
  color: string;
@@ -2,10 +2,7 @@ import { useAtomValue, useSetAtom } from 'jotai';
2
2
  import { useEffect } from 'react';
3
3
 
4
4
  import { margin } from '../../common';
5
- import {
6
- eventMouseLeaveAtom,
7
- mousePositionAtom
8
- } from '../interactionWithGraphAtoms';
5
+ import { mousePositionAtom } from '../interactionWithGraphAtoms';
9
6
  import type { Props } from '.';
10
7
  import {
11
8
  annotationHoveredAtom,
@@ -20,7 +17,6 @@ const useAnnotation = ({
20
17
  const [annotationHoveredId] = crypto.getRandomValues(new Uint16Array(1));
21
18
 
22
19
  const mousePosition = useAtomValue(mousePositionAtom);
23
- const _mouseLeaveEvent = useAtomValue(eventMouseLeaveAtom);
24
20
 
25
21
  const setAnnotationHovered = useSetAtom(annotationHoveredAtom);
26
22
  const changeAnnotationHovered = useSetAtom(
@@ -1,5 +1,5 @@
1
1
  import { Event, Tooltip } from '@visx/visx';
2
- import type { ScaleLinear } from 'd3-scale';
2
+ import type { ScaleLinear, ScaleTime } from 'd3-scale';
3
3
  import { useAtomValue } from 'jotai';
4
4
  import { useEffect } from 'react';
5
5
 
@@ -13,7 +13,7 @@ interface Props {
13
13
  graphWidth: number;
14
14
  timeSeries: Array<TimeValue>;
15
15
  tooltipWidth?: number;
16
- xScale: ScaleLinear<number, number>;
16
+ xScale: ScaleLinear<number, number> | ScaleTime<number, number>;
17
17
  }
18
18
 
19
19
  const useGraphTooltip = ({
@@ -71,10 +71,10 @@ interface CommonData {
71
71
  graphHeight: number;
72
72
  graphSvgRef: MutableRefObject<SVGSVGElement | null>;
73
73
  graphWidth: number;
74
- lines;
74
+ lines: Array<Line>;
75
75
  timeSeries: Array<TimeValue>;
76
76
  xScale: ScaleTime<number, number>;
77
- yScalesPerUnit: Record<string, ScaleLinear<string, string>>;
77
+ yScalesPerUnit: Record<string, ScaleLinear<number, number>>;
78
78
  }
79
79
 
80
80
  interface TimeShiftZonesData extends InteractedZone {
@@ -129,15 +129,15 @@ const InteractionWithGraph = ({
129
129
  !isNil(annotationData?.data) && !isEmpty(annotationData?.data);
130
130
  const displayTimeShiftZones = timeShiftZonesData?.enable ?? true;
131
131
 
132
- const mouseLeave = (event): void => {
133
- setEventMouseLeave(event);
132
+ const mouseLeave = (event: MouseEvent): void => {
133
+ setEventMouseLeave(event.nativeEvent);
134
134
  setEventMouseDown(null);
135
135
  updateMousePosition(null);
136
136
  setGraphTooltipData(null);
137
137
  };
138
138
 
139
- const mouseUp = (event): void => {
140
- setEventMouseUp(event);
139
+ const mouseUp = (event: MouseEvent): void => {
140
+ setEventMouseUp(event.nativeEvent);
141
141
  setEventMouseDown(null);
142
142
  };
143
143
 
@@ -164,8 +164,8 @@ const InteractionWithGraph = ({
164
164
  }
165
165
  };
166
166
 
167
- const mouseDown = (event): void => {
168
- setEventMouseDown(event);
167
+ const mouseDown = (event: MouseEvent): void => {
168
+ setEventMouseDown(event.nativeEvent);
169
169
  };
170
170
 
171
171
  const graphMarginLeft = useMemo(
@@ -12,11 +12,16 @@ import type { Line } from '../../common/timeSeries/models';
12
12
  import LegendContent from './LegendContent';
13
13
  import { LegendDisplayMode } from './models';
14
14
 
15
+ interface MinMaxAvgEntry {
16
+ label: string;
17
+ value: number | null;
18
+ }
19
+
15
20
  interface Props {
16
21
  isDisplayedOnSide: boolean;
17
22
  isListMode: boolean;
18
23
  line: Line;
19
- minMaxAvg?;
24
+ minMaxAvg?: Array<MinMaxAvgEntry>;
20
25
  unit: string;
21
26
  value?: string | null;
22
27
  }
@@ -151,7 +151,10 @@ const MainLegend = ({
151
151
  label: labelAvg,
152
152
  value: line.average_value
153
153
  }
154
- ].filter(Boolean);
154
+ ].filter(Boolean) as Array<{
155
+ label: string;
156
+ value: number | null;
157
+ }>;
155
158
 
156
159
  return (
157
160
  <li
@@ -30,7 +30,7 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
30
30
  const getLineByMetric = (metric_id: number): Line =>
31
31
  find(propEq(metric_id, 'metric_id'), lines) as Line;
32
32
 
33
- const toggleMetricLine = (metric_id): void => {
33
+ const toggleMetricLine = (metric_id: number): void => {
34
34
  const data = lines.map((line) => ({
35
35
  ...line,
36
36
  display: equals(line.metric_id, metric_id) ? !line.display : line.display
@@ -39,7 +39,7 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
39
39
  setLinesGraph(data);
40
40
  };
41
41
 
42
- const highlightLine = (metric_id): void => {
42
+ const highlightLine = (metric_id: number): void => {
43
43
  const data = lines.map((line) => ({
44
44
  ...line,
45
45
  highlight: equals(line.metric_id, metric_id)
@@ -47,7 +47,17 @@ export const lastDayForwardDate = '2023-06-07';
47
47
  export const getCustomText = (text: string): string =>
48
48
  `<span style="color:#1EA7FD;fontSize:12px">(${text})</span>`;
49
49
 
50
- export const getBodyDescription = ({ key, description, type }): string => {
50
+ interface BodyDescriptionProps {
51
+ key: string;
52
+ description: string;
53
+ type?: string;
54
+ }
55
+
56
+ export const getBodyDescription = ({
57
+ key,
58
+ description,
59
+ type
60
+ }: BodyDescriptionProps): string => {
51
61
  const body = !type
52
62
  ? `${description} <br>`
53
63
  : `${description} ${getCustomText(type)} <br>`;
@@ -1,4 +1,4 @@
1
- import type { ScaleLinear } from 'd3-scale';
1
+ import type { ScaleLinear, ScaleTime } from 'd3-scale';
2
2
  import type { ReactNode } from 'react';
3
3
 
4
4
  import type { BarStyle } from '../BarChart/models';
@@ -188,7 +188,7 @@ export interface LegendModel {
188
188
  export interface GetDate {
189
189
  positionX: number;
190
190
  timeSeries: Array<TimeValue>;
191
- xScale: ScaleLinear<number, number>;
191
+ xScale: ScaleLinear<number, number> | ScaleTime<number, number>;
192
192
  }
193
193
 
194
194
  export interface GraphTooltipData {
@@ -28,7 +28,7 @@ interface Props {
28
28
  start?: string;
29
29
  }
30
30
 
31
- const getBoolean = (value) => Boolean(Number(value));
31
+ const getBoolean = (value: unknown): boolean => Boolean(Number(value));
32
32
  const defaultDsData = {
33
33
  ds_color_line: '#000000',
34
34
  ds_filled: false,
@@ -108,8 +108,9 @@ const useGraphData = ({ data }: Props): GraphDataResult => {
108
108
  }
109
109
 
110
110
  const { timeSeries } = adjustGraphData(dataWithAdjustedMetricsColor);
111
- const baseAxis = dataWithAdjustedMetricsColor.global.base;
112
- const { title } = dataWithAdjustedMetricsColor.global;
111
+ const baseAxis =
112
+ (dataWithAdjustedMetricsColor.global.base as number) ?? 1000;
113
+ const title = (dataWithAdjustedMetricsColor.global.title as string) ?? '';
113
114
 
114
115
  const newLineData = adjustGraphData(dataWithAdjustedMetricsColor).lines;
115
116
 
@@ -4,7 +4,11 @@ interface GraphIntersectionState {
4
4
  isInViewport: boolean;
5
5
  }
6
6
 
7
- export const useIntersection = ({ element }): GraphIntersectionState => {
7
+ export const useIntersection = ({
8
+ element
9
+ }: {
10
+ element: Element | null;
11
+ }): GraphIntersectionState => {
8
12
  const [entry, setEntry] = useState<IntersectionObserverEntry | null>(null);
9
13
 
10
14
  const observer = useRef<IntersectionObserver | null>(null);
@@ -8,7 +8,11 @@ import type { Thresholds } from '../common/models';
8
8
 
9
9
  type AnimatedStyles = { endAngle: number; opacity: number; startAngle: number };
10
10
 
11
- const fromLeaveTransition = ({ endAngle }): AnimatedStyles => ({
11
+ const fromLeaveTransition = ({
12
+ endAngle
13
+ }: {
14
+ endAngle: number;
15
+ }): AnimatedStyles => ({
12
16
  endAngle,
13
17
  opacity: 0,
14
18
  startAngle: -(Math.PI / 2)
@@ -27,7 +31,8 @@ type AnimatedPieProps<Datum> = ProvidedProps<Datum> & {
27
31
  getColor: (d: PieArcDatum<Datum>) => string;
28
32
  getKey: (d: PieArcDatum<Datum>) => string;
29
33
  hideTooltip?: () => void;
30
- showTooltip?: (args) => void;
34
+ // biome-ignore lint/suspicious/noExplicitAny: visx useTooltip generic parameter
35
+ showTooltip?: (args: any) => void;
31
36
  thresholds: Thresholds;
32
37
  };
33
38
 
@@ -1,6 +1,12 @@
1
1
  import type { Thresholds } from '../common/models';
2
2
  import type { Metric } from '../common/timeSeries/models';
3
3
 
4
+ export interface ShowTooltipArgs<T = {}> {
5
+ tooltipData?: T;
6
+ tooltipLeft?: number;
7
+ tooltipTop?: number;
8
+ }
9
+
4
10
  export interface GaugeProps {
5
11
  adaptedMaxValue: number;
6
12
  baseColor?: string;
@@ -8,7 +14,7 @@ export interface GaugeProps {
8
14
  hideTooltip: () => void;
9
15
  metric: Metric;
10
16
  radius: number;
11
- showTooltip: (args) => void;
17
+ showTooltip: (args: ShowTooltipArgs) => void;
12
18
  thresholds: Thresholds;
13
19
  width: number;
14
20
  }
@@ -22,7 +22,13 @@ const DefaultLegend = ({ scale, direction }: LegendProps): JSX.Element => (
22
22
 
23
23
  type Placement = 'left' | 'right' | 'top' | 'bottom';
24
24
 
25
- const getTooltipPlacement = ({ radianX, radianY }): Placement => {
25
+ const getTooltipPlacement = ({
26
+ radianX,
27
+ radianY
28
+ }: {
29
+ radianX: number;
30
+ radianY: number;
31
+ }): Placement => {
26
32
  if (gt(Math.abs(radianX), Math.abs(radianY))) {
27
33
  return ifElse<[b: number], Placement, Placement>(
28
34
  lt(0),
@@ -1,12 +1,31 @@
1
+ import type { LegendProps as BaseLegendProps } from '../Legend/models';
2
+
1
3
  export interface ArcType {
2
4
  color: string;
3
5
  label: string;
4
6
  value: number;
5
7
  }
6
8
 
9
+ export interface PieLegendProps extends BaseLegendProps {
10
+ data: Array<ArcType>;
11
+ title?: string;
12
+ total: number;
13
+ unit?: 'percentage' | 'number';
14
+ }
15
+
16
+ export interface PieTooltipContentProps {
17
+ color: string;
18
+ label: string;
19
+ title?: string;
20
+ total: number;
21
+ value: number;
22
+ }
23
+
7
24
  export interface PieProps {
8
- Legend?: ({ scale, direction, data, title, total, unit }) => JSX.Element;
9
- TooltipContent?: (arcData) => JSX.Element | boolean | null;
25
+ Legend?: (props: PieLegendProps) => JSX.Element;
26
+ TooltipContent?: (
27
+ arcData: PieTooltipContentProps
28
+ ) => JSX.Element | boolean | null;
10
29
  data: Array<ArcType>;
11
30
  displayLegend?: boolean;
12
31
  displayTotal?: boolean;
@@ -14,7 +33,7 @@ export interface PieProps {
14
33
  innerRadius?: number;
15
34
  innerRadiusNoLimit?: boolean;
16
35
  legendDirection?: 'row' | 'column';
17
- onArcClick?: (arcData) => void;
36
+ onArcClick?: (arcData: ArcType) => void;
18
37
  opacity: number;
19
38
  padAngle?: number;
20
39
  title?: string;
@@ -1,4 +1,5 @@
1
1
  import { equals, pluck, reject } from 'ramda';
2
+ import type { RefObject } from 'react';
2
3
 
3
4
  import { getValueByUnit } from '../common/utils';
4
5
  import type { LegendScale } from '../Legend/models';
@@ -9,8 +10,8 @@ interface ResponsivePieProps {
9
10
  defaultInnerRadius: number;
10
11
  height: number;
11
12
  innerRadiusNoLimit: boolean;
12
- legendRef;
13
- titleRef;
13
+ legendRef: RefObject<HTMLElement | null>;
14
+ titleRef: RefObject<HTMLElement | null>;
14
15
  unit: 'percentage' | 'number';
15
16
  width: number;
16
17
  }
@@ -18,12 +18,16 @@ export const lineMargins = {
18
18
  small: 5
19
19
  };
20
20
 
21
+ interface ShowTooltipArgs {
22
+ tooltipData: string;
23
+ }
24
+
21
25
  interface Props extends Pick<SingleBarProps, 'direction'> {
22
26
  barHeight: number;
23
27
  hideTooltip: () => void;
24
28
  isSmall: boolean;
25
29
  label: string;
26
- showTooltip: (args) => void;
30
+ showTooltip: (args: ShowTooltipArgs) => void;
27
31
  size: 'small' | 'medium';
28
32
  thresholdType: string;
29
33
  value: number;
@@ -4,11 +4,15 @@ import { ThresholdLine } from './ThresholdLine';
4
4
 
5
5
  export const groupMargin = 25;
6
6
 
7
+ interface ShowTooltipArgs {
8
+ tooltipData: string;
9
+ }
10
+
7
11
  interface Props extends Pick<SingleBarProps, 'direction'> {
8
12
  barHeight: number;
9
13
  hideTooltip: () => void;
10
14
  isSmall: boolean;
11
- showTooltip: (args) => void;
15
+ showTooltip: (args: ShowTooltipArgs) => void;
12
16
  size: 'small' | 'medium';
13
17
  thresholds: ThresholdsModel;
14
18
  xScale: (value: number) => number;
@@ -58,7 +58,7 @@ const Timeline = ({
58
58
  const { getTimeDifference } = useTimeline();
59
59
 
60
60
  const getFormattedStart = useCallback(
61
- (start) =>
61
+ (start: string | Date) =>
62
62
  format({
63
63
  date: dayjs(start).tz(timezone).toDate(),
64
64
  formatString: dateTimeFormat
@@ -67,7 +67,7 @@ const Timeline = ({
67
67
  );
68
68
 
69
69
  const getFormattedEnd = useCallback(
70
- (end) =>
70
+ (end: string | Date) =>
71
71
  format({
72
72
  date: dayjs(end).tz(timezone).toDate(),
73
73
  formatString: dateTimeFormat
@@ -1,5 +1,6 @@
1
1
  import { usePluralizedTranslation } from '@centreon/ui';
2
2
 
3
+ import type { ScaleTime } from 'd3-scale';
3
4
  import dayjs, { type Dayjs } from 'dayjs';
4
5
  import { lt } from 'ramda';
5
6
  import { useCallback } from 'react';
@@ -19,7 +20,7 @@ interface StartEndProps {
19
20
 
20
21
  interface GetWidthProps extends StartEndProps {
21
22
  timezone: string;
22
- xScale;
23
+ xScale: ScaleTime<number, number>;
23
24
  }
24
25
 
25
26
  interface UseTimelineState {
@@ -1,6 +1,7 @@
1
1
  import { Group } from '@visx/group';
2
2
  import type { HierarchyPointNode } from '@visx/hierarchy/lib/types';
3
3
  import { gt, isNil, pluck } from 'ramda';
4
+ import type { MouseEvent as ReactMouseEvent } from 'react';
4
5
  import { useState } from 'react';
5
6
 
6
7
  import type { BaseProp, Node, TreeProps } from './models';
@@ -26,13 +27,13 @@ const DescendantNodes = <TData extends BaseProp>({
26
27
  null
27
28
  );
28
29
 
29
- const mouseDown = (e: MouseEvent): void => {
30
+ const mouseDown = (e: ReactMouseEvent): void => {
30
31
  setPressEventTimeStamp(e.timeStamp);
31
32
  };
32
33
 
33
34
  const mouseUp =
34
- (callback) =>
35
- (e: MouseEvent): void => {
35
+ (callback: () => void) =>
36
+ (e: ReactMouseEvent): void => {
36
37
  if (isNil(pressEventTimeStamp)) {
37
38
  callback();
38
39
 
@@ -28,7 +28,13 @@ export const Tree = <TData extends BaseProp>({
28
28
  );
29
29
 
30
30
  const toggleTreeNodesExpanded = useCallback(
31
- ({ currentTree, targetNode }): Node<TData> => {
31
+ ({
32
+ currentTree,
33
+ targetNode
34
+ }: {
35
+ currentTree: Node<TData>;
36
+ targetNode: Node<TData>;
37
+ }): Node<TData> => {
32
38
  return updateNodeFromTree({
33
39
  callback: (subTree) => {
34
40
  if (isNil(subTree.isExpanded) && isNil(node.isDefaultExpanded)) {
@@ -26,8 +26,8 @@ export interface ChildrenProps<TData> {
26
26
  height: number;
27
27
  width: number;
28
28
  };
29
- onMouseDown: (e) => void;
30
- onMouseUp: (callback) => (e) => void;
29
+ onMouseDown: (e: React.MouseEvent) => void;
30
+ onMouseUp: (callback: () => void) => (e: React.MouseEvent) => void;
31
31
  }
32
32
 
33
33
  export interface TreeProps<TData> {
@@ -25,7 +25,7 @@ const UnitLabel = ({
25
25
  <SelectField
26
26
  className={classes.axisInput}
27
27
  dataTestId="unit-selector"
28
- onChange={(e) => onUnitChange(e.target.value)}
28
+ onChange={(e) => onUnitChange(e.target.value as string)}
29
29
  options={units.map((unitOption) => ({
30
30
  id: unitOption,
31
31
  name: unitOption
@@ -1,7 +1,7 @@
1
1
  import { useLocaleDateTimeFormat } from '@centreon/ui';
2
2
 
3
3
  import { Axis } from '@visx/visx';
4
- import type { ScaleLinear } from 'd3-scale';
4
+ import type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';
5
5
  import { equals, head, isNil, last } from 'ramda';
6
6
 
7
7
  import { margin } from '../../Chart/common';
@@ -19,7 +19,10 @@ interface Props {
19
19
  orientation: 'horizontal' | 'vertical';
20
20
  rightScale: ScaleLinear<number, number>;
21
21
  width: number;
22
- xScale: ScaleLinear<number, number>;
22
+ xScale:
23
+ | ScaleLinear<number, number>
24
+ | ScaleTime<number, number>
25
+ | ScaleBand<number>;
23
26
  }
24
27
 
25
28
  const Axes = ({
@@ -47,16 +50,22 @@ const Axes = ({
47
50
 
48
51
  const xTickCount = Math.floor(Math.min(width / 100, 12));
49
52
 
50
- const domain = xScale.domain();
53
+ const domain = xScale.domain() as Array<number | Date>;
51
54
 
52
55
  const start = head(domain);
53
56
  const end = last(domain);
54
57
 
58
+ const toISOString = (v: number | Date | undefined): string | undefined =>
59
+ v !== undefined
60
+ ? (v instanceof Date ? v : new Date(v)).toISOString()
61
+ : undefined;
62
+
55
63
  const tickFormat =
56
- data?.axisX?.xAxisTickFormat ?? getXAxisTickFormat({ end, start });
64
+ data?.axisX?.xAxisTickFormat ??
65
+ getXAxisTickFormat({ end: toISOString(end), start: toISOString(start) });
57
66
 
58
- const formatAxisTick = (tick): string =>
59
- format({ date: new Date(tick), formatString: tickFormat });
67
+ const formatAxisTick = (tick: unknown): string =>
68
+ format({ date: new Date(tick as number | Date), formatString: tickFormat });
60
69
 
61
70
  const displayAxisRight = !isNil(secondUnit) && !isNil(rightScale);
62
71
 
@@ -61,8 +61,8 @@ const useAxisY = ({
61
61
  );
62
62
 
63
63
  const formatTick =
64
- ({ unit }) =>
65
- (value): string => {
64
+ ({ unit }: { unit: string }) =>
65
+ (value: unknown): string => {
66
66
  if (isNil(value)) {
67
67
  return '';
68
68
  }
@@ -70,7 +70,7 @@ const useAxisY = ({
70
70
  return formatMetricValueWithUnit({
71
71
  base: data.baseAxis,
72
72
  unit,
73
- value
73
+ value: value as number
74
74
  }) as string;
75
75
  };
76
76
 
@@ -1,10 +1,11 @@
1
+ import type { ScaleLinear } from 'd3-scale';
1
2
  import { useMemo } from 'react';
2
3
 
3
4
  import type { AdditionalLineProps } from '../models';
4
5
 
5
6
  interface Props extends AdditionalLineProps {
6
7
  graphWidth: number;
7
- yScale;
8
+ yScale: ScaleLinear<number, number>;
8
9
  }
9
10
 
10
11
  const AdditionalLine = ({
@@ -1,4 +1,5 @@
1
1
  import { Group } from '@visx/visx';
2
+ import type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';
2
3
  import { equals } from 'ramda';
3
4
  import type { MutableRefObject, ReactElement } from 'react';
4
5
 
@@ -19,13 +20,16 @@ interface Props {
19
20
  graphHeight: number;
20
21
  graphWidth: number;
21
22
  gridLinesType?: string;
22
- leftScale;
23
+ leftScale: ScaleLinear<number, number>;
23
24
  orientation?: 'horizontal' | 'vertical';
24
- rightScale;
25
+ rightScale: ScaleLinear<number, number>;
25
26
  showGridLines: boolean;
26
27
  svgRef: MutableRefObject<SVGSVGElement | null>;
27
28
  timeSeries: Array<TimeValue>;
28
- xScale;
29
+ xScale:
30
+ | ScaleTime<number, number>
31
+ | ScaleLinear<number, number>
32
+ | ScaleBand<number>;
29
33
  maxAxisCharacters?: number;
30
34
  hasSecondUnit?: boolean;
31
35
  title?: string;
@@ -1,5 +1,5 @@
1
1
  import { Grid } from '@visx/visx';
2
- import type { ScaleLinear } from 'd3-scale';
2
+ import type { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';
3
3
  import { includes } from 'ramda';
4
4
  import { useMemo } from 'react';
5
5
 
@@ -7,9 +7,15 @@ import type { ChartAxis } from '../../Chart/models';
7
7
 
8
8
  interface Props extends Pick<ChartAxis, 'gridLinesType'> {
9
9
  height: number;
10
- leftScale?: ScaleLinear<number, number>;
10
+ leftScale?:
11
+ | ScaleLinear<number, number>
12
+ | ScaleTime<number, number>
13
+ | ScaleBand<number>;
11
14
  width: number;
12
- xScale?: ScaleLinear<number, number>;
15
+ xScale?:
16
+ | ScaleLinear<number, number>
17
+ | ScaleTime<number, number>
18
+ | ScaleBand<number>;
13
19
  }
14
20
 
15
21
  const Grids = ({