@assistant-ui/react-generative-ui 0.0.6 → 0.0.7
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 +4 -1
- package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
- package/dist/JSONGenerativeUI.client.js +9 -2
- package/dist/JSONGenerativeUI.client.js.map +1 -1
- package/dist/JSONGenerativeUI.shared.d.ts +8 -0
- package/dist/JSONGenerativeUI.shared.d.ts.map +1 -1
- package/dist/JSONGenerativeUI.shared.js.map +1 -1
- package/dist/actionRegistry.d.ts +41 -0
- package/dist/actionRegistry.d.ts.map +1 -0
- package/dist/actionRegistry.js +41 -0
- package/dist/actionRegistry.js.map +1 -0
- package/dist/buildPresentParameters.js +10 -1
- package/dist/buildPresentParameters.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +5 -2
- package/dist/index.server.d.ts +12 -0
- package/dist/index.server.js +10 -0
- package/dist/index.shared.d.ts +11 -0
- package/dist/index.shared.js +9 -0
- package/dist/ir.d.ts +115 -0
- package/dist/ir.d.ts.map +1 -0
- package/dist/ir.js +149 -0
- package/dist/ir.js.map +1 -0
- package/dist/renderGenerativeUI.d.ts +5 -4
- package/dist/renderGenerativeUI.d.ts.map +1 -1
- package/dist/renderGenerativeUI.js +18 -45
- package/dist/renderGenerativeUI.js.map +1 -1
- package/dist/types.d.ts +34 -30
- package/dist/types.d.ts.map +1 -1
- package/dist/vocabulary/alert.d.ts +34 -0
- package/dist/vocabulary/alert.d.ts.map +1 -0
- package/dist/vocabulary/alert.js +49 -0
- package/dist/vocabulary/alert.js.map +1 -0
- package/dist/vocabulary/data.d.ts +53 -0
- package/dist/vocabulary/data.d.ts.map +1 -0
- package/dist/vocabulary/data.js +63 -0
- package/dist/vocabulary/data.js.map +1 -0
- package/dist/vocabulary/fact.d.ts +20 -0
- package/dist/vocabulary/fact.d.ts.map +1 -0
- package/dist/vocabulary/fact.js +24 -0
- package/dist/vocabulary/fact.js.map +1 -0
- package/dist/vocabulary/index.d.ts +16 -0
- package/dist/vocabulary/index.d.ts.map +1 -0
- package/dist/vocabulary/index.js +30 -0
- package/dist/vocabulary/index.js.map +1 -0
- package/dist/vocabulary/interactive.d.ts +81 -0
- package/dist/vocabulary/interactive.d.ts.map +1 -0
- package/dist/vocabulary/interactive.js +123 -0
- package/dist/vocabulary/interactive.js.map +1 -0
- package/dist/vocabulary/layout.d.ts +78 -0
- package/dist/vocabulary/layout.d.ts.map +1 -0
- package/dist/vocabulary/layout.js +72 -0
- package/dist/vocabulary/layout.js.map +1 -0
- package/dist/vocabulary/media.d.ts +34 -0
- package/dist/vocabulary/media.d.ts.map +1 -0
- package/dist/vocabulary/media.js +32 -0
- package/dist/vocabulary/media.js.map +1 -0
- package/dist/vocabulary/text.d.ts +74 -0
- package/dist/vocabulary/text.d.ts.map +1 -0
- package/dist/vocabulary/text.js +48 -0
- package/dist/vocabulary/text.js.map +1 -0
- package/package.json +12 -12
- package/src/JSONGenerativeUI.client.tsx +10 -2
- package/src/JSONGenerativeUI.shared.ts +8 -0
- package/src/actionRegistry.test.ts +90 -0
- package/src/actionRegistry.ts +96 -0
- package/src/buildPresentParameters.ts +23 -7
- package/src/index.server.ts +2 -0
- package/src/index.shared.ts +58 -0
- package/src/index.ts +2 -26
- package/src/ir.test.ts +203 -0
- package/src/ir.ts +253 -0
- package/src/renderGenerativeUI.test.tsx +53 -0
- package/src/renderGenerativeUI.tsx +49 -82
- package/src/types.ts +57 -42
- package/src/vocabulary/alert.test.tsx +66 -0
- package/src/vocabulary/alert.tsx +47 -0
- package/src/vocabulary/data.test.tsx +67 -0
- package/src/vocabulary/data.tsx +86 -0
- package/src/vocabulary/fact.test.tsx +15 -0
- package/src/vocabulary/fact.tsx +22 -0
- package/src/vocabulary/index.test.ts +56 -0
- package/src/vocabulary/index.ts +27 -0
- package/src/vocabulary/interactive.dispatch.test.tsx +110 -0
- package/src/vocabulary/interactive.test.tsx +108 -0
- package/src/vocabulary/interactive.tsx +165 -0
- package/src/vocabulary/layout.test.tsx +61 -0
- package/src/vocabulary/layout.tsx +76 -0
- package/src/vocabulary/media.test.tsx +53 -0
- package/src/vocabulary/media.tsx +37 -0
- package/src/vocabulary/text.test.tsx +73 -0
- package/src/vocabulary/text.tsx +59 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/vocabulary/data.tsx
|
|
4
|
+
const columnSchema = z.object({ label: z.string().describe("Column header label.") });
|
|
5
|
+
const cellSchema = z.union([
|
|
6
|
+
z.string(),
|
|
7
|
+
z.number(),
|
|
8
|
+
z.boolean()
|
|
9
|
+
]).describe("A cell value.");
|
|
10
|
+
const dataVocabulary = {
|
|
11
|
+
Table: {
|
|
12
|
+
description: "Tabular data. Provide `columns` and `rows`; each row is an array of cells matching the columns.",
|
|
13
|
+
properties: z.object({
|
|
14
|
+
columns: z.array(columnSchema).optional().describe("Column definitions."),
|
|
15
|
+
rows: z.array(z.array(cellSchema)).optional().describe("Rows of cells.")
|
|
16
|
+
}),
|
|
17
|
+
render: ({ columns, rows, children }) => /* @__PURE__ */ jsxs("table", {
|
|
18
|
+
"data-aui": "table",
|
|
19
|
+
children: [
|
|
20
|
+
columns?.length ? /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((c, i) => /* @__PURE__ */ jsx("th", {
|
|
21
|
+
"data-aui": "table-col",
|
|
22
|
+
children: c.label
|
|
23
|
+
}, i)) }) }) : null,
|
|
24
|
+
rows?.length ? /* @__PURE__ */ jsx("tbody", { children: rows.map((row, r) => /* @__PURE__ */ jsx("tr", { children: row.map((cell, c) => /* @__PURE__ */ jsx("td", { children: String(cell) }, c)) }, r)) }) : null,
|
|
25
|
+
children
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
},
|
|
29
|
+
Markdown: {
|
|
30
|
+
description: "A markdown string. Rendered as-is by default; override this component for a full markdown renderer.",
|
|
31
|
+
properties: z.object({ value: z.string().describe("Markdown source.") }),
|
|
32
|
+
streamProperties: true,
|
|
33
|
+
render: ({ value, children }) => /* @__PURE__ */ jsxs("div", {
|
|
34
|
+
"data-aui": "markdown",
|
|
35
|
+
children: [value, children]
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
Chart: {
|
|
39
|
+
description: "A chart placeholder. Carries variant and data for a client renderer to draw.",
|
|
40
|
+
properties: z.object({
|
|
41
|
+
variant: z.enum([
|
|
42
|
+
"bar",
|
|
43
|
+
"line",
|
|
44
|
+
"sparkline"
|
|
45
|
+
]).describe("Chart variant."),
|
|
46
|
+
data: z.array(z.object({
|
|
47
|
+
label: z.string().optional(),
|
|
48
|
+
value: z.number()
|
|
49
|
+
})).describe("Data points."),
|
|
50
|
+
color: z.string().optional().describe("Series color.")
|
|
51
|
+
}),
|
|
52
|
+
render: ({ variant, data, color }) => /* @__PURE__ */ jsx("div", {
|
|
53
|
+
"data-aui": "chart",
|
|
54
|
+
"data-aui-variant": variant,
|
|
55
|
+
"data-aui-color": color,
|
|
56
|
+
"data-aui-data": JSON.stringify(data)
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { dataVocabulary };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","names":[],"sources":["../../src/vocabulary/data.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\n\nconst columnSchema = z.object({\n label: z.string().describe(\"Column header label.\"),\n});\n\nconst cellSchema = z\n .union([z.string(), z.number(), z.boolean()])\n .describe(\"A cell value.\");\n\nexport const dataVocabulary = {\n Table: {\n description:\n \"Tabular data. Provide `columns` and `rows`; each row is an array of cells matching the columns.\",\n properties: z.object({\n columns: z.array(columnSchema).optional().describe(\"Column definitions.\"),\n rows: z.array(z.array(cellSchema)).optional().describe(\"Rows of cells.\"),\n }),\n render: ({ columns, rows, children }) => (\n <table data-aui=\"table\">\n {columns?.length ? (\n <thead>\n <tr>\n {columns.map((c: { label: string }, i: number) => (\n <th key={i} data-aui=\"table-col\">\n {c.label}\n </th>\n ))}\n </tr>\n </thead>\n ) : null}\n {rows?.length ? (\n <tbody>\n {rows.map((row: (string | number | boolean)[], r: number) => (\n <tr key={r}>\n {row.map((cell: string | number | boolean, c: number) => (\n <td key={c}>{String(cell)}</td>\n ))}\n </tr>\n ))}\n </tbody>\n ) : null}\n {children}\n </table>\n ),\n },\n Markdown: {\n description:\n \"A markdown string. Rendered as-is by default; override this component for a full markdown renderer.\",\n properties: z.object({\n value: z.string().describe(\"Markdown source.\"),\n }),\n streamProperties: true,\n render: ({ value, children }) => (\n <div data-aui=\"markdown\">\n {value}\n {children}\n </div>\n ),\n },\n Chart: {\n description:\n \"A chart placeholder. Carries variant and data for a client renderer to draw.\",\n properties: z.object({\n variant: z.enum([\"bar\", \"line\", \"sparkline\"]).describe(\"Chart variant.\"),\n data: z\n .array(\n z.object({\n label: z.string().optional(),\n value: z.number(),\n }),\n )\n .describe(\"Data points.\"),\n color: z.string().optional().describe(\"Series color.\"),\n }),\n render: ({ variant, data, color }) => (\n <div\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n data-aui-data={JSON.stringify(data)}\n />\n ),\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;AAGA,MAAM,eAAe,EAAE,OAAO,EAC5B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,sBAAsB,EACnD,CAAC;AAED,MAAM,aAAa,EAChB,MAAM;CAAC,EAAE,OAAO;CAAG,EAAE,OAAO;CAAG,EAAE,QAAQ;AAAC,CAAC,CAAC,CAC5C,SAAS,eAAe;AAE3B,MAAa,iBAAiB;CAC5B,OAAO;EACL,aACE;EACF,YAAY,EAAE,OAAO;GACnB,SAAS,EAAE,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,qBAAqB;GACxE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,gBAAgB;EACzE,CAAC;EACD,SAAS,EAAE,SAAS,MAAM,eACxB,qBAAC,SAAD;GAAO,YAAS;aAAhB;IACG,SAAS,SACR,oBAAC,SAAD,EAAA,UACE,oBAAC,MAAD,EAAA,UACG,QAAQ,KAAK,GAAsB,MAClC,oBAAC,MAAD;KAAY,YAAS;eAClB,EAAE;IACD,GAFK,CAEL,CACL,EACC,CAAA,EACC,CAAA,IACL;IACH,MAAM,SACL,oBAAC,SAAD,EAAA,UACG,KAAK,KAAK,KAAoC,MAC7C,oBAAC,MAAD,EAAA,UACG,IAAI,KAAK,MAAiC,MACzC,oBAAC,MAAD,EAAA,UAAa,OAAO,IAAI,EAAM,GAArB,CAAqB,CAC/B,EACC,GAJK,CAIL,CACL,EACI,CAAA,IACL;IACH;GACI;;CAEX;CACA,UAAU;EACR,aACE;EACF,YAAY,EAAE,OAAO,EACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,kBAAkB,EAC/C,CAAC;EACD,kBAAkB;EAClB,SAAS,EAAE,OAAO,eAChB,qBAAC,OAAD;GAAK,YAAS;aAAd,CACG,OACA,QACE;;CAET;CACA,OAAO;EACL,aACE;EACF,YAAY,EAAE,OAAO;GACnB,SAAS,EAAE,KAAK;IAAC;IAAO;IAAQ;GAAW,CAAC,CAAC,CAAC,SAAS,gBAAgB;GACvE,MAAM,EACH,MACC,EAAE,OAAO;IACP,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;IAC3B,OAAO,EAAE,OAAO;GAClB,CAAC,CACH,CAAC,CACA,SAAS,cAAc;GAC1B,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,eAAe;EACvD,CAAC;EACD,SAAS,EAAE,SAAS,MAAM,YACxB,oBAAC,OAAD;GACE,YAAS;GACT,oBAAkB;GAClB,kBAAgB;GAChB,iBAAe,KAAK,UAAU,IAAI;EACnC,CAAA;CAEL;AACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/vocabulary/fact.d.ts
|
|
4
|
+
declare const factVocabulary: {
|
|
5
|
+
Fact: {
|
|
6
|
+
description: string;
|
|
7
|
+
properties: z.ZodObject<{
|
|
8
|
+
label: z.ZodString;
|
|
9
|
+
value: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
render: ({
|
|
12
|
+
label,
|
|
13
|
+
value,
|
|
14
|
+
children
|
|
15
|
+
}: any) => import("react").JSX.Element;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { factVocabulary };
|
|
20
|
+
//# sourceMappingURL=fact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fact.d.ts","names":[],"sources":["../../src/vocabulary/fact.tsx"],"mappings":";;;cAGa,cAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/vocabulary/fact.tsx
|
|
4
|
+
const factVocabulary = { Fact: {
|
|
5
|
+
description: "A label/value pair, rendered as a key followed by its value. Use for compact metadata.",
|
|
6
|
+
properties: z.object({
|
|
7
|
+
label: z.string().describe("The fact label (key)."),
|
|
8
|
+
value: z.string().describe("The fact value.")
|
|
9
|
+
}),
|
|
10
|
+
render: ({ label, value, children }) => /* @__PURE__ */ jsxs("dl", {
|
|
11
|
+
"data-aui": "fact",
|
|
12
|
+
children: [/* @__PURE__ */ jsx("dt", {
|
|
13
|
+
"data-aui": "fact-label",
|
|
14
|
+
children: label
|
|
15
|
+
}), /* @__PURE__ */ jsxs("dd", {
|
|
16
|
+
"data-aui": "fact-value",
|
|
17
|
+
children: [value, children]
|
|
18
|
+
})]
|
|
19
|
+
})
|
|
20
|
+
} };
|
|
21
|
+
//#endregion
|
|
22
|
+
export { factVocabulary };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=fact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fact.js","names":[],"sources":["../../src/vocabulary/fact.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\n\nexport const factVocabulary = {\n Fact: {\n description:\n \"A label/value pair, rendered as a key followed by its value. Use for compact metadata.\",\n properties: z.object({\n label: z.string().describe(\"The fact label (key).\"),\n value: z.string().describe(\"The fact value.\"),\n }),\n render: ({ label, value, children }) => (\n <dl data-aui=\"fact\">\n <dt data-aui=\"fact-label\">{label}</dt>\n <dd data-aui=\"fact-value\">\n {value}\n {children}\n </dd>\n </dl>\n ),\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;AAGA,MAAa,iBAAiB,EAC5B,MAAM;CACJ,aACE;CACF,YAAY,EAAE,OAAO;EACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,uBAAuB;EAClD,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,iBAAiB;CAC9C,CAAC;CACD,SAAS,EAAE,OAAO,OAAO,eACvB,qBAAC,MAAD;EAAI,YAAS;YAAb,CACE,oBAAC,MAAD;GAAI,YAAS;aAAc;EAAU,CAAA,GACrC,qBAAC,MAAD;GAAI,YAAS;aAAb,CACG,OACA,QACC;IACF;;AAER,EACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GenerativeUILibrary } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/vocabulary/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The closed generative-ui vocabulary the factory ships: a fixed set of
|
|
6
|
+
* intrinsic components the model may render, each a zod `properties` schema
|
|
7
|
+
* plus an unstyled structural `render` (semantic HTML with a `data-aui`
|
|
8
|
+
* attribute naming the component, plus `data-aui-<prop>` hooks, for the host
|
|
9
|
+
* to style). Users opt in by passing it to
|
|
10
|
+
* `new JSONGenerativeUI({ library: defaultGenerativeUILibrary })`, and override
|
|
11
|
+
* or extend entries with their own `defineGenerativeComponents`.
|
|
12
|
+
*/
|
|
13
|
+
declare const defaultGenerativeUILibrary: GenerativeUILibrary;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { defaultGenerativeUILibrary };
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vocabulary/index.ts"],"mappings":";;;;;AAkBA;;;;AAQC;;;cARY,0BAAA,EAA4B,mBAQxC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { alertVocabulary } from "./alert.js";
|
|
2
|
+
import { dataVocabulary } from "./data.js";
|
|
3
|
+
import { factVocabulary } from "./fact.js";
|
|
4
|
+
import { interactiveVocabulary } from "./interactive.js";
|
|
5
|
+
import { layoutVocabulary } from "./layout.js";
|
|
6
|
+
import { mediaVocabulary } from "./media.js";
|
|
7
|
+
import { textVocabulary } from "./text.js";
|
|
8
|
+
//#region src/vocabulary/index.ts
|
|
9
|
+
/**
|
|
10
|
+
* The closed generative-ui vocabulary the factory ships: a fixed set of
|
|
11
|
+
* intrinsic components the model may render, each a zod `properties` schema
|
|
12
|
+
* plus an unstyled structural `render` (semantic HTML with a `data-aui`
|
|
13
|
+
* attribute naming the component, plus `data-aui-<prop>` hooks, for the host
|
|
14
|
+
* to style). Users opt in by passing it to
|
|
15
|
+
* `new JSONGenerativeUI({ library: defaultGenerativeUILibrary })`, and override
|
|
16
|
+
* or extend entries with their own `defineGenerativeComponents`.
|
|
17
|
+
*/
|
|
18
|
+
const defaultGenerativeUILibrary = {
|
|
19
|
+
...textVocabulary,
|
|
20
|
+
...mediaVocabulary,
|
|
21
|
+
...factVocabulary,
|
|
22
|
+
...interactiveVocabulary,
|
|
23
|
+
...layoutVocabulary,
|
|
24
|
+
...dataVocabulary,
|
|
25
|
+
...alertVocabulary
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { defaultGenerativeUILibrary };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/vocabulary/index.ts"],"sourcesContent":["import type { GenerativeUILibrary } from \"../types\";\nimport { alertVocabulary } from \"./alert\";\nimport { dataVocabulary } from \"./data\";\nimport { factVocabulary } from \"./fact\";\nimport { interactiveVocabulary } from \"./interactive\";\nimport { layoutVocabulary } from \"./layout\";\nimport { mediaVocabulary } from \"./media\";\nimport { textVocabulary } from \"./text\";\n\n/**\n * The closed generative-ui vocabulary the factory ships: a fixed set of\n * intrinsic components the model may render, each a zod `properties` schema\n * plus an unstyled structural `render` (semantic HTML with a `data-aui`\n * attribute naming the component, plus `data-aui-<prop>` hooks, for the host\n * to style). Users opt in by passing it to\n * `new JSONGenerativeUI({ library: defaultGenerativeUILibrary })`, and override\n * or extend entries with their own `defineGenerativeComponents`.\n */\nexport const defaultGenerativeUILibrary: GenerativeUILibrary = {\n ...textVocabulary,\n ...mediaVocabulary,\n ...factVocabulary,\n ...interactiveVocabulary,\n ...layoutVocabulary,\n ...dataVocabulary,\n ...alertVocabulary,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAa,6BAAkD;CAC7D,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/vocabulary/interactive.d.ts
|
|
4
|
+
declare const interactiveVocabulary: {
|
|
5
|
+
Button: {
|
|
6
|
+
description: string;
|
|
7
|
+
properties: z.ZodObject<{
|
|
8
|
+
label: z.ZodString;
|
|
9
|
+
buttonStyle: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
secondary: "secondary";
|
|
11
|
+
danger: "danger";
|
|
12
|
+
primary: "primary";
|
|
13
|
+
outline: "outline";
|
|
14
|
+
ghost: "ghost";
|
|
15
|
+
}>>;
|
|
16
|
+
block: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
render: ({
|
|
19
|
+
label,
|
|
20
|
+
buttonStyle,
|
|
21
|
+
block,
|
|
22
|
+
$action,
|
|
23
|
+
$dispatch,
|
|
24
|
+
children
|
|
25
|
+
}: any) => import("react").JSX.Element;
|
|
26
|
+
};
|
|
27
|
+
Select: {
|
|
28
|
+
description: string;
|
|
29
|
+
properties: z.ZodObject<{
|
|
30
|
+
options: z.ZodArray<z.ZodObject<{
|
|
31
|
+
label: z.ZodString;
|
|
32
|
+
value: z.ZodString;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
35
|
+
label: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
render: ({
|
|
38
|
+
options,
|
|
39
|
+
placeholder,
|
|
40
|
+
label,
|
|
41
|
+
$action,
|
|
42
|
+
$dispatch,
|
|
43
|
+
children
|
|
44
|
+
}: any) => import("react").JSX.Element;
|
|
45
|
+
};
|
|
46
|
+
Input: {
|
|
47
|
+
description: string;
|
|
48
|
+
properties: z.ZodObject<{
|
|
49
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
50
|
+
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
label: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
render: ({
|
|
54
|
+
placeholder,
|
|
55
|
+
multiline,
|
|
56
|
+
label,
|
|
57
|
+
$action,
|
|
58
|
+
$dispatch
|
|
59
|
+
}: any) => import("react").JSX.Element;
|
|
60
|
+
};
|
|
61
|
+
DatePicker: {
|
|
62
|
+
description: string;
|
|
63
|
+
properties: z.ZodObject<{
|
|
64
|
+
value: z.ZodOptional<z.ZodString>;
|
|
65
|
+
min: z.ZodOptional<z.ZodString>;
|
|
66
|
+
max: z.ZodOptional<z.ZodString>;
|
|
67
|
+
label: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
render: ({
|
|
70
|
+
value,
|
|
71
|
+
min,
|
|
72
|
+
max,
|
|
73
|
+
label,
|
|
74
|
+
$action,
|
|
75
|
+
$dispatch
|
|
76
|
+
}: any) => import("react").JSX.Element;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
export { interactiveVocabulary };
|
|
81
|
+
//# sourceMappingURL=interactive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","names":[],"sources":["../../src/vocabulary/interactive.tsx"],"mappings":";;;cAgCa,qBAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { BUTTON_STYLES } from "../ir.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/vocabulary/interactive.tsx
|
|
5
|
+
const optionSchema = z.object({
|
|
6
|
+
label: z.string(),
|
|
7
|
+
value: z.string()
|
|
8
|
+
});
|
|
9
|
+
const actionAttr = (a) => a ? JSON.stringify(a) : void 0;
|
|
10
|
+
/** Fires `$action` through `$dispatch` when both are present, merging a runtime
|
|
11
|
+
* value into the payload under the reserved `$input` key (not `value`) so the
|
|
12
|
+
* user's input never clobbers a model-supplied `value` field. No-op when no
|
|
13
|
+
* registry is wired. The returned promise from an async handler is caught and
|
|
14
|
+
* re-thrown on a microtask so rejections surface rather than going unhandled. */
|
|
15
|
+
const fire = ($action, $dispatch, input) => {
|
|
16
|
+
if (!$action || !$dispatch) return;
|
|
17
|
+
const payload = input === void 0 ? $action : {
|
|
18
|
+
...$action,
|
|
19
|
+
$input: input
|
|
20
|
+
};
|
|
21
|
+
Promise.resolve($dispatch(payload)).catch((error) => {
|
|
22
|
+
queueMicrotask(() => {
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const interactiveVocabulary = {
|
|
28
|
+
Button: {
|
|
29
|
+
description: "A clickable button. Carries `$action` describing the side effect or resume value.",
|
|
30
|
+
properties: z.object({
|
|
31
|
+
label: z.string().describe("Button label."),
|
|
32
|
+
buttonStyle: z.enum(BUTTON_STYLES).optional().describe("Visual style."),
|
|
33
|
+
block: z.boolean().optional().describe("Whether the button spans the full width.")
|
|
34
|
+
}),
|
|
35
|
+
render: ({ label, buttonStyle, block, $action, $dispatch, children }) => /* @__PURE__ */ jsxs("button", {
|
|
36
|
+
"data-aui": "button",
|
|
37
|
+
"data-aui-style": buttonStyle,
|
|
38
|
+
"data-aui-block": block || void 0,
|
|
39
|
+
"data-aui-action": actionAttr($action),
|
|
40
|
+
onClick: () => fire($action, $dispatch),
|
|
41
|
+
children: [label, children]
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
Select: {
|
|
45
|
+
description: "A dropdown selector. Carries `$action` describing the on-select behavior.",
|
|
46
|
+
properties: z.object({
|
|
47
|
+
options: z.array(optionSchema).describe("Selectable options."),
|
|
48
|
+
placeholder: z.string().optional().describe("Placeholder shown when nothing is selected."),
|
|
49
|
+
label: z.string().optional().describe("Accessible label for the control.")
|
|
50
|
+
}),
|
|
51
|
+
render: ({ options, placeholder, label, $action, $dispatch, children }) => /* @__PURE__ */ jsxs("select", {
|
|
52
|
+
"data-aui": "select",
|
|
53
|
+
"data-aui-action": actionAttr($action),
|
|
54
|
+
"aria-label": label,
|
|
55
|
+
defaultValue: "",
|
|
56
|
+
onChange: (e) => fire($action, $dispatch, e.currentTarget.value),
|
|
57
|
+
children: [
|
|
58
|
+
placeholder ? /* @__PURE__ */ jsx("option", {
|
|
59
|
+
value: "",
|
|
60
|
+
disabled: true,
|
|
61
|
+
children: placeholder
|
|
62
|
+
}) : null,
|
|
63
|
+
options.map((o, i) => /* @__PURE__ */ jsx("option", {
|
|
64
|
+
value: o.value,
|
|
65
|
+
children: o.label
|
|
66
|
+
}, i)),
|
|
67
|
+
children
|
|
68
|
+
]
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
Input: {
|
|
72
|
+
description: "A text input. Carries `$action` describing the on-submit behavior.",
|
|
73
|
+
properties: z.object({
|
|
74
|
+
placeholder: z.string().optional().describe("Placeholder text."),
|
|
75
|
+
multiline: z.boolean().optional().describe("Render a textarea instead of a single-line input."),
|
|
76
|
+
label: z.string().optional().describe("Accessible label for the control.")
|
|
77
|
+
}),
|
|
78
|
+
render: ({ placeholder, multiline, label, $action, $dispatch }) => {
|
|
79
|
+
const submit = (v) => fire($action, $dispatch, v);
|
|
80
|
+
return multiline ? /* @__PURE__ */ jsx("textarea", {
|
|
81
|
+
"data-aui": "input",
|
|
82
|
+
"data-aui-multiline": true,
|
|
83
|
+
"data-aui-action": actionAttr($action),
|
|
84
|
+
"aria-label": label,
|
|
85
|
+
placeholder,
|
|
86
|
+
onKeyDown: (e) => {
|
|
87
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey) && !e.nativeEvent.isComposing) submit(e.currentTarget.value);
|
|
88
|
+
}
|
|
89
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
90
|
+
"data-aui": "input",
|
|
91
|
+
"data-aui-action": actionAttr($action),
|
|
92
|
+
"aria-label": label,
|
|
93
|
+
placeholder,
|
|
94
|
+
onKeyDown: (e) => {
|
|
95
|
+
if (e.key === "Enter" && !e.nativeEvent.isComposing) submit(e.currentTarget.value);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
DatePicker: {
|
|
101
|
+
description: "A date input. Carries `$action` describing the on-select behavior.",
|
|
102
|
+
properties: z.object({
|
|
103
|
+
value: z.string().optional().describe("Initial date (YYYY-MM-DD)."),
|
|
104
|
+
min: z.string().optional().describe("Minimum date (YYYY-MM-DD)."),
|
|
105
|
+
max: z.string().optional().describe("Maximum date (YYYY-MM-DD)."),
|
|
106
|
+
label: z.string().optional().describe("Accessible label for the control.")
|
|
107
|
+
}),
|
|
108
|
+
render: ({ value, min, max, label, $action, $dispatch }) => /* @__PURE__ */ jsx("input", {
|
|
109
|
+
type: "date",
|
|
110
|
+
"data-aui": "datepicker",
|
|
111
|
+
"data-aui-action": actionAttr($action),
|
|
112
|
+
"aria-label": label,
|
|
113
|
+
defaultValue: value,
|
|
114
|
+
min,
|
|
115
|
+
max,
|
|
116
|
+
onChange: (e) => fire($action, $dispatch, e.currentTarget.value)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
121
|
+
export { interactiveVocabulary };
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=interactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.js","names":[],"sources":["../../src/vocabulary/interactive.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { Action } from \"../ir\";\nimport { BUTTON_STYLES } from \"../ir\";\nimport type { GenerativeUIDispatch, GenerativeUILibrary } from \"../types\";\n\nconst optionSchema = z.object({\n label: z.string(),\n value: z.string(),\n});\n\nconst actionAttr = (a: Action | undefined): string | undefined =>\n a ? JSON.stringify(a) : undefined;\n\n/** Fires `$action` through `$dispatch` when both are present, merging a runtime\n * value into the payload under the reserved `$input` key (not `value`) so the\n * user's input never clobbers a model-supplied `value` field. No-op when no\n * registry is wired. The returned promise from an async handler is caught and\n * re-thrown on a microtask so rejections surface rather than going unhandled. */\nconst fire = (\n $action: Action | undefined,\n $dispatch: GenerativeUIDispatch | undefined,\n input?: unknown,\n) => {\n if (!$action || !$dispatch) return;\n const payload = input === undefined ? $action : { ...$action, $input: input };\n void Promise.resolve($dispatch(payload)).catch((error) => {\n queueMicrotask(() => {\n throw error;\n });\n });\n};\n\nexport const interactiveVocabulary = {\n Button: {\n description:\n \"A clickable button. Carries `$action` describing the side effect or resume value.\",\n properties: z.object({\n label: z.string().describe(\"Button label.\"),\n buttonStyle: z.enum(BUTTON_STYLES).optional().describe(\"Visual style.\"),\n block: z\n .boolean()\n .optional()\n .describe(\"Whether the button spans the full width.\"),\n }),\n render: ({ label, buttonStyle, block, $action, $dispatch, children }) => (\n <button\n data-aui=\"button\"\n data-aui-style={buttonStyle}\n data-aui-block={block || undefined}\n data-aui-action={actionAttr($action)}\n onClick={() => fire($action, $dispatch)}\n >\n {label}\n {children}\n </button>\n ),\n },\n Select: {\n description:\n \"A dropdown selector. Carries `$action` describing the on-select behavior.\",\n properties: z.object({\n options: z.array(optionSchema).describe(\"Selectable options.\"),\n placeholder: z\n .string()\n .optional()\n .describe(\"Placeholder shown when nothing is selected.\"),\n label: z\n .string()\n .optional()\n .describe(\"Accessible label for the control.\"),\n }),\n render: ({ options, placeholder, label, $action, $dispatch, children }) => (\n <select\n data-aui=\"select\"\n data-aui-action={actionAttr($action)}\n aria-label={label}\n defaultValue=\"\"\n onChange={(e) => fire($action, $dispatch, e.currentTarget.value)}\n >\n {placeholder ? (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n ) : null}\n {options.map((o: { label: string; value: string }, i: number) => (\n <option key={i} value={o.value}>\n {o.label}\n </option>\n ))}\n {children}\n </select>\n ),\n },\n Input: {\n description:\n \"A text input. Carries `$action` describing the on-submit behavior.\",\n properties: z.object({\n placeholder: z.string().optional().describe(\"Placeholder text.\"),\n multiline: z\n .boolean()\n .optional()\n .describe(\"Render a textarea instead of a single-line input.\"),\n label: z\n .string()\n .optional()\n .describe(\"Accessible label for the control.\"),\n }),\n render: ({ placeholder, multiline, label, $action, $dispatch }) => {\n const submit = (v: string) => fire($action, $dispatch, v);\n return multiline ? (\n <textarea\n data-aui=\"input\"\n data-aui-multiline\n data-aui-action={actionAttr($action)}\n aria-label={label}\n placeholder={placeholder}\n onKeyDown={(e) => {\n if (\n e.key === \"Enter\" &&\n (e.ctrlKey || e.metaKey) &&\n !e.nativeEvent.isComposing\n )\n submit(e.currentTarget.value);\n }}\n />\n ) : (\n <input\n data-aui=\"input\"\n data-aui-action={actionAttr($action)}\n aria-label={label}\n placeholder={placeholder}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !e.nativeEvent.isComposing)\n submit(e.currentTarget.value);\n }}\n />\n );\n },\n },\n DatePicker: {\n description:\n \"A date input. Carries `$action` describing the on-select behavior.\",\n properties: z.object({\n value: z.string().optional().describe(\"Initial date (YYYY-MM-DD).\"),\n min: z.string().optional().describe(\"Minimum date (YYYY-MM-DD).\"),\n max: z.string().optional().describe(\"Maximum date (YYYY-MM-DD).\"),\n label: z\n .string()\n .optional()\n .describe(\"Accessible label for the control.\"),\n }),\n render: ({ value, min, max, label, $action, $dispatch }) => (\n <input\n type=\"date\"\n data-aui=\"datepicker\"\n data-aui-action={actionAttr($action)}\n aria-label={label}\n defaultValue={value}\n min={min}\n max={max}\n onChange={(e) => fire($action, $dispatch, e.currentTarget.value)}\n />\n ),\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/vocabulary/layout.d.ts
|
|
4
|
+
declare const layoutVocabulary: {
|
|
5
|
+
Card: {
|
|
6
|
+
description: string;
|
|
7
|
+
properties: z.ZodObject<{
|
|
8
|
+
title: z.ZodOptional<z.ZodString>;
|
|
9
|
+
padding: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
background: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
render: ({
|
|
13
|
+
title,
|
|
14
|
+
padding,
|
|
15
|
+
background,
|
|
16
|
+
children
|
|
17
|
+
}: any) => import("react").JSX.Element;
|
|
18
|
+
};
|
|
19
|
+
Col: {
|
|
20
|
+
description: string;
|
|
21
|
+
properties: z.ZodObject<{
|
|
22
|
+
gap: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
start: "start";
|
|
25
|
+
center: "center";
|
|
26
|
+
end: "end";
|
|
27
|
+
}>>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
render: ({
|
|
30
|
+
gap,
|
|
31
|
+
align,
|
|
32
|
+
children
|
|
33
|
+
}: any) => import("react").JSX.Element;
|
|
34
|
+
};
|
|
35
|
+
Row: {
|
|
36
|
+
description: string;
|
|
37
|
+
properties: z.ZodObject<{
|
|
38
|
+
gap: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
40
|
+
start: "start";
|
|
41
|
+
center: "center";
|
|
42
|
+
end: "end";
|
|
43
|
+
}>>;
|
|
44
|
+
justify: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
start: "start";
|
|
46
|
+
center: "center";
|
|
47
|
+
end: "end";
|
|
48
|
+
between: "between";
|
|
49
|
+
}>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
render: ({
|
|
52
|
+
gap,
|
|
53
|
+
align,
|
|
54
|
+
justify,
|
|
55
|
+
children
|
|
56
|
+
}: any) => import("react").JSX.Element;
|
|
57
|
+
};
|
|
58
|
+
Spacer: {
|
|
59
|
+
description: string;
|
|
60
|
+
properties: z.ZodObject<{}, z.core.$strip>;
|
|
61
|
+
render: () => import("react").JSX.Element;
|
|
62
|
+
};
|
|
63
|
+
Badge: {
|
|
64
|
+
description: string;
|
|
65
|
+
properties: z.ZodObject<{
|
|
66
|
+
value: z.ZodString;
|
|
67
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
render: ({
|
|
70
|
+
value,
|
|
71
|
+
variant,
|
|
72
|
+
children
|
|
73
|
+
}: any) => import("react").JSX.Element;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
export { layoutVocabulary };
|
|
78
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","names":[],"sources":["../../src/vocabulary/layout.tsx"],"mappings":";;;cAIa,gBAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ALIGNS, JUSTIFIES } from "../ir.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/vocabulary/layout.tsx
|
|
5
|
+
const layoutVocabulary = {
|
|
6
|
+
Card: {
|
|
7
|
+
description: "A bordered container grouping related content. Optionally titled.",
|
|
8
|
+
properties: z.object({
|
|
9
|
+
title: z.string().optional().describe("Optional card title."),
|
|
10
|
+
padding: z.number().optional().describe("Padding in 4px units (e.g. 2 = 8px)."),
|
|
11
|
+
background: z.string().optional().describe("Background token or color.")
|
|
12
|
+
}),
|
|
13
|
+
render: ({ title, padding, background, children }) => /* @__PURE__ */ jsxs("section", {
|
|
14
|
+
"data-aui": "card",
|
|
15
|
+
"data-aui-padding": padding,
|
|
16
|
+
"data-aui-background": background,
|
|
17
|
+
children: [title ? /* @__PURE__ */ jsx("header", {
|
|
18
|
+
"data-aui": "card-title",
|
|
19
|
+
children: title
|
|
20
|
+
}) : null, children]
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
Col: {
|
|
24
|
+
description: "A vertical stack; children laid out top to bottom.",
|
|
25
|
+
properties: z.object({
|
|
26
|
+
gap: z.number().optional().describe("Gap between children in 4px units."),
|
|
27
|
+
align: z.enum(ALIGNS).optional().describe("Cross-axis alignment.")
|
|
28
|
+
}),
|
|
29
|
+
render: ({ gap, align, children }) => /* @__PURE__ */ jsx("div", {
|
|
30
|
+
"data-aui": "col",
|
|
31
|
+
"data-aui-gap": gap,
|
|
32
|
+
"data-aui-align": align,
|
|
33
|
+
children
|
|
34
|
+
})
|
|
35
|
+
},
|
|
36
|
+
Row: {
|
|
37
|
+
description: "A horizontal row; children laid out left to right.",
|
|
38
|
+
properties: z.object({
|
|
39
|
+
gap: z.number().optional().describe("Gap between children in 4px units."),
|
|
40
|
+
align: z.enum(ALIGNS).optional().describe("Cross-axis alignment."),
|
|
41
|
+
justify: z.enum(JUSTIFIES).optional().describe("Main-axis distribution.")
|
|
42
|
+
}),
|
|
43
|
+
render: ({ gap, align, justify, children }) => /* @__PURE__ */ jsx("div", {
|
|
44
|
+
"data-aui": "row",
|
|
45
|
+
"data-aui-gap": gap,
|
|
46
|
+
"data-aui-align": align,
|
|
47
|
+
"data-aui-justify": justify,
|
|
48
|
+
children
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
Spacer: {
|
|
52
|
+
description: "Empty space that pushes neighbors apart.",
|
|
53
|
+
properties: z.object({}),
|
|
54
|
+
render: () => /* @__PURE__ */ jsx("div", { "data-aui": "spacer" })
|
|
55
|
+
},
|
|
56
|
+
Badge: {
|
|
57
|
+
description: "A small labeled tag, e.g. for status or category.",
|
|
58
|
+
properties: z.object({
|
|
59
|
+
value: z.string().describe("Badge text."),
|
|
60
|
+
variant: z.string().optional().describe("Visual variant token.")
|
|
61
|
+
}),
|
|
62
|
+
render: ({ value, variant, children }) => /* @__PURE__ */ jsxs("span", {
|
|
63
|
+
"data-aui": "badge",
|
|
64
|
+
"data-aui-variant": variant,
|
|
65
|
+
children: [value, children]
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { layoutVocabulary };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../../src/vocabulary/layout.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { ALIGNS, JUSTIFIES } from \"../ir\";\n\nexport const layoutVocabulary = {\n Card: {\n description:\n \"A bordered container grouping related content. Optionally titled.\",\n properties: z.object({\n title: z.string().optional().describe(\"Optional card title.\"),\n padding: z\n .number()\n .optional()\n .describe(\"Padding in 4px units (e.g. 2 = 8px).\"),\n background: z.string().optional().describe(\"Background token or color.\"),\n }),\n render: ({ title, padding, background, children }) => (\n <section\n data-aui=\"card\"\n data-aui-padding={padding}\n data-aui-background={background}\n >\n {title ? <header data-aui=\"card-title\">{title}</header> : null}\n {children}\n </section>\n ),\n },\n Col: {\n description: \"A vertical stack; children laid out top to bottom.\",\n properties: z.object({\n gap: z.number().optional().describe(\"Gap between children in 4px units.\"),\n align: z.enum(ALIGNS).optional().describe(\"Cross-axis alignment.\"),\n }),\n render: ({ gap, align, children }) => (\n <div data-aui=\"col\" data-aui-gap={gap} data-aui-align={align}>\n {children}\n </div>\n ),\n },\n Row: {\n description: \"A horizontal row; children laid out left to right.\",\n properties: z.object({\n gap: z.number().optional().describe(\"Gap between children in 4px units.\"),\n align: z.enum(ALIGNS).optional().describe(\"Cross-axis alignment.\"),\n justify: z.enum(JUSTIFIES).optional().describe(\"Main-axis distribution.\"),\n }),\n render: ({ gap, align, justify, children }) => (\n <div\n data-aui=\"row\"\n data-aui-gap={gap}\n data-aui-align={align}\n data-aui-justify={justify}\n >\n {children}\n </div>\n ),\n },\n Spacer: {\n description: \"Empty space that pushes neighbors apart.\",\n properties: z.object({}),\n render: () => <div data-aui=\"spacer\" />,\n },\n Badge: {\n description: \"A small labeled tag, e.g. for status or category.\",\n properties: z.object({\n value: z.string().describe(\"Badge text.\"),\n variant: z.string().optional().describe(\"Visual variant token.\"),\n }),\n render: ({ value, variant, children }) => (\n <span data-aui=\"badge\" data-aui-variant={variant}>\n {value}\n {children}\n </span>\n ),\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;AAIA,MAAa,mBAAmB;CAC9B,MAAM;EACJ,aACE;EACF,YAAY,EAAE,OAAO;GACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,sBAAsB;GAC5D,SAAS,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,sCAAsC;GAClD,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,4BAA4B;EACzE,CAAC;EACD,SAAS,EAAE,OAAO,SAAS,YAAY,eACrC,qBAAC,WAAD;GACE,YAAS;GACT,oBAAkB;GAClB,uBAAqB;aAHvB,CAKG,QAAQ,oBAAC,UAAD;IAAQ,YAAS;cAAc;GAAc,CAAA,IAAI,MACzD,QACM;;CAEb;CACA,KAAK;EACH,aAAa;EACb,YAAY,EAAE,OAAO;GACnB,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,oCAAoC;GACxE,OAAO,EAAE,KAAK,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,uBAAuB;EACnE,CAAC;EACD,SAAS,EAAE,KAAK,OAAO,eACrB,oBAAC,OAAD;GAAK,YAAS;GAAM,gBAAc;GAAK,kBAAgB;GACpD;EACE,CAAA;CAET;CACA,KAAK;EACH,aAAa;EACb,YAAY,EAAE,OAAO;GACnB,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,oCAAoC;GACxE,OAAO,EAAE,KAAK,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,uBAAuB;GACjE,SAAS,EAAE,KAAK,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,yBAAyB;EAC1E,CAAC;EACD,SAAS,EAAE,KAAK,OAAO,SAAS,eAC9B,oBAAC,OAAD;GACE,YAAS;GACT,gBAAc;GACd,kBAAgB;GAChB,oBAAkB;GAEjB;EACE,CAAA;CAET;CACA,QAAQ;EACN,aAAa;EACb,YAAY,EAAE,OAAO,CAAC,CAAC;EACvB,cAAc,oBAAC,OAAD,EAAK,YAAS,SAAU,CAAA;CACxC;CACA,OAAO;EACL,aAAa;EACb,YAAY,EAAE,OAAO;GACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,aAAa;GACxC,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,uBAAuB;EACjE,CAAC;EACD,SAAS,EAAE,OAAO,SAAS,eACzB,qBAAC,QAAD;GAAM,YAAS;GAAQ,oBAAkB;aAAzC,CACG,OACA,QACG;;CAEV;AACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/vocabulary/media.d.ts
|
|
4
|
+
declare const mediaVocabulary: {
|
|
5
|
+
Image: {
|
|
6
|
+
description: string;
|
|
7
|
+
properties: z.ZodObject<{
|
|
8
|
+
src: z.ZodString;
|
|
9
|
+
alt: z.ZodString;
|
|
10
|
+
size: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
11
|
+
sm: "sm";
|
|
12
|
+
md: "md";
|
|
13
|
+
lg: "lg";
|
|
14
|
+
}>, z.ZodNumber]>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
render: ({
|
|
17
|
+
src,
|
|
18
|
+
alt,
|
|
19
|
+
size
|
|
20
|
+
}: any) => import("react").JSX.Element;
|
|
21
|
+
};
|
|
22
|
+
Divider: {
|
|
23
|
+
description: string;
|
|
24
|
+
properties: z.ZodObject<{
|
|
25
|
+
flush: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
render: ({
|
|
28
|
+
flush
|
|
29
|
+
}: any) => import("react").JSX.Element;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { mediaVocabulary };
|
|
34
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","names":[],"sources":["../../src/vocabulary/media.tsx"],"mappings":";;;cAIa,eAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IMAGE_SIZE_TOKENS } from "../ir.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/vocabulary/media.tsx
|
|
5
|
+
const mediaVocabulary = {
|
|
6
|
+
Image: {
|
|
7
|
+
description: "An image. Provide `src` and `alt` for accessibility.",
|
|
8
|
+
properties: z.object({
|
|
9
|
+
src: z.string().describe("Image URL."),
|
|
10
|
+
alt: z.string().describe("Alt text for accessibility."),
|
|
11
|
+
size: z.union([z.enum(IMAGE_SIZE_TOKENS), z.number()]).optional().describe("Size token or pixel value.")
|
|
12
|
+
}),
|
|
13
|
+
render: ({ src, alt, size }) => /* @__PURE__ */ jsx("img", {
|
|
14
|
+
"data-aui": "image",
|
|
15
|
+
"data-aui-size": typeof size === "number" ? `${size}px` : size,
|
|
16
|
+
src,
|
|
17
|
+
alt
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
Divider: {
|
|
21
|
+
description: "A horizontal rule between sections.",
|
|
22
|
+
properties: z.object({ flush: z.boolean().optional().describe("Whether the divider spans the full width with no inset.") }),
|
|
23
|
+
render: ({ flush }) => /* @__PURE__ */ jsx("hr", {
|
|
24
|
+
"data-aui": "divider",
|
|
25
|
+
"data-aui-flush": flush || void 0
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { mediaVocabulary };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","names":[],"sources":["../../src/vocabulary/media.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { IMAGE_SIZE_TOKENS } from \"../ir\";\n\nexport const mediaVocabulary = {\n Image: {\n description: \"An image. Provide `src` and `alt` for accessibility.\",\n properties: z.object({\n src: z.string().describe(\"Image URL.\"),\n alt: z.string().describe(\"Alt text for accessibility.\"),\n size: z\n .union([z.enum(IMAGE_SIZE_TOKENS), z.number()])\n .optional()\n .describe(\"Size token or pixel value.\"),\n }),\n render: ({ src, alt, size }) => (\n <img\n data-aui=\"image\"\n data-aui-size={typeof size === \"number\" ? `${size}px` : size}\n src={src}\n alt={alt}\n />\n ),\n },\n Divider: {\n description: \"A horizontal rule between sections.\",\n properties: z.object({\n flush: z\n .boolean()\n .optional()\n .describe(\"Whether the divider spans the full width with no inset.\"),\n }),\n render: ({ flush }) => (\n <hr data-aui=\"divider\" data-aui-flush={flush || undefined} />\n ),\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;AAIA,MAAa,kBAAkB;CAC7B,OAAO;EACL,aAAa;EACb,YAAY,EAAE,OAAO;GACnB,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,YAAY;GACrC,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,6BAA6B;GACtD,MAAM,EACH,MAAM,CAAC,EAAE,KAAK,iBAAiB,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAC9C,SAAS,CAAC,CACV,SAAS,4BAA4B;EAC1C,CAAC;EACD,SAAS,EAAE,KAAK,KAAK,WACnB,oBAAC,OAAD;GACE,YAAS;GACT,iBAAe,OAAO,SAAS,WAAW,GAAG,KAAK,MAAM;GACnD;GACA;EACN,CAAA;CAEL;CACA,SAAS;EACP,aAAa;EACb,YAAY,EAAE,OAAO,EACnB,OAAO,EACJ,QAAQ,CAAC,CACT,SAAS,CAAC,CACV,SAAS,yDAAyD,EACvE,CAAC;EACD,SAAS,EAAE,YACT,oBAAC,MAAD;GAAI,YAAS;GAAU,kBAAgB,SAAS,KAAA;EAAY,CAAA;CAEhE;AACF"}
|