import * as React from "react" import { Command } from "cmdk" import { CommandSeparator, CommandShortcut } from "@/components/ui/command" import { LaIcon } from "@/components/custom/la-icon" import { CommandItemType, CommandAction } from "./command-data" import { HTMLLikeElement, renderHTMLLikeElement } from "@/lib/utils" export interface CommandItemProps extends Omit { action: CommandAction handleAction: (action: CommandAction, payload?: any) => void } const HTMLLikeRenderer: React.FC<{ content: HTMLLikeElement | string }> = ({ content, }) => { return {renderHTMLLikeElement(content)} } HTMLLikeRenderer.displayName = "HTMLLikeRenderer" export const CommandItem: React.FC = ({ icon, label, action, payload, shortcut, handleAction, ...item }) => ( handleAction(action, payload)} > {icon && } {shortcut && {shortcut}} ) CommandItem.displayName = "CommandItem" export interface CommandGroupProps { heading?: string items: CommandItemType[] handleAction: (action: CommandAction, payload?: any) => void isLastGroup: boolean } export const CommandGroup: React.FC = ({ heading, items, handleAction, isLastGroup, }) => { return ( <> {heading ? ( {items.map((item, index) => ( ))} ) : ( items.map((item, index) => ( )) )} {!isLastGroup && } ) } CommandGroup.displayName = "CommandGroup"