{"version":3,"names":["createContext","useContext","ComboboxRootContext","useComboboxRootContext","optional","ctx","Error"],"sources":["combobox-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tBaseUIGenericEventDetails,\n\tREASONS,\n} from \"../../internals/change-event-details\";\nimport type { FloatingRootStore } from \"../../internals/floating-ui/components/floating-root-store\";\nimport type { UseInteractionsReturn } from \"../../internals/floating-ui/hooks/use-interactions\";\nimport type { MutableRef } from \"../../internals/floating-ui/types\";\nimport type { TransitionStatus } from \"../../internals/use-transition-status/use-transition-status\";\nimport type { ItemEqualityComparer } from \"../internals/item-equality\";\nimport type { Group } from \"../internals/resolve-value-label\";\nimport type { ComboboxSide } from \"../positioner/positioner-context\";\n\nexport type ComboboxRootChangeEventReason =\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.outsidePress\n\t| typeof REASONS.escapeKey\n\t| typeof REASONS.focusOut\n\t| typeof REASONS.listNavigation\n\t| typeof REASONS.inputChange\n\t| typeof REASONS.inputClear\n\t| typeof REASONS.itemPress\n\t| typeof REASONS.clearPress\n\t| typeof REASONS.inputPress\n\t| typeof REASONS.chipRemovePress\n\t| typeof REASONS.none;\n\nexport type ComboboxRootChangeEventDetails =\n\tBaseUIChangeEventDetails<ComboboxRootChangeEventReason>;\n\nexport type ComboboxRootHighlightEventReason = \"keyboard\" | \"pointer\" | \"none\";\n\nexport type ComboboxRootHighlightEventDetails = BaseUIGenericEventDetails<\n\tComboboxRootHighlightEventReason,\n\t{ index: number }\n>;\n\n/**\n * Shared state exposed through the root context. Accessors throughout so\n * consumers don't need to guard reactive reads.\n */\nexport interface ComboboxRootContextValue<Value = unknown> {\n\t// Identity\n\tid: Accessor<string | undefined>;\n\tlabelId: Accessor<string | undefined>;\n\tsetLabelId: (id: string | undefined) => void;\n\n\t// Open state + transitions\n\topen: Accessor<boolean>;\n\tmounted: Accessor<boolean>;\n\ttransitionStatus: Accessor<TransitionStatus>;\n\n\t// Input value + selection\n\tinputValue: Accessor<string>;\n\tsetInputValue: (\n\t\tnext: string,\n\t\tdetails: ComboboxRootChangeEventDetails,\n\t) => void;\n\t/**\n\t * In single-select + `\"none\"` modes this is the single selected value (or\n\t * `null`); in multi-select mode it's an array of selected values.\n\t */\n\tselectedValue: Accessor<Value | Value[] | null>;\n\tsetSelectedValue: (\n\t\tnext: Value | Value[] | null,\n\t\tdetails: ComboboxRootChangeEventDetails,\n\t) => void;\n\t/** Selection mode — drives chip/array vs. scalar semantics. */\n\tselectionMode: Accessor<\"none\" | \"single\" | \"multiple\">;\n\n\t// Active/selected indices\n\tactiveIndex: Accessor<number | null>;\n\tselectedIndex: Accessor<number | null>;\n\tsetIndices: (options: {\n\t\tactiveIndex?: number | null | undefined;\n\t\tselectedIndex?: number | null | undefined;\n\t\ttype?: ComboboxRootHighlightEventReason | undefined;\n\t}) => void;\n\n\t// Control / flags\n\tdisabled: Accessor<boolean>;\n\treadOnly: Accessor<boolean>;\n\trequired: Accessor<boolean>;\n\tautoHighlightMode: Accessor<false | \"input-change\" | \"always\">;\n\thighlightItemOnHover: Accessor<boolean>;\n\tmodal: Accessor<boolean>;\n\tloopFocus: Accessor<boolean>;\n\topenOnInputClick: Accessor<boolean>;\n\t/**\n\t * Whether list items are presented as a grid. See `grid` prop on\n\t * `<Combobox.Root>`.\n\t */\n\tgrid: Accessor<boolean>;\n\t/**\n\t * Whether items are externally virtualized. See `virtualized` prop on\n\t * `<Combobox.Root>`.\n\t */\n\tvirtualized: Accessor<boolean>;\n\titemToStringLabel: Accessor<((item: Value) => string) | undefined>;\n\titemToStringValue: Accessor<((item: Value) => string) | undefined>;\n\tisItemEqualToValue: Accessor<ItemEqualityComparer<Value, Value>>;\n\n\t// Items / filtering\n\titems: Accessor<readonly Value[] | readonly Group<Value>[] | undefined>;\n\tfilteredItems: Accessor<readonly Value[] | readonly Group<Value>[]>;\n\tflatFilteredItems: Accessor<readonly Value[]>;\n\tquery: Accessor<string>;\n\n\t// Static-children (no `items` prop) filtering. When consumers render\n\t// `<*.Item>` children directly (the cmdk \"Command\" pattern) instead of\n\t// passing `items`, there is no `flatFilteredItems` to drive empty-state /\n\t// per-item visibility. These helpers let filtering be driven by the\n\t// registered children instead:\n\t//   • `matchesQuery(value)` — whether a single item's value matches the\n\t//     current query (honoring `filter` / `filter={null}`, and the\n\t//     autocomplete `mode` static-item contract). Returns `true` when the\n\t//     query is empty or filtering is disabled.\n\t//   • `setItemVisible(token, visible)` — each item reports its live\n\t//     visibility keyed by a per-item token.\n\t//   • `visibleItemCount` — reactive count of currently-visible static\n\t//     children, read by `<*.Empty>` / `<*.List>`.\n\t// All three are inert in items-mode (visibility + empty derive from\n\t// `flatFilteredItems`).\n\tmatchesQuery: (value: Value) => boolean;\n\tsetItemVisible: (token: symbol, visible: boolean) => void;\n\tvisibleItemCount: Accessor<number>;\n\n\t// Refs shared with parts\n\tlistRef: MutableRef<Array<HTMLElement | null>>;\n\tlabelsRef: MutableRef<Array<string | null>>;\n\tpopupRef: MutableRef<HTMLElement | null>;\n\tinputRef: MutableRef<HTMLInputElement | null>;\n\temptyRef: MutableRef<HTMLElement | null>;\n\tclearRef: MutableRef<HTMLButtonElement | null>;\n\tvaluesRef: MutableRef<Value[]>;\n\tallValuesRef: MutableRef<Value[]>;\n\t/** Host ref for `<Combobox.Chips>`. Used by dismiss outside-press filter. */\n\tchipsContainerRef: MutableRef<HTMLDivElement | null>;\n\n\t// Elements (reactive)\n\ttriggerElement: Accessor<HTMLElement | null>;\n\tsetTriggerElement: (el: HTMLElement | null) => void;\n\tinputElement: Accessor<HTMLInputElement | null>;\n\tsetInputElement: (el: HTMLInputElement | null) => void;\n\tlistElement: Accessor<HTMLElement | null>;\n\tsetListElement: (el: HTMLElement | null) => void;\n\tpositionerElement: Accessor<HTMLElement | null>;\n\tsetPositionerElement: (el: HTMLElement | null) => void;\n\tpopupSide: Accessor<ComboboxSide | null>;\n\tsetPopupSide: (side: ComboboxSide | null) => void;\n\n\t// Imperative actions + setOpen\n\tsetOpen: (next: boolean, details: ComboboxRootChangeEventDetails) => void;\n\thandleSelection: (\n\t\tevent: MouseEvent | PointerEvent | KeyboardEvent,\n\t\tvalue?: Value,\n\t) => void;\n\tforceMount: () => void;\n\n\t// Floating/interactions\n\tfloatingRootContext: FloatingRootStore;\n\tinteractions: UseInteractionsReturn;\n\n\t// keyboard/pointer modality ref\n\tkeyboardActiveRef: MutableRef<boolean>;\n}\n\nexport const ComboboxRootContext =\n\tcreateContext<ComboboxRootContextValue<unknown> | null>(null);\n\nexport function useComboboxRootContext<\n\tValue = unknown,\n>(): ComboboxRootContextValue<Value>;\nexport function useComboboxRootContext<Value = unknown>(\n\toptional: true,\n): ComboboxRootContextValue<Value> | null;\nexport function useComboboxRootContext<Value = unknown>(\n\toptional?: boolean,\n): ComboboxRootContextValue<Value> | null {\n\tconst ctx = useContext(ComboboxRootContext);\n\tif (ctx == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: ComboboxRootContext is missing. Combobox parts must be placed within <Combobox.Root>.\",\n\t\t);\n\t}\n\treturn ctx as ComboboxRootContextValue<Value> | null;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAsCnE;AACA;AACA;AACA;;AA+HA,OAAO,MAAMC,mBAAmB,GAC/BF,aAAa,CAA2C,IAAI,CAAC;AAQ9D,OAAO,SAASG,sBAAsBA,CACrCC,QAAkB,EACuB;EACzC,MAAMC,GAAG,GAAGJ,UAAU,CAACC,mBAAmB,CAAC;EAC3C,IAAIG,GAAG,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IAC7B,MAAM,IAAIE,KAAK,CACd,gGACD,CAAC;EACF;EACA,OAAOD,GAAG;AACX","ignoreList":[]}