goey-toast 0.2.0 → 0.2.2

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
@@ -19,6 +19,15 @@
19
19
  - Hover pause: hovering an expanded toast pauses the dismiss timer
20
20
  - Hover re-expand: hovering a collapsed pill re-expands the toast
21
21
  - Pre-dismiss collapse animation
22
+ - In-place toast updates via `goeyToast.update()`
23
+ - Dismiss by type filter: `goeyToast.dismiss({ type: 'error' })`
24
+ - Dark mode and RTL layout support
25
+ - Animation presets: smooth, bouncy, subtle, snappy
26
+ - Timestamp display on expanded toasts
27
+ - Countdown progress bar with hover-pause and re-expand
28
+ - Keyboard dismiss (Escape) and swipe-to-dismiss on mobile
29
+ - Toast queue with configurable overflow strategy
30
+ - Dismiss callbacks: `onDismiss` and `onAutoClose`
22
31
 
23
32
  ## Installation
24
33
 
@@ -87,7 +96,54 @@ goeyToast.error(title, options?) // red
87
96
  goeyToast.warning(title, options?) // yellow
88
97
  goeyToast.info(title, options?) // blue
89
98
  goeyToast.promise(promise, data) // loading -> success/error
90
- goeyToast.dismiss(toastId?) // dismiss one or all toasts
99
+ goeyToast.update(id, options) // update an existing toast in-place
100
+ goeyToast.dismiss(idOrFilter?) // dismiss one, by type, or all toasts
101
+ ```
102
+
103
+ #### `goeyToast.update(id, options)`
104
+
105
+ Updates an existing toast in-place without removing and re-creating it.
106
+
107
+ ```tsx
108
+ const id = goeyToast('Uploading...', {
109
+ icon: <SpinnerIcon />,
110
+ })
111
+
112
+ // Later, update the toast
113
+ goeyToast.update(id, {
114
+ title: 'Upload complete',
115
+ type: 'success',
116
+ description: '3 files uploaded.',
117
+ icon: null, // clears the custom icon
118
+ })
119
+ ```
120
+
121
+ **`GoeyToastUpdateOptions`:**
122
+
123
+ | Option | Type | Description |
124
+ | ------------- | ----------------- | ----------------------------- |
125
+ | `title` | `string` | New title text |
126
+ | `description` | `ReactNode` | New body content |
127
+ | `type` | `GoeyToastType` | Change the toast type/color |
128
+ | `action` | `GoeyToastAction` | New action button |
129
+ | `icon` | `ReactNode \| null` | Custom icon (pass `null` to clear) |
130
+
131
+ #### `goeyToast.dismiss(idOrFilter?)`
132
+
133
+ Dismiss a single toast by ID, all toasts of a given type, or all toasts at once.
134
+
135
+ ```ts
136
+ // Dismiss a specific toast
137
+ goeyToast.dismiss(toastId)
138
+
139
+ // Dismiss all error toasts
140
+ goeyToast.dismiss({ type: 'error' })
141
+
142
+ // Dismiss multiple types
143
+ goeyToast.dismiss({ type: ['error', 'warning'] })
144
+
145
+ // Dismiss all toasts
146
+ goeyToast.dismiss()
91
147
  ```
92
148
 
93
149
  ### `GoeyToastOptions`
@@ -108,6 +164,10 @@ Options passed as the second argument to `goeyToast()` and type-specific methods
108
164
  | `timing` | `GoeyToastTimings` | Animation timing overrides |
109
165
  | `spring` | `boolean` | Enable spring/bounce animations (default `true`) |
110
166
  | `bounce` | `number` | Spring intensity from `0.05` (subtle) to `0.8` (dramatic), default `0.4` |
167
+ | `showProgress`| `boolean` | Show countdown progress bar |
168
+ | `onDismiss` | `(id) => void` | Called when toast is dismissed (any reason) |
169
+ | `onAutoClose` | `(id) => void` | Called only on timer-based auto-dismiss |
170
+ | `preset` | `AnimationPresetName`| Animation preset (`'smooth'`, `'bouncy'`, `'subtle'`, `'snappy'`) |
111
171
 
112
172
  ### `GoeyToastAction`
113
173
 
@@ -154,6 +214,13 @@ Props for the `<GoeyToaster />` component.
154
214
  | `toastOptions` | `Partial<ExternalToast>` | -- | Default options passed to Sonner |
155
215
  | `spring` | `boolean` | `true` | Enable spring/bounce animations globally |
156
216
  | `bounce` | `number` | `0.4` | Spring intensity: `0.05` (subtle) to `0.8` (dramatic) |
217
+ | `preset` | `AnimationPresetName` | -- | Animation preset for all toasts |
218
+ | `closeOnEscape` | `boolean` | `true` | Dismiss most recent toast on Escape key |
219
+ | `showProgress` | `boolean` | `false` | Show countdown progress bar on all toasts |
220
+ | `maxQueue` | `number` | `Infinity` | Maximum queued toasts |
221
+ | `queueOverflow` | `'drop-oldest' \| 'drop-newest'` | `'drop-oldest'` | Queue overflow strategy |
222
+ | `dir` | `'ltr' \| 'rtl'` | `'ltr'` | Layout direction |
223
+ | `swipeToDismiss` | `boolean` | `true` | Enable swipe-to-dismiss on mobile |
157
224
 
158
225
  ### `GoeyPromiseData<T>`
159
226
 
@@ -173,6 +240,8 @@ Configuration for `goeyToast.promise()`.
173
240
  | `timing` | `GoeyToastTimings` | No | Animation timing overrides |
174
241
  | `spring` | `boolean` | No | Enable spring/bounce animations (default `true`) |
175
242
  | `bounce` | `number` | No | Spring intensity: `0.05` (subtle) to `0.8` (dramatic), default `0.4` |
243
+ | `onDismiss` | `(id: string \| number) => void` | No | Called when toast is dismissed (any reason) |
244
+ | `onAutoClose` | `(id: string \| number) => void` | No | Called only on timer-based auto-dismiss |
176
245
 
177
246
  **`description` sub-fields:**
178
247
 
@@ -311,6 +380,48 @@ goeyToast.success('Saved', { bounce: 0.8 })
311
380
 
312
381
  The `bounce` value (0.05 to 0.8) controls spring stiffness, damping, and squish magnitude together so you get a consistent feel from one number.
313
382
 
383
+ ### Dark Mode
384
+
385
+ ```tsx
386
+ <GoeyToaster theme="dark" />
387
+ ```
388
+
389
+ ### RTL Support
390
+
391
+ ```tsx
392
+ <GoeyToaster dir="rtl" />
393
+ ```
394
+
395
+ ### Animation Presets
396
+
397
+ Four built-in presets: `smooth`, `bouncy`, `subtle`, `snappy`. Apply per-toast or globally:
398
+
399
+ ```tsx
400
+ goeyToast.success('Saved', { preset: 'bouncy' })
401
+
402
+ // Or globally
403
+ <GoeyToaster preset="smooth" />
404
+ ```
405
+
406
+ ### Progress Bar
407
+
408
+ Show a countdown progress bar on toasts:
409
+
410
+ ```tsx
411
+ goeyToast.success('Saved', { showProgress: true })
412
+
413
+ // Or enable globally
414
+ <GoeyToaster showProgress />
415
+ ```
416
+
417
+ ### Keyboard Shortcuts
418
+
419
+ Press **Escape** to dismiss the most recent toast. Enabled by default; disable with `closeOnEscape={false}`.
420
+
421
+ ### Swipe to Dismiss
422
+
423
+ On mobile, swipe toasts to dismiss them. Enabled by default; disable with `swipeToDismiss={false}`.
424
+
314
425
  ## Exports
315
426
 
316
427
  ```ts
@@ -320,6 +431,9 @@ export { GoeyToaster } from 'goey-toast'
320
431
  // Toast function
321
432
  export { goeyToast } from 'goey-toast'
322
433
 
434
+ // Animation presets
435
+ export { animationPresets } from 'goey-toast'
436
+
323
437
  // Types
324
438
  export type {
325
439
  GoeyToastOptions,
@@ -328,6 +442,10 @@ export type {
328
442
  GoeyToastAction,
329
443
  GoeyToastClassNames,
330
444
  GoeyToastTimings,
445
+ GoeyToastUpdateOptions,
446
+ DismissFilter,
447
+ AnimationPreset,
448
+ AnimationPresetName,
331
449
  } from 'goey-toast'
332
450
  ```
333
451