cortena-ui 1.3.0 → 1.4.0
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 +74 -3
- package/dist/a2ui/catalogue-doc.d.ts +44 -0
- package/dist/a2ui/catalogue-doc.js +169 -0
- package/dist/a2ui/catalogue-doc.js.map +1 -0
- package/dist/a2ui/catalogue.d.ts +44 -0
- package/dist/a2ui/catalogue.js +942 -0
- package/dist/a2ui/catalogue.js.map +1 -0
- package/dist/a2ui/index.d.ts +7 -0
- package/dist/a2ui/message.d.ts +232 -0
- package/dist/a2ui/message.js +365 -0
- package/dist/a2ui/message.js.map +1 -0
- package/dist/a2ui/renderer.d.ts +46 -0
- package/dist/a2ui/renderer.js +252 -0
- package/dist/a2ui/renderer.js.map +1 -0
- package/dist/a2ui/views.d.ts +80 -0
- package/dist/a2ui/views.js +596 -0
- package/dist/a2ui/views.js.map +1 -0
- package/dist/a2ui.d.ts +8 -0
- package/dist/a2ui.js +7 -0
- package/dist/chart.d.ts +9 -0
- package/dist/chart.js +9 -0
- package/dist/components/accordion.d.ts +22 -0
- package/dist/components/accordion.js +63 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.d.ts +15 -0
- package/dist/components/alert.js +64 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/avatar.d.ts +18 -0
- package/dist/components/avatar.js +40 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +47 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +71 -0
- package/dist/components/breadcrumb.js +123 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button-link.d.ts +28 -0
- package/dist/components/button-link.js +24 -0
- package/dist/components/button-link.js.map +1 -0
- package/dist/components/button.d.ts +24 -0
- package/dist/components/button.js +65 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +28 -0
- package/dist/components/calendar.js +123 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +32 -0
- package/dist/components/card.js +57 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/chart/chart.d.ts +71 -0
- package/dist/components/chart/chart.js +167 -0
- package/dist/components/chart/chart.js.map +1 -0
- package/dist/components/chart/container.d.ts +88 -0
- package/dist/components/chart/container.js +189 -0
- package/dist/components/chart/container.js.map +1 -0
- package/dist/components/chart/data.js +128 -0
- package/dist/components/chart/data.js.map +1 -0
- package/dist/components/chart/index.d.ts +9 -0
- package/dist/components/chart/index.js +10 -0
- package/dist/components/chart/nivo-charts.js +225 -0
- package/dist/components/chart/nivo-charts.js.map +1 -0
- package/dist/components/chart/nivo-lazy.js +50 -0
- package/dist/components/chart/nivo-lazy.js.map +1 -0
- package/dist/components/chart/nivo-theme.d.ts +156 -0
- package/dist/components/chart/nivo-theme.js +161 -0
- package/dist/components/chart/nivo-theme.js.map +1 -0
- package/dist/components/chart/recharts-charts.js +276 -0
- package/dist/components/chart/recharts-charts.js.map +1 -0
- package/dist/components/chart/recharts-lazy.js +58 -0
- package/dist/components/chart/recharts-lazy.js.map +1 -0
- package/dist/components/chart/recharts-parts.d.ts +10 -0
- package/dist/components/chart/recharts-parts.js +25 -0
- package/dist/components/chart/recharts-parts.js.map +1 -0
- package/dist/components/chart/tokens.d.ts +62 -0
- package/dist/components/chart/tokens.js +192 -0
- package/dist/components/chart/tokens.js.map +1 -0
- package/dist/components/chart/types.d.ts +114 -0
- package/dist/components/chart/types.js +27 -0
- package/dist/components/chart/types.js.map +1 -0
- package/dist/components/checkbox.d.ts +20 -0
- package/dist/components/checkbox.js +24 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip.d.ts +17 -0
- package/dist/components/chip.js +47 -0
- package/dist/components/chip.js.map +1 -0
- package/dist/components/combobox.d.ts +76 -0
- package/dist/components/combobox.js +201 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command.d.ts +50 -0
- package/dist/components/command.js +117 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/data-table/data-table.d.ts +65 -0
- package/dist/components/data-table/data-table.js +588 -0
- package/dist/components/data-table/data-table.js.map +1 -0
- package/dist/components/data-table/export.d.ts +23 -0
- package/dist/components/data-table/export.js +95 -0
- package/dist/components/data-table/export.js.map +1 -0
- package/dist/components/data-table/features.d.ts +66 -0
- package/dist/components/data-table/features.js +103 -0
- package/dist/components/data-table/features.js.map +1 -0
- package/dist/components/data-table/index.d.ts +8 -0
- package/dist/components/data-table/parts.d.ts +79 -0
- package/dist/components/data-table/parts.js +400 -0
- package/dist/components/data-table/parts.js.map +1 -0
- package/dist/components/data-table/system-columns.js +84 -0
- package/dist/components/data-table/system-columns.js.map +1 -0
- package/dist/components/data-table/types.d.ts +172 -0
- package/dist/components/data-table/use-data-table.d.ts +19 -0
- package/dist/components/data-table/use-data-table.js +171 -0
- package/dist/components/data-table/use-data-table.js.map +1 -0
- package/dist/components/data-table/use-server-source.js +200 -0
- package/dist/components/data-table/use-server-source.js.map +1 -0
- package/dist/components/date-field.d.ts +54 -0
- package/dist/components/date-field.js +235 -0
- package/dist/components/date-field.js.map +1 -0
- package/dist/components/date-picker.d.ts +42 -0
- package/dist/components/date-picker.js +125 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dialog.d.ts +36 -0
- package/dist/components/dialog.js +97 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +54 -0
- package/dist/components/dropdown-menu.js +191 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/dropzone.d.ts +48 -0
- package/dist/components/dropzone.js +185 -0
- package/dist/components/dropzone.js.map +1 -0
- package/dist/components/empty-state.d.ts +22 -0
- package/dist/components/empty-state.js +46 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/error-banner.d.ts +17 -0
- package/dist/components/error-banner.js +52 -0
- package/dist/components/error-banner.js.map +1 -0
- package/dist/components/field.d.ts +64 -0
- package/dist/components/field.js +133 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/form.d.ts +37 -0
- package/dist/components/form.js +103 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +26 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/kbd.d.ts +11 -0
- package/dist/components/kbd.js +20 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.d.ts +14 -0
- package/dist/components/label.js +28 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/loading-skeleton.d.ts +22 -0
- package/dist/components/loading-skeleton.js +123 -0
- package/dist/components/loading-skeleton.js.map +1 -0
- package/dist/components/markdown.d.ts +44 -0
- package/dist/components/markdown.js +231 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/page-header.d.ts +26 -0
- package/dist/components/page-header.js +53 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/popover.d.ts +29 -0
- package/dist/components/popover.js +74 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.d.ts +22 -0
- package/dist/components/progress.js +49 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +20 -0
- package/dist/components/radio-group.js +29 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/scroll-area.d.ts +25 -0
- package/dist/components/scroll-area.js +39 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/section-card.d.ts +29 -0
- package/dist/components/section-card.js +55 -0
- package/dist/components/section-card.js.map +1 -0
- package/dist/components/segmented.d.ts +27 -0
- package/dist/components/segmented.js +32 -0
- package/dist/components/segmented.js.map +1 -0
- package/dist/components/select.d.ts +62 -0
- package/dist/components/select.js +97 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +19 -0
- package/dist/components/separator.js +23 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +35 -0
- package/dist/components/sheet.js +131 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/skeleton.d.ts +12 -0
- package/dist/components/skeleton.js +22 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/sortable-list.d.ts +67 -0
- package/dist/components/sortable-list.js +206 -0
- package/dist/components/sortable-list.js.map +1 -0
- package/dist/components/spinner.d.ts +29 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/status-dot.d.ts +26 -0
- package/dist/components/status-dot.js +47 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/switch.d.ts +21 -0
- package/dist/components/switch.js +21 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/tabs.d.ts +24 -0
- package/dist/components/tabs.js +60 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +19 -0
- package/dist/components/textarea.js +47 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toast.d.ts +47 -0
- package/dist/components/toast.js +106 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toolbar.d.ts +19 -0
- package/dist/components/toolbar.js +45 -0
- package/dist/components/toolbar.js.map +1 -0
- package/dist/components/tooltip.d.ts +28 -0
- package/dist/components/tooltip.js +59 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/core.d.ts +44 -0
- package/dist/core.js +44 -0
- package/dist/data-table.d.ts +9 -0
- package/dist/data-table.js +7 -0
- package/dist/form.d.ts +7 -0
- package/dist/form.js +7 -0
- package/dist/hooks/use-cortena-theme.d.ts +98 -0
- package/dist/hooks/use-cortena-theme.js +145 -0
- package/dist/hooks/use-cortena-theme.js.map +1 -0
- package/dist/index.d.ts +75 -2678
- package/dist/index.js +66 -8598
- package/dist/lib/cn.d.ts +10 -0
- package/dist/lib/cn.js +15 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/render.d.ts +23 -0
- package/dist/lib/render.js +20 -0
- package/dist/lib/render.js.map +1 -0
- package/dist/lib/shakeable.js +39 -0
- package/dist/lib/shakeable.js.map +1 -0
- package/dist/markdown.d.ts +3 -0
- package/dist/markdown.js +3 -0
- package/dist/sortable-list.d.ts +3 -0
- package/dist/sortable-list.js +3 -0
- package/package.json +37 -14
- package/src/a2ui/catalogue.ts +140 -103
- package/src/a2ui/views.tsx +5 -2
- package/src/components/alert.tsx +1 -1
- package/src/components/badge.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/chart/chart.tsx +72 -25
- package/src/components/chart/container.tsx +24 -39
- package/src/components/chart/index.tsx +4 -2
- package/src/components/chart/nivo-charts.tsx +41 -13
- package/src/components/chart/nivo-lazy.tsx +52 -0
- package/src/components/chart/recharts-charts.tsx +98 -3
- package/src/components/chart/recharts-lazy.tsx +72 -0
- package/src/components/chart/recharts-parts.tsx +34 -0
- package/src/components/chart/tokens.ts +1 -1
- package/src/components/chart/types.ts +14 -0
- package/src/components/chip.tsx +1 -1
- package/src/components/combobox.tsx +2 -2
- package/src/components/data-table/export.ts +18 -2
- package/src/components/data-table/features.ts +77 -45
- package/src/components/data-table/parts.tsx +15 -0
- package/src/components/data-table/use-data-table.ts +7 -2
- package/src/components/data-table/use-server-source.ts +17 -4
- package/src/components/date-field.tsx +1 -1
- package/src/components/error-banner.tsx +1 -1
- package/src/components/field.tsx +2 -2
- package/src/components/form.tsx +2 -2
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +1 -1
- package/src/components/markdown.tsx +5 -4
- package/src/components/sheet.tsx +2 -2
- package/src/components/sortable-list.tsx +2 -2
- package/src/components/textarea.tsx +1 -1
- package/src/components/toast.tsx +1 -1
- package/src/entries/a2ui.ts +11 -0
- package/src/entries/chart.ts +10 -0
- package/src/entries/core.ts +91 -0
- package/src/entries/data-table.ts +9 -0
- package/src/entries/form.ts +24 -0
- package/src/entries/markdown.ts +9 -0
- package/src/entries/sortable-list.ts +13 -0
- package/src/index.ts +32 -98
- package/src/lib/shakeable.ts +33 -0
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { Alert, AlertDescription, AlertIcon, AlertTitle } from "../components/alert.js";
|
|
5
|
+
import { Badge } from "../components/badge.js";
|
|
6
|
+
import { Button } from "../components/button.js";
|
|
7
|
+
import { ButtonLink } from "../components/button-link.js";
|
|
8
|
+
import { Card, CardContent } from "../components/card.js";
|
|
9
|
+
import { Checkbox } from "../components/checkbox.js";
|
|
10
|
+
import { Input } from "../components/input.js";
|
|
11
|
+
import { EmptyState } from "../components/empty-state.js";
|
|
12
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "../components/field.js";
|
|
13
|
+
import { Progress, ProgressLabel, ProgressValue } from "../components/progress.js";
|
|
14
|
+
import { RadioGroup, RadioGroupItem } from "../components/radio-group.js";
|
|
15
|
+
import { SectionCard } from "../components/section-card.js";
|
|
16
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../components/select.js";
|
|
17
|
+
import { Separator } from "../components/separator.js";
|
|
18
|
+
import { StatusDot } from "../components/status-dot.js";
|
|
19
|
+
import { Switch } from "../components/switch.js";
|
|
20
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../components/tabs.js";
|
|
21
|
+
import { Textarea } from "../components/textarea.js";
|
|
22
|
+
import { DateField, formatDateISO, parseDateISO } from "../components/date-field.js";
|
|
23
|
+
import { DataTable } from "../components/data-table/data-table.js";
|
|
24
|
+
import { Chart } from "../components/chart/chart.js";
|
|
25
|
+
import { Markdown } from "../components/markdown.js";
|
|
26
|
+
import { AlertTriangle, CheckCircle2, Info, OctagonAlert, Terminal } from "lucide-react";
|
|
27
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
28
|
+
import * as React from "react";
|
|
29
|
+
//#region src/a2ui/views.tsx
|
|
30
|
+
/**
|
|
31
|
+
* The cortena-ui side of the A2UI catalogue.
|
|
32
|
+
*
|
|
33
|
+
* One React view per catalogue entry. Each is a real component, not a render
|
|
34
|
+
* function, so an interactive entry can hold hooks (draft input state, the
|
|
35
|
+
* debounce timer) without the renderer having to care which entries are
|
|
36
|
+
* stateful.
|
|
37
|
+
*
|
|
38
|
+
* Views receive already-resolved props: the renderer has read the data
|
|
39
|
+
* bindings, validated against the entry's zod schema and normalised actions
|
|
40
|
+
* before any of this runs. A view therefore never parses A2UI, and never sees
|
|
41
|
+
* an unvalidated value.
|
|
42
|
+
*
|
|
43
|
+
* Every visual value is a cortena-design token, as everywhere else in the
|
|
44
|
+
* package. The Tailwind scale maps below exist because Tailwind only emits a
|
|
45
|
+
* class it can see in the source, so `gap-${n}` would silently produce nothing.
|
|
46
|
+
*/
|
|
47
|
+
/** Tailwind spacing steps an agent may pick. Written out so Tailwind emits them. */
|
|
48
|
+
const GAP = {
|
|
49
|
+
0: "gap-0",
|
|
50
|
+
1: "gap-1",
|
|
51
|
+
2: "gap-2",
|
|
52
|
+
3: "gap-3",
|
|
53
|
+
4: "gap-4",
|
|
54
|
+
6: "gap-6",
|
|
55
|
+
8: "gap-8"
|
|
56
|
+
};
|
|
57
|
+
const PADDING = {
|
|
58
|
+
0: "p-0",
|
|
59
|
+
1: "p-1",
|
|
60
|
+
2: "p-2",
|
|
61
|
+
3: "p-3",
|
|
62
|
+
4: "p-4",
|
|
63
|
+
6: "p-6",
|
|
64
|
+
8: "p-8"
|
|
65
|
+
};
|
|
66
|
+
const HEIGHT = {
|
|
67
|
+
0: "h-0",
|
|
68
|
+
1: "h-1",
|
|
69
|
+
2: "h-2",
|
|
70
|
+
3: "h-3",
|
|
71
|
+
4: "h-4",
|
|
72
|
+
6: "h-6",
|
|
73
|
+
8: "h-8"
|
|
74
|
+
};
|
|
75
|
+
const ALIGN = {
|
|
76
|
+
start: "items-start",
|
|
77
|
+
center: "items-center",
|
|
78
|
+
end: "items-end",
|
|
79
|
+
stretch: "items-stretch",
|
|
80
|
+
baseline: "items-baseline"
|
|
81
|
+
};
|
|
82
|
+
const JUSTIFY = {
|
|
83
|
+
start: "justify-start",
|
|
84
|
+
center: "justify-center",
|
|
85
|
+
end: "justify-end",
|
|
86
|
+
between: "justify-between"
|
|
87
|
+
};
|
|
88
|
+
const TEXT_ALIGN = {
|
|
89
|
+
start: "text-left",
|
|
90
|
+
center: "text-center",
|
|
91
|
+
end: "text-right"
|
|
92
|
+
};
|
|
93
|
+
const TEXT_ROLE = {
|
|
94
|
+
heading: "font-display text-[length:var(--ds-text-h3)] leading-[var(--ds-text-h3--line-height)] font-semibold",
|
|
95
|
+
subheading: "text-[length:var(--ds-text-body-md)] leading-[var(--ds-text-body-md--line-height)] font-semibold",
|
|
96
|
+
body: "text-[length:var(--ds-text-body-sm)] leading-[var(--ds-text-body-sm--line-height)]",
|
|
97
|
+
caption: "text-[length:var(--ds-text-caption)] leading-[var(--ds-text-caption--line-height)]",
|
|
98
|
+
eyebrow: "text-[length:var(--ds-text-eyebrow)] leading-[var(--ds-text-eyebrow--line-height)] font-medium uppercase tracking-[var(--ds-text-eyebrow--letter-spacing)]"
|
|
99
|
+
};
|
|
100
|
+
const TEXT_TONE = {
|
|
101
|
+
default: "text-[color:var(--ds-foreground)]",
|
|
102
|
+
muted: "text-[color:var(--ds-muted-foreground)]",
|
|
103
|
+
success: "text-[color:var(--ds-success)]",
|
|
104
|
+
warning: "text-[color:var(--ds-warning)]",
|
|
105
|
+
danger: "text-[color:var(--ds-destructive)]",
|
|
106
|
+
info: "text-[color:var(--ds-info)]"
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Components that are inline by nature.
|
|
110
|
+
*
|
|
111
|
+
* A Column stretches its children on the cross axis, which is right for a field
|
|
112
|
+
* or a table and wrong for a badge — one would span the whole surface. `w-fit`
|
|
113
|
+
* gives the item an explicit cross size, which is what disables the stretch,
|
|
114
|
+
* without overriding a Row's own alignment.
|
|
115
|
+
*/
|
|
116
|
+
const INLINE = "w-fit";
|
|
117
|
+
const ALERT_ICON = {
|
|
118
|
+
default: /* @__PURE__ */ jsx(Terminal, {}),
|
|
119
|
+
success: /* @__PURE__ */ jsx(CheckCircle2, {}),
|
|
120
|
+
warn: /* @__PURE__ */ jsx(AlertTriangle, {}),
|
|
121
|
+
danger: /* @__PURE__ */ jsx(OctagonAlert, {}),
|
|
122
|
+
info: /* @__PURE__ */ jsx(Info, {})
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Debounce a value. Used for continuous inputs so an agent receives one action
|
|
126
|
+
* per pause rather than one per keystroke; the visible input stays immediate.
|
|
127
|
+
*/
|
|
128
|
+
function useDebouncedEmit(emit, delay) {
|
|
129
|
+
const latest = React.useRef(emit);
|
|
130
|
+
latest.current = emit;
|
|
131
|
+
const timer = React.useRef(void 0);
|
|
132
|
+
React.useEffect(() => () => {
|
|
133
|
+
if (timer.current !== void 0) clearTimeout(timer.current);
|
|
134
|
+
}, []);
|
|
135
|
+
return React.useCallback((value) => {
|
|
136
|
+
if (timer.current !== void 0) clearTimeout(timer.current);
|
|
137
|
+
timer.current = setTimeout(() => latest.current(value), delay);
|
|
138
|
+
}, [delay]);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A value that follows the data model but can be typed over.
|
|
142
|
+
*
|
|
143
|
+
* The bound value wins whenever the agent changes it; between agent updates the
|
|
144
|
+
* local draft wins, so typing is not swallowed by a re-render.
|
|
145
|
+
*
|
|
146
|
+
* `key` is what identity is judged on, and defaults to the value itself. It
|
|
147
|
+
* matters for a value the renderer rebuilds each pass — a Date parsed from an
|
|
148
|
+
* ISO string is a new object every render, so comparing the objects would reset
|
|
149
|
+
* the draft forever. Compare the string instead.
|
|
150
|
+
*/
|
|
151
|
+
function useDraft(bound, key = bound) {
|
|
152
|
+
const [draft, setDraft] = React.useState(bound);
|
|
153
|
+
const previous = React.useRef(key);
|
|
154
|
+
if (!Object.is(previous.current, key)) {
|
|
155
|
+
previous.current = key;
|
|
156
|
+
setDraft(bound);
|
|
157
|
+
}
|
|
158
|
+
return [draft, setDraft];
|
|
159
|
+
}
|
|
160
|
+
const ColumnView = ({ props, children }) => /* @__PURE__ */ jsx("div", {
|
|
161
|
+
"data-slot": "a2ui-column",
|
|
162
|
+
className: cn("flex min-w-0 flex-col", GAP[props.gap ?? 3], props.padding !== void 0 ? PADDING[props.padding] : void 0, props.align ? ALIGN[props.align] : void 0, props.justify ? JUSTIFY[props.justify] : void 0),
|
|
163
|
+
children
|
|
164
|
+
});
|
|
165
|
+
const RowView = ({ props, children }) => /* @__PURE__ */ jsx("div", {
|
|
166
|
+
"data-slot": "a2ui-row",
|
|
167
|
+
className: cn("flex min-w-0 flex-row", props.wrap === false ? "flex-nowrap" : "flex-wrap", GAP[props.gap ?? 2], props.padding !== void 0 ? PADDING[props.padding] : void 0, ALIGN[props.align ?? "center"], props.justify ? JUSTIFY[props.justify] : void 0),
|
|
168
|
+
children
|
|
169
|
+
});
|
|
170
|
+
const CardView = ({ props, children }) => /* @__PURE__ */ jsx(Card, {
|
|
171
|
+
"data-slot": "a2ui-card",
|
|
172
|
+
accent: props.accent,
|
|
173
|
+
children: props.flush ? /* @__PURE__ */ jsx("div", {
|
|
174
|
+
className: "flex flex-col gap-3",
|
|
175
|
+
children
|
|
176
|
+
}) : /* @__PURE__ */ jsx(CardContent, {
|
|
177
|
+
className: "flex flex-col gap-3 p-5",
|
|
178
|
+
children
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
const SectionCardView = ({ props, children }) => /* @__PURE__ */ jsx(SectionCard, {
|
|
182
|
+
"data-slot": "a2ui-section-card",
|
|
183
|
+
title: props.title,
|
|
184
|
+
description: props.description,
|
|
185
|
+
flush: props.flush,
|
|
186
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
187
|
+
className: "flex flex-col gap-3",
|
|
188
|
+
children
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
const DividerView = ({ props }) => /* @__PURE__ */ jsx(Separator, {
|
|
192
|
+
"data-slot": "a2ui-divider",
|
|
193
|
+
orientation: props.orientation ?? "horizontal"
|
|
194
|
+
});
|
|
195
|
+
const SpacerView = ({ props }) => /* @__PURE__ */ jsx("div", {
|
|
196
|
+
"data-slot": "a2ui-spacer",
|
|
197
|
+
"aria-hidden": true,
|
|
198
|
+
className: cn("w-full", HEIGHT[props.size ?? 4])
|
|
199
|
+
});
|
|
200
|
+
const TextView = ({ props }) => /* @__PURE__ */ jsx("p", {
|
|
201
|
+
"data-slot": "a2ui-text",
|
|
202
|
+
"data-role": props.role ?? "body",
|
|
203
|
+
className: cn("min-w-0 break-words", TEXT_ROLE[props.role ?? "body"], TEXT_TONE[props.tone ?? "default"], props.align ? TEXT_ALIGN[props.align] : void 0, props.mono ? "font-[family-name:var(--ds-font-mono)]" : void 0),
|
|
204
|
+
children: props.text
|
|
205
|
+
});
|
|
206
|
+
const MarkdownView = ({ props }) => /* @__PURE__ */ jsx(Markdown, {
|
|
207
|
+
"data-slot": "a2ui-markdown",
|
|
208
|
+
compact: props.compact,
|
|
209
|
+
children: props.text
|
|
210
|
+
});
|
|
211
|
+
function FieldShell({ label, description, error, children, slot, orientation, controlId }) {
|
|
212
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
213
|
+
"data-slot": slot,
|
|
214
|
+
orientation: orientation ?? "vertical",
|
|
215
|
+
invalid: Boolean(error),
|
|
216
|
+
children: [
|
|
217
|
+
label ? /* @__PURE__ */ jsx(FieldLabel, {
|
|
218
|
+
htmlFor: controlId,
|
|
219
|
+
children: label
|
|
220
|
+
}) : null,
|
|
221
|
+
children,
|
|
222
|
+
description ? /* @__PURE__ */ jsx(FieldDescription, { children: description }) : null,
|
|
223
|
+
error ? /* @__PURE__ */ jsx(FieldError, { children: error }) : null
|
|
224
|
+
]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
const TextFieldView = ({ props, emit, writeBack, debounceMs }) => {
|
|
228
|
+
const id = React.useId();
|
|
229
|
+
const [draft, setDraft] = useDraft(props.value ?? "");
|
|
230
|
+
const send = useDebouncedEmit((value) => emit(props.onChange, "change", { value }), debounceMs);
|
|
231
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
232
|
+
slot: "a2ui-text-field",
|
|
233
|
+
label: props.label,
|
|
234
|
+
description: props.description,
|
|
235
|
+
error: props.error,
|
|
236
|
+
controlId: id,
|
|
237
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
238
|
+
id,
|
|
239
|
+
type: props.type ?? "text",
|
|
240
|
+
value: draft,
|
|
241
|
+
placeholder: props.placeholder,
|
|
242
|
+
disabled: props.disabled,
|
|
243
|
+
required: props.required,
|
|
244
|
+
"aria-label": props.label ? void 0 : props.placeholder ?? "Text field",
|
|
245
|
+
onChange: (event) => {
|
|
246
|
+
const next = event.target.value;
|
|
247
|
+
setDraft(next);
|
|
248
|
+
writeBack("value", next);
|
|
249
|
+
send(next);
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
const TextAreaView = ({ props, emit, writeBack, debounceMs }) => {
|
|
255
|
+
const id = React.useId();
|
|
256
|
+
const [draft, setDraft] = useDraft(props.value ?? "");
|
|
257
|
+
const send = useDebouncedEmit((value) => emit(props.onChange, "change", { value }), debounceMs);
|
|
258
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
259
|
+
slot: "a2ui-text-area",
|
|
260
|
+
label: props.label,
|
|
261
|
+
description: props.description,
|
|
262
|
+
error: props.error,
|
|
263
|
+
controlId: id,
|
|
264
|
+
children: /* @__PURE__ */ jsx(Textarea, {
|
|
265
|
+
id,
|
|
266
|
+
value: draft,
|
|
267
|
+
rows: props.rows ?? 4,
|
|
268
|
+
placeholder: props.placeholder,
|
|
269
|
+
disabled: props.disabled,
|
|
270
|
+
autoGrow: props.autoGrow,
|
|
271
|
+
"aria-label": props.label ? void 0 : props.placeholder ?? "Text area",
|
|
272
|
+
onChange: (event) => {
|
|
273
|
+
const next = event.target.value;
|
|
274
|
+
setDraft(next);
|
|
275
|
+
writeBack("value", next);
|
|
276
|
+
send(next);
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
const SelectView = ({ props, emit, writeBack }) => {
|
|
282
|
+
const [draft, setDraft] = useDraft(props.value ?? null);
|
|
283
|
+
const items = React.useMemo(() => props.options.map((option) => ({
|
|
284
|
+
value: option.value,
|
|
285
|
+
label: option.label ?? option.value
|
|
286
|
+
})), [props.options]);
|
|
287
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
288
|
+
slot: "a2ui-select",
|
|
289
|
+
label: props.label,
|
|
290
|
+
description: props.description,
|
|
291
|
+
error: props.error,
|
|
292
|
+
children: /* @__PURE__ */ jsxs(Select, {
|
|
293
|
+
items,
|
|
294
|
+
value: draft,
|
|
295
|
+
disabled: props.disabled,
|
|
296
|
+
onValueChange: (next) => {
|
|
297
|
+
const value = next === null ? "" : String(next);
|
|
298
|
+
setDraft(value);
|
|
299
|
+
writeBack("value", value);
|
|
300
|
+
emit(props.onChange, "change", { value });
|
|
301
|
+
},
|
|
302
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
303
|
+
"aria-label": props.label ?? props.placeholder ?? "Select",
|
|
304
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: props.placeholder ?? "Select…" })
|
|
305
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: props.options.map((option) => /* @__PURE__ */ jsx(SelectItem, {
|
|
306
|
+
value: option.value,
|
|
307
|
+
disabled: option.disabled,
|
|
308
|
+
children: option.label ?? option.value
|
|
309
|
+
}, option.value)) })]
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
const CheckboxView = ({ props, emit, writeBack }) => {
|
|
314
|
+
const [draft, setDraft] = useDraft(props.checked ?? false);
|
|
315
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
316
|
+
slot: "a2ui-checkbox",
|
|
317
|
+
description: props.description,
|
|
318
|
+
orientation: "horizontal",
|
|
319
|
+
children: /* @__PURE__ */ jsxs("label", {
|
|
320
|
+
className: "flex items-start gap-3 text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-foreground)]",
|
|
321
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
322
|
+
className: "flex h-5 items-center",
|
|
323
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
324
|
+
checked: draft,
|
|
325
|
+
disabled: props.disabled,
|
|
326
|
+
"aria-label": props.label ?? "Checkbox",
|
|
327
|
+
onCheckedChange: (checked) => {
|
|
328
|
+
setDraft(checked);
|
|
329
|
+
writeBack("checked", checked);
|
|
330
|
+
emit(props.onChange, "change", { checked });
|
|
331
|
+
}
|
|
332
|
+
})
|
|
333
|
+
}), /* @__PURE__ */ jsx("span", { children: props.label })]
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
const SwitchView = ({ props, emit, writeBack }) => {
|
|
338
|
+
const [draft, setDraft] = useDraft(props.checked ?? false);
|
|
339
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
340
|
+
slot: "a2ui-switch",
|
|
341
|
+
description: props.description,
|
|
342
|
+
orientation: "horizontal",
|
|
343
|
+
children: /* @__PURE__ */ jsxs("label", {
|
|
344
|
+
className: "flex items-center gap-3 text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-foreground)]",
|
|
345
|
+
children: [/* @__PURE__ */ jsx(Switch, {
|
|
346
|
+
checked: draft,
|
|
347
|
+
disabled: props.disabled,
|
|
348
|
+
"aria-label": props.label ?? "Switch",
|
|
349
|
+
onCheckedChange: (checked) => {
|
|
350
|
+
setDraft(checked);
|
|
351
|
+
writeBack("checked", checked);
|
|
352
|
+
emit(props.onChange, "change", { checked });
|
|
353
|
+
}
|
|
354
|
+
}), /* @__PURE__ */ jsx("span", { children: props.label })]
|
|
355
|
+
})
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
const RadioGroupView = ({ props, emit, writeBack }) => {
|
|
359
|
+
const [draft, setDraft] = useDraft(props.value ?? "");
|
|
360
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
361
|
+
slot: "a2ui-radio-group",
|
|
362
|
+
label: props.label,
|
|
363
|
+
description: props.description,
|
|
364
|
+
children: /* @__PURE__ */ jsx(RadioGroup, {
|
|
365
|
+
"aria-label": props.label ?? "Options",
|
|
366
|
+
value: draft,
|
|
367
|
+
disabled: props.disabled,
|
|
368
|
+
onValueChange: (next) => {
|
|
369
|
+
const value = String(next);
|
|
370
|
+
setDraft(value);
|
|
371
|
+
writeBack("value", value);
|
|
372
|
+
emit(props.onChange, "change", { value });
|
|
373
|
+
},
|
|
374
|
+
children: props.options.map((option) => /* @__PURE__ */ jsxs("label", {
|
|
375
|
+
className: "flex items-start gap-3 text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-foreground)]",
|
|
376
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
377
|
+
className: "flex h-5 items-center",
|
|
378
|
+
children: /* @__PURE__ */ jsx(RadioGroupItem, {
|
|
379
|
+
value: option.value,
|
|
380
|
+
disabled: option.disabled
|
|
381
|
+
})
|
|
382
|
+
}), /* @__PURE__ */ jsx("span", { children: option.label ?? option.value })]
|
|
383
|
+
}, option.value))
|
|
384
|
+
})
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
const DateFieldView = ({ props, emit, writeBack }) => {
|
|
388
|
+
const id = React.useId();
|
|
389
|
+
const [draft, setDraft] = useDraft(props.value ? parseDateISO(props.value) : void 0, props.value ?? "");
|
|
390
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
391
|
+
slot: "a2ui-date-field",
|
|
392
|
+
label: props.label,
|
|
393
|
+
description: props.description,
|
|
394
|
+
error: props.error,
|
|
395
|
+
controlId: id,
|
|
396
|
+
children: /* @__PURE__ */ jsx(DateField, {
|
|
397
|
+
id,
|
|
398
|
+
value: draft,
|
|
399
|
+
min: props.min ? parseDateISO(props.min) : void 0,
|
|
400
|
+
max: props.max ? parseDateISO(props.max) : void 0,
|
|
401
|
+
disabled: props.disabled,
|
|
402
|
+
invalid: Boolean(props.error),
|
|
403
|
+
"aria-label": props.label ?? "Date",
|
|
404
|
+
onValueChange: (date) => {
|
|
405
|
+
setDraft(date);
|
|
406
|
+
const value = date ? formatDateISO(date) : "";
|
|
407
|
+
writeBack("value", value);
|
|
408
|
+
emit(props.onChange, "change", { value });
|
|
409
|
+
}
|
|
410
|
+
})
|
|
411
|
+
});
|
|
412
|
+
};
|
|
413
|
+
const ButtonView = ({ props, emit, dataModel }) => /* @__PURE__ */ jsx(Button, {
|
|
414
|
+
"data-slot": "a2ui-button",
|
|
415
|
+
className: INLINE,
|
|
416
|
+
variant: props.variant ?? "primary",
|
|
417
|
+
size: props.size ?? "md",
|
|
418
|
+
disabled: props.disabled,
|
|
419
|
+
onClick: () => emit(props.onPress, props.submit ? "submit" : "press", props.submit ? { data: dataModel } : {}),
|
|
420
|
+
children: props.label
|
|
421
|
+
});
|
|
422
|
+
const ButtonLinkView = ({ props }) => /* @__PURE__ */ jsx("span", {
|
|
423
|
+
"data-slot": "a2ui-button-link",
|
|
424
|
+
className: cn("inline-flex", INLINE),
|
|
425
|
+
children: /* @__PURE__ */ jsx(ButtonLink, {
|
|
426
|
+
variant: props.variant ?? "secondary",
|
|
427
|
+
size: props.size ?? "md",
|
|
428
|
+
href: props.href,
|
|
429
|
+
target: props.target,
|
|
430
|
+
rel: props.target === "_blank" ? "noopener noreferrer" : void 0,
|
|
431
|
+
children: props.label
|
|
432
|
+
})
|
|
433
|
+
});
|
|
434
|
+
const LinkView = ({ props }) => /* @__PURE__ */ jsx("a", {
|
|
435
|
+
"data-slot": "a2ui-link",
|
|
436
|
+
href: props.href,
|
|
437
|
+
target: props.target,
|
|
438
|
+
rel: props.target === "_blank" ? "noopener noreferrer" : void 0,
|
|
439
|
+
className: cn(INLINE, "text-[length:var(--ds-text-body-sm)] text-[color:var(--ds-primary)] underline underline-offset-4", "hover:text-[color:var(--ds-primary-hover)]"),
|
|
440
|
+
children: props.label
|
|
441
|
+
});
|
|
442
|
+
const BadgeView = ({ props }) => /* @__PURE__ */ jsx(Badge, {
|
|
443
|
+
"data-slot": "a2ui-badge",
|
|
444
|
+
className: INLINE,
|
|
445
|
+
variant: props.variant ?? "default",
|
|
446
|
+
children: props.label
|
|
447
|
+
});
|
|
448
|
+
const AlertView = ({ props }) => {
|
|
449
|
+
const variant = props.variant ?? "default";
|
|
450
|
+
return /* @__PURE__ */ jsxs(Alert, {
|
|
451
|
+
"data-slot": "a2ui-alert",
|
|
452
|
+
variant,
|
|
453
|
+
children: [/* @__PURE__ */ jsx(AlertIcon, { children: ALERT_ICON[variant] }), /* @__PURE__ */ jsxs("div", { children: [props.title ? /* @__PURE__ */ jsx(AlertTitle, { children: props.title }) : null, props.description ? /* @__PURE__ */ jsx(AlertDescription, { children: props.description }) : null] })]
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
const ProgressViewComponent = ({ props }) => /* @__PURE__ */ jsxs(Progress, {
|
|
457
|
+
"data-slot": "a2ui-progress",
|
|
458
|
+
value: props.value === void 0 ? null : props.value,
|
|
459
|
+
max: props.max,
|
|
460
|
+
"aria-label": props.label ?? "Progress",
|
|
461
|
+
children: [props.label ? /* @__PURE__ */ jsx(ProgressLabel, { children: props.label }) : null, props.showValue === false ? null : /* @__PURE__ */ jsx(ProgressValue, {})]
|
|
462
|
+
});
|
|
463
|
+
const StatusDotView = ({ props }) => /* @__PURE__ */ jsx(StatusDot, {
|
|
464
|
+
"data-slot": "a2ui-status-dot",
|
|
465
|
+
className: INLINE,
|
|
466
|
+
tone: props.tone ?? "accent",
|
|
467
|
+
live: props.live,
|
|
468
|
+
label: props.label
|
|
469
|
+
});
|
|
470
|
+
const EmptyStateView = ({ props, children }) => /* @__PURE__ */ jsx(EmptyState, {
|
|
471
|
+
"data-slot": "a2ui-empty-state",
|
|
472
|
+
title: props.title,
|
|
473
|
+
description: props.description,
|
|
474
|
+
size: props.size ?? "compact",
|
|
475
|
+
action: children.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
476
|
+
className: "flex gap-2",
|
|
477
|
+
children
|
|
478
|
+
}) : void 0
|
|
479
|
+
});
|
|
480
|
+
const DataTableView = ({ props, emit, resolveDataSource }) => {
|
|
481
|
+
const columns = React.useMemo(() => props.columns.map((column) => ({
|
|
482
|
+
id: column.id,
|
|
483
|
+
accessorKey: column.id,
|
|
484
|
+
header: column.label ?? column.id,
|
|
485
|
+
size: column.width,
|
|
486
|
+
meta: {
|
|
487
|
+
align: column.align,
|
|
488
|
+
filter: column.filter,
|
|
489
|
+
label: column.label ?? column.id
|
|
490
|
+
}
|
|
491
|
+
})), [props.columns]);
|
|
492
|
+
const source = props.dataSource;
|
|
493
|
+
const resolved = source.kind === "client" ? {
|
|
494
|
+
kind: "client",
|
|
495
|
+
rows: source.rows
|
|
496
|
+
} : resolveDataSource(source.sourceId);
|
|
497
|
+
if (!resolved) return /* @__PURE__ */ jsx(A2UIErrorCard, {
|
|
498
|
+
title: "Unknown data source",
|
|
499
|
+
detail: `No data source is registered for "${source.sourceId}". The host resolves a server table through resolveDataSource.`
|
|
500
|
+
});
|
|
501
|
+
return /* @__PURE__ */ jsx("div", {
|
|
502
|
+
"data-slot": "a2ui-data-table",
|
|
503
|
+
children: /* @__PURE__ */ jsx(DataTable, {
|
|
504
|
+
columns,
|
|
505
|
+
dataSource: resolved,
|
|
506
|
+
pageSize: props.pageSize ?? 10,
|
|
507
|
+
density: props.density ?? "compact",
|
|
508
|
+
maxHeight: props.maxHeight,
|
|
509
|
+
searchPlaceholder: props.searchPlaceholder,
|
|
510
|
+
emptyMessage: props.emptyMessage,
|
|
511
|
+
onRowClick: (row) => emit(props.onRowClick, "rowClick", { row })
|
|
512
|
+
})
|
|
513
|
+
});
|
|
514
|
+
};
|
|
515
|
+
const ChartView = ({ props }) => /* @__PURE__ */ jsxs("div", {
|
|
516
|
+
"data-slot": "a2ui-chart",
|
|
517
|
+
className: "flex flex-col gap-2",
|
|
518
|
+
children: [props.title ? /* @__PURE__ */ jsx("p", {
|
|
519
|
+
className: "text-[length:var(--ds-text-caption-lg)] font-medium text-[color:var(--ds-foreground)]",
|
|
520
|
+
children: props.title
|
|
521
|
+
}) : null, /* @__PURE__ */ jsx(Chart, {
|
|
522
|
+
type: props.type,
|
|
523
|
+
data: props.data,
|
|
524
|
+
height: props.height ?? 260,
|
|
525
|
+
stacked: props.stacked,
|
|
526
|
+
legend: props.legend,
|
|
527
|
+
grid: props.grid,
|
|
528
|
+
scale: props.scale,
|
|
529
|
+
indexBy: props.indexBy,
|
|
530
|
+
keys: props.keys,
|
|
531
|
+
from: props.from,
|
|
532
|
+
to: props.to,
|
|
533
|
+
emptyMessage: props.emptyMessage
|
|
534
|
+
})]
|
|
535
|
+
});
|
|
536
|
+
const TabsView = ({ props, children, emit, writeBack }) => {
|
|
537
|
+
const first = props.tabs[0]?.value ?? "";
|
|
538
|
+
const [draft, setDraft] = useDraft(props.value ?? first);
|
|
539
|
+
return /* @__PURE__ */ jsxs(Tabs, {
|
|
540
|
+
"data-slot": "a2ui-tabs",
|
|
541
|
+
value: draft,
|
|
542
|
+
onValueChange: (next) => {
|
|
543
|
+
const value = String(next);
|
|
544
|
+
setDraft(value);
|
|
545
|
+
writeBack("value", value);
|
|
546
|
+
emit(props.onChange, "tabChange", { value });
|
|
547
|
+
},
|
|
548
|
+
children: [/* @__PURE__ */ jsx(TabsList, { children: props.tabs.map((tab) => /* @__PURE__ */ jsx(TabsTrigger, {
|
|
549
|
+
value: tab.value,
|
|
550
|
+
children: tab.label
|
|
551
|
+
}, tab.value)) }), props.tabs.map((tab, index) => /* @__PURE__ */ jsx(TabsContent, {
|
|
552
|
+
value: tab.value,
|
|
553
|
+
children: children[index] ?? null
|
|
554
|
+
}, tab.value))]
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
const ImageView = ({ props }) => /* @__PURE__ */ jsx("img", {
|
|
558
|
+
"data-slot": "a2ui-image",
|
|
559
|
+
src: props.src,
|
|
560
|
+
alt: props.alt,
|
|
561
|
+
width: props.width,
|
|
562
|
+
height: props.height,
|
|
563
|
+
className: cn(INLINE, "max-w-full", props.fit === "cover" ? "object-cover" : "object-contain", props.rounded === false ? void 0 : "rounded-[var(--ds-radius-md)]", "border border-[var(--ds-border-subtle)]")
|
|
564
|
+
});
|
|
565
|
+
/**
|
|
566
|
+
* What the renderer draws instead of a component it cannot draw.
|
|
567
|
+
*
|
|
568
|
+
* Never raw markup and never the offending payload as HTML: the detail is set
|
|
569
|
+
* as text, so a malformed message cannot inject anything. This is the
|
|
570
|
+
* "fallback: an error card on malformed payloads" of `05-agent-ui.md`.
|
|
571
|
+
*/
|
|
572
|
+
function A2UIErrorCard({ title, detail, componentId }) {
|
|
573
|
+
return /* @__PURE__ */ jsxs(Alert, {
|
|
574
|
+
"data-slot": "a2ui-error",
|
|
575
|
+
variant: "danger",
|
|
576
|
+
role: "alert",
|
|
577
|
+
children: [/* @__PURE__ */ jsx(AlertIcon, { children: /* @__PURE__ */ jsx(OctagonAlert, {}) }), /* @__PURE__ */ jsxs("div", {
|
|
578
|
+
className: "min-w-0",
|
|
579
|
+
children: [
|
|
580
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: title }),
|
|
581
|
+
detail ? /* @__PURE__ */ jsx(AlertDescription, {
|
|
582
|
+
className: "font-[family-name:var(--ds-font-mono)] text-[length:var(--ds-text-caption)] break-words",
|
|
583
|
+
children: detail
|
|
584
|
+
}) : null,
|
|
585
|
+
componentId ? /* @__PURE__ */ jsxs(AlertDescription, {
|
|
586
|
+
className: "text-[length:var(--ds-text-caption-sm)] text-[color:var(--ds-muted-foreground)]",
|
|
587
|
+
children: ["Component id: ", componentId]
|
|
588
|
+
}) : null
|
|
589
|
+
]
|
|
590
|
+
})]
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
//#endregion
|
|
594
|
+
export { A2UIErrorCard, AlertView, BadgeView, ButtonLinkView, ButtonView, CardView, ChartView, CheckboxView, ColumnView, DataTableView, DateFieldView, DividerView, EmptyStateView, ImageView, LinkView, MarkdownView, ProgressViewComponent, RadioGroupView, RowView, SectionCardView, SelectView, SpacerView, StatusDotView, SwitchView, TabsView, TextAreaView, TextFieldView, TextView };
|
|
595
|
+
|
|
596
|
+
//# sourceMappingURL=views.js.map
|