@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.
- package/README.md +153 -2
- package/dist/a2ui/A2uiSurfaces.d.ts +16 -0
- package/dist/a2ui/A2uiSurfaces.js +61 -0
- package/dist/a2ui/catalog.d.ts +16 -0
- package/dist/a2ui/catalog.js +66 -0
- package/dist/a2ui/check.d.ts +4 -0
- package/dist/a2ui/check.js +34 -0
- package/dist/a2ui/express.d.ts +38 -0
- package/dist/a2ui/express.js +64 -0
- package/dist/a2ui/index.d.ts +8 -0
- package/dist/a2ui/index.js +4 -0
- package/dist/a2ui/prompt.d.ts +16 -0
- package/dist/a2ui/prompt.js +17 -0
- package/dist/a2ui/toA2uiSchema.d.ts +19 -0
- package/dist/a2ui/toA2uiSchema.js +61 -0
- package/dist/components/Alert.d.ts +11 -0
- package/dist/components/Alert.js +43 -0
- package/dist/components/AreaChart.d.ts +36 -0
- package/dist/components/AreaChart.js +90 -0
- package/dist/components/Badge.d.ts +11 -0
- package/dist/components/Badge.js +30 -0
- package/dist/components/BarList.d.ts +26 -0
- package/dist/components/BarList.js +66 -0
- package/dist/components/Button.d.ts +10 -0
- package/dist/components/Button.js +40 -0
- package/dist/components/Card.d.ts +2 -0
- package/dist/components/Card.js +17 -0
- package/dist/components/ColumnChart.d.ts +32 -0
- package/dist/components/ColumnChart.js +114 -0
- package/dist/components/Grid.d.ts +29 -0
- package/dist/components/Grid.js +72 -0
- package/dist/components/Heading.d.ts +10 -0
- package/dist/components/Heading.js +29 -0
- package/dist/components/HorizontalBarStack.d.ts +39 -0
- package/dist/components/HorizontalBarStack.js +67 -0
- package/dist/components/LineChart.d.ts +36 -0
- package/dist/components/LineChart.js +101 -0
- package/dist/components/Metric.d.ts +35 -0
- package/dist/components/Metric.js +85 -0
- package/dist/components/PieChart.d.ts +25 -0
- package/dist/components/PieChart.js +83 -0
- package/dist/components/Section.d.ts +5 -0
- package/dist/components/Section.js +39 -0
- package/dist/components/Stack.d.ts +18 -0
- package/dist/components/Stack.js +41 -0
- package/dist/components/Table.d.ts +30 -0
- package/dist/components/Table.js +128 -0
- package/dist/components/Text.d.ts +9 -0
- package/dist/components/Text.js +27 -0
- package/dist/components/index.d.ts +20 -0
- package/dist/components/index.js +55 -0
- package/dist/core/check.d.ts +35 -0
- package/dist/core/check.js +63 -0
- package/dist/core/define.d.ts +64 -0
- package/dist/core/define.js +7 -0
- package/dist/core/format.d.ts +24 -0
- package/dist/core/format.js +74 -0
- package/dist/core/guards.d.ts +2 -0
- package/dist/core/guards.js +2 -0
- package/dist/fixtures/apiInventory.d.ts +36 -0
- package/dist/fixtures/apiInventory.js +287 -0
- package/dist/fixtures/attackSummary.d.ts +13 -0
- package/dist/fixtures/attackSummary.js +329 -0
- package/dist/fixtures/dashboard.d.ts +119 -0
- package/dist/fixtures/dashboard.js +428 -0
- package/dist/fixtures/incident.d.ts +44 -0
- package/dist/fixtures/incident.js +331 -0
- package/dist/fixtures/index.d.ts +13 -0
- package/dist/fixtures/index.js +9 -0
- package/dist/fixtures/liveMonitor.d.ts +9 -0
- package/dist/fixtures/liveMonitor.js +180 -0
- package/dist/fixtures/openui.d.ts +16 -0
- package/dist/fixtures/openui.js +74 -0
- package/dist/fixtures/scenarios.d.ts +13 -0
- package/dist/fixtures/scenarios.js +39 -0
- package/dist/fixtures/stream.d.ts +79 -0
- package/dist/fixtures/stream.js +147 -0
- package/dist/fixtures/weeklyReport.d.ts +46 -0
- package/dist/fixtures/weeklyReport.js +266 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +4 -0
- package/dist/json-render/JsonRenderSurface.d.ts +13 -0
- package/dist/json-render/JsonRenderSurface.js +63 -0
- package/dist/json-render/catalog.d.ts +64 -0
- package/dist/json-render/catalog.js +50 -0
- package/dist/json-render/check.d.ts +4 -0
- package/dist/json-render/check.js +13 -0
- package/dist/json-render/index.d.ts +6 -0
- package/dist/json-render/index.js +4 -0
- package/dist/json-render/spec.d.ts +23 -0
- package/dist/json-render/spec.js +77 -0
- package/dist/openui/OpenUiSurface.d.ts +24 -0
- package/dist/openui/OpenUiSurface.js +30 -0
- package/dist/openui/catalog.d.ts +23 -0
- package/dist/openui/catalog.js +65 -0
- package/dist/openui/check.d.ts +4 -0
- package/dist/openui/check.js +68 -0
- package/dist/openui/index.d.ts +5 -0
- package/dist/openui/index.js +3 -0
- package/dist/playground/GenUiChatDemo.d.ts +11 -0
- package/dist/playground/GenUiChatDemo.js +148 -0
- package/dist/playground/GenUiPlayground.d.ts +15 -0
- package/dist/playground/GenUiPlayground.js +413 -0
- package/dist/playground/index.d.ts +3 -0
- package/dist/playground/index.js +2 -0
- package/dist/playground/useEmulatedAgent.d.ts +37 -0
- package/dist/playground/useEmulatedAgent.js +221 -0
- package/dist/render/ChartSkeleton.d.ts +6 -0
- package/dist/render/ChartSkeleton.js +26 -0
- package/dist/render/GuardedView.d.ts +18 -0
- package/dist/render/GuardedView.js +24 -0
- package/dist/render/Placeholder.d.ts +16 -0
- package/dist/render/Placeholder.js +15 -0
- package/dist/render/SurfaceBoundary.d.ts +15 -0
- package/dist/render/SurfaceBoundary.js +15 -0
- package/dist/render/warn.d.ts +1 -0
- package/dist/render/warn.js +2 -0
- package/package.json +94 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const AreaChartComponent: import("../index.js").GenUiComponent<z.ZodObject<{
|
|
3
|
+
title: z.ZodString;
|
|
4
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
5
|
+
stacked: "stacked";
|
|
6
|
+
standard: "standard";
|
|
7
|
+
}>>;
|
|
8
|
+
series: z.ZodArray<z.ZodObject<{
|
|
9
|
+
key: z.ZodString;
|
|
10
|
+
label: z.ZodString;
|
|
11
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
amber: "amber";
|
|
13
|
+
blue: "blue";
|
|
14
|
+
brand: "brand";
|
|
15
|
+
green: "green";
|
|
16
|
+
purple: "purple";
|
|
17
|
+
red: "red";
|
|
18
|
+
slate: "slate";
|
|
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,90 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AreaChart, AreaChartArea, AreaChartBody, Chart, ChartHeader, ChartTitle, LineChartEmpty, LineChartGrid, LineChartHoverPopoverDot, LineChartLegend, LineChartLegendItem, 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
|
+
'stacked',
|
|
10
|
+
'standard'
|
|
11
|
+
]);
|
|
12
|
+
const AreaChartComponent = defineComponent({
|
|
13
|
+
name: 'AreaChart',
|
|
14
|
+
description: "Volume over time drawn with filled areas: stacked to show how series add up to a total (traffic by verdict), standard to overlay series that should not be summed. series lists the areas; each point is { x: ISO time, <series key>: number }, sorted by x ascending. null means no value for that series at that x.",
|
|
15
|
+
props: __rspack_external_zod.object({
|
|
16
|
+
title: __rspack_external_zod.string(),
|
|
17
|
+
variant: __rspack_external_zod["enum"](VARIANTS).optional().describe('stacked (default) sums the series; standard overlays them from zero'),
|
|
18
|
+
series: __rspack_external_zod.array(__rspack_external_zod.object({
|
|
19
|
+
key: seriesKey.describe('The field in each point that holds this area’s value'),
|
|
20
|
+
label: __rspack_external_zod.string(),
|
|
21
|
+
color: __rspack_external_zod["enum"](CHART_COLORS).optional()
|
|
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
|
+
return /*#__PURE__*/ jsxs(Chart, {
|
|
37
|
+
className: "h-full",
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ jsx(ChartHeader, {
|
|
40
|
+
children: /*#__PURE__*/ jsx(ChartTitle, {
|
|
41
|
+
children: props.title
|
|
42
|
+
})
|
|
43
|
+
}),
|
|
44
|
+
0 === points.length || 0 === series.length ? /*#__PURE__*/ jsx(LineChartEmpty, {
|
|
45
|
+
children: "No data"
|
|
46
|
+
}) : /*#__PURE__*/ jsxs(AreaChart, {
|
|
47
|
+
data: points,
|
|
48
|
+
series: series,
|
|
49
|
+
xKey: "x",
|
|
50
|
+
variant: props.variant,
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ jsx(LineChartLegend, {
|
|
53
|
+
children: series.map((s)=>/*#__PURE__*/ jsxs(LineChartLegendItem, {
|
|
54
|
+
seriesKey: s.key,
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ jsx(LineChartHoverPopoverDot, {
|
|
57
|
+
color: s.color
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ jsx("span", {
|
|
60
|
+
className: "text-xs font-mono text-text-primary",
|
|
61
|
+
children: s.label
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}, s.key))
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ jsxs(AreaChartBody, {
|
|
67
|
+
children: [
|
|
68
|
+
/*#__PURE__*/ jsx(LineChartGrid, {}),
|
|
69
|
+
/*#__PURE__*/ jsx(LineChartXAxis, {
|
|
70
|
+
tickFormatter: formatX,
|
|
71
|
+
density: "normal"
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ jsx(LineChartYAxis, {
|
|
74
|
+
tickFormatter: formatY
|
|
75
|
+
}),
|
|
76
|
+
series.map((s)=>/*#__PURE__*/ jsx(AreaChartArea, {
|
|
77
|
+
seriesKey: s.key
|
|
78
|
+
}, s.key)),
|
|
79
|
+
/*#__PURE__*/ jsx(LineChartTooltip, {
|
|
80
|
+
xTickFormatter: formatX
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
export { AreaChartComponent };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const BadgeComponent: import("../index.js").GenUiComponent<z.ZodObject<{
|
|
3
|
+
text: z.ZodString;
|
|
4
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
5
|
+
amber: "amber";
|
|
6
|
+
blue: "blue";
|
|
7
|
+
green: "green";
|
|
8
|
+
red: "red";
|
|
9
|
+
slate: "slate";
|
|
10
|
+
}>>;
|
|
11
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Badge } from "@wallarm-org/design-system/Badge";
|
|
3
|
+
import { Skeleton } from "@wallarm-org/design-system/Skeleton";
|
|
4
|
+
import { defineComponent, subsetOf } from "../core/define.js";
|
|
5
|
+
import * as __rspack_external_zod from "zod";
|
|
6
|
+
const BadgeComponent = defineComponent({
|
|
7
|
+
name: 'Badge',
|
|
8
|
+
description: 'A short status label, e.g. a severity or an attack type.',
|
|
9
|
+
props: __rspack_external_zod.object({
|
|
10
|
+
text: __rspack_external_zod.string(),
|
|
11
|
+
color: __rspack_external_zod["enum"](subsetOf()([
|
|
12
|
+
'slate',
|
|
13
|
+
'red',
|
|
14
|
+
'amber',
|
|
15
|
+
'green',
|
|
16
|
+
'blue'
|
|
17
|
+
])).optional()
|
|
18
|
+
}),
|
|
19
|
+
Skeleton: ()=>/*#__PURE__*/ jsx(Skeleton, {
|
|
20
|
+
width: "64px",
|
|
21
|
+
height: "20px",
|
|
22
|
+
transparent: false
|
|
23
|
+
}),
|
|
24
|
+
View: ({ props })=>/*#__PURE__*/ jsx(Badge, {
|
|
25
|
+
type: "secondary",
|
|
26
|
+
color: props.color ?? 'slate',
|
|
27
|
+
children: props.text
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
export { BadgeComponent };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/** The chart palette the catalog offers; shared by every chart entry. */
|
|
3
|
+
export declare const CHART_COLORS: readonly ["brand", "blue", "green", "red", "amber", "purple", "slate"];
|
|
4
|
+
export declare const BarListComponent: import("../index.js").GenUiComponent<z.ZodObject<{
|
|
5
|
+
title: z.ZodString;
|
|
6
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
bytes: "bytes";
|
|
8
|
+
compact: "compact";
|
|
9
|
+
ms: "ms";
|
|
10
|
+
number: "number";
|
|
11
|
+
percent: "percent";
|
|
12
|
+
}>>;
|
|
13
|
+
items: z.ZodArray<z.ZodObject<{
|
|
14
|
+
label: z.ZodString;
|
|
15
|
+
value: z.ZodNumber;
|
|
16
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
amber: "amber";
|
|
18
|
+
blue: "blue";
|
|
19
|
+
brand: "brand";
|
|
20
|
+
green: "green";
|
|
21
|
+
purple: "purple";
|
|
22
|
+
red: "red";
|
|
23
|
+
slate: "slate";
|
|
24
|
+
}>>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BarList, BarListBar, BarListItem, BarListLabel, BarListPercent, BarListSkeleton, BarListValue, Chart, ChartHeader, ChartTitle } from "@wallarm-org/design-system/SimpleCharts";
|
|
3
|
+
import { defineComponent, subsetOf, unique } 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 CHART_COLORS = subsetOf()([
|
|
8
|
+
'brand',
|
|
9
|
+
'blue',
|
|
10
|
+
'green',
|
|
11
|
+
'red',
|
|
12
|
+
'amber',
|
|
13
|
+
'purple',
|
|
14
|
+
'slate'
|
|
15
|
+
]);
|
|
16
|
+
const BarListComponent = defineComponent({
|
|
17
|
+
name: 'BarList',
|
|
18
|
+
description: 'A ranked top-N breakdown (endpoints, IPs, attack types). Send rows sorted.',
|
|
19
|
+
props: __rspack_external_zod.object({
|
|
20
|
+
title: __rspack_external_zod.string(),
|
|
21
|
+
format: numberFormat,
|
|
22
|
+
items: __rspack_external_zod.array(__rspack_external_zod.object({
|
|
23
|
+
label: __rspack_external_zod.string(),
|
|
24
|
+
value: __rspack_external_zod.number(),
|
|
25
|
+
color: __rspack_external_zod["enum"](CHART_COLORS).optional()
|
|
26
|
+
})).refine(unique('label'), 'labels must be unique')
|
|
27
|
+
}),
|
|
28
|
+
Skeleton: ({ title })=>/*#__PURE__*/ jsx(ChartSkeleton, {
|
|
29
|
+
title: title,
|
|
30
|
+
children: /*#__PURE__*/ jsx(BarListSkeleton, {})
|
|
31
|
+
}),
|
|
32
|
+
View: ({ props })=>{
|
|
33
|
+
const { items } = props;
|
|
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__*/ jsx(BarList, {
|
|
43
|
+
max: items.reduce((sum, item)=>sum + item.value, 0),
|
|
44
|
+
children: items.map((item)=>/*#__PURE__*/ jsxs(BarListItem, {
|
|
45
|
+
value: item.value,
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ jsx(BarListBar, {
|
|
48
|
+
color: item.color
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsx(BarListLabel, {
|
|
51
|
+
children: item.label
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ jsxs(BarListValue, {
|
|
54
|
+
children: [
|
|
55
|
+
formatNumber(item.value, props.format),
|
|
56
|
+
/*#__PURE__*/ jsx(BarListPercent, {})
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
}, item.label))
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
export { BarListComponent, CHART_COLORS };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const ButtonComponent: import("../index.js").GenUiComponent<z.ZodObject<{
|
|
3
|
+
label: z.ZodString;
|
|
4
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
5
|
+
ghost: "ghost";
|
|
6
|
+
outline: "outline";
|
|
7
|
+
primary: "primary";
|
|
8
|
+
}>>;
|
|
9
|
+
destructive: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "@wallarm-org/design-system/Button";
|
|
3
|
+
import { Skeleton } from "@wallarm-org/design-system/Skeleton";
|
|
4
|
+
import { defineComponent, subsetOf } from "../core/define.js";
|
|
5
|
+
import * as __rspack_external_zod from "zod";
|
|
6
|
+
const VARIANTS = subsetOf()([
|
|
7
|
+
'primary',
|
|
8
|
+
'outline',
|
|
9
|
+
'ghost'
|
|
10
|
+
]);
|
|
11
|
+
const COLOR = {
|
|
12
|
+
primary: 'brand',
|
|
13
|
+
outline: 'neutral',
|
|
14
|
+
ghost: 'neutral'
|
|
15
|
+
};
|
|
16
|
+
const ButtonComponent = defineComponent({
|
|
17
|
+
name: 'Button',
|
|
18
|
+
description: 'Asks the app to do something. The app runs the action; side effects still go through approval.',
|
|
19
|
+
props: __rspack_external_zod.object({
|
|
20
|
+
label: __rspack_external_zod.string(),
|
|
21
|
+
variant: __rspack_external_zod["enum"](VARIANTS).optional(),
|
|
22
|
+
destructive: __rspack_external_zod.boolean().optional()
|
|
23
|
+
}),
|
|
24
|
+
events: [
|
|
25
|
+
'press'
|
|
26
|
+
],
|
|
27
|
+
Skeleton: ()=>/*#__PURE__*/ jsx(Skeleton, {
|
|
28
|
+
width: "120px",
|
|
29
|
+
height: "36px",
|
|
30
|
+
rounded: 8,
|
|
31
|
+
transparent: false
|
|
32
|
+
}),
|
|
33
|
+
View: ({ props, emit })=>/*#__PURE__*/ jsx(Button, {
|
|
34
|
+
variant: props.variant ?? 'outline',
|
|
35
|
+
color: props.destructive ? 'destructive' : COLOR[props.variant ?? 'outline'],
|
|
36
|
+
onClick: ()=>emit('press'),
|
|
37
|
+
children: props.label
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
export { ButtonComponent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardContent } from "@wallarm-org/design-system/Card";
|
|
3
|
+
import { defineComponent } from "../core/define.js";
|
|
4
|
+
import * as __rspack_external_zod from "zod";
|
|
5
|
+
const CardComponent = defineComponent({
|
|
6
|
+
name: 'Card',
|
|
7
|
+
description: 'A bordered surface that groups related content.',
|
|
8
|
+
props: __rspack_external_zod.object({}),
|
|
9
|
+
hasChildren: true,
|
|
10
|
+
View: ({ children })=>/*#__PURE__*/ jsx(Card, {
|
|
11
|
+
className: "h-full",
|
|
12
|
+
children: /*#__PURE__*/ jsx(CardContent, {
|
|
13
|
+
children: children
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
export { CardComponent };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const ColumnChartComponent: 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
|
+
}, z.core.$strip>>;
|
|
17
|
+
points: z.ZodArray<z.ZodObject<{
|
|
18
|
+
x: z.ZodString;
|
|
19
|
+
}, z.core.$catchall<z.ZodNullable<z.ZodNumber>>>>;
|
|
20
|
+
xFormat: z.ZodOptional<z.ZodEnum<{
|
|
21
|
+
date: "date";
|
|
22
|
+
datetime: "datetime";
|
|
23
|
+
time: "time";
|
|
24
|
+
}>>;
|
|
25
|
+
yFormat: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
bytes: "bytes";
|
|
27
|
+
compact: "compact";
|
|
28
|
+
ms: "ms";
|
|
29
|
+
number: "number";
|
|
30
|
+
percent: "percent";
|
|
31
|
+
}>>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Chart, ChartHeader, ChartTitle, ColumnChart, ColumnChartBody, ColumnChartStack, ColumnChartXAxis, LineChartEmpty, LineChartGrid, LineChartHoverPopover, LineChartHoverPopoverDot, LineChartHoverPopoverRow, LineChartHoverPopoverTimestamp, LineChartLegend, LineChartLegendItem, LineChartTooltip, LineChartYAxis } from "@wallarm-org/design-system/SimpleCharts";
|
|
3
|
+
import { 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 X_KEY = '__x';
|
|
9
|
+
const ColumnChartComponent = defineComponent({
|
|
10
|
+
name: 'ColumnChart',
|
|
11
|
+
description: "Vertical columns, one per time bucket or category (attacks per hour, requests per day), each split into its series stacked with the first series on top; one series gives plain columns. series lists the stacks; each point is { x: ISO time or category label, <series key>: number }, sorted by x. A missing or null value counts as 0. Set xFormat when x is an ISO time; leave it out for category labels.",
|
|
12
|
+
props: __rspack_external_zod.object({
|
|
13
|
+
title: __rspack_external_zod.string(),
|
|
14
|
+
series: __rspack_external_zod.array(__rspack_external_zod.object({
|
|
15
|
+
key: seriesKey.describe('The field in each point that holds this series’ value'),
|
|
16
|
+
label: __rspack_external_zod.string(),
|
|
17
|
+
color: __rspack_external_zod["enum"](CHART_COLORS).optional()
|
|
18
|
+
})).refine(unique('key'), 'series keys must be unique'),
|
|
19
|
+
points: __rspack_external_zod.array(__rspack_external_zod.object({
|
|
20
|
+
x: __rspack_external_zod.string()
|
|
21
|
+
}).catchall(__rspack_external_zod.number().nullable())),
|
|
22
|
+
xFormat: timeFormat,
|
|
23
|
+
yFormat: numberFormat
|
|
24
|
+
}),
|
|
25
|
+
Skeleton: ({ title })=>/*#__PURE__*/ jsx(ChartSkeleton, {
|
|
26
|
+
title: title
|
|
27
|
+
}),
|
|
28
|
+
View: ({ props })=>{
|
|
29
|
+
const { series, points } = props;
|
|
30
|
+
const formatX = (index)=>{
|
|
31
|
+
const x = points[Number(index)]?.x ?? '';
|
|
32
|
+
return props.xFormat ? formatTime(x, props.xFormat) : x;
|
|
33
|
+
};
|
|
34
|
+
const formatValue = (value)=>formatNumber(Number(value ?? 0), props.yFormat);
|
|
35
|
+
const valueAt = (point, key)=>{
|
|
36
|
+
const value = point[key];
|
|
37
|
+
return 'number' == typeof value ? value : 0;
|
|
38
|
+
};
|
|
39
|
+
const data = points.map((point, index)=>{
|
|
40
|
+
const datum = {
|
|
41
|
+
[X_KEY]: index
|
|
42
|
+
};
|
|
43
|
+
for (const s of series)datum[s.key] = valueAt(point, s.key);
|
|
44
|
+
return datum;
|
|
45
|
+
});
|
|
46
|
+
const renderTooltip = ({ rows, xValue })=>/*#__PURE__*/ jsxs(LineChartHoverPopover, {
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ jsx(LineChartHoverPopoverTimestamp, {
|
|
49
|
+
children: formatX(xValue)
|
|
50
|
+
}),
|
|
51
|
+
rows.map((row)=>/*#__PURE__*/ jsx(LineChartHoverPopoverRow, {
|
|
52
|
+
series: row.series,
|
|
53
|
+
value: formatValue(row.value)
|
|
54
|
+
}, row.series.key))
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
return /*#__PURE__*/ jsx("div", {
|
|
58
|
+
className: "h-full min-w-0 flex-1",
|
|
59
|
+
children: /*#__PURE__*/ jsxs(Chart, {
|
|
60
|
+
className: "h-full",
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ jsx(ChartHeader, {
|
|
63
|
+
children: /*#__PURE__*/ jsx(ChartTitle, {
|
|
64
|
+
children: props.title
|
|
65
|
+
})
|
|
66
|
+
}),
|
|
67
|
+
/*#__PURE__*/ jsxs(ColumnChart, {
|
|
68
|
+
data: data,
|
|
69
|
+
series: series,
|
|
70
|
+
xKey: X_KEY,
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ jsx(LineChartLegend, {
|
|
73
|
+
children: series.map((s)=>/*#__PURE__*/ jsxs(LineChartLegendItem, {
|
|
74
|
+
seriesKey: s.key,
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ jsx(LineChartHoverPopoverDot, {
|
|
77
|
+
color: s.color
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ jsx("span", {
|
|
80
|
+
className: "text-xs font-mono text-text-primary",
|
|
81
|
+
children: s.label
|
|
82
|
+
}),
|
|
83
|
+
/*#__PURE__*/ jsx("span", {
|
|
84
|
+
className: "text-xs font-mono font-medium text-text-primary",
|
|
85
|
+
children: formatValue(points.reduce((sum, p)=>sum + valueAt(p, s.key), 0))
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
}, s.key))
|
|
89
|
+
}),
|
|
90
|
+
0 === data.length ? /*#__PURE__*/ jsx(LineChartEmpty, {
|
|
91
|
+
children: "No data"
|
|
92
|
+
}) : /*#__PURE__*/ jsxs(ColumnChartBody, {
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ jsx(LineChartGrid, {}),
|
|
95
|
+
/*#__PURE__*/ jsx(ColumnChartXAxis, {
|
|
96
|
+
tickFormatter: formatX
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ jsx(LineChartYAxis, {
|
|
99
|
+
tickFormatter: formatValue
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ jsx(ColumnChartStack, {}),
|
|
102
|
+
/*#__PURE__*/ jsx(LineChartTooltip, {
|
|
103
|
+
children: renderTooltip
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
export { ColumnChartComponent };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const GridComponent: import("../index.js").GenUiComponent<z.ZodObject<{
|
|
3
|
+
columns: z.ZodOptional<z.ZodEnum<{
|
|
4
|
+
1: "1";
|
|
5
|
+
12: "12";
|
|
6
|
+
2: "2";
|
|
7
|
+
3: "3";
|
|
8
|
+
4: "4";
|
|
9
|
+
6: "6";
|
|
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>>;
|
|
19
|
+
export declare const GridItemComponent: import("../index.js").GenUiComponent<z.ZodObject<{
|
|
20
|
+
span: z.ZodEnum<{
|
|
21
|
+
1: "1";
|
|
22
|
+
12: "12";
|
|
23
|
+
2: "2";
|
|
24
|
+
3: "3";
|
|
25
|
+
4: "4";
|
|
26
|
+
6: "6";
|
|
27
|
+
full: "full";
|
|
28
|
+
}>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@wallarm-org/design-system/utils/cn";
|
|
3
|
+
import { defineComponent } from "../core/define.js";
|
|
4
|
+
import { GAPS } from "./Stack.js";
|
|
5
|
+
import * as __rspack_external_zod from "zod";
|
|
6
|
+
const COLUMNS = [
|
|
7
|
+
'1',
|
|
8
|
+
'2',
|
|
9
|
+
'3',
|
|
10
|
+
'4',
|
|
11
|
+
'6',
|
|
12
|
+
'12'
|
|
13
|
+
];
|
|
14
|
+
const SPANS = [
|
|
15
|
+
'1',
|
|
16
|
+
'2',
|
|
17
|
+
'3',
|
|
18
|
+
'4',
|
|
19
|
+
'6',
|
|
20
|
+
'12',
|
|
21
|
+
'full'
|
|
22
|
+
];
|
|
23
|
+
const COLUMN_CLASS = {
|
|
24
|
+
1: 'grid-cols-1',
|
|
25
|
+
2: 'grid-cols-2',
|
|
26
|
+
3: 'grid-cols-3',
|
|
27
|
+
4: 'grid-cols-4',
|
|
28
|
+
6: 'grid-cols-6',
|
|
29
|
+
12: 'grid-cols-12'
|
|
30
|
+
};
|
|
31
|
+
const GAP_CLASS = {
|
|
32
|
+
4: 'gap-4',
|
|
33
|
+
8: 'gap-8',
|
|
34
|
+
12: 'gap-12',
|
|
35
|
+
16: 'gap-16',
|
|
36
|
+
24: 'gap-24'
|
|
37
|
+
};
|
|
38
|
+
const SPAN_CLASS = {
|
|
39
|
+
1: 'col-span-1',
|
|
40
|
+
2: 'col-span-2',
|
|
41
|
+
3: 'col-span-3',
|
|
42
|
+
4: 'col-span-4',
|
|
43
|
+
6: 'col-span-6',
|
|
44
|
+
12: 'col-span-12',
|
|
45
|
+
full: 'col-span-full'
|
|
46
|
+
};
|
|
47
|
+
const GridComponent = defineComponent({
|
|
48
|
+
name: 'Grid',
|
|
49
|
+
description: 'A dashboard grid: equal columns, children fill them left to right. Use 4 columns for KPI tiles, 2 for charts side by side; wrap a child in GridItem to span several columns.',
|
|
50
|
+
props: __rspack_external_zod.object({
|
|
51
|
+
columns: __rspack_external_zod["enum"](COLUMNS).optional().describe('Default 2'),
|
|
52
|
+
gap: __rspack_external_zod["enum"](GAPS).optional().describe('Space between cells, px. Default 12')
|
|
53
|
+
}),
|
|
54
|
+
hasChildren: true,
|
|
55
|
+
View: ({ props, children })=>/*#__PURE__*/ jsx("div", {
|
|
56
|
+
className: cn('grid w-full', COLUMN_CLASS[props.columns ?? '2'], GAP_CLASS[props.gap ?? '12']),
|
|
57
|
+
children: children
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
const GridItemComponent = defineComponent({
|
|
61
|
+
name: 'GridItem',
|
|
62
|
+
description: 'One Grid cell that spans several columns, e.g. a wide chart or table.',
|
|
63
|
+
props: __rspack_external_zod.object({
|
|
64
|
+
span: __rspack_external_zod["enum"](SPANS).describe('Columns to span; full spans the row')
|
|
65
|
+
}),
|
|
66
|
+
hasChildren: true,
|
|
67
|
+
View: ({ props, children })=>/*#__PURE__*/ jsx("div", {
|
|
68
|
+
className: cn('min-w-0', SPAN_CLASS[props.span]),
|
|
69
|
+
children: children
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
export { GridComponent, GridItemComponent };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Heading } from "@wallarm-org/design-system/Heading";
|
|
3
|
+
import { Skeleton } from "@wallarm-org/design-system/Skeleton";
|
|
4
|
+
import { defineComponent, subsetOf } from "../core/define.js";
|
|
5
|
+
import * as __rspack_external_zod from "zod";
|
|
6
|
+
const HeadingComponent = defineComponent({
|
|
7
|
+
name: 'Heading',
|
|
8
|
+
description: 'A page or block title. For a titled group of content, prefer Section.',
|
|
9
|
+
props: __rspack_external_zod.object({
|
|
10
|
+
text: __rspack_external_zod.string(),
|
|
11
|
+
size: __rspack_external_zod["enum"](subsetOf()([
|
|
12
|
+
'md',
|
|
13
|
+
'lg',
|
|
14
|
+
'xl',
|
|
15
|
+
'2xl'
|
|
16
|
+
])).optional()
|
|
17
|
+
}),
|
|
18
|
+
Skeleton: ()=>/*#__PURE__*/ jsx(Skeleton, {
|
|
19
|
+
width: "40%",
|
|
20
|
+
height: "24px",
|
|
21
|
+
transparent: false
|
|
22
|
+
}),
|
|
23
|
+
View: ({ props })=>/*#__PURE__*/ jsx(Heading, {
|
|
24
|
+
size: props.size ?? 'lg',
|
|
25
|
+
weight: "medium",
|
|
26
|
+
children: props.text
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
export { HeadingComponent };
|