@dilipod/ui 0.2.12 → 0.2.13
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/dist/components/use-toast.d.ts.map +1 -1
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/dialog.tsx +1 -1
- package/src/components/dropdown-menu.tsx +2 -2
- package/src/components/sheet.tsx +2 -2
- package/src/components/toast.tsx +1 -1
- package/src/components/use-toast.tsx +21 -1
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ const DialogContent = React.forwardRef<
|
|
|
38
38
|
<DialogPrimitive.Content
|
|
39
39
|
ref={ref}
|
|
40
40
|
className={cn(
|
|
41
|
-
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-white p-6 shadow-lg duration-150 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-[0.
|
|
41
|
+
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-white p-6 shadow-lg duration-150 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-[0.98] data-[state=open]:zoom-in-[0.98] sm:rounded-lg',
|
|
42
42
|
className
|
|
43
43
|
)}
|
|
44
44
|
{...props}
|
|
@@ -47,7 +47,7 @@ const DropdownMenuSubContent = React.forwardRef<
|
|
|
47
47
|
<DropdownMenuPrimitive.SubContent
|
|
48
48
|
ref={ref}
|
|
49
49
|
className={cn(
|
|
50
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-
|
|
50
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 origin-[--radix-dropdown-menu-content-transform-origin]",
|
|
51
51
|
className
|
|
52
52
|
)}
|
|
53
53
|
{...props}
|
|
@@ -65,7 +65,7 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
65
65
|
ref={ref}
|
|
66
66
|
sideOffset={sideOffset}
|
|
67
67
|
className={cn(
|
|
68
|
-
"z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-sm border bg-popover p-1.5 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-
|
|
68
|
+
"z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-sm border bg-popover p-1.5 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 origin-[--radix-dropdown-menu-content-transform-origin]",
|
|
69
69
|
className
|
|
70
70
|
)}
|
|
71
71
|
{...props}
|
package/src/components/sheet.tsx
CHANGED
|
@@ -23,7 +23,7 @@ const SheetOverlay = React.forwardRef<
|
|
|
23
23
|
// @ts-ignore - Radix Dialog Overlay accepts className at runtime
|
|
24
24
|
<SheetPrimitive.Overlay
|
|
25
25
|
className={cn(
|
|
26
|
-
'fixed inset-0 z-50 bg-black/
|
|
26
|
+
'fixed inset-0 z-50 bg-black/60 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-150',
|
|
27
27
|
className
|
|
28
28
|
)}
|
|
29
29
|
{...props}
|
|
@@ -33,7 +33,7 @@ const SheetOverlay = React.forwardRef<
|
|
|
33
33
|
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
|
|
34
34
|
|
|
35
35
|
const sheetVariants = cva(
|
|
36
|
-
'fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out
|
|
36
|
+
'fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out duration-150',
|
|
37
37
|
{
|
|
38
38
|
variants: {
|
|
39
39
|
side: {
|
package/src/components/toast.tsx
CHANGED
|
@@ -24,7 +24,7 @@ const ToastViewport = React.forwardRef<
|
|
|
24
24
|
ToastViewport.displayName = ToastPrimitives.Viewport.displayName
|
|
25
25
|
|
|
26
26
|
const toastVariants = cva(
|
|
27
|
-
'group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-sm border-none p-4 transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-
|
|
27
|
+
'group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-sm border-none p-4 transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-[0.98] data-[state=open]:zoom-in-[0.98] duration-150',
|
|
28
28
|
{
|
|
29
29
|
variants: {
|
|
30
30
|
variant: {
|
|
@@ -4,7 +4,8 @@ import * as React from 'react'
|
|
|
4
4
|
import type { ToastActionElement, ToastProps } from './toast'
|
|
5
5
|
|
|
6
6
|
const TOAST_LIMIT = 5
|
|
7
|
-
const TOAST_REMOVE_DELAY =
|
|
7
|
+
const TOAST_REMOVE_DELAY = 1000
|
|
8
|
+
const TOAST_AUTO_DISMISS_DELAY = 4000
|
|
8
9
|
|
|
9
10
|
type ToasterToast = ToastProps & {
|
|
10
11
|
id: string
|
|
@@ -52,6 +53,7 @@ interface State {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
|
|
56
|
+
const autoDismissTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
|
|
55
57
|
|
|
56
58
|
const addToRemoveQueue = (toastId: string) => {
|
|
57
59
|
if (toastTimeouts.has(toastId)) {
|
|
@@ -69,9 +71,27 @@ const addToRemoveQueue = (toastId: string) => {
|
|
|
69
71
|
toastTimeouts.set(toastId, timeout)
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
const scheduleAutoDismiss = (toastId: string) => {
|
|
75
|
+
if (autoDismissTimeouts.has(toastId)) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const timeout = setTimeout(() => {
|
|
80
|
+
autoDismissTimeouts.delete(toastId)
|
|
81
|
+
dispatch({
|
|
82
|
+
type: 'DISMISS_TOAST',
|
|
83
|
+
toastId: toastId,
|
|
84
|
+
})
|
|
85
|
+
}, TOAST_AUTO_DISMISS_DELAY)
|
|
86
|
+
|
|
87
|
+
autoDismissTimeouts.set(toastId, timeout)
|
|
88
|
+
}
|
|
89
|
+
|
|
72
90
|
export const reducer = (state: State, action: Action): State => {
|
|
73
91
|
switch (action.type) {
|
|
74
92
|
case 'ADD_TOAST':
|
|
93
|
+
// Schedule auto-dismiss for the new toast
|
|
94
|
+
scheduleAutoDismiss(action.toast.id)
|
|
75
95
|
return {
|
|
76
96
|
...state,
|
|
77
97
|
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|