Path: blob/main/components/dashboard/src/prebuilds/configuration-input/ComboboxItem.tsx
2501 views
/**1* Copyright (c) 2024 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { FC } from "react";7import { cn } from "@podkit/lib/cn";8import { ComboboxElement } from "./Combobox";910type Props = {11element: ComboboxElement;12isActive: boolean;13className?: string;14onSelected: (id: string) => void;15onFocused: (id: string) => void;16};17export const ComboboxItem: FC<Props> = ({ element, isActive, className, onSelected, onFocused }) => {18let selectionClasses = `bg-pk-surface-secondary/25 font-normal focus:text-accent-foreground cursor-default select-none`;19if (isActive) {20selectionClasses = `bg-pk-content-secondary/10 cursor-pointer focus:outline-none focus:ring-0`;21}22if (!element.isSelectable) {23selectionClasses = ``;24}2526return (27<li28id={element.id}29className={cn("h-min rounded-lg flex items-center px-2 py-1.5", selectionClasses, className)}30onMouseDown={() => {31if (element.isSelectable) {32onSelected(element.id);33}34}}35onMouseOver={() => onFocused(element.id)}36onFocus={() => onFocused(element.id)}37>38{element.element}39</li>40);41};424344