@editora/toast 2.0.8 โ†’ 2.0.10

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 CHANGED
@@ -1,935 +1,351 @@
1
- # Editora Toast
2
-
3
- > [!IMPORTANT]
4
- > **Live Website:** https://editora-ecosystem.netlify.app/
5
- > **Storybook:** https://editora-ecosystem-storybook.netlify.app/
6
-
7
-
8
- > Advanced toast notification system with enterprise features, backward compatibility, and rich customization options.
9
-
10
- [![Version](https://img.shields.io/npm/v/@editora/toast)](https://www.npmjs.com/package/@editora/toast)
11
- [![License](https://img.shields.io/npm/l/@editora/toast)](https://github.com/ajaykr089/Editora/blob/main/LICENSE)
12
- [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
13
- [![Size](https://img.shields.io/bundlephobia/minzip/@editora/toast)](https://bundlephobia.com/package/@editora/toast)
14
-
15
- A modern, framework-agnostic toast notification library designed for enterprise applications. Features advanced UX patterns, accessibility compliance, plugin architecture, and seamless integration with rich text editors.
16
-
17
- ## ๐Ÿ“ธ Screenshots
18
-
19
- ### Animated Toast Demo
20
- ![Animated Toast Demo](toast-screenshots/toast-demo.gif)
21
-
22
- ### Hero Section
23
- ![Hero Section](toast-screenshots/hero-section.png)
24
-
25
- ### Basic Toast Types
26
- ![Basic Toast Types](toast-screenshots/basic-toast-types.png)
27
-
28
- ### Beautiful Themes
29
- ![Beautiful Themes](toast-screenshots/beautiful-themes.png)
30
-
31
- ### Interactive Actions
32
- ![Interactive Actions](toast-screenshots/interactive-actions.png)
33
-
34
- ### Interactive Feedback Form
35
- ![Interactive Feedback Form](toast-screenshots/interactive-feedback-form.png)
36
-
37
- ### Progress Scenarios
38
- ![Progress Scenarios](toast-screenshots/progress-scenarios.png)
39
-
40
- ### Advanced Features
41
- ![Advanced Features](toast-screenshots/advanced-features.png)
42
-
43
- ### Async Operations
44
- ![Async Operations](toast-screenshots/async-operations.png)
45
-
46
- ### Error Handling
47
- ![Error Handling](toast-screenshots/error-handling.png)
48
-
49
- ## โœจ Features
50
-
51
- ### Core Features
52
- - ๐Ÿš€ **Framework Agnostic** - Works with any JavaScript framework or vanilla JS
53
- - โ™ฟ **Accessibility First** - WCAG AA compliant with screen reader support
54
- - ๐Ÿ”„ **Promise Lifecycle** - Automatic state transitions for async operations
55
- - ๐Ÿ“ฑ **Mobile Optimized** - Touch gestures, swipe-to-dismiss, and responsive design
56
- - ๐ŸŽจ **Advanced Theming** - 13 built-in themes with CSS variables and custom themes
57
- - ๐Ÿ”Œ **Plugin Architecture** - Extensible with custom plugins and hooks
58
- - ๐Ÿ“Š **Smart Queue Management** - Priority-based queuing with overflow strategies
59
- - ๐ŸŽฏ **Rich Content Support** - HTML, icons, actions, progress bars, and custom rendering
60
- - ๐ŸŽช **Spring Physics Animations** - Realistic animations with customizable physics parameters
61
- - ๐Ÿ—๏ธ **SSR Safe** - Server-side rendering compatible
62
- - ๐Ÿช **Editor Integration** - Built-in hooks for rich text editors
63
- - ๐Ÿ”’ **Security** - HTML sanitization and XSS protection
64
- - ๐Ÿ“ฆ **Zero Dependencies** - Lightweight and self-contained
65
-
66
- ### Advanced Features (v2.0.0)
67
- - ๐Ÿ”„ **Toast Updates** - Modify existing toasts dynamically with smooth transitions
68
- - ๐ŸŽฏ **Toast Grouping** - Group related notifications with stacking and management
69
- - ๐Ÿงฑ **Stacked Layouts** - Sonner-style collapsed stacks with hover/focus expansion
70
- - ๐Ÿ“ **Title + Description API** - Modern content hierarchy for concise messages
71
- - ๐ŸŽช **Custom Animation Hooks** - User-defined animation functions for complete control
72
- - ๐Ÿ“ **Multiple Positions** - Support for all screen corners and center positioning
73
- - ๐ŸŽจ **Animation Manager** - Centralized system supporting CSS, spring, and custom animations
74
- - ๐Ÿ“ฑ **Gesture Support** - Swipe and drag gestures for mobile interaction
75
- - ๐ŸŽฏ **Focus Management** - Proper keyboard navigation and focus handling
76
- - ๐Ÿ”„ **Promise Integration** - Seamless integration with async operations and promises
77
- - ๐Ÿ“Š **Progress Tracking** - Built-in progress bars with percentage display
78
- - ๐ŸŽฏ **Action Buttons** - Interactive buttons within toasts for user actions
79
- - โ†ฉ๏ธ **Action/Cancel Shortcuts** - First-class `action` and `cancel` options for undo flows
80
- - ๐ŸŽจ **Theme Variants** - Light, dark, system, colored, minimal, glass, neon, retro, ocean, forest, sunset, midnight themes
81
- - ๐Ÿ”ง **Global Configuration** - Comprehensive configuration system for all aspects
82
- - ๐Ÿงฉ **Headless State** - `subscribe()` and `getState()` for custom renderers and framework adapters
83
-
84
- ### Performance & Architecture
85
-
86
- - โšก **Optimized Queue Management** - O(1) insertion with priority-based queuing
87
- - ๐ŸŽฏ **Batched DOM Updates** - Efficient rendering with minimal reflows
88
- - ๐Ÿง  **Memory Safe** - Automatic cleanup and leak prevention
89
- - ๐Ÿš€ **Virtualized Rendering** - Handles large queues without performance degradation
90
- - ๐Ÿ”„ **Event-Driven Architecture** - Plugin system with comprehensive hooks
91
- - ๐Ÿ“ฆ **Tree-Shakable** - Import only what you need for smaller bundles
92
-
93
- ## ๐Ÿ“ฆ Installation
1
+ <h1 align="center">@editora/toast</h1>
2
+
3
+ <p align="center">
4
+ Toast notifications with no dependencies and nothing to mount: call <code>toast.success('Saved')</code> from
5
+ anywhere. Promise toasts, actions, progress, thirteen themes, seven positions and screen-reader announcements.
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/@editora/toast"><img src="https://img.shields.io/npm/v/@editora/toast.svg" alt="npm version"></a>
10
+ <a href="https://www.npmjs.com/package/@editora/toast"><img src="https://img.shields.io/npm/dm/@editora/toast.svg" alt="npm downloads"></a>
11
+ <a href="https://github.com/ajaykr089/Editora/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@editora/toast.svg" alt="license"></a>
12
+ <a href="https://www.npmjs.com/package/@editora/toast"><img src="https://img.shields.io/npm/types/@editora/toast.svg" alt="TypeScript types included"></a>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://editora-ecosystem.netlify.app/toast-demo.html">Live demo</a> ยท
17
+ <a href="https://editora-ecosystem-storybook.netlify.app/">Storybook</a> ยท
18
+ <a href="https://github.com/ajaykr089/Editora">GitHub</a>
19
+ </p>
20
+
21
+ <p align="center">
22
+ <img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/editora-toast/docs/images/themes.png" alt="Ten toasts stacked in the top-right corner, one in each of the light, colored, minimal, glass, neon, retro, ocean, forest, sunset and midnight themes" width="440">
23
+ </p>
24
+
25
+ ## Features
26
+
27
+ - **Nothing to mount.** No provider, no container element: the first call creates what it needs. It works from React,
28
+ Vue, plain JavaScript, a service, or an event handler.
29
+ - **Promise toasts.** One toast follows a promise from *loading* to *success* or *error*.
30
+ - **Actions and progress**: buttons in the toast, and a progress bar with an optional percentage.
31
+ - **Thirteen themes and seven positions**, a queue (three toasts show at once by default), duplicate prevention and
32
+ swipe-to-dismiss.
33
+ - **Accessible.** Errors are announced as alerts, the rest politely, and a close button is labelled.
34
+ - **Small.** 9 KB gzipped, plus 6 KB of CSS. No dependencies.
35
+ - **Safe on the server.** The package imports in Node and the calls do nothing there, so a call in shared code does not
36
+ break server rendering.
37
+ - Written in TypeScript. A script tag works too (a UMD build).
38
+
39
+ ## Install
94
40
 
95
41
  ```bash
96
42
  npm install @editora/toast
97
43
  ```
98
44
 
99
- ## ๐ŸŒ CDN Usage
45
+ ## Quick start
100
46
 
101
- You can also use Editora Toast directly from a CDN without installing it via npm. Include the following scripts in your HTML:
102
- ### Examples
103
- ``` https://editora-ecosystem.netlify.app/toast-demo.html ```
104
- ### Basic CDN Setup
47
+ ```ts
48
+ import { toast } from '@editora/toast';
49
+ import '@editora/toast/toast.css';
105
50
 
106
- ```html
107
- <!DOCTYPE html>
108
- <html lang="en">
109
- <head>
110
- <meta charset="UTF-8">
111
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
112
- <title>My App</title>
113
-
114
- <!-- Include the CSS -->
115
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@editora/toast@latest/dist/toast.css">
116
- </head>
117
- <body>
118
- <!-- Your content here -->
119
-
120
- <!-- Include the JavaScript -->
121
- <script src="https://cdn.jsdelivr.net/npm/@editora/toast@latest/dist/index.umd.js"></script>
122
-
123
- <script>
124
- // Now you can use the toast functions (legacy API supports an optional options object)
125
- toast.success('Hello from CDN!', { theme: 'light', position: 'top-right' });
126
- toast.error('Something went wrong!', { duration: 1000 });
127
- toast.info('This is an info message', { theme: 'light', position: 'top-right' });
128
- toast.warning('This is a warning', { theme: 'light', position: 'top-right' });
129
-
130
- // Advanced usage (toastAdvanced, toastPro)
131
- // global window.toastPro.show()
132
- // global window.toastAdvanced.show()
133
- const notification = toastAdvanced.show({
134
- message: 'File uploaded successfully!',
135
- level: 'success',
136
- icon: 'โœ“',
137
- actions: [
138
- { label: 'View', onClick: () => console.log('View clicked') },
139
- { label: 'Dismiss', onClick: () => notification.dismiss() }
140
- ]
141
- });
142
- const notification = toastPro.show({
143
- message: 'File uploaded successfully!',
144
- level: 'success',
145
- icon: 'โœ“',
146
- actions: [
147
- { label: 'View', onClick: () => console.log('View clicked') },
148
- { label: 'Dismiss', onClick: () => notification.dismiss() }
149
- ]
150
- });
151
- </script>
152
- </body>
153
- </html>
51
+ toast.success('Document saved');
52
+ toast.info('A new version is available');
53
+ toast.warning('Storage is almost full');
54
+ toast.error('Upload failed');
154
55
  ```
155
56
 
156
- ### CDN URLs
157
-
158
- - **JavaScript**: `https://cdn.jsdelivr.net/npm/@editora/toast@latest/dist/index.umd.js`
159
- - **CSS**: `https://cdn.jsdelivr.net/npm/@editora/toast@latest/dist/toast.css`
57
+ <p align="center">
58
+ <img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/editora-toast/docs/images/levels.png" alt="Three toasts in the bottom-right corner: Document saved in green, A new version is available in blue and Storage is almost full in orange" width="440">
59
+ </p>
160
60
 
161
- > **Note**: Replace `@latest` with a specific version number (e.g., `@2.0.0`) for production use to avoid unexpected updates.
61
+ Toasts appear in the bottom-right corner and go away after four seconds. Three are visible at once; the rest wait in a
62
+ queue (a fourth toast, *Upload failed* above, appears when there is room).
162
63
 
163
- ## ๐Ÿš€ Quick Start
64
+ `toast` is the simple API: `toast.info`, `toast.success`, `toast.warning`, `toast.error` and `toast.loading`, each taking
65
+ a message and, if you like, an options object or a duration in milliseconds. For everything else there is
66
+ `toastAdvanced` (also exported as `toastPro`).
164
67
 
165
- ### Basic Usage (Backward Compatible)
68
+ ## Titles, actions and progress
166
69
 
167
- ```typescript
168
- import { toast } from '@editora/toast';
169
- import "@editora/toast/toast.css";
170
-
171
- // Simple notifications (migrated to optional advanced options)
172
- toast.success('File saved successfully!', { theme: 'light', position: 'top-right' });
173
- toast.error('Failed to save file', { theme: 'light', position: 'top-right' });
174
- toast.info('Info message', { theme: 'light', position: 'top-right' });
175
- toast.warning('Warning message', { theme: 'light', position: 'top-right' });
176
- ```
177
-
178
- ### Advanced Usage (v2.0.0 Features)
179
-
180
- ```typescript
70
+ ```ts
181
71
  import { toastAdvanced as toast } from '@editora/toast';
182
- import "@editora/toast/toast.css";
183
- // Rich notifications with actions and progress
184
- const notification = toast.show({
185
- message: 'Document uploaded successfully!',
72
+ import '@editora/toast/toast.css';
73
+
74
+ // A toast with a title, a description, actions and progress. duration: 0 keeps it until it is dismissed.
75
+ const report = toast.show({
186
76
  level: 'success',
187
- icon: 'โœ“',
77
+ title: 'Report ready',
78
+ description: 'Q3-summary.pdf is 2.4 MB',
188
79
  actions: [
189
- { label: 'View Document', onClick: () => console.log('View clicked') },
190
- { label: 'Share', onClick: () => console.log('Share clicked') },
191
- { label: 'Dismiss', onClick: () => notification.dismiss() }
80
+ { label: 'Open', primary: true, onClick: () => console.log('open') },
81
+ { label: 'Dismiss', onClick: () => report.dismiss() }
192
82
  ],
193
- progress: { value: 100, showPercentage: true },
194
- duration: 6000
83
+ duration: 0
195
84
  });
196
85
 
197
- // Promise-based notifications with automatic state transitions
198
- toast.promise(
199
- uploadFile(file),
200
- {
201
- loading: 'Uploading file...',
202
- success: (data) => `File "${data.name}" uploaded successfully!`,
203
- error: (error) => `Upload failed: ${error.message}`
204
- }
205
- );
206
-
207
- // Update existing toast dynamically
208
- const loadingToast = toast.loading('Saving document...');
209
- setTimeout(() => {
210
- toast.update(loadingToast.id, {
211
- message: 'Document saved successfully!',
212
- level: 'success',
213
- icon: '๐Ÿ’พ',
214
- actions: [{ label: 'Open', onClick: () => {} }]
215
- });
216
- }, 2000);
217
-
218
- // Group related notifications
219
- toast.group('file-operations', {
220
- message: 'File 1 processed',
221
- level: 'success'
222
- });
223
-
224
- toast.group('file-operations', {
225
- message: 'File 2 processed',
226
- level: 'success'
227
- });
228
- ```
229
-
230
- ## ๐ŸŽ›๏ธ Configuration
231
-
232
- ```typescript
233
- import { toastAdvanced as toast } from '@editora/toast';
234
- import "@editora/toast/toast.css";
235
- // Global configuration with all available options
236
- toast.configure({
237
- // Positioning
238
- position: 'top-right', // 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center'
239
- offset: 16,
240
- mobileOffset: 16,
241
-
242
- // Timing
243
- duration: 5000, // Default duration in milliseconds
244
- pauseOnHover: true, // Pause timer when hovering
245
- pauseOnWindowBlur: true, // Pause timers when the tab/window is inactive
246
-
247
- // Display
248
- maxVisible: 3, // Maximum visible toasts
249
- visibleToasts: 3, // Sonner-compatible alias
250
- stack: false, // Set true to collapse visible toasts into a stack
251
- expand: true, // Keep stacked toasts expanded by default
252
- richColors: false, // Use semantic colored surfaces
253
- closeButton: true, // Show close buttons globally
254
- theme: 'system', // Theme: 'light' | 'dark' | 'system' | 'colored' | 'minimal' | 'glass' | 'neon' | 'retro' | 'ocean' | 'forest' | 'sunset' | 'midnight' | 'custom'
255
-
256
- // Accessibility
257
- enableAccessibility: true, // Enable screen reader support
258
-
259
- // Interactions
260
- swipeDismiss: true, // Enable swipe to dismiss on mobile
261
- dragDismiss: false, // Enable drag to dismiss
262
-
263
- // Queue Management
264
- queueStrategy: 'fifo', // 'fifo' | 'lifo'
265
- preventDuplicate: true,
266
- dedupeScope: 'all', // 'visible' | 'queue' | 'all'
267
-
268
- // Animations
269
- animation: {
270
- type: 'spring', // 'css' | 'spring' | 'custom'
271
- config: {
272
- stiffness: 120,
273
- damping: 12,
274
- mass: 1,
275
- precision: 0.01
276
- }
277
- },
278
-
279
- // Advanced
280
- zIndex: 9999 // Base z-index for toasts
86
+ const upload = toast.show({
87
+ level: 'info',
88
+ message: 'Uploading photos',
89
+ progress: { value: 64, showPercentage: true },
90
+ duration: 0
281
91
  });
282
92
  ```
283
93
 
284
- ## ๐ŸŽจ Theming
285
-
286
- ![Beautiful Themes](toast-screenshots/beautiful-themes.png)
287
-
288
- ### Built-in Themes
94
+ <p align="center">
95
+ <img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/editora-toast/docs/images/actions.png" alt="A toast titled Report ready with a description and Open and Dismiss buttons, under a toast that says Uploading photos" width="440">
96
+ </p>
289
97
 
290
- Editora Toast comes with 13 beautiful themes:
98
+ `show()` returns the toast: `dismiss()` removes it and `update(options)` changes it. Pressing an action runs its `onClick`
99
+ and closes the toast; give the action `dismissOnClick: false` to keep the toast open.
291
100
 
292
- - **`light`** - Clean white background with subtle shadows
293
- - **`dark`** - Dark background with high contrast text
294
- - **`system`** - Automatically switches between light/dark based on system preference
295
- - **`colored`** - Vibrant gradient backgrounds for each toast level
296
- - **`minimal`** - Clean design with subtle borders and minimal styling
297
- - **`glass`** - Frosted glass effect with backdrop blur
298
- - **`neon`** - Bright neon colors with glowing effects
299
- - **`retro`** - 80s/90s style with bold colors and gradients
300
- - **`ocean`** - Blue aquatic theme with calming colors
301
- - **`forest`** - Green natural theme with earthy tones
302
- - **`sunset`** - Warm orange/pink sunset colors
303
- - **`midnight`** - Deep blue dark theme with subtle gradients
304
- - **`custom`** - Fully customizable with CSS variables
101
+ ## Promises and updates
305
102
 
306
- ### Usage
103
+ `toast.promise()` shows one toast that becomes the result of a promise, and `update()` changes any toast by id:
307
104
 
308
- ```typescript
105
+ ```ts
309
106
  import { toastAdvanced as toast } from '@editora/toast';
310
- import "@editora/toast/toast.css";
311
- // Set global theme
312
- toast.configure({
313
- theme: 'glass' // or 'neon', 'retro', 'ocean', etc.
314
- });
107
+ import '@editora/toast/toast.css';
315
108
 
316
- // Per-toast theme
317
- toast.show({
318
- message: 'Hello World',
319
- theme: 'colored'
109
+ const saveDocument = new Promise<{ name: string }>((resolve) => {
110
+ setTimeout(() => resolve({ name: 'Q3-summary.pdf' }), 1500);
320
111
  });
321
- ```
322
-
323
- ### CSS Variables
324
-
325
- ```css
326
- :root {
327
- --editora-toast-bg: rgba(0, 0, 0, 0.85);
328
- --editora-toast-color: #fff;
329
- --editora-toast-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
330
- --editora-toast-border-radius: 6px;
331
- --editora-toast-font-family: system-ui, -apple-system, 'Segoe UI', Roboto;
332
- --editora-toast-font-size: 13px;
333
- --editora-toast-padding: 10px 14px;
334
- }
335
- ```
336
112
 
337
- ### Theme Classes
338
-
339
- ```html
340
- <!-- Apply theme globally -->
341
- <div data-theme="glass">
342
- <!-- All toasts will use glass theme -->
343
- </div>
344
-
345
- <!-- Or apply to specific container -->
346
- <div class="editora-toast-container" data-theme="neon">
347
- </div>
348
- ```
349
-
350
- ## ๐ŸŽฏ Advanced Features
351
-
352
- ### Promise Lifecycle Toasts
353
- ![Async Operations](toast-screenshots/async-operations.png)
354
-
355
- Automatically handle async operations with state transitions:
356
-
357
- ```typescript
358
- import { toastAdvanced as toast } from '@editora/toast';
359
-
360
- // Promise-based notifications
361
- const uploadPromise = uploadFile(file);
362
-
363
- toast.promise(uploadPromise, {
364
- loading: {
365
- message: 'Uploading file...',
366
- icon: 'โณ',
367
- progress: { indeterminate: true }
368
- },
369
- success: {
370
- message: 'File uploaded successfully!',
371
- icon: 'โœ…',
372
- duration: 4000,
373
- actions: [{ label: 'View', onClick: () => openFile() }]
374
- },
375
- error: {
376
- message: 'Upload failed. Please try again.',
377
- icon: 'โŒ',
378
- duration: 6000,
379
- actions: [
380
- { label: 'Retry', onClick: () => retryUpload() },
381
- { label: 'Cancel', onClick: () => {} }
382
- ]
383
- }
113
+ // One toast that moves from loading to success or error by itself.
114
+ toast.promise(saveDocument, {
115
+ loading: 'Saving document...',
116
+ success: (file) => `Saved ${file.name}`,
117
+ error: (error) => `Could not save: ${error.message}`
384
118
  });
385
- ```
386
-
387
- ### Interactive Actions
388
- ![Interactive Actions](toast-screenshots/interactive-actions.png)
389
119
 
390
- Add interactive buttons to your toasts:
391
-
392
- ```typescript
393
- import { toastAdvanced as toast } from '@editora/toast';
394
- import "@editora/toast/toast.css";
395
- const notification = toast.show({
396
- message: 'Document saved successfully!',
397
- level: 'success',
398
- icon: '๐Ÿ’พ',
399
- actions: [
400
- {
401
- label: 'Open Document',
402
- onClick: () => openDocument(),
403
- primary: true // Primary action styling
404
- },
405
- {
406
- label: 'Share',
407
- onClick: () => shareDocument(),
408
- variant: 'secondary'
409
- },
410
- {
411
- label: 'Dismiss',
412
- onClick: () => notification.dismiss(),
413
- variant: 'ghost'
414
- }
415
- ],
416
- duration: 8000 // Longer duration for actions
417
- });
418
- ```
419
-
420
- ### Progress Tracking
421
- ![Progress Scenarios](toast-screenshots/progress-scenarios.png)
422
-
423
- Built-in progress bars with customizable display:
424
-
425
- ```typescript
426
- import { toastAdvanced as toast } from '@editora/toast';
427
- import "@editora/toast/toast.css";
428
- // Determinate progress
429
- const progressToast = toast.show({
430
- message: 'Processing files...',
431
- level: 'info',
432
- progress: {
433
- value: 0,
434
- showPercentage: true,
435
- color: '#007acc'
436
- }
437
- });
438
-
439
- // Update progress
440
- let progress = 0;
441
- const interval = setInterval(() => {
442
- progress += 10;
443
- toast.update(progressToast.id, {
444
- progress: { value: progress, showPercentage: true },
445
- message: `Processing files... ${progress}%`
446
- });
447
-
448
- if (progress >= 100) {
449
- clearInterval(interval);
450
- toast.update(progressToast.id, {
451
- message: 'Processing complete!',
452
- level: 'success',
453
- progress: { value: 100, showPercentage: true }
454
- });
455
- }
456
- }, 500);
120
+ // Or update a toast yourself.
121
+ const sync = toast.loading('Syncing...');
122
+ setTimeout(() => {
123
+ toast.update(sync.id, { message: 'Everything is up to date', level: 'success' });
124
+ }, 2500);
457
125
  ```
458
126
 
459
- ### Toast Updates
460
- ![Advanced Features](toast-screenshots/advanced-features.png)
461
-
462
- Modify existing toasts dynamically:
463
-
464
- ```typescript
465
- import { toastAdvanced as toast } from '@editora/toast';
466
- import "@editora/toast/toast.css";
467
- // Create a loading toast
468
- const loadingToast = toast.loading('Connecting to server...');
469
-
470
- // Update with progress
471
- setTimeout(() => {
472
- toast.update(loadingToast.id, {
473
- message: 'Authenticating...',
474
- progress: { value: 25, showPercentage: true }
475
- });
476
- }, 1000);
127
+ <table>
128
+ <tr>
129
+ <td><img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/editora-toast/docs/images/promise-loading.png" alt="Two toasts that read Saving document and Syncing"></td>
130
+ <td><img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/editora-toast/docs/images/promise-success.png" alt="The same toasts after the promise resolved and the update: Saved Q3-summary.pdf and Everything is up to date"></td>
131
+ </tr>
132
+ <tr>
133
+ <td align="center"><sub>While it works</sub></td>
134
+ <td align="center"><sub>After the promise resolves and the update</sub></td>
135
+ </tr>
136
+ </table>
477
137
 
478
- // Update with success
479
- setTimeout(() => {
480
- toast.update(loadingToast.id, {
481
- message: 'Connected successfully!',
482
- level: 'success',
483
- icon: '๐Ÿ”—',
484
- progress: { value: 100, showPercentage: true },
485
- actions: [{ label: 'Explore', onClick: () => {} }]
486
- });
487
- }, 2000);
488
- ```
138
+ `toast.promise()` returns the promise you gave it, so you can still `await` it. If you only need the message, `success`
139
+ and `error` can be plain strings.
489
140
 
490
- ### Toast Grouping
491
- ![Error Handling](toast-screenshots/error-handling.png)
141
+ ## In React, and in any framework
492
142
 
493
- Group related notifications together:
143
+ There is nothing to render. Call `toast` from a handler, an effect or a service:
494
144
 
495
- ```typescript
145
+ ```tsx
496
146
  import { toastAdvanced as toast } from '@editora/toast';
497
- import "@editora/toast/toast.css";
498
- // Group file operations
499
- const files = ['document.pdf', 'image.jpg', 'data.json'];
500
-
501
- files.forEach((file, index) => {
502
- setTimeout(() => {
503
- toast.group('file-upload', {
504
- message: `Uploaded ${file}`,
505
- level: 'success',
506
- icon: '๐Ÿ“',
507
- duration: 3000
508
- });
509
- }, index * 500);
510
- });
147
+ import '@editora/toast/toast.css';
511
148
 
512
- // Group error notifications
513
- toast.group('validation-errors', {
514
- message: 'Invalid email format',
515
- level: 'error',
516
- icon: 'โš ๏ธ'
517
- });
149
+ async function saveDraft() {
150
+ await new Promise((resolve) => setTimeout(resolve, 800));
151
+ return { name: 'draft.md' };
152
+ }
518
153
 
519
- toast.group('validation-errors', {
520
- message: 'Password too weak',
521
- level: 'error',
522
- icon: '๐Ÿ”’'
523
- });
154
+ // There is nothing to mount: call toast from any handler or effect.
155
+ export default function SaveButton() {
156
+ return (
157
+ <button
158
+ onClick={() =>
159
+ toast.promise(saveDraft(), {
160
+ loading: 'Saving...',
161
+ success: (file) => `Saved ${file.name}`,
162
+ error: 'Could not save'
163
+ })
164
+ }
165
+ >
166
+ Save
167
+ </button>
168
+ );
169
+ }
524
170
  ```
525
171
 
526
- ### Interactive Feedback Forms
527
- ![Interactive Feedback Form](toast-screenshots/interactive-feedback-form.png)
172
+ ## From a script tag
528
173
 
529
- Create interactive forms within toasts:
174
+ The UMD build defines three globals: `toast`, `toastAdvanced` and `toastPro` (the same object as `toastAdvanced`).
175
+ Pin a version in production, as here:
530
176
 
531
- ```typescript
532
- import { toastAdvanced as toast } from '@editora/toast';
533
- import "@editora/toast/toast.css";
534
- toast.show({
535
- message: 'How was your experience?',
536
- level: 'info',
537
- icon: 'โญ',
538
- render: () => {
539
- const container = document.createElement('div');
540
- container.innerHTML = `
541
- <div style="display: flex; gap: 8px; margin-top: 8px;">
542
- <button class="feedback-btn" data-rating="1">๐Ÿ˜ž</button>
543
- <button class="feedback-btn" data-rating="2">๐Ÿ˜</button>
544
- <button class="feedback-btn" data-rating="3">๐Ÿ˜Š</button>
545
- <button class="feedback-btn" data-rating="4">๐Ÿ˜ƒ</button>
546
- <button class="feedback-btn" data-rating="5">๐Ÿ˜</button>
547
- </div>
548
- `;
549
-
550
- container.addEventListener('click', (e) => {
551
- if (e.target.classList.contains('feedback-btn')) {
552
- const rating = e.target.dataset.rating;
553
- submitFeedback(rating);
554
- toast.success('Thank you for your feedback!');
555
- }
556
- });
177
+ ```html
178
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@editora/toast@2/dist/toast.css" />
179
+ <script src="https://cdn.jsdelivr.net/npm/@editora/toast@2/dist/index.umd.js"></script>
557
180
 
558
- return container;
559
- },
560
- duration: 10000
561
- });
562
- ```
181
+ <button id="save">Save</button>
563
182
 
564
- ## ๐Ÿ”Œ Plugins
183
+ <script>
184
+ document.getElementById('save').onclick = () => {
185
+ // The script defines three globals: toast, toastAdvanced and toastPro (the same object as toastAdvanced).
186
+ toast.success('Saved from a CDN');
565
187
 
566
- ```typescript
567
- import { toastAdvanced as toast } from '@editora/toast';
568
- import "@editora/toast/toast.css";
569
- const myPlugin = {
570
- name: 'my-plugin',
571
- install(manager) {
572
- // Add custom functionality
573
- manager.on('beforeShow', (toast) => {
574
- console.log('Toast about to show:', toast.message);
188
+ const notification = toastAdvanced.show({
189
+ message: 'File uploaded',
190
+ level: 'success',
191
+ actions: [
192
+ { label: 'View', onClick: () => console.log('view') },
193
+ { label: 'Dismiss', onClick: () => notification.dismiss() }
194
+ ],
195
+ duration: 0
575
196
  });
576
- }
577
- };
578
-
579
- toast.use(myPlugin);
197
+ };
198
+ </script>
580
199
  ```
581
200
 
582
- ## ๐Ÿ“ฑ Positions
201
+ ## Configure it
583
202
 
584
- ```typescript
585
- toast.show({
586
- message: 'Hello World',
587
- position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center'
588
- });
589
- ```
590
-
591
- ## ๐ŸŽช Advanced Features
203
+ `configure()` sets the defaults for every toast from then on. A single toast can still override them:
592
204
 
593
- ### Spring Physics Animations
594
-
595
- ```typescript
205
+ ```ts
596
206
  import { toastAdvanced as toast } from '@editora/toast';
597
- import "@editora/toast/toast.css";
598
- // Spring animation with custom physics
599
- toast.show({
600
- message: 'Spring animated toast!',
601
- level: 'success',
602
- animation: {
603
- type: 'spring',
604
- config: {
605
- stiffness: 120, // Spring stiffness (default: 100)
606
- damping: 12, // Spring damping (default: 10)
607
- mass: 1, // Spring mass (default: 1)
608
- precision: 0.01 // Animation precision (default: 0.01)
609
- }
610
- }
611
- });
612
- ```
613
-
614
- ### Custom Animation Hooks
207
+ import '@editora/toast/toast.css';
615
208
 
616
- ```typescript
617
- import { toastAdvanced as toast } from '@editora/toast';
618
- import "@editora/toast/toast.css";
619
- // Custom animation functions
620
- toast.show({
621
- message: 'Custom animated toast!',
622
- level: 'info',
623
- animation: {
624
- type: 'custom',
625
- show: async (element, toast) => {
626
- // Custom show animation
627
- element.style.opacity = '0';
628
- element.style.transform = 'rotateX(90deg)';
629
-
630
- await new Promise(resolve => {
631
- element.style.transition = 'all 0.5s ease';
632
- element.style.opacity = '1';
633
- element.style.transform = 'rotateX(0deg)';
634
- element.addEventListener('transitionend', resolve, { once: true });
635
- });
636
- },
637
- hide: async (element, toast) => {
638
- // Custom hide animation
639
- element.style.transition = 'all 0.3s ease';
640
- element.style.opacity = '0';
641
- element.style.transform = 'scale(0.8)';
642
-
643
- return new Promise(resolve => {
644
- setTimeout(resolve, 300);
645
- });
646
- },
647
- update: async (element, toast, updates) => {
648
- // Custom update animation
649
- element.style.transform = 'scale(1.05)';
650
- setTimeout(() => {
651
- element.style.transform = 'scale(1)';
652
- }, 150);
653
- }
654
- }
655
- });
656
- ```
657
-
658
- ### Global Animation Configuration
659
-
660
- ```typescript
661
- import { toastAdvanced as toast } from '@editora/toast';
662
- import "@editora/toast/toast.css";
663
- // Set default animation for all toasts
209
+ // Settings for every toast from now on. A toast can still override them.
664
210
  toast.configure({
665
- animation: {
666
- type: 'spring',
667
- config: { stiffness: 150, damping: 15 }
668
- }
211
+ position: 'top-center',
212
+ duration: 6000,
213
+ maxVisible: 3,
214
+ theme: 'ocean',
215
+ closeButton: true,
216
+ preventDuplicate: true
669
217
  });
670
- ```
671
-
672
- ### Toast Groups
673
218
 
674
- ```typescript
675
- // Group related notifications
676
- toast.group('upload-group', {
677
- message: 'Upload 1 complete',
678
- level: 'success'
679
- });
680
-
681
- toast.group('upload-group', {
682
- message: 'Upload 2 complete',
683
- level: 'success'
684
- });
219
+ toast.info('Welcome back');
220
+ toast.info('Welcome back'); // the duplicate is dropped
221
+ toast.warning('Your plan renews tomorrow', { theme: 'sunset', duration: 0 });
685
222
  ```
686
223
 
687
- ### Custom Render Function
688
-
689
- ```typescript
690
- toast.show({
691
- render: () => {
692
- const div = document.createElement('div');
693
- div.innerHTML = '<strong>Custom</strong> content';
694
- return div;
695
- }
696
- });
697
- ```
698
-
699
- ### Editor Integration
700
-
701
- ```typescript
224
+ | Setting | Default | |
225
+ | --- | --- | --- |
226
+ | `position` | `'bottom-right'` | Where toasts appear (see [Positions](#positions)). |
227
+ | `duration` | `4000` | How long a toast stays, in milliseconds. `0` keeps it until it is dismissed. |
228
+ | `maxVisible` | `3` | How many show at once; the others wait in the queue. (`visibleToasts` is an alias.) |
229
+ | `queueStrategy` | `'fifo'` | `'fifo'` or `'lifo'`: which waiting toast comes next. |
230
+ | `theme` | `'system'` | One of the [themes](#themes). |
231
+ | `closeButton` | `false` | Show a close button on every toast. |
232
+ | `preventDuplicate` | `false` | Drop a toast whose content is already showing. With `dedupeScope`: `'visible'`, `'queue'` or `'all'` (the default). |
233
+ | `pauseOnHover`, `pauseOnFocus`, `pauseOnWindowBlur` | `true`, `false`, `false` | Pause the timer while the pointer is over a toast, a toast has focus, or the window is in the background. |
234
+ | `swipeDismiss`, `swipeDirection`, `dragDismiss` | `true`, `'any'`, `false` | Dismiss by swiping, in which direction, and by dragging. |
235
+ | `stack`, `expand`, `gap` | `false`, `true`, `8` | How several visible toasts are laid out, and the gap between them. |
236
+ | `offset`, `mobileOffset`, `zIndex` | `16`, `16`, none | The distance from the edge of the screen, on desktop and on mobile, and the stacking order. |
237
+ | `rtl` | `false` | Right-to-left layout. |
238
+ | `richColors` | `false` | Richer colours for the levels. |
239
+ | `container` | the page body | The element toasts are added to. |
240
+
241
+ `toast.getConfig()` returns the current settings.
242
+
243
+ ## Themes
244
+
245
+ `light`, `dark`, `system`, `colored`, `minimal`, `glass`, `neon`, `retro`, `ocean`, `forest`, `sunset`, `midnight` and
246
+ `custom`. Set one for all toasts with `configure({ theme })`, or for one toast with `{ theme }`:
247
+
248
+ ```ts
702
249
  import { toastAdvanced as toast } from '@editora/toast';
703
- import "@editora/toast/toast.css";
704
- // Listen for editor events
705
- toast.onEditorEvent('spellcheck-error', (error) => {
706
- toast.error(`Spelling error: ${error.word}`, { theme: 'light', position: 'top-right' });
707
- });
708
-
709
- // Trigger editor events
710
- toast.triggerEditorEvent('media-upload-progress', { progress: 50 });
711
- ```
712
-
713
- ## ๐Ÿ“‹ API Reference
714
-
715
- ### Core Methods
716
-
717
- - `toast.show(options)` - Show a toast with full options
718
- - `toast.update(id, options)` - Update an existing toast dynamically
719
- - `toast.dismiss(id?)` - Dismiss a specific toast or all toasts
720
- - `toast.clear()` - Clear all visible toasts
721
-
722
- ### Convenience Methods
723
-
724
- - `toast.info(message, options?)` - Info level toast
725
- - `toast.success(message, options?)` - Success level toast
726
- - `toast.error(message, options?)` - Error level toast
727
- - `toast.warning(message, options?)` - Warning level toast
728
- - `toast.loading(message, options?)` - Loading state toast
729
-
730
- ### Advanced Methods (v2.0.0)
731
-
732
- - `toast.promise(promise, options)` - Promise lifecycle toasts with automatic state transitions
733
- - `toast.group(id, options)` - Group related toasts with stacking behavior
734
- - `toast.configure(config)` - Update global configuration
735
- - `toast.use(plugin)` - Install a plugin
736
- - `toast.getState()` - Read visible, queued, grouped, and configured toast state
737
- - `toast.subscribe(listener)` - Subscribe to state changes for headless/custom renderers
738
- - `toast.onEditorEvent(event, handler)` - Listen for editor integration events
739
- - `toast.triggerEditorEvent(event, data)` - Trigger editor integration events
740
-
741
- ### Toast Options Interface
742
-
743
- ```typescript
744
- interface ToastOptions {
745
- // Content
746
- message?: string;
747
- title?: string;
748
- description?: string;
749
- level?: 'info' | 'success' | 'error' | 'warning' | 'loading' | 'progress' | 'promise' | 'custom';
750
- icon?: string;
751
- html?: boolean;
752
- render?: (toast: ToastInstance) => HTMLElement;
753
-
754
- // Behavior
755
- duration?: number;
756
- pauseOnHover?: boolean;
757
- persistent?: boolean;
758
- closeButton?: boolean;
759
-
760
- // Positioning
761
- position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center';
762
-
763
- // Interactions
764
- actions?: ToastAction[];
765
- action?: ToastAction;
766
- cancel?: ToastAction;
767
- swipeDismiss?: boolean;
768
- dragDismiss?: boolean;
769
-
770
- // Progress
771
- progress?: ToastProgress;
772
-
773
- // Styling
774
- theme?: string;
775
- customClass?: string;
776
-
777
- // Advanced
778
- group?: string;
779
- priority?: number;
780
- important?: boolean;
781
- preventDuplicate?: boolean;
782
- dedupeKey?: string;
783
- dedupeScope?: 'visible' | 'queue' | 'all';
784
- ariaLive?: 'polite' | 'assertive' | 'off';
785
- animation?: ToastAnimation;
786
- onShow?: () => void;
787
- onHide?: () => void;
788
- onUpdate?: (updates: Partial<ToastOptions>) => void;
789
- }
250
+ import '@editora/toast/toast.css';
790
251
 
791
- interface ToastAction {
792
- label: string;
793
- onClick: () => void;
794
- primary?: boolean;
795
- dismissOnClick?: boolean;
796
- altText?: string;
797
- }
252
+ toast.configure({ position: 'top-right', maxVisible: 10, gap: 8 });
798
253
 
799
- interface ToastProgress {
800
- value: number; // 0-100
801
- showPercentage?: boolean;
802
- }
254
+ const themes = [
255
+ 'light', 'colored', 'minimal', 'glass', 'neon', 'retro', 'ocean', 'forest', 'sunset', 'midnight'
256
+ ] as const;
803
257
 
804
- interface ToastAnimation {
805
- type: 'css' | 'spring' | 'custom';
806
- config?: SpringConfig;
807
- show?: AnimationFunction;
808
- hide?: AnimationFunction;
809
- update?: AnimationFunction;
258
+ for (const theme of themes) {
259
+ toast.info(`The ${theme} theme`, { theme, duration: 0 });
810
260
  }
811
261
  ```
812
262
 
813
- ## ๐ŸŽฎ Live Demo & Examples
814
-
815
- Try out all the features with our comprehensive demo:
816
-
817
- ```bash
818
- # Clone the repository
819
- git clone https://github.com/ajaykr089/Editora.git
820
- cd Editora/packages/editora-toast
821
-
822
- # Install dependencies
823
- npm install
824
-
825
- # Start the standalone CodeSandbox-ready example
826
- cd ../../examples/editora-toast
827
- npm install
828
- npm run dev
829
- ```
830
-
831
- The demo showcases:
832
- - โœ… All 13 built-in themes
833
- - ๐ŸŽฏ Interactive actions and buttons
834
- - ๐Ÿ“Š Progress bars and indicators
835
- - ๐Ÿ”„ Promise lifecycle management
836
- - ๐ŸŽช Spring physics animations
837
- - ๐Ÿ“ฑ Mobile gestures and touch support
838
- - โ™ฟ Accessibility features
839
- - ๐ŸŽจ Custom rendering and HTML content
840
- - ๐Ÿ“ฑ Responsive design across devices
841
-
842
- ## ๐Ÿ”ง Build & Development
843
-
844
- ```bash
845
- # Install dependencies
846
- npm install
847
-
848
- # Build
849
- npm run build
850
-
851
- # Development watch
852
- npm run dev
853
-
854
- # Clean
855
- npm run clean
856
- ```
263
+ The picture at the top of this page is that code. `system` (the default) follows the operating system's light or
264
+ dark setting. Each toast carries `data-theme` and level classes (`editora-toast-info`, ...), so you can restyle the
265
+ themes with CSS.
857
266
 
858
- ## ๐ŸŒ Browser Support
267
+ ## Positions
859
268
 
860
- - Chrome 60+
861
- - Firefox 55+
862
- - Safari 12+
863
- - Edge 79+
269
+ `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, `bottom-right` and `center`:
864
270
 
865
- ## ๐Ÿ“„ License
866
-
867
- MIT ยฉ [Ajay Kumar](https://github.com/ajaykr089)
868
-
869
- ## ๐Ÿค Contributing
870
-
871
- Contributions welcome! Please see the [main repository](https://github.com/ajaykr089/Editora) for contribution guidelines.
872
-
873
- ## ๐Ÿ“š Migration Guide
874
-
875
- ### From v1.x to v2.0.0
876
-
877
- The v2.0.0 release introduces powerful new features while maintaining **full backward compatibility**. Your existing code will continue to work without changes.
878
-
879
- #### โœจ New Features in v2.0.0
880
-
881
- ```typescript
882
- // v1.x (still works)
883
- import { toast } from '@editora/toast';
884
- import "@editora/toast/toast.css";
885
- toast.success('Hello World', { theme: 'light', position: 'top-right' });
886
-
887
- // v2.0.0 advanced features
271
+ ```ts
888
272
  import { toastAdvanced as toast } from '@editora/toast';
889
- import "@editora/toast/toast.css";
890
- // Promise lifecycle toasts
891
- toast.promise(fetchData(), {
892
- loading: 'Loading...',
893
- success: 'Data loaded!',
894
- error: 'Failed to load'
895
- });
273
+ import '@editora/toast/toast.css';
896
274
 
897
- // Rich content with actions
898
- toast.show({
899
- message: 'File uploaded!',
900
- level: 'success',
901
- icon: 'โœ…',
902
- actions: [
903
- { label: 'View', onClick: () => {} },
904
- { label: 'Share', onClick: () => {} }
905
- ],
906
- progress: { value: 100, showPercentage: true }
907
- });
275
+ toast.configure({ maxVisible: 10 });
908
276
 
909
- // Dynamic toast updates
910
- const toast = toast.loading('Saving...');
911
- toast.update(toast.id, { message: 'Saved!', level: 'success' });
277
+ const positions = [
278
+ 'top-left', 'top-center', 'top-right',
279
+ 'bottom-left', 'bottom-center', 'bottom-right',
280
+ 'center'
281
+ ] as const;
912
282
 
913
- // Toast grouping
914
- toast.group('operations', { message: 'Task 1 complete', level: 'success' });
915
- toast.group('operations', { message: 'Task 2 complete', level: 'success' });
283
+ for (const position of positions) {
284
+ toast.success(position, { position, duration: 0 });
285
+ }
916
286
  ```
917
287
 
918
- #### Configuration Changes
288
+ <p align="center">
289
+ <img src="https://raw.githubusercontent.com/ajaykr089/Editora/main/packages/editora-toast/docs/images/positions.png" alt="Seven toasts on a page: one at each corner, one at the top centre, one at the bottom centre and one in the middle" width="900">
290
+ </p>
291
+
292
+ ## Toast options
293
+
294
+ Everything `show()` accepts. All of it is optional except a message (or a title):
295
+
296
+ | Option | |
297
+ | --- | --- |
298
+ | `message`, `title`, `description` | The text. |
299
+ | `level` | `'info'`, `'success'`, `'warning'`, `'error'` or `'loading'`. |
300
+ | `icon` | An icon, as a string. |
301
+ | `actions`, `action`, `cancel` | Buttons: `{ label, onClick, primary?, dismissOnClick? }`. |
302
+ | `progress` | `{ value, showPercentage? }`, with `value` from 0 to 100. |
303
+ | `duration`, `persistent` | How long it stays (`0`, or `persistent: true`, keeps it until dismissed). |
304
+ | `position`, `theme`, `customClass`, `rtl` | Where it appears and how it looks. |
305
+ | `closable` / `closeButton` | Show a close button. |
306
+ | `html` | Render `message` as HTML. Only inline formatting, lists and safe links are kept. |
307
+ | `render` | Build the toast yourself: `(toast) => HTMLElement`. |
308
+ | `priority`, `important` | Show higher priorities first; `important` also pushes lower-priority toasts out. |
309
+ | `preventDuplicate`, `dedupeKey`, `dedupeScope` | Drop duplicates, by content or by your own key. |
310
+ | `pauseOnHover`, `pauseOnFocus`, `swipeDismiss`, `swipeDirection`, `dragDismiss` | Behaviour; see the [settings](#configure-it). |
311
+ | `role`, `ariaLive` | Override the announcement (see [Accessibility](#accessibility)). |
312
+ | `group` | The id of a group the toast belongs to. |
313
+ | `animation` | Animation settings (a CSS animation by default; spring and other types are available). |
314
+ | `onShow`, `onHide`, `onUpdate` | Lifecycle callbacks. |
315
+
316
+ ## Accessibility
317
+
318
+ Toasts live in a region that is announced politely. An **error** toast is a `role="alert"` with `aria-live="assertive"`,
319
+ so a screen reader interrupts to read it; every other level is `role="status"` with `aria-live="polite"`. The close button
320
+ is labelled "Close notification". Override the announcement of one toast with `role` and `ariaLive`. Actions are buttons,
321
+ so a keyboard can reach them, and `pauseOnFocus` pauses the timer while a toast has focus.
322
+
323
+ ## API
324
+
325
+ `toastAdvanced` (`toastPro`):
326
+
327
+ | Method | |
328
+ | --- | --- |
329
+ | `show(options)` | Show a toast; returns `{ id, options, dismiss(), update(options) }`. |
330
+ | `info`, `success`, `warning`, `error`, `loading` `(message, options?)` | Shorthands for `show`. |
331
+ | `update(id, options)` / `dismiss(id)` / `clear()` | Change, remove or remove every toast. |
332
+ | `promise(promise, { loading, success, error })` | A toast that follows a promise; also `onSuccess` and `onError` callbacks. |
333
+ | `group(id, options)` | Show a toast that belongs to a group. |
334
+ | `configure(settings)` / `getConfig()` | Set and read the [settings](#configure-it). |
335
+ | `getToasts()` / `getGroups()` / `getState()` | The toasts, the groups, or both with the queue and the settings. |
336
+ | `subscribe(listener)` | Call `listener(state)` when the toasts change; returns an unsubscribe function. |
337
+ | `use(plugin)` | Install a plugin: `{ name, install(manager), uninstall? }`. |
338
+ | `onEditorEvent(event, callback)` / `triggerEditorEvent(event, toast, ...args)` | Connect toasts to your editor's events. |
339
+ | `destroy()` | Remove every toast and the toast region. |
340
+
341
+ The classes and types are exported too: `ToastManager`, and `ToastOptions`, `ToastConfig`, `ToastInstance`,
342
+ `ToastPosition`, `ToastTheme`, `ToastPromiseOptions` and more. If you are upgrading from 1.x, see the
343
+ [migration guide](https://github.com/ajaykr089/Editora/blob/main/packages/editora-toast/MIGRATION_GUIDE.md).
344
+
345
+ ## Part of Editora
346
+
347
+ [`@editora/ui-react`](https://www.npmjs.com/package/@editora/ui-react) depends on this package.
348
+
349
+ ## License
919
350
 
920
- ```typescript
921
- // New configuration options in v2.0.0
922
- toast.configure({
923
- theme: 'system', // New themes: glass, neon, retro, ocean, etc.
924
- swipeDismiss: true, // Mobile gesture support
925
- dragDismiss: false,
926
- animation: {
927
- type: 'spring', // New spring physics animations
928
- config: { stiffness: 120, damping: 12 }
929
- },
930
- queueStrategy: 'priority', // Priority-based queuing
931
- enableKeyboardNavigation: true // Enhanced accessibility
932
- });
933
- ```
934
-
935
- For more detailed migration information, see the [migration guide](./MIGRATION_GUIDE.md).
351
+ MIT ยฉ [Ajay Kumar](https://github.com/ajaykr089)