@c-rex/ui 0.0.11 → 0.0.13

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.
Files changed (106) hide show
  1. package/package.json +34 -54
  2. package/src/alert.tsx +58 -0
  3. package/src/breadcrumb.tsx +115 -0
  4. package/src/button.tsx +66 -0
  5. package/src/command.tsx +151 -0
  6. package/src/dialog.tsx +122 -0
  7. package/src/hooks/use-mobile.tsx +19 -0
  8. package/src/input.tsx +22 -0
  9. package/src/popover.tsx +31 -0
  10. package/src/select.tsx +157 -0
  11. package/src/separator.tsx +29 -0
  12. package/src/sheet.tsx +140 -0
  13. package/src/sidebar.tsx +785 -0
  14. package/src/skeleton.tsx +15 -0
  15. package/src/table.tsx +120 -0
  16. package/src/tooltip.tsx +30 -0
  17. package/dist/alert.cjs.js +0 -197
  18. package/dist/alert.cjs.js.map +0 -1
  19. package/dist/alert.d.cts +0 -11
  20. package/dist/alert.d.ts +0 -11
  21. package/dist/alert.esm.js +0 -116
  22. package/dist/alert.esm.js.map +0 -1
  23. package/dist/breadcrumb.cjs.js +0 -299
  24. package/dist/breadcrumb.cjs.js.map +0 -1
  25. package/dist/breadcrumb.d.cts +0 -22
  26. package/dist/breadcrumb.d.ts +0 -22
  27. package/dist/breadcrumb.esm.js +0 -202
  28. package/dist/breadcrumb.esm.js.map +0 -1
  29. package/dist/button.cjs.js +0 -200
  30. package/dist/button.cjs.js.map +0 -1
  31. package/dist/button.d.cts +0 -15
  32. package/dist/button.d.ts +0 -15
  33. package/dist/button.esm.js +0 -123
  34. package/dist/button.esm.js.map +0 -1
  35. package/dist/command.cjs.js +0 -387
  36. package/dist/command.cjs.js.map +0 -1
  37. package/dist/command.d.cts +0 -83
  38. package/dist/command.d.ts +0 -83
  39. package/dist/command.esm.js +0 -282
  40. package/dist/command.esm.js.map +0 -1
  41. package/dist/dialog.cjs.js +0 -290
  42. package/dist/dialog.cjs.js.map +0 -1
  43. package/dist/dialog.d.cts +0 -22
  44. package/dist/dialog.d.ts +0 -22
  45. package/dist/dialog.esm.js +0 -181
  46. package/dist/dialog.esm.js.map +0 -1
  47. package/dist/hooks/use-mobile.cjs.js +0 -127
  48. package/dist/hooks/use-mobile.cjs.js.map +0 -1
  49. package/dist/hooks/use-mobile.d.cts +0 -3
  50. package/dist/hooks/use-mobile.d.ts +0 -3
  51. package/dist/hooks/use-mobile.esm.js +0 -66
  52. package/dist/hooks/use-mobile.esm.js.map +0 -1
  53. package/dist/input.cjs.js +0 -155
  54. package/dist/input.cjs.js.map +0 -1
  55. package/dist/input.d.cts +0 -5
  56. package/dist/input.d.ts +0 -5
  57. package/dist/input.esm.js +0 -82
  58. package/dist/input.esm.js.map +0 -1
  59. package/dist/popover.cjs.js +0 -175
  60. package/dist/popover.cjs.js.map +0 -1
  61. package/dist/popover.d.cts +0 -9
  62. package/dist/popover.d.ts +0 -9
  63. package/dist/popover.esm.js +0 -90
  64. package/dist/popover.esm.js.map +0 -1
  65. package/dist/select.cjs.js +0 -326
  66. package/dist/select.cjs.js.map +0 -1
  67. package/dist/select.d.cts +0 -15
  68. package/dist/select.d.ts +0 -15
  69. package/dist/select.esm.js +0 -217
  70. package/dist/select.esm.js.map +0 -1
  71. package/dist/separator.cjs.js +0 -158
  72. package/dist/separator.cjs.js.map +0 -1
  73. package/dist/separator.d.cts +0 -6
  74. package/dist/separator.d.ts +0 -6
  75. package/dist/separator.esm.js +0 -85
  76. package/dist/separator.esm.js.map +0 -1
  77. package/dist/sheet.cjs.js +0 -308
  78. package/dist/sheet.cjs.js.map +0 -1
  79. package/dist/sheet.d.cts +0 -29
  80. package/dist/sheet.d.ts +0 -29
  81. package/dist/sheet.esm.js +0 -199
  82. package/dist/sheet.esm.js.map +0 -1
  83. package/dist/sidebar.cjs.js +0 -1077
  84. package/dist/sidebar.cjs.js.map +0 -1
  85. package/dist/sidebar.d.cts +0 -72
  86. package/dist/sidebar.d.ts +0 -72
  87. package/dist/sidebar.esm.js +0 -912
  88. package/dist/sidebar.esm.js.map +0 -1
  89. package/dist/skeleton.cjs.js +0 -138
  90. package/dist/skeleton.cjs.js.map +0 -1
  91. package/dist/skeleton.d.cts +0 -5
  92. package/dist/skeleton.d.ts +0 -5
  93. package/dist/skeleton.esm.js +0 -76
  94. package/dist/skeleton.esm.js.map +0 -1
  95. package/dist/table.cjs.js +0 -254
  96. package/dist/table.cjs.js.map +0 -1
  97. package/dist/table.d.cts +0 -12
  98. package/dist/table.d.ts +0 -12
  99. package/dist/table.esm.js +0 -153
  100. package/dist/table.esm.js.map +0 -1
  101. package/dist/tooltip.cjs.js +0 -173
  102. package/dist/tooltip.cjs.js.map +0 -1
  103. package/dist/tooltip.d.cts +0 -9
  104. package/dist/tooltip.d.ts +0 -9
  105. package/dist/tooltip.esm.js +0 -88
  106. package/dist/tooltip.esm.js.map +0 -1
package/package.json CHANGED
@@ -1,99 +1,79 @@
1
1
  {
2
2
  "name": "@c-rex/ui",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "files": [
6
- "dist"
6
+ "src"
7
7
  ],
8
+ "sideEffects": false,
8
9
  "publishConfig": {
9
10
  "access": "public"
10
11
  },
11
12
  "exports": {
12
13
  "./alert": {
13
- "types": "./dist/alert.d.ts",
14
- "import": "./dist/alert.esm.js",
15
- "require": "./dist/alert.cjs.js"
14
+ "types": "./src/alert.tsx",
15
+ "import": "./src/alert.tsx"
16
16
  },
17
17
  "./breadcrumb": {
18
- "types": "./dist/breadcrumb.d.ts",
19
- "import": "./dist/breadcrumb.esm.js",
20
- "require": "./dist/breadcrumb.cjs.js"
18
+ "types": "./src/breadcrumb.tsx",
19
+ "import": "./src/breadcrumb.tsx"
21
20
  },
22
21
  "./button": {
23
- "types": "./dist/button.d.ts",
24
- "import": "./dist/button.esm.js",
25
- "require": "./dist/button.cjs.js"
22
+ "types": "./src/button.tsx",
23
+ "import": "./src/button.tsx"
26
24
  },
27
25
  "./command": {
28
- "types": "./dist/command.d.ts",
29
- "import": "./dist/command.esm.js",
30
- "require": "./dist/command.cjs.js"
26
+ "types": "./src/command.tsx",
27
+ "import": "./src/command.tsx"
31
28
  },
32
29
  "./dialog": {
33
- "types": "./dist/dialog.d.ts",
34
- "import": "./dist/dialog.esm.js",
35
- "require": "./dist/dialog.cjs.js"
30
+ "types": "./src/dialog.tsx",
31
+ "import": "./src/dialog.tsx"
36
32
  },
37
33
  "./hooks/use-mobile": {
38
- "types": "./dist/hooks/use-mobile.d.ts",
39
- "import": "./dist/hooks/use-mobile.esm.js",
40
- "require": "./dist/hooks/use-mobile.cjs.js"
34
+ "types": "./src/hooks/use-mobile.tsx",
35
+ "import": "./src/hooks/use-mobile.tsx"
41
36
  },
42
37
  "./input": {
43
- "types": "./dist/input.d.ts",
44
- "import": "./dist/input.esm.js",
45
- "require": "./dist/input.cjs.js"
38
+ "types": "./src/input.tsx",
39
+ "import": "./src/input.tsx"
46
40
  },
47
41
  "./popover": {
48
- "types": "./dist/popover.d.ts",
49
- "import": "./dist/popover.esm.js",
50
- "require": "./dist/popover.cjs.js"
42
+ "types": "./src/popover.tsx",
43
+ "import": "./src/popover.tsx"
51
44
  },
52
45
  "./select": {
53
- "types": "./dist/select.d.ts",
54
- "import": "./dist/select.esm.js",
55
- "require": "./dist/select.cjs.js"
46
+ "types": "./src/select.tsx",
47
+ "import": "./src/select.tsx"
56
48
  },
57
49
  "./separator": {
58
- "types": "./dist/separator.d.ts",
59
- "import": "./dist/separator.esm.js",
60
- "require": "./dist/separator.cjs.js"
50
+ "types": "./src/separator.tsx",
51
+ "import": "./src/separator.tsx"
61
52
  },
62
53
  "./sheet": {
63
- "types": "./dist/sheet.d.ts",
64
- "import": "./dist/sheet.esm.js",
65
- "require": "./dist/sheet.cjs.js"
54
+ "types": "./src/sheet.tsx",
55
+ "import": "./src/sheet.tsx"
66
56
  },
67
57
  "./sidebar": {
68
- "types": "./dist/sidebar.d.ts",
69
- "import": "./dist/sidebar.esm.js",
70
- "require": "./dist/sidebar.cjs.js"
58
+ "types": "./src/sidebar.tsx",
59
+ "import": "./src/sidebar.tsx"
71
60
  },
72
61
  "./skeleton": {
73
- "types": "./dist/skeleton.d.ts",
74
- "import": "./dist/skeleton.esm.js",
75
- "require": "./dist/skeleton.cjs.js"
62
+ "types": "./src/skeleton.tsx",
63
+ "import": "./src/skeleton.tsx"
76
64
  },
77
65
  "./table": {
78
- "types": "./dist/table.d.ts",
79
- "import": "./dist/table.esm.js",
80
- "require": "./dist/table.cjs.js"
66
+ "types": "./src/table.tsx",
67
+ "import": "./src/table.tsx"
81
68
  },
82
69
  "./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"
70
+ "types": "./src/tooltip.tsx",
71
+ "import": "./src/tooltip.tsx"
72
+ }
92
73
  },
93
74
  "devDependencies": {
94
75
  "@c-rex/eslint-config": "*",
95
76
  "@c-rex/typescript-config": "*",
96
- "@swc/core": "^1.11.22",
97
77
  "@turbo/gen": "^2.4.4",
98
78
  "@types/node": "^22.13.10",
99
79
  "@types/react": "19.0.10",
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 };
@@ -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
+ }