@widgetic/design-system 0.5.26 → 0.5.28

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 (41) hide show
  1. package/dist/components/CopyableHeader.svelte +29 -10
  2. package/dist/components/CopyableHeader.svelte.d.ts +3 -0
  3. package/dist/components/EmptyState.svelte +13 -3
  4. package/dist/components/modals/BaseModal.svelte +133 -11
  5. package/dist/components/modals/BaseModal.svelte.d.ts +1 -0
  6. package/dist/components/modals/NewItemDialog.svelte +2 -0
  7. package/dist/components/shad-editor/custom/Extentions/SearchAndReplace.js +0 -1
  8. package/dist/components/shad-editor/custom/utils.d.ts +1 -1
  9. package/dist/components/shad-editor/custom/utils.js +0 -1
  10. package/dist/components/shell/NavRow.svelte +5 -4
  11. package/dist/components/shell/NavRow.svelte.d.ts +3 -3
  12. package/dist/components/ui/accordion/accordion-content.svelte +5 -1
  13. package/dist/components/ui/accordion/accordion-item.svelte +2 -1
  14. package/dist/components/ui/accordion/accordion-trigger.svelte +38 -0
  15. package/dist/components/ui/button/button.svelte +1 -1
  16. package/dist/components/ui/button/button.svelte.d.ts +3 -3
  17. package/dist/components/ui/calendar/calendar.svelte.d.ts +1 -1
  18. package/dist/components/ui/checkbox/checkbox.svelte +1 -1
  19. package/dist/components/ui/dialog/dialog-overlay.svelte +8 -1
  20. package/dist/components/ui/icon-button/icon-button.svelte +1 -1
  21. package/dist/components/ui/icon-button/icon-button.svelte.d.ts +2 -2
  22. package/dist/components/ui/input-otp/input-otp-slot.svelte.d.ts +1 -1
  23. package/dist/components/ui/radio-group/radio-group-item.svelte +1 -1
  24. package/dist/components/ui/range-calendar/range-calendar.svelte.d.ts +1 -1
  25. package/dist/components/ui/select/select-content.svelte +2 -2
  26. package/dist/components/ui/select/select-scroll-down-button.svelte +1 -1
  27. package/dist/components/ui/select/select-scroll-up-button.svelte +1 -1
  28. package/dist/components/ui/select/select-trigger.svelte +1 -1
  29. package/dist/components/ui/stepper-button/stepper-button.svelte +1 -1
  30. package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
  31. package/dist/components/widget-system/Moveable.svelte +24 -21
  32. package/dist/styles/tokens.css +60 -1
  33. package/dist/utils/isEditableEventTarget.d.ts +5 -0
  34. package/dist/utils/isEditableEventTarget.js +25 -0
  35. package/dist/utils/modalFocusTrap.d.ts +28 -0
  36. package/dist/utils/modalFocusTrap.js +135 -0
  37. package/dist/utils/overlayMotion.d.ts +6 -0
  38. package/dist/utils/overlayMotion.js +7 -0
  39. package/dist/utils/overlayStacking.d.ts +47 -0
  40. package/dist/utils/overlayStacking.js +63 -0
  41. package/package.json +1 -1
@@ -22,6 +22,7 @@
22
22
  <script lang="ts">
23
23
  import { createEventDispatcher, onDestroy } from 'svelte';
24
24
  import { toast, Button, Tooltip, Portal, IconButton, Link, Skeleton } from './';
25
+ import type { ButtonVariant } from './ui/button/index.js';
25
26
  import { cn } from '../utils.js';
26
27
  import { IconCopy, IconCheck, IconAlertTriangle } from '@tabler/icons-svelte';
27
28
  import { sideAtStart, useTextDirection } from './textDirection.js';
@@ -43,6 +44,8 @@
43
44
  export let monospaceContent = true;
44
45
  export let showStandaloneCopyButton = false;
45
46
  export let standaloneCopyButtonText = '';
47
+ /** Style of the labelled copy button; `secondary` when a primary action sits next to the header (a dialog's own confirm button). */
48
+ export let standaloneCopyButtonVariant: ButtonVariant = 'default';
46
49
  export let copiedTitle = 'Copied to clipboard';
47
50
  export let copiedDescription = 'Content copied successfully.';
48
51
  export let copyFailedTitle = 'Copy failed';
@@ -56,6 +59,8 @@
56
59
  export let loading = false;
57
60
  export let errorTitle = '';
58
61
  export let errorDetail = '';
62
+ /** Tailwind gap class between the title row and the code card (`gap-4` = 16px). */
63
+ export let titleToContentGapClass = 'gap-4';
59
64
 
60
65
  let showCopyTooltip = false;
61
66
  let tooltipDebounce = false;
@@ -64,6 +69,7 @@
64
69
  let copied = false;
65
70
  let copiedTimeout: ReturnType<typeof setTimeout> | undefined;
66
71
  let isToastVisible = false;
72
+ let copyStatusMessage = '';
67
73
 
68
74
  $: showHelpRow = showHelp && !!helpUrl && (!!helpPrompt || !!helpText);
69
75
 
@@ -95,9 +101,11 @@
95
101
  try {
96
102
  await navigator.clipboard.writeText(content);
97
103
  copied = true;
104
+ copyStatusMessage = copiedTitle;
98
105
  if (copiedTimeout) clearTimeout(copiedTimeout);
99
106
  copiedTimeout = setTimeout(() => {
100
107
  copied = false;
108
+ copyStatusMessage = '';
101
109
  }, 2000);
102
110
  if (showInternalToast) {
103
111
  showToast('success', copiedTitle, {
@@ -119,7 +127,12 @@
119
127
  function handleSnippetClick(event: MouseEvent) {
120
128
  if (!contentElement || isSelectingSnippet) return;
121
129
  const selection = window.getSelection();
122
- if (selection && !selection.isCollapsed && selection.anchorNode && contentElement.contains(selection.anchorNode)) {
130
+ if (
131
+ selection &&
132
+ !selection.isCollapsed &&
133
+ selection.anchorNode &&
134
+ contentElement.contains(selection.anchorNode)
135
+ ) {
123
136
  return;
124
137
  }
125
138
  event.preventDefault();
@@ -158,7 +171,10 @@
158
171
  </script>
159
172
 
160
173
  <!-- `min-w-0` on the root and on the title row: a `truncate` title has its whole text as min-content, so inside a grid or flex parent (a dialog) the row would push the copy button out of the parent instead of cutting the title. -->
161
- <div class={cn('copyable-header flex w-full min-w-0 flex-col gap-4', className)} {style}>
174
+ <div
175
+ class={cn('copyable-header flex w-full min-w-0 flex-col', titleToContentGapClass, className)}
176
+ {style}
177
+ >
162
178
  <!-- Title row: section label + copy control (Figma 32px). -->
163
179
  <div class={cn('flex h-8 min-w-0 items-center justify-between gap-3', headerBackgroundColor)}>
164
180
  <div class={cn('text-heading-section text-foreground min-w-0 truncate', headerTextClass)}>
@@ -172,7 +188,7 @@
172
188
  {#snippet child({ props }: TriggerChildProps)}
173
189
  <Button
174
190
  {...props}
175
- variant="default"
191
+ variant={standaloneCopyButtonVariant}
176
192
  class={cn(buttonClass, props.class)}
177
193
  onclick={handleCopyButtonClick}
178
194
  onmouseenter={() => {
@@ -213,8 +229,9 @@
213
229
  {#snippet child({ props }: TriggerChildProps)}
214
230
  <IconButton
215
231
  {...props}
216
- variant={copied ? 'accent' : 'ghost'}
217
- label={standaloneCopyButtonText || 'Copy'}
232
+ variant="ghost"
233
+ label={copied ? copiedTitle : standaloneCopyButtonText || 'Copy'}
234
+ aria-live="polite"
218
235
  class={cn(headerBackgroundColor, props.class)}
219
236
  onclick={handleCopyButtonClick}
220
237
  onmouseenter={() => {
@@ -229,9 +246,10 @@
229
246
  }}
230
247
  >
231
248
  {#if copied}
232
- <IconCheck class="size-4 stroke-2" />
249
+ <!-- The green of the success toast icon (`text-brand`); there is no `text-success` utility in the theme. -->
250
+ <IconCheck class="text-brand size-4 stroke-2" aria-hidden="true" />
233
251
  {:else}
234
- <IconCopy class="text-muted-foreground size-4 stroke-2" />
252
+ <IconCopy class="text-muted-foreground size-4 stroke-2" aria-hidden="true" />
235
253
  {/if}
236
254
  </IconButton>
237
255
  {/snippet}
@@ -247,11 +265,12 @@
247
265
  </Tooltip.Provider>
248
266
  {/if}
249
267
  </div>
268
+ <span class="sr-only" aria-live="polite">{copyStatusMessage}</span>
250
269
 
251
270
  <!-- Code card: accent surface; loading skeleton, error, or selectable snippet. -->
252
271
  <div
253
272
  class={cn(
254
- 'embed-code-surface bg-accent flex flex-col gap-2 rounded-xl p-3 transition-colors duration-fast hover:bg-accent-hover',
273
+ 'embed-code-surface bg-accent duration-fast hover:bg-accent-hover flex flex-col gap-2 rounded-xl p-3 transition-colors',
255
274
  contentBorderColor && 'border-border border'
256
275
  )}
257
276
  style={contentBorderColor && !contentBorderColor.startsWith('border')
@@ -279,8 +298,8 @@
279
298
  <div
280
299
  bind:this={contentElement}
281
300
  class={cn(
282
- // Three lines of the snippet are visible (`3lh` follows the line height of the text style); the rest scrolls inside the card.
283
- 'embed-code-snippet text-code text-foreground max-h-[3lh] w-full cursor-text overflow-y-auto text-start break-all whitespace-pre-wrap',
301
+ // Three lines of soft-wrapped snippet are visible (`3lh` follows the line height); extra lines scroll vertically inside the card.
302
+ 'embed-code-snippet text-code text-foreground max-h-[3lh] w-full min-w-0 cursor-text overflow-x-hidden overflow-y-auto text-start [overflow-wrap:anywhere] break-all whitespace-pre-wrap',
284
303
  monospaceContent ? '' : 'text-body'
285
304
  )}
286
305
  tabindex="0"
@@ -1,3 +1,4 @@
1
+ import type { ButtonVariant } from './ui/button/index.js';
1
2
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
3
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
4
  $$bindings?: Bindings;
@@ -24,6 +25,7 @@ declare const CopyableHeader: $$__sveltets_2_IsomorphicComponent<{
24
25
  monospaceContent?: boolean;
25
26
  showStandaloneCopyButton?: boolean;
26
27
  standaloneCopyButtonText?: string;
28
+ /** Style of the labelled copy button; `secondary` when a primary action sits next to the header (a dialog's own confirm button). */ standaloneCopyButtonVariant?: ButtonVariant;
27
29
  copiedTitle?: string;
28
30
  copiedDescription?: string;
29
31
  copyFailedTitle?: string;
@@ -37,6 +39,7 @@ declare const CopyableHeader: $$__sveltets_2_IsomorphicComponent<{
37
39
  loading?: boolean;
38
40
  errorTitle?: string;
39
41
  errorDetail?: string;
42
+ /** Tailwind gap class between the title row and the code card (`gap-4` = 16px). */ titleToContentGapClass?: string;
40
43
  }, {
41
44
  copy: CustomEvent<any>;
42
45
  copyError: CustomEvent<any>;
@@ -1,6 +1,9 @@
1
1
  <!--
2
2
  * EmptyState — Figma: Empty State (component set 54:71, node 54:71).
3
3
  * Centered empty view with icon tile, title, optional description, and actions.
4
+ *
5
+ * In a pane below a header, pass `class="min-h-0 flex-1"`, `height="auto"` or `height="100%"`, and put the empty state in a
6
+ * flex column parent so it grows into the remaining space and keeps its content centered.
4
7
  -->
5
8
  <script lang="ts">
6
9
  import { onMount } from 'svelte';
@@ -62,14 +65,21 @@
62
65
 
63
66
  const titleStyle = $derived(textColor ? `color: ${textColor}` : undefined);
64
67
  const iconStyle = $derived(iconColor ? `color: ${iconColor}` : undefined);
68
+
69
+ const containerStyle = $derived.by(() => {
70
+ const extra = style ? `${style};` : '';
71
+ if (height === 'auto') return extra || undefined;
72
+ if (height === '100%') return `min-height: 0; height: 100%; ${extra}`;
73
+ return `height: ${height}; ${extra}`;
74
+ });
65
75
  </script>
66
76
 
67
77
  <div
68
78
  class={cn(
69
- 'empty-state-container flex w-full items-center justify-center overflow-hidden',
79
+ 'empty-state-container flex min-h-0 w-full items-center justify-center overflow-hidden',
70
80
  className
71
81
  )}
72
- style="height: {height}; {style}"
82
+ style={containerStyle}
73
83
  >
74
84
  <div
75
85
  class="empty-state-content pointer-events-auto flex w-full max-w-[30rem] flex-col items-center gap-3 px-12 py-12 text-center"
@@ -85,7 +95,7 @@
85
95
  {/if}
86
96
 
87
97
  <div class="flex w-full min-w-0 flex-col gap-1">
88
- <p class="text-heading-section text-foreground" style={titleStyle}>{message}</p>
98
+ <p class="text-body text-muted-foreground" style={titleStyle}>{message}</p>
89
99
  {#if description}
90
100
  <p class="text-body text-muted-foreground">{description}</p>
91
101
  {/if}
@@ -1,8 +1,16 @@
1
1
  <script lang="ts">
2
2
  // Svelte imports
3
3
  import { fade, scale } from 'svelte/transition';
4
- import { createEventDispatcher, onDestroy, onMount } from 'svelte';
4
+ import { createEventDispatcher, onDestroy, onMount, tick } from 'svelte';
5
5
  const dispatch = createEventDispatcher();
6
+ import {
7
+ deepActiveElement,
8
+ getTabbableElements,
9
+ isFocusAllowed,
10
+ isFocusable,
11
+ nextModalTitleId,
12
+ tabWrapTarget
13
+ } from '../../utils/modalFocusTrap.js';
6
14
 
7
15
  // Design system componentsimports
8
16
  import { IconButton, WScrollArea, Portal } from '..';
@@ -23,6 +31,8 @@
23
31
  overlayTransitionDurationMs,
24
32
  overlayTransitionEasing
25
33
  } from '../../utils/overlayMotion.js';
34
+ // A scrim drawn over another scrim only dims (the page is blurred once): see overlayStacking.ts.
35
+ import { stackedScrimMark } from '../../utils/overlayStacking.js';
26
36
 
27
37
  /* COMPONENT PROPS */
28
38
  // class and style props
@@ -58,6 +68,8 @@
58
68
  export let closeOnBackdropClick = true;
59
69
  /** When false, Escape does not close. Default: Escape dismisses unless a nested control already handled the key. */
60
70
  export let closeOnEscape = true;
71
+ /** Spoken name of the dialog when there is no visible title row (a bare modal should pass one, for example the file's name). */
72
+ export let ariaLabel: string | undefined = undefined;
61
73
 
62
74
  // children prop(svelte 5) to replace the traditional slot(svelte 4)
63
75
  export let children: any;
@@ -68,7 +80,8 @@
68
80
  const easing = overlayTransitionEasing;
69
81
  const transitionOpts = { duration: transitionDuration, easing };
70
82
 
71
- const focusRingGutterPx = 4;
83
+ /** Room for focus-visible rings (2px) plus ring-offset (2px), plus one pixel for anti-aliasing. */
84
+ const focusRingGutterPx = 6;
72
85
 
73
86
  // Update constants for modal constraints
74
87
  const PADDING = 24; // Consistent padding for sides and bottom
@@ -115,6 +128,74 @@
115
128
  // Show logs
116
129
  let showLogs = false;
117
130
 
131
+ let modalPanelEl: HTMLDivElement | undefined;
132
+ // One id per modal, never shared: two modals of the same type open at once (one over the other) each name themselves.
133
+ const titleElementId = nextModalTitleId();
134
+ let focusBeforeOpen: HTMLElement | null = null;
135
+ let focusTrapActive = false;
136
+
137
+ async function engageFocusTrap() {
138
+ if (focusTrapActive) return;
139
+ if (!open || !isTopModal() || !modalPanelEl) return;
140
+ focusTrapActive = true;
141
+ await tick();
142
+ if (!modalPanelEl) return;
143
+ // Content that already put focus on one of its own controls while it mounted keeps it
144
+ const focusedNow = deepActiveElement();
145
+ if (focusedNow && focusedNow !== modalPanelEl && modalPanelEl.contains(focusedNow)) return;
146
+ const autofocusTarget = modalPanelEl.querySelector<HTMLElement>('[autofocus]');
147
+ if (autofocusTarget && isFocusable(autofocusTarget)) {
148
+ autofocusTarget.focus();
149
+ } else {
150
+ modalPanelEl.focus();
151
+ }
152
+ }
153
+
154
+ function disengageFocusTrap() {
155
+ if (!focusTrapActive) return;
156
+ focusTrapActive = false;
157
+ const restoreTarget = focusBeforeOpen;
158
+ focusBeforeOpen = null;
159
+ // `isConnected`, not `document.contains`: the control may live in a shadow root
160
+ if (restoreTarget && restoreTarget.isConnected && isFocusable(restoreTarget)) {
161
+ try {
162
+ restoreTarget.focus({ preventScroll: true });
163
+ } catch {
164
+ /* element became unfocusable */
165
+ }
166
+ }
167
+ }
168
+
169
+ function handleDocumentKeydownTab(event: KeyboardEvent) {
170
+ if (!focusTrapActive || !open || !isTopModal() || !modalPanelEl || event.key !== 'Tab') return;
171
+ const activeElement = deepActiveElement();
172
+ // Focus is in a menu, list or popover that a control of this modal opened: that layer handles Tab itself
173
+ if (
174
+ activeElement &&
175
+ !modalPanelEl.contains(activeElement) &&
176
+ isFocusAllowed(modalPanelEl, activeElement)
177
+ ) {
178
+ return;
179
+ }
180
+ const tabbables = getTabbableElements(modalPanelEl);
181
+ if (tabbables.length === 0) {
182
+ event.preventDefault();
183
+ modalPanelEl.focus();
184
+ return;
185
+ }
186
+ // Only at the two ends of the modal (or when focus is outside it) does the trap choose where focus goes
187
+ const wrapTarget = tabWrapTarget({
188
+ elements: tabbables,
189
+ active: activeElement,
190
+ shiftKey: event.shiftKey,
191
+ modalRoot: modalPanelEl
192
+ });
193
+ if (wrapTarget) {
194
+ event.preventDefault();
195
+ wrapTarget.focus();
196
+ }
197
+ }
198
+
118
199
  /* METHODS */
119
200
  function toggleUpdateContentDimensions(flag: boolean = true) {
120
201
  if (!flag) {
@@ -171,9 +252,12 @@
171
252
  }
172
253
 
173
254
  window.addEventListener('keydown', handleKeydown);
255
+ document.addEventListener('keydown', handleDocumentKeydownTab, true);
174
256
 
175
257
  return () => {
176
258
  window.removeEventListener('keydown', handleKeydown);
259
+ document.removeEventListener('keydown', handleDocumentKeydownTab, true);
260
+ disengageFocusTrap();
177
261
  popModalStore();
178
262
  toggleUpdateContentDimensions(false);
179
263
  };
@@ -257,6 +341,7 @@
257
341
  }
258
342
 
259
343
  function handleClose() {
344
+ disengageFocusTrap();
260
345
  open = false;
261
346
  toggleUpdateContentDimensions(false);
262
347
  dispatch('close');
@@ -287,11 +372,29 @@
287
372
  }
288
373
  }
289
374
 
375
+ // The element that had focus when the modal opened, captured BEFORE the card exists: content that focuses itself while it
376
+ // mounts (the autofocus input of a rename dialog) must not be taken for it, or focus would not go back to the button that
377
+ // opened the modal when the dialog closes.
378
+ let focusCapturedForThisOpening = false;
379
+ $: if (open && !focusCapturedForThisOpening) {
380
+ focusCapturedForThisOpening = true;
381
+ const activeElement = typeof document !== 'undefined' ? deepActiveElement() : null;
382
+ focusBeforeOpen = activeElement && activeElement !== document.body ? activeElement : null;
383
+ } else if (!open) {
384
+ focusCapturedForThisOpening = false;
385
+ }
386
+
290
387
  // Only update the modal store when `open` is true (push once per open); closing is handled in outro / destroy.
291
388
  $: if (open) {
292
389
  pushModalStore();
293
390
  keepPortalMounted = true;
294
391
  exiting = false;
392
+ } else if (!exiting) {
393
+ disengageFocusTrap();
394
+ }
395
+
396
+ $: if (open && modalPanelEl && isTopModal()) {
397
+ void engageFocusTrap();
295
398
  }
296
399
 
297
400
  $: if (prevOpenForExit && !open) {
@@ -317,12 +420,14 @@
317
420
  >
318
421
  {#if open || exiting}
319
422
  <!-- Host-scoped scrim (absolute fills the portal host, not the viewport). -->
320
- <!-- svelte-ignore a11y_no_static_element_interactions -->
423
+ <!-- The panel below now has role="dialog", so the old svelte-ignore for a11y_no_static_element_interactions that sat here is not needed any more (the Svelte autofixer reported it as unused). -->
321
424
  <div class="modal-dismiss-layer pointer-events-none absolute inset-0 z-[1000]">
322
425
  <!-- svelte-ignore a11y_click_events_have_key_events -->
323
426
  <div
324
427
  role="presentation"
325
428
  data-widgetic-overlay="base-modal-backdrop"
429
+ data-state={open ? 'open' : 'closed'}
430
+ data-stacked={stackedScrimMark()}
326
431
  class="modal-backdrop-container bg-muted-foreground/80 pointer-events-auto absolute inset-0"
327
432
  style="backdrop-filter: blur({backdropBlur}); z-index: 0;"
328
433
  in:fade|global={reduceMotion ? { duration: 0 } : transitionOpts}
@@ -335,8 +440,14 @@
335
440
  >
336
441
  <!-- svelte-ignore a11y_click_events_have_key_events -->
337
442
  <div
443
+ bind:this={modalPanelEl}
444
+ role="dialog"
445
+ aria-modal="true"
446
+ aria-labelledby={title ? titleElementId : undefined}
447
+ aria-label={title ? undefined : ariaLabel}
448
+ tabindex="-1"
338
449
  data-widgetic-overlay="base-modal-panel"
339
- class="modal-content-inner-container bg-background border-border rounded-panel pointer-events-auto relative max-h-[calc(100vh-3rem)] select-text overflow-hidden border {bare
450
+ class="modal-content-inner-container bg-background border-border rounded-panel pointer-events-auto relative max-h-[calc(100vh-3rem)] select-text overflow-hidden border outline-none {bare
340
451
  ? 'p-0'
341
452
  : 'p-6'}"
342
453
  style="
@@ -384,7 +495,10 @@
384
495
  aria-selected={isSelected}
385
496
  >
386
497
  {#if title}
387
- <h2 class="text-heading-page text-foreground min-w-0 flex-1 break-words text-start">
498
+ <h2
499
+ id={titleElementId}
500
+ class="text-heading-page text-foreground min-w-0 flex-1 break-words text-start"
501
+ >
388
502
  {title}
389
503
  </h2>
390
504
  {:else}
@@ -422,14 +536,13 @@
422
536
  {/if}
423
537
  {:else}
424
538
  <!--
425
- Focus ring gutter: the clip wrapper uses margin -4px / padding +4px so the overflow clip edge sits
426
- outside the content box; the inner flow/scroll root keeps the same footprint as before (no inner
427
- padding), so layout parity stays 25px from the card border. For showScroll, the scroll root is
428
- extended by 8px and an inner wrapper provides the 4px pad for rings without changing measured height.
539
+ Focus ring gutter: the clip wrapper uses negative margin and matching padding so the overflow clip
540
+ edge sits outside the content box (rectangular clip — not the card radius). For showScroll, the scroll
541
+ root is extended and an inner wrapper provides the same pad for rings without changing measured height.
429
542
  -->
430
543
  <div
431
544
  class="modal-focus-ring-clip min-h-0 overflow-hidden"
432
- style="margin: -{focusRingGutterPx}px; padding: {focusRingGutterPx}px; border-radius: inherit;"
545
+ style="margin: -{focusRingGutterPx}px; padding: {focusRingGutterPx}px;"
433
546
  >
434
547
  {#if showScroll}
435
548
  <WScrollArea
@@ -439,7 +552,10 @@
439
552
  style="margin: -{focusRingGutterPx}px; width: calc(100% + {2 *
440
553
  focusRingGutterPx}px); height: {contentAvailableHeight + 2 * focusRingGutterPx}px;"
441
554
  >
442
- <div class="modal-scroll-focus-gutter box-border min-h-0 p-1">
555
+ <div
556
+ class="modal-scroll-focus-gutter box-border min-h-0"
557
+ style="padding: {focusRingGutterPx}px;"
558
+ >
443
559
  {@render contentSlot()}
444
560
  </div>
445
561
  </WScrollArea>
@@ -481,6 +597,12 @@
481
597
  pointer-events: auto;
482
598
  }
483
599
 
600
+ /* Drawn over another scrim (see overlayStacking.ts): it only dims, the page is blurred once. The blur is inline on the
601
+ element, so taking it off needs !important. */
602
+ .modal-backdrop-container[data-stacked] {
603
+ backdrop-filter: none !important;
604
+ }
605
+
484
606
  :global(.ScrollAreaViewport) {
485
607
  width: 100%;
486
608
  height: 100%;
@@ -31,6 +31,7 @@ declare const BaseModal: $$__sveltets_2_IsomorphicComponent<{
31
31
  bare?: boolean;
32
32
  /** When false, clicks and taps on the scrim do not close (destructive confirms can set this). Default matches Figma: scrim dismisses. */ closeOnBackdropClick?: boolean;
33
33
  /** When false, Escape does not close. Default: Escape dismisses unless a nested control already handled the key. */ closeOnEscape?: boolean;
34
+ /** Spoken name of the dialog when there is no visible title row (a bare modal should pass one, for example the file's name). */ ariaLabel?: string | undefined;
34
35
  children: any;
35
36
  }, {
36
37
  pointerdown: PointerEvent;
@@ -164,9 +164,11 @@
164
164
  {style}
165
165
  >
166
166
  <div class="flex flex-col gap-1.5">
167
+ <!-- The name is what this dialog asks for: BaseModal's focus trap puts the cursor here when the dialog opens (round 26) -->
167
168
  <Input
168
169
  bind:ref={inputElement}
169
170
  bind:value={itemName}
171
+ autofocus
170
172
  {placeholder}
171
173
  maxlength={maxLength}
172
174
  aria-invalid={Boolean(currentError)}
@@ -18,7 +18,6 @@
18
18
  import { Extension } from '@tiptap/core';
19
19
  import { Decoration, DecorationSet } from '@tiptap/pm/view';
20
20
  import { Plugin, PluginKey } from '@tiptap/pm/state';
21
- import { Node as PMNode } from '@tiptap/pm/model';
22
21
  const getRegex = (s, disableRegex, caseSensitive) => {
23
22
  return RegExp(disableRegex ? s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') : s, caseSensitive ? 'gu' : 'gui');
24
23
  };
@@ -1,5 +1,5 @@
1
1
  import type { Editor } from '@tiptap/core';
2
- import { Node } from '@tiptap/pm/model';
2
+ import type { Node } from '@tiptap/pm/model';
3
3
  import { DecorationSet } from '@tiptap/pm/view';
4
4
  export default function (doc: Node): DecorationSet;
5
5
  export declare const duplicateContent: (editor: Editor) => void;
@@ -1,4 +1,3 @@
1
- import { Node } from '@tiptap/pm/model';
2
1
  import { Decoration, DecorationSet } from '@tiptap/pm/view';
3
2
  export default function (doc) {
4
3
  const hexColor = /(#[0-9a-f]{3,6})\b/gi;
@@ -4,14 +4,14 @@
4
4
  import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
5
5
 
6
6
  export const navRowVariants = tv({
7
- base: 'group/nav-row flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2',
7
+ base: 'group/nav-row flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2',
8
8
  variants: {
9
9
  active: {
10
- true: 'bg-sidebar-accent text-sidebar-accent-foreground text-body-medium',
10
+ true: 'bg-sidebar-accent text-sidebar-accent-foreground text-body-medium active:bg-accent-hover',
11
11
  // The inactive row carries its own type style (14/20 regular, Figma Nav Row): without it the label took the size
12
12
  // of whatever it sat in (16px in a dialog), bigger than the active row's 14/20 medium.
13
13
  false:
14
- 'text-body text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground'
14
+ 'text-body text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-accent-hover active:text-sidebar-accent-foreground'
15
15
  }
16
16
  },
17
17
  defaultVariants: {
@@ -19,7 +19,7 @@
19
19
  }
20
20
  });
21
21
 
22
- export type NavRowVisualState = 'default' | 'hover' | 'active' | 'focus' | 'disabled';
22
+ export type NavRowVisualState = 'default' | 'hover' | 'pressed' | 'active' | 'focus' | 'disabled';
23
23
 
24
24
  export type NavRowProps = WithElementRef<HTMLButtonAttributes> &
25
25
  WithElementRef<HTMLAnchorAttributes> & {
@@ -72,6 +72,7 @@
72
72
  const showcaseClass = $derived.by(() => {
73
73
  if (!visualState || visualState === 'default' || visualState === 'active') return '';
74
74
  if (visualState === 'hover') return 'bg-sidebar-accent text-sidebar-accent-foreground';
75
+ if (visualState === 'pressed') return 'bg-accent-hover text-sidebar-accent-foreground';
75
76
  if (visualState === 'focus')
76
77
  return 'ring-2 ring-sidebar-ring ring-offset-2 ring-offset-sidebar';
77
78
  return '';
@@ -5,7 +5,7 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
5
5
  true: string;
6
6
  false: string;
7
7
  };
8
- }, undefined, "group/nav-row flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
8
+ }, undefined, "group/nav-row flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
9
9
  responsiveVariants?: boolean | (string | number | symbol)[] | {
10
10
  active?: boolean | (string | number | symbol)[] | undefined;
11
11
  } | undefined;
@@ -27,7 +27,7 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
27
27
  true: string;
28
28
  false: string;
29
29
  };
30
- }, undefined, "group/nav-row flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
30
+ }, undefined, "group/nav-row flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
31
31
  active: {
32
32
  true: string;
33
33
  false: string;
@@ -38,7 +38,7 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
38
38
  false: string;
39
39
  };
40
40
  }>, unknown, unknown, undefined>>;
41
- export type NavRowVisualState = 'default' | 'hover' | 'active' | 'focus' | 'disabled';
41
+ export type NavRowVisualState = 'default' | 'hover' | 'pressed' | 'active' | 'focus' | 'disabled';
42
42
  export type NavRowProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<HTMLAnchorAttributes> & {
43
43
  ref?: HTMLAnchorElement | HTMLButtonElement | null;
44
44
  class?: string;
@@ -13,7 +13,11 @@
13
13
  <AccordionPrimitive.Content
14
14
  bind:ref
15
15
  class={cn(
16
- "text-body data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden transition-[height]",
16
+ "text-body overflow-hidden",
17
+ "group-data-[animate=true]/accordion-item:transition-[height]",
18
+ // A closing animates for the toggled item and for the siblings that close with it; an opening only for the toggled item.
19
+ "group-data-[animate-close=true]/accordion-item:data-[state=closed]:animate-accordion-up",
20
+ "group-data-[animate=true]/accordion-item:data-[state=open]:animate-accordion-down",
17
21
  className
18
22
  )}
19
23
  {...restProps}
@@ -13,8 +13,9 @@
13
13
  The stroke is an inset ring, not a border, so it takes no room: the trigger and the rows keep the full 402px of the Figma frame. -->
14
14
  <AccordionPrimitive.Item
15
15
  bind:ref
16
+ data-accordion-item
16
17
  class={cn(
17
- "bg-popover text-popover-foreground ring-border overflow-hidden rounded-xl ring-1 ring-inset",
18
+ "group/accordion-item bg-popover text-popover-foreground ring-border overflow-hidden rounded-xl ring-1 ring-inset",
18
19
  className
19
20
  )}
20
21
  {...restProps}
@@ -8,10 +8,46 @@
8
8
  class: className,
9
9
  level = 3,
10
10
  children,
11
+ onclick,
12
+ onkeydown,
11
13
  ...restProps
12
14
  }: WithoutChild<AccordionPrimitive.TriggerProps> & {
13
15
  level?: AccordionPrimitive.HeaderProps["level"];
14
16
  } = $props();
17
+
18
+ /**
19
+ * Height animations start with the first user toggle, never on mount (an item that is open by default appears open).
20
+ * The toggled item animates both ways (`data-animate`). The other items of the accordion may close because of this
21
+ * click (a single-open accordion closes the open item as another one opens), so they animate a closing
22
+ * (`data-animate-close`) and nothing else: an item that stays open takes no animation from that flag, so it does not
23
+ * collapse and open again when a sibling is toggled.
24
+ */
25
+ function markAccordionItemsAnimate(event: Event) {
26
+ try {
27
+ const trigger = event.currentTarget as HTMLElement | null;
28
+ const accordionRoot = trigger?.closest("[data-accordion-root]");
29
+ const ownItem = trigger?.closest("[data-accordion-item]");
30
+ ownItem?.setAttribute("data-animate", "true");
31
+ ownItem?.setAttribute("data-animate-close", "true");
32
+ accordionRoot?.querySelectorAll("[data-accordion-item]").forEach((item) => {
33
+ if (item !== ownItem) item.setAttribute("data-animate-close", "true");
34
+ });
35
+ } catch (error) {
36
+ console.warn("[accordion] could not mark the items to animate:", error);
37
+ }
38
+ }
39
+
40
+ function handleTriggerClick(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) {
41
+ markAccordionItemsAnimate(event);
42
+ onclick?.(event);
43
+ }
44
+
45
+ function handleTriggerKeydown(event: KeyboardEvent & { currentTarget: EventTarget & HTMLButtonElement }) {
46
+ if (event.key === "Enter" || event.key === " ") {
47
+ markAccordionItemsAnimate(event);
48
+ }
49
+ onkeydown?.(event);
50
+ }
15
51
  </script>
16
52
 
17
53
  <AccordionPrimitive.Header {level} class="flex">
@@ -22,6 +58,8 @@
22
58
  "text-body-medium text-foreground focus-visible:ring-ring flex h-12 flex-1 items-center justify-between gap-2 px-4 text-start transition-colors duration-fast outline-none hover:bg-accent focus-visible:rounded-xl focus-visible:ring-2 focus-visible:ring-inset [&[data-state=open]>svg]:rotate-180",
23
59
  className
24
60
  )}
61
+ onclick={handleTriggerClick}
62
+ onkeydown={handleTriggerKeydown}
25
63
  {...restProps}
26
64
  >
27
65
  {@render children?.()}
@@ -13,7 +13,7 @@
13
13
  import type { VariantProps } from "tailwind-variants";
14
14
 
15
15
  export const buttonVariants = tv({
16
- base: "inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
16
+ base: "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
17
17
  variants: {
18
18
  variant: {
19
19
  default: "bg-primary text-primary-foreground hover:bg-primary/90",