@zag-js/toast 0.1.9 → 0.1.12
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/LICENSE +21 -0
- package/dist/index.d.ts +198 -8
- package/dist/index.js +192 -191
- package/dist/index.mjs +186 -195
- package/package.json +14 -11
- package/dist/toast-group.connect.d.ts +0 -24
- package/dist/toast-group.machine.d.ts +0 -2
- package/dist/toast.connect.d.ts +0 -17
- package/dist/toast.dom.d.ts +0 -12
- package/dist/toast.machine.d.ts +0 -2
- package/dist/toast.types.d.ts +0 -154
- package/dist/toast.utils.d.ts +0 -6
package/dist/toast.types.d.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import type { Machine, StateMachine as S } from "@zag-js/core";
|
|
2
|
-
import type { Context, Direction, DirectionProperty, RootProperties } from "@zag-js/types";
|
|
3
|
-
export declare type Type = "success" | "error" | "loading" | "info" | "custom";
|
|
4
|
-
export declare type Placement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end";
|
|
5
|
-
declare type SharedContext = {
|
|
6
|
-
/**
|
|
7
|
-
* Whether to pause toast when the user leaves the browser tab
|
|
8
|
-
*/
|
|
9
|
-
pauseOnPageIdle?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Whether to pause the toast when interacted with
|
|
12
|
-
*/
|
|
13
|
-
pauseOnInteraction?: boolean;
|
|
14
|
-
};
|
|
15
|
-
export declare type ToastOptions = {
|
|
16
|
-
/**
|
|
17
|
-
* The unique id of the toast
|
|
18
|
-
*/
|
|
19
|
-
id: string;
|
|
20
|
-
/**
|
|
21
|
-
* The type of the toast
|
|
22
|
-
*/
|
|
23
|
-
type: Type;
|
|
24
|
-
/**
|
|
25
|
-
* The placement of the toast
|
|
26
|
-
*/
|
|
27
|
-
placement: Placement;
|
|
28
|
-
/**
|
|
29
|
-
* The message of the toast
|
|
30
|
-
*/
|
|
31
|
-
title?: string;
|
|
32
|
-
/**
|
|
33
|
-
* The description of the toast
|
|
34
|
-
*/
|
|
35
|
-
description?: string;
|
|
36
|
-
/**
|
|
37
|
-
* The duration the toast will be visible
|
|
38
|
-
*/
|
|
39
|
-
duration: number;
|
|
40
|
-
/**
|
|
41
|
-
* Custom function to render the toast element.
|
|
42
|
-
*/
|
|
43
|
-
render?: (options: RenderOptions) => any;
|
|
44
|
-
/**
|
|
45
|
-
* The duration for the toast to kept alive before it is removed.
|
|
46
|
-
* Useful for exit transitions.
|
|
47
|
-
*/
|
|
48
|
-
removeDelay?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Function called when the toast has been closed and removed
|
|
51
|
-
*/
|
|
52
|
-
onClose?: VoidFunction;
|
|
53
|
-
/**
|
|
54
|
-
* Function called when the toast is leaving
|
|
55
|
-
*/
|
|
56
|
-
onClosing?: VoidFunction;
|
|
57
|
-
/**
|
|
58
|
-
* Function called when the toast is shown
|
|
59
|
-
*/
|
|
60
|
-
onOpen?: VoidFunction;
|
|
61
|
-
/**
|
|
62
|
-
* Function called when the toast is updated
|
|
63
|
-
*/
|
|
64
|
-
onUpdate?: VoidFunction;
|
|
65
|
-
};
|
|
66
|
-
export declare type Options = Partial<ToastOptions>;
|
|
67
|
-
export declare type RenderOptions = Omit<ToastOptions, "render"> & {
|
|
68
|
-
dismiss(): void;
|
|
69
|
-
};
|
|
70
|
-
export declare type MachineContext = SharedContext & RootProperties & Omit<ToastOptions, "removeDelay"> & {
|
|
71
|
-
/**
|
|
72
|
-
* The duration for the toast to kept alive before it is removed.
|
|
73
|
-
* Useful for exit transitions.
|
|
74
|
-
*/
|
|
75
|
-
removeDelay: number;
|
|
76
|
-
/**
|
|
77
|
-
* The document's text/writing direction.
|
|
78
|
-
*/
|
|
79
|
-
dir?: Direction;
|
|
80
|
-
/**
|
|
81
|
-
* The time the toast was created
|
|
82
|
-
*/
|
|
83
|
-
createdAt: number;
|
|
84
|
-
/**
|
|
85
|
-
* The time left before the toast is removed
|
|
86
|
-
*/
|
|
87
|
-
remaining: number;
|
|
88
|
-
};
|
|
89
|
-
export declare type MachineState = {
|
|
90
|
-
value: "active" | "active:temp" | "dismissing" | "inactive" | "persist";
|
|
91
|
-
tags: "visible" | "paused" | "updating";
|
|
92
|
-
};
|
|
93
|
-
export declare type State = S.State<MachineContext, MachineState>;
|
|
94
|
-
export declare type Send = S.Send;
|
|
95
|
-
export declare type Service = Machine<MachineContext, MachineState>;
|
|
96
|
-
declare type GroupPublicContext = SharedContext & DirectionProperty & {
|
|
97
|
-
/**
|
|
98
|
-
* The gutter or spacing between toasts
|
|
99
|
-
*/
|
|
100
|
-
gutter: string;
|
|
101
|
-
/**
|
|
102
|
-
* The z-index applied to each toast group
|
|
103
|
-
*/
|
|
104
|
-
zIndex: number;
|
|
105
|
-
/**
|
|
106
|
-
* The maximum number of toasts that can be shown at once
|
|
107
|
-
*/
|
|
108
|
-
max: number;
|
|
109
|
-
/**
|
|
110
|
-
* The offset from the safe environment edge of the viewport
|
|
111
|
-
*/
|
|
112
|
-
offsets: string | Record<"left" | "right" | "bottom" | "top", string>;
|
|
113
|
-
};
|
|
114
|
-
export declare type UserDefinedGroupContext = Partial<GroupPublicContext>;
|
|
115
|
-
declare type GroupComputedContext = Readonly<{
|
|
116
|
-
/**
|
|
117
|
-
* @computed
|
|
118
|
-
* The total number of toasts in the group
|
|
119
|
-
*/
|
|
120
|
-
readonly count: number;
|
|
121
|
-
}>;
|
|
122
|
-
declare type GroupPrivateContext = Context<{
|
|
123
|
-
/**
|
|
124
|
-
* @internal
|
|
125
|
-
* The child toast machines (spawned by the toast group)
|
|
126
|
-
*/
|
|
127
|
-
toasts: Service[];
|
|
128
|
-
}>;
|
|
129
|
-
export declare type GroupMachineContext = GroupPublicContext & GroupComputedContext & GroupPrivateContext;
|
|
130
|
-
export declare type GroupState = S.State<GroupMachineContext>;
|
|
131
|
-
export declare type GroupSend = (event: S.Event<S.AnyEventObject>) => void;
|
|
132
|
-
declare type MaybeFunction<Value, Args> = Value | ((arg: Args) => Value);
|
|
133
|
-
export declare type PromiseOptions<Value> = {
|
|
134
|
-
loading: ToastOptions;
|
|
135
|
-
success: MaybeFunction<ToastOptions, Value>;
|
|
136
|
-
error: MaybeFunction<ToastOptions, Error>;
|
|
137
|
-
};
|
|
138
|
-
export declare type GroupProps = {
|
|
139
|
-
placement: Placement;
|
|
140
|
-
label?: string;
|
|
141
|
-
};
|
|
142
|
-
export declare type Toaster = {
|
|
143
|
-
count: number;
|
|
144
|
-
isVisible(id: string): boolean;
|
|
145
|
-
upsert(options: ToastOptions): string | undefined;
|
|
146
|
-
create(options: ToastOptions): string | undefined;
|
|
147
|
-
success(options: ToastOptions): string | undefined;
|
|
148
|
-
error(options: ToastOptions): string | undefined;
|
|
149
|
-
loading(options: ToastOptions): string | undefined;
|
|
150
|
-
dismiss(id?: string | undefined): void;
|
|
151
|
-
remove(id?: string | undefined): void;
|
|
152
|
-
promise<T>(promise: Promise<T>, options: PromiseOptions<T>, shared?: ToastOptions): Promise<T>;
|
|
153
|
-
};
|
|
154
|
-
export {};
|
package/dist/toast.utils.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Style } from "@zag-js/types";
|
|
2
|
-
import type { GroupMachineContext, MachineContext, Placement, Service, Type } from "./toast.types";
|
|
3
|
-
export declare function getToastsByPlacement(toasts: Service[]): Partial<Record<Placement, Service[]>>;
|
|
4
|
-
export declare const defaultTimeouts: Record<Type, number>;
|
|
5
|
-
export declare function getToastDuration(duration: number | undefined, type: MachineContext["type"]): number;
|
|
6
|
-
export declare function getGroupPlacementStyle(ctx: GroupMachineContext, placement: Placement): Style;
|