@centreon/ui 26.5.14 → 26.7.0

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
@@ -1,6 +1,6 @@
1
1
  import { BarRounded } from '@visx/shape';
2
2
  import { BarGroupBar, SeriesPoint, StackKey } from '@visx/shape/lib/types';
3
- import type { ScaleLinear } from 'd3-scale';
3
+ import type { ScaleBand, ScaleLinear } from 'd3-scale';
4
4
  import { equals } from 'ramda';
5
5
  import { ReactElement } from 'react';
6
6
 
@@ -16,7 +16,7 @@ interface GetFirstBarHeightProps {
16
16
  barWidth: number;
17
17
  y: number;
18
18
  isFirstBar: boolean;
19
- yScale: ScaleLinear<number, number>;
19
+ yScale: ScaleLinear<number, number> | ScaleBand<number>;
20
20
  neutralValue: number;
21
21
  }
22
22
 
@@ -42,13 +42,23 @@ const getFirstBarHeight = ({
42
42
  }
43
43
 
44
44
  if (isHorizontal) {
45
- return Math.abs(bar.width) - (y - yScale(neutralValue));
45
+ return Math.abs(bar.width) - (y - (yScale(neutralValue) ?? 0));
46
46
  }
47
47
 
48
48
  return barWidth;
49
49
  };
50
50
 
51
- const getPadding = ({ padding, size, isNegativeValue }): number => {
51
+ interface GetPaddingProps {
52
+ padding: number;
53
+ size: number;
54
+ isNegativeValue: boolean;
55
+ }
56
+
57
+ const getPadding = ({
58
+ padding,
59
+ size,
60
+ isNegativeValue
61
+ }: GetPaddingProps): number => {
52
62
  if (!isNegativeValue) {
53
63
  return padding;
54
64
  }
@@ -56,6 +66,30 @@ const getPadding = ({ padding, size, isNegativeValue }): number => {
56
66
  return padding + size;
57
67
  };
58
68
 
69
+ interface BarProps {
70
+ barRoundedProps: Record<string, boolean>;
71
+ bar: Omit<BarGroupBar<StackKey>, 'key' | 'value'> & {
72
+ bar: SeriesPoint<unknown>;
73
+ key: StackKey;
74
+ };
75
+ isTooltipHidden: boolean;
76
+ isHorizontal: boolean;
77
+ shouldApplyRadiusOnBottom: boolean;
78
+ barPadding: number;
79
+ barWidth: number;
80
+ neutralValue: number;
81
+ isNegativeValue: boolean;
82
+ barIndex: number;
83
+ exitBar: () => void;
84
+ hoverBar: (props: {
85
+ barIndex: number;
86
+ highlightedMetric: number;
87
+ }) => () => void;
88
+ barY: number;
89
+ barStyle: BarStyle;
90
+ yScale: ScaleLinear<number, number> | ScaleBand<number>;
91
+ }
92
+
59
93
  export const Bar = ({
60
94
  barRoundedProps,
61
95
  bar,
@@ -72,7 +106,7 @@ export const Bar = ({
72
106
  barY,
73
107
  barStyle,
74
108
  yScale
75
- }): ReactElement => {
109
+ }: BarProps): ReactElement => {
76
110
  const style = getStyle({
77
111
  metricId: Number(bar.key),
78
112
  style: barStyle
@@ -2,6 +2,7 @@ import { scaleBand, scaleOrdinal } from '@visx/scale';
2
2
  import { BarGroupHorizontal, BarGroup as VisxBarGroup } from '@visx/shape';
3
3
  import type { ScaleLinear } from 'd3-scale';
4
4
  import { difference, equals, keys, omit, pick } from 'ramda';
5
+ import type { ComponentType } from 'react';
5
6
  import { memo, useMemo } from 'react';
6
7
 
7
8
  import { useDeepMemo } from '../../utils';
@@ -29,7 +30,8 @@ interface Props {
29
30
  orientation: 'horizontal' | 'vertical';
30
31
  size: number;
31
32
  timeSeries: Array<TimeValue>;
32
- xScale;
33
+ // biome-ignore lint/suspicious/noExplicitAny: visx bandwidth scale typing
34
+ xScale: any;
33
35
  yScalesPerUnit: Record<string, ScaleLinear<number, number>>;
34
36
  scaleType?: 'linear' | 'logarithmic';
35
37
  }
@@ -50,7 +52,9 @@ const BarGroup = ({
50
52
  const [firstUnit] = getUnits(lines);
51
53
 
52
54
  const BarComponent = useMemo(
53
- () => (isHorizontal ? VisxBarGroup : BarGroupHorizontal),
55
+ () =>
56
+ // biome-ignore lint/suspicious/noExplicitAny: visx BarGroup union type
57
+ (isHorizontal ? VisxBarGroup : BarGroupHorizontal) as ComponentType<any>,
54
58
  [isHorizontal]
55
59
  );
56
60
 
@@ -139,15 +143,15 @@ const BarGroup = ({
139
143
  const neutralValue = useMemo(() => getNeutralValue(scaleType), [scaleType]);
140
144
 
141
145
  return (
142
- <BarComponent<TimeValue>
143
- // @ts-expect-error - suppressing pre-existing type mismatch
146
+ <BarComponent
144
147
  color={colorScale}
145
148
  data={normalizedTimeSeries}
146
149
  height={size}
147
150
  keys={sortedLineKeys}
148
151
  {...barComponentBaseProps}
149
152
  >
150
- {(barGroups) =>
153
+ {/* biome-ignore lint/suspicious/noExplicitAny: visx BarGroup union type */}
154
+ {(barGroups: Array<any>) =>
151
155
  barGroups.map((barGroup, index) => {
152
156
  return (
153
157
  <MemoizedGroup
@@ -22,7 +22,17 @@ interface Props extends Omit<UseBarStackProps, 'xScale'> {
22
22
  isStacked?: boolean;
23
23
  }
24
24
 
25
- const getPadding = ({ padding, size, isNegativeValue }): number => {
25
+ interface GetPaddingProps {
26
+ padding: number;
27
+ size: number;
28
+ isNegativeValue: boolean;
29
+ }
30
+
31
+ const getPadding = ({
32
+ padding,
33
+ size,
34
+ isNegativeValue
35
+ }: GetPaddingProps): number => {
26
36
  if (!isNegativeValue) {
27
37
  return padding;
28
38
  }
@@ -59,9 +69,12 @@ const BarStack = ({
59
69
  keys={lineKeys}
60
70
  {...commonBarStackProps}
61
71
  >
62
- {(barStacks) => {
63
- return barStacks.map((barStack, index) =>
64
- barStack.bars.map((bar) => {
72
+ {/* biome-ignore lint/suspicious/noExplicitAny: visx BarStack union */}
73
+ {(barStacks: Array<any>) => {
74
+ // biome-ignore lint/suspicious/noExplicitAny: visx BarStack union
75
+ return barStacks.map((barStack: any, index: number) =>
76
+ // biome-ignore lint/suspicious/noExplicitAny: visx BarStack union
77
+ barStack.bars.map((bar: any) => {
65
78
  const shouldApplyRadiusOnBottom = equals(index, 0);
66
79
  const shouldApplyRadiusOnTop = equals(index, dec(barStacks.length));
67
80
  const isNegativeValue = gt(0, bar.bar[1]);
@@ -1,7 +1,9 @@
1
1
  import { scaleOrdinal } from '@visx/scale';
2
2
  import { BarStack, BarStackHorizontal } from '@visx/shape';
3
+ import type { ScaleBand, ScaleLinear, ScaleOrdinal } from 'd3-scale';
3
4
  import { useSetAtom } from 'jotai';
4
5
  import { equals, keys, omit } from 'ramda';
6
+ import type { ComponentType } from 'react';
5
7
  import { useCallback, useMemo } from 'react';
6
8
 
7
9
  import { useDeepMemo } from '../../utils';
@@ -17,14 +19,18 @@ export interface UseBarStackProps {
17
19
  isHorizontal: boolean;
18
20
  lines: Array<Line>;
19
21
  timeSeries: Array<TimeValue>;
20
- xScale;
21
- yScale;
22
+ xScale: ScaleBand<number> | ScaleLinear<number, number>;
23
+ yScale: ScaleBand<number> | ScaleLinear<number, number>;
22
24
  }
23
25
 
26
+ // biome-ignore lint/suspicious/noExplicitAny: scale union with visx
27
+ type CommonBarStackProps = Record<string, any>;
28
+
24
29
  interface UseBarStackState {
25
- BarStackComponent: typeof BarStack | typeof BarStackHorizontal;
26
- colorScale;
27
- commonBarStackProps;
30
+ // biome-ignore lint/suspicious/noExplicitAny: visx BarStack/BarStackHorizontal union
31
+ BarStackComponent: ComponentType<any>;
32
+ colorScale: ScaleOrdinal<number, string>;
33
+ commonBarStackProps: CommonBarStackProps;
28
34
  exitBar: () => void;
29
35
  hoverBar: (props: HoverBarProps) => () => void;
30
36
  lineKeys: Array<number>;
@@ -40,7 +46,9 @@ export const useBarStack = ({
40
46
  const setTooltipData = useSetAtom(tooltipDataAtom);
41
47
 
42
48
  const BarStackComponent = useMemo(
43
- () => (isHorizontal ? BarStack : BarStackHorizontal),
49
+ () =>
50
+ // biome-ignore lint/suspicious/noExplicitAny: visx BarStack/BarStackHorizontal union
51
+ (isHorizontal ? BarStack : BarStackHorizontal) as ComponentType<any>,
44
52
  [isHorizontal]
45
53
  );
46
54
 
@@ -70,13 +78,13 @@ export const useBarStack = ({
70
78
 
71
79
  const commonBarStackProps = isHorizontal
72
80
  ? {
73
- x: (d) => d.timeTick,
81
+ x: (d: TimeValue) => d.timeTick,
74
82
  xScale,
75
83
  yScale
76
84
  }
77
85
  : {
78
86
  xScale: yScale,
79
- y: (d) => d.timeTick,
87
+ y: (d: TimeValue) => d.timeTick,
80
88
  yScale: xScale
81
89
  };
82
90
 
@@ -4,13 +4,14 @@ import {
4
4
  BarStack as BarStackVertical
5
5
  } from '@visx/shape';
6
6
  import { Text } from '@visx/text';
7
+ import type { ScaleOrdinal } from 'd3-scale';
7
8
  import { equals, props } from 'ramda';
8
9
  import { memo, useMemo } from 'react';
9
10
 
10
11
  import { Tooltip } from '../../components';
11
12
  import { getValueByUnit } from '../common/utils';
12
13
  import { useGraphStyles } from './BarStack.styles';
13
- import type { BarStackProps } from './models';
14
+ import type { BarStackProps, BarType } from './models';
14
15
  import { useGraphAndLegend } from './useGraphAndLegend';
15
16
 
16
17
  interface Props
@@ -26,11 +27,21 @@ interface Props
26
27
  width: number;
27
28
  height: number;
28
29
  isVerticalBar: boolean;
29
- colorScale;
30
+ colorScale: ScaleOrdinal<string, string>;
30
31
  total: number;
31
32
  }
32
33
 
33
- const getFitsInBar = ({ isVerticalBar, bar, unit }): boolean => {
34
+ interface GetFitsInBarProps {
35
+ isVerticalBar: boolean;
36
+ bar: { width: number; height: number };
37
+ unit?: 'percentage' | 'number';
38
+ }
39
+
40
+ const getFitsInBar = ({
41
+ isVerticalBar,
42
+ bar,
43
+ unit
44
+ }: GetFitsInBarProps): boolean => {
34
45
  if (isVerticalBar) {
35
46
  return bar.height >= 18;
36
47
  }
@@ -41,16 +52,21 @@ const getFitsInBar = ({ isVerticalBar, bar, unit }): boolean => {
41
52
  );
42
53
  };
43
54
 
55
+ interface GetClickProps {
56
+ onSingleBarClick?: (barData: BarType) => void;
57
+ bar: BarType | unknown;
58
+ }
59
+
44
60
  const getClick = ({
45
61
  onSingleBarClick,
46
62
  bar
47
- }): ((e: MouseEvent) => void) | undefined => {
63
+ }: GetClickProps): ((e: MouseEvent) => void) | undefined => {
48
64
  if (onSingleBarClick) {
49
65
  return (e: MouseEvent): void => {
50
66
  if (!equals(e.button, 0)) {
51
67
  return;
52
68
  }
53
- onSingleBarClick(bar);
69
+ onSingleBarClick(bar as BarType);
54
70
  };
55
71
  }
56
72
 
@@ -1,3 +1,4 @@
1
+ import type { ScaleOrdinal } from 'd3-scale';
1
2
  import { equals, props } from 'ramda';
2
3
  import { memo, useMemo } from 'react';
3
4
 
@@ -21,7 +22,7 @@ interface Props
21
22
  displayLegend: boolean;
22
23
  height: number;
23
24
  width: number;
24
- colorScale;
25
+ colorScale: ScaleOrdinal<string, string>;
25
26
  total: number;
26
27
  }
27
28
 
@@ -1,17 +1,37 @@
1
+ import type { LegendScale } from '../Legend/models';
2
+
1
3
  export interface BarType {
2
4
  color: string;
3
5
  label: string;
4
6
  value: number;
5
7
  }
6
8
 
9
+ export interface LegendProps {
10
+ scale: LegendScale;
11
+ data: Array<BarType>;
12
+ title?: string;
13
+ total: number;
14
+ unit?: 'percentage' | 'number';
15
+ direction?: 'row' | 'column';
16
+ }
17
+
18
+ export interface TooltipContentProps {
19
+ color: string;
20
+ label: string;
21
+ total: number;
22
+ value: number;
23
+ }
24
+
7
25
  export type BarStackProps = {
8
- Legend?: ({ scale, data, title, total, unit, direction }) => JSX.Element;
9
- TooltipContent?: (barData) => JSX.Element | boolean | null;
26
+ Legend?: (props: LegendProps) => JSX.Element;
27
+ TooltipContent?: (
28
+ barData: TooltipContentProps
29
+ ) => JSX.Element | boolean | null;
10
30
  data: Array<BarType>;
11
31
  displayLegend?: boolean;
12
32
  displayValues?: boolean;
13
33
  legendDirection?: 'row' | 'column';
14
- onSingleBarClick?: (barData) => void;
34
+ onSingleBarClick?: (barData: BarType) => void;
15
35
  title?: string;
16
36
  tooltipProps?: object;
17
37
  unit?: 'percentage' | 'number';
@@ -1,4 +1,5 @@
1
1
  import { scaleBand, scaleLinear } from '@visx/scale';
2
+ import type { ScaleBand, ScaleLinear } from 'd3-scale';
2
3
  import { pluck } from 'ramda';
3
4
  import { useMemo } from 'react';
4
5
 
@@ -14,8 +15,8 @@ interface UseGraphandLegendProps {
14
15
 
15
16
  interface UseGraphAndLegendState {
16
17
  barStackData: Record<string, number>;
17
- xScale;
18
- yScale;
18
+ xScale: ScaleBand<number> | ScaleLinear<number, number>;
19
+ yScale: ScaleBand<number> | ScaleLinear<number, number>;
19
20
  keys: Array<string>;
20
21
  }
21
22
 
@@ -38,11 +39,14 @@ export const useGraphAndLegend = ({
38
39
 
39
40
  const barStackData = useMemo(
40
41
  () =>
41
- dataWithNonEmptyValue.reduce((acc, { label, value }) => {
42
- acc[label] = value;
42
+ dataWithNonEmptyValue.reduce<Record<string, number>>(
43
+ (acc, { label, value }) => {
44
+ acc[label] = value;
43
45
 
44
- return acc;
45
- }, {}),
46
+ return acc;
47
+ },
48
+ {}
49
+ ),
46
50
  [dataWithNonEmptyValue]
47
51
  );
48
52
 
@@ -1,4 +1,5 @@
1
1
  import { scaleOrdinal } from '@visx/scale';
2
+ import type { ScaleOrdinal } from 'd3-scale';
2
3
  import { equals, isNil, pluck } from 'ramda';
3
4
  import { useMemo } from 'react';
4
5
 
@@ -21,7 +22,7 @@ interface UseBarStackState {
21
22
  titleVariant: 'xs' | 'sm' | 'md';
22
23
  isVerticalBar: boolean;
23
24
  legendScale: LegendScale;
24
- colorScale;
25
+ colorScale: ScaleOrdinal<string, string>;
25
26
  formattedLegendDirection: 'column' | 'row';
26
27
  }
27
28
 
@@ -1,10 +1,11 @@
1
+ import type { ScaleTime } from 'd3-scale';
1
2
  import { isNil } from 'ramda';
2
3
 
3
4
  interface Props {
4
5
  lineColor: string;
5
6
  radius: number;
6
7
  timeTick: Date;
7
- xScale;
8
+ xScale: ScaleTime<number, number>;
8
9
  yPoint: number | null;
9
10
  }
10
11
 
@@ -53,7 +53,7 @@ const RegularLine = ({
53
53
  const props = {
54
54
  curve: curveType,
55
55
  data: timeSeries,
56
- defined: (value): boolean => !isNil(value[metric_id]),
56
+ defined: (value: TimeValue): boolean => !isNil(value[metric_id]),
57
57
  opacity: 1,
58
58
  stroke: lineColor,
59
59
  strokeDasharray: getStrokeDashArray({
@@ -66,8 +66,9 @@ const RegularLine = ({
66
66
  ? Math.ceil((formattedLineWidth || 1) * 1.3)
67
67
  : formattedLineWidth,
68
68
  unit,
69
- x: (timeValue): number => xScale(getTime(timeValue)) as number,
70
- y: (timeValue): number => yScale(prop(metric_id, timeValue)) ?? null
69
+ x: (timeValue: TimeValue): number => xScale(getTime(timeValue)) as number,
70
+ y: (timeValue: TimeValue): number =>
71
+ yScale(prop(metric_id, timeValue)) ?? null
71
72
  };
72
73
 
73
74
  if (filled) {
@@ -6,7 +6,7 @@ import type { Line } from '../../../../common/timeSeries/models';
6
6
  interface RegularLines {
7
7
  regularLines: Array<Line>;
8
8
  }
9
- const useRegularLines = ({ lines }): RegularLines => {
9
+ const useRegularLines = ({ lines }: { lines: Array<Line> }): RegularLines => {
10
10
  const stackedLines = getSortedStackedLines(lines);
11
11
 
12
12
  return { regularLines: difference(lines, stackedLines) };
@@ -60,9 +60,8 @@ const StackLines = ({
60
60
  }: Props): ReactElement => {
61
61
  const curveType = getCurveFactory(
62
62
  (equals(type(lineStyle), 'Array')
63
- ? lineStyle?.[0].curve
64
- : // @ts-expect-error - suppressing pre-existing type mismatch
65
- lineStyle?.curve) || 'linear'
63
+ ? (lineStyle as Array<LineStyle>)?.[0].curve
64
+ : (lineStyle as LineStyle)?.curve) || 'linear'
66
65
  );
67
66
  return (
68
67
  <Shape.AreaStack
@@ -72,7 +71,7 @@ const StackLines = ({
72
71
  return pipe(
73
72
  // @ts-expect-error - suppressing pre-existing type mismatch
74
73
  map(prop('metric_id')) as unknown as (
75
- displayedLines
74
+ displayedLines: Array<Line>
76
75
  ) => Array<string>,
77
76
  all((metric_id) => pipe(path(['data', metric_id]), isNil, not)(d))
78
77
  )(lines);
@@ -177,7 +176,7 @@ const StackLines = ({
177
176
  }
178
177
  // @ts-expect-error - suppressing pre-existing type mismatch
179
178
  x={(d) => xScale(getTime(d.data)) ?? 0}
180
- y={(d) => yScale(d[1]) ?? 0}
179
+ y={(d) => yScale(d[1] ?? 0) ?? 0}
181
180
  />
182
181
  </g>
183
182
  );
@@ -3,6 +3,7 @@ import {
3
3
  getNotInvertedStackedLines,
4
4
  getStackedLinesTimeSeriesPerStackAndUnit
5
5
  } from '../../../../common/timeSeries';
6
+ import type { Line, TimeValue } from '../../../../common/timeSeries/models';
6
7
  import type { LinesData } from '../models';
7
8
 
8
9
  interface StackedLinesState {
@@ -10,7 +11,15 @@ interface StackedLinesState {
10
11
  stackedLinesData: Record<string, LinesData>;
11
12
  }
12
13
 
13
- const useStackedLines = ({ lines, timeSeries }): StackedLinesState => {
14
+ interface UseStackedLinesProps {
15
+ lines: Array<Line>;
16
+ timeSeries: Array<TimeValue>;
17
+ }
18
+
19
+ const useStackedLines = ({
20
+ lines,
21
+ timeSeries
22
+ }: UseStackedLinesProps): StackedLinesState => {
14
23
  const regularStackedLines = getNotInvertedStackedLines(lines);
15
24
  const {
16
25
  stackedLinesTimeSeriesPerStackKeyAndUnit:
@@ -15,7 +15,7 @@ import ThresholdWithVariation from './ThresholdWithVariation';
15
15
  import useScaleThreshold from './useScaleThreshold';
16
16
 
17
17
  interface Props extends WrapperThresholdLinesModel {
18
- curve: 'linear' | 'natural' | 'step';
18
+ curve?: 'linear' | 'natural' | 'step';
19
19
  graphHeight: number;
20
20
  timeSeries: Array<TimeValue>;
21
21
  }
@@ -126,9 +126,18 @@ const WrapperThresholdLines = ({
126
126
  return (
127
127
  <g>
128
128
  {filteredThresholdLines.map((element) =>
129
- element?.map(({ Component, props, key }) => (
130
- <Component {...props} id={props?.id ?? key} key={key} />
131
- ))
129
+ element?.map(({ Component, props, key }) => {
130
+ const componentProps = props as { id?: string | number };
131
+
132
+ return (
133
+ <Component
134
+ // biome-ignore lint/suspicious/noExplicitAny: union of threshold component props
135
+ {...(props as any)}
136
+ id={componentProps?.id ?? key}
137
+ key={key}
138
+ />
139
+ );
140
+ })
132
141
  )}
133
142
  </g>
134
143
  );
@@ -1,4 +1,4 @@
1
- import type { ScaleLinear } from 'd3-scale';
1
+ import type { ScaleLinear, ScaleTime } from 'd3-scale';
2
2
  import { equals, reject } from 'ramda';
3
3
 
4
4
  import type { Line, TimeValue } from '../../../../common/timeSeries/models';
@@ -60,7 +60,7 @@ export interface LinesThreshold {
60
60
  export interface WrapperThresholdLinesModel {
61
61
  areaThresholdLines?: GlobalAreaLines['areaThresholdLines'];
62
62
  lines: Array<Line>;
63
- xScale: ScaleLinear<number, number>;
63
+ xScale: ScaleLinear<number, number> | ScaleTime<number, number>;
64
64
  yScalesPerUnit: Record<string, ScaleLinear<number, number>>;
65
65
  }
66
66
 
@@ -1,4 +1,4 @@
1
- import type { ScaleLinear } from 'd3-scale';
1
+ import type { ScaleLinear, ScaleTime } from 'd3-scale';
2
2
  import { isNil } from 'ramda';
3
3
  import type { MutableRefObject } from 'react';
4
4
 
@@ -36,7 +36,7 @@ interface Props extends GlobalAreaLines {
36
36
  scaleLogarithmicBase?: number;
37
37
  timeSeries: Array<TimeValue>;
38
38
  width: number;
39
- xScale: ScaleLinear<number, number>;
39
+ xScale: ScaleTime<number, number>;
40
40
  yScalesPerUnit: Record<string, ScaleLinear<number, number>>;
41
41
  lineStyle: LineStyle | Array<LineStyle>;
42
42
  hasSecondUnit?: boolean;
@@ -177,7 +177,6 @@ const Lines = ({
177
177
  )}
178
178
 
179
179
  {displayThresholdArea && (
180
- // @ts-expect-error - suppressing pre-existing type mismatch
181
180
  <WrapperThresholdLines
182
181
  areaThresholdLines={areaThresholdLines}
183
182
  graphHeight={height}
@@ -236,14 +235,11 @@ const Lines = ({
236
235
  <g key={metric_id}>
237
236
  {displayGuidingLines && (
238
237
  <RegularAnchorPoint
239
- // @ts-expect-error - suppressing pre-existing type mismatch
240
- areaColor={areaColor || lineColor}
241
238
  hasSecondUnit={hasSecondUnit}
242
239
  lineColor={lineColor}
243
240
  maxLeftAxisCharacters={maxLeftAxisCharacters}
244
241
  metric_id={metric_id}
245
242
  timeSeries={relatedTimeSeries}
246
- transparency={transparency}
247
243
  xScale={xScale}
248
244
  yScale={yScale}
249
245
  />
@@ -253,10 +249,7 @@ const Lines = ({
253
249
  <Point
254
250
  key={timeTick.toString()}
255
251
  lineColor={lineColor}
256
- // @ts-expect-error - suppressing pre-existing type mismatch
257
- metric_id={metric_id}
258
252
  radius={getPointRadius(style?.lineWidth)}
259
- timeSeries={relatedTimeSeries}
260
253
  timeTick={timeTick}
261
254
  xScale={xScale}
262
255
  yPoint={getYAnchorPoint({
@@ -265,7 +258,6 @@ const Lines = ({
265
258
  timeTick,
266
259
  yScale
267
260
  })}
268
- yScale={yScale}
269
261
  />
270
262
  ))}
271
263
  <RegularLine
@@ -20,15 +20,19 @@ interface Props {
20
20
  interface GetYAnchorPoint {
21
21
  stackValues: Array<StackValue>;
22
22
  timeTick: Date | null;
23
- yScale: ScaleTime<number, number>;
23
+ yScale: ScaleLinear<number, number> | ScaleTime<number, number>;
24
24
  }
25
25
 
26
26
  const getStackedDates = (stackValues: Array<StackValue>): Array<Date> => {
27
- const toTimeTick = (stackValue): string => stackValue?.data?.timeTick;
27
+ const toTimeTick = (stackValue: { data?: { timeTick: string } }): string =>
28
+ stackValue?.data?.timeTick as string;
28
29
 
29
30
  const toDate = (tick: string): Date => new Date(tick);
30
31
 
31
- return pipe(map(toTimeTick), map(toDate))(stackValues);
32
+ return pipe(
33
+ map(toTimeTick),
34
+ map(toDate)
35
+ )(stackValues as unknown as Array<{ data?: { timeTick: string } }>);
32
36
  };
33
37
 
34
38
  export const getYAnchorPoint = ({
@@ -16,7 +16,7 @@ export interface RegularLinesAnchorPoint extends AnchorPoint {
16
16
  }
17
17
 
18
18
  export interface StackedAnchorPoint extends AnchorPoint {
19
- stack;
19
+ stack: Array<StackValue>;
20
20
  }
21
21
 
22
22
  export interface StackData {
@@ -28,7 +28,7 @@ export interface GuidingLines {
28
28
  graphHeight: number;
29
29
  graphWidth: number;
30
30
  timeSeries: Array<TimeValue>;
31
- xScale: ScaleLinear<number, number>;
31
+ xScale: ScaleTime<number, number>;
32
32
  maxLeftAxisCharacters: number;
33
33
  hasSecondUnit?: boolean;
34
34
  leftScale?: ScaleLinear<number, number>;
@@ -1,4 +1,4 @@
1
- import type { ScaleLinear } from 'd3-scale';
1
+ import type { ScaleLinear, ScaleTime } from 'd3-scale';
2
2
  import { useAtomValue } from 'jotai';
3
3
  import { type MutableRefObject, useEffect, useState } from 'react';
4
4
 
@@ -26,7 +26,7 @@ interface Props {
26
26
  lines?: Array<Line>;
27
27
  rightScale?: ScaleLinear<number, number>;
28
28
  timeSeries: Array<TimeValue>;
29
- xScale: ScaleLinear<number, number>;
29
+ xScale: ScaleTime<number, number>;
30
30
  hasSecondUnit?: boolean;
31
31
  maxLeftAxisCharacters: number;
32
32
  hasUnit?: boolean;
@@ -89,7 +89,7 @@ const useTickGraph = ({
89
89
 
90
90
  setTickAxisBottom(timeTickValue);
91
91
 
92
- const valueTickAxisLeft = leftScale?.invert(positionY);
92
+ const valueTickAxisLeft = leftScale?.invert(positionY ?? 0);
93
93
  const formattedTickAxisLeft = axisLeft?.tickFormat?.(valueTickAxisLeft);
94
94
 
95
95
  setTickAxisLeft(formattedTickAxisLeft);
@@ -99,7 +99,7 @@ const useTickGraph = ({
99
99
 
100
100
  return;
101
101
  }
102
- const valueTickAxisRight = rightScale?.invert(positionY);
102
+ const valueTickAxisRight = rightScale?.invert(positionY ?? 0);
103
103
  const formattedTickAxisRight = axisRight?.tickFormat?.(valueTickAxisRight);
104
104
  setTickAxisRight(formattedTickAxisRight);
105
105
  }, [mousePosition]);