xpeditis2.0/apps/frontend/src/components/ui/command.tsx
2026-05-12 21:01:52 +02:00

71 lines
2.3 KiB
TypeScript

'use client';
import * as React from 'react';
const Command = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground ${className || ''}`}
{...props}
/>
)
);
Command.displayName = 'Command';
const CommandInput = React.forwardRef<
HTMLInputElement,
React.InputHTMLAttributes<HTMLInputElement>
>(({ className, ...props }, ref) => (
<input
ref={ref}
className={`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 ${className || ''}`}
{...props}
/>
));
CommandInput.displayName = 'CommandInput';
const CommandList = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={`max-h-[300px] overflow-y-auto overflow-x-hidden ${className || ''}`}
{...props}
/>
)
);
CommandList.displayName = 'CommandList';
const CommandEmpty = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div ref={ref} className={`py-6 text-center text-sm ${className || ''}`} {...props} />
)
);
CommandEmpty.displayName = 'CommandEmpty';
const CommandGroup = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
className={`overflow-hidden p-1 text-foreground ${className || ''}`}
{...props}
/>
)
);
CommandGroup.displayName = 'CommandGroup';
const CommandItem = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & { onSelect?: () => void }
>(({ className, onSelect, ...props }, ref) => (
<div
ref={ref}
className={`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 ${className || ''}`}
onClick={onSelect}
{...props}
/>
));
CommandItem.displayName = 'CommandItem';
export { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem };