// packages/core/src/components/command-palette/command-palette.props.ts
import { z } from "zod/v4";
import type { JSX } from "solid-js";
import type { ComponentMeta } from "../../meta";

export const CommandPaletteRootPropsSchema = z.object({
  value: z.string().optional().describe("Controlled selected item value"),
  defaultValue: z.string().optional().describe("Initial selected item (uncontrolled)"),
  search: z.string().optional().describe("Controlled search input value"),
  defaultSearch: z.string().optional().describe("Initial search value (uncontrolled)"),
  loop: z.boolean().optional().describe("Whether keyboard navigation wraps. Defaults to true"),
  filter: z.boolean().optional().describe("Whether built-in filtering is enabled. Defaults to true"),
});

export interface CommandPaletteRootProps extends z.infer<typeof CommandPaletteRootPropsSchema> {
  onValueChange?: (value: string) => void;
  onSearchChange?: (search: string) => void;
  onSelect?: (value: string) => void;
  children: JSX.Element;
}

export interface CommandPaletteInputProps
  extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "value" | "onInput"> {
  placeholder?: string;
}

export interface CommandPaletteListProps extends JSX.HTMLAttributes<HTMLDivElement> {
  children: JSX.Element;
}

export interface CommandPaletteItemProps extends JSX.HTMLAttributes<HTMLDivElement> {
  value: string;
  keywords?: string[];
  disabled?: boolean;
  onSelect?: () => void;
  children?: JSX.Element;
}

export interface CommandPaletteGroupProps extends JSX.HTMLAttributes<HTMLDivElement> {
  heading?: string;
  children: JSX.Element;
}

export interface CommandPaletteEmptyProps extends JSX.HTMLAttributes<HTMLDivElement> {
  children?: JSX.Element;
}

export interface CommandPaletteSeparatorProps extends JSX.HTMLAttributes<HTMLDivElement> {}

export const CommandPaletteMeta: ComponentMeta = {
  name: "CommandPalette",
  description:
    "Search-driven command menu for finding and executing actions, with keyboard navigation and grouping",
  parts: ["Root", "Input", "List", "Item", "Group", "Empty", "Separator"] as const,
  requiredParts: ["Root", "Input", "List", "Item"] as const,
} as const;
