@diegopluna/narvi 0.4.0 → 0.4.1

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.
@@ -544,6 +544,20 @@
544
544
  const providerName = (model: ComposerModel) =>
545
545
  providers?.find((p) => p.value === model.provider)?.label ?? '';
546
546
 
547
+ // An option is named in full, as it reads: its name, badge and provider, then "Starred" after
548
+ // a comma. Not by a word hidden inside it, which is a box of its own and is read with a space
549
+ // each side, as "Ithil 2 , Starred"
550
+ const optionName = (model: ComposerModel, star: boolean) => {
551
+ const shown = [
552
+ model.label,
553
+ model.badge,
554
+ mixed && railed && model.provider ? providerName(model) : undefined
555
+ ]
556
+ .filter(Boolean)
557
+ .join(' ');
558
+ return star ? `${shown}, ${word.starred}` : shown;
559
+ };
560
+
547
561
  // A search looks past the rail, through every model
548
562
  const words = $derived(
549
563
  searchable
@@ -1046,6 +1060,7 @@
1046
1060
  <div
1047
1061
  id={optionId(model)}
1048
1062
  role="option"
1063
+ aria-label={optionName(model, star)}
1049
1064
  aria-selected={isSelected}
1050
1065
  aria-disabled={model.disabled || undefined}
1051
1066
  {...stylex.attrs(
@@ -1065,7 +1080,6 @@
1065
1080
  {#if mixed && railed && model.provider}
1066
1081
  <span {...stylex.attrs(styles.from)}>{providerName(model)}</span>
1067
1082
  {/if}
1068
- {#if star}<span {...stylex.attrs(visuallyHidden)}>, {word.starred}</span>{/if}
1069
1083
  </span>
1070
1084
  {#if isSelected}
1071
1085
  <span {...stylex.attrs(styles.check)}><Glyph name="check" stroke={1.75} /></span>
@@ -12,7 +12,6 @@
12
12
  import type { Snippet } from 'svelte';
13
13
  import Glyph, { type GlyphName } from '../../internal/Glyph.svelte';
14
14
  import { attrs, type Sx } from '../../internal/sx.js';
15
- import { visuallyHidden } from '../../visually-hidden.js';
16
15
  import { colors, density, font, radius, space } from '../../tokens.stylex.js';
17
16
  import Button from '../button/Button.svelte';
18
17
  import { text, type MessageTextSize } from '../message/styles.js';
@@ -27,7 +26,8 @@
27
26
  statusText?: string | undefined;
28
27
  /**
29
28
  * What the status means, in full: "Sends once the worktree's setup script succeeds".
30
- * Shown in a tooltip on the status, and read after it. Each status has its own.
29
+ * Shown in a tooltip on the status, and given as the status's description, so its text is
30
+ * the word alone. Each status has its own.
31
31
  */
32
32
  detail?: string | undefined;
33
33
  /**
@@ -207,6 +207,8 @@
207
207
  const word = $derived(statusText ?? STATUS[status]);
208
208
  // A word of the app's own has no meaning of Narvi's to explain it
209
209
  const meaning = $derived(detail ?? (statusText ? undefined : DETAIL[status]));
210
+ const uid = $props.id();
211
+ const meaningId = `${uid}-meaning`;
210
212
  </script>
211
213
 
212
214
  {#snippet statusLine(row: boolean)}
@@ -217,16 +219,21 @@
217
219
  <span
218
220
  {...props}
219
221
  data-slot="queued-message-status"
222
+ aria-describedby={meaningId}
220
223
  {...stylex.attrs(
221
224
  styles.status,
222
225
  row && styles.rowStatus,
223
226
  status === 'unsent' && styles.unsent
224
- )}>{word}<span {...stylex.attrs(visuallyHidden)}>, {meaning}</span></span
227
+ )}>{word}</span
225
228
  >
226
229
  {/snippet}
227
230
  </Tooltip.Trigger>
228
231
  <Tooltip.Content>{meaning}</Tooltip.Content>
229
232
  </Tooltip.Root>
233
+ <!-- Always there to describe the status, which the tooltip does only while open. Words
234
+ hidden inside it would be a box of their own, read as "After setup , Sends once…",
235
+ and would keep the word from being found on its own -->
236
+ <span id={meaningId} hidden>{meaning}</span>
230
237
  {:else}
231
238
  <span
232
239
  data-slot="queued-message-status"
@@ -8,7 +8,8 @@ export type QueuedMessageProps = {
8
8
  statusText?: string | undefined;
9
9
  /**
10
10
  * What the status means, in full: "Sends once the worktree's setup script succeeds".
11
- * Shown in a tooltip on the status, and read after it. Each status has its own.
11
+ * Shown in a tooltip on the status, and given as the status's description, so its text is
12
+ * the word alone. Each status has its own.
12
13
  */
13
14
  detail?: string | undefined;
14
15
  /**
@@ -1,5 +1,4 @@
1
1
  <script lang="ts" module>
2
- import { visuallyHidden } from '../../visually-hidden.js';
3
2
  import * as stylex from '@stylexjs/stylex';
4
3
  import type { Snippet } from 'svelte';
5
4
  import { shared } from '../../internal/shared.js';
@@ -123,6 +122,15 @@
123
122
 
124
123
  const count = $derived(typeof badge === 'number' && badge > 0 ? badge : undefined);
125
124
  const dot = $derived(badge === true);
125
+ // Named in full, not by words hidden inside it: a hidden word is a box of its own, and a box
126
+ // is read with a space each side, as "Eregion , 2 new"
127
+ const name = $derived(
128
+ count !== undefined
129
+ ? `${label}, ${count} new`
130
+ : dot
131
+ ? `${label}, ${badgeTone === 'success' ? 'online' : 'new'}`
132
+ : label
133
+ );
126
134
  </script>
127
135
 
128
136
  {#snippet face()}
@@ -133,13 +141,11 @@
133
141
  {...stylex.attrs(styles.badge, badgeTone === 'success' && styles.badgeSuccess)}
134
142
  >{count > 99 ? '99+' : count}</span
135
143
  >
136
- <span {...stylex.attrs(visuallyHidden)}>, {count} new</span>
137
144
  {:else if dot}
138
145
  <span
139
146
  aria-hidden="true"
140
147
  {...stylex.attrs(styles.badge, styles.dot, badgeTone === 'success' && styles.badgeSuccess)}
141
148
  ></span>
142
- <span {...stylex.attrs(visuallyHidden)}>{badgeTone === 'success' ? ', online' : ', new'}</span>
143
149
  {/if}
144
150
  {/snippet}
145
151
 
@@ -151,13 +157,21 @@
151
157
  className
152
158
  )}
153
159
  {#if href !== undefined}
154
- <a {...props} {href} data-rail-item aria-current={current ? 'page' : undefined} {...own}>
155
- <span {...stylex.attrs(visuallyHidden)}>{label}</span>{@render face()}
160
+ <a
161
+ {...props}
162
+ {href}
163
+ aria-label={name}
164
+ data-rail-item
165
+ aria-current={current ? 'page' : undefined}
166
+ {...own}
167
+ >
168
+ {@render face()}
156
169
  </a>
157
170
  {:else}
158
171
  <button
159
172
  {...props}
160
173
  type="button"
174
+ aria-label={name}
161
175
  data-rail-item
162
176
  aria-current={current ? 'page' : undefined}
163
177
  {...own}
@@ -166,7 +180,7 @@
166
180
  onclick?.(event);
167
181
  }}
168
182
  >
169
- <span {...stylex.attrs(visuallyHidden)}>{label}</span>{@render face()}
183
+ {@render face()}
170
184
  </button>
171
185
  {/if}
172
186
  {/snippet}
@@ -280,6 +280,10 @@
280
280
  transitionTimingFunction: 'ease'
281
281
  }
282
282
  });
283
+
284
+ // The space after a picked row's hidden word, as an expression: Svelte trims a bare space at
285
+ // the end of a block
286
+ const SPACE = ' ';
283
287
  </script>
284
288
 
285
289
  <script lang="ts">
@@ -343,10 +347,11 @@
343
347
 
344
348
  {#snippet inside()}
345
349
  {#if leading}<span {...stylex.attrs(styles.lead)}>{@render leading()}</span>{/if}
350
+ <!-- The space after the hidden word is text of its own, so every reading of the name has it:
351
+ some pad a hidden box with spaces, some don't. On screen it starts the line, and goes -->
346
352
  <span {...stylex.attrs(styles.title)}
347
- >{#if picked && !option}<span {...stylex.attrs(visuallyHidden)}
348
- >{pickedLabel},
349
- </span>{/if}{@render children?.()}</span
353
+ >{#if picked && !option}<span {...stylex.attrs(visuallyHidden)}>{pickedLabel},</span
354
+ >{SPACE}{/if}{@render children?.()}</span
350
355
  >
351
356
  {#if trailing}
352
357
  <span {...stylex.attrs(styles.trail, actions && styles.trailHides)}>{@render trailing()}</span>
@@ -19,7 +19,6 @@
19
19
  own `panelId`. For a fixed set of sections that own their panel, use Tabs.
20
20
  -->
21
21
  <script lang="ts" module>
22
- import { visuallyHidden } from '../../visually-hidden.js';
23
22
  import * as stylex from '@stylexjs/stylex';
24
23
  import { tick, type Snippet } from 'svelte';
25
24
  import type { HTMLAttributes } from 'svelte/elements';
@@ -48,7 +47,9 @@
48
47
  renamable?: boolean | undefined;
49
48
  /**
50
49
  * A preview, which the next one opened takes the place of: in italics, and said as
51
- * "preview" after its name. A double-click calls `onkeep`, ahead of renaming.
50
+ * "preview" after its name. The italics are on the label inside the tab
51
+ * (`[data-slot="tab-strip-label"]`), not on the tab itself. A double-click calls `onkeep`,
52
+ * ahead of renaming.
52
53
  */
53
54
  temporary?: boolean | undefined;
54
55
  };
@@ -83,7 +84,10 @@
83
84
  addLabel?: string | undefined;
84
85
  /** The name of a tab's close button. */
85
86
  closeLabel?: ((tab: TabStripTab) => string) | undefined;
86
- /** Before a tab's label: an icon, or a StatusIndicator. */
87
+ /**
88
+ * Before a tab's label: an icon, or a StatusIndicator. It is not part of the tab's name,
89
+ * which is its label and what `temporary` and `mark` add: say a tab's state there.
90
+ */
87
91
  leading?: Snippet<[TabStripTab]> | undefined;
88
92
  /**
89
93
  * Buttons of a tab's own, after its label and before its close button: one that mutes a
@@ -537,6 +541,17 @@
537
541
  return others;
538
542
  }
539
543
 
544
+ // Named in full, not by words hidden inside it: a hidden word is a box of its own, and a box
545
+ // is read with a space each side, as "Fix the parser , preview"
546
+ const tabName = (tab: TabStripTab) =>
547
+ [
548
+ tab.label,
549
+ tab.temporary && 'preview',
550
+ tab.mark && (tab.mark === 'live' ? 'working' : 'unsaved')
551
+ ]
552
+ .filter(Boolean)
553
+ .join(', ');
554
+
540
555
  const renamable = (tab: TabStripTab) => !!onrename && tab.renamable !== false;
541
556
 
542
557
  function startRename(tab: TabStripTab) {
@@ -661,6 +676,7 @@
661
676
  aria-selected={selected}
662
677
  aria-controls={tab.panelId ?? controls}
663
678
  aria-current={selected ? 'true' : undefined}
679
+ aria-label={tabName(tab)}
664
680
  title={tab.title ?? tab.label}
665
681
  {...stylex.attrs(
666
682
  styles.button,
@@ -709,11 +725,10 @@
709
725
  {/if}
710
726
  </span>
711
727
  {/if}
712
- <span {...stylex.attrs(styles.text, tab.temporary && styles.temporary)}>{tab.label}</span
713
- >{#if tab.temporary}<span {...stylex.attrs(visuallyHidden)}>, preview</span>{/if}
714
- {#if tab.mark}<span {...stylex.attrs(visuallyHidden)}
715
- >, {tab.mark === 'live' ? 'working' : 'unsaved'}</span
716
- >{/if}
728
+ <span
729
+ data-slot="tab-strip-label"
730
+ {...stylex.attrs(styles.text, tab.temporary && styles.temporary)}>{tab.label}</span
731
+ >
717
732
  </button>
718
733
  {/if}
719
734
  {#if trailing}
@@ -16,7 +16,9 @@ export type TabStripTab = {
16
16
  renamable?: boolean | undefined;
17
17
  /**
18
18
  * A preview, which the next one opened takes the place of: in italics, and said as
19
- * "preview" after its name. A double-click calls `onkeep`, ahead of renaming.
19
+ * "preview" after its name. The italics are on the label inside the tab
20
+ * (`[data-slot="tab-strip-label"]`), not on the tab itself. A double-click calls `onkeep`,
21
+ * ahead of renaming.
20
22
  */
21
23
  temporary?: boolean | undefined;
22
24
  };
@@ -47,7 +49,10 @@ export type TabStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'o
47
49
  addLabel?: string | undefined;
48
50
  /** The name of a tab's close button. */
49
51
  closeLabel?: ((tab: TabStripTab) => string) | undefined;
50
- /** Before a tab's label: an icon, or a StatusIndicator. */
52
+ /**
53
+ * Before a tab's label: an icon, or a StatusIndicator. It is not part of the tab's name,
54
+ * which is its label and what `temporary` and `mark` add: say a tab's state there.
55
+ */
51
56
  leading?: Snippet<[TabStripTab]> | undefined;
52
57
  /**
53
58
  * Buttons of a tab's own, after its label and before its close button: one that mutes a
@@ -78,6 +78,11 @@ export type TypeRole = keyof typeof typography;
78
78
  * the mark it sits on). Without `monogram.mark` on an ancestor the letter is sized from the
79
79
  * window, so never use `letter` alone.
80
80
  *
81
+ * `mark` makes the mark a size container, so what is inside it no longer sizes it: a mark with
82
+ * no width and height of its own collapses to nothing, letter and all: give it both. It is
83
+ * `size`, not `inline-size`, because the letter is sized from the shorter side, which may be
84
+ * the height.
85
+ *
81
86
  * <span {...stylex.attrs(monogram.mark, styles.mark)}>
82
87
  * <span {...stylex.attrs(monogram.letter)}>AL</span>
83
88
  * </span>
@@ -89,6 +89,11 @@ export const typography = stylex.create({
89
89
  * the mark it sits on). Without `monogram.mark` on an ancestor the letter is sized from the
90
90
  * window, so never use `letter` alone.
91
91
  *
92
+ * `mark` makes the mark a size container, so what is inside it no longer sizes it: a mark with
93
+ * no width and height of its own collapses to nothing, letter and all: give it both. It is
94
+ * `size`, not `inline-size`, because the letter is sized from the shorter side, which may be
95
+ * the height.
96
+ *
92
97
  * <span {...stylex.attrs(monogram.mark, styles.mark)}>
93
98
  * <span {...stylex.attrs(monogram.letter)}>AL</span>
94
99
  * </span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegopluna/narvi",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "packageManager": "pnpm@12.18.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -12,7 +12,7 @@ metadata:
12
12
  Grid, and Narvi's conventions for colour, labels and copy.
13
13
  type: core
14
14
  library: '@diegopluna/narvi'
15
- library_version: '0.4.0'
15
+ library_version: '0.4.1'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -425,7 +425,7 @@ Parts of a thread that are easy to redraw by hand, and shouldn't be:
425
425
  - **Composer.ModelPicker** takes `bind:open`, and `multiple` with `value: string[]` to pick
426
426
  several, `providers` (a `provider` on each model) for a rail of agents beside the list,
427
427
  `searchable` for a field that searches them all, and `bind:starred` (values; keep them where
428
- they last) for stars, ⌘D included, and a Starred place in the rail. A model's `older` folds it into one row; `bind:also` adds models beside the chosen one with Shift or ⌘. `Composer.Toggle` works outside a `Composer.Root` too.
428
+ they last) for stars, ⌘D included, and a Starred place in the rail; a starred option is named "Ithil 2, Starred". A model's `older` folds it into one row; `bind:also` adds models beside the chosen one with Shift or ⌘. `Composer.Toggle` works outside a `Composer.Root` too.
429
429
  - **Composer.Tray** opens its shelf only for a child with height (measured), so an empty wrapper
430
430
  opens none; `waiting` overrides. Its `queue` scrolls; read [the tray](references/components.md#the-composers-tray).
431
431
  - **A user's message with attachments:** `<Message.Content bubble={false}>` is a column at the
@@ -99,7 +99,10 @@ for a tab's own buttons, `beside` for the tab shown in a split, and per tab `tab
99
99
  a menu. A middle click anywhere on a tab calls `onclose` (and neither scrolls nor pastes).
100
100
 
101
101
  A preview tab, which the next one opened replaces, is `temporary: true`: in italics and said as
102
- "preview". A double-click on it calls `onkeep(id)` instead of renaming; set its `temporary` to
102
+ "preview". A tab's name is its label, then "preview" and "working" or "unsaved" (from `mark`),
103
+ joined with commas: `getByRole('tab', { name: 'Fix the parser, preview' })`. `leading` is not
104
+ part of it. The italics are on `[data-slot="tab-strip-label"]` inside the tab, so a test of
105
+ `font-style` on `role=tab` sees `normal`. A double-click on it calls `onkeep(id)` instead of renaming; set its `temporary` to
103
106
  false there, and offer "Keep open" in its `menu` for the keyboard. Don't mark tabs with a
104
107
  `MutationObserver`, or listen for `dblclick` or `auxclick` around the strip: the strip does it.
105
108
 
@@ -207,6 +210,10 @@ sidebar, the page and the panel go inside the sheet. The bar is where macOS's tr
207
210
  in a desktop window with a hidden title bar: set `windowInset` on the root to the room they take
208
211
  (about `5.25rem` since macOS 26, `4.5rem` before, `0px` in full screen and off macOS).
209
212
 
213
+ A `Rail.Item` is named whole, its `label` and then its badge in words, joined with a comma:
214
+ `getByRole('button', { name: 'Eregion, 2 new' })`, or `', new'` and `', online'` for a dot.
215
+ What it shows inside, such as initials, is not read.
216
+
210
217
  ```svelte
211
218
  <AppShell.Root bind:sidebarOpen windowInset="5.25rem">
212
219
  <AppShell.Bar>
@@ -439,8 +446,9 @@ the request nearest the composer, and what waits behind it in a region that scro
439
446
  - **`QueuedMessage`**: `compact` is one line, cut with an ellipsis, so give it words, not
440
447
  blocks. `handle` is a snippet at its start: put your drag-and-drop library's attachment on
441
448
  the Button (Narvi's Button passes `{@attach}` on). `status` and `statusText` are one word;
442
- what it means goes in `detail`, shown in a tooltip and read after the word. Never join them
443
- with a dot. `attachments` sits after the words in the row: keep it to a count.
449
+ what it means goes in `detail`, shown in a tooltip and given as the status's description
450
+ (`toHaveAccessibleDescription`), so the status's text is the word alone and an exact
451
+ `getByText('Queued')` finds it. Never join them with a dot. `attachments` sits after the words in the row: keep it to a count.
444
452
 
445
453
  ## Utilities
446
454
 
@@ -12,7 +12,7 @@ metadata:
12
12
  patching the DOM, and decide which links and images text from a model may load.
13
13
  type: core
14
14
  library: '@diegopluna/narvi'
15
- library_version: '0.4.0'
15
+ library_version: '0.4.1'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -11,7 +11,7 @@ metadata:
11
11
  4 when the app uses it.
12
12
  type: lifecycle
13
13
  library: '@diegopluna/narvi'
14
- library_version: '0.4.0'
14
+ library_version: '0.4.1'
15
15
  sources:
16
16
  - src/lib/vite.ts
17
17
  - src/lib/base.css
@@ -12,7 +12,7 @@ metadata:
12
12
  hover, motion and forced-colour preferences.
13
13
  type: core
14
14
  library: '@diegopluna/narvi'
15
- library_version: '0.4.0'
15
+ library_version: '0.4.1'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -111,7 +111,9 @@ package root) breaks them.
111
111
  `monogram.letter` on the letter, or on a badge inside the mark. The letter is a quarter of
112
112
  the mark's shorter side plus 4px (a 16px mark gives 8px, 24px gives 10px) and follows the
113
113
  mark when it is resized. Without `monogram.mark` on an ancestor the letter is sized from the
114
- window, so never use `monogram.letter` alone. `Avatar` already does this.
114
+ window, so never use `monogram.letter` alone. `Avatar` already does this. `monogram.mark` is
115
+ `container-type: size`, so the mark's contents no longer size it: give the mark a width and a
116
+ height of its own, or it collapses to nothing.
115
117
  - `visuallyHidden` (from the package root) hides an element from sight and keeps it for
116
118
  assistive technology: `stylex.attrs(visuallyHidden)`. Don't write your own.
117
119
  - `focusRing` (from the package root) is focus as Narvi's parts show it. `focusRing.ring` goes on
@@ -12,7 +12,7 @@ metadata:
12
12
  menus and dialogs, and resolve token colours for drawing code that cannot read CSS variables.
13
13
  type: core
14
14
  library: '@diegopluna/narvi'
15
- library_version: '0.4.0'
15
+ library_version: '0.4.1'
16
16
  requires:
17
17
  - setup
18
18
  sources: