@tangle-network/ui 11.9.0 → 11.11.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.
Files changed (155) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +14 -0
  3. package/dist/active-sessions-store-Gt1R0rFG.js +262 -0
  4. package/dist/{active-sessions-store-CeOmXgv5.d.ts → active-sessions-store-nl70ZnMC.d.ts} +40 -41
  5. package/dist/artifact-pane-BL_DFWNl.d.ts +32 -0
  6. package/dist/artifact-pane-DMXT9a8U.js +70 -0
  7. package/dist/auth-DixfCMCk.js +154 -0
  8. package/dist/auth.d.ts +2 -74
  9. package/dist/auth.js +2 -15
  10. package/dist/branding-26d5ARIr.d.ts +14 -0
  11. package/dist/button-uhNnwdsD.js +78 -0
  12. package/dist/button-yoIv77e2.d.ts +16 -0
  13. package/dist/chat-CPLL0Fd9.js +667 -0
  14. package/dist/chat.d.ts +2 -201
  15. package/dist/chat.js +2 -30
  16. package/dist/code-block-B9miUPht.d.ts +23 -0
  17. package/dist/code-block-CngSn37j.js +165 -0
  18. package/dist/diff-preview-cySuqowW.js +533 -0
  19. package/dist/document-editor-pane-BcoABlhn.d.ts +131 -0
  20. package/dist/document-editor-pane-Cz6oEF1o.js +1287 -0
  21. package/dist/dropdown-menu-BpcLa5vF.js +101 -0
  22. package/dist/editor.d.ts +76 -78
  23. package/dist/editor.js +2 -33
  24. package/dist/file-format-BgXbr-Ib.js +160 -0
  25. package/dist/files-CYlOo0mE.js +743 -0
  26. package/dist/files.d.ts +2 -243
  27. package/dist/files.js +3 -40
  28. package/dist/focus-Cw02pNSr.js +56 -0
  29. package/dist/format-DfcLWqMa.js +54 -0
  30. package/dist/hooks.d.ts +30 -37
  31. package/dist/hooks.js +111 -45
  32. package/dist/index-2UntyjBb.d.ts +52 -0
  33. package/dist/index-COgqsFAQ.d.ts +42 -0
  34. package/dist/index-CPDET_s1.d.ts +549 -0
  35. package/dist/index-CUhfHT_V.d.ts +204 -0
  36. package/dist/index-Cg6gYAqh.d.ts +73 -0
  37. package/dist/index-Cq-EJzqW.d.ts +16 -0
  38. package/dist/index-DhYmSaLF.d.ts +245 -0
  39. package/dist/index-DjKxO357.d.ts +128 -0
  40. package/dist/index-b56ew9aF.d.ts +107 -0
  41. package/dist/index.d.ts +26 -43
  42. package/dist/index.js +35 -460
  43. package/dist/markdown-BprL96Gl.js +45 -0
  44. package/dist/markdown.d.ts +3 -18
  45. package/dist/markdown.js +3 -14
  46. package/dist/message-vhUI0c5G.d.ts +16 -0
  47. package/dist/nav.d.ts +6 -8
  48. package/dist/nav.js +29 -11
  49. package/dist/openui-artifact-renderer-D3E5bIAI.d.ts +114 -0
  50. package/dist/openui-artifact-renderer-DT4xbvWt.js +266 -0
  51. package/dist/openui.d.ts +2 -115
  52. package/dist/openui.js +2 -12
  53. package/dist/parts-5mhy9yJ3.d.ts +37 -0
  54. package/dist/primitives-DE-blUz-.js +1239 -0
  55. package/dist/primitives.d.ts +5 -523
  56. package/dist/primitives.js +9 -211
  57. package/dist/redaction-CGGB2ENG.js +74 -0
  58. package/dist/redaction.d.ts +2 -42
  59. package/dist/redaction.js +2 -7
  60. package/dist/run-OyWmIDqu.d.ts +41 -0
  61. package/dist/run-ZsIKPA6J.js +17 -0
  62. package/dist/run-group-D1InSdQu.js +410 -0
  63. package/dist/run.d.ts +3 -126
  64. package/dist/run.js +5 -39
  65. package/dist/sdk-hooks.d.ts +2 -285
  66. package/dist/sdk-hooks.js +3 -35
  67. package/dist/stores.d.ts +13 -14
  68. package/dist/stores.js +34 -76
  69. package/dist/table-DHyqDPbU.js +146 -0
  70. package/dist/tabs-ujuqAdtb.js +40 -0
  71. package/dist/text-shimmer-BUUo6I-g.js +64 -0
  72. package/dist/tool-call-feed-BeB1_4pX.d.ts +47 -0
  73. package/dist/tool-call-feed-C1W1N54c.js +109 -0
  74. package/dist/tool-call-step-Bi3_YJRV.js +434 -0
  75. package/dist/tool-display-BAuAVa43.js +158 -0
  76. package/dist/{tool-display-z4JcDmMQ.d.ts → tool-display-DgmL5rIU.d.ts} +16 -16
  77. package/dist/tool-previews.d.ts +2 -48
  78. package/dist/tool-previews.js +2 -22
  79. package/dist/types.d.ts +6 -19
  80. package/dist/types.js +0 -1
  81. package/dist/use-auto-scroll-C5Pjeqon.js +153 -0
  82. package/dist/use-sse-stream-BjVBDbxK.js +884 -0
  83. package/dist/use-sse-stream-Dm6R5YWz.d.ts +282 -0
  84. package/dist/utils-Bl_CZ0Qp.js +37 -0
  85. package/dist/{chunk-RQHJBTEU.js → utils-C_uf36nf.js} +4 -6
  86. package/dist/utils.d.ts +2 -51
  87. package/dist/utils.js +6 -32
  88. package/package.json +39 -41
  89. package/src/auth/auth.tsx +5 -1
  90. package/src/chat/agent-timeline.tsx +6 -1
  91. package/src/chat/chat-container.tsx +2 -1
  92. package/src/editor/document-editor-pane.test.tsx +3 -1
  93. package/src/editor/document-editor-pane.tsx +5 -1
  94. package/src/editor/markdown-document-editor.test.tsx +9 -4
  95. package/src/files/file-artifact-pane.tsx +3 -2
  96. package/src/files/file-preview.tsx +3 -1
  97. package/src/files/file-tabs.tsx +9 -2
  98. package/src/lib/focus.ts +63 -0
  99. package/src/markdown/code-block.tsx +5 -1
  100. package/src/primitives/badge.tsx +2 -1
  101. package/src/primitives/button.tsx +2 -1
  102. package/src/primitives/card.tsx +1 -2
  103. package/src/primitives/dialog.tsx +7 -1
  104. package/src/primitives/input.tsx +15 -14
  105. package/src/primitives/segmented-control.tsx +5 -3
  106. package/src/primitives/select.tsx +3 -1
  107. package/src/primitives/switch.tsx +3 -1
  108. package/src/primitives/tabs.tsx +6 -4
  109. package/src/primitives/terminal-display.tsx +6 -8
  110. package/src/primitives/toast.tsx +5 -1
  111. package/src/tool-previews/command-preview.tsx +5 -1
  112. package/src/tool-previews/web-search-preview.tsx +2 -1
  113. package/src/utils/index.ts +7 -0
  114. package/dist/artifact-pane-DpuWcAiF.d.ts +0 -33
  115. package/dist/button-CMQuQEW_.d.ts +0 -17
  116. package/dist/chunk-34A66VBG.js +0 -214
  117. package/dist/chunk-3OI2QKFD.js +0 -0
  118. package/dist/chunk-3TI5DEHV.js +0 -299
  119. package/dist/chunk-4CLN43XT.js +0 -45
  120. package/dist/chunk-565EATZZ.js +0 -156
  121. package/dist/chunk-5Z5ZYMOJ.js +0 -0
  122. package/dist/chunk-6BGQA4BQ.js +0 -0
  123. package/dist/chunk-7YOCS6IF.js +0 -728
  124. package/dist/chunk-EOAX2ENE.js +0 -60
  125. package/dist/chunk-GYPQXTJU.js +0 -230
  126. package/dist/chunk-HFL6R6IF.js +0 -37
  127. package/dist/chunk-HGML45QH.js +0 -104
  128. package/dist/chunk-KNYSKNZX.js +0 -550
  129. package/dist/chunk-L57WRIND.js +0 -59
  130. package/dist/chunk-LDLOJKPC.js +0 -1585
  131. package/dist/chunk-LTEKI7YJ.js +0 -59
  132. package/dist/chunk-MKTSMWVD.js +0 -109
  133. package/dist/chunk-ND3ZFXQK.js +0 -179
  134. package/dist/chunk-NKDZ7GZE.js +0 -192
  135. package/dist/chunk-NWECTSOH.js +0 -589
  136. package/dist/chunk-OEX7NZE3.js +0 -321
  137. package/dist/chunk-Q56BYXQF.js +0 -61
  138. package/dist/chunk-REJESC5U.js +0 -117
  139. package/dist/chunk-RQGKSCEZ.js +0 -0
  140. package/dist/chunk-TN4FUEWY.js +0 -437
  141. package/dist/chunk-VPWY4I5O.js +0 -1048
  142. package/dist/chunk-WUQDUBJG.js +0 -168
  143. package/dist/chunk-XGKULLYE.js +0 -40
  144. package/dist/chunk-XU3HB5QL.js +0 -127
  145. package/dist/chunk-XYAIX4SU.js +0 -133
  146. package/dist/chunk-YJ6RE5WV.js +0 -875
  147. package/dist/chunk-YTO5V6QS.js +0 -19
  148. package/dist/chunk-ZKCEAIIZ.js +0 -1395
  149. package/dist/code-block-0kSpWMnf.d.ts +0 -25
  150. package/dist/document-editor-pane-EX25CEYW.js +0 -12
  151. package/dist/document-editor-pane-IAEQn_Dl.d.ts +0 -128
  152. package/dist/message-BHWbxBtT.d.ts +0 -15
  153. package/dist/parts-dj7AcUg0.d.ts +0 -36
  154. package/dist/run-PfLmDAox.d.ts +0 -41
  155. package/dist/tool-call-feed-D9iofJgW.d.ts +0 -46
@@ -1,214 +0,0 @@
1
- import {
2
- cn
3
- } from "./chunk-RQHJBTEU.js";
4
-
5
- // src/primitives/avatar.tsx
6
- import * as AvatarPrimitive from "@radix-ui/react-avatar";
7
- import * as React from "react";
8
- import { jsx } from "react/jsx-runtime";
9
- var Avatar = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
10
- AvatarPrimitive.Root,
11
- {
12
- ref,
13
- className: cn(
14
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
15
- className
16
- ),
17
- ...props
18
- }
19
- ));
20
- Avatar.displayName = AvatarPrimitive.Root.displayName;
21
- var AvatarImage = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
22
- AvatarPrimitive.Image,
23
- {
24
- ref,
25
- className: cn("aspect-square h-full w-full", className),
26
- ...props
27
- }
28
- ));
29
- AvatarImage.displayName = AvatarPrimitive.Image.displayName;
30
- var AvatarFallback = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
31
- AvatarPrimitive.Fallback,
32
- {
33
- ref,
34
- className: cn(
35
- "flex h-full w-full items-center justify-center rounded-full bg-muted font-medium text-sm",
36
- className
37
- ),
38
- ...props
39
- }
40
- ));
41
- AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
42
-
43
- // src/primitives/dropdown-menu.tsx
44
- import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
45
- import { Check, ChevronRight, Circle } from "lucide-react";
46
- import * as React2 from "react";
47
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
48
- var DropdownMenu = DropdownMenuPrimitive.Root;
49
- var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
50
- var DropdownMenuGroup = DropdownMenuPrimitive.Group;
51
- var DropdownMenuPortal = DropdownMenuPrimitive.Portal;
52
- var DropdownMenuSub = DropdownMenuPrimitive.Sub;
53
- var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
54
- var DropdownMenuSubTrigger = React2.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
55
- DropdownMenuPrimitive.SubTrigger,
56
- {
57
- ref,
58
- className: cn(
59
- "flex cursor-default select-none items-center rounded-md px-2 py-1.5 text-sm outline-none",
60
- "focus:bg-accent data-[state=open]:bg-muted/50",
61
- inset && "pl-8",
62
- className
63
- ),
64
- ...props,
65
- children: [
66
- children,
67
- /* @__PURE__ */ jsx2(ChevronRight, { className: "ml-auto h-4 w-4" })
68
- ]
69
- }
70
- ));
71
- DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
72
- var DropdownMenuSubContent = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx2(
73
- DropdownMenuPrimitive.SubContent,
74
- {
75
- ref,
76
- className: cn(
77
- "z-50 min-w-[8rem] overflow-hidden rounded-xl border border-border bg-card p-1 text-foreground shadow-[var(--shadow-card)]",
78
- "data-[state=closed]:animate-out data-[state=open]:animate-in",
79
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
80
- "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
81
- "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2",
82
- "data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
83
- className
84
- ),
85
- ...props
86
- }
87
- ));
88
- DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
89
- var DropdownMenuContent = React2.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx2(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx2(
90
- DropdownMenuPrimitive.Content,
91
- {
92
- ref,
93
- sideOffset,
94
- className: cn(
95
- "z-50 min-w-[8rem] overflow-hidden rounded-xl border border-border bg-card p-1 text-foreground shadow-[var(--shadow-card)]",
96
- "data-[state=closed]:animate-out data-[state=open]:animate-in",
97
- "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
98
- "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
99
- "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2",
100
- "data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
101
- className
102
- ),
103
- ...props
104
- }
105
- ) }));
106
- DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
107
- var DropdownMenuItem = React2.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx2(
108
- DropdownMenuPrimitive.Item,
109
- {
110
- ref,
111
- className: cn(
112
- "relative flex cursor-pointer select-none items-center rounded-md px-2 py-1.5 text-sm outline-none transition-colors",
113
- "focus:bg-muted/50 focus:text-foreground",
114
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
115
- inset && "pl-8",
116
- className
117
- ),
118
- ...props
119
- }
120
- ));
121
- DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
122
- var DropdownMenuCheckboxItem = React2.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
123
- DropdownMenuPrimitive.CheckboxItem,
124
- {
125
- ref,
126
- className: cn(
127
- "relative flex cursor-pointer select-none items-center rounded-md py-1.5 pr-2 pl-8 text-sm outline-none transition-colors",
128
- "focus:bg-muted/50 focus:text-foreground",
129
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
130
- className
131
- ),
132
- checked,
133
- ...props,
134
- children: [
135
- /* @__PURE__ */ jsx2("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx2(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx2(Check, { className: "h-4 w-4" }) }) }),
136
- children
137
- ]
138
- }
139
- ));
140
- DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
141
- var DropdownMenuRadioItem = React2.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
142
- DropdownMenuPrimitive.RadioItem,
143
- {
144
- ref,
145
- className: cn(
146
- "relative flex cursor-pointer select-none items-center rounded-md py-1.5 pr-2 pl-8 text-sm outline-none transition-colors",
147
- "focus:bg-muted/50 focus:text-foreground",
148
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
149
- className
150
- ),
151
- ...props,
152
- children: [
153
- /* @__PURE__ */ jsx2("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx2(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx2(Circle, { className: "h-2 w-2 fill-current" }) }) }),
154
- children
155
- ]
156
- }
157
- ));
158
- DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
159
- var DropdownMenuLabel = React2.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx2(
160
- DropdownMenuPrimitive.Label,
161
- {
162
- ref,
163
- className: cn(
164
- "px-2 py-1.5 font-semibold text-sm",
165
- inset && "pl-8",
166
- className
167
- ),
168
- ...props
169
- }
170
- ));
171
- DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
172
- var DropdownMenuSeparator = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx2(
173
- DropdownMenuPrimitive.Separator,
174
- {
175
- ref,
176
- className: cn("-mx-1 my-1 h-px bg-border", className),
177
- ...props
178
- }
179
- ));
180
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
181
- var DropdownMenuShortcut = ({
182
- className,
183
- ...props
184
- }) => {
185
- return /* @__PURE__ */ jsx2(
186
- "span",
187
- {
188
- className: cn("ml-auto text-xs tracking-widest opacity-60", className),
189
- ...props
190
- }
191
- );
192
- };
193
- DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
194
-
195
- export {
196
- Avatar,
197
- AvatarImage,
198
- AvatarFallback,
199
- DropdownMenu,
200
- DropdownMenuTrigger,
201
- DropdownMenuGroup,
202
- DropdownMenuPortal,
203
- DropdownMenuSub,
204
- DropdownMenuRadioGroup,
205
- DropdownMenuSubTrigger,
206
- DropdownMenuSubContent,
207
- DropdownMenuContent,
208
- DropdownMenuItem,
209
- DropdownMenuCheckboxItem,
210
- DropdownMenuRadioItem,
211
- DropdownMenuLabel,
212
- DropdownMenuSeparator,
213
- DropdownMenuShortcut
214
- };
File without changes
@@ -1,299 +0,0 @@
1
- import {
2
- Badge,
3
- Card,
4
- CardContent,
5
- CardDescription,
6
- CardHeader,
7
- CardTitle,
8
- Table,
9
- TableBody,
10
- TableCell,
11
- TableHead,
12
- TableHeader,
13
- TableRow
14
- } from "./chunk-GYPQXTJU.js";
15
- import {
16
- Button
17
- } from "./chunk-MKTSMWVD.js";
18
- import {
19
- Markdown
20
- } from "./chunk-EOAX2ENE.js";
21
- import {
22
- CodeBlock
23
- } from "./chunk-WUQDUBJG.js";
24
- import {
25
- cn
26
- } from "./chunk-RQHJBTEU.js";
27
-
28
- // src/openui/openui-artifact-renderer.tsx
29
- import { Fragment } from "react";
30
- import { Minus } from "lucide-react";
31
- import { jsx, jsxs } from "react/jsx-runtime";
32
- var NODE_TYPES = /* @__PURE__ */ new Set([
33
- "heading",
34
- "text",
35
- "badge",
36
- "stat",
37
- "key_value",
38
- "code",
39
- "markdown",
40
- "table",
41
- "actions",
42
- "separator",
43
- "stack",
44
- "grid",
45
- "card"
46
- ]);
47
- var GAP_STYLES = {
48
- sm: "gap-2",
49
- md: "gap-4",
50
- lg: "gap-6"
51
- };
52
- var GRID_STYLES = {
53
- 1: "grid-cols-1",
54
- 2: "grid-cols-1 md:grid-cols-2",
55
- 3: "grid-cols-1 md:grid-cols-3",
56
- 4: "grid-cols-1 md:grid-cols-2 xl:grid-cols-4"
57
- };
58
- var ALIGN_STYLES = {
59
- start: "items-start",
60
- center: "items-center",
61
- end: "items-end",
62
- stretch: "items-stretch"
63
- };
64
- function formatValue(value) {
65
- if (value === null || value === void 0) {
66
- return /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" });
67
- }
68
- if (typeof value === "boolean") {
69
- return value ? "Yes" : "No";
70
- }
71
- return value;
72
- }
73
- function asArray(value) {
74
- return Array.isArray(value) ? value : [];
75
- }
76
- function isOpenUIComponentNode(value) {
77
- return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string" && NODE_TYPES.has(value.type);
78
- }
79
- function renderActions(actions, onAction) {
80
- if (actions.length === 0) return null;
81
- return /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions.map((action) => /* @__PURE__ */ jsx(
82
- Button,
83
- {
84
- type: "button",
85
- size: "sm",
86
- variant: action.tone ?? "outline",
87
- disabled: action.disabled,
88
- onClick: () => {
89
- action.onPress?.();
90
- onAction?.(action);
91
- },
92
- children: action.label
93
- },
94
- action.id
95
- )) });
96
- }
97
- function renderNode(node, onAction) {
98
- switch (node.type) {
99
- case "heading": {
100
- const level = node.level ?? 2;
101
- const HeadingTag = `h${level}`;
102
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
103
- node.kicker && /* @__PURE__ */ jsx("div", { className: "text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground", children: node.kicker }),
104
- /* @__PURE__ */ jsx(
105
- HeadingTag,
106
- {
107
- className: cn(
108
- "font-semibold tracking-tight text-foreground",
109
- level === 1 && "text-2xl",
110
- level === 2 && "text-xl",
111
- level === 3 && "text-lg",
112
- level === 4 && "text-base"
113
- ),
114
- children: node.text
115
- }
116
- ),
117
- node.meta && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: node.meta })
118
- ] });
119
- }
120
- case "text":
121
- return /* @__PURE__ */ jsx(
122
- "p",
123
- {
124
- className: cn(
125
- "text-sm leading-6 text-foreground",
126
- node.tone === "muted" && "text-muted-foreground",
127
- node.tone === "success" && "text-[var(--surface-success-text)]",
128
- node.tone === "warning" && "text-[var(--surface-warning-text)]",
129
- node.tone === "error" && "text-[var(--surface-danger-text)]",
130
- node.mono && "font-mono text-[13px]"
131
- ),
132
- children: node.text
133
- }
134
- );
135
- case "badge":
136
- return /* @__PURE__ */ jsx(Badge, { variant: node.tone ?? "outline", children: node.label });
137
- case "stat":
138
- return /* @__PURE__ */ jsx(Card, { variant: "glass", className: "border-border shadow-[var(--shadow-card)]", children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-2 p-4", children: [
139
- /* @__PURE__ */ jsx("div", { className: "text-xs uppercase tracking-[0.12em] text-muted-foreground", children: node.label }),
140
- /* @__PURE__ */ jsx("div", { className: "text-2xl font-semibold tracking-tight text-foreground", children: node.value }),
141
- node.change && /* @__PURE__ */ jsx(
142
- "div",
143
- {
144
- className: cn(
145
- "text-xs",
146
- node.tone === "success" && "text-[var(--surface-success-text)]",
147
- node.tone === "warning" && "text-[var(--surface-warning-text)]",
148
- node.tone === "error" && "text-[var(--surface-danger-text)]",
149
- node.tone === "info" && "text-[var(--surface-info-text)]",
150
- !node.tone || node.tone === "default" ? "text-muted-foreground" : void 0
151
- ),
152
- children: node.change
153
- }
154
- )
155
- ] }) });
156
- case "key_value":
157
- if (asArray(node.items).length === 0) {
158
- return null;
159
- }
160
- return /* @__PURE__ */ jsx("dl", { className: "grid gap-3 sm:grid-cols-2", children: asArray(node.items).map((item, index) => /* @__PURE__ */ jsxs(
161
- "div",
162
- {
163
- className: "rounded-[var(--radius-lg)] border border-border bg-card px-4 py-3",
164
- children: [
165
- /* @__PURE__ */ jsx("dt", { className: "text-[11px] uppercase tracking-[0.12em] text-muted-foreground", children: item.label }),
166
- /* @__PURE__ */ jsx(
167
- "dd",
168
- {
169
- className: cn(
170
- "mt-1 text-sm font-medium text-foreground",
171
- item.tone === "muted" && "text-foreground"
172
- ),
173
- children: formatValue(item.value)
174
- }
175
- )
176
- ]
177
- },
178
- item.id ?? `${item.label}-${index}`
179
- )) });
180
- case "code":
181
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
182
- node.title && /* @__PURE__ */ jsx("div", { className: "text-xs uppercase tracking-[0.12em] text-muted-foreground", children: node.title }),
183
- /* @__PURE__ */ jsx(
184
- CodeBlock,
185
- {
186
- code: node.code,
187
- language: node.language,
188
- showLineNumbers: node.showLineNumbers,
189
- className: "border-border bg-background"
190
- }
191
- )
192
- ] });
193
- case "markdown":
194
- return /* @__PURE__ */ jsx("div", { className: "rounded-[var(--radius-lg)] border border-border bg-card p-5", children: /* @__PURE__ */ jsx(Markdown, { className: "prose-sm max-w-none", children: node.content }) });
195
- case "table":
196
- if (asArray(node.columns).length === 0) {
197
- return null;
198
- }
199
- return /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card", children: [
200
- /* @__PURE__ */ jsxs(Table, { children: [
201
- /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsx(TableRow, { className: "border-border", children: asArray(node.columns).map((column) => /* @__PURE__ */ jsx(
202
- TableHead,
203
- {
204
- className: cn(
205
- "h-10 text-[11px] uppercase tracking-[0.1em] text-muted-foreground",
206
- column.align === "right" && "text-right"
207
- ),
208
- children: column.header
209
- },
210
- column.key
211
- )) }) }),
212
- /* @__PURE__ */ jsx(TableBody, { children: asArray(node.rows).map((row, rowIndex) => /* @__PURE__ */ jsx(TableRow, { className: "border-border", children: asArray(node.columns).map((column) => /* @__PURE__ */ jsx(
213
- TableCell,
214
- {
215
- className: cn(
216
- "py-3 text-sm text-foreground",
217
- column.align === "right" && "text-right tabular-nums"
218
- ),
219
- children: formatValue(row[column.key])
220
- },
221
- column.key
222
- )) }, rowIndex)) })
223
- ] }),
224
- node.caption && /* @__PURE__ */ jsx("div", { className: "border-t border-border px-4 py-2 text-xs text-muted-foreground", children: node.caption })
225
- ] });
226
- case "actions":
227
- return renderActions(asArray(node.actions), onAction);
228
- case "separator":
229
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
230
- /* @__PURE__ */ jsx("div", { className: "h-px flex-1 bg-border" }),
231
- node.label && /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-[0.14em] text-muted-foreground", children: node.label }),
232
- /* @__PURE__ */ jsx("div", { className: "h-px flex-1 bg-border" })
233
- ] });
234
- case "stack":
235
- if (asArray(node.children).length === 0) {
236
- return null;
237
- }
238
- return /* @__PURE__ */ jsx(
239
- "div",
240
- {
241
- className: cn(
242
- "flex",
243
- node.direction === "row" ? "flex-row" : "flex-col",
244
- GAP_STYLES[node.gap ?? "md"],
245
- ALIGN_STYLES[node.align ?? "stretch"],
246
- node.wrap && "flex-wrap"
247
- ),
248
- children: asArray(node.children).map((child, index) => /* @__PURE__ */ jsx(Fragment, { children: renderNode(child, onAction) }, child.id ?? `${child.type}-${index}`))
249
- }
250
- );
251
- case "grid":
252
- if (asArray(node.children).length === 0) {
253
- return null;
254
- }
255
- return /* @__PURE__ */ jsx("div", { className: cn("grid", GRID_STYLES[node.columns ?? 2], GAP_STYLES[node.gap ?? "md"]), children: asArray(node.children).map((child, index) => /* @__PURE__ */ jsx(Fragment, { children: renderNode(child, onAction) }, child.id ?? `${child.type}-${index}`)) });
256
- case "card":
257
- return /* @__PURE__ */ jsxs(Card, { variant: "glass", className: "border-border shadow-[var(--shadow-card)]", children: [
258
- (node.eyebrow || node.title || node.description || node.badge || asArray(node.actions).length > 0) && /* @__PURE__ */ jsxs(CardHeader, { className: "gap-2 p-4 pb-0", children: [
259
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
260
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
261
- node.eyebrow && /* @__PURE__ */ jsx("div", { className: "text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground", children: node.eyebrow }),
262
- node.title && /* @__PURE__ */ jsx(CardTitle, { className: "text-base text-foreground", children: node.title }),
263
- node.description && /* @__PURE__ */ jsx(CardDescription, { className: "text-muted-foreground", children: node.description })
264
- ] }),
265
- node.badge && /* @__PURE__ */ jsx(Badge, { variant: node.badge.tone ?? "outline", children: node.badge.label })
266
- ] }),
267
- asArray(node.actions).length > 0 && renderActions(asArray(node.actions), onAction)
268
- ] }),
269
- asArray(node.children).length > 0 && /* @__PURE__ */ jsx(CardContent, { className: "space-y-4 p-4", children: asArray(node.children).map((child, index) => /* @__PURE__ */ jsx(Fragment, { children: renderNode(child, onAction) }, child.id ?? `${child.type}-${index}`)) })
270
- ] });
271
- }
272
- }
273
- function OpenUIArtifactRenderer({
274
- schema,
275
- onAction,
276
- className
277
- }) {
278
- const nodes = (Array.isArray(schema) ? schema : [schema]).filter(isOpenUIComponentNode);
279
- if (nodes.length === 0) {
280
- return /* @__PURE__ */ jsx(
281
- "div",
282
- {
283
- className: cn(
284
- "flex min-h-[6rem] items-center justify-center rounded-[var(--radius-xl)] border border-dashed border-border bg-card p-5 text-center",
285
- className
286
- ),
287
- children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
288
- /* @__PURE__ */ jsx("div", { className: "mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-muted/50 text-muted-foreground", children: /* @__PURE__ */ jsx(Minus, { className: "h-4 w-4" }) }),
289
- /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-foreground", children: "No view was generated." })
290
- ] })
291
- }
292
- );
293
- }
294
- return /* @__PURE__ */ jsx("div", { className: cn("space-y-4", className), children: nodes.map((node, index) => /* @__PURE__ */ jsx(Fragment, { children: renderNode(node, onAction) }, node.id ?? `${node.type}-${index}`)) });
295
- }
296
-
297
- export {
298
- OpenUIArtifactRenderer
299
- };
@@ -1,45 +0,0 @@
1
- // src/utils/format.ts
2
- function formatDuration(ms) {
3
- if (ms < 1e3) return "<1s";
4
- const seconds = Math.floor(ms / 1e3);
5
- if (seconds < 60) return `${seconds}s`;
6
- const minutes = Math.floor(seconds / 60);
7
- const remaining = seconds % 60;
8
- return remaining > 0 ? `${minutes}m ${remaining}s` : `${minutes}m`;
9
- }
10
- function truncateText(text, max) {
11
- const cleaned = text.replace(/\s+/g, " ").trim();
12
- if (cleaned.length <= max) return cleaned;
13
- return cleaned.slice(0, max).trim() + "...";
14
- }
15
- function formatUptime(ms) {
16
- if (!Number.isFinite(ms) || ms < 0) return "\u2014";
17
- const totalSeconds = Math.floor(ms / 1e3);
18
- if (totalSeconds < 60) return `${totalSeconds}s`;
19
- const minutes = Math.floor(totalSeconds / 60);
20
- const seconds = totalSeconds % 60;
21
- if (minutes < 60) return `${minutes}m ${seconds}s`;
22
- const hours = Math.floor(minutes / 60);
23
- const remMinutes = minutes % 60;
24
- if (hours < 24) return `${hours}h ${remMinutes}m`;
25
- const days = Math.floor(hours / 24);
26
- const remHours = hours % 24;
27
- return `${days}d ${remHours}h`;
28
- }
29
- function formatBytes(bytes) {
30
- if (!Number.isFinite(bytes) || bytes < 0) return "\u2014";
31
- if (bytes < 1024) return `${Math.round(bytes)} B`;
32
- const kb = bytes / 1024;
33
- if (kb < 1024) return `${kb < 10 ? kb.toFixed(1) : Math.round(kb)} KB`;
34
- const mb = kb / 1024;
35
- if (mb < 1024) return `${mb < 10 ? mb.toFixed(1) : Math.round(mb)} MB`;
36
- const gb = mb / 1024;
37
- return `${gb < 10 ? gb.toFixed(2) : gb.toFixed(1)} GB`;
38
- }
39
-
40
- export {
41
- formatDuration,
42
- truncateText,
43
- formatUptime,
44
- formatBytes
45
- };