@solid2-aria/sonner 0.0.0-stage → 0.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pekochan069
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE.txt ADDED
@@ -0,0 +1,27 @@
1
+ Solid2 Sonner third-party notices
2
+ ================================
3
+
4
+ The source files in src/ are derived from solid-sonner:
5
+ https://github.com/wobsoriano/solid-sonner (src/index.tsx, src/assets.tsx,
6
+ src/state.ts, src/types.ts, src/primitives.ts, and src/styles.css).
7
+ Copyright (c) 2022 Robert Soriano <https://github.com/wobsoriano>
8
+ The upstream MIT license is reproduced verbatim in SOLID-SONNER-LICENSE.md.
9
+
10
+ solid-sonner is based on Sonner:
11
+ https://github.com/emilkowalski/sonner (src/index.tsx, src/assets.tsx,
12
+ src/state.ts, src/types.ts, and src/styles.css).
13
+ Copyright (c) 2023 Emil Kowalski
14
+ The upstream MIT license is reproduced verbatim in SONNER-LICENSE.md.
15
+ The original Sonner attribution comment is retained in src/index.tsx.
16
+
17
+ Modified for Solid Aria: Solid 2 renderer imports, reactive props, signals,
18
+ stores, compute/apply effects, lifecycle cleanup, native DOM events, promise
19
+ handling, dismissal and history management, and browser/server packaging.
20
+ Styles are exported as a separate CSS entry point. Each derived source file
21
+ identifies its upstream path and modifications. Upstream source notices and
22
+ license texts were compared with upstream main during package integration.
23
+
24
+ Tests, build configuration, and package verification scripts are independently
25
+ written. Solid Aria contributions use the MIT license in LICENSE, Copyright
26
+ (c) 2026 pekochan069. This license does not replace the upstream licenses and
27
+ notices. This package introduces no Adobe-derived code or JSON translations.
package/README.md CHANGED
@@ -1,3 +1,76 @@
1
- # Temporary Holding Version
1
+ # Solid 2 Sonner
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Toast notifications for Solid 2, adapted from solid-sonner and Sonner. Requires `solid-js` and `@solidjs/web` 2.0.0-rc.17 or later in the Solid 2 release line.
4
+
5
+ In a workspace app, add the dependency and build the package from the repository root:
6
+
7
+ ```sh
8
+ bun add --cwd apps/your-app @solid2-aria/sonner@^0.0.1
9
+ bun run --filter @solid2-aria/sonner build
10
+ ```
11
+
12
+ Import the stylesheet once in your app entry point, and mount a `Toaster`:
13
+
14
+ ```tsx
15
+ import { Toaster, toast } from "@solid2-aria/sonner";
16
+
17
+ import "@solid2-aria/sonner/styles.css";
18
+
19
+ export default function App() {
20
+ return (
21
+ <>
22
+ <button onClick={() => toast.success("Saved")}>Save</button>
23
+ <Toaster theme="system" richColors closeButton />
24
+ </>
25
+ );
26
+ }
27
+ ```
28
+
29
+ Mount one default toaster per application. To route notifications to another toaster, use `<Toaster id="editor" />` with `toast("Saved", { toasterId: "editor" })`.
30
+
31
+ The package exports `Toaster`, `toast`, `useSonner`, and public types including `ToasterProps`, `ExternalToast`, and `PromiseData`. It supports actions, six positions, swipe dismissal, paused timers, custom icons, and style overrides.
32
+
33
+ Update or dismiss an existing toast with its ID:
34
+
35
+ ```tsx
36
+ const id = toast.loading("Saving");
37
+ toast.success("Saved", { id });
38
+ toast.dismiss(id);
39
+
40
+ toast.promise(saveChanges(), {
41
+ loading: "Saving",
42
+ success: "Saved",
43
+ error: "Could not save",
44
+ });
45
+
46
+ toast.custom((id) => (
47
+ <button onClick={() => toast.dismiss(id)}>Dismiss</button>
48
+ ));
49
+ ```
50
+
51
+ Call `useSonner()` inside a Solid owner to observe active toasts through `toasts()`:
52
+
53
+ ```tsx
54
+ import { useSonner } from "@solid2-aria/sonner";
55
+
56
+ function NotificationCount() {
57
+ const { toasts } = useSonner();
58
+ return <span>{toasts().length} notifications</span>;
59
+ }
60
+ ```
61
+
62
+ The export selects compiled browser code for browser bundles and SSR code for server bundles. SSR and hydration are checked with Solid's rendering APIs. Toast state is module scoped, so call `toast()` from client interactions rather than request-scoped server code.
63
+
64
+ Run verification from `packages/sonner`:
65
+
66
+ ```sh
67
+ bun run build
68
+ bun run check-types
69
+ bun test
70
+ bun run check-build
71
+ bun run check
72
+ ```
73
+
74
+ `check-build` copies shipped files into a temporary consumer and checks exports, CSS, types, SSR, DOM hydration, and toast interactions. DOM checks use Happy DOM.
75
+
76
+ Solid Aria contributions use the [MIT license](./LICENSE). The original MIT licenses are in [SOLID-SONNER-LICENSE.md](./SOLID-SONNER-LICENSE.md) for solid-sonner and [SONNER-LICENSE.md](./SONNER-LICENSE.md) for Sonner. [NOTICE.txt](./NOTICE.txt) records source provenance and modifications.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Robert Soriano <https://github.com/wobsoriano>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Emil Kowalski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,219 @@
1
+ /*!
2
+ * Derived from solid-sonner (https://github.com/wobsoriano/solid-sonner), src/.
3
+ * Copyright (c) 2022 Robert Soriano <https://github.com/wobsoriano>
4
+ * Derived from Sonner (https://github.com/emilkowalski/sonner), src/.
5
+ * Copyright (c) 2023 Emil Kowalski
6
+ * Modified for Solid Aria: Solid 2 reactivity, rendering, lifecycle, and packaging.
7
+ * MIT licensed. See LICENSE, SOLID-SONNER-LICENSE.md, SONNER-LICENSE.md, and NOTICE.txt in the package root.
8
+ */
9
+ import { JSX } from "@solidjs/web";
10
+ import { Setter } from "solid-js";
11
+ type ToastTypes = "normal" | "action" | "success" | "info" | "warning" | "error" | "loading" | "default";
12
+ type PromiseT<Data = unknown> = Promise<Data> | (() => Promise<Data>);
13
+ type ToastContent = (() => JSX.Element) | JSX.Element;
14
+ interface PromiseIExtendedResult extends ExternalToast {
15
+ message: JSX.Element | string;
16
+ }
17
+ type PromiseTExtendedResult<Data = unknown> = PromiseIExtendedResult | ((data: Data) => PromiseIExtendedResult | Promise<PromiseIExtendedResult>);
18
+ type PromiseTResult<Data = unknown> = string | JSX.Element | ((data: Data) => JSX.Element | string | Promise<JSX.Element | string>);
19
+ type PromiseExternalToast = Omit<ExternalToast, "description">;
20
+ type PromiseData<ToastData = unknown> = PromiseExternalToast & {
21
+ loading?: string | JSX.Element;
22
+ success?: PromiseTResult<ToastData> | PromiseTExtendedResult<ToastData>;
23
+ error?: PromiseTResult | PromiseTExtendedResult;
24
+ description?: PromiseTResult;
25
+ finally?: () => void | Promise<void>;
26
+ };
27
+ interface ToastClassnames {
28
+ toast?: string;
29
+ title?: string;
30
+ description?: string;
31
+ loader?: string;
32
+ closeButton?: string;
33
+ cancelButton?: string;
34
+ actionButton?: string;
35
+ success?: string;
36
+ error?: string;
37
+ info?: string;
38
+ warning?: string;
39
+ loading?: string;
40
+ default?: string;
41
+ content?: string;
42
+ icon?: string;
43
+ }
44
+ interface ToastIcons {
45
+ success?: JSX.Element | null;
46
+ info?: JSX.Element | null;
47
+ warning?: JSX.Element | null;
48
+ error?: JSX.Element | null;
49
+ loading?: JSX.Element | null;
50
+ close?: JSX.Element | null;
51
+ }
52
+ interface Action {
53
+ label: JSX.Element;
54
+ onClick: (event: MouseEvent) => void;
55
+ actionButtonStyle?: JSX.CSSProperties;
56
+ }
57
+ interface ToastT {
58
+ id: number | string;
59
+ toasterId?: string;
60
+ title?: ToastContent;
61
+ type?: ToastTypes;
62
+ icon?: JSX.Element | null;
63
+ jsx?: JSX.Element;
64
+ richColors?: boolean;
65
+ invert?: boolean;
66
+ closeButton?: boolean;
67
+ dismissible?: boolean;
68
+ description?: ToastContent;
69
+ duration?: number;
70
+ delete?: boolean;
71
+ action?: Action | JSX.Element;
72
+ cancel?: Action | JSX.Element;
73
+ onDismiss?: (toast: ToastT) => void;
74
+ onAutoClose?: (toast: ToastT) => void;
75
+ promise?: PromiseT;
76
+ cancelButtonStyle?: JSX.CSSProperties;
77
+ actionButtonStyle?: JSX.CSSProperties;
78
+ style?: JSX.CSSProperties;
79
+ unstyled?: boolean;
80
+ className?: string;
81
+ classNames?: ToastClassnames;
82
+ descriptionClassName?: string;
83
+ position?: Position;
84
+ testId?: string;
85
+ class?: string;
86
+ classes?: ToastClassnames;
87
+ descriptionClass?: string;
88
+ }
89
+ declare function isAction(action: Action | JSX.Element): action is Action;
90
+ type Position = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top-center" | "bottom-center";
91
+ interface HeightT {
92
+ height: number;
93
+ toastId: number | string;
94
+ toasterId?: string;
95
+ position?: Position;
96
+ }
97
+ interface ToastOptions {
98
+ className?: string;
99
+ closeButton?: boolean;
100
+ descriptionClassName?: string;
101
+ style?: JSX.CSSProperties;
102
+ cancelButtonStyle?: JSX.CSSProperties;
103
+ actionButtonStyle?: JSX.CSSProperties;
104
+ duration?: number;
105
+ unstyled?: boolean;
106
+ classNames?: ToastClassnames;
107
+ closeButtonAriaLabel?: string;
108
+ toasterId?: string;
109
+ class?: string;
110
+ classes?: ToastClassnames;
111
+ descriptionClass?: string;
112
+ }
113
+ type Offset = {
114
+ top?: string | number;
115
+ right?: string | number;
116
+ bottom?: string | number;
117
+ left?: string | number;
118
+ } | string | number;
119
+ type SwipeDirection = "top" | "right" | "bottom" | "left";
120
+ interface ToasterProps {
121
+ id?: string;
122
+ invert?: boolean;
123
+ theme?: "light" | "dark" | "system";
124
+ position?: Position;
125
+ hotkey?: string[];
126
+ richColors?: boolean;
127
+ expand?: boolean;
128
+ duration?: number;
129
+ gap?: number;
130
+ visibleToasts?: number;
131
+ closeButton?: boolean;
132
+ toastOptions?: ToastOptions;
133
+ className?: string;
134
+ style?: JSX.CSSProperties;
135
+ offset?: Offset;
136
+ mobileOffset?: Offset;
137
+ dir?: "rtl" | "ltr" | "auto";
138
+ swipeDirections?: SwipeDirection[];
139
+ icons?: ToastIcons;
140
+ customAriaLabel?: string;
141
+ containerAriaLabel?: string;
142
+ pauseWhenPageIsHidden?: boolean;
143
+ class?: string;
144
+ }
145
+ interface ToastProps {
146
+ toast: ToastT;
147
+ toasts: ToastT[];
148
+ index: number;
149
+ swipeDirections?: SwipeDirection[];
150
+ expanded: boolean;
151
+ invert: boolean;
152
+ heights: HeightT[];
153
+ setHeights: Setter<HeightT[]>;
154
+ removeToast: (toast: ToastT) => void;
155
+ gap?: number;
156
+ position: Position;
157
+ visibleToasts: number;
158
+ expandByDefault: boolean;
159
+ closeButton: boolean;
160
+ interacting: boolean;
161
+ style?: JSX.CSSProperties;
162
+ cancelButtonStyle?: JSX.CSSProperties;
163
+ actionButtonStyle?: JSX.CSSProperties;
164
+ duration?: number;
165
+ className?: string;
166
+ unstyled?: boolean;
167
+ descriptionClassName?: string;
168
+ classNames?: ToastClassnames;
169
+ icons?: ToastIcons;
170
+ closeButtonAriaLabel?: string;
171
+ defaultRichColors?: boolean;
172
+ pauseWhenPageIsHidden?: boolean;
173
+ class?: string;
174
+ classes?: ToastClassnames;
175
+ descriptionClass?: string;
176
+ }
177
+ declare enum SwipeStateTypes {
178
+ SwipedOut = "SwipedOut",
179
+ SwipedBack = "SwipedBack",
180
+ NotSwiped = "NotSwiped"
181
+ }
182
+ type Theme = "light" | "dark";
183
+ interface ToastToDismiss {
184
+ id: number | string;
185
+ dismiss: boolean;
186
+ }
187
+ type ExternalToast = Omit<ToastT, "id" | "type" | "title" | "jsx" | "delete" | "promise"> & {
188
+ id?: number | string;
189
+ toasterId?: string;
190
+ };
191
+ declare function toastFunction(message: ToastContent, data?: ExternalToast): string | number;
192
+ declare const getHistory: () => ToastT[];
193
+ declare const getToasts: () => ToastT[];
194
+ export declare const toast: typeof toastFunction & {
195
+ custom: (jsx: (id: number | string) => JSX.Element, data?: ExternalToast) => string | number;
196
+ dismiss: (id?: number | string) => string | number | undefined;
197
+ error: (message: ToastContent, data?: ExternalToast) => string | number;
198
+ info: (message: ToastContent, data?: ExternalToast) => string | number;
199
+ loading: (message: ToastContent, data?: ExternalToast) => string | number;
200
+ message: (message: ToastContent, data?: ExternalToast) => string | number;
201
+ promise: <ToastData>(promise: PromiseT<ToastData>, data?: PromiseData<ToastData> | undefined) => {
202
+ unwrap: () => Promise<ToastData>;
203
+ } | (string & {
204
+ unwrap: () => Promise<ToastData>;
205
+ }) | (number & {
206
+ unwrap: () => Promise<ToastData>;
207
+ }) | undefined;
208
+ success: (message: ToastContent, data?: ExternalToast) => string | number;
209
+ warning: (message: ToastContent, data?: ExternalToast) => string | number;
210
+ } & {
211
+ getHistory: typeof getHistory;
212
+ getToasts: typeof getToasts;
213
+ };
214
+ declare function useSonner(): {
215
+ toasts: import("solid-js").SourceAccessor<ToastT[]>;
216
+ };
217
+ declare function Toaster(props: ToasterProps): JSX.Element;
218
+ export { type Action, type ExternalToast, type HeightT, type Offset, type Position, type PromiseData, type PromiseExternalToast, type PromiseIExtendedResult, type PromiseT, type PromiseTExtendedResult, type PromiseTResult, type SwipeDirection, type SwipeStateTypes, type Theme, type ToastClassnames, type ToastContent, type ToastIcons, type ToastOptions, type ToastProps, type ToastT, type ToastToDismiss, type ToastTypes, Toaster, type ToasterProps, type isAction, useSonner };
219
+ //# sourceMappingURL=index.d.ts.map