@wallarm-org/gen-ui 0.0.0-stage → 0.1.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,26 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Chart, ChartHeader, ChartTitle } from "@wallarm-org/design-system/SimpleCharts";
|
|
3
|
+
import { Skeleton } from "@wallarm-org/design-system/Skeleton";
|
|
4
|
+
const ChartSkeleton = ({ title, children })=>/*#__PURE__*/ jsxs(Chart, {
|
|
5
|
+
className: "h-full",
|
|
6
|
+
children: [
|
|
7
|
+
/*#__PURE__*/ jsx(ChartHeader, {
|
|
8
|
+
children: title ? /*#__PURE__*/ jsx(ChartTitle, {
|
|
9
|
+
children: title
|
|
10
|
+
}) : /*#__PURE__*/ jsx(Skeleton, {
|
|
11
|
+
width: "96px",
|
|
12
|
+
height: "12px",
|
|
13
|
+
transparent: false
|
|
14
|
+
})
|
|
15
|
+
}),
|
|
16
|
+
children ?? /*#__PURE__*/ jsx("div", {
|
|
17
|
+
className: "p-12",
|
|
18
|
+
children: /*#__PURE__*/ jsx(Skeleton, {
|
|
19
|
+
width: "100%",
|
|
20
|
+
height: "180px",
|
|
21
|
+
transparent: false
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
export { ChartSkeleton };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import type { GenUiComponent } from '../core/define.js';
|
|
3
|
+
interface GuardedViewProps {
|
|
4
|
+
component: GenUiComponent;
|
|
5
|
+
/** The props as the format resolved them: untrusted, and possibly incomplete mid-stream. */
|
|
6
|
+
props: unknown;
|
|
7
|
+
emit: (event: string) => void;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Renders a component only with props that match its schema. Neither format validates props
|
|
12
|
+
* before rendering, and a View can't defend against every value a model may send (an enum value
|
|
13
|
+
* the DS lacks, a missing required field). A props object that fails holds the component's
|
|
14
|
+
* skeleton instead: mid-stream that is a binding whose data hasn't arrived yet, at the end a
|
|
15
|
+
* mistake in the answer (the reasons are in the skeleton's tooltip).
|
|
16
|
+
*/
|
|
17
|
+
export declare const GuardedView: FC<GuardedViewProps>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { isRecord } from "../core/guards.js";
|
|
3
|
+
import { Placeholder } from "./Placeholder.js";
|
|
4
|
+
const GuardedView = ({ component, props, emit, children })=>{
|
|
5
|
+
const parsed = component.props.safeParse(props);
|
|
6
|
+
if (!parsed.success) {
|
|
7
|
+
const { Skeleton } = component;
|
|
8
|
+
const title = isRecord(props) && 'string' == typeof props.title ? props.title : void 0;
|
|
9
|
+
return /*#__PURE__*/ jsx(Placeholder, {
|
|
10
|
+
id: component.name,
|
|
11
|
+
detail: parsed.error.issues.map((i)=>`${i.path.join('.') || '(props)'}: ${i.message}`),
|
|
12
|
+
children: Skeleton && /*#__PURE__*/ jsx(Skeleton, {
|
|
13
|
+
title: title
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const { View } = component;
|
|
18
|
+
return /*#__PURE__*/ jsx(View, {
|
|
19
|
+
props: parsed.data,
|
|
20
|
+
emit: emit,
|
|
21
|
+
children: children
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export { GuardedView };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
|
+
interface PlaceholderProps {
|
|
3
|
+
/** The agent's id, or the component type: for tests and debugging, never shown. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Why it isn't renderable yet (schema issues), in the tooltip. */
|
|
6
|
+
detail?: readonly string[];
|
|
7
|
+
/** A skeleton shaped like the component; default a plain block. */
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Stands in for a part that isn't renderable yet, so a streaming layout keeps its shape: a child
|
|
12
|
+
* the agent named but hasn't sent, or a component whose props don't match its schema yet (data
|
|
13
|
+
* still on its way, or a mistake).
|
|
14
|
+
*/
|
|
15
|
+
export declare const Placeholder: FC<PlaceholderProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Skeleton } from "@wallarm-org/design-system/Skeleton";
|
|
3
|
+
const Placeholder = ({ id, detail, children })=>/*#__PURE__*/ jsx("div", {
|
|
4
|
+
"data-gen-ui-placeholder": id,
|
|
5
|
+
"aria-busy": "true",
|
|
6
|
+
title: detail?.join('\n'),
|
|
7
|
+
className: "h-full w-full min-w-0",
|
|
8
|
+
children: children ?? /*#__PURE__*/ jsx(Skeleton, {
|
|
9
|
+
width: "100%",
|
|
10
|
+
height: "96px",
|
|
11
|
+
rounded: 12,
|
|
12
|
+
transparent: false
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
export { Placeholder };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component, type ReactNode } from 'react';
|
|
2
|
+
/** Agent output is untrusted: a View that throws on it blanks its own surface, not the chat. */
|
|
3
|
+
export declare class SurfaceBoundary extends Component<{
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}, {
|
|
6
|
+
failed: boolean;
|
|
7
|
+
}> {
|
|
8
|
+
state: {
|
|
9
|
+
failed: boolean;
|
|
10
|
+
};
|
|
11
|
+
static getDerivedStateFromError(): {
|
|
12
|
+
failed: boolean;
|
|
13
|
+
};
|
|
14
|
+
render(): ReactNode;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component } from "react";
|
|
2
|
+
class SurfaceBoundary extends Component {
|
|
3
|
+
state = {
|
|
4
|
+
failed: false
|
|
5
|
+
};
|
|
6
|
+
static getDerivedStateFromError() {
|
|
7
|
+
return {
|
|
8
|
+
failed: true
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
render() {
|
|
12
|
+
return this.state.failed ? null : this.props.children;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export { SurfaceBoundary };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const warn: (...args: any[]) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wallarm-org/gen-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Generative UI catalog for the Wallarm Design System: one component definition, rendered from A2UI, json-render and OpenUI",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/wallarm/design-system.git",
|
|
9
|
+
"directory": "packages/gen-ui"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
|
+
},
|
|
15
|
+
"author": "Wallarm",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./a2ui": {
|
|
23
|
+
"types": "./dist/a2ui/index.d.ts",
|
|
24
|
+
"default": "./dist/a2ui/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./a2ui/express": {
|
|
27
|
+
"types": "./dist/a2ui/express.d.ts",
|
|
28
|
+
"default": "./dist/a2ui/express.js"
|
|
29
|
+
},
|
|
30
|
+
"./a2ui/prompt": {
|
|
31
|
+
"types": "./dist/a2ui/prompt.d.ts",
|
|
32
|
+
"default": "./dist/a2ui/prompt.js"
|
|
33
|
+
},
|
|
34
|
+
"./json-render": {
|
|
35
|
+
"types": "./dist/json-render/index.d.ts",
|
|
36
|
+
"default": "./dist/json-render/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./openui": {
|
|
39
|
+
"types": "./dist/openui/index.d.ts",
|
|
40
|
+
"default": "./dist/openui/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./fixtures": {
|
|
43
|
+
"types": "./dist/fixtures/index.d.ts",
|
|
44
|
+
"default": "./dist/fixtures/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./playground": {
|
|
47
|
+
"types": "./dist/playground/index.d.ts",
|
|
48
|
+
"default": "./dist/playground/index.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist"
|
|
53
|
+
],
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "rslib build",
|
|
56
|
+
"dev": "rslib build --watch",
|
|
57
|
+
"test": "rstest watch",
|
|
58
|
+
"test:run": "rstest run",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"prepublishOnly": "prepare-publish",
|
|
61
|
+
"postpublish": "restore-package"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@a2ui/agent": "0.1.0",
|
|
65
|
+
"@a2ui/react": "0.15.0",
|
|
66
|
+
"@a2ui/web_core": "0.15.0",
|
|
67
|
+
"@json-render/core": "0.22.0",
|
|
68
|
+
"@json-render/react": "0.22.0",
|
|
69
|
+
"@openuidev/react-lang": "1.1.0"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@rsbuild/plugin-react": "catalog:",
|
|
73
|
+
"@rslib/core": "catalog:",
|
|
74
|
+
"@rstest/core": "catalog:",
|
|
75
|
+
"@testing-library/react": "catalog:",
|
|
76
|
+
"@testing-library/user-event": "catalog:",
|
|
77
|
+
"@types/node": "catalog:",
|
|
78
|
+
"@types/prismjs": "1.26.6",
|
|
79
|
+
"@types/react": "catalog:",
|
|
80
|
+
"@wallarm-org/design-system": "workspace:*",
|
|
81
|
+
"@wallarm-org/publish-scripts": "workspace:*",
|
|
82
|
+
"@wallarm-org/rstest-config": "workspace:*",
|
|
83
|
+
"@wallarm-org/typescript-config": "workspace:*",
|
|
84
|
+
"jsdom": "catalog:",
|
|
85
|
+
"react": "catalog:",
|
|
86
|
+
"react-dom": "catalog:",
|
|
87
|
+
"typescript": "catalog:",
|
|
88
|
+
"zod": "catalog:"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"@wallarm-org/design-system": ">=4.14.0",
|
|
92
|
+
"react": "^19.2.3",
|
|
93
|
+
"react-dom": "^19.2.3",
|
|
94
|
+
"zod": "^4.0.0"
|
|
95
|
+
}
|
|
96
|
+
}
|