@camox/ui 0.6.1 → 0.7.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.
@@ -1,30 +1,36 @@
1
- import { Slot } from "@radix-ui/react-slot";
2
- import type { VariantProps } from "class-variance-authority";
3
- import { cva } from "class-variance-authority";
4
- import * as React from "react";
1
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
2
+ import { cva, type VariantProps } from "class-variance-authority";
5
3
 
6
4
  import { cn } from "../lib/utils";
7
5
 
8
6
  const buttonVariants = cva(
9
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
7
+ "group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
10
8
  {
11
9
  variants: {
12
10
  variant: {
13
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
14
- destructive:
15
- "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
16
12
  outline:
17
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
18
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
13
+ "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
14
+ secondary:
15
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
16
+ ghost:
17
+ "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
18
+ destructive:
19
+ "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
20
20
  link: "text-primary underline-offset-4 hover:underline",
21
21
  },
22
22
  size: {
23
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
24
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
25
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
23
+ default:
24
+ "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
25
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
26
+ sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
27
+ lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
26
28
  icon: "size-9",
27
- "icon-sm": "size-7",
29
+ "icon-xs":
30
+ "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
31
+ "icon-sm":
32
+ "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
33
+ "icon-lg": "size-10",
28
34
  },
29
35
  },
30
36
  defaultVariants: {
@@ -36,20 +42,14 @@ const buttonVariants = cva(
36
42
 
37
43
  function Button({
38
44
  className,
39
- variant,
40
- size,
41
- asChild = false,
45
+ variant = "default",
46
+ size = "default",
42
47
  ...props
43
- }: React.ComponentProps<"button"> &
44
- VariantProps<typeof buttonVariants> & {
45
- asChild?: boolean;
46
- }) {
47
- const Comp = asChild ? Slot : "button";
48
-
48
+ }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
49
49
  return (
50
- <Comp
50
+ <ButtonPrimitive
51
51
  data-slot="button"
52
- className={cn(buttonVariants({ variant, size }), className)}
52
+ className={cn(buttonVariants({ variant, size, className }))}
53
53
  {...props}
54
54
  />
55
55
  );
@@ -1,18 +1,17 @@
1
- "use client";
2
-
3
1
  import { Command as CommandPrimitive } from "cmdk";
4
- import { SearchIcon } from "lucide-react";
2
+ import { SearchIcon, CheckIcon } from "lucide-react";
5
3
  import * as React from "react";
6
4
 
7
5
  import { cn } from "../lib/utils";
8
6
  import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "./dialog";
7
+ import { InputGroup, InputGroupAddon } from "./input-group";
9
8
 
10
9
  function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
11
10
  return (
12
11
  <CommandPrimitive
13
12
  data-slot="command"
14
13
  className={cn(
15
- "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
14
+ "flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",
16
15
  className,
17
16
  )}
18
17
  {...props}
@@ -25,17 +24,15 @@ function CommandDialog({
25
24
  description = "Search for a command to run...",
26
25
  children,
27
26
  className,
28
- showCloseButton = true,
29
- value,
30
- onValueChange,
27
+ showCloseButton = false,
31
28
  ...props
32
- }: React.ComponentProps<typeof Dialog> &
33
- React.ComponentProps<typeof CommandPrimitive> & {
34
- title?: string;
35
- description?: string;
36
- className?: string;
37
- showCloseButton?: boolean;
38
- }) {
29
+ }: Omit<React.ComponentProps<typeof Dialog>, "children"> & {
30
+ title?: string;
31
+ description?: string;
32
+ className?: string;
33
+ showCloseButton?: boolean;
34
+ children: React.ReactNode;
35
+ }) {
39
36
  return (
40
37
  <Dialog {...props}>
41
38
  <DialogHeader className="sr-only">
@@ -43,16 +40,10 @@ function CommandDialog({
43
40
  <DialogDescription>{description}</DialogDescription>
44
41
  </DialogHeader>
45
42
  <DialogContent
46
- className={cn("overflow-hidden p-0", "top-[20%] translate-y-0", className)}
43
+ className={cn("top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0", className)}
47
44
  showCloseButton={showCloseButton}
48
45
  >
49
- <Command
50
- value={value}
51
- onValueChange={onValueChange}
52
- className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[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"
53
- >
54
- {children}
55
- </Command>
46
+ {children}
56
47
  </DialogContent>
57
48
  </Dialog>
58
49
  );
@@ -60,25 +51,23 @@ function CommandDialog({
60
51
 
61
52
  function CommandInput({
62
53
  className,
63
- wrapperClassName,
64
54
  ...props
65
- }: React.ComponentProps<typeof CommandPrimitive.Input> & {
66
- wrapperClassName?: string;
67
- }) {
55
+ }: React.ComponentProps<typeof CommandPrimitive.Input>) {
68
56
  return (
69
- <div
70
- data-slot="command-input-wrapper"
71
- className={cn("flex h-9 items-center gap-2 border-b px-3", wrapperClassName)}
72
- >
73
- <SearchIcon className="size-4 shrink-0 opacity-50" />
74
- <CommandPrimitive.Input
75
- data-slot="command-input"
76
- className={cn(
77
- "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
78
- className,
79
- )}
80
- {...props}
81
- />
57
+ <div data-slot="command-input-wrapper" className="p-1 pb-0">
58
+ <InputGroup className="border-input/30 bg-input/30 h-8! rounded-lg! shadow-none! *:data-[slot=input-group-addon]:pl-2!">
59
+ <CommandPrimitive.Input
60
+ data-slot="command-input"
61
+ className={cn(
62
+ "w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
63
+ className,
64
+ )}
65
+ {...props}
66
+ />
67
+ <InputGroupAddon>
68
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
69
+ </InputGroupAddon>
70
+ </InputGroup>
82
71
  </div>
83
72
  );
84
73
  }
@@ -87,17 +76,23 @@ function CommandList({ className, ...props }: React.ComponentProps<typeof Comman
87
76
  return (
88
77
  <CommandPrimitive.List
89
78
  data-slot="command-list"
90
- className={cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className)}
79
+ className={cn(
80
+ "no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",
81
+ className,
82
+ )}
91
83
  {...props}
92
84
  />
93
85
  );
94
86
  }
95
87
 
96
- function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
88
+ function CommandEmpty({
89
+ className,
90
+ ...props
91
+ }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
97
92
  return (
98
93
  <CommandPrimitive.Empty
99
94
  data-slot="command-empty"
100
- className="py-6 text-center text-sm"
95
+ className={cn("py-6 text-center text-sm", className)}
101
96
  {...props}
102
97
  />
103
98
  );
@@ -111,7 +106,7 @@ function CommandGroup({
111
106
  <CommandPrimitive.Group
112
107
  data-slot="command-group"
113
108
  className={cn(
114
- "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
109
+ "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",
115
110
  className,
116
111
  )}
117
112
  {...props}
@@ -126,22 +121,29 @@ function CommandSeparator({
126
121
  return (
127
122
  <CommandPrimitive.Separator
128
123
  data-slot="command-separator"
129
- className={cn("bg-border -mx-1 h-px", className)}
124
+ className={cn("-mx-1 h-px w-auto bg-border", className)}
130
125
  {...props}
131
126
  />
132
127
  );
133
128
  }
134
129
 
135
- function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
130
+ function CommandItem({
131
+ className,
132
+ children,
133
+ ...props
134
+ }: React.ComponentProps<typeof CommandPrimitive.Item>) {
136
135
  return (
137
136
  <CommandPrimitive.Item
138
137
  data-slot="command-item"
139
138
  className={cn(
140
- "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
139
+ "group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
141
140
  className,
142
141
  )}
143
142
  {...props}
144
- />
143
+ >
144
+ {children}
145
+ <CheckIcon className="ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" />
146
+ </CommandPrimitive.Item>
145
147
  );
146
148
  }
147
149
 
@@ -149,7 +151,10 @@ function CommandShortcut({ className, ...props }: React.ComponentProps<"span">)
149
151
  return (
150
152
  <span
151
153
  data-slot="command-shortcut"
152
- className={cn("text-muted-foreground ml-auto text-xs tracking-widest", className)}
154
+ className={cn(
155
+ "ml-auto text-xs text-muted-foreground group-data-selected/command-item:text-foreground *:data-[slot=kbd]:bg-transparent *:data-[slot=kbd]:p-0 *:data-[slot=kbd]:min-w-0",
156
+ className,
157
+ )}
153
158
  {...props}
154
159
  />
155
160
  );
@@ -1,34 +1,32 @@
1
- import * as DialogPrimitive from "@radix-ui/react-dialog";
1
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
2
2
  import { XIcon } from "lucide-react";
3
3
  import * as React from "react";
4
4
 
5
5
  import { cn } from "../lib/utils";
6
+ import { Button } from "./button";
6
7
 
7
- function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
8
+ function Dialog({ ...props }: DialogPrimitive.Root.Props) {
8
9
  return <DialogPrimitive.Root data-slot="dialog" {...props} />;
9
10
  }
10
11
 
11
- function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
12
+ function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {
12
13
  return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
13
14
  }
14
15
 
15
- function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
16
+ function DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {
16
17
  return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
17
18
  }
18
19
 
19
- function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {
20
+ function DialogClose({ ...props }: DialogPrimitive.Close.Props) {
20
21
  return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
21
22
  }
22
23
 
23
- function DialogOverlay({
24
- className,
25
- ...props
26
- }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
24
+ function DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) {
27
25
  return (
28
- <DialogPrimitive.Overlay
26
+ <DialogPrimitive.Backdrop
29
27
  data-slot="dialog-overlay"
30
28
  className={cn(
31
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
29
+ "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
32
30
  className,
33
31
  )}
34
32
  {...props}
@@ -40,17 +38,19 @@ function DialogContent({
40
38
  className,
41
39
  children,
42
40
  showCloseButton = true,
41
+ forceOverlay = false,
43
42
  ...props
44
- }: React.ComponentProps<typeof DialogPrimitive.Content> & {
43
+ }: DialogPrimitive.Popup.Props & {
45
44
  showCloseButton?: boolean;
45
+ forceOverlay?: boolean;
46
46
  }) {
47
47
  return (
48
- <DialogPortal data-slot="dialog-portal">
49
- <DialogOverlay />
50
- <DialogPrimitive.Content
48
+ <DialogPortal>
49
+ <DialogOverlay forceRender={forceOverlay || undefined} />
50
+ <DialogPrimitive.Popup
51
51
  data-slot="dialog-content"
52
52
  className={cn(
53
- "bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
53
+ "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
54
54
  className,
55
55
  )}
56
56
  {...props}
@@ -59,55 +59,63 @@ function DialogContent({
59
59
  {showCloseButton && (
60
60
  <DialogPrimitive.Close
61
61
  data-slot="dialog-close"
62
- className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
62
+ render={<Button variant="ghost" className="absolute top-4 right-4" size="icon-sm" />}
63
63
  >
64
64
  <XIcon />
65
65
  <span className="sr-only">Close</span>
66
66
  </DialogPrimitive.Close>
67
67
  )}
68
- </DialogPrimitive.Content>
68
+ </DialogPrimitive.Popup>
69
69
  </DialogPortal>
70
70
  );
71
71
  }
72
72
 
73
73
  function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
74
74
  return (
75
- <div
76
- data-slot="dialog-header"
77
- className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
78
- {...props}
79
- />
75
+ <div data-slot="dialog-header" className={cn("flex flex-col gap-2", className)} {...props} />
80
76
  );
81
77
  }
82
78
 
83
- function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
79
+ function DialogFooter({
80
+ className,
81
+ showCloseButton = false,
82
+ children,
83
+ ...props
84
+ }: React.ComponentProps<"div"> & {
85
+ showCloseButton?: boolean;
86
+ }) {
84
87
  return (
85
88
  <div
86
89
  data-slot="dialog-footer"
87
90
  className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
88
91
  {...props}
89
- />
92
+ >
93
+ {children}
94
+ {showCloseButton && (
95
+ <DialogPrimitive.Close render={<Button variant="outline" />}>Close</DialogPrimitive.Close>
96
+ )}
97
+ </div>
90
98
  );
91
99
  }
92
100
 
93
- function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
101
+ function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
94
102
  return (
95
103
  <DialogPrimitive.Title
96
104
  data-slot="dialog-title"
97
- className={cn("text-lg leading-none font-semibold", className)}
105
+ className={cn("leading-none font-medium", className)}
98
106
  {...props}
99
107
  />
100
108
  );
101
109
  }
102
110
 
103
- function DialogDescription({
104
- className,
105
- ...props
106
- }: React.ComponentProps<typeof DialogPrimitive.Description>) {
111
+ function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {
107
112
  return (
108
113
  <DialogPrimitive.Description
109
114
  data-slot="dialog-description"
110
- className={cn("text-muted-foreground text-sm", className)}
115
+ className={cn(
116
+ "text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
117
+ className,
118
+ )}
111
119
  {...props}
112
120
  />
113
121
  );