'use client' import { forwardRef, useRef } from 'react' import { CommandList_Shadcn_, cn } from 'ui' import { CommandItem, type ICommand } from '../internal/Command' import { CommandEmpty } from '../internal/CommandEmpty' import { CommandGroup } from '../internal/CommandGroup' import { useCommands } from './hooks/commandsHooks' import { useQuery } from './hooks/queryHooks' import { TextHighlighter } from './TextHighlighter' const CommandList = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => { const commandSections = useCommands() const query = useQuery() const innerRef = useRef(undefined) const setInnerRef = (elem: HTMLDivElement) => (innerRef.current = elem) const setRef = (elem: HTMLDivElement) => { if (ref) typeof ref === 'function' ? ref(elem) : (ref.current = elem) setInnerRef(elem) } return ( No results found. {commandSections.map((section) => { if (section.commands.every((command) => command.defaultHidden) && !query) return null return ( {section.commands .filter((command) => !command.defaultHidden || query) .map((_command) => { const command = _command as ICommand // strip the readonly applied from the proxy return ( {command.name} ) })} ) })} ) }) CommandList.displayName = CommandList_Shadcn_.displayName export { CommandList }