import { type Accessor, createContext, useContext } from "solid-js"; import type { MutableRef } from "../../internals/floating-ui/types"; /** * Context shared between `` and its descendant * `` / `` parts. The context is * optional — the combobox can be rendered without chips (single-select), * so `useContext` returns `null` when there's no `` * ancestor. Callers that require it (Chip / ChipRemove) throw. */ export interface ComboboxChipsContextValue { highlightedChipIndex: Accessor; setHighlightedChipIndex: (next: number | undefined) => void; chipsRef: MutableRef>; } export const ComboboxChipsContext = createContext(null); export function useComboboxChipsContext(): ComboboxChipsContextValue | null { return useContext(ComboboxChipsContext); }