@c-rex/ui 0.0.4 → 0.0.5
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 +2 -2
- 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/constants/src/index.d.ts +0 -17
- package/dist/constants/src/index.d.ts.map +0 -1
- package/dist/constants/src/index.js +0 -30
- package/dist/interfaces/src/common.d.ts +0 -36
- package/dist/interfaces/src/common.d.ts.map +0 -1
- package/dist/interfaces/src/common.js +0 -2
- package/dist/interfaces/src/config.d.ts +0 -26
- package/dist/interfaces/src/config.d.ts.map +0 -1
- package/dist/interfaces/src/config.js +0 -2
- package/dist/interfaces/src/directoryNodes.d.ts +0 -8
- package/dist/interfaces/src/directoryNodes.d.ts.map +0 -1
- package/dist/interfaces/src/directoryNodes.js +0 -2
- package/dist/interfaces/src/documentTypes.d.ts +0 -7
- package/dist/interfaces/src/documentTypes.d.ts.map +0 -1
- package/dist/interfaces/src/documentTypes.js +0 -2
- package/dist/interfaces/src/index.d.ts +0 -7
- package/dist/interfaces/src/index.d.ts.map +0 -1
- package/dist/interfaces/src/index.js +0 -22
- package/dist/interfaces/src/informationUnits.d.ts +0 -53
- package/dist/interfaces/src/informationUnits.d.ts.map +0 -1
- package/dist/interfaces/src/informationUnits.js +0 -2
- package/dist/interfaces/src/treeOfContent.d.ts +0 -8
- package/dist/interfaces/src/treeOfContent.d.ts.map +0 -1
- package/dist/interfaces/src/treeOfContent.js +0 -2
- package/dist/types/src/index.d.ts +0 -8
- package/dist/types/src/index.d.ts.map +0 -1
- package/dist/types/src/index.js +0 -2
- package/dist/ui/src/alert.d.ts +0 -9
- package/dist/ui/src/alert.d.ts.map +0 -1
- package/dist/ui/src/alert.js +0 -60
- package/dist/ui/src/breadcrumb.d.ts +0 -20
- package/dist/ui/src/breadcrumb.d.ts.map +0 -1
- package/dist/ui/src/breadcrumb.js +0 -65
- package/dist/ui/src/button.d.ts +0 -13
- package/dist/ui/src/button.d.ts.map +0 -1
- package/dist/ui/src/button.js +0 -79
- package/dist/ui/src/command.d.ts +0 -81
- package/dist/ui/src/command.d.ts.map +0 -1
- package/dist/ui/src/command.js +0 -72
- package/dist/ui/src/dialog.d.ts +0 -20
- package/dist/ui/src/dialog.d.ts.map +0 -1
- package/dist/ui/src/dialog.js +0 -68
- package/dist/ui/src/hooks/use-mobile.d.ts +0 -2
- package/dist/ui/src/hooks/use-mobile.d.ts.map +0 -1
- package/dist/ui/src/hooks/use-mobile.js +0 -18
- package/dist/ui/src/input.d.ts +0 -4
- package/dist/ui/src/input.d.ts.map +0 -1
- package/dist/ui/src/input.js +0 -44
- package/dist/ui/src/popover.d.ts +0 -8
- package/dist/ui/src/popover.d.ts.map +0 -1
- package/dist/ui/src/popover.js +0 -49
- package/dist/ui/src/select.d.ts +0 -14
- package/dist/ui/src/select.d.ts.map +0 -1
- package/dist/ui/src/select.js +0 -71
- package/dist/ui/src/separator.d.ts +0 -5
- package/dist/ui/src/separator.d.ts.map +0 -1
- package/dist/ui/src/separator.js +0 -43
- package/dist/ui/src/sheet.d.ts +0 -26
- package/dist/ui/src/sheet.d.ts.map +0 -1
- package/dist/ui/src/sheet.js +0 -82
- package/dist/ui/src/sidebar.d.ts +0 -67
- package/dist/ui/src/sidebar.d.ts.map +0 -1
- package/dist/ui/src/sidebar.js +0 -292
- package/dist/ui/src/skeleton.d.ts +0 -3
- package/dist/ui/src/skeleton.d.ts.map +0 -1
- package/dist/ui/src/skeleton.js +0 -8
- package/dist/ui/src/table.d.ts +0 -11
- package/dist/ui/src/table.d.ts.map +0 -1
- package/dist/ui/src/table.js +0 -63
- package/dist/ui/src/tooltip.d.ts +0 -8
- package/dist/ui/src/tooltip.d.ts.map +0 -1
- package/dist/ui/src/tooltip.js +0 -49
- package/dist/utils/src/breadcrumbs.d.ts +0 -3
- package/dist/utils/src/breadcrumbs.d.ts.map +0 -1
- package/dist/utils/src/breadcrumbs.js +0 -14
- package/dist/utils/src/classMerge.d.ts +0 -3
- package/dist/utils/src/classMerge.d.ts.map +0 -1
- package/dist/utils/src/classMerge.js +0 -8
- package/dist/utils/src/index.d.ts +0 -5
- package/dist/utils/src/index.d.ts.map +0 -1
- package/dist/utils/src/index.js +0 -20
- package/dist/utils/src/treeOfContent.d.ts +0 -2
- package/dist/utils/src/treeOfContent.d.ts.map +0 -1
- package/dist/utils/src/treeOfContent.js +0 -85
- package/dist/utils/src/utils.d.ts +0 -8
- package/dist/utils/src/utils.d.ts.map +0 -1
- package/dist/utils/src/utils.js +0 -37
package/package.json
CHANGED
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
|
+
};
|
package/src/dialog.tsx
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@c-rex/utils";
|
|
8
|
+
|
|
9
|
+
const Dialog = DialogPrimitive.Root;
|
|
10
|
+
|
|
11
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
12
|
+
|
|
13
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
14
|
+
|
|
15
|
+
const DialogClose = DialogPrimitive.Close;
|
|
16
|
+
|
|
17
|
+
const DialogOverlay = React.forwardRef<
|
|
18
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
19
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
20
|
+
>(({ className, ...props }, ref) => (
|
|
21
|
+
<DialogPrimitive.Overlay
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn(
|
|
24
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
25
|
+
className,
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
));
|
|
30
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
31
|
+
|
|
32
|
+
const DialogContent = React.forwardRef<
|
|
33
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
35
|
+
>(({ className, children, ...props }, ref) => (
|
|
36
|
+
<DialogPortal>
|
|
37
|
+
<DialogOverlay />
|
|
38
|
+
<DialogPrimitive.Content
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn(
|
|
41
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
|
48
|
+
<X className="h-4 w-4" />
|
|
49
|
+
<span className="sr-only">Close</span>
|
|
50
|
+
</DialogPrimitive.Close>
|
|
51
|
+
</DialogPrimitive.Content>
|
|
52
|
+
</DialogPortal>
|
|
53
|
+
));
|
|
54
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
55
|
+
|
|
56
|
+
const DialogHeader = ({
|
|
57
|
+
className,
|
|
58
|
+
...props
|
|
59
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
60
|
+
<div
|
|
61
|
+
className={cn(
|
|
62
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
63
|
+
className,
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
DialogHeader.displayName = "DialogHeader";
|
|
69
|
+
|
|
70
|
+
const DialogFooter = ({
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
74
|
+
<div
|
|
75
|
+
className={cn(
|
|
76
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
77
|
+
className,
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
DialogFooter.displayName = "DialogFooter";
|
|
83
|
+
|
|
84
|
+
const DialogTitle = React.forwardRef<
|
|
85
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
86
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
87
|
+
>(({ className, ...props }, ref) => (
|
|
88
|
+
<DialogPrimitive.Title
|
|
89
|
+
ref={ref}
|
|
90
|
+
className={cn(
|
|
91
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
92
|
+
className,
|
|
93
|
+
)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
));
|
|
97
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
98
|
+
|
|
99
|
+
const DialogDescription = React.forwardRef<
|
|
100
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
101
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
102
|
+
>(({ className, ...props }, ref) => (
|
|
103
|
+
<DialogPrimitive.Description
|
|
104
|
+
ref={ref}
|
|
105
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
));
|
|
109
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
Dialog,
|
|
113
|
+
DialogPortal,
|
|
114
|
+
DialogOverlay,
|
|
115
|
+
DialogTrigger,
|
|
116
|
+
DialogClose,
|
|
117
|
+
DialogContent,
|
|
118
|
+
DialogHeader,
|
|
119
|
+
DialogFooter,
|
|
120
|
+
DialogTitle,
|
|
121
|
+
DialogDescription,
|
|
122
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const MOBILE_BREAKPOINT = 768;
|
|
4
|
+
|
|
5
|
+
export function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = useState<boolean | undefined>(undefined);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
10
|
+
const onChange = () => {
|
|
11
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
12
|
+
};
|
|
13
|
+
mql.addEventListener("change", onChange);
|
|
14
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
15
|
+
return () => mql.removeEventListener("change", onChange);
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
return !!isMobile;
|
|
19
|
+
}
|
package/src/input.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@c-rex/utils";
|
|
4
|
+
|
|
5
|
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
|
6
|
+
({ className, type, ...props }, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<input
|
|
9
|
+
type={type}
|
|
10
|
+
className={cn(
|
|
11
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
ref={ref}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
Input.displayName = "Input";
|
|
21
|
+
|
|
22
|
+
export { Input };
|
package/src/popover.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@c-rex/utils";
|
|
5
|
+
|
|
6
|
+
const Popover = PopoverPrimitive.Root;
|
|
7
|
+
|
|
8
|
+
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
9
|
+
|
|
10
|
+
const PopoverAnchor = PopoverPrimitive.Anchor;
|
|
11
|
+
|
|
12
|
+
const PopoverContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
15
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
16
|
+
<PopoverPrimitive.Portal>
|
|
17
|
+
<PopoverPrimitive.Content
|
|
18
|
+
ref={ref}
|
|
19
|
+
align={align}
|
|
20
|
+
sideOffset={sideOffset}
|
|
21
|
+
className={cn(
|
|
22
|
+
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
</PopoverPrimitive.Portal>
|
|
28
|
+
));
|
|
29
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
30
|
+
|
|
31
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|