@quarklab/rad-ui 0.1.5 → 0.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/package.json CHANGED
@@ -1,42 +1,50 @@
1
1
  {
2
2
  "name": "@quarklab/rad-ui",
3
- "version": "0.1.5",
4
- "private": false,
3
+ "version": "0.3.0",
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
+ "license": "MIT",
6
+ "type": "module",
5
7
  "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "rad-ui": "dist/index.js"
10
+ },
8
11
  "files": [
9
- "dist/**"
12
+ "dist",
13
+ "templates"
10
14
  ],
11
15
  "scripts": {
12
- "lint": "eslint . --max-warnings 0",
13
- "build": "tsup src/index.ts --format cjs,esm --dts --minify --clean"
16
+ "prebuild": "node scripts/sync-templates.js",
17
+ "build": "tsup",
18
+ "dev": "tsup --watch",
19
+ "clean": "rm -rf dist templates/web templates/mobile"
14
20
  },
15
21
  "dependencies": {
16
- "@radix-ui/react-aspect-ratio": "^1.1.8",
17
- "@radix-ui/react-avatar": "^1.1.11",
18
- "@radix-ui/react-label": "^2.1.8",
19
- "@radix-ui/react-separator": "^1.1.8",
20
- "class-variance-authority": "^0.7.1",
21
- "clsx": "^2.1.0",
22
- "tailwind-merge": "^2.2.1"
22
+ "commander": "^12.1.0",
23
+ "@clack/prompts": "^0.8.2",
24
+ "chalk": "^5.3.0",
25
+ "fs-extra": "^11.2.0",
26
+ "execa": "^9.5.2"
23
27
  },
24
28
  "devDependencies": {
25
- "@types/react": "^18.2.48",
26
- "@types/react-dom": "^18.2.18",
27
- "@typescript-eslint/eslint-plugin": "^8.51.0",
28
- "@typescript-eslint/parser": "^8.51.0",
29
- "autoprefixer": "^10.4.17",
30
- "eslint": "^8.57.1",
31
- "postcss": "^8.4.33",
32
- "tailwindcss": "^3.4.1",
33
- "tailwindcss-rtl": "^0.9.0",
34
- "tsup": "^8.3.6",
29
+ "@types/fs-extra": "^11.0.4",
30
+ "@types/node": "^20.11.5",
31
+ "tsup": "^8.0.0",
35
32
  "typescript": "^5.3.3"
36
33
  },
37
- "peerDependencies": {
38
- "react": "^18.0.0 || ^19.0.0",
39
- "react-dom": "^18.0.0 || ^19.0.0",
40
- "tailwindcss": "^3.0.0"
41
- }
34
+ "keywords": [
35
+ "rad-ui",
36
+ "react",
37
+ "ui",
38
+ "components",
39
+ "cli",
40
+ "tailwindcss",
41
+ "radix-ui",
42
+ "persian",
43
+ "quarklab"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/quarklab/rad-ui.git"
48
+ },
49
+ "homepage": "https://rad-ui.com"
42
50
  }
@@ -0,0 +1,5 @@
1
+ import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio";
2
+
3
+ const AspectRatio = AspectRatioPrimitive.Root;
4
+
5
+ export { AspectRatio };
@@ -0,0 +1,47 @@
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 };
@@ -0,0 +1,35 @@
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 };
@@ -0,0 +1,54 @@
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 };
@@ -0,0 +1,34 @@
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 };
@@ -0,0 +1,291 @@
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 };