SPB Git forge

spb/polyllm

Public
15commits 1branches 0releases
2.2 MBsize
maindefault branch
13 days agolast push
TypeScript 97.4% SQL 1% JavaScript 0.9% CSS 0.6%
3.1 KB · 60 lines tsx
Raw Blame History
1"use client";2import * as React from "react";3import * as SelectPrimitive from "@radix-ui/react-select";4import { Check, ChevronDown } from "lucide-react";5import { cn } from "@/lib/utils";67export const Select = SelectPrimitive.Root;8export const SelectGroup = SelectPrimitive.Group;9export const SelectValue = SelectPrimitive.Value;1011export const SelectTrigger = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Trigger>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>>(function SelectTrigger({ className, children, ...props }, ref) {12  return (13    <SelectPrimitive.Trigger14      ref={ref}15      className={cn(16        "flex h-9 w-full items-center justify-between gap-2 rounded-md border border-border bg-bg-elevated px-3 text-sm shadow-xs transition-colors hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-accent/25 disabled:opacity-50 [&>span]:truncate",17        className,18      )}19      {...props}20    >21      {children}22      <SelectPrimitive.Icon asChild>23        <ChevronDown className="size-4 shrink-0 text-fg-subtle" />24      </SelectPrimitive.Icon>25    </SelectPrimitive.Trigger>26  );27});2829export const SelectContent = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Content>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>>(function SelectContent({ className, children, position = "popper", ...props }, ref) {30  return (31    <SelectPrimitive.Portal>32      <SelectPrimitive.Content33        ref={ref}34        position={position}35        className={cn("relative z-50 max-h-72 min-w-[8rem] overflow-hidden rounded-lg border border-border bg-bg-elevated shadow-lg animate-scale-in", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1 w-[var(--radix-select-trigger-width)]", className)}36        {...props}37      >38        <SelectPrimitive.Viewport className="p-1">{children}</SelectPrimitive.Viewport>39      </SelectPrimitive.Content>40    </SelectPrimitive.Portal>41  );42});4344export const SelectItem = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Item>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>>(function SelectItem({ className, children, ...props }, ref) {45  return (46    <SelectPrimitive.Item ref={ref} className={cn("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-bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className)} {...props}>47      <span className="absolute left-2 flex size-4 items-center justify-center">48        <SelectPrimitive.ItemIndicator>49          <Check className="size-4" />50        </SelectPrimitive.ItemIndicator>51      </span>52      <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>53    </SelectPrimitive.Item>54  );55});5657export const SelectLabel = React.forwardRef<React.ElementRef<typeof SelectPrimitive.Label>, React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>>(function SelectLabel({ className, ...props }, ref) {58  return <SelectPrimitive.Label ref={ref} className={cn("px-2 py-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-subtle", className)} {...props} />;59});60