@copilotkit/shared 2.0.0-rc.30 → 2.0.0-rc.32
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/generative-ui/catalog/catalog-export.cjs +329 -0
- package/dist/generative-ui/catalog/catalog-export.cjs.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.d.cts +92 -0
- package/dist/generative-ui/catalog/catalog-export.d.cts.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.d.mts +92 -0
- package/dist/generative-ui/catalog/catalog-export.d.mts.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.mjs +328 -0
- package/dist/generative-ui/catalog/catalog-export.mjs.map +1 -0
- package/dist/generative-ui/catalog/catalog.cjs +315 -0
- package/dist/generative-ui/catalog/catalog.cjs.map +1 -0
- package/dist/generative-ui/catalog/catalog.d.cts +407 -0
- package/dist/generative-ui/catalog/catalog.d.cts.map +1 -0
- package/dist/generative-ui/catalog/catalog.d.mts +407 -0
- package/dist/generative-ui/catalog/catalog.d.mts.map +1 -0
- package/dist/generative-ui/catalog/catalog.mjs +312 -0
- package/dist/generative-ui/catalog/catalog.mjs.map +1 -0
- package/dist/generative-ui/catalog/errors.cjs +13 -0
- package/dist/generative-ui/catalog/errors.cjs.map +1 -0
- package/dist/generative-ui/catalog/errors.d.cts +46 -0
- package/dist/generative-ui/catalog/errors.d.cts.map +1 -0
- package/dist/generative-ui/catalog/errors.d.mts +46 -0
- package/dist/generative-ui/catalog/errors.d.mts.map +1 -0
- package/dist/generative-ui/catalog/errors.mjs +12 -0
- package/dist/generative-ui/catalog/errors.mjs.map +1 -0
- package/dist/generative-ui/catalog/index.d.mts +6 -0
- package/dist/generative-ui/catalog/json-schema.cjs +16 -0
- package/dist/generative-ui/catalog/json-schema.cjs.map +1 -0
- package/dist/generative-ui/catalog/json-schema.d.cts +12 -0
- package/dist/generative-ui/catalog/json-schema.d.cts.map +1 -0
- package/dist/generative-ui/catalog/json-schema.d.mts +12 -0
- package/dist/generative-ui/catalog/json-schema.d.mts.map +1 -0
- package/dist/generative-ui/catalog/json-schema.mjs +16 -0
- package/dist/generative-ui/catalog/json-schema.mjs.map +1 -0
- package/dist/generative-ui/catalog/refs.cjs +21 -0
- package/dist/generative-ui/catalog/refs.cjs.map +1 -0
- package/dist/generative-ui/catalog/refs.d.cts +55 -0
- package/dist/generative-ui/catalog/refs.d.cts.map +1 -0
- package/dist/generative-ui/catalog/refs.d.mts +55 -0
- package/dist/generative-ui/catalog/refs.d.mts.map +1 -0
- package/dist/generative-ui/catalog/refs.mjs +18 -0
- package/dist/generative-ui/catalog/refs.mjs.map +1 -0
- package/dist/generative-ui/catalog/schema.cjs +74 -0
- package/dist/generative-ui/catalog/schema.cjs.map +1 -0
- package/dist/generative-ui/catalog/schema.d.cts +43 -0
- package/dist/generative-ui/catalog/schema.d.cts.map +1 -0
- package/dist/generative-ui/catalog/schema.d.mts +43 -0
- package/dist/generative-ui/catalog/schema.d.mts.map +1 -0
- package/dist/generative-ui/catalog/schema.mjs +68 -0
- package/dist/generative-ui/catalog/schema.mjs.map +1 -0
- package/dist/generative-ui/index.cjs +247 -0
- package/dist/generative-ui/index.d.cts +33 -0
- package/dist/generative-ui/index.d.mts +35 -0
- package/dist/generative-ui/index.mjs +34 -0
- package/dist/generative-ui/is-record.cjs +6 -1
- package/dist/generative-ui/is-record.cjs.map +1 -1
- package/dist/generative-ui/is-record.d.cts +6 -0
- package/dist/generative-ui/is-record.d.cts.map +1 -0
- package/dist/generative-ui/is-record.d.mts +6 -0
- package/dist/generative-ui/is-record.d.mts.map +1 -0
- package/dist/generative-ui/is-record.mjs +6 -2
- package/dist/generative-ui/is-record.mjs.map +1 -1
- package/dist/generative-ui/standard/chart.cjs +56 -0
- package/dist/generative-ui/standard/chart.cjs.map +1 -0
- package/dist/generative-ui/standard/chart.d.cts +62 -0
- package/dist/generative-ui/standard/chart.d.cts.map +1 -0
- package/dist/generative-ui/standard/chart.d.mts +62 -0
- package/dist/generative-ui/standard/chart.d.mts.map +1 -0
- package/dist/generative-ui/standard/chart.mjs +54 -0
- package/dist/generative-ui/standard/chart.mjs.map +1 -0
- package/dist/generative-ui/standard/checks.cjs +74 -0
- package/dist/generative-ui/standard/checks.cjs.map +1 -0
- package/dist/generative-ui/standard/checks.d.cts +56 -0
- package/dist/generative-ui/standard/checks.d.cts.map +1 -0
- package/dist/generative-ui/standard/checks.d.mts +56 -0
- package/dist/generative-ui/standard/checks.d.mts.map +1 -0
- package/dist/generative-ui/standard/checks.mjs +71 -0
- package/dist/generative-ui/standard/checks.mjs.map +1 -0
- package/dist/generative-ui/standard/components.cjs +23 -0
- package/dist/generative-ui/standard/components.cjs.map +1 -0
- package/dist/generative-ui/standard/components.d.cts +24 -0
- package/dist/generative-ui/standard/components.d.cts.map +1 -0
- package/dist/generative-ui/standard/components.d.mts +24 -0
- package/dist/generative-ui/standard/components.d.mts.map +1 -0
- package/dist/generative-ui/standard/components.mjs +22 -0
- package/dist/generative-ui/standard/components.mjs.map +1 -0
- package/dist/generative-ui/standard/composites.cjs +143 -0
- package/dist/generative-ui/standard/composites.cjs.map +1 -0
- package/dist/generative-ui/standard/composites.d.cts +233 -0
- package/dist/generative-ui/standard/composites.d.cts.map +1 -0
- package/dist/generative-ui/standard/composites.d.mts +233 -0
- package/dist/generative-ui/standard/composites.d.mts.map +1 -0
- package/dist/generative-ui/standard/composites.mjs +132 -0
- package/dist/generative-ui/standard/composites.mjs.map +1 -0
- package/dist/generative-ui/standard/data.cjs +176 -0
- package/dist/generative-ui/standard/data.cjs.map +1 -0
- package/dist/generative-ui/standard/data.d.cts +365 -0
- package/dist/generative-ui/standard/data.d.cts.map +1 -0
- package/dist/generative-ui/standard/data.d.mts +365 -0
- package/dist/generative-ui/standard/data.d.mts.map +1 -0
- package/dist/generative-ui/standard/data.mjs +167 -0
- package/dist/generative-ui/standard/data.mjs.map +1 -0
- package/dist/generative-ui/standard/declarations.cjs +40 -0
- package/dist/generative-ui/standard/declarations.cjs.map +1 -0
- package/dist/generative-ui/standard/declarations.d.cts +2570 -0
- package/dist/generative-ui/standard/declarations.d.cts.map +1 -0
- package/dist/generative-ui/standard/declarations.d.mts +2571 -0
- package/dist/generative-ui/standard/declarations.d.mts.map +1 -0
- package/dist/generative-ui/standard/declarations.mjs +39 -0
- package/dist/generative-ui/standard/declarations.mjs.map +1 -0
- package/dist/generative-ui/standard/feedback.cjs +97 -0
- package/dist/generative-ui/standard/feedback.cjs.map +1 -0
- package/dist/generative-ui/standard/feedback.d.cts +133 -0
- package/dist/generative-ui/standard/feedback.d.cts.map +1 -0
- package/dist/generative-ui/standard/feedback.d.mts +133 -0
- package/dist/generative-ui/standard/feedback.d.mts.map +1 -0
- package/dist/generative-ui/standard/feedback.mjs +90 -0
- package/dist/generative-ui/standard/feedback.mjs.map +1 -0
- package/dist/generative-ui/standard/index.d.mts +16 -0
- package/dist/generative-ui/standard/inputs.cjs +333 -0
- package/dist/generative-ui/standard/inputs.cjs.map +1 -0
- package/dist/generative-ui/standard/inputs.d.cts +1128 -0
- package/dist/generative-ui/standard/inputs.d.cts.map +1 -0
- package/dist/generative-ui/standard/inputs.d.mts +1128 -0
- package/dist/generative-ui/standard/inputs.d.mts.map +1 -0
- package/dist/generative-ui/standard/inputs.mjs +318 -0
- package/dist/generative-ui/standard/inputs.mjs.map +1 -0
- package/dist/generative-ui/standard/layout.cjs +289 -0
- package/dist/generative-ui/standard/layout.cjs.map +1 -0
- package/dist/generative-ui/standard/layout.d.cts +1974 -0
- package/dist/generative-ui/standard/layout.d.cts.map +1 -0
- package/dist/generative-ui/standard/layout.d.mts +1975 -0
- package/dist/generative-ui/standard/layout.d.mts.map +1 -0
- package/dist/generative-ui/standard/layout.mjs +269 -0
- package/dist/generative-ui/standard/layout.mjs.map +1 -0
- package/dist/generative-ui/standard/map.cjs +27 -0
- package/dist/generative-ui/standard/map.cjs.map +1 -0
- package/dist/generative-ui/standard/map.d.cts +31 -0
- package/dist/generative-ui/standard/map.d.cts.map +1 -0
- package/dist/generative-ui/standard/map.d.mts +31 -0
- package/dist/generative-ui/standard/map.d.mts.map +1 -0
- package/dist/generative-ui/standard/map.mjs +25 -0
- package/dist/generative-ui/standard/map.mjs.map +1 -0
- package/dist/generative-ui/standard/media.cjs +215 -0
- package/dist/generative-ui/standard/media.cjs.map +1 -0
- package/dist/generative-ui/standard/media.d.cts +396 -0
- package/dist/generative-ui/standard/media.d.cts.map +1 -0
- package/dist/generative-ui/standard/media.d.mts +396 -0
- package/dist/generative-ui/standard/media.d.mts.map +1 -0
- package/dist/generative-ui/standard/media.mjs +205 -0
- package/dist/generative-ui/standard/media.mjs.map +1 -0
- package/dist/generative-ui/standard/parameter-order.cjs +231 -0
- package/dist/generative-ui/standard/parameter-order.cjs.map +1 -0
- package/dist/generative-ui/standard/parameter-order.d.cts +84 -0
- package/dist/generative-ui/standard/parameter-order.d.cts.map +1 -0
- package/dist/generative-ui/standard/parameter-order.d.mts +84 -0
- package/dist/generative-ui/standard/parameter-order.d.mts.map +1 -0
- package/dist/generative-ui/standard/parameter-order.mjs +230 -0
- package/dist/generative-ui/standard/parameter-order.mjs.map +1 -0
- package/dist/generative-ui/standard/styles.cjs +62 -0
- package/dist/generative-ui/standard/styles.cjs.map +1 -0
- package/dist/generative-ui/standard/styles.d.cts +17 -0
- package/dist/generative-ui/standard/styles.d.cts.map +1 -0
- package/dist/generative-ui/standard/styles.d.mts +17 -0
- package/dist/generative-ui/standard/styles.d.mts.map +1 -0
- package/dist/generative-ui/standard/styles.mjs +60 -0
- package/dist/generative-ui/standard/styles.mjs.map +1 -0
- package/dist/generative-ui/standard/text.cjs +226 -0
- package/dist/generative-ui/standard/text.cjs.map +1 -0
- package/dist/generative-ui/standard/text.d.cts +522 -0
- package/dist/generative-ui/standard/text.d.cts.map +1 -0
- package/dist/generative-ui/standard/text.d.mts +522 -0
- package/dist/generative-ui/standard/text.d.mts.map +1 -0
- package/dist/generative-ui/standard/text.mjs +209 -0
- package/dist/generative-ui/standard/text.mjs.map +1 -0
- package/dist/generative-ui/standard/theme.cjs +115 -0
- package/dist/generative-ui/standard/theme.cjs.map +1 -0
- package/dist/generative-ui/standard/theme.d.cts +60 -0
- package/dist/generative-ui/standard/theme.d.cts.map +1 -0
- package/dist/generative-ui/standard/theme.d.mts +60 -0
- package/dist/generative-ui/standard/theme.d.mts.map +1 -0
- package/dist/generative-ui/standard/theme.mjs +112 -0
- package/dist/generative-ui/standard/theme.mjs.map +1 -0
- package/dist/generative-ui/standard/tokens.cjs +336 -0
- package/dist/generative-ui/standard/tokens.cjs.map +1 -0
- package/dist/generative-ui/standard/tokens.d.cts +76 -0
- package/dist/generative-ui/standard/tokens.d.cts.map +1 -0
- package/dist/generative-ui/standard/tokens.d.mts +76 -0
- package/dist/generative-ui/standard/tokens.d.mts.map +1 -0
- package/dist/generative-ui/standard/tokens.mjs +305 -0
- package/dist/generative-ui/standard/tokens.mjs.map +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.mts +10 -10
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +7 -3
- package/src/generative-ui/base.ts +9 -0
- package/src/generative-ui/catalog/catalog-export.ts +478 -0
- package/src/generative-ui/catalog/catalog.ts +1167 -0
- package/src/generative-ui/catalog/errors.ts +102 -0
- package/src/generative-ui/catalog/index.ts +6 -0
- package/src/generative-ui/catalog/json-schema.ts +14 -0
- package/src/generative-ui/catalog/refs.ts +87 -0
- package/src/generative-ui/catalog/schema.ts +107 -0
- package/src/generative-ui/index.ts +7 -0
- package/src/generative-ui/is-record.ts +6 -1
- package/src/generative-ui/standard/__tests__/theme.test.ts +61 -0
- package/src/generative-ui/standard/__tests__/tokens.test.ts +139 -0
- package/src/generative-ui/standard/chart.ts +79 -0
- package/src/generative-ui/standard/checks.ts +98 -0
- package/src/generative-ui/standard/components.ts +35 -0
- package/src/generative-ui/standard/composites.ts +158 -0
- package/src/generative-ui/standard/data.ts +213 -0
- package/src/generative-ui/standard/declarations.ts +57 -0
- package/src/generative-ui/standard/feedback.ts +105 -0
- package/src/generative-ui/standard/index.ts +19 -0
- package/src/generative-ui/standard/inputs.ts +423 -0
- package/src/generative-ui/standard/layout.ts +312 -0
- package/src/generative-ui/standard/map.ts +32 -0
- package/src/generative-ui/standard/media.ts +265 -0
- package/src/generative-ui/standard/parameter-order.ts +155 -0
- package/src/generative-ui/standard/styles.ts +79 -0
- package/src/generative-ui/standard/text.ts +210 -0
- package/src/generative-ui/standard/theme.ts +198 -0
- package/src/generative-ui/standard/tokens.ts +317 -0
- package/src/index.ts +1 -1
- package/tsdown.config.ts +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { NO_ARGS, sizeValue } from "./layout.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/generative-ui/standard/composites.ts
|
|
5
|
+
const text = (description) => z.string().optional().describe(description);
|
|
6
|
+
const linkCardSchema = z.object({
|
|
7
|
+
href: z.string().describe("The URL (http, https)"),
|
|
8
|
+
title: z.string().describe("The page title"),
|
|
9
|
+
description: text("One or two lines"),
|
|
10
|
+
image: text("A thumbnail URL"),
|
|
11
|
+
domain: text("Shown next to the favicon. Default: the host of href"),
|
|
12
|
+
favicon: z.boolean().optional().describe("Default true")
|
|
13
|
+
});
|
|
14
|
+
const citationSchema = z.object({
|
|
15
|
+
index: z.number().optional().describe("The marker number. Default 1"),
|
|
16
|
+
label: text("Marker text instead of the number, for example a domain"),
|
|
17
|
+
title: text("The source title"),
|
|
18
|
+
url: text("The source URL (http, https)"),
|
|
19
|
+
snippet: text("The quoted passage, one or two lines"),
|
|
20
|
+
source: text("The publisher or domain. Default: the host of url")
|
|
21
|
+
});
|
|
22
|
+
const followUpItem = z.union([z.string(), z.object({
|
|
23
|
+
label: z.string(),
|
|
24
|
+
message: text("The text sent when the user clicks. Default: label")
|
|
25
|
+
})]);
|
|
26
|
+
const followUpSchema = z.object({
|
|
27
|
+
items: z.array(followUpItem).optional(),
|
|
28
|
+
title: text("A caption above the pills")
|
|
29
|
+
});
|
|
30
|
+
const followUpArgs = z.object({ message: z.string().describe("The message of the clicked pill") });
|
|
31
|
+
const BADGE_COLORS = [
|
|
32
|
+
"secondary",
|
|
33
|
+
"success",
|
|
34
|
+
"danger",
|
|
35
|
+
"warning",
|
|
36
|
+
"info",
|
|
37
|
+
"discovery"
|
|
38
|
+
];
|
|
39
|
+
const cardAction = z.object({
|
|
40
|
+
label: z.string(),
|
|
41
|
+
href: text("Opens this URL in a new tab"),
|
|
42
|
+
variant: z.enum([
|
|
43
|
+
"solid",
|
|
44
|
+
"soft",
|
|
45
|
+
"outline",
|
|
46
|
+
"ghost"
|
|
47
|
+
]).optional()
|
|
48
|
+
});
|
|
49
|
+
const entityCardSchema = z.object({
|
|
50
|
+
title: z.string().describe("The name"),
|
|
51
|
+
subtitle: text("A second line, for example the brand or category"),
|
|
52
|
+
description: text("Up to three lines"),
|
|
53
|
+
image: text("An image URL"),
|
|
54
|
+
imageAspectRatio: z.string().optional().describe("Default \"4 / 3\""),
|
|
55
|
+
meta: text("A short fact line, for example \"$29 / month\" or \"Open until 22:00\""),
|
|
56
|
+
badge: z.object({
|
|
57
|
+
label: z.string(),
|
|
58
|
+
color: z.enum(BADGE_COLORS).optional()
|
|
59
|
+
}).optional(),
|
|
60
|
+
rating: z.number().optional().describe("0 to 5, shown as stars"),
|
|
61
|
+
ratingCount: z.number().optional().describe("The number of ratings"),
|
|
62
|
+
href: text("Opens this URL in a new tab when the user clicks the card"),
|
|
63
|
+
actions: z.array(cardAction).max(3).optional().describe("Up to three buttons. A button without href sends onAction with its label"),
|
|
64
|
+
layout: z.enum(["vertical", "horizontal"]).optional().describe("Default \"vertical\". \"horizontal\" puts the image on the left"),
|
|
65
|
+
width: sizeValue.optional()
|
|
66
|
+
});
|
|
67
|
+
const entityActionArgs = z.object({ label: z.string().describe("The label of the clicked button") });
|
|
68
|
+
const gridImage = z.object({
|
|
69
|
+
url: z.string(),
|
|
70
|
+
description: z.string().optional().describe("What the image shows"),
|
|
71
|
+
caption: z.string().optional(),
|
|
72
|
+
href: text("Opens this URL instead of the full-screen view")
|
|
73
|
+
});
|
|
74
|
+
const imageGridSchema = z.object({
|
|
75
|
+
images: z.array(gridImage).optional(),
|
|
76
|
+
columns: z.number().optional().describe("Default 3"),
|
|
77
|
+
aspectRatio: z.string().optional().describe("Default \"1 / 1\""),
|
|
78
|
+
gap: sizeValue.optional().describe("Default 2"),
|
|
79
|
+
layout: z.enum(["grid", "bento"]).optional().describe("Default \"grid\". \"bento\" makes the first image twice as large")
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* The standard composite components, without their framework components.
|
|
83
|
+
*
|
|
84
|
+
* - LinkCard and EntityCard open `href`, or send `onClick` when it is bound.
|
|
85
|
+
* - FollowUp sends `onFollowUp` with the message of the pill. Unbound, the
|
|
86
|
+
* engine turns it into a visible user message with that text.
|
|
87
|
+
* - EntityCard buttons without href send `onAction` with their label.
|
|
88
|
+
*/
|
|
89
|
+
const compositeDeclarations = {
|
|
90
|
+
LinkCard: {
|
|
91
|
+
description: "A preview of a URL: favicon and domain, title, description, thumbnail. A click opens it in a new tab, or sends onClick when bound. For sources, articles and products with a page.",
|
|
92
|
+
props: linkCardSchema,
|
|
93
|
+
events: { onClick: {
|
|
94
|
+
description: "Sent when the user clicks the card, instead of the link.",
|
|
95
|
+
parameters: NO_ARGS
|
|
96
|
+
} }
|
|
97
|
+
},
|
|
98
|
+
Citation: {
|
|
99
|
+
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.",
|
|
100
|
+
props: citationSchema
|
|
101
|
+
},
|
|
102
|
+
FollowUp: {
|
|
103
|
+
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.",
|
|
104
|
+
props: followUpSchema,
|
|
105
|
+
events: { onFollowUp: {
|
|
106
|
+
description: "Sent when the user clicks a pill. The args carry the message of the pill.",
|
|
107
|
+
parameters: followUpArgs
|
|
108
|
+
} }
|
|
109
|
+
},
|
|
110
|
+
EntityCard: {
|
|
111
|
+
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.",
|
|
112
|
+
props: entityCardSchema,
|
|
113
|
+
events: {
|
|
114
|
+
onClick: {
|
|
115
|
+
description: "Sent when the user clicks the card and it has no href.",
|
|
116
|
+
parameters: NO_ARGS
|
|
117
|
+
},
|
|
118
|
+
onAction: {
|
|
119
|
+
description: "Sent when the user clicks a button without href. The args carry the label of the button.",
|
|
120
|
+
parameters: entityActionArgs
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
ImageGrid: {
|
|
125
|
+
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.",
|
|
126
|
+
props: imageGridSchema
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { cardAction, citationSchema, compositeDeclarations, entityActionArgs, entityCardSchema, followUpArgs, followUpItem, followUpSchema, gridImage, imageGridSchema, linkCardSchema };
|
|
132
|
+
//# sourceMappingURL=composites.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composites.mjs","names":[],"sources":["../../../src/generative-ui/standard/composites.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { NO_ARGS, sizeValue } from \"./layout\";\n\n// ---- Schemas ----\n\nconst text = (description: string) =>\n z.string().optional().describe(description);\n\nexport const linkCardSchema = z.object({\n href: z.string().describe(\"The URL (http, https)\"),\n title: z.string().describe(\"The page title\"),\n description: text(\"One or two lines\"),\n image: text(\"A thumbnail URL\"),\n domain: text(\"Shown next to the favicon. Default: the host of href\"),\n favicon: z.boolean().optional().describe(\"Default true\"),\n});\nexport const citationSchema = z.object({\n index: z.number().optional().describe(\"The marker number. Default 1\"),\n label: text(\"Marker text instead of the number, for example a domain\"),\n title: text(\"The source title\"),\n url: text(\"The source URL (http, https)\"),\n snippet: text(\"The quoted passage, one or two lines\"),\n source: text(\"The publisher or domain. Default: the host of url\"),\n});\nexport const followUpItem = z.union([\n z.string(),\n z.object({\n label: z.string(),\n message: text(\"The text sent when the user clicks. Default: label\"),\n }),\n]);\nexport const followUpSchema = z.object({\n items: z.array(followUpItem).optional(),\n title: text(\"A caption above the pills\"),\n});\nexport const followUpArgs = z.object({\n message: z.string().describe(\"The message of the clicked pill\"),\n});\nconst BADGE_COLORS = [\n \"secondary\",\n \"success\",\n \"danger\",\n \"warning\",\n \"info\",\n \"discovery\",\n] as const;\nexport const cardAction = z.object({\n label: z.string(),\n href: text(\"Opens this URL in a new tab\"),\n variant: z.enum([\"solid\", \"soft\", \"outline\", \"ghost\"]).optional(),\n});\nexport const entityCardSchema = z.object({\n title: z.string().describe(\"The name\"),\n subtitle: text(\"A second line, for example the brand or category\"),\n description: text(\"Up to three lines\"),\n image: text(\"An image URL\"),\n imageAspectRatio: z.string().optional().describe('Default \"4 / 3\"'),\n meta: text(\n 'A short fact line, for example \"$29 / month\" or \"Open until 22:00\"',\n ),\n badge: z\n .object({ label: z.string(), color: z.enum(BADGE_COLORS).optional() })\n .optional(),\n rating: z.number().optional().describe(\"0 to 5, shown as stars\"),\n ratingCount: z.number().optional().describe(\"The number of ratings\"),\n href: text(\"Opens this URL in a new tab when the user clicks the card\"),\n actions: z\n .array(cardAction)\n .max(3)\n .optional()\n .describe(\n \"Up to three buttons. A button without href sends onAction with its label\",\n ),\n layout: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe('Default \"vertical\". \"horizontal\" puts the image on the left'),\n width: sizeValue.optional(),\n});\nexport const entityActionArgs = z.object({\n label: z.string().describe(\"The label of the clicked button\"),\n});\nexport const gridImage = z.object({\n url: z.string(),\n description: z.string().optional().describe(\"What the image shows\"),\n caption: z.string().optional(),\n href: text(\"Opens this URL instead of the full-screen view\"),\n});\nexport const imageGridSchema = z.object({\n images: z.array(gridImage).optional(),\n columns: z.number().optional().describe(\"Default 3\"),\n aspectRatio: z.string().optional().describe('Default \"1 / 1\"'),\n gap: sizeValue.optional().describe(\"Default 2\"),\n layout: z\n .enum([\"grid\", \"bento\"])\n .optional()\n .describe('Default \"grid\". \"bento\" makes the first image twice as large'),\n});\n\n/**\n * The standard composite components, without their framework components.\n *\n * - LinkCard and EntityCard open `href`, or send `onClick` when it is bound.\n * - FollowUp sends `onFollowUp` with the message of the pill. Unbound, the\n * engine turns it into a visible user message with that text.\n * - EntityCard buttons without href send `onAction` with their label.\n */\nexport const compositeDeclarations = {\n LinkCard: {\n description:\n \"A preview of a URL: favicon and domain, title, description, thumbnail. A click opens it in a new tab, or sends onClick when bound. For sources, articles and products with a page.\",\n props: linkCardSchema,\n events: {\n onClick: {\n description: \"Sent when the user clicks the card, instead of the link.\",\n parameters: NO_ARGS,\n },\n },\n },\n Citation: {\n description:\n \"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.\",\n props: citationSchema,\n },\n FollowUp: {\n description:\n \"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.\",\n props: followUpSchema,\n events: {\n onFollowUp: {\n description:\n \"Sent when the user clicks a pill. The args carry the message of the pill.\",\n parameters: followUpArgs,\n },\n },\n },\n EntityCard: {\n description:\n \"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.\",\n props: entityCardSchema,\n events: {\n onClick: {\n description: \"Sent when the user clicks the card and it has no href.\",\n parameters: NO_ARGS,\n },\n onAction: {\n description:\n \"Sent when the user clicks a button without href. The args carry the label of the button.\",\n parameters: entityActionArgs,\n },\n },\n },\n ImageGrid: {\n description:\n '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.',\n props: imageGridSchema,\n },\n};\n"],"mappings":";;;;AAKA,MAAM,QAAQ,gBACZ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,YAAY;AAE7C,MAAa,iBAAiB,EAAE,OAAO;CACrC,MAAM,EAAE,QAAQ,CAAC,SAAS,wBAAwB;CAClD,OAAO,EAAE,QAAQ,CAAC,SAAS,iBAAiB;CAC5C,aAAa,KAAK,mBAAmB;CACrC,OAAO,KAAK,kBAAkB;CAC9B,QAAQ,KAAK,uDAAuD;CACpE,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,eAAe;CACzD,CAAC;AACF,MAAa,iBAAiB,EAAE,OAAO;CACrC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,+BAA+B;CACrE,OAAO,KAAK,0DAA0D;CACtE,OAAO,KAAK,mBAAmB;CAC/B,KAAK,KAAK,+BAA+B;CACzC,SAAS,KAAK,uCAAuC;CACrD,QAAQ,KAAK,oDAAoD;CAClE,CAAC;AACF,MAAa,eAAe,EAAE,MAAM,CAClC,EAAE,QAAQ,EACV,EAAE,OAAO;CACP,OAAO,EAAE,QAAQ;CACjB,SAAS,KAAK,qDAAqD;CACpE,CAAC,CACH,CAAC;AACF,MAAa,iBAAiB,EAAE,OAAO;CACrC,OAAO,EAAE,MAAM,aAAa,CAAC,UAAU;CACvC,OAAO,KAAK,4BAA4B;CACzC,CAAC;AACF,MAAa,eAAe,EAAE,OAAO,EACnC,SAAS,EAAE,QAAQ,CAAC,SAAS,kCAAkC,EAChE,CAAC;AACF,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACD;AACD,MAAa,aAAa,EAAE,OAAO;CACjC,OAAO,EAAE,QAAQ;CACjB,MAAM,KAAK,8BAA8B;CACzC,SAAS,EAAE,KAAK;EAAC;EAAS;EAAQ;EAAW;EAAQ,CAAC,CAAC,U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AK,CAAC,QAAQ,QAAQ,CAAC,CACvB,UAAU,CACV,SAAS,mEAA+D;CAC5E,CAAC;;;;;;;;;AAUF,MAAa,wBAAwB;CACnC,UAAU;EACR,aACE;EACF,OAAO;EACP,QAAQ,EACN,SAAS;GACP,aAAa;GACb,YAAY;GACb,EACF;EACF;CACD,UAAU;EACR,aACE;EACF,OAAO;EACR;CACD,UAAU;EACR,aACE;EACF,OAAO;EACP,QAAQ,EACN,YAAY;GACV,aACE;GACF,YAAY;GACb,EACF;EACF;CACD,YAAY;EACV,aACE;EACF,OAAO;EACP,QAAQ;GACN,SAAS;IACP,aAAa;IACb,YAAY;IACb;GACD,UAAU;IACR,aACE;IACF,YAAY;IACb;GACF;EACF;CACD,WAAW;EACT,aACE;EACF,OAAO;EACR;CACF"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_layout = require('./layout.cjs');
|
|
3
|
+
const require_chart = require('./chart.cjs');
|
|
4
|
+
const require_map = require('./map.cjs');
|
|
5
|
+
let zod = require("zod");
|
|
6
|
+
|
|
7
|
+
//#region src/generative-ui/standard/data.ts
|
|
8
|
+
const cellAlign = zod.z.enum([
|
|
9
|
+
"start",
|
|
10
|
+
"center",
|
|
11
|
+
"end"
|
|
12
|
+
]).optional();
|
|
13
|
+
/**
|
|
14
|
+
* A table cell or column header that shows another component. `id` is an
|
|
15
|
+
* alias of `componentId`.
|
|
16
|
+
*/
|
|
17
|
+
const tableComponentCell = zod.z.union([zod.z.object({ componentId: zod.z.string() }), zod.z.object({ id: zod.z.string() })]);
|
|
18
|
+
const tableColumn = zod.z.union([
|
|
19
|
+
zod.z.string(),
|
|
20
|
+
zod.z.object({
|
|
21
|
+
label: zod.z.string(),
|
|
22
|
+
align: cellAlign,
|
|
23
|
+
width: require_layout.sizeValue.optional(),
|
|
24
|
+
componentId: zod.z.string().optional()
|
|
25
|
+
}),
|
|
26
|
+
tableComponentCell
|
|
27
|
+
]);
|
|
28
|
+
const tableSchema = zod.z.object({
|
|
29
|
+
caption: zod.z.string().optional().describe("A short name of the table for screen readers. It is not shown"),
|
|
30
|
+
columns: zod.z.array(tableColumn).optional().describe("Default []"),
|
|
31
|
+
rows: zod.z.array(zod.z.array(zod.z.unknown())).optional().describe("A list of row lists. A cell is a string, a number, or { \"componentId\": \"<id>\" } to show a component. Default []"),
|
|
32
|
+
columnSizing: zod.z.enum(["auto", "equal"]).optional().describe("Default \"auto\""),
|
|
33
|
+
dividers: zod.z.boolean().optional().describe("Default true"),
|
|
34
|
+
stickyHeader: zod.z.boolean().optional().describe("Default false"),
|
|
35
|
+
emptyLabel: zod.z.string().optional().describe("Default \"No rows\"")
|
|
36
|
+
});
|
|
37
|
+
const tableSectionSchema = zod.z.object({
|
|
38
|
+
header: zod.z.boolean().optional().describe("Renders the rows as the header"),
|
|
39
|
+
rowDivider: zod.z.boolean().optional()
|
|
40
|
+
});
|
|
41
|
+
const tableRowSchema = zod.z.object({
|
|
42
|
+
header: zod.z.boolean().optional(),
|
|
43
|
+
label: zod.z.string().optional().describe("The text of a header cell at the start of the row"),
|
|
44
|
+
labelColSpan: zod.z.number().optional().describe("Columns the label cell spans")
|
|
45
|
+
});
|
|
46
|
+
const tableCellSchema = zod.z.object({
|
|
47
|
+
text: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
|
|
48
|
+
header: zod.z.boolean().optional(),
|
|
49
|
+
align: cellAlign,
|
|
50
|
+
vAlign: cellAlign.describe("Default \"start\""),
|
|
51
|
+
colSpan: zod.z.number().optional(),
|
|
52
|
+
rowSpan: zod.z.number().optional(),
|
|
53
|
+
width: require_layout.sizeValue.optional(),
|
|
54
|
+
padding: require_layout.sizeValue.optional()
|
|
55
|
+
});
|
|
56
|
+
const listItemValue = zod.z.union([zod.z.string(), zod.z.object({
|
|
57
|
+
label: zod.z.string(),
|
|
58
|
+
description: zod.z.string().optional(),
|
|
59
|
+
icon: zod.z.string().optional().describe("Lucide icon name"),
|
|
60
|
+
value: zod.z.union([zod.z.string(), zod.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")
|
|
61
|
+
})]);
|
|
62
|
+
const LIST_MARKERS = [
|
|
63
|
+
"bullet",
|
|
64
|
+
"number",
|
|
65
|
+
"rich",
|
|
66
|
+
"none"
|
|
67
|
+
];
|
|
68
|
+
const listSchema = zod.z.object({
|
|
69
|
+
items: zod.z.array(listItemValue).optional(),
|
|
70
|
+
direction: zod.z.enum(["vertical", "horizontal"]).optional().describe("Default \"vertical\". \"horizontal\" scrolls sideways"),
|
|
71
|
+
align: zod.z.enum([
|
|
72
|
+
"start",
|
|
73
|
+
"center",
|
|
74
|
+
"end",
|
|
75
|
+
"stretch"
|
|
76
|
+
]).optional(),
|
|
77
|
+
weight: require_layout.weightProp,
|
|
78
|
+
marker: zod.z.enum(LIST_MARKERS).optional().describe("Default \"bullet\""),
|
|
79
|
+
connector: zod.z.enum(["none", "solid"]).optional().describe("Default \"none\""),
|
|
80
|
+
gap: require_layout.sizeValue.optional(),
|
|
81
|
+
start: zod.z.number().optional().describe("The first number of marker \"number\""),
|
|
82
|
+
maxMarkerSize: zod.z.number().optional().describe("The width of the marker column in pixels")
|
|
83
|
+
});
|
|
84
|
+
const listItemSchema = zod.z.object({
|
|
85
|
+
label: zod.z.string().optional(),
|
|
86
|
+
value: zod.z.union([zod.z.string(), zod.z.number()]).optional().describe("Without an action: shown on the right of the label, for a key and value fact"),
|
|
87
|
+
description: zod.z.string().optional(),
|
|
88
|
+
icon: zod.z.string().optional().describe("Lucide icon name"),
|
|
89
|
+
marker: zod.z.string().optional().describe("Shows this text as the marker"),
|
|
90
|
+
markerSize: zod.z.number().optional().describe("The width of the marker column in pixels"),
|
|
91
|
+
disabled: zod.z.boolean().optional().describe("Greys the item out and ignores its action")
|
|
92
|
+
});
|
|
93
|
+
const listSelection = zod.z.object({
|
|
94
|
+
index: zod.z.number(),
|
|
95
|
+
label: zod.z.string(),
|
|
96
|
+
value: zod.z.string().optional()
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* The standard data components, without their framework components:
|
|
100
|
+
* tables, lists, a chart and a map. Each framework adds its components
|
|
101
|
+
* with `withComponents`.
|
|
102
|
+
*
|
|
103
|
+
* - Table: `children` (TableSection or TableRow ids, or a template) and
|
|
104
|
+
* `cellComponents` (the components that `{ componentId }` cells show).
|
|
105
|
+
* - List and ListItem: an `action` event. The List event gets the index,
|
|
106
|
+
* label and value of the picked item.
|
|
107
|
+
* - Map: `selected` is writable, so a `{ "@path" }` binding gets the choice of
|
|
108
|
+
* the user.
|
|
109
|
+
*/
|
|
110
|
+
const dataDeclarations = {
|
|
111
|
+
Table: {
|
|
112
|
+
description: "A data table, in a plain Column, not a Card. Give \"columns\" and \"rows\", or \"children\": TableSection or TableRow ids, or a template { \"componentId\", \"path\" } repeating a TableRow per item. A component in a cell or header (Badge, Button, Icon, Text): { \"componentId\": \"<id>\" }, with the id in \"cellComponents\".",
|
|
113
|
+
props: tableSchema,
|
|
114
|
+
slots: {
|
|
115
|
+
children: "multiple",
|
|
116
|
+
cellComponents: "multiple"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
TableSection: {
|
|
120
|
+
accessibility: "self",
|
|
121
|
+
description: "A group of TableRow children in a Table. With header true, it is the header of the table.",
|
|
122
|
+
props: tableSectionSchema,
|
|
123
|
+
slots: require_layout.CHILDREN_SLOT
|
|
124
|
+
},
|
|
125
|
+
TableRow: {
|
|
126
|
+
accessibility: "self",
|
|
127
|
+
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.",
|
|
128
|
+
props: tableRowSchema,
|
|
129
|
+
slots: require_layout.CHILDREN_SLOT
|
|
130
|
+
},
|
|
131
|
+
TableCell: {
|
|
132
|
+
accessibility: "self",
|
|
133
|
+
description: "A cell of a TableRow. It shows \"text\", or its children. With header true, it is a header cell.",
|
|
134
|
+
props: tableCellSchema,
|
|
135
|
+
slots: require_layout.CHILDREN_SLOT
|
|
136
|
+
},
|
|
137
|
+
List: {
|
|
138
|
+
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.",
|
|
139
|
+
props: listSchema,
|
|
140
|
+
events: { action: {
|
|
141
|
+
description: "Runs when the user picks an item. The args are the index, label and value of the item.",
|
|
142
|
+
parameters: listSelection
|
|
143
|
+
} },
|
|
144
|
+
slots: require_layout.CHILDREN_SLOT
|
|
145
|
+
},
|
|
146
|
+
ListItem: {
|
|
147
|
+
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.",
|
|
148
|
+
props: listItemSchema,
|
|
149
|
+
events: { action: {
|
|
150
|
+
description: "Runs when the user picks the item.",
|
|
151
|
+
parameters: zod.z.object({})
|
|
152
|
+
} },
|
|
153
|
+
slots: require_layout.CHILDREN_SLOT
|
|
154
|
+
},
|
|
155
|
+
Chart: {
|
|
156
|
+
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.",
|
|
157
|
+
props: require_chart.chartSchema
|
|
158
|
+
},
|
|
159
|
+
Map: {
|
|
160
|
+
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.",
|
|
161
|
+
props: require_map.mapSchema,
|
|
162
|
+
writable: ["selected"]
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
exports.LIST_MARKERS = LIST_MARKERS;
|
|
168
|
+
exports.dataDeclarations = dataDeclarations;
|
|
169
|
+
exports.listItemSchema = listItemSchema;
|
|
170
|
+
exports.listSchema = listSchema;
|
|
171
|
+
exports.listSelection = listSelection;
|
|
172
|
+
exports.tableCellSchema = tableCellSchema;
|
|
173
|
+
exports.tableRowSchema = tableRowSchema;
|
|
174
|
+
exports.tableSchema = tableSchema;
|
|
175
|
+
exports.tableSectionSchema = tableSectionSchema;
|
|
176
|
+
//# sourceMappingURL=data.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.cjs","names":["z","sizeValue","weightProp","CHILDREN_SLOT","chartSchema","mapSchema"],"sources":["../../../src/generative-ui/standard/data.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { chartSchema } from \"./chart\";\nimport { CHILDREN_SLOT, sizeValue, weightProp } from \"./layout\";\nimport { mapSchema } from \"./map\";\n\n// ---- Schemas ----\n\nconst cellAlign = z.enum([\"start\", \"center\", \"end\"]).optional();\n\n/**\n * A table cell or column header that shows another component. `id` is an\n * alias of `componentId`.\n */\nconst tableComponentCell = z.union([\n z.object({ componentId: z.string() }),\n z.object({ id: z.string() }),\n]);\n\nconst tableColumn = z.union([\n z.string(),\n z.object({\n label: z.string(),\n align: cellAlign,\n width: sizeValue.optional(),\n componentId: z.string().optional(),\n }),\n tableComponentCell,\n]);\nexport type TableColumn = z.output<typeof tableColumn>;\n\nexport const tableSchema = z.object({\n caption: z\n .string()\n .optional()\n .describe(\"A short name of the table for screen readers. It is not shown\"),\n columns: z.array(tableColumn).optional().describe(\"Default []\"),\n // A cell is `unknown`, so booleans and null from bound data are valid too.\n rows: z\n .array(z.array(z.unknown()))\n .optional()\n .describe(\n 'A list of row lists. A cell is a string, a number, or { \"componentId\": \"<id>\" } to show a component. Default []',\n ),\n columnSizing: z.enum([\"auto\", \"equal\"]).optional().describe('Default \"auto\"'),\n dividers: z.boolean().optional().describe(\"Default true\"),\n stickyHeader: z.boolean().optional().describe(\"Default false\"),\n emptyLabel: z.string().optional().describe('Default \"No rows\"'),\n});\nexport const tableSectionSchema = z.object({\n header: z.boolean().optional().describe(\"Renders the rows as the header\"),\n rowDivider: z.boolean().optional(),\n});\nexport const tableRowSchema = z.object({\n header: z.boolean().optional(),\n label: z\n .string()\n .optional()\n .describe(\"The text of a header cell at the start of the row\"),\n labelColSpan: z.number().optional().describe(\"Columns the label cell spans\"),\n});\nexport const tableCellSchema = z.object({\n text: z.union([z.string(), z.number()]).optional(),\n header: z.boolean().optional(),\n align: cellAlign,\n vAlign: cellAlign.describe('Default \"start\"'),\n colSpan: z.number().optional(),\n rowSpan: z.number().optional(),\n width: sizeValue.optional(),\n padding: sizeValue.optional(),\n});\n\nconst listItemValue = z.union([\n z.string(),\n z.object({\n label: z.string(),\n description: z.string().optional(),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n value: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n \"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\",\n ),\n }),\n]);\nexport type ListItemValue = z.output<typeof listItemValue>;\n\nexport const LIST_MARKERS = [\"bullet\", \"number\", \"rich\", \"none\"] as const;\nexport type ListMarker = (typeof LIST_MARKERS)[number];\n\nexport const listSchema = z.object({\n items: z.array(listItemValue).optional(),\n direction: z\n .enum([\"vertical\", \"horizontal\"])\n .optional()\n .describe('Default \"vertical\". \"horizontal\" scrolls sideways'),\n align: z.enum([\"start\", \"center\", \"end\", \"stretch\"]).optional(),\n weight: weightProp,\n marker: z.enum(LIST_MARKERS).optional().describe('Default \"bullet\"'),\n connector: z.enum([\"none\", \"solid\"]).optional().describe('Default \"none\"'),\n gap: sizeValue.optional(),\n start: z.number().optional().describe('The first number of marker \"number\"'),\n maxMarkerSize: z\n .number()\n .optional()\n .describe(\"The width of the marker column in pixels\"),\n});\nexport const listItemSchema = z.object({\n label: z.string().optional(),\n value: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n \"Without an action: shown on the right of the label, for a key and value fact\",\n ),\n description: z.string().optional(),\n icon: z.string().optional().describe(\"Lucide icon name\"),\n marker: z.string().optional().describe(\"Shows this text as the marker\"),\n markerSize: z\n .number()\n .optional()\n .describe(\"The width of the marker column in pixels\"),\n disabled: z\n .boolean()\n .optional()\n .describe(\"Greys the item out and ignores its action\"),\n});\n\nexport const listSelection = z.object({\n index: z.number(),\n label: z.string(),\n value: z.string().optional(),\n});\n\nexport type ListSelection = z.output<typeof listSelection>;\n\n/**\n * The standard data components, without their framework components:\n * tables, lists, a chart and a map. Each framework adds its components\n * with `withComponents`.\n *\n * - Table: `children` (TableSection or TableRow ids, or a template) and\n * `cellComponents` (the components that `{ componentId }` cells show).\n * - List and ListItem: an `action` event. The List event gets the index,\n * label and value of the picked item.\n * - Map: `selected` is writable, so a `{ \"@path\" }` binding gets the choice of\n * the user.\n */\nexport const dataDeclarations = {\n Table: {\n description:\n 'A data table, in a plain Column, not a Card. Give \"columns\" and \"rows\", or \"children\": TableSection or TableRow ids, or a template { \"componentId\", \"path\" } repeating a TableRow per item. A component in a cell or header (Badge, Button, Icon, Text): { \"componentId\": \"<id>\" }, with the id in \"cellComponents\".',\n props: tableSchema,\n slots: { children: \"multiple\", cellComponents: \"multiple\" } as const,\n },\n TableSection: {\n accessibility: \"self\" as const,\n description:\n \"A group of TableRow children in a Table. With header true, it is the header of the table.\",\n props: tableSectionSchema,\n slots: CHILDREN_SLOT,\n },\n TableRow: {\n accessibility: \"self\" as const,\n description:\n \"A row of a Table. Its children are TableCell ids, or a template. With label, a header cell with that text starts the row.\",\n props: tableRowSchema,\n slots: CHILDREN_SLOT,\n },\n TableCell: {\n accessibility: \"self\" as const,\n description:\n 'A cell of a TableRow. It shows \"text\", or its children. With header true, it is a header cell.',\n props: tableCellSchema,\n slots: CHILDREN_SLOT,\n },\n List: {\n description:\n '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.',\n props: listSchema,\n events: {\n action: {\n description:\n \"Runs when the user picks an item. The args are the index, label and value of the item.\",\n parameters: listSelection,\n },\n },\n slots: CHILDREN_SLOT,\n },\n ListItem: {\n description:\n '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.',\n props: listItemSchema,\n events: {\n action: {\n description: \"Runs when the user picks the item.\",\n parameters: z.object({}),\n },\n },\n slots: CHILDREN_SLOT,\n },\n Chart: {\n description:\n '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.',\n props: chartSchema,\n },\n Map: {\n description:\n '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.',\n props: mapSchema,\n writable: [\"selected\"] as const,\n },\n};\n"],"mappings":";;;;;;;AAOA,MAAM,YAAYA,MAAE,KAAK;CAAC;CAAS;CAAU;CAAM,CAAC,CAAC,UAAU;;;;;AAM/D,MAAM,qBAAqBA,MAAE,MAAM,CACjCA,MAAE,OAAO,EAAE,aAAaA,MAAE,QAAQ,EAAE,CAAC,EACrCA,MAAE,OAAO,EAAE,IAAIA,MAAE,QAAQ,EAAE,CAAC,CAC7B,CAAC;AAEF,MAAM,cAAcA,MAAE,MAAM;CAC1BA,MAAE,QAAQ;CACVA,MAAE,OAAO;EACP,OAAOA,MAAE,QAAQ;EACjB,OAAO;EACP,OAAOC,yBAAU,UAAU;EAC3B,aAAaD,MAAE,QAAQ,CAAC,UAAU;EACnC,CAAC;CACF;CACD,CAAC;AAGF,MAAa,cAAcA,MAAE,OAAO;CAClC,SAASA,MACN,QAAQ,CACR,UAAU,CACV,SAAS,gEAAgE;CAC5E,SAASA,MAAE,MAAM,YAAY,CAAC,UAAU,CAAC,SAAS,aAAa;CAE/D,MAAMA,MACH,MAAMA,MAAE,MAAMA,MAAE,SAAS,CAAC,CAAC,CAC3B,UAAU,CACV,SACC,sHACD;CACH,cAAcA,MAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC,CAAC,UAAU,CAAC,SAAS,mBAAiB;CAC7E,UAAUA,MAAE,SAAS,CAAC,UAAU,CAAC,SAAS,eAAe;CACzD,cAAcA,MAAE,SAAS,CAAC,UAAU,CAAC,SAAS,gBAAgB;CAC9D,YAAYA,MAAE,QAAQ,CAA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