@moontra/moonui 2.0.7 → 2.0.9

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.
Files changed (94) hide show
  1. package/package.json +26 -19
  2. package/src/__tests__/use-intersection-observer.test.tsx +216 -0
  3. package/src/__tests__/use-local-storage.test.tsx +174 -0
  4. package/src/__tests__/use-pro-access.test.tsx +183 -0
  5. package/src/components/ui/__tests__/accordion.test.tsx +571 -0
  6. package/src/components/ui/__tests__/alert.test.tsx +484 -0
  7. package/src/components/ui/__tests__/aspect-ratio.test.tsx +492 -0
  8. package/src/components/ui/__tests__/avatar.test.tsx +382 -0
  9. package/src/components/ui/__tests__/badge.test.tsx +364 -0
  10. package/src/components/ui/__tests__/breadcrumb.test.tsx +687 -0
  11. package/src/components/ui/__tests__/button.test.tsx +91 -0
  12. package/src/components/ui/__tests__/card.test.tsx +104 -0
  13. package/src/components/ui/__tests__/checkbox.test.tsx +591 -0
  14. package/src/components/ui/__tests__/collapsible.test.tsx +592 -0
  15. package/src/components/ui/__tests__/color-picker.test.tsx +365 -0
  16. package/src/components/ui/__tests__/command.test.tsx +677 -0
  17. package/src/components/ui/__tests__/data-table.test.tsx +256 -0
  18. package/src/components/ui/__tests__/date-picker.test.tsx +320 -0
  19. package/src/components/ui/__tests__/dialog.test.tsx +764 -0
  20. package/src/components/ui/__tests__/input.test.tsx +318 -0
  21. package/src/components/ui/__tests__/label.test.tsx +103 -0
  22. package/src/components/ui/__tests__/popover.test.tsx +637 -0
  23. package/src/components/ui/__tests__/progress.test.tsx +382 -0
  24. package/src/components/ui/__tests__/radio-group.test.tsx +555 -0
  25. package/src/components/ui/__tests__/select.test.tsx +705 -0
  26. package/src/components/ui/__tests__/skeleton.test.tsx +253 -0
  27. package/src/components/ui/__tests__/slider.test.tsx +493 -0
  28. package/src/components/ui/__tests__/switch.test.tsx +372 -0
  29. package/src/components/ui/__tests__/table.test.tsx +824 -0
  30. package/src/components/ui/__tests__/tabs.test.tsx +887 -0
  31. package/src/components/ui/__tests__/toast.test.tsx +458 -0
  32. package/src/components/ui/__tests__/tooltip.test.tsx +583 -0
  33. package/src/components/ui/accordion.tsx +63 -0
  34. package/src/components/ui/alert.tsx +130 -0
  35. package/src/components/ui/aspect-ratio.tsx +72 -0
  36. package/src/components/ui/avatar.tsx +135 -0
  37. package/src/components/ui/badge.tsx +225 -0
  38. package/src/components/ui/breadcrumb.tsx +207 -0
  39. package/src/components/ui/button.stories.tsx +162 -0
  40. package/src/components/ui/button.tsx +221 -0
  41. package/src/components/ui/calendar.tsx +262 -0
  42. package/src/components/ui/card.stories.tsx +208 -0
  43. package/src/components/ui/card.tsx +141 -0
  44. package/src/components/ui/checkbox.tsx +256 -0
  45. package/src/components/ui/collapsible.tsx +129 -0
  46. package/src/components/ui/color-picker.tsx +664 -0
  47. package/src/components/ui/command.tsx +218 -0
  48. package/src/components/ui/data-table.stories.tsx +509 -0
  49. package/src/components/ui/data-table.tsx +623 -0
  50. package/src/components/ui/date-picker.stories.tsx +321 -0
  51. package/src/components/ui/date-picker.tsx +603 -0
  52. package/src/components/ui/dialog.tsx +332 -0
  53. package/src/components/ui/dropdown-menu.tsx +200 -0
  54. package/src/components/ui/file-upload.tsx +400 -0
  55. package/src/components/ui/github-stars.tsx +201 -0
  56. package/src/components/ui/index.ts +12 -0
  57. package/src/components/ui/input.stories.tsx +255 -0
  58. package/src/components/ui/input.tsx +219 -0
  59. package/src/components/ui/label.tsx +26 -0
  60. package/src/components/ui/locked-component.tsx +215 -0
  61. package/src/components/ui/moon-logo.tsx +97 -0
  62. package/src/components/ui/pagination.tsx +116 -0
  63. package/src/components/ui/popover.tsx +183 -0
  64. package/src/components/ui/progress.tsx +182 -0
  65. package/src/components/ui/radio-group.tsx +243 -0
  66. package/src/components/ui/select.tsx +273 -0
  67. package/src/components/ui/separator.tsx +140 -0
  68. package/src/components/ui/simple-editor.tsx +652 -0
  69. package/src/components/ui/skeleton.tsx +351 -0
  70. package/src/components/ui/slider.tsx +351 -0
  71. package/src/components/ui/switch.tsx +83 -0
  72. package/src/components/ui/table.tsx +322 -0
  73. package/src/components/ui/tabs.tsx +195 -0
  74. package/src/components/ui/textarea.tsx +46 -0
  75. package/src/components/ui/toast.tsx +313 -0
  76. package/src/components/ui/toggle.tsx +47 -0
  77. package/src/components/ui/tooltip.tsx +152 -0
  78. package/src/docs/theme-system.md +1194 -0
  79. package/src/index.tsx +39 -0
  80. package/src/lib/micro-interactions.ts +255 -0
  81. package/src/lib/theme.tsx +398 -0
  82. package/src/lib/utils.ts +69 -0
  83. package/src/styles/design-system.css +365 -0
  84. package/src/styles/index.css +4 -0
  85. package/src/styles/tailwind.css +6 -0
  86. package/src/styles/tokens.css +453 -0
  87. package/src/use-intersection-observer.tsx +154 -0
  88. package/src/use-local-storage.tsx +71 -0
  89. package/src/use-paddle.ts +138 -0
  90. package/src/use-performance-optimizer.ts +379 -0
  91. package/src/use-pro-access.ts +141 -0
  92. package/src/use-scroll-animation.ts +221 -0
  93. package/src/use-subscription.ts +37 -0
  94. package/src/use-toast.ts +32 -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,129 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
5
+ import { cva, type VariantProps } from "class-variance-authority"
6
+ import { ChevronDown } from "lucide-react"
7
+
8
+ import { cn } from "../../lib/utils"
9
+
10
+ /**
11
+ * Collapsible (Daraltılabilir) Bileşeni
12
+ *
13
+ * İçeriği genişletilip daraltılabilen hafif bir bileşendir.
14
+ * Tema sistemiyle tam entegre, erişilebilir ve özelleştirilebilir.
15
+ */
16
+
17
+ const Collapsible = CollapsiblePrimitive.Root
18
+
19
+ const collapsibleTriggerVariants = cva(
20
+ "flex w-full items-center justify-between transition-all",
21
+ {
22
+ variants: {
23
+ variant: {
24
+ default: "text-foreground hover:text-primary",
25
+ ghost: "text-foreground hover:bg-accent/10 rounded",
26
+ outline: "text-foreground border border-border rounded-t-md hover:bg-accent/5",
27
+ },
28
+ size: {
29
+ sm: "text-xs py-2 px-3",
30
+ default: "text-sm py-3 px-4",
31
+ md: "text-base py-4 px-4",
32
+ lg: "text-lg py-5 px-5",
33
+ },
34
+ },
35
+ defaultVariants: {
36
+ variant: "default",
37
+ size: "default",
38
+ },
39
+ }
40
+ )
41
+
42
+ interface CollapsibleTriggerProps
43
+ extends React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Trigger>,
44
+ VariantProps<typeof collapsibleTriggerVariants> {}
45
+
46
+ const CollapsibleTrigger = React.forwardRef<
47
+ React.ElementRef<typeof CollapsiblePrimitive.Trigger>,
48
+ CollapsibleTriggerProps
49
+ >(({ className, children, variant, size, asChild, ...props }, ref) => {
50
+ // asChild kullanıldığında otomatik ikon eklemeyi atla
51
+ if (asChild) {
52
+ return (
53
+ <CollapsiblePrimitive.Trigger
54
+ ref={ref}
55
+ className={cn(collapsibleTriggerVariants({ variant, size }), className)}
56
+ asChild={asChild}
57
+ {...props}
58
+ >
59
+ {children}
60
+ </CollapsiblePrimitive.Trigger>
61
+ )
62
+ }
63
+
64
+ return (
65
+ <CollapsiblePrimitive.Trigger
66
+ ref={ref}
67
+ className={cn(collapsibleTriggerVariants({ variant, size }), className)}
68
+ {...props}
69
+ >
70
+ {children}
71
+ <ChevronDown className="h-4 w-4 shrink-0 ml-auto transition-transform duration-200 [&[data-state=open]]:rotate-180" />
72
+ </CollapsiblePrimitive.Trigger>
73
+ )
74
+ })
75
+ CollapsibleTrigger.displayName = CollapsiblePrimitive.Trigger.displayName
76
+
77
+ const collapsibleContentVariants = cva(
78
+ "overflow-hidden transition-all data-[state=closed]:animate-collapse-up data-[state=open]:animate-collapse-down",
79
+ {
80
+ variants: {
81
+ variant: {
82
+ default: "text-muted-foreground",
83
+ ghost: "text-muted-foreground rounded-b",
84
+ outline: "text-muted-foreground border border-t-0 border-border rounded-b-md",
85
+ },
86
+ size: {
87
+ sm: "text-xs",
88
+ default: "text-sm",
89
+ md: "text-base",
90
+ lg: "text-lg",
91
+ },
92
+ },
93
+ defaultVariants: {
94
+ variant: "default",
95
+ size: "default",
96
+ },
97
+ }
98
+ )
99
+
100
+ interface CollapsibleContentProps
101
+ extends React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Content>,
102
+ VariantProps<typeof collapsibleContentVariants> {}
103
+
104
+ const CollapsibleContent = React.forwardRef<
105
+ React.ElementRef<typeof CollapsiblePrimitive.Content>,
106
+ CollapsibleContentProps
107
+ >(({ className, children, variant, size, ...props }, ref) => (
108
+ <CollapsiblePrimitive.Content
109
+ ref={ref}
110
+ className={cn(collapsibleContentVariants({ variant, size }), className)}
111
+ {...props}
112
+ >
113
+ <div className="p-4">{children}</div>
114
+ </CollapsiblePrimitive.Content>
115
+ ))
116
+ CollapsibleContent.displayName = CollapsiblePrimitive.Content.displayName
117
+
118
+ export {
119
+ Collapsible,
120
+ CollapsibleTrigger,
121
+ CollapsibleContent,
122
+ collapsibleTriggerVariants,
123
+ collapsibleContentVariants,
124
+ }
125
+
126
+ export type {
127
+ CollapsibleTriggerProps,
128
+ CollapsibleContentProps
129
+ }