toastify-pro 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +475 -45
- package/assets/site/site.webmanifest +1 -1
- package/dist/toastify-pro.esm.js +1059 -68
- package/dist/toastify-pro.esm.js.map +1 -0
- package/dist/toastify-pro.umd.js +1062 -72
- package/dist/toastify-pro.umd.js.map +1 -0
- package/dist/toastify-pro.umd.min.js +24 -1
- package/dist/toastify-pro.umd.min.js.map +1 -0
- package/package.json +6 -5
- package/src/toastify-pro.js +1057 -67
package/README.md
CHANGED
|
@@ -18,12 +18,18 @@
|
|
|
18
18
|
|
|
19
19
|
- 🚀 **Lightweight** - Minimal bundle size with zero dependencies
|
|
20
20
|
- 🎨 **6 Built-in Themes** - Success, Error, Info, Warning, Dark, and Light themes
|
|
21
|
-
-
|
|
22
|
-
-
|
|
21
|
+
- 🎯 **Interactive Confirmation Dialogs** - Perfect replacement for SweetAlert with dark/light themes only
|
|
22
|
+
- 📱 **7 Flexible Positions** - Including new center position ideal for confirmations
|
|
23
|
+
- ⚡ **Apple-Style Animations** - Smooth AirDrop-inspired entrance and car-swipe exit effects
|
|
23
24
|
- 🔧 **Framework Agnostic** - Works with React, Vue, Angular, or vanilla JS
|
|
24
25
|
- 🎯 **Auto-dismiss** - Configurable timeout with manual close option
|
|
26
|
+
- 📝 **Description Support** - Optional secondary text for detailed messages
|
|
25
27
|
- 🌈 **Easy Customization** - Simple API with sensible defaults
|
|
26
|
-
- ♿ **Accessible** - Clean HTML structure with proper
|
|
28
|
+
- ♿ **Accessible** - Clean HTML structure with proper ARIA support
|
|
29
|
+
- 🎨 **Custom SVG Icons** - Beautiful vector icons for each toast type
|
|
30
|
+
- ✨ **Modern Design** - Glassmorphism effects with backdrop blur
|
|
31
|
+
- � **Perfect Callback Handling** - No double execution, conflict-free patterns
|
|
32
|
+
- ❌ **Close Button** - Interactive close buttons for confirmation dialogs
|
|
27
33
|
|
|
28
34
|
## 🚀 Quick Start
|
|
29
35
|
|
|
@@ -36,7 +42,7 @@ npm install toastify-pro
|
|
|
36
42
|
|
|
37
43
|
#### CDN (Browser)
|
|
38
44
|
```html
|
|
39
|
-
<script src="https://cdn.jsdelivr.net/npm/toastify-pro
|
|
45
|
+
<script src="https://cdn.jsdelivr.net/npm/toastify-pro/dist/toastify-pro.umd.min.js"></script>
|
|
40
46
|
```
|
|
41
47
|
|
|
42
48
|
### 🔨 Basic Usage
|
|
@@ -54,6 +60,36 @@ toast.warning('Please check your input');
|
|
|
54
60
|
toast.info('New update available');
|
|
55
61
|
toast.dark('Dark themed message');
|
|
56
62
|
toast.light('Light themed message');
|
|
63
|
+
|
|
64
|
+
// Show toasts with descriptions
|
|
65
|
+
toast.success('Success!', 'Your changes have been saved successfully.');
|
|
66
|
+
toast.error('Error occurred!', 'Please check your network connection and try again.');
|
|
67
|
+
toast.info('New feature!', 'Check out our latest updates in the dashboard.');
|
|
68
|
+
|
|
69
|
+
// 🆕 NEW: Confirmation dialogs
|
|
70
|
+
toast.conf('Delete this item?', (confirmed) => {
|
|
71
|
+
if (confirmed) {
|
|
72
|
+
toast.success('Item deleted successfully!');
|
|
73
|
+
} else {
|
|
74
|
+
toast.info('Delete cancelled');
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Confirmation with description
|
|
79
|
+
toast.conf('Are you sure?', 'This action cannot be undone.', (confirmed) => {
|
|
80
|
+
console.log('User confirmed:', confirmed);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Advanced confirmation options
|
|
84
|
+
toast.conf('Save changes?', {
|
|
85
|
+
description: 'Your changes will be permanently saved.',
|
|
86
|
+
confirmText: 'Save',
|
|
87
|
+
cancelText: 'Discard',
|
|
88
|
+
theme: 'light', // 'dark' (default) or 'light'
|
|
89
|
+
position: 'center', // Default for confirmations
|
|
90
|
+
onConfirm: () => console.log('Confirmed!'),
|
|
91
|
+
onCancel: () => console.log('Cancelled!')
|
|
92
|
+
});
|
|
57
93
|
```
|
|
58
94
|
|
|
59
95
|
#### With CDN
|
|
@@ -62,10 +98,11 @@ toast.light('Light themed message');
|
|
|
62
98
|
<html>
|
|
63
99
|
<head>
|
|
64
100
|
<title>Toastify Pro Example</title>
|
|
65
|
-
<script src="https://cdn.jsdelivr.net/npm/toastify-pro
|
|
101
|
+
<script src="https://cdn.jsdelivr.net/npm/toastify-pro/dist/toastify-pro.umd.min.js"></script>
|
|
66
102
|
</head>
|
|
67
103
|
<body>
|
|
68
104
|
<button onclick="showToast()">Show Toast</button>
|
|
105
|
+
<button onclick="showConfirmation()">Show Confirmation</button>
|
|
69
106
|
|
|
70
107
|
<script>
|
|
71
108
|
const toast = new ToastifyPro();
|
|
@@ -84,6 +121,29 @@ toast.light('Light themed message');
|
|
|
84
121
|
allowClose: true
|
|
85
122
|
});
|
|
86
123
|
}
|
|
124
|
+
|
|
125
|
+
// 🆕 NEW: Confirmation dialogs
|
|
126
|
+
function showConfirmation() {
|
|
127
|
+
toast.conf('Delete this item?', 'This action cannot be undone.', (confirmed) => {
|
|
128
|
+
if (confirmed) {
|
|
129
|
+
toast.success('Item deleted!');
|
|
130
|
+
} else {
|
|
131
|
+
toast.info('Delete cancelled');
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function showAdvancedConfirmation() {
|
|
137
|
+
toast.conf('Save document?', {
|
|
138
|
+
description: 'All your changes will be saved permanently.',
|
|
139
|
+
confirmText: 'Save Now',
|
|
140
|
+
cancelText: 'Cancel',
|
|
141
|
+
theme: 'light',
|
|
142
|
+
position: 'center'
|
|
143
|
+
}, (confirmed) => {
|
|
144
|
+
console.log('User decision:', confirmed);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
87
147
|
</script>
|
|
88
148
|
</body>
|
|
89
149
|
</html>
|
|
@@ -109,6 +169,7 @@ const toast = new ToastifyPro({
|
|
|
109
169
|
- `bottom-left` - Bottom left corner
|
|
110
170
|
- `bottom-right` - Bottom right corner
|
|
111
171
|
- `bottom-center` - Bottom center (default)
|
|
172
|
+
- `center` - Perfect center of screen (ideal for confirmations)
|
|
112
173
|
|
|
113
174
|
### Methods
|
|
114
175
|
|
|
@@ -118,52 +179,159 @@ Main method to display a toast notification.
|
|
|
118
179
|
toast.show('Custom message', 'success', {
|
|
119
180
|
timeout: 5000, // Override default timeout
|
|
120
181
|
allowClose: false, // Hide close button for this toast
|
|
121
|
-
maxLength: 50
|
|
182
|
+
maxLength: 50, // Override message length limit
|
|
183
|
+
description: 'Additional details about the message' // Optional description
|
|
122
184
|
});
|
|
123
185
|
```
|
|
124
186
|
|
|
125
|
-
####
|
|
126
|
-
|
|
187
|
+
#### Enhanced Toast Methods with Description Support
|
|
188
|
+
All toast methods now support description as a second parameter or in options:
|
|
189
|
+
|
|
190
|
+
#### `toast.success(message, options|description)`
|
|
191
|
+
Display a success toast with green background and checkmark icon.
|
|
127
192
|
```javascript
|
|
128
193
|
toast.success('Data saved successfully!');
|
|
129
194
|
toast.success('Upload complete!', { timeout: 2000 });
|
|
195
|
+
toast.success('Success!', 'Your changes have been saved.'); // With description
|
|
130
196
|
```
|
|
131
197
|
|
|
132
|
-
#### `toast.error(message, options)`
|
|
133
|
-
Display an error toast with red background.
|
|
198
|
+
#### `toast.error(message, options|description)`
|
|
199
|
+
Display an error toast with red background and error icon.
|
|
134
200
|
```javascript
|
|
135
201
|
toast.error('Failed to save data!');
|
|
136
202
|
toast.error('Network error occurred!', { allowClose: false });
|
|
203
|
+
toast.error('Error!', 'Please check your connection and try again.'); // With description
|
|
137
204
|
```
|
|
138
205
|
|
|
139
|
-
#### `toast.warning(message, options)`
|
|
140
|
-
Display a warning toast with orange background.
|
|
206
|
+
#### `toast.warning(message, options|description)`
|
|
207
|
+
Display a warning toast with orange background and warning icon.
|
|
141
208
|
```javascript
|
|
142
209
|
toast.warning('Please verify your input');
|
|
143
210
|
toast.warning('Session expires in 5 minutes', { timeout: 10000 });
|
|
211
|
+
toast.warning('Warning!', 'This action cannot be undone.'); // With description
|
|
144
212
|
```
|
|
145
213
|
|
|
146
|
-
#### `toast.info(message, options)`
|
|
147
|
-
Display an info toast with blue background.
|
|
214
|
+
#### `toast.info(message, options|description)`
|
|
215
|
+
Display an info toast with blue background and info icon.
|
|
148
216
|
```javascript
|
|
149
217
|
toast.info('New feature available!');
|
|
150
218
|
toast.info('Check your email for verification', { timeout: 0 }); // No auto-dismiss
|
|
219
|
+
toast.info('Info', 'Here are some helpful tips for you.'); // With description
|
|
151
220
|
```
|
|
152
221
|
|
|
153
|
-
#### `toast.dark(message, options)`
|
|
154
|
-
Display a dark themed toast.
|
|
222
|
+
#### `toast.dark(message, options|description)`
|
|
223
|
+
Display a dark themed toast with star icon.
|
|
155
224
|
```javascript
|
|
156
225
|
toast.dark('Dark mode enabled');
|
|
157
226
|
toast.dark('Processing in background...', { allowClose: false });
|
|
227
|
+
toast.dark('Dark Mode', 'Switched to elegant dark theme.'); // With description
|
|
158
228
|
```
|
|
159
229
|
|
|
160
|
-
#### `toast.light(message, options)`
|
|
161
|
-
Display a light themed toast with dark text.
|
|
230
|
+
#### `toast.light(message, options|description)`
|
|
231
|
+
Display a light themed toast with dark text and calendar icon.
|
|
162
232
|
```javascript
|
|
163
233
|
toast.light('Light theme activated');
|
|
164
234
|
toast.light('Settings updated', { timeout: 2000 });
|
|
235
|
+
toast.light('Light Mode', 'Switched to clean light theme.'); // With description
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### 🆕 `toast.conf(message, descriptionOrCallback, callback)`
|
|
239
|
+
Display an interactive confirmation dialog with confirm/cancel buttons.
|
|
240
|
+
|
|
241
|
+
**Features:**
|
|
242
|
+
- 🎯 **Center positioning** (default) for maximum attention
|
|
243
|
+
- ✖️ **Close button** in top-right corner (acts as cancel)
|
|
244
|
+
- 🎨 **Simple theming** - Dark (default) or Light themes only
|
|
245
|
+
- 📱 **Responsive** design for mobile devices
|
|
246
|
+
- ⚡ **No auto-dismiss** - requires user interaction
|
|
247
|
+
|
|
248
|
+
**Theme Options:**
|
|
249
|
+
- `theme: 'dark'` (default) - Dark theme with elegant styling
|
|
250
|
+
- `theme: 'light'` or `theme: 'white'` - Clean light theme with dark text
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
// Simple confirmation with callback
|
|
254
|
+
toast.conf('Delete this item?', (confirmed) => {
|
|
255
|
+
if (confirmed) {
|
|
256
|
+
console.log('User confirmed');
|
|
257
|
+
} else {
|
|
258
|
+
console.log('User cancelled');
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// Confirmation with description
|
|
263
|
+
toast.conf('Are you sure?', 'This action cannot be undone.', (confirmed) => {
|
|
264
|
+
handleUserChoice(confirmed);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Advanced confirmation with full options
|
|
268
|
+
toast.conf('Save changes?', {
|
|
269
|
+
description: 'Your changes will be permanently saved to the server.',
|
|
270
|
+
confirmText: 'Save Now', // Custom confirm button text
|
|
271
|
+
cancelText: 'Discard', // Custom cancel button text
|
|
272
|
+
theme: 'light', // Theme: 'dark' (default) or 'light'
|
|
273
|
+
position: 'center', // Position (defaults to 'center' for confirmations)
|
|
274
|
+
onConfirm: () => saveData(), // Alternative callback approach
|
|
275
|
+
onCancel: () => discardChanges()
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// Real-world example: Delete confirmation
|
|
279
|
+
function deleteItem(itemId) {
|
|
280
|
+
toast.conf('Delete item?',
|
|
281
|
+
'This will permanently remove the item from your account.',
|
|
282
|
+
(confirmed) => {
|
|
283
|
+
if (confirmed) {
|
|
284
|
+
// Perform deletion
|
|
285
|
+
deleteFromServer(itemId);
|
|
286
|
+
toast.success('Item deleted successfully!');
|
|
287
|
+
} else {
|
|
288
|
+
toast.info('Delete cancelled');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Form save confirmation
|
|
295
|
+
function handleFormSubmit() {
|
|
296
|
+
toast.conf('Save changes?', {
|
|
297
|
+
description: 'Your form data will be submitted and cannot be edited later.',
|
|
298
|
+
confirmText: 'Submit',
|
|
299
|
+
cancelText: 'Keep Editing',
|
|
300
|
+
theme: 'dark', // Default theme, can be 'light'
|
|
301
|
+
position: 'center'
|
|
302
|
+
}, (confirmed) => {
|
|
303
|
+
if (confirmed) {
|
|
304
|
+
submitForm();
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
165
308
|
```
|
|
166
309
|
|
|
310
|
+
### 🆕 Enhanced Features
|
|
311
|
+
|
|
312
|
+
#### Custom SVG Icons
|
|
313
|
+
Each toast type includes beautiful vector icons that scale perfectly:
|
|
314
|
+
- **Success**: ✓ Checkmark circle icon
|
|
315
|
+
- **Error**: ✗ X circle icon
|
|
316
|
+
- **Warning**: ⚠ Triangle warning icon
|
|
317
|
+
- **Info**: ℹ Info circle icon
|
|
318
|
+
- **Dark**: ★ Star icon
|
|
319
|
+
- **Light**: ☀ Calendar icon
|
|
320
|
+
|
|
321
|
+
#### Position-Aware Car Swipe Animations
|
|
322
|
+
Toasts automatically exit with position-aware animations:
|
|
323
|
+
- `carSwipeBottom` - For bottom positioned toasts (swipes down)
|
|
324
|
+
- `carSwipeTop` - For top positioned toasts (swipes up)
|
|
325
|
+
- `carSwipeLeft` - For left positioned toasts (swipes left)
|
|
326
|
+
- `carSwipeRight` - For right positioned toasts (swipes right)
|
|
327
|
+
- `carSwipeCenter` - For center positioned toasts (swipes down)
|
|
328
|
+
|
|
329
|
+
#### POP UP Entrance Animation
|
|
330
|
+
All toasts use the `airdropPop` entrance animation with:
|
|
331
|
+
- 4-stage rotation and scaling effects
|
|
332
|
+
- Professional iOS-inspired timing
|
|
333
|
+
- Smooth cubic-bezier transitions
|
|
334
|
+
|
|
167
335
|
## 🎨 Customization
|
|
168
336
|
|
|
169
337
|
### Global Configuration
|
|
@@ -184,6 +352,16 @@ toast.error('Critical error!', { timeout: 0 });
|
|
|
184
352
|
// Quick notification
|
|
185
353
|
toast.success('Saved!', { timeout: 1000 });
|
|
186
354
|
|
|
355
|
+
// Toast with description - object format
|
|
356
|
+
toast.info('Update Available', {
|
|
357
|
+
description: 'Version 2.0 is now available with new features and improvements.',
|
|
358
|
+
timeout: 8000,
|
|
359
|
+
allowClose: true
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// Toast with description - simple format
|
|
363
|
+
toast.success('Welcome!', 'Thanks for joining our platform. Explore the features!');
|
|
364
|
+
|
|
187
365
|
// Long message with close button
|
|
188
366
|
toast.info('This is a very long message that might be truncated', {
|
|
189
367
|
maxLength: 200,
|
|
@@ -244,11 +422,55 @@ function App() {
|
|
|
244
422
|
const handleError = () => {
|
|
245
423
|
toast?.error('Something went wrong in React!');
|
|
246
424
|
};
|
|
425
|
+
|
|
426
|
+
const handleWithDescription = () => {
|
|
427
|
+
toast?.info('New Feature!', 'Check out our latest React integration updates.');
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
// 🆕 NEW: Confirmation dialog examples
|
|
431
|
+
const handleDelete = () => {
|
|
432
|
+
toast?.conf('Delete item?', 'This action cannot be undone.', (confirmed) => {
|
|
433
|
+
if (confirmed) {
|
|
434
|
+
// Perform deletion logic
|
|
435
|
+
console.log('Deleting item...');
|
|
436
|
+
toast?.success('Item deleted successfully!');
|
|
437
|
+
} else {
|
|
438
|
+
toast?.info('Delete cancelled');
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
const handleLogout = () => {
|
|
444
|
+
toast?.conf('Sign out?', {
|
|
445
|
+
description: 'You will need to sign in again to access your account.',
|
|
446
|
+
confirmText: 'Sign Out',
|
|
447
|
+
cancelText: 'Stay Signed In',
|
|
448
|
+
theme: 'dark',
|
|
449
|
+
position: 'center'
|
|
450
|
+
}, (confirmed) => {
|
|
451
|
+
if (confirmed) {
|
|
452
|
+
// Logout logic
|
|
453
|
+
window.location.href = '/login';
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
const handleIconDemo = () => {
|
|
459
|
+
// Showcase different icons with descriptions
|
|
460
|
+
toast?.success('✓ Success Icon', 'Beautiful checkmark with green theme');
|
|
461
|
+
setTimeout(() => toast?.error('✗ Error Icon', 'Clear error indication with red theme'), 500);
|
|
462
|
+
setTimeout(() => toast?.warning('⚠ Warning Icon', 'Alert triangle with orange theme'), 1000);
|
|
463
|
+
setTimeout(() => toast?.info('ℹ Info Icon', 'Information circle with blue theme'), 1500);
|
|
464
|
+
};
|
|
247
465
|
|
|
248
466
|
return (
|
|
249
467
|
<div>
|
|
250
468
|
<button onClick={handleSuccess}>Show Success</button>
|
|
251
469
|
<button onClick={handleError}>Show Error</button>
|
|
470
|
+
<button onClick={handleWithDescription}>Show with Description</button>
|
|
471
|
+
<button onClick={handleIconDemo}>Demo All Icons</button>
|
|
472
|
+
<button onClick={handleDelete}>Delete with Confirmation</button>
|
|
473
|
+
<button onClick={handleLogout}>Logout Confirmation</button>
|
|
252
474
|
</div>
|
|
253
475
|
);
|
|
254
476
|
}
|
|
@@ -263,6 +485,8 @@ export default App;
|
|
|
263
485
|
<button @click="showSuccess">Show Success</button>
|
|
264
486
|
<button @click="showError">Show Error</button>
|
|
265
487
|
<button @click="showCustom">Show Custom</button>
|
|
488
|
+
<button @click="showConfirmation">Show Confirmation</button>
|
|
489
|
+
<button @click="showDeleteConfirmation">Delete Item</button>
|
|
266
490
|
</div>
|
|
267
491
|
</template>
|
|
268
492
|
|
|
@@ -294,6 +518,38 @@ export default {
|
|
|
294
518
|
timeout: 6000,
|
|
295
519
|
allowClose: true
|
|
296
520
|
});
|
|
521
|
+
},
|
|
522
|
+
// 🆕 NEW: Confirmation methods
|
|
523
|
+
showConfirmation() {
|
|
524
|
+
this.toast.conf('Save changes?', (confirmed) => {
|
|
525
|
+
if (confirmed) {
|
|
526
|
+
this.saveData();
|
|
527
|
+
} else {
|
|
528
|
+
this.toast.info('Changes not saved');
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
},
|
|
532
|
+
showDeleteConfirmation() {
|
|
533
|
+
this.toast.conf('Delete this item?', {
|
|
534
|
+
description: 'This action cannot be undone and will remove all associated data.',
|
|
535
|
+
confirmText: 'Delete',
|
|
536
|
+
cancelText: 'Keep',
|
|
537
|
+
theme: 'dark',
|
|
538
|
+
position: 'center'
|
|
539
|
+
}, (confirmed) => {
|
|
540
|
+
if (confirmed) {
|
|
541
|
+
this.deleteItem();
|
|
542
|
+
this.toast.success('Item deleted successfully!');
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
},
|
|
546
|
+
saveData() {
|
|
547
|
+
// Save logic here
|
|
548
|
+
this.toast.success('Data saved successfully!');
|
|
549
|
+
},
|
|
550
|
+
deleteItem() {
|
|
551
|
+
// Delete logic here
|
|
552
|
+
console.log('Item deleted');
|
|
297
553
|
}
|
|
298
554
|
}
|
|
299
555
|
};
|
|
@@ -311,6 +567,8 @@ import ToastifyPro from 'toastify-pro';
|
|
|
311
567
|
<button (click)="showSuccess()">Show Success</button>
|
|
312
568
|
<button (click)="showError()">Show Error</button>
|
|
313
569
|
<button (click)="showInfo()">Show Info</button>
|
|
570
|
+
<button (click)="showConfirmation()">Show Confirmation</button>
|
|
571
|
+
<button (click)="showLogoutConfirmation()">Logout</button>
|
|
314
572
|
`
|
|
315
573
|
})
|
|
316
574
|
export class ToastExampleComponent implements OnInit {
|
|
@@ -337,6 +595,41 @@ export class ToastExampleComponent implements OnInit {
|
|
|
337
595
|
timeout: 5000
|
|
338
596
|
});
|
|
339
597
|
}
|
|
598
|
+
|
|
599
|
+
// 🆕 NEW: Confirmation methods
|
|
600
|
+
showConfirmation() {
|
|
601
|
+
this.toast.conf('Save document?', 'All changes will be saved permanently.', (confirmed: boolean) => {
|
|
602
|
+
if (confirmed) {
|
|
603
|
+
this.saveDocument();
|
|
604
|
+
} else {
|
|
605
|
+
this.toast.info('Save cancelled');
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
showLogoutConfirmation() {
|
|
611
|
+
this.toast.conf('Sign out?', {
|
|
612
|
+
description: 'You will be logged out of your account.',
|
|
613
|
+
confirmText: 'Sign Out',
|
|
614
|
+
cancelText: 'Cancel',
|
|
615
|
+
theme: 'light',
|
|
616
|
+
position: 'center'
|
|
617
|
+
}, (confirmed: boolean) => {
|
|
618
|
+
if (confirmed) {
|
|
619
|
+
this.logout();
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
private saveDocument() {
|
|
625
|
+
// Save logic
|
|
626
|
+
this.toast.success('Document saved successfully!');
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
private logout() {
|
|
630
|
+
// Logout logic
|
|
631
|
+
this.toast.success('Logged out successfully!');
|
|
632
|
+
}
|
|
340
633
|
}
|
|
341
634
|
```
|
|
342
635
|
|
|
@@ -349,30 +642,157 @@ const toast = new ToastifyPro({
|
|
|
349
642
|
allowClose: true
|
|
350
643
|
});
|
|
351
644
|
|
|
352
|
-
// Form submission example
|
|
645
|
+
// Form submission example with confirmation
|
|
353
646
|
document.getElementById('submitForm').addEventListener('click', async function() {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
647
|
+
toast.conf('Submit form?', 'Your data will be sent to the server.', async (confirmed) => {
|
|
648
|
+
if (confirmed) {
|
|
649
|
+
try {
|
|
650
|
+
// Simulate API call
|
|
651
|
+
const response = await fetch('/api/submit', { method: 'POST' });
|
|
652
|
+
|
|
653
|
+
if (response.ok) {
|
|
654
|
+
toast.success('Form submitted successfully!', 'Your data has been processed and saved.');
|
|
655
|
+
} else {
|
|
656
|
+
toast.error('Failed to submit form', 'Please check your inputs and try again.');
|
|
657
|
+
}
|
|
658
|
+
} catch (error) {
|
|
659
|
+
toast.error('Network error occurred', 'Check your connection and retry.');
|
|
660
|
+
}
|
|
362
661
|
}
|
|
363
|
-
}
|
|
364
|
-
toast.error('Network error occurred');
|
|
365
|
-
}
|
|
662
|
+
});
|
|
366
663
|
});
|
|
367
664
|
|
|
368
|
-
//
|
|
665
|
+
// Delete confirmation example
|
|
666
|
+
function deleteItem(itemId) {
|
|
667
|
+
toast.conf('Delete this item?', {
|
|
668
|
+
description: 'This action cannot be undone and will permanently remove all associated data.',
|
|
669
|
+
confirmText: 'Delete',
|
|
670
|
+
cancelText: 'Keep',
|
|
671
|
+
theme: 'dark',
|
|
672
|
+
position: 'center'
|
|
673
|
+
}, (confirmed) => {
|
|
674
|
+
if (confirmed) {
|
|
675
|
+
// Perform deletion
|
|
676
|
+
console.log('Deleting item:', itemId);
|
|
677
|
+
toast.success('Item deleted!', 'The item has been permanently removed.');
|
|
678
|
+
} else {
|
|
679
|
+
toast.info('Delete cancelled', 'Your item is safe.');
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// File upload with confirmation and progress
|
|
685
|
+
function handleFileUpload() {
|
|
686
|
+
toast.conf('Upload file?', 'The file will be uploaded to your account.', (confirmed) => {
|
|
687
|
+
if (confirmed) {
|
|
688
|
+
toast.info('Uploading...', 'Please wait while we process your file.');
|
|
689
|
+
|
|
690
|
+
// Simulate upload completion
|
|
691
|
+
setTimeout(() => {
|
|
692
|
+
toast.success('Upload complete!', 'Your file has been uploaded successfully.');
|
|
693
|
+
}, 3000);
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// Logout confirmation
|
|
699
|
+
function logout() {
|
|
700
|
+
toast.conf('Sign out?', {
|
|
701
|
+
description: 'You will need to sign in again to access your account.',
|
|
702
|
+
confirmText: 'Sign Out',
|
|
703
|
+
cancelText: 'Stay Signed In',
|
|
704
|
+
theme: 'light'
|
|
705
|
+
}, (confirmed) => {
|
|
706
|
+
if (confirmed) {
|
|
707
|
+
window.location.href = '/login';
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// Multiple toast types with descriptions
|
|
369
713
|
function showAllTypes() {
|
|
370
|
-
toast.success('Success
|
|
371
|
-
setTimeout(() => toast.error('Error
|
|
372
|
-
setTimeout(() => toast.warning('Warning
|
|
373
|
-
setTimeout(() => toast.info('Info
|
|
374
|
-
setTimeout(() => toast.dark('Dark
|
|
375
|
-
setTimeout(() => toast.light('Light
|
|
714
|
+
toast.success('Success!', 'Operation completed successfully');
|
|
715
|
+
setTimeout(() => toast.error('Error!', 'Something went wrong'), 500);
|
|
716
|
+
setTimeout(() => toast.warning('Warning!', 'Please review this action'), 1000);
|
|
717
|
+
setTimeout(() => toast.info('Info', 'Here is some helpful information'), 1500);
|
|
718
|
+
setTimeout(() => toast.dark('Dark Mode', 'Elegant dark notification'), 2000);
|
|
719
|
+
setTimeout(() => toast.light('Light Mode', 'Clean light notification'), 2500);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// Showcase new enhanced features including confirmations
|
|
723
|
+
function demoEnhancedFeatures() {
|
|
724
|
+
// SVG Icons demo
|
|
725
|
+
toast.success('✓ Beautiful Icons', 'Each type has its own vector icon that scales perfectly');
|
|
726
|
+
|
|
727
|
+
// Car swipe animation (automatic based on position)
|
|
728
|
+
setTimeout(() => {
|
|
729
|
+
toast.info('🚗 Car Swipe Exit', 'Watch the position-aware exit animation');
|
|
730
|
+
}, 1000);
|
|
731
|
+
|
|
732
|
+
// Apple AirDrop entrance (automatic)
|
|
733
|
+
setTimeout(() => {
|
|
734
|
+
toast.warning('📱 AirDrop Style', 'iOS-inspired entrance with rotation effects');
|
|
735
|
+
}, 2000);
|
|
736
|
+
|
|
737
|
+
// Glassmorphism design
|
|
738
|
+
setTimeout(() => {
|
|
739
|
+
toast.dark('✨ Glassmorphism', 'Modern backdrop blur with translucent design');
|
|
740
|
+
}, 3000);
|
|
741
|
+
|
|
742
|
+
// 🆕 Confirmation dialog demo
|
|
743
|
+
setTimeout(() => {
|
|
744
|
+
toast.conf('Try confirmation?', 'Experience the new interactive dialog feature.', (confirmed) => {
|
|
745
|
+
if (confirmed) {
|
|
746
|
+
toast.success('🎉 Confirmation works!', 'You can now create interactive dialogs easily.');
|
|
747
|
+
} else {
|
|
748
|
+
toast.info('No problem!', 'Confirmation dialogs are optional.');
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
}, 4000);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// Advanced confirmation examples
|
|
755
|
+
function advancedConfirmationExamples() {
|
|
756
|
+
// Settings reset confirmation
|
|
757
|
+
toast.conf('Reset all settings?', {
|
|
758
|
+
description: 'This will restore all settings to their default values.',
|
|
759
|
+
confirmText: 'Reset',
|
|
760
|
+
cancelText: 'Cancel',
|
|
761
|
+
theme: 'dark',
|
|
762
|
+
position: 'center'
|
|
763
|
+
}, (confirmed) => {
|
|
764
|
+
if (confirmed) {
|
|
765
|
+
// Reset settings logic
|
|
766
|
+
toast.success('Settings reset!', 'All settings have been restored to defaults.');
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Advanced usage with all new features
|
|
772
|
+
function advancedExample() {
|
|
773
|
+
// Progress indication with confirmation first
|
|
774
|
+
toast.conf('Start processing?', {
|
|
775
|
+
description: 'This will upload your file to the server and may take a few minutes.',
|
|
776
|
+
confirmText: 'Start',
|
|
777
|
+
cancelText: 'Later',
|
|
778
|
+
theme: 'light'
|
|
779
|
+
}, (confirmed) => {
|
|
780
|
+
if (confirmed) {
|
|
781
|
+
toast.info('Processing...', {
|
|
782
|
+
description: 'Please wait while we upload your file to the server',
|
|
783
|
+
timeout: 0, // No auto-dismiss
|
|
784
|
+
allowClose: true
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
// Simulate progress completion
|
|
788
|
+
setTimeout(() => {
|
|
789
|
+
toast.success('Upload Complete!', {
|
|
790
|
+
description: 'Your file has been uploaded successfully with all metadata',
|
|
791
|
+
timeout: 5000
|
|
792
|
+
});
|
|
793
|
+
}, 3000);
|
|
794
|
+
}
|
|
795
|
+
});
|
|
376
796
|
}
|
|
377
797
|
```
|
|
378
798
|
|
|
@@ -393,17 +813,27 @@ function showAllTypes() {
|
|
|
393
813
|
| `timeout` | number | `3000` | Auto-dismiss time (0 = no auto-dismiss) |
|
|
394
814
|
| `allowClose` | boolean | `true` | Show close button |
|
|
395
815
|
| `maxLength` | number | `100` | Maximum message length |
|
|
816
|
+
| `description` | string | `undefined` | Optional secondary text for detailed information |
|
|
396
817
|
|
|
397
818
|
## 🎨 Available Themes
|
|
398
819
|
|
|
399
|
-
| Theme | Background | Text Color | Use Case |
|
|
400
|
-
|
|
401
|
-
| `success` | Green | White | Success messages |
|
|
402
|
-
| `error` | Red | White | Error messages |
|
|
403
|
-
| `warning` | Orange | White | Warning messages |
|
|
404
|
-
| `info` | Blue | White | Information messages |
|
|
405
|
-
| `dark` | Dark Gray | White | General purpose |
|
|
406
|
-
| `light` | Light Gray | Black | Light theme compatibility |
|
|
820
|
+
| Theme | Background | Text Color | Icon | Use Case |
|
|
821
|
+
|-------|------------|------------|------|----------|
|
|
822
|
+
| `success` | Green | White | ✓ Checkmark | Success messages |
|
|
823
|
+
| `error` | Red | White | ✗ X Circle | Error messages |
|
|
824
|
+
| `warning` | Orange | White | ⚠ Triangle | Warning messages |
|
|
825
|
+
| `info` | Blue | White | ℹ Info Circle | Information messages |
|
|
826
|
+
| `dark` | Dark Gray | White | ★ Star | General purpose |
|
|
827
|
+
| `light` | Light Gray | Black | ☀ Calendar | Light theme compatibility |
|
|
828
|
+
|
|
829
|
+
### 🆕 Enhanced Visual Features
|
|
830
|
+
|
|
831
|
+
- **Custom SVG Icons**: Each theme includes beautiful vector icons that are crisp at any resolution
|
|
832
|
+
- **Glassmorphism Design**: Modern backdrop-filter blur effects with translucent backgrounds
|
|
833
|
+
- **Car Swipe Animations**: Position-aware exit animations that swipe toasts in natural directions
|
|
834
|
+
- **POP UP Entrance**: Professional iOS-inspired entrance with 4-stage rotation and scaling
|
|
835
|
+
- **Progress Bar**: Animated progress bar with shimmer effects showing remaining time
|
|
836
|
+
- **Responsive Design**: Mobile-first approach that adapts to all screen sizes
|
|
407
837
|
|
|
408
838
|
## 📄 License
|
|
409
839
|
|