macbetter 0.1.0-beta.1 → 0.1.0-beta.2

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 (65) hide show
  1. package/dist/components/artifact-card.d.ts +41 -0
  2. package/dist/components/artifact-card.js +57 -0
  3. package/dist/components/attachment.d.ts +48 -0
  4. package/dist/components/attachment.js +65 -0
  5. package/dist/components/chat.d.ts +29 -0
  6. package/dist/components/chat.js +29 -0
  7. package/dist/components/code-block.d.ts +39 -0
  8. package/dist/components/code-block.js +65 -0
  9. package/dist/components/confirmation.d.ts +24 -0
  10. package/dist/components/confirmation.js +50 -0
  11. package/dist/components/content-unavailable.d.ts +19 -0
  12. package/dist/components/content-unavailable.js +21 -0
  13. package/dist/components/description-list.d.ts +18 -0
  14. package/dist/components/description-list.js +17 -0
  15. package/dist/components/generated-image.d.ts +39 -0
  16. package/dist/components/generated-image.js +47 -0
  17. package/dist/components/inspector.d.ts +29 -0
  18. package/dist/components/inspector.js +40 -0
  19. package/dist/components/message.d.ts +65 -0
  20. package/dist/components/message.js +69 -0
  21. package/dist/components/model-picker.d.ts +61 -0
  22. package/dist/components/model-picker.js +59 -0
  23. package/dist/components/plan.d.ts +25 -0
  24. package/dist/components/plan.js +43 -0
  25. package/dist/components/prompt-input.d.ts +93 -0
  26. package/dist/components/prompt-input.js +172 -0
  27. package/dist/components/reasoning.d.ts +28 -0
  28. package/dist/components/reasoning.js +52 -0
  29. package/dist/components/response.d.ts +14 -0
  30. package/dist/components/response.js +14 -0
  31. package/dist/components/shimmer.d.ts +18 -0
  32. package/dist/components/shimmer.js +17 -0
  33. package/dist/components/sources.d.ts +51 -0
  34. package/dist/components/sources.js +46 -0
  35. package/dist/components/suggestion.d.ts +23 -0
  36. package/dist/components/suggestion.js +29 -0
  37. package/dist/components/tool-call.d.ts +48 -0
  38. package/dist/components/tool-call.js +77 -0
  39. package/dist/index.d.ts +19 -0
  40. package/dist/index.js +19 -0
  41. package/dist/lib/agent-glyphs.d.ts +10 -0
  42. package/dist/lib/agent-glyphs.js +19 -0
  43. package/dist/styles/components/artifact-card.css +238 -0
  44. package/dist/styles/components/attachment.css +540 -0
  45. package/dist/styles/components/chat.css +209 -0
  46. package/dist/styles/components/code-block.css +162 -0
  47. package/dist/styles/components/confirmation.css +189 -0
  48. package/dist/styles/components/content-unavailable.css +105 -0
  49. package/dist/styles/components/description-list.css +92 -0
  50. package/dist/styles/components/device-frame.css +8 -0
  51. package/dist/styles/components/generated-image.css +248 -0
  52. package/dist/styles/components/index.css +19 -0
  53. package/dist/styles/components/inspector.css +236 -0
  54. package/dist/styles/components/message.css +236 -0
  55. package/dist/styles/components/model-picker.css +64 -0
  56. package/dist/styles/components/navigation-bar.css +2 -1
  57. package/dist/styles/components/plan.css +212 -0
  58. package/dist/styles/components/prompt-input.css +503 -0
  59. package/dist/styles/components/reasoning.css +214 -0
  60. package/dist/styles/components/response.css +303 -0
  61. package/dist/styles/components/shimmer.css +60 -0
  62. package/dist/styles/components/sources.css +349 -0
  63. package/dist/styles/components/suggestion.css +203 -0
  64. package/dist/styles/components/tool-call.css +391 -0
  65. package/package.json +1 -1
@@ -0,0 +1,41 @@
1
+ import { type RenderProp } from "@ui-sdk/react/primitive";
2
+ import * as React from "react";
3
+ import type { SystemColor } from "../lib/theme.js";
4
+ import { type ButtonProps } from "./button.js";
5
+ type ArtifactCardState = "generating" | "ready";
6
+ type ArtifactCardProps = React.ComponentProps<"div"> & {
7
+ /** `generating` shimmers the meta line and puts a progress ring on the icon. */
8
+ state?: ArtifactCardState;
9
+ /** Progress from 0 to 100 while generating. Leave it out when it isn't known and the ring spins. */
10
+ progress?: number;
11
+ /** Makes the whole card one link or button. Use it only without ArtifactCardActions; otherwise pass `render` to ArtifactCardTitle. */
12
+ render?: RenderProp;
13
+ };
14
+ /** A row-shaped card for a file or document the assistant made, which opens it. */
15
+ declare function ArtifactCard({ state, progress, render, className, ...props }: ArtifactCardProps): React.JSX.Element;
16
+ type ArtifactCardIconProps = React.ComponentProps<"span"> & {
17
+ /** The tile's color. */
18
+ color?: SystemColor | "gray" | "accent";
19
+ };
20
+ /** The leading tile with the file's icon. While generating, a ring turns over it. */
21
+ declare function ArtifactCardIcon({ color, className, style, children, ...props }: ArtifactCardIconProps): React.JSX.Element;
22
+ type ArtifactCardTitleProps = React.ComponentProps<"span"> & {
23
+ /**
24
+ * Makes the title the card's link or button, such as `<a href="…" />`, with a hit area that
25
+ * covers the whole card. Use this when the card also has actions.
26
+ */
27
+ render?: RenderProp;
28
+ };
29
+ declare function ArtifactCardTitle({ render, id, className, ...props }: ArtifactCardTitleProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
30
+ /** The kind and who can see it, like "Slides · Only you". It shimmers while generating. */
31
+ declare function ArtifactCardMeta({ className, children, ...props }: React.ComponentProps<"span">): React.JSX.Element;
32
+ /** Trailing buttons, beside the card's main control rather than inside it. */
33
+ declare function ArtifactCardActions({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
34
+ type ArtifactCardActionProps = Omit<ButtonProps, "aria-label"> & {
35
+ /** The action's name, like "Download". The card's title is read after it. */
36
+ label: string;
37
+ };
38
+ /** An icon button for ArtifactCardActions, named by its label and the card's title: "Download Quarterly review". */
39
+ declare function ArtifactCardAction({ label, id, className, ...props }: ArtifactCardActionProps): React.JSX.Element;
40
+ export { ArtifactCard, ArtifactCardAction, ArtifactCardActions, ArtifactCardIcon, ArtifactCardMeta, ArtifactCardTitle, };
41
+ export type { ArtifactCardActionProps, ArtifactCardIconProps, ArtifactCardProps, ArtifactCardState, ArtifactCardTitleProps };
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { renderElement } from "@ui-sdk/react/primitive";
4
+ import * as React from "react";
5
+ import { cx, join } from "../lib/cx.js";
6
+ import { Button } from "./button.js";
7
+ import { ProgressCircle } from "./progress.js";
8
+ import { Shimmer } from "./shimmer.js";
9
+ const ArtifactCardContext = React.createContext({
10
+ state: "ready",
11
+ progress: null,
12
+ titleId: "",
13
+ });
14
+ /** A row-shaped card for a file or document the assistant made, which opens it. */
15
+ function ArtifactCard({ state = "ready", progress, render, className, ...props }) {
16
+ const titleId = React.useId();
17
+ const context = React.useMemo(() => ({ state, progress: progress ?? null, titleId }), [state, progress, titleId]);
18
+ return (_jsx(ArtifactCardContext.Provider, { value: context, children: renderElement("div", {
19
+ ...props,
20
+ "aria-busy": state === "generating" ? true : undefined,
21
+ "data-state": state,
22
+ "data-interactive": render ? "" : undefined,
23
+ className: join("mb-artifact-card", className),
24
+ }, render) }));
25
+ }
26
+ /** The leading tile with the file's icon. While generating, a ring turns over it. */
27
+ function ArtifactCardIcon({ color, className, style, children, ...props }) {
28
+ const { state, progress } = React.useContext(ArtifactCardContext);
29
+ const tint = color ? (color === "gray" ? "var(--mb-label-secondary)" : `var(--mb-${color})`) : undefined;
30
+ return (_jsxs("span", { "aria-hidden": state === "generating" ? undefined : true, className: join("mb-artifact-card-icon", className), style: tint ? { "--mb-artifact-card-tint": tint, ...style } : style, ...props, children: [_jsx("span", { "aria-hidden": "true", className: "mb-artifact-card-glyph", children: children }), state === "generating" ? (_jsx("span", { className: "mb-artifact-card-progress", children: _jsx(ProgressCircle, { size: "sm", value: progress, "aria-label": "Generating", className: "mb-artifact-card-ring" }) })) : null] }));
31
+ }
32
+ function ArtifactCardTitle({ render, id, className, ...props }) {
33
+ const { titleId } = React.useContext(ArtifactCardContext);
34
+ return renderElement("span", {
35
+ ...props,
36
+ id: id ?? (titleId || undefined),
37
+ "data-interactive": render ? "" : undefined,
38
+ className: join("mb-artifact-card-title", className),
39
+ }, render);
40
+ }
41
+ /** The kind and who can see it, like "Slides · Only you". It shimmers while generating. */
42
+ function ArtifactCardMeta({ className, children, ...props }) {
43
+ const { state } = React.useContext(ArtifactCardContext);
44
+ return (_jsx(Shimmer, { active: state === "generating", className: join("mb-artifact-card-meta", className), ...props, children: children }));
45
+ }
46
+ /** Trailing buttons, beside the card's main control rather than inside it. */
47
+ function ArtifactCardActions({ className, ...props }) {
48
+ return _jsx("div", { className: join("mb-artifact-card-actions", className), ...props });
49
+ }
50
+ /** An icon button for ArtifactCardActions, named by its label and the card's title: "Download Quarterly review". */
51
+ function ArtifactCardAction({ label, id, className, ...props }) {
52
+ const { titleId } = React.useContext(ArtifactCardContext);
53
+ const ownId = React.useId();
54
+ const buttonId = id ?? ownId;
55
+ return (_jsx(Button, { id: buttonId, variant: "plain", tone: "neutral", size: "sm", shape: "circle", "aria-label": label, "aria-labelledby": titleId ? `${buttonId} ${titleId}` : undefined, className: cx("mb-artifact-card-action", className), ...props }));
56
+ }
57
+ export { ArtifactCard, ArtifactCardAction, ArtifactCardActions, ArtifactCardIcon, ArtifactCardMeta, ArtifactCardTitle, };
@@ -0,0 +1,48 @@
1
+ import { Button as ButtonPrimitive } from "@ui-sdk/react/button";
2
+ import { type RenderProp } from "@ui-sdk/react/primitive";
3
+ import * as React from "react";
4
+ import type { SystemColor } from "../lib/theme.js";
5
+ type AttachmentVariant = "chip" | "tile" | "thumbnail" | "row";
6
+ type AttachmentState = "uploading" | "ready" | "error";
7
+ type AttachmentsProps = React.ComponentProps<"ul"> & {
8
+ /** `wrap` flows onto more lines, `scroll` keeps one line that scrolls sideways, `column` stacks rows. */
9
+ layout?: "wrap" | "scroll" | "column";
10
+ };
11
+ /** A list of attachments. Each Attachment inside becomes a list item. */
12
+ declare function Attachments({ layout, className, ...props }: AttachmentsProps): React.JSX.Element;
13
+ type AttachmentProps = React.ComponentProps<"div"> & {
14
+ /** `chip` for a composer, `tile` for a grid, `thumbnail` for an image alone, `row` for a list in an inspector. */
15
+ variant?: AttachmentVariant;
16
+ state?: AttachmentState;
17
+ /** Upload progress from 0 to 100 while `state` is `uploading`. Leave it out when the size isn't known. */
18
+ progress?: number;
19
+ /** Renders the attachment as a link or button, such as `<a href="…" />`. Use it only without AttachmentRemove. */
20
+ render?: RenderProp;
21
+ };
22
+ declare function Attachment({ variant, state, progress, className, render, ...props }: AttachmentProps): React.JSX.Element;
23
+ type AttachmentPreviewProps = React.ComponentProps<"span"> & {
24
+ /** An image to show. Without it, and without children, a document glyph is drawn. */
25
+ src?: string;
26
+ /** The image's description. Empty by default, since AttachmentName names the file. */
27
+ alt?: string;
28
+ /** A short type label printed on the document glyph, like `PDF` or `CSV`, where there's room. */
29
+ extension?: string;
30
+ /** The glyph's label color. */
31
+ color?: SystemColor | "gray" | "accent";
32
+ };
33
+ /** The image or file glyph. While uploading it shows the progress ring; after a failure, an alert badge. */
34
+ declare function AttachmentPreview({ src, alt, extension, color, className, style, children, ...props }: AttachmentPreviewProps): React.JSX.Element;
35
+ type AttachmentNameProps = React.ComponentProps<"span"> & {
36
+ /**
37
+ * Makes the name a link or button, such as `<a href="…" />`, whose hit area covers the whole
38
+ * attachment. Use this instead of Attachment's `render` when there's also a remove button.
39
+ */
40
+ render?: RenderProp;
41
+ };
42
+ declare function AttachmentName({ className, render, id, ...props }: AttachmentNameProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
43
+ /** The kind and size, like `PDF · 2.4 MB`, or what went wrong. */
44
+ declare function AttachmentMeta({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
45
+ /** Removes the attachment. It's named "Remove" plus the attachment's name. */
46
+ declare function AttachmentRemove({ className, children, id, "aria-label": label, ...props }: React.ComponentProps<typeof ButtonPrimitive>): React.JSX.Element;
47
+ export { Attachment, AttachmentMeta, AttachmentName, AttachmentPreview, AttachmentRemove, Attachments };
48
+ export type { AttachmentNameProps, AttachmentPreviewProps, AttachmentProps, AttachmentsProps, AttachmentState, AttachmentVariant, };
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Button as ButtonPrimitive } from "@ui-sdk/react/button";
4
+ import { renderElement } from "@ui-sdk/react/primitive";
5
+ import * as React from "react";
6
+ import { cx, join } from "../lib/cx.js";
7
+ import { ProgressCircle } from "./progress.js";
8
+ const AttachmentContext = React.createContext(null);
9
+ const ListContext = React.createContext(false);
10
+ function useAttachment() {
11
+ return React.useContext(AttachmentContext) ?? { state: "ready", progress: null, nameId: "" };
12
+ }
13
+ /** A list of attachments. Each Attachment inside becomes a list item. */
14
+ function Attachments({ layout = "wrap", className, ...props }) {
15
+ // Safari drops the list role from a list styled without markers unless it's restated.
16
+ return (_jsx(ListContext.Provider, { value: true, children: _jsx("ul", { role: "list", "data-layout": layout, className: join("mb-attachments", className), ...props }) }));
17
+ }
18
+ function Attachment({ variant = "chip", state = "ready", progress, className, render, ...props }) {
19
+ const inList = React.useContext(ListContext);
20
+ const nameId = React.useId();
21
+ const context = React.useMemo(() => ({ state, progress: progress ?? null, nameId }), [state, progress, nameId]);
22
+ const element = renderElement("div", {
23
+ ...props,
24
+ "aria-busy": state === "uploading" ? true : undefined,
25
+ "data-variant": variant,
26
+ "data-state": state,
27
+ "data-interactive": render ? "" : undefined,
28
+ className: join("mb-attachment", className),
29
+ }, render);
30
+ return (_jsx(AttachmentContext.Provider, { value: context, children: inList ? _jsx("li", { className: "mb-attachments-item", children: element }) : element }));
31
+ }
32
+ function DocumentGlyph() {
33
+ return (_jsxs("svg", { viewBox: "0 0 32 40", "aria-hidden": "true", focusable: "false", className: "mb-attachment-glyph", children: [_jsx("path", { className: "mb-attachment-glyph-page", d: "M6 1.75h14.2a2 2 0 0 1 1.42.59l6.04 6.04a2 2 0 0 1 .59 1.42V36.25a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V3.75a2 2 0 0 1 2-2Z" }), _jsx("path", { className: "mb-attachment-glyph-fold", d: "M21 1.9v5.6a1.75 1.75 0 0 0 1.75 1.75h5.6" }), _jsx("path", { className: "mb-attachment-glyph-lines", d: "M9 15.5h14M9 20h14M9 24.5h14M9 29h9" })] }));
34
+ }
35
+ function ErrorGlyph() {
36
+ return (_jsxs("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", className: "mb-attachment-error", children: [_jsx("circle", { cx: "8", cy: "8", r: "7.25" }), _jsx("path", { d: "M8 4.5v4.25" }), _jsx("circle", { cx: "8", cy: "11.4", r: "0.6" })] }));
37
+ }
38
+ /** The image or file glyph. While uploading it shows the progress ring; after a failure, an alert badge. */
39
+ function AttachmentPreview({ src, alt = "", extension, color, className, style, children, ...props }) {
40
+ const { state, progress } = useAttachment();
41
+ const tint = color ? (color === "gray" ? "var(--mb-label-secondary)" : `var(--mb-${color})`) : undefined;
42
+ return (_jsxs("span", { "data-image": src ? "" : undefined, className: join("mb-attachment-preview", className), style: tint ? { "--mb-attachment-tint": tint, ...style } : style, ...props, children: [children ??
43
+ (src ? (_jsx("img", { src: src, alt: alt, className: "mb-attachment-image" })) : (_jsxs("span", { className: "mb-attachment-document", children: [_jsx(DocumentGlyph, {}), extension ? _jsx("span", { "aria-hidden": "true", className: "mb-attachment-extension", children: extension }) : null] }))), state === "uploading" ? (_jsx("span", { className: "mb-attachment-progress", children: _jsx(ProgressCircle, { size: "sm", value: progress, "aria-label": "Uploading", className: "mb-attachment-progress-ring" }) })) : null, state === "error" ? _jsx(ErrorGlyph, {}) : null] }));
44
+ }
45
+ function AttachmentName({ className, render, id, ...props }) {
46
+ const { nameId } = useAttachment();
47
+ return renderElement("span", {
48
+ ...props,
49
+ id: id ?? (nameId || undefined),
50
+ "data-interactive": render ? "" : undefined,
51
+ className: join("mb-attachment-name", className),
52
+ }, render);
53
+ }
54
+ /** The kind and size, like `PDF · 2.4 MB`, or what went wrong. */
55
+ function AttachmentMeta({ className, ...props }) {
56
+ return _jsx("span", { className: join("mb-attachment-meta", className), ...props });
57
+ }
58
+ /** Removes the attachment. It's named "Remove" plus the attachment's name. */
59
+ function AttachmentRemove({ className, children, id, "aria-label": label = "Remove", ...props }) {
60
+ const { nameId } = useAttachment();
61
+ const ownId = React.useId();
62
+ const buttonId = id ?? ownId;
63
+ return (_jsx(ButtonPrimitive, { id: buttonId, "aria-label": label, "aria-labelledby": nameId ? `${buttonId} ${nameId}` : undefined, className: cx("mb-attachment-remove", className), ...props, children: children ?? (_jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "m4.75 4.75 6.5 6.5m0-6.5-6.5 6.5" }) })) }));
64
+ }
65
+ export { Attachment, AttachmentMeta, AttachmentName, AttachmentPreview, AttachmentRemove, Attachments };
@@ -0,0 +1,29 @@
1
+ import { ScrollArea, ScrollAreaContent, ScrollAreaScrollToEnd, ScrollAreaViewport } from "@ui-sdk/react/scroll-area";
2
+ import * as React from "react";
3
+ type ChatProps = React.ComponentProps<typeof ScrollArea> & {
4
+ /**
5
+ * Set while a reply streams. The log is marked busy, so screen readers wait
6
+ * and read the finished reply instead of each word as it arrives.
7
+ */
8
+ busy?: boolean;
9
+ };
10
+ /** The thread. It follows the reply while you're at the end and lets go when you scroll up. */
11
+ declare function Chat({ stickToEnd, type, busy, className, children, ...props }: ChatProps): React.JSX.Element;
12
+ /** The scrolling log of turns. Name it with `aria-label`. */
13
+ declare function ChatViewport({ "aria-label": ariaLabel, className, ...props }: React.ComponentProps<typeof ScrollAreaViewport>): React.JSX.Element;
14
+ /** The centered column the turns sit in, with even gaps between them. */
15
+ declare function ChatContent({ className, ...props }: React.ComponentProps<typeof ScrollAreaContent>): React.JSX.Element;
16
+ /** A floating glass button that jumps back to the latest turn. It shows only once you've scrolled away. */
17
+ declare function ChatScrollButton({ "aria-label": ariaLabel, className, children, ...props }: React.ComponentProps<typeof ScrollAreaScrollToEnd>): React.JSX.Element;
18
+ type ChatGreetingProps = Omit<React.ComponentProps<"div">, "title"> & {
19
+ /** A mark above the title, like your app's icon. Decorative. */
20
+ icon?: React.ReactNode;
21
+ title: React.ReactNode;
22
+ description?: React.ReactNode;
23
+ /** The title's heading level. A new-chat screen's greeting is usually its page heading. */
24
+ level?: 1 | 2 | 3;
25
+ };
26
+ /** The empty state of a new chat: a large greeting, with the composer and suggestions as children. */
27
+ declare function ChatGreeting({ icon, title, description, level, className, children, ...props }: ChatGreetingProps): React.JSX.Element;
28
+ export { Chat, ChatContent, ChatGreeting, ChatScrollButton, ChatViewport };
29
+ export type { ChatGreetingProps, ChatProps };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ScrollArea, ScrollAreaContent, ScrollAreaScrollbar, ScrollAreaScrollToEnd, ScrollAreaThumb, ScrollAreaViewport, } from "@ui-sdk/react/scroll-area";
4
+ import * as React from "react";
5
+ import { cx, join } from "../lib/cx.js";
6
+ const ChatBusyContext = React.createContext(false);
7
+ /** The thread. It follows the reply while you're at the end and lets go when you scroll up. */
8
+ function Chat({ stickToEnd = true, type = "hover", busy, className, children, ...props }) {
9
+ return (_jsx(ScrollArea, { stickToEnd: stickToEnd, type: type, "data-busy": busy ? "" : undefined, className: cx("mb-chat", className), ...props, children: (state) => (_jsxs(ChatBusyContext.Provider, { value: Boolean(busy), children: [typeof children === "function" ? children(state) : children, _jsx(ScrollAreaScrollbar, { orientation: "vertical", className: "mb-scroll-view-scrollbar mb-chat-scrollbar", children: _jsx(ScrollAreaThumb, { className: "mb-scroll-view-thumb" }) })] })) }));
10
+ }
11
+ /** The scrolling log of turns. Name it with `aria-label`. */
12
+ function ChatViewport({ "aria-label": ariaLabel = "Conversation", className, ...props }) {
13
+ const busy = React.useContext(ChatBusyContext);
14
+ return (_jsx(ScrollAreaViewport, { role: "log", "aria-live": "polite", "aria-label": ariaLabel, "aria-busy": busy || undefined, className: cx("mb-chat-viewport", className), ...props }));
15
+ }
16
+ /** The centered column the turns sit in, with even gaps between them. */
17
+ function ChatContent({ className, ...props }) {
18
+ return _jsx(ScrollAreaContent, { className: cx("mb-chat-content", className), ...props });
19
+ }
20
+ /** A floating glass button that jumps back to the latest turn. It shows only once you've scrolled away. */
21
+ function ChatScrollButton({ "aria-label": ariaLabel = "Scroll to latest", className, children, ...props }) {
22
+ return (_jsx(ScrollAreaScrollToEnd, { type: "button", "aria-label": ariaLabel, className: cx("mb-glass mb-chat-scroll-button", className), "data-shape": "circle", ...props, children: children ?? (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M8 2.75v10.5M3.5 8.75 8 13.25l4.5-4.5", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round" }) })) }));
23
+ }
24
+ /** The empty state of a new chat: a large greeting, with the composer and suggestions as children. */
25
+ function ChatGreeting({ icon, title, description, level = 1, className, children, ...props }) {
26
+ const Heading = `h${level}`;
27
+ return (_jsxs("div", { className: join("mb-chat-greeting", className), ...props, children: [icon ? (_jsx("div", { "aria-hidden": "true", className: "mb-chat-greeting-icon", children: icon })) : null, _jsx(Heading, { className: "mb-chat-greeting-title", children: title }), description ? _jsx("p", { className: "mb-chat-greeting-description", children: description }) : null, children ? _jsx("div", { className: "mb-chat-greeting-body", children: children }) : null] }));
28
+ }
29
+ export { Chat, ChatContent, ChatGreeting, ChatScrollButton, ChatViewport };
@@ -0,0 +1,39 @@
1
+ import * as React from "react";
2
+ import { type ButtonProps } from "./button.js";
3
+ type CodeBlockProps = React.ComponentProps<"div"> & {
4
+ /** Wraps long lines instead of scrolling sideways. */
5
+ wrap?: boolean;
6
+ /** Numbers each line in the gutter. Highlighted markup needs one element per line with the class `line`. */
7
+ lineNumbers?: boolean;
8
+ /** Scrolls the code past this height, in pixels or any CSS length. */
9
+ maxHeight?: number | string;
10
+ };
11
+ declare function CodeBlock({ wrap, lineNumbers, maxHeight, className, style, ...props }: CodeBlockProps): React.JSX.Element;
12
+ /** The title bar: a CodeBlockTitle, then a CodeBlockCopy at the trailing edge. */
13
+ declare function CodeBlockHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
14
+ type CodeBlockTitleProps = React.ComponentProps<"div"> & {
15
+ /** A language label after the file name, like `TypeScript`. */
16
+ language?: React.ReactNode;
17
+ };
18
+ declare function CodeBlockTitle({ language, className, children, ...props }: CodeBlockTitleProps): React.JSX.Element;
19
+ type CodeBlockContentProps = Omit<React.ComponentProps<"pre">, "children" | "dangerouslySetInnerHTML"> & {
20
+ /** Plain text. Each line is wrapped in its own element, so line numbers work. */
21
+ children?: React.ReactNode;
22
+ /**
23
+ * Markup from your highlighter, used in place of children. A whole `<pre><code>` block, as most
24
+ * highlighters return, has its wrapper dropped and its lines kept. Only pass markup you trust.
25
+ */
26
+ html?: string;
27
+ };
28
+ /** The code: a `<pre><code>` that scrolls sideways (or wraps) and takes focus so the keyboard can scroll it. */
29
+ declare function CodeBlockContent({ html, className, children, tabIndex, ...props }: CodeBlockContentProps): React.JSX.Element;
30
+ type CodeBlockCopyProps = Omit<ButtonProps, "value"> & {
31
+ /** The text to copy. Leave it out to copy what CodeBlockContent shows. */
32
+ value?: string;
33
+ /** How long the check mark stays, in milliseconds. */
34
+ resetAfter?: number;
35
+ };
36
+ /** Copies the code and shows a check mark for two seconds. If the clipboard is unavailable it does nothing. */
37
+ declare function CodeBlockCopy({ value, resetAfter, onClick, className, children, "aria-label": label, ...props }: CodeBlockCopyProps): React.JSX.Element;
38
+ export { CodeBlock, CodeBlockContent, CodeBlockCopy, CodeBlockHeader, CodeBlockTitle };
39
+ export type { CodeBlockContentProps, CodeBlockCopyProps, CodeBlockProps, CodeBlockTitleProps };
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cx, join } from "../lib/cx.js";
5
+ import { Button } from "./button.js";
6
+ const CodeBlockContext = React.createContext(null);
7
+ function CodeBlock({ wrap, lineNumbers, maxHeight, className, style, ...props }) {
8
+ const code = React.useRef(null);
9
+ const height = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
10
+ return (_jsx(CodeBlockContext.Provider, { value: code, children: _jsx("div", { "data-wrap": wrap ? "" : undefined, "data-line-numbers": lineNumbers ? "" : undefined, className: join("mb-code-block", className), style: height ? { "--mb-code-block-max-height": height, ...style } : style, ...props }) }));
11
+ }
12
+ /** The title bar: a CodeBlockTitle, then a CodeBlockCopy at the trailing edge. */
13
+ function CodeBlockHeader({ className, ...props }) {
14
+ return _jsx("div", { className: join("mb-code-block-header", className), ...props });
15
+ }
16
+ function CodeBlockTitle({ language, className, children, ...props }) {
17
+ return (_jsxs("div", { className: join("mb-code-block-title", className), ...props, children: [children != null ? _jsx("span", { className: "mb-code-block-title-text", children: children }) : null, language != null ? _jsx("span", { className: "mb-code-block-language", children: language }) : null] }));
18
+ }
19
+ function unwrap(html) {
20
+ return html
21
+ .trim()
22
+ .replace(/^<pre\b[^>]*>\s*(?:<code\b[^>]*>)?/i, "")
23
+ .replace(/(?:<\/code>)?\s*<\/pre>$/i, "");
24
+ }
25
+ function lines(text) {
26
+ const all = text.replace(/\n$/, "").split("\n");
27
+ return all.map((line, index) => (
28
+ // A line has no identity beyond its position.
29
+ _jsxs(React.Fragment, { children: [_jsx("span", { className: "mb-code-block-line", children: line }), index < all.length - 1 ? "\n" : null] }, index)));
30
+ }
31
+ /** The code: a `<pre><code>` that scrolls sideways (or wraps) and takes focus so the keyboard can scroll it. */
32
+ function CodeBlockContent({ html, className, children, tabIndex = 0, ...props }) {
33
+ const code = React.useContext(CodeBlockContext);
34
+ return (_jsx("pre", { tabIndex: tabIndex, className: join("mb-code-block-content", className), ...props, children: html !== undefined ? (_jsx("code", { ref: code, className: "mb-code-block-code", dangerouslySetInnerHTML: { __html: unwrap(html) } })) : (_jsx("code", { ref: code, className: "mb-code-block-code", children: typeof children === "string" ? lines(children) : children })) }));
35
+ }
36
+ function CopyGlyph() {
37
+ return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", focusable: "false", children: [_jsx("rect", { x: "5.25", y: "5.25", width: "8.5", height: "8.5", rx: "2", stroke: "currentColor", strokeWidth: "1.3" }), _jsx("path", { d: "M10.75 3.25A1.75 1.75 0 0 0 9 2.25H4.25a2 2 0 0 0-2 2V9a1.75 1.75 0 0 0 1 1.58", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })] }));
38
+ }
39
+ function CheckGlyph() {
40
+ return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "m3.25 8.5 3 3 6.5-7", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) }));
41
+ }
42
+ /** Copies the code and shows a check mark for two seconds. If the clipboard is unavailable it does nothing. */
43
+ function CodeBlockCopy({ value, resetAfter = 2000, onClick, className, children, "aria-label": label = "Copy code", ...props }) {
44
+ const code = React.useContext(CodeBlockContext);
45
+ const [copied, setCopied] = React.useState(false);
46
+ const timer = React.useRef(undefined);
47
+ React.useEffect(() => () => clearTimeout(timer.current), []);
48
+ const copy = async () => {
49
+ const text = value ?? code?.current?.textContent ?? "";
50
+ try {
51
+ await navigator.clipboard.writeText(text);
52
+ }
53
+ catch {
54
+ return;
55
+ }
56
+ setCopied(true);
57
+ clearTimeout(timer.current);
58
+ timer.current = setTimeout(() => setCopied(false), resetAfter);
59
+ };
60
+ return (_jsx(Button, { variant: "plain", tone: "neutral", size: "sm", shape: "circle", "aria-label": copied ? "Copied" : label, "data-copied": copied ? "" : undefined, className: cx("mb-code-block-copy", className), onClick: (event, details) => {
61
+ onClick?.(event, details);
62
+ void copy();
63
+ }, ...props, children: children ?? (copied ? _jsx(CheckGlyph, {}) : _jsx(CopyGlyph, {})) }));
64
+ }
65
+ export { CodeBlock, CodeBlockContent, CodeBlockCopy, CodeBlockHeader, CodeBlockTitle };
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ type ConfirmationState = "pending" | "allowed" | "denied";
3
+ type ConfirmationProps = React.ComponentProps<"div"> & {
4
+ /** `pending` asks; `allowed` and `denied` collapse it to one quiet line. */
5
+ state?: ConfirmationState;
6
+ /** The line shown once answered. Defaults to "Allowed" or "Denied"; say "Allowed once" or "Always allowed" when it matters. */
7
+ outcome?: React.ReactNode;
8
+ };
9
+ /**
10
+ * An inline card that asks before a tool runs. It sits in the thread, not over it: nothing
11
+ * else on the page is blocked while it waits. It's a group named by its ConfirmationTitle.
12
+ */
13
+ declare function Confirmation({ state, outcome, className, children, ...props }: ConfirmationProps): React.JSX.Element;
14
+ /** The tool's icon, in a tile at the start of the card. */
15
+ declare function ConfirmationIcon({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
16
+ /** The question, like "Allow Calendar to create an event?". It names the card. */
17
+ declare function ConfirmationTitle({ className, id, ...props }: React.ComponentProps<"p">): React.JSX.Element;
18
+ declare function ConfirmationDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
19
+ /** The request's details, such as a DescriptionList of what the tool will send. */
20
+ declare function ConfirmationDetails({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
21
+ /** The buttons: in a trailing row on macOS, stacked full width on iOS with the last one on top. */
22
+ declare function ConfirmationActions({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
23
+ export { Confirmation, ConfirmationActions, ConfirmationDescription, ConfirmationDetails, ConfirmationIcon, ConfirmationTitle, };
24
+ export type { ConfirmationProps, ConfirmationState };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { CheckGlyph, CrossGlyph } from "../lib/agent-glyphs.js";
5
+ import { join } from "../lib/cx.js";
6
+ const TitleIdContext = React.createContext(undefined);
7
+ /**
8
+ * An inline card that asks before a tool runs. It sits in the thread, not over it: nothing
9
+ * else on the page is blocked while it waits. It's a group named by its ConfirmationTitle.
10
+ */
11
+ function Confirmation({ state = "pending", outcome, className, children, ...props }) {
12
+ const titleId = React.useId();
13
+ const outcomeId = React.useId();
14
+ const root = React.useRef(null);
15
+ const previous = React.useRef(state);
16
+ // Answering removes the buttons; keep focus in the card rather than losing it to the page.
17
+ React.useEffect(() => {
18
+ const was = previous.current;
19
+ previous.current = state;
20
+ if (was !== "pending" || state === "pending")
21
+ return;
22
+ const element = root.current;
23
+ if (element && (element.contains(document.activeElement) || document.activeElement === document.body)) {
24
+ element.focus({ preventScroll: true });
25
+ }
26
+ }, [state]);
27
+ const resolved = state !== "pending";
28
+ return (_jsx("div", { ref: root, role: "group", "aria-labelledby": resolved ? outcomeId : titleId, tabIndex: resolved ? -1 : undefined, "data-state": state, className: join("mb-confirmation", className), ...props, children: resolved ? (_jsxs("p", { id: outcomeId, className: "mb-confirmation-outcome", children: [state === "allowed" ? (_jsx(CheckGlyph, { className: "mb-confirmation-outcome-glyph" })) : (_jsx(CrossGlyph, { className: "mb-confirmation-outcome-glyph" })), _jsx("span", { children: outcome ?? (state === "allowed" ? "Allowed" : "Denied") })] })) : (_jsx(TitleIdContext.Provider, { value: titleId, children: children })) }));
29
+ }
30
+ /** The tool's icon, in a tile at the start of the card. */
31
+ function ConfirmationIcon({ className, ...props }) {
32
+ return _jsx("span", { "aria-hidden": "true", className: join("mb-confirmation-icon", className), ...props });
33
+ }
34
+ /** The question, like "Allow Calendar to create an event?". It names the card. */
35
+ function ConfirmationTitle({ className, id, ...props }) {
36
+ const titleId = React.useContext(TitleIdContext);
37
+ return _jsx("p", { id: id ?? titleId, className: join("mb-confirmation-title", className), ...props });
38
+ }
39
+ function ConfirmationDescription({ className, ...props }) {
40
+ return _jsx("p", { className: join("mb-confirmation-description", className), ...props });
41
+ }
42
+ /** The request's details, such as a DescriptionList of what the tool will send. */
43
+ function ConfirmationDetails({ className, ...props }) {
44
+ return _jsx("div", { className: join("mb-confirmation-details", className), ...props });
45
+ }
46
+ /** The buttons: in a trailing row on macOS, stacked full width on iOS with the last one on top. */
47
+ function ConfirmationActions({ className, ...props }) {
48
+ return _jsx("div", { className: join("mb-confirmation-actions", className), ...props });
49
+ }
50
+ export { Confirmation, ConfirmationActions, ConfirmationDescription, ConfirmationDetails, ConfirmationIcon, ConfirmationTitle, };
@@ -0,0 +1,19 @@
1
+ import { type RenderProp } from "@ui-sdk/react/primitive";
2
+ import type * as React from "react";
3
+ type ContentUnavailableProps = React.ComponentProps<"div"> & {
4
+ /** `sm` fits a sidebar or popover, `md` a pane, `lg` an empty window. */
5
+ size?: "sm" | "md" | "lg";
6
+ };
7
+ /** The empty state: an icon, a title, a description and actions, centered in the space it fills. */
8
+ declare function ContentUnavailable({ size, className, ...props }: ContentUnavailableProps): React.JSX.Element;
9
+ /** A large glyph above the title. Decorative: the title says what happened. */
10
+ declare function ContentUnavailableIcon({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
11
+ type ContentUnavailableTitleProps = React.ComponentProps<"h2"> & {
12
+ /** Renders a different heading level, such as `<h3 />`, to fit the page's outline. */
13
+ render?: RenderProp;
14
+ };
15
+ declare function ContentUnavailableTitle({ className, render, ...props }: ContentUnavailableTitleProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
16
+ declare function ContentUnavailableDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
17
+ declare function ContentUnavailableActions({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
18
+ export { ContentUnavailable, ContentUnavailableActions, ContentUnavailableDescription, ContentUnavailableIcon, ContentUnavailableTitle, };
19
+ export type { ContentUnavailableProps, ContentUnavailableTitleProps };
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { renderElement } from "@ui-sdk/react/primitive";
3
+ import { join } from "../lib/cx.js";
4
+ /** The empty state: an icon, a title, a description and actions, centered in the space it fills. */
5
+ function ContentUnavailable({ size = "md", className, ...props }) {
6
+ return _jsx("div", { "data-size": size, className: join("mb-content-unavailable", className), ...props });
7
+ }
8
+ /** A large glyph above the title. Decorative: the title says what happened. */
9
+ function ContentUnavailableIcon({ className, ...props }) {
10
+ return _jsx("span", { "aria-hidden": "true", className: join("mb-content-unavailable-icon", className), ...props });
11
+ }
12
+ function ContentUnavailableTitle({ className, render, ...props }) {
13
+ return renderElement("h2", { ...props, className: join("mb-content-unavailable-title", className) }, render);
14
+ }
15
+ function ContentUnavailableDescription({ className, ...props }) {
16
+ return _jsx("p", { className: join("mb-content-unavailable-description", className), ...props });
17
+ }
18
+ function ContentUnavailableActions({ className, ...props }) {
19
+ return _jsx("div", { className: join("mb-content-unavailable-actions", className), ...props });
20
+ }
21
+ export { ContentUnavailable, ContentUnavailableActions, ContentUnavailableDescription, ContentUnavailableIcon, ContentUnavailableTitle, };
@@ -0,0 +1,18 @@
1
+ import type * as React from "react";
2
+ type DescriptionListProps = React.ComponentProps<"dl"> & {
3
+ /** `rows` puts each label in a column beside its value; `stacked` puts the label above the value. */
4
+ layout?: "rows" | "stacked";
5
+ size?: "sm" | "md";
6
+ };
7
+ /** Label and value pairs, on a real `<dl>`. Wrap each pair in a DescriptionItem. */
8
+ declare function DescriptionList({ layout, size, className, ...props }: DescriptionListProps): React.JSX.Element;
9
+ /** One label and its value (or values). A `div`, which is the one wrapper a `<dl>` allows. */
10
+ declare function DescriptionItem({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
11
+ declare function DescriptionTerm({ className, ...props }: React.ComponentProps<"dt">): React.JSX.Element;
12
+ type DescriptionDetailsProps = React.ComponentProps<"dd"> & {
13
+ /** Sets the value in the monospaced font, for ids, hashes and paths. */
14
+ mono?: boolean;
15
+ };
16
+ declare function DescriptionDetails({ mono, className, ...props }: DescriptionDetailsProps): React.JSX.Element;
17
+ export { DescriptionDetails, DescriptionItem, DescriptionList, DescriptionTerm };
18
+ export type { DescriptionDetailsProps, DescriptionListProps };
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { join } from "../lib/cx.js";
3
+ /** Label and value pairs, on a real `<dl>`. Wrap each pair in a DescriptionItem. */
4
+ function DescriptionList({ layout = "rows", size = "md", className, ...props }) {
5
+ return _jsx("dl", { "data-layout": layout, "data-size": size, className: join("mb-description-list", className), ...props });
6
+ }
7
+ /** One label and its value (or values). A `div`, which is the one wrapper a `<dl>` allows. */
8
+ function DescriptionItem({ className, ...props }) {
9
+ return _jsx("div", { className: join("mb-description-item", className), ...props });
10
+ }
11
+ function DescriptionTerm({ className, ...props }) {
12
+ return _jsx("dt", { className: join("mb-description-term", className), ...props });
13
+ }
14
+ function DescriptionDetails({ mono, className, ...props }) {
15
+ return (_jsx("dd", { "data-mono": mono ? "" : undefined, className: join("mb-description-details", className), ...props }));
16
+ }
17
+ export { DescriptionDetails, DescriptionItem, DescriptionList, DescriptionTerm };
@@ -0,0 +1,39 @@
1
+ import { Radio, RadioGroup } from "@ui-sdk/react/radio";
2
+ import * as React from "react";
3
+ type GeneratedImageState = "generating" | "ready";
4
+ type GeneratedImageProps = Omit<React.ComponentProps<"div">, "defaultValue"> & {
5
+ /** `generating` shows a soft drifting placeholder and "Creating image…" on the stage. */
6
+ state?: GeneratedImageState;
7
+ /** The chosen image's value, to control it. */
8
+ value?: string | null;
9
+ /** The image chosen at first, when uncontrolled. */
10
+ defaultValue?: string | null;
11
+ onValueChange?: (value: string | null) => void;
12
+ /** Width over height of the stage, like `1`, `4 / 3` or `"16 / 9"`. */
13
+ aspectRatio?: number | string;
14
+ /** What the stage says while generating. */
15
+ generatingLabel?: React.ReactNode;
16
+ };
17
+ /**
18
+ * One or more generated images: a large stage, glass actions over its bottom corners, and an
19
+ * optional strip of thumbnails beside it on macOS and below it on iOS.
20
+ */
21
+ declare function GeneratedImage({ state, value, defaultValue, onValueChange, aspectRatio, generatingLabel, className, style, ...props }: GeneratedImageProps): React.JSX.Element;
22
+ type GeneratedImageStageProps = Omit<React.ComponentProps<"div">, "children"> & {
23
+ /** The image: an `<img>`, an Artwork, or a function of the chosen thumbnail's value. */
24
+ children?: React.ReactNode | ((value: string | null) => React.ReactNode);
25
+ };
26
+ /** The large image on a dark rounded stage. While generating it shows the placeholder instead. */
27
+ declare function GeneratedImageStage({ className, children, ...props }: GeneratedImageStageProps): React.JSX.Element;
28
+ /** Buttons over the stage's bottom corners: the first at the leading edge, the rest at the trailing edge. */
29
+ declare function GeneratedImageActions({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
30
+ /** The strip of thumbnails. Choose one with a click or the arrow keys to show it on the stage. */
31
+ declare function GeneratedImageThumbnails({ className, "aria-label": label, ...props }: Omit<React.ComponentProps<typeof RadioGroup>, "value" | "defaultValue" | "onValueChange">): React.JSX.Element;
32
+ type GeneratedImageThumbnailProps = React.ComponentProps<typeof Radio> & {
33
+ /** Names the image for assistive tech, like "Image 2" or what it shows. */
34
+ "aria-label": string;
35
+ };
36
+ /** One thumbnail: a square that takes an accent ring when it's on the stage. */
37
+ declare function GeneratedImageThumbnail({ className, ...props }: GeneratedImageThumbnailProps): React.JSX.Element;
38
+ export { GeneratedImage, GeneratedImageActions, GeneratedImageStage, GeneratedImageThumbnail, GeneratedImageThumbnails, };
39
+ export type { GeneratedImageProps, GeneratedImageStageProps, GeneratedImageState, GeneratedImageThumbnailProps };