toastify-pro 1.6.0 โ†’ 1.7.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 CHANGED
@@ -1,930 +1,228 @@
1
1
  <div align="center">
2
2
 
3
- <img src="https://abhipotter.github.io/toastify-pro/assets/logo/logo.png" alt="Toastify Pro Logo" width="100" height="100"/>
4
- <h1> ๐Ÿš€ Quick Start - Install Toastify Pro (JavaScript Toast Notifications) </h1>
3
+ # Toastify Pro
5
4
 
6
- **A modern, lightweight, and highly customizable toast notification library**
5
+ **Modern, lightweight toast notifications for JavaScript**
7
6
 
8
7
  [![npm version](https://img.shields.io/npm/v/toastify-pro.svg)](https://www.npmjs.com/package/toastify-pro)
9
8
  [![npm downloads](https://img.shields.io/npm/dm/toastify-pro.svg)](https://www.npmjs.com/package/toastify-pro)
10
- [![License](https://img.shields.io/npm/l/toastify-pro.svg)](https://github.com/abhipotter/toastify-pro/blob/main/LICENSE)
11
9
  [![Bundle Size](https://img.shields.io/bundlephobia/minzip/toastify-pro)](https://bundlephobia.com/package/toastify-pro)
10
+ [![License](https://img.shields.io/npm/l/toastify-pro.svg)](LICENSE)
12
11
 
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)
12
+ [Demo](https://abhipotter.github.io/toastify-pro/demo) ยท [Documentation](https://abhipotter.github.io/toastify-pro/demo)
14
13
 
15
14
  </div>
16
15
 
17
- ## โœจ Features
18
-
19
- - ๐Ÿš€ **Lightweight** - Minimal bundle size with zero dependencies
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 center position ideal for confirmations
23
- - โšก **Apple-Style Animations** - Smooth AirDrop-inspired entrance and car-swipe exit effects
24
- - ๐Ÿ”ง **Framework Agnostic** - Works with React, Vue, Angular, or vanilla JS
25
- - ๐ŸŽฏ **Auto-dismiss** - Configurable timeout with manual close option
26
- - ๐Ÿ“ **Description Support** - Optional secondary text for detailed messages
27
- - ๐ŸŒˆ **Easy Customization** - Simple API with sensible defaults
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
- - ๐Ÿ”’ **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
34
-
35
- ## ๐Ÿš€ Quick Start
36
-
37
- ### ๐Ÿ“ฆ Installation
38
-
39
- #### NPM (React, Node.js, etc.)
16
+ ---
17
+
18
+ ## Features
19
+
20
+ - **Lightweight** โ€” ~2KB minified, zero dependencies
21
+ - **6 Themes** โ€” Success, error, warning, info, dark, light
22
+ - **7 Positions** โ€” All corners, centers, and center
23
+ - **Confirmations** โ€” Interactive dialogs with async support
24
+ - **Input Prompts** โ€” Text input with validation
25
+ - **Glassmorphism** โ€” Modern blur effects
26
+ - **Accessible** โ€” ARIA support, keyboard navigation
27
+ - **Framework Agnostic** โ€” Works everywhere
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
40
33
  ```bash
41
34
  npm install toastify-pro
42
35
  ```
43
36
 
44
- #### CDN (Browser)
37
+ **Or use CDN:**
38
+
45
39
  ```html
46
40
  <script src="https://cdn.jsdelivr.net/npm/toastify-pro/dist/toastify-pro.umd.min.js"></script>
47
41
  ```
48
42
 
49
- ### ๐Ÿ”จ Basic Usage
43
+ ---
44
+
45
+ ## Quick Start
50
46
 
51
- #### With NPM
52
47
  ```javascript
53
48
  import ToastifyPro from 'toastify-pro';
54
49
 
55
50
  const toast = new ToastifyPro();
56
51
 
57
- // Show different types of toasts
58
- toast.success('Operation completed successfully!');
59
- toast.error('Something went wrong!');
52
+ // Basic toasts
53
+ toast.success('Saved successfully!');
54
+ toast.error('Something went wrong');
60
55
  toast.warning('Please check your input');
61
56
  toast.info('New update available');
62
- toast.dark('Dark themed message');
63
- toast.light('Light themed message');
64
-
65
- // Show toasts with descriptions
66
- toast.success('Success!', 'Your changes have been saved successfully.');
67
- toast.error('Error occurred!', 'Please check your network connection and try again.');
68
- toast.info('New feature!', 'Check out our latest updates in the dashboard.');
69
-
70
- // ๐Ÿ†• NEW: Confirmation dialogs
71
- toast.conf('Delete this item?', (confirmed) => {
72
- if (confirmed) {
73
- toast.success('Item deleted successfully!');
74
- } else {
75
- toast.info('Delete cancelled');
76
- }
77
- });
78
-
79
- // Confirmation with description
80
- toast.conf('Are you sure?', 'This action cannot be undone.', (confirmed) => {
81
- console.log('User confirmed:', confirmed);
82
- });
83
-
84
- // Advanced confirmation options
85
- toast.conf('Save changes?', {
86
- description: 'Your changes will be permanently saved.',
87
- confirmText: 'Save',
88
- cancelText: 'Discard',
89
- theme: 'light', // 'dark' (default) or 'light'
90
- position: 'center', // Default for confirmations
91
- onConfirm: () => console.log('Confirmed!'),
92
- onCancel: () => console.log('Cancelled!')
93
- });
94
- ```
95
-
96
- #### With CDN
97
- ```html
98
- <!DOCTYPE html>
99
- <html>
100
- <head>
101
- <title>Toastify Pro Example</title>
102
- <script src="https://cdn.jsdelivr.net/npm/toastify-pro/dist/toastify-pro.umd.min.js"></script>
103
- </head>
104
- <body>
105
- <button onclick="showToast()">Show Toast</button>
106
- <button onclick="showConfirmation()">Show Confirmation</button>
107
-
108
- <script>
109
- const toast = new ToastifyPro();
110
-
111
- function showToast() {
112
- toast.success('Hello from Toastify Pro!');
113
- }
114
-
115
- function showError() {
116
- toast.error('Something went wrong!');
117
- }
118
-
119
- function showCustom() {
120
- toast.show('Custom message', 'info', {
121
- timeout: 5000,
122
- allowClose: true
123
- });
124
- }
125
-
126
- // ๐Ÿ†• NEW: Confirmation dialogs
127
- function showConfirmation() {
128
- toast.conf('Delete this item?', 'This action cannot be undone.', (confirmed) => {
129
- if (confirmed) {
130
- toast.success('Item deleted!');
131
- } else {
132
- toast.info('Delete cancelled');
133
- }
134
- });
135
- }
136
-
137
- function showAdvancedConfirmation() {
138
- toast.conf('Save document?', {
139
- description: 'All your changes will be saved permanently.',
140
- confirmText: 'Save Now',
141
- cancelText: 'Cancel',
142
- theme: 'light',
143
- position: 'center'
144
- }, (confirmed) => {
145
- console.log('User decision:', confirmed);
146
- });
147
- }
148
- </script>
149
- </body>
150
- </html>
151
- ```
152
-
153
- ## ๐Ÿ“š API Reference
154
-
155
- ### Constructor Options
156
-
157
- ```javascript
158
- const toast = new ToastifyPro({
159
- position: 'bottom-center', // Position of toast container
160
- timeout: 3000, // Auto-dismiss time in milliseconds
161
- allowClose: true, // Show close button
162
- maxLength: 100 // Maximum message length
163
- });
164
- ```
165
-
166
- #### Position Options
167
- - `top-left` - Top left corner
168
- - `top-right` - Top right corner
169
- - `top-center` - Top center
170
- - `bottom-left` - Bottom left corner
171
- - `bottom-right` - Bottom right corner
172
- - `bottom-center` - Bottom center (default)
173
- - `center` - Perfect center of screen (ideal for confirmations)
174
-
175
- ### Methods
176
-
177
- #### `toast.show(message, type, options)`
178
- Main method to display a toast notification.
179
- ```javascript
180
- toast.show('Custom message', 'success', {
181
- timeout: 5000, // Override default timeout
182
- allowClose: false, // Hide close button for this toast
183
- maxLength: 50, // Override message length limit
184
- description: 'Additional details about the message' // Optional description
185
- });
186
- ```
187
57
 
188
- #### Enhanced Toast Methods with Description Support
189
- All toast methods now support description as a second parameter or in options:
190
-
191
- #### `toast.success(message, options|description)`
192
- Display a success toast with green background and checkmark icon.
193
- ```javascript
194
- toast.success('Data saved successfully!');
195
- toast.success('Upload complete!', { timeout: 2000 });
196
- toast.success('Success!', 'Your changes have been saved.'); // With description
197
- ```
198
-
199
- #### `toast.error(message, options|description)`
200
- Display an error toast with red background and error icon.
201
- ```javascript
202
- toast.error('Failed to save data!');
203
- toast.error('Network error occurred!', { allowClose: false });
204
- toast.error('Error!', 'Please check your connection and try again.'); // With description
205
- ```
206
-
207
- #### `toast.warning(message, options|description)`
208
- Display a warning toast with orange background and warning icon.
209
- ```javascript
210
- toast.warning('Please verify your input');
211
- toast.warning('Session expires in 5 minutes', { timeout: 10000 });
212
- toast.warning('Warning!', 'This action cannot be undone.'); // With description
213
- ```
214
-
215
- #### `toast.info(message, options|description)`
216
- Display an info toast with blue background and info icon.
217
- ```javascript
218
- toast.info('New feature available!');
219
- toast.info('Check your email for verification', { timeout: 0 }); // No auto-dismiss
220
- toast.info('Info', 'Here are some helpful tips for you.'); // With description
221
- ```
222
-
223
- #### `toast.dark(message, options|description)`
224
- Display a dark themed toast with star icon.
225
- ```javascript
226
- toast.dark('Dark mode enabled');
227
- toast.dark('Processing in background...', { allowClose: false });
228
- toast.dark('Dark Mode', 'Switched to elegant dark theme.'); // With description
58
+ // With description
59
+ toast.success('File uploaded', { description: 'document.pdf is ready' });
229
60
  ```
230
61
 
231
- #### `toast.light(message, options|description)`
232
- Display a light themed toast with dark text and calendar icon.
233
- ```javascript
234
- toast.light('Light theme activated');
235
- toast.light('Settings updated', { timeout: 2000 });
236
- toast.light('Light Mode', 'Switched to clean light theme.'); // With description
237
- ```
62
+ ---
238
63
 
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.
241
-
242
- **Features:**
243
- - ๐ŸŽฏ **Center positioning** (default) for maximum attention
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
247
- - ๐Ÿ“ฑ **Responsive** design for mobile devices
248
- - โšก **No auto-dismiss** - requires user interaction
249
-
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 |
64
+ ## Confirmation Dialogs
262
65
 
263
66
  ```javascript
264
- // Simple confirmation
67
+ // Simple
265
68
  toast.conf('Delete this item?', (confirmed) => {
266
- if (confirmed) toast.success('Deleted!');
267
- });
268
-
269
- // With description
270
- toast.conf('Are you sure?', 'This action cannot be undone.', (confirmed) => {
271
- console.log('User confirmed:', confirmed);
69
+ if (confirmed) toast.success('Deleted!');
272
70
  });
273
71
 
274
72
  // With options
275
73
  toast.conf('Save changes?', {
276
- description: 'Your changes will be saved permanently.',
277
- confirmText: 'Save',
278
- cancelText: 'Discard',
279
- theme: 'light',
280
- position: 'center'
74
+ description: 'This cannot be undone',
75
+ confirmText: 'Save',
76
+ cancelText: 'Discard',
77
+ theme: 'light'
281
78
  }, (confirmed) => {
282
- if (confirmed) submitForm();
79
+ if (confirmed) saveData();
80
+ });
81
+
82
+ // Async loading
83
+ toast.conf('Submit form?', {
84
+ onConfirm: async ({ setLoading, close }) => {
85
+ setLoading(true);
86
+ await fetch('/api/submit', { method: 'POST' });
87
+ close();
88
+ toast.success('Submitted!');
89
+ }
283
90
  });
284
91
  ```
285
92
 
286
- #### โณ Loading States
287
- Handle async operations with built-in loading spinner:
93
+ ---
288
94
 
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
- });
95
+ ## Input Prompts
310
96
 
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
- }
97
+ ```javascript
98
+ // Simple
99
+ toast.input('What is your name?', (value) => {
100
+ toast.success(`Hello, ${value}!`);
318
101
  });
319
102
 
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
- }
103
+ // With validation
104
+ toast.input('Enter email', {
105
+ type: 'email',
106
+ placeholder: 'you@example.com',
107
+ validate: (val) => val.includes('@') || 'Invalid email',
108
+ onSubmit: async (email) => {
109
+ await subscribe(email);
110
+ toast.success('Subscribed!');
111
+ }
330
112
  });
331
113
  ```
332
114
 
333
- #### ๐ŸŽจ Custom Gradient Colors
334
- Create beautiful gradient backgrounds:
115
+ ---
335
116
 
336
- ```javascript
337
- // Orange gradient
338
- toast.conf('Custom styled!', {
339
- primaryColor: '#f97316',
340
- secondaryColor: '#ea580c',
341
- confirmText: 'Nice!'
342
- });
117
+ ## Custom Colors
343
118
 
344
- // Purple gradient
345
- toast.conf('Purple theme', {
346
- primaryColor: '#8b5cf6',
347
- secondaryColor: '#6366f1'
119
+ ```javascript
120
+ // Gradient toast
121
+ toast.custom('Custom styled!', {
122
+ primaryColor: '#8b5cf6',
123
+ secondaryColor: '#6366f1'
348
124
  });
349
125
 
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
126
+ // Gradient confirmation
127
+ toast.conf('Continue?', {
128
+ primaryColor: '#f97316',
129
+ secondaryColor: '#ea580c'
354
130
  });
355
131
  ```
356
132
 
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:
133
+ ---
359
134
 
360
- ```javascript
361
- // First call - shows confirmation
362
- toast.conf('First dialog');
135
+ ## API Reference
363
136
 
364
- // Second call - shakes existing dialog instead of opening new one
365
- toast.conf('Second dialog'); // Shakes first dialog!
366
- ```
137
+ ### Constructor
367
138
 
368
- ### ๐Ÿ†• Enhanced Features
369
-
370
- #### Custom SVG Icons
371
- Each toast type includes beautiful vector icons that scale perfectly:
372
- - **Success**: โœ“ Checkmark circle icon
373
- - **Error**: โœ— X circle icon
374
- - **Warning**: โš  Triangle warning icon
375
- - **Info**: โ„น Info circle icon
376
- - **Dark**: โ˜… Star icon
377
- - **Light**: โ˜€ Calendar icon
378
-
379
- #### Position-Aware Car Swipe Animations
380
- Toasts automatically exit with position-aware animations:
381
- - `carSwipeBottom` - For bottom positioned toasts (swipes down)
382
- - `carSwipeTop` - For top positioned toasts (swipes up)
383
- - `carSwipeLeft` - For left positioned toasts (swipes left)
384
- - `carSwipeRight` - For right positioned toasts (swipes right)
385
- - `carSwipeCenter` - For center positioned toasts (swipes down)
386
-
387
- #### POP UP Entrance Animation
388
- All toasts use the `airdropPop` entrance animation with:
389
- - 4-stage rotation and scaling effects
390
- - Professional iOS-inspired timing
391
- - Smooth cubic-bezier transitions
392
-
393
- ## ๐ŸŽจ Customization
394
-
395
- ### Global Configuration
396
139
  ```javascript
397
140
  const toast = new ToastifyPro({
398
- position: 'top-right',
399
- timeout: 4000,
400
- allowClose: true,
401
- maxLength: 150
141
+ position: 'bottom-center', // Position on screen
142
+ timeout: 3000, // Auto-dismiss (0 to disable)
143
+ allowClose: true, // Show close button
144
+ pauseOnHover: true, // Pause timeout on hover
145
+ maxToasts: 0, // Max visible (0 = unlimited)
146
+ newestOnTop: true // Stack order
402
147
  });
403
148
  ```
404
149
 
405
- ### Per-Toast Options
406
- ```javascript
407
- // Persistent toast (no auto-dismiss)
408
- toast.error('Critical error!', { timeout: 0 });
150
+ ### Positions
409
151
 
410
- // Quick notification
411
- toast.success('Saved!', { timeout: 1000 });
152
+ `top-left` ยท `top-center` ยท `top-right` ยท `bottom-left` ยท `bottom-center` ยท `bottom-right` ยท `center`
412
153
 
413
- // Toast with description - object format
414
- toast.info('Update Available', {
415
- description: 'Version 2.0 is now available with new features and improvements.',
416
- timeout: 8000,
417
- allowClose: true
418
- });
419
-
420
- // Toast with description - simple format
421
- toast.success('Welcome!', 'Thanks for joining our platform. Explore the features!');
422
-
423
- // Long message with close button
424
- toast.info('This is a very long message that might be truncated', {
425
- maxLength: 200,
426
- allowClose: true,
427
- timeout: 8000
428
- });
429
- ```
430
-
431
- ### Custom Styling
432
- You can override the default styles by adding your own CSS:
433
-
434
- ```css
435
- /* Custom positioning */
436
- .toastify-pro-container.bottom-center {
437
- bottom: 50px; /* Adjust distance from bottom */
438
- }
439
-
440
- /* Custom toast appearance */
441
- .toastify-pro {
442
- border-radius: 12px;
443
- font-family: 'Inter', sans-serif;
444
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
445
- }
446
-
447
- /* Custom success color */
448
- .toastify-pro.success {
449
- background: rgba(34, 197, 94, 0.95);
450
- }
154
+ ### Methods
451
155
 
452
- /* Custom close button */
453
- .toastify-pro .close-btn {
454
- font-weight: bold;
455
- font-size: 18px;
156
+ | Method | Description |
157
+ |--------|-------------|
158
+ | `success(msg, opts?)` | Green success toast |
159
+ | `error(msg, opts?)` | Red error toast |
160
+ | `warning(msg, opts?)` | Orange warning toast |
161
+ | `info(msg, opts?)` | Blue info toast |
162
+ | `dark(msg, opts?)` | Dark theme toast |
163
+ | `light(msg, opts?)` | Light theme toast |
164
+ | `custom(msg, opts?)` | Custom colors |
165
+ | `conf(msg, opts?, cb?)` | Confirmation dialog |
166
+ | `input(msg, opts?, cb?)` | Input prompt |
167
+ | `dismissAll(type?)` | Dismiss all toasts |
168
+
169
+ ### Toast Options
170
+
171
+ ```javascript
172
+ {
173
+ description: 'Secondary text',
174
+ timeout: 5000,
175
+ allowClose: true,
176
+ action: {
177
+ label: 'Undo',
178
+ onClick: ({ close }) => { /* ... */ }
179
+ }
456
180
  }
457
181
  ```
458
182
 
459
- ## ๐ŸŒŸ Framework Examples
183
+ ### Confirmation Options
460
184
 
461
- ### React Integration
462
- ```jsx
463
- import React, { useEffect } from 'react';
464
- import ToastifyPro from 'toastify-pro';
465
-
466
- function App() {
467
- const [toast, setToast] = React.useState(null);
468
-
469
- useEffect(() => {
470
- setToast(new ToastifyPro({
471
- position: 'top-right',
472
- timeout: 3000
473
- }));
474
- }, []);
475
-
476
- const handleSuccess = () => {
477
- toast?.success('React integration works perfectly!');
478
- };
479
-
480
- const handleError = () => {
481
- toast?.error('Something went wrong in React!');
482
- };
483
-
484
- const handleWithDescription = () => {
485
- toast?.info('New Feature!', 'Check out our latest React integration updates.');
486
- };
487
-
488
- // ๐Ÿ†• NEW: Confirmation dialog examples
489
- const handleDelete = () => {
490
- toast?.conf('Delete item?', 'This action cannot be undone.', (confirmed) => {
491
- if (confirmed) {
492
- // Perform deletion logic
493
- console.log('Deleting item...');
494
- toast?.success('Item deleted successfully!');
495
- } else {
496
- toast?.info('Delete cancelled');
497
- }
498
- });
499
- };
500
-
501
- const handleLogout = () => {
502
- toast?.conf('Sign out?', {
503
- description: 'You will need to sign in again to access your account.',
504
- confirmText: 'Sign Out',
505
- cancelText: 'Stay Signed In',
506
- theme: 'dark',
507
- position: 'center'
508
- }, (confirmed) => {
509
- if (confirmed) {
510
- // Logout logic
511
- window.location.href = '/login';
512
- }
513
- });
514
- };
515
-
516
- const handleIconDemo = () => {
517
- // Showcase different icons with descriptions
518
- toast?.success('โœ“ Success Icon', 'Beautiful checkmark with green theme');
519
- setTimeout(() => toast?.error('โœ— Error Icon', 'Clear error indication with red theme'), 500);
520
- setTimeout(() => toast?.warning('โš  Warning Icon', 'Alert triangle with orange theme'), 1000);
521
- setTimeout(() => toast?.info('โ„น Info Icon', 'Information circle with blue theme'), 1500);
522
- };
523
-
524
- return (
525
- <div>
526
- <button onClick={handleSuccess}>Show Success</button>
527
- <button onClick={handleError}>Show Error</button>
528
- <button onClick={handleWithDescription}>Show with Description</button>
529
- <button onClick={handleIconDemo}>Demo All Icons</button>
530
- <button onClick={handleDelete}>Delete with Confirmation</button>
531
- <button onClick={handleLogout}>Logout Confirmation</button>
532
- </div>
533
- );
185
+ ```javascript
186
+ {
187
+ description: 'Details text',
188
+ confirmText: 'Confirm',
189
+ cancelText: 'Cancel',
190
+ theme: 'dark', // 'dark' | 'light'
191
+ position: 'center',
192
+ primaryColor: '#6366f1', // Custom gradient
193
+ secondaryColor: '#8b5cf6',
194
+ onConfirm: (helpers) => {},
195
+ onCancel: () => {}
534
196
  }
535
-
536
- export default App;
537
197
  ```
538
198
 
539
- ### Vue.js Integration
540
- ```vue
541
- <template>
542
- <div>
543
- <button @click="showSuccess">Show Success</button>
544
- <button @click="showError">Show Error</button>
545
- <button @click="showCustom">Show Custom</button>
546
- <button @click="showConfirmation">Show Confirmation</button>
547
- <button @click="showDeleteConfirmation">Delete Item</button>
548
- </div>
549
- </template>
550
-
551
- <script>
552
- import ToastifyPro from 'toastify-pro';
553
-
554
- export default {
555
- name: 'ToastExample',
556
- data() {
557
- return {
558
- toast: null
559
- };
560
- },
561
- mounted() {
562
- this.toast = new ToastifyPro({
563
- position: 'bottom-right',
564
- timeout: 4000
565
- });
566
- },
567
- methods: {
568
- showSuccess() {
569
- this.toast.success('Vue.js integration successful!');
570
- },
571
- showError() {
572
- this.toast.error('Error in Vue component!');
573
- },
574
- showCustom() {
575
- this.toast.show('Custom Vue message', 'warning', {
576
- timeout: 6000,
577
- allowClose: true
578
- });
579
- },
580
- // ๐Ÿ†• NEW: Confirmation methods
581
- showConfirmation() {
582
- this.toast.conf('Save changes?', (confirmed) => {
583
- if (confirmed) {
584
- this.saveData();
585
- } else {
586
- this.toast.info('Changes not saved');
587
- }
588
- });
589
- },
590
- showDeleteConfirmation() {
591
- this.toast.conf('Delete this item?', {
592
- description: 'This action cannot be undone and will remove all associated data.',
593
- confirmText: 'Delete',
594
- cancelText: 'Keep',
595
- theme: 'dark',
596
- position: 'center'
597
- }, (confirmed) => {
598
- if (confirmed) {
599
- this.deleteItem();
600
- this.toast.success('Item deleted successfully!');
601
- }
602
- });
603
- },
604
- saveData() {
605
- // Save logic here
606
- this.toast.success('Data saved successfully!');
607
- },
608
- deleteItem() {
609
- // Delete logic here
610
- console.log('Item deleted');
611
- }
612
- }
613
- };
614
- </script>
615
- ```
616
-
617
- ### Angular Integration
618
- ```typescript
619
- import { Component, OnInit } from '@angular/core';
620
- import ToastifyPro from 'toastify-pro';
199
+ ### Input Options
621
200
 
622
- @Component({
623
- selector: 'app-toast-example',
624
- template: `
625
- <button (click)="showSuccess()">Show Success</button>
626
- <button (click)="showError()">Show Error</button>
627
- <button (click)="showInfo()">Show Info</button>
628
- <button (click)="showConfirmation()">Show Confirmation</button>
629
- <button (click)="showLogoutConfirmation()">Logout</button>
630
- `
631
- })
632
- export class ToastExampleComponent implements OnInit {
633
- private toast: ToastifyPro;
634
-
635
- ngOnInit() {
636
- this.toast = new ToastifyPro({
637
- position: 'top-center',
638
- timeout: 3500,
639
- allowClose: true
640
- });
641
- }
642
-
643
- showSuccess() {
644
- this.toast.success('Angular integration works!');
645
- }
646
-
647
- showError() {
648
- this.toast.error('Error in Angular component!');
649
- }
650
-
651
- showInfo() {
652
- this.toast.info('Information from Angular', {
653
- timeout: 5000
654
- });
655
- }
656
-
657
- // ๐Ÿ†• NEW: Confirmation methods
658
- showConfirmation() {
659
- this.toast.conf('Save document?', 'All changes will be saved permanently.', (confirmed: boolean) => {
660
- if (confirmed) {
661
- this.saveDocument();
662
- } else {
663
- this.toast.info('Save cancelled');
664
- }
665
- });
666
- }
667
-
668
- showLogoutConfirmation() {
669
- this.toast.conf('Sign out?', {
670
- description: 'You will be logged out of your account.',
671
- confirmText: 'Sign Out',
672
- cancelText: 'Cancel',
673
- theme: 'light',
674
- position: 'center'
675
- }, (confirmed: boolean) => {
676
- if (confirmed) {
677
- this.logout();
678
- }
679
- });
680
- }
681
-
682
- private saveDocument() {
683
- // Save logic
684
- this.toast.success('Document saved successfully!');
685
- }
686
-
687
- private logout() {
688
- // Logout logic
689
- this.toast.success('Logged out successfully!');
690
- }
691
- }
692
- ```
693
-
694
- ### Vanilla JavaScript Examples
695
201
  ```javascript
696
- // Initialize toast
697
- const toast = new ToastifyPro({
698
- position: 'top-left',
699
- timeout: 3000,
700
- allowClose: true
701
- });
702
-
703
- // Form submission example with confirmation
704
- document.getElementById('submitForm').addEventListener('click', async function() {
705
- toast.conf('Submit form?', 'Your data will be sent to the server.', async (confirmed) => {
706
- if (confirmed) {
707
- try {
708
- // Simulate API call
709
- const response = await fetch('/api/submit', { method: 'POST' });
710
-
711
- if (response.ok) {
712
- toast.success('Form submitted successfully!', 'Your data has been processed and saved.');
713
- } else {
714
- toast.error('Failed to submit form', 'Please check your inputs and try again.');
715
- }
716
- } catch (error) {
717
- toast.error('Network error occurred', 'Check your connection and retry.');
718
- }
719
- }
720
- });
721
- });
722
-
723
- // Delete confirmation example
724
- function deleteItem(itemId) {
725
- toast.conf('Delete this item?', {
726
- description: 'This action cannot be undone and will permanently remove all associated data.',
727
- confirmText: 'Delete',
728
- cancelText: 'Keep',
729
- theme: 'dark',
730
- position: 'center'
731
- }, (confirmed) => {
732
- if (confirmed) {
733
- // Perform deletion
734
- console.log('Deleting item:', itemId);
735
- toast.success('Item deleted!', 'The item has been permanently removed.');
736
- } else {
737
- toast.info('Delete cancelled', 'Your item is safe.');
738
- }
739
- });
740
- }
741
-
742
- // File upload with confirmation and progress
743
- function handleFileUpload() {
744
- toast.conf('Upload file?', 'The file will be uploaded to your account.', (confirmed) => {
745
- if (confirmed) {
746
- toast.info('Uploading...', 'Please wait while we process your file.');
747
-
748
- // Simulate upload completion
749
- setTimeout(() => {
750
- toast.success('Upload complete!', 'Your file has been uploaded successfully.');
751
- }, 3000);
752
- }
753
- });
754
- }
755
-
756
- // Logout confirmation
757
- function logout() {
758
- toast.conf('Sign out?', {
759
- description: 'You will need to sign in again to access your account.',
760
- confirmText: 'Sign Out',
761
- cancelText: 'Stay Signed In',
762
- theme: 'light'
763
- }, (confirmed) => {
764
- if (confirmed) {
765
- window.location.href = '/login';
766
- }
767
- });
768
- }
769
-
770
- // Multiple toast types with descriptions
771
- function showAllTypes() {
772
- toast.success('Success!', 'Operation completed successfully');
773
- setTimeout(() => toast.error('Error!', 'Something went wrong'), 500);
774
- setTimeout(() => toast.warning('Warning!', 'Please review this action'), 1000);
775
- setTimeout(() => toast.info('Info', 'Here is some helpful information'), 1500);
776
- setTimeout(() => toast.dark('Dark Mode', 'Elegant dark notification'), 2000);
777
- setTimeout(() => toast.light('Light Mode', 'Clean light notification'), 2500);
778
- }
779
-
780
- // Showcase new enhanced features including confirmations
781
- function demoEnhancedFeatures() {
782
- // SVG Icons demo
783
- toast.success('โœ“ Beautiful Icons', 'Each type has its own vector icon that scales perfectly');
784
-
785
- // Car swipe animation (automatic based on position)
786
- setTimeout(() => {
787
- toast.info('๐Ÿš— Car Swipe Exit', 'Watch the position-aware exit animation');
788
- }, 1000);
789
-
790
- // Apple AirDrop entrance (automatic)
791
- setTimeout(() => {
792
- toast.warning('๐Ÿ“ฑ AirDrop Style', 'iOS-inspired entrance with rotation effects');
793
- }, 2000);
794
-
795
- // Glassmorphism design
796
- setTimeout(() => {
797
- toast.dark('โœจ Glassmorphism', 'Modern backdrop blur with translucent design');
798
- }, 3000);
799
-
800
- // ๐Ÿ†• Confirmation dialog demo
801
- setTimeout(() => {
802
- toast.conf('Try confirmation?', 'Experience the new interactive dialog feature.', (confirmed) => {
803
- if (confirmed) {
804
- toast.success('๐ŸŽ‰ Confirmation works!', 'You can now create interactive dialogs easily.');
805
- } else {
806
- toast.info('No problem!', 'Confirmation dialogs are optional.');
807
- }
808
- });
809
- }, 4000);
810
- }
811
-
812
- // Advanced confirmation examples
813
- function advancedConfirmationExamples() {
814
- // Settings reset confirmation
815
- toast.conf('Reset all settings?', {
816
- description: 'This will restore all settings to their default values.',
817
- confirmText: 'Reset',
818
- cancelText: 'Cancel',
819
- theme: 'dark',
820
- position: 'center'
821
- }, (confirmed) => {
822
- if (confirmed) {
823
- // Reset settings logic
824
- toast.success('Settings reset!', 'All settings have been restored to defaults.');
825
- }
826
- });
827
- }
828
-
829
- // Advanced usage with all new features
830
- function advancedExample() {
831
- // Progress indication with confirmation first
832
- toast.conf('Start processing?', {
833
- description: 'This will upload your file to the server and may take a few minutes.',
834
- confirmText: 'Start',
835
- cancelText: 'Later',
836
- theme: 'light'
837
- }, (confirmed) => {
838
- if (confirmed) {
839
- toast.info('Processing...', {
840
- description: 'Please wait while we upload your file to the server',
841
- timeout: 0, // No auto-dismiss
842
- allowClose: true
843
- });
844
-
845
- // Simulate progress completion
846
- setTimeout(() => {
847
- toast.success('Upload Complete!', {
848
- description: 'Your file has been uploaded successfully with all metadata',
849
- timeout: 5000
850
- });
851
- }, 3000);
852
- }
853
- });
202
+ {
203
+ description: 'Help text',
204
+ placeholder: 'Enter value...',
205
+ submitText: 'Submit',
206
+ cancelText: 'Cancel',
207
+ type: 'text', // 'text' | 'email' | 'password' | 'number' | 'url'
208
+ defaultValue: '',
209
+ required: true,
210
+ validate: (val) => true, // Return true or error string
211
+ theme: 'dark',
212
+ primaryColor: '#6366f1',
213
+ onSubmit: (value, helpers) => {},
214
+ onCancel: () => {}
854
215
  }
855
216
  ```
856
217
 
857
- ## ๐Ÿ“ฑ Browser Support
858
-
859
- | Browser | Version |
860
- |---------|---------|
861
- | Chrome | โ‰ฅ 60 |
862
- | Firefox | โ‰ฅ 55 |
863
- | Safari | โ‰ฅ 12 |
864
- | Edge | โ‰ฅ 79 |
865
-
866
- ## โš™๏ธ Configuration Options
867
-
868
- | Option | Type | Default | Description |
869
- |--------|------|---------|-------------|
870
- | `position` | string | `'bottom-center'` | Toast container position |
871
- | `timeout` | number | `3000` | Auto-dismiss time (0 = no auto-dismiss) |
872
- | `allowClose` | boolean | `true` | Show close button |
873
- | `maxLength` | number | `100` | Maximum message length |
874
- | `description` | string | `undefined` | Optional secondary text for detailed information |
875
-
876
- ## ๐ŸŽจ Available Themes
877
-
878
- | Theme | Background | Text Color | Icon | Use Case |
879
- |-------|------------|------------|------|----------|
880
- | `success` | Green | White | โœ“ Checkmark | Success messages |
881
- | `error` | Red | White | โœ— X Circle | Error messages |
882
- | `warning` | Orange | White | โš  Triangle | Warning messages |
883
- | `info` | Blue | White | โ„น Info Circle | Information messages |
884
- | `dark` | Dark Gray | White | โ˜… Star | General purpose |
885
- | `light` | Light Gray | Black | โ˜€ Calendar | Light theme compatibility |
886
-
887
- ### ๐Ÿ†• Enhanced Visual Features
888
-
889
- - **Custom SVG Icons**: Each theme includes beautiful vector icons that are crisp at any resolution
890
- - **Glassmorphism Design**: Modern backdrop-filter blur effects with translucent backgrounds
891
- - **Car Swipe Animations**: Position-aware exit animations that swipe toasts in natural directions
892
- - **POP UP Entrance**: Professional iOS-inspired entrance with 4-stage rotation and scaling
893
- - **Progress Bar**: Animated progress bar with shimmer effects showing remaining time
894
- - **Responsive Design**: Mobile-first approach that adapts to all screen sizes
895
-
896
- ## ๐Ÿ“„ License
897
-
898
- MIT ยฉ [Abhishek Potter](https://github.com/abhipotter)
899
-
900
- ## ๐Ÿค Contributing
901
-
902
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
903
-
904
- 1. Fork the repository
905
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
906
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
907
- 4. Push to the branch (`git push origin feature/amazing-feature`)
908
- 5. Open a Pull Request
909
-
910
- ## ๐Ÿ“ง Support
911
-
912
- - ๐Ÿ› **Bug Reports**: [GitHub Issues](https://github.com/abhipotter/toastify-pro/issues)
913
- - ๐Ÿ’ฌ **Discussions**: [GitHub Discussions](https://github.com/abhipotter/toastify-pro/discussions)
914
- - ๐Ÿ“ง **Email**: [abhishekpotter77@gmail.com](mailto:abhishekpotter77@gmail.com)
218
+ ---
915
219
 
916
- ## ๐Ÿ™ Acknowledgments
220
+ ## Browser Support
917
221
 
918
- - Inspired by modern toast libraries
919
- - Built with โค๏ธ by the open-source community
920
- - Special thanks to all contributors
222
+ Chrome, Firefox, Safari, Edge (all modern versions)
921
223
 
922
224
  ---
923
225
 
924
- <div align="center">
925
-
926
- **Made with โค๏ธ by [Abhishek Potter](https://github.com/abhipotter)**
927
-
928
- If you found this project helpful, please consider giving it a โญ๏ธ!
226
+ ## License
929
227
 
930
- </div>
228
+ MIT ยฉ [Abhishek Potter](https://github.com/abhipotter)