@diegopluna/narvi 0.3.13 → 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.
Files changed (66) hide show
  1. package/dist/components/app-shell/AppShellHeader.svelte +15 -2
  2. package/dist/components/app-shell/AppShellStrip.svelte +41 -0
  3. package/dist/components/app-shell/AppShellStrip.svelte.d.ts +10 -0
  4. package/dist/components/app-shell/index.d.ts +3 -1
  5. package/dist/components/app-shell/index.js +2 -1
  6. package/dist/components/approval/Approval.svelte +147 -13
  7. package/dist/components/approval/Approval.svelte.d.ts +22 -0
  8. package/dist/components/avatar/AvatarFallback.svelte +2 -1
  9. package/dist/components/avatar/AvatarRoot.svelte +9 -6
  10. package/dist/components/composer/ComposerModelPicker.svelte +15 -1
  11. package/dist/components/composer/ComposerTray.svelte +150 -10
  12. package/dist/components/composer/ComposerTray.svelte.d.ts +15 -3
  13. package/dist/components/heading/Heading.svelte +2 -1
  14. package/dist/components/markdown/MarkdownHtml.svelte +7 -3
  15. package/dist/components/markdown/MarkdownTable.svelte +19 -5
  16. package/dist/components/markdown/styles.d.ts +0 -17
  17. package/dist/components/markdown/styles.js +4 -20
  18. package/dist/components/plan/Plan.svelte +146 -28
  19. package/dist/components/plan/Plan.svelte.d.ts +17 -2
  20. package/dist/components/queued-message/QueuedMessage.svelte +185 -49
  21. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +26 -4
  22. package/dist/components/rail/RailItem.svelte +20 -6
  23. package/dist/components/sidebar/SidebarItem.svelte +8 -3
  24. package/dist/components/tab-strip/TabStrip.svelte +140 -17
  25. package/dist/components/tab-strip/TabStrip.svelte.d.ts +23 -1
  26. package/dist/components/table/TableBody.svelte +27 -0
  27. package/dist/components/table/TableBody.svelte.d.ts +10 -0
  28. package/dist/components/table/TableCell.svelte +54 -0
  29. package/dist/components/table/TableCell.svelte.d.ts +17 -0
  30. package/dist/components/table/TableFoot.svelte +39 -0
  31. package/dist/components/table/TableFoot.svelte.d.ts +10 -0
  32. package/dist/components/table/TableHead.svelte +33 -0
  33. package/dist/components/table/TableHead.svelte.d.ts +10 -0
  34. package/dist/components/table/TableHeaderCell.svelte +61 -0
  35. package/dist/components/table/TableHeaderCell.svelte.d.ts +17 -0
  36. package/dist/components/table/TableRoot.svelte +144 -0
  37. package/dist/components/table/TableRoot.svelte.d.ts +22 -0
  38. package/dist/components/table/TableRow.svelte +59 -0
  39. package/dist/components/table/TableRow.svelte.d.ts +12 -0
  40. package/dist/components/table/context.d.ts +14 -0
  41. package/dist/components/table/context.js +15 -0
  42. package/dist/components/table/index.d.ts +16 -0
  43. package/dist/components/table/index.js +8 -0
  44. package/dist/components/table/styles.d.ts +56 -0
  45. package/dist/components/table/styles.js +44 -0
  46. package/dist/components/text/Text.svelte +19 -4
  47. package/dist/components/text/Text.svelte.d.ts +4 -2
  48. package/dist/components/work-fold/WorkFold.svelte +26 -1
  49. package/dist/components/work-fold/WorkFold.svelte.d.ts +5 -0
  50. package/dist/index.d.ts +4 -1
  51. package/dist/index.js +7 -1
  52. package/dist/internal/markers.stylex.d.ts +4 -0
  53. package/dist/internal/markers.stylex.js +2 -0
  54. package/dist/internal/table.d.ts +29 -0
  55. package/dist/internal/table.js +34 -0
  56. package/dist/tokens.stylex.d.ts +2 -0
  57. package/dist/tokens.stylex.js +9 -3
  58. package/dist/typography.d.ts +45 -1
  59. package/dist/typography.js +47 -2
  60. package/package.json +1 -1
  61. package/skills/building-ui/SKILL.md +23 -23
  62. package/skills/building-ui/references/components.md +204 -42
  63. package/skills/markdown/SKILL.md +1 -1
  64. package/skills/setup/SKILL.md +1 -1
  65. package/skills/styling/SKILL.md +23 -5
  66. package/skills/theming/SKILL.md +1 -1
@@ -7,46 +7,86 @@ component: import the namespace (`Dialog`) and use `Dialog.Root`. Docs and live
7
7
 
8
8
  ## Layout and text
9
9
 
10
- | Component | Use it for | Docs slug |
11
- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
12
- | `Stack` | Children in a column or a row, with even gaps, by breakpoint | `stack` |
13
- | `Grid` | Children in columns (a count or a template), by breakpoint | `grid` |
14
- | `Card` | A surface that groups related content; `href` makes the whole card a link | `card` |
15
- | `Frame` | A tray around an inset panel, with an optional title: Narvi's signature container | `frame` |
16
- | `Separator` | A thin line between groups | `separator` |
17
- | `Heading` | A title: `level` for the outline, `size` for the look | `heading` |
18
- | `Text` | Text in a role (`variant`: `title`, `reading`, `label`, `body`, `meta`, `caption`, `micro`, `lead`), in the page's face or the display serif | `text` |
19
- | `Link` | A link inside running text | `link` |
20
- | `List.Root`, `.Item` | Rows on one card, with a line between each | `list` |
21
- | `Code` | A short piece of code inside text | `code` |
22
- | `Markdown` | Markdown, streamed or finished: an AI reply, a README (see the `markdown` skill) | `markdown` |
23
- | `Kbd` | A key cap, for shortcuts. Inside a `Button` it takes the button's ink, and in a flex row it keeps its width | `kbd` |
24
- | `Reveal` | Eases part of a scrolled page into place. For marketing pages, not apps | `reveal` |
25
- | `Theme` | Sets the scheme or a custom theme for part of the page (see `theming`) | `theme` |
10
+ | Component | Use it for | Docs slug |
11
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
12
+ | `Stack` | Children in a column or a row, with even gaps, by breakpoint | `stack` |
13
+ | `Grid` | Children in columns (a count or a template), by breakpoint | `grid` |
14
+ | `Card` | A surface that groups related content; `href` makes the whole card a link | `card` |
15
+ | `Frame` | A tray around an inset panel, with an optional title: Narvi's signature container | `frame` |
16
+ | `Separator` | A thin line between groups | `separator` |
17
+ | `Heading` | A title: `level` for the outline, `size` for the look | `heading` |
18
+ | `Text` | Text in a role (`variant`: `title`, `reading`, `label`, `body`, `meta`, `caption`, `micro`, `lead`), in the page's face or the display serif | `text` |
19
+ | `Link` | A link inside running text | `link` |
20
+ | `List.Root`, `.Item` | Rows on one card, with a line between each | `list` |
21
+ | `Table.Root` and parts | Rows of data (a CSV file, usage, totals) in a frame that scrolls both ways, with its head and foot kept in view | `table` |
22
+ | `Code` | A short piece of code inside text | `code` |
23
+ | `Markdown` | Markdown, streamed or finished: an AI reply, a README (see the `markdown` skill) | `markdown` |
24
+ | `Kbd` | A key cap, for shortcuts. Inside a `Button` it takes the button's ink, and in a flex row it keeps its width | `kbd` |
25
+ | `Reveal` | Eases part of a scrolled page into place. For marketing pages, not apps | `reveal` |
26
+ | `Theme` | Sets the scheme or a custom theme for part of the page (see `theming`) | `theme` |
27
+
28
+ ### Tables
29
+
30
+ `Table.Root` (`label` is required) holds `Table.Head`, `Table.Body` and `Table.Foot`, each of
31
+ `Table.Row`s of `Table.HeaderCell`s and `Table.Cell`s. Don't draw a `<table>` of your own or copy
32
+ Markdown's table styles: Markdown's tables and this one share their look.
33
+
34
+ ```svelte
35
+ <Table.Root label="usage.csv" rowNumbers truncate style="height: 18rem">
36
+ <Table.Head>
37
+ <Table.Row>
38
+ <Table.HeaderCell>provider</Table.HeaderCell>
39
+ <Table.HeaderCell numeric>tokens</Table.HeaderCell>
40
+ </Table.Row>
41
+ </Table.Head>
42
+ <Table.Body>
43
+ {#each rows as row, at (at)}
44
+ <Table.Row>
45
+ <Table.Cell title={row.provider}>{row.provider}</Table.Cell>
46
+ <Table.Cell numeric>{row.tokens}</Table.Cell>
47
+ </Table.Row>
48
+ {/each}
49
+ </Table.Body>
50
+ </Table.Root>
51
+ ```
52
+
53
+ - Give the root a height (`style="height: 18rem"`, or `sx` with `flexGrow: 1, minHeight: 0` in a
54
+ flex column) and it scrolls inside its edge, the head kept at the top and the foot at the
55
+ bottom. Wide columns scroll sideways without a wrapper of yours. On a card, pass `raised`.
56
+ - `numeric` on a cell, and on its column's header cell, puts it at the end; digits line up in
57
+ every cell. `align` (`start | center | end`) for anything else.
58
+ - `rowNumbers` on the root numbers the body's rows from one; `number` on a `Table.Row` when the
59
+ rows shown are not the first.
60
+ - A cell wraps at 24rem. `truncate` (on the root, or a cell) keeps it to one line: give the cell
61
+ a `title` with the whole of it.
62
+ - `Table.Foot` is for a row of totals. A summary of the table ("120 rows", "Comma separated")
63
+ goes under the root, each part its own `Text variant="caption"`, not joined with a dot.
64
+ - A `Table.HeaderCell` in the body names its row (`scope="row"` is set for you). Cells are in the
65
+ text's face; put `Code` in a cell when the data is code.
26
66
 
27
67
  ## Controls and forms
28
68
 
29
- | Component | Use it for | Docs slug |
30
- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
31
- | `Button` | An action; `href` makes it a link; `variant` (12, from `primary` to `success-outline`), `size` (`micro` to `lg`), `shape`, `justify`, `loading`, `iconOnly`, `pressed`, `tooltip` | `button` |
32
- | `Field` | Label, help text and error around one control | `field` |
33
- | `Input` | One line of text | `input` |
34
- | `Textarea` | Several lines of text | `textarea` |
35
- | `Select` | One choice from a short list (`options: { value, label, icon?, detail?, detailMono?, group? }[]`, `align`, `optionIcon`) | `select` |
36
- | `Checkbox` | An option on or off, or several from a list | `checkbox` |
37
- | `ChoiceCards` | One choice among a few, each a card with a title and a line of detail | `choice-cards` |
38
- | `Switch` | A setting that takes effect at once | `switch` |
39
- | `SegmentedControl` | One of a few options, all visible (`options: { value, label, title? }[]`, `onchange`) | `segmented-control` |
40
- | `Slider` | A value or a range along a track | `slider` |
41
- | `ColorField` | A colour: a swatch that opens Narvi's picker, beside a hex field (`label`, `bind:value`, `onchange`, `size`, `labels`) | `color-field` |
42
- | `SplitButton` | A main action joined to a menu of how to do it (`menu`, `menuLabel`, `label`, `variant` incl. `ghost`, `shape`, `mainDisabled`, `mainSx`/`menuSx`, `menuMinWidth`) | `split-button` |
43
- | `Toggle` | A button that stays pressed (`tone`: `accent`, or `neutral` for toolbar icons) | `toggle` |
44
- | `ToggleGroup.Root`, `.Item` | Toggles that belong together: one pressed, or any number | `toggle-group` |
45
- | `SettingsGroup` | A titled group of settings: a heading, an action, the rows on one card | `settings-group` |
46
- | `SettingsRow` | One setting: what it is, beside its control (`leading`, `dimmed`, `mono`) | `settings-row` |
47
- | `Tabs` | Views that share one place (`items: TabItem[]`) | `tabs` |
48
- | `SearchButton` | Looks like a search field and opens search (`label`, `shortcut`): for a window's bar | `search-button` |
49
- | `TabStrip` | Tabs for what is open in a pane: closable, addable, scrolling (`tabs`, `bind:value`, `onclose`, `onadd`); `menu`, `onmove`, `onrename`, `trailing`. The panels are yours | `tab-strip` |
69
+ | Component | Use it for | Docs slug |
70
+ | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
71
+ | `Button` | An action; `href` makes it a link; `variant` (12, from `primary` to `success-outline`), `size` (`micro` to `lg`), `shape`, `justify`, `loading`, `iconOnly`, `pressed`, `tooltip` | `button` |
72
+ | `Field` | Label, help text and error around one control | `field` |
73
+ | `Input` | One line of text | `input` |
74
+ | `Textarea` | Several lines of text | `textarea` |
75
+ | `Select` | One choice from a short list (`options: { value, label, icon?, detail?, detailMono?, group? }[]`, `align`, `optionIcon`) | `select` |
76
+ | `Checkbox` | An option on or off, or several from a list | `checkbox` |
77
+ | `ChoiceCards` | One choice among a few, each a card with a title and a line of detail | `choice-cards` |
78
+ | `Switch` | A setting that takes effect at once | `switch` |
79
+ | `SegmentedControl` | One of a few options, all visible (`options: { value, label, title? }[]`, `onchange`) | `segmented-control` |
80
+ | `Slider` | A value or a range along a track | `slider` |
81
+ | `ColorField` | A colour: a swatch that opens Narvi's picker, beside a hex field (`label`, `bind:value`, `onchange`, `size`, `labels`) | `color-field` |
82
+ | `SplitButton` | A main action joined to a menu of how to do it (`menu`, `menuLabel`, `label`, `variant` incl. `ghost`, `shape`, `mainDisabled`, `mainSx`/`menuSx`, `menuMinWidth`) | `split-button` |
83
+ | `Toggle` | A button that stays pressed (`tone`: `accent`, or `neutral` for toolbar icons) | `toggle` |
84
+ | `ToggleGroup.Root`, `.Item` | Toggles that belong together: one pressed, or any number | `toggle-group` |
85
+ | `SettingsGroup` | A titled group of settings: a heading, an action, the rows on one card | `settings-group` |
86
+ | `SettingsRow` | One setting: what it is, beside its control (`leading`, `dimmed`, `mono`) | `settings-row` |
87
+ | `Tabs` | Views that share one place (`items: TabItem[]`) | `tabs` |
88
+ | `SearchButton` | Looks like a search field and opens search (`label`, `shortcut`): for a window's bar | `search-button` |
89
+ | `TabStrip` | Tabs for what is open in a pane: closable, addable, scrolling (`tabs`, `bind:value`, `onclose`, `onadd`); `menu`, `onmove`, `onrename`, `onkeep`, `trailing`, `variant`. The panels are yours | `tab-strip` |
50
90
 
51
91
  ### Tab strips
52
92
 
@@ -56,7 +96,41 @@ right-click, the menu key, a long press), `onmove(id, index)` (drag, or Alt+Shif
56
96
  for a tab's own buttons, `beside` for the tab shown in a split, and per tab `tabId`, `panelId`,
57
97
  `title`, `renamable`. Arrows open the tab they reach (`activation="manual"` only moves focus);
58
98
  `onchange(id)`; a name cleared comes as `''`; `addMenu` (Menu parts) makes the add button open
59
- a menu.
99
+ a menu. A middle click anywhere on a tab calls `onclose` (and neither scrolls nor pastes).
100
+
101
+ A preview tab, which the next one opened replaces, is `temporary: true`: in italics and said as
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
106
+ false there, and offer "Keep open" in its `menu` for the keyboard. Don't mark tabs with a
107
+ `MutationObserver`, or listen for `dblclick` or `auxclick` around the strip: the strip does it.
108
+
109
+ Workspace tabs across the page's header take `variant="notch"`: the open tab is the colour of the
110
+ page under the header and runs down into it, with a curve each side and no line or shadow. Put
111
+ the strip in `AppShell.Strip`, which runs the header's full height; the header then becomes a
112
+ band of `colors.bg` with no line under it, and its other parts stay centred. Give the band
113
+ another colour with the header's `sx`, and if the page under it is not `colors.bgRaised`, set
114
+ `--narvi-tab-surface` to its colour (StyleX tokens can't be read from plain CSS, so don't copy
115
+ the colour into global CSS of your own).
116
+
117
+ ```svelte
118
+ <AppShell.Header>
119
+ <AppShell.Toggle when="closed" />
120
+ <AppShell.Strip>
121
+ <TabStrip
122
+ variant="notch"
123
+ label="Open tabs"
124
+ {tabs}
125
+ bind:value
126
+ onclose={closeTab}
127
+ onkeep={keepTab}
128
+ onadd={newTab}
129
+ />
130
+ </AppShell.Strip>
131
+ <Button size="sm" variant="ghost" iconOnly aria-label="Show the panel">…</Button>
132
+ </AppShell.Header>
133
+ ```
60
134
 
61
135
  ### Colour fields
62
136
 
@@ -126,7 +200,7 @@ errors with an `Announcer` too.
126
200
 
127
201
  | Component | Use it for | Docs slug |
128
202
  | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ----------- |
129
- | `AppShell.Root` (`bind:sidebarOpen`, `windowInset`), `.Bar` (`center`, `end` snippets), `.Rail`, `.Panes`, `.Sheet` (`flush`), `.Sidebar`, `.Main`, `.Header` (`drag`), `.Panel` (`bind:width`), `.Toggle` (`when`) | The window: its bar, a rail, and one sheet for the sidebar, the page and a side panel | `app-shell` |
203
+ | `AppShell.Root` (`bind:sidebarOpen`, `windowInset`), `.Bar` (`center`, `end` snippets), `.Rail`, `.Panes`, `.Sheet` (`flush`), `.Sidebar`, `.Main`, `.Header` (`drag`, `divider`), `.Strip`, `.Panel` (`bind:width`), `.Toggle` (`when`) | The window: its bar, a rail, and one sheet for the sidebar, the page and a side panel | `app-shell` |
130
204
  | `Sidebar.Root` (`label`), `.Header` (`drag`), `.Content` (`label`, `pinned` snippet), `.Group` (`label`, `collapsible`, `keepCurrent`, `actions`), `.Folder` (`bind:open`, `leading`, `trailing` snippets), `.Item` (`current`, `picked`, `disabled`, `as`, `itemProps`, `leading`, `trailing`, `meta`, `actions` snippets), `.Switcher` (`leading`, `aside`), `.Footer` | A column of rows, in groups and folders. `Root` is for one on its own; in an app shell the same parts go in `AppShell.Sidebar` | `sidebar` |
131
205
  | `Rail.Root` (`label`), `.Item` (`label`, `href`, `current`, `badge`, `badgeTone`, `shortcut`), `.Separator`, `.Spacer` | A narrow strip of places to go: workspaces, settings. On its own beside a page, or in `AppShell.Rail` | `rail` |
132
206
  | `ResizeHandle` | A draggable edge between two areas | none |
@@ -136,6 +210,10 @@ sidebar, the page and the panel go inside the sheet. The bar is where macOS's tr
136
210
  in a desktop window with a hidden title bar: set `windowInset` on the root to the room they take
137
211
  (about `5.25rem` since macOS 26, `4.5rem` before, `0px` in full screen and off macOS).
138
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
+
139
217
  ```svelte
140
218
  <AppShell.Root bind:sidebarOpen windowInset="5.25rem">
141
219
  <AppShell.Bar>
@@ -263,11 +341,11 @@ Docs slug: `agent-timeline`.
263
341
  | Component | Use it for |
264
342
  | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
265
343
  | `Activity.Root`, `.Trigger`, `.Content`, `.Step`, `.Thought`, `.Icon` | A stretch of work: says what the agent is doing, then what it did. `.Icon` starts a row of your own |
266
- | `WorkFold` | Folds a finished turn's work behind "Worked for 2m 5s" |
267
- | `Plan` (`steps: { label, status }[]`) | What the agent means to do, ticked off as it goes |
344
+ | `WorkFold` (`label`, `trailing`) | Folds a finished turn's work behind "Worked for 2m 5s"; `trailing` puts the turn's totals (a `ChangeStats`) on that line, outside the button |
345
+ | `Plan` (`steps: { label, status }[]`) | What the agent means to do, ticked off as it goes; `fold` for the tray, `bare` and `title={null}` in a card |
268
346
  | `Approval` | The agent asks before acting; folds into the decision once answered. A choice's `shortcut` (`mod+enter`, `mod+backspace`, `enter`, `escape`) shows on its button and makes it |
269
347
  | `Questionnaire` | Questions one at a time, with keys 1–9 to pick, arrows between answers and questions, and ⌘Enter to send once all are answered; `secret` answers; `busy`; `heading`; `bare` |
270
- | `QueuedMessage` | A message sent while the agent was still working, waiting its turn (`attachments`, `disabled`) |
348
+ | `QueuedMessage` | A message sent while the agent was still working, waiting its turn (`attachments`, `disabled`, `detail`); `compact` with a `handle` for the tray |
271
349
  | `ChangesSummary` (`ChangedFile[]`), `ChangeStats` (`additions`, `deletions`) | What a turn changed, and +12 −3 counts |
272
350
  | `Divider` (`label`, or children; `role`) | A labelled break in a timeline: a new day, "Context compacted" |
273
351
 
@@ -288,6 +366,90 @@ to fit and in the step's colour. Inside an opened row the icon stays quiet: grey
288
366
  with its spinner (the row above is what is lit), and a faint red when it did not go through, its
289
367
  badge saying it in words. Don't recolour it with a wrapper of your own.
290
368
 
369
+ A timeline row of your own starts with `Activity.Icon` (`kind`, `tone`, `spinning`, or your own
370
+ icon as children), as the others' do. `Activity.Thought` takes a snippet, such as Markdown, in
371
+ place of `text`. `Activity.Step` takes `wrap` for a label that runs on, and `status="neutral"` for
372
+ a step that settled without going through or failing ("Skipped", `statusLabels.neutral`); it and
373
+ `WorkFold` pass `data-*` attributes on.
374
+
375
+ ### The composer's tray
376
+
377
+ Read this when putting what waits on the person in `Composer.Tray`. The tray keeps itself short:
378
+ the request nearest the composer, and what waits behind it in a region that scrolls.
379
+
380
+ ```svelte
381
+ <script lang="ts">
382
+ import { Approval, Button, Composer, Plan, QueuedMessage } from '@diegopluna/narvi';
383
+
384
+ let shown = $state(0); // which of the waiting approvals is shown
385
+ </script>
386
+
387
+ <Composer.Tray>
388
+ {#snippet queue()}
389
+ <Plan fold steps={plan} />
390
+ {#each queued as message, index (message.id)}
391
+ <QueuedMessage
392
+ compact
393
+ status={editing === message.id ? 'editing' : 'queued'}
394
+ onedit={() => edit(message)}
395
+ ontakeback={() => takeBack(message)}
396
+ >
397
+ {#snippet handle()}
398
+ <Button variant="ghost" size="xs" iconOnly aria-label="Move queued message, {index + 1}">
399
+ <GripVertical />
400
+ </Button>
401
+ {/snippet}
402
+ {message.text}
403
+ </QueuedMessage>
404
+ {/each}
405
+ {/snippet}
406
+ {#snippet pending()}
407
+ {#if approvals.length}
408
+ {@const ask = approvals[shown]}
409
+ <Approval
410
+ compact
411
+ title="Run this command?"
412
+ command={ask.command}
413
+ index={shown}
414
+ count={approvals.length}
415
+ onindexchange={(index) => (shown = index)}
416
+ choices={ask.choices}
417
+ onchoose={(value) => answer(ask, value)}
418
+ />
419
+ {/if}
420
+ {/snippet}
421
+ <Composer.Root>…</Composer.Root>
422
+ </Composer.Tray>
423
+ ```
424
+
425
+ - **`queue`** holds the folded `Plan` and compact `QueuedMessage`s. It scrolls once taller than
426
+ `queueMaxHeight` (about a folded plan and four rows), with room at its edges for its buttons'
427
+ focus rings and 40px hit areas. Don't wrap it in a scrolling `div` of your own: that cuts them
428
+ off.
429
+ - **The shelf opens only for what has height.** The tray measures `pending` and `queue`: an empty
430
+ wrapper (hidden, or holding only whitespace, comments or empty elements) opens nothing, and a
431
+ queue holding only one takes no room. `waiting` overrides it: `true` holds the shelf open,
432
+ `false` keeps it shut. Held open with nothing to see, it warns in the console while developing
433
+ (`Composer.Tray "<label>": the shelf is open, but what is in it measures 0px tall`): render
434
+ nothing when nothing waits, or drop `waiting`. Before hydration the shelf is shut, so a
435
+ server-rendered page shows what waits once the app is running.
436
+ - **`Approval`**: `compact` takes less room (the command on one line that scrolls sideways).
437
+ With several waiting, show one with `index` (from 0) and `count`; it says "2 of 3", and with
438
+ `onindexchange` it has buttons to the others that wrap round. Clamp `index` when one is
439
+ answered and leaves. Its `mod` shortcuts answer the one shown, and leave the key to a field
440
+ with words typed in it: a textarea, an input, or a contenteditable editor (ProseMirror) whose
441
+ text isn't empty. An editor's placeholder must not be text in the element.
442
+ - **`Plan`**: `fold` is one row with the step under way (or the next, or the last once all are
443
+ done) and "1 of 3", opening to every step; `bind:open`. Outside the tray, `bare` drops its
444
+ edge and padding inside a card of yours, and `title={null}` its title (it is still named
445
+ "Plan", or by `aria-label`).
446
+ - **`QueuedMessage`**: `compact` is one line, cut with an ellipsis, so give it words, not
447
+ blocks. `handle` is a snippet at its start: put your drag-and-drop library's attachment on
448
+ the Button (Narvi's Button passes `{@attach}` on). `status` and `statusText` are one word;
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.
452
+
291
453
  ## Utilities
292
454
 
293
455
  - `sx()`, `classes()` and the `Sx` type: see the `styling` skill.
@@ -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.3.13'
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.3.13'
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.3.13'
15
+ library_version: '0.4.1'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -91,11 +91,29 @@ package root) breaks them.
91
91
  - `font`: `body` (inherits the page), `display` (the heading serif), `mono`; the weights
92
92
  `weightRegular`, `weightMedium` and `weightSemibold`; the line heights `leadingTight`,
93
93
  `leadingSnug` and `leadingNormal`; and sizes named for what they set: `sizeMicro` (11px),
94
- `sizeCaption` (12), `sizeMeta` (13), `sizeBody` (14), `sizeReading` (16), `sizeTitle` (17)
95
- and `sizeFigure` (28, a number that is the point of its place). Prefer a whole role to a
96
- size: `import { typography } from '@diegopluna/narvi'` gives `figure`, `title`, `reading`,
97
- `label`, `body`, `meta`, `caption` and `micro`, each a size, a weight and a line height, for
94
+ `sizeCaption` (12), `sizeMeta` (13), `sizeBody` (14), `sizeReading` (16), `sizeTitle` (17,
95
+ a dialog's, a section's or a detail page's title), and three figure sizes for a number that
96
+ is the point of its place, named for where it stands: `sizeFigureTile` (24, one among
97
+ several in a tile or a grid of totals), `sizeFigure` (36, the figure a card is about) and
98
+ `sizeFigurePage` (48, the one figure a page or view is about). Prefer a whole role to a
99
+ size: `import { typography } from '@diegopluna/narvi'` gives `figurePage`, `figure`,
100
+ `figureTile`, `title`, `reading`, `label`, `body`, `meta`, `caption` and `micro`, each a
101
+ size, a weight and a line height (the figures with `tabular-nums`), for
98
102
  `stylex.attrs(typography.caption, styles.count)`.
103
+ - There is no step between `title` (17) and `figureTile` (24). A page or detail heading
104
+ that wants 18px takes `title` (or `Heading size="lg"`, which is the same 17px); don't
105
+ write `1.125rem`.
106
+ - Pick a figure by where it stands, not by how big it should look: three figures side by
107
+ side are `figureTile`, even on a page.
108
+ - A letter inside a small mark (an avatar's initials, a monogram, the letter badge on a
109
+ provider's mark) takes no role and no written size. `import { monogram } from
110
+ '@diegopluna/narvi'`: `monogram.mark` on the mark (the box with a width and a height),
111
+ `monogram.letter` on the letter, or on a badge inside the mark. The letter is a quarter of
112
+ the mark's shorter side plus 4px (a 16px mark gives 8px, 24px gives 10px) and follows the
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. `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.
99
117
  - `visuallyHidden` (from the package root) hides an element from sight and keeps it for
100
118
  assistive technology: `stylex.attrs(visuallyHidden)`. Don't write your own.
101
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.3.13'
15
+ library_version: '0.4.1'
16
16
  requires:
17
17
  - setup
18
18
  sources: