@widgetic/design-system 0.5.30 → 0.5.32

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 (52) hide show
  1. package/dist/components/EmptyState.svelte +5 -2
  2. package/dist/components/chat/OptionRow.svelte +1 -1
  3. package/dist/components/modals/ActionModal.svelte +10 -9
  4. package/dist/components/modals/BaseModal.svelte +6 -6
  5. package/dist/components/modals/README.md +1 -1
  6. package/dist/components/shell/SettingsDialog.svelte +54 -33
  7. package/dist/components/shell/WidgetRow.svelte +8 -1
  8. package/dist/components/shell/WidgetRow.svelte.d.ts +2 -0
  9. package/dist/components/toast/ToasterModal.svelte +65 -33
  10. package/dist/components/toast/ToasterModal.svelte.d.ts +6 -1
  11. package/dist/components/toast/toastDismissCountdown.d.ts +5 -0
  12. package/dist/components/toast/toastDismissCountdown.js +47 -0
  13. package/dist/components/toast/toastDismissCountdownPayload.d.ts +16 -0
  14. package/dist/components/toast/toastDismissCountdownPayload.js +24 -0
  15. package/dist/components/ui/button/button.svelte +1 -1
  16. package/dist/components/ui/command/command-item.svelte +1 -1
  17. package/dist/components/ui/command/command-link-item.svelte +1 -1
  18. package/dist/components/ui/dialog/DialogLayerSync.svelte +38 -0
  19. package/dist/components/ui/dialog/DialogLayerSync.svelte.d.ts +8 -0
  20. package/dist/components/ui/dialog/dialog-content.svelte +63 -20
  21. package/dist/components/ui/dialog/dialog-content.svelte.d.ts +1 -0
  22. package/dist/components/ui/dialog/dialog-overlay.svelte +24 -20
  23. package/dist/components/ui/dialog/overlay-layer-context.d.ts +8 -0
  24. package/dist/components/ui/dialog/overlay-layer-context.js +1 -0
  25. package/dist/components/ui/drawer/drawer-content.svelte +25 -1
  26. package/dist/components/ui/drawer/drawer-overlay.svelte +32 -5
  27. package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +1 -1
  28. package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +3 -1
  29. package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +1 -1
  30. package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +1 -1
  31. package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +3 -1
  32. package/dist/components/ui/hover-card/hover-card-content.svelte +3 -1
  33. package/dist/components/ui/popover/popover-content.svelte +3 -1
  34. package/dist/components/ui/select/select-content.svelte +3 -1
  35. package/dist/components/ui/slider/slider.svelte +17 -6
  36. package/dist/components/ui/tabs/tabs-trigger.svelte +1 -1
  37. package/dist/components/ui/toggle/toggle.svelte +1 -1
  38. package/dist/components/ui/toggle/toggle.svelte.d.ts +2 -2
  39. package/dist/components/ui/tooltip/tooltip-content.svelte +3 -1
  40. package/dist/styles/fonts.css +4 -33
  41. package/dist/styles/global.css +86 -20
  42. package/dist/styles/tokens.css +6 -10
  43. package/dist/utils/overlayLayerStack.d.ts +54 -0
  44. package/dist/utils/overlayLayerStack.js +89 -0
  45. package/dist/utils/overlayMotion.d.ts +17 -39
  46. package/dist/utils/overlayMotion.js +42 -61
  47. package/dist/utils/toastMotion.d.ts +12 -0
  48. package/dist/utils/toastMotion.js +12 -0
  49. package/package.json +2 -2
  50. package/tailwind.config.ts +4 -11
  51. package/dist/fonts/Cousine/Cousine-Bold.woff2 +0 -0
  52. package/dist/fonts/Cousine/Cousine-Regular.woff2 +0 -0
@@ -72,11 +72,14 @@
72
72
  if (height === '100%') return `min-height: 0; height: 100%; ${extra}`;
73
73
  return `height: ${height}; ${extra}`;
74
74
  });
75
+
76
+ const containerOverflow = $derived(height === 'auto' ? 'overflow-visible' : 'overflow-hidden');
75
77
  </script>
76
78
 
77
79
  <div
78
80
  class={cn(
79
- 'empty-state-container flex min-h-0 w-full items-center justify-center overflow-hidden',
81
+ 'empty-state-container flex min-h-0 w-full items-center justify-center',
82
+ containerOverflow,
80
83
  className
81
84
  )}
82
85
  style={containerStyle}
@@ -95,7 +98,7 @@
95
98
  {/if}
96
99
 
97
100
  <div class="flex w-full min-w-0 flex-col gap-1">
98
- <p class="text-body text-muted-foreground" style={titleStyle}>{message}</p>
101
+ <p class="text-body text-foreground font-medium" style={titleStyle}>{message}</p>
99
102
  {#if description}
100
103
  <p class="text-body text-muted-foreground">{description}</p>
101
104
  {/if}
@@ -41,7 +41,7 @@
41
41
  {disabled}
42
42
  class={cn(
43
43
  'border-border duration-fast hover:bg-accent focus-visible:ring-ring focus-visible:ring-offset-background flex h-9 w-full items-center gap-2 rounded-lg border px-3 py-2 text-start transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',
44
- selected && 'border-primary bg-accent',
44
+ selected && 'border-primary bg-brand-subtle',
45
45
  className
46
46
  )}
47
47
  onclick={() => onSelect?.()}
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  // Svelte imports
3
- import { createEventDispatcher, onMount } from 'svelte';
3
+ import { createEventDispatcher, onDestroy, onMount } from 'svelte';
4
4
  const dispatch = createEventDispatcher();
5
5
 
6
6
  // Local imports
@@ -42,15 +42,20 @@
42
42
  /* INTERNAL STATE */
43
43
  let confirmResult: string = '';
44
44
  let isInitialized = false;
45
+ let isComponentDestroyed = false;
45
46
 
46
47
  // Only initialize once mounted
47
48
  onMount(() => {
48
49
  isInitialized = true;
49
50
  });
50
51
 
52
+ onDestroy(() => {
53
+ isComponentDestroyed = true;
54
+ });
55
+
51
56
  // Initialize modalData with our current props if not provided externally
52
57
  // Only do this when modal is actually open
53
- $: if (isOpen && isInitialized && modalData === null) {
58
+ $: if (!isComponentDestroyed && isOpen && isInitialized && modalData === null) {
54
59
  modalData = {
55
60
  items,
56
61
  title,
@@ -62,7 +67,6 @@
62
67
  };
63
68
  }
64
69
 
65
- // Check if buttons are present
66
70
  $: hasButtons = cancelLabel || confirmLabel;
67
71
 
68
72
  function handleClose(event: Event) {
@@ -72,15 +76,17 @@
72
76
  }
73
77
 
74
78
  async function handleConfirm() {
79
+ if (isComponentDestroyed) return;
75
80
  // call the onConfirm handler
76
81
  let result = await onConfirm();
82
+ if (isComponentDestroyed) return;
77
83
  confirmResult = result || '';
78
84
 
79
85
  // Dispatch a confirmation event with all items
80
86
  dispatch('confirm', { items });
81
87
 
82
88
  // Callers that show an error inside the dialog set closeOnConfirm to false.
83
- if (closeOnConfirm) isOpen = false;
89
+ if (closeOnConfirm && !isComponentDestroyed) isOpen = false;
84
90
  }
85
91
 
86
92
  // Support for restoring modal state
@@ -109,11 +115,6 @@
109
115
  }
110
116
  }
111
117
 
112
- // Only log when modal is actually open
113
- $: if (isOpen && isInitialized && items && items.length > 0 && showLogs) {
114
- // console.log('Items in open modal:', items);
115
- // console.log('First item name:', items[0]?.name);
116
- }
117
118
  </script>
118
119
 
119
120
  <BaseModal
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  // Svelte imports
3
- import { fade, scale } from 'svelte/transition';
3
+ import { fade, fly } from 'svelte/transition';
4
4
  import { createEventDispatcher, onDestroy, onMount, tick } from 'svelte';
5
5
  const dispatch = createEventDispatcher();
6
6
  import {
@@ -27,7 +27,7 @@
27
27
  } from './modalStore';
28
28
  import {
29
29
  overlayBackdropBlurPx,
30
- overlayContentScaleStart,
30
+ overlayContentSlidePx,
31
31
  overlayTransitionDurationMs,
32
32
  overlayTransitionEasing
33
33
  } from '../../utils/overlayMotion.js';
@@ -466,19 +466,19 @@
466
466
  z-index: 2;
467
467
  "
468
468
  bind:offsetHeight={modalHeight}
469
- in:scale|global={reduceMotion
469
+ in:fly|global={reduceMotion
470
470
  ? { duration: 0 }
471
471
  : {
472
472
  duration: transitionDuration,
473
- start: overlayContentScaleStart,
473
+ y: overlayContentSlidePx,
474
474
  opacity: 0,
475
475
  easing
476
476
  }}
477
- out:scale|global={reduceMotion
477
+ out:fly|global={reduceMotion
478
478
  ? { duration: 0 }
479
479
  : {
480
480
  duration: transitionDuration,
481
- start: overlayContentScaleStart,
481
+ y: overlayContentSlidePx,
482
482
  opacity: 0,
483
483
  easing
484
484
  }}
@@ -126,7 +126,7 @@ another language passes its own words and nothing else changes.
126
126
  | `NewItemDialog` | `messages`: `invalidTitle`, `required`, `invalidCharacters`, `tooLong` (`{max}`). The English defaults are built from `itemType` ("Folder name is required"). |
127
127
  | `Breadcrumbs` | `backLabel`, `forwardLabel`, `rootLabel`, `breadcrumbLabel` |
128
128
  | `PDFViewer` | `loadingLabel`, `failedLabel`, `pageLabel` (`{page}`, `{total}`), `previousPageLabel`, `nextPageLabel` |
129
- | `ToasterModal` (`components/toast`) | `containerAriaLabel` (the region that holds the toasts, "Notifications"; the library adds the key that moves focus to it), `closeButtonAriaLabel` ("Close toast"). The title and description of a toast are the words of whoever calls `showToast`. |
129
+ | `ToasterModal` (`components/toast`) | `containerAriaLabel` (the region that holds the toasts, "Notifications"; the library adds the key that moves focus to it), `closeButtonAriaLabel` ("Close toast"). The title and description of a toast are the words of whoever calls `showToast`. Every toast uses the unstyled Widgetic pill (`toast.success` and `showToast` alike). Pointer hover pauses dismiss; leaving the stack or blurring keyboard focus restarts the full duration. |
130
130
 
131
131
  A key of `messages` that is left out keeps its English text. A message can hold the values named next to it in
132
132
  curly braces: `tooLong: 'Der Name darf höchstens {max} Zeichen haben'`.
@@ -31,6 +31,18 @@
31
31
  import SettingsNav from './SettingsNav.svelte';
32
32
  import type { SettingsNavGroup } from './settings-nav-types.js';
33
33
  import { createNestedModalTracker } from './nested-modal-guard.js';
34
+ import { onDestroy, setContext } from 'svelte';
35
+ import { claimOverlayLayerPair } from '../../utils/overlayLayerStack.js';
36
+ import {
37
+ OVERLAY_LAYER_CONTEXT_KEY,
38
+ type OverlayLayerContext
39
+ } from '../ui/dialog/overlay-layer-context.js';
40
+ import DialogLayerSync from '../ui/dialog/DialogLayerSync.svelte';
41
+ import {
42
+ overlayReducedMotionClasses,
43
+ overlayScrimFadeTransition
44
+ } from '../../utils/overlayMotion.js';
45
+ import { fade } from 'svelte/transition';
34
46
 
35
47
  let {
36
48
  open = $bindable(false),
@@ -53,6 +65,22 @@
53
65
 
54
66
  // A modal a pane opens (ActionModal, RenameDialog, ...) is drawn outside this dialog: while one is open, a click or
55
67
  // Escape in it must not close the settings dialog, and the focus trap must let its fields take the focus.
68
+ const overlayLayerContext: OverlayLayerContext = {
69
+ ensureLayer() {
70
+ if (!this.layer) {
71
+ this.layer = claimOverlayLayerPair();
72
+ }
73
+ return this.layer;
74
+ },
75
+ releaseLayer() {
76
+ this.layer?.release();
77
+ this.layer = null;
78
+ },
79
+ layer: null
80
+ };
81
+ setContext(OVERLAY_LAYER_CONTEXT_KEY, overlayLayerContext);
82
+ onDestroy(() => overlayLayerContext.releaseLayer());
83
+
56
84
  const nestedModalTracker = createNestedModalTracker();
57
85
  const nestedModalOpen = $derived($modalState.isOpen);
58
86
  $effect(() => {
@@ -82,17 +110,6 @@
82
110
  );
83
111
  }
84
112
 
85
- // The close button is in the corner of the dialog, above whatever the page under the title shows. While that page is scrolled
86
- // away from the top the button fades out (250 ms, none with reduced motion) and takes neither clicks nor focus (it is inert);
87
- // at the top it comes back. Escape and a click on the scrim still close the dialog while the button is away.
88
- // 1px of tolerance: a page at rest at the top can report a fraction of a pixel on a scaled screen.
89
- const PANE_SCROLLED_AFTER_PX = 1;
90
- let paneScrolled = $state(false);
91
-
92
- function handlePaneScroll(event: Event): void {
93
- paneScrolled = (event.currentTarget as HTMLElement).scrollTop > PANE_SCROLLED_AFTER_PX;
94
- }
95
-
96
113
  // Parent keeps pe-8 (32px). A native bar always sits against the content box, so when the page scrolls we
97
114
  // (1) pull the scroll area into that padding and (2) add matching padding-right so the cards stay on the
98
115
  // pe-8 line and the bar is centred in the leftover space between the cards and the dialog edge.
@@ -130,20 +147,32 @@
130
147
  <!-- The scrim is the shared one of every overlay (muted foreground at 80%, 3px blur), set by the dialog overlay itself -->
131
148
  <Dialog.Overlay />
132
149
  <DialogPrimitive.Content
133
- class={cn(
134
- 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 border-border bg-background duration-base fixed z-50 flex overflow-hidden border',
135
- 'inset-0 h-full max-h-none w-full rounded-none',
136
- // Centred with auto margins, not with a translate: a CSS transform would make this box the containing block
137
- // of every `position: fixed` element inside a pane (a legacy confirm dialog would be drawn, and clipped, inside it).
138
- 'lg:h-settings-modal lg:w-settings-modal lg:rounded-panel lg:m-auto lg:max-h-[calc(100vh-2rem)] lg:max-w-[calc(100vw-2rem)]',
139
- // bits-ui's inline `contain: layout style` wins over a `style` prop, so the override has to be `!important`.
140
- 'contain-none!',
141
- className
142
- )}
150
+ forceMount
143
151
  aria-describedby={description || descriptionSlot ? 'settings-dialog-description' : undefined}
144
152
  trapFocus={!nestedModalOpen}
145
153
  onEscapeKeydown={handleEscapeKeydown}
154
+ class={className}
146
155
  >
156
+ {#snippet child({ props, open })}
157
+ <DialogLayerSync {open} {overlayLayerContext} />
158
+ {#if open}
159
+ <div
160
+ {...props}
161
+ data-widgetic-overlay="dialog-panel"
162
+ style:z-index|important={overlayLayerContext.ensureLayer().scrimZ + 1}
163
+ class={cn(
164
+ 'border-border bg-background fixed flex overflow-hidden border',
165
+ overlayReducedMotionClasses,
166
+ 'inset-0 h-full max-h-none w-full rounded-none',
167
+ // Centred with auto margins, not with a translate: a CSS transform would make this box the containing block
168
+ // of every `position: fixed` element inside a pane (a legacy confirm dialog would be drawn, and clipped, inside it).
169
+ 'lg:h-settings-modal lg:w-settings-modal lg:rounded-panel lg:m-auto lg:max-h-[calc(100vh-2rem)] lg:max-w-[calc(100vw-2rem)]',
170
+ 'contain-none!',
171
+ className
172
+ )}
173
+ in:fade|global={overlayScrimFadeTransition()}
174
+ out:fade|global={overlayScrimFadeTransition()}
175
+ >
147
176
  <div class="flex min-h-0 min-w-0 flex-1 flex-col lg:flex-row">
148
177
  <aside
149
178
  class="border-border bg-sidebar flex w-full shrink-0 flex-col border-b p-3 lg:w-64 lg:border-e lg:border-b-0"
@@ -182,23 +211,12 @@
182
211
  class="settings-dialog-pane-scroll -mt-1.5 -me-1.5 flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto overflow-x-hidden ps-8 pt-1.5 pe-1.5 pb-8"
183
212
  use:overlayScrollbar
184
213
  style={paneScrollStyle}
185
- onscroll={handlePaneScroll}
186
214
  >
187
215
  {@render children()}
188
216
  </div>
189
217
  </div>
190
218
  </div>
191
- <!-- The fade is on a box around the button, so that the button keeps its own quick hover; `inert` takes it out of the
192
- tab order and of what a screen reader reads while it is hidden. -->
193
- <div
194
- class={cn(
195
- 'duration-slow absolute end-2 top-2 transition-opacity motion-reduce:transition-none',
196
- paneScrolled && 'pointer-events-none opacity-0'
197
- )}
198
- inert={paneScrolled || undefined}
199
- data-settings-dialog-close-box
200
- data-scrolled={paneScrolled || undefined}
201
- >
219
+ <div class="absolute end-2 top-2" data-settings-dialog-close-box>
202
220
  <DialogPrimitive.Close
203
221
  class="text-foreground hover:bg-accent duration-fast focus-visible:ring-ring focus-visible:ring-offset-background inline-flex size-8 items-center justify-center rounded-lg transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden"
204
222
  >
@@ -206,6 +224,9 @@
206
224
  <span class="sr-only">{closeLabel}</span>
207
225
  </DialogPrimitive.Close>
208
226
  </div>
227
+ </div>
228
+ {/if}
229
+ {/snippet}
209
230
  </DialogPrimitive.Content>
210
231
  </Dialog.Portal>
211
232
  </Dialog.Root>
@@ -37,6 +37,7 @@
37
37
  meta = '',
38
38
  showBadge = true,
39
39
  badgeLabel = 'Published',
40
+ badgeTone = 'published',
40
41
  selected = false,
41
42
  loading = false,
42
43
  visualState = undefined,
@@ -49,6 +50,8 @@
49
50
  meta?: string;
50
51
  showBadge?: boolean;
51
52
  badgeLabel?: string;
53
+ /** Figma 55:441 — Published uses the green pill; Draft is plain neutral text without a dot. */
54
+ badgeTone?: 'published' | 'draft';
52
55
  selected?: boolean;
53
56
  loading?: boolean;
54
57
  visualState?: WidgetRowVisualState;
@@ -109,7 +112,11 @@
109
112
  </div>
110
113
 
111
114
  {#if showBadge}
112
- <Badge variant="secondary" showDot class="shrink-0 max-sm:hidden">{badgeLabel}</Badge>
115
+ {#if badgeTone === 'draft'}
116
+ <span class="text-caption text-muted-foreground shrink-0 max-sm:hidden">{badgeLabel}</span>
117
+ {:else}
118
+ <Badge variant="secondary" showDot class="shrink-0 max-sm:hidden">{badgeLabel}</Badge>
119
+ {/if}
113
120
  {/if}
114
121
 
115
122
  {#if actions}
@@ -65,6 +65,8 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
65
65
  meta?: string;
66
66
  showBadge?: boolean;
67
67
  badgeLabel?: string;
68
+ /** Figma 55:441 — Published uses the green pill; Draft is plain neutral text without a dot. */
69
+ badgeTone?: 'published' | 'draft';
68
70
  selected?: boolean;
69
71
  loading?: boolean;
70
72
  visualState?: WidgetRowVisualState;
@@ -5,11 +5,14 @@
5
5
  import IconExclamationCircle from '@tabler/icons-svelte/icons/exclamation-circle';
6
6
  import IconInfoCircle from '@tabler/icons-svelte/icons/info-circle';
7
7
  import { toastLookupRoots } from './toasterRoots';
8
+ import { toastEnterDurationMs, toastExitDurationMs, toastMaxWidthClass } from '../../utils/toastMotion.js';
9
+ import {
10
+ holdActiveToastsDuringKeyboardFocus,
11
+ restartDismissCountdownForActiveToasts
12
+ } from './toastDismissCountdown';
8
13
 
9
14
  type ToastTypes = 'success' | 'error' | 'warning' | 'info' | 'loading';
10
15
 
11
- // Icon of each tone: the same glyphs as the Tone variants of the Toast in Figma (135:87).
12
- // `info` is the Default tone of Figma. `loading` keeps the spinner of the library.
13
16
  const toneIcons: Partial<Record<ToastTypes, typeof IconInfoCircle>> = {
14
17
  info: IconInfoCircle,
15
18
  success: IconCircleCheck,
@@ -24,42 +27,46 @@
24
27
  export let element: HTMLElement | null = null;
25
28
 
26
29
  let toastMainClass = 'toast-modal';
27
- let isToastVisible = false;
28
30
 
31
+ /**
32
+ * Show one centered pill toast: a single message line (no separate title/description in the UI).
33
+ * `message` is the sentence users see. Legacy callers may still pass `options.description`; it is
34
+ * only used when `message` is empty, otherwise ignored so the toast stays one line.
35
+ */
29
36
  export function showToast(
30
37
  type: string = 'success',
31
- title: string,
38
+ message: string,
32
39
  options: Record<string, unknown> | null = null
33
40
  ) {
34
- isToastVisible = true;
35
-
36
41
  if (options === null) {
37
42
  options = {};
38
43
  }
39
44
 
40
45
  const duration = (options?.duration as number | undefined) || defaultDuration;
46
+ const descriptionText =
47
+ typeof options.description === 'string' ? options.description.trim() : '';
48
+ const messageText = typeof message === 'string' ? message.trim() : '';
49
+ let line = messageText || descriptionText;
50
+ if (messageText && descriptionText && !messageText.includes(descriptionText)) {
51
+ line = `${messageText} — ${descriptionText}`;
52
+ }
41
53
 
42
- // Every tone has its own icon, the same one as in Figma, so a caller does not swap it.
43
54
  const toneIcon = toneIcons[type as ToastTypes];
44
55
  if (toneIcon) options.icon = toneIcon;
45
56
 
46
- // A type the library does not know is shown as info instead of throwing, and says so once.
57
+ const { description: _ignoredDescription, ...toastOptions } = options;
58
+
47
59
  let toastKey: ToastTypes = type as ToastTypes;
48
60
  if (typeof toast[toastKey] !== 'function') {
49
61
  console.warn(`[showToast] Unknown toast type "${type}", showing it as info.`);
50
62
  toastKey = 'info';
51
63
  }
52
64
 
53
- return toast[toastKey](title, {
54
- ...options,
65
+ return toast[toastKey](line, {
66
+ ...toastOptions,
55
67
  duration,
56
68
  unstyled: true,
57
- onAutoClose: () => {
58
- isToastVisible = false;
59
- },
60
- onDismiss: () => {
61
- isToastVisible = false;
62
- }
69
+ description: undefined
63
70
  });
64
71
  }
65
72
  </script>
@@ -76,41 +83,66 @@
76
83
  onMount(() => registerToasterRoot(rootMarker.getRootNode() as Document | ShadowRoot));
77
84
 
78
85
  const textDirection = useTextDirection();
86
+
87
+ let keyboardFocusWithinToastStack = 0;
88
+
89
+ function handleToasterMouseLeave() {
90
+ // Run after svelte-sonner clears its expanded/pause state so the fresh duration sticks.
91
+ queueMicrotask(() => restartDismissCountdownForActiveToasts(defaultDuration));
92
+ }
93
+
94
+ function handleToasterFocusIn() {
95
+ keyboardFocusWithinToastStack += 1;
96
+ holdActiveToastsDuringKeyboardFocus(defaultDuration);
97
+ }
98
+
99
+ function handleToasterFocusOut() {
100
+ keyboardFocusWithinToastStack = Math.max(0, keyboardFocusWithinToastStack - 1);
101
+ if (keyboardFocusWithinToastStack === 0) {
102
+ queueMicrotask(() => restartDismissCountdownForActiveToasts(defaultDuration));
103
+ }
104
+ }
79
105
  </script>
80
106
 
81
107
  <span hidden bind:this={rootMarker}></span>
82
108
  <Toaster
83
109
  theme="light"
84
110
  dir={$textDirection}
85
- position={$textDirection === 'rtl' ? 'bottom-left' : 'bottom-right'}
111
+ position="top-center"
86
112
  {containerAriaLabel}
87
113
  {closeButtonAriaLabel}
88
114
  closeButton
115
+ onmouseleave={handleToasterMouseLeave}
116
+ onfocusin={handleToasterFocusIn}
117
+ onfocusout={handleToasterFocusOut}
89
118
  toastOptions={{
119
+ duration: defaultDuration,
120
+ unstyled: true,
90
121
  classes: {
91
122
  toast:
92
123
  toastMainClass +
93
- ' !fixed !bottom-5 !end-5 !flex !min-w-[20rem] !max-w-[22.25rem] !items-start !gap-3 !rounded-xl !border !border-border !bg-popover !p-4 !pe-10 !text-popover-foreground !shadow-none [&>[data-icon]]:!mt-0.5 [&>[data-icon]]:!size-4 [&>[data-icon]_svg]:!size-4 [&>[data-icon]_svg]:!stroke-2',
94
- title: toastMainClass + '-title text-body-medium text-foreground',
95
- description: toastMainClass + '-description text-body text-muted-foreground',
124
+ ` !relative !flex !w-max !min-w-0 ${toastMaxWidthClass} !flex-nowrap !items-center !gap-2 !rounded-xl !border !px-4 !py-2.5 !pe-9 !text-sm !font-medium !shadow-none [&>[data-icon]]:!hidden [&>[data-content]]:!min-w-0 [&>[data-content]]:!flex-1 [&>[data-content]]:!truncate`,
125
+ title:
126
+ toastMainClass +
127
+ '-title !min-w-0 !flex-1 !truncate !whitespace-nowrap !text-inherit',
128
+ description: toastMainClass + '-description !hidden',
96
129
  actionButton:
97
- '!h-8 !rounded-lg !border !border-input !bg-background !px-2 !text-label !text-foreground hover:!bg-accent',
130
+ '!h-8 !rounded-lg !border !border-current/30 !bg-transparent !px-2 !text-label !text-inherit hover:!bg-current/15',
98
131
  cancelButton: '',
99
- // The same X as the one of the settings dialog: a plain X, no background, inside the toast at its end and top
100
- // (16px, 2 stroke; its 32px target tints on hover and on the keyboard focus, as the dialog's does).
101
132
  closeButton:
102
133
  toastMainClass +
103
- '-close-button !absolute !end-2 !top-2 !flex !size-8 !items-center !justify-center !rounded-lg !border-0 !bg-transparent !p-0 !text-foreground !transition-colors hover:!bg-accent focus-visible:!bg-accent focus-visible:!outline-hidden [&_svg]:!size-4 [&_svg]:!stroke-2',
104
- // The icon takes the colour of its tone, the Icon modes of Figma: Muted for info (Default), Brand, Warning and Destructive.
105
- info: '[&>[data-icon]]:!text-muted-foreground',
106
- success: '[&>[data-icon]]:!text-brand',
107
- warning: '[&>[data-icon]]:!text-warning',
108
- error: '[&>[data-icon]]:!text-destructive'
134
+ '-close-button !absolute !end-1.5 !top-1/2 !z-10 !-translate-y-1/2 !flex !size-7 !shrink-0 !items-center !justify-center !rounded-full !border-0 !bg-transparent !p-0 !text-inherit !transition-colors hover:!bg-current/20 focus-visible:!bg-current/20 focus-visible:!outline-hidden [&_svg]:!size-3.5 [&_svg]:!stroke-2',
135
+ info: '!border-border !bg-popover !text-popover-foreground',
136
+ success:
137
+ '!border-transparent !bg-toast-green !text-inverse-foreground [&>[data-icon]]:!hidden',
138
+ warning: '!border-transparent !bg-warning !text-primary-foreground [&>[data-icon]]:!hidden',
139
+ error:
140
+ '!border-transparent !bg-destructive !text-destructive-foreground [&>[data-icon]]:!hidden'
109
141
  }
110
142
  }}
111
- expand={false}
112
- visibleToasts={1}
143
+ expand={true}
144
+ visibleToasts={3}
113
145
  offset="1rem"
114
- class={className}
115
- {style}
146
+ class="{className} toast-modal-host"
147
+ style="--width: max-content; --toast-enter-ms: {toastEnterDurationMs}ms; --toast-exit-ms: {toastExitDurationMs}ms;{style}"
116
148
  />
@@ -3,7 +3,12 @@ export { className as class };
3
3
  export declare let style: string;
4
4
  export declare let defaultDuration: number;
5
5
  export declare let element: HTMLElement | null;
6
- export declare function showToast(type: string | undefined, title: string, options?: Record<string, unknown> | null): string | number;
6
+ /**
7
+ * Show one centered pill toast: a single message line (no separate title/description in the UI).
8
+ * `message` is the sentence users see. Legacy callers may still pass `options.description`; it is
9
+ * only used when `message` is empty, otherwise ignored so the toast stays one line.
10
+ */
11
+ export declare function showToast(type: string | undefined, message: string, options?: Record<string, unknown> | null): string | number;
7
12
  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> {
8
13
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
9
14
  $$bindings?: Bindings;
@@ -0,0 +1,5 @@
1
+ export { buildToastRefreshPayload, resolveDismissDurationMs } from './toastDismissCountdownPayload.js';
2
+ /** Tell svelte-sonner to run the full dismiss duration again from zero (not the remaining slice). */
3
+ export declare function restartDismissCountdownForActiveToasts(defaultDurationMs: number): void;
4
+ /** Pause auto-dismiss while keyboard focus is inside the toast stack (pointer hover is handled by svelte-sonner). */
5
+ export declare function holdActiveToastsDuringKeyboardFocus(defaultDurationMs: number): void;
@@ -0,0 +1,47 @@
1
+ import { toast } from '../ui/sonner/index.js';
2
+ import { buildToastRefreshPayload, resolveDismissDurationMs } from './toastDismissCountdownPayload.js';
3
+ export { buildToastRefreshPayload, resolveDismissDurationMs } from './toastDismissCountdownPayload.js';
4
+ /** Last finite dismiss length before a keyboard-hold refresh overwrote duration with Infinity. */
5
+ const finiteDismissMsBeforeKeyboardHold = new Map();
6
+ /**
7
+ * Show a toast again with fresh options, through the presenter of its type when svelte-sonner has one (`toast.success(…)`),
8
+ * else through `toast(…)` with the type in the options. svelte-sonner types `toast` as a callable with named presenters and
9
+ * without an index signature, so the lookup by name goes through `unknown`.
10
+ */
11
+ function presentToastAgain(toastType, title, payload) {
12
+ const presentersByType = toast;
13
+ const presenter = presentersByType[toastType];
14
+ if (typeof presenter === 'function') {
15
+ presenter(title, payload);
16
+ return;
17
+ }
18
+ toast(title, { ...payload, type: toastType });
19
+ }
20
+ /** Tell svelte-sonner to run the full dismiss duration again from zero (not the remaining slice). */
21
+ export function restartDismissCountdownForActiveToasts(defaultDurationMs) {
22
+ for (const activeToast of toast.getActiveToasts()) {
23
+ if (activeToast.type === 'loading')
24
+ continue;
25
+ const title = typeof activeToast.title === 'string' ? activeToast.title : '';
26
+ const stored = finiteDismissMsBeforeKeyboardHold.get(activeToast.id);
27
+ finiteDismissMsBeforeKeyboardHold.delete(activeToast.id);
28
+ const dismissMs = resolveDismissDurationMs(activeToast, defaultDurationMs, stored);
29
+ const payload = buildToastRefreshPayload(activeToast, dismissMs);
30
+ presentToastAgain(activeToast.type ?? 'default', title, payload);
31
+ }
32
+ }
33
+ /** Pause auto-dismiss while keyboard focus is inside the toast stack (pointer hover is handled by svelte-sonner). */
34
+ export function holdActiveToastsDuringKeyboardFocus(defaultDurationMs) {
35
+ for (const activeToast of toast.getActiveToasts()) {
36
+ if (activeToast.type === 'loading')
37
+ continue;
38
+ const title = typeof activeToast.title === 'string' ? activeToast.title : '';
39
+ const finiteMs = resolveDismissDurationMs(activeToast, defaultDurationMs);
40
+ finiteDismissMsBeforeKeyboardHold.set(activeToast.id, finiteMs);
41
+ const payload = {
42
+ ...buildToastRefreshPayload(activeToast, Number.POSITIVE_INFINITY),
43
+ duration: Number.POSITIVE_INFINITY
44
+ };
45
+ presentToastAgain(activeToast.type ?? 'default', title, payload);
46
+ }
47
+ }
@@ -0,0 +1,16 @@
1
+ /** Fields we keep when asking svelte-sonner to refresh a toast's dismiss timer. */
2
+ export type RefreshableToastFields = {
3
+ id: string | number;
4
+ title?: unknown;
5
+ type?: string;
6
+ duration?: number;
7
+ description?: unknown;
8
+ action?: unknown;
9
+ cancel?: unknown;
10
+ icon?: unknown;
11
+ class?: unknown;
12
+ classes?: unknown;
13
+ };
14
+ /** Full dismiss length to use after hover/focus ends (ignores Infinity from a hold refresh). */
15
+ export declare function resolveDismissDurationMs(activeToast: RefreshableToastFields, defaultDurationMs: number, storedFiniteMs?: number): number;
16
+ export declare function buildToastRefreshPayload(activeToast: RefreshableToastFields, dismissDurationMs: number): Record<string, unknown>;
@@ -0,0 +1,24 @@
1
+ /** Full dismiss length to use after hover/focus ends (ignores Infinity from a hold refresh). */
2
+ export function resolveDismissDurationMs(activeToast, defaultDurationMs, storedFiniteMs) {
3
+ if (typeof storedFiniteMs === 'number' && Number.isFinite(storedFiniteMs) && storedFiniteMs > 0) {
4
+ return storedFiniteMs;
5
+ }
6
+ const fromToast = activeToast.duration;
7
+ if (typeof fromToast === 'number' && Number.isFinite(fromToast) && fromToast > 0) {
8
+ return fromToast;
9
+ }
10
+ return defaultDurationMs;
11
+ }
12
+ export function buildToastRefreshPayload(activeToast, dismissDurationMs) {
13
+ return {
14
+ id: activeToast.id,
15
+ duration: dismissDurationMs,
16
+ description: activeToast.description,
17
+ action: activeToast.action,
18
+ cancel: activeToast.cancel,
19
+ icon: activeToast.icon,
20
+ class: activeToast.class,
21
+ classes: activeToast.classes,
22
+ unstyled: true
23
+ };
24
+ }
@@ -22,7 +22,7 @@
22
22
  destructive:
23
23
  "bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:bg-destructive/90",
24
24
  outline:
25
- "border border-input bg-background text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
25
+ "border border-input bg-background text-foreground hover:bg-accent-hover hover:text-foreground focus-visible:bg-accent-hover focus-visible:text-foreground active:bg-accent-hover",
26
26
  secondary:
27
27
  "bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
28
28
  ghost: "text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
@@ -15,7 +15,7 @@
15
15
 
16
16
  <CommandPrimitive.Item
17
17
  class={cn(
18
- "text-body aria-selected:bg-accent aria-selected:text-foreground relative flex h-8 cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
18
+ "text-body data-[selected]:bg-brand-subtle hover:not-data-[selected]:bg-accent relative flex h-8 cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
19
19
  className
20
20
  )}
21
21
  bind:ref
@@ -15,7 +15,7 @@
15
15
 
16
16
  <CommandPrimitive.LinkItem
17
17
  class={cn(
18
- "aria-selected:bg-accent aria-selected:text-accent-foreground relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
18
+ "data-[selected]:bg-brand-subtle hover:not-data-[selected]:bg-accent relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
19
19
  className
20
20
  )}
21
21
  bind:ref