@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.
- package/dist/components/composites/action-button/action-button.d.ts +6 -0
- package/dist/components/composites/action-button/action-button.d.ts.map +1 -1
- package/dist/components/composites/action-button/action-button.js +29 -2
- package/dist/components/composites/action-button/action-button.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.d.ts +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.js +305 -172
- package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.d.ts +6 -0
- package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.js +2 -2
- package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-types.d.ts +26 -0
- package/dist/components/composites/appearance-editor/appearance-types.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-types.js +10 -0
- package/dist/components/composites/appearance-editor/appearance-types.js.map +1 -0
- package/dist/components/composites/appearance-editor/font-settings-group.d.ts +13 -1
- package/dist/components/composites/appearance-editor/font-settings-group.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/font-settings-group.js +51 -15
- package/dist/components/composites/appearance-editor/font-settings-group.js.map +1 -1
- package/dist/components/composites/appearance-editor/index.d.ts +2 -1
- package/dist/components/composites/appearance-editor/index.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/index.js +3 -2
- package/dist/components/composites/model-selector/index.d.ts +1 -1
- package/dist/components/composites/model-selector/index.d.ts.map +1 -1
- package/dist/components/composites/model-selector/model-selector.d.ts +22 -0
- package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
- package/dist/components/composites/model-selector/model-selector.js +191 -46
- package/dist/components/composites/model-selector/model-selector.js.map +1 -1
- package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip/tooltip.js +4 -18
- package/dist/components/ui/tooltip/tooltip.js.map +1 -1
- package/dist/index.js +5 -4
- package/dist/lib/appearance-font-settings.d.ts +18 -4
- package/dist/lib/appearance-font-settings.d.ts.map +1 -1
- package/dist/lib/appearance-font-settings.js +24 -6
- package/dist/lib/appearance-font-settings.js.map +1 -1
- package/dist/lib/font-catalog.d.ts +5 -0
- package/dist/lib/font-catalog.d.ts.map +1 -1
- package/dist/lib/font-catalog.js +10 -5
- package/dist/lib/font-catalog.js.map +1 -1
- package/dist/lib/font-zoom.d.ts +1 -1
- package/dist/lib/font-zoom.d.ts.map +1 -1
- package/dist/lib/font-zoom.js +5 -1
- package/dist/lib/font-zoom.js.map +1 -1
- package/dist/lib/tokens.d.ts.map +1 -1
- package/dist/lib/tokens.js +17 -2
- package/dist/lib/tokens.js.map +1 -1
- package/dist/r/action-button.json +1 -0
- package/dist/r/appearance-editor.json +1 -0
- package/dist/r/registry.json +2 -0
- package/dist/r/src/components/composites/action-button/action-button.tsx +17 -1
- package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +202 -110
- package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +11 -1
- package/dist/r/src/components/composites/appearance-editor/appearance-types.ts +27 -0
- package/dist/r/src/components/composites/appearance-editor/font-settings-group.tsx +50 -10
- package/dist/r/src/components/composites/appearance-editor/index.ts +3 -0
- package/dist/r/src/components/composites/model-selector/index.ts +1 -1
- package/dist/r/src/components/composites/model-selector/model-selector.tsx +155 -10
- package/dist/r/src/components/ui/tooltip/tooltip.tsx +9 -18
- package/dist/r/src/lib/appearance-font-settings.ts +43 -7
- package/dist/r/src/lib/font-catalog.ts +5 -0
- package/dist/r/src/lib/font-zoom.ts +3 -0
- package/dist/r/src/lib/tokens.ts +17 -2
- package/dist/r/src/styles/appearance-font-settings.css +2 -0
- package/package.json +1 -1
- package/registry.json +2 -0
- package/src/components/composites/action-button/action-button.tsx +17 -1
- package/src/components/composites/appearance-editor/appearance-editor.tsx +202 -110
- package/src/components/composites/appearance-editor/appearance-rows.tsx +11 -1
- package/src/components/composites/appearance-editor/appearance-types.ts +27 -0
- package/src/components/composites/appearance-editor/font-settings-group.tsx +50 -10
- package/src/components/composites/appearance-editor/index.ts +3 -0
- package/src/components/composites/model-selector/index.ts +1 -1
- package/src/components/composites/model-selector/model-selector.tsx +155 -10
- package/src/components/ui/tooltip/tooltip.tsx +9 -18
- package/src/lib/appearance-font-settings.ts +43 -7
- package/src/lib/font-catalog.ts +5 -0
- package/src/lib/font-zoom.ts +3 -0
- package/src/lib/tokens.ts +17 -2
- package/src/styles/appearance-font-settings.css +2 -0
|
@@ -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: {
|
|
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: {
|
|
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
|
|
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
|
-
|
|
204
|
-
|
|
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
|
-
|
|
207
|
-
if (pointerCloseIntentTimeout) clearTimeout(pointerCloseIntentTimeout)
|
|
208
|
-
pointerCloseIntentTimeout = undefined
|
|
204
|
+
pointerClosePending = false
|
|
209
205
|
}
|
|
210
206
|
const markPointerCloseIntent = () => {
|
|
211
|
-
if (
|
|
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 &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_FONT_ID, fontOptions, type FontOption } from '#lib/font-catalog'
|
|
2
2
|
import { safeScriptStringLiteral } from '#lib/safe-script'
|
|
3
3
|
|
|
4
|
-
export const APPEARANCE_EDITOR_FONT_AXES = ['ui', 'content', 'code'] as const
|
|
4
|
+
export const APPEARANCE_EDITOR_FONT_AXES = ['ui', 'content', 'code', 'terminal'] as const
|
|
5
5
|
|
|
6
6
|
export type AppearanceEditorFontAxis = (typeof APPEARANCE_EDITOR_FONT_AXES)[number]
|
|
7
7
|
export type AppearanceEditorFontFamilyId = FontOption['id']
|
|
@@ -13,8 +13,21 @@ export type AppearanceEditorFontSetting = Readonly<{
|
|
|
13
13
|
size: number
|
|
14
14
|
}>
|
|
15
15
|
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* The host-owned choices edited by the shared appearance composition.
|
|
18
|
+
*
|
|
19
|
+
* `terminal` is optional in what a host stores: a record written before the
|
|
20
|
+
* terminal had its own axis, or by a host that never offers one, follows the
|
|
21
|
+
* Code axis. Normalization keeps it absent, so such a record is stored as it was.
|
|
22
|
+
*/
|
|
17
23
|
export type AppearanceEditorFontSettings = Readonly<
|
|
24
|
+
Record<Exclude<AppearanceEditorFontAxis, 'terminal'>, AppearanceEditorFontSetting> & {
|
|
25
|
+
terminal?: AppearanceEditorFontSetting
|
|
26
|
+
}
|
|
27
|
+
>
|
|
28
|
+
|
|
29
|
+
/** Font settings with every axis resolved (`resolveAppearanceEditorFontSettings`). */
|
|
30
|
+
export type ResolvedAppearanceEditorFontSettings = Readonly<
|
|
18
31
|
Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>
|
|
19
32
|
>
|
|
20
33
|
|
|
@@ -28,6 +41,15 @@ export const DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS: AppearanceEditorFontSettin
|
|
|
28
41
|
code: Object.freeze({ family: DEFAULT_FONT_ID, size: 12 }),
|
|
29
42
|
})
|
|
30
43
|
|
|
44
|
+
/** Every axis with a value: the terminal follows Code until it is given its own. */
|
|
45
|
+
export function resolveAppearanceEditorFontSettings(
|
|
46
|
+
settings: AppearanceEditorFontSettings
|
|
47
|
+
): ResolvedAppearanceEditorFontSettings {
|
|
48
|
+
return settings.terminal
|
|
49
|
+
? (settings as ResolvedAppearanceEditorFontSettings)
|
|
50
|
+
: { ...settings, terminal: settings.code }
|
|
51
|
+
}
|
|
52
|
+
|
|
31
53
|
export type NormalizedAppearanceEditorFontSettings = Readonly<{
|
|
32
54
|
settings: AppearanceEditorFontSettings
|
|
33
55
|
/** Axes whose persisted family or size was unavailable or outside its limits. */
|
|
@@ -71,6 +93,13 @@ const fontAxisProjection = Object.freeze({
|
|
|
71
93
|
scaleProperty: '--font-code-scale',
|
|
72
94
|
defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,
|
|
73
95
|
}),
|
|
96
|
+
terminal: Object.freeze({
|
|
97
|
+
familyAttribute: 'data-terminal-font',
|
|
98
|
+
familyProperty: '--font-terminal',
|
|
99
|
+
sizeProperty: '--font-terminal-size',
|
|
100
|
+
scaleProperty: '--font-terminal-scale',
|
|
101
|
+
defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,
|
|
102
|
+
}),
|
|
74
103
|
})
|
|
75
104
|
|
|
76
105
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
@@ -108,6 +137,8 @@ export function normalizeAppearanceEditorFontSize(value: unknown, fallback: numb
|
|
|
108
137
|
/**
|
|
109
138
|
* Recover persisted font choices against the shared font catalogue.
|
|
110
139
|
*
|
|
140
|
+
* A record with no `terminal` axis is returned without one: it follows Code.
|
|
141
|
+
*
|
|
111
142
|
* `legacyUiFamily` lets a host migrate its previous single font field into the
|
|
112
143
|
* UI axis. Content and code remain on the new System defaults during that
|
|
113
144
|
* migration. Missing settings are ordinary defaults; an unknown saved id or an
|
|
@@ -120,13 +151,18 @@ export function normalizeAppearanceEditorFontSettings(
|
|
|
120
151
|
const source = isRecord(value) ? value : undefined
|
|
121
152
|
const malformedRoot = value !== undefined && value !== null && source === undefined
|
|
122
153
|
const recovered = new Set<AppearanceEditorFontAxis>()
|
|
123
|
-
const settings = {} as
|
|
154
|
+
const settings = {} as {
|
|
155
|
+
-readonly [Axis in keyof AppearanceEditorFontSettings]: AppearanceEditorFontSettings[Axis]
|
|
156
|
+
}
|
|
124
157
|
|
|
125
158
|
for (const axis of APPEARANCE_EDITOR_FONT_AXES) {
|
|
126
159
|
const axisPresent = source ? hasOwn(source, axis) : false
|
|
127
160
|
const axisValue = source?.[axis]
|
|
128
161
|
const axisSource = isRecord(axisValue) ? axisValue : undefined
|
|
129
|
-
|
|
162
|
+
// The terminal used the Code axis before it had its own. A record without a
|
|
163
|
+
// terminal entry stays without one and keeps following Code.
|
|
164
|
+
if (axis === 'terminal' && !axisPresent) continue
|
|
165
|
+
const fallback = DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS[axis === 'terminal' ? 'code' : axis]
|
|
130
166
|
|
|
131
167
|
if (malformedRoot || (axisPresent && axisSource === undefined)) recovered.add(axis)
|
|
132
168
|
|
|
@@ -170,7 +206,7 @@ export function normalizeAppearanceEditorFontSettings(
|
|
|
170
206
|
*
|
|
171
207
|
* This is shared by `ThemeProvider` and hosts that own their own appearance
|
|
172
208
|
* persistence, so UI/content/code use the same catalogue ids, theme tokens,
|
|
173
|
-
* sizes, and projected CSS variables. The marker activates the optional role
|
|
209
|
+
* sizes, and projected CSS variables (terminal included). The marker activates the optional role
|
|
174
210
|
* stylesheet and survives CSS import reordering.
|
|
175
211
|
*/
|
|
176
212
|
export function applyAppearanceFontSettings(
|
|
@@ -178,7 +214,7 @@ export function applyAppearanceFontSettings(
|
|
|
178
214
|
value: unknown
|
|
179
215
|
): NormalizedAppearanceEditorFontSettings {
|
|
180
216
|
const normalized = normalizeAppearanceEditorFontSettings(value)
|
|
181
|
-
const
|
|
217
|
+
const settings = resolveAppearanceEditorFontSettings(normalized.settings)
|
|
182
218
|
|
|
183
219
|
// Only changed values are written: this runs on every theme pass, and an
|
|
184
220
|
// unchanged attribute or property rewritten still dirties the document's style.
|
|
@@ -233,5 +269,5 @@ export function fontSettingsBootstrapScript(storageKey: string, persistedVersion
|
|
|
233
269
|
? ''
|
|
234
270
|
: `&&parsed.version===Number(${safeScriptStringLiteral(String(persistedVersion))})`
|
|
235
271
|
|
|
236
|
-
return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(${APPEARANCE_EDITOR_FONT_SIZE_MAX},Math.max(${APPEARANCE_EDITOR_FONT_SIZE_MIN},Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`
|
|
272
|
+
return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(${APPEARANCE_EDITOR_FONT_SIZE_MAX},Math.max(${APPEARANCE_EDITOR_FONT_SIZE_MIN},Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=axis==='terminal'&&!has(saved,'terminal')?saved.code:saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`
|
|
237
273
|
}
|
package/src/lib/font-catalog.ts
CHANGED
|
@@ -18,6 +18,7 @@ const FONT_OPTIONS = [
|
|
|
18
18
|
ui: '--font-family-space-grotesk',
|
|
19
19
|
content: '--font-family-space-grotesk',
|
|
20
20
|
code: '--font-family-space-grotesk',
|
|
21
|
+
terminal: '--font-family-space-grotesk',
|
|
21
22
|
},
|
|
22
23
|
uiTracking: 'normal',
|
|
23
24
|
uiWordSpacing: 'normal',
|
|
@@ -30,6 +31,7 @@ const FONT_OPTIONS = [
|
|
|
30
31
|
ui: '--font-family-system',
|
|
31
32
|
content: '--font-family-system',
|
|
32
33
|
code: '--font-family-system-mono',
|
|
34
|
+
terminal: '--font-family-system-mono',
|
|
33
35
|
},
|
|
34
36
|
uiTracking: 'normal',
|
|
35
37
|
uiWordSpacing: 'normal',
|
|
@@ -42,6 +44,7 @@ const FONT_OPTIONS = [
|
|
|
42
44
|
ui: '--font-family-geist',
|
|
43
45
|
content: '--font-family-geist',
|
|
44
46
|
code: '--font-family-geist',
|
|
47
|
+
terminal: '--font-family-geist',
|
|
45
48
|
},
|
|
46
49
|
uiTracking: 'normal',
|
|
47
50
|
uiWordSpacing: 'normal',
|
|
@@ -54,6 +57,7 @@ const FONT_OPTIONS = [
|
|
|
54
57
|
ui: '--font-family-geist-mono',
|
|
55
58
|
content: '--font-family-geist-mono',
|
|
56
59
|
code: '--font-family-geist-mono',
|
|
60
|
+
terminal: '--font-family-geist-mono',
|
|
57
61
|
},
|
|
58
62
|
uiTracking: '-0.03em',
|
|
59
63
|
uiWordSpacing: '-1.5px',
|
|
@@ -66,6 +70,7 @@ const FONT_OPTIONS = [
|
|
|
66
70
|
ui: '--font-family-jetbrains-mono',
|
|
67
71
|
content: '--font-family-jetbrains-mono',
|
|
68
72
|
code: '--font-family-jetbrains-mono',
|
|
73
|
+
terminal: '--font-family-jetbrains-mono',
|
|
69
74
|
},
|
|
70
75
|
uiTracking: '-0.04em',
|
|
71
76
|
uiWordSpacing: '-2.5px',
|
package/src/lib/font-zoom.ts
CHANGED
|
@@ -62,6 +62,9 @@ export function stepAppearanceFontSizes(
|
|
|
62
62
|
ui: { ...current.ui, size: step(current.ui.size) },
|
|
63
63
|
content: { ...current.content, size: step(current.content.size) },
|
|
64
64
|
code: { ...current.code, size: step(current.code.size) },
|
|
65
|
+
...(current.terminal
|
|
66
|
+
? { terminal: { ...current.terminal, size: step(current.terminal.size) } }
|
|
67
|
+
: {}),
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
|
package/src/lib/tokens.ts
CHANGED
|
@@ -418,7 +418,12 @@ export const typographyTokens: TokenDefinition[] = [
|
|
|
418
418
|
{
|
|
419
419
|
name: 'font-code',
|
|
420
420
|
kind: 'font-family',
|
|
421
|
-
description: 'The selected family for code,
|
|
421
|
+
description: 'The selected family for code, keyboard keys, ids and paths.',
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
name: 'font-terminal',
|
|
425
|
+
kind: 'font-family',
|
|
426
|
+
description: 'The selected family for terminals; follows the code family until chosen.',
|
|
422
427
|
},
|
|
423
428
|
{
|
|
424
429
|
name: 'font-sans',
|
|
@@ -473,7 +478,12 @@ export const typographyTokens: TokenDefinition[] = [
|
|
|
473
478
|
{
|
|
474
479
|
name: 'font-code-size',
|
|
475
480
|
kind: 'dimension',
|
|
476
|
-
description: 'Runtime-projected code
|
|
481
|
+
description: 'Runtime-projected code and keyboard-key size in pixels.',
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
name: 'font-terminal-size',
|
|
485
|
+
kind: 'dimension',
|
|
486
|
+
description: 'Runtime-projected terminal size in pixels; follows the code size until chosen.',
|
|
477
487
|
},
|
|
478
488
|
{
|
|
479
489
|
name: 'font-ui-scale',
|
|
@@ -490,6 +500,11 @@ export const typographyTokens: TokenDefinition[] = [
|
|
|
490
500
|
kind: 'number',
|
|
491
501
|
description: 'The code size ratio applied to rem-relative code text.',
|
|
492
502
|
},
|
|
503
|
+
{
|
|
504
|
+
name: 'font-terminal-scale',
|
|
505
|
+
kind: 'number',
|
|
506
|
+
description: 'The terminal size ratio applied to rem-relative terminal text.',
|
|
507
|
+
},
|
|
493
508
|
{
|
|
494
509
|
name: 'ui-tracking',
|
|
495
510
|
kind: 'text',
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
--font-ui: var(--font-family-system);
|
|
14
14
|
--font-content: var(--font-family-system);
|
|
15
15
|
--font-code: var(--font-family-system-mono);
|
|
16
|
+
--font-terminal: var(--font-family-system-mono);
|
|
16
17
|
--font-sans: var(--font-ui);
|
|
17
18
|
--font-mono: var(--font-code);
|
|
18
19
|
--font-ui-scale: 1;
|
|
19
20
|
--font-content-scale: 1;
|
|
20
21
|
--font-code-scale: 1;
|
|
22
|
+
--font-terminal-scale: 1;
|
|
21
23
|
|
|
22
24
|
--text-2xs: calc(0.6875rem * var(--font-ui-scale));
|
|
23
25
|
--text-xs: calc(0.75rem * var(--font-ui-scale));
|