sonner-vanilla 0.1.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/README.md +264 -0
- package/dist/assets.d.ts +9 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +49 -0
- package/dist/assets.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +7 -0
- package/dist/state.d.ts +60 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +212 -0
- package/dist/state.js.map +1 -0
- package/dist/stimulus.d.ts +171 -0
- package/dist/stimulus.d.ts.map +1 -0
- package/dist/stimulus.js +13 -0
- package/dist/stimulus.js.map +7 -0
- package/dist/styles.css +725 -0
- package/dist/toaster.d.ts +40 -0
- package/dist/toaster.d.ts.map +1 -0
- package/dist/toaster.js +702 -0
- package/dist/toaster.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Sonner Vanilla
|
|
2
|
+
|
|
3
|
+
A vanilla JavaScript port of the [Sonner](https://sonner.emilkowal.ski/) toast library. Zero dependencies.
|
|
4
|
+
|
|
5
|
+
> **For Rails users:** See the main [rails README](../../README.md) for Hotwire/Stimulus integration.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install sonner-vanilla
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { toast, createToaster } from 'sonner-vanilla';
|
|
17
|
+
import 'sonner-vanilla/styles.css';
|
|
18
|
+
|
|
19
|
+
// Initialize the toaster (do this once)
|
|
20
|
+
const toaster = createToaster({
|
|
21
|
+
position: 'bottom-right',
|
|
22
|
+
theme: 'light',
|
|
23
|
+
richColors: true,
|
|
24
|
+
});
|
|
25
|
+
toaster.mount(document.body);
|
|
26
|
+
|
|
27
|
+
// Show toasts
|
|
28
|
+
toast('Hello World');
|
|
29
|
+
toast.success('Success!');
|
|
30
|
+
toast.error('Something went wrong');
|
|
31
|
+
toast.warning('Warning message');
|
|
32
|
+
toast.info('Info message');
|
|
33
|
+
toast.loading('Loading...');
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Toast Types
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
// Default
|
|
40
|
+
toast('Default message');
|
|
41
|
+
toast.message('Same as default');
|
|
42
|
+
|
|
43
|
+
// Success
|
|
44
|
+
toast.success('Operation completed!');
|
|
45
|
+
|
|
46
|
+
// Error
|
|
47
|
+
toast.error('Something went wrong');
|
|
48
|
+
|
|
49
|
+
// Warning
|
|
50
|
+
toast.warning('Please review your input');
|
|
51
|
+
|
|
52
|
+
// Info
|
|
53
|
+
toast.info('New updates available');
|
|
54
|
+
|
|
55
|
+
// Loading
|
|
56
|
+
const id = toast.loading('Processing...');
|
|
57
|
+
// Later, dismiss or update it
|
|
58
|
+
toast.dismiss(id);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Toast Options
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
toast.success('Saved!', {
|
|
65
|
+
description: 'Your changes have been saved.',
|
|
66
|
+
duration: 5000, // Duration in ms (Infinity for persistent)
|
|
67
|
+
dismissible: true, // Can be dismissed by user
|
|
68
|
+
closeButton: true, // Show close button
|
|
69
|
+
position: 'top-center', // Override toaster position
|
|
70
|
+
richColors: true, // Override toaster richColors
|
|
71
|
+
className: 'my-toast', // Custom class
|
|
72
|
+
id: 'my-toast-id', // Custom ID (for updating/dismissing)
|
|
73
|
+
|
|
74
|
+
// Callbacks
|
|
75
|
+
onDismiss: (t) => console.log('Dismissed', t),
|
|
76
|
+
onAutoClose: (t) => console.log('Auto closed', t),
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Action Buttons
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
toast('File deleted', {
|
|
84
|
+
action: {
|
|
85
|
+
label: 'Undo',
|
|
86
|
+
onClick: () => restoreFile(),
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
toast('Confirm action', {
|
|
91
|
+
action: {
|
|
92
|
+
label: 'Confirm',
|
|
93
|
+
onClick: () => doSomething(),
|
|
94
|
+
},
|
|
95
|
+
cancel: {
|
|
96
|
+
label: 'Cancel',
|
|
97
|
+
onClick: () => console.log('Cancelled'),
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Promise Toast
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
toast.promise(saveData(), {
|
|
106
|
+
loading: 'Saving...',
|
|
107
|
+
success: 'Saved successfully!',
|
|
108
|
+
error: 'Failed to save',
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// With dynamic messages
|
|
112
|
+
toast.promise(fetchUser(), {
|
|
113
|
+
loading: 'Loading user...',
|
|
114
|
+
success: (user) => `Welcome, ${user.name}!`,
|
|
115
|
+
error: (err) => `Error: ${err.message}`,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Access the promise result
|
|
119
|
+
const result = toast.promise(fetchData(), {
|
|
120
|
+
loading: 'Loading...',
|
|
121
|
+
success: 'Done!',
|
|
122
|
+
error: 'Failed',
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
result.unwrap().then(data => {
|
|
126
|
+
console.log('Data:', data);
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Custom Content
|
|
131
|
+
|
|
132
|
+
Render completely custom toast content:
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
// HTML string
|
|
136
|
+
toast.custom('<div class="my-toast"><strong>Bold</strong> message</div>');
|
|
137
|
+
|
|
138
|
+
// HTMLElement
|
|
139
|
+
const el = document.createElement('div');
|
|
140
|
+
el.className = 'custom-toast';
|
|
141
|
+
el.innerHTML = '<span>Custom element</span>';
|
|
142
|
+
toast.custom(el);
|
|
143
|
+
|
|
144
|
+
// Builder function (receives toast ID)
|
|
145
|
+
toast.custom((id) => {
|
|
146
|
+
const div = document.createElement('div');
|
|
147
|
+
div.innerHTML = `
|
|
148
|
+
<p>Custom toast #${id}</p>
|
|
149
|
+
<button onclick="toast.dismiss('${id}')">Close</button>
|
|
150
|
+
`;
|
|
151
|
+
return div;
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// With options
|
|
155
|
+
toast.custom('<div>Custom</div>', {
|
|
156
|
+
duration: 10000,
|
|
157
|
+
position: 'top-center',
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Dismissing Toasts
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
// Dismiss by ID
|
|
165
|
+
const id = toast.loading('Loading...');
|
|
166
|
+
toast.dismiss(id);
|
|
167
|
+
|
|
168
|
+
// Dismiss all
|
|
169
|
+
toast.dismiss();
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Updating Toasts
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
const id = toast.loading('Uploading...', { id: 'upload' });
|
|
176
|
+
|
|
177
|
+
// Update the same toast
|
|
178
|
+
toast.success('Upload complete!', { id: 'upload' });
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Toaster Options
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
const toaster = createToaster({
|
|
185
|
+
position: 'bottom-right', // Toast position
|
|
186
|
+
theme: 'light', // 'light', 'dark', 'system'
|
|
187
|
+
richColors: false, // Colorful backgrounds
|
|
188
|
+
closeButton: false, // Show close button
|
|
189
|
+
expand: false, // Expand toasts by default
|
|
190
|
+
duration: 4000, // Default duration (ms)
|
|
191
|
+
visibleToasts: 3, // Max visible toasts
|
|
192
|
+
gap: 14, // Gap between toasts (px)
|
|
193
|
+
offset: '24px', // Offset from viewport
|
|
194
|
+
dir: 'auto', // 'ltr', 'rtl', 'auto'
|
|
195
|
+
hotkey: ['altKey', 'KeyT'], // Keyboard shortcut to focus
|
|
196
|
+
containerAriaLabel: 'Notifications',
|
|
197
|
+
|
|
198
|
+
// Default options for all toasts
|
|
199
|
+
toastOptions: {
|
|
200
|
+
className: '',
|
|
201
|
+
duration: 4000,
|
|
202
|
+
closeButton: false,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Lifecycle
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
// Mount to a specific element
|
|
211
|
+
const toaster = createToaster();
|
|
212
|
+
toaster.mount(document.getElementById('toaster-container'));
|
|
213
|
+
|
|
214
|
+
// Unmount when done
|
|
215
|
+
toaster.unmount();
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Accessing Toasts
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
// Get all toasts (including dismissed)
|
|
222
|
+
const history = toast.getHistory();
|
|
223
|
+
|
|
224
|
+
// Get active toasts only
|
|
225
|
+
const active = toast.getToasts();
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Styling
|
|
229
|
+
|
|
230
|
+
The default styles are included in `sonner-vanilla/styles.css`. You can customize using CSS variables or override the classes.
|
|
231
|
+
|
|
232
|
+
```css
|
|
233
|
+
/* Custom theme example */
|
|
234
|
+
[data-sonner-toaster][data-theme="dark"] {
|
|
235
|
+
--normal-bg: #1a1a1a;
|
|
236
|
+
--normal-text: #fff;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* Custom toast styles */
|
|
240
|
+
[data-sonner-toast][data-type="success"] {
|
|
241
|
+
--success-bg: #10b981;
|
|
242
|
+
--success-text: #fff;
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## TypeScript
|
|
247
|
+
|
|
248
|
+
Full TypeScript support is included:
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import {
|
|
252
|
+
toast,
|
|
253
|
+
createToaster,
|
|
254
|
+
type ToastT,
|
|
255
|
+
type ToasterOptions,
|
|
256
|
+
type ExternalToast,
|
|
257
|
+
type Position,
|
|
258
|
+
type Theme,
|
|
259
|
+
} from 'sonner-vanilla';
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
MIT
|
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG icons and loader component
|
|
3
|
+
* Vanilla JS port of sonner's assets.tsx
|
|
4
|
+
*/
|
|
5
|
+
import type { ToastTypes } from './types';
|
|
6
|
+
export declare function getAsset(type: ToastTypes): string | null;
|
|
7
|
+
export declare function createLoader(visible: boolean, className?: string): HTMLElement;
|
|
8
|
+
export declare const CloseIcon = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n</svg>";
|
|
9
|
+
//# sourceMappingURL=assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAaxD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAgB9E;AAkBD,eAAO,MAAM,SAAS,oUAGf,CAAC"}
|
package/dist/assets.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG icons and loader component
|
|
3
|
+
* Vanilla JS port of sonner's assets.tsx
|
|
4
|
+
*/
|
|
5
|
+
export function getAsset(type) {
|
|
6
|
+
switch (type) {
|
|
7
|
+
case 'success':
|
|
8
|
+
return SuccessIcon;
|
|
9
|
+
case 'info':
|
|
10
|
+
return InfoIcon;
|
|
11
|
+
case 'warning':
|
|
12
|
+
return WarningIcon;
|
|
13
|
+
case 'error':
|
|
14
|
+
return ErrorIcon;
|
|
15
|
+
default:
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function createLoader(visible, className) {
|
|
20
|
+
const wrapper = document.createElement('div');
|
|
21
|
+
wrapper.className = ['sonner-loading-wrapper', className].filter(Boolean).join(' ');
|
|
22
|
+
wrapper.dataset.visible = String(visible);
|
|
23
|
+
const spinner = document.createElement('div');
|
|
24
|
+
spinner.className = 'sonner-spinner';
|
|
25
|
+
for (let i = 0; i < 12; i++) {
|
|
26
|
+
const bar = document.createElement('div');
|
|
27
|
+
bar.className = 'sonner-loading-bar';
|
|
28
|
+
spinner.appendChild(bar);
|
|
29
|
+
}
|
|
30
|
+
wrapper.appendChild(spinner);
|
|
31
|
+
return wrapper;
|
|
32
|
+
}
|
|
33
|
+
const SuccessIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
34
|
+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" />
|
|
35
|
+
</svg>`;
|
|
36
|
+
const WarningIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="20" width="20">
|
|
37
|
+
<path fill-rule="evenodd" d="M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z" clip-rule="evenodd" />
|
|
38
|
+
</svg>`;
|
|
39
|
+
const InfoIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
40
|
+
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd" />
|
|
41
|
+
</svg>`;
|
|
42
|
+
const ErrorIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
43
|
+
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
|
|
44
|
+
</svg>`;
|
|
45
|
+
export const CloseIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
46
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
47
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
48
|
+
</svg>`;
|
|
49
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0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AEb,CAAC;AAER,MAAM,QAAQ,GAAG;;OAEV,CAAC;AAER,MAAM,SAAS,GAAG;;OAEX,CAAC;AAER,MAAM,CAAC,MAAM,SAAS,GAAG;;;OAGlB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sonner Vanilla - A vanilla JavaScript toast library
|
|
3
|
+
* Port of the React sonner library for use with Rails Hotwire/Stimulus
|
|
4
|
+
*/
|
|
5
|
+
export { toast, ToastState } from './state';
|
|
6
|
+
export { Toaster, createToaster } from './toaster';
|
|
7
|
+
export { getAsset, createLoader, CloseIcon } from './assets';
|
|
8
|
+
export type { ToastTypes, Position, SwipeDirection, Theme, ToastClassnames, Action, ToastT, ToastToDismiss, ExternalToast, PromiseT, PromiseTResult, PromiseData, HeightT, Offset, ToasterOptions, CustomContent, } from './types';
|
|
9
|
+
export { isAction } from './types';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE7D,YAAY,EACV,UAAU,EACV,QAAQ,EACR,cAAc,EACd,KAAK,EACL,eAAe,EACf,MAAM,EACN,MAAM,EACN,cAAc,EACd,aAAa,EACb,QAAQ,EACR,cAAc,EACd,WAAW,EACX,OAAO,EACP,MAAM,EACN,cAAc,EACd,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var y=1,v=class{constructor(){this.subscribers=[];this.toasts=[];this.dismissedToasts=new Set}subscribe(e){return this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}}publish(e){this.subscribers.forEach(t=>t(e))}addToast(e){this.publish(e),this.toasts=[...this.toasts,e]}create(e){let{message:t,...i}=e,a=typeof e?.id=="number"||e.id&&String(e.id).length>0?e.id:y++,l=this.toasts.find(s=>s.id===a),c=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),l?this.toasts=this.toasts.map(s=>s.id===a?(this.publish({...s,...e,id:a,title:t}),{...s,...e,id:a,dismissible:c,title:t}):s):this.addToast({title:t,...i,dismissible:c,id:a}),a}dismiss(e){return e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(t=>{this.subscribers.forEach(i=>i({id:t.id,dismiss:!0}))}),e}message(e,t){return this.create({...t,message:e})}error(e,t){return this.create({...t,message:e,type:"error"})}success(e,t){return this.create({...t,type:"success",message:e})}info(e,t){return this.create({...t,type:"info",message:e})}warning(e,t){return this.create({...t,type:"warning",message:e})}loading(e,t){return this.create({...t,type:"loading",message:e})}withType(e,t,i){return this.create({...i,type:e,message:t})}promise(e,t){if(!t)return;let i;t.loading!==void 0&&(i=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let a=Promise.resolve(typeof e=="function"?e():e),l=i!==void 0,c,s=a.then(async o=>{if(c=["resolve",o],C(o)&&!o.ok){l=!1;let r=typeof t.error=="function"?await t.error(`HTTP error! status: ${o.status}`):t.error,p=typeof t.description=="function"?await t.description(`HTTP error! status: ${o.status}`):t.description;this.create({id:i,type:"error",description:p,message:r})}else if(o instanceof Error){l=!1;let r=typeof t.error=="function"?await t.error(o):t.error,p=typeof t.description=="function"?await t.description(o):t.description;this.create({id:i,type:"error",description:p,message:r})}else if(t.success!==void 0){l=!1;let r=typeof t.success=="function"?await t.success(o):t.success,p=typeof t.description=="function"?await t.description(o):t.description;this.create({id:i,type:"success",description:p,message:r})}}).catch(async o=>{if(c=["reject",o],t.error!==void 0){l=!1;let r=typeof t.error=="function"?await t.error(o):t.error,p=typeof t.description=="function"?await t.description(o):t.description;this.create({id:i,type:"error",description:p,message:r})}}).finally(()=>{l&&(this.dismiss(i),i=void 0),t.finally?.()}),n=()=>new Promise((o,r)=>s.then(()=>c[0]==="reject"?r(c[1]):o(c[1])).catch(r));return typeof i!="string"&&typeof i!="number"?{unwrap:n}:Object.assign(i,{unwrap:n})}custom(e,t){let i=t?.id??y++;return this.addToast({...t,id:i,custom:e}),i}getActiveToasts(){return this.toasts.filter(e=>!this.dismissedToasts.has(e.id))}};function C(d){return d!==null&&typeof d=="object"&&"ok"in d&&typeof d.ok=="boolean"&&"status"in d&&typeof d.status=="number"}var u=new v,A=(d,e)=>{let t=e?.id??y++;return u.addToast({title:d,...e,id:t}),t},L=()=>u.toasts,P=()=>u.getActiveToasts(),O=Object.assign(A,{success:u.success.bind(u),info:u.info.bind(u),warning:u.warning.bind(u),error:u.error.bind(u),message:u.message.bind(u),promise:u.promise.bind(u),dismiss:u.dismiss.bind(u),loading:u.loading.bind(u),custom:u.custom.bind(u),withType:u.withType.bind(u)},{getHistory:L,getToasts:P});function g(d){switch(d){case"success":return H;case"info":return I;case"warning":return N;case"error":return M;default:return null}}function w(d,e){let t=document.createElement("div");t.className=["sonner-loading-wrapper",e].filter(Boolean).join(" "),t.dataset.visible=String(d);let i=document.createElement("div");i.className="sonner-spinner";for(let a=0;a<12;a++){let l=document.createElement("div");l.className="sonner-loading-bar",i.appendChild(l)}return t.appendChild(i),t}var H=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
2
|
+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" />
|
|
3
|
+
</svg>`,N=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="20" width="20">
|
|
4
|
+
<path fill-rule="evenodd" d="M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z" clip-rule="evenodd" />
|
|
5
|
+
</svg>`,I=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
6
|
+
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd" />
|
|
7
|
+
</svg>`,M=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
8
|
+
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
|
|
9
|
+
</svg>`,E=`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
10
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
11
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
12
|
+
</svg>`;function T(d){return typeof d=="object"&&d!==null&&"label"in d&&"onClick"in d}var B=3,S="24px",D="16px",k=4e3,$=356,R=14,j=45,F=200;function h(...d){return d.filter(Boolean).join(" ")}function z(d){let[e,t]=d.split("-"),i=[];return e&&i.push(e),t&&i.push(t),i}function x(){if(typeof window>"u"||typeof document>"u")return"ltr";let d=document.documentElement.getAttribute("dir");return d==="auto"||!d?window.getComputedStyle(document.documentElement).direction:d}function V(d,e){let t={};return[d,e].forEach((i,a)=>{let l=a===1,c=l?"--mobile-offset":"--offset",s=l?D:S;function n(o){["top","right","bottom","left"].forEach(r=>{t[`${c}-${r}`]=typeof o=="number"?`${o}px`:o})}typeof i=="number"||typeof i=="string"?n(i):typeof i=="object"&&i!==null?["top","right","bottom","left"].forEach(o=>{let r=o;i[r]===void 0?t[`${c}-${o}`]=s:t[`${c}-${o}`]=typeof i[r]=="number"?`${i[r]}px`:String(i[r])}):n(s)}),t}var b=class{constructor(e={}){this.container=null;this.listEl=null;this.toastInstances=new Map;this.heights=[];this.expanded=!1;this.interacting=!1;this.unsubscribe=null;this.boundListHandlers=null;this.actualTheme="light";this.isDocumentHidden=!1;this.handleKeyDown=e=>{let{hotkey:t}=this.options;t.length>0&&t.every(a=>e[a]||e.code===a)&&(this.setExpanded(!0),this.listEl?.focus()),e.code==="Escape"&&this.listEl?.contains(document.activeElement)&&this.setExpanded(!1)};this.handleVisibilityChange=()=>{this.isDocumentHidden=document.hidden,this.toastInstances.forEach(e=>{this.isDocumentHidden?this.pauseTimer(e):this.startTimer(e)})};this.options={id:e.id??"",invert:e.invert??!1,theme:e.theme??"light",position:e.position??"bottom-right",hotkey:e.hotkey??["altKey","KeyT"],richColors:e.richColors??!1,expand:e.expand??!1,duration:e.duration??k,gap:e.gap??R,visibleToasts:e.visibleToasts??B,closeButton:e.closeButton??!1,className:e.className??"",style:e.style??{},offset:e.offset??S,mobileOffset:e.mobileOffset??D,dir:e.dir??x(),swipeDirections:e.swipeDirections??void 0,containerAriaLabel:e.containerAriaLabel??"Notifications",toastOptions:e.toastOptions??{}}}mount(e=document.body){let t=typeof e=="string"?document.querySelector(e):e;if(!t){console.error("Toaster: target element not found");return}this.setupTheme(),this.createContainer(),t.appendChild(this.container),this.setupEventListeners(),this.subscribeToState()}unmount(){document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.listEl&&this.boundListHandlers&&(this.listEl.removeEventListener("mouseenter",this.boundListHandlers.mouseenter),this.listEl.removeEventListener("mousemove",this.boundListHandlers.mousemove),this.listEl.removeEventListener("mouseleave",this.boundListHandlers.mouseleave),this.listEl.removeEventListener("pointerdown",this.boundListHandlers.pointerdown),this.listEl.removeEventListener("pointerup",this.boundListHandlers.pointerup)),this.boundListHandlers=null,this.unsubscribe?.(),this.container?.remove(),this.container=null,this.listEl=null,this.toastInstances.clear()}setupTheme(){if(this.options.theme!=="system"){this.actualTheme=this.options.theme;return}if(typeof window<"u"&&window.matchMedia){let e=window.matchMedia("(prefers-color-scheme: dark)");this.actualTheme=e.matches?"dark":"light",e.addEventListener("change",t=>{this.actualTheme=t.matches?"dark":"light",this.listEl?.setAttribute("data-sonner-theme",this.actualTheme)})}}createContainer(){let[e,t]=this.options.position.split("-");this.container=document.createElement("section");let i=this.options.hotkey.join("+").replace(/Key/g,"").replace(/Digit/g,"");this.container.setAttribute("aria-label",`${this.options.containerAriaLabel} ${i}`),this.container.setAttribute("tabindex","-1"),this.container.setAttribute("aria-live","polite"),this.container.setAttribute("aria-relevant","additions text"),this.container.setAttribute("aria-atomic","false"),this.listEl=document.createElement("ol"),this.listEl.setAttribute("data-sonner-toaster",""),this.listEl.setAttribute("data-sonner-theme",this.actualTheme),this.listEl.setAttribute("data-y-position",e),this.listEl.setAttribute("data-x-position",t),this.listEl.setAttribute("dir",this.options.dir==="auto"?x():this.options.dir),this.listEl.setAttribute("tabindex","-1"),this.options.className&&(this.listEl.className=this.options.className),this.listEl.style.setProperty("--front-toast-height","0px"),this.listEl.style.setProperty("--width",`${$}px`),this.listEl.style.setProperty("--gap",`${this.options.gap}px`);let a=V(this.options.offset,this.options.mobileOffset);Object.entries(a).forEach(([l,c])=>{this.listEl.style.setProperty(l,c)}),Object.assign(this.listEl.style,this.options.style),this.container.appendChild(this.listEl)}setupEventListeners(){document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("visibilitychange",this.handleVisibilityChange),this.boundListHandlers={mouseenter:()=>this.setExpanded(!0),mousemove:()=>this.setExpanded(!0),mouseleave:()=>{this.interacting||this.setExpanded(!1)},pointerdown:e=>{e.target.dataset.dismissible!=="false"&&(this.interacting=!0)},pointerup:()=>{this.interacting=!1}},this.listEl?.addEventListener("mouseenter",this.boundListHandlers.mouseenter),this.listEl?.addEventListener("mousemove",this.boundListHandlers.mousemove),this.listEl?.addEventListener("mouseleave",this.boundListHandlers.mouseleave),this.listEl?.addEventListener("pointerdown",this.boundListHandlers.pointerdown),this.listEl?.addEventListener("pointerup",this.boundListHandlers.pointerup)}setExpanded(e){this.expanded=e,this.toastInstances.forEach(t=>{t.element.dataset.expanded=String(e||this.options.expand)}),this.updatePositions()}subscribeToState(){this.unsubscribe=u.subscribe(e=>{if(e.dismiss)this.dismissToast(e.id);else{let t=e;if(this.options.id){if(t.toasterId!==this.options.id)return}else if(t.toasterId)return;this.addOrUpdateToast(t)}})}addOrUpdateToast(e){let t=this.toastInstances.get(e.id);t?this.updateToastElement(t,e):this.createToast(e)}createToast(e){let[t,i]=(e.position||this.options.position).split("-"),a=e.duration??this.options.toastOptions?.duration??this.options.duration,l=e.dismissible!==!1,c=e.closeButton??this.options.toastOptions?.closeButton??this.options.closeButton,s=e.type,n=document.createElement("li");n.setAttribute("tabindex","0"),n.setAttribute("data-sonner-toast",""),n.setAttribute("data-styled",String(!e.custom&&!e.unstyled&&!this.options.toastOptions?.unstyled)),n.setAttribute("data-mounted","false"),n.setAttribute("data-promise",String(!!e.promise)),n.setAttribute("data-swiped","false"),n.setAttribute("data-removed","false"),n.setAttribute("data-visible","true"),n.setAttribute("data-y-position",t),n.setAttribute("data-x-position",i),n.setAttribute("data-front","true"),n.setAttribute("data-swiping","false"),n.setAttribute("data-dismissible",String(l)),n.setAttribute("data-type",s||""),n.setAttribute("data-invert",String(e.invert??this.options.invert)),n.setAttribute("data-swipe-out","false"),n.setAttribute("data-expanded",String(this.expanded||this.options.expand)),n.setAttribute("data-rich-colors",String(e.richColors??this.options.richColors)),e.testId&&n.setAttribute("data-testid",e.testId),n.className=h(this.options.toastOptions?.className,e.className,this.options.toastOptions?.classNames?.toast,e.classNames?.toast,this.options.toastOptions?.classNames?.[s],e.classNames?.[s]),this.buildToastContent(n,e,c);let o={toast:e,element:n,mounted:!1,removed:!1,height:0,offset:0,remainingTime:a,closeTimerStart:0,swiping:!1,swipeDirection:null,pointerStart:null,dragStartTime:null,isSwiped:!1};this.setupSwipeHandlers(o,l),this.listEl?.prepend(n),this.toastInstances.set(e.id,o),requestAnimationFrame(()=>{let r=n.getBoundingClientRect().height;o.height=r,this.heights.unshift({toastId:e.id,height:r,position:e.position||this.options.position}),n.dataset.mounted="true",this.updatePositions(),s!=="loading"&&e.promise===void 0&&a!==1/0&&this.startTimer(o)})}buildToastContent(e,t,i){let a=t.type;if(t.custom){let s;if(typeof t.custom=="string"){let n=document.createElement("div");n.innerHTML=t.custom,s=n.firstElementChild||n}else typeof t.custom=="function"?s=t.custom(t.id):s=t.custom;e.appendChild(s);return}if(i&&a!=="loading"){let s=document.createElement("button");s.setAttribute("aria-label","Close toast"),s.setAttribute("data-close-button",""),s.className=h(this.options.toastOptions?.classNames?.closeButton,t.classNames?.closeButton),s.innerHTML=E,s.addEventListener("click",()=>{t.dismissible!==!1&&(this.removeToast(t),t.onDismiss?.(t))}),e.appendChild(s)}if(a||t.icon){let s=document.createElement("div");if(s.setAttribute("data-icon",""),s.className=h(this.options.toastOptions?.classNames?.icon,t.classNames?.icon),t.type==="loading"&&!t.icon){let n=w(!0,h(this.options.toastOptions?.classNames?.loader,t.classNames?.loader));s.appendChild(n)}else if(t.icon)typeof t.icon=="string"?s.innerHTML=t.icon:s.appendChild(t.icon);else{let n=g(a);n&&(s.innerHTML=n)}e.appendChild(s)}let l=document.createElement("div");l.setAttribute("data-content",""),l.className=h(this.options.toastOptions?.classNames?.content,t.classNames?.content);let c=document.createElement("div");if(c.setAttribute("data-title",""),c.className=h(this.options.toastOptions?.classNames?.title,t.classNames?.title),c.textContent=t.title||"",l.appendChild(c),t.description){let s=document.createElement("div");s.setAttribute("data-description",""),s.className=h(this.options.toastOptions?.descriptionClassName,t.descriptionClassName,this.options.toastOptions?.classNames?.description,t.classNames?.description),s.textContent=t.description,l.appendChild(s)}if(e.appendChild(l),t.cancel&&T(t.cancel)){let s=document.createElement("button");s.setAttribute("data-button",""),s.setAttribute("data-cancel",""),s.className=h(this.options.toastOptions?.classNames?.cancelButton,t.classNames?.cancelButton),s.textContent=t.cancel.label,Object.assign(s.style,t.cancelButtonStyle||this.options.toastOptions?.cancelButtonStyle),s.addEventListener("click",n=>{t.dismissible!==!1&&(t.cancel.onClick(n),this.removeToast(t))}),e.appendChild(s)}if(t.action&&T(t.action)){let s=document.createElement("button");s.setAttribute("data-button",""),s.setAttribute("data-action",""),s.className=h(this.options.toastOptions?.classNames?.actionButton,t.classNames?.actionButton),s.textContent=t.action.label,Object.assign(s.style,t.actionButtonStyle||this.options.toastOptions?.actionButtonStyle),s.addEventListener("click",n=>{t.action.onClick(n),n.defaultPrevented||this.removeToast(t)}),e.appendChild(s)}}setupSwipeHandlers(e,t){let{element:i,toast:a}=e,l=a.position||this.options.position,c=this.options.swipeDirections??z(l);i.addEventListener("pointerdown",s=>{s.button!==2&&(a.type==="loading"||!t||(e.dragStartTime=new Date,e.pointerStart={x:s.clientX,y:s.clientY},s.target.setPointerCapture(s.pointerId),s.target.tagName!=="BUTTON"&&(e.swiping=!0,i.dataset.swiping="true")))}),i.addEventListener("pointermove",s=>{if(!e.pointerStart||!t||(window.getSelection()?.toString().length??0)>0)return;let o=s.clientY-e.pointerStart.y,r=s.clientX-e.pointerStart.x;!e.swipeDirection&&(Math.abs(r)>1||Math.abs(o)>1)&&(e.swipeDirection=Math.abs(r)>Math.abs(o)?"x":"y");let p={x:0,y:0},f=m=>1/(1.5+Math.abs(m)/20);if(e.swipeDirection==="y"){if(c.includes("top")||c.includes("bottom"))if(c.includes("top")&&o<0||c.includes("bottom")&&o>0)p.y=o;else{let m=o*f(o);p.y=Math.abs(m)<Math.abs(o)?m:o}}else if(e.swipeDirection==="x"&&(c.includes("left")||c.includes("right")))if(c.includes("left")&&r<0||c.includes("right")&&r>0)p.x=r;else{let m=r*f(r);p.x=Math.abs(m)<Math.abs(r)?m:r}(Math.abs(p.x)>0||Math.abs(p.y)>0)&&(e.isSwiped=!0,i.dataset.swiped="true"),i.style.setProperty("--swipe-amount-x",`${p.x}px`),i.style.setProperty("--swipe-amount-y",`${p.y}px`)}),i.addEventListener("pointerup",()=>{if(!t)return;let s=parseFloat(i.style.getPropertyValue("--swipe-amount-x")||"0"),n=parseFloat(i.style.getPropertyValue("--swipe-amount-y")||"0"),o=e.dragStartTime?new Date().getTime()-e.dragStartTime.getTime():1e3,r=e.swipeDirection==="x"?s:n,p=Math.abs(r)/o;Math.abs(r)>=j||p>.11?(a.onDismiss?.(a),e.swipeDirection==="x"?i.dataset.swipeDirection=s>0?"right":"left":i.dataset.swipeDirection=n>0?"down":"up",i.dataset.swipeOut="true",this.removeToast(a)):(i.style.setProperty("--swipe-amount-x","0px"),i.style.setProperty("--swipe-amount-y","0px")),e.isSwiped=!1,e.swiping=!1,e.swipeDirection=null,e.pointerStart=null,i.dataset.swiped="false",i.dataset.swiping="false"})}updateToastElement(e,t){let{element:i}=e;e.toast=t,i.dataset.type=t.type||"";let a=i.querySelector("[data-title]");a&&(a.textContent=t.title||"");let l=i.querySelector("[data-description]");t.description?(l||(l=document.createElement("div"),l.setAttribute("data-description",""),i.querySelector("[data-content]")?.appendChild(l)),l.textContent=t.description):l&&l.remove();let c=i.querySelector("[data-icon]");if(c&&t.type&&t.type!=="loading"){let s=g(t.type);s&&(c.innerHTML=s)}t.type!=="loading"&&(e.remainingTime=t.duration??this.options.duration,this.startTimer(e))}startTimer(e){let{toast:t}=e;t.promise&&t.type==="loading"||t.duration===1/0||t.type==="loading"||this.expanded||this.interacting||this.isDocumentHidden||(clearTimeout(e.closeTimeout),e.closeTimerStart=Date.now(),e.closeTimeout=setTimeout(()=>{t.onAutoClose?.(t),this.removeToast(t)},e.remainingTime))}pauseTimer(e){if(e.closeTimerStart>0){let t=Date.now()-e.closeTimerStart;e.remainingTime=Math.max(0,e.remainingTime-t)}clearTimeout(e.closeTimeout)}dismissToast(e){let t=this.toastInstances.get(e);t&&(t.element.dataset.removed="true",this.removeToast(t.toast))}removeToast(e){let t=this.toastInstances.get(e.id);!t||t.removed||(t.removed=!0,t.element.dataset.removed="true",clearTimeout(t.closeTimeout),this.heights=this.heights.filter(i=>i.toastId!==e.id),setTimeout(()=>{t.element.remove(),this.toastInstances.delete(e.id),u.dismiss(e.id),this.updatePositions()},F),this.updatePositions())}updatePositions(){let{visibleToasts:e,gap:t,expand:i}=this.options,a=this.heights.map(n=>this.toastInstances.get(n.toastId)).filter(n=>n!==void 0&&!n.removed),l=a.length>0?a[0].height:0,c=this.expanded||i;a.forEach((n,o)=>{let{element:r}=n;if(!(o===0)&&!c){let f=r.getBoundingClientRect().height;f>0&&(r.style.height=`${f}px`)}}),a.length>1&&this.listEl?.offsetHeight;let s=0;a.forEach((n,o)=>{let{element:r}=n,p=o===0,f=o<e;r.dataset.index=String(o),r.dataset.visible=String(f);let m=o*t+s;n.offset=m,r.style.setProperty("--index",String(o)),r.style.setProperty("--toasts-before",String(o)),r.style.setProperty("--z-index",String(a.length-o)),r.style.setProperty("--offset",`${m}px`),r.style.setProperty("--initial-height",`${n.height}px`),c?r.style.height=`${n.height}px`:p?r.style.height="":r.style.height=`${l}px`,s+=n.height}),this.listEl&&a.length>0&&this.listEl.style.setProperty("--front-toast-height",`${l}px`),a.forEach((n,o)=>{n.element.dataset.front=String(o===0)})}};function _(d){return new b(d)}export{E as CloseIcon,u as ToastState,b as Toaster,w as createLoader,_ as createToaster,g as getAsset,T as isAction,O as toast};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/state.ts", "../src/assets.ts", "../src/types.ts", "../src/toaster.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Toast state management - Observer pattern\n * Vanilla JS port of sonner's state.ts\n */\n\nimport type {\n CustomContent,\n ExternalToast,\n PromiseData,\n PromiseT,\n ToastT,\n ToastToDismiss,\n ToastTypes,\n} from './types';\n\nlet toastsCounter = 1;\n\ntype Subscriber = (toast: ToastT | ToastToDismiss) => void;\n\nclass Observer {\n subscribers: Subscriber[] = [];\n toasts: ToastT[] = [];\n dismissedToasts: Set<string | number> = new Set();\n\n subscribe(subscriber: Subscriber): () => void {\n this.subscribers.push(subscriber);\n return () => {\n const index = this.subscribers.indexOf(subscriber);\n this.subscribers.splice(index, 1);\n };\n }\n\n publish(data: ToastT | ToastToDismiss): void {\n this.subscribers.forEach((subscriber) => subscriber(data));\n }\n\n addToast(data: ToastT): void {\n this.publish(data);\n this.toasts = [...this.toasts, data];\n }\n\n create(\n data: ExternalToast & {\n message?: string;\n type?: ToastTypes;\n promise?: PromiseT;\n }\n ): number | string {\n const { message, ...rest } = data;\n const id =\n typeof data?.id === 'number' || (data.id && String(data.id).length > 0)\n ? data.id!\n : toastsCounter++;\n const alreadyExists = this.toasts.find((toast) => toast.id === id);\n const dismissible = data.dismissible === undefined ? true : data.dismissible;\n\n if (this.dismissedToasts.has(id)) {\n this.dismissedToasts.delete(id);\n }\n\n if (alreadyExists) {\n this.toasts = this.toasts.map((toast) => {\n if (toast.id === id) {\n this.publish({ ...toast, ...data, id, title: message } as ToastT);\n return {\n ...toast,\n ...data,\n id,\n dismissible,\n title: message,\n };\n }\n return toast;\n });\n } else {\n this.addToast({ title: message, ...rest, dismissible, id } as ToastT);\n }\n\n return id;\n }\n\n dismiss(id?: number | string): number | string | undefined {\n if (id) {\n this.dismissedToasts.add(id);\n requestAnimationFrame(() =>\n this.subscribers.forEach((subscriber) => subscriber({ id, dismiss: true }))\n );\n } else {\n this.toasts.forEach((toast) => {\n this.subscribers.forEach((subscriber) => subscriber({ id: toast.id, dismiss: true }));\n });\n }\n return id;\n }\n\n message(message: string, data?: ExternalToast): number | string {\n return this.create({ ...data, message });\n }\n\n error(message: string, data?: ExternalToast): number | string {\n return this.create({ ...data, message, type: 'error' });\n }\n\n success(message: string, data?: ExternalToast): number | string {\n return this.create({ ...data, type: 'success', message });\n }\n\n info(message: string, data?: ExternalToast): number | string {\n return this.create({ ...data, type: 'info', message });\n }\n\n warning(message: string, data?: ExternalToast): number | string {\n return this.create({ ...data, type: 'warning', message });\n }\n\n loading(message: string, data?: ExternalToast): number | string {\n return this.create({ ...data, type: 'loading', message });\n }\n\n // Create toast with any custom type (e.g., 'congrats', 'celebration')\n withType(type: string, message: string, data?: ExternalToast): number | string {\n return this.create({ ...data, type, message });\n }\n\n promise<ToastData>(\n promise: PromiseT<ToastData>,\n data?: PromiseData<ToastData>\n ): { unwrap: () => Promise<ToastData> } | (number & { unwrap: () => Promise<ToastData> }) | (string & { unwrap: () => Promise<ToastData> }) | undefined {\n if (!data) return undefined;\n\n let id: string | number | undefined = undefined;\n if (data.loading !== undefined) {\n id = this.create({\n ...data,\n promise,\n type: 'loading',\n message: data.loading,\n description: typeof data.description !== 'function' ? data.description : undefined,\n });\n }\n\n const p = Promise.resolve(typeof promise === 'function' ? promise() : promise);\n\n let shouldDismiss = id !== undefined;\n let result: ['resolve', ToastData] | ['reject', unknown];\n\n const originalPromise = p\n .then(async (response) => {\n result = ['resolve', response];\n\n // Check for HTTP error response\n if (isHttpResponse(response) && !response.ok) {\n shouldDismiss = false;\n const promiseData =\n typeof data.error === 'function'\n ? await data.error(`HTTP error! status: ${response.status}`)\n : data.error;\n const description =\n typeof data.description === 'function'\n ? await data.description(`HTTP error! status: ${response.status}`)\n : data.description;\n this.create({ id, type: 'error', description, message: promiseData });\n } else if (response instanceof Error) {\n shouldDismiss = false;\n const promiseData =\n typeof data.error === 'function' ? await data.error(response) : data.error;\n const description =\n typeof data.description === 'function'\n ? await data.description(response)\n : data.description;\n this.create({ id, type: 'error', description, message: promiseData });\n } else if (data.success !== undefined) {\n shouldDismiss = false;\n const promiseData =\n typeof data.success === 'function' ? await data.success(response) : data.success;\n const description =\n typeof data.description === 'function'\n ? await data.description(response)\n : data.description;\n this.create({ id, type: 'success', description, message: promiseData });\n }\n })\n .catch(async (error: unknown) => {\n result = ['reject', error];\n if (data.error !== undefined) {\n shouldDismiss = false;\n const promiseData =\n typeof data.error === 'function' ? await data.error(error) : data.error;\n const description =\n typeof data.description === 'function'\n ? await data.description(error)\n : data.description;\n this.create({ id, type: 'error', description, message: promiseData });\n }\n })\n .finally(() => {\n if (shouldDismiss) {\n this.dismiss(id);\n id = undefined;\n }\n data.finally?.();\n });\n\n const unwrap = () =>\n new Promise<ToastData>((resolve, reject) =>\n originalPromise\n .then(() => (result[0] === 'reject' ? reject(result[1]) : resolve(result[1])))\n .catch(reject)\n );\n\n if (typeof id !== 'string' && typeof id !== 'number') {\n return { unwrap };\n } else {\n return Object.assign(id, { unwrap }) as (number | string) & { unwrap: () => Promise<ToastData> };\n }\n }\n\n custom(content: CustomContent, data?: ExternalToast): number | string {\n const id = data?.id ?? toastsCounter++;\n this.addToast({\n ...data,\n id,\n custom: content,\n } as ToastT);\n return id;\n }\n\n getActiveToasts(): ToastT[] {\n return this.toasts.filter((toast) => !this.dismissedToasts.has(toast.id));\n }\n}\n\nfunction isHttpResponse(data: unknown): data is Response {\n return (\n data !== null &&\n typeof data === 'object' &&\n 'ok' in data &&\n typeof (data as Response).ok === 'boolean' &&\n 'status' in data &&\n typeof (data as Response).status === 'number'\n );\n}\n\nexport const ToastState = new Observer();\n\n// Main toast function\nconst toastFunction = (message: string, data?: ExternalToast): number | string => {\n const id = data?.id ?? toastsCounter++;\n ToastState.addToast({\n title: message,\n ...data,\n id,\n } as ToastT);\n return id;\n};\n\nconst getHistory = () => ToastState.toasts;\nconst getToasts = () => ToastState.getActiveToasts();\n\n// Export toast API with all methods\nexport const toast = Object.assign(\n toastFunction,\n {\n success: ToastState.success.bind(ToastState),\n info: ToastState.info.bind(ToastState),\n warning: ToastState.warning.bind(ToastState),\n error: ToastState.error.bind(ToastState),\n message: ToastState.message.bind(ToastState),\n promise: ToastState.promise.bind(ToastState),\n dismiss: ToastState.dismiss.bind(ToastState),\n loading: ToastState.loading.bind(ToastState),\n custom: ToastState.custom.bind(ToastState),\n withType: ToastState.withType.bind(ToastState),\n },\n { getHistory, getToasts }\n);\n", "/**\n * SVG icons and loader component\n * Vanilla JS port of sonner's assets.tsx\n */\n\nimport type { ToastTypes } from './types';\n\nexport function getAsset(type: ToastTypes): string | null {\n switch (type) {\n case 'success':\n return SuccessIcon;\n case 'info':\n return InfoIcon;\n case 'warning':\n return WarningIcon;\n case 'error':\n return ErrorIcon;\n default:\n return null;\n }\n}\n\nexport function createLoader(visible: boolean, className?: string): HTMLElement {\n const wrapper = document.createElement('div');\n wrapper.className = ['sonner-loading-wrapper', className].filter(Boolean).join(' ');\n wrapper.dataset.visible = String(visible);\n\n const spinner = document.createElement('div');\n spinner.className = 'sonner-spinner';\n\n for (let i = 0; i < 12; i++) {\n const bar = document.createElement('div');\n bar.className = 'sonner-loading-bar';\n spinner.appendChild(bar);\n }\n\n wrapper.appendChild(spinner);\n return wrapper;\n}\n\nconst SuccessIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" height=\"20\" width=\"20\">\n <path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\" clip-rule=\"evenodd\" />\n</svg>`;\n\nconst WarningIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" height=\"20\" width=\"20\">\n <path fill-rule=\"evenodd\" d=\"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z\" clip-rule=\"evenodd\" />\n</svg>`;\n\nconst InfoIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" height=\"20\" width=\"20\">\n <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z\" clip-rule=\"evenodd\" />\n</svg>`;\n\nconst ErrorIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" height=\"20\" width=\"20\">\n <path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\" />\n</svg>`;\n\nexport const CloseIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n</svg>`;\n", "/**\n * Type definitions for sonner-vanilla\n * Vanilla JS port of sonner's types\n */\n\n// Built-in types with icons\nexport type BuiltInToastTypes = 'normal' | 'action' | 'success' | 'info' | 'warning' | 'error' | 'loading' | 'default';\n\n// Allow any string for custom types (e.g., 'congrats', 'celebration')\nexport type ToastTypes = BuiltInToastTypes | (string & {});\n\nexport type Position = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center';\n\nexport type SwipeDirection = 'top' | 'right' | 'bottom' | 'left';\n\nexport type Theme = 'light' | 'dark' | 'system';\n\nexport interface ToastClassnames {\n toast?: string;\n title?: string;\n description?: string;\n loader?: string;\n closeButton?: string;\n cancelButton?: string;\n actionButton?: string;\n success?: string;\n error?: string;\n info?: string;\n warning?: string;\n loading?: string;\n default?: string;\n content?: string;\n icon?: string;\n}\n\nexport interface Action {\n label: string;\n onClick: (event: MouseEvent) => void;\n}\n\n// Custom content can be HTML string, HTMLElement, or a builder function\nexport type CustomContent = string | HTMLElement | ((id: number | string) => HTMLElement);\n\nexport interface ToastT {\n id: number | string;\n toasterId?: string;\n title?: string;\n type?: ToastTypes;\n // Custom content replaces the default toast structure\n custom?: CustomContent;\n icon?: string | HTMLElement;\n richColors?: boolean;\n invert?: boolean;\n closeButton?: boolean;\n dismissible?: boolean;\n description?: string;\n duration?: number;\n delete?: boolean;\n action?: Action;\n cancel?: Action;\n onDismiss?: (toast: ToastT) => void;\n onAutoClose?: (toast: ToastT) => void;\n promise?: PromiseT;\n cancelButtonStyle?: Partial<CSSStyleDeclaration>;\n actionButtonStyle?: Partial<CSSStyleDeclaration>;\n style?: Partial<CSSStyleDeclaration>;\n unstyled?: boolean;\n className?: string;\n classNames?: ToastClassnames;\n descriptionClassName?: string;\n position?: Position;\n testId?: string;\n}\n\nexport interface ToastToDismiss {\n id: number | string;\n dismiss: boolean;\n}\n\nexport type ExternalToast = Omit<ToastT, 'id' | 'type' | 'title' | 'delete' | 'promise'> & {\n id?: number | string;\n toasterId?: string;\n};\n\nexport type PromiseT<Data = unknown> = Promise<Data> | (() => Promise<Data>);\n\nexport type PromiseTResult<Data = unknown> = string | ((data: Data) => string | Promise<string>);\n\nexport interface PromiseData<ToastData = unknown> {\n loading?: string;\n success?: PromiseTResult<ToastData>;\n error?: PromiseTResult<unknown>;\n description?: PromiseTResult<unknown>;\n finally?: () => void | Promise<void>;\n id?: number | string;\n}\n\nexport interface HeightT {\n height: number;\n toastId: number | string;\n position: Position;\n}\n\nexport type Offset =\n | {\n top?: string | number;\n right?: string | number;\n bottom?: string | number;\n left?: string | number;\n }\n | string\n | number;\n\nexport interface ToasterOptions {\n id?: string;\n invert?: boolean;\n theme?: Theme;\n position?: Position;\n hotkey?: string[];\n richColors?: boolean;\n expand?: boolean;\n duration?: number;\n gap?: number;\n visibleToasts?: number;\n closeButton?: boolean;\n className?: string;\n style?: Partial<CSSStyleDeclaration>;\n offset?: Offset;\n mobileOffset?: Offset;\n dir?: 'rtl' | 'ltr' | 'auto';\n swipeDirections?: SwipeDirection[];\n containerAriaLabel?: string;\n toastOptions?: {\n className?: string;\n closeButton?: boolean;\n descriptionClassName?: string;\n style?: Partial<CSSStyleDeclaration>;\n cancelButtonStyle?: Partial<CSSStyleDeclaration>;\n actionButtonStyle?: Partial<CSSStyleDeclaration>;\n duration?: number;\n unstyled?: boolean;\n classNames?: ToastClassnames;\n };\n}\n\nexport function isAction(action: Action | unknown): action is Action {\n return typeof action === 'object' && action !== null && 'label' in action && 'onClick' in action;\n}\n", "/**\n * Toaster component - DOM manipulation and rendering\n * Vanilla JS port of sonner's index.tsx\n */\n\nimport { CloseIcon, createLoader, getAsset } from './assets';\nimport { ToastState } from './state';\nimport {\n isAction,\n type HeightT,\n type Offset,\n type SwipeDirection,\n type ToasterOptions,\n type ToastT,\n type ToastToDismiss,\n} from './types';\n\n// Constants\nconst VISIBLE_TOASTS_AMOUNT = 3;\nconst VIEWPORT_OFFSET = '24px';\nconst MOBILE_VIEWPORT_OFFSET = '16px';\nconst TOAST_LIFETIME = 4000;\nconst TOAST_WIDTH = 356;\nconst GAP = 14;\nconst SWIPE_THRESHOLD = 45;\nconst TIME_BEFORE_UNMOUNT = 200;\n\nfunction cn(...classes: (string | undefined)[]): string {\n return classes.filter(Boolean).join(' ');\n}\n\nfunction getDefaultSwipeDirections(position: string): SwipeDirection[] {\n const [y, x] = position.split('-');\n const directions: SwipeDirection[] = [];\n if (y) directions.push(y as SwipeDirection);\n if (x) directions.push(x as SwipeDirection);\n return directions;\n}\n\nfunction getDocumentDirection(): 'ltr' | 'rtl' | 'auto' {\n if (typeof window === 'undefined' || typeof document === 'undefined') return 'ltr';\n const dirAttribute = document.documentElement.getAttribute('dir');\n if (dirAttribute === 'auto' || !dirAttribute) {\n return window.getComputedStyle(document.documentElement).direction as 'ltr' | 'rtl';\n }\n return dirAttribute as 'ltr' | 'rtl';\n}\n\nfunction assignOffset(\n defaultOffset: Offset | undefined,\n mobileOffset: Offset | undefined\n): Record<string, string> {\n const styles: Record<string, string> = {};\n\n [defaultOffset, mobileOffset].forEach((offset, index) => {\n const isMobile = index === 1;\n const prefix = isMobile ? '--mobile-offset' : '--offset';\n const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;\n\n function assignAll(offset: string | number) {\n ['top', 'right', 'bottom', 'left'].forEach((key) => {\n styles[`${prefix}-${key}`] = typeof offset === 'number' ? `${offset}px` : offset;\n });\n }\n\n if (typeof offset === 'number' || typeof offset === 'string') {\n assignAll(offset);\n } else if (typeof offset === 'object' && offset !== null) {\n ['top', 'right', 'bottom', 'left'].forEach((key) => {\n const k = key as keyof typeof offset;\n if (offset[k] === undefined) {\n styles[`${prefix}-${key}`] = defaultValue;\n } else {\n styles[`${prefix}-${key}`] = typeof offset[k] === 'number' ? `${offset[k]}px` : String(offset[k]);\n }\n });\n } else {\n assignAll(defaultValue);\n }\n });\n\n return styles;\n}\n\n\ninterface ToastInstance {\n toast: ToastT;\n element: HTMLLIElement;\n mounted: boolean;\n removed: boolean;\n height: number;\n offset: number;\n closeTimeout?: ReturnType<typeof setTimeout>;\n remainingTime: number;\n closeTimerStart: number;\n swiping: boolean;\n swipeDirection: 'x' | 'y' | null;\n pointerStart: { x: number; y: number } | null;\n dragStartTime: Date | null;\n isSwiped: boolean;\n}\n\nexport class Toaster {\n private container: HTMLElement | null = null;\n private listEl: HTMLOListElement | null = null;\n private toastInstances: Map<number | string, ToastInstance> = new Map();\n private heights: HeightT[] = [];\n private expanded = false;\n private interacting = false;\n private unsubscribe: (() => void) | null = null;\n private boundListHandlers: {\n mouseenter: () => void;\n mousemove: () => void;\n mouseleave: () => void;\n pointerdown: (e: PointerEvent) => void;\n pointerup: () => void;\n } | null = null;\n private options: ToasterOptions & {\n id: string;\n invert: boolean;\n theme: 'light' | 'dark' | 'system';\n position: string;\n hotkey: string[];\n richColors: boolean;\n expand: boolean;\n duration: number;\n gap: number;\n visibleToasts: number;\n closeButton: boolean;\n className: string;\n style: Partial<CSSStyleDeclaration>;\n offset: Offset;\n mobileOffset: Offset;\n dir: 'rtl' | 'ltr' | 'auto';\n containerAriaLabel: string;\n toastOptions: NonNullable<ToasterOptions['toastOptions']>;\n };\n private actualTheme: 'light' | 'dark' = 'light';\n private isDocumentHidden = false;\n\n constructor(options: ToasterOptions = {}) {\n this.options = {\n id: options.id ?? '',\n invert: options.invert ?? false,\n theme: options.theme ?? 'light',\n position: options.position ?? 'bottom-right',\n hotkey: options.hotkey ?? ['altKey', 'KeyT'],\n richColors: options.richColors ?? false,\n expand: options.expand ?? false,\n duration: options.duration ?? TOAST_LIFETIME,\n gap: options.gap ?? GAP,\n visibleToasts: options.visibleToasts ?? VISIBLE_TOASTS_AMOUNT,\n closeButton: options.closeButton ?? false,\n className: options.className ?? '',\n style: options.style ?? {},\n offset: options.offset ?? VIEWPORT_OFFSET,\n mobileOffset: options.mobileOffset ?? MOBILE_VIEWPORT_OFFSET,\n dir: options.dir ?? getDocumentDirection(),\n swipeDirections: options.swipeDirections ?? undefined,\n containerAriaLabel: options.containerAriaLabel ?? 'Notifications',\n toastOptions: options.toastOptions ?? {},\n };\n }\n\n mount(target: HTMLElement | string = document.body): void {\n const targetEl = typeof target === 'string' ? document.querySelector(target) : target;\n if (!targetEl) {\n console.error('Toaster: target element not found');\n return;\n }\n\n this.setupTheme();\n this.createContainer();\n targetEl.appendChild(this.container!);\n this.setupEventListeners();\n this.subscribeToState();\n }\n\n unmount(): void {\n document.removeEventListener('keydown', this.handleKeyDown);\n document.removeEventListener('visibilitychange', this.handleVisibilityChange);\n\n // Remove list event listeners\n if (this.listEl && this.boundListHandlers) {\n this.listEl.removeEventListener('mouseenter', this.boundListHandlers.mouseenter);\n this.listEl.removeEventListener('mousemove', this.boundListHandlers.mousemove);\n this.listEl.removeEventListener('mouseleave', this.boundListHandlers.mouseleave);\n this.listEl.removeEventListener('pointerdown', this.boundListHandlers.pointerdown);\n this.listEl.removeEventListener('pointerup', this.boundListHandlers.pointerup);\n }\n this.boundListHandlers = null;\n\n this.unsubscribe?.();\n this.container?.remove();\n this.container = null;\n this.listEl = null;\n this.toastInstances.clear();\n }\n\n private setupTheme(): void {\n if (this.options.theme !== 'system') {\n this.actualTheme = this.options.theme as 'light' | 'dark';\n return;\n }\n\n if (typeof window !== 'undefined' && window.matchMedia) {\n const darkQuery = window.matchMedia('(prefers-color-scheme: dark)');\n this.actualTheme = darkQuery.matches ? 'dark' : 'light';\n\n darkQuery.addEventListener('change', (e) => {\n this.actualTheme = e.matches ? 'dark' : 'light';\n this.listEl?.setAttribute('data-sonner-theme', this.actualTheme);\n });\n }\n }\n\n private createContainer(): void {\n const [y, x] = this.options.position.split('-');\n\n // Create section wrapper\n this.container = document.createElement('section');\n const hotkeyLabel = this.options.hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');\n this.container.setAttribute('aria-label', `${this.options.containerAriaLabel} ${hotkeyLabel}`);\n this.container.setAttribute('tabindex', '-1');\n this.container.setAttribute('aria-live', 'polite');\n this.container.setAttribute('aria-relevant', 'additions text');\n this.container.setAttribute('aria-atomic', 'false');\n\n // Create ordered list\n this.listEl = document.createElement('ol');\n this.listEl.setAttribute('data-sonner-toaster', '');\n this.listEl.setAttribute('data-sonner-theme', this.actualTheme);\n this.listEl.setAttribute('data-y-position', y);\n this.listEl.setAttribute('data-x-position', x);\n this.listEl.setAttribute('dir', this.options.dir === 'auto' ? getDocumentDirection() : this.options.dir);\n this.listEl.setAttribute('tabindex', '-1');\n\n if (this.options.className) {\n this.listEl.className = this.options.className;\n }\n\n // Apply styles - CSS custom properties must use setProperty\n this.listEl.style.setProperty('--front-toast-height', '0px');\n this.listEl.style.setProperty('--width', `${TOAST_WIDTH}px`);\n this.listEl.style.setProperty('--gap', `${this.options.gap}px`);\n\n // Apply offset styles (CSS custom properties)\n const offsetStyles = assignOffset(this.options.offset, this.options.mobileOffset);\n Object.entries(offsetStyles).forEach(([key, value]) => {\n this.listEl!.style.setProperty(key, value);\n });\n\n // Apply any additional user styles\n Object.assign(this.listEl.style, this.options.style);\n\n this.container.appendChild(this.listEl);\n }\n\n private setupEventListeners(): void {\n // Hotkey listener\n document.addEventListener('keydown', this.handleKeyDown);\n\n // Document visibility\n document.addEventListener('visibilitychange', this.handleVisibilityChange);\n\n // List interactions - store references for cleanup\n this.boundListHandlers = {\n mouseenter: () => this.setExpanded(true),\n mousemove: () => this.setExpanded(true),\n mouseleave: () => {\n if (!this.interacting) this.setExpanded(false);\n },\n pointerdown: (e: PointerEvent) => {\n const target = e.target as HTMLElement;\n if (target.dataset.dismissible !== 'false') {\n this.interacting = true;\n }\n },\n pointerup: () => {\n this.interacting = false;\n },\n };\n\n this.listEl?.addEventListener('mouseenter', this.boundListHandlers.mouseenter);\n this.listEl?.addEventListener('mousemove', this.boundListHandlers.mousemove);\n this.listEl?.addEventListener('mouseleave', this.boundListHandlers.mouseleave);\n this.listEl?.addEventListener('pointerdown', this.boundListHandlers.pointerdown);\n this.listEl?.addEventListener('pointerup', this.boundListHandlers.pointerup);\n }\n\n private handleKeyDown = (event: KeyboardEvent): void => {\n const { hotkey } = this.options;\n const isHotkeyPressed =\n hotkey.length > 0 &&\n hotkey.every((key) => (event as unknown as Record<string, boolean>)[key] || event.code === key);\n\n if (isHotkeyPressed) {\n this.setExpanded(true);\n this.listEl?.focus();\n }\n\n if (event.code === 'Escape' && this.listEl?.contains(document.activeElement)) {\n this.setExpanded(false);\n }\n };\n\n private handleVisibilityChange = (): void => {\n this.isDocumentHidden = document.hidden;\n // Pause/resume timers for all toasts\n this.toastInstances.forEach((instance) => {\n if (this.isDocumentHidden) {\n this.pauseTimer(instance);\n } else {\n this.startTimer(instance);\n }\n });\n };\n\n private setExpanded(expanded: boolean): void {\n this.expanded = expanded;\n this.toastInstances.forEach((instance) => {\n instance.element.dataset.expanded = String(expanded || this.options.expand);\n });\n // Update positions to recalculate heights for expanded/collapsed state\n this.updatePositions();\n }\n\n private subscribeToState(): void {\n this.unsubscribe = ToastState.subscribe((toast) => {\n if ((toast as ToastToDismiss).dismiss) {\n this.dismissToast(toast.id);\n } else {\n const toastData = toast as ToastT;\n // Filter by toasterId - only show toasts that match this toaster's id\n // If toaster has an id, only show toasts with matching toasterId\n // If toaster has no id, only show toasts without a toasterId\n if (this.options.id) {\n if (toastData.toasterId !== this.options.id) return;\n } else {\n if (toastData.toasterId) return;\n }\n this.addOrUpdateToast(toastData);\n }\n });\n }\n\n private addOrUpdateToast(toast: ToastT): void {\n const existing = this.toastInstances.get(toast.id);\n\n if (existing) {\n // Update existing toast\n this.updateToastElement(existing, toast);\n } else {\n // Create new toast\n this.createToast(toast);\n }\n }\n\n private createToast(toast: ToastT): void {\n const [y, x] = (toast.position || this.options.position).split('-');\n const duration = toast.duration ?? this.options.toastOptions?.duration ?? this.options.duration;\n const dismissible = toast.dismissible !== false;\n const closeButton = toast.closeButton ?? this.options.toastOptions?.closeButton ?? this.options.closeButton;\n const toastType = toast.type;\n\n // Create list item\n const li = document.createElement('li');\n li.setAttribute('tabindex', '0');\n li.setAttribute('data-sonner-toast', '');\n li.setAttribute('data-styled', String(!toast.custom && !toast.unstyled && !this.options.toastOptions?.unstyled));\n li.setAttribute('data-mounted', 'false');\n li.setAttribute('data-promise', String(Boolean(toast.promise)));\n li.setAttribute('data-swiped', 'false');\n li.setAttribute('data-removed', 'false');\n li.setAttribute('data-visible', 'true');\n li.setAttribute('data-y-position', y);\n li.setAttribute('data-x-position', x);\n li.setAttribute('data-front', 'true');\n li.setAttribute('data-swiping', 'false');\n li.setAttribute('data-dismissible', String(dismissible));\n li.setAttribute('data-type', toastType || '');\n li.setAttribute('data-invert', String(toast.invert ?? this.options.invert));\n li.setAttribute('data-swipe-out', 'false');\n li.setAttribute('data-expanded', String(this.expanded || this.options.expand));\n li.setAttribute('data-rich-colors', String(toast.richColors ?? this.options.richColors));\n if (toast.testId) {\n li.setAttribute('data-testid', toast.testId);\n }\n\n li.className = cn(\n this.options.toastOptions?.className,\n toast.className,\n this.options.toastOptions?.classNames?.toast,\n toast.classNames?.toast,\n this.options.toastOptions?.classNames?.[toastType as keyof typeof this.options.toastOptions.classNames],\n toast.classNames?.[toastType as keyof typeof toast.classNames]\n );\n\n // Build toast content\n this.buildToastContent(li, toast, closeButton);\n\n // Create instance\n const instance: ToastInstance = {\n toast,\n element: li,\n mounted: false,\n removed: false,\n height: 0,\n offset: 0,\n remainingTime: duration,\n closeTimerStart: 0,\n swiping: false,\n swipeDirection: null,\n pointerStart: null,\n dragStartTime: null,\n isSwiped: false,\n };\n\n // Setup pointer events for swipe\n this.setupSwipeHandlers(instance, dismissible);\n\n // Add to DOM\n this.listEl?.prepend(li);\n this.toastInstances.set(toast.id, instance);\n\n // Measure height after adding to DOM\n requestAnimationFrame(() => {\n const height = li.getBoundingClientRect().height;\n instance.height = height;\n this.heights.unshift({ toastId: toast.id, height, position: toast.position || this.options.position });\n\n // Set mounted and update positions\n li.dataset.mounted = 'true';\n this.updatePositions();\n\n // Start close timer\n if (toastType !== 'loading' && toast.promise === undefined && duration !== Infinity) {\n this.startTimer(instance);\n }\n });\n }\n\n private buildToastContent(li: HTMLLIElement, toast: ToastT, closeButton: boolean): void {\n const toastType = toast.type;\n\n // Handle custom content - replaces the default structure\n if (toast.custom) {\n let customElement: HTMLElement;\n\n if (typeof toast.custom === 'string') {\n // HTML string\n const wrapper = document.createElement('div');\n wrapper.innerHTML = toast.custom;\n customElement = wrapper.firstElementChild as HTMLElement || wrapper;\n } else if (typeof toast.custom === 'function') {\n // Builder function\n customElement = toast.custom(toast.id);\n } else {\n // HTMLElement\n customElement = toast.custom;\n }\n\n li.appendChild(customElement);\n return;\n }\n\n // Close button\n if (closeButton && toastType !== 'loading') {\n const closeBtn = document.createElement('button');\n closeBtn.setAttribute('aria-label', 'Close toast');\n closeBtn.setAttribute('data-close-button', '');\n closeBtn.className = cn(this.options.toastOptions?.classNames?.closeButton, toast.classNames?.closeButton);\n closeBtn.innerHTML = CloseIcon;\n closeBtn.addEventListener('click', () => {\n if (toast.dismissible !== false) {\n this.removeToast(toast);\n toast.onDismiss?.(toast);\n }\n });\n li.appendChild(closeBtn);\n }\n\n // Icon\n if (toastType || toast.icon) {\n const iconWrapper = document.createElement('div');\n iconWrapper.setAttribute('data-icon', '');\n iconWrapper.className = cn(this.options.toastOptions?.classNames?.icon, toast.classNames?.icon);\n\n if (toast.type === 'loading' && !toast.icon) {\n const loader = createLoader(true, cn(this.options.toastOptions?.classNames?.loader, toast.classNames?.loader));\n iconWrapper.appendChild(loader);\n } else if (toast.icon) {\n if (typeof toast.icon === 'string') {\n iconWrapper.innerHTML = toast.icon;\n } else {\n iconWrapper.appendChild(toast.icon);\n }\n } else {\n const asset = getAsset(toastType!);\n if (asset) {\n iconWrapper.innerHTML = asset;\n }\n }\n\n li.appendChild(iconWrapper);\n }\n\n // Content\n const content = document.createElement('div');\n content.setAttribute('data-content', '');\n content.className = cn(this.options.toastOptions?.classNames?.content, toast.classNames?.content);\n\n // Title\n const title = document.createElement('div');\n title.setAttribute('data-title', '');\n title.className = cn(this.options.toastOptions?.classNames?.title, toast.classNames?.title);\n title.textContent = toast.title || '';\n content.appendChild(title);\n\n // Description\n if (toast.description) {\n const desc = document.createElement('div');\n desc.setAttribute('data-description', '');\n desc.className = cn(\n this.options.toastOptions?.descriptionClassName,\n toast.descriptionClassName,\n this.options.toastOptions?.classNames?.description,\n toast.classNames?.description\n );\n desc.textContent = toast.description;\n content.appendChild(desc);\n }\n\n li.appendChild(content);\n\n // Cancel button\n if (toast.cancel && isAction(toast.cancel)) {\n const cancelBtn = document.createElement('button');\n cancelBtn.setAttribute('data-button', '');\n cancelBtn.setAttribute('data-cancel', '');\n cancelBtn.className = cn(this.options.toastOptions?.classNames?.cancelButton, toast.classNames?.cancelButton);\n cancelBtn.textContent = toast.cancel.label;\n Object.assign(cancelBtn.style, toast.cancelButtonStyle || this.options.toastOptions?.cancelButtonStyle);\n cancelBtn.addEventListener('click', (e) => {\n if (toast.dismissible !== false) {\n toast.cancel!.onClick(e);\n this.removeToast(toast);\n }\n });\n li.appendChild(cancelBtn);\n }\n\n // Action button\n if (toast.action && isAction(toast.action)) {\n const actionBtn = document.createElement('button');\n actionBtn.setAttribute('data-button', '');\n actionBtn.setAttribute('data-action', '');\n actionBtn.className = cn(this.options.toastOptions?.classNames?.actionButton, toast.classNames?.actionButton);\n actionBtn.textContent = toast.action.label;\n Object.assign(actionBtn.style, toast.actionButtonStyle || this.options.toastOptions?.actionButtonStyle);\n actionBtn.addEventListener('click', (e) => {\n toast.action!.onClick(e);\n if (!e.defaultPrevented) {\n this.removeToast(toast);\n }\n });\n li.appendChild(actionBtn);\n }\n }\n\n private setupSwipeHandlers(instance: ToastInstance, dismissible: boolean): void {\n const { element: li, toast } = instance;\n const position = toast.position || this.options.position;\n const swipeDirections = this.options.swipeDirections ?? getDefaultSwipeDirections(position);\n\n li.addEventListener('pointerdown', (e) => {\n if (e.button === 2) return; // Right click\n if (toast.type === 'loading' || !dismissible) return;\n\n instance.dragStartTime = new Date();\n instance.pointerStart = { x: e.clientX, y: e.clientY };\n (e.target as HTMLElement).setPointerCapture(e.pointerId);\n\n if ((e.target as HTMLElement).tagName !== 'BUTTON') {\n instance.swiping = true;\n li.dataset.swiping = 'true';\n }\n });\n\n li.addEventListener('pointermove', (e) => {\n if (!instance.pointerStart || !dismissible) return;\n\n const isHighlighted = (window.getSelection()?.toString().length ?? 0) > 0;\n if (isHighlighted) return;\n\n const yDelta = e.clientY - instance.pointerStart.y;\n const xDelta = e.clientX - instance.pointerStart.x;\n\n // Determine swipe direction\n if (!instance.swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {\n instance.swipeDirection = Math.abs(xDelta) > Math.abs(yDelta) ? 'x' : 'y';\n }\n\n let swipeAmount = { x: 0, y: 0 };\n\n const getDampening = (delta: number) => {\n const factor = Math.abs(delta) / 20;\n return 1 / (1.5 + factor);\n };\n\n if (instance.swipeDirection === 'y') {\n if (swipeDirections.includes('top') || swipeDirections.includes('bottom')) {\n if ((swipeDirections.includes('top') && yDelta < 0) || (swipeDirections.includes('bottom') && yDelta > 0)) {\n swipeAmount.y = yDelta;\n } else {\n const dampenedDelta = yDelta * getDampening(yDelta);\n swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;\n }\n }\n } else if (instance.swipeDirection === 'x') {\n if (swipeDirections.includes('left') || swipeDirections.includes('right')) {\n if ((swipeDirections.includes('left') && xDelta < 0) || (swipeDirections.includes('right') && xDelta > 0)) {\n swipeAmount.x = xDelta;\n } else {\n const dampenedDelta = xDelta * getDampening(xDelta);\n swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;\n }\n }\n }\n\n if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) {\n instance.isSwiped = true;\n li.dataset.swiped = 'true';\n }\n\n li.style.setProperty('--swipe-amount-x', `${swipeAmount.x}px`);\n li.style.setProperty('--swipe-amount-y', `${swipeAmount.y}px`);\n });\n\n li.addEventListener('pointerup', () => {\n if (!dismissible) return;\n\n const swipeAmountX = parseFloat(li.style.getPropertyValue('--swipe-amount-x') || '0');\n const swipeAmountY = parseFloat(li.style.getPropertyValue('--swipe-amount-y') || '0');\n const timeTaken = instance.dragStartTime ? new Date().getTime() - instance.dragStartTime.getTime() : 1000;\n\n const swipeAmount = instance.swipeDirection === 'x' ? swipeAmountX : swipeAmountY;\n const velocity = Math.abs(swipeAmount) / timeTaken;\n\n if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {\n toast.onDismiss?.(toast);\n\n if (instance.swipeDirection === 'x') {\n li.dataset.swipeDirection = swipeAmountX > 0 ? 'right' : 'left';\n } else {\n li.dataset.swipeDirection = swipeAmountY > 0 ? 'down' : 'up';\n }\n\n li.dataset.swipeOut = 'true';\n this.removeToast(toast);\n } else {\n li.style.setProperty('--swipe-amount-x', '0px');\n li.style.setProperty('--swipe-amount-y', '0px');\n }\n\n instance.isSwiped = false;\n instance.swiping = false;\n instance.swipeDirection = null;\n instance.pointerStart = null;\n li.dataset.swiped = 'false';\n li.dataset.swiping = 'false';\n });\n }\n\n private updateToastElement(instance: ToastInstance, toast: ToastT): void {\n const { element: li } = instance;\n instance.toast = toast;\n\n // Update type\n li.dataset.type = toast.type || '';\n\n // Update title\n const titleEl = li.querySelector('[data-title]');\n if (titleEl) {\n titleEl.textContent = toast.title || '';\n }\n\n // Update description\n let descEl = li.querySelector('[data-description]');\n if (toast.description) {\n if (!descEl) {\n descEl = document.createElement('div');\n descEl.setAttribute('data-description', '');\n li.querySelector('[data-content]')?.appendChild(descEl);\n }\n descEl.textContent = toast.description;\n } else if (descEl) {\n descEl.remove();\n }\n\n // Update icon if type changed\n const iconEl = li.querySelector('[data-icon]');\n if (iconEl && toast.type && toast.type !== 'loading') {\n const asset = getAsset(toast.type);\n if (asset) {\n iconEl.innerHTML = asset;\n }\n }\n\n // Restart timer for non-loading types\n if (toast.type !== 'loading') {\n instance.remainingTime = toast.duration ?? this.options.duration;\n this.startTimer(instance);\n }\n }\n\n private startTimer(instance: ToastInstance): void {\n const { toast } = instance;\n if (toast.promise && toast.type === 'loading') return;\n if (toast.duration === Infinity || toast.type === 'loading') return;\n if (this.expanded || this.interacting || this.isDocumentHidden) return;\n\n clearTimeout(instance.closeTimeout);\n instance.closeTimerStart = Date.now();\n\n instance.closeTimeout = setTimeout(() => {\n toast.onAutoClose?.(toast);\n this.removeToast(toast);\n }, instance.remainingTime);\n }\n\n private pauseTimer(instance: ToastInstance): void {\n if (instance.closeTimerStart > 0) {\n const elapsed = Date.now() - instance.closeTimerStart;\n instance.remainingTime = Math.max(0, instance.remainingTime - elapsed);\n }\n clearTimeout(instance.closeTimeout);\n }\n\n private dismissToast(id: number | string): void {\n const instance = this.toastInstances.get(id);\n if (instance) {\n instance.element.dataset.removed = 'true';\n this.removeToast(instance.toast);\n }\n }\n\n private removeToast(toast: ToastT): void {\n const instance = this.toastInstances.get(toast.id);\n if (!instance || instance.removed) return;\n\n instance.removed = true;\n instance.element.dataset.removed = 'true';\n clearTimeout(instance.closeTimeout);\n\n // Remove from heights\n this.heights = this.heights.filter((h) => h.toastId !== toast.id);\n\n setTimeout(() => {\n instance.element.remove();\n this.toastInstances.delete(toast.id);\n ToastState.dismiss(toast.id);\n this.updatePositions();\n }, TIME_BEFORE_UNMOUNT);\n\n this.updatePositions();\n }\n\n private updatePositions(): void {\n const { visibleToasts, gap, expand } = this.options;\n\n // Use heights array order (newest first) to determine positioning\n const orderedToasts = this.heights\n .map((h) => this.toastInstances.get(h.toastId))\n .filter((instance): instance is ToastInstance => instance !== undefined && !instance.removed);\n\n const newFrontHeight = orderedToasts.length > 0 ? orderedToasts[0].height : 0;\n const isExpanded = this.expanded || expand;\n\n // FIRST PASS: Lock current heights to enable transitions\n // This captures the current rendered height before we change anything\n // We do NOT change data-front here to avoid triggering opacity changes\n orderedToasts.forEach((instance, index) => {\n const { element: li } = instance;\n const isFront = index === 0;\n\n if (!isFront && !isExpanded) {\n // Get current computed height and set it explicitly\n // This gives the transition a \"from\" value\n const currentHeight = li.getBoundingClientRect().height;\n if (currentHeight > 0) {\n li.style.height = `${currentHeight}px`;\n }\n }\n });\n\n // Force a reflow so the browser registers the current heights\n // before we change them to new values\n if (orderedToasts.length > 1) {\n void this.listEl?.offsetHeight;\n }\n\n // SECOND PASS: Update heights and positions (but not data-front yet)\n let heightBefore = 0;\n\n orderedToasts.forEach((instance, index) => {\n const { element: li } = instance;\n const isFront = index === 0;\n const isVisible = index < visibleToasts;\n\n li.dataset.index = String(index);\n li.dataset.visible = String(isVisible);\n\n const offset = index * gap + heightBefore;\n instance.offset = offset;\n\n li.style.setProperty('--index', String(index));\n li.style.setProperty('--toasts-before', String(index));\n li.style.setProperty('--z-index', String(orderedToasts.length - index));\n li.style.setProperty('--offset', `${offset}px`);\n li.style.setProperty('--initial-height', `${instance.height}px`);\n\n // Set explicit height to enable smooth CSS transitions\n if (isExpanded) {\n li.style.height = `${instance.height}px`;\n } else if (isFront) {\n li.style.height = '';\n } else {\n li.style.height = `${newFrontHeight}px`;\n }\n\n heightBefore += instance.height;\n });\n\n // Update front toast height on the container\n if (this.listEl && orderedToasts.length > 0) {\n this.listEl.style.setProperty('--front-toast-height', `${newFrontHeight}px`);\n }\n\n // THIRD PASS: Update data-front\n orderedToasts.forEach((instance, index) => {\n instance.element.dataset.front = String(index === 0);\n });\n }\n}\n\n// Factory function for easier usage\nexport function createToaster(options?: ToasterOptions): Toaster {\n return new Toaster(options);\n}\n"],
|
|
5
|
+
"mappings": "AAeA,IAAIA,EAAgB,EAIdC,EAAN,KAAe,CAAf,cACE,iBAA4B,CAAC,EAC7B,YAAmB,CAAC,EACpB,qBAAwC,IAAI,IAE5C,UAAUC,EAAoC,CAC5C,YAAK,YAAY,K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CAAK,CAAC,EAC7C4B,EAAG,MAAM,YAAY,kBAAmB,OAAO5B,CAAK,CAAC,EACrD4B,EAAG,MAAM,YAAY,YAAa,OAAOqC,EAAc,OAASjE,CAAK,CAAC,EACtE4B,EAAG,MAAM,YAAY,WAAY,GAAG7B,CAAM,IAAI,EAC9C6B,EAAG,MAAM,YAAY,mBAAoB,GAAGjB,EAAS,MAAM,IAAI,EAG3DwD,EACFvC,EAAG,MAAM,OAAS,GAAGjB,EAAS,MAAM,KAC3B2D,EACT1C,EAAG,MAAM,OAAS,GAElBA,EAAG,MAAM,OAAS,GAAGsC,CAAc,KAGrCG,GAAgB1D,EAAS,MAC3B,CAAC,EAGG,KAAK,QAAUsD,EAAc,OAAS,GACxC,KAAK,OAAO,MAAM,YAAY,uBAAwB,GAAGC,CAAc,IAAI,EAI7ED,EAAc,QAAQ,CAACtD,EAAUX,IAAU,CACzCW,EAAS,QAAQ,QAAQ,MAAQ,OAAOX,IAAU,CAAC,CACrD,CAAC,CACH,CACF,EAGO,SAASwE,EAAchE,EAAmC,CAC/D,OAAO,IAAID,EAAQC,CAAO,CAC5B",
|
|
6
|
+
"names": ["toastsCounter", "Observer", "subscriber", "index", "data", "message", "rest", "id", "alreadyExists", "toast", "dismissible", "type", "promise", "p", "shouldDismiss", "result", "originalPromise", "response", "isHttpResponse", "promiseData", "description", "error", "unwrap", "resolve", "reject", "content", "ToastState", "toastFunction", "getHistory", "getToasts", "getAsset", "type", "SuccessIcon", "InfoIcon", "WarningIcon", "ErrorIcon", "createLoader", "visible", "className", "wrapper", "spinner", "i", "bar", "CloseIcon", "isAction", "action", "VISIBLE_TOASTS_AMOUNT", "VIEWPORT_OFFSET", "MOBILE_VIEWPORT_OFFSET", "TOAST_LIFETIME", "TOAST_WIDTH", "GAP", "SWIPE_THRESHOLD", "TIME_BEFORE_UNMOUNT", "cn", "classes", "getDefaultSwipeDirections", "position", "y", "x", "directions", "getDocumentDirection", "dirAttribute", "assignOffset", "defaultOffset", "mobileOffset", "styles", "offset", "index", "isMobile", "prefix", "defaultValue", "assignAll", "key", "k", "Toaster", "options", "event", "hotkey", "instance", "target", "targetEl", "darkQuery", "e", "hotkeyLabel", "offsetStyles", "value", "expanded", "ToastState", "toast", "toastData", "existing", "duration", "dismissible", "closeButton", "toastType", "li", "height", "customElement", "wrapper", "closeBtn", "CloseIcon", "iconWrapper", "loader", "createLoader", "asset", "getAsset", "content", "title", "desc", "isAction", "cancelBtn", "actionBtn", "swipeDirections", "yDelta", "xDelta", "swipeAmount", "getDampening", "delta", "dampenedDelta", "swipeAmountX", "swipeAmountY", "timeTaken", "velocity", "titleEl", "descEl", "iconEl", "elapsed", "id", "h", "visibleToasts", "gap", "expand", "orderedToasts", "newFrontHeight", "isExpanded", "currentHeight", "heightBefore", "isFront", "isVisible", "createToaster"]
|
|
7
|
+
}
|