toastify-pro 1.3.0 → 1.5.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 +115 -57
- package/dist/toastify-pro.esm.js +676 -72
- package/dist/toastify-pro.esm.js.map +1 -1
- package/dist/toastify-pro.umd.js +676 -72
- package/dist/toastify-pro.umd.js.map +1 -1
- package/dist/toastify-pro.umd.min.js +4 -2
- package/dist/toastify-pro.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/toastify-pro.js +676 -72
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
[](https://github.com/abhipotter/toastify-pro/blob/main/LICENSE)
|
|
11
11
|
[](https://bundlephobia.com/package/toastify-pro)
|
|
12
12
|
|
|
13
|
-
[Demo](https://abhipotter.github.io/toastify-pro) • [Documentation](https://github.com/abhipotter/toastify-pro/wiki) • [Examples](https://github.com/abhipotter/toastify-pro/tree/main/examples)
|
|
13
|
+
[Demo](https://abhipotter.github.io/toastify-pro/demo) • [Documentation](https://github.com/abhipotter/toastify-pro/wiki) • [Examples](https://github.com/abhipotter/toastify-pro/tree/main/examples)
|
|
14
14
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
@@ -18,8 +18,8 @@
|
|
|
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
|
-
- 🎯 **Interactive Confirmation Dialogs** - Perfect replacement for SweetAlert with dark/light themes
|
|
22
|
-
- 📱 **7 Flexible Positions** - Including
|
|
21
|
+
- 🎯 **Interactive Confirmation Dialogs** - Perfect replacement for SweetAlert with dark/light themes
|
|
22
|
+
- 📱 **7 Flexible Positions** - Including center position ideal for confirmations
|
|
23
23
|
- ⚡ **Apple-Style Animations** - Smooth AirDrop-inspired entrance and car-swipe exit effects
|
|
24
24
|
- 🔧 **Framework Agnostic** - Works with React, Vue, Angular, or vanilla JS
|
|
25
25
|
- 🎯 **Auto-dismiss** - Configurable timeout with manual close option
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
- ♿ **Accessible** - Clean HTML structure with proper ARIA support
|
|
29
29
|
- 🎨 **Custom SVG Icons** - Beautiful vector icons for each toast type
|
|
30
30
|
- ✨ **Modern Design** - Glassmorphism effects with backdrop blur
|
|
31
|
-
-
|
|
32
|
-
-
|
|
31
|
+
- 🔒 **Single Instance** - Only one confirmation at a time with shake animation
|
|
32
|
+
- ⏳ **Loading States** - Built-in loading spinner for async operations
|
|
33
|
+
- 🎨 **Custom Gradients** - primaryColor & secondaryColor for gradient backgrounds
|
|
33
34
|
|
|
34
35
|
## 🚀 Quick Start
|
|
35
36
|
|
|
@@ -235,76 +236,133 @@ toast.light('Settings updated', { timeout: 2000 });
|
|
|
235
236
|
toast.light('Light Mode', 'Switched to clean light theme.'); // With description
|
|
236
237
|
```
|
|
237
238
|
|
|
238
|
-
#### 🆕 `toast.conf(message, descriptionOrCallback, callback)`
|
|
239
|
-
Display an interactive confirmation dialog with confirm/cancel buttons.
|
|
239
|
+
#### 🆕 `toast.conf(message, descriptionOrCallback, callback)` or `toast.confirm(message, descriptionOrCallback, callback)`
|
|
240
|
+
Display an interactive confirmation dialog with confirm/cancel buttons. Both methods work identically.
|
|
240
241
|
|
|
241
242
|
**Features:**
|
|
242
243
|
- 🎯 **Center positioning** (default) for maximum attention
|
|
243
|
-
-
|
|
244
|
-
-
|
|
244
|
+
- 🔒 **Single instance** - Only one confirmation at a time with shake animation
|
|
245
|
+
- ⏳ **Loading states** - Built-in spinner for async operations
|
|
246
|
+
- 🎨 **Custom gradients** - primaryColor & secondaryColor support
|
|
245
247
|
- 📱 **Responsive** design for mobile devices
|
|
246
248
|
- ⚡ **No auto-dismiss** - requires user interaction
|
|
247
249
|
|
|
248
|
-
**
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
**Options:**
|
|
251
|
+
| Option | Type | Default | Description |
|
|
252
|
+
|--------|------|---------|-------------|
|
|
253
|
+
| `description` | string | - | Secondary text below the message |
|
|
254
|
+
| `confirmText` | string | `'Confirm'` | Custom confirm button text |
|
|
255
|
+
| `cancelText` | string | `'Cancel'` | Custom cancel button text |
|
|
256
|
+
| `theme` | string | `'dark'` | Theme: `'dark'` or `'light'` |
|
|
257
|
+
| `position` | string | `'center'` | Any valid position |
|
|
258
|
+
| `primaryColor` | string | - | Primary gradient color (hex) |
|
|
259
|
+
| `secondaryColor` | string | - | Secondary gradient color (hex) |
|
|
260
|
+
| `onConfirm` | function | - | Callback when confirmed |
|
|
261
|
+
| `onCancel` | function | - | Callback when cancelled |
|
|
251
262
|
|
|
252
263
|
```javascript
|
|
253
|
-
// Simple confirmation
|
|
264
|
+
// Simple confirmation
|
|
254
265
|
toast.conf('Delete this item?', (confirmed) => {
|
|
255
|
-
if (confirmed)
|
|
256
|
-
console.log('User confirmed');
|
|
257
|
-
} else {
|
|
258
|
-
console.log('User cancelled');
|
|
259
|
-
}
|
|
266
|
+
if (confirmed) toast.success('Deleted!');
|
|
260
267
|
});
|
|
261
268
|
|
|
262
|
-
//
|
|
269
|
+
// With description
|
|
263
270
|
toast.conf('Are you sure?', 'This action cannot be undone.', (confirmed) => {
|
|
264
|
-
|
|
271
|
+
console.log('User confirmed:', confirmed);
|
|
265
272
|
});
|
|
266
273
|
|
|
267
|
-
//
|
|
274
|
+
// With options
|
|
268
275
|
toast.conf('Save changes?', {
|
|
269
|
-
description: 'Your changes will be
|
|
270
|
-
confirmText: 'Save
|
|
271
|
-
cancelText: 'Discard',
|
|
272
|
-
theme: 'light',
|
|
273
|
-
position: 'center'
|
|
274
|
-
|
|
275
|
-
|
|
276
|
+
description: 'Your changes will be saved permanently.',
|
|
277
|
+
confirmText: 'Save',
|
|
278
|
+
cancelText: 'Discard',
|
|
279
|
+
theme: 'light',
|
|
280
|
+
position: 'center'
|
|
281
|
+
}, (confirmed) => {
|
|
282
|
+
if (confirmed) submitForm();
|
|
276
283
|
});
|
|
284
|
+
```
|
|
277
285
|
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
}
|
|
286
|
+
#### ⏳ Loading States
|
|
287
|
+
Handle async operations with built-in loading spinner:
|
|
293
288
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
289
|
+
```javascript
|
|
290
|
+
// Manual loading control
|
|
291
|
+
toast.conf('Process data?', {
|
|
292
|
+
confirmText: 'Process'
|
|
293
|
+
}, (confirmed, { setLoading, close }) => {
|
|
294
|
+
if (confirmed) {
|
|
295
|
+
setLoading(true); // Show spinner, disable buttons
|
|
296
|
+
|
|
297
|
+
fetch('/api/process')
|
|
298
|
+
.then(() => {
|
|
299
|
+
setLoading(false);
|
|
300
|
+
close();
|
|
301
|
+
toast.success('Done!');
|
|
302
|
+
})
|
|
303
|
+
.catch(() => {
|
|
304
|
+
setLoading(false);
|
|
305
|
+
close();
|
|
306
|
+
toast.error('Failed!');
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// Async/await (auto-loading for promises)
|
|
312
|
+
toast.conf('Fetch data?', {
|
|
313
|
+
confirmText: 'Fetch',
|
|
314
|
+
onConfirm: async () => {
|
|
315
|
+
await fetch('/api/data'); // Auto shows loading
|
|
316
|
+
toast.success('Data fetched!');
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// With custom colors
|
|
321
|
+
toast.conf('Upload file?', {
|
|
322
|
+
primaryColor: '#f59e0b',
|
|
323
|
+
secondaryColor: '#d97706',
|
|
324
|
+
onConfirm: async ({ setLoading, close }) => {
|
|
325
|
+
setLoading(true);
|
|
326
|
+
await uploadFile();
|
|
327
|
+
close();
|
|
328
|
+
toast.success('Uploaded!');
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### 🎨 Custom Gradient Colors
|
|
334
|
+
Create beautiful gradient backgrounds:
|
|
335
|
+
|
|
336
|
+
```javascript
|
|
337
|
+
// Orange gradient
|
|
338
|
+
toast.conf('Custom styled!', {
|
|
339
|
+
primaryColor: '#f97316',
|
|
340
|
+
secondaryColor: '#ea580c',
|
|
341
|
+
confirmText: 'Nice!'
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// Purple gradient
|
|
345
|
+
toast.conf('Purple theme', {
|
|
346
|
+
primaryColor: '#8b5cf6',
|
|
347
|
+
secondaryColor: '#6366f1'
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// Text color auto-adjusts based on background brightness
|
|
351
|
+
toast.conf('Light background', {
|
|
352
|
+
primaryColor: '#fef3c7', // Light color
|
|
353
|
+
secondaryColor: '#fde68a' // Dark text will be used
|
|
354
|
+
});
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### 🔒 Single Instance (Shake Effect)
|
|
358
|
+
Only one confirmation dialog can be open at a time. Attempting to open another will shake the existing one:
|
|
359
|
+
|
|
360
|
+
```javascript
|
|
361
|
+
// First call - shows confirmation
|
|
362
|
+
toast.conf('First dialog');
|
|
363
|
+
|
|
364
|
+
// Second call - shakes existing dialog instead of opening new one
|
|
365
|
+
toast.conf('Second dialog'); // Shakes first dialog!
|
|
308
366
|
```
|
|
309
367
|
|
|
310
368
|
### 🆕 Enhanced Features
|