@diegopluna/narvi 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/components/activity/ActivityIcon.svelte +54 -0
  2. package/dist/components/activity/ActivityIcon.svelte.d.ts +24 -0
  3. package/dist/components/activity/ActivityStep.svelte +47 -13
  4. package/dist/components/activity/ActivityStep.svelte.d.ts +13 -4
  5. package/dist/components/activity/ActivityThought.svelte +24 -5
  6. package/dist/components/activity/ActivityThought.svelte.d.ts +12 -2
  7. package/dist/components/activity/index.d.ts +3 -1
  8. package/dist/components/activity/index.js +2 -1
  9. package/dist/components/app-shell/AppShellHeader.svelte +18 -4
  10. package/dist/components/app-shell/AppShellHeader.svelte.d.ts +5 -0
  11. package/dist/components/approval/Approval.svelte +14 -1
  12. package/dist/components/approval/Approval.svelte.d.ts +5 -0
  13. package/dist/components/badge/Badge.svelte +3 -1
  14. package/dist/components/badge/Badge.svelte.d.ts +1 -1
  15. package/dist/components/button/Button.svelte +17 -6
  16. package/dist/components/composer/ComposerModelPicker.svelte +80 -13
  17. package/dist/components/composer/ComposerModelPicker.svelte.d.ts +23 -6
  18. package/dist/components/composer/ComposerRoot.svelte +51 -12
  19. package/dist/components/composer/ComposerRoot.svelte.d.ts +16 -0
  20. package/dist/components/composer/ComposerSubmit.svelte +19 -5
  21. package/dist/components/composer/ComposerSubmit.svelte.d.ts +3 -1
  22. package/dist/components/composer/ComposerToggle.svelte +18 -4
  23. package/dist/components/composer/ComposerToggle.svelte.d.ts +2 -0
  24. package/dist/components/composer/ComposerTray.svelte +17 -3
  25. package/dist/components/composer/ComposerTray.svelte.d.ts +5 -0
  26. package/dist/components/composer/context.d.ts +4 -1
  27. package/dist/components/dialog/DialogContent.svelte +22 -12
  28. package/dist/components/dialog/DialogContent.svelte.d.ts +10 -0
  29. package/dist/components/divider/Divider.svelte +56 -14
  30. package/dist/components/divider/Divider.svelte.d.ts +13 -3
  31. package/dist/components/empty-state/EmptyState.svelte +12 -2
  32. package/dist/components/empty-state/EmptyState.svelte.d.ts +6 -0
  33. package/dist/components/heading/Heading.svelte +15 -0
  34. package/dist/components/heading/Heading.svelte.d.ts +6 -0
  35. package/dist/components/hover-card/HoverCardContent.svelte +18 -2
  36. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -0
  37. package/dist/components/input/Input.svelte +13 -3
  38. package/dist/components/input/Input.svelte.d.ts +10 -2
  39. package/dist/components/markdown/Markdown.svelte +22 -2
  40. package/dist/components/markdown/MarkdownDiagram.svelte +33 -2
  41. package/dist/components/markdown/MarkdownFile.svelte +56 -10
  42. package/dist/components/markdown/MarkdownMath.svelte +6 -0
  43. package/dist/components/markdown/MarkdownTable.svelte +3 -4
  44. package/dist/components/markdown/context.d.ts +6 -0
  45. package/dist/components/markdown/labels.d.ts +7 -0
  46. package/dist/components/markdown/labels.js +2 -0
  47. package/dist/components/menu/MenuCheckboxItem.svelte +44 -7
  48. package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +12 -2
  49. package/dist/components/menu/MenuContent.svelte +10 -2
  50. package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
  51. package/dist/components/menu/MenuItem.svelte +17 -2
  52. package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
  53. package/dist/components/menu/MenuSubContent.svelte +10 -2
  54. package/dist/components/menu/MenuSubContent.svelte.d.ts +10 -0
  55. package/dist/components/menu/MenuSubTrigger.svelte +19 -2
  56. package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -0
  57. package/dist/components/message/MessageBubble.svelte +40 -0
  58. package/dist/components/message/MessageBubble.svelte.d.ts +12 -0
  59. package/dist/components/message/MessageContent.svelte +23 -14
  60. package/dist/components/message/MessageContent.svelte.d.ts +6 -0
  61. package/dist/components/message/MessageCopy.svelte +27 -15
  62. package/dist/components/message/MessageCopy.svelte.d.ts +9 -2
  63. package/dist/components/message/MessageRoot.svelte +20 -3
  64. package/dist/components/message/MessageRoot.svelte.d.ts +6 -0
  65. package/dist/components/message/context.d.ts +2 -0
  66. package/dist/components/message/index.d.ts +4 -1
  67. package/dist/components/message/index.js +3 -2
  68. package/dist/components/message/styles.d.ts +30 -0
  69. package/dist/components/message/styles.js +24 -0
  70. package/dist/components/notice/Notice.svelte +3 -3
  71. package/dist/components/popover/PopoverContent.svelte +27 -3
  72. package/dist/components/popover/PopoverContent.svelte.d.ts +18 -0
  73. package/dist/components/questionnaire/Questionnaire.svelte +103 -19
  74. package/dist/components/questionnaire/Questionnaire.svelte.d.ts +13 -1
  75. package/dist/components/queued-message/QueuedMessage.svelte +44 -6
  76. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +12 -1
  77. package/dist/components/select/Select.svelte +18 -2
  78. package/dist/components/select/Select.svelte.d.ts +7 -0
  79. package/dist/components/toast/Toaster.svelte +1 -1
  80. package/dist/components/toggle/Toggle.svelte +12 -2
  81. package/dist/components/toggle/Toggle.svelte.d.ts +11 -1
  82. package/dist/components/toggle-group/ToggleGroupItem.svelte +10 -1
  83. package/dist/components/toggle-group/ToggleGroupRoot.svelte +7 -1
  84. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +3 -1
  85. package/dist/components/toggle-group/context.d.ts +2 -1
  86. package/dist/components/tooltip/TooltipContent.svelte +13 -1
  87. package/dist/components/tooltip/TooltipContent.svelte.d.ts +10 -0
  88. package/dist/components/work-fold/WorkFold.svelte +13 -4
  89. package/dist/components/work-fold/WorkFold.svelte.d.ts +2 -1
  90. package/dist/focus-ring.d.ts +29 -0
  91. package/dist/focus-ring.js +42 -0
  92. package/dist/index.d.ts +6 -5
  93. package/dist/index.js +7 -2
  94. package/dist/internal/Collapse.svelte +15 -2
  95. package/dist/internal/Glyph.svelte +28 -0
  96. package/dist/internal/Glyph.svelte.d.ts +5 -0
  97. package/dist/internal/Tile.svelte +3 -2
  98. package/dist/internal/layer.d.ts +23 -0
  99. package/dist/internal/layer.js +19 -0
  100. package/dist/internal/toggle.d.ts +8 -1
  101. package/dist/internal/toggle.js +20 -2
  102. package/dist/markdown/file-paths.d.ts +7 -0
  103. package/dist/markdown/file-paths.js +29 -0
  104. package/dist/markdown/files.d.ts +22 -2
  105. package/dist/markdown/files.js +45 -14
  106. package/dist/tokens.stylex.d.ts +3 -0
  107. package/dist/tokens.stylex.js +5 -1
  108. package/package.json +1 -1
  109. package/skills/building-ui/SKILL.md +55 -3
  110. package/skills/building-ui/references/components.md +33 -33
  111. package/skills/markdown/SKILL.md +22 -6
  112. package/skills/setup/SKILL.md +1 -1
  113. package/skills/styling/SKILL.md +10 -3
  114. package/skills/theming/SKILL.md +11 -4
@@ -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 wrote, kept as they typed it, line breaks and all
30
- user: {
31
- maxWidth: 'min(85%, 36rem)',
32
- paddingBlock: '0.5625rem',
33
- paddingInline: '0.875rem',
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
- [styles.content, styles[message.from], message.from === 'user' && shared.edged, sx],
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, with the status that says "Copied" after it: a button and its
66
- * icon, and nothing else. The tick is not there until something is copied (`showCopied`):
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
- const text = typeof value === 'function' ? value() : value;
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
- } catch {
130
- return;
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 = true;
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)}>{copied ? copiedLabel : ''}</span>
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, with the status that says "Copied" after it: a button and its
16
- * icon, and nothing else. The tick is not there until something is copied (`showCopied`):
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
  */
@@ -7,6 +7,10 @@
7
7
  import { colors, font } from '../../tokens.stylex.js';
8
8
  import { media } from '../../media.stylex.js';
9
9
  import { setMessageContext, type MessageFrom } from './context.js';
10
+ import type { MessageTextSize } from './styles.js';
11
+
12
+ // A user message whose content is not a bubble holds more than one: attachments, cards
13
+ const HOLDS_MORE = ':has(> [data-slot="message-content"]:not([data-bubble]))';
10
14
 
11
15
  export type MessageRootProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
12
16
  /** Who wrote it. The person's messages sit at the end of the line, in a bubble. */
@@ -16,6 +20,11 @@
16
20
  * assistive technology reads it once, when it is complete.
17
21
  */
18
22
  streaming?: boolean | undefined;
23
+ /**
24
+ * The size its words are read at: `reading`, a step up from interface text, or `body`,
25
+ * the interface's own, for a denser conversation.
26
+ */
27
+ textSize?: MessageTextSize | undefined;
19
28
  sx?: Sx | undefined;
20
29
  ref?: HTMLElement | null | undefined;
21
30
  /** A Message.Content, and optionally Message.Actions. */
@@ -33,11 +42,15 @@
33
42
  },
34
43
  // The person's message opens a new exchange, so it stands further from the
35
44
  // reply before it than a reply stands from its question. With a mouse, its
36
- // actions sit beside the bubble, at its foot, so they take no height.
45
+ // actions sit beside the bubble, at its foot, so they take no height; under it,
46
+ // when it holds more than the bubble.
37
47
  user: {
38
48
  alignItems: 'flex-end',
39
- flexDirection: { default: 'column', [media.hover]: 'row-reverse' },
40
- gap: { default: '0.375rem', [media.hover]: '0.25rem' },
49
+ flexDirection: {
50
+ default: 'column',
51
+ [media.hover]: { default: 'row-reverse', [HOLDS_MORE]: 'column' }
52
+ },
53
+ gap: { default: '0.375rem', [media.hover]: { default: '0.25rem', [HOLDS_MORE]: '0.375rem' } },
41
54
  marginBlockStart: { default: '1.5rem', ':first-child': 0 }
42
55
  },
43
56
  assistant: { alignItems: 'stretch' }
@@ -48,6 +61,7 @@
48
61
  let {
49
62
  from = 'assistant',
50
63
  streaming = false,
64
+ textSize = 'reading',
51
65
  sx,
52
66
  class: className,
53
67
  ref = $bindable(null),
@@ -61,6 +75,9 @@
61
75
  },
62
76
  get streaming() {
63
77
  return streaming;
78
+ },
79
+ get textSize() {
80
+ return textSize;
64
81
  }
65
82
  });
66
83
  </script>
@@ -2,6 +2,7 @@ import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type Sx } from '../../internal/sx.js';
4
4
  import { type MessageFrom } from './context.js';
5
+ import type { MessageTextSize } from './styles.js';
5
6
  export type MessageRootProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
6
7
  /** Who wrote it. The person's messages sit at the end of the line, in a bubble. */
7
8
  from?: MessageFrom | undefined;
@@ -10,6 +11,11 @@ export type MessageRootProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
10
11
  * assistive technology reads it once, when it is complete.
11
12
  */
12
13
  streaming?: boolean | undefined;
14
+ /**
15
+ * The size its words are read at: `reading`, a step up from interface text, or `body`,
16
+ * the interface's own, for a denser conversation.
17
+ */
18
+ textSize?: MessageTextSize | undefined;
13
19
  sx?: Sx | undefined;
14
20
  ref?: HTMLElement | null | undefined;
15
21
  /** A Message.Content, and optionally Message.Actions. */
@@ -1,7 +1,9 @@
1
+ import type { MessageTextSize } from './styles.js';
1
2
  export type MessageFrom = 'user' | 'assistant';
2
3
  export type MessageContext = {
3
4
  readonly from: MessageFrom;
4
5
  readonly streaming: boolean;
6
+ readonly textSize: MessageTextSize;
5
7
  };
6
8
  export declare function setMessageContext(context: MessageContext): void;
7
9
  export declare function getMessageContext(part: string): MessageContext;
@@ -1,15 +1,18 @@
1
1
  import Action from './MessageAction.svelte';
2
2
  import Actions from './MessageActions.svelte';
3
+ import Bubble from './MessageBubble.svelte';
3
4
  import Content from './MessageContent.svelte';
4
5
  import Copy from './MessageCopy.svelte';
5
6
  import Header from './MessageHeader.svelte';
6
7
  import Pending from './MessagePending.svelte';
7
8
  import Root from './MessageRoot.svelte';
8
9
  import Time from './MessageTime.svelte';
9
- export { Root, Header, Pending, Content, Actions, Action, Copy, Time, Root as MessageRoot, Header as MessageHeader, Pending as MessagePending, Content as MessageContent, Actions as MessageActions, Action as MessageAction, Copy as MessageCopy, Time as MessageTime };
10
+ export { Root, Header, Pending, Content, Bubble, Actions, Action, Copy, Time, Root as MessageRoot, Header as MessageHeader, Pending as MessagePending, Content as MessageContent, Bubble as MessageBubble, Actions as MessageActions, Action as MessageAction, Copy as MessageCopy, Time as MessageTime };
10
11
  export type { MessageFrom } from './context.js';
11
12
  export type { MessageActionProps } from './MessageAction.svelte';
12
13
  export type { MessageActionsProps } from './MessageActions.svelte';
14
+ export type { MessageBubbleProps } from './MessageBubble.svelte';
15
+ export type { MessageTextSize } from './styles.js';
13
16
  export type { MessageContentProps } from './MessageContent.svelte';
14
17
  export type { MessageCopyProps } from './MessageCopy.svelte';
15
18
  export type { MessageHeaderProps } from './MessageHeader.svelte';
@@ -1,11 +1,12 @@
1
1
  import Action from './MessageAction.svelte';
2
2
  import Actions from './MessageActions.svelte';
3
+ import Bubble from './MessageBubble.svelte';
3
4
  import Content from './MessageContent.svelte';
4
5
  import Copy from './MessageCopy.svelte';
5
6
  import Header from './MessageHeader.svelte';
6
7
  import Pending from './MessagePending.svelte';
7
8
  import Root from './MessageRoot.svelte';
8
9
  import Time from './MessageTime.svelte';
9
- export { Root, Header, Pending, Content, Actions, Action, Copy, Time,
10
+ export { Root, Header, Pending, Content, Bubble, Actions, Action, Copy, Time,
10
11
  //
11
- Root as MessageRoot, Header as MessageHeader, Pending as MessagePending, Content as MessageContent, Actions as MessageActions, Action as MessageAction, Copy as MessageCopy, Time as MessageTime };
12
+ Root as MessageRoot, Header as MessageHeader, Pending as MessagePending, Content as MessageContent, Bubble as MessageBubble, Actions as MessageActions, Action as MessageAction, Copy as MessageCopy, Time as MessageTime };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * What a message's words look like, shared by Message.Content and Message.Bubble: the size
3
+ * they are read at, and the person's bubble.
4
+ */
5
+ import * as stylex from '@stylexjs/stylex';
6
+ /** The size a message is read at: `reading`, a step up from interface text, or `body`, as the interface's. */
7
+ export type MessageTextSize = 'reading' | 'body';
8
+ export declare const text: Readonly<{
9
+ readonly reading: Readonly<{
10
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
11
+ readonly lineHeight: stylex.StyleXClassNameFor<"lineHeight", string>;
12
+ }>;
13
+ readonly body: Readonly<{
14
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
15
+ readonly lineHeight: stylex.StyleXClassNameFor<"lineHeight", string>;
16
+ }>;
17
+ }>;
18
+ export declare const bubble: Readonly<{
19
+ readonly bubble: Readonly<{
20
+ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
21
+ readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "min(85%, 36rem)">;
22
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
23
+ readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", "0.5625rem">;
24
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.875rem">;
25
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
26
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
27
+ readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "pre-wrap">;
28
+ readonly overflowWrap: stylex.StyleXClassNameFor<"overflowWrap", "anywhere">;
29
+ }>;
30
+ }>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What a message's words look like, shared by Message.Content and Message.Bubble: the size
3
+ * they are read at, and the person's bubble.
4
+ */
5
+ import * as stylex from '@stylexjs/stylex';
6
+ import { colors, font, radius } from '../../tokens.stylex.js';
7
+ export const text = stylex.create({
8
+ reading: { fontSize: font.sizeReading, lineHeight: font.leadingNormal },
9
+ body: { fontSize: font.sizeBody, lineHeight: font.leadingNormal }
10
+ });
11
+ export const bubble = stylex.create({
12
+ // What the person wrote, kept as they typed it, line breaks and all
13
+ bubble: {
14
+ boxSizing: 'border-box',
15
+ maxWidth: 'min(85%, 36rem)',
16
+ minWidth: 0,
17
+ paddingBlock: '0.5625rem',
18
+ paddingInline: '0.875rem',
19
+ borderRadius: radius.frame,
20
+ backgroundColor: colors.fillMuted,
21
+ whiteSpace: 'pre-wrap',
22
+ overflowWrap: 'anywhere'
23
+ }
24
+ });
@@ -55,7 +55,7 @@
55
55
  backgroundColor: colors.fillSunken,
56
56
  color: colors.text
57
57
  },
58
- info: { backgroundColor: colors.accentSoft, color: colors.text },
58
+ info: { backgroundColor: colors.infoSoft, color: colors.infoText },
59
59
  success: { backgroundColor: colors.successSoft, color: colors.successText },
60
60
  warning: { backgroundColor: colors.warningSoft, color: colors.warningText },
61
61
  danger: { backgroundColor: colors.dangerSoft, color: colors.dangerText },
@@ -65,7 +65,7 @@
65
65
  backgroundColor: colors.bgRaised,
66
66
  boxShadow: `inset 0 0 0 1px ${colors.border}`
67
67
  },
68
- raisedInfo: { backgroundImage: `linear-gradient(${colors.accentSoft}, ${colors.accentSoft})` },
68
+ raisedInfo: { backgroundImage: `linear-gradient(${colors.infoSoft}, ${colors.infoSoft})` },
69
69
  raisedSuccess: {
70
70
  backgroundImage: `linear-gradient(${colors.successSoft}, ${colors.successSoft})`
71
71
  },
@@ -77,7 +77,7 @@
77
77
  },
78
78
  icon: { display: 'grid', placeItems: 'center', width: '1rem', height: '1lh' },
79
79
  iconNeutral: { color: colors.textMuted },
80
- iconInfo: { color: colors.accent },
80
+ iconInfo: { color: colors.info },
81
81
  text: { display: 'flex', flexDirection: 'column', gap: '0.125rem', minWidth: 0 },
82
82
  title: { fontWeight: font.weightMedium },
83
83
  detail: {
@@ -3,11 +3,20 @@
3
3
  import { Popover } from 'bits-ui';
4
4
  import * as stylex from '@stylexjs/stylex';
5
5
  import type { Snippet } from 'svelte';
6
- import { layer } from '../../internal/layer.js';
6
+ import { layer, widthStyle } from '../../internal/layer.js';
7
7
  import { attrs, type Sx } from '../../internal/sx.js';
8
8
 
9
9
  export type PopoverContentProps = Loose<
10
10
  Omit<Popover.ContentProps, 'children' | 'child'> & {
11
+ /**
12
+ * `default` gives its content room of its own; `none` takes the padding away, for
13
+ * content that brings its own, such as a list of items that reach the edges.
14
+ */
15
+ padding?: 'default' | 'none' | undefined;
16
+ /** `column` sets its content one part under another, with room between them. */
17
+ layout?: 'block' | 'column' | undefined;
18
+ /** A width of its own, such as `20rem`, in place of fitting its content (16 to 22rem). */
19
+ width?: string | undefined;
11
20
  sx?: Sx | undefined;
12
21
  children?: Snippet | undefined;
13
22
  }
@@ -15,7 +24,8 @@
15
24
 
16
25
  const styles = stylex.create({
17
26
  // Room for content of its own, rather than a list of items
18
- padded: { padding: '0.75rem', minWidth: 'max(16rem, var(--bits-floating-anchor-width, 0px))' }
27
+ padded: { padding: '0.75rem', minWidth: 'max(16rem, var(--bits-floating-anchor-width, 0px))' },
28
+ bare: { padding: 0, minWidth: 'max(12rem, var(--bits-floating-anchor-width, 0px))' }
19
29
  });
20
30
  </script>
21
31
 
@@ -24,6 +34,10 @@
24
34
  sideOffset = 6,
25
35
  collisionPadding = 8,
26
36
  align = 'start',
37
+ padding = 'default',
38
+ layout = 'block',
39
+ width,
40
+ style,
27
41
  sx,
28
42
  class: className,
29
43
  children,
@@ -38,7 +52,17 @@
38
52
  {align}
39
53
  data-slot="popover-content"
40
54
  {...rest}
41
- {...attrs([layer.surface, styles.padded, sx], className)}
55
+ style={widthStyle(width, style)}
56
+ {...attrs(
57
+ [
58
+ layer.surface,
59
+ padding === 'none' ? styles.bare : styles.padded,
60
+ layout === 'column' && layer.column,
61
+ !!width && layer.sized,
62
+ sx
63
+ ],
64
+ className
65
+ )}
42
66
  >
43
67
  {@render children?.()}
44
68
  </Popover.Content>
@@ -3,10 +3,28 @@ import { Popover } from 'bits-ui';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
5
  export type PopoverContentProps = Loose<Omit<Popover.ContentProps, 'children' | 'child'> & {
6
+ /**
7
+ * `default` gives its content room of its own; `none` takes the padding away, for
8
+ * content that brings its own, such as a list of items that reach the edges.
9
+ */
10
+ padding?: 'default' | 'none' | undefined;
11
+ /** `column` sets its content one part under another, with room between them. */
12
+ layout?: 'block' | 'column' | undefined;
13
+ /** A width of its own, such as `20rem`, in place of fitting its content (16 to 22rem). */
14
+ width?: string | undefined;
6
15
  sx?: Sx | undefined;
7
16
  children?: Snippet | undefined;
8
17
  }>;
9
18
  declare const PopoverContent: import("svelte").Component<Loose<Omit<Popover.ContentProps, "children" | "child"> & {
19
+ /**
20
+ * `default` gives its content room of its own; `none` takes the padding away, for
21
+ * content that brings its own, such as a list of items that reach the edges.
22
+ */
23
+ padding?: "default" | "none" | undefined;
24
+ /** `column` sets its content one part under another, with room between them. */
25
+ layout?: "block" | "column" | undefined;
26
+ /** A width of its own, such as `20rem`, in place of fitting its content (16 to 22rem). */
27
+ width?: string | undefined;
10
28
  sx?: Sx | undefined;
11
29
  children?: Snippet | undefined;
12
30
  }>, {}, "">;