@scality/core-ui 0.186.0 → 0.188.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 (171) hide show
  1. package/dist/components/{linetemporalchart/MetricTimespanProvider.d.ts → charts/MetricsTimeSpanProvider.d.ts} +1 -1
  2. package/dist/components/charts/MetricsTimeSpanProvider.d.ts.map +1 -0
  3. package/dist/components/{barchartv2/Barchart.component.d.ts → charts/barchart/Barchart.d.ts} +2 -33
  4. package/dist/components/charts/barchart/Barchart.d.ts.map +1 -0
  5. package/dist/components/charts/barchart/Barchart.js +56 -0
  6. package/dist/components/{barchartv2/utils.d.ts → charts/barchart/Barchart.utils.d.ts} +8 -35
  7. package/dist/components/charts/barchart/Barchart.utils.d.ts.map +1 -0
  8. package/dist/components/{barchartv2/utils.js → charts/barchart/Barchart.utils.js} +7 -88
  9. package/dist/components/{barchartv2 → charts/barchart}/BarchartTooltip.d.ts +2 -1
  10. package/dist/components/charts/barchart/BarchartTooltip.d.ts.map +1 -0
  11. package/dist/components/{barchartv2 → charts/barchart}/BarchartTooltip.js +3 -3
  12. package/dist/components/{charttooltip → charts/common}/ChartTooltip.d.ts +9 -2
  13. package/dist/components/charts/common/ChartTooltip.d.ts.map +1 -0
  14. package/dist/components/{charttooltip → charts/common}/ChartTooltip.js +11 -15
  15. package/dist/components/charts/common/SharedComponents.d.ts +47 -0
  16. package/dist/components/charts/common/SharedComponents.d.ts.map +1 -0
  17. package/dist/components/charts/common/SharedComponents.js +83 -0
  18. package/dist/components/charts/common/chartUtils.d.ts +91 -0
  19. package/dist/components/charts/common/chartUtils.d.ts.map +1 -0
  20. package/dist/components/charts/common/chartUtils.js +243 -0
  21. package/dist/components/{globalhealthbar/GlobalHealthBarRecharts.component.d.ts → charts/globalhealthbar/GlobalHealthBar.d.ts} +2 -2
  22. package/dist/components/charts/globalhealthbar/GlobalHealthBar.d.ts.map +1 -0
  23. package/dist/components/{globalhealthbar/useHealthBarData.d.ts → charts/globalhealthbar/GlobalHealthBar.hooks.d.ts} +1 -1
  24. package/dist/components/charts/globalhealthbar/GlobalHealthBar.hooks.d.ts.map +1 -0
  25. package/dist/components/{globalhealthbar/GlobalHealthBarRecharts.component.js → charts/globalhealthbar/GlobalHealthBar.js} +4 -4
  26. package/dist/components/{globalhealthbar/healthBarUtils.d.ts → charts/globalhealthbar/GlobalHealthBar.utils.d.ts} +1 -1
  27. package/dist/components/charts/globalhealthbar/GlobalHealthBar.utils.d.ts.map +1 -0
  28. package/dist/components/{globalhealthbar/healthBarUtils.js → charts/globalhealthbar/GlobalHealthBar.utils.js} +1 -1
  29. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.d.ts +1 -1
  30. package/dist/components/charts/globalhealthbar/GlobalHealthBarTooltip.d.ts.map +1 -0
  31. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.js +7 -3
  32. package/dist/components/charts/globalhealthbar/HealthBarXAxis.d.ts.map +1 -0
  33. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.js +1 -1
  34. package/dist/components/charts/index.d.ts +16 -0
  35. package/dist/components/charts/index.d.ts.map +1 -0
  36. package/dist/components/charts/index.js +15 -0
  37. package/dist/components/{chartlegend → charts/legend}/ChartLegend.d.ts +1 -1
  38. package/dist/components/charts/legend/ChartLegend.d.ts.map +1 -0
  39. package/dist/components/{chartlegend → charts/legend}/ChartLegend.js +2 -2
  40. package/dist/components/{chartlegend → charts/legend}/ChartLegendWrapper.d.ts +1 -1
  41. package/dist/components/charts/legend/ChartLegendWrapper.d.ts.map +1 -0
  42. package/dist/components/{linetimeseriechart/linetimeseriechart.component.d.ts → charts/linetimeseries/LineTimeSerieChart.d.ts} +12 -2
  43. package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts.map +1 -0
  44. package/dist/components/{linetimeseriechart/linetimeseriechart.component.js → charts/linetimeseries/LineTimeSerieChart.js} +34 -35
  45. package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts +14 -0
  46. package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts.map +1 -0
  47. package/dist/components/{linetimeseriechart/utils.js → charts/linetimeseries/LineTimeSerieChart.utils.js} +4 -6
  48. package/dist/components/charts/sparkline/Sparkline.d.ts +23 -0
  49. package/dist/components/charts/sparkline/Sparkline.d.ts.map +1 -0
  50. package/dist/components/{sparkline/sparkline.component.js → charts/sparkline/Sparkline.js} +12 -6
  51. package/dist/components/charts/types.d.ts +34 -0
  52. package/dist/components/charts/types.d.ts.map +1 -0
  53. package/dist/components/charts/types.js +4 -0
  54. package/dist/components/icon/Icon.component.d.ts +1 -0
  55. package/dist/components/icon/Icon.component.d.ts.map +1 -1
  56. package/dist/components/icon/Icon.component.js +2 -2
  57. package/dist/components/textbadge/TextBadge.component.d.ts +1 -1
  58. package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -1
  59. package/dist/index.d.ts +0 -2
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +4 -2
  62. package/dist/next.d.ts +3 -11
  63. package/dist/next.d.ts.map +1 -1
  64. package/dist/next.js +4 -11
  65. package/package.json +2 -6
  66. package/src/lib/components/{barchartv2/Barchart.component.test.tsx → charts/barchart/Barchart.test.tsx} +35 -10
  67. package/src/lib/components/{barchartv2/Barchart.component.tsx → charts/barchart/Barchart.tsx} +42 -207
  68. package/src/lib/components/{barchartv2/utils.test.ts → charts/barchart/Barchart.utils.test.ts} +2 -141
  69. package/src/lib/components/{barchartv2/utils.ts → charts/barchart/Barchart.utils.ts} +17 -143
  70. package/src/lib/components/{barchartv2 → charts/barchart}/BarchartTooltip.tsx +5 -9
  71. package/src/lib/components/{charttooltip → charts/common}/ChartTooltip.tsx +13 -20
  72. package/src/lib/components/charts/common/SharedComponents.tsx +193 -0
  73. package/src/lib/components/charts/common/chartUtils.test.ts +402 -0
  74. package/src/lib/components/charts/common/chartUtils.ts +334 -0
  75. package/src/lib/components/{globalhealthbar/useHealthBarData.spec.tsx → charts/globalhealthbar/GlobalHealthBar.hooks.test.tsx} +1 -1
  76. package/src/lib/components/{globalhealthbar/GlobalHealthBarRecharts.component.tsx → charts/globalhealthbar/GlobalHealthBar.tsx} +4 -4
  77. package/src/lib/components/{globalhealthbar/healthBarUtils.spec.ts → charts/globalhealthbar/GlobalHealthBar.utils.test.ts} +1 -1
  78. package/src/lib/components/{globalhealthbar/healthBarUtils.ts → charts/globalhealthbar/GlobalHealthBar.utils.ts} +1 -1
  79. package/src/lib/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.tsx +8 -4
  80. package/src/lib/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.tsx +1 -1
  81. package/src/lib/components/charts/index.ts +59 -0
  82. package/src/lib/components/{chartlegend → charts/legend}/ChartLegend.tsx +2 -2
  83. package/src/lib/components/{chartlegend → charts/legend}/ChartLegendWrapper.tsx +1 -1
  84. package/src/lib/components/{linetimeseriechart/linetimeseriechart.test.tsx → charts/linetimeseries/LineTimeSerieChart.test.tsx} +3 -6
  85. package/src/lib/components/{linetimeseriechart/linetimeseriechart.component.tsx → charts/linetimeseries/LineTimeSerieChart.tsx} +48 -44
  86. package/src/lib/components/{linetimeseriechart/utils.test.ts → charts/linetimeseries/LineTimeSerieChart.utils.test.ts} +1 -1
  87. package/src/lib/components/{linetimeseriechart/utils.ts → charts/linetimeseries/LineTimeSerieChart.utils.ts} +4 -6
  88. package/src/lib/components/charts/sparkline/Sparkline.tsx +80 -0
  89. package/src/lib/components/charts/types.ts +36 -0
  90. package/src/lib/components/icon/Icon.component.tsx +12 -8
  91. package/src/lib/components/textbadge/TextBadge.component.tsx +1 -1
  92. package/src/lib/index.ts +4 -2
  93. package/src/lib/next.ts +26 -13
  94. package/stories/BarChart/barchart.stories.tsx +10 -9
  95. package/stories/GlobalHealthBar/{globalhealthbarRecharts.stories.tsx → globalhealthbar.stories.tsx} +3 -21
  96. package/stories/GlobalHealthBar/globalheathbarrecharts.guideline.mdx +2 -2
  97. package/stories/guideline/chart-guideline.mdx +1 -38
  98. package/stories/linetimeseriechart.stories.tsx +4 -6
  99. package/stories/sparkline.stories.tsx +13 -11
  100. package/stories/textbadge.stories.tsx +15 -0
  101. package/dist/components/barchart/BarChart.component.d.ts +0 -17
  102. package/dist/components/barchart/BarChart.component.d.ts.map +0 -1
  103. package/dist/components/barchart/BarChart.component.js +0 -27
  104. package/dist/components/barchartv2/Barchart.component.d.ts.map +0 -1
  105. package/dist/components/barchartv2/Barchart.component.js +0 -122
  106. package/dist/components/barchartv2/BarchartTooltip.d.ts.map +0 -1
  107. package/dist/components/barchartv2/utils.d.ts.map +0 -1
  108. package/dist/components/chartlegend/ChartLegend.d.ts.map +0 -1
  109. package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +0 -1
  110. package/dist/components/charttooltip/ChartTooltip.d.ts.map +0 -1
  111. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +0 -23
  112. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +0 -1
  113. package/dist/components/globalhealthbar/GlobalHealthBar.component.js +0 -173
  114. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts.map +0 -1
  115. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts.map +0 -1
  116. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts.map +0 -1
  117. package/dist/components/globalhealthbar/healthBarUtils.d.ts.map +0 -1
  118. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts +0 -2
  119. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts.map +0 -1
  120. package/dist/components/globalhealthbar/healthBarUtils.spec.js +0 -391
  121. package/dist/components/globalhealthbar/tooltip/index.d.ts +0 -8
  122. package/dist/components/globalhealthbar/tooltip/index.d.ts.map +0 -1
  123. package/dist/components/globalhealthbar/tooltip/index.js +0 -55
  124. package/dist/components/globalhealthbar/useHealthBarData.d.ts.map +0 -1
  125. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts +0 -2
  126. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts.map +0 -1
  127. package/dist/components/globalhealthbar/useHealthBarData.spec.js +0 -209
  128. package/dist/components/linetemporalchart/ChartUtil.d.ts +0 -41
  129. package/dist/components/linetemporalchart/ChartUtil.d.ts.map +0 -1
  130. package/dist/components/linetemporalchart/ChartUtil.js +0 -148
  131. package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +0 -46
  132. package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +0 -1
  133. package/dist/components/linetemporalchart/LineTemporalChart.component.js +0 -579
  134. package/dist/components/linetemporalchart/MetricTimespanProvider.d.ts.map +0 -1
  135. package/dist/components/linetemporalchart/tooltip/index.d.ts +0 -30
  136. package/dist/components/linetemporalchart/tooltip/index.d.ts.map +0 -1
  137. package/dist/components/linetemporalchart/tooltip/index.js +0 -104
  138. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +0 -1
  139. package/dist/components/linetimeseriechart/utils.d.ts +0 -16
  140. package/dist/components/linetimeseriechart/utils.d.ts.map +0 -1
  141. package/dist/components/sparkline/sparkline.component.d.ts +0 -17
  142. package/dist/components/sparkline/sparkline.component.d.ts.map +0 -1
  143. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +0 -12
  144. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +0 -1
  145. package/dist/components/vegachartv2/SyncedCursorCharts.js +0 -15
  146. package/dist/components/vegachartv2/VegaChartV2.component.d.ts +0 -15
  147. package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +0 -1
  148. package/dist/components/vegachartv2/VegaChartV2.component.js +0 -218
  149. package/src/lib/components/barchart/BarChart.component.tsx +0 -51
  150. package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +0 -204
  151. package/src/lib/components/globalhealthbar/tooltip/index.ts +0 -72
  152. package/src/lib/components/linetemporalchart/ChartUtil.test.ts +0 -250
  153. package/src/lib/components/linetemporalchart/ChartUtil.ts +0 -225
  154. package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +0 -800
  155. package/src/lib/components/linetemporalchart/tooltip/index.ts +0 -178
  156. package/src/lib/components/sparkline/sparkline.component.tsx +0 -56
  157. package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +0 -28
  158. package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +0 -276
  159. package/stories/barchart.stories.tsx +0 -142
  160. package/stories/globalhealthbar.stories.tsx +0 -191
  161. package/stories/guideline/mdxExampleComponents.tsx +0 -57
  162. package/stories/linecharttemporal.stories.tsx +0 -88
  163. /package/dist/components/{linetemporalchart/MetricTimespanProvider.js → charts/MetricsTimeSpanProvider.js} +0 -0
  164. /package/dist/components/{globalhealthbar/useHealthBarData.js → charts/globalhealthbar/GlobalHealthBar.hooks.js} +0 -0
  165. /package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.d.ts +0 -0
  166. /package/dist/components/{chartlegend → charts/legend}/ChartLegendWrapper.js +0 -0
  167. /package/src/lib/components/{linetemporalchart/MetricTimespanProvider.tsx → charts/MetricsTimeSpanProvider.tsx} +0 -0
  168. /package/src/lib/components/{barchartv2 → charts/barchart}/BarchartTooltip.test.tsx +0 -0
  169. /package/src/lib/components/{globalhealthbar/useHealthBarData.ts → charts/globalhealthbar/GlobalHealthBar.hooks.ts} +0 -0
  170. /package/src/lib/components/{chartlegend → charts/legend}/ChartLegend.test.tsx +0 -0
  171. /package/src/lib/components/{chartlegend → charts/legend}/ChartLegendWrapper.test.tsx +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  TIME_FORMATER,
3
3
  DAY_MONTH_ABBREVIATED_YEAR,
4
4
  DAY_MONTH_ABBREVIATED_HOUR_MINUTE,
5
- } from '../date/FormattedDateTime';
5
+ } from '../../date/FormattedDateTime';
6
6
 
7
7
  export const ONE_YEAR_MILLISECONDS = 366 * 24 * 60 * 60 * 1000;
8
8
 
@@ -11,13 +11,11 @@ export type ChartDataPoint = {
11
11
  } & Record<string, number | null>;
12
12
 
13
13
  /**
14
- * Formats timestamp for X-axis labels based on time format and data range:
15
- * For 'date-time' format, return day-month-abbreviated-hour-minute format
16
- * For 'date' format, return YYYY-MM-DD format if time range is greater than 1 year, otherwise return MM-DD format
14
+ * Formats timestamp for X-axis labels based on duration
15
+ *
17
16
  *
18
17
  * @param timestamp - The timestamp to format in milliseconds
19
- * @param timeFormat - The format type ('date-time' or 'date')
20
- * @param chartData - The chart data to determine time range for optimal formatting
18
+ * @param duration - The duration in seconds
21
19
  * @returns Formatted string for display on X-axis
22
20
  */
23
21
  export const formatXAxisLabel = (
@@ -0,0 +1,80 @@
1
+ import { useMemo } from 'react';
2
+ import {
3
+ Area,
4
+ AreaChart,
5
+ CartesianGrid,
6
+ ResponsiveContainer,
7
+ YAxis,
8
+ } from 'recharts';
9
+ import { useTheme } from 'styled-components';
10
+ import { chartColors } from '../../../style/theme';
11
+ import { addMissingDataPoint } from '../common/chartUtils';
12
+
13
+ type SparklineProps = {
14
+ serie: {
15
+ data: [number, number | null][];
16
+ color?: string; // exa color code like '#ff0000'
17
+ };
18
+ startingTimeStamp: number;
19
+ sampleDuration: number;
20
+ sampleInterval: number;
21
+ yAxisType?: 'default' | 'percentage';
22
+ };
23
+
24
+ /**
25
+ * Sparkline is a simple dynamically sized area chart.
26
+ * Used to show trends in data over time.
27
+ * @param serie - The data series to display
28
+ * @param startingTimeStamp - The starting timestamp in seconds
29
+ * @param sampleDuration - The total duration in seconds to cover in the sparkline
30
+ * @param sampleInterval - The interval in seconds between data points
31
+ * @param yAxisType - The type of y-axis to display
32
+ * @returns The sparkline component
33
+ */
34
+ export function Sparkline({
35
+ serie,
36
+ startingTimeStamp,
37
+ sampleDuration,
38
+ sampleInterval,
39
+ yAxisType,
40
+ }: SparklineProps) {
41
+ const data = useMemo(() => {
42
+ const dataMdp = addMissingDataPoint(
43
+ serie.data,
44
+ startingTimeStamp,
45
+ sampleDuration,
46
+ sampleInterval,
47
+ );
48
+ return dataMdp.map(([x, y]) => ({ x, y }));
49
+ }, [serie.data]);
50
+ const color = serie.color ?? chartColors.lineColor1;
51
+ const strokeGridColor = useTheme().border;
52
+
53
+ return (
54
+ <ResponsiveContainer>
55
+ <AreaChart data={data}>
56
+ <defs>
57
+ <linearGradient id={`gradient-${color}`} x1="0" y1="0" x2="0" y2="1">
58
+ <stop offset="0%" stopColor={color} stopOpacity={0.7} />
59
+ <stop offset="100%" stopColor={color} stopOpacity={0.1} />
60
+ </linearGradient>
61
+ </defs>
62
+ <CartesianGrid
63
+ horizontal={false}
64
+ stroke={strokeGridColor}
65
+ strokeOpacity={0.5}
66
+ />
67
+ <Area
68
+ type="linear"
69
+ dataKey="y"
70
+ stroke={color}
71
+ fill={`url(#gradient-${color})`}
72
+ dot={false}
73
+ activeDot={false}
74
+ isAnimationActive={false}
75
+ />
76
+ {yAxisType === 'percentage' && <YAxis domain={[0, 100]} hide />}
77
+ </AreaChart>
78
+ </ResponsiveContainer>
79
+ );
80
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Shared types used across chart components
3
+ */
4
+
5
+ /**
6
+ * Unit range configuration for automatic unit scaling
7
+ * Should at least have base unit with threshold 1
8
+ * @example [{ threshold: 1, label: 'B' }, { threshold: 1000, label: 'kB' }]
9
+ */
10
+ export type UnitRange = {
11
+ threshold: number;
12
+ label: string;
13
+ }[];
14
+
15
+ /**
16
+ * Time-based chart configuration
17
+ * @param startDate - Start date
18
+ * @param endDate - End date
19
+ * @param interval - Interval in milliseconds
20
+ */
21
+ export type TimeType = {
22
+ type: 'time';
23
+ timeRange: {
24
+ startDate: Date;
25
+ endDate: Date;
26
+ interval: number;
27
+ };
28
+ };
29
+
30
+ /**
31
+ * Category-based chart configuration
32
+ */
33
+ export type CategoryType = {
34
+ type: 'category';
35
+ gap?: number;
36
+ };
@@ -143,6 +143,7 @@ export const iconTable = {
143
143
  ThumbsUp: 'far faThumbsUp',
144
144
  ThumbsDown: 'far faThumbsDown',
145
145
  Sidebar: 'fas faColumns',
146
+ Bookopen: 'fas faBookOpen',
146
147
  };
147
148
 
148
149
  type IconProps = {
@@ -153,7 +154,10 @@ type IconProps = {
153
154
  title?: string;
154
155
  };
155
156
 
156
- export const customIcons: Record<string, ((props: IconProps) => JSX.Element) & { displayName?: string }> = {
157
+ export const customIcons: Record<
158
+ string,
159
+ ((props: IconProps) => JSX.Element) & { displayName?: string }
160
+ > = {
157
161
  'Remote-user': ({ 'aria-label': ariaLabel, color, size }) => (
158
162
  <RemoteUser ariaLabel={ariaLabel} color={color} size={size} />
159
163
  ),
@@ -259,7 +263,8 @@ function NonWrappedIcon({
259
263
  }
260
264
 
261
265
  const [iconType, iconClass] = iconInfo.split(' ');
262
- const fontAwesomeType = iconType === 'far' ? 'free-regular-svg-icons' : 'free-solid-svg-icons';
266
+ const fontAwesomeType =
267
+ iconType === 'far' ? 'free-regular-svg-icons' : 'free-solid-svg-icons';
263
268
  const cacheKey = `${fontAwesomeType}/${iconClass}`;
264
269
  if (iconCache[cacheKey]) {
265
270
  setIcon(iconCache[cacheKey]);
@@ -267,11 +272,10 @@ function NonWrappedIcon({
267
272
  }
268
273
 
269
274
  // Handle FontAwesome icons with dynamic import
270
- import(`@fortawesome/${fontAwesomeType}/${iconClass}.js`)
271
- .then((module) => {
272
- setIcon(module[iconClass]);
273
- iconCache[cacheKey] = module[iconClass];
274
- });
275
+ import(`@fortawesome/${fontAwesomeType}/${iconClass}.js`).then((module) => {
276
+ setIcon(module[iconClass]);
277
+ iconCache[cacheKey] = module[iconClass];
278
+ });
275
279
  return () => setIcon(undefined);
276
280
  }, [name, iconInfo]);
277
281
 
@@ -292,7 +296,7 @@ function NonWrappedIcon({
292
296
  title={title}
293
297
  aria-label={`${name} ${ariaLabel}`}
294
298
  {...rest}
295
- />
299
+ />
296
300
  );
297
301
  }
298
302
 
@@ -24,7 +24,7 @@ const StyledTextBadge = styled.span<{ variant: TextBadgeVariant }>`
24
24
  `}
25
25
  `;
26
26
  type Props = {
27
- text: string;
27
+ text: React.ReactNode;
28
28
  className?: string;
29
29
  variant?: TextBadgeVariant;
30
30
  } & React.HTMLAttributes<HTMLSpanElement>;
package/src/lib/index.ts CHANGED
@@ -28,11 +28,13 @@ export { Tooltip } from './components/tooltip/Tooltip.component';
28
28
  export { ProgressBar } from './components/progressbar/ProgressBar.component';
29
29
  export { TextArea } from './components/textarea/TextArea.component';
30
30
 
31
- export { BarChart } from './components/barchart/BarChart.component';
31
+ // BarChart (deprecated) - Use Barchart from @scality/core-ui/dist/next instead
32
+ // export { BarChart } from './components/barchart/BarChart.component';
32
33
  export { CircularProgressBar } from './components/circularprogressbar/CircularProgressBar.component';
33
34
 
34
35
  export { LateralNavbarLayout } from './components/lateralnavbarlayout/LateralNavbarLayout.component';
35
- export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBar.component';
36
+ // GlobalHealthBar (deprecated vega version) - Use GlobalHealthBar from @scality/core-ui/dist/next instead
37
+ // export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBar.component';
36
38
  export { ConstrainedText } from './components/constrainedtext/Constrainedtext.component';
37
39
  export { EmptyState } from './components/emptystate/Emptystate.component';
38
40
  export { EmptyTable } from './components/emptytable/Emptytable.component';
package/src/lib/next.ts CHANGED
@@ -4,36 +4,49 @@ export { Button } from './components/buttonv2/Buttonv2.component';
4
4
  export { CopyButton } from './components/buttonv2/CopyButton.component';
5
5
  export { Tabs, Tab } from './components/tabsv2/Tabsv2.component';
6
6
  export { Table } from './components/tablev2/Tablev2.component';
7
- export { LineTemporalChart } from './components/linetemporalchart/LineTemporalChart.component';
7
+
8
+ // Keep MetricsTimeSpanProvider for backward compatibility (still used in external projects)
8
9
  export {
9
10
  MetricsTimeSpanProvider,
10
11
  useMetricsTimeSpan,
11
- } from './components/linetemporalchart/MetricTimespanProvider';
12
- export { SyncedCursorCharts } from './components/vegachartv2/SyncedCursorCharts';
12
+ } from './components/charts/MetricsTimeSpanProvider';
13
+
13
14
  export { Select } from './components/selectv2/Selectv2.component';
14
15
  export { HealthSelector } from './components/healthselectorv2/HealthSelector.component';
15
16
  export { CoreUiThemeProvider } from './components/coreuithemeprovider/CoreUiThemeProvider';
16
17
  export { Box } from './components/box/Box';
17
18
  export { Input } from './components/inputv2/inputv2';
18
19
  export { Accordion } from './components/accordion/Accordion.component';
20
+
21
+ // Export all chart components from the consolidated charts folder
19
22
  export {
20
23
  Barchart,
21
24
  BarchartSortFn,
22
25
  BarchartTooltipFn,
23
- } from './components/barchartv2/Barchart.component';
24
- export { BarchartTooltip } from './components/barchartv2/BarchartTooltip';
25
- export {
26
+ BarchartTooltip,
27
+ LineTimeSerieChart,
28
+ GlobalHealthBar,
29
+ Sparkline,
30
+ ChartLegend,
26
31
  ChartLegendWrapper,
27
32
  useChartId,
28
- } from './components/chartlegend/ChartLegendWrapper';
29
- export { ChartLegend } from './components/chartlegend/ChartLegend';
30
- export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
31
- export {
33
+ useChartLegend,
32
34
  ChartTooltipContainer,
33
35
  ChartTooltipItem,
34
36
  ChartTooltipHeader,
35
37
  ChartTooltipItemsContainer,
36
- } from './components/charttooltip/ChartTooltip';
38
+ } from './components/charts';
39
+
40
+ export type {
41
+ BarchartProps,
42
+ BarchartBars,
43
+ LineChartProps,
44
+ Serie,
45
+ GlobalHealthProps,
46
+ Alert,
47
+ UnitRange,
48
+ TimeType,
49
+ CategoryType,
50
+ } from './components/charts';
51
+
37
52
  export { CoreUITheme } from './style/theme';
38
- export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBarRecharts.component';
39
- export { Sparkline } from './components/sparkline/sparkline.component';
@@ -6,14 +6,14 @@ import {
6
6
  BarchartProps,
7
7
  BarchartSortFn,
8
8
  BarchartTooltipFn,
9
- } from '../../src/lib/components/barchartv2/Barchart.component';
9
+ ChartLegendWrapper,
10
+ ChartLegend,
11
+ } from '../../src/lib/components/charts';
10
12
  import { Button } from '../../src/lib/components/buttonv2/Buttonv2.component';
11
13
  import { Text } from '../../src/lib/components/text/Text.component';
12
14
  import { spacing, Stack, Wrap } from '../../src/lib/spacing';
13
15
  import { CoreUITheme } from '../../src/lib/style/theme';
14
16
  import { Wrapper } from '../common';
15
- import { ChartLegendWrapper } from '../../src/lib/components/chartlegend/ChartLegendWrapper';
16
- import { ChartLegend } from '../../src/lib/components/chartlegend/ChartLegend';
17
17
 
18
18
  type Story = StoryObj<typeof Barchart>;
19
19
 
@@ -39,17 +39,17 @@ export const Playground: Story = {
39
39
  {
40
40
  label: 'Success',
41
41
  data: [
42
- ['category1', 1],
43
- ['category2', 1],
44
- ['category3', 2],
42
+ ['category1', 0.001],
43
+ ['category2', 0.005],
44
+ ['category3', 0.002],
45
45
  ],
46
46
  },
47
47
  {
48
48
  label: 'Failed',
49
49
  data: [
50
- ['category1', 1],
51
- ['category2', 1],
52
- ['category3', 2],
50
+ ['category1', 0.01],
51
+ ['category2', 0.05],
52
+ ['category3', 0.02],
53
53
  ],
54
54
  },
55
55
  ] as const;
@@ -197,6 +197,7 @@ export const Time7DaysWithMissingData: Story = {
197
197
  Success: theme.statusHealthy,
198
198
  Failed: theme.statusCritical,
199
199
  }}
200
+ sortOrder="status"
200
201
  >
201
202
  <Barchart
202
203
  title="Time 7 Days With Missing Data"
@@ -1,33 +1,15 @@
1
- import React, { useState } from 'react';
2
1
  import { Meta, StoryObj } from '@storybook/react';
2
+ import React from 'react';
3
3
  import {
4
4
  Alert,
5
5
  GlobalHealthBar,
6
6
  GlobalHealthProps,
7
- } from '../../src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component';
8
-
9
- import {
10
- DATE_FORMATER,
11
- TIME_SECOND_FORMATER,
12
- } from '../../src/lib/components/date/FormattedDateTime';
13
- import {
14
- MetricsTimeSpanProvider,
15
- useMetricsTimeSpan,
16
- } from '../../src/lib/next';
17
- import { Dropdown, Icon, Stack } from '../../src/lib';
18
- import {
19
- LAST_ONE_HOUR,
20
- LAST_SEVEN_DAYS,
21
- LAST_TWENTY_FOUR_HOURS,
22
- SAMPLE_DURATION_LAST_ONE_HOUR,
23
- SAMPLE_DURATION_LAST_SEVEN_DAYS,
24
- SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
25
- } from '../../src/lib/components/constants';
7
+ } from '../../src/lib/components/charts';
26
8
 
27
9
  type Story = StoryObj<GlobalHealthProps>;
28
10
 
29
11
  const meta: Meta<GlobalHealthProps> = {
30
- title: 'Components/GlobalHealthBarRecharts',
12
+ title: 'Components/DataDisplay/Charts/GlobalHealthBar',
31
13
  component: GlobalHealthBar,
32
14
  };
33
15
  export default meta;
@@ -1,5 +1,5 @@
1
1
  import { Meta } from '@storybook/blocks';
2
- import { GlobalHealthBar } from '../../src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component';
3
- import * as GlobalHealthBarStories from './globalhealthbarRecharts.stories';
2
+ import { GlobalHealthBar } from '../../src/lib/components/charts';
3
+ import * as GlobalHealthBarStories from './globalhealthbar.stories';
4
4
 
5
5
  <Meta name="Guideline" of={GlobalHealthBarStories} />
@@ -1,5 +1,4 @@
1
1
  import { Meta, Story } from '@storybook/blocks';
2
- import { ChartExample } from './mdxExampleComponents';
3
2
  import { SuccessBanner } from '../banner.stories';
4
3
 
5
4
  <Meta title="Guidelines/Chart" />
@@ -14,10 +13,6 @@ Used mostly for monitoring-related tasks.
14
13
 
15
14
  Don’t depend too heavily on tooltips. They are as providing supplemental or expanded information, but shouldn’t be the only way a user can see the plotted value.
16
15
 
17
- ### Grid lines
18
-
19
- Only use grid lines when it’s helpful. Possible to use only horizontal or vertical.
20
-
21
16
  ### Elements
22
17
 
23
18
  - Title
@@ -28,36 +23,4 @@ _produce an example WIP_
28
23
 
29
24
  ## Type
30
25
 
31
- 4 types for most cases: pie/donut, bar/column, line, or area.
32
-
33
- ### Pie charts
34
-
35
- - No more than 6 categories
36
- - Values should be different enough (otherwise select Bar charts)
37
- - Should be a 100% total
38
- - Categories in the desc order
39
-
40
- _produce an example WIP_
41
-
42
- _(Currently, there is no Pie chart in the UI)_
43
-
44
- ### Bar and column charts
45
-
46
- - Should start at a baseline of zero.
47
- {/* <ChartExample /> */}
48
-
49
- ### Line charts
50
-
51
- - No more than 5–7 different lines
52
- - Avoid randomly chosen color (otherwise risk of contrast issues)
53
-
54
- Here, the colors for Get and List are too close.
55
-
56
- Components/Chart/LineChart
57
-
58
- Area charts
59
-
60
- - Could be a single area, overlapping area, or stacked area
61
- - Max 3-4 categories
62
-
63
- {/* <SuccessBanner /> */}
26
+ {/* TODO: add Guidelines for charts types and add date format guidelines here or in format.mdx */}
@@ -3,14 +3,12 @@ import { Meta, StoryObj } from '@storybook/react';
3
3
  import {
4
4
  LineTimeSerieChart,
5
5
  Serie,
6
- } from '../src/lib/components/linetimeseriechart/linetimeseriechart.component';
7
- import { ChartLegendWrapper } from '../src/lib/components/chartlegend/ChartLegendWrapper';
8
- import { lineTimeSeriesColorRange } from '../src/lib/style/theme';
9
- import { ChartLegend } from '../src/lib/components/chartlegend/ChartLegend';
10
- import {
6
+ ChartLegendWrapper,
7
+ ChartLegend,
11
8
  useChartId,
12
9
  useChartLegend,
13
- } from '../src/lib/components/chartlegend/ChartLegendWrapper';
10
+ } from '../src/lib/components/charts';
11
+ import { lineTimeSeriesColorRange } from '../src/lib/style/theme';
14
12
  import { useEffect } from 'react';
15
13
  import {
16
14
  SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { Sparkline } from '../src/lib/components/sparkline/sparkline.component';
2
+ import React from 'react';
3
+ import { Sparkline } from '../src/lib/components/charts';
3
4
  import { lineColor5, lineColor6 } from '../src/lib/style/theme';
4
5
 
5
6
  const meta: Meta<typeof Sparkline> = {
@@ -10,21 +11,21 @@ const meta: Meta<typeof Sparkline> = {
10
11
  },
11
12
  tags: ['autodocs'],
12
13
  argTypes: {
13
- serie: {
14
+ serie: {
14
15
  control: 'object',
15
- description: 'Data series containing array of [timestamp, value] pairs'
16
+ description: 'Data series containing array of [timestamp, value] pairs',
16
17
  },
17
- startingTimeStamp: {
18
+ startingTimeStamp: {
18
19
  control: 'number',
19
- description: 'Starting timestamp in seconds for the data series'
20
+ description: 'Starting timestamp in seconds for the data series',
20
21
  },
21
- sampleDuration: {
22
+ sampleDuration: {
22
23
  control: 'number',
23
- description: 'Total duration in seconds to cover in the sparkline'
24
+ description: 'Total duration in seconds to cover in the sparkline',
24
25
  },
25
- sampleInterval: {
26
+ sampleInterval: {
26
27
  control: 'number',
27
- description: 'Interval in seconds between data points'
28
+ description: 'Interval in seconds between data points',
28
29
  },
29
30
  },
30
31
  decorators: [
@@ -82,7 +83,7 @@ const trendingDownData: [number, number][] = [
82
83
  [1740412800, 22.1],
83
84
  ];
84
85
 
85
- const flatData: [number, number|null][] = [
86
+ const flatData: [number, number | null][] = [
86
87
  [1740405600, 50.0],
87
88
  [1740406320, 50.0],
88
89
  [1740407760, 50.0],
@@ -105,7 +106,8 @@ export const Default: Story = {
105
106
  parameters: {
106
107
  docs: {
107
108
  description: {
108
- story: 'Sparkline displaying highly volatile data with frequent peaks and valleys.',
109
+ story:
110
+ 'Sparkline displaying highly volatile data with frequent peaks and valleys.',
109
111
  },
110
112
  },
111
113
  },
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextBadge } from '../src/lib/components/textbadge/TextBadge.component';
3
3
  import { Wrapper, Title } from './common';
4
+ import { IconHelp } from '../src/lib/components/iconhelper/IconHelper';
5
+ import { Text } from '../src/lib/components/text/Text.component';
4
6
  export default {
5
7
  title: 'Components/TextBadge',
6
8
  component: TextBadge,
@@ -21,6 +23,19 @@ export const Default = {
21
23
  <TextBadge text="2" variant="statusWarning" />
22
24
  <TextBadge text="3" variant="statusCritical" />
23
25
  <TextBadge text="Badge" variant="infoSecondary" />
26
+ <TextBadge
27
+ text={
28
+ <>
29
+ <Text>This is a badge with a tooltip</Text>
30
+ <span style={{ marginLeft: '8px' }}>
31
+ <IconHelp
32
+ tooltipMessage={<div>This is a tooltip</div>}
33
+ title="Info"
34
+ />
35
+ </span>
36
+ </>
37
+ }
38
+ />
24
39
  </Wrapper>
25
40
  );
26
41
  },
@@ -1,17 +0,0 @@
1
- type Props = {
2
- id: string;
3
- data: Array<Record<string, any>>;
4
- xAxis: Record<string, any>;
5
- yAxis: Record<string, any>;
6
- color?: Record<string, any>;
7
- height?: number;
8
- barConfig?: Record<string, any>;
9
- };
10
- /**
11
- * @deprecated Use Barchart v2 instead
12
- * @example import { Barchart } from '@scality/core-ui/dist/next';
13
-
14
- */
15
- declare function BarChart({ id, data, xAxis, yAxis, color, height, barConfig, }: Props): import("react/jsx-runtime").JSX.Element;
16
- export { BarChart };
17
- //# sourceMappingURL=BarChart.component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BarChart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchart/BarChart.component.tsx"],"names":[],"mappings":"AACA,KAAK,KAAK,GAAG;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,EAChB,EAAE,EACF,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAY,EACZ,SAAS,GACV,EAAE,KAAK,2CAwBP;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,27 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { VegaChart } from '../vegachartv2/VegaChartV2.component';
3
- /**
4
- * @deprecated Use Barchart v2 instead
5
- * @example import { Barchart } from '@scality/core-ui/dist/next';
6
-
7
- */
8
- function BarChart({ id, data, xAxis, yAxis, color, height = 200, barConfig, }) {
9
- const spec = {
10
- mark: {
11
- type: 'bar',
12
- ...barConfig,
13
- },
14
- width: 'container',
15
- height,
16
- data: {
17
- values: data,
18
- },
19
- encoding: {
20
- x: xAxis,
21
- y: yAxis,
22
- color,
23
- },
24
- };
25
- return (_jsx(VegaChart, { id: id, spec: spec }, `barchart-${id}-${data.length}`));
26
- }
27
- export { BarChart };
@@ -1 +0,0 @@
1
- {"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"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"}