import clsx from "clsx"; import { Command as CommandPrimitive } from "cmdk"; import * as React from "react"; import { useGetKey, useGetSet } from "../../hooks"; import { useDebugEvents } from "../../utils"; import { composeEventHandlers } from "../../utils/composeEvents"; import * as styles from "./styles.module.css"; export const Command = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )) as any; Command.displayName = CommandPrimitive.displayName; Command.CommandLoading = CommandPrimitive.Loading; const INITIAL_STATE = { value: "" }; interface InputProps extends React.ComponentPropsWithoutRef { "data-id": string; onChange: (event: any) => void; } Command.CommandInput = React.forwardRef< React.ComponentRef, InputProps >(({ onChange, ...rest }, ref) => { const key = useGetKey(rest); const [{ value }, setState] = useGetSet<{ value: string }>( key, INITIAL_STATE, ); const { className, onChange: handleChange, ...props } = useDebugEvents( Object.assign(rest, { onChange: composeEventHandlers((value: string) => { setState({ value }, process.env.PREVIEW ? `onChange` : undefined); }, onChange), }), ); return ( handleChange(value)} {...props} /> ); }); Command.CommandInput.displayName = CommandPrimitive.Input.displayName; Command.CommandList = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); Command.CommandList.displayName = CommandPrimitive.List.displayName; Command.CommandEmpty = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); Command.CommandEmpty.displayName = CommandPrimitive.Empty.displayName; Command.CommandGroup = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); Command.CommandGroup.displayName = CommandPrimitive.Group.displayName; Command.CommandSeparator = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); Command.CommandSeparator.displayName = CommandPrimitive.Separator.displayName; Command.CommandItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); Command.CommandItem.displayName = CommandPrimitive.Item.displayName;