@nextclaw/ui 0.3.15 → 0.3.16

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.
@@ -0,0 +1,135 @@
1
+ import * as React from "react"
2
+ import * as SelectPrimitive from "@radix-ui/react-select"
3
+ import { Check, ChevronDown, ChevronUp } from "lucide-react"
4
+ import { cn } from "@/lib/utils"
5
+
6
+ const Select = SelectPrimitive.Root
7
+ const SelectGroup = SelectPrimitive.Group
8
+ const SelectValue = SelectPrimitive.Value
9
+
10
+ const SelectTrigger = React.forwardRef<
11
+ React.ElementRef<typeof SelectPrimitive.Trigger>,
12
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
13
+ >(({ className, children, ...props }, ref) => (
14
+ <SelectPrimitive.Trigger
15
+ ref={ref}
16
+ className={cn(
17
+ "flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-gray-200 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 bg-white",
18
+ className
19
+ )}
20
+ {...props}
21
+ >
22
+ {children}
23
+ <SelectPrimitive.Icon asChild>
24
+ <ChevronDown className="h-4 w-4 opacity-50" />
25
+ </SelectPrimitive.Icon>
26
+ </SelectPrimitive.Trigger>
27
+ ))
28
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
29
+
30
+ const SelectScrollUpButton = React.forwardRef<
31
+ React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
32
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
33
+ >(({ className, ...props }, ref) => (
34
+ <SelectPrimitive.ScrollUpButton
35
+ ref={ref}
36
+ className={cn("flex cursor-default items-center justify-center py-1", className)}
37
+ {...props}
38
+ >
39
+ <ChevronUp className="h-4 w-4" />
40
+ </SelectPrimitive.ScrollUpButton>
41
+ ))
42
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
43
+
44
+ const SelectScrollDownButton = React.forwardRef<
45
+ React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
46
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
47
+ >(({ className, ...props }, ref) => (
48
+ <SelectPrimitive.ScrollDownButton
49
+ ref={ref}
50
+ className={cn("flex cursor-default items-center justify-center py-1", className)}
51
+ {...props}
52
+ >
53
+ <ChevronDown className="h-4 w-4" />
54
+ </SelectPrimitive.ScrollDownButton>
55
+ ))
56
+ SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName
57
+
58
+ const SelectContent = React.forwardRef<
59
+ React.ElementRef<typeof SelectPrimitive.Content>,
60
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
61
+ >(({ className, children, position = "popper", ...props }, ref) => (
62
+ <SelectPrimitive.Portal>
63
+ <SelectPrimitive.Content
64
+ ref={ref}
65
+ className={cn(
66
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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 bg-white",
67
+ position === "popper" &&
68
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
69
+ className
70
+ )}
71
+ position={position}
72
+ {...props}
73
+ >
74
+ <SelectScrollUpButton />
75
+ <SelectPrimitive.Viewport
76
+ className={cn("p-1", position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")}
77
+ >
78
+ {children}
79
+ </SelectPrimitive.Viewport>
80
+ <SelectScrollDownButton />
81
+ </SelectPrimitive.Content>
82
+ </SelectPrimitive.Portal>
83
+ ))
84
+ SelectContent.displayName = SelectPrimitive.Content.displayName
85
+
86
+ const SelectLabel = React.forwardRef<
87
+ React.ElementRef<typeof SelectPrimitive.Label>,
88
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
89
+ >(({ className, ...props }, ref) => (
90
+ <SelectPrimitive.Label ref={ref} className={cn("px-2 py-1.5 text-sm font-semibold", className)} {...props} />
91
+ ))
92
+ SelectLabel.displayName = SelectPrimitive.Label.displayName
93
+
94
+ const SelectItem = React.forwardRef<
95
+ React.ElementRef<typeof SelectPrimitive.Item>,
96
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
97
+ >(({ className, children, ...props }, ref) => (
98
+ <SelectPrimitive.Item
99
+ ref={ref}
100
+ className={cn(
101
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100",
102
+ className
103
+ )}
104
+ {...props}
105
+ >
106
+ <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
107
+ <SelectPrimitive.ItemIndicator>
108
+ <Check className="h-4 w-4" />
109
+ </SelectPrimitive.ItemIndicator>
110
+ </span>
111
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
112
+ </SelectPrimitive.Item>
113
+ ))
114
+ SelectItem.displayName = SelectPrimitive.Item.displayName
115
+
116
+ const SelectSeparator = React.forwardRef<
117
+ React.ElementRef<typeof SelectPrimitive.Separator>,
118
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
119
+ >(({ className, ...props }, ref) => (
120
+ <SelectPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} />
121
+ ))
122
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName
123
+
124
+ export {
125
+ Select,
126
+ SelectGroup,
127
+ SelectValue,
128
+ SelectTrigger,
129
+ SelectContent,
130
+ SelectLabel,
131
+ SelectItem,
132
+ SelectSeparator,
133
+ SelectScrollUpButton,
134
+ SelectScrollDownButton,
135
+ }