@sixb/app 0.1.17 → 0.1.18
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/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/bash/interpret.d.ts +6 -2
- package/dist/agent/bash/interpret.d.ts.map +1 -1
- package/dist/agent/components/approval-mode-icons.d.ts +5 -0
- package/dist/agent/components/approval-mode-icons.d.ts.map +1 -0
- package/dist/agent/components/composer-add-menu.d.ts +15 -0
- package/dist/agent/components/composer-add-menu.d.ts.map +1 -0
- package/dist/agent/components/composer-commands.d.ts +37 -0
- package/dist/agent/components/composer-commands.d.ts.map +1 -0
- package/dist/agent/components/composer-menu.d.ts +18 -15
- package/dist/agent/components/composer-menu.d.ts.map +1 -1
- package/dist/agent/components/composer-settings.d.ts +34 -0
- package/dist/agent/components/composer-settings.d.ts.map +1 -0
- package/dist/agent/components/composer.d.ts +10 -3
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-chips.d.ts +5 -0
- package/dist/agent/components/context-chips.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +3 -1
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/dictation-bar.d.ts +7 -3
- package/dist/agent/components/dictation-bar.d.ts.map +1 -1
- package/dist/agent/components/model-picker-row.d.ts +1 -3
- package/dist/agent/components/model-picker-row.d.ts.map +1 -1
- package/dist/agent/components/reasoning-effort-slider.d.ts.map +1 -1
- package/dist/agent/components/shared-thread-notice.d.ts +4 -2
- package/dist/agent/components/shared-thread-notice.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/hooks/use-agent-conversation.d.ts +2 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts +8 -0
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +69 -8
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +126 -12
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/model-selection.d.ts +1 -0
- package/dist/agent/model-selection.d.ts.map +1 -1
- package/dist/agent/run-sounds.d.ts +18 -0
- package/dist/agent/run-sounds.d.ts.map +1 -0
- package/dist/chunk-6n5pdqp0.js.map +1 -1
- package/dist/{chunk-12v6y89k.js → chunk-btky7c9w.js} +11678 -11190
- package/dist/{chunk-12v6y89k.js.map → chunk-btky7c9w.js.map} +59 -57
- package/dist/{chunk-bpj9mg5c.js → chunk-gq6xek89.js} +1 -1
- package/dist/{chunk-bpj9mg5c.js.map → chunk-gq6xek89.js.map} +1 -1
- package/dist/{chunk-hzy2g13h.js → chunk-hdbmj6f0.js} +1 -1
- package/dist/{chunk-hzy2g13h.js.map → chunk-hdbmj6f0.js.map} +1 -1
- package/dist/chunk-md3p7qdt.js.map +1 -1
- package/dist/{chunk-2a69ge8h.js → chunk-pkcm8rn8.js} +1 -1
- package/dist/{chunk-2a69ge8h.js.map → chunk-pkcm8rn8.js.map} +1 -1
- package/dist/chunk-yvhzn4ye.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +3 -3
- package/dist/pages/settings/messages.d.ts +16 -0
- package/dist/pages/settings/messages.d.ts.map +1 -1
- package/dist/pages/settings/personal.d.ts +2 -2
- package/dist/pages/settings/personal.d.ts.map +1 -1
- package/dist/pages.js +49 -3
- package/dist/pages.js.map +4 -4
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
- package/src/agent/agent-chat.tsx +6 -1
- package/src/agent/agent.css +145 -14
- package/src/agent/bash/interpret.ts +41 -5
- package/src/agent/components/approval-mode-icons.ts +9 -0
- package/src/agent/components/composer-add-menu.tsx +126 -0
- package/src/agent/components/composer-commands.tsx +165 -0
- package/src/agent/components/composer-menu.tsx +33 -46
- package/src/agent/components/composer-settings.tsx +437 -0
- package/src/agent/components/composer.tsx +312 -153
- package/src/agent/components/context-chips.tsx +21 -8
- package/src/agent/components/conversation-panel.tsx +16 -9
- package/src/agent/components/dictation-bar.tsx +28 -23
- package/src/agent/components/model-picker-row.tsx +14 -24
- package/src/agent/components/reasoning-effort-slider.tsx +14 -10
- package/src/agent/components/shared-thread-notice.tsx +7 -2
- package/src/agent/components/transcript.tsx +2 -1
- package/src/agent/hooks/use-agent-conversation.ts +18 -6
- package/src/agent/i18n/en.ts +58 -15
- package/src/agent/i18n/fr.ts +77 -13
- package/src/agent/model-selection.ts +4 -0
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +3 -2
- package/src/agent/run-sounds.ts +171 -0
- package/src/index.ts +5 -1
- package/src/pages/settings/messages.ts +8 -0
- package/src/pages/settings/personal.tsx +60 -3
- package/dist/agent/components/approval-mode-chip.d.ts +0 -15
- package/dist/agent/components/approval-mode-chip.d.ts.map +0 -1
- package/dist/agent/components/auto-model-chip.d.ts +0 -23
- package/dist/agent/components/auto-model-chip.d.ts.map +0 -1
- package/dist/agent/components/model-controls.d.ts +0 -41
- package/dist/agent/components/model-controls.d.ts.map +0 -1
- package/src/agent/components/approval-mode-chip.tsx +0 -120
- package/src/agent/components/auto-model-chip.tsx +0 -219
- package/src/agent/components/model-controls.tsx +0 -238
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Hand, type LucideIcon, PencilLine, Zap } from "lucide-react"
|
|
2
|
+
import type { AgentApprovalMode } from "../approvals"
|
|
3
|
+
|
|
4
|
+
/** Each approval mode's icon, in the composer's permissions and in Settings. */
|
|
5
|
+
export const APPROVAL_MODE_ICONS: Readonly<Record<AgentApprovalMode, LucideIcon>> = {
|
|
6
|
+
manual: Hand,
|
|
7
|
+
"accept-edits": PencilLine,
|
|
8
|
+
auto: Zap,
|
|
9
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
2
|
+
import { AtSign, type LucideIcon, Paperclip, Plus, Slash } from "lucide-react"
|
|
3
|
+
import { useRef, useState } from "react"
|
|
4
|
+
import { useAgentMessages } from "../i18n"
|
|
5
|
+
import { COMPOSER_MENU_ROW_CLASS_NAME, ComposerMenu } from "./composer-menu"
|
|
6
|
+
|
|
7
|
+
export interface ComposerAddMenuProps {
|
|
8
|
+
readonly onAddFiles?: () => void
|
|
9
|
+
/** Starts an `@` mention at the caret, which opens the context picker. */
|
|
10
|
+
readonly onMention: () => void
|
|
11
|
+
/** Starts a slash command; omitted while the message has text. */
|
|
12
|
+
readonly onCommand?: () => void
|
|
13
|
+
readonly disabled?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The composer's `+`: what a message can carry besides its text. It turns into × while open. */
|
|
17
|
+
export function ComposerAddMenu({
|
|
18
|
+
onAddFiles,
|
|
19
|
+
onMention,
|
|
20
|
+
onCommand,
|
|
21
|
+
disabled,
|
|
22
|
+
}: ComposerAddMenuProps) {
|
|
23
|
+
const messages = useAgentMessages().composer
|
|
24
|
+
const [open, setOpen] = useState(false)
|
|
25
|
+
// A choice that types into the message keeps the focus there, not on `+`.
|
|
26
|
+
const typing = useRef(false)
|
|
27
|
+
|
|
28
|
+
const choose = (action: () => void, types: boolean) => () => {
|
|
29
|
+
typing.current = types
|
|
30
|
+
setOpen(false)
|
|
31
|
+
action()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<ComposerMenu
|
|
36
|
+
open={open}
|
|
37
|
+
onOpenChange={setOpen}
|
|
38
|
+
title={messages.add}
|
|
39
|
+
align="start"
|
|
40
|
+
className="w-[16.5rem]"
|
|
41
|
+
onCloseAutoFocus={(event) => {
|
|
42
|
+
if (!typing.current) return
|
|
43
|
+
typing.current = false
|
|
44
|
+
event.preventDefault()
|
|
45
|
+
}}
|
|
46
|
+
trigger={
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
aria-label={messages.add}
|
|
51
|
+
aria-haspopup="menu"
|
|
52
|
+
aria-expanded={open}
|
|
53
|
+
className="flex size-[38px] shrink-0 items-center justify-center self-end rounded-full bg-black/[0.05] text-foreground/80 outline-none transition-[background-color,transform] duration-200 ease-[cubic-bezier(.2,.8,.2,1)] hover:bg-black/[0.08] focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 aria-expanded:rotate-45 aria-expanded:bg-black/[0.08] dark:bg-white/[0.1] dark:hover:bg-white/[0.14] dark:aria-expanded:bg-white/[0.14] mb-px"
|
|
54
|
+
>
|
|
55
|
+
<Plus className="size-[18px]" strokeWidth={2} aria-hidden="true" />
|
|
56
|
+
</button>
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
<div role="menu" aria-label={messages.add} className="flex flex-col gap-px">
|
|
60
|
+
{onAddFiles ? (
|
|
61
|
+
<AddMenuItem
|
|
62
|
+
icon={Paperclip}
|
|
63
|
+
label={messages.addFiles}
|
|
64
|
+
onSelect={choose(onAddFiles, false)}
|
|
65
|
+
/>
|
|
66
|
+
) : null}
|
|
67
|
+
<AddMenuItem
|
|
68
|
+
icon={AtSign}
|
|
69
|
+
label={messages.mention}
|
|
70
|
+
shortcut="@"
|
|
71
|
+
onSelect={choose(onMention, true)}
|
|
72
|
+
/>
|
|
73
|
+
{onCommand ? (
|
|
74
|
+
<AddMenuItem
|
|
75
|
+
icon={Slash}
|
|
76
|
+
label={messages.commands}
|
|
77
|
+
shortcut="/"
|
|
78
|
+
onSelect={choose(onCommand, true)}
|
|
79
|
+
/>
|
|
80
|
+
) : null}
|
|
81
|
+
</div>
|
|
82
|
+
</ComposerMenu>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function AddMenuItem({
|
|
87
|
+
icon: Icon,
|
|
88
|
+
label,
|
|
89
|
+
shortcut,
|
|
90
|
+
onSelect,
|
|
91
|
+
}: {
|
|
92
|
+
readonly icon: LucideIcon
|
|
93
|
+
readonly label: string
|
|
94
|
+
/** The character that does the same from the message. */
|
|
95
|
+
readonly shortcut?: string
|
|
96
|
+
readonly onSelect: () => void
|
|
97
|
+
}) {
|
|
98
|
+
return (
|
|
99
|
+
<button
|
|
100
|
+
type="button"
|
|
101
|
+
role="menuitem"
|
|
102
|
+
onClick={onSelect}
|
|
103
|
+
className={cn(COMPOSER_MENU_ROW_CLASS_NAME, "min-h-10 gap-3")}
|
|
104
|
+
>
|
|
105
|
+
<Icon
|
|
106
|
+
className="size-[18px] shrink-0 text-foreground/75"
|
|
107
|
+
strokeWidth={1.75}
|
|
108
|
+
aria-hidden="true"
|
|
109
|
+
/>
|
|
110
|
+
<span className="min-w-0 flex-1 truncate text-foreground">{label}</span>
|
|
111
|
+
{shortcut ? <ComposerKey>{shortcut}</ComposerKey> : null}
|
|
112
|
+
</button>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** A keycap, for the character or key that does the same from the keyboard. */
|
|
117
|
+
export function ComposerKey({ children }: { readonly children: string }) {
|
|
118
|
+
return (
|
|
119
|
+
<kbd
|
|
120
|
+
aria-hidden="true"
|
|
121
|
+
className="inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-md bg-background px-[5px] font-sans text-[11px] text-foreground/75 shadow-[0_0_0_0.5px_rgb(0_0_0/0.16),0_1px_0_rgb(0_0_0/0.08)] dark:bg-white/[0.1] dark:shadow-[0_0_0_0.5px_rgb(255_255_255/0.16)]"
|
|
122
|
+
>
|
|
123
|
+
{children}
|
|
124
|
+
</kbd>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
2
|
+
import { AGENT_APPROVAL_MODES, type AgentApprovalMode } from "../approvals"
|
|
3
|
+
import { useAgentMessages } from "../i18n"
|
|
4
|
+
import type { AgentMessages } from "../i18n/en"
|
|
5
|
+
import { hasTiers } from "../model-selection"
|
|
6
|
+
import type { LanguageModel } from "../types"
|
|
7
|
+
import { ComposerKey } from "./composer-add-menu"
|
|
8
|
+
import {
|
|
9
|
+
COMPOSER_MENU_ROW_CLASS_NAME,
|
|
10
|
+
COMPOSER_MENU_ROW_SELECTED_CLASS_NAME,
|
|
11
|
+
} from "./composer-menu"
|
|
12
|
+
|
|
13
|
+
/** A slash command: typed as the whole message, `/name`, and run with Enter. */
|
|
14
|
+
export interface ComposerCommand {
|
|
15
|
+
/** What follows the slash, lowercase and without spaces: `opus` for `/opus`. */
|
|
16
|
+
readonly name: string
|
|
17
|
+
/** What it does, as the list shows it. */
|
|
18
|
+
readonly label: string
|
|
19
|
+
readonly run: () => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The command being typed, without its slash; `null` unless the message is one slash word. */
|
|
23
|
+
export function commandQuery(value: string): string | null {
|
|
24
|
+
const match = /^\/([^\s/]*)$/.exec(value)
|
|
25
|
+
return match ? (match[1] ?? "").toLowerCase() : null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The commands a query names or describes, those whose name starts with it first. */
|
|
29
|
+
export function matchCommands(
|
|
30
|
+
commands: readonly ComposerCommand[],
|
|
31
|
+
query: string
|
|
32
|
+
): readonly ComposerCommand[] {
|
|
33
|
+
const named = commands.filter((command) => command.name.startsWith(query))
|
|
34
|
+
const rest = commands.filter(
|
|
35
|
+
(command) =>
|
|
36
|
+
!named.includes(command) &&
|
|
37
|
+
(command.name.includes(query) || command.label.toLowerCase().includes(query))
|
|
38
|
+
)
|
|
39
|
+
return [...named, ...rest]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The permission modes by the word a command uses for each. */
|
|
43
|
+
const MODE_COMMANDS: Readonly<Record<AgentApprovalMode, string>> = {
|
|
44
|
+
manual: "ask",
|
|
45
|
+
"accept-edits": "edits",
|
|
46
|
+
auto: "full",
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The commands the composer offers on its own: `/auto` with tiers, one per model, and one per
|
|
51
|
+
* permission mode. Each exists only when the composer can make that change.
|
|
52
|
+
*/
|
|
53
|
+
export function builtInCommands({
|
|
54
|
+
models,
|
|
55
|
+
onSelectModel,
|
|
56
|
+
onResetModelSelection,
|
|
57
|
+
onApprovalModeChange,
|
|
58
|
+
messages,
|
|
59
|
+
}: {
|
|
60
|
+
readonly models: readonly LanguageModel[]
|
|
61
|
+
readonly onSelectModel?: (model: LanguageModel) => void
|
|
62
|
+
readonly onResetModelSelection?: () => void
|
|
63
|
+
readonly onApprovalModeChange?: (mode: AgentApprovalMode) => void
|
|
64
|
+
readonly messages: AgentMessages["commands"]
|
|
65
|
+
}): ComposerCommand[] {
|
|
66
|
+
const commands: ComposerCommand[] = []
|
|
67
|
+
if (onResetModelSelection && hasTiers(models)) {
|
|
68
|
+
commands.push({ name: "auto", label: messages.auto, run: onResetModelSelection })
|
|
69
|
+
}
|
|
70
|
+
if (onSelectModel) {
|
|
71
|
+
for (const model of models) {
|
|
72
|
+
commands.push({
|
|
73
|
+
name: commandName(model.name),
|
|
74
|
+
label: messages.model(model.name),
|
|
75
|
+
run: () => onSelectModel(model),
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (onApprovalModeChange) {
|
|
80
|
+
for (const mode of AGENT_APPROVAL_MODES) {
|
|
81
|
+
commands.push({
|
|
82
|
+
name: MODE_COMMANDS[mode],
|
|
83
|
+
label: messages.modes[mode],
|
|
84
|
+
run: () => onApprovalModeChange(mode),
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return commands
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** `Claude Opus 5.5` → `claude-opus-5-5`. */
|
|
92
|
+
function commandName(name: string): string {
|
|
93
|
+
return name
|
|
94
|
+
.toLowerCase()
|
|
95
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
96
|
+
.replace(/^-|-$/g, "")
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface ComposerCommandListProps {
|
|
100
|
+
readonly open: boolean
|
|
101
|
+
readonly query: string
|
|
102
|
+
readonly commands: readonly ComposerCommand[]
|
|
103
|
+
readonly activeIndex: number
|
|
104
|
+
readonly onActiveIndexChange: (index: number) => void
|
|
105
|
+
readonly onRun: (command: ComposerCommand) => void
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The commands matching what is typed, over the composer; Enter runs the highlighted one. */
|
|
109
|
+
export function ComposerCommandList({
|
|
110
|
+
open,
|
|
111
|
+
query,
|
|
112
|
+
commands,
|
|
113
|
+
activeIndex,
|
|
114
|
+
onActiveIndexChange,
|
|
115
|
+
onRun,
|
|
116
|
+
}: ComposerCommandListProps) {
|
|
117
|
+
const messages = useAgentMessages().commands
|
|
118
|
+
if (!open) return null
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div
|
|
122
|
+
role="listbox"
|
|
123
|
+
aria-label={messages.list}
|
|
124
|
+
className="sixb-composer-glass absolute bottom-[calc(100%+0.625rem)] left-0 z-20 flex w-[21.25rem] max-w-full flex-col gap-px rounded-[20px] p-1.5"
|
|
125
|
+
>
|
|
126
|
+
{commands.slice(0, 6).map((command, index) => {
|
|
127
|
+
const active = index === activeIndex
|
|
128
|
+
const at = command.name.indexOf(query)
|
|
129
|
+
return (
|
|
130
|
+
<button
|
|
131
|
+
key={`${command.name}:${index}`}
|
|
132
|
+
type="button"
|
|
133
|
+
role="option"
|
|
134
|
+
aria-selected={active}
|
|
135
|
+
onPointerEnter={() => onActiveIndexChange(index)}
|
|
136
|
+
// Keep the focus in the message while choosing.
|
|
137
|
+
onPointerDown={(event) => event.preventDefault()}
|
|
138
|
+
onClick={() => onRun(command)}
|
|
139
|
+
className={cn(
|
|
140
|
+
COMPOSER_MENU_ROW_CLASS_NAME,
|
|
141
|
+
active && COMPOSER_MENU_ROW_SELECTED_CLASS_NAME
|
|
142
|
+
)}
|
|
143
|
+
>
|
|
144
|
+
<span className="min-w-[62px] shrink-0 font-mono text-[12.5px] text-foreground">
|
|
145
|
+
/
|
|
146
|
+
{query && at >= 0 ? (
|
|
147
|
+
<>
|
|
148
|
+
{command.name.slice(0, at)}
|
|
149
|
+
<mark className="rounded-[3px] bg-black/[0.08] text-inherit dark:bg-white/[0.14]">
|
|
150
|
+
{command.name.slice(at, at + query.length)}
|
|
151
|
+
</mark>
|
|
152
|
+
{command.name.slice(at + query.length)}
|
|
153
|
+
</>
|
|
154
|
+
) : (
|
|
155
|
+
command.name
|
|
156
|
+
)}
|
|
157
|
+
</span>
|
|
158
|
+
<span className="min-w-0 flex-1 truncate text-foreground/75">{command.label}</span>
|
|
159
|
+
{active ? <ComposerKey>↩</ComposerKey> : null}
|
|
160
|
+
</button>
|
|
161
|
+
)
|
|
162
|
+
})}
|
|
163
|
+
</div>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
@@ -10,35 +10,28 @@ import {
|
|
|
10
10
|
} from "@sixb/ui/components"
|
|
11
11
|
import { useIsMobile } from "@sixb/ui/hooks"
|
|
12
12
|
import { cn } from "@sixb/ui/lib/utils"
|
|
13
|
-
import { Check } from "lucide-react"
|
|
14
13
|
import { type ReactNode, useEffect, useRef } from "react"
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
|
-
* The anatomy the composer's menus share (
|
|
18
|
-
*
|
|
16
|
+
* The anatomy the composer's menus share (`+`, the model and permissions): frosted glass, rows of
|
|
17
|
+
* an icon and a title, the choice marked by a resting highlight rather than a check.
|
|
19
18
|
*/
|
|
20
|
-
const COMPOSER_MENU_CLASS_NAME =
|
|
21
|
-
"w-[19rem] max-w-[calc(100vw-1rem)] overflow-hidden rounded-[18px] border-black/[0.06] p-0 shadow-[0_18px_50px_-18px_rgb(0_0_0/0.28),0_2px_8px_-2px_rgb(0_0_0/0.06)] dark:border-white/[0.08] dark:shadow-[0_18px_50px_-18px_rgb(0_0_0/0.8)]"
|
|
22
|
-
|
|
23
19
|
export const COMPOSER_MENU_ROW_CLASS_NAME =
|
|
24
|
-
"flex w-full min-w-0 items-center gap-
|
|
25
|
-
|
|
26
|
-
/** A composer control that opens one of these menus: quiet medium text, filled while open. */
|
|
27
|
-
export const COMPOSER_TRIGGER_CLASS_NAME = cn(
|
|
28
|
-
"flex h-8 min-w-0 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium text-muted-foreground outline-none transition-colors",
|
|
29
|
-
"hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40",
|
|
30
|
-
"disabled:cursor-default disabled:opacity-60 aria-expanded:bg-muted/60 aria-expanded:text-foreground"
|
|
31
|
-
)
|
|
20
|
+
"flex w-full min-w-0 items-center gap-[11px] rounded-xl px-2.5 py-1.5 min-h-9 text-left text-[13.5px] tracking-[-0.005em] outline-none transition-colors duration-100 hover:bg-black/[0.04] focus-visible:bg-black/[0.04] disabled:opacity-50 dark:hover:bg-white/[0.07] dark:focus-visible:bg-white/[0.07]"
|
|
32
21
|
|
|
33
|
-
/** The chosen row's resting highlight
|
|
34
|
-
export const COMPOSER_MENU_ROW_SELECTED_CLASS_NAME = "bg-black/[0.
|
|
22
|
+
/** The chosen row's resting highlight. */
|
|
23
|
+
export const COMPOSER_MENU_ROW_SELECTED_CLASS_NAME = "bg-black/[0.05] dark:bg-white/[0.08]"
|
|
35
24
|
|
|
36
|
-
/**
|
|
25
|
+
/** A section under a menu's list, set off by a hairline: the permissions. */
|
|
37
26
|
export const COMPOSER_MENU_SECTION_CLASS_NAME =
|
|
38
|
-
"shrink-0 border-t border-black/[0.
|
|
27
|
+
"shrink-0 border-t-[0.5px] border-black/[0.08] px-4 pt-3 pb-3.5 dark:border-white/[0.08]"
|
|
39
28
|
|
|
40
29
|
export function ComposerMenuHeader({ children }: { readonly children: ReactNode }) {
|
|
41
|
-
return
|
|
30
|
+
return (
|
|
31
|
+
<div className="px-2.5 pt-1.5 pb-1 text-[11.5px] font-medium text-muted-foreground">
|
|
32
|
+
{children}
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
42
35
|
}
|
|
43
36
|
|
|
44
37
|
/** A row's title, the choice in medium weight, over a line that says what it does. */
|
|
@@ -46,47 +39,38 @@ export function ComposerMenuRowText({
|
|
|
46
39
|
title,
|
|
47
40
|
description,
|
|
48
41
|
descriptionId,
|
|
49
|
-
selected = false,
|
|
50
42
|
}: {
|
|
51
43
|
readonly title: string
|
|
52
44
|
readonly description: string
|
|
53
45
|
readonly descriptionId: string
|
|
54
|
-
readonly selected: boolean
|
|
55
46
|
}) {
|
|
56
47
|
return (
|
|
57
|
-
<span className="min-w-0 flex-1">
|
|
58
|
-
<span
|
|
59
|
-
|
|
60
|
-
"block break-words text-[13.5px] tracking-[-0.005em] text-foreground",
|
|
61
|
-
selected && "font-medium"
|
|
62
|
-
)}
|
|
63
|
-
>
|
|
64
|
-
{title}
|
|
65
|
-
</span>
|
|
66
|
-
<span id={descriptionId} className="block text-xs leading-snug text-muted-foreground">
|
|
48
|
+
<span className="flex min-w-0 flex-1 flex-col gap-px">
|
|
49
|
+
<span className="break-words font-medium text-foreground">{title}</span>
|
|
50
|
+
<span id={descriptionId} className="text-xs leading-4 text-muted-foreground">
|
|
67
51
|
{description}
|
|
68
52
|
</span>
|
|
69
53
|
</span>
|
|
70
54
|
)
|
|
71
55
|
}
|
|
72
56
|
|
|
73
|
-
|
|
57
|
+
/** A hairline between a menu's groups; `strong` sets off a choice from the list after it. */
|
|
58
|
+
export function ComposerMenuDivider({ strong = false }: { readonly strong?: boolean }) {
|
|
74
59
|
return (
|
|
75
|
-
<
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
<div
|
|
61
|
+
className={cn(
|
|
62
|
+
"mx-2.5 h-[0.5px]",
|
|
63
|
+
strong
|
|
64
|
+
? "my-1.5 bg-black/[0.09] dark:bg-white/[0.12]"
|
|
65
|
+
: "my-[3px] bg-black/[0.05] dark:bg-white/[0.08]"
|
|
66
|
+
)}
|
|
67
|
+
/>
|
|
80
68
|
)
|
|
81
69
|
}
|
|
82
70
|
|
|
83
|
-
export function ComposerMenuDivider() {
|
|
84
|
-
return <div className="mx-2.5 my-1 h-px bg-border/70" />
|
|
85
|
-
}
|
|
86
|
-
|
|
87
71
|
/**
|
|
88
|
-
* A composer menu
|
|
89
|
-
* opens it.
|
|
72
|
+
* A composer menu on frosted glass beside its trigger, or a bottom sheet on a phone. `trigger` is
|
|
73
|
+
* the button that opens it.
|
|
90
74
|
*/
|
|
91
75
|
export function ComposerMenu({
|
|
92
76
|
open,
|
|
@@ -95,6 +79,7 @@ export function ComposerMenu({
|
|
|
95
79
|
title,
|
|
96
80
|
align,
|
|
97
81
|
className,
|
|
82
|
+
onCloseAutoFocus,
|
|
98
83
|
children,
|
|
99
84
|
}: {
|
|
100
85
|
readonly open: boolean
|
|
@@ -104,6 +89,8 @@ export function ComposerMenu({
|
|
|
104
89
|
readonly title: string
|
|
105
90
|
readonly align: "start" | "end"
|
|
106
91
|
readonly className?: string
|
|
92
|
+
/** Where the focus goes once the menu closes; the trigger unless prevented. */
|
|
93
|
+
readonly onCloseAutoFocus?: (event: Event) => void
|
|
107
94
|
readonly children: ReactNode
|
|
108
95
|
}) {
|
|
109
96
|
const mobile = useIsMobile()
|
|
@@ -112,7 +99,7 @@ export function ComposerMenu({
|
|
|
112
99
|
return (
|
|
113
100
|
<Drawer open={open} onOpenChange={onOpenChange}>
|
|
114
101
|
<DrawerTrigger asChild>{trigger}</DrawerTrigger>
|
|
115
|
-
<DrawerContent className="max-h-[85dvh]">
|
|
102
|
+
<DrawerContent className="max-h-[85dvh]" onCloseAutoFocus={onCloseAutoFocus}>
|
|
116
103
|
<DrawerTitle className="sr-only">{title}</DrawerTitle>
|
|
117
104
|
<DrawerDescription className="sr-only">{title}</DrawerDescription>
|
|
118
105
|
<div className="flex min-h-0 flex-col px-2 pt-1 pb-[max(0.75rem,env(safe-area-inset-bottom))]">
|
|
@@ -132,11 +119,11 @@ export function ComposerMenu({
|
|
|
132
119
|
sideOffset={10}
|
|
133
120
|
collisionPadding={12}
|
|
134
121
|
aria-label={title}
|
|
122
|
+
onCloseAutoFocus={onCloseAutoFocus}
|
|
135
123
|
// Capped by the viewport, not Radix's available-height variable: a size that depends on a
|
|
136
124
|
// value Radix rewrites loops its resize observer.
|
|
137
125
|
className={cn(
|
|
138
|
-
|
|
139
|
-
"flex max-h-[min(32rem,calc(100dvh-8rem))] flex-col",
|
|
126
|
+
"sixb-composer-glass flex max-h-[min(34rem,calc(100dvh-8rem))] w-[20rem] max-w-[calc(100vw-1rem)] flex-col overflow-hidden rounded-[20px] border-0 p-1.5",
|
|
140
127
|
className
|
|
141
128
|
)}
|
|
142
129
|
>
|