'use client'; import React from 'react'; import { cn } from '@/lib/utils'; import { Dialog, DialogContent } from '@/components/ui/dialog'; import { RiSearchLine, RiCloseLine } from '@remixicon/react'; import { Button } from '@/components/ui/button'; // A command palette in the shadcn shape, implemented on this project's own // Dialog rather than cmdk so it stays dependency-free. Filtering is left to the // caller, which suits async sources like the Storefront API. function Command({ className, ...props }: React.ComponentProps<'div'>) { return (
); } interface CommandDialogProps { open: boolean; onOpenChange: (open: boolean) => void; children: React.ReactNode; className?: string; } function CommandDialog({ open, onOpenChange, children, className, }: CommandDialogProps) { // Dialog portals straight into document.body, so hold off until mounted or // prerendering this component's page throws "document is not defined". const [mounted, setMounted] = React.useState(false); React.useEffect(() => setMounted(true), []); if (!mounted) return null; return ( {children} ); } interface CommandInputProps extends Omit, 'onChange'> { onValueChange?: (value: string) => void; onClear?: () => void; onClose?: () => void; } function CommandInput({ className, value, onValueChange, onClear, onClose, ...props }: CommandInputProps) { const hasValue = Boolean(String(value ?? '').length); return (
onValueChange?.(event.target.value)} className={cn( 'flex h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground', className )} {...props} /> {hasValue && onClear && ( )} {onClose && ( )}
); } function CommandList({ className, ...props }: React.ComponentProps<'div'>) { return (
); } function CommandEmpty({ className, ...props }: React.ComponentProps<'div'>) { return (
); } interface CommandGroupProps extends React.ComponentProps<'div'> { heading?: string; } function CommandGroup({ className, heading, children, ...props }: CommandGroupProps) { return (
{heading && (
{heading}
)} {children}
); } function CommandItem({ className, ...props }: React.ComponentProps<'div'>) { return (
); } function CommandSeparator({ className, ...props }: React.ComponentProps<'div'>) { return (
); } export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator, };