@diegopluna/narvi 0.3.4 → 0.3.6

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 (63) hide show
  1. package/dist/components/app-shell/AppShellPanel.svelte +35 -4
  2. package/dist/components/badge/Badge.svelte +13 -1
  3. package/dist/components/badge/Badge.svelte.d.ts +6 -0
  4. package/dist/components/button/Button.svelte +80 -33
  5. package/dist/components/button/Button.svelte.d.ts +18 -0
  6. package/dist/components/command/CommandDialog.svelte +24 -2
  7. package/dist/components/command/CommandDialog.svelte.d.ts +12 -0
  8. package/dist/components/command/CommandItem.svelte +15 -4
  9. package/dist/components/command/CommandItem.svelte.d.ts +20 -4
  10. package/dist/components/command/CommandRoot.svelte +57 -2
  11. package/dist/components/command/CommandRoot.svelte.d.ts +25 -1
  12. package/dist/components/composer/ComposerModelPicker.svelte +608 -53
  13. package/dist/components/composer/ComposerModelPicker.svelte.d.ts +56 -1
  14. package/dist/components/composer/ComposerRoot.svelte.d.ts +1 -1
  15. package/dist/components/composer/ComposerSubmit.svelte +12 -2
  16. package/dist/components/composer/ComposerSubmit.svelte.d.ts +6 -0
  17. package/dist/components/composer/index.d.ts +1 -1
  18. package/dist/components/input/Input.svelte.d.ts +1 -1
  19. package/dist/components/menu/MenuCheckboxItem.svelte +14 -5
  20. package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +15 -4
  21. package/dist/components/menu/MenuItem.svelte +9 -3
  22. package/dist/components/menu/MenuItem.svelte.d.ts +11 -4
  23. package/dist/components/menu/MenuRadioItem.svelte +18 -9
  24. package/dist/components/menu/MenuRadioItem.svelte.d.ts +15 -4
  25. package/dist/components/menu/MenuSubTrigger.svelte +9 -3
  26. package/dist/components/menu/MenuSubTrigger.svelte.d.ts +11 -4
  27. package/dist/components/questionnaire/Questionnaire.svelte +100 -9
  28. package/dist/components/questionnaire/Questionnaire.svelte.d.ts +11 -0
  29. package/dist/components/queued-message/QueuedMessage.svelte +3 -2
  30. package/dist/components/rail/RailRoot.svelte +3 -3
  31. package/dist/components/segmented/SegmentedControl.svelte +2 -1
  32. package/dist/components/select/Select.svelte +11 -1
  33. package/dist/components/select/Select.svelte.d.ts +5 -0
  34. package/dist/components/settings-row/SettingsRow.svelte +3 -2
  35. package/dist/components/slider/Slider.svelte.d.ts +2 -2
  36. package/dist/components/split-button/SplitButton.svelte +14 -1
  37. package/dist/components/split-button/SplitButton.svelte.d.ts +7 -0
  38. package/dist/components/tab-strip/TabStrip.svelte +77 -20
  39. package/dist/components/tab-strip/TabStrip.svelte.d.ts +16 -3
  40. package/dist/components/tabs/Tabs.svelte +2 -1
  41. package/dist/components/textarea/Textarea.svelte.d.ts +1 -1
  42. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +1 -1
  43. package/dist/components/tooltip/TooltipProvider.svelte +23 -0
  44. package/dist/components/tooltip/TooltipProvider.svelte.d.ts +8 -0
  45. package/dist/components/tooltip/index.d.ts +4 -5
  46. package/dist/components/tooltip/index.js +3 -5
  47. package/dist/index.d.ts +3 -3
  48. package/dist/internal/ItemDescription.svelte +34 -0
  49. package/dist/internal/ItemDescription.svelte.d.ts +10 -0
  50. package/dist/internal/TooltipScope.svelte +19 -0
  51. package/dist/internal/TooltipScope.svelte.d.ts +7 -0
  52. package/dist/internal/roving.d.ts +3 -1
  53. package/dist/internal/roving.js +6 -3
  54. package/dist/media.stylex.d.ts +6 -0
  55. package/dist/media.stylex.js +6 -0
  56. package/dist/vite.js +4 -0
  57. package/package.json +20 -1
  58. package/skills/building-ui/SKILL.md +45 -37
  59. package/skills/building-ui/references/components.md +42 -42
  60. package/skills/markdown/SKILL.md +1 -1
  61. package/skills/setup/SKILL.md +1 -1
  62. package/skills/styling/SKILL.md +11 -2
  63. package/skills/theming/SKILL.md +1 -1
@@ -6,6 +6,7 @@
6
6
  import '../../internal/icons.css';
7
7
  import { groupTrigger } from '../../internal/tooltip-trigger.js';
8
8
  import * as Tooltip from '../tooltip/index.js';
9
+ import TooltipScope from '../../internal/TooltipScope.svelte';
9
10
  import { attrs, type Sx } from '../../internal/sx.js';
10
11
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
11
12
  import { media } from '../../media.stylex.js';
@@ -198,7 +199,7 @@
198
199
  {/each}
199
200
  {/snippet}
200
201
  {#if tabs.some((tab) => tab.title)}
201
- <Tooltip.Provider delayDuration={400}>{@render items()}</Tooltip.Provider>
202
+ <TooltipScope>{@render items()}</TooltipScope>
202
203
  {:else}
203
204
  {@render items()}
204
205
  {/if}
@@ -8,6 +8,6 @@ export type TextareaProps = Omit<HTMLTextareaAttributes, 'children'> & {
8
8
  sx?: Sx | undefined;
9
9
  ref?: HTMLTextAreaElement | null | undefined;
10
10
  };
11
- declare const Textarea: import("svelte").Component<TextareaProps, {}, "value" | "ref">;
11
+ declare const Textarea: import("svelte").Component<TextareaProps, {}, "ref" | "value">;
12
12
  type Textarea = ReturnType<typeof Textarea>;
13
13
  export default Textarea;
@@ -31,6 +31,6 @@ export type ToggleGroupRootProps = Html & Base & ({
31
31
  value?: string[] | undefined;
32
32
  onValueChange?: ((value: string[]) => void) | undefined;
33
33
  });
34
- declare const ToggleGroupRoot: import("svelte").Component<ToggleGroupRootProps, {}, "value" | "ref">;
34
+ declare const ToggleGroupRoot: import("svelte").Component<ToggleGroupRootProps, {}, "ref" | "value">;
35
35
  type ToggleGroupRoot = ReturnType<typeof ToggleGroupRoot>;
36
36
  export default ToggleGroupRoot;
@@ -0,0 +1,23 @@
1
+ <script lang="ts" module>
2
+ import type { Loose } from '../../internal/loose.js';
3
+ import { Tooltip } from 'bits-ui';
4
+ import { hasContext, setContext } from 'svelte';
5
+
6
+ export type TooltipProviderProps = Loose<Tooltip.ProviderProps>;
7
+
8
+ const PROVIDED = Symbol('narvi.tooltip.provider');
9
+
10
+ /** Whether a Tooltip.Provider of Narvi's is above the calling component. */
11
+ export const hasTooltipProvider = () => hasContext(PROVIDED);
12
+ </script>
13
+
14
+ <script lang="ts">
15
+ let { children, ...rest }: TooltipProviderProps = $props();
16
+
17
+ // Narvi's own parts with a tooltip find it, and take its delay rather than one of their own
18
+ setContext(PROVIDED, true);
19
+ </script>
20
+
21
+ <Tooltip.Provider {...rest}>
22
+ {@render children?.()}
23
+ </Tooltip.Provider>
@@ -0,0 +1,8 @@
1
+ import type { Loose } from '../../internal/loose.js';
2
+ import { Tooltip } from 'bits-ui';
3
+ export type TooltipProviderProps = Loose<Tooltip.ProviderProps>;
4
+ /** Whether a Tooltip.Provider of Narvi's is above the calling component. */
5
+ export declare const hasTooltipProvider: () => boolean;
6
+ declare const TooltipProvider: import("svelte").Component<Loose<Tooltip.ProviderProps>, {}, "">;
7
+ type TooltipProvider = ReturnType<typeof TooltipProvider>;
8
+ export default TooltipProvider;
@@ -1,14 +1,13 @@
1
- import { Tooltip } from 'bits-ui';
2
- import { type Loosened } from '../../internal/loose.js';
3
1
  import Content from './TooltipContent.svelte';
2
+ import Provider from './TooltipProvider.svelte';
4
3
  import Root from './TooltipRoot.svelte';
5
4
  import Trigger from './TooltipTrigger.svelte';
6
5
  /**
7
- * Place one Provider near the root of the app. Its delay applies to every
8
- * tooltip inside, and once one is open the next opens without waiting.
6
+ * Place one Provider near the root of the app. Its delay applies to every tooltip inside, Narvi's
7
+ * own parts' among them, and once one is open the next opens without waiting.
9
8
  */
10
- declare const Provider: Loosened<typeof Tooltip.Provider>;
11
9
  export { Provider, Root, Trigger, Content };
12
10
  export type { TooltipContentProps } from './TooltipContent.svelte';
11
+ export type { TooltipProviderProps } from './TooltipProvider.svelte';
13
12
  export type { TooltipRootProps } from './TooltipRoot.svelte';
14
13
  export type { TooltipTriggerProps } from './TooltipTrigger.svelte';
@@ -1,11 +1,9 @@
1
- import { Tooltip } from 'bits-ui';
2
- import { loose } from '../../internal/loose.js';
3
1
  import Content from './TooltipContent.svelte';
2
+ import Provider from './TooltipProvider.svelte';
4
3
  import Root from './TooltipRoot.svelte';
5
4
  import Trigger from './TooltipTrigger.svelte';
6
5
  /**
7
- * Place one Provider near the root of the app. Its delay applies to every
8
- * tooltip inside, and once one is open the next opens without waiting.
6
+ * Place one Provider near the root of the app. Its delay applies to every tooltip inside, Narvi's
7
+ * own parts' among them, and once one is open the next opens without waiting.
9
8
  */
10
- const Provider = loose(Tooltip.Provider);
11
9
  export { Provider, Root, Trigger, Content };
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export type { AvatarFallbackProps, AvatarImageProps, AvatarRootProps, AvatarSize
12
12
  export { default as Badge } from './components/badge/Badge.svelte';
13
13
  export type { BadgeProps, BadgeTone } from './components/badge/Badge.svelte';
14
14
  export { default as Button } from './components/button/Button.svelte';
15
- export type { ButtonProps, ButtonShape, ButtonSize, ButtonVariant } from './components/button/Button.svelte';
15
+ export type { ButtonJustify, ButtonProps, ButtonShape, ButtonSize, ButtonTooltipSide, ButtonVariant } from './components/button/Button.svelte';
16
16
  export { default as Card } from './components/card/Card.svelte';
17
17
  export type { CardPadding, CardProps, CardVariant } from './components/card/Card.svelte';
18
18
  export { default as ChangeStats } from './components/change-stats/ChangeStats.svelte';
@@ -31,7 +31,7 @@ export * as Command from './components/command/index.js';
31
31
  export type { CommandDialogProps, CommandEmptyProps, CommandFooterProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandRootProps } from './components/command/index.js';
32
32
  export * as Composer from './components/composer/index.js';
33
33
  export { getComposerContext } from './components/composer/index.js';
34
- export type { ComposerAttachButtonProps, ComposerAttachmentProps, ComposerAttachmentsProps, ComposerContext, ComposerMessage, ComposerModel, ComposerModelPickerProps, ComposerRejection, ComposerRootProps, ComposerStatus, ComposerSubmitProps, ComposerTextareaProps, ComposerToggleProps, ComposerToolbarProps, ComposerTrayProps } from './components/composer/index.js';
34
+ export type { ComposerAttachButtonProps, ComposerAttachmentProps, ComposerAttachmentsProps, ComposerContext, ComposerMessage, ComposerModel, ComposerModelPickerProps, ComposerModelProvider, ComposerRejection, ComposerRootProps, ComposerStatus, ComposerSubmitProps, ComposerTextareaProps, ComposerToggleProps, ComposerToolbarProps, ComposerTrayProps } from './components/composer/index.js';
35
35
  export * as ContextMenu from './components/menu/context-menu.js';
36
36
  export type { ContextMenuContentProps, ContextMenuTriggerProps } from './components/menu/context-menu.js';
37
37
  export * as Conversation from './components/conversation/index.js';
@@ -159,7 +159,7 @@ export type { ToasterProps } from './components/toast/Toaster.svelte';
159
159
  export { toast } from './components/toast/toasts.svelte.js';
160
160
  export type { ToastAction, ToastId, ToastOptions, ToastTone } from './components/toast/toasts.svelte.js';
161
161
  export * as Tooltip from './components/tooltip/index.js';
162
- export type { TooltipContentProps, TooltipRootProps, TooltipTriggerProps } from './components/tooltip/index.js';
162
+ export type { TooltipContentProps, TooltipProviderProps, TooltipRootProps, TooltipTriggerProps } from './components/tooltip/index.js';
163
163
  export { default as Theme } from './components/theme/Theme.svelte';
164
164
  export type { ThemeOverrides, ThemeProps, ThemeScheme } from './components/theme/Theme.svelte';
165
165
  export { default as WorkFold } from './components/work-fold/WorkFold.svelte';
@@ -0,0 +1,34 @@
1
+ <!--
2
+ The line under an item's label in a menu: words, or a snippet of words with an
3
+ icon in them, such as a branch's icon and its name. An icon put in it is 12px
4
+ and lies in the line, rather than breaking it as an svg's block would.
5
+ -->
6
+ <script lang="ts" module>
7
+ import * as stylex from '@stylexjs/stylex';
8
+ import type { Snippet } from 'svelte';
9
+ import { layer } from './layer.js';
10
+ import './icons.css';
11
+
12
+ /** A line under an item's label: words, or a snippet that may hold an icon. */
13
+ export type ItemDescriptionContent = string | Snippet;
14
+
15
+ const styles = stylex.create({
16
+ rich: {
17
+ '--narvi-icon-size': '0.75rem',
18
+ display: 'flex',
19
+ alignItems: 'center',
20
+ gap: '0.25rem',
21
+ minWidth: 0
22
+ }
23
+ });
24
+ </script>
25
+
26
+ <script lang="ts">
27
+ let { description }: { description: ItemDescriptionContent } = $props();
28
+ </script>
29
+
30
+ {#if typeof description === 'function'}
31
+ <span data-icons {...stylex.attrs(layer.description, styles.rich)}>{@render description()}</span>
32
+ {:else}
33
+ <span {...stylex.attrs(layer.description)}>{description}</span>
34
+ {/if}
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ import './icons.css';
3
+ /** A line under an item's label: words, or a snippet that may hold an icon. */
4
+ export type ItemDescriptionContent = string | Snippet;
5
+ type $$ComponentProps = {
6
+ description: ItemDescriptionContent;
7
+ };
8
+ declare const ItemDescription: import("svelte").Component<$$ComponentProps, {}, "">;
9
+ type ItemDescription = ReturnType<typeof ItemDescription>;
10
+ export default ItemDescription;
@@ -0,0 +1,19 @@
1
+ <!--
2
+ Around a part's tooltips. Inside the app's Tooltip.Provider they are the app's: they wait as
3
+ long as it says, and one opens at once after another anywhere under it, along a toolbar of
4
+ buttons each with its own. Without one they have their own, which waits 400ms.
5
+ -->
6
+ <script lang="ts">
7
+ import type { Snippet } from 'svelte';
8
+ import Provider, { hasTooltipProvider } from '../components/tooltip/TooltipProvider.svelte';
9
+
10
+ let { children }: { children: Snippet } = $props();
11
+
12
+ const provided = hasTooltipProvider();
13
+ </script>
14
+
15
+ {#if provided}
16
+ {@render children()}
17
+ {:else}
18
+ <Provider delayDuration={400}>{@render children()}</Provider>
19
+ {/if}
@@ -0,0 +1,7 @@
1
+ import type { Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ children: Snippet;
4
+ };
5
+ declare const TooltipScope: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type TooltipScope = ReturnType<typeof TooltipScope>;
7
+ export default TooltipScope;
@@ -13,5 +13,7 @@ export type RovingOptions = {
13
13
  selector: string;
14
14
  /** Which arrow keys move: up and down, or left and right. */
15
15
  orientation?: 'vertical' | 'horizontal' | undefined;
16
+ /** Past the last item, the arrows go on to the first, and back from the first to the last, as tabs do. */
17
+ wrap?: boolean | undefined;
16
18
  };
17
- export declare function roving({ selector, orientation }: RovingOptions): Attachment<HTMLElement>;
19
+ export declare function roving({ selector, orientation, wrap }: RovingOptions): Attachment<HTMLElement>;
@@ -1,6 +1,6 @@
1
1
  const isTyping = (target) => target instanceof HTMLElement &&
2
2
  (target.isContentEditable || target.matches('input, textarea, select'));
3
- export function roving({ selector, orientation = 'vertical' }) {
3
+ export function roving({ selector, orientation = 'vertical', wrap = false }) {
4
4
  return (container) => {
5
5
  let last = null;
6
6
  const items = () => [...container.querySelectorAll(selector)].filter((item) => !item.hasAttribute('disabled') &&
@@ -38,10 +38,13 @@ export function roving({ selector, orientation = 'vertical' }) {
38
38
  const forward = orientation === 'vertical' ? 'ArrowDown' : rtl ? 'ArrowLeft' : 'ArrowRight';
39
39
  const back = orientation === 'vertical' ? 'ArrowUp' : rtl ? 'ArrowRight' : 'ArrowLeft';
40
40
  let next;
41
+ const step = (by) => wrap
42
+ ? all[(index + by + all.length) % all.length]
43
+ : all[Math.min(Math.max(index + by, 0), all.length - 1)];
41
44
  if (event.key === forward)
42
- next = all[Math.min(index + 1, all.length - 1)];
45
+ next = step(1);
43
46
  else if (event.key === back)
44
- next = all[Math.max(index - 1, 0)];
47
+ next = step(-1);
45
48
  else if (event.key === 'Home')
46
49
  next = all[0];
47
50
  else if (event.key === 'End')
@@ -39,6 +39,12 @@ export declare const media: {
39
39
  * hold, such as an image's opacity.
40
40
  */
41
41
  dark: string;
42
+ /**
43
+ * The app's own dark mode: a `dark` class on the root, as Tailwind and shadcn set it, and
44
+ * as an app does that keeps its own Light, Dark and System setting. For an app that picks its scheme itself, where `dark` would follow the
45
+ * system instead; like it, for what the tokens cannot hold, such as a logo's dark version.
46
+ */
47
+ darkClass: string;
42
48
  /** Forced-colours mode, such as Windows High Contrast: shadows are gone, outlines stay. */
43
49
  forcedColors: string;
44
50
  /** 640px: large phones on their side, small tablets. */
@@ -40,6 +40,12 @@ export const media = stylex.defineConsts({
40
40
  * hold, such as an image's opacity.
41
41
  */
42
42
  dark: '@media (prefers-color-scheme: dark)',
43
+ /**
44
+ * The app's own dark mode: a `dark` class on the root, as Tailwind and shadcn set it, and
45
+ * as an app does that keeps its own Light, Dark and System setting. For an app that picks its scheme itself, where `dark` would follow the
46
+ * system instead; like it, for what the tokens cannot hold, such as a logo's dark version.
47
+ */
48
+ darkClass: ':is(.dark *)',
43
49
  /** Forced-colours mode, such as Windows High Contrast: shadows are gone, outlines stay. */
44
50
  forcedColors: '@media (forced-colors: active)',
45
51
  /** 640px: large phones on their side, small tablets. */
package/dist/vite.js CHANGED
@@ -61,6 +61,10 @@ export function narvi({ tailwind = false, ...options } = {}) {
61
61
  after: ['components', 'utilities']
62
62
  }
63
63
  : { before: [BASE_LAYER], prefix: NARVI_LAYER },
64
+ // The style applied last wins, a shorthand over a longhand too: a caller's `padding` in
65
+ // `sx` sets a part's padding, which StyleX's default would leave to the part's own
66
+ // `paddingInline`, whatever the order
67
+ styleResolution: 'application-order',
64
68
  ...options,
65
69
  // Narvi ships StyleX source, which must reach the compiler: Vite's dependency
66
70
  // pre-bundling would hand the page `stylex.create` calls that throw at runtime.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegopluna/narvi",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "packageManager": "pnpm@12.18.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -106,6 +106,7 @@
106
106
  "format": "prettier --write .",
107
107
  "test:unit": "vitest",
108
108
  "test": "npm run test:unit -- --run",
109
+ "bench:markdown": "NODE_ENV=production vitest --run --config src/bench/markdown/vitest.config.ts",
109
110
  "test:browsers": "NARVI_BROWSERS=firefox,webkit vitest --run --project client src/tests/markdown",
110
111
  "deploy": "pnpm build:docs && wrangler deploy"
111
112
  },
@@ -128,6 +129,7 @@
128
129
  "@fontsource/ibm-plex-mono": "^5.3.0",
129
130
  "@fontsource/ibm-plex-sans": "^5.3.0",
130
131
  "@fontsource/instrument-serif": "^5.3.0",
132
+ "@humanspeak/svelte-markdown": "2.2.0",
131
133
  "@lezer/common": "^1.5.5",
132
134
  "@lezer/highlight": "^1.2.5",
133
135
  "@lezer/javascript": "^1.5.6",
@@ -138,22 +140,39 @@
138
140
  "@sveltejs/package": "^2.5.8",
139
141
  "@sveltejs/vite-plugin-svelte": "^7.2.0",
140
142
  "@tanstack/intent": "0.5.6",
143
+ "@types/markdown-it": "14.2.0",
141
144
  "@types/node": "^24",
145
+ "@types/react": "19.2.14",
146
+ "@types/react-dom": "19.2.3",
142
147
  "@vitest/browser-playwright": "^4.1.8",
143
148
  "axe-core": "^4.14.0",
144
149
  "eslint": "^10.4.1",
145
150
  "eslint-config-prettier": "^10.1.8",
146
151
  "eslint-plugin-svelte": "^3.19.0",
147
152
  "globals": "^17.6.0",
153
+ "markdown-it": "15.0.3",
154
+ "marked": "18.1.2",
155
+ "micromark": "4.0.3",
156
+ "micromark-extension-gfm": "3.0.0",
148
157
  "playwright": "^1.60.0",
149
158
  "prettier": "^3.8.3",
150
159
  "prettier-plugin-svelte": "^4.1.0",
151
160
  "publint": "^0.3.21",
161
+ "react": "19.2.9",
162
+ "react-dom": "19.2.9",
163
+ "rehype-stringify": "10.0.1",
164
+ "remark-gfm": "4.0.1",
165
+ "remark-parse": "11.0.0",
166
+ "remark-rehype": "11.1.2",
152
167
  "shiki": "^4.6.0",
168
+ "streamdown": "2.7.1",
153
169
  "svelte": "^5.57.2",
154
170
  "svelte-check": "^4.6.0",
171
+ "svelte-exmarkdown": "5.0.2",
172
+ "svelte-streamdown": "5.0.0",
155
173
  "typescript": "^6.0.3",
156
174
  "typescript-eslint": "^8.60.1",
175
+ "unified": "11.0.5",
157
176
  "vite": "^8.3.0",
158
177
  "vitest": "^4.1.8",
159
178
  "vitest-browser-svelte": "^2.1.1",
@@ -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.3.4'
15
+ library_version: '0.3.6'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -35,6 +35,10 @@ sources:
35
35
  - src/lib/components/tab-strip/TabStrip.svelte
36
36
  - src/lib/components/split-button/SplitButton.svelte
37
37
  - src/lib/components/app-shell/AppShellPanel.svelte
38
+ - src/lib/components/composer/ComposerModelPicker.svelte
39
+ - src/lib/components/questionnaire/Questionnaire.svelte
40
+ - src/lib/components/button/Button.svelte
41
+ - src/lib/components/tooltip/TooltipProvider.svelte
38
42
  ---
39
43
 
40
44
  # Build interfaces with Narvi
@@ -128,7 +132,8 @@ A Select, Menu or Popover opened inside a dialog or a sheet opens over it.
128
132
 
129
133
  A menu that picks one of several uses `Menu.RadioGroup` and `Menu.RadioItem`. Picking an item
130
134
  closes the menu, as a select does (`closeOnSelect={false}` keeps it open), and an item takes
131
- an `icon` snippet and a `shortcut`, as `Menu.Item` does. `Menu.CheckboxItem` takes the same and
135
+ an `icon` snippet, a `shortcut` and a `trailing` snippet ("Default", "Custom"), as `Menu.Item`
136
+ does; a `Select` option's `detail` is the same word in a select's list. `Menu.CheckboxItem` takes the same and
132
137
  closes the menu too; pass `closeOnSelect={false}` for a menu of settings set several at a time.
133
138
  A `Menu.Label` names the `Menu.Group` or `Menu.RadioGroup` it is in; on its own it is a heading
134
139
  only to the eye, with no group needed. On a `ContextMenu.Trigger`, `menuKey={false}` leaves
@@ -297,48 +302,48 @@ line, `lines={2}` for several). Use `Code` and `Kbd` inline, and
297
302
  ```
298
303
 
299
304
  - Errors and work under way stay until dismissed, and every toast has a Dismiss button.
300
- - `Tooltip.Root` must sit inside a `Tooltip.Provider`. Mount one near the root. Give an icon
301
- button an `aria-label` too, because the tooltip shows a name but doesn't supply one.
305
+ - `Tooltip.Root` needs a `Tooltip.Provider` near the root, whose delay and hand-off Narvi's own
306
+ tooltips (Button, Rail, Tabs) take too. An icon button needs an `aria-label` as well.
302
307
  - Use `Notice` for a note in place (`tone`: neutral, info, success, warning, danger; `raised`
303
- over a busy background, such as an image behind the composer),
304
- `EmptyState` for an empty place, `Skeleton`, `Spinner` or `Progress` while loading, and
305
- `StatusIndicator` (`status`: idle, working, waiting, done, failed, stopped, connecting) for where
306
- a run stands. Where there is no room for its shapes, beside a name or on a mark's corner, use
307
- `StatusDot` (`tone`; `shape`: dot, ring for on its way, diamond for failed; `size`, 6px; `label`).
308
- Don't draw a dot as a span of your own.
308
+ over a busy background, such as an image behind the composer), `EmptyState` for an empty
309
+ place, `Skeleton`, `Spinner` or `Progress` while loading, and `StatusIndicator` (`status`:
310
+ idle, working, waiting, done, failed, stopped, connecting) for where a run stands. With no
311
+ room for its shapes, use `StatusDot` (`tone`; `shape`: dot, ring for on its way, diamond for
312
+ failed; `size`, 6px; `label`): don't draw a dot as a span of your own.
309
313
 
310
314
  ### Lists, badges and folds
311
315
 
312
316
  - Rows on one card with a line between each: `List.Root` (a `ul`, or `as="div"`) holding
313
317
  `List.Item`s, or rows of your own. Don't redraw the card and its lines.
314
318
  - `Badge` shows its tone as a dot; `plain` hides the dot and colours the words in the tone.
315
- `size="sm"` is 18px, a sidebar row's line, so it sits in a row without growing it. An icon in
316
- it is sized to 12px.
319
+ `color` paints the dot alone in a colour of its own (a label's `#d73a4a`): don't draw a dot.
320
+ `size="sm"` is 18px, a sidebar row's line, so a row keeps its height; an icon in it is 12px.
317
321
  - `Collapsible.Trigger` takes `chevron="start"` to put the chevron before its label, as in a tree.
318
- - `Tabs` and `SegmentedControl` options take an `icon` (a component, sized to fit) and a
319
- `title` that names a short label in full, as a tooltip and the item's description.
320
- - A `Button` that is loading hides its label under the spinner, which is as large as an icon in
321
- a button of that size, icon-only ones too; `loadingLabel="Connecting…"`
322
- says what it is doing beside the spinner instead. `variant="link"` sits in a sentence, at its
323
- size, with no padding. A ghost, bare, secondary or floating Button that opens a menu or a
324
- popover holds an open look while it shows, by the `aria-expanded` bits-ui sets: don't style
325
- the open trigger yourself. `pressed` makes it a toggle button (`aria-pressed`) held in the same
326
- look while true: don't style `aria-pressed` by hand.
322
+ - `Tabs` and `SegmentedControl` options take an `icon` and a `title`: tooltip and description.
323
+ - A loading `Button` hides its label under the spinner; `loadingLabel="Connecting…"` says what
324
+ it does beside it instead. `tooltip` (words or a snippet), `tooltipSide` (`bottom` under a
325
+ bar) and `tooltipShortcut` (`['⌘', 'K']`) give it a tooltip, as on `Composer.Submit` and a
326
+ `SplitButton` (`menuTooltip` for its chevron; `onopenchange`): don't wrap one in `Tooltip`
327
+ parts. `justify="start"` starts its contents, for a full-width row, and a margin of `auto`
328
+ sends the last to the end. `variant="link"` sits in a sentence. An open ghost, bare, secondary
329
+ or floating trigger holds an open look by bits-ui's `aria-expanded`, and `pressed` makes a
330
+ toggle button (`aria-pressed`) in that look: style neither.
327
331
  - A main action with a menu of how to do it (Merge, Sign in) is a `SplitButton`: `menu` snippet,
328
332
  `menuLabel` for the chevron, `label` for the group, both halves disabled together. Without
329
333
  `menu` it stands alone. Don't join two Buttons by hand.
330
- - `Toggle` and `ToggleGroup.Root` take `tone="neutral"` for a toolbar's icons that show or hide
331
- something: pressed, they take the fill of what is chosen instead of lighting in the accent.
332
- - `Menu.Item`, `Menu.SubTrigger` and `Menu.CheckboxItem` take a `description` (a line under the
333
- label), and `Menu.Item` a `trailing` snippet after its shortcut. A `Menu.CheckboxItem` with an
334
+ - `Toggle` and `ToggleGroup.Root` take `tone="neutral"`: pressed, a toolbar's icon takes the fill
335
+ of what is chosen, not the accent.
336
+ - `Menu.Item`, `Menu.SubTrigger`, `Menu.CheckboxItem` and `Menu.RadioItem` take a
337
+ `description` (a line under the label): a string, or a snippet whose icon is 12px and lies in
338
+ the line; say in words what the icon stands for. All but the SubTrigger take `trailing`. A `Menu.CheckboxItem` with an
334
339
  `icon` puts its tick at the end, so its icon lines up with the others'. `Menu.Content` takes a
335
340
  `width` (`'18rem'`) in place of fitting its items, up to 22rem.
336
341
  - `Popover.Content` takes `padding="none"`, `layout="column"` and a `width`;
337
342
  `HoverCard.Content` takes `layout="column"` and `padding`; `Tooltip.Content` takes
338
343
  `layout="column"` for a title over a line that says more.
339
- - `Select` takes an `optionIcon` snippet, given each option, for an icon with props of its own.
340
- An option's `detail` (a hash, a size, a count; `detailMono` for code) is muted at the end of
341
- its row in the list, and kept off the trigger.
344
+ - `Select` takes `optionIcon` for an icon with props, and `prefix` for muted words before the
345
+ choice on its trigger ("Text size"). An option's `detail` (`detailMono` for code) is muted at
346
+ the end of its row, off the trigger. Groups get a hairline between them.
342
347
  - `EmptyState`'s title is a heading (`level`, 2 by default). `Heading` takes a `weight`.
343
348
 
344
349
  ### App and chat screens
@@ -392,9 +397,11 @@ Parts of the shell that are easy to redraw by hand, and shouldn't be:
392
397
  a long press), `onmove(id, index)` (drag, or Alt+Shift+arrow), `onrename(id, label)` with
393
398
  `bind:renaming` (double-click, F2, or a menu's Rename), `trailing` for a tab's own buttons,
394
399
  `beside` for the tab shown in a split, and per tab `tabId`, `panelId`, `title`, `renamable`.
395
- - **AppShell.Panel** goes narrow by its row (the sheet less the sidebar), not the window.
396
- `maximized` lays it over the whole page, header too; the page underneath is kept, inert. Give
397
- the panel its own `AppShell.Header` with `AppShell.Toggle when="closed"`.
400
+ Arrows open the tab they reach (`activation="manual"` only moves focus); `onchange(id)`; a
401
+ name cleared comes as `''`; `addMenu` (Menu parts) makes the add button open a menu.
402
+ - **AppShell.Panel** goes narrow by its row, not the window; `maximized` lays it over the page,
403
+ kept inert, so give it an `AppShell.Header` with `AppShell.Toggle when="closed"`. Beside a
404
+ thread, put it in a flex row of yours (`position: relative`) inside `AppShell.Main`.
398
405
  - **A Sheet** focuses itself as it opens (`focusOnOpen="sheet"`), so a Rail or a list in it
399
406
  shows no focus ring until the keys move in. Pass `focusOnOpen="first"` for a sheet that
400
407
  holds a form.
@@ -408,10 +415,12 @@ Parts of a thread that are easy to redraw by hand, and shouldn't be:
408
415
  its own). The frame shows its focus edge and sends clicks to it. Set `hasContent` from the
409
416
  editor, so `Composer.Submit` knows there is something to send, and `sending` while a message
410
417
  is on its way and can't be stopped: Submit spins, says "Sending" (`sendingLabel`), and nothing
411
- more is sent. `onfiles` receives picked, dropped and pasted files; return `false` to keep them
418
+ more is sent. `sendingText="Creating worktree…"` says it beside the spinner, widening Submit. `onfiles` receives picked, dropped and pasted files; return `false` to keep them
412
419
  on a list of your own instead of the composer's.
413
420
  - **Composer.ModelPicker** takes `bind:open`, and `multiple` with `value: string[]` to pick
414
- several. `Composer.Toggle` works outside a `Composer.Root` too.
421
+ several, `providers` (a `provider` on each model) for a rail of agents beside the list,
422
+ `searchable` for a field that searches them all, and `bind:starred` (values; keep them where
423
+ 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.
415
424
  - **Composer.Tray** shows its shelf for a child that holds something and isn't `hidden`; pass
416
425
  `waiting` when what is inside hides itself some other way.
417
426
  - **A user's message with attachments:** `<Message.Content bubble={false}>` is a column at the
@@ -425,12 +434,11 @@ Parts of a thread that are easy to redraw by hand, and shouldn't be:
425
434
  Markdown, in place of `text`. `Activity.Step` takes `wrap` for a label that runs on, and
426
435
  `status="neutral"` for a step that settled without going through or failing ("Skipped",
427
436
  `statusLabels.neutral`); it and `WorkFold` pass `data-*` attributes on.
428
- - **A divider with more than words:** `Divider` takes children (a link, a time) and
429
- `role="status"` for words read out as they change. A long label wraps between the rules.
437
+ - **A divider with more than words:** `Divider` takes children (a link, a time) and `role="status"`.
430
438
  - **Answers on their way:** `Approval` and `Questionnaire` take `busy`, which spins the button
431
439
  pressed and holds the rest. A `Question` takes a `description`, and `secret` for an answer
432
- typed into a hidden field and never shown back. ⌘Enter sends only once every question is
433
- answered or skipped.
440
+ never shown back. ⌘Enter sends once every question is answered or skipped. `Questionnaire` takes a `heading` snippet beside its count, and `bare`
441
+ inside a card of yours; its arrow keys are built in (↑/↓ answers, ←/→ questions).
434
442
  - **Closed folds** (`WorkFold`, `Collapsible`, `Activity`, `Reasoning`, `Tool`) stop rendering
435
443
  their content once shut, so `checkVisibility()`, find-in-page and Playwright see it as hidden.
436
444
  Don't add `display: none` of your own.