@widgetic/design-system 0.5.27 → 0.5.29

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 (64) hide show
  1. package/dist/components/CopyableHeader.svelte +29 -10
  2. package/dist/components/CopyableHeader.svelte.d.ts +3 -0
  3. package/dist/components/EmptyState.svelte +13 -3
  4. package/dist/components/chat/ChatHeader.svelte +29 -3
  5. package/dist/components/chat/ChatHeader.svelte.d.ts +5 -0
  6. package/dist/components/chat/Composer.svelte +58 -1
  7. package/dist/components/chat/Composer.svelte.d.ts +8 -0
  8. package/dist/components/chat/MessageCheckpointRow.svelte +87 -0
  9. package/dist/components/chat/MessageCheckpointRow.svelte.d.ts +21 -0
  10. package/dist/components/chat/MessageRatingActions.svelte +157 -0
  11. package/dist/components/chat/MessageRatingActions.svelte.d.ts +26 -0
  12. package/dist/components/chat/chatHeaderLogic.d.ts +8 -0
  13. package/dist/components/chat/chatHeaderLogic.js +14 -0
  14. package/dist/components/chat/composerModelMenuLogic.d.ts +9 -0
  15. package/dist/components/chat/composerModelMenuLogic.js +12 -0
  16. package/dist/components/chat/index.d.ts +10 -0
  17. package/dist/components/chat/index.js +8 -0
  18. package/dist/components/chat/messageRatingActionsLogic.d.ts +11 -0
  19. package/dist/components/chat/messageRatingActionsLogic.js +17 -0
  20. package/dist/components/chat/messageRatingTypes.d.ts +2 -0
  21. package/dist/components/chat/messageRatingTypes.js +1 -0
  22. package/dist/components/modals/BaseModal.svelte +133 -11
  23. package/dist/components/modals/BaseModal.svelte.d.ts +1 -0
  24. package/dist/components/modals/NewItemDialog.svelte +2 -0
  25. package/dist/components/shad-editor/custom/Extentions/SearchAndReplace.js +0 -1
  26. package/dist/components/shad-editor/custom/utils.d.ts +1 -1
  27. package/dist/components/shad-editor/custom/utils.js +0 -1
  28. package/dist/components/shell/ErrorState.svelte +5 -2
  29. package/dist/components/shell/ErrorState.svelte.d.ts +2 -1
  30. package/dist/components/shell/NavRow.svelte +5 -4
  31. package/dist/components/shell/NavRow.svelte.d.ts +3 -3
  32. package/dist/components/shell/SettingsDialog.svelte +65 -4
  33. package/dist/components/shell/WidgetRow.svelte +6 -6
  34. package/dist/components/shell/WidgetRow.svelte.d.ts +2 -2
  35. package/dist/components/ui/accordion/accordion-content.svelte +5 -1
  36. package/dist/components/ui/accordion/accordion-item.svelte +2 -1
  37. package/dist/components/ui/accordion/accordion-trigger.svelte +38 -0
  38. package/dist/components/ui/button/button.svelte +1 -1
  39. package/dist/components/ui/button/button.svelte.d.ts +3 -3
  40. package/dist/components/ui/calendar/calendar.svelte.d.ts +1 -1
  41. package/dist/components/ui/checkbox/checkbox.svelte +1 -1
  42. package/dist/components/ui/dialog/dialog-overlay.svelte +8 -1
  43. package/dist/components/ui/icon-button/icon-button.svelte +1 -1
  44. package/dist/components/ui/icon-button/icon-button.svelte.d.ts +2 -2
  45. package/dist/components/ui/input-otp/input-otp-slot.svelte.d.ts +1 -1
  46. package/dist/components/ui/radio-group/radio-group-item.svelte +1 -1
  47. package/dist/components/ui/range-calendar/range-calendar.svelte.d.ts +1 -1
  48. package/dist/components/ui/scroll-area/scroll-area-scrollbar.svelte +1 -1
  49. package/dist/components/ui/select/select-content.svelte +2 -2
  50. package/dist/components/ui/select/select-scroll-down-button.svelte +1 -1
  51. package/dist/components/ui/select/select-scroll-up-button.svelte +1 -1
  52. package/dist/components/ui/select/select-trigger.svelte +1 -1
  53. package/dist/components/ui/stepper-button/stepper-button.svelte +1 -1
  54. package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
  55. package/dist/components/widget-system/Moveable.svelte +24 -21
  56. package/dist/utils/isEditableEventTarget.d.ts +5 -0
  57. package/dist/utils/isEditableEventTarget.js +25 -0
  58. package/dist/utils/modalFocusTrap.d.ts +28 -0
  59. package/dist/utils/modalFocusTrap.js +135 -0
  60. package/dist/utils/overlayMotion.d.ts +6 -0
  61. package/dist/utils/overlayMotion.js +7 -0
  62. package/dist/utils/overlayStacking.d.ts +47 -0
  63. package/dist/utils/overlayStacking.js +63 -0
  64. package/package.json +1 -1
@@ -22,6 +22,7 @@
22
22
  <script lang="ts">
23
23
  import { createEventDispatcher, onDestroy } from 'svelte';
24
24
  import { toast, Button, Tooltip, Portal, IconButton, Link, Skeleton } from './';
25
+ import type { ButtonVariant } from './ui/button/index.js';
25
26
  import { cn } from '../utils.js';
26
27
  import { IconCopy, IconCheck, IconAlertTriangle } from '@tabler/icons-svelte';
27
28
  import { sideAtStart, useTextDirection } from './textDirection.js';
@@ -43,6 +44,8 @@
43
44
  export let monospaceContent = true;
44
45
  export let showStandaloneCopyButton = false;
45
46
  export let standaloneCopyButtonText = '';
47
+ /** Style of the labelled copy button; `secondary` when a primary action sits next to the header (a dialog's own confirm button). */
48
+ export let standaloneCopyButtonVariant: ButtonVariant = 'default';
46
49
  export let copiedTitle = 'Copied to clipboard';
47
50
  export let copiedDescription = 'Content copied successfully.';
48
51
  export let copyFailedTitle = 'Copy failed';
@@ -56,6 +59,8 @@
56
59
  export let loading = false;
57
60
  export let errorTitle = '';
58
61
  export let errorDetail = '';
62
+ /** Tailwind gap class between the title row and the code card (`gap-4` = 16px). */
63
+ export let titleToContentGapClass = 'gap-4';
59
64
 
60
65
  let showCopyTooltip = false;
61
66
  let tooltipDebounce = false;
@@ -64,6 +69,7 @@
64
69
  let copied = false;
65
70
  let copiedTimeout: ReturnType<typeof setTimeout> | undefined;
66
71
  let isToastVisible = false;
72
+ let copyStatusMessage = '';
67
73
 
68
74
  $: showHelpRow = showHelp && !!helpUrl && (!!helpPrompt || !!helpText);
69
75
 
@@ -95,9 +101,11 @@
95
101
  try {
96
102
  await navigator.clipboard.writeText(content);
97
103
  copied = true;
104
+ copyStatusMessage = copiedTitle;
98
105
  if (copiedTimeout) clearTimeout(copiedTimeout);
99
106
  copiedTimeout = setTimeout(() => {
100
107
  copied = false;
108
+ copyStatusMessage = '';
101
109
  }, 2000);
102
110
  if (showInternalToast) {
103
111
  showToast('success', copiedTitle, {
@@ -119,7 +127,12 @@
119
127
  function handleSnippetClick(event: MouseEvent) {
120
128
  if (!contentElement || isSelectingSnippet) return;
121
129
  const selection = window.getSelection();
122
- if (selection && !selection.isCollapsed && selection.anchorNode && contentElement.contains(selection.anchorNode)) {
130
+ if (
131
+ selection &&
132
+ !selection.isCollapsed &&
133
+ selection.anchorNode &&
134
+ contentElement.contains(selection.anchorNode)
135
+ ) {
123
136
  return;
124
137
  }
125
138
  event.preventDefault();
@@ -158,7 +171,10 @@
158
171
  </script>
159
172
 
160
173
  <!-- `min-w-0` on the root and on the title row: a `truncate` title has its whole text as min-content, so inside a grid or flex parent (a dialog) the row would push the copy button out of the parent instead of cutting the title. -->
161
- <div class={cn('copyable-header flex w-full min-w-0 flex-col gap-4', className)} {style}>
174
+ <div
175
+ class={cn('copyable-header flex w-full min-w-0 flex-col', titleToContentGapClass, className)}
176
+ {style}
177
+ >
162
178
  <!-- Title row: section label + copy control (Figma 32px). -->
163
179
  <div class={cn('flex h-8 min-w-0 items-center justify-between gap-3', headerBackgroundColor)}>
164
180
  <div class={cn('text-heading-section text-foreground min-w-0 truncate', headerTextClass)}>
@@ -172,7 +188,7 @@
172
188
  {#snippet child({ props }: TriggerChildProps)}
173
189
  <Button
174
190
  {...props}
175
- variant="default"
191
+ variant={standaloneCopyButtonVariant}
176
192
  class={cn(buttonClass, props.class)}
177
193
  onclick={handleCopyButtonClick}
178
194
  onmouseenter={() => {
@@ -213,8 +229,9 @@
213
229
  {#snippet child({ props }: TriggerChildProps)}
214
230
  <IconButton
215
231
  {...props}
216
- variant={copied ? 'accent' : 'ghost'}
217
- label={standaloneCopyButtonText || 'Copy'}
232
+ variant="ghost"
233
+ label={copied ? copiedTitle : standaloneCopyButtonText || 'Copy'}
234
+ aria-live="polite"
218
235
  class={cn(headerBackgroundColor, props.class)}
219
236
  onclick={handleCopyButtonClick}
220
237
  onmouseenter={() => {
@@ -229,9 +246,10 @@
229
246
  }}
230
247
  >
231
248
  {#if copied}
232
- <IconCheck class="size-4 stroke-2" />
249
+ <!-- The green of the success toast icon (`text-brand`); there is no `text-success` utility in the theme. -->
250
+ <IconCheck class="text-brand size-4 stroke-2" aria-hidden="true" />
233
251
  {:else}
234
- <IconCopy class="text-muted-foreground size-4 stroke-2" />
252
+ <IconCopy class="text-muted-foreground size-4 stroke-2" aria-hidden="true" />
235
253
  {/if}
236
254
  </IconButton>
237
255
  {/snippet}
@@ -247,11 +265,12 @@
247
265
  </Tooltip.Provider>
248
266
  {/if}
249
267
  </div>
268
+ <span class="sr-only" aria-live="polite">{copyStatusMessage}</span>
250
269
 
251
270
  <!-- Code card: accent surface; loading skeleton, error, or selectable snippet. -->
252
271
  <div
253
272
  class={cn(
254
- 'embed-code-surface bg-accent flex flex-col gap-2 rounded-xl p-3 transition-colors duration-fast hover:bg-accent-hover',
273
+ 'embed-code-surface bg-accent duration-fast hover:bg-accent-hover flex flex-col gap-2 rounded-xl p-3 transition-colors',
255
274
  contentBorderColor && 'border-border border'
256
275
  )}
257
276
  style={contentBorderColor && !contentBorderColor.startsWith('border')
@@ -279,8 +298,8 @@
279
298
  <div
280
299
  bind:this={contentElement}
281
300
  class={cn(
282
- // Three lines of the snippet are visible (`3lh` follows the line height of the text style); the rest scrolls inside the card.
283
- 'embed-code-snippet text-code text-foreground max-h-[3lh] w-full cursor-text overflow-y-auto text-start break-all whitespace-pre-wrap',
301
+ // Three lines of soft-wrapped snippet are visible (`3lh` follows the line height); extra lines scroll vertically inside the card.
302
+ 'embed-code-snippet text-code text-foreground max-h-[3lh] w-full min-w-0 cursor-text overflow-x-hidden overflow-y-auto text-start [overflow-wrap:anywhere] break-all whitespace-pre-wrap',
284
303
  monospaceContent ? '' : 'text-body'
285
304
  )}
286
305
  tabindex="0"
@@ -1,3 +1,4 @@
1
+ import type { ButtonVariant } from './ui/button/index.js';
1
2
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
3
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
4
  $$bindings?: Bindings;
@@ -24,6 +25,7 @@ declare const CopyableHeader: $$__sveltets_2_IsomorphicComponent<{
24
25
  monospaceContent?: boolean;
25
26
  showStandaloneCopyButton?: boolean;
26
27
  standaloneCopyButtonText?: string;
28
+ /** Style of the labelled copy button; `secondary` when a primary action sits next to the header (a dialog's own confirm button). */ standaloneCopyButtonVariant?: ButtonVariant;
27
29
  copiedTitle?: string;
28
30
  copiedDescription?: string;
29
31
  copyFailedTitle?: string;
@@ -37,6 +39,7 @@ declare const CopyableHeader: $$__sveltets_2_IsomorphicComponent<{
37
39
  loading?: boolean;
38
40
  errorTitle?: string;
39
41
  errorDetail?: string;
42
+ /** Tailwind gap class between the title row and the code card (`gap-4` = 16px). */ titleToContentGapClass?: string;
40
43
  }, {
41
44
  copy: CustomEvent<any>;
42
45
  copyError: CustomEvent<any>;
@@ -1,6 +1,9 @@
1
1
  <!--
2
2
  * EmptyState — Figma: Empty State (component set 54:71, node 54:71).
3
3
  * Centered empty view with icon tile, title, optional description, and actions.
4
+ *
5
+ * In a pane below a header, pass `class="min-h-0 flex-1"`, `height="auto"` or `height="100%"`, and put the empty state in a
6
+ * flex column parent so it grows into the remaining space and keeps its content centered.
4
7
  -->
5
8
  <script lang="ts">
6
9
  import { onMount } from 'svelte';
@@ -62,14 +65,21 @@
62
65
 
63
66
  const titleStyle = $derived(textColor ? `color: ${textColor}` : undefined);
64
67
  const iconStyle = $derived(iconColor ? `color: ${iconColor}` : undefined);
68
+
69
+ const containerStyle = $derived.by(() => {
70
+ const extra = style ? `${style};` : '';
71
+ if (height === 'auto') return extra || undefined;
72
+ if (height === '100%') return `min-height: 0; height: 100%; ${extra}`;
73
+ return `height: ${height}; ${extra}`;
74
+ });
65
75
  </script>
66
76
 
67
77
  <div
68
78
  class={cn(
69
- 'empty-state-container flex w-full items-center justify-center overflow-hidden',
79
+ 'empty-state-container flex min-h-0 w-full items-center justify-center overflow-hidden',
70
80
  className
71
81
  )}
72
- style="height: {height}; {style}"
82
+ style={containerStyle}
73
83
  >
74
84
  <div
75
85
  class="empty-state-content pointer-events-auto flex w-full max-w-[30rem] flex-col items-center gap-3 px-12 py-12 text-center"
@@ -85,7 +95,7 @@
85
95
  {/if}
86
96
 
87
97
  <div class="flex w-full min-w-0 flex-col gap-1">
88
- <p class="text-heading-section text-foreground" style={titleStyle}>{message}</p>
98
+ <p class="text-body text-muted-foreground" style={titleStyle}>{message}</p>
89
99
  {#if description}
90
100
  <p class="text-body text-muted-foreground">{description}</p>
91
101
  {/if}
@@ -7,7 +7,9 @@
7
7
  import IconMessagePlus from '@tabler/icons-svelte/icons/message-plus';
8
8
  import IconMessages from '@tabler/icons-svelte/icons/messages';
9
9
  import IconPin from '@tabler/icons-svelte/icons/pin';
10
+ import IconTerminal2 from '@tabler/icons-svelte/icons/terminal-2';
10
11
  import IconX from '@tabler/icons-svelte/icons/x';
12
+ import { shouldShowConsoleButton, shouldShowPinButton } from './chatHeaderLogic.js';
11
13
  import { Button } from '../ui/button';
12
14
  import { IconButton } from '../ui/icon-button';
13
15
  import { cn } from '../../utils.js';
@@ -18,6 +20,7 @@
18
20
  newChat: string;
19
21
  history: string;
20
22
  pin: string;
23
+ console: string;
21
24
  close: string;
22
25
  openHistory: string;
23
26
  };
@@ -26,6 +29,7 @@
26
29
  newChat: 'New chat',
27
30
  history: 'Chat history',
28
31
  pin: 'Pin chat',
32
+ console: 'Console',
29
33
  close: 'Close chat',
30
34
  openHistory: 'Open chat history'
31
35
  };
@@ -37,11 +41,15 @@
37
41
  title?: string;
38
42
  status?: string;
39
43
  showClose?: boolean;
44
+ /** When true with `onToggleConsole`, the header shows the debug console icon instead of pin. */
45
+ showConsole?: boolean;
46
+ consoleOpen?: boolean;
40
47
  messages?: Partial<ChatHeaderMessages>;
41
48
  onTitleClick?: () => void;
42
49
  onNewChat?: () => void;
43
50
  onHistory?: () => void;
44
51
  onPin?: () => void;
52
+ onToggleConsole?: () => void;
45
53
  onClose?: () => void;
46
54
  };
47
55
 
@@ -52,17 +60,22 @@
52
60
  title,
53
61
  status,
54
62
  showClose = false,
63
+ showConsole = false,
64
+ consoleOpen = false,
55
65
  messages: messagesProp,
56
66
  onTitleClick,
57
67
  onNewChat,
58
68
  onHistory,
59
69
  onPin,
70
+ onToggleConsole,
60
71
  onClose,
61
72
  ...restProps
62
73
  }: Props = $props();
63
74
 
64
75
  const messages = $derived({ ...defaultMessages, ...messagesProp });
65
76
  const displayTitle = $derived(title?.trim() || messages.newChat);
77
+ const consoleVisible = $derived(shouldShowConsoleButton(showConsole, onToggleConsole));
78
+ const pinVisible = $derived(shouldShowPinButton(showConsole, onToggleConsole, onPin));
66
79
  </script>
67
80
 
68
81
  <header
@@ -92,13 +105,26 @@
92
105
 
93
106
  <span class="min-w-0 flex-1" aria-hidden="true"></span>
94
107
 
95
- <IconButton variant="ghost" label={messages.pin} onclick={onPin}>
96
- <IconPin class="stroke-2" />
97
- </IconButton>
108
+ {#if consoleVisible}
109
+ <IconButton
110
+ variant="ghost"
111
+ label={messages.console}
112
+ aria-pressed={consoleOpen}
113
+ onclick={onToggleConsole}
114
+ >
115
+ <IconTerminal2 class="stroke-2" />
116
+ </IconButton>
117
+ {:else if pinVisible}
118
+ <IconButton variant="ghost" label={messages.pin} onclick={onPin}>
119
+ <IconPin class="stroke-2" />
120
+ </IconButton>
121
+ {/if}
98
122
 
123
+ {#if onNewChat}
99
124
  <IconButton variant="ghost" label={messages.newChat} onclick={onNewChat}>
100
125
  <IconMessagePlus class="stroke-2" />
101
126
  </IconButton>
127
+ {/if}
102
128
 
103
129
  {#if onHistory}
104
130
  <IconButton variant="ghost" label={messages.history} onclick={onHistory}>
@@ -4,6 +4,7 @@ export type ChatHeaderMessages = {
4
4
  newChat: string;
5
5
  history: string;
6
6
  pin: string;
7
+ console: string;
7
8
  close: string;
8
9
  openHistory: string;
9
10
  };
@@ -14,11 +15,15 @@ type Props = HTMLAttributes<HTMLElement> & {
14
15
  title?: string;
15
16
  status?: string;
16
17
  showClose?: boolean;
18
+ /** When true with `onToggleConsole`, the header shows the debug console icon instead of pin. */
19
+ showConsole?: boolean;
20
+ consoleOpen?: boolean;
17
21
  messages?: Partial<ChatHeaderMessages>;
18
22
  onTitleClick?: () => void;
19
23
  onNewChat?: () => void;
20
24
  onHistory?: () => void;
21
25
  onPin?: () => void;
26
+ onToggleConsole?: () => void;
22
27
  onClose?: () => void;
23
28
  };
24
29
  declare const ChatHeader: import("svelte").Component<Props, {}, "ref">;
@@ -12,6 +12,11 @@
12
12
  characterLimit: string;
13
13
  };
14
14
 
15
+ export type ComposerModelOption = {
16
+ id: string;
17
+ label: string;
18
+ };
19
+
15
20
  export type ComposerProps = HTMLAttributes<HTMLDivElement> & {
16
21
  ref?: HTMLDivElement | null;
17
22
  class?: string;
@@ -21,6 +26,10 @@
21
26
  disabled?: boolean;
22
27
  maxLength?: number;
23
28
  allowEmpty?: boolean;
29
+ assistantLabel?: string;
30
+ models?: ComposerModelOption[];
31
+ selectedModelId?: string | null;
32
+ onSelectModel?: (modelId: string) => void;
24
33
  messages?: Partial<ComposerMessages>;
25
34
  onSend?: (text: string) => void;
26
35
  onStop?: () => void;
@@ -31,11 +40,19 @@
31
40
  </script>
32
41
 
33
42
  <script lang="ts">
43
+ import IconCheck from '@tabler/icons-svelte/icons/check';
44
+ import IconChevronDown from '@tabler/icons-svelte/icons/chevron-down';
34
45
  import IconPlayerStop from '@tabler/icons-svelte/icons/player-stop';
35
46
  import IconSend from '@tabler/icons-svelte/icons/send';
36
47
  import { cn } from '../../utils.js';
48
+ import { Button } from '../ui/button/index.js';
37
49
  import { IconButton } from '../ui/icon-button/index.js';
50
+ import * as DropdownMenu from '../ui/dropdown-menu';
38
51
  import { canSendText, clampTextareaHeight, shouldSendOnKeyDown } from './composerLogic.js';
52
+ import {
53
+ selectedModelLabel,
54
+ shouldShowComposerModelMenu
55
+ } from './composerModelMenuLogic.js';
39
56
 
40
57
  const defaultMessages: ComposerMessages = {
41
58
  send: 'Send message',
@@ -53,6 +70,10 @@
53
70
  disabled = false,
54
71
  maxLength,
55
72
  allowEmpty = false,
73
+ assistantLabel = 'Assistant',
74
+ models = [],
75
+ selectedModelId = null,
76
+ onSelectModel,
56
77
  messages: messagesProp,
57
78
  onSend,
58
79
  onStop,
@@ -63,6 +84,9 @@
63
84
  }: ComposerProps = $props();
64
85
 
65
86
  const messages = $derived({ ...defaultMessages, ...messagesProp });
87
+ const modelMenuVisible = $derived(shouldShowComposerModelMenu(models));
88
+ const modelMenuLabel = $derived(selectedModelLabel(models, selectedModelId, assistantLabel));
89
+ let modelMenuOpen = $state(false);
66
90
 
67
91
  let textareaRef = $state<HTMLTextAreaElement | null>(null);
68
92
  let isComposing = $state(false);
@@ -148,10 +172,43 @@
148
172
  </div>
149
173
 
150
174
  <div class="flex items-center gap-2">
151
- <div class="flex min-w-0 flex-1 items-center gap-1">
175
+ <div class="relative flex min-w-0 flex-1 items-center gap-1">
176
+ <!-- Figma toolbar order: the host's controls first (attach), then the model menu (mode). -->
152
177
  {#if leading}
153
178
  {@render leading()}
154
179
  {/if}
180
+ {#if modelMenuVisible}
181
+ <!-- The DS dropdown handles outside click, Escape, arrow keys and focus return; the menu opens upwards because the composer sits at the bottom edge. -->
182
+ <DropdownMenu.Root bind:open={modelMenuOpen}>
183
+ <DropdownMenu.Trigger>
184
+ {#snippet child({ props }: { props: Record<string, unknown> })}
185
+ <Button
186
+ {...props}
187
+ variant="ghost"
188
+ size="sm"
189
+ class="max-w-[11rem] shrink-0 gap-1 px-2"
190
+ disabled={busy || disabled}
191
+ >
192
+ <span class="truncate">{modelMenuLabel}</span>
193
+ <IconChevronDown class="size-4 shrink-0 stroke-2" aria-hidden="true" />
194
+ </Button>
195
+ {/snippet}
196
+ </DropdownMenu.Trigger>
197
+ <DropdownMenu.Content side="top" align="start" class="max-h-48 w-56 overflow-y-auto">
198
+ {#each models as model (model.id)}
199
+ <DropdownMenu.Item
200
+ class="justify-between gap-2"
201
+ onSelect={() => onSelectModel?.(model.id)}
202
+ >
203
+ <span class="truncate">{model.label}</span>
204
+ {#if model.id === selectedModelId}
205
+ <IconCheck class="size-4 shrink-0 stroke-2" aria-hidden="true" />
206
+ {/if}
207
+ </DropdownMenu.Item>
208
+ {/each}
209
+ </DropdownMenu.Content>
210
+ </DropdownMenu.Root>
211
+ {/if}
155
212
  </div>
156
213
  {#if trailing}
157
214
  {@render trailing()}
@@ -6,6 +6,10 @@ export type ComposerMessages = {
6
6
  attach: string;
7
7
  characterLimit: string;
8
8
  };
9
+ export type ComposerModelOption = {
10
+ id: string;
11
+ label: string;
12
+ };
9
13
  export type ComposerProps = HTMLAttributes<HTMLDivElement> & {
10
14
  ref?: HTMLDivElement | null;
11
15
  class?: string;
@@ -15,6 +19,10 @@ export type ComposerProps = HTMLAttributes<HTMLDivElement> & {
15
19
  disabled?: boolean;
16
20
  maxLength?: number;
17
21
  allowEmpty?: boolean;
22
+ assistantLabel?: string;
23
+ models?: ComposerModelOption[];
24
+ selectedModelId?: string | null;
25
+ onSelectModel?: (modelId: string) => void;
18
26
  messages?: Partial<ComposerMessages>;
19
27
  onSend?: (text: string) => void;
20
28
  onStop?: () => void;
@@ -0,0 +1,87 @@
1
+ <!--
2
+ Figma: checkpoint row under a user turn (version label, restore, redo).
3
+ -->
4
+ <script lang="ts" module>
5
+ import type { HTMLAttributes } from 'svelte/elements';
6
+
7
+ export type MessageCheckpointRowMessages = {
8
+ version: string;
9
+ restore: string;
10
+ redo: string;
11
+ restored: string;
12
+ };
13
+
14
+ export type MessageCheckpointRowProps = HTMLAttributes<HTMLDivElement> & {
15
+ ref?: HTMLDivElement | null;
16
+ class?: string;
17
+ versionLabel?: string | null;
18
+ showRestore?: boolean;
19
+ showRedo?: boolean;
20
+ restoredToVersion?: string | null;
21
+ messages?: Partial<MessageCheckpointRowMessages>;
22
+ onRestore?: () => void;
23
+ onRedo?: () => void;
24
+ };
25
+ </script>
26
+
27
+ <script lang="ts">
28
+ import IconHistory from '@tabler/icons-svelte/icons/history';
29
+ import IconArrowBackUp from '@tabler/icons-svelte/icons/arrow-back-up';
30
+ import { cn } from '../../utils.js';
31
+ import { Button } from '../ui/button/index.js';
32
+
33
+ const defaultMessages: MessageCheckpointRowMessages = {
34
+ version: 'Version {n}',
35
+ restore: 'Restore',
36
+ redo: 'Redo',
37
+ restored: 'Restored to version {n}'
38
+ };
39
+
40
+ let {
41
+ ref = $bindable(null),
42
+ class: className,
43
+ versionLabel = null,
44
+ showRestore = false,
45
+ showRedo = false,
46
+ restoredToVersion = null,
47
+ messages: messagesProp,
48
+ onRestore,
49
+ onRedo,
50
+ ...restProps
51
+ }: MessageCheckpointRowProps = $props();
52
+
53
+ const messages = $derived({ ...defaultMessages, ...messagesProp });
54
+ const restoredText = $derived(
55
+ restoredToVersion
56
+ ? messages.restored.replace('{n}', restoredToVersion)
57
+ : ''
58
+ );
59
+ </script>
60
+
61
+ <div
62
+ bind:this={ref}
63
+ class={cn('flex w-full min-w-0 items-center justify-between gap-2', className)}
64
+ {...restProps}
65
+ >
66
+ <div class="flex min-w-0 items-center gap-2">
67
+ {#if restoredText}
68
+ <span class="text-caption text-muted-foreground truncate">{restoredText}</span>
69
+ {:else if versionLabel}
70
+ <span class="text-caption text-muted-foreground truncate">{versionLabel}</span>
71
+ {/if}
72
+ </div>
73
+ <div class="flex shrink-0 items-center gap-1">
74
+ {#if showRestore && onRestore}
75
+ <Button variant="ghost" size="sm" onclick={onRestore}>
76
+ <IconArrowBackUp class="size-4 stroke-2" aria-hidden="true" />
77
+ {messages.restore}
78
+ </Button>
79
+ {/if}
80
+ {#if showRedo && onRedo}
81
+ <Button variant="ghost" size="sm" onclick={onRedo}>
82
+ <IconHistory class="size-4 stroke-2" aria-hidden="true" />
83
+ {messages.redo}
84
+ </Button>
85
+ {/if}
86
+ </div>
87
+ </div>
@@ -0,0 +1,21 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ export type MessageCheckpointRowMessages = {
3
+ version: string;
4
+ restore: string;
5
+ redo: string;
6
+ restored: string;
7
+ };
8
+ export type MessageCheckpointRowProps = HTMLAttributes<HTMLDivElement> & {
9
+ ref?: HTMLDivElement | null;
10
+ class?: string;
11
+ versionLabel?: string | null;
12
+ showRestore?: boolean;
13
+ showRedo?: boolean;
14
+ restoredToVersion?: string | null;
15
+ messages?: Partial<MessageCheckpointRowMessages>;
16
+ onRestore?: () => void;
17
+ onRedo?: () => void;
18
+ };
19
+ declare const MessageCheckpointRow: import("svelte").Component<MessageCheckpointRowProps, {}, "ref">;
20
+ type MessageCheckpointRow = ReturnType<typeof MessageCheckpointRow>;
21
+ export default MessageCheckpointRow;