@cere/cere-design-system 0.1.0 → 0.2.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 (165) hide show
  1. package/README.md +76 -0
  2. package/dist/buttons.d.mts +27 -22
  3. package/dist/buttons.d.ts +27 -22
  4. package/dist/buttons.js +5 -5
  5. package/dist/buttons.mjs +4 -4
  6. package/dist/charts.d.mts +1 -23
  7. package/dist/charts.d.ts +1 -23
  8. package/dist/charts.js +2 -9
  9. package/dist/charts.js.map +1 -1
  10. package/dist/charts.mjs +1 -8
  11. package/dist/{chunk-THQKYTQE.js → chunk-2KDN37PQ.js} +28 -32
  12. package/dist/chunk-2KDN37PQ.js.map +1 -0
  13. package/dist/{chunk-3WCMINE5.mjs → chunk-34LFXT6C.mjs} +25 -29
  14. package/dist/chunk-34LFXT6C.mjs.map +1 -0
  15. package/dist/chunk-3KCXCVOX.mjs +411 -0
  16. package/dist/chunk-3KCXCVOX.mjs.map +1 -0
  17. package/dist/{chunk-NXTVJ6PY.js → chunk-4OKTICU5.js} +10 -10
  18. package/dist/chunk-4OKTICU5.js.map +1 -0
  19. package/dist/{chunk-FN5YL4BK.js → chunk-72TQ56EP.js} +47 -45
  20. package/dist/chunk-72TQ56EP.js.map +1 -0
  21. package/dist/{chunk-QYYQYZHV.js → chunk-7KXKK2RE.js} +3 -5
  22. package/dist/chunk-7KXKK2RE.js.map +1 -0
  23. package/dist/{chunk-CCN6M4LI.js → chunk-ARSCL4ZZ.js} +18 -10
  24. package/dist/chunk-ARSCL4ZZ.js.map +1 -0
  25. package/dist/chunk-AWVNEU6R.mjs +1478 -0
  26. package/dist/chunk-AWVNEU6R.mjs.map +1 -0
  27. package/dist/{chunk-CUCKULYC.mjs → chunk-BH4FNZKK.mjs} +74 -1260
  28. package/dist/chunk-BH4FNZKK.mjs.map +1 -0
  29. package/dist/{chunk-FFZ5S7PQ.mjs → chunk-BOQPWZIB.mjs} +6 -5
  30. package/dist/chunk-BOQPWZIB.mjs.map +1 -0
  31. package/dist/chunk-BT7XUTT5.mjs +392 -0
  32. package/dist/chunk-BT7XUTT5.mjs.map +1 -0
  33. package/dist/{chunk-ATIFLPH6.mjs → chunk-D7D25O6E.mjs} +4 -2
  34. package/dist/{chunk-ATIFLPH6.mjs.map → chunk-D7D25O6E.mjs.map} +1 -1
  35. package/dist/{chunk-JS4IB5IU.mjs → chunk-DRGMEIPT.mjs} +2 -2
  36. package/dist/chunk-DRGMEIPT.mjs.map +1 -0
  37. package/dist/{chunk-KF2Y7HO3.js → chunk-DZXNYLVG.js} +43 -246
  38. package/dist/chunk-DZXNYLVG.js.map +1 -0
  39. package/dist/{chunk-IE6GCHDI.mjs → chunk-GR52ENYI.mjs} +26 -29
  40. package/dist/chunk-GR52ENYI.mjs.map +1 -0
  41. package/dist/chunk-GTBKQXXI.js +1472 -0
  42. package/dist/chunk-GTBKQXXI.js.map +1 -0
  43. package/dist/{chunk-463SRKKD.js → chunk-HJ24WKU4.js} +14 -5
  44. package/dist/chunk-HJ24WKU4.js.map +1 -0
  45. package/dist/{chunk-EOF3QNPF.js → chunk-KKIKOIMP.js} +140 -1028
  46. package/dist/chunk-KKIKOIMP.js.map +1 -0
  47. package/dist/{chunk-MNM6HE72.js → chunk-LVJSKRX3.js} +16 -15
  48. package/dist/chunk-LVJSKRX3.js.map +1 -0
  49. package/dist/{chunk-KPDYKK3V.js → chunk-PFZZJZ64.js} +8 -8
  50. package/dist/{chunk-KPDYKK3V.js.map → chunk-PFZZJZ64.js.map} +1 -1
  51. package/dist/{chunk-KVBMZNWT.mjs → chunk-POCAW2G4.mjs} +18 -10
  52. package/dist/chunk-POCAW2G4.mjs.map +1 -0
  53. package/dist/{chunk-L2TIGA7I.js → chunk-QCFLZ7X3.js} +39 -42
  54. package/dist/chunk-QCFLZ7X3.js.map +1 -0
  55. package/dist/{chunk-6EUAU67C.mjs → chunk-SG2TD7FQ.mjs} +8 -8
  56. package/dist/chunk-SG2TD7FQ.mjs.map +1 -0
  57. package/dist/{chunk-QY65OUAC.mjs → chunk-SSFALO6S.mjs} +13 -4
  58. package/dist/chunk-SSFALO6S.mjs.map +1 -0
  59. package/dist/{chunk-PWF2NJDB.mjs → chunk-WC2TCWXK.mjs} +82 -14
  60. package/dist/chunk-WC2TCWXK.mjs.map +1 -0
  61. package/dist/{chunk-ZGCN5WCG.js → chunk-XZZZ4MZV.js} +83 -15
  62. package/dist/chunk-XZZZ4MZV.js.map +1 -0
  63. package/dist/chunk-YCDCQSYH.js +411 -0
  64. package/dist/chunk-YCDCQSYH.js.map +1 -0
  65. package/dist/{chunk-CWJ4OU6W.mjs → chunk-ZDAZYIXB.mjs} +2 -4
  66. package/dist/chunk-ZDAZYIXB.mjs.map +1 -0
  67. package/dist/feedback.d.mts +20 -8
  68. package/dist/feedback.d.ts +20 -8
  69. package/dist/feedback.js +5 -5
  70. package/dist/feedback.mjs +4 -4
  71. package/dist/fonts/HumanSans-BlackOblique.otf +0 -0
  72. package/dist/fonts/HumanSans-Thin.otf +0 -0
  73. package/dist/fonts/HumanSans-ThinOblique.otf +0 -0
  74. package/dist/fonts/human-sans-font.css +88 -0
  75. package/dist/fonts/human-sans.css +3 -0
  76. package/dist/fonts/inter.css +3 -0
  77. package/dist/icons.d.mts +2 -3
  78. package/dist/icons.d.ts +2 -3
  79. package/dist/icons.js +2 -2
  80. package/dist/icons.mjs +1 -1
  81. package/dist/index.d.mts +37 -8
  82. package/dist/index.d.ts +37 -8
  83. package/dist/index.js +23 -90
  84. package/dist/index.js.map +1 -1
  85. package/dist/index.mjs +46 -113
  86. package/dist/index.mjs.map +1 -1
  87. package/dist/inputs.d.mts +23 -3
  88. package/dist/inputs.d.ts +23 -3
  89. package/dist/inputs.js +5 -5
  90. package/dist/inputs.js.map +1 -1
  91. package/dist/inputs.mjs +15 -15
  92. package/dist/layout.d.mts +37 -283
  93. package/dist/layout.d.ts +37 -283
  94. package/dist/layout.js +8 -32
  95. package/dist/layout.js.map +1 -1
  96. package/dist/layout.mjs +16 -40
  97. package/dist/navigation.d.mts +9 -114
  98. package/dist/navigation.d.ts +9 -114
  99. package/dist/navigation.js +5 -9
  100. package/dist/navigation.js.map +1 -1
  101. package/dist/navigation.mjs +6 -10
  102. package/dist/third-party.d.mts +3 -527
  103. package/dist/third-party.d.ts +3 -527
  104. package/dist/third-party.js +2 -40
  105. package/dist/third-party.js.map +1 -1
  106. package/dist/third-party.mjs +3 -41
  107. package/dist/tokens.css +45 -71
  108. package/dist/utilities.js +2 -4
  109. package/dist/utilities.js.map +1 -1
  110. package/dist/utilities.mjs +2 -4
  111. package/package.json +23 -9
  112. package/dist/WorkflowNode-BnxXO6t_.d.mts +0 -46
  113. package/dist/WorkflowNode-BnxXO6t_.d.ts +0 -46
  114. package/dist/chunk-27JEWSWA.mjs +0 -233
  115. package/dist/chunk-27JEWSWA.mjs.map +0 -1
  116. package/dist/chunk-3WCMINE5.mjs.map +0 -1
  117. package/dist/chunk-463SRKKD.js.map +0 -1
  118. package/dist/chunk-6EUAU67C.mjs.map +0 -1
  119. package/dist/chunk-AIY6222Q.js +0 -11
  120. package/dist/chunk-AIY6222Q.js.map +0 -1
  121. package/dist/chunk-AJBM7IE6.mjs +0 -2366
  122. package/dist/chunk-AJBM7IE6.mjs.map +0 -1
  123. package/dist/chunk-CCN6M4LI.js.map +0 -1
  124. package/dist/chunk-CUCKULYC.mjs.map +0 -1
  125. package/dist/chunk-CWJ4OU6W.mjs.map +0 -1
  126. package/dist/chunk-EOF3QNPF.js.map +0 -1
  127. package/dist/chunk-FFZ5S7PQ.mjs.map +0 -1
  128. package/dist/chunk-FN5YL4BK.js.map +0 -1
  129. package/dist/chunk-HLH2VWXL.js +0 -2658
  130. package/dist/chunk-HLH2VWXL.js.map +0 -1
  131. package/dist/chunk-IE6GCHDI.mjs.map +0 -1
  132. package/dist/chunk-JS4IB5IU.mjs.map +0 -1
  133. package/dist/chunk-KF2Y7HO3.js.map +0 -1
  134. package/dist/chunk-KVBMZNWT.mjs.map +0 -1
  135. package/dist/chunk-L2TIGA7I.js.map +0 -1
  136. package/dist/chunk-MNM6HE72.js.map +0 -1
  137. package/dist/chunk-NXTVJ6PY.js.map +0 -1
  138. package/dist/chunk-PWF2NJDB.mjs.map +0 -1
  139. package/dist/chunk-QD6RLAO2.mjs +0 -11
  140. package/dist/chunk-QD6RLAO2.mjs.map +0 -1
  141. package/dist/chunk-QY65OUAC.mjs.map +0 -1
  142. package/dist/chunk-QYYQYZHV.js.map +0 -1
  143. package/dist/chunk-T7LPABOL.mjs +0 -595
  144. package/dist/chunk-T7LPABOL.mjs.map +0 -1
  145. package/dist/chunk-THQKYTQE.js.map +0 -1
  146. package/dist/chunk-X7E6GMFL.js +0 -233
  147. package/dist/chunk-X7E6GMFL.js.map +0 -1
  148. package/dist/chunk-XF66WQZE.mjs +0 -1535
  149. package/dist/chunk-XF66WQZE.mjs.map +0 -1
  150. package/dist/chunk-YQOZPLTY.js +0 -1535
  151. package/dist/chunk-YQOZPLTY.js.map +0 -1
  152. package/dist/chunk-ZGCN5WCG.js.map +0 -1
  153. package/dist/index.css +0 -79
  154. package/dist/index.css.map +0 -1
  155. /package/dist/{HumanSans-Black-C4YJONK7.otf → fonts/HumanSans-Black.otf} +0 -0
  156. /package/dist/{HumanSans-Bold-4EAJ3L3T.otf → fonts/HumanSans-Bold.otf} +0 -0
  157. /package/dist/{HumanSans-BoldOblique-4D325T4F.otf → fonts/HumanSans-BoldOblique.otf} +0 -0
  158. /package/dist/{HumanSans-ExtraLight-VL7DEKQ4.otf → fonts/HumanSans-ExtraLight.otf} +0 -0
  159. /package/dist/{HumanSans-ExtraLightOblique-VK2JTUXF.otf → fonts/HumanSans-ExtraLightOblique.otf} +0 -0
  160. /package/dist/{HumanSans-Light-YV7AFKRB.otf → fonts/HumanSans-Light.otf} +0 -0
  161. /package/dist/{HumanSans-LightOblique-VIXV7QA6.otf → fonts/HumanSans-LightOblique.otf} +0 -0
  162. /package/dist/{HumanSans-Medium-UULJ3PIR.otf → fonts/HumanSans-Medium.otf} +0 -0
  163. /package/dist/{HumanSans-MediumOblique-M7FHDZRS.otf → fonts/HumanSans-MediumOblique.otf} +0 -0
  164. /package/dist/{HumanSans-Regular-QMFEP3F6.otf → fonts/HumanSans-Regular.otf} +0 -0
  165. /package/dist/{HumanSans-RegularOblique-YPKQJAAM.otf → fonts/HumanSans-RegularOblique.otf} +0 -0
@@ -1,595 +0,0 @@
1
- import {
2
- BytesSize
3
- } from "./chunk-QD6RLAO2.mjs";
4
- import {
5
- deploymentSurfaceTokens
6
- } from "./chunk-ATIFLPH6.mjs";
7
-
8
- // src/components/charts/ChartWidget/ChartWidget.tsx
9
- import { Box, Stack, Typography, styled, useTheme } from "@mui/material";
10
- import { LineChart } from "@mui/x-charts";
11
- import size from "byte-size";
12
- import { format } from "date-fns";
13
- import { jsx, jsxs } from "react/jsx-runtime";
14
- var Chart = styled(Box)(() => ({
15
- height: 200
16
- }));
17
- var ChartWidget = ({
18
- title,
19
- value,
20
- history,
21
- formatValue = (value2) => size(value2 || 0).toString()
22
- }) => {
23
- const theme = useTheme();
24
- return /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
25
- /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: title }),
26
- /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: value }),
27
- /* @__PURE__ */ jsx(Chart, { children: /* @__PURE__ */ jsx(
28
- LineChart,
29
- {
30
- dataset: history || [],
31
- axisHighlight: { x: "none", y: "none" },
32
- grid: { horizontal: true, vertical: false },
33
- margin: { top: 10, right: 20, bottom: 40, left: 40 },
34
- colors: [theme.palette.primary.main],
35
- slots: {
36
- noDataOverlay: () => null
37
- },
38
- yAxis: [
39
- {
40
- dataKey: "value",
41
- disableLine: true,
42
- disableTicks: true,
43
- min: history?.length ? void 0 : 0,
44
- max: history?.length ? void 0 : 100,
45
- tickNumber: history?.length ? void 0 : 5,
46
- valueFormatter: (value2) => formatValue(value2 || 0),
47
- tickLabelStyle: {
48
- fontSize: 10
49
- }
50
- }
51
- ],
52
- xAxis: [
53
- {
54
- dataKey: "date",
55
- min: history && Math.min(...history.map((record) => +record.date)),
56
- max: history && Math.max(...history.map((record) => +record.date)),
57
- disableLine: true,
58
- disableTicks: true,
59
- valueFormatter: (date) => format(date, "do MMM"),
60
- tickPlacement: "end",
61
- tickNumber: 1,
62
- tickLabelStyle: {
63
- fontSize: 10,
64
- transform: "translate(-16px, 16px) rotate(-30deg)"
65
- }
66
- }
67
- ],
68
- series: [
69
- {
70
- curve: "linear",
71
- dataKey: "value",
72
- showMark: false,
73
- valueFormatter: (value2) => formatValue(value2 || 0)
74
- }
75
- ]
76
- }
77
- ) })
78
- ] });
79
- };
80
-
81
- // src/components/charts/MetricsChart/MetricsChart.tsx
82
- import { format as format2, startOfDay, subHours, subWeeks, subMonths } from "date-fns";
83
- import { LineChart as LineChart2 } from "@mui/x-charts";
84
- import { useDrawingArea, useYScale } from "@mui/x-charts/hooks";
85
- import { Box as Box2, Card, CardHeader, CardMedia, Divider, Stack as Stack2, styled as styled2, Typography as Typography2, useTheme as useTheme2 } from "@mui/material";
86
-
87
- // src/components/charts/MetricsChart/PeriodSelect.tsx
88
- import { MenuItem, TextField } from "@mui/material";
89
- import { jsx as jsx2 } from "react/jsx-runtime";
90
- var options = [
91
- /**
92
- * TODO: Enable the options below when the backend supports them
93
- */
94
- // { value: 'hour', label: 'Last hour' },
95
- // { value: 'day', label: '24 hours' },
96
- { value: "week", label: "1 week" },
97
- { value: "month", label: "1 month" }
98
- ];
99
- var PeriodSelect = ({ value, onChange }) => /* @__PURE__ */ jsx2(
100
- TextField,
101
- {
102
- select: true,
103
- size: "small",
104
- value,
105
- defaultValue: options[0].value,
106
- onChange: (e) => onChange?.(e.target.value),
107
- children: options.map(({ value: value2, label }) => /* @__PURE__ */ jsx2(MenuItem, { value: value2, children: label }, value2))
108
- }
109
- );
110
-
111
- // src/components/charts/MetricsChart/MetricsChart.tsx
112
- import { useMemo, useState } from "react";
113
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
114
- var mapPeriodToFromDate = (period = "month") => {
115
- const date = /* @__PURE__ */ new Date();
116
- if (period === "hour") {
117
- return subHours(date, 1);
118
- }
119
- if (period === "day") {
120
- return subHours(date, 24);
121
- }
122
- if (period === "week") {
123
- return startOfDay(subWeeks(date, 1));
124
- }
125
- return startOfDay(subMonths(date, 1));
126
- };
127
- var Chart2 = styled2(LineChart2)({
128
- height: 320,
129
- marginBottom: 16
130
- });
131
- var NoDataRect = styled2("rect")({
132
- fill: deploymentSurfaceTokens.highlightBg
133
- });
134
- var LoadingText = styled2("text")(({ theme }) => ({
135
- stroke: "none",
136
- fill: theme.palette.text.primary,
137
- shapeRendering: "crispEdges",
138
- textAnchor: "middle",
139
- dominantBaseline: "middle"
140
- }));
141
- var MetricsChart = ({ history = [] }) => {
142
- const theme = useTheme2();
143
- const [period, setPeriod] = useState("week");
144
- const periodFrom = useMemo(() => mapPeriodToFromDate(period), [period]);
145
- const periodHistory = useMemo(
146
- () => history.filter((record) => record.recordTime > periodFrom),
147
- [history, periodFrom]
148
- );
149
- const total = useMemo(
150
- () => periodHistory.reduce(
151
- (acc, record) => ({
152
- gets: acc.gets + record.gets,
153
- puts: acc.puts + record.puts,
154
- storedBytes: acc.storedBytes + record.storedBytes,
155
- transferredBytes: acc.transferredBytes + record.transferredBytes
156
- }),
157
- { gets: 0, puts: 0, storedBytes: 0, transferredBytes: 0 }
158
- ),
159
- [periodHistory]
160
- );
161
- const NoDataOverlay = () => {
162
- const yScale = useYScale();
163
- const { left, width, height } = useDrawingArea();
164
- const [, top] = yScale.range();
165
- const padding = { top: 8, bottom: 8, left: 20, right: 20 };
166
- const text = "No data for selected period";
167
- const textWidth = 211;
168
- const textHeight = 24;
169
- const backgroundWidth = textWidth + padding.left + padding.right;
170
- const backgroundHeight = textHeight + padding.top + padding.bottom;
171
- const rectX = left + (width - backgroundWidth) / 2;
172
- const rectY = top + (height - backgroundHeight) / 2;
173
- return /* @__PURE__ */ jsxs2("g", { children: [
174
- /* @__PURE__ */ jsx3(NoDataRect, { x: rectX, y: rectY, width: backgroundWidth, height: backgroundHeight }),
175
- /* @__PURE__ */ jsx3(LoadingText, { style: { ...theme.typography.subtitle1 }, x: left + width / 2, y: top + height / 2, children: text })
176
- ] });
177
- };
178
- return /* @__PURE__ */ jsxs2(Card, { children: [
179
- /* @__PURE__ */ jsx3(CardHeader, { title: "GET / PUT Requests", action: /* @__PURE__ */ jsx3(PeriodSelect, { value: period, onChange: setPeriod }) }),
180
- /* @__PURE__ */ jsxs2(CardMedia, { children: [
181
- /* @__PURE__ */ jsx3(
182
- Chart2,
183
- {
184
- skipAnimation: true,
185
- dataset: periodHistory || [],
186
- axisHighlight: { x: "none", y: "none" },
187
- grid: { horizontal: true, vertical: false },
188
- margin: { top: 10, right: 20, bottom: 40, left: 40 },
189
- colors: [theme.palette.primary.main, theme.palette.success.main],
190
- slots: {
191
- noDataOverlay: NoDataOverlay
192
- },
193
- slotProps: {
194
- noDataOverlay: {
195
- style: {
196
- ...theme.typography.h4
197
- }
198
- }
199
- },
200
- yAxis: periodHistory.length ? [
201
- {
202
- min: periodHistory.length ? void 0 : 0,
203
- max: periodHistory.length ? void 0 : 100,
204
- tickNumber: periodHistory.length ? void 0 : 5,
205
- disableLine: true,
206
- disableTicks: true,
207
- tickLabelStyle: {
208
- fontSize: 10
209
- }
210
- }
211
- ] : [],
212
- xAxis: [
213
- {
214
- dataKey: "recordTime",
215
- min: periodFrom,
216
- max: /* @__PURE__ */ new Date(),
217
- disableLine: false,
218
- disableTicks: false,
219
- valueFormatter: (date) => format2(date, "do MMM"),
220
- tickMinStep: 3600 * 1e3 * 24,
221
- // min step: 24h
222
- tickLabelStyle: {
223
- fontSize: 10,
224
- transform: "translate(-16px, 16px) rotate(-30deg)"
225
- }
226
- }
227
- ],
228
- series: [
229
- {
230
- curve: "linear",
231
- dataKey: "gets",
232
- showMark: false
233
- },
234
- {
235
- curve: "linear",
236
- dataKey: "puts",
237
- showMark: false
238
- }
239
- ]
240
- }
241
- ),
242
- periodHistory.length > 0 && /* @__PURE__ */ jsxs2(Stack2, { direction: "row", spacing: 2, marginY: 3, justifyContent: "center", children: [
243
- /* @__PURE__ */ jsxs2(Stack2, { direction: "row", spacing: 1, alignItems: "center", children: [
244
- /* @__PURE__ */ jsx3(Box2, { sx: { width: 14, height: 14, borderRadius: "4px", backgroundColor: theme.palette.primary.main } }),
245
- /* @__PURE__ */ jsx3(Typography2, { variant: "body2", children: "Get" })
246
- ] }),
247
- /* @__PURE__ */ jsxs2(Stack2, { direction: "row", spacing: 1, alignItems: "center", children: [
248
- /* @__PURE__ */ jsx3(Box2, { sx: { width: 14, height: 14, borderRadius: "4px", backgroundColor: theme.palette.success.main } }),
249
- /* @__PURE__ */ jsx3(Typography2, { variant: "body2", children: "Put" })
250
- ] })
251
- ] })
252
- ] }),
253
- /* @__PURE__ */ jsxs2(CardMedia, { children: [
254
- /* @__PURE__ */ jsx3(Divider, { flexItem: true }),
255
- /* @__PURE__ */ jsxs2(Stack2, { direction: "row", spacing: 2, padding: 2, children: [
256
- /* @__PURE__ */ jsxs2(Stack2, { direction: "row", alignItems: "center", spacing: 1, children: [
257
- /* @__PURE__ */ jsx3(Typography2, { variant: "body2", color: "secondary", children: "GET Requests per account" }),
258
- /* @__PURE__ */ jsx3(Typography2, { variant: "h3", children: total.gets })
259
- ] }),
260
- /* @__PURE__ */ jsxs2(Stack2, { direction: "row", alignItems: "center", spacing: 1, children: [
261
- /* @__PURE__ */ jsx3(Typography2, { variant: "body2", color: "secondary", children: "PUT Requests per account" }),
262
- /* @__PURE__ */ jsx3(Typography2, { variant: "h3", children: total.puts })
263
- ] }),
264
- /* @__PURE__ */ jsxs2(Stack2, { direction: "row", alignItems: "center", spacing: 1, children: [
265
- /* @__PURE__ */ jsx3(Typography2, { variant: "body2", color: "secondary", children: "Total Consumed per account" }),
266
- /* @__PURE__ */ jsx3(Typography2, { variant: "h3", children: /* @__PURE__ */ jsx3(BytesSize, { bytes: total.transferredBytes }) })
267
- ] }),
268
- /* @__PURE__ */ jsxs2(Stack2, { direction: "row", alignItems: "center", spacing: 1, children: [
269
- /* @__PURE__ */ jsx3(Typography2, { variant: "body2", color: "secondary", children: "Total Stored per account" }),
270
- /* @__PURE__ */ jsx3(Typography2, { variant: "h3", children: /* @__PURE__ */ jsx3(BytesSize, { bytes: total.storedBytes }) })
271
- ] })
272
- ] })
273
- ] })
274
- ] });
275
- };
276
-
277
- // src/components/charts/TimeSeriesGraph/TimeSeriesGraph.tsx
278
- import { useCallback, useMemo as useMemo2, useState as useState2 } from "react";
279
- import {
280
- Box as Box3,
281
- Card as Card2,
282
- CardHeader as CardHeader2,
283
- CardMedia as CardMedia2,
284
- CircularProgress,
285
- Divider as Divider2,
286
- Stack as Stack4,
287
- Typography as Typography4,
288
- styled as styled3,
289
- useTheme as useTheme3
290
- } from "@mui/material";
291
- import { LineChart as LineChart3 } from "@mui/x-charts";
292
- import { format as format3 } from "date-fns";
293
-
294
- // src/components/charts/TimeSeriesGraph/TimeRangeSelect.tsx
295
- import { MenuItem as MenuItem2, TextField as TextField2 } from "@mui/material";
296
- import { jsx as jsx4 } from "react/jsx-runtime";
297
- var TimeRangeSelect = ({ options: options2, value, onChange }) => /* @__PURE__ */ jsx4(
298
- TextField2,
299
- {
300
- select: true,
301
- size: "small",
302
- value: value ?? (options2.length > 0 ? options2[0].value : ""),
303
- onChange: (e) => onChange?.(e.target.value),
304
- "aria-label": "Time range selector",
305
- sx: { minWidth: 120 },
306
- children: options2.map((option) => /* @__PURE__ */ jsx4(MenuItem2, { value: option.value, children: option.label }, option.value))
307
- }
308
- );
309
-
310
- // src/components/charts/TimeSeriesGraph/SummaryStats.tsx
311
- import { Stack as Stack3, Typography as Typography3 } from "@mui/material";
312
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
313
- var formatSummaryValue = (value, unit) => {
314
- const displayValue = typeof value === "number" ? value.toLocaleString() : value;
315
- return unit ? `${displayValue} ${unit}` : displayValue;
316
- };
317
- var SummaryStats = ({ items }) => {
318
- if (items.length === 0) {
319
- return null;
320
- }
321
- return /* @__PURE__ */ jsx5(
322
- Stack3,
323
- {
324
- direction: "row",
325
- spacing: 3,
326
- padding: 2,
327
- flexWrap: "wrap",
328
- useFlexGap: true,
329
- role: "list",
330
- "aria-label": "Summary statistics",
331
- children: items.map((item) => /* @__PURE__ */ jsxs3(
332
- Stack3,
333
- {
334
- direction: "row",
335
- alignItems: "center",
336
- spacing: 1,
337
- role: "listitem",
338
- children: [
339
- /* @__PURE__ */ jsx5(Typography3, { variant: "body2", color: "text.secondary", children: item.label }),
340
- /* @__PURE__ */ jsx5(Typography3, { variant: "h5", fontWeight: 600, children: formatSummaryValue(item.value, item.unit) })
341
- ]
342
- },
343
- item.label
344
- ))
345
- }
346
- );
347
- };
348
-
349
- // src/components/charts/TimeSeriesGraph/TimeSeriesGraph.tsx
350
- import { Fragment, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
351
- var ChartContainer = styled3(Box3)({
352
- position: "relative",
353
- height: 320
354
- });
355
- var LoadingOverlay = styled3(Box3)(({ theme }) => ({
356
- position: "absolute",
357
- inset: 0,
358
- display: "flex",
359
- alignItems: "center",
360
- justifyContent: "center",
361
- backgroundColor: "rgba(255, 255, 255, 0.7)",
362
- zIndex: 1,
363
- borderRadius: theme.shape.borderRadius
364
- }));
365
- var LegendDot = styled3(Box3, {
366
- shouldForwardProp: (prop) => prop !== "dotColor"
367
- })(({ dotColor }) => ({
368
- width: 14,
369
- height: 14,
370
- borderRadius: 4,
371
- backgroundColor: dotColor,
372
- flexShrink: 0
373
- }));
374
- var formatYAxisValue = (value) => {
375
- const absValue = Math.abs(value);
376
- if (absValue >= 1e9) {
377
- return `${(value / 1e9).toFixed(absValue % 1e9 === 0 ? 0 : 1)}B`;
378
- }
379
- if (absValue >= 1e6) {
380
- return `${(value / 1e6).toFixed(absValue % 1e6 === 0 ? 0 : 1)}M`;
381
- }
382
- if (absValue >= 1e3) {
383
- return `${(value / 1e3).toFixed(absValue % 1e3 === 0 ? 0 : 1)}K`;
384
- }
385
- return String(value);
386
- };
387
- var TWENTY_FOUR_HOURS_MS = 24 * 60 * 60 * 1e3;
388
- var inferXAxisFormat = (min, max) => {
389
- if (!min || !max) return "do MMM";
390
- const spanMs = max.getTime() - min.getTime();
391
- return spanMs <= TWENTY_FOUR_HOURS_MS ? "HH:mm" : "do MMM";
392
- };
393
- var buildDataset = (series, hiddenSeries) => {
394
- const timestampMap = /* @__PURE__ */ new Map();
395
- series.forEach((s) => {
396
- if (hiddenSeries.has(s.name)) return;
397
- s.data.forEach((dp) => {
398
- const ts = dp.timestamp.getTime();
399
- if (!timestampMap.has(ts)) {
400
- timestampMap.set(ts, { timestamp: dp.timestamp });
401
- }
402
- timestampMap.get(ts)[s.name] = dp.value;
403
- });
404
- });
405
- return Array.from(timestampMap.values()).sort(
406
- (a, b) => a.timestamp.getTime() - b.timestamp.getTime()
407
- );
408
- };
409
- var TimeSeriesGraph = ({
410
- title,
411
- series,
412
- timeRangeOptions,
413
- selectedTimeRange,
414
- onTimeRangeChange,
415
- summaryItems,
416
- showSummary = true,
417
- headerAction,
418
- loading = false,
419
- xAxisFormat
420
- }) => {
421
- const theme = useTheme3();
422
- const [hiddenSeries, setHiddenSeries] = useState2(/* @__PURE__ */ new Set());
423
- const dataset = useMemo2(() => buildDataset(series, hiddenSeries), [series, hiddenSeries]);
424
- const visibleSeries = useMemo2(
425
- () => series.filter((s) => !hiddenSeries.has(s.name)),
426
- [series, hiddenSeries]
427
- );
428
- const chartColors = useMemo2(() => visibleSeries.map((s) => s.color), [visibleSeries]);
429
- const handleLegendToggle = useCallback((seriesName) => {
430
- setHiddenSeries((prev) => {
431
- const next = new Set(prev);
432
- if (next.has(seriesName)) {
433
- next.delete(seriesName);
434
- } else {
435
- next.add(seriesName);
436
- }
437
- return next;
438
- });
439
- }, []);
440
- const timeBounds = useMemo2(() => {
441
- if (dataset.length === 0) return { min: void 0, max: void 0 };
442
- const timestamps = dataset.map((row) => row.timestamp.getTime());
443
- return {
444
- min: new Date(Math.min(...timestamps)),
445
- max: new Date(Math.max(...timestamps))
446
- };
447
- }, [dataset]);
448
- const resolvedXAxisFormat = useMemo2(
449
- () => xAxisFormat ?? inferXAxisFormat(timeBounds.min, timeBounds.max),
450
- [xAxisFormat, timeBounds.min, timeBounds.max]
451
- );
452
- const hasData = dataset.length > 0;
453
- const shouldShowSummary = showSummary && summaryItems && summaryItems.length > 0;
454
- const headerActionElement = /* @__PURE__ */ jsxs4(Stack4, { direction: "row", spacing: 1, alignItems: "center", children: [
455
- headerAction,
456
- timeRangeOptions && timeRangeOptions.length > 0 && /* @__PURE__ */ jsx6(
457
- TimeRangeSelect,
458
- {
459
- options: timeRangeOptions,
460
- value: selectedTimeRange,
461
- onChange: onTimeRangeChange
462
- }
463
- )
464
- ] });
465
- const showHeader = !!title || !!headerAction || timeRangeOptions && timeRangeOptions.length > 0;
466
- return /* @__PURE__ */ jsxs4(
467
- Card2,
468
- {
469
- "aria-label": title ? `Line chart showing ${title}` : "Line chart",
470
- role: "figure",
471
- children: [
472
- showHeader && /* @__PURE__ */ jsx6(
473
- CardHeader2,
474
- {
475
- title,
476
- titleTypographyProps: {
477
- variant: "subtitle1",
478
- fontWeight: 500
479
- },
480
- action: headerActionElement
481
- }
482
- ),
483
- /* @__PURE__ */ jsxs4(CardMedia2, { children: [
484
- /* @__PURE__ */ jsxs4(ChartContainer, { children: [
485
- loading && /* @__PURE__ */ jsx6(LoadingOverlay, { role: "status", "aria-label": "Loading chart data", children: /* @__PURE__ */ jsx6(CircularProgress, { size: 40 }) }),
486
- /* @__PURE__ */ jsx6(
487
- LineChart3,
488
- {
489
- dataset,
490
- axisHighlight: { x: "line", y: "none" },
491
- grid: { horizontal: true, vertical: false },
492
- margin: { top: 10, right: 20, bottom: 40, left: 50 },
493
- colors: chartColors.length > 0 ? chartColors : [theme.palette.primary.main],
494
- slots: {
495
- noDataOverlay: () => null
496
- },
497
- tooltip: { trigger: hasData ? "axis" : "none" },
498
- yAxis: [
499
- {
500
- disableLine: true,
501
- disableTicks: true,
502
- min: hasData ? void 0 : 0,
503
- max: hasData ? void 0 : 100,
504
- tickNumber: hasData ? void 0 : 5,
505
- valueFormatter: (value) => formatYAxisValue(value || 0),
506
- tickLabelStyle: {
507
- fontSize: 10
508
- }
509
- }
510
- ],
511
- xAxis: [
512
- {
513
- dataKey: "timestamp",
514
- scaleType: "time",
515
- min: timeBounds.min,
516
- max: timeBounds.max,
517
- disableLine: true,
518
- disableTicks: true,
519
- valueFormatter: (date) => format3(date, resolvedXAxisFormat),
520
- tickLabelStyle: {
521
- fontSize: 10
522
- }
523
- }
524
- ],
525
- series: visibleSeries.map((s) => ({
526
- curve: "linear",
527
- dataKey: s.name,
528
- label: s.name,
529
- showMark: false,
530
- connectNulls: false
531
- })),
532
- slotProps: {
533
- legend: { hidden: true }
534
- }
535
- }
536
- )
537
- ] }),
538
- series.length > 0 && /* @__PURE__ */ jsx6(
539
- Stack4,
540
- {
541
- direction: "row",
542
- spacing: 2,
543
- justifyContent: "center",
544
- paddingY: 1,
545
- flexWrap: "wrap",
546
- useFlexGap: true,
547
- role: "list",
548
- "aria-label": "Chart legend",
549
- children: series.map((s) => {
550
- const isHidden = hiddenSeries.has(s.name);
551
- return /* @__PURE__ */ jsxs4(
552
- Stack4,
553
- {
554
- direction: "row",
555
- spacing: 1,
556
- alignItems: "center",
557
- role: "listitem",
558
- onClick: () => handleLegendToggle(s.name),
559
- sx: {
560
- cursor: "pointer",
561
- opacity: isHidden ? 0.4 : 1,
562
- transition: "opacity 0.2s ease",
563
- userSelect: "none"
564
- },
565
- "aria-pressed": !isHidden,
566
- "aria-label": `Toggle ${s.name} visibility`,
567
- children: [
568
- /* @__PURE__ */ jsx6(LegendDot, { dotColor: s.color }),
569
- /* @__PURE__ */ jsx6(Typography4, { variant: "body2", children: s.name })
570
- ]
571
- },
572
- s.name
573
- );
574
- })
575
- }
576
- )
577
- ] }),
578
- shouldShowSummary && /* @__PURE__ */ jsxs4(Fragment, { children: [
579
- /* @__PURE__ */ jsx6(Divider2, {}),
580
- /* @__PURE__ */ jsx6(SummaryStats, { items: summaryItems })
581
- ] })
582
- ]
583
- }
584
- );
585
- };
586
-
587
- export {
588
- ChartWidget,
589
- PeriodSelect,
590
- MetricsChart,
591
- TimeRangeSelect,
592
- SummaryStats,
593
- TimeSeriesGraph
594
- };
595
- //# sourceMappingURL=chunk-T7LPABOL.mjs.map