@karakuri-ui/react 0.2.2 → 0.2.4
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/README.md +9 -0
- package/dist/components/ui/accordion.d.mts +49 -0
- package/dist/components/ui/accordion.d.ts +49 -0
- package/dist/components/ui/accordion.js +220 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/accordion.mjs +181 -0
- package/dist/components/ui/accordion.mjs.map +1 -0
- package/dist/components/ui/alert.d.mts +47 -0
- package/dist/components/ui/alert.d.ts +47 -0
- package/dist/components/ui/alert.js +223 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/alert.mjs +185 -0
- package/dist/components/ui/alert.mjs.map +1 -0
- package/dist/components/ui/avatar.d.mts +232 -0
- package/dist/components/ui/avatar.d.ts +232 -0
- package/dist/components/ui/avatar.js +250 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/avatar.mjs +209 -0
- package/dist/components/ui/avatar.mjs.map +1 -0
- package/dist/components/ui/badge.d.mts +31 -0
- package/dist/components/ui/badge.d.ts +31 -0
- package/dist/components/ui/badge.js +205 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/badge.mjs +170 -0
- package/dist/components/ui/badge.mjs.map +1 -0
- package/dist/components/ui/breadcrumb.d.mts +57 -0
- package/dist/components/ui/breadcrumb.d.ts +57 -0
- package/dist/components/ui/breadcrumb.js +209 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/breadcrumb.mjs +168 -0
- package/dist/components/ui/breadcrumb.mjs.map +1 -0
- package/dist/components/ui/button-group.d.mts +22 -0
- package/dist/components/ui/button-group.d.ts +22 -0
- package/dist/components/ui/button-group.js +107 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button-group.mjs +72 -0
- package/dist/components/ui/button-group.mjs.map +1 -0
- package/dist/components/ui/button.d.mts +31 -0
- package/dist/components/ui/button.d.ts +31 -0
- package/dist/components/ui/button.js +176 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/button.mjs +141 -0
- package/dist/components/ui/button.mjs.map +1 -0
- package/dist/components/ui/card.d.mts +77 -0
- package/dist/components/ui/card.d.ts +77 -0
- package/dist/components/ui/card.js +370 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/card.mjs +328 -0
- package/dist/components/ui/card.mjs.map +1 -0
- package/dist/{chart.js → components/ui/chart.js} +29 -39
- package/dist/components/ui/chart.js.map +1 -0
- package/dist/{chart.mjs → components/ui/chart.mjs} +21 -31
- package/dist/components/ui/chart.mjs.map +1 -0
- package/dist/components/ui/checkbox.d.mts +24 -0
- package/dist/components/ui/checkbox.d.ts +24 -0
- package/dist/components/ui/checkbox.js +173 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/checkbox.mjs +138 -0
- package/dist/components/ui/checkbox.mjs.map +1 -0
- package/dist/components/ui/divider.d.mts +27 -0
- package/dist/components/ui/divider.d.ts +27 -0
- package/dist/components/ui/divider.js +147 -0
- package/dist/components/ui/divider.js.map +1 -0
- package/dist/components/ui/divider.mjs +112 -0
- package/dist/components/ui/divider.mjs.map +1 -0
- package/dist/components/ui/drawer.d.mts +51 -0
- package/dist/components/ui/drawer.d.ts +51 -0
- package/dist/components/ui/drawer.js +225 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/drawer.mjs +178 -0
- package/dist/components/ui/drawer.mjs.map +1 -0
- package/dist/components/ui/dropdown.d.mts +59 -0
- package/dist/components/ui/dropdown.d.ts +59 -0
- package/dist/components/ui/dropdown.js +310 -0
- package/dist/components/ui/dropdown.js.map +1 -0
- package/dist/components/ui/dropdown.mjs +263 -0
- package/dist/components/ui/dropdown.mjs.map +1 -0
- package/dist/components/ui/field.d.mts +33 -0
- package/dist/components/ui/field.d.ts +33 -0
- package/dist/components/ui/field.js +146 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/field.mjs +108 -0
- package/dist/components/ui/field.mjs.map +1 -0
- package/dist/components/ui/icon-button.d.mts +20 -0
- package/dist/components/ui/icon-button.d.ts +20 -0
- package/dist/components/ui/icon-button.js +147 -0
- package/dist/components/ui/icon-button.js.map +1 -0
- package/dist/components/ui/icon-button.mjs +112 -0
- package/dist/components/ui/icon-button.mjs.map +1 -0
- package/dist/components/ui/index.d.mts +55 -0
- package/dist/components/ui/index.d.ts +55 -0
- package/dist/components/ui/index.js +476 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/index.mjs +246 -0
- package/dist/components/ui/index.mjs.map +1 -0
- package/dist/components/ui/input.d.mts +20 -0
- package/dist/components/ui/input.d.ts +20 -0
- package/dist/components/ui/input.js +250 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/input.mjs +215 -0
- package/dist/components/ui/input.mjs.map +1 -0
- package/dist/components/ui/metric-card.d.mts +53 -0
- package/dist/components/ui/metric-card.d.ts +53 -0
- package/dist/components/ui/metric-card.js +258 -0
- package/dist/components/ui/metric-card.js.map +1 -0
- package/dist/components/ui/metric-card.mjs +217 -0
- package/dist/components/ui/metric-card.mjs.map +1 -0
- package/dist/components/ui/modal.d.mts +77 -0
- package/dist/components/ui/modal.d.ts +77 -0
- package/dist/components/ui/modal.js +396 -0
- package/dist/components/ui/modal.js.map +1 -0
- package/dist/components/ui/modal.mjs +338 -0
- package/dist/components/ui/modal.mjs.map +1 -0
- package/dist/components/ui/navigation-menu.d.mts +139 -0
- package/dist/components/ui/navigation-menu.d.ts +139 -0
- package/dist/components/ui/navigation-menu.js +531 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/navigation-menu.mjs +488 -0
- package/dist/components/ui/navigation-menu.mjs.map +1 -0
- package/dist/components/ui/pagination.d.mts +130 -0
- package/dist/components/ui/pagination.d.ts +130 -0
- package/dist/components/ui/pagination.js +495 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/pagination.mjs +449 -0
- package/dist/components/ui/pagination.mjs.map +1 -0
- package/dist/components/ui/popover.d.mts +41 -0
- package/dist/components/ui/popover.d.ts +41 -0
- package/dist/components/ui/popover.js +175 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/popover.mjs +133 -0
- package/dist/components/ui/popover.mjs.map +1 -0
- package/dist/components/ui/progress.d.mts +35 -0
- package/dist/components/ui/progress.d.ts +35 -0
- package/dist/components/ui/progress.js +194 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/progress.mjs +159 -0
- package/dist/components/ui/progress.mjs.map +1 -0
- package/dist/components/ui/radio-group.d.mts +40 -0
- package/dist/components/ui/radio-group.d.ts +40 -0
- package/dist/components/ui/radio-group.js +177 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/radio-group.mjs +140 -0
- package/dist/components/ui/radio-group.mjs.map +1 -0
- package/dist/components/ui/segmented.d.mts +30 -0
- package/dist/components/ui/segmented.d.ts +30 -0
- package/dist/components/ui/segmented.js +241 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/segmented.mjs +204 -0
- package/dist/components/ui/segmented.mjs.map +1 -0
- package/dist/components/ui/select.d.mts +31 -0
- package/dist/components/ui/select.d.ts +31 -0
- package/dist/components/ui/select.js +317 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/select.mjs +276 -0
- package/dist/components/ui/select.mjs.map +1 -0
- package/dist/components/ui/skeleton.d.mts +26 -0
- package/dist/components/ui/skeleton.d.ts +26 -0
- package/dist/components/ui/skeleton.js +144 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/skeleton.mjs +109 -0
- package/dist/components/ui/skeleton.mjs.map +1 -0
- package/dist/components/ui/slider.d.mts +38 -0
- package/dist/components/ui/slider.d.ts +38 -0
- package/dist/components/ui/slider.js +180 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/slider.mjs +145 -0
- package/dist/components/ui/slider.mjs.map +1 -0
- package/dist/components/ui/spinner.d.mts +23 -0
- package/dist/components/ui/spinner.d.ts +23 -0
- package/dist/components/ui/spinner.js +471 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/spinner.mjs +436 -0
- package/dist/components/ui/spinner.mjs.map +1 -0
- package/dist/components/ui/switch.d.mts +22 -0
- package/dist/components/ui/switch.d.ts +22 -0
- package/dist/components/ui/switch.js +173 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/switch.mjs +138 -0
- package/dist/components/ui/switch.mjs.map +1 -0
- package/dist/components/ui/table.d.mts +74 -0
- package/dist/components/ui/table.d.ts +74 -0
- package/dist/components/ui/table.js +240 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/table.mjs +199 -0
- package/dist/components/ui/table.mjs.map +1 -0
- package/dist/components/ui/tabs.d.mts +40 -0
- package/dist/components/ui/tabs.d.ts +40 -0
- package/dist/components/ui/tabs.js +238 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/tabs.mjs +199 -0
- package/dist/components/ui/tabs.mjs.map +1 -0
- package/dist/components/ui/textarea.d.mts +19 -0
- package/dist/components/ui/textarea.d.ts +19 -0
- package/dist/components/ui/textarea.js +181 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/textarea.mjs +146 -0
- package/dist/components/ui/textarea.mjs.map +1 -0
- package/dist/components/ui/toast.d.mts +93 -0
- package/dist/components/ui/toast.d.ts +93 -0
- package/dist/components/ui/toast.js +429 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toast.mjs +393 -0
- package/dist/components/ui/toast.mjs.map +1 -0
- package/dist/components/ui/toggle-group.d.mts +47 -0
- package/dist/components/ui/toggle-group.d.ts +47 -0
- package/dist/components/ui/toggle-group.js +186 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle-group.mjs +149 -0
- package/dist/components/ui/toggle-group.mjs.map +1 -0
- package/dist/components/ui/toggle.d.mts +19 -0
- package/dist/components/ui/toggle.d.ts +19 -0
- package/dist/components/ui/toggle.js +194 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/toggle.mjs +159 -0
- package/dist/components/ui/toggle.mjs.map +1 -0
- package/dist/components/ui/tooltip.d.mts +37 -0
- package/dist/components/ui/tooltip.d.ts +37 -0
- package/dist/components/ui/tooltip.js +137 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/tooltip.mjs +96 -0
- package/dist/components/ui/tooltip.mjs.map +1 -0
- package/dist/lib/utils.d.mts +10 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/lib/utils.js +33 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +9 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/package.json +11 -11
- package/dist/chart.js.map +0 -1
- package/dist/chart.mjs.map +0 -1
- package/dist/index.d.mts +0 -1636
- package/dist/index.d.ts +0 -1636
- package/dist/index.js +0 -7291
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -7048
- package/dist/index.mjs.map +0 -1
- /package/dist/{chart.d.mts → components/ui/chart.d.mts} +0 -0
- /package/dist/{chart.d.ts → components/ui/chart.d.ts} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
const CIRCULAR_VIEWBOX = 100;
|
|
7
|
+
const CIRCULAR_CENTER = 50;
|
|
8
|
+
const CIRCULAR_SIZES = {
|
|
9
|
+
sm: 32,
|
|
10
|
+
default: 48,
|
|
11
|
+
lg: 64
|
|
12
|
+
};
|
|
13
|
+
const CIRCULAR_THICKNESS = {
|
|
14
|
+
sm: 4,
|
|
15
|
+
default: 5,
|
|
16
|
+
lg: 6
|
|
17
|
+
};
|
|
18
|
+
const CIRCULAR_FONT_SIZES = {
|
|
19
|
+
sm: "text-2xs",
|
|
20
|
+
default: "text-xs",
|
|
21
|
+
lg: "text-sm"
|
|
22
|
+
};
|
|
23
|
+
const linearTrackVariants = cva(
|
|
24
|
+
"relative w-full overflow-hidden bg-border rounded-full",
|
|
25
|
+
{
|
|
26
|
+
variants: {
|
|
27
|
+
size: {
|
|
28
|
+
sm: "h-1",
|
|
29
|
+
default: "h-2",
|
|
30
|
+
lg: "h-3"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
size: "default"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
const colorMap = {
|
|
39
|
+
default: "bg-foreground",
|
|
40
|
+
primary: "bg-primary"
|
|
41
|
+
};
|
|
42
|
+
const circularColorMap = {
|
|
43
|
+
default: "stroke-foreground",
|
|
44
|
+
primary: "stroke-primary"
|
|
45
|
+
};
|
|
46
|
+
const valueFontSizes = {
|
|
47
|
+
sm: "text-xs",
|
|
48
|
+
default: "text-sm",
|
|
49
|
+
lg: "text-base"
|
|
50
|
+
};
|
|
51
|
+
const Progress = React.forwardRef(({
|
|
52
|
+
className,
|
|
53
|
+
type = "linear",
|
|
54
|
+
value = 0,
|
|
55
|
+
max = 100,
|
|
56
|
+
size,
|
|
57
|
+
variant = "default",
|
|
58
|
+
color = "default",
|
|
59
|
+
indicatorClassName,
|
|
60
|
+
showValue = false,
|
|
61
|
+
formatLabel,
|
|
62
|
+
animated = false,
|
|
63
|
+
thickness,
|
|
64
|
+
label,
|
|
65
|
+
...props
|
|
66
|
+
}, ref) => {
|
|
67
|
+
const resolvedSize = size || "default";
|
|
68
|
+
const clampedValue = Math.min(Math.max(value, 0), max);
|
|
69
|
+
const percentage = clampedValue / max * 100;
|
|
70
|
+
const valueLabel = formatLabel ? formatLabel(clampedValue, max) : `${Math.round(percentage)}%`;
|
|
71
|
+
if (type === "circular") {
|
|
72
|
+
const diameter = CIRCULAR_SIZES[resolvedSize];
|
|
73
|
+
const strokeWidth = thickness ?? CIRCULAR_THICKNESS[resolvedSize];
|
|
74
|
+
const r = (CIRCULAR_VIEWBOX - strokeWidth) / 2;
|
|
75
|
+
const circumference = 2 * Math.PI * r;
|
|
76
|
+
const offset = circumference * (1 - percentage / 100);
|
|
77
|
+
return /* @__PURE__ */ React.createElement(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
className: cn("inline-flex items-center gap-2", className),
|
|
81
|
+
role: "progressbar",
|
|
82
|
+
"aria-valuenow": clampedValue,
|
|
83
|
+
"aria-valuemin": 0,
|
|
84
|
+
"aria-valuemax": max,
|
|
85
|
+
"aria-label": label
|
|
86
|
+
},
|
|
87
|
+
/* @__PURE__ */ React.createElement("div", { className: "relative", style: { width: diameter, height: diameter } }, /* @__PURE__ */ React.createElement(
|
|
88
|
+
"svg",
|
|
89
|
+
{
|
|
90
|
+
viewBox: `0 0 ${CIRCULAR_VIEWBOX} ${CIRCULAR_VIEWBOX}`,
|
|
91
|
+
className: "transform -rotate-90",
|
|
92
|
+
width: diameter,
|
|
93
|
+
height: diameter
|
|
94
|
+
},
|
|
95
|
+
/* @__PURE__ */ React.createElement(
|
|
96
|
+
"circle",
|
|
97
|
+
{
|
|
98
|
+
cx: CIRCULAR_CENTER,
|
|
99
|
+
cy: CIRCULAR_CENTER,
|
|
100
|
+
r,
|
|
101
|
+
fill: "none",
|
|
102
|
+
className: "stroke-border",
|
|
103
|
+
strokeWidth
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ React.createElement(
|
|
107
|
+
"circle",
|
|
108
|
+
{
|
|
109
|
+
cx: CIRCULAR_CENTER,
|
|
110
|
+
cy: CIRCULAR_CENTER,
|
|
111
|
+
r,
|
|
112
|
+
fill: "none",
|
|
113
|
+
className: cn(indicatorClassName || circularColorMap[color], "transition-[stroke-dashoffset] duration-normal ease-out"),
|
|
114
|
+
strokeWidth,
|
|
115
|
+
strokeDasharray: circumference,
|
|
116
|
+
strokeDashoffset: offset,
|
|
117
|
+
strokeLinecap: "round"
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
), showValue && resolvedSize !== "sm" && /* @__PURE__ */ React.createElement("div", { className: cn(
|
|
121
|
+
"absolute inset-0 flex items-center justify-center font-semibold font-mono tabular-nums text-foreground",
|
|
122
|
+
CIRCULAR_FONT_SIZES[resolvedSize]
|
|
123
|
+
) }, valueLabel))
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
const stripedBg = variant === "striped" ? "bg-[length:1rem_1rem] bg-[linear-gradient(45deg,rgba(255,255,255,0.15)_25%,transparent_25%,transparent_50%,rgba(255,255,255,0.15)_50%,rgba(255,255,255,0.15)_75%,transparent_75%,transparent)]" : "";
|
|
127
|
+
return /* @__PURE__ */ React.createElement("div", { className: cn("flex items-center gap-3", showValue && "w-full", className) }, /* @__PURE__ */ React.createElement(
|
|
128
|
+
ProgressPrimitive.Root,
|
|
129
|
+
{
|
|
130
|
+
ref,
|
|
131
|
+
className: cn(linearTrackVariants({ size })),
|
|
132
|
+
value: clampedValue,
|
|
133
|
+
max,
|
|
134
|
+
"aria-label": label,
|
|
135
|
+
...props
|
|
136
|
+
},
|
|
137
|
+
/* @__PURE__ */ React.createElement(
|
|
138
|
+
ProgressPrimitive.Indicator,
|
|
139
|
+
{
|
|
140
|
+
className: cn(
|
|
141
|
+
"h-full transition-[width] duration-normal ease-out rounded-full",
|
|
142
|
+
indicatorClassName || colorMap[color],
|
|
143
|
+
stripedBg,
|
|
144
|
+
animated && variant === "striped" && "animate-progress-stripe"
|
|
145
|
+
),
|
|
146
|
+
style: { width: `${percentage}%` }
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
), showValue && /* @__PURE__ */ React.createElement("span", { className: cn(
|
|
150
|
+
"shrink-0 font-semibold font-mono tabular-nums text-foreground",
|
|
151
|
+
valueFontSizes[resolvedSize]
|
|
152
|
+
) }, valueLabel));
|
|
153
|
+
});
|
|
154
|
+
Progress.displayName = "Progress";
|
|
155
|
+
export {
|
|
156
|
+
Progress,
|
|
157
|
+
linearTrackVariants
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=progress.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/progress.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport * as ProgressPrimitive from '@radix-ui/react-progress'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n/** Circular SVG viewBox size */\nconst CIRCULAR_VIEWBOX = 100\n/** Circular center point */\nconst CIRCULAR_CENTER = 50\n\n/** Circular sizes (diameter in px) */\nconst CIRCULAR_SIZES = {\n sm: 32,\n default: 48,\n lg: 64,\n} as const\n\n/** Circular stroke thickness per size */\nconst CIRCULAR_THICKNESS = {\n sm: 4,\n default: 5,\n lg: 6,\n} as const\n\n/** Circular value font sizes */\nconst CIRCULAR_FONT_SIZES = {\n sm: 'text-2xs',\n default: 'text-xs',\n lg: 'text-sm',\n} as const\n\n// ============================================================================\n// Linear Progress\n// ============================================================================\n\nconst linearTrackVariants = cva(\n 'relative w-full overflow-hidden bg-border rounded-full',\n {\n variants: {\n size: {\n sm: 'h-1',\n default: 'h-2',\n lg: 'h-3',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n }\n)\n\nconst colorMap = {\n default: 'bg-foreground',\n primary: 'bg-primary',\n} as const\n\nconst circularColorMap = {\n default: 'stroke-foreground',\n primary: 'stroke-primary',\n} as const\n\nconst valueFontSizes = {\n sm: 'text-xs',\n default: 'text-sm',\n lg: 'text-base',\n} as const\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface ProgressProps\n extends Omit<React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>, 'children'>,\n VariantProps<typeof linearTrackVariants> {\n /** Progress type */\n type?: 'linear' | 'circular'\n /** Current value (0 to max) */\n value?: number\n /** Maximum value */\n max?: number\n /** Visual variant (linear only) */\n variant?: 'default' | 'striped'\n /** Indicator color */\n color?: 'default' | 'primary'\n /** Custom indicator class (overrides color) */\n indicatorClassName?: string\n /** Show percentage value */\n showValue?: boolean\n /** Custom label formatter */\n formatLabel?: (value: number, max: number) => string\n /** Animate striped variant */\n animated?: boolean\n /** Circular stroke thickness override */\n thickness?: number\n /** Accessibility label */\n label?: string\n}\n\nconst Progress = React.forwardRef<\n React.ElementRef<typeof ProgressPrimitive.Root>,\n ProgressProps\n>(({\n className,\n type = 'linear',\n value = 0,\n max = 100,\n size,\n variant = 'default',\n color = 'default',\n indicatorClassName,\n showValue = false,\n formatLabel,\n animated = false,\n thickness,\n label,\n ...props\n}, ref) => {\n const resolvedSize = size || 'default'\n const clampedValue = Math.min(Math.max(value, 0), max)\n const percentage = (clampedValue / max) * 100\n\n const valueLabel = formatLabel\n ? formatLabel(clampedValue, max)\n : `${Math.round(percentage)}%`\n\n // ── Circular ──\n if (type === 'circular') {\n const diameter = CIRCULAR_SIZES[resolvedSize]\n const strokeWidth = thickness ?? CIRCULAR_THICKNESS[resolvedSize]\n const r = (CIRCULAR_VIEWBOX - strokeWidth) / 2\n const circumference = 2 * Math.PI * r\n const offset = circumference * (1 - percentage / 100)\n\n return (\n <div\n className={cn('inline-flex items-center gap-2', className)}\n role=\"progressbar\"\n aria-valuenow={clampedValue}\n aria-valuemin={0}\n aria-valuemax={max}\n aria-label={label}\n >\n <div className=\"relative\" style={{ width: diameter, height: diameter }}>\n <svg\n viewBox={`0 0 ${CIRCULAR_VIEWBOX} ${CIRCULAR_VIEWBOX}`}\n className=\"transform -rotate-90\"\n width={diameter}\n height={diameter}\n >\n {/* Track */}\n <circle\n cx={CIRCULAR_CENTER}\n cy={CIRCULAR_CENTER}\n r={r}\n fill=\"none\"\n className=\"stroke-border\"\n strokeWidth={strokeWidth}\n />\n {/* Indicator */}\n <circle\n cx={CIRCULAR_CENTER}\n cy={CIRCULAR_CENTER}\n r={r}\n fill=\"none\"\n className={cn(indicatorClassName || circularColorMap[color], 'transition-[stroke-dashoffset] duration-normal ease-out')}\n strokeWidth={strokeWidth}\n strokeDasharray={circumference}\n strokeDashoffset={offset}\n strokeLinecap=\"round\"\n />\n </svg>\n {/* Center value */}\n {showValue && resolvedSize !== 'sm' && (\n <div className={cn(\n 'absolute inset-0 flex items-center justify-center font-semibold font-mono tabular-nums text-foreground',\n CIRCULAR_FONT_SIZES[resolvedSize]\n )}>\n {valueLabel}\n </div>\n )}\n </div>\n </div>\n )\n }\n\n // ── Linear ──\n const stripedBg = variant === 'striped'\n ? 'bg-[length:1rem_1rem] bg-[linear-gradient(45deg,rgba(255,255,255,0.15)_25%,transparent_25%,transparent_50%,rgba(255,255,255,0.15)_50%,rgba(255,255,255,0.15)_75%,transparent_75%,transparent)]'\n : ''\n\n return (\n <div className={cn('flex items-center gap-3', showValue && 'w-full', className)}>\n <ProgressPrimitive.Root\n ref={ref}\n className={cn(linearTrackVariants({ size }))}\n value={clampedValue}\n max={max}\n aria-label={label}\n {...props}\n >\n <ProgressPrimitive.Indicator\n className={cn(\n 'h-full transition-[width] duration-normal ease-out rounded-full',\n indicatorClassName || colorMap[color],\n stripedBg,\n animated && variant === 'striped' && 'animate-progress-stripe',\n )}\n style={{ width: `${percentage}%` }}\n />\n </ProgressPrimitive.Root>\n {showValue && (\n <span className={cn(\n 'shrink-0 font-semibold font-mono tabular-nums text-foreground',\n valueFontSizes[resolvedSize]\n )}>\n {valueLabel}\n </span>\n )}\n </div>\n )\n})\nProgress.displayName = 'Progress'\n\nexport { Progress, linearTrackVariants }\n"],"mappings":";AAEA,YAAY,WAAW;AACvB,YAAY,uBAAuB;AACnC,SAAS,WAA8B;AACvC,SAAS,UAAU;AAOnB,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB;AAGxB,MAAM,iBAAiB;AAAA,EACrB,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,IAAI;AAC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C,WAAW;AAAA,UACT;AAAA,UACA,sBAAsB,SAAS,KAAK;AAAA,UACpC;AAAA,UACA,YAAY,YAAY,aAAa;AAAA,QACvC;AAAA,QACA,OAAO,EAAE,OAAO,GAAG,UAAU,IAAI;AAAA;AAAA,IACnC;AAAA,EACF,GACC,aACC,oCAAC,UAAK,WAAW;AAAA,IACf;AAAA,IACA,eAAe,YAAY;AAAA,EAC7B,KACG,UACH,CAEJ;AAEJ,CAAC;AACD,SAAS,cAAc;","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
4
|
+
|
|
5
|
+
declare const radioColorMap: {
|
|
6
|
+
readonly default: {
|
|
7
|
+
readonly border: "data-[state=checked]:border-foreground";
|
|
8
|
+
readonly dot: "bg-foreground";
|
|
9
|
+
};
|
|
10
|
+
readonly primary: {
|
|
11
|
+
readonly border: "data-[state=checked]:border-primary";
|
|
12
|
+
readonly dot: "bg-primary";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
type RadioColor = keyof typeof radioColorMap;
|
|
16
|
+
declare const radioGroupVariants: (props?: ({
|
|
17
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
18
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
19
|
+
interface RadioGroupProps extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> {
|
|
20
|
+
size?: 'sm' | 'default' | 'lg';
|
|
21
|
+
weight?: 'thin' | 'bold';
|
|
22
|
+
/** Checked state color */
|
|
23
|
+
color?: RadioColor;
|
|
24
|
+
}
|
|
25
|
+
declare const radioItemVariants: (props?: ({
|
|
26
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
27
|
+
weight?: "bold" | "thin" | null | undefined;
|
|
28
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
29
|
+
interface RadioGroupItemProps extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> {
|
|
30
|
+
label?: string;
|
|
31
|
+
}
|
|
32
|
+
declare const RadioGroupItem: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>> & {
|
|
34
|
+
Item: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
35
|
+
};
|
|
36
|
+
declare namespace RadioGroup {
|
|
37
|
+
type ItemProps = RadioGroupItemProps;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { type RadioColor, RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, radioGroupVariants, radioItemVariants };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
4
|
+
|
|
5
|
+
declare const radioColorMap: {
|
|
6
|
+
readonly default: {
|
|
7
|
+
readonly border: "data-[state=checked]:border-foreground";
|
|
8
|
+
readonly dot: "bg-foreground";
|
|
9
|
+
};
|
|
10
|
+
readonly primary: {
|
|
11
|
+
readonly border: "data-[state=checked]:border-primary";
|
|
12
|
+
readonly dot: "bg-primary";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
type RadioColor = keyof typeof radioColorMap;
|
|
16
|
+
declare const radioGroupVariants: (props?: ({
|
|
17
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
18
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
19
|
+
interface RadioGroupProps extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> {
|
|
20
|
+
size?: 'sm' | 'default' | 'lg';
|
|
21
|
+
weight?: 'thin' | 'bold';
|
|
22
|
+
/** Checked state color */
|
|
23
|
+
color?: RadioColor;
|
|
24
|
+
}
|
|
25
|
+
declare const radioItemVariants: (props?: ({
|
|
26
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
27
|
+
weight?: "bold" | "thin" | null | undefined;
|
|
28
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
29
|
+
interface RadioGroupItemProps extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> {
|
|
30
|
+
label?: string;
|
|
31
|
+
}
|
|
32
|
+
declare const RadioGroupItem: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>> & {
|
|
34
|
+
Item: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
35
|
+
};
|
|
36
|
+
declare namespace RadioGroup {
|
|
37
|
+
type ItemProps = RadioGroupItemProps;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { type RadioColor, RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, radioGroupVariants, radioItemVariants };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var radio_group_exports = {};
|
|
31
|
+
__export(radio_group_exports, {
|
|
32
|
+
RadioGroup: () => RadioGroup,
|
|
33
|
+
RadioGroupItem: () => RadioGroupItem,
|
|
34
|
+
radioGroupVariants: () => radioGroupVariants,
|
|
35
|
+
radioItemVariants: () => radioItemVariants
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(radio_group_exports);
|
|
38
|
+
var React = __toESM(require("react"));
|
|
39
|
+
var RadioGroupPrimitive = __toESM(require("@radix-ui/react-radio-group"));
|
|
40
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
41
|
+
var import_utils = require("../../lib/utils");
|
|
42
|
+
var import_field = require("./field");
|
|
43
|
+
const radioColorMap = {
|
|
44
|
+
default: {
|
|
45
|
+
border: "data-[state=checked]:border-foreground",
|
|
46
|
+
dot: "bg-foreground"
|
|
47
|
+
},
|
|
48
|
+
primary: {
|
|
49
|
+
border: "data-[state=checked]:border-primary",
|
|
50
|
+
dot: "bg-primary"
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const RadioGroupContext = React.createContext({ size: "default", weight: "bold", color: "default" });
|
|
54
|
+
const radioGroupVariants = (0, import_class_variance_authority.cva)("grid gap-3", {
|
|
55
|
+
variants: {
|
|
56
|
+
orientation: {
|
|
57
|
+
vertical: "grid-cols-1",
|
|
58
|
+
horizontal: "grid-flow-col auto-cols-max gap-4"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: {
|
|
62
|
+
orientation: "vertical"
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const RadioGroupRoot = React.forwardRef(({ className, orientation, size = "default", weight = "bold", color = "default", disabled, ...props }, ref) => {
|
|
66
|
+
const fieldContext = (0, import_field.useFieldContext)();
|
|
67
|
+
const resolvedDisabled = disabled ?? fieldContext?.disabled;
|
|
68
|
+
return /* @__PURE__ */ React.createElement(RadioGroupContext.Provider, { value: { size, weight, color, disabled: resolvedDisabled } }, /* @__PURE__ */ React.createElement(
|
|
69
|
+
RadioGroupPrimitive.Root,
|
|
70
|
+
{
|
|
71
|
+
ref,
|
|
72
|
+
className: (0, import_utils.cn)(radioGroupVariants({ orientation }), className),
|
|
73
|
+
orientation: orientation || void 0,
|
|
74
|
+
disabled: resolvedDisabled,
|
|
75
|
+
...props
|
|
76
|
+
}
|
|
77
|
+
));
|
|
78
|
+
});
|
|
79
|
+
RadioGroupRoot.displayName = "RadioGroup";
|
|
80
|
+
const radioItemVariants = (0, import_class_variance_authority.cva)(
|
|
81
|
+
[
|
|
82
|
+
"relative shrink-0 rounded-full border-border-form hover:border-border-form-strong transition-all duration-micro ease-out",
|
|
83
|
+
"focus-visible:focus-ring",
|
|
84
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
85
|
+
// Transparent hit area expansion via ::after
|
|
86
|
+
"after:absolute after:content-['']"
|
|
87
|
+
].join(" "),
|
|
88
|
+
{
|
|
89
|
+
variants: {
|
|
90
|
+
size: {
|
|
91
|
+
sm: "w-3.5 h-3.5 after:-inset-[5px]",
|
|
92
|
+
// 14px circle → 24px click
|
|
93
|
+
default: "w-4 h-4 after:-inset-2",
|
|
94
|
+
// 16px circle → 32px click
|
|
95
|
+
lg: "w-5 h-5 after:-inset-2"
|
|
96
|
+
// 20px circle → 36px click
|
|
97
|
+
},
|
|
98
|
+
weight: {
|
|
99
|
+
thin: "border",
|
|
100
|
+
// 1px
|
|
101
|
+
bold: "border-2"
|
|
102
|
+
// 2px
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
defaultVariants: {
|
|
106
|
+
size: "default",
|
|
107
|
+
weight: "bold"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
const dotSizes = {
|
|
112
|
+
sm: "w-1.5 h-1.5",
|
|
113
|
+
// 6px
|
|
114
|
+
default: "w-2 h-2",
|
|
115
|
+
// 8px
|
|
116
|
+
lg: "w-2.5 h-2.5"
|
|
117
|
+
// 10px
|
|
118
|
+
};
|
|
119
|
+
const labelSizes = {
|
|
120
|
+
sm: "text-xs",
|
|
121
|
+
// 12px
|
|
122
|
+
default: "text-md",
|
|
123
|
+
// 14px
|
|
124
|
+
lg: "text-base"
|
|
125
|
+
// 16px
|
|
126
|
+
};
|
|
127
|
+
const gapSizes = {
|
|
128
|
+
sm: "gap-1.5",
|
|
129
|
+
default: "gap-2",
|
|
130
|
+
lg: "gap-2.5"
|
|
131
|
+
};
|
|
132
|
+
const RadioGroupItem = React.forwardRef(({ className, label, disabled, ...props }, ref) => {
|
|
133
|
+
const { size, weight, color, disabled: groupDisabled } = React.useContext(RadioGroupContext);
|
|
134
|
+
const resolvedDisabled = disabled ?? groupDisabled;
|
|
135
|
+
const itemId = React.useId();
|
|
136
|
+
const radio = /* @__PURE__ */ React.createElement(
|
|
137
|
+
RadioGroupPrimitive.Item,
|
|
138
|
+
{
|
|
139
|
+
ref,
|
|
140
|
+
id: label ? itemId : void 0,
|
|
141
|
+
disabled: resolvedDisabled,
|
|
142
|
+
className: (0, import_utils.cn)(
|
|
143
|
+
radioItemVariants({ size, weight }),
|
|
144
|
+
radioColorMap[color].border,
|
|
145
|
+
className
|
|
146
|
+
),
|
|
147
|
+
...props
|
|
148
|
+
},
|
|
149
|
+
/* @__PURE__ */ React.createElement(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center animate-radio-enter" }, /* @__PURE__ */ React.createElement("div", { className: (0, import_utils.cn)("rounded-full", radioColorMap[color].dot, dotSizes[size]) }))
|
|
150
|
+
);
|
|
151
|
+
if (!label) return radio;
|
|
152
|
+
return /* @__PURE__ */ React.createElement("div", { className: (0, import_utils.cn)("group flex items-center", gapSizes[size]) }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center" }, radio), /* @__PURE__ */ React.createElement(
|
|
153
|
+
"label",
|
|
154
|
+
{
|
|
155
|
+
htmlFor: itemId,
|
|
156
|
+
className: (0, import_utils.cn)(
|
|
157
|
+
labelSizes[size],
|
|
158
|
+
"text-text-muted cursor-pointer select-none transition-colors duration-micro",
|
|
159
|
+
"group-hover:text-foreground",
|
|
160
|
+
resolvedDisabled && "opacity-50 cursor-not-allowed"
|
|
161
|
+
)
|
|
162
|
+
},
|
|
163
|
+
label
|
|
164
|
+
));
|
|
165
|
+
});
|
|
166
|
+
RadioGroupItem.displayName = "RadioGroupItem";
|
|
167
|
+
const RadioGroup = Object.assign(RadioGroupRoot, {
|
|
168
|
+
Item: RadioGroupItem
|
|
169
|
+
});
|
|
170
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
+
0 && (module.exports = {
|
|
172
|
+
RadioGroup,
|
|
173
|
+
RadioGroupItem,
|
|
174
|
+
radioGroupVariants,
|
|
175
|
+
radioItemVariants
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=radio-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/radio-group.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group'\nimport { cva } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\nimport { useFieldContext } from './field'\n\n// Color maps for checked state\nconst radioColorMap = {\n default: {\n border: 'data-[state=checked]:border-foreground',\n dot: 'bg-foreground',\n },\n primary: {\n border: 'data-[state=checked]:border-primary',\n dot: 'bg-primary',\n },\n} as const\n\nexport type RadioColor = keyof typeof radioColorMap\n\n// Context to pass size, weight, color from RadioGroup to RadioGroupItem\ntype RadioGroupContextValue = {\n size: 'sm' | 'default' | 'lg'\n weight: 'thin' | 'bold'\n color: RadioColor\n disabled?: boolean\n}\nconst RadioGroupContext = React.createContext<RadioGroupContextValue>({ size: 'default', weight: 'bold', color: 'default' })\n\n// RadioGroup container\nconst radioGroupVariants = cva('grid gap-3', {\n variants: {\n orientation: {\n vertical: 'grid-cols-1',\n horizontal: 'grid-flow-col auto-cols-max gap-4',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n})\n\nexport interface RadioGroupProps\n extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> {\n size?: 'sm' | 'default' | 'lg'\n weight?: 'thin' | 'bold'\n /** Checked state color */\n color?: RadioColor\n}\n\nconst RadioGroupRoot = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Root>,\n RadioGroupProps\n>(({ className, orientation, size = 'default', weight = 'bold', color = 'default', disabled, ...props }, ref) => {\n const fieldContext = useFieldContext()\n const resolvedDisabled = disabled ?? fieldContext?.disabled\n\n return (\n <RadioGroupContext.Provider value={{ size, weight, color, disabled: resolvedDisabled }}>\n <RadioGroupPrimitive.Root\n ref={ref}\n className={cn(radioGroupVariants({ orientation }), className)}\n orientation={orientation || undefined}\n disabled={resolvedDisabled}\n {...props}\n />\n </RadioGroupContext.Provider>\n )\n})\nRadioGroupRoot.displayName = 'RadioGroup'\n\n// RadioGroupItem circle variants\nconst radioItemVariants = cva(\n [\n 'relative shrink-0 rounded-full border-border-form hover:border-border-form-strong transition-all duration-micro ease-out',\n 'focus-visible:focus-ring',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n // Transparent hit area expansion via ::after\n \"after:absolute after:content-['']\",\n ].join(' '),\n {\n variants: {\n size: {\n sm: 'w-3.5 h-3.5 after:-inset-[5px]', // 14px circle → 24px click\n default: 'w-4 h-4 after:-inset-2', // 16px circle → 32px click\n lg: 'w-5 h-5 after:-inset-2', // 20px circle → 36px click\n },\n weight: {\n thin: 'border', // 1px\n bold: 'border-2', // 2px\n },\n },\n defaultVariants: {\n size: 'default',\n weight: 'bold',\n },\n }\n)\n\n// Dot sizes per radio size\nconst dotSizes = {\n sm: 'w-1.5 h-1.5', // 6px\n default: 'w-2 h-2', // 8px\n lg: 'w-2.5 h-2.5', // 10px\n}\n\n// Label font sizes\nconst labelSizes = {\n sm: 'text-xs', // 12px\n default: 'text-md', // 14px\n lg: 'text-base', // 16px\n}\n\n// Gap between radio and label\nconst gapSizes = {\n sm: 'gap-1.5',\n default: 'gap-2',\n lg: 'gap-2.5',\n}\n\nexport interface RadioGroupItemProps\n extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> {\n label?: string\n}\n\nconst RadioGroupItem = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Item>,\n RadioGroupItemProps\n>(({ className, label, disabled, ...props }, ref) => {\n const { size, weight, color, disabled: groupDisabled } = React.useContext(RadioGroupContext)\n const resolvedDisabled = disabled ?? groupDisabled\n const itemId = React.useId()\n\n const radio = (\n <RadioGroupPrimitive.Item\n ref={ref}\n id={label ? itemId : undefined}\n disabled={resolvedDisabled}\n className={cn(\n radioItemVariants({ size, weight }),\n radioColorMap[color].border,\n className\n )}\n {...props}\n >\n <RadioGroupPrimitive.Indicator className=\"flex items-center justify-center animate-radio-enter\">\n <div className={cn('rounded-full', radioColorMap[color].dot, dotSizes[size])} />\n </RadioGroupPrimitive.Indicator>\n </RadioGroupPrimitive.Item>\n )\n\n if (!label) return radio\n\n return (\n <div className={cn('group flex items-center', gapSizes[size])}>\n <div className=\"flex items-center\">\n {radio}\n </div>\n <label\n htmlFor={itemId}\n className={cn(\n labelSizes[size],\n 'text-text-muted cursor-pointer select-none transition-colors duration-micro',\n 'group-hover:text-foreground',\n resolvedDisabled && 'opacity-50 cursor-not-allowed'\n )}\n >\n {label}\n </label>\n </div>\n )\n})\nRadioGroupItem.displayName = 'RadioGroupItem'\n\n// ─── Namespace ──────────────────────────────────────────\nconst RadioGroup = Object.assign(RadioGroupRoot, {\n Item: RadioGroupItem,\n})\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace RadioGroup {\n export type ItemProps = RadioGroupItemProps\n}\n\nexport { RadioGroup, RadioGroupItem, radioGroupVariants, radioItemVariants }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AACvB,0BAAqC;AACrC,sCAAoB;AACpB,mBAAmB;AACnB,mBAAgC;AAGhC,MAAM,gBAAgB;AAAA,EACpB,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AACF;AAWA,MAAM,oBAAoB,MAAM,cAAsC,EAAE,MAAM,WAAW,QAAQ,QAAQ,OAAO,UAAU,CAAC;AAG3H,MAAM,yBAAqB,qCAAI,cAAc;AAAA,EAC3C,UAAU;AAAA,IACR,aAAa;AAAA,MACX,UAAU;AAAA,MACV,YAAY;AAAA,IACd;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,aAAa;AAAA,EACf;AACF,CAAC;AAUD,MAAM,iBAAiB,MAAM,WAG3B,CAAC,EAAE,WAAW,aAAa,OAAO,WAAW,SAAS,QAAQ,QAAQ,WAAW,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/G,QAAM,mBAAe,8BAAgB;AACrC,QAAM,mBAAmB,YAAY,cAAc;AAEnD,SACE,oCAAC,kBA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AAA,MACC;AAAA,MACA,IAAI,QAAQ,SAAS;AAAA,MACrB,UAAU;AAAA,MACV,eAAW;AAAA,QACT,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAAA,QAClC,cAAc,KAAK,EAAE;AAAA,QACrB;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,IAEJ,oCAAC,oBAAoB,WAApB,EAA8B,WAAU,0DACvC,oCAAC,SAAI,eAAW,iBAAG,gBAAgB,cAAc,KAAK,EAAE,KAAK,SAAS,IAAI,CAAC,GAAG,CAChF;AAAA,EACF;AAGF,MAAI,CAAC,MAAO,QAAO;AAEnB,SACE,oCAAC,SAAI,eAAW,iBAAG,2BAA2B,SAAS,IAAI,CAAC,KAC1D,oCAAC,SAAI,WAAU,uBACZ,KACH,GACA;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,eAAW;AAAA,QACT,WAAW,IAAI;AAAA,QACf;AAAA,QACA;AAAA,QACA,oBAAoB;AAAA,MACtB;AAAA;AAAA,IAEC;AAAA,EACH,CACF;AAEJ,CAAC;AACD,eAAe,cAAc;AAG7B,MAAM,aAAa,OAAO,OAAO,gBAAgB;AAAA,EAC/C,MAAM;AACR,CAAC;","names":[]}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
import { useFieldContext } from "./field";
|
|
7
|
+
const radioColorMap = {
|
|
8
|
+
default: {
|
|
9
|
+
border: "data-[state=checked]:border-foreground",
|
|
10
|
+
dot: "bg-foreground"
|
|
11
|
+
},
|
|
12
|
+
primary: {
|
|
13
|
+
border: "data-[state=checked]:border-primary",
|
|
14
|
+
dot: "bg-primary"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const RadioGroupContext = React.createContext({ size: "default", weight: "bold", color: "default" });
|
|
18
|
+
const radioGroupVariants = cva("grid gap-3", {
|
|
19
|
+
variants: {
|
|
20
|
+
orientation: {
|
|
21
|
+
vertical: "grid-cols-1",
|
|
22
|
+
horizontal: "grid-flow-col auto-cols-max gap-4"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
orientation: "vertical"
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const RadioGroupRoot = React.forwardRef(({ className, orientation, size = "default", weight = "bold", color = "default", disabled, ...props }, ref) => {
|
|
30
|
+
const fieldContext = useFieldContext();
|
|
31
|
+
const resolvedDisabled = disabled ?? fieldContext?.disabled;
|
|
32
|
+
return /* @__PURE__ */ React.createElement(RadioGroupContext.Provider, { value: { size, weight, color, disabled: resolvedDisabled } }, /* @__PURE__ */ React.createElement(
|
|
33
|
+
RadioGroupPrimitive.Root,
|
|
34
|
+
{
|
|
35
|
+
ref,
|
|
36
|
+
className: cn(radioGroupVariants({ orientation }), className),
|
|
37
|
+
orientation: orientation || void 0,
|
|
38
|
+
disabled: resolvedDisabled,
|
|
39
|
+
...props
|
|
40
|
+
}
|
|
41
|
+
));
|
|
42
|
+
});
|
|
43
|
+
RadioGroupRoot.displayName = "RadioGroup";
|
|
44
|
+
const radioItemVariants = cva(
|
|
45
|
+
[
|
|
46
|
+
"relative shrink-0 rounded-full border-border-form hover:border-border-form-strong transition-all duration-micro ease-out",
|
|
47
|
+
"focus-visible:focus-ring",
|
|
48
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
49
|
+
// Transparent hit area expansion via ::after
|
|
50
|
+
"after:absolute after:content-['']"
|
|
51
|
+
].join(" "),
|
|
52
|
+
{
|
|
53
|
+
variants: {
|
|
54
|
+
size: {
|
|
55
|
+
sm: "w-3.5 h-3.5 after:-inset-[5px]",
|
|
56
|
+
// 14px circle → 24px click
|
|
57
|
+
default: "w-4 h-4 after:-inset-2",
|
|
58
|
+
// 16px circle → 32px click
|
|
59
|
+
lg: "w-5 h-5 after:-inset-2"
|
|
60
|
+
// 20px circle → 36px click
|
|
61
|
+
},
|
|
62
|
+
weight: {
|
|
63
|
+
thin: "border",
|
|
64
|
+
// 1px
|
|
65
|
+
bold: "border-2"
|
|
66
|
+
// 2px
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
size: "default",
|
|
71
|
+
weight: "bold"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
const dotSizes = {
|
|
76
|
+
sm: "w-1.5 h-1.5",
|
|
77
|
+
// 6px
|
|
78
|
+
default: "w-2 h-2",
|
|
79
|
+
// 8px
|
|
80
|
+
lg: "w-2.5 h-2.5"
|
|
81
|
+
// 10px
|
|
82
|
+
};
|
|
83
|
+
const labelSizes = {
|
|
84
|
+
sm: "text-xs",
|
|
85
|
+
// 12px
|
|
86
|
+
default: "text-md",
|
|
87
|
+
// 14px
|
|
88
|
+
lg: "text-base"
|
|
89
|
+
// 16px
|
|
90
|
+
};
|
|
91
|
+
const gapSizes = {
|
|
92
|
+
sm: "gap-1.5",
|
|
93
|
+
default: "gap-2",
|
|
94
|
+
lg: "gap-2.5"
|
|
95
|
+
};
|
|
96
|
+
const RadioGroupItem = React.forwardRef(({ className, label, disabled, ...props }, ref) => {
|
|
97
|
+
const { size, weight, color, disabled: groupDisabled } = React.useContext(RadioGroupContext);
|
|
98
|
+
const resolvedDisabled = disabled ?? groupDisabled;
|
|
99
|
+
const itemId = React.useId();
|
|
100
|
+
const radio = /* @__PURE__ */ React.createElement(
|
|
101
|
+
RadioGroupPrimitive.Item,
|
|
102
|
+
{
|
|
103
|
+
ref,
|
|
104
|
+
id: label ? itemId : void 0,
|
|
105
|
+
disabled: resolvedDisabled,
|
|
106
|
+
className: cn(
|
|
107
|
+
radioItemVariants({ size, weight }),
|
|
108
|
+
radioColorMap[color].border,
|
|
109
|
+
className
|
|
110
|
+
),
|
|
111
|
+
...props
|
|
112
|
+
},
|
|
113
|
+
/* @__PURE__ */ React.createElement(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center animate-radio-enter" }, /* @__PURE__ */ React.createElement("div", { className: cn("rounded-full", radioColorMap[color].dot, dotSizes[size]) }))
|
|
114
|
+
);
|
|
115
|
+
if (!label) return radio;
|
|
116
|
+
return /* @__PURE__ */ React.createElement("div", { className: cn("group flex items-center", gapSizes[size]) }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center" }, radio), /* @__PURE__ */ React.createElement(
|
|
117
|
+
"label",
|
|
118
|
+
{
|
|
119
|
+
htmlFor: itemId,
|
|
120
|
+
className: cn(
|
|
121
|
+
labelSizes[size],
|
|
122
|
+
"text-text-muted cursor-pointer select-none transition-colors duration-micro",
|
|
123
|
+
"group-hover:text-foreground",
|
|
124
|
+
resolvedDisabled && "opacity-50 cursor-not-allowed"
|
|
125
|
+
)
|
|
126
|
+
},
|
|
127
|
+
label
|
|
128
|
+
));
|
|
129
|
+
});
|
|
130
|
+
RadioGroupItem.displayName = "RadioGroupItem";
|
|
131
|
+
const RadioGroup = Object.assign(RadioGroupRoot, {
|
|
132
|
+
Item: RadioGroupItem
|
|
133
|
+
});
|
|
134
|
+
export {
|
|
135
|
+
RadioGroup,
|
|
136
|
+
RadioGroupItem,
|
|
137
|
+
radioGroupVariants,
|
|
138
|
+
radioItemVariants
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=radio-group.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/radio-group.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group'\nimport { cva } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\nimport { useFieldContext } from './field'\n\n// Color maps for checked state\nconst radioColorMap = {\n default: {\n border: 'data-[state=checked]:border-foreground',\n dot: 'bg-foreground',\n },\n primary: {\n border: 'data-[state=checked]:border-primary',\n dot: 'bg-primary',\n },\n} as const\n\nexport type RadioColor = keyof typeof radioColorMap\n\n// Context to pass size, weight, color from RadioGroup to RadioGroupItem\ntype RadioGroupContextValue = {\n size: 'sm' | 'default' | 'lg'\n weight: 'thin' | 'bold'\n color: RadioColor\n disabled?: boolean\n}\nconst RadioGroupContext = React.createContext<RadioGroupContextValue>({ size: 'default', weight: 'bold', color: 'default' })\n\n// RadioGroup container\nconst radioGroupVariants = cva('grid gap-3', {\n variants: {\n orientation: {\n vertical: 'grid-cols-1',\n horizontal: 'grid-flow-col auto-cols-max gap-4',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n})\n\nexport interface RadioGroupProps\n extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> {\n size?: 'sm' | 'default' | 'lg'\n weight?: 'thin' | 'bold'\n /** Checked state color */\n color?: RadioColor\n}\n\nconst RadioGroupRoot = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Root>,\n RadioGroupProps\n>(({ className, orientation, size = 'default', weight = 'bold', color = 'default', disabled, ...props }, ref) => {\n const fieldContext = useFieldContext()\n const resolvedDisabled = disabled ?? fieldContext?.disabled\n\n return (\n <RadioGroupContext.Provider value={{ size, weight, color, disabled: resolvedDisabled }}>\n <RadioGroupPrimitive.Root\n ref={ref}\n className={cn(radioGroupVariants({ orientation }), className)}\n orientation={orientation || undefined}\n disabled={resolvedDisabled}\n {...props}\n />\n </RadioGroupContext.Provider>\n )\n})\nRadioGroupRoot.displayName = 'RadioGroup'\n\n// RadioGroupItem circle variants\nconst radioItemVariants = cva(\n [\n 'relative shrink-0 rounded-full border-border-form hover:border-border-form-strong transition-all duration-micro ease-out',\n 'focus-visible:focus-ring',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n // Transparent hit area expansion via ::after\n \"after:absolute after:content-['']\",\n ].join(' '),\n {\n variants: {\n size: {\n sm: 'w-3.5 h-3.5 after:-inset-[5px]', // 14px circle → 24px click\n default: 'w-4 h-4 after:-inset-2', // 16px circle → 32px click\n lg: 'w-5 h-5 after:-inset-2', // 20px circle → 36px click\n },\n weight: {\n thin: 'border', // 1px\n bold: 'border-2', // 2px\n },\n },\n defaultVariants: {\n size: 'default',\n weight: 'bold',\n },\n }\n)\n\n// Dot sizes per radio size\nconst dotSizes = {\n sm: 'w-1.5 h-1.5', // 6px\n default: 'w-2 h-2', // 8px\n lg: 'w-2.5 h-2.5', // 10px\n}\n\n// Label font sizes\nconst labelSizes = {\n sm: 'text-xs', // 12px\n default: 'text-md', // 14px\n lg: 'text-base', // 16px\n}\n\n// Gap between radio and label\nconst gapSizes = {\n sm: 'gap-1.5',\n default: 'gap-2',\n lg: 'gap-2.5',\n}\n\nexport interface RadioGroupItemProps\n extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> {\n label?: string\n}\n\nconst RadioGroupItem = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Item>,\n RadioGroupItemProps\n>(({ className, label, disabled, ...props }, ref) => {\n const { size, weight, color, disabled: groupDisabled } = React.useContext(RadioGroupContext)\n const resolvedDisabled = disabled ?? groupDisabled\n const itemId = React.useId()\n\n const radio = (\n <RadioGroupPrimitive.Item\n ref={ref}\n id={label ? itemId : undefined}\n disabled={resolvedDisabled}\n className={cn(\n radioItemVariants({ size, weight }),\n radioColorMap[color].border,\n className\n )}\n {...props}\n >\n <RadioGroupPrimitive.Indicator className=\"flex items-center justify-center animate-radio-enter\">\n <div className={cn('rounded-full', radioColorMap[color].dot, dotSizes[size])} />\n </RadioGroupPrimitive.Indicator>\n </RadioGroupPrimitive.Item>\n )\n\n if (!label) return radio\n\n return (\n <div className={cn('group flex items-center', gapSizes[size])}>\n <div className=\"flex items-center\">\n {radio}\n </div>\n <label\n htmlFor={itemId}\n className={cn(\n labelSizes[size],\n 'text-text-muted cursor-pointer select-none transition-colors duration-micro',\n 'group-hover:text-foreground',\n resolvedDisabled && 'opacity-50 cursor-not-allowed'\n )}\n >\n {label}\n </label>\n </div>\n )\n})\nRadioGroupItem.displayName = 'RadioGroupItem'\n\n// ─── Namespace ──────────────────────────────────────────\nconst RadioGroup = Object.assign(RadioGroupRoot, {\n Item: RadioGroupItem,\n})\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace RadioGroup {\n export type ItemProps = RadioGroupItemProps\n}\n\nexport { RadioGroup, RadioGroupItem, radioGroupVariants, radioItemVariants }\n"],"mappings":";AAEA,YAAY,WAAW;AACvB,YAAY,yBAAyB;AACrC,SAAS,WAAW;AACpB,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAGhC,MAAM,gBAAgB;AAAA,EACpB,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AACF;AAWA,MAAM,oBAAoB,MAAM,cAAsC,EAAE,MAAM,WAAW,QAAQ,QAAQ,OAAO,UAAU,CAAC;AAG3H,MAAM,qBAAqB,IAAI,cAAc;AAAA,EAC3C,UAAU;AAAA,IACR,aAAa;AAAA,MACX,UAAU;AAAA,MACV,YAAY;AAAA,IACd;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,aAAa;AAAA,EACf;AACF,CAAC;AAUD,MAAM,iBAAiB,MAAM,WAG3B,CAAC,EAAE,WAAW,aAAa,OAAO,WAAW,SAAS,QAAQ,QAAQ,WAAW,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/G,QAAM,eAAe,gBAAgB;AACrC,QAAM,mBAAmB,YAAY,cAAc;AAEnD,SACE,oCAAC,kBAAkB,UAAlB,EAA2B,OAAO,EAAE,MAAM,QAAQ,OAAO,UAAU,iBAAiB,KACnF;AAAA,IAAC,oBAAoB;AAAA,IAApB;AAAA,MACC;AAAA,MACA,WAAW,GAAG,mBAAmB,EAAE,YAAY,CAAC,GAAG,SAAS;AAAA,MAC5D,aAAa,eAAe;AAAA,MAC5B,UAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACN,CACF;AA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WAAW,GAAG,gBAAgB,cAAc,KAAK,EAAE,KAAK,SAAS,IAAI,CAAC,GAAG,CAChF;AAAA,EACF;AAGF,MAAI,CAAC,MAAO,QAAO;AAEnB,SACE,oCAAC,SAAI,WAAW,GAAG,2BAA2B,SAAS,IAAI,CAAC,KAC1D,oCAAC,SAAI,WAAU,uBACZ,KACH,GACA;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,WAAW;AAAA,QACT,WAAW,IAAI;AAAA,QACf;AAAA,QACA;AAAA,QACA,oBAAoB;AAAA,MACtB;AAAA;AAAA,IAEC;AAAA,EACH,CACF;AAEJ,CAAC;AACD,eAAe,cAAc;AAG7B,MAAM,aAAa,OAAO,OAAO,gBAAgB;AAAA,EAC/C,MAAM;AACR,CAAC;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
4
|
+
import { VariantProps } from 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
declare const segmentedVariants: (props?: ({
|
|
7
|
+
variant?: "default" | "outline" | "ghost" | "underline" | null | undefined;
|
|
8
|
+
size?: "default" | "sm" | "lg" | "md" | null | undefined;
|
|
9
|
+
radius?: "default" | "sm" | "lg" | "base" | "none" | "xl" | "2xl" | "3xl" | "full" | null | undefined;
|
|
10
|
+
fontWeight?: "normal" | "semibold" | null | undefined;
|
|
11
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
12
|
+
declare const segmentedItemVariants: (props?: ({
|
|
13
|
+
variant?: "default" | "outline" | "ghost" | "underline" | null | undefined;
|
|
14
|
+
size?: "default" | "sm" | "lg" | "md" | null | undefined;
|
|
15
|
+
radius?: "default" | "sm" | "lg" | "base" | "none" | "xl" | "2xl" | "3xl" | "full" | null | undefined;
|
|
16
|
+
contentType?: "text" | "icon" | "icon-text" | null | undefined;
|
|
17
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
18
|
+
interface SegmentedProps extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>, VariantProps<typeof segmentedVariants> {
|
|
19
|
+
}
|
|
20
|
+
interface SegmentedItemProps extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>, Omit<VariantProps<typeof segmentedItemVariants>, 'variant'> {
|
|
21
|
+
}
|
|
22
|
+
declare const SegmentedItem: React.ForwardRefExoticComponent<SegmentedItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
23
|
+
declare const Segmented: React.ForwardRefExoticComponent<SegmentedProps & React.RefAttributes<HTMLDivElement>> & {
|
|
24
|
+
Item: React.ForwardRefExoticComponent<SegmentedItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
};
|
|
26
|
+
declare namespace Segmented {
|
|
27
|
+
type ItemProps = SegmentedItemProps;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { Segmented, SegmentedItem, type SegmentedItemProps, type SegmentedProps, segmentedItemVariants, segmentedVariants };
|