@copilotkit/react-core 2.0.0-rc.4 → 2.0.0-rc.40

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 (80) hide show
  1. package/README.md +1 -1
  2. package/dist/MarkdownRendererContext-BL8ct_3U.d.mts +34 -0
  3. package/dist/MarkdownRendererContext-BL8ct_3U.d.mts.map +1 -0
  4. package/dist/MarkdownRendererContext-C2J_lgqF.d.cts +34 -0
  5. package/dist/MarkdownRendererContext-C2J_lgqF.d.cts.map +1 -0
  6. package/dist/MarkdownSurfaces-Byz821bg.mjs +324 -0
  7. package/dist/MarkdownSurfaces-Byz821bg.mjs.map +1 -0
  8. package/dist/MarkdownSurfaces-D2Ck-cbb.cjs +378 -0
  9. package/dist/MarkdownSurfaces-D2Ck-cbb.cjs.map +1 -0
  10. package/dist/chat-Bf0vVdo7.mjs +1600 -0
  11. package/dist/chat-Bf0vVdo7.mjs.map +1 -0
  12. package/dist/chat-D3fxo6Ah.cjs +1784 -0
  13. package/dist/chat-D3fxo6Ah.cjs.map +1 -0
  14. package/dist/chat-DgP2N7bD.d.mts +233 -0
  15. package/dist/chat-DgP2N7bD.d.mts.map +1 -0
  16. package/dist/chat-DtHs4alO.d.cts +233 -0
  17. package/dist/chat-DtHs4alO.d.cts.map +1 -0
  18. package/dist/context.cjs +75 -63
  19. package/dist/context.cjs.map +1 -1
  20. package/dist/context.d.cts +62 -107
  21. package/dist/context.d.cts.map +1 -1
  22. package/dist/context.d.mts +62 -107
  23. package/dist/context.d.mts.map +1 -1
  24. package/dist/context.mjs +76 -64
  25. package/dist/context.mjs.map +1 -1
  26. package/dist/generative-ui/native.cjs +66 -0
  27. package/dist/generative-ui/native.cjs.map +1 -0
  28. package/dist/generative-ui/native.d.cts +155 -0
  29. package/dist/generative-ui/native.d.cts.map +1 -0
  30. package/dist/generative-ui/native.d.mts +155 -0
  31. package/dist/generative-ui/native.d.mts.map +1 -0
  32. package/dist/generative-ui/native.mjs +24 -0
  33. package/dist/generative-ui/native.mjs.map +1 -0
  34. package/dist/generative-ui.cjs +757 -3056
  35. package/dist/generative-ui.cjs.map +1 -1
  36. package/dist/generative-ui.d.cts +2470 -4788
  37. package/dist/generative-ui.d.cts.map +1 -1
  38. package/dist/generative-ui.d.mts +2470 -4788
  39. package/dist/generative-ui.d.mts.map +1 -1
  40. package/dist/generative-ui.mjs +327 -2636
  41. package/dist/generative-ui.mjs.map +1 -1
  42. package/dist/headless.cjs +289 -1054
  43. package/dist/headless.cjs.map +1 -1
  44. package/dist/headless.d.cts +145 -370
  45. package/dist/headless.d.cts.map +1 -1
  46. package/dist/headless.d.mts +119 -235
  47. package/dist/headless.d.mts.map +1 -1
  48. package/dist/headless.mjs +283 -1054
  49. package/dist/headless.mjs.map +1 -1
  50. package/dist/hooks-2Ur8NQhj.d.cts +84 -0
  51. package/dist/hooks-2Ur8NQhj.d.cts.map +1 -0
  52. package/dist/hooks-BRYonCVu.d.mts +84 -0
  53. package/dist/hooks-BRYonCVu.d.mts.map +1 -0
  54. package/dist/index.cjs +6960 -11012
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.cts +337 -831
  57. package/dist/index.d.cts.map +1 -1
  58. package/dist/index.d.mts +334 -828
  59. package/dist/index.d.mts.map +1 -1
  60. package/dist/index.mjs +1896 -7582
  61. package/dist/index.mjs.map +1 -1
  62. package/dist/index.umd.js +6319 -11463
  63. package/dist/index.umd.js.map +1 -1
  64. package/dist/refs-BIUfn1wb.cjs +43 -0
  65. package/dist/refs-BIUfn1wb.cjs.map +1 -0
  66. package/dist/refs-CMrRm3ta.mjs +31 -0
  67. package/dist/refs-CMrRm3ta.mjs.map +1 -0
  68. package/dist/use-generative-ui-root-C12htqbK.cjs +390 -0
  69. package/dist/use-generative-ui-root-C12htqbK.cjs.map +1 -0
  70. package/dist/use-generative-ui-root-CVgsDy1f.mjs +385 -0
  71. package/dist/use-generative-ui-root-CVgsDy1f.mjs.map +1 -0
  72. package/package.json +45 -23
  73. package/dist/MarkdownRendererContext-B4Us6mwL.d.cts +0 -954
  74. package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
  75. package/dist/MarkdownRendererContext-CRKFzsEB.d.mts +0 -954
  76. package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
  77. package/dist/MarkdownSurfaces-Bd--93O1.mjs +0 -3676
  78. package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
  79. package/dist/MarkdownSurfaces-S4wfUl3J.cjs +0 -3991
  80. package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
@@ -1,403 +1,17 @@
1
1
  "use client";
2
2
 
3
- import { A as GenerativeUIError, F as toJsonSchema, P as createGenerativeUI, _ as GenerativeUINodeContext, b as useRequiredGenerativeUIRuntime, c as SurfaceView, d as namedRole, f as useGenerativeUIAccessibility, g as useManagerVersion, h as useGenerativeUIState, j as isRecord, l as DARK_THEME_CSS, m as useGenerativeUIFunction, n as ProviderMarkdown, p as wrapperAria, r as DefaultGenerativeUIChatCard, t as MarkdownSurfaces, u as controlAria, y as useGenerativeUIRuntime } from "./MarkdownSurfaces-Bd--93O1.mjs";
3
+ import { c as IconSvg, n as ProviderMarkdown, t as MarkdownSurfaces } from "./MarkdownSurfaces-Byz821bg.mjs";
4
+ import { S as GenerativeUINodeContext, T as useRequiredGenerativeUIRuntime, b as useGenerativeUIState, c as namedRole, l as useGenerativeUIAccessibility, m as createGenerativeUI, o as SurfaceView, s as controlAria, t as DefaultGenerativeUIChatCard, u as wrapperAria, w as useGenerativeUIRuntime, x as useManagerVersion, y as useGenerativeUIFunction } from "./chat-Bf0vVdo7.mjs";
5
+ import { n as childList, t as child } from "./refs-CMrRm3ta.mjs";
4
6
  import React, { Suspense, createContext, isValidElement, memo, useCallback, useContext, useEffect, useId, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
5
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
- import { A2UI_CHILD_LIST_MARK, A2UI_CHILD_LIST_REF, A2UI_COMPONENT_ID_MARK, A2UI_COMPONENT_ID_REF, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_MAX_TARGET_COMPONENTS, childRefKind, functionCallers } from "@copilotkit/shared";
7
- import { z } from "zod";
8
+ import { allowedComponents, scrollToSurface } from "@copilotkit/core/generative-ui";
9
+ import { ACCENT, BACKDROP, CHART_CURSOR, CHART_PALETTE, FONT_WEIGHT, GenerativeUIError, INNER_PANEL_BG, ON_ACCENT, SHADOW_MD, SHADOW_SM, SHADOW_SOFT, SHADOW_XS, STANDARD_CATALOG_ID, STANDARD_CSS, STANDARD_STYLE_ID, backgroundColor, borderColor, checkMessageStyle, compositeDeclarations, dataDeclarations, exportA2UICatalog, feedbackDeclarations, firstFailedCheck, inputDeclarations, layoutDeclarations, mediaDeclarations, panelBackground, radius, spacing, textColor, textDeclarations, textFont, withComponents, withStandardParameterOrder } from "@copilotkit/shared/generative-ui";
8
10
  import { createPortal } from "react-dom";
9
11
 
10
- //#region src/generative-ui/refs.ts
11
- /**
12
- * Schema helpers that mark a prop as a component reference, the way A2UI
13
- * 1.0 marks it with the `ComponentId` and `ChildList` common types. The
14
- * engine finds every marked prop in the props schema, at any depth, renders
15
- * the referenced components, and hands the component the rendered nodes in
16
- * place of the ids. The model sees the prop as `componentId` or as a list
17
- * of ids or a template.
18
- *
19
- * @example
20
- * ```ts
21
- * const tabsSchema = z.object({
22
- * tabs: z.array(z.object({ title: z.string(), child: child() })),
23
- * });
24
- * // The component gets `tabs: { title: string; child: ReactNode }[]`.
25
- * ```
26
- */
27
- const toNode = (value) => value;
28
- const mark = (prefix, description) => description ? `${prefix} ${description}` : prefix;
29
- /**
30
- * One component id. The component receives the rendered child. Pass the
31
- * description here, not with `.describe()`, which would replace the mark.
32
- */
33
- function child(description) {
34
- return z.string().min(1).describe(mark(A2UI_COMPONENT_ID_MARK, description)).transform(toNode);
35
- }
36
- /**
37
- * A list of component ids, or a template `{ componentId, path }` that
38
- * repeats one component for each item of the list at `path`. The
39
- * component receives the rendered children. Pass the description here,
40
- * not with `.describe()`.
41
- */
42
- function childList(description) {
43
- return z.union([z.array(z.string().min(1)), z.object({
44
- componentId: z.string().min(1),
45
- path: z.string().min(1)
46
- })]).describe(mark(A2UI_CHILD_LIST_MARK, description)).transform(toNode);
47
- }
48
-
49
- //#endregion
50
- //#region src/generative-ui/catalog-export.ts
51
- const COMMON = "common_types.json#/$defs/";
52
- const DATA_BINDING_REF = `${COMMON}DataBinding`;
53
- const FUNCTION_CALL_REF = `${COMMON}FunctionCall`;
54
- const ACTION_REF = `${COMMON}Action`;
55
- const DYNAMIC_REFS = {
56
- string: `${COMMON}DynamicString`,
57
- number: `${COMMON}DynamicNumber`,
58
- boolean: `${COMMON}DynamicBoolean`,
59
- "string[]": `${COMMON}DynamicStringList`,
60
- unknown: `${COMMON}DynamicValue`
61
- };
62
- /**
63
- * The A2UI 1.0 catalog definition of a generative UI, as a JSON value that
64
- * follows `catalog_definition.json`: one `components` entry per component,
65
- * with `component` as a `const`, `functions` for the built-ins and the
66
- * declared functions, and `$defs.anyComponent` / `$defs.anyFunction`. Other
67
- * A2UI tools (a validator, another renderer, a prompt builder) read it.
68
- *
69
- * - A prop that `child()` or `childList()` marks is a `ComponentId` or a
70
- * `ChildList` reference; so is a slot. An event prop is an `Action`.
71
- * - Every other value, at any depth of a prop or of the args of a declared
72
- * function, takes its literal schema, a `DataBinding` or a `FunctionCall`,
73
- * because the renderer resolves dynamic values at any depth.
74
- * - Every function states `returnType` and `allowedCallers`: the built-ins
75
- * are `rendererOnly`, and so is a declared function without
76
- * `allowedCallers`, as in A2UI 1.0.
77
- *
78
- * @param ui - The generative UI to describe.
79
- * @param options - The title, description and instructions of the catalog.
80
- *
81
- * @example
82
- * ```ts
83
- * const catalog = exportA2UICatalog(shopUI, { title: "Acme shop" });
84
- * fs.writeFileSync("shop-catalog.json", JSON.stringify(catalog, null, 2));
85
- * ```
86
- */
87
- function exportA2UICatalog(ui, options = {}) {
88
- const components = Object.fromEntries(Object.entries(ui.manifestComponents).map(([name, manifest]) => [name, toDraft2020(rebaseRefs(componentDefinition(name, manifest), `#/components/${pointerSegment(name)}`))]));
89
- const functions = {};
90
- for (const [name, info] of Object.entries(GENERATIVE_UI_FUNCTIONS)) {
91
- if (ui.functions.has(name)) continue;
92
- functions[name] = functionEntry(name, info, {
93
- description: info.description,
94
- returnType: info.returnType,
95
- args: argsSchemaFromSignature(info.parameters)
96
- });
97
- }
98
- for (const [name, fn] of ui.functions) functions[name] = functionEntry(name, fn, {
99
- description: fn.description,
100
- returnType: fn.returnType ?? "any",
101
- args: toDraft2020(rebaseRefs(dynamicArgs(toJsonSchema(fn.parameters)), `#/functions/${pointerSegment(name)}/properties/args`))
102
- });
103
- const { title, description, instructions } = options;
104
- return {
105
- $schema: "https://json-schema.org/draft/2020-12/schema",
106
- protocolVersion: "1.0",
107
- catalogId: ui.id,
108
- ...title === void 0 ? {} : { title },
109
- ...description === void 0 ? {} : { description },
110
- ...instructions === void 0 ? {} : { instructions },
111
- components,
112
- functions,
113
- $defs: {
114
- anyComponent: {
115
- ...oneOfRefs("components", Object.keys(components)),
116
- discriminator: { propertyName: "component" }
117
- },
118
- anyFunction: oneOfRefs("functions", Object.keys(functions))
119
- }
120
- };
121
- }
122
- /**
123
- * `oneOf` over the entries of a section. JSON Schema wants at least one
124
- * variant, so an empty section (a UI with no components) matches nothing.
125
- */
126
- function oneOfRefs(section, names) {
127
- if (names.length === 0) return { not: {} };
128
- return { oneOf: names.map((name) => ({ $ref: `#/${section}/${pointerSegment(name)}` })) };
129
- }
130
- /** A name as a JSON Pointer segment in a URI fragment: `acme/Card` is `acme~1Card`. */
131
- function pointerSegment(name) {
132
- return encodeURIComponent(name.replace(/~/g, "~0").replace(/\//g, "~1"));
133
- }
134
- /** Keywords whose value is data, not a schema. */
135
- const LITERAL_KEYWORDS = new Set([
136
- "default",
137
- "const",
138
- "enum",
139
- "examples"
140
- ]);
141
- /**
142
- * A schema in the draft 2020-12 dialect that the catalog declares. The
143
- * converter writes draft-07, where a tuple is `items: [...]` with
144
- * `additionalItems`; 2020-12 spells that `prefixItems` and `items`.
145
- */
146
- function toDraft2020(schema) {
147
- return mapSchema$1(schema, (node) => {
148
- const { items, additionalItems, ...rest } = node;
149
- if (!Array.isArray(items)) return node;
150
- return {
151
- ...rest,
152
- prefixItems: items,
153
- ...additionalItems === void 0 ? {} : { items: additionalItems }
154
- };
155
- });
156
- }
157
- /** One `components` entry: the props as the model sets them, with the A2UI common types. */
158
- function componentDefinition(name, manifest) {
159
- const { properties, required, description, $defs, definitions } = manifest.props;
160
- const props = Object.fromEntries(Object.entries(isRecord(properties) ? properties : {}).map(([key, schema]) => [key, dynamicProp(schema)]));
161
- const events = Object.fromEntries(Object.entries(manifest.events ?? {}).map(([key, event]) => [key, {
162
- $ref: ACTION_REF,
163
- ...event.description ? { description: event.description } : {}
164
- }]));
165
- const slots = Object.fromEntries(Object.entries(manifest.slots ?? {}).map(([key, kind]) => [key, { $ref: kind === "single" ? A2UI_COMPONENT_ID_REF : A2UI_CHILD_LIST_REF }]));
166
- const fields = {
167
- ...props,
168
- ...events,
169
- ...slots
170
- };
171
- const orderedFields = manifest.parameterOrder === void 0 ? fields : Object.fromEntries([...new Set([...manifest.parameterOrder, ...Object.keys(fields)])].filter((key) => Object.hasOwn(fields, key)).map((key) => [key, fields[key]]));
172
- const text = manifest.description ?? description;
173
- return {
174
- type: "object",
175
- ...typeof text === "string" ? { description: text } : {},
176
- properties: {
177
- component: { const: name },
178
- ...orderedFields
179
- },
180
- required: ["component", ...Array.isArray(required) ? required.filter(isString) : []],
181
- ...withDynamicChildren({
182
- ...isRecord($defs) ? { $defs } : {},
183
- ...isRecord(definitions) ? { definitions } : {}
184
- })
185
- };
186
- }
187
- /**
188
- * The schema with its local references (`#/...`) pointing into the place
189
- * it is embedded at. A converter that writes `$defs` refers to them from
190
- * the root of its own document; inside the catalog, that root is `base`.
191
- */
192
- function rebaseRefs(schema, base) {
193
- return mapSchema$1(schema, (node) => {
194
- const ref = node.$ref;
195
- if (ref === "#") return {
196
- ...node,
197
- $ref: base
198
- };
199
- if (typeof ref === "string" && ref.startsWith("#/")) return {
200
- ...node,
201
- $ref: `${base}${ref.slice(1)}`
202
- };
203
- return node;
204
- });
205
- }
206
- /** Keywords whose value is a map from a name to a schema. */
207
- const SCHEMA_MAP_KEYWORDS = new Set([
208
- "properties",
209
- "patternProperties",
210
- "$defs",
211
- "definitions",
212
- "dependentSchemas"
213
- ]);
214
- /**
215
- * Walks a JSON Schema and rebuilds each schema node with `transform`, the
216
- * children first. The names in `properties` and the definition maps are
217
- * names, not keywords: a prop called `default` is a schema, while the
218
- * `default` of a schema is data and stays as it is.
219
- */
220
- function mapSchema$1(schema, transform) {
221
- const visitValue = (value) => {
222
- if (Array.isArray(value)) return value.map(visitValue);
223
- return isRecord(value) ? visitNode(value) : value;
224
- };
225
- const visitNode = (node) => {
226
- const result = {};
227
- for (const [key, value] of Object.entries(node)) if (LITERAL_KEYWORDS.has(key)) result[key] = value;
228
- else if (SCHEMA_MAP_KEYWORDS.has(key) && isRecord(value)) result[key] = Object.fromEntries(Object.entries(value).map(([name, entry]) => [name, isRecord(entry) ? visitNode(entry) : entry]));
229
- else result[key] = visitValue(value);
230
- return transform(result);
231
- };
232
- return visitNode(schema);
233
- }
234
- const isString = (value) => typeof value === "string";
235
- /**
236
- * A prop as the catalog states it. A component reference stays one. Any
237
- * other value takes its literal schema, a data binding or a function call,
238
- * and so does every value inside it: the properties of an object, the
239
- * values of a record and the items of a list, because the renderer
240
- * resolves dynamic values at any depth. The variants of a union are
241
- * transformed in place.
242
- */
243
- function dynamicProp(schema) {
244
- if (!isRecord(schema)) return { $ref: DYNAMIC_REFS.unknown };
245
- if (childRefKind(schema)) return schema;
246
- const { description, ...literal } = withDynamicChildren(schema);
247
- return {
248
- ...typeof description === "string" ? { description } : {},
249
- anyOf: [
250
- literal,
251
- { $ref: DATA_BINDING_REF },
252
- { $ref: FUNCTION_CALL_REF }
253
- ]
254
- };
255
- }
256
- /** The schema with its nested values made dynamic, itself unchanged. */
257
- function withDynamicChildren(schema) {
258
- const result = { ...schema };
259
- if (isRecord(schema.properties)) result.properties = Object.fromEntries(Object.entries(schema.properties).map(([key, value]) => [key, dynamicProp(value)]));
260
- if (isRecord(schema.items)) result.items = dynamicProp(schema.items);
261
- if (Array.isArray(schema.items)) result.items = schema.items.map((item) => isRecord(item) ? dynamicProp(item) : item);
262
- if (isRecord(schema.additionalItems)) result.additionalItems = dynamicProp(schema.additionalItems);
263
- for (const key of ["$defs", "definitions"]) {
264
- const defs = schema[key];
265
- if (isRecord(defs)) result[key] = Object.fromEntries(Object.entries(defs).map(([name, def]) => [name, isRecord(def) ? withDynamicChildren(def) : def]));
266
- }
267
- if (Array.isArray(schema.allOf)) result.allOf = schema.allOf.map((part) => isRecord(part) ? withDynamicChildren(part) : part);
268
- if (isRecord(schema.additionalProperties)) result.additionalProperties = dynamicProp(schema.additionalProperties);
269
- if (isRecord(schema.patternProperties)) result.patternProperties = Object.fromEntries(Object.entries(schema.patternProperties).map(([pattern, value]) => [pattern, dynamicProp(value)]));
270
- for (const key of ["anyOf", "oneOf"]) {
271
- const variants = schema[key];
272
- if (Array.isArray(variants)) result[key] = variants.map((variant) => isRecord(variant) && !childRefKind(variant) ? withDynamicChildren(variant) : variant);
273
- }
274
- return result;
275
- }
276
- /**
277
- * The args of a declared function as the catalog states them: the object
278
- * stays an object, each arg takes a value, a binding or a function call.
279
- */
280
- function dynamicArgs(schema) {
281
- return withDynamicChildren(schema);
282
- }
283
- /** One `functions` entry, in the A2UI `FunctionDefinition` shape. */
284
- function functionEntry(name, permissions, parts) {
285
- const callers = functionCallers(permissions);
286
- const allowedCallers = callers.renderer && callers.agent ? "rendererOrAgent" : callers.agent ? "agentOnly" : "rendererOnly";
287
- const argsRequired = hasRequiredArgs(parts.args);
288
- return {
289
- type: "object",
290
- ...parts.description ? { description: parts.description } : {},
291
- returnType: parts.returnType,
292
- allowedCallers,
293
- requiresUserActivation: permissions.requiresUserActivation === true,
294
- properties: {
295
- "@call": { const: name },
296
- args: parts.args
297
- },
298
- required: argsRequired ? ["@call", "args"] : ["@call"]
299
- };
300
- }
301
- /**
302
- * True when an empty args object fails the schema: a key is required at
303
- * its top, in an `allOf` part, or in every variant of an `anyOf` / `oneOf`.
304
- */
305
- function hasRequiredArgs(schema) {
306
- if (!isRecord(schema)) return false;
307
- if (Array.isArray(schema.required) && schema.required.length > 0) return true;
308
- if (Array.isArray(schema.allOf) && schema.allOf.some(hasRequiredArgs)) return true;
309
- for (const key of ["anyOf", "oneOf"]) {
310
- const variants = schema[key];
311
- if (Array.isArray(variants) && variants.length > 0) {
312
- if (variants.every(hasRequiredArgs)) return true;
313
- }
314
- }
315
- return false;
316
- }
317
- /**
318
- * The JSON Schema of the args of a built-in function, from its short
319
- * TypeScript-like signature (`{ value: number; decimals?: number }`). Each
320
- * arg takes a literal, a binding or a function call, so a type maps to the
321
- * A2UI dynamic type; `[name: string]: T` becomes `additionalProperties`.
322
- *
323
- * @example
324
- * ```ts
325
- * argsSchemaFromSignature("{ value: string; min?: number }");
326
- * // { type: "object", properties: { value: { $ref: ".../DynamicString" }, min: { $ref: ".../DynamicNumber" } }, required: ["value"], additionalProperties: false }
327
- * ```
328
- */
329
- function argsSchemaFromSignature(signature) {
330
- const body = signature.trim().replace(/^\{/, "").replace(/\}$/, "");
331
- const properties = {};
332
- const required = [];
333
- let additionalProperties = false;
334
- for (const part of body.split(";")) {
335
- const field = part.trim();
336
- if (field === "") continue;
337
- const index = field.match(/^\[\w+: string\]:\s*(.+)$/);
338
- if (index) {
339
- additionalProperties = typeSchema(index[1]);
340
- continue;
341
- }
342
- const named = field.match(/^(\w+)(\?)?:\s*(.+)$/);
343
- if (!named) continue;
344
- properties[named[1]] = typeSchema(named[3]);
345
- if (!named[2]) required.push(named[1]);
346
- }
347
- return {
348
- type: "object",
349
- properties,
350
- ...required.length > 0 ? { required } : {},
351
- additionalProperties
352
- };
353
- }
354
- function typeSchema(type) {
355
- const trimmed = type.trim();
356
- const alternatives = trimmed.split("|").map((part) => part.trim());
357
- if (alternatives.length > 1) return { anyOf: alternatives.map(typeSchema) };
358
- if (trimmed in DYNAMIC_REFS) return { $ref: DYNAMIC_REFS[trimmed] };
359
- if (trimmed.endsWith("[]")) return { anyOf: [
360
- {
361
- type: "array",
362
- items: typeSchema(trimmed.slice(0, -2))
363
- },
364
- { $ref: DATA_BINDING_REF },
365
- { $ref: FUNCTION_CALL_REF }
366
- ] };
367
- return { $ref: DYNAMIC_REFS.unknown };
368
- }
369
-
370
- //#endregion
371
12
  //#region src/generative-ui/GenerativeUISurface.tsx
372
- /** Scrolls `element` into view, unless it is already fully on screen. */
373
- function scrollToSurface(element) {
374
- const { top, bottom } = element.getBoundingClientRect();
375
- if (top >= 0 && bottom <= window.innerHeight) return;
376
- const reduceMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
377
- element.scrollIntoView?.({
378
- behavior: reduceMotion ? "auto" : "smooth",
379
- block: "start"
380
- });
381
- }
382
13
  const isDevelopment = () => process.env.NODE_ENV !== "production";
383
14
  /**
384
- * The names of `requested` that `ui` has, without repeats, at most the
385
- * number that the envelope takes. `warning` tells what was dropped.
386
- */
387
- function allowedComponents(requested, ui) {
388
- const unique = [...new Set(requested)];
389
- const unknown = unique.filter((name) => !ui.components.has(name));
390
- const known = unique.filter((name) => ui.components.has(name));
391
- const names = known.slice(0, GENERATIVE_UI_MAX_TARGET_COMPONENTS);
392
- const problems = [];
393
- if (unknown.length > 0) problems.push(`these components are not in the UI and are ignored: ${unknown.join(", ")}`);
394
- if (known.length > names.length) problems.push(`only the first ${GENERATIVE_UI_MAX_TARGET_COMPONENTS} components are used`);
395
- return {
396
- names,
397
- warning: problems.join("; ")
398
- };
399
- }
400
- /**
401
15
  * Experimental. A named place on the page where the agent can render UI.
402
16
  *
403
17
  * @example
@@ -492,276 +106,6 @@ function useOverlayEscape(isOpen, close) {
492
106
  }, [isOpen, close]);
493
107
  }
494
108
 
495
- //#endregion
496
- //#region src/generative-ui/standard/tokens.ts
497
- /**
498
- * Design tokens of the standard components. Each token is a CSS variable
499
- * with a literal fallback, so a host can restyle a surface with the
500
- * `--a2ui-*` variables. A value that is not a token passes through as raw
501
- * CSS.
502
- */
503
- /** Id of `standardUI`, the catalog id the model writes in createSurface. */
504
- const STANDARD_CATALOG_ID = "copilotkit/standard@1";
505
- const TITLE_SIZES = [
506
- "sm",
507
- "md",
508
- "lg",
509
- "xl",
510
- "2xl",
511
- "3xl",
512
- "4xl",
513
- "5xl"
514
- ];
515
- const TEXT_SIZES = [
516
- "3xs",
517
- "2xs",
518
- "xs",
519
- "sm",
520
- "md",
521
- "lg"
522
- ];
523
- const WEIGHTS = [
524
- "normal",
525
- "medium",
526
- "semibold",
527
- "bold"
528
- ];
529
- const ALIGN = [
530
- "start",
531
- "center",
532
- "end",
533
- "baseline",
534
- "stretch"
535
- ];
536
- const JUSTIFY = [
537
- "start",
538
- "center",
539
- "end",
540
- "spaceBetween",
541
- "spaceAround",
542
- "spaceEvenly",
543
- "stretch"
544
- ];
545
- const WRAP = [
546
- "nowrap",
547
- "wrap",
548
- "wrap-reverse"
549
- ];
550
- const RADII = [
551
- "2xs",
552
- "xs",
553
- "sm",
554
- "md",
555
- "lg",
556
- "xl",
557
- "2xl",
558
- "3xl",
559
- "4xl",
560
- "full"
561
- ];
562
- const TEXT_COLORS = [
563
- "default",
564
- "prose",
565
- "primary",
566
- "emphasis",
567
- "secondary",
568
- "tertiary",
569
- "success",
570
- "info",
571
- "warning",
572
- "caution",
573
- "danger",
574
- "discovery"
575
- ];
576
- const BORDER_COLORS = [
577
- "default",
578
- "subtle",
579
- "strong",
580
- "info",
581
- "warning",
582
- "caution",
583
- "success",
584
- "danger",
585
- "discovery"
586
- ];
587
- const BACKGROUNDS = [
588
- "surface",
589
- "surface-secondary",
590
- "surface-tertiary",
591
- "surface-elevated",
592
- "surface-elevated-secondary",
593
- "surface-inverted",
594
- "surface-soft",
595
- "info",
596
- "warning",
597
- "caution",
598
- "success",
599
- "danger",
600
- "discovery",
601
- "info-solid",
602
- "warning-solid",
603
- "caution-solid",
604
- "success-solid",
605
- "danger-solid",
606
- "discovery-solid"
607
- ];
608
- const RADIUS_PX = {
609
- "2xs": "2px",
610
- xs: "4px",
611
- sm: "6px",
612
- md: "8px",
613
- lg: "12px",
614
- xl: "16px",
615
- "2xl": "20px",
616
- "3xl": "24px",
617
- "4xl": "32px",
618
- full: "9999px"
619
- };
620
- const TEXT_COLOR_FALLBACK = {
621
- default: "#0d0d0d",
622
- prose: "#0d0d0d",
623
- primary: "#0d0d0d",
624
- emphasis: "#000",
625
- secondary: "#5d5d5d",
626
- tertiary: "#8e8e8e",
627
- success: "#00805d",
628
- info: "#0068bc",
629
- warning: "#946200",
630
- caution: "#946200",
631
- danger: "#c1322c",
632
- discovery: "#7040c1"
633
- };
634
- const BG_FALLBACK = {
635
- surface: "#fff",
636
- "surface-secondary": "#f7f7f8",
637
- "surface-tertiary": "#ececec",
638
- "surface-elevated": "#fff",
639
- "surface-elevated-secondary": "#f7f7f8",
640
- "surface-inverted": "#0d0d0d",
641
- "surface-soft": "#fcfcfc",
642
- info: "rgba(0, 104, 188, 0.08)",
643
- warning: "rgba(148, 98, 0, 0.08)",
644
- caution: "rgba(148, 98, 0, 0.08)",
645
- success: "rgba(0, 128, 93, 0.08)",
646
- danger: "rgba(193, 50, 44, 0.08)",
647
- discovery: "rgba(112, 64, 193, 0.08)",
648
- "info-solid": "#0068bc",
649
- "warning-solid": "#946200",
650
- "caution-solid": "#946200",
651
- "success-solid": "#00805d",
652
- "danger-solid": "#c1322c",
653
- "discovery-solid": "#7040c1"
654
- };
655
- const BORDER_FALLBACK = {
656
- default: "rgba(0, 0, 0, 0.1)",
657
- subtle: "rgba(0, 0, 0, 0.05)",
658
- strong: "#cdcdcd",
659
- info: "#9cc4ea",
660
- warning: "#e6c98a",
661
- caution: "#e6c98a",
662
- success: "#9ad9c3",
663
- danger: "#eeaaa6",
664
- discovery: "#c8b4ea"
665
- };
666
- function hasToken(table, key) {
667
- return Object.hasOwn(table, key);
668
- }
669
- /** A number is a count of 4px steps. A string passes through as CSS. */
670
- function spacing(value) {
671
- if (value === void 0) return void 0;
672
- return typeof value === "number" ? `calc(var(--spacing, 0.25rem) * ${value})` : value;
673
- }
674
- /** A radius token, a number of pixels, or raw CSS. */
675
- function radius(value) {
676
- if (value === void 0) return void 0;
677
- if (typeof value === "number") return `${value}px`;
678
- if (value === "full") return "9999px";
679
- return hasToken(RADIUS_PX, value) ? `var(--a2ui-radius-${value}, ${RADIUS_PX[value]})` : value;
680
- }
681
- /** A text color token, or a raw CSS color. */
682
- function textColor(value) {
683
- if (!value) return void 0;
684
- return hasToken(TEXT_COLOR_FALLBACK, value) ? `var(--a2ui-color-text-${value}, ${TEXT_COLOR_FALLBACK[value]})` : value;
685
- }
686
- /** A background token, or a raw CSS color. */
687
- function backgroundColor(value) {
688
- if (!value) return void 0;
689
- return hasToken(BG_FALLBACK, value) ? `var(--a2ui-color-${value}, ${BG_FALLBACK[value]})` : value;
690
- }
691
- /** The one inner panel of a Card: near-white fill. */
692
- const INNER_PANEL_BG = "var(--a2ui-color-panel, rgb(252, 252, 252))";
693
- const SOFT_TINT = {
694
- info: "rgba(0, 104, 188, 0.06)",
695
- warning: "rgba(148, 98, 0, 0.06)",
696
- caution: "rgba(148, 98, 0, 0.06)",
697
- success: "rgba(0, 128, 93, 0.06)",
698
- danger: "rgba(193, 50, 44, 0.06)",
699
- discovery: "rgba(112, 64, 193, 0.06)"
700
- };
701
- /**
702
- * The background of a panel inside a Card. A neutral surface becomes the
703
- * near-white inner panel. A semantic tint gets lighter (about 6% alpha).
704
- * Solid and raw values go through `backgroundColor`.
705
- */
706
- function panelBackground(value) {
707
- if (!value) return void 0;
708
- if (value === "surface-secondary" || value === "surface-soft" || value === "surface-elevated-secondary") return INNER_PANEL_BG;
709
- return hasToken(SOFT_TINT, value) ? `var(--a2ui-color-${value}-soft, ${SOFT_TINT[value]})` : backgroundColor(value);
710
- }
711
- /** A border color token, or a raw CSS color. */
712
- function borderColor(value) {
713
- if (!value) return void 0;
714
- return hasToken(BORDER_FALLBACK, value) ? `var(--a2ui-color-border-${value}, ${BORDER_FALLBACK[value]})` : value;
715
- }
716
- const TEXT_SCALE = {
717
- "3xs": [".625em", 1.2],
718
- "2xs": [".6875em", 1.273],
719
- xs: [".75em", 1.333],
720
- sm: [".875em", 1.429],
721
- md: ["1em", 1.625],
722
- lg: ["1.125em", 1.556]
723
- };
724
- /** Text on an accent fill (solid buttons and badges, selected segments). */
725
- const ON_ACCENT = "var(--a2ui-color-on-accent, #fff)";
726
- /** The fill of a control (checkbox, radio, slider thumb, selected segment). */
727
- const CONTROL_BG = "var(--a2ui-color-control, #fff)";
728
- const SHADOW_XS = "var(--a2ui-shadow-xs, 0 1px 2px rgba(0,0,0,.12))";
729
- const SHADOW_SM = "var(--a2ui-shadow-sm, 0 1px 3px rgba(0,0,0,.12))";
730
- const SHADOW_SOFT = "var(--a2ui-shadow-soft, 0 1px 3px rgba(0,0,0,.06))";
731
- const SHADOW_MD = "var(--a2ui-shadow-md, 0 4px 12px rgba(0,0,0,.08))";
732
- /** The scrim behind a lightbox or modal. */
733
- const BACKDROP = "var(--a2ui-color-backdrop, rgba(0,0,0,.8))";
734
- /** The hover band behind a chart column. */
735
- const CHART_CURSOR = "var(--a2ui-color-chart-cursor, rgba(0,0,0,.04))";
736
- /**
737
- * Chart series colors: a soft blue family first, then muted companions, so
738
- * a chart with many series stays easy to read. A host can change each one
739
- * with `--a2ui-chart-1`, `--a2ui-chart-2`, and so on.
740
- */
741
- const CHART_PALETTE_FALLBACK = [
742
- "#7fb0f2",
743
- "#2f6fd1",
744
- "#b7cff7",
745
- "#8bb5a8",
746
- "#d9b36b",
747
- "#c08bb0"
748
- ];
749
- const CHART_PALETTE = CHART_PALETTE_FALLBACK.map((hex, index) => `var(--a2ui-chart-${index + 1}, ${hex})`);
750
- /** The body text size, in em of the text around it. */
751
- function textFont(size = "md") {
752
- const [fontSize, lineHeight] = TEXT_SCALE[size];
753
- return {
754
- fontSize,
755
- lineHeight
756
- };
757
- }
758
- const FONT_WEIGHT = {
759
- normal: 400,
760
- medium: 500,
761
- semibold: 600,
762
- bold: 700
763
- };
764
-
765
109
  //#endregion
766
110
  //#region src/generative-ui/standard/lightbox.tsx
767
111
  const LIGHTBOX_BUTTON = {
@@ -897,58 +241,6 @@ function openUrl(href) {
897
241
 
898
242
  //#endregion
899
243
  //#region src/generative-ui/standard/styles.ts
900
- /**
901
- * The stylesheet for what inline styles cannot do: pseudo-elements (slider
902
- * track and thumb, placeholder), `:checked` and `:first-child` states,
903
- * heading fallbacks, and resets for host prose styles. It is added once per
904
- * document.
905
- *
906
- * Typography is inherited: a surface takes the font, size, line height and
907
- * color of the text around it (the chat prose). Headings take the heading
908
- * styles of the host.
909
- */
910
- const STANDARD_STYLE_ID = "a2ui-standard-catalog";
911
- const ACCENT = "var(--a2ui-color-accent, #0d0d0d)";
912
- const FOCUS_RING$1 = "2px solid var(--a2ui-color-focus, #0285ff)";
913
- const CHECK_SVG = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E\")";
914
- const SLIDER_TRACK = "var(--a2ui-color-slider-track, rgba(0, 0, 0, 0.04))";
915
- const THUMB = `width:20px;height:20px;box-sizing:border-box;border-radius:9999px;background:${CONTROL_BG};border:1px solid ${borderColor("default")};box-shadow:${SHADOW_XS};cursor:pointer`;
916
- const STANDARD_CSS = [
917
- DARK_THEME_CSS,
918
- ".a2ui-surface{min-width:0;max-width:100%;box-sizing:border-box}",
919
- ".a2ui-surface{font:inherit;color:inherit}",
920
- ":where(.a2ui-surface) :where(h2){font-size:1.5em;font-weight:600;line-height:1.3}",
921
- ":where(.a2ui-surface) :where(h3){font-size:1.25em;font-weight:600;line-height:1.3}",
922
- ":where(.a2ui-surface) :where(h4){font-size:1em;font-weight:600;line-height:1.4}",
923
- "[data-a2ui-std] :is(button,input,select,textarea),[data-a2ui-input]{font:inherit;color:inherit}",
924
- "[data-a2ui-row=\"spaceBetween\"]>[data-a2ui-text]:last-child:not(:first-child){text-align:right;margin-inline-start:auto}",
925
- `[data-a2ui-input]:focus-visible{outline:${FOCUS_RING$1};outline-offset:1px}`,
926
- `[data-a2ui-scroll]:focus-visible{outline:${FOCUS_RING$1};outline-offset:2px}`,
927
- `[data-a2ui-input]::placeholder{color:${textColor("tertiary")};opacity:1}`,
928
- `.a2ui-std-range{-webkit-appearance:none;appearance:none;display:block;width:100%;height:24px;margin:0;padding:0 2px;box-sizing:border-box;border-radius:9999px;background:${SLIDER_TRACK};cursor:pointer}`,
929
- ".a2ui-std-range:disabled{cursor:not-allowed;opacity:.5}",
930
- ".a2ui-std-range::-webkit-slider-runnable-track{height:24px;background:transparent;border:0}",
931
- `.a2ui-std-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;margin-top:2px;${THUMB}}`,
932
- ".a2ui-std-range::-moz-range-track{height:24px;background:transparent;border:0}",
933
- `.a2ui-std-range::-moz-range-thumb{${THUMB}}`,
934
- `.a2ui-std-check{-webkit-appearance:none;appearance:none;flex-shrink:0;width:20px;height:20px;margin:0;box-sizing:border-box;border:1px solid ${borderColor("strong")};border-radius:9999px;background:${CONTROL_BG} center/14px 14px no-repeat;cursor:pointer}`,
935
- ".a2ui-std-check[data-shape=\"square\"]{border-radius:6px}",
936
- `.a2ui-std-check:checked{background-color:${ACCENT};border-color:${ACCENT};background-image:${CHECK_SVG}}`,
937
- `.a2ui-std-check[type="radio"]:checked{background-image:none;background-color:${CONTROL_BG};border:6px solid ${ACCENT}}`,
938
- ".a2ui-std-check:disabled{cursor:not-allowed}",
939
- ".a2ui-surface :is(h1,h2,h3,h4,h5,h6):not(.a2ui-markdown *){margin:var(--a2ui-heading-margin,0)}",
940
- ".a2ui-surface :is(p,table,figure,figcaption,blockquote,pre):not(.a2ui-markdown *){margin:var(--a2ui-block-margin,0)}",
941
- ".a2ui-markdown>:first-child{margin-top:0}",
942
- ".a2ui-markdown>:last-child{margin-bottom:0}",
943
- ".a2ui-surface :is(.a2ui-std-list,.a2ui-std-list>li){margin:0}",
944
- ".a2ui-surface .a2ui-std-table{font-size:inherit;line-height:inherit}",
945
- ".a2ui-std-table-wrap{width:100%;max-width:100%;min-width:0;overflow-x:auto}",
946
- ".a2ui-std-cell{padding:8px}",
947
- ".a2ui-std-cell:first-child{padding-inline-start:0}",
948
- ".a2ui-std-cell:last-child{padding-inline-end:0}",
949
- `.a2ui-std-cell[data-divider]{border-bottom:1px solid ${borderColor("subtle")}}`,
950
- ".a2ui-std-table>tbody:last-child>tr:last-child>.a2ui-std-cell{border-bottom:0}"
951
- ].join("\n");
952
244
  const noEffect$2 = () => {};
953
245
  const useInjectEffect$2 = typeof document === "undefined" ? noEffect$2 : React.useInsertionEffect;
954
246
  /**
@@ -966,170 +258,164 @@ function useStandardStyles() {
966
258
  }
967
259
 
968
260
  //#endregion
969
- //#region src/generative-ui/standard/layout.tsx
970
- /** A number is a count of 4px steps. A string is raw CSS. */
971
- const sizeValue = z.union([z.number(), z.string()]);
972
- /** The A2UI `weight`: how much of the free space of a Row or Column to take. */
973
- const weightProp = z.number().optional().describe("flex-grow in a Row or Column");
974
- const radiusValue = z.union([
975
- z.enum(RADII),
976
- z.number(),
977
- z.string(),
978
- z.object({
979
- topLeft: z.string().optional(),
980
- topRight: z.string().optional(),
981
- bottomLeft: z.string().optional(),
982
- bottomRight: z.string().optional()
983
- })
984
- ]);
985
- /**
986
- * The layout props of every container. Spread them into a props schema:
987
- * `z.object({ ...layoutProps, variant: ... })`. The children of a container
988
- * are a slot, not a prop.
989
- */
990
- const layoutProps = {
991
- align: z.enum(ALIGN).optional(),
992
- justify: z.enum(JUSTIFY).optional(),
993
- wrap: z.enum(WRAP).optional(),
994
- gap: sizeValue.optional().describe("4px steps when a number"),
995
- rowGap: sizeValue.optional(),
996
- columnGap: sizeValue.optional(),
997
- padding: sizeValue.optional().describe("4px steps when a number"),
998
- background: z.string().optional().describe(`One of ${BACKGROUNDS.join("|")} or a CSS color. Leave it unset. Only one summary panel in a Card can use "surface-secondary"`),
999
- border: z.boolean().optional(),
1000
- borderColor: z.enum(BORDER_COLORS).optional(),
1001
- radius: radiusValue.optional(),
1002
- width: sizeValue.optional(),
1003
- height: sizeValue.optional(),
1004
- minWidth: sizeValue.optional(),
1005
- maxWidth: sizeValue.optional(),
1006
- minHeight: sizeValue.optional(),
1007
- maxHeight: sizeValue.optional(),
1008
- flex: z.number().optional(),
1009
- weight: weightProp,
1010
- aspectRatio: z.string().optional(),
1011
- scrollable: z.boolean().optional(),
1012
- clip: z.boolean().optional(),
1013
- shadow: z.boolean().optional(),
1014
- inline: z.boolean().optional(),
1015
- role: z.string().optional().describe("ARIA role"),
1016
- flush: z.boolean().optional().describe("No padding"),
1017
- minSize: sizeValue.optional().describe("Minimum width and height"),
1018
- maxSize: sizeValue.optional().describe("Maximum width and height"),
1019
- disableAutoSpacing: z.boolean().optional().describe("No default gap between children")
261
+ //#region src/generative-ui/standard/markdown.tsx
262
+ const SAFE_URL = /^(https?:|mailto:)/i;
263
+ /** The trimmed URL when it is http, https or mailto. Else `undefined`. */
264
+ function safeHref(url) {
265
+ const trimmed = url.trim();
266
+ return SAFE_URL.test(trimmed) ? trimmed : void 0;
267
+ }
268
+ /** Hides text on screen but keeps it for screen readers. */
269
+ const VISUALLY_HIDDEN$1 = {
270
+ position: "absolute",
271
+ width: 1,
272
+ height: 1,
273
+ padding: 0,
274
+ margin: -1,
275
+ overflow: "hidden",
276
+ clipPath: "inset(50%)",
277
+ whiteSpace: "nowrap",
278
+ border: 0
1020
279
  };
1021
- const layoutSchema = z.object(layoutProps);
1022
- /** The arguments of a click or visibility event: none. */
1023
- const NO_ARGS$3 = z.object({});
1024
280
  /**
1025
- * The `onVisible` event of every container: sent once, the first time the
1026
- * container scrolls into view.
281
+ * A link that opens in a new tab. Screen readers also hear that it opens a
282
+ * new tab.
1027
283
  */
1028
- const VISIBLE_EVENT = { onVisible: {
1029
- description: "Sent once, the first time the container scrolls into view. Use it to load more content lazily.",
1030
- parameters: NO_ARGS$3
1031
- } };
1032
- /** The slot of every container: a list of children or a template. */
1033
- const CHILDREN_SLOT = { children: "multiple" };
1034
- const boxSchema = z.object({
1035
- ...layoutProps,
1036
- direction: z.enum(["col", "row"]).optional().describe("Default \"col\"")
1037
- });
1038
- const gridSchema = z.object({
1039
- ...layoutProps,
1040
- columns: z.union([z.number(), z.string()]).optional().describe("Column count or CSS template. Default 2"),
1041
- minChildWidth: sizeValue.optional(),
1042
- rows: z.union([z.number(), z.string()]).optional()
1043
- });
1044
- const gridItemSchema = z.object({
1045
- ...layoutProps,
1046
- span: z.number().optional(),
1047
- rowSpan: z.number().optional()
1048
- });
1049
- const cardSchema = z.object({
1050
- ...layoutProps,
1051
- variant: z.enum([
1052
- "default",
1053
- "outline",
1054
- "section",
1055
- "soft",
1056
- "elevated",
1057
- "transparent"
1058
- ]).optional(),
1059
- shadowStyle: z.enum([
1060
- "none",
1061
- "sm",
1062
- "md"
1063
- ]).optional().describe("Overrides the shadow of the variant"),
1064
- size: z.enum([
1065
- "sm",
1066
- "md",
1067
- "lg"
1068
- ]).optional().describe("The padding preset: 8, 16 or 24px. Default \"md\"")
1069
- });
1070
- const flowSchema = z.object({
1071
- ...layoutProps,
1072
- columns: z.number().optional(),
1073
- rows: z.number().optional(),
1074
- layout: z.enum(["pack", "fixed"]).optional().describe("Default \"pack\"")
1075
- });
1076
- const flowItemSchema = z.object({
1077
- ...layoutProps,
1078
- span: z.number().optional(),
1079
- rowSpan: z.number().optional(),
1080
- aspectRatio: z.string().optional().describe("Default \"1 / 1\""),
1081
- aspectMode: z.enum(["soft", "fixed"]).optional()
1082
- });
1083
- const carouselSchema = z.object({
1084
- ...layoutProps,
1085
- label: z.string().optional().describe("A short name of the carousel for screen readers"),
1086
- visibleItems: z.number().optional(),
1087
- showArrows: z.boolean().optional().describe("Default true"),
1088
- activeIndex: z.number().optional().describe("The index of the slide in view. Bind it with { \"@path\": \"/x\" } to read or set it"),
1089
- previousLabel: z.string().optional().describe("Default \"Previous\""),
1090
- nextLabel: z.string().optional().describe("Default \"Next\""),
1091
- snap: z.enum([
1092
- "none",
1093
- "proximity",
1094
- "mandatory"
1095
- ]).optional(),
1096
- snapAlign: z.enum([
1097
- "start",
1098
- "center",
1099
- "end"
1100
- ]).optional()
1101
- });
1102
- const CAROUSEL_MEDIA_SIZES = [
1103
- "sm",
1104
- "md",
1105
- "lg"
284
+ function ExternalLink({ href, title, style, children }) {
285
+ return /* @__PURE__ */ jsxs("a", {
286
+ href,
287
+ title,
288
+ target: "_blank",
289
+ rel: "noopener noreferrer",
290
+ style,
291
+ children: [children, /* @__PURE__ */ jsx("span", {
292
+ style: VISUALLY_HIDDEN$1,
293
+ children: " (opens in a new tab)"
294
+ })]
295
+ });
296
+ }
297
+ const DELIMITERS = [
298
+ {
299
+ open: "**",
300
+ tag: "strong"
301
+ },
302
+ {
303
+ open: "~~",
304
+ tag: "s"
305
+ },
306
+ {
307
+ open: "++",
308
+ tag: "u"
309
+ },
310
+ {
311
+ open: "`",
312
+ tag: "code"
313
+ },
314
+ {
315
+ open: "*",
316
+ tag: "em"
317
+ },
318
+ {
319
+ open: "_",
320
+ tag: "em"
321
+ }
1106
322
  ];
1107
- const carouselMediaItemSchema = z.object({
1108
- ...layoutProps,
1109
- url: z.string().describe("Image URL"),
1110
- description: z.string().optional().describe("What the image shows, for screen readers"),
1111
- size: z.enum(CAROUSEL_MEDIA_SIZES).optional().describe("The width: \"sm\" 160px, \"md\" 240px, \"lg\" 320px. Default \"md\""),
1112
- aspectRatio: z.string().optional().describe("Default \"4 / 3\""),
1113
- href: z.string().optional().describe("Opens this URL in a new tab"),
1114
- lightbox: z.boolean().optional().describe("Default true: a click opens all slides full-screen")
1115
- });
1116
- const spacerSchema = z.object({ minSize: sizeValue.optional() });
1117
- const tabsSchema = z.object({
1118
- tabs: z.array(z.object({
1119
- title: z.string().describe("The tab title"),
1120
- child: child("The id of the panel component")
1121
- })).describe("One entry per tab"),
1122
- selectedIndex: z.number().optional().describe("The open tab. Default 0. Bind it with { \"@path\": \"/x\" } to read it"),
1123
- weight: weightProp
1124
- });
1125
- const dividerSchema = z.object({
1126
- axis: z.enum(["horizontal", "vertical"]).optional().describe("Default \"horizontal\""),
1127
- weight: weightProp,
1128
- color: z.enum(BORDER_COLORS).optional(),
1129
- size: z.number().optional(),
1130
- spacing: sizeValue.optional(),
1131
- flush: z.boolean().optional()
1132
- });
323
+ /** The link that starts at `start` (`[label](url)`), or `null`. */
324
+ function matchLink(text, start) {
325
+ if (text[start] !== "[") return null;
326
+ const close = text.indexOf("](", start + 1);
327
+ if (close < 0) return null;
328
+ const end = text.indexOf(")", close + 2);
329
+ if (end < 0) return null;
330
+ let urlEnd = end;
331
+ if (text.slice(close + 2, end).includes("(")) {
332
+ const next = text.indexOf(")", end + 1);
333
+ if (next < 0) return null;
334
+ urlEnd = next;
335
+ }
336
+ return {
337
+ label: text.slice(start + 1, close),
338
+ url: text.slice(close + 2, urlEnd),
339
+ next: urlEnd + 1
340
+ };
341
+ }
342
+ /**
343
+ * Renders a small set of inline markdown: `**bold**`, `*italic*` and
344
+ * `_italic_`, `~~strike~~`, `++underline++`, `` `code` `` and
345
+ * `[label](url)`.
346
+ *
347
+ * - A marker without a closing partner stays literal text.
348
+ * - A link is a link only for http, https and mailto URLs. For other URLs,
349
+ * only the label shows.
350
+ * - Marks do not nest.
351
+ *
352
+ * @param text - The source text.
353
+ */
354
+ function renderInlineMarkdown(text) {
355
+ if (!text) return text;
356
+ const out = [];
357
+ let buffer = "";
358
+ let key = 0;
359
+ const flush = () => {
360
+ if (buffer) out.push(buffer);
361
+ buffer = "";
362
+ };
363
+ let index = 0;
364
+ while (index < text.length) {
365
+ const link = matchLink(text, index);
366
+ if (link) {
367
+ flush();
368
+ const href = safeHref(link.url);
369
+ out.push(href ? /* @__PURE__ */ jsx(ExternalLink, {
370
+ href,
371
+ children: link.label
372
+ }, key++) : /* @__PURE__ */ jsx(React.Fragment, { children: link.label }, key++));
373
+ index = link.next;
374
+ continue;
375
+ }
376
+ const delimiter = DELIMITERS.find((d) => text.startsWith(d.open, index));
377
+ const isIntraWordUnderscore = delimiter?.open === "_" && /\w/.test(text[index - 1] ?? "");
378
+ if (delimiter && !isIntraWordUnderscore) {
379
+ const start = index + delimiter.open.length;
380
+ const end = text.indexOf(delimiter.open, start);
381
+ const inner = end > start ? text.slice(start, end) : "";
382
+ if (inner !== "" && (delimiter.tag === "code" || inner.trim() === inner)) {
383
+ flush();
384
+ const Tag = delimiter.tag;
385
+ out.push(/* @__PURE__ */ jsx(Tag, { children: inner }, key++));
386
+ index = end + delimiter.open.length;
387
+ continue;
388
+ }
389
+ buffer += delimiter.open;
390
+ index = start;
391
+ continue;
392
+ }
393
+ buffer += text[index];
394
+ index += 1;
395
+ }
396
+ flush();
397
+ return out.length === 1 && typeof out[0] === "string" ? out[0] : out;
398
+ }
399
+ /**
400
+ * Full GitHub-flavored markdown, rendered with the same markdown renderer
401
+ * as the chat messages. It has no typography of its own, so it reads like
402
+ * the chat text around the surface. While `streaming` is true, the renderer
403
+ * handles markdown that is not complete yet.
404
+ */
405
+ function Markdown({ text, streaming = false }) {
406
+ useStandardStyles();
407
+ return /* @__PURE__ */ jsx("div", {
408
+ className: "a2ui-markdown",
409
+ "data-a2ui-std": "",
410
+ children: /* @__PURE__ */ jsx(ProviderMarkdown, {
411
+ content: text,
412
+ isStreaming: streaming
413
+ })
414
+ });
415
+ }
416
+
417
+ //#endregion
418
+ //#region src/generative-ui/standard/layout.tsx
1133
419
  const ALIGN_CSS$1 = {
1134
420
  start: "flex-start",
1135
421
  end: "flex-end",
@@ -1345,6 +631,7 @@ function cardShadow(props) {
1345
631
  case "md": return SHADOW_MD;
1346
632
  case "sm": return SHADOW_SM;
1347
633
  case "none": return "none";
634
+ case void 0:
1348
635
  default: return props.variant === "elevated" ? SHADOW_SOFT : void 0;
1349
636
  }
1350
637
  }
@@ -1798,477 +1085,73 @@ function Tabs(props) {
1798
1085
  role: "tabpanel",
1799
1086
  id: `${id}-panel-${index}`,
1800
1087
  "aria-labelledby": `${id}-tab-${index}`,
1801
- style: {
1802
- display: "flex",
1803
- flexDirection: "column",
1804
- gap: spacing(3)
1805
- },
1806
- children: tab.child
1807
- }, index) : null)]
1808
- });
1809
- }
1810
- function Spacer(props) {
1811
- return /* @__PURE__ */ jsx("div", {
1812
- "aria-hidden": "true",
1813
- style: {
1814
- flex: 1,
1815
- minWidth: spacing(props.minSize ?? 2),
1816
- minHeight: spacing(props.minSize ?? 2)
1817
- }
1818
- });
1819
- }
1820
- function Divider(props) {
1821
- const line = `${props.size ?? 1}px solid ${borderColor(props.color ?? "subtle")}`;
1822
- const margin = props.flush ? 0 : spacing(props.spacing ?? 2);
1823
- const isVertical = props.axis === "vertical";
1824
- return /* @__PURE__ */ jsx("hr", {
1825
- "aria-orientation": isVertical ? "vertical" : void 0,
1826
- style: {
1827
- border: 0,
1828
- ...isVertical ? {
1829
- borderLeft: line,
1830
- margin: `0 ${margin}`,
1831
- height: "auto"
1832
- } : {
1833
- borderTop: line,
1834
- margin: `${margin} 0`,
1835
- width: "100%"
1836
- },
1837
- flexShrink: 0,
1838
- flexGrow: props.weight,
1839
- alignSelf: "stretch"
1840
- }
1841
- });
1842
- }
1843
- /**
1844
- * The standard layout components: containers, Spacer and Divider. Give
1845
- * them to `createGenerativeUI({ components: { ...layoutComponents } })`.
1846
- * Every container has a "multiple" `children` slot, so it takes a list of
1847
- * child ids or a template `{ componentId, path }`.
1848
- */
1849
- const layoutComponents = {
1850
- Box: {
1851
- component: Box,
1852
- description: "A flex container. It stacks its children in a column (direction \"row\" puts them in a row). Use it to group children with gap, padding, border, radius or background.",
1853
- props: boxSchema,
1854
- events: VISIBLE_EVENT,
1855
- slots: CHILDREN_SLOT
1856
- },
1857
- Column: {
1858
- component: Column,
1859
- description: "A vertical flex container. Its default gap already separates sections, so do not add padding, background or a Spacer for space.",
1860
- props: layoutSchema,
1861
- events: VISIBLE_EVENT,
1862
- slots: CHILDREN_SLOT
1863
- },
1864
- Row: {
1865
- component: Row,
1866
- description: "A horizontal flex container. For a label and value pair, use a Row with justify \"spaceBetween\": a Caption on the left and a Text with fontWeight \"medium\" on the right. Put buttons in a Row at the bottom of a Card: one Button with variant \"primary\", and the default or \"borderless\" for the others.",
1867
- props: layoutSchema,
1868
- events: VISIBLE_EVENT,
1869
- slots: CHILDREN_SLOT
1870
- },
1871
- Grid: {
1872
- component: Grid,
1873
- description: "A CSS grid container. On a narrow screen, its columns collapse towards one column.",
1874
- props: gridSchema,
1875
- events: VISIBLE_EVENT,
1876
- slots: CHILDREN_SLOT
1877
- },
1878
- GridItem: {
1879
- component: GridItem,
1880
- description: "A cell of a Grid, with an optional span. A span that covers all rendered columns fills the row.",
1881
- props: gridItemSchema,
1882
- events: VISIBLE_EVENT,
1883
- slots: CHILDREN_SLOT
1884
- },
1885
- Card: {
1886
- component: Card,
1887
- description: "A bordered, padded container, only for an interactive panel (controls, a form, a configurator). Tables, charts and text do not need one. Give it a Title and a Caption. Separate the groups in it with a Divider or the plain gap, never with a nested Card or a bordered Box. Variant \"section\" is a heading and content without a box. Variant \"outline\" always has a box. In markdown mode, a Card without controls renders as \"section\" unless it sets variant or border.",
1888
- props: cardSchema,
1889
- events: VISIBLE_EVENT,
1890
- slots: {
1891
- child: "single",
1892
- children: "multiple"
1893
- }
1894
- },
1895
- Flow: {
1896
- component: Flow,
1897
- description: "A masonry-like grid that packs cells of different sizes. Put FlowItem children in it.",
1898
- props: flowSchema,
1899
- events: VISIBLE_EVENT,
1900
- slots: CHILDREN_SLOT
1901
- },
1902
- FlowItem: {
1903
- component: FlowItem,
1904
- description: "A cell of a Flow, with an optional span.",
1905
- props: flowItemSchema,
1906
- events: VISIBLE_EVENT,
1907
- slots: CHILDREN_SLOT
1908
- },
1909
- Carousel: {
1910
- component: Carousel,
1911
- description: "A row that scrolls horizontally and snaps to its slides, with previous and next arrows. Put CarouselItem or CarouselMediaItem children in it. Bind activeIndex with { \"@path\": \"/x\" } to read or set the slide in view.",
1912
- props: carouselSchema,
1913
- events: VISIBLE_EVENT,
1914
- slots: CHILDREN_SLOT,
1915
- writable: ["activeIndex"]
1916
- },
1917
- CarouselItem: {
1918
- component: CarouselItem,
1919
- description: "A slide of a Carousel.",
1920
- props: layoutSchema,
1921
- events: VISIBLE_EVENT,
1922
- slots: CHILDREN_SLOT
1923
- },
1924
- CarouselMediaItem: {
1925
- component: CarouselMediaItem,
1926
- description: "A slide of a Carousel with an image on top and its children (a Caption, a Text) under it. size \"sm\" is 160px, \"md\" 240px (default), \"lg\" 320px wide. A click on the image opens all slides full-screen, unless href or onClick is set.",
1927
- props: carouselMediaItemSchema,
1928
- events: {
1929
- ...VISIBLE_EVENT,
1930
- onClick: {
1931
- description: "Sent when the user clicks the image. It replaces the full-screen view.",
1932
- parameters: NO_ARGS$3
1933
- }
1934
- },
1935
- slots: CHILDREN_SLOT
1936
- },
1937
- Spacer: {
1938
- component: Spacer,
1939
- description: "Flexible empty space. You almost never need it: use the default gap.",
1940
- props: spacerSchema
1941
- },
1942
- Divider: {
1943
- component: Divider,
1944
- description: "A line between two groups: horizontal, or vertical with axis \"vertical\" in a Row.",
1945
- props: dividerSchema
1946
- },
1947
- Tabs: {
1948
- component: Tabs,
1949
- description: "Tabs that show one panel at a time. Each tab has a title and the id of its panel component: \"tabs\":[{\"title\":\"Specs\",\"child\":\"specs\"}].",
1950
- props: tabsSchema,
1951
- writable: ["selectedIndex"]
1952
- }
1953
- };
1954
-
1955
- //#endregion
1956
- //#region src/generative-ui/standard/markdown.tsx
1957
- const SAFE_URL = /^(https?:|mailto:)/i;
1958
- /** The trimmed URL when it is http, https or mailto. Else `undefined`. */
1959
- function safeHref(url) {
1960
- const trimmed = url.trim();
1961
- return SAFE_URL.test(trimmed) ? trimmed : void 0;
1962
- }
1963
- /** Hides text on screen but keeps it for screen readers. */
1964
- const VISUALLY_HIDDEN$1 = {
1965
- position: "absolute",
1966
- width: 1,
1967
- height: 1,
1968
- padding: 0,
1969
- margin: -1,
1970
- overflow: "hidden",
1971
- clipPath: "inset(50%)",
1972
- whiteSpace: "nowrap",
1973
- border: 0
1974
- };
1975
- /**
1976
- * A link that opens in a new tab. Screen readers also hear that it opens a
1977
- * new tab.
1978
- */
1979
- function ExternalLink({ href, title, style, children }) {
1980
- return /* @__PURE__ */ jsxs("a", {
1981
- href,
1982
- title,
1983
- target: "_blank",
1984
- rel: "noopener noreferrer",
1985
- style,
1986
- children: [children, /* @__PURE__ */ jsx("span", {
1987
- style: VISUALLY_HIDDEN$1,
1988
- children: " (opens in a new tab)"
1989
- })]
1990
- });
1991
- }
1992
- const DELIMITERS = [
1993
- {
1994
- open: "**",
1995
- tag: "strong"
1996
- },
1997
- {
1998
- open: "~~",
1999
- tag: "s"
2000
- },
2001
- {
2002
- open: "++",
2003
- tag: "u"
2004
- },
2005
- {
2006
- open: "`",
2007
- tag: "code"
2008
- },
2009
- {
2010
- open: "*",
2011
- tag: "em"
2012
- },
2013
- {
2014
- open: "_",
2015
- tag: "em"
2016
- }
2017
- ];
2018
- /** The link that starts at `start` (`[label](url)`), or `null`. */
2019
- function matchLink(text, start) {
2020
- if (text[start] !== "[") return null;
2021
- const close = text.indexOf("](", start + 1);
2022
- if (close < 0) return null;
2023
- const end = text.indexOf(")", close + 2);
2024
- if (end < 0) return null;
2025
- let urlEnd = end;
2026
- if (text.slice(close + 2, end).includes("(")) {
2027
- const next = text.indexOf(")", end + 1);
2028
- if (next < 0) return null;
2029
- urlEnd = next;
2030
- }
2031
- return {
2032
- label: text.slice(start + 1, close),
2033
- url: text.slice(close + 2, urlEnd),
2034
- next: urlEnd + 1
2035
- };
2036
- }
2037
- /**
2038
- * Renders a small set of inline markdown: `**bold**`, `*italic*` and
2039
- * `_italic_`, `~~strike~~`, `++underline++`, `` `code` `` and
2040
- * `[label](url)`.
2041
- *
2042
- * - A marker without a closing partner stays literal text.
2043
- * - A link is a link only for http, https and mailto URLs. For other URLs,
2044
- * only the label shows.
2045
- * - Marks do not nest.
2046
- *
2047
- * @param text - The source text.
2048
- */
2049
- function renderInlineMarkdown(text) {
2050
- if (!text) return text;
2051
- const out = [];
2052
- let buffer = "";
2053
- let key = 0;
2054
- const flush = () => {
2055
- if (buffer) out.push(buffer);
2056
- buffer = "";
2057
- };
2058
- let index = 0;
2059
- while (index < text.length) {
2060
- const link = matchLink(text, index);
2061
- if (link) {
2062
- flush();
2063
- const href = safeHref(link.url);
2064
- out.push(href ? /* @__PURE__ */ jsx(ExternalLink, {
2065
- href,
2066
- children: link.label
2067
- }, key++) : /* @__PURE__ */ jsx(React.Fragment, { children: link.label }, key++));
2068
- index = link.next;
2069
- continue;
1088
+ style: {
1089
+ display: "flex",
1090
+ flexDirection: "column",
1091
+ gap: spacing(3)
1092
+ },
1093
+ children: tab.child
1094
+ }, index) : null)]
1095
+ });
1096
+ }
1097
+ function Spacer(props) {
1098
+ return /* @__PURE__ */ jsx("div", {
1099
+ "aria-hidden": "true",
1100
+ style: {
1101
+ flex: 1,
1102
+ minWidth: spacing(props.minSize ?? 2),
1103
+ minHeight: spacing(props.minSize ?? 2)
2070
1104
  }
2071
- const delimiter = DELIMITERS.find((d) => text.startsWith(d.open, index));
2072
- const isIntraWordUnderscore = delimiter?.open === "_" && /\w/.test(text[index - 1] ?? "");
2073
- if (delimiter && !isIntraWordUnderscore) {
2074
- const start = index + delimiter.open.length;
2075
- const end = text.indexOf(delimiter.open, start);
2076
- const inner = end > start ? text.slice(start, end) : "";
2077
- if (inner !== "" && (delimiter.tag === "code" || inner.trim() === inner)) {
2078
- flush();
2079
- const Tag = delimiter.tag;
2080
- out.push(/* @__PURE__ */ jsx(Tag, { children: inner }, key++));
2081
- index = end + delimiter.open.length;
2082
- continue;
2083
- }
2084
- buffer += delimiter.open;
2085
- index = start;
2086
- continue;
1105
+ });
1106
+ }
1107
+ function Divider(props) {
1108
+ const line = `${props.size ?? 1}px solid ${borderColor(props.color ?? "subtle")}`;
1109
+ const margin = props.flush ? 0 : spacing(props.spacing ?? 2);
1110
+ const isVertical = props.axis === "vertical";
1111
+ return /* @__PURE__ */ jsx("hr", {
1112
+ "aria-orientation": isVertical ? "vertical" : void 0,
1113
+ style: {
1114
+ border: 0,
1115
+ ...isVertical ? {
1116
+ borderLeft: line,
1117
+ margin: `0 ${margin}`,
1118
+ height: "auto"
1119
+ } : {
1120
+ borderTop: line,
1121
+ margin: `${margin} 0`,
1122
+ width: "100%"
1123
+ },
1124
+ flexShrink: 0,
1125
+ flexGrow: props.weight,
1126
+ alignSelf: "stretch"
2087
1127
  }
2088
- buffer += text[index];
2089
- index += 1;
2090
- }
2091
- flush();
2092
- return out.length === 1 && typeof out[0] === "string" ? out[0] : out;
1128
+ });
2093
1129
  }
2094
1130
  /**
2095
- * Full GitHub-flavored markdown, rendered with the same markdown renderer
2096
- * as the chat messages. It has no typography of its own, so it reads like
2097
- * the chat text around the surface. While `streaming` is true, the renderer
2098
- * handles markdown that is not complete yet.
1131
+ * The standard layout components: containers, Spacer and Divider. Give
1132
+ * them to `createGenerativeUI({ components: { ...layoutComponents } })`.
1133
+ * Every container has a "multiple" `children` slot, so it takes a list of
1134
+ * child ids or a template `{ componentId, path }`.
2099
1135
  */
2100
- function Markdown({ text, streaming = false }) {
2101
- useStandardStyles();
2102
- return /* @__PURE__ */ jsx("div", {
2103
- className: "a2ui-markdown",
2104
- "data-a2ui-std": "",
2105
- children: /* @__PURE__ */ jsx(ProviderMarkdown, {
2106
- content: text,
2107
- isStreaming: streaming
2108
- })
2109
- });
2110
- }
1136
+ const layoutComponents = withComponents(layoutDeclarations, {
1137
+ Box,
1138
+ Column,
1139
+ Row,
1140
+ Grid,
1141
+ GridItem,
1142
+ Card,
1143
+ Flow,
1144
+ FlowItem,
1145
+ Carousel,
1146
+ CarouselItem,
1147
+ CarouselMediaItem,
1148
+ Spacer,
1149
+ Divider,
1150
+ Tabs
1151
+ });
2111
1152
 
2112
1153
  //#endregion
2113
1154
  //#region src/generative-ui/standard/media.tsx
2114
- const NO_ARGS$2 = z.object({});
2115
- const colorProp$1 = z.string().optional();
2116
- const ICON_SIZES = [
2117
- "sm",
2118
- "md",
2119
- "lg",
2120
- "xl"
2121
- ];
2122
- const imageSchema = z.object({
2123
- url: z.string().describe("Image URL"),
2124
- description: z.string().optional().describe("What the image shows, for screen readers. Leave it unset only for a decorative image"),
2125
- variant: z.enum([
2126
- "icon",
2127
- "avatar",
2128
- "smallFeature",
2129
- "mediumFeature",
2130
- "largeFeature",
2131
- "header"
2132
- ]).optional().describe("The size: \"icon\" 24px, \"avatar\" 40px round, \"smallFeature\" 160px wide, \"largeFeature\" and \"header\" full width. Default \"mediumFeature\": the natural size"),
2133
- weight: weightProp,
2134
- aspectRatio: z.string().optional(),
2135
- fit: z.enum([
2136
- "cover",
2137
- "contain",
2138
- "fill",
2139
- "none",
2140
- "scaleDown"
2141
- ]).optional().describe("CSS object-fit. Default \"cover\""),
2142
- radius: radiusValue.optional(),
2143
- width: sizeValue.optional(),
2144
- height: sizeValue.optional(),
2145
- maxWidth: sizeValue.optional(),
2146
- maxHeight: sizeValue.optional(),
2147
- minWidth: sizeValue.optional(),
2148
- minHeight: sizeValue.optional(),
2149
- background: z.string().optional(),
2150
- frame: z.boolean().optional(),
2151
- position: z.string().optional().describe("CSS object-position, for example \"top\" or \"50% 20%\""),
2152
- hideOnFailure: z.boolean().optional().describe("Default false"),
2153
- fallback: z.string().optional().describe("Text shown in place of the image when it does not load"),
2154
- hoverZoom: z.boolean().optional().describe("A slight zoom on hover"),
2155
- lightbox: z.boolean().optional().describe("Default true: a click opens the image full-screen"),
2156
- actionOverlay: z.object({
2157
- label: z.string(),
2158
- icon: z.string().optional().describe("Lucide icon name"),
2159
- href: z.string().optional().describe("Opens this URL in a new tab")
2160
- }).optional().describe("A button over the bottom-right corner of the image. Without href, it sends onOverlayClick")
2161
- });
2162
- const iconSchema = z.object({
2163
- name: z.union([z.string(), z.object({ svgPath: z.string() })]).describe("A Lucide icon name in kebab-case (\"arrow-right\"), an A2UI icon name (\"arrowBack\"), or { \"svgPath\" } on a 24px grid"),
2164
- label: z.string().optional().describe("What the icon means, for screen readers. Leave it unset when text next to the icon says the same"),
2165
- size: z.union([z.enum(ICON_SIZES), z.number()]).optional().describe("Default \"md\""),
2166
- color: colorProp$1,
2167
- inline: z.boolean().optional().describe("Default false"),
2168
- strokeWeight: z.enum(WEIGHTS).optional().describe("The stroke width"),
2169
- weight: weightProp
2170
- });
2171
- const faviconSchema = z.object({
2172
- url: z.string(),
2173
- alt: z.string().optional(),
2174
- size: z.number().optional().describe("Pixels. Default 16"),
2175
- inline: z.boolean().optional().describe("Default false"),
2176
- frame: z.boolean().optional().describe("Default false")
2177
- });
2178
- const svgSchema = z.object({
2179
- viewBox: z.string().optional(),
2180
- label: z.string().optional().describe("What the drawing shows, for screen readers. Leave it unset for a decorative drawing"),
2181
- width: sizeValue.optional(),
2182
- height: sizeValue.optional(),
2183
- size: sizeValue.optional(),
2184
- color: colorProp$1.describe("Default \"prose\""),
2185
- fill: colorProp$1.describe("Default \"currentColor\""),
2186
- stroke: colorProp$1,
2187
- strokeWidth: z.number().optional(),
2188
- strokeLinecap: z.enum([
2189
- "butt",
2190
- "round",
2191
- "square"
2192
- ]).optional(),
2193
- strokeLinejoin: z.enum([
2194
- "miter",
2195
- "round",
2196
- "bevel"
2197
- ]).optional(),
2198
- preserveAspectRatio: z.string().optional(),
2199
- paths: z.array(z.object({
2200
- d: z.string(),
2201
- fill: colorProp$1,
2202
- stroke: colorProp$1,
2203
- strokeWidth: z.number().optional()
2204
- })).optional(),
2205
- circles: z.array(z.object({
2206
- cx: z.number(),
2207
- cy: z.number(),
2208
- r: z.number(),
2209
- fill: colorProp$1,
2210
- stroke: colorProp$1
2211
- })).optional(),
2212
- rects: z.array(z.object({
2213
- x: z.number(),
2214
- y: z.number(),
2215
- width: z.number(),
2216
- height: z.number(),
2217
- rx: z.number().optional(),
2218
- fill: colorProp$1,
2219
- stroke: colorProp$1
2220
- })).optional(),
2221
- lines: z.array(z.object({
2222
- x1: z.number(),
2223
- y1: z.number(),
2224
- x2: z.number(),
2225
- y2: z.number(),
2226
- stroke: colorProp$1
2227
- })).optional(),
2228
- texts: z.array(z.object({
2229
- x: z.number(),
2230
- y: z.number(),
2231
- text: z.string(),
2232
- size: z.number().optional(),
2233
- fill: colorProp$1,
2234
- anchor: z.enum([
2235
- "start",
2236
- "middle",
2237
- "end"
2238
- ]).optional()
2239
- })).optional()
2240
- });
2241
- const captionTrack = z.object({
2242
- url: z.string().describe("The URL of a WebVTT file"),
2243
- language: z.string().optional().describe("BCP 47, for example \"en\""),
2244
- label: z.string().optional().describe("Shown in the captions menu"),
2245
- kind: z.enum([
2246
- "subtitles",
2247
- "captions",
2248
- "descriptions"
2249
- ]).optional()
2250
- });
2251
- const videoSchema = z.object({
2252
- url: z.string().describe("The URL of a video file, or of a YouTube video or short. A page on another video site shows as a link"),
2253
- posterUrl: z.string().optional().describe("The image shown before the video plays"),
2254
- title: z.string().optional().describe("Names the video for screen readers"),
2255
- captions: z.array(captionTrack).optional().describe("Caption tracks of a video file"),
2256
- aspectRatio: z.string().optional().describe("Default \"16 / 9\""),
2257
- width: sizeValue.optional().describe("Default \"100%\""),
2258
- maxWidth: sizeValue.optional().describe("Default \"100%\""),
2259
- weight: weightProp
2260
- });
2261
- const audioPlayerSchema = z.object({
2262
- url: z.string().describe("The URL of the audio file"),
2263
- description: z.string().optional().describe("A title or summary of the audio, shown above the player"),
2264
- weight: weightProp
2265
- });
2266
- const htmlViewSchema = z.object({
2267
- html: z.string(),
2268
- height: sizeValue.optional().describe("Pixels when a number. Default 360"),
2269
- width: sizeValue.optional().describe("Default \"100%\""),
2270
- title: z.string().optional()
2271
- });
2272
1155
  /** Pixels when a number, raw CSS when a string. */
2273
1156
  function px$1(value) {
2274
1157
  if (value === void 0) return void 0;
@@ -2290,10 +1173,14 @@ const ICON_STROKE = {
2290
1173
  function kebabToPascal(name) {
2291
1174
  return name.split(/[-_\s]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
2292
1175
  }
1176
+ /** "ArrowRight" gives "arrow-right", as Lucide names its icon classes. */
1177
+ function pascalToKebab(name) {
1178
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1179
+ }
2293
1180
  let lucidePromise = null;
2294
1181
  let lucideIcons = null;
2295
1182
  function loadLucideIcons() {
2296
- lucidePromise ??= import("lucide-react").then((module) => {
1183
+ lucidePromise ??= import("lucide").then((module) => {
2297
1184
  const icons = module.icons;
2298
1185
  lucideIcons = icons;
2299
1186
  return icons;
@@ -2301,9 +1188,9 @@ function loadLucideIcons() {
2301
1188
  return lucidePromise;
2302
1189
  }
2303
1190
  /**
2304
- * lucide-react has about 1,500 icons. A static import of its `icons` map
2305
- * puts all of them in every bundle and makes module load slow. So the map
2306
- * loads once, on first use, and the icons show when it is there.
1191
+ * Lucide has about 1,500 icons. A static import of its `icons` map puts all
1192
+ * of them in every bundle and makes module load slow. So the map loads once,
1193
+ * on first use, and the icons show when it is there.
2307
1194
  */
2308
1195
  function useLucideIcons() {
2309
1196
  const [icons, setIcons] = useState(lucideIcons);
@@ -2319,6 +1206,20 @@ function useLucideIcons() {
2319
1206
  }, []);
2320
1207
  return icons;
2321
1208
  }
1209
+ /** The icon for a kebab-case or PascalCase name, or `null` when there is none. */
1210
+ function findLucideIcon(icons, name) {
1211
+ const pascalName = kebabToPascal(name);
1212
+ const key = pascalName in icons ? pascalName : name in icons ? name : null;
1213
+ if (key === null) return null;
1214
+ const nodes = icons[key].map(([tag, attributes]) => ({
1215
+ tag,
1216
+ attributes
1217
+ }));
1218
+ return {
1219
+ lucideName: pascalToKebab(key),
1220
+ nodes
1221
+ };
1222
+ }
2322
1223
  /**
2323
1224
  * A lucide icon by kebab-case (or PascalCase) name. An unknown name renders
2324
1225
  * nothing. Without a `label`, the icon is hidden from screen readers.
@@ -2331,18 +1232,20 @@ function useLucideIcons() {
2331
1232
  function LucideIcon({ name, label, description, size = "md", color, weight, inline, style }) {
2332
1233
  const icons = useLucideIcons();
2333
1234
  if (!name || !icons) return null;
2334
- const IconComponent = icons[kebabToPascal(name)] ?? icons[name];
2335
- if (!IconComponent) return null;
1235
+ const icon = findLucideIcon(icons, name);
1236
+ if (!icon) return null;
2336
1237
  const pixels = typeof size === "number" ? size : inline ? "1em" : ICON_PX$1[size];
2337
- return /* @__PURE__ */ jsx(IconComponent, {
2338
- ...label === void 0 ? { "aria-hidden": true } : {
2339
- role: "img",
2340
- "aria-label": label,
2341
- "aria-description": description
2342
- },
1238
+ const a11y = label === void 0 ? { "aria-hidden": true } : {
1239
+ role: "img",
1240
+ "aria-label": label,
1241
+ "aria-description": description
1242
+ };
1243
+ return /* @__PURE__ */ jsx(IconSvg, {
1244
+ lucideName: icon.lucideName,
1245
+ nodes: icon.nodes,
1246
+ ...a11y,
2343
1247
  focusable: "false",
2344
- width: pixels,
2345
- height: pixels,
1248
+ size: pixels,
2346
1249
  color: textColor(color) ?? "currentColor",
2347
1250
  strokeWidth: weight ? ICON_STROKE[weight] : void 0,
2348
1251
  style: {
@@ -2971,133 +1874,18 @@ function HtmlView(props) {
2971
1874
  * The standard media components. Give them to
2972
1875
  * `createGenerativeUI({ components: { ...mediaComponents } })`.
2973
1876
  */
2974
- const mediaComponents = {
2975
- Image: {
2976
- component: Image,
2977
- description: "An image from a URL. A click opens it full-screen. Set description to say what the image shows, unless it is only decoration.",
2978
- props: imageSchema,
2979
- events: { onOverlayClick: {
2980
- description: "Sent when the user clicks the actionOverlay button and it has no href.",
2981
- parameters: NO_ARGS$2
2982
- } }
2983
- },
2984
- Icon: {
2985
- component: Icon,
2986
- description: "A Lucide icon by kebab-case name (for example \"arrow-right\"), or an A2UI icon name (for example \"arrowBack\"). Set label when no text next to the icon says what it means.",
2987
- props: iconSchema
2988
- },
2989
- Favicon: {
2990
- component: Favicon,
2991
- description: "The favicon of the site at a URL.",
2992
- props: faviconSchema
2993
- },
2994
- Svg: {
2995
- component: Svg,
2996
- description: "A vector drawing from primitive shapes (paths, circles, rects, lines, texts). Colors take text color tokens or CSS colors.",
2997
- props: svgSchema
2998
- },
2999
- Video: {
3000
- component: Video,
3001
- description: "A video player for a video file URL (with optional captions), or a YouTube link in privacy-enhanced mode: the poster shows first, and the player loads when the user presses play. A page on another video site shows as a link to it. Set title to name the video.",
3002
- props: videoSchema
3003
- },
3004
- AudioPlayer: {
3005
- component: AudioPlayer,
3006
- description: "An audio player for an audio file URL, with the description above it.",
3007
- props: audioPlayerSchema
3008
- },
3009
- HtmlView: {
3010
- component: HtmlView,
3011
- description: "Raw HTML in a fully sandboxed iframe: no scripts, no same-origin access. Set title to name the content.",
3012
- props: htmlViewSchema
3013
- }
3014
- };
1877
+ const mediaComponents = withComponents(mediaDeclarations, {
1878
+ Image,
1879
+ Icon,
1880
+ Favicon,
1881
+ Svg,
1882
+ Video,
1883
+ AudioPlayer,
1884
+ HtmlView
1885
+ });
3015
1886
 
3016
1887
  //#endregion
3017
1888
  //#region src/generative-ui/standard/composites.tsx
3018
- /**
3019
- * The composite components: the prebuilt widgets that sit next to
3020
- * its primitives (LinkCard, Citation, FollowUp pills, entity cards, image
3021
- * grids). Each one is a single component, so the model places it with one
3022
- * object instead of eight primitives.
3023
- */
3024
- const NO_ARGS$1 = z.object({});
3025
- const text = (description) => z.string().optional().describe(description);
3026
- const linkCardSchema = z.object({
3027
- href: z.string().describe("The URL (http, https)"),
3028
- title: z.string().describe("The page title"),
3029
- description: text("One or two lines"),
3030
- image: text("A thumbnail URL"),
3031
- domain: text("Shown next to the favicon. Default: the host of href"),
3032
- favicon: z.boolean().optional().describe("Default true")
3033
- });
3034
- const citationSchema = z.object({
3035
- index: z.number().optional().describe("The marker number. Default 1"),
3036
- label: text("Marker text instead of the number, for example a domain"),
3037
- title: text("The source title"),
3038
- url: text("The source URL (http, https)"),
3039
- snippet: text("The quoted passage, one or two lines"),
3040
- source: text("The publisher or domain. Default: the host of url")
3041
- });
3042
- const followUpItem = z.union([z.string(), z.object({
3043
- label: z.string(),
3044
- message: text("The text sent when the user clicks. Default: label")
3045
- })]);
3046
- const followUpSchema = z.object({
3047
- items: z.array(followUpItem).optional().describe("Strings or { \"label\", \"message\"? }, or { \"@path\": \"/x\" }"),
3048
- title: text("A caption above the pills")
3049
- });
3050
- const followUpArgs = z.object({ message: z.string().describe("The message of the clicked pill") });
3051
- const BADGE_COLORS = [
3052
- "secondary",
3053
- "success",
3054
- "danger",
3055
- "warning",
3056
- "info",
3057
- "discovery"
3058
- ];
3059
- const cardAction = z.object({
3060
- label: z.string(),
3061
- href: text("Opens this URL in a new tab"),
3062
- variant: z.enum([
3063
- "solid",
3064
- "soft",
3065
- "outline",
3066
- "ghost"
3067
- ]).optional()
3068
- });
3069
- const entityCardSchema = z.object({
3070
- title: z.string().describe("The name"),
3071
- subtitle: text("A second line, for example the brand or category"),
3072
- description: text("Up to three lines"),
3073
- image: text("An image URL"),
3074
- imageAspectRatio: z.string().optional().describe("Default \"4 / 3\""),
3075
- meta: text("A short fact line, for example \"$29 / month\" or \"Open until 22:00\""),
3076
- badge: z.object({
3077
- label: z.string(),
3078
- color: z.enum(BADGE_COLORS).optional()
3079
- }).optional(),
3080
- rating: z.number().optional().describe("0 to 5, shown as stars"),
3081
- ratingCount: z.number().optional().describe("The number of ratings"),
3082
- href: text("Opens this URL in a new tab when the user clicks the card"),
3083
- actions: z.array(cardAction).max(3).optional().describe("Up to three buttons. A button without href sends onAction with its label"),
3084
- layout: z.enum(["vertical", "horizontal"]).optional().describe("Default \"vertical\". \"horizontal\" puts the image on the left"),
3085
- width: sizeValue.optional()
3086
- });
3087
- const entityActionArgs = z.object({ label: z.string().describe("The label of the clicked button") });
3088
- const gridImage = z.object({
3089
- url: z.string(),
3090
- description: z.string().optional().describe("What the image shows"),
3091
- caption: z.string().optional(),
3092
- href: text("Opens this URL instead of the full-screen view")
3093
- });
3094
- const imageGridSchema = z.object({
3095
- images: z.array(gridImage).optional().describe("A list of { \"url\", \"description\"?, \"caption\"?, \"href\"? }, or { \"@path\": \"/x\" }"),
3096
- columns: z.number().optional().describe("Default 3"),
3097
- aspectRatio: z.string().optional().describe("Default \"1 / 1\""),
3098
- gap: sizeValue.optional().describe("Default 2"),
3099
- layout: z.enum(["grid", "bento"]).optional().describe("Default \"grid\". \"bento\" makes the first image twice as large")
3100
- });
3101
1889
  function FaviconImage({ host, size = 16 }) {
3102
1890
  return /* @__PURE__ */ jsx("img", {
3103
1891
  src: `https://www.google.com/s2/favicons?domain=${encodeURIComponent(host)}&sz=64`,
@@ -3669,101 +2457,16 @@ function ImageGrid(props) {
3669
2457
  * engine turns it into a visible user message with that text.
3670
2458
  * - EntityCard buttons without href send `onAction` with their label.
3671
2459
  */
3672
- const compositeComponents = {
3673
- LinkCard: {
3674
- component: LinkCard,
3675
- description: "A preview card of a URL: the favicon and domain, the title, a description and a thumbnail. A click opens the link in a new tab, or sends onClick when it is bound. Use it for sources, articles and products that have a page.",
3676
- props: linkCardSchema,
3677
- events: { onClick: {
3678
- description: "Sent when the user clicks the card, instead of the link.",
3679
- parameters: NO_ARGS$1
3680
- } }
3681
- },
3682
- Citation: {
3683
- component: Citation,
3684
- description: "An inline source marker ([1]) that shows the source on hover or click: the title, a snippet and a link. Put it inline after the sentence it supports, as a child of a Text or in a Row.",
3685
- props: citationSchema
3686
- },
3687
- FollowUp: {
3688
- component: FollowUp,
3689
- description: "Suggested next prompts as pills. A click sends the message of the pill as the next turn of the user, with no event binding needed. Put it at the end of a surface, with two to four short items.",
3690
- props: followUpSchema,
3691
- events: { onFollowUp: {
3692
- description: "Sent when the user clicks a pill. The args carry the message of the pill.",
3693
- parameters: followUpArgs
3694
- } }
3695
- },
3696
- EntityCard: {
3697
- component: EntityCard,
3698
- description: "A card for one thing (a product, place, person or listing): an image, title, subtitle, description, a price or meta line, a badge, a rating and up to three buttons. href opens a page, and onClick is sent when it is bound. Use a Grid of EntityCards for several things.",
3699
- props: entityCardSchema,
3700
- events: {
3701
- onClick: {
3702
- description: "Sent when the user clicks the card and it has no href.",
3703
- parameters: NO_ARGS$1
3704
- },
3705
- onAction: {
3706
- description: "Sent when the user clicks a button without href. The args carry the label of the button.",
3707
- parameters: entityActionArgs
3708
- }
3709
- }
3710
- },
3711
- ImageGrid: {
3712
- component: ImageGrid,
3713
- description: "A gallery of images in a grid. A click opens the image full-screen, with arrows to the other images. layout \"bento\" makes the first image twice as large.",
3714
- props: imageGridSchema
3715
- }
3716
- };
2460
+ const compositeComponents = withComponents(compositeDeclarations, {
2461
+ LinkCard,
2462
+ Citation,
2463
+ FollowUp,
2464
+ EntityCard,
2465
+ ImageGrid
2466
+ });
3717
2467
 
3718
2468
  //#endregion
3719
2469
  //#region src/generative-ui/standard/Chart.tsx
3720
- const chartSeries = z.union([z.string(), z.object({
3721
- key: z.string(),
3722
- label: z.string().optional(),
3723
- color: z.string().optional().describe("A text color token or a CSS color")
3724
- })]);
3725
- const chartSchema = z.object({
3726
- chartType: z.enum([
3727
- "bar",
3728
- "line",
3729
- "area",
3730
- "scatter",
3731
- "pie",
3732
- "donut"
3733
- ]).optional().describe("Default \"bar\""),
3734
- data: z.array(z.record(z.string(), z.unknown())).optional().describe("A list of objects, or { \"@path\": \"/x\" }"),
3735
- xKey: z.string().optional().describe("The field of the category axis"),
3736
- series: z.array(chartSeries).optional().describe("The value fields: strings or { \"key\", \"label\"?, \"color\"? }. Default: every number field except xKey"),
3737
- stacked: z.boolean().optional(),
3738
- layout: z.enum(["vertical", "horizontal"]).optional().describe("\"horizontal\" draws the bars from left to right. Default \"vertical\""),
3739
- yAxis: z.object({
3740
- label: z.string().optional(),
3741
- min: z.number().optional(),
3742
- max: z.number().optional(),
3743
- width: z.number().optional().describe("Pixels")
3744
- }).optional().describe("The value axis configuration object: {label?: string, min?: number, max?: number, width?: number}. Example: {label: \"Revenue (USD)\", min: 0, max: 100}. In horizontal charts, label, min and max apply to the horizontal value axis, and width sets the width of the category axis on the left."),
3745
- showDots: z.boolean().optional().describe("Point markers on a line or area"),
3746
- barRadius: z.number().optional().describe("The corner radius of a bar, in pixels"),
3747
- innerRadius: z.union([z.number(), z.string()]).optional().describe("Pie and donut"),
3748
- outerRadius: z.union([z.number(), z.string()]).optional().describe("Pie and donut"),
3749
- startAngle: z.number().optional().describe("Pie and donut. Default 90"),
3750
- endAngle: z.number().optional().describe("Pie and donut. Default -270"),
3751
- cornerRadius: z.number().optional().describe("The corners of a slice"),
3752
- paddingAngle: z.number().optional().describe("The gap between slices"),
3753
- showLabelLines: z.boolean().optional().describe("Leader lines of the slice labels. Default true"),
3754
- height: z.number().optional().describe("Pixels. Default 240"),
3755
- showLegend: z.boolean().optional().describe("Default true"),
3756
- showGrid: z.boolean().optional().describe("Default true"),
3757
- showTooltip: z.boolean().optional().describe("Default true"),
3758
- showValueLabels: z.boolean().optional(),
3759
- format: z.enum([
3760
- "number",
3761
- "currency",
3762
- "percent"
3763
- ]).optional().describe("Number formatting. With \"percent\", data values and axis min/max are fractions: 0.4 displays as 40%. For 0% to 10%, use min: 0 and max: 0.1."),
3764
- currency: z.string().optional().describe("ISO code. Default \"USD\""),
3765
- title: z.string().optional()
3766
- });
3767
2470
  const DEFAULT_HEIGHT = 240;
3768
2471
  /** Hides an element on screen. Screen readers still read it. */
3769
2472
  const VISUALLY_HIDDEN = {
@@ -4166,24 +2869,6 @@ function Chart(props) {
4166
2869
 
4167
2870
  //#endregion
4168
2871
  //#region src/generative-ui/standard/Map.tsx
4169
- const mapMarker = z.object({
4170
- label: z.string(),
4171
- lat: z.number(),
4172
- lng: z.number(),
4173
- category: z.string().optional(),
4174
- icon: z.string().optional()
4175
- });
4176
- const mapSchema = z.object({
4177
- markers: z.array(mapMarker).optional().describe("A list of places, or { \"@path\": \"/x\" }"),
4178
- route: z.boolean().optional().describe("Draws a line through the markers in order"),
4179
- selected: z.string().optional().describe("The label of the selected marker. Bind it with { \"@path\": \"/x\" } to read the choice of the user"),
4180
- height: z.number().optional().describe("Pixels. Default 240"),
4181
- zoom: z.number().optional().describe("With two or more markers, only the highest zoom of the fit"),
4182
- center: z.object({
4183
- lat: z.number(),
4184
- lng: z.number()
4185
- }).optional()
4186
- });
4187
2872
  /**
4188
2873
  * The default basemap: the Positron style of OpenFreeMap. It is a keyless
4189
2874
  * OpenStreetMap vector style with streets and labels at city zoom. A host
@@ -4480,95 +3165,6 @@ function MapView(props) {
4480
3165
 
4481
3166
  //#endregion
4482
3167
  //#region src/generative-ui/standard/data.tsx
4483
- const cellAlign = z.enum([
4484
- "start",
4485
- "center",
4486
- "end"
4487
- ]).optional();
4488
- /**
4489
- * A table cell or column header that shows another component. `id` is an
4490
- * alias of `componentId`.
4491
- */
4492
- const tableComponentCell = z.union([z.object({ componentId: z.string() }), z.object({ id: z.string() })]);
4493
- const tableColumn = z.union([
4494
- z.string(),
4495
- z.object({
4496
- label: z.string(),
4497
- align: cellAlign,
4498
- width: sizeValue.optional(),
4499
- componentId: z.string().optional()
4500
- }),
4501
- tableComponentCell
4502
- ]);
4503
- const tableSchema = z.object({
4504
- caption: z.string().optional().describe("A short name of the table for screen readers. It is not shown"),
4505
- columns: z.array(tableColumn).optional().describe("Strings, { \"label\", \"align\"?, \"width\"?, \"componentId\"? } or { \"componentId\" }, or { \"@path\": \"/x\" }. Default []"),
4506
- rows: z.array(z.array(z.unknown())).optional().describe("A list of row lists, or { \"@path\": \"/x\" }. A cell is a string, a number, or { \"componentId\": \"<id>\" } to show a component. Default []"),
4507
- columnSizing: z.enum(["auto", "equal"]).optional().describe("Default \"auto\""),
4508
- dividers: z.boolean().optional().describe("Default true"),
4509
- stickyHeader: z.boolean().optional().describe("Default false"),
4510
- emptyLabel: z.string().optional().describe("Default \"No rows\"")
4511
- });
4512
- const tableSectionSchema = z.object({
4513
- header: z.boolean().optional().describe("Renders the rows as the header"),
4514
- rowDivider: z.boolean().optional()
4515
- });
4516
- const tableRowSchema = z.object({
4517
- header: z.boolean().optional(),
4518
- label: z.string().optional().describe("The text of a header cell at the start of the row"),
4519
- labelColSpan: z.number().optional().describe("Columns the label cell spans")
4520
- });
4521
- const tableCellSchema = z.object({
4522
- text: z.union([z.string(), z.number()]).optional(),
4523
- header: z.boolean().optional(),
4524
- align: cellAlign,
4525
- vAlign: cellAlign.describe("Default \"start\""),
4526
- colSpan: z.number().optional(),
4527
- rowSpan: z.number().optional(),
4528
- width: sizeValue.optional(),
4529
- padding: sizeValue.optional()
4530
- });
4531
- const listItemValue = z.union([z.string(), z.object({
4532
- label: z.string(),
4533
- description: z.string().optional(),
4534
- icon: z.string().optional().describe("Lucide icon name"),
4535
- value: z.union([z.string(), z.number()]).optional().describe("Without an action: shown on the right of the label, for a key and value fact. With an action: the payload of the pick, not shown")
4536
- })]);
4537
- const listSchema = z.object({
4538
- items: z.array(listItemValue).optional().describe("Strings or { \"label\", \"value\"?, \"description\"?, \"icon\"? }, or { \"@path\": \"/x\" }"),
4539
- direction: z.enum(["vertical", "horizontal"]).optional().describe("Default \"vertical\". \"horizontal\" scrolls sideways"),
4540
- align: z.enum([
4541
- "start",
4542
- "center",
4543
- "end",
4544
- "stretch"
4545
- ]).optional(),
4546
- weight: weightProp,
4547
- marker: z.enum([
4548
- "bullet",
4549
- "number",
4550
- "rich",
4551
- "none"
4552
- ]).optional().describe("Default \"bullet\""),
4553
- connector: z.enum(["none", "solid"]).optional().describe("Default \"none\""),
4554
- gap: sizeValue.optional(),
4555
- start: z.number().optional().describe("The first number of marker \"number\""),
4556
- maxMarkerSize: z.number().optional().describe("The width of the marker column in pixels")
4557
- });
4558
- const listItemSchema = z.object({
4559
- label: z.string().optional(),
4560
- value: z.union([z.string(), z.number()]).optional().describe("Without an action: shown on the right of the label, for a key and value fact"),
4561
- description: z.string().optional(),
4562
- icon: z.string().optional().describe("Lucide icon name"),
4563
- marker: z.string().optional().describe("Shows this text as the marker"),
4564
- markerSize: z.number().optional().describe("The width of the marker column in pixels"),
4565
- disabled: z.boolean().optional().describe("Greys the item out and ignores its action")
4566
- });
4567
- const listSelection = z.object({
4568
- index: z.number(),
4569
- label: z.string(),
4570
- value: z.string().optional()
4571
- });
4572
3168
  const TableContext = createContext(null);
4573
3169
  const V_ALIGN = {
4574
3170
  start: "top",
@@ -4986,69 +3582,16 @@ function ListItem(props) {
4986
3582
  * - Map: `selected` is writable, so a `{ "@path" }` binding gets the choice of
4987
3583
  * the user.
4988
3584
  */
4989
- const dataComponents = {
4990
- Table: {
4991
- component: Table,
4992
- description: "A data table. Put it in a plain Column, not in a Card. Give \"columns\" and \"rows\" (a list of row lists). Or give \"children\": TableSection or TableRow ids, or a template { \"componentId\", \"path\" } that repeats a TableRow for each item of a data list. To show a component (Badge, Button, Icon, Text) in a cell or a column header, set it to { \"componentId\": \"<id>\" } and put the id in \"cellComponents\".",
4993
- props: tableSchema,
4994
- slots: {
4995
- children: "multiple",
4996
- cellComponents: "multiple"
4997
- }
4998
- },
4999
- TableSection: {
5000
- component: TableSection,
5001
- accessibility: "self",
5002
- description: "A group of TableRow children in a Table. With header true, it is the header of the table.",
5003
- props: tableSectionSchema,
5004
- slots: CHILDREN_SLOT
5005
- },
5006
- TableRow: {
5007
- component: TableRow,
5008
- accessibility: "self",
5009
- description: "A row of a Table. Its children are TableCell ids, or a template. With label, a header cell with that text starts the row.",
5010
- props: tableRowSchema,
5011
- slots: CHILDREN_SLOT
5012
- },
5013
- TableCell: {
5014
- component: TableCell,
5015
- accessibility: "self",
5016
- description: "A cell of a TableRow. It shows \"text\", or its children. With header true, it is a header cell.",
5017
- props: tableCellSchema,
5018
- slots: CHILDREN_SLOT
5019
- },
5020
- List: {
5021
- component: List,
5022
- description: "A list in a Card or next to another component. A plain list of text is markdown, not a List. Give \"items\" (strings or { \"label\", \"value\"?, \"description\"?, \"icon\"? }); without an action, an item with a value is a key and value row, for facts like Price: $1,599. Or, when there are no items, give \"children\": ListItem ids or a template. With an \"action\", the user can pick an item: the event context gets \"index\", \"label\" and \"value\" of the item.",
5023
- props: listSchema,
5024
- events: { action: {
5025
- description: "Runs when the user picks an item. The args are the index, label and value of the item.",
5026
- parameters: listSelection
5027
- } },
5028
- slots: CHILDREN_SLOT
5029
- },
5030
- ListItem: {
5031
- component: ListItem,
5032
- description: "An item of a List, with a label, a value on the right, a description, an icon and children. With an \"action\", the user can pick it.",
5033
- props: listItemSchema,
5034
- events: { action: {
5035
- description: "Runs when the user picks the item.",
5036
- parameters: z.object({})
5037
- } },
5038
- slots: CHILDREN_SLOT
5039
- },
5040
- Chart: {
5041
- component: Chart,
5042
- description: "A bar, line, area, scatter, pie or donut chart. \"data\" is a list of objects. \"xKey\" is the field of the category. \"series\" are the value fields.",
5043
- props: chartSchema
5044
- },
5045
- Map: {
5046
- component: MapView,
5047
- description: "A map with markers. With \"route\", a line connects the markers in order. Bind \"selected\" to { \"@path\": \"/x\" } to get the label of the marker that the user picks. When maps are not available, it shows a list of the places.",
5048
- props: mapSchema,
5049
- writable: ["selected"]
5050
- }
5051
- };
3585
+ const dataComponents = withComponents(dataDeclarations, {
3586
+ Table,
3587
+ TableSection,
3588
+ TableRow,
3589
+ TableCell,
3590
+ List,
3591
+ ListItem,
3592
+ Chart,
3593
+ Map: MapView
3594
+ });
5052
3595
 
5053
3596
  //#endregion
5054
3597
  //#region src/generative-ui/standard/feedback.tsx
@@ -5090,41 +3633,6 @@ const BUTTON_RESET = {
5090
3633
  textAlign: "inherit",
5091
3634
  cursor: "pointer"
5092
3635
  };
5093
- const pulseIndicatorSchema = z.object({
5094
- label: z.string().optional().describe("What the dot means, for screen readers. Leave it unset when text next to the dot says the same"),
5095
- color: z.string().optional().describe("Text color token. Default \"success\""),
5096
- size: z.number().optional().describe("Pixels. Default 12"),
5097
- pulseColor: z.string().optional(),
5098
- duration: z.number().optional().describe("Milliseconds. Default 1500"),
5099
- endScale: z.number().optional().describe("Default 2.4"),
5100
- startOpacity: z.number().optional().describe("Default 0.6")
5101
- });
5102
- const flashcardSchema = z.object({
5103
- front: z.string().optional().describe("The text on the front"),
5104
- back: z.string().optional().describe("The text on the back"),
5105
- hint: z.string().optional().describe("A small line under the front, for example \"Click to flip\"")
5106
- });
5107
- const popoverSchema = z.object({
5108
- open: z.boolean().optional().describe("Default false"),
5109
- showOnHover: z.boolean().optional(),
5110
- hoverOpenDelay: z.number().optional().describe("Milliseconds before a hover opens it. Default 0")
5111
- });
5112
- const popoverTriggerSchema = z.object({ block: z.boolean().optional().describe("Full width") });
5113
- const popoverContentSchema = z.object({
5114
- side: z.enum([
5115
- "top",
5116
- "bottom",
5117
- "left",
5118
- "right"
5119
- ]).optional().describe("Default \"bottom\""),
5120
- sideOffset: z.number().optional().describe("Pixels between the trigger and the content. Default 6"),
5121
- align: z.enum([
5122
- "start",
5123
- "center",
5124
- "end"
5125
- ]).optional().describe("Default \"center\""),
5126
- width: sizeValue.optional().describe("4px steps when a number")
5127
- });
5128
3636
  /** A spinning ring. It is decoration: the caller names the status. */
5129
3637
  function PulseIndicator(props) {
5130
3638
  useFeedbackStyles();
@@ -5382,12 +3890,6 @@ function PopoverContent(props) {
5382
3890
  children: props.children
5383
3891
  });
5384
3892
  }
5385
- const modalSchema = z.object({
5386
- title: z.string().optional().describe("The heading of the dialog"),
5387
- open: z.boolean().optional().describe("Default false. Bind it with { \"@path\": \"/x\" } to read it"),
5388
- maxWidth: sizeValue.optional().describe("Default 480"),
5389
- weight: weightProp
5390
- });
5391
3893
  const FOCUSABLE = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),iframe,video[controls],audio[controls],[tabindex]:not([tabindex=\"-1\"])";
5392
3894
  /**
5393
3895
  * A control, enabled or not: a disabled Button, or a Pressable (a div with
@@ -5587,107 +4089,18 @@ function Modal(props) {
5587
4089
  * "multiple" `children` slot. Popover `open` is writable, so the component
5588
4090
  * gets a `setOpen` prop.
5589
4091
  */
5590
- const feedbackComponents = {
5591
- PulseIndicator: {
5592
- component: PulseIndicator,
5593
- description: "A small dot that pulses, for example next to the text \"Live\". Set label when no text next to the dot says what it means.",
5594
- props: pulseIndicatorSchema
5595
- },
5596
- FlashcardFlip: {
5597
- component: FlashcardFlip,
5598
- description: "A card that shows the front text. A click or the Enter key flips it to the back text, and again to the front.",
5599
- props: flashcardSchema
5600
- },
5601
- Popover: {
5602
- component: Popover,
5603
- description: "A small overlay next to a trigger. Put exactly two children in it: one PopoverTrigger, then one PopoverContent. A click on the trigger opens and closes the content. Escape or a click outside closes it.",
5604
- props: popoverSchema,
5605
- slots: CHILDREN_SLOT,
5606
- writable: ["open"]
5607
- },
5608
- PopoverTrigger: {
5609
- component: PopoverTrigger,
5610
- description: "The trigger of a Popover. Its children are the label of the trigger: a Text or an Icon. Do not put a Button in it, because the trigger is already a button.",
5611
- props: popoverTriggerSchema,
5612
- slots: CHILDREN_SLOT
5613
- },
5614
- PopoverContent: {
5615
- component: PopoverContent,
5616
- description: "The body of a Popover. It shows only when the Popover is open.",
5617
- props: popoverContentSchema,
5618
- slots: CHILDREN_SLOT
5619
- },
5620
- Modal: {
5621
- component: Modal,
5622
- description: "A dialog over the page. A click on the trigger (a Button or a Text) opens the content in the dialog. Escape, the close button or a click on the backdrop closes it.",
5623
- props: modalSchema,
5624
- slots: {
5625
- trigger: "single",
5626
- content: "single"
5627
- },
5628
- writable: ["open"]
5629
- }
5630
- };
4092
+ const feedbackComponents = withComponents(feedbackDeclarations, {
4093
+ PulseIndicator,
4094
+ FlashcardFlip,
4095
+ Popover,
4096
+ PopoverTrigger,
4097
+ PopoverContent,
4098
+ Modal
4099
+ });
5631
4100
 
5632
4101
  //#endregion
5633
4102
  //#region src/generative-ui/standard/checks.ts
5634
4103
  /**
5635
- * The `checks` of the A2UI 1.0 `Checkable` components. The model writes
5636
- * each condition as a validator call or a boolean binding:
5637
- * `{ "condition": { "@call": "email", "args": { "value": { "@path": "/form/email" } } }, "message": "..." }`.
5638
- * The engine resolves the condition before the component renders, so a
5639
- * component sees a boolean or a `ValidationResult`.
5640
- */
5641
- const severity = z.enum([
5642
- "error",
5643
- "warning",
5644
- "info"
5645
- ]);
5646
- const validationResult = z.object({
5647
- valid: z.boolean(),
5648
- message: z.string().optional(),
5649
- code: z.string().optional(),
5650
- severity: severity.optional()
5651
- }).passthrough();
5652
- const checksProp = z.array(z.object({
5653
- condition: z.union([z.boolean(), validationResult]).optional().describe("A validator call, for example {\"@call\":\"required\",\"args\":{\"value\":{\"@path\":\"/x\"}}}, or a boolean binding"),
5654
- message: z.string().optional().describe("Shown when the check fails, instead of the default message")
5655
- })).optional().describe("Validation rules. The control shows the first failed one");
5656
- /**
5657
- * The failed check to show, or `undefined` when every check passes: the
5658
- * first error, or the first warning or info when no check is an error, so
5659
- * a warning never hides an error that comes after it. A condition that is
5660
- * not known yet (undefined) passes. A `false` condition is an error with
5661
- * the check's message. The check's message also wins over the message of
5662
- * a validator result: the built-in validators always have one, and the
5663
- * check is where the model puts its own wording.
5664
- */
5665
- function firstFailedCheck(checks) {
5666
- let first;
5667
- for (const check of checks ?? []) {
5668
- const { condition } = check;
5669
- if (condition === void 0 || condition === null) continue;
5670
- let failed;
5671
- if (typeof condition === "boolean") {
5672
- if (condition) continue;
5673
- failed = {
5674
- message: check.message ?? "Invalid value",
5675
- severity: "error"
5676
- };
5677
- } else {
5678
- if (condition.valid) continue;
5679
- failed = {
5680
- message: check.message ?? condition.message ?? "Invalid value",
5681
- severity: condition.severity ?? "error",
5682
- ...condition.code === void 0 ? {} : { code: condition.code }
5683
- };
5684
- }
5685
- if (failed.severity === "error") return failed;
5686
- first ??= failed;
5687
- }
5688
- return first;
5689
- }
5690
- /**
5691
4104
  * The check state of a control: the failed check to show, whether the
5692
4105
  * control is invalid, and the blur handler that marks it as touched. The
5693
4106
  * message shows only once the user has been in the control, or when it has
@@ -5705,13 +4118,6 @@ function useChecks(checks, value) {
5705
4118
  onBlur: () => setTouched(true)
5706
4119
  };
5707
4120
  }
5708
- /** The style of a check message, by its severity. */
5709
- function checkMessageStyle(severity) {
5710
- return {
5711
- ...textFont("sm"),
5712
- color: textColor(severity === "error" ? "danger" : severity === "warning" ? "warning" : "secondary")
5713
- };
5714
- }
5715
4121
 
5716
4122
  //#endregion
5717
4123
  //#region src/generative-ui/standard/inputs.tsx
@@ -5724,223 +4130,6 @@ async function copyText(text) {
5724
4130
  return false;
5725
4131
  }
5726
4132
  }
5727
- /**
5728
- * The arguments of a click or submit event: none. The model adds values
5729
- * with the `context` of its `{ "event": ... }` binding.
5730
- */
5731
- const NO_ARGS = z.object({});
5732
- /** A list of choices: plain strings or `{ value, label, description? }`. */
5733
- const optionList = z.array(z.union([z.string(), z.object({
5734
- value: z.string(),
5735
- label: z.string().optional(),
5736
- description: z.string().optional()
5737
- })])).optional().describe("Strings or { \"value\", \"label\", \"description\"? }");
5738
- const SIZES = [
5739
- "sm",
5740
- "md",
5741
- "lg",
5742
- "xl"
5743
- ];
5744
- const size = (fallback) => z.enum(SIZES).optional().describe(`Default "${fallback}"`);
5745
- const pill = z.boolean().optional().describe("Default true");
5746
- const fieldLabel = z.string().optional().describe("The visible label of the field. Always set it");
5747
- const boundValue = z.string().optional().describe("Bind it with { \"@path\": \"/x\" } to read what the user entered");
5748
- const buttonSchema = z.object({
5749
- label: z.string().optional().describe("The button text"),
5750
- checks: checksProp,
5751
- text: z.string().optional().describe("Same as label. Used when label is not set"),
5752
- variant: z.enum([
5753
- "default",
5754
- "primary",
5755
- "soft",
5756
- "borderless"
5757
- ]).optional().describe("Default \"default\": outlined. \"primary\" is filled, for the one main action. \"borderless\" has no box, like a link"),
5758
- color: z.enum([
5759
- "primary",
5760
- "secondary",
5761
- "danger"
5762
- ]).optional().describe("Default \"primary\""),
5763
- size: z.enum([
5764
- "sm",
5765
- "md",
5766
- "lg"
5767
- ]).optional().describe("Default \"lg\""),
5768
- block: z.boolean().optional().describe("Full width"),
5769
- weight: weightProp,
5770
- pill,
5771
- disabled: z.boolean().optional(),
5772
- loading: z.boolean().optional(),
5773
- submit: z.boolean().optional().describe("Submits the Form around it. The Form sends its onSubmit event"),
5774
- icon: z.string().optional().describe("Lucide icon name"),
5775
- uniform: z.boolean().optional().describe("A square button, for an icon"),
5776
- href: z.string().optional().describe("Opens this URL in a new tab on click, instead of onClick"),
5777
- copy: z.string().optional().describe("Copies this text to the clipboard on click and shows a check mark, instead of onClick")
5778
- });
5779
- const pressableSchema = z.object({
5780
- ...layoutProps,
5781
- disabled: z.boolean().optional(),
5782
- hoverBackground: z.string().optional(),
5783
- href: z.string().optional().describe("Opens this URL in a new tab on click, instead of onClick"),
5784
- tooltip: z.string().optional().describe("Shown on hover"),
5785
- ariaPressed: z.boolean().optional().describe("For a toggle"),
5786
- insetBorder: z.boolean().optional().describe("A 1px border inside the box")
5787
- });
5788
- const formSchema = z.object({
5789
- ...layoutProps,
5790
- label: z.string().optional().describe("A short name of the form for screen readers")
5791
- });
5792
- const textFieldSchema = z.object({
5793
- checks: checksProp,
5794
- value: z.union([z.string(), z.number()]).optional().describe("Bind it with { \"@path\": \"/x\" } to read what the user typed"),
5795
- placeholder: z.string().optional(),
5796
- label: fieldLabel,
5797
- variant: z.enum([
5798
- "shortText",
5799
- "longText",
5800
- "number",
5801
- "obscured",
5802
- "email",
5803
- "url",
5804
- "tel"
5805
- ]).optional().describe("Default \"shortText\". \"longText\" is a multi-line field, \"obscured\" a password"),
5806
- weight: weightProp,
5807
- name: z.string().optional(),
5808
- required: z.boolean().optional(),
5809
- disabled: z.boolean().optional(),
5810
- invalid: z.boolean().optional(),
5811
- size: size("xl"),
5812
- pill,
5813
- autoSelect: z.boolean().optional(),
5814
- mask: z.string().optional()
5815
- });
5816
- const textAreaSchema = z.object({
5817
- checks: checksProp,
5818
- value: boundValue,
5819
- placeholder: z.string().optional(),
5820
- label: fieldLabel,
5821
- weight: weightProp,
5822
- rows: z.number().optional().describe("Default 3"),
5823
- maxRows: z.number().optional(),
5824
- autoResize: z.boolean().optional(),
5825
- name: z.string().optional(),
5826
- required: z.boolean().optional(),
5827
- disabled: z.boolean().optional(),
5828
- invalid: z.boolean().optional(),
5829
- size: size("xl")
5830
- });
5831
- const selectSchema = z.object({
5832
- checks: checksProp,
5833
- value: boundValue,
5834
- options: optionList,
5835
- placeholder: z.string().optional(),
5836
- label: fieldLabel,
5837
- name: z.string().optional(),
5838
- required: z.boolean().optional(),
5839
- disabled: z.boolean().optional(),
5840
- clearable: z.boolean().optional(),
5841
- clearLabel: z.string().optional().describe("The label of the empty option"),
5842
- searchable: z.boolean().optional(),
5843
- icon: z.string().optional().describe("Lucide icon shown before the value"),
5844
- block: z.boolean().optional().describe("Full width"),
5845
- size: size("xl"),
5846
- pill
5847
- });
5848
- const checkBoxSchema = z.object({
5849
- checks: checksProp,
5850
- value: z.boolean().optional().describe("True when checked. Bind it with { \"@path\": \"/x\" } to read the state of the box"),
5851
- label: z.string().optional().describe("The label text. Always set it"),
5852
- name: z.string().optional(),
5853
- weight: weightProp,
5854
- disabled: z.boolean().optional(),
5855
- required: z.boolean().optional(),
5856
- lineThrough: z.boolean().optional().describe("Default false. Strikes the label when the box is checked"),
5857
- shape: z.enum(["round", "square"]).optional().describe("Default \"round\"")
5858
- });
5859
- const radioSchema = z.object({
5860
- value: z.string().optional(),
5861
- label: z.string().optional(),
5862
- disabled: z.boolean().optional(),
5863
- required: z.boolean().optional()
5864
- });
5865
- const radioGroupSchema = z.object({
5866
- checks: checksProp,
5867
- value: boundValue,
5868
- options: optionList,
5869
- label: fieldLabel,
5870
- name: z.string().optional(),
5871
- direction: z.enum(["row", "col"]).optional().describe("Default \"row\""),
5872
- variant: z.enum([
5873
- "list",
5874
- "pills",
5875
- "cards"
5876
- ]).optional(),
5877
- disabled: z.boolean().optional(),
5878
- required: z.boolean().optional()
5879
- });
5880
- const sliderSchema = z.object({
5881
- checks: checksProp,
5882
- value: z.number().optional().describe("Bind it with { \"@path\": \"/x\" } to read the number"),
5883
- min: z.number().optional().describe("Default 0"),
5884
- max: z.number().optional().describe("Default 100"),
5885
- step: z.number().optional().describe("Default 1"),
5886
- steps: z.number().int().min(1).optional().describe("The number of equal divisions between min and max, instead of step"),
5887
- label: fieldLabel,
5888
- weight: weightProp,
5889
- unit: z.string().optional().describe("Unit after the value, for example \"%\""),
5890
- marks: z.array(z.object({
5891
- value: z.number(),
5892
- label: z.string().optional()
5893
- })).optional(),
5894
- sliderStyle: z.enum(["continuous", "discrete"]).optional().describe("Default \"continuous\""),
5895
- disabled: z.boolean().optional(),
5896
- name: z.string().optional()
5897
- });
5898
- const segmentedControlSchema = z.object({
5899
- checks: checksProp,
5900
- value: boundValue,
5901
- options: optionList,
5902
- label: fieldLabel,
5903
- block: z.boolean().optional().describe("Full width"),
5904
- size: size("lg"),
5905
- pill,
5906
- variant: z.enum([
5907
- "solid",
5908
- "soft",
5909
- "outline",
5910
- "ghost"
5911
- ]).optional().describe("Default \"ghost\""),
5912
- disabled: z.boolean().optional()
5913
- });
5914
- const choicePickerSchema = z.object({
5915
- checks: checksProp,
5916
- value: z.array(z.string()).optional().describe("The chosen option values. Bind it with { \"@path\": \"/x\" } to a string list"),
5917
- options: optionList,
5918
- label: fieldLabel,
5919
- variant: z.enum(["multipleSelection", "mutuallyExclusive"]).optional().describe("Default \"mutuallyExclusive\": the user picks one option"),
5920
- displayStyle: z.enum(["checkbox", "chips"]).optional().describe("Default \"checkbox\". \"chips\" shows the options as pills"),
5921
- filterable: z.boolean().optional().describe("Default false. Shows a field that filters the options"),
5922
- weight: weightProp,
5923
- disabled: z.boolean().optional(),
5924
- required: z.boolean().optional()
5925
- });
5926
- const dateTimeInputSchema = z.object({
5927
- checks: checksProp,
5928
- value: z.string().optional().describe("ISO 8601: \"YYYY-MM-DD\", \"HH:MM\" or \"YYYY-MM-DDTHH:MM\". Bind it with { \"@path\": \"/x\" }"),
5929
- label: fieldLabel,
5930
- enableDate: z.boolean().optional().describe("The user picks a date. Default true unless only enableTime is set"),
5931
- enableTime: z.boolean().optional().describe("The user picks a time"),
5932
- timeStep: z.number().int().min(1).max(720).optional().describe("Minutes between the times the user can pick, e.g. 15 or 30. Shows the time as a list"),
5933
- weight: weightProp,
5934
- min: z.string().optional().describe("The earliest value, ISO 8601"),
5935
- max: z.string().optional().describe("The latest value, ISO 8601"),
5936
- placeholder: z.string().optional(),
5937
- disabled: z.boolean().optional(),
5938
- required: z.boolean().optional(),
5939
- clearable: z.boolean().optional(),
5940
- block: z.boolean().optional().describe("Full width")
5941
- });
5942
- /** The writable list of a control that keeps its state in `value`. */
5943
- const VALUE_WRITABLE = ["value"];
5944
4133
  const HEIGHT = {
5945
4134
  sm: 28,
5946
4135
  md: 32,
@@ -6349,7 +4538,7 @@ function dateTimeMode(props) {
6349
4538
  /** The date and the time of an ISO 8601 value: a date, a time, or both. */
6350
4539
  function splitDateTime(value) {
6351
4540
  const [head, tail] = value.split("T");
6352
- if (tail !== void 0) return {
4541
+ if (head !== void 0 && tail !== void 0) return {
6353
4542
  date: head,
6354
4543
  time: tail
6355
4544
  };
@@ -6410,7 +4599,7 @@ function fullTime(time) {
6410
4599
  }
6411
4600
  /** The minute of the day of a time, rounded up to a whole minute. */
6412
4601
  function timeToMinute(time) {
6413
- const [hours, minutes, seconds] = fullTime(time).split(":").map(Number);
4602
+ const [hours = NaN, minutes = NaN, seconds = NaN] = fullTime(time).split(":").map(Number);
6414
4603
  return hours * 60 + minutes + (seconds > 0 ? 1 : 0);
6415
4604
  }
6416
4605
  /**
@@ -7036,8 +5225,10 @@ function SegmentedControl(props) {
7036
5225
  const onKeyDown = (event, index) => {
7037
5226
  const next = nextOptionIndex(event.key, index, options.length);
7038
5227
  if (next === void 0) return;
5228
+ const option = options[next];
5229
+ if (option === void 0) return;
7039
5230
  event.preventDefault();
7040
- props.setValue(options[next].value);
5231
+ props.setValue(option.value);
7041
5232
  segments.current[next]?.focus();
7042
5233
  };
7043
5234
  return /* @__PURE__ */ jsx(Field, {
@@ -7183,226 +5374,24 @@ function Slider(props) {
7183
5374
  * When the model binds it to `{ "@path": "/x" }`, what the user enters goes
7184
5375
  * into the data model at that path, and the agent can no longer change it.
7185
5376
  */
7186
- const inputComponents = {
7187
- Button: {
7188
- component: Button,
7189
- description: "A button that sends its onClick event. With href it opens the URL, and with copy it copies the text, both without the agent. Use variant \"primary\" for the one main Button in a Row, and the default for the others. With submit true inside a Form, it submits the Form. The child or children render instead of the label. With checks, it is disabled while a check fails.",
7190
- props: buttonSchema,
7191
- events: { onClick: {
7192
- description: "Sent when the user clicks the button.",
7193
- parameters: NO_ARGS
7194
- } },
7195
- slots: {
7196
- child: "single",
7197
- children: "multiple"
7198
- }
7199
- },
7200
- Pressable: {
7201
- component: Pressable,
7202
- description: "A layout container that the user can click or press with Enter or Space. It sends its onClick event, or opens href. A control inside it sends only its own event.",
7203
- props: pressableSchema,
7204
- events: {
7205
- ...VISIBLE_EVENT,
7206
- onClick: {
7207
- description: "Sent when the user clicks or presses the container.",
7208
- parameters: NO_ARGS
7209
- }
7210
- },
7211
- slots: CHILDREN_SLOT
7212
- },
7213
- Form: {
7214
- component: Form,
7215
- description: "A layout container that is a form. It sends its onSubmit event when the user submits it (a Button with submit true, or Enter in a field). Put the values of its fields in the event context with { \"@path\": \"/x\" }.",
7216
- props: formSchema,
7217
- events: { onSubmit: {
7218
- description: "Sent when the user submits the form.",
7219
- parameters: NO_ARGS
7220
- } },
7221
- slots: CHILDREN_SLOT
7222
- },
7223
- TextField: {
7224
- component: TextField,
7225
- description: "A text input, single-line unless variant is \"longText\". Bind value with { \"@path\": \"/x\" } to read what the user typed. Give it a label.",
7226
- props: textFieldSchema,
7227
- writable: VALUE_WRITABLE
7228
- },
7229
- TextArea: {
7230
- component: TextArea,
7231
- description: "A multi-line text input. Bind value with { \"@path\": \"/x\" } to read what the user typed. Give it a label.",
7232
- props: textAreaSchema,
7233
- writable: VALUE_WRITABLE
7234
- },
7235
- Select: {
7236
- component: Select,
7237
- description: "A dropdown list of options. Bind value with { \"@path\": \"/x\" } to read the chosen option. Give it a label.",
7238
- props: selectSchema,
7239
- writable: VALUE_WRITABLE
7240
- },
7241
- CheckBox: {
7242
- component: CheckBox,
7243
- description: "A checkbox with a label. Bind value with { \"@path\": \"/x\" } to read its state, true or false.",
7244
- props: checkBoxSchema,
7245
- writable: VALUE_WRITABLE
7246
- },
7247
- Radio: {
7248
- component: Radio,
7249
- description: "One radio button. Use RadioGroup instead, because it keeps the chosen value.",
7250
- props: radioSchema
7251
- },
7252
- RadioGroup: {
7253
- component: RadioGroup,
7254
- description: "A group of radio buttons. The user chooses one option. Bind value with { \"@path\": \"/x\" } to read it. Give it a label.",
7255
- props: radioGroupSchema,
7256
- writable: VALUE_WRITABLE
7257
- },
7258
- Slider: {
7259
- component: Slider,
7260
- description: "A range slider for a number between min and max. Bind value with { \"@path\": \"/x\" } to read the number. Give it a label.",
7261
- props: sliderSchema,
7262
- writable: VALUE_WRITABLE
7263
- },
7264
- SegmentedControl: {
7265
- component: SegmentedControl,
7266
- description: "A row of segments. The user chooses one option. Use it for 2 to 5 short options. Bind value with { \"@path\": \"/x\" } to read it.",
7267
- props: segmentedControlSchema,
7268
- writable: VALUE_WRITABLE
7269
- },
7270
- ChoicePicker: {
7271
- component: ChoicePicker,
7272
- description: "A list of options, as checkboxes or chips. The user picks one, or several with variant \"multipleSelection\". Bind value with { \"@path\": \"/x\" } to read the chosen values as a list. Give it a label.",
7273
- props: choicePickerSchema,
7274
- writable: VALUE_WRITABLE
7275
- },
7276
- DateTimeInput: {
7277
- component: DateTimeInput,
7278
- description: "A date picker, or a time picker with enableTime, or both. Set timeStep (minutes) to offer fixed times, e.g. 30 for a booking. The value is ISO 8601. Bind value with { \"@path\": \"/x\" } to read it. Give it a label.",
7279
- props: dateTimeInputSchema,
7280
- writable: VALUE_WRITABLE
7281
- }
7282
- };
5377
+ const inputComponents = withComponents(inputDeclarations, {
5378
+ Button,
5379
+ Pressable,
5380
+ Form,
5381
+ TextField,
5382
+ TextArea,
5383
+ Select,
5384
+ CheckBox,
5385
+ Radio,
5386
+ RadioGroup,
5387
+ Slider,
5388
+ SegmentedControl,
5389
+ ChoicePicker,
5390
+ DateTimeInput
5391
+ });
7283
5392
 
7284
5393
  //#endregion
7285
5394
  //#region src/generative-ui/standard/text.tsx
7286
- const colorProp = z.string().optional().describe(`One of ${TEXT_COLORS.join("|")} or a CSS color`);
7287
- const fontWeight = z.enum(WEIGHTS).optional();
7288
- const textAlign = z.enum([
7289
- "start",
7290
- "center",
7291
- "end"
7292
- ]).optional();
7293
- const typographyProps = {
7294
- color: colorProp,
7295
- fontWeight,
7296
- textAlign,
7297
- italic: z.boolean().optional(),
7298
- truncate: z.boolean().optional(),
7299
- maxLines: z.number().optional(),
7300
- tabularNums: z.boolean().optional(),
7301
- width: sizeValue.optional()
7302
- };
7303
- z.object(typographyProps);
7304
- const titleSchema = z.object({
7305
- ...typographyProps,
7306
- text: z.string().describe("Heading text"),
7307
- size: z.enum(TITLE_SIZES).optional().describe("Default \"md\""),
7308
- strong: z.boolean().optional().describe("Default true")
7309
- });
7310
- const textSchema = z.object({
7311
- ...typographyProps,
7312
- weight: weightProp,
7313
- text: z.union([z.string(), z.number()]).optional().describe("Text with inline markdown. A bound number shows as text"),
7314
- size: z.enum(TEXT_SIZES).optional().describe("Default \"md\""),
7315
- fontSize: sizeValue.optional().describe("Pixels when a number. Wins over size"),
7316
- lineHeight: z.union([z.number(), z.string()]).optional().describe("A unitless ratio, or CSS"),
7317
- minLines: z.number().optional().describe("Reserves the height of this many lines"),
7318
- strong: z.boolean().optional().describe("Default false"),
7319
- underline: z.boolean().optional(),
7320
- lineThrough: z.boolean().optional(),
7321
- inline: z.boolean().optional(),
7322
- preserveWhitespace: z.boolean().optional(),
7323
- highlight: z.union([z.enum([
7324
- "green",
7325
- "orange",
7326
- "pink"
7327
- ]), z.boolean()]).optional()
7328
- });
7329
- const captionSchema = z.object({
7330
- text: z.union([z.string(), z.number()]).describe("Caption text"),
7331
- color: colorProp,
7332
- size: z.enum([
7333
- "sm",
7334
- "md",
7335
- "lg"
7336
- ]).optional().describe("Default \"lg\""),
7337
- fontWeight: fontWeight.describe("Default \"normal\""),
7338
- textAlign,
7339
- truncate: z.boolean().optional(),
7340
- maxLines: z.number().optional()
7341
- });
7342
- const labelSchema = z.object({
7343
- text: z.union([z.string(), z.number()]).describe("Label text"),
7344
- htmlFor: z.string().optional(),
7345
- color: colorProp,
7346
- size: z.enum(TEXT_SIZES).optional().describe("Default \"sm\""),
7347
- fontWeight: fontWeight.describe("Default \"medium\""),
7348
- textAlign,
7349
- truncate: z.boolean().optional(),
7350
- width: sizeValue.optional()
7351
- });
7352
- const boldSchema = z.object({
7353
- text: z.string(),
7354
- fontWeight
7355
- });
7356
- const inlineTextSchema = z.object({ text: z.string() });
7357
- const blockquoteSchema = z.object({ text: z.string().describe("The quoted text, with inline markdown") });
7358
- const badgeSchema = z.object({
7359
- label: z.string().describe("Badge text"),
7360
- color: z.enum([
7361
- "secondary",
7362
- "success",
7363
- "danger",
7364
- "warning",
7365
- "info",
7366
- "discovery"
7367
- ]).optional().describe("Default \"secondary\""),
7368
- size: z.enum([
7369
- "sm",
7370
- "md",
7371
- "lg"
7372
- ]).optional().describe("Default \"md\""),
7373
- pill: z.boolean().optional().describe("Default true"),
7374
- variant: z.enum([
7375
- "soft",
7376
- "solid",
7377
- "outline"
7378
- ]).optional().describe("Default \"soft\""),
7379
- fontWeight: fontWeight.describe("Default \"medium\""),
7380
- maxWidth: sizeValue.optional(),
7381
- padding: sizeValue.optional()
7382
- });
7383
- const codeSchema = z.object({
7384
- text: z.string().describe("Source code"),
7385
- language: z.string().optional()
7386
- });
7387
- const markdownSchema = z.object({
7388
- text: z.string().describe("Markdown source"),
7389
- streaming: z.boolean().optional().describe("Default false")
7390
- });
7391
- const mathSchema = z.object({
7392
- value: z.string().describe("TeX source"),
7393
- block: z.boolean().optional().describe("Default false")
7394
- });
7395
- const shimmerSchema = z.object({
7396
- ...typographyProps,
7397
- text: z.string(),
7398
- size: z.enum(TEXT_SIZES).optional().describe("Default \"md\""),
7399
- lineThrough: z.boolean().optional()
7400
- });
7401
- const linkSchema = z.object({
7402
- text: z.string().describe("Link text"),
7403
- href: z.string().describe("URL"),
7404
- title: z.string().optional()
7405
- });
7406
5395
  const FOCUS_RING = "2px solid var(--a2ui-color-focus, #0285ff)";
7407
5396
  const TEXT_STYLE_ID = "a2ui-standard-text";
7408
5397
  const TEXT_CSS = [
@@ -7775,322 +5764,28 @@ function Tooltip({ trigger, content }) {
7775
5764
  * - Tooltip has two "single" slots: `trigger` and `content`.
7776
5765
  * - Link is a plain link. It opens http, https and mailto URLs only.
7777
5766
  */
7778
- const textComponents = {
7779
- Title: {
7780
- component: Title,
7781
- description: "A heading inside a Card or next to another component. A heading alone is markdown outside the fence. Use size \"2xl\" at most once in a surface, and \"lg\" for section headings. Size \"sm\" is an h4, \"md\" and \"lg\" are an h3 (default \"md\"), \"xl\" and larger are an h2. It is bold unless strong is false.",
7782
- props: titleSchema
7783
- },
7784
- Text: {
7785
- component: Text,
7786
- description: "Body text inside a Card or next to another component. A paragraph alone is markdown outside the fence. Use color \"default\" or \"secondary\". `text` can have inline markdown: **bold**, *italic*, ~~strike~~, ++underline++, `code` and [link](https://example.com). The `children` ids render inline after the text, for example a Badge.",
7787
- props: textSchema,
7788
- slots: CHILDREN_SLOT
7789
- },
7790
- Caption: {
7791
- component: Caption,
7792
- description: "Small secondary text: a hint under a control, or a label in a Row. `text` can have inline markdown.",
7793
- props: captionSchema
7794
- },
7795
- Label: {
7796
- component: Label,
7797
- description: "The label of a form field.",
7798
- props: labelSchema
7799
- },
7800
- Bold: {
7801
- component: Bold,
7802
- description: "Bold inline text.",
7803
- props: boldSchema
7804
- },
7805
- Italic: {
7806
- component: Italic,
7807
- description: "Italic inline text.",
7808
- props: inlineTextSchema
7809
- },
7810
- Underline: {
7811
- component: Underline,
7812
- description: "Underlined inline text.",
7813
- props: inlineTextSchema
7814
- },
7815
- Strikethrough: {
7816
- component: Strikethrough,
7817
- description: "Struck-through inline text.",
7818
- props: inlineTextSchema
7819
- },
7820
- Badge: {
7821
- component: Badge,
7822
- description: "A small status pill. Use the colors success, danger and warning only to show a status, not for decoration.",
7823
- props: badgeSchema
7824
- },
7825
- Blockquote: {
7826
- component: Blockquote,
7827
- description: "A block quotation with a line on the left. `text` can have inline markdown.",
7828
- props: blockquoteSchema
7829
- },
7830
- Code: {
7831
- component: Code,
7832
- description: "A block of code in a monospace font.",
7833
- props: codeSchema
7834
- },
7835
- Markdown: {
7836
- component: Markdown,
7837
- description: "A block of GitHub-flavored markdown. Use it only next to other components, for example in a table cell or next to a chart. Markdown alone goes outside the fence.",
7838
- props: markdownSchema
7839
- },
7840
- Math: {
7841
- component: MathFormula,
7842
- description: "A TeX math formula, typeset with KaTeX. Set block to true for a centered formula on its own line.",
7843
- props: mathSchema
7844
- },
7845
- ShimmerText: {
7846
- component: ShimmerText,
7847
- description: "Text with a moving shimmer. It shows that something is loading or pending.",
7848
- props: shimmerSchema
7849
- },
7850
- Link: {
7851
- component: Link,
7852
- description: "A link. Only http, https and mailto URLs work. It opens in a new tab.",
7853
- props: linkSchema
7854
- },
7855
- Tooltip: {
7856
- component: Tooltip,
7857
- description: "Shows `content` when the user points at `trigger` or moves keyboard focus to it. `trigger` is one child id: a Text, Icon or Badge, not a Button or Link. `content` is one child id of short text, for example a Text. Do not put links or buttons in `content`.",
7858
- slots: {
7859
- trigger: "single",
7860
- content: "single"
7861
- }
7862
- }
7863
- };
7864
-
7865
- //#endregion
7866
- //#region src/generative-ui/standard/parameter-order.ts
7867
- /** CopilotKit catalog design, not an A2UI-mandated list of signatures.
7868
- * Express maps positional arguments using the exported JSON Schema property order:
7869
- * https://a2ui.org/specification/proposals/express/a2ui_express/#schema-driven-key-mapping
7870
- * Keep these prefixes stable. Optional styling is best passed by name.
7871
- */
7872
- const STANDARD_ARGUMENT_PREFIXES = {
7873
- Box: ["children"],
7874
- Column: ["children"],
7875
- Row: ["children"],
7876
- Grid: ["children", "columns"],
7877
- GridItem: ["children"],
7878
- Card: ["children", "child"],
7879
- Flow: ["children"],
7880
- FlowItem: ["children"],
7881
- Carousel: ["children", "activeIndex"],
7882
- CarouselItem: ["children"],
7883
- CarouselMediaItem: [
7884
- "url",
7885
- "children",
7886
- "onClick"
7887
- ],
7888
- Spacer: ["minSize"],
7889
- Divider: ["axis"],
7890
- Tabs: ["tabs", "selectedIndex"],
7891
- Title: ["text"],
7892
- Text: ["text", "children"],
7893
- Caption: ["text"],
7894
- Label: ["text", "htmlFor"],
7895
- Bold: ["text"],
7896
- Italic: ["text"],
7897
- Underline: ["text"],
7898
- Strikethrough: ["text"],
7899
- Badge: ["label"],
7900
- Blockquote: ["text"],
7901
- Code: ["text", "language"],
7902
- Markdown: ["text"],
7903
- Math: ["value"],
7904
- ShimmerText: ["text"],
7905
- Link: ["text", "href"],
7906
- Tooltip: ["trigger", "content"],
7907
- Button: ["label", "onClick"],
7908
- Pressable: [
7909
- "children",
7910
- "onClick",
7911
- "href"
7912
- ],
7913
- Form: ["children", "onSubmit"],
7914
- TextField: ["label", "value"],
7915
- TextArea: ["label", "value"],
7916
- Select: [
7917
- "label",
7918
- "options",
7919
- "value"
7920
- ],
7921
- CheckBox: ["label", "value"],
7922
- Radio: ["label", "value"],
7923
- RadioGroup: [
7924
- "label",
7925
- "options",
7926
- "value"
7927
- ],
7928
- Slider: [
7929
- "label",
7930
- "value",
7931
- "min",
7932
- "max"
7933
- ],
7934
- SegmentedControl: [
7935
- "label",
7936
- "options",
7937
- "value"
7938
- ],
7939
- ChoicePicker: [
7940
- "label",
7941
- "options",
7942
- "value"
7943
- ],
7944
- DateTimeInput: ["label", "value"],
7945
- PulseIndicator: ["label"],
7946
- FlashcardFlip: ["front", "back"],
7947
- Popover: ["children", "open"],
7948
- PopoverTrigger: ["children"],
7949
- PopoverContent: ["children"],
7950
- Modal: [
7951
- "trigger",
7952
- "content",
7953
- "title"
7954
- ],
7955
- Table: [
7956
- "columns",
7957
- "rows",
7958
- "children"
7959
- ],
7960
- TableSection: ["children"],
7961
- TableRow: ["children", "label"],
7962
- TableCell: ["text", "children"],
7963
- List: [
7964
- "items",
7965
- "children",
7966
- "action"
7967
- ],
7968
- ListItem: [
7969
- "label",
7970
- "value",
7971
- "action",
7972
- "children"
7973
- ],
7974
- Chart: [
7975
- "data",
7976
- "xKey",
7977
- "series",
7978
- "chartType"
7979
- ],
7980
- Map: [
7981
- "markers",
7982
- "selected",
7983
- "route"
7984
- ],
7985
- Image: [
7986
- "url",
7987
- "description",
7988
- "onOverlayClick"
7989
- ],
7990
- Icon: ["name", "label"],
7991
- Favicon: ["url", "alt"],
7992
- Svg: ["paths", "viewBox"],
7993
- Video: [
7994
- "url",
7995
- "title",
7996
- "captions"
7997
- ],
7998
- AudioPlayer: ["url", "description"],
7999
- HtmlView: ["html", "title"],
8000
- LinkCard: [
8001
- "href",
8002
- "title",
8003
- "onClick"
8004
- ],
8005
- Citation: [
8006
- "index",
8007
- "title",
8008
- "url"
8009
- ],
8010
- FollowUp: [
8011
- "items",
8012
- "onFollowUp",
8013
- "title"
8014
- ],
8015
- EntityCard: [
8016
- "title",
8017
- "actions",
8018
- "onAction",
8019
- "onClick"
8020
- ],
8021
- ImageGrid: ["images"]
8022
- };
8023
- const PRESENTATION_PARAMETERS = new Set([
8024
- "align",
8025
- "aspectRatio",
8026
- "background",
8027
- "border",
8028
- "borderColor",
8029
- "clip",
8030
- "color",
8031
- "columnGap",
8032
- "disableAutoSpacing",
8033
- "flex",
8034
- "flush",
8035
- "fontSize",
8036
- "fontWeight",
8037
- "gap",
8038
- "height",
8039
- "highlight",
8040
- "hoverBackground",
8041
- "inline",
8042
- "insetBorder",
8043
- "italic",
8044
- "justify",
8045
- "lineHeight",
8046
- "lineThrough",
8047
- "maxHeight",
8048
- "maxLines",
8049
- "maxSize",
8050
- "maxWidth",
8051
- "minHeight",
8052
- "minLines",
8053
- "minSize",
8054
- "minWidth",
8055
- "padding",
8056
- "pill",
8057
- "preserveWhitespace",
8058
- "radius",
8059
- "role",
8060
- "rowGap",
8061
- "scrollable",
8062
- "shadow",
8063
- "shadowStyle",
8064
- "size",
8065
- "strokeWeight",
8066
- "strong",
8067
- "tabularNums",
8068
- "textAlign",
8069
- "truncate",
8070
- "underline",
8071
- "weight",
8072
- "width",
8073
- "wrap"
8074
- ]);
8075
- /** Put content/actions before presentation, across props, slots and events. */
8076
- function standardParameterOrder(name, definition) {
8077
- const keys = [
8078
- ...Object.keys(definition.props ? toJsonSchema(definition.props).properties ?? {} : {}),
8079
- ...Object.keys(definition.slots ?? {}),
8080
- ...Object.keys(definition.events ?? {})
8081
- ];
8082
- const prefix = STANDARD_ARGUMENT_PREFIXES[name];
8083
- const remainder = keys.filter((key) => !prefix.includes(key));
8084
- return [
8085
- ...prefix,
8086
- ...remainder.filter((key) => !PRESENTATION_PARAMETERS.has(key)),
8087
- ...remainder.filter((key) => PRESENTATION_PARAMETERS.has(key))
8088
- ];
8089
- }
5767
+ const textComponents = withComponents(textDeclarations, {
5768
+ Title,
5769
+ Text,
5770
+ Caption,
5771
+ Label,
5772
+ Bold,
5773
+ Italic,
5774
+ Underline,
5775
+ Strikethrough,
5776
+ Badge,
5777
+ Blockquote,
5778
+ Code,
5779
+ Markdown,
5780
+ Math: MathFormula,
5781
+ ShimmerText,
5782
+ Link,
5783
+ Tooltip
5784
+ });
8090
5785
 
8091
5786
  //#endregion
8092
5787
  //#region src/generative-ui/standard/index.ts
8093
- const components = {
5788
+ const orderedComponents = withStandardParameterOrder({
8094
5789
  ...layoutComponents,
8095
5790
  ...textComponents,
8096
5791
  ...inputComponents,
@@ -8098,11 +5793,7 @@ const components = {
8098
5793
  ...dataComponents,
8099
5794
  ...mediaComponents,
8100
5795
  ...compositeComponents
8101
- };
8102
- const orderedComponents = Object.fromEntries(Object.entries(components).map(([name, definition]) => [name, {
8103
- ...definition,
8104
- parameterOrder: standardParameterOrder(name, definition)
8105
- }]));
5796
+ });
8106
5797
  /**
8107
5798
  * Experimental. The standard components: layout, text, inputs, feedback,
8108
5799
  * data, media and composites. Give it to the provider as it is, or add your