@moontra/moonui-pro 2.0.22 → 2.1.0
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.mjs +215 -214
- package/package.json +4 -2
- package/src/__tests__/use-intersection-observer.test.tsx +216 -0
- package/src/__tests__/use-local-storage.test.tsx +174 -0
- package/src/__tests__/use-pro-access.test.tsx +183 -0
- package/src/components/advanced-chart/advanced-chart.test.tsx +281 -0
- package/src/components/advanced-chart/index.tsx +412 -0
- package/src/components/advanced-forms/index.tsx +431 -0
- package/src/components/animated-button/index.tsx +202 -0
- package/src/components/calendar/event-dialog.tsx +372 -0
- package/src/components/calendar/index.tsx +557 -0
- package/src/components/color-picker/index.tsx +434 -0
- package/src/components/dashboard/index.tsx +334 -0
- package/src/components/data-table/data-table.test.tsx +187 -0
- package/src/components/data-table/index.tsx +368 -0
- package/src/components/draggable-list/index.tsx +100 -0
- package/src/components/enhanced/button.tsx +360 -0
- package/src/components/enhanced/card.tsx +272 -0
- package/src/components/enhanced/dialog.tsx +248 -0
- package/src/components/enhanced/index.ts +3 -0
- package/src/components/error-boundary/index.tsx +111 -0
- package/src/components/file-upload/file-upload.test.tsx +242 -0
- package/src/components/file-upload/index.tsx +362 -0
- package/src/components/floating-action-button/index.tsx +209 -0
- package/src/components/github-stars/index.tsx +414 -0
- package/src/components/health-check/index.tsx +441 -0
- package/src/components/hover-card-3d/index.tsx +170 -0
- package/src/components/index.ts +76 -0
- package/src/components/kanban/index.tsx +436 -0
- package/src/components/lazy-component/index.tsx +342 -0
- package/src/components/magnetic-button/index.tsx +170 -0
- package/src/components/memory-efficient-data/index.tsx +352 -0
- package/src/components/optimized-image/index.tsx +427 -0
- package/src/components/performance-debugger/index.tsx +591 -0
- package/src/components/performance-monitor/index.tsx +775 -0
- package/src/components/pinch-zoom/index.tsx +172 -0
- package/src/components/rich-text-editor/index-old-backup.tsx +443 -0
- package/src/components/rich-text-editor/index.tsx +1537 -0
- package/src/components/rich-text-editor/slash-commands-extension.ts +220 -0
- package/src/components/rich-text-editor/slash-commands.css +35 -0
- package/src/components/rich-text-editor/table-styles.css +65 -0
- package/src/components/spotlight-card/index.tsx +194 -0
- package/src/components/swipeable-card/index.tsx +100 -0
- package/src/components/timeline/index.tsx +333 -0
- package/src/components/ui/animated-button.tsx +185 -0
- package/src/components/ui/avatar.tsx +135 -0
- package/src/components/ui/badge.tsx +225 -0
- package/src/components/ui/button.tsx +221 -0
- package/src/components/ui/card.tsx +141 -0
- package/src/components/ui/checkbox.tsx +256 -0
- package/src/components/ui/color-picker.tsx +95 -0
- package/src/components/ui/dialog.tsx +332 -0
- package/src/components/ui/dropdown-menu.tsx +200 -0
- package/src/components/ui/hover-card-3d.tsx +103 -0
- package/src/components/ui/index.ts +33 -0
- package/src/components/ui/input.tsx +219 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/magnetic-button.tsx +129 -0
- package/src/components/ui/popover.tsx +183 -0
- package/src/components/ui/select.tsx +273 -0
- package/src/components/ui/separator.tsx +140 -0
- package/src/components/ui/slider.tsx +351 -0
- package/src/components/ui/spotlight-card.tsx +119 -0
- package/src/components/ui/switch.tsx +83 -0
- package/src/components/ui/tabs.tsx +195 -0
- package/src/components/ui/textarea.tsx +25 -0
- package/src/components/ui/toast.tsx +313 -0
- package/src/components/ui/tooltip.tsx +152 -0
- package/src/components/virtual-list/index.tsx +369 -0
- package/src/hooks/use-chart.ts +205 -0
- package/src/hooks/use-data-table.ts +182 -0
- package/src/hooks/use-docs-pro-access.ts +13 -0
- package/src/hooks/use-license-check.ts +65 -0
- package/src/hooks/use-subscription.ts +19 -0
- package/src/index.ts +14 -0
- package/src/lib/micro-interactions.ts +255 -0
- package/src/lib/utils.ts +6 -0
- package/src/patterns/login-form/index.tsx +276 -0
- package/src/patterns/login-form/types.ts +67 -0
- package/src/setupTests.ts +41 -0
- package/src/styles/design-system.css +365 -0
- package/src/styles/index.css +4 -0
- package/src/styles/tailwind.css +6 -0
- package/src/styles/tokens.css +453 -0
- package/src/types/moonui.d.ts +22 -0
- package/src/use-intersection-observer.tsx +154 -0
- package/src/use-local-storage.tsx +71 -0
- package/src/use-paddle.ts +138 -0
- package/src/use-performance-optimizer.ts +379 -0
- package/src/use-pro-access.ts +141 -0
- package/src/use-scroll-animation.ts +221 -0
- package/src/use-subscription.ts +37 -0
- package/src/use-toast.ts +32 -0
- package/src/utils/chart-helpers.ts +257 -0
- package/src/utils/cn.ts +69 -0
- package/src/utils/data-processing.ts +151 -0
- package/src/utils/license-guard.tsx +177 -0
- package/src/utils/license-validator.tsx +183 -0
- package/src/utils/package-guard.ts +60 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
5
|
+
import { Check, Minus } from "lucide-react";
|
|
6
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
7
|
+
|
|
8
|
+
import { cn } from "../../lib/utils";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checkbox Bileşeni
|
|
12
|
+
*
|
|
13
|
+
* Erişilebilir, özelleştirilebilir ve tema sistemiyle tam entegre checkbox bileşeni.
|
|
14
|
+
* Form elemanları ve seçim listeleri için kullanılır.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const checkboxVariants = cva(
|
|
18
|
+
"peer shrink-0 border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:text-primary-foreground",
|
|
19
|
+
{
|
|
20
|
+
variants: {
|
|
21
|
+
variant: {
|
|
22
|
+
default: "border-border bg-background data-[state=checked]:bg-primary data-[state=checked]:border-primary",
|
|
23
|
+
outline: "border-border bg-transparent data-[state=checked]:bg-primary data-[state=checked]:border-primary",
|
|
24
|
+
muted: "border-border bg-accent data-[state=checked]:bg-primary data-[state=checked]:border-primary",
|
|
25
|
+
ghost: "border-transparent bg-transparent hover:bg-accent data-[state=checked]:bg-primary data-[state=checked]:border-primary",
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
sm: "h-3.5 w-3.5",
|
|
29
|
+
default: "h-4 w-4",
|
|
30
|
+
md: "h-5 w-5",
|
|
31
|
+
lg: "h-6 w-6",
|
|
32
|
+
},
|
|
33
|
+
radius: {
|
|
34
|
+
none: "rounded-none",
|
|
35
|
+
sm: "rounded-sm",
|
|
36
|
+
default: "rounded-sm",
|
|
37
|
+
md: "rounded-md",
|
|
38
|
+
full: "rounded-full",
|
|
39
|
+
},
|
|
40
|
+
animation: {
|
|
41
|
+
none: "",
|
|
42
|
+
subtle: "transition-all duration-200",
|
|
43
|
+
default: "transition-all duration-200",
|
|
44
|
+
bounce: "transition-all duration-200",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
variant: "default",
|
|
49
|
+
size: "default",
|
|
50
|
+
radius: "default",
|
|
51
|
+
animation: "default",
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export interface CheckboxProps
|
|
57
|
+
extends React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,
|
|
58
|
+
VariantProps<typeof checkboxVariants> {
|
|
59
|
+
/**
|
|
60
|
+
* İndeterminate durumu - grup seçimlerinde bazı öğeler seçilmişse kullanılır
|
|
61
|
+
*/
|
|
62
|
+
indeterminate?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Özel ikon komponenti
|
|
65
|
+
*/
|
|
66
|
+
icon?: React.ReactNode;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const Checkbox = React.forwardRef<
|
|
70
|
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
71
|
+
CheckboxProps
|
|
72
|
+
>(({
|
|
73
|
+
className,
|
|
74
|
+
variant,
|
|
75
|
+
size,
|
|
76
|
+
radius,
|
|
77
|
+
animation,
|
|
78
|
+
indeterminate = false,
|
|
79
|
+
icon,
|
|
80
|
+
checked,
|
|
81
|
+
...props
|
|
82
|
+
}, ref) => {
|
|
83
|
+
// Indeterminate state yönetimi
|
|
84
|
+
const [isIndeterminate, setIsIndeterminate] = React.useState(indeterminate);
|
|
85
|
+
|
|
86
|
+
React.useEffect(() => {
|
|
87
|
+
setIsIndeterminate(indeterminate);
|
|
88
|
+
}, [indeterminate]);
|
|
89
|
+
|
|
90
|
+
// Checked state override, indeterminate olduğunda
|
|
91
|
+
const effectiveChecked = isIndeterminate ? false : checked;
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<CheckboxPrimitive.Root
|
|
95
|
+
ref={ref}
|
|
96
|
+
checked={effectiveChecked}
|
|
97
|
+
className={cn(checkboxVariants({ variant, size, radius, animation }), className)}
|
|
98
|
+
{...props}
|
|
99
|
+
>
|
|
100
|
+
<CheckboxPrimitive.Indicator
|
|
101
|
+
className={cn(
|
|
102
|
+
"flex items-center justify-center text-current",
|
|
103
|
+
animation === "bounce" && "data-[state=checked]:animate-bounce"
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
{isIndeterminate ? (
|
|
107
|
+
<Minus className="h-[65%] w-[65%]" />
|
|
108
|
+
) : icon ? (
|
|
109
|
+
icon
|
|
110
|
+
) : (
|
|
111
|
+
<Check className="h-[65%] w-[65%]" />
|
|
112
|
+
)}
|
|
113
|
+
</CheckboxPrimitive.Indicator>
|
|
114
|
+
</CheckboxPrimitive.Root>
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
118
|
+
|
|
119
|
+
// CheckboxGroup bileşeni
|
|
120
|
+
interface CheckboxGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
121
|
+
/**
|
|
122
|
+
* Grup içi yerleşim - dikey veya yatay
|
|
123
|
+
*/
|
|
124
|
+
orientation?: "horizontal" | "vertical";
|
|
125
|
+
/**
|
|
126
|
+
* Öğeler arasındaki boşluk (piksel)
|
|
127
|
+
*/
|
|
128
|
+
spacing?: number | string;
|
|
129
|
+
/**
|
|
130
|
+
* Alt bileşenler
|
|
131
|
+
*/
|
|
132
|
+
children: React.ReactNode;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const CheckboxGroup = React.forwardRef<HTMLDivElement, CheckboxGroupProps>(
|
|
136
|
+
({ className, orientation = "vertical", spacing = "1rem", children, ...props }, ref) => {
|
|
137
|
+
return (
|
|
138
|
+
<div
|
|
139
|
+
ref={ref}
|
|
140
|
+
className={cn(
|
|
141
|
+
"flex",
|
|
142
|
+
orientation === "vertical" ? "flex-col" : "flex-row flex-wrap",
|
|
143
|
+
className
|
|
144
|
+
)}
|
|
145
|
+
style={{ gap: spacing }}
|
|
146
|
+
role="group"
|
|
147
|
+
{...props}
|
|
148
|
+
>
|
|
149
|
+
{children}
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
CheckboxGroup.displayName = "CheckboxGroup";
|
|
155
|
+
|
|
156
|
+
// CheckboxLabel bileşeni
|
|
157
|
+
interface CheckboxLabelProps extends React.HTMLAttributes<HTMLLabelElement> {
|
|
158
|
+
/**
|
|
159
|
+
* Checkbox bileşeni için HTML id
|
|
160
|
+
*/
|
|
161
|
+
htmlFor?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Label içeriği
|
|
164
|
+
*/
|
|
165
|
+
children: React.ReactNode;
|
|
166
|
+
/**
|
|
167
|
+
* Checkbox öncesi veya sonrası
|
|
168
|
+
*/
|
|
169
|
+
position?: "start" | "end";
|
|
170
|
+
/**
|
|
171
|
+
* Devre dışı durum stili
|
|
172
|
+
*/
|
|
173
|
+
disabled?: boolean;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const CheckboxLabel = React.forwardRef<HTMLLabelElement, CheckboxLabelProps>(
|
|
177
|
+
({ className, htmlFor, children, position = "end", disabled = false, ...props }, ref) => {
|
|
178
|
+
return (
|
|
179
|
+
<label
|
|
180
|
+
ref={ref}
|
|
181
|
+
htmlFor={htmlFor}
|
|
182
|
+
className={cn(
|
|
183
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
184
|
+
position === "start" ? "mr-2" : "ml-2",
|
|
185
|
+
disabled && "cursor-not-allowed opacity-70",
|
|
186
|
+
className
|
|
187
|
+
)}
|
|
188
|
+
{...props}
|
|
189
|
+
>
|
|
190
|
+
{children}
|
|
191
|
+
</label>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
CheckboxLabel.displayName = "CheckboxLabel";
|
|
196
|
+
|
|
197
|
+
// Checkbox ve Label içeren bileşen
|
|
198
|
+
interface CheckboxWithLabelProps extends CheckboxProps {
|
|
199
|
+
/**
|
|
200
|
+
* Label içeriği
|
|
201
|
+
*/
|
|
202
|
+
label: React.ReactNode;
|
|
203
|
+
/**
|
|
204
|
+
* Label pozisyonu
|
|
205
|
+
*/
|
|
206
|
+
labelPosition?: "start" | "end";
|
|
207
|
+
/**
|
|
208
|
+
* Label için HTML sınıfları
|
|
209
|
+
*/
|
|
210
|
+
labelClassName?: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const CheckboxWithLabel = React.forwardRef<
|
|
214
|
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
215
|
+
CheckboxWithLabelProps
|
|
216
|
+
>(({
|
|
217
|
+
id,
|
|
218
|
+
label,
|
|
219
|
+
labelPosition = "end",
|
|
220
|
+
labelClassName,
|
|
221
|
+
...checkboxProps
|
|
222
|
+
}, ref) => {
|
|
223
|
+
const generatedId = React.useId();
|
|
224
|
+
const checkboxId = id || generatedId;
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<div className="flex items-center">
|
|
228
|
+
{labelPosition === "start" && (
|
|
229
|
+
<CheckboxLabel
|
|
230
|
+
htmlFor={checkboxId}
|
|
231
|
+
position="start"
|
|
232
|
+
disabled={checkboxProps.disabled}
|
|
233
|
+
className={labelClassName}
|
|
234
|
+
>
|
|
235
|
+
{label}
|
|
236
|
+
</CheckboxLabel>
|
|
237
|
+
)}
|
|
238
|
+
|
|
239
|
+
<Checkbox ref={ref} id={checkboxId} {...checkboxProps} />
|
|
240
|
+
|
|
241
|
+
{labelPosition === "end" && (
|
|
242
|
+
<CheckboxLabel
|
|
243
|
+
htmlFor={checkboxId}
|
|
244
|
+
position="end"
|
|
245
|
+
disabled={checkboxProps.disabled}
|
|
246
|
+
className={labelClassName}
|
|
247
|
+
>
|
|
248
|
+
{label}
|
|
249
|
+
</CheckboxLabel>
|
|
250
|
+
)}
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
CheckboxWithLabel.displayName = "CheckboxWithLabel";
|
|
255
|
+
|
|
256
|
+
export { Checkbox, CheckboxGroup, CheckboxLabel, CheckboxWithLabel };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import React, { useState } from "react"
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
export interface ColorPickerProps {
|
|
7
|
+
value?: string
|
|
8
|
+
onChange?: (color: string) => void
|
|
9
|
+
className?: string
|
|
10
|
+
showInput?: boolean
|
|
11
|
+
showPresets?: boolean
|
|
12
|
+
size?: string
|
|
13
|
+
presets?: string[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const defaultColors = [
|
|
17
|
+
"#000000", "#374151", "#EF4444", "#F97316",
|
|
18
|
+
"#F59E0B", "#EAB308", "#22C55E", "#10B981",
|
|
19
|
+
"#06B6D4", "#3B82F6", "#6366F1", "#8B5CF6",
|
|
20
|
+
"#A855F7", "#D946EF", "#EC4899", "#F43F5E"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
// React 19 compatible - removed forwardRef
|
|
24
|
+
export const ColorPicker = ({
|
|
25
|
+
value = "#000000",
|
|
26
|
+
onChange,
|
|
27
|
+
className,
|
|
28
|
+
showInput = false,
|
|
29
|
+
showPresets = true,
|
|
30
|
+
size = "default",
|
|
31
|
+
presets = defaultColors
|
|
32
|
+
}: ColorPickerProps) => {
|
|
33
|
+
const [currentColor, setCurrentColor] = useState(value)
|
|
34
|
+
|
|
35
|
+
const handleColorChange = (color: string) => {
|
|
36
|
+
setCurrentColor(color)
|
|
37
|
+
onChange?.(color)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const sizeClasses = {
|
|
41
|
+
sm: "w-6 h-6",
|
|
42
|
+
default: "w-8 h-8",
|
|
43
|
+
lg: "w-10 h-10"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className={cn("flex flex-col gap-2", className)}>
|
|
48
|
+
{showInput && (
|
|
49
|
+
<div className="flex gap-2 items-center">
|
|
50
|
+
<input
|
|
51
|
+
type="color"
|
|
52
|
+
value={currentColor}
|
|
53
|
+
onChange={(e) => handleColorChange(e.target.value)}
|
|
54
|
+
className={cn("rounded border cursor-pointer", sizeClasses[size as keyof typeof sizeClasses] || sizeClasses.default)}
|
|
55
|
+
/>
|
|
56
|
+
<input
|
|
57
|
+
type="text"
|
|
58
|
+
value={currentColor}
|
|
59
|
+
onChange={(e) => handleColorChange(e.target.value)}
|
|
60
|
+
className="px-2 py-1 border rounded text-sm font-mono"
|
|
61
|
+
placeholder="#000000"
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
{!showInput && (
|
|
67
|
+
<input
|
|
68
|
+
type="color"
|
|
69
|
+
value={currentColor}
|
|
70
|
+
onChange={(e) => handleColorChange(e.target.value)}
|
|
71
|
+
className={cn("rounded border cursor-pointer", sizeClasses[size as keyof typeof sizeClasses] || sizeClasses.default)}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
|
|
75
|
+
{showPresets && presets && presets.length > 0 && (
|
|
76
|
+
<div className="flex flex-wrap gap-1">
|
|
77
|
+
{presets.map((color) => (
|
|
78
|
+
<button
|
|
79
|
+
key={color}
|
|
80
|
+
type="button"
|
|
81
|
+
onClick={() => handleColorChange(color)}
|
|
82
|
+
className={cn(
|
|
83
|
+
"w-6 h-6 rounded border-2 hover:scale-110 transition-transform",
|
|
84
|
+
currentColor === color ? "border-gray-900 dark:border-gray-100" : "border-transparent"
|
|
85
|
+
)}
|
|
86
|
+
style={{ backgroundColor: color }}
|
|
87
|
+
/>
|
|
88
|
+
))}
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default ColorPicker
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
+
import { Check, Loader2, X } from "lucide-react";
|
|
7
|
+
|
|
8
|
+
import { cn } from "../../lib/utils";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Premium Dialog Component
|
|
12
|
+
*
|
|
13
|
+
* Modern, accessible and customizable modal dialog component.
|
|
14
|
+
* Enhances user experience with variants, sizes and rich features.
|
|
15
|
+
* Provides a premium appearance with dark and light mode compatibility and fluid animations.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const Dialog = DialogPrimitive.Root;
|
|
19
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
20
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
21
|
+
const DialogClose = DialogPrimitive.Close;
|
|
22
|
+
|
|
23
|
+
const overlayVariants = cva(
|
|
24
|
+
"fixed inset-0 z-50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
25
|
+
{
|
|
26
|
+
variants: {
|
|
27
|
+
variant: {
|
|
28
|
+
default: "bg-black/80",
|
|
29
|
+
subtle: "bg-black/60",
|
|
30
|
+
blur: "bg-black/40 backdrop-blur-md",
|
|
31
|
+
minimal: "bg-black/20 backdrop-blur-sm",
|
|
32
|
+
},
|
|
33
|
+
animation: {
|
|
34
|
+
default: "duration-200",
|
|
35
|
+
slow: "duration-300",
|
|
36
|
+
fast: "duration-100",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
variant: "default",
|
|
41
|
+
animation: "default",
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
interface DialogOverlayProps
|
|
47
|
+
extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>,
|
|
48
|
+
VariantProps<typeof overlayVariants> {}
|
|
49
|
+
|
|
50
|
+
const DialogOverlay = React.forwardRef<
|
|
51
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
52
|
+
DialogOverlayProps
|
|
53
|
+
>(({ className, variant, animation, ...props }, ref) => (
|
|
54
|
+
<DialogPrimitive.Overlay
|
|
55
|
+
ref={ref}
|
|
56
|
+
className={cn(overlayVariants({ variant, animation }), className)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
));
|
|
60
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
61
|
+
|
|
62
|
+
const dialogContentVariants = cva(
|
|
63
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background shadow-lg",
|
|
64
|
+
{
|
|
65
|
+
variants: {
|
|
66
|
+
variant: {
|
|
67
|
+
default: "border-gray-200 dark:border-gray-700",
|
|
68
|
+
primary: "border-primary/20 dark:border-primary/30",
|
|
69
|
+
secondary: "border-gray-300 dark:border-gray-600",
|
|
70
|
+
ghost: "border-transparent shadow-xl",
|
|
71
|
+
destructive: "border-error/20 dark:border-error/30",
|
|
72
|
+
},
|
|
73
|
+
size: {
|
|
74
|
+
xs: "max-w-xs p-4",
|
|
75
|
+
sm: "max-w-sm p-5",
|
|
76
|
+
default: "max-w-lg p-6",
|
|
77
|
+
md: "max-w-md p-6",
|
|
78
|
+
lg: "max-w-2xl p-7",
|
|
79
|
+
xl: "max-w-4xl p-8",
|
|
80
|
+
full: "max-w-[95vw] max-h-[95vh] p-6",
|
|
81
|
+
},
|
|
82
|
+
radius: {
|
|
83
|
+
none: "rounded-none",
|
|
84
|
+
sm: "rounded-md",
|
|
85
|
+
default: "rounded-lg",
|
|
86
|
+
lg: "rounded-xl",
|
|
87
|
+
xl: "rounded-2xl",
|
|
88
|
+
full: "rounded-3xl",
|
|
89
|
+
},
|
|
90
|
+
animation: {
|
|
91
|
+
default:
|
|
92
|
+
"duration-200 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-95 data-[state=open]:zoom-in-95",
|
|
93
|
+
fade: "duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
94
|
+
zoom: "duration-200 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-95 data-[state=open]:zoom-in-95",
|
|
95
|
+
slide: "duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
|
96
|
+
none: "",
|
|
97
|
+
},
|
|
98
|
+
position: {
|
|
99
|
+
default: "top-[50%]",
|
|
100
|
+
top: "top-[5%]",
|
|
101
|
+
bottom: "bottom-[5%] top-auto translate-y-0",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
defaultVariants: {
|
|
105
|
+
variant: "default",
|
|
106
|
+
size: "default",
|
|
107
|
+
radius: "default",
|
|
108
|
+
animation: "default",
|
|
109
|
+
position: "default",
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
interface DialogContentProps
|
|
115
|
+
extends Omit<React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, 'title'>,
|
|
116
|
+
VariantProps<typeof dialogContentVariants> {
|
|
117
|
+
/** X butonunu gizle */
|
|
118
|
+
hideCloseButton?: boolean;
|
|
119
|
+
/** Overlay varyantı */
|
|
120
|
+
overlayVariant?: VariantProps<typeof overlayVariants>["variant"];
|
|
121
|
+
/** Overlay animasyonu */
|
|
122
|
+
overlayAnimation?: VariantProps<typeof overlayVariants>["animation"];
|
|
123
|
+
/** İçerik başlığı (hızlı kullanım için) */
|
|
124
|
+
title?: React.ReactNode;
|
|
125
|
+
/** İçerik açıklaması (hızlı kullanım için) */
|
|
126
|
+
description?: React.ReactNode;
|
|
127
|
+
/** Başlık ikonu */
|
|
128
|
+
icon?: React.ReactNode;
|
|
129
|
+
/** Yükleniyor durumu */
|
|
130
|
+
loading?: boolean;
|
|
131
|
+
/** Success durumu */
|
|
132
|
+
success?: boolean;
|
|
133
|
+
/** Özel onClose handler */
|
|
134
|
+
onClose?: () => void;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const DialogContent = React.forwardRef<
|
|
138
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
139
|
+
DialogContentProps
|
|
140
|
+
>(
|
|
141
|
+
(
|
|
142
|
+
{
|
|
143
|
+
className,
|
|
144
|
+
children,
|
|
145
|
+
variant,
|
|
146
|
+
size,
|
|
147
|
+
radius,
|
|
148
|
+
animation,
|
|
149
|
+
position,
|
|
150
|
+
overlayVariant = "default",
|
|
151
|
+
overlayAnimation = "default",
|
|
152
|
+
hideCloseButton = false,
|
|
153
|
+
title,
|
|
154
|
+
description,
|
|
155
|
+
icon,
|
|
156
|
+
loading = false,
|
|
157
|
+
success = false,
|
|
158
|
+
onClose,
|
|
159
|
+
...props
|
|
160
|
+
},
|
|
161
|
+
ref
|
|
162
|
+
) => {
|
|
163
|
+
// Capturing the close function through the Radix Dialog API
|
|
164
|
+
const handleClose = () => {
|
|
165
|
+
if (onClose) {
|
|
166
|
+
onClose();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<DialogPortal>
|
|
172
|
+
<DialogOverlay
|
|
173
|
+
variant={overlayVariant}
|
|
174
|
+
animation={overlayAnimation}
|
|
175
|
+
onClick={hideCloseButton ? undefined : handleClose}
|
|
176
|
+
/>
|
|
177
|
+
<DialogPrimitive.Content
|
|
178
|
+
ref={ref}
|
|
179
|
+
onEscapeKeyDown={hideCloseButton ? undefined : handleClose}
|
|
180
|
+
onInteractOutside={
|
|
181
|
+
hideCloseButton ? undefined : handleClose
|
|
182
|
+
}
|
|
183
|
+
className={cn(
|
|
184
|
+
dialogContentVariants({
|
|
185
|
+
variant,
|
|
186
|
+
size,
|
|
187
|
+
radius,
|
|
188
|
+
animation,
|
|
189
|
+
position,
|
|
190
|
+
}),
|
|
191
|
+
"outline-none",
|
|
192
|
+
loading && "pointer-events-none",
|
|
193
|
+
success && "border-success/40",
|
|
194
|
+
className
|
|
195
|
+
)}
|
|
196
|
+
{...props}
|
|
197
|
+
>
|
|
198
|
+
{/* Başlık ve açıklama varsa otomatik olarak DialogHeader oluştur */}
|
|
199
|
+
{(title || description || icon) && (
|
|
200
|
+
<DialogHeader className="flex gap-4">
|
|
201
|
+
{/* İkon veya loading/success durumları */}
|
|
202
|
+
{(icon || loading || success) && (
|
|
203
|
+
<div className="flex shrink-0 items-center justify-center">
|
|
204
|
+
{loading && (
|
|
205
|
+
<Loader2 className="h-5 w-5 animate-spin text-primary" />
|
|
206
|
+
)}
|
|
207
|
+
{success && (
|
|
208
|
+
<Check className="h-5 w-5 text-success" />
|
|
209
|
+
)}
|
|
210
|
+
{!loading && !success && icon && (
|
|
211
|
+
<span className="text-primary">
|
|
212
|
+
{icon}
|
|
213
|
+
</span>
|
|
214
|
+
)}
|
|
215
|
+
</div>
|
|
216
|
+
)}
|
|
217
|
+
<div className="flex-1">
|
|
218
|
+
{title && <DialogTitle>{title}</DialogTitle>}
|
|
219
|
+
{description && (
|
|
220
|
+
<DialogDescription>
|
|
221
|
+
{description}
|
|
222
|
+
</DialogDescription>
|
|
223
|
+
)}
|
|
224
|
+
</div>
|
|
225
|
+
</DialogHeader>
|
|
226
|
+
)}
|
|
227
|
+
|
|
228
|
+
{/* Main content */}
|
|
229
|
+
{children}
|
|
230
|
+
|
|
231
|
+
{/* Close button */}
|
|
232
|
+
{!hideCloseButton && (
|
|
233
|
+
<DialogPrimitive.Close
|
|
234
|
+
onClick={handleClose}
|
|
235
|
+
className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:ring-offset-2 disabled:pointer-events-none dark:text-gray-300 dark:hover:text-white"
|
|
236
|
+
>
|
|
237
|
+
<X className="h-4 w-4" />
|
|
238
|
+
<span className="sr-only">Close</span>
|
|
239
|
+
</DialogPrimitive.Close>
|
|
240
|
+
)}
|
|
241
|
+
</DialogPrimitive.Content>
|
|
242
|
+
</DialogPortal>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
247
|
+
|
|
248
|
+
const DialogHeader = ({
|
|
249
|
+
className,
|
|
250
|
+
...props
|
|
251
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
252
|
+
<div
|
|
253
|
+
className={cn(
|
|
254
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
255
|
+
className
|
|
256
|
+
)}
|
|
257
|
+
{...props}
|
|
258
|
+
/>
|
|
259
|
+
);
|
|
260
|
+
DialogHeader.displayName = "DialogHeader";
|
|
261
|
+
|
|
262
|
+
const DialogFooter = ({
|
|
263
|
+
className,
|
|
264
|
+
...props
|
|
265
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
266
|
+
<div
|
|
267
|
+
className={cn(
|
|
268
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end sm:space-x-2 mt-6",
|
|
269
|
+
className
|
|
270
|
+
)}
|
|
271
|
+
{...props}
|
|
272
|
+
/>
|
|
273
|
+
);
|
|
274
|
+
DialogFooter.displayName = "DialogFooter";
|
|
275
|
+
|
|
276
|
+
const DialogTitle = React.forwardRef<
|
|
277
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
278
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
279
|
+
>(({ className, ...props }, ref) => (
|
|
280
|
+
<DialogPrimitive.Title
|
|
281
|
+
ref={ref}
|
|
282
|
+
className={cn(
|
|
283
|
+
"text-xl font-semibold leading-snug tracking-tight dark:text-white",
|
|
284
|
+
className
|
|
285
|
+
)}
|
|
286
|
+
{...props}
|
|
287
|
+
/>
|
|
288
|
+
));
|
|
289
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
290
|
+
|
|
291
|
+
const DialogDescription = React.forwardRef<
|
|
292
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
293
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
294
|
+
>(({ className, ...props }, ref) => (
|
|
295
|
+
<DialogPrimitive.Description
|
|
296
|
+
ref={ref}
|
|
297
|
+
className={cn(
|
|
298
|
+
"text-sm text-muted-foreground leading-normal dark:text-gray-400",
|
|
299
|
+
className
|
|
300
|
+
)}
|
|
301
|
+
{...props}
|
|
302
|
+
/>
|
|
303
|
+
));
|
|
304
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Dialog-Form integration for use with form support
|
|
308
|
+
* Used to integrate form submission processes into the modal
|
|
309
|
+
*/
|
|
310
|
+
const DialogForm = React.forwardRef<
|
|
311
|
+
HTMLFormElement,
|
|
312
|
+
React.HTMLAttributes<HTMLFormElement>
|
|
313
|
+
>(({ className, ...props }, ref) => (
|
|
314
|
+
<form
|
|
315
|
+
ref={ref}
|
|
316
|
+
className={cn("flex flex-col gap-4", className)}
|
|
317
|
+
{...props}
|
|
318
|
+
/>
|
|
319
|
+
));
|
|
320
|
+
DialogForm.displayName = "DialogForm";
|
|
321
|
+
|
|
322
|
+
export {
|
|
323
|
+
Dialog,
|
|
324
|
+
DialogTrigger,
|
|
325
|
+
DialogContent,
|
|
326
|
+
DialogHeader,
|
|
327
|
+
DialogFooter,
|
|
328
|
+
DialogTitle,
|
|
329
|
+
DialogDescription,
|
|
330
|
+
DialogClose,
|
|
331
|
+
DialogForm,
|
|
332
|
+
};
|