@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
@@ -17,6 +17,11 @@
17
17
  size?: DialogSize | undefined;
18
18
  /** Opens as a sheet along one edge of the window, the full height of it. */
19
19
  side?: 'start' | 'end' | undefined;
20
+ /**
21
+ * The element it is: `form` makes the dialog the form itself, so its fields and the
22
+ * footer's buttons are one form, and Enter in a field submits it. Give it `onsubmit`.
23
+ */
24
+ as?: 'div' | 'form' | undefined;
20
25
  /** Accessible name of the close button in the corner. `null` leaves it out. */
21
26
  closeLabel?: string | null | undefined;
22
27
  sx?: Sx | undefined;
@@ -30,6 +35,7 @@
30
35
  let {
31
36
  size = 'md',
32
37
  side,
38
+ as = 'div',
33
39
  closeLabel = 'Close',
34
40
  sx,
35
41
  class: className,
@@ -48,17 +54,21 @@
48
54
  className
49
55
  )}
50
56
  >
51
- {@render children?.()}
52
- {#if closeLabel}
53
- <span {...stylex.attrs(dialog.close)}>
54
- <Dialog.Close>
55
- {#snippet child({ props })}
56
- <Button {...props} variant="ghost" size="sm" iconOnly aria-label={closeLabel}>
57
- <Glyph name="close" />
58
- </Button>
59
- {/snippet}
60
- </Dialog.Close>
61
- </span>
62
- {/if}
57
+ {#snippet child({ props })}
58
+ <svelte:element this={as} {...props}>
59
+ {@render children?.()}
60
+ {#if closeLabel}
61
+ <span {...stylex.attrs(dialog.close)}>
62
+ <Dialog.Close>
63
+ {#snippet child({ props: close })}
64
+ <Button {...close} variant="ghost" size="sm" iconOnly aria-label={closeLabel}>
65
+ <Glyph name="close" />
66
+ </Button>
67
+ {/snippet}
68
+ </Dialog.Close>
69
+ </span>
70
+ {/if}
71
+ </svelte:element>
72
+ {/snippet}
63
73
  </Dialog.Content>
64
74
  </Dialog.Portal>
@@ -8,6 +8,11 @@ export type DialogContentProps = Loose<Omit<Dialog.ContentProps, 'children' | 'c
8
8
  size?: DialogSize | undefined;
9
9
  /** Opens as a sheet along one edge of the window, the full height of it. */
10
10
  side?: 'start' | 'end' | undefined;
11
+ /**
12
+ * The element it is: `form` makes the dialog the form itself, so its fields and the
13
+ * footer's buttons are one form, and Enter in a field submits it. Give it `onsubmit`.
14
+ */
15
+ as?: 'div' | 'form' | undefined;
11
16
  /** Accessible name of the close button in the corner. `null` leaves it out. */
12
17
  closeLabel?: string | null | undefined;
13
18
  sx?: Sx | undefined;
@@ -19,6 +24,11 @@ declare const DialogContent: import("svelte").Component<Loose<Omit<Dialog.Conten
19
24
  size?: DialogSize | undefined;
20
25
  /** Opens as a sheet along one edge of the window, the full height of it. */
21
26
  side?: "start" | "end" | undefined;
27
+ /**
28
+ * The element it is: `form` makes the dialog the form itself, so its fields and the
29
+ * footer's buttons are one form, and Enter in a field submits it. Give it `onsubmit`.
30
+ */
31
+ as?: "div" | "form" | undefined;
22
32
  /** Accessible name of the close button in the corner. `null` leaves it out. */
23
33
  closeLabel?: string | null | undefined;
24
34
  sx?: Sx | undefined;
@@ -1,42 +1,84 @@
1
- <!-- A labelled break in a timeline: a new day, or "Context compacted". -->
1
+ <!--
2
+ A labelled break in a timeline: a new day, or "Context compacted". Its words wrap
3
+ between the rules when they run long, and the rules keep a little of their length.
4
+ -->
2
5
  <script lang="ts" module>
3
6
  import * as stylex from '@stylexjs/stylex';
4
7
  import type { Snippet } from 'svelte';
8
+ import type { HTMLAttributes } from 'svelte/elements';
5
9
  import { attrs, type Sx } from '../../internal/sx.js';
6
- import { colors, font } from '../../tokens.stylex.js';
10
+ import { colors, font, space } from '../../tokens.stylex.js';
7
11
 
8
- export type DividerProps = {
9
- label: string;
12
+ export type DividerProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'role'> & {
13
+ /** Its words. With `children` too, the name a separator is read by. */
14
+ label?: string | undefined;
15
+ /** A 14px icon before the words. */
10
16
  icon?: Snippet | undefined;
17
+ /**
18
+ * `separator` (the default for a `label` alone) is read as a break, by its label.
19
+ * `status` reads the words out as they change, such as "Compacting…" turning to
20
+ * "Context compacted". `none` leaves the words as text, for words with a link in them.
21
+ */
22
+ role?: 'separator' | 'status' | 'none' | undefined;
11
23
  sx?: Sx | undefined;
12
- class?: string | undefined;
24
+ /** Words of your own in place of `label`: a link to where it came from, a time. */
25
+ children?: Snippet | undefined;
13
26
  };
14
27
 
15
28
  const styles = stylex.create({
16
29
  divider: {
17
30
  display: 'flex',
18
31
  alignItems: 'center',
19
- gap: '0.75rem',
32
+ gap: space.x3,
20
33
  color: colors.textSubtle,
21
34
  fontSize: font.sizeCaption,
22
35
  fontWeight: font.weightMedium,
23
- whiteSpace: 'nowrap',
24
- '::before': { content: '""', flexGrow: 1, height: '1px', backgroundColor: colors.border },
25
- '::after': { content: '""', flexGrow: 1, height: '1px', backgroundColor: colors.border }
36
+ lineHeight: font.leadingSnug,
37
+ '::before': {
38
+ content: '""',
39
+ flexGrow: 1,
40
+ minWidth: space.x3,
41
+ height: '1px',
42
+ backgroundColor: colors.border
43
+ },
44
+ '::after': {
45
+ content: '""',
46
+ flexGrow: 1,
47
+ minWidth: space.x3,
48
+ height: '1px',
49
+ backgroundColor: colors.border
50
+ }
26
51
  },
27
- label: { display: 'inline-flex', alignItems: 'center', gap: '0.375rem' }
52
+ label: {
53
+ display: 'inline-flex',
54
+ alignItems: 'center',
55
+ gap: '0.375rem',
56
+ minWidth: 0,
57
+ textAlign: 'center',
58
+ textWrap: 'balance',
59
+ overflowWrap: 'anywhere'
60
+ },
61
+ icon: { '--narvi-icon-size': '0.875rem', display: 'grid', flexShrink: 0 }
28
62
  });
29
63
  </script>
30
64
 
31
65
  <script lang="ts">
32
- let { label, icon, sx, class: className }: DividerProps = $props();
66
+ let { label, icon, role, sx, class: className, children, ...rest }: DividerProps = $props();
67
+
68
+ // A label alone is a break, read by its label. Words of your own are read as they stand.
69
+ const resolved = $derived(role ?? (children ? 'none' : 'separator'));
70
+ const separator = $derived(resolved === 'separator');
33
71
  </script>
34
72
 
35
73
  <div
36
- role="separator"
37
- aria-label={label}
74
+ role={resolved === 'none' ? undefined : resolved}
75
+ aria-label={separator ? label : undefined}
38
76
  data-slot="divider"
77
+ {...rest}
39
78
  {...attrs([styles.divider, sx], className)}
40
79
  >
41
- <span aria-hidden="true" {...stylex.attrs(styles.label)}>{@render icon?.()}{label}</span>
80
+ <span aria-hidden={separator || undefined} {...stylex.attrs(styles.label)}>
81
+ {#if icon}<span data-icons {...stylex.attrs(styles.icon)}>{@render icon()}</span>{/if}
82
+ {#if children}{@render children()}{:else}{label}{/if}
83
+ </span>
42
84
  </div>
@@ -1,10 +1,20 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
2
3
  import { type Sx } from '../../internal/sx.js';
3
- export type DividerProps = {
4
- label: string;
4
+ export type DividerProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'role'> & {
5
+ /** Its words. With `children` too, the name a separator is read by. */
6
+ label?: string | undefined;
7
+ /** A 14px icon before the words. */
5
8
  icon?: Snippet | undefined;
9
+ /**
10
+ * `separator` (the default for a `label` alone) is read as a break, by its label.
11
+ * `status` reads the words out as they change, such as "Compacting…" turning to
12
+ * "Context compacted". `none` leaves the words as text, for words with a link in them.
13
+ */
14
+ role?: 'separator' | 'status' | 'none' | undefined;
6
15
  sx?: Sx | undefined;
7
- class?: string | undefined;
16
+ /** Words of your own in place of `label`: a link to where it came from, a time. */
17
+ children?: Snippet | undefined;
8
18
  };
9
19
  declare const Divider: import("svelte").Component<DividerProps, {}, "">;
10
20
  type Divider = ReturnType<typeof Divider>;
@@ -7,7 +7,13 @@
7
7
  import { colors, font, radius, space } from '../../tokens.stylex.js';
8
8
 
9
9
  export type EmptyStateProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {
10
+ /** What is empty, as a heading. */
10
11
  title: string;
12
+ /**
13
+ * The heading's level, for the page's outline: `2` by default, for a place that stands
14
+ * where a section's content would be. Its look stays the same at every level.
15
+ */
16
+ level?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
11
17
  /** What to do about it: text, or a snippet with code or a link in it. */
12
18
  description?: string | Snippet | undefined;
13
19
  /** An icon or picture above the title. */
@@ -42,8 +48,11 @@
42
48
  title: {
43
49
  margin: 0,
44
50
  color: colors.text,
51
+ fontFamily: font.body,
45
52
  fontSize: font.sizeReading,
46
- fontWeight: font.weightSemibold
53
+ fontWeight: font.weightSemibold,
54
+ lineHeight: font.leadingSnug,
55
+ letterSpacing: 'normal'
47
56
  },
48
57
  description: {
49
58
  maxWidth: '26rem',
@@ -65,6 +74,7 @@
65
74
  <script lang="ts">
66
75
  let {
67
76
  title,
77
+ level = 2,
68
78
  description,
69
79
  media,
70
80
  actions,
@@ -76,7 +86,7 @@
76
86
 
77
87
  <div data-slot="empty-state" {...rest} {...attrs([styles.empty, sx], className)}>
78
88
  {#if media}<div {...stylex.attrs(styles.media)}>{@render media()}</div>{/if}
79
- <p {...stylex.attrs(styles.title)}>{title}</p>
89
+ <svelte:element this={`h${level}`} {...stylex.attrs(styles.title)}>{title}</svelte:element>
80
90
  {#if description}
81
91
  <p {...stylex.attrs(styles.description)}>
82
92
  {#if typeof description === 'string'}{description}{:else}{@render description()}{/if}
@@ -2,7 +2,13 @@ import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type Sx } from '../../internal/sx.js';
4
4
  export type EmptyStateProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {
5
+ /** What is empty, as a heading. */
5
6
  title: string;
7
+ /**
8
+ * The heading's level, for the page's outline: `2` by default, for a place that stands
9
+ * where a section's content would be. Its look stays the same at every level.
10
+ */
11
+ level?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
6
12
  /** What to do about it: text, or a snippet with code or a link in it. */
7
13
  description?: string | Snippet | undefined;
8
14
  /** An icon or picture above the title. */
@@ -7,12 +7,18 @@
7
7
 
8
8
  export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
9
9
  export type HeadingSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
10
+ export type HeadingWeight = 'regular' | 'medium' | 'semibold' | 'display';
10
11
 
11
12
  export type HeadingProps = Omit<HTMLAttributes<HTMLHeadingElement>, 'children'> & {
12
13
  /** Semantic level: renders `h1` to `h6`. Pick it for the document outline, not the look. */
13
14
  level?: HeadingLevel | undefined;
14
15
  /** Visual size. `xl` and up are set in the display serif; smaller ones in the interface font. */
15
16
  size?: HeadingSize | undefined;
17
+ /**
18
+ * Its weight, from the font's roles. By default the interface sizes are semibold and the
19
+ * display sizes take the display face's own weight (`display`).
20
+ */
21
+ weight?: HeadingWeight | undefined;
16
22
  /** Cuts the heading off with an ellipsis on one line, for a name that may run long. */
17
23
  truncate?: boolean | undefined;
18
24
  sx?: Sx | undefined;
@@ -47,6 +53,13 @@
47
53
  }
48
54
  });
49
55
 
56
+ const weights = stylex.create({
57
+ regular: { fontWeight: font.weightRegular },
58
+ medium: { fontWeight: font.weightMedium },
59
+ semibold: { fontWeight: font.weightSemibold },
60
+ display: { fontWeight: font.weightDisplay }
61
+ });
62
+
50
63
  const sizes = stylex.create({
51
64
  sm: { fontSize: font.sizeBody },
52
65
  md: { fontSize: font.sizeReading },
@@ -77,6 +90,7 @@
77
90
  let {
78
91
  level = 2,
79
92
  size,
93
+ weight,
80
94
  truncate = false,
81
95
  sx,
82
96
  class: className,
@@ -95,6 +109,7 @@
95
109
  styles.base,
96
110
  isDisplay(resolved) ? styles.display : styles.interface,
97
111
  sizes[resolved],
112
+ weight && weights[weight],
98
113
  truncate && styles.truncate,
99
114
  sx
100
115
  ],
@@ -3,11 +3,17 @@ import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type Sx } from '../../internal/sx.js';
4
4
  export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
5
5
  export type HeadingSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
6
+ export type HeadingWeight = 'regular' | 'medium' | 'semibold' | 'display';
6
7
  export type HeadingProps = Omit<HTMLAttributes<HTMLHeadingElement>, 'children'> & {
7
8
  /** Semantic level: renders `h1` to `h6`. Pick it for the document outline, not the look. */
8
9
  level?: HeadingLevel | undefined;
9
10
  /** Visual size. `xl` and up are set in the display serif; smaller ones in the interface font. */
10
11
  size?: HeadingSize | undefined;
12
+ /**
13
+ * Its weight, from the font's roles. By default the interface sizes are semibold and the
14
+ * display sizes take the display face's own weight (`display`).
15
+ */
16
+ weight?: HeadingWeight | undefined;
11
17
  /** Cuts the heading off with an ellipsis on one line, for a name that may run long. */
12
18
  truncate?: boolean | undefined;
13
19
  sx?: Sx | undefined;
@@ -8,6 +8,10 @@
8
8
 
9
9
  export type HoverCardContentProps = Loose<
10
10
  Omit<LinkPreview.ContentProps, 'children' | 'child'> & {
11
+ /** `column` sets its content one part under another, with room between them. */
12
+ layout?: 'block' | 'column' | undefined;
13
+ /** `none` takes the padding away, for content that brings its own. */
14
+ padding?: 'default' | 'none' | undefined;
11
15
  sx?: Sx | undefined;
12
16
  children?: Snippet | undefined;
13
17
  }
@@ -19,7 +23,8 @@
19
23
  width: '20rem',
20
24
  minWidth: 0,
21
25
  padding: '0.75rem'
22
- }
26
+ },
27
+ bare: { padding: 0 }
23
28
  });
24
29
  </script>
25
30
 
@@ -29,6 +34,8 @@
29
34
  sideOffset = 6,
30
35
  collisionPadding = 8,
31
36
  align = 'start',
37
+ layout = 'block',
38
+ padding = 'default',
32
39
  ref = $bindable(null),
33
40
  sx,
34
41
  class: className,
@@ -46,7 +53,16 @@
46
53
  {align}
47
54
  data-slot="hover-card-content"
48
55
  {...rest}
49
- {...attrs([layer.surface, styles.card, sx], className)}
56
+ {...attrs(
57
+ [
58
+ layer.surface,
59
+ styles.card,
60
+ padding === 'none' && styles.bare,
61
+ layout === 'column' && layer.column,
62
+ sx
63
+ ],
64
+ className
65
+ )}
50
66
  >
51
67
  {@render children?.()}
52
68
  </LinkPreview.Content>
@@ -3,10 +3,18 @@ import { LinkPreview } from 'bits-ui';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
5
  export type HoverCardContentProps = Loose<Omit<LinkPreview.ContentProps, 'children' | 'child'> & {
6
+ /** `column` sets its content one part under another, with room between them. */
7
+ layout?: 'block' | 'column' | undefined;
8
+ /** `none` takes the padding away, for content that brings its own. */
9
+ padding?: 'default' | 'none' | undefined;
6
10
  sx?: Sx | undefined;
7
11
  children?: Snippet | undefined;
8
12
  }>;
9
13
  declare const HoverCardContent: import("svelte").Component<Loose<Omit<LinkPreview.ContentProps, "children" | "child"> & {
14
+ /** `column` sets its content one part under another, with room between them. */
15
+ layout?: "block" | "column" | undefined;
16
+ /** `none` takes the padding away, for content that brings its own. */
17
+ padding?: "default" | "none" | undefined;
10
18
  sx?: Sx | undefined;
11
19
  children?: Snippet | undefined;
12
20
  }>, {}, "ref">;
@@ -16,10 +16,18 @@
16
16
  invalid?: boolean | undefined;
17
17
  /**
18
18
  * An icon at the start of the field, such as a magnifier, sized to the field. With one,
19
- * `sx` and `class` style the element around the field.
19
+ * `sx` and `class` style the element around the field, and `inputSx` and `inputClass`
20
+ * the field itself.
20
21
  */
21
22
  icon?: Snippet | undefined;
22
23
  sx?: Sx | undefined;
24
+ /**
25
+ * Styles for the field itself, whether or not there is an `icon`: its text, its fill,
26
+ * its edge. Without an icon they go after `sx`.
27
+ */
28
+ inputSx?: Sx | undefined;
29
+ /** Classes for the field itself, as `inputSx`. */
30
+ inputClass?: ClassValue | null | undefined;
23
31
  ref?: HTMLInputElement | null | undefined;
24
32
  };
25
33
 
@@ -59,6 +67,8 @@
59
67
  'aria-describedby': describedBy,
60
68
  sx,
61
69
  class: className,
70
+ inputSx,
71
+ inputClass,
62
72
  ref = $bindable(null),
63
73
  ...rest
64
74
  }: InputProps = $props();
@@ -86,8 +96,8 @@
86
96
  <span data-icons aria-hidden="true" {...stylex.attrs(styles.icon, iconStyles[size])}>
87
97
  {@render icon()}
88
98
  </span>
89
- {@render input([besideStyles[size]])}
99
+ {@render input([besideStyles[size], inputSx], inputClass)}
90
100
  </span>
91
101
  {:else}
92
- {@render input([sx], className)}
102
+ {@render input([sx, inputSx], [className, inputClass])}
93
103
  {/if}
@@ -1,5 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { HTMLInputAttributes } from 'svelte/elements';
2
+ import type { ClassValue, HTMLInputAttributes } from 'svelte/elements';
3
3
  import '../../internal/icons.css';
4
4
  import { type ControlSize } from '../../internal/control.js';
5
5
  import { type Sx } from '../../internal/sx.js';
@@ -10,10 +10,18 @@ export type InputProps = Omit<HTMLInputAttributes, 'size' | 'children'> & {
10
10
  invalid?: boolean | undefined;
11
11
  /**
12
12
  * An icon at the start of the field, such as a magnifier, sized to the field. With one,
13
- * `sx` and `class` style the element around the field.
13
+ * `sx` and `class` style the element around the field, and `inputSx` and `inputClass`
14
+ * the field itself.
14
15
  */
15
16
  icon?: Snippet | undefined;
16
17
  sx?: Sx | undefined;
18
+ /**
19
+ * Styles for the field itself, whether or not there is an `icon`: its text, its fill,
20
+ * its edge. Without an icon they go after `sx`.
21
+ */
22
+ inputSx?: Sx | undefined;
23
+ /** Classes for the field itself, as `inputSx`. */
24
+ inputClass?: ClassValue | null | undefined;
17
25
  ref?: HTMLInputElement | null | undefined;
18
26
  };
19
27
  declare const Input: import("svelte").Component<InputProps, {}, "value" | "ref">;
@@ -38,6 +38,7 @@
38
38
  import { measureScrollables } from './scrollable.js';
39
39
  import { staticHtml, type StaticContext } from './static.js';
40
40
  import { prose } from './styles.js';
41
+ import { visuallyHidden } from '../../visually-hidden.js';
41
42
 
42
43
  export type MarkdownProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
43
44
  /** The Markdown text: all of it so far, while it streams. */
@@ -479,8 +480,11 @@
479
480
  if (block?.type === 'code') saveFile(codeFileName(codeTitle(block), block.lang), code);
480
481
  } else
481
482
  void navigator.clipboard.writeText(withoutControls(code)).then(
482
- () => showCopied(button, words.copied),
483
- () => {}
483
+ () => {
484
+ showCopied(button, words.copied);
485
+ announce(words.copied);
486
+ },
487
+ () => announce(words.copyFailed)
484
488
  );
485
489
  }
486
490
  }
@@ -613,6 +617,7 @@
613
617
  get labels() {
614
618
  return words;
615
619
  },
620
+ announce,
616
621
  woken: (id) => woken.has(id),
617
622
  task: () => ontaskchange,
618
623
  math: {
@@ -654,6 +659,20 @@
654
659
  }
655
660
  };
656
661
  setMarkdownContext(context);
662
+
663
+ /** What the document's status region says now: emptied a moment later, so it can say it again. */
664
+ let said = $state('');
665
+ let saidTimer: ReturnType<typeof setTimeout> | undefined;
666
+ function announce(message: string) {
667
+ clearTimeout(saidTimer);
668
+ // Emptied first, so the same words twice in a row are read twice
669
+ said = '';
670
+ saidTimer = setTimeout(() => {
671
+ said = message;
672
+ saidTimer = setTimeout(() => (said = ''), 2000);
673
+ }, 50);
674
+ }
675
+ $effect(() => () => clearTimeout(saidTimer));
657
676
  </script>
658
677
 
659
678
  <div
@@ -690,6 +709,7 @@
690
709
  footnotes={before ? NO_FOOTNOTES : footnotes}
691
710
  order={before ? NO_ORDER : footnoteOrder.order}
692
711
  />
712
+ <span role="status" data-markdown-status {...stylex.attrs(visuallyHidden)}>{said}</span>
693
713
  </div>
694
714
 
695
715
  <!--
@@ -168,6 +168,7 @@
168
168
  let { node }: MarkdownDiagramProps = $props();
169
169
 
170
170
  const md = getMarkdownContext();
171
+ const uid = $props.id();
171
172
 
172
173
  const source = $derived(node.value.trim());
173
174
 
@@ -183,6 +184,29 @@
183
184
  let expanded = $state(false);
184
185
  let stage = $state<HTMLElement | null>(null);
185
186
 
187
+ // A diagram's name holds the first of its words: enough to know it by, not all it says
188
+ const NAMED_LABELS = 12;
189
+
190
+ /**
191
+ * Names the picture, which Pele leaves without a name unless its source gives a title:
192
+ * the words in it, so a screen reader can tell one diagram from the next.
193
+ */
194
+ function name(element: HTMLElement) {
195
+ const svg = element.querySelector<SVGSVGElement>(':scope > svg');
196
+ if (!svg) return;
197
+ svg.setAttribute('role', 'img');
198
+ if (svg.hasAttribute('aria-labelledby')) return;
199
+ // Read once, while the name is written: nothing reacts to it
200
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
201
+ const words = new Set<string>();
202
+ for (const text of svg.querySelectorAll('text')) {
203
+ const word = text.textContent?.replace(/\s+/g, ' ').trim();
204
+ if (word) words.add(word);
205
+ if (words.size === NAMED_LABELS) break;
206
+ }
207
+ svg.setAttribute('aria-label', md.labels.diagramPicture([...words]));
208
+ }
209
+
186
210
  /**
187
211
  * Pele shrinks a diagram to the width it has. In a narrow column that makes its labels too
188
212
  * small to read, so past three quarters of its own size the diagram scrolls instead.
@@ -204,6 +228,8 @@
204
228
  ([pele, sanitize]) => {
205
229
  if (gone) return;
206
230
  mounted = pele.mount(element, text, {
231
+ // Two drawings of one diagram, and two diagrams, keep the ids of their titles apart
232
+ idPrefix: `${md.id}-diagram-${uid}-${zoom ? 'zoom' : 'page'}`,
207
233
  links: false,
208
234
  images: false,
209
235
  zoom: zoom
@@ -222,6 +248,7 @@
222
248
  onRender: () => {
223
249
  failure = null;
224
250
  drawn = true;
251
+ name(element);
225
252
  if (!zoom) keepLegible(element);
226
253
  },
227
254
  onError: (cause) =>
@@ -242,6 +269,9 @@
242
269
  }
243
270
 
244
271
  $effect(() => draw(canvas, false));
272
+ $effect(() => {
273
+ if (failure) md.announce(md.labels.diagramFailed(failure.message));
274
+ });
245
275
  // The full-size view draws its own copy, which pans and zooms
246
276
  $effect(() => draw(stage, true));
247
277
  </script>
@@ -263,8 +293,9 @@
263
293
  {/if}
264
294
  </div>
265
295
  {#if failure}
266
- <!-- Said, not shouted: a thread can open with several of these -->
267
- <p role="status" {...attrs([styles.failure])}>
296
+ <!-- Read out through the reply's one status region (below), not a region of its own:
297
+ said, not shouted, as a thread can open with several of these -->
298
+ <p data-markdown-diagram-failure {...attrs([styles.failure])}>
268
299
  {md.labels.diagramFailed(failure.message)}
269
300
  </p>
270
301
  {/if}