@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,95 @@
1
+ import { type KeyboardEvent, type ReactNode } from "react";
2
+ /** A file attached to the message, shown as a chip above the text. */
3
+ export interface PromptAttachment {
4
+ /** Identifies it to onRemoveAttachment, and keys its chip. */
5
+ id: string;
6
+ /** The file name, shown on the chip (a long one is cut short before its extension) and read out by its remove button. */
7
+ name: string;
8
+ /** Bytes, shown under the name: "48 kB". */
9
+ size?: number;
10
+ /** The MIME type, such as "image/png". With the name, it picks the chip's icon when there's no preview. */
11
+ type?: string;
12
+ /** An image to show as the chip's thumbnail: an object URL from URL.createObjectURL, or any image URL. */
13
+ previewUrl?: string;
14
+ }
15
+ export interface PromptInputProps {
16
+ /** The text, when controlled. Clear it yourself in onSubmit. */
17
+ value?: string;
18
+ /** The starting text when uncontrolled. The box clears itself after each send.
19
+ * @default "" */
20
+ defaultValue?: string;
21
+ /** Called with the text on every change. */
22
+ onChange?(value: string): void;
23
+ /**
24
+ * Called on Enter or the send button with the text (trimmed) and the attachments. It isn't called while there's
25
+ * nothing to send (no text and no attachments), while streaming, or while disabled.
26
+ */
27
+ onSubmit?(value: string, attachments: PromptAttachment[]): void;
28
+ /** The agent is replying: the send button becomes a Stop button and Escape in the box stops it. The next message can
29
+ * be typed meanwhile, but not sent.
30
+ * @default false */
31
+ isStreaming?: boolean;
32
+ /** Called by the Stop button, and by Escape in the box, while streaming. */
33
+ onStop?(): void;
34
+ /** The files attached so far, as chips above the text. You keep the list: add to it in onAttach and take from it in
35
+ * onRemoveAttachment. */
36
+ attachments?: PromptAttachment[];
37
+ /** Called with the files picked with the paperclip, pasted, or dropped on the box. Giving it shows the paperclip. */
38
+ onAttach?(files: File[]): void;
39
+ /** Called with an attachment's id when its remove button is pressed. Giving it shows the remove buttons. */
40
+ onRemoveAttachment?(id: string): void;
41
+ /** File types to accept, as for <input accept>: "image/*,.log,.txt". Other files are turned away with a message. */
42
+ accept?: string;
43
+ /** Lets several files be attached at once.
44
+ * @default true */
45
+ multiple?: boolean;
46
+ /** Controls at the start of the toolbar under the text, after the paperclip: a model Select, a toggle. Buttons here
47
+ * should be size sm. */
48
+ startActions?: ReactNode;
49
+ /** Controls at the end of the toolbar, before the send button. */
50
+ endActions?: ReactNode;
51
+ /** A muted line under the box, such as how to send: "Enter to send, Shift + Enter for a new line". The text box
52
+ * points to it with aria-describedby. */
53
+ hint?: ReactNode;
54
+ /** @default "Message the agent…" */
55
+ placeholder?: string;
56
+ /** Names the text box for screen readers. It's "Message" unless something else labels it: aria-labelledby, or an id
57
+ * that a <label> points to, as in a Field. */
58
+ "aria-label"?: string;
59
+ "aria-labelledby"?: string;
60
+ "aria-describedby"?: string;
61
+ /** The text box's id. Field sets it. */
62
+ id?: string;
63
+ /** Marks the box invalid: a danger border, and aria-invalid on the text box. Field sets it from its error.
64
+ * @default false */
65
+ isInvalid?: boolean;
66
+ /** Turns off the text box, its buttons and the controls in the toolbar, and fades the box.
67
+ * @default false */
68
+ disabled?: boolean;
69
+ /** Focuses the text box when it appears. Use it where typing is plainly the next step, such as a new chat.
70
+ * @default false */
71
+ autoFocus?: boolean;
72
+ /** The most characters the text can have. A quiet count shows once it's 80% full. */
73
+ maxLength?: number;
74
+ /** The rows of text the box shows when it's empty.
75
+ * @default 1 */
76
+ minRows?: number;
77
+ /** The most rows it grows to; past that, the text scrolls.
78
+ * @default 8 */
79
+ maxRows?: number;
80
+ /** md for a chat page, sm for a side panel or a reply box.
81
+ * @default "md" */
82
+ size?: "sm" | "md";
83
+ /** The locale for attachment sizes and the character count, such as "de-CH". Defaults to the browser's. */
84
+ locale?: string;
85
+ /** Called for each key in the text box before the box's own keys. Call event.preventDefault() to take a key over, for
86
+ * example the Up arrow to edit the last message. */
87
+ onKeyDown?(event: KeyboardEvent<HTMLTextAreaElement>): void;
88
+ /** Classes for the outer element, which holds the box and the hint. */
89
+ className?: string;
90
+ }
91
+ /**
92
+ * The box you write to the agent in. Enter sends and Shift+Enter starts a new line; it grows with the text, takes files
93
+ * from a picker, the clipboard or a drop, and turns its send button into Stop while the agent replies.
94
+ */
95
+ export declare const PromptInput: import("react").ForwardRefExoticComponent<PromptInputProps & import("react").RefAttributes<HTMLTextAreaElement>>;
@@ -0,0 +1,36 @@
1
+ import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode } from "react";
2
+ export interface PromptSuggestionProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
3
+ /** The suggested prompt, or a short title for it. Keep it to a few words on a pill. */
4
+ children: ReactNode;
5
+ /** A 16px lucide-react icon before the text. */
6
+ icon?: ReactNode;
7
+ /** A muted second line under the text, saying what the agent will do. Shown on cards. */
8
+ description?: ReactNode;
9
+ /** `pill` for a row of short prompts; `card` for a few larger starting points, each with a description.
10
+ * @default "card" with a description, otherwise "pill" */
11
+ variant?: "pill" | "card";
12
+ }
13
+ /**
14
+ * A suggested prompt to start from: a quiet pill, or a card with a second line. It's a button: what it does on click,
15
+ * filling the prompt box or sending at once, is up to you.
16
+ */
17
+ export declare const PromptSuggestion: import("react").ForwardRefExoticComponent<PromptSuggestionProps & import("react").RefAttributes<HTMLButtonElement>>;
18
+ export interface PromptSuggestionsProps extends HTMLAttributes<HTMLDivElement> {
19
+ /** PromptSuggestion buttons. */
20
+ children: ReactNode;
21
+ /** `wrap` runs pills along a line and onto the next; `grid` sets cards in equal columns that fold to one when
22
+ * there's no room.
23
+ * @default "wrap" */
24
+ layout?: "wrap" | "grid";
25
+ /** The most columns in a grid. Columns are at least 200px wide, so a narrow grid has fewer.
26
+ * @default 2 */
27
+ columns?: number;
28
+ /** Where wrapped pills line up.
29
+ * @default "start" */
30
+ align?: "start" | "center";
31
+ /** Names the set for screen readers.
32
+ * @default "Suggested prompts" */
33
+ "aria-label"?: string;
34
+ }
35
+ /** Suggested prompts, as a labelled group: pills that wrap, or cards in a grid. */
36
+ export declare function PromptSuggestions({ children, layout, columns, align, "aria-label": ariaLabel, className, style, ...props }: PromptSuggestionsProps): import("react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode } from "react";
2
+ export interface PromptSuggestionProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
3
+ /** The suggested prompt, or a short title for it. Keep it to a few words on a pill. */
4
+ children: ReactNode;
5
+ /** A 16px lucide-react icon before the text. */
6
+ icon?: ReactNode;
7
+ /** A muted second line under the text, saying what the agent will do. Shown on cards. */
8
+ description?: ReactNode;
9
+ /** `pill` for a row of short prompts; `card` for a few larger starting points, each with a description.
10
+ * @default "card" with a description, otherwise "pill" */
11
+ variant?: "pill" | "card";
12
+ }
13
+ /**
14
+ * A suggested prompt to start from: a quiet pill, or a card with a second line. It's a button: what it does on click,
15
+ * filling the prompt box or sending at once, is up to you.
16
+ */
17
+ export declare const PromptSuggestion: import("react").ForwardRefExoticComponent<PromptSuggestionProps & import("react").RefAttributes<HTMLButtonElement>>;
18
+ export interface PromptSuggestionsProps extends HTMLAttributes<HTMLDivElement> {
19
+ /** PromptSuggestion buttons. */
20
+ children: ReactNode;
21
+ /** `wrap` runs pills along a line and onto the next; `grid` sets cards in equal columns that fold to one when
22
+ * there's no room.
23
+ * @default "wrap" */
24
+ layout?: "wrap" | "grid";
25
+ /** The most columns in a grid. Columns are at least 200px wide, so a narrow grid has fewer.
26
+ * @default 2 */
27
+ columns?: number;
28
+ /** Where wrapped pills line up.
29
+ * @default "start" */
30
+ align?: "start" | "center";
31
+ /** Names the set for screen readers.
32
+ * @default "Suggested prompts" */
33
+ "aria-label"?: string;
34
+ }
35
+ /** Suggested prompts, as a labelled group: pills that wrap, or cards in a grid. */
36
+ export declare function PromptSuggestions({ children, layout, columns, align, "aria-label": ariaLabel, className, style, ...props }: PromptSuggestionsProps): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ export interface ProseProps extends HTMLAttributes<HTMLElement> {
3
+ /** sm sets 14px interface text with a tight rhythm and modest headings, for chat answers and comments. md sets the prose
4
+ * style (16.5px, 1.7 leading) with headings from the type scale, for articles and docs.
5
+ * @default "md" */
6
+ size?: "sm" | "md";
7
+ /** Drops the readable width (about 68 characters a line at md) so the text runs the full width of its container. sm has no
8
+ * maximum width to drop.
9
+ * @default false */
10
+ fullWidth?: boolean;
11
+ /** The element: article for a post, section for part of a page.
12
+ * @default "div" */
13
+ as?: "div" | "article" | "section" | "main" | "aside";
14
+ /** Plain HTML elements to style: what a Markdown renderer, a CMS or a server gives back. */
15
+ children?: ReactNode;
16
+ }
17
+ /**
18
+ * Styles content you don't write element by element: Markdown rendered to HTML, a CMS body, an agent's answer. It sets
19
+ * the plain elements inside it (headings, paragraphs, lists, quotes, code, tables, images, details) in Openware's type
20
+ * and colours, and leaves Openware components inside it as they are.
21
+ */
22
+ export declare const Prose: import("react").ForwardRefExoticComponent<ProseProps & import("react").RefAttributes<HTMLElement>>;
@@ -0,0 +1,22 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ export interface ProseProps extends HTMLAttributes<HTMLElement> {
3
+ /** sm sets 14px interface text with a tight rhythm and modest headings, for chat answers and comments. md sets the prose
4
+ * style (16.5px, 1.7 leading) with headings from the type scale, for articles and docs.
5
+ * @default "md" */
6
+ size?: "sm" | "md";
7
+ /** Drops the readable width (about 68 characters a line at md) so the text runs the full width of its container. sm has no
8
+ * maximum width to drop.
9
+ * @default false */
10
+ fullWidth?: boolean;
11
+ /** The element: article for a post, section for part of a page.
12
+ * @default "div" */
13
+ as?: "div" | "article" | "section" | "main" | "aside";
14
+ /** Plain HTML elements to style: what a Markdown renderer, a CMS or a server gives back. */
15
+ children?: ReactNode;
16
+ }
17
+ /**
18
+ * Styles content you don't write element by element: Markdown rendered to HTML, a CMS body, an agent's answer. It sets
19
+ * the plain elements inside it (headings, paragraphs, lists, quotes, code, tables, images, details) in Openware's type
20
+ * and colours, and leaves Openware components inside it as they are.
21
+ */
22
+ export declare const Prose: import("react").ForwardRefExoticComponent<ProseProps & import("react").RefAttributes<HTMLElement>>;
@@ -22,6 +22,12 @@ export interface SliderProps<V extends SliderValue = number> {
22
22
  formatValue?(value: number): string;
23
23
  /** Names the slider when there's no visible label. */
24
24
  "aria-label"?: string;
25
+ /** Names the slider by another element's id, such as a Field's label. */
26
+ "aria-labelledby"?: string;
27
+ /** Ids of the hint or error that describe it; Field sets this. */
28
+ "aria-describedby"?: string;
29
+ /** The id of the (first) handle's input, so a Field's label points at it; Field sets this. */
30
+ id?: string;
25
31
  disabled?: boolean;
26
32
  className?: string;
27
33
  }
@@ -29,5 +35,5 @@ export interface SliderProps<V extends SliderValue = number> {
29
35
  * Picks a number, or a range, by dragging. It's built on native range inputs, so the arrow keys,
30
36
  * PageUp, PageDown, Home and End work as people expect.
31
37
  */
32
- export declare function Slider<V extends SliderValue = number>({ value, defaultValue, onChange, onChangeEnd, min, max, step, label, showValue, formatValue, "aria-label": ariaLabel, disabled, className, }: SliderProps<V>): import("react").JSX.Element;
38
+ export declare function Slider<V extends SliderValue = number>({ value, defaultValue, onChange, onChangeEnd, min, max, step, label, showValue, formatValue, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, id, disabled, className, }: SliderProps<V>): import("react").JSX.Element;
33
39
  export {};
@@ -22,6 +22,12 @@ export interface SliderProps<V extends SliderValue = number> {
22
22
  formatValue?(value: number): string;
23
23
  /** Names the slider when there's no visible label. */
24
24
  "aria-label"?: string;
25
+ /** Names the slider by another element's id, such as a Field's label. */
26
+ "aria-labelledby"?: string;
27
+ /** Ids of the hint or error that describe it; Field sets this. */
28
+ "aria-describedby"?: string;
29
+ /** The id of the (first) handle's input, so a Field's label points at it; Field sets this. */
30
+ id?: string;
25
31
  disabled?: boolean;
26
32
  className?: string;
27
33
  }
@@ -29,5 +35,5 @@ export interface SliderProps<V extends SliderValue = number> {
29
35
  * Picks a number, or a range, by dragging. It's built on native range inputs, so the arrow keys,
30
36
  * PageUp, PageDown, Home and End work as people expect.
31
37
  */
32
- export declare function Slider<V extends SliderValue = number>({ value, defaultValue, onChange, onChangeEnd, min, max, step, label, showValue, formatValue, "aria-label": ariaLabel, disabled, className, }: SliderProps<V>): import("react").JSX.Element;
38
+ export declare function Slider<V extends SliderValue = number>({ value, defaultValue, onChange, onChangeEnd, min, max, step, label, showValue, formatValue, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, id, disabled, className, }: SliderProps<V>): import("react").JSX.Element;
33
39
  export {};
@@ -0,0 +1,20 @@
1
+ import type { JSX, ReactNode } from "react";
2
+ export interface TextShimmerProps {
3
+ /** The words that shimmer, usually a status ending in an ellipsis: "Thinking…", "Running tests…". */
4
+ children: ReactNode;
5
+ /** The element, so it can sit in a heading or a paragraph.
6
+ * @default "span" */
7
+ as?: keyof JSX.IntrinsicElements;
8
+ /** Seconds for the highlight to cross the text once.
9
+ * @default 2 */
10
+ duration?: number;
11
+ /** Stops the shimmer and shows the text plainly, e.g. once the step has finished.
12
+ * @default true */
13
+ active?: boolean;
14
+ className?: string;
15
+ }
16
+ /**
17
+ * Text with a highlight sweeping across it, for work in progress: "Thinking…", "Searching the codebase…". It's plain
18
+ * text to screen readers, and stands still when the person prefers reduced motion.
19
+ */
20
+ export declare function TextShimmer({ children, as, duration, active, className }: TextShimmerProps): JSX.Element;
@@ -0,0 +1,20 @@
1
+ import type { JSX, ReactNode } from "react";
2
+ export interface TextShimmerProps {
3
+ /** The words that shimmer, usually a status ending in an ellipsis: "Thinking…", "Running tests…". */
4
+ children: ReactNode;
5
+ /** The element, so it can sit in a heading or a paragraph.
6
+ * @default "span" */
7
+ as?: keyof JSX.IntrinsicElements;
8
+ /** Seconds for the highlight to cross the text once.
9
+ * @default 2 */
10
+ duration?: number;
11
+ /** Stops the shimmer and shows the text plainly, e.g. once the step has finished.
12
+ * @default true */
13
+ active?: boolean;
14
+ className?: string;
15
+ }
16
+ /**
17
+ * Text with a highlight sweeping across it, for work in progress: "Thinking…", "Searching the codebase…". It's plain
18
+ * text to screen readers, and stands still when the person prefers reduced motion.
19
+ */
20
+ export declare function TextShimmer({ children, as, duration, active, className }: TextShimmerProps): JSX.Element;
@@ -0,0 +1,74 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ToggleButtonGroupOption {
3
+ /** Identifies the option in `value`. */
4
+ value: string;
5
+ /** The visible text. Leave it out for an icon-only option, and give that an aria-label. */
6
+ label?: ReactNode;
7
+ /** A 16px icon before the label, or on its own. */
8
+ icon?: ReactNode;
9
+ /** Names an icon-only option for screen readers; a tooltip shows the same words. */
10
+ "aria-label"?: string;
11
+ /** Greys the option out; the arrow keys skip it.
12
+ * @default false */
13
+ disabled?: boolean;
14
+ }
15
+ export interface ToggleButtonGroupProps {
16
+ /** The toggles, in order. */
17
+ options: ToggleButtonGroupOption[];
18
+ /** `multiple` lets any number be on, like bold and italic; `single` allows at most one, like an alignment.
19
+ * Either way all can be off, unless `disallowEmptySelection`.
20
+ * @default "single" */
21
+ selectionMode?: "single" | "multiple";
22
+ /** What's on: in single mode a value, or "" for none; in multiple mode an array of values. Leave it out to let the
23
+ * group keep its own state. */
24
+ value?: string | string[];
25
+ /** The starting value when uncontrolled.
26
+ * @default "" or [] */
27
+ defaultValue?: string | string[];
28
+ /** Called with the new value: a string ("" for none) in single mode, an array in the options' order in multiple mode. */
29
+ onChange?(value: string | string[]): void;
30
+ /** Keeps one option on: pressing the only one that's on leaves it on.
31
+ * @default false */
32
+ disallowEmptySelection?: boolean;
33
+ /** sm 32px, md 40px tall, like Button. Inside a Toolbar it takes the toolbar's size.
34
+ * @default "md" */
35
+ size?: "sm" | "md";
36
+ /** Inside a Toolbar it takes the toolbar's orientation.
37
+ * @default "horizontal" */
38
+ orientation?: "horizontal" | "vertical";
39
+ /** Disables every option, keeping what's on visible.
40
+ * @default false */
41
+ disabled?: boolean;
42
+ /** Names the group for screen readers, e.g. "Text style". */
43
+ "aria-label"?: string;
44
+ /** The id of a visible label for the group, in place of aria-label. */
45
+ "aria-labelledby"?: string;
46
+ /** The id of a hint or description for the group. */
47
+ "aria-describedby"?: string;
48
+ /** An id for the group's element. */
49
+ id?: string;
50
+ /** Extra classes for the group. */
51
+ className?: string;
52
+ }
53
+ type SharedProps = Omit<ToggleButtonGroupProps, "selectionMode" | "value" | "defaultValue" | "onChange">;
54
+ /** The props in single mode: `value` is one option's value, or "" when none is on. */
55
+ export type ToggleButtonGroupSingleProps = SharedProps & {
56
+ selectionMode?: "single";
57
+ value?: string;
58
+ defaultValue?: string;
59
+ onChange?(value: string): void;
60
+ };
61
+ /** The props in multiple mode: `value` is the values of the options that are on. */
62
+ export type ToggleButtonGroupMultipleProps = SharedProps & {
63
+ selectionMode: "multiple";
64
+ value?: string[];
65
+ defaultValue?: string[];
66
+ onChange?(value: string[]): void;
67
+ };
68
+ /**
69
+ * Toggle buttons joined into one control: several can be on (bold, italic, underline) or at most one (an alignment),
70
+ * and, unlike a SegmentedControl, all can be off. On its own it's one tab stop with the arrow keys moving between its
71
+ * buttons; inside a Toolbar it leaves the arrow keys to the toolbar.
72
+ */
73
+ export declare function ToggleButtonGroup(props: ToggleButtonGroupSingleProps | ToggleButtonGroupMultipleProps): import("react").JSX.Element;
74
+ export {};
@@ -0,0 +1,74 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ToggleButtonGroupOption {
3
+ /** Identifies the option in `value`. */
4
+ value: string;
5
+ /** The visible text. Leave it out for an icon-only option, and give that an aria-label. */
6
+ label?: ReactNode;
7
+ /** A 16px icon before the label, or on its own. */
8
+ icon?: ReactNode;
9
+ /** Names an icon-only option for screen readers; a tooltip shows the same words. */
10
+ "aria-label"?: string;
11
+ /** Greys the option out; the arrow keys skip it.
12
+ * @default false */
13
+ disabled?: boolean;
14
+ }
15
+ export interface ToggleButtonGroupProps {
16
+ /** The toggles, in order. */
17
+ options: ToggleButtonGroupOption[];
18
+ /** `multiple` lets any number be on, like bold and italic; `single` allows at most one, like an alignment.
19
+ * Either way all can be off, unless `disallowEmptySelection`.
20
+ * @default "single" */
21
+ selectionMode?: "single" | "multiple";
22
+ /** What's on: in single mode a value, or "" for none; in multiple mode an array of values. Leave it out to let the
23
+ * group keep its own state. */
24
+ value?: string | string[];
25
+ /** The starting value when uncontrolled.
26
+ * @default "" or [] */
27
+ defaultValue?: string | string[];
28
+ /** Called with the new value: a string ("" for none) in single mode, an array in the options' order in multiple mode. */
29
+ onChange?(value: string | string[]): void;
30
+ /** Keeps one option on: pressing the only one that's on leaves it on.
31
+ * @default false */
32
+ disallowEmptySelection?: boolean;
33
+ /** sm 32px, md 40px tall, like Button. Inside a Toolbar it takes the toolbar's size.
34
+ * @default "md" */
35
+ size?: "sm" | "md";
36
+ /** Inside a Toolbar it takes the toolbar's orientation.
37
+ * @default "horizontal" */
38
+ orientation?: "horizontal" | "vertical";
39
+ /** Disables every option, keeping what's on visible.
40
+ * @default false */
41
+ disabled?: boolean;
42
+ /** Names the group for screen readers, e.g. "Text style". */
43
+ "aria-label"?: string;
44
+ /** The id of a visible label for the group, in place of aria-label. */
45
+ "aria-labelledby"?: string;
46
+ /** The id of a hint or description for the group. */
47
+ "aria-describedby"?: string;
48
+ /** An id for the group's element. */
49
+ id?: string;
50
+ /** Extra classes for the group. */
51
+ className?: string;
52
+ }
53
+ type SharedProps = Omit<ToggleButtonGroupProps, "selectionMode" | "value" | "defaultValue" | "onChange">;
54
+ /** The props in single mode: `value` is one option's value, or "" when none is on. */
55
+ export type ToggleButtonGroupSingleProps = SharedProps & {
56
+ selectionMode?: "single";
57
+ value?: string;
58
+ defaultValue?: string;
59
+ onChange?(value: string): void;
60
+ };
61
+ /** The props in multiple mode: `value` is the values of the options that are on. */
62
+ export type ToggleButtonGroupMultipleProps = SharedProps & {
63
+ selectionMode: "multiple";
64
+ value?: string[];
65
+ defaultValue?: string[];
66
+ onChange?(value: string[]): void;
67
+ };
68
+ /**
69
+ * Toggle buttons joined into one control: several can be on (bold, italic, underline) or at most one (an alignment),
70
+ * and, unlike a SegmentedControl, all can be off. On its own it's one tab stop with the arrow keys moving between its
71
+ * buttons; inside a Toolbar it leaves the arrow keys to the toolbar.
72
+ */
73
+ export declare function ToggleButtonGroup(props: ToggleButtonGroupSingleProps | ToggleButtonGroupMultipleProps): import("react").JSX.Element;
74
+ export {};
@@ -0,0 +1,36 @@
1
+ import { type HTMLAttributes } from "react";
2
+ export interface ToolbarProps extends HTMLAttributes<HTMLDivElement> {
3
+ /** Names the toolbar for screen readers, e.g. "Formatting". Every toolbar needs a name, from this or aria-labelledby. */
4
+ "aria-label"?: string;
5
+ /** The id of a visible heading that names the toolbar, in place of aria-label. */
6
+ "aria-labelledby"?: string;
7
+ /** Which way it runs. The arrow keys follow it: Left and Right across a horizontal toolbar, Up and Down a vertical one.
8
+ * @default "horizontal" */
9
+ orientation?: "horizontal" | "vertical";
10
+ /** `raised` is a bar of its own: a surface with a hairline border and a soft shadow. `plain` has no ground, for a
11
+ * toolbar in a card or panel header.
12
+ * @default "raised" */
13
+ variant?: "raised" | "plain";
14
+ /** The bar's padding and gaps, and the size its ToggleButtonGroups and separators take. Give its Buttons the same size.
15
+ * @default "md" */
16
+ size?: "sm" | "md";
17
+ }
18
+ export interface ToolbarSeparatorProps {
19
+ /** Extra classes for the line. */
20
+ className?: string;
21
+ }
22
+ interface ToolbarContextValue {
23
+ orientation: "horizontal" | "vertical";
24
+ size: "sm" | "md";
25
+ }
26
+ /** Lets what's inside a Toolbar follow its orientation and size, and leave the arrow keys to it. */
27
+ export declare const ToolbarContext: import("react").Context<ToolbarContextValue | null>;
28
+ /**
29
+ * A row of controls for one context: an editor's formatting bar, a table's actions. It's a single tab stop: the
30
+ * arrow keys move between every control inside it, ToggleButtonGroups' buttons included, and Tab leaves it, coming
31
+ * back to the control that was focused last.
32
+ */
33
+ export declare const Toolbar: import("react").ForwardRefExoticComponent<ToolbarProps & import("react").RefAttributes<HTMLDivElement>>;
34
+ /** A line between groups of controls in a Toolbar, across the toolbar's direction. */
35
+ export declare function ToolbarSeparator({ className }: ToolbarSeparatorProps): import("react").JSX.Element;
36
+ export {};
@@ -0,0 +1,36 @@
1
+ import { type HTMLAttributes } from "react";
2
+ export interface ToolbarProps extends HTMLAttributes<HTMLDivElement> {
3
+ /** Names the toolbar for screen readers, e.g. "Formatting". Every toolbar needs a name, from this or aria-labelledby. */
4
+ "aria-label"?: string;
5
+ /** The id of a visible heading that names the toolbar, in place of aria-label. */
6
+ "aria-labelledby"?: string;
7
+ /** Which way it runs. The arrow keys follow it: Left and Right across a horizontal toolbar, Up and Down a vertical one.
8
+ * @default "horizontal" */
9
+ orientation?: "horizontal" | "vertical";
10
+ /** `raised` is a bar of its own: a surface with a hairline border and a soft shadow. `plain` has no ground, for a
11
+ * toolbar in a card or panel header.
12
+ * @default "raised" */
13
+ variant?: "raised" | "plain";
14
+ /** The bar's padding and gaps, and the size its ToggleButtonGroups and separators take. Give its Buttons the same size.
15
+ * @default "md" */
16
+ size?: "sm" | "md";
17
+ }
18
+ export interface ToolbarSeparatorProps {
19
+ /** Extra classes for the line. */
20
+ className?: string;
21
+ }
22
+ interface ToolbarContextValue {
23
+ orientation: "horizontal" | "vertical";
24
+ size: "sm" | "md";
25
+ }
26
+ /** Lets what's inside a Toolbar follow its orientation and size, and leave the arrow keys to it. */
27
+ export declare const ToolbarContext: import("react").Context<ToolbarContextValue | null>;
28
+ /**
29
+ * A row of controls for one context: an editor's formatting bar, a table's actions. It's a single tab stop: the
30
+ * arrow keys move between every control inside it, ToggleButtonGroups' buttons included, and Tab leaves it, coming
31
+ * back to the control that was focused last.
32
+ */
33
+ export declare const Toolbar: import("react").ForwardRefExoticComponent<ToolbarProps & import("react").RefAttributes<HTMLDivElement>>;
34
+ /** A line between groups of controls in a Toolbar, across the toolbar's direction. */
35
+ export declare function ToolbarSeparator({ className }: ToolbarSeparatorProps): import("react").JSX.Element;
36
+ export {};