@c-rex/ui 0.0.10 → 0.0.12
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 +87 -107
- package/src/alert.tsx +58 -0
- package/src/breadcrumb.tsx +115 -0
- package/src/button.tsx +66 -0
- package/src/command.tsx +151 -0
- package/src/dialog.tsx +122 -0
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/input.tsx +22 -0
- package/src/popover.tsx +31 -0
- package/src/select.tsx +157 -0
- package/src/separator.tsx +29 -0
- package/src/sheet.tsx +140 -0
- package/src/sidebar.tsx +785 -0
- package/src/skeleton.tsx +15 -0
- package/src/table.tsx +120 -0
- package/src/tooltip.tsx +30 -0
- package/dist/alert.cjs +0 -2
- package/dist/alert.cjs.map +0 -1
- package/dist/alert.d.cts +0 -11
- package/dist/alert.d.ts +0 -11
- package/dist/alert.js +0 -2
- package/dist/alert.js.map +0 -1
- package/dist/breadcrumb.cjs +0 -2
- package/dist/breadcrumb.cjs.map +0 -1
- package/dist/breadcrumb.d.cts +0 -22
- package/dist/breadcrumb.d.ts +0 -22
- package/dist/breadcrumb.js +0 -2
- package/dist/breadcrumb.js.map +0 -1
- package/dist/button.cjs +0 -2
- package/dist/button.cjs.map +0 -1
- package/dist/button.d.cts +0 -15
- package/dist/button.d.ts +0 -15
- package/dist/button.js +0 -2
- package/dist/button.js.map +0 -1
- package/dist/command.cjs +0 -2
- package/dist/command.cjs.map +0 -1
- package/dist/command.d.cts +0 -83
- package/dist/command.d.ts +0 -83
- package/dist/command.js +0 -2
- package/dist/command.js.map +0 -1
- package/dist/dialog.cjs +0 -2
- package/dist/dialog.cjs.map +0 -1
- package/dist/dialog.d.cts +0 -22
- package/dist/dialog.d.ts +0 -22
- package/dist/dialog.js +0 -2
- package/dist/dialog.js.map +0 -1
- package/dist/hooks/use-mobile.cjs +0 -2
- package/dist/hooks/use-mobile.cjs.map +0 -1
- package/dist/hooks/use-mobile.d.cts +0 -3
- package/dist/hooks/use-mobile.d.ts +0 -3
- package/dist/hooks/use-mobile.js +0 -2
- package/dist/hooks/use-mobile.js.map +0 -1
- package/dist/input.cjs +0 -2
- package/dist/input.cjs.map +0 -1
- package/dist/input.d.cts +0 -5
- package/dist/input.d.ts +0 -5
- package/dist/input.js +0 -2
- package/dist/input.js.map +0 -1
- package/dist/popover.cjs +0 -2
- package/dist/popover.cjs.map +0 -1
- package/dist/popover.d.cts +0 -9
- package/dist/popover.d.ts +0 -9
- package/dist/popover.js +0 -2
- package/dist/popover.js.map +0 -1
- package/dist/select.cjs +0 -2
- package/dist/select.cjs.map +0 -1
- package/dist/select.d.cts +0 -15
- package/dist/select.d.ts +0 -15
- package/dist/select.js +0 -2
- package/dist/select.js.map +0 -1
- package/dist/separator.cjs +0 -2
- package/dist/separator.cjs.map +0 -1
- package/dist/separator.d.cts +0 -6
- package/dist/separator.d.ts +0 -6
- package/dist/separator.js +0 -2
- package/dist/separator.js.map +0 -1
- package/dist/sheet.cjs +0 -2
- package/dist/sheet.cjs.map +0 -1
- package/dist/sheet.d.cts +0 -29
- package/dist/sheet.d.ts +0 -29
- package/dist/sheet.js +0 -2
- package/dist/sheet.js.map +0 -1
- package/dist/sidebar.cjs +0 -2
- package/dist/sidebar.cjs.map +0 -1
- package/dist/sidebar.d.cts +0 -72
- package/dist/sidebar.d.ts +0 -72
- package/dist/sidebar.js +0 -2
- package/dist/sidebar.js.map +0 -1
- package/dist/skeleton.cjs +0 -2
- package/dist/skeleton.cjs.map +0 -1
- package/dist/skeleton.d.cts +0 -5
- package/dist/skeleton.d.ts +0 -5
- package/dist/skeleton.js +0 -2
- package/dist/skeleton.js.map +0 -1
- package/dist/table.cjs +0 -2
- package/dist/table.cjs.map +0 -1
- package/dist/table.d.cts +0 -12
- package/dist/table.d.ts +0 -12
- package/dist/table.js +0 -2
- package/dist/table.js.map +0 -1
- package/dist/tooltip.cjs +0 -2
- package/dist/tooltip.cjs.map +0 -1
- package/dist/tooltip.d.cts +0 -9
- package/dist/tooltip.d.ts +0 -9
- package/dist/tooltip.js +0 -2
- package/dist/tooltip.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,120 +1,100 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c-rex/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
|
-
|
|
6
|
+
"src"
|
|
7
7
|
],
|
|
8
|
+
"sideEffects": false,
|
|
8
9
|
"publishConfig": {
|
|
9
|
-
|
|
10
|
+
"access": "public"
|
|
10
11
|
},
|
|
11
12
|
"exports": {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"./skeleton": {
|
|
73
|
-
"types": "./dist/skeleton.d.ts",
|
|
74
|
-
"import": "./dist/skeleton.esm.js",
|
|
75
|
-
"require": "./dist/skeleton.cjs.js"
|
|
76
|
-
},
|
|
77
|
-
"./table": {
|
|
78
|
-
"types": "./dist/table.d.ts",
|
|
79
|
-
"import": "./dist/table.esm.js",
|
|
80
|
-
"require": "./dist/table.cjs.js"
|
|
81
|
-
},
|
|
82
|
-
"./tooltip": {
|
|
83
|
-
"types": "./dist/tooltip.d.ts",
|
|
84
|
-
"import": "./dist/tooltip.esm.js",
|
|
85
|
-
"require": "./dist/tooltip.cjs.js"
|
|
86
|
-
},
|
|
87
|
-
"./package.json": "./package.json"
|
|
88
|
-
},
|
|
89
|
-
"scripts": {
|
|
90
|
-
"dev": "tsup --watch",
|
|
91
|
-
"build": "tsup"
|
|
13
|
+
"./alert": {
|
|
14
|
+
"types": "./src/alert.tsx",
|
|
15
|
+
"import": "./src/alert.tsx"
|
|
16
|
+
},
|
|
17
|
+
"./breadcrumb": {
|
|
18
|
+
"types": "./src/breadcrumb.tsx",
|
|
19
|
+
"import": "./src/breadcrumb.tsx"
|
|
20
|
+
},
|
|
21
|
+
"./button": {
|
|
22
|
+
"types": "./src/button.tsx",
|
|
23
|
+
"import": "./src/button.tsx"
|
|
24
|
+
},
|
|
25
|
+
"./command": {
|
|
26
|
+
"types": "./src/command.tsx",
|
|
27
|
+
"import": "./src/command.tsx"
|
|
28
|
+
},
|
|
29
|
+
"./dialog": {
|
|
30
|
+
"types": "./src/dialog.tsx",
|
|
31
|
+
"import": "./src/dialog.tsx"
|
|
32
|
+
},
|
|
33
|
+
"./hooks/use-mobile": {
|
|
34
|
+
"types": "./src/hooks/use-mobile.tsx",
|
|
35
|
+
"import": "./src/hooks/use-mobile.tsx"
|
|
36
|
+
},
|
|
37
|
+
"./input": {
|
|
38
|
+
"types": "./src/input.tsx",
|
|
39
|
+
"import": "./src/input.tsx"
|
|
40
|
+
},
|
|
41
|
+
"./popover": {
|
|
42
|
+
"types": "./src/popover.tsx",
|
|
43
|
+
"import": "./src/popover.tsx"
|
|
44
|
+
},
|
|
45
|
+
"./select": {
|
|
46
|
+
"types": "./src/select.tsx",
|
|
47
|
+
"import": "./src/select.tsx"
|
|
48
|
+
},
|
|
49
|
+
"./separator": {
|
|
50
|
+
"types": "./src/separator.tsx",
|
|
51
|
+
"import": "./src/separator.tsx"
|
|
52
|
+
},
|
|
53
|
+
"./sheet": {
|
|
54
|
+
"types": "./src/sheet.tsx",
|
|
55
|
+
"import": "./src/sheet.tsx"
|
|
56
|
+
},
|
|
57
|
+
"./sidebar": {
|
|
58
|
+
"types": "./src/sidebar.tsx",
|
|
59
|
+
"import": "./src/sidebar.tsx"
|
|
60
|
+
},
|
|
61
|
+
"./skeleton": {
|
|
62
|
+
"types": "./src/skeleton.tsx",
|
|
63
|
+
"import": "./src/skeleton.tsx"
|
|
64
|
+
},
|
|
65
|
+
"./table": {
|
|
66
|
+
"types": "./src/table.tsx",
|
|
67
|
+
"import": "./src/table.tsx"
|
|
68
|
+
},
|
|
69
|
+
"./tooltip": {
|
|
70
|
+
"types": "./src/tooltip.tsx",
|
|
71
|
+
"import": "./src/tooltip.tsx"
|
|
72
|
+
}
|
|
92
73
|
},
|
|
93
74
|
"devDependencies": {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
75
|
+
"@c-rex/eslint-config": "*",
|
|
76
|
+
"@c-rex/typescript-config": "*",
|
|
77
|
+
"@turbo/gen": "^2.4.4",
|
|
78
|
+
"@types/node": "^22.13.10",
|
|
79
|
+
"@types/react": "19.0.10",
|
|
80
|
+
"@types/react-dom": "19.0.4",
|
|
81
|
+
"eslint": "^9.23.0",
|
|
82
|
+
"shadcn": "^2.4.1",
|
|
83
|
+
"typescript": "latest"
|
|
103
84
|
},
|
|
104
85
|
"dependencies": {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
86
|
+
"@c-rex/utils": "*",
|
|
87
|
+
"@radix-ui/react-dialog": "^1.1.6",
|
|
88
|
+
"@radix-ui/react-popover": "^1.1.6",
|
|
89
|
+
"@radix-ui/react-select": "^2.1.6",
|
|
90
|
+
"@radix-ui/react-separator": "^1.1.2",
|
|
91
|
+
"@radix-ui/react-tooltip": "^1.1.8",
|
|
92
|
+
"class-variance-authority": "^0.7.1",
|
|
93
|
+
"clsx": "^2.1.1",
|
|
94
|
+
"cmdk": "^1.1.1",
|
|
95
|
+
"lucide-react": "^0.486.0",
|
|
96
|
+
"react": "^18.3.1",
|
|
97
|
+
"react-dom": "^18.3.1",
|
|
98
|
+
"tailwind-merge": "^3.0.2"
|
|
118
99
|
}
|
|
119
|
-
|
|
120
|
-
|
|
100
|
+
}
|
package/src/alert.tsx
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@c-rex/utils";
|
|
4
|
+
|
|
5
|
+
const alertVariants = cva(
|
|
6
|
+
"relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: "bg-background text-foreground",
|
|
11
|
+
destructive:
|
|
12
|
+
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
variant: "default",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const Alert = React.forwardRef<
|
|
22
|
+
HTMLDivElement,
|
|
23
|
+
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
|
|
24
|
+
>(({ className, variant, ...props }, ref) => (
|
|
25
|
+
<div
|
|
26
|
+
ref={ref}
|
|
27
|
+
role="alert"
|
|
28
|
+
className={cn(alertVariants({ variant }), className)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
));
|
|
32
|
+
Alert.displayName = "Alert";
|
|
33
|
+
|
|
34
|
+
const AlertTitle = React.forwardRef<
|
|
35
|
+
HTMLParagraphElement,
|
|
36
|
+
React.HTMLAttributes<HTMLHeadingElement>
|
|
37
|
+
>(({ className, ...props }, ref) => (
|
|
38
|
+
<h5
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
));
|
|
44
|
+
AlertTitle.displayName = "AlertTitle";
|
|
45
|
+
|
|
46
|
+
const AlertDescription = React.forwardRef<
|
|
47
|
+
HTMLParagraphElement,
|
|
48
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
49
|
+
>(({ className, ...props }, ref) => (
|
|
50
|
+
<div
|
|
51
|
+
ref={ref}
|
|
52
|
+
className={cn("text-sm [&_p]:leading-relaxed", className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
));
|
|
56
|
+
AlertDescription.displayName = "AlertDescription";
|
|
57
|
+
|
|
58
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@c-rex/utils";
|
|
6
|
+
|
|
7
|
+
const Breadcrumb = React.forwardRef<
|
|
8
|
+
HTMLElement,
|
|
9
|
+
React.ComponentPropsWithoutRef<"nav"> & {
|
|
10
|
+
separator?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
|
13
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
14
|
+
|
|
15
|
+
const BreadcrumbList = React.forwardRef<
|
|
16
|
+
HTMLOListElement,
|
|
17
|
+
React.ComponentPropsWithoutRef<"ol">
|
|
18
|
+
>(({ className, ...props }, ref) => (
|
|
19
|
+
<ol
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={cn(
|
|
22
|
+
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
));
|
|
28
|
+
BreadcrumbList.displayName = "BreadcrumbList";
|
|
29
|
+
|
|
30
|
+
const BreadcrumbItem = React.forwardRef<
|
|
31
|
+
HTMLLIElement,
|
|
32
|
+
React.ComponentPropsWithoutRef<"li">
|
|
33
|
+
>(({ className, ...props }, ref) => (
|
|
34
|
+
<li
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn("inline-flex items-center gap-1.5", className)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
));
|
|
40
|
+
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
41
|
+
|
|
42
|
+
const BreadcrumbLink = React.forwardRef<
|
|
43
|
+
HTMLAnchorElement,
|
|
44
|
+
React.ComponentPropsWithoutRef<"a"> & {
|
|
45
|
+
asChild?: boolean;
|
|
46
|
+
}
|
|
47
|
+
>(({ asChild, className, ...props }, ref) => {
|
|
48
|
+
const Comp = asChild ? Slot : "a";
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Comp
|
|
52
|
+
ref={ref}
|
|
53
|
+
className={cn("transition-colors hover:text-foreground", className)}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
59
|
+
|
|
60
|
+
const BreadcrumbPage = React.forwardRef<
|
|
61
|
+
HTMLSpanElement,
|
|
62
|
+
React.ComponentPropsWithoutRef<"span">
|
|
63
|
+
>(({ className, ...props }, ref) => (
|
|
64
|
+
<span
|
|
65
|
+
ref={ref}
|
|
66
|
+
role="link"
|
|
67
|
+
aria-disabled="true"
|
|
68
|
+
aria-current="page"
|
|
69
|
+
className={cn("font-normal text-foreground", className)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
));
|
|
73
|
+
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
74
|
+
|
|
75
|
+
const BreadcrumbSeparator = ({
|
|
76
|
+
children,
|
|
77
|
+
className,
|
|
78
|
+
...props
|
|
79
|
+
}: React.ComponentProps<"li">) => (
|
|
80
|
+
<li
|
|
81
|
+
role="presentation"
|
|
82
|
+
aria-hidden="true"
|
|
83
|
+
className={cn("[&>svg]:w-3.5 [&>svg]:h-3.5", className)}
|
|
84
|
+
{...props}
|
|
85
|
+
>
|
|
86
|
+
{children ?? <ChevronRight />}
|
|
87
|
+
</li>
|
|
88
|
+
);
|
|
89
|
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
90
|
+
|
|
91
|
+
const BreadcrumbEllipsis = ({
|
|
92
|
+
className,
|
|
93
|
+
...props
|
|
94
|
+
}: React.ComponentProps<"span">) => (
|
|
95
|
+
<span
|
|
96
|
+
role="presentation"
|
|
97
|
+
aria-hidden="true"
|
|
98
|
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
|
99
|
+
{...props}
|
|
100
|
+
>
|
|
101
|
+
<MoreHorizontal className="h-4 w-4" />
|
|
102
|
+
<span className="sr-only">More</span>
|
|
103
|
+
</span>
|
|
104
|
+
);
|
|
105
|
+
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
Breadcrumb,
|
|
109
|
+
BreadcrumbList,
|
|
110
|
+
BreadcrumbItem,
|
|
111
|
+
BreadcrumbLink,
|
|
112
|
+
BreadcrumbPage,
|
|
113
|
+
BreadcrumbSeparator,
|
|
114
|
+
BreadcrumbEllipsis,
|
|
115
|
+
};
|
package/src/button.tsx
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@c-rex/utils";
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
14
|
+
destructive:
|
|
15
|
+
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
16
|
+
outline:
|
|
17
|
+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
18
|
+
secondary:
|
|
19
|
+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
20
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
21
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
default: "h-9 px-4 py-2",
|
|
25
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
26
|
+
lg: "h-10 rounded-md px-8",
|
|
27
|
+
icon: "h-9 w-9",
|
|
28
|
+
},
|
|
29
|
+
rounded: {
|
|
30
|
+
default: "rounded-md",
|
|
31
|
+
sm: "rounded-sm",
|
|
32
|
+
lg: "rounded-lg",
|
|
33
|
+
xl: "rounded-xl",
|
|
34
|
+
"2xl": "rounded-2xl",
|
|
35
|
+
full: "rounded-full",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
variant: "default",
|
|
40
|
+
size: "default",
|
|
41
|
+
rounded: "default",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export interface ButtonProps
|
|
47
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
48
|
+
VariantProps<typeof buttonVariants> {
|
|
49
|
+
asChild?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
53
|
+
({ className, variant, size, rounded, asChild = false, ...props }, ref) => {
|
|
54
|
+
const Comp = asChild ? Slot : "button";
|
|
55
|
+
return (
|
|
56
|
+
<Comp
|
|
57
|
+
className={cn(buttonVariants({ variant, size, rounded, className }))}
|
|
58
|
+
ref={ref}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
Button.displayName = "Button";
|
|
65
|
+
|
|
66
|
+
export { Button, buttonVariants };
|
package/src/command.tsx
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type DialogProps } from "@radix-ui/react-dialog";
|
|
3
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
4
|
+
import { Search } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "@c-rex/utils";
|
|
7
|
+
import { Dialog, DialogContent } from "./dialog";
|
|
8
|
+
|
|
9
|
+
const Command = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof CommandPrimitive>,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
|
|
12
|
+
>(({ className, ...props }, ref) => (
|
|
13
|
+
<CommandPrimitive
|
|
14
|
+
ref={ref}
|
|
15
|
+
className={cn(
|
|
16
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
17
|
+
className,
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
));
|
|
22
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
23
|
+
|
|
24
|
+
const CommandDialog = ({ children, ...props }: DialogProps) => {
|
|
25
|
+
return (
|
|
26
|
+
<Dialog {...props}>
|
|
27
|
+
<DialogContent className="overflow-hidden p-0">
|
|
28
|
+
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
29
|
+
{children}
|
|
30
|
+
</Command>
|
|
31
|
+
</DialogContent>
|
|
32
|
+
</Dialog>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const CommandInput = React.forwardRef<
|
|
37
|
+
React.ElementRef<typeof CommandPrimitive.Input>,
|
|
38
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
|
|
39
|
+
>(({ className, ...props }, ref) => (
|
|
40
|
+
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
|
|
41
|
+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
|
42
|
+
<CommandPrimitive.Input
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn(
|
|
45
|
+
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
));
|
|
52
|
+
|
|
53
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
54
|
+
|
|
55
|
+
const CommandList = React.forwardRef<
|
|
56
|
+
React.ElementRef<typeof CommandPrimitive.List>,
|
|
57
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
58
|
+
>(({ className, ...props }, ref) => (
|
|
59
|
+
<CommandPrimitive.List
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
));
|
|
65
|
+
|
|
66
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
67
|
+
|
|
68
|
+
const CommandEmpty = React.forwardRef<
|
|
69
|
+
React.ElementRef<typeof CommandPrimitive.Empty>,
|
|
70
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
|
|
71
|
+
>((props, ref) => (
|
|
72
|
+
<CommandPrimitive.Empty
|
|
73
|
+
ref={ref}
|
|
74
|
+
className="py-6 text-center text-sm"
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
));
|
|
78
|
+
|
|
79
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
80
|
+
|
|
81
|
+
const CommandGroup = React.forwardRef<
|
|
82
|
+
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
83
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
84
|
+
>(({ className, ...props }, ref) => (
|
|
85
|
+
<CommandPrimitive.Group
|
|
86
|
+
ref={ref}
|
|
87
|
+
className={cn(
|
|
88
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
89
|
+
className,
|
|
90
|
+
)}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
));
|
|
94
|
+
|
|
95
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
96
|
+
|
|
97
|
+
const CommandSeparator = React.forwardRef<
|
|
98
|
+
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
99
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
100
|
+
>(({ className, ...props }, ref) => (
|
|
101
|
+
<CommandPrimitive.Separator
|
|
102
|
+
ref={ref}
|
|
103
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
104
|
+
{...props}
|
|
105
|
+
/>
|
|
106
|
+
));
|
|
107
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
108
|
+
|
|
109
|
+
const CommandItem = React.forwardRef<
|
|
110
|
+
React.ElementRef<typeof CommandPrimitive.Item>,
|
|
111
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
|
|
112
|
+
>(({ className, ...props }, ref) => (
|
|
113
|
+
<CommandPrimitive.Item
|
|
114
|
+
ref={ref}
|
|
115
|
+
className={cn(
|
|
116
|
+
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
117
|
+
className,
|
|
118
|
+
)}
|
|
119
|
+
{...props}
|
|
120
|
+
/>
|
|
121
|
+
));
|
|
122
|
+
|
|
123
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
124
|
+
|
|
125
|
+
const CommandShortcut = ({
|
|
126
|
+
className,
|
|
127
|
+
...props
|
|
128
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
129
|
+
return (
|
|
130
|
+
<span
|
|
131
|
+
className={cn(
|
|
132
|
+
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
133
|
+
className,
|
|
134
|
+
)}
|
|
135
|
+
{...props}
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
Command,
|
|
143
|
+
CommandDialog,
|
|
144
|
+
CommandInput,
|
|
145
|
+
CommandList,
|
|
146
|
+
CommandEmpty,
|
|
147
|
+
CommandGroup,
|
|
148
|
+
CommandItem,
|
|
149
|
+
CommandShortcut,
|
|
150
|
+
CommandSeparator,
|
|
151
|
+
};
|