@assistant-ui/react-generative-ui 0.0.18 → 0.0.19
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/JSONGenerativeUI.client.d.ts +1 -2
- package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
- package/dist/JSONGenerativeUI.server.d.ts +1 -2
- package/dist/JSONGenerativeUI.server.d.ts.map +1 -1
- package/dist/JSONGenerativeUI.shared.d.ts +8 -9
- package/dist/JSONGenerativeUI.shared.d.ts.map +1 -1
- package/dist/a2ui/convert.d.ts +1 -2
- package/dist/a2ui/convert.d.ts.map +1 -1
- package/dist/a2ui/reducer.d.ts +1 -2
- package/dist/a2ui/reducer.d.ts.map +1 -1
- package/dist/a2ui/types.d.ts +17 -18
- package/dist/a2ui/types.d.ts.map +1 -1
- package/dist/actionRegistry.d.ts +5 -6
- package/dist/actionRegistry.d.ts.map +1 -1
- package/dist/buildPresentParameters.d.ts +2 -3
- package/dist/buildPresentParameters.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -1
- package/dist/constants.js.map +1 -1
- package/dist/convert/boundSpec.d.ts +7 -8
- package/dist/convert/boundSpec.d.ts.map +1 -1
- package/dist/convert/copyBounded.d.ts +1 -2
- package/dist/convert/copyBounded.d.ts.map +1 -1
- package/dist/convert/isElement.d.ts +1 -2
- package/dist/convert/isElement.d.ts.map +1 -1
- package/dist/convert/takeRun.d.ts +1 -2
- package/dist/convert/takeRun.d.ts.map +1 -1
- package/dist/defineGenerativeComponents.d.ts +1 -2
- package/dist/defineGenerativeComponents.d.ts.map +1 -1
- package/dist/generativeUIToJSX.d.ts +2 -3
- package/dist/generativeUIToJSX.d.ts.map +1 -1
- package/dist/ir.d.ts +28 -29
- package/dist/ir.d.ts.map +1 -1
- package/dist/renderGenerativeUI.d.ts +1 -2
- package/dist/renderGenerativeUI.d.ts.map +1 -1
- package/dist/slack/constants.d.ts +35 -36
- package/dist/slack/constants.d.ts.map +1 -1
- package/dist/slack/decodeBlockAction.d.ts +1 -2
- package/dist/slack/decodeBlockAction.d.ts.map +1 -1
- package/dist/slack/fromSlackBlocks.d.ts +1 -2
- package/dist/slack/fromSlackBlocks.d.ts.map +1 -1
- package/dist/slack/toSlackBlocks.d.ts +1 -2
- package/dist/slack/toSlackBlocks.d.ts.map +1 -1
- package/dist/slack/types.d.ts +32 -33
- package/dist/slack/types.d.ts.map +1 -1
- package/dist/teams/constants.d.ts +14 -15
- package/dist/teams/constants.d.ts.map +1 -1
- package/dist/teams/decodeSubmitData.d.ts +1 -2
- package/dist/teams/decodeSubmitData.d.ts.map +1 -1
- package/dist/teams/toAdaptiveCard.d.ts +6 -7
- package/dist/teams/toAdaptiveCard.d.ts.map +1 -1
- package/dist/teams/toTeamsAttachments.d.ts +1 -2
- package/dist/teams/toTeamsAttachments.d.ts.map +1 -1
- package/dist/teams/types.d.ts +29 -30
- package/dist/teams/types.d.ts.map +1 -1
- package/dist/types.d.ts +9 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/vocabulary/alert.d.ts +1 -2
- package/dist/vocabulary/alert.d.ts.map +1 -1
- package/dist/vocabulary/collectFormValues.d.ts +6 -5
- package/dist/vocabulary/collectFormValues.d.ts.map +1 -1
- package/dist/vocabulary/collectFormValues.js +3 -2
- package/dist/vocabulary/collectFormValues.js.map +1 -1
- package/dist/vocabulary/data.d.ts +1 -2
- package/dist/vocabulary/data.d.ts.map +1 -1
- package/dist/vocabulary/dispatch.d.ts +2 -3
- package/dist/vocabulary/dispatch.d.ts.map +1 -1
- package/dist/vocabulary/fact.d.ts +1 -2
- package/dist/vocabulary/fact.d.ts.map +1 -1
- package/dist/vocabulary/form.d.ts +1 -2
- package/dist/vocabulary/form.d.ts.map +1 -1
- package/dist/vocabulary/icon.d.ts +1 -2
- package/dist/vocabulary/icon.d.ts.map +1 -1
- package/dist/vocabulary/index.d.ts +1 -2
- package/dist/vocabulary/index.d.ts.map +1 -1
- package/dist/vocabulary/interactive.d.ts +4 -4
- package/dist/vocabulary/interactive.d.ts.map +1 -1
- package/dist/vocabulary/interactive.js +2 -0
- package/dist/vocabulary/interactive.js.map +1 -1
- package/dist/vocabulary/layout.d.ts +1 -2
- package/dist/vocabulary/layout.d.ts.map +1 -1
- package/dist/vocabulary/list.d.ts +1 -2
- package/dist/vocabulary/list.d.ts.map +1 -1
- package/dist/vocabulary/media.d.ts +1 -2
- package/dist/vocabulary/media.d.ts.map +1 -1
- package/dist/vocabulary/text.d.ts +2 -3
- package/dist/vocabulary/text.d.ts.map +1 -1
- package/dist/vocabulary/toTextContent.d.ts +1 -2
- package/dist/vocabulary/toTextContent.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/constants.ts +2 -0
- package/src/slack/fromSlackBlocks.test.ts +4 -1
- package/src/slack/toSlackBlocks.test.ts +8 -4
- package/src/teams/toAdaptiveCard.test.ts +5 -3
- package/src/vocabulary/collectFormValues.test.ts +38 -0
- package/src/vocabulary/collectFormValues.ts +11 -2
- package/src/vocabulary/form.test.tsx +1 -0
- package/src/vocabulary/interactive.test.tsx +14 -1
- package/src/vocabulary/interactive.tsx +8 -1
- package/src/vocabulary/layout.test.tsx +1 -0
- package/src/vocabulary/list.test.tsx +5 -4
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts +0 -141
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","names":[],"sources":["../../src/vocabulary/list.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"list.d.ts","names":[],"sources":["../../src/vocabulary/list.tsx"],"mappings":";;qBAOa"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/vocabulary/media.d.ts
|
|
3
|
-
declare const mediaVocabulary: {
|
|
3
|
+
export declare const mediaVocabulary: {
|
|
4
4
|
Image: {
|
|
5
5
|
description: string;
|
|
6
6
|
properties: z.ZodObject<{
|
|
@@ -24,5 +24,4 @@ declare const mediaVocabulary: {
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
//#endregion
|
|
27
|
-
export { mediaVocabulary };
|
|
28
27
|
//# sourceMappingURL=media.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","names":[],"sources":["../../src/vocabulary/media.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"media.d.ts","names":[],"sources":["../../src/vocabulary/media.tsx"],"mappings":";;qBAKa"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/vocabulary/text.d.ts
|
|
3
|
-
declare const textVocabulary: {
|
|
3
|
+
export declare const textVocabulary: {
|
|
4
4
|
Header: {
|
|
5
5
|
description: string;
|
|
6
6
|
properties: z.ZodObject<{
|
|
@@ -35,8 +35,8 @@ declare const textVocabulary: {
|
|
|
35
35
|
semibold: "semibold";
|
|
36
36
|
}>>;
|
|
37
37
|
color: z.ZodOptional<z.ZodEnum<{
|
|
38
|
-
emphasis: "emphasis";
|
|
39
38
|
secondary: "secondary";
|
|
39
|
+
emphasis: "emphasis";
|
|
40
40
|
"alpha-70": "alpha-70";
|
|
41
41
|
white: "white";
|
|
42
42
|
"white-70": "white-70";
|
|
@@ -56,5 +56,4 @@ declare const textVocabulary: {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
//#endregion
|
|
59
|
-
export { textVocabulary };
|
|
60
59
|
//# sourceMappingURL=text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","names":[],"sources":["../../src/vocabulary/text.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"text.d.ts","names":[],"sources":["../../src/vocabulary/text.tsx"],"mappings":";;qBAKa"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/vocabulary/toTextContent.d.ts
|
|
2
|
-
declare const toTextContent: (value: unknown) => string | number | null;
|
|
2
|
+
export declare const toTextContent: (value: unknown) => string | number | null;
|
|
3
3
|
//#endregion
|
|
4
|
-
export { toTextContent };
|
|
5
4
|
//# sourceMappingURL=toTextContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toTextContent.d.ts","names":[],"sources":["../../src/vocabulary/toTextContent.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"toTextContent.d.ts","names":[],"sources":["../../src/vocabulary/toTextContent.ts"],"mappings":";qBAAa,gBAAiB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react-generative-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Generative UI components for assistant-ui",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"generative-ui",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
],
|
|
51
51
|
"sideEffects": false,
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"
|
|
53
|
+
"@types/json-schema": "^7.0.15",
|
|
54
|
+
"assistant-stream": "^0.3.44"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"@assistant-ui/react": "^0.15.0",
|
|
@@ -64,14 +65,14 @@
|
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
|
-
"@assistant-ui/react": "0.15.
|
|
68
|
-
"@assistant-ui/x-buildutils": "0.0.
|
|
69
|
-
"@types/
|
|
70
|
-
"
|
|
71
|
-
"react": "^19.
|
|
72
|
-
"react-dom": "^19.
|
|
73
|
-
"vitest": "^
|
|
74
|
-
"zod": "^4.5
|
|
68
|
+
"@assistant-ui/react": "0.15.21",
|
|
69
|
+
"@assistant-ui/x-buildutils": "0.0.28",
|
|
70
|
+
"@types/react": "^19.3.0",
|
|
71
|
+
"jsdom": "^30.0.1",
|
|
72
|
+
"react": "^19.3.0",
|
|
73
|
+
"react-dom": "^19.3.0",
|
|
74
|
+
"vitest": "^5.0.1",
|
|
75
|
+
"zod": "^4.6.5"
|
|
75
76
|
},
|
|
76
77
|
"publishConfig": {
|
|
77
78
|
"access": "public",
|
|
@@ -89,6 +90,7 @@
|
|
|
89
90
|
"scripts": {
|
|
90
91
|
"build": "aui-build",
|
|
91
92
|
"test": "vitest run",
|
|
93
|
+
"typecheck": "tsc --noEmit",
|
|
92
94
|
"test:watch": "vitest"
|
|
93
95
|
}
|
|
94
96
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1107,7 +1107,10 @@ describe("fromSlackBlocks checkbox and radio caps", () => {
|
|
|
1107
1107
|
],
|
|
1108
1108
|
},
|
|
1109
1109
|
]);
|
|
1110
|
-
const radio = nodes[0]
|
|
1110
|
+
const radio = nodes[0];
|
|
1111
|
+
if (radio?.$type !== "RadioGroup" || !Array.isArray(radio.options)) {
|
|
1112
|
+
throw new Error("Expected a RadioGroup with options.");
|
|
1113
|
+
}
|
|
1111
1114
|
expect(radio.options).toHaveLength(10);
|
|
1112
1115
|
expect(
|
|
1113
1116
|
warnings.some(
|
|
@@ -2346,9 +2346,10 @@ describe("toSlackBlocks data_table integrity", () => {
|
|
|
2346
2346
|
columns: [{ label: "A" }, { label: "B" }],
|
|
2347
2347
|
rows: [[{ nested: true }, "kept"]],
|
|
2348
2348
|
});
|
|
2349
|
-
const table = blocks[0]
|
|
2350
|
-
|
|
2351
|
-
|
|
2349
|
+
const table = blocks[0];
|
|
2350
|
+
if (table?.type !== "data_table") {
|
|
2351
|
+
throw new Error("Expected a data table block.");
|
|
2352
|
+
}
|
|
2352
2353
|
expect(table.rows[1]).toEqual([
|
|
2353
2354
|
{ type: "raw_text", text: "" },
|
|
2354
2355
|
{ type: "raw_text", text: "kept" },
|
|
@@ -2361,7 +2362,10 @@ describe("toSlackBlocks data_table integrity", () => {
|
|
|
2361
2362
|
columns: [{ label: "A" }, { label: "B" }, { label: "C" }],
|
|
2362
2363
|
rows: [["x"], ["x", "y", "z"]],
|
|
2363
2364
|
});
|
|
2364
|
-
const table = blocks[0]
|
|
2365
|
+
const table = blocks[0];
|
|
2366
|
+
if (table?.type !== "data_table") {
|
|
2367
|
+
throw new Error("Expected a data table block.");
|
|
2368
|
+
}
|
|
2365
2369
|
expect(new Set(table.rows.map((row) => row.length))).toEqual(new Set([3]));
|
|
2366
2370
|
});
|
|
2367
2371
|
|
|
@@ -1038,9 +1038,11 @@ describe("toAdaptiveCard", () => {
|
|
|
1038
1038
|
name: "s",
|
|
1039
1039
|
options: [{ label: "ok", value: "a" }, { label: "bad" }, "nope"],
|
|
1040
1040
|
});
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1041
|
+
const select = card.body[0];
|
|
1042
|
+
if (select?.type !== "Input.ChoiceSet") {
|
|
1043
|
+
throw new Error("Expected an input choice set.");
|
|
1044
|
+
}
|
|
1045
|
+
expect(select.choices).toEqual([{ title: "ok", value: "a" }]);
|
|
1044
1046
|
expect(warnings).toContainEqual({
|
|
1045
1047
|
code: "dropped",
|
|
1046
1048
|
component: "Select",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
1
3
|
import { describe, it, expect } from "vitest";
|
|
2
4
|
import {
|
|
3
5
|
collectFormValues,
|
|
4
6
|
type FormControlElementLike,
|
|
5
7
|
} from "./collectFormValues";
|
|
8
|
+
import { GENERATED_NAME_ATTR } from "../constants";
|
|
6
9
|
|
|
7
10
|
const el = (
|
|
8
11
|
partial: Partial<FormControlElementLike>,
|
|
@@ -11,6 +14,7 @@ const el = (
|
|
|
11
14
|
type: "text",
|
|
12
15
|
value: "",
|
|
13
16
|
disabled: false,
|
|
17
|
+
hasAttribute: () => false,
|
|
14
18
|
...partial,
|
|
15
19
|
});
|
|
16
20
|
|
|
@@ -82,6 +86,20 @@ describe("collectFormValues", () => {
|
|
|
82
86
|
).toEqual({ kept: "yes" });
|
|
83
87
|
});
|
|
84
88
|
|
|
89
|
+
it("skips radio groups whose name is generated only for native grouping", () => {
|
|
90
|
+
expect(
|
|
91
|
+
collectFormValues([
|
|
92
|
+
el({
|
|
93
|
+
name: "_R_1_",
|
|
94
|
+
type: "radio",
|
|
95
|
+
value: "sm",
|
|
96
|
+
checked: true,
|
|
97
|
+
hasAttribute: (name) => name === GENERATED_NAME_ATTR,
|
|
98
|
+
}),
|
|
99
|
+
]),
|
|
100
|
+
).toEqual({});
|
|
101
|
+
});
|
|
102
|
+
|
|
85
103
|
it("skips disabled controls", () => {
|
|
86
104
|
expect(
|
|
87
105
|
collectFormValues([
|
|
@@ -106,6 +124,26 @@ describe("collectFormValues", () => {
|
|
|
106
124
|
).toEqual({ size: undefined });
|
|
107
125
|
});
|
|
108
126
|
|
|
127
|
+
it("skips controls disabled by a fieldset while preserving its first legend", () => {
|
|
128
|
+
const form = document.createElement("form");
|
|
129
|
+
form.innerHTML = `
|
|
130
|
+
<fieldset disabled>
|
|
131
|
+
<legend><input name="legend" value="kept" /></legend>
|
|
132
|
+
<input name="blocked" value="old" />
|
|
133
|
+
</fieldset>
|
|
134
|
+
<input name="enabled" value="yes" />
|
|
135
|
+
`;
|
|
136
|
+
const blocked = form.elements.namedItem("blocked") as HTMLInputElement;
|
|
137
|
+
|
|
138
|
+
expect(blocked.disabled).toBe(false);
|
|
139
|
+
|
|
140
|
+
expect(
|
|
141
|
+
collectFormValues(
|
|
142
|
+
form.elements as unknown as ArrayLike<FormControlElementLike>,
|
|
143
|
+
),
|
|
144
|
+
).toEqual({ legend: "kept", enabled: "yes" });
|
|
145
|
+
});
|
|
146
|
+
|
|
109
147
|
it("returns an empty object for no elements", () => {
|
|
110
148
|
expect(collectFormValues([])).toEqual({});
|
|
111
149
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FormEvent } from "react";
|
|
2
|
+
import { GENERATED_NAME_ATTR } from "../constants";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The subset of `HTMLInputElement`/`HTMLSelectElement`/`HTMLTextAreaElement` that {@link collectFormValues} reads. A structural type rather than the DOM interfaces themselves, so a plain object can stand in for a form control in tests.
|
|
@@ -9,10 +10,12 @@ export type FormControlElementLike = {
|
|
|
9
10
|
readonly value: string;
|
|
10
11
|
readonly checked?: boolean;
|
|
11
12
|
readonly disabled: boolean;
|
|
13
|
+
readonly hasAttribute: (name: string) => boolean;
|
|
14
|
+
readonly matches?: ((selector: string) => boolean) | undefined;
|
|
12
15
|
};
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
|
-
* Collects a submitted form's named control values into a plain object, keyed by `name`, in document order. Reads each control's live DOM state rather than `FormData`, so a checkbox resolves to its `checked` boolean instead of an on/off string. A radio group resolves to its checked option's `value`, or `undefined` if none is checked. Any other repeated `name` resolves to an array of its controls' values, in document order. Controls without a `name`, or that are
|
|
18
|
+
* Collects a submitted form's named control values into a plain object, keyed by `name`, in document order. Reads each control's live DOM state rather than `FormData`, so a checkbox resolves to its `checked` boolean instead of an on/off string. A radio group resolves to its checked option's `value`, or `undefined` if none is checked. Any other repeated `name` resolves to an array of its controls' values, in document order. Controls without a `name`, that carry `data-aui-generated-name`, or that are effectively disabled, including through an ancestor disabled fieldset outside its first legend, are skipped entirely.
|
|
16
19
|
*/
|
|
17
20
|
export function collectFormValues(
|
|
18
21
|
elements: ArrayLike<FormControlElementLike>,
|
|
@@ -21,7 +24,13 @@ export function collectFormValues(
|
|
|
21
24
|
|
|
22
25
|
for (const element of Array.from(elements)) {
|
|
23
26
|
const { name, disabled } = element;
|
|
24
|
-
if (
|
|
27
|
+
if (
|
|
28
|
+
!name ||
|
|
29
|
+
disabled ||
|
|
30
|
+
element.hasAttribute(GENERATED_NAME_ATTR) ||
|
|
31
|
+
element.matches?.(":disabled")
|
|
32
|
+
)
|
|
33
|
+
continue;
|
|
25
34
|
|
|
26
35
|
if (element.type === "radio") {
|
|
27
36
|
if (element.checked) values[name] = element.value;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
2
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
|
+
import { GENERATED_NAME_ATTR } from "../constants";
|
|
3
4
|
import { renderGenerativeUI } from "../renderGenerativeUI";
|
|
4
5
|
import { interactiveVocabulary } from "./interactive";
|
|
5
6
|
|
|
@@ -232,6 +233,7 @@ describe("interactiveVocabulary", () => {
|
|
|
232
233
|
],
|
|
233
234
|
});
|
|
234
235
|
expect((html.match(/name="size"/g) ?? []).length).toBe(2);
|
|
236
|
+
expect(html).not.toContain(GENERATED_NAME_ATTR);
|
|
235
237
|
});
|
|
236
238
|
|
|
237
239
|
it("RadioGroup falls back to a generated shared name when name is omitted", () => {
|
|
@@ -242,10 +244,21 @@ describe("interactiveVocabulary", () => {
|
|
|
242
244
|
{ label: "Large", value: "lg" },
|
|
243
245
|
],
|
|
244
246
|
});
|
|
245
|
-
const names = [...html.matchAll(/name="([^"]*)"/g)].map((m) => m[1]);
|
|
247
|
+
const names = [...html.matchAll(/ name="([^"]*)"/g)].map((m) => m[1]);
|
|
246
248
|
expect(names.length).toBe(2);
|
|
247
249
|
expect(names[0]).toBe(names[1]);
|
|
248
250
|
expect(names[0]).toBeTruthy();
|
|
251
|
+
expect(html.split(`${GENERATED_NAME_ATTR}=""`).length - 1).toBe(2);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("RadioGroup marks a generated shared name when name is null", () => {
|
|
255
|
+
const html = render({
|
|
256
|
+
$type: "RadioGroup",
|
|
257
|
+
name: null,
|
|
258
|
+
options: [{ label: "Small", value: "sm" }],
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
expect(html).toContain(`${GENERATED_NAME_ATTR}=""`);
|
|
249
262
|
});
|
|
250
263
|
|
|
251
264
|
it("RadioGroup marks the option matching defaultValue as checked", () => {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { useId } from "react";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { GENERATED_NAME_ATTR } from "../constants";
|
|
3
4
|
import type { Action } from "../ir";
|
|
4
5
|
import { BUTTON_STYLES } from "../ir";
|
|
5
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
GenerativeUIDispatch,
|
|
8
|
+
GenerativeUILibrary,
|
|
9
|
+
GenerativeUIStatus,
|
|
10
|
+
} from "../types";
|
|
6
11
|
import { actionAttr, fire } from "./dispatch";
|
|
7
12
|
import { toTextContent } from "./toTextContent";
|
|
8
13
|
|
|
@@ -26,6 +31,7 @@ type RadioGroupRenderProps = {
|
|
|
26
31
|
name?: string;
|
|
27
32
|
label?: string;
|
|
28
33
|
defaultValue?: string;
|
|
34
|
+
$status: GenerativeUIStatus;
|
|
29
35
|
$action?: Action;
|
|
30
36
|
$dispatch?: GenerativeUIDispatch;
|
|
31
37
|
};
|
|
@@ -53,6 +59,7 @@ function RadioGroupRender({
|
|
|
53
59
|
<input
|
|
54
60
|
type="radio"
|
|
55
61
|
name={fieldName}
|
|
62
|
+
{...(name == null ? { [GENERATED_NAME_ATTR]: "" } : {})}
|
|
56
63
|
value={option.value}
|
|
57
64
|
defaultChecked={defaultValue === option.value}
|
|
58
65
|
onChange={() => fire($action, $dispatch, option.value)}
|
|
@@ -3,6 +3,7 @@ import type { ReactElement } from "react";
|
|
|
3
3
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
4
|
import { renderGenerativeUI } from "../renderGenerativeUI";
|
|
5
5
|
import { createActionRegistry } from "../actionRegistry";
|
|
6
|
+
import type { GenerativeUIDispatch } from "../types";
|
|
6
7
|
import { listVocabulary } from "./list";
|
|
7
8
|
|
|
8
9
|
const render = (node: unknown) =>
|
|
@@ -55,13 +56,13 @@ describe("listVocabulary", () => {
|
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
describe("listVocabulary $action dispatch", () => {
|
|
58
|
-
const rowOut = (dispatch:
|
|
59
|
+
const rowOut = (dispatch: GenerativeUIDispatch) =>
|
|
59
60
|
listVocabulary.ListViewItem.render({
|
|
60
61
|
$status: "done",
|
|
61
62
|
$action: { type: "open" },
|
|
62
63
|
$dispatch: dispatch,
|
|
63
64
|
children: "row",
|
|
64
|
-
}) as ReactElement
|
|
65
|
+
}) as ReactElement<{ children: ReactElement }>;
|
|
65
66
|
|
|
66
67
|
it("clicking the trigger fires $action with no $input", () => {
|
|
67
68
|
const handler = vi.fn();
|
|
@@ -83,8 +84,8 @@ describe("listVocabulary $action dispatch", () => {
|
|
|
83
84
|
preventDefault: () => void;
|
|
84
85
|
};
|
|
85
86
|
|
|
86
|
-
const getOnKeyDown = (dispatch:
|
|
87
|
-
const trigger = rowOut(dispatch).props.children
|
|
87
|
+
const getOnKeyDown = (dispatch: GenerativeUIDispatch) => {
|
|
88
|
+
const trigger = rowOut(dispatch).props.children;
|
|
88
89
|
return (trigger.props as { onKeyDown: (e: KeyDownEvent) => void })
|
|
89
90
|
.onKeyDown;
|
|
90
91
|
};
|
package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
|
|
2
|
-
// ==================================================================================================
|
|
3
|
-
// JSON Schema Draft 07
|
|
4
|
-
// ==================================================================================================
|
|
5
|
-
// https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
6
|
-
// --------------------------------------------------------------------------------------------------
|
|
7
|
-
/**
|
|
8
|
-
* Primitive type
|
|
9
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
|
|
10
|
-
*/
|
|
11
|
-
type JSONSchema7TypeName = "string" //
|
|
12
|
-
| "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
13
|
-
/**
|
|
14
|
-
* Primitive type
|
|
15
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
|
|
16
|
-
*/
|
|
17
|
-
type JSONSchema7Type = string //
|
|
18
|
-
| number | boolean | JSONSchema7Object | JSONSchema7Array | null;
|
|
19
|
-
// Workaround for infinite type recursion
|
|
20
|
-
interface JSONSchema7Object {
|
|
21
|
-
[key: string]: JSONSchema7Type;
|
|
22
|
-
}
|
|
23
|
-
// Workaround for infinite type recursion
|
|
24
|
-
// https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
|
|
25
|
-
interface JSONSchema7Array extends Array<JSONSchema7Type> {}
|
|
26
|
-
/**
|
|
27
|
-
* Meta schema
|
|
28
|
-
*
|
|
29
|
-
* Recommended values:
|
|
30
|
-
* - 'http://json-schema.org/schema#'
|
|
31
|
-
* - 'http://json-schema.org/hyper-schema#'
|
|
32
|
-
* - 'http://json-schema.org/draft-07/schema#'
|
|
33
|
-
* - 'http://json-schema.org/draft-07/hyper-schema#'
|
|
34
|
-
*
|
|
35
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
|
|
36
|
-
*/
|
|
37
|
-
type JSONSchema7Version = string;
|
|
38
|
-
/**
|
|
39
|
-
* JSON Schema v7
|
|
40
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
41
|
-
*/
|
|
42
|
-
type JSONSchema7Definition = JSONSchema7 | boolean;
|
|
43
|
-
interface JSONSchema7 {
|
|
44
|
-
$id?: string | undefined;
|
|
45
|
-
$ref?: string | undefined;
|
|
46
|
-
$schema?: JSONSchema7Version | undefined;
|
|
47
|
-
$comment?: string | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
50
|
-
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
51
|
-
*/
|
|
52
|
-
$defs?: {
|
|
53
|
-
[key: string]: JSONSchema7Definition;
|
|
54
|
-
} | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
|
|
57
|
-
*/
|
|
58
|
-
type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
|
|
59
|
-
enum?: JSONSchema7Type[] | undefined;
|
|
60
|
-
const?: JSONSchema7Type | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
|
|
63
|
-
*/
|
|
64
|
-
multipleOf?: number | undefined;
|
|
65
|
-
maximum?: number | undefined;
|
|
66
|
-
exclusiveMaximum?: number | undefined;
|
|
67
|
-
minimum?: number | undefined;
|
|
68
|
-
exclusiveMinimum?: number | undefined;
|
|
69
|
-
/**
|
|
70
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
|
|
71
|
-
*/
|
|
72
|
-
maxLength?: number | undefined;
|
|
73
|
-
minLength?: number | undefined;
|
|
74
|
-
pattern?: string | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
|
|
77
|
-
*/
|
|
78
|
-
items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
|
|
79
|
-
additionalItems?: JSONSchema7Definition | undefined;
|
|
80
|
-
maxItems?: number | undefined;
|
|
81
|
-
minItems?: number | undefined;
|
|
82
|
-
uniqueItems?: boolean | undefined;
|
|
83
|
-
contains?: JSONSchema7Definition | undefined;
|
|
84
|
-
/**
|
|
85
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
|
|
86
|
-
*/
|
|
87
|
-
maxProperties?: number | undefined;
|
|
88
|
-
minProperties?: number | undefined;
|
|
89
|
-
required?: string[] | undefined;
|
|
90
|
-
properties?: {
|
|
91
|
-
[key: string]: JSONSchema7Definition;
|
|
92
|
-
} | undefined;
|
|
93
|
-
patternProperties?: {
|
|
94
|
-
[key: string]: JSONSchema7Definition;
|
|
95
|
-
} | undefined;
|
|
96
|
-
additionalProperties?: JSONSchema7Definition | undefined;
|
|
97
|
-
dependencies?: {
|
|
98
|
-
[key: string]: JSONSchema7Definition | string[];
|
|
99
|
-
} | undefined;
|
|
100
|
-
propertyNames?: JSONSchema7Definition | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
|
|
103
|
-
*/
|
|
104
|
-
if?: JSONSchema7Definition | undefined;
|
|
105
|
-
then?: JSONSchema7Definition | undefined;
|
|
106
|
-
else?: JSONSchema7Definition | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
|
|
109
|
-
*/
|
|
110
|
-
allOf?: JSONSchema7Definition[] | undefined;
|
|
111
|
-
anyOf?: JSONSchema7Definition[] | undefined;
|
|
112
|
-
oneOf?: JSONSchema7Definition[] | undefined;
|
|
113
|
-
not?: JSONSchema7Definition | undefined;
|
|
114
|
-
/**
|
|
115
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
|
|
116
|
-
*/
|
|
117
|
-
format?: string | undefined;
|
|
118
|
-
/**
|
|
119
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
|
|
120
|
-
*/
|
|
121
|
-
contentMediaType?: string | undefined;
|
|
122
|
-
contentEncoding?: string | undefined;
|
|
123
|
-
/**
|
|
124
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
|
|
125
|
-
*/
|
|
126
|
-
definitions?: {
|
|
127
|
-
[key: string]: JSONSchema7Definition;
|
|
128
|
-
} | undefined;
|
|
129
|
-
/**
|
|
130
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
|
|
131
|
-
*/
|
|
132
|
-
title?: string | undefined;
|
|
133
|
-
description?: string | undefined;
|
|
134
|
-
default?: JSONSchema7Type | undefined;
|
|
135
|
-
readOnly?: boolean | undefined;
|
|
136
|
-
writeOnly?: boolean | undefined;
|
|
137
|
-
examples?: JSONSchema7Type | undefined;
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
export { JSONSchema7, JSONSchema7Array, JSONSchema7Definition, JSONSchema7Object, JSONSchema7Type, JSONSchema7TypeName, JSONSchema7Version };
|
|
141
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;KA+iBY;;;;;;KAaA;sBAIN,oBACA;;UAIW;GACZ,cAAc;;;;UAKF,yBAAyB,MAAM;;;;;;;;;;;;KAapC;;;;;KAMA,wBAAwB;UACnB;EACb;EACA;EACA,UAAU;EACV;;;;;EAMA;KACK,cAAc;;;;;EAMnB,OAAO,sBAAsB;EAC7B,OAAO;EACP,QAAQ;;;;EAKR;EACA;EACA;EACA;EACA;;;;EAKA;EACA;EACA;;;;EAKA,QAAQ,wBAAwB;EAChC,kBAAkB;EAClB;EACA;EACA;EACA,WAAW;;;;EAKX;EACA;EACA;EACA;KACK,cAAc;;EAEnB;KACK,cAAc;;EAEnB,uBAAuB;EACvB;KACK,cAAc;;EAEnB,gBAAgB;;;;EAKhB,KAAK;EACL,OAAO;EACP,OAAO;;;;EAKP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,MAAM;;;;EAKN;;;;EAKA;EACA;;;;EAKA;KACK,cAAc;;;;;EAMnB;EACA;EACA,UAAU;EACV;EACA;EACA,WAAW"}
|