@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.
- package/dist/components/activity/ActivityIcon.svelte +54 -0
- package/dist/components/activity/ActivityIcon.svelte.d.ts +24 -0
- package/dist/components/activity/ActivityStep.svelte +47 -13
- package/dist/components/activity/ActivityStep.svelte.d.ts +13 -4
- package/dist/components/activity/ActivityThought.svelte +24 -5
- package/dist/components/activity/ActivityThought.svelte.d.ts +12 -2
- package/dist/components/activity/index.d.ts +3 -1
- package/dist/components/activity/index.js +2 -1
- package/dist/components/app-shell/AppShellHeader.svelte +18 -4
- package/dist/components/app-shell/AppShellHeader.svelte.d.ts +5 -0
- package/dist/components/app-shell/AppShellMain.svelte +14 -2
- package/dist/components/app-shell/AppShellPanel.svelte +77 -12
- package/dist/components/app-shell/AppShellPanel.svelte.d.ts +11 -1
- package/dist/components/app-shell/AppShellSheet.svelte +11 -1
- package/dist/components/app-shell/context.d.ts +8 -0
- package/dist/components/app-shell/context.js +7 -0
- package/dist/components/approval/Approval.svelte +14 -1
- package/dist/components/approval/Approval.svelte.d.ts +5 -0
- package/dist/components/avatar/AvatarRoot.svelte +20 -7
- package/dist/components/avatar/AvatarRoot.svelte.d.ts +10 -3
- package/dist/components/badge/Badge.svelte +3 -1
- package/dist/components/badge/Badge.svelte.d.ts +1 -1
- package/dist/components/button/Button.svelte +28 -6
- package/dist/components/button/Button.svelte.d.ts +7 -0
- package/dist/components/composer/ComposerModelPicker.svelte +80 -13
- package/dist/components/composer/ComposerModelPicker.svelte.d.ts +23 -6
- package/dist/components/composer/ComposerRoot.svelte +51 -12
- package/dist/components/composer/ComposerRoot.svelte.d.ts +16 -0
- package/dist/components/composer/ComposerSubmit.svelte +19 -5
- package/dist/components/composer/ComposerSubmit.svelte.d.ts +3 -1
- package/dist/components/composer/ComposerToggle.svelte +18 -4
- package/dist/components/composer/ComposerToggle.svelte.d.ts +2 -0
- package/dist/components/composer/ComposerTray.svelte +17 -3
- package/dist/components/composer/ComposerTray.svelte.d.ts +5 -0
- package/dist/components/composer/context.d.ts +4 -1
- package/dist/components/dialog/DialogContent.svelte +22 -12
- package/dist/components/dialog/DialogContent.svelte.d.ts +10 -0
- package/dist/components/divider/Divider.svelte +56 -14
- package/dist/components/divider/Divider.svelte.d.ts +13 -3
- package/dist/components/empty-state/EmptyState.svelte +12 -2
- package/dist/components/empty-state/EmptyState.svelte.d.ts +6 -0
- package/dist/components/heading/Heading.svelte +15 -0
- package/dist/components/heading/Heading.svelte.d.ts +6 -0
- package/dist/components/hover-card/HoverCardContent.svelte +18 -2
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -0
- package/dist/components/input/Input.svelte +13 -3
- package/dist/components/input/Input.svelte.d.ts +10 -2
- package/dist/components/markdown/Markdown.svelte +22 -2
- package/dist/components/markdown/MarkdownDiagram.svelte +33 -2
- package/dist/components/markdown/MarkdownFile.svelte +56 -10
- package/dist/components/markdown/MarkdownMath.svelte +6 -0
- package/dist/components/markdown/MarkdownTable.svelte +3 -4
- package/dist/components/markdown/context.d.ts +6 -0
- package/dist/components/markdown/labels.d.ts +7 -0
- package/dist/components/markdown/labels.js +2 -0
- package/dist/components/menu/MenuCheckboxItem.svelte +44 -7
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +12 -2
- package/dist/components/menu/MenuContent.svelte +10 -2
- package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
- package/dist/components/menu/MenuItem.svelte +17 -2
- package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
- package/dist/components/menu/MenuSubContent.svelte +10 -2
- package/dist/components/menu/MenuSubContent.svelte.d.ts +10 -0
- package/dist/components/menu/MenuSubTrigger.svelte +19 -2
- package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -0
- package/dist/components/message/MessageBubble.svelte +40 -0
- package/dist/components/message/MessageBubble.svelte.d.ts +12 -0
- package/dist/components/message/MessageContent.svelte +23 -14
- package/dist/components/message/MessageContent.svelte.d.ts +6 -0
- package/dist/components/message/MessageCopy.svelte +27 -15
- package/dist/components/message/MessageCopy.svelte.d.ts +9 -2
- package/dist/components/message/MessageRoot.svelte +20 -3
- package/dist/components/message/MessageRoot.svelte.d.ts +6 -0
- package/dist/components/message/context.d.ts +2 -0
- package/dist/components/message/index.d.ts +4 -1
- package/dist/components/message/index.js +3 -2
- package/dist/components/message/styles.d.ts +30 -0
- package/dist/components/message/styles.js +24 -0
- package/dist/components/notice/Notice.svelte +3 -3
- package/dist/components/popover/PopoverContent.svelte +27 -3
- package/dist/components/popover/PopoverContent.svelte.d.ts +18 -0
- package/dist/components/questionnaire/Questionnaire.svelte +103 -19
- package/dist/components/questionnaire/Questionnaire.svelte.d.ts +13 -1
- package/dist/components/queued-message/QueuedMessage.svelte +44 -6
- package/dist/components/queued-message/QueuedMessage.svelte.d.ts +12 -1
- package/dist/components/segmented/SegmentedControl.svelte +12 -1
- package/dist/components/segmented/SegmentedControl.svelte.d.ts +3 -1
- package/dist/components/select/Select.svelte +43 -6
- package/dist/components/select/Select.svelte.d.ts +14 -0
- package/dist/components/settings-row/SettingsRow.svelte +87 -37
- package/dist/components/settings-row/SettingsRow.svelte.d.ts +13 -0
- package/dist/components/split-button/SplitButton.svelte +137 -0
- package/dist/components/split-button/SplitButton.svelte.d.ts +29 -0
- package/dist/components/tab-strip/TabStrip.svelte +337 -93
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +36 -1
- package/dist/components/tab-strip/drag.svelte.d.ts +31 -0
- package/dist/components/tab-strip/drag.svelte.js +148 -0
- package/dist/components/toast/Toaster.svelte +1 -1
- package/dist/components/toggle/Toggle.svelte +12 -2
- package/dist/components/toggle/Toggle.svelte.d.ts +11 -1
- package/dist/components/toggle-group/ToggleGroupItem.svelte +10 -1
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +7 -1
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +3 -1
- package/dist/components/toggle-group/context.d.ts +2 -1
- package/dist/components/tooltip/TooltipContent.svelte +13 -1
- package/dist/components/tooltip/TooltipContent.svelte.d.ts +10 -0
- package/dist/components/work-fold/WorkFold.svelte +13 -4
- package/dist/components/work-fold/WorkFold.svelte.d.ts +2 -1
- package/dist/focus-ring.d.ts +29 -0
- package/dist/focus-ring.js +42 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +8 -2
- package/dist/internal/Collapse.svelte +15 -2
- package/dist/internal/Glyph.svelte +28 -0
- package/dist/internal/Glyph.svelte.d.ts +5 -0
- package/dist/internal/Tile.svelte +3 -2
- package/dist/internal/layer.d.ts +23 -0
- package/dist/internal/layer.js +19 -0
- package/dist/internal/toggle.d.ts +8 -1
- package/dist/internal/toggle.js +20 -2
- package/dist/markdown/file-paths.d.ts +7 -0
- package/dist/markdown/file-paths.js +29 -0
- package/dist/markdown/files.d.ts +22 -2
- package/dist/markdown/files.js +45 -14
- package/dist/tokens.stylex.d.ts +3 -0
- package/dist/tokens.stylex.js +5 -1
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +77 -5
- package/skills/building-ui/references/components.md +51 -50
- package/skills/markdown/SKILL.md +22 -6
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +10 -3
- package/skills/theming/SKILL.md +11 -4
|
@@ -6,17 +6,34 @@
|
|
|
6
6
|
import Glyph from '../../internal/Glyph.svelte';
|
|
7
7
|
import { layer } from '../../internal/layer.js';
|
|
8
8
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
9
|
+
import { colors } from '../../tokens.stylex.js';
|
|
9
10
|
|
|
10
11
|
export type MenuCheckboxItemProps = Loose<
|
|
11
12
|
Omit<DropdownMenu.CheckboxItemProps, 'children' | 'child'> & {
|
|
12
13
|
/** The keys that do the same, shown at the end, such as "⌘D". */
|
|
13
14
|
shortcut?: string | undefined;
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* A 16px icon before the label, where the other items' icons are. The tick then goes
|
|
17
|
+
* to the end of the row, so the icons line up down the menu.
|
|
18
|
+
*/
|
|
15
19
|
icon?: Snippet | undefined;
|
|
20
|
+
/** A line under the label, such as what the setting does. */
|
|
21
|
+
description?: string | undefined;
|
|
16
22
|
sx?: Sx | undefined;
|
|
17
23
|
children?: Snippet | undefined;
|
|
18
24
|
}
|
|
19
25
|
>;
|
|
26
|
+
|
|
27
|
+
const styles = stylex.create({
|
|
28
|
+
// At the end, the tick keeps its place whether shown or not, so the shortcuts line up
|
|
29
|
+
check: {
|
|
30
|
+
display: 'grid',
|
|
31
|
+
placeItems: 'center',
|
|
32
|
+
width: '1rem',
|
|
33
|
+
height: '1rem',
|
|
34
|
+
color: colors.text
|
|
35
|
+
}
|
|
36
|
+
});
|
|
20
37
|
</script>
|
|
21
38
|
|
|
22
39
|
<script lang="ts">
|
|
@@ -24,6 +41,7 @@
|
|
|
24
41
|
checked = $bindable(false),
|
|
25
42
|
shortcut,
|
|
26
43
|
icon,
|
|
44
|
+
description,
|
|
27
45
|
// Picking it closes the menu, as a radio item's does: one left open takes the next click
|
|
28
46
|
// that was meant for the page. Pass `false` for a menu of settings set several at a time.
|
|
29
47
|
closeOnSelect = true,
|
|
@@ -42,11 +60,30 @@
|
|
|
42
60
|
{...attrs([layer.item, sx], className)}
|
|
43
61
|
>
|
|
44
62
|
{#snippet children({ checked })}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
{#if icon}
|
|
64
|
+
<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>
|
|
65
|
+
{:else}
|
|
66
|
+
<span {...stylex.attrs(layer.icon)}>
|
|
67
|
+
{#if checked}<Glyph name="check" stroke={1.75} />{/if}
|
|
68
|
+
</span>
|
|
69
|
+
{/if}
|
|
70
|
+
{#if description}
|
|
71
|
+
<span {...stylex.attrs(layer.text)}>
|
|
72
|
+
<span {...stylex.attrs(layer.label)}>{@render label?.()}</span>
|
|
73
|
+
<span {...stylex.attrs(layer.description)}>{description}</span>
|
|
74
|
+
</span>
|
|
75
|
+
{:else}
|
|
76
|
+
<span {...stylex.attrs(layer.label)}>{@render label?.()}</span>
|
|
77
|
+
{/if}
|
|
78
|
+
{#if shortcut || icon}
|
|
79
|
+
<span {...stylex.attrs(layer.trailing)}>
|
|
80
|
+
{shortcut}
|
|
81
|
+
{#if icon}
|
|
82
|
+
<span data-slot="menu-check" {...stylex.attrs(styles.check)}>
|
|
83
|
+
{#if checked}<Glyph name="check" stroke={1.75} />{/if}
|
|
84
|
+
</span>
|
|
85
|
+
{/if}
|
|
86
|
+
</span>
|
|
87
|
+
{/if}
|
|
51
88
|
{/snippet}
|
|
52
89
|
</DropdownMenu.CheckboxItem>
|
|
@@ -5,16 +5,26 @@ import { type Sx } from '../../internal/sx.js';
|
|
|
5
5
|
export type MenuCheckboxItemProps = Loose<Omit<DropdownMenu.CheckboxItemProps, 'children' | 'child'> & {
|
|
6
6
|
/** The keys that do the same, shown at the end, such as "⌘D". */
|
|
7
7
|
shortcut?: string | undefined;
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* A 16px icon before the label, where the other items' icons are. The tick then goes
|
|
10
|
+
* to the end of the row, so the icons line up down the menu.
|
|
11
|
+
*/
|
|
9
12
|
icon?: Snippet | undefined;
|
|
13
|
+
/** A line under the label, such as what the setting does. */
|
|
14
|
+
description?: string | undefined;
|
|
10
15
|
sx?: Sx | undefined;
|
|
11
16
|
children?: Snippet | undefined;
|
|
12
17
|
}>;
|
|
13
18
|
declare const MenuCheckboxItem: import("svelte").Component<Loose<Omit<DropdownMenu.CheckboxItemProps, "children" | "child"> & {
|
|
14
19
|
/** The keys that do the same, shown at the end, such as "⌘D". */
|
|
15
20
|
shortcut?: string | undefined;
|
|
16
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* A 16px icon before the label, where the other items' icons are. The tick then goes
|
|
23
|
+
* to the end of the row, so the icons line up down the menu.
|
|
24
|
+
*/
|
|
17
25
|
icon?: Snippet | undefined;
|
|
26
|
+
/** A line under the label, such as what the setting does. */
|
|
27
|
+
description?: string | undefined;
|
|
18
28
|
sx?: Sx | undefined;
|
|
19
29
|
children?: Snippet | undefined;
|
|
20
30
|
}>, {}, "checked">;
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
import type { Loose } from '../../internal/loose.js';
|
|
3
3
|
import { DropdownMenu } from 'bits-ui';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
|
-
import { layer } from '../../internal/layer.js';
|
|
5
|
+
import { layer, widthStyle } from '../../internal/layer.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
7
|
|
|
8
8
|
export type MenuContentProps = Loose<
|
|
9
9
|
Omit<DropdownMenu.ContentProps, 'children' | 'child'> & {
|
|
10
|
+
/**
|
|
11
|
+
* A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
|
|
12
|
+
* the trigger's width, up to 22rem). It is still no wider than the window has room for.
|
|
13
|
+
*/
|
|
14
|
+
width?: string | undefined;
|
|
10
15
|
sx?: Sx | undefined;
|
|
11
16
|
children?: Snippet | undefined;
|
|
12
17
|
}
|
|
@@ -17,6 +22,8 @@
|
|
|
17
22
|
let {
|
|
18
23
|
sideOffset = 6,
|
|
19
24
|
collisionPadding = 8,
|
|
25
|
+
width,
|
|
26
|
+
style,
|
|
20
27
|
align = 'start',
|
|
21
28
|
sx,
|
|
22
29
|
class: className,
|
|
@@ -32,7 +39,8 @@
|
|
|
32
39
|
{align}
|
|
33
40
|
data-slot="menu-content"
|
|
34
41
|
{...rest}
|
|
35
|
-
{
|
|
42
|
+
style={widthStyle(width, style)}
|
|
43
|
+
{...attrs([layer.surface, !!width && layer.sized, sx], className)}
|
|
36
44
|
>
|
|
37
45
|
{@render children?.()}
|
|
38
46
|
</DropdownMenu.Content>
|
|
@@ -3,10 +3,20 @@ import { DropdownMenu } from 'bits-ui';
|
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
5
|
export type MenuContentProps = Loose<Omit<DropdownMenu.ContentProps, 'children' | 'child'> & {
|
|
6
|
+
/**
|
|
7
|
+
* A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
|
|
8
|
+
* the trigger's width, up to 22rem). It is still no wider than the window has room for.
|
|
9
|
+
*/
|
|
10
|
+
width?: string | undefined;
|
|
6
11
|
sx?: Sx | undefined;
|
|
7
12
|
children?: Snippet | undefined;
|
|
8
13
|
}>;
|
|
9
14
|
declare const MenuContent: import("svelte").Component<Loose<Omit<DropdownMenu.ContentProps, "children" | "child"> & {
|
|
15
|
+
/**
|
|
16
|
+
* A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
|
|
17
|
+
* the trigger's width, up to 22rem). It is still no wider than the window has room for.
|
|
18
|
+
*/
|
|
19
|
+
width?: string | undefined;
|
|
10
20
|
sx?: Sx | undefined;
|
|
11
21
|
children?: Snippet | undefined;
|
|
12
22
|
}>, {}, "">;
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
shortcut?: string | undefined;
|
|
15
15
|
/** A 16px icon before the label. */
|
|
16
16
|
icon?: Snippet | undefined;
|
|
17
|
+
/** A line under the label, such as what the action does. */
|
|
18
|
+
description?: string | undefined;
|
|
19
|
+
/** Something at the end, after the shortcut: a badge, a count, a status. */
|
|
20
|
+
trailing?: Snippet | undefined;
|
|
17
21
|
sx?: Sx | undefined;
|
|
18
22
|
children?: Snippet | undefined;
|
|
19
23
|
}
|
|
@@ -25,6 +29,8 @@
|
|
|
25
29
|
tone = 'default',
|
|
26
30
|
shortcut,
|
|
27
31
|
icon,
|
|
32
|
+
description,
|
|
33
|
+
trailing,
|
|
28
34
|
sx,
|
|
29
35
|
class: className,
|
|
30
36
|
children,
|
|
@@ -39,6 +45,15 @@
|
|
|
39
45
|
{...attrs([layer.item, tone === 'danger' && layer.danger, sx], className)}
|
|
40
46
|
>
|
|
41
47
|
{#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
{#if description}
|
|
49
|
+
<span {...stylex.attrs(layer.text)}>
|
|
50
|
+
<span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
|
|
51
|
+
<span {...stylex.attrs(layer.description)}>{description}</span>
|
|
52
|
+
</span>
|
|
53
|
+
{:else}
|
|
54
|
+
<span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
|
|
55
|
+
{/if}
|
|
56
|
+
{#if shortcut || trailing}
|
|
57
|
+
<span {...stylex.attrs(layer.trailing)}>{shortcut}{@render trailing?.()}</span>
|
|
58
|
+
{/if}
|
|
44
59
|
</DropdownMenu.Item>
|
|
@@ -9,6 +9,10 @@ export type MenuItemProps = Loose<Omit<DropdownMenu.ItemProps, 'children' | 'chi
|
|
|
9
9
|
shortcut?: string | undefined;
|
|
10
10
|
/** A 16px icon before the label. */
|
|
11
11
|
icon?: Snippet | undefined;
|
|
12
|
+
/** A line under the label, such as what the action does. */
|
|
13
|
+
description?: string | undefined;
|
|
14
|
+
/** Something at the end, after the shortcut: a badge, a count, a status. */
|
|
15
|
+
trailing?: Snippet | undefined;
|
|
12
16
|
sx?: Sx | undefined;
|
|
13
17
|
children?: Snippet | undefined;
|
|
14
18
|
}>;
|
|
@@ -19,6 +23,10 @@ declare const MenuItem: import("svelte").Component<Loose<Omit<DropdownMenu.ItemP
|
|
|
19
23
|
shortcut?: string | undefined;
|
|
20
24
|
/** A 16px icon before the label. */
|
|
21
25
|
icon?: Snippet | undefined;
|
|
26
|
+
/** A line under the label, such as what the action does. */
|
|
27
|
+
description?: string | undefined;
|
|
28
|
+
/** Something at the end, after the shortcut: a badge, a count, a status. */
|
|
29
|
+
trailing?: Snippet | undefined;
|
|
22
30
|
sx?: Sx | undefined;
|
|
23
31
|
children?: Snippet | undefined;
|
|
24
32
|
}>, {}, "">;
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
import type { Loose } from '../../internal/loose.js';
|
|
3
3
|
import { DropdownMenu } from 'bits-ui';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
|
-
import { layer } from '../../internal/layer.js';
|
|
5
|
+
import { layer, widthStyle } from '../../internal/layer.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
7
|
|
|
8
8
|
export type MenuSubContentProps = Loose<
|
|
9
9
|
Omit<DropdownMenu.SubContentProps, 'children' | 'child'> & {
|
|
10
|
+
/**
|
|
11
|
+
* A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
|
|
12
|
+
* the trigger's width, up to 22rem). It is still no wider than the window has room for.
|
|
13
|
+
*/
|
|
14
|
+
width?: string | undefined;
|
|
10
15
|
sx?: Sx | undefined;
|
|
11
16
|
children?: Snippet | undefined;
|
|
12
17
|
}
|
|
@@ -17,6 +22,8 @@
|
|
|
17
22
|
let {
|
|
18
23
|
sideOffset = 2,
|
|
19
24
|
collisionPadding = 8,
|
|
25
|
+
width,
|
|
26
|
+
style,
|
|
20
27
|
sx,
|
|
21
28
|
class: className,
|
|
22
29
|
children,
|
|
@@ -30,7 +37,8 @@
|
|
|
30
37
|
{collisionPadding}
|
|
31
38
|
data-slot="menu-sub-content"
|
|
32
39
|
{...rest}
|
|
33
|
-
{
|
|
40
|
+
style={widthStyle(width, style)}
|
|
41
|
+
{...attrs([layer.surface, !!width && layer.sized, sx], className)}
|
|
34
42
|
>
|
|
35
43
|
{@render children?.()}
|
|
36
44
|
</DropdownMenu.SubContent>
|
|
@@ -3,10 +3,20 @@ import { DropdownMenu } from 'bits-ui';
|
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
5
|
export type MenuSubContentProps = Loose<Omit<DropdownMenu.SubContentProps, 'children' | 'child'> & {
|
|
6
|
+
/**
|
|
7
|
+
* A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
|
|
8
|
+
* the trigger's width, up to 22rem). It is still no wider than the window has room for.
|
|
9
|
+
*/
|
|
10
|
+
width?: string | undefined;
|
|
6
11
|
sx?: Sx | undefined;
|
|
7
12
|
children?: Snippet | undefined;
|
|
8
13
|
}>;
|
|
9
14
|
declare const MenuSubContent: import("svelte").Component<Loose<Omit<DropdownMenu.SubContentProps, "children" | "child"> & {
|
|
15
|
+
/**
|
|
16
|
+
* A width of its own, such as `18rem`, in place of fitting its items (from 12rem, or
|
|
17
|
+
* the trigger's width, up to 22rem). It is still no wider than the window has room for.
|
|
18
|
+
*/
|
|
19
|
+
width?: string | undefined;
|
|
10
20
|
sx?: Sx | undefined;
|
|
11
21
|
children?: Snippet | undefined;
|
|
12
22
|
}>, {}, "">;
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
export type MenuSubTriggerProps = Loose<
|
|
11
11
|
Omit<DropdownMenu.SubTriggerProps, 'children' | 'child'> & {
|
|
12
|
+
/** A 16px icon before the label. */
|
|
12
13
|
icon?: Snippet | undefined;
|
|
14
|
+
/** A line under the label, such as what the submenu holds. */
|
|
15
|
+
description?: string | undefined;
|
|
13
16
|
sx?: Sx | undefined;
|
|
14
17
|
children?: Snippet | undefined;
|
|
15
18
|
}
|
|
@@ -22,7 +25,14 @@
|
|
|
22
25
|
</script>
|
|
23
26
|
|
|
24
27
|
<script lang="ts">
|
|
25
|
-
let {
|
|
28
|
+
let {
|
|
29
|
+
icon,
|
|
30
|
+
description,
|
|
31
|
+
sx,
|
|
32
|
+
class: className,
|
|
33
|
+
children,
|
|
34
|
+
...rest
|
|
35
|
+
}: MenuSubTriggerProps = $props();
|
|
26
36
|
</script>
|
|
27
37
|
|
|
28
38
|
<DropdownMenu.SubTrigger
|
|
@@ -31,7 +41,14 @@
|
|
|
31
41
|
{...attrs([layer.item, sx], className)}
|
|
32
42
|
>
|
|
33
43
|
{#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
|
|
34
|
-
|
|
44
|
+
{#if description}
|
|
45
|
+
<span {...stylex.attrs(layer.text)}>
|
|
46
|
+
<span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
|
|
47
|
+
<span {...stylex.attrs(layer.description)}>{description}</span>
|
|
48
|
+
</span>
|
|
49
|
+
{:else}
|
|
50
|
+
<span {...stylex.attrs(layer.label)}>{@render children?.()}</span>
|
|
51
|
+
{/if}
|
|
35
52
|
<span {...stylex.attrs(layer.trailing)}>
|
|
36
53
|
<span {...stylex.attrs(styles.chevron)}><Glyph name="chevron" size={14} /></span>
|
|
37
54
|
</span>
|
|
@@ -3,12 +3,18 @@ import { DropdownMenu } from 'bits-ui';
|
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
5
|
export type MenuSubTriggerProps = Loose<Omit<DropdownMenu.SubTriggerProps, 'children' | 'child'> & {
|
|
6
|
+
/** A 16px icon before the label. */
|
|
6
7
|
icon?: Snippet | undefined;
|
|
8
|
+
/** A line under the label, such as what the submenu holds. */
|
|
9
|
+
description?: string | undefined;
|
|
7
10
|
sx?: Sx | undefined;
|
|
8
11
|
children?: Snippet | undefined;
|
|
9
12
|
}>;
|
|
10
13
|
declare const MenuSubTrigger: import("svelte").Component<Loose<Omit<DropdownMenu.SubTriggerProps, "children" | "child"> & {
|
|
14
|
+
/** A 16px icon before the label. */
|
|
11
15
|
icon?: Snippet | undefined;
|
|
16
|
+
/** A line under the label, such as what the submenu holds. */
|
|
17
|
+
description?: string | undefined;
|
|
12
18
|
sx?: Sx | undefined;
|
|
13
19
|
children?: Snippet | undefined;
|
|
14
20
|
}>, {}, "">;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The person's words in their bubble, for a Message.Content that holds more than them
|
|
3
|
+
(`bubble={false}`): attachments over the bubble, cards under it.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts" module>
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
8
|
+
import { shared } from '../../internal/shared.js';
|
|
9
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
10
|
+
import { getMessageContext } from './context.js';
|
|
11
|
+
import { bubble, text } from './styles.js';
|
|
12
|
+
|
|
13
|
+
export type MessageBubbleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
14
|
+
sx?: Sx | undefined;
|
|
15
|
+
ref?: HTMLDivElement | null | undefined;
|
|
16
|
+
/** What the person wrote. */
|
|
17
|
+
children?: Snippet | undefined;
|
|
18
|
+
};
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
let {
|
|
23
|
+
sx,
|
|
24
|
+
class: className,
|
|
25
|
+
ref = $bindable(null),
|
|
26
|
+
children,
|
|
27
|
+
...rest
|
|
28
|
+
}: MessageBubbleProps = $props();
|
|
29
|
+
|
|
30
|
+
const message = getMessageContext('Bubble');
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<div
|
|
34
|
+
bind:this={ref}
|
|
35
|
+
data-slot="message-bubble"
|
|
36
|
+
{...rest}
|
|
37
|
+
{...attrs([bubble.bubble, text[message.textSize], shared.edged, sx], className)}
|
|
38
|
+
>
|
|
39
|
+
{@render children?.()}
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
export type MessageBubbleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
5
|
+
sx?: Sx | undefined;
|
|
6
|
+
ref?: HTMLDivElement | null | undefined;
|
|
7
|
+
/** What the person wrote. */
|
|
8
|
+
children?: Snippet | undefined;
|
|
9
|
+
};
|
|
10
|
+
declare const MessageBubble: import("svelte").Component<MessageBubbleProps, {}, "ref">;
|
|
11
|
+
type MessageBubble = ReturnType<typeof MessageBubble>;
|
|
12
|
+
export default MessageBubble;
|
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
5
|
import { shared } from '../../internal/shared.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
|
-
import { colors, font, radius } from '../../tokens.stylex.js';
|
|
8
7
|
import { getMessageContext } from './context.js';
|
|
8
|
+
import { bubble as bubbleStyles, text } from './styles.js';
|
|
9
9
|
|
|
10
10
|
export type MessageContentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
11
|
+
/**
|
|
12
|
+
* In the person's message, whether the content is the bubble. `false` makes it a column
|
|
13
|
+
* at the end of the line, for what goes around the bubble: attachments over it, cards
|
|
14
|
+
* under it, with the words in a Message.Bubble. The actions then sit under it all.
|
|
15
|
+
*/
|
|
16
|
+
bubble?: boolean | undefined;
|
|
11
17
|
sx?: Sx | undefined;
|
|
12
18
|
ref?: HTMLDivElement | null | undefined;
|
|
13
19
|
/** The text of the message, or anything else: rendered Markdown, a Tool, Reasoning. */
|
|
@@ -21,20 +27,13 @@
|
|
|
21
27
|
flexDirection: 'column',
|
|
22
28
|
gap: '0.75rem',
|
|
23
29
|
minWidth: 0,
|
|
24
|
-
// A size for reading at length: a step up from interface text
|
|
25
|
-
fontSize: font.sizeReading,
|
|
26
|
-
lineHeight: font.leadingNormal,
|
|
27
30
|
overflowWrap: 'break-word'
|
|
28
31
|
},
|
|
29
|
-
// What the person
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
borderRadius: radius.frame,
|
|
35
|
-
backgroundColor: colors.fillMuted,
|
|
36
|
-
whiteSpace: 'pre-wrap',
|
|
37
|
-
overflowWrap: 'anywhere'
|
|
32
|
+
// What goes with the person's words, one under another at the end of the line
|
|
33
|
+
around: {
|
|
34
|
+
alignItems: 'flex-end',
|
|
35
|
+
alignSelf: 'stretch',
|
|
36
|
+
gap: '0.5rem'
|
|
38
37
|
},
|
|
39
38
|
assistant: {
|
|
40
39
|
width: '100%'
|
|
@@ -44,6 +43,7 @@
|
|
|
44
43
|
|
|
45
44
|
<script lang="ts">
|
|
46
45
|
let {
|
|
46
|
+
bubble = true,
|
|
47
47
|
sx,
|
|
48
48
|
class: className,
|
|
49
49
|
ref = $bindable(null),
|
|
@@ -52,14 +52,23 @@
|
|
|
52
52
|
}: MessageContentProps = $props();
|
|
53
53
|
|
|
54
54
|
const message = getMessageContext('Content');
|
|
55
|
+
const isBubble = $derived(message.from === 'user' && bubble);
|
|
55
56
|
</script>
|
|
56
57
|
|
|
57
58
|
<div
|
|
58
59
|
bind:this={ref}
|
|
59
60
|
data-slot="message-content"
|
|
61
|
+
data-bubble={isBubble || undefined}
|
|
60
62
|
{...rest}
|
|
61
63
|
{...attrs(
|
|
62
|
-
[
|
|
64
|
+
[
|
|
65
|
+
styles.content,
|
|
66
|
+
text[message.textSize],
|
|
67
|
+
message.from === 'assistant' && styles.assistant,
|
|
68
|
+
message.from === 'user' && !bubble && styles.around,
|
|
69
|
+
isBubble && [bubbleStyles.bubble, shared.edged],
|
|
70
|
+
sx
|
|
71
|
+
],
|
|
63
72
|
className
|
|
64
73
|
)}
|
|
65
74
|
>
|
|
@@ -2,6 +2,12 @@ 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 MessageContentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
5
|
+
/**
|
|
6
|
+
* In the person's message, whether the content is the bubble. `false` makes it a column
|
|
7
|
+
* at the end of the line, for what goes around the bubble: attachments over it, cards
|
|
8
|
+
* under it, with the words in a Message.Bubble. The actions then sit under it all.
|
|
9
|
+
*/
|
|
10
|
+
bubble?: boolean | undefined;
|
|
5
11
|
sx?: Sx | undefined;
|
|
6
12
|
ref?: HTMLDivElement | null | undefined;
|
|
7
13
|
/** The text of the message, or anything else: rendered Markdown, a Tool, Reasoning. */
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
copiedLabel?: string | undefined;
|
|
20
20
|
/** Called after a successful copy. */
|
|
21
21
|
oncopy?: ((text: string) => void) | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Called when the clipboard turns the text away, such as when the page is not focused
|
|
24
|
+
* or the browser does not allow it. `failedLabel` is read out either way.
|
|
25
|
+
*/
|
|
26
|
+
onerror?: ((error: unknown) => void) | undefined;
|
|
27
|
+
/** Read out when the text could not be copied. */
|
|
28
|
+
failedLabel?: string | undefined;
|
|
22
29
|
sx?: Sx | undefined;
|
|
23
30
|
};
|
|
24
31
|
|
|
@@ -59,11 +66,10 @@
|
|
|
59
66
|
});
|
|
60
67
|
const arrivedClass = classes(lean.arrived);
|
|
61
68
|
const arrivedCheckClass = classes(lean.arrived, lean.check);
|
|
62
|
-
const statusClass = classes(visuallyHidden);
|
|
63
69
|
|
|
64
70
|
/**
|
|
65
|
-
* A copy button as markup
|
|
66
|
-
*
|
|
71
|
+
* A copy button as markup: a button and its icon, and nothing else. What it copied is said
|
|
72
|
+
* by the status region of what it is in (Markdown's, through its `announce`). The tick is not there until something is copied (`showCopied`):
|
|
67
73
|
* a page of code blocks has a copy button for each, and nearly none of them is pressed.
|
|
68
74
|
* `label` and `attributes` are escaped already.
|
|
69
75
|
*/
|
|
@@ -72,10 +78,7 @@
|
|
|
72
78
|
attributes?: string | undefined;
|
|
73
79
|
sx?: Sx | undefined;
|
|
74
80
|
}): string {
|
|
75
|
-
return (
|
|
76
|
-
actionHtml({ ...options, bare: true, inner: glyphHtml('copy') }) +
|
|
77
|
-
`<span role="status" class="${statusClass}"></span>`
|
|
78
|
-
);
|
|
81
|
+
return actionHtml({ ...options, bare: true, inner: glyphHtml('copy') });
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
const putBack = new WeakMap<Element, ReturnType<typeof setTimeout>>();
|
|
@@ -114,25 +117,31 @@
|
|
|
114
117
|
label = 'Copy',
|
|
115
118
|
copiedLabel = 'Copied',
|
|
116
119
|
oncopy,
|
|
120
|
+
onerror,
|
|
121
|
+
failedLabel = "Couldn't copy",
|
|
117
122
|
sx,
|
|
118
123
|
onclick,
|
|
119
124
|
...rest
|
|
120
125
|
}: MessageCopyProps = $props();
|
|
121
126
|
|
|
122
127
|
let copied = $state(false);
|
|
128
|
+
let failed = $state(false);
|
|
123
129
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
124
130
|
|
|
125
131
|
async function copy() {
|
|
126
|
-
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
copied = failed = false;
|
|
127
134
|
try {
|
|
135
|
+
const text = typeof value === 'function' ? value() : value;
|
|
128
136
|
await navigator.clipboard.writeText(text);
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
copied = true;
|
|
138
|
+
oncopy?.(text);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
// The icon stays as it was: nothing was copied. The status says so.
|
|
141
|
+
failed = true;
|
|
142
|
+
onerror?.(error);
|
|
131
143
|
}
|
|
132
|
-
copied =
|
|
133
|
-
oncopy?.(text);
|
|
134
|
-
clearTimeout(timer);
|
|
135
|
-
timer = setTimeout(() => (copied = false), 2000);
|
|
144
|
+
timer = setTimeout(() => (copied = failed = false), 2000);
|
|
136
145
|
}
|
|
137
146
|
|
|
138
147
|
$effect(() => () => clearTimeout(timer));
|
|
@@ -141,6 +150,7 @@
|
|
|
141
150
|
<MessageAction
|
|
142
151
|
{label}
|
|
143
152
|
data-copied={copied || undefined}
|
|
153
|
+
data-failed={failed || undefined}
|
|
144
154
|
{...rest}
|
|
145
155
|
{sx}
|
|
146
156
|
onclick={(event: MouseEvent) => {
|
|
@@ -158,4 +168,6 @@
|
|
|
158
168
|
</span>
|
|
159
169
|
</MessageAction>
|
|
160
170
|
<!-- Outside the button: a button's contents are not read out as they change -->
|
|
161
|
-
<span role="status" {...stylex.attrs(visuallyHidden)}
|
|
171
|
+
<span role="status" {...stylex.attrs(visuallyHidden)}
|
|
172
|
+
>{copied ? copiedLabel : failed ? failedLabel : ''}</span
|
|
173
|
+
>
|
|
@@ -9,11 +9,18 @@ export type MessageCopyProps = Omit<MessageActionProps, 'children' | 'value' | '
|
|
|
9
9
|
copiedLabel?: string | undefined;
|
|
10
10
|
/** Called after a successful copy. */
|
|
11
11
|
oncopy?: ((text: string) => void) | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Called when the clipboard turns the text away, such as when the page is not focused
|
|
14
|
+
* or the browser does not allow it. `failedLabel` is read out either way.
|
|
15
|
+
*/
|
|
16
|
+
onerror?: ((error: unknown) => void) | undefined;
|
|
17
|
+
/** Read out when the text could not be copied. */
|
|
18
|
+
failedLabel?: string | undefined;
|
|
12
19
|
sx?: Sx | undefined;
|
|
13
20
|
};
|
|
14
21
|
/**
|
|
15
|
-
* A copy button as markup
|
|
16
|
-
*
|
|
22
|
+
* A copy button as markup: a button and its icon, and nothing else. What it copied is said
|
|
23
|
+
* by the status region of what it is in (Markdown's, through its `announce`). The tick is not there until something is copied (`showCopied`):
|
|
17
24
|
* a page of code blocks has a copy button for each, and nearly none of them is pressed.
|
|
18
25
|
* `label` and `attributes` are escaped already.
|
|
19
26
|
*/
|