local-frontier / src /components /ui /command.tsx
Onur Solmaz
feat: add shadcn TypeScript scaffold
b2301b7
Raw
History Blame Contribute Delete
2.26 kB
import { Command as CommandPrimitive } from "cmdk";
import * as React from "react";
import { cn } from "@/lib/utils";
function Command({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive>): React.JSX.Element {
return (
<CommandPrimitive
className={cn("flex h-full w-full flex-col overflow-hidden", className)}
{...props}
/>
);
}
function CommandInput({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive.Input>): React.JSX.Element {
return (
<div className="flex items-center border-b border-border px-3">
<CommandPrimitive.Input
className={cn(
"flex h-10 w-full bg-transparent py-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
{...props}
/>
</div>
);
}
function CommandList({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive.List>): React.JSX.Element {
return (
<CommandPrimitive.List
className={cn("max-h-72 overflow-y-auto overflow-x-hidden", className)}
{...props}
/>
);
}
function CommandEmpty({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive.Empty>): React.JSX.Element {
return (
<CommandPrimitive.Empty
className={cn("py-6 text-center text-sm", className)}
{...props}
/>
);
}
function CommandGroup({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive.Group>): React.JSX.Element {
return (
<CommandPrimitive.Group
className={cn("overflow-hidden p-1 text-foreground", className)}
{...props}
/>
);
}
function CommandItem({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive.Item>): React.JSX.Element {
return (
<CommandPrimitive.Item
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-2 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
className,
)}
{...props}
/>
);
}
export {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
};