@diegopluna/narvi 0.3.1 → 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 (139) 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/app-shell/AppShellMain.svelte +5 -1
  12. package/dist/components/approval/Approval.svelte +14 -1
  13. package/dist/components/approval/Approval.svelte.d.ts +5 -0
  14. package/dist/components/badge/Badge.svelte +19 -2
  15. package/dist/components/badge/Badge.svelte.d.ts +4 -1
  16. package/dist/components/button/Button.svelte +63 -13
  17. package/dist/components/composer/ComposerModelPicker.svelte +80 -13
  18. package/dist/components/composer/ComposerModelPicker.svelte.d.ts +23 -6
  19. package/dist/components/composer/ComposerRoot.svelte +51 -12
  20. package/dist/components/composer/ComposerRoot.svelte.d.ts +16 -0
  21. package/dist/components/composer/ComposerSubmit.svelte +19 -5
  22. package/dist/components/composer/ComposerSubmit.svelte.d.ts +3 -1
  23. package/dist/components/composer/ComposerToggle.svelte +18 -4
  24. package/dist/components/composer/ComposerToggle.svelte.d.ts +2 -0
  25. package/dist/components/composer/ComposerTray.svelte +17 -3
  26. package/dist/components/composer/ComposerTray.svelte.d.ts +5 -0
  27. package/dist/components/composer/context.d.ts +4 -1
  28. package/dist/components/dialog/DialogContent.svelte +22 -12
  29. package/dist/components/dialog/DialogContent.svelte.d.ts +10 -0
  30. package/dist/components/divider/Divider.svelte +56 -14
  31. package/dist/components/divider/Divider.svelte.d.ts +13 -3
  32. package/dist/components/empty-state/EmptyState.svelte +12 -2
  33. package/dist/components/empty-state/EmptyState.svelte.d.ts +6 -0
  34. package/dist/components/heading/Heading.svelte +15 -0
  35. package/dist/components/heading/Heading.svelte.d.ts +6 -0
  36. package/dist/components/hover-card/HoverCardContent.svelte +19 -3
  37. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -0
  38. package/dist/components/input/Input.svelte +13 -3
  39. package/dist/components/input/Input.svelte.d.ts +10 -2
  40. package/dist/components/markdown/Markdown.svelte +22 -2
  41. package/dist/components/markdown/MarkdownDiagram.svelte +33 -2
  42. package/dist/components/markdown/MarkdownFile.svelte +56 -10
  43. package/dist/components/markdown/MarkdownMath.svelte +6 -0
  44. package/dist/components/markdown/MarkdownTable.svelte +3 -4
  45. package/dist/components/markdown/context.d.ts +6 -0
  46. package/dist/components/markdown/labels.d.ts +7 -0
  47. package/dist/components/markdown/labels.js +2 -0
  48. package/dist/components/menu/ContextMenuTrigger.svelte +14 -2
  49. package/dist/components/menu/ContextMenuTrigger.svelte.d.ts +10 -0
  50. package/dist/components/menu/MenuCheckboxItem.svelte +50 -7
  51. package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +16 -0
  52. package/dist/components/menu/MenuContent.svelte +10 -2
  53. package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
  54. package/dist/components/menu/MenuGroup.svelte +16 -0
  55. package/dist/components/menu/MenuGroup.svelte.d.ts +6 -0
  56. package/dist/components/menu/MenuItem.svelte +17 -2
  57. package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
  58. package/dist/components/menu/MenuLabel.svelte +22 -8
  59. package/dist/components/menu/MenuRadioGroup.svelte +16 -0
  60. package/dist/components/menu/MenuRadioGroup.svelte.d.ts +6 -0
  61. package/dist/components/menu/MenuSubContent.svelte +10 -2
  62. package/dist/components/menu/MenuSubContent.svelte.d.ts +10 -0
  63. package/dist/components/menu/MenuSubTrigger.svelte +19 -2
  64. package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -0
  65. package/dist/components/menu/group.d.ts +2 -0
  66. package/dist/components/menu/group.js +9 -0
  67. package/dist/components/menu/index.d.ts +4 -2
  68. package/dist/components/menu/index.js +2 -2
  69. package/dist/components/message/MessageBubble.svelte +40 -0
  70. package/dist/components/message/MessageBubble.svelte.d.ts +12 -0
  71. package/dist/components/message/MessageContent.svelte +23 -14
  72. package/dist/components/message/MessageContent.svelte.d.ts +6 -0
  73. package/dist/components/message/MessageCopy.svelte +27 -15
  74. package/dist/components/message/MessageCopy.svelte.d.ts +9 -2
  75. package/dist/components/message/MessageRoot.svelte +20 -3
  76. package/dist/components/message/MessageRoot.svelte.d.ts +6 -0
  77. package/dist/components/message/context.d.ts +2 -0
  78. package/dist/components/message/index.d.ts +4 -1
  79. package/dist/components/message/index.js +3 -2
  80. package/dist/components/message/styles.d.ts +30 -0
  81. package/dist/components/message/styles.js +24 -0
  82. package/dist/components/notice/Notice.svelte +3 -3
  83. package/dist/components/popover/PopoverContent.svelte +27 -3
  84. package/dist/components/popover/PopoverContent.svelte.d.ts +18 -0
  85. package/dist/components/questionnaire/Questionnaire.svelte +103 -19
  86. package/dist/components/questionnaire/Questionnaire.svelte.d.ts +13 -1
  87. package/dist/components/queued-message/QueuedMessage.svelte +44 -6
  88. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +12 -1
  89. package/dist/components/select/Select.svelte +18 -2
  90. package/dist/components/select/Select.svelte.d.ts +7 -0
  91. package/dist/components/sidebar/SidebarContent.svelte +59 -13
  92. package/dist/components/sidebar/SidebarContent.svelte.d.ts +6 -0
  93. package/dist/components/sidebar/SidebarFolder.svelte +29 -2
  94. package/dist/components/sidebar/SidebarGroup.svelte +50 -7
  95. package/dist/components/sidebar/SidebarGroup.svelte.d.ts +10 -1
  96. package/dist/components/sidebar/SidebarItem.svelte +136 -21
  97. package/dist/components/sidebar/SidebarItem.svelte.d.ts +22 -2
  98. package/dist/components/sidebar/SidebarSwitcher.svelte +18 -2
  99. package/dist/components/sidebar/SidebarSwitcher.svelte.d.ts +2 -0
  100. package/dist/components/sidebar/fold.d.ts +12 -0
  101. package/dist/components/sidebar/fold.js +8 -0
  102. package/dist/components/status-indicator/StatusDot.svelte +90 -0
  103. package/dist/components/status-indicator/StatusDot.svelte.d.ts +18 -0
  104. package/dist/components/toast/Toaster.svelte +1 -1
  105. package/dist/components/toggle/Toggle.svelte +12 -2
  106. package/dist/components/toggle/Toggle.svelte.d.ts +11 -1
  107. package/dist/components/toggle-group/ToggleGroupItem.svelte +10 -1
  108. package/dist/components/toggle-group/ToggleGroupRoot.svelte +7 -1
  109. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +3 -1
  110. package/dist/components/toggle-group/context.d.ts +2 -1
  111. package/dist/components/tooltip/TooltipContent.svelte +13 -1
  112. package/dist/components/tooltip/TooltipContent.svelte.d.ts +10 -0
  113. package/dist/components/work-fold/WorkFold.svelte +13 -4
  114. package/dist/components/work-fold/WorkFold.svelte.d.ts +2 -1
  115. package/dist/focus-ring.d.ts +29 -0
  116. package/dist/focus-ring.js +42 -0
  117. package/dist/index.d.ts +9 -6
  118. package/dist/index.js +8 -2
  119. package/dist/internal/Collapse.svelte +15 -2
  120. package/dist/internal/Glyph.svelte +28 -0
  121. package/dist/internal/Glyph.svelte.d.ts +5 -0
  122. package/dist/internal/Tile.svelte +3 -2
  123. package/dist/internal/layer.d.ts +23 -0
  124. package/dist/internal/layer.js +19 -0
  125. package/dist/internal/toggle.d.ts +8 -1
  126. package/dist/internal/toggle.js +20 -2
  127. package/dist/markdown/file-paths.d.ts +7 -0
  128. package/dist/markdown/file-paths.js +29 -0
  129. package/dist/markdown/files.d.ts +22 -2
  130. package/dist/markdown/files.js +45 -14
  131. package/dist/tokens.stylex.d.ts +3 -0
  132. package/dist/tokens.stylex.js +5 -1
  133. package/package.json +1 -1
  134. package/skills/building-ui/SKILL.md +87 -8
  135. package/skills/building-ui/references/components.md +39 -38
  136. package/skills/markdown/SKILL.md +22 -6
  137. package/skills/setup/SKILL.md +1 -1
  138. package/skills/styling/SKILL.md +10 -3
  139. package/skills/theming/SKILL.md +11 -4
@@ -6,11 +6,13 @@
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
7
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
8
8
  import { media } from '../../media.stylex.js';
9
- import { useComposer } from './context.js';
9
+ import { getComposerContext } from './context.js';
10
10
 
11
11
  export type ComposerToggleProps = Omit<HTMLButtonAttributes, 'children'> & {
12
12
  /** Whether it is on. Bindable. */
13
13
  pressed?: boolean | undefined;
14
+ /** How it shows it is on: lit in the `accent`, or `neutral`, in the fill of what is chosen. */
15
+ tone?: 'accent' | 'neutral' | undefined;
14
16
  sx?: Sx | undefined;
15
17
  ref?: HTMLButtonElement | null | undefined;
16
18
  /** A 16px icon and a short label, such as "Search". */
@@ -64,6 +66,10 @@
64
66
  ':hover': { default: null, [media.hover]: colors.focusHalo }
65
67
  },
66
68
  color: { default: colors.accent, ':hover': colors.accent, [media.forcedColors]: 'Highlight' }
69
+ },
70
+ onNeutral: {
71
+ backgroundColor: colors.fillSelected,
72
+ color: { default: colors.text, [media.forcedColors]: 'Highlight' }
67
73
  }
68
74
  });
69
75
  </script>
@@ -71,6 +77,7 @@
71
77
  <script lang="ts">
72
78
  let {
73
79
  pressed = $bindable(false),
80
+ tone = 'accent',
74
81
  disabled,
75
82
  sx,
76
83
  class: className,
@@ -80,19 +87,26 @@
80
87
  ...rest
81
88
  }: ComposerToggleProps = $props();
82
89
 
83
- const composer = useComposer('Toggle');
90
+ // Works outside a Composer.Root too, such as in a toolbar of the app's own
91
+ const composer = getComposerContext();
84
92
  </script>
85
93
 
86
94
  <button
87
95
  bind:this={ref}
88
96
  type="button"
89
97
  aria-pressed={pressed}
90
- disabled={disabled ?? composer.disabled}
98
+ disabled={disabled ?? composer?.disabled}
91
99
  data-slot="composer-toggle"
92
100
  data-state={pressed ? 'on' : 'off'}
93
101
  {...rest}
94
102
  {...attrs(
95
- [styles.toggle, shared.focusable, styles.withIcon, pressed && styles.on, sx],
103
+ [
104
+ styles.toggle,
105
+ shared.focusable,
106
+ styles.withIcon,
107
+ pressed && (tone === 'neutral' ? styles.onNeutral : styles.on),
108
+ sx
109
+ ],
96
110
  className
97
111
  )}
98
112
  onclick={(event) => {
@@ -4,6 +4,8 @@ import { type Sx } from '../../internal/sx.js';
4
4
  export type ComposerToggleProps = Omit<HTMLButtonAttributes, 'children'> & {
5
5
  /** Whether it is on. Bindable. */
6
6
  pressed?: boolean | undefined;
7
+ /** How it shows it is on: lit in the `accent`, or `neutral`, in the fill of what is chosen. */
8
+ tone?: 'accent' | 'neutral' | undefined;
7
9
  sx?: Sx | undefined;
8
10
  ref?: HTMLButtonElement | null | undefined;
9
11
  /** A 16px icon and a short label, such as "Search". */
@@ -19,6 +19,11 @@
19
19
  label?: string | undefined;
20
20
  /** What is waiting on the person: an Approval, a Questionnaire, QueuedMessages. */
21
21
  pending?: Snippet | undefined;
22
+ /**
23
+ * Whether anything is waiting. Narvi shows the shelf while `pending` puts an element in
24
+ * it with something inside; set this when what is inside hides itself some other way.
25
+ */
26
+ waiting?: boolean | undefined;
22
27
  sx?: Sx | undefined;
23
28
  /** The Composer.Root. */
24
29
  children?: Snippet | undefined;
@@ -27,9 +32,10 @@
27
32
  const styles = stylex.create({
28
33
  tray: { display: 'flex', flexDirection: 'column', minWidth: 0 },
29
34
  // A flat fill whose foot tucks in behind the composer by the composer's own radius, so
30
- // the two read as one piece. It is there only while something is in it.
35
+ // the two read as one piece. It is there only while something is in it: an element
36
+ // that holds something and is not hidden.
31
37
  pending: {
32
- display: { default: 'none', ':has(> *)': 'flex' },
38
+ display: { default: 'none', ':has(> :not(:empty, [hidden], template))': 'flex' },
33
39
  flexDirection: 'column',
34
40
  gap: '0.375rem',
35
41
  padding: '0.375rem',
@@ -43,6 +49,8 @@
43
49
  outlineColor: 'transparent',
44
50
  outlineOffset: '-1px'
45
51
  },
52
+ shown: { display: 'flex' },
53
+ gone: { display: 'none' },
46
54
  // The composer stands in front of the shelf
47
55
  front: {
48
56
  position: 'relative',
@@ -58,6 +66,7 @@
58
66
  let {
59
67
  label = 'Waiting for you',
60
68
  pending,
69
+ waiting,
61
70
  sx,
62
71
  class: className,
63
72
  children,
@@ -70,7 +79,12 @@
70
79
  role="group"
71
80
  aria-label={label}
72
81
  data-slot="composer-tray-pending"
73
- {...stylex.attrs(styles.pending)}
82
+ data-waiting={waiting}
83
+ {...stylex.attrs(
84
+ styles.pending,
85
+ waiting === true && styles.shown,
86
+ waiting === false && styles.gone
87
+ )}
74
88
  >
75
89
  {@render pending?.()}
76
90
  </div>
@@ -6,6 +6,11 @@ export type ComposerTrayProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>
6
6
  label?: string | undefined;
7
7
  /** What is waiting on the person: an Approval, a Questionnaire, QueuedMessages. */
8
8
  pending?: Snippet | undefined;
9
+ /**
10
+ * Whether anything is waiting. Narvi shows the shelf while `pending` puts an element in
11
+ * it with something inside; set this when what is inside hides itself some other way.
12
+ */
13
+ waiting?: boolean | undefined;
9
14
  sx?: Sx | undefined;
10
15
  /** The Composer.Root. */
11
16
  children?: Snippet | undefined;
@@ -23,8 +23,10 @@ export type ComposerContext = {
23
23
  readonly disabled: boolean;
24
24
  /** True while a reply is on its way. Submitting stops it instead of sending. */
25
25
  readonly busy: boolean;
26
+ /** True while a message is on its way and cannot be stopped: nothing can be sent or stopped. */
27
+ readonly sending: boolean;
26
28
  /**
27
- * Something to send, text or files, and nothing in the way of sending it.
29
+ * Something to send, text or files (or `hasContent`), and nothing in the way of sending it.
28
30
  * While a reply is under way, true only if the composer can queue.
29
31
  */
30
32
  readonly canSend: boolean;
@@ -37,6 +39,7 @@ export type ComposerContext = {
37
39
  browse(): void;
38
40
  /** True once a Composer.Attachments is placed: only then are dropped or pasted files taken. */
39
41
  readonly attachable: boolean;
42
+ /** Focuses the text field: the textarea, or an editor of your own marked `data-composer-field`. */
40
43
  focus(): void;
41
44
  /** Reads a short message out to assistive technology, such as "Attached report.pdf". */
42
45
  announce(message: string): void;
@@ -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,
@@ -44,9 +51,18 @@
44
51
  {sideOffset}
45
52
  {collisionPadding}
46
53
  {align}
47
- data-slot="hover-card"
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">;