@wallarm-org/gen-ui 0.0.0-stage → 1.0.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 (118) hide show
  1. package/README.md +153 -2
  2. package/dist/a2ui/A2uiSurfaces.d.ts +16 -0
  3. package/dist/a2ui/A2uiSurfaces.js +61 -0
  4. package/dist/a2ui/catalog.d.ts +16 -0
  5. package/dist/a2ui/catalog.js +66 -0
  6. package/dist/a2ui/check.d.ts +4 -0
  7. package/dist/a2ui/check.js +34 -0
  8. package/dist/a2ui/express.d.ts +38 -0
  9. package/dist/a2ui/express.js +64 -0
  10. package/dist/a2ui/index.d.ts +8 -0
  11. package/dist/a2ui/index.js +4 -0
  12. package/dist/a2ui/prompt.d.ts +16 -0
  13. package/dist/a2ui/prompt.js +17 -0
  14. package/dist/a2ui/toA2uiSchema.d.ts +19 -0
  15. package/dist/a2ui/toA2uiSchema.js +61 -0
  16. package/dist/components/Alert.d.ts +11 -0
  17. package/dist/components/Alert.js +43 -0
  18. package/dist/components/AreaChart.d.ts +36 -0
  19. package/dist/components/AreaChart.js +90 -0
  20. package/dist/components/Badge.d.ts +11 -0
  21. package/dist/components/Badge.js +30 -0
  22. package/dist/components/BarList.d.ts +26 -0
  23. package/dist/components/BarList.js +66 -0
  24. package/dist/components/Button.d.ts +10 -0
  25. package/dist/components/Button.js +40 -0
  26. package/dist/components/Card.d.ts +2 -0
  27. package/dist/components/Card.js +17 -0
  28. package/dist/components/ColumnChart.d.ts +32 -0
  29. package/dist/components/ColumnChart.js +114 -0
  30. package/dist/components/Grid.d.ts +29 -0
  31. package/dist/components/Grid.js +72 -0
  32. package/dist/components/Heading.d.ts +10 -0
  33. package/dist/components/Heading.js +29 -0
  34. package/dist/components/HorizontalBarStack.d.ts +39 -0
  35. package/dist/components/HorizontalBarStack.js +67 -0
  36. package/dist/components/LineChart.d.ts +36 -0
  37. package/dist/components/LineChart.js +101 -0
  38. package/dist/components/Metric.d.ts +35 -0
  39. package/dist/components/Metric.js +85 -0
  40. package/dist/components/PieChart.d.ts +25 -0
  41. package/dist/components/PieChart.js +83 -0
  42. package/dist/components/Section.d.ts +5 -0
  43. package/dist/components/Section.js +39 -0
  44. package/dist/components/Stack.d.ts +18 -0
  45. package/dist/components/Stack.js +41 -0
  46. package/dist/components/Table.d.ts +30 -0
  47. package/dist/components/Table.js +128 -0
  48. package/dist/components/Text.d.ts +9 -0
  49. package/dist/components/Text.js +27 -0
  50. package/dist/components/index.d.ts +20 -0
  51. package/dist/components/index.js +55 -0
  52. package/dist/core/check.d.ts +35 -0
  53. package/dist/core/check.js +63 -0
  54. package/dist/core/define.d.ts +64 -0
  55. package/dist/core/define.js +7 -0
  56. package/dist/core/format.d.ts +24 -0
  57. package/dist/core/format.js +74 -0
  58. package/dist/core/guards.d.ts +2 -0
  59. package/dist/core/guards.js +2 -0
  60. package/dist/fixtures/apiInventory.d.ts +36 -0
  61. package/dist/fixtures/apiInventory.js +287 -0
  62. package/dist/fixtures/attackSummary.d.ts +13 -0
  63. package/dist/fixtures/attackSummary.js +329 -0
  64. package/dist/fixtures/dashboard.d.ts +119 -0
  65. package/dist/fixtures/dashboard.js +428 -0
  66. package/dist/fixtures/incident.d.ts +44 -0
  67. package/dist/fixtures/incident.js +331 -0
  68. package/dist/fixtures/index.d.ts +13 -0
  69. package/dist/fixtures/index.js +9 -0
  70. package/dist/fixtures/liveMonitor.d.ts +9 -0
  71. package/dist/fixtures/liveMonitor.js +180 -0
  72. package/dist/fixtures/openui.d.ts +16 -0
  73. package/dist/fixtures/openui.js +74 -0
  74. package/dist/fixtures/scenarios.d.ts +13 -0
  75. package/dist/fixtures/scenarios.js +39 -0
  76. package/dist/fixtures/stream.d.ts +79 -0
  77. package/dist/fixtures/stream.js +147 -0
  78. package/dist/fixtures/weeklyReport.d.ts +46 -0
  79. package/dist/fixtures/weeklyReport.js +266 -0
  80. package/dist/index.d.ts +8 -0
  81. package/dist/index.js +4 -0
  82. package/dist/json-render/JsonRenderSurface.d.ts +13 -0
  83. package/dist/json-render/JsonRenderSurface.js +63 -0
  84. package/dist/json-render/catalog.d.ts +64 -0
  85. package/dist/json-render/catalog.js +50 -0
  86. package/dist/json-render/check.d.ts +4 -0
  87. package/dist/json-render/check.js +13 -0
  88. package/dist/json-render/index.d.ts +6 -0
  89. package/dist/json-render/index.js +4 -0
  90. package/dist/json-render/spec.d.ts +23 -0
  91. package/dist/json-render/spec.js +77 -0
  92. package/dist/openui/OpenUiSurface.d.ts +24 -0
  93. package/dist/openui/OpenUiSurface.js +30 -0
  94. package/dist/openui/catalog.d.ts +23 -0
  95. package/dist/openui/catalog.js +65 -0
  96. package/dist/openui/check.d.ts +4 -0
  97. package/dist/openui/check.js +68 -0
  98. package/dist/openui/index.d.ts +5 -0
  99. package/dist/openui/index.js +3 -0
  100. package/dist/playground/GenUiChatDemo.d.ts +11 -0
  101. package/dist/playground/GenUiChatDemo.js +148 -0
  102. package/dist/playground/GenUiPlayground.d.ts +15 -0
  103. package/dist/playground/GenUiPlayground.js +413 -0
  104. package/dist/playground/index.d.ts +3 -0
  105. package/dist/playground/index.js +2 -0
  106. package/dist/playground/useEmulatedAgent.d.ts +37 -0
  107. package/dist/playground/useEmulatedAgent.js +221 -0
  108. package/dist/render/ChartSkeleton.d.ts +6 -0
  109. package/dist/render/ChartSkeleton.js +26 -0
  110. package/dist/render/GuardedView.d.ts +18 -0
  111. package/dist/render/GuardedView.js +24 -0
  112. package/dist/render/Placeholder.d.ts +16 -0
  113. package/dist/render/Placeholder.js +15 -0
  114. package/dist/render/SurfaceBoundary.d.ts +15 -0
  115. package/dist/render/SurfaceBoundary.js +15 -0
  116. package/dist/render/warn.d.ts +1 -0
  117. package/dist/render/warn.js +2 -0
  118. package/package.json +94 -4
@@ -0,0 +1,39 @@
1
+ import * as z from 'zod';
2
+ export declare const HorizontalBarStackComponent: import("../index.js").GenUiComponent<z.ZodObject<{
3
+ title: z.ZodString;
4
+ value: z.ZodOptional<z.ZodNumber>;
5
+ format: z.ZodOptional<z.ZodEnum<{
6
+ bytes: "bytes";
7
+ compact: "compact";
8
+ ms: "ms";
9
+ number: "number";
10
+ percent: "percent";
11
+ }>>;
12
+ delta: z.ZodOptional<z.ZodObject<{
13
+ value: z.ZodNumber;
14
+ trend: z.ZodOptional<z.ZodEnum<{
15
+ down: "down";
16
+ up: "up";
17
+ }>>;
18
+ sentiment: z.ZodOptional<z.ZodEnum<{
19
+ negative: "negative";
20
+ neutral: "neutral";
21
+ positive: "positive";
22
+ }>>;
23
+ }, z.core.$strip>>;
24
+ total: z.ZodOptional<z.ZodNumber>;
25
+ legend: z.ZodOptional<z.ZodBoolean>;
26
+ items: z.ZodArray<z.ZodObject<{
27
+ name: z.ZodString;
28
+ value: z.ZodNumber;
29
+ color: z.ZodOptional<z.ZodEnum<{
30
+ amber: "amber";
31
+ blue: "blue";
32
+ brand: "brand";
33
+ green: "green";
34
+ purple: "purple";
35
+ red: "red";
36
+ slate: "slate";
37
+ }>>;
38
+ }, z.core.$strip>>;
39
+ }, z.core.$strip>>;
@@ -0,0 +1,67 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Chart, ChartHeader, ChartTitle, HorizontalBarStack, HorizontalBarStackSkeleton, MetricDelta, MetricHeader, MetricValue } from "@wallarm-org/design-system/SimpleCharts";
3
+ import { allOf, defineComponent } from "../core/define.js";
4
+ import { formatNumber, numberFormat } from "../core/format.js";
5
+ import { ChartSkeleton } from "../render/ChartSkeleton.js";
6
+ import { CHART_COLORS } from "./BarList.js";
7
+ import * as __rspack_external_zod from "zod";
8
+ const TRENDS = allOf()([
9
+ 'up',
10
+ 'down'
11
+ ]);
12
+ const SENTIMENTS = allOf()([
13
+ 'positive',
14
+ 'negative',
15
+ 'neutral'
16
+ ]);
17
+ const HorizontalBarStackComponent = defineComponent({
18
+ name: 'HorizontalBarStack',
19
+ description: 'One total split into a few named parts in a single 100% bar with a legend (incidents by severity, traffic by verdict). Use 2-6 parts; for a ranked list where each part needs its own row use BarList. value is the optional headline number above the bar; total > sum of parts leaves a grey remainder.',
20
+ props: __rspack_external_zod.object({
21
+ title: __rspack_external_zod.string(),
22
+ value: __rspack_external_zod.number().optional(),
23
+ format: numberFormat,
24
+ delta: __rspack_external_zod.object({
25
+ value: __rspack_external_zod.number(),
26
+ trend: __rspack_external_zod["enum"](TRENDS).optional(),
27
+ sentiment: __rspack_external_zod["enum"](SENTIMENTS).optional()
28
+ }).optional(),
29
+ total: __rspack_external_zod.number().optional(),
30
+ legend: __rspack_external_zod.boolean().optional(),
31
+ items: __rspack_external_zod.array(__rspack_external_zod.object({
32
+ name: __rspack_external_zod.string(),
33
+ value: __rspack_external_zod.number(),
34
+ color: __rspack_external_zod["enum"](CHART_COLORS).optional()
35
+ }))
36
+ }),
37
+ Skeleton: ({ title })=>/*#__PURE__*/ jsx(ChartSkeleton, {
38
+ title: title,
39
+ children: /*#__PURE__*/ jsx(HorizontalBarStackSkeleton, {})
40
+ }),
41
+ View: ({ props })=>/*#__PURE__*/ jsxs(Chart, {
42
+ className: "h-full",
43
+ children: [
44
+ /*#__PURE__*/ jsx(ChartHeader, {
45
+ children: /*#__PURE__*/ jsx(ChartTitle, {
46
+ children: props.title
47
+ })
48
+ }),
49
+ /*#__PURE__*/ jsx(HorizontalBarStack, {
50
+ data: props.items,
51
+ total: props.total,
52
+ legend: props.legend,
53
+ children: void 0 !== props.value && /*#__PURE__*/ jsxs(MetricHeader, {
54
+ children: [
55
+ /*#__PURE__*/ jsx(MetricValue, {
56
+ children: formatNumber(props.value, props.format)
57
+ }),
58
+ props.delta && /*#__PURE__*/ jsx(MetricDelta, {
59
+ ...props.delta
60
+ })
61
+ ]
62
+ })
63
+ })
64
+ ]
65
+ })
66
+ });
67
+ export { HorizontalBarStackComponent };
@@ -0,0 +1,36 @@
1
+ import * as z from 'zod';
2
+ export declare const LineChartComponent: import("../index.js").GenUiComponent<z.ZodObject<{
3
+ title: z.ZodString;
4
+ series: z.ZodArray<z.ZodObject<{
5
+ key: z.ZodString;
6
+ label: z.ZodString;
7
+ color: z.ZodOptional<z.ZodEnum<{
8
+ amber: "amber";
9
+ blue: "blue";
10
+ brand: "brand";
11
+ green: "green";
12
+ purple: "purple";
13
+ red: "red";
14
+ slate: "slate";
15
+ }>>;
16
+ variant: z.ZodOptional<z.ZodEnum<{
17
+ dashed: "dashed";
18
+ solid: "solid";
19
+ }>>;
20
+ }, z.core.$strip>>;
21
+ points: z.ZodArray<z.ZodObject<{
22
+ x: z.ZodString;
23
+ }, z.core.$catchall<z.ZodNullable<z.ZodNumber>>>>;
24
+ xFormat: z.ZodOptional<z.ZodEnum<{
25
+ date: "date";
26
+ datetime: "datetime";
27
+ time: "time";
28
+ }>>;
29
+ yFormat: z.ZodOptional<z.ZodEnum<{
30
+ bytes: "bytes";
31
+ compact: "compact";
32
+ ms: "ms";
33
+ number: "number";
34
+ percent: "percent";
35
+ }>>;
36
+ }, z.core.$strip>>;
@@ -0,0 +1,101 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Chart, ChartHeader, ChartTitle, LineChart, LineChartBody, LineChartEmpty, LineChartGrid, LineChartHoverPopover, LineChartHoverPopoverDot, LineChartHoverPopoverRow, LineChartHoverPopoverTimestamp, LineChartLegend, LineChartLegendItem, LineChartLine, LineChartTooltip, LineChartXAxis, LineChartYAxis } from "@wallarm-org/design-system/SimpleCharts";
3
+ import { allOf, defineComponent, seriesKey, unique } from "../core/define.js";
4
+ import { formatNumber, formatTime, numberFormat, timeFormat } from "../core/format.js";
5
+ import { ChartSkeleton } from "../render/ChartSkeleton.js";
6
+ import { CHART_COLORS } from "./BarList.js";
7
+ import * as __rspack_external_zod from "zod";
8
+ const VARIANTS = allOf()([
9
+ 'solid',
10
+ 'dashed'
11
+ ]);
12
+ const LineChartComponent = defineComponent({
13
+ name: 'LineChart',
14
+ description: "A time series: one or more lines over time (requests per hour, attacks per day). series lists the lines; each point is { x: ISO time, <series key>: number }, sorted by x ascending. A missing or null value leaves a gap. Use BarList for a ranking, Metric for a single number.",
15
+ props: __rspack_external_zod.object({
16
+ title: __rspack_external_zod.string(),
17
+ series: __rspack_external_zod.array(__rspack_external_zod.object({
18
+ key: seriesKey.describe('The field in each point that holds this line’s value'),
19
+ label: __rspack_external_zod.string(),
20
+ color: __rspack_external_zod["enum"](CHART_COLORS).optional(),
21
+ variant: __rspack_external_zod["enum"](VARIANTS).optional().describe('dashed for a baseline or forecast')
22
+ })).refine(unique('key'), 'series keys must be unique'),
23
+ points: __rspack_external_zod.array(__rspack_external_zod.object({
24
+ x: __rspack_external_zod.string()
25
+ }).catchall(__rspack_external_zod.number().nullable())),
26
+ xFormat: timeFormat,
27
+ yFormat: numberFormat
28
+ }),
29
+ Skeleton: ({ title })=>/*#__PURE__*/ jsx(ChartSkeleton, {
30
+ title: title
31
+ }),
32
+ View: ({ props })=>{
33
+ const { series, points } = props;
34
+ const formatX = (value)=>formatTime(String(value), props.xFormat);
35
+ const formatY = (value)=>'number' == typeof value ? formatNumber(value, props.yFormat) : '—';
36
+ const tooltip = ({ rows, xValue })=>/*#__PURE__*/ jsxs(LineChartHoverPopover, {
37
+ children: [
38
+ /*#__PURE__*/ jsx(LineChartHoverPopoverTimestamp, {
39
+ children: formatX(xValue)
40
+ }),
41
+ rows.map((row)=>/*#__PURE__*/ jsx(LineChartHoverPopoverRow, {
42
+ series: row.series,
43
+ value: row.value,
44
+ formatValue: formatY
45
+ }, row.series.key))
46
+ ]
47
+ });
48
+ return /*#__PURE__*/ jsxs(Chart, {
49
+ className: "h-full",
50
+ children: [
51
+ /*#__PURE__*/ jsx(ChartHeader, {
52
+ children: /*#__PURE__*/ jsx(ChartTitle, {
53
+ children: props.title
54
+ })
55
+ }),
56
+ 0 === points.length || 0 === series.length ? /*#__PURE__*/ jsx(LineChartEmpty, {
57
+ children: "No data"
58
+ }) : /*#__PURE__*/ jsxs(LineChart, {
59
+ data: points,
60
+ series: series,
61
+ xKey: "x",
62
+ children: [
63
+ series.length > 1 && /*#__PURE__*/ jsx(LineChartLegend, {
64
+ children: series.map((s)=>/*#__PURE__*/ jsxs(LineChartLegendItem, {
65
+ seriesKey: s.key,
66
+ children: [
67
+ /*#__PURE__*/ jsx(LineChartHoverPopoverDot, {
68
+ color: s.color
69
+ }),
70
+ /*#__PURE__*/ jsx("span", {
71
+ className: "font-mono text-xs text-text-primary",
72
+ children: s.label
73
+ })
74
+ ]
75
+ }, s.key))
76
+ }),
77
+ /*#__PURE__*/ jsxs(LineChartBody, {
78
+ children: [
79
+ /*#__PURE__*/ jsx(LineChartGrid, {}),
80
+ /*#__PURE__*/ jsx(LineChartXAxis, {
81
+ tickFormatter: formatX,
82
+ density: "normal"
83
+ }),
84
+ /*#__PURE__*/ jsx(LineChartYAxis, {
85
+ tickFormatter: formatY
86
+ }),
87
+ series.map((s)=>/*#__PURE__*/ jsx(LineChartLine, {
88
+ seriesKey: s.key
89
+ }, s.key)),
90
+ /*#__PURE__*/ jsx(LineChartTooltip, {
91
+ children: tooltip
92
+ })
93
+ ]
94
+ })
95
+ ]
96
+ })
97
+ ]
98
+ });
99
+ }
100
+ });
101
+ export { LineChartComponent };
@@ -0,0 +1,35 @@
1
+ import * as z from 'zod';
2
+ export declare const MetricComponent: import("../index.js").GenUiComponent<z.ZodObject<{
3
+ title: z.ZodString;
4
+ value: z.ZodNumber;
5
+ format: z.ZodOptional<z.ZodEnum<{
6
+ bytes: "bytes";
7
+ compact: "compact";
8
+ ms: "ms";
9
+ number: "number";
10
+ percent: "percent";
11
+ }>>;
12
+ caption: z.ZodOptional<z.ZodString>;
13
+ delta: z.ZodOptional<z.ZodObject<{
14
+ value: z.ZodNumber;
15
+ trend: z.ZodOptional<z.ZodEnum<{
16
+ down: "down";
17
+ up: "up";
18
+ }>>;
19
+ sentiment: z.ZodOptional<z.ZodEnum<{
20
+ negative: "negative";
21
+ neutral: "neutral";
22
+ positive: "positive";
23
+ }>>;
24
+ }, z.core.$strip>>;
25
+ sparkline: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
+ x: z.ZodString;
27
+ y: z.ZodNumber;
28
+ }, z.core.$strip>>>;
29
+ sparklineColor: z.ZodOptional<z.ZodEnum<{
30
+ brand: "brand";
31
+ negative: "negative";
32
+ neutral: "neutral";
33
+ positive: "positive";
34
+ }>>;
35
+ }, z.core.$strip>>;
@@ -0,0 +1,85 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Chart, ChartHeader, ChartTitle, Metric, MetricCaption, MetricDelta, MetricHeader, MetricSkeleton, MetricSparkline, MetricValue } from "@wallarm-org/design-system/SimpleCharts";
3
+ import { allOf, defineComponent } from "../core/define.js";
4
+ import { formatNumber, numberFormat } from "../core/format.js";
5
+ import { ChartSkeleton } from "../render/ChartSkeleton.js";
6
+ import * as __rspack_external_zod from "zod";
7
+ const TRENDS = allOf()([
8
+ 'up',
9
+ 'down'
10
+ ]);
11
+ const SPARKLINE_COLORS = allOf()([
12
+ 'brand',
13
+ 'positive',
14
+ 'negative',
15
+ 'neutral'
16
+ ]);
17
+ const SENTIMENTS = allOf()([
18
+ 'positive',
19
+ 'negative',
20
+ 'neutral'
21
+ ]);
22
+ const MetricComponent = defineComponent({
23
+ name: 'Metric',
24
+ description: 'One headline number on a card (a KPI tile), optionally with its change. sentiment is the meaning (an increase in attacks is negative), trend is the arrow. Add sparkline for the trend over the period.',
25
+ props: __rspack_external_zod.object({
26
+ title: __rspack_external_zod.string(),
27
+ value: __rspack_external_zod.number(),
28
+ format: numberFormat,
29
+ caption: __rspack_external_zod.string().optional(),
30
+ delta: __rspack_external_zod.object({
31
+ value: __rspack_external_zod.number(),
32
+ trend: __rspack_external_zod["enum"](TRENDS).optional(),
33
+ sentiment: __rspack_external_zod["enum"](SENTIMENTS).optional()
34
+ }).optional(),
35
+ sparkline: __rspack_external_zod.array(__rspack_external_zod.object({
36
+ x: __rspack_external_zod.string(),
37
+ y: __rspack_external_zod.number()
38
+ })).optional().describe('Trend over the period: points oldest first, x is an ISO time, y the value'),
39
+ sparklineColor: __rspack_external_zod["enum"](SPARKLINE_COLORS).optional().describe('Match it to the delta sentiment; brand by default')
40
+ }),
41
+ Skeleton: ({ title })=>/*#__PURE__*/ jsx(ChartSkeleton, {
42
+ title: title,
43
+ children: /*#__PURE__*/ jsx(MetricSkeleton, {})
44
+ }),
45
+ View: ({ props })=>/*#__PURE__*/ jsx("div", {
46
+ className: "h-full min-w-0 flex-1",
47
+ children: /*#__PURE__*/ jsxs(Chart, {
48
+ className: "h-full",
49
+ children: [
50
+ /*#__PURE__*/ jsx(ChartHeader, {
51
+ children: /*#__PURE__*/ jsx(ChartTitle, {
52
+ children: props.title
53
+ })
54
+ }),
55
+ /*#__PURE__*/ jsxs(Metric, {
56
+ children: [
57
+ /*#__PURE__*/ jsxs(MetricHeader, {
58
+ children: [
59
+ /*#__PURE__*/ jsx(MetricValue, {
60
+ children: formatNumber(props.value, props.format)
61
+ }),
62
+ props.delta && /*#__PURE__*/ jsx(MetricDelta, {
63
+ ...props.delta
64
+ })
65
+ ]
66
+ }),
67
+ props.caption && /*#__PURE__*/ jsx(MetricCaption, {
68
+ children: props.caption
69
+ })
70
+ ]
71
+ }),
72
+ props.sparkline && /*#__PURE__*/ jsx(MetricSparkline, {
73
+ data: props.sparkline.map((p)=>({
74
+ x: p.x,
75
+ value: p.y
76
+ })),
77
+ color: props.sparklineColor,
78
+ label: props.title,
79
+ formatValue: (v)=>formatNumber(v, props.format)
80
+ })
81
+ ]
82
+ })
83
+ })
84
+ });
85
+ export { MetricComponent };
@@ -0,0 +1,25 @@
1
+ import * as z from 'zod';
2
+ export declare const PieChartComponent: import("../index.js").GenUiComponent<z.ZodObject<{
3
+ title: z.ZodString;
4
+ format: z.ZodOptional<z.ZodEnum<{
5
+ bytes: "bytes";
6
+ compact: "compact";
7
+ ms: "ms";
8
+ number: "number";
9
+ percent: "percent";
10
+ }>>;
11
+ centerLabel: z.ZodOptional<z.ZodString>;
12
+ items: z.ZodArray<z.ZodObject<{
13
+ label: z.ZodString;
14
+ value: z.ZodNumber;
15
+ color: z.ZodOptional<z.ZodEnum<{
16
+ amber: "amber";
17
+ blue: "blue";
18
+ brand: "brand";
19
+ green: "green";
20
+ purple: "purple";
21
+ red: "red";
22
+ slate: "slate";
23
+ }>>;
24
+ }, z.core.$strip>>;
25
+ }, z.core.$strip>>;
@@ -0,0 +1,83 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Chart, ChartHeader, ChartTitle, LegendDot, PieChart, PieChartCenter, PieChartCenterLabel, PieChartCenterValue, PieChartDonut, PieChartLegend, PieChartLegendItem, PieChartLegendPercent, PieChartLegendValue, PieChartSkeleton } from "@wallarm-org/design-system/SimpleCharts";
3
+ import { defineComponent, unique } from "../core/define.js";
4
+ import { formatNumber, numberFormat } from "../core/format.js";
5
+ import { ChartSkeleton } from "../render/ChartSkeleton.js";
6
+ import { CHART_COLORS } from "./BarList.js";
7
+ import * as __rspack_external_zod from "zod";
8
+ const PieChartComponent = defineComponent({
9
+ name: 'PieChart',
10
+ description: 'A donut with a legend for the share of a whole (attack types, response status codes, traffic sources) where the parts add up to a meaningful total; 2-6 slices read best. Use BarList instead to compare magnitudes or rank many rows. items: unique labels, values are counts (percents are computed). centerLabel names the total in the middle, e.g. "requests".',
11
+ props: __rspack_external_zod.object({
12
+ title: __rspack_external_zod.string(),
13
+ format: numberFormat,
14
+ centerLabel: __rspack_external_zod.string().optional(),
15
+ items: __rspack_external_zod.array(__rspack_external_zod.object({
16
+ label: __rspack_external_zod.string(),
17
+ value: __rspack_external_zod.number(),
18
+ color: __rspack_external_zod["enum"](CHART_COLORS).optional()
19
+ })).refine(unique('label'), 'labels must be unique')
20
+ }),
21
+ Skeleton: ({ title })=>/*#__PURE__*/ jsx(ChartSkeleton, {
22
+ title: title,
23
+ children: /*#__PURE__*/ jsx(PieChartSkeleton, {})
24
+ }),
25
+ View: ({ props })=>{
26
+ const { items } = props;
27
+ const data = items.map((item)=>({
28
+ name: item.label,
29
+ value: item.value,
30
+ color: item.color
31
+ }));
32
+ const total = items.reduce((sum, item)=>sum + Math.max(0, item.value), 0);
33
+ const formatHovered = (datum)=>formatNumber(datum.value, props.format);
34
+ return /*#__PURE__*/ jsxs(Chart, {
35
+ className: "h-full",
36
+ children: [
37
+ /*#__PURE__*/ jsx(ChartHeader, {
38
+ children: /*#__PURE__*/ jsx(ChartTitle, {
39
+ children: props.title
40
+ })
41
+ }),
42
+ /*#__PURE__*/ jsxs(PieChart, {
43
+ data: data,
44
+ children: [
45
+ /*#__PURE__*/ jsx(PieChartDonut, {
46
+ children: /*#__PURE__*/ jsxs(PieChartCenter, {
47
+ children: [
48
+ /*#__PURE__*/ jsx(PieChartCenterValue, {
49
+ formatHoveredValue: formatHovered,
50
+ children: formatNumber(total, props.format)
51
+ }),
52
+ props.centerLabel && /*#__PURE__*/ jsx(PieChartCenterLabel, {
53
+ className: "whitespace-nowrap",
54
+ children: props.centerLabel
55
+ })
56
+ ]
57
+ })
58
+ }),
59
+ /*#__PURE__*/ jsx(PieChartLegend, {
60
+ children: items.map((item)=>/*#__PURE__*/ jsxs(PieChartLegendItem, {
61
+ name: item.label,
62
+ children: [
63
+ /*#__PURE__*/ jsx("span", {
64
+ className: "min-w-0 flex-1 truncate text-xs text-text-primary",
65
+ children: item.label
66
+ }),
67
+ /*#__PURE__*/ jsxs(PieChartLegendValue, {
68
+ children: [
69
+ formatNumber(item.value, props.format),
70
+ /*#__PURE__*/ jsx(LegendDot, {}),
71
+ /*#__PURE__*/ jsx(PieChartLegendPercent, {})
72
+ ]
73
+ })
74
+ ]
75
+ }, item.label))
76
+ })
77
+ ]
78
+ })
79
+ ]
80
+ });
81
+ }
82
+ });
83
+ export { PieChartComponent };
@@ -0,0 +1,5 @@
1
+ import * as z from 'zod';
2
+ export declare const SectionComponent: import("../index.js").GenUiComponent<z.ZodObject<{
3
+ title: z.ZodString;
4
+ subtitle: z.ZodOptional<z.ZodString>;
5
+ }, z.core.$strip>>;
@@ -0,0 +1,39 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Heading } from "@wallarm-org/design-system/Heading";
3
+ import { VStack } from "@wallarm-org/design-system/Stack";
4
+ import { Text } from "@wallarm-org/design-system/Text";
5
+ import { defineComponent } from "../core/define.js";
6
+ import * as __rspack_external_zod from "zod";
7
+ const SectionComponent = defineComponent({
8
+ name: 'Section',
9
+ description: 'A titled block of a page or dashboard: a heading, an optional one-line subtitle, then its children. Use one per topic (Traffic, Threats, Endpoints).',
10
+ props: __rspack_external_zod.object({
11
+ title: __rspack_external_zod.string(),
12
+ subtitle: __rspack_external_zod.string().optional()
13
+ }),
14
+ hasChildren: true,
15
+ View: ({ props, children })=>/*#__PURE__*/ jsxs(VStack, {
16
+ gap: 12,
17
+ align: "stretch",
18
+ fullWidth: true,
19
+ children: [
20
+ /*#__PURE__*/ jsxs(VStack, {
21
+ gap: 2,
22
+ align: "start",
23
+ children: [
24
+ /*#__PURE__*/ jsx(Heading, {
25
+ size: "lg",
26
+ weight: "medium",
27
+ children: props.title
28
+ }),
29
+ props.subtitle && /*#__PURE__*/ jsx(Text, {
30
+ color: "secondary",
31
+ children: props.subtitle
32
+ })
33
+ ]
34
+ }),
35
+ children
36
+ ]
37
+ })
38
+ });
39
+ export { SectionComponent };
@@ -0,0 +1,18 @@
1
+ import * as z from 'zod';
2
+ import { type StackProps } from '@wallarm-org/design-system/Stack';
3
+ /** The gaps the catalog offers, each mapped to a DS gap: a gap the DS drops fails typecheck. */
4
+ export declare const GAPS: readonly ['4', '8', '12', '16', '24'];
5
+ export declare const GAP: Record<(typeof GAPS)[number], NonNullable<StackProps['gap']>>;
6
+ export declare const StackComponent: import("../index.js").GenUiComponent<z.ZodObject<{
7
+ direction: z.ZodOptional<z.ZodEnum<{
8
+ column: "column";
9
+ row: "row";
10
+ }>>;
11
+ gap: z.ZodOptional<z.ZodEnum<{
12
+ 12: "12";
13
+ 16: "16";
14
+ 24: "24";
15
+ 4: "4";
16
+ 8: "8";
17
+ }>>;
18
+ }, z.core.$strip>>;
@@ -0,0 +1,41 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Stack } from "@wallarm-org/design-system/Stack";
3
+ import { defineComponent } from "../core/define.js";
4
+ import * as __rspack_external_zod from "zod";
5
+ const GAPS = [
6
+ '4',
7
+ '8',
8
+ '12',
9
+ '16',
10
+ '24'
11
+ ];
12
+ const GAP = {
13
+ 4: 4,
14
+ 8: 8,
15
+ 12: 12,
16
+ 16: 16,
17
+ 24: 24
18
+ };
19
+ const StackComponent = defineComponent({
20
+ name: 'Stack',
21
+ description: 'Lays children out in a row or a column. Use a row for side-by-side metrics.',
22
+ props: __rspack_external_zod.object({
23
+ direction: __rspack_external_zod["enum"]([
24
+ 'row',
25
+ 'column'
26
+ ]).optional().describe('Default column'),
27
+ gap: __rspack_external_zod["enum"](GAPS).optional().describe('Space between children, px. Default 12')
28
+ }),
29
+ hasChildren: true,
30
+ View: ({ props, children })=>{
31
+ const direction = props.direction ?? 'column';
32
+ return /*#__PURE__*/ jsx(Stack, {
33
+ direction: direction,
34
+ gap: GAP[props.gap ?? '12'],
35
+ wrap: 'row' === direction ? 'wrap' : 'nowrap',
36
+ fullWidth: true,
37
+ children: children
38
+ });
39
+ }
40
+ });
41
+ export { GAP, GAPS, StackComponent };
@@ -0,0 +1,30 @@
1
+ import * as z from 'zod';
2
+ export declare const TableComponent: import("../index.js").GenUiComponent<z.ZodObject<{
3
+ title: z.ZodOptional<z.ZodString>;
4
+ rowKey: z.ZodString;
5
+ columns: z.ZodArray<z.ZodObject<{
6
+ key: z.ZodString;
7
+ header: z.ZodString;
8
+ type: z.ZodOptional<z.ZodEnum<{
9
+ badge: "badge";
10
+ code: "code";
11
+ datetime: "datetime";
12
+ ip: "ip";
13
+ method: "method";
14
+ number: "number";
15
+ status: "status";
16
+ text: "text";
17
+ }>>;
18
+ format: z.ZodOptional<z.ZodEnum<{
19
+ bytes: "bytes";
20
+ compact: "compact";
21
+ date: "date";
22
+ datetime: "datetime";
23
+ ms: "ms";
24
+ number: "number";
25
+ percent: "percent";
26
+ relative: "relative";
27
+ }>>;
28
+ }, z.core.$strip>>;
29
+ rows: z.ZodArray<z.ZodObject<{}, z.core.$loose>>;
30
+ }, z.core.$strip>>;