@assistant-ui/react-generative-ui 0.0.17 → 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.
Files changed (141) hide show
  1. package/dist/JSONGenerativeUI.client.d.ts +1 -2
  2. package/dist/JSONGenerativeUI.client.d.ts.map +1 -1
  3. package/dist/JSONGenerativeUI.server.d.ts +1 -2
  4. package/dist/JSONGenerativeUI.server.d.ts.map +1 -1
  5. package/dist/JSONGenerativeUI.shared.d.ts +8 -9
  6. package/dist/JSONGenerativeUI.shared.d.ts.map +1 -1
  7. package/dist/a2ui/convert.d.ts +1 -2
  8. package/dist/a2ui/convert.d.ts.map +1 -1
  9. package/dist/a2ui/convert.js +11 -2
  10. package/dist/a2ui/convert.js.map +1 -1
  11. package/dist/a2ui/reducer.d.ts +1 -2
  12. package/dist/a2ui/reducer.d.ts.map +1 -1
  13. package/dist/a2ui/reducer.js +63 -10
  14. package/dist/a2ui/reducer.js.map +1 -1
  15. package/dist/a2ui/types.d.ts +17 -18
  16. package/dist/a2ui/types.d.ts.map +1 -1
  17. package/dist/actionRegistry.d.ts +5 -6
  18. package/dist/actionRegistry.d.ts.map +1 -1
  19. package/dist/buildPresentParameters.d.ts +2 -3
  20. package/dist/buildPresentParameters.d.ts.map +1 -1
  21. package/dist/buildPresentParameters.js +4 -3
  22. package/dist/buildPresentParameters.js.map +1 -1
  23. package/dist/constants.d.ts +2 -2
  24. package/dist/constants.d.ts.map +1 -1
  25. package/dist/constants.js +2 -1
  26. package/dist/constants.js.map +1 -1
  27. package/dist/convert/boundSpec.d.ts +7 -8
  28. package/dist/convert/boundSpec.d.ts.map +1 -1
  29. package/dist/convert/copyBounded.d.ts +1 -2
  30. package/dist/convert/copyBounded.d.ts.map +1 -1
  31. package/dist/convert/isElement.d.ts +1 -2
  32. package/dist/convert/isElement.d.ts.map +1 -1
  33. package/dist/convert/takeRun.d.ts +1 -2
  34. package/dist/convert/takeRun.d.ts.map +1 -1
  35. package/dist/defineGenerativeComponents.d.ts +1 -2
  36. package/dist/defineGenerativeComponents.d.ts.map +1 -1
  37. package/dist/generativeUIToJSX.d.ts +2 -3
  38. package/dist/generativeUIToJSX.d.ts.map +1 -1
  39. package/dist/ir.d.ts +28 -29
  40. package/dist/ir.d.ts.map +1 -1
  41. package/dist/renderGenerativeUI.d.ts +1 -2
  42. package/dist/renderGenerativeUI.d.ts.map +1 -1
  43. package/dist/renderGenerativeUI.js +1 -1
  44. package/dist/renderGenerativeUI.js.map +1 -1
  45. package/dist/slack/constants.d.ts +35 -36
  46. package/dist/slack/constants.d.ts.map +1 -1
  47. package/dist/slack/decodeBlockAction.d.ts +1 -2
  48. package/dist/slack/decodeBlockAction.d.ts.map +1 -1
  49. package/dist/slack/fromSlackBlocks.d.ts +1 -2
  50. package/dist/slack/fromSlackBlocks.d.ts.map +1 -1
  51. package/dist/slack/toSlackBlocks.d.ts +1 -2
  52. package/dist/slack/toSlackBlocks.d.ts.map +1 -1
  53. package/dist/slack/types.d.ts +32 -33
  54. package/dist/slack/types.d.ts.map +1 -1
  55. package/dist/teams/constants.d.ts +14 -15
  56. package/dist/teams/constants.d.ts.map +1 -1
  57. package/dist/teams/decodeSubmitData.d.ts +1 -2
  58. package/dist/teams/decodeSubmitData.d.ts.map +1 -1
  59. package/dist/teams/toAdaptiveCard.d.ts +6 -7
  60. package/dist/teams/toAdaptiveCard.d.ts.map +1 -1
  61. package/dist/teams/toTeamsAttachments.d.ts +1 -2
  62. package/dist/teams/toTeamsAttachments.d.ts.map +1 -1
  63. package/dist/teams/types.d.ts +29 -30
  64. package/dist/teams/types.d.ts.map +1 -1
  65. package/dist/types.d.ts +9 -10
  66. package/dist/types.d.ts.map +1 -1
  67. package/dist/vocabulary/alert.d.ts +2 -3
  68. package/dist/vocabulary/alert.d.ts.map +1 -1
  69. package/dist/vocabulary/alert.js +21 -16
  70. package/dist/vocabulary/alert.js.map +1 -1
  71. package/dist/vocabulary/collectFormValues.d.ts +6 -5
  72. package/dist/vocabulary/collectFormValues.d.ts.map +1 -1
  73. package/dist/vocabulary/collectFormValues.js +3 -2
  74. package/dist/vocabulary/collectFormValues.js.map +1 -1
  75. package/dist/vocabulary/data.d.ts +1 -2
  76. package/dist/vocabulary/data.d.ts.map +1 -1
  77. package/dist/vocabulary/data.js +20 -12
  78. package/dist/vocabulary/data.js.map +1 -1
  79. package/dist/vocabulary/dispatch.d.ts +2 -3
  80. package/dist/vocabulary/dispatch.d.ts.map +1 -1
  81. package/dist/vocabulary/fact.d.ts +1 -2
  82. package/dist/vocabulary/fact.d.ts.map +1 -1
  83. package/dist/vocabulary/fact.js +3 -2
  84. package/dist/vocabulary/fact.js.map +1 -1
  85. package/dist/vocabulary/form.d.ts +1 -2
  86. package/dist/vocabulary/form.d.ts.map +1 -1
  87. package/dist/vocabulary/icon.d.ts +1 -2
  88. package/dist/vocabulary/icon.d.ts.map +1 -1
  89. package/dist/vocabulary/index.d.ts +1 -2
  90. package/dist/vocabulary/index.d.ts.map +1 -1
  91. package/dist/vocabulary/interactive.d.ts +10 -9
  92. package/dist/vocabulary/interactive.d.ts.map +1 -1
  93. package/dist/vocabulary/interactive.js +30 -23
  94. package/dist/vocabulary/interactive.js.map +1 -1
  95. package/dist/vocabulary/layout.d.ts +1 -2
  96. package/dist/vocabulary/layout.d.ts.map +1 -1
  97. package/dist/vocabulary/layout.js +7 -5
  98. package/dist/vocabulary/layout.js.map +1 -1
  99. package/dist/vocabulary/list.d.ts +1 -2
  100. package/dist/vocabulary/list.d.ts.map +1 -1
  101. package/dist/vocabulary/media.d.ts +1 -2
  102. package/dist/vocabulary/media.d.ts.map +1 -1
  103. package/dist/vocabulary/text.d.ts +2 -3
  104. package/dist/vocabulary/text.d.ts.map +1 -1
  105. package/dist/vocabulary/text.js +4 -3
  106. package/dist/vocabulary/text.js.map +1 -1
  107. package/dist/vocabulary/toTextContent.d.ts +4 -0
  108. package/dist/vocabulary/toTextContent.d.ts.map +1 -0
  109. package/dist/vocabulary/toTextContent.js +6 -0
  110. package/dist/vocabulary/toTextContent.js.map +1 -0
  111. package/package.json +12 -10
  112. package/src/a2ui/convert.test.ts +36 -0
  113. package/src/a2ui/convert.ts +21 -2
  114. package/src/a2ui/reducer.test.ts +223 -0
  115. package/src/a2ui/reducer.ts +76 -12
  116. package/src/buildPresentParameters.ts +7 -4
  117. package/src/constants.ts +2 -0
  118. package/src/renderGenerativeUI.test.tsx +57 -0
  119. package/src/renderGenerativeUI.tsx +3 -1
  120. package/src/slack/fromSlackBlocks.test.ts +4 -1
  121. package/src/slack/toSlackBlocks.test.ts +8 -4
  122. package/src/teams/toAdaptiveCard.test.ts +5 -3
  123. package/src/vocabulary/alert.test.tsx +10 -0
  124. package/src/vocabulary/alert.tsx +16 -7
  125. package/src/vocabulary/collectFormValues.test.ts +38 -0
  126. package/src/vocabulary/collectFormValues.ts +11 -2
  127. package/src/vocabulary/data.test.tsx +40 -0
  128. package/src/vocabulary/data.tsx +47 -26
  129. package/src/vocabulary/fact.test.tsx +12 -0
  130. package/src/vocabulary/fact.tsx +3 -2
  131. package/src/vocabulary/form.test.tsx +1 -0
  132. package/src/vocabulary/interactive.test.tsx +55 -1
  133. package/src/vocabulary/interactive.tsx +50 -29
  134. package/src/vocabulary/layout.test.tsx +17 -0
  135. package/src/vocabulary/layout.tsx +8 -4
  136. package/src/vocabulary/list.test.tsx +5 -4
  137. package/src/vocabulary/text.test.tsx +29 -0
  138. package/src/vocabulary/text.tsx +4 -3
  139. package/src/vocabulary/toTextContent.ts +2 -0
  140. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts +0 -141
  141. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  //#region src/vocabulary/alert.d.ts
3
- declare const alertVocabulary: {
3
+ export declare const alertVocabulary: {
4
4
  Alert: {
5
5
  description: string;
6
6
  properties: z.ZodObject<{
@@ -8,9 +8,9 @@ declare const alertVocabulary: {
8
8
  description: z.ZodOptional<z.ZodString>;
9
9
  tone: z.ZodOptional<z.ZodEnum<{
10
10
  success: "success";
11
- danger: "danger";
12
11
  info: "info";
13
12
  warning: "warning";
13
+ danger: "danger";
14
14
  }>>;
15
15
  }, z.core.$strip>;
16
16
  render: ({ title, description, tone, children }: any) => import("react").JSX.Element;
@@ -24,5 +24,4 @@ declare const alertVocabulary: {
24
24
  };
25
25
  };
26
26
  //#endregion
27
- export { alertVocabulary };
28
27
  //# sourceMappingURL=alert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"alert.d.ts","names":[],"sources":["../../src/vocabulary/alert.tsx"],"mappings":";;cAOa"}
1
+ {"version":3,"file":"alert.d.ts","names":[],"sources":["../../src/vocabulary/alert.tsx"],"mappings":";;qBAQa"}
@@ -1,4 +1,5 @@
1
1
  import { ALERT_TONES } from "../ir.js";
2
+ import { toTextContent } from "./toTextContent.js";
2
3
  import { Children } from "react";
3
4
  import { jsx, jsxs } from "react/jsx-runtime";
4
5
  import { z } from "zod";
@@ -12,22 +13,26 @@ const alertVocabulary = {
12
13
  description: z.string().optional().describe("Supporting description text."),
13
14
  tone: z.enum(ALERT_TONES).optional().describe("Severity tone; defaults to `info`.")
14
15
  }),
15
- render: ({ title, description, tone, children }) => /* @__PURE__ */ jsxs("div", {
16
- "data-aui": "alert",
17
- "data-aui-tone": tone ?? "info",
18
- role: "alert",
19
- children: [
20
- title ? /* @__PURE__ */ jsx("header", {
21
- "data-aui": "alert-title",
22
- children: title
23
- }) : null,
24
- description ? /* @__PURE__ */ jsx("p", {
25
- "data-aui": "alert-desc",
26
- children: description
27
- }) : null,
28
- children
29
- ]
30
- })
16
+ render: ({ title, description, tone, children }) => {
17
+ const alertTitle = toTextContent(title);
18
+ const alertDescription = toTextContent(description);
19
+ return /* @__PURE__ */ jsxs("div", {
20
+ "data-aui": "alert",
21
+ "data-aui-tone": tone ?? "info",
22
+ role: "alert",
23
+ children: [
24
+ alertTitle ? /* @__PURE__ */ jsx("header", {
25
+ "data-aui": "alert-title",
26
+ children: alertTitle
27
+ }) : null,
28
+ alertDescription ? /* @__PURE__ */ jsx("p", {
29
+ "data-aui": "alert-desc",
30
+ children: alertDescription
31
+ }) : null,
32
+ children
33
+ ]
34
+ });
35
+ }
31
36
  },
32
37
  Carousel: {
33
38
  description: "A horizontally scrollable group of `Card` children (max 10). Set `label` for an accessible name.",
@@ -1 +1 @@
1
- {"version":3,"file":"alert.js","names":[],"sources":["../../src/vocabulary/alert.tsx"],"sourcesContent":["import { Children } from \"react\";\nimport { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { ALERT_TONES } from \"../ir\";\n\nconst MAX_CARDS = 10;\n\nexport const alertVocabulary = {\n Alert: {\n description:\n \"A highlighted message conveying urgency. `tone` drives the severity.\",\n properties: z.object({\n title: z.string().optional().describe(\"Alert title.\"),\n description: z\n .string()\n .optional()\n .describe(\"Supporting description text.\"),\n tone: z\n .enum(ALERT_TONES)\n .optional()\n .describe(\"Severity tone; defaults to `info`.\"),\n }),\n render: ({ title, description, tone, children }) => (\n <div data-aui=\"alert\" data-aui-tone={tone ?? \"info\"} role=\"alert\">\n {title ? <header data-aui=\"alert-title\">{title}</header> : null}\n {description ? <p data-aui=\"alert-desc\">{description}</p> : null}\n {children}\n </div>\n ),\n },\n Carousel: {\n description:\n \"A horizontally scrollable group of `Card` children (max 10). Set `label` for an accessible name.\",\n properties: z.object({\n label: z\n .string()\n .optional()\n .describe(\"Accessible label for the carousel.\"),\n }),\n render: ({ label, children }) => {\n const cards = Children.toArray(children).slice(0, MAX_CARDS);\n const n = cards.length;\n return (\n <div\n data-aui=\"carousel\"\n role={label ? \"region\" : \"group\"}\n aria-roledescription=\"carousel\"\n aria-label={label}\n tabIndex={0}\n >\n {cards.map((card, i) => (\n <div\n key={i}\n data-aui=\"carousel-slide\"\n role=\"group\"\n aria-roledescription=\"slide\"\n aria-label={`${i + 1} of ${n}`}\n >\n {card}\n </div>\n ))}\n </div>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;;AAKA,MAAM,YAAY;AAElB,MAAa,kBAAkB;CAC7B,OAAO;EACL,aACE;EACF,YAAY,EAAE,OAAO;GACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,cAAc;GACpD,aAAa,EACV,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,8BAA8B;GAC1C,MAAM,EACH,KAAK,WAAW,CAAC,CACjB,SAAS,CAAC,CACV,SAAS,oCAAoC;EAClD,CAAC;EACD,SAAS,EAAE,OAAO,aAAa,MAAM,eACnC,qBAAC,OAAD;GAAK,YAAS;GAAQ,iBAAe,QAAQ;GAAQ,MAAK;GAA1D,UAAA;IACG,QAAQ,oBAAC,UAAD;KAAQ,YAAS;KAAe,UAAA;IAAc,CAAA,IAAI;IAC1D,cAAc,oBAAC,KAAD;KAAG,YAAS;KAAc,UAAA;IAAe,CAAA,IAAI;IAC3D;GACE;;CAET;CACA,UAAU;EACR,aACE;EACF,YAAY,EAAE,OAAO,EACnB,OAAO,EACJ,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,oCAAoC,EAClD,CAAC;EACD,SAAS,EAAE,OAAO,eAAe;GAC/B,MAAM,QAAQ,SAAS,QAAQ,QAAQ,CAAC,CAAC,MAAM,GAAG,SAAS;GAC3D,MAAM,IAAI,MAAM;GAChB,OACE,oBAAC,OAAD;IACE,YAAS;IACT,MAAM,QAAQ,WAAW;IACzB,wBAAqB;IACrB,cAAY;IACZ,UAAU;IAET,UAAA,MAAM,KAAK,MAAM,MAChB,oBAAC,OAAD;KAEE,YAAS;KACT,MAAK;KACL,wBAAqB;KACrB,cAAY,GAAG,IAAI,EAAE,MAAM;KAE1B,UAAA;IACE,GAPE,CAOF,CACN;GACE,CAAA;EAET;CACF;AACF"}
1
+ {"version":3,"file":"alert.js","names":[],"sources":["../../src/vocabulary/alert.tsx"],"sourcesContent":["import { Children } from \"react\";\nimport { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { ALERT_TONES } from \"../ir\";\nimport { toTextContent } from \"./toTextContent\";\n\nconst MAX_CARDS = 10;\n\nexport const alertVocabulary = {\n Alert: {\n description:\n \"A highlighted message conveying urgency. `tone` drives the severity.\",\n properties: z.object({\n title: z.string().optional().describe(\"Alert title.\"),\n description: z\n .string()\n .optional()\n .describe(\"Supporting description text.\"),\n tone: z\n .enum(ALERT_TONES)\n .optional()\n .describe(\"Severity tone; defaults to `info`.\"),\n }),\n render: ({ title, description, tone, children }) => {\n const alertTitle = toTextContent(title);\n const alertDescription = toTextContent(description);\n return (\n <div data-aui=\"alert\" data-aui-tone={tone ?? \"info\"} role=\"alert\">\n {alertTitle ? (\n <header data-aui=\"alert-title\">{alertTitle}</header>\n ) : null}\n {alertDescription ? (\n <p data-aui=\"alert-desc\">{alertDescription}</p>\n ) : null}\n {children}\n </div>\n );\n },\n },\n Carousel: {\n description:\n \"A horizontally scrollable group of `Card` children (max 10). Set `label` for an accessible name.\",\n properties: z.object({\n label: z\n .string()\n .optional()\n .describe(\"Accessible label for the carousel.\"),\n }),\n render: ({ label, children }) => {\n const cards = Children.toArray(children).slice(0, MAX_CARDS);\n const n = cards.length;\n return (\n <div\n data-aui=\"carousel\"\n role={label ? \"region\" : \"group\"}\n aria-roledescription=\"carousel\"\n aria-label={label}\n tabIndex={0}\n >\n {cards.map((card, i) => (\n <div\n key={i}\n data-aui=\"carousel-slide\"\n role=\"group\"\n aria-roledescription=\"slide\"\n aria-label={`${i + 1} of ${n}`}\n >\n {card}\n </div>\n ))}\n </div>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;;;AAMA,MAAM,YAAY;AAElB,MAAa,kBAAkB;CAC7B,OAAO;EACL,aACE;EACF,YAAY,EAAE,OAAO;GACnB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,cAAc;GACpD,aAAa,EACV,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,8BAA8B;GAC1C,MAAM,EACH,KAAK,WAAW,CAAC,CACjB,SAAS,CAAC,CACV,SAAS,oCAAoC;EAClD,CAAC;EACD,SAAS,EAAE,OAAO,aAAa,MAAM,eAAe;GAClD,MAAM,aAAa,cAAc,KAAK;GACtC,MAAM,mBAAmB,cAAc,WAAW;GAClD,OACE,qBAAC,OAAD;IAAK,YAAS;IAAQ,iBAAe,QAAQ;IAAQ,MAAK;IAA1D,UAAA;KACG,aACC,oBAAC,UAAD;MAAQ,YAAS;MAAe,UAAA;KAAmB,CAAA,IACjD;KACH,mBACC,oBAAC,KAAD;MAAG,YAAS;MAAc,UAAA;KAAoB,CAAA,IAC5C;KACH;IACE;;EAET;CACF;CACA,UAAU;EACR,aACE;EACF,YAAY,EAAE,OAAO,EACnB,OAAO,EACJ,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,oCAAoC,EAClD,CAAC;EACD,SAAS,EAAE,OAAO,eAAe;GAC/B,MAAM,QAAQ,SAAS,QAAQ,QAAQ,CAAC,CAAC,MAAM,GAAG,SAAS;GAC3D,MAAM,IAAI,MAAM;GAChB,OACE,oBAAC,OAAD;IACE,YAAS;IACT,MAAM,QAAQ,WAAW;IACzB,wBAAqB;IACrB,cAAY;IACZ,UAAU;IAET,UAAA,MAAM,KAAK,MAAM,MAChB,oBAAC,OAAD;KAEE,YAAS;KACT,MAAK;KACL,wBAAqB;KACrB,cAAY,GAAG,IAAI,EAAE,MAAM;KAE1B,UAAA;IACE,GAPE,CAOF,CACN;GACE,CAAA;EAET;CACF;AACF"}
@@ -3,21 +3,22 @@ import { FormEvent } from "react";
3
3
  /**
4
4
  * 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.
5
5
  */
6
- type FormControlElementLike = {
6
+ export type FormControlElementLike = {
7
7
  readonly name: string;
8
8
  readonly type: string;
9
9
  readonly value: string;
10
10
  readonly checked?: boolean;
11
11
  readonly disabled: boolean;
12
+ readonly hasAttribute: (name: string) => boolean;
13
+ readonly matches?: ((selector: string) => boolean) | undefined;
12
14
  };
13
15
  /**
14
- * 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 `disabled`, are skipped entirely.
16
+ * 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.
15
17
  */
16
- declare function collectFormValues(elements: ArrayLike<FormControlElementLike>): Record<string, unknown>;
18
+ export declare function collectFormValues(elements: ArrayLike<FormControlElementLike>): Record<string, unknown>;
17
19
  /**
18
20
  * Convenience wrapper around {@link collectFormValues} for a native form submit event; the cast from `HTMLFormControlsCollection` to `ArrayLike<FormControlElementLike>` lives here once instead of at every call site.
19
21
  */
20
- declare function collectFormValuesFromEvent(event: FormEvent<HTMLFormElement>): Record<string, unknown>;
22
+ export declare function collectFormValuesFromEvent(event: FormEvent<HTMLFormElement>): Record<string, unknown>;
21
23
  //#endregion
22
- export { FormControlElementLike, collectFormValues, collectFormValuesFromEvent };
23
24
  //# sourceMappingURL=collectFormValues.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collectFormValues.d.ts","names":[],"sources":["../../src/vocabulary/collectFormValues.ts"],"mappings":";;;;;KAKY;WACD;WACA;WACA;WACA;WACA;;;;;iBAMK,kBACd,UAAU,UAAU,0BACnB;;;;iBAgCa,2BACd,OAAO,UAAU,mBAChB"}
1
+ {"version":3,"file":"collectFormValues.d.ts","names":[],"sources":["../../src/vocabulary/collectFormValues.ts"],"mappings":";;;;;YAMY;WACD;WACA;WACA;WACA;WACA;WACA,eAAe;WACf,YAAY;;;;;wBAMP,kBACd,UAAU,UAAU,0BACnB;;;;wBAsCa,2BACd,OAAO,UAAU,mBAChB"}
@@ -1,12 +1,13 @@
1
+ import "../constants.js";
1
2
  //#region src/vocabulary/collectFormValues.ts
2
3
  /**
3
- * 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 `disabled`, are skipped entirely.
4
+ * 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.
4
5
  */
5
6
  function collectFormValues(elements) {
6
7
  const values = Object.create(null);
7
8
  for (const element of Array.from(elements)) {
8
9
  const { name, disabled } = element;
9
- if (!name || disabled) continue;
10
+ if (!name || disabled || element.hasAttribute("data-aui-generated-name") || element.matches?.(":disabled")) continue;
10
11
  if (element.type === "radio") {
11
12
  if (element.checked) values[name] = element.value;
12
13
  else if (!Object.hasOwn(values, name)) values[name] = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"collectFormValues.js","names":[],"sources":["../../src/vocabulary/collectFormValues.ts"],"sourcesContent":["import type { FormEvent } from \"react\";\n\n/**\n * 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.\n */\nexport type FormControlElementLike = {\n readonly name: string;\n readonly type: string;\n readonly value: string;\n readonly checked?: boolean;\n readonly disabled: boolean;\n};\n\n/**\n * 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 `disabled`, are skipped entirely.\n */\nexport function collectFormValues(\n elements: ArrayLike<FormControlElementLike>,\n): Record<string, unknown> {\n const values: Record<string, unknown> = Object.create(null);\n\n for (const element of Array.from(elements)) {\n const { name, disabled } = element;\n if (!name || disabled) continue;\n\n if (element.type === \"radio\") {\n if (element.checked) values[name] = element.value;\n else if (!Object.hasOwn(values, name)) values[name] = undefined;\n continue;\n }\n\n const value: string | boolean =\n element.type === \"checkbox\" ? (element.checked ?? false) : element.value;\n\n if (Object.hasOwn(values, name)) {\n const existing = values[name];\n values[name] = Array.isArray(existing)\n ? [...existing, value]\n : [existing, value];\n } else {\n values[name] = value;\n }\n }\n\n return values;\n}\n\n/**\n * Convenience wrapper around {@link collectFormValues} for a native form submit event; the cast from `HTMLFormControlsCollection` to `ArrayLike<FormControlElementLike>` lives here once instead of at every call site.\n */\nexport function collectFormValuesFromEvent(\n event: FormEvent<HTMLFormElement>,\n): Record<string, unknown> {\n return collectFormValues(\n event.currentTarget\n .elements as unknown as ArrayLike<FormControlElementLike>,\n );\n}\n"],"mappings":";;;;AAgBA,SAAgB,kBACd,UACyB;CACzB,MAAM,SAAkC,OAAO,OAAO,IAAI;CAE1D,KAAK,MAAM,WAAW,MAAM,KAAK,QAAQ,GAAG;EAC1C,MAAM,EAAE,MAAM,aAAa;EAC3B,IAAI,CAAC,QAAQ,UAAU;EAEvB,IAAI,QAAQ,SAAS,SAAS;GAC5B,IAAI,QAAQ,SAAS,OAAO,QAAQ,QAAQ;QACvC,IAAI,CAAC,OAAO,OAAO,QAAQ,IAAI,GAAG,OAAO,QAAQ,KAAA;GACtD;EACF;EAEA,MAAM,QACJ,QAAQ,SAAS,aAAc,QAAQ,WAAW,QAAS,QAAQ;EAErE,IAAI,OAAO,OAAO,QAAQ,IAAI,GAAG;GAC/B,MAAM,WAAW,OAAO;GACxB,OAAO,QAAQ,MAAM,QAAQ,QAAQ,IACjC,CAAC,GAAG,UAAU,KAAK,IACnB,CAAC,UAAU,KAAK;EACtB,OACE,OAAO,QAAQ;CAEnB;CAEA,OAAO;AACT;;;;AAKA,SAAgB,2BACd,OACyB;CACzB,OAAO,kBACL,MAAM,cACH,QACL;AACF"}
1
+ {"version":3,"file":"collectFormValues.js","names":[],"sources":["../../src/vocabulary/collectFormValues.ts"],"sourcesContent":["import type { FormEvent } from \"react\";\nimport { GENERATED_NAME_ATTR } from \"../constants\";\n\n/**\n * 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.\n */\nexport type FormControlElementLike = {\n readonly name: string;\n readonly type: string;\n readonly value: string;\n readonly checked?: boolean;\n readonly disabled: boolean;\n readonly hasAttribute: (name: string) => boolean;\n readonly matches?: ((selector: string) => boolean) | undefined;\n};\n\n/**\n * 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.\n */\nexport function collectFormValues(\n elements: ArrayLike<FormControlElementLike>,\n): Record<string, unknown> {\n const values: Record<string, unknown> = Object.create(null);\n\n for (const element of Array.from(elements)) {\n const { name, disabled } = element;\n if (\n !name ||\n disabled ||\n element.hasAttribute(GENERATED_NAME_ATTR) ||\n element.matches?.(\":disabled\")\n )\n continue;\n\n if (element.type === \"radio\") {\n if (element.checked) values[name] = element.value;\n else if (!Object.hasOwn(values, name)) values[name] = undefined;\n continue;\n }\n\n const value: string | boolean =\n element.type === \"checkbox\" ? (element.checked ?? false) : element.value;\n\n if (Object.hasOwn(values, name)) {\n const existing = values[name];\n values[name] = Array.isArray(existing)\n ? [...existing, value]\n : [existing, value];\n } else {\n values[name] = value;\n }\n }\n\n return values;\n}\n\n/**\n * Convenience wrapper around {@link collectFormValues} for a native form submit event; the cast from `HTMLFormControlsCollection` to `ArrayLike<FormControlElementLike>` lives here once instead of at every call site.\n */\nexport function collectFormValuesFromEvent(\n event: FormEvent<HTMLFormElement>,\n): Record<string, unknown> {\n return collectFormValues(\n event.currentTarget\n .elements as unknown as ArrayLike<FormControlElementLike>,\n );\n}\n"],"mappings":";;;;;AAmBA,SAAgB,kBACd,UACyB;CACzB,MAAM,SAAkC,OAAO,OAAO,IAAI;CAE1D,KAAK,MAAM,WAAW,MAAM,KAAK,QAAQ,GAAG;EAC1C,MAAM,EAAE,MAAM,aAAa;EAC3B,IACE,CAAC,QACD,YACA,QAAQ,aAAA,yBAAgC,KACxC,QAAQ,UAAU,WAAW,GAE7B;EAEF,IAAI,QAAQ,SAAS,SAAS;GAC5B,IAAI,QAAQ,SAAS,OAAO,QAAQ,QAAQ;QACvC,IAAI,CAAC,OAAO,OAAO,QAAQ,IAAI,GAAG,OAAO,QAAQ,KAAA;GACtD;EACF;EAEA,MAAM,QACJ,QAAQ,SAAS,aAAc,QAAQ,WAAW,QAAS,QAAQ;EAErE,IAAI,OAAO,OAAO,QAAQ,IAAI,GAAG;GAC/B,MAAM,WAAW,OAAO;GACxB,OAAO,QAAQ,MAAM,QAAQ,QAAQ,IACjC,CAAC,GAAG,UAAU,KAAK,IACnB,CAAC,UAAU,KAAK;EACtB,OACE,OAAO,QAAQ;CAEnB;CAEA,OAAO;AACT;;;;AAKA,SAAgB,2BACd,OACyB;CACzB,OAAO,kBACL,MAAM,cACH,QACL;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  //#region src/vocabulary/data.d.ts
3
- declare const dataVocabulary: {
3
+ export declare const dataVocabulary: {
4
4
  Table: {
5
5
  description: string;
6
6
  properties: z.ZodObject<{
@@ -48,5 +48,4 @@ declare const dataVocabulary: {
48
48
  };
49
49
  };
50
50
  //#endregion
51
- export { dataVocabulary };
52
51
  //# sourceMappingURL=data.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","names":[],"sources":["../../src/vocabulary/data.tsx"],"mappings":";;cAoRa"}
1
+ {"version":3,"file":"data.d.ts","names":[],"sources":["../../src/vocabulary/data.tsx"],"mappings":";;qBAmSa"}
@@ -1,3 +1,4 @@
1
+ import { toTextContent } from "./toTextContent.js";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { z } from "zod";
3
4
  //#region src/vocabulary/data.tsx
@@ -7,6 +8,8 @@ const cellSchema = z.union([
7
8
  z.number(),
8
9
  z.boolean()
9
10
  ]).describe("A cell value.");
11
+ const isTableColumn = (column) => column !== null && typeof column === "object" && "label" in column && typeof column.label === "string";
12
+ const isTableCell = (cell) => typeof cell === "string" || typeof cell === "number" || typeof cell === "boolean";
10
13
  const CHART_HEIGHT = 40;
11
14
  const CHART_WIDTH = 100;
12
15
  const clampValue = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
@@ -178,17 +181,22 @@ const dataVocabulary = {
178
181
  columns: z.array(columnSchema).optional().describe("Column definitions."),
179
182
  rows: z.array(z.array(cellSchema)).optional().describe("Rows of cells.")
180
183
  }),
181
- render: ({ columns, rows, children }) => /* @__PURE__ */ jsxs("table", {
182
- "data-aui": "table",
183
- children: [
184
- columns?.length ? /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((c, i) => /* @__PURE__ */ jsx("th", {
185
- "data-aui": "table-col",
186
- children: c.label
187
- }, i)) }) }) : null,
188
- 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,
189
- children
190
- ]
191
- })
184
+ render: ({ columns, rows, children }) => {
185
+ const safeColumns = Array.isArray(columns) ? columns : [];
186
+ const hasColumns = safeColumns.some(isTableColumn);
187
+ const safeRows = Array.isArray(rows) ? rows.filter(Array.isArray) : [];
188
+ return /* @__PURE__ */ jsxs("table", {
189
+ "data-aui": "table",
190
+ children: [
191
+ hasColumns ? /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: safeColumns.map((column, i) => /* @__PURE__ */ jsx("th", {
192
+ "data-aui": "table-col",
193
+ children: isTableColumn(column) ? column.label : ""
194
+ }, i)) }) }) : null,
195
+ safeRows.length ? /* @__PURE__ */ jsx("tbody", { children: safeRows.map((row, r) => /* @__PURE__ */ jsx("tr", { children: row.map((cell, c) => /* @__PURE__ */ jsx("td", { children: isTableCell(cell) ? String(cell) : "" }, c)) }, r)) }) : null,
196
+ children
197
+ ]
198
+ });
199
+ }
192
200
  },
193
201
  Markdown: {
194
202
  description: "A markdown string. Rendered as-is by default; override this component for a full markdown renderer.",
@@ -196,7 +204,7 @@ const dataVocabulary = {
196
204
  streamProperties: true,
197
205
  render: ({ value, children }) => /* @__PURE__ */ jsxs("div", {
198
206
  "data-aui": "markdown",
199
- children: [value, children]
207
+ children: [toTextContent(value), children]
200
208
  })
201
209
  },
202
210
  Chart: {
@@ -1 +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\nconst CHART_HEIGHT = 40;\nconst CHART_WIDTH = 100;\n\nconst clampValue = (value: unknown): number =>\n typeof value === \"number\" && Number.isFinite(value) ? Math.max(0, value) : 0;\n\nconst yFor = (value: number, max: number): number =>\n max > 0 ? CHART_HEIGHT - (value / max) * CHART_HEIGHT : CHART_HEIGHT;\n\nconst pointSchema = z.object({\n label: z.string().optional().describe(\"Point label.\"),\n value: z.number().describe(\"Point value.\"),\n});\n\nconst seriesSchema = z.object({\n label: z.string().optional().describe(\"Series label, shown in the legend.\"),\n data: z.array(pointSchema).describe(\"Data points for this series.\"),\n});\n\ntype ChartPoint = { label?: string; value: number };\ntype ChartSeriesInput = { label?: string; data: ChartPoint[] };\ntype NormalizedChartSeries = {\n label: string | undefined;\n values: number[];\n labels: (string | undefined)[];\n};\n\n/** Pads every series to the longest series' length, treating a shorter series' missing points as `{ value: 0 }` so mismatched series never misalign or throw. */\nfunction normalizeSeries(\n seriesProp: unknown,\n dataProp: unknown,\n): { count: number; series: NormalizedChartSeries[] } {\n const rawSeries: ChartSeriesInput[] =\n Array.isArray(seriesProp) && seriesProp.length > 0\n ? (seriesProp as ChartSeriesInput[])\n : [{ data: Array.isArray(dataProp) ? (dataProp as ChartPoint[]) : [] }];\n\n const count = rawSeries.reduce((max, s) => {\n const len = Array.isArray(s?.data) ? s.data.length : 0;\n return Math.max(max, len);\n }, 0);\n\n const series = rawSeries.map((s) => {\n const points = Array.isArray(s?.data) ? s.data : [];\n const values: number[] = [];\n const labels: (string | undefined)[] = [];\n for (let i = 0; i < count; i++) {\n const point = points[i];\n values.push(clampValue(point?.value));\n labels.push(typeof point?.label === \"string\" ? point.label : undefined);\n }\n return {\n label: typeof s?.label === \"string\" ? s.label : undefined,\n values,\n labels,\n };\n });\n\n return { count, series };\n}\n\nfunction computeMax(\n series: NormalizedChartSeries[],\n count: number,\n stacked: boolean,\n): number {\n if (stacked) {\n let max = 0;\n for (let i = 0; i < count; i++) {\n let sum = 0;\n for (const s of series) sum += s.values[i] ?? 0;\n max = Math.max(max, sum);\n }\n return max;\n }\n let max = 0;\n for (const s of series) for (const v of s.values) max = Math.max(max, v);\n return max;\n}\n\nconst NICE_MULTIPLES = [1, 2, 5];\n\n/** The smallest of `{1, 2, 5} × 10^n` that is `>= max`, so axis ticks land on round numbers. */\nfunction niceMax(max: number): number {\n if (max <= 0) return 0;\n const exponent = Math.floor(Math.log10(max));\n for (const multiple of NICE_MULTIPLES) {\n const candidate = multiple * 10 ** exponent;\n if (candidate >= max) return candidate;\n }\n return 10 ** (exponent + 1);\n}\n\nconst TICK_COUNT = 5;\n\n/** `TICK_COUNT` evenly spaced ticks from `max` down to `0`, for a top-to-bottom y-axis column. */\nfunction tickValues(max: number): number[] {\n const ticks: number[] = [];\n for (let i = 0; i < TICK_COUNT; i++) {\n ticks.push((max * (TICK_COUNT - 1 - i)) / (TICK_COUNT - 1));\n }\n return ticks;\n}\n\nfunction formatTick(value: number): string {\n return (Math.round(value * 100) / 100).toLocaleString(\"en-US\");\n}\n\ntype ChartVariant = \"bar\" | \"line\" | \"sparkline\" | \"area\";\n\nconst SERIES_PALETTE_SIZE = 5;\n\nfunction renderSeriesMarks(\n variant: ChartVariant,\n series: NormalizedChartSeries[],\n count: number,\n scaleMax: number,\n stacked: boolean,\n) {\n if (variant === \"bar\") {\n const slot = count > 0 ? CHART_WIDTH / count : 0;\n const gap = slot * 0.2;\n const groupWidth = slot - gap;\n const seriesCount = series.length;\n const perSeriesWidth =\n stacked || seriesCount <= 1 ? groupWidth : groupWidth / seriesCount;\n const cumulative = new Array(count).fill(0) as number[];\n\n return series.map((s, seriesIndex) => {\n const marks = s.values.map((value, i) => {\n const height = scaleMax > 0 ? (value / scaleMax) * CHART_HEIGHT : 0;\n const belowHeight =\n stacked && scaleMax > 0\n ? ((cumulative[i] ?? 0) / scaleMax) * CHART_HEIGHT\n : 0;\n const x =\n stacked || seriesCount <= 1\n ? i * slot + gap / 2\n : i * slot + gap / 2 + seriesIndex * perSeriesWidth;\n return (\n <rect\n key={i}\n x={x}\n y={CHART_HEIGHT - belowHeight - height}\n width={perSeriesWidth}\n height={height}\n fill=\"currentColor\"\n />\n );\n });\n if (stacked) {\n for (let i = 0; i < count; i++) {\n cumulative[i] = (cumulative[i] ?? 0) + (s.values[i] ?? 0);\n }\n }\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n {marks}\n </g>\n );\n });\n }\n\n if (variant === \"area\") {\n const cumulative = new Array(count).fill(0) as number[];\n\n return series.map((s, seriesIndex) => {\n const bottoms = stacked\n ? cumulative.slice()\n : (new Array(count).fill(0) as number[]);\n if (stacked) {\n for (let i = 0; i < count; i++) {\n cumulative[i] = (cumulative[i] ?? 0) + (s.values[i] ?? 0);\n }\n }\n const tops = stacked ? cumulative.slice() : s.values.slice();\n\n if (count === 1) {\n const y = yFor(tops[0] ?? 0, scaleMax);\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n <circle cx={CHART_WIDTH / 2} cy={y} r={2} fill=\"currentColor\" />\n </g>\n );\n }\n if (count === 0) {\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n />\n );\n }\n\n const topPoints = tops.map(\n (v, i) => `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n );\n const bottomPoints = bottoms\n .map(\n (v, i) => `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n )\n .reverse();\n\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n <polygon\n points={[...topPoints, ...bottomPoints].join(\" \")}\n fill=\"currentColor\"\n fillOpacity=\"0.25\"\n />\n <polyline\n points={topPoints.join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n vectorEffect=\"non-scaling-stroke\"\n />\n </g>\n );\n });\n }\n\n // line / sparkline: each series is always drawn independently. Stacking a line has no single standard meaning, so `stacked` is ignored (the caller never passes it for these variants).\n return series.map((s, seriesIndex) => (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n {count === 1 ? (\n <circle\n cx={CHART_WIDTH / 2}\n cy={yFor(s.values[0] ?? 0, scaleMax)}\n r={2}\n fill=\"currentColor\"\n />\n ) : count > 1 ? (\n <polyline\n points={s.values\n .map(\n (v, i) =>\n `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n )\n .join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ) : null}\n </g>\n ));\n}\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. `variant` selects bar, line, sparkline, or area rendering. Provide `data` for a single series, or `series` for multiple named series (`series` takes precedence over `data` when both are present). Set `stacked` to accumulate series values instead of overlaying them, and `showAxis`/`showLegend` to add y-axis ticks, x-axis point labels, and a legend.\",\n properties: z.object({\n variant: z\n .enum([\"bar\", \"line\", \"sparkline\", \"area\"])\n .describe(\"Chart variant.\"),\n data: z\n .array(pointSchema)\n .optional()\n .describe(\"Data points for a single series.\"),\n series: z\n .array(seriesSchema)\n .optional()\n .describe(\n \"Multiple named series; takes precedence over `data` when present.\",\n ),\n stacked: z\n .boolean()\n .optional()\n .describe(\n \"Accumulate series values instead of overlaying them (bar and area variants; ignored for line and sparkline).\",\n ),\n showAxis: z\n .boolean()\n .optional()\n .describe(\"Show y-axis ticks and x-axis point labels.\"),\n showLegend: z\n .boolean()\n .optional()\n .describe(\"Show a legend mapping each series to its color.\"),\n color: z\n .string()\n .optional()\n .describe(\n \"Series color (single-series mode only). One of `emphasis`, `secondary`, `alpha-70`, `white`, `white-70`, or `white-50`, matching Text's `color` tokens; other values have no visual effect.\",\n ),\n }),\n render: ({\n variant,\n data,\n series,\n stacked,\n showAxis,\n showLegend,\n color,\n }) => {\n const usesExtendedFeatures =\n variant === \"area\" ||\n !!stacked ||\n !!showAxis ||\n !!showLegend ||\n (Array.isArray(series) && series.length > 0);\n\n if (!usesExtendedFeatures) {\n const points = Array.isArray(data) ? data : [];\n const n = points.length;\n const values = points.map((d) => clampValue(d?.value));\n const max = values.reduce((m, v) => Math.max(m, v), 0);\n const slot = n > 0 ? CHART_WIDTH / n : 0;\n const gap = slot * 0.2;\n const barWidth = slot - gap;\n\n return (\n <svg\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n role=\"img\"\n aria-label={`${variant} chart with ${n} data points`}\n viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}\n preserveAspectRatio=\"none\"\n >\n {variant === \"bar\" ? (\n values.map((v, i) => {\n const height = max > 0 ? (v / max) * CHART_HEIGHT : 0;\n return (\n <rect\n key={i}\n x={i * slot + gap / 2}\n y={CHART_HEIGHT - height}\n width={barWidth}\n height={height}\n fill=\"currentColor\"\n />\n );\n })\n ) : n === 1 ? (\n <circle\n cx={CHART_WIDTH / 2}\n cy={yFor(values[0] ?? 0, max)}\n r={2}\n fill=\"currentColor\"\n />\n ) : n > 1 ? (\n <polyline\n points={values\n .map(\n (v, i) => `${(i / (n - 1)) * CHART_WIDTH},${yFor(v, max)}`,\n )\n .join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n />\n ) : null}\n </svg>\n );\n }\n\n const { count, series: normalized } = normalizeSeries(series, data);\n const stackedScale =\n !!stacked && (variant === \"bar\" || variant === \"area\");\n const rawMax = computeMax(normalized, count, stackedScale);\n const scaleMax = showAxis ? niceMax(rawMax) : rawMax;\n const marks = renderSeriesMarks(\n variant,\n normalized,\n count,\n scaleMax,\n stackedScale,\n );\n\n const svg = (\n <svg\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n role=\"img\"\n aria-label={`${variant} chart with ${count} data points`}\n viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}\n preserveAspectRatio=\"none\"\n >\n {marks}\n </svg>\n );\n\n if (!showAxis && !showLegend) return svg;\n\n return (\n <div data-aui=\"chart-frame\">\n {showAxis ? (\n <div data-aui=\"chart-ticks\">\n {tickValues(scaleMax).map((tick, i) => (\n <div key={i}>{formatTick(tick)}</div>\n ))}\n </div>\n ) : null}\n {svg}\n {showAxis ? (\n <div data-aui=\"chart-xlabels\">\n {(normalized[0]?.labels ?? []).map((label, i) => (\n <div key={i}>{label ?? \"\"}</div>\n ))}\n </div>\n ) : null}\n {showLegend ? (\n <div data-aui=\"chart-legend\">\n {normalized.map((s, i) => (\n <span\n key={i}\n data-aui=\"chart-legend-item\"\n data-aui-series={i % SERIES_PALETTE_SIZE}\n >\n <span data-aui=\"chart-legend-swatch\" />\n {s.label ?? `Series ${i + 1}`}\n </span>\n ))}\n </div>\n ) : null}\n </div>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;AAGA,MAAM,eAAe,EAAE,OAAO,EA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GAArB,CAAqB,CAChC;KACE,CAAA,IACH;KACH,aACC,oBAAC,OAAD;MAAK,YAAS;MACX,UAAA,WAAW,KAAK,GAAG,MAClB,qBAAC,QAAD;OAEE,YAAS;OACT,mBAAiB,IAAI;OAHvB,UAAA,CAKE,oBAAC,QAAD,EAAM,YAAS,sBAAuB,CAAA,GACrC,EAAE,SAAS,UAAU,IAAI,GACtB;MANC,GAAA,CAMD,CACP;KACE,CAAA,IACH;IACD;;EAET;CACF;AACF"}
1
+ {"version":3,"file":"data.js","names":[],"sources":["../../src/vocabulary/data.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { toTextContent } from \"./toTextContent\";\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\ntype TableColumn = { label: string };\ntype TableCell = string | number | boolean;\n\nconst isTableColumn = (column: unknown): column is TableColumn =>\n column !== null &&\n typeof column === \"object\" &&\n \"label\" in column &&\n typeof column.label === \"string\";\n\nconst isTableCell = (cell: unknown): cell is TableCell =>\n typeof cell === \"string\" ||\n typeof cell === \"number\" ||\n typeof cell === \"boolean\";\n\nconst CHART_HEIGHT = 40;\nconst CHART_WIDTH = 100;\n\nconst clampValue = (value: unknown): number =>\n typeof value === \"number\" && Number.isFinite(value) ? Math.max(0, value) : 0;\n\nconst yFor = (value: number, max: number): number =>\n max > 0 ? CHART_HEIGHT - (value / max) * CHART_HEIGHT : CHART_HEIGHT;\n\nconst pointSchema = z.object({\n label: z.string().optional().describe(\"Point label.\"),\n value: z.number().describe(\"Point value.\"),\n});\n\nconst seriesSchema = z.object({\n label: z.string().optional().describe(\"Series label, shown in the legend.\"),\n data: z.array(pointSchema).describe(\"Data points for this series.\"),\n});\n\ntype ChartPoint = { label?: string; value: number };\ntype ChartSeriesInput = { label?: string; data: ChartPoint[] };\ntype NormalizedChartSeries = {\n label: string | undefined;\n values: number[];\n labels: (string | undefined)[];\n};\n\n/** Pads every series to the longest series' length, treating a shorter series' missing points as `{ value: 0 }` so mismatched series never misalign or throw. */\nfunction normalizeSeries(\n seriesProp: unknown,\n dataProp: unknown,\n): { count: number; series: NormalizedChartSeries[] } {\n const rawSeries: ChartSeriesInput[] =\n Array.isArray(seriesProp) && seriesProp.length > 0\n ? (seriesProp as ChartSeriesInput[])\n : [{ data: Array.isArray(dataProp) ? (dataProp as ChartPoint[]) : [] }];\n\n const count = rawSeries.reduce((max, s) => {\n const len = Array.isArray(s?.data) ? s.data.length : 0;\n return Math.max(max, len);\n }, 0);\n\n const series = rawSeries.map((s) => {\n const points = Array.isArray(s?.data) ? s.data : [];\n const values: number[] = [];\n const labels: (string | undefined)[] = [];\n for (let i = 0; i < count; i++) {\n const point = points[i];\n values.push(clampValue(point?.value));\n labels.push(typeof point?.label === \"string\" ? point.label : undefined);\n }\n return {\n label: typeof s?.label === \"string\" ? s.label : undefined,\n values,\n labels,\n };\n });\n\n return { count, series };\n}\n\nfunction computeMax(\n series: NormalizedChartSeries[],\n count: number,\n stacked: boolean,\n): number {\n if (stacked) {\n let max = 0;\n for (let i = 0; i < count; i++) {\n let sum = 0;\n for (const s of series) sum += s.values[i] ?? 0;\n max = Math.max(max, sum);\n }\n return max;\n }\n let max = 0;\n for (const s of series) for (const v of s.values) max = Math.max(max, v);\n return max;\n}\n\nconst NICE_MULTIPLES = [1, 2, 5];\n\n/** The smallest of `{1, 2, 5} × 10^n` that is `>= max`, so axis ticks land on round numbers. */\nfunction niceMax(max: number): number {\n if (max <= 0) return 0;\n const exponent = Math.floor(Math.log10(max));\n for (const multiple of NICE_MULTIPLES) {\n const candidate = multiple * 10 ** exponent;\n if (candidate >= max) return candidate;\n }\n return 10 ** (exponent + 1);\n}\n\nconst TICK_COUNT = 5;\n\n/** `TICK_COUNT` evenly spaced ticks from `max` down to `0`, for a top-to-bottom y-axis column. */\nfunction tickValues(max: number): number[] {\n const ticks: number[] = [];\n for (let i = 0; i < TICK_COUNT; i++) {\n ticks.push((max * (TICK_COUNT - 1 - i)) / (TICK_COUNT - 1));\n }\n return ticks;\n}\n\nfunction formatTick(value: number): string {\n return (Math.round(value * 100) / 100).toLocaleString(\"en-US\");\n}\n\ntype ChartVariant = \"bar\" | \"line\" | \"sparkline\" | \"area\";\n\nconst SERIES_PALETTE_SIZE = 5;\n\nfunction renderSeriesMarks(\n variant: ChartVariant,\n series: NormalizedChartSeries[],\n count: number,\n scaleMax: number,\n stacked: boolean,\n) {\n if (variant === \"bar\") {\n const slot = count > 0 ? CHART_WIDTH / count : 0;\n const gap = slot * 0.2;\n const groupWidth = slot - gap;\n const seriesCount = series.length;\n const perSeriesWidth =\n stacked || seriesCount <= 1 ? groupWidth : groupWidth / seriesCount;\n const cumulative = new Array(count).fill(0) as number[];\n\n return series.map((s, seriesIndex) => {\n const marks = s.values.map((value, i) => {\n const height = scaleMax > 0 ? (value / scaleMax) * CHART_HEIGHT : 0;\n const belowHeight =\n stacked && scaleMax > 0\n ? ((cumulative[i] ?? 0) / scaleMax) * CHART_HEIGHT\n : 0;\n const x =\n stacked || seriesCount <= 1\n ? i * slot + gap / 2\n : i * slot + gap / 2 + seriesIndex * perSeriesWidth;\n return (\n <rect\n key={i}\n x={x}\n y={CHART_HEIGHT - belowHeight - height}\n width={perSeriesWidth}\n height={height}\n fill=\"currentColor\"\n />\n );\n });\n if (stacked) {\n for (let i = 0; i < count; i++) {\n cumulative[i] = (cumulative[i] ?? 0) + (s.values[i] ?? 0);\n }\n }\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n {marks}\n </g>\n );\n });\n }\n\n if (variant === \"area\") {\n const cumulative = new Array(count).fill(0) as number[];\n\n return series.map((s, seriesIndex) => {\n const bottoms = stacked\n ? cumulative.slice()\n : (new Array(count).fill(0) as number[]);\n if (stacked) {\n for (let i = 0; i < count; i++) {\n cumulative[i] = (cumulative[i] ?? 0) + (s.values[i] ?? 0);\n }\n }\n const tops = stacked ? cumulative.slice() : s.values.slice();\n\n if (count === 1) {\n const y = yFor(tops[0] ?? 0, scaleMax);\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n <circle cx={CHART_WIDTH / 2} cy={y} r={2} fill=\"currentColor\" />\n </g>\n );\n }\n if (count === 0) {\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n />\n );\n }\n\n const topPoints = tops.map(\n (v, i) => `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n );\n const bottomPoints = bottoms\n .map(\n (v, i) => `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n )\n .reverse();\n\n return (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n <polygon\n points={[...topPoints, ...bottomPoints].join(\" \")}\n fill=\"currentColor\"\n fillOpacity=\"0.25\"\n />\n <polyline\n points={topPoints.join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n vectorEffect=\"non-scaling-stroke\"\n />\n </g>\n );\n });\n }\n\n // line / sparkline: each series is always drawn independently. Stacking a line has no single standard meaning, so `stacked` is ignored (the caller never passes it for these variants).\n return series.map((s, seriesIndex) => (\n <g\n key={seriesIndex}\n data-aui=\"chart-series\"\n data-aui-series={seriesIndex % SERIES_PALETTE_SIZE}\n >\n {count === 1 ? (\n <circle\n cx={CHART_WIDTH / 2}\n cy={yFor(s.values[0] ?? 0, scaleMax)}\n r={2}\n fill=\"currentColor\"\n />\n ) : count > 1 ? (\n <polyline\n points={s.values\n .map(\n (v, i) =>\n `${(i / (count - 1)) * CHART_WIDTH},${yFor(v, scaleMax)}`,\n )\n .join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ) : null}\n </g>\n ));\n}\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 const safeColumns = Array.isArray(columns) ? columns : [];\n const hasColumns = safeColumns.some(isTableColumn);\n const safeRows = Array.isArray(rows) ? rows.filter(Array.isArray) : [];\n\n return (\n <table data-aui=\"table\">\n {hasColumns ? (\n <thead>\n <tr>\n {safeColumns.map((column, i) => (\n <th key={i} data-aui=\"table-col\">\n {isTableColumn(column) ? column.label : \"\"}\n </th>\n ))}\n </tr>\n </thead>\n ) : null}\n {safeRows.length ? (\n <tbody>\n {safeRows.map((row, r) => (\n <tr key={r}>\n {row.map((cell, c) => (\n <td key={c}>{isTableCell(cell) ? String(cell) : \"\"}</td>\n ))}\n </tr>\n ))}\n </tbody>\n ) : null}\n {children}\n </table>\n );\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 {toTextContent(value)}\n {children}\n </div>\n ),\n },\n Chart: {\n description:\n \"A chart. `variant` selects bar, line, sparkline, or area rendering. Provide `data` for a single series, or `series` for multiple named series (`series` takes precedence over `data` when both are present). Set `stacked` to accumulate series values instead of overlaying them, and `showAxis`/`showLegend` to add y-axis ticks, x-axis point labels, and a legend.\",\n properties: z.object({\n variant: z\n .enum([\"bar\", \"line\", \"sparkline\", \"area\"])\n .describe(\"Chart variant.\"),\n data: z\n .array(pointSchema)\n .optional()\n .describe(\"Data points for a single series.\"),\n series: z\n .array(seriesSchema)\n .optional()\n .describe(\n \"Multiple named series; takes precedence over `data` when present.\",\n ),\n stacked: z\n .boolean()\n .optional()\n .describe(\n \"Accumulate series values instead of overlaying them (bar and area variants; ignored for line and sparkline).\",\n ),\n showAxis: z\n .boolean()\n .optional()\n .describe(\"Show y-axis ticks and x-axis point labels.\"),\n showLegend: z\n .boolean()\n .optional()\n .describe(\"Show a legend mapping each series to its color.\"),\n color: z\n .string()\n .optional()\n .describe(\n \"Series color (single-series mode only). One of `emphasis`, `secondary`, `alpha-70`, `white`, `white-70`, or `white-50`, matching Text's `color` tokens; other values have no visual effect.\",\n ),\n }),\n render: ({\n variant,\n data,\n series,\n stacked,\n showAxis,\n showLegend,\n color,\n }) => {\n const usesExtendedFeatures =\n variant === \"area\" ||\n !!stacked ||\n !!showAxis ||\n !!showLegend ||\n (Array.isArray(series) && series.length > 0);\n\n if (!usesExtendedFeatures) {\n const points = Array.isArray(data) ? data : [];\n const n = points.length;\n const values = points.map((d) => clampValue(d?.value));\n const max = values.reduce((m, v) => Math.max(m, v), 0);\n const slot = n > 0 ? CHART_WIDTH / n : 0;\n const gap = slot * 0.2;\n const barWidth = slot - gap;\n\n return (\n <svg\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n role=\"img\"\n aria-label={`${variant} chart with ${n} data points`}\n viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}\n preserveAspectRatio=\"none\"\n >\n {variant === \"bar\" ? (\n values.map((v, i) => {\n const height = max > 0 ? (v / max) * CHART_HEIGHT : 0;\n return (\n <rect\n key={i}\n x={i * slot + gap / 2}\n y={CHART_HEIGHT - height}\n width={barWidth}\n height={height}\n fill=\"currentColor\"\n />\n );\n })\n ) : n === 1 ? (\n <circle\n cx={CHART_WIDTH / 2}\n cy={yFor(values[0] ?? 0, max)}\n r={2}\n fill=\"currentColor\"\n />\n ) : n > 1 ? (\n <polyline\n points={values\n .map(\n (v, i) => `${(i / (n - 1)) * CHART_WIDTH},${yFor(v, max)}`,\n )\n .join(\" \")}\n fill=\"none\"\n stroke=\"currentColor\"\n />\n ) : null}\n </svg>\n );\n }\n\n const { count, series: normalized } = normalizeSeries(series, data);\n const stackedScale =\n !!stacked && (variant === \"bar\" || variant === \"area\");\n const rawMax = computeMax(normalized, count, stackedScale);\n const scaleMax = showAxis ? niceMax(rawMax) : rawMax;\n const marks = renderSeriesMarks(\n variant,\n normalized,\n count,\n scaleMax,\n stackedScale,\n );\n\n const svg = (\n <svg\n data-aui=\"chart\"\n data-aui-variant={variant}\n data-aui-color={color}\n role=\"img\"\n aria-label={`${variant} chart with ${count} data points`}\n viewBox={`0 0 ${CHART_WIDTH} ${CHART_HEIGHT}`}\n preserveAspectRatio=\"none\"\n >\n {marks}\n </svg>\n );\n\n if (!showAxis && !showLegend) return svg;\n\n return (\n <div data-aui=\"chart-frame\">\n {showAxis ? (\n <div data-aui=\"chart-ticks\">\n {tickValues(scaleMax).map((tick, i) => (\n <div key={i}>{formatTick(tick)}</div>\n ))}\n </div>\n ) : null}\n {svg}\n {showAxis ? (\n <div data-aui=\"chart-xlabels\">\n {(normalized[0]?.labels ?? []).map((label, i) => (\n <div key={i}>{label ?? \"\"}</div>\n ))}\n </div>\n ) : null}\n {showLegend ? (\n <div data-aui=\"chart-legend\">\n {normalized.map((s, i) => (\n <span\n key={i}\n data-aui=\"chart-legend-item\"\n data-aui-series={i % SERIES_PALETTE_SIZE}\n >\n <span data-aui=\"chart-legend-swatch\" />\n {s.label ?? `Series ${i + 1}`}\n </span>\n ))}\n </div>\n ) : null}\n </div>\n );\n },\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;AAIA,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;AAK3B,MAAM,iBAAiB,WACrB,WAAW,QACX,OAAO,WAAW,YAClB,WAAW,UACX,OAAO,O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ACC,oBAAC,OAAD;MAAK,YAAS;MACV,WAAA,WAAW,EAAE,EAAE,UAAU,CAAC,EAAA,CAAG,KAAK,OAAO,MACzC,oBAAC,OAAD,EAAA,UAAc,SAAS,GAAQ,GAArB,CAAqB,CAChC;KACE,CAAA,IACH;KACH,aACC,oBAAC,OAAD;MAAK,YAAS;MACX,UAAA,WAAW,KAAK,GAAG,MAClB,qBAAC,QAAD;OAEE,YAAS;OACT,mBAAiB,IAAI;OAHvB,UAAA,CAKE,oBAAC,QAAD,EAAM,YAAS,sBAAuB,CAAA,GACrC,EAAE,SAAS,UAAU,IAAI,GACtB;MANC,GAAA,CAMD,CACP;KACE,CAAA,IACH;IACD;;EAET;CACF;AACF"}
@@ -1,11 +1,10 @@
1
1
  import { Action } from "../ir.js";
2
2
  import { GenerativeUIDispatch } from "../types.js";
3
3
  //#region src/vocabulary/dispatch.d.ts
4
- declare const actionAttr: (a: Action | undefined) => string | undefined;
4
+ export declare const actionAttr: (a: Action | undefined) => string | undefined;
5
5
  /**
6
6
  * Fires `$action` through `$dispatch` when both are present, merging a runtime value into the payload under the reserved `$input` key (not `value`) so the user's input never clobbers a model-supplied `value` field. No-op when no registry is wired. The returned promise from an async handler is caught and re-thrown on a microtask so rejections surface rather than going unhandled.
7
7
  */
8
- declare const fire: ($action: Action | undefined, $dispatch: GenerativeUIDispatch | undefined, input?: unknown) => void;
8
+ export declare const fire: ($action: Action | undefined, $dispatch: GenerativeUIDispatch | undefined, input?: unknown) => void;
9
9
  //#endregion
10
- export { actionAttr, fire };
11
10
  //# sourceMappingURL=dispatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","names":[],"sources":["../../src/vocabulary/dispatch.ts"],"mappings":";;;cAGa,aAAc,GAAG;;;;cAMjB,OACX,SAAS,oBACT,WAAW,kCACX"}
1
+ {"version":3,"file":"dispatch.d.ts","names":[],"sources":["../../src/vocabulary/dispatch.ts"],"mappings":";;;qBAGa,aAAc,GAAG;;;;qBAMjB,OACX,SAAS,oBACT,WAAW,kCACX"}
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  //#region src/vocabulary/fact.d.ts
3
- declare const factVocabulary: {
3
+ export declare const factVocabulary: {
4
4
  Fact: {
5
5
  description: string;
6
6
  properties: z.ZodObject<{
@@ -11,5 +11,4 @@ declare const factVocabulary: {
11
11
  };
12
12
  };
13
13
  //#endregion
14
- export { factVocabulary };
15
14
  //# sourceMappingURL=fact.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fact.d.ts","names":[],"sources":["../../src/vocabulary/fact.tsx"],"mappings":";;cAGa"}
1
+ {"version":3,"file":"fact.d.ts","names":[],"sources":["../../src/vocabulary/fact.tsx"],"mappings":";;qBAIa"}
@@ -1,3 +1,4 @@
1
+ import { toTextContent } from "./toTextContent.js";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { z } from "zod";
3
4
  //#region src/vocabulary/fact.tsx
@@ -11,10 +12,10 @@ const factVocabulary = { Fact: {
11
12
  "data-aui": "fact",
12
13
  children: [/* @__PURE__ */ jsx("dt", {
13
14
  "data-aui": "fact-label",
14
- children: label
15
+ children: toTextContent(label)
15
16
  }), /* @__PURE__ */ jsxs("dd", {
16
17
  "data-aui": "fact-value",
17
- children: [value, children]
18
+ children: [toTextContent(value), children]
18
19
  })]
19
20
  })
20
21
  } };
@@ -1 +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;EAAb,UAAA,CACE,oBAAC,MAAD;GAAI,YAAS;GAAc,UAAA;EAAU,CAAA,GACrC,qBAAC,MAAD;GAAI,YAAS;GAAb,UAAA,CACG,OACA,QACC;EACF,CAAA,CAAA;;AAER,EACF"}
1
+ {"version":3,"file":"fact.js","names":[],"sources":["../../src/vocabulary/fact.tsx"],"sourcesContent":["import { z } from \"zod\";\nimport type { GenerativeUILibrary } from \"../types\";\nimport { toTextContent } from \"./toTextContent\";\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\">{toTextContent(label)}</dt>\n <dd data-aui=\"fact-value\">\n {toTextContent(value)}\n {children}\n </dd>\n </dl>\n ),\n },\n} satisfies GenerativeUILibrary;\n"],"mappings":";;;;AAIA,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;EAAb,UAAA,CACE,oBAAC,MAAD;GAAI,YAAS;GAAc,UAAA,cAAc,KAAK;EAAM,CAAA,GACpD,qBAAC,MAAD;GAAI,YAAS;GAAb,UAAA,CACG,cAAc,KAAK,GACnB,QACC;EACF,CAAA,CAAA;;AAER,EACF"}
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  //#region src/vocabulary/form.d.ts
3
- declare const formVocabulary: {
3
+ export declare const formVocabulary: {
4
4
  Form: {
5
5
  description: string;
6
6
  properties: z.ZodObject<{
@@ -10,5 +10,4 @@ declare const formVocabulary: {
10
10
  };
11
11
  };
12
12
  //#endregion
13
- export { formVocabulary };
14
13
  //# sourceMappingURL=form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","names":[],"sources":["../../src/vocabulary/form.tsx"],"mappings":";;cAKa"}
1
+ {"version":3,"file":"form.d.ts","names":[],"sources":["../../src/vocabulary/form.tsx"],"mappings":";;qBAKa"}
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  //#region src/vocabulary/icon.d.ts
3
- declare const iconVocabulary: {
3
+ export declare const iconVocabulary: {
4
4
  Icon: {
5
5
  description: string;
6
6
  properties: z.ZodObject<{
@@ -40,5 +40,4 @@ declare const iconVocabulary: {
40
40
  };
41
41
  };
42
42
  //#endregion
43
- export { iconVocabulary };
44
43
  //# sourceMappingURL=icon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"icon.d.ts","names":[],"sources":["../../src/vocabulary/icon.tsx"],"mappings":";;cAyIa"}
1
+ {"version":3,"file":"icon.d.ts","names":[],"sources":["../../src/vocabulary/icon.tsx"],"mappings":";;qBAyIa"}
@@ -9,7 +9,6 @@ import { GenerativeUILibrary } from "../types.js";
9
9
  * `new JSONGenerativeUI({ library: defaultGenerativeUILibrary })`, and override
10
10
  * or extend entries with their own `defineGenerativeComponents`.
11
11
  */
12
- declare const defaultGenerativeUILibrary: GenerativeUILibrary;
12
+ export declare const defaultGenerativeUILibrary: GenerativeUILibrary;
13
13
  //#endregion
14
- export { defaultGenerativeUILibrary };
15
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vocabulary/index.ts"],"mappings":";;;;;;;;;;;cAqBa,4BAA4B"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/vocabulary/index.ts"],"mappings":";;;;;;;;;;;qBAqBa,4BAA4B"}
@@ -1,30 +1,32 @@
1
1
  import { Action } from "../ir.js";
2
- import { GenerativeUIDispatch } from "../types.js";
2
+ import { GenerativeUIDispatch, GenerativeUIStatus } from "../types.js";
3
3
  import { z } from "zod";
4
4
  //#region src/vocabulary/interactive.d.ts
5
+ type Option = {
6
+ label: string;
7
+ value: string;
8
+ };
5
9
  type RadioGroupRenderProps = {
6
- options: {
7
- label: string;
8
- value: string;
9
- }[];
10
+ options: Option[];
10
11
  name?: string;
11
12
  label?: string;
12
13
  defaultValue?: string;
14
+ $status: GenerativeUIStatus;
13
15
  $action?: Action;
14
16
  $dispatch?: GenerativeUIDispatch;
15
17
  };
16
18
  declare function RadioGroupRender({ options, name, label, defaultValue, $action, $dispatch }: RadioGroupRenderProps): import("react").JSX.Element;
17
- declare const interactiveVocabulary: {
19
+ export declare const interactiveVocabulary: {
18
20
  Button: {
19
21
  description: string;
20
22
  properties: z.ZodObject<{
21
23
  label: z.ZodString;
22
24
  buttonStyle: z.ZodOptional<z.ZodEnum<{
23
- secondary: "secondary";
25
+ danger: "danger";
24
26
  primary: "primary";
27
+ secondary: "secondary";
25
28
  outline: "outline";
26
29
  ghost: "ghost";
27
- danger: "danger";
28
30
  }>>;
29
31
  block: z.ZodOptional<z.ZodBoolean>;
30
32
  submit: z.ZodOptional<z.ZodBoolean>;
@@ -89,5 +91,4 @@ declare const interactiveVocabulary: {
89
91
  };
90
92
  };
91
93
  //#endregion
92
- export { interactiveVocabulary };
93
94
  //# sourceMappingURL=interactive.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactive.d.ts","names":[],"sources":["../../src/vocabulary/interactive.tsx"],"mappings":";;;;KAYK;EACH;IAAW;IAAe;;EAC1B;EACA;EACA;EACA,UAAU;EACV,YAAY;;iBAGL,mBACP,SACA,MACA,OACA,cACA,SACA,aACC,wCAAqB,IAAA;cA8BX"}
1
+ {"version":3,"file":"interactive.d.ts","names":[],"sources":["../../src/vocabulary/interactive.tsx"],"mappings":";;;;KAkBK;EAAW;EAAe;;KAU1B;EACH,SAAS;EACT;EACA;EACA;EACA,SAAS;EACT,UAAU;EACV,YAAY;;iBAGL,mBACP,SACA,MACA,OACA,cACA,SACA,aACC,wCAAqB,IAAA;qBA6BX"}