varsel 0.1.1 → 0.2.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.
- package/dist/VarselItem.svelte +228 -229
- package/dist/VarselItem.svelte.d.ts +19 -23
- package/dist/VarselItem.svelte.d.ts.map +1 -1
- package/dist/VarselManager.svelte +58 -37
- package/dist/VarselManager.svelte.d.ts +7 -18
- package/dist/VarselManager.svelte.d.ts.map +1 -1
- package/dist/VarselToaster.svelte +22 -5
- package/dist/VarselToaster.svelte.d.ts +12 -19
- package/dist/VarselToaster.svelte.d.ts.map +1 -1
- package/dist/core/accessibility.d.ts +4 -0
- package/dist/core/accessibility.d.ts.map +1 -1
- package/dist/core/accessibility.js +4 -0
- package/dist/core/animations.d.ts +15 -0
- package/dist/core/animations.d.ts.map +1 -1
- package/dist/core/animations.js +15 -0
- package/dist/core/positions.d.ts +7 -0
- package/dist/core/positions.d.ts.map +1 -1
- package/dist/core/positions.js +4 -0
- package/dist/core/swipe.d.ts +12 -0
- package/dist/core/swipe.d.ts.map +1 -1
- package/dist/core/swipe.js +10 -0
- package/dist/core/toast-factory.d.ts.map +1 -1
- package/dist/core/toast-factory.js +38 -0
- package/dist/core/toast-state.d.ts +32 -0
- package/dist/core/toast-state.d.ts.map +1 -1
- package/dist/core/toast-state.js +33 -0
- package/dist/core/toaster-instances.d.ts +17 -0
- package/dist/core/toaster-instances.d.ts.map +1 -1
- package/dist/core/toaster-instances.js +17 -0
- package/dist/core/types.d.ts +70 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/utils.d.ts +8 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/core/utils.js +8 -0
- package/dist/core/variants.d.ts +10 -0
- package/dist/core/variants.d.ts.map +1 -1
- package/dist/core/variants.js +16 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/internals.d.ts +5 -0
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +5 -0
- package/dist/styles.css +1 -765
- package/dist/variant-icons.d.ts +9 -0
- package/dist/variant-icons.d.ts.map +1 -1
- package/dist/variant-icons.js +5 -0
- package/package.json +10 -4
package/dist/core/toast-state.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages the global state of toast notifications.
|
|
3
|
+
* Implements a singleton pattern with a subscription mechanism.
|
|
4
|
+
*/
|
|
1
5
|
class ToastState {
|
|
2
6
|
toasts = [];
|
|
3
7
|
subscribers = new Set();
|
|
4
8
|
idCounter = 0;
|
|
9
|
+
/**
|
|
10
|
+
* Subscribes to changes in the toast list.
|
|
11
|
+
* @param callback - Function to be called when the toast list updates.
|
|
12
|
+
* @returns A cleanup function to unsubscribe.
|
|
13
|
+
*/
|
|
5
14
|
subscribe(callback) {
|
|
6
15
|
this.subscribers.add(callback);
|
|
7
16
|
return () => {
|
|
@@ -16,21 +25,40 @@ class ToastState {
|
|
|
16
25
|
generateId() {
|
|
17
26
|
return `toast-${Date.now()}-${++this.idCounter}`;
|
|
18
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Adds a new toast to the state.
|
|
30
|
+
* @param data - The toast configuration (without ID).
|
|
31
|
+
* @returns The generated ID of the new toast.
|
|
32
|
+
*/
|
|
19
33
|
add(data) {
|
|
20
34
|
const id = this.generateId();
|
|
21
35
|
const newToast = { ...data, id };
|
|
36
|
+
// Add new toasts to the beginning of the array (stack LIFO visually for some positions, logic handled in manager)
|
|
22
37
|
this.toasts = [newToast, ...this.toasts];
|
|
23
38
|
this.notify();
|
|
24
39
|
return id;
|
|
25
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Removes a toast from the state by its ID.
|
|
43
|
+
* @param id - The ID of the toast to remove.
|
|
44
|
+
*/
|
|
26
45
|
remove(id) {
|
|
27
46
|
this.toasts = this.toasts.filter((toast) => toast.id !== id);
|
|
28
47
|
this.notify();
|
|
29
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Updates an existing toast's data.
|
|
51
|
+
* @param id - The ID of the toast to update.
|
|
52
|
+
* @param data - Partial data to merge into the existing toast.
|
|
53
|
+
*/
|
|
30
54
|
update(id, data) {
|
|
31
55
|
this.toasts = this.toasts.map((toast) => toast.id === id ? { ...toast, ...data } : toast);
|
|
32
56
|
this.notify();
|
|
33
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Marks all active toasts for dismissal.
|
|
60
|
+
* Triggers the closing animation by setting `shouldClose` to true.
|
|
61
|
+
*/
|
|
34
62
|
dismissAll() {
|
|
35
63
|
this.toasts = this.toasts.map((toast) => ({
|
|
36
64
|
...toast,
|
|
@@ -39,9 +67,14 @@ class ToastState {
|
|
|
39
67
|
}));
|
|
40
68
|
this.notify();
|
|
41
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the current list of active toasts.
|
|
72
|
+
* @returns A copy of the toast array.
|
|
73
|
+
*/
|
|
42
74
|
getToasts() {
|
|
43
75
|
return [...this.toasts];
|
|
44
76
|
}
|
|
45
77
|
}
|
|
78
|
+
/** Global singleton instance of the toast state. */
|
|
46
79
|
export const toastState = new ToastState();
|
|
47
80
|
export { ToastState };
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages unique instances of the Toaster component to prevent conflicts.
|
|
3
|
+
* Ensures that if multiple Toasters are rendered, only one (the first or primary) is active.
|
|
4
|
+
*/
|
|
1
5
|
declare class ToasterInstanceManager {
|
|
2
6
|
private activeInstanceId;
|
|
3
7
|
private instanceCounter;
|
|
8
|
+
/**
|
|
9
|
+
* Registers a new toaster instance.
|
|
10
|
+
* @returns A unique instance ID.
|
|
11
|
+
*/
|
|
4
12
|
registerInstance(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Unregisters an instance, potentially freeing up the active slot.
|
|
15
|
+
* @param instanceId - The ID of the instance to unregister.
|
|
16
|
+
*/
|
|
5
17
|
unregisterInstance(instanceId: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the given instance is the currently active one.
|
|
20
|
+
* @param instanceId - The ID to check.
|
|
21
|
+
* @returns True if active, false otherwise.
|
|
22
|
+
*/
|
|
6
23
|
isActiveInstance(instanceId: string): boolean;
|
|
7
24
|
}
|
|
8
25
|
export declare const toasterInstanceManager: ToasterInstanceManager;
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"toaster-instances.d.ts","sourceRoot":"","sources":["../../src/lib/core/toaster-instances.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAM,sBAAsB;IAC3B,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,eAAe,CAAK;IAE5B;;;OAGG;IACH,gBAAgB,IAAI,MAAM;IAQ1B;;;OAGG;IACH,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAM5C;;;;OAIG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAG7C;AAED,eAAO,MAAM,sBAAsB,wBAA+B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages unique instances of the Toaster component to prevent conflicts.
|
|
3
|
+
* Ensures that if multiple Toasters are rendered, only one (the first or primary) is active.
|
|
4
|
+
*/
|
|
1
5
|
class ToasterInstanceManager {
|
|
2
6
|
activeInstanceId = null;
|
|
3
7
|
instanceCounter = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Registers a new toaster instance.
|
|
10
|
+
* @returns A unique instance ID.
|
|
11
|
+
*/
|
|
4
12
|
registerInstance() {
|
|
5
13
|
const instanceId = `toaster-${++this.instanceCounter}`;
|
|
6
14
|
if (!this.activeInstanceId) {
|
|
@@ -8,11 +16,20 @@ class ToasterInstanceManager {
|
|
|
8
16
|
}
|
|
9
17
|
return instanceId;
|
|
10
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Unregisters an instance, potentially freeing up the active slot.
|
|
21
|
+
* @param instanceId - The ID of the instance to unregister.
|
|
22
|
+
*/
|
|
11
23
|
unregisterInstance(instanceId) {
|
|
12
24
|
if (this.activeInstanceId === instanceId) {
|
|
13
25
|
this.activeInstanceId = null;
|
|
14
26
|
}
|
|
15
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Checks if the given instance is the currently active one.
|
|
30
|
+
* @param instanceId - The ID to check.
|
|
31
|
+
* @returns True if active, false otherwise.
|
|
32
|
+
*/
|
|
16
33
|
isActiveInstance(instanceId) {
|
|
17
34
|
return this.activeInstanceId === instanceId;
|
|
18
35
|
}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -2,43 +2,112 @@ import type { VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import type { toastContainerVariants } from "./variants";
|
|
3
3
|
import type { ToastPosition } from "./positions";
|
|
4
4
|
import type { SwipeAxis, SwipeDirection } from "./swipe";
|
|
5
|
+
/**
|
|
6
|
+
* Represents the data structure for a single toast notification.
|
|
7
|
+
*/
|
|
5
8
|
export interface ToastData extends VariantProps<typeof toastContainerVariants> {
|
|
9
|
+
/** Unique identifier for the toast. */
|
|
6
10
|
id: string;
|
|
11
|
+
/** The main title of the toast notification. */
|
|
7
12
|
title?: string;
|
|
13
|
+
/** Additional details or description displayed below the title. */
|
|
8
14
|
description?: string;
|
|
15
|
+
/** Optional CSS class to apply to the toast container. */
|
|
9
16
|
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Duration in milliseconds before the toast automatically closes.
|
|
19
|
+
* Defaults to 5000ms. Set to `Infinity` to keep open indefinitely.
|
|
20
|
+
*/
|
|
10
21
|
duration?: number;
|
|
22
|
+
/** Whether the toast is in a loading state. */
|
|
11
23
|
isLoading?: boolean;
|
|
24
|
+
/** Whether to show the close button. Defaults to `true`. */
|
|
12
25
|
showClose?: boolean;
|
|
26
|
+
/** Optional action button to display within the toast. */
|
|
13
27
|
action?: {
|
|
28
|
+
/** Label for the action button. */
|
|
14
29
|
label: string;
|
|
30
|
+
/** Callback function executed when the action button is clicked. */
|
|
15
31
|
onClick: () => void;
|
|
16
32
|
};
|
|
33
|
+
/** Callback function executed when the toast is closed. */
|
|
17
34
|
onClose?: () => void;
|
|
35
|
+
/** Internal flag: signals that the toast should begin its closing animation. */
|
|
18
36
|
shouldClose?: boolean;
|
|
37
|
+
/** Internal flag: signals that the toast is currently leaving the DOM. */
|
|
19
38
|
isLeaving?: boolean;
|
|
39
|
+
/** The position on the screen where this toast should appear. */
|
|
20
40
|
position?: ToastPosition;
|
|
21
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Represents the possible states for a promise-based toast.
|
|
44
|
+
* Can be a static message string, a ToastData object (minus ID), or a function returning one of those.
|
|
45
|
+
*/
|
|
22
46
|
export type PromiseToastState<Value> = string | Omit<ToastData, "id"> | ((value: Value) => string | Omit<ToastData, "id"> | PromiseLike<string | Omit<ToastData, "id">>);
|
|
47
|
+
/**
|
|
48
|
+
* Options for the `toast.promise` function.
|
|
49
|
+
*/
|
|
23
50
|
export type ToastPromiseOptions<SuccessValue = unknown, ErrorValue = unknown> = {
|
|
51
|
+
/** The message or data to show while the promise is pending. */
|
|
24
52
|
loading: Omit<ToastData, "id"> | string;
|
|
53
|
+
/** The message or data to show when the promise resolves successfully. */
|
|
25
54
|
success: PromiseToastState<SuccessValue>;
|
|
55
|
+
/** The message or data to show when the promise rejects. */
|
|
26
56
|
error: PromiseToastState<ErrorValue>;
|
|
27
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* The interface for the main `toast` function and its utility methods.
|
|
60
|
+
*/
|
|
28
61
|
export type ToastInvoker = {
|
|
62
|
+
/**
|
|
63
|
+
* Creates a default toast notification.
|
|
64
|
+
* @param data - The toast options or description string.
|
|
65
|
+
* @returns The ID of the created toast.
|
|
66
|
+
*/
|
|
29
67
|
(data: Omit<ToastData, "id"> | string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a success toast notification.
|
|
70
|
+
*/
|
|
30
71
|
success: (data: Omit<ToastData, "id" | "variant"> | string) => string;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a warning toast notification.
|
|
74
|
+
*/
|
|
31
75
|
warning: (data: Omit<ToastData, "id" | "variant"> | string) => string;
|
|
76
|
+
/**
|
|
77
|
+
* Creates an error toast notification.
|
|
78
|
+
*/
|
|
32
79
|
error: (data: Omit<ToastData, "id" | "variant"> | string) => string;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a toast that updates based on the state of a Promise.
|
|
82
|
+
* @param promise - The promise to track.
|
|
83
|
+
* @param options - Configuration for loading, success, and error states.
|
|
84
|
+
* @returns The ID of the toast.
|
|
85
|
+
*/
|
|
33
86
|
promise: <T, E = unknown>(promise: PromiseLike<T>, options: ToastPromiseOptions<T, E>) => string;
|
|
87
|
+
/**
|
|
88
|
+
* Dismisses a specific toast by its ID.
|
|
89
|
+
* @param id - The ID of the toast to dismiss.
|
|
90
|
+
*/
|
|
34
91
|
dismiss: (id: string) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Dismisses all currently active toasts.
|
|
94
|
+
*/
|
|
35
95
|
dismissAll: () => void;
|
|
36
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Extends `ToastData` with positioning information for rendering.
|
|
99
|
+
*/
|
|
37
100
|
export type PositionedToast = ToastData & {
|
|
101
|
+
/** The visual index of the toast in the stack. */
|
|
38
102
|
index: number;
|
|
103
|
+
/** The render order index (z-index calculation base). */
|
|
39
104
|
renderIndex: number;
|
|
105
|
+
/** Total number of toasts in the current group. */
|
|
40
106
|
total: number;
|
|
41
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Context provided to toast items (mostly for internal use).
|
|
110
|
+
*/
|
|
42
111
|
export interface VarselItemContext {
|
|
43
112
|
toast: PositionedToast;
|
|
44
113
|
onRemove: (id: string) => void;
|
|
@@ -50,6 +119,7 @@ export interface VarselItemContext {
|
|
|
50
119
|
onHeightChange?: (id: string, height: number) => void;
|
|
51
120
|
onGroupHoverEnter?: () => void;
|
|
52
121
|
}
|
|
122
|
+
/** Function signature for toast state subscribers. */
|
|
53
123
|
export type ToastSubscriber = (toasts: ToastData[]) => void;
|
|
54
124
|
export type { ToastPosition, SwipeAxis, SwipeDirection };
|
|
55
125
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/core/types.d.ts.map
CHANGED
|
@@ -1 +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,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,SAAU,SAAQ,YAAY,CAAC,OAAO,sBAAsB,CAAC;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IAC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AAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,iBAAiB,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"}
|
package/dist/core/utils.d.ts
CHANGED
|
@@ -1,2 +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
|
+
*/
|
|
1
9
|
export declare const cn: (...values: Array<string | false | undefined | null>) => string;
|
|
2
10
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/core/utils.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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"}
|
package/dist/core/utils.js
CHANGED
|
@@ -1 +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
|
+
*/
|
|
1
9
|
export const cn = (...values) => values.filter(Boolean).join(" ");
|
package/dist/core/variants.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
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
|
+
*/
|
|
1
6
|
export declare const toastContainerVariants: (props?: ({
|
|
2
7
|
position?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | null | undefined;
|
|
3
8
|
variant?: "default" | "success" | "warning" | "destructive" | null | undefined;
|
|
4
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
|
+
*/
|
|
5
15
|
export declare const toastContentVariants: (props?: ({
|
|
6
16
|
variant?: "default" | "success" | "warning" | "destructive" | null | undefined;
|
|
7
17
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/lib/core/variants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB;;;
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/lib/core/variants.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;8EAgClC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;8EAY/B,CAAC"}
|
package/dist/core/variants.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
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
|
+
*/
|
|
2
7
|
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
8
|
variants: {
|
|
9
|
+
/**
|
|
10
|
+
* Determines where the toast is anchored on the screen.
|
|
11
|
+
*/
|
|
4
12
|
position: {
|
|
5
13
|
"top-left": "top-4 left-4 w-full max-w-sm",
|
|
6
14
|
"top-center": "top-4 left-1/2 w-full max-w-sm -translate-x-1/2 transform",
|
|
@@ -9,6 +17,9 @@ export const toastContainerVariants = cva("pointer-events-auto fixed rounded-vs-
|
|
|
9
17
|
"bottom-center": "bottom-4 left-1/2 w-full max-w-sm -translate-x-1/2 transform",
|
|
10
18
|
"bottom-right": "right-4 bottom-4 w-full max-w-sm",
|
|
11
19
|
},
|
|
20
|
+
/**
|
|
21
|
+
* Semantic variant of the toast affecting text colors.
|
|
22
|
+
*/
|
|
12
23
|
variant: {
|
|
13
24
|
default: "text-vs-foreground",
|
|
14
25
|
success: "text-vs-success/90",
|
|
@@ -21,6 +32,11 @@ export const toastContainerVariants = cva("pointer-events-auto fixed rounded-vs-
|
|
|
21
32
|
variant: "default",
|
|
22
33
|
},
|
|
23
34
|
});
|
|
35
|
+
/**
|
|
36
|
+
* CVA definition for the inner content wrapper of the toast.
|
|
37
|
+
* Useful for applying styles specific to the content area (e.g. overflow, padding overrides)
|
|
38
|
+
* separate from the structural container.
|
|
39
|
+
*/
|
|
24
40
|
export const toastContentVariants = cva("relative overflow-hidden rounded-vs-lg", {
|
|
25
41
|
variants: {
|
|
26
42
|
variant: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
*/
|
|
1
7
|
export { default as VarselToaster } from "./VarselToaster.svelte";
|
|
2
8
|
export { toast } from "./internals";
|
|
3
9
|
export type { ToastData, ToastInvoker, ToastPosition, SwipeAxis, SwipeDirection, PositionedToast, VarselItemContext, ToastPromiseOptions, } from "./internals";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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
CHANGED
package/dist/internals.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
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
|
+
*/
|
|
1
6
|
export { ANIMATION_CONFIG } from "./core/animations";
|
|
2
7
|
export { FOCUSABLE_SELECTORS } from "./core/accessibility";
|
|
3
8
|
export { POSITION_CONFIGS, type ToastPosition } from "./core/positions";
|
package/dist/internals.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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"}
|
package/dist/internals.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
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
|
+
*/
|
|
1
6
|
export { ANIMATION_CONFIG } from "./core/animations";
|
|
2
7
|
export { FOCUSABLE_SELECTORS } from "./core/accessibility";
|
|
3
8
|
export { POSITION_CONFIGS } from "./core/positions";
|