MCPcopy Create free account
hub / github.com/sqlchat/sqlchat / Select

Function Select

src/components/kit/Select.tsx:17–70  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

15}
16
17const Select = (props: Props) => {
18 const { itemList, value, placeholder, className, onValueChange } = props;
19
20 return (
21 <SelectUI.Root value={value} onValueChange={onValueChange}>
22 <SelectUI.Trigger
23 className={`${
24 className || ""
25 } flex flex-row justify-between items-center text-sm whitespace-nowrap dark:text-gray-300 bg-white dark:bg-zinc-700 border dark:border-zinc-800 px-3 py-2 rounded-lg`}
26 >
27 <SelectUI.Value placeholder={placeholder} />
28 <SelectUI.Icon className="ml-1 w-5 h-auto shrink-0">
29 <Icon.BiChevronDown className="w-full h-auto opacity-60" />
30 </SelectUI.Icon>
31 </SelectUI.Trigger>
32 <SelectUI.Portal>
33 <SelectUI.Content
34 className="z-[999] mt-1"
35 style={{
36 minWidth: "var(--radix-select-trigger-width)",
37 }}
38 position="popper"
39 >
40 <ScrollArea.Root
41 className={`${
42 itemList.length > 7 ? "h-80 overflow-hidden" : "max-h-80 overflow-auto"
43 } border dark:border-zinc-800 rounded-lg drop-shadow-lg`}
44 type="auto"
45 >
46 <SelectUI.Viewport asChild className="bg-white dark:bg-zinc-700 p-1 rounded-lg">
47 <ScrollArea.Viewport className="w-full h-full">
48 <SelectUI.Group>
49 {placeholder && <SelectUI.Label className="w-full px-3 mt-2 mb-2 text-sm text-gray-400">{placeholder}</SelectUI.Label>}
50 {itemList.map((item) => (
51 <SelectUI.Item
52 className="w-full px-3 py-2 whitespace-nowrap truncate text-ellipsis overflow-x-hidden text-sm rounded-lg flex flex-row justify-between items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-zinc-800"
53 key={item.label}
54 value={item.value}
55 >
56 <SelectUI.ItemText className="truncate">{item.label}</SelectUI.ItemText>
57 <SelectUI.ItemIndicator className="w-5 h-auto">
58 <Icon.BiCheck className="w-full h-auto" />
59 </SelectUI.ItemIndicator>
60 </SelectUI.Item>
61 ))}
62 </SelectUI.Group>
63 </ScrollArea.Viewport>
64 </SelectUI.Viewport>
65 </ScrollArea.Root>
66 </SelectUI.Content>
67 </SelectUI.Portal>
68 </SelectUI.Root>
69 );
70};
71
72export default Select;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected