@moontra/moonui-pro 2.20.1 → 2.20.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.
- package/dist/index.d.ts +691 -261
- package/dist/index.mjs +7418 -4934
- package/package.json +11 -5
- package/plugin/index.d.ts +86 -0
- package/plugin/index.js +308 -0
- package/scripts/postbuild.js +27 -0
- package/scripts/postinstall.js +176 -23
- package/src/__tests__/use-intersection-observer.test.tsx +0 -216
- package/src/__tests__/use-local-storage.test.tsx +0 -174
- package/src/__tests__/use-pro-access.test.tsx +0 -183
- package/src/components/advanced-chart/advanced-chart.test.tsx +0 -281
- package/src/components/advanced-chart/index.tsx +0 -1242
- package/src/components/advanced-forms/index.tsx +0 -426
- package/src/components/animated-button/index.tsx +0 -385
- package/src/components/calendar/event-dialog.tsx +0 -372
- package/src/components/calendar/index.tsx +0 -1073
- package/src/components/calendar-pro/index.tsx +0 -1697
- package/src/components/color-picker/index.tsx +0 -432
- package/src/components/credit-card-input/index.tsx +0 -406
- package/src/components/dashboard/dashboard-grid.tsx +0 -462
- package/src/components/dashboard/demo.tsx +0 -425
- package/src/components/dashboard/index.tsx +0 -1046
- package/src/components/dashboard/time-range-picker.tsx +0 -336
- package/src/components/dashboard/types.ts +0 -222
- package/src/components/dashboard/widgets/activity-feed.tsx +0 -344
- package/src/components/dashboard/widgets/chart-widget.tsx +0 -418
- package/src/components/dashboard/widgets/metric-card.tsx +0 -343
- package/src/components/data-table/data-table-bulk-actions.tsx +0 -204
- package/src/components/data-table/data-table-column-toggle.tsx +0 -169
- package/src/components/data-table/data-table-export.ts +0 -156
- package/src/components/data-table/data-table-filter-drawer.tsx +0 -448
- package/src/components/data-table/data-table.test.tsx +0 -187
- package/src/components/data-table/index.tsx +0 -845
- package/src/components/draggable-list/index.tsx +0 -100
- package/src/components/enhanced/badge.tsx +0 -191
- package/src/components/enhanced/button.tsx +0 -362
- package/src/components/enhanced/card.tsx +0 -266
- package/src/components/enhanced/dialog.tsx +0 -246
- package/src/components/enhanced/index.ts +0 -4
- package/src/components/error-boundary/index.tsx +0 -109
- package/src/components/file-upload/file-upload.test.tsx +0 -243
- package/src/components/file-upload/index.tsx +0 -1660
- package/src/components/floating-action-button/index.tsx +0 -206
- package/src/components/form-wizard/form-wizard-context.tsx +0 -307
- package/src/components/form-wizard/form-wizard-navigation.tsx +0 -118
- package/src/components/form-wizard/form-wizard-progress.tsx +0 -298
- package/src/components/form-wizard/form-wizard-step.tsx +0 -111
- package/src/components/form-wizard/index.tsx +0 -102
- package/src/components/form-wizard/types.ts +0 -76
- package/src/components/gesture-drawer/index.tsx +0 -551
- package/src/components/github-stars/github-api.ts +0 -426
- package/src/components/github-stars/hooks.ts +0 -516
- package/src/components/github-stars/index.tsx +0 -375
- package/src/components/github-stars/types.ts +0 -148
- package/src/components/github-stars/variants.tsx +0 -513
- package/src/components/health-check/index.tsx +0 -439
- package/src/components/hover-card-3d/index.tsx +0 -530
- package/src/components/index.ts +0 -128
- package/src/components/internal/index.ts +0 -78
- package/src/components/kanban/add-card-modal.tsx +0 -502
- package/src/components/kanban/card-detail-modal.tsx +0 -761
- package/src/components/kanban/index.ts +0 -13
- package/src/components/kanban/kanban.tsx +0 -1684
- package/src/components/kanban/types.ts +0 -168
- package/src/components/lazy-component/index.tsx +0 -823
- package/src/components/license-error/index.tsx +0 -29
- package/src/components/magnetic-button/index.tsx +0 -167
- package/src/components/memory-efficient-data/index.tsx +0 -1016
- package/src/components/moonui-quiz-form/index.tsx +0 -817
- package/src/components/optimized-image/index.tsx +0 -425
- package/src/components/performance-debugger/index.tsx +0 -589
- package/src/components/performance-monitor/index.tsx +0 -794
- package/src/components/phone-number-input/index.tsx +0 -338
- package/src/components/pinch-zoom/index.tsx +0 -566
- package/src/components/quiz-form/index.tsx +0 -479
- package/src/components/rich-text-editor/index-old-backup.tsx +0 -437
- package/src/components/rich-text-editor/index.tsx +0 -2324
- package/src/components/rich-text-editor/slash-commands-extension.ts +0 -220
- package/src/components/rich-text-editor/slash-commands.css +0 -35
- package/src/components/rich-text-editor/table-styles.css +0 -65
- package/src/components/sidebar/index.tsx +0 -865
- package/src/components/spotlight-card/index.tsx +0 -191
- package/src/components/swipeable-card/index.tsx +0 -100
- package/src/components/timeline/index.tsx +0 -1148
- package/src/components/ui/accordion.tsx +0 -73
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/alert.tsx +0 -141
- package/src/components/ui/aspect-ratio.tsx +0 -245
- package/src/components/ui/avatar.tsx +0 -153
- package/src/components/ui/badge.tsx +0 -228
- package/src/components/ui/breadcrumb.tsx +0 -214
- package/src/components/ui/button.tsx +0 -222
- package/src/components/ui/calendar.tsx +0 -387
- package/src/components/ui/card.tsx +0 -214
- package/src/components/ui/checkbox.tsx +0 -259
- package/src/components/ui/collapsible.tsx +0 -135
- package/src/components/ui/color-picker.tsx +0 -97
- package/src/components/ui/command.tsx +0 -225
- package/src/components/ui/dialog.tsx +0 -334
- package/src/components/ui/dropdown-menu.tsx +0 -218
- package/src/components/ui/gesture-drawer.tsx +0 -11
- package/src/components/ui/hover-card.tsx +0 -29
- package/src/components/ui/index.ts +0 -190
- package/src/components/ui/input.tsx +0 -222
- package/src/components/ui/label.tsx +0 -29
- package/src/components/ui/lightbox.tsx +0 -606
- package/src/components/ui/magnetic-button.tsx +0 -129
- package/src/components/ui/media-gallery.tsx +0 -612
- package/src/components/ui/pagination.tsx +0 -123
- package/src/components/ui/popover.tsx +0 -185
- package/src/components/ui/progress.tsx +0 -30
- package/src/components/ui/radio-group.tsx +0 -257
- package/src/components/ui/scroll-area.tsx +0 -47
- package/src/components/ui/select.tsx +0 -374
- package/src/components/ui/separator.tsx +0 -145
- package/src/components/ui/sheet.tsx +0 -139
- package/src/components/ui/skeleton.tsx +0 -20
- package/src/components/ui/slider.tsx +0 -354
- package/src/components/ui/spotlight-card.tsx +0 -119
- package/src/components/ui/switch.tsx +0 -86
- package/src/components/ui/table.tsx +0 -329
- package/src/components/ui/tabs.tsx +0 -198
- package/src/components/ui/textarea.tsx +0 -28
- package/src/components/ui/toast.tsx +0 -317
- package/src/components/ui/toggle.tsx +0 -119
- package/src/components/ui/tooltip.tsx +0 -151
- package/src/components/virtual-list/index.tsx +0 -668
- package/src/hooks/use-chart.ts +0 -205
- package/src/hooks/use-data-table.ts +0 -182
- package/src/hooks/use-docs-pro-access.ts +0 -13
- package/src/hooks/use-license-check.ts +0 -65
- package/src/hooks/use-subscription.ts +0 -19
- package/src/hooks/use-toast.ts +0 -15
- package/src/index.ts +0 -14
- package/src/lib/ai-providers.ts +0 -377
- package/src/lib/component-metadata.ts +0 -18
- package/src/lib/micro-interactions.ts +0 -255
- package/src/lib/paddle.ts +0 -17
- package/src/lib/utils.ts +0 -6
- package/src/patterns/login-form/index.tsx +0 -276
- package/src/patterns/login-form/types.ts +0 -67
- package/src/setupTests.ts +0 -41
- package/src/styles/advanced-chart.css +0 -239
- package/src/styles/calendar.css +0 -35
- package/src/styles/design-system.css +0 -363
- package/src/styles/index.css +0 -85
- package/src/styles/tailwind.css +0 -7
- package/src/styles/tokens.css +0 -455
- package/src/types/moonui.d.ts +0 -22
- package/src/types/next-auth.d.ts +0 -21
- package/src/use-intersection-observer.tsx +0 -154
- package/src/use-local-storage.tsx +0 -71
- package/src/use-paddle.ts +0 -138
- package/src/use-performance-optimizer.ts +0 -389
- package/src/use-pro-access.ts +0 -141
- package/src/use-scroll-animation.ts +0 -219
- package/src/use-subscription.ts +0 -37
- package/src/use-toast.ts +0 -32
- package/src/utils/chart-helpers.ts +0 -357
- package/src/utils/cn.ts +0 -6
- package/src/utils/data-processing.ts +0 -151
- package/src/utils/license-validator.tsx +0 -183
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React, { ReactNode } from "react"
|
|
4
|
-
import { DragDropContext, Droppable, Draggable, DropResult } from "@hello-pangea/dnd"
|
|
5
|
-
import { cn } from '../../lib/utils'
|
|
6
|
-
|
|
7
|
-
export interface DraggableListProps<T> {
|
|
8
|
-
items: T[]
|
|
9
|
-
onReorder: (items: T[]) => void
|
|
10
|
-
renderItem: (item: T, index: number) => ReactNode
|
|
11
|
-
keyExtractor: (item: T) => string
|
|
12
|
-
direction?: "vertical" | "horizontal"
|
|
13
|
-
className?: string
|
|
14
|
-
droppableId?: string
|
|
15
|
-
disabled?: boolean
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function DraggableList<T>({
|
|
19
|
-
items,
|
|
20
|
-
onReorder,
|
|
21
|
-
renderItem,
|
|
22
|
-
keyExtractor,
|
|
23
|
-
direction = "vertical",
|
|
24
|
-
className,
|
|
25
|
-
droppableId = "draggable-list",
|
|
26
|
-
disabled = false,
|
|
27
|
-
}: DraggableListProps<T>) {
|
|
28
|
-
const handleDragEnd = (result: DropResult) => {
|
|
29
|
-
if (!result.destination || disabled) {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const sourceIndex = result.source.index
|
|
34
|
-
const destinationIndex = result.destination.index
|
|
35
|
-
|
|
36
|
-
if (sourceIndex === destinationIndex) {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const newItems = Array.from(items)
|
|
41
|
-
const [reorderedItem] = newItems.splice(sourceIndex, 1)
|
|
42
|
-
newItems.splice(destinationIndex, 0, reorderedItem)
|
|
43
|
-
|
|
44
|
-
onReorder(newItems)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<DragDropContext onDragEnd={handleDragEnd}>
|
|
49
|
-
<Droppable
|
|
50
|
-
droppableId={droppableId}
|
|
51
|
-
direction={direction}
|
|
52
|
-
isDropDisabled={disabled}
|
|
53
|
-
>
|
|
54
|
-
{(provided, snapshot) => (
|
|
55
|
-
<div
|
|
56
|
-
{...provided.droppableProps}
|
|
57
|
-
ref={provided.innerRef}
|
|
58
|
-
className={cn(
|
|
59
|
-
"space-y-2",
|
|
60
|
-
direction === "horizontal" && "flex space-y-0 space-x-2",
|
|
61
|
-
snapshot.isDraggingOver && "bg-muted/50 rounded-lg",
|
|
62
|
-
className
|
|
63
|
-
)}
|
|
64
|
-
>
|
|
65
|
-
{items.map((item, index) => (
|
|
66
|
-
<Draggable
|
|
67
|
-
key={keyExtractor(item)}
|
|
68
|
-
draggableId={keyExtractor(item)}
|
|
69
|
-
index={index}
|
|
70
|
-
isDragDisabled={disabled}
|
|
71
|
-
>
|
|
72
|
-
{(provided, snapshot) => (
|
|
73
|
-
<div
|
|
74
|
-
ref={provided.innerRef}
|
|
75
|
-
{...provided.draggableProps}
|
|
76
|
-
{...provided.dragHandleProps}
|
|
77
|
-
className={cn(
|
|
78
|
-
"transition-all duration-200",
|
|
79
|
-
snapshot.isDragging && "rotate-2 scale-105 shadow-lg z-50",
|
|
80
|
-
disabled && "cursor-not-allowed opacity-50"
|
|
81
|
-
)}
|
|
82
|
-
style={{
|
|
83
|
-
...provided.draggableProps.style,
|
|
84
|
-
transform: snapshot.isDragging
|
|
85
|
-
? provided.draggableProps.style?.transform
|
|
86
|
-
: "none",
|
|
87
|
-
}}
|
|
88
|
-
>
|
|
89
|
-
{renderItem(item, index)}
|
|
90
|
-
</div>
|
|
91
|
-
)}
|
|
92
|
-
</Draggable>
|
|
93
|
-
))}
|
|
94
|
-
{provided.placeholder}
|
|
95
|
-
</div>
|
|
96
|
-
)}
|
|
97
|
-
</Droppable>
|
|
98
|
-
</DragDropContext>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { motion, AnimatePresence } from 'framer-motion'
|
|
3
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
-
import { cn } from '../../lib/utils'
|
|
5
|
-
|
|
6
|
-
const badgeVariants = cva(
|
|
7
|
-
["inline-flex items-center gap-1.5",
|
|
8
|
-
"font-medium transition-all duration-200",
|
|
9
|
-
"border focus:outline-none",
|
|
10
|
-
"focus-visible:ring-2 focus-visible:ring-offset-1"],
|
|
11
|
-
{
|
|
12
|
-
variants: {
|
|
13
|
-
variant: {
|
|
14
|
-
default: [
|
|
15
|
-
"border-transparent bg-primary text-primary-foreground",
|
|
16
|
-
"hover:bg-primary/90",
|
|
17
|
-
"focus-visible:ring-primary/30",
|
|
18
|
-
],
|
|
19
|
-
secondary: [
|
|
20
|
-
"border-transparent bg-secondary text-secondary-foreground",
|
|
21
|
-
"hover:bg-secondary/80",
|
|
22
|
-
"focus-visible:ring-gray-400/30",
|
|
23
|
-
],
|
|
24
|
-
destructive: [
|
|
25
|
-
"border-transparent bg-destructive text-destructive-foreground",
|
|
26
|
-
"hover:bg-destructive/90",
|
|
27
|
-
"focus-visible:ring-destructive/30",
|
|
28
|
-
],
|
|
29
|
-
outline: [
|
|
30
|
-
"border-input bg-transparent",
|
|
31
|
-
"hover:border-input/80",
|
|
32
|
-
"focus-visible:ring-gray-400/30",
|
|
33
|
-
],
|
|
34
|
-
success: [
|
|
35
|
-
"border-transparent bg-green-500 text-white",
|
|
36
|
-
"hover:bg-green-600",
|
|
37
|
-
"focus-visible:ring-green-500/30",
|
|
38
|
-
],
|
|
39
|
-
warning: [
|
|
40
|
-
"border-transparent bg-yellow-500 text-white",
|
|
41
|
-
"hover:bg-yellow-600",
|
|
42
|
-
"focus-visible:ring-yellow-500/30",
|
|
43
|
-
],
|
|
44
|
-
pro: [
|
|
45
|
-
"border-transparent bg-gradient-to-r from-purple-600 to-pink-600 text-white",
|
|
46
|
-
"hover:from-purple-700 hover:to-pink-700",
|
|
47
|
-
"focus-visible:ring-purple-400/30",
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
size: {
|
|
51
|
-
sm: "h-5 px-2 text-xs",
|
|
52
|
-
default: "h-6 px-3 text-sm",
|
|
53
|
-
lg: "h-8 px-4 text-base",
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
defaultVariants: {
|
|
57
|
-
variant: "default",
|
|
58
|
-
size: "default",
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
export interface BadgeProProps
|
|
64
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
65
|
-
VariantProps<typeof badgeVariants> {
|
|
66
|
-
enablePulse?: boolean
|
|
67
|
-
enableGlow?: boolean
|
|
68
|
-
enableShimmer?: boolean
|
|
69
|
-
removable?: boolean
|
|
70
|
-
onRemove?: () => void
|
|
71
|
-
leftIcon?: React.ReactNode
|
|
72
|
-
rightIcon?: React.ReactNode
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const BadgePro = React.forwardRef<
|
|
76
|
-
HTMLDivElement,
|
|
77
|
-
BadgeProProps
|
|
78
|
-
>(({
|
|
79
|
-
className,
|
|
80
|
-
variant,
|
|
81
|
-
size,
|
|
82
|
-
enablePulse = false,
|
|
83
|
-
enableGlow = false,
|
|
84
|
-
enableShimmer = false,
|
|
85
|
-
removable = false,
|
|
86
|
-
onRemove,
|
|
87
|
-
leftIcon,
|
|
88
|
-
rightIcon,
|
|
89
|
-
children,
|
|
90
|
-
...props
|
|
91
|
-
}, ref) => {
|
|
92
|
-
const [isRemoving, setIsRemoving] = React.useState(false)
|
|
93
|
-
|
|
94
|
-
const handleRemove = () => {
|
|
95
|
-
setIsRemoving(true)
|
|
96
|
-
setTimeout(() => {
|
|
97
|
-
onRemove?.()
|
|
98
|
-
}, 300)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Auto-assign icons for special variants
|
|
102
|
-
let autoLeftIcon = leftIcon
|
|
103
|
-
let autoChildren = children
|
|
104
|
-
|
|
105
|
-
if (variant === 'pro' && !leftIcon) {
|
|
106
|
-
autoLeftIcon = (
|
|
107
|
-
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" className="w-3 h-3">
|
|
108
|
-
<path d="M12 0L13.09 8.26L22 9L13.09 9.74L12 18L10.91 9.74L2 9L10.91 8.26L12 0Z" fill="currentColor"/>
|
|
109
|
-
<path d="M19 5L19.5 7L21 7.5L19.5 8L19 10L18.5 8L17 7.5L18.5 7L19 5Z" fill="currentColor"/>
|
|
110
|
-
<path d="M19 15L19.5 17L21 17.5L19.5 18L19 20L18.5 18L17 17.5L18.5 17L19 15Z" fill="currentColor"/>
|
|
111
|
-
</svg>
|
|
112
|
-
)
|
|
113
|
-
autoChildren = children || 'Pro'
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<AnimatePresence>
|
|
118
|
-
{!isRemoving && (
|
|
119
|
-
<motion.div
|
|
120
|
-
ref={ref}
|
|
121
|
-
className={cn(
|
|
122
|
-
badgeVariants({ variant, size }),
|
|
123
|
-
enablePulse && "animate-pulse",
|
|
124
|
-
enableGlow && "shadow-lg shadow-current/50",
|
|
125
|
-
enableShimmer && "relative overflow-hidden",
|
|
126
|
-
className
|
|
127
|
-
)}
|
|
128
|
-
initial={{ opacity: 0, scale: 0.8 }}
|
|
129
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
130
|
-
exit={{ opacity: 0, scale: 0.8 }}
|
|
131
|
-
transition={{ duration: 0.2 }}
|
|
132
|
-
whileHover={{ scale: 1.05 }}
|
|
133
|
-
whileTap={{ scale: 0.95 }}
|
|
134
|
-
>
|
|
135
|
-
{enableShimmer && (
|
|
136
|
-
<motion.div
|
|
137
|
-
className="absolute inset-0 -translate-x-full bg-gradient-to-r from-transparent via-white/20 to-transparent"
|
|
138
|
-
animate={{ translateX: "200%" }}
|
|
139
|
-
transition={{ duration: 2, repeat: Infinity, ease: "linear" }}
|
|
140
|
-
/>
|
|
141
|
-
)}
|
|
142
|
-
|
|
143
|
-
{autoLeftIcon && (
|
|
144
|
-
<motion.span
|
|
145
|
-
className="inline-flex shrink-0"
|
|
146
|
-
animate={enablePulse ? { scale: [1, 1.2, 1] } : {}}
|
|
147
|
-
transition={{ duration: 2, repeat: Infinity }}
|
|
148
|
-
>
|
|
149
|
-
{autoLeftIcon}
|
|
150
|
-
</motion.span>
|
|
151
|
-
)}
|
|
152
|
-
|
|
153
|
-
<span className="truncate">{autoChildren}</span>
|
|
154
|
-
|
|
155
|
-
{rightIcon && (
|
|
156
|
-
<span className="inline-flex shrink-0">
|
|
157
|
-
{rightIcon}
|
|
158
|
-
</span>
|
|
159
|
-
)}
|
|
160
|
-
|
|
161
|
-
{removable && onRemove && (
|
|
162
|
-
<motion.button
|
|
163
|
-
type="button"
|
|
164
|
-
className="ml-1 -mr-1 h-3.5 w-3.5 rounded-full inline-flex items-center justify-center hover:bg-black/10 dark:hover:bg-white/10"
|
|
165
|
-
onClick={handleRemove}
|
|
166
|
-
whileHover={{ rotate: 90 }}
|
|
167
|
-
transition={{ type: "spring", stiffness: 300 }}
|
|
168
|
-
aria-label="Remove badge"
|
|
169
|
-
>
|
|
170
|
-
<svg
|
|
171
|
-
width="8"
|
|
172
|
-
height="8"
|
|
173
|
-
viewBox="0 0 8 8"
|
|
174
|
-
fill="none"
|
|
175
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
176
|
-
className="opacity-70"
|
|
177
|
-
aria-hidden="true"
|
|
178
|
-
>
|
|
179
|
-
<path d="M0.799988 7.19999L7.19999 0.799988M0.799988 0.799988L7.19999 7.19999" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
|
|
180
|
-
</svg>
|
|
181
|
-
</motion.button>
|
|
182
|
-
)}
|
|
183
|
-
</motion.div>
|
|
184
|
-
)}
|
|
185
|
-
</AnimatePresence>
|
|
186
|
-
)
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
BadgePro.displayName = 'BadgePro'
|
|
190
|
-
|
|
191
|
-
export { badgeVariants }
|
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React, { useRef, useState, useEffect } from "react"
|
|
4
|
-
import { motion, AnimatePresence } from "framer-motion"
|
|
5
|
-
import { Loader2, Check, X, Sparkles } from "lucide-react"
|
|
6
|
-
import { cn } from "../../lib/utils"
|
|
7
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
8
|
-
|
|
9
|
-
const enhancedButtonVariants = cva(
|
|
10
|
-
"relative inline-flex items-center justify-center whitespace-nowrap text-sm font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 overflow-hidden transform active:scale-[0.98] rounded-lg",
|
|
11
|
-
{
|
|
12
|
-
variants: {
|
|
13
|
-
variant: {
|
|
14
|
-
default: "bg-primary text-primary-foreground dark:bg-primary dark:text-primary-foreground hover:bg-primary/90 dark:hover:bg-primary/90 shadow-sm hover:shadow-md",
|
|
15
|
-
destructive: "bg-destructive text-destructive-foreground dark:bg-destructive dark:text-destructive-foreground hover:bg-destructive/90 dark:hover:bg-destructive/90 shadow-sm hover:shadow-md",
|
|
16
|
-
outline: "border border-input dark:border-input bg-background dark:bg-background text-foreground dark:text-foreground hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent dark:hover:text-accent-foreground transition-all duration-200",
|
|
17
|
-
secondary: "bg-muted text-muted-foreground dark:bg-muted dark:text-muted-foreground hover:bg-muted/80 dark:hover:bg-muted/80 border border-input dark:border-input shadow-sm hover:shadow-md",
|
|
18
|
-
ghost: "text-foreground dark:text-foreground hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent dark:hover:text-accent-foreground transition-all duration-200",
|
|
19
|
-
link: "text-primary underline-offset-4 hover:underline hover:text-primary/80",
|
|
20
|
-
gradient: "bg-gradient-to-r from-purple-600 to-pink-600 text-white hover:from-purple-700 hover:to-pink-700 shadow-md hover:shadow-lg",
|
|
21
|
-
glow: "bg-primary text-primary-foreground shadow-lg shadow-primary/50 hover:shadow-xl hover:shadow-primary/60",
|
|
22
|
-
},
|
|
23
|
-
size: {
|
|
24
|
-
default: "h-10 px-4 py-2",
|
|
25
|
-
sm: "h-9 px-3",
|
|
26
|
-
lg: "h-11 px-8",
|
|
27
|
-
icon: "h-10 w-10",
|
|
28
|
-
},
|
|
29
|
-
animation: {
|
|
30
|
-
ripple: "ripple-effect",
|
|
31
|
-
morph: "morph-effect",
|
|
32
|
-
particles: "particles-effect",
|
|
33
|
-
magnetic: "magnetic-effect",
|
|
34
|
-
glitch: "glitch-effect",
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
defaultVariants: {
|
|
38
|
-
variant: "default",
|
|
39
|
-
size: "default",
|
|
40
|
-
animation: "ripple",
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
interface RippleEffect {
|
|
46
|
-
x: number
|
|
47
|
-
y: number
|
|
48
|
-
id: number
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface ButtonProProps
|
|
52
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
53
|
-
VariantProps<typeof enhancedButtonVariants> {
|
|
54
|
-
state?: "idle" | "loading" | "success" | "error"
|
|
55
|
-
onStateChange?: (state: "idle" | "loading" | "success" | "error") => void
|
|
56
|
-
enableRipple?: boolean
|
|
57
|
-
enableMorph?: boolean
|
|
58
|
-
enableParticles?: boolean
|
|
59
|
-
enableMagnetic?: boolean
|
|
60
|
-
enableGlitch?: boolean
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const ButtonPro = React.forwardRef<HTMLButtonElement, ButtonProProps>(
|
|
64
|
-
({
|
|
65
|
-
className,
|
|
66
|
-
variant,
|
|
67
|
-
size,
|
|
68
|
-
animation,
|
|
69
|
-
state = "idle",
|
|
70
|
-
onStateChange,
|
|
71
|
-
children,
|
|
72
|
-
onClick,
|
|
73
|
-
enableRipple = true,
|
|
74
|
-
enableMorph = true,
|
|
75
|
-
enableParticles = false,
|
|
76
|
-
enableMagnetic = false,
|
|
77
|
-
enableGlitch = false,
|
|
78
|
-
disabled,
|
|
79
|
-
type = "button",
|
|
80
|
-
...props
|
|
81
|
-
}, ref) => {
|
|
82
|
-
const [internalState, setInternalState] = useState<"idle" | "loading" | "success" | "error">("idle")
|
|
83
|
-
const [ripples, setRipples] = useState<RippleEffect[]>([])
|
|
84
|
-
const [particles, setParticles] = useState<{ x: number; y: number; id: number }[]>([])
|
|
85
|
-
const [magneticPosition, setMagneticPosition] = useState({ x: 0, y: 0 })
|
|
86
|
-
const buttonRef = useRef<HTMLButtonElement>(null)
|
|
87
|
-
const currentState = state !== "idle" ? state : internalState
|
|
88
|
-
|
|
89
|
-
// Ripple effect
|
|
90
|
-
const createRipple = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
91
|
-
if (!enableRipple) return
|
|
92
|
-
|
|
93
|
-
const button = event.currentTarget
|
|
94
|
-
const rect = button.getBoundingClientRect()
|
|
95
|
-
const ripple = {
|
|
96
|
-
x: event.clientX - rect.left,
|
|
97
|
-
y: event.clientY - rect.top,
|
|
98
|
-
id: Date.now()
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
setRipples([...ripples, ripple])
|
|
102
|
-
setTimeout(() => {
|
|
103
|
-
setRipples(prev => prev.filter(r => r.id !== ripple.id))
|
|
104
|
-
}, 1000)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Particle effect
|
|
108
|
-
const createParticles = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
109
|
-
if (!enableParticles) return
|
|
110
|
-
|
|
111
|
-
const button = event.currentTarget
|
|
112
|
-
const rect = button.getBoundingClientRect()
|
|
113
|
-
const newParticles = Array.from({ length: 8 }, (_, i) => ({
|
|
114
|
-
x: event.clientX - rect.left,
|
|
115
|
-
y: event.clientY - rect.top,
|
|
116
|
-
id: Date.now() + i
|
|
117
|
-
}))
|
|
118
|
-
|
|
119
|
-
setParticles([...particles, ...newParticles])
|
|
120
|
-
setTimeout(() => {
|
|
121
|
-
setParticles([])
|
|
122
|
-
}, 1000)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Magnetic effect
|
|
126
|
-
const handleMouseMove = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
127
|
-
if (!enableMagnetic) return
|
|
128
|
-
|
|
129
|
-
const button = event.currentTarget
|
|
130
|
-
const rect = button.getBoundingClientRect()
|
|
131
|
-
const centerX = rect.width / 2
|
|
132
|
-
const centerY = rect.height / 2
|
|
133
|
-
const x = event.clientX - rect.left - centerX
|
|
134
|
-
const y = event.clientY - rect.top - centerY
|
|
135
|
-
|
|
136
|
-
setMagneticPosition({
|
|
137
|
-
x: x * 0.2,
|
|
138
|
-
y: y * 0.2
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const handleMouseLeave = () => {
|
|
143
|
-
if (enableMagnetic) {
|
|
144
|
-
setMagneticPosition({ x: 0, y: 0 })
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const handleClick = async (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
149
|
-
createRipple(e)
|
|
150
|
-
createParticles(e)
|
|
151
|
-
|
|
152
|
-
if (currentState === "loading") return
|
|
153
|
-
|
|
154
|
-
if (enableMorph) {
|
|
155
|
-
setInternalState("loading")
|
|
156
|
-
onStateChange?.("loading")
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (onClick) {
|
|
160
|
-
try {
|
|
161
|
-
await onClick(e)
|
|
162
|
-
if (enableMorph) {
|
|
163
|
-
setInternalState("success")
|
|
164
|
-
onStateChange?.("success")
|
|
165
|
-
|
|
166
|
-
setTimeout(() => {
|
|
167
|
-
setInternalState("idle")
|
|
168
|
-
onStateChange?.("idle")
|
|
169
|
-
}, 2000)
|
|
170
|
-
}
|
|
171
|
-
} catch (error) {
|
|
172
|
-
if (enableMorph) {
|
|
173
|
-
setInternalState("error")
|
|
174
|
-
onStateChange?.("error")
|
|
175
|
-
|
|
176
|
-
setTimeout(() => {
|
|
177
|
-
setInternalState("idle")
|
|
178
|
-
onStateChange?.("idle")
|
|
179
|
-
}, 2000)
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const getIcon = () => {
|
|
186
|
-
switch (currentState) {
|
|
187
|
-
case "loading":
|
|
188
|
-
return <Loader2 className="h-4 w-4 animate-spin" />
|
|
189
|
-
case "success":
|
|
190
|
-
return <Check className="h-4 w-4" />
|
|
191
|
-
case "error":
|
|
192
|
-
return <X className="h-4 w-4" />
|
|
193
|
-
default:
|
|
194
|
-
return null
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const getBackgroundColor = () => {
|
|
199
|
-
switch (currentState) {
|
|
200
|
-
case "success":
|
|
201
|
-
return "bg-success"
|
|
202
|
-
case "error":
|
|
203
|
-
return "bg-destructive"
|
|
204
|
-
default:
|
|
205
|
-
return ""
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return (
|
|
210
|
-
<motion.button
|
|
211
|
-
className={cn(enhancedButtonVariants({ variant, size }), className)}
|
|
212
|
-
ref={buttonRef || ref}
|
|
213
|
-
onClick={handleClick}
|
|
214
|
-
onMouseMove={handleMouseMove}
|
|
215
|
-
onMouseLeave={handleMouseLeave}
|
|
216
|
-
disabled={currentState === "loading" || disabled}
|
|
217
|
-
type={type}
|
|
218
|
-
animate={{
|
|
219
|
-
x: magneticPosition.x,
|
|
220
|
-
y: magneticPosition.y,
|
|
221
|
-
}}
|
|
222
|
-
transition={{
|
|
223
|
-
type: "spring",
|
|
224
|
-
stiffness: 150,
|
|
225
|
-
damping: 15,
|
|
226
|
-
mass: 0.1
|
|
227
|
-
}}
|
|
228
|
-
>
|
|
229
|
-
{/* Ripple effects */}
|
|
230
|
-
<AnimatePresence>
|
|
231
|
-
{ripples.map((ripple) => (
|
|
232
|
-
<motion.span
|
|
233
|
-
key={ripple.id}
|
|
234
|
-
className="absolute rounded-full bg-white/30 pointer-events-none"
|
|
235
|
-
style={{
|
|
236
|
-
left: ripple.x,
|
|
237
|
-
top: ripple.y,
|
|
238
|
-
}}
|
|
239
|
-
initial={{ width: 0, height: 0, x: 0, y: 0, opacity: 1 }}
|
|
240
|
-
animate={{
|
|
241
|
-
width: 200,
|
|
242
|
-
height: 200,
|
|
243
|
-
x: -100,
|
|
244
|
-
y: -100,
|
|
245
|
-
opacity: 0
|
|
246
|
-
}}
|
|
247
|
-
exit={{ opacity: 0 }}
|
|
248
|
-
transition={{ duration: 1, ease: "easeOut" }}
|
|
249
|
-
/>
|
|
250
|
-
))}
|
|
251
|
-
</AnimatePresence>
|
|
252
|
-
|
|
253
|
-
{/* Particle effects */}
|
|
254
|
-
<AnimatePresence>
|
|
255
|
-
{particles.map((particle, i) => (
|
|
256
|
-
<motion.span
|
|
257
|
-
key={particle.id}
|
|
258
|
-
className="absolute w-1 h-1 bg-primary rounded-full pointer-events-none"
|
|
259
|
-
style={{
|
|
260
|
-
left: particle.x,
|
|
261
|
-
top: particle.y,
|
|
262
|
-
}}
|
|
263
|
-
initial={{ scale: 0, opacity: 1 }}
|
|
264
|
-
animate={{
|
|
265
|
-
scale: [0, 1, 0],
|
|
266
|
-
x: (i % 2 === 0 ? 1 : -1) * (20 + Math.random() * 30),
|
|
267
|
-
y: -20 - Math.random() * 30,
|
|
268
|
-
opacity: [1, 1, 0]
|
|
269
|
-
}}
|
|
270
|
-
exit={{ opacity: 0 }}
|
|
271
|
-
transition={{ duration: 0.6, ease: "easeOut" }}
|
|
272
|
-
/>
|
|
273
|
-
))}
|
|
274
|
-
</AnimatePresence>
|
|
275
|
-
|
|
276
|
-
{/* Morph content */}
|
|
277
|
-
<motion.div
|
|
278
|
-
className="flex items-center gap-2"
|
|
279
|
-
animate={{
|
|
280
|
-
width: currentState !== "idle" ? "auto" : "100%"
|
|
281
|
-
}}
|
|
282
|
-
transition={{ duration: 0.2 }}
|
|
283
|
-
>
|
|
284
|
-
<AnimatePresence mode="wait">
|
|
285
|
-
{currentState !== "idle" && (
|
|
286
|
-
<motion.div
|
|
287
|
-
initial={{ scale: 0, opacity: 0 }}
|
|
288
|
-
animate={{ scale: 1, opacity: 1 }}
|
|
289
|
-
exit={{ scale: 0, opacity: 0 }}
|
|
290
|
-
transition={{ duration: 0.2 }}
|
|
291
|
-
className="flex items-center"
|
|
292
|
-
>
|
|
293
|
-
{getIcon()}
|
|
294
|
-
</motion.div>
|
|
295
|
-
)}
|
|
296
|
-
</AnimatePresence>
|
|
297
|
-
|
|
298
|
-
<motion.span
|
|
299
|
-
animate={{
|
|
300
|
-
opacity: currentState === "idle" ? 1 : 0,
|
|
301
|
-
x: currentState !== "idle" ? -20 : 0
|
|
302
|
-
}}
|
|
303
|
-
transition={{ duration: 0.2 }}
|
|
304
|
-
>
|
|
305
|
-
{children}
|
|
306
|
-
</motion.span>
|
|
307
|
-
</motion.div>
|
|
308
|
-
|
|
309
|
-
{/* Background animation for success/error states */}
|
|
310
|
-
<AnimatePresence>
|
|
311
|
-
{(currentState === "success" || currentState === "error") && (
|
|
312
|
-
<motion.div
|
|
313
|
-
className={cn(
|
|
314
|
-
"absolute inset-0 rounded-md -z-10",
|
|
315
|
-
getBackgroundColor()
|
|
316
|
-
)}
|
|
317
|
-
initial={{ scale: 0, opacity: 0 }}
|
|
318
|
-
animate={{ scale: 1, opacity: 1 }}
|
|
319
|
-
exit={{ scale: 0, opacity: 0 }}
|
|
320
|
-
transition={{ duration: 0.3 }}
|
|
321
|
-
/>
|
|
322
|
-
)}
|
|
323
|
-
</AnimatePresence>
|
|
324
|
-
|
|
325
|
-
{/* Glitch effect overlay */}
|
|
326
|
-
{enableGlitch && (
|
|
327
|
-
<motion.div
|
|
328
|
-
className="absolute inset-0 pointer-events-none"
|
|
329
|
-
animate={{
|
|
330
|
-
opacity: [0, 0.1, 0, 0.2, 0],
|
|
331
|
-
clipPath: [
|
|
332
|
-
"inset(0 0 100% 0)",
|
|
333
|
-
"inset(20% 0 60% 0)",
|
|
334
|
-
"inset(40% 0 40% 0)",
|
|
335
|
-
"inset(80% 0 10% 0)",
|
|
336
|
-
"inset(0 0 100% 0)",
|
|
337
|
-
]
|
|
338
|
-
}}
|
|
339
|
-
transition={{
|
|
340
|
-
duration: 0.5,
|
|
341
|
-
repeat: Infinity,
|
|
342
|
-
repeatDelay: 5,
|
|
343
|
-
}}
|
|
344
|
-
style={{
|
|
345
|
-
background: "linear-gradient(45deg, #ff0080, #00ff88, #0080ff)",
|
|
346
|
-
mixBlendMode: "screen"
|
|
347
|
-
}}
|
|
348
|
-
/>
|
|
349
|
-
)}
|
|
350
|
-
|
|
351
|
-
{/* Sparkle decoration for special variants */}
|
|
352
|
-
{variant === "gradient" && (
|
|
353
|
-
<Sparkles className="absolute top-1 right-1 h-3 w-3 text-white/50 animate-pulse" />
|
|
354
|
-
)}
|
|
355
|
-
</motion.button>
|
|
356
|
-
)
|
|
357
|
-
}
|
|
358
|
-
)
|
|
359
|
-
|
|
360
|
-
ButtonPro.displayName = "ButtonPro"
|
|
361
|
-
|
|
362
|
-
export { ButtonPro as Button, enhancedButtonVariants }
|