@widgetic/design-system 0.5.43 → 0.5.44

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/README.md CHANGED
@@ -416,6 +416,58 @@ A person who attaches three pictures can say what happens with each: type `#` af
416
416
 
417
417
  To see it work run `npm run dev` and open `/showcase/prompt-references` (a tray of made-up files and five boxes: a wide one, a narrow one, one with ghost text, a right-to-left one) or the "With file references" composer on `/showcase/chat`. In a right-to-left box the badge reads as the bidirectional algorithm reads it: `label#`.
418
418
 
419
+ ### Previewing a suggestion in the box (`Composer` `previewText`)
420
+
421
+ A chat that offers ideas (follow-ups under the last reply, starter cards in an empty chat) can show an idea in the box while the pointer rests on it, the way Figma's chat does, instead of a tooltip. The page gives the `Composer` the idea's words in `previewText` when the pointer (or the keyboard) enters the idea, and `null` when it leaves.
422
+
423
+ - **What the box does**: it shows the words greyed, in place of what is typed. What was typed is not touched (the textarea keeps its focus, caret and text, and it is back the moment the preview ends), the send control is greyed, Enter sends nothing while the preview shows, and the grey suggestion after the caret is gone with it. The box grows to the taller of the two texts, up to the same limit as the textarea. A blank or non-text `previewText` is no preview.
424
+ - **What the page does**: it sets `previewText` on enter and focus of the idea, clears it on leave and blur, on a click (the idea then goes into the text for real), and when the idea is taken out of the page (a removed pill never sends a leave). Putting the idea into the text (a click: "after what is already there") is the page's own rule, it is not the box's.
425
+
426
+ ```svelte
427
+ <Composer bind:value previewText={hoveredIdea?.request ?? null} onSend={send} />
428
+ ```
429
+
430
+ To see it run `npm run dev`, open `/showcase/chat` and hover the three ideas under the "With a suggestion previewed" box.
431
+
432
+ ### A box that is off until something changes (`Composer` `disabledLook`)
433
+
434
+ A `disabled` `Composer` fades the whole box to half (`disabledLook="faded"`, the default), the look of a box that is off for a moment. A chat that stays off until something outside it changes (the workspace ran out of AI credits and a notice above the box says so, as in Figma) uses `disabledLook="muted"`: the box keeps its words and takes the grey `bg-muted` ground, the text turns `text-muted-foreground`, and the send, attach and model controls are off as before. The prop does nothing for a box that is not `disabled`.
435
+
436
+ ```svelte
437
+ <Composer bind:value disabled={outOfCredits} disabledLook="muted" onSend={send} />
438
+ ```
439
+
440
+ To see it open `/showcase/chat` and look at the "Disabled, muted" box.
441
+
442
+ ### A notice above the box (`ComposerNotice`)
443
+
444
+ `ComposerNotice` is the tinted, rounded block a chat keeps right above its `Composer` for as long as something is true (the workspace is out of AI credits, as in Figma's own chat): the words, and under them one small filled button (`actionLabel` and `onAction`; no button when either is missing). It is a `role="status"` region on the `brand-subtle` ground (the design system has no blue info token), as wide as the box, and the words wrap inside it. It holds no English: the page gives the words as the children and the label of the button.
445
+
446
+ ```svelte
447
+ <ComposerNotice actionLabel="Manage credits" onAction={openBilling}>
448
+ You're out of AI credits in Design Team. Credits reset Nov 26.
449
+ </ComposerNotice>
450
+ <Composer bind:value disabled disabledLook="muted" />
451
+ ```
452
+
453
+ It does not go away by itself: the page removes it when it is no longer true (`@widgetic/chat` keeps the credits one across reloads and drops it when the reset day comes). Open `/showcase/chat` for the three states ("Composer notice").
454
+
455
+ ### The arrow to the newest message (`ScrollToBottom` `visible`)
456
+
457
+ `ScrollToBottom` stays in the page the whole time and is only moved and faded: it **slides up from the bottom edge while it fades in** when `visible` becomes true, and **slides back down while it fades out** when it becomes false. The list around it never changes size when it comes or goes, a change of mind half way (the person scrolls back down while it is still arriving) turns it around from where it is, and while it is away it is out of the tab order and the accessibility tree (`inert`). People who ask for less motion get no slide and no fade. The page decides `visible` (the person is away from the end of the list) and what `onScroll` does (`@widgetic/chat` glides the list to its end with an ease, it does not jump).
458
+
459
+ ```svelte
460
+ <ScrollToBottom visible={isAwayFromEnd} label="Scroll to latest messages" onScroll={glideToEnd} />
461
+ ```
462
+
463
+ ### An "i" at the end of the message actions (`MessageRatingActions` `onDetails`)
464
+
465
+ The row under an assistant message (copy, regenerate, thumbs) draws a small **"i" at its far end** when the page gives `onDetails`: it is for support and not for the person's own use, which is why it sits away from the buttons that act on the message. Pressing it calls `onDetails`; what it opens (a card with a Support ID, `SupportIdDialog` of `@widgetic/chat`) is the page's. The name of the button is `messages.details` ("Copy debug details"). Without `onDetails` no "i" is drawn, and like the rest of the row it is drawn only when the row has something else to show (words to copy, or a version to rate).
466
+
467
+ ```svelte
468
+ <MessageRatingActions copyText={words} onCopy={copy} onDetails={supportId ? openSupportCard : undefined} messages={{ details: 'Copy debug details' }} />
469
+ ```
470
+
419
471
  ## Troubleshooting
420
472
 
421
473
  ### File Case Sensitivity Issues (macOS/Windows Teams)
@@ -116,6 +116,13 @@
116
116
  placeholder?: string;
117
117
  busy?: boolean;
118
118
  disabled?: boolean;
119
+ /**
120
+ * How a `disabled` box looks. `faded` (the default): the whole box fades to half, the look of a box that is off for a moment.
121
+ * `muted`: the box keeps its words and takes the grey ground of Figma's locked composer, for a chat that is off until
122
+ * something outside it changes (the workspace is out of AI credits) and says why in a notice above the box. It does nothing
123
+ * for a box that is not `disabled`.
124
+ */
125
+ disabledLook?: 'faded' | 'muted';
119
126
  maxLength?: number;
120
127
  allowEmpty?: boolean;
121
128
  assistantLabel?: string;
@@ -152,6 +159,14 @@
152
159
  * becomes a badge (picture, name, X) inside the text. Without it the box is as it was: no menu, no badges, no listeners.
153
160
  */
154
161
  references?: ComposerReferences;
162
+ /**
163
+ * Words to show in the box, greyed, in place of what is typed, while the pointer (or the keyboard) rests on a suggestion
164
+ * elsewhere on the page (Figma's chat does this for its follow-ups): the page sets it when the suggestion is entered and sets
165
+ * it back to `null` when it is left. Only a preview: what was typed is not touched (it is back the moment the preview ends),
166
+ * the send control is greyed and nothing is sent while it shows, and the grey suggestion after the caret is gone with it.
167
+ * Without it (or with `null`, or blank words) the box is as it was.
168
+ */
169
+ previewText?: string | null;
155
170
  /** Bounce + white tooltip on the send control (publish-before-send nudge). */
156
171
  sendAttention?: {
157
172
  bounce: boolean;
@@ -181,6 +196,7 @@
181
196
  composerPrimaryAction,
182
197
  enterKeyAction,
183
198
  isQueueableText,
199
+ previewTextOf,
184
200
  shouldSendOnKeyDown
185
201
  } from './composerLogic.js';
186
202
  import { selectedModelLabel, shouldShowComposerModelMenu } from './composerModelMenuLogic.js';
@@ -220,6 +236,7 @@
220
236
  placeholder = 'Type your message…',
221
237
  busy = $bindable(false),
222
238
  disabled = false,
239
+ disabledLook = 'faded',
223
240
  maxLength,
224
241
  allowEmpty = false,
225
242
  assistantLabel = 'Assistant',
@@ -237,11 +254,16 @@
237
254
  attachments,
238
255
  completion,
239
256
  references,
257
+ previewText = null,
240
258
  sendAttention,
241
259
  ...restProps
242
260
  }: ComposerProps = $props();
243
261
 
244
262
  const messages = $derived({ ...defaultMessages, ...messagesProp });
263
+ // The words shown in place of the typed text while the page previews a suggestion (null: nothing is previewed)
264
+ const preview = $derived(previewTextOf(previewText));
265
+ // A disabled box that keeps its words on a grey ground (Figma's locked composer) instead of fading to half
266
+ const mutedWhenDisabled = $derived(disabledLook === 'muted');
245
267
  const modelMenuVisible = $derived(shouldShowComposerModelMenu(models));
246
268
  const modelMenuLabel = $derived(selectedModelLabel(models, selectedModelId, assistantLabel));
247
269
  let modelMenuOpen = $state(false);
@@ -310,11 +332,12 @@
310
332
 
311
333
  // What the ghost-text action is told. `value` is there so a text the page changes by itself (the box clears after a send) is
312
334
  // noticed and the suggestion goes with it. The ghost stays while the assistant builds (`busy`), and goes while the box is
313
- // disabled and while the `#` menu is open (one popup at a time, and the menu owns the keys).
335
+ // disabled and while the `#` menu is open (one popup at a time, and the menu owns the keys). It also goes while a suggestion of the
336
+ // page is previewed in the box (the typed text is hidden then), and is asked for again when the preview ends.
314
337
  const completionParams = $derived<InlineCompletionParams>({
315
338
  source: completionSource,
316
339
  value,
317
- disabled: disabled || referenceMenuOpen,
340
+ disabled: disabled || referenceMenuOpen || preview !== null,
318
341
  // Written here, in this file, so the class is found where the design system's styles are built.
319
342
  ghostClass: 'text-muted-foreground',
320
343
  debounceMs: completion?.debounceMs,
@@ -416,6 +439,8 @@
416
439
  * Enter on an empty text while an agent works does nothing (Stop is a button).
417
440
  */
418
441
  function handleSend(source: 'control' | 'enter' = 'control') {
442
+ // What the box shows is a preview of something else, not the message: nothing is sent (nor queued, nor saved) until it ends
443
+ if (preview !== null) return;
419
444
  const action = source === 'enter' ? enterKeyAction(primaryAction, onQueue != null) : primaryAction;
420
445
  if (action === 'none') return;
421
446
  if (action === 'stop') {
@@ -481,7 +506,9 @@
481
506
  bind:this={ref}
482
507
  class={cn(
483
508
  'max-w-content rounded-card border-input bg-background flex w-full flex-col gap-2 border p-[11px]',
484
- disabled && 'pointer-events-none opacity-50',
509
+ disabled && 'pointer-events-none',
510
+ disabled && !mutedWhenDisabled && 'opacity-50',
511
+ disabled && mutedWhenDisabled && 'bg-muted',
485
512
  className
486
513
  )}
487
514
  {...restProps}
@@ -500,12 +527,19 @@
500
527
  <div class="flex flex-wrap gap-1.5 overflow-hidden">{@render attachments()}</div>
501
528
  {/if}
502
529
 
503
- <!-- Positioned, so the layer the suggestion is painted on (a sibling of the textarea) is measured against this box. -->
504
- <div class="relative min-h-12 w-full px-1 pt-1">
530
+ <!-- Positioned, so the layer the suggestion is painted on (a sibling of the textarea) is measured against this box. While a
531
+ suggestion of the page is previewed, the box is a grid of one cell where the textarea and the preview lie one over the other, so
532
+ the box grows to the taller of the two. -->
533
+ <div class="relative min-h-12 w-full px-1 pt-1" class:grid={preview !== null}>
505
534
  <textarea
506
535
  bind:this={textareaRef}
507
536
  bind:value
508
- class="text-body text-foreground placeholder:text-muted-foreground block w-full resize-none overflow-y-auto border-0 bg-transparent outline-hidden focus-visible:outline-hidden disabled:cursor-not-allowed"
537
+ class={cn(
538
+ 'text-body placeholder:text-muted-foreground block w-full resize-none overflow-y-auto border-0 bg-transparent outline-hidden focus-visible:outline-hidden disabled:cursor-not-allowed',
539
+ disabled && mutedWhenDisabled ? 'text-muted-foreground' : 'text-foreground'
540
+ )}
541
+ class:col-start-1={preview !== null}
542
+ class:row-start-1={preview !== null}
509
543
  style="min-height: 2.75rem; max-height: 7.5rem;"
510
544
  {placeholder}
511
545
  {disabled}
@@ -522,6 +556,15 @@
522
556
  isComposing = false;
523
557
  }}
524
558
  ></textarea>
559
+ {#if preview !== null}
560
+ <!-- The words of the suggestion the page is previewing, greyed, over the text (which stays where it was: the textarea keeps
561
+ its focus, its caret and its text, and none of it is changed). Opaque, so the badges and the grey suggestion under it
562
+ do not show through. Not read out and not pointed at: it is gone when the pointer leaves the suggestion. -->
563
+ <div
564
+ class="text-body text-muted-foreground bg-background pointer-events-none z-10 col-start-1 row-start-1 max-h-[7.5rem] overflow-hidden whitespace-pre-wrap [overflow-wrap:anywhere]"
565
+ aria-hidden="true"
566
+ data-testid="composer-preview">{preview}</div>
567
+ {/if}
525
568
  {#if overLimit}
526
569
  <p class="text-caption text-destructive mt-1" role="status">{messages.characterLimit}</p>
527
570
  {/if}
@@ -606,7 +649,7 @@
606
649
  sendAttention?.bounce && 'wc-composer-send-bounce'
607
650
  )}
608
651
  label={primaryLabel}
609
- disabled={!sendEnabled}
652
+ disabled={!sendEnabled || preview !== null}
610
653
  onclick={() => handleSend('control')}
611
654
  >
612
655
  {#if primaryAction === 'stop'}
@@ -87,6 +87,13 @@ export type ComposerProps = HTMLAttributes<HTMLDivElement> & {
87
87
  placeholder?: string;
88
88
  busy?: boolean;
89
89
  disabled?: boolean;
90
+ /**
91
+ * How a `disabled` box looks. `faded` (the default): the whole box fades to half, the look of a box that is off for a moment.
92
+ * `muted`: the box keeps its words and takes the grey ground of Figma's locked composer, for a chat that is off until
93
+ * something outside it changes (the workspace is out of AI credits) and says why in a notice above the box. It does nothing
94
+ * for a box that is not `disabled`.
95
+ */
96
+ disabledLook?: 'faded' | 'muted';
90
97
  maxLength?: number;
91
98
  allowEmpty?: boolean;
92
99
  assistantLabel?: string;
@@ -123,6 +130,14 @@ export type ComposerProps = HTMLAttributes<HTMLDivElement> & {
123
130
  * becomes a badge (picture, name, X) inside the text. Without it the box is as it was: no menu, no badges, no listeners.
124
131
  */
125
132
  references?: ComposerReferences;
133
+ /**
134
+ * Words to show in the box, greyed, in place of what is typed, while the pointer (or the keyboard) rests on a suggestion
135
+ * elsewhere on the page (Figma's chat does this for its follow-ups): the page sets it when the suggestion is entered and sets
136
+ * it back to `null` when it is left. Only a preview: what was typed is not touched (it is back the moment the preview ends),
137
+ * the send control is greyed and nothing is sent while it shows, and the grey suggestion after the caret is gone with it.
138
+ * Without it (or with `null`, or blank words) the box is as it was.
139
+ */
140
+ previewText?: string | null;
126
141
  /** Bounce + white tooltip on the send control (publish-before-send nudge). */
127
142
  sendAttention?: {
128
143
  bounce: boolean;
@@ -0,0 +1,56 @@
1
+ <!--
2
+ Figma: none yet (code only). Drawn from the banner Figma's own AI chat puts above its message box when the workspace is out of
3
+ AI credits (seen on 21 Nov 2026): a tinted, rounded block as wide as the message box, the sentence in the body size, and one
4
+ small filled button under it, at the start of the line. `Banner` (shell) is the page-wide row with an icon; this is the stacked
5
+ notice of a chat, which sits right above the `Composer` and stays for as long as it is true.
6
+ 12px of padding on every side and 8px between the words and the button, the radius of `Banner`, the `brand-subtle` ground (the
7
+ design system has no blue "info" token; its light surface is the sage tint).
8
+ -->
9
+ <script lang="ts" module>
10
+ import type { Snippet } from 'svelte';
11
+ import type { HTMLAttributes } from 'svelte/elements';
12
+
13
+ export type ComposerNoticeProps = HTMLAttributes<HTMLDivElement> & {
14
+ ref?: HTMLDivElement | null;
15
+ class?: string;
16
+ /** The words of the notice (plain text: a sentence or two). The design system holds no English: the page gives them. */
17
+ children: Snippet;
18
+ /** The label of the button under the words. No button when it is empty or when there is no `onAction`. */
19
+ actionLabel?: string;
20
+ onAction?: () => void;
21
+ };
22
+ </script>
23
+
24
+ <script lang="ts">
25
+ import { cn } from '../../utils.js';
26
+ import { Button } from '../ui/button/index.js';
27
+
28
+ let {
29
+ ref = $bindable(null),
30
+ class: className,
31
+ children,
32
+ actionLabel = '',
33
+ onAction,
34
+ ...restProps
35
+ }: ComposerNoticeProps = $props();
36
+
37
+ /** Whether the notice has a button (a label and a handler). */
38
+ const hasAction = $derived(Boolean(actionLabel) && typeof onAction === 'function');
39
+ </script>
40
+
41
+ <!-- A status region: a screen reader says the words when the notice appears, and they stay in the reading order above the box. -->
42
+ <div
43
+ bind:this={ref}
44
+ role="status"
45
+ data-testid="composer-notice"
46
+ class={cn(
47
+ 'max-w-content bg-brand-subtle text-body text-foreground flex w-full flex-col items-start gap-2 rounded-xl p-3',
48
+ className
49
+ )}
50
+ {...restProps}
51
+ >
52
+ <div class="min-w-0 [overflow-wrap:anywhere]" data-testid="composer-notice-text">{@render children()}</div>
53
+ {#if hasAction}
54
+ <Button data-testid="composer-notice-action" size="sm" onclick={onAction}>{actionLabel}</Button>
55
+ {/if}
56
+ </div>
@@ -0,0 +1,14 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ export type ComposerNoticeProps = HTMLAttributes<HTMLDivElement> & {
4
+ ref?: HTMLDivElement | null;
5
+ class?: string;
6
+ /** The words of the notice (plain text: a sentence or two). The design system holds no English: the page gives them. */
7
+ children: Snippet;
8
+ /** The label of the button under the words. No button when it is empty or when there is no `onAction`. */
9
+ actionLabel?: string;
10
+ onAction?: () => void;
11
+ };
12
+ declare const ComposerNotice: import("svelte").Component<ComposerNoticeProps, {}, "ref">;
13
+ type ComposerNotice = ReturnType<typeof ComposerNotice>;
14
+ export default ComposerNotice;
@@ -1,5 +1,7 @@
1
1
  <!--
2
2
  Figma: Message actions row (copy, regenerate, thumbs) on assistant turns.
3
+ The "i" button at the far end of the row (`onDetails`) has no frame of its own in our Figma file: it follows the row Figma's own
4
+ assistant draws (copy, thumbs, then an "i" that opens "Copy debug details"), so that a person can hand support the id of the chat.
3
5
  -->
4
6
  <script lang="ts" module>
5
7
  import type { HTMLAttributes } from 'svelte/elements';
@@ -13,6 +15,8 @@
13
15
  rateGroup: string;
14
16
  rateUp: string;
15
17
  rateDown: string;
18
+ /** The name of the "i" button at the far end of the row (its tooltip and what a screen reader says). */
19
+ details: string;
16
20
  };
17
21
 
18
22
  export type MessageRatingActionsProps = HTMLAttributes<HTMLDivElement> & {
@@ -26,6 +30,12 @@
26
30
  onCopy?: () => void | Promise<void>;
27
31
  onRegenerate?: () => void;
28
32
  onRate?: (messageId: string, pressed: VersionThumb) => void;
33
+ /**
34
+ * Draws an "i" button at the far end of the row (away from the buttons that act on the message: it is for support, not for the
35
+ * person's own use). Pressing it calls this; what it opens (the page's dialog with a Support ID) is the page's. Without it no
36
+ * "i" is drawn. Like the rest of the row it is drawn only when the row has something else to show.
37
+ */
38
+ onDetails?: () => void;
29
39
  };
30
40
  </script>
31
41
 
@@ -35,8 +45,10 @@
35
45
  import IconThumbDown from '@tabler/icons-svelte/icons/thumb-down';
36
46
  import IconThumbUp from '@tabler/icons-svelte/icons/thumb-up';
37
47
  import IconCheck from '@tabler/icons-svelte/icons/check';
48
+ import IconInfoCircle from '@tabler/icons-svelte/icons/info-circle';
38
49
  import { cn } from '../../utils.js';
39
50
  import { IconButton } from '../ui/icon-button/index.js';
51
+ import HintTooltip from '../tooltip/HintTooltip.svelte';
40
52
  import {
41
53
  shouldRenderMessageRatingBar,
42
54
  shouldShowCopyAction,
@@ -51,7 +63,8 @@
51
63
  regenerate: 'Regenerate response',
52
64
  rateGroup: 'Rate this version',
53
65
  rateUp: 'Good result',
54
- rateDown: 'Poor result'
66
+ rateDown: 'Poor result',
67
+ details: 'Copy debug details'
55
68
  };
56
69
 
57
70
  let {
@@ -65,6 +78,7 @@
65
78
  onCopy,
66
79
  onRegenerate,
67
80
  onRate,
81
+ onDetails,
68
82
  ...restProps
69
83
  }: MessageRatingActionsProps = $props();
70
84
 
@@ -162,6 +176,29 @@
162
176
  </span>
163
177
  {/if}
164
178
 
179
+ {#if onDetails}
180
+ <!-- Pushed to the far end of the row (`ms-auto` is the end side in both directions): the other buttons are for the message, this
181
+ one is for support, and nothing on it says so but its tooltip, so it has one (the white hint, above the button). -->
182
+ <span class="ms-auto inline-flex items-center">
183
+ <HintTooltip content={messages.details} side="top" align="end" sideOffset={8}>
184
+ {#snippet trigger({ props })}
185
+ <IconButton
186
+ {...props}
187
+ variant="ghost"
188
+ class={quietButtonClass}
189
+ label={messages.details}
190
+ onclick={(event: MouseEvent) => {
191
+ (props.onclick as ((event: MouseEvent) => void) | undefined)?.(event);
192
+ onDetails?.();
193
+ }}
194
+ >
195
+ <IconInfoCircle class="size-4 stroke-2" aria-hidden="true" />
196
+ </IconButton>
197
+ {/snippet}
198
+ </HintTooltip>
199
+ </span>
200
+ {/if}
201
+
165
202
  <span class="sr-only" aria-live="polite">{copied ? messages.copied : ''}</span>
166
203
  </div>
167
204
  {/if}
@@ -8,6 +8,8 @@ export type MessageRatingActionsMessages = {
8
8
  rateGroup: string;
9
9
  rateUp: string;
10
10
  rateDown: string;
11
+ /** The name of the "i" button at the far end of the row (its tooltip and what a screen reader says). */
12
+ details: string;
11
13
  };
12
14
  export type MessageRatingActionsProps = HTMLAttributes<HTMLDivElement> & {
13
15
  ref?: HTMLDivElement | null;
@@ -20,6 +22,12 @@ export type MessageRatingActionsProps = HTMLAttributes<HTMLDivElement> & {
20
22
  onCopy?: () => void | Promise<void>;
21
23
  onRegenerate?: () => void;
22
24
  onRate?: (messageId: string, pressed: VersionThumb) => void;
25
+ /**
26
+ * Draws an "i" button at the far end of the row (away from the buttons that act on the message: it is for support, not for the
27
+ * person's own use). Pressing it calls this; what it opens (the page's dialog with a Support ID) is the page's. Without it no
28
+ * "i" is drawn. Like the rest of the row it is drawn only when the row has something else to show.
29
+ */
30
+ onDetails?: () => void;
23
31
  };
24
32
  declare const MessageRatingActions: import("svelte").Component<MessageRatingActionsProps, {}, "ref">;
25
33
  type MessageRatingActions = ReturnType<typeof MessageRatingActions>;
@@ -1,5 +1,12 @@
1
1
  <!--
2
2
  Figma: Scroll to Bottom (component set 69:79, node 69:79)
3
+
4
+ The arrow slides up from the bottom edge while it fades in, and slides back down while it fades out (owner, 21 Nov 2026: it
5
+ "appears with a slide ... in a fading, and then when it goes back out, it goes back to the bottom, it will slide down and the
6
+ same fading"). It stays in the page the whole time and is only moved and faded, so the list around it never changes size when
7
+ it comes or goes, and a change of mind half way (the person scrolls back down while it is still arriving) turns it around from
8
+ where it is. While it is away it is out of the tab order and out of the accessibility tree (`inert`). People who ask for less
9
+ motion get no slide and no fade.
3
10
  -->
4
11
  <script lang="ts" module>
5
12
  import type { HTMLAttributes } from 'svelte/elements';
@@ -7,6 +14,7 @@
7
14
  export type ScrollToBottomProps = HTMLAttributes<HTMLButtonElement> & {
8
15
  ref?: HTMLButtonElement | null;
9
16
  class?: string;
17
+ /** Whether the arrow is shown. It slides and fades in when this becomes true, and slides and fades out when it becomes false. */
10
18
  visible?: boolean;
11
19
  label?: string;
12
20
  onScroll?: () => void;
@@ -30,10 +38,13 @@
30
38
 
31
39
  <div
32
40
  class={cn(
33
- 'duration-base pointer-events-none transition-opacity',
34
- visible ? 'opacity-100' : 'opacity-0',
41
+ 'duration-base ease-out pointer-events-none transition-[opacity,translate,visibility] motion-reduce:transition-none',
42
+ visible ? 'visible translate-y-0 opacity-100' : 'invisible translate-y-2 opacity-0',
35
43
  className
36
44
  )}
45
+ inert={!visible}
46
+ data-testid="scroll-to-bottom"
47
+ data-visible={visible ? 'true' : 'false'}
37
48
  >
38
49
  <IconButton
39
50
  bind:ref
@@ -2,6 +2,7 @@ import type { HTMLAttributes } from 'svelte/elements';
2
2
  export type ScrollToBottomProps = HTMLAttributes<HTMLButtonElement> & {
3
3
  ref?: HTMLButtonElement | null;
4
4
  class?: string;
5
+ /** Whether the arrow is shown. It slides and fades in when this becomes true, and slides and fades out when it becomes false. */
5
6
  visible?: boolean;
6
7
  label?: string;
7
8
  onScroll?: () => void;
@@ -22,6 +22,12 @@ export type CanSendTextOptions = {
22
22
  };
23
23
  /** Whether the primary send action is allowed (not stop — use `busy` on the component for that). */
24
24
  export declare function canSendText(text: string, options?: CanSendTextOptions): boolean;
25
+ /**
26
+ * The words the box shows in place of what is typed while the pointer (or the keyboard) rests on a suggestion somewhere else on the
27
+ * page: the text trimmed, or `null` when there is nothing to show (blank, or not text at all), so a page can hand over whatever it
28
+ * holds without checking it first.
29
+ */
30
+ export declare function previewTextOf(value: unknown): string | null;
25
31
  /** What the primary control of the composer does at this moment. */
26
32
  export type ComposerPrimaryAction = 'send' | 'queue' | 'stop' | 'confirmEdit';
27
33
  export type ComposerPrimaryState = {
@@ -40,6 +40,17 @@ export function canSendText(text, options = {}) {
40
40
  return false;
41
41
  return true;
42
42
  }
43
+ /**
44
+ * The words the box shows in place of what is typed while the pointer (or the keyboard) rests on a suggestion somewhere else on the
45
+ * page: the text trimmed, or `null` when there is nothing to show (blank, or not text at all), so a page can hand over whatever it
46
+ * holds without checking it first.
47
+ */
48
+ export function previewTextOf(value) {
49
+ if (typeof value !== 'string')
50
+ return null;
51
+ const trimmed = value.trim();
52
+ return trimmed === '' ? null : trimmed;
53
+ }
43
54
  /** Whether the text can be queued or saved as an edit: something is written (a queued message is never empty) and it fits. */
44
55
  export function isQueueableText(text, maxLength) {
45
56
  const trimmed = text.trim();
@@ -10,6 +10,7 @@ export { default as ActivityRow, type ActivityRowProps, type ActivityRowStatus }
10
10
  export { default as OptionRow, type OptionRowProps, type OptionRowSelectionMode } from './OptionRow.svelte';
11
11
  export { default as TaskRow, type TaskRowProps, type TaskRowStatus } from './TaskRow.svelte';
12
12
  export { default as ScrollToBottom, type ScrollToBottomProps } from './ScrollToBottom.svelte';
13
+ export { default as ComposerNotice, type ComposerNoticeProps } from './ComposerNotice.svelte';
13
14
  export { canSendText, clampTextareaHeight, COMPOSER_TEXTAREA_MAX_HEIGHT_PX, COMPOSER_TEXTAREA_MIN_HEIGHT_PX, composerPrimaryAction, enterKeyAction, isQueueableText, shouldSendOnKeyDown, type ComposerPrimaryAction, type ComposerPrimaryState } from './composerLogic.js';
14
15
  export { default as ChatHeader } from './ChatHeader.svelte';
15
16
  export type { ChatHeaderLayout, ChatHeaderMessages } from './ChatHeader.svelte';
@@ -18,6 +18,8 @@ export { default as ActivityRow } from './ActivityRow.svelte';
18
18
  export { default as OptionRow } from './OptionRow.svelte';
19
19
  export { default as TaskRow } from './TaskRow.svelte';
20
20
  export { default as ScrollToBottom } from './ScrollToBottom.svelte';
21
+ // The tinted notice above the message box that stays while it is true (out of AI credits), with an optional button under the words.
22
+ export { default as ComposerNotice } from './ComposerNotice.svelte';
21
23
  export { canSendText, clampTextareaHeight, COMPOSER_TEXTAREA_MAX_HEIGHT_PX, COMPOSER_TEXTAREA_MIN_HEIGHT_PX, composerPrimaryAction, enterKeyAction, isQueueableText, shouldSendOnKeyDown } from './composerLogic.js';
22
24
  // [C2 exports]
23
25
  export { default as ChatHeader } from './ChatHeader.svelte';
@@ -5,7 +5,7 @@ export { default as GenerateLoader } from './GenerateLoader.svelte';
5
5
  export { default as PasswordInput } from './PasswordInput.svelte';
6
6
  export { default as ThumbHashImage } from './ThumbHashImage.svelte';
7
7
  export { default as WScrollArea } from './WScrollArea.svelte';
8
- export { Composer, type ComposerCompletion, type ComposerEditing, type ComposerMessages, type ComposerProps, type ComposerReferenceMessages, type ComposerReferences, type ComposerSendOptions, assignReferenceLabel, genericLabelNumber, isValidReferenceLabel, referenceOccurrences, removeTokensOfLabel, unbadgeTokensWithoutFiles, type CollectedReference, type ReferenceHoverEvent, type ReferenceItem, QueueCard, type QueueCardItem, type QueueCardMessages, type QueueCardProps, queueRowMode, type QueueRowMode, Message, type MessageMessages, type MessageProps, type MessageRole, ChatAlertCard, type ChatAlertCardProps, ActivityRow, type ActivityRowProps, type ActivityRowStatus, OptionRow, type OptionRowProps, type OptionRowSelectionMode, TaskRow, type TaskRowProps, type TaskRowStatus, ScrollToBottom, type ScrollToBottomProps, canSendText, clampTextareaHeight, composerPrimaryAction, enterKeyAction, isQueueableText, shouldSendOnKeyDown, type ComposerPrimaryAction, type ComposerPrimaryState, ChatHeader, PlanCard, QuestionCard, QuestionCardSummary, type QuestionCardSummaryMessages, areAllQuestionsSkipped, canAdvanceQuestion, canStepBack, canStepForward, canSubmitQuestion, collectQuestionSelections, formatQuestionStep, isFirstQuestion, isLastQuestion, isQuestionSkipped, moveFocusedIndex, optionItemRole, primaryQuestionLabel, questionCardTitle, selectionRole, showsQuestionPager, stepQuestionIndex, toggleOption, type QuestionSummaryItem, SuggestionCard, MessageRatingActions, MessageCheckpointRow, shouldShowConsoleButton, shouldShowPinButton, shouldRenderMessageRatingBar, shouldShowCopyAction, shouldShowRatingActions, shouldShowRegenerateAction, thumbIsPressed, type VersionThumb, selectedModelLabel, shouldShowComposerModelMenu, type ComposerModelOption } from './chat';
8
+ export { Composer, type ComposerCompletion, type ComposerEditing, type ComposerMessages, type ComposerProps, type ComposerReferenceMessages, type ComposerReferences, type ComposerSendOptions, assignReferenceLabel, genericLabelNumber, isValidReferenceLabel, referenceOccurrences, removeTokensOfLabel, unbadgeTokensWithoutFiles, type CollectedReference, type ReferenceHoverEvent, type ReferenceItem, QueueCard, type QueueCardItem, type QueueCardMessages, type QueueCardProps, queueRowMode, type QueueRowMode, Message, type MessageMessages, type MessageProps, type MessageRole, ChatAlertCard, type ChatAlertCardProps, ActivityRow, type ActivityRowProps, type ActivityRowStatus, OptionRow, type OptionRowProps, type OptionRowSelectionMode, TaskRow, type TaskRowProps, type TaskRowStatus, ScrollToBottom, type ScrollToBottomProps, ComposerNotice, type ComposerNoticeProps, canSendText, clampTextareaHeight, composerPrimaryAction, enterKeyAction, isQueueableText, shouldSendOnKeyDown, type ComposerPrimaryAction, type ComposerPrimaryState, ChatHeader, PlanCard, QuestionCard, QuestionCardSummary, type QuestionCardSummaryMessages, areAllQuestionsSkipped, canAdvanceQuestion, canStepBack, canStepForward, canSubmitQuestion, collectQuestionSelections, formatQuestionStep, isFirstQuestion, isLastQuestion, isQuestionSkipped, moveFocusedIndex, optionItemRole, primaryQuestionLabel, questionCardTitle, selectionRole, showsQuestionPager, stepQuestionIndex, toggleOption, type QuestionSummaryItem, SuggestionCard, MessageRatingActions, MessageCheckpointRow, shouldShowConsoleButton, shouldShowPinButton, shouldRenderMessageRatingBar, shouldShowCopyAction, shouldShowRatingActions, shouldShowRegenerateAction, thumbIsPressed, type VersionThumb, selectedModelLabel, shouldShowComposerModelMenu, type ComposerModelOption } from './chat';
9
9
  export { ColorPicker, type ColorPickerMessages, type ColorPickerProps, normalizeHex, hexToHsv, hsvToHex, type Hsv } from './color-picker';
10
10
  export { CreatorBar, CanvasBoardStatusChip, type CanvasBoardStatusChipVariant } from './creator';
11
11
  export { default as DebugGrid } from './debug-grid/DebugGrid.svelte';
@@ -6,7 +6,7 @@ export { default as GenerateLoader } from './GenerateLoader.svelte';
6
6
  export { default as PasswordInput } from './PasswordInput.svelte';
7
7
  export { default as ThumbHashImage } from './ThumbHashImage.svelte';
8
8
  export { default as WScrollArea } from './WScrollArea.svelte';
9
- export { Composer, assignReferenceLabel, genericLabelNumber, isValidReferenceLabel, referenceOccurrences, removeTokensOfLabel, unbadgeTokensWithoutFiles, QueueCard, queueRowMode, Message, ChatAlertCard, ActivityRow, OptionRow, TaskRow, ScrollToBottom, canSendText, clampTextareaHeight, composerPrimaryAction, enterKeyAction, isQueueableText, shouldSendOnKeyDown, ChatHeader, PlanCard, QuestionCard, QuestionCardSummary, areAllQuestionsSkipped, canAdvanceQuestion, canStepBack, canStepForward, canSubmitQuestion, collectQuestionSelections, formatQuestionStep, isFirstQuestion, isLastQuestion, isQuestionSkipped, moveFocusedIndex, optionItemRole, primaryQuestionLabel, questionCardTitle, selectionRole, showsQuestionPager, stepQuestionIndex, toggleOption, SuggestionCard, MessageRatingActions, MessageCheckpointRow, shouldShowConsoleButton, shouldShowPinButton, shouldRenderMessageRatingBar, shouldShowCopyAction, shouldShowRatingActions, shouldShowRegenerateAction, thumbIsPressed, selectedModelLabel, shouldShowComposerModelMenu } from './chat';
9
+ export { Composer, assignReferenceLabel, genericLabelNumber, isValidReferenceLabel, referenceOccurrences, removeTokensOfLabel, unbadgeTokensWithoutFiles, QueueCard, queueRowMode, Message, ChatAlertCard, ActivityRow, OptionRow, TaskRow, ScrollToBottom, ComposerNotice, canSendText, clampTextareaHeight, composerPrimaryAction, enterKeyAction, isQueueableText, shouldSendOnKeyDown, ChatHeader, PlanCard, QuestionCard, QuestionCardSummary, areAllQuestionsSkipped, canAdvanceQuestion, canStepBack, canStepForward, canSubmitQuestion, collectQuestionSelections, formatQuestionStep, isFirstQuestion, isLastQuestion, isQuestionSkipped, moveFocusedIndex, optionItemRole, primaryQuestionLabel, questionCardTitle, selectionRole, showsQuestionPager, stepQuestionIndex, toggleOption, SuggestionCard, MessageRatingActions, MessageCheckpointRow, shouldShowConsoleButton, shouldShowPinButton, shouldRenderMessageRatingBar, shouldShowCopyAction, shouldShowRatingActions, shouldShowRegenerateAction, thumbIsPressed, selectedModelLabel, shouldShowComposerModelMenu } from './chat';
10
10
  export { ColorPicker, normalizeHex, hexToHsv, hsvToHex } from './color-picker';
11
11
  export { CreatorBar, CanvasBoardStatusChip } from './creator';
12
12
  export { default as DebugGrid } from './debug-grid/DebugGrid.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/design-system",
3
- "version": "0.5.43",
3
+ "version": "0.5.44",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "svelte": "./dist/index.js",