@scality/core-ui 0.171.0 → 0.173.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 (72) hide show
  1. package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
  2. package/dist/components/barchartv2/Barchart.component.js +2 -2
  3. package/dist/components/barchartv2/BarchartTooltip.d.ts +11 -0
  4. package/dist/components/barchartv2/BarchartTooltip.d.ts.map +1 -0
  5. package/dist/components/barchartv2/BarchartTooltip.js +27 -0
  6. package/dist/components/charttooltip/ChartTooltip.d.ts +13 -0
  7. package/dist/components/charttooltip/ChartTooltip.d.ts.map +1 -0
  8. package/dist/components/charttooltip/ChartTooltip.js +49 -0
  9. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +4 -0
  10. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +1 -1
  11. package/dist/components/globalhealthbar/GlobalHealthBar.component.js +4 -0
  12. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts +10 -0
  13. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts.map +1 -0
  14. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.js +78 -0
  15. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts +18 -0
  16. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts.map +1 -0
  17. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.js +95 -0
  18. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts +7 -0
  19. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts.map +1 -0
  20. package/dist/components/globalhealthbar/components/HealthBarXAxis.js +25 -0
  21. package/dist/components/globalhealthbar/healthBarUtils.d.ts +77 -0
  22. package/dist/components/globalhealthbar/healthBarUtils.d.ts.map +1 -0
  23. package/dist/components/globalhealthbar/healthBarUtils.js +196 -0
  24. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts +2 -0
  25. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts.map +1 -0
  26. package/dist/components/globalhealthbar/healthBarUtils.spec.js +391 -0
  27. package/dist/components/globalhealthbar/useHealthBarData.d.ts +18 -0
  28. package/dist/components/globalhealthbar/useHealthBarData.d.ts.map +1 -0
  29. package/dist/components/globalhealthbar/useHealthBarData.js +46 -0
  30. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts +2 -0
  31. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts.map +1 -0
  32. package/dist/components/globalhealthbar/useHealthBarData.spec.js +207 -0
  33. package/dist/components/icon/Icon.component.js +2 -2
  34. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +0 -2
  35. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
  36. package/dist/components/linetimeseriechart/linetimeseriechart.component.js +17 -57
  37. package/dist/components/sparkline/sparkline.component.d.ts +16 -0
  38. package/dist/components/sparkline/sparkline.component.d.ts.map +1 -0
  39. package/dist/components/sparkline/sparkline.component.js +20 -0
  40. package/dist/components/text/Text.component.d.ts +1 -1
  41. package/dist/components/text/Text.component.d.ts.map +1 -1
  42. package/dist/components/text/Text.component.js +6 -1
  43. package/dist/next.d.ts +4 -1
  44. package/dist/next.d.ts.map +1 -1
  45. package/dist/next.js +4 -1
  46. package/package.json +2 -2
  47. package/src/lib/components/barchartv2/Barchart.component.tsx +3 -2
  48. package/src/lib/components/barchartv2/{ChartTooltip.test.tsx → BarchartTooltip.test.tsx} +35 -12
  49. package/src/lib/components/barchartv2/BarchartTooltip.tsx +89 -0
  50. package/src/lib/components/charttooltip/ChartTooltip.tsx +83 -0
  51. package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +4 -1
  52. package/src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component.tsx +203 -0
  53. package/src/lib/components/globalhealthbar/components/GlobalHealthBarTooltip.tsx +173 -0
  54. package/src/lib/components/globalhealthbar/components/HealthBarXAxis.tsx +94 -0
  55. package/src/lib/components/globalhealthbar/healthBarUtils.spec.ts +701 -0
  56. package/src/lib/components/globalhealthbar/healthBarUtils.ts +311 -0
  57. package/src/lib/components/globalhealthbar/useHealthBarData.spec.tsx +487 -0
  58. package/src/lib/components/globalhealthbar/useHealthBarData.ts +74 -0
  59. package/src/lib/components/icon/Icon.component.tsx +2 -2
  60. package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +50 -77
  61. package/src/lib/components/sparkline/sparkline.component.tsx +54 -0
  62. package/src/lib/components/text/Text.component.tsx +8 -2
  63. package/src/lib/next.ts +9 -1
  64. package/stories/GlobalHealthBar/globalhealthbarRecharts.stories.tsx +145 -0
  65. package/stories/GlobalHealthBar/globalheathbarrecharts.guideline.mdx +5 -0
  66. package/stories/InlineInput/InlineInput.stories.tsx +7 -1
  67. package/stories/globalhealthbar.stories.tsx +25 -5
  68. package/stories/sparkline.stories.tsx +168 -0
  69. package/dist/components/barchartv2/ChartTooltip.d.ts +0 -14
  70. package/dist/components/barchartv2/ChartTooltip.d.ts.map +0 -1
  71. package/dist/components/barchartv2/ChartTooltip.js +0 -41
  72. package/src/lib/components/barchartv2/ChartTooltip.tsx +0 -106
@@ -0,0 +1,207 @@
1
+ import { useHealthBarData } from './useHealthBarData';
2
+ import { renderHook } from '@testing-library/react';
3
+ describe('useHealthBarData', () => {
4
+ const mockTimestamp = {
5
+ start: new Date('2023-12-01T00:00:00Z').getTime(),
6
+ end: new Date('2023-12-01T12:00:00Z').getTime(),
7
+ };
8
+ const createMockAlert = (severity, startsAt, endsAt, description = 'Test alert') => ({
9
+ description,
10
+ severity,
11
+ startsAt,
12
+ endsAt,
13
+ });
14
+ describe('Alert Filtering', () => {
15
+ it('should include alerts that are completely within the time range', () => {
16
+ const alerts = [
17
+ createMockAlert('critical', '2023-12-01T02:00:00Z', '2023-12-01T04:00:00Z'),
18
+ createMockAlert('warning', '2023-12-01T06:00:00Z', '2023-12-01T08:00:00Z'),
19
+ ];
20
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
21
+ expect(result.current.chartData[0]).toHaveProperty('critical_0');
22
+ expect(result.current.chartData[0]).toHaveProperty('warning_1');
23
+ expect(result.current.alertKeys.criticalKeys).toContain('critical_0');
24
+ expect(result.current.alertKeys.warningKeys).toContain('warning_1');
25
+ });
26
+ it('should include alerts that start before and end within the time range', () => {
27
+ const alerts = [
28
+ createMockAlert('critical', '2023-11-30T22:00:00Z', '2023-12-01T04:00:00Z'),
29
+ ];
30
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
31
+ expect(result.current.chartData[0]).toHaveProperty('critical_0');
32
+ expect(result.current.alertKeys.criticalKeys).toContain('critical_0');
33
+ });
34
+ it('should include alerts that start within and end after the time range', () => {
35
+ const alerts = [
36
+ createMockAlert('warning', '2023-12-01T10:00:00Z', '2023-12-01T14:00:00Z'),
37
+ ];
38
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
39
+ expect(result.current.chartData[0]).toHaveProperty('warning_0');
40
+ expect(result.current.alertKeys.warningKeys).toContain('warning_0');
41
+ });
42
+ it('should include alerts that span the entire time range', () => {
43
+ const alerts = [
44
+ createMockAlert('critical', '2023-11-30T20:00:00Z', '2023-12-01T16:00:00Z'),
45
+ ];
46
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
47
+ expect(result.current.chartData[0]).toHaveProperty('critical_0');
48
+ expect(result.current.alertKeys.criticalKeys).toContain('critical_0');
49
+ });
50
+ it('should exclude alerts that are completely before the time range', () => {
51
+ const alerts = [
52
+ createMockAlert('warning', '2023-11-30T10:00:00Z', '2023-11-30T20:00:00Z'),
53
+ ];
54
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
55
+ expect(result.current.chartData[0]).not.toHaveProperty('warning_0');
56
+ expect(result.current.alertKeys.warningKeys).toHaveLength(0);
57
+ });
58
+ it('should exclude alerts that are completely after the time range', () => {
59
+ const alerts = [
60
+ createMockAlert('critical', '2023-12-01T14:00:00Z', '2023-12-01T18:00:00Z'),
61
+ ];
62
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
63
+ expect(result.current.chartData[0]).not.toHaveProperty('critical_0');
64
+ expect(result.current.alertKeys.criticalKeys).toHaveLength(0);
65
+ });
66
+ });
67
+ describe('Data Transformation', () => {
68
+ it('should create correct data structure with basic properties', () => {
69
+ const alerts = [
70
+ createMockAlert('warning', '2023-12-01T02:00:00Z', '2023-12-01T04:00:00Z'),
71
+ ];
72
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
73
+ const data = result.current.chartData[0];
74
+ expect(data.range).toEqual([mockTimestamp.start, mockTimestamp.end]);
75
+ });
76
+ it('should create correct alert data keys with timestamps', () => {
77
+ const alerts = [
78
+ createMockAlert('critical', '2023-12-01T02:00:00Z', '2023-12-01T04:00:00Z'),
79
+ ];
80
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
81
+ const data = result.current.chartData[0];
82
+ const expectedStartTime = new Date('2023-12-01T02:00:00Z').getTime();
83
+ const expectedEndTime = new Date('2023-12-01T04:00:00Z').getTime();
84
+ expect(data['critical_0']).toEqual([expectedStartTime, expectedEndTime]);
85
+ });
86
+ it('should create alert metadata with correct structure', () => {
87
+ const alerts = [
88
+ createMockAlert('warning', '2023-12-01T02:00:00Z', '2023-12-01T04:00:00Z', 'Test warning'),
89
+ ];
90
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
91
+ expect(result.current.alertsMap['warning_0']).toEqual({
92
+ description: 'Test warning',
93
+ severity: 'warning',
94
+ startsAt: '2023-12-01T02:00:00Z',
95
+ endsAt: '2023-12-01T04:00:00Z',
96
+ });
97
+ });
98
+ it('should handle multiple alerts with correct indexing', () => {
99
+ const alerts = [
100
+ createMockAlert('warning', '2023-12-01T01:00:00Z', '2023-12-01T02:00:00Z'),
101
+ createMockAlert('critical', '2023-12-01T03:00:00Z', '2023-12-01T04:00:00Z'),
102
+ createMockAlert('warning', '2023-12-01T05:00:00Z', '2023-12-01T06:00:00Z'),
103
+ ];
104
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
105
+ const data = result.current.chartData[0];
106
+ expect(data).toHaveProperty('warning_0');
107
+ expect(data).toHaveProperty('critical_1');
108
+ expect(data).toHaveProperty('warning_2');
109
+ expect(result.current.alertsMap).toHaveProperty('warning_0');
110
+ expect(result.current.alertsMap).toHaveProperty('critical_1');
111
+ expect(result.current.alertsMap).toHaveProperty('warning_2');
112
+ });
113
+ });
114
+ describe('Alert Key Categorization', () => {
115
+ it('should categorize alert keys by severity', () => {
116
+ const alerts = [
117
+ createMockAlert('warning', '2023-12-01T01:00:00Z', '2023-12-01T02:00:00Z'),
118
+ createMockAlert('critical', '2023-12-01T03:00:00Z', '2023-12-01T04:00:00Z'),
119
+ createMockAlert('warning', '2023-12-01T05:00:00Z', '2023-12-01T06:00:00Z'),
120
+ createMockAlert('critical', '2023-12-01T07:00:00Z', '2023-12-01T08:00:00Z'),
121
+ ];
122
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
123
+ expect(result.current.alertKeys.warningKeys).toEqual([
124
+ 'warning_0',
125
+ 'warning_2',
126
+ ]);
127
+ expect(result.current.alertKeys.criticalKeys).toEqual([
128
+ 'critical_1',
129
+ 'critical_3',
130
+ ]);
131
+ expect(result.current.alertKeys.unavailableKeys).toEqual([]);
132
+ });
133
+ it('should handle only warning alerts', () => {
134
+ const alerts = [
135
+ createMockAlert('warning', '2023-12-01T01:00:00Z', '2023-12-01T02:00:00Z'),
136
+ createMockAlert('warning', '2023-12-01T03:00:00Z', '2023-12-01T04:00:00Z'),
137
+ ];
138
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
139
+ expect(result.current.alertKeys.warningKeys).toEqual([
140
+ 'warning_0',
141
+ 'warning_1',
142
+ ]);
143
+ expect(result.current.alertKeys.criticalKeys).toEqual([]);
144
+ expect(result.current.alertKeys.unavailableKeys).toEqual([]);
145
+ });
146
+ it('should handle only critical alerts', () => {
147
+ const alerts = [
148
+ createMockAlert('critical', '2023-12-01T01:00:00Z', '2023-12-01T02:00:00Z'),
149
+ createMockAlert('critical', '2023-12-01T03:00:00Z', '2023-12-01T04:00:00Z'),
150
+ ];
151
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
152
+ expect(result.current.alertKeys.warningKeys).toEqual([]);
153
+ expect(result.current.alertKeys.criticalKeys).toEqual([
154
+ 'critical_0',
155
+ 'critical_1',
156
+ ]);
157
+ expect(result.current.alertKeys.unavailableKeys).toEqual([]);
158
+ });
159
+ it('should only include alert bar keys and exclude metadata and basic properties', () => {
160
+ const alerts = [
161
+ createMockAlert('warning', '2023-12-01T01:00:00Z', '2023-12-01T02:00:00Z'),
162
+ ];
163
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
164
+ // Should only contain the actual alert bar keys for rendering
165
+ expect(result.current.alertKeys.warningKeys).toEqual(['warning_0']);
166
+ // Should not contain basic data properties
167
+ expect(result.current.alertKeys.warningKeys).not.toContain('start');
168
+ expect(result.current.alertKeys.warningKeys).not.toContain('end');
169
+ expect(result.current.alertKeys.warningKeys).not.toContain('range');
170
+ expect(result.current.alertKeys.warningKeys).not.toContain('id');
171
+ // Should not contain alert metadata keys (used for tooltips, not bars)
172
+ expect(result.current.alertKeys.warningKeys).not.toContain('alert_warning_0');
173
+ });
174
+ });
175
+ describe('Edge Cases', () => {
176
+ it('should handle empty alerts array', () => {
177
+ const { result } = renderHook(() => useHealthBarData([], mockTimestamp.start, mockTimestamp.end, 'test-id'));
178
+ const data = result.current.chartData[0];
179
+ expect(data.range).toEqual([mockTimestamp.start, mockTimestamp.end]);
180
+ expect(result.current.alertKeys.warningKeys).toEqual([]);
181
+ expect(result.current.alertKeys.criticalKeys).toEqual([]);
182
+ expect(result.current.alertKeys.unavailableKeys).toEqual([]);
183
+ });
184
+ it('should handle overlapping alerts correctly', () => {
185
+ const alerts = [
186
+ createMockAlert('warning', '2023-12-01T01:00:00Z', '2023-12-01T04:00:00Z'),
187
+ createMockAlert('critical', '2023-12-01T02:00:00Z', '2023-12-01T05:00:00Z'),
188
+ ];
189
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
190
+ expect(result.current.chartData[0]).toHaveProperty('warning_0');
191
+ expect(result.current.chartData[0]).toHaveProperty('critical_1');
192
+ expect(result.current.alertKeys.warningKeys).toContain('warning_0');
193
+ expect(result.current.alertKeys.criticalKeys).toContain('critical_1');
194
+ });
195
+ it('should handle alerts with same timestamps', () => {
196
+ const alerts = [
197
+ createMockAlert('warning', '2023-12-01T02:00:00Z', '2023-12-01T04:00:00Z'),
198
+ createMockAlert('critical', '2023-12-01T02:00:00Z', '2023-12-01T04:00:00Z'),
199
+ ];
200
+ const { result } = renderHook(() => useHealthBarData(alerts, mockTimestamp.start, mockTimestamp.end, 'test-id'));
201
+ expect(result.current.chartData[0]).toHaveProperty('warning_0');
202
+ expect(result.current.chartData[0]).toHaveProperty('critical_1');
203
+ expect(result.current.alertKeys.warningKeys).toContain('warning_0');
204
+ expect(result.current.alertKeys.criticalKeys).toContain('critical_1');
205
+ });
206
+ });
207
+ });
@@ -131,8 +131,8 @@ export const iconTable = {
131
131
  Stop: 'fas faStop',
132
132
  Play: 'fas faPlay',
133
133
  Mail: 'fas faEnvelope',
134
- ThumbsUp: 'fas faThumbsUp',
135
- ThumbsDown: 'fas faThumbsDown',
134
+ ThumbsUp: 'far faThumbsUp',
135
+ ThumbsDown: 'far faThumbsDown',
136
136
  };
137
137
  export const customIcons = {
138
138
  'Remote-user': ({ 'aria-label': ariaLabel, color, size }) => (_jsx(RemoteUser, { ariaLabel: ariaLabel, color: color, size: size })),
@@ -1,6 +1,4 @@
1
1
  import { TooltipContentProps } from 'recharts';
2
- export declare const TooltipContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
- export declare const TooltipTime: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
2
  export type Serie = {
5
3
  resource: string;
6
4
  data: [number, number | string | null][];
@@ -1 +1 @@
1
- {"version":3,"file":"linetimeseriechart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AA8BlB,eAAO,MAAM,gBAAgB,yGAO5B,CAAC;AAEF,eAAO,MAAM,WAAW,yGAMvB,CAAC;AAwCF,MAAM,MAAM,KAAK,GAAG;IAElB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAEzC,eAAe,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,SAAS,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;CAC7B,CAAC;AAGF,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EACF;QACE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;QAC3B,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;KAC5B,GACD,SAAS,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CACzB,wBAAwB,GACxB,qBAAqB,CACxB,GAAG;IACF,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,CACd,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,EACjD,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,KAC9B,KAAK,CAAC,SAAS,CAAC;CACtB,CAAC;AA6EF,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAiB,EACjB,UAAwB,EACxB,SAAqB,EACrB,UAAU,EACV,QAAQ,EACR,MAAM,EACN,aAAa,EACb,GAAG,IAAI,EACR,EAAE,cAAc,2CAmWhB"}
1
+ {"version":3,"file":"linetimeseriechart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AAqClB,MAAM,MAAM,KAAK,GAAG;IA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AM,EAAE,MAAM,CAAC,EACjD,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,KAC9B,KAAK,CAAC,SAAS,CAAC;CACtB,CAAC;AA6FF,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAiB,EACjB,UAAwB,EACxB,SAAqB,EACrB,UAAU,EACV,QAAQ,EACR,MAAM,EACN,aAAa,EACb,GAAG,IAAI,EACR,EAAE,cAAc,2CAwWhB"}
@@ -3,7 +3,7 @@ import { CartesianGrid, Line, LineChart, ReferenceLine, ResponsiveContainer, Too
3
3
  import { useCallback, useMemo, useRef, useState } from 'react';
4
4
  import styled, { useTheme } from 'styled-components';
5
5
  import { spacing } from '../../spacing';
6
- import { fontSize, fontWeight } from '../../style/theme';
6
+ import { fontSize } from '../../style/theme';
7
7
  import { Box } from '../box/Box';
8
8
  import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
9
9
  import { FormattedDateTime } from '../date/FormattedDateTime';
@@ -13,6 +13,8 @@ import { Loader } from '../loader/Loader.component';
13
13
  import { ChartTitleText, SmallerText } from '../text/Text.component';
14
14
  import { Tooltip as TooltipComponent } from '../tooltip/Tooltip.component';
15
15
  import { formatXAxisLabel } from './utils';
16
+ import { ChartTooltipContainer, ChartTooltipItem, ChartTooltipHeader, ChartTooltipItemsContainer, } from '../charttooltip/ChartTooltip';
17
+ import { LegendShape } from '../chartlegend/ChartLegend';
16
18
  const LineTemporalChartWrapper = styled.div `
17
19
  display: flex;
18
20
  flex-direction: column;
@@ -23,56 +25,8 @@ const ChartHeader = styled.div `
23
25
  display: flex;
24
26
  align-items: center;
25
27
  `;
26
- export const TooltipContainer = styled.div `
27
- background-color: ${(props) => props.theme.backgroundLevel1};
28
- padding: ${spacing.r8};
29
- border: 1px solid ${(props) => props.theme.border};
30
- border-radius: 4px;
31
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
32
- max-width: 250px;
33
- `;
34
- export const TooltipTime = styled.div `
35
- margin-bottom: ${spacing.r8};
36
- color: ${(props) => props.theme.textPrimary};
37
- font-size: ${fontSize.smaller};
38
- font-weight: ${fontWeight.bold};
39
- text-align: center;
40
- `;
41
- const TooltipValue = styled.div `
42
- font-size: ${fontSize.smaller};
43
- margin-top: 4px;
44
- color: ${(props) => props.theme.textSecondary};
45
- display: flex;
46
- align-items: flex-start;
47
- justify-content: space-between;
48
- width: 100%;
49
- `;
50
- const TooltipLegend = styled.div `
51
- width: 12px;
52
- height: 3px;
53
- background-color: ${(props) => props.color};
54
- margin-right: 8px;
55
- flex-shrink: 0;
56
- margin-top: 8px;
57
- `;
58
- const TooltipLeftGroup = styled.div `
59
- display: flex;
60
- align-items: flex-start;
61
- min-width: 0;
62
- flex: 1;
63
- `;
64
- const TooltipName = styled.div `
65
- word-wrap: break-word;
66
- word-break: break-word;
67
- flex: 1;
68
- `;
69
- const TooltipInstanceValue = styled.div `
70
- margin-left: 16px;
71
- flex-shrink: 0;
72
- text-align: right;
73
- `;
74
- const CustomTooltip = ({ unitLabel, timeFormat, isChartActive, tooltipProps, renderTooltip, }) => {
75
- const { active, payload, label, ...rest } = tooltipProps;
28
+ const LineTimeSerieChartTooltip = ({ unitLabel, timeFormat, isChartActive, tooltipProps, renderTooltip, hoveredValue, }) => {
29
+ const { active, payload, label } = tooltipProps;
76
30
  if (!active || !payload || !payload.length || !label || !isChartActive)
77
31
  return null;
78
32
  if (renderTooltip) {
@@ -91,11 +45,16 @@ const CustomTooltip = ({ unitLabel, timeFormat, isChartActive, tooltipProps, ren
91
45
  }
92
46
  return bValue - aValue; // Positives before negatives
93
47
  });
94
- return (_jsxs(TooltipContainer, { children: [_jsx(TooltipTime, { children: _jsx(FormattedDateTime, { format: timeFormat === 'date-time'
48
+ return (_jsxs(ChartTooltipContainer, { children: [_jsx(ChartTooltipHeader, { children: _jsx(FormattedDateTime, { format: timeFormat === 'date-time'
95
49
  ? 'day-month-abbreviated-hour-minute-second'
96
- : 'long-date-without-weekday', value: new Date(label) }) }), sortedPayload.map((entry, index) => (_jsxs(TooltipValue, { children: [_jsxs(TooltipLeftGroup, { children: [_jsx(TooltipLegend, { color: entry.color }), _jsx(TooltipName, { children: entry.name })] }), _jsx(TooltipInstanceValue, { children: !Number.isFinite(entry.value)
97
- ? '-'
98
- : `${entry.value.toFixed(2)} ${unitLabel}` })] }, index)))] }));
50
+ : 'long-date-without-weekday', value: new Date(label) }) }), _jsx(ChartTooltipItemsContainer, { children: sortedPayload.map((entry, index) => {
51
+ const legendIcon = (_jsx(LegendShape, { color: entry.color, shape: "line", chartColors: { [entry.color]: entry.color } }));
52
+ const isHovered = entry.name === hoveredValue;
53
+ const formattedValue = !Number.isFinite(entry.value)
54
+ ? '-'
55
+ : `${entry.value.toFixed(2)} ${unitLabel}`;
56
+ return (_jsx(ChartTooltipItem, { label: entry.name, value: formattedValue, legendIcon: legendIcon, isHovered: isHovered }, index));
57
+ }) })] }));
99
58
  };
100
59
  const isSymmetricalSeries = (series) => {
101
60
  return 'above' in series && 'below' in series;
@@ -105,6 +64,7 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
105
64
  const { getColor, selectedResources } = useChartLegend();
106
65
  const chartRef = useRef(null);
107
66
  const [isChartActive, setIsChartActive] = useState(false);
67
+ const [hoveredValue, setHoveredValue] = useState(undefined);
108
68
  const chartData = useMemo(() => {
109
69
  // Guard against empty/undefined series data
110
70
  if (!series || (Array.isArray(series) && series.length === 0)) {
@@ -279,8 +239,8 @@ export function LineTimeSerieChart({ series, title, height, startingTimeStamp, i
279
239
  : [0, topValue], axisLine: { stroke: theme.border }, tick: {
280
240
  fill: theme.textSecondary,
281
241
  fontSize: fontSize.smaller,
282
- }, tickFormatter: (value) => Math.round(value).toString(), tickCount: 5, interval: 'preserveStartEnd' }), _jsx(Tooltip, { content: (props) => (_jsx(CustomTooltip, { unitLabel: unitLabel, timeFormat: timeFormat, renderTooltip: renderTooltip, tooltipProps: props, isChartActive: isChartActive })) }), yAxisType === 'symmetrical' && (_jsx(ReferenceLine, { y: 0, stroke: theme.border })), Object.entries(groupedSeries).map(([resource, resourceSeries]) => resourceSeries.map((serie, serieIndex) => {
242
+ }, tickFormatter: (value) => Math.round(value).toString(), tickCount: 5, interval: 'preserveStartEnd' }), _jsx(Tooltip, { content: (props) => (_jsx(LineTimeSerieChartTooltip, { unitLabel: unitLabel, timeFormat: timeFormat, renderTooltip: renderTooltip, tooltipProps: props, isChartActive: isChartActive, hoveredValue: hoveredValue })) }), yAxisType === 'symmetrical' && (_jsx(ReferenceLine, { y: 0, stroke: theme.border })), Object.entries(groupedSeries).map(([resource, resourceSeries]) => resourceSeries.map((serie, serieIndex) => {
283
243
  const label = serie.getTooltipLabel(serie.metricPrefix, serie.resource);
284
- return (_jsx(Line, { type: "monotone", dataKey: label, stroke: colorMapping[resource], dot: false, isAnimationActive: false }, `${title}-${resource}-${serieIndex}`));
244
+ return (_jsx(Line, { type: "monotone", dataKey: label, stroke: colorMapping[resource], dot: false, isAnimationActive: false, onMouseEnter: () => setHoveredValue(label), onMouseLeave: () => setHoveredValue(undefined) }, `${title}-${resource}-${serieIndex}`));
285
245
  }))] }) }) })] }));
286
246
  }
@@ -0,0 +1,16 @@
1
+ type SparklineProps = {
2
+ serie: {
3
+ data: [number, number | null][];
4
+ color?: string;
5
+ };
6
+ startingTimeStamp: number;
7
+ sampleDuration: number;
8
+ sampleInterval: number;
9
+ };
10
+ /**
11
+ * Sparkline is a simple dynamically sized area chart.
12
+ * Used to show trends in data over time.
13
+ */
14
+ export declare function Sparkline({ serie, startingTimeStamp, sampleDuration, sampleInterval }: SparklineProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=sparkline.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparkline.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/sparkline/sparkline.component.tsx"],"names":[],"mappings":"AAMA,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE;QACL,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,EAAE,cAAc,2CAiCrG"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { Area, AreaChart, CartesianGrid, ResponsiveContainer } from "recharts";
4
+ import { useTheme } from "styled-components";
5
+ import { chartColors } from "../../style/theme";
6
+ import { addMissingDataPoint } from "../linetemporalchart/ChartUtil";
7
+ /**
8
+ * Sparkline is a simple dynamically sized area chart.
9
+ * Used to show trends in data over time.
10
+ */
11
+ export function Sparkline({ serie, startingTimeStamp, sampleDuration, sampleInterval }) {
12
+ var _a;
13
+ const data = useMemo(() => {
14
+ const dataMdp = addMissingDataPoint(serie.data, startingTimeStamp, sampleDuration, sampleInterval);
15
+ return dataMdp.map(([x, y]) => ({ x, y }));
16
+ }, [serie.data]);
17
+ const color = (_a = serie.color) !== null && _a !== void 0 ? _a : chartColors.lineColor1;
18
+ const strokeGridColor = useTheme().border;
19
+ return (_jsx(ResponsiveContainer, { children: _jsxs(AreaChart, { data: data, children: [_jsx("defs", { children: _jsxs("linearGradient", { id: `gradient-${color}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0.7 }), _jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 0.1 })] }) }), _jsx(CartesianGrid, { horizontal: false, stroke: strokeGridColor, strokeOpacity: 0.5 }), _jsx(Area, { type: "linear", dataKey: "y", stroke: color, fill: `url(#gradient-${color})`, dot: false, activeDot: false, isAnimationActive: false })] }) }));
20
+ }
@@ -1,5 +1,5 @@
1
1
  import { CoreUITheme } from '../../style/theme';
2
- export type TextVariant = 'ChartTitle' | 'Basic' | 'Smaller' | 'Larger' | 'Large';
2
+ export type TextVariant = 'ChartTitle' | 'Basic' | 'Smaller' | 'Larger' | 'Large' | 'Small';
3
3
  type Status = 'unknown' | 'healthy' | 'warning' | 'critical';
4
4
  type Props = {
5
5
  children: React.ReactNode | string;
@@ -1 +1 @@
1
- {"version":3,"file":"Text.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/text/Text.component.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,MAAM,WAAW,GACnB,YAAY,GACZ,OAAO,GACP,SAAS,GACT,QAAQ,GACR,OAAO,CAAC;AAEZ,KAAK,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAC7D,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAsDF,eAAO,MAAM,uBAAuB;iBACrB,MAAM;SAIpB,CAAC;AAIF,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAErD;AACD,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAEzD;AACD,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAEtD;AACD,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAEvD;AACD,wBAAgB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gB,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAErD;AACD,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAEzD;AACD,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAEtD;AACD,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAEvD;AACD,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAO9D;AACD,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAErD;AACD,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAEvD;AACD,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAIhE;AACD,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAOtE;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,KAAK,2CAE1D;AACD,eAAO,MAAM,0BAA0B;iBACxB,OAAO;SAUrB,CAAC;AAEF,eAAO,MAAM,IAAI;cACL,WAAW;YACb,MAAM,WAAW;iBACZ,OAAO;uBACD,OAAO;SAgD3B,CAAC;AAEF,eAAO,MAAM,IAAI,uGAchB,CAAC"}
@@ -116,7 +116,12 @@ export const Text = styled.span `
116
116
  line-height: 1.4;
117
117
  letter-spacing: 2%;// to be defined, percentage value is not valid
118
118
  `
119
- : `
119
+ : props.variant === 'Small'
120
+ ? `
121
+ font-size: 0.85rem;
122
+ line-height: 1.4;
123
+ `
124
+ : `
120
125
  font-size: 1rem;
121
126
  line-height: ${spacing.r24};
122
127
  `}
package/dist/next.d.ts CHANGED
@@ -14,9 +14,12 @@ export { Box } from './components/box/Box';
14
14
  export { Input } from './components/inputv2/inputv2';
15
15
  export { Accordion } from './components/accordion/Accordion.component';
16
16
  export { Barchart, BarchartSortFn, BarchartTooltipFn, } from './components/barchartv2/Barchart.component';
17
- export { ChartTooltip } from './components/barchartv2/ChartTooltip';
17
+ export { BarchartTooltip } from './components/barchartv2/BarchartTooltip';
18
18
  export { ChartLegendWrapper, useChartId, } from './components/chartlegend/ChartLegendWrapper';
19
19
  export { ChartLegend } from './components/chartlegend/ChartLegend';
20
20
  export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
21
+ export { ChartTooltipContainer, ChartTooltipItem, ChartTooltipHeader, ChartTooltipItemsContainer, } from './components/charttooltip/ChartTooltip';
21
22
  export { CoreUITheme } from './style/theme';
23
+ export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBarRecharts.component';
24
+ export { Sparkline } from './components/sparkline/sparkline.component';
22
25
  //# sourceMappingURL=next.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../src/lib/next.ts"],"names":[],"mappings":"AAAA,OAAO,2CAA2C,CAAC;AACnD,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4DAA4D,CAAC;AAC/F,OAAO,EACL,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM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AAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AACvE,OAAO,EACL,QAAQ,EACR,cAAc,EACd,iBAAiB,GAClB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EACL,kBAAkB,EAClB,UAAU,GACX,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,gEAAgE,CAAC;AACjG,OAAO,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC"}
package/dist/next.js CHANGED
@@ -14,7 +14,10 @@ export { Box } from './components/box/Box';
14
14
  export { Input } from './components/inputv2/inputv2';
15
15
  export { Accordion } from './components/accordion/Accordion.component';
16
16
  export { Barchart, } from './components/barchartv2/Barchart.component';
17
- export { ChartTooltip } from './components/barchartv2/ChartTooltip';
17
+ export { BarchartTooltip } from './components/barchartv2/BarchartTooltip';
18
18
  export { ChartLegendWrapper, useChartId, } from './components/chartlegend/ChartLegendWrapper';
19
19
  export { ChartLegend } from './components/chartlegend/ChartLegend';
20
20
  export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
21
+ export { ChartTooltipContainer, ChartTooltipItem, ChartTooltipHeader, ChartTooltipItemsContainer, } from './components/charttooltip/ChartTooltip';
22
+ export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBarRecharts.component';
23
+ export { Sparkline } from './components/sparkline/sparkline.component';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scality/core-ui",
3
- "version": "0.171.0",
3
+ "version": "0.173.0",
4
4
  "description": "Scality common React component library",
5
5
  "author": "Scality Engineering",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -20,7 +20,7 @@
20
20
  "prepare": "npm run build",
21
21
  "postbuild": "npm run copy-files",
22
22
  "test": "jest",
23
- "storybook": "storybook dev -p 3000",
23
+ "storybook": "storybook dev -p 3001",
24
24
  "build-storybook": "storybook build",
25
25
  "storybook:deploy": "npm run build-storybook && gh-pages -d storybook-static -u \"github-actions-bot <support+actions@github.com>\""
26
26
  },
@@ -20,7 +20,7 @@ import { FormattedDateTime } from '../date/FormattedDateTime';
20
20
  import { IconHelp } from '../iconhelper/IconHelper';
21
21
  import { Loader } from '../loader/Loader.component';
22
22
  import { Text } from '../text/Text.component';
23
- import { ChartTooltip } from './ChartTooltip';
23
+ import { BarchartTooltip } from './BarchartTooltip';
24
24
  import { UnitRange, useChartData } from './utils';
25
25
 
26
26
  const CHART_CONSTANTS = {
@@ -393,12 +393,13 @@ export const Barchart = <T extends BarchartBars>(props: BarchartProps<T>) => {
393
393
 
394
394
  <Tooltip
395
395
  content={(props: TooltipContentProps<number, string>) => (
396
- <ChartTooltip
396
+ <BarchartTooltip
397
397
  type={type}
398
398
  colorSet={colorSet}
399
399
  tooltipProps={props}
400
400
  hoveredValue={hoveredValue}
401
401
  tooltip={tooltip}
402
+ unitLabel={unitLabel}
402
403
  />
403
404
  )}
404
405
  cursor={false}
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
- import { ChartTooltip } from './ChartTooltip';
3
+ import { BarchartTooltip } from './BarchartTooltip';
4
4
 
5
5
  const ONE_DAY_IN_MILLISECONDS = 24 * 60 * 60 * 1000;
6
6
  const ONE_HOUR_IN_MILLISECONDS = 60 * 60 * 1000;
@@ -27,12 +27,13 @@ describe('ChartTooltip', () => {
27
27
  successValue: () => screen.queryByText(SUCCESS_VALUE),
28
28
  failed: () => screen.queryByText(/Failed/),
29
29
  failedValue: () => screen.queryByText(FAILED_VALUE),
30
- date: () => screen.queryByText(/Monday, 01 July 2024/),
31
- time: () => screen.queryByText(/00:00/),
30
+ longDate: () => screen.queryByText(/01 July 2024/),
31
+ date: () => screen.queryByText(/\b01 Jul\b/),
32
+ time: () => screen.queryByText(/00:00:00/),
32
33
  };
33
- it('should render the ChartTooltip component', () => {
34
+ it('should render the BarchartTooltip component', () => {
34
35
  render(
35
- <ChartTooltip
36
+ <BarchartTooltip
36
37
  type={{ type: 'category' }}
37
38
  tooltipProps={testTooltipProps}
38
39
  hoveredValue="Success"
@@ -47,7 +48,7 @@ describe('ChartTooltip', () => {
47
48
  });
48
49
  it('should render tooltip when tooltip is provided', () => {
49
50
  render(
50
- <ChartTooltip
51
+ <BarchartTooltip
51
52
  type={{ type: 'category' }}
52
53
  tooltipProps={testTooltipProps}
53
54
  hoveredValue="Success"
@@ -58,7 +59,7 @@ describe('ChartTooltip', () => {
58
59
  });
59
60
  it('should not render tooltip when tooltipProps is not active', () => {
60
61
  render(
61
- <ChartTooltip
62
+ <BarchartTooltip
62
63
  type={{ type: 'category' }}
63
64
  tooltipProps={{ ...testTooltipProps, active: false }}
64
65
  hoveredValue="Success"
@@ -71,7 +72,7 @@ describe('ChartTooltip', () => {
71
72
  // timestamp for Mon Jul 01 2024 00:00:00 GMT+0000 (Coordinated Universal Time)
72
73
  const label = date;
73
74
  render(
74
- <ChartTooltip
75
+ <BarchartTooltip
75
76
  type={{
76
77
  type: 'time',
77
78
  timeRange: {
@@ -84,19 +85,18 @@ describe('ChartTooltip', () => {
84
85
  hoveredValue="Success"
85
86
  />,
86
87
  );
87
-
88
88
  expect(selectors.success()).toBeInTheDocument();
89
89
  expect(selectors.successValue()).toBeInTheDocument();
90
90
  expect(selectors.failed()).toBeInTheDocument();
91
91
  expect(selectors.failedValue()).toBeInTheDocument();
92
-
93
- expect(selectors.date()).toBeInTheDocument();
92
+ expect(selectors.date()).not.toBeInTheDocument();
93
+ expect(selectors.longDate()).toBeInTheDocument();
94
94
  expect(selectors.time()).not.toBeInTheDocument();
95
95
  });
96
96
  it('should render time tooltip when type is time and interval is one hour', () => {
97
97
  const label = date;
98
98
  render(
99
- <ChartTooltip
99
+ <BarchartTooltip
100
100
  type={{
101
101
  type: 'time',
102
102
  timeRange: {
@@ -114,6 +114,29 @@ describe('ChartTooltip', () => {
114
114
  expect(selectors.failed()).toBeInTheDocument();
115
115
  expect(selectors.failedValue()).toBeInTheDocument();
116
116
  expect(selectors.date()).toBeInTheDocument();
117
+ expect(selectors.longDate()).not.toBeInTheDocument();
117
118
  expect(selectors.time()).toBeInTheDocument();
118
119
  });
120
+ it('should render with correctly formatted values when unitLabel is provided', () => {
121
+ const FREE_VALUE = 123.456789;
122
+ const USED_VALUE = 20;
123
+ const tooltipProps = {
124
+ ...testTooltipProps,
125
+ payload: [
126
+ { name: 'Free', value: FREE_VALUE },
127
+ { name: 'Used', value: USED_VALUE },
128
+ ],
129
+ };
130
+ render(
131
+ <BarchartTooltip
132
+ type={{ type: 'category' }}
133
+ tooltipProps={tooltipProps}
134
+ hoveredValue="Success"
135
+ unitLabel="kB"
136
+ />,
137
+ );
138
+
139
+ expect(screen.getByText('123.46 kB')).toBeInTheDocument();
140
+ expect(screen.getByText('20 kB')).toBeInTheDocument();
141
+ });
119
142
  });