@horon-ai/react 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +2 -2
- package/src/components/agent-activity.tsx +75 -7
- package/src/components/agent-lane.tsx +32 -3
- package/src/components/agent-lanes-timeline.tsx +85 -7
- package/src/components/agent-panel.tsx +46 -4
- package/src/components/agent-steering-panel.tsx +53 -3
- package/src/components/approval-card.tsx +34 -2
- package/src/components/avatar.tsx +20 -4
- package/src/components/badge.tsx +24 -3
- package/src/components/banner.tsx +19 -3
- package/src/components/bot-instructions-panel.tsx +86 -7
- package/src/components/bot-list-row.tsx +13 -1
- package/src/components/bot-memory-panel.tsx +58 -3
- package/src/components/bottom-sheet.tsx +61 -7
- package/src/components/breadcrumb-header.tsx +32 -2
- package/src/components/breadcrumb.tsx +31 -1
- package/src/components/button.tsx +46 -1
- package/src/components/calendar.tsx +76 -6
- package/src/components/card.tsx +30 -1
- package/src/components/chat-bubble.tsx +32 -3
- package/src/components/chat-controls.tsx +60 -7
- package/src/components/checkbox.tsx +22 -1
- package/src/components/chip.tsx +29 -2
- package/src/components/choice-card.tsx +25 -1
- package/src/components/code-panel.tsx +28 -3
- package/src/components/combobox.tsx +52 -2
- package/src/components/command-palette.tsx +65 -1
- package/src/components/composer.tsx +28 -1
- package/src/components/data-table.tsx +198 -16
- package/src/components/date-field.tsx +31 -2
- package/src/components/dialog.tsx +45 -3
- package/src/components/directory-card.tsx +23 -2
- package/src/components/document-extract-panel.tsx +83 -5
- package/src/components/empty-state.tsx +21 -2
- package/src/components/field.tsx +49 -3
- package/src/components/file-drop.tsx +39 -4
- package/src/components/filter-bar.tsx +38 -1
- package/src/components/flue-background.tsx +88 -4
- package/src/components/horon-icon.tsx +50 -3
- package/src/components/horon-wordmark.tsx +26 -1
- package/src/components/icon-button.tsx +38 -1
- package/src/components/input-group.tsx +57 -6
- package/src/components/input.tsx +48 -2
- package/src/components/integration-row.tsx +43 -2
- package/src/components/kbd.tsx +28 -2
- package/src/components/knowledge-base-panel.tsx +40 -2
- package/src/components/liquid-glass.tsx +16 -0
- package/src/components/list-detail.tsx +89 -7
- package/src/components/marketplace-card.tsx +40 -4
- package/src/components/mcp-server-row.tsx +49 -3
- package/src/components/menu.tsx +83 -3
- package/src/components/message-extras.tsx +50 -4
- package/src/components/modal.tsx +71 -4
- package/src/components/orchestrator-panel.tsx +48 -4
- package/src/components/page-header.tsx +26 -3
- package/src/components/plan-card.tsx +28 -1
- package/src/components/plan-step.tsx +41 -1
- package/src/components/plugin-row.tsx +61 -3
- package/src/components/progress.tsx +32 -2
- package/src/components/radio-group.tsx +55 -2
- package/src/components/research-run-panel.tsx +73 -3
- package/src/components/schedule.tsx +163 -12
- package/src/components/segmented-control.tsx +57 -2
- package/src/components/select.tsx +60 -0
- package/src/components/settings-list.tsx +66 -8
- package/src/components/sidebar.tsx +214 -23
- package/src/components/skeleton.tsx +61 -4
- package/src/components/slider.tsx +30 -0
- package/src/components/source-row.tsx +43 -4
- package/src/components/spinner.tsx +29 -2
- package/src/components/split-button.tsx +37 -3
- package/src/components/switch.tsx +31 -1
- package/src/components/tab-bar.tsx +47 -2
- package/src/components/tabs.tsx +59 -5
- package/src/components/task-row.tsx +49 -3
- package/src/components/textarea-field.tsx +36 -2
- package/src/components/textarea.tsx +35 -2
- package/src/components/toast.tsx +52 -3
- package/src/components/tool-call.tsx +87 -4
- package/src/components/tool-calls-header.tsx +32 -1
- package/src/components/tool-permissions.tsx +50 -2
- package/src/components/tooltip.tsx +33 -1
- package/src/components/top-bar.tsx +35 -2
- package/src/components/usage-meter.tsx +28 -2
- package/src/components/workspace-menu.tsx +46 -1
- package/src/hooks/use-active-indicator.ts +44 -1
- package/src/hooks/use-color-scheme.ts +24 -1
- package/src/hooks/use-copy-to-clipboard.ts +23 -0
- package/src/hooks/use-device.ts +29 -1
- package/src/hooks/use-hotkey.ts +21 -0
- package/src/hooks/use-media-query.ts +18 -0
- package/src/hooks/use-platform.ts +30 -1
- package/src/hooks/use-reduced-motion.ts +18 -1
- package/src/index.ts +31 -0
- package/src/lib/cn.ts +13 -1
- package/src/lib/cursor-ghost.ts +16 -6
- package/src/lib/platform.ts +71 -4
|
@@ -2,13 +2,20 @@ import { Radio as BaseRadio } from "@base-ui/react/radio";
|
|
|
2
2
|
import type { ComponentProps, ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
import { cn } from "../lib/cn";
|
|
5
|
+
/**
|
|
6
|
+
* Props for {@link ChoiceCard}: a radio root plus the card's own title, description and badge slots.
|
|
7
|
+
* `value`, `disabled` and the other radio props pass straight through to the Base UI radio root.
|
|
8
|
+
*/
|
|
5
9
|
export type ChoiceCardProps = Omit<ComponentProps<typeof BaseRadio.Root>, "className" | "children" | "title"> & {
|
|
10
|
+
/** Card heading on the title line; `label-md` semibold primary text, wrapped onto as many lines as the card width allows. */
|
|
6
11
|
title: ReactNode;
|
|
12
|
+
/** Optional second line under the title, rendered as `caption` secondary text. */
|
|
7
13
|
description?: ReactNode;
|
|
8
14
|
/** Pill at the end of the title line, e.g. "Recommended": 22px, 8px padding, 18% sky with brand text (Paper Mobile connection). */
|
|
9
15
|
badge?: ReactNode;
|
|
10
|
-
/** `brand` (default) is 18% sky with brand text; `neutral` is 6% ink with secondary text. */
|
|
16
|
+
/** `brand` (default) is 18% sky with brand text; `neutral` is 6% ink with secondary text. @default "brand" */
|
|
11
17
|
badgeTone?: "brand" | "neutral";
|
|
18
|
+
/** Extra classes on the card root, merged after the layout, border and state classes. */
|
|
12
19
|
className?: string;
|
|
13
20
|
};
|
|
14
21
|
|
|
@@ -16,6 +23,23 @@ export type ChoiceCardProps = Omit<ComponentProps<typeof BaseRadio.Root>, "class
|
|
|
16
23
|
* Paper `Choice card` (1VXM-0 selected, 1VXR-0 default): a 252px solid card, padding 14, radius 16, gap 12,
|
|
17
24
|
* with a 1px default border that turns brand when selected; no glass.
|
|
18
25
|
* Use inside `RadioGroup`. The 18px radio is a ring: 1.5px grey when off, a 5px ink ring around an 8px core when on.
|
|
26
|
+
*
|
|
27
|
+
* The card is a Base UI radio root, so it belongs to a single-select group: arrow keys move the selection,
|
|
28
|
+
* `value` / `defaultValue` on the group pick the card, and `disabled` drops the card to 40% opacity and blocks
|
|
29
|
+
* the click. The radio mark is decorative; the accessible name is the card's own text.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <RadioGroup defaultValue="team">
|
|
34
|
+
* <ChoiceCard value="solo" title="Solo" description="One workspace for yourself." />
|
|
35
|
+
* <ChoiceCard
|
|
36
|
+
* value="team"
|
|
37
|
+
* title="Team"
|
|
38
|
+
* description="Shared bots, memory and billing."
|
|
39
|
+
* badge="Recommended"
|
|
40
|
+
* />
|
|
41
|
+
* </RadioGroup>
|
|
42
|
+
* ```
|
|
19
43
|
*/
|
|
20
44
|
export function ChoiceCard({ title, description, badge, badgeTone = "brand", className, ...props }: ChoiceCardProps) {
|
|
21
45
|
return (
|
|
@@ -2,12 +2,26 @@ import type { ComponentProps } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "../lib/cn";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/** Props for {@link CodePanel}: the `<pre>` attributes (`children` carries the code) plus a merged `className`. */
|
|
6
|
+
export type CodePanelProps = Omit<ComponentProps<"pre">, "className"> & {
|
|
7
|
+
/** Extra classes on the `<pre>`, merged after the panel surface and type classes. */
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Paper `Code block` (1VV9-0), the light variant: a 10px-radius neutral-50 panel with a 1px hairline,
|
|
9
13
|
* Geist Mono 12px on a 21px line pitch (Paper rows are 19px with a 2px gap), no header bar or copy button. Wrap keys in `CodeKey`; plain text reads as the string color.
|
|
10
14
|
* Chat surfaces keep the ink `CodeBlock` from message-extras.
|
|
15
|
+
*
|
|
16
|
+
* The `<pre>` scrolls horizontally instead of wrapping (`whitespace-pre`), and the dark theme swaps the
|
|
17
|
+
* panel to neutral-800 with a stronger border.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <CodePanel>
|
|
22
|
+
* {"---\ntitle: Weekly digest\n---"}
|
|
23
|
+
* </CodePanel>
|
|
24
|
+
* ```
|
|
11
25
|
*/
|
|
12
26
|
export function CodePanel({ className, ...props }: CodePanelProps) {
|
|
13
27
|
return (
|
|
@@ -21,7 +35,18 @@ export function CodePanel({ className, ...props }: CodePanelProps) {
|
|
|
21
35
|
);
|
|
22
36
|
}
|
|
23
37
|
|
|
24
|
-
/**
|
|
25
|
-
|
|
38
|
+
/**
|
|
39
|
+
* A frontmatter key or other highlighted token inside a `CodePanel`.
|
|
40
|
+
*
|
|
41
|
+
* Part of {@link CodePanel}. Renders an inline `span` in the key colour, so it only changes the colour of
|
|
42
|
+
* the text it wraps; extra classes can override or add weight.
|
|
43
|
+
*/
|
|
44
|
+
export function CodeKey({
|
|
45
|
+
className,
|
|
46
|
+
...props
|
|
47
|
+
}: Omit<ComponentProps<"span">, "className"> & {
|
|
48
|
+
/** Extra classes on the span, merged after the key colour. */
|
|
49
|
+
className?: string;
|
|
50
|
+
}) {
|
|
26
51
|
return <span className={cn("text-syntax-key", className)} {...props} />;
|
|
27
52
|
}
|
|
@@ -7,9 +7,12 @@ import type { ControlSize } from "../lib/size";
|
|
|
7
7
|
import { fieldBoxClass, fieldSizeClass, fieldTextClass, type InputSurface } from "./input";
|
|
8
8
|
import { inputGroupSegmentClass, useInputGroup } from "./input-group";
|
|
9
9
|
|
|
10
|
+
/** Height and text rung, shared with the other controls: `sm` 32px, `md` 40px, `lg` 48px. */
|
|
10
11
|
export type ComboboxSize = ControlSize;
|
|
11
12
|
|
|
13
|
+
/** One option in the list; the `value` is what the field reports and submits. */
|
|
12
14
|
export type ComboboxItemData = {
|
|
15
|
+
/** Stable identity, reported by `value` / `onValueChange` and submitted with the form. */
|
|
13
16
|
value: string;
|
|
14
17
|
/** Row text and the text the search matches. */
|
|
15
18
|
label: string;
|
|
@@ -19,46 +22,71 @@ export type ComboboxItemData = {
|
|
|
19
22
|
trailing?: ReactNode;
|
|
20
23
|
/** Extra search terms that are not shown, such as `KR` or `Korea`. */
|
|
21
24
|
keywords?: readonly string[];
|
|
25
|
+
/** Dims the row to 40% and makes it unselectable. */
|
|
22
26
|
disabled?: boolean;
|
|
23
27
|
};
|
|
24
28
|
|
|
29
|
+
/** Props shared by both value modes; `multiple` selects the mode in {@link ComboboxProps}. */
|
|
25
30
|
type ComboboxBaseProps = {
|
|
31
|
+
/** Options in list order, in the shape of {@link ComboboxItemData}. */
|
|
26
32
|
items: readonly ComboboxItemData[];
|
|
33
|
+
/** Text while nothing is chosen, and the field's `aria-label` in the `field` variant. @default "Search" */
|
|
27
34
|
placeholder?: string;
|
|
28
|
-
/** Placeholder of the search box inside the popup (`segment` variant). */
|
|
35
|
+
/** Placeholder of the search box inside the popup (`segment` variant). @default "Search" */
|
|
29
36
|
searchPlaceholder?: string;
|
|
30
|
-
/** Shown in the popup when nothing matches the search. */
|
|
37
|
+
/** Shown in the popup when nothing matches the search. @default "No results" */
|
|
31
38
|
emptyLabel?: ReactNode;
|
|
39
|
+
/** Rung of the field, rows and chips. @default "md" */
|
|
32
40
|
size?: ComboboxSize;
|
|
41
|
+
/** Surface of the field; the popup follows it. @default "solid" */
|
|
33
42
|
surface?: InputSurface;
|
|
34
43
|
/**
|
|
35
44
|
* `field` is a searchable field (the default). `segment` is the tinted prefix or suffix of an
|
|
36
45
|
* `InputGroup`: a button that opens a popup with the search box on top, taking the group's size.
|
|
46
|
+
* @default "field"
|
|
37
47
|
*/
|
|
38
48
|
variant?: "field" | "segment";
|
|
49
|
+
/** Turns the field or chips border danger red and sets `aria-invalid`; a `segment` trigger gets neither, because the wrapping `InputGroup` owns that border. */
|
|
39
50
|
invalid?: boolean;
|
|
51
|
+
/** Blocks the field; in a `segment` it also inherits `disabled` from the wrapping `InputGroup`. */
|
|
40
52
|
disabled?: boolean;
|
|
41
53
|
/** Form field name; the submitted value is the item `value`. */
|
|
42
54
|
name?: string;
|
|
55
|
+
/** Extra classes on the field or trigger, merged after the surface and size classes. */
|
|
43
56
|
className?: string;
|
|
57
|
+
/** Accessible name of the text field or segment trigger; the placeholder covers it in the `field` variant. */
|
|
44
58
|
"aria-label"?: string;
|
|
45
59
|
};
|
|
46
60
|
|
|
61
|
+
/** Single-select combobox: `value` / `onValueChange` carry one item `value` or `null`. */
|
|
47
62
|
export type ComboboxSingleProps = ComboboxBaseProps & {
|
|
63
|
+
/** Single-select mode; the default when the prop is omitted. */
|
|
48
64
|
multiple?: false;
|
|
65
|
+
/** Controlled choice, as an item `value`; `null` means nothing is chosen. */
|
|
49
66
|
value?: string | null;
|
|
67
|
+
/** Starting choice of the uncontrolled field. */
|
|
50
68
|
defaultValue?: string | null;
|
|
69
|
+
/** Fires with the picked item `value`, or `null` when the field is cleared. */
|
|
51
70
|
onValueChange?: (value: string | null) => void;
|
|
52
71
|
};
|
|
53
72
|
|
|
73
|
+
/** Multi-select combobox: the chosen items show as removable chips and the value is an array of item `value`s. */
|
|
54
74
|
export type ComboboxMultipleProps = ComboboxBaseProps & {
|
|
55
75
|
/** Chosen items show as removable chips in the field. */
|
|
56
76
|
multiple: true;
|
|
77
|
+
/** Controlled selection, in the order chosen. */
|
|
57
78
|
value?: readonly string[];
|
|
79
|
+
/** Starting selection of the uncontrolled field. */
|
|
58
80
|
defaultValue?: readonly string[];
|
|
81
|
+
/** Fires with the full next selection as item `value`s, in the order chosen. */
|
|
59
82
|
onValueChange?: (value: string[]) => void;
|
|
60
83
|
};
|
|
61
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Props for {@link Combobox}, a discriminated union on `multiple`: without it the field is single-select
|
|
87
|
+
* and its value is `string | null`; with `multiple: true` it is multi-select and its value is `readonly string[]`.
|
|
88
|
+
* Narrow on `props.multiple` before reading `value` or `onValueChange`.
|
|
89
|
+
*/
|
|
62
90
|
export type ComboboxProps = ComboboxSingleProps | ComboboxMultipleProps;
|
|
63
91
|
|
|
64
92
|
const itemClass: Record<ComboboxSize, string> = {
|
|
@@ -96,6 +124,28 @@ const shortLabel = (item: ComboboxItemData) => item.selectedLabel ?? item.label;
|
|
|
96
124
|
* `multiple`, several items shown as chips. The popup matches `Select`: the veil, rows with
|
|
97
125
|
* a check. `variant="segment"` puts it in an `InputGroup`, such as a country code before a
|
|
98
126
|
* phone number.
|
|
127
|
+
*
|
|
128
|
+
* Filtering is a case-insensitive substring match over each item's `label`, `value` and `keywords`,
|
|
129
|
+
* with the query trimmed first; a blank query keeps every item. The chosen item's `selectedLabel`
|
|
130
|
+
* (falling back to `label`) is what the field shows, while the form and `onValueChange` carry `value`.
|
|
131
|
+
* The popup portals to the body, opens 4px below the field and is at least as wide as it; the list scrolls
|
|
132
|
+
* past 256px and the panel caps at 320px. In `segment` form the popup is a 256px column with its own search
|
|
133
|
+
* box on top; on `multiple` the field grows and wraps as chips fill it instead of fixing its height.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```tsx
|
|
137
|
+
* const [country, setCountry] = useState<string | null>("+82");
|
|
138
|
+
*
|
|
139
|
+
* <Combobox
|
|
140
|
+
* aria-label="Country code"
|
|
141
|
+
* value={country}
|
|
142
|
+
* onValueChange={setCountry}
|
|
143
|
+
* items={[
|
|
144
|
+
* { value: "+82", label: "+82 South Korea", keywords: ["KR", "Korea"] },
|
|
145
|
+
* { value: "+1", label: "+1 United States", keywords: ["US"] },
|
|
146
|
+
* ]}
|
|
147
|
+
* />
|
|
148
|
+
* ```
|
|
99
149
|
*/
|
|
100
150
|
export function Combobox(props: ComboboxProps) {
|
|
101
151
|
const {
|
|
@@ -11,9 +11,13 @@ import { Kbd } from "./kbd";
|
|
|
11
11
|
const touchCloseClass =
|
|
12
12
|
"flex size-7 shrink-0 motion-press cursor-pointer items-center justify-center rounded-full text-text-secondary hover:bg-overlay-ink-6 hover:text-text-primary focus-visible:outline-2 focus-visible:outline-text-brand [&_svg]:size-4";
|
|
13
13
|
|
|
14
|
+
/** One selectable row of the palette. */
|
|
14
15
|
export type CommandItem = {
|
|
16
|
+
/** Stable identity and the React key of the row; keep it unique across the palette. */
|
|
15
17
|
value: string;
|
|
18
|
+
/** Row text; the query also matches it, together with `keywords`. */
|
|
16
19
|
label: string;
|
|
20
|
+
/** Extra search terms that are not shown, such as an abbreviation or a path. */
|
|
17
21
|
keywords?: string;
|
|
18
22
|
/** 28px leading tile: an initial or a 16px icon. */
|
|
19
23
|
tile?: ReactNode;
|
|
@@ -23,31 +27,76 @@ export type CommandItem = {
|
|
|
23
27
|
meta?: ReactNode;
|
|
24
28
|
/** Right-side hint, usually `<Kbd>`; hidden when the device shows no keyboard hints. */
|
|
25
29
|
hint?: ReactNode;
|
|
30
|
+
/** Runs when the row is clicked, before the palette closes itself. */
|
|
26
31
|
onSelect?: () => void;
|
|
27
32
|
};
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
/** A titled block of rows; groups are rendered in the order given. */
|
|
35
|
+
export type CommandGroup = {
|
|
36
|
+
/** Section heading, `caption` secondary text above the rows. */
|
|
37
|
+
label: string;
|
|
38
|
+
/** Rows of this section. */
|
|
39
|
+
items: CommandItem[];
|
|
40
|
+
};
|
|
30
41
|
|
|
42
|
+
/** Props for {@link CommandPalette}: the dialog state, the grouped rows and the footer hints. */
|
|
31
43
|
export type CommandPaletteProps = {
|
|
44
|
+
/** Controlled open state; leave it out to let the palette open from its `trigger`. */
|
|
32
45
|
open?: boolean;
|
|
46
|
+
/** Called with the next open state when the palette opens, closes on Escape, closes on select or its backdrop is pressed. */
|
|
33
47
|
onOpenChange?: (open: boolean) => void;
|
|
48
|
+
/** Sections of rows, in render order. */
|
|
34
49
|
groups: CommandGroup[];
|
|
50
|
+
/** Search field placeholder; it also names the dialog (`aria-label`). @default "Search" */
|
|
35
51
|
placeholder?: string;
|
|
36
52
|
/** Shown when the query has no matches; defaults to "No results". */
|
|
37
53
|
empty?: ReactNode;
|
|
38
54
|
/** Footer key hints, such as `[["↑↓", "Move"], ["↵", "Open"]]`; hidden when the device shows no keyboard hints. */
|
|
39
55
|
hints?: [ReactNode, string][];
|
|
56
|
+
/** Element rendered inside the dialog root as the opener, usually a `DialogTrigger`. */
|
|
40
57
|
trigger?: ReactNode;
|
|
41
58
|
/**
|
|
42
59
|
* `solid` (default) is an opaque palette with a default border. `glass` puts it on the veil (`veil-overlay`).
|
|
60
|
+
* @default "solid"
|
|
43
61
|
*/
|
|
44
62
|
surface?: "solid" | "glass";
|
|
63
|
+
/** Extra classes on the popup, merged after the surface, radius and motion classes. */
|
|
45
64
|
className?: string;
|
|
46
65
|
};
|
|
47
66
|
|
|
48
67
|
/**
|
|
49
68
|
* Figma `Command palette` (110:676): a 560px palette, 24px radius, with a 48px search row,
|
|
50
69
|
* grouped 44px results and a key-hint footer.
|
|
70
|
+
*
|
|
71
|
+
* A Base UI dialog on a 32% scrim with a 6px blur, anchored to the top of the viewport 96px down rather
|
|
72
|
+
* than centred. It always renders {@link CommandPaletteBody} with its own close control — an `esc` chip on
|
|
73
|
+
* devices that show keyboard hints, a 28px `X` tile on touch — and every row select reports
|
|
74
|
+
* `onOpenChange(false)`. Row hints and the footer hints disappear on those touch devices too. The body
|
|
75
|
+
* owns filtering and keyboard movement.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* const [open, setOpen] = useState(false);
|
|
80
|
+
*
|
|
81
|
+
* <CommandPalette
|
|
82
|
+
* open={open}
|
|
83
|
+
* onOpenChange={setOpen}
|
|
84
|
+
* trigger={<DialogTrigger render={<Button variant="solid" />}>Search</DialogTrigger>}
|
|
85
|
+
* groups={[
|
|
86
|
+
* {
|
|
87
|
+
* label: "Bots",
|
|
88
|
+
* items: [
|
|
89
|
+
* { value: "weekly", label: "Weekly digest", meta: "Product", hint: <Kbd>↵</Kbd> },
|
|
90
|
+
* { value: "inbox", label: "Inbox triage", meta: "Ops" },
|
|
91
|
+
* ],
|
|
92
|
+
* },
|
|
93
|
+
* ]}
|
|
94
|
+
* hints={[
|
|
95
|
+
* ["↑↓", "Move"],
|
|
96
|
+
* ["↵", "Open"],
|
|
97
|
+
* ]}
|
|
98
|
+
* />
|
|
99
|
+
* ```
|
|
51
100
|
*/
|
|
52
101
|
export function CommandPalette({
|
|
53
102
|
open,
|
|
@@ -108,17 +157,32 @@ export function CommandPalette({
|
|
|
108
157
|
);
|
|
109
158
|
}
|
|
110
159
|
|
|
160
|
+
/** Props for {@link CommandPaletteBody}: the rows plus the close control and the select callback the host owns. */
|
|
111
161
|
export type CommandPaletteBodyProps = {
|
|
162
|
+
/** Sections of rows, in render order. */
|
|
112
163
|
groups: CommandGroup[];
|
|
164
|
+
/** Search field placeholder. @default "Search" */
|
|
113
165
|
placeholder?: string;
|
|
166
|
+
/** Shown when the query has no matches. @default "No results" */
|
|
114
167
|
empty?: ReactNode;
|
|
168
|
+
/** Accessible name of the fallback `esc` button, used when no `closeControl` is passed. @default "Close" */
|
|
115
169
|
closeLabel?: string;
|
|
116
170
|
/** A ready close control; the dialog passes its own `Dialog.Close` so uncontrolled palettes still close. */
|
|
117
171
|
closeControl?: ReactNode;
|
|
172
|
+
/** Makes the fallback `esc` button close the palette; without both this and `closeControl` no button renders. */
|
|
118
173
|
onClose?: () => void;
|
|
174
|
+
/** Called after a row's own `onSelect`, so the host can close its dialog. */
|
|
119
175
|
onSelect?: () => void;
|
|
120
176
|
};
|
|
121
177
|
|
|
178
|
+
/**
|
|
179
|
+
* The search row, groups and result rows of a command palette.
|
|
180
|
+
*
|
|
181
|
+
* Part of {@link CommandPalette}. Renders a Base UI `Autocomplete` that is always open and inline: the
|
|
182
|
+
* query filters on label plus keywords (case-insensitive), the first row is highlighted as soon as the
|
|
183
|
+
* list renders, and arrow keys move through the rows while Enter picks the highlighted one. Escape is left
|
|
184
|
+
* to the host's close control, which is why this part owns no dialog state.
|
|
185
|
+
*/
|
|
122
186
|
export function CommandPaletteBody({
|
|
123
187
|
groups,
|
|
124
188
|
placeholder = "Search",
|
|
@@ -5,21 +5,34 @@ import { cn } from "../lib/cn";
|
|
|
5
5
|
import type { ControlSize } from "../lib/size";
|
|
6
6
|
import { IconButton } from "./icon-button";
|
|
7
7
|
|
|
8
|
+
/** Height and text rung of the composer: `sm` 32px, `md` 40px, `lg` 48px, shared with the other controls. */
|
|
8
9
|
export type ComposerSize = ControlSize;
|
|
10
|
+
/** `solid` is the opaque bordered pill; `glass` is the veil field for imagery and glass panels. */
|
|
9
11
|
export type ComposerSurface = "solid" | "glass";
|
|
10
12
|
|
|
13
|
+
/** Props for {@link Composer}: the message value, the send callback and the two side actions. */
|
|
11
14
|
export type ComposerProps = {
|
|
15
|
+
/** Rung of the field and its icon buttons. @default "md" */
|
|
12
16
|
size?: ComposerSize;
|
|
13
|
-
/** `solid` (default) on raised surfaces, `glass` over imagery and glass panels. */
|
|
17
|
+
/** `solid` (default) on raised surfaces, `glass` over imagery and glass panels. @default "solid" */
|
|
14
18
|
surface?: ComposerSurface;
|
|
19
|
+
/** Field placeholder; it doubles as the `aria-label` because the field has no visible label. @default "Message" */
|
|
15
20
|
placeholder?: string;
|
|
21
|
+
/** Controlled text. Leave it out to let the composer own the value and still report changes. */
|
|
16
22
|
value?: string;
|
|
23
|
+
/** Starting text of the uncontrolled composer. @default "" */
|
|
17
24
|
defaultValue?: string;
|
|
25
|
+
/** Fires on every keystroke with the next full text, controlled or not. */
|
|
18
26
|
onValueChange?: (value: string) => void;
|
|
27
|
+
/** Fires with the full (untrimmed) text when the form submits, from Enter or the send button; whitespace-only text blocks the submit. The field is cleared after. */
|
|
19
28
|
onSubmit?: (value: string) => void;
|
|
29
|
+
/** Fires when the plus button is pressed; the composer itself opens nothing. */
|
|
20
30
|
onAttach?: () => void;
|
|
31
|
+
/** Fires when the microphone button is pressed, i.e. while the field is empty. */
|
|
21
32
|
onVoice?: () => void;
|
|
33
|
+
/** Disables the field and both icon buttons without changing the layout. */
|
|
22
34
|
disabled?: boolean;
|
|
35
|
+
/** Extra classes on the form, merged after the surface and size classes. */
|
|
23
36
|
className?: string;
|
|
24
37
|
};
|
|
25
38
|
|
|
@@ -39,6 +52,20 @@ const textClass: Record<ComposerSize, string> = {
|
|
|
39
52
|
* Figma `Composer` (63:462): a regular-glass pill with an attach button, the
|
|
40
53
|
* message field, and a voice button that turns into the ink send button once
|
|
41
54
|
* there is text.
|
|
55
|
+
*
|
|
56
|
+
* A real `form`, so Enter submits and the browser handles implicit submission; a value that is only
|
|
57
|
+
* whitespace blocks the send and leaves the typed text in place. The last slot swaps between the voice
|
|
58
|
+
* button (empty field) and the primary send button (`motion-swap`), and only the visible one is focusable.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* <Composer
|
|
63
|
+
* placeholder="Ask anything"
|
|
64
|
+
* onAttach={() => openFilePicker()}
|
|
65
|
+
* onVoice={() => startDictation()}
|
|
66
|
+
* onSubmit={(text) => sendMessage(text)}
|
|
67
|
+
* />
|
|
68
|
+
* ```
|
|
42
69
|
*/
|
|
43
70
|
export function Composer({
|
|
44
71
|
size = "md",
|