@widgetic/design-system 0.5.31 → 0.5.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/components/EmptyState.svelte +5 -2
  2. package/dist/components/modals/ActionModal.svelte +10 -9
  3. package/dist/components/modals/README.md +1 -1
  4. package/dist/components/navigation/Breadcrumbs.svelte +11 -3
  5. package/dist/components/navigation/Breadcrumbs.svelte.d.ts +2 -0
  6. package/dist/components/navigation/types.d.ts +4 -0
  7. package/dist/components/shell/SettingsDialog.svelte +59 -11
  8. package/dist/components/shell/WidgetRow.svelte +8 -1
  9. package/dist/components/shell/WidgetRow.svelte.d.ts +2 -0
  10. package/dist/components/toast/ToasterModal.svelte +54 -10
  11. package/dist/components/toast/ToasterModal.svelte.d.ts +6 -1
  12. package/dist/components/toast/toastDismissCountdown.d.ts +5 -0
  13. package/dist/components/toast/toastDismissCountdown.js +47 -0
  14. package/dist/components/toast/toastDismissCountdownPayload.d.ts +16 -0
  15. package/dist/components/toast/toastDismissCountdownPayload.js +24 -0
  16. package/dist/components/ui/dialog/DialogLayerSync.svelte +38 -0
  17. package/dist/components/ui/dialog/DialogLayerSync.svelte.d.ts +8 -0
  18. package/dist/components/ui/dialog/dialog-content.svelte +63 -20
  19. package/dist/components/ui/dialog/dialog-content.svelte.d.ts +1 -0
  20. package/dist/components/ui/dialog/dialog-overlay.svelte +24 -20
  21. package/dist/components/ui/dialog/overlay-layer-context.d.ts +8 -0
  22. package/dist/components/ui/dialog/overlay-layer-context.js +1 -0
  23. package/dist/components/ui/drawer/drawer-content.svelte +25 -1
  24. package/dist/components/ui/drawer/drawer-overlay.svelte +32 -5
  25. package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +3 -1
  26. package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +3 -1
  27. package/dist/components/ui/hover-card/hover-card-content.svelte +3 -1
  28. package/dist/components/ui/popover/popover-content.svelte +3 -1
  29. package/dist/components/ui/select/select-content.svelte +3 -1
  30. package/dist/components/ui/tooltip/tooltip-content.svelte +3 -1
  31. package/dist/styles/global.css +33 -61
  32. package/dist/styles/tokens.css +19 -7
  33. package/dist/utils/overlayLayerStack.d.ts +54 -0
  34. package/dist/utils/overlayLayerStack.js +89 -0
  35. package/dist/utils/overlayMotion.d.ts +14 -46
  36. package/dist/utils/overlayMotion.js +36 -63
  37. package/package.json +1 -1
@@ -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;
@@ -1,86 +1,59 @@
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
+ /** Backdrop scrim + card motion duration (ms). */
8
6
  export const overlayTransitionDurationMs = 200;
9
- /** Easing for open/close (Svelte transition easing function — matches “cubic out” in the legacy modals). */
10
7
  export const overlayTransitionEasing = 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
8
  export const overlayBackdropBlurPx = 3;
16
- /** Content scale at the start of the open transition / end of the close transition. */
17
9
  export 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
10
  export const overlayContentSlideDistance = 5;
23
- /** Pixel slide distance for Svelte `fly` on centred modals (Tailwind spacing step 5 → 20px). */
24
11
  export const overlayContentSlidePx = overlayContentSlideDistance * 4;
25
- /** Tailwind slide utilities for centred dialog panels (not drawers/sheets that enter from the side). */
26
12
  export const overlayDialogContentSlideClasses = [
27
13
  `data-[state=closed]:slide-out-to-bottom-${overlayContentSlideDistance}`,
28
14
  `data-[state=open]:slide-in-from-bottom-${overlayContentSlideDistance}`
29
15
  ];
30
- /**
31
- * Tailwind duration class — must be a source literal so Tailwind's scanner emits `duration-[200ms]`.
32
- * Kept in sync with `overlayTransitionDurationMs` (see tests/overlayMotionDuration.test.ts).
33
- */
34
16
  export const overlayDurationClass = 'duration-[200ms]';
35
- /**
36
- * bits-ui applies `data-[state=open]:animate-in` at specificity 0,2,0 with a 150ms default duration, which beats a
37
- * plain `duration-[200ms]` (0,1,0). These state-scoped arbitrary properties match open/closed and win in cascade.
38
- * Literal strings — keep in sync with `overlayTransitionDurationMs`.
39
- */
40
- export const overlayDialogOpenClosedAnimationDurationClasses = [
41
- 'data-[state=open]:[animation-duration:200ms]',
42
- 'data-[state=closed]:[animation-duration:200ms]'
43
- ];
44
- /**
45
- * The scrim colour: the muted foreground token (neutral 550 in the design system) at 80%. The opacity is part of the colour, not of
46
- * the layer, because an element that is itself translucent would not blur what is behind it. Literal so Tailwind's
47
- * scanner emits it; `bg-muted-foreground/80` is the Figma scrim (`Foundations / Overlay`).
48
- */
49
17
  export const overlayScrimColorClass = 'bg-muted-foreground/80';
50
- /** Backdrop blur class — matches `overlayBackdropBlurPx`. Literal for the same reason as the colour. */
51
18
  export const overlayBackdropBlurClass = 'backdrop-blur-[3px]';
52
- /**
53
- * The whole scrim: colour and blur. Every surface that dims the page behind a panel (dialogs, modals, drawers, the
54
- * navigation drawer) uses these two classes, so the overlay looks the same everywhere. Written out, not joined from the
55
- * two constants above, so the scanner of Tailwind finds both classes in this one literal as well.
56
- */
57
19
  export const overlayScrimClasses = 'bg-muted-foreground/80 backdrop-blur-[3px]';
58
- /** Tailwind arbitrary easing approximating Svelte `cubicOut` (ease-out cubic, 1 − (1 − t)³). */
59
20
  export const overlayEasingClass = 'ease-[cubic-bezier(0.33,1,0.68,1)]';
60
- /**
61
- * A scrim drawn over another scrim only dims: the one below blurs the page already, and two backdrop blurs that fade
62
- * in together flicker. `markStackedScrim` (`overlayStacking.ts`) puts `data-stacked` on such a scrim, and this takes its
63
- * blur off. Literal so Tailwind's scanner emits it.
64
- */
65
21
  export const overlayStackedScrimClass = 'data-[stacked]:backdrop-blur-none';
66
- /** Overlay + panel classes for bits-ui Dialog (fade + slide, 200ms, cubic-out-like; no zoom). */
22
+ /** Scrim surface classes only (motion is Svelte `fade` on the overlay child element). */
67
23
  export const overlayDialogOverlayClasses = [
68
24
  overlayScrimClasses,
69
- overlayStackedScrimClass,
70
- overlayDurationClass,
71
- overlayEasingClass,
72
- ...overlayDialogOpenClosedAnimationDurationClasses,
73
- `data-[state=open]:animate-in`,
74
- `data-[state=closed]:animate-out`,
75
- `data-[state=closed]:fade-out-0`,
76
- `data-[state=open]:fade-in-0`
77
- ].join(' ');
78
- /** Centred dialog panel motion is keyed in global.css (`widgetic-dialog-enter/exit`) so slide composes with -translate-x/y-1/2. */
79
- export const overlayDialogContentClasses = [
80
- overlayDurationClass,
81
- overlayEasingClass,
82
- 'widgetic-dialog-panel-motion',
83
- ...overlayDialogOpenClosedAnimationDurationClasses
25
+ overlayStackedScrimClass
84
26
  ].join(' ');
85
- /** Applied with overlay dialog classes so users who prefer reduced motion get instant open/close. */
86
- export const overlayReducedMotionClasses = 'motion-reduce:!duration-0 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none';
27
+ /** Card chrome inside the flex-centred dialog host (no fixed positioning on the card itself). */
28
+ export const overlayDialogPanelCardClasses = 'relative';
29
+ /** Full-viewport host that centres the card (see `dialog-content.svelte`). */
30
+ export const overlayDialogPanelLayoutClasses = 'fixed inset-0 flex items-center justify-center';
31
+ /** @deprecated Kept for grep tests; motion no longer uses Tailwind animate utilities. */
32
+ export const overlayDialogContentClasses = overlayDialogPanelLayoutClasses;
33
+ /** @deprecated */
34
+ export const overlayDialogContentMotionClasses = overlayDialogPanelLayoutClasses;
35
+ export const overlayReducedMotionClasses = 'motion-reduce:transition-none';
36
+ export function prefersReducedOverlayMotion() {
37
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
38
+ return false;
39
+ return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
40
+ }
41
+ function isVitestEnvironment() {
42
+ return typeof process !== 'undefined' && (process.env.VITEST === 'true' || process.env.NODE_ENV === 'test');
43
+ }
44
+ export function overlayScrimFadeTransition(reducedMotion = prefersReducedOverlayMotion()) {
45
+ if (isVitestEnvironment() || reducedMotion)
46
+ return { duration: 0 };
47
+ return { duration: overlayTransitionDurationMs, easing: overlayTransitionEasing };
48
+ }
49
+ export function overlayPanelFlyTransition(reducedMotion = prefersReducedOverlayMotion()) {
50
+ if (isVitestEnvironment() || reducedMotion) {
51
+ return { duration: 0, y: 0, opacity: 1 };
52
+ }
53
+ return {
54
+ duration: overlayTransitionDurationMs,
55
+ y: overlayContentSlidePx,
56
+ opacity: 0,
57
+ easing: overlayTransitionEasing
58
+ };
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/design-system",
3
- "version": "0.5.31",
3
+ "version": "0.5.33",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "svelte": "./dist/index.js",