@diegopluna/narvi 0.3.4 → 0.3.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.
- package/dist/components/app-shell/AppShellPanel.svelte +35 -4
- package/dist/components/badge/Badge.svelte +13 -1
- package/dist/components/badge/Badge.svelte.d.ts +6 -0
- package/dist/components/button/Button.svelte +60 -32
- package/dist/components/button/Button.svelte.d.ts +6 -0
- package/dist/components/command/CommandDialog.svelte +24 -2
- package/dist/components/command/CommandDialog.svelte.d.ts +12 -0
- package/dist/components/command/CommandItem.svelte +15 -4
- package/dist/components/command/CommandItem.svelte.d.ts +20 -4
- package/dist/components/command/CommandRoot.svelte +57 -2
- package/dist/components/command/CommandRoot.svelte.d.ts +25 -1
- package/dist/components/composer/ComposerModelPicker.svelte +608 -53
- package/dist/components/composer/ComposerModelPicker.svelte.d.ts +56 -1
- package/dist/components/composer/ComposerRoot.svelte.d.ts +1 -1
- package/dist/components/composer/ComposerSubmit.svelte +12 -2
- package/dist/components/composer/ComposerSubmit.svelte.d.ts +6 -0
- package/dist/components/composer/index.d.ts +1 -1
- package/dist/components/input/Input.svelte.d.ts +1 -1
- package/dist/components/menu/MenuCheckboxItem.svelte +14 -5
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +15 -4
- package/dist/components/menu/MenuItem.svelte +9 -3
- package/dist/components/menu/MenuItem.svelte.d.ts +11 -4
- package/dist/components/menu/MenuRadioItem.svelte +18 -9
- package/dist/components/menu/MenuRadioItem.svelte.d.ts +15 -4
- package/dist/components/menu/MenuSubTrigger.svelte +9 -3
- package/dist/components/menu/MenuSubTrigger.svelte.d.ts +11 -4
- package/dist/components/questionnaire/Questionnaire.svelte +100 -9
- package/dist/components/questionnaire/Questionnaire.svelte.d.ts +11 -0
- package/dist/components/select/Select.svelte +11 -1
- package/dist/components/select/Select.svelte.d.ts +5 -0
- package/dist/components/slider/Slider.svelte.d.ts +2 -2
- package/dist/components/split-button/SplitButton.svelte +11 -1
- package/dist/components/split-button/SplitButton.svelte.d.ts +7 -0
- package/dist/components/tab-strip/TabStrip.svelte +77 -20
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +16 -3
- package/dist/components/textarea/Textarea.svelte.d.ts +1 -1
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/internal/ItemDescription.svelte +34 -0
- package/dist/internal/ItemDescription.svelte.d.ts +10 -0
- package/dist/internal/roving.d.ts +3 -1
- package/dist/internal/roving.js +6 -3
- package/dist/media.stylex.d.ts +6 -0
- package/dist/media.stylex.js +6 -0
- package/dist/vite.js +4 -0
- package/package.json +20 -1
- package/skills/building-ui/SKILL.md +30 -22
- package/skills/building-ui/references/components.md +22 -22
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +11 -2
- package/skills/theming/SKILL.md +1 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import * as stylex from '@stylexjs/stylex';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
3
4
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
5
|
import Glyph from '../../internal/Glyph.svelte';
|
|
6
|
+
import type { IconComponent } from '../../internal/icon.js';
|
|
7
|
+
import '../../internal/icons.css';
|
|
8
|
+
import { visuallyHidden } from '../../visually-hidden.js';
|
|
5
9
|
import { shared } from '../../internal/shared.js';
|
|
6
10
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
11
|
import { colors, font, motion, radius } from '../../tokens.stylex.js';
|
|
@@ -17,9 +21,25 @@
|
|
|
17
21
|
group?: string | undefined;
|
|
18
22
|
/** A short tag beside the name, such as "New". */
|
|
19
23
|
badge?: string | undefined;
|
|
24
|
+
/** With `providers`, the value of the provider it comes from, whose models it is listed with. */
|
|
25
|
+
provider?: string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Superseded by a newer model: folded with the other older ones into one row at the end of
|
|
28
|
+
* the list, or of its provider's, until that row is opened. A search shows it as any other.
|
|
29
|
+
*/
|
|
30
|
+
older?: boolean | undefined;
|
|
20
31
|
disabled?: boolean | undefined;
|
|
21
32
|
};
|
|
22
33
|
|
|
34
|
+
/** Who a model comes from, one to a button in the rail beside the list: an agent, a provider. */
|
|
35
|
+
export type ComposerModelProvider = {
|
|
36
|
+
value: string;
|
|
37
|
+
/** Its name, given to its button and said with the list as it is shown. */
|
|
38
|
+
label: string;
|
|
39
|
+
/** Its mark in the rail, a component such as a Lucide icon, sized to 16px. */
|
|
40
|
+
icon?: IconComponent | undefined;
|
|
41
|
+
};
|
|
42
|
+
|
|
23
43
|
type PickerBase = Omit<HTMLButtonAttributes, 'children' | 'value' | 'onchange'> & {
|
|
24
44
|
models: ComposerModel[];
|
|
25
45
|
/** What is being chosen. Names the list, and is read before the model on the button. */
|
|
@@ -28,6 +48,37 @@
|
|
|
28
48
|
open?: boolean | undefined;
|
|
29
49
|
/** Called when the list opens or closes. */
|
|
30
50
|
onopenchange?: ((open: boolean) => void) | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Who the models come from. With more than one, a rail of them stands beside the list, and
|
|
53
|
+
* the list shows the models of the one chosen there, by each model's `provider`. It opens
|
|
54
|
+
* on the chosen model's.
|
|
55
|
+
*/
|
|
56
|
+
providers?: ComposerModelProvider[] | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Draws a provider's mark in the rail, in place of `provider.icon`: for a mark that takes
|
|
59
|
+
* props, or one with a badge of its own. It is sized as a 16px icon.
|
|
60
|
+
*/
|
|
61
|
+
providerIcon?: Snippet<[provider: ComposerModelProvider]> | undefined;
|
|
62
|
+
/** Names the rail of providers. */
|
|
63
|
+
providersLabel?: string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* A field over the list that searches every model by its name, value, group and provider,
|
|
66
|
+
* past the rail. It takes focus as the list opens.
|
|
67
|
+
*/
|
|
68
|
+
searchable?: boolean | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* The values of the starred models. Bindable. Given, each model can be starred, with its
|
|
71
|
+
* star or ⌘D, and with `providers` the starred ones are listed together at the top of the rail.
|
|
72
|
+
*/
|
|
73
|
+
starred?: string[] | undefined;
|
|
74
|
+
/** Called as a model is starred or unstarred. */
|
|
75
|
+
onstar?: ((value: string, starred: boolean) => void) | undefined;
|
|
76
|
+
/** Its words: the search field's name, what no match says, and a star's two states. */
|
|
77
|
+
labels?:
|
|
78
|
+
| Partial<
|
|
79
|
+
Record<'search' | 'noMatch' | 'starred' | 'unstarred' | 'older' | 'alsoHint', string>
|
|
80
|
+
>
|
|
81
|
+
| undefined;
|
|
31
82
|
sx?: Sx | undefined;
|
|
32
83
|
ref?: HTMLButtonElement | null | undefined;
|
|
33
84
|
};
|
|
@@ -42,6 +93,14 @@
|
|
|
42
93
|
/** Called when the person picks a model. */
|
|
43
94
|
onchange?: ((value: string) => void) | undefined;
|
|
44
95
|
placeholder?: undefined;
|
|
96
|
+
/**
|
|
97
|
+
* The models beside the chosen one, to send the prompt to each too. Bindable. Given,
|
|
98
|
+
* Shift, ⌘ or Ctrl with a click or Enter adds a model beside the chosen one, or takes
|
|
99
|
+
* it off, and the list stays open.
|
|
100
|
+
*/
|
|
101
|
+
also?: string[] | undefined;
|
|
102
|
+
/** Called with the models beside the chosen one as one is added or taken off. */
|
|
103
|
+
onalso?: ((values: string[]) => void) | undefined;
|
|
45
104
|
}
|
|
46
105
|
| {
|
|
47
106
|
multiple: true;
|
|
@@ -51,6 +110,8 @@
|
|
|
51
110
|
onchange?: ((value: string[]) => void) | undefined;
|
|
52
111
|
/** What the button says while none is chosen. */
|
|
53
112
|
placeholder?: string | undefined;
|
|
113
|
+
also?: undefined;
|
|
114
|
+
onalso?: undefined;
|
|
54
115
|
}
|
|
55
116
|
);
|
|
56
117
|
|
|
@@ -140,12 +201,65 @@
|
|
|
140
201
|
transitionDuration: { default: '100ms', ':popover-open': '160ms' },
|
|
141
202
|
transitionTimingFunction: motion.easeOut
|
|
142
203
|
},
|
|
204
|
+
// With a rail, a little wider, for the rail's column
|
|
205
|
+
popoverRailed: { minWidth: '18rem', maxWidth: 'min(360px, calc(100vw - 16px))' },
|
|
143
206
|
list: {
|
|
144
207
|
display: 'flex',
|
|
145
208
|
flexDirection: 'column',
|
|
146
209
|
gap: '2px',
|
|
147
210
|
outlineStyle: 'none'
|
|
148
211
|
},
|
|
212
|
+
// The rail, then a hairline, then the list. The rail stays put as the list scrolls.
|
|
213
|
+
frame: { display: 'flex', alignItems: 'flex-start' },
|
|
214
|
+
frameList: { flexGrow: 1, minWidth: 0 },
|
|
215
|
+
rail: {
|
|
216
|
+
position: 'sticky',
|
|
217
|
+
top: 0,
|
|
218
|
+
display: 'flex',
|
|
219
|
+
flexDirection: 'column',
|
|
220
|
+
gap: '2px',
|
|
221
|
+
flexShrink: 0
|
|
222
|
+
},
|
|
223
|
+
divider: {
|
|
224
|
+
alignSelf: 'stretch',
|
|
225
|
+
flexShrink: 0,
|
|
226
|
+
width: '1px',
|
|
227
|
+
marginInline: '0.25rem',
|
|
228
|
+
backgroundColor: colors.border
|
|
229
|
+
},
|
|
230
|
+
provider: {
|
|
231
|
+
'--narvi-icon-size': '1rem',
|
|
232
|
+
display: 'grid',
|
|
233
|
+
placeItems: 'center',
|
|
234
|
+
width: '2rem',
|
|
235
|
+
height: '2rem',
|
|
236
|
+
margin: 0,
|
|
237
|
+
padding: 0,
|
|
238
|
+
borderWidth: 0,
|
|
239
|
+
borderRadius: radius.control,
|
|
240
|
+
backgroundColor: {
|
|
241
|
+
default: 'transparent',
|
|
242
|
+
':hover': { default: null, [media.hover]: colors.fillHover }
|
|
243
|
+
},
|
|
244
|
+
color: {
|
|
245
|
+
default: colors.textMuted,
|
|
246
|
+
':hover': { default: null, [media.hover]: colors.text }
|
|
247
|
+
},
|
|
248
|
+
fontFamily: 'inherit',
|
|
249
|
+
fontSize: font.sizeCaption,
|
|
250
|
+
fontWeight: font.weightMedium,
|
|
251
|
+
lineHeight: 1,
|
|
252
|
+
cursor: 'pointer',
|
|
253
|
+
WebkitTapHighlightColor: 'transparent'
|
|
254
|
+
},
|
|
255
|
+
// The provider shown: the fill of what is chosen, and its ink
|
|
256
|
+
providerPressed: {
|
|
257
|
+
backgroundColor: { default: colors.fillSelected, ':hover': colors.fillSelected },
|
|
258
|
+
color: { default: colors.text, ':hover': colors.text },
|
|
259
|
+
outlineStyle: { default: null, [media.forcedColors]: 'solid' },
|
|
260
|
+
outlineWidth: { default: null, [media.forcedColors]: '1px' },
|
|
261
|
+
outlineColor: { default: null, [media.forcedColors]: 'Highlight' }
|
|
262
|
+
},
|
|
149
263
|
group: {
|
|
150
264
|
display: 'flex',
|
|
151
265
|
flexDirection: 'column',
|
|
@@ -222,9 +336,138 @@
|
|
|
222
336
|
gridRow: '1',
|
|
223
337
|
display: 'grid',
|
|
224
338
|
color: colors.accent
|
|
339
|
+
},
|
|
340
|
+
// A column for the star, at the end of the first line
|
|
341
|
+
optionStarrable: { gridTemplateColumns: 'minmax(0, 1fr) 16px 20px', columnGap: '0.5rem' },
|
|
342
|
+
star: {
|
|
343
|
+
gridColumn: '3',
|
|
344
|
+
gridRow: '1',
|
|
345
|
+
display: 'grid',
|
|
346
|
+
placeItems: 'center',
|
|
347
|
+
width: '1.25rem',
|
|
348
|
+
height: '1.25rem',
|
|
349
|
+
margin: 0,
|
|
350
|
+
padding: 0,
|
|
351
|
+
borderWidth: 0,
|
|
352
|
+
borderRadius: radius.chip,
|
|
353
|
+
backgroundColor: 'transparent',
|
|
354
|
+
color: {
|
|
355
|
+
default: colors.textSubtle,
|
|
356
|
+
':hover': { default: null, [media.hover]: colors.text }
|
|
357
|
+
},
|
|
358
|
+
cursor: 'pointer'
|
|
359
|
+
},
|
|
360
|
+
// Not starred, it shows on the row the pointer or the keyboard is on, where there is hover
|
|
361
|
+
starHidden: { opacity: { default: 1, [media.hover]: 0 } },
|
|
362
|
+
// Starred, the star is filled, in the text's ink: a mark of the person's, not a status
|
|
363
|
+
starOn: { color: { default: colors.text, ':hover': colors.text } },
|
|
364
|
+
// The provider a model comes from, beside its name, where the list mixes providers
|
|
365
|
+
from: {
|
|
366
|
+
flexShrink: 0,
|
|
367
|
+
color: colors.textSubtle,
|
|
368
|
+
fontSize: font.sizeCaption,
|
|
369
|
+
fontWeight: font.weightRegular
|
|
370
|
+
},
|
|
371
|
+
// The search field over the list: it stays as the list scrolls under it
|
|
372
|
+
search: {
|
|
373
|
+
'--narvi-icon-size': '0.875rem',
|
|
374
|
+
position: 'sticky',
|
|
375
|
+
top: '-0.25rem',
|
|
376
|
+
zIndex: 1,
|
|
377
|
+
display: 'flex',
|
|
378
|
+
alignItems: 'center',
|
|
379
|
+
gap: '0.5rem',
|
|
380
|
+
marginTop: '-0.25rem',
|
|
381
|
+
marginBottom: '0.25rem',
|
|
382
|
+
paddingTop: '0.25rem',
|
|
383
|
+
paddingInline: '0.625rem',
|
|
384
|
+
minHeight: '2.25rem',
|
|
385
|
+
backgroundColor: colors.bgRaised,
|
|
386
|
+
boxShadow: `inset 0 -1px 0 ${colors.border}`,
|
|
387
|
+
color: colors.textSubtle
|
|
388
|
+
},
|
|
389
|
+
searchField: {
|
|
390
|
+
flexGrow: 1,
|
|
391
|
+
minWidth: 0,
|
|
392
|
+
height: '2rem',
|
|
393
|
+
margin: 0,
|
|
394
|
+
padding: 0,
|
|
395
|
+
borderWidth: 0,
|
|
396
|
+
backgroundColor: 'transparent',
|
|
397
|
+
color: colors.text,
|
|
398
|
+
fontFamily: 'inherit',
|
|
399
|
+
fontSize: font.sizeBody,
|
|
400
|
+
outlineStyle: 'none',
|
|
401
|
+
'::placeholder': { color: colors.textSubtle }
|
|
402
|
+
},
|
|
403
|
+
empty: {
|
|
404
|
+
paddingBlock: '0.75rem',
|
|
405
|
+
paddingInline: '0.625rem',
|
|
406
|
+
color: colors.textMuted,
|
|
407
|
+
fontSize: font.sizeMeta
|
|
408
|
+
},
|
|
409
|
+
olderRow: { gridTemplateColumns: 'minmax(0, 1fr) 16px', minHeight: '2rem' },
|
|
410
|
+
olderName: { color: colors.textMuted, fontWeight: font.weightRegular },
|
|
411
|
+
olderChevron: {
|
|
412
|
+
gridColumn: '2',
|
|
413
|
+
display: 'grid',
|
|
414
|
+
color: colors.textSubtle,
|
|
415
|
+
rotate: { default: '-90deg', ':dir(rtl)': '90deg' },
|
|
416
|
+
transitionProperty: { default: 'none', [media.motion]: 'rotate' },
|
|
417
|
+
transitionDuration: motion.fast
|
|
418
|
+
},
|
|
419
|
+
olderOpen: { rotate: { default: '0deg', ':dir(rtl)': '0deg' } },
|
|
420
|
+
// What Shift and ⌘ do, at the foot of the list
|
|
421
|
+
hint: {
|
|
422
|
+
margin: 0,
|
|
423
|
+
marginTop: '0.25rem',
|
|
424
|
+
paddingTop: '0.5rem',
|
|
425
|
+
paddingBottom: '0.25rem',
|
|
426
|
+
paddingInline: '0.625rem',
|
|
427
|
+
boxShadow: `inset 0 1px 0 ${colors.border}`,
|
|
428
|
+
color: colors.textSubtle,
|
|
429
|
+
fontSize: font.sizeCaption,
|
|
430
|
+
lineHeight: font.leadingSnug
|
|
431
|
+
},
|
|
432
|
+
railRule: {
|
|
433
|
+
alignSelf: 'stretch',
|
|
434
|
+
height: '1px',
|
|
435
|
+
marginBlock: '0.125rem',
|
|
436
|
+
backgroundColor: colors.border
|
|
225
437
|
}
|
|
226
438
|
});
|
|
227
439
|
|
|
440
|
+
// Starred models' place in the rail, apart from any provider's value
|
|
441
|
+
const STARRED = '\u0000starred';
|
|
442
|
+
// Page Up and Page Down move this many models
|
|
443
|
+
const PAGE = 6;
|
|
444
|
+
|
|
445
|
+
/** How well a model matches every word searched for: higher is better, and 0 leaves it out. */
|
|
446
|
+
function matchScore(model: ComposerModel, providerName: string, words: string[]) {
|
|
447
|
+
const name = model.label.toLowerCase();
|
|
448
|
+
const text = `${name} ${model.value} ${model.group ?? ''} ${providerName}`.toLowerCase();
|
|
449
|
+
let score = 0;
|
|
450
|
+
for (const word of words) {
|
|
451
|
+
if (!text.includes(word)) return 0;
|
|
452
|
+
if (name.startsWith(word)) score += 3;
|
|
453
|
+
else if (name.split(/[\s/-]+/u).some((part) => part.startsWith(word))) score += 2;
|
|
454
|
+
else score += 1;
|
|
455
|
+
}
|
|
456
|
+
return score;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const LABELS = {
|
|
460
|
+
search: 'Search models',
|
|
461
|
+
noMatch: 'No model matches.',
|
|
462
|
+
starred: 'Starred',
|
|
463
|
+
unstarred: 'Not starred',
|
|
464
|
+
older: 'Older models',
|
|
465
|
+
alsoHint: 'Shift-click or ⌘-click a model to send to it too.'
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
// The row that folds older models away, among the options the keyboard goes through
|
|
469
|
+
const OLDER = '\u0000older';
|
|
470
|
+
|
|
228
471
|
type Group = { name: string | undefined; models: ComposerModel[] };
|
|
229
472
|
|
|
230
473
|
function groupModels(models: ComposerModel[]): Group[] {
|
|
@@ -250,6 +493,15 @@
|
|
|
250
493
|
open = $bindable(false),
|
|
251
494
|
onopenchange,
|
|
252
495
|
onchange,
|
|
496
|
+
providers,
|
|
497
|
+
providerIcon,
|
|
498
|
+
providersLabel = 'Providers',
|
|
499
|
+
searchable = false,
|
|
500
|
+
also = $bindable(),
|
|
501
|
+
onalso,
|
|
502
|
+
starred = $bindable(),
|
|
503
|
+
onstar,
|
|
504
|
+
labels,
|
|
253
505
|
disabled,
|
|
254
506
|
sx,
|
|
255
507
|
class: className,
|
|
@@ -264,10 +516,79 @@
|
|
|
264
516
|
|
|
265
517
|
let popover = $state<HTMLDivElement | null>(null);
|
|
266
518
|
let list = $state<HTMLDivElement | null>(null);
|
|
519
|
+
let field = $state<HTMLInputElement | null>(null);
|
|
267
520
|
let active = $state<string>();
|
|
521
|
+
let query = $state('');
|
|
522
|
+
let announcement = $state('');
|
|
523
|
+
|
|
524
|
+
const word = $derived({ ...LABELS, ...labels });
|
|
525
|
+
const starrable = $derived(starred !== undefined || !!onstar);
|
|
526
|
+
const starredModels = $derived(models.filter((model) => starred?.includes(model.value)));
|
|
527
|
+
const isStarred = (model: ComposerModel) => !!starred?.includes(model.value);
|
|
528
|
+
|
|
529
|
+
// With more than one provider, the list shows the models of the one chosen in the rail.
|
|
530
|
+
// Starred models, from every provider, come first, while there are any.
|
|
531
|
+
const railed = $derived(!!providers && providers.length > 1);
|
|
532
|
+
const railItems = $derived(
|
|
533
|
+
railed
|
|
534
|
+
? [...(starrable && starredModels.length ? [STARRED] : []), ...providers!.map((p) => p.value)]
|
|
535
|
+
: []
|
|
536
|
+
);
|
|
537
|
+
let shown = $state<string>();
|
|
538
|
+
const current = $derived(
|
|
539
|
+
railed ? (railItems.includes(shown!) ? shown! : railItems[0]) : undefined
|
|
540
|
+
);
|
|
541
|
+
const provider = $derived(railed ? providers!.find((p) => p.value === current) : undefined);
|
|
542
|
+
const providerName = (model: ComposerModel) =>
|
|
543
|
+
providers?.find((p) => p.value === model.provider)?.label ?? '';
|
|
268
544
|
|
|
269
|
-
|
|
270
|
-
const
|
|
545
|
+
// A search looks past the rail, through every model
|
|
546
|
+
const words = $derived(
|
|
547
|
+
searchable
|
|
548
|
+
? query
|
|
549
|
+
.trim()
|
|
550
|
+
.toLowerCase()
|
|
551
|
+
.split(/\s+/u)
|
|
552
|
+
.filter((w) => w !== '')
|
|
553
|
+
: []
|
|
554
|
+
);
|
|
555
|
+
const searching = $derived(words.length > 0);
|
|
556
|
+
// Older models fold into one row at the end, until it is opened
|
|
557
|
+
let showOlder = $state(false);
|
|
558
|
+
const base = $derived.by((): ComposerModel[] => {
|
|
559
|
+
if (searching) {
|
|
560
|
+
return models
|
|
561
|
+
.map((model) => ({ model, score: matchScore(model, providerName(model), words) }))
|
|
562
|
+
.filter(({ score }) => score > 0)
|
|
563
|
+
.sort((a, b) => b.score - a.score)
|
|
564
|
+
.map(({ model }) => model);
|
|
565
|
+
}
|
|
566
|
+
if (!railed) return models;
|
|
567
|
+
if (current === STARRED) return starredModels;
|
|
568
|
+
return models.filter((model) => model.provider === current);
|
|
569
|
+
});
|
|
570
|
+
// Found, or starred, the models are from several providers: one list, each with its provider
|
|
571
|
+
const mixed = $derived(searching || current === STARRED);
|
|
572
|
+
const foldable = $derived(!mixed && base.some((model) => model.older));
|
|
573
|
+
const fresh = $derived(foldable ? base.filter((model) => !model.older) : base);
|
|
574
|
+
const old = $derived(foldable ? base.filter((model) => model.older) : []);
|
|
575
|
+
const listed = $derived(showOlder ? [...fresh, ...old] : fresh);
|
|
576
|
+
const groups = $derived(mixed ? [{ name: undefined, models: fresh }] : groupModels(fresh));
|
|
577
|
+
const heading = $derived(
|
|
578
|
+
searching ? undefined : current === STARRED ? word.starred : provider?.label
|
|
579
|
+
);
|
|
580
|
+
const enabled = $derived(listed.filter((model) => !model.disabled));
|
|
581
|
+
// What the keyboard goes through, in order: the models, and the row that folds the older ones
|
|
582
|
+
const entries = $derived([
|
|
583
|
+
...fresh.filter((model) => !model.disabled).map((model) => model.value),
|
|
584
|
+
...(foldable ? [OLDER] : []),
|
|
585
|
+
...(showOlder ? old.filter((model) => !model.disabled).map((model) => model.value) : [])
|
|
586
|
+
]);
|
|
587
|
+
// Models beside the chosen one, in the list's order
|
|
588
|
+
const besideable = $derived(!multiple && (also !== undefined || !!onalso));
|
|
589
|
+
const alsoModels = $derived(
|
|
590
|
+
besideable ? models.filter((model) => also?.includes(model.value)) : []
|
|
591
|
+
);
|
|
271
592
|
// The chosen models, in the list's order. One at most, and the first by default, unless several may be.
|
|
272
593
|
const chosen = $derived.by((): ComposerModel[] => {
|
|
273
594
|
if (multiple) {
|
|
@@ -275,22 +596,35 @@
|
|
|
275
596
|
return models.filter((model) => values.includes(model.value));
|
|
276
597
|
}
|
|
277
598
|
const one = models.find((model) => model.value === value) ?? models[0];
|
|
278
|
-
return one ? [one] : [];
|
|
599
|
+
return one ? [one, ...alsoModels.filter((model) => model !== one)] : [];
|
|
279
600
|
});
|
|
280
601
|
const selected = $derived(chosen[0]);
|
|
281
602
|
const isChosen = (model: ComposerModel) => chosen.includes(model);
|
|
282
603
|
const optionId = (model: ComposerModel) => `${uid}-option-${models.indexOf(model)}`;
|
|
283
|
-
const activeModel = $derived(
|
|
604
|
+
const activeModel = $derived(listed.find((model) => model.value === active));
|
|
605
|
+
const activeId = $derived(
|
|
606
|
+
active === OLDER ? `${uid}-older` : activeModel ? optionId(activeModel) : undefined
|
|
607
|
+
);
|
|
284
608
|
const said = $derived(
|
|
285
609
|
chosen.length ? chosen.map((model) => model.label).join(', ') : multiple ? placeholder : ''
|
|
286
610
|
);
|
|
287
611
|
|
|
612
|
+
// Where the keyboard is while the list shows: the search field, or the list itself
|
|
613
|
+
const focusList = () => (searchable ? field : list)?.focus();
|
|
614
|
+
// The first model it can choose of those listed: one that is chosen, if any
|
|
615
|
+
const firstActive = () =>
|
|
616
|
+
chosen.find((model) => listed.includes(model) && !model.disabled)?.value ?? entries[0];
|
|
617
|
+
|
|
288
618
|
function show() {
|
|
289
|
-
|
|
619
|
+
query = '';
|
|
620
|
+
if (railed) shown = selected?.provider ?? providers![0].value;
|
|
621
|
+
// Folded, unless the chosen model is one of the older ones
|
|
622
|
+
showOlder = !!selected?.older;
|
|
623
|
+
active = firstActive();
|
|
290
624
|
popover?.showPopover();
|
|
291
625
|
// Placed and focused at once, so a key pressed straight after opening is not lost
|
|
292
626
|
place();
|
|
293
|
-
|
|
627
|
+
focusList();
|
|
294
628
|
list?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: 'nearest' });
|
|
295
629
|
}
|
|
296
630
|
|
|
@@ -299,8 +633,18 @@
|
|
|
299
633
|
if (refocus) ref?.focus();
|
|
300
634
|
}
|
|
301
635
|
|
|
302
|
-
|
|
636
|
+
// Shift, ⌘ or Ctrl adds a model beside the chosen one, or takes it off
|
|
637
|
+
function choose(model: ComposerModel, beside = false) {
|
|
303
638
|
if (model.disabled) return;
|
|
639
|
+
if (beside && besideable && model !== selected) {
|
|
640
|
+
const on = !alsoModels.includes(model);
|
|
641
|
+
const values = models
|
|
642
|
+
.filter((m) => (m === model ? on : alsoModels.includes(m)))
|
|
643
|
+
.map((m) => m.value);
|
|
644
|
+
also = values;
|
|
645
|
+
onalso?.(values);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
304
648
|
if (multiple) {
|
|
305
649
|
// Several may be chosen: the list stays open to choose the next
|
|
306
650
|
const values = isChosen(model)
|
|
@@ -312,9 +656,22 @@
|
|
|
312
656
|
}
|
|
313
657
|
value = model.value;
|
|
314
658
|
(onchange as ((value: string) => void) | undefined)?.(model.value);
|
|
659
|
+
// Chosen, it is no longer beside itself
|
|
660
|
+
if (alsoModels.includes(model)) {
|
|
661
|
+
also = alsoModels.filter((m) => m !== model).map((m) => m.value);
|
|
662
|
+
onalso?.(also);
|
|
663
|
+
}
|
|
315
664
|
hide();
|
|
316
665
|
}
|
|
317
666
|
|
|
667
|
+
function toggleStar(model: ComposerModel) {
|
|
668
|
+
const on = !isStarred(model);
|
|
669
|
+
// Kept in the models' order, whatever order they were starred in
|
|
670
|
+
starred = models.filter((m) => (m === model ? on : isStarred(m))).map((m) => m.value);
|
|
671
|
+
onstar?.(model.value, on);
|
|
672
|
+
announcement = `${model.label}, ${on ? word.starred : word.unstarred}`;
|
|
673
|
+
}
|
|
674
|
+
|
|
318
675
|
// Beside the button: below it when there is room, otherwise above, which is
|
|
319
676
|
// usually the case for a composer at the foot of the page.
|
|
320
677
|
function place() {
|
|
@@ -346,6 +703,7 @@
|
|
|
346
703
|
open = next;
|
|
347
704
|
onopenchange?.(next);
|
|
348
705
|
}
|
|
706
|
+
if (!next) announcement = '';
|
|
349
707
|
if (!next && popover?.contains(document.activeElement)) {
|
|
350
708
|
// Closed by Escape or a click outside while the list had focus
|
|
351
709
|
ref?.focus();
|
|
@@ -382,11 +740,35 @@
|
|
|
382
740
|
?.scrollIntoView({ block: 'nearest' });
|
|
383
741
|
});
|
|
384
742
|
|
|
743
|
+
// Shows the models of another place in the rail, on the first it can choose
|
|
744
|
+
function showProvider(item: string) {
|
|
745
|
+
shown = item;
|
|
746
|
+
query = '';
|
|
747
|
+
active = firstActive();
|
|
748
|
+
focusList();
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
function cycleProvider(step: number) {
|
|
752
|
+
const at = railItems.indexOf(current!);
|
|
753
|
+
showProvider(railItems[(at + step + railItems.length) % railItems.length]);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
function onsearch(event: Event & { currentTarget: HTMLInputElement }) {
|
|
757
|
+
query = event.currentTarget.value;
|
|
758
|
+
// A new search starts on its best match
|
|
759
|
+
active = entries[0];
|
|
760
|
+
}
|
|
761
|
+
|
|
385
762
|
function move(step: number) {
|
|
386
|
-
if (!
|
|
387
|
-
const index =
|
|
388
|
-
const next = index === -1 ? (step > 0 ? 0 :
|
|
389
|
-
active =
|
|
763
|
+
if (!entries.length) return;
|
|
764
|
+
const index = entries.indexOf(active!);
|
|
765
|
+
const next = index === -1 ? (step > 0 ? 0 : entries.length - 1) : index + step;
|
|
766
|
+
active = entries[Math.min(Math.max(next, 0), entries.length - 1)];
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function toggleOlder() {
|
|
770
|
+
showOlder = !showOlder;
|
|
771
|
+
active = OLDER;
|
|
390
772
|
}
|
|
391
773
|
|
|
392
774
|
// Typing a letter or two jumps to the model whose name starts with them
|
|
@@ -404,7 +786,19 @@
|
|
|
404
786
|
if (match) active = match.value;
|
|
405
787
|
}
|
|
406
788
|
|
|
789
|
+
// The keys of the list, from the list or from the search field. In the field, keys that
|
|
790
|
+
// type or move the caret are left to it.
|
|
407
791
|
function onListKeydown(event: KeyboardEvent) {
|
|
792
|
+
if (event.isComposing) return;
|
|
793
|
+
const inField = event.target === field;
|
|
794
|
+
const mod = event.metaKey || event.ctrlKey;
|
|
795
|
+
if (mod && event.key.toLowerCase() === 'd' && !event.altKey && !event.shiftKey) {
|
|
796
|
+
// ⌘D stars the model the keyboard is on, as a browser's bookmark does
|
|
797
|
+
if (!starrable || !activeModel) return;
|
|
798
|
+
toggleStar(activeModel);
|
|
799
|
+
event.preventDefault();
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
408
802
|
switch (event.key) {
|
|
409
803
|
case 'ArrowDown':
|
|
410
804
|
move(1);
|
|
@@ -412,25 +806,40 @@
|
|
|
412
806
|
case 'ArrowUp':
|
|
413
807
|
move(-1);
|
|
414
808
|
break;
|
|
415
|
-
case '
|
|
416
|
-
|
|
809
|
+
case 'PageDown':
|
|
810
|
+
move(PAGE);
|
|
811
|
+
break;
|
|
812
|
+
case 'PageUp':
|
|
813
|
+
move(-PAGE);
|
|
417
814
|
break;
|
|
815
|
+
case 'Home':
|
|
418
816
|
case 'End':
|
|
419
|
-
|
|
817
|
+
if (inField) return;
|
|
818
|
+
active = event.key === 'Home' ? entries[0] : entries.at(-1);
|
|
420
819
|
break;
|
|
421
820
|
case 'Enter':
|
|
821
|
+
if (active === OLDER) toggleOlder();
|
|
822
|
+
else if (activeModel) choose(activeModel, event.shiftKey || mod);
|
|
823
|
+
break;
|
|
422
824
|
case ' ':
|
|
423
|
-
if (
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
if (activeModel) choose(activeModel);
|
|
825
|
+
if (inField) return;
|
|
826
|
+
if (typed) typeahead(' ');
|
|
827
|
+
else if (active === OLDER) toggleOlder();
|
|
828
|
+
else if (activeModel) choose(activeModel, event.shiftKey);
|
|
428
829
|
break;
|
|
830
|
+
case 'ArrowLeft':
|
|
831
|
+
case 'ArrowRight': {
|
|
832
|
+
// Left and right go through the rail, mirrored right to left, unless words are typed
|
|
833
|
+
if (!railed || (inField && query !== '')) return;
|
|
834
|
+
const rtl = !!list && getComputedStyle(list).direction === 'rtl';
|
|
835
|
+
cycleProvider((event.key === 'ArrowRight') !== rtl ? 1 : -1);
|
|
836
|
+
break;
|
|
837
|
+
}
|
|
429
838
|
case 'Tab':
|
|
430
839
|
hide();
|
|
431
840
|
break;
|
|
432
841
|
default:
|
|
433
|
-
if (event.key.length === 1 && !
|
|
842
|
+
if (!inField && event.key.length === 1 && !mod && !event.altKey) {
|
|
434
843
|
typeahead(event.key);
|
|
435
844
|
break;
|
|
436
845
|
}
|
|
@@ -480,16 +889,105 @@
|
|
|
480
889
|
id="{uid}-popover"
|
|
481
890
|
popover="auto"
|
|
482
891
|
data-slot="composer-model-list"
|
|
483
|
-
{...stylex.attrs(styles.popover)}
|
|
892
|
+
{...stylex.attrs(styles.popover, railed && styles.popoverRailed)}
|
|
484
893
|
{ontoggle}
|
|
485
894
|
>
|
|
895
|
+
{#if railed}
|
|
896
|
+
<div {...stylex.attrs(styles.frame)}>
|
|
897
|
+
<!-- For the pointer: from the list, the left and right arrows go through it -->
|
|
898
|
+
<div role="group" aria-label={providersLabel} {...stylex.attrs(styles.rail)}>
|
|
899
|
+
{#each railItems as item (item)}
|
|
900
|
+
{@const entry = providers!.find((p) => p.value === item)}
|
|
901
|
+
{@const name = entry?.label ?? word.starred}
|
|
902
|
+
{@const pressed = !searching && item === current}
|
|
903
|
+
<button
|
|
904
|
+
type="button"
|
|
905
|
+
tabindex="-1"
|
|
906
|
+
aria-pressed={pressed}
|
|
907
|
+
aria-label={name}
|
|
908
|
+
title={name}
|
|
909
|
+
data-icons
|
|
910
|
+
{...stylex.attrs(styles.provider, pressed && styles.providerPressed)}
|
|
911
|
+
onclick={() => showProvider(item)}
|
|
912
|
+
>
|
|
913
|
+
{#if !entry}{@render starGlyph(true)}{:else if providerIcon}{@render providerIcon(
|
|
914
|
+
entry
|
|
915
|
+
)}{:else if entry.icon}<entry.icon aria-hidden="true" />{:else}<span
|
|
916
|
+
aria-hidden="true">{[...entry.label][0]?.toUpperCase()}</span
|
|
917
|
+
>{/if}
|
|
918
|
+
</button>
|
|
919
|
+
{#if !entry}<span aria-hidden="true" {...stylex.attrs(styles.railRule)}></span>{/if}
|
|
920
|
+
{/each}
|
|
921
|
+
</div>
|
|
922
|
+
<span aria-hidden="true" {...stylex.attrs(styles.divider)}></span>
|
|
923
|
+
<div {...stylex.attrs(styles.frameList)}>
|
|
924
|
+
{@render search()}
|
|
925
|
+
{#if heading}
|
|
926
|
+
<div aria-hidden="true" {...stylex.attrs(styles.groupLabel)}>{heading}</div>
|
|
927
|
+
{/if}
|
|
928
|
+
{@render options()}
|
|
929
|
+
</div>
|
|
930
|
+
</div>
|
|
931
|
+
{:else}
|
|
932
|
+
{@render search()}
|
|
933
|
+
{@render options()}
|
|
934
|
+
{/if}
|
|
935
|
+
<span role="status" {...stylex.attrs(visuallyHidden)}>{announcement}</span>
|
|
936
|
+
</div>
|
|
937
|
+
|
|
938
|
+
{#snippet starGlyph(filled: boolean)}
|
|
939
|
+
<svg data-glyph="" width="14" height="14" viewBox="0 0 16 16" aria-hidden="true">
|
|
940
|
+
<path
|
|
941
|
+
d="M8 2.25l1.8 3.65 4.03.58-2.92 2.84.69 4.01L8 11.44l-3.6 1.89.69-4.01-2.92-2.84 4.03-.58Z"
|
|
942
|
+
fill={filled ? 'currentColor' : 'none'}
|
|
943
|
+
stroke="currentColor"
|
|
944
|
+
stroke-width="1.25"
|
|
945
|
+
stroke-linejoin="round"
|
|
946
|
+
/>
|
|
947
|
+
</svg>
|
|
948
|
+
{/snippet}
|
|
949
|
+
|
|
950
|
+
{#snippet search()}
|
|
951
|
+
{#if searchable}
|
|
952
|
+
<div {...stylex.attrs(styles.search)}>
|
|
953
|
+
<Glyph name="search" size={14} />
|
|
954
|
+
<input
|
|
955
|
+
bind:this={field}
|
|
956
|
+
type="text"
|
|
957
|
+
role="combobox"
|
|
958
|
+
aria-expanded="true"
|
|
959
|
+
aria-autocomplete="list"
|
|
960
|
+
aria-controls="{uid}-listbox"
|
|
961
|
+
aria-activedescendant={activeId}
|
|
962
|
+
aria-label={word.search}
|
|
963
|
+
placeholder="{word.search}…"
|
|
964
|
+
autocomplete="off"
|
|
965
|
+
spellcheck={false}
|
|
966
|
+
value={query}
|
|
967
|
+
oninput={onsearch}
|
|
968
|
+
onkeydown={onListKeydown}
|
|
969
|
+
{...stylex.attrs(styles.searchField)}
|
|
970
|
+
/>
|
|
971
|
+
</div>
|
|
972
|
+
{/if}
|
|
973
|
+
{/snippet}
|
|
974
|
+
|
|
975
|
+
{#snippet options()}
|
|
976
|
+
{@render listbox()}
|
|
977
|
+
{#if searching && !listed.length}
|
|
978
|
+
<div role="status" {...stylex.attrs(styles.empty)}>{word.noMatch}</div>
|
|
979
|
+
{/if}
|
|
980
|
+
{/snippet}
|
|
981
|
+
|
|
982
|
+
{#snippet listbox()}
|
|
486
983
|
<div
|
|
487
984
|
bind:this={list}
|
|
985
|
+
id="{uid}-listbox"
|
|
488
986
|
role="listbox"
|
|
489
987
|
tabindex="-1"
|
|
490
|
-
aria-label={label}
|
|
491
|
-
aria-multiselectable={multiple || undefined}
|
|
492
|
-
aria-activedescendant={
|
|
988
|
+
aria-label={heading ? `${label}: ${heading}` : label}
|
|
989
|
+
aria-multiselectable={multiple || besideable || undefined}
|
|
990
|
+
aria-activedescendant={!searchable ? activeId : undefined}
|
|
493
991
|
{...stylex.attrs(styles.list)}
|
|
494
992
|
onkeydown={onListKeydown}
|
|
495
993
|
>
|
|
@@ -503,36 +1001,93 @@
|
|
|
503
1001
|
<div id="{uid}-group-{g}" {...stylex.attrs(styles.groupLabel)}>{group.name}</div>
|
|
504
1002
|
{/if}
|
|
505
1003
|
{#each group.models as model (model.value)}
|
|
506
|
-
{@
|
|
507
|
-
<!-- The list handles the keyboard for every option; this click is for the pointer -->
|
|
508
|
-
<div
|
|
509
|
-
id={optionId(model)}
|
|
510
|
-
role="option"
|
|
511
|
-
aria-selected={isSelected}
|
|
512
|
-
aria-disabled={model.disabled || undefined}
|
|
513
|
-
{...stylex.attrs(
|
|
514
|
-
styles.option,
|
|
515
|
-
model.value === active && styles.active,
|
|
516
|
-
model.disabled && styles.optionDisabled
|
|
517
|
-
)}
|
|
518
|
-
onpointermove={() => {
|
|
519
|
-
if (!model.disabled) active = model.value;
|
|
520
|
-
}}
|
|
521
|
-
onclick={() => choose(model)}
|
|
522
|
-
>
|
|
523
|
-
<span {...stylex.attrs(styles.name)}>
|
|
524
|
-
<span {...stylex.attrs(styles.nameText)}>{model.label}</span>
|
|
525
|
-
{#if model.badge}<span {...stylex.attrs(styles.badge)}>{model.badge}</span>{/if}
|
|
526
|
-
</span>
|
|
527
|
-
{#if isSelected}
|
|
528
|
-
<span {...stylex.attrs(styles.check)}><Glyph name="check" stroke={1.75} /></span>
|
|
529
|
-
{/if}
|
|
530
|
-
{#if model.description}
|
|
531
|
-
<span {...stylex.attrs(styles.description)}>{model.description}</span>
|
|
532
|
-
{/if}
|
|
533
|
-
</div>
|
|
1004
|
+
{@render option(model)}
|
|
534
1005
|
{/each}
|
|
535
1006
|
</div>
|
|
536
1007
|
{/each}
|
|
1008
|
+
{#if foldable}
|
|
1009
|
+
{@const count = old.length}
|
|
1010
|
+
<!-- Opens or folds the older models; Enter does the same from the keyboard -->
|
|
1011
|
+
<div
|
|
1012
|
+
id="{uid}-older"
|
|
1013
|
+
role="option"
|
|
1014
|
+
aria-selected="false"
|
|
1015
|
+
aria-label="{word.older}, {count}"
|
|
1016
|
+
{...stylex.attrs(styles.option, styles.olderRow, active === OLDER && styles.active)}
|
|
1017
|
+
onpointermove={() => (active = OLDER)}
|
|
1018
|
+
onclick={toggleOlder}
|
|
1019
|
+
>
|
|
1020
|
+
<span {...stylex.attrs(styles.name, styles.olderName)}>
|
|
1021
|
+
<span {...stylex.attrs(styles.nameText)}>{word.older}</span>
|
|
1022
|
+
<span {...stylex.attrs(styles.from)}>{count}</span>
|
|
1023
|
+
</span>
|
|
1024
|
+
<span {...stylex.attrs(styles.olderChevron, showOlder && styles.olderOpen)}
|
|
1025
|
+
><Glyph name="chevron" size={14} /></span
|
|
1026
|
+
>
|
|
1027
|
+
</div>
|
|
1028
|
+
{#if showOlder}
|
|
1029
|
+
{#each old as model (model.value)}
|
|
1030
|
+
{@render option(model)}
|
|
1031
|
+
{/each}
|
|
1032
|
+
{/if}
|
|
1033
|
+
{/if}
|
|
537
1034
|
</div>
|
|
538
|
-
|
|
1035
|
+
{#if besideable}
|
|
1036
|
+
<p {...stylex.attrs(styles.hint)}>{word.alsoHint}</p>
|
|
1037
|
+
{/if}
|
|
1038
|
+
{/snippet}
|
|
1039
|
+
|
|
1040
|
+
{#snippet option(model: ComposerModel)}
|
|
1041
|
+
{@const isSelected = isChosen(model)}
|
|
1042
|
+
{@const star = isStarred(model)}
|
|
1043
|
+
<!-- The list handles the keyboard for every option; this click is for the pointer -->
|
|
1044
|
+
<div
|
|
1045
|
+
id={optionId(model)}
|
|
1046
|
+
role="option"
|
|
1047
|
+
aria-selected={isSelected}
|
|
1048
|
+
aria-disabled={model.disabled || undefined}
|
|
1049
|
+
{...stylex.attrs(
|
|
1050
|
+
styles.option,
|
|
1051
|
+
starrable && styles.optionStarrable,
|
|
1052
|
+
model.value === active && styles.active,
|
|
1053
|
+
model.disabled && styles.optionDisabled
|
|
1054
|
+
)}
|
|
1055
|
+
onpointermove={() => {
|
|
1056
|
+
if (!model.disabled) active = model.value;
|
|
1057
|
+
}}
|
|
1058
|
+
onclick={(event) => choose(model, event.shiftKey || event.metaKey || event.ctrlKey)}
|
|
1059
|
+
>
|
|
1060
|
+
<span {...stylex.attrs(styles.name)}>
|
|
1061
|
+
<span {...stylex.attrs(styles.nameText)}>{model.label}</span>
|
|
1062
|
+
{#if model.badge}<span {...stylex.attrs(styles.badge)}>{model.badge}</span>{/if}
|
|
1063
|
+
{#if mixed && railed && model.provider}
|
|
1064
|
+
<span {...stylex.attrs(styles.from)}>{providerName(model)}</span>
|
|
1065
|
+
{/if}
|
|
1066
|
+
{#if star}<span {...stylex.attrs(visuallyHidden)}>, {word.starred}</span>{/if}
|
|
1067
|
+
</span>
|
|
1068
|
+
{#if isSelected}
|
|
1069
|
+
<span {...stylex.attrs(styles.check)}><Glyph name="check" stroke={1.75} /></span>
|
|
1070
|
+
{/if}
|
|
1071
|
+
{#if starrable}
|
|
1072
|
+
<!-- For the pointer: ⌘D stars the model the keyboard is on -->
|
|
1073
|
+
<button
|
|
1074
|
+
type="button"
|
|
1075
|
+
tabindex="-1"
|
|
1076
|
+
aria-hidden="true"
|
|
1077
|
+
{...stylex.attrs(
|
|
1078
|
+
styles.star,
|
|
1079
|
+
star ? styles.starOn : model.value !== active && styles.starHidden
|
|
1080
|
+
)}
|
|
1081
|
+
onclick={(event) => {
|
|
1082
|
+
event.stopPropagation();
|
|
1083
|
+
toggleStar(model);
|
|
1084
|
+
}}
|
|
1085
|
+
>
|
|
1086
|
+
{@render starGlyph(star)}
|
|
1087
|
+
</button>
|
|
1088
|
+
{/if}
|
|
1089
|
+
{#if model.description}
|
|
1090
|
+
<span {...stylex.attrs(styles.description)}>{model.description}</span>
|
|
1091
|
+
{/if}
|
|
1092
|
+
</div>
|
|
1093
|
+
{/snippet}
|