@opencode/ui 0.0.0-dev-562 → 0.0.0-dev-566

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.
@@ -16,6 +16,10 @@ export type SelectProps<T> = Omit<ComponentProps<typeof Root<T, {
16
16
  onHighlight?: (value: T | undefined) => void | (() => void);
17
17
  invalid?: boolean;
18
18
  numeric?: boolean;
19
+ /** `inline` is the borderless settings trigger; `small`, `base` and `large` are 24px, 28px and 32px input fields. */
20
+ appearance?: "inline" | "small" | "base" | "large";
21
+ /** Background surface of an input field; invisible gains a fill on hover. */
22
+ surface?: "base" | "layer-1" | "invisible";
19
23
  children?: (item: T) => JSX.Element;
20
24
  valueClass?: string;
21
25
  contentClass?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode/ui",
3
- "version": "0.0.0-dev-562",
3
+ "version": "0.0.0-dev-566",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -269,11 +269,11 @@
269
269
  "typecheck:tsc": "tsc --noEmit",
270
270
  "test": "bun test src --only-failures",
271
271
  "dev": "vite",
272
- "bench:motion": "bun script/motion-bench.ts",
273
272
  "generate:tailwind": "bun run script/tailwind.ts",
274
273
  "generate:v2-oc2": "bun run script/build-oc2-v2-overrides.ts"
275
274
  },
276
275
  "devDependencies": {
276
+ "@hona/strobe": "0.3.0",
277
277
  "@solidjs/meta": "0.29.4",
278
278
  "@tsconfig/node22": "22.0.2",
279
279
  "@types/bun": "1.4.3",
@@ -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": "0.0.0-dev-562",
291
+ "@opencode/util": "0.0.0-dev-566",
292
292
  "@pierre/diffs": "1.6.1",
293
293
  "@pierre/highlights": "0.2.0",
294
294
  "@solid-primitives/event-listener": "2.4.6",
@@ -32,10 +32,9 @@
32
32
  border: 0;
33
33
  border-radius: 6px;
34
34
  outline: 1px solid transparent;
35
- outline-offset: 0;
36
- background:
37
- linear-gradient(180deg, var(--v2-alpha-light-2) 0%, var(--v2-alpha-light-0) 100%), var(--v2-background-bg-base);
38
- box-shadow: var(--v2-elevation-button-neutral);
35
+ outline-offset: -1px;
36
+ background: var(--v2-background-bg-base);
37
+ box-shadow: var(--v2-elevation-input);
39
38
  flex: none;
40
39
  align-self: stretch;
41
40
  user-select: none;
@@ -45,21 +44,59 @@
45
44
  box-shadow 85ms ease-out;
46
45
  }
47
46
 
48
- [data-component="select-v2"]:where(:hover):not([data-disabled], [data-invalid]):not(:focus-within):not(
49
- [data-expanded]
50
- ) {
51
- background:
52
- linear-gradient(0deg, var(--v2-overlay-simple-overlay-hover), var(--v2-overlay-simple-overlay-hover)),
53
- linear-gradient(180deg, var(--v2-alpha-light-2) 0%, var(--v2-alpha-light-0) 100%), var(--v2-background-bg-base);
47
+ [data-component="select-v2"][data-appearance="small"] {
48
+ height: 24px;
54
49
  }
55
50
 
56
- [data-component="select-v2"]:where([data-expanded]):not([data-disabled], [data-invalid]) {
57
- background:
58
- linear-gradient(0deg, var(--v2-overlay-simple-overlay-hover), var(--v2-overlay-simple-overlay-hover)),
59
- linear-gradient(180deg, var(--v2-alpha-light-2) 0%, var(--v2-alpha-light-0) 100%), var(--v2-background-bg-base);
51
+ [data-component="select-v2"][data-appearance="large"] {
52
+ height: 32px;
53
+ padding-inline: 0 8px;
54
+ }
55
+
56
+ [data-component="select-v2"][data-surface="layer-1"] {
57
+ background: var(--v2-background-bg-layer-01);
58
+ }
59
+
60
+ [data-component="select-v2"][data-surface="invisible"] {
61
+ background: transparent;
62
+ box-shadow: none;
63
+ }
64
+
65
+ /* An inset overlay keeps the surface colour underneath, the same hover the text input uses. */
66
+ @media (hover: hover) {
67
+ [data-component="select-v2"]:where(:hover):not(
68
+ [data-disabled],
69
+ [data-invalid],
70
+ [data-expanded],
71
+ [data-appearance="inline"],
72
+ [data-surface="invisible"]
73
+ ):not(:focus-within) {
74
+ box-shadow:
75
+ inset 0 0 0 100vmax var(--v2-overlay-simple-overlay-hover),
76
+ var(--v2-elevation-input);
77
+ }
78
+
79
+ [data-component="select-v2"][data-surface="invisible"]:where(:hover):not(
80
+ [data-disabled],
81
+ [data-invalid],
82
+ [data-expanded]
83
+ ):not(:focus-within) {
84
+ background: var(--v2-overlay-simple-overlay-hover);
85
+ }
86
+ }
87
+
88
+ [data-component="select-v2"]:where([data-expanded]):not([data-disabled], [data-invalid], [data-appearance="inline"]) {
89
+ box-shadow:
90
+ inset 0 0 0 100vmax var(--v2-overlay-simple-overlay-hover),
91
+ var(--v2-elevation-input);
60
92
  outline-color: transparent;
61
93
  }
62
94
 
95
+ [data-component="select-v2"][data-surface="invisible"]:where([data-expanded]):not([data-disabled], [data-invalid]) {
96
+ background: var(--v2-overlay-simple-overlay-hover);
97
+ box-shadow: none;
98
+ }
99
+
63
100
  [data-component="select-v2"]:where(:focus-within):not([data-disabled], [data-invalid]):not([data-expanded]) {
64
101
  outline-color: var(--v2-border-border-focus);
65
102
  box-shadow: none;
@@ -70,11 +70,17 @@ export type SelectProps<T> = Omit<
70
70
  onHighlight?: (value: T | undefined) => void | (() => void)
71
71
  invalid?: boolean
72
72
  numeric?: boolean
73
+ /** `inline` is the borderless settings trigger; `small`, `base` and `large` are 24px, 28px and 32px input fields. */
74
+ appearance?: "inline" | "small" | "base" | "large"
75
+ /** Background surface of an input field; invisible gains a fill on hover. */
76
+ surface?: "base" | "layer-1" | "invisible"
73
77
  children?: (item: T) => JSX.Element
74
78
  valueClass?: string
75
79
  contentClass?: string
76
80
  }
77
81
 
82
+ type HighlightState = { key?: string; cleanup?: void | (() => void) }
83
+
78
84
  export function Select<T>(props: SelectProps<T>) {
79
85
  const [local, others] = splitProps(props, [
80
86
  "class",
@@ -91,6 +97,8 @@ export function Select<T>(props: SelectProps<T>) {
91
97
  "children",
92
98
  "invalid",
93
99
  "numeric",
100
+ "appearance",
101
+ "surface",
94
102
  "disabled",
95
103
  "valueClass",
96
104
  "contentClass",
@@ -102,7 +110,7 @@ export function Select<T>(props: SelectProps<T>) {
102
110
  "fitViewport",
103
111
  ])
104
112
 
105
- const state: { key?: string; cleanup?: void | (() => void) } = {}
113
+ const state: HighlightState = {}
106
114
 
107
115
  const stop = () => {
108
116
  state.cleanup?.()
@@ -110,7 +118,7 @@ export function Select<T>(props: SelectProps<T>) {
110
118
  state.key = undefined
111
119
  }
112
120
 
113
- const keyFor = (item: T) => (local.value ? local.value(item) : String(item as string))
121
+ const keyFor = (item: T) => (local.value ? local.value(item) : String(item))
114
122
 
115
123
  const move = (item: T | undefined) => {
116
124
  if (!local.onHighlight) return
@@ -148,8 +156,8 @@ export function Select<T>(props: SelectProps<T>) {
148
156
  fitViewport={local.fitViewport ?? false}
149
157
  value={local.current}
150
158
  options={grouped()}
151
- optionValue={(x) => (local.value ? local.value(x) : String(x as string))}
152
- optionTextValue={(x) => (local.label ? local.label(x) : String(x as string))}
159
+ optionValue={(x) => (local.value ? local.value(x) : String(x))}
160
+ optionTextValue={(x) => (local.label ? local.label(x) : String(x))}
153
161
  optionGroupChildren="options"
154
162
  placeholder={local.placeholder}
155
163
  sectionComponent={(sectionProps) => (
@@ -172,7 +180,7 @@ export function Select<T>(props: SelectProps<T>) {
172
180
  ? local.children(itemProps.item.rawValue)
173
181
  : local.label
174
182
  ? local.label(itemProps.item.rawValue)
175
- : String(itemProps.item.rawValue as string)}
183
+ : String(itemProps.item.rawValue)}
176
184
  </ItemLabel>
177
185
  <ItemIndicator data-slot="menu-v2-item-indicator" forceMount>
178
186
  <CheckSmall />
@@ -180,7 +188,7 @@ export function Select<T>(props: SelectProps<T>) {
180
188
  </Item>
181
189
  )}
182
190
  onChange={(next) => {
183
- const v = next == null ? null : Array.isArray(next) ? ((next[0] as T) ?? null) : (next as T)
191
+ const v = next == null ? null : Array.isArray(next) ? (next[0] ?? null) : next
184
192
  local.onSelect?.(v)
185
193
  stop()
186
194
  }}
@@ -195,7 +203,8 @@ export function Select<T>(props: SelectProps<T>) {
195
203
  aria-label={props["aria-label"]}
196
204
  aria-labelledby={props["aria-labelledby"]}
197
205
  data-component="select-v2"
198
- data-appearance="inline"
206
+ data-appearance={local.appearance ?? "inline"}
207
+ data-surface={local.appearance && local.appearance !== "inline" ? (local.surface ?? "base") : undefined}
199
208
  data-invalid={local.invalid ? "" : undefined}
200
209
  data-numeric={local.numeric ? "" : undefined}
201
210
  disabled={local.disabled}
@@ -212,7 +221,7 @@ export function Select<T>(props: SelectProps<T>) {
212
221
 
213
222
  if (local.label && selected != null) return local.label(selected)
214
223
 
215
- return selected != null ? (selected as string) : ""
224
+ return selected != null ? String(selected) : ""
216
225
  }}
217
226
  </Value>
218
227
  </div>