@quarklab/rad-ui 0.3.1 → 0.3.2
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/package.json +3 -5
- package/templates/web/aspect-ratio.tsx +0 -5
- package/templates/web/avatar.tsx +0 -47
- package/templates/web/badge.tsx +0 -35
- package/templates/web/button.tsx +0 -54
- package/templates/web/checkbox.tsx +0 -34
- package/templates/web/field.tsx +0 -291
- package/templates/web/input/input.tsx +0 -454
- package/templates/web/input/validation.ts +0 -202
- package/templates/web/input-group.tsx +0 -209
- package/templates/web/input-otp.tsx +0 -85
- package/templates/web/kbd.tsx +0 -37
- package/templates/web/label.tsx +0 -23
- package/templates/web/lib/utils.ts +0 -7
- package/templates/web/native-select.tsx +0 -71
- package/templates/web/radio-group.tsx +0 -43
- package/templates/web/separator.tsx +0 -29
- package/templates/web/skeleton.tsx +0 -15
- package/templates/web/slider.tsx +0 -46
- package/templates/web/spinner.tsx +0 -44
- package/templates/web/switch.tsx +0 -32
- package/templates/web/textarea.tsx +0 -28
- package/templates/web/toggle-group.tsx +0 -58
- package/templates/web/toggle.tsx +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quarklab/rad-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "A CLI for adding Rad UI components to your project. Beautiful Persian-themed React components built on Radix UI and Tailwind CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,14 +9,12 @@
|
|
|
9
9
|
"rad-ui": "dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
13
|
-
"templates"
|
|
12
|
+
"dist"
|
|
14
13
|
],
|
|
15
14
|
"scripts": {
|
|
16
|
-
"prebuild": "node scripts/sync-templates.js",
|
|
17
15
|
"build": "tsup",
|
|
18
16
|
"dev": "tsup --watch",
|
|
19
|
-
"clean": "rm -rf dist
|
|
17
|
+
"clean": "rm -rf dist"
|
|
20
18
|
},
|
|
21
19
|
"dependencies": {
|
|
22
20
|
"commander": "^12.1.0",
|
package/templates/web/avatar.tsx
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
3
|
-
import { cn } from "../lib/utils";
|
|
4
|
-
|
|
5
|
-
const Avatar = React.forwardRef<
|
|
6
|
-
React.ElementRef<typeof AvatarPrimitive.Root>,
|
|
7
|
-
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
|
8
|
-
>(({ className, ...props }, ref) => (
|
|
9
|
-
<AvatarPrimitive.Root
|
|
10
|
-
ref={ref}
|
|
11
|
-
className={cn(
|
|
12
|
-
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
|
13
|
-
className
|
|
14
|
-
)}
|
|
15
|
-
{...props}
|
|
16
|
-
/>
|
|
17
|
-
));
|
|
18
|
-
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
19
|
-
|
|
20
|
-
const AvatarImage = React.forwardRef<
|
|
21
|
-
React.ElementRef<typeof AvatarPrimitive.Image>,
|
|
22
|
-
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
|
23
|
-
>(({ className, ...props }, ref) => (
|
|
24
|
-
<AvatarPrimitive.Image
|
|
25
|
-
ref={ref}
|
|
26
|
-
className={cn("aspect-square h-full w-full", className)}
|
|
27
|
-
{...props}
|
|
28
|
-
/>
|
|
29
|
-
));
|
|
30
|
-
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
31
|
-
|
|
32
|
-
const AvatarFallback = React.forwardRef<
|
|
33
|
-
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
|
34
|
-
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
|
35
|
-
>(({ className, ...props }, ref) => (
|
|
36
|
-
<AvatarPrimitive.Fallback
|
|
37
|
-
ref={ref}
|
|
38
|
-
className={cn(
|
|
39
|
-
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
|
40
|
-
className
|
|
41
|
-
)}
|
|
42
|
-
{...props}
|
|
43
|
-
/>
|
|
44
|
-
));
|
|
45
|
-
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
46
|
-
|
|
47
|
-
export { Avatar, AvatarImage, AvatarFallback };
|
package/templates/web/badge.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { type VariantProps, cva } from "class-variance-authority";
|
|
3
|
-
import { cn } from "../lib/utils";
|
|
4
|
-
|
|
5
|
-
const badgeVariants = cva(
|
|
6
|
-
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
7
|
-
{
|
|
8
|
-
variants: {
|
|
9
|
-
variant: {
|
|
10
|
-
default:
|
|
11
|
-
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
|
12
|
-
secondary:
|
|
13
|
-
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
14
|
-
destructive:
|
|
15
|
-
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
|
16
|
-
outline: "text-foreground",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
defaultVariants: {
|
|
20
|
-
variant: "default",
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export interface BadgeProps
|
|
26
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
27
|
-
VariantProps<typeof badgeVariants> {}
|
|
28
|
-
|
|
29
|
-
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
30
|
-
return (
|
|
31
|
-
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { Badge, badgeVariants };
|
package/templates/web/button.tsx
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { type VariantProps, cva } from "class-variance-authority";
|
|
3
|
-
import { cn } from "../lib/utils";
|
|
4
|
-
|
|
5
|
-
const buttonVariants = cva(
|
|
6
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
7
|
-
{
|
|
8
|
-
variants: {
|
|
9
|
-
variant: {
|
|
10
|
-
default:
|
|
11
|
-
"bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80",
|
|
12
|
-
destructive:
|
|
13
|
-
"bg-destructive text-destructive-foreground hover:bg-destructive/90 active:bg-destructive/80",
|
|
14
|
-
outline:
|
|
15
|
-
"border border-border bg-background hover:bg-muted hover:text-foreground active:bg-muted/80",
|
|
16
|
-
ghost:
|
|
17
|
-
"hover:bg-muted hover:text-foreground active:bg-muted/80",
|
|
18
|
-
link:
|
|
19
|
-
"text-primary underline-offset-4 hover:underline active:text-primary/80",
|
|
20
|
-
},
|
|
21
|
-
size: {
|
|
22
|
-
sm: "h-9 px-3 text-xs rounded-md",
|
|
23
|
-
md: "h-10 px-4 py-2",
|
|
24
|
-
lg: "h-11 px-8 text-base rounded-lg",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
defaultVariants: {
|
|
28
|
-
variant: "default",
|
|
29
|
-
size: "md",
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
export interface ButtonProps
|
|
35
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
36
|
-
VariantProps<typeof buttonVariants> {
|
|
37
|
-
asChild?: boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
41
|
-
({ className, variant, size, ...props }, ref) => {
|
|
42
|
-
return (
|
|
43
|
-
<button
|
|
44
|
-
className={cn(buttonVariants({ variant, size, className }))}
|
|
45
|
-
ref={ref}
|
|
46
|
-
{...props}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
Button.displayName = "Button";
|
|
53
|
-
|
|
54
|
-
export { Button, buttonVariants };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
|
-
import { Check } from "lucide-react";
|
|
4
|
-
import { cn } from "../lib/utils";
|
|
5
|
-
|
|
6
|
-
export interface CheckboxProps
|
|
7
|
-
extends React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> {}
|
|
8
|
-
|
|
9
|
-
const Checkbox = React.forwardRef<
|
|
10
|
-
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
11
|
-
CheckboxProps
|
|
12
|
-
>(({ className, ...props }, ref) => (
|
|
13
|
-
<CheckboxPrimitive.Root
|
|
14
|
-
ref={ref}
|
|
15
|
-
className={cn(
|
|
16
|
-
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow transition-colors",
|
|
17
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
18
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
19
|
-
"data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
20
|
-
className
|
|
21
|
-
)}
|
|
22
|
-
{...props}
|
|
23
|
-
>
|
|
24
|
-
<CheckboxPrimitive.Indicator
|
|
25
|
-
className={cn("flex items-center justify-center text-current")}
|
|
26
|
-
>
|
|
27
|
-
<Check className="h-4 w-4" />
|
|
28
|
-
</CheckboxPrimitive.Indicator>
|
|
29
|
-
</CheckboxPrimitive.Root>
|
|
30
|
-
));
|
|
31
|
-
|
|
32
|
-
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
33
|
-
|
|
34
|
-
export { Checkbox };
|
package/templates/web/field.tsx
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
-
|
|
6
|
-
import { cn } from "../lib/utils";
|
|
7
|
-
import { Label } from "./label";
|
|
8
|
-
import { Separator } from "./separator";
|
|
9
|
-
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
// FieldSet
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
|
|
14
|
-
const FieldSet = React.forwardRef<
|
|
15
|
-
HTMLFieldSetElement,
|
|
16
|
-
React.FieldsetHTMLAttributes<HTMLFieldSetElement>
|
|
17
|
-
>(({ className, ...props }, ref) => (
|
|
18
|
-
<fieldset
|
|
19
|
-
ref={ref}
|
|
20
|
-
className={cn(
|
|
21
|
-
"space-y-6 border-none p-0 [&>*+[data-slot=field-group]]:pt-4",
|
|
22
|
-
className
|
|
23
|
-
)}
|
|
24
|
-
{...props}
|
|
25
|
-
/>
|
|
26
|
-
));
|
|
27
|
-
FieldSet.displayName = "FieldSet";
|
|
28
|
-
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
// FieldLegend
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
interface FieldLegendProps extends React.HTMLAttributes<HTMLLegendElement> {
|
|
34
|
-
variant?: "legend" | "label";
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const FieldLegend = React.forwardRef<HTMLLegendElement, FieldLegendProps>(
|
|
38
|
-
({ className, variant = "legend", ...props }, ref) => (
|
|
39
|
-
<legend
|
|
40
|
-
ref={ref}
|
|
41
|
-
className={cn(
|
|
42
|
-
variant === "legend"
|
|
43
|
-
? "text-base font-semibold leading-none"
|
|
44
|
-
: "text-sm font-medium leading-none",
|
|
45
|
-
className
|
|
46
|
-
)}
|
|
47
|
-
{...props}
|
|
48
|
-
/>
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
FieldLegend.displayName = "FieldLegend";
|
|
52
|
-
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
|
-
// FieldGroup
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
|
-
|
|
57
|
-
const FieldGroup = React.forwardRef<
|
|
58
|
-
HTMLDivElement,
|
|
59
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
60
|
-
>(({ className, ...props }, ref) => (
|
|
61
|
-
<div
|
|
62
|
-
ref={ref}
|
|
63
|
-
data-slot="field-group"
|
|
64
|
-
className={cn("@container/field-group flex flex-col gap-4", className)}
|
|
65
|
-
{...props}
|
|
66
|
-
/>
|
|
67
|
-
));
|
|
68
|
-
FieldGroup.displayName = "FieldGroup";
|
|
69
|
-
|
|
70
|
-
// ---------------------------------------------------------------------------
|
|
71
|
-
// Field
|
|
72
|
-
// ---------------------------------------------------------------------------
|
|
73
|
-
|
|
74
|
-
const fieldVariants = cva(
|
|
75
|
-
"group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
76
|
-
{
|
|
77
|
-
variants: {
|
|
78
|
-
orientation: {
|
|
79
|
-
vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
|
|
80
|
-
horizontal: [
|
|
81
|
-
"flex-row items-center",
|
|
82
|
-
"[&>[data-slot=field-label]]:flex-auto",
|
|
83
|
-
"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
84
|
-
],
|
|
85
|
-
responsive: [
|
|
86
|
-
"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto",
|
|
87
|
-
"@md/field-group:[&>[data-slot=field-label]]:flex-auto",
|
|
88
|
-
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
defaultVariants: {
|
|
93
|
-
orientation: "vertical",
|
|
94
|
-
},
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
export interface FieldProps
|
|
99
|
-
extends
|
|
100
|
-
React.HTMLAttributes<HTMLDivElement>,
|
|
101
|
-
VariantProps<typeof fieldVariants> {}
|
|
102
|
-
|
|
103
|
-
const Field = React.forwardRef<HTMLDivElement, FieldProps>(
|
|
104
|
-
({ className, orientation = "vertical", ...props }, ref) => (
|
|
105
|
-
<div
|
|
106
|
-
ref={ref}
|
|
107
|
-
role="group"
|
|
108
|
-
data-slot="field"
|
|
109
|
-
className={cn(fieldVariants({ orientation }), className)}
|
|
110
|
-
{...props}
|
|
111
|
-
/>
|
|
112
|
-
)
|
|
113
|
-
);
|
|
114
|
-
Field.displayName = "Field";
|
|
115
|
-
|
|
116
|
-
// ---------------------------------------------------------------------------
|
|
117
|
-
// FieldContent
|
|
118
|
-
// ---------------------------------------------------------------------------
|
|
119
|
-
|
|
120
|
-
const FieldContent = React.forwardRef<
|
|
121
|
-
HTMLDivElement,
|
|
122
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
123
|
-
>(({ className, ...props }, ref) => (
|
|
124
|
-
<div
|
|
125
|
-
ref={ref}
|
|
126
|
-
data-slot="field-content"
|
|
127
|
-
className={cn("flex flex-col gap-1", className)}
|
|
128
|
-
{...props}
|
|
129
|
-
/>
|
|
130
|
-
));
|
|
131
|
-
FieldContent.displayName = "FieldContent";
|
|
132
|
-
|
|
133
|
-
// ---------------------------------------------------------------------------
|
|
134
|
-
// FieldLabel
|
|
135
|
-
// ---------------------------------------------------------------------------
|
|
136
|
-
|
|
137
|
-
const FieldLabel = React.forwardRef<
|
|
138
|
-
React.ElementRef<typeof Label>,
|
|
139
|
-
React.ComponentPropsWithoutRef<typeof Label>
|
|
140
|
-
>(({ className, ...props }, ref) => (
|
|
141
|
-
<Label
|
|
142
|
-
ref={ref}
|
|
143
|
-
data-slot="field-label"
|
|
144
|
-
className={cn(
|
|
145
|
-
"group-data-[invalid=true]/field:text-destructive",
|
|
146
|
-
className
|
|
147
|
-
)}
|
|
148
|
-
{...props}
|
|
149
|
-
/>
|
|
150
|
-
));
|
|
151
|
-
FieldLabel.displayName = "FieldLabel";
|
|
152
|
-
|
|
153
|
-
// ---------------------------------------------------------------------------
|
|
154
|
-
// FieldTitle
|
|
155
|
-
// ---------------------------------------------------------------------------
|
|
156
|
-
|
|
157
|
-
const FieldTitle = React.forwardRef<
|
|
158
|
-
HTMLDivElement,
|
|
159
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
160
|
-
>(({ className, ...props }, ref) => (
|
|
161
|
-
<div
|
|
162
|
-
ref={ref}
|
|
163
|
-
data-slot="field-title"
|
|
164
|
-
className={cn(
|
|
165
|
-
"text-sm font-medium leading-none group-data-[invalid=true]/field:text-destructive",
|
|
166
|
-
className
|
|
167
|
-
)}
|
|
168
|
-
{...props}
|
|
169
|
-
/>
|
|
170
|
-
));
|
|
171
|
-
FieldTitle.displayName = "FieldTitle";
|
|
172
|
-
|
|
173
|
-
// ---------------------------------------------------------------------------
|
|
174
|
-
// FieldDescription
|
|
175
|
-
// ---------------------------------------------------------------------------
|
|
176
|
-
|
|
177
|
-
const FieldDescription = React.forwardRef<
|
|
178
|
-
HTMLParagraphElement,
|
|
179
|
-
React.HTMLAttributes<HTMLParagraphElement>
|
|
180
|
-
>(({ className, ...props }, ref) => (
|
|
181
|
-
<p
|
|
182
|
-
ref={ref}
|
|
183
|
-
data-slot="field-description"
|
|
184
|
-
className={cn("text-sm text-muted-foreground text-pretty", className)}
|
|
185
|
-
{...props}
|
|
186
|
-
/>
|
|
187
|
-
));
|
|
188
|
-
FieldDescription.displayName = "FieldDescription";
|
|
189
|
-
|
|
190
|
-
// ---------------------------------------------------------------------------
|
|
191
|
-
// FieldSeparator
|
|
192
|
-
// ---------------------------------------------------------------------------
|
|
193
|
-
|
|
194
|
-
interface FieldSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
195
|
-
children?: React.ReactNode;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const FieldSeparator = React.forwardRef<HTMLDivElement, FieldSeparatorProps>(
|
|
199
|
-
({ children, className, ...props }, ref) => (
|
|
200
|
-
<div
|
|
201
|
-
ref={ref}
|
|
202
|
-
data-slot="field-separator"
|
|
203
|
-
className={cn("flex items-center gap-3", className)}
|
|
204
|
-
{...props}
|
|
205
|
-
>
|
|
206
|
-
<Separator className="flex-1" />
|
|
207
|
-
{children && (
|
|
208
|
-
<span className="text-xs text-muted-foreground font-medium">
|
|
209
|
-
{children}
|
|
210
|
-
</span>
|
|
211
|
-
)}
|
|
212
|
-
<Separator className={cn("flex-1", !children && "hidden")} />
|
|
213
|
-
</div>
|
|
214
|
-
)
|
|
215
|
-
);
|
|
216
|
-
FieldSeparator.displayName = "FieldSeparator";
|
|
217
|
-
|
|
218
|
-
// ---------------------------------------------------------------------------
|
|
219
|
-
// FieldError
|
|
220
|
-
// ---------------------------------------------------------------------------
|
|
221
|
-
|
|
222
|
-
interface FieldErrorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
223
|
-
errors?: Array<{ message?: string } | undefined>;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const FieldError = React.forwardRef<HTMLDivElement, FieldErrorProps>(
|
|
227
|
-
({ className, children, errors, ...props }, ref) => {
|
|
228
|
-
const content = React.useMemo(() => {
|
|
229
|
-
if (children) {
|
|
230
|
-
return children;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (!errors?.length) {
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const uniqueErrors = [
|
|
238
|
-
...new Map(errors.map((error) => [error?.message, error])).values(),
|
|
239
|
-
];
|
|
240
|
-
|
|
241
|
-
if (uniqueErrors?.length === 1) {
|
|
242
|
-
return uniqueErrors[0]?.message;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return (
|
|
246
|
-
<ul className="list-disc list-inside space-y-1">
|
|
247
|
-
{uniqueErrors.map(
|
|
248
|
-
(error, index) =>
|
|
249
|
-
error?.message && <li key={index}>{error.message}</li>
|
|
250
|
-
)}
|
|
251
|
-
</ul>
|
|
252
|
-
);
|
|
253
|
-
}, [children, errors]);
|
|
254
|
-
|
|
255
|
-
if (!content) {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return (
|
|
260
|
-
<div
|
|
261
|
-
ref={ref}
|
|
262
|
-
data-slot="field-error"
|
|
263
|
-
role="alert"
|
|
264
|
-
className={cn("text-sm text-destructive", className)}
|
|
265
|
-
{...props}
|
|
266
|
-
>
|
|
267
|
-
{content}
|
|
268
|
-
</div>
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
);
|
|
272
|
-
FieldError.displayName = "FieldError";
|
|
273
|
-
|
|
274
|
-
// ---------------------------------------------------------------------------
|
|
275
|
-
// Exports
|
|
276
|
-
// ---------------------------------------------------------------------------
|
|
277
|
-
|
|
278
|
-
export {
|
|
279
|
-
Field,
|
|
280
|
-
fieldVariants,
|
|
281
|
-
FieldContent,
|
|
282
|
-
FieldDescription,
|
|
283
|
-
FieldError,
|
|
284
|
-
FieldGroup,
|
|
285
|
-
FieldLabel,
|
|
286
|
-
FieldLegend,
|
|
287
|
-
FieldSeparator,
|
|
288
|
-
FieldSet,
|
|
289
|
-
FieldTitle,
|
|
290
|
-
};
|
|
291
|
-
export type { FieldLegendProps, FieldSeparatorProps, FieldErrorProps };
|