@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,432 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React, { useState, useCallback, useRef, useEffect } from "react"
|
|
4
|
-
import { motion } from "framer-motion"
|
|
5
|
-
import { Card, CardContent } from "../ui/card"
|
|
6
|
-
import { Button } from "../ui/button"
|
|
7
|
-
import { Input } from "../ui/input"
|
|
8
|
-
import { Label } from "../ui/label"
|
|
9
|
-
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"
|
|
10
|
-
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"
|
|
11
|
-
import { cn } from "../../lib/utils"
|
|
12
|
-
import { Lock, Sparkles, Palette, Copy, Check, RotateCcw } from "lucide-react"
|
|
13
|
-
import { useSubscription } from "../../hooks/use-subscription"
|
|
14
|
-
|
|
15
|
-
interface ColorPickerProps {
|
|
16
|
-
value?: string
|
|
17
|
-
onChange?: (color: string) => void
|
|
18
|
-
disabled?: boolean
|
|
19
|
-
showPresets?: boolean
|
|
20
|
-
showAlpha?: boolean
|
|
21
|
-
showInput?: boolean
|
|
22
|
-
showCopy?: boolean
|
|
23
|
-
presetColors?: string[]
|
|
24
|
-
className?: string
|
|
25
|
-
size?: "sm" | "default" | "lg"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface HSV {
|
|
29
|
-
h: number
|
|
30
|
-
s: number
|
|
31
|
-
v: number
|
|
32
|
-
a: number
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface RGB {
|
|
36
|
-
r: number
|
|
37
|
-
g: number
|
|
38
|
-
b: number
|
|
39
|
-
a: number
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const ColorPickerInternal: React.FC<ColorPickerProps> = ({
|
|
43
|
-
value = "#3b82f6",
|
|
44
|
-
onChange,
|
|
45
|
-
disabled = false,
|
|
46
|
-
showPresets = true,
|
|
47
|
-
showAlpha = true,
|
|
48
|
-
showInput = true,
|
|
49
|
-
showCopy = true,
|
|
50
|
-
presetColors = [
|
|
51
|
-
"#ef4444", "#f97316", "#f59e0b", "#eab308", "#84cc16", "#22c55e",
|
|
52
|
-
"#10b981", "#14b8a6", "#06b6d4", "#0ea5e9", "#3b82f6", "#6366f1",
|
|
53
|
-
"#8b5cf6", "#a855f7", "#d946ef", "#ec4899", "#f43f5e", "#000000",
|
|
54
|
-
"#404040", "#737373", "#a3a3a3", "#d4d4d4", "#f5f5f5", "#ffffff"
|
|
55
|
-
],
|
|
56
|
-
className,
|
|
57
|
-
size = "default"
|
|
58
|
-
}) => {
|
|
59
|
-
const [currentColor, setCurrentColor] = useState(value)
|
|
60
|
-
const [hsv, setHsv] = useState<HSV>({ h: 0, s: 100, v: 100, a: 1 })
|
|
61
|
-
const [inputValue, setInputValue] = useState(value)
|
|
62
|
-
const [copied, setCopied] = useState(false)
|
|
63
|
-
const [isDragging, setIsDragging] = useState<'hue' | 'saturation' | 'alpha' | null>(null)
|
|
64
|
-
|
|
65
|
-
const saturationRef = useRef<HTMLDivElement>(null)
|
|
66
|
-
const hueRef = useRef<HTMLDivElement>(null)
|
|
67
|
-
const alphaRef = useRef<HTMLDivElement>(null)
|
|
68
|
-
|
|
69
|
-
const sizeClasses = {
|
|
70
|
-
sm: "w-8 h-8",
|
|
71
|
-
default: "w-10 h-10",
|
|
72
|
-
lg: "w-12 h-12"
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Convert color utilities
|
|
76
|
-
const hexToRgb = (hex: string): RGB => {
|
|
77
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
|
|
78
|
-
return result ? {
|
|
79
|
-
r: parseInt(result[1], 16),
|
|
80
|
-
g: parseInt(result[2], 16),
|
|
81
|
-
b: parseInt(result[3], 16),
|
|
82
|
-
a: 1
|
|
83
|
-
} : { r: 0, g: 0, b: 0, a: 1 }
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const rgbToHex = (r: number, g: number, b: number): string => {
|
|
87
|
-
return "#" + [r, g, b].map(x => {
|
|
88
|
-
const hex = Math.round(x).toString(16)
|
|
89
|
-
return hex.length === 1 ? "0" + hex : hex
|
|
90
|
-
}).join("")
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const rgbToHsv = (rgb: RGB): HSV => {
|
|
94
|
-
const r = rgb.r / 255
|
|
95
|
-
const g = rgb.g / 255
|
|
96
|
-
const b = rgb.b / 255
|
|
97
|
-
|
|
98
|
-
const max = Math.max(r, g, b)
|
|
99
|
-
const min = Math.min(r, g, b)
|
|
100
|
-
const diff = max - min
|
|
101
|
-
|
|
102
|
-
let h = 0
|
|
103
|
-
if (diff !== 0) {
|
|
104
|
-
if (max === r) h = ((g - b) / diff) % 6
|
|
105
|
-
else if (max === g) h = (b - r) / diff + 2
|
|
106
|
-
else h = (r - g) / diff + 4
|
|
107
|
-
}
|
|
108
|
-
h = Math.round(h * 60)
|
|
109
|
-
if (h < 0) h += 360
|
|
110
|
-
|
|
111
|
-
const s = max === 0 ? 0 : (diff / max) * 100
|
|
112
|
-
const v = max * 100
|
|
113
|
-
|
|
114
|
-
return { h, s, v, a: rgb.a }
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const hsvToRgb = (hsv: HSV): RGB => {
|
|
118
|
-
const h = hsv.h / 60
|
|
119
|
-
const s = hsv.s / 100
|
|
120
|
-
const v = hsv.v / 100
|
|
121
|
-
|
|
122
|
-
const c = v * s
|
|
123
|
-
const x = c * (1 - Math.abs((h % 2) - 1))
|
|
124
|
-
const m = v - c
|
|
125
|
-
|
|
126
|
-
let r = 0, g = 0, b = 0
|
|
127
|
-
|
|
128
|
-
if (h >= 0 && h < 1) [r, g, b] = [c, x, 0]
|
|
129
|
-
else if (h >= 1 && h < 2) [r, g, b] = [x, c, 0]
|
|
130
|
-
else if (h >= 2 && h < 3) [r, g, b] = [0, c, x]
|
|
131
|
-
else if (h >= 3 && h < 4) [r, g, b] = [0, x, c]
|
|
132
|
-
else if (h >= 4 && h < 5) [r, g, b] = [x, 0, c]
|
|
133
|
-
else if (h >= 5 && h < 6) [r, g, b] = [c, 0, x]
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
r: Math.round((r + m) * 255),
|
|
137
|
-
g: Math.round((g + m) * 255),
|
|
138
|
-
b: Math.round((b + m) * 255),
|
|
139
|
-
a: hsv.a
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const updateColor = useCallback((newHsv: HSV) => {
|
|
144
|
-
setHsv(newHsv)
|
|
145
|
-
const rgb = hsvToRgb(newHsv)
|
|
146
|
-
const hex = rgbToHex(rgb.r, rgb.g, rgb.b)
|
|
147
|
-
setCurrentColor(hex)
|
|
148
|
-
setInputValue(hex)
|
|
149
|
-
onChange?.(hex)
|
|
150
|
-
}, [onChange])
|
|
151
|
-
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
const rgb = hexToRgb(currentColor)
|
|
154
|
-
const newHsv = rgbToHsv(rgb)
|
|
155
|
-
setHsv(newHsv)
|
|
156
|
-
}, [currentColor])
|
|
157
|
-
|
|
158
|
-
const handleSaturationChange = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
|
159
|
-
if (!saturationRef.current) return
|
|
160
|
-
|
|
161
|
-
const rect = saturationRef.current.getBoundingClientRect()
|
|
162
|
-
const x = Math.max(0, Math.min(rect.width, e.clientX - rect.left))
|
|
163
|
-
const y = Math.max(0, Math.min(rect.height, e.clientY - rect.top))
|
|
164
|
-
|
|
165
|
-
const s = (x / rect.width) * 100
|
|
166
|
-
const v = 100 - (y / rect.height) * 100
|
|
167
|
-
|
|
168
|
-
updateColor({ ...hsv, s, v })
|
|
169
|
-
}, [hsv, updateColor])
|
|
170
|
-
|
|
171
|
-
const handleHueChange = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
|
172
|
-
if (!hueRef.current) return
|
|
173
|
-
|
|
174
|
-
const rect = hueRef.current.getBoundingClientRect()
|
|
175
|
-
const x = Math.max(0, Math.min(rect.width, e.clientX - rect.left))
|
|
176
|
-
const h = (x / rect.width) * 360
|
|
177
|
-
|
|
178
|
-
updateColor({ ...hsv, h })
|
|
179
|
-
}, [hsv, updateColor])
|
|
180
|
-
|
|
181
|
-
const handleAlphaChange = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
|
182
|
-
if (!alphaRef.current) return
|
|
183
|
-
|
|
184
|
-
const rect = alphaRef.current.getBoundingClientRect()
|
|
185
|
-
const x = Math.max(0, Math.min(rect.width, e.clientX - rect.left))
|
|
186
|
-
const a = x / rect.width
|
|
187
|
-
|
|
188
|
-
updateColor({ ...hsv, a })
|
|
189
|
-
}, [hsv, updateColor])
|
|
190
|
-
|
|
191
|
-
const handleInputChange = (value: string) => {
|
|
192
|
-
setInputValue(value)
|
|
193
|
-
if (/^#[0-9A-F]{6}$/i.test(value)) {
|
|
194
|
-
setCurrentColor(value)
|
|
195
|
-
onChange?.(value)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const copyToClipboard = async () => {
|
|
200
|
-
try {
|
|
201
|
-
await navigator.clipboard.writeText(currentColor)
|
|
202
|
-
setCopied(true)
|
|
203
|
-
setTimeout(() => setCopied(false), 2000)
|
|
204
|
-
} catch (err) {
|
|
205
|
-
console.error("Failed to copy color:", err)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const handlePresetClick = (color: string) => {
|
|
210
|
-
setCurrentColor(color)
|
|
211
|
-
setInputValue(color)
|
|
212
|
-
onChange?.(color)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const resetColor = () => {
|
|
216
|
-
setCurrentColor(value)
|
|
217
|
-
setInputValue(value)
|
|
218
|
-
onChange?.(value)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return (
|
|
222
|
-
<Popover>
|
|
223
|
-
<PopoverTrigger asChild>
|
|
224
|
-
<Button
|
|
225
|
-
variant="outline"
|
|
226
|
-
className={cn(
|
|
227
|
-
sizeClasses[size],
|
|
228
|
-
"p-1 border-2 border-muted-foreground/20 hover:border-muted-foreground/40",
|
|
229
|
-
disabled && "opacity-50 cursor-not-allowed",
|
|
230
|
-
className
|
|
231
|
-
)}
|
|
232
|
-
disabled={disabled}
|
|
233
|
-
>
|
|
234
|
-
<div
|
|
235
|
-
className="w-full h-full rounded-sm"
|
|
236
|
-
style={{ backgroundColor: currentColor }}
|
|
237
|
-
/>
|
|
238
|
-
</Button>
|
|
239
|
-
</PopoverTrigger>
|
|
240
|
-
|
|
241
|
-
<PopoverContent className="w-80 p-4" side="bottom" align="start">
|
|
242
|
-
<div className="space-y-4">
|
|
243
|
-
{/* Saturation/Brightness Picker */}
|
|
244
|
-
<div className="space-y-2">
|
|
245
|
-
<Label>Color</Label>
|
|
246
|
-
<div
|
|
247
|
-
ref={saturationRef}
|
|
248
|
-
className="relative w-full h-48 rounded-lg cursor-crosshair overflow-hidden"
|
|
249
|
-
style={{
|
|
250
|
-
background: `linear-gradient(to right, white, hsl(${hsv.h}, 100%, 50%)),
|
|
251
|
-
linear-gradient(to top, black, transparent)`
|
|
252
|
-
}}
|
|
253
|
-
onMouseDown={(e) => {
|
|
254
|
-
setIsDragging('saturation')
|
|
255
|
-
handleSaturationChange(e)
|
|
256
|
-
}}
|
|
257
|
-
onMouseMove={(e) => isDragging === 'saturation' && handleSaturationChange(e)}
|
|
258
|
-
>
|
|
259
|
-
<div
|
|
260
|
-
className="absolute w-4 h-4 border-2 border-white rounded-full shadow-lg transform -translate-x-2 -translate-y-2 pointer-events-none"
|
|
261
|
-
style={{
|
|
262
|
-
left: `${hsv.s}%`,
|
|
263
|
-
top: `${100 - hsv.v}%`
|
|
264
|
-
}}
|
|
265
|
-
/>
|
|
266
|
-
</div>
|
|
267
|
-
</div>
|
|
268
|
-
|
|
269
|
-
{/* Hue Slider */}
|
|
270
|
-
<div className="space-y-2">
|
|
271
|
-
<Label>Hue</Label>
|
|
272
|
-
<div
|
|
273
|
-
ref={hueRef}
|
|
274
|
-
className="relative w-full h-4 rounded-lg cursor-pointer"
|
|
275
|
-
style={{
|
|
276
|
-
background: "linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)"
|
|
277
|
-
}}
|
|
278
|
-
onMouseDown={(e) => {
|
|
279
|
-
setIsDragging('hue')
|
|
280
|
-
handleHueChange(e)
|
|
281
|
-
}}
|
|
282
|
-
onMouseMove={(e) => isDragging === 'hue' && handleHueChange(e)}
|
|
283
|
-
>
|
|
284
|
-
<div
|
|
285
|
-
className="absolute w-4 h-4 bg-white border-2 border-gray-300 rounded-full shadow-lg transform -translate-x-2 -translate-y-0 pointer-events-none"
|
|
286
|
-
style={{ left: `${(hsv.h / 360) * 100}%` }}
|
|
287
|
-
/>
|
|
288
|
-
</div>
|
|
289
|
-
</div>
|
|
290
|
-
|
|
291
|
-
{/* Alpha Slider */}
|
|
292
|
-
{showAlpha && (
|
|
293
|
-
<div className="space-y-2">
|
|
294
|
-
<Label>Opacity</Label>
|
|
295
|
-
<div
|
|
296
|
-
ref={alphaRef}
|
|
297
|
-
className="relative w-full h-4 rounded-lg cursor-pointer"
|
|
298
|
-
style={{
|
|
299
|
-
background: `linear-gradient(to right, transparent, ${currentColor}),
|
|
300
|
-
repeating-linear-gradient(45deg, #ccc 0, #ccc 2px, #fff 2px, #fff 4px)`
|
|
301
|
-
}}
|
|
302
|
-
onMouseDown={(e) => {
|
|
303
|
-
setIsDragging('alpha')
|
|
304
|
-
handleAlphaChange(e)
|
|
305
|
-
}}
|
|
306
|
-
onMouseMove={(e) => isDragging === 'alpha' && handleAlphaChange(e)}
|
|
307
|
-
>
|
|
308
|
-
<div
|
|
309
|
-
className="absolute w-4 h-4 bg-white border-2 border-gray-300 rounded-full shadow-lg transform -translate-x-2 -translate-y-0 pointer-events-none"
|
|
310
|
-
style={{ left: `${hsv.a * 100}%` }}
|
|
311
|
-
/>
|
|
312
|
-
</div>
|
|
313
|
-
</div>
|
|
314
|
-
)}
|
|
315
|
-
|
|
316
|
-
{/* Color Input and Copy */}
|
|
317
|
-
{showInput && (
|
|
318
|
-
<div className="flex gap-2">
|
|
319
|
-
<div className="flex-1">
|
|
320
|
-
<Label htmlFor="color-input">Hex</Label>
|
|
321
|
-
<Input
|
|
322
|
-
id="color-input"
|
|
323
|
-
value={inputValue}
|
|
324
|
-
onChange={(e) => handleInputChange(e.target.value)}
|
|
325
|
-
placeholder="#000000"
|
|
326
|
-
className="font-mono"
|
|
327
|
-
/>
|
|
328
|
-
</div>
|
|
329
|
-
|
|
330
|
-
{showCopy && (
|
|
331
|
-
<div className="flex flex-col gap-2">
|
|
332
|
-
<Label> </Label>
|
|
333
|
-
<Button
|
|
334
|
-
variant="outline"
|
|
335
|
-
size="sm"
|
|
336
|
-
onClick={copyToClipboard}
|
|
337
|
-
className="px-3"
|
|
338
|
-
>
|
|
339
|
-
{copied ? (
|
|
340
|
-
<Check className="h-4 w-4 text-green-500" />
|
|
341
|
-
) : (
|
|
342
|
-
<Copy className="h-4 w-4" />
|
|
343
|
-
)}
|
|
344
|
-
</Button>
|
|
345
|
-
</div>
|
|
346
|
-
)}
|
|
347
|
-
|
|
348
|
-
<div className="flex flex-col gap-2">
|
|
349
|
-
<Label> </Label>
|
|
350
|
-
<Button
|
|
351
|
-
variant="outline"
|
|
352
|
-
size="sm"
|
|
353
|
-
onClick={resetColor}
|
|
354
|
-
className="px-3"
|
|
355
|
-
>
|
|
356
|
-
<RotateCcw className="h-4 w-4" />
|
|
357
|
-
</Button>
|
|
358
|
-
</div>
|
|
359
|
-
</div>
|
|
360
|
-
)}
|
|
361
|
-
|
|
362
|
-
{/* Preset Colors */}
|
|
363
|
-
{showPresets && (
|
|
364
|
-
<div className="space-y-2">
|
|
365
|
-
<Label>Presets</Label>
|
|
366
|
-
<div className="grid grid-cols-8 gap-2">
|
|
367
|
-
{presetColors.map((color, index) => (
|
|
368
|
-
<motion.button
|
|
369
|
-
key={color}
|
|
370
|
-
className="w-8 h-8 rounded-md border-2 border-muted-foreground/20 hover:border-muted-foreground/40 transition-colors"
|
|
371
|
-
style={{ backgroundColor: color }}
|
|
372
|
-
onClick={() => handlePresetClick(color)}
|
|
373
|
-
whileHover={{ scale: 1.1 }}
|
|
374
|
-
whileTap={{ scale: 0.95 }}
|
|
375
|
-
initial={{ opacity: 0, scale: 0 }}
|
|
376
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
377
|
-
transition={{ delay: index * 0.02 }}
|
|
378
|
-
/>
|
|
379
|
-
))}
|
|
380
|
-
</div>
|
|
381
|
-
</div>
|
|
382
|
-
)}
|
|
383
|
-
</div>
|
|
384
|
-
</PopoverContent>
|
|
385
|
-
</Popover>
|
|
386
|
-
)
|
|
387
|
-
|
|
388
|
-
// Mouse up handler for the entire document
|
|
389
|
-
useEffect(() => {
|
|
390
|
-
const handleMouseUp = () => setIsDragging(null)
|
|
391
|
-
document.addEventListener('mouseup', handleMouseUp)
|
|
392
|
-
return () => document.removeEventListener('mouseup', handleMouseUp)
|
|
393
|
-
}, [])
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
export const ColorPicker: React.FC<ColorPickerProps> = ({ className, ...props }) => {
|
|
397
|
-
// Check if we're in docs mode or have pro access
|
|
398
|
-
const { hasProAccess, isLoading } = useSubscription()
|
|
399
|
-
|
|
400
|
-
// In docs mode, always show the component
|
|
401
|
-
|
|
402
|
-
// If not in docs mode and no pro access, show upgrade prompt
|
|
403
|
-
if (!isLoading && !hasProAccess) {
|
|
404
|
-
return (
|
|
405
|
-
<Card className={cn("w-fit", className)}>
|
|
406
|
-
<CardContent className="py-6 text-center">
|
|
407
|
-
<div className="space-y-4">
|
|
408
|
-
<div className="rounded-full bg-purple-100 dark:bg-purple-900/30 p-3 w-fit mx-auto">
|
|
409
|
-
<Lock className="h-6 w-6 text-purple-600 dark:text-purple-400" />
|
|
410
|
-
</div>
|
|
411
|
-
<div>
|
|
412
|
-
<h3 className="font-semibold text-sm mb-2">Pro Feature</h3>
|
|
413
|
-
<p className="text-muted-foreground text-xs mb-4">
|
|
414
|
-
Color Picker is available exclusively to MoonUI Pro subscribers.
|
|
415
|
-
</p>
|
|
416
|
-
<a href="/pricing">
|
|
417
|
-
<Button size="sm">
|
|
418
|
-
<Sparkles className="mr-2 h-4 w-4" />
|
|
419
|
-
Upgrade to Pro
|
|
420
|
-
</Button>
|
|
421
|
-
</a>
|
|
422
|
-
</div>
|
|
423
|
-
</div>
|
|
424
|
-
</CardContent>
|
|
425
|
-
</Card>
|
|
426
|
-
)
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
return <ColorPickerInternal className={className} {...props} />
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
export type { ColorPickerProps }
|