@openwarelabs/ui 0.3.1 → 0.5.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 (71) hide show
  1. package/README.md +8 -7
  2. package/dist/components/Calendar/Calendar.d.cts +58 -0
  3. package/dist/components/Calendar/Calendar.d.ts +58 -0
  4. package/dist/components/Calendar/DateRangePicker.d.cts +39 -0
  5. package/dist/components/Calendar/DateRangePicker.d.ts +39 -0
  6. package/dist/components/Calendar/RangeCalendar.d.cts +38 -0
  7. package/dist/components/Calendar/RangeCalendar.d.ts +38 -0
  8. package/dist/components/Calendar/dates.d.cts +13 -0
  9. package/dist/components/Calendar/dates.d.ts +13 -0
  10. package/dist/components/ChainOfThought/ChainOfThought.d.cts +44 -0
  11. package/dist/components/ChainOfThought/ChainOfThought.d.ts +44 -0
  12. package/dist/components/Chat/ChatConversation.d.cts +48 -0
  13. package/dist/components/Chat/ChatConversation.d.ts +48 -0
  14. package/dist/components/Chat/ChatLoader.d.cts +21 -0
  15. package/dist/components/Chat/ChatLoader.d.ts +21 -0
  16. package/dist/components/Chat/ChatMessage.d.cts +93 -0
  17. package/dist/components/Chat/ChatMessage.d.ts +93 -0
  18. package/dist/components/ChatSource/ChatSource.d.cts +58 -0
  19. package/dist/components/ChatSource/ChatSource.d.ts +58 -0
  20. package/dist/components/ChatTool/ChatTool.d.cts +89 -0
  21. package/dist/components/ChatTool/ChatTool.d.ts +89 -0
  22. package/dist/components/ColorPicker/ColorArea.d.cts +44 -0
  23. package/dist/components/ColorPicker/ColorArea.d.ts +44 -0
  24. package/dist/components/ColorPicker/ColorSlider.d.cts +53 -0
  25. package/dist/components/ColorPicker/ColorSlider.d.ts +53 -0
  26. package/dist/components/ColorPicker/ColorSwatchPicker.d.cts +43 -0
  27. package/dist/components/ColorPicker/ColorSwatchPicker.d.ts +43 -0
  28. package/dist/components/ColorPicker/color.d.cts +91 -0
  29. package/dist/components/ColorPicker/color.d.ts +91 -0
  30. package/dist/components/DateField/DateField.d.cts +47 -0
  31. package/dist/components/DateField/DateField.d.ts +47 -0
  32. package/dist/components/DateField/SegmentedField.d.cts +63 -0
  33. package/dist/components/DateField/SegmentedField.d.ts +63 -0
  34. package/dist/components/DateField/TimeField.d.cts +52 -0
  35. package/dist/components/DateField/TimeField.d.ts +52 -0
  36. package/dist/components/Field/Field.d.cts +17 -5
  37. package/dist/components/Field/Field.d.ts +17 -5
  38. package/dist/components/FileDropZone/FileDropZone.d.cts +1 -1
  39. package/dist/components/FileDropZone/FileDropZone.d.ts +1 -1
  40. package/dist/components/Form/Form.d.cts +63 -0
  41. package/dist/components/Form/Form.d.ts +63 -0
  42. package/dist/components/InputOTP/InputOTP.d.cts +7 -1
  43. package/dist/components/InputOTP/InputOTP.d.ts +7 -1
  44. package/dist/components/ListBox/ListBox.d.cts +65 -0
  45. package/dist/components/ListBox/ListBox.d.ts +65 -0
  46. package/dist/components/Meter/Meter.d.cts +62 -0
  47. package/dist/components/Meter/Meter.d.ts +62 -0
  48. package/dist/components/PromptInput/PromptInput.d.cts +95 -0
  49. package/dist/components/PromptInput/PromptInput.d.ts +95 -0
  50. package/dist/components/PromptInput/PromptSuggestion.d.cts +36 -0
  51. package/dist/components/PromptInput/PromptSuggestion.d.ts +36 -0
  52. package/dist/components/Prose/Prose.d.cts +22 -0
  53. package/dist/components/Prose/Prose.d.ts +22 -0
  54. package/dist/components/Slider/Slider.d.cts +7 -1
  55. package/dist/components/Slider/Slider.d.ts +7 -1
  56. package/dist/components/TextShimmer/TextShimmer.d.cts +20 -0
  57. package/dist/components/TextShimmer/TextShimmer.d.ts +20 -0
  58. package/dist/components/ToggleButtonGroup/ToggleButtonGroup.d.cts +74 -0
  59. package/dist/components/ToggleButtonGroup/ToggleButtonGroup.d.ts +74 -0
  60. package/dist/components/Toolbar/Toolbar.d.cts +36 -0
  61. package/dist/components/Toolbar/Toolbar.d.ts +36 -0
  62. package/dist/components.css +3557 -38
  63. package/dist/index.cjs +7391 -3179
  64. package/dist/index.cjs.map +4 -4
  65. package/dist/index.d.cts +45 -0
  66. package/dist/index.d.ts +45 -0
  67. package/dist/index.js +7478 -3214
  68. package/dist/index.js.map +4 -4
  69. package/dist/openware-ui.iife.js +7 -6
  70. package/dist/styles.css +3557 -38
  71. package/package.json +1 -1
@@ -0,0 +1,93 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ export interface ChatAgentAvatarProps {
3
+ /** sm 24px, md 28px beside a message, lg 36px in a page or panel header: the sizes of Avatar.
4
+ * @default "md" */
5
+ size?: "sm" | "md" | "lg";
6
+ /** Give it when the avatar stands alone; beside the agent's name, leave it out and it's hidden from screen readers. */
7
+ label?: string;
8
+ className?: string;
9
+ }
10
+ /**
11
+ * The agent's avatar: a bot icon on a tinted circle, in the sizes of Avatar. Messages and the loader show it by
12
+ * default; use it wherever else the agent appears, such as a chat's header.
13
+ */
14
+ export declare function ChatAgentAvatar({ size, label, className }: ChatAgentAvatarProps): import("react").JSX.Element;
15
+ /**
16
+ * Whether this message or loader should animate in: only when it arrives in a conversation that's already showing,
17
+ * not for the history it opens with.
18
+ * @internal
19
+ */
20
+ export declare function useChatEntrance(): boolean;
21
+ export type ChatMessageFrom = "user" | "assistant" | "system";
22
+ export type ChatMessageStatus = "streaming" | "done" | "error";
23
+ export interface ChatMessageProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
24
+ /** Who it's from. `user`: the person, in a bubble on the right. `assistant`: the agent, full width beside its
25
+ * avatar. `system`: a muted line in the middle, between hairlines, for things that happened ("Maya changed the
26
+ * model to Claude Sonnet"). */
27
+ from: ChatMessageFrom;
28
+ /** The message. A person's plain text keeps its line breaks; give an agent's formatted answer as Prose, and put
29
+ * paragraphs in Text so blocks sit 12px apart. */
30
+ children?: ReactNode;
31
+ /** Shown above the message: "Acme agent", "Maya Chen". Left out, screen readers hear "You" or "Agent" instead. */
32
+ name?: ReactNode;
33
+ /** The agent's bot tile by default; any node (an Avatar) in its place, or null for none. A person's message shows one
34
+ * only when you give it. */
35
+ avatar?: ReactNode;
36
+ /** When it was sent, as a Date or an ISO string. It shows as a short local time, with the full date on hover. */
37
+ time?: Date | string;
38
+ /** The locale for the time, such as "en-GB". Defaults to the browser's. */
39
+ locale?: string;
40
+ /** `streaming` while the text is still arriving: a soft caret blinks after it and the message is aria-busy.
41
+ * `error` shows a line saying what went wrong, with Retry when you pass `onRetry`.
42
+ * @default "done" */
43
+ status?: ChatMessageStatus;
44
+ /** What went wrong, for `status="error"`.
45
+ * @default "The answer didn't finish." for the agent, "Couldn't send this message." for a person */
46
+ error?: ReactNode;
47
+ /** Shows a Retry button on the error line. */
48
+ onRetry?(): void;
49
+ /** The Retry button's words, for another language.
50
+ * @default "Retry" */
51
+ retryLabel?: string;
52
+ /** Actions under the message, usually a ChatMessageActions. They wait until the message has finished streaming. */
53
+ actions?: ReactNode;
54
+ /** `hover` shows the actions while the message is hovered or has focus, and always on touch screens. `always` keeps
55
+ * them in view, for the latest answer.
56
+ * @default "hover" */
57
+ showActions?: "hover" | "always";
58
+ }
59
+ /**
60
+ * One message in a conversation: the person's in a bubble on the right, the agent's across the full width with its
61
+ * avatar, name and time, or a system line in the middle. It shows a caret while the answer streams, an error with
62
+ * Retry when it fails, and its actions on hover.
63
+ */
64
+ export declare const ChatMessage: import("react").ForwardRefExoticComponent<ChatMessageProps & import("react").RefAttributes<HTMLElement>>;
65
+ export type ChatRating = "up" | "down";
66
+ export interface ChatMessageActionsProps {
67
+ /** The message as plain text. Shows Copy, which copies it and says "Copied" for two seconds. */
68
+ copyText?: string;
69
+ /** Shows Edit, for the person's own messages. */
70
+ onEdit?(): void;
71
+ /** Shows Retry, to ask for the answer again. */
72
+ onRetry?(): void;
73
+ /** Shows Good response and Bad response. Called with the one pressed, or null when the pressed one is pressed again. */
74
+ onRate?(rating: ChatRating | null): void;
75
+ /** Which rating is pressed, when you keep it yourself. */
76
+ rating?: ChatRating | null;
77
+ /** The starting rating when uncontrolled.
78
+ * @default null */
79
+ defaultRating?: ChatRating | null;
80
+ /** More actions after these: ghost, sm, icon-only Buttons, each in a Tooltip with its aria-label. */
81
+ children?: ReactNode;
82
+ /** The buttons' words, for another language. */
83
+ labels?: Partial<Record<"copy" | "copied" | "edit" | "retry" | "good" | "bad", string>>;
84
+ /** Names the toolbar for screen readers.
85
+ * @default "Message actions" */
86
+ "aria-label"?: string;
87
+ className?: string;
88
+ }
89
+ /**
90
+ * The row of small actions under a message: Copy, Edit, Retry, and Good or Bad response. Only the ones you give a
91
+ * callback (or `copyText`) appear. It's a toolbar: one tab stop, with the arrow keys moving between the buttons.
92
+ */
93
+ export declare function ChatMessageActions({ copyText: text, onEdit, onRetry, onRate, rating, defaultRating, children, labels, "aria-label": ariaLabel, className, }: ChatMessageActionsProps): import("react").JSX.Element;
@@ -0,0 +1,93 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ export interface ChatAgentAvatarProps {
3
+ /** sm 24px, md 28px beside a message, lg 36px in a page or panel header: the sizes of Avatar.
4
+ * @default "md" */
5
+ size?: "sm" | "md" | "lg";
6
+ /** Give it when the avatar stands alone; beside the agent's name, leave it out and it's hidden from screen readers. */
7
+ label?: string;
8
+ className?: string;
9
+ }
10
+ /**
11
+ * The agent's avatar: a bot icon on a tinted circle, in the sizes of Avatar. Messages and the loader show it by
12
+ * default; use it wherever else the agent appears, such as a chat's header.
13
+ */
14
+ export declare function ChatAgentAvatar({ size, label, className }: ChatAgentAvatarProps): import("react").JSX.Element;
15
+ /**
16
+ * Whether this message or loader should animate in: only when it arrives in a conversation that's already showing,
17
+ * not for the history it opens with.
18
+ * @internal
19
+ */
20
+ export declare function useChatEntrance(): boolean;
21
+ export type ChatMessageFrom = "user" | "assistant" | "system";
22
+ export type ChatMessageStatus = "streaming" | "done" | "error";
23
+ export interface ChatMessageProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
24
+ /** Who it's from. `user`: the person, in a bubble on the right. `assistant`: the agent, full width beside its
25
+ * avatar. `system`: a muted line in the middle, between hairlines, for things that happened ("Maya changed the
26
+ * model to Claude Sonnet"). */
27
+ from: ChatMessageFrom;
28
+ /** The message. A person's plain text keeps its line breaks; give an agent's formatted answer as Prose, and put
29
+ * paragraphs in Text so blocks sit 12px apart. */
30
+ children?: ReactNode;
31
+ /** Shown above the message: "Acme agent", "Maya Chen". Left out, screen readers hear "You" or "Agent" instead. */
32
+ name?: ReactNode;
33
+ /** The agent's bot tile by default; any node (an Avatar) in its place, or null for none. A person's message shows one
34
+ * only when you give it. */
35
+ avatar?: ReactNode;
36
+ /** When it was sent, as a Date or an ISO string. It shows as a short local time, with the full date on hover. */
37
+ time?: Date | string;
38
+ /** The locale for the time, such as "en-GB". Defaults to the browser's. */
39
+ locale?: string;
40
+ /** `streaming` while the text is still arriving: a soft caret blinks after it and the message is aria-busy.
41
+ * `error` shows a line saying what went wrong, with Retry when you pass `onRetry`.
42
+ * @default "done" */
43
+ status?: ChatMessageStatus;
44
+ /** What went wrong, for `status="error"`.
45
+ * @default "The answer didn't finish." for the agent, "Couldn't send this message." for a person */
46
+ error?: ReactNode;
47
+ /** Shows a Retry button on the error line. */
48
+ onRetry?(): void;
49
+ /** The Retry button's words, for another language.
50
+ * @default "Retry" */
51
+ retryLabel?: string;
52
+ /** Actions under the message, usually a ChatMessageActions. They wait until the message has finished streaming. */
53
+ actions?: ReactNode;
54
+ /** `hover` shows the actions while the message is hovered or has focus, and always on touch screens. `always` keeps
55
+ * them in view, for the latest answer.
56
+ * @default "hover" */
57
+ showActions?: "hover" | "always";
58
+ }
59
+ /**
60
+ * One message in a conversation: the person's in a bubble on the right, the agent's across the full width with its
61
+ * avatar, name and time, or a system line in the middle. It shows a caret while the answer streams, an error with
62
+ * Retry when it fails, and its actions on hover.
63
+ */
64
+ export declare const ChatMessage: import("react").ForwardRefExoticComponent<ChatMessageProps & import("react").RefAttributes<HTMLElement>>;
65
+ export type ChatRating = "up" | "down";
66
+ export interface ChatMessageActionsProps {
67
+ /** The message as plain text. Shows Copy, which copies it and says "Copied" for two seconds. */
68
+ copyText?: string;
69
+ /** Shows Edit, for the person's own messages. */
70
+ onEdit?(): void;
71
+ /** Shows Retry, to ask for the answer again. */
72
+ onRetry?(): void;
73
+ /** Shows Good response and Bad response. Called with the one pressed, or null when the pressed one is pressed again. */
74
+ onRate?(rating: ChatRating | null): void;
75
+ /** Which rating is pressed, when you keep it yourself. */
76
+ rating?: ChatRating | null;
77
+ /** The starting rating when uncontrolled.
78
+ * @default null */
79
+ defaultRating?: ChatRating | null;
80
+ /** More actions after these: ghost, sm, icon-only Buttons, each in a Tooltip with its aria-label. */
81
+ children?: ReactNode;
82
+ /** The buttons' words, for another language. */
83
+ labels?: Partial<Record<"copy" | "copied" | "edit" | "retry" | "good" | "bad", string>>;
84
+ /** Names the toolbar for screen readers.
85
+ * @default "Message actions" */
86
+ "aria-label"?: string;
87
+ className?: string;
88
+ }
89
+ /**
90
+ * The row of small actions under a message: Copy, Edit, Retry, and Good or Bad response. Only the ones you give a
91
+ * callback (or `copyText`) appear. It's a toolbar: one tab stop, with the arrow keys moving between the buttons.
92
+ */
93
+ export declare function ChatMessageActions({ copyText: text, onEdit, onRetry, onRate, rating, defaultRating, children, labels, "aria-label": ariaLabel, className, }: ChatMessageActionsProps): import("react").JSX.Element;
@@ -0,0 +1,58 @@
1
+ import { type HTMLAttributes, type MouseEvent, type ReactNode } from "react";
2
+ /** One source an answer drew on: a file, a pull request, a web page. ChatSource and ChatSources both take it. */
3
+ export interface ChatSourceItem {
4
+ /** What it is: a function, a pull request's title, a page's title. */
5
+ title: ReactNode;
6
+ /** Where it is, in one line: "src/billing/invoice.ts · lines 40–72", "Pull request #482", "docs.stripe.com". */
7
+ source?: ReactNode;
8
+ /** A few lines from it, in the preview. ChatSources leaves it out. */
9
+ snippet?: ReactNode;
10
+ /** Where it opens. With it the citation is a link; without, a button. */
11
+ href?: string;
12
+ /** Opens `href` in a new tab, for sources outside your app.
13
+ * @default false */
14
+ external?: boolean;
15
+ /** A 15px icon for the kind of source, beside its title. */
16
+ icon?: ReactNode;
17
+ /** Its number, shown in the citation chip and on its card: [1], [2]. */
18
+ index?: number;
19
+ }
20
+ export interface ChatSourceProps extends ChatSourceItem {
21
+ /** A short name for the chip when there's no `index`: "invoice.ts", "#482". */
22
+ label?: string;
23
+ /** How a string `snippet` shows: `text` as a quote, `code` in the mono face with its line breaks kept.
24
+ * @default "text" */
25
+ snippetFormat?: "text" | "code";
26
+ /** The words of the preview's link to `href`.
27
+ * @default "Open" */
28
+ openLabel?: string;
29
+ /** Called when the chip is pressed, e.g. to show the source in a side panel. On touch, the first press opens the preview instead. */
30
+ onClick?(event: MouseEvent<HTMLElement>): void;
31
+ /** Names the chip for screen readers. Defaults to "Source 1", or the label. */
32
+ "aria-label"?: string;
33
+ /** Classes for the chip's wrapper, which also holds the preview. */
34
+ className?: string;
35
+ }
36
+ /**
37
+ * An inline citation in an answer: a small numbered chip that previews its source on hover, keyboard focus, or a tap,
38
+ * in a card above the page. The chip is a link to the source when it has an `href`; the preview describes it to screen
39
+ * readers without taking focus.
40
+ */
41
+ export declare const ChatSource: import("react").ForwardRefExoticComponent<ChatSourceProps & import("react").RefAttributes<HTMLElement>>;
42
+ export interface ChatSourcesProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
43
+ /** The sources, in the order the answer cites them. An `id` keeps each one's place as the list changes. */
44
+ sources: Array<ChatSourceItem & {
45
+ id?: string;
46
+ }>;
47
+ /** The toggle's words. Defaults to "3 sources". */
48
+ label?: ReactNode;
49
+ /** Whether the list shows. */
50
+ expanded?: boolean;
51
+ /** Whether the list starts open.
52
+ * @default false */
53
+ defaultExpanded?: boolean;
54
+ /** Called with the new state when the person opens or closes the list. */
55
+ onExpandedChange?(expanded: boolean): void;
56
+ }
57
+ /** The sources under an answer: a "3 sources" toggle that opens to a card for each, linking to it when it has an `href`. */
58
+ export declare const ChatSources: import("react").ForwardRefExoticComponent<ChatSourcesProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,58 @@
1
+ import { type HTMLAttributes, type MouseEvent, type ReactNode } from "react";
2
+ /** One source an answer drew on: a file, a pull request, a web page. ChatSource and ChatSources both take it. */
3
+ export interface ChatSourceItem {
4
+ /** What it is: a function, a pull request's title, a page's title. */
5
+ title: ReactNode;
6
+ /** Where it is, in one line: "src/billing/invoice.ts · lines 40–72", "Pull request #482", "docs.stripe.com". */
7
+ source?: ReactNode;
8
+ /** A few lines from it, in the preview. ChatSources leaves it out. */
9
+ snippet?: ReactNode;
10
+ /** Where it opens. With it the citation is a link; without, a button. */
11
+ href?: string;
12
+ /** Opens `href` in a new tab, for sources outside your app.
13
+ * @default false */
14
+ external?: boolean;
15
+ /** A 15px icon for the kind of source, beside its title. */
16
+ icon?: ReactNode;
17
+ /** Its number, shown in the citation chip and on its card: [1], [2]. */
18
+ index?: number;
19
+ }
20
+ export interface ChatSourceProps extends ChatSourceItem {
21
+ /** A short name for the chip when there's no `index`: "invoice.ts", "#482". */
22
+ label?: string;
23
+ /** How a string `snippet` shows: `text` as a quote, `code` in the mono face with its line breaks kept.
24
+ * @default "text" */
25
+ snippetFormat?: "text" | "code";
26
+ /** The words of the preview's link to `href`.
27
+ * @default "Open" */
28
+ openLabel?: string;
29
+ /** Called when the chip is pressed, e.g. to show the source in a side panel. On touch, the first press opens the preview instead. */
30
+ onClick?(event: MouseEvent<HTMLElement>): void;
31
+ /** Names the chip for screen readers. Defaults to "Source 1", or the label. */
32
+ "aria-label"?: string;
33
+ /** Classes for the chip's wrapper, which also holds the preview. */
34
+ className?: string;
35
+ }
36
+ /**
37
+ * An inline citation in an answer: a small numbered chip that previews its source on hover, keyboard focus, or a tap,
38
+ * in a card above the page. The chip is a link to the source when it has an `href`; the preview describes it to screen
39
+ * readers without taking focus.
40
+ */
41
+ export declare const ChatSource: import("react").ForwardRefExoticComponent<ChatSourceProps & import("react").RefAttributes<HTMLElement>>;
42
+ export interface ChatSourcesProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
43
+ /** The sources, in the order the answer cites them. An `id` keeps each one's place as the list changes. */
44
+ sources: Array<ChatSourceItem & {
45
+ id?: string;
46
+ }>;
47
+ /** The toggle's words. Defaults to "3 sources". */
48
+ label?: ReactNode;
49
+ /** Whether the list shows. */
50
+ expanded?: boolean;
51
+ /** Whether the list starts open.
52
+ * @default false */
53
+ defaultExpanded?: boolean;
54
+ /** Called with the new state when the person opens or closes the list. */
55
+ onExpandedChange?(expanded: boolean): void;
56
+ }
57
+ /** The sources under an answer: a "3 sources" toggle that opens to a card for each, linking to it when it has an `href`. */
58
+ export declare const ChatSources: import("react").ForwardRefExoticComponent<ChatSourcesProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,89 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ /**
3
+ * Where a tool call or a step has got to. `approval` waits for a person to approve it; `cancelled` didn't run or didn't
4
+ * finish because a person denied it or stopped the run.
5
+ */
6
+ export type ChatToolStatus = "pending" | "running" | "success" | "error" | "approval" | "cancelled";
7
+ /** The round mark before a tool call or a step: a spinner, a check, a cross, a "!", a slash or a hollow ring, with its status as words for screen readers. */
8
+ export declare function ChatStatusMarker({ status, icon }: {
9
+ status: ChatToolStatus;
10
+ icon?: ReactNode;
11
+ }): import("react").JSX.Element;
12
+ /** "380 ms", "4.2 s", "12 s", "1 min 12 s", "1 h 4 min": a duration as people say it, with the locale's digits. */
13
+ export declare function formatDuration(ms: number, locale?: string): string;
14
+ /** A duration in a <time> element, so it carries a machine-readable value too. */
15
+ export declare function ChatDuration({ ms, locale, className }: {
16
+ ms: number;
17
+ locale?: string;
18
+ className?: string;
19
+ }): import("react").JSX.Element;
20
+ /**
21
+ * Open state that follows a status: it opens when `wantsOpen` turns true (an error, a step under way) and closes again
22
+ * when it turns false, unless the person has opened or closed it themselves since. A controlled `expanded` is left alone.
23
+ */
24
+ export declare function useStatusExpansion({ expanded, defaultExpanded, onExpandedChange, wantsOpen, closeWhenSettled, initial, }: {
25
+ expanded: boolean | undefined;
26
+ defaultExpanded: boolean | undefined;
27
+ onExpandedChange: ((expanded: boolean) => void) | undefined;
28
+ wantsOpen: boolean;
29
+ closeWhenSettled?: boolean;
30
+ initial?: boolean;
31
+ }): [boolean, () => void];
32
+ /**
33
+ * A panel that opens and closes under a disclosure button, animating its height (a 0fr → 1fr grid row). Closed, it's
34
+ * inert: nothing in it can be tabbed to or read out. `bleed` lets focus rings at its edges show past the clip.
35
+ */
36
+ export declare function ChatCollapse({ id, open, bleed, className, children, }: {
37
+ id: string;
38
+ open: boolean;
39
+ bleed?: boolean;
40
+ className?: string;
41
+ children: ReactNode;
42
+ }): import("react").JSX.Element;
43
+ export interface ChatToolProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
44
+ /** What the agent is doing, in words: "Run the test suite". */
45
+ title: ReactNode;
46
+ /** The tool it calls, shown in code type beside the title: "run_tests". */
47
+ name?: string;
48
+ /** A 15px icon for the tool, before the title. */
49
+ icon?: ReactNode;
50
+ /** Where the call has got to. Running shows a spinner and a shimmering title; `approval` asks the person to approve it;
51
+ * `cancelled` is for a call they denied, or one the run stopped before it finished: say which in `summary`. */
52
+ status: ChatToolStatus;
53
+ /** The result in one line: "212 tests passed", "Read 3 files". */
54
+ summary?: ReactNode;
55
+ /** How long it took, or has taken so far, in milliseconds. Shown as "4.2 s". */
56
+ duration?: number;
57
+ /** What the tool was called with: a one-line string (a command) in a Snippet, a longer one in a code block, or an
58
+ * object as formatted JSON. Shown under "Input". */
59
+ input?: string | Record<string, unknown> | unknown[];
60
+ /** What the tool returned: a string in a code block, or any node (a list of files, a link). Shown under "Output". */
61
+ output?: ReactNode;
62
+ /** What went wrong, shown in the danger colour under "Error". */
63
+ error?: ReactNode;
64
+ /** Whether the input and output show. Leave out to let it follow the status: closed, opening for an error or an approval. */
65
+ expanded?: boolean;
66
+ /** Whether it starts open. Defaults to open for an error or an approval and closed otherwise. */
67
+ defaultExpanded?: boolean;
68
+ /** Called with the new state when it opens or closes, by the person or by a change of status. */
69
+ onExpandedChange?(expanded: boolean): void;
70
+ /** What it asks to do, while `status` is "approval". Defaults to "Wants to run" and the tool's name. */
71
+ approvalMessage?: ReactNode;
72
+ /** The approve button's label: name the action, e.g. "Approve and publish".
73
+ * @default "Approve" */
74
+ approveLabel?: string;
75
+ /** The deny button's label, e.g. "Don't publish".
76
+ * @default "Deny" */
77
+ denyLabel?: string;
78
+ /** Called when the person approves the call. Move `status` on from "approval" in response. */
79
+ onApprove?(): void;
80
+ /** Called when the person refuses the call. Move `status` on to "cancelled" in response. */
81
+ onDeny?(): void;
82
+ /** The locale for the duration's digits, e.g. "de-CH". Defaults to the browser's. */
83
+ locale?: string;
84
+ }
85
+ /**
86
+ * One tool call an agent makes: what it's doing, the tool, its status and result on one row, which opens to show the
87
+ * input and output. A failed call opens to its error, and a call that needs approval asks for it with Approve and Deny.
88
+ */
89
+ export declare const ChatTool: import("react").ForwardRefExoticComponent<ChatToolProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,89 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ /**
3
+ * Where a tool call or a step has got to. `approval` waits for a person to approve it; `cancelled` didn't run or didn't
4
+ * finish because a person denied it or stopped the run.
5
+ */
6
+ export type ChatToolStatus = "pending" | "running" | "success" | "error" | "approval" | "cancelled";
7
+ /** The round mark before a tool call or a step: a spinner, a check, a cross, a "!", a slash or a hollow ring, with its status as words for screen readers. */
8
+ export declare function ChatStatusMarker({ status, icon }: {
9
+ status: ChatToolStatus;
10
+ icon?: ReactNode;
11
+ }): import("react").JSX.Element;
12
+ /** "380 ms", "4.2 s", "12 s", "1 min 12 s", "1 h 4 min": a duration as people say it, with the locale's digits. */
13
+ export declare function formatDuration(ms: number, locale?: string): string;
14
+ /** A duration in a <time> element, so it carries a machine-readable value too. */
15
+ export declare function ChatDuration({ ms, locale, className }: {
16
+ ms: number;
17
+ locale?: string;
18
+ className?: string;
19
+ }): import("react").JSX.Element;
20
+ /**
21
+ * Open state that follows a status: it opens when `wantsOpen` turns true (an error, a step under way) and closes again
22
+ * when it turns false, unless the person has opened or closed it themselves since. A controlled `expanded` is left alone.
23
+ */
24
+ export declare function useStatusExpansion({ expanded, defaultExpanded, onExpandedChange, wantsOpen, closeWhenSettled, initial, }: {
25
+ expanded: boolean | undefined;
26
+ defaultExpanded: boolean | undefined;
27
+ onExpandedChange: ((expanded: boolean) => void) | undefined;
28
+ wantsOpen: boolean;
29
+ closeWhenSettled?: boolean;
30
+ initial?: boolean;
31
+ }): [boolean, () => void];
32
+ /**
33
+ * A panel that opens and closes under a disclosure button, animating its height (a 0fr → 1fr grid row). Closed, it's
34
+ * inert: nothing in it can be tabbed to or read out. `bleed` lets focus rings at its edges show past the clip.
35
+ */
36
+ export declare function ChatCollapse({ id, open, bleed, className, children, }: {
37
+ id: string;
38
+ open: boolean;
39
+ bleed?: boolean;
40
+ className?: string;
41
+ children: ReactNode;
42
+ }): import("react").JSX.Element;
43
+ export interface ChatToolProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
44
+ /** What the agent is doing, in words: "Run the test suite". */
45
+ title: ReactNode;
46
+ /** The tool it calls, shown in code type beside the title: "run_tests". */
47
+ name?: string;
48
+ /** A 15px icon for the tool, before the title. */
49
+ icon?: ReactNode;
50
+ /** Where the call has got to. Running shows a spinner and a shimmering title; `approval` asks the person to approve it;
51
+ * `cancelled` is for a call they denied, or one the run stopped before it finished: say which in `summary`. */
52
+ status: ChatToolStatus;
53
+ /** The result in one line: "212 tests passed", "Read 3 files". */
54
+ summary?: ReactNode;
55
+ /** How long it took, or has taken so far, in milliseconds. Shown as "4.2 s". */
56
+ duration?: number;
57
+ /** What the tool was called with: a one-line string (a command) in a Snippet, a longer one in a code block, or an
58
+ * object as formatted JSON. Shown under "Input". */
59
+ input?: string | Record<string, unknown> | unknown[];
60
+ /** What the tool returned: a string in a code block, or any node (a list of files, a link). Shown under "Output". */
61
+ output?: ReactNode;
62
+ /** What went wrong, shown in the danger colour under "Error". */
63
+ error?: ReactNode;
64
+ /** Whether the input and output show. Leave out to let it follow the status: closed, opening for an error or an approval. */
65
+ expanded?: boolean;
66
+ /** Whether it starts open. Defaults to open for an error or an approval and closed otherwise. */
67
+ defaultExpanded?: boolean;
68
+ /** Called with the new state when it opens or closes, by the person or by a change of status. */
69
+ onExpandedChange?(expanded: boolean): void;
70
+ /** What it asks to do, while `status` is "approval". Defaults to "Wants to run" and the tool's name. */
71
+ approvalMessage?: ReactNode;
72
+ /** The approve button's label: name the action, e.g. "Approve and publish".
73
+ * @default "Approve" */
74
+ approveLabel?: string;
75
+ /** The deny button's label, e.g. "Don't publish".
76
+ * @default "Deny" */
77
+ denyLabel?: string;
78
+ /** Called when the person approves the call. Move `status` on from "approval" in response. */
79
+ onApprove?(): void;
80
+ /** Called when the person refuses the call. Move `status` on to "cancelled" in response. */
81
+ onDeny?(): void;
82
+ /** The locale for the duration's digits, e.g. "de-CH". Defaults to the browser's. */
83
+ locale?: string;
84
+ }
85
+ /**
86
+ * One tool call an agent makes: what it's doing, the tool, its status and result on one row, which opens to show the
87
+ * input and output. A failed call opens to its error, and a call that needs approval asks for it with Approve and Deny.
88
+ */
89
+ export declare const ChatTool: import("react").ForwardRefExoticComponent<ChatToolProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,44 @@
1
+ export interface ColorAreaProps {
2
+ /** The colour as hex, "#0d9488". Given with alpha ("#0d9488cc"), it keeps the alpha. */
3
+ value?: string;
4
+ /** The starting colour when uncontrolled.
5
+ * @default "#312c7e" */
6
+ defaultValue?: string;
7
+ /** Called with a lowercase hex as the person drags or presses the arrow keys. */
8
+ onChange?(color: string): void;
9
+ /** Called when the person lets go or releases the key, for work too slow to do on every move. */
10
+ onChangeEnd?(color: string): void;
11
+ /** The hue to show while the colour is a grey, which has none of its own. Pass a hue ColorSlider's `onHueChange`
12
+ * value here to keep the two in step on greys. Without it, the area keeps the last hue it had. */
13
+ hue?: number;
14
+ /** Pixels, or any CSS width. It never grows past its container.
15
+ * @default 232 */
16
+ width?: number | string;
17
+ /** Pixels, or any CSS height.
18
+ * @default 152 */
19
+ height?: number | string;
20
+ /** Fades it; the pointer and the keys do nothing.
21
+ * @default false */
22
+ disabled?: boolean;
23
+ /** The locale for the percentages screen readers hear. Defaults to the browser's. */
24
+ locale?: string;
25
+ /** The form field name; the hex is submitted under it. */
26
+ name?: string;
27
+ /** Names the area for screen readers; its two sliders are "Saturation" and "Brightness" within it.
28
+ * @default "Colour" */
29
+ "aria-label"?: string;
30
+ /** Names the area by a visible label's id, in place of aria-label. */
31
+ "aria-labelledby"?: string;
32
+ /** Ids of a hint or an error, read out after each slider's value. */
33
+ "aria-describedby"?: string;
34
+ /** The group's id. */
35
+ id?: string;
36
+ /** Classes for the area, e.g. a size. */
37
+ className?: string;
38
+ }
39
+ /**
40
+ * A square of one hue: saturation across, brightness up and down. Drag the thumb, or use the arrow keys.
41
+ * To screen readers it's two sliders, saturation and brightness, each reading out the colour.
42
+ * The ref is the saturation slider's input, for focusing it.
43
+ */
44
+ export declare const ColorArea: import("react").ForwardRefExoticComponent<ColorAreaProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,44 @@
1
+ export interface ColorAreaProps {
2
+ /** The colour as hex, "#0d9488". Given with alpha ("#0d9488cc"), it keeps the alpha. */
3
+ value?: string;
4
+ /** The starting colour when uncontrolled.
5
+ * @default "#312c7e" */
6
+ defaultValue?: string;
7
+ /** Called with a lowercase hex as the person drags or presses the arrow keys. */
8
+ onChange?(color: string): void;
9
+ /** Called when the person lets go or releases the key, for work too slow to do on every move. */
10
+ onChangeEnd?(color: string): void;
11
+ /** The hue to show while the colour is a grey, which has none of its own. Pass a hue ColorSlider's `onHueChange`
12
+ * value here to keep the two in step on greys. Without it, the area keeps the last hue it had. */
13
+ hue?: number;
14
+ /** Pixels, or any CSS width. It never grows past its container.
15
+ * @default 232 */
16
+ width?: number | string;
17
+ /** Pixels, or any CSS height.
18
+ * @default 152 */
19
+ height?: number | string;
20
+ /** Fades it; the pointer and the keys do nothing.
21
+ * @default false */
22
+ disabled?: boolean;
23
+ /** The locale for the percentages screen readers hear. Defaults to the browser's. */
24
+ locale?: string;
25
+ /** The form field name; the hex is submitted under it. */
26
+ name?: string;
27
+ /** Names the area for screen readers; its two sliders are "Saturation" and "Brightness" within it.
28
+ * @default "Colour" */
29
+ "aria-label"?: string;
30
+ /** Names the area by a visible label's id, in place of aria-label. */
31
+ "aria-labelledby"?: string;
32
+ /** Ids of a hint or an error, read out after each slider's value. */
33
+ "aria-describedby"?: string;
34
+ /** The group's id. */
35
+ id?: string;
36
+ /** Classes for the area, e.g. a size. */
37
+ className?: string;
38
+ }
39
+ /**
40
+ * A square of one hue: saturation across, brightness up and down. Drag the thumb, or use the arrow keys.
41
+ * To screen readers it's two sliders, saturation and brightness, each reading out the colour.
42
+ * The ref is the saturation slider's input, for focusing it.
43
+ */
44
+ export declare const ColorArea: import("react").ForwardRefExoticComponent<ColorAreaProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,53 @@
1
+ import { type ReactNode } from "react";
2
+ /** A channel a ColorSlider changes: HSL's hue, saturation or lightness, the alpha, or red, green or blue. */
3
+ export type ColorChannel = "hue" | "saturation" | "lightness" | "alpha" | "red" | "green" | "blue";
4
+ export interface ColorSliderProps {
5
+ /** The channel it changes. Saturation and lightness are HSL's; the track shows the channel's range for the current colour. */
6
+ channel: ColorChannel;
7
+ /** The colour as hex. The alpha channel takes and returns "#rrggbbaa"; the others keep any alpha they're given. */
8
+ value?: string;
9
+ /** The starting colour when uncontrolled.
10
+ * @default "#312c7e" */
11
+ defaultValue?: string;
12
+ /** Called with a lowercase hex as the person drags or presses the arrow keys. */
13
+ onChange?(color: string): void;
14
+ /** Called when the person lets go or releases the key, for work too slow to do on every move. */
15
+ onChangeEnd?(color: string): void;
16
+ /** The hue to show while the colour is a grey, which has none of its own. Without it, the slider keeps the last hue it had. */
17
+ hue?: number;
18
+ /** Called with the hue as a hue slider moves, including over a grey, whose hex doesn't change. Pass it on to a
19
+ * ColorArea's `hue` to keep the two in step. */
20
+ onHueChange?(hue: number): void;
21
+ /** Shown above the track, and names the slider for screen readers. */
22
+ label?: ReactNode;
23
+ /** Shows the channel's value (174°, 72%, or 0 to 255 for red, green and blue) at the right of the label.
24
+ * Defaults to true when there's a label. */
25
+ showValue?: boolean;
26
+ /** A vertical slider is 152px tall, a ColorArea's height; set another with CSS.
27
+ * @default "horizontal" */
28
+ orientation?: "horizontal" | "vertical";
29
+ /** Fades it; the pointer and the keys do nothing.
30
+ * @default false */
31
+ disabled?: boolean;
32
+ /** The locale for the value shown and read out. Defaults to the browser's. */
33
+ locale?: string;
34
+ /** The form field name; the hex is submitted under it. */
35
+ name?: string;
36
+ /** Names the slider when there's no label. Defaults to the channel's name ("Hue", "Opacity"), unless aria-labelledby
37
+ * or a Field names it. */
38
+ "aria-label"?: string;
39
+ /** Names the slider by a visible label's id. */
40
+ "aria-labelledby"?: string;
41
+ /** Ids of a hint or an error, read out after the value; a Field sets it. */
42
+ "aria-describedby"?: string;
43
+ /** The input's id; a Field sets it so its label names the slider. */
44
+ id?: string;
45
+ /** Classes for the slider's outer element, e.g. a height for a vertical one. */
46
+ className?: string;
47
+ }
48
+ /**
49
+ * Changes one channel of a colour by dragging, over a track that shows that channel's range: a hue slider, an
50
+ * opacity slider over a checkerboard, or red, green and blue. It works with the keyboard like Slider.
51
+ * The ref is its input, for focusing it.
52
+ */
53
+ export declare const ColorSlider: import("react").ForwardRefExoticComponent<ColorSliderProps & import("react").RefAttributes<HTMLInputElement>>;