@assistant-ui/react-generative-ui 0.0.16 → 0.0.18
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/dist/a2ui/convert.d.ts.map +1 -1
- package/dist/a2ui/convert.js +11 -2
- package/dist/a2ui/convert.js.map +1 -1
- package/dist/a2ui/reducer.d.ts.map +1 -1
- package/dist/a2ui/reducer.js +63 -10
- package/dist/a2ui/reducer.js.map +1 -1
- package/dist/buildPresentParameters.js +4 -3
- package/dist/buildPresentParameters.js.map +1 -1
- package/dist/convert/boundSpec.d.ts +5 -1
- package/dist/convert/boundSpec.d.ts.map +1 -1
- package/dist/convert/boundSpec.js +13 -4
- package/dist/convert/boundSpec.js.map +1 -1
- package/dist/renderGenerativeUI.js +1 -1
- package/dist/renderGenerativeUI.js.map +1 -1
- package/dist/teams/toTeamsAttachments.d.ts.map +1 -1
- package/dist/teams/toTeamsAttachments.js +2 -5
- package/dist/teams/toTeamsAttachments.js.map +1 -1
- package/dist/vocabulary/alert.d.ts +1 -1
- package/dist/vocabulary/alert.d.ts.map +1 -1
- package/dist/vocabulary/alert.js +21 -16
- package/dist/vocabulary/alert.js.map +1 -1
- package/dist/vocabulary/data.d.ts.map +1 -1
- package/dist/vocabulary/data.js +20 -12
- package/dist/vocabulary/data.js.map +1 -1
- package/dist/vocabulary/fact.d.ts.map +1 -1
- package/dist/vocabulary/fact.js +3 -2
- package/dist/vocabulary/fact.js.map +1 -1
- package/dist/vocabulary/interactive.d.ts +6 -5
- package/dist/vocabulary/interactive.d.ts.map +1 -1
- package/dist/vocabulary/interactive.js +28 -23
- package/dist/vocabulary/interactive.js.map +1 -1
- package/dist/vocabulary/layout.d.ts.map +1 -1
- package/dist/vocabulary/layout.js +7 -5
- package/dist/vocabulary/layout.js.map +1 -1
- package/dist/vocabulary/text.d.ts.map +1 -1
- package/dist/vocabulary/text.js +4 -3
- package/dist/vocabulary/text.js.map +1 -1
- package/dist/vocabulary/toTextContent.d.ts +5 -0
- package/dist/vocabulary/toTextContent.d.ts.map +1 -0
- package/dist/vocabulary/toTextContent.js +6 -0
- package/dist/vocabulary/toTextContent.js.map +1 -0
- package/package.json +5 -5
- package/src/a2ui/convert.test.ts +36 -0
- package/src/a2ui/convert.ts +21 -2
- package/src/a2ui/reducer.test.ts +223 -0
- package/src/a2ui/reducer.ts +76 -12
- package/src/buildPresentParameters.ts +7 -4
- package/src/convert/boundSpec.test.ts +47 -2
- package/src/convert/boundSpec.ts +12 -14
- package/src/renderGenerativeUI.test.tsx +57 -0
- package/src/renderGenerativeUI.tsx +3 -1
- package/src/teams/toTeamsAttachments.ts +2 -9
- package/src/vocabulary/alert.test.tsx +10 -0
- package/src/vocabulary/alert.tsx +16 -7
- package/src/vocabulary/data.test.tsx +40 -0
- package/src/vocabulary/data.tsx +47 -26
- package/src/vocabulary/fact.test.tsx +12 -0
- package/src/vocabulary/fact.tsx +3 -2
- package/src/vocabulary/interactive.test.tsx +41 -0
- package/src/vocabulary/interactive.tsx +42 -28
- package/src/vocabulary/layout.test.tsx +16 -0
- package/src/vocabulary/layout.tsx +8 -4
- package/src/vocabulary/text.test.tsx +29 -0
- package/src/vocabulary/text.tsx +4 -3
- package/src/vocabulary/toTextContent.ts +2 -0
|
@@ -70,4 +70,33 @@ describe("textVocabulary", () => {
|
|
|
70
70
|
'<p data-aui="caption">muted note</p>',
|
|
71
71
|
);
|
|
72
72
|
});
|
|
73
|
+
|
|
74
|
+
it.each([
|
|
75
|
+
[
|
|
76
|
+
{ $type: "Header", text: { unexpected: true } },
|
|
77
|
+
undefined,
|
|
78
|
+
'<h2 data-aui="header" data-aui-size="lg"></h2>',
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
{ $type: "Text", value: { unexpected: true } },
|
|
82
|
+
{ status: "streaming" as const },
|
|
83
|
+
'<span data-aui="text" data-aui-size="md"></span>',
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
{ $type: "Caption", value: { unexpected: true } },
|
|
87
|
+
{ status: "streaming" as const },
|
|
88
|
+
'<p data-aui="caption"></p>',
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
{ $type: "Text", value: 42 },
|
|
92
|
+
{ status: "streaming" as const },
|
|
93
|
+
'<span data-aui="text" data-aui-size="md">42</span>',
|
|
94
|
+
],
|
|
95
|
+
])("renders only supported text properties", (node, options, expected) => {
|
|
96
|
+
expect(
|
|
97
|
+
renderToStaticMarkup(
|
|
98
|
+
<>{renderGenerativeUI(node, textVocabulary, options)}</>,
|
|
99
|
+
),
|
|
100
|
+
).toBe(expected);
|
|
101
|
+
});
|
|
73
102
|
});
|
package/src/vocabulary/text.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { GenerativeUILibrary } from "../types";
|
|
3
3
|
import { COLORS, TEXT_SIZES, WEIGHTS } from "../ir";
|
|
4
|
+
import { toTextContent } from "./toTextContent";
|
|
4
5
|
|
|
5
6
|
export const textVocabulary = {
|
|
6
7
|
Header: {
|
|
@@ -14,7 +15,7 @@ export const textVocabulary = {
|
|
|
14
15
|
}),
|
|
15
16
|
render: ({ text, size, children }) => (
|
|
16
17
|
<h2 data-aui="header" data-aui-size={size ?? "lg"}>
|
|
17
|
-
{text}
|
|
18
|
+
{toTextContent(text)}
|
|
18
19
|
{children}
|
|
19
20
|
</h2>
|
|
20
21
|
),
|
|
@@ -38,7 +39,7 @@ export const textVocabulary = {
|
|
|
38
39
|
data-aui-weight={weight}
|
|
39
40
|
data-aui-color={color}
|
|
40
41
|
>
|
|
41
|
-
{value}
|
|
42
|
+
{toTextContent(value)}
|
|
42
43
|
{children}
|
|
43
44
|
</span>
|
|
44
45
|
),
|
|
@@ -51,7 +52,7 @@ export const textVocabulary = {
|
|
|
51
52
|
streamProperties: true,
|
|
52
53
|
render: ({ value, children }) => (
|
|
53
54
|
<p data-aui="caption">
|
|
54
|
-
{value}
|
|
55
|
+
{toTextContent(value)}
|
|
55
56
|
{children}
|
|
56
57
|
</p>
|
|
57
58
|
),
|