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