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