@umituz/web-dashboard 10.3.0 → 10.4.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 (27) hide show
  1. package/package.json +1 -6
  2. package/src/domains/layouts/components/FilterPanel.test.tsx +0 -21
  3. package/src/domains/notifications/components/NotificationsPage.tsx +1 -1
  4. package/src/domains/settings/components/index.ts +0 -1
  5. package/src/styles/dashboard.contract.test.ts +9 -7
  6. package/src/styles/dashboard.css +0 -1
  7. package/src/domains/charts/charts.css +0 -455
  8. package/src/domains/charts/components/ActivityHeatmap.test.tsx +0 -48
  9. package/src/domains/charts/components/ActivityHeatmap.tsx +0 -5
  10. package/src/domains/charts/components/BarChart.test.tsx +0 -91
  11. package/src/domains/charts/components/BarChart.tsx +0 -6
  12. package/src/domains/charts/components/ChartCard.tsx +0 -1
  13. package/src/domains/charts/components/ChartPrimitives.test.tsx +0 -90
  14. package/src/domains/charts/components/ChartTip.tsx +0 -1
  15. package/src/domains/charts/components/Donut.test.tsx +0 -51
  16. package/src/domains/charts/components/Donut.tsx +0 -5
  17. package/src/domains/charts/components/HBars.tsx +0 -1
  18. package/src/domains/charts/components/Legend.tsx +0 -1
  19. package/src/domains/charts/components/LineChart.test.tsx +0 -81
  20. package/src/domains/charts/components/LineChart.tsx +0 -6
  21. package/src/domains/charts/components/Sparkline.tsx +0 -1
  22. package/src/domains/charts/components/index.ts +0 -9
  23. package/src/domains/charts/index.ts +0 -28
  24. package/src/domains/charts/ssr.test.tsx +0 -35
  25. package/src/domains/charts/types/index.ts +0 -8
  26. package/src/domains/charts/utils.ts +0 -10
  27. package/src/domains/settings/components/AuditLogList.tsx +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "10.3.0",
3
+ "version": "10.4.0",
4
4
  "description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -23,11 +23,6 @@
23
23
  "./calendar/services": "./src/domains/calendar/services/index.ts",
24
24
  "./calendar/types": "./src/domains/calendar/types/index.ts",
25
25
  "./calendar/utils": "./src/domains/calendar/utils/index.ts",
26
- "./charts": "./src/domains/charts/index.ts",
27
- "./charts/charts.css": "./src/domains/charts/charts.css",
28
- "./charts/components": "./src/domains/charts/components/index.ts",
29
- "./charts/types": "./src/domains/charts/types/index.ts",
30
- "./charts/utils": "./src/domains/charts/utils.ts",
31
26
  "./chrome.css": "./src/styles/chrome.css",
32
27
  "./config": "./src/config/index.ts",
33
28
  "./layouts": "./src/domains/layouts/index.ts",
@@ -74,24 +74,3 @@ describe("SingleSelectFilterList", () => {
74
74
  });
75
75
  });
76
76
 
77
- import { BarChart } from "../../charts/components";
78
-
79
- describe("BarChart per-bar accents", () => {
80
- it("paints bars with accent overrides falling back to the series tone", () => {
81
- const html = renderToString(
82
- <BarChart
83
- labels={["Mon", "Tue"]}
84
- series={[
85
- {
86
- label: "load",
87
- values: [3, 5],
88
- tone: "#111111",
89
- accents: ["#ff0000", undefined],
90
- },
91
- ]}
92
- />,
93
- );
94
- expect(html).toContain("#ff0000");
95
- expect(html).toContain("#111111");
96
- });
97
- });
@@ -3,7 +3,7 @@ import { CheckCheck } from "lucide-react";
3
3
  import { Button } from "@umituz/web-design-system/atoms";
4
4
  import { Segmented } from "@umituz/web-design-system/molecules";
5
5
  import type { SegmentedOption } from "@umituz/web-design-system/molecules";
6
- import { PageHeader } from "../../layouts/components";
6
+ import { PageHeader } from "@umituz/web-design-system/templates";
7
7
  import { useNotifications } from "../NotificationsContext";
8
8
  import { severityOf } from "../time";
9
9
  import type { NotificationListLabels, NotificationTypeMeta } from "../types";
@@ -9,7 +9,6 @@ export {
9
9
  PermissionMatrixScreen,
10
10
  type PermissionMatrixScreenProps,
11
11
  } from './PermissionMatrixScreen';
12
- export { AuditLogList, type AuditLogListProps, type AuditEntry } from './AuditLogList';
13
12
  export {
14
13
  OrganizationProfileForm,
15
14
  type OrganizationProfileFormProps,
@@ -3,8 +3,7 @@ import { describe, expect, it } from "vitest";
3
3
 
4
4
  const entry = readFileSync(new URL("./dashboard.css", import.meta.url), "utf8");
5
5
  const css = readFileSync(new URL("./chrome.css", import.meta.url), "utf8");
6
- const chartsCss = readFileSync(new URL("../domains/charts/charts.css", import.meta.url), "utf8");
7
- const sheet = css + chartsCss;
6
+ const sheet = css;
8
7
 
9
8
  const defined = new Set([...sheet.matchAll(/(--udb-[a-z0-9-]+)\s*:/g)].map((m) => m[1]));
10
9
  const used = new Set([...sheet.matchAll(/var\((--udb-[a-z0-9-]+)\)/g)].map((m) => m[1]));
@@ -14,23 +13,26 @@ describe("dashboard stylesheet contract", () => {
14
13
  expect([...used].filter((v) => !defined.has(v))).toEqual([]);
15
14
  });
16
15
 
17
- it("defines the eight chart series tokens", () => {
16
+ it("design-system stylesheet defines the eight chart series tokens", () => {
17
+ const dsCss = readFileSync(
18
+ new URL("../../node_modules/@umituz/web-design-system/dist/styles.css", import.meta.url),
19
+ "utf8",
20
+ );
18
21
  for (let i = 1; i <= 8; i += 1) {
19
- expect(chartsCss).toContain(`--udb-chart-${i}:`);
22
+ expect(dsCss).toContain(`--udb-chart-${i}`);
20
23
  }
21
24
  });
22
25
 
23
- it("entry chains the design-system stylesheet, the chrome rules and the chart rules", () => {
26
+ it("entry chains the design-system stylesheet and the chrome rules", () => {
24
27
  expect(entry).toContain('@import "@umituz/web-design-system/styles.css";');
25
28
  expect(entry).toContain('@import "./chrome.css";');
26
- expect(entry).toContain('@import "../domains/charts/charts.css";');
27
29
  });
28
30
 
29
31
  it("chrome carries no stylesheet imports (Tailwind hosts import it beside their own DS build)", () => {
30
32
  expect(css.match(/@import[^;]+;/g) ?? []).toEqual([]);
31
33
  });
32
34
 
33
- it("chart selectors live in charts.css, not chrome.css", () => {
35
+ it("chart selectors live in design-system charts stylesheet, not chrome.css", () => {
34
36
  expect(
35
37
  css.match(/udb-(chartcard|chartlegend|charttip|barchart|donut|linechart|hbars|heatmap)[a-z_-]*/g) ?? [],
36
38
  ).toEqual([]);
@@ -1,3 +1,2 @@
1
1
  @import "@umituz/web-design-system/styles.css";
2
2
  @import "./chrome.css";
3
- @import "../domains/charts/charts.css";
@@ -1,455 +0,0 @@
1
- :root {
2
- --udb-chart-1: #357344;
3
- --udb-chart-2: #b06e22;
4
- --udb-chart-3: #3e5f80;
5
- --udb-chart-4: #7a6ba8;
6
- --udb-chart-5: #8a5a3b;
7
- --udb-chart-6: #5e7d5a;
8
- --udb-chart-7: #a8b5a0;
9
- --udb-chart-8: #c9862f;
10
- }
11
- .udb-chartcard {
12
- display: flex;
13
- flex-direction: column;
14
- min-width: 0;
15
- background: var(--color-card);
16
- border: 1px solid var(--color-border);
17
- border-radius: var(--radius-lg);
18
- box-shadow: var(--shadow-sm);
19
- }
20
- .udb-chartcard__head {
21
- display: flex;
22
- align-items: flex-start;
23
- justify-content: space-between;
24
- gap: var(--udb-space-3);
25
- padding: 14px 18px 4px;
26
- flex-wrap: wrap;
27
- }
28
- .udb-chartcard__heading {
29
- min-width: 0;
30
- }
31
- .udb-chartcard__title {
32
- font-size: var(--udb-font-size-md);
33
- font-weight: 600;
34
- color: var(--color-foreground);
35
- }
36
- .udb-chartcard__sub {
37
- font-size: var(--udb-font-size-sm);
38
- color: var(--color-muted-foreground);
39
- margin-top: 1px;
40
- }
41
- .udb-chartcard__tools {
42
- display: flex;
43
- align-items: center;
44
- gap: 12px;
45
- flex-wrap: wrap;
46
- }
47
- .udb-chartcard__body {
48
- padding: 10px 14px 14px;
49
- min-width: 0;
50
- }
51
- .udb-chartcard__body svg {
52
- display: block;
53
- width: 100%;
54
- height: auto;
55
- }
56
- .udb-chartcard__plot {
57
- position: relative;
58
- }
59
- .udb-chartlegend {
60
- display: flex;
61
- flex-wrap: wrap;
62
- gap: 5px 14px;
63
- }
64
- .udb-chartlegend__item {
65
- display: inline-flex;
66
- align-items: center;
67
- gap: 6px;
68
- font-size: var(--udb-font-size-sm);
69
- color: var(--color-foreground);
70
- white-space: nowrap;
71
- }
72
- .udb-chartlegend__dot {
73
- width: 8px;
74
- height: 8px;
75
- border-radius: 2.5px;
76
- flex: none;
77
- }
78
- .udb-chartlegend__value {
79
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
80
- color: var(--color-muted-foreground);
81
- font-size: var(--udb-font-size-xs);
82
- }
83
- .udb-chartlegend__hint {
84
- color: var(--color-muted-foreground);
85
- font-size: var(--udb-font-size-xs);
86
- }
87
- .udb-charttip {
88
- position: absolute;
89
- pointer-events: none;
90
- background: var(--color-foreground);
91
- color: var(--color-background);
92
- border-radius: var(--radius-md);
93
- padding: 7px 10px;
94
- font-size: var(--udb-font-size-sm);
95
- box-shadow: var(--shadow-lg);
96
- z-index: 30;
97
- min-width: 120px;
98
- transform: translate(-50%, calc(-100% - 10px));
99
- }
100
- .udb-charttip__title {
101
- font-weight: 600;
102
- margin-bottom: 2px;
103
- white-space: nowrap;
104
- }
105
- .udb-charttip__row {
106
- display: flex;
107
- align-items: center;
108
- gap: 6px;
109
- justify-content: space-between;
110
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
111
- font-size: var(--udb-font-size-xs);
112
- }
113
- .udb-charttip__row b {
114
- font-weight: 600;
115
- }
116
- .udb-charttip__label {
117
- display: inline-flex;
118
- align-items: center;
119
- gap: 5px;
120
- }
121
- .udb-hbars {
122
- display: flex;
123
- flex-direction: column;
124
- gap: 10px;
125
- }
126
- .udb-hbars__row {
127
- display: grid;
128
- grid-template-columns: minmax(120px, 1.2fr) 2fr auto;
129
- align-items: center;
130
- gap: 12px;
131
- }
132
- .udb-hbars__label {
133
- min-width: 0;
134
- }
135
- .udb-hbars__name {
136
- font-weight: 600;
137
- font-size: var(--udb-font-size-sm);
138
- overflow: hidden;
139
- text-overflow: ellipsis;
140
- white-space: nowrap;
141
- color: var(--color-foreground);
142
- }
143
- .udb-hbars__sub {
144
- font-size: var(--udb-font-size-xs);
145
- color: var(--color-muted-foreground);
146
- }
147
- .udb-hbars__track {
148
- height: 8px;
149
- background: var(--color-border);
150
- border-radius: 999px;
151
- overflow: hidden;
152
- }
153
- .udb-hbars__fill {
154
- height: 100%;
155
- background: var(--color-primary);
156
- border-radius: 999px;
157
- }
158
- .udb-hbars__value {
159
- font-size: var(--udb-font-size-sm);
160
- color: var(--color-foreground);
161
- text-align: right;
162
- font-variant-numeric: tabular-nums;
163
- }
164
- .udb-barchart {
165
- position: relative;
166
- display: flex;
167
- align-items: flex-end;
168
- gap: 3px;
169
- width: 100%;
170
- }
171
- .udb-barchart__goal {
172
- position: absolute;
173
- left: 0;
174
- right: 0;
175
- z-index: 5;
176
- pointer-events: none;
177
- border-top: 1.5px dashed var(--udb-chart-goal, #d97706);
178
- }
179
- .udb-barchart__goallabel {
180
- position: absolute;
181
- right: 0;
182
- bottom: 2px;
183
- padding: 0 4px;
184
- border: 1px solid var(--udb-chart-goal, #d97706);
185
- border-radius: var(--udb-radius-pill);
186
- background: var(--color-card);
187
- font-size: var(--udb-font-size-xs);
188
- line-height: 16px;
189
- color: var(--udb-chart-goal, #d97706);
190
- }
191
- .udb-barchart__col {
192
- position: relative;
193
- display: flex;
194
- flex: 1;
195
- align-items: flex-end;
196
- min-width: 0;
197
- height: 100%;
198
- }
199
- .udb-barchart__bars {
200
- display: flex;
201
- align-items: flex-end;
202
- justify-content: center;
203
- gap: 2px;
204
- width: 100%;
205
- height: 100%;
206
- }
207
- .udb-barchart__bars .udb-barchart__bar {
208
- flex: 1;
209
- width: auto;
210
- }
211
- .udb-barchart__bar {
212
- width: 100%;
213
- min-height: 2px;
214
- border-radius: 3px 3px 0 0;
215
- transition: opacity 150ms ease, height 300ms ease;
216
- }
217
- .udb-barchart__bars--stacked {
218
- flex-direction: column-reverse;
219
- align-items: center;
220
- justify-content: flex-end;
221
- gap: 0;
222
- }
223
- .udb-barchart__bars--stacked .udb-barchart__bar {
224
- flex: none;
225
- width: 100%;
226
- border-radius: 0;
227
- }
228
- .udb-barchart__bars--stacked .udb-barchart__bar:last-child {
229
- border-radius: 3px 3px 0 0;
230
- }
231
- .udb-barchart__tip {
232
- position: absolute;
233
- bottom: calc(100% + 6px);
234
- left: 50%;
235
- z-index: 10;
236
- padding: 4px 8px;
237
- white-space: nowrap;
238
- pointer-events: none;
239
- border: 1px solid var(--color-border);
240
- border-radius: var(--radius-sm);
241
- background: var(--color-card);
242
- box-shadow: var(--shadow-sm);
243
- font-size: var(--udb-font-size-xs);
244
- color: var(--color-muted-foreground);
245
- }
246
- .udb-barchart__tiptitle {
247
- font-weight: var(--font-weight-medium);
248
- color: var(--color-foreground);
249
- }
250
- .udb-barchart__tiprow {
251
- display: flex;
252
- align-items: center;
253
- justify-content: space-between;
254
- gap: 10px;
255
- }
256
- .udb-barchart__tiprow--total {
257
- margin-top: 3px;
258
- padding-top: 3px;
259
- border-top: 1px solid var(--color-border);
260
- }
261
- .udb-barchart__tiplabel {
262
- display: inline-flex;
263
- align-items: center;
264
- gap: 5px;
265
- }
266
- .udb-barchart__tip b {
267
- margin-right: 4px;
268
- font-weight: var(--font-weight-medium);
269
- color: var(--color-foreground);
270
- }
271
- .udb-donut {
272
- display: flex;
273
- align-items: center;
274
- gap: 20px;
275
- }
276
- .udb-donut__wrap {
277
- position: relative;
278
- flex-shrink: 0;
279
- }
280
- .udb-donut__seg {
281
- cursor: pointer;
282
- transition: stroke-width 150ms ease, opacity 150ms ease;
283
- }
284
- .udb-donut__center {
285
- position: absolute;
286
- inset: 0;
287
- display: flex;
288
- flex-direction: column;
289
- align-items: center;
290
- justify-content: center;
291
- }
292
- .udb-donut__value {
293
- font-size: var(--udb-font-size-lg);
294
- font-weight: var(--font-weight-bold);
295
- color: var(--color-foreground);
296
- font-variant-numeric: tabular-nums;
297
- }
298
- .udb-donut__label {
299
- margin-top: 2px;
300
- font-size: var(--udb-font-size-xs);
301
- color: var(--color-muted-foreground);
302
- }
303
- .udb-donut__list {
304
- display: flex;
305
- min-width: 0;
306
- flex: 1;
307
- flex-direction: column;
308
- gap: 6px;
309
- }
310
- .udb-donut__item {
311
- display: flex;
312
- align-items: center;
313
- justify-content: space-between;
314
- gap: 8px;
315
- padding: 4px 6px;
316
- border-radius: var(--radius-sm);
317
- }
318
- .udb-donut__item:hover {
319
- background: var(--color-muted);
320
- }
321
- .udb-donut__itemlabel {
322
- display: flex;
323
- min-width: 0;
324
- align-items: center;
325
- gap: 8px;
326
- font-size: var(--udb-font-size-sm);
327
- color: var(--color-foreground);
328
- }
329
- .udb-donut__dot {
330
- width: 8px;
331
- height: 8px;
332
- flex-shrink: 0;
333
- border-radius: 3px;
334
- }
335
- .udb-donut__itemvalue {
336
- flex-shrink: 0;
337
- font-size: var(--udb-font-size-sm);
338
- font-weight: var(--font-weight-medium);
339
- color: var(--color-foreground);
340
- font-variant-numeric: tabular-nums;
341
- }
342
- .udb-donut__pct {
343
- margin-left: 6px;
344
- color: var(--color-muted-foreground);
345
- }
346
- .udb-linechart {
347
- position: relative;
348
- width: 100%;
349
- user-select: none;
350
- }
351
- .udb-linechart__svg {
352
- display: block;
353
- width: 100%;
354
- }
355
- .udb-linechart__axis {
356
- fill: var(--color-muted-foreground);
357
- font-size: var(--udb-font-size-xs);
358
- font-family: var(--font-sans);
359
- }
360
- .udb-linechart__grid {
361
- stroke: var(--color-border);
362
- stroke-width: 1;
363
- }
364
- .udb-linechart__band {
365
- fill: var(--color-primary);
366
- opacity: 0.08;
367
- }
368
- .udb-linechart__crosshair {
369
- stroke: var(--udb-border-strong);
370
- stroke-width: 1;
371
- stroke-dasharray: 3 3;
372
- }
373
- .udb-linechart__tip {
374
- position: absolute;
375
- top: 8px;
376
- z-index: 10;
377
- min-width: 132px;
378
- padding: 8px;
379
- pointer-events: none;
380
- border: 1px solid var(--color-border);
381
- border-radius: var(--radius-md);
382
- background: var(--color-card);
383
- box-shadow: var(--shadow-md);
384
- }
385
- .udb-linechart__tiptitle {
386
- margin-bottom: 4px;
387
- font-size: var(--udb-font-size-xs);
388
- color: var(--color-muted-foreground);
389
- }
390
- .udb-linechart__tiprow {
391
- display: flex;
392
- align-items: center;
393
- justify-content: space-between;
394
- gap: 12px;
395
- font-size: var(--udb-font-size-sm);
396
- }
397
- .udb-linechart__tiprow span {
398
- display: flex;
399
- align-items: center;
400
- gap: 6px;
401
- color: var(--color-muted-foreground);
402
- }
403
- .udb-linechart__tiprow b {
404
- font-weight: var(--font-weight-medium);
405
- color: var(--color-foreground);
406
- font-variant-numeric: tabular-nums;
407
- }
408
- .udb-linechart__swatch {
409
- display: inline-block;
410
- width: 12px;
411
- height: 3px;
412
- border-radius: 999px;
413
- }
414
- .udb-linechart__legendhost {
415
- margin-top: 4px;
416
- padding: 0 8px;
417
- }
418
- .udb-heatmap {
419
- display: grid;
420
- grid-auto-flow: column;
421
- grid-template-rows: repeat(7, minmax(0, 1fr));
422
- gap: 4px;
423
- }
424
- .udb-heatmap__cell {
425
- width: 14px;
426
- height: 14px;
427
- border-radius: 3px;
428
- transition: background-color 150ms ease;
429
- }
430
- .udb-heatmap__cell--l0 {
431
- background: color-mix(in oklab, var(--color-muted) 40%, transparent);
432
- }
433
- .udb-heatmap__cell--l1 {
434
- background: color-mix(in oklab, var(--color-primary) 20%, var(--color-card));
435
- }
436
- .udb-heatmap__cell--l2 {
437
- background: color-mix(in oklab, var(--color-primary) 40%, var(--color-card));
438
- }
439
- .udb-heatmap__cell--l3 {
440
- background: color-mix(in oklab, var(--color-primary) 70%, var(--color-card));
441
- }
442
- .udb-heatmap__cell--l4 {
443
- background: var(--color-primary);
444
- }
445
- .udb-heatmap__sr {
446
- position: absolute;
447
- width: 1px;
448
- height: 1px;
449
- padding: 0;
450
- margin: -1px;
451
- overflow: hidden;
452
- clip: rect(0, 0, 0, 0);
453
- white-space: nowrap;
454
- border-width: 0;
455
- }
@@ -1,48 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { render } from "@testing-library/react";
3
- import { ActivityHeatmap } from "./ActivityHeatmap";
4
-
5
- const cells = [
6
- { day: "2026-01-01", value: 0 },
7
- { day: "2026-01-02", value: 5 },
8
- { day: "2026-01-03", value: 10 },
9
- ];
10
-
11
- describe("ActivityHeatmap", () => {
12
- it("levels cells by intensity against the peak", () => {
13
- const { container } = render(<ActivityHeatmap cells={cells} max={10} />);
14
- const cellEls = container.querySelectorAll(".udb-heatmap__cell");
15
- expect(cellEls).toHaveLength(3);
16
- expect(cellEls[0]!.className).toContain("udb-heatmap__cell--l0");
17
- expect(cellEls[1]!.className).toContain("udb-heatmap__cell--l2");
18
- expect(cellEls[2]!.className).toContain("udb-heatmap__cell--l4");
19
- });
20
-
21
- it("exposes each cell title visually and for screen readers", () => {
22
- const { container } = render(<ActivityHeatmap cells={cells} max={10} />);
23
- expect(container.querySelector(".udb-heatmap__cell")!.getAttribute("title")).toBe(
24
- "2026-01-01: 0",
25
- );
26
- expect(container.querySelector(".udb-heatmap__sr")!.textContent).toBe("2026-01-01: 0");
27
- });
28
-
29
- it("keeps the levelClassNames escape hatch", () => {
30
- const { container } = render(
31
- <ActivityHeatmap
32
- cells={cells}
33
- max={10}
34
- levelClassNames={["z0", "z1", "z2", "z3", "z4"]}
35
- />,
36
- );
37
- const cellEls = container.querySelectorAll(".udb-heatmap__cell");
38
- expect(cellEls[0]!.className).toContain("z0");
39
- expect(cellEls[0]!.className).not.toContain("udb-heatmap__cell--");
40
- });
41
-
42
- it("derives the peak from the data when max is omitted", () => {
43
- const { container } = render(<ActivityHeatmap cells={cells} />);
44
- const cellEls = container.querySelectorAll(".udb-heatmap__cell");
45
- expect(cellEls[1]!.className).toContain("udb-heatmap__cell--l2");
46
- expect(cellEls[2]!.className).toContain("udb-heatmap__cell--l4");
47
- });
48
- });
@@ -1,5 +0,0 @@
1
- export {
2
- ActivityHeatmap,
3
- type HeatmapCell,
4
- type ActivityHeatmapProps,
5
- } from '@umituz/web-design-system/charts';
@@ -1,91 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { fireEvent, render } from "@testing-library/react";
3
- import { BarChart } from "./BarChart";
4
-
5
- const labels = ["Oca", "Şub", "Mar"];
6
-
7
- describe("BarChart", () => {
8
- it("renders one column per label with a bar per grouped series", () => {
9
- const { container } = render(
10
- <BarChart
11
- labels={labels}
12
- series={[
13
- { label: "A", values: [1, 2, 3] },
14
- { label: "B", values: [3, 2, 1] },
15
- ]}
16
- />,
17
- );
18
- const cols = container.querySelectorAll(".udb-barchart__col");
19
- expect(cols).toHaveLength(3);
20
- expect(cols[0]!.querySelectorAll(".udb-barchart__bar")).toHaveLength(2);
21
- });
22
-
23
- it("scales grouped heights against the global max", () => {
24
- const { container } = render(
25
- <BarChart labels={labels} series={[{ label: "A", values: [4, 1, 2] }]} />,
26
- );
27
- const bars = [...container.querySelectorAll(".udb-barchart__bar")] as HTMLElement[];
28
- expect(bars.map((b) => b.style.height)).toEqual(["100%", "25%", "50%"]);
29
- });
30
-
31
- it("scales stacked segments against column totals", () => {
32
- const { container } = render(
33
- <BarChart
34
- labels={labels}
35
- stacking="stacked"
36
- series={[
37
- { label: "A", values: [2, 1, 0] },
38
- { label: "B", values: [2, 3, 2] },
39
- ]}
40
- />,
41
- );
42
- const cols = container.querySelectorAll(".udb-barchart__col");
43
- const first = [...cols[0]!.querySelectorAll(".udb-barchart__bar")] as HTMLElement[];
44
- expect(first.map((b) => b.style.height)).toEqual(["50%", "50%"]);
45
- const third = [...cols[2]!.querySelectorAll(".udb-barchart__bar")] as HTMLElement[];
46
- expect(third[0]!.style.height).toBe("0%");
47
- });
48
-
49
- it("shows per-series rows plus a total row in the stacked tooltip", () => {
50
- const { container } = render(
51
- <BarChart
52
- labels={labels}
53
- stacking="stacked"
54
- totalLabel="Toplam"
55
- series={[
56
- { label: "A", values: [2, 1, 0] },
57
- { label: "B", values: [2, 3, 2] },
58
- ]}
59
- />,
60
- );
61
- fireEvent.mouseEnter(container.querySelectorAll(".udb-barchart__col")[0]!);
62
- const tip = container.querySelector(".udb-barchart__tip");
63
- expect(tip).not.toBeNull();
64
- expect(tip!.textContent).toContain("A");
65
- expect(tip!.textContent).toContain("B");
66
- expect(tip!.textContent).toContain("Toplam");
67
- expect(tip!.querySelector(".udb-barchart__tiprow--total")!.textContent).toContain("4");
68
- });
69
-
70
- it("positions the goal line relative to the max", () => {
71
- const { container } = render(
72
- <BarChart
73
- labels={labels}
74
- goalLine={{ value: 2, label: "Hedef" }}
75
- series={[{ label: "A", values: [4, 4, 4] }]}
76
- />,
77
- );
78
- const goal = container.querySelector(".udb-barchart__goal") as HTMLElement;
79
- expect(goal.style.bottom).toBe("50%");
80
- expect(goal.textContent).toContain("Hedef");
81
- });
82
-
83
- it("colors series through the --udb-chart tokens by default", () => {
84
- const { container } = render(
85
- <BarChart labels={labels} series={[{ label: "A", values: [1, 2, 3] }]} />,
86
- );
87
- const bar = container.querySelector(".udb-barchart__bar") as HTMLElement;
88
- expect(bar.style.background).toContain("var(--udb-chart-1");
89
- expect(bar.style.background).toContain("#357344");
90
- });
91
- });
@@ -1,6 +0,0 @@
1
- export {
2
- BarChart,
3
- type BarSeries,
4
- type BarChartGoalLine,
5
- type BarChartProps,
6
- } from '@umituz/web-design-system/charts';
@@ -1 +0,0 @@
1
- export { ChartCard, type ChartCardProps } from '@umituz/web-design-system/charts';
@@ -1,90 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { render } from "@testing-library/react";
3
- import { ChartCard } from "./ChartCard";
4
- import { Legend } from "./Legend";
5
- import { HBars } from "./HBars";
6
- import { Sparkline } from "./Sparkline";
7
- import type { TipState } from "../utils";
8
-
9
- describe("ChartCard", () => {
10
- const tip: TipState = { x: 10, y: 20, title: "bugün", rows: [{ label: "A", value: "7", color: "#111111" }] };
11
-
12
- it("renders the heading, tools, body and tooltip", () => {
13
- const { container } = render(
14
- <ChartCard
15
- title="Gelir"
16
- subtitle="son 30 gün"
17
- legend={<Legend items={[{ label: "A", color: "#111111", value: "7" }]} />}
18
- actions={<button type="button">act</button>}
19
- tip={tip}
20
- >
21
- <div>plot</div>
22
- </ChartCard>,
23
- );
24
- expect(container.querySelector(".udb-chartcard__title")!.textContent).toBe("Gelir");
25
- expect(container.querySelector(".udb-chartcard__sub")!.textContent).toBe("son 30 gün");
26
- expect(container.querySelector(".udb-chartlegend__value")!.textContent).toBe("7");
27
- expect(container.querySelector(".udb-chartcard__tools button")).not.toBeNull();
28
- expect(container.querySelector(".udb-charttip__title")!.textContent).toBe("bugün");
29
- expect(container.querySelector(".udb-charttip")!.textContent).toContain("7");
30
- });
31
-
32
- it("omits the tooltip when tip is null and zeroes body padding when bare", () => {
33
- const { container } = render(
34
- <ChartCard title="T" tip={null} bare>
35
- <div>x</div>
36
- </ChartCard>,
37
- );
38
- expect(container.querySelector(".udb-charttip")).toBeNull();
39
- expect(container.querySelector<HTMLElement>(".udb-chartcard__body")!.style.padding).toBe("0px");
40
- });
41
- });
42
-
43
- describe("Legend", () => {
44
- it("renders items with optional value and hint", () => {
45
- const { container } = render(
46
- <Legend
47
- items={[
48
- { label: "A", color: "#111111", value: "3" },
49
- { label: "B", color: "#222222", hint: "tahmini" },
50
- ]}
51
- />,
52
- );
53
- const items = container.querySelectorAll(".udb-chartlegend__item");
54
- expect(items).toHaveLength(2);
55
- expect(items[0]!.textContent).toContain("3");
56
- expect(items[1]!.textContent).toContain("tahmini");
57
- });
58
- });
59
-
60
- describe("HBars", () => {
61
- it("scales fill widths against the largest row and applies tones", () => {
62
- const { container } = render(
63
- <HBars
64
- rows={[
65
- { label: "A", value: 5 },
66
- { label: "B", value: 10, tone: "#00ff00" },
67
- ]}
68
- formatValue={(n) => `${n}₺`}
69
- />,
70
- );
71
- const fills = [...container.querySelectorAll(".udb-hbars__fill")] as HTMLElement[];
72
- expect(fills.map((f) => f.style.width)).toEqual(["50%", "100%"]);
73
- expect(fills[1]!.style.background).toBe("rgb(0, 255, 0)");
74
- expect(container.querySelector(".udb-hbars__value")!.textContent).toBe("5₺");
75
- });
76
- });
77
-
78
- describe("Sparkline", () => {
79
- it("renders a gradient area, line and end dot", () => {
80
- const { container } = render(<Sparkline data={[1, 5, 3]} />);
81
- expect(container.querySelector("linearGradient")).not.toBeNull();
82
- expect(container.querySelector("circle")).not.toBeNull();
83
- expect(container.querySelectorAll("path")).toHaveLength(2);
84
- });
85
-
86
- it("renders nothing for fewer than two points", () => {
87
- const { container } = render(<Sparkline data={[1]} />);
88
- expect(container.firstChild).toBeNull();
89
- });
90
- });
@@ -1 +0,0 @@
1
- export { ChartTip } from '@umituz/web-design-system/charts';
@@ -1,51 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { fireEvent, render } from "@testing-library/react";
3
- import { Donut } from "./Donut";
4
-
5
- describe("Donut", () => {
6
- it("renders one segment per entry with computed percentages", () => {
7
- const { container } = render(
8
- <Donut
9
- segments={[
10
- { label: "A", value: 3 },
11
- { label: "B", value: 1 },
12
- ]}
13
- centerValue="4"
14
- centerLabel="total"
15
- />,
16
- );
17
- expect(container.querySelectorAll(".udb-donut__seg")).toHaveLength(2);
18
- expect(container.querySelectorAll(".udb-donut__item")).toHaveLength(2);
19
- expect(container.querySelector(".udb-donut__pct")!.textContent).toBe("75%");
20
- expect(container.querySelector(".udb-donut__value")!.textContent).toBe("4");
21
- expect(container.querySelector(".udb-donut__label")!.textContent).toBe("total");
22
- });
23
-
24
- it("swaps the center readout to the hovered segment", () => {
25
- const { container } = render(
26
- <Donut
27
- segments={[
28
- { label: "A", value: 3 },
29
- { label: "B", value: 1 },
30
- ]}
31
- centerValue="4"
32
- />,
33
- );
34
- fireEvent.mouseEnter(container.querySelectorAll(".udb-donut__seg")[1]!);
35
- expect(container.querySelector(".udb-donut__value")!.textContent).toBe("1");
36
- expect(container.querySelector(".udb-donut__label")!.textContent).toBe("B");
37
- });
38
-
39
- it("colors segments through the --udb-chart tokens by default", () => {
40
- const { container } = render(<Donut segments={[{ label: "A", value: 1 }]} />);
41
- const seg = container.querySelector(".udb-donut__seg")!;
42
- expect(seg.getAttribute("stroke")).toContain("var(--udb-chart-1");
43
- });
44
-
45
- it("lets an explicit tone win over the series tokens", () => {
46
- const { container } = render(
47
- <Donut segments={[{ label: "A", value: 1, tone: "#ff0000" }]} />,
48
- );
49
- expect(container.querySelector(".udb-donut__seg")!.getAttribute("stroke")).toBe("#ff0000");
50
- });
51
- });
@@ -1,5 +0,0 @@
1
- export {
2
- Donut,
3
- type DonutSegment,
4
- type DonutProps,
5
- } from '@umituz/web-design-system/charts';
@@ -1 +0,0 @@
1
- export { HBars, type HBarRow } from '@umituz/web-design-system/charts';
@@ -1 +0,0 @@
1
- export { Legend, type LegendItem } from '@umituz/web-design-system/charts';
@@ -1,81 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { fireEvent, render } from "@testing-library/react";
3
- import { LineChart } from "./LineChart";
4
-
5
- const labels = ["1", "2", "3", "4"];
6
-
7
- describe("LineChart", () => {
8
- it("renders nothing without points", () => {
9
- const { container } = render(<LineChart labels={[]} series={[]} />);
10
- expect(container.firstChild).toBeNull();
11
- });
12
-
13
- it("renders a flat area by default", () => {
14
- const { container } = render(
15
- <LineChart labels={labels} series={[{ label: "A", values: [1, 2, 3, 4] }]} />,
16
- );
17
- const paths = container.querySelectorAll("path");
18
- expect(paths).toHaveLength(2);
19
- expect(paths[0]!.getAttribute("opacity")).toBe("0.07");
20
- expect(container.querySelector("linearGradient")).toBeNull();
21
- });
22
-
23
- it("paints the area with a per-series gradient when requested", () => {
24
- const { container } = render(
25
- <LineChart
26
- labels={labels}
27
- series={[{ label: "A", values: [1, 2, 3, 4], areaFill: "gradient" }]}
28
- />,
29
- );
30
- const gradient = container.querySelector("linearGradient");
31
- expect(gradient).not.toBeNull();
32
- expect(gradient!.querySelectorAll("stop")).toHaveLength(2);
33
- const areaPath = [...container.querySelectorAll("path")].find((p) =>
34
- p.getAttribute("fill")?.startsWith("url(#"),
35
- );
36
- expect(areaPath).toBeDefined();
37
- expect(areaPath!.getAttribute("opacity")).toBeNull();
38
- });
39
-
40
- it("drops the area for dashed series", () => {
41
- const { container } = render(
42
- <LineChart labels={labels} series={[{ label: "A", values: [1, 2, 3, 4], dashed: true }]} />,
43
- );
44
- expect(container.querySelectorAll("path")).toHaveLength(1);
45
- expect(container.querySelector("linearGradient")).toBeNull();
46
- });
47
-
48
- it("renders the band and a crosshair with tooltip on hover", () => {
49
- const { container } = render(
50
- <LineChart
51
- labels={labels}
52
- band={{ from: 1, to: 2 }}
53
- series={[{ label: "A", values: [1, 2, 3, 4] }]}
54
- />,
55
- );
56
- expect(container.querySelector(".udb-linechart__band")).not.toBeNull();
57
-
58
- const svg = container.querySelector("svg")!;
59
- fireEvent.mouseMove(svg, { clientX: 700, clientY: 50 });
60
- expect(container.querySelector(".udb-linechart__crosshair")).not.toBeNull();
61
- const tip = container.querySelector(".udb-linechart__tip");
62
- expect(tip).not.toBeNull();
63
- expect(tip!.textContent).toContain("A");
64
- });
65
-
66
- it("renders the built-in legend from the series", () => {
67
- const { container } = render(
68
- <LineChart
69
- labels={labels}
70
- series={[
71
- { label: "A", values: [1, 2, 3, 4] },
72
- { label: "B", values: [4, 3, 2, 1], axis: "right" },
73
- ]}
74
- />,
75
- );
76
- const items = container.querySelectorAll(".udb-chartlegend__item");
77
- expect(items).toHaveLength(2);
78
- expect(items[0]!.textContent).toContain("A");
79
- expect(items[1]!.textContent).toContain("B");
80
- });
81
- });
@@ -1,6 +0,0 @@
1
- export {
2
- LineChart,
3
- type LineSeries,
4
- type LineChartPoint,
5
- type LineChartProps,
6
- } from '@umituz/web-design-system/charts';
@@ -1 +0,0 @@
1
- export { Sparkline } from '@umituz/web-design-system/charts';
@@ -1,9 +0,0 @@
1
- export { ChartTip } from './ChartTip';
2
- export { ChartCard, type ChartCardProps } from './ChartCard';
3
- export { Legend, type LegendItem } from './Legend';
4
- export { Sparkline } from './Sparkline';
5
- export { HBars, type HBarRow } from './HBars';
6
- export { BarChart, type BarSeries, type BarChartGoalLine, type BarChartProps } from './BarChart';
7
- export { Donut, type DonutSegment, type DonutProps } from './Donut';
8
- export { LineChart, type LineSeries, type LineChartPoint, type LineChartProps } from './LineChart';
9
- export { ActivityHeatmap, type HeatmapCell, type ActivityHeatmapProps } from './ActivityHeatmap';
@@ -1,28 +0,0 @@
1
- export { PALETTE, SERIES_COLORS, seriesColor, useTip, niceMax, gridTicks } from './utils';
2
- export type { TipRow, TipState } from './utils';
3
- export {
4
- ChartTip,
5
- ChartCard,
6
- Legend,
7
- Sparkline,
8
- HBars,
9
- BarChart,
10
- Donut,
11
- LineChart,
12
- ActivityHeatmap,
13
- } from './components';
14
- export type {
15
- ChartCardProps,
16
- LegendItem,
17
- HBarRow,
18
- BarSeries,
19
- BarChartGoalLine,
20
- BarChartProps,
21
- DonutSegment,
22
- DonutProps,
23
- LineSeries,
24
- LineChartPoint,
25
- LineChartProps,
26
- HeatmapCell,
27
- ActivityHeatmapProps,
28
- } from './components';
@@ -1,35 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { renderToString } from "react-dom/server";
3
- import { BarChart } from "./components/BarChart";
4
- import { Donut } from "./components/Donut";
5
- import { LineChart } from "./components/LineChart";
6
- import { ActivityHeatmap } from "./components/ActivityHeatmap";
7
- import { ChartCard } from "./components/ChartCard";
8
- import { HBars } from "./components/HBars";
9
- import { Sparkline } from "./components/Sparkline";
10
-
11
- describe("charts server rendering", () => {
12
- it("renders every chart primitive to static markup", () => {
13
- const html = [
14
- renderToString(
15
- <ChartCard title="T" tip={null}>
16
- <span>body</span>
17
- </ChartCard>,
18
- ),
19
- renderToString(<BarChart labels={["a", "b"]} series={[{ label: "A", values: [1, 2] }]} />),
20
- renderToString(<BarChart labels={["a"]} stacking="stacked" series={[{ label: "A", values: [2] }, { label: "B", values: [2] }]} />),
21
- renderToString(<Donut segments={[{ label: "A", value: 1 }]} centerValue="1" />),
22
- renderToString(<LineChart labels={["a", "b"]} series={[{ label: "A", values: [1, 2], areaFill: "gradient" }]} />),
23
- renderToString(<ActivityHeatmap cells={[{ day: "2026-01-01", value: 3 }]} />),
24
- renderToString(<Sparkline data={[1, 2]} />),
25
- renderToString(<HBars rows={[{ label: "A", value: 1 }]} />),
26
- ].join("");
27
- expect(html).toContain("udb-chartcard");
28
- expect(html).toContain("udb-barchart__bars--stacked");
29
- expect(html).toContain("udb-donut");
30
- expect(html).toContain("udb-linechart");
31
- expect(html).toContain("linearGradient");
32
- expect(html).toContain("udb-heatmap__cell--l");
33
- expect(html).toContain("udb-hbars");
34
- });
35
- });
@@ -1,8 +0,0 @@
1
- export type { TipRow, TipState } from '../utils';
2
- export type { ChartCardProps } from '../components/ChartCard';
3
- export type { LegendItem } from '../components/Legend';
4
- export type { HBarRow } from '../components/HBars';
5
- export type { BarSeries, BarChartGoalLine, BarChartProps } from '../components/BarChart';
6
- export type { DonutSegment, DonutProps } from '../components/Donut';
7
- export type { LineSeries, LineChartPoint, LineChartProps } from '../components/LineChart';
8
- export type { HeatmapCell, ActivityHeatmapProps } from '../components/ActivityHeatmap';
@@ -1,10 +0,0 @@
1
- export {
2
- PALETTE,
3
- SERIES_COLORS,
4
- seriesColor,
5
- useTip,
6
- niceMax,
7
- gridTicks,
8
- type TipRow,
9
- type TipState,
10
- } from '@umituz/web-design-system/charts';
@@ -1,6 +0,0 @@
1
- export {
2
- AuditLogList,
3
- type AuditLogListProps,
4
- type AuditEntry,
5
- } from '@umituz/web-design-system/organisms';
6
- export { AuditLogList as default } from '@umituz/web-design-system/organisms';