/
githubmirror
/
gogs
Обзор
Документация
Войти
/
githubmirror
/
gogs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
web/src/components/ui/select.tsx
75 строк
3 KB
ᴊᴏᴇ ᴄʜᴇɴ
web: align components with React 19 and fix accessibility findings (#8306)
31 май 2026, 18:06
Не верифицирован
31 май 2026, 18:06
2c46f01
Код
Авторство
О чём код?
import * as SelectPrimitive from "@radix-ui/react-select"; import { Check, ChevronDown } from "lucide-react"; import * as React from "react"; import { cn } from "@/lib/utils"; const Select = SelectPrimitive.Root; const SelectGroup = SelectPrimitive.Group; const SelectValue = SelectPrimitive.Value; function SelectTrigger({ className, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger>) { return ( <SelectPrimitive.Trigger className={cn( "flex h-10 w-full items-center justify-between rounded-md border border-(--color-input) bg-(--color-background) px-3 py-2 text-sm text-(--color-foreground) outline-none transition-colors", "focus-visible:border-(--color-ring) focus-visible:ring-1 focus-visible:ring-(--color-ring)", "disabled:cursor-not-allowed disabled:opacity-60", "data-[placeholder]:text-(--color-muted-foreground)", className, )} {...props} > {children} <SelectPrimitive.Icon asChild> <ChevronDown className="size-4 text-(--color-muted-foreground)" aria-hidden /> </SelectPrimitive.Icon> </SelectPrimitive.Trigger> ); } function SelectContent({ className, children, position = "popper", ...props }: React.ComponentProps<typeof SelectPrimitive.Content>) { return ( <SelectPrimitive.Portal> <SelectPrimitive.Content position={position} className={cn( "relative z-50 max-h-(--radix-select-content-available-height) min-w-(--radix-select-trigger-width) overflow-hidden rounded-md border border-(--color-border) bg-(--color-popover) text-(--color-popover-foreground) shadow-md outline-none", "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", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1", className, )} {...props} > <SelectPrimitive.Viewport className="p-1">{children}</SelectPrimitive.Viewport> </SelectPrimitive.Content> </SelectPrimitive.Portal> ); } function SelectItem({ className, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Item>) { return ( <SelectPrimitive.Item className={cn( "relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none", "focus:bg-(--color-surface) data-[disabled]:pointer-events-none data-[disabled]:opacity-60", className, )} {...props} > <span className="absolute left-2 flex size-3.5 items-center justify-center"> <SelectPrimitive.ItemIndicator> <Check className="size-4" aria-hidden /> </SelectPrimitive.ItemIndicator> </span> <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText> </SelectPrimitive.Item> ); } export { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue };