@scality/core-ui 0.185.0 → 0.187.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 (177) hide show
  1. package/.storybook/preview.js +1 -7
  2. package/dist/components/{linetemporalchart/MetricTimespanProvider.d.ts → charts/MetricsTimeSpanProvider.d.ts} +1 -1
  3. package/dist/components/charts/MetricsTimeSpanProvider.d.ts.map +1 -0
  4. package/dist/components/{barchartv2/Barchart.component.d.ts → charts/barchart/Barchart.d.ts} +2 -33
  5. package/dist/components/charts/barchart/Barchart.d.ts.map +1 -0
  6. package/dist/components/charts/barchart/Barchart.js +56 -0
  7. package/dist/components/{barchartv2/utils.d.ts → charts/barchart/Barchart.utils.d.ts} +8 -35
  8. package/dist/components/charts/barchart/Barchart.utils.d.ts.map +1 -0
  9. package/dist/components/{barchartv2/utils.js → charts/barchart/Barchart.utils.js} +7 -88
  10. package/dist/components/{barchartv2 → charts/barchart}/BarchartTooltip.d.ts +2 -1
  11. package/dist/components/charts/barchart/BarchartTooltip.d.ts.map +1 -0
  12. package/dist/components/{barchartv2 → charts/barchart}/BarchartTooltip.js +3 -3
  13. package/dist/components/{charttooltip → charts/common}/ChartTooltip.d.ts +9 -2
  14. package/dist/components/charts/common/ChartTooltip.d.ts.map +1 -0
  15. package/dist/components/{charttooltip → charts/common}/ChartTooltip.js +11 -15
  16. package/dist/components/charts/common/SharedComponents.d.ts +47 -0
  17. package/dist/components/charts/common/SharedComponents.d.ts.map +1 -0
  18. package/dist/components/charts/common/SharedComponents.js +73 -0
  19. package/dist/components/charts/common/chartUtils.d.ts +91 -0
  20. package/dist/components/charts/common/chartUtils.d.ts.map +1 -0
  21. package/dist/components/charts/common/chartUtils.js +243 -0
  22. package/dist/components/{globalhealthbar/GlobalHealthBarRecharts.component.d.ts → charts/globalhealthbar/GlobalHealthBar.d.ts} +2 -2
  23. package/dist/components/charts/globalhealthbar/GlobalHealthBar.d.ts.map +1 -0
  24. package/dist/components/{globalhealthbar/useHealthBarData.d.ts → charts/globalhealthbar/GlobalHealthBar.hooks.d.ts} +1 -1
  25. package/dist/components/charts/globalhealthbar/GlobalHealthBar.hooks.d.ts.map +1 -0
  26. package/dist/components/{globalhealthbar/GlobalHealthBarRecharts.component.js → charts/globalhealthbar/GlobalHealthBar.js} +4 -4
  27. package/dist/components/{globalhealthbar/healthBarUtils.d.ts → charts/globalhealthbar/GlobalHealthBar.utils.d.ts} +1 -1
  28. package/dist/components/charts/globalhealthbar/GlobalHealthBar.utils.d.ts.map +1 -0
  29. package/dist/components/{globalhealthbar/healthBarUtils.js → charts/globalhealthbar/GlobalHealthBar.utils.js} +1 -1
  30. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.d.ts +1 -1
  31. package/dist/components/charts/globalhealthbar/GlobalHealthBarTooltip.d.ts.map +1 -0
  32. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.js +7 -3
  33. package/dist/components/charts/globalhealthbar/HealthBarXAxis.d.ts.map +1 -0
  34. package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.js +1 -1
  35. package/dist/components/charts/index.d.ts +16 -0
  36. package/dist/components/charts/index.d.ts.map +1 -0
  37. package/dist/components/charts/index.js +15 -0
  38. package/dist/components/{chartlegend → charts/legend}/ChartLegend.d.ts +1 -1
  39. package/dist/components/charts/legend/ChartLegend.d.ts.map +1 -0
  40. package/dist/components/{chartlegend → charts/legend}/ChartLegend.js +2 -2
  41. package/dist/components/{chartlegend → charts/legend}/ChartLegendWrapper.d.ts +1 -1
  42. package/dist/components/charts/legend/ChartLegendWrapper.d.ts.map +1 -0
  43. package/dist/components/{linetimeseriechart/linetimeseriechart.component.d.ts → charts/linetimeseries/LineTimeSerieChart.d.ts} +12 -2
  44. package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts.map +1 -0
  45. package/dist/components/{linetimeseriechart/linetimeseriechart.component.js → charts/linetimeseries/LineTimeSerieChart.js} +34 -35
  46. package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts +14 -0
  47. package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts.map +1 -0
  48. package/dist/components/{linetimeseriechart/utils.js → charts/linetimeseries/LineTimeSerieChart.utils.js} +4 -6
  49. package/dist/components/charts/sparkline/Sparkline.d.ts +23 -0
  50. package/dist/components/charts/sparkline/Sparkline.d.ts.map +1 -0
  51. package/dist/components/{sparkline/sparkline.component.js → charts/sparkline/Sparkline.js} +12 -6
  52. package/dist/components/charts/types.d.ts +34 -0
  53. package/dist/components/charts/types.d.ts.map +1 -0
  54. package/dist/components/charts/types.js +4 -0
  55. package/dist/components/icon/Icon.component.d.ts +1 -0
  56. package/dist/components/icon/Icon.component.d.ts.map +1 -1
  57. package/dist/components/icon/Icon.component.js +2 -2
  58. package/dist/components/textbadge/TextBadge.component.d.ts +1 -1
  59. package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -1
  60. package/dist/components/tooltip/Tooltip.component.d.ts.map +1 -1
  61. package/dist/components/tooltip/Tooltip.component.js +16 -29
  62. package/dist/index.d.ts +0 -2
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +4 -2
  65. package/dist/next.d.ts +3 -11
  66. package/dist/next.d.ts.map +1 -1
  67. package/dist/next.js +4 -11
  68. package/package.json +2 -6
  69. package/src/lib/components/{barchartv2/Barchart.component.test.tsx → charts/barchart/Barchart.test.tsx} +35 -10
  70. package/src/lib/components/{barchartv2/Barchart.component.tsx → charts/barchart/Barchart.tsx} +42 -207
  71. package/src/lib/components/{barchartv2/utils.test.ts → charts/barchart/Barchart.utils.test.ts} +2 -141
  72. package/src/lib/components/{barchartv2/utils.ts → charts/barchart/Barchart.utils.ts} +17 -143
  73. package/src/lib/components/{barchartv2 → charts/barchart}/BarchartTooltip.tsx +5 -9
  74. package/src/lib/components/{charttooltip → charts/common}/ChartTooltip.tsx +13 -20
  75. package/src/lib/components/charts/common/SharedComponents.tsx +180 -0
  76. package/src/lib/components/charts/common/chartUtils.test.ts +402 -0
  77. package/src/lib/components/charts/common/chartUtils.ts +334 -0
  78. package/src/lib/components/{globalhealthbar/useHealthBarData.spec.tsx → charts/globalhealthbar/GlobalHealthBar.hooks.test.tsx} +1 -1
  79. package/src/lib/components/{globalhealthbar/GlobalHealthBarRecharts.component.tsx → charts/globalhealthbar/GlobalHealthBar.tsx} +4 -4
  80. package/src/lib/components/{globalhealthbar/healthBarUtils.spec.ts → charts/globalhealthbar/GlobalHealthBar.utils.test.ts} +1 -1
  81. package/src/lib/components/{globalhealthbar/healthBarUtils.ts → charts/globalhealthbar/GlobalHealthBar.utils.ts} +1 -1
  82. package/src/lib/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.tsx +8 -4
  83. package/src/lib/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.tsx +1 -1
  84. package/src/lib/components/charts/index.ts +59 -0
  85. package/src/lib/components/{chartlegend → charts/legend}/ChartLegend.tsx +2 -2
  86. package/src/lib/components/{chartlegend → charts/legend}/ChartLegendWrapper.tsx +1 -1
  87. package/src/lib/components/{linetimeseriechart/linetimeseriechart.test.tsx → charts/linetimeseries/LineTimeSerieChart.test.tsx} +3 -6
  88. package/src/lib/components/{linetimeseriechart/linetimeseriechart.component.tsx → charts/linetimeseries/LineTimeSerieChart.tsx} +48 -44
  89. package/src/lib/components/{linetimeseriechart/utils.test.ts → charts/linetimeseries/LineTimeSerieChart.utils.test.ts} +1 -1
  90. package/src/lib/components/{linetimeseriechart/utils.ts → charts/linetimeseries/LineTimeSerieChart.utils.ts} +4 -6
  91. package/src/lib/components/charts/sparkline/Sparkline.tsx +80 -0
  92. package/src/lib/components/charts/types.ts +36 -0
  93. package/src/lib/components/icon/Icon.component.tsx +12 -8
  94. package/src/lib/components/textbadge/TextBadge.component.tsx +1 -1
  95. package/src/lib/components/tooltip/Tooltip.component.tsx +37 -47
  96. package/src/lib/index.ts +4 -2
  97. package/src/lib/next.ts +26 -13
  98. package/stories/BarChart/barchart.stories.tsx +10 -9
  99. package/stories/GlobalHealthBar/{globalhealthbarRecharts.stories.tsx → globalhealthbar.stories.tsx} +3 -21
  100. package/stories/GlobalHealthBar/globalheathbarrecharts.guideline.mdx +2 -2
  101. package/stories/common.tsx +1 -1
  102. package/stories/guideline/chart-guideline.mdx +1 -38
  103. package/stories/linetimeseriechart.stories.tsx +4 -6
  104. package/stories/sparkline.stories.tsx +13 -11
  105. package/stories/tablev2.stories.tsx +1 -1
  106. package/stories/textbadge.stories.tsx +15 -0
  107. package/dist/components/barchart/BarChart.component.d.ts +0 -17
  108. package/dist/components/barchart/BarChart.component.d.ts.map +0 -1
  109. package/dist/components/barchart/BarChart.component.js +0 -27
  110. package/dist/components/barchartv2/Barchart.component.d.ts.map +0 -1
  111. package/dist/components/barchartv2/Barchart.component.js +0 -122
  112. package/dist/components/barchartv2/BarchartTooltip.d.ts.map +0 -1
  113. package/dist/components/barchartv2/utils.d.ts.map +0 -1
  114. package/dist/components/chartlegend/ChartLegend.d.ts.map +0 -1
  115. package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +0 -1
  116. package/dist/components/charttooltip/ChartTooltip.d.ts.map +0 -1
  117. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +0 -23
  118. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +0 -1
  119. package/dist/components/globalhealthbar/GlobalHealthBar.component.js +0 -173
  120. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts.map +0 -1
  121. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts.map +0 -1
  122. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts.map +0 -1
  123. package/dist/components/globalhealthbar/healthBarUtils.d.ts.map +0 -1
  124. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts +0 -2
  125. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts.map +0 -1
  126. package/dist/components/globalhealthbar/healthBarUtils.spec.js +0 -391
  127. package/dist/components/globalhealthbar/tooltip/index.d.ts +0 -8
  128. package/dist/components/globalhealthbar/tooltip/index.d.ts.map +0 -1
  129. package/dist/components/globalhealthbar/tooltip/index.js +0 -55
  130. package/dist/components/globalhealthbar/useHealthBarData.d.ts.map +0 -1
  131. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts +0 -2
  132. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts.map +0 -1
  133. package/dist/components/globalhealthbar/useHealthBarData.spec.js +0 -209
  134. package/dist/components/linetemporalchart/ChartUtil.d.ts +0 -41
  135. package/dist/components/linetemporalchart/ChartUtil.d.ts.map +0 -1
  136. package/dist/components/linetemporalchart/ChartUtil.js +0 -148
  137. package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +0 -46
  138. package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +0 -1
  139. package/dist/components/linetemporalchart/LineTemporalChart.component.js +0 -579
  140. package/dist/components/linetemporalchart/MetricTimespanProvider.d.ts.map +0 -1
  141. package/dist/components/linetemporalchart/tooltip/index.d.ts +0 -30
  142. package/dist/components/linetemporalchart/tooltip/index.d.ts.map +0 -1
  143. package/dist/components/linetemporalchart/tooltip/index.js +0 -104
  144. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +0 -1
  145. package/dist/components/linetimeseriechart/utils.d.ts +0 -16
  146. package/dist/components/linetimeseriechart/utils.d.ts.map +0 -1
  147. package/dist/components/sparkline/sparkline.component.d.ts +0 -17
  148. package/dist/components/sparkline/sparkline.component.d.ts.map +0 -1
  149. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +0 -12
  150. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +0 -1
  151. package/dist/components/vegachartv2/SyncedCursorCharts.js +0 -15
  152. package/dist/components/vegachartv2/VegaChartV2.component.d.ts +0 -15
  153. package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +0 -1
  154. package/dist/components/vegachartv2/VegaChartV2.component.js +0 -218
  155. package/src/lib/components/barchart/BarChart.component.tsx +0 -51
  156. package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +0 -204
  157. package/src/lib/components/globalhealthbar/tooltip/index.ts +0 -72
  158. package/src/lib/components/linetemporalchart/ChartUtil.test.ts +0 -250
  159. package/src/lib/components/linetemporalchart/ChartUtil.ts +0 -225
  160. package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +0 -800
  161. package/src/lib/components/linetemporalchart/tooltip/index.ts +0 -178
  162. package/src/lib/components/sparkline/sparkline.component.tsx +0 -56
  163. package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +0 -28
  164. package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +0 -276
  165. package/stories/barchart.stories.tsx +0 -142
  166. package/stories/globalhealthbar.stories.tsx +0 -191
  167. package/stories/guideline/mdxExampleComponents.tsx +0 -57
  168. package/stories/linecharttemporal.stories.tsx +0 -88
  169. /package/dist/components/{linetemporalchart/MetricTimespanProvider.js → charts/MetricsTimeSpanProvider.js} +0 -0
  170. /package/dist/components/{globalhealthbar/useHealthBarData.js → charts/globalhealthbar/GlobalHealthBar.hooks.js} +0 -0
  171. /package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.d.ts +0 -0
  172. /package/dist/components/{chartlegend → charts/legend}/ChartLegendWrapper.js +0 -0
  173. /package/src/lib/components/{linetemporalchart/MetricTimespanProvider.tsx → charts/MetricsTimeSpanProvider.tsx} +0 -0
  174. /package/src/lib/components/{barchartv2 → charts/barchart}/BarchartTooltip.test.tsx +0 -0
  175. /package/src/lib/components/{globalhealthbar/useHealthBarData.ts → charts/globalhealthbar/GlobalHealthBar.hooks.ts} +0 -0
  176. /package/src/lib/components/{chartlegend → charts/legend}/ChartLegend.test.tsx +0 -0
  177. /package/src/lib/components/{chartlegend → charts/legend}/ChartLegendWrapper.test.tsx +0 -0
@@ -1,104 +0,0 @@
1
- // @ts-nocheck
2
- import { stringify } from 'vega-lite';
3
- import { Handler } from 'vega-tooltip';
4
- import { isArray, isObject, isString } from 'vega-util';
5
- import { spacing } from '../../../style/theme';
6
- export function defaultRenderTooltipSerie({ color, isLineDashed, name, value, key, }) {
7
- return `<tr>
8
- <td class="color">
9
- ${color !== undefined
10
- ? `<span style='background: ${isLineDashed
11
- ? `repeating-linear-gradient(to right,${color} 0,${color} ${spacing.sp1},transparent ${spacing.sp1},transparent ${spacing.sp2})`
12
- : color};width: ${spacing.sp8};height:${spacing.sp2};display: inline-block;vertical-align: middle;'></span>`
13
- : ''}
14
- </td>
15
- <td class="key" style="text-align: left;">
16
- ${name}
17
- </td>
18
- <td class="value" style="text-align: right;">
19
- ${value}
20
- </td>
21
- </tr>`;
22
- }
23
- export class TooltipHandlerWithPaint extends Handler {
24
- constructor(options, onHover) {
25
- super(options);
26
- this.prevCall = this.call;
27
- this.onHover = onHover;
28
- this.call = this.newCall.bind(this);
29
- }
30
- newCall(handler, event, item, value) {
31
- if (item &&
32
- this.onHover &&
33
- JSON.stringify(value) !== JSON.stringify(this.value)) {
34
- this.onHover(item.datum.datum);
35
- }
36
- this.handler = handler;
37
- this.event = event;
38
- this.item = item;
39
- this.value = value;
40
- this.prevCall(handler, event, item, value);
41
- }
42
- paint() {
43
- this.prevCall(this.handler, this.event, this.item, this.value);
44
- }
45
- }
46
- /**
47
- * Format the value to be shown in the tooltip.
48
- *
49
- * @param value The value to show in the tooltip.
50
- * @param valueToHtml Function to convert a single cell value to an HTML string
51
- */
52
- export function formatValue(series, customizedColorRange, colorRange, unitLabel, yAxisType, renderTooltipSerie = defaultRenderTooltipSerie) {
53
- return (value, valueToHtml, maxDepth) => {
54
- if (isArray(value)) {
55
- return `[${value
56
- .map((v) => valueToHtml(isString(v) ? v : stringify(v, maxDepth)))
57
- .join(', ')}]`;
58
- }
59
- if (isObject(value)) {
60
- let content = '';
61
- const { title, image, ...rest } = value;
62
- if (title) {
63
- content += `<h2 style="text-align: center;">${valueToHtml(title)}</h2>`;
64
- }
65
- if (image) {
66
- content += `<img src="${valueToHtml(image)}">`;
67
- }
68
- const keys = Object.keys(rest);
69
- if (keys.length > 0) {
70
- content += '<table>';
71
- for (const key of keys) {
72
- let val = rest[key];
73
- // ignore undefined properties
74
- if (val === undefined) {
75
- continue;
76
- }
77
- if (isObject(val)) {
78
- val = stringify(val, maxDepth);
79
- }
80
- const currentSerie = series.find((serie) => serie.getTooltipLabel(serie.metricPrefix, serie.resource) === key);
81
- const currentSerieIndex = series.findIndex((serie) => serie.getTooltipLabel(serie.metricPrefix, serie.resource) === key);
82
- const serieIndex = yAxisType === 'symmetrical' && !customizedColorRange.length // $FlowFixMe
83
- ? [...new Set(series.map((serie) => serie.resource))].findIndex((serieResource) => serieResource ===
84
- (currentSerie ? currentSerie.resource : null))
85
- : currentSerieIndex;
86
- const serieColorRange = customizedColorRange.length
87
- ? customizedColorRange
88
- : colorRange;
89
- content += renderTooltipSerie({
90
- key,
91
- color: serieIndex !== -1 ? serieColorRange[serieIndex] : undefined,
92
- isLineDashed: serieIndex !== -1 ? series[serieIndex].isLineDashed : undefined,
93
- name: valueToHtml(key),
94
- value: val !== 'NaN' ? `${valueToHtml(val)} ${unitLabel}` : '-',
95
- unitLabel,
96
- }, value);
97
- }
98
- content += `</table>`;
99
- }
100
- return content || '{}'; // show empty object if there are no properties
101
- }
102
- return valueToHtml(value);
103
- };
104
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"linetimeseriechart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAiD,MAAM,OAAO,CAAC;AAiCtE,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,QAAQ,CAAC,EAAE,MAAM,KACd,KAAK,CAAC,SAAS,CAAC;CACtB,CAAC;AAiHF,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,2CAgWhB"}
@@ -1,16 +0,0 @@
1
- export declare const ONE_YEAR_MILLISECONDS: number;
2
- export type ChartDataPoint = {
3
- timestamp: number;
4
- } & Record<string, number | null>;
5
- /**
6
- * Formats timestamp for X-axis labels based on time format and data range:
7
- * For 'date-time' format, return day-month-abbreviated-hour-minute format
8
- * For 'date' format, return YYYY-MM-DD format if time range is greater than 1 year, otherwise return MM-DD format
9
- *
10
- * @param timestamp - The timestamp to format in milliseconds
11
- * @param timeFormat - The format type ('date-time' or 'date')
12
- * @param chartData - The chart data to determine time range for optimal formatting
13
- * @returns Formatted string for display on X-axis
14
- */
15
- export declare const formatXAxisLabel: (timestamp: number, duration: number) => string;
16
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/utils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,QAA4B,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,cAChB,MAAM,YACP,MAAM,KACf,MAaF,CAAC"}
@@ -1,17 +0,0 @@
1
- type SparklineProps = {
2
- serie: {
3
- data: [number, number | null][];
4
- color?: string;
5
- };
6
- startingTimeStamp: number;
7
- sampleDuration: number;
8
- sampleInterval: number;
9
- yAxisType?: 'default' | 'percentage';
10
- };
11
- /**
12
- * Sparkline is a simple dynamically sized area chart.
13
- * Used to show trends in data over time.
14
- */
15
- export declare function Sparkline({ serie, startingTimeStamp, sampleDuration, sampleInterval, yAxisType }: SparklineProps): import("react/jsx-runtime").JSX.Element;
16
- export {};
17
- //# sourceMappingURL=sparkline.component.d.ts.map
@@ -1 +0,0 @@
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,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;CACtC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,cAAc,2CAkChH"}
@@ -1,12 +0,0 @@
1
- export declare const SyncedCursorChartsContext: import("react").Context<{
2
- cursorX: number;
3
- setCursorX: (cursorX: number) => void;
4
- } | null>;
5
- export declare const useCursorX: () => {
6
- cursorX: number;
7
- setCursorX: (cursorX: number) => void;
8
- } | null;
9
- export declare function SyncedCursorCharts({ children }: {
10
- children: JSX.Element;
11
- }): import("react/jsx-runtime").JSX.Element;
12
- //# sourceMappingURL=SyncedCursorCharts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SyncedCursorCharts.d.ts","sourceRoot":"","sources":["../../../src/lib/components/vegachartv2/SyncedCursorCharts.tsx"],"names":[],"mappings":"AACA,eAAO,MAAM,yBAAyB;aAC3B,MAAM;gBACH,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;SACxB,CAAC;AAChB,eAAO,MAAM,UAAU,QAAO;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,GAAG,IAQH,CAAC;AACF,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAA;CAAE,2CAUzE"}
@@ -1,15 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useState, createContext, useContext, useMemo } from 'react';
3
- export const SyncedCursorChartsContext = createContext(null);
4
- export const useCursorX = () => {
5
- const contextValue = useContext(SyncedCursorChartsContext);
6
- if (contextValue === null) {
7
- console.error("Can't use useCursorX() outside SyncedCursorCharts");
8
- }
9
- return contextValue;
10
- };
11
- export function SyncedCursorCharts({ children }) {
12
- const [cursorX, setCursorX] = useState(0);
13
- const contextValue = useMemo(() => ({ cursorX, setCursorX }), [cursorX]);
14
- return (_jsx(SyncedCursorChartsContext.Provider, { value: contextValue, children: children }));
15
- }
@@ -1,15 +0,0 @@
1
- import * as vega from 'vega';
2
- export declare const TOP = "top";
3
- export declare const BOTTOM = "bottom";
4
- type Position = typeof TOP | typeof BOTTOM;
5
- type Props = {
6
- spec: Record<string, any>;
7
- tooltipPosition?: Position;
8
- theme?: 'light' | 'dark' | 'custom';
9
- id?: string;
10
- onHover?: (dataPoint: any) => void;
11
- formatTooltip?: (value: any, valueToHtml: (value: any) => string, maxDepth: number) => string;
12
- };
13
- export declare const VegaChart: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<typeof vega.View>>;
14
- export {};
15
- //# sourceMappingURL=VegaChartV2.component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VegaChartV2.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/vegachartv2/VegaChartV2.component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAK7B,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,KAAK,QAAQ,GAAG,OAAO,GAAG,GAAG,OAAO,MAAM,CAAC;AAC3C,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,aAAa,CAAC,EAAE,CACd,KAAK,EAAE,GAAG,EACV,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,EACnC,QAAQ,EAAE,MAAM,KACb,MAAM,CAAC;CACb,CAAC;AA8PF,eAAO,MAAM,SAAS,oGAAgC,CAAC"}
@@ -1,218 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- // @ts-nocheck
3
- import { useEffect, useRef, useLayoutEffect, useMemo, forwardRef } from 'react';
4
- import * as vega from 'vega';
5
- import vegaEmbed from 'vega-embed';
6
- import { createGlobalStyle, css, useTheme } from 'styled-components';
7
- import { useCursorX, SyncedCursorChartsContext } from './SyncedCursorCharts';
8
- import { TooltipHandlerWithPaint } from '../linetemporalchart/tooltip';
9
- export const TOP = 'top';
10
- export const BOTTOM = 'bottom';
11
- /* How to theme tooltip:
12
- https://github.com/vega/vega-tooltip/blob/master/docs/customizing_your_tooltip.md
13
- */
14
- const VegaTooltipTheme = createGlobalStyle `
15
- #vg-tooltip-element.vg-tooltip.custom-theme {
16
- ${(props) => {
17
- const { theme } = props;
18
- return css `
19
- padding: 8px;
20
- position: fixed;
21
- z-index: 1000;
22
- width: calc(100vw / 6);
23
- font-family: 'Lato';
24
- font-size: 12px;
25
- border-radius: 3px;
26
- box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
27
- color: ${theme.textPrimary};
28
- background-color: ${theme.backgroundLevel1};
29
- border: 1px solid ${theme.border};
30
- // customize the title
31
- h2 {
32
- color: ${theme.textPrimary};
33
- margin-bottom: 10px;
34
- font-size: 12px;
35
- }
36
- table {
37
- width: 100%;
38
- }
39
- table tr td.key {
40
- color: ${theme.textSecondary};
41
- }
42
- `;
43
- }}
44
-
45
- }
46
- `;
47
- function VegaChartInternal({ spec, tooltipPosition = BOTTOM, theme = 'custom', formatTooltip, onHover, }, ref) {
48
- // $FlowFixMe
49
- const { cursorX, setCursorX } = useCursorX();
50
- const currentTheme = useTheme();
51
- const themeConfig = {
52
- config: {
53
- background: 'transparent',
54
- axis: {
55
- labelColor: currentTheme.textSecondary,
56
- titleColor: currentTheme.textSecondary,
57
- grid: false,
58
- domainColor: 'transparent',
59
- },
60
- title: {
61
- color: currentTheme.textPrimary,
62
- font: 'Lato',
63
- },
64
- view: {
65
- stroke: currentTheme.border,
66
- strokeWidth: 0.5,
67
- fill: currentTheme.backgroundLevel1,
68
- },
69
- // the headers provide a title and labels for faceted plots.
70
- header: {
71
- labelColor: currentTheme.textPrimary,
72
- },
73
- // the label of max/min
74
- text: {
75
- color: currentTheme.textPrimary,
76
- font: 'Lato',
77
- },
78
- legend: {
79
- labelColor: currentTheme.textSecondary,
80
- },
81
- },
82
- };
83
- const themedSpec = { ...spec, ...themeConfig };
84
- const vegaInstance = useRef();
85
- const vegaDOMInstance = useRef(null);
86
- let tooltipOptions = {
87
- theme: theme,
88
- formatTooltip: formatTooltip,
89
- };
90
- if (tooltipPosition === TOP) {
91
- tooltipOptions = {
92
- theme: theme,
93
- offsetX: -85,
94
- offsetY: -140,
95
- formatTooltip: formatTooltip,
96
- };
97
- }
98
- const tooltipHandler = useMemo(() => new TooltipHandlerWithPaint(tooltipOptions, onHover), [theme]);
99
- /*
100
- useEffect() and useEffectLayout():
101
- The first effect will only render once, to initalize the chart and add the event lisener.
102
- The second useEffectLayout is in charge of updating the chart when the `themedSpec` or `tooltipOptions` get updated.
103
- Note it's important to useEffectLayout for the performance.
104
- */
105
- useEffect(() => {
106
- let isMounted = true;
107
- // embed(el, spec[, opt]) the el can be a DOM element or CSS selector. https://github.com/vega/vega-embed
108
- vegaDOMInstance &&
109
- vegaDOMInstance.current &&
110
- vegaEmbed(vegaDOMInstance.current, themedSpec, {
111
- renderer: 'svg',
112
- // Override the DEFAULT_OPTIONS https://github.com/vega/vega-tooltip/blob/master/src/defaults.ts
113
- tooltip: tooltipHandler.call,
114
- /* Determines if action links
115
- ("Export as PNG/SVG", "View Source", "View Vega" (only for Vega-Lite), "Open in Vega Editor") are included with the embedded view.
116
- If the value is true, all action links will be shown and none if the value is false. */
117
- actions: false,
118
- })
119
- .then((result) => {
120
- vegaInstance.current = result;
121
- // result.view contains the Vega view
122
- // get the current state of view: result.view.getState()
123
- const view = result.view;
124
- if (ref) {
125
- ref.current = view;
126
- }
127
- if (SyncedCursorChartsContext && view) {
128
- view.addEventListener('mouseover', function (event, item) {
129
- const currentTime = item &&
130
- item.datum &&
131
- item.datum.datum &&
132
- item.datum.datum.timestamp;
133
- if (currentTime) {
134
- setCursorX(currentTime);
135
- }
136
- });
137
- /*When the mouse leaves the chart area, set the cursorX to null*/
138
- view.addEventListener('mouseleave', function (event, item) {
139
- setCursorX(0);
140
- });
141
- }
142
- })
143
- .catch((...args) => {
144
- if (isMounted) {
145
- console.error(...args); // TODO: we should handle this with a retry or an error state of the component
146
- }
147
- });
148
- return () => {
149
- isMounted = false;
150
- if (vegaInstance.current) {
151
- vegaInstance.current.view.finalize();
152
- }
153
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
154
- }, [vegaDOMInstance, currentTheme]);
155
- useLayoutEffect(() => {
156
- if (vegaInstance.current) {
157
- const view = vegaInstance.current.view;
158
- tooltipHandler.options.formatTooltip = formatTooltip;
159
- tooltipHandler.onHover = onHover;
160
- view.tooltip(tooltipHandler.call).run();
161
- tooltipHandler.paint(); // to repaint the tooltip
162
- }
163
- }, [formatTooltip, vegaInstance, onHover]);
164
- useLayoutEffect(() => {
165
- if (vegaInstance.current) {
166
- const view = vegaInstance.current.view;
167
- let changeset = vega
168
- .changeset()
169
- .remove(() => true)
170
- .insert(themedSpec.data.values);
171
- //only the data.values changes trigger the graph's repaint
172
- // For some reason source_0 is the default dataset name
173
- view
174
- .change('source_0', changeset)
175
- .runAsync()
176
- .then(() => {
177
- // call resize() after the data is loaded to make sure the width is set correctly.
178
- view.resize().runAsync();
179
- });
180
- } // eslint-disable-next-line react-hooks/exhaustive-deps
181
- }, [
182
- // eslint-disable-next-line
183
- JSON.stringify(themedSpec.data.values),
184
- vegaInstance,
185
- ]);
186
- useLayoutEffect(() => {
187
- if (vegaInstance.current && themedSpec.params) {
188
- const view = vegaInstance.current.view;
189
- // when the mouse go out, we trigger the event to set cursorX to null
190
- if (!themedSpec.params.find((param) => param.name === 'cursorX').value ||
191
- !cursorX) {
192
- view
193
- .signal('cursorX', (themedSpec &&
194
- themedSpec.data &&
195
- themedSpec.data.values &&
196
- themedSpec.data.values[0] &&
197
- themedSpec.data.values[0].timestamp) ||
198
- Date.now())
199
- .run();
200
- view.signal('isCursorDisplayed', false).run();
201
- }
202
- else {
203
- view
204
- .signal('cursorX', themedSpec.params.find((param) => param.name === 'cursorX').value)
205
- .run();
206
- view.signal('isCursorDisplayed', true).run();
207
- }
208
- } // eslint-disable-next-line react-hooks/exhaustive-deps
209
- }, [
210
- // eslint-disable-next-line
211
- JSON.stringify(themedSpec),
212
- vegaInstance,
213
- ]);
214
- return (_jsx("div", { className: "sc-vegachart", ref: vegaDOMInstance, style: {
215
- width: '100%',
216
- }, children: _jsx(VegaTooltipTheme, {}) }));
217
- } // @ts-expect-error
218
- export const VegaChart = forwardRef(VegaChartInternal);
@@ -1,51 +0,0 @@
1
- import { VegaChart } from '../vegachartv2/VegaChartV2.component';
2
- type Props = {
3
- id: string;
4
- data: Array<Record<string, any>>;
5
- xAxis: Record<string, any>;
6
- yAxis: Record<string, any>;
7
- color?: Record<string, any>;
8
- height?: number;
9
- barConfig?: Record<string, any>;
10
- };
11
-
12
- /**
13
- * @deprecated Use Barchart v2 instead
14
- * @example import { Barchart } from '@scality/core-ui/dist/next';
15
-
16
- */
17
- function BarChart({
18
- id,
19
- data,
20
- xAxis,
21
- yAxis,
22
- color,
23
- height = 200,
24
- barConfig,
25
- }: Props) {
26
- const spec = {
27
- mark: {
28
- type: 'bar',
29
- ...barConfig,
30
- },
31
- width: 'container',
32
- height,
33
- data: {
34
- values: data,
35
- },
36
- encoding: {
37
- x: xAxis,
38
- y: yAxis,
39
- color,
40
- },
41
- };
42
- return (
43
- <VegaChart
44
- key={`barchart-${id}-${data.length}`}
45
- id={id}
46
- spec={spec}
47
- ></VegaChart>
48
- );
49
- }
50
-
51
- export { BarChart };
@@ -1,204 +0,0 @@
1
- // @ts-nocheck
2
- import { useMemo } from 'react';
3
- import { VegaChart } from '../vegachartv2/VegaChartV2.component';
4
- import { useTheme } from 'styled-components';
5
- import { formatValue } from './tooltip/index';
6
- export const TOP = 'top';
7
- export const BOTTOM = 'bottom';
8
- type Position = typeof TOP | typeof BOTTOM;
9
- export type GlobalHealthProps = {
10
- id: string;
11
- alerts: {
12
- description: string;
13
- startsAt: string;
14
- endsAt: string;
15
- severity: string;
16
- }[];
17
- start: string;
18
- end: string;
19
- height?: number;
20
- tooltipPosition?: Position;
21
- };
22
- /**
23
- * @deprecated Use GlobalHealthBar v2 instead
24
- * @example import { GlobalHealthBar } from '@scality/core-ui/dist/next';
25
- */
26
- function GlobalHealthBar({
27
- id,
28
- alerts,
29
- start,
30
- end,
31
- height = 8,
32
- tooltipPosition = TOP,
33
- }: GlobalHealthProps) {
34
- const theme = useTheme();
35
- const trimAlerts = alerts.map((alert) => {
36
- if (new Date(alert.startsAt) < new Date(start)) {
37
- return { ...alert, startsAt: start };
38
- }
39
-
40
- return { ...alert };
41
- });
42
- trimAlerts.unshift({
43
- startsAt: start,
44
- endsAt: end,
45
- severity: 'healthy',
46
- });
47
- const spec = {
48
- width: 'container',
49
- height,
50
- data: {
51
- values: trimAlerts,
52
- },
53
- transform: [
54
- {
55
- calculate:
56
- "datum.description !== '' ? 'View details on alert page' : ''",
57
- as: 'title',
58
- },
59
- ],
60
- view: {
61
- cornerRadius: 6,
62
- },
63
- config: {
64
- style: {
65
- cell: {
66
- stroke: 'transparent',
67
- strokeWidth: 0,
68
- },
69
- },
70
- },
71
- layer: [
72
- // Paint the entire bar with green
73
- {
74
- mark: {
75
- type: 'rect',
76
- clip: true,
77
- },
78
- encoding: {
79
- color: {
80
- value: theme.statusHealthy,
81
- },
82
- },
83
- }, // Paint the timespan as x-axis
84
- {
85
- mark: {
86
- type: 'rect',
87
- cursor: 'pointer',
88
- clip: true,
89
- },
90
- encoding: {
91
- x: {
92
- field: 'startsAt',
93
- type: 'temporal',
94
- title: null,
95
- stack: null,
96
- axis: {
97
- format: '%d%b %H:%M:%S',
98
- ticks: true,
99
- tickCount: 5,
100
- //A desired number of ticks, for axes visualizing quantitative scales. The resulting number may be different so that values are “nice” (multiples of 2, 5, 10) and lie within the underlying scale’s range.
101
- labelFlush: 20,
102
- labelColor: theme.textSecondary,
103
- },
104
- },
105
- x2: {
106
- field: 'endsAt',
107
- },
108
- color: {
109
- value: theme.statusHealthy,
110
- },
111
- },
112
- },
113
- {
114
- mark: {
115
- type: 'rect',
116
- tooltip: true,
117
- cursor: 'pointer',
118
- clip: true,
119
- },
120
- params: [
121
- {
122
- name: 'highlight',
123
- // The supported DOM event types for mark items are https://vega.github.io/vega/docs/event-streams/
124
- select: {
125
- type: 'point',
126
- on: 'mouseover',
127
- clear: 'mouseout',
128
- },
129
- },
130
- ],
131
- encoding: {
132
- x: {
133
- timeUnit: 'yearmonthdatehoursminutes',
134
- field: 'startsAt',
135
- type: 'temporal',
136
- title: null,
137
- },
138
- x2: {
139
- field: 'endsAt',
140
- },
141
- color: {
142
- field: 'severity',
143
- type: 'nominal',
144
- title: 'null',
145
- scale: {
146
- domain: ['healthy', 'critical', 'unavailable', 'warning'],
147
- range: [
148
- theme.statusHealthy,
149
- theme.statusCritical,
150
- theme.textSecondary,
151
- theme.statusWarning,
152
- ],
153
- },
154
- legend: null,
155
- },
156
- tooltip: [
157
- {
158
- field: 'severity',
159
- title: 'Severity',
160
- },
161
- {
162
- field: 'startsAt',
163
- title: 'Start',
164
- type: 'temporal',
165
- timeUnit: 'yearmonthdatehoursminutes',
166
- },
167
- {
168
- field: 'endsAt',
169
- title: 'End',
170
- type: 'temporal',
171
- timeUnit: 'yearmonthdatehoursminutes',
172
- },
173
- {
174
- field: 'title',
175
- title: 'title',
176
- },
177
- {
178
- field: 'description',
179
- title: 'Description',
180
- },
181
- ],
182
- opacity: {
183
- condition: {
184
- param: 'highlight',
185
- value: 1,
186
- },
187
- value: 0.6,
188
- },
189
- },
190
- },
191
- ],
192
- };
193
- return (
194
- <VegaChart
195
- className="sc-globalhealthbar"
196
- spec={spec}
197
- theme={'custom'}
198
- tooltipPosition={tooltipPosition}
199
- formatTooltip={useMemo(() => formatValue(), [])}
200
- ></VegaChart>
201
- );
202
- }
203
-
204
- export { GlobalHealthBar };