@widgetic/design-system 0.5.31 → 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 (33) 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/shell/SettingsDialog.svelte +53 -10
  5. package/dist/components/shell/WidgetRow.svelte +8 -1
  6. package/dist/components/shell/WidgetRow.svelte.d.ts +2 -0
  7. package/dist/components/toast/ToasterModal.svelte +54 -10
  8. package/dist/components/toast/ToasterModal.svelte.d.ts +6 -1
  9. package/dist/components/toast/toastDismissCountdown.d.ts +5 -0
  10. package/dist/components/toast/toastDismissCountdown.js +47 -0
  11. package/dist/components/toast/toastDismissCountdownPayload.d.ts +16 -0
  12. package/dist/components/toast/toastDismissCountdownPayload.js +24 -0
  13. package/dist/components/ui/dialog/DialogLayerSync.svelte +38 -0
  14. package/dist/components/ui/dialog/DialogLayerSync.svelte.d.ts +8 -0
  15. package/dist/components/ui/dialog/dialog-content.svelte +63 -20
  16. package/dist/components/ui/dialog/dialog-content.svelte.d.ts +1 -0
  17. package/dist/components/ui/dialog/dialog-overlay.svelte +24 -20
  18. package/dist/components/ui/dialog/overlay-layer-context.d.ts +8 -0
  19. package/dist/components/ui/dialog/overlay-layer-context.js +1 -0
  20. package/dist/components/ui/drawer/drawer-content.svelte +25 -1
  21. package/dist/components/ui/drawer/drawer-overlay.svelte +32 -5
  22. package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +3 -1
  23. package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +3 -1
  24. package/dist/components/ui/hover-card/hover-card-content.svelte +3 -1
  25. package/dist/components/ui/popover/popover-content.svelte +3 -1
  26. package/dist/components/ui/select/select-content.svelte +3 -1
  27. package/dist/components/ui/tooltip/tooltip-content.svelte +3 -1
  28. package/dist/styles/global.css +33 -61
  29. package/dist/utils/overlayLayerStack.d.ts +54 -0
  30. package/dist/utils/overlayLayerStack.js +89 -0
  31. package/dist/utils/overlayMotion.d.ts +14 -46
  32. package/dist/utils/overlayMotion.js +36 -63
  33. package/package.json +1 -1
@@ -4,34 +4,38 @@
4
4
  </script>
5
5
 
6
6
  <script lang="ts">
7
- import { cn } from "../../../utils.js";
8
- import {
9
- overlayDialogOverlayClasses,
10
- overlayReducedMotionClasses
11
- } from "../../../utils/overlayMotion.js";
12
- // A scrim drawn over another scrim only dims (the page is blurred once): see overlayStacking.ts.
7
+ import { fade } from "svelte/transition";
8
+ import { getContext } from "svelte";
9
+ import { cn } from "../../../utils.js";
10
+ import { overlayDialogOverlayClasses, overlayScrimFadeTransition } from "../../../utils/overlayMotion.js";
13
11
  import { stackedScrimMark } from "../../../utils/overlayStacking.js";
12
+ import {
13
+ OVERLAY_LAYER_CONTEXT_KEY,
14
+ type OverlayLayerContext
15
+ } from "./overlay-layer-context.js";
14
16
 
15
17
  let {
16
18
  ref = $bindable(null),
17
19
  class: className,
18
20
  ...restProps
19
21
  }: DialogOverlayProps = $props();
22
+
23
+ const overlayLayerContext = getContext<OverlayLayerContext | undefined>(OVERLAY_LAYER_CONTEXT_KEY);
24
+ const scrimFade = $derived(overlayScrimFadeTransition());
20
25
  </script>
21
26
 
22
- <DialogPrimitive.Overlay
23
- bind:ref
24
- data-widgetic-overlay="dialog-backdrop"
25
- class={cn(
26
- "fixed inset-0 z-50",
27
- overlayDialogOverlayClasses,
28
- overlayReducedMotionClasses,
29
- className
30
- )}
31
- {...restProps}
32
- >
33
- {#snippet child({ props })}
34
- <!-- The element is created here, only while the dialog is shown: it is marked as it is created, so a scrim over another one never has the blur to lose. -->
35
- <div {...props} data-stacked={stackedScrimMark()}></div>
27
+ <DialogPrimitive.Overlay bind:ref forceMount {...restProps}>
28
+ {#snippet child({ props, open })}
29
+ {#if open}
30
+ <div
31
+ {...props}
32
+ data-widgetic-overlay="dialog-backdrop"
33
+ data-stacked={stackedScrimMark()}
34
+ class={cn("fixed inset-0 pointer-events-auto", overlayDialogOverlayClasses, className)}
35
+ style:z-index|important={overlayLayerContext ? overlayLayerContext.ensureLayer().scrimZ : 50}
36
+ in:fade|global={scrimFade}
37
+ out:fade|global={scrimFade}
38
+ ></div>
39
+ {/if}
36
40
  {/snippet}
37
41
  </DialogPrimitive.Overlay>
@@ -0,0 +1,8 @@
1
+ import type { claimOverlayLayerPair } from '../../../utils/overlayLayerStack.js';
2
+ export type OverlayLayerHandle = ReturnType<typeof claimOverlayLayerPair>;
3
+ export type OverlayLayerContext = {
4
+ layer: OverlayLayerHandle | null;
5
+ ensureLayer: () => OverlayLayerHandle;
6
+ releaseLayer: () => void;
7
+ };
8
+ export declare const OVERLAY_LAYER_CONTEXT_KEY: unique symbol;
@@ -0,0 +1 @@
1
+ export const OVERLAY_LAYER_CONTEXT_KEY = Symbol('widgetic-overlay-layer');
@@ -2,6 +2,29 @@
2
2
  import { Drawer as DrawerPrimitive } from "vaul-svelte";
3
3
  import DrawerOverlay from "./drawer-overlay.svelte";
4
4
  import { cn } from "../../../utils.js";
5
+ import { onDestroy, setContext } from "svelte";
6
+ import { claimOverlayLayerPair, overlayLayerZIndexStyle } from "../../../utils/overlayLayerStack.js";
7
+ import {
8
+ OVERLAY_LAYER_CONTEXT_KEY,
9
+ type OverlayLayerContext
10
+ } from "../dialog/overlay-layer-context.js";
11
+
12
+ const overlayLayerContext: OverlayLayerContext = {
13
+ ensureLayer() {
14
+ if (!this.layer) {
15
+ this.layer = claimOverlayLayerPair();
16
+ }
17
+ return this.layer;
18
+ },
19
+ releaseLayer() {
20
+ this.layer?.release();
21
+ this.layer = null;
22
+ },
23
+ layer: null
24
+ };
25
+ setContext(OVERLAY_LAYER_CONTEXT_KEY, overlayLayerContext);
26
+ onDestroy(() => overlayLayerContext.releaseLayer());
27
+ overlayLayerContext.ensureLayer();
5
28
 
6
29
  let {
7
30
  ref = $bindable(null),
@@ -18,8 +41,9 @@
18
41
  <DrawerOverlay />
19
42
  <DrawerPrimitive.Content
20
43
  bind:ref
44
+ style={overlayLayerZIndexStyle(overlayLayerContext.ensureLayer().scrimZ)}
21
45
  class={cn(
22
- "bg-background border-border fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-xl border",
46
+ "bg-background border-border fixed inset-x-0 bottom-0 mt-24 flex h-auto flex-col rounded-t-xl border",
23
47
  className
24
48
  )}
25
49
  {...restProps}
@@ -4,17 +4,44 @@
4
4
  </script>
5
5
 
6
6
  <script lang="ts">
7
+ import { fade } from "svelte/transition";
8
+ import { getContext } from "svelte";
7
9
  import { cn } from "../../../utils.js";
10
+ import { overlayDialogOverlayClasses, overlayScrimFadeTransition } from "../../../utils/overlayMotion.js";
11
+ import { stackedScrimMark } from "../../../utils/overlayStacking.js";
12
+ import {
13
+ OVERLAY_LAYER_CONTEXT_KEY,
14
+ type OverlayLayerContext
15
+ } from "../dialog/overlay-layer-context.js";
8
16
 
9
17
  let {
10
18
  ref = $bindable(null),
11
19
  class: className,
12
20
  ...restProps
13
21
  }: DrawerOverlayProps = $props();
22
+
23
+ const overlayLayerContext = getContext<OverlayLayerContext | undefined>(OVERLAY_LAYER_CONTEXT_KEY);
24
+ const scrimZ = overlayLayerContext ? overlayLayerContext.ensureLayer().scrimZ : undefined;
25
+ const scrimFade = $derived(overlayScrimFadeTransition());
26
+
27
+ // vaul-svelte hands every prop on to bits-ui's Overlay, `child` included, and bits-ui renders the backdrop as `child` asks:
28
+ // the Svelte transitions below need our own element. Only the prop *types* of vaul-svelte leave `child` out
29
+ // (`WithoutChildrenOrChild`), so the props go through an untyped object for that one prop.
30
+ const overlayProps = $derived({ ...restProps, child: backdrop } as Record<string, unknown>);
14
31
  </script>
15
32
 
16
- <DrawerPrimitive.Overlay
17
- bind:ref
18
- class={cn("fixed inset-0 z-50 bg-muted-foreground/80 backdrop-blur-[3px]", className)}
19
- {...restProps}
20
- />
33
+ {#snippet backdrop({ props, open }: { props: Record<string, unknown>; open: boolean })}
34
+ {#if open}
35
+ <div
36
+ {...props}
37
+ data-widgetic-overlay="drawer-backdrop"
38
+ data-stacked={stackedScrimMark()}
39
+ class={cn("fixed inset-0", overlayDialogOverlayClasses, className)}
40
+ style:z-index|important={scrimZ ?? 50}
41
+ in:fade|global={scrimFade}
42
+ out:fade|global={scrimFade}
43
+ ></div>
44
+ {/if}
45
+ {/snippet}
46
+
47
+ <DrawerPrimitive.Overlay bind:ref {...overlayProps} />
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { cn } from "../../../utils.js";
3
+ import { overlayFloatingContentZClass } from "../../../utils/overlayLayerStack.js";
3
4
  import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
4
5
  import { useTextDirection } from "../../textDirection.js";
5
6
 
@@ -24,7 +25,8 @@
24
25
  {sideOffset}
25
26
  dir={$textDirection}
26
27
  class={cn(
27
- "bg-popover text-popover-foreground border-border data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-xl border p-1 outline-hidden",
28
+ 'bg-popover text-popover-foreground border-border data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 min-w-[8rem] overflow-hidden rounded-xl border p-1 outline-hidden',
29
+ overlayFloatingContentZClass,
28
30
  className
29
31
  )}
30
32
  {...restProps}
@@ -5,6 +5,7 @@
5
5
 
6
6
  <script lang="ts">
7
7
  import { cn } from "../../../utils.js";
8
+ import { overlayFloatingContentZClass } from "../../../utils/overlayLayerStack.js";
8
9
  import { useTextDirection } from "../../textDirection.js";
9
10
 
10
11
  // The library writes dir="ltr" on the floating element unless it is told the direction: left to right text and
@@ -22,7 +23,8 @@
22
23
  bind:ref
23
24
  dir={$textDirection}
24
25
  class={cn(
25
- "bg-popover text-popover-foreground border-border z-50 min-w-[8rem] rounded-xl border p-1 focus:outline-hidden",
26
+ 'bg-popover text-popover-foreground border-border min-w-[8rem] rounded-xl border p-1 focus:outline-hidden',
27
+ overlayFloatingContentZClass,
26
28
  className
27
29
  )}
28
30
  {...restProps}
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { LinkPreview as HoverCardPrimitive } from "bits-ui";
3
3
  import { cn } from "../../../utils.js";
4
+ import { overlayFloatingContentZClass } from "../../../utils/overlayLayerStack.js";
4
5
  import { useTextDirection } from "../../textDirection.js";
5
6
 
6
7
  // The library writes dir="ltr" on the floating element unless it is told the direction: left to right text and
@@ -26,7 +27,8 @@
26
27
  {sideOffset}
27
28
  dir={$textDirection}
28
29
  class={cn(
29
- "bg-popover text-popover-foreground border-border z-50 mt-3 w-64 rounded-xl border p-4 outline-hidden",
30
+ 'bg-popover text-popover-foreground border-border mt-3 w-64 rounded-xl border p-4 outline-hidden',
31
+ overlayFloatingContentZClass,
30
32
  className
31
33
  )}
32
34
  {...restProps}
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { cn } from "../../../utils.js";
3
+ import { overlayFloatingContentZClass } from "../../../utils/overlayLayerStack.js";
3
4
  import { Popover as PopoverPrimitive } from "bits-ui";
4
5
  import { useTextDirection } from "../../textDirection.js";
5
6
 
@@ -26,7 +27,8 @@
26
27
  {align}
27
28
  dir={$textDirection}
28
29
  class={cn(
29
- "bg-popover text-popover-foreground border-border data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-xl border p-4 outline-hidden",
30
+ 'bg-popover text-popover-foreground border-border data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 w-72 rounded-xl border p-4 outline-hidden',
31
+ overlayFloatingContentZClass,
30
32
  className
31
33
  )}
32
34
  {...restProps}
@@ -4,6 +4,7 @@
4
4
  import IconChevronDown from "@tabler/icons-svelte/icons/chevron-down";
5
5
  import { onMount, tick } from "svelte";
6
6
  import { cn } from "../../../utils.js";
7
+ import { overlayFloatingContentZClass } from "../../../utils/overlayLayerStack.js";
7
8
  import { useTextDirection } from "../../textDirection.js";
8
9
  import { installInputModality } from "../../../utils/inputModality.js";
9
10
 
@@ -127,7 +128,8 @@
127
128
  {sideOffset}
128
129
  dir={$textDirection}
129
130
  class={cn(
130
- "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
131
+ 'relative max-h-96 min-w-[8rem] overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
132
+ overlayFloatingContentZClass,
131
133
  className
132
134
  )}
133
135
  {...restProps}
@@ -5,6 +5,7 @@
5
5
 
6
6
  <script lang="ts">
7
7
  import { cn } from "../../../utils.js";
8
+ import { overlayFloatingContentZClass } from "../../../utils/overlayLayerStack.js";
8
9
  import { useTextDirection } from "../../textDirection.js";
9
10
 
10
11
  // The library writes dir="ltr" on the floating element unless it is told the direction: left to right text and
@@ -24,7 +25,8 @@
24
25
  {sideOffset}
25
26
  dir={$textDirection}
26
27
  class={cn(
27
- "bg-popover text-popover-foreground border-border text-caption animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-w-[min(18rem,calc(100vw-2rem))] overflow-hidden rounded-lg border px-3 py-1.5 text-balance whitespace-normal",
28
+ 'bg-popover text-popover-foreground border-border text-caption animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-w-[min(18rem,calc(100vw-2rem))] overflow-hidden rounded-lg border px-3 py-1.5 text-balance whitespace-normal',
29
+ overlayFloatingContentZClass,
28
30
  className
29
31
  )}
30
32
  {...restProps}
@@ -936,69 +936,26 @@ go 3 levels up in development mode, 2 levels up in production mode*/
936
936
  }
937
937
  } /* End of Base Layer Styles */
938
938
 
939
- /* Centred bits-ui dialog panels: fade + 20px slide (no zoom); composes with -translate-x/y-1/2 centering. */
940
- @media (prefers-reduced-motion: no-preference) {
941
- [data-widgetic-overlay='dialog-panel'][data-state='open'] {
942
- animation: widgetic-dialog-enter 200ms cubic-bezier(0.33, 1, 0.68, 1) both;
943
- }
944
-
945
- [data-widgetic-overlay='dialog-panel'][data-state='closed'] {
946
- animation: widgetic-dialog-exit 200ms cubic-bezier(0.33, 1, 0.68, 1) both;
947
- }
939
+ /* Toast (ToasterModal): width fits copy; stack stays above dialogs (Portal ~1e8, sonner default ~1e9). */
940
+ .toast-modal-host[data-sonner-toaster] {
941
+ left: 50% !important;
942
+ right: auto !important;
943
+ transform: translateX(-50%) !important;
944
+ width: max-content !important;
945
+ max-width: min(420px, calc(100vw - 2rem));
948
946
  }
949
947
 
950
- @media (prefers-reduced-motion: reduce) {
951
- [data-widgetic-overlay='dialog-panel'][data-state='open'] {
952
- animation: widgetic-dialog-fade-in 200ms cubic-bezier(0.33, 1, 0.68, 1) both;
953
- }
954
-
955
- [data-widgetic-overlay='dialog-panel'][data-state='closed'] {
956
- animation: widgetic-dialog-fade-out 200ms cubic-bezier(0.33, 1, 0.68, 1) both;
957
- }
948
+ .toast-modal-host [data-sonner-toast].toast-modal {
949
+ width: max-content;
950
+ max-width: 420px;
958
951
  }
959
952
 
960
- @keyframes widgetic-dialog-enter {
961
- from {
962
- opacity: 0;
963
- transform: translate(-50%, calc(-50% + 20px));
964
- }
965
-
966
- to {
967
- opacity: 1;
968
- transform: translate(-50%, -50%);
969
- }
953
+ .toast-modal-host [data-sonner-toast].toast-modal [data-title] {
954
+ text-align: start;
970
955
  }
971
956
 
972
- @keyframes widgetic-dialog-exit {
973
- from {
974
- opacity: 1;
975
- transform: translate(-50%, -50%);
976
- }
977
-
978
- to {
979
- opacity: 0;
980
- transform: translate(-50%, calc(-50% + 20px));
981
- }
982
- }
983
-
984
- @keyframes widgetic-dialog-fade-in {
985
- from {
986
- opacity: 0;
987
- }
988
-
989
- to {
990
- opacity: 1;
991
- }
992
- }
993
-
994
- @keyframes widgetic-dialog-fade-out {
995
- from {
996
- opacity: 1;
997
- }
998
-
999
- to {
1000
- opacity: 0;
1001
- }
957
+ .toast-modal-host [data-sonner-toast].toast-modal [data-description] {
958
+ display: none !important;
1002
959
  }
1003
960
 
1004
961
  /* Toast (ToasterModal): top-centre pill, slide in, fade out in place. */
@@ -1019,24 +976,22 @@ go 3 levels up in development mode, 2 levels up in production mode*/
1019
976
  @keyframes widgetic-toast-enter {
1020
977
  from {
1021
978
  opacity: 0;
1022
- transform: translate(-50%, -16px);
979
+ transform: translateY(-16px);
1023
980
  }
1024
981
 
1025
982
  to {
1026
983
  opacity: 1;
1027
- transform: translate(-50%, 0);
984
+ transform: translateY(0);
1028
985
  }
1029
986
  }
1030
987
 
1031
988
  @keyframes widgetic-toast-exit {
1032
989
  from {
1033
990
  opacity: 1;
1034
- transform: translate(-50%, 0);
1035
991
  }
1036
992
 
1037
993
  to {
1038
994
  opacity: 0;
1039
- transform: translate(-50%, 0);
1040
995
  }
1041
996
  }
1042
997
 
@@ -1047,6 +1002,23 @@ go 3 levels up in development mode, 2 levels up in production mode*/
1047
1002
  }
1048
1003
  }
1049
1004
 
1005
+ /* Sonner's <600px rules left-align the stack; toasts stay viewport-centred. */
1006
+ @media (max-width: 600px) {
1007
+ .toast-modal-host[data-sonner-toaster] {
1008
+ left: 50% !important;
1009
+ right: auto !important;
1010
+ transform: translateX(-50%) !important;
1011
+ width: max-content !important;
1012
+ }
1013
+
1014
+ .toast-modal-host[data-sonner-toaster] [data-sonner-toast] {
1015
+ left: auto !important;
1016
+ right: auto !important;
1017
+ width: max-content !important;
1018
+ max-width: min(420px, calc(100vw - 2rem));
1019
+ }
1020
+ }
1021
+
1050
1022
  /* Debug styles */
1051
1023
  [data-debug="true"] [data-debug-footer] {
1052
1024
  @apply bg-blue-100/30;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Z-index stack for dialog / drawer scrims portaled to the document.
3
+ *
4
+ * Only scrims get a rising z-index (`50 + 2 * index`). Panels sit one above their scrim (`scrim + 1`, see
5
+ * `overlayLayerZIndexStyle`) and popovers read `--widgetic-overlay-floating-z` (`scrim + 2` of the top layer), so selects and
6
+ * menus stay above every panel.
7
+ *
8
+ * A host that draws layers of its own above 50 (the creator's floating panels sit at 2003) says so where it opens a dialog,
9
+ * with `layerBase` on `Dialog.Content`: that dialog, and every dialog opened above it, start from that base. Page CSS cannot
10
+ * do it (see `overlayLayerZIndexStyle`: the layers are out of its reach, by design).
11
+ */
12
+ /** First scrim z-index when the host asks for nothing else; leaves z-40 for the canvas overlay portal. */
13
+ export declare const overlayLayerBaseZ = 50;
14
+ export declare const overlayLayerStride = 2;
15
+ /** Default when no overlay is open (matches legacy `z-50` on floating layers). */
16
+ export declare const overlayFloatingContentDefaultZ = 50;
17
+ /**
18
+ * Claim the next scrim layer while a dialog is opening.
19
+ *
20
+ * @param layerBase - Where the layer starts when nothing is open below it (`overlayLayerBaseZ`, 50, unless the host asked
21
+ * for more). A layer opened above another one is always above it, whatever its base: the dialog opened last is on top.
22
+ * @returns Scrim z-index plus `release` when the portal unmounts. `panelZ` is kept for tests only (scrim + 1).
23
+ */
24
+ export declare function claimOverlayLayerPair(layerBase?: number): {
25
+ scrimZ: number;
26
+ panelZ: number;
27
+ release: () => void;
28
+ };
29
+ /**
30
+ * The inline style that puts a scrim or a panel on its layer.
31
+ *
32
+ * It carries `!important` on purpose. An inline declaration with `!important` outranks every rule of every stylesheet,
33
+ * `!important` ones included, and the order of a dialog's two layers (the scrim at `z`, the panel at `z + 1`) is all that keeps
34
+ * the panel above its own scrim. A page can break that order from outside with one rule, and one did: the creator shipped a
35
+ * global `[data-dialog-overlay] { z-index: 9998 !important }`, which lifted the scrim of every dialog in the page above its
36
+ * panel (still at 51), so the Invite dialog of the dashboard, the settings dialog and the drawers were drawn under their own
37
+ * scrim whenever the creator's stylesheet was loaded. With the pair out of reach of the host page's CSS, that cannot happen
38
+ * again, whoever writes the next rule.
39
+ *
40
+ * This is the string form, for a `style` prop of a component or an element that spreads nothing. An element that spreads
41
+ * bits-ui's `props` (the scrim, the settings panel) writes the same thing as `style:z-index|important={z}`: a `style`
42
+ * ATTRIBUTE after the spread would replace `props.style`, where bits-ui keeps `pointer-events: auto` (the page behind a modal
43
+ * dialog has `pointer-events: none`), and nothing inside the settings dialog could be clicked; a `style:` directive merges.
44
+ * `tests/overlayLayerZIndexInline.test.ts` holds both rules.
45
+ *
46
+ * @param zIndex - The layer: `scrimZ` for a scrim, `scrimZ + 1` for a panel.
47
+ */
48
+ export declare function overlayLayerZIndexStyle(zIndex: number): string;
49
+ /** z-index for select / popover / menu / tooltip portals (above every open dialog panel). */
50
+ export declare function overlayFloatingContentZ(): number;
51
+ /** Tailwind-friendly class for floating overlay content (literal for the scanner). */
52
+ export declare const overlayFloatingContentZClass = "z-[var(--widgetic-overlay-floating-z,50)]";
53
+ export declare function overlayLayerStackDepth(): number;
54
+ export declare function resetOverlayLayerStackForTests(): void;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Z-index stack for dialog / drawer scrims portaled to the document.
3
+ *
4
+ * Only scrims get a rising z-index (`50 + 2 * index`). Panels sit one above their scrim (`scrim + 1`, see
5
+ * `overlayLayerZIndexStyle`) and popovers read `--widgetic-overlay-floating-z` (`scrim + 2` of the top layer), so selects and
6
+ * menus stay above every panel.
7
+ *
8
+ * A host that draws layers of its own above 50 (the creator's floating panels sit at 2003) says so where it opens a dialog,
9
+ * with `layerBase` on `Dialog.Content`: that dialog, and every dialog opened above it, start from that base. Page CSS cannot
10
+ * do it (see `overlayLayerZIndexStyle`: the layers are out of its reach, by design).
11
+ */
12
+ /** First scrim z-index when the host asks for nothing else; leaves z-40 for the canvas overlay portal. */
13
+ export const overlayLayerBaseZ = 50;
14
+ export const overlayLayerStride = 2;
15
+ /** Default when no overlay is open (matches legacy `z-50` on floating layers). */
16
+ export const overlayFloatingContentDefaultZ = overlayLayerBaseZ;
17
+ const FLOATING_CSS_VAR = '--widgetic-overlay-floating-z';
18
+ let openLayers = [];
19
+ function syncFloatingCssVar() {
20
+ if (typeof document === 'undefined')
21
+ return;
22
+ const top = openLayers.at(-1);
23
+ const floatingZ = top ? top.scrimZ + 2 : overlayFloatingContentDefaultZ;
24
+ document.documentElement.style.setProperty(FLOATING_CSS_VAR, String(floatingZ));
25
+ }
26
+ /**
27
+ * Claim the next scrim layer while a dialog is opening.
28
+ *
29
+ * @param layerBase - Where the layer starts when nothing is open below it (`overlayLayerBaseZ`, 50, unless the host asked
30
+ * for more). A layer opened above another one is always above it, whatever its base: the dialog opened last is on top.
31
+ * @returns Scrim z-index plus `release` when the portal unmounts. `panelZ` is kept for tests only (scrim + 1).
32
+ */
33
+ export function claimOverlayLayerPair(layerBase = overlayLayerBaseZ) {
34
+ // A base below the default would put a scrim under the page chrome the stack is built to cover: ignore it
35
+ const startZ = Number.isFinite(layerBase) ? Math.max(layerBase, overlayLayerBaseZ) : overlayLayerBaseZ;
36
+ const below = openLayers.at(-1);
37
+ const scrimZ = below ? Math.max(startZ, below.scrimZ + overlayLayerStride) : startZ;
38
+ const entry = { scrimZ };
39
+ openLayers = [...openLayers, entry];
40
+ syncFloatingCssVar();
41
+ let released = false;
42
+ return {
43
+ scrimZ,
44
+ panelZ: scrimZ + 1,
45
+ release() {
46
+ if (released)
47
+ return;
48
+ released = true;
49
+ openLayers = openLayers.filter((layer) => layer !== entry);
50
+ syncFloatingCssVar();
51
+ }
52
+ };
53
+ }
54
+ /**
55
+ * The inline style that puts a scrim or a panel on its layer.
56
+ *
57
+ * It carries `!important` on purpose. An inline declaration with `!important` outranks every rule of every stylesheet,
58
+ * `!important` ones included, and the order of a dialog's two layers (the scrim at `z`, the panel at `z + 1`) is all that keeps
59
+ * the panel above its own scrim. A page can break that order from outside with one rule, and one did: the creator shipped a
60
+ * global `[data-dialog-overlay] { z-index: 9998 !important }`, which lifted the scrim of every dialog in the page above its
61
+ * panel (still at 51), so the Invite dialog of the dashboard, the settings dialog and the drawers were drawn under their own
62
+ * scrim whenever the creator's stylesheet was loaded. With the pair out of reach of the host page's CSS, that cannot happen
63
+ * again, whoever writes the next rule.
64
+ *
65
+ * This is the string form, for a `style` prop of a component or an element that spreads nothing. An element that spreads
66
+ * bits-ui's `props` (the scrim, the settings panel) writes the same thing as `style:z-index|important={z}`: a `style`
67
+ * ATTRIBUTE after the spread would replace `props.style`, where bits-ui keeps `pointer-events: auto` (the page behind a modal
68
+ * dialog has `pointer-events: none`), and nothing inside the settings dialog could be clicked; a `style:` directive merges.
69
+ * `tests/overlayLayerZIndexInline.test.ts` holds both rules.
70
+ *
71
+ * @param zIndex - The layer: `scrimZ` for a scrim, `scrimZ + 1` for a panel.
72
+ */
73
+ export function overlayLayerZIndexStyle(zIndex) {
74
+ return `z-index: ${zIndex} !important`;
75
+ }
76
+ /** z-index for select / popover / menu / tooltip portals (above every open dialog panel). */
77
+ export function overlayFloatingContentZ() {
78
+ const top = openLayers.at(-1);
79
+ return top ? top.scrimZ + 2 : overlayFloatingContentDefaultZ;
80
+ }
81
+ /** Tailwind-friendly class for floating overlay content (literal for the scanner). */
82
+ export const overlayFloatingContentZClass = 'z-[var(--widgetic-overlay-floating-z,50)]';
83
+ export function overlayLayerStackDepth() {
84
+ return openLayers.length;
85
+ }
86
+ export function resetOverlayLayerStackForTests() {
87
+ openLayers = [];
88
+ syncFloatingCssVar();
89
+ }
@@ -1,65 +1,33 @@
1
1
  /**
2
2
  * Shared overlay motion tokens so BaseModal, bits-ui Dialog, and related surfaces stay in sync.
3
- * FilePreview / legacy modals: backdrop fades 200ms with cubicOut; the card scales from 0.95 with the same timing.
4
- * Change here when Figma updates overlay motion.
5
3
  */
6
4
  import { cubicOut } from 'svelte/easing';
7
- /** Backdrop scrim + card motion duration (ms). Intentionally 200ms; DS `--duration-base` is 160ms for small UI. */
5
+ import type { FadeParams, FlyParams } from 'svelte/transition';
6
+ /** Backdrop scrim + card motion duration (ms). */
8
7
  export declare const overlayTransitionDurationMs = 200;
9
- /** Easing for open/close (Svelte transition easing function — matches “cubic out” in the legacy modals). */
10
8
  export declare const overlayTransitionEasing: typeof cubicOut;
11
- /**
12
- * Backdrop blur (px) of the scrim behind every modal, dialog, drawer and sheet. It is the Figma effect style
13
- * `Overlay/Scrim blur` (a background blur of 3).
14
- */
15
9
  export declare const overlayBackdropBlurPx = 3;
16
- /** Content scale at the start of the open transition / end of the close transition. */
17
10
  export declare const overlayContentScaleStart = 0.95;
18
- /**
19
- * Centred dialogs slide this many pixels up on open and down on close, with the same duration as the fade.
20
- * Tailwind spacing step (5 → 20px with the design-system scale).
21
- */
22
11
  export declare const overlayContentSlideDistance = 5;
23
- /** Pixel slide distance for Svelte `fly` on centred modals (Tailwind spacing step 5 → 20px). */
24
12
  export declare const overlayContentSlidePx: number;
25
- /** Tailwind slide utilities for centred dialog panels (not drawers/sheets that enter from the side). */
26
13
  export declare const overlayDialogContentSlideClasses: readonly ["data-[state=closed]:slide-out-to-bottom-5", "data-[state=open]:slide-in-from-bottom-5"];
27
- /**
28
- * Tailwind duration class — must be a source literal so Tailwind's scanner emits `duration-[200ms]`.
29
- * Kept in sync with `overlayTransitionDurationMs` (see tests/overlayMotionDuration.test.ts).
30
- */
31
14
  export declare const overlayDurationClass = "duration-[200ms]";
32
- /**
33
- * bits-ui applies `data-[state=open]:animate-in` at specificity 0,2,0 with a 150ms default duration, which beats a
34
- * plain `duration-[200ms]` (0,1,0). These state-scoped arbitrary properties match open/closed and win in cascade.
35
- * Literal strings — keep in sync with `overlayTransitionDurationMs`.
36
- */
37
- export declare const overlayDialogOpenClosedAnimationDurationClasses: readonly ["data-[state=open]:[animation-duration:200ms]", "data-[state=closed]:[animation-duration:200ms]"];
38
- /**
39
- * The scrim colour: the muted foreground token (neutral 550 in the design system) at 80%. The opacity is part of the colour, not of
40
- * the layer, because an element that is itself translucent would not blur what is behind it. Literal so Tailwind's
41
- * scanner emits it; `bg-muted-foreground/80` is the Figma scrim (`Foundations / Overlay`).
42
- */
43
15
  export declare const overlayScrimColorClass = "bg-muted-foreground/80";
44
- /** Backdrop blur class — matches `overlayBackdropBlurPx`. Literal for the same reason as the colour. */
45
16
  export declare const overlayBackdropBlurClass = "backdrop-blur-[3px]";
46
- /**
47
- * The whole scrim: colour and blur. Every surface that dims the page behind a panel (dialogs, modals, drawers, the
48
- * navigation drawer) uses these two classes, so the overlay looks the same everywhere. Written out, not joined from the
49
- * two constants above, so the scanner of Tailwind finds both classes in this one literal as well.
50
- */
51
17
  export declare const overlayScrimClasses = "bg-muted-foreground/80 backdrop-blur-[3px]";
52
- /** Tailwind arbitrary easing approximating Svelte `cubicOut` (ease-out cubic, 1 − (1 − t)³). */
53
18
  export declare const overlayEasingClass = "ease-[cubic-bezier(0.33,1,0.68,1)]";
54
- /**
55
- * A scrim drawn over another scrim only dims: the one below blurs the page already, and two backdrop blurs that fade
56
- * in together flicker. `markStackedScrim` (`overlayStacking.ts`) puts `data-stacked` on such a scrim, and this takes its
57
- * blur off. Literal so Tailwind's scanner emits it.
58
- */
59
19
  export declare const overlayStackedScrimClass = "data-[stacked]:backdrop-blur-none";
60
- /** Overlay + panel classes for bits-ui Dialog (fade + slide, 200ms, cubic-out-like; no zoom). */
20
+ /** Scrim surface classes only (motion is Svelte `fade` on the overlay child element). */
61
21
  export declare const overlayDialogOverlayClasses: string;
62
- /** Centred dialog panel motion is keyed in global.css (`widgetic-dialog-enter/exit`) so slide composes with -translate-x/y-1/2. */
22
+ /** Card chrome inside the flex-centred dialog host (no fixed positioning on the card itself). */
23
+ export declare const overlayDialogPanelCardClasses = "relative";
24
+ /** Full-viewport host that centres the card (see `dialog-content.svelte`). */
25
+ export declare const overlayDialogPanelLayoutClasses = "fixed inset-0 flex items-center justify-center";
26
+ /** @deprecated Kept for grep tests; motion no longer uses Tailwind animate utilities. */
63
27
  export declare const overlayDialogContentClasses: string;
64
- /** Applied with overlay dialog classes so users who prefer reduced motion get instant open/close. */
65
- export declare const overlayReducedMotionClasses = "motion-reduce:!duration-0 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none";
28
+ /** @deprecated */
29
+ export declare const overlayDialogContentMotionClasses: string;
30
+ export declare const overlayReducedMotionClasses = "motion-reduce:transition-none";
31
+ export declare function prefersReducedOverlayMotion(): boolean;
32
+ export declare function overlayScrimFadeTransition(reducedMotion?: boolean): FadeParams;
33
+ export declare function overlayPanelFlyTransition(reducedMotion?: boolean): FlyParams;