@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.
- package/dist/components/EmptyState.svelte +5 -2
- package/dist/components/modals/ActionModal.svelte +10 -9
- package/dist/components/modals/README.md +1 -1
- package/dist/components/navigation/Breadcrumbs.svelte +11 -3
- package/dist/components/navigation/Breadcrumbs.svelte.d.ts +2 -0
- package/dist/components/navigation/types.d.ts +4 -0
- package/dist/components/shell/SettingsDialog.svelte +59 -11
- package/dist/components/shell/WidgetRow.svelte +8 -1
- package/dist/components/shell/WidgetRow.svelte.d.ts +2 -0
- package/dist/components/toast/ToasterModal.svelte +54 -10
- package/dist/components/toast/ToasterModal.svelte.d.ts +6 -1
- package/dist/components/toast/toastDismissCountdown.d.ts +5 -0
- package/dist/components/toast/toastDismissCountdown.js +47 -0
- package/dist/components/toast/toastDismissCountdownPayload.d.ts +16 -0
- package/dist/components/toast/toastDismissCountdownPayload.js +24 -0
- package/dist/components/ui/dialog/DialogLayerSync.svelte +38 -0
- package/dist/components/ui/dialog/DialogLayerSync.svelte.d.ts +8 -0
- package/dist/components/ui/dialog/dialog-content.svelte +63 -20
- package/dist/components/ui/dialog/dialog-content.svelte.d.ts +1 -0
- package/dist/components/ui/dialog/dialog-overlay.svelte +24 -20
- package/dist/components/ui/dialog/overlay-layer-context.d.ts +8 -0
- package/dist/components/ui/dialog/overlay-layer-context.js +1 -0
- package/dist/components/ui/drawer/drawer-content.svelte +25 -1
- package/dist/components/ui/drawer/drawer-overlay.svelte +32 -5
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +3 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +3 -1
- package/dist/components/ui/hover-card/hover-card-content.svelte +3 -1
- package/dist/components/ui/popover/popover-content.svelte +3 -1
- package/dist/components/ui/select/select-content.svelte +3 -1
- package/dist/components/ui/tooltip/tooltip-content.svelte +3 -1
- package/dist/styles/global.css +33 -61
- package/dist/styles/tokens.css +19 -7
- package/dist/utils/overlayLayerStack.d.ts +54 -0
- package/dist/utils/overlayLayerStack.js +89 -0
- package/dist/utils/overlayMotion.d.ts +14 -46
- package/dist/utils/overlayMotion.js +36 -63
- package/package.json +1 -1
|
@@ -2,47 +2,90 @@
|
|
|
2
2
|
import { Dialog as DialogPrimitive, type WithoutChildrenOrChild } from "bits-ui";
|
|
3
3
|
import IconX from "@tabler/icons-svelte/icons/x";
|
|
4
4
|
import type { Snippet } from "svelte";
|
|
5
|
+
import { fly } from "svelte/transition";
|
|
6
|
+
import { onDestroy, setContext } from "svelte";
|
|
5
7
|
import * as Dialog from "./index.js";
|
|
6
8
|
import { cn } from "../../../utils.js";
|
|
7
9
|
import {
|
|
8
|
-
|
|
10
|
+
overlayDialogPanelCardClasses,
|
|
11
|
+
overlayPanelFlyTransition,
|
|
9
12
|
overlayReducedMotionClasses
|
|
10
13
|
} from "../../../utils/overlayMotion.js";
|
|
14
|
+
import { claimOverlayLayerPair, overlayLayerZIndexStyle } from "../../../utils/overlayLayerStack.js";
|
|
15
|
+
import { OVERLAY_LAYER_CONTEXT_KEY, type OverlayLayerContext } from "./overlay-layer-context.js";
|
|
16
|
+
import DialogLayerSync from "./DialogLayerSync.svelte";
|
|
11
17
|
|
|
12
18
|
let {
|
|
13
19
|
ref = $bindable(null),
|
|
14
20
|
class: className,
|
|
15
21
|
portalProps,
|
|
16
|
-
// The name the close button has for a screen reader (it is drawn as an X): a page in another language gives its own.
|
|
17
22
|
closeLabel = "Close",
|
|
23
|
+
// Where this dialog's layers start (see `claimOverlayLayerPair`). Only a host that draws layers of its own above 50
|
|
24
|
+
// needs it: the creator's floating panels sit at 2003, so its confirm dialogs start above that.
|
|
25
|
+
layerBase,
|
|
18
26
|
children,
|
|
19
27
|
...restProps
|
|
20
28
|
}: WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
|
|
21
29
|
portalProps?: DialogPrimitive.PortalProps;
|
|
22
30
|
closeLabel?: string;
|
|
31
|
+
layerBase?: number;
|
|
23
32
|
children: Snippet;
|
|
24
33
|
} = $props();
|
|
34
|
+
|
|
35
|
+
const overlayLayerContext: OverlayLayerContext = {
|
|
36
|
+
ensureLayer() {
|
|
37
|
+
if (!this.layer) {
|
|
38
|
+
this.layer = claimOverlayLayerPair(layerBase);
|
|
39
|
+
}
|
|
40
|
+
return this.layer;
|
|
41
|
+
},
|
|
42
|
+
releaseLayer() {
|
|
43
|
+
this.layer?.release();
|
|
44
|
+
this.layer = null;
|
|
45
|
+
},
|
|
46
|
+
layer: null
|
|
47
|
+
};
|
|
48
|
+
setContext(OVERLAY_LAYER_CONTEXT_KEY, overlayLayerContext);
|
|
49
|
+
onDestroy(() => overlayLayerContext.releaseLayer());
|
|
50
|
+
|
|
51
|
+
const panelFly = $derived(overlayPanelFlyTransition());
|
|
25
52
|
</script>
|
|
26
53
|
|
|
27
54
|
<Dialog.Portal {...portalProps}>
|
|
28
55
|
<Dialog.Overlay />
|
|
29
|
-
<DialogPrimitive.Content
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
<DialogPrimitive.Content bind:ref forceMount {...restProps}>
|
|
57
|
+
{#snippet child({ props, open })}
|
|
58
|
+
<DialogLayerSync {open} {overlayLayerContext} />
|
|
59
|
+
{#if open}
|
|
60
|
+
<!-- Full-viewport host: layout only. bits-ui `ref` + dismissible bounds must sit on the card: an inset-0 host made every pointer event "inside" the dialog. -->
|
|
61
|
+
<div
|
|
62
|
+
data-widgetic-overlay="dialog-panel"
|
|
63
|
+
class={cn(
|
|
64
|
+
"fixed inset-0 flex items-center justify-center p-6 pointer-events-none",
|
|
65
|
+
overlayReducedMotionClasses
|
|
66
|
+
)}
|
|
67
|
+
style={overlayLayerZIndexStyle(overlayLayerContext.ensureLayer().scrimZ + 1)}
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
{...props}
|
|
71
|
+
class={cn(
|
|
72
|
+
"bg-background border-border pointer-events-auto grid w-dialog max-w-[calc(100vw-3rem)] gap-4 rounded-panel border p-6",
|
|
73
|
+
overlayDialogPanelCardClasses,
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
76
|
+
in:fly|global={panelFly}
|
|
77
|
+
out:fly|global={panelFly}
|
|
78
|
+
>
|
|
79
|
+
{@render children?.()}
|
|
80
|
+
<DialogPrimitive.Close
|
|
81
|
+
class="text-foreground hover:bg-accent absolute end-4 top-4 inline-flex size-8 items-center justify-center rounded-lg transition-colors duration-fast 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"
|
|
82
|
+
>
|
|
83
|
+
<IconX class="size-4 stroke-2" />
|
|
84
|
+
<span class="sr-only">{closeLabel}</span>
|
|
85
|
+
</DialogPrimitive.Close>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
{/if}
|
|
89
|
+
{/snippet}
|
|
47
90
|
</DialogPrimitive.Content>
|
|
48
91
|
</Dialog.Portal>
|
|
@@ -3,6 +3,7 @@ import type { Snippet } from "svelte";
|
|
|
3
3
|
type $$ComponentProps = WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
|
|
4
4
|
portalProps?: DialogPrimitive.PortalProps;
|
|
5
5
|
closeLabel?: string;
|
|
6
|
+
layerBase?: number;
|
|
6
7
|
children: Snippet;
|
|
7
8
|
};
|
|
8
9
|
declare const DialogContent: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
@@ -4,34 +4,38 @@
|
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<script lang="ts">
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
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
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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}
|
package/dist/styles/global.css
CHANGED
|
@@ -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
|
-
/*
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
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
|
-
|
|
951
|
-
|
|
952
|
-
|
|
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
|
-
|
|
961
|
-
|
|
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
|
-
|
|
973
|
-
|
|
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:
|
|
979
|
+
transform: translateY(-16px);
|
|
1023
980
|
}
|
|
1024
981
|
|
|
1025
982
|
to {
|
|
1026
983
|
opacity: 1;
|
|
1027
|
-
transform:
|
|
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;
|
package/dist/styles/tokens.css
CHANGED
|
@@ -55,10 +55,13 @@
|
|
|
55
55
|
--muted-foreground: var(--color-neutral-550);
|
|
56
56
|
--accent: var(--color-alpha-dark-04);
|
|
57
57
|
--accent-foreground: var(--color-dark);
|
|
58
|
-
/*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
/*
|
|
59
|
+
* Hover of a surface that is already accent (soft controls, the search field, the rows of the editor).
|
|
60
|
+
* The Figma Hover variants stack a second accent fill on the first (4% over 4%); the nearest alpha primitive is 8%.
|
|
61
|
+
* Opaque mix of page background and ink so outline and ghost hovers stay solid on a dark band behind them (transparent
|
|
62
|
+
* alpha tints would show the parent). Derived from the primitives, not a Figma variable.
|
|
63
|
+
*/
|
|
64
|
+
--accent-hover: color-mix(in oklab, var(--background) 92%, var(--foreground) 8%);
|
|
62
65
|
--destructive: var(--color-error);
|
|
63
66
|
--destructive-foreground: var(--color-white);
|
|
64
67
|
/* Warning icon and text, 5.0:1 on white, and the surface of the Warning toast (white text on it is 5.0:1 too). Never a button. */
|
|
@@ -159,9 +162,8 @@
|
|
|
159
162
|
--muted-foreground: var(--color-alpha-light-70);
|
|
160
163
|
--accent: var(--color-alpha-light-10);
|
|
161
164
|
--accent-foreground: var(--color-white);
|
|
162
|
-
/* Not a Figma variable, like
|
|
163
|
-
|
|
164
|
-
--accent-hover: color-mix(in oklab, var(--color-white) 20%, transparent);
|
|
165
|
+
/* Not a Figma variable, like `--accent-hover` of `:root`: the hover of a surface that is already accent — opaque 20% ink. */
|
|
166
|
+
--accent-hover: color-mix(in oklab, var(--background) 80%, var(--foreground) 20%);
|
|
165
167
|
--destructive: var(--color-error-light);
|
|
166
168
|
--destructive-foreground: var(--color-dark);
|
|
167
169
|
--warning: var(--color-amber-light);
|
|
@@ -177,6 +179,16 @@
|
|
|
177
179
|
--sidebar-ring: var(--color-sage-green);
|
|
178
180
|
}
|
|
179
181
|
|
|
182
|
+
/*
|
|
183
|
+
* Inverse / marketing bands that are not a full `.dark` theme: only interactive tints flip so ghost, outline-like controls
|
|
184
|
+
* and fields use a light ink on the dark canvas. Text colours stay whatever the band sets; put `data-surface="dark"` on the
|
|
185
|
+
* wrapper (Tailwind does not read it — it is a hook for these tokens only).
|
|
186
|
+
*/
|
|
187
|
+
[data-surface="dark"] {
|
|
188
|
+
--accent: color-mix(in oklab, var(--color-dark) 96%, var(--color-white) 4%);
|
|
189
|
+
--accent-hover: color-mix(in oklab, var(--color-dark) 92%, var(--color-white) 8%);
|
|
190
|
+
}
|
|
191
|
+
|
|
180
192
|
@theme inline {
|
|
181
193
|
--color-background: var(--background);
|
|
182
194
|
--color-foreground: var(--foreground);
|
|
@@ -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;
|