varsel 0.5.1 → 0.5.4

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 (50) hide show
  1. package/dist/VarselItem.svelte +900 -0
  2. package/dist/VarselItem.svelte.d.ts +23 -0
  3. package/dist/VarselItem.svelte.d.ts.map +1 -0
  4. package/dist/VarselManager.svelte +451 -0
  5. package/dist/VarselManager.svelte.d.ts +18 -0
  6. package/dist/VarselManager.svelte.d.ts.map +1 -0
  7. package/dist/VarselToaster.svelte +104 -0
  8. package/dist/VarselToaster.svelte.d.ts +32 -0
  9. package/dist/VarselToaster.svelte.d.ts.map +1 -0
  10. package/dist/core/accessibility.d.ts +6 -0
  11. package/dist/core/accessibility.d.ts.map +1 -0
  12. package/dist/core/accessibility.js +12 -0
  13. package/dist/core/animations.d.ts +29 -0
  14. package/dist/core/animations.d.ts.map +1 -0
  15. package/dist/core/animations.js +28 -0
  16. package/dist/core/positions.d.ts +71 -0
  17. package/dist/core/positions.d.ts.map +1 -0
  18. package/dist/core/positions.js +30 -0
  19. package/dist/core/swipe.d.ts +20 -0
  20. package/dist/core/swipe.d.ts.map +1 -0
  21. package/dist/core/swipe.js +30 -0
  22. package/dist/core/toast-factory.d.ts +3 -0
  23. package/dist/core/toast-factory.d.ts.map +1 -0
  24. package/dist/core/toast-factory.js +144 -0
  25. package/dist/core/toast-state.d.ts +49 -0
  26. package/dist/core/toast-state.d.ts.map +1 -0
  27. package/dist/core/toast-state.js +80 -0
  28. package/dist/core/toaster-instances.d.ts +28 -0
  29. package/dist/core/toaster-instances.d.ts.map +1 -0
  30. package/dist/core/toaster-instances.js +46 -0
  31. package/dist/core/types.d.ts +144 -0
  32. package/dist/core/types.d.ts.map +1 -0
  33. package/dist/core/types.js +1 -0
  34. package/dist/core/utils.d.ts +10 -0
  35. package/dist/core/utils.d.ts.map +1 -0
  36. package/dist/core/utils.js +9 -0
  37. package/dist/core/variants.d.ts +18 -0
  38. package/dist/core/variants.d.ts.map +1 -0
  39. package/dist/core/variants.js +56 -0
  40. package/dist/index.d.ts +10 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +8 -0
  43. package/dist/internals.d.ts +16 -0
  44. package/dist/internals.d.ts.map +1 -0
  45. package/dist/internals.js +14 -0
  46. package/dist/styles.css +195 -0
  47. package/dist/variant-icons.d.ts +108 -0
  48. package/dist/variant-icons.d.ts.map +1 -0
  49. package/dist/variant-icons.js +45 -0
  50. package/package.json +7 -4
@@ -0,0 +1,144 @@
1
+ import type { VariantProps } from "class-variance-authority";
2
+ import type { Component } from "svelte";
3
+ import type { toastContainerVariants } from "./variants";
4
+ import type { ToastPosition } from "./positions";
5
+ import type { SwipeAxis, SwipeDirection } from "./swipe";
6
+ /**
7
+ * Represents the data structure for a single toast notification.
8
+ */
9
+ export interface ToastData extends VariantProps<typeof toastContainerVariants> {
10
+ /** Unique identifier for the toast. */
11
+ id: string;
12
+ /** The main title of the toast notification. */
13
+ title?: string;
14
+ /** Additional details or description displayed below the title. */
15
+ description?: string;
16
+ /** Optional CSS class to apply to the toast container. */
17
+ className?: string;
18
+ /**
19
+ * Duration in milliseconds before the toast automatically closes.
20
+ * Defaults to 5000ms. Set to `0` or `Infinity` to keep open indefinitely.
21
+ */
22
+ duration?: number;
23
+ /** Whether the toast is in a loading state. */
24
+ isLoading?: boolean;
25
+ /** Whether to show the close button. Defaults to `true`. */
26
+ showClose?: boolean;
27
+ /** Optional action button to display within the toast. */
28
+ action?: {
29
+ /** Label for the action button. */
30
+ label: string;
31
+ /** Callback function executed when the action button is clicked. */
32
+ onClick: () => void;
33
+ };
34
+ /** Callback fired when the toast finishes its auto-close timer. */
35
+ onAutoClose?: () => void;
36
+ /** Callback fired when the toast is dismissed manually (button, swipe, `toast.dismiss`, etc.). */
37
+ onDismiss?: () => void;
38
+ /** Internal flag: signals that the toast should begin its closing animation. */
39
+ shouldClose?: boolean;
40
+ /** Internal flag: signals that the toast is currently leaving the DOM. */
41
+ isLeaving?: boolean;
42
+ /** The position on the screen where this toast should appear. */
43
+ position?: ToastPosition;
44
+ /** Custom Svelte component to render instead of the default toast layout. */
45
+ component?: Component<any>;
46
+ /** Props to pass to the custom component. */
47
+ componentProps?: Record<string, any>;
48
+ }
49
+ /**
50
+ * Represents the possible states for a promise-based toast.
51
+ * Can be a static message string, a ToastData object (minus ID), or a function returning one of those.
52
+ */
53
+ export type PromiseToastState<Value> = string | Omit<ToastData, "id"> | ((value: Value) => string | Omit<ToastData, "id"> | PromiseLike<string | Omit<ToastData, "id">>);
54
+ /**
55
+ * Options for the `toast.promise` function.
56
+ */
57
+ export type ToastPromiseOptions<SuccessValue = unknown, ErrorValue = unknown> = {
58
+ /** The message or data to show while the promise is pending. */
59
+ loading: Omit<ToastData, "id"> | string;
60
+ /** The message or data to show when the promise resolves successfully. */
61
+ success: PromiseToastState<SuccessValue>;
62
+ /** The message or data to show when the promise rejects. */
63
+ error: PromiseToastState<ErrorValue>;
64
+ };
65
+ /**
66
+ * The interface for the main `toast` function and its utility methods.
67
+ */
68
+ export type ToastInvoker = {
69
+ /**
70
+ * Creates a default toast notification.
71
+ * @param data - The toast options or description string.
72
+ * @returns The ID of the created toast.
73
+ */
74
+ (data: Omit<ToastData, "id"> | string): string;
75
+ /**
76
+ * Creates a success toast notification.
77
+ */
78
+ success: (data: Omit<ToastData, "id" | "variant"> | string) => string;
79
+ /**
80
+ * Creates a warning toast notification.
81
+ */
82
+ warning: (data: Omit<ToastData, "id" | "variant"> | string) => string;
83
+ /**
84
+ * Creates an info toast notification.
85
+ */
86
+ info: (data: Omit<ToastData, "id" | "variant"> | string) => string;
87
+ /**
88
+ * Creates an error toast notification.
89
+ */
90
+ error: (data: Omit<ToastData, "id" | "variant"> | string) => string;
91
+ /**
92
+ * Creates a custom component toast.
93
+ * @param component - The Svelte component to render.
94
+ * @param options - Additional options and props for the component.
95
+ */
96
+ custom: <Props extends Record<string, any> = Record<string, any>>(component: Component<Props>, options?: Omit<ToastData, "id" | "component" | "variant" | "componentProps"> & {
97
+ componentProps?: Omit<Props, "id" | "toast">;
98
+ }) => string;
99
+ /**
100
+ * Creates a toast that updates based on the state of a Promise.
101
+ * @param promise - The promise to track.
102
+ * @param options - Configuration for loading, success, and error states.
103
+ * @returns The ID of the toast.
104
+ */
105
+ promise: <T, E = unknown>(promise: PromiseLike<T>, options: ToastPromiseOptions<T, E>) => string;
106
+ /**
107
+ * Dismisses a specific toast by its ID.
108
+ * @param id - The ID of the toast to dismiss.
109
+ */
110
+ dismiss: (id: string) => void;
111
+ /**
112
+ * Dismisses all currently active toasts.
113
+ */
114
+ dismissAll: () => void;
115
+ };
116
+ /**
117
+ * Extends `ToastData` with positioning information for rendering.
118
+ */
119
+ export type PositionedToast = ToastData & {
120
+ /** The visual index of the toast in the stack. */
121
+ index: number;
122
+ /** The render order index (z-index calculation base). */
123
+ renderIndex: number;
124
+ /** Total number of toasts in the current group. */
125
+ total: number;
126
+ };
127
+ /**
128
+ * Context provided to toast items (mostly for internal use).
129
+ */
130
+ export interface VarselItemContext {
131
+ toast: PositionedToast;
132
+ onRemove: (id: string) => void;
133
+ isGroupHovered?: boolean;
134
+ expandedOffset?: number;
135
+ expandedGap?: number;
136
+ collapsedOffset?: number;
137
+ hiddenCollapsedOffset?: number;
138
+ onHeightChange?: (id: string, height: number) => void;
139
+ onGroupHoverEnter?: () => void;
140
+ }
141
+ /** Function signature for toast state subscribers. */
142
+ export type ToastSubscriber = (toasts: ToastData[]) => void;
143
+ export type { ToastPosition, SwipeAxis, SwipeDirection };
144
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,Y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AAiB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;AAE5D,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Utility function to conditionally join class names.
3
+ * A lightweight alternative to libraries like `clsx` or `classnames`,
4
+ * tailored for this project's needs.
5
+ *
6
+ * @param values - A list of class names or conditional expressions.
7
+ * @returns A single string of valid class names joined by spaces.
8
+ */
9
+ export declare const cn: (...values: Array<string | false | undefined | null>) => string;
10
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/core/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,EAAE,GAAI,GAAG,QAAQ,KAAK,CAAC,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC,WACrC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Utility function to conditionally join class names.
3
+ * A lightweight alternative to libraries like `clsx` or `classnames`,
4
+ * tailored for this project's needs.
5
+ *
6
+ * @param values - A list of class names or conditional expressions.
7
+ * @returns A single string of valid class names joined by spaces.
8
+ */
9
+ export const cn = (...values) => values.filter(Boolean).join(" ");
@@ -0,0 +1,18 @@
1
+ /**
2
+ * CVA definition for the main toast container element.
3
+ * Handles positioning logic (absolute/fixed positioning coordinates)
4
+ * and base theming (colors based on variant).
5
+ */
6
+ export declare const toastContainerVariants: (props?: ({
7
+ position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | null | undefined;
8
+ variant?: "default" | "success" | "warning" | "destructive" | "info" | "custom" | null | undefined;
9
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
+ /**
11
+ * CVA definition for the inner content wrapper of the toast.
12
+ * Useful for applying styles specific to the content area (e.g. overflow, padding overrides)
13
+ * separate from the structural container.
14
+ */
15
+ export declare const toastContentVariants: (props?: ({
16
+ variant?: "default" | "success" | "warning" | "destructive" | "info" | "custom" | null | undefined;
17
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
18
+ //# sourceMappingURL=variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/lib/core/variants.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;8EAsClC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;8EAc/B,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { cva } from "class-variance-authority";
2
+ /**
3
+ * CVA definition for the main toast container element.
4
+ * Handles positioning logic (absolute/fixed positioning coordinates)
5
+ * and base theming (colors based on variant).
6
+ */
7
+ export const toastContainerVariants = cva("pointer-events-auto fixed will-change-transform", {
8
+ variants: {
9
+ /**
10
+ * Determines where the toast is anchored on the screen.
11
+ */
12
+ position: {
13
+ "top-left": "top-4 left-4 w-full max-w-sm",
14
+ "top-center": "top-4 left-1/2 w-full max-w-sm -translate-x-1/2 transform",
15
+ "top-right": "top-4 right-4 w-full max-w-sm",
16
+ "bottom-left": "bottom-4 left-4 w-full max-w-sm",
17
+ "bottom-center": "bottom-4 left-1/2 w-full max-w-sm -translate-x-1/2 transform",
18
+ "bottom-right": "right-4 bottom-4 w-full max-w-sm",
19
+ },
20
+ /**
21
+ * Semantic variant of the toast affecting text colors.
22
+ */
23
+ variant: {
24
+ default: "rounded-vs-lg border shadow-vs-toast border-vs-border bg-vs-popover text-vs-foreground",
25
+ success: "rounded-vs-lg border shadow-vs-toast border-vs-border bg-vs-popover text-vs-success/90",
26
+ warning: "rounded-vs-lg border shadow-vs-toast border-vs-border bg-vs-popover text-vs-warning/90",
27
+ destructive: "rounded-vs-lg border shadow-vs-toast border-vs-border bg-vs-popover text-vs-destructive/90",
28
+ info: "rounded-vs-lg border shadow-vs-toast border-vs-border bg-vs-popover text-vs-info/90",
29
+ custom: "",
30
+ },
31
+ },
32
+ defaultVariants: {
33
+ position: "bottom-center",
34
+ variant: "default",
35
+ },
36
+ });
37
+ /**
38
+ * CVA definition for the inner content wrapper of the toast.
39
+ * Useful for applying styles specific to the content area (e.g. overflow, padding overrides)
40
+ * separate from the structural container.
41
+ */
42
+ export const toastContentVariants = cva("relative overflow-hidden rounded-vs-lg", {
43
+ variants: {
44
+ variant: {
45
+ default: "",
46
+ success: "",
47
+ warning: "",
48
+ destructive: "",
49
+ info: "",
50
+ custom: "",
51
+ },
52
+ },
53
+ defaultVariants: {
54
+ variant: "default",
55
+ },
56
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Public API of the Varsel library.
3
+ * Exports the main components, functions, and types required to use the library.
4
+ *
5
+ * @module varsel
6
+ */
7
+ export { default as VarselToaster } from "./VarselToaster.svelte";
8
+ export { toast } from "./internals";
9
+ export type { ToastData, ToastInvoker, ToastPosition, SwipeAxis, SwipeDirection, PositionedToast, VarselItemContext, ToastPromiseOptions, } from "./internals";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,YAAY,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,SAAS,EACT,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Public API of the Varsel library.
3
+ * Exports the main components, functions, and types required to use the library.
4
+ *
5
+ * @module varsel
6
+ */
7
+ export { default as VarselToaster } from "./VarselToaster.svelte";
8
+ export { toast } from "./internals";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Internal aggregation module.
3
+ * Re-exports core functionality to simplify imports within the library.
4
+ * This file is meant for internal package usage and shouldn't generally be imported directly by consumers.
5
+ */
6
+ export { ANIMATION_CONFIG } from "./core/animations";
7
+ export { FOCUSABLE_SELECTORS } from "./core/accessibility";
8
+ export { POSITION_CONFIGS, type ToastPosition } from "./core/positions";
9
+ export { SWIPE_DISMISS_THRESHOLD, SWIPE_DISMISS_VELOCITY, SWIPE_EXIT_DISTANCE, getDefaultSwipeDirections, type SwipeAxis, type SwipeDirection, } from "./core/swipe";
10
+ export { toastContainerVariants, toastContentVariants, } from "./core/variants";
11
+ export { cn } from "./core/utils";
12
+ export { toast } from "./core/toast-factory";
13
+ export { toastState } from "./core/toast-state";
14
+ export { toasterInstanceManager } from "./core/toaster-instances";
15
+ export type { ToastData, ToastInvoker, ToastPromiseOptions, PositionedToast, VarselItemContext, } from "./core/types";
16
+ //# sourceMappingURL=internals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internals.d.ts","sourceRoot":"","sources":["../src/lib/internals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,SAAS,EACd,KAAK,cAAc,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,sBAAsB,EACtB,oBAAoB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EACX,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,iBAAiB,GACjB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Internal aggregation module.
3
+ * Re-exports core functionality to simplify imports within the library.
4
+ * This file is meant for internal package usage and shouldn't generally be imported directly by consumers.
5
+ */
6
+ export { ANIMATION_CONFIG } from "./core/animations";
7
+ export { FOCUSABLE_SELECTORS } from "./core/accessibility";
8
+ export { POSITION_CONFIGS } from "./core/positions";
9
+ export { SWIPE_DISMISS_THRESHOLD, SWIPE_DISMISS_VELOCITY, SWIPE_EXIT_DISTANCE, getDefaultSwipeDirections, } from "./core/swipe";
10
+ export { toastContainerVariants, toastContentVariants, } from "./core/variants";
11
+ export { cn } from "./core/utils";
12
+ export { toast } from "./core/toast-factory";
13
+ export { toastState } from "./core/toast-state";
14
+ export { toasterInstanceManager } from "./core/toaster-instances";
@@ -0,0 +1,195 @@
1
+ /*
2
+ * Main stylesheet for Varsel.
3
+ * Built with Tailwind CSS v4 using the @theme directive.
4
+ *
5
+ * Defines custom CSS variables for colors, shadows, and animations.
6
+ * Supports light and dark modes via the .dark class (standard Tailwind approach).
7
+ */
8
+
9
+ @import "tailwindcss";
10
+ @source "./**/*.{svelte,js,ts}";
11
+
12
+ :root {
13
+ /* Base hue used for generating the color palette (oklch) */
14
+ --base-hue: 265;
15
+
16
+ /* Semantic color tokens */
17
+ --color-vs-popover: oklch(1 0 0);
18
+ --color-vs-popover-muted: oklch(0.96 0.002 var(--base-hue));
19
+ --color-vs-foreground: oklch(0.1408 0.0044 var(--base-hue));
20
+ --color-vs-border: oklch(0.8925 0.0014 var(--base-hue));
21
+ --color-vs-ring: oklch(0.55 0.012 var(--base-hue));
22
+ --color-vs-ring-offset: oklch(0.96 0.002 var(--base-hue));
23
+ --color-vs-destructive: oklch(0.62 0.21 25);
24
+ --color-vs-warning: oklch(0.8 0.2 75);
25
+ --color-vs-success: oklch(0.7 0.18 155);
26
+ --color-vs-info: oklch(0.7 0.18 240);
27
+
28
+ /* Shadows */
29
+ --shadow-vs-button:
30
+ 0px 1px 1px -0.5px rgba(0, 0, 0, 0.15), 0px 3px 3px -1.5px
31
+ rgba(0, 0, 0, 0.05);
32
+ --shadow-vs-toast:
33
+ 0px 1px 1px -0.5px rgba(0, 0, 0, 0.15),
34
+ 0px 3px 3px -1.5px rgba(0, 0, 0, 0.05),
35
+ 0px 6px 6px -3px rgba(0, 0, 0, 0.05),
36
+ 0px 12px 12px -6px rgba(0, 0, 0, 0.05),
37
+ 0px 24px 24px -12px rgba(0, 0, 0, 0.05),
38
+ 0px 48px 48px -24px rgba(0, 0, 0, 0.05);
39
+
40
+ /* Radius & Easing */
41
+ --radius-base: 0.125rem;
42
+ --ease-vs-button: cubic-bezier(0.25, 0.46, 0.45, 0.94);
43
+ --ease-vs-toast: cubic-bezier(0.32, 0.72, 0, 1);
44
+ --ease-vs-pop: cubic-bezier(0.18, 0.89, 0.32, 1.28);
45
+ }
46
+
47
+ .dark {
48
+ --color-vs-popover: oklch(0.2139 0.0101 var(--base-hue));
49
+ --color-vs-popover-muted: oklch(0.2502 0.016 var(--base-hue));
50
+ --color-vs-foreground: oklch(0.9824 0.0013 var(--base-hue));
51
+ --color-vs-border: oklch(0.278 0.015 var(--base-hue));
52
+ --color-vs-ring: oklch(0.58 0.012 var(--base-hue));
53
+ --color-vs-ring-offset: oklch(0.15 0.005 var(--base-hue));
54
+ --color-vs-destructive: oklch(0.72 0.27 25);
55
+ --color-vs-warning: oklch(0.82 0.24 85);
56
+ --color-vs-success: oklch(0.78 0.25 155);
57
+ --color-vs-info: oklch(0.78 0.18 240);
58
+ }
59
+
60
+ @theme {
61
+ --color-vs-popover: var(--vs-popover);
62
+ --color-vs-popover-muted: var(--vs-popover-muted);
63
+ --color-vs-foreground: var(--vs-foreground);
64
+ --color-vs-border: var(--vs-border);
65
+ --color-vs-ring: var(--vs-ring);
66
+ --color-vs-ring-offset: var(--vs-ring-offset);
67
+ --color-vs-destructive: var(--vs-destructive);
68
+ --color-vs-warning: var(--vs-warning);
69
+ --color-vs-success: var(--vs-success);
70
+ --color-vs-info: var(--vs-info);
71
+ --shadow-vs-button: var(--shadow-vs-button);
72
+ --shadow-vs-toast: var(--shadow-vs-toast);
73
+ --radius-vs-sm: calc(var(--radius-base) * 2);
74
+ --radius-vs-md: calc(var(--radius-base) * 3);
75
+ --radius-vs-lg: calc(var(--radius-base) * 4);
76
+ --ease-vs-button: var(--ease-vs-button);
77
+ --ease-vs-toast: var(--ease-vs-toast);
78
+ --ease-vs-pop: var(--ease-vs-pop);
79
+ }
80
+
81
+ /* Spinner Styles */
82
+ .vs-spinner {
83
+ display: inline-flex;
84
+ width: 1rem;
85
+ height: 1rem;
86
+ align-items: center;
87
+ justify-content: center;
88
+ flex-shrink: 0;
89
+ position: absolute;
90
+ inset: 0;
91
+ transform-origin: center;
92
+ }
93
+
94
+ .vs-spinner--active {
95
+ opacity: 1;
96
+ }
97
+
98
+ .vs-spinner--finish {
99
+ animation: vs-spinner-finish 0.42s var(--ease-vs-toast) forwards;
100
+ }
101
+
102
+ .vs-spinner svg {
103
+ width: 100%;
104
+ height: 100%;
105
+ animation: vs-spin 1s linear infinite;
106
+ }
107
+
108
+ /* Icon Styles */
109
+ .vs-icon {
110
+ display: inline-flex;
111
+ width: 1rem;
112
+ height: 1rem;
113
+ align-items: center;
114
+ justify-content: center;
115
+ flex-shrink: 0;
116
+ position: absolute;
117
+ inset: 0;
118
+ }
119
+
120
+ .vs-icon--static {
121
+ opacity: 1;
122
+ transform: scale(1);
123
+ }
124
+
125
+ .vs-icon--waiting {
126
+ opacity: 0;
127
+ transform: scale(0.75) rotate(-6deg);
128
+ }
129
+
130
+ .vs-icon--pop {
131
+ animation: vs-icon-pop 0.36s var(--ease-vs-pop) forwards;
132
+ }
133
+
134
+ .vs-icon svg {
135
+ width: 100%;
136
+ height: 100%;
137
+ }
138
+
139
+ @keyframes vs-spin {
140
+ to {
141
+ transform: rotate(360deg);
142
+ }
143
+ }
144
+
145
+ @keyframes vs-spinner-finish {
146
+ 0% {
147
+ opacity: 1;
148
+ transform: scale(1) rotate(0deg);
149
+ filter: blur(0);
150
+ }
151
+ 60% {
152
+ opacity: 0.65;
153
+ transform: scale(0.55) rotate(140deg);
154
+ filter: blur(0.3px);
155
+ }
156
+ 100% {
157
+ opacity: 0;
158
+ transform: scale(0) rotate(220deg);
159
+ filter: blur(0.8px);
160
+ }
161
+ }
162
+
163
+ @keyframes vs-icon-pop {
164
+ 0% {
165
+ opacity: 0;
166
+ transform: scale(0.5) rotate(-10deg);
167
+ filter: blur(2px);
168
+ }
169
+ 60% {
170
+ opacity: 1;
171
+ transform: scale(1.18) rotate(2deg);
172
+ filter: blur(0);
173
+ }
174
+ 100% {
175
+ opacity: 1;
176
+ transform: scale(1) rotate(0deg);
177
+ filter: blur(0);
178
+ }
179
+ }
180
+
181
+ @media (prefers-reduced-motion: reduce) {
182
+ .vs-spinner svg {
183
+ animation-duration: 2s;
184
+ }
185
+
186
+ .vs-spinner--finish {
187
+ animation-duration: 0s;
188
+ }
189
+
190
+ .vs-icon--pop {
191
+ animation: none;
192
+ opacity: 1;
193
+ transform: scale(1);
194
+ }
195
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * SVG definitions for status icons (success, warning, error).
3
+ * These are lightweight SVG path data objects rendered by the toast component.
4
+ */
5
+ import type { ToastData } from "./internals";
6
+ declare const ICON_VARIANTS: readonly ["success", "warning", "destructive", "info"];
7
+ export type IconVariant = (typeof ICON_VARIANTS)[number];
8
+ type IconElement = {
9
+ tag: "path";
10
+ d: string;
11
+ } | {
12
+ tag: "line";
13
+ x1: number;
14
+ y1: number;
15
+ x2: number;
16
+ y2: number;
17
+ } | {
18
+ tag: "circle";
19
+ cx: number;
20
+ cy: number;
21
+ r: number;
22
+ };
23
+ export interface VariantIconDefinition {
24
+ viewBox: string;
25
+ elements: IconElement[];
26
+ }
27
+ export declare const variantIconMap: {
28
+ success: {
29
+ viewBox: string;
30
+ elements: ({
31
+ tag: "circle";
32
+ cx: number;
33
+ cy: number;
34
+ r: number;
35
+ d?: undefined;
36
+ } | {
37
+ tag: "path";
38
+ d: string;
39
+ cx?: undefined;
40
+ cy?: undefined;
41
+ r?: undefined;
42
+ })[];
43
+ };
44
+ warning: {
45
+ viewBox: string;
46
+ elements: ({
47
+ tag: "path";
48
+ d: string;
49
+ x1?: undefined;
50
+ y1?: undefined;
51
+ x2?: undefined;
52
+ y2?: undefined;
53
+ } | {
54
+ tag: "line";
55
+ x1: number;
56
+ y1: number;
57
+ x2: number;
58
+ y2: number;
59
+ d?: undefined;
60
+ })[];
61
+ };
62
+ destructive: {
63
+ viewBox: string;
64
+ elements: ({
65
+ tag: "circle";
66
+ cx: number;
67
+ cy: number;
68
+ r: number;
69
+ d?: undefined;
70
+ } | {
71
+ tag: "path";
72
+ d: string;
73
+ cx?: undefined;
74
+ cy?: undefined;
75
+ r?: undefined;
76
+ })[];
77
+ };
78
+ info: {
79
+ viewBox: string;
80
+ elements: ({
81
+ tag: "circle";
82
+ cx: number;
83
+ cy: number;
84
+ r: number;
85
+ x1?: undefined;
86
+ y1?: undefined;
87
+ x2?: undefined;
88
+ y2?: undefined;
89
+ } | {
90
+ tag: "line";
91
+ x1: number;
92
+ y1: number;
93
+ x2: number;
94
+ y2: number;
95
+ cx?: undefined;
96
+ cy?: undefined;
97
+ r?: undefined;
98
+ })[];
99
+ };
100
+ };
101
+ /**
102
+ * Checks if a given toast variant has an associated icon.
103
+ * @param variant - The variant string to check.
104
+ * @returns True if the variant is one of 'success', 'warning', or 'destructive'.
105
+ */
106
+ export declare const hasVariantIcon: (variant?: ToastData["variant"]) => variant is IconVariant;
107
+ export {};
108
+ //# sourceMappingURL=variant-icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant-icons.d.ts","sourceRoot":"","sources":["../src/lib/variant-icons.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,QAAA,MAAM,aAAa,wDAAyD,CAAC;AAE7E,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,KAAK,WAAW,GACb;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1B;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,GAAG,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC2B,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAC1B,UAAU,SAAS,CAAC,SAAS,CAAC,KAC5B,OAAO,IAAI,WAEb,CAAC"}
@@ -0,0 +1,45 @@
1
+ const ICON_VARIANTS = ["success", "warning", "destructive", "info"];
2
+ export const variantIconMap = {
3
+ success: {
4
+ viewBox: "0 0 24 24",
5
+ elements: [
6
+ { tag: "circle", cx: 12, cy: 12, r: 10 },
7
+ { tag: "path", d: "m9 12 2 2 4-4" },
8
+ ],
9
+ },
10
+ warning: {
11
+ viewBox: "0 0 24 24",
12
+ elements: [
13
+ {
14
+ tag: "path",
15
+ d: "M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z",
16
+ },
17
+ { tag: "line", x1: 12, y1: 9, x2: 12, y2: 13 },
18
+ { tag: "line", x1: 12, y1: 17, x2: 12.01, y2: 17 },
19
+ ],
20
+ },
21
+ destructive: {
22
+ viewBox: "0 0 24 24",
23
+ elements: [
24
+ { tag: "circle", cx: 12, cy: 12, r: 10 },
25
+ { tag: "path", d: "m15 9-6 6" },
26
+ { tag: "path", d: "m9 9 6 6" },
27
+ ],
28
+ },
29
+ info: {
30
+ viewBox: "0 0 24 24",
31
+ elements: [
32
+ { tag: "circle", cx: 12, cy: 12, r: 10 },
33
+ { tag: "line", x1: 12, y1: 16, x2: 12, y2: 12 },
34
+ { tag: "line", x1: 12, y1: 8, x2: 12.01, y2: 8 },
35
+ ],
36
+ },
37
+ };
38
+ /**
39
+ * Checks if a given toast variant has an associated icon.
40
+ * @param variant - The variant string to check.
41
+ * @returns True if the variant is one of 'success', 'warning', or 'destructive'.
42
+ */
43
+ export const hasVariantIcon = (variant) => {
44
+ return Boolean(variant && ICON_VARIANTS.includes(variant));
45
+ };