/* * Portions of this file are based on code from react-spectrum. * Apache License Version 2.0, Copyright 2020 Adobe. * * Credits to the React Spectrum team: * https://github.com/adobe/react-spectrum/blob/22cb32d329e66c60f55d4fc4025d1d44bb015d71/packages/@react-aria/listbox/src/useListBox.ts */ import { Key, OverrideComponentProps, access, composeEventHandlers, createGenerateId, mergeDefaultProps, mergeRefs, } from "@kobalte/utils"; import { type Accessor, type JSX, Match, Show, Switch, type ValidComponent, createMemo, createUniqueId, splitProps, } from "solid-js"; import { type ListState, createListState, createSelectableList } from "../list"; import { type ElementOf, Polymorphic, type PolymorphicProps, } from "../polymorphic"; import type { Collection, CollectionNode } from "../primitives"; import type { FocusStrategy, KeyboardDelegate, SelectionBehavior, SelectionMode, } from "../selection"; import { ListboxContext, type ListboxContextValue } from "./listbox-context"; export interface ListboxRootOptions { /** The controlled value of the listbox. */ value?: Iterable; /** * The value of the listbox when initially rendered. * Useful when you do not need to control the state. */ defaultValue?: Iterable; /** Event handler called when the value changes. */ onChange?: (value: Set) => void; /** An array of options to display as the available options. */ options?: Array