import type { JSX, ValidComponent } from "@solidjs/web"; import { dynamic } from "@solidjs/web"; import { omit } from "solid-js"; import { composeRefs, userRef } from "../../internals/compose-refs"; import { mergeRootProps } from "../../internals/merge-root-props"; import { resolveClassStyle } from "../../internals/resolve-class-style"; import type { BaseUIComponentProps } from "../../internals/types"; import { useSelectRootContext } from "../select-root-context"; // biome-ignore lint/complexity/noBannedTypes: public empty-state for consumer type references. export type SelectListState = {}; export interface SelectListProps extends BaseUIComponentProps<"div", SelectListState> { as?: ValidComponent; } const EMPTY_STATE: SelectListState = {}; /** * `` — an inner container for ``s that takes the * `listbox` role. */ export function SelectList(props: SelectListProps): JSX.Element { const root = useSelectRootContext(); const setListRef = (el: HTMLElement | null): void => { root.setListElement(el); }; const internal = { get id() { return `${root.id() ?? ""}-list`; }, role: "listbox" as const, get "aria-multiselectable"() { return root.multiple() ? "true" : undefined; }, // The list is the scroll container when present; keep the popup's // scroll-arrow visibility in sync with it. onScroll(event: Event & { currentTarget: HTMLElement }): void { root.scrollHandlerRef.current(event.currentTarget); }, }; const userClassStyle = resolveClassStyle(props, () => EMPTY_STATE); const userProps = omit(props, "as", "class", "style", "attrs"); let merged: Record = mergeRootProps( internal, userClassStyle, ); merged = mergeRootProps(merged, userProps); const Tag = dynamic(() => props.as ?? "div"); return ; }