add CommandList to Combobox component

This commit is contained in:
Amruth Pillai
2024-03-11 09:54:10 +01:00
parent 32445a5cd7
commit 6405102cab
2 changed files with 41 additions and 37 deletions

View File

@ -3,9 +3,15 @@ import { cn } from "@reactive-resume/utils";
import { forwardRef, useState } from "react"; import { forwardRef, useState } from "react";
import { Button } from "./button"; import { Button } from "./button";
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem } from "./command"; import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "./command";
import { Popover, PopoverContent, PopoverTrigger } from "./popover"; import { Popover, PopoverContent, PopoverTrigger } from "./popover";
import { ScrollArea } from "./scroll-area";
export interface ComboboxOption { export interface ComboboxOption {
value: string; value: string;
@ -93,10 +99,9 @@ export const Combobox = forwardRef(
ref={ref} ref={ref}
placeholder={props.searchPlaceholder ?? "Search for an option"} placeholder={props.searchPlaceholder ?? "Search for an option"}
/> />
<CommandList>
<CommandEmpty>{props.emptyText ?? "No results found"}</CommandEmpty> <CommandEmpty>{props.emptyText ?? "No results found"}</CommandEmpty>
<CommandGroup> <CommandGroup>
<ScrollArea orientation="vertical">
<div className="max-h-60">
{props.options.map((option) => ( {props.options.map((option) => (
<CommandItem <CommandItem
key={option.value} key={option.value}
@ -127,9 +132,8 @@ export const Combobox = forwardRef(
{option.label} {option.label}
</CommandItem> </CommandItem>
))} ))}
</div>
</ScrollArea>
</CommandGroup> </CommandGroup>
</CommandList>
</Command> </Command>
</PopoverContent> </PopoverContent>
</Popover> </Popover>

View File

@ -1,7 +1,7 @@
{ {
"name": "@reactive-resume/source", "name": "@reactive-resume/source",
"description": "A free and open-source resume builder that simplifies the process of creating, updating, and sharing your resume.", "description": "A free and open-source resume builder that simplifies the process of creating, updating, and sharing your resume.",
"version": "4.0.7", "version": "4.0.8",
"license": "MIT", "license": "MIT",
"private": true, "private": true,
"author": { "author": {