@diegopluna/narvi 0.3.2 → 0.3.4

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 (133) 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 +14 -2
  12. package/dist/components/app-shell/AppShellPanel.svelte +77 -12
  13. package/dist/components/app-shell/AppShellPanel.svelte.d.ts +11 -1
  14. package/dist/components/app-shell/AppShellSheet.svelte +11 -1
  15. package/dist/components/app-shell/context.d.ts +8 -0
  16. package/dist/components/app-shell/context.js +7 -0
  17. package/dist/components/approval/Approval.svelte +14 -1
  18. package/dist/components/approval/Approval.svelte.d.ts +5 -0
  19. package/dist/components/avatar/AvatarRoot.svelte +20 -7
  20. package/dist/components/avatar/AvatarRoot.svelte.d.ts +10 -3
  21. package/dist/components/badge/Badge.svelte +3 -1
  22. package/dist/components/badge/Badge.svelte.d.ts +1 -1
  23. package/dist/components/button/Button.svelte +28 -6
  24. package/dist/components/button/Button.svelte.d.ts +7 -0
  25. package/dist/components/composer/ComposerModelPicker.svelte +80 -13
  26. package/dist/components/composer/ComposerModelPicker.svelte.d.ts +23 -6
  27. package/dist/components/composer/ComposerRoot.svelte +51 -12
  28. package/dist/components/composer/ComposerRoot.svelte.d.ts +16 -0
  29. package/dist/components/composer/ComposerSubmit.svelte +19 -5
  30. package/dist/components/composer/ComposerSubmit.svelte.d.ts +3 -1
  31. package/dist/components/composer/ComposerToggle.svelte +18 -4
  32. package/dist/components/composer/ComposerToggle.svelte.d.ts +2 -0
  33. package/dist/components/composer/ComposerTray.svelte +17 -3
  34. package/dist/components/composer/ComposerTray.svelte.d.ts +5 -0
  35. package/dist/components/composer/context.d.ts +4 -1
  36. package/dist/components/dialog/DialogContent.svelte +22 -12
  37. package/dist/components/dialog/DialogContent.svelte.d.ts +10 -0
  38. package/dist/components/divider/Divider.svelte +56 -14
  39. package/dist/components/divider/Divider.svelte.d.ts +13 -3
  40. package/dist/components/empty-state/EmptyState.svelte +12 -2
  41. package/dist/components/empty-state/EmptyState.svelte.d.ts +6 -0
  42. package/dist/components/heading/Heading.svelte +15 -0
  43. package/dist/components/heading/Heading.svelte.d.ts +6 -0
  44. package/dist/components/hover-card/HoverCardContent.svelte +18 -2
  45. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -0
  46. package/dist/components/input/Input.svelte +13 -3
  47. package/dist/components/input/Input.svelte.d.ts +10 -2
  48. package/dist/components/markdown/Markdown.svelte +22 -2
  49. package/dist/components/markdown/MarkdownDiagram.svelte +33 -2
  50. package/dist/components/markdown/MarkdownFile.svelte +56 -10
  51. package/dist/components/markdown/MarkdownMath.svelte +6 -0
  52. package/dist/components/markdown/MarkdownTable.svelte +3 -4
  53. package/dist/components/markdown/context.d.ts +6 -0
  54. package/dist/components/markdown/labels.d.ts +7 -0
  55. package/dist/components/markdown/labels.js +2 -0
  56. package/dist/components/menu/MenuCheckboxItem.svelte +44 -7
  57. package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +12 -2
  58. package/dist/components/menu/MenuContent.svelte +10 -2
  59. package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
  60. package/dist/components/menu/MenuItem.svelte +17 -2
  61. package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
  62. package/dist/components/menu/MenuSubContent.svelte +10 -2
  63. package/dist/components/menu/MenuSubContent.svelte.d.ts +10 -0
  64. package/dist/components/menu/MenuSubTrigger.svelte +19 -2
  65. package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -0
  66. package/dist/components/message/MessageBubble.svelte +40 -0
  67. package/dist/components/message/MessageBubble.svelte.d.ts +12 -0
  68. package/dist/components/message/MessageContent.svelte +23 -14
  69. package/dist/components/message/MessageContent.svelte.d.ts +6 -0
  70. package/dist/components/message/MessageCopy.svelte +27 -15
  71. package/dist/components/message/MessageCopy.svelte.d.ts +9 -2
  72. package/dist/components/message/MessageRoot.svelte +20 -3
  73. package/dist/components/message/MessageRoot.svelte.d.ts +6 -0
  74. package/dist/components/message/context.d.ts +2 -0
  75. package/dist/components/message/index.d.ts +4 -1
  76. package/dist/components/message/index.js +3 -2
  77. package/dist/components/message/styles.d.ts +30 -0
  78. package/dist/components/message/styles.js +24 -0
  79. package/dist/components/notice/Notice.svelte +3 -3
  80. package/dist/components/popover/PopoverContent.svelte +27 -3
  81. package/dist/components/popover/PopoverContent.svelte.d.ts +18 -0
  82. package/dist/components/questionnaire/Questionnaire.svelte +103 -19
  83. package/dist/components/questionnaire/Questionnaire.svelte.d.ts +13 -1
  84. package/dist/components/queued-message/QueuedMessage.svelte +44 -6
  85. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +12 -1
  86. package/dist/components/segmented/SegmentedControl.svelte +12 -1
  87. package/dist/components/segmented/SegmentedControl.svelte.d.ts +3 -1
  88. package/dist/components/select/Select.svelte +43 -6
  89. package/dist/components/select/Select.svelte.d.ts +14 -0
  90. package/dist/components/settings-row/SettingsRow.svelte +87 -37
  91. package/dist/components/settings-row/SettingsRow.svelte.d.ts +13 -0
  92. package/dist/components/split-button/SplitButton.svelte +137 -0
  93. package/dist/components/split-button/SplitButton.svelte.d.ts +29 -0
  94. package/dist/components/tab-strip/TabStrip.svelte +337 -93
  95. package/dist/components/tab-strip/TabStrip.svelte.d.ts +36 -1
  96. package/dist/components/tab-strip/drag.svelte.d.ts +31 -0
  97. package/dist/components/tab-strip/drag.svelte.js +148 -0
  98. package/dist/components/toast/Toaster.svelte +1 -1
  99. package/dist/components/toggle/Toggle.svelte +12 -2
  100. package/dist/components/toggle/Toggle.svelte.d.ts +11 -1
  101. package/dist/components/toggle-group/ToggleGroupItem.svelte +10 -1
  102. package/dist/components/toggle-group/ToggleGroupRoot.svelte +7 -1
  103. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +3 -1
  104. package/dist/components/toggle-group/context.d.ts +2 -1
  105. package/dist/components/tooltip/TooltipContent.svelte +13 -1
  106. package/dist/components/tooltip/TooltipContent.svelte.d.ts +10 -0
  107. package/dist/components/work-fold/WorkFold.svelte +13 -4
  108. package/dist/components/work-fold/WorkFold.svelte.d.ts +2 -1
  109. package/dist/focus-ring.d.ts +29 -0
  110. package/dist/focus-ring.js +42 -0
  111. package/dist/index.d.ts +8 -5
  112. package/dist/index.js +8 -2
  113. package/dist/internal/Collapse.svelte +15 -2
  114. package/dist/internal/Glyph.svelte +28 -0
  115. package/dist/internal/Glyph.svelte.d.ts +5 -0
  116. package/dist/internal/Tile.svelte +3 -2
  117. package/dist/internal/layer.d.ts +23 -0
  118. package/dist/internal/layer.js +19 -0
  119. package/dist/internal/toggle.d.ts +8 -1
  120. package/dist/internal/toggle.js +20 -2
  121. package/dist/markdown/file-paths.d.ts +7 -0
  122. package/dist/markdown/file-paths.js +29 -0
  123. package/dist/markdown/files.d.ts +22 -2
  124. package/dist/markdown/files.js +45 -14
  125. package/dist/tokens.stylex.d.ts +3 -0
  126. package/dist/tokens.stylex.js +5 -1
  127. package/package.json +1 -1
  128. package/skills/building-ui/SKILL.md +77 -5
  129. package/skills/building-ui/references/components.md +51 -50
  130. package/skills/markdown/SKILL.md +22 -6
  131. package/skills/setup/SKILL.md +1 -1
  132. package/skills/styling/SKILL.md +10 -3
  133. package/skills/theming/SKILL.md +11 -4
@@ -10,6 +10,7 @@
10
10
  import { attrs, type Sx } from '../../internal/sx.js';
11
11
  import { colors, font, radius } from '../../tokens.stylex.js';
12
12
  import Button from '../button/Button.svelte';
13
+ import { text, type MessageTextSize } from '../message/styles.js';
13
14
  import * as Tooltip from '../tooltip/index.js';
14
15
 
15
16
  export type QueuedMessageStatus = 'queued' | 'editing' | 'unsent';
@@ -26,12 +27,23 @@
26
27
  /** Stops the turn and sends it. */
27
28
  onsend?: (() => void) | undefined;
28
29
  labels?: Partial<Record<'edit' | 'takeBack' | 'steer' | 'send', string>> | undefined;
30
+ /**
31
+ * Holds the actions back, such as while the message is being sent: `true` for all of
32
+ * them, or the ones to hold back by name.
33
+ */
34
+ disabled?: boolean | QueuedMessageAction[] | undefined;
35
+ /** The size its words are read at, as a Message's `textSize`. */
36
+ textSize?: MessageTextSize | undefined;
37
+ /** What goes with it, over the bubble: its images and files. */
38
+ attachments?: Snippet | undefined;
29
39
  sx?: Sx | undefined;
30
40
  class?: string | undefined;
31
- /** The message. */
41
+ /** The message's words. With none, only its attachments show, with no bubble. */
32
42
  children?: Snippet | undefined;
33
43
  };
34
44
 
45
+ export type QueuedMessageAction = 'edit' | 'takeBack' | 'steer' | 'send';
46
+
35
47
  // One short label each. What "queued" means is said on hover, not strung on with a dot.
36
48
  const STATUS: Record<QueuedMessageStatus, string> = {
37
49
  queued: 'Queued',
@@ -51,7 +63,18 @@
51
63
  gap: '0.25rem',
52
64
  minWidth: 0
53
65
  },
66
+ attachments: {
67
+ display: { default: 'flex', ':empty': 'none' },
68
+ flexWrap: 'wrap',
69
+ justifyContent: 'flex-end',
70
+ gap: '0.375rem',
71
+ maxWidth: 'min(85%, 36rem)',
72
+ // Waiting, as the bubble is
73
+ opacity: 0.8
74
+ },
54
75
  bubble: {
76
+ // A bubble with no words in it is not drawn
77
+ display: { default: 'block', ':empty': 'none' },
55
78
  maxWidth: 'min(85%, 36rem)',
56
79
  paddingBlock: '0.5625rem',
57
80
  paddingInline: '0.875rem',
@@ -59,8 +82,6 @@
59
82
  backgroundColor: 'transparent',
60
83
  boxShadow: `inset 0 0 0 1px ${colors.borderStrong}`,
61
84
  color: colors.textMuted,
62
- fontSize: font.sizeReading,
63
- lineHeight: font.leadingNormal,
64
85
  whiteSpace: 'pre-wrap',
65
86
  overflowWrap: 'anywhere'
66
87
  },
@@ -87,11 +108,17 @@
87
108
  onsteer,
88
109
  onsend,
89
110
  labels,
111
+ disabled = false,
112
+ textSize = 'reading',
113
+ attachments,
90
114
  sx,
91
115
  class: className,
92
116
  children
93
117
  }: QueuedMessageProps = $props();
94
118
 
119
+ const held = (key: QueuedMessageAction) =>
120
+ disabled === true || (Array.isArray(disabled) && disabled.includes(key));
121
+
95
122
  const actions = $derived(
96
123
  (
97
124
  [
@@ -105,9 +132,19 @@
105
132
  </script>
106
133
 
107
134
  <div data-slot="queued-message" data-status={status} {...attrs([styles.root, sx], className)}>
108
- <div {...stylex.attrs(styles.bubble, status !== 'unsent' && styles.waiting)}>
109
- {@render children?.()}
110
- </div>
135
+ {#if attachments}
136
+ <div data-slot="queued-message-attachments" {...stylex.attrs(styles.attachments)}>
137
+ {@render attachments()}
138
+ </div>
139
+ {/if}
140
+ {#if children}
141
+ <div
142
+ data-slot="queued-message-bubble"
143
+ {...stylex.attrs(styles.bubble, text[textSize], status !== 'unsent' && styles.waiting)}
144
+ >
145
+ {@render children()}
146
+ </div>
147
+ {/if}
111
148
  <div {...stylex.attrs(styles.foot)}>
112
149
  <span
113
150
  title={statusText ? undefined : DETAIL[status]}
@@ -126,6 +163,7 @@
126
163
  size="sm"
127
164
  iconOnly
128
165
  aria-label={label}
166
+ disabled={held(key)}
129
167
  onclick={() => handler?.()}
130
168
  >
131
169
  <Glyph name={icon as GlyphName} />
@@ -1,5 +1,6 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import { type Sx } from '../../internal/sx.js';
3
+ import { type MessageTextSize } from '../message/styles.js';
3
4
  export type QueuedMessageStatus = 'queued' | 'editing' | 'unsent';
4
5
  export type QueuedMessageProps = {
5
6
  status?: QueuedMessageStatus | undefined;
@@ -13,11 +14,21 @@ export type QueuedMessageProps = {
13
14
  /** Stops the turn and sends it. */
14
15
  onsend?: (() => void) | undefined;
15
16
  labels?: Partial<Record<'edit' | 'takeBack' | 'steer' | 'send', string>> | undefined;
17
+ /**
18
+ * Holds the actions back, such as while the message is being sent: `true` for all of
19
+ * them, or the ones to hold back by name.
20
+ */
21
+ disabled?: boolean | QueuedMessageAction[] | undefined;
22
+ /** The size its words are read at, as a Message's `textSize`. */
23
+ textSize?: MessageTextSize | undefined;
24
+ /** What goes with it, over the bubble: its images and files. */
25
+ attachments?: Snippet | undefined;
16
26
  sx?: Sx | undefined;
17
27
  class?: string | undefined;
18
- /** The message. */
28
+ /** The message's words. With none, only its attachments show, with no bubble. */
19
29
  children?: Snippet | undefined;
20
30
  };
31
+ export type QueuedMessageAction = 'edit' | 'takeBack' | 'steer' | 'send';
21
32
  declare const QueuedMessage: import("svelte").Component<QueuedMessageProps, {}, "">;
22
33
  type QueuedMessage = ReturnType<typeof QueuedMessage>;
23
34
  export default QueuedMessage;
@@ -23,7 +23,10 @@
23
23
  disabled?: boolean | undefined;
24
24
  };
25
25
 
26
- export type SegmentedControlProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
26
+ export type SegmentedControlProps = Omit<
27
+ HTMLAttributes<HTMLDivElement>,
28
+ 'children' | 'onchange'
29
+ > & {
27
30
  /** The choices, in order. Two to five read best. */
28
31
  options: SegmentedOption[];
29
32
  /** The selected option's value. Bindable. */
@@ -31,6 +34,8 @@
31
34
  /** Form field name. Generated when omitted. */
32
35
  name?: string | undefined;
33
36
  disabled?: boolean | undefined;
37
+ /** Called when the person picks an option, with its value: not when `value` is set. */
38
+ onchange?: ((value: string) => void) | undefined;
34
39
  sx?: Sx | undefined;
35
40
  };
36
41
 
@@ -139,6 +144,7 @@
139
144
  value = $bindable(),
140
145
  name,
141
146
  disabled = false,
147
+ onchange,
142
148
  sx,
143
149
  class: className,
144
150
  ...rest
@@ -181,6 +187,11 @@
181
187
  name={name ?? uid}
182
188
  value={option.value}
183
189
  bind:group={value}
190
+ onchange={() => {
191
+ // The binding may not have run yet: the value is set before the callback reads it
192
+ value = option.value;
193
+ onchange?.(option.value);
194
+ }}
184
195
  disabled={off}
185
196
  aria-describedby={titleId}
186
197
  {...stylex.attrs(styles.input, segmentedInputMarker)}
@@ -14,7 +14,7 @@ export type SegmentedOption = {
14
14
  icon?: IconComponent | undefined;
15
15
  disabled?: boolean | undefined;
16
16
  };
17
- export type SegmentedControlProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
17
+ export type SegmentedControlProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onchange'> & {
18
18
  /** The choices, in order. Two to five read best. */
19
19
  options: SegmentedOption[];
20
20
  /** The selected option's value. Bindable. */
@@ -22,6 +22,8 @@ export type SegmentedControlProps = Omit<HTMLAttributes<HTMLDivElement>, 'childr
22
22
  /** Form field name. Generated when omitted. */
23
23
  name?: string | undefined;
24
24
  disabled?: boolean | undefined;
25
+ /** Called when the person picks an option, with its value: not when `value` is set. */
26
+ onchange?: ((value: string) => void) | undefined;
25
27
  sx?: Sx | undefined;
26
28
  };
27
29
  declare const SegmentedControl: import("svelte").Component<SegmentedControlProps, {}, "value">;
@@ -6,11 +6,12 @@
6
6
  import type { IconComponent } from '../../internal/icon.js';
7
7
  import { Select } from 'bits-ui';
8
8
  import * as stylex from '@stylexjs/stylex';
9
+ import type { Snippet } from 'svelte';
9
10
  import Glyph from '../../internal/Glyph.svelte';
10
11
  import { control, type ControlSize } from '../../internal/control.js';
11
12
  import { layer } from '../../internal/layer.js';
12
13
  import { attrs, type Sx } from '../../internal/sx.js';
13
- import { colors } from '../../tokens.stylex.js';
14
+ import { colors, font } from '../../tokens.stylex.js';
14
15
  import { getFieldContext } from '../field/context.js';
15
16
 
16
17
  export type SelectOption = {
@@ -21,6 +22,13 @@
21
22
  * component such as a Lucide icon, which is sized to fit.
22
23
  */
23
24
  icon?: IconComponent | undefined;
25
+ /**
26
+ * More about the option, at the end of its row in the list and muted: a commit's short
27
+ * hash, a device's size, a count. It is not shown on the trigger.
28
+ */
29
+ detail?: string | undefined;
30
+ /** Sets `detail` in monospace, for code such as a hash. */
31
+ detailMono?: boolean | undefined;
24
32
  /** Options with the same group are listed together under its name. */
25
33
  group?: string | undefined;
26
34
  disabled?: boolean | undefined;
@@ -32,6 +40,12 @@
32
40
  value?: string | undefined;
33
41
  /** Shown while nothing is chosen. */
34
42
  placeholder?: string | undefined;
43
+ /**
44
+ * Draws each option's icon, in the list and on the trigger, in place of `option.icon`:
45
+ * for an icon that takes props, such as a provider's mark in its colours, or a dot.
46
+ * It is given the option, and is sized as a 16px icon.
47
+ */
48
+ optionIcon?: Snippet<[option: SelectOption]> | undefined;
35
49
  size?: ControlSize | undefined;
36
50
  /** Where the list lines up with the trigger: `end` for a select at the end of a row. */
37
51
  align?: 'start' | 'center' | 'end' | undefined;
@@ -72,9 +86,16 @@
72
86
  color: colors.textMuted
73
87
  },
74
88
  selector: { display: 'grid', flexShrink: 0, color: colors.textSubtle },
75
- check: { display: 'grid', marginInlineStart: 'auto', color: colors.accent }
89
+ check: { display: 'grid', marginInlineStart: 'auto', color: colors.accent },
90
+ // Where options have details, every row keeps the check's room, so the details line up
91
+ unchecked: { visibility: 'hidden' },
92
+ mono: { fontFamily: font.mono }
76
93
  });
77
94
 
95
+ // Made here: the item's `selected` comes through a snippet's argument, which StyleX cannot read
96
+ const check = stylex.attrs(styles.check);
97
+ const checkHidden = stylex.attrs(styles.check, styles.unchecked);
98
+
78
99
  type Group = { name: string | undefined; options: SelectOption[] };
79
100
  function grouped(options: SelectOption[]): Group[] {
80
101
  const groups: Group[] = [];
@@ -92,6 +113,7 @@
92
113
  options,
93
114
  value = $bindable(),
94
115
  placeholder = 'Choose…',
116
+ optionIcon,
95
117
  size = 'md',
96
118
  align = 'start',
97
119
  disabled,
@@ -107,6 +129,7 @@
107
129
  const field = getFieldContext();
108
130
  const selected = $derived(options.find((option) => option.value === value));
109
131
  const groups = $derived(grouped(options));
132
+ const detailed = $derived(options.some((option) => option.detail));
110
133
  </script>
111
134
 
112
135
  <Select.Root
@@ -124,7 +147,11 @@
124
147
  data-slot="select"
125
148
  {...attrs([control.base, control[size], styles.trigger, sx], className)}
126
149
  >
127
- {#if selected?.icon}
150
+ {#if selected && optionIcon}
151
+ <span data-icons aria-hidden="true" {...stylex.attrs(styles.icon)}
152
+ >{@render optionIcon(selected)}</span
153
+ >
154
+ {:else if selected?.icon}
128
155
  <span data-icons {...stylex.attrs(styles.icon)}><selected.icon aria-hidden="true" /></span>
129
156
  {/if}
130
157
  <span {...stylex.attrs(styles.value, !selected && styles.placeholder)}>
@@ -150,14 +177,24 @@
150
177
  {...stylex.attrs(layer.item)}
151
178
  >
152
179
  {#snippet children({ selected })}
153
- {#if option.icon}
180
+ {#if optionIcon}
181
+ <span data-icons aria-hidden="true" {...stylex.attrs(layer.icon)}
182
+ >{@render optionIcon(option)}</span
183
+ >
184
+ {:else if option.icon}
154
185
  <span data-icons {...stylex.attrs(layer.icon)}
155
186
  ><option.icon aria-hidden="true" /></span
156
187
  >
157
188
  {/if}
158
189
  <span {...stylex.attrs(layer.label)}>{option.label}</span>
159
- {#if selected}
160
- <span {...stylex.attrs(styles.check)}><Glyph name="check" stroke={1.75} /></span
190
+ {#if option.detail}
191
+ <span {...stylex.attrs(layer.trailing, option.detailMono && styles.mono)}
192
+ >{option.detail}</span
193
+ >
194
+ {/if}
195
+ {#if selected || detailed}
196
+ <span aria-hidden={!selected || undefined} {...selected ? check : checkHidden}
197
+ ><Glyph name="check" stroke={1.75} /></span
161
198
  >
162
199
  {/if}
163
200
  {/snippet}
@@ -1,5 +1,6 @@
1
1
  import type { IconComponent } from '../../internal/icon.js';
2
2
  import { Select } from 'bits-ui';
3
+ import type { Snippet } from 'svelte';
3
4
  import { type ControlSize } from '../../internal/control.js';
4
5
  import { type Sx } from '../../internal/sx.js';
5
6
  export type SelectOption = {
@@ -10,6 +11,13 @@ export type SelectOption = {
10
11
  * component such as a Lucide icon, which is sized to fit.
11
12
  */
12
13
  icon?: IconComponent | undefined;
14
+ /**
15
+ * More about the option, at the end of its row in the list and muted: a commit's short
16
+ * hash, a device's size, a count. It is not shown on the trigger.
17
+ */
18
+ detail?: string | undefined;
19
+ /** Sets `detail` in monospace, for code such as a hash. */
20
+ detailMono?: boolean | undefined;
13
21
  /** Options with the same group are listed together under its name. */
14
22
  group?: string | undefined;
15
23
  disabled?: boolean | undefined;
@@ -20,6 +28,12 @@ export type SelectProps = {
20
28
  value?: string | undefined;
21
29
  /** Shown while nothing is chosen. */
22
30
  placeholder?: string | undefined;
31
+ /**
32
+ * Draws each option's icon, in the list and on the trigger, in place of `option.icon`:
33
+ * for an icon that takes props, such as a provider's mark in its colours, or a dot.
34
+ * It is given the option, and is sized as a 16px icon.
35
+ */
36
+ optionIcon?: Snippet<[option: SelectOption]> | undefined;
23
37
  size?: ControlSize | undefined;
24
38
  /** Where the list lines up with the trigger: `end` for a select at the end of a row. */
25
39
  align?: 'start' | 'center' | 'end' | undefined;
@@ -11,11 +11,12 @@
11
11
  import Glyph from '../../internal/Glyph.svelte';
12
12
  import { shared } from '../../internal/shared.js';
13
13
  import { attrs, type Sx } from '../../internal/sx.js';
14
- import { colors, motion, radius, space } from '../../tokens.stylex.js';
14
+ import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
15
15
  import { media } from '../../media.stylex.js';
16
16
  import { typography } from '../../typography.js';
17
17
  import * as Tooltip from '../tooltip/index.js';
18
18
  import { getSettingsGroupContext } from '../settings-group/context.js';
19
+ import '../../internal/icons.css';
19
20
 
20
21
  export type SettingsRowControl = {
21
22
  /** For the control's `id`, which the label's `for` names: `controlId` when it is set. */
@@ -28,6 +29,18 @@
28
29
 
29
30
  export type SettingsRowProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {
30
31
  label: string;
32
+ /**
33
+ * Before the label and the description: a provider's mark, an icon of what the row is,
34
+ * an Avatar. Decoration: the label names the row.
35
+ */
36
+ leading?: Snippet | undefined;
37
+ /** Sets the label in the muted ink: for something switched off, or not to be had here. */
38
+ dimmed?: boolean | undefined;
39
+ /**
40
+ * Sets the label in monospace, for a name that is code: an environment variable, a
41
+ * header, a tool, a path.
42
+ */
43
+ mono?: boolean | undefined;
31
44
  /**
32
45
  * What the setting does, in a sentence or two, behind an info mark beside the label. It
33
46
  * opens on a hover, or as the mark takes the focus.
@@ -88,9 +101,27 @@
88
101
  text: { display: 'flex', flexDirection: 'column', gap: '0.125rem', minWidth: 0 },
89
102
  // Beside the control, the text takes the room and wraps the control under it below 14rem
90
103
  textInline: { flexGrow: 1, flexShrink: 1, flexBasis: '14rem' },
104
+ // The leading mark and the text beside it
105
+ lead: { display: 'flex', alignItems: 'center', gap: space.x3, minWidth: 0 },
106
+ leading: {
107
+ '--narvi-icon-size': '1rem',
108
+ display: 'grid',
109
+ placeItems: 'center',
110
+ flexShrink: 0,
111
+ color: colors.textMuted
112
+ },
113
+ leadText: { flexGrow: 1 },
91
114
  // Room for the info mark's focus ring beside the label
92
115
  title: { display: 'flex', alignItems: 'center', gap: '0.375rem', minWidth: 0 },
93
116
  label: { color: colors.text },
117
+ dimmed: { color: colors.textMuted },
118
+ // Mono runs wider than the text's face: a step down, and no heavier than the text
119
+ mono: {
120
+ fontFamily: font.mono,
121
+ fontSize: font.sizeMeta,
122
+ fontWeight: font.weightRegular,
123
+ overflowWrap: 'anywhere'
124
+ },
94
125
  about: {
95
126
  position: 'relative',
96
127
  display: 'inline-grid',
@@ -127,6 +158,9 @@
127
158
  <script lang="ts">
128
159
  let {
129
160
  label,
161
+ leading,
162
+ dimmed = false,
163
+ mono = false,
130
164
  about,
131
165
  description,
132
166
  stacked = false,
@@ -149,6 +183,12 @@
149
183
  .filter(Boolean)
150
184
  .join(' ') || undefined
151
185
  );
186
+ const labelStyles = $derived([
187
+ typography.label,
188
+ styles.label,
189
+ dimmed && styles.dimmed,
190
+ mono && styles.mono
191
+ ]);
152
192
  const control = $derived({
153
193
  id: controlId ?? `${uid}-control`,
154
194
  labelId: `${uid}-label`,
@@ -171,43 +211,53 @@
171
211
  className
172
212
  )}
173
213
  >
174
- <div {...stylex.attrs(styles.text, !stacked && styles.textInline)}>
175
- <span {...stylex.attrs(styles.title)}>
176
- {#if labelFor && children}
177
- <label
178
- id={control.labelId}
179
- for={control.id}
180
- {...stylex.attrs(typography.label, styles.label)}>{label}</label
181
- >
182
- {:else}
183
- <span id={control.labelId} {...stylex.attrs(typography.label, styles.label)}>{label}</span>
184
- {/if}
185
- {#if about}
186
- <Tooltip.Provider delayDuration={400}>
187
- <Tooltip.Root>
188
- <Tooltip.Trigger>
189
- {#snippet child({ props })}
190
- <button
191
- {...props}
192
- type="button"
193
- aria-label="About {label}"
194
- {...stylex.attrs(styles.about, shared.focusable)}
195
- >
196
- <Glyph name="info" size={14} />
197
- </button>
198
- {/snippet}
199
- </Tooltip.Trigger>
200
- <Tooltip.Content side="top">{about}</Tooltip.Content>
201
- </Tooltip.Root>
202
- </Tooltip.Provider>
214
+ {#snippet text(sx: Sx | false)}
215
+ <div {...stylex.attrs(styles.text, sx)}>
216
+ <span {...stylex.attrs(styles.title)}>
217
+ {#if labelFor && children}
218
+ <label id={control.labelId} for={control.id} {...stylex.attrs(...labelStyles)}
219
+ >{label}</label
220
+ >
221
+ {:else}
222
+ <span id={control.labelId} {...stylex.attrs(...labelStyles)}>{label}</span>
223
+ {/if}
224
+ {#if about}
225
+ <Tooltip.Provider delayDuration={400}>
226
+ <Tooltip.Root>
227
+ <Tooltip.Trigger>
228
+ {#snippet child({ props })}
229
+ <button
230
+ {...props}
231
+ type="button"
232
+ aria-label="About {label}"
233
+ {...stylex.attrs(styles.about, shared.focusable)}
234
+ >
235
+ <Glyph name="info" size={14} />
236
+ </button>
237
+ {/snippet}
238
+ </Tooltip.Trigger>
239
+ <Tooltip.Content side="top">{about}</Tooltip.Content>
240
+ </Tooltip.Root>
241
+ </Tooltip.Provider>
242
+ {/if}
243
+ </span>
244
+ {#if description}
245
+ <div id="{uid}-description" {...stylex.attrs(typography.meta, styles.description)}>
246
+ {#if typeof description === 'string'}{description}{:else}{@render description()}{/if}
247
+ </div>
203
248
  {/if}
204
- </span>
205
- {#if description}
206
- <div id="{uid}-description" {...stylex.attrs(typography.meta, styles.description)}>
207
- {#if typeof description === 'string'}{description}{:else}{@render description()}{/if}
208
- </div>
209
- {/if}
210
- </div>
249
+ </div>
250
+ {/snippet}
251
+ {#if leading}
252
+ <div {...stylex.attrs(styles.lead, !stacked && styles.textInline)}>
253
+ <span data-icons aria-hidden="true" {...stylex.attrs(styles.leading)}
254
+ >{@render leading()}</span
255
+ >
256
+ {@render text(styles.leadText)}
257
+ </div>
258
+ {:else}
259
+ {@render text(!stacked && styles.textInline)}
260
+ {/if}
211
261
  {#if children}
212
262
  <div {...stylex.attrs(styles.control, stacked ? styles.full : styles.controlInline)}>
213
263
  {@render children(control)}
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type Sx } from '../../internal/sx.js';
4
+ import '../../internal/icons.css';
4
5
  export type SettingsRowControl = {
5
6
  /** For the control's `id`, which the label's `for` names: `controlId` when it is set. */
6
7
  id: string;
@@ -11,6 +12,18 @@ export type SettingsRowControl = {
11
12
  };
12
13
  export type SettingsRowProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {
13
14
  label: string;
15
+ /**
16
+ * Before the label and the description: a provider's mark, an icon of what the row is,
17
+ * an Avatar. Decoration: the label names the row.
18
+ */
19
+ leading?: Snippet | undefined;
20
+ /** Sets the label in the muted ink: for something switched off, or not to be had here. */
21
+ dimmed?: boolean | undefined;
22
+ /**
23
+ * Sets the label in monospace, for a name that is code: an environment variable, a
24
+ * header, a tool, a path.
25
+ */
26
+ mono?: boolean | undefined;
14
27
  /**
15
28
  * What the setting does, in a sentence or two, behind an info mark beside the label. It
16
29
  * opens on a hover, or as the mark takes the focus.
@@ -0,0 +1,137 @@
1
+ <!--
2
+ A button and, joined to its end, a second that opens a menu of how to do it, or
3
+ of what else there is to do: Merge, and the ways to merge. The two are one
4
+ group, disabled together. Without a menu the button stands alone, rounded at
5
+ both ends, so a menu that is offered only sometimes does not change the markup.
6
+ -->
7
+ <script lang="ts" module>
8
+ import * as stylex from '@stylexjs/stylex';
9
+ import type { Snippet } from 'svelte';
10
+ import Glyph from '../../internal/Glyph.svelte';
11
+ import { attrs, type Sx } from '../../internal/sx.js';
12
+ import Button, { type ButtonProps } from '../button/Button.svelte';
13
+ import * as Menu from '../menu/index.js';
14
+
15
+ export type SplitButtonProps = Omit<
16
+ ButtonProps,
17
+ 'variant' | 'iconOnly' | 'href' | 'shape' | 'pressed' | 'sx'
18
+ > & {
19
+ /** `secondary`, an edge round both halves; `primary`, the one solid, with a line between them. */
20
+ variant?: 'primary' | 'secondary' | undefined;
21
+ /** Names the pair as a group, where the button's own words do not say it all: "Merge". */
22
+ label?: string | undefined;
23
+ /** Names the button that opens the menu: "Choose how to merge", "More for GitHub". */
24
+ menuLabel?: string | undefined;
25
+ /**
26
+ * The menu: Menu.Item, Menu.RadioGroup, Menu.CheckboxItem and the rest. Without it there
27
+ * is no second button.
28
+ */
29
+ menu?: Snippet | undefined;
30
+ /** Where the menu lines up with the pair. */
31
+ align?: 'start' | 'center' | 'end' | undefined;
32
+ /** A width of its own for the menu, such as `16rem`. */
33
+ menuWidth?: string | undefined;
34
+ /** Whether the menu is open. Bindable. */
35
+ open?: boolean | undefined;
36
+ /** On the group, which holds both halves. */
37
+ sx?: Sx | undefined;
38
+ /** The main button's label, and its icon if it has one. */
39
+ children?: Snippet | undefined;
40
+ };
41
+
42
+ const styles = stylex.create({
43
+ group: {
44
+ display: 'inline-flex',
45
+ alignItems: 'stretch',
46
+ flexShrink: 0,
47
+ verticalAlign: 'middle'
48
+ },
49
+ // The focused half is drawn over its neighbour, so its ring is whole
50
+ half: { zIndex: { default: null, ':focus-visible': 1 } },
51
+ main: { borderStartEndRadius: 0, borderEndEndRadius: 0 },
52
+ more: { borderStartStartRadius: 0, borderEndStartRadius: 0 },
53
+ // The edges overlap, so one hairline runs between the halves
54
+ moreSecondary: { marginInlineStart: '-1px' },
55
+ // On the solid, a line in its own ink, faint, divides them
56
+ morePrimary: {
57
+ '::before': {
58
+ content: '""',
59
+ position: 'absolute',
60
+ insetInlineStart: 0,
61
+ insetBlock: 0,
62
+ width: '1px',
63
+ backgroundColor: 'color-mix(in srgb, currentColor 28%, transparent)',
64
+ pointerEvents: 'none'
65
+ }
66
+ },
67
+ // The chevron's button is a little narrower than a square: it is the lesser half
68
+ moreWidth: { paddingInline: '0.375rem' }
69
+ });
70
+ </script>
71
+
72
+ <script lang="ts">
73
+ let {
74
+ variant = 'secondary',
75
+ size = 'md',
76
+ label,
77
+ menuLabel = 'More options',
78
+ menu,
79
+ align = 'end',
80
+ menuWidth,
81
+ open = $bindable(false),
82
+ disabled = false,
83
+ loading = false,
84
+ sx,
85
+ class: className,
86
+ ref = $bindable(null),
87
+ children,
88
+ ...rest
89
+ }: SplitButtonProps = $props();
90
+
91
+ const glyph = { micro: 10, xs: 12, sm: 12, md: 14, lg: 16 } as const;
92
+ </script>
93
+
94
+ <div
95
+ role="group"
96
+ aria-label={label}
97
+ data-slot="split-button"
98
+ {...attrs([styles.group, sx], className)}
99
+ >
100
+ <Button
101
+ bind:ref
102
+ {...rest}
103
+ {variant}
104
+ {size}
105
+ {disabled}
106
+ {loading}
107
+ sx={[styles.half, menu && styles.main]}
108
+ >
109
+ {@render children?.()}
110
+ </Button>
111
+ {#if menu}
112
+ <Menu.Root bind:open>
113
+ <Menu.Trigger disabled={disabled || loading}>
114
+ {#snippet child({ props })}
115
+ <Button
116
+ {...props}
117
+ {variant}
118
+ {size}
119
+ disabled={disabled || loading}
120
+ aria-label={menuLabel}
121
+ sx={[
122
+ styles.half,
123
+ styles.more,
124
+ styles.moreWidth,
125
+ variant === 'primary' ? styles.morePrimary : styles.moreSecondary
126
+ ]}
127
+ >
128
+ <Glyph name="chevron" size={glyph[size]} />
129
+ </Button>
130
+ {/snippet}
131
+ </Menu.Trigger>
132
+ <Menu.Content {align} width={menuWidth}>
133
+ {@render menu()}
134
+ </Menu.Content>
135
+ </Menu.Root>
136
+ {/if}
137
+ </div>