@widgetic/design-system 0.5.31 → 0.5.33

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 (37) hide show
  1. package/dist/components/EmptyState.svelte +5 -2
  2. package/dist/components/modals/ActionModal.svelte +10 -9
  3. package/dist/components/modals/README.md +1 -1
  4. package/dist/components/navigation/Breadcrumbs.svelte +11 -3
  5. package/dist/components/navigation/Breadcrumbs.svelte.d.ts +2 -0
  6. package/dist/components/navigation/types.d.ts +4 -0
  7. package/dist/components/shell/SettingsDialog.svelte +59 -11
  8. package/dist/components/shell/WidgetRow.svelte +8 -1
  9. package/dist/components/shell/WidgetRow.svelte.d.ts +2 -0
  10. package/dist/components/toast/ToasterModal.svelte +54 -10
  11. package/dist/components/toast/ToasterModal.svelte.d.ts +6 -1
  12. package/dist/components/toast/toastDismissCountdown.d.ts +5 -0
  13. package/dist/components/toast/toastDismissCountdown.js +47 -0
  14. package/dist/components/toast/toastDismissCountdownPayload.d.ts +16 -0
  15. package/dist/components/toast/toastDismissCountdownPayload.js +24 -0
  16. package/dist/components/ui/dialog/DialogLayerSync.svelte +38 -0
  17. package/dist/components/ui/dialog/DialogLayerSync.svelte.d.ts +8 -0
  18. package/dist/components/ui/dialog/dialog-content.svelte +63 -20
  19. package/dist/components/ui/dialog/dialog-content.svelte.d.ts +1 -0
  20. package/dist/components/ui/dialog/dialog-overlay.svelte +24 -20
  21. package/dist/components/ui/dialog/overlay-layer-context.d.ts +8 -0
  22. package/dist/components/ui/dialog/overlay-layer-context.js +1 -0
  23. package/dist/components/ui/drawer/drawer-content.svelte +25 -1
  24. package/dist/components/ui/drawer/drawer-overlay.svelte +32 -5
  25. package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +3 -1
  26. package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +3 -1
  27. package/dist/components/ui/hover-card/hover-card-content.svelte +3 -1
  28. package/dist/components/ui/popover/popover-content.svelte +3 -1
  29. package/dist/components/ui/select/select-content.svelte +3 -1
  30. package/dist/components/ui/tooltip/tooltip-content.svelte +3 -1
  31. package/dist/styles/global.css +33 -61
  32. package/dist/styles/tokens.css +19 -7
  33. package/dist/utils/overlayLayerStack.d.ts +54 -0
  34. package/dist/utils/overlayLayerStack.js +89 -0
  35. package/dist/utils/overlayMotion.d.ts +14 -46
  36. package/dist/utils/overlayMotion.js +36 -63
  37. package/package.json +1 -1
@@ -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}
@@ -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
@@ -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'`.
@@ -52,6 +52,9 @@
52
52
  export let onForward: BreadcrumbsProps['onForward'] = () => {};
53
53
  // debug settings
54
54
  export let showDebugVisualizer: boolean = false;
55
+ /** When true, ancestor crumbs are valid folder drop targets for the file browser. */
56
+ export let enableFolderDropTargets: boolean = false;
57
+ export let rootDropTargetId: string = 'root';
55
58
 
56
59
  // A name a visitor wrote keeps a direction of its own on a right to left screen (a Latin folder name reads left to
57
60
  // right inside it); on a left to right screen no attribute is written and nothing changes.
@@ -302,8 +305,9 @@
302
305
  <span
303
306
  role="link"
304
307
  tabindex="0"
305
- class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer whitespace-nowrap transition-colors duration-fast hover:underline"
308
+ class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer whitespace-nowrap rounded-md px-1 transition-all duration-fast hover:underline data-[folder-drop-hover=true]:bg-accent data-[folder-drop-hover=true]:text-foreground data-[folder-drop-hover=true]:ring-2 data-[folder-drop-hover=true]:ring-brand"
306
309
  class:opacity-50={isLoading}
310
+ data-folder-drop-target={enableFolderDropTargets ? rootDropTargetId : undefined}
307
311
  style="pointer-events: {isLoading ? 'none' : 'auto'};"
308
312
  on:click={(e) => handleClick(e, -1)}
309
313
  on:keydown={(e) => handleKeyDown(e, -1)}
@@ -357,8 +361,11 @@
357
361
  dir={nameDirection}
358
362
  role="link"
359
363
  tabindex="0"
360
- class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer transition-colors duration-fast hover:underline"
364
+ class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer rounded-md px-1 transition-all duration-fast hover:underline data-[folder-drop-hover=true]:bg-accent data-[folder-drop-hover=true]:text-foreground data-[folder-drop-hover=true]:ring-2 data-[folder-drop-hover=true]:ring-brand"
361
365
  class:opacity-50={isLoading}
366
+ data-folder-drop-target={enableFolderDropTargets
367
+ ? currentPath[currentPath.length - itemsToShow + 1 + index]
368
+ : undefined}
362
369
  style="pointer-events: {isLoading ? 'none' : 'auto'};"
363
370
  on:click={(e) => handleClick(e, currentPath.length - itemsToShow + 1 + index)}
364
371
  on:keydown={(e) =>
@@ -383,8 +390,9 @@
383
390
  dir={nameDirection}
384
391
  role="link"
385
392
  tabindex="0"
386
- class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer transition-colors duration-fast hover:underline"
393
+ class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer rounded-md px-1 transition-all duration-fast hover:underline data-[folder-drop-hover=true]:bg-accent data-[folder-drop-hover=true]:text-foreground data-[folder-drop-hover=true]:ring-2 data-[folder-drop-hover=true]:ring-brand"
387
394
  class:opacity-50={isLoading}
395
+ data-folder-drop-target={enableFolderDropTargets ? currentPath[index] : undefined}
388
396
  style="pointer-events: {isLoading ? 'none' : 'auto'};"
389
397
  on:click={(e) => handleClick(e, index)}
390
398
  on:keydown={(e) => handleKeyDown(e, index)}
@@ -33,6 +33,8 @@ declare const Breadcrumbs: $$__sveltets_2_IsomorphicComponent<{
33
33
  onBack?: BreadcrumbsProps["onBack"];
34
34
  onForward?: BreadcrumbsProps["onForward"];
35
35
  showDebugVisualizer?: boolean;
36
+ /** When true, ancestor crumbs are valid folder drop targets for the file browser. */ enableFolderDropTargets?: boolean;
37
+ rootDropTargetId?: string;
36
38
  }, {
37
39
  [evt: string]: CustomEvent<any>;
38
40
  }, {}, {}, string>;
@@ -19,4 +19,8 @@ export interface BreadcrumbsProps {
19
19
  breadcrumbLabel?: string;
20
20
  /** Figma Crumbs Size=Compact: Heading/Section text and a 4px gap (a narrow header). Default: false (Size=Page). */
21
21
  compact?: boolean;
22
+ /** When true, ancestor crumbs accept file-browser drag-to-folder drops (`data-folder-drop-target`). */
23
+ enableFolderDropTargets?: boolean;
24
+ /** Folder id for the root crumb drop target (defaults to `root`). */
25
+ rootDropTargetId?: string;
22
26
  }
@@ -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(() => {
@@ -86,6 +114,8 @@
86
114
  // (1) pull the scroll area into that padding and (2) add matching padding-right so the cards stay on the
87
115
  // pe-8 line and the bar is centred in the leftover space between the cards and the dialog edge.
88
116
  const PANE_RIGHT_PADDING_PX = 32;
117
+ /** Moves the scroll rail toward the dialog edge while the content line stays on pe-8. */
118
+ const SCROLLBAR_SHIFT_TOWARD_EDGE_PX = 8;
89
119
  let paneScrollStyle = $state('');
90
120
 
91
121
  function overlayScrollbar(node: HTMLElement) {
@@ -97,7 +127,10 @@
97
127
  }
98
128
  // Read the real bar width (often ~14px in Chromium, 8px when thin styles apply).
99
129
  const barWidth = Math.max(node.offsetWidth - node.clientWidth, 8);
100
- const outerGap = Math.max((PANE_RIGHT_PADDING_PX - barWidth) / 2, 0);
130
+ const outerGap = Math.max(
131
+ (PANE_RIGHT_PADDING_PX - barWidth) / 2 - SCROLLBAR_SHIFT_TOWARD_EDGE_PX,
132
+ 0
133
+ );
101
134
  const pull = PANE_RIGHT_PADDING_PX - outerGap;
102
135
  // End side, not the right: the bar sits at the inline end of the page, so a dialog read right to left mirrors it
103
136
  // (tests/rtl/sourcePlacement.test.ts fails on a physical side). Left to right, this is margin-right/padding-right.
@@ -119,20 +152,32 @@
119
152
  <!-- The scrim is the shared one of every overlay (muted foreground at 80%, 3px blur), set by the dialog overlay itself -->
120
153
  <Dialog.Overlay />
121
154
  <DialogPrimitive.Content
122
- class={cn(
123
- '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',
124
- 'inset-0 h-full max-h-none w-full rounded-none',
125
- // Centred with auto margins, not with a translate: a CSS transform would make this box the containing block
126
- // of every `position: fixed` element inside a pane (a legacy confirm dialog would be drawn, and clipped, inside it).
127
- '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)]',
128
- // bits-ui's inline `contain: layout style` wins over a `style` prop, so the override has to be `!important`.
129
- 'contain-none!',
130
- className
131
- )}
155
+ forceMount
132
156
  aria-describedby={description || descriptionSlot ? 'settings-dialog-description' : undefined}
133
157
  trapFocus={!nestedModalOpen}
134
158
  onEscapeKeydown={handleEscapeKeydown}
159
+ class={className}
135
160
  >
161
+ {#snippet child({ props, open })}
162
+ <DialogLayerSync {open} {overlayLayerContext} />
163
+ {#if open}
164
+ <div
165
+ {...props}
166
+ data-widgetic-overlay="dialog-panel"
167
+ style:z-index|important={overlayLayerContext.ensureLayer().scrimZ + 1}
168
+ class={cn(
169
+ 'border-border bg-background fixed flex overflow-hidden border',
170
+ overlayReducedMotionClasses,
171
+ 'inset-0 h-full max-h-none w-full rounded-none',
172
+ // Centred with auto margins, not with a translate: a CSS transform would make this box the containing block
173
+ // of every `position: fixed` element inside a pane (a legacy confirm dialog would be drawn, and clipped, inside it).
174
+ '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)]',
175
+ 'contain-none!',
176
+ className
177
+ )}
178
+ in:fade|global={overlayScrimFadeTransition()}
179
+ out:fade|global={overlayScrimFadeTransition()}
180
+ >
136
181
  <div class="flex min-h-0 min-w-0 flex-1 flex-col lg:flex-row">
137
182
  <aside
138
183
  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"
@@ -184,6 +229,9 @@
184
229
  <span class="sr-only">{closeLabel}</span>
185
230
  </DialogPrimitive.Close>
186
231
  </div>
232
+ </div>
233
+ {/if}
234
+ {/snippet}
187
235
  </DialogPrimitive.Content>
188
236
  </Dialog.Portal>
189
237
  </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,7 +5,11 @@
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 } from '../../utils/toastMotion.js';
8
+ import { toastEnterDurationMs, toastExitDurationMs, toastMaxWidthClass } from '../../utils/toastMotion.js';
9
+ import {
10
+ holdActiveToastsDuringKeyboardFocus,
11
+ restartDismissCountdownForActiveToasts
12
+ } from './toastDismissCountdown';
9
13
 
10
14
  type ToastTypes = 'success' | 'error' | 'warning' | 'info' | 'loading';
11
15
 
@@ -24,9 +28,14 @@
24
28
 
25
29
  let toastMainClass = 'toast-modal';
26
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
+ */
27
36
  export function showToast(
28
37
  type: string = 'success',
29
- title: string,
38
+ message: string,
30
39
  options: Record<string, unknown> | null = null
31
40
  ) {
32
41
  if (options === null) {
@@ -34,20 +43,30 @@
34
43
  }
35
44
 
36
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
+ }
37
53
 
38
54
  const toneIcon = toneIcons[type as ToastTypes];
39
55
  if (toneIcon) options.icon = toneIcon;
40
56
 
57
+ const { description: _ignoredDescription, ...toastOptions } = options;
58
+
41
59
  let toastKey: ToastTypes = type as ToastTypes;
42
60
  if (typeof toast[toastKey] !== 'function') {
43
61
  console.warn(`[showToast] Unknown toast type "${type}", showing it as info.`);
44
62
  toastKey = 'info';
45
63
  }
46
64
 
47
- return toast[toastKey](title, {
48
- ...options,
65
+ return toast[toastKey](line, {
66
+ ...toastOptions,
49
67
  duration,
50
- unstyled: true
68
+ unstyled: true,
69
+ description: undefined
51
70
  });
52
71
  }
53
72
  </script>
@@ -64,6 +83,25 @@
64
83
  onMount(() => registerToasterRoot(rootMarker.getRootNode() as Document | ShadowRoot));
65
84
 
66
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
+ }
67
105
  </script>
68
106
 
69
107
  <span hidden bind:this={rootMarker}></span>
@@ -74,20 +112,26 @@
74
112
  {containerAriaLabel}
75
113
  {closeButtonAriaLabel}
76
114
  closeButton
115
+ onmouseleave={handleToasterMouseLeave}
116
+ onfocusin={handleToasterFocusIn}
117
+ onfocusout={handleToasterFocusOut}
77
118
  toastOptions={{
78
119
  duration: defaultDuration,
120
+ unstyled: true,
79
121
  classes: {
80
122
  toast:
81
123
  toastMainClass +
82
- ' !flex !min-w-0 !max-w-[420px] !flex-wrap !items-center !gap-2 !rounded-xl !border !px-4 !py-2.5 !pe-9 !text-sm !font-medium !shadow-none [&>[data-icon]]:!hidden',
83
- title: toastMainClass + '-title !text-inherit',
84
- description: toastMainClass + '-description !text-inherit/90 !text-sm',
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',
85
129
  actionButton:
86
130
  '!h-8 !rounded-lg !border !border-current/30 !bg-transparent !px-2 !text-label !text-inherit hover:!bg-current/15',
87
131
  cancelButton: '',
88
132
  closeButton:
89
133
  toastMainClass +
90
- '-close-button !absolute !end-1.5 !top-1/2 !-translate-y-1/2 !flex !size-7 !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',
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',
91
135
  info: '!border-border !bg-popover !text-popover-foreground',
92
136
  success:
93
137
  '!border-transparent !bg-toast-green !text-inverse-foreground [&>[data-icon]]:!hidden',
@@ -100,5 +144,5 @@
100
144
  visibleToasts={3}
101
145
  offset="1rem"
102
146
  class="{className} toast-modal-host"
103
- style="--toast-enter-ms: {toastEnterDurationMs}ms; --toast-exit-ms: {toastExitDurationMs}ms;{style}"
147
+ style="--width: max-content; --toast-enter-ms: {toastEnterDurationMs}ms; --toast-exit-ms: {toastExitDurationMs}ms;{style}"
104
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
+ }
@@ -0,0 +1,38 @@
1
+ <script lang="ts">
2
+ import { onDestroy } from 'svelte';
3
+ import type { OverlayLayerContext } from './overlay-layer-context.js';
4
+ import { overlayTransitionDurationMs } from '../../../utils/overlayMotion.js';
5
+
6
+ let {
7
+ open,
8
+ overlayLayerContext
9
+ }: { open: boolean; overlayLayerContext: OverlayLayerContext } = $props();
10
+
11
+ let releaseTimer: ReturnType<typeof setTimeout> | undefined;
12
+
13
+ const isVitest =
14
+ typeof process !== 'undefined' && (process.env.VITEST === 'true' || process.env.NODE_ENV === 'test');
15
+
16
+ $effect(() => {
17
+ if (open) {
18
+ if (releaseTimer !== undefined) {
19
+ clearTimeout(releaseTimer);
20
+ releaseTimer = undefined;
21
+ }
22
+ overlayLayerContext.ensureLayer();
23
+ return;
24
+ }
25
+ if (overlayLayerContext.layer) {
26
+ const delay = isVitest ? 0 : overlayTransitionDurationMs + 32;
27
+ releaseTimer = setTimeout(() => {
28
+ overlayLayerContext.releaseLayer();
29
+ releaseTimer = undefined;
30
+ }, delay);
31
+ }
32
+ });
33
+
34
+ onDestroy(() => {
35
+ if (releaseTimer !== undefined) clearTimeout(releaseTimer);
36
+ overlayLayerContext.releaseLayer();
37
+ });
38
+ </script>
@@ -0,0 +1,8 @@
1
+ import type { OverlayLayerContext } from './overlay-layer-context.js';
2
+ type $$ComponentProps = {
3
+ open: boolean;
4
+ overlayLayerContext: OverlayLayerContext;
5
+ };
6
+ declare const DialogLayerSync: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type DialogLayerSync = ReturnType<typeof DialogLayerSync>;
8
+ export default DialogLayerSync;