@c-rex/ui 0.3.0-build.42 → 0.3.0-build.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/ui",
3
- "version": "0.3.0-build.42",
3
+ "version": "0.3.0-build.49",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -153,7 +153,12 @@
153
153
  },
154
154
  "scripts": {
155
155
  "lint": "eslint .",
156
- "lint:fix": "eslint . --fix"
156
+ "lint:fix": "eslint . --fix",
157
+ "check-types": "tsc --noEmit",
158
+ "test": "echo \u0027No tests\u0027",
159
+ "build": "echo \u0027No build script\u0027",
160
+ "format:check": "prettier --check .",
161
+ "validate": "npm run lint \u0026\u0026 npm run check-types \u0026\u0026 npm run test \u0026\u0026 npm run build"
157
162
  },
158
163
  "devDependencies": {
159
164
  "@c-rex/eslint-config": "*",
package/src/badge.tsx CHANGED
@@ -1,46 +1,46 @@
1
- import * as React from "react"
2
- import { Slot } from "@radix-ui/react-slot"
3
- import { cva, type VariantProps } from "class-variance-authority"
1
+ import * as React from "react";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import { cva, type VariantProps } from "class-variance-authority";
4
4
 
5
- import { cn } from "@c-rex/utils"
5
+ import { cn } from "@c-rex/utils";
6
6
 
7
7
  const badgeVariants = cva(
8
- "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-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 transition-[color,box-shadow] overflow-hidden",
9
- {
10
- variants: {
11
- variant: {
12
- default:
13
- "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
14
- secondary:
15
- "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
16
- destructive:
17
- "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
18
- outline:
19
- "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
20
- },
21
- },
22
- defaultVariants: {
23
- variant: "default",
24
- },
25
- }
26
- )
8
+ "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-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 transition-[color,box-shadow] overflow-hidden",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default:
13
+ "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
14
+ secondary:
15
+ "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
16
+ destructive:
17
+ "border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
18
+ outline:
19
+ "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ variant: "default",
24
+ },
25
+ },
26
+ );
27
27
 
28
28
  function Badge({
29
- className,
30
- variant,
31
- asChild = false,
32
- ...props
29
+ className,
30
+ variant,
31
+ asChild = false,
32
+ ...props
33
33
  }: React.ComponentProps<"span"> &
34
- VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
35
- const Comp = asChild ? Slot : "span"
34
+ VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
35
+ const Comp = asChild ? Slot : "span";
36
36
 
37
- return (
38
- <Comp
39
- data-slot="badge"
40
- className={cn(badgeVariants({ variant }), className)}
41
- {...props}
42
- />
43
- )
37
+ return (
38
+ <Comp
39
+ data-slot="badge"
40
+ className={cn(badgeVariants({ variant }), className)}
41
+ {...props}
42
+ />
43
+ );
44
44
  }
45
45
 
46
- export { Badge, badgeVariants }
46
+ export { Badge, badgeVariants };
package/src/command.tsx CHANGED
@@ -7,145 +7,149 @@ import { cn } from "@c-rex/utils";
7
7
  import { Dialog, DialogContent } from "./dialog";
8
8
 
9
9
  const Command = React.forwardRef<
10
- React.ElementRef<typeof CommandPrimitive>,
11
- React.ComponentPropsWithoutRef<typeof CommandPrimitive>
10
+ React.ElementRef<typeof CommandPrimitive>,
11
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive>
12
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
- />
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
21
  ));
22
22
  Command.displayName = CommandPrimitive.displayName;
23
23
 
24
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
- );
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
34
  };
35
35
 
36
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>
37
+ React.ElementRef<typeof CommandPrimitive.Input>,
38
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> & {
39
+ /** Rendered inside the input row, after the text field (e.g. an info button). */
40
+ trailing?: React.ReactNode;
41
+ }
42
+ >(({ className, trailing, ...props }, ref) => (
43
+ <div className="flex items-center border-b px-3" cmdk-input-wrapper="">
44
+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
45
+ <CommandPrimitive.Input
46
+ ref={ref}
47
+ className={cn(
48
+ "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",
49
+ className,
50
+ )}
51
+ {...props}
52
+ />
53
+ {trailing}
54
+ </div>
51
55
  ));
52
56
 
53
57
  CommandInput.displayName = CommandPrimitive.Input.displayName;
54
58
 
55
59
  const CommandList = React.forwardRef<
56
- React.ElementRef<typeof CommandPrimitive.List>,
57
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
60
+ React.ElementRef<typeof CommandPrimitive.List>,
61
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
58
62
  >(({ 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
- />
63
+ <CommandPrimitive.List
64
+ ref={ref}
65
+ className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
66
+ {...props}
67
+ />
64
68
  ));
65
69
 
66
70
  CommandList.displayName = CommandPrimitive.List.displayName;
67
71
 
68
72
  const CommandEmpty = React.forwardRef<
69
- React.ElementRef<typeof CommandPrimitive.Empty>,
70
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
73
+ React.ElementRef<typeof CommandPrimitive.Empty>,
74
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
71
75
  >((props, ref) => (
72
- <CommandPrimitive.Empty
73
- ref={ref}
74
- className="py-6 text-center text-sm"
75
- {...props}
76
- />
76
+ <CommandPrimitive.Empty
77
+ ref={ref}
78
+ className="py-6 text-center text-sm"
79
+ {...props}
80
+ />
77
81
  ));
78
82
 
79
83
  CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
80
84
 
81
85
  const CommandGroup = React.forwardRef<
82
- React.ElementRef<typeof CommandPrimitive.Group>,
83
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
86
+ React.ElementRef<typeof CommandPrimitive.Group>,
87
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
84
88
  >(({ 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
- />
89
+ <CommandPrimitive.Group
90
+ ref={ref}
91
+ className={cn(
92
+ "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",
93
+ className,
94
+ )}
95
+ {...props}
96
+ />
93
97
  ));
94
98
 
95
99
  CommandGroup.displayName = CommandPrimitive.Group.displayName;
96
100
 
97
101
  const CommandSeparator = React.forwardRef<
98
- React.ElementRef<typeof CommandPrimitive.Separator>,
99
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
102
+ React.ElementRef<typeof CommandPrimitive.Separator>,
103
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
100
104
  >(({ className, ...props }, ref) => (
101
- <CommandPrimitive.Separator
102
- ref={ref}
103
- className={cn("-mx-1 h-px bg-border", className)}
104
- {...props}
105
- />
105
+ <CommandPrimitive.Separator
106
+ ref={ref}
107
+ className={cn("-mx-1 h-px bg-border", className)}
108
+ {...props}
109
+ />
106
110
  ));
107
111
  CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
108
112
 
109
113
  const CommandItem = React.forwardRef<
110
- React.ElementRef<typeof CommandPrimitive.Item>,
111
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
114
+ React.ElementRef<typeof CommandPrimitive.Item>,
115
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
112
116
  >(({ 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
- />
117
+ <CommandPrimitive.Item
118
+ ref={ref}
119
+ className={cn(
120
+ "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",
121
+ className,
122
+ )}
123
+ {...props}
124
+ />
121
125
  ));
122
126
 
123
127
  CommandItem.displayName = CommandPrimitive.Item.displayName;
124
128
 
125
129
  const CommandShortcut = ({
126
- className,
127
- ...props
130
+ className,
131
+ ...props
128
132
  }: 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
- );
133
+ return (
134
+ <span
135
+ className={cn(
136
+ "ml-auto text-xs tracking-widest text-muted-foreground",
137
+ className,
138
+ )}
139
+ {...props}
140
+ />
141
+ );
138
142
  };
139
143
  CommandShortcut.displayName = "CommandShortcut";
140
144
 
141
145
  export {
142
- Command,
143
- CommandDialog,
144
- CommandInput,
145
- CommandList,
146
- CommandEmpty,
147
- CommandGroup,
148
- CommandItem,
149
- CommandShortcut,
150
- CommandSeparator,
146
+ Command,
147
+ CommandDialog,
148
+ CommandInput,
149
+ CommandList,
150
+ CommandEmpty,
151
+ CommandGroup,
152
+ CommandItem,
153
+ CommandShortcut,
154
+ CommandSeparator,
151
155
  };
@@ -1,27 +1,24 @@
1
- import { cn } from "@c-rex/utils"
1
+ import { cn } from "@c-rex/utils";
2
2
 
3
3
  interface DropdownHoverItemProps {
4
- label: React.ReactNode;
5
- children: React.ReactNode;
6
- className?: string;
4
+ label: React.ReactNode;
5
+ children: React.ReactNode;
6
+ className?: string;
7
7
  }
8
8
 
9
9
  export function DropdownHoverItem({
10
- label,
11
- children,
12
- className
10
+ label,
11
+ children,
12
+ className,
13
13
  }: DropdownHoverItemProps) {
14
- return (
15
- <div className={cn("relative inline-block group/dropdown", className)}>
16
-
17
- {label}
18
- <div className="hidden group-hover/dropdown:block absolute left-0 z-10 pt-2">
19
-
20
- <div className="w-48 bg-white border rounded shadow-lg p-2 max-h-[30rem] overflow-auto">
21
- {children}
22
- </div>
23
-
24
- </div>
14
+ return (
15
+ <div className={cn("relative inline-block group/dropdown", className)}>
16
+ {label}
17
+ <div className="hidden group-hover/dropdown:block absolute left-0 z-10 pt-2">
18
+ <div className="w-48 rounded border border-border bg-popover p-2 text-popover-foreground shadow-lg max-h-[30rem] overflow-auto">
19
+ {children}
25
20
  </div>
26
- );
21
+ </div>
22
+ </div>
23
+ );
27
24
  }
@@ -1,192 +1,188 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
1
+ import * as React from "react";
2
+ import { cva, type VariantProps } from "class-variance-authority";
3
3
 
4
- import { cn } from "@c-rex/utils"
5
- import { Button } from "./button"
6
- import { Input } from "./input"
7
- import { Textarea } from "./textarea"
4
+ import { cn } from "@c-rex/utils";
5
+ import { Button } from "./button";
6
+ import { Input } from "./input";
7
+ import { Textarea } from "./textarea";
8
8
 
9
9
  const inputGroupVariants = cva(
10
- "group/input-group relative flex w-full items-center rounded-md transition-[color,box-shadow] outline-none h-9 min-w-0 has-[>textarea]:h-auto",
11
- {
12
- variants: {
13
- variant: {
14
- default:
15
- "border border-input bg-white",
16
- embedded:
17
- "border-0 bg-transparent shadow-none",
18
- },
19
- },
20
- defaultVariants: {
21
- variant: "default",
22
- },
23
- }
24
- )
10
+ "group/input-group relative flex w-full items-center rounded-md transition-[color,box-shadow] outline-none h-9 min-w-0 has-[>textarea]:h-auto",
11
+ {
12
+ variants: {
13
+ variant: {
14
+ default: "border border-input bg-background",
15
+ embedded: "border-0 bg-transparent shadow-none",
16
+ },
17
+ },
18
+ defaultVariants: {
19
+ variant: "default",
20
+ },
21
+ },
22
+ );
25
23
 
26
24
  function InputGroup({
27
- className,
28
- variant,
29
- ...props
30
- }: React.ComponentProps<"div"> &
31
- VariantProps<typeof inputGroupVariants>) {
32
- return (
33
- <div
34
- data-slot="input-group"
35
- role="group"
36
- className={cn(
37
- inputGroupVariants({ variant }),
38
-
39
- // Variants based on alignment.
40
- "has-[>[data-align=inline-start]]:[&>input]:pl-2",
41
- "has-[>[data-align=inline-end]]:[&>input]:pr-2",
42
- "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
43
- "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
44
-
45
- // Focus state.
46
- "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50",
47
-
48
- // Error state.
49
- "has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",
50
-
51
- className
52
- )}
53
- {...props}
54
- />
55
- )
25
+ className,
26
+ variant,
27
+ ...props
28
+ }: React.ComponentProps<"div"> & VariantProps<typeof inputGroupVariants>) {
29
+ return (
30
+ <div
31
+ data-slot="input-group"
32
+ role="group"
33
+ className={cn(
34
+ inputGroupVariants({ variant }),
35
+
36
+ // Variants based on alignment.
37
+ "has-[>[data-align=inline-start]]:[&>input]:pl-2",
38
+ "has-[>[data-align=inline-end]]:[&>input]:pr-2",
39
+ "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3",
40
+ "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3",
41
+
42
+ // Focus state.
43
+ "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50",
44
+
45
+ // Error state.
46
+ "has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",
47
+
48
+ className,
49
+ )}
50
+ {...props}
51
+ />
52
+ );
56
53
  }
57
54
 
58
55
  const inputGroupAddonVariants = cva(
59
- "text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",
60
- {
61
- variants: {
62
- align: {
63
- "inline-start":
64
- "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
65
- "inline-end":
66
- "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
67
- "block-start":
68
- "order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5",
69
- "block-end":
70
- "order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5",
71
- },
72
- },
73
- defaultVariants: {
74
- align: "inline-start",
75
- },
76
- }
77
- )
56
+ "text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",
57
+ {
58
+ variants: {
59
+ align: {
60
+ "inline-start":
61
+ "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
62
+ "inline-end":
63
+ "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
64
+ "block-start":
65
+ "order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5",
66
+ "block-end":
67
+ "order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5",
68
+ },
69
+ },
70
+ defaultVariants: {
71
+ align: "inline-start",
72
+ },
73
+ },
74
+ );
78
75
 
79
76
  function InputGroupAddon({
80
- className,
81
- align = "inline-start",
82
- ...props
77
+ className,
78
+ align = "inline-start",
79
+ ...props
83
80
  }: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
84
- return (
85
- <div
86
- role="group"
87
- data-slot="input-group-addon"
88
- data-align={align}
89
- className={cn(inputGroupAddonVariants({ align }), className)}
90
- onClick={(e) => {
91
- if ((e.target as HTMLElement).closest("button")) {
92
- return
93
- }
94
- e.currentTarget.parentElement?.querySelector("input")?.focus()
95
- }}
96
- {...props}
97
- />
98
- )
81
+ return (
82
+ <div
83
+ role="group"
84
+ data-slot="input-group-addon"
85
+ data-align={align}
86
+ className={cn(inputGroupAddonVariants({ align }), className)}
87
+ onClick={(e) => {
88
+ if ((e.target as HTMLElement).closest("button")) {
89
+ return;
90
+ }
91
+ e.currentTarget.parentElement?.querySelector("input")?.focus();
92
+ }}
93
+ {...props}
94
+ />
95
+ );
99
96
  }
100
97
 
101
98
  const inputGroupButtonVariants = cva(
102
- "text-sm shadow-none flex gap-2 items-center",
103
- {
104
- variants: {
105
- size: {
106
- xs: "h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",
107
- sm: "h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5",
108
- "icon-xs":
109
- "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
110
- "icon-sm": "size-8 p-0 has-[>svg]:p-0",
111
- },
112
- },
113
- defaultVariants: {
114
- size: "xs",
115
- },
116
- }
117
- )
99
+ "text-sm shadow-none flex gap-2 items-center",
100
+ {
101
+ variants: {
102
+ size: {
103
+ xs: "h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",
104
+ sm: "h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5",
105
+ "icon-xs":
106
+ "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
107
+ "icon-sm": "size-8 p-0 has-[>svg]:p-0",
108
+ },
109
+ },
110
+ defaultVariants: {
111
+ size: "xs",
112
+ },
113
+ },
114
+ );
118
115
 
119
116
  function InputGroupButton({
120
- className,
121
- type = "button",
122
- variant = "ghost",
123
- size = "xs",
124
- ...props
117
+ className,
118
+ type = "button",
119
+ variant = "ghost",
120
+ size = "xs",
121
+ ...props
125
122
  }: Omit<React.ComponentProps<typeof Button>, "size"> &
126
- VariantProps<typeof inputGroupButtonVariants>) {
127
- return (
128
- <Button
129
- type={type}
130
- data-size={size}
131
- variant={variant}
132
- className={cn(inputGroupButtonVariants({ size }), className)}
133
- {...props}
134
- />
135
- )
123
+ VariantProps<typeof inputGroupButtonVariants>) {
124
+ return (
125
+ <Button
126
+ type={type}
127
+ data-size={size}
128
+ variant={variant}
129
+ className={cn(inputGroupButtonVariants({ size }), className)}
130
+ {...props}
131
+ />
132
+ );
136
133
  }
137
134
 
138
135
  function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
139
- return (
140
- <span
141
- className={cn(
142
- "text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
143
- className
144
- )}
145
- {...props}
146
- />
147
- )
136
+ return (
137
+ <span
138
+ className={cn(
139
+ "text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
140
+ className,
141
+ )}
142
+ {...props}
143
+ />
144
+ );
148
145
  }
149
146
 
150
147
  const InputGroupInput = React.forwardRef<
151
- HTMLInputElement,
152
- React.ComponentProps<typeof Input>
148
+ HTMLInputElement,
149
+ React.ComponentProps<typeof Input>
153
150
  >(({ className, ...props }, ref) => {
154
- return (
155
- <Input
156
- data-slot="input-group-control"
157
- ref={ref}
158
- className={cn(
159
- "flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
160
- className
161
- )}
162
- {...props}
163
- />
164
- )
165
- })
166
- InputGroupInput.displayName = "InputGroupInput"
167
-
151
+ return (
152
+ <Input
153
+ data-slot="input-group-control"
154
+ ref={ref}
155
+ className={cn(
156
+ "flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",
157
+ className,
158
+ )}
159
+ {...props}
160
+ />
161
+ );
162
+ });
163
+ InputGroupInput.displayName = "InputGroupInput";
168
164
 
169
165
  function InputGroupTextarea({
170
- className,
171
- ...props
166
+ className,
167
+ ...props
172
168
  }: React.ComponentProps<"textarea">) {
173
- return (
174
- <Textarea
175
- data-slot="input-group-control"
176
- className={cn(
177
- "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
178
- className
179
- )}
180
- {...props}
181
- />
182
- )
169
+ return (
170
+ <Textarea
171
+ data-slot="input-group-control"
172
+ className={cn(
173
+ "flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",
174
+ className,
175
+ )}
176
+ {...props}
177
+ />
178
+ );
183
179
  }
184
180
 
185
181
  export {
186
- InputGroup,
187
- InputGroupAddon,
188
- InputGroupButton,
189
- InputGroupText,
190
- InputGroupInput,
191
- InputGroupTextarea,
192
- }
182
+ InputGroup,
183
+ InputGroupAddon,
184
+ InputGroupButton,
185
+ InputGroupText,
186
+ InputGroupInput,
187
+ InputGroupTextarea,
188
+ };