@moontra/moonui 3.1.0 → 3.3.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/chunk-VXDFZPDA.global.js +33 -0
- package/dist/{chunk-X5ULQZNC.global.js.map → chunk-VXDFZPDA.global.js.map} +1 -1
- package/dist/index.d.mts +140 -1
- package/dist/index.d.ts +140 -1
- package/dist/index.global.js +365 -52
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +419 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +399 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/components/ui/__tests__/button-group.test.tsx +183 -0
- package/src/components/ui/__tests__/kbd.test.tsx +86 -0
- package/src/components/ui/__tests__/rating.test.tsx +218 -0
- package/src/components/ui/__tests__/spinner.test.tsx +141 -0
- package/src/components/ui/__tests__/toggle-group.test.tsx +293 -0
- package/src/components/ui/button-group.tsx +125 -0
- package/src/components/ui/index.ts +43 -0
- package/src/components/ui/kbd.tsx +66 -0
- package/src/components/ui/rating.tsx +253 -0
- package/src/components/ui/spinner.tsx +112 -0
- package/src/components/ui/toggle-group.tsx +93 -0
- package/dist/chunk-X5ULQZNC.global.js +0 -33
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
+
import { Star } from "lucide-react";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Premium Rating Component
|
|
10
|
+
*
|
|
11
|
+
* Standalone yıldız-değerlendirme bileşeni (input + display).
|
|
12
|
+
* Kontrollü/kontrolsüz kullanım, yarım-yıldız hassasiyeti, salt-gösterim modu
|
|
13
|
+
* ve tam klavye erişilebilirliği (radiogroup) sunar. Dark/light modda uyumludur.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const ratingVariants = cva(
|
|
17
|
+
[
|
|
18
|
+
"moonui-theme inline-flex items-center rounded-md outline-none",
|
|
19
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
20
|
+
],
|
|
21
|
+
{
|
|
22
|
+
variants: {
|
|
23
|
+
size: {
|
|
24
|
+
sm: "gap-0.5",
|
|
25
|
+
md: "gap-1",
|
|
26
|
+
lg: "gap-1.5",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
size: "md",
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Boyuta göre ikon ölçüsü (yarım-yıldız maskesinin hizalanması için sabit px gerekir)
|
|
36
|
+
const iconSizeMap: Record<NonNullable<VariantProps<typeof ratingVariants>["size"]>, string> = {
|
|
37
|
+
sm: "h-4 w-4",
|
|
38
|
+
md: "h-5 w-5",
|
|
39
|
+
lg: "h-6 w-6",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export interface RatingProps
|
|
43
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange">,
|
|
44
|
+
VariantProps<typeof ratingVariants> {
|
|
45
|
+
/** Kontrollü değer (0..max) */
|
|
46
|
+
value?: number;
|
|
47
|
+
/** Kontrolsüz başlangıç değeri */
|
|
48
|
+
defaultValue?: number;
|
|
49
|
+
/** Değer değiştiğinde çağrılır */
|
|
50
|
+
onValueChange?: (value: number) => void;
|
|
51
|
+
/** Yıldız sayısı (varsayılan 5) */
|
|
52
|
+
max?: number;
|
|
53
|
+
/** Salt-gösterim: etkileşim yok, aria-readonly işaretlenir */
|
|
54
|
+
readOnly?: boolean;
|
|
55
|
+
/** Yarım-yıldız desteği (varsayılan "full") */
|
|
56
|
+
precision?: "full" | "half";
|
|
57
|
+
/** Özel ikon (varsayılan lucide Star) */
|
|
58
|
+
icon?: React.ReactNode;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Premium Rating Component
|
|
63
|
+
*
|
|
64
|
+
* @param props.value - Kontrollü değer
|
|
65
|
+
* @param props.defaultValue - Kontrolsüz başlangıç değeri
|
|
66
|
+
* @param props.onValueChange - Değer değişim geri çağrımı
|
|
67
|
+
* @param props.max - Yıldız sayısı (varsayılan 5)
|
|
68
|
+
* @param props.readOnly - Salt-gösterim modu
|
|
69
|
+
* @param props.precision - "full" | "half" hassasiyet
|
|
70
|
+
* @param props.icon - Özel ikon
|
|
71
|
+
* @param props.size - Boyut (sm | md | lg)
|
|
72
|
+
*/
|
|
73
|
+
const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
74
|
+
(
|
|
75
|
+
{
|
|
76
|
+
className,
|
|
77
|
+
value,
|
|
78
|
+
defaultValue,
|
|
79
|
+
onValueChange,
|
|
80
|
+
max = 5,
|
|
81
|
+
readOnly = false,
|
|
82
|
+
precision = "full",
|
|
83
|
+
icon,
|
|
84
|
+
size,
|
|
85
|
+
"aria-label": ariaLabel = "Rating",
|
|
86
|
+
...props
|
|
87
|
+
},
|
|
88
|
+
ref
|
|
89
|
+
) => {
|
|
90
|
+
const resolvedSize = size ?? "md";
|
|
91
|
+
const iconSizeClass = iconSizeMap[resolvedSize];
|
|
92
|
+
const step = precision === "half" ? 0.5 : 1;
|
|
93
|
+
|
|
94
|
+
const isControlled = value !== undefined;
|
|
95
|
+
const [internalValue, setInternalValue] = React.useState<number>(defaultValue ?? 0);
|
|
96
|
+
const currentValue = isControlled ? value ?? 0 : internalValue;
|
|
97
|
+
|
|
98
|
+
// Hover önizlemesi (geçici doldurma)
|
|
99
|
+
const [hoverValue, setHoverValue] = React.useState<number | null>(null);
|
|
100
|
+
const displayValue = hoverValue !== null ? hoverValue : currentValue;
|
|
101
|
+
|
|
102
|
+
// Değeri işle: kontrolsüzde iç state'i güncelle, her durumda geri çağrımı tetikle
|
|
103
|
+
const commit = React.useCallback(
|
|
104
|
+
(next: number) => {
|
|
105
|
+
if (readOnly) return;
|
|
106
|
+
if (!isControlled) setInternalValue(next);
|
|
107
|
+
onValueChange?.(next);
|
|
108
|
+
},
|
|
109
|
+
[readOnly, isControlled, onValueChange]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Klavye: ok-tuşları değeri step kadar artır/azalt, Home/End min/max
|
|
113
|
+
const handleKeyDown = React.useCallback(
|
|
114
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
115
|
+
if (readOnly) return;
|
|
116
|
+
let next: number | null = null;
|
|
117
|
+
switch (event.key) {
|
|
118
|
+
case "ArrowRight":
|
|
119
|
+
case "ArrowUp":
|
|
120
|
+
next = Math.min(max, currentValue + step);
|
|
121
|
+
break;
|
|
122
|
+
case "ArrowLeft":
|
|
123
|
+
case "ArrowDown":
|
|
124
|
+
next = Math.max(step, currentValue - step);
|
|
125
|
+
break;
|
|
126
|
+
case "Home":
|
|
127
|
+
next = step;
|
|
128
|
+
break;
|
|
129
|
+
case "End":
|
|
130
|
+
next = max;
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
commit(next);
|
|
137
|
+
},
|
|
138
|
+
[readOnly, max, currentValue, step, commit]
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// İkonu doldurmalı/boş olarak üret (özel ikon desteklenir)
|
|
142
|
+
const renderIcon = (filled: boolean): React.ReactNode => {
|
|
143
|
+
if (React.isValidElement(icon)) {
|
|
144
|
+
const element = icon as React.ReactElement<{ className?: string }>;
|
|
145
|
+
return React.cloneElement(element, {
|
|
146
|
+
className: cn(
|
|
147
|
+
iconSizeClass,
|
|
148
|
+
"shrink-0",
|
|
149
|
+
filled && "fill-current",
|
|
150
|
+
element.props?.className
|
|
151
|
+
),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return (
|
|
155
|
+
<Star
|
|
156
|
+
className={cn(iconSizeClass, "shrink-0", filled && "fill-current")}
|
|
157
|
+
aria-hidden="true"
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const stars = Array.from({ length: max }, (_, index) => index + 1);
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<div
|
|
166
|
+
ref={ref}
|
|
167
|
+
role="radiogroup"
|
|
168
|
+
aria-label={ariaLabel}
|
|
169
|
+
aria-orientation="horizontal"
|
|
170
|
+
aria-readonly={readOnly || undefined}
|
|
171
|
+
tabIndex={readOnly ? undefined : 0}
|
|
172
|
+
onKeyDown={handleKeyDown}
|
|
173
|
+
onMouseLeave={() => setHoverValue(null)}
|
|
174
|
+
className={cn(ratingVariants({ size }), className)}
|
|
175
|
+
{...props}
|
|
176
|
+
>
|
|
177
|
+
{stars.map((starValue) => {
|
|
178
|
+
// Bu yıldızın doluluk oranı (0..1) — yarım yıldız için ondalık olur
|
|
179
|
+
const fraction = Math.max(0, Math.min(1, displayValue - (starValue - 1)));
|
|
180
|
+
const halfValue = starValue - 0.5;
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<span
|
|
184
|
+
key={starValue}
|
|
185
|
+
data-slot="rating-star"
|
|
186
|
+
className={cn(
|
|
187
|
+
"relative inline-flex shrink-0",
|
|
188
|
+
!readOnly && "cursor-pointer"
|
|
189
|
+
)}
|
|
190
|
+
>
|
|
191
|
+
{/* Boş katman (görsel taban) */}
|
|
192
|
+
<span aria-hidden="true" className="inline-flex text-muted-foreground/30">
|
|
193
|
+
{renderIcon(false)}
|
|
194
|
+
</span>
|
|
195
|
+
|
|
196
|
+
{/* Dolu katman — overflow-hidden maske ile kısmi doldurma */}
|
|
197
|
+
<span
|
|
198
|
+
aria-hidden="true"
|
|
199
|
+
className="pointer-events-none absolute left-0 top-0 h-full overflow-hidden text-amber-400"
|
|
200
|
+
style={{ width: `${fraction * 100}%` }}
|
|
201
|
+
>
|
|
202
|
+
{renderIcon(true)}
|
|
203
|
+
</span>
|
|
204
|
+
|
|
205
|
+
{/* Etkileşim katmanı (salt-gösterimde yok) */}
|
|
206
|
+
{!readOnly && precision === "half" && (
|
|
207
|
+
<>
|
|
208
|
+
<button
|
|
209
|
+
type="button"
|
|
210
|
+
role="radio"
|
|
211
|
+
aria-checked={currentValue === halfValue}
|
|
212
|
+
aria-label={`${halfValue} stars`}
|
|
213
|
+
tabIndex={-1}
|
|
214
|
+
onClick={() => commit(halfValue)}
|
|
215
|
+
onMouseEnter={() => setHoverValue(halfValue)}
|
|
216
|
+
className="absolute inset-y-0 left-0 z-10 w-1/2 cursor-pointer bg-transparent"
|
|
217
|
+
/>
|
|
218
|
+
<button
|
|
219
|
+
type="button"
|
|
220
|
+
role="radio"
|
|
221
|
+
aria-checked={currentValue === starValue}
|
|
222
|
+
aria-label={`${starValue} stars`}
|
|
223
|
+
tabIndex={-1}
|
|
224
|
+
onClick={() => commit(starValue)}
|
|
225
|
+
onMouseEnter={() => setHoverValue(starValue)}
|
|
226
|
+
className="absolute inset-y-0 right-0 z-10 w-1/2 cursor-pointer bg-transparent"
|
|
227
|
+
/>
|
|
228
|
+
</>
|
|
229
|
+
)}
|
|
230
|
+
|
|
231
|
+
{!readOnly && precision === "full" && (
|
|
232
|
+
<button
|
|
233
|
+
type="button"
|
|
234
|
+
role="radio"
|
|
235
|
+
aria-checked={currentValue === starValue}
|
|
236
|
+
aria-label={`${starValue} ${starValue === 1 ? "star" : "stars"}`}
|
|
237
|
+
tabIndex={-1}
|
|
238
|
+
onClick={() => commit(starValue)}
|
|
239
|
+
onMouseEnter={() => setHoverValue(starValue)}
|
|
240
|
+
className="absolute inset-0 z-10 cursor-pointer bg-transparent"
|
|
241
|
+
/>
|
|
242
|
+
)}
|
|
243
|
+
</span>
|
|
244
|
+
);
|
|
245
|
+
})}
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
Rating.displayName = "Rating";
|
|
252
|
+
|
|
253
|
+
export { Rating, ratingVariants };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Spinner Component
|
|
9
|
+
*
|
|
10
|
+
* Bağımsız (standalone) dönen yükleme göstergesi. Asenkron işlemler
|
|
11
|
+
* sırasında kullanıcıya süregelen bir aktivite olduğunu bildirmek için
|
|
12
|
+
* kullanılır.
|
|
13
|
+
*
|
|
14
|
+
* Erişilebilirlik: `role="status"` + `aria-live="polite"` ile ekran
|
|
15
|
+
* okuyuculara duyurulur; görsel olarak gizli (`sr-only`) `label` metni
|
|
16
|
+
* seslendirilir. `prefers-reduced-motion` açıkken animasyon
|
|
17
|
+
* `motion-reduce:animate-none` ile durdurulur.
|
|
18
|
+
*
|
|
19
|
+
* Renk `currentColor` üzerinden miras alınır; `text-primary`, `text-muted-foreground`
|
|
20
|
+
* gibi metin renk yardımcılarıyla renklendirilir (hardcoded renk yoktur).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// Dönen halka (default) varyantının temel stilleri + boyut eşlemesi
|
|
24
|
+
const spinnerVariants = cva(
|
|
25
|
+
[
|
|
26
|
+
"inline-block shrink-0 rounded-full",
|
|
27
|
+
"border-current border-t-transparent",
|
|
28
|
+
"animate-spin motion-reduce:animate-none",
|
|
29
|
+
],
|
|
30
|
+
{
|
|
31
|
+
variants: {
|
|
32
|
+
size: {
|
|
33
|
+
sm: "h-4 w-4 border-2", // 16px
|
|
34
|
+
md: "h-6 w-6 border-2", // 24px
|
|
35
|
+
lg: "h-8 w-8 border-[3px]", // 32px
|
|
36
|
+
xl: "h-10 w-10 border-4", // 40px
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
size: "md",
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// Dots varyantı için nokta boyutu eşlemesi (renk `currentColor` ile gelir)
|
|
46
|
+
const dotSizeMap = {
|
|
47
|
+
sm: "h-1 w-1",
|
|
48
|
+
md: "h-1.5 w-1.5",
|
|
49
|
+
lg: "h-2 w-2",
|
|
50
|
+
xl: "h-2.5 w-2.5",
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
export interface SpinnerProps
|
|
54
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
55
|
+
VariantProps<typeof spinnerVariants> {
|
|
56
|
+
/**
|
|
57
|
+
* Görsel stil: dönen halka (`default`) veya zıplayan noktalar (`dots`)
|
|
58
|
+
*/
|
|
59
|
+
variant?: "default" | "dots";
|
|
60
|
+
/**
|
|
61
|
+
* Ekran okuyucular için erişilebilir metin (görsel olarak gizli)
|
|
62
|
+
* @default "Loading"
|
|
63
|
+
*/
|
|
64
|
+
label?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Spinner — dönen yükleme göstergesi
|
|
69
|
+
*
|
|
70
|
+
* @param props.size - Gösterge boyutu (`sm` | `md` | `lg` | `xl`)
|
|
71
|
+
* @param props.variant - Görsel stil (`default` halka | `dots` noktalar)
|
|
72
|
+
* @param props.label - Ekran okuyucular için erişilebilir metin (varsayılan "Loading")
|
|
73
|
+
*/
|
|
74
|
+
const Spinner = React.forwardRef<HTMLDivElement, SpinnerProps>(
|
|
75
|
+
({ className, size, variant = "default", label = "Loading", ...props }, ref) => {
|
|
76
|
+
return (
|
|
77
|
+
<div
|
|
78
|
+
ref={ref}
|
|
79
|
+
role="status"
|
|
80
|
+
aria-live="polite"
|
|
81
|
+
className={cn(
|
|
82
|
+
"moonui-theme inline-flex items-center justify-center",
|
|
83
|
+
className
|
|
84
|
+
)}
|
|
85
|
+
{...props}
|
|
86
|
+
>
|
|
87
|
+
{variant === "dots" ? (
|
|
88
|
+
<span className="inline-flex items-center gap-1" aria-hidden="true">
|
|
89
|
+
{[0, 1, 2].map((i) => (
|
|
90
|
+
<span
|
|
91
|
+
key={i}
|
|
92
|
+
className={cn(
|
|
93
|
+
"inline-block rounded-full bg-current",
|
|
94
|
+
"animate-bounce motion-reduce:animate-none",
|
|
95
|
+
dotSizeMap[size ?? "md"]
|
|
96
|
+
)}
|
|
97
|
+
style={{ animationDelay: `${i * 0.15}s` }}
|
|
98
|
+
/>
|
|
99
|
+
))}
|
|
100
|
+
</span>
|
|
101
|
+
) : (
|
|
102
|
+
<span className={cn(spinnerVariants({ size }))} aria-hidden="true" />
|
|
103
|
+
)}
|
|
104
|
+
{/* Görsel olarak gizli erişilebilir metin */}
|
|
105
|
+
<span className="sr-only">{label}</span>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
Spinner.displayName = "Spinner";
|
|
111
|
+
|
|
112
|
+
export { Spinner, spinnerVariants };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
|
|
5
|
+
import { type VariantProps } from "class-variance-authority"
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils"
|
|
8
|
+
import { toggleVariants } from "./toggle"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ToggleGroup Component
|
|
12
|
+
*
|
|
13
|
+
* Tek (single) veya çoklu (multiple) seçim destekleyen segmented toggle seti.
|
|
14
|
+
* Radix UI `ToggleGroup` primitive'i üzerine kuruludur; roving-tabindex klavye
|
|
15
|
+
* navigasyonu, tek/çoklu seçim mantığı ve erişilebilirlik rolleri (single için
|
|
16
|
+
* `role="radiogroup"` + item `role="radio"`, multiple için `role="toolbar"` +
|
|
17
|
+
* item `aria-pressed`) Radix tarafından yönetilir — bu davranış yeniden yazılmaz.
|
|
18
|
+
*
|
|
19
|
+
* `variant` ve `size` değerleri bir React context (`ToggleGroupContext`) ile
|
|
20
|
+
* item'lara yayılır (shadcn deseni). Her `ToggleGroupItem`, `Toggle` bileşeniyle
|
|
21
|
+
* görsel parite için `toggleVariants`'i yeniden kullanır — aktif durum
|
|
22
|
+
* `data-[state=on]:bg-accent data-[state=on]:text-accent-foreground` ile stillenir.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
// Grup düzeyinde belirlenen variant/size'i item'lara taşıyan context (shadcn deseni).
|
|
26
|
+
// Item, önce context değerini; context tanımsızsa kendi prop'unu kullanır.
|
|
27
|
+
const ToggleGroupContext = React.createContext<
|
|
28
|
+
VariantProps<typeof toggleVariants>
|
|
29
|
+
>({
|
|
30
|
+
size: "default",
|
|
31
|
+
variant: "default",
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// NOT: Radix `ToggleGroup.Root` prop tipi ayrımlı bir union'dır
|
|
35
|
+
// (type="single" → value: string, type="multiple" → value: string[]). Bir `interface`
|
|
36
|
+
// union'ı `extend` edemediğinden burada intersection'lı `type` alias kullanılır — bu,
|
|
37
|
+
// tek/çoklu ayrımını (discriminated union) korur.
|
|
38
|
+
export type ToggleGroupProps = React.ComponentPropsWithoutRef<
|
|
39
|
+
typeof ToggleGroupPrimitive.Root
|
|
40
|
+
> &
|
|
41
|
+
VariantProps<typeof toggleVariants>
|
|
42
|
+
|
|
43
|
+
const ToggleGroup = React.forwardRef<
|
|
44
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
45
|
+
ToggleGroupProps
|
|
46
|
+
>(({ className, variant, size, children, ...props }, ref) => (
|
|
47
|
+
<ToggleGroupPrimitive.Root
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn(
|
|
50
|
+
"moonui-theme inline-flex items-center justify-center gap-1",
|
|
51
|
+
className
|
|
52
|
+
)}
|
|
53
|
+
{...props}
|
|
54
|
+
>
|
|
55
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
56
|
+
{children}
|
|
57
|
+
</ToggleGroupContext.Provider>
|
|
58
|
+
</ToggleGroupPrimitive.Root>
|
|
59
|
+
))
|
|
60
|
+
|
|
61
|
+
ToggleGroup.displayName = "ToggleGroup"
|
|
62
|
+
|
|
63
|
+
export interface ToggleGroupItemProps
|
|
64
|
+
extends React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item>,
|
|
65
|
+
VariantProps<typeof toggleVariants> {}
|
|
66
|
+
|
|
67
|
+
const ToggleGroupItem = React.forwardRef<
|
|
68
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
69
|
+
ToggleGroupItemProps
|
|
70
|
+
>(({ className, children, variant, size, ...props }, ref) => {
|
|
71
|
+
// Grup context'i varsa onun değeri, yoksa item'ın kendi prop'u geçerli olur.
|
|
72
|
+
const context = React.useContext(ToggleGroupContext)
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<ToggleGroupPrimitive.Item
|
|
76
|
+
ref={ref}
|
|
77
|
+
className={cn(
|
|
78
|
+
toggleVariants({
|
|
79
|
+
variant: context.variant ?? variant,
|
|
80
|
+
size: context.size ?? size,
|
|
81
|
+
}),
|
|
82
|
+
className
|
|
83
|
+
)}
|
|
84
|
+
{...props}
|
|
85
|
+
>
|
|
86
|
+
{children}
|
|
87
|
+
</ToggleGroupPrimitive.Item>
|
|
88
|
+
)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
ToggleGroupItem.displayName = "ToggleGroupItem"
|
|
92
|
+
|
|
93
|
+
export { ToggleGroup, ToggleGroupItem }
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/** @license MoonUI v1.0.0 - MIT License - https://moonui.dev */
|
|
4
|
-
var M=Object.create;var $=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var ve=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var d=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Y=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of z(t))!W.call(e,o)&&o!==r&&$(e,o,{get:()=>t[o],enumerable:!(n=B(t,o))||n.enumerable});return e};var me=(e,t,r)=>(r=e!=null?M(H(e)):{},Y(t||!e||!e.__esModule?$(r,"default",{value:e,enumerable:!0}):r,e));var T=d(u=>{"use strict";var y=Symbol.for("react.element"),G=Symbol.for("react.portal"),J=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),X=Symbol.for("react.provider"),Z=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),re=Symbol.for("react.memo"),ne=Symbol.for("react.lazy"),b=Symbol.iterator;function oe(e){return e===null||typeof e!="object"?null:(e=b&&e[b]||e["@@iterator"],typeof e=="function"?e:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,P={};function p(e,t,r){this.props=e,this.context=t,this.refs=P,this.updater=r||C}p.prototype.isReactComponent={};p.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};p.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function g(){}g.prototype=p.prototype;function E(e,t,r){this.props=e,this.context=t,this.refs=P,this.updater=r||C}var k=E.prototype=new g;k.constructor=E;x(k,p.prototype);k.isPureReactComponent=!0;var j=Array.isArray,I=Object.prototype.hasOwnProperty,R={current:null},q={key:!0,ref:!0,__self:!0,__source:!0};function N(e,t,r){var n,o={},i=null,s=null;if(t!=null)for(n in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)I.call(t,n)&&!q.hasOwnProperty(n)&&(o[n]=t[n]);var f=arguments.length-2;if(f===1)o.children=r;else if(1<f){for(var c=Array(f),a=0;a<f;a++)c[a]=arguments[a+2];o.children=c}if(e&&e.defaultProps)for(n in f=e.defaultProps,f)o[n]===void 0&&(o[n]=f[n]);return{$$typeof:y,type:e,key:i,ref:s,props:o,_owner:R.current}}function ue(e,t){return{$$typeof:y,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function w(e){return typeof e=="object"&&e!==null&&e.$$typeof===y}function ie(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(r){return t[r]})}var O=/\/+/g;function S(e,t){return typeof e=="object"&&e!==null&&e.key!=null?ie(""+e.key):t.toString(36)}function v(e,t,r,n,o){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(i){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case y:case G:s=!0}}if(s)return s=e,o=o(s),e=n===""?"."+S(s,0):n,j(o)?(r="",e!=null&&(r=e.replace(O,"$&/")+"/"),v(o,t,r,"",function(a){return a})):o!=null&&(w(o)&&(o=ue(o,r+(!o.key||s&&s.key===o.key?"":(""+o.key).replace(O,"$&/")+"/")+e)),t.push(o)),1;if(s=0,n=n===""?".":n+":",j(e))for(var f=0;f<e.length;f++){i=e[f];var c=n+S(i,f);s+=v(i,t,r,c,o)}else if(c=oe(e),typeof c=="function")for(e=c.call(e),f=0;!(i=e.next()).done;)i=i.value,c=n+S(i,f++),s+=v(i,t,r,c,o);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return s}function _(e,t,r){if(e==null)return e;var n=[],o=0;return v(e,n,"","",function(i){return t.call(r,i,o++)}),n}function se(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(r){(e._status===0||e._status===-1)&&(e._status=1,e._result=r)},function(r){(e._status===0||e._status===-1)&&(e._status=2,e._result=r)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var l={current:null},m={transition:null},ce={ReactCurrentDispatcher:l,ReactCurrentBatchConfig:m,ReactCurrentOwner:R};function D(){throw Error("act(...) is not supported in production builds of React.")}u.Children={map:_,forEach:function(e,t,r){_(e,function(){t.apply(this,arguments)},r)},count:function(e){var t=0;return _(e,function(){t++}),t},toArray:function(e){return _(e,function(t){return t})||[]},only:function(e){if(!w(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};u.Component=p;u.Fragment=J;u.Profiler=Q;u.PureComponent=E;u.StrictMode=K;u.Suspense=te;u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ce;u.act=D;u.cloneElement=function(e,t,r){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=x({},e.props),o=e.key,i=e.ref,s=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,s=R.current),t.key!==void 0&&(o=""+t.key),e.type&&e.type.defaultProps)var f=e.type.defaultProps;for(c in t)I.call(t,c)&&!q.hasOwnProperty(c)&&(n[c]=t[c]===void 0&&f!==void 0?f[c]:t[c])}var c=arguments.length-2;if(c===1)n.children=r;else if(1<c){f=Array(c);for(var a=0;a<c;a++)f[a]=arguments[a+2];n.children=f}return{$$typeof:y,type:e.type,key:o,ref:i,props:n,_owner:s}};u.createContext=function(e){return e={$$typeof:Z,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:X,_context:e},e.Consumer=e};u.createElement=N;u.createFactory=function(e){var t=N.bind(null,e);return t.type=e,t};u.createRef=function(){return{current:null}};u.forwardRef=function(e){return{$$typeof:ee,render:e}};u.isValidElement=w;u.lazy=function(e){return{$$typeof:ne,_payload:{_status:-1,_result:e},_init:se}};u.memo=function(e,t){return{$$typeof:re,type:e,compare:t===void 0?null:t}};u.startTransition=function(e){var t=m.transition;m.transition={};try{e()}finally{m.transition=t}};u.unstable_act=D;u.useCallback=function(e,t){return l.current.useCallback(e,t)};u.useContext=function(e){return l.current.useContext(e)};u.useDebugValue=function(){};u.useDeferredValue=function(e){return l.current.useDeferredValue(e)};u.useEffect=function(e,t){return l.current.useEffect(e,t)};u.useId=function(){return l.current.useId()};u.useImperativeHandle=function(e,t,r){return l.current.useImperativeHandle(e,t,r)};u.useInsertionEffect=function(e,t){return l.current.useInsertionEffect(e,t)};u.useLayoutEffect=function(e,t){return l.current.useLayoutEffect(e,t)};u.useMemo=function(e,t){return l.current.useMemo(e,t)};u.useReducer=function(e,t,r){return l.current.useReducer(e,t,r)};u.useRef=function(e){return l.current.useRef(e)};u.useState=function(e){return l.current.useState(e)};u.useSyncExternalStore=function(e,t,r){return l.current.useSyncExternalStore(e,t,r)};u.useTransition=function(){return l.current.useTransition()};u.version="18.3.1"});var L=d((Ee,V)=>{"use strict";V.exports=T()});var A=d(h=>{"use strict";var fe=L(),le=Symbol.for("react.element"),ae=Symbol.for("react.fragment"),pe=Object.prototype.hasOwnProperty,ye=fe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,de={key:!0,ref:!0,__self:!0,__source:!0};function U(e,t,r){var n,o={},i=null,s=null;r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)pe.call(t,n)&&!de.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:le,type:e,key:i,ref:s,props:o,_owner:ye.current}}h.Fragment=ae;h.jsx=U;h.jsxs=U});var _e=d((Re,F)=>{"use strict";F.exports=A()});export{ve as a,d as b,me as c,L as d,_e as e};
|
|
5
|
-
/*! Bundled license information:
|
|
6
|
-
|
|
7
|
-
react/cjs/react.production.min.js:
|
|
8
|
-
(**
|
|
9
|
-
* @license React
|
|
10
|
-
* react.production.min.js
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the MIT license found in the
|
|
15
|
-
* LICENSE file in the root directory of this source tree.
|
|
16
|
-
*)
|
|
17
|
-
|
|
18
|
-
react/cjs/react-jsx-runtime.production.min.js:
|
|
19
|
-
(**
|
|
20
|
-
* @license React
|
|
21
|
-
* react-jsx-runtime.production.min.js
|
|
22
|
-
*
|
|
23
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the MIT license found in the
|
|
26
|
-
* LICENSE file in the root directory of this source tree.
|
|
27
|
-
*)
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
if (typeof window !== 'undefined' && !window.React) {
|
|
31
|
-
console.warn('MoonUI: React not found. Please include React and ReactDOM before MoonUI.');
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=chunk-X5ULQZNC.global.js.map
|