@opencode/ui 2.2.4 → 2.2.5

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.
@@ -0,0 +1,6 @@
1
+ import { type ComponentProps } from "solid-js";
2
+ import "./menu-scroll.css";
3
+ export declare function MenuScroll(props: Omit<ComponentProps<"div">, "ref" | "onScroll"> & {
4
+ viewportClass?: string;
5
+ viewportRef?: (element: HTMLDivElement) => void;
6
+ }): import("solid-js").JSX.Element;
@@ -35,5 +35,14 @@ export interface LineCommentEditorProps extends Omit<ComponentProps<"div">, "chi
35
35
  /** Submit an empty value too, such as to clear a comment that exists (default: false). Compact empty actions otherwise cancel. */
36
36
  allowEmpty?: boolean;
37
37
  mention?: LineCommentEditorMention;
38
+ /** Compact editor action on Mod+Enter or modifier-click. */
39
+ alternateSubmit?: {
40
+ label: string;
41
+ keys: string[];
42
+ disabled?: boolean;
43
+ onSubmit: (value: string) => void;
44
+ };
45
+ /** Keep the draft read-only and prevent duplicate actions while its submission settles. */
46
+ submitting?: boolean;
38
47
  }
39
48
  export declare function LineCommentEditor(props: LineCommentEditorProps): JSX.Element;
@@ -22,8 +22,10 @@ export interface TextInputProps extends Omit<ComponentProps<"input">, "type"> {
22
22
  numeric?: boolean;
23
23
  /** Error styling for the field and value text. */
24
24
  invalid?: boolean;
25
- /** `base` is 28px tall; `large` is 32px tall. */
26
- appearance?: "base" | "large";
25
+ /** `small` is 24px tall; `base` is 28px tall; `large` is 32px tall. */
26
+ appearance?: "small" | "base" | "large";
27
+ /** Background surface; invisible gains a fill on hover. */
28
+ surface?: "base" | "layer-1" | "invisible";
27
29
  type?: ComponentProps<"input">["type"];
28
30
  }
29
31
  export declare function TextInput(props: TextInputProps): JSX.Element;
@@ -3,5 +3,6 @@ import "./textarea.css";
3
3
  export interface TextareaProps extends ComponentProps<"textarea"> {
4
4
  /** Error styling for the field and value text. */
5
5
  invalid?: boolean;
6
+ surface?: "base" | "layer-1";
6
7
  }
7
8
  export declare function Textarea(props: TextareaProps): import("solid-js").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode/ui",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -288,7 +288,7 @@
288
288
  "dependencies": {
289
289
  "@kitlangton/solid-motion": "0.2.2",
290
290
  "@kobalte/core": "0.13.13",
291
- "@opencode/util": "2.2.4",
291
+ "@opencode/util": "2.2.5",
292
292
  "@pierre/diffs": "1.6.1",
293
293
  "@pierre/highlights": "0.2.0",
294
294
  "@solid-primitives/event-listener": "2.4.6",
@@ -0,0 +1,59 @@
1
+ [data-component="menu-scroll"] {
2
+ position: relative;
3
+ display: flex;
4
+ min-height: 0;
5
+ flex-direction: column;
6
+ overflow: hidden;
7
+ isolation: isolate;
8
+ }
9
+
10
+ [data-slot="menu-scroll-viewport"] {
11
+ min-height: 0;
12
+ overflow-y: auto;
13
+ }
14
+
15
+ [data-slot="menu-scroll-thumb"] {
16
+ display: none;
17
+ }
18
+
19
+ @media (hover: hover) and (pointer: fine) {
20
+ [data-slot="menu-scroll-viewport"] {
21
+ scrollbar-width: none;
22
+ }
23
+
24
+ [data-slot="menu-scroll-viewport"]::-webkit-scrollbar {
25
+ display: none;
26
+ }
27
+
28
+ [data-slot="menu-scroll-thumb"] {
29
+ position: absolute;
30
+ z-index: 1;
31
+ inset-inline-end: 0;
32
+ top: 0;
33
+ display: block;
34
+ width: 8px;
35
+ opacity: 0;
36
+ pointer-events: none;
37
+ touch-action: none;
38
+ user-select: none;
39
+
40
+ &::after {
41
+ position: absolute;
42
+ inset: 0 2px;
43
+ border-radius: 9999px;
44
+ background: var(--v2-border-border-muted);
45
+ content: "";
46
+ }
47
+
48
+ &:hover::after,
49
+ &[data-dragging]::after {
50
+ background: var(--v2-border-border-strong);
51
+ }
52
+ }
53
+
54
+ [data-component="menu-scroll"]:hover > [data-slot="menu-scroll-thumb"],
55
+ [data-slot="menu-scroll-thumb"][data-dragging] {
56
+ opacity: 1;
57
+ pointer-events: auto;
58
+ }
59
+ }
@@ -0,0 +1,84 @@
1
+ import { createResizeObserver } from "@solid-primitives/resize-observer"
2
+ import { onMount, Show, splitProps, type ComponentProps } from "solid-js"
3
+ import { createStore } from "solid-js/store"
4
+ import "./menu-scroll.css"
5
+
6
+ export function MenuScroll(
7
+ props: Omit<ComponentProps<"div">, "ref" | "onScroll"> & {
8
+ viewportClass?: string
9
+ viewportRef?: (element: HTMLDivElement) => void
10
+ },
11
+ ) {
12
+ const [local, rest] = splitProps(props, ["class", "children", "viewportClass", "viewportRef"])
13
+
14
+ const [state, setState] = createStore<{ size: number; start: number; overflow: boolean; grab?: number }>({
15
+ size: 0,
16
+ start: 4,
17
+ overflow: false,
18
+ })
19
+
20
+ let viewport!: HTMLDivElement
21
+
22
+ let content!: HTMLDivElement
23
+
24
+ const measure = () => {
25
+ const track = Math.max(0, viewport.clientHeight - 8)
26
+
27
+ const size = Math.min(track, Math.max(32, (viewport.clientHeight / Math.max(1, viewport.scrollHeight)) * track))
28
+
29
+ const max = viewport.scrollHeight - viewport.clientHeight
30
+
31
+ setState({ size, start: 4 + (max > 0 ? (viewport.scrollTop / max) * (track - size) : 0), overflow: max > 0 })
32
+
33
+ if (max <= 0) setState("grab", undefined)
34
+ }
35
+
36
+ onMount(() => {
37
+ local.viewportRef?.(viewport)
38
+ createResizeObserver([viewport, content], measure)
39
+ })
40
+
41
+ return (
42
+ <div data-component="menu-scroll" class={local.class}>
43
+ <div
44
+ {...rest}
45
+ ref={viewport}
46
+ data-slot="menu-scroll-viewport"
47
+ data-scrollable
48
+ class={local.viewportClass}
49
+ onScroll={measure}
50
+ >
51
+ <div ref={content}>{local.children}</div>
52
+ </div>
53
+ <Show when={state.overflow}>
54
+ <div
55
+ data-slot="menu-scroll-thumb"
56
+ data-dragging={state.grab !== undefined ? "" : undefined}
57
+ aria-hidden="true"
58
+ style={{ height: `${state.size}px`, transform: `translateY(${state.start}px)` }}
59
+ onPointerDown={(event) => {
60
+ if (event.button !== 0) return
61
+ event.preventDefault()
62
+ event.stopPropagation()
63
+ setState("grab", event.clientY - event.currentTarget.getBoundingClientRect().top)
64
+ event.currentTarget.setPointerCapture(event.pointerId)
65
+ }}
66
+ onPointerMove={(event) => {
67
+ if (state.grab === undefined) return
68
+ const travel = viewport.clientHeight - 8 - state.size
69
+
70
+ if (travel <= 0) return
71
+ viewport.scrollTop =
72
+ ((event.clientY - viewport.getBoundingClientRect().top - 4 - state.grab) / travel) *
73
+ (viewport.scrollHeight - viewport.clientHeight)
74
+ }}
75
+ onPointerUp={(event) => {
76
+ if (state.grab === undefined) return
77
+ event.currentTarget.releasePointerCapture(event.pointerId)
78
+ }}
79
+ onLostPointerCapture={() => setState("grab", undefined)}
80
+ />
81
+ </Show>
82
+ </div>
83
+ )
84
+ }
@@ -18,6 +18,8 @@ import { Icon } from "@opencode/ui/icon"
18
18
  import { IconButton } from "@opencode/ui/icon-button"
19
19
  import { Keybind } from "@opencode/ui/keybind"
20
20
  import { Tooltip } from "@opencode/ui/tooltip"
21
+ import { Loader } from "@opencode/ui/loader"
22
+ import { makeEventListener } from "@solid-primitives/event-listener"
21
23
  import check from "./quote-check.svg"
22
24
  import "./line-comment.css"
23
25
 
@@ -100,6 +102,15 @@ export interface LineCommentEditorProps extends Omit<ComponentProps<"div">, "chi
100
102
  /** Submit an empty value too, such as to clear a comment that exists (default: false). Compact empty actions otherwise cancel. */
101
103
  allowEmpty?: boolean
102
104
  mention?: LineCommentEditorMention
105
+ /** Compact editor action on Mod+Enter or modifier-click. */
106
+ alternateSubmit?: {
107
+ label: string
108
+ keys: string[]
109
+ disabled?: boolean
110
+ onSubmit: (value: string) => void
111
+ }
112
+ /** Keep the draft read-only and prevent duplicate actions while its submission settles. */
113
+ submitting?: boolean
103
114
  }
104
115
 
105
116
  function pathFilename(path: string) {
@@ -119,6 +130,8 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
119
130
  let textareaRef: HTMLTextAreaElement | undefined
120
131
  const [mentionOpen, setMentionOpen] = createSignal(false)
121
132
 
133
+ const [alternate, setAlternate] = createSignal(false)
134
+
122
135
  const [local, rest] = splitProps(props, [
123
136
  "label",
124
137
  "value",
@@ -134,6 +147,8 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
134
147
  "autofocus",
135
148
  "allowEmpty",
136
149
  "mention",
150
+ "alternateSubmit",
151
+ "submitting",
137
152
  "class",
138
153
  "classList",
139
154
  ])
@@ -141,10 +156,25 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
141
156
  const canSubmit = () => !!local.allowEmpty || local.value.trim().length > 0
142
157
  const compactCancel = () => !canSubmit()
143
158
 
159
+ const alternateActive = () => !!local.alternateSubmit && alternate()
160
+
144
161
  const compactLabel = () =>
145
- compactCancel()
146
- ? (local.cancelLabel ?? i18n.t("ui.lineComment.cancel"))
147
- : (local.submitLabel ?? i18n.t("ui.lineComment.submit"))
162
+ alternateActive()
163
+ ? local.alternateSubmit!.label
164
+ : compactCancel()
165
+ ? (local.cancelLabel ?? i18n.t("ui.lineComment.cancel"))
166
+ : (local.submitLabel ?? i18n.t("ui.lineComment.submit"))
167
+
168
+ createEffect(() => {
169
+ if (local.variant !== "compact" || !local.alternateSubmit) return
170
+
171
+ const update = (event: KeyboardEvent) => setAlternate(modified(event))
172
+
173
+ // Capture modifier releases; the textarea stops key propagation.
174
+ makeEventListener(document, "keydown", update, { capture: true })
175
+ makeEventListener(document, "keyup", update, { capture: true })
176
+ makeEventListener(window, "blur", () => setAlternate(false))
177
+ })
148
178
 
149
179
  const closeMention = () => {
150
180
  setMentionOpen(false)
@@ -228,10 +258,18 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
228
258
  selectMention(items.find((item) => item.path === active) ?? items[0])
229
259
  }
230
260
 
231
- const submit = () => {
261
+ const submit = (alternate = false) => {
262
+ if (local.submitting) return
232
263
  const v = local.value.trim()
233
264
 
234
265
  if (!v && !local.allowEmpty) return
266
+
267
+ if (alternate && local.alternateSubmit) {
268
+ if (!local.alternateSubmit.disabled) local.alternateSubmit.onSubmit(v)
269
+
270
+ return
271
+ }
272
+
235
273
  local.onSubmit(v)
236
274
  }
237
275
 
@@ -278,6 +316,7 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
278
316
  data-component="line-comment-v2"
279
317
  data-variant="editor"
280
318
  data-layout={local.variant ?? "default"}
319
+ aria-busy={local.submitting || undefined}
281
320
  classList={{
282
321
  ...local.classList,
283
322
  [local.class ?? ""]: !!local.class,
@@ -300,6 +339,7 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
300
339
  rows={local.rows ?? (local.variant === "compact" ? 1 : 4)}
301
340
  placeholder={local.placeholder ?? i18n.t("ui.lineComment.contextPlaceholder")}
302
341
  value={local.value}
342
+ readOnly={local.submitting}
303
343
  style={{ "unicode-bidi": "plaintext", "text-align": "start" }}
304
344
  onInput={(e) => {
305
345
  local.onInput(e.currentTarget.value)
@@ -312,7 +352,7 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
312
352
 
313
353
  if (e.isComposing || e.keyCode === 229) return
314
354
 
315
- if (mentionOpen()) {
355
+ if (mentionOpen() && !local.submitting) {
316
356
  if (e.key === "Escape") {
317
357
  e.preventDefault()
318
358
  closeMention()
@@ -343,6 +383,8 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
343
383
 
344
384
  if (e.key === "Escape") {
345
385
  e.preventDefault()
386
+
387
+ if (local.submitting) return
346
388
  e.currentTarget.blur()
347
389
  local.onCancel()
348
390
 
@@ -351,11 +393,13 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
351
393
 
352
394
  if (e.key === "Enter" && !e.shiftKey) {
353
395
  e.preventDefault()
354
- submit()
396
+
397
+ if (e.repeat) return
398
+ submit(modified(e))
355
399
  }
356
400
  }}
357
401
  />
358
- <Show when={mentionOpen() && mention.flat().length > 0}>
402
+ <Show when={!local.submitting && mentionOpen() && mention.flat().length > 0}>
359
403
  <div data-slot="line-comment-v2-mention-list">
360
404
  <For each={mention.flat().slice(0, 10)}>
361
405
  {(item) => {
@@ -388,9 +432,21 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
388
432
  <Show when={local.variant === "compact"}>
389
433
  <Tooltip
390
434
  value={
391
- <>
392
- {compactLabel()} <Keybind keys={[compactCancel() ? "Esc" : "⏎"]} variant="neutral" />
393
- </>
435
+ <div class="flex flex-col gap-1.5">
436
+ <div class="flex items-center gap-1.5">
437
+ {compactLabel()}
438
+ <Keybind
439
+ keys={alternateActive() ? local.alternateSubmit!.keys : [compactCancel() ? "Esc" : "⏎"]}
440
+ variant="neutral"
441
+ />
442
+ </div>
443
+ <Show when={local.alternateSubmit && !alternateActive()}>
444
+ <div class="flex items-center gap-1.5">
445
+ {local.alternateSubmit!.label}
446
+ <Keybind keys={local.alternateSubmit!.keys} variant="neutral" />
447
+ </div>
448
+ </Show>
449
+ </div>
394
450
  }
395
451
  placement="top"
396
452
  >
@@ -398,9 +454,16 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
398
454
  data-slot="line-comment-v2-submit"
399
455
  type="button"
400
456
  size="small"
401
- variant={local.value.trim() ? "neutral" : "ghost-muted"}
457
+ variant={
458
+ alternateActive() || local.submitting ? "submit" : local.value.trim() ? "neutral" : "ghost-muted"
459
+ }
460
+ disabled={local.submitting || (alternateActive() && local.alternateSubmit?.disabled)}
402
461
  icon={
403
- compactCancel() ? (
462
+ local.submitting ? (
463
+ <Loader />
464
+ ) : alternateActive() ? (
465
+ <Icon name="arrow-up" />
466
+ ) : compactCancel() ? (
404
467
  <Icon name="close" />
405
468
  ) : (
406
469
  <span
@@ -411,12 +474,30 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
411
474
  )
412
475
  }
413
476
  aria-label={compactLabel()}
414
- onClick={() => (compactCancel() ? local.onCancel() : submit())}
477
+ onPointerEnter={(event) => {
478
+ if (modified(event)) setAlternate(true)
479
+ }}
480
+ onClick={(event) => {
481
+ if (compactCancel() && !alternateActive()) return local.onCancel()
482
+ submit(alternateActive() || modified(event))
483
+ }}
415
484
  onKeyDown={(event) => {
416
- if (event.key !== "Escape" || event.isComposing) return
485
+ if (event.isComposing) return
486
+
487
+ if (event.key === "Enter" && modified(event) && local.alternateSubmit) {
488
+ event.preventDefault()
489
+ event.stopPropagation()
490
+
491
+ if (!event.repeat) submit(true)
492
+
493
+ return
494
+ }
495
+
496
+ if (event.key !== "Escape") return
417
497
  event.preventDefault()
418
498
  event.stopPropagation()
419
- local.onCancel()
499
+
500
+ if (!local.submitting) local.onCancel()
420
501
  }}
421
502
  />
422
503
  </Tooltip>
@@ -441,3 +522,7 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
441
522
  </div>
442
523
  )
443
524
  }
525
+
526
+ function modified(event: Pick<KeyboardEvent, "metaKey" | "ctrlKey" | "altKey" | "shiftKey">) {
527
+ return (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey
528
+ }
@@ -15,10 +15,9 @@
15
15
  border: 0;
16
16
  border-radius: 6px;
17
17
  outline: 1px solid transparent;
18
- outline-offset: 0;
19
- background:
20
- linear-gradient(180deg, var(--v2-alpha-light-6) 0%, var(--v2-alpha-light-2) 100%), var(--v2-background-bg-base);
21
- box-shadow: var(--v2-elevation-button-neutral);
18
+ outline-offset: -1px;
19
+ background: var(--v2-background-bg-base);
20
+ box-shadow: var(--v2-elevation-input);
22
21
  flex: none;
23
22
  align-self: stretch;
24
23
  transition:
@@ -27,14 +26,37 @@
27
26
  box-shadow 85ms ease-out;
28
27
  }
29
28
 
29
+ [data-component="text-input-v2"][data-appearance="small"] {
30
+ height: 24px;
31
+ }
32
+
30
33
  [data-component="text-input-v2"][data-appearance="large"] {
31
34
  height: 32px;
32
35
  }
33
36
 
34
- [data-component="text-input-v2"]:where(:hover):not([data-disabled], [data-invalid]):not(:focus-within) {
35
- background:
36
- linear-gradient(0deg, var(--v2-overlay-simple-overlay-hover), var(--v2-overlay-simple-overlay-hover)),
37
- linear-gradient(180deg, var(--v2-alpha-light-6) 0%, var(--v2-alpha-light-2) 100%), var(--v2-background-bg-base);
37
+ [data-component="text-input-v2"][data-surface="layer-1"] {
38
+ background: var(--v2-background-bg-layer-01);
39
+ }
40
+
41
+ [data-component="text-input-v2"][data-surface="invisible"] {
42
+ background: transparent;
43
+ box-shadow: none;
44
+ }
45
+
46
+ @media (hover: hover) {
47
+ [data-component="text-input-v2"]:where(:hover):not([data-disabled], [data-invalid], [data-surface="invisible"]):not(
48
+ :focus-within
49
+ ) {
50
+ box-shadow:
51
+ inset 0 0 0 100vmax var(--v2-overlay-simple-overlay-hover),
52
+ var(--v2-elevation-input);
53
+ }
54
+
55
+ [data-component="text-input-v2"][data-surface="invisible"]:where(:hover):not([data-disabled], [data-invalid]):not(
56
+ :focus-within
57
+ ) {
58
+ background: var(--v2-overlay-simple-overlay-hover);
59
+ }
38
60
  }
39
61
 
40
62
  [data-component="text-input-v2"]:where(:focus-within):not([data-disabled], [data-invalid]) {
@@ -166,14 +188,6 @@
166
188
  color: currentColor;
167
189
  }
168
190
 
169
- [data-component="text-input-v2"] [data-slot="text-input-v2-icon-button"][data-variant="clear"] {
170
- width: 28px;
171
- height: 28px;
172
- padding: 0;
173
- border-radius: 6px;
174
- margin-inline-end: -8px;
175
- }
176
-
177
191
  /* Pulls the buttons' padding out so their glyphs sit at the same inset as the leading icon. */
178
192
  [data-component="text-input-v2"] [data-slot="text-input-v2-trailing"] {
179
193
  display: flex;
@@ -24,8 +24,10 @@ export interface TextInputProps extends Omit<ComponentProps<"input">, "type"> {
24
24
  numeric?: boolean
25
25
  /** Error styling for the field and value text. */
26
26
  invalid?: boolean
27
- /** `base` is 28px tall; `large` is 32px tall. */
28
- appearance?: "base" | "large"
27
+ /** `small` is 24px tall; `base` is 28px tall; `large` is 32px tall. */
28
+ appearance?: "small" | "base" | "large"
29
+ /** Background surface; invisible gains a fill on hover. */
30
+ surface?: "base" | "layer-1" | "invisible"
29
31
  type?: ComponentProps<"input">["type"]
30
32
  }
31
33
 
@@ -47,6 +49,7 @@ export function TextInput(props: TextInputProps) {
47
49
  "numeric",
48
50
  "invalid",
49
51
  "appearance",
52
+ "surface",
50
53
  "disabled",
51
54
  ])
52
55
 
@@ -57,6 +60,7 @@ export function TextInput(props: TextInputProps) {
57
60
  data-invalid={local.invalid ? "" : undefined}
58
61
  data-numeric={local.numeric ? "" : undefined}
59
62
  data-appearance={local.appearance ?? "base"}
63
+ data-surface={local.surface ?? "base"}
60
64
  data-leading-icon={local.leadingIcon ? "" : undefined}
61
65
  classList={{
62
66
  ...local.classList,
@@ -9,10 +9,9 @@
9
9
  border: 0;
10
10
  border-radius: 6px;
11
11
  outline: 1px solid transparent;
12
- outline-offset: 0;
13
- background:
14
- linear-gradient(180deg, var(--v2-alpha-light-2) 0%, var(--v2-alpha-light-0) 100%), var(--v2-background-bg-base);
15
- box-shadow: var(--v2-elevation-button-neutral);
12
+ outline-offset: -1px;
13
+ background: var(--v2-background-bg-base);
14
+ box-shadow: var(--v2-elevation-input);
16
15
  flex: none;
17
16
  align-self: stretch;
18
17
  transition:
@@ -21,10 +20,16 @@
21
20
  box-shadow 85ms ease-out;
22
21
  }
23
22
 
24
- [data-component="textarea-v2"]:where(:hover):not([data-disabled], [data-invalid]):not(:focus-within) {
25
- background:
26
- linear-gradient(0deg, var(--v2-overlay-simple-overlay-hover), var(--v2-overlay-simple-overlay-hover)),
27
- linear-gradient(180deg, var(--v2-alpha-light-2) 0%, var(--v2-alpha-light-0) 100%), var(--v2-background-bg-base);
23
+ [data-component="textarea-v2"][data-surface="layer-1"] {
24
+ background: var(--v2-background-bg-layer-01);
25
+ }
26
+
27
+ @media (hover: hover) {
28
+ [data-component="textarea-v2"]:where(:hover):not([data-disabled], [data-invalid]):not(:focus-within) {
29
+ box-shadow:
30
+ inset 0 0 0 100vmax var(--v2-overlay-simple-overlay-hover),
31
+ var(--v2-elevation-input);
32
+ }
28
33
  }
29
34
 
30
35
  [data-component="textarea-v2"]:where(:focus-within):not([data-disabled], [data-invalid]) {
@@ -4,14 +4,16 @@ import "./textarea.css"
4
4
  export interface TextareaProps extends ComponentProps<"textarea"> {
5
5
  /** Error styling for the field and value text. */
6
6
  invalid?: boolean
7
+ surface?: "base" | "layer-1"
7
8
  }
8
9
 
9
10
  export function Textarea(props: TextareaProps) {
10
- const [local, textareaProps] = splitProps(props, ["class", "classList", "invalid", "disabled", "rows"])
11
+ const [local, textareaProps] = splitProps(props, ["class", "classList", "invalid", "disabled", "rows", "surface"])
11
12
 
12
13
  return (
13
14
  <div
14
15
  data-component="textarea-v2"
16
+ data-surface={local.surface ?? "base"}
15
17
  data-disabled={local.disabled ? "" : undefined}
16
18
  data-invalid={local.invalid ? "" : undefined}
17
19
  classList={{
@@ -5,6 +5,7 @@ import { Icon } from "@opencode/ui/icon"
5
5
  import { abort } from "@opencode/util/abort"
6
6
  import { useI18n } from "../../context/i18n"
7
7
  import { Loader } from "../../feedback/loader/loader"
8
+ import { MenuScroll } from "../../components/menu-scroll"
8
9
  import { createTypeahead } from "./controller"
9
10
 
10
11
  export { createTypeahead } from "./controller"
@@ -165,12 +166,12 @@ export function Typeahead<T>(props: {
165
166
  )
166
167
  }
167
168
  >
168
- {/* A stable gutter keeps rows from shifting when the list overflows; the end padding gives way to it. */}
169
- <div
169
+ <MenuScroll
170
170
  id={typeahead.listID}
171
171
  role="listbox"
172
- data-scrollable
173
- class="max-h-56 overflow-y-auto py-1 ps-1 pe-[max(0px,calc(4px-var(--scrollbar-size,0px)))] [scrollbar-gutter:stable] empty:hidden"
172
+ class="max-h-56"
173
+ viewportClass="p-1"
174
+ classList={{ hidden: results().items.length === 0 }}
174
175
  >
175
176
  <For each={results().items}>
176
177
  {(item) => (
@@ -195,7 +196,7 @@ export function Typeahead<T>(props: {
195
196
  </div>
196
197
  )}
197
198
  </For>
198
- </div>
199
+ </MenuScroll>
199
200
  {/* Stays mounted while a retry or a newer query is pending, so the list never collapses to nothing. */}
200
201
  <Show when={results().items.length === 0}>
201
202
  <div
@@ -112,6 +112,9 @@
112
112
  --v2-elevation-overlay:
113
113
  0px 16px 32px 0px var(--v2-alpha-dark-4), 0px 8px 16px 0px var(--v2-alpha-dark-8),
114
114
  0px 0px 0px 0.5px var(--v2-alpha-dark-12), 0px 0px 0px 0px var(--v2-alpha-dark-0);
115
+ --v2-elevation-input:
116
+ 0px 1px 1.5px 0px var(--v2-alpha-dark-10), 0px 0px 0px 0.5px var(--v2-alpha-dark-14),
117
+ 0px 0px 0px 0px var(--v2-alpha-dark-0);
115
118
  --v2-elevation-button-neutral:
116
119
  0px 1px 1.5px 0px var(--v2-alpha-dark-10), 0px 0px 0px 0.5px var(--v2-alpha-dark-14),
117
120
  0px 0px 0px 0px var(--v2-alpha-dark-0);
@@ -229,6 +232,10 @@
229
232
  0px 8px 16px 0px var(--v2-alpha-dark-30),
230
233
  0px 0px 0px 0.5px var(--v2-alpha-light-16),
231
234
  0px -0.5px 0px 0px var(--v2-alpha-light-6);
235
+ --v2-elevation-input:
236
+ 0px 1px 2px 0px var(--v2-alpha-dark-0),
237
+ 0px 0px 0px 0.5px var(--v2-alpha-light-16),
238
+ 0px -0.5px 0px 0px var(--v2-alpha-light-6);
232
239
  --v2-elevation-button-neutral:
233
240
  0px 1px 2px 0px var(--v2-alpha-dark-40),
234
241
  0px 0px 0px 0.5px var(--v2-alpha-light-20),
@@ -342,6 +349,9 @@
342
349
  --v2-elevation-overlay:
343
350
  0px 16px 32px 0px var(--v2-alpha-dark-4), 0px 8px 16px 0px var(--v2-alpha-dark-8),
344
351
  0px 0px 0px 0.5px var(--v2-alpha-dark-12), 0px 0px 0px 0px var(--v2-alpha-dark-0);
352
+ --v2-elevation-input:
353
+ 0px 1px 1.5px 0px var(--v2-alpha-dark-10), 0px 0px 0px 0.5px var(--v2-alpha-dark-14),
354
+ 0px 0px 0px 0px var(--v2-alpha-dark-0);
345
355
  --v2-elevation-button-neutral:
346
356
  0px 1px 1.5px 0px var(--v2-alpha-dark-10), 0px 0px 0px 0.5px var(--v2-alpha-dark-14),
347
357
  0px 0px 0px 0px var(--v2-alpha-dark-0);
@@ -488,6 +498,9 @@
488
498
  --v2-elevation-overlay:
489
499
  0px 16px 32px 0px var(--v2-alpha-dark-30), 0px 8px 16px 0px var(--v2-alpha-dark-30),
490
500
  0px 0px 0px 0.5px var(--v2-alpha-light-16), 0px -0.5px 0px 0px var(--v2-alpha-light-6);
501
+ --v2-elevation-input:
502
+ 0px 1px 2px 0px var(--v2-alpha-dark-0), 0px 0px 0px 0.5px var(--v2-alpha-light-16),
503
+ 0px -0.5px 0px 0px var(--v2-alpha-light-6);
491
504
  --v2-elevation-button-neutral:
492
505
  0px 1px 2px 0px var(--v2-alpha-dark-40), 0px 0px 0px 0.5px var(--v2-alpha-light-20),
493
506
  0px -0.5px 0px 0px var(--v2-alpha-light-10);
@@ -243,6 +243,7 @@
243
243
  "v2-elevation-raised": "0px 2px 4px 0px var(--v2-alpha-dark-4), 0px 1px 2px -1px var(--v2-alpha-dark-8), 0px 0px 0px 0.5px var(--v2-alpha-dark-12), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
244
244
  "v2-elevation-floating": "0px 8px 16px 0px var(--v2-alpha-dark-4), 0px 4px 8px 0px var(--v2-alpha-dark-8), 0px 0px 0px 0.5px var(--v2-alpha-dark-12), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
245
245
  "v2-elevation-overlay": "0px 16px 32px 0px var(--v2-alpha-dark-4), 0px 8px 16px 0px var(--v2-alpha-dark-8), 0px 0px 0px 0.5px var(--v2-alpha-dark-12), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
246
+ "v2-elevation-input": "0px 1px 1.5px 0px var(--v2-alpha-dark-10), 0px 0px 0px 0.5px var(--v2-alpha-dark-14), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
246
247
  "v2-elevation-button-neutral": "0px 1px 1.5px 0px var(--v2-alpha-dark-10), 0px 0px 0px 0.5px var(--v2-alpha-dark-14), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
247
248
  "v2-elevation-button-contrast": "0px 1px 1.5px 0px var(--v2-alpha-dark-20), 0px 0px 0px 0.5px var(--v2-grey-800), inset 0px 1px 2px 0px var(--v2-alpha-light-14), inset 0px -1px 2px 0px var(--v2-alpha-dark-6), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
248
249
  "v2-elevation-elements": "0px 0.5px 0.5px 0px var(--v2-alpha-dark-40)",
@@ -494,6 +495,7 @@
494
495
  "v2-elevation-raised": "0px 2px 4px 0px var(--v2-alpha-dark-30), 0px 1px 2px 0px var(--v2-alpha-dark-30), 0px 0px 0px 0.5px var(--v2-alpha-light-16), 0px -0.5px 0px 0px var(--v2-alpha-light-6)",
495
496
  "v2-elevation-floating": "0px 8px 16px 0px var(--v2-alpha-dark-30), 0px 4px 8px 0px var(--v2-alpha-dark-30), 0px 0px 0px 0.5px var(--v2-alpha-light-16), 0px -0.5px 0px 0px var(--v2-alpha-light-6)",
496
497
  "v2-elevation-overlay": "0px 16px 32px 0px var(--v2-alpha-dark-30), 0px 8px 16px 0px var(--v2-alpha-dark-30), 0px 0px 0px 0.5px var(--v2-alpha-light-16), 0px -0.5px 0px 0px var(--v2-alpha-light-6)",
498
+ "v2-elevation-input": "0px 1px 2px 0px var(--v2-alpha-dark-0), 0px 0px 0px 0.5px var(--v2-alpha-light-16), 0px -0.5px 0px 0px var(--v2-alpha-light-6)",
497
499
  "v2-elevation-button-neutral": "0px 1px 2px 0px var(--v2-alpha-dark-40), 0px 0px 0px 0.5px var(--v2-alpha-light-20), 0px -0.5px 0px 0px var(--v2-alpha-light-10)",
498
500
  "v2-elevation-button-contrast": "0px 1px 2px 0px var(--v2-alpha-dark-40), 0px 0px 0px 0.5px var(--v2-alpha-light-40), inset 0px 0px 0px 0px var(--v2-alpha-light-0), inset 0px 0px 0px 0px var(--v2-alpha-light-0), 0px -0.5px 0px 0px var(--v2-alpha-light-30)",
499
501
  "v2-elevation-elements": "0px 0.5px 0.5px 0px var(--v2-alpha-dark-40)",
@@ -3,7 +3,7 @@ import { V2_AVATAR_DARK, V2_AVATAR_LIGHT } from "./avatar"
3
3
 
4
4
  const ref = (name: string): V2ColorValue => `var(--${name})`
5
5
 
6
- const lightAgentTokens: Record<string, V2ColorValue> = {
6
+ const lightAgentTokens = {
7
7
  "v2-agent-plan-solid": ref("v2-pink-800"),
8
8
  "v2-agent-plan-border": "rgba(200, 61, 139, 0.20)",
9
9
  "v2-agent-plan-background": "rgba(253, 236, 243, 0.10)",
@@ -15,9 +15,9 @@ const lightAgentTokens: Record<string, V2ColorValue> = {
15
15
  "v2-agent-explore-background": "rgba(254, 250, 236, 0.1)",
16
16
  "v2-agent-review-solid": ref("v2-green-800"),
17
17
  "v2-agent-writer-solid": ref("v2-purple-700"),
18
- }
18
+ } satisfies Record<string, V2ColorValue>
19
19
 
20
- const darkAgentTokens: Record<string, V2ColorValue> = {
20
+ const darkAgentTokens = {
21
21
  "v2-agent-plan-solid": ref("v2-pink-400"),
22
22
  "v2-agent-plan-border": "rgba(247, 153, 198, 0.20)",
23
23
  "v2-agent-plan-background": "rgba(170, 53, 118, 0.05)",
@@ -29,9 +29,9 @@ const darkAgentTokens: Record<string, V2ColorValue> = {
29
29
  "v2-agent-explore-background": "rgba(172, 136, 51, 0.05)",
30
30
  "v2-agent-review-solid": ref("v2-green-300"),
31
31
  "v2-agent-writer-solid": ref("v2-purple-400"),
32
- }
32
+ } satisfies Record<string, V2ColorValue>
33
33
 
34
- const light: Record<string, V2ColorValue> = {
34
+ const light = {
35
35
  "v2-background-bg-base": ref("v2-grey-100"),
36
36
  "v2-background-bg-deep": ref("v2-grey-200"),
37
37
  "v2-background-bg-layer-01": ref("v2-grey-300"),
@@ -85,6 +85,8 @@ const light: Record<string, V2ColorValue> = {
85
85
  "0px 8px 16px 0px var(--v2-alpha-dark-4), 0px 4px 8px 0px var(--v2-alpha-dark-8), 0px 0px 0px 0.5px var(--v2-alpha-dark-12), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
86
86
  "v2-elevation-overlay":
87
87
  "0px 16px 32px 0px var(--v2-alpha-dark-4), 0px 8px 16px 0px var(--v2-alpha-dark-8), 0px 0px 0px 0.5px var(--v2-alpha-dark-12), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
88
+ "v2-elevation-input":
89
+ "0px 1px 1.5px 0px var(--v2-alpha-dark-10), 0px 0px 0px 0.5px var(--v2-alpha-dark-14), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
88
90
  "v2-elevation-button-neutral":
89
91
  "0px 1px 1.5px 0px var(--v2-alpha-dark-10), 0px 0px 0px 0.5px var(--v2-alpha-dark-14), 0px 0px 0px 0px var(--v2-alpha-dark-0)",
90
92
  "v2-elevation-button-contrast":
@@ -97,9 +99,9 @@ const light: Record<string, V2ColorValue> = {
97
99
  "v2-illustration-illustration-layer-01": ref("v2-grey-300"),
98
100
  "v2-illustration-illustration-layer-02": ref("v2-grey-400"),
99
101
  "v2-illustration-illustration-layer-03": ref("v2-grey-500"),
100
- }
102
+ } satisfies Record<string, V2ColorValue>
101
103
 
102
- const dark: Record<string, V2ColorValue> = {
104
+ const dark = {
103
105
  "v2-background-bg-base": ref("v2-grey-1000"),
104
106
  "v2-background-bg-deep": ref("v2-grey-1100"),
105
107
  "v2-background-bg-layer-01": ref("v2-grey-800"),
@@ -153,6 +155,8 @@ const dark: Record<string, V2ColorValue> = {
153
155
  "0px 8px 16px 0px var(--v2-alpha-dark-30), 0px 4px 8px 0px var(--v2-alpha-dark-30), 0px 0px 0px 0.5px var(--v2-alpha-light-16), 0px -0.5px 0px 0px var(--v2-alpha-light-6)",
154
156
  "v2-elevation-overlay":
155
157
  "0px 16px 32px 0px var(--v2-alpha-dark-30), 0px 8px 16px 0px var(--v2-alpha-dark-30), 0px 0px 0px 0.5px var(--v2-alpha-light-16), 0px -0.5px 0px 0px var(--v2-alpha-light-6)",
158
+ "v2-elevation-input":
159
+ "0px 1px 2px 0px var(--v2-alpha-dark-0), 0px 0px 0px 0.5px var(--v2-alpha-light-16), 0px -0.5px 0px 0px var(--v2-alpha-light-6)",
156
160
  "v2-elevation-button-neutral":
157
161
  "0px 1px 2px 0px var(--v2-alpha-dark-40), 0px 0px 0px 0.5px var(--v2-alpha-light-20), 0px -0.5px 0px 0px var(--v2-alpha-light-10)",
158
162
  "v2-elevation-button-contrast":
@@ -165,7 +169,7 @@ const dark: Record<string, V2ColorValue> = {
165
169
  "v2-illustration-illustration-layer-01": ref("v2-grey-900"),
166
170
  "v2-illustration-illustration-layer-02": ref("v2-grey-800"),
167
171
  "v2-illustration-illustration-layer-03": ref("v2-grey-700"),
168
- }
172
+ } satisfies Record<string, V2ColorValue>
169
173
 
170
174
  export function mapV2Semantics(isDark: boolean): Record<string, V2ColorValue> {
171
175
  return isDark ? dark : light