@adea-ai/ui 0.157.0 → 0.159.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/components/composites/action-button/action-button.d.ts +6 -0
  2. package/dist/components/composites/action-button/action-button.d.ts.map +1 -1
  3. package/dist/components/composites/action-button/action-button.js +29 -2
  4. package/dist/components/composites/action-button/action-button.js.map +1 -1
  5. package/dist/components/composites/appearance-editor/appearance-editor.d.ts +1 -1
  6. package/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
  7. package/dist/components/composites/appearance-editor/appearance-editor.js +305 -172
  8. package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
  9. package/dist/components/composites/appearance-editor/appearance-rows.d.ts +6 -0
  10. package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
  11. package/dist/components/composites/appearance-editor/appearance-rows.js +2 -2
  12. package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
  13. package/dist/components/composites/appearance-editor/appearance-types.d.ts +26 -0
  14. package/dist/components/composites/appearance-editor/appearance-types.d.ts.map +1 -1
  15. package/dist/components/composites/appearance-editor/appearance-types.js +10 -0
  16. package/dist/components/composites/appearance-editor/appearance-types.js.map +1 -0
  17. package/dist/components/composites/appearance-editor/font-settings-group.d.ts +13 -1
  18. package/dist/components/composites/appearance-editor/font-settings-group.d.ts.map +1 -1
  19. package/dist/components/composites/appearance-editor/font-settings-group.js +51 -15
  20. package/dist/components/composites/appearance-editor/font-settings-group.js.map +1 -1
  21. package/dist/components/composites/appearance-editor/index.d.ts +2 -1
  22. package/dist/components/composites/appearance-editor/index.d.ts.map +1 -1
  23. package/dist/components/composites/appearance-editor/index.js +3 -2
  24. package/dist/components/composites/model-selector/index.d.ts +1 -1
  25. package/dist/components/composites/model-selector/index.d.ts.map +1 -1
  26. package/dist/components/composites/model-selector/model-selector.d.ts +22 -0
  27. package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
  28. package/dist/components/composites/model-selector/model-selector.js +191 -46
  29. package/dist/components/composites/model-selector/model-selector.js.map +1 -1
  30. package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -1
  31. package/dist/components/ui/tooltip/tooltip.js +4 -18
  32. package/dist/components/ui/tooltip/tooltip.js.map +1 -1
  33. package/dist/index.js +5 -4
  34. package/dist/lib/appearance-font-settings.d.ts +18 -4
  35. package/dist/lib/appearance-font-settings.d.ts.map +1 -1
  36. package/dist/lib/appearance-font-settings.js +24 -6
  37. package/dist/lib/appearance-font-settings.js.map +1 -1
  38. package/dist/lib/font-catalog.d.ts +5 -0
  39. package/dist/lib/font-catalog.d.ts.map +1 -1
  40. package/dist/lib/font-catalog.js +10 -5
  41. package/dist/lib/font-catalog.js.map +1 -1
  42. package/dist/lib/font-zoom.d.ts +1 -1
  43. package/dist/lib/font-zoom.d.ts.map +1 -1
  44. package/dist/lib/font-zoom.js +5 -1
  45. package/dist/lib/font-zoom.js.map +1 -1
  46. package/dist/lib/tokens.d.ts.map +1 -1
  47. package/dist/lib/tokens.js +17 -2
  48. package/dist/lib/tokens.js.map +1 -1
  49. package/dist/r/action-button.json +1 -0
  50. package/dist/r/appearance-editor.json +1 -0
  51. package/dist/r/registry.json +2 -0
  52. package/dist/r/src/components/composites/action-button/action-button.tsx +17 -1
  53. package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +202 -110
  54. package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +11 -1
  55. package/dist/r/src/components/composites/appearance-editor/appearance-types.ts +27 -0
  56. package/dist/r/src/components/composites/appearance-editor/font-settings-group.tsx +50 -10
  57. package/dist/r/src/components/composites/appearance-editor/index.ts +3 -0
  58. package/dist/r/src/components/composites/model-selector/index.ts +1 -1
  59. package/dist/r/src/components/composites/model-selector/model-selector.tsx +155 -10
  60. package/dist/r/src/components/ui/tooltip/tooltip.tsx +9 -18
  61. package/dist/r/src/lib/appearance-font-settings.ts +43 -7
  62. package/dist/r/src/lib/font-catalog.ts +5 -0
  63. package/dist/r/src/lib/font-zoom.ts +3 -0
  64. package/dist/r/src/lib/tokens.ts +17 -2
  65. package/dist/r/src/styles/appearance-font-settings.css +2 -0
  66. package/package.json +1 -1
  67. package/registry.json +2 -0
  68. package/src/components/composites/action-button/action-button.tsx +17 -1
  69. package/src/components/composites/appearance-editor/appearance-editor.tsx +202 -110
  70. package/src/components/composites/appearance-editor/appearance-rows.tsx +11 -1
  71. package/src/components/composites/appearance-editor/appearance-types.ts +27 -0
  72. package/src/components/composites/appearance-editor/font-settings-group.tsx +50 -10
  73. package/src/components/composites/appearance-editor/index.ts +3 -0
  74. package/src/components/composites/model-selector/index.ts +1 -1
  75. package/src/components/composites/model-selector/model-selector.tsx +155 -10
  76. package/src/components/ui/tooltip/tooltip.tsx +9 -18
  77. package/src/lib/appearance-font-settings.ts +43 -7
  78. package/src/lib/font-catalog.ts +5 -0
  79. package/src/lib/font-zoom.ts +3 -0
  80. package/src/lib/tokens.ts +17 -2
  81. package/src/styles/appearance-font-settings.css +2 -0
@@ -3,8 +3,9 @@ import {
3
3
  ChevronDown as LucideChevronDown,
4
4
  Code2 as LucideCode2,
5
5
  PanelsTopLeft as LucidePanelsTopLeft,
6
+ SquareTerminal as LucideSquareTerminal,
6
7
  } from 'lucide-solid'
7
- import { For, createMemo, createSignal, createUniqueId } from 'solid-js'
8
+ import { For, Show, createMemo, createSignal, createUniqueId } from 'solid-js'
8
9
  import { DEFAULT_FONT_ID, fontOptions } from '../../../lib/font-catalog'
9
10
  import { Button } from '../../ui/button'
10
11
  import {
@@ -22,6 +23,7 @@ import {
22
23
  APPEARANCE_EDITOR_FONT_SIZE_MIN,
23
24
  normalizeAppearanceEditorFontSettings,
24
25
  normalizeAppearanceEditorFontSize,
26
+ resolveAppearanceEditorFontSettings,
25
27
  type AppearanceEditorFontAxis,
26
28
  type AppearanceEditorFontFamilyId,
27
29
  type AppearanceEditorFontSettings,
@@ -33,14 +35,29 @@ const BookOpen = fastIcon(LucideBookOpen)
33
35
  const ChevronDown = fastIcon(LucideChevronDown)
34
36
  const Code2 = fastIcon(LucideCode2)
35
37
  const PanelsTopLeft = fastIcon(LucidePanelsTopLeft)
38
+ const SquareTerminal = fastIcon(LucideSquareTerminal)
36
39
 
37
40
  export type AppearanceFontSettingsGroupProps = {
38
41
  settings: AppearanceEditorFontSettings
39
42
  menuPortalMount?: HTMLElement
40
43
  onChange: (settings: AppearanceEditorFontSettings) => void
41
44
  disabled?: boolean
45
+ /**
46
+ * The axes to draw, in the catalogue's order. The default is UI, Content and
47
+ * Code: with no terminal row the terminal keeps following Code. A host that
48
+ * lists `terminal` lets it be set apart; until it is, the row shows Code's value.
49
+ */
50
+ axes?: readonly AppearanceEditorFontAxis[]
51
+ /**
52
+ * The rows sit under a tab that already names their subject: each is titled
53
+ * "Font" and carries no description. Controls keep the axis in their
54
+ * accessible names.
55
+ */
56
+ sectioned?: boolean
42
57
  }
43
58
 
59
+ const DEFAULT_FONT_ROW_AXES: readonly AppearanceEditorFontAxis[] = ['ui', 'content', 'code']
60
+
44
61
  const FONT_ROWS = [
45
62
  {
46
63
  axis: 'ui',
@@ -57,9 +74,15 @@ const FONT_ROWS = [
57
74
  {
58
75
  axis: 'code',
59
76
  label: 'Code',
60
- description: 'Code, terminals, and file paths.',
77
+ description: 'Code, diffs, and file paths.',
61
78
  icon: Code2,
62
79
  },
80
+ {
81
+ axis: 'terminal',
82
+ label: 'Terminal',
83
+ description: 'Terminals and agent CLIs.',
84
+ icon: SquareTerminal,
85
+ },
63
86
  ] as const satisfies readonly {
64
87
  axis: AppearanceEditorFontAxis
65
88
  label: string
@@ -71,6 +94,7 @@ const catalogFontOptions = fontOptions.filter((option) => option.id !== DEFAULT_
71
94
 
72
95
  function FontFamilyMenu(props: {
73
96
  label: string
97
+ axis: AppearanceEditorFontAxis
74
98
  family: AppearanceEditorFontFamilyId
75
99
  menuPortalMount?: HTMLElement
76
100
  disabled?: boolean
@@ -85,6 +109,12 @@ function FontFamilyMenu(props: {
85
109
  fontOptions.find((option) => option.id === DEFAULT_FONT_ID)?.label ??
86
110
  'System'
87
111
 
112
+ const selectedFamilyVariable = () =>
113
+ (
114
+ fontOptions.find((option) => option.id === props.family) ??
115
+ fontOptions.find((option) => option.id === DEFAULT_FONT_ID)
116
+ )?.familyVariables[props.axis] ?? '--font-family-system'
117
+
88
118
  return (
89
119
  <DropdownMenu
90
120
  modal={false}
@@ -103,7 +133,11 @@ function FontFamilyMenu(props: {
103
133
  disabled={props.disabled}
104
134
  class="w-32 max-w-full justify-between"
105
135
  >
106
- <span class="truncate">{selectedLabel()}</span>
136
+ {/* The choice is drawn in its own face: a preview, and the face is fetched as soon as
137
+ it is picked even when nothing else on screen uses this axis yet. */}
138
+ <span class="truncate" style={{ 'font-family': `var(${selectedFamilyVariable()})` }}>
139
+ {selectedLabel()}
140
+ </span>
107
141
  <ChevronDown aria-hidden="true" class="ms-2 size-4 shrink-0 text-muted-foreground" />
108
142
  </DropdownMenuTrigger>
109
143
  <DropdownMenuContent
@@ -198,6 +232,9 @@ export function AppearanceFontSettingsGroup(props: AppearanceFontSettingsGroupPr
198
232
  >({})
199
233
  const sizeHintPrefix = createUniqueId()
200
234
  const settings = createMemo(() => normalizeAppearanceEditorFontSettings(props.settings).settings)
235
+ const resolved = createMemo(() => resolveAppearanceEditorFontSettings(settings()))
236
+ const axes = () => props.axes ?? DEFAULT_FONT_ROW_AXES
237
+ const rows = createMemo(() => FONT_ROWS.filter((row) => axes().includes(row.axis)))
201
238
 
202
239
  const updateAxis = (
203
240
  axis: AppearanceEditorFontAxis,
@@ -207,7 +244,7 @@ export function AppearanceFontSettingsGroup(props: AppearanceFontSettingsGroupPr
207
244
  props.onChange({
208
245
  ...current,
209
246
  [axis]: {
210
- ...current[axis],
247
+ ...resolved()[axis],
211
248
  ...patch,
212
249
  },
213
250
  })
@@ -216,21 +253,21 @@ export function AppearanceFontSettingsGroup(props: AppearanceFontSettingsGroupPr
216
253
  const commitSize = (axis: AppearanceEditorFontAxis) => {
217
254
  const input = sizeDrafts()[axis]
218
255
  if (input === undefined) return
219
- const size = normalizeAppearanceEditorFontSize(input, settings()[axis].size)
256
+ const size = normalizeAppearanceEditorFontSize(input, resolved()[axis].size)
220
257
  setSizeDrafts((current) => {
221
258
  const next = { ...current }
222
259
  delete next[axis]
223
260
  return next
224
261
  })
225
- if (size !== settings()[axis].size) updateAxis(axis, { size })
262
+ if (size !== resolved()[axis].size) updateAxis(axis, { size })
226
263
  }
227
264
 
228
265
  return (
229
266
  <div class="global-appearance-font-settings">
230
- <For each={FONT_ROWS}>
267
+ <For each={rows()}>
231
268
  {(row) => {
232
269
  const Icon = row.icon
233
- const value = () => settings()[row.axis]
270
+ const value = () => resolved()[row.axis]
234
271
  const inputValue = () => sizeDrafts()[row.axis] ?? String(value().size)
235
272
  const sizeHintId = `${sizeHintPrefix}-${row.axis}-font-size-help`
236
273
  const sizeIsInvalid = () => {
@@ -257,12 +294,15 @@ export function AppearanceFontSettingsGroup(props: AppearanceFontSettingsGroupPr
257
294
  and the title/subtitle stay aligned. The compact widths keep
258
295
  that true at the appearance sheet's own width. */}
259
296
  <div class="min-w-0 flex-1">
260
- <h3 class="text-sm font-medium">{row.label}</h3>
261
- <div class="mt-0.5 truncate text-xs text-muted-foreground">{row.description}</div>
297
+ <h3 class="text-sm font-medium">{props.sectioned ? 'Font' : row.label}</h3>
298
+ <Show when={!props.sectioned}>
299
+ <div class="mt-0.5 truncate text-xs text-muted-foreground">{row.description}</div>
300
+ </Show>
262
301
  </div>
263
302
  <div class="flex shrink-0 items-center gap-2">
264
303
  <FontFamilyMenu
265
304
  label={row.label}
305
+ axis={row.axis}
266
306
  family={value().family}
267
307
  menuPortalMount={props.menuPortalMount}
268
308
  disabled={props.disabled}
@@ -14,12 +14,15 @@ export {
14
14
  fontSettingsBootstrapScript,
15
15
  normalizeAppearanceEditorFontSettings,
16
16
  normalizeAppearanceEditorFontSize,
17
+ resolveAppearanceEditorFontSettings,
17
18
  type AppearanceEditorFontAxis,
18
19
  type AppearanceEditorFontFamilyId,
19
20
  type AppearanceEditorFontSetting,
20
21
  type AppearanceEditorFontSettings,
21
22
  type NormalizedAppearanceEditorFontSettings,
23
+ type ResolvedAppearanceEditorFontSettings,
22
24
  } from '../../../lib/appearance-font-settings'
25
+ export { APPEARANCE_EDITOR_TABS, type AppearanceEditorTab } from './appearance-types'
23
26
  export type {
24
27
  AppearanceDraft,
25
28
  AppearanceEditorProps,
@@ -1,4 +1,4 @@
1
- export { ModelSelector, type ModelSelectorProps } from './model-selector'
1
+ export { ModelSelector, type ModelSelectorFooter, type ModelSelectorProps } from './model-selector'
2
2
  export {
3
3
  findModel,
4
4
  groupModels,
@@ -29,7 +29,9 @@ import {
29
29
  DropdownMenuGroup,
30
30
  DropdownMenuLabel,
31
31
  DropdownMenuRadioGroup,
32
+ DropdownMenuItem,
32
33
  DropdownMenuRadioItem,
34
+ DropdownMenuSeparator,
33
35
  DropdownMenuTrigger,
34
36
  } from '../../ui/dropdown-menu'
35
37
  import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'
@@ -45,6 +47,7 @@ import {
45
47
  type ModelOption,
46
48
  } from './models'
47
49
  import { fastIcon } from '../../../lib/fast-icon'
50
+ import { menuItem } from '../../../lib/overlay'
48
51
 
49
52
  // lucide icons drawn from a cloned template (see fastIcon).
50
53
  const Brain = fastIcon(LucideBrain)
@@ -95,7 +98,28 @@ const ChevronsUpDown = fastIcon(LucideChevronsUpDown)
95
98
  * or the provider's initial and named by its tooltip. Under the tabs, a search
96
99
  * box and the list cover the selected tab's models only. The tab starts on the
97
100
  * selected model's provider. Effort stays its own menu.
101
+ *
102
+ * ## Footer
103
+ *
104
+ * `footer` is one choice that is not a model, such as "Workspace default", which
105
+ * lets the host pick both the provider and the model. It sits under the list,
106
+ * outside the search and the scroll, in every layout, and closes the menu when
107
+ * chosen. While `footer.selected` is true the trigger shows its label (and its
108
+ * `icon`) in place of a model.
109
+ *
110
+ * The searchable layouts trap focus while open: Tab and Shift+Tab move between
111
+ * the tabs, the search box and the footer instead of leaving the popover, which
112
+ * would close it.
98
113
  */
114
+ export type ModelSelectorFooter = {
115
+ label: string
116
+ /** The footer is the current choice: the trigger names it and it carries the check. */
117
+ selected?: boolean
118
+ /** Drawn before the label in the footer, and in the trigger while selected. */
119
+ icon?: JSX.Element
120
+ onSelect: () => void
121
+ }
122
+
99
123
  export type ModelSelectorProps = {
100
124
  models: readonly ModelOption[]
101
125
  /** The selected model's id. */
@@ -114,6 +138,8 @@ export type ModelSelectorProps = {
114
138
  layout?: 'list' | 'tabs'
115
139
  /** The provider's mark, drawn with `currentColor`, for the tabs and the trigger. */
116
140
  providerIcon?: (provider: string) => JSX.Element
141
+ /** A fixed choice under the list that is not a model; see Footer. */
142
+ footer?: ModelSelectorFooter
117
143
  class?: string
118
144
  }
119
145
 
@@ -129,6 +155,7 @@ export function ModelSelector(props: ModelSelectorProps) {
129
155
  'label',
130
156
  'layout',
131
157
  'providerIcon',
158
+ 'footer',
132
159
  'class',
133
160
  ])
134
161
  const blocked = () => local.disabledReason !== undefined
@@ -153,7 +180,7 @@ export function ModelSelector(props: ModelSelectorProps) {
153
180
  <Show when={local.value}>
154
181
  <span class="truncate px-2 text-sm text-muted-foreground">
155
182
  <span class="visually-hidden">Model: </span>
156
- {triggerText({ selected: selected(), value: local.value })}
183
+ {triggerText({ selected: selected(), value: local.value, footer: local.footer })}
157
184
  </span>
158
185
  </Show>
159
186
  }
@@ -168,6 +195,7 @@ export function ModelSelector(props: ModelSelectorProps) {
168
195
  blocked={blocked()}
169
196
  describedBy={describedBy()}
170
197
  providerIcon={local.providerIcon}
198
+ footer={local.footer}
171
199
  onChange={(id) => local.onChange?.(id)}
172
200
  />
173
201
  }
@@ -181,6 +209,7 @@ export function ModelSelector(props: ModelSelectorProps) {
181
209
  value={local.value}
182
210
  blocked={blocked()}
183
211
  describedBy={describedBy()}
212
+ footer={local.footer}
184
213
  onChange={(id) => local.onChange?.(id)}
185
214
  />
186
215
  }
@@ -191,6 +220,7 @@ export function ModelSelector(props: ModelSelectorProps) {
191
220
  value={local.value}
192
221
  blocked={blocked()}
193
222
  describedBy={describedBy()}
223
+ footer={local.footer}
194
224
  onChange={(id) => local.onChange?.(id)}
195
225
  />
196
226
  </Show>
@@ -230,7 +260,12 @@ export function ModelSelector(props: ModelSelectorProps) {
230
260
  )
231
261
  }
232
262
 
233
- function triggerText(props: { selected?: ModelOption; value?: string }): string {
263
+ function triggerText(props: {
264
+ selected?: ModelOption
265
+ value?: string
266
+ footer?: ModelSelectorFooter
267
+ }): string {
268
+ if (props.footer?.selected) return boundText(props.footer.label, 60)
234
269
  if (props.selected) return boundText(props.selected.label, 60)
235
270
  return props.value ? boundText(props.value, 60) : 'Choose a model'
236
271
  }
@@ -262,14 +297,27 @@ type PickerProps = {
262
297
  value?: string
263
298
  blocked: boolean
264
299
  describedBy?: string
300
+ footer?: ModelSelectorFooter
265
301
  onChange: (id: string) => void
266
302
  }
267
303
 
268
- function ModelTrigger(props: { selected?: ModelOption; value?: string; empty: boolean }) {
304
+ function ModelTrigger(props: {
305
+ selected?: ModelOption
306
+ value?: string
307
+ footer?: ModelSelectorFooter
308
+ empty: boolean
309
+ }) {
269
310
  return (
270
311
  <>
312
+ <Show when={props.footer?.selected && props.footer.icon}>
313
+ {(icon) => (
314
+ <span aria-hidden="true" class="inline-flex size-4 shrink-0 items-center justify-center">
315
+ {icon()}
316
+ </span>
317
+ )}
318
+ </Show>
271
319
  <span class="max-w-48 truncate">
272
- {props.empty ? 'No models available' : triggerText(props)}
320
+ {props.empty && !props.footer ? 'No models available' : triggerText(props)}
273
321
  </span>
274
322
  <ChevronsUpDown aria-hidden="true" />
275
323
  </>
@@ -279,7 +327,7 @@ function ModelTrigger(props: { selected?: ModelOption; value?: string; empty: bo
279
327
  function ModelMenu(props: PickerProps) {
280
328
  const [open, setOpen] = createSignal(false)
281
329
  const groups = createMemo(() => groupModels(props.models))
282
- const inert = () => props.blocked || props.models.length === 0
330
+ const inert = () => props.blocked || (props.models.length === 0 && !props.footer)
283
331
 
284
332
  createEffect(() => {
285
333
  if (inert()) setOpen(false)
@@ -294,13 +342,14 @@ function ModelMenu(props: PickerProps) {
294
342
  >
295
343
  <DropdownMenuTrigger
296
344
  as={PromptInputControl}
297
- aria-label={`Model: ${props.models.length === 0 ? 'No models available' : triggerText(props)}`}
345
+ aria-label={`Model: ${props.models.length === 0 && !props.footer ? 'No models available' : triggerText(props)}`}
298
346
  aria-disabled={inert() || undefined}
299
347
  aria-describedby={props.describedBy}
300
348
  >
301
349
  <ModelTrigger
302
350
  selected={props.selected}
303
351
  value={props.value}
352
+ footer={props.footer}
304
353
  empty={props.models.length === 0}
305
354
  />
306
355
  </DropdownMenuTrigger>
@@ -333,11 +382,79 @@ function ModelMenu(props: PickerProps) {
333
382
  )}
334
383
  </For>
335
384
  </DropdownMenuRadioGroup>
385
+ <Show when={props.footer}>
386
+ {(footer) => (
387
+ <>
388
+ <DropdownMenuSeparator />
389
+ <DropdownMenuItem
390
+ data-slot="model-selector-footer"
391
+ disabled={props.blocked}
392
+ onSelect={() => {
393
+ if (!props.blocked) footer().onSelect()
394
+ }}
395
+ >
396
+ <FooterBody footer={footer()} />
397
+ </DropdownMenuItem>
398
+ </>
399
+ )}
400
+ </Show>
336
401
  </DropdownMenuContent>
337
402
  </DropdownMenu>
338
403
  )
339
404
  }
340
405
 
406
+ /** The footer's icon, label and, while it is the current choice, the check. */
407
+ function FooterBody(props: { footer: ModelSelectorFooter }) {
408
+ return (
409
+ <>
410
+ <Show when={props.footer.icon}>
411
+ {(icon) => (
412
+ <span aria-hidden="true" class="inline-flex size-4 shrink-0 items-center justify-center">
413
+ {icon()}
414
+ </span>
415
+ )}
416
+ </Show>
417
+ <span class="min-w-0 truncate">{boundText(props.footer.label, 60)}</span>
418
+ <Show when={props.footer.selected}>
419
+ <Check aria-hidden="true" class="ms-auto text-primary" />
420
+ <span class="visually-hidden">Current choice</span>
421
+ </Show>
422
+ </>
423
+ )
424
+ }
425
+
426
+ /**
427
+ * The footer of a searchable picker: one full-width button under the list, outside its search
428
+ * and scroll, so it stays in view however long the list is.
429
+ */
430
+ function PaletteFooter(props: {
431
+ footer: ModelSelectorFooter
432
+ blocked: boolean
433
+ onDone: () => void
434
+ }) {
435
+ return (
436
+ <div data-slot="model-selector-footer" class="border-t border-border p-1">
437
+ <button
438
+ type="button"
439
+ aria-pressed={props.footer.selected ? 'true' : 'false'}
440
+ aria-disabled={props.blocked || undefined}
441
+ class={cn(
442
+ menuItem,
443
+ 'w-full cursor-pointer text-start hover:bg-surface-hover focus-visible:bg-surface-hover',
444
+ 'aria-disabled:pointer-events-none aria-disabled:text-muted-foreground'
445
+ )}
446
+ onClick={() => {
447
+ if (props.blocked) return
448
+ props.footer.onSelect()
449
+ props.onDone()
450
+ }}
451
+ >
452
+ <FooterBody footer={props.footer} />
453
+ </button>
454
+ </div>
455
+ )
456
+ }
457
+
341
458
  function ModelSearch(props: PickerProps) {
342
459
  const [open, setOpen] = createSignal(false)
343
460
  const groups = createMemo(() => groupModels(props.models))
@@ -350,6 +467,8 @@ function ModelSearch(props: PickerProps) {
350
467
  <Popover
351
468
  open={open()}
352
469
  onOpenChange={(next) => setOpen(next && !props.blocked)}
470
+ // Traps focus: Tab past the search box would otherwise leave the popover and close it.
471
+ modal
353
472
  placement="top-start"
354
473
  gutter={6}
355
474
  >
@@ -359,7 +478,12 @@ function ModelSearch(props: PickerProps) {
359
478
  aria-disabled={props.blocked || undefined}
360
479
  aria-describedby={props.describedBy}
361
480
  >
362
- <ModelTrigger selected={props.selected} value={props.value} empty={false} />
481
+ <ModelTrigger
482
+ selected={props.selected}
483
+ value={props.value}
484
+ footer={props.footer}
485
+ empty={false}
486
+ />
363
487
  </PopoverTrigger>
364
488
  <PopoverContent class="w-80 max-w-full">
365
489
  <Command
@@ -396,6 +520,15 @@ function ModelSearch(props: PickerProps) {
396
520
  </For>
397
521
  </CommandList>
398
522
  </Command>
523
+ <Show when={props.footer}>
524
+ {(footer) => (
525
+ <PaletteFooter
526
+ footer={footer()}
527
+ blocked={props.blocked}
528
+ onDone={() => setOpen(false)}
529
+ />
530
+ )}
531
+ </Show>
399
532
  </PopoverContent>
400
533
  </Popover>
401
534
  )
@@ -424,7 +557,7 @@ function ProviderGlyph(props: { provider: string; icon?: (provider: string) => J
424
557
  function ModelTabs(props: PickerProps & { providerIcon?: (provider: string) => JSX.Element }) {
425
558
  const [open, setOpen] = createSignal(false)
426
559
  const groups = createMemo(() => groupModels(props.models))
427
- const inert = () => props.blocked || props.models.length === 0
560
+ const inert = () => props.blocked || (props.models.length === 0 && !props.footer)
428
561
  const groupOf = (model: ModelOption | undefined) =>
429
562
  model ? groups().find((group) => group.models.includes(model))?.provider : undefined
430
563
  const [tab, setTab] = createSignal<string>()
@@ -450,21 +583,24 @@ function ModelTabs(props: PickerProps & { providerIcon?: (provider: string) => J
450
583
  setOpen(next && !inert())
451
584
  if (!next) setTab(undefined)
452
585
  }}
586
+ // Traps focus: Tab from the last control would otherwise leave the popover and close it.
587
+ modal
453
588
  placement="top-start"
454
589
  gutter={6}
455
590
  >
456
591
  <PopoverTrigger
457
592
  as={PromptInputControl}
458
- aria-label={`Model: ${props.models.length === 0 ? 'No models available' : triggerText(props)}`}
593
+ aria-label={`Model: ${props.models.length === 0 && !props.footer ? 'No models available' : triggerText(props)}`}
459
594
  aria-disabled={inert() || undefined}
460
595
  aria-describedby={props.describedBy}
461
596
  >
462
- <Show when={groupOf(props.selected)}>
597
+ <Show when={!props.footer?.selected && groupOf(props.selected)}>
463
598
  {(provider) => <ProviderGlyph provider={provider()} icon={props.providerIcon} />}
464
599
  </Show>
465
600
  <ModelTrigger
466
601
  selected={props.selected}
467
602
  value={props.value}
603
+ footer={props.footer}
468
604
  empty={props.models.length === 0}
469
605
  />
470
606
  </PopoverTrigger>
@@ -538,6 +674,15 @@ function ModelTabs(props: PickerProps & { providerIcon?: (provider: string) => J
538
674
  )}
539
675
  </For>
540
676
  </Tabs>
677
+ <Show when={props.footer}>
678
+ {(footer) => (
679
+ <PaletteFooter
680
+ footer={footer()}
681
+ blocked={props.blocked}
682
+ onDone={() => setOpen(false)}
683
+ />
684
+ )}
685
+ </Show>
541
686
  </PopoverContent>
542
687
  </Popover>
543
688
  )
@@ -47,13 +47,6 @@ const tooltipDefaults: TooltipTiming = {
47
47
 
48
48
  const TooltipTimingContext = createContext<TooltipTiming>(tooltipDefaults)
49
49
 
50
- /**
51
- * How long after a pointer leaves a keyboard-focused trigger its close request
52
- * still counts as the pointer's: Kobalte reports that close one `closeDelay`
53
- * later, plus a frame of slack for the timer to fire.
54
- */
55
- const POINTER_CLOSE_INTENT_SLACK_MS = 50
56
-
57
50
  /**
58
51
  * The layer a tooltip sits in, when that layer closes on Escape.
59
52
  *
@@ -200,19 +193,18 @@ export function Tooltip(props: TooltipRootProps) {
200
193
  let closeIntent = false
201
194
  let ignoreDuplicateClose = false
202
195
  let onOpenChange: (next: boolean, source?: 'handoff') => void
203
- let pointerCloseIntentUntil = 0
204
- let pointerCloseIntentTimeout: ReturnType<typeof setTimeout> | undefined
196
+ // Whether the next close Kobalte reports belongs to the pointer having left a
197
+ // trigger that still holds keyboard focus. It is state, not a deadline: Kobalte
198
+ // reports that close one `closeDelay` later on a timer, and a busy event loop
199
+ // can deliver it arbitrarily late, so the request stays the pointer's until it
200
+ // is answered or something explicit (open, blur, click, Escape, scroll, a
201
+ // handoff) takes over.
202
+ let pointerClosePending = false
205
203
  const clearPointerCloseIntent = () => {
206
- pointerCloseIntentUntil = 0
207
- if (pointerCloseIntentTimeout) clearTimeout(pointerCloseIntentTimeout)
208
- pointerCloseIntentTimeout = undefined
204
+ pointerClosePending = false
209
205
  }
210
206
  const markPointerCloseIntent = () => {
211
- if (!isOpen()) return
212
- clearPointerCloseIntent()
213
- const intentWindow = (props.closeDelay ?? timing.closeDelay) + POINTER_CLOSE_INTENT_SLACK_MS
214
- pointerCloseIntentUntil = Date.now() + intentWindow
215
- pointerCloseIntentTimeout = setTimeout(clearPointerCloseIntent, intentWindow)
207
+ if (isOpen()) pointerClosePending = true
216
208
  }
217
209
  const markCloseIntent = () => {
218
210
  closeIntent = true
@@ -277,7 +269,6 @@ export function Tooltip(props: TooltipRootProps) {
277
269
  const focusedTrigger = interaction.isTriggerFocused()
278
270
  const anotherTooltipOpening =
279
271
  pendingTooltipOpenId !== undefined && pendingTooltipOpenId !== id
280
- const pointerClosePending = Date.now() <= pointerCloseIntentUntil
281
272
  if (
282
273
  source !== 'handoff' &&
283
274
  focusedTrigger &&