1 | import {
|
2 | SealedInitialState,
|
3 | useSealedState,
|
4 | } from "reakit-utils/useSealedState";
|
5 | import {
|
6 | useCompositeState,
|
7 | CompositeState,
|
8 | CompositeActions,
|
9 | CompositeInitialState,
|
10 | } from "../Composite/CompositeState";
|
11 | import {
|
12 | ComboboxBaseState,
|
13 | ComboboxBaseActions,
|
14 | ComboboxBaseInitialState,
|
15 | useComboboxBaseState,
|
16 | } from "./__utils/ComboboxBaseState";
|
17 |
|
18 | export function unstable_useComboboxListState(
|
19 | initialState: SealedInitialState<unstable_ComboboxListInitialState> = {}
|
20 | ): unstable_ComboboxListStateReturn {
|
21 | const {
|
22 | currentId = null,
|
23 | orientation = "vertical",
|
24 | loop = true,
|
25 | ...sealed
|
26 | } = useSealedState(initialState);
|
27 |
|
28 | const composite = useCompositeState({
|
29 | currentId,
|
30 | orientation,
|
31 | loop,
|
32 | ...sealed,
|
33 | unstable_virtual: true,
|
34 | unstable_includesBaseElement: true,
|
35 | });
|
36 |
|
37 | return useComboboxBaseState(composite, sealed);
|
38 | }
|
39 |
|
40 | export type unstable_ComboboxListState = ComboboxBaseState<CompositeState>;
|
41 |
|
42 | export type unstable_ComboboxListActions = ComboboxBaseActions<CompositeActions>;
|
43 |
|
44 | export type unstable_ComboboxListInitialState = Omit<
|
45 | CompositeInitialState,
|
46 | "unstable_virtual" | "unstable_includesBaseElement"
|
47 | > &
|
48 | ComboboxBaseInitialState;
|
49 |
|
50 | export type unstable_ComboboxListStateReturn = unstable_ComboboxListState &
|
51 | unstable_ComboboxListActions;
|