@lumx/core 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.
@@ -47,6 +47,15 @@ export declare function getActiveOption(): HTMLElement | null;
47
47
  * Exported so TestStories.tsx can reuse the same templates for browser-only tests.
48
48
  */
49
49
  export declare function createTemplates(Combobox: ComboboxNamespace, IconButton: any): {
50
+ listChangeTemplate: ({ value, onChange, onOpen, }: {
51
+ value: string;
52
+ onChange: (v: string) => void;
53
+ onOpen?: (isOpen: boolean) => void;
54
+ }) => import("react").JSX.Element;
55
+ autoFilterListChangeTemplate: ({ value, onChange }: {
56
+ value: string;
57
+ onChange: (v: string) => void;
58
+ }) => import("react").JSX.Element;
50
59
  inlineTemplate: ({ value, onChange, onSelect, alwaysOpen, }: {
51
60
  value: string;
52
61
  onChange: (v: string) => void;
@@ -1,6 +1,6 @@
1
1
  export { setupComboboxInput } from './setupComboboxInput';
2
2
  export { setupComboboxButton } from './setupComboboxButton';
3
- export type { ComboboxCallbacks, ComboboxHandle } from './types';
3
+ export type { ComboboxCallbacks, ComboboxEventMap, ComboboxHandle } from './types';
4
4
  export { ComboboxPopover } from './ComboboxPopover';
5
5
  export type { ComboboxPopoverProps, ComboboxPopoverComponents } from './ComboboxPopover';
6
6
  export { ComboboxButton } from './ComboboxButton';
@@ -1,24 +1,26 @@
1
1
  import type { ComboboxCallbacks, ComboboxHandle, OnTriggerAttach } from './types';
2
- /** Options for configuring the shared combobox behavior. */
3
- interface ListboxOptions {
2
+ /** Options of {@link setupCombobox}: the callbacks, and the shared combobox behavior options. */
3
+ interface SetupComboboxOptions extends ComboboxCallbacks {
4
4
  /** When true, ArrowDown/ArrowUp wrap around in listbox mode (input pattern). Default: false. */
5
5
  wrapNavigation?: boolean;
6
+ /**
7
+ * Called when the trigger is registered and the signal is ready. Used by the mode-specific wrappers
8
+ * (setupComboboxInput/Button) to attach the controller of their mode.
9
+ */
10
+ onTriggerAttach?: OnTriggerAttach;
6
11
  }
7
12
  /**
8
- * Set up combobox behavior (WAI-ARIA combobox pattern) on a trigger + listbox pair.
13
+ * Set up combobox behavior (WAI-ARIA combobox pattern) on a trigger + list pair.
9
14
  *
10
- * The trigger and listbox are registered separately via the returned handle,
15
+ * The trigger and the list are registered separately via the returned handle,
11
16
  * allowing framework components to register them on mount. The behavior is
12
- * fully attached once both are registered.
17
+ * fully attached once both are registered. The list is late-bound: the list component attaches its
18
+ * composite handle with `handle.attachList`.
13
19
  *
14
20
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/combobox/
15
21
  *
16
- * @param callbacks Callbacks invoked on combobox events (e.g. option selection).
17
- * @param options Options for configuring the shared combobox behavior.
18
- * @param onTriggerAttach Optional callback invoked when the trigger is registered and the signal is ready.
19
- * Used by mode-specific wrappers (setupComboboxInput/Button) to automatically
20
- * attach the appropriate controller.
22
+ * @param options The callbacks (e.g. option selection) and the shared combobox behavior options.
21
23
  * @returns A ComboboxHandle for interacting with the combobox.
22
24
  */
23
- export declare function setupCombobox(callbacks: ComboboxCallbacks, options?: ListboxOptions, onTriggerAttach?: OnTriggerAttach): ComboboxHandle;
25
+ export declare function setupCombobox(options?: SetupComboboxOptions): ComboboxHandle;
24
26
  export {};
@@ -3,8 +3,8 @@ import type { ComboboxCallbacks, ComboboxHandle } from './types';
3
3
  * Set up a combobox with a button trigger (select-only pattern).
4
4
  *
5
5
  * Creates a full combobox handle with the button-mode controller automatically
6
- * wired in and the trigger registered. The consumer only needs to call
7
- * `handle.list.mount(listbox)`.
6
+ * wired in and the trigger registered. The consumer only needs to attach the list
7
+ * with `handle.attachList(setupListbox)`.
8
8
  *
9
9
  * Handles what is button-specific: click (toggle), Space (open), Tab and Alt+ArrowUp (select),
10
10
  * and "open first" for Home/End, ArrowLeft/Right and typeahead. The navigation itself is
@@ -20,8 +20,8 @@ export interface SetupComboboxInputOptions extends ComboboxCallbacks, ComboboxIn
20
20
  * Set up a combobox with an input trigger (autocomplete/filter pattern).
21
21
  *
22
22
  * Creates a full combobox handle with the input-mode controller automatically
23
- * wired in and the trigger registered. The consumer only needs to call
24
- * `handle.list.mount(listbox)`.
23
+ * wired in and the trigger registered. The consumer only needs to attach the list
24
+ * with `handle.attachList(setupListbox)`.
25
25
  *
26
26
  * Handles: Home/End (text cursor), ArrowLeft/Right (clear active descendant),
27
27
  * filtering (on input and on open), and focus behavior.
@@ -1,4 +1,4 @@
1
- import type { ListboxHandle } from '../Listbox/types';
1
+ import type { CompositeEventMap, CompositeEventSource, CompositeHandle, CompositeOptions } from '../Composite/types';
2
2
  /** Callbacks provided by the consumer (React/Vue) to react to combobox state changes. */
3
3
  export interface ComboboxCallbacks {
4
4
  /** Called when an option is selected (click or keyboard). */
@@ -43,36 +43,74 @@ export interface ComboboxInputOptions {
43
43
  */
44
44
  selectionMode?: 'fill' | 'keep' | 'clear';
45
45
  }
46
+ /**
47
+ * Map of combobox event names to their payload types.
48
+ *
49
+ * The combobox owns `open`, `expanded` and `composite`. The other events are the ones of the attached list (see
50
+ * {@link CompositeEventMap}): the combobox forwards them from the current list, re-subscribes when the list
51
+ * changes, and then dispatches the snapshot of the new list (`undefined` when no list is attached).
52
+ */
53
+ export interface ComboboxEventMap extends CompositeEventMap {
54
+ /**
55
+ * Fired when the popup opens or closes (see {@link ComboboxHandle.setIsOpen}).
56
+ * Owned by the combobox (it exists before any list registers) and forwarded to the registered list.
57
+ * Replayed on subscribe while open.
58
+ */
59
+ open: boolean;
60
+ /**
61
+ * Fired when the trigger `aria-expanded` changes: the popup is open and the list has something to show
62
+ * (visible items or root skeletons, see {@link CompositeHandle.hasVisibleContent}).
63
+ */
64
+ expanded: boolean;
65
+ /**
66
+ * Fired when a composite (listbox, grid, tree, …) attaches as the list of the combobox, or detaches (see
67
+ * {@link ComboboxHandle.attachList}). Payload: the composite handle, or null.
68
+ */
69
+ composite: CompositeHandle | null;
70
+ }
46
71
  /**
47
72
  * Handle returned by `setupCombobox`. Used by framework wrappers and mode controllers.
48
73
  *
49
- * The combobox owns the trigger. Everything else (the open state, the option registry, the filter,
50
- * the focus navigation, the selection, the loading state and all the events) is on the
51
- * {@link ListboxHandle} exposed as `list`: the listbox element is mounted with `list.mount(element)`.
52
- * The combobox open state is the listbox `open` event.
74
+ * The combobox owns the trigger and the popup open state. The list is late-bound: the list component
75
+ * attaches its own composite handle (e.g. `setupListbox`) with {@link ComboboxHandle.attachList}. The list
76
+ * owns the item registry, the filter, the focus navigation, the selection, the loading state and the list events.
53
77
  */
54
- export interface ComboboxHandle {
78
+ export interface ComboboxHandle extends CompositeEventSource<ComboboxEventMap> {
55
79
  /** Register the trigger element. Returns a cleanup function. */
56
80
  registerTrigger(trigger: HTMLInputElement | HTMLButtonElement): () => void;
57
- /** Tear down all listeners and state. */
81
+ /**
82
+ * Create the list handle with the combobox list options, and register it: the current open state is
83
+ * forwarded to it. Attaching another list replaces the previous one.
84
+ *
85
+ * The list options link the list to the combobox: the trigger is the focus owner (`aria-activedescendant`,
86
+ * `aria-haspopup` and the inline detection on mount), a single selection closes the popup, and the input
87
+ * trigger wraps the navigation.
88
+ *
89
+ * Returns the list and `detach`, which unregisters the list (if it is still the current one), then destroys it.
90
+ */
91
+ attachList<H extends CompositeHandle>(createList: (options: CompositeOptions) => H): {
92
+ list: H;
93
+ detach(): void;
94
+ };
95
+ /** Tear down all listeners and state (the attached list is unregistered, not destroyed: its `detach` destroys it). */
58
96
  destroy(): void;
59
97
  /** The current trigger element (may be null before registration). */
60
98
  readonly trigger: HTMLInputElement | HTMLButtonElement | null;
61
- /** The listbox handle (option registry, filter, focus navigation, selection, listbox events). */
62
- readonly list: ListboxHandle;
63
- /** Whether the popup is open (same as `list.isOpen`). */
99
+ /** The attached list handle (null until a list attaches). */
100
+ readonly list: CompositeHandle | null;
101
+ /** Whether the popup is open. */
64
102
  readonly isOpen: boolean;
65
- /** Whether the listbox is always open (see {@link ComboboxHandle.setAlwaysOpen}). */
103
+ /** Whether the list is always open (see {@link ComboboxHandle.setAlwaysOpen}). */
66
104
  readonly alwaysOpen: boolean;
67
105
  /**
68
- * Set the open state and update ARIA. Subscribe to `list` `open` to observe it.
106
+ * Set the open state and update ARIA. Subscribe to `open` to observe it.
69
107
  * When always open, a close request only clears the active option.
70
108
  */
71
109
  setIsOpen(isOpen: boolean): void;
72
110
  /**
73
- * Force the listbox always open (inline listbox, not in a popup) or not. With `false`, the listbox uses the
74
- * open/close behavior (the listbox closes). When always open, focus out, selection and Escape do not
75
- * close the listbox. With `undefined` (default), the listbox is always open when it is mounted outside of a
111
+ * Force the list always open (inline list, not in a popup) or not. With `false`, the list uses the
112
+ * open/close behavior (the list closes). When always open, focus out, selection and Escape do not
113
+ * close the list. With `undefined` (default), the list is always open when it is mounted outside of a
76
114
  * `Combobox.Popover`.
77
115
  */
78
116
  setAlwaysOpen(alwaysOpen: boolean | undefined): void;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@floating-ui/dom": "^1.7.5",
10
- "@lumx/icons": "^4.28.0-next.0",
10
+ "@lumx/icons": "^4.28.0-next.1",
11
11
  "classnames": "^2.3.2",
12
12
  "focus-visible": "^5.0.2",
13
13
  "lodash": "4.18.1",
@@ -66,7 +66,7 @@
66
66
  "update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
67
67
  },
68
68
  "sideEffects": false,
69
- "version": "4.28.0-next.0",
69
+ "version": "4.28.0-next.1",
70
70
  "devDependencies": {
71
71
  "@rollup/plugin-typescript": "^12.3.0",
72
72
  "@testing-library/dom": "^10.4.1",