@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,426 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React, { useState } from "react"
|
|
4
|
-
import { motion, AnimatePresence } from "framer-motion"
|
|
5
|
-
import { useForm } from "react-hook-form"
|
|
6
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/card"
|
|
7
|
-
import { Button } from "../ui/button"
|
|
8
|
-
import { Input } from "../ui/input"
|
|
9
|
-
import { Label } from "../ui/label"
|
|
10
|
-
import { Textarea } from "../ui/textarea"
|
|
11
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select"
|
|
12
|
-
import { Checkbox } from "../ui/checkbox"
|
|
13
|
-
import { Switch } from "../ui/switch"
|
|
14
|
-
import { MoonUIBadgePro as Badge } from "../ui/badge"
|
|
15
|
-
import { cn } from "../../lib/utils"
|
|
16
|
-
import { Lock, Sparkles, CheckCircle, AlertCircle, Eye, EyeOff, Upload, X } from "lucide-react"
|
|
17
|
-
import { useSubscription } from "../../hooks/use-subscription"
|
|
18
|
-
|
|
19
|
-
interface AdvancedFormField {
|
|
20
|
-
name: string
|
|
21
|
-
label: string
|
|
22
|
-
type: "text" | "email" | "password" | "textarea" | "select" | "checkbox" | "switch" | "file" | "number" | "url" | "tel"
|
|
23
|
-
placeholder?: string
|
|
24
|
-
required?: boolean
|
|
25
|
-
options?: Array<{ value: string; label: string }>
|
|
26
|
-
validation?: {
|
|
27
|
-
minLength?: number
|
|
28
|
-
maxLength?: number
|
|
29
|
-
pattern?: RegExp
|
|
30
|
-
custom?: (value: any) => string | true
|
|
31
|
-
}
|
|
32
|
-
description?: string
|
|
33
|
-
defaultValue?: any
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface AdvancedFormsProps {
|
|
37
|
-
fields: AdvancedFormField[]
|
|
38
|
-
onSubmit: (data: any) => void | Promise<void>
|
|
39
|
-
title?: string
|
|
40
|
-
description?: string
|
|
41
|
-
submitText?: string
|
|
42
|
-
enableAutoSave?: boolean
|
|
43
|
-
showProgress?: boolean
|
|
44
|
-
className?: string
|
|
45
|
-
layout?: "vertical" | "horizontal" | "grid"
|
|
46
|
-
columns?: number
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const AdvancedFormsInternal: React.FC<AdvancedFormsProps> = ({
|
|
50
|
-
fields,
|
|
51
|
-
onSubmit,
|
|
52
|
-
title = "Advanced Form",
|
|
53
|
-
description,
|
|
54
|
-
submitText = "Submit",
|
|
55
|
-
enableAutoSave = false,
|
|
56
|
-
showProgress = true,
|
|
57
|
-
className,
|
|
58
|
-
layout = "vertical",
|
|
59
|
-
columns = 2
|
|
60
|
-
}) => {
|
|
61
|
-
const [isSubmitting, setIsSubmitting] = useState(false)
|
|
62
|
-
const [showPasswords, setShowPasswords] = useState<Record<string, boolean>>({})
|
|
63
|
-
const [uploadedFiles, setUploadedFiles] = useState<Record<string, File[]>>({})
|
|
64
|
-
|
|
65
|
-
const {
|
|
66
|
-
register,
|
|
67
|
-
handleSubmit,
|
|
68
|
-
watch,
|
|
69
|
-
formState: { errors, isValid, touchedFields },
|
|
70
|
-
setValue,
|
|
71
|
-
getValues
|
|
72
|
-
} = useForm<any>({
|
|
73
|
-
mode: "onChange",
|
|
74
|
-
defaultValues: fields.reduce((acc, field) => ({
|
|
75
|
-
...acc,
|
|
76
|
-
[field.name]: field.defaultValue || (field.type === "checkbox" ? false : "")
|
|
77
|
-
}), {})
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const watchedValues = watch()
|
|
81
|
-
const completedFields = Object.keys(touchedFields).length
|
|
82
|
-
const progress = fields.length > 0 ? (completedFields / fields.length) * 100 : 0
|
|
83
|
-
|
|
84
|
-
const handleFormSubmit = async (data: any) => {
|
|
85
|
-
setIsSubmitting(true)
|
|
86
|
-
try {
|
|
87
|
-
await onSubmit(data)
|
|
88
|
-
} finally {
|
|
89
|
-
setIsSubmitting(false)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const togglePasswordVisibility = (fieldName: string) => {
|
|
94
|
-
setShowPasswords(prev => ({
|
|
95
|
-
...prev,
|
|
96
|
-
[fieldName]: !prev[fieldName]
|
|
97
|
-
}))
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const handleFileUpload = (fieldName: string, files: FileList | null) => {
|
|
101
|
-
if (files) {
|
|
102
|
-
const fileArray = Array.from(files)
|
|
103
|
-
setUploadedFiles(prev => ({
|
|
104
|
-
...prev,
|
|
105
|
-
[fieldName]: fileArray
|
|
106
|
-
}))
|
|
107
|
-
setValue(fieldName as any, fileArray as any)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const removeFile = (fieldName: string, index: number) => {
|
|
112
|
-
setUploadedFiles(prev => {
|
|
113
|
-
const newFiles = [...(prev[fieldName] || [])]
|
|
114
|
-
newFiles.splice(index, 1)
|
|
115
|
-
return {
|
|
116
|
-
...prev,
|
|
117
|
-
[fieldName]: newFiles
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
setValue(fieldName as any, uploadedFiles[fieldName]?.filter((_, i) => i !== index) || [] as any)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const renderField = (field: AdvancedFormField, index: number) => {
|
|
124
|
-
const error = errors[field.name]
|
|
125
|
-
const isTouched = touchedFields[field.name]
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<motion.div
|
|
129
|
-
key={field.name}
|
|
130
|
-
initial={{ opacity: 0, y: 20 }}
|
|
131
|
-
animate={{ opacity: 1, y: 0 }}
|
|
132
|
-
transition={{ delay: index * 0.1 }}
|
|
133
|
-
className="space-y-2"
|
|
134
|
-
>
|
|
135
|
-
<div className="flex items-center justify-between">
|
|
136
|
-
<Label htmlFor={field.name} className="flex items-center gap-2">
|
|
137
|
-
{field.label}
|
|
138
|
-
{field.required && <span className="text-destructive">*</span>}
|
|
139
|
-
{isTouched && !error && (
|
|
140
|
-
<CheckCircle className="h-4 w-4 text-green-500" />
|
|
141
|
-
)}
|
|
142
|
-
{error && <AlertCircle className="h-4 w-4 text-destructive" />}
|
|
143
|
-
</Label>
|
|
144
|
-
</div>
|
|
145
|
-
|
|
146
|
-
<div className="relative">
|
|
147
|
-
{field.type === "text" || field.type === "email" || field.type === "number" || field.type === "url" || field.type === "tel" && (
|
|
148
|
-
<Input
|
|
149
|
-
id={field.name}
|
|
150
|
-
type={field.type}
|
|
151
|
-
placeholder={field.placeholder}
|
|
152
|
-
className={cn(error && "border-destructive")}
|
|
153
|
-
{...register(field.name, {
|
|
154
|
-
required: field.required ? `${field.label} is required` : false,
|
|
155
|
-
minLength: field.validation?.minLength ? {
|
|
156
|
-
value: field.validation.minLength,
|
|
157
|
-
message: `Minimum ${field.validation.minLength} characters required`
|
|
158
|
-
} : undefined,
|
|
159
|
-
maxLength: field.validation?.maxLength ? {
|
|
160
|
-
value: field.validation.maxLength,
|
|
161
|
-
message: `Maximum ${field.validation.maxLength} characters allowed`
|
|
162
|
-
} : undefined,
|
|
163
|
-
pattern: field.validation?.pattern ? {
|
|
164
|
-
value: field.validation.pattern,
|
|
165
|
-
message: "Invalid format"
|
|
166
|
-
} : undefined,
|
|
167
|
-
validate: field.validation?.custom
|
|
168
|
-
})}
|
|
169
|
-
/>
|
|
170
|
-
)}
|
|
171
|
-
|
|
172
|
-
{field.type === "password" && (
|
|
173
|
-
<div className="relative">
|
|
174
|
-
<Input
|
|
175
|
-
id={field.name}
|
|
176
|
-
type={showPasswords[field.name] ? "text" : "password"}
|
|
177
|
-
placeholder={field.placeholder}
|
|
178
|
-
className={cn("pr-10", error && "border-destructive")}
|
|
179
|
-
{...register(field.name, {
|
|
180
|
-
required: field.required ? `${field.label} is required` : false,
|
|
181
|
-
minLength: field.validation?.minLength ? {
|
|
182
|
-
value: field.validation.minLength,
|
|
183
|
-
message: `Minimum ${field.validation.minLength} characters required`
|
|
184
|
-
} : undefined
|
|
185
|
-
})}
|
|
186
|
-
/>
|
|
187
|
-
<Button
|
|
188
|
-
type="button"
|
|
189
|
-
variant="ghost"
|
|
190
|
-
size="sm"
|
|
191
|
-
className="absolute right-1 top-1/2 -translate-y-1/2 h-8 w-8 p-0"
|
|
192
|
-
onClick={() => togglePasswordVisibility(field.name)}
|
|
193
|
-
>
|
|
194
|
-
{showPasswords[field.name] ? (
|
|
195
|
-
<EyeOff className="h-4 w-4" />
|
|
196
|
-
) : (
|
|
197
|
-
<Eye className="h-4 w-4" />
|
|
198
|
-
)}
|
|
199
|
-
</Button>
|
|
200
|
-
</div>
|
|
201
|
-
)}
|
|
202
|
-
|
|
203
|
-
{field.type === "textarea" && (
|
|
204
|
-
<Textarea
|
|
205
|
-
id={field.name}
|
|
206
|
-
placeholder={field.placeholder}
|
|
207
|
-
className={cn(error && "border-destructive")}
|
|
208
|
-
rows={3}
|
|
209
|
-
{...register(field.name, {
|
|
210
|
-
required: field.required ? `${field.label} is required` : false,
|
|
211
|
-
maxLength: field.validation?.maxLength ? {
|
|
212
|
-
value: field.validation.maxLength,
|
|
213
|
-
message: `Maximum ${field.validation.maxLength} characters allowed`
|
|
214
|
-
} : undefined
|
|
215
|
-
})}
|
|
216
|
-
/>
|
|
217
|
-
)}
|
|
218
|
-
|
|
219
|
-
{field.type === "select" && (
|
|
220
|
-
<Select
|
|
221
|
-
onValueChange={(value) => setValue(field.name, value)}
|
|
222
|
-
defaultValue={field.defaultValue}
|
|
223
|
-
>
|
|
224
|
-
<SelectTrigger className={cn(error && "border-destructive")}>
|
|
225
|
-
<SelectValue placeholder={field.placeholder} />
|
|
226
|
-
</SelectTrigger>
|
|
227
|
-
<SelectContent>
|
|
228
|
-
{field.options?.map((option) => (
|
|
229
|
-
<SelectItem key={option.value} value={option.value}>
|
|
230
|
-
{option.label}
|
|
231
|
-
</SelectItem>
|
|
232
|
-
))}
|
|
233
|
-
</SelectContent>
|
|
234
|
-
</Select>
|
|
235
|
-
)}
|
|
236
|
-
|
|
237
|
-
{field.type === "checkbox" && (
|
|
238
|
-
<div className="flex items-center space-x-2">
|
|
239
|
-
<Checkbox
|
|
240
|
-
id={field.name}
|
|
241
|
-
{...register(field.name)}
|
|
242
|
-
onCheckedChange={(checked: boolean) => setValue(field.name, checked)}
|
|
243
|
-
/>
|
|
244
|
-
<Label htmlFor={field.name} className="text-sm">
|
|
245
|
-
{field.placeholder || "Check this option"}
|
|
246
|
-
</Label>
|
|
247
|
-
</div>
|
|
248
|
-
)}
|
|
249
|
-
|
|
250
|
-
{field.type === "switch" && (
|
|
251
|
-
<div className="flex items-center space-x-2">
|
|
252
|
-
<Switch
|
|
253
|
-
id={field.name}
|
|
254
|
-
{...register(field.name)}
|
|
255
|
-
onCheckedChange={(checked: boolean) => setValue(field.name, checked)}
|
|
256
|
-
/>
|
|
257
|
-
<Label htmlFor={field.name} className="text-sm">
|
|
258
|
-
{field.placeholder || "Toggle this option"}
|
|
259
|
-
</Label>
|
|
260
|
-
</div>
|
|
261
|
-
)}
|
|
262
|
-
|
|
263
|
-
{field.type === "file" && (
|
|
264
|
-
<div className="space-y-2">
|
|
265
|
-
<div className="flex items-center justify-center w-full">
|
|
266
|
-
<label
|
|
267
|
-
htmlFor={field.name}
|
|
268
|
-
className="flex flex-col items-center justify-center w-full h-32 border-2 border-dashed rounded-lg cursor-pointer bg-muted/50 hover:bg-muted/80 transition-colors"
|
|
269
|
-
>
|
|
270
|
-
<div className="flex flex-col items-center justify-center pt-5 pb-6">
|
|
271
|
-
<Upload className="w-8 h-8 mb-4 text-muted-foreground" />
|
|
272
|
-
<p className="mb-2 text-sm text-muted-foreground">
|
|
273
|
-
<span className="font-semibold">Click to upload</span> or drag and drop
|
|
274
|
-
</p>
|
|
275
|
-
</div>
|
|
276
|
-
<input
|
|
277
|
-
id={field.name}
|
|
278
|
-
type="file"
|
|
279
|
-
multiple
|
|
280
|
-
className="hidden"
|
|
281
|
-
onChange={(e) => handleFileUpload(field.name, e.target.files)}
|
|
282
|
-
/>
|
|
283
|
-
</label>
|
|
284
|
-
</div>
|
|
285
|
-
|
|
286
|
-
{uploadedFiles[field.name] && uploadedFiles[field.name].length > 0 && (
|
|
287
|
-
<div className="space-y-2">
|
|
288
|
-
{uploadedFiles[field.name].map((file, index) => (
|
|
289
|
-
<div key={index} className="flex items-center justify-between p-2 bg-muted rounded-md">
|
|
290
|
-
<span className="text-sm truncate">{file.name}</span>
|
|
291
|
-
<Button
|
|
292
|
-
type="button"
|
|
293
|
-
variant="ghost"
|
|
294
|
-
size="sm"
|
|
295
|
-
onClick={() => removeFile(field.name, index)}
|
|
296
|
-
>
|
|
297
|
-
<X className="h-4 w-4" />
|
|
298
|
-
</Button>
|
|
299
|
-
</div>
|
|
300
|
-
))}
|
|
301
|
-
</div>
|
|
302
|
-
)}
|
|
303
|
-
</div>
|
|
304
|
-
)}
|
|
305
|
-
</div>
|
|
306
|
-
|
|
307
|
-
{field.description && (
|
|
308
|
-
<p className="text-sm text-muted-foreground">{field.description}</p>
|
|
309
|
-
)}
|
|
310
|
-
|
|
311
|
-
<AnimatePresence>
|
|
312
|
-
{error && (
|
|
313
|
-
<motion.p
|
|
314
|
-
initial={{ opacity: 0, height: 0 }}
|
|
315
|
-
animate={{ opacity: 1, height: "auto" }}
|
|
316
|
-
exit={{ opacity: 0, height: 0 }}
|
|
317
|
-
className="text-sm text-destructive"
|
|
318
|
-
>
|
|
319
|
-
{error.message as string}
|
|
320
|
-
</motion.p>
|
|
321
|
-
)}
|
|
322
|
-
</AnimatePresence>
|
|
323
|
-
</motion.div>
|
|
324
|
-
)
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
const gridClassName = layout === "grid" ? `grid grid-cols-1 md:grid-cols-${columns} gap-6` : "space-y-6"
|
|
328
|
-
|
|
329
|
-
return (
|
|
330
|
-
<Card className={cn("w-full max-w-4xl", className)}>
|
|
331
|
-
<CardHeader>
|
|
332
|
-
<div className="flex items-center justify-between">
|
|
333
|
-
<div>
|
|
334
|
-
<CardTitle>{title}</CardTitle>
|
|
335
|
-
{description && <CardDescription>{description}</CardDescription>}
|
|
336
|
-
</div>
|
|
337
|
-
<Badge variant="pro" className="ml-2">
|
|
338
|
-
PRO
|
|
339
|
-
</Badge>
|
|
340
|
-
</div>
|
|
341
|
-
|
|
342
|
-
{showProgress && (
|
|
343
|
-
<div className="space-y-2">
|
|
344
|
-
<div className="flex justify-between text-sm">
|
|
345
|
-
<span>Progress</span>
|
|
346
|
-
<span>{Math.round(progress)}%</span>
|
|
347
|
-
</div>
|
|
348
|
-
<div className="w-full bg-muted rounded-full h-2">
|
|
349
|
-
<motion.div
|
|
350
|
-
className="bg-primary h-2 rounded-full"
|
|
351
|
-
initial={{ width: 0 }}
|
|
352
|
-
animate={{ width: `${progress}%` }}
|
|
353
|
-
transition={{ duration: 0.3 }}
|
|
354
|
-
/>
|
|
355
|
-
</div>
|
|
356
|
-
</div>
|
|
357
|
-
)}
|
|
358
|
-
</CardHeader>
|
|
359
|
-
|
|
360
|
-
<CardContent>
|
|
361
|
-
<form onSubmit={handleSubmit(handleFormSubmit)} className="space-y-6">
|
|
362
|
-
<div className={gridClassName}>
|
|
363
|
-
{fields.map((field, index) => renderField(field, index))}
|
|
364
|
-
</div>
|
|
365
|
-
|
|
366
|
-
<div className="flex items-center justify-between pt-6">
|
|
367
|
-
<div className="text-sm text-muted-foreground">
|
|
368
|
-
{completedFields}/{fields.length} fields completed
|
|
369
|
-
</div>
|
|
370
|
-
|
|
371
|
-
<Button
|
|
372
|
-
type="submit"
|
|
373
|
-
disabled={isSubmitting || !isValid}
|
|
374
|
-
className="min-w-32"
|
|
375
|
-
>
|
|
376
|
-
{isSubmitting ? (
|
|
377
|
-
<motion.div
|
|
378
|
-
animate={{ rotate: 360 }}
|
|
379
|
-
transition={{ duration: 1, repeat: Infinity, ease: "linear" }}
|
|
380
|
-
className="w-4 h-4 border-2 border-white border-t-transparent rounded-full"
|
|
381
|
-
/>
|
|
382
|
-
) : (
|
|
383
|
-
submitText
|
|
384
|
-
)}
|
|
385
|
-
</Button>
|
|
386
|
-
</div>
|
|
387
|
-
</form>
|
|
388
|
-
</CardContent>
|
|
389
|
-
</Card>
|
|
390
|
-
)
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
export const AdvancedForms: React.FC<AdvancedFormsProps> = ({ className, ...props }) => {
|
|
394
|
-
const { hasProAccess, isLoading } = useSubscription()
|
|
395
|
-
|
|
396
|
-
// If no pro access, show upgrade prompt
|
|
397
|
-
if (!isLoading && !hasProAccess) {
|
|
398
|
-
return (
|
|
399
|
-
<Card className={cn("w-fit", className)}>
|
|
400
|
-
<CardContent className="py-6 text-center">
|
|
401
|
-
<div className="space-y-4">
|
|
402
|
-
<div className="rounded-full bg-purple-100 dark:bg-purple-900/30 p-3 w-fit mx-auto">
|
|
403
|
-
<Lock className="h-6 w-6 text-purple-600 dark:text-purple-400" />
|
|
404
|
-
</div>
|
|
405
|
-
<div>
|
|
406
|
-
<h3 className="font-semibold text-sm mb-2">Pro Feature</h3>
|
|
407
|
-
<p className="text-muted-foreground text-xs mb-4">
|
|
408
|
-
Advanced Forms is available exclusively to MoonUI Pro subscribers.
|
|
409
|
-
</p>
|
|
410
|
-
<a href="/pricing">
|
|
411
|
-
<Button size="sm">
|
|
412
|
-
<Sparkles className="mr-2 h-4 w-4" />
|
|
413
|
-
Upgrade to Pro
|
|
414
|
-
</Button>
|
|
415
|
-
</a>
|
|
416
|
-
</div>
|
|
417
|
-
</div>
|
|
418
|
-
</CardContent>
|
|
419
|
-
</Card>
|
|
420
|
-
)
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return <AdvancedFormsInternal className={className} {...props} />
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
export type { AdvancedFormField, AdvancedFormsProps }
|