varsel 0.1.0

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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/dist/VarselItem.svelte +875 -0
  4. package/dist/VarselItem.svelte.d.ts +31 -0
  5. package/dist/VarselItem.svelte.d.ts.map +1 -0
  6. package/dist/VarselManager.svelte +387 -0
  7. package/dist/VarselManager.svelte.d.ts +24 -0
  8. package/dist/VarselManager.svelte.d.ts.map +1 -0
  9. package/dist/VarselToaster.svelte +46 -0
  10. package/dist/VarselToaster.svelte.d.ts +22 -0
  11. package/dist/VarselToaster.svelte.d.ts.map +1 -0
  12. package/dist/core/accessibility.d.ts +2 -0
  13. package/dist/core/accessibility.d.ts.map +1 -0
  14. package/dist/core/accessibility.js +8 -0
  15. package/dist/core/animations.d.ts +14 -0
  16. package/dist/core/animations.d.ts.map +1 -0
  17. package/dist/core/animations.js +13 -0
  18. package/dist/core/positions.d.ts +64 -0
  19. package/dist/core/positions.d.ts.map +1 -0
  20. package/dist/core/positions.js +26 -0
  21. package/dist/core/swipe.d.ts +8 -0
  22. package/dist/core/swipe.d.ts.map +1 -0
  23. package/dist/core/swipe.js +20 -0
  24. package/dist/core/toast-factory.d.ts +3 -0
  25. package/dist/core/toast-factory.d.ts.map +1 -0
  26. package/dist/core/toast-factory.js +67 -0
  27. package/dist/core/toast-state.d.ts +17 -0
  28. package/dist/core/toast-state.d.ts.map +1 -0
  29. package/dist/core/toast-state.js +47 -0
  30. package/dist/core/toaster-instances.d.ts +10 -0
  31. package/dist/core/toaster-instances.d.ts.map +1 -0
  32. package/dist/core/toaster-instances.js +21 -0
  33. package/dist/core/types.d.ts +55 -0
  34. package/dist/core/types.d.ts.map +1 -0
  35. package/dist/core/types.js +1 -0
  36. package/dist/core/utils.d.ts +2 -0
  37. package/dist/core/utils.d.ts.map +1 -0
  38. package/dist/core/utils.js +1 -0
  39. package/dist/core/variants.d.ts +8 -0
  40. package/dist/core/variants.d.ts.map +1 -0
  41. package/dist/core/variants.js +36 -0
  42. package/dist/index.d.ts +4 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +2 -0
  45. package/dist/internals.d.ts +11 -0
  46. package/dist/internals.d.ts.map +1 -0
  47. package/dist/internals.js +9 -0
  48. package/dist/styles.css +174 -0
  49. package/dist/variant-icons.d.ts +77 -0
  50. package/dist/variant-icons.d.ts.map +1 -0
  51. package/dist/variant-icons.js +32 -0
  52. package/package.json +61 -0
@@ -0,0 +1,20 @@
1
+ export const SWIPE_DISMISS_THRESHOLD = 45;
2
+ export const SWIPE_DISMISS_VELOCITY = 0.11;
3
+ export const SWIPE_EXIT_DISTANCE = 600;
4
+ export const getDefaultSwipeDirections = (position) => {
5
+ if (!position) {
6
+ return ["top", "bottom", "left", "right"];
7
+ }
8
+ const [vertical, horizontal] = position.split("-");
9
+ const directions = [];
10
+ if (vertical === "top" || vertical === "bottom") {
11
+ directions.push(vertical);
12
+ }
13
+ if (horizontal === "left" || horizontal === "right") {
14
+ directions.push(horizontal);
15
+ }
16
+ if (directions.length === 0) {
17
+ directions.push("top", "bottom");
18
+ }
19
+ return directions;
20
+ };
@@ -0,0 +1,3 @@
1
+ import type { ToastInvoker } from "./types";
2
+ export declare const toast: ToastInvoker;
3
+ //# sourceMappingURL=toast-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast-factory.d.ts","sourceRoot":"","sources":["../../src/lib/core/toast-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGX,YAAY,EAEZ,MAAM,SAAS,CAAC;AAkGjB,eAAO,MAAM,KAAK,cAAc,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { toastState } from "./toast-state";
2
+ const normalizeToastData = (data) => {
3
+ if (typeof data === "string") {
4
+ return { description: data };
5
+ }
6
+ return data;
7
+ };
8
+ const resolvePromiseState = async (value, state) => {
9
+ const resolved = typeof state === "function" ? await state(value) : await state;
10
+ return normalizeToastData(resolved);
11
+ };
12
+ const createToast = ((data) => {
13
+ return toastState.add(normalizeToastData(data));
14
+ });
15
+ createToast.success = (data) => {
16
+ if (typeof data === "string") {
17
+ return toastState.add({ description: data, variant: "success" });
18
+ }
19
+ return toastState.add({ ...data, variant: "success" });
20
+ };
21
+ createToast.warning = (data) => {
22
+ if (typeof data === "string") {
23
+ return toastState.add({ description: data, variant: "warning" });
24
+ }
25
+ return toastState.add({ ...data, variant: "warning" });
26
+ };
27
+ createToast.error = (data) => {
28
+ if (typeof data === "string") {
29
+ return toastState.add({ description: data, variant: "destructive" });
30
+ }
31
+ return toastState.add({ ...data, variant: "destructive" });
32
+ };
33
+ createToast.promise = (promise, options) => {
34
+ const loadingData = normalizeToastData(options.loading);
35
+ const toastId = toastState.add({
36
+ ...loadingData,
37
+ duration: loadingData.duration ?? 0,
38
+ isLoading: true,
39
+ showClose: loadingData.showClose ?? false,
40
+ });
41
+ const handleResult = async (state, value, defaultVariant) => {
42
+ const payload = await resolvePromiseState(value, state);
43
+ toastState.update(toastId, {
44
+ ...payload,
45
+ isLoading: false,
46
+ duration: payload.duration,
47
+ variant: payload.variant ?? defaultVariant,
48
+ showClose: payload.showClose ?? false,
49
+ });
50
+ };
51
+ Promise.resolve(promise)
52
+ .then(async (value) => {
53
+ await handleResult(options.success, value, "success");
54
+ return value;
55
+ })
56
+ .catch(async (error) => {
57
+ await handleResult(options.error, error, "destructive");
58
+ });
59
+ return toastId;
60
+ };
61
+ createToast.dismiss = (id) => {
62
+ toastState.update(id, { shouldClose: true });
63
+ };
64
+ createToast.dismissAll = () => {
65
+ toastState.dismissAll();
66
+ };
67
+ export const toast = createToast;
@@ -0,0 +1,17 @@
1
+ import type { ToastData, ToastSubscriber } from "./types";
2
+ declare class ToastState {
3
+ private toasts;
4
+ private subscribers;
5
+ private idCounter;
6
+ subscribe(callback: ToastSubscriber): () => void;
7
+ private notify;
8
+ private generateId;
9
+ add(data: Omit<ToastData, "id">): string;
10
+ remove(id: string): void;
11
+ update(id: string, data: Partial<ToastData>): void;
12
+ dismissAll(): void;
13
+ getToasts(): ToastData[];
14
+ }
15
+ export declare const toastState: ToastState;
16
+ export { ToastState };
17
+ //# sourceMappingURL=toast-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast-state.d.ts","sourceRoot":"","sources":["../../src/lib/core/toast-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1D,cAAM,UAAU;IACf,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,SAAS,CAAK;IAEtB,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,IAAI;IAOhD,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,UAAU;IAIlB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,MAAM;IAQxC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKxB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;IAOlD,UAAU,IAAI,IAAI;IASlB,SAAS,IAAI,SAAS,EAAE;CAGxB;AAED,eAAO,MAAM,UAAU,YAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,47 @@
1
+ class ToastState {
2
+ toasts = [];
3
+ subscribers = new Set();
4
+ idCounter = 0;
5
+ subscribe(callback) {
6
+ this.subscribers.add(callback);
7
+ return () => {
8
+ this.subscribers.delete(callback);
9
+ };
10
+ }
11
+ notify() {
12
+ this.subscribers.forEach((callback) => {
13
+ callback([...this.toasts]);
14
+ });
15
+ }
16
+ generateId() {
17
+ return `toast-${Date.now()}-${++this.idCounter}`;
18
+ }
19
+ add(data) {
20
+ const id = this.generateId();
21
+ const newToast = { ...data, id };
22
+ this.toasts = [newToast, ...this.toasts];
23
+ this.notify();
24
+ return id;
25
+ }
26
+ remove(id) {
27
+ this.toasts = this.toasts.filter((toast) => toast.id !== id);
28
+ this.notify();
29
+ }
30
+ update(id, data) {
31
+ this.toasts = this.toasts.map((toast) => toast.id === id ? { ...toast, ...data } : toast);
32
+ this.notify();
33
+ }
34
+ dismissAll() {
35
+ this.toasts = this.toasts.map((toast) => ({
36
+ ...toast,
37
+ shouldClose: true,
38
+ duration: 0,
39
+ }));
40
+ this.notify();
41
+ }
42
+ getToasts() {
43
+ return [...this.toasts];
44
+ }
45
+ }
46
+ export const toastState = new ToastState();
47
+ export { ToastState };
@@ -0,0 +1,10 @@
1
+ declare class ToasterInstanceManager {
2
+ private activeInstanceId;
3
+ private instanceCounter;
4
+ registerInstance(): string;
5
+ unregisterInstance(instanceId: string): void;
6
+ isActiveInstance(instanceId: string): boolean;
7
+ }
8
+ export declare const toasterInstanceManager: ToasterInstanceManager;
9
+ export { ToasterInstanceManager };
10
+ //# sourceMappingURL=toaster-instances.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toaster-instances.d.ts","sourceRoot":"","sources":["../../src/lib/core/toaster-instances.ts"],"names":[],"mappings":"AAAA,cAAM,sBAAsB;IAC3B,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,eAAe,CAAK;IAE5B,gBAAgB,IAAI,MAAM;IAQ1B,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAM5C,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAG7C;AAED,eAAO,MAAM,sBAAsB,wBAA+B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ class ToasterInstanceManager {
2
+ activeInstanceId = null;
3
+ instanceCounter = 0;
4
+ registerInstance() {
5
+ const instanceId = `toaster-${++this.instanceCounter}`;
6
+ if (!this.activeInstanceId) {
7
+ this.activeInstanceId = instanceId;
8
+ }
9
+ return instanceId;
10
+ }
11
+ unregisterInstance(instanceId) {
12
+ if (this.activeInstanceId === instanceId) {
13
+ this.activeInstanceId = null;
14
+ }
15
+ }
16
+ isActiveInstance(instanceId) {
17
+ return this.activeInstanceId === instanceId;
18
+ }
19
+ }
20
+ export const toasterInstanceManager = new ToasterInstanceManager();
21
+ export { ToasterInstanceManager };
@@ -0,0 +1,55 @@
1
+ import type { VariantProps } from "class-variance-authority";
2
+ import type { toastContainerVariants } from "./variants";
3
+ import type { ToastPosition } from "./positions";
4
+ import type { SwipeAxis, SwipeDirection } from "./swipe";
5
+ export interface ToastData extends VariantProps<typeof toastContainerVariants> {
6
+ id: string;
7
+ title?: string;
8
+ description?: string;
9
+ className?: string;
10
+ duration?: number;
11
+ isLoading?: boolean;
12
+ showClose?: boolean;
13
+ action?: {
14
+ label: string;
15
+ onClick: () => void;
16
+ };
17
+ onClose?: () => void;
18
+ shouldClose?: boolean;
19
+ isLeaving?: boolean;
20
+ position?: ToastPosition;
21
+ }
22
+ export type PromiseToastState<Value> = string | Omit<ToastData, "id"> | ((value: Value) => string | Omit<ToastData, "id"> | PromiseLike<string | Omit<ToastData, "id">>);
23
+ export type ToastPromiseOptions<SuccessValue = unknown, ErrorValue = unknown> = {
24
+ loading: Omit<ToastData, "id"> | string;
25
+ success: PromiseToastState<SuccessValue>;
26
+ error: PromiseToastState<ErrorValue>;
27
+ };
28
+ export type ToastInvoker = {
29
+ (data: Omit<ToastData, "id"> | string): string;
30
+ success: (data: Omit<ToastData, "id" | "variant"> | string) => string;
31
+ warning: (data: Omit<ToastData, "id" | "variant"> | string) => string;
32
+ error: (data: Omit<ToastData, "id" | "variant"> | string) => string;
33
+ promise: <T, E = unknown>(promise: PromiseLike<T>, options: ToastPromiseOptions<T, E>) => string;
34
+ dismiss: (id: string) => void;
35
+ dismissAll: () => void;
36
+ };
37
+ export type PositionedToast = ToastData & {
38
+ index: number;
39
+ renderIndex: number;
40
+ total: number;
41
+ };
42
+ export interface VarselItemContext {
43
+ toast: PositionedToast;
44
+ onRemove: (id: string) => void;
45
+ isGroupHovered?: boolean;
46
+ expandedOffset?: number;
47
+ expandedGap?: number;
48
+ collapsedOffset?: number;
49
+ hiddenCollapsedOffset?: number;
50
+ onHeightChange?: (id: string, height: number) => void;
51
+ onGroupHoverEnter?: () => void;
52
+ }
53
+ export type ToastSubscriber = (toasts: ToastData[]) => void;
54
+ export type { ToastPosition, SwipeAxis, SwipeDirection };
55
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/core/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const cn: (...values: Array<string | false | undefined | null>) => string;
2
+ //# 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,eAAO,MAAM,EAAE,GAAI,GAAG,QAAQ,KAAK,CAAC,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC,WACrC,CAAC"}
@@ -0,0 +1 @@
1
+ export const cn = (...values) => values.filter(Boolean).join(" ");
@@ -0,0 +1,8 @@
1
+ export declare const toastContainerVariants: (props?: ({
2
+ position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | null | undefined;
3
+ variant?: "default" | "success" | "warning" | "destructive" | null | undefined;
4
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
5
+ export declare const toastContentVariants: (props?: ({
6
+ variant?: "default" | "success" | "warning" | "destructive" | null | undefined;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
+ //# 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,eAAO,MAAM,sBAAsB;;;8EA0BlC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;8EAY/B,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { cva } from "class-variance-authority";
2
+ export const toastContainerVariants = cva("pointer-events-auto fixed rounded-vs-lg border shadow-vs-toast will-change-transform border-vs-border bg-vs-popover", {
3
+ variants: {
4
+ position: {
5
+ "top-left": "top-4 left-4 w-full max-w-sm",
6
+ "top-center": "top-4 left-1/2 w-full max-w-sm -translate-x-1/2 transform",
7
+ "top-right": "top-4 right-4 w-full max-w-sm",
8
+ "bottom-left": "bottom-4 left-4 w-full max-w-sm",
9
+ "bottom-center": "bottom-4 left-1/2 w-full max-w-sm -translate-x-1/2 transform",
10
+ "bottom-right": "right-4 bottom-4 w-full max-w-sm",
11
+ },
12
+ variant: {
13
+ default: "text-vs-foreground",
14
+ success: "text-vs-success/90",
15
+ warning: "text-vs-warning/90",
16
+ destructive: "text-vs-destructive/90",
17
+ },
18
+ },
19
+ defaultVariants: {
20
+ position: "bottom-center",
21
+ variant: "default",
22
+ },
23
+ });
24
+ export const toastContentVariants = cva("relative overflow-hidden rounded-vs-lg", {
25
+ variants: {
26
+ variant: {
27
+ default: "",
28
+ success: "",
29
+ warning: "",
30
+ destructive: "",
31
+ },
32
+ },
33
+ defaultVariants: {
34
+ variant: "default",
35
+ },
36
+ });
@@ -0,0 +1,4 @@
1
+ export { default as VarselToaster } from "./VarselToaster.svelte";
2
+ export { toast } from "./internals";
3
+ export type { ToastData, ToastInvoker, ToastPosition, SwipeAxis, SwipeDirection, PositionedToast, VarselItemContext, ToastPromiseOptions, } from "./internals";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,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,2 @@
1
+ export { default as VarselToaster } from "./VarselToaster.svelte";
2
+ export { toast } from "./internals";
@@ -0,0 +1,11 @@
1
+ export { ANIMATION_CONFIG } from "./core/animations";
2
+ export { FOCUSABLE_SELECTORS } from "./core/accessibility";
3
+ export { POSITION_CONFIGS, type ToastPosition } from "./core/positions";
4
+ export { SWIPE_DISMISS_THRESHOLD, SWIPE_DISMISS_VELOCITY, SWIPE_EXIT_DISTANCE, getDefaultSwipeDirections, type SwipeAxis, type SwipeDirection, } from "./core/swipe";
5
+ export { toastContainerVariants, toastContentVariants, } from "./core/variants";
6
+ export { cn } from "./core/utils";
7
+ export { toast } from "./core/toast-factory";
8
+ export { toastState } from "./core/toast-state";
9
+ export { toasterInstanceManager } from "./core/toaster-instances";
10
+ export type { ToastData, ToastInvoker, ToastPromiseOptions, PositionedToast, VarselItemContext, } from "./core/types";
11
+ //# sourceMappingURL=internals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internals.d.ts","sourceRoot":"","sources":["../src/lib/internals.ts"],"names":[],"mappings":"AAAA,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,9 @@
1
+ export { ANIMATION_CONFIG } from "./core/animations";
2
+ export { FOCUSABLE_SELECTORS } from "./core/accessibility";
3
+ export { POSITION_CONFIGS } from "./core/positions";
4
+ export { SWIPE_DISMISS_THRESHOLD, SWIPE_DISMISS_VELOCITY, SWIPE_EXIT_DISTANCE, getDefaultSwipeDirections, } from "./core/swipe";
5
+ export { toastContainerVariants, toastContentVariants, } from "./core/variants";
6
+ export { cn } from "./core/utils";
7
+ export { toast } from "./core/toast-factory";
8
+ export { toastState } from "./core/toast-state";
9
+ export { toasterInstanceManager } from "./core/toaster-instances";
@@ -0,0 +1,174 @@
1
+ @import "tailwindcss";
2
+ @source "./**/*.{svelte,js}";
3
+
4
+ :root {
5
+ --base-hue: 265;
6
+ --color-vs-popover: oklch(1 0 0);
7
+ --color-vs-popover-muted: oklch(0.96 0.002 var(--base-hue));
8
+ --color-vs-foreground: oklch(0.1408 0.0044 var(--base-hue));
9
+ --color-vs-border: oklch(0.8925 0.0014 var(--base-hue));
10
+ --color-vs-ring: oklch(0.55 0.012 var(--base-hue));
11
+ --color-vs-ring-offset: oklch(0.96 0.002 var(--base-hue));
12
+ --color-vs-destructive: oklch(0.62 0.21 25);
13
+ --color-vs-warning: oklch(0.8 0.2 75);
14
+ --color-vs-success: oklch(0.7 0.18 155);
15
+
16
+ --shadow-vs-button:
17
+ 0px 1px 1px -0.5px rgba(0, 0, 0, 0.15), 0px 3px 3px -1.5px
18
+ rgba(0, 0, 0, 0.05);
19
+ --shadow-vs-toast:
20
+ 0px 1px 1px -0.5px rgba(0, 0, 0, 0.15),
21
+ 0px 3px 3px -1.5px rgba(0, 0, 0, 0.05),
22
+ 0px 6px 6px -3px rgba(0, 0, 0, 0.05),
23
+ 0px 12px 12px -6px rgba(0, 0, 0, 0.05),
24
+ 0px 24px 24px -12px rgba(0, 0, 0, 0.05),
25
+ 0px 48px 48px -24px rgba(0, 0, 0, 0.05);
26
+ --radius-base: 0.125rem;
27
+ --ease-vs-button: cubic-bezier(0.25, 0.46, 0.45, 0.94);
28
+ --ease-vs-toast: cubic-bezier(0.32, 0.72, 0, 1);
29
+ }
30
+
31
+ .dark {
32
+ --color-vs-popover: oklch(0.2139 0.0101 var(--base-hue));
33
+ --color-vs-popover-muted: oklch(0.2502 0.016 var(--base-hue));
34
+ --color-vs-foreground: oklch(0.9824 0.0013 var(--base-hue));
35
+ --color-vs-border: oklch(0.278 0.015 var(--base-hue));
36
+ --color-vs-ring: oklch(0.58 0.012 var(--base-hue));
37
+ --color-vs-ring-offset: oklch(0.15 0.005 var(--base-hue));
38
+ --color-vs-destructive: oklch(0.72 0.27 25);
39
+ --color-vs-warning: oklch(0.82 0.24 85);
40
+ --color-vs-success: oklch(0.78 0.25 155);
41
+ }
42
+
43
+ @theme {
44
+ --color-vs-popover: var(--vs-popover);
45
+ --color-vs-popover-muted: var(--vs-popover-muted);
46
+ --color-vs-foreground: var(--vs-foreground);
47
+ --color-vs-border: var(--vs-border);
48
+ --color-vs-ring: var(--vs-ring);
49
+ --color-vs-ring-offset: var(--vs-ring-offset);
50
+ --color-vs-destructive: var(--vs-destructive);
51
+ --color-vs-warning: var(--vs-warning);
52
+ --color-vs-success: var(--vs-success);
53
+ --shadow-vs-button: var(--shadow-vs-button);
54
+ --shadow-vs-toast: var(--shadow-vs-toast);
55
+ --radius-vs-sm: calc(var(--radius-base) * 2);
56
+ --radius-vs-md: calc(var(--radius-base) * 3);
57
+ --radius-vs-lg: calc(var(--radius-base) * 4);
58
+ --ease-vs-button: var(--ease-vs-button);
59
+ --ease-vs-toast: var(--ease-vs-toast);
60
+ }
61
+
62
+ .vs-spinner {
63
+ display: inline-flex;
64
+ width: 1rem;
65
+ height: 1rem;
66
+ align-items: center;
67
+ justify-content: center;
68
+ flex-shrink: 0;
69
+ position: absolute;
70
+ inset: 0;
71
+ transform-origin: center;
72
+ }
73
+
74
+ .vs-spinner--active {
75
+ opacity: 1;
76
+ }
77
+
78
+ .vs-spinner--finish {
79
+ animation: vs-spinner-finish 0.42s cubic-bezier(0.32, 0.72, 0, 1) forwards;
80
+ }
81
+
82
+ .vs-spinner svg {
83
+ width: 100%;
84
+ height: 100%;
85
+ animation: vs-spin 1s linear infinite;
86
+ }
87
+
88
+ .vs-icon {
89
+ display: inline-flex;
90
+ width: 1rem;
91
+ height: 1rem;
92
+ align-items: center;
93
+ justify-content: center;
94
+ flex-shrink: 0;
95
+ position: absolute;
96
+ inset: 0;
97
+ }
98
+
99
+ .vs-icon--static {
100
+ opacity: 1;
101
+ transform: scale(1);
102
+ }
103
+
104
+ .vs-icon--waiting {
105
+ opacity: 0;
106
+ transform: scale(0.75) rotate(-6deg);
107
+ }
108
+
109
+ .vs-icon--pop {
110
+ animation: vs-icon-pop 0.36s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
111
+ }
112
+
113
+ .vs-icon svg {
114
+ width: 100%;
115
+ height: 100%;
116
+ }
117
+
118
+ @keyframes vs-spin {
119
+ to {
120
+ transform: rotate(360deg);
121
+ }
122
+ }
123
+
124
+ @keyframes vs-spinner-finish {
125
+ 0% {
126
+ opacity: 1;
127
+ transform: scale(1) rotate(0deg);
128
+ filter: blur(0);
129
+ }
130
+ 60% {
131
+ opacity: 0.65;
132
+ transform: scale(0.55) rotate(140deg);
133
+ filter: blur(0.3px);
134
+ }
135
+ 100% {
136
+ opacity: 0;
137
+ transform: scale(0) rotate(220deg);
138
+ filter: blur(0.8px);
139
+ }
140
+ }
141
+
142
+ @keyframes vs-icon-pop {
143
+ 0% {
144
+ opacity: 0;
145
+ transform: scale(0.5) rotate(-10deg);
146
+ filter: blur(2px);
147
+ }
148
+ 60% {
149
+ opacity: 1;
150
+ transform: scale(1.18) rotate(2deg);
151
+ filter: blur(0);
152
+ }
153
+ 100% {
154
+ opacity: 1;
155
+ transform: scale(1) rotate(0deg);
156
+ filter: blur(0);
157
+ }
158
+ }
159
+
160
+ @media (prefers-reduced-motion: reduce) {
161
+ .vs-spinner svg {
162
+ animation-duration: 2s;
163
+ }
164
+
165
+ .vs-spinner--finish {
166
+ animation-duration: 0s;
167
+ }
168
+
169
+ .vs-icon--pop {
170
+ animation: none;
171
+ opacity: 1;
172
+ transform: scale(1);
173
+ }
174
+ }
@@ -0,0 +1,77 @@
1
+ import type { ToastData } from "./internals";
2
+ declare const ICON_VARIANTS: readonly ["success", "warning", "destructive"];
3
+ export type IconVariant = (typeof ICON_VARIANTS)[number];
4
+ type IconElement = {
5
+ tag: "path";
6
+ d: string;
7
+ } | {
8
+ tag: "line";
9
+ x1: number;
10
+ y1: number;
11
+ x2: number;
12
+ y2: number;
13
+ } | {
14
+ tag: "circle";
15
+ cx: number;
16
+ cy: number;
17
+ r: number;
18
+ };
19
+ export interface VariantIconDefinition {
20
+ viewBox: string;
21
+ elements: IconElement[];
22
+ }
23
+ export declare const variantIconMap: {
24
+ success: {
25
+ viewBox: string;
26
+ elements: ({
27
+ tag: "circle";
28
+ cx: number;
29
+ cy: number;
30
+ r: number;
31
+ d?: undefined;
32
+ } | {
33
+ tag: "path";
34
+ d: string;
35
+ cx?: undefined;
36
+ cy?: undefined;
37
+ r?: undefined;
38
+ })[];
39
+ };
40
+ warning: {
41
+ viewBox: string;
42
+ elements: ({
43
+ tag: "path";
44
+ d: string;
45
+ x1?: undefined;
46
+ y1?: undefined;
47
+ x2?: undefined;
48
+ y2?: undefined;
49
+ } | {
50
+ tag: "line";
51
+ x1: number;
52
+ y1: number;
53
+ x2: number;
54
+ y2: number;
55
+ d?: undefined;
56
+ })[];
57
+ };
58
+ destructive: {
59
+ viewBox: string;
60
+ elements: ({
61
+ tag: "circle";
62
+ cx: number;
63
+ cy: number;
64
+ r: number;
65
+ d?: undefined;
66
+ } | {
67
+ tag: "path";
68
+ d: string;
69
+ cx?: undefined;
70
+ cy?: undefined;
71
+ r?: undefined;
72
+ })[];
73
+ };
74
+ };
75
+ export declare const hasVariantIcon: (variant?: ToastData["variant"]) => variant is IconVariant;
76
+ export {};
77
+ //# 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,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,QAAA,MAAM,aAAa,gDAAiD,CAAC;AAErE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B2B,CAAC;AAEvD,eAAO,MAAM,cAAc,GAC1B,UAAU,SAAS,CAAC,SAAS,CAAC,KAC5B,OAAO,IAAI,WAEb,CAAC"}
@@ -0,0 +1,32 @@
1
+ const ICON_VARIANTS = ["success", "warning", "destructive"];
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
+ };
30
+ export const hasVariantIcon = (variant) => {
31
+ return Boolean(variant && ICON_VARIANTS.includes(variant));
32
+ };