@diegopluna/narvi 0.3.2 → 0.3.3

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 (114) hide show
  1. package/dist/components/activity/ActivityIcon.svelte +54 -0
  2. package/dist/components/activity/ActivityIcon.svelte.d.ts +24 -0
  3. package/dist/components/activity/ActivityStep.svelte +47 -13
  4. package/dist/components/activity/ActivityStep.svelte.d.ts +13 -4
  5. package/dist/components/activity/ActivityThought.svelte +24 -5
  6. package/dist/components/activity/ActivityThought.svelte.d.ts +12 -2
  7. package/dist/components/activity/index.d.ts +3 -1
  8. package/dist/components/activity/index.js +2 -1
  9. package/dist/components/app-shell/AppShellHeader.svelte +18 -4
  10. package/dist/components/app-shell/AppShellHeader.svelte.d.ts +5 -0
  11. package/dist/components/approval/Approval.svelte +14 -1
  12. package/dist/components/approval/Approval.svelte.d.ts +5 -0
  13. package/dist/components/badge/Badge.svelte +3 -1
  14. package/dist/components/badge/Badge.svelte.d.ts +1 -1
  15. package/dist/components/button/Button.svelte +17 -6
  16. package/dist/components/composer/ComposerModelPicker.svelte +80 -13
  17. package/dist/components/composer/ComposerModelPicker.svelte.d.ts +23 -6
  18. package/dist/components/composer/ComposerRoot.svelte +51 -12
  19. package/dist/components/composer/ComposerRoot.svelte.d.ts +16 -0
  20. package/dist/components/composer/ComposerSubmit.svelte +19 -5
  21. package/dist/components/composer/ComposerSubmit.svelte.d.ts +3 -1
  22. package/dist/components/composer/ComposerToggle.svelte +18 -4
  23. package/dist/components/composer/ComposerToggle.svelte.d.ts +2 -0
  24. package/dist/components/composer/ComposerTray.svelte +17 -3
  25. package/dist/components/composer/ComposerTray.svelte.d.ts +5 -0
  26. package/dist/components/composer/context.d.ts +4 -1
  27. package/dist/components/dialog/DialogContent.svelte +22 -12
  28. package/dist/components/dialog/DialogContent.svelte.d.ts +10 -0
  29. package/dist/components/divider/Divider.svelte +56 -14
  30. package/dist/components/divider/Divider.svelte.d.ts +13 -3
  31. package/dist/components/empty-state/EmptyState.svelte +12 -2
  32. package/dist/components/empty-state/EmptyState.svelte.d.ts +6 -0
  33. package/dist/components/heading/Heading.svelte +15 -0
  34. package/dist/components/heading/Heading.svelte.d.ts +6 -0
  35. package/dist/components/hover-card/HoverCardContent.svelte +18 -2
  36. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -0
  37. package/dist/components/input/Input.svelte +13 -3
  38. package/dist/components/input/Input.svelte.d.ts +10 -2
  39. package/dist/components/markdown/Markdown.svelte +22 -2
  40. package/dist/components/markdown/MarkdownDiagram.svelte +33 -2
  41. package/dist/components/markdown/MarkdownFile.svelte +56 -10
  42. package/dist/components/markdown/MarkdownMath.svelte +6 -0
  43. package/dist/components/markdown/MarkdownTable.svelte +3 -4
  44. package/dist/components/markdown/context.d.ts +6 -0
  45. package/dist/components/markdown/labels.d.ts +7 -0
  46. package/dist/components/markdown/labels.js +2 -0
  47. package/dist/components/menu/MenuCheckboxItem.svelte +44 -7
  48. package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +12 -2
  49. package/dist/components/menu/MenuContent.svelte +10 -2
  50. package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
  51. package/dist/components/menu/MenuItem.svelte +17 -2
  52. package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
  53. package/dist/components/menu/MenuSubContent.svelte +10 -2
  54. package/dist/components/menu/MenuSubContent.svelte.d.ts +10 -0
  55. package/dist/components/menu/MenuSubTrigger.svelte +19 -2
  56. package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -0
  57. package/dist/components/message/MessageBubble.svelte +40 -0
  58. package/dist/components/message/MessageBubble.svelte.d.ts +12 -0
  59. package/dist/components/message/MessageContent.svelte +23 -14
  60. package/dist/components/message/MessageContent.svelte.d.ts +6 -0
  61. package/dist/components/message/MessageCopy.svelte +27 -15
  62. package/dist/components/message/MessageCopy.svelte.d.ts +9 -2
  63. package/dist/components/message/MessageRoot.svelte +20 -3
  64. package/dist/components/message/MessageRoot.svelte.d.ts +6 -0
  65. package/dist/components/message/context.d.ts +2 -0
  66. package/dist/components/message/index.d.ts +4 -1
  67. package/dist/components/message/index.js +3 -2
  68. package/dist/components/message/styles.d.ts +30 -0
  69. package/dist/components/message/styles.js +24 -0
  70. package/dist/components/notice/Notice.svelte +3 -3
  71. package/dist/components/popover/PopoverContent.svelte +27 -3
  72. package/dist/components/popover/PopoverContent.svelte.d.ts +18 -0
  73. package/dist/components/questionnaire/Questionnaire.svelte +103 -19
  74. package/dist/components/questionnaire/Questionnaire.svelte.d.ts +13 -1
  75. package/dist/components/queued-message/QueuedMessage.svelte +44 -6
  76. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +12 -1
  77. package/dist/components/select/Select.svelte +18 -2
  78. package/dist/components/select/Select.svelte.d.ts +7 -0
  79. package/dist/components/toast/Toaster.svelte +1 -1
  80. package/dist/components/toggle/Toggle.svelte +12 -2
  81. package/dist/components/toggle/Toggle.svelte.d.ts +11 -1
  82. package/dist/components/toggle-group/ToggleGroupItem.svelte +10 -1
  83. package/dist/components/toggle-group/ToggleGroupRoot.svelte +7 -1
  84. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +3 -1
  85. package/dist/components/toggle-group/context.d.ts +2 -1
  86. package/dist/components/tooltip/TooltipContent.svelte +13 -1
  87. package/dist/components/tooltip/TooltipContent.svelte.d.ts +10 -0
  88. package/dist/components/work-fold/WorkFold.svelte +13 -4
  89. package/dist/components/work-fold/WorkFold.svelte.d.ts +2 -1
  90. package/dist/focus-ring.d.ts +29 -0
  91. package/dist/focus-ring.js +42 -0
  92. package/dist/index.d.ts +6 -5
  93. package/dist/index.js +7 -2
  94. package/dist/internal/Collapse.svelte +15 -2
  95. package/dist/internal/Glyph.svelte +28 -0
  96. package/dist/internal/Glyph.svelte.d.ts +5 -0
  97. package/dist/internal/Tile.svelte +3 -2
  98. package/dist/internal/layer.d.ts +23 -0
  99. package/dist/internal/layer.js +19 -0
  100. package/dist/internal/toggle.d.ts +8 -1
  101. package/dist/internal/toggle.js +20 -2
  102. package/dist/markdown/file-paths.d.ts +7 -0
  103. package/dist/markdown/file-paths.js +29 -0
  104. package/dist/markdown/files.d.ts +22 -2
  105. package/dist/markdown/files.js +45 -14
  106. package/dist/tokens.stylex.d.ts +3 -0
  107. package/dist/tokens.stylex.js +5 -1
  108. package/package.json +1 -1
  109. package/skills/building-ui/SKILL.md +55 -3
  110. package/skills/building-ui/references/components.md +33 -33
  111. package/skills/markdown/SKILL.md +22 -6
  112. package/skills/setup/SKILL.md +1 -1
  113. package/skills/styling/SKILL.md +10 -3
  114. package/skills/theming/SKILL.md +11 -4
@@ -1,15 +1,16 @@
1
1
  <!--
2
- A file named in a reply, as a chip: its name, with the whole path as its title. With a way
3
- to open files it is a button; without one it only shows.
2
+ A file named in a reply, as a chip: an icon for its kind (a folder, code, an image, text,
3
+ data) or the app's own, its name, with the whole path as its title. With a way to open
4
+ files it is a button; without one it only shows.
4
5
  -->
5
6
  <script lang="ts" module>
6
7
  import * as stylex from '@stylexjs/stylex';
7
8
  import type { Snippet } from 'svelte';
8
- import Glyph, { glyphHtml } from '../../internal/Glyph.svelte';
9
+ import Glyph, { glyphHtml, type GlyphName } from '../../internal/Glyph.svelte';
9
10
  import { attrs, classes } from '../../internal/sx.js';
10
11
  import type { StaticTools } from '../../markdown/plugin.js';
11
12
  import type { InlineCustom } from '../../markdown/ast.js';
12
- import { formatPosition, type FileReference } from '../../markdown/file-paths.js';
13
+ import { formatPosition, type FileKind, type FileReference } from '../../markdown/file-paths.js';
13
14
  import { colors, motion, radius } from '../../tokens.stylex.js';
14
15
  import { media } from '../../media.stylex.js';
15
16
 
@@ -59,6 +60,18 @@
59
60
  // A chip made from a link keeps the link's words, in the text's own face
60
61
  words: { fontFamily: 'inherit', fontSize: '0.9375em' },
61
62
  icon: { flexShrink: 0, color: colors.textSubtle },
63
+ // The app's own icon, an SVG drawn as a mask in the colour it gives, or the icon's
64
+ own: {
65
+ display: 'inline-block',
66
+ width: '12px',
67
+ height: '12px',
68
+ backgroundColor: 'currentColor',
69
+ maskImage: 'var(--narvi-file-icon)',
70
+ maskSize: 'contain',
71
+ maskRepeat: 'no-repeat',
72
+ maskPosition: 'center',
73
+ forcedColorAdjust: 'auto'
74
+ },
62
75
  label: { minWidth: 0, overflowWrap: 'anywhere' }
63
76
  });
64
77
 
@@ -69,6 +82,32 @@
69
82
  buttonWords: classes(styles.chip, styles.button, styles.words)
70
83
  };
71
84
  const iconClass = classes(styles.icon);
85
+ const ownIconClass = classes(styles.icon, styles.own);
86
+
87
+ type ChipData = FileReference & {
88
+ source: string;
89
+ link?: boolean | undefined;
90
+ kind?: FileKind | undefined;
91
+ icon?: { url: string; color?: string | undefined } | undefined;
92
+ };
93
+
94
+ const KIND_GLYPHS: Record<FileKind, GlyphName> = {
95
+ folder: 'folder',
96
+ code: 'fileCode',
97
+ image: 'fileImage',
98
+ text: 'fileText',
99
+ data: 'fileData',
100
+ file: 'file'
101
+ };
102
+
103
+ /** The icon as markup: the app's own, or Narvi's for the kind. */
104
+ function iconHtml(file: ChipData, escape: (text: string) => string): string {
105
+ if (file.icon) {
106
+ const color = file.icon.color ? `; color: ${escape(file.icon.color)}` : '';
107
+ return `<span aria-hidden="true" class="${ownIconClass}" style="--narvi-file-icon: url(&quot;${escape(file.icon.url)}&quot;)${color}"></span>`;
108
+ }
109
+ return glyphHtml(KIND_GLYPHS[file.kind ?? 'file'], 12, 1.5, iconClass);
110
+ }
72
111
  const labelClass = classes(styles.label);
73
112
 
74
113
  /**
@@ -76,11 +115,11 @@
76
115
  * file it names, for `chipFile` to read back when it is pressed.
77
116
  */
78
117
  export function fileHtml(node: InlineCustom, opens: boolean, tools: StaticTools): string {
79
- const file = node.data as FileReference & { source: string; link?: boolean | undefined };
118
+ const file = node.data as ChipData;
80
119
  const attributes =
81
120
  ` data-markdown-file="true" data-markdown-copy="${tools.escape(file.source)}"` +
82
121
  ` title="${tools.escape(file.path + formatPosition(file))}"`;
83
- const inside = `${glyphHtml('file', 12, 1.5, iconClass)}<span class="${labelClass}">${tools.children()}</span>`;
122
+ const inside = `${iconHtml(file, tools.escape)}<span class="${labelClass}">${tools.children()}</span>`;
84
123
  if (!opens)
85
124
  return `<span${attributes} class="${file.link ? chipClass.shownWords : chipClass.shown}">${inside}</span>`;
86
125
  const { path, line, column, endLine } = file;
@@ -102,14 +141,21 @@
102
141
  <script lang="ts">
103
142
  let { node, children, open }: MarkdownFileProps = $props();
104
143
 
105
- const file = $derived(
106
- node.data as FileReference & { source: string; link?: boolean | undefined }
107
- );
144
+ const file = $derived(node.data as ChipData);
108
145
  const title = $derived(file.path + formatPosition(file));
109
146
  </script>
110
147
 
111
148
  {#snippet content()}
112
- <Glyph name="file" size={12} {...attrs([styles.icon])} />
149
+ {#if file.icon}
150
+ <span
151
+ aria-hidden="true"
152
+ style:--narvi-file-icon={`url("${file.icon.url}")`}
153
+ style:color={file.icon.color}
154
+ {...attrs([styles.icon, styles.own])}
155
+ ></span>
156
+ {:else}
157
+ <Glyph name={KIND_GLYPHS[file.kind ?? 'file']} size={12} {...attrs([styles.icon])} />
158
+ {/if}
113
159
  <span {...attrs([styles.label])}>{@render children?.()}</span>
114
160
  {/snippet}
115
161
 
@@ -37,6 +37,8 @@
37
37
  // characters takes seconds, and 85 KB of nested braces make 12 MB of markup. No formula a
38
38
  // person reads is this long; a longer one shows as its source.
39
39
  const MAX_TEX = 10_000;
40
+ // KaTeX escapes the TeX it writes here, so no `<` comes before the closing tag
41
+ const ANNOTATION = /<annotation encoding="application\/x-tex">[^<]*<\/annotation>/g;
40
42
  const MAX_MARKUP = 200_000;
41
43
  // Many formulas, each within those limits, could still fill the page with millions of
42
44
  // elements. A document's formulas share this much markup; past it, they show as source.
@@ -63,6 +65,10 @@
63
65
  } catch {
64
66
  html = '';
65
67
  }
68
+ // KaTeX keeps the formula's TeX in its MathML as an annotation. Hidden as it is, the
69
+ // page's find and a test's text search still find it, so the source reads as being
70
+ // on the page twice. A copy takes the TeX from `data-markdown-copy`, so it goes.
71
+ html = html.replace(ANNOTATION, '');
66
72
  if (html.length > MAX_MARKUP) html = '';
67
73
  while (cache.size >= CACHE_SIZE || (cached + html.length > CACHE_BYTES && cache.size > 0)) {
68
74
  const oldest = cache.keys().next().value!;
@@ -3,7 +3,6 @@
3
3
  on hover or focus, copies it as Markdown or CSV, or saves it as a CSV file.
4
4
  -->
5
5
  <script lang="ts" module>
6
- import { visuallyHidden } from '../../visually-hidden.js';
7
6
  import * as stylex from '@stylexjs/stylex';
8
7
  import Glyph, { glyphHtml } from '../../internal/Glyph.svelte';
9
8
  import { markdownTableMarker } from '../../internal/markers.stylex.js';
@@ -120,7 +119,7 @@
120
119
  bare: true,
121
120
  inner: glyphHtml('copy')
122
121
  }) +
123
- `</div><span role="status" class="${classes(visuallyHidden)}"></span></div>`
122
+ `</div></div>`
124
123
  );
125
124
  }
126
125
  </script>
@@ -149,8 +148,10 @@
149
148
  try {
150
149
  await navigator.clipboard.writeText(text);
151
150
  } catch {
151
+ md.announce(md.labels.copyFailed);
152
152
  return;
153
153
  }
154
+ md.announce(md.labels.copied);
154
155
  copied = true;
155
156
  clearTimeout(timer);
156
157
  timer = setTimeout(() => (copied = false), 2000);
@@ -252,7 +253,5 @@
252
253
  </Menu.Root>
253
254
  {/if}
254
255
  </div>
255
- <!-- Outside the button: a button's contents are not read out as they change -->
256
- <span role="status" {...attrs([visuallyHidden])}>{copied ? md.labels.copied : ''}</span>
257
256
  {/if}
258
257
  </div>
@@ -35,6 +35,12 @@ export type MarkdownContext = {
35
35
  breaks: () => boolean;
36
36
  /** The words the controls show. */
37
37
  labels: MarkdownLabels;
38
+ /**
39
+ * Says a short message to assistive technology, in the document's one status region:
40
+ * "Copied", or why a diagram could not be drawn. One region for the whole reply, not one
41
+ * per code block and table, so a long reply is not full of empty ones.
42
+ */
43
+ announce: (message: string) => void;
38
44
  /** Called when a task item's box is ticked or cleared, when the app takes that. */
39
45
  task: () => ((item: ListItem, checked: boolean) => unknown) | undefined;
40
46
  /** Whether a block that `static` wrote has been asked for as parts: a table whose menu is wanted. */
@@ -6,6 +6,8 @@ export type MarkdownLabels = {
6
6
  copyCode: string;
7
7
  downloadCode: string;
8
8
  copied: string;
9
+ /** Said when the clipboard turned a copy away. */
10
+ copyFailed: string;
9
11
  /** Names the table's menu button. */
10
12
  tableActions: string;
11
13
  copyAsMarkdown: string;
@@ -19,6 +21,11 @@ export type MarkdownLabels = {
19
21
  zoomIn: string;
20
22
  zoomOut: string;
21
23
  resetZoom: string;
24
+ /**
25
+ * Names a diagram's picture for assistive technology, from the words in it, when its
26
+ * source gives it no title (`accTitle`).
27
+ */
28
+ diagramPicture: (labels: string[]) => string;
22
29
  /** Says a diagram could not be drawn, with the reason. */
23
30
  diagramFailed: (reason: string) => string;
24
31
  diagramNotLoaded: string;
@@ -2,6 +2,7 @@ export const defaultLabels = {
2
2
  copyCode: 'Copy code',
3
3
  downloadCode: 'Download code',
4
4
  copied: 'Copied',
5
+ copyFailed: "Couldn't copy",
5
6
  tableActions: 'Copy or save this table',
6
7
  copyAsMarkdown: 'Copy as Markdown',
7
8
  copyAsCsv: 'Copy as CSV',
@@ -14,6 +15,7 @@ export const defaultLabels = {
14
15
  zoomIn: 'Zoom in',
15
16
  zoomOut: 'Zoom out',
16
17
  resetZoom: 'Reset zoom',
18
+ diagramPicture: (labels) => (labels.length ? `Diagram: ${labels.join(', ')}` : 'Diagram'),
17
19
  diagramFailed: (reason) => `This diagram could not be drawn: ${reason}`,
18
20
  diagramNotLoaded: 'What draws diagrams could not be loaded.',
19
21
  diagramInvalid: 'It is not a diagram that can be drawn.',
@@ -6,17 +6,34 @@
6
6
  import Glyph from '../../internal/Glyph.svelte';
7
7
  import { layer } from '../../internal/layer.js';
8
8
  import { attrs, type Sx } from '../../internal/sx.js';
9
+ import { colors } from '../../tokens.stylex.js';
9
10
 
10
11
  export type MenuCheckboxItemProps = Loose<
11
12
  Omit<DropdownMenu.CheckboxItemProps, 'children' | 'child'> & {
12
13
  /** The keys that do the same, shown at the end, such as "⌘D". */
13
14
  shortcut?: string | undefined;
14
- /** A 16px icon before the label, after the tick. */
15
+ /**
16
+ * A 16px icon before the label, where the other items' icons are. The tick then goes
17
+ * to the end of the row, so the icons line up down the menu.
18
+ */
15
19
  icon?: Snippet | undefined;
20
+ /** A line under the label, such as what the setting does. */
21
+ description?: string | undefined;
16
22
  sx?: Sx | undefined;
17
23
  children?: Snippet | undefined;
18
24
  }
19
25
  >;
26
+
27
+ const styles = stylex.create({
28
+ // At the end, the tick keeps its place whether shown or not, so the shortcuts line up
29
+ check: {
30
+ display: 'grid',
31
+ placeItems: 'center',
32
+ width: '1rem',
33
+ height: '1rem',
34
+ color: colors.text
35
+ }
36
+ });
20
37
  </script>
21
38
 
22
39
  <script lang="ts">
@@ -24,6 +41,7 @@
24
41
  checked = $bindable(false),
25
42
  shortcut,
26
43
  icon,
44
+ description,
27
45
  // Picking it closes the menu, as a radio item's does: one left open takes the next click
28
46
  // that was meant for the page. Pass `false` for a menu of settings set several at a time.
29
47
  closeOnSelect = true,
@@ -42,11 +60,30 @@
42
60
  {...attrs([layer.item, sx], className)}
43
61
  >
44
62
  {#snippet children({ checked })}
45
- <span {...stylex.attrs(layer.icon)}>
46
- {#if checked}<Glyph name="check" stroke={1.75} />{/if}
47
- </span>
48
- {#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
49
- <span {...stylex.attrs(layer.label)}>{@render label?.()}</span>
50
- {#if shortcut}<span {...stylex.attrs(layer.trailing)}>{shortcut}</span>{/if}
63
+ {#if icon}
64
+ <span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>
65
+ {:else}
66
+ <span {...stylex.attrs(layer.icon)}>
67
+ {#if checked}<Glyph name="check" stroke={1.75} />{/if}
68
+ </span>
69
+ {/if}
70
+ {#if description}
71
+ <span {...stylex.attrs(layer.text)}>
72
+ <span {...stylex.attrs(layer.label)}>{@render label?.()}</span>
73
+ <span {...stylex.attrs(layer.description)}>{description}</span>
74
+ </span>
75
+ {:else}
76
+ <span {...stylex.attrs(layer.label)}>{@render label?.()}</span>
77
+ {/if}
78
+ {#if shortcut || icon}
79
+ <span {...stylex.attrs(layer.trailing)}>
80
+ {shortcut}
81
+ {#if icon}
82
+ <span data-slot="menu-check" {...stylex.attrs(styles.check)}>
83
+ {#if checked}<Glyph name="check" stroke={1.75} />{/if}
84
+ </span>
85
+ {/if}
86
+ </span>
87
+ {/if}
51
88
  {/snippet}
52
89
  </DropdownMenu.CheckboxItem>
@@ -5,16 +5,26 @@ import { type Sx } from '../../internal/sx.js';
5
5
  export type MenuCheckboxItemProps = Loose<Omit<DropdownMenu.CheckboxItemProps, 'children' | 'child'> & {
6
6
  /** The keys that do the same, shown at the end, such as "⌘D". */
7
7
  shortcut?: string | undefined;
8
- /** A 16px icon before the label, after the tick. */
8
+ /**
9
+ * A 16px icon before the label, where the other items' icons are. The tick then goes
10
+ * to the end of the row, so the icons line up down the menu.
11
+ */
9
12
  icon?: Snippet | undefined;
13
+ /** A line under the label, such as what the setting does. */
14
+ description?: string | undefined;
10
15
  sx?: Sx | undefined;
11
16
  children?: Snippet | undefined;
12
17
  }>;
13
18
  declare const MenuCheckboxItem: import("svelte").Component<Loose<Omit<DropdownMenu.CheckboxItemProps, "children" | "child"> & {
14
19
  /** The keys that do the same, shown at the end, such as "⌘D". */
15
20
  shortcut?: string | undefined;
16
- /** A 16px icon before the label, after the tick. */
21
+ /**
22
+ * A 16px icon before the label, where the other items' icons are. The tick then goes
23
+ * to the end of the row, so the icons line up down the menu.
24
+ */
17
25
  icon?: Snippet | undefined;
26
+ /** A line under the label, such as what the setting does. */
27
+ description?: string | undefined;
18
28
  sx?: Sx | undefined;
19
29
  children?: Snippet | undefined;
20
30
  }>, {}, "checked">;
@@ -2,11 +2,16 @@
2
2
  import type { Loose } from '../../internal/loose.js';
3
3
  import { DropdownMenu } from 'bits-ui';
4
4
  import type { Snippet } from 'svelte';
5
- import { layer } from '../../internal/layer.js';
5
+ import { layer, widthStyle } from '../../internal/layer.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
7
 
8
8
  export type MenuContentProps = Loose<
9
9
  Omit<DropdownMenu.ContentProps, 'children' | 'child'> & {
10
+ /**
11
+ * A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
12
+ * the trigger's width, up to 22rem). It is still no wider than the window has room for.
13
+ */
14
+ width?: string | undefined;
10
15
  sx?: Sx | undefined;
11
16
  children?: Snippet | undefined;
12
17
  }
@@ -17,6 +22,8 @@
17
22
  let {
18
23
  sideOffset = 6,
19
24
  collisionPadding = 8,
25
+ width,
26
+ style,
20
27
  align = 'start',
21
28
  sx,
22
29
  class: className,
@@ -32,7 +39,8 @@
32
39
  {align}
33
40
  data-slot="menu-content"
34
41
  {...rest}
35
- {...attrs([layer.surface, sx], className)}
42
+ style={widthStyle(width, style)}
43
+ {...attrs([layer.surface, !!width && layer.sized, sx], className)}
36
44
  >
37
45
  {@render children?.()}
38
46
  </DropdownMenu.Content>
@@ -3,10 +3,20 @@ import { DropdownMenu } from 'bits-ui';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
5
  export type MenuContentProps = Loose<Omit<DropdownMenu.ContentProps, 'children' | 'child'> & {
6
+ /**
7
+ * A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
8
+ * the trigger's width, up to 22rem). It is still no wider than the window has room for.
9
+ */
10
+ width?: string | undefined;
6
11
  sx?: Sx | undefined;
7
12
  children?: Snippet | undefined;
8
13
  }>;
9
14
  declare const MenuContent: import("svelte").Component<Loose<Omit<DropdownMenu.ContentProps, "children" | "child"> & {
15
+ /**
16
+ * A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
17
+ * the trigger's width, up to 22rem). It is still no wider than the window has room for.
18
+ */
19
+ width?: string | undefined;
10
20
  sx?: Sx | undefined;
11
21
  children?: Snippet | undefined;
12
22
  }>, {}, "">;
@@ -14,6 +14,10 @@
14
14
  shortcut?: string | undefined;
15
15
  /** A 16px icon before the label. */
16
16
  icon?: Snippet | undefined;
17
+ /** A line under the label, such as what the action does. */
18
+ description?: string | undefined;
19
+ /** Something at the end, after the shortcut: a badge, a count, a status. */
20
+ trailing?: Snippet | undefined;
17
21
  sx?: Sx | undefined;
18
22
  children?: Snippet | undefined;
19
23
  }
@@ -25,6 +29,8 @@
25
29
  tone = 'default',
26
30
  shortcut,
27
31
  icon,
32
+ description,
33
+ trailing,
28
34
  sx,
29
35
  class: className,
30
36
  children,
@@ -39,6 +45,15 @@
39
45
  {...attrs([layer.item, tone === 'danger' && layer.danger, sx], className)}
40
46
  >
41
47
  {#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
42
- <span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
43
- {#if shortcut}<span {...stylex.attrs(layer.trailing)}>{shortcut}</span>{/if}
48
+ {#if description}
49
+ <span {...stylex.attrs(layer.text)}>
50
+ <span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
51
+ <span {...stylex.attrs(layer.description)}>{description}</span>
52
+ </span>
53
+ {:else}
54
+ <span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
55
+ {/if}
56
+ {#if shortcut || trailing}
57
+ <span {...stylex.attrs(layer.trailing)}>{shortcut}{@render trailing?.()}</span>
58
+ {/if}
44
59
  </DropdownMenu.Item>
@@ -9,6 +9,10 @@ export type MenuItemProps = Loose<Omit<DropdownMenu.ItemProps, 'children' | 'chi
9
9
  shortcut?: string | undefined;
10
10
  /** A 16px icon before the label. */
11
11
  icon?: Snippet | undefined;
12
+ /** A line under the label, such as what the action does. */
13
+ description?: string | undefined;
14
+ /** Something at the end, after the shortcut: a badge, a count, a status. */
15
+ trailing?: Snippet | undefined;
12
16
  sx?: Sx | undefined;
13
17
  children?: Snippet | undefined;
14
18
  }>;
@@ -19,6 +23,10 @@ declare const MenuItem: import("svelte").Component<Loose<Omit<DropdownMenu.ItemP
19
23
  shortcut?: string | undefined;
20
24
  /** A 16px icon before the label. */
21
25
  icon?: Snippet | undefined;
26
+ /** A line under the label, such as what the action does. */
27
+ description?: string | undefined;
28
+ /** Something at the end, after the shortcut: a badge, a count, a status. */
29
+ trailing?: Snippet | undefined;
22
30
  sx?: Sx | undefined;
23
31
  children?: Snippet | undefined;
24
32
  }>, {}, "">;
@@ -2,11 +2,16 @@
2
2
  import type { Loose } from '../../internal/loose.js';
3
3
  import { DropdownMenu } from 'bits-ui';
4
4
  import type { Snippet } from 'svelte';
5
- import { layer } from '../../internal/layer.js';
5
+ import { layer, widthStyle } from '../../internal/layer.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
7
 
8
8
  export type MenuSubContentProps = Loose<
9
9
  Omit<DropdownMenu.SubContentProps, 'children' | 'child'> & {
10
+ /**
11
+ * A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
12
+ * the trigger's width, up to 22rem). It is still no wider than the window has room for.
13
+ */
14
+ width?: string | undefined;
10
15
  sx?: Sx | undefined;
11
16
  children?: Snippet | undefined;
12
17
  }
@@ -17,6 +22,8 @@
17
22
  let {
18
23
  sideOffset = 2,
19
24
  collisionPadding = 8,
25
+ width,
26
+ style,
20
27
  sx,
21
28
  class: className,
22
29
  children,
@@ -30,7 +37,8 @@
30
37
  {collisionPadding}
31
38
  data-slot="menu-sub-content"
32
39
  {...rest}
33
- {...attrs([layer.surface, sx], className)}
40
+ style={widthStyle(width, style)}
41
+ {...attrs([layer.surface, !!width && layer.sized, sx], className)}
34
42
  >
35
43
  {@render children?.()}
36
44
  </DropdownMenu.SubContent>
@@ -3,10 +3,20 @@ import { DropdownMenu } from 'bits-ui';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
5
  export type MenuSubContentProps = Loose<Omit<DropdownMenu.SubContentProps, 'children' | 'child'> & {
6
+ /**
7
+ * A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
8
+ * the trigger's width, up to 22rem). It is still no wider than the window has room for.
9
+ */
10
+ width?: string | undefined;
6
11
  sx?: Sx | undefined;
7
12
  children?: Snippet | undefined;
8
13
  }>;
9
14
  declare const MenuSubContent: import("svelte").Component<Loose<Omit<DropdownMenu.SubContentProps, "children" | "child"> & {
15
+ /**
16
+ * A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
17
+ * the trigger's width, up to 22rem). It is still no wider than the window has room for.
18
+ */
19
+ width?: string | undefined;
10
20
  sx?: Sx | undefined;
11
21
  children?: Snippet | undefined;
12
22
  }>, {}, "">;
@@ -9,7 +9,10 @@
9
9
 
10
10
  export type MenuSubTriggerProps = Loose<
11
11
  Omit<DropdownMenu.SubTriggerProps, 'children' | 'child'> & {
12
+ /** A 16px icon before the label. */
12
13
  icon?: Snippet | undefined;
14
+ /** A line under the label, such as what the submenu holds. */
15
+ description?: string | undefined;
13
16
  sx?: Sx | undefined;
14
17
  children?: Snippet | undefined;
15
18
  }
@@ -22,7 +25,14 @@
22
25
  </script>
23
26
 
24
27
  <script lang="ts">
25
- let { icon, sx, class: className, children, ...rest }: MenuSubTriggerProps = $props();
28
+ let {
29
+ icon,
30
+ description,
31
+ sx,
32
+ class: className,
33
+ children,
34
+ ...rest
35
+ }: MenuSubTriggerProps = $props();
26
36
  </script>
27
37
 
28
38
  <DropdownMenu.SubTrigger
@@ -31,7 +41,14 @@
31
41
  {...attrs([layer.item, sx], className)}
32
42
  >
33
43
  {#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
34
- <span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
44
+ {#if description}
45
+ <span {...stylex.attrs(layer.text)}>
46
+ <span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
47
+ <span {...stylex.attrs(layer.description)}>{description}</span>
48
+ </span>
49
+ {:else}
50
+ <span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
51
+ {/if}
35
52
  <span {...stylex.attrs(layer.trailing)}>
36
53
  <span {...stylex.attrs(styles.chevron)}><Glyph name="chevron" size={14} /></span>
37
54
  </span>
@@ -3,12 +3,18 @@ import { DropdownMenu } from 'bits-ui';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
5
  export type MenuSubTriggerProps = Loose<Omit<DropdownMenu.SubTriggerProps, 'children' | 'child'> & {
6
+ /** A 16px icon before the label. */
6
7
  icon?: Snippet | undefined;
8
+ /** A line under the label, such as what the submenu holds. */
9
+ description?: string | undefined;
7
10
  sx?: Sx | undefined;
8
11
  children?: Snippet | undefined;
9
12
  }>;
10
13
  declare const MenuSubTrigger: import("svelte").Component<Loose<Omit<DropdownMenu.SubTriggerProps, "children" | "child"> & {
14
+ /** A 16px icon before the label. */
11
15
  icon?: Snippet | undefined;
16
+ /** A line under the label, such as what the submenu holds. */
17
+ description?: string | undefined;
12
18
  sx?: Sx | undefined;
13
19
  children?: Snippet | undefined;
14
20
  }>, {}, "">;
@@ -0,0 +1,40 @@
1
+ <!--
2
+ The person's words in their bubble, for a Message.Content that holds more than them
3
+ (`bubble={false}`): attachments over the bubble, cards under it.
4
+ -->
5
+ <script lang="ts" module>
6
+ import type { Snippet } from 'svelte';
7
+ import type { HTMLAttributes } from 'svelte/elements';
8
+ import { shared } from '../../internal/shared.js';
9
+ import { attrs, type Sx } from '../../internal/sx.js';
10
+ import { getMessageContext } from './context.js';
11
+ import { bubble, text } from './styles.js';
12
+
13
+ export type MessageBubbleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
14
+ sx?: Sx | undefined;
15
+ ref?: HTMLDivElement | null | undefined;
16
+ /** What the person wrote. */
17
+ children?: Snippet | undefined;
18
+ };
19
+ </script>
20
+
21
+ <script lang="ts">
22
+ let {
23
+ sx,
24
+ class: className,
25
+ ref = $bindable(null),
26
+ children,
27
+ ...rest
28
+ }: MessageBubbleProps = $props();
29
+
30
+ const message = getMessageContext('Bubble');
31
+ </script>
32
+
33
+ <div
34
+ bind:this={ref}
35
+ data-slot="message-bubble"
36
+ {...rest}
37
+ {...attrs([bubble.bubble, text[message.textSize], shared.edged, sx], className)}
38
+ >
39
+ {@render children?.()}
40
+ </div>
@@ -0,0 +1,12 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type MessageBubbleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
5
+ sx?: Sx | undefined;
6
+ ref?: HTMLDivElement | null | undefined;
7
+ /** What the person wrote. */
8
+ children?: Snippet | undefined;
9
+ };
10
+ declare const MessageBubble: import("svelte").Component<MessageBubbleProps, {}, "ref">;
11
+ type MessageBubble = ReturnType<typeof MessageBubble>;
12
+ export default MessageBubble;