@lumx/vue 4.28.0-next.0 → 4.28.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,8 @@ export interface ComboboxProviderProps {
13
13
  *
14
14
  * Provides shared context to sub-components. The vanilla JS combobox handle is
15
15
  * created by the trigger sub-component (Combobox.Input or Combobox.Button) on mount.
16
+ * The list handle is created by the list component, which registers it on the combobox handle:
17
+ * the provider shares the registered list with the sub-components (composite context).
16
18
  *
17
19
  * @param props Component props.
18
20
  * @return Vue element.
@@ -21,3 +21,5 @@ export declare function provideComboboxContext(value: ComboboxContextValue): voi
21
21
  * @returns The combobox context value.
22
22
  */
23
23
  export declare function useComboboxContext(): ComboboxContextValue;
24
+ /** Access the Combobox context, or `undefined` outside of a Combobox (does not throw). */
25
+ export declare function useOptionalComboboxContext(): ComboboxContextValue | undefined;
@@ -1,10 +1,11 @@
1
1
  import { Ref } from 'vue';
2
- import { CompositeEventMap } from '@lumx/core/js/components/Composite/types';
2
+ import { ComboboxEventMap } from '@lumx/core/js/components/Combobox/types';
3
3
  /**
4
- * Composable to subscribe to a combobox event (`open`, `optionsChange`, `loadingChange`,
4
+ * Composable to subscribe to a combobox event (`open`, `expanded`, `optionsChange`, `loadingChange`,
5
5
  * `activeDescendantChange`, …). Must be used within a `Combobox.Provider`.
6
6
  *
7
- * The events are dispatched by the listbox handle of the combobox (see {@link useCompositeEvent}).
8
- * `optionsChange` updates are coalesced (see `useCompositeEvent`).
7
+ * The combobox handle owns the `open` and `expanded` events (even before a list registers) and forwards the other events
8
+ * from the registered list: it re-subscribes when the registered list changes and dispatches the snapshot of
9
+ * the new list (see `ComboboxEventMap`). `optionsChange` updates are coalesced (see `useCompositeEvent`).
9
10
  */
10
- export declare function useComboboxEvent<K extends keyof CompositeEventMap>(event: K, initialValue: CompositeEventMap[K]): Ref<CompositeEventMap[K]>;
11
+ export declare function useComboboxEvent<K extends keyof ComboboxEventMap>(event: K, initialValue: ComboboxEventMap[K]): Ref<ComboboxEventMap[K]>;
@@ -4,11 +4,11 @@ import { CompositeHandle, CompositeType } from '@lumx/core/js/components/Composi
4
4
  * Context value shared by the sub-components of a composite widget (a list, a grid, …): the list,
5
5
  * its items, sections, skeletons and state.
6
6
  *
7
- * Provided by `ListboxProvider` (standalone listbox) and by `Combobox.Provider` (listbox of a combobox),
8
- * then re-provided by the list with its `type`.
7
+ * Provided by `ListboxProvider` (standalone listbox) and by `Combobox.Provider` (the list registered on
8
+ * the combobox, with `comboboxListId`), then re-provided by the list with its `type`, without `comboboxListId`.
9
9
  */
10
10
  export interface CompositeContextValue {
11
- /** The composite handle (null inside a combobox until the trigger creates it). */
11
+ /** The composite handle (null inside a combobox until a list registers). */
12
12
  handle: Readonly<Ref<CompositeHandle | null>>;
13
13
  /** The ID of the composite element. */
14
14
  id: string;
@@ -21,6 +21,13 @@ export interface CompositeContextValue {
21
21
  selectionType?: 'single' | 'multiple';
22
22
  /** The nesting level of the items (0 or undefined: root items). A skeleton is nested when it is above 0. */
23
23
  level?: number;
24
+ /**
25
+ * The ID of the list of the combobox (the trigger `aria-controls` it). Set by `Combobox.Provider` only: a list
26
+ * is the combobox list when its nearest composite context carries it. The list, its items and a nested
27
+ * `ListboxProvider` provide their own context without it, so a list rendered inside them is standalone.
28
+ * (At that level, it is the same value as `id`.)
29
+ */
30
+ comboboxListId?: string;
24
31
  }
25
32
  /** Provide the composite context (see `ListboxProvider` and `Combobox.Provider`). */
26
33
  export declare function provideCompositeContext(value: CompositeContextValue): void;
@@ -1,9 +1,10 @@
1
1
  import { Ref } from 'vue';
2
2
  import { CompositeEventMap, CompositeEventSource } from '@lumx/core/js/components/Composite/types';
3
3
  /**
4
- * Subscribe to an event of a handle (a composite handle). Re-subscribes when the handle changes, then starts from
5
- * the new handle snapshot (or `initialValue` while there is no handle or until the event has fired at least once),
6
- * so it never keeps the value of the previous handle. An `undefined` notification resets the value to
7
- * `initialValue` the same way.
4
+ * Subscribe to an event of a handle (a composite handle, or the combobox handle, which has the composite events and
5
+ * its own). Re-subscribes when the handle changes, then starts from the new handle snapshot (or `initialValue` while
6
+ * there is no handle or until the event has fired at least once), so it never keeps the value of the previous
7
+ * handle. An `undefined` notification (e.g. the combobox list detached) resets the value to `initialValue` the same
8
+ * way.
8
9
  */
9
10
  export declare function useCompositeEvent<M extends CompositeEventMap, K extends keyof M>(handle: Readonly<Ref<CompositeEventSource<M> | null>>, event: K, initialValue: M[K]): Ref<M[K]>;
@@ -0,0 +1,31 @@
1
+ import { Ref } from 'vue';
2
+ import { CompositeHandle, CompositeOptions } from '@lumx/core/js/components/Composite/types';
3
+ /** Options of {@link useCompositeList}. */
4
+ export interface UseCompositeListOptions<H extends CompositeHandle> {
5
+ /** The list element, mounted on the handle. */
6
+ elementRef: Readonly<Ref<HTMLElement | null>>;
7
+ /** Create the list handle (e.g. `setupListbox`) with the combobox list options. */
8
+ createList(options: CompositeOptions): H;
9
+ /** Standalone list: the handle of the list provider above the list (e.g. `ListboxProvider`). */
10
+ standaloneHandle: Readonly<Ref<H | null>>;
11
+ }
12
+ /** Result of {@link useCompositeList}. */
13
+ export interface UseCompositeListResult<H extends CompositeHandle> {
14
+ /** The list handle (null inside a combobox until the trigger mounts). */
15
+ handle: Readonly<Ref<H | null>>;
16
+ /** Whether the items are visible (standalone: always; combobox: while open). */
17
+ isOpen: Readonly<Ref<boolean>>;
18
+ /** Whether root skeletons are registered (`aria-busy` on the list). */
19
+ isLoading: Readonly<Ref<boolean>>;
20
+ }
21
+ /**
22
+ * Set up the handle of a list component (e.g. `Combobox.List`, `Listbox.List`):
23
+ * - The list is the combobox list when its nearest composite context is the one of `Combobox.Provider` (it
24
+ * carries `comboboxListId`). Set on setup.
25
+ * - Combobox list: attach the handle (linked to the trigger) when the combobox handle exists, then detach it on
26
+ * unmount or when the combobox handle changes.
27
+ * - Standalone list: the handle of the list provider.
28
+ * - Mount the list element on the handle.
29
+ * - Replay the pending keyboard navigation after the items render on open.
30
+ */
31
+ export declare function useCompositeList<H extends CompositeHandle>(options: UseCompositeListOptions<H>): UseCompositeListResult<H>;
@@ -9,11 +9,12 @@ export type ListboxListProps = VueToJSXProps<UIProps, 'aria-label' | 'aria-busy'
9
9
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
10
10
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/grid/
11
11
  *
12
- * Mounts the listbox handle of the enclosing provider on its element:
13
- * - Inside a combobox (`Combobox.Provider`): renders its options only while the combobox is open.
14
- * The trigger owns focus.
12
+ * Mounts a listbox handle on its element:
13
+ * - Inside a combobox (`Combobox.Provider`): creates the listbox handle with the combobox list options and
14
+ * registers it on the combobox. Renders its options only while the combobox is open. The trigger owns focus.
15
15
  * - Inside a `ListboxProvider`: a standalone list that owns focus (`tabindex="0"` +
16
- * `aria-activedescendant`) and handles its own keyboard navigation.
16
+ * `aria-activedescendant`) and handles its own keyboard navigation. A `ListboxProvider` nested
17
+ * in a combobox wins (the list stays standalone and does not register on the combobox).
17
18
  *
18
19
  * @param props Component props.
19
20
  * @return Vue element.