daisy-ui-kit 5.2.2 → 5.2.3

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.
@@ -29,6 +29,9 @@ export interface Toast {
29
29
  progress?: number // 0-1 for progress bar
30
30
  promiseId?: string // for async/promise support
31
31
  ariaLive?: 'polite' | 'assertive' // accessibility
32
+ intervalId?: number
33
+ originalDuration?: number
34
+ startTime?: number
32
35
  [key: string]: any
33
36
  }
34
37
 
@@ -118,7 +121,7 @@ export interface UseToastOptions {
118
121
  * addToast({ message: 'Hi' }) // will use defaults
119
122
  * // In UI: <Toast name="admin" />
120
123
  */
121
- function normalizeToast(toast: any): Toast & { countdown: number; originalDuration: number; intervalId?: number } {
124
+ function normalizeToast(toast: any): Toast {
122
125
  if (toast.originalDuration == null) {
123
126
  toast.originalDuration = toast.duration ?? 0
124
127
  }
@@ -128,7 +131,7 @@ function normalizeToast(toast: any): Toast & { countdown: number; originalDurati
128
131
  if (typeof toast.intervalId === 'undefined') {
129
132
  toast.intervalId = undefined
130
133
  }
131
- return toast as Toast & { countdown: number; originalDuration: number; intervalId?: number }
134
+ return toast as Toast
132
135
  }
133
136
 
134
137
  export function useToast(options?: UseToastOptions) {
@@ -187,7 +190,7 @@ export function useToast(options?: UseToastOptions) {
187
190
  const idx = channel.value.toasts.findIndex(t => t.id === id)
188
191
  if (idx !== -1) {
189
192
  // Defensive: clear countdown timer if present
190
- const toast = channel.value.toasts[idx] as Toast & { intervalId?: number }
193
+ const toast = channel.value.toasts[idx]!
191
194
  if (toast.intervalId) {
192
195
  clearInterval(toast.intervalId)
193
196
  }
@@ -311,10 +314,9 @@ export function useToast(options?: UseToastOptions) {
311
314
  }
312
315
  }
313
316
 
314
- function startToastTimer(
315
- toast: Toast & { countdown: number; originalDuration: number; intervalId?: number; startTime?: number },
316
- ) {
317
- if (toast.originalDuration > 0) {
317
+ function startToastTimer(toast: Toast) {
318
+ const duration = toast.originalDuration ?? 0
319
+ if (duration > 0) {
318
320
  if (toast.intervalId) {
319
321
  clearInterval(toast.intervalId)
320
322
  }
@@ -323,8 +325,8 @@ export function useToast(options?: UseToastOptions) {
323
325
 
324
326
  toast.intervalId = setInterval(() => {
325
327
  const elapsed = Date.now() - (toast.startTime ?? start)
326
- toast.countdown = Math.max(0, toast.originalDuration - elapsed)
327
- toast.progress = Math.max(0, toast.countdown / toast.originalDuration)
328
+ toast.countdown = Math.max(0, duration - elapsed)
329
+ toast.progress = Math.max(0, toast.countdown / duration)
328
330
  if (toast.countdown <= 0) {
329
331
  clearInterval(toast.intervalId)
330
332
  removeToast(toast.id)
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "5.2.2",
7
+ "version": "5.2.3",
8
8
  "packageManager": "pnpm@10.10.0",
9
9
  "author": "feathers.dev",
10
10
  "exports": {