{"version":3,"names":["dynamic","createMemo","omit","composeRefs","userRef","CompositeList","mergeRootProps","resolveClassStyle","useComboboxRootContext","ComboboxList","props","root","state","empty","flatFilteredItems","length","setListRef","el","setListElement","onKeyDown","event","disabled","readOnly","key","ai","activeIndex","preventDefault","li","listRef","current","click","internal","role","tabIndex","id","floatingRootContext","useState","undefined","onKeyDownCapture","keyboardActiveRef","onPointerMoveCapture","data-empty","userClassStyle","userProps","merged","interactions","getFloatingProps","Tag","as","element","hasItems","items","labelsRef"],"sources":["combobox-list.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { createMemo, omit } from \"solid-js\";\nimport { composeRefs, userRef } from \"../../internals/compose-refs\";\nimport { CompositeList } from \"../../internals/composite/composite-list\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type { BaseUIComponentProps } from \"../../internals/types\";\nimport { useComboboxRootContext } from \"../root/combobox-root-context\";\n\nexport interface ComboboxListState {\n\tempty: boolean;\n}\n\nexport interface ComboboxListProps\n\textends BaseUIComponentProps<\"div\", ComboboxListState> {\n\tas?: ValidComponent;\n}\n\n/**\n * A list container for the items. Renders a `<div>` element with\n * `role=\"listbox\"` and wires `<CompositeList>` so items auto-register\n * their DOM order + labels for typeahead.\n */\nexport function ComboboxList(props: ComboboxListProps): JSX.Element {\n\tconst root = useComboboxRootContext();\n\n\tconst state = createMemo<ComboboxListState>(() => ({\n\t\tempty: root.flatFilteredItems().length === 0,\n\t}));\n\n\tconst setListRef = (el: HTMLElement | null): void => {\n\t\troot.setListElement(el);\n\t};\n\n\tfunction onKeyDown(event: KeyboardEvent): void {\n\t\tif (root.disabled() || root.readOnly()) return;\n\t\tif (event.key === \"Enter\") {\n\t\t\tconst ai = root.activeIndex();\n\t\t\tif (ai == null) return;\n\t\t\tevent.preventDefault();\n\t\t\tconst li = root.listRef.current[ai];\n\t\t\tif (li) li.click();\n\t\t}\n\t}\n\n\tconst internal = {\n\t\trole: \"listbox\" as const,\n\t\ttabIndex: -1,\n\t\tget id() {\n\t\t\treturn root.floatingRootContext.useState(\"floatingId\") ?? undefined;\n\t\t},\n\t\tonKeyDown,\n\t\tonKeyDownCapture(): void {\n\t\t\troot.keyboardActiveRef.current = true;\n\t\t},\n\t\tonPointerMoveCapture(): void {\n\t\t\troot.keyboardActiveRef.current = false;\n\t\t},\n\t\tget \"data-empty\"() {\n\t\t\treturn state().empty ? \"\" : undefined;\n\t\t},\n\t};\n\n\tconst userClassStyle = resolveClassStyle(props, () => state());\n\tconst userProps = omit(props, \"as\", \"class\", \"style\", \"attrs\");\n\n\tlet merged: Record<string, unknown> = mergeRootProps(\n\t\troot.interactions.getFloatingProps(),\n\t\tinternal,\n\t);\n\tmerged = mergeRootProps(merged, userClassStyle);\n\tmerged = mergeRootProps(merged, userProps);\n\n\tconst Tag = dynamic(() => props.as ?? \"div\");\n\tconst element = (): JSX.Element => (\n\t\t<Tag {...merged} ref={composeRefs(setListRef, userRef(props))} />\n\t);\n\n\tconst hasItems = (): boolean => root.items() !== undefined;\n\n\t// In static-children mode the `dynamic()` element (and therefore the\n\t// `<Combobox.Item>` children it renders) MUST be created *inside* the\n\t// `<CompositeList>` provider so the items resolve the real\n\t// `CompositeListContext` and register their DOM order. If the element were\n\t// built in this component's own owner (e.g. `const element = <Tag/>`)\n\t// the item children would execute under ComboboxList's owner — outside the\n\t// provider — and silently fall back to the no-op context, so they would\n\t// never register, `index()` would stay `-1`, `listRef` would stay empty,\n\t// and keyboard navigation would be dead. Mirror `<Select.Positioner>`,\n\t// which inlines its `dynamic()` element inside `<CompositeList>` for the same\n\t// reason. (items-mode has no item-registration dependency, so the plain\n\t// element is fine there.)\n\treturn (\n\t\t<>\n\t\t\t{hasItems() ? (\n\t\t\t\telement()\n\t\t\t) : (\n\t\t\t\t<CompositeList\n\t\t\t\t\telementsRef={root.listRef.current}\n\t\t\t\t\tlabelsRef={root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